@drincs/pixi-vn-ink 1.2.2 → 1.3.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 +19 -7
- package/dist/{chunk-FZNELQSE.mjs → chunk-IMJVHDRE.mjs} +72 -68
- package/dist/{chunk-6T44XYGF.mjs → chunk-TQBTVKLJ.mjs} +1 -1
- package/dist/converter.cjs +39 -39
- package/dist/converter.mjs +39 -39
- package/dist/index.cjs +72 -68
- package/dist/index.mjs +1 -1
- package/dist/mapper.cjs +15 -15
- package/dist/mapper.mjs +15 -15
- package/dist/parser.cjs +28 -28
- package/dist/parser.mjs +28 -28
- package/dist/vite-listener.cjs +71 -71
- package/dist/vite-listener.mjs +1 -1
- package/dist/vite.cjs +67 -67
- package/dist/vite.mjs +1 -1
- package/package.json +3 -3
|
@@ -1,109 +1,113 @@
|
|
|
1
|
-
import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import D,{ZodType}from'zod';import {PixiError,createExportableElement}from'@drincs/pixi-vn';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 {NarrationManagerStatic,narration,RegisteredLabels,LabelAbstract}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {storage}from'@drincs/pixi-vn/storage';var Y0=Object.create;var Uf=Object.defineProperty;var Z0=Object.getOwnPropertyDescriptor;var Q0=Object.getOwnPropertyNames;var eC=Object.getPrototypeOf,tC=Object.prototype.hasOwnProperty;var On=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var E=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var nC=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Q0(e))!tC.call(n,i)&&i!==t&&Uf(n,i,{get:()=>e[i],enumerable:!(r=Z0(e,i))||r.enumerable});return n};var Zr=(n,e,t)=>(t=n!=null?Y0(eC(n)):{},nC(e||!n||!n.__esModule?Uf(t,"default",{value:n,enumerable:true}):t,n));var oi=E(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Y.regexpCode=Y.getEsmExportName=Y.getProperty=Y.safeStringify=Y.stringify=Y.strConcat=Y.addCodeArg=Y.str=Y._=Y.nil=Y._Code=Y.Name=Y.IDENTIFIER=Y._CodeOrName=void 0;var si=class{};Y._CodeOrName=si;Y.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var In=class extends si{constructor(e){if(super(),!Y.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};Y.Name=In;var ft=class extends si{constructor(e){super(),this._items=typeof e=="string"?[e]:e;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let e=this._items[0];return e===""||e==='""'}get str(){var e;return (e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((t,r)=>`${t}${r}`,"")}get names(){var e;return (e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((t,r)=>(r instanceof In&&(t[r.str]=(t[r.str]||0)+1),t),{})}};Y._Code=ft;Y.nil=new ft("");function qp(n,...e){let t=[n[0]],r=0;for(;r<e.length;)al(t,e[r]),t.push(n[++r]);return new ft(t)}Y._=qp;var sl=new ft("+");function Bp(n,...e){let t=[ai(n[0])],r=0;for(;r<e.length;)t.push(sl),al(t,e[r]),t.push(sl,ai(n[++r]));return pb(t),new ft(t)}Y.str=Bp;function al(n,e){e instanceof ft?n.push(...e._items):e instanceof In?n.push(e):n.push(yb(e));}Y.addCodeArg=al;function pb(n){let e=1;for(;e<n.length-1;){if(n[e]===sl){let t=mb(n[e-1],n[e+1]);if(t!==void 0){n.splice(e-1,3,t);continue}n[e++]="+";}e++;}}function mb(n,e){if(e==='""')return n;if(n==='""')return e;if(typeof n=="string")return e instanceof In||n[n.length-1]!=='"'?void 0:typeof e!="string"?`${n.slice(0,-1)}${e}"`:e[0]==='"'?n.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(n instanceof In))return `"${n}${e.slice(1)}`}function gb(n,e){return e.emptyStr()?n:n.emptyStr()?e:Bp`${n}${e}`}Y.strConcat=gb;function yb(n){return typeof n=="number"||typeof n=="boolean"||n===null?n:ai(Array.isArray(n)?n.join(","):n)}function vb(n){return new ft(ai(n))}Y.stringify=vb;function ai(n){return JSON.stringify(n).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Y.safeStringify=ai;function Cb(n){return typeof n=="string"&&Y.IDENTIFIER.test(n)?new ft(`.${n}`):qp`[${n}]`}Y.getProperty=Cb;function bb(n){if(typeof n=="string"&&Y.IDENTIFIER.test(n))return new ft(`${n}`);throw new Error(`CodeGen: invalid export name: ${n}, use explicit $id name mapping`)}Y.getEsmExportName=bb;function _b(n){return new ft(n.toString())}Y.regexpCode=_b;});var ll=E(et=>{Object.defineProperty(et,"__esModule",{value:true});et.ValueScope=et.ValueScopeName=et.Scope=et.varKinds=et.UsedValueState=void 0;var Qe=oi(),ol=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value;}},Fs;(function(n){n[n.Started=0]="Started",n[n.Completed=1]="Completed";})(Fs||(et.UsedValueState=Fs={}));et.varKinds={const:new Qe.Name("const"),let:new Qe.Name("let"),var:new Qe.Name("var")};var Is=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t;}toName(e){return e instanceof Qe.Name?e:this.name(e)}name(e){return new Qe.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return `${e}${t.index++}`}_nameGroup(e){var t,r;if(!((r=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||r===void 0)&&r.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};et.Scope=Is;var ks=class extends Qe.Name{constructor(e,t){super(t),this.prefix=e;}setValue(e,{property:t,itemIndex:r}){this.value=e,this.scopePath=(0, Qe._)`.${new Qe.Name(t)}[${r}]`;}};et.ValueScopeName=ks;var Sb=(0, Qe._)`\n`,ul=class extends Is{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Sb:Qe.nil};}get(){return this._scope}name(e){return new ks(e,this._newName(e))}value(e,t){var r;if(t.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:a}=i,s=(r=t.key)!==null&&r!==void 0?r:t.ref,o=this._values[a];if(o){let c=o.get(s);if(c)return c}else o=this._values[a]=new Map;o.set(s,i);let u=this._scope[a]||(this._scope[a]=[]),l=u.length;return u[l]=t.ref,i.setValue(t,{property:a,itemIndex:l}),i}getValue(e,t){let r=this._values[e];if(r)return r.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,r=>{if(r.scopePath===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return (0, Qe._)`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},t,r)}_reduceValues(e,t,r={},i){let a=Qe.nil;for(let s in e){let o=e[s];if(!o)continue;let u=r[s]=r[s]||new Map;o.forEach(l=>{if(u.has(l))return;u.set(l,Fs.Started);let c=t(l);if(c){let h=this.opts.es5?et.varKinds.var:et.varKinds.const;a=(0, Qe._)`${a}${h} ${l} = ${c};${this.opts._n}`;}else if(c=i?.(l))a=(0, Qe._)`${a}${c}${this.opts._n}`;else throw new ol(l);u.set(l,Fs.Completed);});}return a}};et.ValueScope=ul;});var $=E(q=>{Object.defineProperty(q,"__esModule",{value:true});q.or=q.and=q.not=q.CodeGen=q.operators=q.varKinds=q.ValueScopeName=q.ValueScope=q.Scope=q.Name=q.regexpCode=q.stringify=q.getProperty=q.nil=q.strConcat=q.str=q._=void 0;var H=oi(),Pt=ll(),cn=oi();Object.defineProperty(q,"_",{enumerable:true,get:function(){return cn._}});Object.defineProperty(q,"str",{enumerable:true,get:function(){return cn.str}});Object.defineProperty(q,"strConcat",{enumerable:true,get:function(){return cn.strConcat}});Object.defineProperty(q,"nil",{enumerable:true,get:function(){return cn.nil}});Object.defineProperty(q,"getProperty",{enumerable:true,get:function(){return cn.getProperty}});Object.defineProperty(q,"stringify",{enumerable:true,get:function(){return cn.stringify}});Object.defineProperty(q,"regexpCode",{enumerable:true,get:function(){return cn.regexpCode}});Object.defineProperty(q,"Name",{enumerable:true,get:function(){return cn.Name}});var js=ll();Object.defineProperty(q,"Scope",{enumerable:true,get:function(){return js.Scope}});Object.defineProperty(q,"ValueScope",{enumerable:true,get:function(){return js.ValueScope}});Object.defineProperty(q,"ValueScopeName",{enumerable:true,get:function(){return js.ValueScopeName}});Object.defineProperty(q,"varKinds",{enumerable:true,get:function(){return js.varKinds}});q.operators={GT:new H._Code(">"),GTE:new H._Code(">="),LT:new H._Code("<"),LTE:new H._Code("<="),EQ:new H._Code("==="),NEQ:new H._Code("!=="),NOT:new H._Code("!"),OR:new H._Code("||"),AND:new H._Code("&&"),ADD:new H._Code("+")};var Zt=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},cl=class extends Zt{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r;}render({es5:e,_n:t}){let r=e?Pt.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return `${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=ur(this.rhs,e,t)),this}get names(){return this.rhs instanceof H._CodeOrName?this.rhs.names:{}}},Vs=class extends Zt{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r;}render({_n:e}){return `${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof H.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ur(this.rhs,e,t),this}get names(){let e=this.lhs instanceof H.Name?{}:{...this.lhs.names};return $s(e,this.rhs)}},hl=class extends Vs{constructor(e,t,r,i){super(e,r,i),this.op=t;}render({_n:e}){return `${this.lhs} ${this.op}= ${this.rhs};`+e}},dl=class extends Zt{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `${this.label}:`+e}},fl=class extends Zt{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `break${this.label?` ${this.label}`:""};`+e}},pl=class extends Zt{constructor(e){super(),this.error=e;}render({_n:e}){return `throw ${this.error};`+e}get names(){return this.error.names}},ml=class extends Zt{constructor(e){super(),this.code=e;}render({_n:e}){return `${this.code};`+e}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(e,t){return this.code=ur(this.code,e,t),this}get names(){return this.code instanceof H._CodeOrName?this.code.names:{}}},ui=class extends Zt{constructor(e=[]){super(),this.nodes=e;}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1);}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:r}=this,i=r.length;for(;i--;){let a=r[i];a.optimizeNames(e,t)||(Eb(e,a.names),r.splice(i,1));}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>Rn(e,t.names),{})}},Qt=class extends ui{render(e){return "{"+e._n+super.render(e)+"}"+e._n}},gl=class extends ui{},or=class extends Qt{};or.kind="else";var kn=class n extends Qt{constructor(e,t){super(t),this.condition=e;}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===true)return this.nodes;let t=this.else;if(t){let r=t.optimizeNodes();t=this.else=Array.isArray(r)?new or(r):r;}if(t)return e===false?t instanceof n?t:t.nodes:this.nodes.length?this:new n(Wp(e),t instanceof n?[t]:t.nodes);if(!(e===false||!this.nodes.length))return this}optimizeNames(e,t){var r;if(this.else=(r=this.else)===null||r===void 0?void 0:r.optimizeNames(e,t),!!(super.optimizeNames(e,t)||this.else))return this.condition=ur(this.condition,e,t),this}get names(){let e=super.names;return $s(e,this.condition),this.else&&Rn(e,this.else.names),e}};kn.kind="if";var Vn=class extends Qt{};Vn.kind="for";var yl=class extends Vn{constructor(e){super(),this.iteration=e;}render(e){return `for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=ur(this.iteration,e,t),this}get names(){return Rn(super.names,this.iteration.names)}},vl=class extends Vn{constructor(e,t,r,i){super(),this.varKind=e,this.name=t,this.from=r,this.to=i;}render(e){let t=e.es5?Pt.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return `for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){let e=$s(super.names,this.from);return $s(e,this.to)}},Rs=class extends Vn{constructor(e,t,r,i){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=i;}render(e){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=ur(this.iterable,e,t),this}get names(){return Rn(super.names,this.iterable.names)}},li=class extends Qt{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r;}render(e){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};li.kind="func";var ci=class extends ui{render(e){return "return "+super.render(e)}};ci.kind="return";var Cl=class extends Qt{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(e,t){var r,i;return super.optimizeNames(e,t),(r=this.catch)===null||r===void 0||r.optimizeNames(e,t),(i=this.finally)===null||i===void 0||i.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&Rn(e,this.catch.names),this.finally&&Rn(e,this.finally.names),e}},hi=class extends Qt{constructor(e){super(),this.error=e;}render(e){return `catch(${this.error})`+super.render(e)}};hi.kind="catch";var di=class extends Qt{render(e){return "finally"+super.render(e)}};di.kind="finally";var bl=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
2
|
-
`:""},this._extScope=e,this._scope=new Pt.Scope({parent:e}),this._nodes=[new gl];}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let r=this._extScope.value(e,t);return (this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,i){let a=this._scope.toName(t);return r!==void 0&&i&&(this._constants[a.str]=r),this._leafNode(new cl(e,a,r)),a}const(e,t,r){return this._def(Pt.varKinds.const,e,t,r)}let(e,t,r){return this._def(Pt.varKinds.let,e,t,r)}var(e,t,r){return this._def(Pt.varKinds.var,e,t,r)}assign(e,t,r){return this._leafNode(new Vs(e,t,r))}add(e,t){return this._leafNode(new hl(e,q.operators.ADD,t))}code(e){return typeof e=="function"?e():e!==H.nil&&this._leafNode(new ml(e)),this}object(...e){let t=["{"];for(let[r,i]of e)t.length>1&&t.push(","),t.push(r),(r!==i||this.opts.es5)&&(t.push(":"),(0, H.addCodeArg)(t,i));return t.push("}"),new H._Code(t)}if(e,t,r){if(this._blockNode(new kn(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new kn(e))}else(){return this._elseNode(new or)}endIf(){return this._endBlockNode(kn,or)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new yl(e),t)}forRange(e,t,r,i,a=this.opts.es5?Pt.varKinds.var:Pt.varKinds.let){let s=this._scope.toName(e);return this._for(new vl(a,s,t,r),()=>i(s))}forOf(e,t,r,i=Pt.varKinds.const){let a=this._scope.toName(e);if(this.opts.es5){let s=t instanceof H.Name?t:this.var("_arr",t);return this.forRange("_i",0,(0, H._)`${s}.length`,o=>{this.var(a,(0, H._)`${s}[${o}]`),r(a);})}return this._for(new Rs("of",i,a,t),()=>r(a))}forIn(e,t,r,i=this.opts.es5?Pt.varKinds.var:Pt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0, H._)`Object.keys(${t})`,r);let a=this._scope.toName(e);return this._for(new Rs("in",i,a,t),()=>r(a))}endFor(){return this._endBlockNode(Vn)}label(e){return this._leafNode(new dl(e))}break(e){return this._leafNode(new fl(e))}return(e){let t=new ci;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(ci)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new Cl;if(this._blockNode(i),this.code(e),t){let a=this.name("e");this._currNode=i.catch=new hi(a),t(a);}return r&&(this._currNode=i.finally=new di,this.code(r)),this._endBlockNode(hi,di)}throw(e){return this._leafNode(new pl(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw new Error("CodeGen: not in self-balancing block");let r=this._nodes.length-t;if(r<0||e!==void 0&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=H.nil,r,i){return this._blockNode(new li(e,t,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(li)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants);}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e);}_endBlockNode(e,t){let r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof kn))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e;}};q.CodeGen=bl;function Rn(n,e){for(let t in e)n[t]=(n[t]||0)+(e[t]||0);return n}function $s(n,e){return e instanceof H._CodeOrName?Rn(n,e.names):n}function ur(n,e,t){if(n instanceof H.Name)return r(n);if(!i(n))return n;return new H._Code(n._items.reduce((a,s)=>(s instanceof H.Name&&(s=r(s)),s instanceof H._Code?a.push(...s._items):a.push(s),a),[]));function r(a){let s=t[a.str];return s===void 0||e[a.str]!==1?a:(delete e[a.str],s)}function i(a){return a instanceof H._Code&&a._items.some(s=>s instanceof H.Name&&e[s.str]===1&&t[s.str]!==void 0)}}function Eb(n,e){for(let t in e)n[t]=(n[t]||0)-(e[t]||0);}function Wp(n){return typeof n=="boolean"||typeof n=="number"||n===null?!n:(0, H._)`!${_l(n)}`}q.not=Wp;var wb=Mp(q.operators.AND);function Db(...n){return n.reduce(wb)}q.and=Db;var Ab=Mp(q.operators.OR);function Pb(...n){return n.reduce(Ab)}q.or=Pb;function Mp(n){return (e,t)=>e===H.nil?t:t===H.nil?e:(0, H._)`${_l(e)} ${n} ${_l(t)}`}function _l(n){return n instanceof H.Name?n:(0, H._)`(${n})`}});var M=E(W=>{Object.defineProperty(W,"__esModule",{value:true});W.checkStrictMode=W.getErrorPath=W.Type=W.useFunc=W.setEvaluated=W.evaluatedPropsToName=W.mergeEvaluated=W.eachItem=W.unescapeJsonPointer=W.escapeJsonPointer=W.escapeFragment=W.unescapeFragment=W.schemaRefOrVal=W.schemaHasRulesButRef=W.schemaHasRules=W.checkUnknownRules=W.alwaysValidSchema=W.toHash=void 0;var oe=$(),Ob=oi();function xb(n){let e={};for(let t of n)e[t]=true;return e}W.toHash=xb;function Tb(n,e){return typeof e=="boolean"?e:Object.keys(e).length===0?true:(Jp(n,e),!Hp(e,n.self.RULES.all))}W.alwaysValidSchema=Tb;function Jp(n,e=n.schema){let{opts:t,self:r}=n;if(!t.strictSchema||typeof e=="boolean")return;let i=r.RULES.keywords;for(let a in e)i[a]||Xp(n,`unknown keyword: "${a}"`);}W.checkUnknownRules=Jp;function Hp(n,e){if(typeof n=="boolean")return !n;for(let t in n)if(e[t])return true;return false}W.schemaHasRules=Hp;function Nb(n,e){if(typeof n=="boolean")return !n;for(let t in n)if(t!=="$ref"&&e.all[t])return true;return false}W.schemaHasRulesButRef=Nb;function Fb({topSchemaRef:n,schemaPath:e},t,r,i){if(!i){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return (0, oe._)`${t}`}return (0, oe._)`${n}${e}${(0, oe.getProperty)(r)}`}W.schemaRefOrVal=Fb;function Ib(n){return Up(decodeURIComponent(n))}W.unescapeFragment=Ib;function kb(n){return encodeURIComponent(El(n))}W.escapeFragment=kb;function El(n){return typeof n=="number"?`${n}`:n.replace(/~/g,"~0").replace(/\//g,"~1")}W.escapeJsonPointer=El;function Up(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}W.unescapeJsonPointer=Up;function Vb(n,e){if(Array.isArray(n))for(let t of n)e(t);else e(n);}W.eachItem=Vb;function Gp({mergeNames:n,mergeToName:e,mergeValues:t,resultToName:r}){return (i,a,s,o)=>{let u=s===void 0?a:s instanceof oe.Name?(a instanceof oe.Name?n(i,a,s):e(i,a,s),s):a instanceof oe.Name?(e(i,s,a),a):t(a,s);return o===oe.Name&&!(u instanceof oe.Name)?r(i,u):u}}W.mergeEvaluated={props:Gp({mergeNames:(n,e,t)=>n.if((0, oe._)`${t} !== true && ${e} !== undefined`,()=>{n.if((0, oe._)`${e} === true`,()=>n.assign(t,true),()=>n.assign(t,(0, oe._)`${t} || {}`).code((0, oe._)`Object.assign(${t}, ${e})`));}),mergeToName:(n,e,t)=>n.if((0, oe._)`${t} !== true`,()=>{e===true?n.assign(t,true):(n.assign(t,(0, oe._)`${t} || {}`),wl(n,t,e));}),mergeValues:(n,e)=>n===true?true:{...n,...e},resultToName:Kp}),items:Gp({mergeNames:(n,e,t)=>n.if((0, oe._)`${t} !== true && ${e} !== undefined`,()=>n.assign(t,(0, oe._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(n,e,t)=>n.if((0, oe._)`${t} !== true`,()=>n.assign(t,e===true?true:(0, oe._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(n,e)=>n===true?true:Math.max(n,e),resultToName:(n,e)=>n.var("items",e)})};function Kp(n,e){if(e===true)return n.var("props",true);let t=n.var("props",(0, oe._)`{}`);return e!==void 0&&wl(n,t,e),t}W.evaluatedPropsToName=Kp;function wl(n,e,t){Object.keys(t).forEach(r=>n.assign((0, oe._)`${e}${(0, oe.getProperty)(r)}`,true));}W.setEvaluated=wl;var zp={};function Rb(n,e){return n.scopeValue("func",{ref:e,code:zp[e.code]||(zp[e.code]=new Ob._Code(e.code))})}W.useFunc=Rb;var Sl;(function(n){n[n.Num=0]="Num",n[n.Str=1]="Str";})(Sl||(W.Type=Sl={}));function $b(n,e,t){if(n instanceof oe.Name){let r=e===Sl.Num;return t?r?(0, oe._)`"[" + ${n} + "]"`:(0, oe._)`"['" + ${n} + "']"`:r?(0, oe._)`"/" + ${n}`:(0, oe._)`"/" + ${n}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0, oe.getProperty)(n).toString():"/"+El(n)}W.getErrorPath=$b;function Xp(n,e,t=n.opts.strictSchema){if(t){if(e=`strict mode: ${e}`,t===true)throw new Error(e);n.self.logger.warn(e);}}W.checkStrictMode=Xp;});var pt=E(Dl=>{Object.defineProperty(Dl,"__esModule",{value:true});var ke=$(),jb={data:new ke.Name("data"),valCxt:new ke.Name("valCxt"),instancePath:new ke.Name("instancePath"),parentData:new ke.Name("parentData"),parentDataProperty:new ke.Name("parentDataProperty"),rootData:new ke.Name("rootData"),dynamicAnchors:new ke.Name("dynamicAnchors"),vErrors:new ke.Name("vErrors"),errors:new ke.Name("errors"),this:new ke.Name("this"),self:new ke.Name("self"),scope:new ke.Name("scope"),json:new ke.Name("json"),jsonPos:new ke.Name("jsonPos"),jsonLen:new ke.Name("jsonLen"),jsonPart:new ke.Name("jsonPart")};Dl.default=jb;});var fi=E(Ve=>{Object.defineProperty(Ve,"__esModule",{value:true});Ve.extendErrors=Ve.resetErrorsCount=Ve.reportExtraError=Ve.reportError=Ve.keyword$DataError=Ve.keywordError=void 0;var K=$(),Ls=M(),Je=pt();Ve.keywordError={message:({keyword:n})=>(0, K.str)`must pass "${n}" keyword validation`};Ve.keyword$DataError={message:({keyword:n,schemaType:e})=>e?(0, K.str)`"${n}" keyword must be ${e} ($data)`:(0, K.str)`"${n}" keyword is invalid ($data)`};function Lb(n,e=Ve.keywordError,t,r){let{it:i}=n,{gen:a,compositeRule:s,allErrors:o}=i,u=Qp(n,e,t);r??(s||o)?Yp(a,u):Zp(i,(0, K._)`[${u}]`);}Ve.reportError=Lb;function qb(n,e=Ve.keywordError,t){let{it:r}=n,{gen:i,compositeRule:a,allErrors:s}=r,o=Qp(n,e,t);Yp(i,o),a||s||Zp(r,Je.default.vErrors);}Ve.reportExtraError=qb;function Bb(n,e){n.assign(Je.default.errors,e),n.if((0, K._)`${Je.default.vErrors} !== null`,()=>n.if(e,()=>n.assign((0, K._)`${Je.default.vErrors}.length`,e),()=>n.assign(Je.default.vErrors,null)));}Ve.resetErrorsCount=Bb;function Wb({gen:n,keyword:e,schemaValue:t,data:r,errsCount:i,it:a}){if(i===void 0)throw new Error("ajv implementation error");let s=n.name("err");n.forRange("i",i,Je.default.errors,o=>{n.const(s,(0, K._)`${Je.default.vErrors}[${o}]`),n.if((0, K._)`${s}.instancePath === undefined`,()=>n.assign((0, K._)`${s}.instancePath`,(0, K.strConcat)(Je.default.instancePath,a.errorPath))),n.assign((0, K._)`${s}.schemaPath`,(0, K.str)`${a.errSchemaPath}/${e}`),a.opts.verbose&&(n.assign((0, K._)`${s}.schema`,t),n.assign((0, K._)`${s}.data`,r));});}Ve.extendErrors=Wb;function Yp(n,e){let t=n.const("err",e);n.if((0, K._)`${Je.default.vErrors} === null`,()=>n.assign(Je.default.vErrors,(0, K._)`[${t}]`),(0, K._)`${Je.default.vErrors}.push(${t})`),n.code((0, K._)`${Je.default.errors}++`);}function Zp(n,e){let{gen:t,validateName:r,schemaEnv:i}=n;i.$async?t.throw((0, K._)`new ${n.ValidationError}(${e})`):(t.assign((0, K._)`${r}.errors`,e),t.return(false));}var $n={keyword:new K.Name("keyword"),schemaPath:new K.Name("schemaPath"),params:new K.Name("params"),propertyName:new K.Name("propertyName"),message:new K.Name("message"),schema:new K.Name("schema"),parentSchema:new K.Name("parentSchema")};function Qp(n,e,t){let{createErrors:r}=n.it;return r===false?(0, K._)`{}`:Mb(n,e,t)}function Mb(n,e,t={}){let{gen:r,it:i}=n,a=[Gb(i,t),zb(n,t)];return Jb(n,e,a),r.object(...a)}function Gb({errorPath:n},{instancePath:e}){let t=e?(0, K.str)`${n}${(0, Ls.getErrorPath)(e,Ls.Type.Str)}`:n;return [Je.default.instancePath,(0, K.strConcat)(Je.default.instancePath,t)]}function zb({keyword:n,it:{errSchemaPath:e}},{schemaPath:t,parentSchema:r}){let i=r?e:(0, K.str)`${e}/${n}`;return t&&(i=(0, K.str)`${i}${(0, Ls.getErrorPath)(t,Ls.Type.Str)}`),[$n.schemaPath,i]}function Jb(n,{params:e,message:t},r){let{keyword:i,data:a,schemaValue:s,it:o}=n,{opts:u,propertyName:l,topSchemaRef:c,schemaPath:h}=o;r.push([$n.keyword,i],[$n.params,typeof e=="function"?e(n):e||(0, K._)`{}`]),u.messages&&r.push([$n.message,typeof t=="function"?t(n):t]),u.verbose&&r.push([$n.schema,s],[$n.parentSchema,(0, K._)`${c}${h}`],[Je.default.data,a]),l&&r.push([$n.propertyName,l]);}});var tm=E(lr=>{Object.defineProperty(lr,"__esModule",{value:true});lr.boolOrEmptySchema=lr.topBoolOrEmptySchema=void 0;var Hb=fi(),Ub=$(),Kb=pt(),Xb={message:"boolean schema is false"};function Yb(n){let{gen:e,schema:t,validateName:r}=n;t===false?em(n,false):typeof t=="object"&&t.$async===true?e.return(Kb.default.data):(e.assign((0, Ub._)`${r}.errors`,null),e.return(true));}lr.topBoolOrEmptySchema=Yb;function Zb(n,e){let{gen:t,schema:r}=n;r===false?(t.var(e,false),em(n)):t.var(e,true);}lr.boolOrEmptySchema=Zb;function em(n,e){let{gen:t,data:r}=n,i={gen:t,keyword:"false schema",data:r,schema:false,schemaCode:false,schemaValue:false,params:{},it:n};(0, Hb.reportError)(i,Xb,void 0,e);}});var Al=E(cr=>{Object.defineProperty(cr,"__esModule",{value:true});cr.getRules=cr.isJSONType=void 0;var Qb=["string","number","integer","boolean","null","object","array"],e_=new Set(Qb);function t_(n){return typeof n=="string"&&e_.has(n)}cr.isJSONType=t_;function n_(){let n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return {types:{...n,integer:true,boolean:true,null:true},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}cr.getRules=n_;});var Pl=E(hn=>{Object.defineProperty(hn,"__esModule",{value:true});hn.shouldUseRule=hn.shouldUseGroup=hn.schemaHasRulesForType=void 0;function r_({schema:n,self:e},t){let r=e.RULES.types[t];return r&&r!==true&&nm(n,r)}hn.schemaHasRulesForType=r_;function nm(n,e){return e.rules.some(t=>rm(n,t))}hn.shouldUseGroup=nm;function rm(n,e){var t;return n[e.keyword]!==void 0||((t=e.definition.implements)===null||t===void 0?void 0:t.some(r=>n[r]!==void 0))}hn.shouldUseRule=rm;});var pi=E(Re=>{Object.defineProperty(Re,"__esModule",{value:true});Re.reportTypeError=Re.checkDataTypes=Re.checkDataType=Re.coerceAndCheckDataType=Re.getJSONTypes=Re.getSchemaTypes=Re.DataType=void 0;var i_=Al(),s_=Pl(),a_=fi(),j=$(),im=M(),hr;(function(n){n[n.Correct=0]="Correct",n[n.Wrong=1]="Wrong";})(hr||(Re.DataType=hr={}));function o_(n){let e=sm(n.type);if(e.includes("null")){if(n.nullable===false)throw new Error("type: null contradicts nullable: false")}else {if(!e.length&&n.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');n.nullable===true&&e.push("null");}return e}Re.getSchemaTypes=o_;function sm(n){let e=Array.isArray(n)?n:n?[n]:[];if(e.every(i_.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Re.getJSONTypes=sm;function u_(n,e){let{gen:t,data:r,opts:i}=n,a=l_(e,i.coerceTypes),s=e.length>0&&!(a.length===0&&e.length===1&&(0, s_.schemaHasRulesForType)(n,e[0]));if(s){let o=xl(e,r,i.strictNumbers,hr.Wrong);t.if(o,()=>{a.length?c_(n,e,a):Tl(n);});}return s}Re.coerceAndCheckDataType=u_;var am=new Set(["string","number","integer","boolean","null"]);function l_(n,e){return e?n.filter(t=>am.has(t)||e==="array"&&t==="array"):[]}function c_(n,e,t){let{gen:r,data:i,opts:a}=n,s=r.let("dataType",(0, j._)`typeof ${i}`),o=r.let("coerced",(0, j._)`undefined`);a.coerceTypes==="array"&&r.if((0, j._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>r.assign(i,(0, j._)`${i}[0]`).assign(s,(0, j._)`typeof ${i}`).if(xl(e,i,a.strictNumbers),()=>r.assign(o,i))),r.if((0, j._)`${o} !== undefined`);for(let l of t)(am.has(l)||l==="array"&&a.coerceTypes==="array")&&u(l);r.else(),Tl(n),r.endIf(),r.if((0, j._)`${o} !== undefined`,()=>{r.assign(i,o),h_(n,o);});function u(l){switch(l){case "string":r.elseIf((0, j._)`${s} == "number" || ${s} == "boolean"`).assign(o,(0, j._)`"" + ${i}`).elseIf((0, j._)`${i} === null`).assign(o,(0, j._)`""`);return;case "number":r.elseIf((0, j._)`${s} == "boolean" || ${i} === null
|
|
3
|
-
|| (${s} == "string" && ${i} && ${i} == +${i})`).assign(o,(0,
|
|
4
|
-
|| (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(o,(0,
|
|
5
|
-
|| ${s} === "boolean" || ${i} === null`).assign(o,(0, j._)`[${i}]`);}}}function h_({gen:n,parentData:e,parentDataProperty:t},r){n.if((0, j._)`${e} !== undefined`,()=>n.assign((0, j._)`${e}[${t}]`,r));}function Ol(n,e,t,r=hr.Correct){let i=r===hr.Correct?j.operators.EQ:j.operators.NEQ,a;switch(n){case "null":return (0, j._)`${e} ${i} null`;case "array":a=(0, j._)`Array.isArray(${e})`;break;case "object":a=(0, j._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case "integer":a=s((0, j._)`!(${e} % 1) && !isNaN(${e})`);break;case "number":a=s();break;default:return (0, j._)`typeof ${e} ${i} ${n}`}return r===hr.Correct?a:(0, j.not)(a);function s(o=j.nil){return (0, j.and)((0, j._)`typeof ${e} == "number"`,o,t?(0, j._)`isFinite(${e})`:j.nil)}}Re.checkDataType=Ol;function xl(n,e,t,r){if(n.length===1)return Ol(n[0],e,t,r);let i,a=(0, im.toHash)(n);if(a.array&&a.object){let s=(0, j._)`typeof ${e} != "object"`;i=a.null?s:(0, j._)`!${e} || ${s}`,delete a.null,delete a.array,delete a.object;}else i=j.nil;a.number&&delete a.integer;for(let s in a)i=(0, j.and)(i,Ol(s,e,t,r));return i}Re.checkDataTypes=xl;var d_={message:({schema:n})=>`must be ${n}`,params:({schema:n,schemaValue:e})=>typeof n=="string"?(0, j._)`{type: ${n}}`:(0, j._)`{type: ${e}}`};function Tl(n){let e=f_(n);(0, a_.reportError)(e,d_);}Re.reportTypeError=Tl;function f_(n){let{gen:e,data:t,schema:r}=n,i=(0, im.schemaRefOrVal)(n,r,"type");return {gen:e,keyword:"type",data:t,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:n}}});var um=E(qs=>{Object.defineProperty(qs,"__esModule",{value:true});qs.assignDefaults=void 0;var dr=$(),p_=M();function m_(n,e){let{properties:t,items:r}=n.schema;if(e==="object"&&t)for(let i in t)om(n,i,t[i].default);else e==="array"&&Array.isArray(r)&&r.forEach((i,a)=>om(n,a,i.default));}qs.assignDefaults=m_;function om(n,e,t){let{gen:r,compositeRule:i,data:a,opts:s}=n;if(t===void 0)return;let o=(0, dr._)`${a}${(0, dr.getProperty)(e)}`;if(i){(0, p_.checkStrictMode)(n,`default is ignored for: ${o}`);return}let u=(0, dr._)`${o} === undefined`;s.useDefaults==="empty"&&(u=(0, dr._)`${u} || ${o} === null || ${o} === ""`),r.if(u,(0, dr._)`${o} = ${(0, dr.stringify)(t)}`);}});var mt=E(se=>{Object.defineProperty(se,"__esModule",{value:true});se.validateUnion=se.validateArray=se.usePattern=se.callValidateCode=se.schemaProperties=se.allSchemaProperties=se.noPropertyInData=se.propertyInData=se.isOwnProperty=se.hasPropFunc=se.reportMissingProp=se.checkMissingProp=se.checkReportMissingProp=void 0;var fe=$(),Nl=M(),dn=pt(),g_=M();function y_(n,e){let{gen:t,data:r,it:i}=n;t.if(Il(t,r,e,i.opts.ownProperties),()=>{n.setParams({missingProperty:(0, fe._)`${e}`},true),n.error();});}se.checkReportMissingProp=y_;function v_({gen:n,data:e,it:{opts:t}},r,i){return (0, fe.or)(...r.map(a=>(0, fe.and)(Il(n,e,a,t.ownProperties),(0, fe._)`${i} = ${a}`)))}se.checkMissingProp=v_;function C_(n,e){n.setParams({missingProperty:e},true),n.error();}se.reportMissingProp=C_;function lm(n){return n.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, fe._)`Object.prototype.hasOwnProperty`})}se.hasPropFunc=lm;function Fl(n,e,t){return (0, fe._)`${lm(n)}.call(${e}, ${t})`}se.isOwnProperty=Fl;function b_(n,e,t,r){let i=(0, fe._)`${e}${(0, fe.getProperty)(t)} !== undefined`;return r?(0, fe._)`${i} && ${Fl(n,e,t)}`:i}se.propertyInData=b_;function Il(n,e,t,r){let i=(0, fe._)`${e}${(0, fe.getProperty)(t)} === undefined`;return r?(0, fe.or)(i,(0, fe.not)(Fl(n,e,t))):i}se.noPropertyInData=Il;function cm(n){return n?Object.keys(n).filter(e=>e!=="__proto__"):[]}se.allSchemaProperties=cm;function __(n,e){return cm(e).filter(t=>!(0, Nl.alwaysValidSchema)(n,e[t]))}se.schemaProperties=__;function S_({schemaCode:n,data:e,it:{gen:t,topSchemaRef:r,schemaPath:i,errorPath:a},it:s},o,u,l){let c=l?(0, fe._)`${n}, ${e}, ${r}${i}`:e,h=[[dn.default.instancePath,(0, fe.strConcat)(dn.default.instancePath,a)],[dn.default.parentData,s.parentData],[dn.default.parentDataProperty,s.parentDataProperty],[dn.default.rootData,dn.default.rootData]];s.opts.dynamicRef&&h.push([dn.default.dynamicAnchors,dn.default.dynamicAnchors]);let p=(0, fe._)`${c}, ${t.object(...h)}`;return u!==fe.nil?(0, fe._)`${o}.call(${u}, ${p})`:(0, fe._)`${o}(${p})`}se.callValidateCode=S_;var E_=(0, fe._)`new RegExp`;function w_({gen:n,it:{opts:e}},t){let r=e.unicodeRegExp?"u":"",{regExp:i}=e.code,a=i(t,r);return n.scopeValue("pattern",{key:a.toString(),ref:a,code:(0, fe._)`${i.code==="new RegExp"?E_:(0, g_.useFunc)(n,i)}(${t}, ${r})`})}se.usePattern=w_;function D_(n){let{gen:e,data:t,keyword:r,it:i}=n,a=e.name("valid");if(i.allErrors){let o=e.let("valid",true);return s(()=>e.assign(o,false)),o}return e.var(a,true),s(()=>e.break()),a;function s(o){let u=e.const("len",(0, fe._)`${t}.length`);e.forRange("i",0,u,l=>{n.subschema({keyword:r,dataProp:l,dataPropType:Nl.Type.Num},a),e.if((0, fe.not)(a),o);});}}se.validateArray=D_;function A_(n){let{gen:e,schema:t,keyword:r,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(u=>(0, Nl.alwaysValidSchema)(i,u))&&!i.opts.unevaluated)return;let s=e.let("valid",false),o=e.name("_valid");e.block(()=>t.forEach((u,l)=>{let c=n.subschema({keyword:r,schemaProp:l,compositeRule:true},o);e.assign(s,(0, fe._)`${s} || ${o}`),n.mergeValidEvaluated(c,o)||e.if((0, fe.not)(s));})),n.result(s,()=>n.reset(),()=>n.error(true));}se.validateUnion=A_;});var fm=E(Vt=>{Object.defineProperty(Vt,"__esModule",{value:true});Vt.validateKeywordUsage=Vt.validSchemaType=Vt.funcKeywordCode=Vt.macroKeywordCode=void 0;var He=$(),jn=pt(),P_=mt(),O_=fi();function x_(n,e){let{gen:t,keyword:r,schema:i,parentSchema:a,it:s}=n,o=e.macro.call(s.self,i,a,s),u=dm(t,r,o);s.opts.validateSchema!==false&&s.self.validateSchema(o,true);let l=t.name("valid");n.subschema({schema:o,schemaPath:He.nil,errSchemaPath:`${s.errSchemaPath}/${r}`,topSchemaRef:u,compositeRule:true},l),n.pass(l,()=>n.error(true));}Vt.macroKeywordCode=x_;function T_(n,e){var t;let{gen:r,keyword:i,schema:a,parentSchema:s,$data:o,it:u}=n;F_(u,e);let l=!o&&e.compile?e.compile.call(u.self,a,s,u):e.validate,c=dm(r,i,l),h=r.let("valid");n.block$data(h,p),n.ok((t=e.valid)!==null&&t!==void 0?t:h);function p(){if(e.errors===false)y(),e.modifying&&hm(n),C(()=>n.error());else {let _=e.async?f():g();e.modifying&&hm(n),C(()=>N_(n,_));}}function f(){let _=r.let("ruleErrs",null);return r.try(()=>y((0, He._)`await `),v=>r.assign(h,false).if((0, He._)`${v} instanceof ${u.ValidationError}`,()=>r.assign(_,(0, He._)`${v}.errors`),()=>r.throw(v))),_}function g(){let _=(0, He._)`${c}.errors`;return r.assign(_,null),y(He.nil),_}function y(_=e.async?(0, He._)`await `:He.nil){let v=u.opts.passContext?jn.default.this:jn.default.self,d=!("compile"in e&&!o||e.schema===false);r.assign(h,(0, He._)`${_}${(0, P_.callValidateCode)(n,c,v,d)}`,e.modifying);}function C(_){var v;r.if((0, He.not)((v=e.valid)!==null&&v!==void 0?v:h),_);}}Vt.funcKeywordCode=T_;function hm(n){let{gen:e,data:t,it:r}=n;e.if(r.parentData,()=>e.assign(t,(0, He._)`${r.parentData}[${r.parentDataProperty}]`));}function N_(n,e){let{gen:t}=n;t.if((0, He._)`Array.isArray(${e})`,()=>{t.assign(jn.default.vErrors,(0, He._)`${jn.default.vErrors} === null ? ${e} : ${jn.default.vErrors}.concat(${e})`).assign(jn.default.errors,(0, He._)`${jn.default.vErrors}.length`),(0, O_.extendErrors)(n);},()=>n.error());}function F_({schemaEnv:n},e){if(e.async&&!n.$async)throw new Error("async keyword in sync schema")}function dm(n,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return n.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0, He.stringify)(t)})}function I_(n,e,t=false){return !e.length||e.some(r=>r==="array"?Array.isArray(n):r==="object"?n&&typeof n=="object"&&!Array.isArray(n):typeof n==r||t&&typeof n>"u")}Vt.validSchemaType=I_;function k_({schema:n,opts:e,self:t,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(o=>!Object.prototype.hasOwnProperty.call(n,o)))throw new Error(`parent schema must have dependencies of ${a}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(n[a])){let u=`keyword "${a}" value is invalid at path "${r}": `+t.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(u);else throw new Error(u)}}Vt.validateKeywordUsage=k_;});var mm=E(fn=>{Object.defineProperty(fn,"__esModule",{value:true});fn.extendSubschemaMode=fn.extendSubschemaData=fn.getSubschema=void 0;var Rt=$(),pm=M();function V_(n,{keyword:e,schemaProp:t,schema:r,schemaPath:i,errSchemaPath:a,topSchemaRef:s}){if(e!==void 0&&r!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let o=n.schema[e];return t===void 0?{schema:o,schemaPath:(0, Rt._)`${n.schemaPath}${(0, Rt.getProperty)(e)}`,errSchemaPath:`${n.errSchemaPath}/${e}`}:{schema:o[t],schemaPath:(0, Rt._)`${n.schemaPath}${(0, Rt.getProperty)(e)}${(0, Rt.getProperty)(t)}`,errSchemaPath:`${n.errSchemaPath}/${e}/${(0, pm.escapeFragment)(t)}`}}if(r!==void 0){if(i===void 0||a===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return {schema:r,schemaPath:i,topSchemaRef:s,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')}fn.getSubschema=V_;function R_(n,e,{dataProp:t,dataPropType:r,data:i,dataTypes:a,propertyName:s}){if(i!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:o}=e;if(t!==void 0){let{errorPath:l,dataPathArr:c,opts:h}=e,p=o.let("data",(0, Rt._)`${e.data}${(0, Rt.getProperty)(t)}`,true);u(p),n.errorPath=(0, Rt.str)`${l}${(0, pm.getErrorPath)(t,r,h.jsPropertySyntax)}`,n.parentDataProperty=(0, Rt._)`${t}`,n.dataPathArr=[...c,n.parentDataProperty];}if(i!==void 0){let l=i instanceof Rt.Name?i:o.let("data",i,true);u(l),s!==void 0&&(n.propertyName=s);}a&&(n.dataTypes=a);function u(l){n.data=l,n.dataLevel=e.dataLevel+1,n.dataTypes=[],e.definedProperties=new Set,n.parentData=e.data,n.dataNames=[...e.dataNames,l];}}fn.extendSubschemaData=R_;function $_(n,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(n.compositeRule=r),i!==void 0&&(n.createErrors=i),a!==void 0&&(n.allErrors=a),n.jtdDiscriminator=e,n.jtdMetadata=t;}fn.extendSubschemaMode=$_;});var kl=E((RI,gm)=>{gm.exports=function n(e,t){if(e===t)return true;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return false;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=t.length)return false;for(i=r;i--!==0;)if(!n(e[i],t[i]))return false;return true}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return false;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,a[i]))return false;for(i=r;i--!==0;){var s=a[i];if(!n(e[s],t[s]))return false}return true}return e!==e&&t!==t};});var vm=E(($I,ym)=>{var pn=ym.exports=function(n,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var r=typeof t=="function"?t:t.pre||function(){},i=t.post||function(){};Bs(e,r,i,n,"",n);};pn.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};pn.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};pn.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};pn.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function Bs(n,e,t,r,i,a,s,o,u,l){if(r&&typeof r=="object"&&!Array.isArray(r)){e(r,i,a,s,o,u,l);for(var c in r){var h=r[c];if(Array.isArray(h)){if(c in pn.arrayKeywords)for(var p=0;p<h.length;p++)Bs(n,e,t,h[p],i+"/"+c+"/"+p,a,i,c,r,p);}else if(c in pn.propsKeywords){if(h&&typeof h=="object")for(var f in h)Bs(n,e,t,h[f],i+"/"+c+"/"+j_(f),a,i,c,r,f);}else (c in pn.keywords||n.allKeys&&!(c in pn.skipKeywords))&&Bs(n,e,t,h,i+"/"+c,a,i,c,r);}t(r,i,a,s,o,u,l);}}function j_(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}});var mi=E(tt=>{Object.defineProperty(tt,"__esModule",{value:true});tt.getSchemaRefs=tt.resolveUrl=tt.normalizeId=tt._getFullPath=tt.getFullPath=tt.inlineRef=void 0;var L_=M(),q_=kl(),B_=vm(),W_=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function M_(n,e=true){return typeof n=="boolean"?true:e===true?!Vl(n):e?Cm(n)<=e:false}tt.inlineRef=M_;var G_=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Vl(n){for(let e in n){if(G_.has(e))return true;let t=n[e];if(Array.isArray(t)&&t.some(Vl)||typeof t=="object"&&Vl(t))return true}return false}function Cm(n){let e=0;for(let t in n){if(t==="$ref")return 1/0;if(e++,!W_.has(t)&&(typeof n[t]=="object"&&(0, L_.eachItem)(n[t],r=>e+=Cm(r)),e===1/0))return 1/0}return e}function bm(n,e="",t){t!==false&&(e=fr(e));let r=n.parse(e);return _m(n,r)}tt.getFullPath=bm;function _m(n,e){return n.serialize(e).split("#")[0]+"#"}tt._getFullPath=_m;var z_=/#\/?$/;function fr(n){return n?n.replace(z_,""):""}tt.normalizeId=fr;function J_(n,e,t){return t=fr(t),n.resolve(e,t)}tt.resolveUrl=J_;var H_=/^[a-z_][-a-z0-9._]*$/i;function U_(n,e){if(typeof n=="boolean")return {};let{schemaId:t,uriResolver:r}=this.opts,i=fr(n[t]||e),a={"":i},s=bm(r,i,false),o={},u=new Set;return B_(n,{allKeys:true},(h,p,f,g)=>{if(g===void 0)return;let y=s+p,C=a[g];typeof h[t]=="string"&&(C=_.call(this,h[t])),v.call(this,h.$anchor),v.call(this,h.$dynamicAnchor),a[p]=C;function _(d){let S=this.opts.uriResolver.resolve;if(d=fr(C?S(C,d):d),u.has(d))throw c(d);u.add(d);let m=this.refs[d];return typeof m=="string"&&(m=this.refs[m]),typeof m=="object"?l(h,m.schema,d):d!==fr(y)&&(d[0]==="#"?(l(h,o[d],d),o[d]=h):this.refs[d]=y),d}function v(d){if(typeof d=="string"){if(!H_.test(d))throw new Error(`invalid anchor "${d}"`);_.call(this,`#${d}`);}}}),o;function l(h,p,f){if(p!==void 0&&!q_(h,p))throw c(f)}function c(h){return new Error(`reference "${h}" resolves to more than one schema`)}}tt.getSchemaRefs=U_;});var pr=E(mn=>{Object.defineProperty(mn,"__esModule",{value:true});mn.getData=mn.KeywordCxt=mn.validateFunctionCode=void 0;var Am=tm(),Sm=pi(),$l=Pl(),Ws=pi(),K_=um(),yi=fm(),Rl=mm(),N=$(),V=pt(),X_=mi(),en=M(),gi=fi();function Y_(n){if(xm(n)&&(Tm(n),Om(n))){eS(n);return}Pm(n,()=>(0, Am.topBoolOrEmptySchema)(n));}mn.validateFunctionCode=Y_;function Pm({gen:n,validateName:e,schema:t,schemaEnv:r,opts:i},a){i.code.es5?n.func(e,(0, N._)`${V.default.data}, ${V.default.valCxt}`,r.$async,()=>{n.code((0, N._)`"use strict"; ${Em(t,i)}`),Q_(n,i),n.code(a);}):n.func(e,(0, N._)`${V.default.data}, ${Z_(i)}`,r.$async,()=>n.code(Em(t,i)).code(a));}function Z_(n){return (0, N._)`{${V.default.instancePath}="", ${V.default.parentData}, ${V.default.parentDataProperty}, ${V.default.rootData}=${V.default.data}${n.dynamicRef?(0, N._)`, ${V.default.dynamicAnchors}={}`:N.nil}}={}`}function Q_(n,e){n.if(V.default.valCxt,()=>{n.var(V.default.instancePath,(0, N._)`${V.default.valCxt}.${V.default.instancePath}`),n.var(V.default.parentData,(0, N._)`${V.default.valCxt}.${V.default.parentData}`),n.var(V.default.parentDataProperty,(0, N._)`${V.default.valCxt}.${V.default.parentDataProperty}`),n.var(V.default.rootData,(0, N._)`${V.default.valCxt}.${V.default.rootData}`),e.dynamicRef&&n.var(V.default.dynamicAnchors,(0, N._)`${V.default.valCxt}.${V.default.dynamicAnchors}`);},()=>{n.var(V.default.instancePath,(0, N._)`""`),n.var(V.default.parentData,(0, N._)`undefined`),n.var(V.default.parentDataProperty,(0, N._)`undefined`),n.var(V.default.rootData,V.default.data),e.dynamicRef&&n.var(V.default.dynamicAnchors,(0, N._)`{}`);});}function eS(n){let{schema:e,opts:t,gen:r}=n;Pm(n,()=>{t.$comment&&e.$comment&&Fm(n),sS(n),r.let(V.default.vErrors,null),r.let(V.default.errors,0),t.unevaluated&&tS(n),Nm(n),uS(n);});}function tS(n){let{gen:e,validateName:t}=n;n.evaluated=e.const("evaluated",(0, N._)`${t}.evaluated`),e.if((0, N._)`${n.evaluated}.dynamicProps`,()=>e.assign((0, N._)`${n.evaluated}.props`,(0, N._)`undefined`)),e.if((0, N._)`${n.evaluated}.dynamicItems`,()=>e.assign((0, N._)`${n.evaluated}.items`,(0, N._)`undefined`));}function Em(n,e){let t=typeof n=="object"&&n[e.schemaId];return t&&(e.code.source||e.code.process)?(0, N._)`/*# sourceURL=${t} */`:N.nil}function nS(n,e){if(xm(n)&&(Tm(n),Om(n))){rS(n,e);return}(0, Am.boolOrEmptySchema)(n,e);}function Om({schema:n,self:e}){if(typeof n=="boolean")return !n;for(let t in n)if(e.RULES.all[t])return true;return false}function xm(n){return typeof n.schema!="boolean"}function rS(n,e){let{schema:t,gen:r,opts:i}=n;i.$comment&&t.$comment&&Fm(n),aS(n),oS(n);let a=r.const("_errs",V.default.errors);Nm(n,a),r.var(e,(0, N._)`${a} === ${V.default.errors}`);}function Tm(n){(0, en.checkUnknownRules)(n),iS(n);}function Nm(n,e){if(n.opts.jtd)return wm(n,[],false,e);let t=(0, Sm.getSchemaTypes)(n.schema),r=(0, Sm.coerceAndCheckDataType)(n,t);wm(n,t,!r,e);}function iS(n){let{schema:e,errSchemaPath:t,opts:r,self:i}=n;e.$ref&&r.ignoreKeywordsWithRef&&(0, en.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${t}"`);}function sS(n){let{schema:e,opts:t}=n;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0, en.checkStrictMode)(n,"default is ignored in the schema root");}function aS(n){let e=n.schema[n.opts.schemaId];e&&(n.baseId=(0, X_.resolveUrl)(n.opts.uriResolver,n.baseId,e));}function oS(n){if(n.schema.$async&&!n.schemaEnv.$async)throw new Error("async schema in sync schema")}function Fm({gen:n,schemaEnv:e,schema:t,errSchemaPath:r,opts:i}){let a=t.$comment;if(i.$comment===true)n.code((0, N._)`${V.default.self}.logger.log(${a})`);else if(typeof i.$comment=="function"){let s=(0, N.str)`${r}/$comment`,o=n.scopeValue("root",{ref:e.root});n.code((0, N._)`${V.default.self}.opts.$comment(${a}, ${s}, ${o}.schema)`);}}function uS(n){let{gen:e,schemaEnv:t,validateName:r,ValidationError:i,opts:a}=n;t.$async?e.if((0, N._)`${V.default.errors} === 0`,()=>e.return(V.default.data),()=>e.throw((0, N._)`new ${i}(${V.default.vErrors})`)):(e.assign((0, N._)`${r}.errors`,V.default.vErrors),a.unevaluated&&lS(n),e.return((0, N._)`${V.default.errors} === 0`));}function lS({gen:n,evaluated:e,props:t,items:r}){t instanceof N.Name&&n.assign((0, N._)`${e}.props`,t),r instanceof N.Name&&n.assign((0, N._)`${e}.items`,r);}function wm(n,e,t,r){let{gen:i,schema:a,data:s,allErrors:o,opts:u,self:l}=n,{RULES:c}=l;if(a.$ref&&(u.ignoreKeywordsWithRef||!(0, en.schemaHasRulesButRef)(a,c))){i.block(()=>km(n,"$ref",c.all.$ref.definition));return}u.jtd||cS(n,e),i.block(()=>{for(let p of c.rules)h(p);h(c.post);});function h(p){(0, $l.shouldUseGroup)(a,p)&&(p.type?(i.if((0, Ws.checkDataType)(p.type,s,u.strictNumbers)),Dm(n,p),e.length===1&&e[0]===p.type&&t&&(i.else(),(0, Ws.reportTypeError)(n)),i.endIf()):Dm(n,p),o||i.if((0, N._)`${V.default.errors} === ${r||0}`));}}function Dm(n,e){let{gen:t,schema:r,opts:{useDefaults:i}}=n;i&&(0, K_.assignDefaults)(n,e.type),t.block(()=>{for(let a of e.rules)(0, $l.shouldUseRule)(r,a)&&km(n,a.keyword,a.definition,e.type);});}function cS(n,e){n.schemaEnv.meta||!n.opts.strictTypes||(hS(n,e),n.opts.allowUnionTypes||dS(n,e),fS(n,n.dataTypes));}function hS(n,e){if(e.length){if(!n.dataTypes.length){n.dataTypes=e;return}e.forEach(t=>{Im(n.dataTypes,t)||jl(n,`type "${t}" not allowed by context "${n.dataTypes.join(",")}"`);}),mS(n,e);}}function dS(n,e){e.length>1&&!(e.length===2&&e.includes("null"))&&jl(n,"use allowUnionTypes to allow union type keyword");}function fS(n,e){let t=n.self.RULES.all;for(let r in t){let i=t[r];if(typeof i=="object"&&(0, $l.shouldUseRule)(n.schema,i)){let{type:a}=i.definition;a.length&&!a.some(s=>pS(e,s))&&jl(n,`missing type "${a.join(",")}" for keyword "${r}"`);}}}function pS(n,e){return n.includes(e)||e==="number"&&n.includes("integer")}function Im(n,e){return n.includes(e)||e==="integer"&&n.includes("number")}function mS(n,e){let t=[];for(let r of n.dataTypes)Im(e,r)?t.push(r):e.includes("integer")&&r==="number"&&t.push("integer");n.dataTypes=t;}function jl(n,e){let t=n.schemaEnv.baseId+n.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0, en.checkStrictMode)(n,e,n.opts.strictTypes);}var Ms=class{constructor(e,t,r){if((0, yi.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0, en.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",Vm(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0, yi.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==false)&&(this.errsCount=e.gen.const("_errs",V.default.errors));}result(e,t,r){this.failResult((0, N.not)(e),t,r);}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else();}pass(e,t){this.failResult((0, N.not)(e),void 0,t);}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(false);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else();}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0, N._)`${t} !== undefined && (${(0, N.or)(this.invalid$data(),e)})`);}error(e,t,r){if(t){this.setParams(t),this._error(e,r),this.setParams({});return}this._error(e,r);}_error(e,t){(e?gi.reportExtraError:gi.reportError)(this,this.def.error,t);}$dataError(){(0, gi.reportError)(this,this.def.$dataError||gi.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, gi.resetErrorsCount)(this.gen,this.errsCount);}ok(e){this.allErrors||this.gen.if(e);}setParams(e,t){t?Object.assign(this.params,e):this.params=e;}block$data(e,t,r=N.nil){this.gen.block(()=>{this.check$data(e,r),t();});}check$data(e=N.nil,t=N.nil){if(!this.$data)return;let{gen:r,schemaCode:i,schemaType:a,def:s}=this;r.if((0, N.or)((0, N._)`${i} === undefined`,t)),e!==N.nil&&r.assign(e,true),(a.length||s.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==N.nil&&r.assign(e,false)),r.else();}invalid$data(){let{gen:e,schemaCode:t,schemaType:r,def:i,it:a}=this;return (0, N.or)(s(),o());function s(){if(r.length){if(!(t instanceof N.Name))throw new Error("ajv implementation error");let u=Array.isArray(r)?r:[r];return (0, N._)`${(0, Ws.checkDataTypes)(u,t,a.opts.strictNumbers,Ws.DataType.Wrong)}`}return N.nil}function o(){if(i.validateSchema){let u=e.scopeValue("validate$data",{ref:i.validateSchema});return (0, N._)`!${u}(${t})`}return N.nil}}subschema(e,t){let r=(0, Rl.getSubschema)(this.it,e);(0, Rl.extendSubschemaData)(r,this.it,e),(0, Rl.extendSubschemaMode)(r,e);let i={...this.it,...r,items:void 0,props:void 0};return nS(i,t),i}mergeEvaluated(e,t){let{it:r,gen:i}=this;r.opts.unevaluated&&(r.props!==true&&e.props!==void 0&&(r.props=en.mergeEvaluated.props(i,e.props,r.props,t)),r.items!==true&&e.items!==void 0&&(r.items=en.mergeEvaluated.items(i,e.items,r.items,t)));}mergeValidEvaluated(e,t){let{it:r,gen:i}=this;if(r.opts.unevaluated&&(r.props!==true||r.items!==true))return i.if(t,()=>this.mergeEvaluated(e,N.Name)),true}};mn.KeywordCxt=Ms;function km(n,e,t,r){let i=new Ms(n,t,e);"code"in t?t.code(i,r):i.$data&&t.validate?(0, yi.funcKeywordCode)(i,t):"macro"in t?(0, yi.macroKeywordCode)(i,t):(t.compile||t.validate)&&(0, yi.funcKeywordCode)(i,t);}var gS=/^\/(?:[^~]|~0|~1)*$/,yS=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Vm(n,{dataLevel:e,dataNames:t,dataPathArr:r}){let i,a;if(n==="")return V.default.rootData;if(n[0]==="/"){if(!gS.test(n))throw new Error(`Invalid JSON-pointer: ${n}`);i=n,a=V.default.rootData;}else {let l=yS.exec(n);if(!l)throw new Error(`Invalid JSON-pointer: ${n}`);let c=+l[1];if(i=l[2],i==="#"){if(c>=e)throw new Error(u("property/index",c));return r[e-c]}if(c>e)throw new Error(u("data",c));if(a=t[e-c],!i)return a}let s=a,o=i.split("/");for(let l of o)l&&(a=(0, N._)`${a}${(0, N.getProperty)((0, en.unescapeJsonPointer)(l))}`,s=(0, N._)`${s} && ${a}`);return s;function u(l,c){return `Cannot access ${l} ${c} levels up, current level is ${e}`}}mn.getData=Vm;});var vi=E(ql=>{Object.defineProperty(ql,"__esModule",{value:true});var Ll=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=true;}};ql.default=Ll;});var mr=E(Ml=>{Object.defineProperty(Ml,"__esModule",{value:true});var Bl=mi(),Wl=class extends Error{constructor(e,t,r,i){super(i||`can't resolve reference ${r} from id ${t}`),this.missingRef=(0, Bl.resolveUrl)(e,t,r),this.missingSchema=(0, Bl.normalizeId)((0, Bl.getFullPath)(e,this.missingRef));}};Ml.default=Wl;});var Ci=E(gt=>{Object.defineProperty(gt,"__esModule",{value:true});gt.resolveSchema=gt.getCompilingSchema=gt.resolveRef=gt.compileSchema=gt.SchemaEnv=void 0;var Ot=$(),vS=vi(),Ln=pt(),xt=mi(),Rm=M(),CS=pr(),gr=class{constructor(e){var t;this.refs={},this.dynamicAnchors={};let r;typeof e.schema=="object"&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0, xt.normalizeId)(r?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=r?.$async,this.refs={};}};gt.SchemaEnv=gr;function zl(n){let e=$m.call(this,n);if(e)return e;let t=(0, xt.getFullPath)(this.opts.uriResolver,n.root.baseId),{es5:r,lines:i}=this.opts.code,{ownProperties:a}=this.opts,s=new Ot.CodeGen(this.scope,{es5:r,lines:i,ownProperties:a}),o;n.$async&&(o=s.scopeValue("Error",{ref:vS.default,code:(0, Ot._)`require("ajv/dist/runtime/validation_error").default`}));let u=s.scopeName("validate");n.validateName=u;let l={gen:s,allErrors:this.opts.allErrors,data:Ln.default.data,parentData:Ln.default.parentData,parentDataProperty:Ln.default.parentDataProperty,dataNames:[Ln.default.data],dataPathArr:[Ot.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===true?{ref:n.schema,code:(0, Ot.stringify)(n.schema)}:{ref:n.schema}),validateName:u,ValidationError:o,schema:n.schema,schemaEnv:n,rootId:t,baseId:n.baseId||t,schemaPath:Ot.nil,errSchemaPath:n.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, Ot._)`""`,opts:this.opts,self:this},c;try{this._compilations.add(n),(0,CS.validateFunctionCode)(l),s.optimize(this.opts.code.optimize);let h=s.toString();c=`${s.scopeRefs(Ln.default.scope)}return ${h}`,this.opts.code.process&&(c=this.opts.code.process(c,n));let f=new Function(`${Ln.default.self}`,`${Ln.default.scope}`,c)(this,this.scope.get());if(this.scope.value(u,{ref:f}),f.errors=null,f.schema=n.schema,f.schemaEnv=n,n.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:u,validateCode:h,scopeValues:s._values}),this.opts.unevaluated){let{props:g,items:y}=l;f.evaluated={props:g instanceof Ot.Name?void 0:g,items:y instanceof Ot.Name?void 0:y,dynamicProps:g instanceof Ot.Name,dynamicItems:y instanceof Ot.Name},f.source&&(f.source.evaluated=(0,Ot.stringify)(f.evaluated));}return n.validate=f,n}catch(h){throw delete n.validate,delete n.validateName,c&&this.logger.error("Error compiling schema, function code:",c),h}finally{this._compilations.delete(n);}}gt.compileSchema=zl;function bS(n,e,t){var r;t=(0, xt.resolveUrl)(this.opts.uriResolver,e,t);let i=n.refs[t];if(i)return i;let a=ES.call(this,n,t);if(a===void 0){let s=(r=n.localRefs)===null||r===void 0?void 0:r[t],{schemaId:o}=this.opts;s&&(a=new gr({schema:s,schemaId:o,root:n,baseId:e}));}if(a!==void 0)return n.refs[t]=_S.call(this,a)}gt.resolveRef=bS;function _S(n){return (0, xt.inlineRef)(n.schema,this.opts.inlineRefs)?n.schema:n.validate?n:zl.call(this,n)}function $m(n){for(let e of this._compilations)if(SS(e,n))return e}gt.getCompilingSchema=$m;function SS(n,e){return n.schema===e.schema&&n.root===e.root&&n.baseId===e.baseId}function ES(n,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||Gs.call(this,n,e)}function Gs(n,e){let t=this.opts.uriResolver.parse(e),r=(0, xt._getFullPath)(this.opts.uriResolver,t),i=(0, xt.getFullPath)(this.opts.uriResolver,n.baseId,void 0);if(Object.keys(n.schema).length>0&&r===i)return Gl.call(this,t,n);let a=(0, xt.normalizeId)(r),s=this.refs[a]||this.schemas[a];if(typeof s=="string"){let o=Gs.call(this,n,s);return typeof o?.schema!="object"?void 0:Gl.call(this,t,o)}if(typeof s?.schema=="object"){if(s.validate||zl.call(this,s),a===(0, xt.normalizeId)(e)){let{schema:o}=s,{schemaId:u}=this.opts,l=o[u];return l&&(i=(0, xt.resolveUrl)(this.opts.uriResolver,i,l)),new gr({schema:o,schemaId:u,root:n,baseId:i})}return Gl.call(this,t,s)}}gt.resolveSchema=Gs;var wS=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Gl(n,{baseId:e,schema:t,root:r}){var i;if(((i=n.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let o of n.fragment.slice(1).split("/")){if(typeof t=="boolean")return;let u=t[(0, Rm.unescapeFragment)(o)];if(u===void 0)return;t=u;let l=typeof t=="object"&&t[this.opts.schemaId];!wS.has(o)&&l&&(e=(0, xt.resolveUrl)(this.opts.uriResolver,e,l));}let a;if(typeof t!="boolean"&&t.$ref&&!(0, Rm.schemaHasRulesButRef)(t,this.RULES)){let o=(0, xt.resolveUrl)(this.opts.uriResolver,e,t.$ref);a=Gs.call(this,r,o);}let{schemaId:s}=this.opts;if(a=a||new gr({schema:t,schemaId:s,root:r,baseId:e}),a.schema!==a.root.schema)return a}});var jm=E((MI,DS)=>{DS.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:false};});var Yl=E((GI,zm)=>{var AS=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Hl=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),PS=RegExp.prototype.test.bind(/^\d*$/u),qn=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Ul=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),qm=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Kl=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),OS=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),nt=new Array(256);{let n="0123456789ABCDEF";for(let e=0;e<256;e++)nt[e]="%"+n[e>>4]+n[e&15];}function $e(n){return n<2048?nt[192|n>>6]+nt[128|n&63]:n<65536?nt[224|n>>12]+nt[128|n>>6&63]+nt[128|n&63]:nt[240|n>>18]+nt[128|n>>12&63]+nt[128|n>>6&63]+nt[128|n&63]}function xS(n){let e="",t=0,r=0;for(r=0;r<n.length;r++)if(t=n[r].charCodeAt(0),t!==48){if(!(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102))return "";e+=n[r];break}for(r+=1;r<n.length;r++){if(t=n[r].charCodeAt(0),!(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102))return "";e+=n[r];}return e}var TS=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),NS=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),FS=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),IS=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function kS(n){if(n.length===0)return false;for(let e=0;e<n.length;e++)if(!FS(n[e])){if(n[e]==="%"&&e+2<n.length&&qn(n.slice(e+1,e+3))){e+=2;continue}return false}return true}function Lm(n){let e=-1,t=0,r=-1,i=0;for(let o=0;o<n.length;o++)n[o]==="0"?(r===-1&&(r=o),i++,i>t&&(t=i,e=r)):(r=-1,i=0);if(t<2)return n.join(":");let a=n.slice(0,e).join(":"),s=n.slice(e+t).join(":");return a+"::"+s}function VS(n){let e=n.indexOf("::");if(e!==-1&&n.indexOf("::",e+1)!==-1)return;let t=e===-1?n.split(":"):n.slice(0,e).split(":"),r=e===-1?[]:n.slice(e+2).split(":");e!==-1&&(t.length===1&&t[0]===""&&(t.length=0),r.length===1&&r[0]===""&&(r.length=0));let i=t.concat(r),a=0;for(let o=0;o<i.length;o++){let u=i[o];if(u==="")return;if(u.indexOf(".")!==-1){if(o!==i.length-1||e!==-1&&r.length===0||!Hl(u))return;a+=2;continue}if(!TS(u))return;i[o]=parseInt(u,16).toString(16),a++;}if(e===-1)return a!==8?void 0:Lm(i);if(a>=8)return;let s=i.slice(0,t.length);for(let o=a;o<8;o++)s.push("0");for(let o=t.length;o<i.length;o++)s.push(i[o]);return Lm(s)}function Jl(n){let e=n[0]==="["&&n[n.length-1]==="]";if((n[0]==="["||n[n.length-1]==="]")&&!e)return {host:n,isIPV6:false,error:true};let r=e?n.slice(1,-1):n;if(e&&NS(r))return r=r.toLowerCase(),{host:`[${r}]`,escapedHost:r,isIPV6:false,isIPVFuture:true};if(RS(r,":")<2)return {host:n,isIPV6:false,error:e};let i="",a=r.indexOf("%");if(a!==-1){let o=r.slice(a,a+3).toLowerCase()==="%25"?3:1;if(i=r.slice(a+o),!kS(i))return {host:n,isIPV6:false,error:true};r=r.slice(0,a);}let s=VS(r);return s===void 0?{host:n,isIPV6:false,error:true}:{host:s+(i?"%"+i:""),escapedHost:s+(i?"%25"+i:""),isIPV6:true}}function RS(n,e){let t=0;for(let r=0;r<n.length;r++)n[r]===e&&t++;return t}function $S(n){let e=n,t=[],r=-1,i=0;for(;i=e.length;){if(i===1){if(e===".")break;if(e==="/"){t.push("/");break}else {t.push(e);break}}else if(i===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){t.push("/");break}}else if(i===3&&e==="/.."){t.length!==0&&t.pop(),t.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),t.length!==0&&t.pop();continue}}if((r=e.indexOf("/",1))===-1){t.push(e);break}else t.push(e.slice(0,r)),e=e.slice(r);}return t.join("")}var jS={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},LS=/[@/?#:]/g,qS=/[@/?#]/g;function Bm(n,e){let t=e?qS:LS;return t.lastIndex=0,n.replace(t,r=>jS[r])}function Wm(n,e=false){if(n.indexOf("%")===-1)return n;let t="";for(let r=0;r<n.length;r++){if(n[r]==="%"&&r+2<n.length){let i=n.slice(r+1,r+3);if(qn(i)){let a=i.toUpperCase(),s=String.fromCharCode(parseInt(a,16));e&&Ul(s)?t+=s:t+="%"+a,r+=2;continue}}t+=n[r];}return t}function BS(n){let e="";for(let t=0;t<n.length;t++){let r=n[t];if(r==="%"&&t+2<n.length){let i=n.slice(t+1,t+3);if(qn(i)){let a=i.toUpperCase(),s=String.fromCharCode(parseInt(a,16));s!=="."&&Ul(s)?e+=s:e+="%"+a,t+=2;continue}}if(qm(r))e+=r;else {let i=n.charCodeAt(t);if(i<128)e+=Gm(i)?r:nt[i];else if(i<55296||i>57343)e+=$e(i);else if(i<=56319&&t+1<n.length){let a=n.charCodeAt(t+1);a>=56320&&a<=57343?(e+=$e(65536+(i-55296<<10)+(a-56320)),t++):e+=$e(65533);}else e+=$e(65533);}}return e}function WS(n,e=false){let t="",r=e&&n[0]!=="/";for(let i=0;i<n.length;i++){let a=n[i];if(a==="%"&&i+2<n.length){let s=n.slice(i+1,i+3);if(qn(s)){t+="%"+s.toUpperCase(),i+=2;continue}}if(a==="/"&&(r=false),qm(a)&&(a!==":"||!r))t+=a;else {let s=n.charCodeAt(i);if(s<128)t+=nt[s];else if(s<55296||s>57343)t+=$e(s);else if(s<=56319&&i+1<n.length){let o=n.charCodeAt(i+1);o>=56320&&o<=57343?(t+=$e(65536+(s-55296<<10)+(o-56320)),i++):t+=$e(65533);}else t+=$e(65533);}}return t}function Xl(n,e){let t="";for(let r=0;r<n.length;r++){let i=n[r];if(i==="%"&&r+2<n.length){let a=n.slice(r+1,r+3);if(qn(a)){t+="%"+a.toUpperCase(),r+=2;continue}}if(e(i))t+=i;else {let a=n.charCodeAt(r);if(a<128)t+=nt[a];else if(a<55296||a>57343)t+=$e(a);else if(a<=56319&&r+1<n.length){let s=n.charCodeAt(r+1);s>=56320&&s<=57343?(t+=$e(65536+(a-55296<<10)+(s-56320)),r++):t+=$e(65533);}else t+=$e(65533);}}return t}function Mm(n){return Xl(n,OS)}function MS(n){return Xl(n,Kl)}function GS(n){return Xl(n,Kl)}function Gm(n){return n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||n===42||n===43||n===45||n===46||n===47||n===64||n===95}function zS(n){let e="";for(let t=0;t<n.length;t++){let r=n[t];if(r==="%"&&t+2<n.length){let i=n.slice(t+1,t+3);if(qn(i)){let a=i.toUpperCase(),s=String.fromCharCode(parseInt(a,16));Ul(s)?e+=s:e+="%"+a,t+=2;continue}}if(Kl(r))e+=r;else {let i=n.charCodeAt(t);if(i<128)e+=Gm(i)?r:nt[i];else if(i<55296||i>57343)e+=$e(i);else if(i<=56319&&t+1<n.length){let a=n.charCodeAt(t+1);a>=56320&&a<=57343?(e+=$e(65536+(i-55296<<10)+(a-56320)),t++):e+=$e(65533);}else e+=$e(65533);}}return e}function JS(n){let e="";for(let t=0;t<n.length;t++){if(n[t]==="%"&&t+2<n.length){let r=n.slice(t+1,t+3);if(qn(r)){e+="%"+r.toUpperCase(),t+=2;continue}}e+=escape(n[t]);}return e}function HS(n){let e=[];if(n.userinfo!==void 0&&(e.push(Mm(n.userinfo)),e.push("@")),n.host!==void 0){let t=n.host;if(!Hl(t)){let r=Jl(t);r.isIPV6!==true&&r.isIPVFuture!==true&&(t=Wm(t,true),r=Jl(t)),r.isIPV6===true||r.isIPVFuture===true?t=`[${r.escapedHost}]`:t=Bm(t,false);}e.push(t);}if(typeof n.port=="number"||typeof n.port=="string"){let t=String(n.port);if(!PS(t))throw new TypeError("URI port is malformed.");e.push(":"),e.push(t);}return e.length?e.join(""):void 0}zm.exports={nonSimpleDomain:IS,recomposeAuthority:HS,reescapeHostDelimiters:Bm,normalizePercentEncoding:Wm,normalizePathEncoding:BS,serializePathEncoding:WS,normalizeQueryFragmentEncoding:zS,encodeUserinfo:Mm,encodeQuery:MS,encodeFragment:GS,escapePreservingEscapes:JS,removeDotSegments:$S,isIPv4:Hl,isUUID:AS,normalizeIPv6:Jl,stringArrayToHexStripped:xS};});var Xm=E((zI,Km)=>{var{isUUID:US}=Yl(),KS=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,XS=["http","https","ws","wss","urn","urn:uuid"];function YS(n){return XS.indexOf(n)!==-1}function Zl(n){return n.secure===true?true:n.secure===false?false:n.scheme?n.scheme.length===3&&(n.scheme[0]==="w"||n.scheme[0]==="W")&&(n.scheme[1]==="s"||n.scheme[1]==="S")&&(n.scheme[2]==="s"||n.scheme[2]==="S"):false}function Jm(n){return n.host||(n.error=n.error||"HTTP URIs must have a host."),n}function Hm(n){let e=String(n.scheme).toLowerCase()==="https";return (n.port===(e?443:80)||n.port==="")&&(n.port=void 0),n.path||(n.path="/"),n}function ZS(n){return n.secure=Zl(n),n.resourceName=(n.path||"/")+(n.query?"?"+n.query:""),n.path=void 0,n.query=void 0,n}function QS(n){if((n.port===(Zl(n)?443:80)||n.port==="")&&(n.port=void 0),typeof n.secure=="boolean"&&(n.scheme=n.secure?"wss":"ws",n.secure=void 0),n.resourceName){let e=n.resourceName.indexOf("?"),t=e===-1?n.resourceName:n.resourceName.slice(0,e);n.path=t&&t!=="/"?t:void 0,n.query=e===-1?void 0:n.resourceName.slice(e+1),n.resourceName=void 0;}return n.fragment=void 0,n}function eE(n,e){if(!n.path)return n.error="URN can not be parsed",n;let t=n.path.match(KS);if(t&&t[0]===n.path){let r=e.scheme||n.scheme||"urn";n.nid=t[1].toLowerCase(),n.nss=t[2];let i=`${r}:${e.nid||n.nid}`,a=Ql(i);n.path=void 0,a&&(n=a.parse(n,e));}else n.error=n.error||"URN can not be parsed.";return n}function tE(n,e){if(n.nid===void 0)throw new Error("URN without nid cannot be serialized");let t=e.scheme||n.scheme||"urn",r=n.nid.toLowerCase(),i=`${t}:${e.nid||r}`,a=Ql(i);a&&(n=a.serialize(n,e));let s=n,o=n.nss;return s.path=`${r||e.nid}:${o}`,e.skipEscape=true,s}function nE(n,e){let t=n;return t.uuid=t.nss,t.nss=void 0,!e.tolerant&&(!t.uuid||!US(t.uuid))&&(t.error=t.error||"UUID is not valid."),t}function rE(n){let e=n;return e.nss=(n.uuid||"").toLowerCase(),e}var Um={scheme:"http",domainHost:true,parse:Jm,serialize:Hm},iE={scheme:"https",domainHost:Um.domainHost,parse:Jm,serialize:Hm},zs={scheme:"ws",domainHost:true,parse:ZS,serialize:QS},sE={scheme:"wss",domainHost:zs.domainHost,parse:zs.parse,serialize:zs.serialize},aE={scheme:"urn",parse:eE,serialize:tE,skipNormalize:true},oE={scheme:"urn:uuid",parse:nE,serialize:rE,skipNormalize:true},Js={http:Um,https:iE,ws:zs,wss:sE,urn:aE,"urn:uuid":oE};Object.setPrototypeOf(Js,null);function Ql(n){return n&&(Js[n]||Js[n.toLowerCase()])||void 0}Km.exports={wsIsSecure:Zl,SCHEMES:Js,isValidSchemeName:YS,getSchemeHandler:Ql};});var lg=E((JI,Ks)=>{var{normalizeIPv6:tg,removeDotSegments:_i,recomposeAuthority:uE,normalizePercentEncoding:ec,normalizePathEncoding:lE,serializePathEncoding:Ym,normalizeQueryFragmentEncoding:Zm,encodeQuery:cE,encodeFragment:hE,reescapeHostDelimiters:dE,isIPv4:ng,nonSimpleDomain:fE}=Yl(),{SCHEMES:rg,getSchemeHandler:tc}=Xm(),ig=/^[A-Za-z][A-Za-z0-9+.-]*$/u,sg="URI scheme is malformed.";function Qm(n){let e=unescape(String(n));if(!ig.test(e))throw new TypeError(sg);return e}function pE(n,e){return typeof n=="string"?n=SE(n,e):typeof n=="object"&&(n=Us(Bn(n,e),e)),n}function mE(n,e,t){let r=t?Object.assign({scheme:"null"},t):{scheme:"null"},{parsed:i,malformedAuthorityOrPort:a,malformedPercentEncoding:s,malformedSchemeSpecific:o,malformedHost:u,malformedScheme:l}=Hs(n,r),{parsed:c,malformedAuthorityOrPort:h,malformedPercentEncoding:p,malformedSchemeSpecific:f,malformedHost:g,malformedScheme:y}=Hs(e,r);if(a||h||s||p||o||f||u||g||l||y)throw new Error(i.error||c.error||"URI is malformed.");let C=ag(i,c,r,true),_=tc(t&&t.scheme||C.scheme),v=C.host,d=v!==void 0&&v!==""&&(ng(v)||tg(v).isIPV6);og(C,t||{},_,d);let S=v&&v.indexOf("%")!==-1&&!/\P{ASCII}/u.test(v);if(C.error&&!S)throw new Error(C.error);return r.skipEscape=true,Bn(C,r)}function ag(n,e,t,r){let i={};return r||(n=Us(Bn(n,t),t),e=Us(Bn(e,t),t)),t=t||{},!t.tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=_i(e.path||""),i.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=_i(e.path||""),i.query=e.query):(e.path?(e.path[0]==="/"?i.path=_i(e.path):((n.userinfo!==void 0||n.host!==void 0||n.port!==void 0)&&!n.path?i.path="/"+e.path:n.path?i.path=n.path.slice(0,n.path.lastIndexOf("/")+1)+e.path:i.path=e.path,i.path=_i(i.path)),i.query=e.query):(i.path=n.path,e.query!==void 0?i.query=e.query:i.query=n.query),i.userinfo=n.userinfo,i.host=n.host,i.port=n.port),i.scheme=n.scheme),i.fragment=e.fragment,i}function gE(n,e,t){let r=eg(n,t),i=eg(e,t);return r!==void 0&&i!==void 0&&r===i}function Bn(n,e){let t={host:n.host,scheme:n.scheme,userinfo:n.userinfo,port:n.port,path:n.path,query:n.query,nid:n.nid,nss:n.nss,uuid:n.uuid,fragment:n.fragment,reference:n.reference,resourceName:n.resourceName,secure:n.secure,error:""},r=Object.assign({},e),i=[];t.scheme&&(t.scheme=Qm(t.scheme));let a=tc(r.scheme||t.scheme);a&&a.serialize&&a.serialize(t,r);let s=t.userinfo!==void 0||t.host!==void 0||t.port!==void 0,o=!r.skipEscape&&t.scheme===void 0&&!s;t.path!==void 0&&(r.skipEscape?t.path=ec(t.path):t.path=Ym(t.path,o)),r.reference!=="suffix"&&t.scheme&&(t.scheme=Qm(t.scheme),i.push(t.scheme,":"));let u=uE(t);if(u!==void 0&&(r.reference!=="suffix"&&i.push("//"),i.push(u),t.path&&t.path[0]!=="/"&&i.push("/")),t.path!==void 0){let l=t.path;!r.absolutePath&&(!a||!a.absolutePath)&&(l=_i(l)),o&&(l=Ym(l,true)),u===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),i.push(l);}return t.query!==void 0&&i.push("?",cE(t.query)),t.fragment!==void 0&&i.push("#",hE(t.fragment)),i.join("")}var yE=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,vE=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,CE=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function bE(n,e){if(e[2]!==void 0&&n.path&&n.path[0]!=="/")return 'URI path must start with "/" when authority is present.';if(typeof n.port=="number"&&(n.port<0||n.port>65535))return "URI port is malformed."}function bi(n){if(n===void 0)return false;let e=n.indexOf("%");for(;e!==-1;){if(e+2>=n.length||!/^[\da-f]{2}$/iu.test(n.slice(e+1,e+3)))return true;e=n.indexOf("%",e+3);}return false}function nc(n){return n[0]==="["&&n[n.length-1]==="]"}function _E(n){let e=n[4];return bi(n[3])||e!==void 0&&!nc(e)&&bi(e)||bi(n[6])||bi(n[7])||bi(n[8])}function og(n,e,t,r){if(!e.unicodeSupport&&(!t||!t.unicodeSupport)&&n.host&&!nc(n.host)&&(e.domainHost||t&&t.domainHost)&&r===false&&fE(n.host))try{n.host=new URL("http://"+n.host).hostname;}catch(i){return n.error=n.error||"Host's domain name can not be converted to ASCII: "+i,true}return false}function Hs(n,e){let t=Object.assign({},e),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=false,a=false,s=false,o=false,u=false,l=false,c=false;t.reference==="suffix"&&(t.scheme?n=t.scheme+":"+n:n="//"+n);let h=n.match(vE);h!==null&&h[1].indexOf("\\")!==-1&&(r.error="URI authority must not contain a literal backslash.",i=true);let p=n.match(CE);if(p!==null){let g=p[1],y=g.replace(/[\t\n\r]/g,"");y.length>=2&&(y.slice(0,2)!=="//"?(r.error=r.error||"URI authority must not contain a literal backslash.",i=true):g.length!==y.length&&(r.error=r.error||"URI authority introducer must not contain whitespace.",i=true));}let f=n.match(yE);if(f){if(r.scheme=f[1],r.userinfo=f[3],r.host=f[4],r.port=parseInt(f[5],10),r.path=f[6]||"",r.query=f[7],r.fragment=f[8],r.scheme!==void 0){let C=unescape(r.scheme);ig.test(C)?r.scheme=C.toLowerCase():(r.error=r.error||sg,l=true);}a=_E(f),a&&(r.error=r.error||"URI contains malformed percent-encoding."),isNaN(r.port)&&(r.port=f[5]);let g=bE(r,f);if(g!==void 0&&(r.error=r.error||g,i=true),r.host)if(ng(r.host)===false){let _=nc(r.host),v=r.host.indexOf("[")!==-1||r.host.indexOf("]")!==-1,d=tg(r.host);c=d.isIPV6||d.isIPVFuture===true,u=v&&(!_||d.error===true),r.host=c?d.host:d.host.toLowerCase(),u&&(r.error=r.error||"URI host is malformed.",i=true);}else c=true;r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path?r.reference="same-document":r.scheme===void 0?r.reference="relative":r.fragment===void 0?r.reference="absolute":r.reference="uri",t.reference&&t.reference!=="suffix"&&t.reference!==r.reference&&(r.error=r.error||"URI is not a "+t.reference+" reference.");let y=tc(t.scheme||r.scheme);if(u||(o=og(r,t,y,c)),n.indexOf("%")!==-1&&r.host!==void 0&&!u){let C=c?r.host:ec(r.host,true);c||(C=ec(C.toLowerCase())),r.host=dE(C,c);}(!y||y&&!y.skipNormalize)&&(r.path&&(r.path=lE(r.path)),r.query&&(r.query=Zm(r.query)),r.fragment&&(r.fragment=Zm(r.fragment))),y&&y.parse&&(y.parse(r,t),y===rg.urn&&r.nid===void 0&&(s=true));}else r.error=r.error||"URI can not be parsed.";return {parsed:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:s,malformedHost:o,malformedScheme:l}}function Us(n,e){return Hs(n,e).parsed}function SE(n,e){return ug(n,e).normalized}function ug(n,e){let{parsed:t,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:s,malformedScheme:o}=Hs(n,e);return {normalized:r||i||a||s||o?n:Bn(t,e),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:s,malformedScheme:o}}function eg(n,e){if(typeof n!="string"&&typeof n!="object")return;let t;try{t=typeof n=="string"?n:Bn(n,e);}catch{return}let{normalized:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:s,malformedHost:o,malformedScheme:u}=ug(t,e);return i||a||s||o||u?void 0:r}var rc={SCHEMES:rg,normalize:pE,resolve:mE,resolveComponent:ag,equal:gE,serialize:Bn,parse:Us};Ks.exports=rc;Ks.exports.default=rc;Ks.exports.fastUri=rc;});var hg=E(ic=>{Object.defineProperty(ic,"__esModule",{value:true});var cg=lg();cg.code='require("ajv/dist/runtime/uri").default';ic.default=cg;});var oc=E(Ne=>{Object.defineProperty(Ne,"__esModule",{value:true});Ne.CodeGen=Ne.Name=Ne.nil=Ne.stringify=Ne.str=Ne._=Ne.KeywordCxt=void 0;var EE=pr();Object.defineProperty(Ne,"KeywordCxt",{enumerable:true,get:function(){return EE.KeywordCxt}});var yr=$();Object.defineProperty(Ne,"_",{enumerable:true,get:function(){return yr._}});Object.defineProperty(Ne,"str",{enumerable:true,get:function(){return yr.str}});Object.defineProperty(Ne,"stringify",{enumerable:true,get:function(){return yr.stringify}});Object.defineProperty(Ne,"nil",{enumerable:true,get:function(){return yr.nil}});Object.defineProperty(Ne,"Name",{enumerable:true,get:function(){return yr.Name}});Object.defineProperty(Ne,"CodeGen",{enumerable:true,get:function(){return yr.CodeGen}});var wE=vi(),gg=mr(),DE=Al(),Si=Ci(),AE=$(),Ei=mi(),Xs=pi(),ac=M(),dg=jm(),PE=hg(),yg=(n,e)=>new RegExp(n,e);yg.code="new RegExp";var OE=["removeAdditional","useDefaults","coerceTypes"],xE=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),TE={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},NE={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},fg=200;function FE(n){var e,t,r,i,a,s,o,u,l,c,h,p,f,g,y,C,_,v,d,S,m,b,w,P,O;let k=n.strict,z=(e=n.code)===null||e===void 0?void 0:e.optimize,ie=z===true||z===void 0?1:z||0,ue=(r=(t=n.code)===null||t===void 0?void 0:t.regExp)!==null&&r!==void 0?r:yg,an=(i=n.uriResolver)!==null&&i!==void 0?i:PE.default;return {strictSchema:(s=(a=n.strictSchema)!==null&&a!==void 0?a:k)!==null&&s!==void 0?s:true,strictNumbers:(u=(o=n.strictNumbers)!==null&&o!==void 0?o:k)!==null&&u!==void 0?u:true,strictTypes:(c=(l=n.strictTypes)!==null&&l!==void 0?l:k)!==null&&c!==void 0?c:"log",strictTuples:(p=(h=n.strictTuples)!==null&&h!==void 0?h:k)!==null&&p!==void 0?p:"log",strictRequired:(g=(f=n.strictRequired)!==null&&f!==void 0?f:k)!==null&&g!==void 0?g:false,code:n.code?{...n.code,optimize:ie,regExp:ue}:{optimize:ie,regExp:ue},loopRequired:(y=n.loopRequired)!==null&&y!==void 0?y:fg,loopEnum:(C=n.loopEnum)!==null&&C!==void 0?C:fg,meta:(_=n.meta)!==null&&_!==void 0?_:true,messages:(v=n.messages)!==null&&v!==void 0?v:true,inlineRefs:(d=n.inlineRefs)!==null&&d!==void 0?d:true,schemaId:(S=n.schemaId)!==null&&S!==void 0?S:"$id",addUsedSchema:(m=n.addUsedSchema)!==null&&m!==void 0?m:true,validateSchema:(b=n.validateSchema)!==null&&b!==void 0?b:true,validateFormats:(w=n.validateFormats)!==null&&w!==void 0?w:true,unicodeRegExp:(P=n.unicodeRegExp)!==null&&P!==void 0?P:true,int32range:(O=n.int32range)!==null&&O!==void 0?O:true,uriResolver:an}}var wi=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...FE(e)};let{es5:t,lines:r}=this.opts.code;this.scope=new AE.ValueScope({scope:{},prefixes:xE,es5:t,lines:r}),this.logger=jE(e.logger);let i=e.validateFormats;e.validateFormats=false,this.RULES=(0, DE.getRules)(),pg.call(this,TE,e,"NOT SUPPORTED"),pg.call(this,NE,e,"DEPRECATED","warn"),this._metaOpts=RE.call(this),e.formats&&kE.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&VE.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),IE.call(this),e.validateFormats=i;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:r}=this.opts,i=dg;r==="id"&&(i={...dg},i.id=i.$id,delete i.$id),t&&e&&this.addMetaSchema(i,i[r],false);}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[t]||e:void 0}validate(e,t){let r;if(typeof e=="string"){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);let i=r(t);return "$async"in r||(this.errors=r.errors),i}compile(e,t){let r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:r}=this.opts;return i.call(this,e,t);async function i(c,h){await a.call(this,c.$schema);let p=this._addSchema(c,h);return p.validate||s.call(this,p)}async function a(c){c&&!this.getSchema(c)&&await i.call(this,{$ref:c},true);}async function s(c){try{return this._compileSchemaEnv(c)}catch(h){if(!(h instanceof gg.default))throw h;return o.call(this,h),await u.call(this,h.missingSchema),s.call(this,c)}}function o({missingSchema:c,missingRef:h}){if(this.refs[c])throw new Error(`AnySchema ${c} is loaded but ${h} cannot be resolved`)}async function u(c){let h=await l.call(this,c);this.refs[c]||await a.call(this,h.$schema),this.refs[c]||this.addSchema(h,c,t);}async function l(c){let h=this._loading[c];if(h)return h;try{return await(this._loading[c]=r(c))}finally{delete this._loading[c];}}}addSchema(e,t,r,i=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,r,i);return this}let a;if(typeof e=="object"){let{schemaId:s}=this.opts;if(a=e[s],a!==void 0&&typeof a!="string")throw new Error(`schema ${s} must be string`)}return t=(0, Ei.normalizeId)(t||a),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,i,true),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,true,r),this}validateSchema(e,t){if(typeof e=="boolean")return true;let r;if(r=e.$schema,r!==void 0&&typeof r!="string")throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,true;let i=this.validate(r,e);if(!i&&t){let a="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(a);else throw new Error(a)}return i}getSchema(e){let t;for(;typeof(t=mg.call(this,e))=="string";)e=t;if(t===void 0){let{schemaId:r}=this.opts,i=new Si.SchemaEnv({schema:{},schemaId:r});if(t=Si.resolveSchema.call(this,i,e),!t)return;this.refs[e]=t;}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case "undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case "string":{let t=mg.call(this,e);return typeof t=="object"&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case "object":{let t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0, Ei.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if(typeof e=="string")r=e,typeof t=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else if(typeof e=="object"&&t===void 0){if(t=e,r=t.keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(qE.call(this,r,t),!t)return (0, ac.eachItem)(r,a=>sc.call(this,a)),this;WE.call(this,t);let i={...t,type:(0, Xs.getJSONTypes)(t.type),schemaType:(0, Xs.getJSONTypes)(t.schemaType)};return (0, ac.eachItem)(r,i.type.length===0?a=>sc.call(this,a,i):a=>i.type.forEach(s=>sc.call(this,a,i,s))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t=="object"?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let r of t.rules){let i=r.rules.findIndex(a=>a.keyword===e);i>=0&&r.rules.splice(i,1);}return this}addFormat(e,t){return typeof t=="string"&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return !e||e.length===0?"No errors":e.map(i=>`${r}${i.instancePath} ${i.message}`).reduce((i,a)=>i+t+a)}$dataMetaSchema(e,t){let r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of t){let a=i.split("/").slice(1),s=e;for(let o of a)s=s[o];for(let o in r){let u=r[o];if(typeof u!="object")continue;let{$data:l}=u.definition,c=s[o];l&&c&&(s[o]=vg(c));}}return e}_removeAllSchemas(e,t){for(let r in e){let i=e[r];(!t||t.test(r))&&(typeof i=="string"?delete e[r]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[r]));}}_addSchema(e,t,r,i=this.opts.validateSchema,a=this.opts.addUsedSchema){let s,{schemaId:o}=this.opts;if(typeof e=="object")s=e[o];else {if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(e);if(u!==void 0)return u;r=(0, Ei.normalizeId)(s||r);let l=Ei.getSchemaRefs.call(this,e,r);return u=new Si.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:r,localRefs:l}),this._cache.set(u.schema,u),a&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=u),i&&this.validateSchema(e,true),u}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Si.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{Si.compileSchema.call(this,e);}finally{this.opts=t;}}};wi.ValidationError=wE.default;wi.MissingRefError=gg.default;Ne.default=wi;function pg(n,e,t,r="error"){for(let i in n){let a=i;a in e&&this.logger[r](`${t}: option ${i}. ${n[a]}`);}}function mg(n){return n=(0, Ei.normalizeId)(n),this.schemas[n]||this.refs[n]}function IE(){let n=this.opts.schemas;if(n)if(Array.isArray(n))this.addSchema(n);else for(let e in n)this.addSchema(n[e],e);}function kE(){for(let n in this.opts.formats){let e=this.opts.formats[n];e&&this.addFormat(n,e);}}function VE(n){if(Array.isArray(n)){this.addVocabulary(n);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in n){let t=n[e];t.keyword||(t.keyword=e),this.addKeyword(t);}}function RE(){let n={...this.opts};for(let e of OE)delete n[e];return n}var $E={log(){},warn(){},error(){}};function jE(n){if(n===false)return $E;if(n===void 0)return console;if(n.log&&n.warn&&n.error)return n;throw new Error("logger must implement log, warn and error methods")}var LE=/^[a-z_$][a-z0-9_$:-]*$/i;function qE(n,e){let{RULES:t}=this;if((0, ac.eachItem)(n,r=>{if(t.keywords[r])throw new Error(`Keyword ${r} is already defined`);if(!LE.test(r))throw new Error(`Keyword ${r} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function sc(n,e,t){var r;let i=e?.post;if(t&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:a}=this,s=i?a.post:a.rules.find(({type:u})=>u===t);if(s||(s={type:t,rules:[]},a.rules.push(s)),a.keywords[n]=true,!e)return;let o={keyword:n,definition:{...e,type:(0, Xs.getJSONTypes)(e.type),schemaType:(0, Xs.getJSONTypes)(e.schemaType)}};e.before?BE.call(this,s,o,e.before):s.rules.push(o),a.all[n]=o,(r=e.implements)===null||r===void 0||r.forEach(u=>this.addKeyword(u));}function BE(n,e,t){let r=n.rules.findIndex(i=>i.keyword===t);r>=0?n.rules.splice(r,0,e):(n.rules.push(e),this.logger.warn(`rule ${t} is not defined`));}function WE(n){let{metaSchema:e}=n;e!==void 0&&(n.$data&&this.opts.$data&&(e=vg(e)),n.validateSchema=this.compile(e,true));}var ME={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function vg(n){return {anyOf:[n,ME]}}});var Cg=E(uc=>{Object.defineProperty(uc,"__esModule",{value:true});var GE={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};uc.default=GE;});var Qs=E(Wn=>{Object.defineProperty(Wn,"__esModule",{value:true});Wn.callRef=Wn.getValidate=void 0;var zE=mr(),bg=mt(),rt=$(),vr=pt(),_g=Ci(),Ys=M(),JE={keyword:"$ref",schemaType:"string",code(n){let{gen:e,schema:t,it:r}=n,{baseId:i,schemaEnv:a,validateName:s,opts:o,self:u}=r,{root:l}=a;if((t==="#"||t==="#/")&&i===l.baseId)return h();let c=_g.resolveRef.call(u,l,i,t);if(c===void 0)throw new zE.default(r.opts.uriResolver,i,t);if(c instanceof _g.SchemaEnv)return p(c);return f(c);function h(){if(a===l)return Zs(n,s,a,a.$async);let g=e.scopeValue("root",{ref:l});return Zs(n,(0, rt._)`${g}.validate`,l,l.$async)}function p(g){let y=Sg(n,g);Zs(n,y,g,g.$async);}function f(g){let y=e.scopeValue("schema",o.code.source===true?{ref:g,code:(0, rt.stringify)(g)}:{ref:g}),C=e.name("valid"),_=n.subschema({schema:g,dataTypes:[],schemaPath:rt.nil,topSchemaRef:y,errSchemaPath:t},C);n.mergeEvaluated(_),n.ok(C);}}};function Sg(n,e){let{gen:t}=n;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0, rt._)`${t.scopeValue("wrapper",{ref:e})}.validate`}Wn.getValidate=Sg;function Zs(n,e,t,r){let{gen:i,it:a}=n,{allErrors:s,schemaEnv:o,opts:u}=a,l=u.passContext?vr.default.this:rt.nil;r?c():h();function c(){if(!o.$async)throw new Error("async schema referenced by sync schema");let g=i.let("valid");i.try(()=>{i.code((0, rt._)`await ${(0, bg.callValidateCode)(n,e,l)}`),f(e),s||i.assign(g,true);},y=>{i.if((0, rt._)`!(${y} instanceof ${a.ValidationError})`,()=>i.throw(y)),p(y),s||i.assign(g,false);}),n.ok(g);}function h(){n.result((0, bg.callValidateCode)(n,e,l),()=>f(e),()=>p(e));}function p(g){let y=(0, rt._)`${g}.errors`;i.assign(vr.default.vErrors,(0, rt._)`${vr.default.vErrors} === null ? ${y} : ${vr.default.vErrors}.concat(${y})`),i.assign(vr.default.errors,(0, rt._)`${vr.default.vErrors}.length`);}function f(g){var y;if(!a.opts.unevaluated)return;let C=(y=t?.validate)===null||y===void 0?void 0:y.evaluated;if(a.props!==true)if(C&&!C.dynamicProps)C.props!==void 0&&(a.props=Ys.mergeEvaluated.props(i,C.props,a.props));else {let _=i.var("props",(0, rt._)`${g}.evaluated.props`);a.props=Ys.mergeEvaluated.props(i,_,a.props,rt.Name);}if(a.items!==true)if(C&&!C.dynamicItems)C.items!==void 0&&(a.items=Ys.mergeEvaluated.items(i,C.items,a.items));else {let _=i.var("items",(0, rt._)`${g}.evaluated.items`);a.items=Ys.mergeEvaluated.items(i,_,a.items,rt.Name);}}}Wn.callRef=Zs;Wn.default=JE;});var cc=E(lc=>{Object.defineProperty(lc,"__esModule",{value:true});var HE=Cg(),UE=Qs(),KE=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",HE.default,UE.default];lc.default=KE;});var Eg=E(hc=>{Object.defineProperty(hc,"__esModule",{value:true});var ea=$(),gn=ea.operators,ta={maximum:{okStr:"<=",ok:gn.LTE,fail:gn.GT},minimum:{okStr:">=",ok:gn.GTE,fail:gn.LT},exclusiveMaximum:{okStr:"<",ok:gn.LT,fail:gn.GTE},exclusiveMinimum:{okStr:">",ok:gn.GT,fail:gn.LTE}},XE={message:({keyword:n,schemaCode:e})=>(0, ea.str)`must be ${ta[n].okStr} ${e}`,params:({keyword:n,schemaCode:e})=>(0, ea._)`{comparison: ${ta[n].okStr}, limit: ${e}}`},YE={keyword:Object.keys(ta),type:"number",schemaType:"number",$data:true,error:XE,code(n){let{keyword:e,data:t,schemaCode:r}=n;n.fail$data((0, ea._)`${t} ${ta[e].fail} ${r} || isNaN(${t})`);}};hc.default=YE;});var wg=E(dc=>{Object.defineProperty(dc,"__esModule",{value:true});var Di=$(),ZE={message:({schemaCode:n})=>(0, Di.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0, Di._)`{multipleOf: ${n}}`},QE={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:ZE,code(n){let{gen:e,data:t,schemaCode:r,it:i}=n,a=i.opts.multipleOfPrecision,s=e.let("res"),o=a?(0, Di._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${a}`:(0, Di._)`${s} !== parseInt(${s})`;n.fail$data((0, Di._)`(${r} === 0 || (${s} = ${t}/${r}, ${o}))`);}};dc.default=QE;});var Ag=E(fc=>{Object.defineProperty(fc,"__esModule",{value:true});function Dg(n){let e=n.length,t=0,r=0,i;for(;r<e;)t++,i=n.charCodeAt(r++),i>=55296&&i<=56319&&r<e&&(i=n.charCodeAt(r),(i&64512)===56320&&r++);return t}fc.default=Dg;Dg.code='require("ajv/dist/runtime/ucs2length").default';});var Pg=E(pc=>{Object.defineProperty(pc,"__esModule",{value:true});var Mn=$(),ew=M(),tw=Ag(),nw={message({keyword:n,schemaCode:e}){let t=n==="maxLength"?"more":"fewer";return (0, Mn.str)`must NOT have ${t} than ${e} characters`},params:({schemaCode:n})=>(0, Mn._)`{limit: ${n}}`},rw={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:nw,code(n){let{keyword:e,data:t,schemaCode:r,it:i}=n,a=e==="maxLength"?Mn.operators.GT:Mn.operators.LT,s=i.opts.unicode===false?(0, Mn._)`${t}.length`:(0, Mn._)`${(0, ew.useFunc)(n.gen,tw.default)}(${t})`;n.fail$data((0, Mn._)`${s} ${a} ${r}`);}};pc.default=rw;});var Og=E(mc=>{Object.defineProperty(mc,"__esModule",{value:true});var iw=mt(),sw=M(),Cr=$(),aw={message:({schemaCode:n})=>(0, Cr.str)`must match pattern "${n}"`,params:({schemaCode:n})=>(0, Cr._)`{pattern: ${n}}`},ow={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:aw,code(n){let{gen:e,data:t,$data:r,schema:i,schemaCode:a,it:s}=n,o=s.opts.unicodeRegExp?"u":"";if(r){let{regExp:u}=s.opts.code,l=u.code==="new RegExp"?(0, Cr._)`new RegExp`:(0, sw.useFunc)(e,u),c=e.let("valid");e.try(()=>e.assign(c,(0, Cr._)`${l}(${a}, ${o}).test(${t})`),()=>e.assign(c,false)),n.fail$data((0, Cr._)`!${c}`);}else {let u=(0, iw.usePattern)(n,i);n.fail$data((0, Cr._)`!${u}.test(${t})`);}}};mc.default=ow;});var xg=E(gc=>{Object.defineProperty(gc,"__esModule",{value:true});var Ai=$(),uw={message({keyword:n,schemaCode:e}){let t=n==="maxProperties"?"more":"fewer";return (0, Ai.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:n})=>(0, Ai._)`{limit: ${n}}`},lw={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:uw,code(n){let{keyword:e,data:t,schemaCode:r}=n,i=e==="maxProperties"?Ai.operators.GT:Ai.operators.LT;n.fail$data((0, Ai._)`Object.keys(${t}).length ${i} ${r}`);}};gc.default=lw;});var Tg=E(yc=>{Object.defineProperty(yc,"__esModule",{value:true});var Pi=mt(),Oi=$(),cw=M(),hw={message:({params:{missingProperty:n}})=>(0, Oi.str)`must have required property '${n}'`,params:({params:{missingProperty:n}})=>(0, Oi._)`{missingProperty: ${n}}`},dw={keyword:"required",type:"object",schemaType:"array",$data:true,error:hw,code(n){let{gen:e,schema:t,schemaCode:r,data:i,$data:a,it:s}=n,{opts:o}=s;if(!a&&t.length===0)return;let u=t.length>=o.loopRequired;if(s.allErrors?l():c(),o.strictRequired){let f=n.parentSchema.properties,{definedProperties:g}=n.it;for(let y of t)if(f?.[y]===void 0&&!g.has(y)){let C=s.schemaEnv.baseId+s.errSchemaPath,_=`required property "${y}" is not defined at "${C}" (strictRequired)`;(0, cw.checkStrictMode)(s,_,s.opts.strictRequired);}}function l(){if(u||a)n.block$data(Oi.nil,h);else for(let f of t)(0, Pi.checkReportMissingProp)(n,f);}function c(){let f=e.let("missing");if(u||a){let g=e.let("valid",true);n.block$data(g,()=>p(f,g)),n.ok(g);}else e.if((0, Pi.checkMissingProp)(n,t,f)),(0, Pi.reportMissingProp)(n,f),e.else();}function h(){e.forOf("prop",r,f=>{n.setParams({missingProperty:f}),e.if((0, Pi.noPropertyInData)(e,i,f,o.ownProperties),()=>n.error());});}function p(f,g){n.setParams({missingProperty:f}),e.forOf(f,r,()=>{e.assign(g,(0, Pi.propertyInData)(e,i,f,o.ownProperties)),e.if((0, Oi.not)(g),()=>{n.error(),e.break();});},Oi.nil);}}};yc.default=dw;});var Ng=E(vc=>{Object.defineProperty(vc,"__esModule",{value:true});var xi=$(),fw={message({keyword:n,schemaCode:e}){let t=n==="maxItems"?"more":"fewer";return (0, xi.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:n})=>(0, xi._)`{limit: ${n}}`},pw={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:fw,code(n){let{keyword:e,data:t,schemaCode:r}=n,i=e==="maxItems"?xi.operators.GT:xi.operators.LT;n.fail$data((0, xi._)`${t}.length ${i} ${r}`);}};vc.default=pw;});var na=E(Cc=>{Object.defineProperty(Cc,"__esModule",{value:true});var Fg=kl();Fg.code='require("ajv/dist/runtime/equal").default';Cc.default=Fg;});var Ig=E(_c=>{Object.defineProperty(_c,"__esModule",{value:true});var bc=pi(),Fe=$(),mw=M(),gw=na(),yw={message:({params:{i:n,j:e}})=>(0, Fe.str)`must NOT have duplicate items (items ## ${e} and ${n} are identical)`,params:({params:{i:n,j:e}})=>(0, Fe._)`{i: ${n}, j: ${e}}`},vw={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:yw,code(n){let{gen:e,data:t,$data:r,schema:i,parentSchema:a,schemaCode:s,it:o}=n;if(!r&&!i)return;let u=e.let("valid"),l=a.items?(0, bc.getSchemaTypes)(a.items):[];n.block$data(u,c,(0, Fe._)`${s} === false`),n.ok(u);function c(){let g=e.let("i",(0, Fe._)`${t}.length`),y=e.let("j");n.setParams({i:g,j:y}),e.assign(u,true),e.if((0, Fe._)`${g} > 1`,()=>(h()?p:f)(g,y));}function h(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function p(g,y){let C=e.name("item"),_=(0, bc.checkDataTypes)(l,C,o.opts.strictNumbers,bc.DataType.Wrong),v=e.const("indices",(0, Fe._)`{}`);e.for((0, Fe._)`;${g}--;`,()=>{e.let(C,(0, Fe._)`${t}[${g}]`),e.if(_,(0, Fe._)`continue`),l.length>1&&e.if((0, Fe._)`typeof ${C} == "string"`,(0, Fe._)`${C} += "_"`),e.if((0, Fe._)`typeof ${v}[${C}] == "number"`,()=>{e.assign(y,(0, Fe._)`${v}[${C}]`),n.error(),e.assign(u,false).break();}).code((0, Fe._)`${v}[${C}] = ${g}`);});}function f(g,y){let C=(0, mw.useFunc)(e,gw.default),_=e.name("outer");e.label(_).for((0, Fe._)`;${g}--;`,()=>e.for((0, Fe._)`${y} = ${g}; ${y}--;`,()=>e.if((0, Fe._)`${C}(${t}[${g}], ${t}[${y}])`,()=>{n.error(),e.assign(u,false).break(_);})));}}};_c.default=vw;});var kg=E(Ec=>{Object.defineProperty(Ec,"__esModule",{value:true});var Sc=$(),Cw=M(),bw=na(),_w={message:"must be equal to constant",params:({schemaCode:n})=>(0, Sc._)`{allowedValue: ${n}}`},Sw={keyword:"const",$data:true,error:_w,code(n){let{gen:e,data:t,$data:r,schemaCode:i,schema:a}=n;r||a&&typeof a=="object"?n.fail$data((0, Sc._)`!${(0, Cw.useFunc)(e,bw.default)}(${t}, ${i})`):n.fail((0, Sc._)`${a} !== ${t}`);}};Ec.default=Sw;});var Vg=E(wc=>{Object.defineProperty(wc,"__esModule",{value:true});var Ti=$(),Ew=M(),ww=na(),Dw={message:"must be equal to one of the allowed values",params:({schemaCode:n})=>(0, Ti._)`{allowedValues: ${n}}`},Aw={keyword:"enum",schemaType:"array",$data:true,error:Dw,code(n){let{gen:e,data:t,$data:r,schema:i,schemaCode:a,it:s}=n;if(!r&&i.length===0)throw new Error("enum must have non-empty array");let o=i.length>=s.opts.loopEnum,u,l=()=>u??(u=(0, Ew.useFunc)(e,ww.default)),c;if(o||r)c=e.let("valid"),n.block$data(c,h);else {if(!Array.isArray(i))throw new Error("ajv implementation error");let f=e.const("vSchema",a);c=(0, Ti.or)(...i.map((g,y)=>p(f,y)));}n.pass(c);function h(){e.assign(c,false),e.forOf("v",a,f=>e.if((0, Ti._)`${l()}(${t}, ${f})`,()=>e.assign(c,true).break()));}function p(f,g){let y=i[g];return typeof y=="object"&&y!==null?(0, Ti._)`${l()}(${t}, ${f}[${g}])`:(0, Ti._)`${t} === ${y}`}}};wc.default=Aw;});var Ac=E(Dc=>{Object.defineProperty(Dc,"__esModule",{value:true});var Pw=Eg(),Ow=wg(),xw=Pg(),Tw=Og(),Nw=xg(),Fw=Tg(),Iw=Ng(),kw=Ig(),Vw=kg(),Rw=Vg(),$w=[Pw.default,Ow.default,xw.default,Tw.default,Nw.default,Fw.default,Iw.default,kw.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Vw.default,Rw.default];Dc.default=$w;});var Oc=E(Ni=>{Object.defineProperty(Ni,"__esModule",{value:true});Ni.validateAdditionalItems=void 0;var Gn=$(),Pc=M(),jw={message:({params:{len:n}})=>(0, Gn.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0, Gn._)`{limit: ${n}}`},Lw={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:jw,code(n){let{parentSchema:e,it:t}=n,{items:r}=e;if(!Array.isArray(r)){(0, Pc.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}Rg(n,r);}};function Rg(n,e){let{gen:t,schema:r,data:i,keyword:a,it:s}=n;s.items=true;let o=t.const("len",(0, Gn._)`${i}.length`);if(r===false)n.setParams({len:e.length}),n.pass((0, Gn._)`${o} <= ${e.length}`);else if(typeof r=="object"&&!(0, Pc.alwaysValidSchema)(s,r)){let l=t.var("valid",(0, Gn._)`${o} <= ${e.length}`);t.if((0, Gn.not)(l),()=>u(l)),n.ok(l);}function u(l){t.forRange("i",e.length,o,c=>{n.subschema({keyword:a,dataProp:c,dataPropType:Pc.Type.Num},l),s.allErrors||t.if((0, Gn.not)(l),()=>t.break());});}}Ni.validateAdditionalItems=Rg;Ni.default=Lw;});var xc=E(Fi=>{Object.defineProperty(Fi,"__esModule",{value:true});Fi.validateTuple=void 0;var $g=$(),ra=M(),qw=mt(),Bw={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(n){let{schema:e,it:t}=n;if(Array.isArray(e))return jg(n,"additionalItems",e);t.items=true,!(0, ra.alwaysValidSchema)(t,e)&&n.ok((0, qw.validateArray)(n));}};function jg(n,e,t=n.schema){let{gen:r,parentSchema:i,data:a,keyword:s,it:o}=n;c(i),o.opts.unevaluated&&t.length&&o.items!==true&&(o.items=ra.mergeEvaluated.items(r,t.length,o.items));let u=r.name("valid"),l=r.const("len",(0, $g._)`${a}.length`);t.forEach((h,p)=>{(0, ra.alwaysValidSchema)(o,h)||(r.if((0, $g._)`${l} > ${p}`,()=>n.subschema({keyword:s,schemaProp:p,dataProp:p},u)),n.ok(u));});function c(h){let{opts:p,errSchemaPath:f}=o,g=t.length,y=g===h.minItems&&(g===h.maxItems||h[e]===false);if(p.strictTuples&&!y){let C=`"${s}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0, ra.checkStrictMode)(o,C,p.strictTuples);}}}Fi.validateTuple=jg;Fi.default=Bw;});var Lg=E(Tc=>{Object.defineProperty(Tc,"__esModule",{value:true});var Ww=xc(),Mw={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:n=>(0, Ww.validateTuple)(n,"items")};Tc.default=Mw;});var Bg=E(Nc=>{Object.defineProperty(Nc,"__esModule",{value:true});var qg=$(),Gw=M(),zw=mt(),Jw=Oc(),Hw={message:({params:{len:n}})=>(0, qg.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0, qg._)`{limit: ${n}}`},Uw={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Hw,code(n){let{schema:e,parentSchema:t,it:r}=n,{prefixItems:i}=t;r.items=true,!(0, Gw.alwaysValidSchema)(r,e)&&(i?(0, Jw.validateAdditionalItems)(n,i):n.ok((0, zw.validateArray)(n)));}};Nc.default=Uw;});var Wg=E(Fc=>{Object.defineProperty(Fc,"__esModule",{value:true});var yt=$(),ia=M(),Kw={message:({params:{min:n,max:e}})=>e===void 0?(0, yt.str)`must contain at least ${n} valid item(s)`:(0, yt.str)`must contain at least ${n} and no more than ${e} valid item(s)`,params:({params:{min:n,max:e}})=>e===void 0?(0, yt._)`{minContains: ${n}}`:(0, yt._)`{minContains: ${n}, maxContains: ${e}}`},Xw={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:Kw,code(n){let{gen:e,schema:t,parentSchema:r,data:i,it:a}=n,s,o,{minContains:u,maxContains:l}=r;a.opts.next?(s=u===void 0?1:u,o=l):s=1;let c=e.const("len",(0, yt._)`${i}.length`);if(n.setParams({min:s,max:o}),o===void 0&&s===0){(0, ia.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(o!==void 0&&s>o){(0, ia.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),n.fail();return}if((0, ia.alwaysValidSchema)(a,t)){let y=(0, yt._)`${c} >= ${s}`;o!==void 0&&(y=(0, yt._)`${y} && ${c} <= ${o}`),n.pass(y);return}a.items=true;let h=e.name("valid");o===void 0&&s===1?f(h,()=>e.if(h,()=>e.break())):s===0?(e.let(h,true),o!==void 0&&e.if((0, yt._)`${i}.length > 0`,p)):(e.let(h,false),p()),n.result(h,()=>n.reset());function p(){let y=e.name("_valid"),C=e.let("count",0);f(y,()=>e.if(y,()=>g(C)));}function f(y,C){e.forRange("i",0,c,_=>{n.subschema({keyword:"contains",dataProp:_,dataPropType:ia.Type.Num,compositeRule:true},y),C();});}function g(y){e.code((0, yt._)`${y}++`),o===void 0?e.if((0, yt._)`${y} >= ${s}`,()=>e.assign(h,true).break()):(e.if((0, yt._)`${y} > ${o}`,()=>e.assign(h,false).break()),s===1?e.assign(h,true):e.if((0, yt._)`${y} >= ${s}`,()=>e.assign(h,true)));}}};Fc.default=Xw;});var sa=E($t=>{Object.defineProperty($t,"__esModule",{value:true});$t.validateSchemaDeps=$t.validatePropertyDeps=$t.error=void 0;var Ic=$(),Yw=M(),Ii=mt();$t.error={message:({params:{property:n,depsCount:e,deps:t}})=>{let r=e===1?"property":"properties";return (0, Ic.str)`must have ${r} ${t} when property ${n} is present`},params:({params:{property:n,depsCount:e,deps:t,missingProperty:r}})=>(0, Ic._)`{property: ${n},
|
|
1
|
+
import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import D,{ZodType}from'zod';import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {canvas,VideoSprite,showVideo,Assets,Text,showText,ImageSprite,showImage,ImageContainer,showImageContainer,effects,transitions}from'@drincs/pixi-vn/canvas';import {NarrationManagerStatic,narration,RegisteredLabels,LabelAbstract}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {storage}from'@drincs/pixi-vn/storage';var Qb=Object.create;var Kp=Object.defineProperty;var e0=Object.getOwnPropertyDescriptor;var t0=Object.getOwnPropertyNames;var n0=Object.getPrototypeOf,r0=Object.prototype.hasOwnProperty;var Tn=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var w=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var i0=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of t0(e))!r0.call(n,i)&&i!==t&&Kp(n,i,{get:()=>e[i],enumerable:!(r=e0(e,i))||r.enumerable});return n};var ei=(n,e,t)=>(t=n!=null?Qb(n0(n)):{},i0(e||!n||!n.__esModule?Kp(t,"default",{value:n,enumerable:true}):t,n));var li=w(Z=>{Object.defineProperty(Z,"__esModule",{value:true});Z.regexpCode=Z.getEsmExportName=Z.getProperty=Z.safeStringify=Z.stringify=Z.strConcat=Z.addCodeArg=Z.str=Z._=Z.nil=Z._Code=Z.Name=Z.IDENTIFIER=Z._CodeOrName=void 0;var oi=class{};Z._CodeOrName=oi;Z.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Vn=class extends oi{constructor(e){if(super(),!Z.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};Z.Name=Vn;var mt=class extends oi{constructor(e){super(),this._items=typeof e=="string"?[e]:e;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let e=this._items[0];return e===""||e==='""'}get str(){var e;return (e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((t,r)=>`${t}${r}`,"")}get names(){var e;return (e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((t,r)=>(r instanceof Vn&&(t[r.str]=(t[r.str]||0)+1),t),{})}};Z._Code=mt;Z.nil=new mt("");function Wf(n,...e){let t=[n[0]],r=0;for(;r<e.length;)ul(t,e[r]),t.push(n[++r]);return new mt(t)}Z._=Wf;var ol=new mt("+");function Mf(n,...e){let t=[ui(n[0])],r=0;for(;r<e.length;)t.push(ol),ul(t,e[r]),t.push(ol,ui(n[++r]));return uC(t),new mt(t)}Z.str=Mf;function ul(n,e){e instanceof mt?n.push(...e._items):e instanceof Vn?n.push(e):n.push(hC(e));}Z.addCodeArg=ul;function uC(n){let e=1;for(;e<n.length-1;){if(n[e]===ol){let t=lC(n[e-1],n[e+1]);if(t!==void 0){n.splice(e-1,3,t);continue}n[e++]="+";}e++;}}function lC(n,e){if(e==='""')return n;if(n==='""')return e;if(typeof n=="string")return e instanceof Vn||n[n.length-1]!=='"'?void 0:typeof e!="string"?`${n.slice(0,-1)}${e}"`:e[0]==='"'?n.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(n instanceof Vn))return `"${n}${e.slice(1)}`}function cC(n,e){return e.emptyStr()?n:n.emptyStr()?e:Mf`${n}${e}`}Z.strConcat=cC;function hC(n){return typeof n=="number"||typeof n=="boolean"||n===null?n:ui(Array.isArray(n)?n.join(","):n)}function dC(n){return new mt(ui(n))}Z.stringify=dC;function ui(n){return JSON.stringify(n).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Z.safeStringify=ui;function pC(n){return typeof n=="string"&&Z.IDENTIFIER.test(n)?new mt(`.${n}`):Wf`[${n}]`}Z.getProperty=pC;function fC(n){if(typeof n=="string"&&Z.IDENTIFIER.test(n))return new mt(`${n}`);throw new Error(`CodeGen: invalid export name: ${n}, use explicit $id name mapping`)}Z.getEsmExportName=fC;function mC(n){return new mt(n.toString())}Z.regexpCode=mC;});var hl=w(nt=>{Object.defineProperty(nt,"__esModule",{value:true});nt.ValueScope=nt.ValueScopeName=nt.Scope=nt.varKinds=nt.UsedValueState=void 0;var tt=li(),ll=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value;}},ks;(function(n){n[n.Started=0]="Started",n[n.Completed=1]="Completed";})(ks||(nt.UsedValueState=ks={}));nt.varKinds={const:new tt.Name("const"),let:new tt.Name("let"),var:new tt.Name("var")};var Vs=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t;}toName(e){return e instanceof tt.Name?e:this.name(e)}name(e){return new tt.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return `${e}${t.index++}`}_nameGroup(e){var t,r;if(!((r=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||r===void 0)&&r.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};nt.Scope=Vs;var Rs=class extends tt.Name{constructor(e,t){super(t),this.prefix=e;}setValue(e,{property:t,itemIndex:r}){this.value=e,this.scopePath=(0, tt._)`.${new tt.Name(t)}[${r}]`;}};nt.ValueScopeName=Rs;var gC=(0, tt._)`\n`,cl=class extends Vs{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?gC:tt.nil};}get(){return this._scope}name(e){return new Rs(e,this._newName(e))}value(e,t){var r;if(t.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:a}=i,s=(r=t.key)!==null&&r!==void 0?r:t.ref,o=this._values[a];if(o){let c=o.get(s);if(c)return c}else o=this._values[a]=new Map;o.set(s,i);let u=this._scope[a]||(this._scope[a]=[]),l=u.length;return u[l]=t.ref,i.setValue(t,{property:a,itemIndex:l}),i}getValue(e,t){let r=this._values[e];if(r)return r.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,r=>{if(r.scopePath===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return (0, tt._)`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},t,r)}_reduceValues(e,t,r={},i){let a=tt.nil;for(let s in e){let o=e[s];if(!o)continue;let u=r[s]=r[s]||new Map;o.forEach(l=>{if(u.has(l))return;u.set(l,ks.Started);let c=t(l);if(c){let h=this.opts.es5?nt.varKinds.var:nt.varKinds.const;a=(0, tt._)`${a}${h} ${l} = ${c};${this.opts._n}`;}else if(c=i?.(l))a=(0, tt._)`${a}${c}${this.opts._n}`;else throw new ll(l);u.set(l,ks.Completed);});}return a}};nt.ValueScope=cl;});var j=w(q=>{Object.defineProperty(q,"__esModule",{value:true});q.or=q.and=q.not=q.CodeGen=q.operators=q.varKinds=q.ValueScopeName=q.ValueScope=q.Scope=q.Name=q.regexpCode=q.stringify=q.getProperty=q.nil=q.strConcat=q.str=q._=void 0;var U=li(),xt=hl(),dn=li();Object.defineProperty(q,"_",{enumerable:true,get:function(){return dn._}});Object.defineProperty(q,"str",{enumerable:true,get:function(){return dn.str}});Object.defineProperty(q,"strConcat",{enumerable:true,get:function(){return dn.strConcat}});Object.defineProperty(q,"nil",{enumerable:true,get:function(){return dn.nil}});Object.defineProperty(q,"getProperty",{enumerable:true,get:function(){return dn.getProperty}});Object.defineProperty(q,"stringify",{enumerable:true,get:function(){return dn.stringify}});Object.defineProperty(q,"regexpCode",{enumerable:true,get:function(){return dn.regexpCode}});Object.defineProperty(q,"Name",{enumerable:true,get:function(){return dn.Name}});var qs=hl();Object.defineProperty(q,"Scope",{enumerable:true,get:function(){return qs.Scope}});Object.defineProperty(q,"ValueScope",{enumerable:true,get:function(){return qs.ValueScope}});Object.defineProperty(q,"ValueScopeName",{enumerable:true,get:function(){return qs.ValueScopeName}});Object.defineProperty(q,"varKinds",{enumerable:true,get:function(){return qs.varKinds}});q.operators={GT:new U._Code(">"),GTE:new U._Code(">="),LT:new U._Code("<"),LTE:new U._Code("<="),EQ:new U._Code("==="),NEQ:new U._Code("!=="),NOT:new U._Code("!"),OR:new U._Code("||"),AND:new U._Code("&&"),ADD:new U._Code("+")};var en=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},dl=class extends en{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r;}render({es5:e,_n:t}){let r=e?xt.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return `${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=cr(this.rhs,e,t)),this}get names(){return this.rhs instanceof U._CodeOrName?this.rhs.names:{}}},js=class extends en{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r;}render({_n:e}){return `${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof U.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=cr(this.rhs,e,t),this}get names(){let e=this.lhs instanceof U.Name?{}:{...this.lhs.names};return Ls(e,this.rhs)}},pl=class extends js{constructor(e,t,r,i){super(e,r,i),this.op=t;}render({_n:e}){return `${this.lhs} ${this.op}= ${this.rhs};`+e}},fl=class extends en{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `${this.label}:`+e}},ml=class extends en{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `break${this.label?` ${this.label}`:""};`+e}},gl=class extends en{constructor(e){super(),this.error=e;}render({_n:e}){return `throw ${this.error};`+e}get names(){return this.error.names}},yl=class extends en{constructor(e){super(),this.code=e;}render({_n:e}){return `${this.code};`+e}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(e,t){return this.code=cr(this.code,e,t),this}get names(){return this.code instanceof U._CodeOrName?this.code.names:{}}},ci=class extends en{constructor(e=[]){super(),this.nodes=e;}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1);}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:r}=this,i=r.length;for(;i--;){let a=r[i];a.optimizeNames(e,t)||(yC(e,a.names),r.splice(i,1));}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>$n(e,t.names),{})}},tn=class extends ci{render(e){return "{"+e._n+super.render(e)+"}"+e._n}},vl=class extends ci{},lr=class extends tn{};lr.kind="else";var Rn=class n extends tn{constructor(e,t){super(t),this.condition=e;}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===true)return this.nodes;let t=this.else;if(t){let r=t.optimizeNodes();t=this.else=Array.isArray(r)?new lr(r):r;}if(t)return e===false?t instanceof n?t:t.nodes:this.nodes.length?this:new n(Gf(e),t instanceof n?[t]:t.nodes);if(!(e===false||!this.nodes.length))return this}optimizeNames(e,t){var r;if(this.else=(r=this.else)===null||r===void 0?void 0:r.optimizeNames(e,t),!!(super.optimizeNames(e,t)||this.else))return this.condition=cr(this.condition,e,t),this}get names(){let e=super.names;return Ls(e,this.condition),this.else&&$n(e,this.else.names),e}};Rn.kind="if";var jn=class extends tn{};jn.kind="for";var bl=class extends jn{constructor(e){super(),this.iteration=e;}render(e){return `for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=cr(this.iteration,e,t),this}get names(){return $n(super.names,this.iteration.names)}},Cl=class extends jn{constructor(e,t,r,i){super(),this.varKind=e,this.name=t,this.from=r,this.to=i;}render(e){let t=e.es5?xt.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return `for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){let e=Ls(super.names,this.from);return Ls(e,this.to)}},$s=class extends jn{constructor(e,t,r,i){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=i;}render(e){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=cr(this.iterable,e,t),this}get names(){return $n(super.names,this.iterable.names)}},hi=class extends tn{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r;}render(e){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};hi.kind="func";var di=class extends ci{render(e){return "return "+super.render(e)}};di.kind="return";var Sl=class extends tn{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(e,t){var r,i;return super.optimizeNames(e,t),(r=this.catch)===null||r===void 0||r.optimizeNames(e,t),(i=this.finally)===null||i===void 0||i.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&$n(e,this.catch.names),this.finally&&$n(e,this.finally.names),e}},pi=class extends tn{constructor(e){super(),this.error=e;}render(e){return `catch(${this.error})`+super.render(e)}};pi.kind="catch";var fi=class extends tn{render(e){return "finally"+super.render(e)}};fi.kind="finally";var _l=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
2
|
+
`:""},this._extScope=e,this._scope=new xt.Scope({parent:e}),this._nodes=[new vl];}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let r=this._extScope.value(e,t);return (this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,i){let a=this._scope.toName(t);return r!==void 0&&i&&(this._constants[a.str]=r),this._leafNode(new dl(e,a,r)),a}const(e,t,r){return this._def(xt.varKinds.const,e,t,r)}let(e,t,r){return this._def(xt.varKinds.let,e,t,r)}var(e,t,r){return this._def(xt.varKinds.var,e,t,r)}assign(e,t,r){return this._leafNode(new js(e,t,r))}add(e,t){return this._leafNode(new pl(e,q.operators.ADD,t))}code(e){return typeof e=="function"?e():e!==U.nil&&this._leafNode(new yl(e)),this}object(...e){let t=["{"];for(let[r,i]of e)t.length>1&&t.push(","),t.push(r),(r!==i||this.opts.es5)&&(t.push(":"),(0, U.addCodeArg)(t,i));return t.push("}"),new U._Code(t)}if(e,t,r){if(this._blockNode(new Rn(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Rn(e))}else(){return this._elseNode(new lr)}endIf(){return this._endBlockNode(Rn,lr)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new bl(e),t)}forRange(e,t,r,i,a=this.opts.es5?xt.varKinds.var:xt.varKinds.let){let s=this._scope.toName(e);return this._for(new Cl(a,s,t,r),()=>i(s))}forOf(e,t,r,i=xt.varKinds.const){let a=this._scope.toName(e);if(this.opts.es5){let s=t instanceof U.Name?t:this.var("_arr",t);return this.forRange("_i",0,(0, U._)`${s}.length`,o=>{this.var(a,(0, U._)`${s}[${o}]`),r(a);})}return this._for(new $s("of",i,a,t),()=>r(a))}forIn(e,t,r,i=this.opts.es5?xt.varKinds.var:xt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0, U._)`Object.keys(${t})`,r);let a=this._scope.toName(e);return this._for(new $s("in",i,a,t),()=>r(a))}endFor(){return this._endBlockNode(jn)}label(e){return this._leafNode(new fl(e))}break(e){return this._leafNode(new ml(e))}return(e){let t=new di;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(di)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new Sl;if(this._blockNode(i),this.code(e),t){let a=this.name("e");this._currNode=i.catch=new pi(a),t(a);}return r&&(this._currNode=i.finally=new fi,this.code(r)),this._endBlockNode(pi,fi)}throw(e){return this._leafNode(new gl(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw new Error("CodeGen: not in self-balancing block");let r=this._nodes.length-t;if(r<0||e!==void 0&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=U.nil,r,i){return this._blockNode(new hi(e,t,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(hi)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants);}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e);}_endBlockNode(e,t){let r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof Rn))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e;}};q.CodeGen=_l;function $n(n,e){for(let t in e)n[t]=(n[t]||0)+(e[t]||0);return n}function Ls(n,e){return e instanceof U._CodeOrName?$n(n,e.names):n}function cr(n,e,t){if(n instanceof U.Name)return r(n);if(!i(n))return n;return new U._Code(n._items.reduce((a,s)=>(s instanceof U.Name&&(s=r(s)),s instanceof U._Code?a.push(...s._items):a.push(s),a),[]));function r(a){let s=t[a.str];return s===void 0||e[a.str]!==1?a:(delete e[a.str],s)}function i(a){return a instanceof U._Code&&a._items.some(s=>s instanceof U.Name&&e[s.str]===1&&t[s.str]!==void 0)}}function yC(n,e){for(let t in e)n[t]=(n[t]||0)-(e[t]||0);}function Gf(n){return typeof n=="boolean"||typeof n=="number"||n===null?!n:(0, U._)`!${wl(n)}`}q.not=Gf;var vC=zf(q.operators.AND);function bC(...n){return n.reduce(vC)}q.and=bC;var CC=zf(q.operators.OR);function SC(...n){return n.reduce(CC)}q.or=SC;function zf(n){return (e,t)=>e===U.nil?t:t===U.nil?e:(0, U._)`${wl(e)} ${n} ${wl(t)}`}function wl(n){return n instanceof U.Name?n:(0, U._)`(${n})`}});var M=w(W=>{Object.defineProperty(W,"__esModule",{value:true});W.checkStrictMode=W.getErrorPath=W.Type=W.useFunc=W.setEvaluated=W.evaluatedPropsToName=W.mergeEvaluated=W.eachItem=W.unescapeJsonPointer=W.escapeJsonPointer=W.escapeFragment=W.unescapeFragment=W.schemaRefOrVal=W.schemaHasRulesButRef=W.schemaHasRules=W.checkUnknownRules=W.alwaysValidSchema=W.toHash=void 0;var ue=j(),_C=li();function wC(n){let e={};for(let t of n)e[t]=true;return e}W.toHash=wC;function EC(n,e){return typeof e=="boolean"?e:Object.keys(e).length===0?true:(Uf(n,e),!Kf(e,n.self.RULES.all))}W.alwaysValidSchema=EC;function Uf(n,e=n.schema){let{opts:t,self:r}=n;if(!t.strictSchema||typeof e=="boolean")return;let i=r.RULES.keywords;for(let a in e)i[a]||Zf(n,`unknown keyword: "${a}"`);}W.checkUnknownRules=Uf;function Kf(n,e){if(typeof n=="boolean")return !n;for(let t in n)if(e[t])return true;return false}W.schemaHasRules=Kf;function DC(n,e){if(typeof n=="boolean")return !n;for(let t in n)if(t!=="$ref"&&e.all[t])return true;return false}W.schemaHasRulesButRef=DC;function AC({topSchemaRef:n,schemaPath:e},t,r,i){if(!i){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return (0, ue._)`${t}`}return (0, ue._)`${n}${e}${(0, ue.getProperty)(r)}`}W.schemaRefOrVal=AC;function OC(n){return Xf(decodeURIComponent(n))}W.unescapeFragment=OC;function PC(n){return encodeURIComponent(Dl(n))}W.escapeFragment=PC;function Dl(n){return typeof n=="number"?`${n}`:n.replace(/~/g,"~0").replace(/\//g,"~1")}W.escapeJsonPointer=Dl;function Xf(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}W.unescapeJsonPointer=Xf;function xC(n,e){if(Array.isArray(n))for(let t of n)e(t);else e(n);}W.eachItem=xC;function Jf({mergeNames:n,mergeToName:e,mergeValues:t,resultToName:r}){return (i,a,s,o)=>{let u=s===void 0?a:s instanceof ue.Name?(a instanceof ue.Name?n(i,a,s):e(i,a,s),s):a instanceof ue.Name?(e(i,s,a),a):t(a,s);return o===ue.Name&&!(u instanceof ue.Name)?r(i,u):u}}W.mergeEvaluated={props:Jf({mergeNames:(n,e,t)=>n.if((0, ue._)`${t} !== true && ${e} !== undefined`,()=>{n.if((0, ue._)`${e} === true`,()=>n.assign(t,true),()=>n.assign(t,(0, ue._)`${t} || {}`).code((0, ue._)`Object.assign(${t}, ${e})`));}),mergeToName:(n,e,t)=>n.if((0, ue._)`${t} !== true`,()=>{e===true?n.assign(t,true):(n.assign(t,(0, ue._)`${t} || {}`),Al(n,t,e));}),mergeValues:(n,e)=>n===true?true:{...n,...e},resultToName:Yf}),items:Jf({mergeNames:(n,e,t)=>n.if((0, ue._)`${t} !== true && ${e} !== undefined`,()=>n.assign(t,(0, ue._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(n,e,t)=>n.if((0, ue._)`${t} !== true`,()=>n.assign(t,e===true?true:(0, ue._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(n,e)=>n===true?true:Math.max(n,e),resultToName:(n,e)=>n.var("items",e)})};function Yf(n,e){if(e===true)return n.var("props",true);let t=n.var("props",(0, ue._)`{}`);return e!==void 0&&Al(n,t,e),t}W.evaluatedPropsToName=Yf;function Al(n,e,t){Object.keys(t).forEach(r=>n.assign((0, ue._)`${e}${(0, ue.getProperty)(r)}`,true));}W.setEvaluated=Al;var Hf={};function TC(n,e){return n.scopeValue("func",{ref:e,code:Hf[e.code]||(Hf[e.code]=new _C._Code(e.code))})}W.useFunc=TC;var El;(function(n){n[n.Num=0]="Num",n[n.Str=1]="Str";})(El||(W.Type=El={}));function NC(n,e,t){if(n instanceof ue.Name){let r=e===El.Num;return t?r?(0, ue._)`"[" + ${n} + "]"`:(0, ue._)`"['" + ${n} + "']"`:r?(0, ue._)`"/" + ${n}`:(0, ue._)`"/" + ${n}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0, ue.getProperty)(n).toString():"/"+Dl(n)}W.getErrorPath=NC;function Zf(n,e,t=n.opts.strictSchema){if(t){if(e=`strict mode: ${e}`,t===true)throw new Error(e);n.self.logger.warn(e);}}W.checkStrictMode=Zf;});var gt=w(Ol=>{Object.defineProperty(Ol,"__esModule",{value:true});var Re=j(),FC={data:new Re.Name("data"),valCxt:new Re.Name("valCxt"),instancePath:new Re.Name("instancePath"),parentData:new Re.Name("parentData"),parentDataProperty:new Re.Name("parentDataProperty"),rootData:new Re.Name("rootData"),dynamicAnchors:new Re.Name("dynamicAnchors"),vErrors:new Re.Name("vErrors"),errors:new Re.Name("errors"),this:new Re.Name("this"),self:new Re.Name("self"),scope:new Re.Name("scope"),json:new Re.Name("json"),jsonPos:new Re.Name("jsonPos"),jsonLen:new Re.Name("jsonLen"),jsonPart:new Re.Name("jsonPart")};Ol.default=FC;});var mi=w(je=>{Object.defineProperty(je,"__esModule",{value:true});je.extendErrors=je.resetErrorsCount=je.reportExtraError=je.reportError=je.keyword$DataError=je.keywordError=void 0;var X=j(),Bs=M(),Ue=gt();je.keywordError={message:({keyword:n})=>(0, X.str)`must pass "${n}" keyword validation`};je.keyword$DataError={message:({keyword:n,schemaType:e})=>e?(0, X.str)`"${n}" keyword must be ${e} ($data)`:(0, X.str)`"${n}" keyword is invalid ($data)`};function IC(n,e=je.keywordError,t,r){let{it:i}=n,{gen:a,compositeRule:s,allErrors:o}=i,u=tm(n,e,t);r??(s||o)?Qf(a,u):em(i,(0, X._)`[${u}]`);}je.reportError=IC;function kC(n,e=je.keywordError,t){let{it:r}=n,{gen:i,compositeRule:a,allErrors:s}=r,o=tm(n,e,t);Qf(i,o),a||s||em(r,Ue.default.vErrors);}je.reportExtraError=kC;function VC(n,e){n.assign(Ue.default.errors,e),n.if((0, X._)`${Ue.default.vErrors} !== null`,()=>n.if(e,()=>n.assign((0, X._)`${Ue.default.vErrors}.length`,e),()=>n.assign(Ue.default.vErrors,null)));}je.resetErrorsCount=VC;function RC({gen:n,keyword:e,schemaValue:t,data:r,errsCount:i,it:a}){if(i===void 0)throw new Error("ajv implementation error");let s=n.name("err");n.forRange("i",i,Ue.default.errors,o=>{n.const(s,(0, X._)`${Ue.default.vErrors}[${o}]`),n.if((0, X._)`${s}.instancePath === undefined`,()=>n.assign((0, X._)`${s}.instancePath`,(0, X.strConcat)(Ue.default.instancePath,a.errorPath))),n.assign((0, X._)`${s}.schemaPath`,(0, X.str)`${a.errSchemaPath}/${e}`),a.opts.verbose&&(n.assign((0, X._)`${s}.schema`,t),n.assign((0, X._)`${s}.data`,r));});}je.extendErrors=RC;function Qf(n,e){let t=n.const("err",e);n.if((0, X._)`${Ue.default.vErrors} === null`,()=>n.assign(Ue.default.vErrors,(0, X._)`[${t}]`),(0, X._)`${Ue.default.vErrors}.push(${t})`),n.code((0, X._)`${Ue.default.errors}++`);}function em(n,e){let{gen:t,validateName:r,schemaEnv:i}=n;i.$async?t.throw((0, X._)`new ${n.ValidationError}(${e})`):(t.assign((0, X._)`${r}.errors`,e),t.return(false));}var Ln={keyword:new X.Name("keyword"),schemaPath:new X.Name("schemaPath"),params:new X.Name("params"),propertyName:new X.Name("propertyName"),message:new X.Name("message"),schema:new X.Name("schema"),parentSchema:new X.Name("parentSchema")};function tm(n,e,t){let{createErrors:r}=n.it;return r===false?(0, X._)`{}`:jC(n,e,t)}function jC(n,e,t={}){let{gen:r,it:i}=n,a=[$C(i,t),LC(n,t)];return qC(n,e,a),r.object(...a)}function $C({errorPath:n},{instancePath:e}){let t=e?(0, X.str)`${n}${(0, Bs.getErrorPath)(e,Bs.Type.Str)}`:n;return [Ue.default.instancePath,(0, X.strConcat)(Ue.default.instancePath,t)]}function LC({keyword:n,it:{errSchemaPath:e}},{schemaPath:t,parentSchema:r}){let i=r?e:(0, X.str)`${e}/${n}`;return t&&(i=(0, X.str)`${i}${(0, Bs.getErrorPath)(t,Bs.Type.Str)}`),[Ln.schemaPath,i]}function qC(n,{params:e,message:t},r){let{keyword:i,data:a,schemaValue:s,it:o}=n,{opts:u,propertyName:l,topSchemaRef:c,schemaPath:h}=o;r.push([Ln.keyword,i],[Ln.params,typeof e=="function"?e(n):e||(0, X._)`{}`]),u.messages&&r.push([Ln.message,typeof t=="function"?t(n):t]),u.verbose&&r.push([Ln.schema,s],[Ln.parentSchema,(0, X._)`${c}${h}`],[Ue.default.data,a]),l&&r.push([Ln.propertyName,l]);}});var rm=w(hr=>{Object.defineProperty(hr,"__esModule",{value:true});hr.boolOrEmptySchema=hr.topBoolOrEmptySchema=void 0;var BC=mi(),WC=j(),MC=gt(),GC={message:"boolean schema is false"};function zC(n){let{gen:e,schema:t,validateName:r}=n;t===false?nm(n,false):typeof t=="object"&&t.$async===true?e.return(MC.default.data):(e.assign((0, WC._)`${r}.errors`,null),e.return(true));}hr.topBoolOrEmptySchema=zC;function JC(n,e){let{gen:t,schema:r}=n;r===false?(t.var(e,false),nm(n)):t.var(e,true);}hr.boolOrEmptySchema=JC;function nm(n,e){let{gen:t,data:r}=n,i={gen:t,keyword:"false schema",data:r,schema:false,schemaCode:false,schemaValue:false,params:{},it:n};(0, BC.reportError)(i,GC,void 0,e);}});var Pl=w(dr=>{Object.defineProperty(dr,"__esModule",{value:true});dr.getRules=dr.isJSONType=void 0;var HC=["string","number","integer","boolean","null","object","array"],UC=new Set(HC);function KC(n){return typeof n=="string"&&UC.has(n)}dr.isJSONType=KC;function XC(){let n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return {types:{...n,integer:true,boolean:true,null:true},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}dr.getRules=XC;});var xl=w(pn=>{Object.defineProperty(pn,"__esModule",{value:true});pn.shouldUseRule=pn.shouldUseGroup=pn.schemaHasRulesForType=void 0;function YC({schema:n,self:e},t){let r=e.RULES.types[t];return r&&r!==true&&im(n,r)}pn.schemaHasRulesForType=YC;function im(n,e){return e.rules.some(t=>sm(n,t))}pn.shouldUseGroup=im;function sm(n,e){var t;return n[e.keyword]!==void 0||((t=e.definition.implements)===null||t===void 0?void 0:t.some(r=>n[r]!==void 0))}pn.shouldUseRule=sm;});var gi=w($e=>{Object.defineProperty($e,"__esModule",{value:true});$e.reportTypeError=$e.checkDataTypes=$e.checkDataType=$e.coerceAndCheckDataType=$e.getJSONTypes=$e.getSchemaTypes=$e.DataType=void 0;var ZC=Pl(),QC=xl(),eS=mi(),$=j(),am=M(),pr;(function(n){n[n.Correct=0]="Correct",n[n.Wrong=1]="Wrong";})(pr||($e.DataType=pr={}));function tS(n){let e=om(n.type);if(e.includes("null")){if(n.nullable===false)throw new Error("type: null contradicts nullable: false")}else {if(!e.length&&n.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');n.nullable===true&&e.push("null");}return e}$e.getSchemaTypes=tS;function om(n){let e=Array.isArray(n)?n:n?[n]:[];if(e.every(ZC.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}$e.getJSONTypes=om;function nS(n,e){let{gen:t,data:r,opts:i}=n,a=rS(e,i.coerceTypes),s=e.length>0&&!(a.length===0&&e.length===1&&(0, QC.schemaHasRulesForType)(n,e[0]));if(s){let o=Nl(e,r,i.strictNumbers,pr.Wrong);t.if(o,()=>{a.length?iS(n,e,a):Fl(n);});}return s}$e.coerceAndCheckDataType=nS;var um=new Set(["string","number","integer","boolean","null"]);function rS(n,e){return e?n.filter(t=>um.has(t)||e==="array"&&t==="array"):[]}function iS(n,e,t){let{gen:r,data:i,opts:a}=n,s=r.let("dataType",(0, $._)`typeof ${i}`),o=r.let("coerced",(0, $._)`undefined`);a.coerceTypes==="array"&&r.if((0, $._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>r.assign(i,(0, $._)`${i}[0]`).assign(s,(0, $._)`typeof ${i}`).if(Nl(e,i,a.strictNumbers),()=>r.assign(o,i))),r.if((0, $._)`${o} !== undefined`);for(let l of t)(um.has(l)||l==="array"&&a.coerceTypes==="array")&&u(l);r.else(),Fl(n),r.endIf(),r.if((0, $._)`${o} !== undefined`,()=>{r.assign(i,o),sS(n,o);});function u(l){switch(l){case "string":r.elseIf((0, $._)`${s} == "number" || ${s} == "boolean"`).assign(o,(0, $._)`"" + ${i}`).elseIf((0, $._)`${i} === null`).assign(o,(0, $._)`""`);return;case "number":r.elseIf((0, $._)`${s} == "boolean" || ${i} === null
|
|
3
|
+
|| (${s} == "string" && ${i} && ${i} == +${i})`).assign(o,(0, $._)`+${i}`);return;case "integer":r.elseIf((0, $._)`${s} === "boolean" || ${i} === null
|
|
4
|
+
|| (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(o,(0, $._)`+${i}`);return;case "boolean":r.elseIf((0, $._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(o,false).elseIf((0, $._)`${i} === "true" || ${i} === 1`).assign(o,true);return;case "null":r.elseIf((0, $._)`${i} === "" || ${i} === 0 || ${i} === false`),r.assign(o,null);return;case "array":r.elseIf((0, $._)`${s} === "string" || ${s} === "number"
|
|
5
|
+
|| ${s} === "boolean" || ${i} === null`).assign(o,(0, $._)`[${i}]`);}}}function sS({gen:n,parentData:e,parentDataProperty:t},r){n.if((0, $._)`${e} !== undefined`,()=>n.assign((0, $._)`${e}[${t}]`,r));}function Tl(n,e,t,r=pr.Correct){let i=r===pr.Correct?$.operators.EQ:$.operators.NEQ,a;switch(n){case "null":return (0, $._)`${e} ${i} null`;case "array":a=(0, $._)`Array.isArray(${e})`;break;case "object":a=(0, $._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case "integer":a=s((0, $._)`!(${e} % 1) && !isNaN(${e})`);break;case "number":a=s();break;default:return (0, $._)`typeof ${e} ${i} ${n}`}return r===pr.Correct?a:(0, $.not)(a);function s(o=$.nil){return (0, $.and)((0, $._)`typeof ${e} == "number"`,o,t?(0, $._)`isFinite(${e})`:$.nil)}}$e.checkDataType=Tl;function Nl(n,e,t,r){if(n.length===1)return Tl(n[0],e,t,r);let i,a=(0, am.toHash)(n);if(a.array&&a.object){let s=(0, $._)`typeof ${e} != "object"`;i=a.null?s:(0, $._)`!${e} || ${s}`,delete a.null,delete a.array,delete a.object;}else i=$.nil;a.number&&delete a.integer;for(let s in a)i=(0, $.and)(i,Tl(s,e,t,r));return i}$e.checkDataTypes=Nl;var aS={message:({schema:n})=>`must be ${n}`,params:({schema:n,schemaValue:e})=>typeof n=="string"?(0, $._)`{type: ${n}}`:(0, $._)`{type: ${e}}`};function Fl(n){let e=oS(n);(0, eS.reportError)(e,aS);}$e.reportTypeError=Fl;function oS(n){let{gen:e,data:t,schema:r}=n,i=(0, am.schemaRefOrVal)(n,r,"type");return {gen:e,keyword:"type",data:t,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:n}}});var cm=w(Ws=>{Object.defineProperty(Ws,"__esModule",{value:true});Ws.assignDefaults=void 0;var fr=j(),uS=M();function lS(n,e){let{properties:t,items:r}=n.schema;if(e==="object"&&t)for(let i in t)lm(n,i,t[i].default);else e==="array"&&Array.isArray(r)&&r.forEach((i,a)=>lm(n,a,i.default));}Ws.assignDefaults=lS;function lm(n,e,t){let{gen:r,compositeRule:i,data:a,opts:s}=n;if(t===void 0)return;let o=(0, fr._)`${a}${(0, fr.getProperty)(e)}`;if(i){(0, uS.checkStrictMode)(n,`default is ignored for: ${o}`);return}let u=(0, fr._)`${o} === undefined`;s.useDefaults==="empty"&&(u=(0, fr._)`${u} || ${o} === null || ${o} === ""`),r.if(u,(0, fr._)`${o} = ${(0, fr.stringify)(t)}`);}});var yt=w(ae=>{Object.defineProperty(ae,"__esModule",{value:true});ae.validateUnion=ae.validateArray=ae.usePattern=ae.callValidateCode=ae.schemaProperties=ae.allSchemaProperties=ae.noPropertyInData=ae.propertyInData=ae.isOwnProperty=ae.hasPropFunc=ae.reportMissingProp=ae.checkMissingProp=ae.checkReportMissingProp=void 0;var fe=j(),Il=M(),fn=gt(),cS=M();function hS(n,e){let{gen:t,data:r,it:i}=n;t.if(Vl(t,r,e,i.opts.ownProperties),()=>{n.setParams({missingProperty:(0, fe._)`${e}`},true),n.error();});}ae.checkReportMissingProp=hS;function dS({gen:n,data:e,it:{opts:t}},r,i){return (0, fe.or)(...r.map(a=>(0, fe.and)(Vl(n,e,a,t.ownProperties),(0, fe._)`${i} = ${a}`)))}ae.checkMissingProp=dS;function pS(n,e){n.setParams({missingProperty:e},true),n.error();}ae.reportMissingProp=pS;function hm(n){return n.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, fe._)`Object.prototype.hasOwnProperty`})}ae.hasPropFunc=hm;function kl(n,e,t){return (0, fe._)`${hm(n)}.call(${e}, ${t})`}ae.isOwnProperty=kl;function fS(n,e,t,r){let i=(0, fe._)`${e}${(0, fe.getProperty)(t)} !== undefined`;return r?(0, fe._)`${i} && ${kl(n,e,t)}`:i}ae.propertyInData=fS;function Vl(n,e,t,r){let i=(0, fe._)`${e}${(0, fe.getProperty)(t)} === undefined`;return r?(0, fe.or)(i,(0, fe.not)(kl(n,e,t))):i}ae.noPropertyInData=Vl;function dm(n){return n?Object.keys(n).filter(e=>e!=="__proto__"):[]}ae.allSchemaProperties=dm;function mS(n,e){return dm(e).filter(t=>!(0, Il.alwaysValidSchema)(n,e[t]))}ae.schemaProperties=mS;function gS({schemaCode:n,data:e,it:{gen:t,topSchemaRef:r,schemaPath:i,errorPath:a},it:s},o,u,l){let c=l?(0, fe._)`${n}, ${e}, ${r}${i}`:e,h=[[fn.default.instancePath,(0, fe.strConcat)(fn.default.instancePath,a)],[fn.default.parentData,s.parentData],[fn.default.parentDataProperty,s.parentDataProperty],[fn.default.rootData,fn.default.rootData]];s.opts.dynamicRef&&h.push([fn.default.dynamicAnchors,fn.default.dynamicAnchors]);let f=(0, fe._)`${c}, ${t.object(...h)}`;return u!==fe.nil?(0, fe._)`${o}.call(${u}, ${f})`:(0, fe._)`${o}(${f})`}ae.callValidateCode=gS;var yS=(0, fe._)`new RegExp`;function vS({gen:n,it:{opts:e}},t){let r=e.unicodeRegExp?"u":"",{regExp:i}=e.code,a=i(t,r);return n.scopeValue("pattern",{key:a.toString(),ref:a,code:(0, fe._)`${i.code==="new RegExp"?yS:(0, cS.useFunc)(n,i)}(${t}, ${r})`})}ae.usePattern=vS;function bS(n){let{gen:e,data:t,keyword:r,it:i}=n,a=e.name("valid");if(i.allErrors){let o=e.let("valid",true);return s(()=>e.assign(o,false)),o}return e.var(a,true),s(()=>e.break()),a;function s(o){let u=e.const("len",(0, fe._)`${t}.length`);e.forRange("i",0,u,l=>{n.subschema({keyword:r,dataProp:l,dataPropType:Il.Type.Num},a),e.if((0, fe.not)(a),o);});}}ae.validateArray=bS;function CS(n){let{gen:e,schema:t,keyword:r,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(u=>(0, Il.alwaysValidSchema)(i,u))&&!i.opts.unevaluated)return;let s=e.let("valid",false),o=e.name("_valid");e.block(()=>t.forEach((u,l)=>{let c=n.subschema({keyword:r,schemaProp:l,compositeRule:true},o);e.assign(s,(0, fe._)`${s} || ${o}`),n.mergeValidEvaluated(c,o)||e.if((0, fe.not)(s));})),n.result(s,()=>n.reset(),()=>n.error(true));}ae.validateUnion=CS;});var mm=w(jt=>{Object.defineProperty(jt,"__esModule",{value:true});jt.validateKeywordUsage=jt.validSchemaType=jt.funcKeywordCode=jt.macroKeywordCode=void 0;var Ke=j(),qn=gt(),SS=yt(),_S=mi();function wS(n,e){let{gen:t,keyword:r,schema:i,parentSchema:a,it:s}=n,o=e.macro.call(s.self,i,a,s),u=fm(t,r,o);s.opts.validateSchema!==false&&s.self.validateSchema(o,true);let l=t.name("valid");n.subschema({schema:o,schemaPath:Ke.nil,errSchemaPath:`${s.errSchemaPath}/${r}`,topSchemaRef:u,compositeRule:true},l),n.pass(l,()=>n.error(true));}jt.macroKeywordCode=wS;function ES(n,e){var t;let{gen:r,keyword:i,schema:a,parentSchema:s,$data:o,it:u}=n;AS(u,e);let l=!o&&e.compile?e.compile.call(u.self,a,s,u):e.validate,c=fm(r,i,l),h=r.let("valid");n.block$data(h,f),n.ok((t=e.valid)!==null&&t!==void 0?t:h);function f(){if(e.errors===false)y(),e.modifying&&pm(n),C(()=>n.error());else {let S=e.async?p():g();e.modifying&&pm(n),C(()=>DS(n,S));}}function p(){let S=r.let("ruleErrs",null);return r.try(()=>y((0, Ke._)`await `),v=>r.assign(h,false).if((0, Ke._)`${v} instanceof ${u.ValidationError}`,()=>r.assign(S,(0, Ke._)`${v}.errors`),()=>r.throw(v))),S}function g(){let S=(0, Ke._)`${c}.errors`;return r.assign(S,null),y(Ke.nil),S}function y(S=e.async?(0, Ke._)`await `:Ke.nil){let v=u.opts.passContext?qn.default.this:qn.default.self,d=!("compile"in e&&!o||e.schema===false);r.assign(h,(0, Ke._)`${S}${(0, SS.callValidateCode)(n,c,v,d)}`,e.modifying);}function C(S){var v;r.if((0, Ke.not)((v=e.valid)!==null&&v!==void 0?v:h),S);}}jt.funcKeywordCode=ES;function pm(n){let{gen:e,data:t,it:r}=n;e.if(r.parentData,()=>e.assign(t,(0, Ke._)`${r.parentData}[${r.parentDataProperty}]`));}function DS(n,e){let{gen:t}=n;t.if((0, Ke._)`Array.isArray(${e})`,()=>{t.assign(qn.default.vErrors,(0, Ke._)`${qn.default.vErrors} === null ? ${e} : ${qn.default.vErrors}.concat(${e})`).assign(qn.default.errors,(0, Ke._)`${qn.default.vErrors}.length`),(0, _S.extendErrors)(n);},()=>n.error());}function AS({schemaEnv:n},e){if(e.async&&!n.$async)throw new Error("async keyword in sync schema")}function fm(n,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return n.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0, Ke.stringify)(t)})}function OS(n,e,t=false){return !e.length||e.some(r=>r==="array"?Array.isArray(n):r==="object"?n&&typeof n=="object"&&!Array.isArray(n):typeof n==r||t&&typeof n>"u")}jt.validSchemaType=OS;function PS({schema:n,opts:e,self:t,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(o=>!Object.prototype.hasOwnProperty.call(n,o)))throw new Error(`parent schema must have dependencies of ${a}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(n[a])){let u=`keyword "${a}" value is invalid at path "${r}": `+t.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(u);else throw new Error(u)}}jt.validateKeywordUsage=PS;});var ym=w(mn=>{Object.defineProperty(mn,"__esModule",{value:true});mn.extendSubschemaMode=mn.extendSubschemaData=mn.getSubschema=void 0;var $t=j(),gm=M();function xS(n,{keyword:e,schemaProp:t,schema:r,schemaPath:i,errSchemaPath:a,topSchemaRef:s}){if(e!==void 0&&r!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let o=n.schema[e];return t===void 0?{schema:o,schemaPath:(0, $t._)`${n.schemaPath}${(0, $t.getProperty)(e)}`,errSchemaPath:`${n.errSchemaPath}/${e}`}:{schema:o[t],schemaPath:(0, $t._)`${n.schemaPath}${(0, $t.getProperty)(e)}${(0, $t.getProperty)(t)}`,errSchemaPath:`${n.errSchemaPath}/${e}/${(0, gm.escapeFragment)(t)}`}}if(r!==void 0){if(i===void 0||a===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return {schema:r,schemaPath:i,topSchemaRef:s,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')}mn.getSubschema=xS;function TS(n,e,{dataProp:t,dataPropType:r,data:i,dataTypes:a,propertyName:s}){if(i!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:o}=e;if(t!==void 0){let{errorPath:l,dataPathArr:c,opts:h}=e,f=o.let("data",(0, $t._)`${e.data}${(0, $t.getProperty)(t)}`,true);u(f),n.errorPath=(0, $t.str)`${l}${(0, gm.getErrorPath)(t,r,h.jsPropertySyntax)}`,n.parentDataProperty=(0, $t._)`${t}`,n.dataPathArr=[...c,n.parentDataProperty];}if(i!==void 0){let l=i instanceof $t.Name?i:o.let("data",i,true);u(l),s!==void 0&&(n.propertyName=s);}a&&(n.dataTypes=a);function u(l){n.data=l,n.dataLevel=e.dataLevel+1,n.dataTypes=[],e.definedProperties=new Set,n.parentData=e.data,n.dataNames=[...e.dataNames,l];}}mn.extendSubschemaData=TS;function NS(n,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(n.compositeRule=r),i!==void 0&&(n.createErrors=i),a!==void 0&&(n.allErrors=a),n.jtdDiscriminator=e,n.jtdMetadata=t;}mn.extendSubschemaMode=NS;});var Rl=w((TI,vm)=>{vm.exports=function n(e,t){if(e===t)return true;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return false;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=t.length)return false;for(i=r;i--!==0;)if(!n(e[i],t[i]))return false;return true}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return false;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,a[i]))return false;for(i=r;i--!==0;){var s=a[i];if(!n(e[s],t[s]))return false}return true}return e!==e&&t!==t};});var Cm=w((NI,bm)=>{var gn=bm.exports=function(n,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var r=typeof t=="function"?t:t.pre||function(){},i=t.post||function(){};Ms(e,r,i,n,"",n);};gn.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};gn.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};gn.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};gn.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function Ms(n,e,t,r,i,a,s,o,u,l){if(r&&typeof r=="object"&&!Array.isArray(r)){e(r,i,a,s,o,u,l);for(var c in r){var h=r[c];if(Array.isArray(h)){if(c in gn.arrayKeywords)for(var f=0;f<h.length;f++)Ms(n,e,t,h[f],i+"/"+c+"/"+f,a,i,c,r,f);}else if(c in gn.propsKeywords){if(h&&typeof h=="object")for(var p in h)Ms(n,e,t,h[p],i+"/"+c+"/"+FS(p),a,i,c,r,p);}else (c in gn.keywords||n.allKeys&&!(c in gn.skipKeywords))&&Ms(n,e,t,h,i+"/"+c,a,i,c,r);}t(r,i,a,s,o,u,l);}}function FS(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}});var yi=w(rt=>{Object.defineProperty(rt,"__esModule",{value:true});rt.getSchemaRefs=rt.resolveUrl=rt.normalizeId=rt._getFullPath=rt.getFullPath=rt.inlineRef=void 0;var IS=M(),kS=Rl(),VS=Cm(),RS=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function jS(n,e=true){return typeof n=="boolean"?true:e===true?!jl(n):e?Sm(n)<=e:false}rt.inlineRef=jS;var $S=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function jl(n){for(let e in n){if($S.has(e))return true;let t=n[e];if(Array.isArray(t)&&t.some(jl)||typeof t=="object"&&jl(t))return true}return false}function Sm(n){let e=0;for(let t in n){if(t==="$ref")return 1/0;if(e++,!RS.has(t)&&(typeof n[t]=="object"&&(0, IS.eachItem)(n[t],r=>e+=Sm(r)),e===1/0))return 1/0}return e}function _m(n,e="",t){t!==false&&(e=mr(e));let r=n.parse(e);return wm(n,r)}rt.getFullPath=_m;function wm(n,e){return n.serialize(e).split("#")[0]+"#"}rt._getFullPath=wm;var LS=/#\/?$/;function mr(n){return n?n.replace(LS,""):""}rt.normalizeId=mr;function qS(n,e,t){return t=mr(t),n.resolve(e,t)}rt.resolveUrl=qS;var BS=/^[a-z_][-a-z0-9._]*$/i;function WS(n,e){if(typeof n=="boolean")return {};let{schemaId:t,uriResolver:r}=this.opts,i=mr(n[t]||e),a={"":i},s=_m(r,i,false),o={},u=new Set;return VS(n,{allKeys:true},(h,f,p,g)=>{if(g===void 0)return;let y=s+f,C=a[g];typeof h[t]=="string"&&(C=S.call(this,h[t])),v.call(this,h.$anchor),v.call(this,h.$dynamicAnchor),a[f]=C;function S(d){let _=this.opts.uriResolver.resolve;if(d=mr(C?_(C,d):d),u.has(d))throw c(d);u.add(d);let m=this.refs[d];return typeof m=="string"&&(m=this.refs[m]),typeof m=="object"?l(h,m.schema,d):d!==mr(y)&&(d[0]==="#"?(l(h,o[d],d),o[d]=h):this.refs[d]=y),d}function v(d){if(typeof d=="string"){if(!BS.test(d))throw new Error(`invalid anchor "${d}"`);S.call(this,`#${d}`);}}}),o;function l(h,f,p){if(f!==void 0&&!kS(h,f))throw c(p)}function c(h){return new Error(`reference "${h}" resolves to more than one schema`)}}rt.getSchemaRefs=WS;});var gr=w(yn=>{Object.defineProperty(yn,"__esModule",{value:true});yn.getData=yn.KeywordCxt=yn.validateFunctionCode=void 0;var Pm=rm(),Em=gi(),Ll=xl(),Gs=gi(),MS=cm(),bi=mm(),$l=ym(),N=j(),V=gt(),GS=yi(),nn=M(),vi=mi();function zS(n){if(Nm(n)&&(Fm(n),Tm(n))){US(n);return}xm(n,()=>(0, Pm.topBoolOrEmptySchema)(n));}yn.validateFunctionCode=zS;function xm({gen:n,validateName:e,schema:t,schemaEnv:r,opts:i},a){i.code.es5?n.func(e,(0, N._)`${V.default.data}, ${V.default.valCxt}`,r.$async,()=>{n.code((0, N._)`"use strict"; ${Dm(t,i)}`),HS(n,i),n.code(a);}):n.func(e,(0, N._)`${V.default.data}, ${JS(i)}`,r.$async,()=>n.code(Dm(t,i)).code(a));}function JS(n){return (0, N._)`{${V.default.instancePath}="", ${V.default.parentData}, ${V.default.parentDataProperty}, ${V.default.rootData}=${V.default.data}${n.dynamicRef?(0, N._)`, ${V.default.dynamicAnchors}={}`:N.nil}}={}`}function HS(n,e){n.if(V.default.valCxt,()=>{n.var(V.default.instancePath,(0, N._)`${V.default.valCxt}.${V.default.instancePath}`),n.var(V.default.parentData,(0, N._)`${V.default.valCxt}.${V.default.parentData}`),n.var(V.default.parentDataProperty,(0, N._)`${V.default.valCxt}.${V.default.parentDataProperty}`),n.var(V.default.rootData,(0, N._)`${V.default.valCxt}.${V.default.rootData}`),e.dynamicRef&&n.var(V.default.dynamicAnchors,(0, N._)`${V.default.valCxt}.${V.default.dynamicAnchors}`);},()=>{n.var(V.default.instancePath,(0, N._)`""`),n.var(V.default.parentData,(0, N._)`undefined`),n.var(V.default.parentDataProperty,(0, N._)`undefined`),n.var(V.default.rootData,V.default.data),e.dynamicRef&&n.var(V.default.dynamicAnchors,(0, N._)`{}`);});}function US(n){let{schema:e,opts:t,gen:r}=n;xm(n,()=>{t.$comment&&e.$comment&&km(n),QS(n),r.let(V.default.vErrors,null),r.let(V.default.errors,0),t.unevaluated&&KS(n),Im(n),n_(n);});}function KS(n){let{gen:e,validateName:t}=n;n.evaluated=e.const("evaluated",(0, N._)`${t}.evaluated`),e.if((0, N._)`${n.evaluated}.dynamicProps`,()=>e.assign((0, N._)`${n.evaluated}.props`,(0, N._)`undefined`)),e.if((0, N._)`${n.evaluated}.dynamicItems`,()=>e.assign((0, N._)`${n.evaluated}.items`,(0, N._)`undefined`));}function Dm(n,e){let t=typeof n=="object"&&n[e.schemaId];return t&&(e.code.source||e.code.process)?(0, N._)`/*# sourceURL=${t} */`:N.nil}function XS(n,e){if(Nm(n)&&(Fm(n),Tm(n))){YS(n,e);return}(0, Pm.boolOrEmptySchema)(n,e);}function Tm({schema:n,self:e}){if(typeof n=="boolean")return !n;for(let t in n)if(e.RULES.all[t])return true;return false}function Nm(n){return typeof n.schema!="boolean"}function YS(n,e){let{schema:t,gen:r,opts:i}=n;i.$comment&&t.$comment&&km(n),e_(n),t_(n);let a=r.const("_errs",V.default.errors);Im(n,a),r.var(e,(0, N._)`${a} === ${V.default.errors}`);}function Fm(n){(0, nn.checkUnknownRules)(n),ZS(n);}function Im(n,e){if(n.opts.jtd)return Am(n,[],false,e);let t=(0, Em.getSchemaTypes)(n.schema),r=(0, Em.coerceAndCheckDataType)(n,t);Am(n,t,!r,e);}function ZS(n){let{schema:e,errSchemaPath:t,opts:r,self:i}=n;e.$ref&&r.ignoreKeywordsWithRef&&(0, nn.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${t}"`);}function QS(n){let{schema:e,opts:t}=n;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0, nn.checkStrictMode)(n,"default is ignored in the schema root");}function e_(n){let e=n.schema[n.opts.schemaId];e&&(n.baseId=(0, GS.resolveUrl)(n.opts.uriResolver,n.baseId,e));}function t_(n){if(n.schema.$async&&!n.schemaEnv.$async)throw new Error("async schema in sync schema")}function km({gen:n,schemaEnv:e,schema:t,errSchemaPath:r,opts:i}){let a=t.$comment;if(i.$comment===true)n.code((0, N._)`${V.default.self}.logger.log(${a})`);else if(typeof i.$comment=="function"){let s=(0, N.str)`${r}/$comment`,o=n.scopeValue("root",{ref:e.root});n.code((0, N._)`${V.default.self}.opts.$comment(${a}, ${s}, ${o}.schema)`);}}function n_(n){let{gen:e,schemaEnv:t,validateName:r,ValidationError:i,opts:a}=n;t.$async?e.if((0, N._)`${V.default.errors} === 0`,()=>e.return(V.default.data),()=>e.throw((0, N._)`new ${i}(${V.default.vErrors})`)):(e.assign((0, N._)`${r}.errors`,V.default.vErrors),a.unevaluated&&r_(n),e.return((0, N._)`${V.default.errors} === 0`));}function r_({gen:n,evaluated:e,props:t,items:r}){t instanceof N.Name&&n.assign((0, N._)`${e}.props`,t),r instanceof N.Name&&n.assign((0, N._)`${e}.items`,r);}function Am(n,e,t,r){let{gen:i,schema:a,data:s,allErrors:o,opts:u,self:l}=n,{RULES:c}=l;if(a.$ref&&(u.ignoreKeywordsWithRef||!(0, nn.schemaHasRulesButRef)(a,c))){i.block(()=>Rm(n,"$ref",c.all.$ref.definition));return}u.jtd||i_(n,e),i.block(()=>{for(let f of c.rules)h(f);h(c.post);});function h(f){(0, Ll.shouldUseGroup)(a,f)&&(f.type?(i.if((0, Gs.checkDataType)(f.type,s,u.strictNumbers)),Om(n,f),e.length===1&&e[0]===f.type&&t&&(i.else(),(0, Gs.reportTypeError)(n)),i.endIf()):Om(n,f),o||i.if((0, N._)`${V.default.errors} === ${r||0}`));}}function Om(n,e){let{gen:t,schema:r,opts:{useDefaults:i}}=n;i&&(0, MS.assignDefaults)(n,e.type),t.block(()=>{for(let a of e.rules)(0, Ll.shouldUseRule)(r,a)&&Rm(n,a.keyword,a.definition,e.type);});}function i_(n,e){n.schemaEnv.meta||!n.opts.strictTypes||(s_(n,e),n.opts.allowUnionTypes||a_(n,e),o_(n,n.dataTypes));}function s_(n,e){if(e.length){if(!n.dataTypes.length){n.dataTypes=e;return}e.forEach(t=>{Vm(n.dataTypes,t)||ql(n,`type "${t}" not allowed by context "${n.dataTypes.join(",")}"`);}),l_(n,e);}}function a_(n,e){e.length>1&&!(e.length===2&&e.includes("null"))&&ql(n,"use allowUnionTypes to allow union type keyword");}function o_(n,e){let t=n.self.RULES.all;for(let r in t){let i=t[r];if(typeof i=="object"&&(0, Ll.shouldUseRule)(n.schema,i)){let{type:a}=i.definition;a.length&&!a.some(s=>u_(e,s))&&ql(n,`missing type "${a.join(",")}" for keyword "${r}"`);}}}function u_(n,e){return n.includes(e)||e==="number"&&n.includes("integer")}function Vm(n,e){return n.includes(e)||e==="integer"&&n.includes("number")}function l_(n,e){let t=[];for(let r of n.dataTypes)Vm(e,r)?t.push(r):e.includes("integer")&&r==="number"&&t.push("integer");n.dataTypes=t;}function ql(n,e){let t=n.schemaEnv.baseId+n.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0, nn.checkStrictMode)(n,e,n.opts.strictTypes);}var zs=class{constructor(e,t,r){if((0, bi.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0, nn.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",jm(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0, bi.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==false)&&(this.errsCount=e.gen.const("_errs",V.default.errors));}result(e,t,r){this.failResult((0, N.not)(e),t,r);}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else();}pass(e,t){this.failResult((0, N.not)(e),void 0,t);}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(false);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else();}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0, N._)`${t} !== undefined && (${(0, N.or)(this.invalid$data(),e)})`);}error(e,t,r){if(t){this.setParams(t),this._error(e,r),this.setParams({});return}this._error(e,r);}_error(e,t){(e?vi.reportExtraError:vi.reportError)(this,this.def.error,t);}$dataError(){(0, vi.reportError)(this,this.def.$dataError||vi.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, vi.resetErrorsCount)(this.gen,this.errsCount);}ok(e){this.allErrors||this.gen.if(e);}setParams(e,t){t?Object.assign(this.params,e):this.params=e;}block$data(e,t,r=N.nil){this.gen.block(()=>{this.check$data(e,r),t();});}check$data(e=N.nil,t=N.nil){if(!this.$data)return;let{gen:r,schemaCode:i,schemaType:a,def:s}=this;r.if((0, N.or)((0, N._)`${i} === undefined`,t)),e!==N.nil&&r.assign(e,true),(a.length||s.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==N.nil&&r.assign(e,false)),r.else();}invalid$data(){let{gen:e,schemaCode:t,schemaType:r,def:i,it:a}=this;return (0, N.or)(s(),o());function s(){if(r.length){if(!(t instanceof N.Name))throw new Error("ajv implementation error");let u=Array.isArray(r)?r:[r];return (0, N._)`${(0, Gs.checkDataTypes)(u,t,a.opts.strictNumbers,Gs.DataType.Wrong)}`}return N.nil}function o(){if(i.validateSchema){let u=e.scopeValue("validate$data",{ref:i.validateSchema});return (0, N._)`!${u}(${t})`}return N.nil}}subschema(e,t){let r=(0, $l.getSubschema)(this.it,e);(0, $l.extendSubschemaData)(r,this.it,e),(0, $l.extendSubschemaMode)(r,e);let i={...this.it,...r,items:void 0,props:void 0};return XS(i,t),i}mergeEvaluated(e,t){let{it:r,gen:i}=this;r.opts.unevaluated&&(r.props!==true&&e.props!==void 0&&(r.props=nn.mergeEvaluated.props(i,e.props,r.props,t)),r.items!==true&&e.items!==void 0&&(r.items=nn.mergeEvaluated.items(i,e.items,r.items,t)));}mergeValidEvaluated(e,t){let{it:r,gen:i}=this;if(r.opts.unevaluated&&(r.props!==true||r.items!==true))return i.if(t,()=>this.mergeEvaluated(e,N.Name)),true}};yn.KeywordCxt=zs;function Rm(n,e,t,r){let i=new zs(n,t,e);"code"in t?t.code(i,r):i.$data&&t.validate?(0, bi.funcKeywordCode)(i,t):"macro"in t?(0, bi.macroKeywordCode)(i,t):(t.compile||t.validate)&&(0, bi.funcKeywordCode)(i,t);}var c_=/^\/(?:[^~]|~0|~1)*$/,h_=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function jm(n,{dataLevel:e,dataNames:t,dataPathArr:r}){let i,a;if(n==="")return V.default.rootData;if(n[0]==="/"){if(!c_.test(n))throw new Error(`Invalid JSON-pointer: ${n}`);i=n,a=V.default.rootData;}else {let l=h_.exec(n);if(!l)throw new Error(`Invalid JSON-pointer: ${n}`);let c=+l[1];if(i=l[2],i==="#"){if(c>=e)throw new Error(u("property/index",c));return r[e-c]}if(c>e)throw new Error(u("data",c));if(a=t[e-c],!i)return a}let s=a,o=i.split("/");for(let l of o)l&&(a=(0, N._)`${a}${(0, N.getProperty)((0, nn.unescapeJsonPointer)(l))}`,s=(0, N._)`${s} && ${a}`);return s;function u(l,c){return `Cannot access ${l} ${c} levels up, current level is ${e}`}}yn.getData=jm;});var Ci=w(Wl=>{Object.defineProperty(Wl,"__esModule",{value:true});var Bl=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=true;}};Wl.default=Bl;});var yr=w(zl=>{Object.defineProperty(zl,"__esModule",{value:true});var Ml=yi(),Gl=class extends Error{constructor(e,t,r,i){super(i||`can't resolve reference ${r} from id ${t}`),this.missingRef=(0, Ml.resolveUrl)(e,t,r),this.missingSchema=(0, Ml.normalizeId)((0, Ml.getFullPath)(e,this.missingRef));}};zl.default=Gl;});var Si=w(vt=>{Object.defineProperty(vt,"__esModule",{value:true});vt.resolveSchema=vt.getCompilingSchema=vt.resolveRef=vt.compileSchema=vt.SchemaEnv=void 0;var Tt=j(),d_=Ci(),Bn=gt(),Nt=yi(),$m=M(),p_=gr(),vr=class{constructor(e){var t;this.refs={},this.dynamicAnchors={};let r;typeof e.schema=="object"&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0, Nt.normalizeId)(r?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=r?.$async,this.refs={};}};vt.SchemaEnv=vr;function Hl(n){let e=Lm.call(this,n);if(e)return e;let t=(0, Nt.getFullPath)(this.opts.uriResolver,n.root.baseId),{es5:r,lines:i}=this.opts.code,{ownProperties:a}=this.opts,s=new Tt.CodeGen(this.scope,{es5:r,lines:i,ownProperties:a}),o;n.$async&&(o=s.scopeValue("Error",{ref:d_.default,code:(0, Tt._)`require("ajv/dist/runtime/validation_error").default`}));let u=s.scopeName("validate");n.validateName=u;let l={gen:s,allErrors:this.opts.allErrors,data:Bn.default.data,parentData:Bn.default.parentData,parentDataProperty:Bn.default.parentDataProperty,dataNames:[Bn.default.data],dataPathArr:[Tt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===true?{ref:n.schema,code:(0, Tt.stringify)(n.schema)}:{ref:n.schema}),validateName:u,ValidationError:o,schema:n.schema,schemaEnv:n,rootId:t,baseId:n.baseId||t,schemaPath:Tt.nil,errSchemaPath:n.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, Tt._)`""`,opts:this.opts,self:this},c;try{this._compilations.add(n),(0,p_.validateFunctionCode)(l),s.optimize(this.opts.code.optimize);let h=s.toString();c=`${s.scopeRefs(Bn.default.scope)}return ${h}`,this.opts.code.process&&(c=this.opts.code.process(c,n));let p=new Function(`${Bn.default.self}`,`${Bn.default.scope}`,c)(this,this.scope.get());if(this.scope.value(u,{ref:p}),p.errors=null,p.schema=n.schema,p.schemaEnv=n,n.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:u,validateCode:h,scopeValues:s._values}),this.opts.unevaluated){let{props:g,items:y}=l;p.evaluated={props:g instanceof Tt.Name?void 0:g,items:y instanceof Tt.Name?void 0:y,dynamicProps:g instanceof Tt.Name,dynamicItems:y instanceof Tt.Name},p.source&&(p.source.evaluated=(0,Tt.stringify)(p.evaluated));}return n.validate=p,n}catch(h){throw delete n.validate,delete n.validateName,c&&this.logger.error("Error compiling schema, function code:",c),h}finally{this._compilations.delete(n);}}vt.compileSchema=Hl;function f_(n,e,t){var r;t=(0, Nt.resolveUrl)(this.opts.uriResolver,e,t);let i=n.refs[t];if(i)return i;let a=y_.call(this,n,t);if(a===void 0){let s=(r=n.localRefs)===null||r===void 0?void 0:r[t],{schemaId:o}=this.opts;s&&(a=new vr({schema:s,schemaId:o,root:n,baseId:e}));}if(a!==void 0)return n.refs[t]=m_.call(this,a)}vt.resolveRef=f_;function m_(n){return (0, Nt.inlineRef)(n.schema,this.opts.inlineRefs)?n.schema:n.validate?n:Hl.call(this,n)}function Lm(n){for(let e of this._compilations)if(g_(e,n))return e}vt.getCompilingSchema=Lm;function g_(n,e){return n.schema===e.schema&&n.root===e.root&&n.baseId===e.baseId}function y_(n,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||Js.call(this,n,e)}function Js(n,e){let t=this.opts.uriResolver.parse(e),r=(0, Nt._getFullPath)(this.opts.uriResolver,t),i=(0, Nt.getFullPath)(this.opts.uriResolver,n.baseId,void 0);if(Object.keys(n.schema).length>0&&r===i)return Jl.call(this,t,n);let a=(0, Nt.normalizeId)(r),s=this.refs[a]||this.schemas[a];if(typeof s=="string"){let o=Js.call(this,n,s);return typeof o?.schema!="object"?void 0:Jl.call(this,t,o)}if(typeof s?.schema=="object"){if(s.validate||Hl.call(this,s),a===(0, Nt.normalizeId)(e)){let{schema:o}=s,{schemaId:u}=this.opts,l=o[u];return l&&(i=(0, Nt.resolveUrl)(this.opts.uriResolver,i,l)),new vr({schema:o,schemaId:u,root:n,baseId:i})}return Jl.call(this,t,s)}}vt.resolveSchema=Js;var v_=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Jl(n,{baseId:e,schema:t,root:r}){var i;if(((i=n.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let o of n.fragment.slice(1).split("/")){if(typeof t=="boolean")return;let u=t[(0, $m.unescapeFragment)(o)];if(u===void 0)return;t=u;let l=typeof t=="object"&&t[this.opts.schemaId];!v_.has(o)&&l&&(e=(0, Nt.resolveUrl)(this.opts.uriResolver,e,l));}let a;if(typeof t!="boolean"&&t.$ref&&!(0, $m.schemaHasRulesButRef)(t,this.RULES)){let o=(0, Nt.resolveUrl)(this.opts.uriResolver,e,t.$ref);a=Js.call(this,r,o);}let{schemaId:s}=this.opts;if(a=a||new vr({schema:t,schemaId:s,root:r,baseId:e}),a.schema!==a.root.schema)return a}});var qm=w((jI,b_)=>{b_.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:false};});var Ql=w(($I,Hm)=>{var C_=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Kl=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),S_=RegExp.prototype.test.bind(/^\d*$/u),Wn=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Xl=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Wm=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Yl=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),__=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),it=new Array(256);{let n="0123456789ABCDEF";for(let e=0;e<256;e++)it[e]="%"+n[e>>4]+n[e&15];}function Le(n){return n<2048?it[192|n>>6]+it[128|n&63]:n<65536?it[224|n>>12]+it[128|n>>6&63]+it[128|n&63]:it[240|n>>18]+it[128|n>>12&63]+it[128|n>>6&63]+it[128|n&63]}function w_(n){let e="",t=0,r=0;for(r=0;r<n.length;r++)if(t=n[r].charCodeAt(0),t!==48){if(!(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102))return "";e+=n[r];break}for(r+=1;r<n.length;r++){if(t=n[r].charCodeAt(0),!(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102))return "";e+=n[r];}return e}var E_=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),D_=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),A_=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),O_=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function P_(n){if(n.length===0)return false;for(let e=0;e<n.length;e++)if(!A_(n[e])){if(n[e]==="%"&&e+2<n.length&&Wn(n.slice(e+1,e+3))){e+=2;continue}return false}return true}function Bm(n){let e=-1,t=0,r=-1,i=0;for(let o=0;o<n.length;o++)n[o]==="0"?(r===-1&&(r=o),i++,i>t&&(t=i,e=r)):(r=-1,i=0);if(t<2)return n.join(":");let a=n.slice(0,e).join(":"),s=n.slice(e+t).join(":");return a+"::"+s}function x_(n){let e=n.indexOf("::");if(e!==-1&&n.indexOf("::",e+1)!==-1)return;let t=e===-1?n.split(":"):n.slice(0,e).split(":"),r=e===-1?[]:n.slice(e+2).split(":");e!==-1&&(t.length===1&&t[0]===""&&(t.length=0),r.length===1&&r[0]===""&&(r.length=0));let i=t.concat(r),a=0;for(let o=0;o<i.length;o++){let u=i[o];if(u==="")return;if(u.indexOf(".")!==-1){if(o!==i.length-1||e!==-1&&r.length===0||!Kl(u))return;a+=2;continue}if(!E_(u))return;i[o]=parseInt(u,16).toString(16),a++;}if(e===-1)return a!==8?void 0:Bm(i);if(a>=8)return;let s=i.slice(0,t.length);for(let o=a;o<8;o++)s.push("0");for(let o=t.length;o<i.length;o++)s.push(i[o]);return Bm(s)}function Ul(n){let e=n[0]==="["&&n[n.length-1]==="]";if((n[0]==="["||n[n.length-1]==="]")&&!e)return {host:n,isIPV6:false,error:true};let r=e?n.slice(1,-1):n;if(e&&D_(r))return r=r.toLowerCase(),{host:`[${r}]`,escapedHost:r,isIPV6:false,isIPVFuture:true};if(T_(r,":")<2)return {host:n,isIPV6:false,error:e};let i="",a=r.indexOf("%");if(a!==-1){let o=r.slice(a,a+3).toLowerCase()==="%25"?3:1;if(i=r.slice(a+o),!P_(i))return {host:n,isIPV6:false,error:true};r=r.slice(0,a);}let s=x_(r);return s===void 0?{host:n,isIPV6:false,error:true}:{host:s+(i?"%"+i:""),escapedHost:s+(i?"%25"+i:""),isIPV6:true}}function T_(n,e){let t=0;for(let r=0;r<n.length;r++)n[r]===e&&t++;return t}function N_(n){let e=n,t=[],r=-1,i=0;for(;i=e.length;){if(i===1){if(e===".")break;if(e==="/"){t.push("/");break}else {t.push(e);break}}else if(i===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){t.push("/");break}}else if(i===3&&e==="/.."){t.length!==0&&t.pop(),t.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),t.length!==0&&t.pop();continue}}if((r=e.indexOf("/",1))===-1){t.push(e);break}else t.push(e.slice(0,r)),e=e.slice(r);}return t.join("")}var F_={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},I_=/[@/?#:]/g,k_=/[@/?#]/g;function Mm(n,e){let t=e?k_:I_;return t.lastIndex=0,n.replace(t,r=>F_[r])}function Gm(n,e=false){if(n.indexOf("%")===-1)return n;let t="";for(let r=0;r<n.length;r++){if(n[r]==="%"&&r+2<n.length){let i=n.slice(r+1,r+3);if(Wn(i)){let a=i.toUpperCase(),s=String.fromCharCode(parseInt(a,16));e&&Xl(s)?t+=s:t+="%"+a,r+=2;continue}}t+=n[r];}return t}function V_(n){let e="";for(let t=0;t<n.length;t++){let r=n[t];if(r==="%"&&t+2<n.length){let i=n.slice(t+1,t+3);if(Wn(i)){let a=i.toUpperCase(),s=String.fromCharCode(parseInt(a,16));s!=="."&&Xl(s)?e+=s:e+="%"+a,t+=2;continue}}if(Wm(r))e+=r;else {let i=n.charCodeAt(t);if(i<128)e+=Jm(i)?r:it[i];else if(i<55296||i>57343)e+=Le(i);else if(i<=56319&&t+1<n.length){let a=n.charCodeAt(t+1);a>=56320&&a<=57343?(e+=Le(65536+(i-55296<<10)+(a-56320)),t++):e+=Le(65533);}else e+=Le(65533);}}return e}function R_(n,e=false){let t="",r=e&&n[0]!=="/";for(let i=0;i<n.length;i++){let a=n[i];if(a==="%"&&i+2<n.length){let s=n.slice(i+1,i+3);if(Wn(s)){t+="%"+s.toUpperCase(),i+=2;continue}}if(a==="/"&&(r=false),Wm(a)&&(a!==":"||!r))t+=a;else {let s=n.charCodeAt(i);if(s<128)t+=it[s];else if(s<55296||s>57343)t+=Le(s);else if(s<=56319&&i+1<n.length){let o=n.charCodeAt(i+1);o>=56320&&o<=57343?(t+=Le(65536+(s-55296<<10)+(o-56320)),i++):t+=Le(65533);}else t+=Le(65533);}}return t}function Zl(n,e){let t="";for(let r=0;r<n.length;r++){let i=n[r];if(i==="%"&&r+2<n.length){let a=n.slice(r+1,r+3);if(Wn(a)){t+="%"+a.toUpperCase(),r+=2;continue}}if(e(i))t+=i;else {let a=n.charCodeAt(r);if(a<128)t+=it[a];else if(a<55296||a>57343)t+=Le(a);else if(a<=56319&&r+1<n.length){let s=n.charCodeAt(r+1);s>=56320&&s<=57343?(t+=Le(65536+(a-55296<<10)+(s-56320)),r++):t+=Le(65533);}else t+=Le(65533);}}return t}function zm(n){return Zl(n,__)}function j_(n){return Zl(n,Yl)}function $_(n){return Zl(n,Yl)}function Jm(n){return n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||n===42||n===43||n===45||n===46||n===47||n===64||n===95}function L_(n){let e="";for(let t=0;t<n.length;t++){let r=n[t];if(r==="%"&&t+2<n.length){let i=n.slice(t+1,t+3);if(Wn(i)){let a=i.toUpperCase(),s=String.fromCharCode(parseInt(a,16));Xl(s)?e+=s:e+="%"+a,t+=2;continue}}if(Yl(r))e+=r;else {let i=n.charCodeAt(t);if(i<128)e+=Jm(i)?r:it[i];else if(i<55296||i>57343)e+=Le(i);else if(i<=56319&&t+1<n.length){let a=n.charCodeAt(t+1);a>=56320&&a<=57343?(e+=Le(65536+(i-55296<<10)+(a-56320)),t++):e+=Le(65533);}else e+=Le(65533);}}return e}function q_(n){let e="";for(let t=0;t<n.length;t++){if(n[t]==="%"&&t+2<n.length){let r=n.slice(t+1,t+3);if(Wn(r)){e+="%"+r.toUpperCase(),t+=2;continue}}e+=escape(n[t]);}return e}function B_(n){let e=[];if(n.userinfo!==void 0&&(e.push(zm(n.userinfo)),e.push("@")),n.host!==void 0){let t=n.host;if(!Kl(t)){let r=Ul(t);r.isIPV6!==true&&r.isIPVFuture!==true&&(t=Gm(t,true),r=Ul(t)),r.isIPV6===true||r.isIPVFuture===true?t=`[${r.escapedHost}]`:t=Mm(t,false);}e.push(t);}if(typeof n.port=="number"||typeof n.port=="string"){let t=String(n.port);if(!S_(t))throw new TypeError("URI port is malformed.");e.push(":"),e.push(t);}return e.length?e.join(""):void 0}Hm.exports={nonSimpleDomain:O_,recomposeAuthority:B_,reescapeHostDelimiters:Mm,normalizePercentEncoding:Gm,normalizePathEncoding:V_,serializePathEncoding:R_,normalizeQueryFragmentEncoding:L_,encodeUserinfo:zm,encodeQuery:j_,encodeFragment:$_,escapePreservingEscapes:q_,removeDotSegments:N_,isIPv4:Kl,isUUID:C_,normalizeIPv6:Ul,stringArrayToHexStripped:w_};});var Zm=w((LI,Ym)=>{var{isUUID:W_}=Ql(),M_=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,G_=["http","https","ws","wss","urn","urn:uuid"];function z_(n){return G_.indexOf(n)!==-1}function ec(n){return n.secure===true?true:n.secure===false?false:n.scheme?n.scheme.length===3&&(n.scheme[0]==="w"||n.scheme[0]==="W")&&(n.scheme[1]==="s"||n.scheme[1]==="S")&&(n.scheme[2]==="s"||n.scheme[2]==="S"):false}function Um(n){return n.host||(n.error=n.error||"HTTP URIs must have a host."),n}function Km(n){let e=String(n.scheme).toLowerCase()==="https";return (n.port===(e?443:80)||n.port==="")&&(n.port=void 0),n.path||(n.path="/"),n}function J_(n){return n.secure=ec(n),n.resourceName=(n.path||"/")+(n.query?"?"+n.query:""),n.path=void 0,n.query=void 0,n}function H_(n){if((n.port===(ec(n)?443:80)||n.port==="")&&(n.port=void 0),typeof n.secure=="boolean"&&(n.scheme=n.secure?"wss":"ws",n.secure=void 0),n.resourceName){let e=n.resourceName.indexOf("?"),t=e===-1?n.resourceName:n.resourceName.slice(0,e);n.path=t&&t!=="/"?t:void 0,n.query=e===-1?void 0:n.resourceName.slice(e+1),n.resourceName=void 0;}return n.fragment=void 0,n}function U_(n,e){if(!n.path)return n.error="URN can not be parsed",n;let t=n.path.match(M_);if(t&&t[0]===n.path){let r=e.scheme||n.scheme||"urn";n.nid=t[1].toLowerCase(),n.nss=t[2];let i=`${r}:${e.nid||n.nid}`,a=tc(i);n.path=void 0,a&&(n=a.parse(n,e));}else n.error=n.error||"URN can not be parsed.";return n}function K_(n,e){if(n.nid===void 0)throw new Error("URN without nid cannot be serialized");let t=e.scheme||n.scheme||"urn",r=n.nid.toLowerCase(),i=`${t}:${e.nid||r}`,a=tc(i);a&&(n=a.serialize(n,e));let s=n,o=n.nss;return s.path=`${r||e.nid}:${o}`,e.skipEscape=true,s}function X_(n,e){let t=n;return t.uuid=t.nss,t.nss=void 0,!e.tolerant&&(!t.uuid||!W_(t.uuid))&&(t.error=t.error||"UUID is not valid."),t}function Y_(n){let e=n;return e.nss=(n.uuid||"").toLowerCase(),e}var Xm={scheme:"http",domainHost:true,parse:Um,serialize:Km},Z_={scheme:"https",domainHost:Xm.domainHost,parse:Um,serialize:Km},Hs={scheme:"ws",domainHost:true,parse:J_,serialize:H_},Q_={scheme:"wss",domainHost:Hs.domainHost,parse:Hs.parse,serialize:Hs.serialize},ew={scheme:"urn",parse:U_,serialize:K_,skipNormalize:true},tw={scheme:"urn:uuid",parse:X_,serialize:Y_,skipNormalize:true},Us={http:Xm,https:Z_,ws:Hs,wss:Q_,urn:ew,"urn:uuid":tw};Object.setPrototypeOf(Us,null);function tc(n){return n&&(Us[n]||Us[n.toLowerCase()])||void 0}Ym.exports={wsIsSecure:ec,SCHEMES:Us,isValidSchemeName:z_,getSchemeHandler:tc};});var hg=w((qI,Ys)=>{var{normalizeIPv6:rg,removeDotSegments:wi,recomposeAuthority:nw,normalizePercentEncoding:nc,normalizePathEncoding:rw,serializePathEncoding:Qm,normalizeQueryFragmentEncoding:eg,encodeQuery:iw,encodeFragment:sw,reescapeHostDelimiters:aw,isIPv4:ig,nonSimpleDomain:ow}=Ql(),{SCHEMES:sg,getSchemeHandler:rc}=Zm(),ag=/^[A-Za-z][A-Za-z0-9+.-]*$/u,og="URI scheme is malformed.";function tg(n){let e=unescape(String(n));if(!ag.test(e))throw new TypeError(og);return e}function uw(n,e){return typeof n=="string"?n=gw(n,e):typeof n=="object"&&(n=Xs(Mn(n,e),e)),n}function lw(n,e,t){let r=t?Object.assign({scheme:"null"},t):{scheme:"null"},{parsed:i,malformedAuthorityOrPort:a,malformedPercentEncoding:s,malformedSchemeSpecific:o,malformedHost:u,malformedScheme:l}=Ks(n,r),{parsed:c,malformedAuthorityOrPort:h,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:g,malformedScheme:y}=Ks(e,r);if(a||h||s||f||o||p||u||g||l||y)throw new Error(i.error||c.error||"URI is malformed.");let C=ug(i,c,r,true),S=rc(t&&t.scheme||C.scheme),v=C.host,d=v!==void 0&&v!==""&&(ig(v)||rg(v).isIPV6);lg(C,t||{},S,d);let _=v&&v.indexOf("%")!==-1&&!/\P{ASCII}/u.test(v);if(C.error&&!_)throw new Error(C.error);return r.skipEscape=true,Mn(C,r)}function ug(n,e,t,r){let i={};return r||(n=Xs(Mn(n,t),t),e=Xs(Mn(e,t),t)),t=t||{},!t.tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=wi(e.path||""),i.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=wi(e.path||""),i.query=e.query):(e.path?(e.path[0]==="/"?i.path=wi(e.path):((n.userinfo!==void 0||n.host!==void 0||n.port!==void 0)&&!n.path?i.path="/"+e.path:n.path?i.path=n.path.slice(0,n.path.lastIndexOf("/")+1)+e.path:i.path=e.path,i.path=wi(i.path)),i.query=e.query):(i.path=n.path,e.query!==void 0?i.query=e.query:i.query=n.query),i.userinfo=n.userinfo,i.host=n.host,i.port=n.port),i.scheme=n.scheme),i.fragment=e.fragment,i}function cw(n,e,t){let r=ng(n,t),i=ng(e,t);return r!==void 0&&i!==void 0&&r===i}function Mn(n,e){let t={host:n.host,scheme:n.scheme,userinfo:n.userinfo,port:n.port,path:n.path,query:n.query,nid:n.nid,nss:n.nss,uuid:n.uuid,fragment:n.fragment,reference:n.reference,resourceName:n.resourceName,secure:n.secure,error:""},r=Object.assign({},e),i=[];t.scheme&&(t.scheme=tg(t.scheme));let a=rc(r.scheme||t.scheme);a&&a.serialize&&a.serialize(t,r);let s=t.userinfo!==void 0||t.host!==void 0||t.port!==void 0,o=!r.skipEscape&&t.scheme===void 0&&!s;t.path!==void 0&&(r.skipEscape?t.path=nc(t.path):t.path=Qm(t.path,o)),r.reference!=="suffix"&&t.scheme&&(t.scheme=tg(t.scheme),i.push(t.scheme,":"));let u=nw(t);if(u!==void 0&&(r.reference!=="suffix"&&i.push("//"),i.push(u),t.path&&t.path[0]!=="/"&&i.push("/")),t.path!==void 0){let l=t.path;!r.absolutePath&&(!a||!a.absolutePath)&&(l=wi(l)),o&&(l=Qm(l,true)),u===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),i.push(l);}return t.query!==void 0&&i.push("?",iw(t.query)),t.fragment!==void 0&&i.push("#",sw(t.fragment)),i.join("")}var hw=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,dw=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,pw=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function fw(n,e){if(e[2]!==void 0&&n.path&&n.path[0]!=="/")return 'URI path must start with "/" when authority is present.';if(typeof n.port=="number"&&(n.port<0||n.port>65535))return "URI port is malformed."}function _i(n){if(n===void 0)return false;let e=n.indexOf("%");for(;e!==-1;){if(e+2>=n.length||!/^[\da-f]{2}$/iu.test(n.slice(e+1,e+3)))return true;e=n.indexOf("%",e+3);}return false}function ic(n){return n[0]==="["&&n[n.length-1]==="]"}function mw(n){let e=n[4];return _i(n[3])||e!==void 0&&!ic(e)&&_i(e)||_i(n[6])||_i(n[7])||_i(n[8])}function lg(n,e,t,r){if(!e.unicodeSupport&&(!t||!t.unicodeSupport)&&n.host&&!ic(n.host)&&(e.domainHost||t&&t.domainHost)&&r===false&&ow(n.host))try{n.host=new URL("http://"+n.host).hostname;}catch(i){return n.error=n.error||"Host's domain name can not be converted to ASCII: "+i,true}return false}function Ks(n,e){let t=Object.assign({},e),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=false,a=false,s=false,o=false,u=false,l=false,c=false;t.reference==="suffix"&&(t.scheme?n=t.scheme+":"+n:n="//"+n);let h=n.match(dw);h!==null&&h[1].indexOf("\\")!==-1&&(r.error="URI authority must not contain a literal backslash.",i=true);let f=n.match(pw);if(f!==null){let g=f[1],y=g.replace(/[\t\n\r]/g,"");y.length>=2&&(y.slice(0,2)!=="//"?(r.error=r.error||"URI authority must not contain a literal backslash.",i=true):g.length!==y.length&&(r.error=r.error||"URI authority introducer must not contain whitespace.",i=true));}let p=n.match(hw);if(p){if(r.scheme=p[1],r.userinfo=p[3],r.host=p[4],r.port=parseInt(p[5],10),r.path=p[6]||"",r.query=p[7],r.fragment=p[8],r.scheme!==void 0){let C=unescape(r.scheme);ag.test(C)?r.scheme=C.toLowerCase():(r.error=r.error||og,l=true);}a=mw(p),a&&(r.error=r.error||"URI contains malformed percent-encoding."),isNaN(r.port)&&(r.port=p[5]);let g=fw(r,p);if(g!==void 0&&(r.error=r.error||g,i=true),r.host)if(ig(r.host)===false){let S=ic(r.host),v=r.host.indexOf("[")!==-1||r.host.indexOf("]")!==-1,d=rg(r.host);c=d.isIPV6||d.isIPVFuture===true,u=v&&(!S||d.error===true),r.host=c?d.host:d.host.toLowerCase(),u&&(r.error=r.error||"URI host is malformed.",i=true);}else c=true;r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path?r.reference="same-document":r.scheme===void 0?r.reference="relative":r.fragment===void 0?r.reference="absolute":r.reference="uri",t.reference&&t.reference!=="suffix"&&t.reference!==r.reference&&(r.error=r.error||"URI is not a "+t.reference+" reference.");let y=rc(t.scheme||r.scheme);if(u||(o=lg(r,t,y,c)),n.indexOf("%")!==-1&&r.host!==void 0&&!u){let C=c?r.host:nc(r.host,true);c||(C=nc(C.toLowerCase())),r.host=aw(C,c);}(!y||y&&!y.skipNormalize)&&(r.path&&(r.path=rw(r.path)),r.query&&(r.query=eg(r.query)),r.fragment&&(r.fragment=eg(r.fragment))),y&&y.parse&&(y.parse(r,t),y===sg.urn&&r.nid===void 0&&(s=true));}else r.error=r.error||"URI can not be parsed.";return {parsed:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:s,malformedHost:o,malformedScheme:l}}function Xs(n,e){return Ks(n,e).parsed}function gw(n,e){return cg(n,e).normalized}function cg(n,e){let{parsed:t,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:s,malformedScheme:o}=Ks(n,e);return {normalized:r||i||a||s||o?n:Mn(t,e),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:s,malformedScheme:o}}function ng(n,e){if(typeof n!="string"&&typeof n!="object")return;let t;try{t=typeof n=="string"?n:Mn(n,e);}catch{return}let{normalized:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:s,malformedHost:o,malformedScheme:u}=cg(t,e);return i||a||s||o||u?void 0:r}var sc={SCHEMES:sg,normalize:uw,resolve:lw,resolveComponent:ug,equal:cw,serialize:Mn,parse:Xs};Ys.exports=sc;Ys.exports.default=sc;Ys.exports.fastUri=sc;});var pg=w(ac=>{Object.defineProperty(ac,"__esModule",{value:true});var dg=hg();dg.code='require("ajv/dist/runtime/uri").default';ac.default=dg;});var lc=w(Fe=>{Object.defineProperty(Fe,"__esModule",{value:true});Fe.CodeGen=Fe.Name=Fe.nil=Fe.stringify=Fe.str=Fe._=Fe.KeywordCxt=void 0;var yw=gr();Object.defineProperty(Fe,"KeywordCxt",{enumerable:true,get:function(){return yw.KeywordCxt}});var br=j();Object.defineProperty(Fe,"_",{enumerable:true,get:function(){return br._}});Object.defineProperty(Fe,"str",{enumerable:true,get:function(){return br.str}});Object.defineProperty(Fe,"stringify",{enumerable:true,get:function(){return br.stringify}});Object.defineProperty(Fe,"nil",{enumerable:true,get:function(){return br.nil}});Object.defineProperty(Fe,"Name",{enumerable:true,get:function(){return br.Name}});Object.defineProperty(Fe,"CodeGen",{enumerable:true,get:function(){return br.CodeGen}});var vw=Ci(),vg=yr(),bw=Pl(),Ei=Si(),Cw=j(),Di=yi(),Zs=gi(),uc=M(),fg=qm(),Sw=pg(),bg=(n,e)=>new RegExp(n,e);bg.code="new RegExp";var _w=["removeAdditional","useDefaults","coerceTypes"],ww=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Ew={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},Dw={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},mg=200;function Aw(n){var e,t,r,i,a,s,o,u,l,c,h,f,p,g,y,C,S,v,d,_,m,b,E,O,P;let k=n.strict,z=(e=n.code)===null||e===void 0?void 0:e.optimize,se=z===true||z===void 0?1:z||0,le=(r=(t=n.code)===null||t===void 0?void 0:t.regExp)!==null&&r!==void 0?r:bg,un=(i=n.uriResolver)!==null&&i!==void 0?i:Sw.default;return {strictSchema:(s=(a=n.strictSchema)!==null&&a!==void 0?a:k)!==null&&s!==void 0?s:true,strictNumbers:(u=(o=n.strictNumbers)!==null&&o!==void 0?o:k)!==null&&u!==void 0?u:true,strictTypes:(c=(l=n.strictTypes)!==null&&l!==void 0?l:k)!==null&&c!==void 0?c:"log",strictTuples:(f=(h=n.strictTuples)!==null&&h!==void 0?h:k)!==null&&f!==void 0?f:"log",strictRequired:(g=(p=n.strictRequired)!==null&&p!==void 0?p:k)!==null&&g!==void 0?g:false,code:n.code?{...n.code,optimize:se,regExp:le}:{optimize:se,regExp:le},loopRequired:(y=n.loopRequired)!==null&&y!==void 0?y:mg,loopEnum:(C=n.loopEnum)!==null&&C!==void 0?C:mg,meta:(S=n.meta)!==null&&S!==void 0?S:true,messages:(v=n.messages)!==null&&v!==void 0?v:true,inlineRefs:(d=n.inlineRefs)!==null&&d!==void 0?d:true,schemaId:(_=n.schemaId)!==null&&_!==void 0?_:"$id",addUsedSchema:(m=n.addUsedSchema)!==null&&m!==void 0?m:true,validateSchema:(b=n.validateSchema)!==null&&b!==void 0?b:true,validateFormats:(E=n.validateFormats)!==null&&E!==void 0?E:true,unicodeRegExp:(O=n.unicodeRegExp)!==null&&O!==void 0?O:true,int32range:(P=n.int32range)!==null&&P!==void 0?P:true,uriResolver:un}}var Ai=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Aw(e)};let{es5:t,lines:r}=this.opts.code;this.scope=new Cw.ValueScope({scope:{},prefixes:ww,es5:t,lines:r}),this.logger=Fw(e.logger);let i=e.validateFormats;e.validateFormats=false,this.RULES=(0, bw.getRules)(),gg.call(this,Ew,e,"NOT SUPPORTED"),gg.call(this,Dw,e,"DEPRECATED","warn"),this._metaOpts=Tw.call(this),e.formats&&Pw.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&xw.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Ow.call(this),e.validateFormats=i;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:r}=this.opts,i=fg;r==="id"&&(i={...fg},i.id=i.$id,delete i.$id),t&&e&&this.addMetaSchema(i,i[r],false);}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[t]||e:void 0}validate(e,t){let r;if(typeof e=="string"){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);let i=r(t);return "$async"in r||(this.errors=r.errors),i}compile(e,t){let r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:r}=this.opts;return i.call(this,e,t);async function i(c,h){await a.call(this,c.$schema);let f=this._addSchema(c,h);return f.validate||s.call(this,f)}async function a(c){c&&!this.getSchema(c)&&await i.call(this,{$ref:c},true);}async function s(c){try{return this._compileSchemaEnv(c)}catch(h){if(!(h instanceof vg.default))throw h;return o.call(this,h),await u.call(this,h.missingSchema),s.call(this,c)}}function o({missingSchema:c,missingRef:h}){if(this.refs[c])throw new Error(`AnySchema ${c} is loaded but ${h} cannot be resolved`)}async function u(c){let h=await l.call(this,c);this.refs[c]||await a.call(this,h.$schema),this.refs[c]||this.addSchema(h,c,t);}async function l(c){let h=this._loading[c];if(h)return h;try{return await(this._loading[c]=r(c))}finally{delete this._loading[c];}}}addSchema(e,t,r,i=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,r,i);return this}let a;if(typeof e=="object"){let{schemaId:s}=this.opts;if(a=e[s],a!==void 0&&typeof a!="string")throw new Error(`schema ${s} must be string`)}return t=(0, Di.normalizeId)(t||a),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,i,true),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,true,r),this}validateSchema(e,t){if(typeof e=="boolean")return true;let r;if(r=e.$schema,r!==void 0&&typeof r!="string")throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,true;let i=this.validate(r,e);if(!i&&t){let a="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(a);else throw new Error(a)}return i}getSchema(e){let t;for(;typeof(t=yg.call(this,e))=="string";)e=t;if(t===void 0){let{schemaId:r}=this.opts,i=new Ei.SchemaEnv({schema:{},schemaId:r});if(t=Ei.resolveSchema.call(this,i,e),!t)return;this.refs[e]=t;}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case "undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case "string":{let t=yg.call(this,e);return typeof t=="object"&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case "object":{let t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0, Di.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if(typeof e=="string")r=e,typeof t=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else if(typeof e=="object"&&t===void 0){if(t=e,r=t.keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(kw.call(this,r,t),!t)return (0, uc.eachItem)(r,a=>oc.call(this,a)),this;Rw.call(this,t);let i={...t,type:(0, Zs.getJSONTypes)(t.type),schemaType:(0, Zs.getJSONTypes)(t.schemaType)};return (0, uc.eachItem)(r,i.type.length===0?a=>oc.call(this,a,i):a=>i.type.forEach(s=>oc.call(this,a,i,s))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t=="object"?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let r of t.rules){let i=r.rules.findIndex(a=>a.keyword===e);i>=0&&r.rules.splice(i,1);}return this}addFormat(e,t){return typeof t=="string"&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return !e||e.length===0?"No errors":e.map(i=>`${r}${i.instancePath} ${i.message}`).reduce((i,a)=>i+t+a)}$dataMetaSchema(e,t){let r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of t){let a=i.split("/").slice(1),s=e;for(let o of a)s=s[o];for(let o in r){let u=r[o];if(typeof u!="object")continue;let{$data:l}=u.definition,c=s[o];l&&c&&(s[o]=Cg(c));}}return e}_removeAllSchemas(e,t){for(let r in e){let i=e[r];(!t||t.test(r))&&(typeof i=="string"?delete e[r]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[r]));}}_addSchema(e,t,r,i=this.opts.validateSchema,a=this.opts.addUsedSchema){let s,{schemaId:o}=this.opts;if(typeof e=="object")s=e[o];else {if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(e);if(u!==void 0)return u;r=(0, Di.normalizeId)(s||r);let l=Di.getSchemaRefs.call(this,e,r);return u=new Ei.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:r,localRefs:l}),this._cache.set(u.schema,u),a&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=u),i&&this.validateSchema(e,true),u}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Ei.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{Ei.compileSchema.call(this,e);}finally{this.opts=t;}}};Ai.ValidationError=vw.default;Ai.MissingRefError=vg.default;Fe.default=Ai;function gg(n,e,t,r="error"){for(let i in n){let a=i;a in e&&this.logger[r](`${t}: option ${i}. ${n[a]}`);}}function yg(n){return n=(0, Di.normalizeId)(n),this.schemas[n]||this.refs[n]}function Ow(){let n=this.opts.schemas;if(n)if(Array.isArray(n))this.addSchema(n);else for(let e in n)this.addSchema(n[e],e);}function Pw(){for(let n in this.opts.formats){let e=this.opts.formats[n];e&&this.addFormat(n,e);}}function xw(n){if(Array.isArray(n)){this.addVocabulary(n);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in n){let t=n[e];t.keyword||(t.keyword=e),this.addKeyword(t);}}function Tw(){let n={...this.opts};for(let e of _w)delete n[e];return n}var Nw={log(){},warn(){},error(){}};function Fw(n){if(n===false)return Nw;if(n===void 0)return console;if(n.log&&n.warn&&n.error)return n;throw new Error("logger must implement log, warn and error methods")}var Iw=/^[a-z_$][a-z0-9_$:-]*$/i;function kw(n,e){let{RULES:t}=this;if((0, uc.eachItem)(n,r=>{if(t.keywords[r])throw new Error(`Keyword ${r} is already defined`);if(!Iw.test(r))throw new Error(`Keyword ${r} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function oc(n,e,t){var r;let i=e?.post;if(t&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:a}=this,s=i?a.post:a.rules.find(({type:u})=>u===t);if(s||(s={type:t,rules:[]},a.rules.push(s)),a.keywords[n]=true,!e)return;let o={keyword:n,definition:{...e,type:(0, Zs.getJSONTypes)(e.type),schemaType:(0, Zs.getJSONTypes)(e.schemaType)}};e.before?Vw.call(this,s,o,e.before):s.rules.push(o),a.all[n]=o,(r=e.implements)===null||r===void 0||r.forEach(u=>this.addKeyword(u));}function Vw(n,e,t){let r=n.rules.findIndex(i=>i.keyword===t);r>=0?n.rules.splice(r,0,e):(n.rules.push(e),this.logger.warn(`rule ${t} is not defined`));}function Rw(n){let{metaSchema:e}=n;e!==void 0&&(n.$data&&this.opts.$data&&(e=Cg(e)),n.validateSchema=this.compile(e,true));}var jw={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Cg(n){return {anyOf:[n,jw]}}});var Sg=w(cc=>{Object.defineProperty(cc,"__esModule",{value:true});var $w={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};cc.default=$w;});var ta=w(Gn=>{Object.defineProperty(Gn,"__esModule",{value:true});Gn.callRef=Gn.getValidate=void 0;var Lw=yr(),_g=yt(),st=j(),Cr=gt(),wg=Si(),Qs=M(),qw={keyword:"$ref",schemaType:"string",code(n){let{gen:e,schema:t,it:r}=n,{baseId:i,schemaEnv:a,validateName:s,opts:o,self:u}=r,{root:l}=a;if((t==="#"||t==="#/")&&i===l.baseId)return h();let c=wg.resolveRef.call(u,l,i,t);if(c===void 0)throw new Lw.default(r.opts.uriResolver,i,t);if(c instanceof wg.SchemaEnv)return f(c);return p(c);function h(){if(a===l)return ea(n,s,a,a.$async);let g=e.scopeValue("root",{ref:l});return ea(n,(0, st._)`${g}.validate`,l,l.$async)}function f(g){let y=Eg(n,g);ea(n,y,g,g.$async);}function p(g){let y=e.scopeValue("schema",o.code.source===true?{ref:g,code:(0, st.stringify)(g)}:{ref:g}),C=e.name("valid"),S=n.subschema({schema:g,dataTypes:[],schemaPath:st.nil,topSchemaRef:y,errSchemaPath:t},C);n.mergeEvaluated(S),n.ok(C);}}};function Eg(n,e){let{gen:t}=n;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0, st._)`${t.scopeValue("wrapper",{ref:e})}.validate`}Gn.getValidate=Eg;function ea(n,e,t,r){let{gen:i,it:a}=n,{allErrors:s,schemaEnv:o,opts:u}=a,l=u.passContext?Cr.default.this:st.nil;r?c():h();function c(){if(!o.$async)throw new Error("async schema referenced by sync schema");let g=i.let("valid");i.try(()=>{i.code((0, st._)`await ${(0, _g.callValidateCode)(n,e,l)}`),p(e),s||i.assign(g,true);},y=>{i.if((0, st._)`!(${y} instanceof ${a.ValidationError})`,()=>i.throw(y)),f(y),s||i.assign(g,false);}),n.ok(g);}function h(){n.result((0, _g.callValidateCode)(n,e,l),()=>p(e),()=>f(e));}function f(g){let y=(0, st._)`${g}.errors`;i.assign(Cr.default.vErrors,(0, st._)`${Cr.default.vErrors} === null ? ${y} : ${Cr.default.vErrors}.concat(${y})`),i.assign(Cr.default.errors,(0, st._)`${Cr.default.vErrors}.length`);}function p(g){var y;if(!a.opts.unevaluated)return;let C=(y=t?.validate)===null||y===void 0?void 0:y.evaluated;if(a.props!==true)if(C&&!C.dynamicProps)C.props!==void 0&&(a.props=Qs.mergeEvaluated.props(i,C.props,a.props));else {let S=i.var("props",(0, st._)`${g}.evaluated.props`);a.props=Qs.mergeEvaluated.props(i,S,a.props,st.Name);}if(a.items!==true)if(C&&!C.dynamicItems)C.items!==void 0&&(a.items=Qs.mergeEvaluated.items(i,C.items,a.items));else {let S=i.var("items",(0, st._)`${g}.evaluated.items`);a.items=Qs.mergeEvaluated.items(i,S,a.items,st.Name);}}}Gn.callRef=ea;Gn.default=qw;});var dc=w(hc=>{Object.defineProperty(hc,"__esModule",{value:true});var Bw=Sg(),Ww=ta(),Mw=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Bw.default,Ww.default];hc.default=Mw;});var Dg=w(pc=>{Object.defineProperty(pc,"__esModule",{value:true});var na=j(),vn=na.operators,ra={maximum:{okStr:"<=",ok:vn.LTE,fail:vn.GT},minimum:{okStr:">=",ok:vn.GTE,fail:vn.LT},exclusiveMaximum:{okStr:"<",ok:vn.LT,fail:vn.GTE},exclusiveMinimum:{okStr:">",ok:vn.GT,fail:vn.LTE}},Gw={message:({keyword:n,schemaCode:e})=>(0, na.str)`must be ${ra[n].okStr} ${e}`,params:({keyword:n,schemaCode:e})=>(0, na._)`{comparison: ${ra[n].okStr}, limit: ${e}}`},zw={keyword:Object.keys(ra),type:"number",schemaType:"number",$data:true,error:Gw,code(n){let{keyword:e,data:t,schemaCode:r}=n;n.fail$data((0, na._)`${t} ${ra[e].fail} ${r} || isNaN(${t})`);}};pc.default=zw;});var Ag=w(fc=>{Object.defineProperty(fc,"__esModule",{value:true});var Oi=j(),Jw={message:({schemaCode:n})=>(0, Oi.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0, Oi._)`{multipleOf: ${n}}`},Hw={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:Jw,code(n){let{gen:e,data:t,schemaCode:r,it:i}=n,a=i.opts.multipleOfPrecision,s=e.let("res"),o=a?(0, Oi._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${a}`:(0, Oi._)`${s} !== parseInt(${s})`;n.fail$data((0, Oi._)`(${r} === 0 || (${s} = ${t}/${r}, ${o}))`);}};fc.default=Hw;});var Pg=w(mc=>{Object.defineProperty(mc,"__esModule",{value:true});function Og(n){let e=n.length,t=0,r=0,i;for(;r<e;)t++,i=n.charCodeAt(r++),i>=55296&&i<=56319&&r<e&&(i=n.charCodeAt(r),(i&64512)===56320&&r++);return t}mc.default=Og;Og.code='require("ajv/dist/runtime/ucs2length").default';});var xg=w(gc=>{Object.defineProperty(gc,"__esModule",{value:true});var zn=j(),Uw=M(),Kw=Pg(),Xw={message({keyword:n,schemaCode:e}){let t=n==="maxLength"?"more":"fewer";return (0, zn.str)`must NOT have ${t} than ${e} characters`},params:({schemaCode:n})=>(0, zn._)`{limit: ${n}}`},Yw={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:Xw,code(n){let{keyword:e,data:t,schemaCode:r,it:i}=n,a=e==="maxLength"?zn.operators.GT:zn.operators.LT,s=i.opts.unicode===false?(0, zn._)`${t}.length`:(0, zn._)`${(0, Uw.useFunc)(n.gen,Kw.default)}(${t})`;n.fail$data((0, zn._)`${s} ${a} ${r}`);}};gc.default=Yw;});var Tg=w(yc=>{Object.defineProperty(yc,"__esModule",{value:true});var Zw=yt(),Qw=M(),Sr=j(),eE={message:({schemaCode:n})=>(0, Sr.str)`must match pattern "${n}"`,params:({schemaCode:n})=>(0, Sr._)`{pattern: ${n}}`},tE={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:eE,code(n){let{gen:e,data:t,$data:r,schema:i,schemaCode:a,it:s}=n,o=s.opts.unicodeRegExp?"u":"";if(r){let{regExp:u}=s.opts.code,l=u.code==="new RegExp"?(0, Sr._)`new RegExp`:(0, Qw.useFunc)(e,u),c=e.let("valid");e.try(()=>e.assign(c,(0, Sr._)`${l}(${a}, ${o}).test(${t})`),()=>e.assign(c,false)),n.fail$data((0, Sr._)`!${c}`);}else {let u=(0, Zw.usePattern)(n,i);n.fail$data((0, Sr._)`!${u}.test(${t})`);}}};yc.default=tE;});var Ng=w(vc=>{Object.defineProperty(vc,"__esModule",{value:true});var Pi=j(),nE={message({keyword:n,schemaCode:e}){let t=n==="maxProperties"?"more":"fewer";return (0, Pi.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:n})=>(0, Pi._)`{limit: ${n}}`},rE={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:nE,code(n){let{keyword:e,data:t,schemaCode:r}=n,i=e==="maxProperties"?Pi.operators.GT:Pi.operators.LT;n.fail$data((0, Pi._)`Object.keys(${t}).length ${i} ${r}`);}};vc.default=rE;});var Fg=w(bc=>{Object.defineProperty(bc,"__esModule",{value:true});var xi=yt(),Ti=j(),iE=M(),sE={message:({params:{missingProperty:n}})=>(0, Ti.str)`must have required property '${n}'`,params:({params:{missingProperty:n}})=>(0, Ti._)`{missingProperty: ${n}}`},aE={keyword:"required",type:"object",schemaType:"array",$data:true,error:sE,code(n){let{gen:e,schema:t,schemaCode:r,data:i,$data:a,it:s}=n,{opts:o}=s;if(!a&&t.length===0)return;let u=t.length>=o.loopRequired;if(s.allErrors?l():c(),o.strictRequired){let p=n.parentSchema.properties,{definedProperties:g}=n.it;for(let y of t)if(p?.[y]===void 0&&!g.has(y)){let C=s.schemaEnv.baseId+s.errSchemaPath,S=`required property "${y}" is not defined at "${C}" (strictRequired)`;(0, iE.checkStrictMode)(s,S,s.opts.strictRequired);}}function l(){if(u||a)n.block$data(Ti.nil,h);else for(let p of t)(0, xi.checkReportMissingProp)(n,p);}function c(){let p=e.let("missing");if(u||a){let g=e.let("valid",true);n.block$data(g,()=>f(p,g)),n.ok(g);}else e.if((0, xi.checkMissingProp)(n,t,p)),(0, xi.reportMissingProp)(n,p),e.else();}function h(){e.forOf("prop",r,p=>{n.setParams({missingProperty:p}),e.if((0, xi.noPropertyInData)(e,i,p,o.ownProperties),()=>n.error());});}function f(p,g){n.setParams({missingProperty:p}),e.forOf(p,r,()=>{e.assign(g,(0, xi.propertyInData)(e,i,p,o.ownProperties)),e.if((0, Ti.not)(g),()=>{n.error(),e.break();});},Ti.nil);}}};bc.default=aE;});var Ig=w(Cc=>{Object.defineProperty(Cc,"__esModule",{value:true});var Ni=j(),oE={message({keyword:n,schemaCode:e}){let t=n==="maxItems"?"more":"fewer";return (0, Ni.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:n})=>(0, Ni._)`{limit: ${n}}`},uE={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:oE,code(n){let{keyword:e,data:t,schemaCode:r}=n,i=e==="maxItems"?Ni.operators.GT:Ni.operators.LT;n.fail$data((0, Ni._)`${t}.length ${i} ${r}`);}};Cc.default=uE;});var ia=w(Sc=>{Object.defineProperty(Sc,"__esModule",{value:true});var kg=Rl();kg.code='require("ajv/dist/runtime/equal").default';Sc.default=kg;});var Vg=w(wc=>{Object.defineProperty(wc,"__esModule",{value:true});var _c=gi(),Ie=j(),lE=M(),cE=ia(),hE={message:({params:{i:n,j:e}})=>(0, Ie.str)`must NOT have duplicate items (items ## ${e} and ${n} are identical)`,params:({params:{i:n,j:e}})=>(0, Ie._)`{i: ${n}, j: ${e}}`},dE={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:hE,code(n){let{gen:e,data:t,$data:r,schema:i,parentSchema:a,schemaCode:s,it:o}=n;if(!r&&!i)return;let u=e.let("valid"),l=a.items?(0, _c.getSchemaTypes)(a.items):[];n.block$data(u,c,(0, Ie._)`${s} === false`),n.ok(u);function c(){let g=e.let("i",(0, Ie._)`${t}.length`),y=e.let("j");n.setParams({i:g,j:y}),e.assign(u,true),e.if((0, Ie._)`${g} > 1`,()=>(h()?f:p)(g,y));}function h(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function f(g,y){let C=e.name("item"),S=(0, _c.checkDataTypes)(l,C,o.opts.strictNumbers,_c.DataType.Wrong),v=e.const("indices",(0, Ie._)`{}`);e.for((0, Ie._)`;${g}--;`,()=>{e.let(C,(0, Ie._)`${t}[${g}]`),e.if(S,(0, Ie._)`continue`),l.length>1&&e.if((0, Ie._)`typeof ${C} == "string"`,(0, Ie._)`${C} += "_"`),e.if((0, Ie._)`typeof ${v}[${C}] == "number"`,()=>{e.assign(y,(0, Ie._)`${v}[${C}]`),n.error(),e.assign(u,false).break();}).code((0, Ie._)`${v}[${C}] = ${g}`);});}function p(g,y){let C=(0, lE.useFunc)(e,cE.default),S=e.name("outer");e.label(S).for((0, Ie._)`;${g}--;`,()=>e.for((0, Ie._)`${y} = ${g}; ${y}--;`,()=>e.if((0, Ie._)`${C}(${t}[${g}], ${t}[${y}])`,()=>{n.error(),e.assign(u,false).break(S);})));}}};wc.default=dE;});var Rg=w(Dc=>{Object.defineProperty(Dc,"__esModule",{value:true});var Ec=j(),pE=M(),fE=ia(),mE={message:"must be equal to constant",params:({schemaCode:n})=>(0, Ec._)`{allowedValue: ${n}}`},gE={keyword:"const",$data:true,error:mE,code(n){let{gen:e,data:t,$data:r,schemaCode:i,schema:a}=n;r||a&&typeof a=="object"?n.fail$data((0, Ec._)`!${(0, pE.useFunc)(e,fE.default)}(${t}, ${i})`):n.fail((0, Ec._)`${a} !== ${t}`);}};Dc.default=gE;});var jg=w(Ac=>{Object.defineProperty(Ac,"__esModule",{value:true});var Fi=j(),yE=M(),vE=ia(),bE={message:"must be equal to one of the allowed values",params:({schemaCode:n})=>(0, Fi._)`{allowedValues: ${n}}`},CE={keyword:"enum",schemaType:"array",$data:true,error:bE,code(n){let{gen:e,data:t,$data:r,schema:i,schemaCode:a,it:s}=n;if(!r&&i.length===0)throw new Error("enum must have non-empty array");let o=i.length>=s.opts.loopEnum,u,l=()=>u??(u=(0, yE.useFunc)(e,vE.default)),c;if(o||r)c=e.let("valid"),n.block$data(c,h);else {if(!Array.isArray(i))throw new Error("ajv implementation error");let p=e.const("vSchema",a);c=(0, Fi.or)(...i.map((g,y)=>f(p,y)));}n.pass(c);function h(){e.assign(c,false),e.forOf("v",a,p=>e.if((0, Fi._)`${l()}(${t}, ${p})`,()=>e.assign(c,true).break()));}function f(p,g){let y=i[g];return typeof y=="object"&&y!==null?(0, Fi._)`${l()}(${t}, ${p}[${g}])`:(0, Fi._)`${t} === ${y}`}}};Ac.default=CE;});var Pc=w(Oc=>{Object.defineProperty(Oc,"__esModule",{value:true});var SE=Dg(),_E=Ag(),wE=xg(),EE=Tg(),DE=Ng(),AE=Fg(),OE=Ig(),PE=Vg(),xE=Rg(),TE=jg(),NE=[SE.default,_E.default,wE.default,EE.default,DE.default,AE.default,OE.default,PE.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},xE.default,TE.default];Oc.default=NE;});var Tc=w(Ii=>{Object.defineProperty(Ii,"__esModule",{value:true});Ii.validateAdditionalItems=void 0;var Jn=j(),xc=M(),FE={message:({params:{len:n}})=>(0, Jn.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0, Jn._)`{limit: ${n}}`},IE={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:FE,code(n){let{parentSchema:e,it:t}=n,{items:r}=e;if(!Array.isArray(r)){(0, xc.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}$g(n,r);}};function $g(n,e){let{gen:t,schema:r,data:i,keyword:a,it:s}=n;s.items=true;let o=t.const("len",(0, Jn._)`${i}.length`);if(r===false)n.setParams({len:e.length}),n.pass((0, Jn._)`${o} <= ${e.length}`);else if(typeof r=="object"&&!(0, xc.alwaysValidSchema)(s,r)){let l=t.var("valid",(0, Jn._)`${o} <= ${e.length}`);t.if((0, Jn.not)(l),()=>u(l)),n.ok(l);}function u(l){t.forRange("i",e.length,o,c=>{n.subschema({keyword:a,dataProp:c,dataPropType:xc.Type.Num},l),s.allErrors||t.if((0, Jn.not)(l),()=>t.break());});}}Ii.validateAdditionalItems=$g;Ii.default=IE;});var Nc=w(ki=>{Object.defineProperty(ki,"__esModule",{value:true});ki.validateTuple=void 0;var Lg=j(),sa=M(),kE=yt(),VE={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(n){let{schema:e,it:t}=n;if(Array.isArray(e))return qg(n,"additionalItems",e);t.items=true,!(0, sa.alwaysValidSchema)(t,e)&&n.ok((0, kE.validateArray)(n));}};function qg(n,e,t=n.schema){let{gen:r,parentSchema:i,data:a,keyword:s,it:o}=n;c(i),o.opts.unevaluated&&t.length&&o.items!==true&&(o.items=sa.mergeEvaluated.items(r,t.length,o.items));let u=r.name("valid"),l=r.const("len",(0, Lg._)`${a}.length`);t.forEach((h,f)=>{(0, sa.alwaysValidSchema)(o,h)||(r.if((0, Lg._)`${l} > ${f}`,()=>n.subschema({keyword:s,schemaProp:f,dataProp:f},u)),n.ok(u));});function c(h){let{opts:f,errSchemaPath:p}=o,g=t.length,y=g===h.minItems&&(g===h.maxItems||h[e]===false);if(f.strictTuples&&!y){let C=`"${s}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0, sa.checkStrictMode)(o,C,f.strictTuples);}}}ki.validateTuple=qg;ki.default=VE;});var Bg=w(Fc=>{Object.defineProperty(Fc,"__esModule",{value:true});var RE=Nc(),jE={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:n=>(0, RE.validateTuple)(n,"items")};Fc.default=jE;});var Mg=w(Ic=>{Object.defineProperty(Ic,"__esModule",{value:true});var Wg=j(),$E=M(),LE=yt(),qE=Tc(),BE={message:({params:{len:n}})=>(0, Wg.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0, Wg._)`{limit: ${n}}`},WE={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:BE,code(n){let{schema:e,parentSchema:t,it:r}=n,{prefixItems:i}=t;r.items=true,!(0, $E.alwaysValidSchema)(r,e)&&(i?(0, qE.validateAdditionalItems)(n,i):n.ok((0, LE.validateArray)(n)));}};Ic.default=WE;});var Gg=w(kc=>{Object.defineProperty(kc,"__esModule",{value:true});var bt=j(),aa=M(),ME={message:({params:{min:n,max:e}})=>e===void 0?(0, bt.str)`must contain at least ${n} valid item(s)`:(0, bt.str)`must contain at least ${n} and no more than ${e} valid item(s)`,params:({params:{min:n,max:e}})=>e===void 0?(0, bt._)`{minContains: ${n}}`:(0, bt._)`{minContains: ${n}, maxContains: ${e}}`},GE={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:ME,code(n){let{gen:e,schema:t,parentSchema:r,data:i,it:a}=n,s,o,{minContains:u,maxContains:l}=r;a.opts.next?(s=u===void 0?1:u,o=l):s=1;let c=e.const("len",(0, bt._)`${i}.length`);if(n.setParams({min:s,max:o}),o===void 0&&s===0){(0, aa.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(o!==void 0&&s>o){(0, aa.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),n.fail();return}if((0, aa.alwaysValidSchema)(a,t)){let y=(0, bt._)`${c} >= ${s}`;o!==void 0&&(y=(0, bt._)`${y} && ${c} <= ${o}`),n.pass(y);return}a.items=true;let h=e.name("valid");o===void 0&&s===1?p(h,()=>e.if(h,()=>e.break())):s===0?(e.let(h,true),o!==void 0&&e.if((0, bt._)`${i}.length > 0`,f)):(e.let(h,false),f()),n.result(h,()=>n.reset());function f(){let y=e.name("_valid"),C=e.let("count",0);p(y,()=>e.if(y,()=>g(C)));}function p(y,C){e.forRange("i",0,c,S=>{n.subschema({keyword:"contains",dataProp:S,dataPropType:aa.Type.Num,compositeRule:true},y),C();});}function g(y){e.code((0, bt._)`${y}++`),o===void 0?e.if((0, bt._)`${y} >= ${s}`,()=>e.assign(h,true).break()):(e.if((0, bt._)`${y} > ${o}`,()=>e.assign(h,false).break()),s===1?e.assign(h,true):e.if((0, bt._)`${y} >= ${s}`,()=>e.assign(h,true)));}}};kc.default=GE;});var oa=w(Lt=>{Object.defineProperty(Lt,"__esModule",{value:true});Lt.validateSchemaDeps=Lt.validatePropertyDeps=Lt.error=void 0;var Vc=j(),zE=M(),Vi=yt();Lt.error={message:({params:{property:n,depsCount:e,deps:t}})=>{let r=e===1?"property":"properties";return (0, Vc.str)`must have ${r} ${t} when property ${n} is present`},params:({params:{property:n,depsCount:e,deps:t,missingProperty:r}})=>(0, Vc._)`{property: ${n},
|
|
6
6
|
missingProperty: ${r},
|
|
7
7
|
depsCount: ${e},
|
|
8
|
-
deps: ${t}}`};var Zw={keyword:"dependencies",type:"object",schemaType:"object",error:$t.error,code(n){let[e,t]=Qw(n);Mg(n,e),Gg(n,t);}};function Qw({schema:n}){let e={},t={};for(let r in n){if(r==="__proto__")continue;let i=Array.isArray(n[r])?e:t;i[r]=n[r];}return [e,t]}function Mg(n,e=n.schema){let{gen:t,data:r,it:i}=n;if(Object.keys(e).length===0)return;let a=t.let("missing");for(let s in e){let o=e[s];if(o.length===0)continue;let u=(0, Ii.propertyInData)(t,r,s,i.opts.ownProperties);n.setParams({property:s,depsCount:o.length,deps:o.join(", ")}),i.allErrors?t.if(u,()=>{for(let l of o)(0, Ii.checkReportMissingProp)(n,l);}):(t.if((0, Ic._)`${u} && (${(0, Ii.checkMissingProp)(n,o,a)})`),(0, Ii.reportMissingProp)(n,a),t.else());}}$t.validatePropertyDeps=Mg;function Gg(n,e=n.schema){let{gen:t,data:r,keyword:i,it:a}=n,s=t.name("valid");for(let o in e)(0, Yw.alwaysValidSchema)(a,e[o])||(t.if((0, Ii.propertyInData)(t,r,o,a.opts.ownProperties),()=>{let u=n.subschema({keyword:i,schemaProp:o},s);n.mergeValidEvaluated(u,s);},()=>t.var(s,true)),n.ok(s));}$t.validateSchemaDeps=Gg;$t.default=Zw;});var Jg=E(kc=>{Object.defineProperty(kc,"__esModule",{value:true});var zg=$(),eD=M(),tD={message:"property name must be valid",params:({params:n})=>(0, zg._)`{propertyName: ${n.propertyName}}`},nD={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:tD,code(n){let{gen:e,schema:t,data:r,it:i}=n;if((0, eD.alwaysValidSchema)(i,t))return;let a=e.name("valid");e.forIn("key",r,s=>{n.setParams({propertyName:s}),n.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:true},a),e.if((0, zg.not)(a),()=>{n.error(true),i.allErrors||e.break();});}),n.ok(a);}};kc.default=nD;});var Rc=E(Vc=>{Object.defineProperty(Vc,"__esModule",{value:true});var aa=mt(),Tt=$(),rD=pt(),oa=M(),iD={message:"must NOT have additional properties",params:({params:n})=>(0, Tt._)`{additionalProperty: ${n.additionalProperty}}`},sD={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:iD,code(n){let{gen:e,schema:t,parentSchema:r,data:i,errsCount:a,it:s}=n;if(!a)throw new Error("ajv implementation error");let{allErrors:o,opts:u}=s;if(s.props=true,u.removeAdditional!=="all"&&(0, oa.alwaysValidSchema)(s,t))return;let l=(0, aa.allSchemaProperties)(r.properties),c=(0, aa.allSchemaProperties)(r.patternProperties);h(),n.ok((0, Tt._)`${a} === ${rD.default.errors}`);function h(){e.forIn("key",i,C=>{!l.length&&!c.length?g(C):e.if(p(C),()=>g(C));});}function p(C){let _;if(l.length>8){let v=(0, oa.schemaRefOrVal)(s,r.properties,"properties");_=(0, aa.isOwnProperty)(e,v,C);}else l.length?_=(0, Tt.or)(...l.map(v=>(0, Tt._)`${C} === ${v}`)):_=Tt.nil;return c.length&&(_=(0, Tt.or)(_,...c.map(v=>(0, Tt._)`${(0, aa.usePattern)(n,v)}.test(${C})`))),(0, Tt.not)(_)}function f(C){e.code((0, Tt._)`delete ${i}[${C}]`);}function g(C){if(u.removeAdditional==="all"||u.removeAdditional&&t===false){f(C);return}if(t===false){n.setParams({additionalProperty:C}),n.error(),o||e.break();return}if(typeof t=="object"&&!(0, oa.alwaysValidSchema)(s,t)){let _=e.name("valid");u.removeAdditional==="failing"?(y(C,_,false),e.if((0, Tt.not)(_),()=>{n.reset(),f(C);})):(y(C,_),o||e.if((0, Tt.not)(_),()=>e.break()));}}function y(C,_,v){let d={keyword:"additionalProperties",dataProp:C,dataPropType:oa.Type.Str};v===false&&Object.assign(d,{compositeRule:true,createErrors:false,allErrors:false}),n.subschema(d,_);}}};Vc.default=sD;});var Kg=E(jc=>{Object.defineProperty(jc,"__esModule",{value:true});var aD=pr(),Hg=mt(),$c=M(),Ug=Rc(),oD={keyword:"properties",type:"object",schemaType:"object",code(n){let{gen:e,schema:t,parentSchema:r,data:i,it:a}=n;a.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&Ug.default.code(new aD.KeywordCxt(a,Ug.default,"additionalProperties"));let s=(0, Hg.allSchemaProperties)(t);for(let h of s)a.definedProperties.add(h);a.opts.unevaluated&&s.length&&a.props!==true&&(a.props=$c.mergeEvaluated.props(e,(0, $c.toHash)(s),a.props));let o=s.filter(h=>!(0, $c.alwaysValidSchema)(a,t[h]));if(o.length===0)return;let u=e.name("valid");for(let h of o)l(h)?c(h):(e.if((0, Hg.propertyInData)(e,i,h,a.opts.ownProperties)),c(h),a.allErrors||e.else().var(u,true),e.endIf()),n.it.definedProperties.add(h),n.ok(u);function l(h){return a.opts.useDefaults&&!a.compositeRule&&t[h].default!==void 0}function c(h){n.subschema({keyword:"properties",schemaProp:h,dataProp:h},u);}}};jc.default=oD;});var Qg=E(Lc=>{Object.defineProperty(Lc,"__esModule",{value:true});var Xg=mt(),ua=$(),Yg=M(),Zg=M(),uD={keyword:"patternProperties",type:"object",schemaType:"object",code(n){let{gen:e,schema:t,data:r,parentSchema:i,it:a}=n,{opts:s}=a,o=(0, Xg.allSchemaProperties)(t),u=o.filter(y=>(0, Yg.alwaysValidSchema)(a,t[y]));if(o.length===0||u.length===o.length&&(!a.opts.unevaluated||a.props===true))return;let l=s.strictSchema&&!s.allowMatchingProperties&&i.properties,c=e.name("valid");a.props!==true&&!(a.props instanceof ua.Name)&&(a.props=(0, Zg.evaluatedPropsToName)(e,a.props));let{props:h}=a;p();function p(){for(let y of o)l&&f(y),a.allErrors?g(y):(e.var(c,true),g(y),e.if(c));}function f(y){for(let C in l)new RegExp(y).test(C)&&(0, Yg.checkStrictMode)(a,`property ${C} matches pattern ${y} (use allowMatchingProperties)`);}function g(y){e.forIn("key",r,C=>{e.if((0, ua._)`${(0, Xg.usePattern)(n,y)}.test(${C})`,()=>{let _=u.includes(y);_||n.subschema({keyword:"patternProperties",schemaProp:y,dataProp:C,dataPropType:Zg.Type.Str},c),a.opts.unevaluated&&h!==true?e.assign((0, ua._)`${h}[${C}]`,true):!_&&!a.allErrors&&e.if((0, ua.not)(c),()=>e.break());});});}}};Lc.default=uD;});var ey=E(qc=>{Object.defineProperty(qc,"__esModule",{value:true});var lD=M(),cD={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(n){let{gen:e,schema:t,it:r}=n;if((0, lD.alwaysValidSchema)(r,t)){n.fail();return}let i=e.name("valid");n.subschema({keyword:"not",compositeRule:true,createErrors:false,allErrors:false},i),n.failResult(i,()=>n.reset(),()=>n.error());},error:{message:"must NOT be valid"}};qc.default=cD;});var ty=E(Bc=>{Object.defineProperty(Bc,"__esModule",{value:true});var hD=mt(),dD={keyword:"anyOf",schemaType:"array",trackErrors:true,code:hD.validateUnion,error:{message:"must match a schema in anyOf"}};Bc.default=dD;});var ny=E(Wc=>{Object.defineProperty(Wc,"__esModule",{value:true});var la=$(),fD=M(),pD={message:"must match exactly one schema in oneOf",params:({params:n})=>(0, la._)`{passingSchemas: ${n.passing}}`},mD={keyword:"oneOf",schemaType:"array",trackErrors:true,error:pD,code(n){let{gen:e,schema:t,parentSchema:r,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(i.opts.discriminator&&r.discriminator)return;let a=t,s=e.let("valid",false),o=e.let("passing",null),u=e.name("_valid");n.setParams({passing:o}),e.block(l),n.result(s,()=>n.reset(),()=>n.error(true));function l(){a.forEach((c,h)=>{let p;(0, fD.alwaysValidSchema)(i,c)?e.var(u,true):p=n.subschema({keyword:"oneOf",schemaProp:h,compositeRule:true},u),h>0&&e.if((0, la._)`${u} && ${s}`).assign(s,false).assign(o,(0, la._)`[${o}, ${h}]`).else(),e.if(u,()=>{e.assign(s,true),e.assign(o,h),p&&n.mergeEvaluated(p,la.Name);});});}}};Wc.default=mD;});var ry=E(Mc=>{Object.defineProperty(Mc,"__esModule",{value:true});var gD=M(),yD={keyword:"allOf",schemaType:"array",code(n){let{gen:e,schema:t,it:r}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");let i=e.name("valid");t.forEach((a,s)=>{if((0, gD.alwaysValidSchema)(r,a))return;let o=n.subschema({keyword:"allOf",schemaProp:s},i);n.ok(i),n.mergeEvaluated(o);});}};Mc.default=yD;});var ay=E(Gc=>{Object.defineProperty(Gc,"__esModule",{value:true});var ca=$(),sy=M(),vD={message:({params:n})=>(0, ca.str)`must match "${n.ifClause}" schema`,params:({params:n})=>(0, ca._)`{failingKeyword: ${n.ifClause}}`},CD={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:vD,code(n){let{gen:e,parentSchema:t,it:r}=n;t.then===void 0&&t.else===void 0&&(0, sy.checkStrictMode)(r,'"if" without "then" and "else" is ignored');let i=iy(r,"then"),a=iy(r,"else");if(!i&&!a)return;let s=e.let("valid",true),o=e.name("_valid");if(u(),n.reset(),i&&a){let c=e.let("ifClause");n.setParams({ifClause:c}),e.if(o,l("then",c),l("else",c));}else i?e.if(o,l("then")):e.if((0, ca.not)(o),l("else"));n.pass(s,()=>n.error(true));function u(){let c=n.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},o);n.mergeEvaluated(c);}function l(c,h){return ()=>{let p=n.subschema({keyword:c},o);e.assign(s,o),n.mergeValidEvaluated(p,s),h?e.assign(h,(0, ca._)`${c}`):n.setParams({ifClause:c});}}}};function iy(n,e){let t=n.schema[e];return t!==void 0&&!(0, sy.alwaysValidSchema)(n,t)}Gc.default=CD;});var oy=E(zc=>{Object.defineProperty(zc,"__esModule",{value:true});var bD=M(),_D={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:n,parentSchema:e,it:t}){e.if===void 0&&(0, bD.checkStrictMode)(t,`"${n}" without "if" is ignored`);}};zc.default=_D;});var Hc=E(Jc=>{Object.defineProperty(Jc,"__esModule",{value:true});var SD=Oc(),ED=Lg(),wD=xc(),DD=Bg(),AD=Wg(),PD=sa(),OD=Jg(),xD=Rc(),TD=Kg(),ND=Qg(),FD=ey(),ID=ty(),kD=ny(),VD=ry(),RD=ay(),$D=oy();function jD(n=false){let e=[FD.default,ID.default,kD.default,VD.default,RD.default,$D.default,OD.default,xD.default,PD.default,TD.default,ND.default];return n?e.push(ED.default,DD.default):e.push(SD.default,wD.default),e.push(AD.default),e}Jc.default=jD;});var uy=E(Uc=>{Object.defineProperty(Uc,"__esModule",{value:true});var _e=$(),LD={message:({schemaCode:n})=>(0, _e.str)`must match format "${n}"`,params:({schemaCode:n})=>(0, _e._)`{format: ${n}}`},qD={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:LD,code(n,e){let{gen:t,data:r,$data:i,schema:a,schemaCode:s,it:o}=n,{opts:u,errSchemaPath:l,schemaEnv:c,self:h}=o;if(!u.validateFormats)return;i?p():f();function p(){let g=t.scopeValue("formats",{ref:h.formats,code:u.code.formats}),y=t.const("fDef",(0, _e._)`${g}[${s}]`),C=t.let("fType"),_=t.let("format");t.if((0, _e._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>t.assign(C,(0, _e._)`${y}.type || "string"`).assign(_,(0, _e._)`${y}.validate`),()=>t.assign(C,(0, _e._)`"string"`).assign(_,y)),n.fail$data((0, _e.or)(v(),d()));function v(){return u.strictSchema===false?_e.nil:(0, _e._)`${s} && !${_}`}function d(){let S=c.$async?(0, _e._)`(${y}.async ? await ${_}(${r}) : ${_}(${r}))`:(0, _e._)`${_}(${r})`,m=(0, _e._)`(typeof ${_} == "function" ? ${S} : ${_}.test(${r}))`;return (0, _e._)`${_} && ${_} !== true && ${C} === ${e} && !${m}`}}function f(){let g=h.formats[a];if(!g){v();return}if(g===true)return;let[y,C,_]=d(g);y===e&&n.pass(S());function v(){if(u.strictSchema===false){h.logger.warn(m());return}throw new Error(m());function m(){return `unknown format "${a}" ignored in schema at path "${l}"`}}function d(m){let b=m instanceof RegExp?(0, _e.regexpCode)(m):u.code.formats?(0, _e._)`${u.code.formats}${(0, _e.getProperty)(a)}`:void 0,w=t.scopeValue("formats",{key:a,ref:m,code:b});return typeof m=="object"&&!(m instanceof RegExp)?[m.type||"string",m.validate,(0, _e._)`${w}.validate`]:["string",m,w]}function S(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!c.$async)throw new Error("async format in sync schema");return (0, _e._)`await ${_}(${r})`}return typeof C=="function"?(0, _e._)`${_}(${r})`:(0, _e._)`${_}.test(${r})`}}}};Uc.default=qD;});var Xc=E(Kc=>{Object.defineProperty(Kc,"__esModule",{value:true});var BD=uy(),WD=[BD.default];Kc.default=WD;});var Yc=E(br=>{Object.defineProperty(br,"__esModule",{value:true});br.contentVocabulary=br.metadataVocabulary=void 0;br.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];br.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var cy=E(Zc=>{Object.defineProperty(Zc,"__esModule",{value:true});var MD=cc(),GD=Ac(),zD=Hc(),JD=Xc(),ly=Yc(),HD=[MD.default,GD.default,(0, zD.default)(),JD.default,ly.metadataVocabulary,ly.contentVocabulary];Zc.default=HD;});var dy=E(ha=>{Object.defineProperty(ha,"__esModule",{value:true});ha.DiscrError=void 0;var hy;(function(n){n.Tag="tag",n.Mapping="mapping";})(hy||(ha.DiscrError=hy={}));});var th=E(eh=>{Object.defineProperty(eh,"__esModule",{value:true});var _r=$(),Qc=dy(),fy=Ci(),UD=mr(),KD=M(),XD={message:({params:{discrError:n,tagName:e}})=>n===Qc.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:n,tag:e,tagName:t}})=>(0, _r._)`{error: ${n}, tag: ${t}, tagValue: ${e}}`},YD={keyword:"discriminator",type:"object",schemaType:"object",error:XD,code(n){let{gen:e,data:t,schema:r,parentSchema:i,it:a}=n,{oneOf:s}=i;if(!a.opts.discriminator)throw new Error("discriminator: requires discriminator option");let o=r.propertyName;if(typeof o!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let u=e.let("valid",false),l=e.const("tag",(0, _r._)`${t}${(0, _r.getProperty)(o)}`);e.if((0, _r._)`typeof ${l} == "string"`,()=>c(),()=>n.error(false,{discrError:Qc.DiscrError.Tag,tag:l,tagName:o})),n.ok(u);function c(){let f=p();e.if(false);for(let g in f)e.elseIf((0, _r._)`${l} === ${g}`),e.assign(u,h(f[g]));e.else(),n.error(false,{discrError:Qc.DiscrError.Mapping,tag:l,tagName:o}),e.endIf();}function h(f){let g=e.name("valid"),y=n.subschema({keyword:"oneOf",schemaProp:f},g);return n.mergeEvaluated(y,_r.Name),g}function p(){var f;let g={},y=_(i),C=true;for(let S=0;S<s.length;S++){let m=s[S];if(m?.$ref&&!(0, KD.schemaHasRulesButRef)(m,a.self.RULES)){let w=m.$ref;if(m=fy.resolveRef.call(a.self,a.schemaEnv.root,a.baseId,w),m instanceof fy.SchemaEnv&&(m=m.schema),m===void 0)throw new UD.default(a.opts.uriResolver,a.baseId,w)}let b=(f=m?.properties)===null||f===void 0?void 0:f[o];if(typeof b!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${o}"`);C=C&&(y||_(m)),v(b,S);}if(!C)throw new Error(`discriminator: "${o}" must be required`);return g;function _({required:S}){return Array.isArray(S)&&S.includes(o)}function v(S,m){if(S.const)d(S.const,m);else if(S.enum)for(let b of S.enum)d(b,m);else throw new Error(`discriminator: "properties/${o}" must have "const" or "enum"`)}function d(S,m){if(typeof S!="string"||S in g)throw new Error(`discriminator: "${o}" values must be unique strings`);g[S]=m;}}}};eh.default=YD;});var py=E((kk,ZD)=>{ZD.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:true,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:true,readOnly:{type:"boolean",default:false},examples:{type:"array",items:true},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:true},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:true,enum:{type:"array",items:true,minItems:1,uniqueItems:true},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:true}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:true};});var gy=E((pe,nh)=>{Object.defineProperty(pe,"__esModule",{value:true});pe.MissingRefError=pe.ValidationError=pe.CodeGen=pe.Name=pe.nil=pe.stringify=pe.str=pe._=pe.KeywordCxt=pe.Ajv=void 0;var QD=oc(),eA=cy(),tA=th(),my=py(),nA=["/properties"],da="http://json-schema.org/draft-07/schema",Sr=class extends QD.default{_addVocabularies(){super._addVocabularies(),eA.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(tA.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(my,nA):my;this.addMetaSchema(e,da,false),this.refs["http://json-schema.org/schema"]=da;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(da)?da:void 0)}};pe.Ajv=Sr;nh.exports=pe=Sr;nh.exports.Ajv=Sr;Object.defineProperty(pe,"__esModule",{value:true});pe.default=Sr;var rA=pr();Object.defineProperty(pe,"KeywordCxt",{enumerable:true,get:function(){return rA.KeywordCxt}});var Er=$();Object.defineProperty(pe,"_",{enumerable:true,get:function(){return Er._}});Object.defineProperty(pe,"str",{enumerable:true,get:function(){return Er.str}});Object.defineProperty(pe,"stringify",{enumerable:true,get:function(){return Er.stringify}});Object.defineProperty(pe,"nil",{enumerable:true,get:function(){return Er.nil}});Object.defineProperty(pe,"Name",{enumerable:true,get:function(){return Er.Name}});Object.defineProperty(pe,"CodeGen",{enumerable:true,get:function(){return Er.CodeGen}});var iA=vi();Object.defineProperty(pe,"ValidationError",{enumerable:true,get:function(){return iA.default}});var sA=mr();Object.defineProperty(pe,"MissingRefError",{enumerable:true,get:function(){return sA.default}});});var ih=E(ki=>{Object.defineProperty(ki,"__esModule",{value:true});ki.dynamicAnchor=void 0;var rh=$(),aA=pt(),yy=Ci(),oA=Qs(),uA={keyword:"$dynamicAnchor",schemaType:"string",code:n=>vy(n,n.schema)};function vy(n,e){let{gen:t,it:r}=n;r.schemaEnv.root.dynamicAnchors[e]=true;let i=(0, rh._)`${aA.default.dynamicAnchors}${(0, rh.getProperty)(e)}`,a=r.errSchemaPath==="#"?r.validateName:lA(n);t.if((0, rh._)`!${i}`,()=>t.assign(i,a));}ki.dynamicAnchor=vy;function lA(n){let{schemaEnv:e,schema:t,self:r}=n.it,{root:i,baseId:a,localRefs:s,meta:o}=e.root,{schemaId:u}=r.opts,l=new yy.SchemaEnv({schema:t,schemaId:u,root:i,baseId:a,localRefs:s,meta:o});return yy.compileSchema.call(r,l),(0, oA.getValidate)(n,l)}ki.default=uA;});var sh=E(Vi=>{Object.defineProperty(Vi,"__esModule",{value:true});Vi.dynamicRef=void 0;var Cy=$(),cA=pt(),by=Qs(),hA={keyword:"$dynamicRef",schemaType:"string",code:n=>_y(n,n.schema)};function _y(n,e){let{gen:t,keyword:r,it:i}=n;if(e[0]!=="#")throw new Error(`"${r}" only supports hash fragment reference`);let a=e.slice(1);if(i.allErrors)s();else {let u=t.let("valid",false);s(u),n.ok(u);}function s(u){if(i.schemaEnv.root.dynamicAnchors[a]){let l=t.let("_v",(0, Cy._)`${cA.default.dynamicAnchors}${(0, Cy.getProperty)(a)}`);t.if(l,o(l,u),o(i.validateName,u));}else o(i.validateName,u)();}function o(u,l){return l?()=>t.block(()=>{(0, by.callRef)(n,u),t.let(l,true);}):()=>(0, by.callRef)(n,u)}}Vi.dynamicRef=_y;Vi.default=hA;});var Sy=E(ah=>{Object.defineProperty(ah,"__esModule",{value:true});var dA=ih(),fA=M(),pA={keyword:"$recursiveAnchor",schemaType:"boolean",code(n){n.schema?(0, dA.dynamicAnchor)(n,""):(0, fA.checkStrictMode)(n.it,"$recursiveAnchor: false is ignored");}};ah.default=pA;});var Ey=E(oh=>{Object.defineProperty(oh,"__esModule",{value:true});var mA=sh(),gA={keyword:"$recursiveRef",schemaType:"string",code:n=>(0, mA.dynamicRef)(n,n.schema)};oh.default=gA;});var wy=E(uh=>{Object.defineProperty(uh,"__esModule",{value:true});var yA=ih(),vA=sh(),CA=Sy(),bA=Ey(),_A=[yA.default,vA.default,CA.default,bA.default];uh.default=_A;});var Ay=E(lh=>{Object.defineProperty(lh,"__esModule",{value:true});var Dy=sa(),SA={keyword:"dependentRequired",type:"object",schemaType:"object",error:Dy.error,code:n=>(0, Dy.validatePropertyDeps)(n)};lh.default=SA;});var Py=E(ch=>{Object.defineProperty(ch,"__esModule",{value:true});var EA=sa(),wA={keyword:"dependentSchemas",type:"object",schemaType:"object",code:n=>(0, EA.validateSchemaDeps)(n)};ch.default=wA;});var Oy=E(hh=>{Object.defineProperty(hh,"__esModule",{value:true});var DA=M(),AA={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:n,parentSchema:e,it:t}){e.contains===void 0&&(0, DA.checkStrictMode)(t,`"${n}" without "contains" is ignored`);}};hh.default=AA;});var xy=E(dh=>{Object.defineProperty(dh,"__esModule",{value:true});var PA=Ay(),OA=Py(),xA=Oy(),TA=[PA.default,OA.default,xA.default];dh.default=TA;});var Ny=E(fh=>{Object.defineProperty(fh,"__esModule",{value:true});var yn=$(),Ty=M(),NA=pt(),FA={message:"must NOT have unevaluated properties",params:({params:n})=>(0, yn._)`{unevaluatedProperty: ${n.unevaluatedProperty}}`},IA={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:true,error:FA,code(n){let{gen:e,schema:t,data:r,errsCount:i,it:a}=n;if(!i)throw new Error("ajv implementation error");let{allErrors:s,props:o}=a;o instanceof yn.Name?e.if((0, yn._)`${o} !== true`,()=>e.forIn("key",r,h=>e.if(l(o,h),()=>u(h)))):o!==true&&e.forIn("key",r,h=>o===void 0?u(h):e.if(c(o,h),()=>u(h))),a.props=true,n.ok((0, yn._)`${i} === ${NA.default.errors}`);function u(h){if(t===false){n.setParams({unevaluatedProperty:h}),n.error(),s||e.break();return}if(!(0, Ty.alwaysValidSchema)(a,t)){let p=e.name("valid");n.subschema({keyword:"unevaluatedProperties",dataProp:h,dataPropType:Ty.Type.Str},p),s||e.if((0, yn.not)(p),()=>e.break());}}function l(h,p){return (0, yn._)`!${h} || !${h}[${p}]`}function c(h,p){let f=[];for(let g in h)h[g]===true&&f.push((0, yn._)`${p} !== ${g}`);return (0, yn.and)(...f)}}};fh.default=IA;});var Iy=E(ph=>{Object.defineProperty(ph,"__esModule",{value:true});var zn=$(),Fy=M(),kA={message:({params:{len:n}})=>(0, zn.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0, zn._)`{limit: ${n}}`},VA={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:kA,code(n){let{gen:e,schema:t,data:r,it:i}=n,a=i.items||0;if(a===true)return;let s=e.const("len",(0, zn._)`${r}.length`);if(t===false)n.setParams({len:a}),n.fail((0, zn._)`${s} > ${a}`);else if(typeof t=="object"&&!(0, Fy.alwaysValidSchema)(i,t)){let u=e.var("valid",(0, zn._)`${s} <= ${a}`);e.if((0, zn.not)(u),()=>o(u,a)),n.ok(u);}i.items=true;function o(u,l){e.forRange("i",l,s,c=>{n.subschema({keyword:"unevaluatedItems",dataProp:c,dataPropType:Fy.Type.Num},u),i.allErrors||e.if((0, zn.not)(u),()=>e.break());});}}};ph.default=VA;});var ky=E(mh=>{Object.defineProperty(mh,"__esModule",{value:true});var RA=Ny(),$A=Iy(),jA=[RA.default,$A.default];mh.default=jA;});var Ry=E(gh=>{Object.defineProperty(gh,"__esModule",{value:true});var LA=cc(),qA=Ac(),BA=Hc(),WA=wy(),MA=xy(),GA=ky(),zA=Xc(),Vy=Yc(),JA=[WA.default,LA.default,qA.default,(0, BA.default)(true),zA.default,Vy.metadataVocabulary,Vy.contentVocabulary,MA.default,GA.default];gh.default=JA;});var $y=E((Uk,HA)=>{HA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":true,"https://json-schema.org/draft/2020-12/vocab/applicator":true,"https://json-schema.org/draft/2020-12/vocab/unevaluated":true,"https://json-schema.org/draft/2020-12/vocab/validation":true,"https://json-schema.org/draft/2020-12/vocab/meta-data":true,"https://json-schema.org/draft/2020-12/vocab/format-annotation":true,"https://json-schema.org/draft/2020-12/vocab/content":true},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:true,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:true,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:true},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:true}}};});var jy=E((Kk,UA)=>{UA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":true},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}};});var Ly=E((Xk,KA)=>{KA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":true},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}};});var qy=E((Yk,XA)=>{XA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":true},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}};});var By=E((Zk,YA)=>{YA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":true},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}};});var Wy=E((Qk,ZA)=>{ZA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":true},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}};});var My=E((eV,QA)=>{QA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":true},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:true,deprecated:{type:"boolean",default:false},readOnly:{type:"boolean",default:false},writeOnly:{type:"boolean",default:false},examples:{type:"array",items:true}}};});var Gy=E((tV,eP)=>{eP.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":true},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:true}]},const:true,enum:{type:"array",items:true},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:true,default:[]}}};});var zy=E(yh=>{Object.defineProperty(yh,"__esModule",{value:true});var tP=$y(),nP=jy(),rP=Ly(),iP=qy(),sP=By(),aP=Wy(),oP=My(),uP=Gy(),lP=["/properties"];function cP(n){return [tP,nP,rP,iP,sP,e(this,aP),oP,e(this,uP)].forEach(t=>this.addMetaSchema(t,void 0,false)),this;function e(t,r){return n?t.$dataMetaSchema(r,lP):r}}yh.default=cP;});var Jy=E((me,Ch)=>{Object.defineProperty(me,"__esModule",{value:true});me.MissingRefError=me.ValidationError=me.CodeGen=me.Name=me.nil=me.stringify=me.str=me._=me.KeywordCxt=me.Ajv2020=void 0;var hP=oc(),dP=Ry(),fP=th(),pP=zy(),vh="https://json-schema.org/draft/2020-12/schema",wr=class extends hP.default{constructor(e={}){super({...e,dynamicRef:true,next:true,unevaluated:true});}_addVocabularies(){super._addVocabularies(),dP.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(fP.default);}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(pP.default.call(this,e),this.refs["http://json-schema.org/schema"]=vh);}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(vh)?vh:void 0)}};me.Ajv2020=wr;Ch.exports=me=wr;Ch.exports.Ajv2020=wr;Object.defineProperty(me,"__esModule",{value:true});me.default=wr;var mP=pr();Object.defineProperty(me,"KeywordCxt",{enumerable:true,get:function(){return mP.KeywordCxt}});var Dr=$();Object.defineProperty(me,"_",{enumerable:true,get:function(){return Dr._}});Object.defineProperty(me,"str",{enumerable:true,get:function(){return Dr.str}});Object.defineProperty(me,"stringify",{enumerable:true,get:function(){return Dr.stringify}});Object.defineProperty(me,"nil",{enumerable:true,get:function(){return Dr.nil}});Object.defineProperty(me,"Name",{enumerable:true,get:function(){return Dr.Name}});Object.defineProperty(me,"CodeGen",{enumerable:true,get:function(){return Dr.CodeGen}});var gP=vi();Object.defineProperty(me,"ValidationError",{enumerable:true,get:function(){return gP.default}});var yP=mr();Object.defineProperty(me,"MissingRefError",{enumerable:true,get:function(){return yP.default}});});var _h=E(fa=>{Object.defineProperty(fa,"__esModule",{value:true});fa.CompilerOptions=void 0;var bh=class{constructor(e=null,t=[],r=false,i=null,a=null){this.sourceFilename=e,this.pluginNames=t,this.countAllVisits=r,this.errorHandler=i,this.fileHandler=a;}};fa.CompilerOptions=bh;});var Hy=E(pa=>{Object.defineProperty(pa,"__esModule",{value:true});pa.DebugSourceRange=void 0;var Sh=class{constructor(e,t,r){this.length=e,this.debugMetadata=t,this.text=r;}};pa.DebugSourceRange=Sh;});var Ar=E(ma=>{Object.defineProperty(ma,"__esModule",{value:true});ma.ErrorType=void 0;var Uy;(function(n){n[n.Author=0]="Author",n[n.Warning=1]="Warning",n[n.Error=2]="Error";})(Uy||(ma.ErrorType=Uy={}));});var Ky=E(ga=>{Object.defineProperty(ga,"__esModule",{value:true});ga.Argument=void 0;var Eh=class{constructor(e=null,t=null,r=null){this.identifier=e,this.isByReference=t,this.isDivertTarget=r;}get typeName(){return "Argument"}};ga.Argument=Eh;});var ae=E(Pe=>{Object.defineProperty(Pe,"__esModule",{value:true});Pe.filterUndef=Pe.isEquatable=Pe.nullIfUndefined=Pe.asINamedContentOrNull=Pe.asBooleanOrThrows=Pe.asNumberOrThrows=Pe.asOrThrows=Pe.asOrNull=void 0;function vP(n,e){return n instanceof e?Xy(n):null}Pe.asOrNull=vP;function CP(n,e){if(n instanceof e)return Xy(n);throw new Error(`${n} is not of type ${e}`)}Pe.asOrThrows=CP;function bP(n){if(typeof n=="number")return n;throw new Error(`${n} is not a number`)}Pe.asNumberOrThrows=bP;function _P(n){if(typeof n=="boolean")return n;throw new Error(`${n} is not a boolean`)}Pe.asBooleanOrThrows=_P;function SP(n){return n.hasValidName&&n.name?n:null}Pe.asINamedContentOrNull=SP;function EP(n){return typeof n>"u"?null:n}Pe.nullIfUndefined=EP;function wP(n){return typeof n=="object"&&typeof n.Equals=="function"}Pe.isEquatable=wP;function Xy(n,e){return n}function DP(n){return n!=null}Pe.filterUndef=DP;});var ye=E(ya=>{Object.defineProperty(ya,"__esModule",{value:true});ya.ParsedObject=void 0;var Yy=ae(),wh=class{constructor(){this._alreadyHadError=false,this._alreadyHadWarning=false,this._debugMetadata=null,this._runtimeObject=null,this.content=[],this.parent=null,this.GetType=()=>this.typeName,this.AddContent=e=>{this.content===null&&(this.content=[]);let t=Array.isArray(e)?e:[e];for(let r of t)r.hasOwnProperty("parent")&&(r.parent=this),this.content.push(r);if(!Array.isArray(e))return e},this.InsertContent=(e,t)=>(this.content===null&&(this.content=[]),t.parent=this,this.content.splice(e,0,t),t),this.Find=e=>(t=null)=>{let r=(0, Yy.asOrNull)(this,e);if(r!==null&&(t===null||t(r)===true))return r;if(this.content===null)return null;for(let i of this.content){let a=i.Find&&i.Find(e)(t);if(a)return a}return null},this.FindAll=e=>(t,r)=>{let i=Array.isArray(r)?r:[],a=(0, Yy.asOrNull)(this,e);if(a!==null&&(!t||t(a)===true)&&i.push(a),this.content===null)return [];for(let s of this.content)s.FindAll&&s.FindAll(e)(t,i);return i},this.Warning=(e,t=null)=>{this.Error(e,t,true);};}get debugMetadata(){return this._debugMetadata===null&&this.parent?this.parent.debugMetadata:this._debugMetadata}set debugMetadata(e){this._debugMetadata=e;}get hasOwnDebugMetadata(){return !!this.debugMetadata}get typeName(){return "ParsedObject"}get story(){let e=this;for(;e.parent;)e=e.parent;return e}get runtimeObject(){return this._runtimeObject||(this._runtimeObject=this.GenerateRuntimeObject(),this._runtimeObject&&(this._runtimeObject.debugMetadata=this.debugMetadata)),this._runtimeObject}set runtimeObject(e){this._runtimeObject=e;}get runtimePath(){if(!this.runtimeObject.path)throw new Error;return this.runtimeObject.path}get containerForCounting(){return this.runtimeObject}get ancestry(){let e=[],t=this.parent;for(;t;)e.push(t),t=t.parent;return e=e.reverse(),e}ResolveReferences(e){if(this.content!==null)for(let t of this.content)t.ResolveReferences(e);}Error(e,t=null,r=false){if(t===null&&(t=this),!(t._alreadyHadError&&!r||t._alreadyHadWarning&&r)){if(this.parent)this.parent.Error(e,t,r);else throw new Error(`No parent object to send error to: ${e}`);r?t._alreadyHadWarning=true:t._alreadyHadError=true;}}};ya.ParsedObject=wh;});var Ca=E(va=>{Object.defineProperty(va,"__esModule",{value:true});va.AuthorWarning=void 0;var AP=ye(),Dh=class extends AP.ParsedObject{constructor(e){super(),this.warningMessage=e,this.GenerateRuntimeObject=()=>(this.Warning(this.warningMessage),null);}get typeName(){return "AuthorWarning"}};va.AuthorWarning=Dh;});var it=E(Ri=>{Object.defineProperty(Ri,"__esModule",{value:true});Ri.Path=void 0;var Pr=class n{constructor(){if(this._components=[],this._componentsString=null,this._isRelative=false,typeof arguments[0]=="string"){let e=arguments[0];this.componentsString=e;}else if(arguments[0]instanceof n.Component&&arguments[1]instanceof n){let e=arguments[0],t=arguments[1];this._components.push(e),this._components=this._components.concat(t._components);}else if(arguments[0]instanceof Array){let e=arguments[0],t=!!arguments[1];this._components=this._components.concat(e),this._isRelative=t;}}get isRelative(){return this._isRelative}get componentCount(){return this._components.length}get head(){return this._components.length>0?this._components[0]:null}get tail(){if(this._components.length>=2){let e=this._components.slice(1,this._components.length);return new n(e)}else return n.self}get length(){return this._components.length}get lastComponent(){let e=this._components.length-1;return e>=0?this._components[e]:null}get containsNamedComponent(){for(let e=0,t=this._components.length;e<t;e++)if(!this._components[e].isIndex)return true;return false}static get self(){let e=new n;return e._isRelative=true,e}GetComponent(e){return this._components[e]}PathByAppendingPath(e){let t=new n,r=0;for(let i=0;i<e._components.length&&e._components[i].isParent;++i)r++;for(let i=0;i<this._components.length-r;++i)t._components.push(this._components[i]);for(let i=r;i<e._components.length;++i)t._components.push(e._components[i]);return t}get componentsString(){return this._componentsString==null&&(this._componentsString=this._components.join("."),this.isRelative&&(this._componentsString="."+this._componentsString)),this._componentsString}set componentsString(e){if(this._components.length=0,this._componentsString=e,this._componentsString==null||this._componentsString=="")return;this._componentsString[0]=="."&&(this._isRelative=true,this._componentsString=this._componentsString.substring(1));let t=this._componentsString.split(".");for(let r of t)/^(\-|\+)?([0-9]+|Infinity)$/.test(r)?this._components.push(new n.Component(parseInt(r))):this._components.push(new n.Component(r));}toString(){return this.componentsString}Equals(e){if(e==null||e._components.length!=this._components.length||e.isRelative!=this.isRelative)return false;for(let t=0,r=e._components.length;t<r;t++)if(!e._components[t].Equals(this._components[t]))return false;return true}PathByAppendingComponent(e){let t=new n;return t._components.push(...this._components),t._components.push(e),t}};Ri.Path=Pr;Pr.parentId="^";(function(n){class e{constructor(r){this.index=-1,this.name=null,typeof r=="string"?this.name=r:this.index=r;}get isIndex(){return this.index>=0}get isParent(){return this.name==n.parentId}static ToParent(){return new e(n.parentId)}toString(){return this.isIndex?this.index.toString():this.name}Equals(r){return r!=null&&r.isIndex==this.isIndex?this.isIndex?this.index==r.index:this.name==r.name:false}}n.Component=e;})(Pr||(Ri.Path=Pr={}));});var $i=E(ba=>{Object.defineProperty(ba,"__esModule",{value:true});ba.Debug=void 0;var Zy;(function(n){function e(r,i,a){t(r instanceof i,a);}n.AssertType=e;function t(r,i){if(!r)throw typeof i<"u"&&console.warn(i),console.trace&&console.trace(),new Error("")}n.Assert=t;})(Zy||(ba.Debug=Zy={}));});var je=E(Or=>{Object.defineProperty(Or,"__esModule",{value:true});Or.throwNullException=Or.NullException=void 0;var _a=class extends Error{};Or.NullException=_a;function PP(n){throw new _a(`${n} is null or undefined`)}Or.throwNullException=PP;});var st=E(Ea=>{Object.defineProperty(Ea,"__esModule",{value:true});Ea.InkObject=void 0;var xr=it(),ji=Ee(),Ah=$i(),Tr=ae(),Sa=je(),Ph=class{constructor(){this.parent=null,this._debugMetadata=null,this._path=null;}get debugMetadata(){return this._debugMetadata===null&&this.parent?this.parent.debugMetadata:this._debugMetadata}set debugMetadata(e){this._debugMetadata=e;}get ownDebugMetadata(){return this._debugMetadata}DebugLineNumberOfPath(e){if(e===null)return null;let t=this.rootContentContainer;if(t){let r=t.ContentAtPath(e).obj;if(r){let i=r.debugMetadata;if(i!==null)return i.startLineNumber}}return null}get path(){if(this._path==null)if(this.parent==null)this._path=new xr.Path;else {let e=[],t=this,r=(0, Tr.asOrNull)(t.parent,ji.Container);for(;r!==null;){let i=(0, Tr.asINamedContentOrNull)(t);if(i!=null&&i.hasValidName){if(i.name===null)return (0, Sa.throwNullException)("namedChild.name");e.unshift(new xr.Path.Component(i.name));}else e.unshift(new xr.Path.Component(r.content.indexOf(t)));t=r,r=(0, Tr.asOrNull)(r.parent,ji.Container);}this._path=new xr.Path(e);}return this._path}ResolvePath(e){if(e===null)return (0, Sa.throwNullException)("path");if(e.isRelative){let t=(0, Tr.asOrNull)(this,ji.Container);return t===null&&(Ah.Debug.Assert(this.parent!==null,"Can't resolve relative path because we don't have a parent"),t=(0, Tr.asOrNull)(this.parent,ji.Container),Ah.Debug.Assert(t!==null,"Expected parent to be a container"),Ah.Debug.Assert(e.GetComponent(0).isParent),e=e.tail),t===null?(0, Sa.throwNullException)("nearestContainer"):t.ContentAtPath(e)}else {let t=this.rootContentContainer;return t===null?(0, Sa.throwNullException)("contentContainer"):t.ContentAtPath(e)}}ConvertPathToRelative(e){let t=this.path,r=Math.min(e.length,t.length),i=-1;for(let u=0;u<r;++u){let l=t.GetComponent(u),c=e.GetComponent(u);if(l.Equals(c))i=u;else break}if(i==-1)return e;let a=t.componentCount-1-i,s=[];for(let u=0;u<a;++u)s.push(xr.Path.Component.ToParent());for(let u=i+1;u<e.componentCount;++u)s.push(e.GetComponent(u));return new xr.Path(s,true)}CompactPathString(e){let t=null,r=null;return e.isRelative?(r=e.componentsString,t=this.path.PathByAppendingPath(e).componentsString):(r=this.ConvertPathToRelative(e).componentsString,t=e.componentsString),r.length<t.length?r:t}get rootContentContainer(){let e=this;for(;e.parent;)e=e.parent;return (0, Tr.asOrNull)(e,ji.Container)}Copy(){throw Error("Not Implemented: Doesn't support copying")}SetChild(e,t,r){e[t]&&(e[t]=null),e[t]=r,e[t]&&(e[t].parent=this);}Equals(e){return e===this}};Ea.InkObject=Ph;});var Jn=E(wa=>{Object.defineProperty(wa,"__esModule",{value:true});wa.StringBuilder=void 0;var Oh=class{constructor(e){e=typeof e<"u"?e.toString():"",this.string=e;}get Length(){return this.string.length}Append(e){e!==null&&(this.string+=e);}AppendLine(e){typeof e<"u"&&this.Append(e),this.string+=`
|
|
9
|
-
`;}AppendFormat(e,...t){this.string+=e.replace(/{(\d+)}/g,(r,i)=>typeof t[i]<"u"?t[i]:r);}toString(){return this.string}Clear(){this.string="";}};wa.StringBuilder=Oh;});var ot=E(Nr=>{Object.defineProperty(Nr,"__esModule",{value:true});Nr.InkList=Nr.InkListItem=void 0;var jt=je(),OP=Jn(),at=class n{constructor(){if(this.originName=null,this.itemName=null,typeof arguments[1]<"u"){let e=arguments[0],t=arguments[1];this.originName=e,this.itemName=t;}else if(arguments[0]){let t=arguments[0].toString().split(".");this.originName=t[0],this.itemName=t[1];}}static get Null(){return new n(null,null)}get isNull(){return this.originName==null&&this.itemName==null}get fullName(){return (this.originName!==null?this.originName:"?")+"."+this.itemName}toString(){return this.fullName}Equals(e){if(e instanceof n){let t=e;return t.itemName==this.itemName&&t.originName==this.originName}return false}copy(){return new n(this.originName,this.itemName)}serialized(){return JSON.stringify({originName:this.originName,itemName:this.itemName})}static fromSerializedKey(e){let t=JSON.parse(e);if(!n.isLikeInkListItem(t))return n.Null;let r=t;return new n(r.originName,r.itemName)}static isLikeInkListItem(e){return !(typeof e!="object"||!e.hasOwnProperty("originName")||!e.hasOwnProperty("itemName")||typeof e.originName!="string"&&typeof e.originName!==null||typeof e.itemName!="string"&&typeof e.itemName!==null)}};Nr.InkListItem=at;var xh=class n extends Map{constructor(){if(super(arguments[0]instanceof n?arguments[0]:[]),this.origins=null,this._originNames=[],arguments[0]instanceof n){let e=arguments[0],t=e.originNames;t!==null&&(this._originNames=t.slice()),e.origins!==null&&(this.origins=e.origins.slice());}else if(typeof arguments[0]=="string"){let e=arguments[0],t=arguments[1];if(this.SetInitialOriginName(e),t.listDefinitions===null)return (0, jt.throwNullException)("originStory.listDefinitions");let r=t.listDefinitions.TryListGetDefinition(e,null);if(r.exists){if(r.result===null)return (0, jt.throwNullException)("def.result");this.origins=[r.result];}else throw new Error("InkList origin could not be found in story when constructing new list: "+e)}else if(typeof arguments[0]=="object"&&arguments[0].hasOwnProperty("Key")&&arguments[0].hasOwnProperty("Value")){let e=arguments[0];this.Add(e.Key,e.Value);}}static FromString(e,t){var r;if(e==null||e=="")return new n;let i=(r=t.listDefinitions)===null||r===void 0?void 0:r.FindSingleItemListWithName(e);if(i)return i.value===null?(0, jt.throwNullException)("listValue.value"):new n(i.value);throw new Error("Could not find the InkListItem from the string '"+e+"' to create an InkList because it doesn't exist in the original list definition in ink.")}AddItem(e,t=null){if(e instanceof at){let r=e;if(r.originName==null){this.AddItem(r.itemName);return}if(this.origins===null)return (0, jt.throwNullException)("this.origins");for(let i of this.origins)if(i.name==r.originName){let a=i.TryGetValueForItem(r,0);if(a.exists){this.Add(r,a.result);return}else throw new Error("Could not add the item "+r+" to this list because it doesn't exist in the original list definition in ink.")}throw new Error("Failed to add item to list because the item was from a new list definition that wasn't previously known to this list. Only items from previously known lists can be used, so that the int value can be found.")}else if(e!==null){let r=e,i=null;if(this.origins===null)return (0, jt.throwNullException)("this.origins");for(let a of this.origins){if(r===null)return (0, jt.throwNullException)("itemName");if(a.ContainsItemWithName(r)){if(i!=null)throw new Error("Could not add the item "+r+" to this list because it could come from either "+a.name+" or "+i.name);i=a;}}if(i==null){if(t==null)throw new Error("Could not add the item "+r+" to this list because it isn't known to any list definitions previously associated with this list.");{let a=n.FromString(r,t).orderedItems[0];this.Add(a.Key,a.Value);}}else {let a=new at(i.name,r),s=i.ValueForItem(a);this.Add(a,s);}}}ContainsItemNamed(e){for(let[t]of this)if(at.fromSerializedKey(t).itemName==e)return true;return false}ContainsKey(e){return this.has(e.serialized())}Add(e,t){let r=e.serialized();if(this.has(r))throw new Error(`The Map already contains an entry for ${e}`);this.set(r,t);}Remove(e){return this.delete(e.serialized())}get Count(){return this.size}get originOfMaxItem(){if(this.origins==null)return null;let e=this.maxItem.Key.originName,t=null;return this.origins.every(r=>r.name==e?(t=r,false):true),t}get originNames(){if(this.Count>0){this._originNames==null&&this.Count>0?this._originNames=[]:(this._originNames||(this._originNames=[]),this._originNames.length=0);for(let[e]of this){let t=at.fromSerializedKey(e);if(t.originName===null)return (0, jt.throwNullException)("item.originName");this._originNames.push(t.originName);}}return this._originNames}SetInitialOriginName(e){this._originNames=[e];}SetInitialOriginNames(e){e==null?this._originNames=null:this._originNames=e.slice();}get maxItem(){let e={Key:at.Null,Value:0};for(let[t,r]of this){let i=at.fromSerializedKey(t);(e.Key.isNull||r>e.Value)&&(e={Key:i,Value:r});}return e}get minItem(){let e={Key:at.Null,Value:0};for(let[t,r]of this){let i=at.fromSerializedKey(t);(e.Key.isNull||r<e.Value)&&(e={Key:i,Value:r});}return e}get inverse(){let e=new n;if(this.origins!=null)for(let t of this.origins)for(let[r,i]of t.items){let a=at.fromSerializedKey(r);this.ContainsKey(a)||e.Add(a,i);}return e}get all(){let e=new n;if(this.origins!=null)for(let t of this.origins)for(let[r,i]of t.items){let a=at.fromSerializedKey(r);e.set(a.serialized(),i);}return e}Union(e){let t=new n(this);for(let[r,i]of e)t.set(r,i);return t}Intersect(e){let t=new n;for(let[r,i]of this)e.has(r)&&t.set(r,i);return t}HasIntersection(e){for(let[t]of this)if(e.has(t))return true;return false}Without(e){let t=new n(this);for(let[r]of e)t.delete(r);return t}Contains(e){if(typeof e=="string")return this.ContainsItemNamed(e);let t=e;if(t.size==0||this.size==0)return false;for(let[r]of t)if(!this.has(r))return false;return true}GreaterThan(e){return this.Count==0?false:e.Count==0?true:this.minItem.Value>e.maxItem.Value}GreaterThanOrEquals(e){return this.Count==0?false:e.Count==0?true:this.minItem.Value>=e.minItem.Value&&this.maxItem.Value>=e.maxItem.Value}LessThan(e){return e.Count==0?false:this.Count==0?true:this.maxItem.Value<e.minItem.Value}LessThanOrEquals(e){return e.Count==0?false:this.Count==0?true:this.maxItem.Value<=e.maxItem.Value&&this.minItem.Value<=e.minItem.Value}MaxAsList(){return this.Count>0?new n(this.maxItem):new n}MinAsList(){return this.Count>0?new n(this.minItem):new n}ListWithSubRange(e,t){if(this.Count==0)return new n;let r=this.orderedItems,i=0,a=Number.MAX_SAFE_INTEGER;Number.isInteger(e)?i=e:e instanceof n&&e.Count>0&&(i=e.minItem.Value),Number.isInteger(t)?a=t:t instanceof n&&t.Count>0&&(a=t.maxItem.Value);let s=new n;s.SetInitialOriginNames(this.originNames);for(let o of r)o.Value>=i&&o.Value<=a&&s.Add(o.Key,o.Value);return s}Equals(e){if(!(e instanceof n)||e.Count!=this.Count)return false;for(let[t]of this)if(!e.has(t))return false;return true}get orderedItems(){let e=new Array;for(let[t,r]of this){let i=at.fromSerializedKey(t);e.push({Key:i,Value:r});}return e.sort((t,r)=>t.Key.originName===null?(0, jt.throwNullException)("x.Key.originName"):r.Key.originName===null?(0, jt.throwNullException)("y.Key.originName"):t.Value==r.Value?t.Key.originName.localeCompare(r.Key.originName):t.Value<r.Value?-1:t.Value>r.Value?1:0),e}get singleItem(){for(let e of this.orderedItems)return e.Key;return null}toString(){let e=this.orderedItems,t=new OP.StringBuilder;for(let r=0;r<e.length;r++){r>0&&t.Append(", ");let i=e[r].Key;if(i.itemName===null)return (0, jt.throwNullException)("item.itemName");t.Append(i.itemName);}return t.toString()}valueOf(){return NaN}};Nr.InkList=xh;});var Li=E(Da=>{Object.defineProperty(Da,"__esModule",{value:true});Da.StoryException=void 0;var Th=class extends Error{constructor(e){super(e),this.useEndLineNumber=false,this.message=e,this.name="StoryException";}};Da.StoryException=Th;});var Fr=E(vn=>{Object.defineProperty(vn,"__esModule",{value:true});vn.tryParseFloat=vn.tryParseInt=vn.tryGetValueFromMap=void 0;function xP(n,e,t){if(n===null)return {result:t,exists:false};let r=n.get(e);return typeof r>"u"?{result:t,exists:false}:{result:r,exists:true}}vn.tryGetValueFromMap=xP;function TP(n,e=0){let t=parseInt(n);return Number.isNaN(t)?{result:e,exists:false}:{result:t,exists:true}}vn.tryParseInt=TP;function NP(n,e=0){let t=parseFloat(n);return Number.isNaN(t)?{result:e,exists:false}:{result:t,exists:true}}vn.tryParseFloat=NP;});var ve=E(Ce=>{Object.defineProperty(Ce,"__esModule",{value:true});Ce.ValueType=Ce.ListValue=Ce.VariablePointerValue=Ce.DivertTargetValue=Ce.StringValue=Ce.FloatValue=Ce.IntValue=Ce.BoolValue=Ce.Value=Ce.AbstractValue=void 0;var Qy=st(),ev=it(),Hn=ot(),FP=Li(),qi=ae(),tv=Fr(),vt=je(),Aa=class n extends Qy.InkObject{static Create(e,t){if(t){if(t===ge.Int&&Number.isInteger(Number(e)))return new qt(Number(e));if(t===ge.Float&&!isNaN(e))return new Bt(Number(e))}if(typeof e=="boolean")return new Ir(!!e);if(typeof e=="string")return new tn(String(e));if(Number.isInteger(Number(e)))return new qt(Number(e));if(isNaN(e)){if(e instanceof ev.Path)return new Pa((0, qi.asOrThrows)(e,ev.Path));if(e instanceof Hn.InkList)return new Oa((0, qi.asOrThrows)(e,Hn.InkList))}else return new Bt(Number(e));return null}Copy(){return (0, qi.asOrThrows)(n.Create(this.valueObject),Qy.InkObject)}BadCastException(e){return new FP.StoryException("Can't cast "+this.valueObject+" from "+this.valueType+" to "+e)}};Ce.AbstractValue=Aa;var Lt=class extends Aa{constructor(e){super(),this.value=e;}get valueObject(){return this.value}toString(){return this.value===null?(0, vt.throwNullException)("Value.value"):this.value.toString()}};Ce.Value=Lt;var Ir=class extends Lt{constructor(e){super(e||false);}get isTruthy(){return !!this.value}get valueType(){return ge.Bool}Cast(e){if(this.value===null)return (0, vt.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==ge.Int)return new qt(this.value?1:0);if(e==ge.Float)return new Bt(this.value?1:0);if(e==ge.String)return new tn(this.value?"true":"false");throw this.BadCastException(e)}toString(){return this.value?"true":"false"}};Ce.BoolValue=Ir;var qt=class extends Lt{constructor(e){super(e||0);}get isTruthy(){return this.value!=0}get valueType(){return ge.Int}Cast(e){if(this.value===null)return (0, vt.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==ge.Bool)return new Ir(this.value!==0);if(e==ge.Float)return new Bt(this.value);if(e==ge.String)return new tn(""+this.value);throw this.BadCastException(e)}};Ce.IntValue=qt;var Bt=class extends Lt{constructor(e){super(e||0);}get isTruthy(){return this.value!=0}get valueType(){return ge.Float}Cast(e){if(this.value===null)return (0, vt.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==ge.Bool)return new Ir(this.value!==0);if(e==ge.Int)return new qt(this.value);if(e==ge.String)return new tn(""+this.value);throw this.BadCastException(e)}};Ce.FloatValue=Bt;var tn=class extends Lt{constructor(e){if(super(e||""),this._isNewline=this.value==`
|
|
10
|
-
`,this._isInlineWhitespace=true,this.value===null)return (0,
|
|
11
|
-
`,"\\n")),e.Append('"')):e.Append(o.toString())),s!=this.content.length-1&&e.Append(","),!(o instanceof n)&&o==r&&e.Append(" <---"),e.AppendLine();}let a=new Map;for(let[s,o]of this.namedContent)this.content.indexOf((0, Cn.asOrThrows)(o,kr.InkObject))>=0||a.set(s,o);if(a.size>0){i(),e.AppendLine("-- named: --");for(let[,s]of a)sv.Debug.AssertType(s,n,"Can only print out named Containers"),s.BuildStringOfHierarchy(e,t,r),e.AppendLine();}t--,i(),e.Append("]");}};Wi.Container=Bi;(function(n){(function(t){t[t.Start=0]="Start",t[t.Visits=1]="Visits",t[t.Turns=2]="Turns",t[t.CountStartOnly=4]="CountStartOnly";})(n.CountFlags||(n.CountFlags={}));})(Bi||(Wi.Container=Bi={}));});var Le=E(Gi=>{Object.defineProperty(Gi,"__esModule",{value:true});Gi.ControlCommand=void 0;var jP=st(),Mi=class n extends jP.InkObject{get commandType(){return this._commandType}constructor(e=n.CommandType.NotSet){super(),this._commandType=e;}Copy(){return new n(this.commandType)}static EvalStart(){return new n(n.CommandType.EvalStart)}static EvalOutput(){return new n(n.CommandType.EvalOutput)}static EvalEnd(){return new n(n.CommandType.EvalEnd)}static Duplicate(){return new n(n.CommandType.Duplicate)}static PopEvaluatedValue(){return new n(n.CommandType.PopEvaluatedValue)}static PopFunction(){return new n(n.CommandType.PopFunction)}static PopTunnel(){return new n(n.CommandType.PopTunnel)}static BeginString(){return new n(n.CommandType.BeginString)}static EndString(){return new n(n.CommandType.EndString)}static NoOp(){return new n(n.CommandType.NoOp)}static ChoiceCount(){return new n(n.CommandType.ChoiceCount)}static Turns(){return new n(n.CommandType.Turns)}static TurnsSince(){return new n(n.CommandType.TurnsSince)}static ReadCount(){return new n(n.CommandType.ReadCount)}static Random(){return new n(n.CommandType.Random)}static SeedRandom(){return new n(n.CommandType.SeedRandom)}static VisitIndex(){return new n(n.CommandType.VisitIndex)}static SequenceShuffleIndex(){return new n(n.CommandType.SequenceShuffleIndex)}static StartThread(){return new n(n.CommandType.StartThread)}static Done(){return new n(n.CommandType.Done)}static End(){return new n(n.CommandType.End)}static ListFromInt(){return new n(n.CommandType.ListFromInt)}static ListRange(){return new n(n.CommandType.ListRange)}static ListRandom(){return new n(n.CommandType.ListRandom)}static BeginTag(){return new n(n.CommandType.BeginTag)}static EndTag(){return new n(n.CommandType.EndTag)}toString(){return "ControlCommand "+this.commandType.toString()}};Gi.ControlCommand=Mi;(function(n){(function(t){t[t.NotSet=-1]="NotSet",t[t.EvalStart=0]="EvalStart",t[t.EvalOutput=1]="EvalOutput",t[t.EvalEnd=2]="EvalEnd",t[t.Duplicate=3]="Duplicate",t[t.PopEvaluatedValue=4]="PopEvaluatedValue",t[t.PopFunction=5]="PopFunction",t[t.PopTunnel=6]="PopTunnel",t[t.BeginString=7]="BeginString",t[t.EndString=8]="EndString",t[t.NoOp=9]="NoOp",t[t.ChoiceCount=10]="ChoiceCount",t[t.Turns=11]="Turns",t[t.TurnsSince=12]="TurnsSince",t[t.ReadCount=13]="ReadCount",t[t.Random=14]="Random",t[t.SeedRandom=15]="SeedRandom",t[t.VisitIndex=16]="VisitIndex",t[t.SequenceShuffleIndex=17]="SequenceShuffleIndex",t[t.StartThread=18]="StartThread",t[t.Done=19]="Done",t[t.End=20]="End",t[t.ListFromInt=21]="ListFromInt",t[t.ListRange=22]="ListRange",t[t.ListRandom=23]="ListRandom",t[t.BeginTag=24]="BeginTag",t[t.EndTag=25]="EndTag",t[t.TOTAL_VALUES=26]="TOTAL_VALUES";})(n.CommandType||(n.CommandType={}));})(Mi||(Gi.ControlCommand=Mi={}));});var Ct=E(Ta=>{Object.defineProperty(Ta,"__esModule",{value:true});Ta.Expression=void 0;var av=Ee(),Ih=Le(),LP=ye(),kh=class extends LP.ParsedObject{constructor(){super(...arguments),this._prototypeRuntimeConstantExpression=null,this.outputWhenComplete=false,this.GenerateRuntimeObject=()=>{let e=new av.Container;return e.AddContent(Ih.ControlCommand.EvalStart()),this.GenerateIntoContainer(e),this.outputWhenComplete&&e.AddContent(Ih.ControlCommand.EvalOutput()),e.AddContent(Ih.ControlCommand.EvalEnd()),e},this.GenerateConstantIntoContainer=e=>{this._prototypeRuntimeConstantExpression===null&&(this._prototypeRuntimeConstantExpression=new av.Container,this.GenerateIntoContainer(this._prototypeRuntimeConstantExpression));for(let t of this._prototypeRuntimeConstantExpression.content){let r=t.Copy();r&&e.AddContent(r);}},this.toString=()=>"No string value in JavaScript.";}get typeName(){return "Expression"}Equals(e){return false}};Ta.Expression=kh;});var Un=E(Na=>{Object.defineProperty(Na,"__esModule",{value:true});Na.Void=void 0;var qP=st(),Vh=class extends qP.InkObject{toString(){return "Void"}};Na.Void=Vh;});var Wt=E(Ia=>{Object.defineProperty(Ia,"__esModule",{value:true});Ia.NativeFunctionCall=void 0;var F=ve(),zi=Li(),BP=Un(),Fa=ot(),WP=st(),bt=ae(),ut=je(),U=class n extends WP.InkObject{static CallWithName(e){return new n(e)}static CallExistsWithName(e){return this.GenerateNativeFunctionsIfNecessary(),this._nativeFunctions.get(e)}get name(){return this._name===null?(0, ut.throwNullException)("NativeFunctionCall._name"):this._name}set name(e){this._name=e,this._isPrototype||(n._nativeFunctions===null?(0, ut.throwNullException)("NativeFunctionCall._nativeFunctions"):this._prototype=n._nativeFunctions.get(this._name)||null);}get numberOfParameters(){return this._prototype?this._prototype.numberOfParameters:this._numberOfParameters}set numberOfParameters(e){this._numberOfParameters=e;}Call(e){if(this._prototype)return this._prototype.Call(e);if(this.numberOfParameters!=e.length)throw new Error("Unexpected number of parameters");let t=false;for(let a of e){if(a instanceof BP.Void)throw new zi.StoryException("Attempting to perform "+this.name+' on a void value. Did you forget to "return" a value from a function you called here?');a instanceof F.ListValue&&(t=true);}if(e.length==2&&t)return this.CallBinaryListOperation(e);let r=this.CoerceValuesToSingleType(e),i=r[0].valueType;return i==F.ValueType.Int?this.CallType(r):i==F.ValueType.Float?this.CallType(r):i==F.ValueType.String?this.CallType(r):i==F.ValueType.DivertTarget?this.CallType(r):i==F.ValueType.List?this.CallType(r):null}CallType(e){let t=(0, bt.asOrThrows)(e[0],F.Value),r=t.valueType,i=t,a=e.length;if(a==2||a==1){if(this._operationFuncs===null)return (0, ut.throwNullException)("NativeFunctionCall._operationFuncs");let s=this._operationFuncs.get(r);if(!s){let o=F.ValueType[r];throw new zi.StoryException("Cannot perform operation "+this.name+" on "+o)}if(a==2){let u=(0, bt.asOrThrows)(e[1],F.Value),l=s;if(i.value===null||u.value===null)return (0, ut.throwNullException)("NativeFunctionCall.Call BinaryOp values");let c=l(i.value,u.value);return F.Value.Create(c)}else {let o=s;if(i.value===null)return (0, ut.throwNullException)("NativeFunctionCall.Call UnaryOp value");let u=o(i.value);return this.name===n.Int?F.Value.Create(u,F.ValueType.Int):this.name===n.Float?F.Value.Create(u,F.ValueType.Float):F.Value.Create(u,t.valueType)}}else throw new Error("Unexpected number of parameters to NativeFunctionCall: "+e.length)}CallBinaryListOperation(e){if((this.name=="+"||this.name=="-")&&e[0]instanceof F.ListValue&&e[1]instanceof F.IntValue)return this.CallListIncrementOperation(e);let t=(0, bt.asOrThrows)(e[0],F.Value),r=(0, bt.asOrThrows)(e[1],F.Value);if((this.name=="&&"||this.name=="||")&&(t.valueType!=F.ValueType.List||r.valueType!=F.ValueType.List)){if(this._operationFuncs===null)return (0, ut.throwNullException)("NativeFunctionCall._operationFuncs");let i=this._operationFuncs.get(F.ValueType.Int);if(i===null)return (0, ut.throwNullException)("NativeFunctionCall.CallBinaryListOperation op");let a=(0, bt.asBooleanOrThrows)(i(t.isTruthy?1:0,r.isTruthy?1:0));return new F.BoolValue(a)}if(t.valueType==F.ValueType.List&&r.valueType==F.ValueType.List)return this.CallType([t,r]);throw new zi.StoryException("Can not call use "+this.name+" operation on "+F.ValueType[t.valueType]+" and "+F.ValueType[r.valueType])}CallListIncrementOperation(e){let t=(0, bt.asOrThrows)(e[0],F.ListValue),r=(0, bt.asOrThrows)(e[1],F.IntValue),i=new Fa.InkList;if(t.value===null)return (0, ut.throwNullException)("NativeFunctionCall.CallListIncrementOperation listVal.value");for(let[a,s]of t.value){let o=Fa.InkListItem.fromSerializedKey(a);if(this._operationFuncs===null)return (0, ut.throwNullException)("NativeFunctionCall._operationFuncs");let u=this._operationFuncs.get(F.ValueType.Int);if(r.value===null)return (0, ut.throwNullException)("NativeFunctionCall.CallListIncrementOperation intVal.value");let l=u(s,r.value),c=null;if(t.value.origins===null)return (0, ut.throwNullException)("NativeFunctionCall.CallListIncrementOperation listVal.value.origins");for(let h of t.value.origins)if(h.name==o.originName){c=h;break}if(c!=null){let h=c.TryGetItemWithValue(l,Fa.InkListItem.Null);h.exists&&i.Add(h.result,l);}}return new F.ListValue(i)}CoerceValuesToSingleType(e){let t=F.ValueType.Int,r=null;for(let a of e){let s=(0, bt.asOrThrows)(a,F.Value);s.valueType>t&&(t=s.valueType),s.valueType==F.ValueType.List&&(r=(0, bt.asOrNull)(s,F.ListValue));}let i=[];if(F.ValueType[t]==F.ValueType[F.ValueType.List])for(let a of e){let s=(0, bt.asOrThrows)(a,F.Value);if(s.valueType==F.ValueType.List)i.push(s);else if(s.valueType==F.ValueType.Int){let o=parseInt(s.valueObject);if(r=(0, bt.asOrThrows)(r,F.ListValue),r.value===null)return (0, ut.throwNullException)("NativeFunctionCall.CoerceValuesToSingleType specialCaseList.value");let u=r.value.originOfMaxItem;if(u===null)return (0, ut.throwNullException)("NativeFunctionCall.CoerceValuesToSingleType list");let l=u.TryGetItemWithValue(o,Fa.InkListItem.Null);if(l.exists){let c=new F.ListValue(l.result,o);i.push(c);}else throw new zi.StoryException("Could not find List item with the value "+o+" in "+u.name)}else {let o=F.ValueType[s.valueType];throw new zi.StoryException("Cannot mix Lists and "+o+" values in this operation")}}else for(let a of e){let o=(0, bt.asOrThrows)(a,F.Value).Cast(t);i.push(o);}return i}constructor(){if(super(),this._name=null,this._numberOfParameters=0,this._prototype=null,this._isPrototype=false,this._operationFuncs=null,arguments.length===0)n.GenerateNativeFunctionsIfNecessary();else if(arguments.length===1){let e=arguments[0];n.GenerateNativeFunctionsIfNecessary(),this.name=e;}else if(arguments.length===2){let e=arguments[0],t=arguments[1];this._isPrototype=true,this.name=e,this.numberOfParameters=t;}}static Identity(e){return e}static GenerateNativeFunctionsIfNecessary(){if(this._nativeFunctions==null){this._nativeFunctions=new Map,this.AddIntBinaryOp(this.Add,(r,i)=>r+i),this.AddIntBinaryOp(this.Subtract,(r,i)=>r-i),this.AddIntBinaryOp(this.Multiply,(r,i)=>r*i),this.AddIntBinaryOp(this.Divide,(r,i)=>Math.floor(r/i)),this.AddIntBinaryOp(this.Mod,(r,i)=>r%i),this.AddIntUnaryOp(this.Negate,r=>-r),this.AddIntBinaryOp(this.Equal,(r,i)=>r==i),this.AddIntBinaryOp(this.Greater,(r,i)=>r>i),this.AddIntBinaryOp(this.Less,(r,i)=>r<i),this.AddIntBinaryOp(this.GreaterThanOrEquals,(r,i)=>r>=i),this.AddIntBinaryOp(this.LessThanOrEquals,(r,i)=>r<=i),this.AddIntBinaryOp(this.NotEquals,(r,i)=>r!=i),this.AddIntUnaryOp(this.Not,r=>r==0),this.AddIntBinaryOp(this.And,(r,i)=>r!=0&&i!=0),this.AddIntBinaryOp(this.Or,(r,i)=>r!=0||i!=0),this.AddIntBinaryOp(this.Max,(r,i)=>Math.max(r,i)),this.AddIntBinaryOp(this.Min,(r,i)=>Math.min(r,i)),this.AddIntBinaryOp(this.Pow,(r,i)=>Math.pow(r,i)),this.AddIntUnaryOp(this.Floor,n.Identity),this.AddIntUnaryOp(this.Ceiling,n.Identity),this.AddIntUnaryOp(this.Int,n.Identity),this.AddIntUnaryOp(this.Float,r=>r),this.AddFloatBinaryOp(this.Add,(r,i)=>r+i),this.AddFloatBinaryOp(this.Subtract,(r,i)=>r-i),this.AddFloatBinaryOp(this.Multiply,(r,i)=>r*i),this.AddFloatBinaryOp(this.Divide,(r,i)=>r/i),this.AddFloatBinaryOp(this.Mod,(r,i)=>r%i),this.AddFloatUnaryOp(this.Negate,r=>-r),this.AddFloatBinaryOp(this.Equal,(r,i)=>r==i),this.AddFloatBinaryOp(this.Greater,(r,i)=>r>i),this.AddFloatBinaryOp(this.Less,(r,i)=>r<i),this.AddFloatBinaryOp(this.GreaterThanOrEquals,(r,i)=>r>=i),this.AddFloatBinaryOp(this.LessThanOrEquals,(r,i)=>r<=i),this.AddFloatBinaryOp(this.NotEquals,(r,i)=>r!=i),this.AddFloatUnaryOp(this.Not,r=>r==0),this.AddFloatBinaryOp(this.And,(r,i)=>r!=0&&i!=0),this.AddFloatBinaryOp(this.Or,(r,i)=>r!=0||i!=0),this.AddFloatBinaryOp(this.Max,(r,i)=>Math.max(r,i)),this.AddFloatBinaryOp(this.Min,(r,i)=>Math.min(r,i)),this.AddFloatBinaryOp(this.Pow,(r,i)=>Math.pow(r,i)),this.AddFloatUnaryOp(this.Floor,r=>Math.floor(r)),this.AddFloatUnaryOp(this.Ceiling,r=>Math.ceil(r)),this.AddFloatUnaryOp(this.Int,r=>Math.floor(r)),this.AddFloatUnaryOp(this.Float,n.Identity),this.AddStringBinaryOp(this.Add,(r,i)=>r+i),this.AddStringBinaryOp(this.Equal,(r,i)=>r===i),this.AddStringBinaryOp(this.NotEquals,(r,i)=>r!==i),this.AddStringBinaryOp(this.Has,(r,i)=>r.includes(i)),this.AddStringBinaryOp(this.Hasnt,(r,i)=>!r.includes(i)),this.AddListBinaryOp(this.Add,(r,i)=>r.Union(i)),this.AddListBinaryOp(this.Subtract,(r,i)=>r.Without(i)),this.AddListBinaryOp(this.Has,(r,i)=>r.Contains(i)),this.AddListBinaryOp(this.Hasnt,(r,i)=>!r.Contains(i)),this.AddListBinaryOp(this.Intersect,(r,i)=>r.Intersect(i)),this.AddListBinaryOp(this.Equal,(r,i)=>r.Equals(i)),this.AddListBinaryOp(this.Greater,(r,i)=>r.GreaterThan(i)),this.AddListBinaryOp(this.Less,(r,i)=>r.LessThan(i)),this.AddListBinaryOp(this.GreaterThanOrEquals,(r,i)=>r.GreaterThanOrEquals(i)),this.AddListBinaryOp(this.LessThanOrEquals,(r,i)=>r.LessThanOrEquals(i)),this.AddListBinaryOp(this.NotEquals,(r,i)=>!r.Equals(i)),this.AddListBinaryOp(this.And,(r,i)=>r.Count>0&&i.Count>0),this.AddListBinaryOp(this.Or,(r,i)=>r.Count>0||i.Count>0),this.AddListUnaryOp(this.Not,r=>r.Count==0?1:0),this.AddListUnaryOp(this.Invert,r=>r.inverse),this.AddListUnaryOp(this.All,r=>r.all),this.AddListUnaryOp(this.ListMin,r=>r.MinAsList()),this.AddListUnaryOp(this.ListMax,r=>r.MaxAsList()),this.AddListUnaryOp(this.Count,r=>r.Count),this.AddListUnaryOp(this.ValueOfList,r=>r.maxItem.Value);let e=(r,i)=>r.Equals(i),t=(r,i)=>!r.Equals(i);this.AddOpToNativeFunc(this.Equal,2,F.ValueType.DivertTarget,e),this.AddOpToNativeFunc(this.NotEquals,2,F.ValueType.DivertTarget,t);}}AddOpFuncForType(e,t){this._operationFuncs==null&&(this._operationFuncs=new Map),this._operationFuncs.set(e,t);}static AddOpToNativeFunc(e,t,r,i){if(this._nativeFunctions===null)return (0, ut.throwNullException)("NativeFunctionCall._nativeFunctions");let a=this._nativeFunctions.get(e);a||(a=new n(e,t),this._nativeFunctions.set(e,a)),a.AddOpFuncForType(r,i);}static AddIntBinaryOp(e,t){this.AddOpToNativeFunc(e,2,F.ValueType.Int,t);}static AddIntUnaryOp(e,t){this.AddOpToNativeFunc(e,1,F.ValueType.Int,t);}static AddFloatBinaryOp(e,t){this.AddOpToNativeFunc(e,2,F.ValueType.Float,t);}static AddFloatUnaryOp(e,t){this.AddOpToNativeFunc(e,1,F.ValueType.Float,t);}static AddStringBinaryOp(e,t){this.AddOpToNativeFunc(e,2,F.ValueType.String,t);}static AddListBinaryOp(e,t){this.AddOpToNativeFunc(e,2,F.ValueType.List,t);}static AddListUnaryOp(e,t){this.AddOpToNativeFunc(e,1,F.ValueType.List,t);}toString(){return 'Native "'+this.name+'"'}};Ia.NativeFunctionCall=U;U.Add="+";U.Subtract="-";U.Divide="/";U.Multiply="*";U.Mod="%";U.Negate="_";U.Equal="==";U.Greater=">";U.Less="<";U.GreaterThanOrEquals=">=";U.LessThanOrEquals="<=";U.NotEquals="!=";U.Not="!";U.And="&&";U.Or="||";U.Min="MIN";U.Max="MAX";U.Pow="POW";U.Floor="FLOOR";U.Ceiling="CEILING";U.Int="INT";U.Float="FLOAT";U.Has="?";U.Hasnt="!?";U.Intersect="^";U.ListMin="LIST_MIN";U.ListMax="LIST_MAX";U.All="LIST_ALL";U.Count="LIST_COUNT";U.ValueOfList="LIST_VALUE";U.Invert="LIST_INVERT";U._nativeFunctions=null;});var Va=E(ka=>{Object.defineProperty(ka,"__esModule",{value:true});ka.NumberExpression=void 0;var MP=Ct(),Rh=ve(),GP=ae(),$h=class n extends MP.Expression{constructor(e,t){if(super(),this.isInt=()=>this.subtype=="int",this.isFloat=()=>this.subtype=="float",this.isBool=()=>this.subtype=="bool",this.GenerateIntoContainer=r=>{this.isInt()?r.AddContent(new Rh.IntValue(this.value)):this.isFloat()?r.AddContent(new Rh.FloatValue(this.value)):this.isBool()&&r.AddContent(new Rh.BoolValue(this.value));},this.toString=()=>String(this.value),typeof e=="number"&&!Number.isNaN(e)||typeof e=="boolean")this.value=e,this.subtype=t;else throw new Error("Unexpected object type in NumberExpression.")}get typeName(){return "Number"}Equals(e){let t=(0, GP.asOrNull)(e,n);return t?t.subtype==this.subtype&&t.value==this.value:false}};ka.NumberExpression=$h;});var jh=E(Ra=>{Object.defineProperty(Ra,"__esModule",{value:true});Ra.UnaryExpression=void 0;var zP=Ct(),JP=Wt(),Vr=Va(),HP=ae(),Ji=class extends zP.Expression{get nativeNameForOp(){return this.op==="-"?"_":this.op==="not"?"!":this.op}constructor(e,t){super(),this.op=t,this.GenerateIntoContainer=r=>{this.innerExpression.GenerateIntoContainer(r),r.AddContent(JP.NativeFunctionCall.CallWithName(this.nativeNameForOp));},this.toString=()=>this.nativeNameForOp+this.innerExpression,this.innerExpression=this.AddContent(e);}get typeName(){return "UnaryExpression"}};Ra.UnaryExpression=Ji;Ji.WithInner=(n,e)=>{let t=(0, HP.asOrNull)(n,Vr.NumberExpression);if(t){if(e==="-"){if(t.isInt())return new Vr.NumberExpression(-t.value,"int");if(t.isFloat())return new Vr.NumberExpression(-t.value,"float")}else if(e=="!"||e=="not"){if(t.isInt())return new Vr.NumberExpression(t.value==0,"bool");if(t.isFloat())return new Vr.NumberExpression(t.value==0,"bool");if(t.isBool())return new Vr.NumberExpression(!t.value,"bool")}throw new Error("Unexpected operation or number type")}return new Ji(n,e)};});var qh=E($a=>{Object.defineProperty($a,"__esModule",{value:true});$a.BinaryExpression=void 0;var UP=Ct(),KP=Wt(),XP=jh(),YP=ae(),Lh=class extends UP.Expression{constructor(e,t,r){super(),this.opName=r,this.GenerateIntoContainer=i=>{this.leftExpression.GenerateIntoContainer(i),this.rightExpression.GenerateIntoContainer(i),this.opName=this.NativeNameForOp(this.opName),i.AddContent(KP.NativeFunctionCall.CallWithName(this.opName));},this.NativeNameForOp=i=>i==="and"?"&&":i==="or"?"||":i==="mod"?"%":i==="has"?"?":i==="hasnt"?"!?":i,this.toString=()=>`(${this.leftExpression} ${this.opName} ${this.rightExpression})`,this.leftExpression=this.AddContent(e),this.rightExpression=this.AddContent(t),this.opName=r;}get typeName(){return "BinaryExpression"}ResolveReferences(e){if(super.ResolveReferences(e),this.NativeNameForOp(this.opName)==="?"){let t=(0, YP.asOrNull)(this.leftExpression,XP.UnaryExpression);t!==null&&(t.op==="not"||t.op==="!")&&this.Error(`Using 'not' or '!' here negates '${t.innerExpression}' rather than the result of the '?' or 'has' operator. You need to add parentheses around the (A ? B) expression.`);}}};$a.BinaryExpression=Lh;});var Ui=E(ja=>{Object.defineProperty(ja,"__esModule",{value:true});ja.CharacterSet=void 0;var Hi=class{constructor(e){this.set=new Set,this.Add=t=>this.set.add(t),this.AddRange=(t,r)=>{for(let i=t.charCodeAt(0);i<=r.charCodeAt(0);++i)this.Add(String.fromCharCode(i));return this},this.AddCharacters=t=>{if(typeof t=="string"||Array.isArray(t))for(let r of t)this.Add(r);else for(let r of t.set)this.Add(r);return this},e&&this.AddCharacters(e);}};ja.CharacterSet=Hi;Hi.FromRange=(n,e)=>new Hi().AddRange(n,e);});var uv=E(La=>{Object.defineProperty(La,"__esModule",{value:true});La.CharacterRange=void 0;var ov=Ui(),Ki=class{constructor(e,t,r=[]){if(this._start=e,this._end=t,this._correspondingCharSet=new ov.CharacterSet,this._excludes=new Set,this.ToCharacterSet=()=>{if(this._correspondingCharSet.set.size===0)for(let i=this.start.charCodeAt(0),a;i<=this.end.charCodeAt(0);i+=1)a=String.fromCharCode(i),this._excludes.has(a)||this._correspondingCharSet.AddCharacters(a);return this._correspondingCharSet},r instanceof ov.CharacterSet)this._excludes=r.set;else for(let i of r)this._excludes.add(i);}get start(){return this._start}get end(){return this._end}};La.CharacterRange=Ki;Ki.Define=(n,e,t=[])=>new Ki(n,e,t);});var Ba=E(qa=>{Object.defineProperty(qa,"__esModule",{value:true});qa.ChoicePoint=void 0;var ZP=st(),QP=it(),Bh=je(),Wh=class extends ZP.InkObject{constructor(e=true){super(),this._pathOnChoice=null,this.hasCondition=false,this.hasStartContent=false,this.hasChoiceOnlyContent=false,this.isInvisibleDefault=false,this.onceOnly=true,this.onceOnly=e;}get pathOnChoice(){if(this._pathOnChoice!=null&&this._pathOnChoice.isRelative){let e=this.choiceTarget;e&&(this._pathOnChoice=e.path);}return this._pathOnChoice}set pathOnChoice(e){this._pathOnChoice=e;}get choiceTarget(){return this._pathOnChoice===null?(0, Bh.throwNullException)("ChoicePoint._pathOnChoice"):this.ResolvePath(this._pathOnChoice).container}get pathStringOnChoice(){return this.pathOnChoice===null?(0, Bh.throwNullException)("ChoicePoint.pathOnChoice"):this.CompactPathString(this.pathOnChoice)}set pathStringOnChoice(e){this.pathOnChoice=new QP.Path(e);}get flags(){let e=0;return this.hasCondition&&(e|=1),this.hasStartContent&&(e|=2),this.hasChoiceOnlyContent&&(e|=4),this.isInvisibleDefault&&(e|=8),this.onceOnly&&(e|=16),e}set flags(e){this.hasCondition=(e&1)>0,this.hasStartContent=(e&2)>0,this.hasChoiceOnlyContent=(e&4)>0,this.isInvisibleDefault=(e&8)>0,this.onceOnly=(e&16)>0;}toString(){if(this.pathOnChoice===null)return (0, Bh.throwNullException)("ChoicePoint.pathOnChoice");let t=this.pathOnChoice.toString();return "Choice: -> "+t}};qa.ChoicePoint=Wh;});var Kn=E(Wa=>{Object.defineProperty(Wa,"__esModule",{value:true});Wa.PushPopType=void 0;var lv;(function(n){n[n.Tunnel=0]="Tunnel",n[n.Function=1]="Function",n[n.FunctionEvaluationFromGame=2]="FunctionEvaluationFromGame";})(lv||(Wa.PushPopType=lv={}));});var Xi=E(Ma=>{Object.defineProperty(Ma,"__esModule",{value:true});Ma.Pointer=void 0;var eO=it(),Mh=class n{constructor(){this.container=null,this.index=-1,arguments.length===2&&(this.container=arguments[0],this.index=arguments[1]);}Resolve(){return this.index<0?this.container:this.container==null?null:this.container.content.length==0?this.container:this.index>=this.container.content.length?null:this.container.content[this.index]}get isNull(){return this.container==null}get path(){return this.isNull?null:this.index>=0?this.container.path.PathByAppendingComponent(new eO.Path.Component(this.index)):this.container.path}toString(){return this.container?"Ink Pointer -> "+this.container.path.toString()+" -- index "+this.index:"Ink Pointer (null)"}copy(){return new n(this.container,this.index)}static StartOf(e){return new n(e,0)}static get Null(){return new n(null,-1)}};Ma.Pointer=Mh;});var Mt=E(za=>{Object.defineProperty(za,"__esModule",{value:true});za.Divert=void 0;var tO=it(),nO=Kn(),rO=Jn(),iO=st(),Gh=Xi(),cv=Ee(),Ga=je(),zh=class n extends iO.InkObject{get targetPath(){if(this._targetPath!=null&&this._targetPath.isRelative){let e=this.targetPointer.Resolve();e&&(this._targetPath=e.path);}return this._targetPath}set targetPath(e){this._targetPath=e,this._targetPointer=Gh.Pointer.Null;}get targetPointer(){if(this._targetPointer.isNull){let e=this.ResolvePath(this._targetPath).obj;if(this._targetPath===null)return (0, Ga.throwNullException)("this._targetPath");if(this._targetPath.lastComponent===null)return (0, Ga.throwNullException)("this._targetPath.lastComponent");if(this._targetPath.lastComponent.isIndex){if(e===null)return (0, Ga.throwNullException)("targetObj");this._targetPointer.container=e.parent instanceof cv.Container?e.parent:null,this._targetPointer.index=this._targetPath.lastComponent.index;}else this._targetPointer=Gh.Pointer.StartOf(e instanceof cv.Container?e:null);}return this._targetPointer.copy()}get targetPathString(){return this.targetPath==null?null:this.CompactPathString(this.targetPath)}set targetPathString(e){e==null?this.targetPath=null:this.targetPath=new tO.Path(e);}get hasVariableTarget(){return this.variableDivertName!=null}constructor(e){super(),this._targetPath=null,this._targetPointer=Gh.Pointer.Null,this.variableDivertName=null,this.pushesToStack=false,this.stackPushType=0,this.isExternal=false,this.externalArgs=0,this.isConditional=false,this.pushesToStack=false,typeof e<"u"&&(this.pushesToStack=true,this.stackPushType=e);}Equals(e){let t=e;return t instanceof n&&this.hasVariableTarget==t.hasVariableTarget?this.hasVariableTarget?this.variableDivertName==t.variableDivertName:this.targetPath===null?(0, Ga.throwNullException)("this.targetPath"):this.targetPath.Equals(t.targetPath):false}toString(){if(this.hasVariableTarget)return "Divert(variable: "+this.variableDivertName+")";if(this.targetPath==null)return "Divert(null)";{let e=new rO.StringBuilder,t=this.targetPath.toString();return e.Append("Divert"),this.isConditional&&e.Append("?"),this.pushesToStack&&(this.stackPushType==nO.PushPopType.Function?e.Append(" function"):e.Append(" tunnel")),e.Append(" -> "),e.Append(this.targetPathString),e.Append(" ("),e.Append(t),e.Append(")"),e.toString()}}};za.Divert=zh;});var nn=E(Ja=>{Object.defineProperty(Ja,"__esModule",{value:true});Ja.SymbolType=void 0;var hv;(function(n){n[n.Knot=0]="Knot",n[n.List=1]="List",n[n.ListItem=2]="ListItem",n[n.Var=3]="Var",n[n.SubFlowAndWeave=4]="SubFlowAndWeave",n[n.Arg=5]="Arg",n[n.Temp=6]="Temp";})(hv||(Ja.SymbolType=hv={}));});var bn=E(Ha=>{Object.defineProperty(Ha,"__esModule",{value:true});Ha.VariableAssignment=void 0;var sO=st(),Jh=class extends sO.InkObject{constructor(e,t){super(),this.variableName=e||null,this.isNewDeclaration=!!t,this.isGlobal=false;}toString(){return "VarAssign to "+this.variableName}};Ha.VariableAssignment=Jh;});var Rr=E(Ka=>{Object.defineProperty(Ka,"__esModule",{value:true});Ka.Choice=void 0;var aO=Ba(),Ua=Ee(),_n=Le(),Hh=Mt(),dv=ve(),oO=ye(),uO=nn(),fv=bn(),Uh=class extends oO.ParsedObject{get runtimeChoice(){if(!this._runtimeChoice)throw new Error;return this._runtimeChoice}get name(){var e;return ((e=this.identifier)===null||e===void 0?void 0:e.name)||null}get condition(){return this._condition}set condition(e){this._condition=e,e&&this.AddContent(e);}get runtimeContainer(){return this._innerContentContainer}get innerContentContainer(){return this._innerContentContainer}get containerForCounting(){return this._innerContentContainer}get runtimePath(){if(!this.innerContentContainer||!this.innerContentContainer.path)throw new Error;return this.innerContentContainer.path}constructor(e,t,r){super(),this._condition=null,this._innerContentContainer=null,this._outerContainer=null,this._runtimeChoice=null,this._returnToR1=null,this._returnToR2=null,this._r1Label=null,this._r2Label=null,this._divertToStartContentOuter=null,this._divertToStartContentInner=null,this._startContentRuntimeContainer=null,this.isInvisibleDefault=false,this.hasWeaveStyleInlineBrackets=false,this.GenerateRuntimeObject=()=>{if(this._outerContainer=new Ua.Container,this._runtimeChoice=new aO.ChoicePoint(this.onceOnly),this._runtimeChoice.isInvisibleDefault=this.isInvisibleDefault,(this.startContent||this.choiceOnlyContent||this.condition)&&this._outerContainer.AddContent(_n.ControlCommand.EvalStart()),this.startContent){this._returnToR1=new dv.DivertTargetValue,this._outerContainer.AddContent(this._returnToR1);let i=new fv.VariableAssignment("$r",true);this._outerContainer.AddContent(i),this._outerContainer.AddContent(_n.ControlCommand.BeginString()),this._divertToStartContentOuter=new Hh.Divert,this._outerContainer.AddContent(this._divertToStartContentOuter),this._startContentRuntimeContainer=this.startContent.GenerateRuntimeObject(),this._startContentRuntimeContainer.name="s";let a=new Hh.Divert;a.variableDivertName="$r",this._startContentRuntimeContainer.AddContent(a),this._outerContainer.AddToNamedContentOnly(this._startContentRuntimeContainer),this._r1Label=new Ua.Container,this._r1Label.name="$r1",this._outerContainer.AddContent(this._r1Label),this._outerContainer.AddContent(_n.ControlCommand.EndString()),this._runtimeChoice.hasStartContent=true;}if(this.choiceOnlyContent){this._outerContainer.AddContent(_n.ControlCommand.BeginString());let i=this.choiceOnlyContent.GenerateRuntimeObject();this._outerContainer.AddContentsOfContainer(i),this._outerContainer.AddContent(_n.ControlCommand.EndString()),this._runtimeChoice.hasChoiceOnlyContent=true;}if(this.condition&&(this.condition.GenerateIntoContainer(this._outerContainer),this._runtimeChoice.hasCondition=true),(this.startContent||this.choiceOnlyContent||this.condition)&&this._outerContainer.AddContent(_n.ControlCommand.EvalEnd()),this._outerContainer.AddContent(this._runtimeChoice),this._innerContentContainer=new Ua.Container,this.startContent){this._returnToR2=new dv.DivertTargetValue,this._innerContentContainer.AddContent(_n.ControlCommand.EvalStart()),this._innerContentContainer.AddContent(this._returnToR2),this._innerContentContainer.AddContent(_n.ControlCommand.EvalEnd());let i=new fv.VariableAssignment("$r",true);this._innerContentContainer.AddContent(i),this._divertToStartContentInner=new Hh.Divert,this._innerContentContainer.AddContent(this._divertToStartContentInner),this._r2Label=new Ua.Container,this._r2Label.name="$r2",this._innerContentContainer.AddContent(this._r2Label);}if(this.innerContent){let i=this.innerContent.GenerateRuntimeObject();this._innerContentContainer.AddContentsOfContainer(i);}return this.story.countAllVisits&&(this._innerContentContainer.visitsShouldBeCounted=true),this._innerContentContainer.countingAtStartOnly=true,this._outerContainer},this.toString=()=>this.choiceOnlyContent!==null?`* ${this.startContent}[${this.choiceOnlyContent}]...`:`* ${this.startContent}...`,this.startContent=e,this.choiceOnlyContent=t,this.innerContent=r,this.indentationDepth=1,e&&this.AddContent(this.startContent),t&&this.AddContent(this.choiceOnlyContent),r&&this.AddContent(this.innerContent),this.onceOnly=true;}get typeName(){return "Choice"}ResolveReferences(e){var t;if(this._innerContentContainer&&(this.runtimeChoice.pathOnChoice=this._innerContentContainer.path,this.onceOnly&&(this._innerContentContainer.visitsShouldBeCounted=true)),this._returnToR1){if(!this._r1Label)throw new Error;this._returnToR1.targetPath=this._r1Label.path;}if(this._returnToR2){if(!this._r2Label)throw new Error;this._returnToR2.targetPath=this._r2Label.path;}if(this._divertToStartContentOuter){if(!this._startContentRuntimeContainer)throw new Error;this._divertToStartContentOuter.targetPath=this._startContentRuntimeContainer.path;}if(this._divertToStartContentInner){if(!this._startContentRuntimeContainer)throw new Error;this._divertToStartContentInner.targetPath=this._startContentRuntimeContainer.path;}super.ResolveReferences(e),this.identifier&&(((t=this.identifier)===null||t===void 0?void 0:t.name)||"").length>0&&e.CheckForNamingCollisions(this,this.identifier,uO.SymbolType.SubFlowAndWeave);}};Ka.Choice=Uh;});var pv=E(Ya=>{Object.defineProperty(Ya,"__esModule",{value:true});Ya.StringParserElement=void 0;var Xa=class n{constructor(){this.characterIndex=0,this.characterInLineIndex=0,this.lineIndex=0,this.reportedErrorInScope=false,this.uniqueId=0,this.customFlags=0,this.CopyFrom=e=>{n._uniqueIdCounter++,this.uniqueId=n._uniqueIdCounter,this.characterIndex=e.characterIndex,this.characterInLineIndex=e.characterInLineIndex,this.lineIndex=e.lineIndex,this.customFlags=e.customFlags,this.reportedErrorInScope=false;},this.SquashFrom=e=>{this.characterIndex=e.characterIndex,this.characterInLineIndex=e.characterInLineIndex,this.lineIndex=e.lineIndex,this.reportedErrorInScope=e.reportedErrorInScope,this.customFlags=e.customFlags;};}};Ya.StringParserElement=Xa;Xa._uniqueIdCounter=1e3;});var gv=E(Za=>{Object.defineProperty(Za,"__esModule",{value:true});Za.StringParserState=void 0;var mv=pv(),Kh=class{get currentElement(){return this._stack[this._numElements-1]}get lineIndex(){return this.currentElement.lineIndex}set lineIndex(e){this.currentElement.lineIndex=e;}get characterIndex(){return this.currentElement.characterIndex}set characterIndex(e){this.currentElement.characterIndex=e;}get characterInLineIndex(){return this.currentElement.characterInLineIndex}set characterInLineIndex(e){this.currentElement.characterInLineIndex=e;}get customFlags(){return this.currentElement.customFlags}set customFlags(e){this.currentElement.customFlags=e;}get errorReportedAlreadyInScope(){return this.currentElement.reportedErrorInScope}get stackHeight(){return this._numElements}constructor(){this._stack=[],this._numElements=0,this.StringParserState=()=>{this._stack=new Array(200);for(let r=0;r<200;++r)this._stack[r]=new mv.StringParserElement;this._numElements=1;},this.Push=()=>{if(this._numElements>=this._stack.length&&this._numElements>0)throw new Error("Stack overflow in parser state.");let t=this._stack[this._numElements-1],r=this._stack[this._numElements];return this._numElements++,r.CopyFrom(t),r.uniqueId},this.Pop=t=>{if(this._numElements==1)throw new Error("Attempting to remove final stack element is illegal! Mismatched Begin/Succceed/Fail?");if(this.currentElement.uniqueId!=t)throw new Error("Mismatched rule IDs while Poping - do you have mismatched Begin/Succeed/Fail?");this._numElements-=1;},this.Peek=t=>{if(this.currentElement.uniqueId!=t)throw new Error("Mismatched rule IDs while Peeking - do you have mismatched Begin/Succeed/Fail?");return this._stack[this._numElements-1]},this.PeekPenultimate=()=>this._numElements>=2?this._stack[this._numElements-2]:null,this.Squash=()=>{if(this._numElements<2)throw new Error("Attempting to remove final stack element is illegal! Mismatched Begin/Succceed/Fail?");let t=this._stack[this._numElements-2],r=this._stack[this._numElements-1];t.SquashFrom(r),this._numElements-=1;},this.NoteErrorReported=()=>{for(let t of this._stack)t.reportedErrorInScope=true;};let e=200;for(let t=0;t<e;t++)this._stack[t]=new mv.StringParserElement;this._numElements=1;}};Za.StringParserState=Kh;});var Yh=E(Xn=>{Object.defineProperty(Xn,"__esModule",{value:true});Xn.StringParser=Xn.ParseSuccess=void 0;var Xh=Ui(),lO=gv();Xn.ParseSuccess=Symbol("ParseSuccessStruct");var Yi=class n{constructor(e){this.ParseRule=null,this.errorHandler=null,this.hadError=false,this.BeginRule=()=>this.state.Push(),this.FailRule=r=>(this.state.Pop(r),null),this.CancelRule=r=>{this.state.Pop(r);},this.SucceedRule=(r,i=null)=>{let a=this.state.Peek(r),s=this.state.PeekPenultimate();this.RuleDidSucceed&&this.RuleDidSucceed(i,s,a),this.state.Squash();let o=i;return o===null&&(o=n.ParseSuccess),o},this.Expect=(r,i=null,a=null)=>{let s=this.ParseObject(r);if(s===null){i===null&&(i=r.name);let o,u=this.LineRemainder();u===null||u.length===0?o="end of line":o=`'${u}'`,this.Error(`Expected ${i} but saw ${o}`),a!==null&&(s=a());}return s},this.Error=(r,i=false)=>{this.ErrorOnLine(r,this.lineIndex+1,i);},this.ErrorWithParsedObject=(r,i,a=false)=>{this.ErrorOnLine(r,i.debugMetadata?i.debugMetadata.startLineNumber:-1,a);},this.ErrorOnLine=(r,i,a)=>{if(!this.state.errorReportedAlreadyInScope){let s=a?"Warning":"Error";if(this.errorHandler)this.errorHandler(r,this.index,i-1,a);else throw new Error(`${s} on line ${i}: ${r}`);this.state.NoteErrorReported();}a||(this.hadError=true);},this.Warning=r=>this.Error(r,true),this.LineRemainder=()=>this.Peek(()=>this.ParseUntilCharactersFromString(`
|
|
8
|
+
deps: ${t}}`};var JE={keyword:"dependencies",type:"object",schemaType:"object",error:Lt.error,code(n){let[e,t]=HE(n);zg(n,e),Jg(n,t);}};function HE({schema:n}){let e={},t={};for(let r in n){if(r==="__proto__")continue;let i=Array.isArray(n[r])?e:t;i[r]=n[r];}return [e,t]}function zg(n,e=n.schema){let{gen:t,data:r,it:i}=n;if(Object.keys(e).length===0)return;let a=t.let("missing");for(let s in e){let o=e[s];if(o.length===0)continue;let u=(0, Vi.propertyInData)(t,r,s,i.opts.ownProperties);n.setParams({property:s,depsCount:o.length,deps:o.join(", ")}),i.allErrors?t.if(u,()=>{for(let l of o)(0, Vi.checkReportMissingProp)(n,l);}):(t.if((0, Vc._)`${u} && (${(0, Vi.checkMissingProp)(n,o,a)})`),(0, Vi.reportMissingProp)(n,a),t.else());}}Lt.validatePropertyDeps=zg;function Jg(n,e=n.schema){let{gen:t,data:r,keyword:i,it:a}=n,s=t.name("valid");for(let o in e)(0, zE.alwaysValidSchema)(a,e[o])||(t.if((0, Vi.propertyInData)(t,r,o,a.opts.ownProperties),()=>{let u=n.subschema({keyword:i,schemaProp:o},s);n.mergeValidEvaluated(u,s);},()=>t.var(s,true)),n.ok(s));}Lt.validateSchemaDeps=Jg;Lt.default=JE;});var Ug=w(Rc=>{Object.defineProperty(Rc,"__esModule",{value:true});var Hg=j(),UE=M(),KE={message:"property name must be valid",params:({params:n})=>(0, Hg._)`{propertyName: ${n.propertyName}}`},XE={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:KE,code(n){let{gen:e,schema:t,data:r,it:i}=n;if((0, UE.alwaysValidSchema)(i,t))return;let a=e.name("valid");e.forIn("key",r,s=>{n.setParams({propertyName:s}),n.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:true},a),e.if((0, Hg.not)(a),()=>{n.error(true),i.allErrors||e.break();});}),n.ok(a);}};Rc.default=XE;});var $c=w(jc=>{Object.defineProperty(jc,"__esModule",{value:true});var ua=yt(),Ft=j(),YE=gt(),la=M(),ZE={message:"must NOT have additional properties",params:({params:n})=>(0, Ft._)`{additionalProperty: ${n.additionalProperty}}`},QE={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:ZE,code(n){let{gen:e,schema:t,parentSchema:r,data:i,errsCount:a,it:s}=n;if(!a)throw new Error("ajv implementation error");let{allErrors:o,opts:u}=s;if(s.props=true,u.removeAdditional!=="all"&&(0, la.alwaysValidSchema)(s,t))return;let l=(0, ua.allSchemaProperties)(r.properties),c=(0, ua.allSchemaProperties)(r.patternProperties);h(),n.ok((0, Ft._)`${a} === ${YE.default.errors}`);function h(){e.forIn("key",i,C=>{!l.length&&!c.length?g(C):e.if(f(C),()=>g(C));});}function f(C){let S;if(l.length>8){let v=(0, la.schemaRefOrVal)(s,r.properties,"properties");S=(0, ua.isOwnProperty)(e,v,C);}else l.length?S=(0, Ft.or)(...l.map(v=>(0, Ft._)`${C} === ${v}`)):S=Ft.nil;return c.length&&(S=(0, Ft.or)(S,...c.map(v=>(0, Ft._)`${(0, ua.usePattern)(n,v)}.test(${C})`))),(0, Ft.not)(S)}function p(C){e.code((0, Ft._)`delete ${i}[${C}]`);}function g(C){if(u.removeAdditional==="all"||u.removeAdditional&&t===false){p(C);return}if(t===false){n.setParams({additionalProperty:C}),n.error(),o||e.break();return}if(typeof t=="object"&&!(0, la.alwaysValidSchema)(s,t)){let S=e.name("valid");u.removeAdditional==="failing"?(y(C,S,false),e.if((0, Ft.not)(S),()=>{n.reset(),p(C);})):(y(C,S),o||e.if((0, Ft.not)(S),()=>e.break()));}}function y(C,S,v){let d={keyword:"additionalProperties",dataProp:C,dataPropType:la.Type.Str};v===false&&Object.assign(d,{compositeRule:true,createErrors:false,allErrors:false}),n.subschema(d,S);}}};jc.default=QE;});var Yg=w(qc=>{Object.defineProperty(qc,"__esModule",{value:true});var eD=gr(),Kg=yt(),Lc=M(),Xg=$c(),tD={keyword:"properties",type:"object",schemaType:"object",code(n){let{gen:e,schema:t,parentSchema:r,data:i,it:a}=n;a.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&Xg.default.code(new eD.KeywordCxt(a,Xg.default,"additionalProperties"));let s=(0, Kg.allSchemaProperties)(t);for(let h of s)a.definedProperties.add(h);a.opts.unevaluated&&s.length&&a.props!==true&&(a.props=Lc.mergeEvaluated.props(e,(0, Lc.toHash)(s),a.props));let o=s.filter(h=>!(0, Lc.alwaysValidSchema)(a,t[h]));if(o.length===0)return;let u=e.name("valid");for(let h of o)l(h)?c(h):(e.if((0, Kg.propertyInData)(e,i,h,a.opts.ownProperties)),c(h),a.allErrors||e.else().var(u,true),e.endIf()),n.it.definedProperties.add(h),n.ok(u);function l(h){return a.opts.useDefaults&&!a.compositeRule&&t[h].default!==void 0}function c(h){n.subschema({keyword:"properties",schemaProp:h,dataProp:h},u);}}};qc.default=tD;});var ty=w(Bc=>{Object.defineProperty(Bc,"__esModule",{value:true});var Zg=yt(),ca=j(),Qg=M(),ey=M(),nD={keyword:"patternProperties",type:"object",schemaType:"object",code(n){let{gen:e,schema:t,data:r,parentSchema:i,it:a}=n,{opts:s}=a,o=(0, Zg.allSchemaProperties)(t),u=o.filter(y=>(0, Qg.alwaysValidSchema)(a,t[y]));if(o.length===0||u.length===o.length&&(!a.opts.unevaluated||a.props===true))return;let l=s.strictSchema&&!s.allowMatchingProperties&&i.properties,c=e.name("valid");a.props!==true&&!(a.props instanceof ca.Name)&&(a.props=(0, ey.evaluatedPropsToName)(e,a.props));let{props:h}=a;f();function f(){for(let y of o)l&&p(y),a.allErrors?g(y):(e.var(c,true),g(y),e.if(c));}function p(y){for(let C in l)new RegExp(y).test(C)&&(0, Qg.checkStrictMode)(a,`property ${C} matches pattern ${y} (use allowMatchingProperties)`);}function g(y){e.forIn("key",r,C=>{e.if((0, ca._)`${(0, Zg.usePattern)(n,y)}.test(${C})`,()=>{let S=u.includes(y);S||n.subschema({keyword:"patternProperties",schemaProp:y,dataProp:C,dataPropType:ey.Type.Str},c),a.opts.unevaluated&&h!==true?e.assign((0, ca._)`${h}[${C}]`,true):!S&&!a.allErrors&&e.if((0, ca.not)(c),()=>e.break());});});}}};Bc.default=nD;});var ny=w(Wc=>{Object.defineProperty(Wc,"__esModule",{value:true});var rD=M(),iD={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(n){let{gen:e,schema:t,it:r}=n;if((0, rD.alwaysValidSchema)(r,t)){n.fail();return}let i=e.name("valid");n.subschema({keyword:"not",compositeRule:true,createErrors:false,allErrors:false},i),n.failResult(i,()=>n.reset(),()=>n.error());},error:{message:"must NOT be valid"}};Wc.default=iD;});var ry=w(Mc=>{Object.defineProperty(Mc,"__esModule",{value:true});var sD=yt(),aD={keyword:"anyOf",schemaType:"array",trackErrors:true,code:sD.validateUnion,error:{message:"must match a schema in anyOf"}};Mc.default=aD;});var iy=w(Gc=>{Object.defineProperty(Gc,"__esModule",{value:true});var ha=j(),oD=M(),uD={message:"must match exactly one schema in oneOf",params:({params:n})=>(0, ha._)`{passingSchemas: ${n.passing}}`},lD={keyword:"oneOf",schemaType:"array",trackErrors:true,error:uD,code(n){let{gen:e,schema:t,parentSchema:r,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(i.opts.discriminator&&r.discriminator)return;let a=t,s=e.let("valid",false),o=e.let("passing",null),u=e.name("_valid");n.setParams({passing:o}),e.block(l),n.result(s,()=>n.reset(),()=>n.error(true));function l(){a.forEach((c,h)=>{let f;(0, oD.alwaysValidSchema)(i,c)?e.var(u,true):f=n.subschema({keyword:"oneOf",schemaProp:h,compositeRule:true},u),h>0&&e.if((0, ha._)`${u} && ${s}`).assign(s,false).assign(o,(0, ha._)`[${o}, ${h}]`).else(),e.if(u,()=>{e.assign(s,true),e.assign(o,h),f&&n.mergeEvaluated(f,ha.Name);});});}}};Gc.default=lD;});var sy=w(zc=>{Object.defineProperty(zc,"__esModule",{value:true});var cD=M(),hD={keyword:"allOf",schemaType:"array",code(n){let{gen:e,schema:t,it:r}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");let i=e.name("valid");t.forEach((a,s)=>{if((0, cD.alwaysValidSchema)(r,a))return;let o=n.subschema({keyword:"allOf",schemaProp:s},i);n.ok(i),n.mergeEvaluated(o);});}};zc.default=hD;});var uy=w(Jc=>{Object.defineProperty(Jc,"__esModule",{value:true});var da=j(),oy=M(),dD={message:({params:n})=>(0, da.str)`must match "${n.ifClause}" schema`,params:({params:n})=>(0, da._)`{failingKeyword: ${n.ifClause}}`},pD={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:dD,code(n){let{gen:e,parentSchema:t,it:r}=n;t.then===void 0&&t.else===void 0&&(0, oy.checkStrictMode)(r,'"if" without "then" and "else" is ignored');let i=ay(r,"then"),a=ay(r,"else");if(!i&&!a)return;let s=e.let("valid",true),o=e.name("_valid");if(u(),n.reset(),i&&a){let c=e.let("ifClause");n.setParams({ifClause:c}),e.if(o,l("then",c),l("else",c));}else i?e.if(o,l("then")):e.if((0, da.not)(o),l("else"));n.pass(s,()=>n.error(true));function u(){let c=n.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},o);n.mergeEvaluated(c);}function l(c,h){return ()=>{let f=n.subschema({keyword:c},o);e.assign(s,o),n.mergeValidEvaluated(f,s),h?e.assign(h,(0, da._)`${c}`):n.setParams({ifClause:c});}}}};function ay(n,e){let t=n.schema[e];return t!==void 0&&!(0, oy.alwaysValidSchema)(n,t)}Jc.default=pD;});var ly=w(Hc=>{Object.defineProperty(Hc,"__esModule",{value:true});var fD=M(),mD={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:n,parentSchema:e,it:t}){e.if===void 0&&(0, fD.checkStrictMode)(t,`"${n}" without "if" is ignored`);}};Hc.default=mD;});var Kc=w(Uc=>{Object.defineProperty(Uc,"__esModule",{value:true});var gD=Tc(),yD=Bg(),vD=Nc(),bD=Mg(),CD=Gg(),SD=oa(),_D=Ug(),wD=$c(),ED=Yg(),DD=ty(),AD=ny(),OD=ry(),PD=iy(),xD=sy(),TD=uy(),ND=ly();function FD(n=false){let e=[AD.default,OD.default,PD.default,xD.default,TD.default,ND.default,_D.default,wD.default,SD.default,ED.default,DD.default];return n?e.push(yD.default,bD.default):e.push(gD.default,vD.default),e.push(CD.default),e}Uc.default=FD;});var cy=w(Xc=>{Object.defineProperty(Xc,"__esModule",{value:true});var _e=j(),ID={message:({schemaCode:n})=>(0, _e.str)`must match format "${n}"`,params:({schemaCode:n})=>(0, _e._)`{format: ${n}}`},kD={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:ID,code(n,e){let{gen:t,data:r,$data:i,schema:a,schemaCode:s,it:o}=n,{opts:u,errSchemaPath:l,schemaEnv:c,self:h}=o;if(!u.validateFormats)return;i?f():p();function f(){let g=t.scopeValue("formats",{ref:h.formats,code:u.code.formats}),y=t.const("fDef",(0, _e._)`${g}[${s}]`),C=t.let("fType"),S=t.let("format");t.if((0, _e._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>t.assign(C,(0, _e._)`${y}.type || "string"`).assign(S,(0, _e._)`${y}.validate`),()=>t.assign(C,(0, _e._)`"string"`).assign(S,y)),n.fail$data((0, _e.or)(v(),d()));function v(){return u.strictSchema===false?_e.nil:(0, _e._)`${s} && !${S}`}function d(){let _=c.$async?(0, _e._)`(${y}.async ? await ${S}(${r}) : ${S}(${r}))`:(0, _e._)`${S}(${r})`,m=(0, _e._)`(typeof ${S} == "function" ? ${_} : ${S}.test(${r}))`;return (0, _e._)`${S} && ${S} !== true && ${C} === ${e} && !${m}`}}function p(){let g=h.formats[a];if(!g){v();return}if(g===true)return;let[y,C,S]=d(g);y===e&&n.pass(_());function v(){if(u.strictSchema===false){h.logger.warn(m());return}throw new Error(m());function m(){return `unknown format "${a}" ignored in schema at path "${l}"`}}function d(m){let b=m instanceof RegExp?(0, _e.regexpCode)(m):u.code.formats?(0, _e._)`${u.code.formats}${(0, _e.getProperty)(a)}`:void 0,E=t.scopeValue("formats",{key:a,ref:m,code:b});return typeof m=="object"&&!(m instanceof RegExp)?[m.type||"string",m.validate,(0, _e._)`${E}.validate`]:["string",m,E]}function _(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!c.$async)throw new Error("async format in sync schema");return (0, _e._)`await ${S}(${r})`}return typeof C=="function"?(0, _e._)`${S}(${r})`:(0, _e._)`${S}.test(${r})`}}}};Xc.default=kD;});var Zc=w(Yc=>{Object.defineProperty(Yc,"__esModule",{value:true});var VD=cy(),RD=[VD.default];Yc.default=RD;});var Qc=w(_r=>{Object.defineProperty(_r,"__esModule",{value:true});_r.contentVocabulary=_r.metadataVocabulary=void 0;_r.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];_r.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var dy=w(eh=>{Object.defineProperty(eh,"__esModule",{value:true});var jD=dc(),$D=Pc(),LD=Kc(),qD=Zc(),hy=Qc(),BD=[jD.default,$D.default,(0, LD.default)(),qD.default,hy.metadataVocabulary,hy.contentVocabulary];eh.default=BD;});var fy=w(pa=>{Object.defineProperty(pa,"__esModule",{value:true});pa.DiscrError=void 0;var py;(function(n){n.Tag="tag",n.Mapping="mapping";})(py||(pa.DiscrError=py={}));});var rh=w(nh=>{Object.defineProperty(nh,"__esModule",{value:true});var wr=j(),th=fy(),my=Si(),WD=yr(),MD=M(),GD={message:({params:{discrError:n,tagName:e}})=>n===th.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:n,tag:e,tagName:t}})=>(0, wr._)`{error: ${n}, tag: ${t}, tagValue: ${e}}`},zD={keyword:"discriminator",type:"object",schemaType:"object",error:GD,code(n){let{gen:e,data:t,schema:r,parentSchema:i,it:a}=n,{oneOf:s}=i;if(!a.opts.discriminator)throw new Error("discriminator: requires discriminator option");let o=r.propertyName;if(typeof o!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let u=e.let("valid",false),l=e.const("tag",(0, wr._)`${t}${(0, wr.getProperty)(o)}`);e.if((0, wr._)`typeof ${l} == "string"`,()=>c(),()=>n.error(false,{discrError:th.DiscrError.Tag,tag:l,tagName:o})),n.ok(u);function c(){let p=f();e.if(false);for(let g in p)e.elseIf((0, wr._)`${l} === ${g}`),e.assign(u,h(p[g]));e.else(),n.error(false,{discrError:th.DiscrError.Mapping,tag:l,tagName:o}),e.endIf();}function h(p){let g=e.name("valid"),y=n.subschema({keyword:"oneOf",schemaProp:p},g);return n.mergeEvaluated(y,wr.Name),g}function f(){var p;let g={},y=S(i),C=true;for(let _=0;_<s.length;_++){let m=s[_];if(m?.$ref&&!(0, MD.schemaHasRulesButRef)(m,a.self.RULES)){let E=m.$ref;if(m=my.resolveRef.call(a.self,a.schemaEnv.root,a.baseId,E),m instanceof my.SchemaEnv&&(m=m.schema),m===void 0)throw new WD.default(a.opts.uriResolver,a.baseId,E)}let b=(p=m?.properties)===null||p===void 0?void 0:p[o];if(typeof b!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${o}"`);C=C&&(y||S(m)),v(b,_);}if(!C)throw new Error(`discriminator: "${o}" must be required`);return g;function S({required:_}){return Array.isArray(_)&&_.includes(o)}function v(_,m){if(_.const)d(_.const,m);else if(_.enum)for(let b of _.enum)d(b,m);else throw new Error(`discriminator: "properties/${o}" must have "const" or "enum"`)}function d(_,m){if(typeof _!="string"||_ in g)throw new Error(`discriminator: "${o}" values must be unique strings`);g[_]=m;}}}};nh.default=zD;});var gy=w((Pk,JD)=>{JD.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:true,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:true,readOnly:{type:"boolean",default:false},examples:{type:"array",items:true},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:true},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:true,enum:{type:"array",items:true,minItems:1,uniqueItems:true},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:true}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:true};});var vy=w((me,ih)=>{Object.defineProperty(me,"__esModule",{value:true});me.MissingRefError=me.ValidationError=me.CodeGen=me.Name=me.nil=me.stringify=me.str=me._=me.KeywordCxt=me.Ajv=void 0;var HD=lc(),UD=dy(),KD=rh(),yy=gy(),XD=["/properties"],fa="http://json-schema.org/draft-07/schema",Er=class extends HD.default{_addVocabularies(){super._addVocabularies(),UD.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(KD.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(yy,XD):yy;this.addMetaSchema(e,fa,false),this.refs["http://json-schema.org/schema"]=fa;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(fa)?fa:void 0)}};me.Ajv=Er;ih.exports=me=Er;ih.exports.Ajv=Er;Object.defineProperty(me,"__esModule",{value:true});me.default=Er;var YD=gr();Object.defineProperty(me,"KeywordCxt",{enumerable:true,get:function(){return YD.KeywordCxt}});var Dr=j();Object.defineProperty(me,"_",{enumerable:true,get:function(){return Dr._}});Object.defineProperty(me,"str",{enumerable:true,get:function(){return Dr.str}});Object.defineProperty(me,"stringify",{enumerable:true,get:function(){return Dr.stringify}});Object.defineProperty(me,"nil",{enumerable:true,get:function(){return Dr.nil}});Object.defineProperty(me,"Name",{enumerable:true,get:function(){return Dr.Name}});Object.defineProperty(me,"CodeGen",{enumerable:true,get:function(){return Dr.CodeGen}});var ZD=Ci();Object.defineProperty(me,"ValidationError",{enumerable:true,get:function(){return ZD.default}});var QD=yr();Object.defineProperty(me,"MissingRefError",{enumerable:true,get:function(){return QD.default}});});var ah=w(Ri=>{Object.defineProperty(Ri,"__esModule",{value:true});Ri.dynamicAnchor=void 0;var sh=j(),eA=gt(),by=Si(),tA=ta(),nA={keyword:"$dynamicAnchor",schemaType:"string",code:n=>Cy(n,n.schema)};function Cy(n,e){let{gen:t,it:r}=n;r.schemaEnv.root.dynamicAnchors[e]=true;let i=(0, sh._)`${eA.default.dynamicAnchors}${(0, sh.getProperty)(e)}`,a=r.errSchemaPath==="#"?r.validateName:rA(n);t.if((0, sh._)`!${i}`,()=>t.assign(i,a));}Ri.dynamicAnchor=Cy;function rA(n){let{schemaEnv:e,schema:t,self:r}=n.it,{root:i,baseId:a,localRefs:s,meta:o}=e.root,{schemaId:u}=r.opts,l=new by.SchemaEnv({schema:t,schemaId:u,root:i,baseId:a,localRefs:s,meta:o});return by.compileSchema.call(r,l),(0, tA.getValidate)(n,l)}Ri.default=nA;});var oh=w(ji=>{Object.defineProperty(ji,"__esModule",{value:true});ji.dynamicRef=void 0;var Sy=j(),iA=gt(),_y=ta(),sA={keyword:"$dynamicRef",schemaType:"string",code:n=>wy(n,n.schema)};function wy(n,e){let{gen:t,keyword:r,it:i}=n;if(e[0]!=="#")throw new Error(`"${r}" only supports hash fragment reference`);let a=e.slice(1);if(i.allErrors)s();else {let u=t.let("valid",false);s(u),n.ok(u);}function s(u){if(i.schemaEnv.root.dynamicAnchors[a]){let l=t.let("_v",(0, Sy._)`${iA.default.dynamicAnchors}${(0, Sy.getProperty)(a)}`);t.if(l,o(l,u),o(i.validateName,u));}else o(i.validateName,u)();}function o(u,l){return l?()=>t.block(()=>{(0, _y.callRef)(n,u),t.let(l,true);}):()=>(0, _y.callRef)(n,u)}}ji.dynamicRef=wy;ji.default=sA;});var Ey=w(uh=>{Object.defineProperty(uh,"__esModule",{value:true});var aA=ah(),oA=M(),uA={keyword:"$recursiveAnchor",schemaType:"boolean",code(n){n.schema?(0, aA.dynamicAnchor)(n,""):(0, oA.checkStrictMode)(n.it,"$recursiveAnchor: false is ignored");}};uh.default=uA;});var Dy=w(lh=>{Object.defineProperty(lh,"__esModule",{value:true});var lA=oh(),cA={keyword:"$recursiveRef",schemaType:"string",code:n=>(0, lA.dynamicRef)(n,n.schema)};lh.default=cA;});var Ay=w(ch=>{Object.defineProperty(ch,"__esModule",{value:true});var hA=ah(),dA=oh(),pA=Ey(),fA=Dy(),mA=[hA.default,dA.default,pA.default,fA.default];ch.default=mA;});var Py=w(hh=>{Object.defineProperty(hh,"__esModule",{value:true});var Oy=oa(),gA={keyword:"dependentRequired",type:"object",schemaType:"object",error:Oy.error,code:n=>(0, Oy.validatePropertyDeps)(n)};hh.default=gA;});var xy=w(dh=>{Object.defineProperty(dh,"__esModule",{value:true});var yA=oa(),vA={keyword:"dependentSchemas",type:"object",schemaType:"object",code:n=>(0, yA.validateSchemaDeps)(n)};dh.default=vA;});var Ty=w(ph=>{Object.defineProperty(ph,"__esModule",{value:true});var bA=M(),CA={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:n,parentSchema:e,it:t}){e.contains===void 0&&(0, bA.checkStrictMode)(t,`"${n}" without "contains" is ignored`);}};ph.default=CA;});var Ny=w(fh=>{Object.defineProperty(fh,"__esModule",{value:true});var SA=Py(),_A=xy(),wA=Ty(),EA=[SA.default,_A.default,wA.default];fh.default=EA;});var Iy=w(mh=>{Object.defineProperty(mh,"__esModule",{value:true});var bn=j(),Fy=M(),DA=gt(),AA={message:"must NOT have unevaluated properties",params:({params:n})=>(0, bn._)`{unevaluatedProperty: ${n.unevaluatedProperty}}`},OA={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:true,error:AA,code(n){let{gen:e,schema:t,data:r,errsCount:i,it:a}=n;if(!i)throw new Error("ajv implementation error");let{allErrors:s,props:o}=a;o instanceof bn.Name?e.if((0, bn._)`${o} !== true`,()=>e.forIn("key",r,h=>e.if(l(o,h),()=>u(h)))):o!==true&&e.forIn("key",r,h=>o===void 0?u(h):e.if(c(o,h),()=>u(h))),a.props=true,n.ok((0, bn._)`${i} === ${DA.default.errors}`);function u(h){if(t===false){n.setParams({unevaluatedProperty:h}),n.error(),s||e.break();return}if(!(0, Fy.alwaysValidSchema)(a,t)){let f=e.name("valid");n.subschema({keyword:"unevaluatedProperties",dataProp:h,dataPropType:Fy.Type.Str},f),s||e.if((0, bn.not)(f),()=>e.break());}}function l(h,f){return (0, bn._)`!${h} || !${h}[${f}]`}function c(h,f){let p=[];for(let g in h)h[g]===true&&p.push((0, bn._)`${f} !== ${g}`);return (0, bn.and)(...p)}}};mh.default=OA;});var Vy=w(gh=>{Object.defineProperty(gh,"__esModule",{value:true});var Hn=j(),ky=M(),PA={message:({params:{len:n}})=>(0, Hn.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0, Hn._)`{limit: ${n}}`},xA={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:PA,code(n){let{gen:e,schema:t,data:r,it:i}=n,a=i.items||0;if(a===true)return;let s=e.const("len",(0, Hn._)`${r}.length`);if(t===false)n.setParams({len:a}),n.fail((0, Hn._)`${s} > ${a}`);else if(typeof t=="object"&&!(0, ky.alwaysValidSchema)(i,t)){let u=e.var("valid",(0, Hn._)`${s} <= ${a}`);e.if((0, Hn.not)(u),()=>o(u,a)),n.ok(u);}i.items=true;function o(u,l){e.forRange("i",l,s,c=>{n.subschema({keyword:"unevaluatedItems",dataProp:c,dataPropType:ky.Type.Num},u),i.allErrors||e.if((0, Hn.not)(u),()=>e.break());});}}};gh.default=xA;});var Ry=w(yh=>{Object.defineProperty(yh,"__esModule",{value:true});var TA=Iy(),NA=Vy(),FA=[TA.default,NA.default];yh.default=FA;});var $y=w(vh=>{Object.defineProperty(vh,"__esModule",{value:true});var IA=dc(),kA=Pc(),VA=Kc(),RA=Ay(),jA=Ny(),$A=Ry(),LA=Zc(),jy=Qc(),qA=[RA.default,IA.default,kA.default,(0, VA.default)(true),LA.default,jy.metadataVocabulary,jy.contentVocabulary,jA.default,$A.default];vh.default=qA;});var Ly=w((Wk,BA)=>{BA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":true,"https://json-schema.org/draft/2020-12/vocab/applicator":true,"https://json-schema.org/draft/2020-12/vocab/unevaluated":true,"https://json-schema.org/draft/2020-12/vocab/validation":true,"https://json-schema.org/draft/2020-12/vocab/meta-data":true,"https://json-schema.org/draft/2020-12/vocab/format-annotation":true,"https://json-schema.org/draft/2020-12/vocab/content":true},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:true,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:true,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:true},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:true}}};});var qy=w((Mk,WA)=>{WA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":true},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}};});var By=w((Gk,MA)=>{MA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":true},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}};});var Wy=w((zk,GA)=>{GA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":true},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}};});var My=w((Jk,zA)=>{zA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":true},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}};});var Gy=w((Hk,JA)=>{JA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":true},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}};});var zy=w((Uk,HA)=>{HA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":true},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:true,deprecated:{type:"boolean",default:false},readOnly:{type:"boolean",default:false},writeOnly:{type:"boolean",default:false},examples:{type:"array",items:true}}};});var Jy=w((Kk,UA)=>{UA.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":true},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:true}]},const:true,enum:{type:"array",items:true},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:true,default:[]}}};});var Hy=w(bh=>{Object.defineProperty(bh,"__esModule",{value:true});var KA=Ly(),XA=qy(),YA=By(),ZA=Wy(),QA=My(),eO=Gy(),tO=zy(),nO=Jy(),rO=["/properties"];function iO(n){return [KA,XA,YA,ZA,QA,e(this,eO),tO,e(this,nO)].forEach(t=>this.addMetaSchema(t,void 0,false)),this;function e(t,r){return n?t.$dataMetaSchema(r,rO):r}}bh.default=iO;});var Uy=w((ge,Sh)=>{Object.defineProperty(ge,"__esModule",{value:true});ge.MissingRefError=ge.ValidationError=ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=ge.Ajv2020=void 0;var sO=lc(),aO=$y(),oO=rh(),uO=Hy(),Ch="https://json-schema.org/draft/2020-12/schema",Ar=class extends sO.default{constructor(e={}){super({...e,dynamicRef:true,next:true,unevaluated:true});}_addVocabularies(){super._addVocabularies(),aO.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(oO.default);}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(uO.default.call(this,e),this.refs["http://json-schema.org/schema"]=Ch);}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ch)?Ch:void 0)}};ge.Ajv2020=Ar;Sh.exports=ge=Ar;Sh.exports.Ajv2020=Ar;Object.defineProperty(ge,"__esModule",{value:true});ge.default=Ar;var lO=gr();Object.defineProperty(ge,"KeywordCxt",{enumerable:true,get:function(){return lO.KeywordCxt}});var Or=j();Object.defineProperty(ge,"_",{enumerable:true,get:function(){return Or._}});Object.defineProperty(ge,"str",{enumerable:true,get:function(){return Or.str}});Object.defineProperty(ge,"stringify",{enumerable:true,get:function(){return Or.stringify}});Object.defineProperty(ge,"nil",{enumerable:true,get:function(){return Or.nil}});Object.defineProperty(ge,"Name",{enumerable:true,get:function(){return Or.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:true,get:function(){return Or.CodeGen}});var cO=Ci();Object.defineProperty(ge,"ValidationError",{enumerable:true,get:function(){return cO.default}});var hO=yr();Object.defineProperty(ge,"MissingRefError",{enumerable:true,get:function(){return hO.default}});});var wh=w(ma=>{Object.defineProperty(ma,"__esModule",{value:true});ma.CompilerOptions=void 0;var _h=class{constructor(e=null,t=[],r=false,i=null,a=null){this.sourceFilename=e,this.pluginNames=t,this.countAllVisits=r,this.errorHandler=i,this.fileHandler=a;}};ma.CompilerOptions=_h;});var Ky=w(ga=>{Object.defineProperty(ga,"__esModule",{value:true});ga.DebugSourceRange=void 0;var Eh=class{constructor(e,t,r){this.length=e,this.debugMetadata=t,this.text=r;}};ga.DebugSourceRange=Eh;});var Pr=w(ya=>{Object.defineProperty(ya,"__esModule",{value:true});ya.ErrorType=void 0;var Xy;(function(n){n[n.Author=0]="Author",n[n.Warning=1]="Warning",n[n.Error=2]="Error";})(Xy||(ya.ErrorType=Xy={}));});var Yy=w(va=>{Object.defineProperty(va,"__esModule",{value:true});va.Argument=void 0;var Dh=class{constructor(e=null,t=null,r=null){this.identifier=e,this.isByReference=t,this.isDivertTarget=r;}get typeName(){return "Argument"}};va.Argument=Dh;});var oe=w(Pe=>{Object.defineProperty(Pe,"__esModule",{value:true});Pe.filterUndef=Pe.isEquatable=Pe.nullIfUndefined=Pe.asINamedContentOrNull=Pe.asBooleanOrThrows=Pe.asNumberOrThrows=Pe.asOrThrows=Pe.asOrNull=void 0;function dO(n,e){return n instanceof e?Zy(n):null}Pe.asOrNull=dO;function pO(n,e){if(n instanceof e)return Zy(n);throw new Error(`${n} is not of type ${e}`)}Pe.asOrThrows=pO;function fO(n){if(typeof n=="number")return n;throw new Error(`${n} is not a number`)}Pe.asNumberOrThrows=fO;function mO(n){if(typeof n=="boolean")return n;throw new Error(`${n} is not a boolean`)}Pe.asBooleanOrThrows=mO;function gO(n){return n.hasValidName&&n.name?n:null}Pe.asINamedContentOrNull=gO;function yO(n){return typeof n>"u"?null:n}Pe.nullIfUndefined=yO;function vO(n){return typeof n=="object"&&typeof n.Equals=="function"}Pe.isEquatable=vO;function Zy(n,e){return n}function bO(n){return n!=null}Pe.filterUndef=bO;});var ve=w(ba=>{Object.defineProperty(ba,"__esModule",{value:true});ba.ParsedObject=void 0;var Qy=oe(),Ah=class{constructor(){this._alreadyHadError=false,this._alreadyHadWarning=false,this._debugMetadata=null,this._runtimeObject=null,this.content=[],this.parent=null,this.GetType=()=>this.typeName,this.AddContent=e=>{this.content===null&&(this.content=[]);let t=Array.isArray(e)?e:[e];for(let r of t)r.hasOwnProperty("parent")&&(r.parent=this),this.content.push(r);if(!Array.isArray(e))return e},this.InsertContent=(e,t)=>(this.content===null&&(this.content=[]),t.parent=this,this.content.splice(e,0,t),t),this.Find=e=>(t=null)=>{let r=(0, Qy.asOrNull)(this,e);if(r!==null&&(t===null||t(r)===true))return r;if(this.content===null)return null;for(let i of this.content){let a=i.Find&&i.Find(e)(t);if(a)return a}return null},this.FindAll=e=>(t,r)=>{let i=Array.isArray(r)?r:[],a=(0, Qy.asOrNull)(this,e);if(a!==null&&(!t||t(a)===true)&&i.push(a),this.content===null)return [];for(let s of this.content)s.FindAll&&s.FindAll(e)(t,i);return i},this.Warning=(e,t=null)=>{this.Error(e,t,true);};}get debugMetadata(){return this._debugMetadata===null&&this.parent?this.parent.debugMetadata:this._debugMetadata}set debugMetadata(e){this._debugMetadata=e;}get hasOwnDebugMetadata(){return !!this.debugMetadata}get typeName(){return "ParsedObject"}get story(){let e=this;for(;e.parent;)e=e.parent;return e}get runtimeObject(){return this._runtimeObject||(this._runtimeObject=this.GenerateRuntimeObject(),this._runtimeObject&&(this._runtimeObject.debugMetadata=this.debugMetadata)),this._runtimeObject}set runtimeObject(e){this._runtimeObject=e;}get runtimePath(){if(!this.runtimeObject.path)throw new Error;return this.runtimeObject.path}get containerForCounting(){return this.runtimeObject}get ancestry(){let e=[],t=this.parent;for(;t;)e.push(t),t=t.parent;return e=e.reverse(),e}ResolveReferences(e){if(this.content!==null)for(let t of this.content)t.ResolveReferences(e);}Error(e,t=null,r=false){if(t===null&&(t=this),!(t._alreadyHadError&&!r||t._alreadyHadWarning&&r)){if(this.parent)this.parent.Error(e,t,r);else throw new Error(`No parent object to send error to: ${e}`);r?t._alreadyHadWarning=true:t._alreadyHadError=true;}}};ba.ParsedObject=Ah;});var Sa=w(Ca=>{Object.defineProperty(Ca,"__esModule",{value:true});Ca.AuthorWarning=void 0;var CO=ve(),Oh=class extends CO.ParsedObject{constructor(e){super(),this.warningMessage=e,this.GenerateRuntimeObject=()=>(this.Warning(this.warningMessage),null);}get typeName(){return "AuthorWarning"}};Ca.AuthorWarning=Oh;});var at=w($i=>{Object.defineProperty($i,"__esModule",{value:true});$i.Path=void 0;var xr=class n{constructor(){if(this._components=[],this._componentsString=null,this._isRelative=false,typeof arguments[0]=="string"){let e=arguments[0];this.componentsString=e;}else if(arguments[0]instanceof n.Component&&arguments[1]instanceof n){let e=arguments[0],t=arguments[1];this._components.push(e),this._components=this._components.concat(t._components);}else if(arguments[0]instanceof Array){let e=arguments[0],t=!!arguments[1];this._components=this._components.concat(e),this._isRelative=t;}}get isRelative(){return this._isRelative}get componentCount(){return this._components.length}get head(){return this._components.length>0?this._components[0]:null}get tail(){if(this._components.length>=2){let e=this._components.slice(1,this._components.length);return new n(e)}else return n.self}get length(){return this._components.length}get lastComponent(){let e=this._components.length-1;return e>=0?this._components[e]:null}get containsNamedComponent(){for(let e=0,t=this._components.length;e<t;e++)if(!this._components[e].isIndex)return true;return false}static get self(){let e=new n;return e._isRelative=true,e}GetComponent(e){return this._components[e]}PathByAppendingPath(e){let t=new n,r=0;for(let i=0;i<e._components.length&&e._components[i].isParent;++i)r++;for(let i=0;i<this._components.length-r;++i)t._components.push(this._components[i]);for(let i=r;i<e._components.length;++i)t._components.push(e._components[i]);return t}get componentsString(){return this._componentsString==null&&(this._componentsString=this._components.join("."),this.isRelative&&(this._componentsString="."+this._componentsString)),this._componentsString}set componentsString(e){if(this._components.length=0,this._componentsString=e,this._componentsString==null||this._componentsString=="")return;this._componentsString[0]=="."&&(this._isRelative=true,this._componentsString=this._componentsString.substring(1));let t=this._componentsString.split(".");for(let r of t)/^(\-|\+)?([0-9]+|Infinity)$/.test(r)?this._components.push(new n.Component(parseInt(r))):this._components.push(new n.Component(r));}toString(){return this.componentsString}Equals(e){if(e==null||e._components.length!=this._components.length||e.isRelative!=this.isRelative)return false;for(let t=0,r=e._components.length;t<r;t++)if(!e._components[t].Equals(this._components[t]))return false;return true}PathByAppendingComponent(e){let t=new n;return t._components.push(...this._components),t._components.push(e),t}};$i.Path=xr;xr.parentId="^";(function(n){class e{constructor(r){this.index=-1,this.name=null,typeof r=="string"?this.name=r:this.index=r;}get isIndex(){return this.index>=0}get isParent(){return this.name==n.parentId}static ToParent(){return new e(n.parentId)}toString(){return this.isIndex?this.index.toString():this.name}Equals(r){return r!=null&&r.isIndex==this.isIndex?this.isIndex?this.index==r.index:this.name==r.name:false}}n.Component=e;})(xr||($i.Path=xr={}));});var Li=w(_a=>{Object.defineProperty(_a,"__esModule",{value:true});_a.Debug=void 0;var ev;(function(n){function e(r,i,a){t(r instanceof i,a);}n.AssertType=e;function t(r,i){if(!r)throw typeof i<"u"&&console.warn(i),console.trace&&console.trace(),new Error("")}n.Assert=t;})(ev||(_a.Debug=ev={}));});var qe=w(Tr=>{Object.defineProperty(Tr,"__esModule",{value:true});Tr.throwNullException=Tr.NullException=void 0;var wa=class extends Error{};Tr.NullException=wa;function SO(n){throw new wa(`${n} is null or undefined`)}Tr.throwNullException=SO;});var ot=w(Da=>{Object.defineProperty(Da,"__esModule",{value:true});Da.InkObject=void 0;var Nr=at(),qi=Ee(),Ph=Li(),Fr=oe(),Ea=qe(),xh=class{constructor(){this.parent=null,this._debugMetadata=null,this._path=null;}get debugMetadata(){return this._debugMetadata===null&&this.parent?this.parent.debugMetadata:this._debugMetadata}set debugMetadata(e){this._debugMetadata=e;}get ownDebugMetadata(){return this._debugMetadata}DebugLineNumberOfPath(e){if(e===null)return null;let t=this.rootContentContainer;if(t){let r=t.ContentAtPath(e).obj;if(r){let i=r.debugMetadata;if(i!==null)return i.startLineNumber}}return null}get path(){if(this._path==null)if(this.parent==null)this._path=new Nr.Path;else {let e=[],t=this,r=(0, Fr.asOrNull)(t.parent,qi.Container);for(;r!==null;){let i=(0, Fr.asINamedContentOrNull)(t);if(i!=null&&i.hasValidName){if(i.name===null)return (0, Ea.throwNullException)("namedChild.name");e.unshift(new Nr.Path.Component(i.name));}else e.unshift(new Nr.Path.Component(r.content.indexOf(t)));t=r,r=(0, Fr.asOrNull)(r.parent,qi.Container);}this._path=new Nr.Path(e);}return this._path}ResolvePath(e){if(e===null)return (0, Ea.throwNullException)("path");if(e.isRelative){let t=(0, Fr.asOrNull)(this,qi.Container);return t===null&&(Ph.Debug.Assert(this.parent!==null,"Can't resolve relative path because we don't have a parent"),t=(0, Fr.asOrNull)(this.parent,qi.Container),Ph.Debug.Assert(t!==null,"Expected parent to be a container"),Ph.Debug.Assert(e.GetComponent(0).isParent),e=e.tail),t===null?(0, Ea.throwNullException)("nearestContainer"):t.ContentAtPath(e)}else {let t=this.rootContentContainer;return t===null?(0, Ea.throwNullException)("contentContainer"):t.ContentAtPath(e)}}ConvertPathToRelative(e){let t=this.path,r=Math.min(e.length,t.length),i=-1;for(let u=0;u<r;++u){let l=t.GetComponent(u),c=e.GetComponent(u);if(l.Equals(c))i=u;else break}if(i==-1)return e;let a=t.componentCount-1-i,s=[];for(let u=0;u<a;++u)s.push(Nr.Path.Component.ToParent());for(let u=i+1;u<e.componentCount;++u)s.push(e.GetComponent(u));return new Nr.Path(s,true)}CompactPathString(e){let t=null,r=null;return e.isRelative?(r=e.componentsString,t=this.path.PathByAppendingPath(e).componentsString):(r=this.ConvertPathToRelative(e).componentsString,t=e.componentsString),r.length<t.length?r:t}get rootContentContainer(){let e=this;for(;e.parent;)e=e.parent;return (0, Fr.asOrNull)(e,qi.Container)}Copy(){throw Error("Not Implemented: Doesn't support copying")}SetChild(e,t,r){e[t]&&(e[t]=null),e[t]=r,e[t]&&(e[t].parent=this);}Equals(e){return e===this}};Da.InkObject=xh;});var Un=w(Aa=>{Object.defineProperty(Aa,"__esModule",{value:true});Aa.StringBuilder=void 0;var Th=class{constructor(e){e=typeof e<"u"?e.toString():"",this.string=e;}get Length(){return this.string.length}Append(e){e!==null&&(this.string+=e);}AppendLine(e){typeof e<"u"&&this.Append(e),this.string+=`
|
|
9
|
+
`;}AppendFormat(e,...t){this.string+=e.replace(/{(\d+)}/g,(r,i)=>typeof t[i]<"u"?t[i]:r);}toString(){return this.string}Clear(){this.string="";}};Aa.StringBuilder=Th;});var lt=w(Ir=>{Object.defineProperty(Ir,"__esModule",{value:true});Ir.InkList=Ir.InkListItem=void 0;var qt=qe(),_O=Un(),ut=class n{constructor(){if(this.originName=null,this.itemName=null,typeof arguments[1]<"u"){let e=arguments[0],t=arguments[1];this.originName=e,this.itemName=t;}else if(arguments[0]){let t=arguments[0].toString().split(".");this.originName=t[0],this.itemName=t[1];}}static get Null(){return new n(null,null)}get isNull(){return this.originName==null&&this.itemName==null}get fullName(){return (this.originName!==null?this.originName:"?")+"."+this.itemName}toString(){return this.fullName}Equals(e){if(e instanceof n){let t=e;return t.itemName==this.itemName&&t.originName==this.originName}return false}copy(){return new n(this.originName,this.itemName)}serialized(){return JSON.stringify({originName:this.originName,itemName:this.itemName})}static fromSerializedKey(e){let t=JSON.parse(e);if(!n.isLikeInkListItem(t))return n.Null;let r=t;return new n(r.originName,r.itemName)}static isLikeInkListItem(e){return !(typeof e!="object"||!e.hasOwnProperty("originName")||!e.hasOwnProperty("itemName")||typeof e.originName!="string"&&typeof e.originName!==null||typeof e.itemName!="string"&&typeof e.itemName!==null)}};Ir.InkListItem=ut;var Nh=class n extends Map{constructor(){if(super(arguments[0]instanceof n?arguments[0]:[]),this.origins=null,this._originNames=[],arguments[0]instanceof n){let e=arguments[0],t=e.originNames;t!==null&&(this._originNames=t.slice()),e.origins!==null&&(this.origins=e.origins.slice());}else if(typeof arguments[0]=="string"){let e=arguments[0],t=arguments[1];if(this.SetInitialOriginName(e),t.listDefinitions===null)return (0, qt.throwNullException)("originStory.listDefinitions");let r=t.listDefinitions.TryListGetDefinition(e,null);if(r.exists){if(r.result===null)return (0, qt.throwNullException)("def.result");this.origins=[r.result];}else throw new Error("InkList origin could not be found in story when constructing new list: "+e)}else if(typeof arguments[0]=="object"&&arguments[0].hasOwnProperty("Key")&&arguments[0].hasOwnProperty("Value")){let e=arguments[0];this.Add(e.Key,e.Value);}}static FromString(e,t){var r;if(e==null||e=="")return new n;let i=(r=t.listDefinitions)===null||r===void 0?void 0:r.FindSingleItemListWithName(e);if(i)return i.value===null?(0, qt.throwNullException)("listValue.value"):new n(i.value);throw new Error("Could not find the InkListItem from the string '"+e+"' to create an InkList because it doesn't exist in the original list definition in ink.")}AddItem(e,t=null){if(e instanceof ut){let r=e;if(r.originName==null){this.AddItem(r.itemName);return}if(this.origins===null)return (0, qt.throwNullException)("this.origins");for(let i of this.origins)if(i.name==r.originName){let a=i.TryGetValueForItem(r,0);if(a.exists){this.Add(r,a.result);return}else throw new Error("Could not add the item "+r+" to this list because it doesn't exist in the original list definition in ink.")}throw new Error("Failed to add item to list because the item was from a new list definition that wasn't previously known to this list. Only items from previously known lists can be used, so that the int value can be found.")}else if(e!==null){let r=e,i=null;if(this.origins===null)return (0, qt.throwNullException)("this.origins");for(let a of this.origins){if(r===null)return (0, qt.throwNullException)("itemName");if(a.ContainsItemWithName(r)){if(i!=null)throw new Error("Could not add the item "+r+" to this list because it could come from either "+a.name+" or "+i.name);i=a;}}if(i==null){if(t==null)throw new Error("Could not add the item "+r+" to this list because it isn't known to any list definitions previously associated with this list.");{let a=n.FromString(r,t).orderedItems[0];this.Add(a.Key,a.Value);}}else {let a=new ut(i.name,r),s=i.ValueForItem(a);this.Add(a,s);}}}ContainsItemNamed(e){for(let[t]of this)if(ut.fromSerializedKey(t).itemName==e)return true;return false}ContainsKey(e){return this.has(e.serialized())}Add(e,t){let r=e.serialized();if(this.has(r))throw new Error(`The Map already contains an entry for ${e}`);this.set(r,t);}Remove(e){return this.delete(e.serialized())}get Count(){return this.size}get originOfMaxItem(){if(this.origins==null)return null;let e=this.maxItem.Key.originName,t=null;return this.origins.every(r=>r.name==e?(t=r,false):true),t}get originNames(){if(this.Count>0){this._originNames==null&&this.Count>0?this._originNames=[]:(this._originNames||(this._originNames=[]),this._originNames.length=0);for(let[e]of this){let t=ut.fromSerializedKey(e);if(t.originName===null)return (0, qt.throwNullException)("item.originName");this._originNames.push(t.originName);}}return this._originNames}SetInitialOriginName(e){this._originNames=[e];}SetInitialOriginNames(e){e==null?this._originNames=null:this._originNames=e.slice();}get maxItem(){let e={Key:ut.Null,Value:0};for(let[t,r]of this){let i=ut.fromSerializedKey(t);(e.Key.isNull||r>e.Value)&&(e={Key:i,Value:r});}return e}get minItem(){let e={Key:ut.Null,Value:0};for(let[t,r]of this){let i=ut.fromSerializedKey(t);(e.Key.isNull||r<e.Value)&&(e={Key:i,Value:r});}return e}get inverse(){let e=new n;if(this.origins!=null)for(let t of this.origins)for(let[r,i]of t.items){let a=ut.fromSerializedKey(r);this.ContainsKey(a)||e.Add(a,i);}return e}get all(){let e=new n;if(this.origins!=null)for(let t of this.origins)for(let[r,i]of t.items){let a=ut.fromSerializedKey(r);e.set(a.serialized(),i);}return e}Union(e){let t=new n(this);for(let[r,i]of e)t.set(r,i);return t}Intersect(e){let t=new n;for(let[r,i]of this)e.has(r)&&t.set(r,i);return t}HasIntersection(e){for(let[t]of this)if(e.has(t))return true;return false}Without(e){let t=new n(this);for(let[r]of e)t.delete(r);return t}Contains(e){if(typeof e=="string")return this.ContainsItemNamed(e);let t=e;if(t.size==0||this.size==0)return false;for(let[r]of t)if(!this.has(r))return false;return true}GreaterThan(e){return this.Count==0?false:e.Count==0?true:this.minItem.Value>e.maxItem.Value}GreaterThanOrEquals(e){return this.Count==0?false:e.Count==0?true:this.minItem.Value>=e.minItem.Value&&this.maxItem.Value>=e.maxItem.Value}LessThan(e){return e.Count==0?false:this.Count==0?true:this.maxItem.Value<e.minItem.Value}LessThanOrEquals(e){return e.Count==0?false:this.Count==0?true:this.maxItem.Value<=e.maxItem.Value&&this.minItem.Value<=e.minItem.Value}MaxAsList(){return this.Count>0?new n(this.maxItem):new n}MinAsList(){return this.Count>0?new n(this.minItem):new n}ListWithSubRange(e,t){if(this.Count==0)return new n;let r=this.orderedItems,i=0,a=Number.MAX_SAFE_INTEGER;Number.isInteger(e)?i=e:e instanceof n&&e.Count>0&&(i=e.minItem.Value),Number.isInteger(t)?a=t:t instanceof n&&t.Count>0&&(a=t.maxItem.Value);let s=new n;s.SetInitialOriginNames(this.originNames);for(let o of r)o.Value>=i&&o.Value<=a&&s.Add(o.Key,o.Value);return s}Equals(e){if(!(e instanceof n)||e.Count!=this.Count)return false;for(let[t]of this)if(!e.has(t))return false;return true}get orderedItems(){let e=new Array;for(let[t,r]of this){let i=ut.fromSerializedKey(t);e.push({Key:i,Value:r});}return e.sort((t,r)=>t.Key.originName===null?(0, qt.throwNullException)("x.Key.originName"):r.Key.originName===null?(0, qt.throwNullException)("y.Key.originName"):t.Value==r.Value?t.Key.originName.localeCompare(r.Key.originName):t.Value<r.Value?-1:t.Value>r.Value?1:0),e}get singleItem(){for(let e of this.orderedItems)return e.Key;return null}toString(){let e=this.orderedItems,t=new _O.StringBuilder;for(let r=0;r<e.length;r++){r>0&&t.Append(", ");let i=e[r].Key;if(i.itemName===null)return (0, qt.throwNullException)("item.itemName");t.Append(i.itemName);}return t.toString()}valueOf(){return NaN}};Ir.InkList=Nh;});var Bi=w(Oa=>{Object.defineProperty(Oa,"__esModule",{value:true});Oa.StoryException=void 0;var Fh=class extends Error{constructor(e){super(e),this.useEndLineNumber=false,this.message=e,this.name="StoryException";}};Oa.StoryException=Fh;});var kr=w(Cn=>{Object.defineProperty(Cn,"__esModule",{value:true});Cn.tryParseFloat=Cn.tryParseInt=Cn.tryGetValueFromMap=void 0;function wO(n,e,t){if(n===null)return {result:t,exists:false};let r=n.get(e);return typeof r>"u"?{result:t,exists:false}:{result:r,exists:true}}Cn.tryGetValueFromMap=wO;function EO(n,e=0){let t=parseInt(n);return Number.isNaN(t)?{result:e,exists:false}:{result:t,exists:true}}Cn.tryParseInt=EO;function DO(n,e=0){let t=parseFloat(n);return Number.isNaN(t)?{result:e,exists:false}:{result:t,exists:true}}Cn.tryParseFloat=DO;});var be=w(Ce=>{Object.defineProperty(Ce,"__esModule",{value:true});Ce.ValueType=Ce.ListValue=Ce.VariablePointerValue=Ce.DivertTargetValue=Ce.StringValue=Ce.FloatValue=Ce.IntValue=Ce.BoolValue=Ce.Value=Ce.AbstractValue=void 0;var tv=ot(),nv=at(),Kn=lt(),AO=Bi(),Wi=oe(),rv=kr(),Ct=qe(),Pa=class n extends tv.InkObject{static Create(e,t){if(t){if(t===ye.Int&&Number.isInteger(Number(e)))return new Wt(Number(e));if(t===ye.Float&&!isNaN(e))return new Mt(Number(e))}if(typeof e=="boolean")return new Vr(!!e);if(typeof e=="string")return new rn(String(e));if(Number.isInteger(Number(e)))return new Wt(Number(e));if(isNaN(e)){if(e instanceof nv.Path)return new xa((0, Wi.asOrThrows)(e,nv.Path));if(e instanceof Kn.InkList)return new Ta((0, Wi.asOrThrows)(e,Kn.InkList))}else return new Mt(Number(e));return null}Copy(){return (0, Wi.asOrThrows)(n.Create(this.valueObject),tv.InkObject)}BadCastException(e){return new AO.StoryException("Can't cast "+this.valueObject+" from "+this.valueType+" to "+e)}};Ce.AbstractValue=Pa;var Bt=class extends Pa{constructor(e){super(),this.value=e;}get valueObject(){return this.value}toString(){return this.value===null?(0, Ct.throwNullException)("Value.value"):this.value.toString()}};Ce.Value=Bt;var Vr=class extends Bt{constructor(e){super(e||false);}get isTruthy(){return !!this.value}get valueType(){return ye.Bool}Cast(e){if(this.value===null)return (0, Ct.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==ye.Int)return new Wt(this.value?1:0);if(e==ye.Float)return new Mt(this.value?1:0);if(e==ye.String)return new rn(this.value?"true":"false");throw this.BadCastException(e)}toString(){return this.value?"true":"false"}};Ce.BoolValue=Vr;var Wt=class extends Bt{constructor(e){super(e||0);}get isTruthy(){return this.value!=0}get valueType(){return ye.Int}Cast(e){if(this.value===null)return (0, Ct.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==ye.Bool)return new Vr(this.value!==0);if(e==ye.Float)return new Mt(this.value);if(e==ye.String)return new rn(""+this.value);throw this.BadCastException(e)}};Ce.IntValue=Wt;var Mt=class extends Bt{constructor(e){super(e||0);}get isTruthy(){return this.value!=0}get valueType(){return ye.Float}Cast(e){if(this.value===null)return (0, Ct.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==ye.Bool)return new Vr(this.value!==0);if(e==ye.Int)return new Wt(this.value);if(e==ye.String)return new rn(""+this.value);throw this.BadCastException(e)}};Ce.FloatValue=Mt;var rn=class extends Bt{constructor(e){if(super(e||""),this._isNewline=this.value==`
|
|
10
|
+
`,this._isInlineWhitespace=true,this.value===null)return (0, Ct.throwNullException)("Value.value");this.value.length>0&&this.value.split("").every(t=>t!=" "&&t!=" "?(this._isInlineWhitespace=false,false):true);}get valueType(){return ye.String}get isTruthy(){return this.value===null?(0, Ct.throwNullException)("Value.value"):this.value.length>0}get isNewline(){return this._isNewline}get isInlineWhitespace(){return this._isInlineWhitespace}get isNonWhitespace(){return !this.isNewline&&!this.isInlineWhitespace}Cast(e){if(e==this.valueType)return this;if(e==ye.Int){let t=(0, rv.tryParseInt)(this.value);if(t.exists)return new Wt(t.result);throw this.BadCastException(e)}if(e==ye.Float){let t=(0, rv.tryParseFloat)(this.value);if(t.exists)return new Mt(t.result);throw this.BadCastException(e)}throw this.BadCastException(e)}};Ce.StringValue=rn;var xa=class extends Bt{constructor(e=null){super(e);}get valueType(){return ye.DivertTarget}get targetPath(){return this.value===null?(0, Ct.throwNullException)("Value.value"):this.value}set targetPath(e){this.value=e;}get isTruthy(){throw new Error("Shouldn't be checking the truthiness of a divert target")}Cast(e){if(e==this.valueType)return this;throw this.BadCastException(e)}toString(){return "DivertTargetValue("+this.targetPath+")"}};Ce.DivertTargetValue=xa;var Ih=class n extends Bt{constructor(e,t=-1){super(e),this._contextIndex=t;}get contextIndex(){return this._contextIndex}set contextIndex(e){this._contextIndex=e;}get variableName(){return this.value===null?(0, Ct.throwNullException)("Value.value"):this.value}set variableName(e){this.value=e;}get valueType(){return ye.VariablePointer}get isTruthy(){throw new Error("Shouldn't be checking the truthiness of a variable pointer")}Cast(e){if(e==this.valueType)return this;throw this.BadCastException(e)}toString(){return "VariablePointerValue("+this.variableName+")"}Copy(){return new n(this.variableName,this.contextIndex)}};Ce.VariablePointerValue=Ih;var Ta=class n extends Bt{get isTruthy(){return this.value===null?(0, Ct.throwNullException)("this.value"):this.value.Count>0}get valueType(){return ye.List}Cast(e){if(this.value===null)return (0, Ct.throwNullException)("Value.value");if(e==ye.Int){let t=this.value.maxItem;return t.Key.isNull?new Wt(0):new Wt(t.Value)}else if(e==ye.Float){let t=this.value.maxItem;return t.Key.isNull?new Mt(0):new Mt(t.Value)}else if(e==ye.String){let t=this.value.maxItem;return t.Key.isNull?new rn(""):new rn(t.Key.toString())}if(e==this.valueType)return this;throw this.BadCastException(e)}constructor(e,t){super(null),!e&&!t?this.value=new Kn.InkList:e instanceof Kn.InkList?this.value=new Kn.InkList(e):e instanceof Kn.InkListItem&&typeof t=="number"&&(this.value=new Kn.InkList({Key:e,Value:t}));}static RetainListOriginsForAssignment(e,t){let r=(0, Wi.asOrNull)(e,n),i=(0, Wi.asOrNull)(t,n);if(i&&i.value===null)return (0, Ct.throwNullException)("newList.value");if(r&&r.value===null)return (0, Ct.throwNullException)("oldList.value");r&&i&&i.value.Count==0&&i.value.SetInitialOriginNames(r.value.originNames);}};Ce.ListValue=Ta;var ye;(function(n){n[n.Bool=-1]="Bool",n[n.Int=0]="Int",n[n.Float=1]="Float",n[n.List=2]="List",n[n.String=3]="String",n[n.DivertTarget=4]="DivertTarget",n[n.VariablePointer=5]="VariablePointer";})(ye||(Ce.ValueType=ye={}));});var iv=w(Na=>{Object.defineProperty(Na,"__esModule",{value:true});Na.SearchResult=void 0;var OO=Ee(),kh=class n{constructor(){this.obj=null,this.approximate=false;}get correctObj(){return this.approximate?null:this.obj}get container(){return this.obj instanceof OO.Container?this.obj:null}copy(){let e=new n;return e.obj=this.obj,e.approximate=this.approximate,e}};Na.SearchResult=kh;});var Ee=w(Gi=>{Object.defineProperty(Gi,"__esModule",{value:true});Gi.Container=void 0;var PO=be(),sv=qe(),xO=Un(),Rr=ot(),TO=iv(),av=at(),ov=Li(),NO=kr(),Sn=oe(),Mi=class n extends Rr.InkObject{constructor(){super(...arguments),this.name=null,this._content=[],this.namedContent=new Map,this.visitsShouldBeCounted=false,this.turnIndexShouldBeCounted=false,this.countingAtStartOnly=false,this._pathToFirstLeafContent=null;}get hasValidName(){return this.name!=null&&this.name.length>0}get content(){return this._content}set content(e){this.AddContent(e);}get namedOnlyContent(){let e=new Map;for(let[t,r]of this.namedContent){let i=(0, Sn.asOrThrows)(r,Rr.InkObject);e.set(t,i);}for(let t of this.content){let r=(0, Sn.asINamedContentOrNull)(t);r!=null&&r.hasValidName&&e.delete(r.name);}return e.size==0&&(e=null),e}set namedOnlyContent(e){let t=this.namedOnlyContent;if(t!=null)for(let[r]of t)this.namedContent.delete(r);if(e!=null)for(let[,r]of e){let i=(0, Sn.asINamedContentOrNull)(r);i!=null&&this.AddToNamedContentOnly(i);}}get countFlags(){let e=0;return this.visitsShouldBeCounted&&(e|=n.CountFlags.Visits),this.turnIndexShouldBeCounted&&(e|=n.CountFlags.Turns),this.countingAtStartOnly&&(e|=n.CountFlags.CountStartOnly),e==n.CountFlags.CountStartOnly&&(e=0),e}set countFlags(e){let t=e;(t&n.CountFlags.Visits)>0&&(this.visitsShouldBeCounted=true),(t&n.CountFlags.Turns)>0&&(this.turnIndexShouldBeCounted=true),(t&n.CountFlags.CountStartOnly)>0&&(this.countingAtStartOnly=true);}get pathToFirstLeafContent(){return this._pathToFirstLeafContent==null&&(this._pathToFirstLeafContent=this.path.PathByAppendingPath(this.internalPathToFirstLeafContent)),this._pathToFirstLeafContent}get internalPathToFirstLeafContent(){let e=[],t=this;for(;t instanceof n;)t.content.length>0&&(e.push(new av.Path.Component(0)),t=t.content[0]);return new av.Path(e)}AddContent(e){if(e instanceof Array){let t=e;for(let r of t)this.AddContent(r);}else {let t=e;if(this._content.push(t),t.parent)throw new Error("content is already in "+t.parent);t.parent=this,this.TryAddNamedContent(t);}}TryAddNamedContent(e){let t=(0, Sn.asINamedContentOrNull)(e);t!=null&&t.hasValidName&&this.AddToNamedContentOnly(t);}AddToNamedContentOnly(e){ov.Debug.AssertType(e,Rr.InkObject,"Can only add Runtime.Objects to a Runtime.Container");let t=(0, Sn.asOrThrows)(e,Rr.InkObject);if(t.parent=this,e.name===null)return (0, sv.throwNullException)("namedContentObj.name");this.namedContent.set(e.name,e);}ContentAtPath(e,t=0,r=-1){r==-1&&(r=e.length);let i=new TO.SearchResult;i.approximate=false;let a=this,s=this;for(let o=t;o<r;++o){let u=e.GetComponent(o);if(a==null){i.approximate=true;break}let l=a.ContentWithPathComponent(u);if(l==null){i.approximate=true;break}let c=(0, Sn.asOrNull)(l,n);if(o<r-1&&c==null){i.approximate=true;break}s=l,a=c;}return i.obj=s,i}InsertContent(e,t){if(this.content.splice(t,0,e),e.parent)throw new Error("content is already in "+e.parent);e.parent=this,this.TryAddNamedContent(e);}AddContentsOfContainer(e){this.content.push(...e.content);for(let t of e.content)t.parent=this,this.TryAddNamedContent(t);}ContentWithPathComponent(e){if(e.isIndex)return e.index>=0&&e.index<this.content.length?this.content[e.index]:null;if(e.isParent)return this.parent;{if(e.name===null)return (0, sv.throwNullException)("component.name");let t=(0, NO.tryGetValueFromMap)(this.namedContent,e.name,null);return t.exists?(0, Sn.asOrThrows)(t.result,Rr.InkObject):null}}BuildStringOfHierarchy(){let e;if(arguments.length==0)return e=new xO.StringBuilder,this.BuildStringOfHierarchy(e,0,null),e.toString();e=arguments[0];let t=arguments[1],r=arguments[2];function i(){for(let o=0;o<4*t;++o)e.Append(" ");}i(),e.Append("["),this.hasValidName&&e.AppendFormat(" ({0})",this.name),this==r&&e.Append(" <---"),e.AppendLine(),t++;for(let s=0;s<this.content.length;++s){let o=this.content[s];o instanceof n?o.BuildStringOfHierarchy(e,t,r):(i(),o instanceof PO.StringValue?(e.Append('"'),e.Append(o.toString().replace(`
|
|
11
|
+
`,"\\n")),e.Append('"')):e.Append(o.toString())),s!=this.content.length-1&&e.Append(","),!(o instanceof n)&&o==r&&e.Append(" <---"),e.AppendLine();}let a=new Map;for(let[s,o]of this.namedContent)this.content.indexOf((0, Sn.asOrThrows)(o,Rr.InkObject))>=0||a.set(s,o);if(a.size>0){i(),e.AppendLine("-- named: --");for(let[,s]of a)ov.Debug.AssertType(s,n,"Can only print out named Containers"),s.BuildStringOfHierarchy(e,t,r),e.AppendLine();}t--,i(),e.Append("]");}};Gi.Container=Mi;(function(n){(function(t){t[t.Start=0]="Start",t[t.Visits=1]="Visits",t[t.Turns=2]="Turns",t[t.CountStartOnly=4]="CountStartOnly";})(n.CountFlags||(n.CountFlags={}));})(Mi||(Gi.Container=Mi={}));});var Be=w(Ji=>{Object.defineProperty(Ji,"__esModule",{value:true});Ji.ControlCommand=void 0;var FO=ot(),zi=class n extends FO.InkObject{get commandType(){return this._commandType}constructor(e=n.CommandType.NotSet){super(),this._commandType=e;}Copy(){return new n(this.commandType)}static EvalStart(){return new n(n.CommandType.EvalStart)}static EvalOutput(){return new n(n.CommandType.EvalOutput)}static EvalEnd(){return new n(n.CommandType.EvalEnd)}static Duplicate(){return new n(n.CommandType.Duplicate)}static PopEvaluatedValue(){return new n(n.CommandType.PopEvaluatedValue)}static PopFunction(){return new n(n.CommandType.PopFunction)}static PopTunnel(){return new n(n.CommandType.PopTunnel)}static BeginString(){return new n(n.CommandType.BeginString)}static EndString(){return new n(n.CommandType.EndString)}static NoOp(){return new n(n.CommandType.NoOp)}static ChoiceCount(){return new n(n.CommandType.ChoiceCount)}static Turns(){return new n(n.CommandType.Turns)}static TurnsSince(){return new n(n.CommandType.TurnsSince)}static ReadCount(){return new n(n.CommandType.ReadCount)}static Random(){return new n(n.CommandType.Random)}static SeedRandom(){return new n(n.CommandType.SeedRandom)}static VisitIndex(){return new n(n.CommandType.VisitIndex)}static SequenceShuffleIndex(){return new n(n.CommandType.SequenceShuffleIndex)}static StartThread(){return new n(n.CommandType.StartThread)}static Done(){return new n(n.CommandType.Done)}static End(){return new n(n.CommandType.End)}static ListFromInt(){return new n(n.CommandType.ListFromInt)}static ListRange(){return new n(n.CommandType.ListRange)}static ListRandom(){return new n(n.CommandType.ListRandom)}static BeginTag(){return new n(n.CommandType.BeginTag)}static EndTag(){return new n(n.CommandType.EndTag)}toString(){return "ControlCommand "+this.commandType.toString()}};Ji.ControlCommand=zi;(function(n){(function(t){t[t.NotSet=-1]="NotSet",t[t.EvalStart=0]="EvalStart",t[t.EvalOutput=1]="EvalOutput",t[t.EvalEnd=2]="EvalEnd",t[t.Duplicate=3]="Duplicate",t[t.PopEvaluatedValue=4]="PopEvaluatedValue",t[t.PopFunction=5]="PopFunction",t[t.PopTunnel=6]="PopTunnel",t[t.BeginString=7]="BeginString",t[t.EndString=8]="EndString",t[t.NoOp=9]="NoOp",t[t.ChoiceCount=10]="ChoiceCount",t[t.Turns=11]="Turns",t[t.TurnsSince=12]="TurnsSince",t[t.ReadCount=13]="ReadCount",t[t.Random=14]="Random",t[t.SeedRandom=15]="SeedRandom",t[t.VisitIndex=16]="VisitIndex",t[t.SequenceShuffleIndex=17]="SequenceShuffleIndex",t[t.StartThread=18]="StartThread",t[t.Done=19]="Done",t[t.End=20]="End",t[t.ListFromInt=21]="ListFromInt",t[t.ListRange=22]="ListRange",t[t.ListRandom=23]="ListRandom",t[t.BeginTag=24]="BeginTag",t[t.EndTag=25]="EndTag",t[t.TOTAL_VALUES=26]="TOTAL_VALUES";})(n.CommandType||(n.CommandType={}));})(zi||(Ji.ControlCommand=zi={}));});var St=w(Fa=>{Object.defineProperty(Fa,"__esModule",{value:true});Fa.Expression=void 0;var uv=Ee(),Vh=Be(),IO=ve(),Rh=class extends IO.ParsedObject{constructor(){super(...arguments),this._prototypeRuntimeConstantExpression=null,this.outputWhenComplete=false,this.GenerateRuntimeObject=()=>{let e=new uv.Container;return e.AddContent(Vh.ControlCommand.EvalStart()),this.GenerateIntoContainer(e),this.outputWhenComplete&&e.AddContent(Vh.ControlCommand.EvalOutput()),e.AddContent(Vh.ControlCommand.EvalEnd()),e},this.GenerateConstantIntoContainer=e=>{this._prototypeRuntimeConstantExpression===null&&(this._prototypeRuntimeConstantExpression=new uv.Container,this.GenerateIntoContainer(this._prototypeRuntimeConstantExpression));for(let t of this._prototypeRuntimeConstantExpression.content){let r=t.Copy();r&&e.AddContent(r);}},this.toString=()=>"No string value in JavaScript.";}get typeName(){return "Expression"}Equals(e){return false}};Fa.Expression=Rh;});var Xn=w(Ia=>{Object.defineProperty(Ia,"__esModule",{value:true});Ia.Void=void 0;var kO=ot(),jh=class extends kO.InkObject{toString(){return "Void"}};Ia.Void=jh;});var Gt=w(Va=>{Object.defineProperty(Va,"__esModule",{value:true});Va.NativeFunctionCall=void 0;var F=be(),Hi=Bi(),VO=Xn(),ka=lt(),RO=ot(),_t=oe(),ct=qe(),K=class n extends RO.InkObject{static CallWithName(e){return new n(e)}static CallExistsWithName(e){return this.GenerateNativeFunctionsIfNecessary(),this._nativeFunctions.get(e)}get name(){return this._name===null?(0, ct.throwNullException)("NativeFunctionCall._name"):this._name}set name(e){this._name=e,this._isPrototype||(n._nativeFunctions===null?(0, ct.throwNullException)("NativeFunctionCall._nativeFunctions"):this._prototype=n._nativeFunctions.get(this._name)||null);}get numberOfParameters(){return this._prototype?this._prototype.numberOfParameters:this._numberOfParameters}set numberOfParameters(e){this._numberOfParameters=e;}Call(e){if(this._prototype)return this._prototype.Call(e);if(this.numberOfParameters!=e.length)throw new Error("Unexpected number of parameters");let t=false;for(let a of e){if(a instanceof VO.Void)throw new Hi.StoryException("Attempting to perform "+this.name+' on a void value. Did you forget to "return" a value from a function you called here?');a instanceof F.ListValue&&(t=true);}if(e.length==2&&t)return this.CallBinaryListOperation(e);let r=this.CoerceValuesToSingleType(e),i=r[0].valueType;return i==F.ValueType.Int?this.CallType(r):i==F.ValueType.Float?this.CallType(r):i==F.ValueType.String?this.CallType(r):i==F.ValueType.DivertTarget?this.CallType(r):i==F.ValueType.List?this.CallType(r):null}CallType(e){let t=(0, _t.asOrThrows)(e[0],F.Value),r=t.valueType,i=t,a=e.length;if(a==2||a==1){if(this._operationFuncs===null)return (0, ct.throwNullException)("NativeFunctionCall._operationFuncs");let s=this._operationFuncs.get(r);if(!s){let o=F.ValueType[r];throw new Hi.StoryException("Cannot perform operation "+this.name+" on "+o)}if(a==2){let u=(0, _t.asOrThrows)(e[1],F.Value),l=s;if(i.value===null||u.value===null)return (0, ct.throwNullException)("NativeFunctionCall.Call BinaryOp values");let c=l(i.value,u.value);return F.Value.Create(c)}else {let o=s;if(i.value===null)return (0, ct.throwNullException)("NativeFunctionCall.Call UnaryOp value");let u=o(i.value);return this.name===n.Int?F.Value.Create(u,F.ValueType.Int):this.name===n.Float?F.Value.Create(u,F.ValueType.Float):F.Value.Create(u,t.valueType)}}else throw new Error("Unexpected number of parameters to NativeFunctionCall: "+e.length)}CallBinaryListOperation(e){if((this.name=="+"||this.name=="-")&&e[0]instanceof F.ListValue&&e[1]instanceof F.IntValue)return this.CallListIncrementOperation(e);let t=(0, _t.asOrThrows)(e[0],F.Value),r=(0, _t.asOrThrows)(e[1],F.Value);if((this.name=="&&"||this.name=="||")&&(t.valueType!=F.ValueType.List||r.valueType!=F.ValueType.List)){if(this._operationFuncs===null)return (0, ct.throwNullException)("NativeFunctionCall._operationFuncs");let i=this._operationFuncs.get(F.ValueType.Int);if(i===null)return (0, ct.throwNullException)("NativeFunctionCall.CallBinaryListOperation op");let a=(0, _t.asBooleanOrThrows)(i(t.isTruthy?1:0,r.isTruthy?1:0));return new F.BoolValue(a)}if(t.valueType==F.ValueType.List&&r.valueType==F.ValueType.List)return this.CallType([t,r]);throw new Hi.StoryException("Can not call use "+this.name+" operation on "+F.ValueType[t.valueType]+" and "+F.ValueType[r.valueType])}CallListIncrementOperation(e){let t=(0, _t.asOrThrows)(e[0],F.ListValue),r=(0, _t.asOrThrows)(e[1],F.IntValue),i=new ka.InkList;if(t.value===null)return (0, ct.throwNullException)("NativeFunctionCall.CallListIncrementOperation listVal.value");for(let[a,s]of t.value){let o=ka.InkListItem.fromSerializedKey(a);if(this._operationFuncs===null)return (0, ct.throwNullException)("NativeFunctionCall._operationFuncs");let u=this._operationFuncs.get(F.ValueType.Int);if(r.value===null)return (0, ct.throwNullException)("NativeFunctionCall.CallListIncrementOperation intVal.value");let l=u(s,r.value),c=null;if(t.value.origins===null)return (0, ct.throwNullException)("NativeFunctionCall.CallListIncrementOperation listVal.value.origins");for(let h of t.value.origins)if(h.name==o.originName){c=h;break}if(c!=null){let h=c.TryGetItemWithValue(l,ka.InkListItem.Null);h.exists&&i.Add(h.result,l);}}return new F.ListValue(i)}CoerceValuesToSingleType(e){let t=F.ValueType.Int,r=null;for(let a of e){let s=(0, _t.asOrThrows)(a,F.Value);s.valueType>t&&(t=s.valueType),s.valueType==F.ValueType.List&&(r=(0, _t.asOrNull)(s,F.ListValue));}let i=[];if(F.ValueType[t]==F.ValueType[F.ValueType.List])for(let a of e){let s=(0, _t.asOrThrows)(a,F.Value);if(s.valueType==F.ValueType.List)i.push(s);else if(s.valueType==F.ValueType.Int){let o=parseInt(s.valueObject);if(r=(0, _t.asOrThrows)(r,F.ListValue),r.value===null)return (0, ct.throwNullException)("NativeFunctionCall.CoerceValuesToSingleType specialCaseList.value");let u=r.value.originOfMaxItem;if(u===null)return (0, ct.throwNullException)("NativeFunctionCall.CoerceValuesToSingleType list");let l=u.TryGetItemWithValue(o,ka.InkListItem.Null);if(l.exists){let c=new F.ListValue(l.result,o);i.push(c);}else throw new Hi.StoryException("Could not find List item with the value "+o+" in "+u.name)}else {let o=F.ValueType[s.valueType];throw new Hi.StoryException("Cannot mix Lists and "+o+" values in this operation")}}else for(let a of e){let o=(0, _t.asOrThrows)(a,F.Value).Cast(t);i.push(o);}return i}constructor(){if(super(),this._name=null,this._numberOfParameters=0,this._prototype=null,this._isPrototype=false,this._operationFuncs=null,arguments.length===0)n.GenerateNativeFunctionsIfNecessary();else if(arguments.length===1){let e=arguments[0];n.GenerateNativeFunctionsIfNecessary(),this.name=e;}else if(arguments.length===2){let e=arguments[0],t=arguments[1];this._isPrototype=true,this.name=e,this.numberOfParameters=t;}}static Identity(e){return e}static GenerateNativeFunctionsIfNecessary(){if(this._nativeFunctions==null){this._nativeFunctions=new Map,this.AddIntBinaryOp(this.Add,(r,i)=>r+i),this.AddIntBinaryOp(this.Subtract,(r,i)=>r-i),this.AddIntBinaryOp(this.Multiply,(r,i)=>r*i),this.AddIntBinaryOp(this.Divide,(r,i)=>Math.floor(r/i)),this.AddIntBinaryOp(this.Mod,(r,i)=>r%i),this.AddIntUnaryOp(this.Negate,r=>-r),this.AddIntBinaryOp(this.Equal,(r,i)=>r==i),this.AddIntBinaryOp(this.Greater,(r,i)=>r>i),this.AddIntBinaryOp(this.Less,(r,i)=>r<i),this.AddIntBinaryOp(this.GreaterThanOrEquals,(r,i)=>r>=i),this.AddIntBinaryOp(this.LessThanOrEquals,(r,i)=>r<=i),this.AddIntBinaryOp(this.NotEquals,(r,i)=>r!=i),this.AddIntUnaryOp(this.Not,r=>r==0),this.AddIntBinaryOp(this.And,(r,i)=>r!=0&&i!=0),this.AddIntBinaryOp(this.Or,(r,i)=>r!=0||i!=0),this.AddIntBinaryOp(this.Max,(r,i)=>Math.max(r,i)),this.AddIntBinaryOp(this.Min,(r,i)=>Math.min(r,i)),this.AddIntBinaryOp(this.Pow,(r,i)=>Math.pow(r,i)),this.AddIntUnaryOp(this.Floor,n.Identity),this.AddIntUnaryOp(this.Ceiling,n.Identity),this.AddIntUnaryOp(this.Int,n.Identity),this.AddIntUnaryOp(this.Float,r=>r),this.AddFloatBinaryOp(this.Add,(r,i)=>r+i),this.AddFloatBinaryOp(this.Subtract,(r,i)=>r-i),this.AddFloatBinaryOp(this.Multiply,(r,i)=>r*i),this.AddFloatBinaryOp(this.Divide,(r,i)=>r/i),this.AddFloatBinaryOp(this.Mod,(r,i)=>r%i),this.AddFloatUnaryOp(this.Negate,r=>-r),this.AddFloatBinaryOp(this.Equal,(r,i)=>r==i),this.AddFloatBinaryOp(this.Greater,(r,i)=>r>i),this.AddFloatBinaryOp(this.Less,(r,i)=>r<i),this.AddFloatBinaryOp(this.GreaterThanOrEquals,(r,i)=>r>=i),this.AddFloatBinaryOp(this.LessThanOrEquals,(r,i)=>r<=i),this.AddFloatBinaryOp(this.NotEquals,(r,i)=>r!=i),this.AddFloatUnaryOp(this.Not,r=>r==0),this.AddFloatBinaryOp(this.And,(r,i)=>r!=0&&i!=0),this.AddFloatBinaryOp(this.Or,(r,i)=>r!=0||i!=0),this.AddFloatBinaryOp(this.Max,(r,i)=>Math.max(r,i)),this.AddFloatBinaryOp(this.Min,(r,i)=>Math.min(r,i)),this.AddFloatBinaryOp(this.Pow,(r,i)=>Math.pow(r,i)),this.AddFloatUnaryOp(this.Floor,r=>Math.floor(r)),this.AddFloatUnaryOp(this.Ceiling,r=>Math.ceil(r)),this.AddFloatUnaryOp(this.Int,r=>Math.floor(r)),this.AddFloatUnaryOp(this.Float,n.Identity),this.AddStringBinaryOp(this.Add,(r,i)=>r+i),this.AddStringBinaryOp(this.Equal,(r,i)=>r===i),this.AddStringBinaryOp(this.NotEquals,(r,i)=>r!==i),this.AddStringBinaryOp(this.Has,(r,i)=>r.includes(i)),this.AddStringBinaryOp(this.Hasnt,(r,i)=>!r.includes(i)),this.AddListBinaryOp(this.Add,(r,i)=>r.Union(i)),this.AddListBinaryOp(this.Subtract,(r,i)=>r.Without(i)),this.AddListBinaryOp(this.Has,(r,i)=>r.Contains(i)),this.AddListBinaryOp(this.Hasnt,(r,i)=>!r.Contains(i)),this.AddListBinaryOp(this.Intersect,(r,i)=>r.Intersect(i)),this.AddListBinaryOp(this.Equal,(r,i)=>r.Equals(i)),this.AddListBinaryOp(this.Greater,(r,i)=>r.GreaterThan(i)),this.AddListBinaryOp(this.Less,(r,i)=>r.LessThan(i)),this.AddListBinaryOp(this.GreaterThanOrEquals,(r,i)=>r.GreaterThanOrEquals(i)),this.AddListBinaryOp(this.LessThanOrEquals,(r,i)=>r.LessThanOrEquals(i)),this.AddListBinaryOp(this.NotEquals,(r,i)=>!r.Equals(i)),this.AddListBinaryOp(this.And,(r,i)=>r.Count>0&&i.Count>0),this.AddListBinaryOp(this.Or,(r,i)=>r.Count>0||i.Count>0),this.AddListUnaryOp(this.Not,r=>r.Count==0?1:0),this.AddListUnaryOp(this.Invert,r=>r.inverse),this.AddListUnaryOp(this.All,r=>r.all),this.AddListUnaryOp(this.ListMin,r=>r.MinAsList()),this.AddListUnaryOp(this.ListMax,r=>r.MaxAsList()),this.AddListUnaryOp(this.Count,r=>r.Count),this.AddListUnaryOp(this.ValueOfList,r=>r.maxItem.Value);let e=(r,i)=>r.Equals(i),t=(r,i)=>!r.Equals(i);this.AddOpToNativeFunc(this.Equal,2,F.ValueType.DivertTarget,e),this.AddOpToNativeFunc(this.NotEquals,2,F.ValueType.DivertTarget,t);}}AddOpFuncForType(e,t){this._operationFuncs==null&&(this._operationFuncs=new Map),this._operationFuncs.set(e,t);}static AddOpToNativeFunc(e,t,r,i){if(this._nativeFunctions===null)return (0, ct.throwNullException)("NativeFunctionCall._nativeFunctions");let a=this._nativeFunctions.get(e);a||(a=new n(e,t),this._nativeFunctions.set(e,a)),a.AddOpFuncForType(r,i);}static AddIntBinaryOp(e,t){this.AddOpToNativeFunc(e,2,F.ValueType.Int,t);}static AddIntUnaryOp(e,t){this.AddOpToNativeFunc(e,1,F.ValueType.Int,t);}static AddFloatBinaryOp(e,t){this.AddOpToNativeFunc(e,2,F.ValueType.Float,t);}static AddFloatUnaryOp(e,t){this.AddOpToNativeFunc(e,1,F.ValueType.Float,t);}static AddStringBinaryOp(e,t){this.AddOpToNativeFunc(e,2,F.ValueType.String,t);}static AddListBinaryOp(e,t){this.AddOpToNativeFunc(e,2,F.ValueType.List,t);}static AddListUnaryOp(e,t){this.AddOpToNativeFunc(e,1,F.ValueType.List,t);}toString(){return 'Native "'+this.name+'"'}};Va.NativeFunctionCall=K;K.Add="+";K.Subtract="-";K.Divide="/";K.Multiply="*";K.Mod="%";K.Negate="_";K.Equal="==";K.Greater=">";K.Less="<";K.GreaterThanOrEquals=">=";K.LessThanOrEquals="<=";K.NotEquals="!=";K.Not="!";K.And="&&";K.Or="||";K.Min="MIN";K.Max="MAX";K.Pow="POW";K.Floor="FLOOR";K.Ceiling="CEILING";K.Int="INT";K.Float="FLOAT";K.Has="?";K.Hasnt="!?";K.Intersect="^";K.ListMin="LIST_MIN";K.ListMax="LIST_MAX";K.All="LIST_ALL";K.Count="LIST_COUNT";K.ValueOfList="LIST_VALUE";K.Invert="LIST_INVERT";K._nativeFunctions=null;});var ja=w(Ra=>{Object.defineProperty(Ra,"__esModule",{value:true});Ra.NumberExpression=void 0;var jO=St(),$h=be(),$O=oe(),Lh=class n extends jO.Expression{constructor(e,t){if(super(),this.isInt=()=>this.subtype=="int",this.isFloat=()=>this.subtype=="float",this.isBool=()=>this.subtype=="bool",this.GenerateIntoContainer=r=>{this.isInt()?r.AddContent(new $h.IntValue(this.value)):this.isFloat()?r.AddContent(new $h.FloatValue(this.value)):this.isBool()&&r.AddContent(new $h.BoolValue(this.value));},this.toString=()=>String(this.value),typeof e=="number"&&!Number.isNaN(e)||typeof e=="boolean")this.value=e,this.subtype=t;else throw new Error("Unexpected object type in NumberExpression.")}get typeName(){return "Number"}Equals(e){let t=(0, $O.asOrNull)(e,n);return t?t.subtype==this.subtype&&t.value==this.value:false}};Ra.NumberExpression=Lh;});var qh=w($a=>{Object.defineProperty($a,"__esModule",{value:true});$a.UnaryExpression=void 0;var LO=St(),qO=Gt(),jr=ja(),BO=oe(),Ui=class extends LO.Expression{get nativeNameForOp(){return this.op==="-"?"_":this.op==="not"?"!":this.op}constructor(e,t){super(),this.op=t,this.GenerateIntoContainer=r=>{this.innerExpression.GenerateIntoContainer(r),r.AddContent(qO.NativeFunctionCall.CallWithName(this.nativeNameForOp));},this.toString=()=>this.nativeNameForOp+this.innerExpression,this.innerExpression=this.AddContent(e);}get typeName(){return "UnaryExpression"}};$a.UnaryExpression=Ui;Ui.WithInner=(n,e)=>{let t=(0, BO.asOrNull)(n,jr.NumberExpression);if(t){if(e==="-"){if(t.isInt())return new jr.NumberExpression(-t.value,"int");if(t.isFloat())return new jr.NumberExpression(-t.value,"float")}else if(e=="!"||e=="not"){if(t.isInt())return new jr.NumberExpression(t.value==0,"bool");if(t.isFloat())return new jr.NumberExpression(t.value==0,"bool");if(t.isBool())return new jr.NumberExpression(!t.value,"bool")}throw new Error("Unexpected operation or number type")}return new Ui(n,e)};});var Wh=w(La=>{Object.defineProperty(La,"__esModule",{value:true});La.BinaryExpression=void 0;var WO=St(),MO=Gt(),GO=qh(),zO=oe(),Bh=class extends WO.Expression{constructor(e,t,r){super(),this.opName=r,this.GenerateIntoContainer=i=>{this.leftExpression.GenerateIntoContainer(i),this.rightExpression.GenerateIntoContainer(i),this.opName=this.NativeNameForOp(this.opName),i.AddContent(MO.NativeFunctionCall.CallWithName(this.opName));},this.NativeNameForOp=i=>i==="and"?"&&":i==="or"?"||":i==="mod"?"%":i==="has"?"?":i==="hasnt"?"!?":i,this.toString=()=>`(${this.leftExpression} ${this.opName} ${this.rightExpression})`,this.leftExpression=this.AddContent(e),this.rightExpression=this.AddContent(t),this.opName=r;}get typeName(){return "BinaryExpression"}ResolveReferences(e){if(super.ResolveReferences(e),this.NativeNameForOp(this.opName)==="?"){let t=(0, zO.asOrNull)(this.leftExpression,GO.UnaryExpression);t!==null&&(t.op==="not"||t.op==="!")&&this.Error(`Using 'not' or '!' here negates '${t.innerExpression}' rather than the result of the '?' or 'has' operator. You need to add parentheses around the (A ? B) expression.`);}}};La.BinaryExpression=Bh;});var Xi=w(qa=>{Object.defineProperty(qa,"__esModule",{value:true});qa.CharacterSet=void 0;var Ki=class{constructor(e){this.set=new Set,this.Add=t=>this.set.add(t),this.AddRange=(t,r)=>{for(let i=t.charCodeAt(0);i<=r.charCodeAt(0);++i)this.Add(String.fromCharCode(i));return this},this.AddCharacters=t=>{if(typeof t=="string"||Array.isArray(t))for(let r of t)this.Add(r);else for(let r of t.set)this.Add(r);return this},e&&this.AddCharacters(e);}};qa.CharacterSet=Ki;Ki.FromRange=(n,e)=>new Ki().AddRange(n,e);});var cv=w(Ba=>{Object.defineProperty(Ba,"__esModule",{value:true});Ba.CharacterRange=void 0;var lv=Xi(),Yi=class{constructor(e,t,r=[]){if(this._start=e,this._end=t,this._correspondingCharSet=new lv.CharacterSet,this._excludes=new Set,this.ToCharacterSet=()=>{if(this._correspondingCharSet.set.size===0)for(let i=this.start.charCodeAt(0),a;i<=this.end.charCodeAt(0);i+=1)a=String.fromCharCode(i),this._excludes.has(a)||this._correspondingCharSet.AddCharacters(a);return this._correspondingCharSet},r instanceof lv.CharacterSet)this._excludes=r.set;else for(let i of r)this._excludes.add(i);}get start(){return this._start}get end(){return this._end}};Ba.CharacterRange=Yi;Yi.Define=(n,e,t=[])=>new Yi(n,e,t);});var Ma=w(Wa=>{Object.defineProperty(Wa,"__esModule",{value:true});Wa.ChoicePoint=void 0;var JO=ot(),HO=at(),Mh=qe(),Gh=class extends JO.InkObject{constructor(e=true){super(),this._pathOnChoice=null,this.hasCondition=false,this.hasStartContent=false,this.hasChoiceOnlyContent=false,this.isInvisibleDefault=false,this.onceOnly=true,this.onceOnly=e;}get pathOnChoice(){if(this._pathOnChoice!=null&&this._pathOnChoice.isRelative){let e=this.choiceTarget;e&&(this._pathOnChoice=e.path);}return this._pathOnChoice}set pathOnChoice(e){this._pathOnChoice=e;}get choiceTarget(){return this._pathOnChoice===null?(0, Mh.throwNullException)("ChoicePoint._pathOnChoice"):this.ResolvePath(this._pathOnChoice).container}get pathStringOnChoice(){return this.pathOnChoice===null?(0, Mh.throwNullException)("ChoicePoint.pathOnChoice"):this.CompactPathString(this.pathOnChoice)}set pathStringOnChoice(e){this.pathOnChoice=new HO.Path(e);}get flags(){let e=0;return this.hasCondition&&(e|=1),this.hasStartContent&&(e|=2),this.hasChoiceOnlyContent&&(e|=4),this.isInvisibleDefault&&(e|=8),this.onceOnly&&(e|=16),e}set flags(e){this.hasCondition=(e&1)>0,this.hasStartContent=(e&2)>0,this.hasChoiceOnlyContent=(e&4)>0,this.isInvisibleDefault=(e&8)>0,this.onceOnly=(e&16)>0;}toString(){if(this.pathOnChoice===null)return (0, Mh.throwNullException)("ChoicePoint.pathOnChoice");let t=this.pathOnChoice.toString();return "Choice: -> "+t}};Wa.ChoicePoint=Gh;});var Yn=w(Ga=>{Object.defineProperty(Ga,"__esModule",{value:true});Ga.PushPopType=void 0;var hv;(function(n){n[n.Tunnel=0]="Tunnel",n[n.Function=1]="Function",n[n.FunctionEvaluationFromGame=2]="FunctionEvaluationFromGame";})(hv||(Ga.PushPopType=hv={}));});var Zi=w(za=>{Object.defineProperty(za,"__esModule",{value:true});za.Pointer=void 0;var UO=at(),zh=class n{constructor(){this.container=null,this.index=-1,arguments.length===2&&(this.container=arguments[0],this.index=arguments[1]);}Resolve(){return this.index<0?this.container:this.container==null?null:this.container.content.length==0?this.container:this.index>=this.container.content.length?null:this.container.content[this.index]}get isNull(){return this.container==null}get path(){return this.isNull?null:this.index>=0?this.container.path.PathByAppendingComponent(new UO.Path.Component(this.index)):this.container.path}toString(){return this.container?"Ink Pointer -> "+this.container.path.toString()+" -- index "+this.index:"Ink Pointer (null)"}copy(){return new n(this.container,this.index)}static StartOf(e){return new n(e,0)}static get Null(){return new n(null,-1)}};za.Pointer=zh;});var zt=w(Ha=>{Object.defineProperty(Ha,"__esModule",{value:true});Ha.Divert=void 0;var KO=at(),XO=Yn(),YO=Un(),ZO=ot(),Jh=Zi(),dv=Ee(),Ja=qe(),Hh=class n extends ZO.InkObject{get targetPath(){if(this._targetPath!=null&&this._targetPath.isRelative){let e=this.targetPointer.Resolve();e&&(this._targetPath=e.path);}return this._targetPath}set targetPath(e){this._targetPath=e,this._targetPointer=Jh.Pointer.Null;}get targetPointer(){if(this._targetPointer.isNull){let e=this.ResolvePath(this._targetPath).obj;if(this._targetPath===null)return (0, Ja.throwNullException)("this._targetPath");if(this._targetPath.lastComponent===null)return (0, Ja.throwNullException)("this._targetPath.lastComponent");if(this._targetPath.lastComponent.isIndex){if(e===null)return (0, Ja.throwNullException)("targetObj");this._targetPointer.container=e.parent instanceof dv.Container?e.parent:null,this._targetPointer.index=this._targetPath.lastComponent.index;}else this._targetPointer=Jh.Pointer.StartOf(e instanceof dv.Container?e:null);}return this._targetPointer.copy()}get targetPathString(){return this.targetPath==null?null:this.CompactPathString(this.targetPath)}set targetPathString(e){e==null?this.targetPath=null:this.targetPath=new KO.Path(e);}get hasVariableTarget(){return this.variableDivertName!=null}constructor(e){super(),this._targetPath=null,this._targetPointer=Jh.Pointer.Null,this.variableDivertName=null,this.pushesToStack=false,this.stackPushType=0,this.isExternal=false,this.externalArgs=0,this.isConditional=false,this.pushesToStack=false,typeof e<"u"&&(this.pushesToStack=true,this.stackPushType=e);}Equals(e){let t=e;return t instanceof n&&this.hasVariableTarget==t.hasVariableTarget?this.hasVariableTarget?this.variableDivertName==t.variableDivertName:this.targetPath===null?(0, Ja.throwNullException)("this.targetPath"):this.targetPath.Equals(t.targetPath):false}toString(){if(this.hasVariableTarget)return "Divert(variable: "+this.variableDivertName+")";if(this.targetPath==null)return "Divert(null)";{let e=new YO.StringBuilder,t=this.targetPath.toString();return e.Append("Divert"),this.isConditional&&e.Append("?"),this.pushesToStack&&(this.stackPushType==XO.PushPopType.Function?e.Append(" function"):e.Append(" tunnel")),e.Append(" -> "),e.Append(this.targetPathString),e.Append(" ("),e.Append(t),e.Append(")"),e.toString()}}};Ha.Divert=Hh;});var sn=w(Ua=>{Object.defineProperty(Ua,"__esModule",{value:true});Ua.SymbolType=void 0;var pv;(function(n){n[n.Knot=0]="Knot",n[n.List=1]="List",n[n.ListItem=2]="ListItem",n[n.Var=3]="Var",n[n.SubFlowAndWeave=4]="SubFlowAndWeave",n[n.Arg=5]="Arg",n[n.Temp=6]="Temp";})(pv||(Ua.SymbolType=pv={}));});var _n=w(Ka=>{Object.defineProperty(Ka,"__esModule",{value:true});Ka.VariableAssignment=void 0;var QO=ot(),Uh=class extends QO.InkObject{constructor(e,t){super(),this.variableName=e||null,this.isNewDeclaration=!!t,this.isGlobal=false;}toString(){return "VarAssign to "+this.variableName}};Ka.VariableAssignment=Uh;});var $r=w(Ya=>{Object.defineProperty(Ya,"__esModule",{value:true});Ya.Choice=void 0;var eP=Ma(),Xa=Ee(),wn=Be(),Kh=zt(),fv=be(),tP=ve(),nP=sn(),mv=_n(),Xh=class extends tP.ParsedObject{get runtimeChoice(){if(!this._runtimeChoice)throw new Error;return this._runtimeChoice}get name(){var e;return ((e=this.identifier)===null||e===void 0?void 0:e.name)||null}get condition(){return this._condition}set condition(e){this._condition=e,e&&this.AddContent(e);}get runtimeContainer(){return this._innerContentContainer}get innerContentContainer(){return this._innerContentContainer}get containerForCounting(){return this._innerContentContainer}get runtimePath(){if(!this.innerContentContainer||!this.innerContentContainer.path)throw new Error;return this.innerContentContainer.path}constructor(e,t,r){super(),this._condition=null,this._innerContentContainer=null,this._outerContainer=null,this._runtimeChoice=null,this._returnToR1=null,this._returnToR2=null,this._r1Label=null,this._r2Label=null,this._divertToStartContentOuter=null,this._divertToStartContentInner=null,this._startContentRuntimeContainer=null,this.isInvisibleDefault=false,this.hasWeaveStyleInlineBrackets=false,this.GenerateRuntimeObject=()=>{if(this._outerContainer=new Xa.Container,this._runtimeChoice=new eP.ChoicePoint(this.onceOnly),this._runtimeChoice.isInvisibleDefault=this.isInvisibleDefault,(this.startContent||this.choiceOnlyContent||this.condition)&&this._outerContainer.AddContent(wn.ControlCommand.EvalStart()),this.startContent){this._returnToR1=new fv.DivertTargetValue,this._outerContainer.AddContent(this._returnToR1);let i=new mv.VariableAssignment("$r",true);this._outerContainer.AddContent(i),this._outerContainer.AddContent(wn.ControlCommand.BeginString()),this._divertToStartContentOuter=new Kh.Divert,this._outerContainer.AddContent(this._divertToStartContentOuter),this._startContentRuntimeContainer=this.startContent.GenerateRuntimeObject(),this._startContentRuntimeContainer.name="s";let a=new Kh.Divert;a.variableDivertName="$r",this._startContentRuntimeContainer.AddContent(a),this._outerContainer.AddToNamedContentOnly(this._startContentRuntimeContainer),this._r1Label=new Xa.Container,this._r1Label.name="$r1",this._outerContainer.AddContent(this._r1Label),this._outerContainer.AddContent(wn.ControlCommand.EndString()),this._runtimeChoice.hasStartContent=true;}if(this.choiceOnlyContent){this._outerContainer.AddContent(wn.ControlCommand.BeginString());let i=this.choiceOnlyContent.GenerateRuntimeObject();this._outerContainer.AddContentsOfContainer(i),this._outerContainer.AddContent(wn.ControlCommand.EndString()),this._runtimeChoice.hasChoiceOnlyContent=true;}if(this.condition&&(this.condition.GenerateIntoContainer(this._outerContainer),this._runtimeChoice.hasCondition=true),(this.startContent||this.choiceOnlyContent||this.condition)&&this._outerContainer.AddContent(wn.ControlCommand.EvalEnd()),this._outerContainer.AddContent(this._runtimeChoice),this._innerContentContainer=new Xa.Container,this.startContent){this._returnToR2=new fv.DivertTargetValue,this._innerContentContainer.AddContent(wn.ControlCommand.EvalStart()),this._innerContentContainer.AddContent(this._returnToR2),this._innerContentContainer.AddContent(wn.ControlCommand.EvalEnd());let i=new mv.VariableAssignment("$r",true);this._innerContentContainer.AddContent(i),this._divertToStartContentInner=new Kh.Divert,this._innerContentContainer.AddContent(this._divertToStartContentInner),this._r2Label=new Xa.Container,this._r2Label.name="$r2",this._innerContentContainer.AddContent(this._r2Label);}if(this.innerContent){let i=this.innerContent.GenerateRuntimeObject();this._innerContentContainer.AddContentsOfContainer(i);}return this.story.countAllVisits&&(this._innerContentContainer.visitsShouldBeCounted=true),this._innerContentContainer.countingAtStartOnly=true,this._outerContainer},this.toString=()=>this.choiceOnlyContent!==null?`* ${this.startContent}[${this.choiceOnlyContent}]...`:`* ${this.startContent}...`,this.startContent=e,this.choiceOnlyContent=t,this.innerContent=r,this.indentationDepth=1,e&&this.AddContent(this.startContent),t&&this.AddContent(this.choiceOnlyContent),r&&this.AddContent(this.innerContent),this.onceOnly=true;}get typeName(){return "Choice"}ResolveReferences(e){var t;if(this._innerContentContainer&&(this.runtimeChoice.pathOnChoice=this._innerContentContainer.path,this.onceOnly&&(this._innerContentContainer.visitsShouldBeCounted=true)),this._returnToR1){if(!this._r1Label)throw new Error;this._returnToR1.targetPath=this._r1Label.path;}if(this._returnToR2){if(!this._r2Label)throw new Error;this._returnToR2.targetPath=this._r2Label.path;}if(this._divertToStartContentOuter){if(!this._startContentRuntimeContainer)throw new Error;this._divertToStartContentOuter.targetPath=this._startContentRuntimeContainer.path;}if(this._divertToStartContentInner){if(!this._startContentRuntimeContainer)throw new Error;this._divertToStartContentInner.targetPath=this._startContentRuntimeContainer.path;}super.ResolveReferences(e),this.identifier&&(((t=this.identifier)===null||t===void 0?void 0:t.name)||"").length>0&&e.CheckForNamingCollisions(this,this.identifier,nP.SymbolType.SubFlowAndWeave);}};Ya.Choice=Xh;});var gv=w(Qa=>{Object.defineProperty(Qa,"__esModule",{value:true});Qa.StringParserElement=void 0;var Za=class n{constructor(){this.characterIndex=0,this.characterInLineIndex=0,this.lineIndex=0,this.reportedErrorInScope=false,this.uniqueId=0,this.customFlags=0,this.CopyFrom=e=>{n._uniqueIdCounter++,this.uniqueId=n._uniqueIdCounter,this.characterIndex=e.characterIndex,this.characterInLineIndex=e.characterInLineIndex,this.lineIndex=e.lineIndex,this.customFlags=e.customFlags,this.reportedErrorInScope=false;},this.SquashFrom=e=>{this.characterIndex=e.characterIndex,this.characterInLineIndex=e.characterInLineIndex,this.lineIndex=e.lineIndex,this.reportedErrorInScope=e.reportedErrorInScope,this.customFlags=e.customFlags;};}};Qa.StringParserElement=Za;Za._uniqueIdCounter=1e3;});var vv=w(eo=>{Object.defineProperty(eo,"__esModule",{value:true});eo.StringParserState=void 0;var yv=gv(),Yh=class{get currentElement(){return this._stack[this._numElements-1]}get lineIndex(){return this.currentElement.lineIndex}set lineIndex(e){this.currentElement.lineIndex=e;}get characterIndex(){return this.currentElement.characterIndex}set characterIndex(e){this.currentElement.characterIndex=e;}get characterInLineIndex(){return this.currentElement.characterInLineIndex}set characterInLineIndex(e){this.currentElement.characterInLineIndex=e;}get customFlags(){return this.currentElement.customFlags}set customFlags(e){this.currentElement.customFlags=e;}get errorReportedAlreadyInScope(){return this.currentElement.reportedErrorInScope}get stackHeight(){return this._numElements}constructor(){this._stack=[],this._numElements=0,this.StringParserState=()=>{this._stack=new Array(200);for(let r=0;r<200;++r)this._stack[r]=new yv.StringParserElement;this._numElements=1;},this.Push=()=>{if(this._numElements>=this._stack.length&&this._numElements>0)throw new Error("Stack overflow in parser state.");let t=this._stack[this._numElements-1],r=this._stack[this._numElements];return this._numElements++,r.CopyFrom(t),r.uniqueId},this.Pop=t=>{if(this._numElements==1)throw new Error("Attempting to remove final stack element is illegal! Mismatched Begin/Succceed/Fail?");if(this.currentElement.uniqueId!=t)throw new Error("Mismatched rule IDs while Poping - do you have mismatched Begin/Succeed/Fail?");this._numElements-=1;},this.Peek=t=>{if(this.currentElement.uniqueId!=t)throw new Error("Mismatched rule IDs while Peeking - do you have mismatched Begin/Succeed/Fail?");return this._stack[this._numElements-1]},this.PeekPenultimate=()=>this._numElements>=2?this._stack[this._numElements-2]:null,this.Squash=()=>{if(this._numElements<2)throw new Error("Attempting to remove final stack element is illegal! Mismatched Begin/Succceed/Fail?");let t=this._stack[this._numElements-2],r=this._stack[this._numElements-1];t.SquashFrom(r),this._numElements-=1;},this.NoteErrorReported=()=>{for(let t of this._stack)t.reportedErrorInScope=true;};let e=200;for(let t=0;t<e;t++)this._stack[t]=new yv.StringParserElement;this._numElements=1;}};eo.StringParserState=Yh;});var Qh=w(Zn=>{Object.defineProperty(Zn,"__esModule",{value:true});Zn.StringParser=Zn.ParseSuccess=void 0;var Zh=Xi(),rP=vv();Zn.ParseSuccess=Symbol("ParseSuccessStruct");var Qi=class n{constructor(e){this.ParseRule=null,this.errorHandler=null,this.hadError=false,this.BeginRule=()=>this.state.Push(),this.FailRule=r=>(this.state.Pop(r),null),this.CancelRule=r=>{this.state.Pop(r);},this.SucceedRule=(r,i=null)=>{let a=this.state.Peek(r),s=this.state.PeekPenultimate();this.RuleDidSucceed&&this.RuleDidSucceed(i,s,a),this.state.Squash();let o=i;return o===null&&(o=n.ParseSuccess),o},this.Expect=(r,i=null,a=null)=>{let s=this.ParseObject(r);if(s===null){i===null&&(i=r.name);let o,u=this.LineRemainder();u===null||u.length===0?o="end of line":o=`'${u}'`,this.Error(`Expected ${i} but saw ${o}`),a!==null&&(s=a());}return s},this.Error=(r,i=false)=>{this.ErrorOnLine(r,this.lineIndex+1,i);},this.ErrorWithParsedObject=(r,i,a=false)=>{this.ErrorOnLine(r,i.debugMetadata?i.debugMetadata.startLineNumber:-1,a);},this.ErrorOnLine=(r,i,a)=>{if(!this.state.errorReportedAlreadyInScope){let s=a?"Warning":"Error";if(this.errorHandler)this.errorHandler(r,this.index,i-1,a);else throw new Error(`${s} on line ${i}: ${r}`);this.state.NoteErrorReported();}a||(this.hadError=true);},this.Warning=r=>this.Error(r,true),this.LineRemainder=()=>this.Peek(()=>this.ParseUntilCharactersFromString(`
|
|
12
12
|
\r`)),this.SetFlag=(r,i)=>{i?this.state.customFlags|=r:this.state.customFlags&=~r;},this.GetFlag=r=>!!(this.state.customFlags&r),this.ParseObject=r=>{let i=this.BeginRule(),a=this.state.stackHeight,s=r();if(a!==this.state.stackHeight)throw new Error("Mismatched Begin/Fail/Succeed rules");return s===null?this.FailRule(i):(this.SucceedRule(i,s),s)},this.Parse=r=>{let i=this.BeginRule(),a=r();return a===null?(this.FailRule(i),null):(this.SucceedRule(i,a),a)},this.OneOf=r=>{for(let i of r){let a=this.ParseObject(i);if(a!==null)return a}return null},this.OneOrMore=r=>{let i=[],a=null;do a=this.ParseObject(r),a!==null&&i.push(a);while(a!==null);return i.length>0?i:null},this.Optional=r=>()=>{let i=this.ParseObject(r);return i===null?n.ParseSuccess:i},this.Exclude=r=>()=>this.ParseObject(r)&&n.ParseSuccess,this.OptionalExclude=r=>()=>(this.ParseObject(r),n.ParseSuccess),this.String=r=>()=>this.ParseString(r),this.TryAddResultToList=(r,i,a=true)=>{if(r!==n.ParseSuccess){if(a&&Array.isArray(r)){let s=r;if(s!==null){for(let o of s)i.push(o);return}}i.push(r);}},this.Interleave=(r,i,a=null,s=true)=>{let o=this.BeginRule(),u=[],l=this.ParseObject(r);if(l===null)return this.FailRule(o);this.TryAddResultToList(l,u,s);let c=null,h=null;do{if(a!==null&&this.Peek(a)!==null||(c=this.ParseObject(i),c===null))break;if(this.TryAddResultToList(c,u,s),h=null,c!==null){if(h=this.ParseObject(r),h===null)break;this.TryAddResultToList(h,u,s);}}while((c!==null||h!==null)&&!(c===n.ParseSuccess&&h==n.ParseSuccess)&&this.remainingLength>0);return u.length===0?this.FailRule(o):this.SucceedRule(o,u)},this.ParseString=r=>{if(r.length>this.remainingLength)return null;let i=this.BeginRule(),a=this.index,s=this.characterInLineIndex,o=this.lineIndex,u=true;for(let l=0;l<r.length;l+=1){let c=r[l];if(this._chars[a]!==c){u=false;break}c===`
|
|
13
13
|
`&&(o++,s=-1),a++,s++;}return this.index=a,this.characterInLineIndex=s,this.lineIndex=o,u?this.SucceedRule(i,r):this.FailRule(i)},this.ParseSingleCharacter=()=>{if(this.remainingLength>0){let r=this._chars[this.index];return r===`
|
|
14
|
-
`&&(this.lineIndex+=1,this.characterInLineIndex=-1),this.index+=1,this.characterInLineIndex+=1,r}return "0"},this.ParseUntilCharactersFromString=(r,i=-1)=>this.ParseCharactersFromString(r,false,i),this.ParseUntilCharactersFromCharSet=(r,i=-1)=>this.ParseCharactersFromCharSet(r,false,i),this.ParseCharactersFromString=(r,i=-1,a=-1)=>{let s=new
|
|
14
|
+
`&&(this.lineIndex+=1,this.characterInLineIndex=-1),this.index+=1,this.characterInLineIndex+=1,r}return "0"},this.ParseUntilCharactersFromString=(r,i=-1)=>this.ParseCharactersFromString(r,false,i),this.ParseUntilCharactersFromCharSet=(r,i=-1)=>this.ParseCharactersFromCharSet(r,false,i),this.ParseCharactersFromString=(r,i=-1,a=-1)=>{let s=new Zh.CharacterSet(r);return typeof i=="number"?this.ParseCharactersFromCharSet(s,true,i):this.ParseCharactersFromCharSet(s,i,a)},this.ParseCharactersFromCharSet=(r,i=true,a=-1)=>{a===-1&&(a=Number.MAX_SAFE_INTEGER);let s=this.index,o=this.index,u=this.characterInLineIndex,l=this.lineIndex,c=0;for(;o<this._chars.length&&r.set.has(this._chars[o])===i&&c<a;)this._chars[o]===`
|
|
15
15
|
`&&(l+=1,u=-1),o+=1,u+=1,c+=1;return this.index=o,this.characterInLineIndex=u,this.lineIndex=l,this.index>s?this._chars.slice(s,this.index).join(""):null},this.Peek=r=>{let i=this.BeginRule(),a=r();return this.CancelRule(i),a},this.ParseInt=()=>{let r=this.index,i=this.characterInLineIndex,a=this.ParseString("-")!==null;this.ParseCharactersFromString(" ");let s=this.ParseCharactersFromCharSet(n.numbersCharacterSet);if(s===null)return this.index=r,this.characterInLineIndex=i,null;let o;return Number.isNaN(Number(s))?(this.Error("Failed to read integer value: "+s+". Perhaps it's out of the range of acceptable numbers ink supports? ("+Number.MIN_SAFE_INTEGER+" to "+Number.MAX_SAFE_INTEGER+")"),null):(o=Number(s),a?-o:o)},this.ParseFloat=()=>{let r=this.index,i=this.characterInLineIndex,a=this.ParseInt();if(a!==null&&this.ParseString(".")!==null){let s=this.ParseCharactersFromCharSet(n.numbersCharacterSet);return +`${a}.${s}`}return this.index=r,this.characterInLineIndex=i,null},this.ParseNewline=()=>{let r=this.BeginRule();return this.ParseString("\r"),this.ParseString(`
|
|
16
16
|
`)===null?this.FailRule(r):this.SucceedRule(r,`
|
|
17
|
-
`)};let t=this.PreProcessInputString(e);this.state=new
|
|
18
|
-
`&&(this.lineIndex+=1,this.characterInLineIndex=-1),this.index+=1,this.characterInLineIndex+=1;continue}else break}}while(true);return s.length>0?this.SucceedRule(i,String(s)):this.FailRule(i)}};
|
|
19
|
-
`),this._commentBlockEndCharacter=new
|
|
17
|
+
`)};let t=this.PreProcessInputString(e);this.state=new rP.StringParserState,e?this._chars=t.split(""):this._chars=[],this.inputString=t;}get currentCharacter(){return this.index>=0&&this.remainingLength>0?this._chars[this.index]:"0"}PreProcessInputString(e){return e}get endOfInput(){return this.index>=this._chars.length}get remainingString(){return this._chars.slice(this.index,this.index+this.remainingLength).join("")}get remainingLength(){return this._chars.length-this.index}get lineIndex(){return this.state.lineIndex}set lineIndex(e){this.state.lineIndex=e;}set characterInLineIndex(e){this.state.characterInLineIndex=e;}get characterInLineIndex(){return this.state.characterInLineIndex}get index(){return this.state.characterIndex}set index(e){this.state.characterIndex=e;}ParseUntil(e,t=null,r=null){let i=this.BeginRule(),a=new Zh.CharacterSet;t!==null&&(a.set=new Set([...a.set.values(),...t.set.values()])),r!==null&&(a.set=new Set([...a.set.values(),...r.set.values()]));let s="",o=null;do{let u=this.ParseUntilCharactersFromCharSet(a);if(u&&(s+=u),o=this.Peek(e),o!==null)break;{if(this.endOfInput)break;let l=this.currentCharacter;if(t!==null&&t.set.has(l)){s+=l,l===`
|
|
18
|
+
`&&(this.lineIndex+=1,this.characterInLineIndex=-1),this.index+=1,this.characterInLineIndex+=1;continue}else break}}while(true);return s.length>0?this.SucceedRule(i,String(s)):this.FailRule(i)}};Zn.StringParser=Qi;Qi.ParseSuccess=Zn.ParseSuccess;Qi.numbersCharacterSet=new Zh.CharacterSet("0123456789");});var bv=w(to=>{Object.defineProperty(to,"__esModule",{value:true});to.CommentEliminator=void 0;var ed=Xi(),iP=Qh(),td=class extends iP.StringParser{constructor(){super(...arguments),this._commentOrNewlineStartCharacter=new ed.CharacterSet(`/\r
|
|
19
|
+
`),this._commentBlockEndCharacter=new ed.CharacterSet("*"),this._newlineCharacters=new ed.CharacterSet(`
|
|
20
20
|
\r`),this.Process=()=>{let e=this.Interleave(this.Optional(this.CommentsAndNewlines),this.Optional(this.MainInk));return e!==null?e.join(""):""},this.MainInk=()=>this.ParseUntil(this.CommentsAndNewlines,this._commentOrNewlineStartCharacter,null),this.CommentsAndNewlines=()=>{let e=this.Interleave(this.Optional(this.ParseNewline),this.Optional(this.ParseSingleComment));return e!==null?e.join(""):null},this.ParseSingleComment=()=>this.OneOf([this.EndOfLineComment,this.BlockComment]),this.EndOfLineComment=()=>this.ParseString("//")===null?null:(this.ParseUntilCharactersFromCharSet(this._newlineCharacters),""),this.BlockComment=()=>{if(this.ParseString("/*")===null)return null;let e=this.lineIndex,t=this.ParseUntil(this.String("*/"),this._commentBlockEndCharacter,null);return this.endOfInput||this.ParseString("*/"),t!=null?`
|
|
21
|
-
`.repeat(this.lineIndex-e):null};}PreProcessInputString(e){return e}};Qa.CommentEliminator=Qh;});var to=E(eo=>{Object.defineProperty(eo,"__esModule",{value:true});eo.Conditional=void 0;var hO=Ee(),vv=Le(),dO=ye(),ed=class extends dO.ParsedObject{constructor(e,t){super(),this.initialCondition=e,this.branches=t,this._reJoinTarget=null,this.GenerateRuntimeObject=()=>{let r=new hO.Container;this.initialCondition&&r.AddContent(this.initialCondition.runtimeObject);for(let i of this.branches){let a=i.runtimeObject;r.AddContent(a);}return this.initialCondition!==null&&this.branches[0].ownExpression!==null&&!this.branches[this.branches.length-1].isElse&&r.AddContent(vv.ControlCommand.PopEvaluatedValue()),this._reJoinTarget=vv.ControlCommand.NoOp(),r.AddContent(this._reJoinTarget),r},this.initialCondition&&this.AddContent(this.initialCondition),this.branches!==null&&this.AddContent(this.branches);}get typeName(){return "Conditional"}ResolveReferences(e){let t=this._reJoinTarget.path;for(let r of this.branches){if(!r.returnDivert)throw new Error;r.returnDivert.targetPath=t;}super.ResolveReferences(e);}};eo.Conditional=ed;});var Sn=E(no=>{Object.defineProperty(no,"__esModule",{value:true});no.Text=void 0;var fO=ye(),pO=ve(),td=class extends fO.ParsedObject{constructor(e){super(),this.text=e,this.GenerateRuntimeObject=()=>new pO.StringValue(this.text),this.toString=()=>this.text;}get typeName(){return "Text"}};no.Text=td;});var io=E(ro=>{Object.defineProperty(ro,"__esModule",{value:true});ro.ConstantDeclaration=void 0;var mO=ye(),gO=nn(),nd=class extends mO.ParsedObject{get constantName(){var e;return (e=this.constantIdentifier)===null||e===void 0?void 0:e.name}get expression(){if(!this._expression)throw new Error;return this._expression}constructor(e,t){super(),this._expression=null,this.GenerateRuntimeObject=()=>null,this.constantIdentifier=e,t&&(this._expression=this.AddContent(t));}get typeName(){return "CONST"}ResolveReferences(e){super.ResolveReferences(e),e.CheckForNamingCollisions(this,this.constantIdentifier,gO.SymbolType.Var);}};ro.ConstantDeclaration=nd;});var $r=E(so=>{Object.defineProperty(so,"__esModule",{value:true});so.FlowLevel=void 0;var Cv;(function(n){n[n.Story=0]="Story",n[n.Knot=1]="Knot",n[n.Stitch=2]="Stitch",n[n.WeavePoint=3]="WeavePoint";})(Cv||(so.FlowLevel=Cv={}));});var Zi=E(ao=>{Object.defineProperty(ao,"__esModule",{value:true});ao.Gather=void 0;var yO=Ee(),vO=ye(),CO=nn(),rd=class extends vO.ParsedObject{get name(){var e;return ((e=this.identifier)===null||e===void 0?void 0:e.name)||null}get runtimeContainer(){return this.runtimeObject}constructor(e,t){super(),this.indentationDepth=t,this.GenerateRuntimeObject=()=>{let r=new yO.Container;if(r.name=this.name,this.story.countAllVisits&&(r.visitsShouldBeCounted=true),r.countingAtStartOnly=true,this.content)for(let i of this.content)r.AddContent(i.runtimeObject);return r},this.toString=()=>{var r,i;return `- ${!((r=this.identifier)===null||r===void 0)&&r.name?"("+((i=this.identifier)===null||i===void 0?void 0:i.name)+")":"gather"}`},e&&(this.identifier=e);}get typeName(){return "Gather"}ResolveReferences(e){super.ResolveReferences(e),this.identifier&&(this.identifier.name||"").length>0&&e.CheckForNamingCollisions(this,this.identifier,CO.SymbolType.SubFlowAndWeave);}};ao.Gather=rd;});var Yn=E(uo=>{Object.defineProperty(uo,"__esModule",{value:true});uo.Path=void 0;var oo=ae(),bv=Gt(),jr=$r(),bO=Zn(),id=class{get baseTargetLevel(){return this.baseLevelIsAmbiguous?jr.FlowLevel.Story:this._baseTargetLevel}get baseLevelIsAmbiguous(){return !this._baseTargetLevel}get firstComponent(){return this.components==null||!this.components.length?null:this.components[0].name}get numberOfComponents(){return this.components?this.components.length:0}get dotSeparatedComponents(){return this._dotSeparatedComponents==null&&(this._dotSeparatedComponents=(this.components?this.components:[]).map(e=>e.name).filter(oo.filterUndef).join(".")),this._dotSeparatedComponents}constructor(e,t){this._dotSeparatedComponents=null,this.toString=()=>this.components===null||this.components.length===0?this.baseTargetLevel===jr.FlowLevel.WeavePoint?"-> <next gather point>":"<invalid Path>":`-> ${this.dotSeparatedComponents}`,this.ResolveFromContext=r=>{if(this.components==null||this.components.length==0)return null;let i=this.ResolveBaseTarget(r);return i===null?null:this.components.length>1?this.ResolveTailComponents(i):i},this.ResolveBaseTarget=r=>{let i=this.firstComponent,a=r;for(;a;){let s=a===r,o=this.GetChildFromContext(a,i,null,s);if(o)return o;a=a.parent;}return null},this.ResolveTailComponents=r=>{let i=r;if(!this.components)return null;for(let a=1;a<this.components.length;++a){let s=this.components[a].name,o,u=(0, oo.asOrNull)(i,bv.FlowBase);if(u!==null?o=u.flowLevel+1:o=jr.FlowLevel.WeavePoint,i=this.GetChildFromContext(i,s,o),i===null)break}return i},this.GetChildFromContext=(r,i,a,s=false)=>{let o=a===null,u=(0, oo.asOrNull)(r,bO.Weave);if(i&&u!==null&&(o||a===jr.FlowLevel.WeavePoint))return u.WeavePointNamed(i);let l=(0, oo.asOrNull)(r,bv.FlowBase);if(i&&l!==null){let c=s||l.flowLevel===jr.FlowLevel.Knot;return l.ContentWithNameAtLevel(i,a,c)}return null},Object.values(jr.FlowLevel).includes(e)?(this._baseTargetLevel=e,this.components=t||[]):Array.isArray(e)?(this._baseTargetLevel=null,this.components=e||[]):(this._baseTargetLevel=null,this.components=[e]);}get typeName(){return "Path"}};uo.Path=id;});var od=E(lo=>{Object.defineProperty(lo,"__esModule",{value:true});lo.ReturnType=void 0;var _O=ye(),SO=Ee(),sd=Le(),EO=Un(),ad=class extends _O.ParsedObject{constructor(e=null){super(),this.returnedExpression=null,this.GenerateRuntimeObject=()=>{let t=new SO.Container;return this.returnedExpression?t.AddContent(this.returnedExpression.runtimeObject):(t.AddContent(sd.ControlCommand.EvalStart()),t.AddContent(new EO.Void),t.AddContent(sd.ControlCommand.EvalEnd())),t.AddContent(sd.ControlCommand.PopFunction()),t},e&&(this.returnedExpression=this.AddContent(e));}get typeName(){return "ReturnType"}};lo.ReturnType=ad;});var Qi=E(co=>{Object.defineProperty(co,"__esModule",{value:true});co.ClosestFlowBase=void 0;function wO(n){let e=n.parent;for(;e;){if(e.hasOwnProperty("iamFlowbase")&&e.iamFlowbase())return e;e=e.parent;}return null}co.ClosestFlowBase=wO;});var fo=E(ho=>{Object.defineProperty(ho,"__esModule",{value:true});ho.Identifier=void 0;var ud=class n{constructor(e){this.debugMetadata=null,this.toString=()=>this.name||"undefined identifer",this.name=e;}get typeName(){return "Identifier"}static Done(){return new n("DONE")}};ho.Identifier=ud;});var Gt=E(po=>{Object.defineProperty(po,"__esModule",{value:true});po.FlowBase=void 0;var DO=Rr(),ld=qr(),AO=Lr(),zt=$r(),PO=Zi(),OO=ye(),xO=Yn(),TO=od(),NO=Ee(),FO=Mt(),IO=bn(),cd=nn(),kO=Zn(),VO=Qi(),RO=fo(),_v=ae(),hd=class n extends OO.ParsedObject{get hasParameters(){return this.args!==null&&this.args.length>0}get subFlowsByName(){return this._subFlowsByName}get typeName(){return this.isFunction?"Function":String(this.flowLevel)}get name(){var e;return ((e=this.identifier)===null||e===void 0?void 0:e.name)||null}constructor(e,t=null,r=null,i=false,a=false){super(),this.isFunction=i,this._rootWeave=null,this._subFlowsByName=new Map,this._startingSubFlowDivert=null,this._startingSubFlowRuntime=null,this._firstChildFlow=null,this.variableDeclarations=new Map,this.identifier=null,this.args=null,this.iamFlowbase=()=>true,this.SplitWeaveAndSubFlowContent=(s,o)=>{var u,l;let c=[],h=[];this._subFlowsByName=new Map;for(let f of s){let g=(0, _v.asOrNull)(f,n);g?(this._firstChildFlow===null&&(this._firstChildFlow=g),h.push(f),!((u=g.identifier)===null||u===void 0)&&u.name&&this._subFlowsByName.set((l=g.identifier)===null||l===void 0?void 0:l.name,g)):c.push(f);}o&&c.push(new PO.Gather(null,1),new ld.Divert(new xO.Path(RO.Identifier.Done())));let p=[];return c.length>0&&(this._rootWeave=new kO.Weave(c,0),p.push(this._rootWeave)),h.length>0&&p.push(...h),p},this.ResolveVariableWithName=(s,o)=>{var u;let l={},c=o===null?this:(0, VO.ClosestFlowBase)(o);if(c){if(c.args!==null){for(let h of c.args)if(((u=h.identifier)===null||u===void 0?void 0:u.name)===s)return l.found=true,l.isArgument=true,l.ownerFlow=c,l}if(c!==this.story&&c.variableDeclarations.has(s))return l.found=true,l.ownerFlow=c,l.isTemporary=true,l}return this.story.variableDeclarations.has(s)?(l.found=true,l.ownerFlow=this.story,l.isGlobal=true,l):(l.found=false,l)},this.AddNewVariableDeclaration=s=>{let o=s.variableName;if(this.variableDeclarations.has(o)){let u=this.variableDeclarations.get(o),l="";u.debugMetadata&&(l=` (${u.debugMetadata})`),this.Error(`found declaration variable '${o}' that was already declared${l}`,s,false);return}this.variableDeclarations.set(s.variableName,s);},this.ResolveWeavePointNaming=()=>{this._rootWeave&&this._rootWeave.ResolveWeavePointNaming();for(let[,s]of this._subFlowsByName)s.hasOwnProperty("ResolveWeavePointNaming")&&s.ResolveWeavePointNaming();},this.GenerateRuntimeObject=()=>{var s;let o=null;this.isFunction?this.CheckForDisallowedFunctionFlowControl():(this.flowLevel===zt.FlowLevel.Knot||this.flowLevel===zt.FlowLevel.Stitch)&&(o=this.Find(TO.ReturnType)(),o!==null&&this.Error(`Return statements can only be used in knots that are declared as functions: == function ${this.identifier} ==`,o));let u=new NO.Container;u.name=(s=this.identifier)===null||s===void 0?void 0:s.name,this.story.countAllVisits&&(u.visitsShouldBeCounted=true),this.GenerateArgumentVariableAssignments(u);let l=0;for(;this.content!==null&&l<this.content.length;){let c=this.content[l];if(c instanceof n){let h=c,p=h.runtimeObject;l===0&&!h.hasParameters&&this.flowLevel===zt.FlowLevel.Knot&&(this._startingSubFlowDivert=new FO.Divert,u.AddContent(this._startingSubFlowDivert),this._startingSubFlowRuntime=p);let f=p,g=u.namedContent.get(f.name)||null;if(g){let y=`${this.GetType()} already contains flow named '${f.name}' (at ${g.debugMetadata})`;this.Error(y,h);}u.AddToNamedContentOnly(f);}else c&&u.AddContent(c.runtimeObject);l+=1;}return this.flowLevel!==zt.FlowLevel.Story&&!this.isFunction&&this._rootWeave!==null&&o===null&&this._rootWeave.ValidateTermination(this.WarningInTermination),u},this.GenerateArgumentVariableAssignments=s=>{var o;if(!(this.args===null||this.args.length===0))for(let u=this.args.length-1;u>=0;--u){let l=((o=this.args[u].identifier)===null||o===void 0?void 0:o.name)||null,c=new IO.VariableAssignment(l,true);s.AddContent(c);}},this.ContentWithNameAtLevel=(s,o=null,u=false)=>{var l;if((o===this.flowLevel||o===null)&&s===((l=this.identifier)===null||l===void 0?void 0:l.name))return this;if(o===zt.FlowLevel.WeavePoint||o===null){let h=null;if(this._rootWeave&&(h=this._rootWeave.WeavePointNamed(s),h))return h;if(o===zt.FlowLevel.WeavePoint)return u?this.DeepSearchForAnyLevelContent(s):null}if(o!==null&&o<this.flowLevel)return null;let c=this._subFlowsByName.get(s)||null;return c&&(o===null||o===c.flowLevel)?c:u?this.DeepSearchForAnyLevelContent(s):null},this.DeepSearchForAnyLevelContent=s=>{let o=this.ContentWithNameAtLevel(s,zt.FlowLevel.WeavePoint,false);if(o)return o;for(let[,u]of this._subFlowsByName){let l=u.ContentWithNameAtLevel(s,null,true);if(l)return l}return null},this.CheckForDisallowedFunctionFlowControl=()=>{this.flowLevel!==zt.FlowLevel.Knot&&this.Error("Functions cannot be stitches - i.e. they should be defined as '== function myFunc ==' rather than internal to another knot.");for(let[u,l]of this._subFlowsByName)this.Error(`Functions may not contain stitches, but saw '${u}' within the function '${this.identifier}'`,l);if(!this._rootWeave)throw new Error;let s=this._rootWeave.FindAll(ld.Divert)();for(let u of s)!u.isFunctionCall&&!(u.parent instanceof AO.DivertTarget)&&this.Error(`Functions may not contain diverts, but saw '${u}'`,u);let o=this._rootWeave.FindAll(DO.Choice)();for(let u of o)this.Error(`Functions may not contain choices, but saw '${u}'`,u);},this.WarningInTermination=s=>{let o="Apparent loose end exists where the flow runs out. Do you need a '-> DONE' statement, choice or divert?";s.parent===this._rootWeave&&this._firstChildFlow&&(o=`${o} Note that if you intend to enter '${this._firstChildFlow.identifier}' next, you need to divert to it explicitly.`);let u=(0, _v.asOrNull)(s,ld.Divert);u&&u.isTunnel&&(o+=` When final tunnel to '${u.target} ->' returns it won't have anywhere to go.`),this.Warning(o,s);},this.toString=()=>`${this.typeName} '${this.identifier}'`,this.identifier=e,this.args=r,t===null&&(t=[]),this.PreProcessTopLevelObjects(t),t=this.SplitWeaveAndSubFlowContent(t,this.GetType()=="Story"&&!a),this.AddContent(t);}PreProcessTopLevelObjects(e){}ResolveReferences(e){var t,r;if(this._startingSubFlowDivert){if(!this._startingSubFlowRuntime)throw new Error;this._startingSubFlowDivert.targetPath=this._startingSubFlowRuntime.path;}if(super.ResolveReferences(e),this.args!==null){for(let i of this.args)e.CheckForNamingCollisions(this,i.identifier,cd.SymbolType.Arg,"argument");for(let i=0;i<this.args.length;i+=1)for(let a=i+1;a<this.args.length;a+=1)((t=this.args[i].identifier)===null||t===void 0?void 0:t.name)==((r=this.args[a].identifier)===null||r===void 0?void 0:r.name)&&this.Error(`Multiple arguments with the same name: '${this.args[i].identifier}'`);}if(this.flowLevel!==zt.FlowLevel.Story){let i=this.flowLevel===zt.FlowLevel.Knot?cd.SymbolType.Knot:cd.SymbolType.SubFlowAndWeave;e.CheckForNamingCollisions(this,this.identifier,i);}}};po.FlowBase=hd;});var go=E(mo=>{Object.defineProperty(mo,"__esModule",{value:true});mo.ContentList=void 0;var $O=Ee(),jO=ye(),LO=Sn(),qO=ae(),dd=class extends jO.ParsedObject{get runtimeContainer(){return this.runtimeObject}constructor(e,...t){super(),this.dontFlatten=false,this.TrimTrailingWhitespace=()=>{for(let r=this.content.length-1;r>=0;--r){let i=(0, qO.asOrNull)(this.content[r],LO.Text);if(i===null)break;if(i.text=i.text.replace(new RegExp(/[ \t]/g),""),i.text.length===0)this.content.splice(r,1);else break}},this.GenerateRuntimeObject=()=>{let r=new $O.Container;if(this.content!==null)for(let i of this.content){let a=i.runtimeObject;a&&r.AddContent(a);}return this.dontFlatten&&this.story.DontFlattenContainer(r),r},this.toString=()=>`ContentList(${this.content.join(", ")})`,e&&this.AddContent(e),t&&this.AddContent(t);}get typeName(){return "ContentList"}};mo.ContentList=dd;});var Br=E(yo=>{Object.defineProperty(yo,"__esModule",{value:true});yo.VariableReference=void 0;var BO=st(),WO=it(),fd=class extends BO.InkObject{get containerForCount(){return this.pathForCount===null?null:this.ResolvePath(this.pathForCount).container}get pathStringForCount(){return this.pathForCount===null?null:this.CompactPathString(this.pathForCount)}set pathStringForCount(e){e===null?this.pathForCount=null:this.pathForCount=new WO.Path(e);}constructor(e=null){super(),this.pathForCount=null,this.name=e;}toString(){return this.name!=null?"var("+this.name+")":"read_count("+this.pathStringForCount+")"}};yo.VariableReference=fd;});var Wr=E(vo=>{Object.defineProperty(vo,"__esModule",{value:true});vo.VariableReference=void 0;var MO=go(),GO=Ct(),Sv=Gt(),zO=Yn(),JO=Br(),HO=Zn(),UO=fo(),Ev=ae(),pd=class extends GO.Expression{get name(){return this.path.join(".")}get path(){return this.pathIdentifiers.map(e=>e.name).filter(Ev.filterUndef)}get identifier(){if(!this.pathIdentifiers||this.pathIdentifiers.length==0)return null;let e=this.path.join(".");return new UO.Identifier(e)}get runtimeVarRef(){return this._runtimeVarRef}constructor(e){super(),this.pathIdentifiers=e,this._runtimeVarRef=null,this.isConstantReference=false,this.isListItemReference=false,this.GenerateIntoContainer=t=>{let r=this.story.constants.get(this.name);if(r){r.GenerateConstantIntoContainer(t),this.isConstantReference=true;return}if(this._runtimeVarRef=new JO.VariableReference(this.name),this.path.length===1||this.path.length===2){let i="",a="";this.path.length===1?i=this.path[0]:(a=this.path[0],i=this.path[1]),this.story.ResolveListItem(a,i,this)&&(this.isListItemReference=true);}t.AddContent(this._runtimeVarRef);},this.toString=()=>`{${this.path.join(".")}}`;}get typeName(){return "ref"}ResolveReferences(e){if(super.ResolveReferences(e),this.isConstantReference||this.isListItemReference)return;let t=new zO.Path(this.pathIdentifiers),r=t.ResolveFromContext(this);if(r){if(!r.containerForCounting)throw new Error;if(r.containerForCounting.visitsShouldBeCounted=true,this._runtimeVarRef===null)return;this._runtimeVarRef.pathForCount=r.runtimePath,this._runtimeVarRef.name=null;let i=(0, Ev.asOrNull)(r,Sv.FlowBase);i&&i.isFunction&&(this.parent instanceof HO.Weave||this.parent instanceof MO.ContentList||this.parent instanceof Sv.FlowBase)&&this.Warning(`'${i.identifier}' being used as read count rather than being called as function. Perhaps you intended to write ${i.identifier}()`);return}if(this.path.length>1){let i=`Could not find target for read count: ${t}`;this.path.length<=2&&(i+=`, or couldn't find list item with the name ${this.path.join(",")}`),this.Error(i);return}e.ResolveVariableWithName(this.name,this).found||this.Error(`Unresolved variable: ${this.name}`,this);}};vo.VariableReference=pd;});var es=E(So=>{Object.defineProperty(So,"__esModule",{value:true});So.FunctionCall=void 0;var Jt=Le(),KO=qr(),XO=Lr(),YO=Ct(),ZO=ot(),QO=ve(),bo=Wt(),wv=Va(),ex=Yn(),tx=ve(),nx=Wr(),Co=ae(),_o=class n extends YO.Expression{get proxyDivert(){return this._proxyDivert}get name(){return this._proxyDivert.target.firstComponent||""}get args(){return this._proxyDivert.args}get runtimeDivert(){return this._proxyDivert.runtimeDivert}get isChoiceCount(){return this.name==="CHOICE_COUNT"}get isTurns(){return this.name==="TURNS"}get isTurnsSince(){return this.name==="TURNS_SINCE"}get isRandom(){return this.name==="RANDOM"}get isSeedRandom(){return this.name==="SEED_RANDOM"}get isListRange(){return this.name==="LIST_RANGE"}get isListRandom(){return this.name==="LIST_RANDOM"}get isReadCount(){return this.name==="READ_COUNT"}constructor(e,t){super(),this._divertTargetToCount=null,this._variableReferenceToCount=null,this.shouldPopReturnedValue=false,this.GenerateIntoContainer=r=>{let i=this.story.ResolveList(this.name),a=false;if(this.isChoiceCount)this.args.length>0&&this.Error("The CHOICE_COUNT() function shouldn't take any arguments"),r.AddContent(Jt.ControlCommand.ChoiceCount());else if(this.isTurns)this.args.length>0&&this.Error("The TURNS() function shouldn't take any arguments"),r.AddContent(Jt.ControlCommand.Turns());else if(this.isTurnsSince||this.isReadCount){let s=(0, Co.asOrNull)(this.args[0],XO.DivertTarget),o=(0, Co.asOrNull)(this.args[0],nx.VariableReference);if(this.args.length!==1||s===null&&o===null){this.Error(`The ${this.name}() function should take one argument: a divert target to the target knot, stitch, gather or choice you want to check. e.g. TURNS_SINCE(-> myKnot)`);return}s?(this._divertTargetToCount=s,this.AddContent(this._divertTargetToCount),this._divertTargetToCount.GenerateIntoContainer(r)):o&&(this._variableReferenceToCount=o,this.AddContent(this._variableReferenceToCount),this._variableReferenceToCount.GenerateIntoContainer(r)),this.isTurnsSince?r.AddContent(Jt.ControlCommand.TurnsSince()):r.AddContent(Jt.ControlCommand.ReadCount());}else if(this.isRandom){this.args.length!==2&&this.Error("RANDOM should take 2 parameters: a minimum and a maximum integer");for(let s=0;s<this.args.length;s+=1){let o=(0, Co.asOrNull)(this.args[s],wv.NumberExpression);if(o&&!o.isInt()){let u=s===0?"minimum":"maximum";this.Error(`RANDOM's ${u} parameter should be an integer`);}this.args[s].GenerateIntoContainer(r);}r.AddContent(Jt.ControlCommand.Random());}else if(this.isSeedRandom){this.args.length!==1&&this.Error("SEED_RANDOM should take 1 parameter - an integer seed");let s=(0, Co.asOrNull)(this.args[0],wv.NumberExpression);s&&!s.isInt()&&this.Error("SEED_RANDOM's parameter should be an integer seed"),this.args[0].GenerateIntoContainer(r),r.AddContent(Jt.ControlCommand.SeedRandom());}else if(this.isListRange){this.args.length!==3&&this.Error("LIST_RANGE should take 3 parameters - a list, a min and a max");for(let s=0;s<this.args.length;s+=1)this.args[s].GenerateIntoContainer(r);r.AddContent(Jt.ControlCommand.ListRange());}else if(this.isListRandom)this.args.length!==1&&this.Error("LIST_RANDOM should take 1 parameter - a list"),this.args[0].GenerateIntoContainer(r),r.AddContent(Jt.ControlCommand.ListRandom());else if(bo.NativeFunctionCall.CallExistsWithName(this.name)){let s=bo.NativeFunctionCall.CallWithName(this.name);if(s.numberOfParameters!==this.args.length){let o=`${n.name} should take ${s.numberOfParameters} parameter`;s.numberOfParameters>1&&(o+="s"),this.Error(o);}for(let o=0;o<this.args.length;o+=1)this.args[o].GenerateIntoContainer(r);r.AddContent(bo.NativeFunctionCall.CallWithName(this.name));}else if(i!==null)if(this.args.length>1&&this.Error("Can currently only construct a list from one integer (or an empty list from a given list definition)"),this.args.length===1)r.AddContent(new tx.StringValue(this.name)),this.args[0].GenerateIntoContainer(r),r.AddContent(Jt.ControlCommand.ListFromInt());else {let s=new ZO.InkList;s.SetInitialOriginName(this.name),r.AddContent(new QO.ListValue(s));}else r.AddContent(this._proxyDivert.runtimeObject),a=true;a||this.content.splice(this.content.indexOf(this._proxyDivert),1),this.shouldPopReturnedValue&&r.AddContent(Jt.ControlCommand.PopEvaluatedValue());},this.toString=()=>{let r=this.args.join(", ");return `${this.name}(${r})`},this._proxyDivert=new KO.Divert(new ex.Path(e),t),this._proxyDivert.isFunctionCall=true,this.AddContent(this._proxyDivert);}get typeName(){return "FunctionCall"}ResolveReferences(e){if(super.ResolveReferences(e),!this.content.includes(this._proxyDivert)&&this.args!==null)for(let t of this.args)t.ResolveReferences(e);if(this._divertTargetToCount){let t=this._divertTargetToCount.divert,r=t.runtimeDivert.variableDivertName!=null;if(r){this.Error(`When getting the TURNS_SINCE() of a variable target, remove the '->' - i.e. it should just be TURNS_SINCE(${t.runtimeDivert.variableDivertName})`);return}let i=t.targetContent;if(i===null)r||this.Error(`Failed to find target for TURNS_SINCE: '${t.target}'`);else {if(!i.containerForCounting)throw new Error;i.containerForCounting.turnIndexShouldBeCounted=true;}}else if(this._variableReferenceToCount){let t=this._variableReferenceToCount.runtimeVarRef;if(!t)throw new Error;t.pathForCount!==null&&this.Error(`Should be '${n.name}'(-> '${this._variableReferenceToCount.name}). Usage without the '->' only makes sense for variable targets.`);}}};So.FunctionCall=_o;_o.IsBuiltIn=n=>bo.NativeFunctionCall.CallExistsWithName(n)?true:n==="CHOICE_COUNT"||n==="TURNS_SINCE"||n==="TURNS"||n==="RANDOM"||n==="SEED_RANDOM"||n==="LIST_VALUE"||n==="LIST_RANDOM"||n==="READ_COUNT";});var gd=E(Eo=>{Object.defineProperty(Eo,"__esModule",{value:true});Eo.MultipleConditionExpression=void 0;var rx=Ct(),ix=Wt(),md=class extends rx.Expression{get subExpressions(){return this.content}constructor(e){super(),this.GenerateIntoContainer=t=>{let r=true;for(let i of this.subExpressions)i.GenerateIntoContainer(t),r||t.AddContent(ix.NativeFunctionCall.CallWithName("&&")),r=false;},this.AddContent(e);}get typeName(){return "MultipleConditionExpression"}};Eo.MultipleConditionExpression=md;});var Lr=E(wo=>{Object.defineProperty(wo,"__esModule",{value:true});wo.DivertTarget=void 0;var sx=qh(),ax=Rr(),ox=to(),ux=bd(),lx=ve(),yd=Ct(),cx=Gt(),Dv=es(),hx=gd(),Av=Wr(),vd=ae(),Cd=class n extends yd.Expression{get runtimeDivert(){if(!this._runtimeDivert)throw new Error;return this._runtimeDivert}get runtimeDivertTargetValue(){if(!this._runtimeDivertTargetValue)throw new Error;return this._runtimeDivertTargetValue}constructor(e){super(),this._runtimeDivert=null,this._runtimeDivertTargetValue=null,this.GenerateIntoContainer=t=>{this.divert.GenerateRuntimeObject(),this._runtimeDivert=this.divert.runtimeDivert,this._runtimeDivertTargetValue=new lx.DivertTargetValue,t.AddContent(this.runtimeDivertTargetValue);},this.Equals=t=>{let r=(0, vd.asOrNull)(t,n);if(!r||!this.divert.target||!r.divert.target)return false;let i=this.divert.target.dotSeparatedComponents,a=r.divert.target.dotSeparatedComponents;return i===a},this.divert=this.AddContent(e);}get typeName(){return "DivertTarget"}ResolveReferences(e){if(super.ResolveReferences(e),this.divert.isDone||this.divert.isEnd){this.Error("Can't use -> DONE or -> END as variable divert targets",this);return}let t=this;for(;t&&t instanceof yd.Expression;){let i=false,a=false,s=t.parent;if(s instanceof sx.BinaryExpression){let o=s;o.opName!=="=="&&o.opName!=="!="?i=true:(o.leftExpression instanceof n||o.leftExpression instanceof Av.VariableReference)&&(o.rightExpression instanceof n||o.rightExpression instanceof Av.VariableReference)||(i=true),a=true;}else if(s instanceof Dv.FunctionCall){let o=s;!o.isTurnsSince&&!o.isReadCount&&(i=true),a=true;}else (s instanceof yd.Expression||s instanceof hx.MultipleConditionExpression||s instanceof ax.Choice&&s.condition===t||s instanceof ox.Conditional||s instanceof ux.ConditionalSingleBranch)&&(i=true,a=true);if(i&&this.Error(`Can't use a divert target like that. Did you intend to call '${this.divert.target}' as a function: likeThis(), or check the read count: likeThis, with no arrows?`,this),a)break;t=s;}if(this.runtimeDivert.hasVariableTarget){if(!this.divert.target)throw new Error;this.Error(`Since '${this.divert.target.dotSeparatedComponents}' is a variable, it shouldn't be preceded by '->' here.`);}this.runtimeDivert.targetPath&&(this.runtimeDivertTargetValue.targetPath=this.runtimeDivert.targetPath);let r=this.divert.targetContent;if(r!==null){let i=r.containerForCounting;if(i!==null){let s=(0, vd.asOrNull)(this.parent,Dv.FunctionCall);s&&s.isTurnsSince||(i.visitsShouldBeCounted=true),i.turnIndexShouldBeCounted=true;}let a=(0, vd.asOrNull)(r,cx.FlowBase);if(a!=null&&a.args!==null)for(let s of a.args)s.isByReference&&this.Error(`Can't store a divert target to a knot or function that has by-reference arguments ('${a.identifier}' has 'ref ${s.identifier}').`);}}};wo.DivertTarget=Cd;});var qr=E(Do=>{Object.defineProperty(Do,"__esModule",{value:true});Do.Divert=void 0;var dx=Ee(),ts=Le(),fx=Mt(),_d=Lr(),Sd=Gt(),px=es(),mx=ye(),Pv=Yn(),gx=it(),Ov=Kn(),yx=ve(),xv=Wr(),vx=Qi(),ns=ae(),Ed=class extends mx.ParsedObject{get runtimeDivert(){if(!this._runtimeDivert)throw new Error;return this._runtimeDivert}set runtimeDivert(e){this._runtimeDivert=e;}get isEnd(){return !!(this.target&&this.target.dotSeparatedComponents==="END")}get isDone(){return !!(this.target&&this.target.dotSeparatedComponents==="DONE")}constructor(e,t){super(),this.args=[],this.target=null,this.targetContent=null,this._runtimeDivert=null,this.isFunctionCall=false,this.isEmpty=false,this.isTunnel=false,this.isThread=false,this.GenerateRuntimeObject=()=>{if(this.isEnd)return ts.ControlCommand.End();if(this.isDone)return ts.ControlCommand.Done();this.runtimeDivert=new fx.Divert,this.ResolveTargetContent(),this.CheckArgumentValidity();let r=this.args!==null&&this.args.length>0;if(r||this.isFunctionCall||this.isTunnel||this.isThread){let i=new dx.Container;if(r){this.isFunctionCall||i.AddContent(ts.ControlCommand.EvalStart());let a=null;this.targetContent&&(a=this.targetContent.args);for(let s=0;s<this.args.length;++s){let o=this.args[s],u=null;if(a&&s<a.length&&(u=a[s]),u&&u.isByReference){let l=(0, ns.asOrNull)(o,xv.VariableReference);if(!l){this.Error(`Expected variable name to pass by reference to 'ref ${u.identifier}' but saw ${o}`);break}let c=new Pv.Path(l.pathIdentifiers);if(c.ResolveFromContext(this)){this.Error(`can't pass a read count by reference. '${c.dotSeparatedComponents}' is a knot/stitch/label, but '${this.target.dotSeparatedComponents}' requires the name of a VAR to be passed.`);break}let p=new yx.VariablePointerValue(l.name);i.AddContent(p);}else o.GenerateIntoContainer(i);}this.isFunctionCall||i.AddContent(ts.ControlCommand.EvalEnd());}return this.isThread?i.AddContent(ts.ControlCommand.StartThread()):(this.isFunctionCall||this.isTunnel)&&(this.runtimeDivert.pushesToStack=true,this.runtimeDivert.stackPushType=this.isFunctionCall?Ov.PushPopType.Function:Ov.PushPopType.Tunnel),i.AddContent(this.runtimeDivert),i}return this.runtimeDivert},this.PathAsVariableName=()=>this.target?this.target.firstComponent:null,this.ResolveTargetContent=()=>{if(!(this.isEmpty||this.isEnd)&&this.targetContent===null){let r=this.PathAsVariableName();if(r!==null){let i=(0, ns.asOrNull)((0, vx.ClosestFlowBase)(this),Sd.FlowBase);if(i){let a=i.ResolveVariableWithName(r,this);if(a.found){if(a.isArgument&&a.ownerFlow&&a.ownerFlow.args){let s=a.ownerFlow.args.find(o=>{var u;return ((u=o.identifier)===null||u===void 0?void 0:u.name)==r});s&&!s.isDivertTarget&&this.Error(`Since '${s.identifier}' is used as a variable divert target (on ${this.debugMetadata}), it should be marked as: -> ${s.identifier}`,a.ownerFlow);}this.runtimeDivert.variableDivertName=r;return}}}if(!this.target)throw new Error;this.targetContent=this.target.ResolveFromContext(this);}},this.CheckArgumentValidity=()=>{if(this.isEmpty)return;let r=0;if(this.args!==null&&this.args.length>0&&(r=this.args.length),this.targetContent===null)return;let i=(0, ns.asOrNull)(this.targetContent,Sd.FlowBase);if(r===0&&(i===null||!i.hasParameters))return;if(i===null&&r>0){this.Error("target needs to be a knot or stitch in order to pass arguments");return}else if(i!==null&&(i.args===null||!i.args&&r>0)){this.Error(`target (${i.name}) doesn't take parameters`);return}else if(this.parent instanceof _d.DivertTarget){r>0&&this.Error("can't store arguments in a divert target variable");return}let a=i.args.length;if(a!==r){let s;r===0?s="but there weren't any passed to it":r<a?s=`but only got ${r}`:s=`but got ${r}`,this.Error(`to '${i.identifier}' requires ${a} arguments, ${s}`);return}for(let s=0;s<a;++s){let o=i.args[s],u=this.args[s];if(o.isDivertTarget){let l=(0, ns.asOrNull)(u,xv.VariableReference);if(!(u instanceof _d.DivertTarget)&&l===null)this.Error(`Target '${i.identifier}' expects a divert target for the parameter named -> ${o.identifier} but saw ${u}`,u);else if(l){let c=new Pv.Path(l.pathIdentifiers);c.ResolveFromContext(l)&&this.Error(`Passing read count of '${c.dotSeparatedComponents}' instead of a divert target. You probably meant '${c}'`);}}}if(i===null){this.Error("Can't call as a function or with arguments unless it's a knot or stitch");return}},this.CheckExternalArgumentValidity=r=>{let i=this.target?this.target.firstComponent:null,a=r.externals.get(i);if(!a)throw new Error("external not found");let s=a.argumentNames.length,o=0;this.args&&(o=this.args.length),o!==s&&this.Error(`incorrect number of arguments sent to external function '${i}'. Expected ${s} but got ${o}`);},this.toString=()=>{let r="";if(this.target!==null)r+=this.target.toString();else return "-> <empty divert>";return this.isTunnel&&(r+=" ->"),this.isFunctionCall&&(r+=" ()"),r},e&&(this.target=e),t&&(this.args=t,this.AddContent(t));}get typeName(){return "Divert"}ResolveReferences(e){if(this.isEmpty||this.isEnd||this.isDone)return;if(!this.runtimeDivert)throw new Error;this.targetContent&&(this.runtimeDivert.targetPath=this.targetContent.runtimePath),super.ResolveReferences(e);let t=(0, ns.asOrNull)(this.targetContent,Sd.FlowBase);t&&(!t.isFunction&&this.isFunctionCall?super.Error(`${t.identifier} hasn't been marked as a function, but it's being called as one. Do you need to declare the knot as '== function ${t.identifier} =='?`):t.isFunction&&!this.isFunctionCall&&!(this.parent instanceof _d.DivertTarget)&&super.Error(t.identifier+" can't be diverted to. It can only be called as a function since it's been marked as such: '"+t.identifier+"(...)'"));let r=this.targetContent!==null,i=false,a=false;if(this.target){if(this.target.numberOfComponents===1){if(!this.target.firstComponent)throw new Error;if(i=px.FunctionCall.IsBuiltIn(this.target.firstComponent),a=e.IsExternal(this.target.firstComponent),i||a){this.isFunctionCall||super.Error(`${this.target.firstComponent} must be called as a function: ~ ${this.target.firstComponent}()`),a&&(this.runtimeDivert.isExternal=true,this.args!==null&&(this.runtimeDivert.externalArgs=this.args.length),this.runtimeDivert.pushesToStack=false,this.runtimeDivert.targetPath=new gx.Path(this.target.firstComponent),this.CheckExternalArgumentValidity(e));return}}}else throw new Error;this.runtimeDivert.variableDivertName==null&&!r&&!i&&!a&&this.Error(`target not found: '${this.target}'`);}Error(e,t=null,r=false){if(t!==this&&t){super.Error(e,t);return}this.isFunctionCall?super.Error(`Function call ${e}`,t,r):super.Error(`Divert ${e}`,t,r);}};Do.Divert=Ed;});var Tv=E(Ao=>{Object.defineProperty(Ao,"__esModule",{value:true});Ao.GatherPointToResolve=void 0;var wd=class{constructor(e,t){this.divert=e,this.targetRuntimeObj=t;}};Ao.GatherPointToResolve=wd;});var Nv=E(Po=>{Object.defineProperty(Po,"__esModule",{value:true});Po.SequenceDivertToResolve=void 0;var Dd=class{constructor(e,t){this.divert=e,this.targetContent=t;}};Po.SequenceDivertToResolve=Dd;});var Ad=E(Oo=>{Object.defineProperty(Oo,"__esModule",{value:true});Oo.SequenceType=void 0;var Fv;(function(n){n[n.Stopping=1]="Stopping",n[n.Cycle=2]="Cycle",n[n.Shuffle=4]="Shuffle",n[n.Once=8]="Once";})(Fv||(Oo.SequenceType=Fv={}));});var xd=E(No=>{Object.defineProperty(No,"__esModule",{value:true});No.Sequence=void 0;var Iv=Ee(),Nt=Le(),Pd=Mt(),rs=ve(),xo=Wt(),Cx=ye(),bx=Nv(),To=Ad(),_x=Zn(),Od=class extends Cx.ParsedObject{constructor(e,t){super(),this.sequenceType=t,this._sequenceDivertsToResolve=[],this.GenerateRuntimeObject=()=>{let r=new Iv.Container;r.visitsShouldBeCounted=true,r.countingAtStartOnly=true,this._sequenceDivertsToResolve=[],r.AddContent(Nt.ControlCommand.EvalStart()),r.AddContent(Nt.ControlCommand.VisitIndex());let i=(this.sequenceType&To.SequenceType.Once)>0,a=(this.sequenceType&To.SequenceType.Cycle)>0,s=(this.sequenceType&To.SequenceType.Stopping)>0,o=(this.sequenceType&To.SequenceType.Shuffle)>0,u=this.sequenceElements.length;if(i&&(u+=1),s||i?(r.AddContent(new rs.IntValue(u-1)),r.AddContent(xo.NativeFunctionCall.CallWithName("MIN"))):a&&(r.AddContent(new rs.IntValue(this.sequenceElements.length)),r.AddContent(xo.NativeFunctionCall.CallWithName("%"))),o){let c=Nt.ControlCommand.NoOp();if(i||s){let p=s?this.sequenceElements.length-1:this.sequenceElements.length;r.AddContent(Nt.ControlCommand.Duplicate()),r.AddContent(new rs.IntValue(p)),r.AddContent(xo.NativeFunctionCall.CallWithName("=="));let f=new Pd.Divert;f.isConditional=true,r.AddContent(f),this.AddDivertToResolve(f,c);}let h=this.sequenceElements.length;s&&(h-=1),r.AddContent(new rs.IntValue(h)),r.AddContent(Nt.ControlCommand.SequenceShuffleIndex()),(i||s)&&r.AddContent(c);}r.AddContent(Nt.ControlCommand.EvalEnd());let l=Nt.ControlCommand.NoOp();for(let c=0;c<u;c+=1){r.AddContent(Nt.ControlCommand.EvalStart()),r.AddContent(Nt.ControlCommand.Duplicate()),r.AddContent(new rs.IntValue(c)),r.AddContent(xo.NativeFunctionCall.CallWithName("==")),r.AddContent(Nt.ControlCommand.EvalEnd());let h=new Pd.Divert;h.isConditional=true,r.AddContent(h);let p;c<this.sequenceElements.length?p=this.sequenceElements[c].runtimeObject:p=new Iv.Container,p.name=`s${c}`,p.InsertContent(Nt.ControlCommand.PopEvaluatedValue(),0);let f=new Pd.Divert;p.AddContent(f),r.AddToNamedContentOnly(p),this.AddDivertToResolve(h,p),this.AddDivertToResolve(f,l);}return r.AddContent(l),r},this.AddDivertToResolve=(r,i)=>{this._sequenceDivertsToResolve.push(new bx.SequenceDivertToResolve(r,i));},this.sequenceType=t,this.sequenceElements=[];for(let r of e){let i=r.content,a=null;i===null||i.length===0?a=r:a=new _x.Weave(i),this.sequenceElements.push(a),this.AddContent(a);}}get typeName(){return "Sequence"}ResolveReferences(e){super.ResolveReferences(e);for(let t of this._sequenceDivertsToResolve)t.divert.targetPath=t.targetContent.path;}};No.Sequence=Od;});var Nd=E(Fo=>{Object.defineProperty(Fo,"__esModule",{value:true});Fo.TunnelOnwards=void 0;var Sx=Ee(),is=Le(),Ex=Mt(),wx=ve(),Dx=ye(),Ax=Un(),Px=ae(),Ox=Br(),Td=class extends Dx.ParsedObject{constructor(){super(...arguments),this._overrideDivertTarget=null,this._divertAfter=null,this.GenerateRuntimeObject=()=>{let e=new Sx.Container;if(e.AddContent(is.ControlCommand.EvalStart()),this.divertAfter){let t=this.divertAfter.GenerateRuntimeObject(),r=t;if(r){let a=this.divertAfter.args;if(a!==null&&a.length>0){let s=-1,o=-1;for(let u=0;u<r.content.length;u+=1){let l=r.content[u];l&&(s==-1&&l.commandType===is.ControlCommand.CommandType.EvalStart?s=u:l.commandType===is.ControlCommand.CommandType.EvalEnd&&(o=u));}for(let u=s+1;u<o;u+=1){let l=r.content[u];l.parent=null,e.AddContent(r.content[u]);}}}let i=(0, Px.asOrNull)(t,Ex.Divert);if(i!=null&&i.hasVariableTarget){let a=new Ox.VariableReference(i.variableDivertName);e.AddContent(a);}else this._overrideDivertTarget=new wx.DivertTargetValue,e.AddContent(this._overrideDivertTarget);}else e.AddContent(new Ax.Void);return e.AddContent(is.ControlCommand.EvalEnd()),e.AddContent(is.ControlCommand.PopTunnel()),e},this.toString=()=>` -> ${this._divertAfter}`;}get divertAfter(){return this._divertAfter}set divertAfter(e){this._divertAfter=e,this._divertAfter&&this.AddContent(this._divertAfter);}get typeName(){return "TunnelOnwards"}ResolveReferences(e){super.ResolveReferences(e),this.divertAfter&&this.divertAfter.targetContent&&(this._overrideDivertTarget.targetPath=this.divertAfter.targetContent.runtimePath);}};Fo.TunnelOnwards=Td;});var kd=E(Io=>{Object.defineProperty(Io,"__esModule",{value:true});Io.ListDefinition=void 0;var Fd=ot(),Id=class{constructor(e,t){this._name=e||"",this._items=null,this._itemNameToValues=t||new Map;}get name(){return this._name}get items(){if(this._items==null){this._items=new Map;for(let[e,t]of this._itemNameToValues){let r=new Fd.InkListItem(this.name,e);this._items.set(r.serialized(),t);}}return this._items}ValueForItem(e){if(!e.itemName)return 0;let t=this._itemNameToValues.get(e.itemName);return typeof t<"u"?t:0}ContainsItem(e){return !e.itemName||e.originName!=this.name?false:this._itemNameToValues.has(e.itemName)}ContainsItemWithName(e){return this._itemNameToValues.has(e)}TryGetItemWithValue(e,t){for(let[r,i]of this._itemNameToValues)if(i==e)return t=new Fd.InkListItem(this.name,r),{result:t,exists:true};return t=Fd.InkListItem.Null,{result:t,exists:false}}TryGetValueForItem(e,t){if(!e.itemName)return {result:0,exists:false};let r=this._itemNameToValues.get(e.itemName);return r?{result:r,exists:true}:{result:0,exists:false}}};Io.ListDefinition=Id;});var Vo=E(ko=>{Object.defineProperty(ko,"__esModule",{value:true});ko.ListDefinition=void 0;var xx=ot(),Tx=ot(),Nx=kd(),Fx=ve(),Ix=ye(),kx=nn(),Vd=class extends Ix.ParsedObject{get typeName(){return "ListDefinition"}get runtimeListDefinition(){var e;let t=new Map;for(let r of this.itemDefinitions)t.has(r.name)?this.Error(`List '${this.identifier}' contains duplicate items called '${r.name}'`):t.set(r.name,r.seriesValue);return new Nx.ListDefinition(((e=this.identifier)===null||e===void 0?void 0:e.name)||"",t)}constructor(e){super(),this.itemDefinitions=e,this.identifier=null,this.variableAssignment=null,this._elementsByName=null,this.ItemNamed=r=>{if(this._elementsByName===null){this._elementsByName=new Map;for(let a of this.itemDefinitions)this._elementsByName.set(a.name,a);}return this._elementsByName.get(r)||null},this.GenerateRuntimeObject=()=>{var r,i;let a=new xx.InkList;for(let s of this.itemDefinitions)if(s.inInitialList){let o=new Tx.InkListItem(((r=this.identifier)===null||r===void 0?void 0:r.name)||null,s.name||null);a.Add(o,s.seriesValue);}return a.SetInitialOriginName(((i=this.identifier)===null||i===void 0?void 0:i.name)||""),new Fx.ListValue(a)};let t=1;for(let r of this.itemDefinitions)r.explicitValue!==null&&(t=r.explicitValue),r.seriesValue=t,t+=1;this.AddContent(e);}ResolveReferences(e){super.ResolveReferences(e),e.CheckForNamingCollisions(this,this.identifier,kx.SymbolType.List);}};ko.ListDefinition=Vd;});var $d=E(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});Ro.VariableAssignment=void 0;var Vx=Ee(),Rx=Qi(),$x=Vo(),jx=ye(),kv=nn(),Lx=bn(),qx=Wr(),Bx=ae(),Rd=class extends jx.ParsedObject{get variableName(){return this.variableIdentifier.name}get typeName(){return this.isNewTemporaryDeclaration?"temp":this.isGlobalDeclaration?this.listDefinition!==null?"LIST":"VAR":"variable assignment"}get isDeclaration(){return this.isGlobalDeclaration||this.isNewTemporaryDeclaration}constructor({assignedExpression:e,isGlobalDeclaration:t,isTemporaryNewDeclaration:r,listDef:i,variableIdentifier:a}){super(),this._runtimeAssignment=null,this.expression=null,this.listDefinition=null,this.GenerateRuntimeObject=()=>{let s=null;if(this.isGlobalDeclaration?s=this.story:this.isNewTemporaryDeclaration&&(s=(0, Rx.ClosestFlowBase)(this)),s&&s.AddNewVariableDeclaration(this),this.isGlobalDeclaration)return null;let o=new Vx.Container;return this.expression?o.AddContent(this.expression.runtimeObject):this.listDefinition&&o.AddContent(this.listDefinition.runtimeObject),this._runtimeAssignment=new Lx.VariableAssignment(this.variableName,this.isNewTemporaryDeclaration),o.AddContent(this._runtimeAssignment),o},this.toString=()=>`${this.isGlobalDeclaration?"VAR":this.isNewTemporaryDeclaration?"~ temp":""} ${this.variableName}`,this.variableIdentifier=a,this.isGlobalDeclaration=!!t,this.isNewTemporaryDeclaration=!!r,i instanceof $x.ListDefinition?(this.listDefinition=this.AddContent(i),this.listDefinition.variableAssignment=this,this.isGlobalDeclaration=true):e&&(this.expression=this.AddContent(e));}ResolveReferences(e){if(super.ResolveReferences(e),this.isDeclaration&&this.listDefinition===null&&e.CheckForNamingCollisions(this,this.variableIdentifier,this.isGlobalDeclaration?kv.SymbolType.Var:kv.SymbolType.Temp),this.isGlobalDeclaration){let t=(0, Bx.asOrNull)(this.expression,qx.VariableReference);t&&!t.isConstantReference&&!t.isListItemReference&&this.Error("global variable assignments cannot refer to other variables, only literal values, constants and list items");}if(!this.isNewTemporaryDeclaration){let t=e.ResolveVariableWithName(this.variableName,this);t.found||(this.variableName in this.story.constants?this.Error(`Can't re-assign to a constant (do you need to use VAR when declaring '${this.variableName}'?)`,this):this.Error(`Variable could not be found to assign to: '${this.variableName}'`,this)),this._runtimeAssignment&&(this._runtimeAssignment.isGlobal=t.isGlobal);}}};Ro.VariableAssignment=Rd;});var Zn=E(Lo=>{Object.defineProperty(Lo,"__esModule",{value:true});Lo.Weave=void 0;var Vv=Ca(),_t=Rr(),$o=to(),Wx=io(),Mx=Ee(),jo=qr(),Gx=Mt(),zx=Lr(),Jx=Gt(),Ht=Zi(),Hx=Tv(),Ux=ye(),jd=xd(),Kx=Sn(),Xx=Nd(),Yx=$d(),St=ae(),Ld=class n extends Ux.ParsedObject{get rootContainer(){return this._rootContainer||(this._rootContainer=this.GenerateRuntimeObject()),this._rootContainer}get namedWeavePoints(){return this._namedWeavePoints}get lastParsedSignificantObject(){if(this.content.length===0)return null;let e=null;for(let r=this.content.length-1;r>=0;--r){e=this.content[r];let i=(0, St.asOrNull)(e,Kx.Text);if(!(i&&i.text===`
|
|
22
|
-
`)&&!this.IsGlobalDeclaration(e))break}let t=(0,
|
|
23
|
-
`),0),(r||this.isElse&&this.matchingEquality)&&this._contentContainer.InsertContent(qo.ControlCommand.PopEvaluatedValue(),0),t.AddToNamedContentOnly(this._contentContainer),this.returnDivert=new $v.Divert,this._contentContainer.AddContent(this.returnDivert),t},this.GenerateRuntimeForContent=()=>this._innerWeave===null?new Rv.Container:this._innerWeave.rootContainer,e&&(this._innerWeave=new nT.Weave(e),this.AddContent(this._innerWeave));}get typeName(){return "ConditionalSingleBranch"}ResolveReferences(e){if(!this._conditionalDivert||!this._contentContainer)throw new Error;this._conditionalDivert.targetPath=this._contentContainer.path,super.ResolveReferences(e);}};Bo.ConditionalSingleBranch=qd;});var Lv=E(Wo=>{Object.defineProperty(Wo,"__esModule",{value:true});Wo.CustomFlags=void 0;var jv;(function(n){n[n.ParsingString=1]="ParsingString",n[n.TagActive=2]="TagActive";})(jv||(Wo.CustomFlags=jv={}));});var qv=E(Mo=>{Object.defineProperty(Mo,"__esModule",{value:true});Mo.DebugMetadata=void 0;var Bd=class n{constructor(){this.startLineNumber=0,this.endLineNumber=0,this.startCharacterNumber=0,this.endCharacterNumber=0,this.fileName=null,this.sourceName=null;}Merge(e){let t=new n;return t.fileName=this.fileName,t.sourceName=this.sourceName,this.startLineNumber<e.startLineNumber?(t.startLineNumber=this.startLineNumber,t.startCharacterNumber=this.startCharacterNumber):this.startLineNumber>e.startLineNumber?(t.startLineNumber=e.startLineNumber,t.startCharacterNumber=e.startCharacterNumber):(t.startLineNumber=this.startLineNumber,t.startCharacterNumber=Math.min(this.startCharacterNumber,e.startCharacterNumber)),this.endLineNumber>e.endLineNumber?(t.endLineNumber=this.endLineNumber,t.endCharacterNumber=this.endCharacterNumber):this.endLineNumber<e.endLineNumber?(t.endLineNumber=e.endLineNumber,t.endCharacterNumber=e.endCharacterNumber):(t.endLineNumber=this.endLineNumber,t.endCharacterNumber=Math.max(this.endCharacterNumber,e.endCharacterNumber)),t}toString(){return this.fileName!==null?`line ${this.startLineNumber} of ${this.fileName}"`:"line "+this.startLineNumber}};Mo.DebugMetadata=Bd;});var Bv=E(Go=>{Object.defineProperty(Go,"__esModule",{value:true});Go.ExternalDeclaration=void 0;var iT=ye(),Wd=class extends iT.ParsedObject{get name(){var e;return ((e=this.identifier)===null||e===void 0?void 0:e.name)||null}constructor(e,t){super(),this.identifier=e,this.argumentNames=t,this.GenerateRuntimeObject=()=>(this.story.AddExternal(this),null);}get typeName(){return "EXTERNAL"}toString(){var e;return `EXTERNAL ${(e=this.identifier)===null||e===void 0?void 0:e.name}`}};Go.ExternalDeclaration=Wd;});var Wv=E(zo=>{Object.defineProperty(zo,"__esModule",{value:true});zo.FlowDecl=void 0;var Md=class{constructor(e,t,r){this.name=e,this.args=t,this.isFunction=r;}};zo.FlowDecl=Md;});var zd=E(Jo=>{Object.defineProperty(Jo,"__esModule",{value:true});Jo.Wrap=void 0;var sT=ye(),Gd=class extends sT.ParsedObject{constructor(e){super(),this._objToWrap=e,this.GenerateRuntimeObject=()=>this._objToWrap;}};Jo.Wrap=Gd;});var Mv=E(Ho=>{Object.defineProperty(Ho,"__esModule",{value:true});Ho.Glue=void 0;var aT=zd(),Jd=class extends aT.Wrap{constructor(e){super(e);}get typeName(){return "Glue"}};Ho.Glue=Jd;});var Ko=E(Uo=>{Object.defineProperty(Uo,"__esModule",{value:true});Uo.Glue=void 0;var oT=st(),Hd=class extends oT.InkObject{toString(){return "Glue"}};Uo.Glue=Hd;});var zv=E(Xo=>{Object.defineProperty(Xo,"__esModule",{value:true});Xo.IncDecExpression=void 0;var uT=go(),Gv=Ct(),lT=Gt(),cT=Wt(),hT=ve(),dT=bn(),fT=Br(),pT=Zn(),Ud=class extends Gv.Expression{constructor(e,t,r){super(),this.varIdentifier=e,this._runtimeAssignment=null,this.expression=null,this.GenerateIntoContainer=i=>{var a,s;i.AddContent(new fT.VariableReference(((a=this.varIdentifier)===null||a===void 0?void 0:a.name)||null)),this.expression?this.expression.GenerateIntoContainer(i):i.AddContent(new hT.IntValue(1)),i.AddContent(cT.NativeFunctionCall.CallWithName(this.isInc?"+":"-")),this._runtimeAssignment=new dT.VariableAssignment(((s=this.varIdentifier)===null||s===void 0?void 0:s.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?"++":"--")},t instanceof Gv.Expression?(this.expression=t,this.AddContent(this.expression),this.isInc=!!r):this.isInc=t;}get typeName(){return "IncDecExpression"}ResolveReferences(e){var t;super.ResolveReferences(e);let r=e.ResolveVariableWithName(((t=this.varIdentifier)===null||t===void 0?void 0:t.name)||"",this);if(r.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=r.isGlobal,!(this.parent instanceof pT.Weave)&&!(this.parent instanceof lT.FlowBase)&&!(this.parent instanceof uT.ContentList)&&this.Error(`Can't use ${this.incrementDecrementWord} as sub-expression`);}get incrementDecrementWord(){return this.isInc?"increment":"decrement"}};Xo.IncDecExpression=Ud;});var Xd=E(Yo=>{Object.defineProperty(Yo,"__esModule",{value:true});Yo.IncludedFile=void 0;var mT=ye(),Kd=class extends mT.ParsedObject{constructor(e){super(),this.includedStory=e,this.GenerateRuntimeObject=()=>null;}get typeName(){return "IncludedFile"}};Yo.IncludedFile=Kd;});var Jv=E(Zo=>{Object.defineProperty(Zo,"__esModule",{value:true});Zo.InfixOperator=void 0;var Yd=class{constructor(e,t,r){this.type=e,this.precedence=t,this.requireWhitespace=r,this.toString=()=>this.type;}};Zo.InfixOperator=Yd;});var Qd=E(Qo=>{Object.defineProperty(Qo,"__esModule",{value:true});Qo.Knot=void 0;var gT=Gt(),Hv=$r(),Zd=class extends gT.FlowBase{get flowLevel(){return Hv.FlowLevel.Knot}constructor(e,t,r,i){super(e,t,r,i);}get typeName(){return this.isFunction?"Function":"Knot"}ResolveReferences(e){super.ResolveReferences(e);let t=this.story;for(let r in this.subFlowsByName){let i=t.ContentWithNameAtLevel(r,Hv.FlowLevel.Knot,false);if(i){let a=this.subFlowsByName.get(r),s=`Stitch '${a?a.name:"NO STITCH FOUND"}' has the same name as a knot (on ${i.debugMetadata})`;this.Error(s,a);}}}};Qo.Knot=Zd;});var Uv=E(eu=>{Object.defineProperty(eu,"__esModule",{value:true});eu.List=void 0;var yT=Ct(),vT=ot(),CT=ot(),bT=ve(),ef=class extends yT.Expression{constructor(e){super(),this.itemIdentifierList=e,this.GenerateIntoContainer=t=>{var r,i;let a=new vT.InkList;if(this.itemIdentifierList!=null)for(let s of this.itemIdentifierList){let o=((r=s?.name)===null||r===void 0?void 0:r.split("."))||[],u=null,l="";o.length>1?(u=o[0],l=o[1]):l=o[0];let c=this.story.ResolveListItem(u,l,this);if(c===null)u===null?this.Error(`Could not find list definition that contains item '${s}'`):this.Error(`Could not find list item ${s}`);else {if(c.parent==null){this.Error(`Could not find list definition for item ${s}`);return}u||(u=((i=c.parent.identifier)===null||i===void 0?void 0:i.name)||null);let h=new CT.InkListItem(u,c.name||null);a.has(h.serialized())?this.Warning(`Duplicate of item '${s}' in list.`):a.Add(h,c.seriesValue);}}t.AddContent(new bT.ListValue(a));};}get typeName(){return "List"}};eu.List=ef;});var nf=E(tu=>{Object.defineProperty(tu,"__esModule",{value:true});tu.ListElementDefinition=void 0;var _T=ye(),ST=nn(),tf=class extends _T.ParsedObject{get fullName(){var e;let t=this.parent;if(t===null)throw new Error("Can't get full name without a parent list.");return `${(e=t.identifier)===null||e===void 0?void 0:e.name}.${this.name}`}get typeName(){return "ListElement"}get name(){var e;return ((e=this.indentifier)===null||e===void 0?void 0:e.name)||null}constructor(e,t,r=null){super(),this.indentifier=e,this.inInitialList=t,this.explicitValue=r,this.seriesValue=0,this.parent=null,this.GenerateRuntimeObject=()=>{throw new Error("Not implemented.")},this.toString=()=>this.fullName,this.parent=this.parent;}ResolveReferences(e){super.ResolveReferences(e),e.CheckForNamingCollisions(this,this.indentifier,ST.SymbolType.ListItem);}};tu.ListElementDefinition=tf;});var rf=E(nu=>{Object.defineProperty(nu,"__esModule",{value:true});nu.StatementLevel=void 0;var Kv;(function(n){n[n.InnerBlock=0]="InnerBlock",n[n.Stitch=1]="Stitch",n[n.Knot=2]="Knot",n[n.Top=3]="Top";})(Kv||(nu.StatementLevel=Kv={}));});var af=E(ru=>{Object.defineProperty(ru,"__esModule",{value:true});ru.Stitch=void 0;var ET=Gt(),wT=$r(),sf=class extends ET.FlowBase{get flowLevel(){return wT.FlowLevel.Stitch}constructor(e,t,r,i){super(e,t,r,i),this.baseToString=this.toString,this.toString=()=>`${this.parent!==null?this.parent+" > ":""}${this.baseToString()}`;}get typeName(){return "Stitch"}};ru.Stitch=sf;});var su=E(iu=>{Object.defineProperty(iu,"__esModule",{value:true});iu.Tag=void 0;var DT=st(),of=class extends DT.InkObject{constructor(e){super(),this.text=e.toString()||"";}toString(){return "# "+this.text}};iu.Tag=of;});var lf=E(au=>{Object.defineProperty(au,"__esModule",{value:true});au.Choice=void 0;var AT=it(),PT=je(),OT=st(),uf=class n extends OT.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, PT.throwNullException)("Choice.targetPath"):this.targetPath.toString()}set pathStringOnChoice(e){this.targetPath=new AT.Path(e);}Clone(){let e=new n;return e.text=this.text,e.sourcePath=this.sourcePath,e.index=this.index,e.targetPath=this.targetPath,e.originalThreadIndex=this.originalThreadIndex,e.isInvisibleDefault=this.isInvisibleDefault,this.threadAtGeneration!==null&&(e.threadAtGeneration=this.threadAtGeneration.Copy()),e}};au.Choice=uf;});var hf=E(ou=>{Object.defineProperty(ou,"__esModule",{value:true});ou.ListDefinitionsOrigin=void 0;var xT=ot(),TT=ve(),NT=je(),cf=class{constructor(e){this._lists=new Map,this._allUnambiguousListValueCache=new Map;for(let t of e){this._lists.set(t.name,t);for(let[r,i]of t.items){let a=xT.InkListItem.fromSerializedKey(r),s=new TT.ListValue(a,i);if(!a.itemName)throw new Error("item.itemName is null or undefined.");this._allUnambiguousListValueCache.set(a.itemName,s),this._allUnambiguousListValueCache.set(a.fullName,s);}}}get lists(){let e=[];for(let[,t]of this._lists)e.push(t);return e}TryListGetDefinition(e,t){if(e===null)return {result:t,exists:false};let r=this._lists.get(e);return r?{result:r,exists:true}:{result:t,exists:false}}FindSingleItemListWithName(e){if(e===null)return (0, NT.throwNullException)("name");let t=this._allUnambiguousListValueCache.get(e);return typeof t<"u"?t:null}};ou.ListDefinitionsOrigin=cf;});var Gr=E(hu=>{Object.defineProperty(hu,"__esModule",{value:true});hu.JsonSerialisation=void 0;var uu=Ee(),lt=ve(),Xv=Ko(),ne=Le(),Mr=Kn(),Yv=Mt(),Zv=Ba(),df=Br(),Qv=bn(),ff=Wt(),e0=Un(),t0=su(),FT=it(),n0=lf(),IT=kd(),kT=hf(),lu=ot(),we=ae(),Qn=je(),cu=class n{static JArrayToRuntimeObjList(e,t=false){let r=e.length;t&&r--;let i=[];for(let a=0;a<r;a++){let s=e[a],o=this.JTokenToRuntimeObject(s);if(o===null)return (0, Qn.throwNullException)("runtimeObj");i.push(o);}return i}static WriteDictionaryRuntimeObjs(e,t){e.WriteObjectStart();for(let[r,i]of t)e.WritePropertyStart(r),this.WriteRuntimeObject(e,i),e.WritePropertyEnd();e.WriteObjectEnd();}static WriteListRuntimeObjs(e,t){e.WriteArrayStart();for(let r of t)this.WriteRuntimeObject(e,r);e.WriteArrayEnd();}static WriteIntDictionary(e,t){e.WriteObjectStart();for(let[r,i]of t)e.WriteIntProperty(r,i);e.WriteObjectEnd();}static WriteRuntimeObject(e,t){let r=(0, we.asOrNull)(t,uu.Container);if(r){this.WriteRuntimeContainer(e,r);return}let i=(0, we.asOrNull)(t,Yv.Divert);if(i){let m="->";i.isExternal?m="x()":i.pushesToStack&&(i.stackPushType==Mr.PushPopType.Function?m="f()":i.stackPushType==Mr.PushPopType.Tunnel&&(m="->t->"));let b;i.hasVariableTarget?b=i.variableDivertName:b=i.targetPathString,e.WriteObjectStart(),e.WriteProperty(m,b),i.hasVariableTarget&&e.WriteProperty("var",true),i.isConditional&&e.WriteProperty("c",true),i.externalArgs>0&&e.WriteIntProperty("exArgs",i.externalArgs),e.WriteObjectEnd();return}let a=(0, we.asOrNull)(t,Zv.ChoicePoint);if(a){e.WriteObjectStart(),e.WriteProperty("*",a.pathStringOnChoice),e.WriteIntProperty("flg",a.flags),e.WriteObjectEnd();return}let s=(0, we.asOrNull)(t,lt.BoolValue);if(s){e.WriteBool(s.value);return}let o=(0, we.asOrNull)(t,lt.IntValue);if(o){e.WriteInt(o.value);return}let u=(0, we.asOrNull)(t,lt.FloatValue);if(u){e.WriteFloat(u.value);return}let l=(0, we.asOrNull)(t,lt.StringValue);if(l){l.isNewline?e.Write(`
|
|
24
|
-
`,false):(e.WriteStringStart(),e.WriteStringInner("^"),e.WriteStringInner(l.value),e.WriteStringEnd());return}let c=(0,
|
|
25
|
-
`&&t.length==1)return new
|
|
26
|
-
`);if(t=="<>")return new Xv.Glue;for(let a=0;a<n._controlCommandNames.length;++a){let s=n._controlCommandNames[a];if(t==s)return new ne.ControlCommand(a)}if(t=="L^"&&(t="^"),ff.NativeFunctionCall.CallExistsWithName(t))return ff.NativeFunctionCall.CallWithName(t);if(t=="->->")return ne.ControlCommand.PopTunnel();if(t=="~ret")return ne.ControlCommand.PopFunction();if(t=="void")return new e0.Void}if(typeof e=="object"&&!Array.isArray(e)){let t=e,r;if(t["^->"])return r=t["^->"],new lt.DivertTargetValue(new FT.Path(r.toString()));if(t["^var"]){r=t["^var"];let c=new lt.VariablePointerValue(r.toString());return "ci"in t&&(r=t.ci,c.contextIndex=parseInt(r)),c}let i=false,a=false,s=Mr.PushPopType.Function,o=false;if((r=t["->"])?i=true:(r=t["f()"])?(i=true,a=true,s=Mr.PushPopType.Function):(r=t["->t->"])?(i=true,a=true,s=Mr.PushPopType.Tunnel):(r=t["x()"])&&(i=true,o=true,a=false,s=Mr.PushPopType.Function),i){let c=new Yv.Divert;c.pushesToStack=a,c.stackPushType=s,c.isExternal=o;let h=r.toString();return (r=t.var)?c.variableDivertName=h:c.targetPathString=h,c.isConditional=!!t.c,o&&(r=t.exArgs)&&(c.externalArgs=parseInt(r)),c}if(r=t["*"]){let c=new Zv.ChoicePoint;return c.pathStringOnChoice=r.toString(),(r=t.flg)&&(c.flags=parseInt(r)),c}if(r=t["VAR?"])return new df.VariableReference(r.toString());if(r=t["CNT?"]){let c=new df.VariableReference;return c.pathStringForCount=r.toString(),c}let u=false,l=false;if((r=t["VAR="])?(u=true,l=true):(r=t["temp="])&&(u=true,l=false),u){let c=r.toString(),h=!t.re,p=new Qv.VariableAssignment(c,h);return p.isGlobal=l,p}if(t["#"]!==void 0)return r=t["#"],new t0.Tag(r.toString());if(r=t.list){let c=r,h=new lu.InkList;if(r=t.origins){let p=r;h.SetInitialOriginNames(p);}for(let p in c)if(c.hasOwnProperty(p)){let f=c[p],g=new lu.InkListItem(p),y=parseInt(f);h.Add(g,y);}return new lt.ListValue(h)}if(t.originalChoicePath!=null)return this.JObjectToChoice(t)}if(Array.isArray(e))return this.JArrayToContainer(e);if(e==null)return null;throw new Error("Failed to convert token to runtime object: "+this.toJson(e,["parent"]))}static toJson(e,t,r){return JSON.stringify(e,(i,a)=>t?.some(s=>s===i)?void 0:a,r)}static WriteRuntimeContainer(e,t,r=false){if(e.WriteArrayStart(),t===null)return (0, Qn.throwNullException)("container");for(let u of t.content)this.WriteRuntimeObject(e,u);let i=t.namedOnlyContent,a=t.countFlags,s=t.name!=null&&!r,o=i!=null||a>0||s;if(o&&e.WriteObjectStart(),i!=null)for(let[u,l]of i){let c=u,h=(0, we.asOrNull)(l,uu.Container);e.WritePropertyStart(c),this.WriteRuntimeContainer(e,h,true),e.WritePropertyEnd();}a>0&&e.WriteIntProperty("#f",a),s&&e.WriteProperty("#n",t.name),o?e.WriteObjectEnd():e.WriteNull(),e.WriteArrayEnd();}static JArrayToContainer(e){let t=new uu.Container;t.content=this.JArrayToRuntimeObjList(e,true);let r=e[e.length-1];if(r!=null){let i=new Map;for(let a in r)if(a=="#f")t.countFlags=parseInt(r[a]);else if(a=="#n")t.name=r[a].toString();else {let s=this.JTokenToRuntimeObject(r[a]),o=(0, we.asOrNull)(s,uu.Container);o&&(o.name=a),i.set(a,s);}t.namedOnlyContent=i;}return t}static JObjectToChoice(e){let t=new n0.Choice;return t.text=e.text.toString(),t.index=parseInt(e.index),t.sourcePath=e.originalChoicePath.toString(),t.originalThreadIndex=parseInt(e.originalThreadIndex),t.pathStringOnChoice=e.targetPath.toString(),t.tags=this.JArrayToTags(e),t.isInvisibleDefault=!!e.isInvisibleDefault,t}static JArrayToTags(e){return e.tags?e.tags:null}static WriteChoice(e,t){e.WriteObjectStart(),e.WriteProperty("text",t.text),e.WriteIntProperty("index",t.index),e.WriteProperty("originalChoicePath",t.sourcePath),e.WriteIntProperty("originalThreadIndex",t.originalThreadIndex),e.WriteProperty("targetPath",t.pathStringOnChoice),e.WriteProperty("isInvisibleDefault",t.isInvisibleDefault),this.WriteChoiceTags(e,t),e.WriteObjectEnd();}static WriteChoiceTags(e,t){if(t.tags&&t.tags.length>0){e.WritePropertyStart("tags"),e.WriteArrayStart();for(let r of t.tags)e.Write(r);e.WriteArrayEnd(),e.WritePropertyEnd();}}static WriteInkList(e,t){let r=t.value;if(r===null)return (0, Qn.throwNullException)("rawList");e.WriteObjectStart(),e.WritePropertyStart("list"),e.WriteObjectStart();for(let[i,a]of r){let s=lu.InkListItem.fromSerializedKey(i),o=a;if(s.itemName===null)return (0, Qn.throwNullException)("item.itemName");e.WritePropertyNameStart(),e.WritePropertyNameInner(s.originName?s.originName:"?"),e.WritePropertyNameInner("."),e.WritePropertyNameInner(s.itemName),e.WritePropertyNameEnd(),e.Write(o),e.WritePropertyEnd();}if(e.WriteObjectEnd(),e.WritePropertyEnd(),r.Count==0&&r.originNames!=null&&r.originNames.length>0){e.WritePropertyStart("origins"),e.WriteArrayStart();for(let i of r.originNames)e.Write(i);e.WriteArrayEnd(),e.WritePropertyEnd();}e.WriteObjectEnd();}static ListDefinitionsToJToken(e){let t={};for(let r of e.lists){let i={};for(let[a,s]of r.items){let o=lu.InkListItem.fromSerializedKey(a);if(o.itemName===null)return (0, Qn.throwNullException)("item.itemName");i[o.itemName]=s;}t[r.name]=i;}return t}static JTokenToListDefinitions(e){let t=e,r=[];for(let i in t)if(t.hasOwnProperty(i)){let a=i.toString(),s=t[i],o=new Map;for(let l in s)if(t.hasOwnProperty(i)){let c=s[l];o.set(l,parseInt(c));}let u=new IT.ListDefinition(a,o);r.push(u);}return new kT.ListDefinitionsOrigin(r)}};hu.JsonSerialisation=cu;cu._controlCommandNames=(()=>{let n=[];n[ne.ControlCommand.CommandType.EvalStart]="ev",n[ne.ControlCommand.CommandType.EvalOutput]="out",n[ne.ControlCommand.CommandType.EvalEnd]="/ev",n[ne.ControlCommand.CommandType.Duplicate]="du",n[ne.ControlCommand.CommandType.PopEvaluatedValue]="pop",n[ne.ControlCommand.CommandType.PopFunction]="~ret",n[ne.ControlCommand.CommandType.PopTunnel]="->->",n[ne.ControlCommand.CommandType.BeginString]="str",n[ne.ControlCommand.CommandType.EndString]="/str",n[ne.ControlCommand.CommandType.NoOp]="nop",n[ne.ControlCommand.CommandType.ChoiceCount]="choiceCnt",n[ne.ControlCommand.CommandType.Turns]="turn",n[ne.ControlCommand.CommandType.TurnsSince]="turns",n[ne.ControlCommand.CommandType.ReadCount]="readc",n[ne.ControlCommand.CommandType.Random]="rnd",n[ne.ControlCommand.CommandType.SeedRandom]="srnd",n[ne.ControlCommand.CommandType.VisitIndex]="visit",n[ne.ControlCommand.CommandType.SequenceShuffleIndex]="seq",n[ne.ControlCommand.CommandType.StartThread]="thread",n[ne.ControlCommand.CommandType.Done]="done",n[ne.ControlCommand.CommandType.End]="end",n[ne.ControlCommand.CommandType.ListFromInt]="listInt",n[ne.ControlCommand.CommandType.ListRange]="range",n[ne.ControlCommand.CommandType.ListRandom]="lrnd",n[ne.ControlCommand.CommandType.BeginTag]="#",n[ne.ControlCommand.CommandType.EndTag]="/#";for(let e=0;e<ne.ControlCommand.CommandType.TOTAL_VALUES;++e)if(n[e]==null)throw new Error("Control command not accounted for in serialisation");return n})();});var gf=E(os=>{Object.defineProperty(os,"__esModule",{value:true});os.CallStack=void 0;var pf=Kn(),r0=it(),VT=us(),i0=Gr(),RT=ve(),$T=Jn(),ss=Xi(),jT=$i(),s0=Fr(),mf=je(),as=class n{get elements(){return this.callStack}get depth(){return this.elements.length}get currentElement(){let t=this._threads[this._threads.length-1].callstack;return t[t.length-1]}get currentElementIndex(){return this.callStack.length-1}get currentThread(){return this._threads[this._threads.length-1]}set currentThread(e){jT.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(e);}get canPop(){return this.callStack.length>1}constructor(){if(this._threadCounter=0,this._startOfRoot=ss.Pointer.Null,arguments[0]instanceof VT.Story){let e=arguments[0];this._startOfRoot=ss.Pointer.StartOf(e.rootContentContainer),this.Reset();}else {let e=arguments[0];this._threads=[];for(let t of e._threads)this._threads.push(t.Copy());this._threadCounter=e._threadCounter,this._startOfRoot=e._startOfRoot.copy();}}Reset(){this._threads=[],this._threads.push(new n.Thread),this._threads[0].callstack.push(new n.Element(pf.PushPopType.Tunnel,this._startOfRoot));}SetJsonToken(e,t){this._threads.length=0;let r=e.threads;for(let i of r){let a=i,s=new n.Thread(a,t);this._threads.push(s);}this._threadCounter=parseInt(e.threadCounter),this._startOfRoot=ss.Pointer.StartOf(t.rootContentContainer);}WriteJson(e){e.WriteObject(t=>{t.WritePropertyStart("threads"),t.WriteArrayStart();for(let r of this._threads)r.WriteJson(t);t.WriteArrayEnd(),t.WritePropertyEnd(),t.WritePropertyStart("threadCounter"),t.WriteInt(this._threadCounter),t.WritePropertyEnd();});}PushThread(){let e=this.currentThread.Copy();this._threadCounter++,e.threadIndex=this._threadCounter,this._threads.push(e);}ForkThread(){let e=this.currentThread.Copy();return this._threadCounter++,e.threadIndex=this._threadCounter,e}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==pf.PushPopType.FunctionEvaluationFromGame}Push(e,t=0,r=0){let i=new n.Element(e,this.currentElement.currentPointer,false);i.evaluationStackHeightWhenPushed=t,i.functionStartInOutputStream=r,this.callStack.push(i);}CanPop(e=null){return this.canPop?e==null?true:this.currentElement.type==e:false}Pop(e=null){if(this.CanPop(e)){this.callStack.pop();return}else throw new Error("Mismatched push/pop in Callstack")}GetTemporaryVariableWithName(e,t=-1){t==-1&&(t=this.currentElementIndex+1);let r=this.callStack[t-1],i=(0, s0.tryGetValueFromMap)(r.temporaryVariables,e,null);return i.exists?i.result:null}SetTemporaryVariable(e,t,r,i=-1){i==-1&&(i=this.currentElementIndex+1);let a=this.callStack[i-1];if(!r&&!a.temporaryVariables.get(e))throw new Error("Could not find temporary variable to set: "+e);let s=(0, s0.tryGetValueFromMap)(a.temporaryVariables,e,null);s.exists&&RT.ListValue.RetainListOriginsForAssignment(s.result,t),a.temporaryVariables.set(e,t);}ContextForVariableNamed(e){return this.currentElement.temporaryVariables.get(e)?this.currentElementIndex+1:0}ThreadWithIndex(e){let t=this._threads.filter(r=>{if(r.threadIndex==e)return r});return t.length>0?t[0]:null}get callStack(){return this.currentThread.callstack}get callStackTrace(){let e=new $T.StringBuilder;for(let t=0;t<this._threads.length;t++){let r=this._threads[t],i=t==this._threads.length-1;e.AppendFormat(`=== THREAD {0}/{1} {2}===
|
|
27
|
-
`,t+1,this._threads.length,i?"(current) ":"");for(let a=0;a<r.callstack.length;a++){r.callstack[a].type==pf.PushPopType.Function?e.Append(" [FUNCTION] "):e.Append(" [TUNNEL] ");let s=r.callstack[a].currentPointer;if(!s.isNull){if(e.Append("<SOMEWHERE IN "),s.container===null)return (0, mf.throwNullException)("pointer.container");e.Append(s.container.path.toString()),e.AppendLine(">");}}}return e.toString()}};os.CallStack=as;(function(n){class e{constructor(i,a,s=false){this.evaluationStackHeightWhenPushed=0,this.functionStartInOutputStream=0,this.currentPointer=a.copy(),this.inExpressionEvaluation=s,this.temporaryVariables=new Map,this.type=i;}Copy(){let i=new e(this.type,this.currentPointer,this.inExpressionEvaluation);return i.temporaryVariables=new Map(this.temporaryVariables),i.evaluationStackHeightWhenPushed=this.evaluationStackHeightWhenPushed,i.functionStartInOutputStream=this.functionStartInOutputStream,i}}n.Element=e;class t{constructor(){if(this.threadIndex=0,this.previousPointer=ss.Pointer.Null,this.callstack=[],arguments[0]&&arguments[1]){let i=arguments[0],a=arguments[1];this.threadIndex=parseInt(i.threadIndex);let s=i.callstack;for(let u of s){let l=u,c=parseInt(l.type),h=ss.Pointer.Null,p,f=l.cPath;if(typeof f<"u"){p=f.toString();let _=a.ContentAtPath(new r0.Path(p));if(h.container=_.container,h.index=parseInt(l.idx),_.obj==null)throw new Error("When loading state, internal story location couldn't be found: "+p+". Has the story changed since this save data was created?");_.approximate&&(h.container!==null?a.Warning("When loading state, exact internal story location couldn't be found: '"+p+"', so it was approximated to '"+h.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: '"+p+"' and it may not be recoverable. Has the story changed since this save data was created?"));}let g=!!l.exp,y=new e(c,h,g),C=l.temp;typeof C<"u"?y.temporaryVariables=i0.JsonSerialisation.JObjectToDictionaryRuntimeObjs(C):y.temporaryVariables.clear(),this.callstack.push(y);}let o=i.previousContentObject;if(typeof o<"u"){let u=new r0.Path(o.toString());this.previousPointer=a.PointerAtPath(u);}}}Copy(){let i=new t;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, mf.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"),i0.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, mf.throwNullException)("this.previousPointer.Resolve()");i.WriteProperty("previousContentObject",a.path.toString());}i.WriteObjectEnd();}}n.Thread=t;})(as||(os.CallStack=as={}));});var o0=E(fu=>{Object.defineProperty(fu,"__esModule",{value:true});fu.VariablesState=void 0;var Ie=ve(),LT=Li(),a0=Gr(),qe=ae(),ls=Fr(),En=je();function qT(){return class{}}var du=class n extends qT(){variableChangedEvent(e,t){for(let r of this.variableChangedEventCallbacks)r(e,t);}StartVariableObservation(){this._batchObservingVariableChanges=true,this._changedVariablesForBatchObs=new Set;}CompleteVariableObservation(){this._batchObservingVariableChanges=false;let e=new Map;if(this._changedVariablesForBatchObs!=null)for(let t of this._changedVariablesForBatchObs){let r=this._globalVariables.get(t);this.variableChangedEvent(t,r);}if(this.patch!=null)for(let t of this.patch.changedVariables){let r=this.patch.TryGetGlobal(t,null);r.exists&&e.set(t,r);}return this._changedVariablesForBatchObs=null,e}NotifyObservers(e){for(let[t,r]of e)this.variableChangedEvent(t,r);}get callStack(){return this._callStack}set callStack(e){this._callStack=e;}$(e,t){if(typeof t>"u"){let r=null;return this.patch!==null&&(r=this.patch.TryGetGlobal(e,null),r.exists)?r.result.valueObject:(r=this._globalVariables.get(e),typeof r>"u"&&(r=this._defaultGlobalVariables.get(e)),typeof r<"u"?r.valueObject:null)}else {if(typeof this._defaultGlobalVariables.get(e)>"u")throw new LT.StoryException("Cannot assign to a variable ("+e+") that hasn't been declared in the story");let r=Ie.Value.Create(t);if(r==null)throw t==null?new Error("Cannot pass null to VariableState"):new Error("Invalid value passed to VariableState: "+t.toString());this.SetGlobal(e,r);}}constructor(e,t){super(),this.variableChangedEventCallbacks=[],this.patch=null,this._defaultGlobalVariables=new Map,this._changedVariablesForBatchObs=new Set,this._batchObservingVariableChanges=false,this._globalVariables=new Map,this._callStack=e,this._listDefsOrigin=t;try{return new Proxy(this,{get(i,a){return a in i?i[a]:i.$(a)},set(i,a,s){return a in i?i[a]=s:i.$(a,s),!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, En.throwNullException)("this.patch");for(let[e,t]of this.patch.globals)this._globalVariables.set(e,t);if(this._changedVariablesForBatchObs!==null)for(let e of this.patch.changedVariables)this._changedVariablesForBatchObs.add(e);this.patch=null;}SetJsonToken(e){this._globalVariables.clear();for(let[t,r]of this._defaultGlobalVariables){let i=e[t];if(typeof i<"u"){let a=a0.JsonSerialisation.JTokenToRuntimeObject(i);if(a===null)return (0, En.throwNullException)("tokenInkObject");this._globalVariables.set(t,a);}else this._globalVariables.set(t,r);}}WriteJson(e){e.WriteObjectStart();for(let[t,r]of this._globalVariables){let i=t,a=r;if(n.dontSaveDefaultValues&&this._defaultGlobalVariables.has(i)){let s=this._defaultGlobalVariables.get(i);if(this.RuntimeObjectsEqual(a,s))continue}e.WritePropertyStart(i),a0.JsonSerialisation.WriteRuntimeObject(e,a),e.WritePropertyEnd();}e.WriteObjectEnd();}RuntimeObjectsEqual(e,t){if(e===null)return (0, En.throwNullException)("obj1");if(t===null)return (0, En.throwNullException)("obj2");if(e.constructor!==t.constructor)return false;let r=(0, qe.asOrNull)(e,Ie.BoolValue);if(r!==null)return r.value===(0, qe.asOrThrows)(t,Ie.BoolValue).value;let i=(0, qe.asOrNull)(e,Ie.IntValue);if(i!==null)return i.value===(0, qe.asOrThrows)(t,Ie.IntValue).value;let a=(0, qe.asOrNull)(e,Ie.FloatValue);if(a!==null)return a.value===(0, qe.asOrThrows)(t,Ie.FloatValue).value;let s=(0, qe.asOrNull)(e,Ie.Value),o=(0, qe.asOrNull)(t,Ie.Value);if(s!==null&&o!==null)return (0, qe.isEquatable)(s.valueObject)&&(0, qe.isEquatable)(o.valueObject)?s.valueObject.Equals(o.valueObject):s.valueObject===o.valueObject;throw new Error("FastRoughDefinitelyEquals: Unsupported runtime object type: "+e.constructor.name)}GetVariableWithName(e,t=-1){let r=this.GetRawVariableWithName(e,t),i=(0, qe.asOrNull)(r,Ie.VariablePointerValue);return i!==null&&(r=this.ValueAtVariablePointer(i)),r}TryGetDefaultVariableValue(e){let t=(0, ls.tryGetValueFromMap)(this._defaultGlobalVariables,e,null);return t.exists?t.result:null}GlobalVariableExistsWithName(e){return this._globalVariables.has(e)||this._defaultGlobalVariables!==null&&this._defaultGlobalVariables.has(e)}GetRawVariableWithName(e,t){let r=null;if(t==0||t==-1){let i=null;if(this.patch!==null&&(i=this.patch.TryGetGlobal(e,null),i.exists)||(i=(0, ls.tryGetValueFromMap)(this._globalVariables,e,null),i.exists)||this._defaultGlobalVariables!==null&&(i=(0, ls.tryGetValueFromMap)(this._defaultGlobalVariables,e,null),i.exists))return i.result;if(this._listDefsOrigin===null)return (0, En.throwNullException)("VariablesState._listDefsOrigin");let a=this._listDefsOrigin.FindSingleItemListWithName(e);if(a)return a}return r=this._callStack.GetTemporaryVariableWithName(e,t),r}ValueAtVariablePointer(e){return this.GetVariableWithName(e.variableName,e.contextIndex)}Assign(e,t){let r=e.variableName;if(r===null)return (0, En.throwNullException)("name");let i=-1,a=false;if(e.isNewDeclaration?a=e.isGlobal:a=this.GlobalVariableExistsWithName(r),e.isNewDeclaration){let s=(0, qe.asOrNull)(t,Ie.VariablePointerValue);s!==null&&(t=this.ResolveVariablePointer(s));}else {let s=null;do s=(0, qe.asOrNull)(this.GetRawVariableWithName(r,i),Ie.VariablePointerValue),s!=null&&(r=s.variableName,i=s.contextIndex,a=i==0);while(s!=null)}a?this.SetGlobal(r,t):this._callStack.SetTemporaryVariable(r,t,e.isNewDeclaration,i);}SnapshotDefaultGlobals(){this._defaultGlobalVariables=new Map(this._globalVariables);}RetainListOriginsForAssignment(e,t){let r=(0, qe.asOrThrows)(e,Ie.ListValue),i=(0, qe.asOrThrows)(t,Ie.ListValue);r.value&&i.value&&i.value.Count==0&&i.value.SetInitialOriginNames(r.value.originNames);}SetGlobal(e,t){let r=null;if(this.patch===null&&(r=(0, ls.tryGetValueFromMap)(this._globalVariables,e,null)),this.patch!==null&&(r=this.patch.TryGetGlobal(e,null),r.exists||(r=(0, ls.tryGetValueFromMap)(this._globalVariables,e,null))),Ie.ListValue.RetainListOriginsForAssignment(r.result,t),e===null)return (0, En.throwNullException)("variableName");if(this.patch!==null?this.patch.SetGlobal(e,t):this._globalVariables.set(e,t),this.variableChangedEvent!==null&&r!==null&&t!==r.result)if(this._batchObservingVariableChanges){if(this._changedVariablesForBatchObs===null)return (0, En.throwNullException)("this._changedVariablesForBatchObs");this.patch!==null?this.patch.AddChangedVariable(e):this._changedVariablesForBatchObs!==null&&this._changedVariablesForBatchObs.add(e);}else this.variableChangedEvent(e,t);}ResolveVariablePointer(e){let t=e.contextIndex;t==-1&&(t=this.GetContextIndexOfVariableNamed(e.variableName));let r=this.GetRawVariableWithName(e.variableName,t),i=(0, qe.asOrNull)(r,Ie.VariablePointerValue);return i??new Ie.VariablePointerValue(e.variableName,t)}GetContextIndexOfVariableNamed(e){return this.GlobalVariableExistsWithName(e)?0:this._callStack.currentElementIndex}ObserveVariableChange(e){this.variableChangedEventCallbacks.push(e);}};fu.VariablesState=du;du.dontSaveDefaultValues=true;});var vf=E(pu=>{Object.defineProperty(pu,"__esModule",{value:true});pu.PRNG=void 0;var yf=class{constructor(e){this.seed=e%2147483647,this.seed<=0&&(this.seed+=2147483646);}next(){return this.seed=this.seed*48271%2147483647}nextFloat(){return (this.next()-1)/2147483646}};pu.PRNG=yf;});var u0=E(mu=>{Object.defineProperty(mu,"__esModule",{value:true});mu.StatePatch=void 0;var Cf=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 e=arguments[0];this._globals=new Map(e._globals),this._changedVariables=new Set(e._changedVariables),this._visitCounts=new Map(e._visitCounts),this._turnIndices=new Map(e._turnIndices);}else this._globals=new Map,this._changedVariables=new Set,this._visitCounts=new Map,this._turnIndices=new Map;}TryGetGlobal(e,t){return e!==null&&this._globals.has(e)?{result:this._globals.get(e),exists:true}:{result:t,exists:false}}SetGlobal(e,t){this._globals.set(e,t);}AddChangedVariable(e){return this._changedVariables.add(e)}TryGetVisitCount(e,t){return this._visitCounts.has(e)?{result:this._visitCounts.get(e),exists:true}:{result:t,exists:false}}SetVisitCount(e,t){this._visitCounts.set(e,t);}SetTurnIndex(e,t){this._turnIndices.set(e,t);}TryGetTurnIndex(e,t){return this._turnIndices.has(e)?{result:this._turnIndices.get(e),exists:true}:{result:t,exists:false}}};mu.StatePatch=Cf;});var bf=E(hs=>{Object.defineProperty(hs,"__esModule",{value:true});hs.SimpleJson=void 0;var cs=class n{static TextToDictionary(e){return new n.Reader(e).ToDictionary()}static TextToArray(e){return new n.Reader(e).ToArray()}};hs.SimpleJson=cs;(function(n){class e{constructor(i){if(JSON.parse("0",(s,o,u)=>u!=null)){let s=(o,u,l)=>Number.isInteger(u)&&l.source.endsWith(".0")?l.source+"f":u;this._rootObject=JSON.parse(i,s);}else {let s=i.replace(/(,\s*)([0-9]+\.[0]+)([,]*)/g,'$1"$2f"$3');this._rootObject=JSON.parse(s);}}ToDictionary(){return this._rootObject}ToArray(){return this._rootObject}}n.Reader=e;class t{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===n.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===n.Writer.State.Array?(this.Assert(this.currentCollection!==null),this.currentCollection.push(i),this._collectionStack.push(i)):(this.Assert(this.state===n.Writer.State.None),this._jsonObject=i,this._collectionStack.push(i));this._stateStack.push(new n.Writer.StateElement(n.Writer.State.Object));}WriteObjectEnd(){this.Assert(this.state===n.Writer.State.Object),this._collectionStack.pop(),this._stateStack.pop();}WriteProperty(i,a){if(this.WritePropertyStart(i),arguments[1]instanceof Function){let s=arguments[1];s(this);}else {let s=arguments[1];this.Write(s);}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===n.Writer.State.Object),this._propertyNameStack.push(i),this.IncrementChildCount(),this._stateStack.push(new n.Writer.StateElement(n.Writer.State.Property));}WritePropertyEnd(){this.Assert(this.state===n.Writer.State.Property),this.Assert(this.childCount===1),this._stateStack.pop();}WritePropertyNameStart(){this.Assert(this.state===n.Writer.State.Object),this.IncrementChildCount(),this._currentPropertyName="",this._stateStack.push(new n.Writer.StateElement(n.Writer.State.Property)),this._stateStack.push(new n.Writer.StateElement(n.Writer.State.PropertyName));}WritePropertyNameEnd(){this.Assert(this.state===n.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===n.Writer.State.PropertyName),this.Assert(this._currentPropertyName!==null),this._currentPropertyName+=i;}WriteArrayStart(){this.StartNewObject(true);let i=[];if(this.state===n.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===n.Writer.State.Array?(this.Assert(this.currentCollection!==null),this.currentCollection.push(i),this._collectionStack.push(i)):(this.Assert(this.state===n.Writer.State.None),this._jsonObject=i,this._collectionStack.push(i));this._stateStack.push(new n.Writer.StateElement(n.Writer.State.Array));}WriteArrayEnd(){this.Assert(this.state===n.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 n.Writer.StateElement(n.Writer.State.String));}WriteStringEnd(){this.Assert(this.state==n.Writer.State.String),this._stateStack.pop(),this._addToCurrentObject(this._currentString),this._currentString=null;}WriteStringInner(i,a=true){if(this.Assert(this.state===n.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===n.Writer.State.None||this.state===n.Writer.State.Property||this.state===n.Writer.State.Array):this.Assert(this.state===n.Writer.State.Property||this.state===n.Writer.State.Array),this.state===n.Writer.State.Property&&this.Assert(this.childCount===0),(this.state===n.Writer.State.Array||this.state===n.Writer.State.Property)&&this.IncrementChildCount();}get state(){return this._stateStack.length>0?this._stateStack[this._stateStack.length-1].type:n.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===n.Writer.State.Array?(this.Assert(Array.isArray(this.currentCollection)),this.currentCollection.push(i)):this.state===n.Writer.State.Property&&(this.Assert(!Array.isArray(this.currentCollection)),this.Assert(this.currentPropertyName!==null),this.currentCollection[this.currentPropertyName]=i,this._propertyNameStack.pop());}}n.Writer=t,(function(r){(function(s){s[s.None=0]="None",s[s.Object=1]="Object",s[s.Array=2]="Array",s[s.Property=3]="Property",s[s.PropertyName=4]="PropertyName",s[s.String=5]="String";})(r.State||(r.State={}));class a{constructor(o){this.type=n.Writer.State.None,this.childCount=0,this.type=o;}}r.StateElement=a;})(t=n.Writer||(n.Writer={}));})(cs||(hs.SimpleJson=cs={}));});var c0=E(yu=>{Object.defineProperty(yu,"__esModule",{value:true});yu.Flow=void 0;var l0=gf(),gu=Gr(),BT=je(),_f=class{constructor(){let e=arguments[0],t=arguments[1];if(this.name=e,this.callStack=new l0.CallStack(t),arguments[2]){let r=arguments[2];this.callStack.SetJsonToken(r.callstack,t),this.outputStream=gu.JsonSerialisation.JArrayToRuntimeObjList(r.outputStream),this.currentChoices=gu.JsonSerialisation.JArrayToRuntimeObjList(r.currentChoices);let i=r.choiceThreads;typeof i<"u"&&this.LoadFlowChoiceThreads(i,t);}else this.outputStream=[],this.currentChoices=[];}WriteJson(e){e.WriteObjectStart(),e.WriteProperty("callstack",r=>this.callStack.WriteJson(r)),e.WriteProperty("outputStream",r=>gu.JsonSerialisation.WriteListRuntimeObjs(r,this.outputStream));let t=false;for(let r of this.currentChoices){if(r.threadAtGeneration===null)return (0, BT.throwNullException)("c.threadAtGeneration");r.originalThreadIndex=r.threadAtGeneration.threadIndex,this.callStack.ThreadWithIndex(r.originalThreadIndex)===null&&(t||(t=true,e.WritePropertyStart("choiceThreads"),e.WriteObjectStart()),e.WritePropertyStart(r.originalThreadIndex),r.threadAtGeneration.WriteJson(e),e.WritePropertyEnd());}t&&(e.WriteObjectEnd(),e.WritePropertyEnd()),e.WriteProperty("currentChoices",r=>{r.WriteArrayStart();for(let i of this.currentChoices)gu.JsonSerialisation.WriteChoice(r,i);r.WriteArrayEnd();}),e.WriteObjectEnd();}LoadFlowChoiceThreads(e,t){for(let r of this.currentChoices){let i=this.callStack.ThreadWithIndex(r.originalThreadIndex);if(i!==null)r.threadAtGeneration=i.Copy();else {let a=e[`${r.originalThreadIndex}`];r.threadAtGeneration=new l0.CallStack.Thread(a,t);}}}};yu.Flow=_f;});var f0=E(Cu=>{Object.defineProperty(Cu,"__esModule",{value:true});Cu.StoryState=void 0;var WT=gf(),MT=o0(),Oe=ve(),wn=Kn(),GT=su(),Sf=Ko(),h0=it(),Ue=Le(),Ef=Jn(),Dn=Gr(),zT=vf(),JT=Un(),zr=Xi(),ds=Fr(),De=ae(),HT=$i(),Et=je(),UT=us(),KT=u0(),d0=bf(),vu=c0(),XT=ot(),wf=class n{ToJson(e=false){let t=new d0.SimpleJson.Writer;return this.WriteJson(t),t.toString()}toJson(e=false){return this.ToJson(e)}LoadJson(e){let t=d0.SimpleJson.TextToDictionary(e);this.LoadJsonObj(t),this.onDidLoadState!==null&&this.onDidLoadState();}VisitCountAtPathString(e){let t;if(this._patch!==null){let r=this.story.ContentAtPath(new h0.Path(e)).container;if(r===null)throw new Error("Content at path not found: "+e);if(t=this._patch.TryGetVisitCount(r,0),t.exists)return t.result}return t=(0, ds.tryGetValueFromMap)(this._visitCounts,e,null),t.exists?t.result:0}VisitCountForContainer(e){if(e===null)return (0, Et.throwNullException)("container");if(!e.visitsShouldBeCounted)return this.story.Error("Read count for target ("+e.name+" - on "+e.debugMetadata+") unknown. The story may need to be compiled with countAllVisits flag (-c)."),0;if(this._patch!==null){let i=this._patch.TryGetVisitCount(e,0);if(i.exists)return i.result}let t=e.path.toString(),r=(0, ds.tryGetValueFromMap)(this._visitCounts,t,null);return r.exists?r.result:0}IncrementVisitCountForContainer(e){if(this._patch!==null){let i=this.VisitCountForContainer(e);i++,this._patch.SetVisitCount(e,i);return}let t=e.path.toString(),r=(0, ds.tryGetValueFromMap)(this._visitCounts,t,null);r.exists?this._visitCounts.set(t,r.result+1):this._visitCounts.set(t,1);}RecordTurnIndexVisitToContainer(e){if(this._patch!==null){this._patch.SetTurnIndex(e,this.currentTurnIndex);return}let t=e.path.toString();this._turnIndices.set(t,this.currentTurnIndex);}TurnsSinceForContainer(e){if(e.turnIndexShouldBeCounted||this.story.Error("TURNS_SINCE() for target ("+e.name+" - on "+e.debugMetadata+") unknown. The story may need to be compiled with countAllVisits flag (-c)."),this._patch!==null){let i=this._patch.TryGetTurnIndex(e,0);if(i.exists)return this.currentTurnIndex-i.result}let t=e.path.toString(),r=(0, ds.tryGetValueFromMap)(this._turnIndices,t,0);return r.exists?this.currentTurnIndex-r.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(e){this._variablesState=e;}get callStack(){return this._currentFlow.callStack}get evaluationStack(){return this._evaluationStack}get currentTurnIndex(){return this._currentTurnIndex}set currentTurnIndex(e){this._currentTurnIndex=e;}get currentPathString(){let e=this.currentPointer;return e.isNull?null:e.path===null?(0, Et.throwNullException)("pointer.path"):e.path.toString()}get previousPathString(){let e=this.previousPointer;return e.isNull?null:e.path===null?(0, Et.throwNullException)("previousPointer.path"):e.path.toString()}get currentPointer(){return this.callStack.currentElement.currentPointer.copy()}set currentPointer(e){this.callStack.currentElement.currentPointer=e.copy();}get previousPointer(){return this.callStack.currentThread.previousPointer.copy()}set previousPointer(e){this.callStack.currentThread.previousPointer=e.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 e=new Ef.StringBuilder,t=false;for(let r of this.outputStream){let i=(0, De.asOrNull)(r,Oe.StringValue);if(!t&&i!==null)e.Append(i.value);else {let a=(0, De.asOrNull)(r,Ue.ControlCommand);a!==null&&(a.commandType==Ue.ControlCommand.CommandType.BeginTag?t=true:a.commandType==Ue.ControlCommand.CommandType.EndTag&&(t=false));}}this._currentText=this.CleanOutputWhitespace(e.toString()),this._outputStreamTextDirty=false;}return this._currentText}CleanOutputWhitespace(e){let t=new Ef.StringBuilder,r=-1,i=0;for(let a=0;a<e.length;a++){let s=e.charAt(a),o=s==" "||s==" ";o&&r==-1&&(r=a),o||(s!=`
|
|
21
|
+
`.repeat(this.lineIndex-e):null};}PreProcessInputString(e){return e}};to.CommentEliminator=td;});var ro=w(no=>{Object.defineProperty(no,"__esModule",{value:true});no.Conditional=void 0;var sP=Ee(),Cv=Be(),aP=ve(),nd=class extends aP.ParsedObject{constructor(e,t){super(),this.initialCondition=e,this.branches=t,this._reJoinTarget=null,this.GenerateRuntimeObject=()=>{let r=new sP.Container;this.initialCondition&&r.AddContent(this.initialCondition.runtimeObject);for(let i of this.branches){let a=i.runtimeObject;r.AddContent(a);}return this.initialCondition!==null&&this.branches[0].ownExpression!==null&&!this.branches[this.branches.length-1].isElse&&r.AddContent(Cv.ControlCommand.PopEvaluatedValue()),this._reJoinTarget=Cv.ControlCommand.NoOp(),r.AddContent(this._reJoinTarget),r},this.initialCondition&&this.AddContent(this.initialCondition),this.branches!==null&&this.AddContent(this.branches);}get typeName(){return "Conditional"}ResolveReferences(e){let t=this._reJoinTarget.path;for(let r of this.branches){if(!r.returnDivert)throw new Error;r.returnDivert.targetPath=t;}super.ResolveReferences(e);}};no.Conditional=nd;});var En=w(io=>{Object.defineProperty(io,"__esModule",{value:true});io.Text=void 0;var oP=ve(),uP=be(),rd=class extends oP.ParsedObject{constructor(e){super(),this.text=e,this.GenerateRuntimeObject=()=>new uP.StringValue(this.text),this.toString=()=>this.text;}get typeName(){return "Text"}};io.Text=rd;});var ao=w(so=>{Object.defineProperty(so,"__esModule",{value:true});so.ConstantDeclaration=void 0;var lP=ve(),cP=sn(),id=class extends lP.ParsedObject{get constantName(){var e;return (e=this.constantIdentifier)===null||e===void 0?void 0:e.name}get expression(){if(!this._expression)throw new Error;return this._expression}constructor(e,t){super(),this._expression=null,this.GenerateRuntimeObject=()=>null,this.constantIdentifier=e,t&&(this._expression=this.AddContent(t));}get typeName(){return "CONST"}ResolveReferences(e){super.ResolveReferences(e),e.CheckForNamingCollisions(this,this.constantIdentifier,cP.SymbolType.Var);}};so.ConstantDeclaration=id;});var Lr=w(oo=>{Object.defineProperty(oo,"__esModule",{value:true});oo.FlowLevel=void 0;var Sv;(function(n){n[n.Story=0]="Story",n[n.Knot=1]="Knot",n[n.Stitch=2]="Stitch",n[n.WeavePoint=3]="WeavePoint";})(Sv||(oo.FlowLevel=Sv={}));});var es=w(uo=>{Object.defineProperty(uo,"__esModule",{value:true});uo.Gather=void 0;var hP=Ee(),dP=ve(),pP=sn(),sd=class extends dP.ParsedObject{get name(){var e;return ((e=this.identifier)===null||e===void 0?void 0:e.name)||null}get runtimeContainer(){return this.runtimeObject}constructor(e,t){super(),this.indentationDepth=t,this.GenerateRuntimeObject=()=>{let r=new hP.Container;if(r.name=this.name,this.story.countAllVisits&&(r.visitsShouldBeCounted=true),r.countingAtStartOnly=true,this.content)for(let i of this.content)r.AddContent(i.runtimeObject);return r},this.toString=()=>{var r,i;return `- ${!((r=this.identifier)===null||r===void 0)&&r.name?"("+((i=this.identifier)===null||i===void 0?void 0:i.name)+")":"gather"}`},e&&(this.identifier=e);}get typeName(){return "Gather"}ResolveReferences(e){super.ResolveReferences(e),this.identifier&&(this.identifier.name||"").length>0&&e.CheckForNamingCollisions(this,this.identifier,pP.SymbolType.SubFlowAndWeave);}};uo.Gather=sd;});var Qn=w(co=>{Object.defineProperty(co,"__esModule",{value:true});co.Path=void 0;var lo=oe(),_v=Jt(),qr=Lr(),fP=er(),ad=class{get baseTargetLevel(){return this.baseLevelIsAmbiguous?qr.FlowLevel.Story:this._baseTargetLevel}get baseLevelIsAmbiguous(){return !this._baseTargetLevel}get firstComponent(){return this.components==null||!this.components.length?null:this.components[0].name}get numberOfComponents(){return this.components?this.components.length:0}get dotSeparatedComponents(){return this._dotSeparatedComponents==null&&(this._dotSeparatedComponents=(this.components?this.components:[]).map(e=>e.name).filter(lo.filterUndef).join(".")),this._dotSeparatedComponents}constructor(e,t){this._dotSeparatedComponents=null,this.toString=()=>this.components===null||this.components.length===0?this.baseTargetLevel===qr.FlowLevel.WeavePoint?"-> <next gather point>":"<invalid Path>":`-> ${this.dotSeparatedComponents}`,this.ResolveFromContext=r=>{if(this.components==null||this.components.length==0)return null;let i=this.ResolveBaseTarget(r);return i===null?null:this.components.length>1?this.ResolveTailComponents(i):i},this.ResolveBaseTarget=r=>{let i=this.firstComponent,a=r;for(;a;){let s=a===r,o=this.GetChildFromContext(a,i,null,s);if(o)return o;a=a.parent;}return null},this.ResolveTailComponents=r=>{let i=r;if(!this.components)return null;for(let a=1;a<this.components.length;++a){let s=this.components[a].name,o,u=(0, lo.asOrNull)(i,_v.FlowBase);if(u!==null?o=u.flowLevel+1:o=qr.FlowLevel.WeavePoint,i=this.GetChildFromContext(i,s,o),i===null)break}return i},this.GetChildFromContext=(r,i,a,s=false)=>{let o=a===null,u=(0, lo.asOrNull)(r,fP.Weave);if(i&&u!==null&&(o||a===qr.FlowLevel.WeavePoint))return u.WeavePointNamed(i);let l=(0, lo.asOrNull)(r,_v.FlowBase);if(i&&l!==null){let c=s||l.flowLevel===qr.FlowLevel.Knot;return l.ContentWithNameAtLevel(i,a,c)}return null},Object.values(qr.FlowLevel).includes(e)?(this._baseTargetLevel=e,this.components=t||[]):Array.isArray(e)?(this._baseTargetLevel=null,this.components=e||[]):(this._baseTargetLevel=null,this.components=[e]);}get typeName(){return "Path"}};co.Path=ad;});var ld=w(ho=>{Object.defineProperty(ho,"__esModule",{value:true});ho.ReturnType=void 0;var mP=ve(),gP=Ee(),od=Be(),yP=Xn(),ud=class extends mP.ParsedObject{constructor(e=null){super(),this.returnedExpression=null,this.GenerateRuntimeObject=()=>{let t=new gP.Container;return this.returnedExpression?t.AddContent(this.returnedExpression.runtimeObject):(t.AddContent(od.ControlCommand.EvalStart()),t.AddContent(new yP.Void),t.AddContent(od.ControlCommand.EvalEnd())),t.AddContent(od.ControlCommand.PopFunction()),t},e&&(this.returnedExpression=this.AddContent(e));}get typeName(){return "ReturnType"}};ho.ReturnType=ud;});var ts=w(po=>{Object.defineProperty(po,"__esModule",{value:true});po.ClosestFlowBase=void 0;function vP(n){let e=n.parent;for(;e;){if(e.hasOwnProperty("iamFlowbase")&&e.iamFlowbase())return e;e=e.parent;}return null}po.ClosestFlowBase=vP;});var mo=w(fo=>{Object.defineProperty(fo,"__esModule",{value:true});fo.Identifier=void 0;var cd=class n{constructor(e){this.debugMetadata=null,this.toString=()=>this.name||"undefined identifer",this.name=e;}get typeName(){return "Identifier"}static Done(){return new n("DONE")}};fo.Identifier=cd;});var Jt=w(go=>{Object.defineProperty(go,"__esModule",{value:true});go.FlowBase=void 0;var bP=$r(),hd=Wr(),CP=Br(),Ht=Lr(),SP=es(),_P=ve(),wP=Qn(),EP=ld(),DP=Ee(),AP=zt(),OP=_n(),dd=sn(),PP=er(),xP=ts(),TP=mo(),wv=oe(),pd=class n extends _P.ParsedObject{get hasParameters(){return this.args!==null&&this.args.length>0}get subFlowsByName(){return this._subFlowsByName}get typeName(){return this.isFunction?"Function":String(this.flowLevel)}get name(){var e;return ((e=this.identifier)===null||e===void 0?void 0:e.name)||null}constructor(e,t=null,r=null,i=false,a=false){super(),this.isFunction=i,this._rootWeave=null,this._subFlowsByName=new Map,this._startingSubFlowDivert=null,this._startingSubFlowRuntime=null,this._firstChildFlow=null,this.variableDeclarations=new Map,this.identifier=null,this.args=null,this.iamFlowbase=()=>true,this.SplitWeaveAndSubFlowContent=(s,o)=>{var u,l;let c=[],h=[];this._subFlowsByName=new Map;for(let p of s){let g=(0, wv.asOrNull)(p,n);g?(this._firstChildFlow===null&&(this._firstChildFlow=g),h.push(p),!((u=g.identifier)===null||u===void 0)&&u.name&&this._subFlowsByName.set((l=g.identifier)===null||l===void 0?void 0:l.name,g)):c.push(p);}o&&c.push(new SP.Gather(null,1),new hd.Divert(new wP.Path(TP.Identifier.Done())));let f=[];return c.length>0&&(this._rootWeave=new PP.Weave(c,0),f.push(this._rootWeave)),h.length>0&&f.push(...h),f},this.ResolveVariableWithName=(s,o)=>{var u;let l={},c=o===null?this:(0, xP.ClosestFlowBase)(o);if(c){if(c.args!==null){for(let h of c.args)if(((u=h.identifier)===null||u===void 0?void 0:u.name)===s)return l.found=true,l.isArgument=true,l.ownerFlow=c,l}if(c!==this.story&&c.variableDeclarations.has(s))return l.found=true,l.ownerFlow=c,l.isTemporary=true,l}return this.story.variableDeclarations.has(s)?(l.found=true,l.ownerFlow=this.story,l.isGlobal=true,l):(l.found=false,l)},this.AddNewVariableDeclaration=s=>{let o=s.variableName;if(this.variableDeclarations.has(o)){let u=this.variableDeclarations.get(o),l="";u.debugMetadata&&(l=` (${u.debugMetadata})`),this.Error(`found declaration variable '${o}' that was already declared${l}`,s,false);return}this.variableDeclarations.set(s.variableName,s);},this.ResolveWeavePointNaming=()=>{this._rootWeave&&this._rootWeave.ResolveWeavePointNaming();for(let[,s]of this._subFlowsByName)s.hasOwnProperty("ResolveWeavePointNaming")&&s.ResolveWeavePointNaming();},this.GenerateRuntimeObject=()=>{var s;let o=null;this.isFunction?this.CheckForDisallowedFunctionFlowControl():(this.flowLevel===Ht.FlowLevel.Knot||this.flowLevel===Ht.FlowLevel.Stitch)&&(o=this.Find(EP.ReturnType)(),o!==null&&this.Error(`Return statements can only be used in knots that are declared as functions: == function ${this.identifier} ==`,o));let u=new DP.Container;u.name=(s=this.identifier)===null||s===void 0?void 0:s.name,this.story.countAllVisits&&(u.visitsShouldBeCounted=true),this.GenerateArgumentVariableAssignments(u);let l=0;for(;this.content!==null&&l<this.content.length;){let c=this.content[l];if(c instanceof n){let h=c,f=h.runtimeObject;l===0&&!h.hasParameters&&this.flowLevel===Ht.FlowLevel.Knot&&(this._startingSubFlowDivert=new AP.Divert,u.AddContent(this._startingSubFlowDivert),this._startingSubFlowRuntime=f);let p=f,g=u.namedContent.get(p.name)||null;if(g){let y=`${this.GetType()} already contains flow named '${p.name}' (at ${g.debugMetadata})`;this.Error(y,h);}u.AddToNamedContentOnly(p);}else c&&u.AddContent(c.runtimeObject);l+=1;}return this.flowLevel!==Ht.FlowLevel.Story&&!this.isFunction&&this._rootWeave!==null&&o===null&&this._rootWeave.ValidateTermination(this.WarningInTermination),u},this.GenerateArgumentVariableAssignments=s=>{var o;if(!(this.args===null||this.args.length===0))for(let u=this.args.length-1;u>=0;--u){let l=((o=this.args[u].identifier)===null||o===void 0?void 0:o.name)||null,c=new OP.VariableAssignment(l,true);s.AddContent(c);}},this.ContentWithNameAtLevel=(s,o=null,u=false)=>{var l;if((o===this.flowLevel||o===null)&&s===((l=this.identifier)===null||l===void 0?void 0:l.name))return this;if(o===Ht.FlowLevel.WeavePoint||o===null){let h=null;if(this._rootWeave&&(h=this._rootWeave.WeavePointNamed(s),h))return h;if(o===Ht.FlowLevel.WeavePoint)return u?this.DeepSearchForAnyLevelContent(s):null}if(o!==null&&o<this.flowLevel)return null;let c=this._subFlowsByName.get(s)||null;return c&&(o===null||o===c.flowLevel)?c:u?this.DeepSearchForAnyLevelContent(s):null},this.DeepSearchForAnyLevelContent=s=>{let o=this.ContentWithNameAtLevel(s,Ht.FlowLevel.WeavePoint,false);if(o)return o;for(let[,u]of this._subFlowsByName){let l=u.ContentWithNameAtLevel(s,null,true);if(l)return l}return null},this.CheckForDisallowedFunctionFlowControl=()=>{this.flowLevel!==Ht.FlowLevel.Knot&&this.Error("Functions cannot be stitches - i.e. they should be defined as '== function myFunc ==' rather than internal to another knot.");for(let[u,l]of this._subFlowsByName)this.Error(`Functions may not contain stitches, but saw '${u}' within the function '${this.identifier}'`,l);if(!this._rootWeave)throw new Error;let s=this._rootWeave.FindAll(hd.Divert)();for(let u of s)!u.isFunctionCall&&!(u.parent instanceof CP.DivertTarget)&&this.Error(`Functions may not contain diverts, but saw '${u}'`,u);let o=this._rootWeave.FindAll(bP.Choice)();for(let u of o)this.Error(`Functions may not contain choices, but saw '${u}'`,u);},this.WarningInTermination=s=>{let o="Apparent loose end exists where the flow runs out. Do you need a '-> DONE' statement, choice or divert?";s.parent===this._rootWeave&&this._firstChildFlow&&(o=`${o} Note that if you intend to enter '${this._firstChildFlow.identifier}' next, you need to divert to it explicitly.`);let u=(0, wv.asOrNull)(s,hd.Divert);u&&u.isTunnel&&(o+=` When final tunnel to '${u.target} ->' returns it won't have anywhere to go.`),this.Warning(o,s);},this.toString=()=>`${this.typeName} '${this.identifier}'`,this.identifier=e,this.args=r,t===null&&(t=[]),this.PreProcessTopLevelObjects(t),t=this.SplitWeaveAndSubFlowContent(t,this.GetType()=="Story"&&!a),this.AddContent(t);}PreProcessTopLevelObjects(e){}ResolveReferences(e){var t,r;if(this._startingSubFlowDivert){if(!this._startingSubFlowRuntime)throw new Error;this._startingSubFlowDivert.targetPath=this._startingSubFlowRuntime.path;}if(super.ResolveReferences(e),this.args!==null){for(let i of this.args)e.CheckForNamingCollisions(this,i.identifier,dd.SymbolType.Arg,"argument");for(let i=0;i<this.args.length;i+=1)for(let a=i+1;a<this.args.length;a+=1)((t=this.args[i].identifier)===null||t===void 0?void 0:t.name)==((r=this.args[a].identifier)===null||r===void 0?void 0:r.name)&&this.Error(`Multiple arguments with the same name: '${this.args[i].identifier}'`);}if(this.flowLevel!==Ht.FlowLevel.Story){let i=this.flowLevel===Ht.FlowLevel.Knot?dd.SymbolType.Knot:dd.SymbolType.SubFlowAndWeave;e.CheckForNamingCollisions(this,this.identifier,i);}}};go.FlowBase=pd;});var vo=w(yo=>{Object.defineProperty(yo,"__esModule",{value:true});yo.ContentList=void 0;var NP=Ee(),FP=ve(),IP=En(),kP=oe(),fd=class extends FP.ParsedObject{get runtimeContainer(){return this.runtimeObject}constructor(e,...t){super(),this.dontFlatten=false,this.TrimTrailingWhitespace=()=>{for(let r=this.content.length-1;r>=0;--r){let i=(0, kP.asOrNull)(this.content[r],IP.Text);if(i===null)break;if(i.text=i.text.replace(new RegExp(/[ \t]/g),""),i.text.length===0)this.content.splice(r,1);else break}},this.GenerateRuntimeObject=()=>{let r=new NP.Container;if(this.content!==null)for(let i of this.content){let a=i.runtimeObject;a&&r.AddContent(a);}return this.dontFlatten&&this.story.DontFlattenContainer(r),r},this.toString=()=>`ContentList(${this.content.join(", ")})`,e&&this.AddContent(e),t&&this.AddContent(t);}get typeName(){return "ContentList"}};yo.ContentList=fd;});var Mr=w(bo=>{Object.defineProperty(bo,"__esModule",{value:true});bo.VariableReference=void 0;var VP=ot(),RP=at(),md=class extends VP.InkObject{get containerForCount(){return this.pathForCount===null?null:this.ResolvePath(this.pathForCount).container}get pathStringForCount(){return this.pathForCount===null?null:this.CompactPathString(this.pathForCount)}set pathStringForCount(e){e===null?this.pathForCount=null:this.pathForCount=new RP.Path(e);}constructor(e=null){super(),this.pathForCount=null,this.name=e;}toString(){return this.name!=null?"var("+this.name+")":"read_count("+this.pathStringForCount+")"}};bo.VariableReference=md;});var Gr=w(Co=>{Object.defineProperty(Co,"__esModule",{value:true});Co.VariableReference=void 0;var jP=vo(),$P=St(),Ev=Jt(),LP=Qn(),qP=Mr(),BP=er(),WP=mo(),Dv=oe(),gd=class extends $P.Expression{get name(){return this.path.join(".")}get path(){return this.pathIdentifiers.map(e=>e.name).filter(Dv.filterUndef)}get identifier(){if(!this.pathIdentifiers||this.pathIdentifiers.length==0)return null;let e=this.path.join(".");return new WP.Identifier(e)}get runtimeVarRef(){return this._runtimeVarRef}constructor(e){super(),this.pathIdentifiers=e,this._runtimeVarRef=null,this.isConstantReference=false,this.isListItemReference=false,this.GenerateIntoContainer=t=>{let r=this.story.constants.get(this.name);if(r){r.GenerateConstantIntoContainer(t),this.isConstantReference=true;return}if(this._runtimeVarRef=new qP.VariableReference(this.name),this.path.length===1||this.path.length===2){let i="",a="";this.path.length===1?i=this.path[0]:(a=this.path[0],i=this.path[1]),this.story.ResolveListItem(a,i,this)&&(this.isListItemReference=true);}t.AddContent(this._runtimeVarRef);},this.toString=()=>`{${this.path.join(".")}}`;}get typeName(){return "ref"}ResolveReferences(e){if(super.ResolveReferences(e),this.isConstantReference||this.isListItemReference)return;let t=new LP.Path(this.pathIdentifiers),r=t.ResolveFromContext(this);if(r){if(!r.containerForCounting)throw new Error;if(r.containerForCounting.visitsShouldBeCounted=true,this._runtimeVarRef===null)return;this._runtimeVarRef.pathForCount=r.runtimePath,this._runtimeVarRef.name=null;let i=(0, Dv.asOrNull)(r,Ev.FlowBase);i&&i.isFunction&&(this.parent instanceof BP.Weave||this.parent instanceof jP.ContentList||this.parent instanceof Ev.FlowBase)&&this.Warning(`'${i.identifier}' being used as read count rather than being called as function. Perhaps you intended to write ${i.identifier}()`);return}if(this.path.length>1){let i=`Could not find target for read count: ${t}`;this.path.length<=2&&(i+=`, or couldn't find list item with the name ${this.path.join(",")}`),this.Error(i);return}e.ResolveVariableWithName(this.name,this).found||this.Error(`Unresolved variable: ${this.name}`,this);}};Co.VariableReference=gd;});var ns=w(Eo=>{Object.defineProperty(Eo,"__esModule",{value:true});Eo.FunctionCall=void 0;var Ut=Be(),MP=Wr(),GP=Br(),zP=St(),JP=lt(),HP=be(),_o=Gt(),Av=ja(),UP=Qn(),KP=be(),XP=Gr(),So=oe(),wo=class n extends zP.Expression{get proxyDivert(){return this._proxyDivert}get name(){return this._proxyDivert.target.firstComponent||""}get args(){return this._proxyDivert.args}get runtimeDivert(){return this._proxyDivert.runtimeDivert}get isChoiceCount(){return this.name==="CHOICE_COUNT"}get isTurns(){return this.name==="TURNS"}get isTurnsSince(){return this.name==="TURNS_SINCE"}get isRandom(){return this.name==="RANDOM"}get isSeedRandom(){return this.name==="SEED_RANDOM"}get isListRange(){return this.name==="LIST_RANGE"}get isListRandom(){return this.name==="LIST_RANDOM"}get isReadCount(){return this.name==="READ_COUNT"}constructor(e,t){super(),this._divertTargetToCount=null,this._variableReferenceToCount=null,this.shouldPopReturnedValue=false,this.GenerateIntoContainer=r=>{let i=this.story.ResolveList(this.name),a=false;if(this.isChoiceCount)this.args.length>0&&this.Error("The CHOICE_COUNT() function shouldn't take any arguments"),r.AddContent(Ut.ControlCommand.ChoiceCount());else if(this.isTurns)this.args.length>0&&this.Error("The TURNS() function shouldn't take any arguments"),r.AddContent(Ut.ControlCommand.Turns());else if(this.isTurnsSince||this.isReadCount){let s=(0, So.asOrNull)(this.args[0],GP.DivertTarget),o=(0, So.asOrNull)(this.args[0],XP.VariableReference);if(this.args.length!==1||s===null&&o===null){this.Error(`The ${this.name}() function should take one argument: a divert target to the target knot, stitch, gather or choice you want to check. e.g. TURNS_SINCE(-> myKnot)`);return}s?(this._divertTargetToCount=s,this.AddContent(this._divertTargetToCount),this._divertTargetToCount.GenerateIntoContainer(r)):o&&(this._variableReferenceToCount=o,this.AddContent(this._variableReferenceToCount),this._variableReferenceToCount.GenerateIntoContainer(r)),this.isTurnsSince?r.AddContent(Ut.ControlCommand.TurnsSince()):r.AddContent(Ut.ControlCommand.ReadCount());}else if(this.isRandom){this.args.length!==2&&this.Error("RANDOM should take 2 parameters: a minimum and a maximum integer");for(let s=0;s<this.args.length;s+=1){let o=(0, So.asOrNull)(this.args[s],Av.NumberExpression);if(o&&!o.isInt()){let u=s===0?"minimum":"maximum";this.Error(`RANDOM's ${u} parameter should be an integer`);}this.args[s].GenerateIntoContainer(r);}r.AddContent(Ut.ControlCommand.Random());}else if(this.isSeedRandom){this.args.length!==1&&this.Error("SEED_RANDOM should take 1 parameter - an integer seed");let s=(0, So.asOrNull)(this.args[0],Av.NumberExpression);s&&!s.isInt()&&this.Error("SEED_RANDOM's parameter should be an integer seed"),this.args[0].GenerateIntoContainer(r),r.AddContent(Ut.ControlCommand.SeedRandom());}else if(this.isListRange){this.args.length!==3&&this.Error("LIST_RANGE should take 3 parameters - a list, a min and a max");for(let s=0;s<this.args.length;s+=1)this.args[s].GenerateIntoContainer(r);r.AddContent(Ut.ControlCommand.ListRange());}else if(this.isListRandom)this.args.length!==1&&this.Error("LIST_RANDOM should take 1 parameter - a list"),this.args[0].GenerateIntoContainer(r),r.AddContent(Ut.ControlCommand.ListRandom());else if(_o.NativeFunctionCall.CallExistsWithName(this.name)){let s=_o.NativeFunctionCall.CallWithName(this.name);if(s.numberOfParameters!==this.args.length){let o=`${n.name} should take ${s.numberOfParameters} parameter`;s.numberOfParameters>1&&(o+="s"),this.Error(o);}for(let o=0;o<this.args.length;o+=1)this.args[o].GenerateIntoContainer(r);r.AddContent(_o.NativeFunctionCall.CallWithName(this.name));}else if(i!==null)if(this.args.length>1&&this.Error("Can currently only construct a list from one integer (or an empty list from a given list definition)"),this.args.length===1)r.AddContent(new KP.StringValue(this.name)),this.args[0].GenerateIntoContainer(r),r.AddContent(Ut.ControlCommand.ListFromInt());else {let s=new JP.InkList;s.SetInitialOriginName(this.name),r.AddContent(new HP.ListValue(s));}else r.AddContent(this._proxyDivert.runtimeObject),a=true;a||this.content.splice(this.content.indexOf(this._proxyDivert),1),this.shouldPopReturnedValue&&r.AddContent(Ut.ControlCommand.PopEvaluatedValue());},this.toString=()=>{let r=this.args.join(", ");return `${this.name}(${r})`},this._proxyDivert=new MP.Divert(new UP.Path(e),t),this._proxyDivert.isFunctionCall=true,this.AddContent(this._proxyDivert);}get typeName(){return "FunctionCall"}ResolveReferences(e){if(super.ResolveReferences(e),!this.content.includes(this._proxyDivert)&&this.args!==null)for(let t of this.args)t.ResolveReferences(e);if(this._divertTargetToCount){let t=this._divertTargetToCount.divert,r=t.runtimeDivert.variableDivertName!=null;if(r){this.Error(`When getting the TURNS_SINCE() of a variable target, remove the '->' - i.e. it should just be TURNS_SINCE(${t.runtimeDivert.variableDivertName})`);return}let i=t.targetContent;if(i===null)r||this.Error(`Failed to find target for TURNS_SINCE: '${t.target}'`);else {if(!i.containerForCounting)throw new Error;i.containerForCounting.turnIndexShouldBeCounted=true;}}else if(this._variableReferenceToCount){let t=this._variableReferenceToCount.runtimeVarRef;if(!t)throw new Error;t.pathForCount!==null&&this.Error(`Should be '${n.name}'(-> '${this._variableReferenceToCount.name}). Usage without the '->' only makes sense for variable targets.`);}}};Eo.FunctionCall=wo;wo.IsBuiltIn=n=>_o.NativeFunctionCall.CallExistsWithName(n)?true:n==="CHOICE_COUNT"||n==="TURNS_SINCE"||n==="TURNS"||n==="RANDOM"||n==="SEED_RANDOM"||n==="LIST_VALUE"||n==="LIST_RANDOM"||n==="READ_COUNT";});var vd=w(Do=>{Object.defineProperty(Do,"__esModule",{value:true});Do.MultipleConditionExpression=void 0;var YP=St(),ZP=Gt(),yd=class extends YP.Expression{get subExpressions(){return this.content}constructor(e){super(),this.GenerateIntoContainer=t=>{let r=true;for(let i of this.subExpressions)i.GenerateIntoContainer(t),r||t.AddContent(ZP.NativeFunctionCall.CallWithName("&&")),r=false;},this.AddContent(e);}get typeName(){return "MultipleConditionExpression"}};Do.MultipleConditionExpression=yd;});var Br=w(Ao=>{Object.defineProperty(Ao,"__esModule",{value:true});Ao.DivertTarget=void 0;var QP=Wh(),ex=$r(),tx=ro(),nx=_d(),rx=be(),bd=St(),ix=Jt(),Ov=ns(),sx=vd(),Pv=Gr(),Cd=oe(),Sd=class n extends bd.Expression{get runtimeDivert(){if(!this._runtimeDivert)throw new Error;return this._runtimeDivert}get runtimeDivertTargetValue(){if(!this._runtimeDivertTargetValue)throw new Error;return this._runtimeDivertTargetValue}constructor(e){super(),this._runtimeDivert=null,this._runtimeDivertTargetValue=null,this.GenerateIntoContainer=t=>{this.divert.GenerateRuntimeObject(),this._runtimeDivert=this.divert.runtimeDivert,this._runtimeDivertTargetValue=new rx.DivertTargetValue,t.AddContent(this.runtimeDivertTargetValue);},this.Equals=t=>{let r=(0, Cd.asOrNull)(t,n);if(!r||!this.divert.target||!r.divert.target)return false;let i=this.divert.target.dotSeparatedComponents,a=r.divert.target.dotSeparatedComponents;return i===a},this.divert=this.AddContent(e);}get typeName(){return "DivertTarget"}ResolveReferences(e){if(super.ResolveReferences(e),this.divert.isDone||this.divert.isEnd){this.Error("Can't use -> DONE or -> END as variable divert targets",this);return}let t=this;for(;t&&t instanceof bd.Expression;){let i=false,a=false,s=t.parent;if(s instanceof QP.BinaryExpression){let o=s;o.opName!=="=="&&o.opName!=="!="?i=true:(o.leftExpression instanceof n||o.leftExpression instanceof Pv.VariableReference)&&(o.rightExpression instanceof n||o.rightExpression instanceof Pv.VariableReference)||(i=true),a=true;}else if(s instanceof Ov.FunctionCall){let o=s;!o.isTurnsSince&&!o.isReadCount&&(i=true),a=true;}else (s instanceof bd.Expression||s instanceof sx.MultipleConditionExpression||s instanceof ex.Choice&&s.condition===t||s instanceof tx.Conditional||s instanceof nx.ConditionalSingleBranch)&&(i=true,a=true);if(i&&this.Error(`Can't use a divert target like that. Did you intend to call '${this.divert.target}' as a function: likeThis(), or check the read count: likeThis, with no arrows?`,this),a)break;t=s;}if(this.runtimeDivert.hasVariableTarget){if(!this.divert.target)throw new Error;this.Error(`Since '${this.divert.target.dotSeparatedComponents}' is a variable, it shouldn't be preceded by '->' here.`);}this.runtimeDivert.targetPath&&(this.runtimeDivertTargetValue.targetPath=this.runtimeDivert.targetPath);let r=this.divert.targetContent;if(r!==null){let i=r.containerForCounting;if(i!==null){let s=(0, Cd.asOrNull)(this.parent,Ov.FunctionCall);s&&s.isTurnsSince||(i.visitsShouldBeCounted=true),i.turnIndexShouldBeCounted=true;}let a=(0, Cd.asOrNull)(r,ix.FlowBase);if(a!=null&&a.args!==null)for(let s of a.args)s.isByReference&&this.Error(`Can't store a divert target to a knot or function that has by-reference arguments ('${a.identifier}' has 'ref ${s.identifier}').`);}}};Ao.DivertTarget=Sd;});var Wr=w(Oo=>{Object.defineProperty(Oo,"__esModule",{value:true});Oo.Divert=void 0;var ax=Ee(),rs=Be(),ox=zt(),wd=Br(),Ed=Jt(),ux=ns(),lx=ve(),xv=Qn(),cx=at(),Tv=Yn(),hx=be(),Nv=Gr(),dx=ts(),is=oe(),Dd=class extends lx.ParsedObject{get runtimeDivert(){if(!this._runtimeDivert)throw new Error;return this._runtimeDivert}set runtimeDivert(e){this._runtimeDivert=e;}get isEnd(){return !!(this.target&&this.target.dotSeparatedComponents==="END")}get isDone(){return !!(this.target&&this.target.dotSeparatedComponents==="DONE")}constructor(e,t){super(),this.args=[],this.target=null,this.targetContent=null,this._runtimeDivert=null,this.isFunctionCall=false,this.isEmpty=false,this.isTunnel=false,this.isThread=false,this.GenerateRuntimeObject=()=>{if(this.isEnd)return rs.ControlCommand.End();if(this.isDone)return rs.ControlCommand.Done();this.runtimeDivert=new ox.Divert,this.ResolveTargetContent(),this.CheckArgumentValidity();let r=this.args!==null&&this.args.length>0;if(r||this.isFunctionCall||this.isTunnel||this.isThread){let i=new ax.Container;if(r){this.isFunctionCall||i.AddContent(rs.ControlCommand.EvalStart());let a=null;this.targetContent&&(a=this.targetContent.args);for(let s=0;s<this.args.length;++s){let o=this.args[s],u=null;if(a&&s<a.length&&(u=a[s]),u&&u.isByReference){let l=(0, is.asOrNull)(o,Nv.VariableReference);if(!l){this.Error(`Expected variable name to pass by reference to 'ref ${u.identifier}' but saw ${o}`);break}let c=new xv.Path(l.pathIdentifiers);if(c.ResolveFromContext(this)){this.Error(`can't pass a read count by reference. '${c.dotSeparatedComponents}' is a knot/stitch/label, but '${this.target.dotSeparatedComponents}' requires the name of a VAR to be passed.`);break}let f=new hx.VariablePointerValue(l.name);i.AddContent(f);}else o.GenerateIntoContainer(i);}this.isFunctionCall||i.AddContent(rs.ControlCommand.EvalEnd());}return this.isThread?i.AddContent(rs.ControlCommand.StartThread()):(this.isFunctionCall||this.isTunnel)&&(this.runtimeDivert.pushesToStack=true,this.runtimeDivert.stackPushType=this.isFunctionCall?Tv.PushPopType.Function:Tv.PushPopType.Tunnel),i.AddContent(this.runtimeDivert),i}return this.runtimeDivert},this.PathAsVariableName=()=>this.target?this.target.firstComponent:null,this.ResolveTargetContent=()=>{if(!(this.isEmpty||this.isEnd)&&this.targetContent===null){let r=this.PathAsVariableName();if(r!==null){let i=(0, is.asOrNull)((0, dx.ClosestFlowBase)(this),Ed.FlowBase);if(i){let a=i.ResolveVariableWithName(r,this);if(a.found){if(a.isArgument&&a.ownerFlow&&a.ownerFlow.args){let s=a.ownerFlow.args.find(o=>{var u;return ((u=o.identifier)===null||u===void 0?void 0:u.name)==r});s&&!s.isDivertTarget&&this.Error(`Since '${s.identifier}' is used as a variable divert target (on ${this.debugMetadata}), it should be marked as: -> ${s.identifier}`,a.ownerFlow);}this.runtimeDivert.variableDivertName=r;return}}}if(!this.target)throw new Error;this.targetContent=this.target.ResolveFromContext(this);}},this.CheckArgumentValidity=()=>{if(this.isEmpty)return;let r=0;if(this.args!==null&&this.args.length>0&&(r=this.args.length),this.targetContent===null)return;let i=(0, is.asOrNull)(this.targetContent,Ed.FlowBase);if(r===0&&(i===null||!i.hasParameters))return;if(i===null&&r>0){this.Error("target needs to be a knot or stitch in order to pass arguments");return}else if(i!==null&&(i.args===null||!i.args&&r>0)){this.Error(`target (${i.name}) doesn't take parameters`);return}else if(this.parent instanceof wd.DivertTarget){r>0&&this.Error("can't store arguments in a divert target variable");return}let a=i.args.length;if(a!==r){let s;r===0?s="but there weren't any passed to it":r<a?s=`but only got ${r}`:s=`but got ${r}`,this.Error(`to '${i.identifier}' requires ${a} arguments, ${s}`);return}for(let s=0;s<a;++s){let o=i.args[s],u=this.args[s];if(o.isDivertTarget){let l=(0, is.asOrNull)(u,Nv.VariableReference);if(!(u instanceof wd.DivertTarget)&&l===null)this.Error(`Target '${i.identifier}' expects a divert target for the parameter named -> ${o.identifier} but saw ${u}`,u);else if(l){let c=new xv.Path(l.pathIdentifiers);c.ResolveFromContext(l)&&this.Error(`Passing read count of '${c.dotSeparatedComponents}' instead of a divert target. You probably meant '${c}'`);}}}if(i===null){this.Error("Can't call as a function or with arguments unless it's a knot or stitch");return}},this.CheckExternalArgumentValidity=r=>{let i=this.target?this.target.firstComponent:null,a=r.externals.get(i);if(!a)throw new Error("external not found");let s=a.argumentNames.length,o=0;this.args&&(o=this.args.length),o!==s&&this.Error(`incorrect number of arguments sent to external function '${i}'. Expected ${s} but got ${o}`);},this.toString=()=>{let r="";if(this.target!==null)r+=this.target.toString();else return "-> <empty divert>";return this.isTunnel&&(r+=" ->"),this.isFunctionCall&&(r+=" ()"),r},e&&(this.target=e),t&&(this.args=t,this.AddContent(t));}get typeName(){return "Divert"}ResolveReferences(e){if(this.isEmpty||this.isEnd||this.isDone)return;if(!this.runtimeDivert)throw new Error;this.targetContent&&(this.runtimeDivert.targetPath=this.targetContent.runtimePath),super.ResolveReferences(e);let t=(0, is.asOrNull)(this.targetContent,Ed.FlowBase);t&&(!t.isFunction&&this.isFunctionCall?super.Error(`${t.identifier} hasn't been marked as a function, but it's being called as one. Do you need to declare the knot as '== function ${t.identifier} =='?`):t.isFunction&&!this.isFunctionCall&&!(this.parent instanceof wd.DivertTarget)&&super.Error(t.identifier+" can't be diverted to. It can only be called as a function since it's been marked as such: '"+t.identifier+"(...)'"));let r=this.targetContent!==null,i=false,a=false;if(this.target){if(this.target.numberOfComponents===1){if(!this.target.firstComponent)throw new Error;if(i=ux.FunctionCall.IsBuiltIn(this.target.firstComponent),a=e.IsExternal(this.target.firstComponent),i||a){this.isFunctionCall||super.Error(`${this.target.firstComponent} must be called as a function: ~ ${this.target.firstComponent}()`),a&&(this.runtimeDivert.isExternal=true,this.args!==null&&(this.runtimeDivert.externalArgs=this.args.length),this.runtimeDivert.pushesToStack=false,this.runtimeDivert.targetPath=new cx.Path(this.target.firstComponent),this.CheckExternalArgumentValidity(e));return}}}else throw new Error;this.runtimeDivert.variableDivertName==null&&!r&&!i&&!a&&this.Error(`target not found: '${this.target}'`);}Error(e,t=null,r=false){if(t!==this&&t){super.Error(e,t);return}this.isFunctionCall?super.Error(`Function call ${e}`,t,r):super.Error(`Divert ${e}`,t,r);}};Oo.Divert=Dd;});var Fv=w(Po=>{Object.defineProperty(Po,"__esModule",{value:true});Po.GatherPointToResolve=void 0;var Ad=class{constructor(e,t){this.divert=e,this.targetRuntimeObj=t;}};Po.GatherPointToResolve=Ad;});var Iv=w(xo=>{Object.defineProperty(xo,"__esModule",{value:true});xo.SequenceDivertToResolve=void 0;var Od=class{constructor(e,t){this.divert=e,this.targetContent=t;}};xo.SequenceDivertToResolve=Od;});var Pd=w(To=>{Object.defineProperty(To,"__esModule",{value:true});To.SequenceType=void 0;var kv;(function(n){n[n.Stopping=1]="Stopping",n[n.Cycle=2]="Cycle",n[n.Shuffle=4]="Shuffle",n[n.Once=8]="Once";})(kv||(To.SequenceType=kv={}));});var Nd=w(Io=>{Object.defineProperty(Io,"__esModule",{value:true});Io.Sequence=void 0;var Vv=Ee(),It=Be(),xd=zt(),ss=be(),No=Gt(),px=ve(),fx=Iv(),Fo=Pd(),mx=er(),Td=class extends px.ParsedObject{constructor(e,t){super(),this.sequenceType=t,this._sequenceDivertsToResolve=[],this.GenerateRuntimeObject=()=>{let r=new Vv.Container;r.visitsShouldBeCounted=true,r.countingAtStartOnly=true,this._sequenceDivertsToResolve=[],r.AddContent(It.ControlCommand.EvalStart()),r.AddContent(It.ControlCommand.VisitIndex());let i=(this.sequenceType&Fo.SequenceType.Once)>0,a=(this.sequenceType&Fo.SequenceType.Cycle)>0,s=(this.sequenceType&Fo.SequenceType.Stopping)>0,o=(this.sequenceType&Fo.SequenceType.Shuffle)>0,u=this.sequenceElements.length;if(i&&(u+=1),s||i?(r.AddContent(new ss.IntValue(u-1)),r.AddContent(No.NativeFunctionCall.CallWithName("MIN"))):a&&(r.AddContent(new ss.IntValue(this.sequenceElements.length)),r.AddContent(No.NativeFunctionCall.CallWithName("%"))),o){let c=It.ControlCommand.NoOp();if(i||s){let f=s?this.sequenceElements.length-1:this.sequenceElements.length;r.AddContent(It.ControlCommand.Duplicate()),r.AddContent(new ss.IntValue(f)),r.AddContent(No.NativeFunctionCall.CallWithName("=="));let p=new xd.Divert;p.isConditional=true,r.AddContent(p),this.AddDivertToResolve(p,c);}let h=this.sequenceElements.length;s&&(h-=1),r.AddContent(new ss.IntValue(h)),r.AddContent(It.ControlCommand.SequenceShuffleIndex()),(i||s)&&r.AddContent(c);}r.AddContent(It.ControlCommand.EvalEnd());let l=It.ControlCommand.NoOp();for(let c=0;c<u;c+=1){r.AddContent(It.ControlCommand.EvalStart()),r.AddContent(It.ControlCommand.Duplicate()),r.AddContent(new ss.IntValue(c)),r.AddContent(No.NativeFunctionCall.CallWithName("==")),r.AddContent(It.ControlCommand.EvalEnd());let h=new xd.Divert;h.isConditional=true,r.AddContent(h);let f;c<this.sequenceElements.length?f=this.sequenceElements[c].runtimeObject:f=new Vv.Container,f.name=`s${c}`,f.InsertContent(It.ControlCommand.PopEvaluatedValue(),0);let p=new xd.Divert;f.AddContent(p),r.AddToNamedContentOnly(f),this.AddDivertToResolve(h,f),this.AddDivertToResolve(p,l);}return r.AddContent(l),r},this.AddDivertToResolve=(r,i)=>{this._sequenceDivertsToResolve.push(new fx.SequenceDivertToResolve(r,i));},this.sequenceType=t,this.sequenceElements=[];for(let r of e){let i=r.content,a=null;i===null||i.length===0?a=r:a=new mx.Weave(i),this.sequenceElements.push(a),this.AddContent(a);}}get typeName(){return "Sequence"}ResolveReferences(e){super.ResolveReferences(e);for(let t of this._sequenceDivertsToResolve)t.divert.targetPath=t.targetContent.path;}};Io.Sequence=Td;});var Id=w(ko=>{Object.defineProperty(ko,"__esModule",{value:true});ko.TunnelOnwards=void 0;var gx=Ee(),as=Be(),yx=zt(),vx=be(),bx=ve(),Cx=Xn(),Sx=oe(),_x=Mr(),Fd=class extends bx.ParsedObject{constructor(){super(...arguments),this._overrideDivertTarget=null,this._divertAfter=null,this.GenerateRuntimeObject=()=>{let e=new gx.Container;if(e.AddContent(as.ControlCommand.EvalStart()),this.divertAfter){let t=this.divertAfter.GenerateRuntimeObject(),r=t;if(r){let a=this.divertAfter.args;if(a!==null&&a.length>0){let s=-1,o=-1;for(let u=0;u<r.content.length;u+=1){let l=r.content[u];l&&(s==-1&&l.commandType===as.ControlCommand.CommandType.EvalStart?s=u:l.commandType===as.ControlCommand.CommandType.EvalEnd&&(o=u));}for(let u=s+1;u<o;u+=1){let l=r.content[u];l.parent=null,e.AddContent(r.content[u]);}}}let i=(0, Sx.asOrNull)(t,yx.Divert);if(i!=null&&i.hasVariableTarget){let a=new _x.VariableReference(i.variableDivertName);e.AddContent(a);}else this._overrideDivertTarget=new vx.DivertTargetValue,e.AddContent(this._overrideDivertTarget);}else e.AddContent(new Cx.Void);return e.AddContent(as.ControlCommand.EvalEnd()),e.AddContent(as.ControlCommand.PopTunnel()),e},this.toString=()=>` -> ${this._divertAfter}`;}get divertAfter(){return this._divertAfter}set divertAfter(e){this._divertAfter=e,this._divertAfter&&this.AddContent(this._divertAfter);}get typeName(){return "TunnelOnwards"}ResolveReferences(e){super.ResolveReferences(e),this.divertAfter&&this.divertAfter.targetContent&&(this._overrideDivertTarget.targetPath=this.divertAfter.targetContent.runtimePath);}};ko.TunnelOnwards=Fd;});var Rd=w(Vo=>{Object.defineProperty(Vo,"__esModule",{value:true});Vo.ListDefinition=void 0;var kd=lt(),Vd=class{constructor(e,t){this._name=e||"",this._items=null,this._itemNameToValues=t||new Map;}get name(){return this._name}get items(){if(this._items==null){this._items=new Map;for(let[e,t]of this._itemNameToValues){let r=new kd.InkListItem(this.name,e);this._items.set(r.serialized(),t);}}return this._items}ValueForItem(e){if(!e.itemName)return 0;let t=this._itemNameToValues.get(e.itemName);return typeof t<"u"?t:0}ContainsItem(e){return !e.itemName||e.originName!=this.name?false:this._itemNameToValues.has(e.itemName)}ContainsItemWithName(e){return this._itemNameToValues.has(e)}TryGetItemWithValue(e,t){for(let[r,i]of this._itemNameToValues)if(i==e)return t=new kd.InkListItem(this.name,r),{result:t,exists:true};return t=kd.InkListItem.Null,{result:t,exists:false}}TryGetValueForItem(e,t){if(!e.itemName)return {result:0,exists:false};let r=this._itemNameToValues.get(e.itemName);return r?{result:r,exists:true}:{result:0,exists:false}}};Vo.ListDefinition=Vd;});var jo=w(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});Ro.ListDefinition=void 0;var wx=lt(),Ex=lt(),Dx=Rd(),Ax=be(),Ox=ve(),Px=sn(),jd=class extends Ox.ParsedObject{get typeName(){return "ListDefinition"}get runtimeListDefinition(){var e;let t=new Map;for(let r of this.itemDefinitions)t.has(r.name)?this.Error(`List '${this.identifier}' contains duplicate items called '${r.name}'`):t.set(r.name,r.seriesValue);return new Dx.ListDefinition(((e=this.identifier)===null||e===void 0?void 0:e.name)||"",t)}constructor(e){super(),this.itemDefinitions=e,this.identifier=null,this.variableAssignment=null,this._elementsByName=null,this.ItemNamed=r=>{if(this._elementsByName===null){this._elementsByName=new Map;for(let a of this.itemDefinitions)this._elementsByName.set(a.name,a);}return this._elementsByName.get(r)||null},this.GenerateRuntimeObject=()=>{var r,i;let a=new wx.InkList;for(let s of this.itemDefinitions)if(s.inInitialList){let o=new Ex.InkListItem(((r=this.identifier)===null||r===void 0?void 0:r.name)||null,s.name||null);a.Add(o,s.seriesValue);}return a.SetInitialOriginName(((i=this.identifier)===null||i===void 0?void 0:i.name)||""),new Ax.ListValue(a)};let t=1;for(let r of this.itemDefinitions)r.explicitValue!==null&&(t=r.explicitValue),r.seriesValue=t,t+=1;this.AddContent(e);}ResolveReferences(e){super.ResolveReferences(e),e.CheckForNamingCollisions(this,this.identifier,Px.SymbolType.List);}};Ro.ListDefinition=jd;});var Ld=w($o=>{Object.defineProperty($o,"__esModule",{value:true});$o.VariableAssignment=void 0;var xx=Ee(),Tx=ts(),Nx=jo(),Fx=ve(),Rv=sn(),Ix=_n(),kx=Gr(),Vx=oe(),$d=class extends Fx.ParsedObject{get variableName(){return this.variableIdentifier.name}get typeName(){return this.isNewTemporaryDeclaration?"temp":this.isGlobalDeclaration?this.listDefinition!==null?"LIST":"VAR":"variable assignment"}get isDeclaration(){return this.isGlobalDeclaration||this.isNewTemporaryDeclaration}constructor({assignedExpression:e,isGlobalDeclaration:t,isTemporaryNewDeclaration:r,listDef:i,variableIdentifier:a}){super(),this._runtimeAssignment=null,this.expression=null,this.listDefinition=null,this.GenerateRuntimeObject=()=>{let s=null;if(this.isGlobalDeclaration?s=this.story:this.isNewTemporaryDeclaration&&(s=(0, Tx.ClosestFlowBase)(this)),s&&s.AddNewVariableDeclaration(this),this.isGlobalDeclaration)return null;let o=new xx.Container;return this.expression?o.AddContent(this.expression.runtimeObject):this.listDefinition&&o.AddContent(this.listDefinition.runtimeObject),this._runtimeAssignment=new Ix.VariableAssignment(this.variableName,this.isNewTemporaryDeclaration),o.AddContent(this._runtimeAssignment),o},this.toString=()=>`${this.isGlobalDeclaration?"VAR":this.isNewTemporaryDeclaration?"~ temp":""} ${this.variableName}`,this.variableIdentifier=a,this.isGlobalDeclaration=!!t,this.isNewTemporaryDeclaration=!!r,i instanceof Nx.ListDefinition?(this.listDefinition=this.AddContent(i),this.listDefinition.variableAssignment=this,this.isGlobalDeclaration=true):e&&(this.expression=this.AddContent(e));}ResolveReferences(e){if(super.ResolveReferences(e),this.isDeclaration&&this.listDefinition===null&&e.CheckForNamingCollisions(this,this.variableIdentifier,this.isGlobalDeclaration?Rv.SymbolType.Var:Rv.SymbolType.Temp),this.isGlobalDeclaration){let t=(0, Vx.asOrNull)(this.expression,kx.VariableReference);t&&!t.isConstantReference&&!t.isListItemReference&&this.Error("global variable assignments cannot refer to other variables, only literal values, constants and list items");}if(!this.isNewTemporaryDeclaration){let t=e.ResolveVariableWithName(this.variableName,this);t.found||(this.variableName in this.story.constants?this.Error(`Can't re-assign to a constant (do you need to use VAR when declaring '${this.variableName}'?)`,this):this.Error(`Variable could not be found to assign to: '${this.variableName}'`,this)),this._runtimeAssignment&&(this._runtimeAssignment.isGlobal=t.isGlobal);}}};$o.VariableAssignment=$d;});var er=w(Bo=>{Object.defineProperty(Bo,"__esModule",{value:true});Bo.Weave=void 0;var jv=Sa(),wt=$r(),Lo=ro(),Rx=ao(),jx=Ee(),qo=Wr(),$x=zt(),Lx=Br(),qx=Jt(),Kt=es(),Bx=Fv(),Wx=ve(),qd=Nd(),Mx=En(),Gx=Id(),zx=Ld(),Et=oe(),Bd=class n extends Wx.ParsedObject{get rootContainer(){return this._rootContainer||(this._rootContainer=this.GenerateRuntimeObject()),this._rootContainer}get namedWeavePoints(){return this._namedWeavePoints}get lastParsedSignificantObject(){if(this.content.length===0)return null;let e=null;for(let r=this.content.length-1;r>=0;--r){e=this.content[r];let i=(0, Et.asOrNull)(e,Mx.Text);if(!(i&&i.text===`
|
|
22
|
+
`)&&!this.IsGlobalDeclaration(e))break}let t=(0, Et.asOrNull)(e,n);return t&&(e=t.lastParsedSignificantObject),e}constructor(e,t=-1){super(),this.previousWeavePoint=null,this.addContentToPreviousWeavePoint=false,this.hasSeenChoiceInSection=false,this.currentContainer=null,this._unnamedGatherCount=0,this._choiceCount=0,this._rootContainer=null,this._namedWeavePoints=new Map,this.looseEnds=[],this.gatherPointsToResolve=[],this.ResolveWeavePointNaming=()=>{var r,i,a;let s=[...this.FindAll(Kt.Gather)(o=>!(o.name===null||o.name===void 0)),...this.FindAll(wt.Choice)(o=>!(o.name===null||o.name===void 0))];this._namedWeavePoints=new Map;for(let o of s){let u=this.namedWeavePoints.get(((r=o.identifier)===null||r===void 0?void 0:r.name)||"");if(u){let l=u instanceof Kt.Gather?"gather":"choice",c=u;this.Error(`A ${l} with the same label name '${o.name}' already exists in this context on line ${c.debugMetadata?c.debugMetadata.startLineNumber:"NO DEBUG METADATA AVAILABLE"}`,o);}!((i=o.identifier)===null||i===void 0)&&i.name&&this.namedWeavePoints.set((a=o.identifier)===null||a===void 0?void 0:a.name,o);}},this.ConstructWeaveHierarchyFromIndentation=()=>{let r=0;for(;r<this.content.length;){let i=this.content[r];if(i instanceof wt.Choice||i instanceof Kt.Gather){let s=i.indentationDepth-1;if(s>this.baseIndentIndex){let o=r;for(;r<this.content.length;){let h=(0, Et.asOrNull)(this.content[r],wt.Choice)||(0, Et.asOrNull)(this.content[r],Kt.Gather);if(h!==null&&h.indentationDepth-1<=this.baseIndentIndex)break;r+=1;}let u=r-o,l=this.content.slice(o,o+u);this.content.splice(o,u);let c=new n(l,s);this.InsertContent(o,c),r=o;}}r+=1;}},this.DetermineBaseIndentationFromContent=r=>{for(let i of r)if(i instanceof wt.Choice||i instanceof Kt.Gather)return i.indentationDepth-1;return 0},this.GenerateRuntimeObject=()=>{this._rootContainer=new jx.Container,this.currentContainer=this._rootContainer,this.looseEnds=[],this.gatherPointsToResolve=[];for(let r of this.content)if(r instanceof wt.Choice||r instanceof Kt.Gather)this.AddRuntimeForWeavePoint(r);else if(r instanceof n){let i=r;this.AddRuntimeForNestedWeave(i),this.gatherPointsToResolve.splice(0,0,...i.gatherPointsToResolve);}else this.AddGeneralRuntimeContent(r.runtimeObject);return this.PassLooseEndsToAncestors(),this._rootContainer},this.AddRuntimeForGather=r=>{let i=!this.hasSeenChoiceInSection;this.hasSeenChoiceInSection=false;let a=r.runtimeContainer;if(r.name||(a.name=`g-${this._unnamedGatherCount}`,this._unnamedGatherCount+=1),i){if(!this.currentContainer)throw new Error;this.currentContainer.AddContent(a);}else this.rootContainer.AddToNamedContentOnly(a);for(let s of this.looseEnds){let o=s;if(o instanceof Kt.Gather&&o.indentationDepth==r.indentationDepth)continue;let u=null;if(o instanceof qo.Divert)u=o.runtimeObject;else {u=new $x.Divert;let l=o;if(!l.runtimeContainer)throw new Error;l.runtimeContainer.AddContent(u);}this.gatherPointsToResolve.push(new Bx.GatherPointToResolve(u,a));}this.looseEnds=[],this.currentContainer=a;},this.AddRuntimeForWeavePoint=r=>{if(r instanceof Kt.Gather)this.AddRuntimeForGather(r);else if(r instanceof wt.Choice){if(!this.currentContainer)throw new Error;this.previousWeavePoint instanceof Kt.Gather&&this.looseEnds.splice(this.looseEnds.indexOf(this.previousWeavePoint),1);let i=r;if(this.currentContainer.AddContent(i.runtimeObject),!i.innerContentContainer)throw new Error;i.innerContentContainer.name=`c-${this._choiceCount}`,this.currentContainer.AddToNamedContentOnly(i.innerContentContainer),this._choiceCount+=1,this.hasSeenChoiceInSection=true;}this.addContentToPreviousWeavePoint=false,this.WeavePointHasLooseEnd(r)&&(this.looseEnds.push(r),(0, Et.asOrNull)(r,wt.Choice)&&(this.addContentToPreviousWeavePoint=true)),this.previousWeavePoint=r;},this.AddRuntimeForNestedWeave=r=>{this.AddGeneralRuntimeContent(r.rootContainer),this.previousWeavePoint!==null&&(this.looseEnds.splice(this.looseEnds.indexOf(this.previousWeavePoint),1),this.addContentToPreviousWeavePoint=false);},this.AddGeneralRuntimeContent=r=>{if(r!==null)if(this.addContentToPreviousWeavePoint){if(!this.previousWeavePoint||!this.previousWeavePoint.runtimeContainer)throw new Error;this.previousWeavePoint.runtimeContainer.AddContent(r);}else {if(!this.currentContainer)throw new Error;this.currentContainer.AddContent(r);}},this.PassLooseEndsToAncestors=()=>{if(this.looseEnds.length===0)return;let r=null,i=null,a=false;for(let s=this.parent;s!==null;s=s.parent){let o=(0, Et.asOrNull)(s,n);o&&(!a&&r===null&&(r=o),a&&i===null&&(i=o)),(s instanceof qd.Sequence||s instanceof Lo.Conditional)&&(a=true);}if(!(r===null&&i===null))for(let s=this.looseEnds.length-1;s>=0;s-=1){let o=this.looseEnds[s],u=false;if(a){if(o instanceof wt.Choice&&r!==null)r.ReceiveLooseEnd(o),u=true;else if(!(o instanceof wt.Choice)){let l=r||i;l!==null&&(l.ReceiveLooseEnd(o),u=true);}}else r?.hasOwnProperty("ReceiveLooseEnd")&&r.ReceiveLooseEnd(o),u=true;u&&this.looseEnds.splice(s,1);}},this.ReceiveLooseEnd=r=>{this.looseEnds.push(r);},this.WeavePointNamed=r=>{if(!this.namedWeavePoints)return null;let i=this.namedWeavePoints.get(r);return i||null},this.IsGlobalDeclaration=r=>{let i=(0, Et.asOrNull)(r,zx.VariableAssignment);return !!(i&&i.isGlobalDeclaration&&i.isDeclaration||(0, Et.asOrNull)(r,Rx.ConstantDeclaration))},this.ContentThatFollowsWeavePoint=r=>{let i=[],a=r;if(a.content!==null)for(let u of a.content)this.IsGlobalDeclaration(u)||i.push(u);let s=(0, Et.asOrNull)(a.parent,n);if(s===null)throw new Error("Expected weave point parent to be weave?");let o=s.content.indexOf(a);for(let u=o+1;u<s.content.length;u+=1){let l=s.content[u];if(!this.IsGlobalDeclaration(l)){if(l instanceof wt.Choice||l instanceof Kt.Gather||l instanceof n)break;i.push(l);}}return i},this.ValidateTermination=r=>{if(this.lastParsedSignificantObject instanceof jv.AuthorWarning)return;if(this.looseEnds!==null&&this.looseEnds.length>0)for(let a of this.looseEnds){let s=this.ContentThatFollowsWeavePoint(a);this.ValidateFlowOfObjectsTerminates(s,a,r);}else {for(let a of this.content)if(a instanceof wt.Choice||a instanceof qo.Divert)return;this.ValidateFlowOfObjectsTerminates(this.content,this,r);}},this.BadNestedTerminationHandler=r=>{let i=null;for(let s=r.parent;s!==null;s=s.parent)if(s instanceof qd.Sequence||s instanceof Lo.Conditional){i=(0, Et.asOrNull)(s,Lo.Conditional);break}let a="Choices nested in conditionals or sequences need to explicitly divert afterwards.";i!==null&&i.FindAll(wt.Choice)().length===1&&(a=`Choices with conditions should be written: '* {condition} choice'. Otherwise, ${a.toLowerCase()}`),this.Error(a,r);},this.ValidateFlowOfObjectsTerminates=(r,i,a)=>{let s=false,o=i;for(let u of r){if(u.Find(qo.Divert)(c=>!c.isThread&&!c.isTunnel&&!c.isFunctionCall&&!(c.parent instanceof Lx.DivertTarget))!==null&&(s=true),u.Find(Gx.TunnelOnwards)()!=null){s=true;break}o=u;}if(!s){if(o instanceof jv.AuthorWarning)return;a(o);}},this.WeavePointHasLooseEnd=r=>{if(r.content===null)return true;for(let i=r.content.length-1;i>=0;--i){let a=(0, Et.asOrNull)(r.content[i],qo.Divert);if(a&&!(a.isThread||a.isTunnel||a.isFunctionCall))return false}return true},this.CheckForWeavePointNamingCollisions=()=>{if(!this.namedWeavePoints)return;let r=[];for(let i of this.ancestry){let a=(0, Et.asOrNull)(i,qx.FlowBase);if(a)r.push(a);else break}for(let[i,a]of this.namedWeavePoints)for(let s of r){let o=s.ContentWithNameAtLevel(i);if(o&&o!==a){let u=`${a.GetType()} '${i}' has the same label name as a ${o.GetType()} (on ${o.debugMetadata})`;this.Error(u,a);}}},t==-1?this.baseIndentIndex=this.DetermineBaseIndentationFromContent(e):this.baseIndentIndex=t,this.AddContent(e),this.ConstructWeaveHierarchyFromIndentation();}get typeName(){return "Weave"}ResolveReferences(e){if(super.ResolveReferences(e),this.looseEnds!==null&&this.looseEnds.length>0){let t=false;for(let r=this.parent;r!==null;r=r.parent)if(r instanceof qd.Sequence||r instanceof Lo.Conditional){t=true;break}t&&this.ValidateTermination(this.BadNestedTerminationHandler);}for(let t of this.gatherPointsToResolve)t.divert.targetPath=t.targetRuntimeObj.path;this.CheckForWeavePointNamingCollisions();}};Bo.Weave=Bd;});var _d=w(Mo=>{Object.defineProperty(Mo,"__esModule",{value:true});Mo.ConditionalSingleBranch=void 0;var $v=Ee(),Wo=Be(),Lv=zt(),Jx=ve(),Hx=Gt(),Ux=be(),Kx=En(),Xx=er(),Yx=oe(),Wd=class extends Jx.ParsedObject{get ownExpression(){return this._ownExpression}set ownExpression(e){this._ownExpression=e,this._ownExpression&&this.AddContent(this._ownExpression);}constructor(e){super(),this._contentContainer=null,this._conditionalDivert=null,this._ownExpression=null,this._innerWeave=null,this.isTrueBranch=false,this.matchingEquality=false,this.isElse=false,this.isInline=false,this.returnDivert=null,this.GenerateRuntimeObject=()=>{if(this._innerWeave)for(let i of this._innerWeave.content){let a=(0, Yx.asOrNull)(i,Kx.Text);a&&a.text.startsWith("else:")&&this.Warning("Saw the text 'else:' which is being treated as content. Did you mean '- else:'?",a);}let t=new $v.Container,r=this.matchingEquality&&!this.isElse;if(r&&t.AddContent(Wo.ControlCommand.Duplicate()),this._conditionalDivert=new Lv.Divert,this._conditionalDivert.isConditional=!this.isElse,!this.isTrueBranch&&!this.isElse){let i=this.ownExpression!==null;i&&t.AddContent(Wo.ControlCommand.EvalStart()),this.ownExpression&&this.ownExpression.GenerateIntoContainer(t),this.matchingEquality&&t.AddContent(Hx.NativeFunctionCall.CallWithName("==")),i&&t.AddContent(Wo.ControlCommand.EvalEnd());}return t.AddContent(this._conditionalDivert),this._contentContainer=this.GenerateRuntimeForContent(),this._contentContainer.name="b",this.isInline||this._contentContainer.InsertContent(new Ux.StringValue(`
|
|
23
|
+
`),0),(r||this.isElse&&this.matchingEquality)&&this._contentContainer.InsertContent(Wo.ControlCommand.PopEvaluatedValue(),0),t.AddToNamedContentOnly(this._contentContainer),this.returnDivert=new Lv.Divert,this._contentContainer.AddContent(this.returnDivert),t},this.GenerateRuntimeForContent=()=>this._innerWeave===null?new $v.Container:this._innerWeave.rootContainer,e&&(this._innerWeave=new Xx.Weave(e),this.AddContent(this._innerWeave));}get typeName(){return "ConditionalSingleBranch"}ResolveReferences(e){if(!this._conditionalDivert||!this._contentContainer)throw new Error;this._conditionalDivert.targetPath=this._contentContainer.path,super.ResolveReferences(e);}};Mo.ConditionalSingleBranch=Wd;});var Bv=w(Go=>{Object.defineProperty(Go,"__esModule",{value:true});Go.CustomFlags=void 0;var qv;(function(n){n[n.ParsingString=1]="ParsingString",n[n.TagActive=2]="TagActive";})(qv||(Go.CustomFlags=qv={}));});var Wv=w(zo=>{Object.defineProperty(zo,"__esModule",{value:true});zo.DebugMetadata=void 0;var Md=class n{constructor(){this.startLineNumber=0,this.endLineNumber=0,this.startCharacterNumber=0,this.endCharacterNumber=0,this.fileName=null,this.sourceName=null;}Merge(e){let t=new n;return t.fileName=this.fileName,t.sourceName=this.sourceName,this.startLineNumber<e.startLineNumber?(t.startLineNumber=this.startLineNumber,t.startCharacterNumber=this.startCharacterNumber):this.startLineNumber>e.startLineNumber?(t.startLineNumber=e.startLineNumber,t.startCharacterNumber=e.startCharacterNumber):(t.startLineNumber=this.startLineNumber,t.startCharacterNumber=Math.min(this.startCharacterNumber,e.startCharacterNumber)),this.endLineNumber>e.endLineNumber?(t.endLineNumber=this.endLineNumber,t.endCharacterNumber=this.endCharacterNumber):this.endLineNumber<e.endLineNumber?(t.endLineNumber=e.endLineNumber,t.endCharacterNumber=e.endCharacterNumber):(t.endLineNumber=this.endLineNumber,t.endCharacterNumber=Math.max(this.endCharacterNumber,e.endCharacterNumber)),t}toString(){return this.fileName!==null?`line ${this.startLineNumber} of ${this.fileName}"`:"line "+this.startLineNumber}};zo.DebugMetadata=Md;});var Mv=w(Jo=>{Object.defineProperty(Jo,"__esModule",{value:true});Jo.ExternalDeclaration=void 0;var Zx=ve(),Gd=class extends Zx.ParsedObject{get name(){var e;return ((e=this.identifier)===null||e===void 0?void 0:e.name)||null}constructor(e,t){super(),this.identifier=e,this.argumentNames=t,this.GenerateRuntimeObject=()=>(this.story.AddExternal(this),null);}get typeName(){return "EXTERNAL"}toString(){var e;return `EXTERNAL ${(e=this.identifier)===null||e===void 0?void 0:e.name}`}};Jo.ExternalDeclaration=Gd;});var Gv=w(Ho=>{Object.defineProperty(Ho,"__esModule",{value:true});Ho.FlowDecl=void 0;var zd=class{constructor(e,t,r){this.name=e,this.args=t,this.isFunction=r;}};Ho.FlowDecl=zd;});var Hd=w(Uo=>{Object.defineProperty(Uo,"__esModule",{value:true});Uo.Wrap=void 0;var Qx=ve(),Jd=class extends Qx.ParsedObject{constructor(e){super(),this._objToWrap=e,this.GenerateRuntimeObject=()=>this._objToWrap;}};Uo.Wrap=Jd;});var zv=w(Ko=>{Object.defineProperty(Ko,"__esModule",{value:true});Ko.Glue=void 0;var eT=Hd(),Ud=class extends eT.Wrap{constructor(e){super(e);}get typeName(){return "Glue"}};Ko.Glue=Ud;});var Yo=w(Xo=>{Object.defineProperty(Xo,"__esModule",{value:true});Xo.Glue=void 0;var tT=ot(),Kd=class extends tT.InkObject{toString(){return "Glue"}};Xo.Glue=Kd;});var Hv=w(Zo=>{Object.defineProperty(Zo,"__esModule",{value:true});Zo.IncDecExpression=void 0;var nT=vo(),Jv=St(),rT=Jt(),iT=Gt(),sT=be(),aT=_n(),oT=Mr(),uT=er(),Xd=class extends Jv.Expression{constructor(e,t,r){super(),this.varIdentifier=e,this._runtimeAssignment=null,this.expression=null,this.GenerateIntoContainer=i=>{var a,s;i.AddContent(new oT.VariableReference(((a=this.varIdentifier)===null||a===void 0?void 0:a.name)||null)),this.expression?this.expression.GenerateIntoContainer(i):i.AddContent(new sT.IntValue(1)),i.AddContent(iT.NativeFunctionCall.CallWithName(this.isInc?"+":"-")),this._runtimeAssignment=new aT.VariableAssignment(((s=this.varIdentifier)===null||s===void 0?void 0:s.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?"++":"--")},t instanceof Jv.Expression?(this.expression=t,this.AddContent(this.expression),this.isInc=!!r):this.isInc=t;}get typeName(){return "IncDecExpression"}ResolveReferences(e){var t;super.ResolveReferences(e);let r=e.ResolveVariableWithName(((t=this.varIdentifier)===null||t===void 0?void 0:t.name)||"",this);if(r.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=r.isGlobal,!(this.parent instanceof uT.Weave)&&!(this.parent instanceof rT.FlowBase)&&!(this.parent instanceof nT.ContentList)&&this.Error(`Can't use ${this.incrementDecrementWord} as sub-expression`);}get incrementDecrementWord(){return this.isInc?"increment":"decrement"}};Zo.IncDecExpression=Xd;});var Zd=w(Qo=>{Object.defineProperty(Qo,"__esModule",{value:true});Qo.IncludedFile=void 0;var lT=ve(),Yd=class extends lT.ParsedObject{constructor(e){super(),this.includedStory=e,this.GenerateRuntimeObject=()=>null;}get typeName(){return "IncludedFile"}};Qo.IncludedFile=Yd;});var Uv=w(eu=>{Object.defineProperty(eu,"__esModule",{value:true});eu.InfixOperator=void 0;var Qd=class{constructor(e,t,r){this.type=e,this.precedence=t,this.requireWhitespace=r,this.toString=()=>this.type;}};eu.InfixOperator=Qd;});var tp=w(tu=>{Object.defineProperty(tu,"__esModule",{value:true});tu.Knot=void 0;var cT=Jt(),Kv=Lr(),ep=class extends cT.FlowBase{get flowLevel(){return Kv.FlowLevel.Knot}constructor(e,t,r,i){super(e,t,r,i);}get typeName(){return this.isFunction?"Function":"Knot"}ResolveReferences(e){super.ResolveReferences(e);let t=this.story;for(let r in this.subFlowsByName){let i=t.ContentWithNameAtLevel(r,Kv.FlowLevel.Knot,false);if(i){let a=this.subFlowsByName.get(r),s=`Stitch '${a?a.name:"NO STITCH FOUND"}' has the same name as a knot (on ${i.debugMetadata})`;this.Error(s,a);}}}};tu.Knot=ep;});var Xv=w(nu=>{Object.defineProperty(nu,"__esModule",{value:true});nu.List=void 0;var hT=St(),dT=lt(),pT=lt(),fT=be(),np=class extends hT.Expression{constructor(e){super(),this.itemIdentifierList=e,this.GenerateIntoContainer=t=>{var r,i;let a=new dT.InkList;if(this.itemIdentifierList!=null)for(let s of this.itemIdentifierList){let o=((r=s?.name)===null||r===void 0?void 0:r.split("."))||[],u=null,l="";o.length>1?(u=o[0],l=o[1]):l=o[0];let c=this.story.ResolveListItem(u,l,this);if(c===null)u===null?this.Error(`Could not find list definition that contains item '${s}'`):this.Error(`Could not find list item ${s}`);else {if(c.parent==null){this.Error(`Could not find list definition for item ${s}`);return}u||(u=((i=c.parent.identifier)===null||i===void 0?void 0:i.name)||null);let h=new pT.InkListItem(u,c.name||null);a.has(h.serialized())?this.Warning(`Duplicate of item '${s}' in list.`):a.Add(h,c.seriesValue);}}t.AddContent(new fT.ListValue(a));};}get typeName(){return "List"}};nu.List=np;});var ip=w(ru=>{Object.defineProperty(ru,"__esModule",{value:true});ru.ListElementDefinition=void 0;var mT=ve(),gT=sn(),rp=class extends mT.ParsedObject{get fullName(){var e;let t=this.parent;if(t===null)throw new Error("Can't get full name without a parent list.");return `${(e=t.identifier)===null||e===void 0?void 0:e.name}.${this.name}`}get typeName(){return "ListElement"}get name(){var e;return ((e=this.indentifier)===null||e===void 0?void 0:e.name)||null}constructor(e,t,r=null){super(),this.indentifier=e,this.inInitialList=t,this.explicitValue=r,this.seriesValue=0,this.parent=null,this.GenerateRuntimeObject=()=>{throw new Error("Not implemented.")},this.toString=()=>this.fullName,this.parent=this.parent;}ResolveReferences(e){super.ResolveReferences(e),e.CheckForNamingCollisions(this,this.indentifier,gT.SymbolType.ListItem);}};ru.ListElementDefinition=rp;});var sp=w(iu=>{Object.defineProperty(iu,"__esModule",{value:true});iu.StatementLevel=void 0;var Yv;(function(n){n[n.InnerBlock=0]="InnerBlock",n[n.Stitch=1]="Stitch",n[n.Knot=2]="Knot",n[n.Top=3]="Top";})(Yv||(iu.StatementLevel=Yv={}));});var op=w(su=>{Object.defineProperty(su,"__esModule",{value:true});su.Stitch=void 0;var yT=Jt(),vT=Lr(),ap=class extends yT.FlowBase{get flowLevel(){return vT.FlowLevel.Stitch}constructor(e,t,r,i){super(e,t,r,i),this.baseToString=this.toString,this.toString=()=>`${this.parent!==null?this.parent+" > ":""}${this.baseToString()}`;}get typeName(){return "Stitch"}};su.Stitch=ap;});var ou=w(au=>{Object.defineProperty(au,"__esModule",{value:true});au.Tag=void 0;var bT=ot(),up=class extends bT.InkObject{constructor(e){super(),this.text=e.toString()||"";}toString(){return "# "+this.text}};au.Tag=up;});var cp=w(uu=>{Object.defineProperty(uu,"__esModule",{value:true});uu.Choice=void 0;var CT=at(),ST=qe(),_T=ot(),lp=class n extends _T.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, ST.throwNullException)("Choice.targetPath"):this.targetPath.toString()}set pathStringOnChoice(e){this.targetPath=new CT.Path(e);}Clone(){let e=new n;return e.text=this.text,e.sourcePath=this.sourcePath,e.index=this.index,e.targetPath=this.targetPath,e.originalThreadIndex=this.originalThreadIndex,e.isInvisibleDefault=this.isInvisibleDefault,this.threadAtGeneration!==null&&(e.threadAtGeneration=this.threadAtGeneration.Copy()),e}};uu.Choice=lp;});var dp=w(lu=>{Object.defineProperty(lu,"__esModule",{value:true});lu.ListDefinitionsOrigin=void 0;var wT=lt(),ET=be(),DT=qe(),hp=class{constructor(e){this._lists=new Map,this._allUnambiguousListValueCache=new Map;for(let t of e){this._lists.set(t.name,t);for(let[r,i]of t.items){let a=wT.InkListItem.fromSerializedKey(r),s=new ET.ListValue(a,i);if(!a.itemName)throw new Error("item.itemName is null or undefined.");this._allUnambiguousListValueCache.set(a.itemName,s),this._allUnambiguousListValueCache.set(a.fullName,s);}}}get lists(){let e=[];for(let[,t]of this._lists)e.push(t);return e}TryListGetDefinition(e,t){if(e===null)return {result:t,exists:false};let r=this._lists.get(e);return r?{result:r,exists:true}:{result:t,exists:false}}FindSingleItemListWithName(e){if(e===null)return (0, DT.throwNullException)("name");let t=this._allUnambiguousListValueCache.get(e);return typeof t<"u"?t:null}};lu.ListDefinitionsOrigin=hp;});var Jr=w(pu=>{Object.defineProperty(pu,"__esModule",{value:true});pu.JsonSerialisation=void 0;var cu=Ee(),ht=be(),Zv=Yo(),re=Be(),zr=Yn(),Qv=zt(),eb=Ma(),pp=Mr(),tb=_n(),fp=Gt(),nb=Xn(),rb=ou(),AT=at(),ib=cp(),OT=Rd(),PT=dp(),hu=lt(),De=oe(),tr=qe(),du=class n{static JArrayToRuntimeObjList(e,t=false){let r=e.length;t&&r--;let i=[];for(let a=0;a<r;a++){let s=e[a],o=this.JTokenToRuntimeObject(s);if(o===null)return (0, tr.throwNullException)("runtimeObj");i.push(o);}return i}static WriteDictionaryRuntimeObjs(e,t){e.WriteObjectStart();for(let[r,i]of t)e.WritePropertyStart(r),this.WriteRuntimeObject(e,i),e.WritePropertyEnd();e.WriteObjectEnd();}static WriteListRuntimeObjs(e,t){e.WriteArrayStart();for(let r of t)this.WriteRuntimeObject(e,r);e.WriteArrayEnd();}static WriteIntDictionary(e,t){e.WriteObjectStart();for(let[r,i]of t)e.WriteIntProperty(r,i);e.WriteObjectEnd();}static WriteRuntimeObject(e,t){let r=(0, De.asOrNull)(t,cu.Container);if(r){this.WriteRuntimeContainer(e,r);return}let i=(0, De.asOrNull)(t,Qv.Divert);if(i){let m="->";i.isExternal?m="x()":i.pushesToStack&&(i.stackPushType==zr.PushPopType.Function?m="f()":i.stackPushType==zr.PushPopType.Tunnel&&(m="->t->"));let b;i.hasVariableTarget?b=i.variableDivertName:b=i.targetPathString,e.WriteObjectStart(),e.WriteProperty(m,b),i.hasVariableTarget&&e.WriteProperty("var",true),i.isConditional&&e.WriteProperty("c",true),i.externalArgs>0&&e.WriteIntProperty("exArgs",i.externalArgs),e.WriteObjectEnd();return}let a=(0, De.asOrNull)(t,eb.ChoicePoint);if(a){e.WriteObjectStart(),e.WriteProperty("*",a.pathStringOnChoice),e.WriteIntProperty("flg",a.flags),e.WriteObjectEnd();return}let s=(0, De.asOrNull)(t,ht.BoolValue);if(s){e.WriteBool(s.value);return}let o=(0, De.asOrNull)(t,ht.IntValue);if(o){e.WriteInt(o.value);return}let u=(0, De.asOrNull)(t,ht.FloatValue);if(u){e.WriteFloat(u.value);return}let l=(0, De.asOrNull)(t,ht.StringValue);if(l){l.isNewline?e.Write(`
|
|
24
|
+
`,false):(e.WriteStringStart(),e.WriteStringInner("^"),e.WriteStringInner(l.value),e.WriteStringEnd());return}let c=(0, De.asOrNull)(t,ht.ListValue);if(c){this.WriteInkList(e,c);return}let h=(0, De.asOrNull)(t,ht.DivertTargetValue);if(h){if(e.WriteObjectStart(),h.value===null)return (0, tr.throwNullException)("divTargetVal.value");e.WriteProperty("^->",h.value.componentsString),e.WriteObjectEnd();return}let f=(0, De.asOrNull)(t,ht.VariablePointerValue);if(f){e.WriteObjectStart(),e.WriteProperty("^var",f.value),e.WriteIntProperty("ci",f.contextIndex),e.WriteObjectEnd();return}if((0, De.asOrNull)(t,Zv.Glue)){e.Write("<>");return}let g=(0, De.asOrNull)(t,re.ControlCommand);if(g){e.Write(n._controlCommandNames[g.commandType]);return}let y=(0, De.asOrNull)(t,fp.NativeFunctionCall);if(y){let m=y.name;m=="^"&&(m="L^"),e.Write(m);return}let C=(0, De.asOrNull)(t,pp.VariableReference);if(C){e.WriteObjectStart();let m=C.pathStringForCount;m!=null?e.WriteProperty("CNT?",m):e.WriteProperty("VAR?",C.name),e.WriteObjectEnd();return}let S=(0, De.asOrNull)(t,tb.VariableAssignment);if(S){e.WriteObjectStart();let m=S.isGlobal?"VAR=":"temp=";e.WriteProperty(m,S.variableName),S.isNewDeclaration||e.WriteProperty("re",true),e.WriteObjectEnd();return}if((0, De.asOrNull)(t,nb.Void)){e.Write("void");return}let d=(0, De.asOrNull)(t,rb.Tag);if(d){e.WriteObjectStart(),e.WriteProperty("#",d.text),e.WriteObjectEnd();return}let _=(0, De.asOrNull)(t,ib.Choice);if(_){this.WriteChoice(e,_);return}throw new Error("Failed to convert runtime object to Json token: "+t)}static JObjectToDictionaryRuntimeObjs(e){let t=new Map;for(let r in e)if(e.hasOwnProperty(r)){let i=this.JTokenToRuntimeObject(e[r]);if(i===null)return (0, tr.throwNullException)("inkObject");t.set(r,i);}return t}static JObjectToIntDictionary(e){let t=new Map;for(let r in e)e.hasOwnProperty(r)&&t.set(r,parseInt(e[r]));return t}static JTokenToRuntimeObject(e){if(typeof e=="number"&&!isNaN(e)||typeof e=="boolean")return ht.Value.Create(e);if(typeof e=="string"){let t=e.toString(),r=/^([0-9]+.[0-9]+f)$/.exec(t);if(r)return new ht.FloatValue(parseFloat(r[0]));let i=t[0];if(i=="^")return new ht.StringValue(t.substring(1));if(i==`
|
|
25
|
+
`&&t.length==1)return new ht.StringValue(`
|
|
26
|
+
`);if(t=="<>")return new Zv.Glue;for(let a=0;a<n._controlCommandNames.length;++a){let s=n._controlCommandNames[a];if(t==s)return new re.ControlCommand(a)}if(t=="L^"&&(t="^"),fp.NativeFunctionCall.CallExistsWithName(t))return fp.NativeFunctionCall.CallWithName(t);if(t=="->->")return re.ControlCommand.PopTunnel();if(t=="~ret")return re.ControlCommand.PopFunction();if(t=="void")return new nb.Void}if(typeof e=="object"&&!Array.isArray(e)){let t=e,r;if(t["^->"])return r=t["^->"],new ht.DivertTargetValue(new AT.Path(r.toString()));if(t["^var"]){r=t["^var"];let c=new ht.VariablePointerValue(r.toString());return "ci"in t&&(r=t.ci,c.contextIndex=parseInt(r)),c}let i=false,a=false,s=zr.PushPopType.Function,o=false;if((r=t["->"])?i=true:(r=t["f()"])?(i=true,a=true,s=zr.PushPopType.Function):(r=t["->t->"])?(i=true,a=true,s=zr.PushPopType.Tunnel):(r=t["x()"])&&(i=true,o=true,a=false,s=zr.PushPopType.Function),i){let c=new Qv.Divert;c.pushesToStack=a,c.stackPushType=s,c.isExternal=o;let h=r.toString();return (r=t.var)?c.variableDivertName=h:c.targetPathString=h,c.isConditional=!!t.c,o&&(r=t.exArgs)&&(c.externalArgs=parseInt(r)),c}if(r=t["*"]){let c=new eb.ChoicePoint;return c.pathStringOnChoice=r.toString(),(r=t.flg)&&(c.flags=parseInt(r)),c}if(r=t["VAR?"])return new pp.VariableReference(r.toString());if(r=t["CNT?"]){let c=new pp.VariableReference;return c.pathStringForCount=r.toString(),c}let u=false,l=false;if((r=t["VAR="])?(u=true,l=true):(r=t["temp="])&&(u=true,l=false),u){let c=r.toString(),h=!t.re,f=new tb.VariableAssignment(c,h);return f.isGlobal=l,f}if(t["#"]!==void 0)return r=t["#"],new rb.Tag(r.toString());if(r=t.list){let c=r,h=new hu.InkList;if(r=t.origins){let f=r;h.SetInitialOriginNames(f);}for(let f in c)if(c.hasOwnProperty(f)){let p=c[f],g=new hu.InkListItem(f),y=parseInt(p);h.Add(g,y);}return new ht.ListValue(h)}if(t.originalChoicePath!=null)return this.JObjectToChoice(t)}if(Array.isArray(e))return this.JArrayToContainer(e);if(e==null)return null;throw new Error("Failed to convert token to runtime object: "+this.toJson(e,["parent"]))}static toJson(e,t,r){return JSON.stringify(e,(i,a)=>t?.some(s=>s===i)?void 0:a,r)}static WriteRuntimeContainer(e,t,r=false){if(e.WriteArrayStart(),t===null)return (0, tr.throwNullException)("container");for(let u of t.content)this.WriteRuntimeObject(e,u);let i=t.namedOnlyContent,a=t.countFlags,s=t.name!=null&&!r,o=i!=null||a>0||s;if(o&&e.WriteObjectStart(),i!=null)for(let[u,l]of i){let c=u,h=(0, De.asOrNull)(l,cu.Container);e.WritePropertyStart(c),this.WriteRuntimeContainer(e,h,true),e.WritePropertyEnd();}a>0&&e.WriteIntProperty("#f",a),s&&e.WriteProperty("#n",t.name),o?e.WriteObjectEnd():e.WriteNull(),e.WriteArrayEnd();}static JArrayToContainer(e){let t=new cu.Container;t.content=this.JArrayToRuntimeObjList(e,true);let r=e[e.length-1];if(r!=null){let i=new Map;for(let a in r)if(a=="#f")t.countFlags=parseInt(r[a]);else if(a=="#n")t.name=r[a].toString();else {let s=this.JTokenToRuntimeObject(r[a]),o=(0, De.asOrNull)(s,cu.Container);o&&(o.name=a),i.set(a,s);}t.namedOnlyContent=i;}return t}static JObjectToChoice(e){let t=new ib.Choice;return t.text=e.text.toString(),t.index=parseInt(e.index),t.sourcePath=e.originalChoicePath.toString(),t.originalThreadIndex=parseInt(e.originalThreadIndex),t.pathStringOnChoice=e.targetPath.toString(),t.tags=this.JArrayToTags(e),t.isInvisibleDefault=!!e.isInvisibleDefault,t}static JArrayToTags(e){return e.tags?e.tags:null}static WriteChoice(e,t){e.WriteObjectStart(),e.WriteProperty("text",t.text),e.WriteIntProperty("index",t.index),e.WriteProperty("originalChoicePath",t.sourcePath),e.WriteIntProperty("originalThreadIndex",t.originalThreadIndex),e.WriteProperty("targetPath",t.pathStringOnChoice),e.WriteProperty("isInvisibleDefault",t.isInvisibleDefault),this.WriteChoiceTags(e,t),e.WriteObjectEnd();}static WriteChoiceTags(e,t){if(t.tags&&t.tags.length>0){e.WritePropertyStart("tags"),e.WriteArrayStart();for(let r of t.tags)e.Write(r);e.WriteArrayEnd(),e.WritePropertyEnd();}}static WriteInkList(e,t){let r=t.value;if(r===null)return (0, tr.throwNullException)("rawList");e.WriteObjectStart(),e.WritePropertyStart("list"),e.WriteObjectStart();for(let[i,a]of r){let s=hu.InkListItem.fromSerializedKey(i),o=a;if(s.itemName===null)return (0, tr.throwNullException)("item.itemName");e.WritePropertyNameStart(),e.WritePropertyNameInner(s.originName?s.originName:"?"),e.WritePropertyNameInner("."),e.WritePropertyNameInner(s.itemName),e.WritePropertyNameEnd(),e.Write(o),e.WritePropertyEnd();}if(e.WriteObjectEnd(),e.WritePropertyEnd(),r.Count==0&&r.originNames!=null&&r.originNames.length>0){e.WritePropertyStart("origins"),e.WriteArrayStart();for(let i of r.originNames)e.Write(i);e.WriteArrayEnd(),e.WritePropertyEnd();}e.WriteObjectEnd();}static ListDefinitionsToJToken(e){let t={};for(let r of e.lists){let i={};for(let[a,s]of r.items){let o=hu.InkListItem.fromSerializedKey(a);if(o.itemName===null)return (0, tr.throwNullException)("item.itemName");i[o.itemName]=s;}t[r.name]=i;}return t}static JTokenToListDefinitions(e){let t=e,r=[];for(let i in t)if(t.hasOwnProperty(i)){let a=i.toString(),s=t[i],o=new Map;for(let l in s)if(t.hasOwnProperty(i)){let c=s[l];o.set(l,parseInt(c));}let u=new OT.ListDefinition(a,o);r.push(u);}return new PT.ListDefinitionsOrigin(r)}};pu.JsonSerialisation=du;du._controlCommandNames=(()=>{let n=[];n[re.ControlCommand.CommandType.EvalStart]="ev",n[re.ControlCommand.CommandType.EvalOutput]="out",n[re.ControlCommand.CommandType.EvalEnd]="/ev",n[re.ControlCommand.CommandType.Duplicate]="du",n[re.ControlCommand.CommandType.PopEvaluatedValue]="pop",n[re.ControlCommand.CommandType.PopFunction]="~ret",n[re.ControlCommand.CommandType.PopTunnel]="->->",n[re.ControlCommand.CommandType.BeginString]="str",n[re.ControlCommand.CommandType.EndString]="/str",n[re.ControlCommand.CommandType.NoOp]="nop",n[re.ControlCommand.CommandType.ChoiceCount]="choiceCnt",n[re.ControlCommand.CommandType.Turns]="turn",n[re.ControlCommand.CommandType.TurnsSince]="turns",n[re.ControlCommand.CommandType.ReadCount]="readc",n[re.ControlCommand.CommandType.Random]="rnd",n[re.ControlCommand.CommandType.SeedRandom]="srnd",n[re.ControlCommand.CommandType.VisitIndex]="visit",n[re.ControlCommand.CommandType.SequenceShuffleIndex]="seq",n[re.ControlCommand.CommandType.StartThread]="thread",n[re.ControlCommand.CommandType.Done]="done",n[re.ControlCommand.CommandType.End]="end",n[re.ControlCommand.CommandType.ListFromInt]="listInt",n[re.ControlCommand.CommandType.ListRange]="range",n[re.ControlCommand.CommandType.ListRandom]="lrnd",n[re.ControlCommand.CommandType.BeginTag]="#",n[re.ControlCommand.CommandType.EndTag]="/#";for(let e=0;e<re.ControlCommand.CommandType.TOTAL_VALUES;++e)if(n[e]==null)throw new Error("Control command not accounted for in serialisation");return n})();});var yp=w(ls=>{Object.defineProperty(ls,"__esModule",{value:true});ls.CallStack=void 0;var mp=Yn(),sb=at(),xT=cs(),ab=Jr(),TT=be(),NT=Un(),os=Zi(),FT=Li(),ob=kr(),gp=qe(),us=class n{get elements(){return this.callStack}get depth(){return this.elements.length}get currentElement(){let t=this._threads[this._threads.length-1].callstack;return t[t.length-1]}get currentElementIndex(){return this.callStack.length-1}get currentThread(){return this._threads[this._threads.length-1]}set currentThread(e){FT.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(e);}get canPop(){return this.callStack.length>1}constructor(){if(this._threadCounter=0,this._startOfRoot=os.Pointer.Null,arguments[0]instanceof xT.Story){let e=arguments[0];this._startOfRoot=os.Pointer.StartOf(e.rootContentContainer),this.Reset();}else {let e=arguments[0];this._threads=[];for(let t of e._threads)this._threads.push(t.Copy());this._threadCounter=e._threadCounter,this._startOfRoot=e._startOfRoot.copy();}}Reset(){this._threads=[],this._threads.push(new n.Thread),this._threads[0].callstack.push(new n.Element(mp.PushPopType.Tunnel,this._startOfRoot));}SetJsonToken(e,t){this._threads.length=0;let r=e.threads;for(let i of r){let a=i,s=new n.Thread(a,t);this._threads.push(s);}this._threadCounter=parseInt(e.threadCounter),this._startOfRoot=os.Pointer.StartOf(t.rootContentContainer);}WriteJson(e){e.WriteObject(t=>{t.WritePropertyStart("threads"),t.WriteArrayStart();for(let r of this._threads)r.WriteJson(t);t.WriteArrayEnd(),t.WritePropertyEnd(),t.WritePropertyStart("threadCounter"),t.WriteInt(this._threadCounter),t.WritePropertyEnd();});}PushThread(){let e=this.currentThread.Copy();this._threadCounter++,e.threadIndex=this._threadCounter,this._threads.push(e);}ForkThread(){let e=this.currentThread.Copy();return this._threadCounter++,e.threadIndex=this._threadCounter,e}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==mp.PushPopType.FunctionEvaluationFromGame}Push(e,t=0,r=0){let i=new n.Element(e,this.currentElement.currentPointer,false);i.evaluationStackHeightWhenPushed=t,i.functionStartInOutputStream=r,this.callStack.push(i);}CanPop(e=null){return this.canPop?e==null?true:this.currentElement.type==e:false}Pop(e=null){if(this.CanPop(e)){this.callStack.pop();return}else throw new Error("Mismatched push/pop in Callstack")}GetTemporaryVariableWithName(e,t=-1){t==-1&&(t=this.currentElementIndex+1);let r=this.callStack[t-1],i=(0, ob.tryGetValueFromMap)(r.temporaryVariables,e,null);return i.exists?i.result:null}SetTemporaryVariable(e,t,r,i=-1){i==-1&&(i=this.currentElementIndex+1);let a=this.callStack[i-1];if(!r&&!a.temporaryVariables.get(e))throw new Error("Could not find temporary variable to set: "+e);let s=(0, ob.tryGetValueFromMap)(a.temporaryVariables,e,null);s.exists&&TT.ListValue.RetainListOriginsForAssignment(s.result,t),a.temporaryVariables.set(e,t);}ContextForVariableNamed(e){return this.currentElement.temporaryVariables.get(e)?this.currentElementIndex+1:0}ThreadWithIndex(e){let t=this._threads.filter(r=>{if(r.threadIndex==e)return r});return t.length>0?t[0]:null}get callStack(){return this.currentThread.callstack}get callStackTrace(){let e=new NT.StringBuilder;for(let t=0;t<this._threads.length;t++){let r=this._threads[t],i=t==this._threads.length-1;e.AppendFormat(`=== THREAD {0}/{1} {2}===
|
|
27
|
+
`,t+1,this._threads.length,i?"(current) ":"");for(let a=0;a<r.callstack.length;a++){r.callstack[a].type==mp.PushPopType.Function?e.Append(" [FUNCTION] "):e.Append(" [TUNNEL] ");let s=r.callstack[a].currentPointer;if(!s.isNull){if(e.Append("<SOMEWHERE IN "),s.container===null)return (0, gp.throwNullException)("pointer.container");e.Append(s.container.path.toString()),e.AppendLine(">");}}}return e.toString()}};ls.CallStack=us;(function(n){class e{constructor(i,a,s=false){this.evaluationStackHeightWhenPushed=0,this.functionStartInOutputStream=0,this.currentPointer=a.copy(),this.inExpressionEvaluation=s,this.temporaryVariables=new Map,this.type=i;}Copy(){let i=new e(this.type,this.currentPointer,this.inExpressionEvaluation);return i.temporaryVariables=new Map(this.temporaryVariables),i.evaluationStackHeightWhenPushed=this.evaluationStackHeightWhenPushed,i.functionStartInOutputStream=this.functionStartInOutputStream,i}}n.Element=e;class t{constructor(){if(this.threadIndex=0,this.previousPointer=os.Pointer.Null,this.callstack=[],arguments[0]&&arguments[1]){let i=arguments[0],a=arguments[1];this.threadIndex=parseInt(i.threadIndex);let s=i.callstack;for(let u of s){let l=u,c=parseInt(l.type),h=os.Pointer.Null,f,p=l.cPath;if(typeof p<"u"){f=p.toString();let S=a.ContentAtPath(new sb.Path(f));if(h.container=S.container,h.index=parseInt(l.idx),S.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?");S.approximate&&(h.container!==null?a.Warning("When loading state, exact internal story location couldn't be found: '"+f+"', so it was approximated to '"+h.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 g=!!l.exp,y=new e(c,h,g),C=l.temp;typeof C<"u"?y.temporaryVariables=ab.JsonSerialisation.JObjectToDictionaryRuntimeObjs(C):y.temporaryVariables.clear(),this.callstack.push(y);}let o=i.previousContentObject;if(typeof o<"u"){let u=new sb.Path(o.toString());this.previousPointer=a.PointerAtPath(u);}}}Copy(){let i=new t;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, gp.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"),ab.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, gp.throwNullException)("this.previousPointer.Resolve()");i.WriteProperty("previousContentObject",a.path.toString());}i.WriteObjectEnd();}}n.Thread=t;})(us||(ls.CallStack=us={}));});var lb=w(mu=>{Object.defineProperty(mu,"__esModule",{value:true});mu.VariablesState=void 0;var ke=be(),IT=Bi(),ub=Jr(),We=oe(),hs=kr(),Dn=qe();function kT(){return class{}}var fu=class n extends kT(){variableChangedEvent(e,t){for(let r of this.variableChangedEventCallbacks)r(e,t);}StartVariableObservation(){this._batchObservingVariableChanges=true,this._changedVariablesForBatchObs=new Set;}CompleteVariableObservation(){this._batchObservingVariableChanges=false;let e=new Map;if(this._changedVariablesForBatchObs!=null)for(let t of this._changedVariablesForBatchObs){let r=this._globalVariables.get(t);this.variableChangedEvent(t,r);}if(this.patch!=null)for(let t of this.patch.changedVariables){let r=this.patch.TryGetGlobal(t,null);r.exists&&e.set(t,r);}return this._changedVariablesForBatchObs=null,e}NotifyObservers(e){for(let[t,r]of e)this.variableChangedEvent(t,r);}get callStack(){return this._callStack}set callStack(e){this._callStack=e;}$(e,t){if(typeof t>"u"){let r=null;return this.patch!==null&&(r=this.patch.TryGetGlobal(e,null),r.exists)?r.result.valueObject:(r=this._globalVariables.get(e),typeof r>"u"&&(r=this._defaultGlobalVariables.get(e)),typeof r<"u"?r.valueObject:null)}else {if(typeof this._defaultGlobalVariables.get(e)>"u")throw new IT.StoryException("Cannot assign to a variable ("+e+") that hasn't been declared in the story");let r=ke.Value.Create(t);if(r==null)throw t==null?new Error("Cannot pass null to VariableState"):new Error("Invalid value passed to VariableState: "+t.toString());this.SetGlobal(e,r);}}constructor(e,t){super(),this.variableChangedEventCallbacks=[],this.patch=null,this._defaultGlobalVariables=new Map,this._changedVariablesForBatchObs=new Set,this._batchObservingVariableChanges=false,this._globalVariables=new Map,this._callStack=e,this._listDefsOrigin=t;try{return new Proxy(this,{get(i,a){return a in i?i[a]:i.$(a)},set(i,a,s){return a in i?i[a]=s:i.$(a,s),!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, Dn.throwNullException)("this.patch");for(let[e,t]of this.patch.globals)this._globalVariables.set(e,t);if(this._changedVariablesForBatchObs!==null)for(let e of this.patch.changedVariables)this._changedVariablesForBatchObs.add(e);this.patch=null;}SetJsonToken(e){this._globalVariables.clear();for(let[t,r]of this._defaultGlobalVariables){let i=e[t];if(typeof i<"u"){let a=ub.JsonSerialisation.JTokenToRuntimeObject(i);if(a===null)return (0, Dn.throwNullException)("tokenInkObject");this._globalVariables.set(t,a);}else this._globalVariables.set(t,r);}}WriteJson(e){e.WriteObjectStart();for(let[t,r]of this._globalVariables){let i=t,a=r;if(n.dontSaveDefaultValues&&this._defaultGlobalVariables.has(i)){let s=this._defaultGlobalVariables.get(i);if(this.RuntimeObjectsEqual(a,s))continue}e.WritePropertyStart(i),ub.JsonSerialisation.WriteRuntimeObject(e,a),e.WritePropertyEnd();}e.WriteObjectEnd();}RuntimeObjectsEqual(e,t){if(e===null)return (0, Dn.throwNullException)("obj1");if(t===null)return (0, Dn.throwNullException)("obj2");if(e.constructor!==t.constructor)return false;let r=(0, We.asOrNull)(e,ke.BoolValue);if(r!==null)return r.value===(0, We.asOrThrows)(t,ke.BoolValue).value;let i=(0, We.asOrNull)(e,ke.IntValue);if(i!==null)return i.value===(0, We.asOrThrows)(t,ke.IntValue).value;let a=(0, We.asOrNull)(e,ke.FloatValue);if(a!==null)return a.value===(0, We.asOrThrows)(t,ke.FloatValue).value;let s=(0, We.asOrNull)(e,ke.Value),o=(0, We.asOrNull)(t,ke.Value);if(s!==null&&o!==null)return (0, We.isEquatable)(s.valueObject)&&(0, We.isEquatable)(o.valueObject)?s.valueObject.Equals(o.valueObject):s.valueObject===o.valueObject;throw new Error("FastRoughDefinitelyEquals: Unsupported runtime object type: "+e.constructor.name)}GetVariableWithName(e,t=-1){let r=this.GetRawVariableWithName(e,t),i=(0, We.asOrNull)(r,ke.VariablePointerValue);return i!==null&&(r=this.ValueAtVariablePointer(i)),r}TryGetDefaultVariableValue(e){let t=(0, hs.tryGetValueFromMap)(this._defaultGlobalVariables,e,null);return t.exists?t.result:null}GlobalVariableExistsWithName(e){return this._globalVariables.has(e)||this._defaultGlobalVariables!==null&&this._defaultGlobalVariables.has(e)}GetRawVariableWithName(e,t){let r=null;if(t==0||t==-1){let i=null;if(this.patch!==null&&(i=this.patch.TryGetGlobal(e,null),i.exists)||(i=(0, hs.tryGetValueFromMap)(this._globalVariables,e,null),i.exists)||this._defaultGlobalVariables!==null&&(i=(0, hs.tryGetValueFromMap)(this._defaultGlobalVariables,e,null),i.exists))return i.result;if(this._listDefsOrigin===null)return (0, Dn.throwNullException)("VariablesState._listDefsOrigin");let a=this._listDefsOrigin.FindSingleItemListWithName(e);if(a)return a}return r=this._callStack.GetTemporaryVariableWithName(e,t),r}ValueAtVariablePointer(e){return this.GetVariableWithName(e.variableName,e.contextIndex)}Assign(e,t){let r=e.variableName;if(r===null)return (0, Dn.throwNullException)("name");let i=-1,a=false;if(e.isNewDeclaration?a=e.isGlobal:a=this.GlobalVariableExistsWithName(r),e.isNewDeclaration){let s=(0, We.asOrNull)(t,ke.VariablePointerValue);s!==null&&(t=this.ResolveVariablePointer(s));}else {let s=null;do s=(0, We.asOrNull)(this.GetRawVariableWithName(r,i),ke.VariablePointerValue),s!=null&&(r=s.variableName,i=s.contextIndex,a=i==0);while(s!=null)}a?this.SetGlobal(r,t):this._callStack.SetTemporaryVariable(r,t,e.isNewDeclaration,i);}SnapshotDefaultGlobals(){this._defaultGlobalVariables=new Map(this._globalVariables);}RetainListOriginsForAssignment(e,t){let r=(0, We.asOrThrows)(e,ke.ListValue),i=(0, We.asOrThrows)(t,ke.ListValue);r.value&&i.value&&i.value.Count==0&&i.value.SetInitialOriginNames(r.value.originNames);}SetGlobal(e,t){let r=null;if(this.patch===null&&(r=(0, hs.tryGetValueFromMap)(this._globalVariables,e,null)),this.patch!==null&&(r=this.patch.TryGetGlobal(e,null),r.exists||(r=(0, hs.tryGetValueFromMap)(this._globalVariables,e,null))),ke.ListValue.RetainListOriginsForAssignment(r.result,t),e===null)return (0, Dn.throwNullException)("variableName");if(this.patch!==null?this.patch.SetGlobal(e,t):this._globalVariables.set(e,t),this.variableChangedEvent!==null&&r!==null&&t!==r.result)if(this._batchObservingVariableChanges){if(this._changedVariablesForBatchObs===null)return (0, Dn.throwNullException)("this._changedVariablesForBatchObs");this.patch!==null?this.patch.AddChangedVariable(e):this._changedVariablesForBatchObs!==null&&this._changedVariablesForBatchObs.add(e);}else this.variableChangedEvent(e,t);}ResolveVariablePointer(e){let t=e.contextIndex;t==-1&&(t=this.GetContextIndexOfVariableNamed(e.variableName));let r=this.GetRawVariableWithName(e.variableName,t),i=(0, We.asOrNull)(r,ke.VariablePointerValue);return i??new ke.VariablePointerValue(e.variableName,t)}GetContextIndexOfVariableNamed(e){return this.GlobalVariableExistsWithName(e)?0:this._callStack.currentElementIndex}ObserveVariableChange(e){this.variableChangedEventCallbacks.push(e);}};mu.VariablesState=fu;fu.dontSaveDefaultValues=true;});var bp=w(gu=>{Object.defineProperty(gu,"__esModule",{value:true});gu.PRNG=void 0;var vp=class{constructor(e){this.seed=e%2147483647,this.seed<=0&&(this.seed+=2147483646);}next(){return this.seed=this.seed*48271%2147483647}nextFloat(){return (this.next()-1)/2147483646}};gu.PRNG=vp;});var cb=w(yu=>{Object.defineProperty(yu,"__esModule",{value:true});yu.StatePatch=void 0;var Cp=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 e=arguments[0];this._globals=new Map(e._globals),this._changedVariables=new Set(e._changedVariables),this._visitCounts=new Map(e._visitCounts),this._turnIndices=new Map(e._turnIndices);}else this._globals=new Map,this._changedVariables=new Set,this._visitCounts=new Map,this._turnIndices=new Map;}TryGetGlobal(e,t){return e!==null&&this._globals.has(e)?{result:this._globals.get(e),exists:true}:{result:t,exists:false}}SetGlobal(e,t){this._globals.set(e,t);}AddChangedVariable(e){return this._changedVariables.add(e)}TryGetVisitCount(e,t){return this._visitCounts.has(e)?{result:this._visitCounts.get(e),exists:true}:{result:t,exists:false}}SetVisitCount(e,t){this._visitCounts.set(e,t);}SetTurnIndex(e,t){this._turnIndices.set(e,t);}TryGetTurnIndex(e,t){return this._turnIndices.has(e)?{result:this._turnIndices.get(e),exists:true}:{result:t,exists:false}}};yu.StatePatch=Cp;});var Sp=w(ps=>{Object.defineProperty(ps,"__esModule",{value:true});ps.SimpleJson=void 0;var ds=class n{static TextToDictionary(e){return new n.Reader(e).ToDictionary()}static TextToArray(e){return new n.Reader(e).ToArray()}};ps.SimpleJson=ds;(function(n){class e{constructor(i){if(JSON.parse("0",(s,o,u)=>u!=null)){let s=(o,u,l)=>Number.isInteger(u)&&l.source.endsWith(".0")?l.source+"f":u;this._rootObject=JSON.parse(i,s);}else {let s=i.replace(/(,\s*)([0-9]+\.[0]+)([,]*)/g,'$1"$2f"$3');this._rootObject=JSON.parse(s);}}ToDictionary(){return this._rootObject}ToArray(){return this._rootObject}}n.Reader=e;class t{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===n.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===n.Writer.State.Array?(this.Assert(this.currentCollection!==null),this.currentCollection.push(i),this._collectionStack.push(i)):(this.Assert(this.state===n.Writer.State.None),this._jsonObject=i,this._collectionStack.push(i));this._stateStack.push(new n.Writer.StateElement(n.Writer.State.Object));}WriteObjectEnd(){this.Assert(this.state===n.Writer.State.Object),this._collectionStack.pop(),this._stateStack.pop();}WriteProperty(i,a){if(this.WritePropertyStart(i),arguments[1]instanceof Function){let s=arguments[1];s(this);}else {let s=arguments[1];this.Write(s);}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===n.Writer.State.Object),this._propertyNameStack.push(i),this.IncrementChildCount(),this._stateStack.push(new n.Writer.StateElement(n.Writer.State.Property));}WritePropertyEnd(){this.Assert(this.state===n.Writer.State.Property),this.Assert(this.childCount===1),this._stateStack.pop();}WritePropertyNameStart(){this.Assert(this.state===n.Writer.State.Object),this.IncrementChildCount(),this._currentPropertyName="",this._stateStack.push(new n.Writer.StateElement(n.Writer.State.Property)),this._stateStack.push(new n.Writer.StateElement(n.Writer.State.PropertyName));}WritePropertyNameEnd(){this.Assert(this.state===n.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===n.Writer.State.PropertyName),this.Assert(this._currentPropertyName!==null),this._currentPropertyName+=i;}WriteArrayStart(){this.StartNewObject(true);let i=[];if(this.state===n.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===n.Writer.State.Array?(this.Assert(this.currentCollection!==null),this.currentCollection.push(i),this._collectionStack.push(i)):(this.Assert(this.state===n.Writer.State.None),this._jsonObject=i,this._collectionStack.push(i));this._stateStack.push(new n.Writer.StateElement(n.Writer.State.Array));}WriteArrayEnd(){this.Assert(this.state===n.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 n.Writer.StateElement(n.Writer.State.String));}WriteStringEnd(){this.Assert(this.state==n.Writer.State.String),this._stateStack.pop(),this._addToCurrentObject(this._currentString),this._currentString=null;}WriteStringInner(i,a=true){if(this.Assert(this.state===n.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===n.Writer.State.None||this.state===n.Writer.State.Property||this.state===n.Writer.State.Array):this.Assert(this.state===n.Writer.State.Property||this.state===n.Writer.State.Array),this.state===n.Writer.State.Property&&this.Assert(this.childCount===0),(this.state===n.Writer.State.Array||this.state===n.Writer.State.Property)&&this.IncrementChildCount();}get state(){return this._stateStack.length>0?this._stateStack[this._stateStack.length-1].type:n.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===n.Writer.State.Array?(this.Assert(Array.isArray(this.currentCollection)),this.currentCollection.push(i)):this.state===n.Writer.State.Property&&(this.Assert(!Array.isArray(this.currentCollection)),this.Assert(this.currentPropertyName!==null),this.currentCollection[this.currentPropertyName]=i,this._propertyNameStack.pop());}}n.Writer=t,(function(r){(function(s){s[s.None=0]="None",s[s.Object=1]="Object",s[s.Array=2]="Array",s[s.Property=3]="Property",s[s.PropertyName=4]="PropertyName",s[s.String=5]="String";})(r.State||(r.State={}));class a{constructor(o){this.type=n.Writer.State.None,this.childCount=0,this.type=o;}}r.StateElement=a;})(t=n.Writer||(n.Writer={}));})(ds||(ps.SimpleJson=ds={}));});var db=w(bu=>{Object.defineProperty(bu,"__esModule",{value:true});bu.Flow=void 0;var hb=yp(),vu=Jr(),VT=qe(),_p=class{constructor(){let e=arguments[0],t=arguments[1];if(this.name=e,this.callStack=new hb.CallStack(t),arguments[2]){let r=arguments[2];this.callStack.SetJsonToken(r.callstack,t),this.outputStream=vu.JsonSerialisation.JArrayToRuntimeObjList(r.outputStream),this.currentChoices=vu.JsonSerialisation.JArrayToRuntimeObjList(r.currentChoices);let i=r.choiceThreads;typeof i<"u"&&this.LoadFlowChoiceThreads(i,t);}else this.outputStream=[],this.currentChoices=[];}WriteJson(e){e.WriteObjectStart(),e.WriteProperty("callstack",r=>this.callStack.WriteJson(r)),e.WriteProperty("outputStream",r=>vu.JsonSerialisation.WriteListRuntimeObjs(r,this.outputStream));let t=false;for(let r of this.currentChoices){if(r.threadAtGeneration===null)return (0, VT.throwNullException)("c.threadAtGeneration");r.originalThreadIndex=r.threadAtGeneration.threadIndex,this.callStack.ThreadWithIndex(r.originalThreadIndex)===null&&(t||(t=true,e.WritePropertyStart("choiceThreads"),e.WriteObjectStart()),e.WritePropertyStart(r.originalThreadIndex),r.threadAtGeneration.WriteJson(e),e.WritePropertyEnd());}t&&(e.WriteObjectEnd(),e.WritePropertyEnd()),e.WriteProperty("currentChoices",r=>{r.WriteArrayStart();for(let i of this.currentChoices)vu.JsonSerialisation.WriteChoice(r,i);r.WriteArrayEnd();}),e.WriteObjectEnd();}LoadFlowChoiceThreads(e,t){for(let r of this.currentChoices){let i=this.callStack.ThreadWithIndex(r.originalThreadIndex);if(i!==null)r.threadAtGeneration=i.Copy();else {let a=e[`${r.originalThreadIndex}`];r.threadAtGeneration=new hb.CallStack.Thread(a,t);}}}};bu.Flow=_p;});var mb=w(Su=>{Object.defineProperty(Su,"__esModule",{value:true});Su.StoryState=void 0;var RT=yp(),jT=lb(),xe=be(),An=Yn(),$T=ou(),wp=Yo(),pb=at(),Xe=Be(),Ep=Un(),On=Jr(),LT=bp(),qT=Xn(),Hr=Zi(),fs=kr(),Ae=oe(),BT=Li(),Dt=qe(),WT=cs(),MT=cb(),fb=Sp(),Cu=db(),GT=lt(),Dp=class n{ToJson(e=false){let t=new fb.SimpleJson.Writer;return this.WriteJson(t),t.toString()}toJson(e=false){return this.ToJson(e)}LoadJson(e){let t=fb.SimpleJson.TextToDictionary(e);this.LoadJsonObj(t),this.onDidLoadState!==null&&this.onDidLoadState();}VisitCountAtPathString(e){let t;if(this._patch!==null){let r=this.story.ContentAtPath(new pb.Path(e)).container;if(r===null)throw new Error("Content at path not found: "+e);if(t=this._patch.TryGetVisitCount(r,0),t.exists)return t.result}return t=(0, fs.tryGetValueFromMap)(this._visitCounts,e,null),t.exists?t.result:0}VisitCountForContainer(e){if(e===null)return (0, Dt.throwNullException)("container");if(!e.visitsShouldBeCounted)return this.story.Error("Read count for target ("+e.name+" - on "+e.debugMetadata+") unknown. The story may need to be compiled with countAllVisits flag (-c)."),0;if(this._patch!==null){let i=this._patch.TryGetVisitCount(e,0);if(i.exists)return i.result}let t=e.path.toString(),r=(0, fs.tryGetValueFromMap)(this._visitCounts,t,null);return r.exists?r.result:0}IncrementVisitCountForContainer(e){if(this._patch!==null){let i=this.VisitCountForContainer(e);i++,this._patch.SetVisitCount(e,i);return}let t=e.path.toString(),r=(0, fs.tryGetValueFromMap)(this._visitCounts,t,null);r.exists?this._visitCounts.set(t,r.result+1):this._visitCounts.set(t,1);}RecordTurnIndexVisitToContainer(e){if(this._patch!==null){this._patch.SetTurnIndex(e,this.currentTurnIndex);return}let t=e.path.toString();this._turnIndices.set(t,this.currentTurnIndex);}TurnsSinceForContainer(e){if(e.turnIndexShouldBeCounted||this.story.Error("TURNS_SINCE() for target ("+e.name+" - on "+e.debugMetadata+") unknown. The story may need to be compiled with countAllVisits flag (-c)."),this._patch!==null){let i=this._patch.TryGetTurnIndex(e,0);if(i.exists)return this.currentTurnIndex-i.result}let t=e.path.toString(),r=(0, fs.tryGetValueFromMap)(this._turnIndices,t,0);return r.exists?this.currentTurnIndex-r.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(e){this._variablesState=e;}get callStack(){return this._currentFlow.callStack}get evaluationStack(){return this._evaluationStack}get currentTurnIndex(){return this._currentTurnIndex}set currentTurnIndex(e){this._currentTurnIndex=e;}get currentPathString(){let e=this.currentPointer;return e.isNull?null:e.path===null?(0, Dt.throwNullException)("pointer.path"):e.path.toString()}get previousPathString(){let e=this.previousPointer;return e.isNull?null:e.path===null?(0, Dt.throwNullException)("previousPointer.path"):e.path.toString()}get currentPointer(){return this.callStack.currentElement.currentPointer.copy()}set currentPointer(e){this.callStack.currentElement.currentPointer=e.copy();}get previousPointer(){return this.callStack.currentThread.previousPointer.copy()}set previousPointer(e){this.callStack.currentThread.previousPointer=e.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 e=new Ep.StringBuilder,t=false;for(let r of this.outputStream){let i=(0, Ae.asOrNull)(r,xe.StringValue);if(!t&&i!==null)e.Append(i.value);else {let a=(0, Ae.asOrNull)(r,Xe.ControlCommand);a!==null&&(a.commandType==Xe.ControlCommand.CommandType.BeginTag?t=true:a.commandType==Xe.ControlCommand.CommandType.EndTag&&(t=false));}}this._currentText=this.CleanOutputWhitespace(e.toString()),this._outputStreamTextDirty=false;}return this._currentText}CleanOutputWhitespace(e){let t=new Ep.StringBuilder,r=-1,i=0;for(let a=0;a<e.length;a++){let s=e.charAt(a),o=s==" "||s==" ";o&&r==-1&&(r=a),o||(s!=`
|
|
28
28
|
`&&r>0&&r!=i&&t.Append(" "),r=-1),s==`
|
|
29
|
-
`&&(i=a+1),o||t.Append(s);}return t.toString()}get currentTags(){if(this._outputStreamTagsDirty){this._currentTags=[];let e=false,t=new
|
|
29
|
+
`&&(i=a+1),o||t.Append(s);}return t.toString()}get currentTags(){if(this._outputStreamTagsDirty){this._currentTags=[];let e=false,t=new Ep.StringBuilder;for(let r of this.outputStream){let i=(0, Ae.asOrNull)(r,Xe.ControlCommand);if(i!=null){if(i.commandType==Xe.ControlCommand.CommandType.BeginTag){if(e&&t.Length>0){let a=this.CleanOutputWhitespace(t.toString());this._currentTags.push(a),t.Clear();}e=true;}else if(i.commandType==Xe.ControlCommand.CommandType.EndTag){if(t.Length>0){let a=this.CleanOutputWhitespace(t.toString());this._currentTags.push(a),t.Clear();}e=false;}}else if(e){let a=(0, Ae.asOrNull)(r,xe.StringValue);a!==null&&t.Append(a.value);}else {let a=(0, Ae.asOrNull)(r,$T.Tag);a!=null&&a.text!=null&&a.text.length>0&&this._currentTags.push(a.text);}}if(t.Length>0){let r=this.CleanOutputWhitespace(t.toString());this._currentTags.push(r),t.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 e of this._namedFlows.keys())e!=this.kDefaultFlowName&&this._aliveFlowNames.push(e);this._aliveFlowNamesDirty=false;}return this._aliveFlowNames}get inExpressionEvaluation(){return this.callStack.currentElement.inExpressionEvaluation}set inExpressionEvaluation(e){this.callStack.currentElement.inExpressionEvaluation=e;}constructor(e){this.kInkSaveStateVersion=10,this.kMinCompatibleLoadVersion=8,this.onDidLoadState=null,this._currentErrors=null,this._currentWarnings=null,this.divertedPointer=Hr.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=e,this._currentFlow=new Cu.Flow(this.kDefaultFlowName,e),this.OutputStreamDirty(),this._aliveFlowNamesDirty=true,this._evaluationStack=[],this._variablesState=new jT.VariablesState(this.callStack,e.listDefinitions),this._visitCounts=new Map,this._turnIndices=new Map,this.currentTurnIndex=-1;let t=new Date().getTime();this.storySeed=new LT.PRNG(t).next()%100,this.previousRandom=0,this.GoToStart();}GoToStart(){this.callStack.currentElement.currentPointer=Hr.Pointer.StartOf(this.story.mainContentContainer);}SwitchFlow_Internal(e){if(e===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)),e===this._currentFlow.name)return;let t,r=(0, fs.tryGetValueFromMap)(this._namedFlows,e,null);r.exists?t=r.result:(t=new Cu.Flow(e,this.story),this._namedFlows.set(e,t),this._aliveFlowNamesDirty=true),this._currentFlow=t,this.variablesState.callStack=this._currentFlow.callStack,this.OutputStreamDirty();}SwitchToDefaultFlow_Internal(){this._namedFlows!==null&&this.SwitchFlow_Internal(this.kDefaultFlowName);}RemoveFlow_Internal(e){if(e===null)throw new Error("Must pass a non-null string to Story.DestroyFlow");if(e===this.kDefaultFlowName)throw new Error("Cannot destroy default flow");if(this._currentFlow.name===e&&this.SwitchToDefaultFlow_Internal(),this._namedFlows===null)return (0, Dt.throwNullException)("this._namedFlows");this._namedFlows.delete(e),this._aliveFlowNamesDirty=true;}CopyAndStartPatching(e){let t=new n(this.story);if(t._patch=new MT.StatePatch(this._patch),t._currentFlow.name=this._currentFlow.name,t._currentFlow.callStack=new RT.CallStack(this._currentFlow.callStack),t._currentFlow.outputStream.push(...this._currentFlow.outputStream),t.OutputStreamDirty(),e)for(let r of this._currentFlow.currentChoices)t._currentFlow.currentChoices.push(r.Clone());else t._currentFlow.currentChoices.push(...this._currentFlow.currentChoices);if(this._namedFlows!==null){t._namedFlows=new Map;for(let[r,i]of this._namedFlows)t._namedFlows.set(r,i),t._aliveFlowNamesDirty=true;t._namedFlows.set(this._currentFlow.name,t._currentFlow);}return this.hasError&&(t._currentErrors=[],t._currentErrors.push(...this.currentErrors||[])),this.hasWarning&&(t._currentWarnings=[],t._currentWarnings.push(...this.currentWarnings||[])),t.variablesState=this.variablesState,t.variablesState.callStack=t.callStack,t.variablesState.patch=t._patch,t.evaluationStack.push(...this.evaluationStack),this.divertedPointer.isNull||(t.divertedPointer=this.divertedPointer.copy()),t.previousPointer=this.previousPointer.copy(),t._visitCounts=this._visitCounts,t._turnIndices=this._turnIndices,t.currentTurnIndex=this.currentTurnIndex,t.storySeed=this.storySeed,t.previousRandom=this.previousRandom,t.didSafeExit=this.didSafeExit,t}RestoreAfterPatch(){this.variablesState.callStack=this.callStack,this.variablesState.patch=this._patch;}ApplyAnyPatch(){if(this._patch!==null){this.variablesState.ApplyPatch();for(let[e,t]of this._patch.visitCounts)this.ApplyCountChanges(e,t,true);for(let[e,t]of this._patch.turnIndices)this.ApplyCountChanges(e,t,false);this._patch=null;}}ApplyCountChanges(e,t,r){(r?this._visitCounts:this._turnIndices).set(e.path.toString(),t);}WriteJson(e){if(e.WriteObjectStart(),e.WritePropertyStart("flows"),e.WriteObjectStart(),this._namedFlows!==null)for(let[t,r]of this._namedFlows)e.WriteProperty(t,i=>r.WriteJson(i));else e.WriteProperty(this._currentFlow.name,t=>this._currentFlow.WriteJson(t));if(e.WriteObjectEnd(),e.WritePropertyEnd(),e.WriteProperty("currentFlowName",this._currentFlow.name),e.WriteProperty("variablesState",t=>this.variablesState.WriteJson(t)),e.WriteProperty("evalStack",t=>On.JsonSerialisation.WriteListRuntimeObjs(t,this.evaluationStack)),!this.divertedPointer.isNull){if(this.divertedPointer.path===null)return (0, Dt.throwNullException)("divertedPointer");e.WriteProperty("currentDivertTarget",this.divertedPointer.path.componentsString);}e.WriteProperty("visitCounts",t=>On.JsonSerialisation.WriteIntDictionary(t,this._visitCounts)),e.WriteProperty("turnIndices",t=>On.JsonSerialisation.WriteIntDictionary(t,this._turnIndices)),e.WriteIntProperty("turnIdx",this.currentTurnIndex),e.WriteIntProperty("storySeed",this.storySeed),e.WriteIntProperty("previousRandom",this.previousRandom),e.WriteIntProperty("inkSaveVersion",this.kInkSaveStateVersion),e.WriteIntProperty("inkFormatVersion",WT.Story.inkVersionCurrent),e.WriteObjectEnd();}LoadJsonObj(e){let t=e,r=t.inkSaveVersion;if(r==null)throw new Error("ink save format incorrect, can't load.");if(parseInt(r)<this.kMinCompatibleLoadVersion)throw new Error("Ink save format isn't compatible with the current version (saw '"+r+"', but minimum is "+this.kMinCompatibleLoadVersion+"), so can't load.");let i=t.flows;if(i!=null){let s=i;Object.keys(s).length===1?this._namedFlows=null:this._namedFlows===null?this._namedFlows=new Map:this._namedFlows.clear();let o=Object.entries(s);for(let[u,l]of o){let c=u,h=l,f=new Cu.Flow(c,this.story,h);if(Object.keys(s).length===1)this._currentFlow=new Cu.Flow(c,this.story,h);else {if(this._namedFlows===null)return (0, Dt.throwNullException)("this._namedFlows");this._namedFlows.set(c,f);}}if(this._namedFlows!=null&&this._namedFlows.size>1){let u=t.currentFlowName;this._currentFlow=this._namedFlows.get(u);}}else {this._namedFlows=null,this._currentFlow.name=this.kDefaultFlowName,this._currentFlow.callStack.SetJsonToken(t.callstackThreads,this.story),this._currentFlow.outputStream=On.JsonSerialisation.JArrayToRuntimeObjList(t.outputStream),this._currentFlow.currentChoices=On.JsonSerialisation.JArrayToRuntimeObjList(t.currentChoices);let s=t.choiceThreads;this._currentFlow.LoadFlowChoiceThreads(s,this.story);}this.OutputStreamDirty(),this._aliveFlowNamesDirty=true,this.variablesState.SetJsonToken(t.variablesState),this.variablesState.callStack=this._currentFlow.callStack,this._evaluationStack=On.JsonSerialisation.JArrayToRuntimeObjList(t.evalStack);let a=t.currentDivertTarget;if(a!=null){let s=new pb.Path(a.toString());this.divertedPointer=this.story.PointerAtPath(s);}this._visitCounts=On.JsonSerialisation.JObjectToIntDictionary(t.visitCounts),this._turnIndices=On.JsonSerialisation.JObjectToIntDictionary(t.turnIndices),this.currentTurnIndex=parseInt(t.turnIdx),this.storySeed=parseInt(t.storySeed),this.previousRandom=parseInt(t.previousRandom);}ResetErrors(){this._currentErrors=null,this._currentWarnings=null;}ResetOutput(e=null){this.outputStream.length=0,e!==null&&this.outputStream.push(...e),this.OutputStreamDirty();}PushToOutputStream(e){let t=(0, Ae.asOrNull)(e,xe.StringValue);if(t!==null){let r=this.TrySplittingHeadTailWhitespace(t);if(r!==null){for(let i of r)this.PushToOutputStreamIndividual(i);this.OutputStreamDirty();return}}this.PushToOutputStreamIndividual(e),this.OutputStreamDirty();}PopFromOutputStream(e){this.outputStream.splice(this.outputStream.length-e,e),this.OutputStreamDirty();}TrySplittingHeadTailWhitespace(e){let t=e.value;if(t===null)return (0, Dt.throwNullException)("single.value");let r=-1,i=-1;for(let c=0;c<t.length;c++){let h=t[c];if(h==`
|
|
30
30
|
`)r==-1&&(r=c),i=c;else {if(h==" "||h==" ")continue;break}}let a=-1,s=-1;for(let c=t.length-1;c>=0;c--){let h=t[c];if(h==`
|
|
31
|
-
`)a==-1&&(a=c),s=c;else {if(h==" "||h==" ")continue;break}}if(r==-1&&a==-1)return null;let o=[],u=0,l=t.length;if(r!=-1){if(r>0){let c=new
|
|
32
|
-
`)),u=i+1;}if(a!=-1&&(l=s),l>u){let c=t.substring(u,l);o.push(new
|
|
33
|
-
`)),a<t.length-1)){let c=t.length-a-1,h=new Oe.StringValue(t.substring(a+1,a+1+c));o.push(h);}return o}PushToOutputStreamIndividual(e){let t=(0, De.asOrNull)(e,Sf.Glue),r=(0, De.asOrNull)(e,Oe.StringValue),i=true;if(t)this.TrimNewlinesFromOutputStream(),i=true;else if(r){let a=-1,s=this.callStack.currentElement;s.type==wn.PushPopType.Function&&(a=s.functionStartInOutputStream);let o=-1;for(let l=this.outputStream.length-1;l>=0;l--){let c=this.outputStream[l],h=c instanceof Ue.ControlCommand?c:null;if((c instanceof Sf.Glue?c:null)!=null){o=l;break}else if(h!=null&&h.commandType==Ue.ControlCommand.CommandType.BeginString){l>=a&&(a=-1);break}}let u=-1;if(o!=-1&&a!=-1?u=Math.min(a,o):o!=-1?u=o:u=a,u!=-1){if(r.isNewline)i=false;else if(r.isNonWhitespace&&(o>-1&&this.RemoveExistingGlue(),a>-1)){let l=this.callStack.elements;for(let c=l.length-1;c>=0;c--){let h=l[c];if(h.type==wn.PushPopType.Function)h.functionStartInOutputStream=-1;else break}}}else r.isNewline&&(this.outputStreamEndsInNewline||!this.outputStreamContainsContent)&&(i=false);}if(i){if(e===null)return (0, Et.throwNullException)("obj");this.outputStream.push(e),this.OutputStreamDirty();}}TrimNewlinesFromOutputStream(){let e=-1,t=this.outputStream.length-1;for(;t>=0;){let r=this.outputStream[t],i=(0, De.asOrNull)(r,Ue.ControlCommand),a=(0, De.asOrNull)(r,Oe.StringValue);if(i!=null||a!=null&&a.isNonWhitespace)break;a!=null&&a.isNewline&&(e=t),t--;}if(e>=0)for(t=e;t<this.outputStream.length;)(0, De.asOrNull)(this.outputStream[t],Oe.StringValue)?this.outputStream.splice(t,1):t++;this.OutputStreamDirty();}RemoveExistingGlue(){for(let e=this.outputStream.length-1;e>=0;e--){let t=this.outputStream[e];if(t instanceof Sf.Glue)this.outputStream.splice(e,1);else if(t instanceof Ue.ControlCommand)break}this.OutputStreamDirty();}get outputStreamEndsInNewline(){if(this.outputStream.length>0)for(let e=this.outputStream.length-1;e>=0&&!(this.outputStream[e]instanceof Ue.ControlCommand);e--){let r=this.outputStream[e];if(r instanceof Oe.StringValue){if(r.isNewline)return true;if(r.isNonWhitespace)break}}return false}get outputStreamContainsContent(){for(let e of this.outputStream)if(e instanceof Oe.StringValue)return true;return false}get inStringEvaluation(){for(let e=this.outputStream.length-1;e>=0;e--){let t=(0, De.asOrNull)(this.outputStream[e],Ue.ControlCommand);if(t instanceof Ue.ControlCommand&&t.commandType==Ue.ControlCommand.CommandType.BeginString)return true}return false}PushEvaluationStack(e){let t=(0, De.asOrNull)(e,Oe.ListValue);if(t){let r=t.value;if(r===null)return (0, Et.throwNullException)("rawList");if(r.originNames!=null){r.origins||(r.origins=[]),r.origins.length=0;for(let i of r.originNames){if(this.story.listDefinitions===null)return (0, Et.throwNullException)("StoryState.story.listDefinitions");let a=this.story.listDefinitions.TryListGetDefinition(i,null);if(a.result===null)return (0, Et.throwNullException)("StoryState def.result");r.origins.indexOf(a.result)<0&&r.origins.push(a.result);}}}if(e===null)return (0, Et.throwNullException)("obj");this.evaluationStack.push(e);}PopEvaluationStack(e){if(typeof e>"u"){let t=this.evaluationStack.pop();return (0, De.nullIfUndefined)(t)}else {if(e>this.evaluationStack.length)throw new Error("trying to pop too many objects");let t=this.evaluationStack.splice(this.evaluationStack.length-e,e);return (0, De.nullIfUndefined)(t)}}PeekEvaluationStack(){return this.evaluationStack[this.evaluationStack.length-1]}ForceEnd(){this.callStack.Reset(),this._currentFlow.currentChoices.length=0,this.currentPointer=zr.Pointer.Null,this.previousPointer=zr.Pointer.Null,this.didSafeExit=true;}TrimWhitespaceFromFunctionEnd(){HT.Debug.Assert(this.callStack.currentElement.type==wn.PushPopType.Function);let e=this.callStack.currentElement.functionStartInOutputStream;e==-1&&(e=0);for(let t=this.outputStream.length-1;t>=e;t--){let r=this.outputStream[t],i=(0, De.asOrNull)(r,Oe.StringValue),a=(0, De.asOrNull)(r,Ue.ControlCommand);if(i!=null){if(a)break;if(i.isNewline||i.isInlineWhitespace)this.outputStream.splice(t,1),this.OutputStreamDirty();else break}}}PopCallStack(e=null){this.callStack.currentElement.type==wn.PushPopType.Function&&this.TrimWhitespaceFromFunctionEnd(),this.callStack.Pop(e);}SetChosenPath(e,t){this._currentFlow.currentChoices.length=0;let r=this.story.PointerAtPath(e);!r.isNull&&r.index==-1&&(r.index=0),this.currentPointer=r,t&&this.currentTurnIndex++;}StartFunctionEvaluationFromGame(e,t){this.callStack.Push(wn.PushPopType.FunctionEvaluationFromGame,this.evaluationStack.length),this.callStack.currentElement.currentPointer=zr.Pointer.StartOf(e),this.PassArgumentsToEvaluationStack(t);}PassArgumentsToEvaluationStack(e){if(e!==null)for(let t=0;t<e.length;t++){if(!(typeof e[t]=="number"||typeof e[t]=="string"||typeof e[t]=="boolean"||e[t]instanceof XT.InkList))throw new Error("ink arguments when calling EvaluateFunction / ChoosePathStringWithParameters must benumber, string, bool or InkList. Argument was "+((0, De.nullIfUndefined)(e[t])===null?"null":e[t].constructor.name));this.PushEvaluationStack(Oe.Value.Create(e[t]));}}TryExitFunctionEvaluationFromGame(){return this.callStack.currentElement.type==wn.PushPopType.FunctionEvaluationFromGame?(this.currentPointer=zr.Pointer.Null,this.didSafeExit=true,true):false}CompleteFunctionEvaluationFromGame(){if(this.callStack.currentElement.type!=wn.PushPopType.FunctionEvaluationFromGame)throw new Error("Expected external function evaluation to be complete. Stack trace: "+this.callStack.callStackTrace);let e=this.callStack.currentElement.evaluationStackHeightWhenPushed,t=null;for(;this.evaluationStack.length>e;){let r=this.PopEvaluationStack();t===null&&(t=r);}if(this.PopCallStack(wn.PushPopType.FunctionEvaluationFromGame),t){if(t instanceof JT.Void)return null;let r=(0, De.asOrThrows)(t,Oe.Value);return r.valueType==Oe.ValueType.DivertTarget?"-> "+r.valueObject.toString():r.valueObject}return null}AddError(e,t){t?(this._currentWarnings==null&&(this._currentWarnings=[]),this._currentWarnings.push(e)):(this._currentErrors==null&&(this._currentErrors=[]),this._currentErrors.push(e));}OutputStreamDirty(){this._outputStreamTextDirty=true,this._outputStreamTagsDirty=true;}};Cu.StoryState=wf;});var p0=E(bu=>{Object.defineProperty(bu,"__esModule",{value:true});bu.Stopwatch=void 0;var Df=class{constructor(){this.startTime=void 0;}get ElapsedMilliseconds(){return typeof this.startTime>"u"?0:new Date().getTime()-this.startTime}Start(){this.startTime=new Date().getTime();}Stop(){this.startTime=void 0;}};bu.Stopwatch=Df;});var g0=E(_u=>{Object.defineProperty(_u,"__esModule",{value:true});_u.ErrorType=void 0;var m0;(function(n){n[n.Author=0]="Author",n[n.Warning=1]="Warning",n[n.Error=2]="Error";})(m0||(_u.ErrorType=m0={}));});var us=E(nr=>{Object.defineProperty(nr,"__esModule",{value:true});nr.Story=nr.InkList=void 0;var Be=Ee(),Af=st(),Pf=Gr(),YT=f0(),B=Le(),wt=Kn(),ZT=Ba(),QT=lf(),y0=Mt(),I=ve(),Of=it(),fs=Un(),Su=su(),e1=bn(),t1=Br(),n1=Wt(),er=Li(),xf=vf(),tr=Jn(),r1=hf(),i1=p0(),An=Xi(),ps=ot(),G=ae(),re=je(),v0=bf(),C0=g0(),s1=ot();Object.defineProperty(nr,"InkList",{enumerable:true,get:function(){return s1.InkList}});Number.isInteger||(Number.isInteger=function(e){return typeof e=="number"&&isFinite(e)&&e>-9007199254740992&&e<9007199254740992&&Math.floor(e)===e});var Jr=class n extends Af.InkObject{get currentChoices(){let e=[];if(this._state===null)return (0, re.throwNullException)("this._state");for(let t of this._state.currentChoices)t.isInvisibleDefault||(t.index=e.length,e.push(t));return e}get currentText(){return this.IfAsyncWeCant("call currentText since it's a work in progress"),this.state.currentText}get currentTags(){return this.IfAsyncWeCant("call currentTags since it's a work in progress"),this.state.currentTags}get currentErrors(){return this.state.currentErrors}get currentWarnings(){return this.state.currentWarnings}get currentFlowName(){return this.state.currentFlowName}get currentFlowIsDefaultFlow(){return this.state.currentFlowIsDefaultFlow}get aliveFlowNames(){return this.state.aliveFlowNames}get hasError(){return this.state.hasError}get hasWarning(){return this.state.hasWarning}get variablesState(){return this.state.variablesState}get listDefinitions(){return this._listDefinitions}get state(){return this._state}StartProfiling(){}EndProfiling(){}constructor(){super(),this.inkVersionMinimumCompatible=18,this.onError=null,this.onDidContinue=null,this.onMakeChoice=null,this.onEvaluateFunction=null,this.onCompleteEvaluateFunction=null,this.onChoosePathString=null,this._prevContainers=[],this.allowExternalFunctionFallbacks=false,this._listDefinitions=null,this._variableObservers=null,this._hasValidatedExternals=false,this._temporaryEvaluationContainer=null,this._asyncContinueActive=false,this._stateSnapshotAtLastNewline=null,this._sawLookaheadUnsafeFunctionAfterNewline=false,this._recursiveContinueCount=0,this._asyncSaving=false,this._profiler=null;let e,t=null,r=null;if(arguments[0]instanceof Be.Container)e=arguments[0],typeof arguments[1]<"u"&&(t=arguments[1]),this._mainContentContainer=e;else if(typeof arguments[0]=="string"){let i=arguments[0];r=v0.SimpleJson.TextToDictionary(i);}else r=arguments[0];if(t!=null&&(this._listDefinitions=new r1.ListDefinitionsOrigin(t)),this._externals=new Map,r!==null){let i=r,a=i.inkVersion;if(a==null)throw new Error("ink version number not found. Are you sure it's a valid .ink.json file?");let s=parseInt(a);if(s>n.inkVersionCurrent)throw new Error("Version of ink used to build story was newer than the current version of the engine");if(s<this.inkVersionMinimumCompatible)throw new Error("Version of ink used to build story is too old to be loaded by this version of the engine");s!=n.inkVersionCurrent&&console.warn(`WARNING: Version of ink ${n.inkVersionCurrent} used to build story doesn't match current version of engine (${s}). Non-critical, but recommend synchronising.`);let o=i.root;if(o==null)throw new Error("Root node for ink not found. Are you sure it's a valid .ink.json file?");let u;(u=i.listDefs)&&(this._listDefinitions=Pf.JsonSerialisation.JTokenToListDefinitions(u)),this._mainContentContainer=(0, G.asOrThrows)(Pf.JsonSerialisation.JTokenToRuntimeObject(o),Be.Container),this.ResetState();}}ToJson(e){let t=false;if(e||(t=true,e=new v0.SimpleJson.Writer),e.WriteObjectStart(),e.WriteIntProperty("inkVersion",n.inkVersionCurrent),e.WriteProperty("root",r=>Pf.JsonSerialisation.WriteRuntimeContainer(r,this._mainContentContainer)),this._listDefinitions!=null){e.WritePropertyStart("listDefs"),e.WriteObjectStart();for(let r of this._listDefinitions.lists){e.WritePropertyStart(r.name),e.WriteObjectStart();for(let[i,a]of r.items){let s=ps.InkListItem.fromSerializedKey(i),o=a;e.WriteIntProperty(s.itemName,o);}e.WriteObjectEnd(),e.WritePropertyEnd();}e.WriteObjectEnd(),e.WritePropertyEnd();}if(e.WriteObjectEnd(),t)return e.toString()}ResetState(){this.IfAsyncWeCant("ResetState"),this._state=new YT.StoryState(this),this._state.variablesState.ObserveVariableChange(this.VariableStateDidChangeEvent.bind(this)),this.ResetGlobals();}ResetErrors(){if(this._state===null)return (0, re.throwNullException)("this._state");this._state.ResetErrors();}ResetCallstack(){if(this.IfAsyncWeCant("ResetCallstack"),this._state===null)return (0, re.throwNullException)("this._state");this._state.ForceEnd();}ResetGlobals(){if(this._mainContentContainer.namedContent.get("global decl")){let e=this.state.currentPointer.copy();this.ChoosePath(new Of.Path("global decl"),false),this.ContinueInternal(),this.state.currentPointer=e;}this.state.variablesState.SnapshotDefaultGlobals();}SwitchFlow(e){if(this.IfAsyncWeCant("switch flow"),this._asyncSaving)throw new Error("Story is already in background saving mode, can't switch flow to "+e);this.state.SwitchFlow_Internal(e);}RemoveFlow(e){this.state.RemoveFlow_Internal(e);}SwitchToDefaultFlow(){this.state.SwitchToDefaultFlow_Internal();}Continue(){return this.ContinueAsync(0),this.currentText}get canContinue(){return this.state.canContinue}get asyncContinueComplete(){return !this._asyncContinueActive}ContinueAsync(e){this._hasValidatedExternals||this.ValidateExternalBindings(),this.ContinueInternal(e);}ContinueInternal(e=0){this._profiler!=null&&this._profiler.PreContinue();let t=e>0;if(this._recursiveContinueCount++,this._asyncContinueActive)this._asyncContinueActive&&!t&&(this._asyncContinueActive=false);else {if(this._asyncContinueActive=t,!this.canContinue)throw new Error("Can't continue - should check canContinue before calling Continue");this._state.didSafeExit=false,this._state.ResetOutput(),this._recursiveContinueCount==1&&this._state.variablesState.StartVariableObservation();}let r=new i1.Stopwatch;r.Start();let i=false;this._sawLookaheadUnsafeFunctionAfterNewline=false;do{try{i=this.ContinueSingleStep();}catch(s){if(!(s instanceof er.StoryException))throw s;this.AddError(s.message,void 0,s.useEndLineNumber);break}if(i||this._asyncContinueActive&&r.ElapsedMilliseconds>e)break}while(this.canContinue);r.Stop();let a=null;if((i||!this.canContinue)&&(this._stateSnapshotAtLastNewline!==null&&this.RestoreStateSnapshot(),this.canContinue||(this.state.callStack.canPopThread&&this.AddError("Thread available to pop, threads should always be flat by the end of evaluation?"),this.state.generatedChoices.length==0&&!this.state.didSafeExit&&this._temporaryEvaluationContainer==null&&(this.state.callStack.CanPop(wt.PushPopType.Tunnel)?this.AddError("unexpectedly reached end of content. Do you need a '->->' to return from a tunnel?"):this.state.callStack.CanPop(wt.PushPopType.Function)?this.AddError("unexpectedly reached end of content. Do you need a '~ return'?"):this.state.callStack.canPop?this.AddError("unexpectedly reached end of content for unknown reason. Please debug compiler!"):this.AddError("ran out of content. Do you need a '-> DONE' or '-> END'?"))),this.state.didSafeExit=false,this._sawLookaheadUnsafeFunctionAfterNewline=false,this._recursiveContinueCount==1&&(a=this._state.variablesState.CompleteVariableObservation()),this._asyncContinueActive=false,this.onDidContinue!==null&&this.onDidContinue()),this._recursiveContinueCount--,this._profiler!=null&&this._profiler.PostContinue(),this.state.hasError||this.state.hasWarning)if(this.onError!==null){if(this.state.hasError)for(let s of this.state.currentErrors)this.onError(s,C0.ErrorType.Error);if(this.state.hasWarning)for(let s of this.state.currentWarnings)this.onError(s,C0.ErrorType.Warning);this.ResetErrors();}else {let s=new tr.StringBuilder;throw s.Append("Ink had "),this.state.hasError&&(s.Append(`${this.state.currentErrors.length}`),s.Append(this.state.currentErrors.length==1?" error":" errors"),this.state.hasWarning&&s.Append(" and ")),this.state.hasWarning&&(s.Append(`${this.state.currentWarnings.length}`),s.Append(this.state.currentWarnings.length==1?" warning":" warnings"),this.state.hasWarning&&s.Append(" and ")),s.Append(". It is strongly suggested that you assign an error handler to story.onError. The first issue was: "),s.Append(this.state.hasError?this.state.currentErrors[0]:this.state.currentWarnings[0]),new er.StoryException(s.toString())}a!=null&&Object.keys(a).length>0&&this._state.variablesState.NotifyObservers(a);}ContinueSingleStep(){if(this._profiler!=null&&this._profiler.PreStep(),this.Step(),this._profiler!=null&&this._profiler.PostStep(),!this.canContinue&&!this.state.callStack.elementIsEvaluateFromGame&&this.TryFollowDefaultInvisibleChoice(),this._profiler!=null&&this._profiler.PreSnapshot(),!this.state.inStringEvaluation){if(this._stateSnapshotAtLastNewline!==null){if(this._stateSnapshotAtLastNewline.currentTags===null)return (0, re.throwNullException)("this._stateAtLastNewline.currentTags");if(this.state.currentTags===null)return (0, re.throwNullException)("this.state.currentTags");let e=this.CalculateNewlineOutputStateChange(this._stateSnapshotAtLastNewline.currentText,this.state.currentText,this._stateSnapshotAtLastNewline.currentTags.length,this.state.currentTags.length);if(e==n.OutputStateChange.ExtendedBeyondNewline||this._sawLookaheadUnsafeFunctionAfterNewline)return this.RestoreStateSnapshot(),true;e==n.OutputStateChange.NewlineRemoved&&this.DiscardSnapshot();}this.state.outputStreamEndsInNewline&&(this.canContinue?this._stateSnapshotAtLastNewline==null&&this.StateSnapshot():this.DiscardSnapshot());}return this._profiler!=null&&this._profiler.PostSnapshot(),false}CalculateNewlineOutputStateChange(e,t,r,i){if(e===null)return (0, re.throwNullException)("prevText");if(t===null)return (0, re.throwNullException)("currText");let a=t.length>=e.length&&e.length>0&&t.charAt(e.length-1)==`
|
|
34
|
-
`;if(r==i&&e.length==t.length&&a)return n.OutputStateChange.NoChange;if(!a)return n.OutputStateChange.NewlineRemoved;if(i>r)return n.OutputStateChange.ExtendedBeyondNewline;for(let s=e.length;s<t.length;s++){let o=t.charAt(s);if(o!=" "&&o!=" ")return n.OutputStateChange.ExtendedBeyondNewline}return n.OutputStateChange.NoChange}ContinueMaximally(){this.IfAsyncWeCant("ContinueMaximally");let e=new tr.StringBuilder;for(;this.canContinue;)e.Append(this.Continue());return e.toString()}ContentAtPath(e){return this.mainContentContainer.ContentAtPath(e)}KnotContainerWithName(e){let t=this.mainContentContainer.namedContent.get(e);return t instanceof Be.Container?t:null}PointerAtPath(e){if(e.length==0)return An.Pointer.Null;let t=new An.Pointer,r=e.length,i=null;return e.lastComponent===null?(0, re.throwNullException)("path.lastComponent"):(e.lastComponent.isIndex?(r=e.length-1,i=this.mainContentContainer.ContentAtPath(e,void 0,r),t.container=i.container,t.index=e.lastComponent.index):(i=this.mainContentContainer.ContentAtPath(e),t.container=i.container,t.index=-1),i.obj==null||i.obj==this.mainContentContainer&&r>0?this.Error("Failed to find content at path '"+e+"', and no approximation of it was possible."):i.approximate&&this.Warning("Failed to find content at path '"+e+"', so it was approximated to: '"+i.obj.path+"'."),t)}StateSnapshot(){this._stateSnapshotAtLastNewline=this._state,this._state=this._state.CopyAndStartPatching(false);}RestoreStateSnapshot(){this._stateSnapshotAtLastNewline===null&&(0, re.throwNullException)("_stateSnapshotAtLastNewline"),this._stateSnapshotAtLastNewline.RestoreAfterPatch(),this._state=this._stateSnapshotAtLastNewline,this._stateSnapshotAtLastNewline=null,this._asyncSaving||this._state.ApplyAnyPatch();}DiscardSnapshot(){this._asyncSaving||this._state.ApplyAnyPatch(),this._stateSnapshotAtLastNewline=null;}CopyStateForBackgroundThreadSave(){if(this.IfAsyncWeCant("start saving on a background thread"),this._asyncSaving)throw new Error("Story is already in background saving mode, can't call CopyStateForBackgroundThreadSave again!");let e=this._state;return this._state=this._state.CopyAndStartPatching(true),this._asyncSaving=true,e}BackgroundSaveComplete(){this._stateSnapshotAtLastNewline===null&&this._state.ApplyAnyPatch(),this._asyncSaving=false;}Step(){let e=true,t=this.state.currentPointer.copy();if(t.isNull)return;let r=(0, G.asOrNull)(t.Resolve(),Be.Container);for(;r&&(this.VisitContainer(r,true),r.content.length!=0);)t=An.Pointer.StartOf(r),r=(0, G.asOrNull)(t.Resolve(),Be.Container);this.state.currentPointer=t.copy(),this._profiler!=null&&this._profiler.Step(this.state.callStack);let i=t.Resolve(),a=this.PerformLogicAndFlowControl(i);if(this.state.currentPointer.isNull)return;a&&(e=false);let s=(0, G.asOrNull)(i,ZT.ChoicePoint);if(s){let u=this.ProcessChoice(s);u&&this.state.generatedChoices.push(u),i=null,e=false;}if(i instanceof Be.Container&&(e=false),e){let u=(0, G.asOrNull)(i,I.VariablePointerValue);if(u&&u.contextIndex==-1){let l=this.state.callStack.ContextForVariableNamed(u.variableName);i=new I.VariablePointerValue(u.variableName,l);}this.state.inExpressionEvaluation?this.state.PushEvaluationStack(i):this.state.PushToOutputStream(i);}this.NextContent();let o=(0, G.asOrNull)(i,B.ControlCommand);o&&o.commandType==B.ControlCommand.CommandType.StartThread&&this.state.callStack.PushThread();}VisitContainer(e,t){(!e.countingAtStartOnly||t)&&(e.visitsShouldBeCounted&&this.state.IncrementVisitCountForContainer(e),e.turnIndexShouldBeCounted&&this.state.RecordTurnIndexVisitToContainer(e));}VisitChangedContainersDueToDivert(){let e=this.state.previousPointer.copy(),t=this.state.currentPointer.copy();if(t.isNull||t.index==-1)return;if(this._prevContainers.length=0,!e.isNull){let s=e.Resolve(),o=(0, G.asOrNull)(s,Be.Container)||(0, G.asOrNull)(e.container,Be.Container);for(;o;)this._prevContainers.push(o),o=(0, G.asOrNull)(o.parent,Be.Container);}let r=t.Resolve();if(r==null)return;let i=(0, G.asOrNull)(r.parent,Be.Container),a=true;for(;i&&(this._prevContainers.indexOf(i)<0||i.countingAtStartOnly);){let s=i.content.length>0&&r==i.content[0]&&a;s||(a=false),this.VisitContainer(i,s),r=i,i=(0, G.asOrNull)(i.parent,Be.Container);}}PopChoiceStringAndTags(e){let t=(0, G.asOrThrows)(this.state.PopEvaluationStack(),I.StringValue);for(;this.state.evaluationStack.length>0&&(0, G.asOrNull)(this.state.PeekEvaluationStack(),Su.Tag)!=null;){let r=(0, G.asOrNull)(this.state.PopEvaluationStack(),Su.Tag);r&&e.push(r.text);}return t.value}ProcessChoice(e){let t=true;if(e.hasCondition){let o=this.state.PopEvaluationStack();this.IsTruthy(o)||(t=false);}let r="",i="",a=[];if(e.hasChoiceOnlyContent&&(i=this.PopChoiceStringAndTags(a)||""),e.hasStartContent&&(r=this.PopChoiceStringAndTags(a)||""),e.onceOnly&&this.state.VisitCountForContainer(e.choiceTarget)>0&&(t=false),!t)return null;let s=new QT.Choice;return s.targetPath=e.pathOnChoice,s.sourcePath=e.path.toString(),s.isInvisibleDefault=e.isInvisibleDefault,s.threadAtGeneration=this.state.callStack.ForkThread(),s.tags=a.reverse(),s.text=(r+i).replace(/^[ \t]+|[ \t]+$/g,""),s}IsTruthy(e){let t=false;if(e instanceof I.Value){let r=e;if(r instanceof I.DivertTargetValue){let i=r;return this.Error("Shouldn't use a divert target (to "+i.targetPath+") as a conditional value. Did you intend a function call 'likeThis()' or a read count check 'likeThis'? (no arrows)"),false}return r.isTruthy}return t}PerformLogicAndFlowControl(e){if(e==null)return false;if(e instanceof y0.Divert){let t=e;if(t.isConditional){let r=this.state.PopEvaluationStack();if(!this.IsTruthy(r))return true}if(t.hasVariableTarget){let r=t.variableDivertName,i=this.state.variablesState.GetVariableWithName(r);if(i==null)this.Error("Tried to divert using a target from a variable that could not be found ("+r+")");else if(!(i instanceof I.DivertTargetValue)){let s=(0, G.asOrNull)(i,I.IntValue),o="Tried to divert to a target from a variable, but the variable ("+r+") didn't contain a divert target, it ";s instanceof I.IntValue&&s.value==0?o+="was empty/null (the value 0).":o+="contained '"+i+"'.",this.Error(o);}let a=(0, G.asOrThrows)(i,I.DivertTargetValue);this.state.divertedPointer=this.PointerAtPath(a.targetPath);}else {if(t.isExternal)return this.CallExternalFunction(t.targetPathString,t.externalArgs),true;this.state.divertedPointer=t.targetPointer.copy();}return t.pushesToStack&&this.state.callStack.Push(t.stackPushType,void 0,this.state.outputStream.length),this.state.divertedPointer.isNull&&!t.isExternal&&(t&&t.debugMetadata&&t.debugMetadata.sourceName!=null?this.Error("Divert target doesn't exist: "+t.debugMetadata.sourceName):this.Error("Divert resolution failed: "+t)),true}else if(e instanceof B.ControlCommand){let t=e;switch(t.commandType){case B.ControlCommand.CommandType.EvalStart:this.Assert(this.state.inExpressionEvaluation===false,"Already in expression evaluation?"),this.state.inExpressionEvaluation=true;break;case B.ControlCommand.CommandType.EvalEnd:this.Assert(this.state.inExpressionEvaluation===true,"Not in expression evaluation mode"),this.state.inExpressionEvaluation=false;break;case B.ControlCommand.CommandType.EvalOutput:if(this.state.evaluationStack.length>0){let m=this.state.PopEvaluationStack();if(!(m instanceof fs.Void)){let b=new I.StringValue(m.toString());this.state.PushToOutputStream(b);}}break;case B.ControlCommand.CommandType.NoOp:break;case B.ControlCommand.CommandType.Duplicate:this.state.PushEvaluationStack(this.state.PeekEvaluationStack());break;case B.ControlCommand.CommandType.PopEvaluatedValue:this.state.PopEvaluationStack();break;case B.ControlCommand.CommandType.PopFunction:case B.ControlCommand.CommandType.PopTunnel:let r=t.commandType==B.ControlCommand.CommandType.PopFunction?wt.PushPopType.Function:wt.PushPopType.Tunnel,i=null;if(r==wt.PushPopType.Tunnel){let m=this.state.PopEvaluationStack();i=(0, G.asOrNull)(m,I.DivertTargetValue),i===null&&this.Assert(m instanceof fs.Void,"Expected void if ->-> doesn't override target");}if(this.state.TryExitFunctionEvaluationFromGame())break;if(this.state.callStack.currentElement.type!=r||!this.state.callStack.canPop){let m=new Map;m.set(wt.PushPopType.Function,"function return statement (~ return)"),m.set(wt.PushPopType.Tunnel,"tunnel onwards statement (->->)");let b=m.get(this.state.callStack.currentElement.type);this.state.callStack.canPop||(b="end of flow (-> END or choice)");let w="Found "+m.get(r)+", when expected "+b;this.Error(w);}else this.state.PopCallStack(),i&&(this.state.divertedPointer=this.PointerAtPath(i.targetPath));break;case B.ControlCommand.CommandType.BeginString:this.state.PushToOutputStream(t),this.Assert(this.state.inExpressionEvaluation===true,"Expected to be in an expression when evaluating a string"),this.state.inExpressionEvaluation=false;break;case B.ControlCommand.CommandType.BeginTag:this.state.PushToOutputStream(t);break;case B.ControlCommand.CommandType.EndTag:{if(this.state.inStringEvaluation){let m=[],b=0;for(let O=this.state.outputStream.length-1;O>=0;--O){let k=this.state.outputStream[O];b++;let z=(0, G.asOrNull)(k,B.ControlCommand);if(z!=null){if(z.commandType==B.ControlCommand.CommandType.BeginTag)break;this.Error("Unexpected ControlCommand while extracting tag from choice");break}k instanceof I.StringValue&&m.push(k);}this.state.PopFromOutputStream(b);let w=new tr.StringBuilder;for(let O of m.reverse())w.Append(O.toString());let P=new Su.Tag(this.state.CleanOutputWhitespace(w.toString()));this.state.PushEvaluationStack(P);}else this.state.PushToOutputStream(t);break}case B.ControlCommand.CommandType.EndString:{let m=[],b=[],w=0;for(let O=this.state.outputStream.length-1;O>=0;--O){let k=this.state.outputStream[O];w++;let z=(0, G.asOrNull)(k,B.ControlCommand);if(z&&z.commandType==B.ControlCommand.CommandType.BeginString)break;k instanceof Su.Tag&&b.push(k),k instanceof I.StringValue&&m.push(k);}this.state.PopFromOutputStream(w);for(let O of b)this.state.PushToOutputStream(O);m=m.reverse();let P=new tr.StringBuilder;for(let O of m)P.Append(O.toString());this.state.inExpressionEvaluation=true,this.state.PushEvaluationStack(new I.StringValue(P.toString()));break}case B.ControlCommand.CommandType.ChoiceCount:let a=this.state.generatedChoices.length;this.state.PushEvaluationStack(new I.IntValue(a));break;case B.ControlCommand.CommandType.Turns:this.state.PushEvaluationStack(new I.IntValue(this.state.currentTurnIndex+1));break;case B.ControlCommand.CommandType.TurnsSince:case B.ControlCommand.CommandType.ReadCount:let s=this.state.PopEvaluationStack();if(!(s instanceof I.DivertTargetValue)){let m="";s instanceof I.IntValue&&(m=". Did you accidentally pass a read count ('knot_name') instead of a target ('-> knot_name')?"),this.Error("TURNS_SINCE / READ_COUNT expected a divert target (knot, stitch, label name), but saw "+s+m);break}let o=(0, G.asOrThrows)(s,I.DivertTargetValue),u=(0, G.asOrNull)(this.ContentAtPath(o.targetPath).correctObj,Be.Container),l;u!=null?t.commandType==B.ControlCommand.CommandType.TurnsSince?l=this.state.TurnsSinceForContainer(u):l=this.state.VisitCountForContainer(u):(t.commandType==B.ControlCommand.CommandType.TurnsSince?l=-1:l=0,this.Warning("Failed to find container for "+t.toString()+" lookup at "+o.targetPath.toString())),this.state.PushEvaluationStack(new I.IntValue(l));break;case B.ControlCommand.CommandType.Random:{let m=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue),b=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue);if(b==null||!(b instanceof I.IntValue))return this.Error("Invalid value for minimum parameter of RANDOM(min, max)");if(m==null||!(m instanceof I.IntValue))return this.Error("Invalid value for maximum parameter of RANDOM(min, max)");if(m.value===null)return (0, re.throwNullException)("maxInt.value");if(b.value===null)return (0, re.throwNullException)("minInt.value");let w=m.value-b.value+1;(!isFinite(w)||w>Number.MAX_SAFE_INTEGER)&&(w=Number.MAX_SAFE_INTEGER,this.Error("RANDOM was called with a range that exceeds the size that ink numbers can use.")),w<=0&&this.Error("RANDOM was called with minimum as "+b.value+" and maximum as "+m.value+". The maximum must be larger");let P=this.state.storySeed+this.state.previousRandom,k=new xf.PRNG(P).next(),z=k%w+b.value;this.state.PushEvaluationStack(new I.IntValue(z)),this.state.previousRandom=k;break}case B.ControlCommand.CommandType.SeedRandom:let c=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue);if(c==null||!(c instanceof I.IntValue))return this.Error("Invalid value passed to SEED_RANDOM");if(c.value===null)return (0, re.throwNullException)("minInt.value");this.state.storySeed=c.value,this.state.previousRandom=0,this.state.PushEvaluationStack(new fs.Void);break;case B.ControlCommand.CommandType.VisitIndex:let h=this.state.VisitCountForContainer(this.state.currentPointer.container)-1;this.state.PushEvaluationStack(new I.IntValue(h));break;case B.ControlCommand.CommandType.SequenceShuffleIndex:let p=this.NextSequenceShuffleIndex();this.state.PushEvaluationStack(new I.IntValue(p));break;case B.ControlCommand.CommandType.StartThread:break;case B.ControlCommand.CommandType.Done:this.state.callStack.canPopThread?this.state.callStack.PopThread():(this.state.didSafeExit=true,this.state.currentPointer=An.Pointer.Null);break;case B.ControlCommand.CommandType.End:this.state.ForceEnd();break;case B.ControlCommand.CommandType.ListFromInt:let f=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue),g=(0, G.asOrThrows)(this.state.PopEvaluationStack(),I.StringValue);if(f===null)throw new er.StoryException("Passed non-integer when creating a list element from a numerical value.");let y=null;if(this.listDefinitions===null)return (0, re.throwNullException)("this.listDefinitions");let C=this.listDefinitions.TryListGetDefinition(g.value,null);if(C.exists){if(f.value===null)return (0, re.throwNullException)("minInt.value");let m=C.result.TryGetItemWithValue(f.value,ps.InkListItem.Null);m.exists&&(y=new I.ListValue(m.result,f.value));}else throw new er.StoryException("Failed to find LIST called "+g.value);y==null&&(y=new I.ListValue),this.state.PushEvaluationStack(y);break;case B.ControlCommand.CommandType.ListRange:let _=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.Value),v=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.Value),d=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.ListValue);if(d===null||v===null||_===null)throw new er.StoryException("Expected list, minimum and maximum for LIST_RANGE");if(d.value===null)return (0, re.throwNullException)("targetList.value");let S=d.value.ListWithSubRange(v.valueObject,_.valueObject);this.state.PushEvaluationStack(new I.ListValue(S));break;case B.ControlCommand.CommandType.ListRandom:{let m=this.state.PopEvaluationStack();if(m===null)throw new er.StoryException("Expected list for LIST_RANDOM");let b=m.value,w=null;if(b===null)throw (0, re.throwNullException)("list");if(b.Count==0)w=new ps.InkList;else {let P=this.state.storySeed+this.state.previousRandom,k=new xf.PRNG(P).next(),z=k%b.Count,ie=b.entries();for(let Yr=0;Yr<=z-1;Yr++)ie.next();let ue=ie.next().value,an={Key:ps.InkListItem.fromSerializedKey(ue[0]),Value:ue[1]};if(an.Key.originName===null)return (0, re.throwNullException)("randomItem.Key.originName");w=new ps.InkList(an.Key.originName,this),w.Add(an.Key,an.Value),this.state.previousRandom=k;}this.state.PushEvaluationStack(new I.ListValue(w));break}default:this.Error("unhandled ControlCommand: "+t);break}return true}else if(e instanceof e1.VariableAssignment){let t=e,r=this.state.PopEvaluationStack();return this.state.variablesState.Assign(t,r),true}else if(e instanceof t1.VariableReference){let t=e,r=null;if(t.pathForCount!=null){let i=t.containerForCount,a=this.state.VisitCountForContainer(i);r=new I.IntValue(a);}else r=this.state.variablesState.GetVariableWithName(t.name),r==null&&(this.Warning("Variable not found: '"+t.name+"'. Using default value of 0 (false). This can happen with temporary variables if the declaration hasn't yet been hit. Globals are always given a default value on load if a value doesn't exist in the save state."),r=new I.IntValue(0));return this.state.PushEvaluationStack(r),true}else if(e instanceof n1.NativeFunctionCall){let t=e,r=this.state.PopEvaluationStack(t.numberOfParameters),i=t.Call(r);return this.state.PushEvaluationStack(i),true}return false}ChoosePathString(e,t=true,r=[]){if(this.IfAsyncWeCant("call ChoosePathString right now"),this.onChoosePathString!==null&&this.onChoosePathString(e,r),t)this.ResetCallstack();else if(this.state.callStack.currentElement.type==wt.PushPopType.Function){let i="",a=this.state.callStack.currentElement.currentPointer.container;throw a!=null&&(i="("+a.path.toString()+") "),new Error("Story was running a function "+i+"when you called ChoosePathString("+e+`) - this is almost certainly not not what you want! Full stack trace:
|
|
35
|
-
`+this.state.callStack.callStackTrace)}this.state.PassArgumentsToEvaluationStack(r),this.ChoosePath(new Of.Path(e));}IfAsyncWeCant(e){if(this._asyncContinueActive)throw new Error("Can't "+e+". Story is in the middle of a ContinueAsync(). Make more ContinueAsync() calls or a single Continue() call beforehand.")}ChoosePath(e,t=true){this.state.SetChosenPath(e,t),this.VisitChangedContainersDueToDivert();}ChooseChoiceIndex(e){e=e;let t=this.currentChoices;this.Assert(e>=0&&e<t.length,"choice out of range");let r=t[e];if(this.onMakeChoice!==null&&this.onMakeChoice(r),r.threadAtGeneration===null)return (0, re.throwNullException)("choiceToChoose.threadAtGeneration");if(r.targetPath===null)return (0, re.throwNullException)("choiceToChoose.targetPath");this.state.callStack.currentThread=r.threadAtGeneration,this.ChoosePath(r.targetPath);}HasFunction(e){try{return this.KnotContainerWithName(e)!=null}catch{return false}}EvaluateFunction(e,t=[],r=false){if(this.onEvaluateFunction!==null&&this.onEvaluateFunction(e,t),this.IfAsyncWeCant("evaluate a function"),e==null)throw new Error("Function is null");if(e==""||e.trim()=="")throw new Error("Function is empty or white space.");let i=this.KnotContainerWithName(e);if(i==null)throw new Error("Function doesn't exist: '"+e+"'");let a=[];a.push(...this.state.outputStream),this._state.ResetOutput(),this.state.StartFunctionEvaluationFromGame(i,t);let s=new tr.StringBuilder;for(;this.canContinue;)s.Append(this.Continue());let o=s.toString();this._state.ResetOutput(a);let u=this.state.CompleteFunctionEvaluationFromGame();return this.onCompleteEvaluateFunction!=null&&this.onCompleteEvaluateFunction(e,t,o,u),r?{returned:u,output:o}:u}EvaluateExpression(e){let t=this.state.callStack.elements.length;this.state.callStack.Push(wt.PushPopType.Tunnel),this._temporaryEvaluationContainer=e,this.state.GoToStart();let r=this.state.evaluationStack.length;return this.Continue(),this._temporaryEvaluationContainer=null,this.state.callStack.elements.length>t&&this.state.PopCallStack(),this.state.evaluationStack.length>r?this.state.PopEvaluationStack():null}CallExternalFunction(e,t){if(e===null)return (0, re.throwNullException)("funcName");let r=this._externals.get(e),i=null,a=typeof r<"u";if(a&&!r.lookAheadSafe&&this._state.inStringEvaluation&&this.Error("External function "+e+` could not be called because 1) it wasn't marked as lookaheadSafe when BindExternalFunction was called and 2) the story is in the middle of string generation, either because choice text is being generated, or because you have ink like "hello {func()}". You can work around this by generating the result of your function into a temporary variable before the string or choice gets generated: ~ temp x = `+e+"()"),a&&!r.lookAheadSafe&&this._stateSnapshotAtLastNewline!==null){this._sawLookaheadUnsafeFunctionAfterNewline=true;return}if(!a)if(this.allowExternalFunctionFallbacks){i=this.KnotContainerWithName(e),this.Assert(i!==null,"Trying to call EXTERNAL function '"+e+"' which has not been bound, and fallback ink function could not be found."),this.state.callStack.Push(wt.PushPopType.Function,void 0,this.state.outputStream.length),this.state.divertedPointer=An.Pointer.StartOf(i);return}else this.Assert(false,"Trying to call EXTERNAL function '"+e+"' which has not been bound (and ink fallbacks disabled).");let s=[];for(let l=0;l<t;++l){let h=(0, G.asOrThrows)(this.state.PopEvaluationStack(),I.Value).valueObject;s.push(h);}s.reverse();let o=r.function(s),u=null;o!=null?(u=I.Value.Create(o),this.Assert(u!==null,"Could not create ink value from returned object of type "+typeof o)):u=new fs.Void,this.state.PushEvaluationStack(u);}BindExternalFunctionGeneral(e,t,r=true){this.IfAsyncWeCant("bind an external function"),this.Assert(!this._externals.has(e),"Function '"+e+"' has already been bound."),this._externals.set(e,{function:t,lookAheadSafe:r});}TryCoerce(e){return e}BindExternalFunction(e,t,r=false){this.Assert(t!=null,"Can't bind a null function"),this.BindExternalFunctionGeneral(e,i=>{this.Assert(i.length>=t.length,"External function expected "+t.length+" arguments");let a=[];for(let s=0,o=i.length;s<o;s++)a[s]=this.TryCoerce(i[s]);return t.apply(null,a)},r);}UnbindExternalFunction(e){this.IfAsyncWeCant("unbind an external a function"),this.Assert(this._externals.has(e),"Function '"+e+"' has not been bound."),this._externals.delete(e);}ValidateExternalBindings(){let e=null,t=null,r=arguments[1]||new Set;if(arguments[0]instanceof Be.Container&&(e=arguments[0]),arguments[0]instanceof Af.InkObject&&(t=arguments[0]),e===null&&t===null)if(this.ValidateExternalBindings(this._mainContentContainer,r),this._hasValidatedExternals=true,r.size==0)this._hasValidatedExternals=true;else {let i="Error: Missing function binding for external";i+=r.size>1?"s":"",i+=": '",i+=Array.from(r).join("', '"),i+="' ",i+=this.allowExternalFunctionFallbacks?", and no fallback ink function found.":" (ink fallbacks disabled)",this.Error(i);}else if(e!=null){for(let i of e.content){let a=i;(a==null||!a.hasValidName)&&this.ValidateExternalBindings(i,r);}for(let[,i]of e.namedContent)this.ValidateExternalBindings((0, G.asOrNull)(i,Af.InkObject),r);}else if(t!=null){let i=(0, G.asOrNull)(t,y0.Divert);if(i&&i.isExternal){let a=i.targetPathString;if(a===null)return (0, re.throwNullException)("name");this._externals.has(a)||this.allowExternalFunctionFallbacks&&this.mainContentContainer.namedContent.has(a)||r.add(a);}}}ObserveVariable(e,t){if(this.IfAsyncWeCant("observe a new variable"),this._variableObservers===null&&(this._variableObservers=new Map),!this.state.variablesState.GlobalVariableExistsWithName(e))throw new Error("Cannot observe variable '"+e+"' because it wasn't declared in the ink story.");this._variableObservers.has(e)?this._variableObservers.get(e).push(t):this._variableObservers.set(e,[t]);}ObserveVariables(e,t){for(let r=0,i=e.length;r<i;r++)this.ObserveVariable(e[r],t[r]);}RemoveVariableObserver(e,t){if(this.IfAsyncWeCant("remove a variable observer"),this._variableObservers!==null){if(t!=null){if(this._variableObservers.has(t))if(e!=null){let r=this._variableObservers.get(t);r!=null&&(r.splice(r.indexOf(e),1),r.length===0&&this._variableObservers.delete(t));}else this._variableObservers.delete(t);}else if(e!=null){let r=this._variableObservers.keys();for(let i of r){let a=this._variableObservers.get(i);a!=null&&(a.splice(a.indexOf(e),1),a.length===0&&this._variableObservers.delete(i));}}}}VariableStateDidChangeEvent(e,t){if(this._variableObservers===null)return;let r=this._variableObservers.get(e);if(typeof r<"u"){if(!(t instanceof I.Value))throw new Error("Tried to get the value of a variable that isn't a standard type");let i=(0, G.asOrThrows)(t,I.Value);for(let a of r)a(e,i.valueObject);}}get globalTags(){return this.TagsAtStartOfFlowContainerWithPathString("")}TagsForContentAtPath(e){return this.TagsAtStartOfFlowContainerWithPathString(e)}TagsAtStartOfFlowContainerWithPathString(e){let t=new Of.Path(e),r=this.ContentAtPath(t).container;if(r===null)return (0, re.throwNullException)("flowContainer");for(;;){let s=r.content[0];if(s instanceof Be.Container)r=s;else break}let i=false,a=null;for(let s of r.content){let o=(0, G.asOrNull)(s,B.ControlCommand);if(o!=null)o.commandType==B.ControlCommand.CommandType.BeginTag?i=true:o.commandType==B.ControlCommand.CommandType.EndTag&&(i=false);else if(i){let u=(0, G.asOrNull)(s,I.StringValue);u!==null?(a===null&&(a=[]),u.value!==null&&a.push(u.value)):this.Error("Tag contained non-text content. Only plain text is allowed when using globalTags or TagsAtContentPath. If you want to evaluate dynamic content, you need to use story.Continue().");}else break}return a}BuildStringOfHierarchy(){let e=new tr.StringBuilder;return this.mainContentContainer.BuildStringOfHierarchy(e,0,this.state.currentPointer.Resolve()),e.toString()}BuildStringOfContainer(e){let t=new tr.StringBuilder;return e.BuildStringOfHierarchy(t,0,this.state.currentPointer.Resolve()),t.toString()}NextContent(){if(this.state.previousPointer=this.state.currentPointer.copy(),!this.state.divertedPointer.isNull&&(this.state.currentPointer=this.state.divertedPointer.copy(),this.state.divertedPointer=An.Pointer.Null,this.VisitChangedContainersDueToDivert(),!this.state.currentPointer.isNull))return;if(!this.IncrementContentPointer()){let t=false;this.state.callStack.CanPop(wt.PushPopType.Function)?(this.state.PopCallStack(wt.PushPopType.Function),this.state.inExpressionEvaluation&&this.state.PushEvaluationStack(new fs.Void),t=true):this.state.callStack.canPopThread?(this.state.callStack.PopThread(),t=true):this.state.TryExitFunctionEvaluationFromGame(),t&&!this.state.currentPointer.isNull&&this.NextContent();}}IncrementContentPointer(){let e=true,t=this.state.callStack.currentElement.currentPointer.copy();if(t.index++,t.container===null)return (0, re.throwNullException)("pointer.container");for(;t.index>=t.container.content.length;){e=false;let r=(0, G.asOrNull)(t.container.parent,Be.Container);if(!(r instanceof Be.Container))break;let i=r.content.indexOf(t.container);if(i==-1)break;if(t=new An.Pointer(r,i),t.index++,e=true,t.container===null)return (0, re.throwNullException)("pointer.container")}return e||(t=An.Pointer.Null),this.state.callStack.currentElement.currentPointer=t.copy(),e}TryFollowDefaultInvisibleChoice(){let e=this._state.currentChoices,t=e.filter(i=>i.isInvisibleDefault);if(t.length==0||e.length>t.length)return false;let r=t[0];return r.targetPath===null?(0, re.throwNullException)("choice.targetPath"):r.threadAtGeneration===null?(0, re.throwNullException)("choice.threadAtGeneration"):(this.state.callStack.currentThread=r.threadAtGeneration,this._stateSnapshotAtLastNewline!==null&&(this.state.callStack.currentThread=this.state.callStack.ForkThread()),this.ChoosePath(r.targetPath,false),true)}NextSequenceShuffleIndex(){let e=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue);if(!(e instanceof I.IntValue))return this.Error("expected number of elements in sequence for shuffle index"),0;let t=this.state.currentPointer.container;if(t===null)return (0, re.throwNullException)("seqContainer");if(e.value===null)return (0, re.throwNullException)("numElementsIntVal.value");let r=e.value,a=(0, G.asOrThrows)(this.state.PopEvaluationStack(),I.IntValue).value;if(a===null)return (0, re.throwNullException)("seqCount");let s=a/r,o=a%r,u=t.path.toString(),l=0;for(let f=0,g=u.length;f<g;f++)l+=u.charCodeAt(f)||0;let c=l+s+this.state.storySeed,h=new xf.PRNG(Math.floor(c)),p=[];for(let f=0;f<r;++f)p.push(f);for(let f=0;f<=o;++f){let g=h.next()%p.length,y=p[g];if(p.splice(g,1),f==o)return y}throw new Error("Should never reach here")}Error(e,t=false){let r=new er.StoryException(e);throw r.useEndLineNumber=t,r}Warning(e){this.AddError(e,true);}AddError(e,t=false,r=false){let i=this.currentDebugMetadata,a=t?"WARNING":"ERROR";if(i!=null){let s=r?i.endLineNumber:i.startLineNumber;e="RUNTIME "+a+": '"+i.fileName+"' line "+s+": "+e;}else this.state.currentPointer.isNull?e="RUNTIME "+a+": "+e:e="RUNTIME "+a+": ("+this.state.currentPointer+"): "+e;this.state.AddError(e,t),t||this.state.ForceEnd();}Assert(e,t=null){if(e==false)throw t==null&&(t="Story assert"),new Error(t+" "+this.currentDebugMetadata)}get currentDebugMetadata(){let e,t=this.state.currentPointer;if(!t.isNull&&t.Resolve()!==null&&(e=t.Resolve().debugMetadata,e!==null))return e;for(let r=this.state.callStack.elements.length-1;r>=0;--r)if(t=this.state.callStack.elements[r].currentPointer,!t.isNull&&t.Resolve()!==null&&(e=t.Resolve().debugMetadata,e!==null))return e;for(let r=this.state.outputStream.length-1;r>=0;--r)if(e=this.state.outputStream[r].debugMetadata,e!==null)return e;return null}get mainContentContainer(){return this._temporaryEvaluationContainer?this._temporaryEvaluationContainer:this._mainContentContainer}};nr.Story=Jr;Jr.inkVersionCurrent=21;(function(n){(function(t){t[t.NoChange=0]="NoChange",t[t.ExtendedBeyondNewline=1]="ExtendedBeyondNewline",t[t.NewlineRemoved=2]="NewlineRemoved";})(n.OutputStateChange||(n.OutputStateChange={}));})(Jr||(nr.Story=Jr={}));});var _0=E(Pu=>{Object.defineProperty(Pu,"__esModule",{value:true});Pu.Story=void 0;var a1=Ca(),o1=io(),Eu=Ee(),wu=Le(),ms=Ar(),Du=Gt(),b0=$r(),u1=Xd(),l1=Vo(),c1=nf(),h1=us(),Hr=nn(),d1=Sn(),f1=bn(),gs=ae(),p1=Qi(),m1=es(),g1=Yn(),Au=class n extends Du.FlowBase{get flowLevel(){return b0.FlowLevel.Story}get hadError(){return this._hadError}get hadWarning(){return this._hadWarning}constructor(e,t=false){super(null,e,null,false,t),this._errorHandler=null,this._hadError=false,this._hadWarning=false,this._dontFlattenContainers=new Set,this._listDefs=new Map,this.constants=new Map,this.externals=new Map,this.countAllVisits=false,this.ExportRuntime=(r=null)=>{var i,a;this._errorHandler=r,this.constants=new Map;for(let c of this.FindAll(o1.ConstantDeclaration)()){let h=this.constants.get(c.constantName);if(h&&!h.Equals(c.expression)){let p=`CONST '${c.constantName}' has been redefined with a different value. Multiple definitions of the same CONST are valid so long as they contain the same value. Initial definition was on ${h.debugMetadata}.`;this.Error(p,c,false);}this.constants.set(c.constantName,c.expression);}this._listDefs=new Map;for(let c of this.FindAll(l1.ListDefinition)())!((i=c.identifier)===null||i===void 0)&&i.name&&this._listDefs.set((a=c.identifier)===null||a===void 0?void 0:a.name,c);this.externals=new Map,this.ResolveWeavePointNaming();let s=this.runtimeObject,o=new Eu.Container;o.AddContent(wu.ControlCommand.EvalStart());let u=[];for(let[c,h]of this.variableDeclarations)if(h.isGlobalDeclaration){if(h.listDefinition)this._listDefs.set(c,h.listDefinition),o.AddContent(h.listDefinition.runtimeObject),u.push(h.listDefinition.runtimeListDefinition);else {if(!h.expression)throw new Error;h.expression.GenerateIntoContainer(o);}let p=new f1.VariableAssignment(c,true);p.isGlobal=true,o.AddContent(p);}o.AddContent(wu.ControlCommand.EvalEnd()),o.AddContent(wu.ControlCommand.End()),this.variableDeclarations.size>0&&(o.name="global decl",s.AddToNamedContentOnly(o)),s.AddContent(wu.ControlCommand.Done());let l=new h1.Story(s,u);return this.runtimeObject=l,this.hadError||(this.FlattenContainersIn(s),this.ResolveReferences(this),this.hadError)?null:(l.ResetState(),l)},this.ResolveList=r=>{let i=this._listDefs.get(r);return i||null},this.ResolveListItem=(r,i,a=null)=>{let s=null;if(r)return (s=this._listDefs.get(r))?s.ItemNamed(i):null;{let o=null,u=null;for(let[,l]of this._listDefs.entries()){let c=l.ItemNamed(i);c&&(o?this.Error(`Ambiguous item name '${i}' found in multiple sets, including ${u.identifier} and ${l.identifier}`,a,false):(o=c,u=l));}return o}},this.FlattenContainersIn=r=>{let i=new Set;if(r.content)for(let a of r.content){let s=(0, gs.asOrNull)(a,Eu.Container);s&&i.add(s);}if(r.namedContent)for(let[,a]of r.namedContent){let s=(0, gs.asOrNull)(a,Eu.Container);s&&i.add(s);}for(let a of i)this.TryFlattenContainer(a),this.FlattenContainersIn(a);},this.TryFlattenContainer=r=>{if(r.namedContent&&r.namedContent.size>0||r.hasValidName||this._dontFlattenContainers.has(r))return;let i=(0, gs.asOrNull)(r.parent,Eu.Container);if(i){let a=i.content.indexOf(r);i.content.splice(a,1);let s=r.ownDebugMetadata;if(r.content)for(let o of r.content)o.parent=null,s!==null&&o.ownDebugMetadata===null&&(o.debugMetadata=s),i.InsertContent(o,a),a+=1;}},this.Error=(r,i,a)=>{let s=a?ms.ErrorType.Warning:ms.ErrorType.Error,o="";if(i instanceof a1.AuthorWarning?(o+="TODO: ",s=ms.ErrorType.Author):a?o+="WARNING: ":o+="ERROR: ",i&&i.debugMetadata!==null&&i.debugMetadata.startLineNumber>=1&&(i.debugMetadata.fileName!=null&&(o+=`'${i.debugMetadata.fileName}' `),o+=`line ${i.debugMetadata.startLineNumber}: `),o+=r,r=o,this._errorHandler!==null)this._errorHandler(r,s);else throw new Error(r);this._hadError=s===ms.ErrorType.Error,this._hadWarning=s===ms.ErrorType.Warning;},this.ResetError=()=>{this._hadError=false,this._hadWarning=false;},this.IsExternal=r=>this.externals.has(r),this.AddExternal=r=>{this.externals.has(r.name)?this.Error(`Duplicate EXTERNAL definition of '${r.name}'`,r,false):r.name&&this.externals.set(r.name,r);},this.DontFlattenContainer=r=>{this._dontFlattenContainers.add(r);},this.NameConflictError=(r,i,a,s)=>{r.Error(`${s} '${i}': name has already been used for a ${a.typeName.toLowerCase()} on ${a.debugMetadata}`);},this.CheckForNamingCollisions=(r,i,a,s="")=>{var o;let u=s||r.typeName;if(n.IsReservedKeyword(i?.name)){r.Error(`'${i}' cannot be used for the name of a ${u.toLowerCase()} because it's a reserved keyword`);return}else if(m1.FunctionCall.IsBuiltIn(i?.name||"")){r.Error(`'${i}' cannot be used for the name of a ${u.toLowerCase()} because it's a built in function`);return}let l=this.ContentWithNameAtLevel(i?.name||"",b0.FlowLevel.Knot),c=(0, gs.asOrNull)(l,Du.FlowBase);if(c&&(c!==r||a===Hr.SymbolType.Arg)){this.NameConflictError(r,i?.name||"",c,u);return}if(a<Hr.SymbolType.List)return;for(let[g,y]of this._listDefs)if(i?.name===g&&r!==y&&y.variableAssignment!==r&&this.NameConflictError(r,i?.name,y,u),!(r instanceof c1.ListElementDefinition))for(let C of y.itemDefinitions)i?.name===C.name&&this.NameConflictError(r,i?.name||"",C,u);if(a<=Hr.SymbolType.Var)return;let h=i?.name&&this.variableDeclarations.get(i?.name)||null;if(h&&h!==r&&h.isGlobalDeclaration&&h.listDefinition==null&&this.NameConflictError(r,i?.name||"",h,u),a<Hr.SymbolType.SubFlowAndWeave)return;let f=new g1.Path(i).ResolveFromContext(r);if(f&&f!==r){this.NameConflictError(r,i?.name||"",f,u);return}if(!(a<Hr.SymbolType.Arg)&&a!==Hr.SymbolType.Arg){let g=(0, gs.asOrNull)(r,Du.FlowBase);if(g||(g=(0, p1.ClosestFlowBase)(r)),g&&g.hasParameters&&g.args){for(let y of g.args)if(((o=y.identifier)===null||o===void 0?void 0:o.name)===i?.name){r.Error(`${u} '${i}': name has already been used for a argument to ${g.identifier} on ${g.debugMetadata}`);return}}}};}get typeName(){return "Story"}PreProcessTopLevelObjects(e){super.PreProcessTopLevelObjects(e);let t=[];for(let r of e)if(r instanceof u1.IncludedFile){let i=r,a=e.indexOf(r);if(e.splice(a,1),i.includedStory){let s=[],o=i.includedStory;if(o.content!=null){for(let u of o.content)u instanceof Du.FlowBase?t.push(u):s.push(u);s.push(new d1.Text(`
|
|
36
|
-
`)),e.splice(a,0,...s);}}continue}e.splice(0,0,...t);}};
|
|
37
|
-
\r`);return o?new
|
|
38
|
-
`));let
|
|
39
|
-
`)),this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),s)},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 o=this.Interleave(this.Optional(this.ContentText),this.Optional(this.InlineLogicOrGlueOrStartTag));if(!this._parsingChoice){let u=this.Parse(this.MultiDivert);u!==null&&(o===null&&(o=[]),this.EndTagIfNecessary(o),this.TrimEndWhitespace(o,true),o.push(...u));}return o||null},this.ContentText=()=>this.ContentTextAllowingEscapeChar(),this.ContentTextAllowingEscapeChar=()=>{let s=null;do{let o=this.Parse(this.ContentTextNoEscape),u=this.ParseString("\\")!==null;if(u||o!==null){if(s===null&&(s=""),o!==null&&(s+=String(o)),u){let l=this.ParseSingleCharacter();s+=l;}}else break}while(true);return s!==null?new
|
|
40
|
-
\r\\#`),this._notTextEndCharactersChoice=new
|
|
31
|
+
`)a==-1&&(a=c),s=c;else {if(h==" "||h==" ")continue;break}}if(r==-1&&a==-1)return null;let o=[],u=0,l=t.length;if(r!=-1){if(r>0){let c=new xe.StringValue(t.substring(0,r));o.push(c);}o.push(new xe.StringValue(`
|
|
32
|
+
`)),u=i+1;}if(a!=-1&&(l=s),l>u){let c=t.substring(u,l);o.push(new xe.StringValue(c));}if(a!=-1&&s>i&&(o.push(new xe.StringValue(`
|
|
33
|
+
`)),a<t.length-1)){let c=t.length-a-1,h=new xe.StringValue(t.substring(a+1,a+1+c));o.push(h);}return o}PushToOutputStreamIndividual(e){let t=(0, Ae.asOrNull)(e,wp.Glue),r=(0, Ae.asOrNull)(e,xe.StringValue),i=true;if(t)this.TrimNewlinesFromOutputStream(),i=true;else if(r){let a=-1,s=this.callStack.currentElement;s.type==An.PushPopType.Function&&(a=s.functionStartInOutputStream);let o=-1;for(let l=this.outputStream.length-1;l>=0;l--){let c=this.outputStream[l],h=c instanceof Xe.ControlCommand?c:null;if((c instanceof wp.Glue?c:null)!=null){o=l;break}else if(h!=null&&h.commandType==Xe.ControlCommand.CommandType.BeginString){l>=a&&(a=-1);break}}let u=-1;if(o!=-1&&a!=-1?u=Math.min(a,o):o!=-1?u=o:u=a,u!=-1){if(r.isNewline)i=false;else if(r.isNonWhitespace&&(o>-1&&this.RemoveExistingGlue(),a>-1)){let l=this.callStack.elements;for(let c=l.length-1;c>=0;c--){let h=l[c];if(h.type==An.PushPopType.Function)h.functionStartInOutputStream=-1;else break}}}else r.isNewline&&(this.outputStreamEndsInNewline||!this.outputStreamContainsContent)&&(i=false);}if(i){if(e===null)return (0, Dt.throwNullException)("obj");this.outputStream.push(e),this.OutputStreamDirty();}}TrimNewlinesFromOutputStream(){let e=-1,t=this.outputStream.length-1;for(;t>=0;){let r=this.outputStream[t],i=(0, Ae.asOrNull)(r,Xe.ControlCommand),a=(0, Ae.asOrNull)(r,xe.StringValue);if(i!=null||a!=null&&a.isNonWhitespace)break;a!=null&&a.isNewline&&(e=t),t--;}if(e>=0)for(t=e;t<this.outputStream.length;)(0, Ae.asOrNull)(this.outputStream[t],xe.StringValue)?this.outputStream.splice(t,1):t++;this.OutputStreamDirty();}RemoveExistingGlue(){for(let e=this.outputStream.length-1;e>=0;e--){let t=this.outputStream[e];if(t instanceof wp.Glue)this.outputStream.splice(e,1);else if(t instanceof Xe.ControlCommand)break}this.OutputStreamDirty();}get outputStreamEndsInNewline(){if(this.outputStream.length>0)for(let e=this.outputStream.length-1;e>=0&&!(this.outputStream[e]instanceof Xe.ControlCommand);e--){let r=this.outputStream[e];if(r instanceof xe.StringValue){if(r.isNewline)return true;if(r.isNonWhitespace)break}}return false}get outputStreamContainsContent(){for(let e of this.outputStream)if(e instanceof xe.StringValue)return true;return false}get inStringEvaluation(){for(let e=this.outputStream.length-1;e>=0;e--){let t=(0, Ae.asOrNull)(this.outputStream[e],Xe.ControlCommand);if(t instanceof Xe.ControlCommand&&t.commandType==Xe.ControlCommand.CommandType.BeginString)return true}return false}PushEvaluationStack(e){let t=(0, Ae.asOrNull)(e,xe.ListValue);if(t){let r=t.value;if(r===null)return (0, Dt.throwNullException)("rawList");if(r.originNames!=null){r.origins||(r.origins=[]),r.origins.length=0;for(let i of r.originNames){if(this.story.listDefinitions===null)return (0, Dt.throwNullException)("StoryState.story.listDefinitions");let a=this.story.listDefinitions.TryListGetDefinition(i,null);if(a.result===null)return (0, Dt.throwNullException)("StoryState def.result");r.origins.indexOf(a.result)<0&&r.origins.push(a.result);}}}if(e===null)return (0, Dt.throwNullException)("obj");this.evaluationStack.push(e);}PopEvaluationStack(e){if(typeof e>"u"){let t=this.evaluationStack.pop();return (0, Ae.nullIfUndefined)(t)}else {if(e>this.evaluationStack.length)throw new Error("trying to pop too many objects");let t=this.evaluationStack.splice(this.evaluationStack.length-e,e);return (0, Ae.nullIfUndefined)(t)}}PeekEvaluationStack(){return this.evaluationStack[this.evaluationStack.length-1]}ForceEnd(){this.callStack.Reset(),this._currentFlow.currentChoices.length=0,this.currentPointer=Hr.Pointer.Null,this.previousPointer=Hr.Pointer.Null,this.didSafeExit=true;}TrimWhitespaceFromFunctionEnd(){BT.Debug.Assert(this.callStack.currentElement.type==An.PushPopType.Function);let e=this.callStack.currentElement.functionStartInOutputStream;e==-1&&(e=0);for(let t=this.outputStream.length-1;t>=e;t--){let r=this.outputStream[t],i=(0, Ae.asOrNull)(r,xe.StringValue),a=(0, Ae.asOrNull)(r,Xe.ControlCommand);if(i!=null){if(a)break;if(i.isNewline||i.isInlineWhitespace)this.outputStream.splice(t,1),this.OutputStreamDirty();else break}}}PopCallStack(e=null){this.callStack.currentElement.type==An.PushPopType.Function&&this.TrimWhitespaceFromFunctionEnd(),this.callStack.Pop(e);}SetChosenPath(e,t){this._currentFlow.currentChoices.length=0;let r=this.story.PointerAtPath(e);!r.isNull&&r.index==-1&&(r.index=0),this.currentPointer=r,t&&this.currentTurnIndex++;}StartFunctionEvaluationFromGame(e,t){this.callStack.Push(An.PushPopType.FunctionEvaluationFromGame,this.evaluationStack.length),this.callStack.currentElement.currentPointer=Hr.Pointer.StartOf(e),this.PassArgumentsToEvaluationStack(t);}PassArgumentsToEvaluationStack(e){if(e!==null)for(let t=0;t<e.length;t++){if(!(typeof e[t]=="number"||typeof e[t]=="string"||typeof e[t]=="boolean"||e[t]instanceof GT.InkList))throw new Error("ink arguments when calling EvaluateFunction / ChoosePathStringWithParameters must benumber, string, bool or InkList. Argument was "+((0, Ae.nullIfUndefined)(e[t])===null?"null":e[t].constructor.name));this.PushEvaluationStack(xe.Value.Create(e[t]));}}TryExitFunctionEvaluationFromGame(){return this.callStack.currentElement.type==An.PushPopType.FunctionEvaluationFromGame?(this.currentPointer=Hr.Pointer.Null,this.didSafeExit=true,true):false}CompleteFunctionEvaluationFromGame(){if(this.callStack.currentElement.type!=An.PushPopType.FunctionEvaluationFromGame)throw new Error("Expected external function evaluation to be complete. Stack trace: "+this.callStack.callStackTrace);let e=this.callStack.currentElement.evaluationStackHeightWhenPushed,t=null;for(;this.evaluationStack.length>e;){let r=this.PopEvaluationStack();t===null&&(t=r);}if(this.PopCallStack(An.PushPopType.FunctionEvaluationFromGame),t){if(t instanceof qT.Void)return null;let r=(0, Ae.asOrThrows)(t,xe.Value);return r.valueType==xe.ValueType.DivertTarget?"-> "+r.valueObject.toString():r.valueObject}return null}AddError(e,t){t?(this._currentWarnings==null&&(this._currentWarnings=[]),this._currentWarnings.push(e)):(this._currentErrors==null&&(this._currentErrors=[]),this._currentErrors.push(e));}OutputStreamDirty(){this._outputStreamTextDirty=true,this._outputStreamTagsDirty=true;}};Su.StoryState=Dp;});var gb=w(_u=>{Object.defineProperty(_u,"__esModule",{value:true});_u.Stopwatch=void 0;var Ap=class{constructor(){this.startTime=void 0;}get ElapsedMilliseconds(){return typeof this.startTime>"u"?0:new Date().getTime()-this.startTime}Start(){this.startTime=new Date().getTime();}Stop(){this.startTime=void 0;}};_u.Stopwatch=Ap;});var vb=w(wu=>{Object.defineProperty(wu,"__esModule",{value:true});wu.ErrorType=void 0;var yb;(function(n){n[n.Author=0]="Author",n[n.Warning=1]="Warning",n[n.Error=2]="Error";})(yb||(wu.ErrorType=yb={}));});var cs=w(ir=>{Object.defineProperty(ir,"__esModule",{value:true});ir.Story=ir.InkList=void 0;var Me=Ee(),Op=ot(),Pp=Jr(),zT=mb(),B=Be(),At=Yn(),JT=Ma(),HT=cp(),bb=zt(),I=be(),xp=at(),ms=Xn(),Eu=ou(),UT=_n(),KT=Mr(),XT=Gt(),nr=Bi(),Tp=bp(),rr=Un(),YT=dp(),ZT=gb(),Pn=Zi(),gs=lt(),G=oe(),ie=qe(),Cb=Sp(),Sb=vb(),QT=lt();Object.defineProperty(ir,"InkList",{enumerable:true,get:function(){return QT.InkList}});Number.isInteger||(Number.isInteger=function(e){return typeof e=="number"&&isFinite(e)&&e>-9007199254740992&&e<9007199254740992&&Math.floor(e)===e});var Ur=class n extends Op.InkObject{get currentChoices(){let e=[];if(this._state===null)return (0, ie.throwNullException)("this._state");for(let t of this._state.currentChoices)t.isInvisibleDefault||(t.index=e.length,e.push(t));return e}get currentText(){return this.IfAsyncWeCant("call currentText since it's a work in progress"),this.state.currentText}get currentTags(){return this.IfAsyncWeCant("call currentTags since it's a work in progress"),this.state.currentTags}get currentErrors(){return this.state.currentErrors}get currentWarnings(){return this.state.currentWarnings}get currentFlowName(){return this.state.currentFlowName}get currentFlowIsDefaultFlow(){return this.state.currentFlowIsDefaultFlow}get aliveFlowNames(){return this.state.aliveFlowNames}get hasError(){return this.state.hasError}get hasWarning(){return this.state.hasWarning}get variablesState(){return this.state.variablesState}get listDefinitions(){return this._listDefinitions}get state(){return this._state}StartProfiling(){}EndProfiling(){}constructor(){super(),this.inkVersionMinimumCompatible=18,this.onError=null,this.onDidContinue=null,this.onMakeChoice=null,this.onEvaluateFunction=null,this.onCompleteEvaluateFunction=null,this.onChoosePathString=null,this._prevContainers=[],this.allowExternalFunctionFallbacks=false,this._listDefinitions=null,this._variableObservers=null,this._hasValidatedExternals=false,this._temporaryEvaluationContainer=null,this._asyncContinueActive=false,this._stateSnapshotAtLastNewline=null,this._sawLookaheadUnsafeFunctionAfterNewline=false,this._recursiveContinueCount=0,this._asyncSaving=false,this._profiler=null;let e,t=null,r=null;if(arguments[0]instanceof Me.Container)e=arguments[0],typeof arguments[1]<"u"&&(t=arguments[1]),this._mainContentContainer=e;else if(typeof arguments[0]=="string"){let i=arguments[0];r=Cb.SimpleJson.TextToDictionary(i);}else r=arguments[0];if(t!=null&&(this._listDefinitions=new YT.ListDefinitionsOrigin(t)),this._externals=new Map,r!==null){let i=r,a=i.inkVersion;if(a==null)throw new Error("ink version number not found. Are you sure it's a valid .ink.json file?");let s=parseInt(a);if(s>n.inkVersionCurrent)throw new Error("Version of ink used to build story was newer than the current version of the engine");if(s<this.inkVersionMinimumCompatible)throw new Error("Version of ink used to build story is too old to be loaded by this version of the engine");s!=n.inkVersionCurrent&&console.warn(`WARNING: Version of ink ${n.inkVersionCurrent} used to build story doesn't match current version of engine (${s}). Non-critical, but recommend synchronising.`);let o=i.root;if(o==null)throw new Error("Root node for ink not found. Are you sure it's a valid .ink.json file?");let u;(u=i.listDefs)&&(this._listDefinitions=Pp.JsonSerialisation.JTokenToListDefinitions(u)),this._mainContentContainer=(0, G.asOrThrows)(Pp.JsonSerialisation.JTokenToRuntimeObject(o),Me.Container),this.ResetState();}}ToJson(e){let t=false;if(e||(t=true,e=new Cb.SimpleJson.Writer),e.WriteObjectStart(),e.WriteIntProperty("inkVersion",n.inkVersionCurrent),e.WriteProperty("root",r=>Pp.JsonSerialisation.WriteRuntimeContainer(r,this._mainContentContainer)),this._listDefinitions!=null){e.WritePropertyStart("listDefs"),e.WriteObjectStart();for(let r of this._listDefinitions.lists){e.WritePropertyStart(r.name),e.WriteObjectStart();for(let[i,a]of r.items){let s=gs.InkListItem.fromSerializedKey(i),o=a;e.WriteIntProperty(s.itemName,o);}e.WriteObjectEnd(),e.WritePropertyEnd();}e.WriteObjectEnd(),e.WritePropertyEnd();}if(e.WriteObjectEnd(),t)return e.toString()}ResetState(){this.IfAsyncWeCant("ResetState"),this._state=new zT.StoryState(this),this._state.variablesState.ObserveVariableChange(this.VariableStateDidChangeEvent.bind(this)),this.ResetGlobals();}ResetErrors(){if(this._state===null)return (0, ie.throwNullException)("this._state");this._state.ResetErrors();}ResetCallstack(){if(this.IfAsyncWeCant("ResetCallstack"),this._state===null)return (0, ie.throwNullException)("this._state");this._state.ForceEnd();}ResetGlobals(){if(this._mainContentContainer.namedContent.get("global decl")){let e=this.state.currentPointer.copy();this.ChoosePath(new xp.Path("global decl"),false),this.ContinueInternal(),this.state.currentPointer=e;}this.state.variablesState.SnapshotDefaultGlobals();}SwitchFlow(e){if(this.IfAsyncWeCant("switch flow"),this._asyncSaving)throw new Error("Story is already in background saving mode, can't switch flow to "+e);this.state.SwitchFlow_Internal(e);}RemoveFlow(e){this.state.RemoveFlow_Internal(e);}SwitchToDefaultFlow(){this.state.SwitchToDefaultFlow_Internal();}Continue(){return this.ContinueAsync(0),this.currentText}get canContinue(){return this.state.canContinue}get asyncContinueComplete(){return !this._asyncContinueActive}ContinueAsync(e){this._hasValidatedExternals||this.ValidateExternalBindings(),this.ContinueInternal(e);}ContinueInternal(e=0){this._profiler!=null&&this._profiler.PreContinue();let t=e>0;if(this._recursiveContinueCount++,this._asyncContinueActive)this._asyncContinueActive&&!t&&(this._asyncContinueActive=false);else {if(this._asyncContinueActive=t,!this.canContinue)throw new Error("Can't continue - should check canContinue before calling Continue");this._state.didSafeExit=false,this._state.ResetOutput(),this._recursiveContinueCount==1&&this._state.variablesState.StartVariableObservation();}let r=new ZT.Stopwatch;r.Start();let i=false;this._sawLookaheadUnsafeFunctionAfterNewline=false;do{try{i=this.ContinueSingleStep();}catch(s){if(!(s instanceof nr.StoryException))throw s;this.AddError(s.message,void 0,s.useEndLineNumber);break}if(i||this._asyncContinueActive&&r.ElapsedMilliseconds>e)break}while(this.canContinue);r.Stop();let a=null;if((i||!this.canContinue)&&(this._stateSnapshotAtLastNewline!==null&&this.RestoreStateSnapshot(),this.canContinue||(this.state.callStack.canPopThread&&this.AddError("Thread available to pop, threads should always be flat by the end of evaluation?"),this.state.generatedChoices.length==0&&!this.state.didSafeExit&&this._temporaryEvaluationContainer==null&&(this.state.callStack.CanPop(At.PushPopType.Tunnel)?this.AddError("unexpectedly reached end of content. Do you need a '->->' to return from a tunnel?"):this.state.callStack.CanPop(At.PushPopType.Function)?this.AddError("unexpectedly reached end of content. Do you need a '~ return'?"):this.state.callStack.canPop?this.AddError("unexpectedly reached end of content for unknown reason. Please debug compiler!"):this.AddError("ran out of content. Do you need a '-> DONE' or '-> END'?"))),this.state.didSafeExit=false,this._sawLookaheadUnsafeFunctionAfterNewline=false,this._recursiveContinueCount==1&&(a=this._state.variablesState.CompleteVariableObservation()),this._asyncContinueActive=false,this.onDidContinue!==null&&this.onDidContinue()),this._recursiveContinueCount--,this._profiler!=null&&this._profiler.PostContinue(),this.state.hasError||this.state.hasWarning)if(this.onError!==null){if(this.state.hasError)for(let s of this.state.currentErrors)this.onError(s,Sb.ErrorType.Error);if(this.state.hasWarning)for(let s of this.state.currentWarnings)this.onError(s,Sb.ErrorType.Warning);this.ResetErrors();}else {let s=new rr.StringBuilder;throw s.Append("Ink had "),this.state.hasError&&(s.Append(`${this.state.currentErrors.length}`),s.Append(this.state.currentErrors.length==1?" error":" errors"),this.state.hasWarning&&s.Append(" and ")),this.state.hasWarning&&(s.Append(`${this.state.currentWarnings.length}`),s.Append(this.state.currentWarnings.length==1?" warning":" warnings"),this.state.hasWarning&&s.Append(" and ")),s.Append(". It is strongly suggested that you assign an error handler to story.onError. The first issue was: "),s.Append(this.state.hasError?this.state.currentErrors[0]:this.state.currentWarnings[0]),new nr.StoryException(s.toString())}a!=null&&Object.keys(a).length>0&&this._state.variablesState.NotifyObservers(a);}ContinueSingleStep(){if(this._profiler!=null&&this._profiler.PreStep(),this.Step(),this._profiler!=null&&this._profiler.PostStep(),!this.canContinue&&!this.state.callStack.elementIsEvaluateFromGame&&this.TryFollowDefaultInvisibleChoice(),this._profiler!=null&&this._profiler.PreSnapshot(),!this.state.inStringEvaluation){if(this._stateSnapshotAtLastNewline!==null){if(this._stateSnapshotAtLastNewline.currentTags===null)return (0, ie.throwNullException)("this._stateAtLastNewline.currentTags");if(this.state.currentTags===null)return (0, ie.throwNullException)("this.state.currentTags");let e=this.CalculateNewlineOutputStateChange(this._stateSnapshotAtLastNewline.currentText,this.state.currentText,this._stateSnapshotAtLastNewline.currentTags.length,this.state.currentTags.length);if(e==n.OutputStateChange.ExtendedBeyondNewline||this._sawLookaheadUnsafeFunctionAfterNewline)return this.RestoreStateSnapshot(),true;e==n.OutputStateChange.NewlineRemoved&&this.DiscardSnapshot();}this.state.outputStreamEndsInNewline&&(this.canContinue?this._stateSnapshotAtLastNewline==null&&this.StateSnapshot():this.DiscardSnapshot());}return this._profiler!=null&&this._profiler.PostSnapshot(),false}CalculateNewlineOutputStateChange(e,t,r,i){if(e===null)return (0, ie.throwNullException)("prevText");if(t===null)return (0, ie.throwNullException)("currText");let a=t.length>=e.length&&e.length>0&&t.charAt(e.length-1)==`
|
|
34
|
+
`;if(r==i&&e.length==t.length&&a)return n.OutputStateChange.NoChange;if(!a)return n.OutputStateChange.NewlineRemoved;if(i>r)return n.OutputStateChange.ExtendedBeyondNewline;for(let s=e.length;s<t.length;s++){let o=t.charAt(s);if(o!=" "&&o!=" ")return n.OutputStateChange.ExtendedBeyondNewline}return n.OutputStateChange.NoChange}ContinueMaximally(){this.IfAsyncWeCant("ContinueMaximally");let e=new rr.StringBuilder;for(;this.canContinue;)e.Append(this.Continue());return e.toString()}ContentAtPath(e){return this.mainContentContainer.ContentAtPath(e)}KnotContainerWithName(e){let t=this.mainContentContainer.namedContent.get(e);return t instanceof Me.Container?t:null}PointerAtPath(e){if(e.length==0)return Pn.Pointer.Null;let t=new Pn.Pointer,r=e.length,i=null;return e.lastComponent===null?(0, ie.throwNullException)("path.lastComponent"):(e.lastComponent.isIndex?(r=e.length-1,i=this.mainContentContainer.ContentAtPath(e,void 0,r),t.container=i.container,t.index=e.lastComponent.index):(i=this.mainContentContainer.ContentAtPath(e),t.container=i.container,t.index=-1),i.obj==null||i.obj==this.mainContentContainer&&r>0?this.Error("Failed to find content at path '"+e+"', and no approximation of it was possible."):i.approximate&&this.Warning("Failed to find content at path '"+e+"', so it was approximated to: '"+i.obj.path+"'."),t)}StateSnapshot(){this._stateSnapshotAtLastNewline=this._state,this._state=this._state.CopyAndStartPatching(false);}RestoreStateSnapshot(){this._stateSnapshotAtLastNewline===null&&(0, ie.throwNullException)("_stateSnapshotAtLastNewline"),this._stateSnapshotAtLastNewline.RestoreAfterPatch(),this._state=this._stateSnapshotAtLastNewline,this._stateSnapshotAtLastNewline=null,this._asyncSaving||this._state.ApplyAnyPatch();}DiscardSnapshot(){this._asyncSaving||this._state.ApplyAnyPatch(),this._stateSnapshotAtLastNewline=null;}CopyStateForBackgroundThreadSave(){if(this.IfAsyncWeCant("start saving on a background thread"),this._asyncSaving)throw new Error("Story is already in background saving mode, can't call CopyStateForBackgroundThreadSave again!");let e=this._state;return this._state=this._state.CopyAndStartPatching(true),this._asyncSaving=true,e}BackgroundSaveComplete(){this._stateSnapshotAtLastNewline===null&&this._state.ApplyAnyPatch(),this._asyncSaving=false;}Step(){let e=true,t=this.state.currentPointer.copy();if(t.isNull)return;let r=(0, G.asOrNull)(t.Resolve(),Me.Container);for(;r&&(this.VisitContainer(r,true),r.content.length!=0);)t=Pn.Pointer.StartOf(r),r=(0, G.asOrNull)(t.Resolve(),Me.Container);this.state.currentPointer=t.copy(),this._profiler!=null&&this._profiler.Step(this.state.callStack);let i=t.Resolve(),a=this.PerformLogicAndFlowControl(i);if(this.state.currentPointer.isNull)return;a&&(e=false);let s=(0, G.asOrNull)(i,JT.ChoicePoint);if(s){let u=this.ProcessChoice(s);u&&this.state.generatedChoices.push(u),i=null,e=false;}if(i instanceof Me.Container&&(e=false),e){let u=(0, G.asOrNull)(i,I.VariablePointerValue);if(u&&u.contextIndex==-1){let l=this.state.callStack.ContextForVariableNamed(u.variableName);i=new I.VariablePointerValue(u.variableName,l);}this.state.inExpressionEvaluation?this.state.PushEvaluationStack(i):this.state.PushToOutputStream(i);}this.NextContent();let o=(0, G.asOrNull)(i,B.ControlCommand);o&&o.commandType==B.ControlCommand.CommandType.StartThread&&this.state.callStack.PushThread();}VisitContainer(e,t){(!e.countingAtStartOnly||t)&&(e.visitsShouldBeCounted&&this.state.IncrementVisitCountForContainer(e),e.turnIndexShouldBeCounted&&this.state.RecordTurnIndexVisitToContainer(e));}VisitChangedContainersDueToDivert(){let e=this.state.previousPointer.copy(),t=this.state.currentPointer.copy();if(t.isNull||t.index==-1)return;if(this._prevContainers.length=0,!e.isNull){let s=e.Resolve(),o=(0, G.asOrNull)(s,Me.Container)||(0, G.asOrNull)(e.container,Me.Container);for(;o;)this._prevContainers.push(o),o=(0, G.asOrNull)(o.parent,Me.Container);}let r=t.Resolve();if(r==null)return;let i=(0, G.asOrNull)(r.parent,Me.Container),a=true;for(;i&&(this._prevContainers.indexOf(i)<0||i.countingAtStartOnly);){let s=i.content.length>0&&r==i.content[0]&&a;s||(a=false),this.VisitContainer(i,s),r=i,i=(0, G.asOrNull)(i.parent,Me.Container);}}PopChoiceStringAndTags(e){let t=(0, G.asOrThrows)(this.state.PopEvaluationStack(),I.StringValue);for(;this.state.evaluationStack.length>0&&(0, G.asOrNull)(this.state.PeekEvaluationStack(),Eu.Tag)!=null;){let r=(0, G.asOrNull)(this.state.PopEvaluationStack(),Eu.Tag);r&&e.push(r.text);}return t.value}ProcessChoice(e){let t=true;if(e.hasCondition){let o=this.state.PopEvaluationStack();this.IsTruthy(o)||(t=false);}let r="",i="",a=[];if(e.hasChoiceOnlyContent&&(i=this.PopChoiceStringAndTags(a)||""),e.hasStartContent&&(r=this.PopChoiceStringAndTags(a)||""),e.onceOnly&&this.state.VisitCountForContainer(e.choiceTarget)>0&&(t=false),!t)return null;let s=new HT.Choice;return s.targetPath=e.pathOnChoice,s.sourcePath=e.path.toString(),s.isInvisibleDefault=e.isInvisibleDefault,s.threadAtGeneration=this.state.callStack.ForkThread(),s.tags=a.reverse(),s.text=(r+i).replace(/^[ \t]+|[ \t]+$/g,""),s}IsTruthy(e){let t=false;if(e instanceof I.Value){let r=e;if(r instanceof I.DivertTargetValue){let i=r;return this.Error("Shouldn't use a divert target (to "+i.targetPath+") as a conditional value. Did you intend a function call 'likeThis()' or a read count check 'likeThis'? (no arrows)"),false}return r.isTruthy}return t}PerformLogicAndFlowControl(e){if(e==null)return false;if(e instanceof bb.Divert){let t=e;if(t.isConditional){let r=this.state.PopEvaluationStack();if(!this.IsTruthy(r))return true}if(t.hasVariableTarget){let r=t.variableDivertName,i=this.state.variablesState.GetVariableWithName(r);if(i==null)this.Error("Tried to divert using a target from a variable that could not be found ("+r+")");else if(!(i instanceof I.DivertTargetValue)){let s=(0, G.asOrNull)(i,I.IntValue),o="Tried to divert to a target from a variable, but the variable ("+r+") didn't contain a divert target, it ";s instanceof I.IntValue&&s.value==0?o+="was empty/null (the value 0).":o+="contained '"+i+"'.",this.Error(o);}let a=(0, G.asOrThrows)(i,I.DivertTargetValue);this.state.divertedPointer=this.PointerAtPath(a.targetPath);}else {if(t.isExternal)return this.CallExternalFunction(t.targetPathString,t.externalArgs),true;this.state.divertedPointer=t.targetPointer.copy();}return t.pushesToStack&&this.state.callStack.Push(t.stackPushType,void 0,this.state.outputStream.length),this.state.divertedPointer.isNull&&!t.isExternal&&(t&&t.debugMetadata&&t.debugMetadata.sourceName!=null?this.Error("Divert target doesn't exist: "+t.debugMetadata.sourceName):this.Error("Divert resolution failed: "+t)),true}else if(e instanceof B.ControlCommand){let t=e;switch(t.commandType){case B.ControlCommand.CommandType.EvalStart:this.Assert(this.state.inExpressionEvaluation===false,"Already in expression evaluation?"),this.state.inExpressionEvaluation=true;break;case B.ControlCommand.CommandType.EvalEnd:this.Assert(this.state.inExpressionEvaluation===true,"Not in expression evaluation mode"),this.state.inExpressionEvaluation=false;break;case B.ControlCommand.CommandType.EvalOutput:if(this.state.evaluationStack.length>0){let m=this.state.PopEvaluationStack();if(!(m instanceof ms.Void)){let b=new I.StringValue(m.toString());this.state.PushToOutputStream(b);}}break;case B.ControlCommand.CommandType.NoOp:break;case B.ControlCommand.CommandType.Duplicate:this.state.PushEvaluationStack(this.state.PeekEvaluationStack());break;case B.ControlCommand.CommandType.PopEvaluatedValue:this.state.PopEvaluationStack();break;case B.ControlCommand.CommandType.PopFunction:case B.ControlCommand.CommandType.PopTunnel:let r=t.commandType==B.ControlCommand.CommandType.PopFunction?At.PushPopType.Function:At.PushPopType.Tunnel,i=null;if(r==At.PushPopType.Tunnel){let m=this.state.PopEvaluationStack();i=(0, G.asOrNull)(m,I.DivertTargetValue),i===null&&this.Assert(m instanceof ms.Void,"Expected void if ->-> doesn't override target");}if(this.state.TryExitFunctionEvaluationFromGame())break;if(this.state.callStack.currentElement.type!=r||!this.state.callStack.canPop){let m=new Map;m.set(At.PushPopType.Function,"function return statement (~ return)"),m.set(At.PushPopType.Tunnel,"tunnel onwards statement (->->)");let b=m.get(this.state.callStack.currentElement.type);this.state.callStack.canPop||(b="end of flow (-> END or choice)");let E="Found "+m.get(r)+", when expected "+b;this.Error(E);}else this.state.PopCallStack(),i&&(this.state.divertedPointer=this.PointerAtPath(i.targetPath));break;case B.ControlCommand.CommandType.BeginString:this.state.PushToOutputStream(t),this.Assert(this.state.inExpressionEvaluation===true,"Expected to be in an expression when evaluating a string"),this.state.inExpressionEvaluation=false;break;case B.ControlCommand.CommandType.BeginTag:this.state.PushToOutputStream(t);break;case B.ControlCommand.CommandType.EndTag:{if(this.state.inStringEvaluation){let m=[],b=0;for(let P=this.state.outputStream.length-1;P>=0;--P){let k=this.state.outputStream[P];b++;let z=(0, G.asOrNull)(k,B.ControlCommand);if(z!=null){if(z.commandType==B.ControlCommand.CommandType.BeginTag)break;this.Error("Unexpected ControlCommand while extracting tag from choice");break}k instanceof I.StringValue&&m.push(k);}this.state.PopFromOutputStream(b);let E=new rr.StringBuilder;for(let P of m.reverse())E.Append(P.toString());let O=new Eu.Tag(this.state.CleanOutputWhitespace(E.toString()));this.state.PushEvaluationStack(O);}else this.state.PushToOutputStream(t);break}case B.ControlCommand.CommandType.EndString:{let m=[],b=[],E=0;for(let P=this.state.outputStream.length-1;P>=0;--P){let k=this.state.outputStream[P];E++;let z=(0, G.asOrNull)(k,B.ControlCommand);if(z&&z.commandType==B.ControlCommand.CommandType.BeginString)break;k instanceof Eu.Tag&&b.push(k),k instanceof I.StringValue&&m.push(k);}this.state.PopFromOutputStream(E);for(let P of b)this.state.PushToOutputStream(P);m=m.reverse();let O=new rr.StringBuilder;for(let P of m)O.Append(P.toString());this.state.inExpressionEvaluation=true,this.state.PushEvaluationStack(new I.StringValue(O.toString()));break}case B.ControlCommand.CommandType.ChoiceCount:let a=this.state.generatedChoices.length;this.state.PushEvaluationStack(new I.IntValue(a));break;case B.ControlCommand.CommandType.Turns:this.state.PushEvaluationStack(new I.IntValue(this.state.currentTurnIndex+1));break;case B.ControlCommand.CommandType.TurnsSince:case B.ControlCommand.CommandType.ReadCount:let s=this.state.PopEvaluationStack();if(!(s instanceof I.DivertTargetValue)){let m="";s instanceof I.IntValue&&(m=". Did you accidentally pass a read count ('knot_name') instead of a target ('-> knot_name')?"),this.Error("TURNS_SINCE / READ_COUNT expected a divert target (knot, stitch, label name), but saw "+s+m);break}let o=(0, G.asOrThrows)(s,I.DivertTargetValue),u=(0, G.asOrNull)(this.ContentAtPath(o.targetPath).correctObj,Me.Container),l;u!=null?t.commandType==B.ControlCommand.CommandType.TurnsSince?l=this.state.TurnsSinceForContainer(u):l=this.state.VisitCountForContainer(u):(t.commandType==B.ControlCommand.CommandType.TurnsSince?l=-1:l=0,this.Warning("Failed to find container for "+t.toString()+" lookup at "+o.targetPath.toString())),this.state.PushEvaluationStack(new I.IntValue(l));break;case B.ControlCommand.CommandType.Random:{let m=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue),b=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue);if(b==null||!(b instanceof I.IntValue))return this.Error("Invalid value for minimum parameter of RANDOM(min, max)");if(m==null||!(m instanceof I.IntValue))return this.Error("Invalid value for maximum parameter of RANDOM(min, max)");if(m.value===null)return (0, ie.throwNullException)("maxInt.value");if(b.value===null)return (0, ie.throwNullException)("minInt.value");let E=m.value-b.value+1;(!isFinite(E)||E>Number.MAX_SAFE_INTEGER)&&(E=Number.MAX_SAFE_INTEGER,this.Error("RANDOM was called with a range that exceeds the size that ink numbers can use.")),E<=0&&this.Error("RANDOM was called with minimum as "+b.value+" and maximum as "+m.value+". The maximum must be larger");let O=this.state.storySeed+this.state.previousRandom,k=new Tp.PRNG(O).next(),z=k%E+b.value;this.state.PushEvaluationStack(new I.IntValue(z)),this.state.previousRandom=k;break}case B.ControlCommand.CommandType.SeedRandom:let c=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue);if(c==null||!(c instanceof I.IntValue))return this.Error("Invalid value passed to SEED_RANDOM");if(c.value===null)return (0, ie.throwNullException)("minInt.value");this.state.storySeed=c.value,this.state.previousRandom=0,this.state.PushEvaluationStack(new ms.Void);break;case B.ControlCommand.CommandType.VisitIndex:let h=this.state.VisitCountForContainer(this.state.currentPointer.container)-1;this.state.PushEvaluationStack(new I.IntValue(h));break;case B.ControlCommand.CommandType.SequenceShuffleIndex:let f=this.NextSequenceShuffleIndex();this.state.PushEvaluationStack(new I.IntValue(f));break;case B.ControlCommand.CommandType.StartThread:break;case B.ControlCommand.CommandType.Done:this.state.callStack.canPopThread?this.state.callStack.PopThread():(this.state.didSafeExit=true,this.state.currentPointer=Pn.Pointer.Null);break;case B.ControlCommand.CommandType.End:this.state.ForceEnd();break;case B.ControlCommand.CommandType.ListFromInt:let p=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue),g=(0, G.asOrThrows)(this.state.PopEvaluationStack(),I.StringValue);if(p===null)throw new nr.StoryException("Passed non-integer when creating a list element from a numerical value.");let y=null;if(this.listDefinitions===null)return (0, ie.throwNullException)("this.listDefinitions");let C=this.listDefinitions.TryListGetDefinition(g.value,null);if(C.exists){if(p.value===null)return (0, ie.throwNullException)("minInt.value");let m=C.result.TryGetItemWithValue(p.value,gs.InkListItem.Null);m.exists&&(y=new I.ListValue(m.result,p.value));}else throw new nr.StoryException("Failed to find LIST called "+g.value);y==null&&(y=new I.ListValue),this.state.PushEvaluationStack(y);break;case B.ControlCommand.CommandType.ListRange:let S=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.Value),v=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.Value),d=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.ListValue);if(d===null||v===null||S===null)throw new nr.StoryException("Expected list, minimum and maximum for LIST_RANGE");if(d.value===null)return (0, ie.throwNullException)("targetList.value");let _=d.value.ListWithSubRange(v.valueObject,S.valueObject);this.state.PushEvaluationStack(new I.ListValue(_));break;case B.ControlCommand.CommandType.ListRandom:{let m=this.state.PopEvaluationStack();if(m===null)throw new nr.StoryException("Expected list for LIST_RANDOM");let b=m.value,E=null;if(b===null)throw (0, ie.throwNullException)("list");if(b.Count==0)E=new gs.InkList;else {let O=this.state.storySeed+this.state.previousRandom,k=new Tp.PRNG(O).next(),z=k%b.Count,se=b.entries();for(let Qr=0;Qr<=z-1;Qr++)se.next();let le=se.next().value,un={Key:gs.InkListItem.fromSerializedKey(le[0]),Value:le[1]};if(un.Key.originName===null)return (0, ie.throwNullException)("randomItem.Key.originName");E=new gs.InkList(un.Key.originName,this),E.Add(un.Key,un.Value),this.state.previousRandom=k;}this.state.PushEvaluationStack(new I.ListValue(E));break}default:this.Error("unhandled ControlCommand: "+t);break}return true}else if(e instanceof UT.VariableAssignment){let t=e,r=this.state.PopEvaluationStack();return this.state.variablesState.Assign(t,r),true}else if(e instanceof KT.VariableReference){let t=e,r=null;if(t.pathForCount!=null){let i=t.containerForCount,a=this.state.VisitCountForContainer(i);r=new I.IntValue(a);}else r=this.state.variablesState.GetVariableWithName(t.name),r==null&&(this.Warning("Variable not found: '"+t.name+"'. Using default value of 0 (false). This can happen with temporary variables if the declaration hasn't yet been hit. Globals are always given a default value on load if a value doesn't exist in the save state."),r=new I.IntValue(0));return this.state.PushEvaluationStack(r),true}else if(e instanceof XT.NativeFunctionCall){let t=e,r=this.state.PopEvaluationStack(t.numberOfParameters),i=t.Call(r);return this.state.PushEvaluationStack(i),true}return false}ChoosePathString(e,t=true,r=[]){if(this.IfAsyncWeCant("call ChoosePathString right now"),this.onChoosePathString!==null&&this.onChoosePathString(e,r),t)this.ResetCallstack();else if(this.state.callStack.currentElement.type==At.PushPopType.Function){let i="",a=this.state.callStack.currentElement.currentPointer.container;throw a!=null&&(i="("+a.path.toString()+") "),new Error("Story was running a function "+i+"when you called ChoosePathString("+e+`) - this is almost certainly not not what you want! Full stack trace:
|
|
35
|
+
`+this.state.callStack.callStackTrace)}this.state.PassArgumentsToEvaluationStack(r),this.ChoosePath(new xp.Path(e));}IfAsyncWeCant(e){if(this._asyncContinueActive)throw new Error("Can't "+e+". Story is in the middle of a ContinueAsync(). Make more ContinueAsync() calls or a single Continue() call beforehand.")}ChoosePath(e,t=true){this.state.SetChosenPath(e,t),this.VisitChangedContainersDueToDivert();}ChooseChoiceIndex(e){e=e;let t=this.currentChoices;this.Assert(e>=0&&e<t.length,"choice out of range");let r=t[e];if(this.onMakeChoice!==null&&this.onMakeChoice(r),r.threadAtGeneration===null)return (0, ie.throwNullException)("choiceToChoose.threadAtGeneration");if(r.targetPath===null)return (0, ie.throwNullException)("choiceToChoose.targetPath");this.state.callStack.currentThread=r.threadAtGeneration,this.ChoosePath(r.targetPath);}HasFunction(e){try{return this.KnotContainerWithName(e)!=null}catch{return false}}EvaluateFunction(e,t=[],r=false){if(this.onEvaluateFunction!==null&&this.onEvaluateFunction(e,t),this.IfAsyncWeCant("evaluate a function"),e==null)throw new Error("Function is null");if(e==""||e.trim()=="")throw new Error("Function is empty or white space.");let i=this.KnotContainerWithName(e);if(i==null)throw new Error("Function doesn't exist: '"+e+"'");let a=[];a.push(...this.state.outputStream),this._state.ResetOutput(),this.state.StartFunctionEvaluationFromGame(i,t);let s=new rr.StringBuilder;for(;this.canContinue;)s.Append(this.Continue());let o=s.toString();this._state.ResetOutput(a);let u=this.state.CompleteFunctionEvaluationFromGame();return this.onCompleteEvaluateFunction!=null&&this.onCompleteEvaluateFunction(e,t,o,u),r?{returned:u,output:o}:u}EvaluateExpression(e){let t=this.state.callStack.elements.length;this.state.callStack.Push(At.PushPopType.Tunnel),this._temporaryEvaluationContainer=e,this.state.GoToStart();let r=this.state.evaluationStack.length;return this.Continue(),this._temporaryEvaluationContainer=null,this.state.callStack.elements.length>t&&this.state.PopCallStack(),this.state.evaluationStack.length>r?this.state.PopEvaluationStack():null}CallExternalFunction(e,t){if(e===null)return (0, ie.throwNullException)("funcName");let r=this._externals.get(e),i=null,a=typeof r<"u";if(a&&!r.lookAheadSafe&&this._state.inStringEvaluation&&this.Error("External function "+e+` could not be called because 1) it wasn't marked as lookaheadSafe when BindExternalFunction was called and 2) the story is in the middle of string generation, either because choice text is being generated, or because you have ink like "hello {func()}". You can work around this by generating the result of your function into a temporary variable before the string or choice gets generated: ~ temp x = `+e+"()"),a&&!r.lookAheadSafe&&this._stateSnapshotAtLastNewline!==null){this._sawLookaheadUnsafeFunctionAfterNewline=true;return}if(!a)if(this.allowExternalFunctionFallbacks){i=this.KnotContainerWithName(e),this.Assert(i!==null,"Trying to call EXTERNAL function '"+e+"' which has not been bound, and fallback ink function could not be found."),this.state.callStack.Push(At.PushPopType.Function,void 0,this.state.outputStream.length),this.state.divertedPointer=Pn.Pointer.StartOf(i);return}else this.Assert(false,"Trying to call EXTERNAL function '"+e+"' which has not been bound (and ink fallbacks disabled).");let s=[];for(let l=0;l<t;++l){let h=(0, G.asOrThrows)(this.state.PopEvaluationStack(),I.Value).valueObject;s.push(h);}s.reverse();let o=r.function(s),u=null;o!=null?(u=I.Value.Create(o),this.Assert(u!==null,"Could not create ink value from returned object of type "+typeof o)):u=new ms.Void,this.state.PushEvaluationStack(u);}BindExternalFunctionGeneral(e,t,r=true){this.IfAsyncWeCant("bind an external function"),this.Assert(!this._externals.has(e),"Function '"+e+"' has already been bound."),this._externals.set(e,{function:t,lookAheadSafe:r});}TryCoerce(e){return e}BindExternalFunction(e,t,r=false){this.Assert(t!=null,"Can't bind a null function"),this.BindExternalFunctionGeneral(e,i=>{this.Assert(i.length>=t.length,"External function expected "+t.length+" arguments");let a=[];for(let s=0,o=i.length;s<o;s++)a[s]=this.TryCoerce(i[s]);return t.apply(null,a)},r);}UnbindExternalFunction(e){this.IfAsyncWeCant("unbind an external a function"),this.Assert(this._externals.has(e),"Function '"+e+"' has not been bound."),this._externals.delete(e);}ValidateExternalBindings(){let e=null,t=null,r=arguments[1]||new Set;if(arguments[0]instanceof Me.Container&&(e=arguments[0]),arguments[0]instanceof Op.InkObject&&(t=arguments[0]),e===null&&t===null)if(this.ValidateExternalBindings(this._mainContentContainer,r),this._hasValidatedExternals=true,r.size==0)this._hasValidatedExternals=true;else {let i="Error: Missing function binding for external";i+=r.size>1?"s":"",i+=": '",i+=Array.from(r).join("', '"),i+="' ",i+=this.allowExternalFunctionFallbacks?", and no fallback ink function found.":" (ink fallbacks disabled)",this.Error(i);}else if(e!=null){for(let i of e.content){let a=i;(a==null||!a.hasValidName)&&this.ValidateExternalBindings(i,r);}for(let[,i]of e.namedContent)this.ValidateExternalBindings((0, G.asOrNull)(i,Op.InkObject),r);}else if(t!=null){let i=(0, G.asOrNull)(t,bb.Divert);if(i&&i.isExternal){let a=i.targetPathString;if(a===null)return (0, ie.throwNullException)("name");this._externals.has(a)||this.allowExternalFunctionFallbacks&&this.mainContentContainer.namedContent.has(a)||r.add(a);}}}ObserveVariable(e,t){if(this.IfAsyncWeCant("observe a new variable"),this._variableObservers===null&&(this._variableObservers=new Map),!this.state.variablesState.GlobalVariableExistsWithName(e))throw new Error("Cannot observe variable '"+e+"' because it wasn't declared in the ink story.");this._variableObservers.has(e)?this._variableObservers.get(e).push(t):this._variableObservers.set(e,[t]);}ObserveVariables(e,t){for(let r=0,i=e.length;r<i;r++)this.ObserveVariable(e[r],t[r]);}RemoveVariableObserver(e,t){if(this.IfAsyncWeCant("remove a variable observer"),this._variableObservers!==null){if(t!=null){if(this._variableObservers.has(t))if(e!=null){let r=this._variableObservers.get(t);r!=null&&(r.splice(r.indexOf(e),1),r.length===0&&this._variableObservers.delete(t));}else this._variableObservers.delete(t);}else if(e!=null){let r=this._variableObservers.keys();for(let i of r){let a=this._variableObservers.get(i);a!=null&&(a.splice(a.indexOf(e),1),a.length===0&&this._variableObservers.delete(i));}}}}VariableStateDidChangeEvent(e,t){if(this._variableObservers===null)return;let r=this._variableObservers.get(e);if(typeof r<"u"){if(!(t instanceof I.Value))throw new Error("Tried to get the value of a variable that isn't a standard type");let i=(0, G.asOrThrows)(t,I.Value);for(let a of r)a(e,i.valueObject);}}get globalTags(){return this.TagsAtStartOfFlowContainerWithPathString("")}TagsForContentAtPath(e){return this.TagsAtStartOfFlowContainerWithPathString(e)}TagsAtStartOfFlowContainerWithPathString(e){let t=new xp.Path(e),r=this.ContentAtPath(t).container;if(r===null)return (0, ie.throwNullException)("flowContainer");for(;;){let s=r.content[0];if(s instanceof Me.Container)r=s;else break}let i=false,a=null;for(let s of r.content){let o=(0, G.asOrNull)(s,B.ControlCommand);if(o!=null)o.commandType==B.ControlCommand.CommandType.BeginTag?i=true:o.commandType==B.ControlCommand.CommandType.EndTag&&(i=false);else if(i){let u=(0, G.asOrNull)(s,I.StringValue);u!==null?(a===null&&(a=[]),u.value!==null&&a.push(u.value)):this.Error("Tag contained non-text content. Only plain text is allowed when using globalTags or TagsAtContentPath. If you want to evaluate dynamic content, you need to use story.Continue().");}else break}return a}BuildStringOfHierarchy(){let e=new rr.StringBuilder;return this.mainContentContainer.BuildStringOfHierarchy(e,0,this.state.currentPointer.Resolve()),e.toString()}BuildStringOfContainer(e){let t=new rr.StringBuilder;return e.BuildStringOfHierarchy(t,0,this.state.currentPointer.Resolve()),t.toString()}NextContent(){if(this.state.previousPointer=this.state.currentPointer.copy(),!this.state.divertedPointer.isNull&&(this.state.currentPointer=this.state.divertedPointer.copy(),this.state.divertedPointer=Pn.Pointer.Null,this.VisitChangedContainersDueToDivert(),!this.state.currentPointer.isNull))return;if(!this.IncrementContentPointer()){let t=false;this.state.callStack.CanPop(At.PushPopType.Function)?(this.state.PopCallStack(At.PushPopType.Function),this.state.inExpressionEvaluation&&this.state.PushEvaluationStack(new ms.Void),t=true):this.state.callStack.canPopThread?(this.state.callStack.PopThread(),t=true):this.state.TryExitFunctionEvaluationFromGame(),t&&!this.state.currentPointer.isNull&&this.NextContent();}}IncrementContentPointer(){let e=true,t=this.state.callStack.currentElement.currentPointer.copy();if(t.index++,t.container===null)return (0, ie.throwNullException)("pointer.container");for(;t.index>=t.container.content.length;){e=false;let r=(0, G.asOrNull)(t.container.parent,Me.Container);if(!(r instanceof Me.Container))break;let i=r.content.indexOf(t.container);if(i==-1)break;if(t=new Pn.Pointer(r,i),t.index++,e=true,t.container===null)return (0, ie.throwNullException)("pointer.container")}return e||(t=Pn.Pointer.Null),this.state.callStack.currentElement.currentPointer=t.copy(),e}TryFollowDefaultInvisibleChoice(){let e=this._state.currentChoices,t=e.filter(i=>i.isInvisibleDefault);if(t.length==0||e.length>t.length)return false;let r=t[0];return r.targetPath===null?(0, ie.throwNullException)("choice.targetPath"):r.threadAtGeneration===null?(0, ie.throwNullException)("choice.threadAtGeneration"):(this.state.callStack.currentThread=r.threadAtGeneration,this._stateSnapshotAtLastNewline!==null&&(this.state.callStack.currentThread=this.state.callStack.ForkThread()),this.ChoosePath(r.targetPath,false),true)}NextSequenceShuffleIndex(){let e=(0, G.asOrNull)(this.state.PopEvaluationStack(),I.IntValue);if(!(e instanceof I.IntValue))return this.Error("expected number of elements in sequence for shuffle index"),0;let t=this.state.currentPointer.container;if(t===null)return (0, ie.throwNullException)("seqContainer");if(e.value===null)return (0, ie.throwNullException)("numElementsIntVal.value");let r=e.value,a=(0, G.asOrThrows)(this.state.PopEvaluationStack(),I.IntValue).value;if(a===null)return (0, ie.throwNullException)("seqCount");let s=a/r,o=a%r,u=t.path.toString(),l=0;for(let p=0,g=u.length;p<g;p++)l+=u.charCodeAt(p)||0;let c=l+s+this.state.storySeed,h=new Tp.PRNG(Math.floor(c)),f=[];for(let p=0;p<r;++p)f.push(p);for(let p=0;p<=o;++p){let g=h.next()%f.length,y=f[g];if(f.splice(g,1),p==o)return y}throw new Error("Should never reach here")}Error(e,t=false){let r=new nr.StoryException(e);throw r.useEndLineNumber=t,r}Warning(e){this.AddError(e,true);}AddError(e,t=false,r=false){let i=this.currentDebugMetadata,a=t?"WARNING":"ERROR";if(i!=null){let s=r?i.endLineNumber:i.startLineNumber;e="RUNTIME "+a+": '"+i.fileName+"' line "+s+": "+e;}else this.state.currentPointer.isNull?e="RUNTIME "+a+": "+e:e="RUNTIME "+a+": ("+this.state.currentPointer+"): "+e;this.state.AddError(e,t),t||this.state.ForceEnd();}Assert(e,t=null){if(e==false)throw t==null&&(t="Story assert"),new Error(t+" "+this.currentDebugMetadata)}get currentDebugMetadata(){let e,t=this.state.currentPointer;if(!t.isNull&&t.Resolve()!==null&&(e=t.Resolve().debugMetadata,e!==null))return e;for(let r=this.state.callStack.elements.length-1;r>=0;--r)if(t=this.state.callStack.elements[r].currentPointer,!t.isNull&&t.Resolve()!==null&&(e=t.Resolve().debugMetadata,e!==null))return e;for(let r=this.state.outputStream.length-1;r>=0;--r)if(e=this.state.outputStream[r].debugMetadata,e!==null)return e;return null}get mainContentContainer(){return this._temporaryEvaluationContainer?this._temporaryEvaluationContainer:this._mainContentContainer}};ir.Story=Ur;Ur.inkVersionCurrent=21;(function(n){(function(t){t[t.NoChange=0]="NoChange",t[t.ExtendedBeyondNewline=1]="ExtendedBeyondNewline",t[t.NewlineRemoved=2]="NewlineRemoved";})(n.OutputStateChange||(n.OutputStateChange={}));})(Ur||(ir.Story=Ur={}));});var wb=w(xu=>{Object.defineProperty(xu,"__esModule",{value:true});xu.Story=void 0;var e1=Sa(),t1=ao(),Du=Ee(),Au=Be(),ys=Pr(),Ou=Jt(),_b=Lr(),n1=Zd(),r1=jo(),i1=ip(),s1=cs(),Kr=sn(),a1=En(),o1=_n(),vs=oe(),u1=ts(),l1=ns(),c1=Qn(),Pu=class n extends Ou.FlowBase{get flowLevel(){return _b.FlowLevel.Story}get hadError(){return this._hadError}get hadWarning(){return this._hadWarning}constructor(e,t=false){super(null,e,null,false,t),this._errorHandler=null,this._hadError=false,this._hadWarning=false,this._dontFlattenContainers=new Set,this._listDefs=new Map,this.constants=new Map,this.externals=new Map,this.countAllVisits=false,this.ExportRuntime=(r=null)=>{var i,a;this._errorHandler=r,this.constants=new Map;for(let c of this.FindAll(t1.ConstantDeclaration)()){let h=this.constants.get(c.constantName);if(h&&!h.Equals(c.expression)){let f=`CONST '${c.constantName}' has been redefined with a different value. Multiple definitions of the same CONST are valid so long as they contain the same value. Initial definition was on ${h.debugMetadata}.`;this.Error(f,c,false);}this.constants.set(c.constantName,c.expression);}this._listDefs=new Map;for(let c of this.FindAll(r1.ListDefinition)())!((i=c.identifier)===null||i===void 0)&&i.name&&this._listDefs.set((a=c.identifier)===null||a===void 0?void 0:a.name,c);this.externals=new Map,this.ResolveWeavePointNaming();let s=this.runtimeObject,o=new Du.Container;o.AddContent(Au.ControlCommand.EvalStart());let u=[];for(let[c,h]of this.variableDeclarations)if(h.isGlobalDeclaration){if(h.listDefinition)this._listDefs.set(c,h.listDefinition),o.AddContent(h.listDefinition.runtimeObject),u.push(h.listDefinition.runtimeListDefinition);else {if(!h.expression)throw new Error;h.expression.GenerateIntoContainer(o);}let f=new o1.VariableAssignment(c,true);f.isGlobal=true,o.AddContent(f);}o.AddContent(Au.ControlCommand.EvalEnd()),o.AddContent(Au.ControlCommand.End()),this.variableDeclarations.size>0&&(o.name="global decl",s.AddToNamedContentOnly(o)),s.AddContent(Au.ControlCommand.Done());let l=new s1.Story(s,u);return this.runtimeObject=l,this.hadError||(this.FlattenContainersIn(s),this.ResolveReferences(this),this.hadError)?null:(l.ResetState(),l)},this.ResolveList=r=>{let i=this._listDefs.get(r);return i||null},this.ResolveListItem=(r,i,a=null)=>{let s=null;if(r)return (s=this._listDefs.get(r))?s.ItemNamed(i):null;{let o=null,u=null;for(let[,l]of this._listDefs.entries()){let c=l.ItemNamed(i);c&&(o?this.Error(`Ambiguous item name '${i}' found in multiple sets, including ${u.identifier} and ${l.identifier}`,a,false):(o=c,u=l));}return o}},this.FlattenContainersIn=r=>{let i=new Set;if(r.content)for(let a of r.content){let s=(0, vs.asOrNull)(a,Du.Container);s&&i.add(s);}if(r.namedContent)for(let[,a]of r.namedContent){let s=(0, vs.asOrNull)(a,Du.Container);s&&i.add(s);}for(let a of i)this.TryFlattenContainer(a),this.FlattenContainersIn(a);},this.TryFlattenContainer=r=>{if(r.namedContent&&r.namedContent.size>0||r.hasValidName||this._dontFlattenContainers.has(r))return;let i=(0, vs.asOrNull)(r.parent,Du.Container);if(i){let a=i.content.indexOf(r);i.content.splice(a,1);let s=r.ownDebugMetadata;if(r.content)for(let o of r.content)o.parent=null,s!==null&&o.ownDebugMetadata===null&&(o.debugMetadata=s),i.InsertContent(o,a),a+=1;}},this.Error=(r,i,a)=>{let s=a?ys.ErrorType.Warning:ys.ErrorType.Error,o="";if(i instanceof e1.AuthorWarning?(o+="TODO: ",s=ys.ErrorType.Author):a?o+="WARNING: ":o+="ERROR: ",i&&i.debugMetadata!==null&&i.debugMetadata.startLineNumber>=1&&(i.debugMetadata.fileName!=null&&(o+=`'${i.debugMetadata.fileName}' `),o+=`line ${i.debugMetadata.startLineNumber}: `),o+=r,r=o,this._errorHandler!==null)this._errorHandler(r,s);else throw new Error(r);this._hadError=s===ys.ErrorType.Error,this._hadWarning=s===ys.ErrorType.Warning;},this.ResetError=()=>{this._hadError=false,this._hadWarning=false;},this.IsExternal=r=>this.externals.has(r),this.AddExternal=r=>{this.externals.has(r.name)?this.Error(`Duplicate EXTERNAL definition of '${r.name}'`,r,false):r.name&&this.externals.set(r.name,r);},this.DontFlattenContainer=r=>{this._dontFlattenContainers.add(r);},this.NameConflictError=(r,i,a,s)=>{r.Error(`${s} '${i}': name has already been used for a ${a.typeName.toLowerCase()} on ${a.debugMetadata}`);},this.CheckForNamingCollisions=(r,i,a,s="")=>{var o;let u=s||r.typeName;if(n.IsReservedKeyword(i?.name)){r.Error(`'${i}' cannot be used for the name of a ${u.toLowerCase()} because it's a reserved keyword`);return}else if(l1.FunctionCall.IsBuiltIn(i?.name||"")){r.Error(`'${i}' cannot be used for the name of a ${u.toLowerCase()} because it's a built in function`);return}let l=this.ContentWithNameAtLevel(i?.name||"",_b.FlowLevel.Knot),c=(0, vs.asOrNull)(l,Ou.FlowBase);if(c&&(c!==r||a===Kr.SymbolType.Arg)){this.NameConflictError(r,i?.name||"",c,u);return}if(a<Kr.SymbolType.List)return;for(let[g,y]of this._listDefs)if(i?.name===g&&r!==y&&y.variableAssignment!==r&&this.NameConflictError(r,i?.name,y,u),!(r instanceof i1.ListElementDefinition))for(let C of y.itemDefinitions)i?.name===C.name&&this.NameConflictError(r,i?.name||"",C,u);if(a<=Kr.SymbolType.Var)return;let h=i?.name&&this.variableDeclarations.get(i?.name)||null;if(h&&h!==r&&h.isGlobalDeclaration&&h.listDefinition==null&&this.NameConflictError(r,i?.name||"",h,u),a<Kr.SymbolType.SubFlowAndWeave)return;let p=new c1.Path(i).ResolveFromContext(r);if(p&&p!==r){this.NameConflictError(r,i?.name||"",p,u);return}if(!(a<Kr.SymbolType.Arg)&&a!==Kr.SymbolType.Arg){let g=(0, vs.asOrNull)(r,Ou.FlowBase);if(g||(g=(0, u1.ClosestFlowBase)(r)),g&&g.hasParameters&&g.args){for(let y of g.args)if(((o=y.identifier)===null||o===void 0?void 0:o.name)===i?.name){r.Error(`${u} '${i}': name has already been used for a argument to ${g.identifier} on ${g.debugMetadata}`);return}}}};}get typeName(){return "Story"}PreProcessTopLevelObjects(e){super.PreProcessTopLevelObjects(e);let t=[];for(let r of e)if(r instanceof n1.IncludedFile){let i=r,a=e.indexOf(r);if(e.splice(a,1),i.includedStory){let s=[],o=i.includedStory;if(o.content!=null){for(let u of o.content)u instanceof Ou.FlowBase?t.push(u):s.push(u);s.push(new a1.Text(`
|
|
36
|
+
`)),e.splice(a,0,...s);}}continue}e.splice(0,0,...t);}};xu.Story=Pu;Pu.IsReservedKeyword=n=>{switch(n){case "true":case "false":case "not":case "return":case "else":case "VAR":case "CONST":case "temp":case "LIST":case "function":return true}return false};});var Db=w(Tu=>{Object.defineProperty(Tu,"__esModule",{value:true});Tu.StringExpression=void 0;var Eb=Be(),h1=St(),d1=En(),p1=oe(),Np=class n extends h1.Expression{get isSingleString(){return !(this.content.length!==1||!(this.content[0]instanceof d1.Text))}constructor(e){super(),this.GenerateIntoContainer=t=>{t.AddContent(Eb.ControlCommand.BeginString());for(let r of this.content)t.AddContent(r.runtimeObject);t.AddContent(Eb.ControlCommand.EndString());},this.toString=()=>{let t="";for(let r of this.content)t+=r;return t},this.AddContent(e);}get typeName(){return "String"}Equals(e){let t=(0, p1.asOrNull)(e,n);if(t===null||!this.isSingleString||!t.isSingleString)return false;let r=this.toString(),i=t.toString();return r===i}};Tu.StringExpression=Np;});var Ob=w(Xr=>{Object.defineProperty(Xr,"__esModule",{value:true});Xr.LegacyTag=Xr.Tag=void 0;var f1=ve(),Ab=Be(),Fp=class extends f1.ParsedObject{constructor(e,t=false){super(),this.GenerateRuntimeObject=()=>this.isStart?Ab.ControlCommand.BeginTag():Ab.ControlCommand.EndTag(),this.toString=()=>this.isStart?"#StartTag":"#EndTag",this.isStart=e,this.inChoice=t;}get typeName(){return "Tag"}};Xr.Tag=Fp;var m1=Hd(),Ip=class extends m1.Wrap{constructor(e){super(e);}get typeName(){return "Tag"}};Xr.LegacyTag=Ip;});var Pb=w(Nu=>{Object.defineProperty(Nu,"__esModule",{value:true});Nu.DefaultFileHandler=void 0;var kp=class{constructor(e){this.rootPath=e,this.ResolveInkFilename=()=>{throw Error("Can't resolve filename because no FileHandler was provided when instantiating the parser / compiler.")},this.LoadInkFileContents=()=>{throw Error("Can't load ink content because no FileHandler was provided when instantiating the parser / compiler.")};}};Nu.DefaultFileHandler=kp;});var $p=w(Vu=>{Object.defineProperty(Vu,"__esModule",{value:true});Vu.InkParser=void 0;var g1=Yy(),y1=Sa(),v1=Wh(),kt=cv(),Ne=Xi(),b1=$r(),C1=bv(),S1=ro(),bs=_d(),dt=vo(),_1=ao(),Fu=Bv(),w1=Wv(),sr=Wr(),Vp=Br(),E1=St(),D1=Mv(),xb=Gv(),Iu=ns(),A1=es(),O1=zv(),P1=Yo(),ku=Hv(),Tb=Zd(),x1=Uv(),T1=tp(),Nb=Xv(),N1=jo(),F1=ip(),I1=vd(),Fb=ve(),k1=Qn(),Ib=ld(),kb=Nd(),Te=Pd(),Ye=sp(),V1=op(),Vb=wb(),Cs=Db(),an=Qh(),Yr=Ob(),on=En(),Rb=Id(),Rp=Ld(),jp=Gr(),R1=qh(),xn=oe(),Ss=mo(),Zr=ja(),jb=Pr(),j1=Pb(),he=class n extends an.StringParser{get fileHandler(){if(!this._fileHandler)throw new Error("No FileHandler defined");return this._fileHandler}set fileHandler(e){this._fileHandler=e;}constructor(e,t=null,r=null,i=null,a=null){if(super(e),this.ParseStory=()=>{let s=this.StatementsAtLevel(Ye.StatementLevel.Top);return new Vb.Story(s,this._rootParser!==this)},this.SeparatedList=(s,o)=>{let u=this.Parse(s);if(u===null)return null;let l=[];l.push(u);do{let c=this.BeginRule();if(o()===null){this.FailRule(c);break}let f=this.Parse(s);if(f===null){this.FailRule(c);break}this.SucceedRule(c),l.push(f);}while(true);return l},this.CreateDebugMetadata=(s,o)=>{let u=new w1.DebugMetadata;return u.startLineNumber=(s?.lineIndex||0)+1,u.endLineNumber=o.lineIndex+1,u.startCharacterNumber=(s?.characterInLineIndex||0)+1,u.endCharacterNumber=o.characterInLineIndex+1,u.fileName=this._filename,u},this.RuleDidSucceed=(s,o,u)=>{let l=(0, xn.asOrNull)(s,Fb.ParsedObject);l&&(l.debugMetadata=this.CreateDebugMetadata(o,u));let c=Array.isArray(s)?s:null;if(c!==null)for(let f of c)(0, xn.asOrNull)(f,Fb.ParsedObject)&&(f.hasOwnDebugMetadata||(f.debugMetadata=this.CreateDebugMetadata(o,u)));let h=(0, xn.asOrNull)(s,Ss.Identifier);h!=null&&(h.debugMetadata=this.CreateDebugMetadata(o,u));},this.OnStringParserError=(s,o,u=0,l=false)=>{let h=l?"WARNING:":"ERROR:";if(this._filename!==null&&(h+=` '${this._filename}'`),h+=` line ${u+1}: ${s}`,this._externalErrorHandler!==null)this._externalErrorHandler(h,l?jb.ErrorType.Warning:jb.ErrorType.Error);else throw new Error(h)},this.AuthorWarning=()=>{this.Whitespace();let s=this.Parse(this.IdentifierWithMetadata);if(s===null||s.name!=="TODO")return null;this.Whitespace(),this.ParseString(":"),this.Whitespace();let o=this.ParseUntilCharactersFromString(`
|
|
37
|
+
\r`);return o?new y1.AuthorWarning(o):null},this.ExtendIdentifierCharacterRanges=s=>{let o=n.ListAllCharacterRanges();for(let u of o)s.AddCharacters(u.ToCharacterSet());},this._parsingChoice=false,this.Choice=()=>{let s=true,o=this.Interleave(this.OptionalExclude(this.Whitespace),this.String("*"));if(!o){if(o=this.Interleave(this.OptionalExclude(this.Whitespace),this.String("+")),o===null)return null;s=false;}let u=this.Parse(this.BracketedName);this.Whitespace(),u!=null&&this.Newline();let l=this.Parse(this.ChoiceCondition);if(this.Whitespace(),this._parsingChoice)throw new Error("Already parsing a choice - shouldn't have nested choices");this._parsingChoice=true;let c=null,h=this.Parse(this.MixedTextAndLogic);h&&(c=new dt.ContentList(h));let f=null,p=null,g=this.ParseString("[")!==null;if(g){this.EndTagIfNecessary(c);let v=this.Parse(this.MixedTextAndLogic);v!==null&&(f=new dt.ContentList(v)),this.Expect(this.String("]"),"closing ']' for weave-style option"),this.EndTagIfNecessary(f);let d=this.Parse(this.MixedTextAndLogic);d!==null&&(p=new dt.ContentList(d));}this.Whitespace(),this.EndTagIfNecessary(p??c);let y=this.Parse(this.MultiDivert);this._parsingChoice=false,this.Whitespace();let C=!c&&!p&&!f;if(C&&y===null&&this.Warning("Choice is completely empty. Interpretting as a default fallback choice. Add a divert arrow to remove this warning: * ->"),!c&&g&&!f&&this.Warning("Blank choice - if you intended a default fallback choice, use the `* ->` syntax"),p||(p=new dt.ContentList),this.EndTagIfNecessary(p),y!==null)for(let v of y){let d=(0, xn.asOrNull)(v,sr.Divert);d&&d.isEmpty||p.AddContent(v);}p.AddContent(new on.Text(`
|
|
38
|
+
`));let S=new b1.Choice(c,f,p);return u&&(S.identifier=u),S.indentationDepth=o.length,S.hasWeaveStyleInlineBrackets=g,S.condition=l,S.onceOnly=s,S.isInvisibleDefault=C,S},this.ChoiceCondition=()=>{let s=this.Interleave(this.ChoiceSingleCondition,this.ChoiceConditionsSpace);return s===null?null:s.length===1?s[0]:new I1.MultipleConditionExpression(s)},this.ChoiceConditionsSpace=()=>(this.Newline(),this.Whitespace(),an.ParseSuccess),this.ChoiceSingleCondition=()=>{if(this.ParseString("{")===null)return null;let s=this.Expect(this.Expression,"choice condition inside { }");return this.DisallowIncrement(s),this.Expect(this.String("}"),"closing '}' for choice condition"),s},this.Gather=()=>{let s=this.Parse(this.GatherDashes);if(s===null)return null;let o=Number(s),u=this.Parse(this.BracketedName),l=new A1.Gather(u,o);return this.Newline(),l},this.GatherDashes=()=>{this.Whitespace();let s=0;for(;this.ParseDashNotArrow()!==null;)s+=1,this.Whitespace();return s===0?null:s},this.ParseDashNotArrow=()=>{let s=this.BeginRule();return this.ParseString("->")===null&&this.ParseSingleCharacter()==="-"?this.SucceedRule(s):this.FailRule(s)},this.BracketedName=()=>{if(this.ParseString("(")===null)return null;this.Whitespace();let s=this.Parse(this.IdentifierWithMetadata);return s===null?null:(this.Whitespace(),this.Expect(this.String(")"),"closing ')' for bracketed name"),s)},this.InnerConditionalContent=s=>{if(s===void 0){let h=this.Parse(this.ConditionExpression),f=this.Parse(()=>this.InnerConditionalContent(h));return f===null?null:f}let o,u=s!==null,l=this.Parse(this.Newline)===null;if(l&&!u)return null;if(l)o=this.InlineConditionalBranches();else {if(o=this.MultilineConditionalBranches(),o===null){if(s){let h=this.StatementsAtLevel(Ye.StatementLevel.InnerBlock);if(h!==null){o=[new bs.ConditionalSingleBranch(h)];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),o.push(p));}}if(o===null)return null}else if(o.length===1&&o[0].isElse&&s){let h=new bs.ConditionalSingleBranch(null);h.isTrueBranch=true,o.unshift(h);}if(s){let h=false;for(let f=0;f<o.length;++f){let p=o[f],g=f===o.length-1;p.ownExpression?(p.matchingEquality=true,h=true):h&&g?(p.matchingEquality=true,p.isElse=true):!g&&o.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 h=0;h<o.length;++h){let f=o[h],p=h===o.length-1;if(f.ownExpression===null)if(p)f.isElse=true;else if(f.isElse){let g=o[o.length-1];g.isElse?this.ErrorWithParsedObject("Multiple 'else' cases. Can have a maximum of one, at the end.",g):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);}o.length===1&&o[0].ownExpression===null&&this.ErrorWithParsedObject("Condition block with no conditions",o[0]);}}if(o===null)return null;for(let h of o)h.isInline=l;return new S1.Conditional(s,o)},this.InlineConditionalBranches=()=>{let s=this.Interleave(this.MixedTextAndLogic,this.Exclude(this.String("|")),null,false);if(s===null||s.length===0)return null;let o=[];if(s.length>2)this.Error("Expected one or two alternatives separated by '|' in inline conditional");else {let u=new bs.ConditionalSingleBranch(s[0]);if(u.isTrueBranch=true,o.push(u),s.length>1){let l=new bs.ConditionalSingleBranch(s[1]);l.isElse=true,o.push(l);}}return o},this.MultilineConditionalBranches=()=>{this.MultilineWhitespace();let s=this.OneOrMore(this.SingleMultilineCondition);return s===null?null:(this.MultilineWhitespace(),s)},this.SingleMultilineCondition=()=>{if(this.Whitespace(),this.ParseString("->")!==null||this.ParseString("-")===null)return null;this.Whitespace();let s=null,o=this.Parse(this.ElseExpression)!==null;o||(s=this.Parse(this.ConditionExpression));let u=this.StatementsAtLevel(Ye.StatementLevel.InnerBlock);s===null&&u===null&&(this.Error("expected content for the conditional branch following '-'"),u=[new on.Text("")]),this.MultilineWhitespace();let l=new bs.ConditionalSingleBranch(u);return l.ownExpression=s,l.isElse=o,l},this.ConditionExpression=()=>{let s=this.Parse(this.Expression);return s===null||(this.DisallowIncrement(s),this.Whitespace(),this.ParseString(":")===null)?null:s},this.ElseExpression=()=>this.ParseString("else")===null||(this.Whitespace(),this.ParseString(":")===null)?null:an.ParseSuccess,this._nonTextPauseCharacters=null,this._nonTextEndCharacters=null,this._notTextEndCharactersChoice=null,this._notTextEndCharactersString=null,this.TrimEndWhitespace=(s,o)=>{if(s.length>0){let u=s.length-1,l=s[u];if(l instanceof on.Text){let c=l;c.text=c.text.replace(new RegExp(/[ \t]+$/g),""),o?c.text+=" ":c.text.length===0&&(s.splice(u,1),this.TrimEndWhitespace(s,false));}}},this.LineOfMixedTextAndLogic=()=>{this.Parse(this.Whitespace);let s=this.Parse(this.MixedTextAndLogic);if(!s||!s.length)return null;let o=s[0];return o&&o.text&&o.text.startsWith("return")&&this.Warning("Do you need a '~' before 'return'? If not, perhaps use a glue: <> (since it's lowercase) or rewrite somehow?"),s.length===0?null:(s[s.length-1]instanceof sr.Divert||this.TrimEndWhitespace(s,false),this.EndTagIfNecessary(s),s.length>0&&s[0]instanceof Yr.Tag&&s[0].isStart||s.push(new on.Text(`
|
|
39
|
+
`)),this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),s)},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 o=this.Interleave(this.Optional(this.ContentText),this.Optional(this.InlineLogicOrGlueOrStartTag));if(!this._parsingChoice){let u=this.Parse(this.MultiDivert);u!==null&&(o===null&&(o=[]),this.EndTagIfNecessary(o),this.TrimEndWhitespace(o,true),o.push(...u));}return o||null},this.ContentText=()=>this.ContentTextAllowingEscapeChar(),this.ContentTextAllowingEscapeChar=()=>{let s=null;do{let o=this.Parse(this.ContentTextNoEscape),u=this.ParseString("\\")!==null;if(u||o!==null){if(s===null&&(s=""),o!==null&&(s+=String(o)),u){let l=this.ParseSingleCharacter();s+=l;}}else break}while(true);return s!==null?new on.Text(s):null},this.ContentTextNoEscape=()=>{this._nonTextPauseCharacters===null&&(this._nonTextPauseCharacters=new Ne.CharacterSet("-<")),this._nonTextEndCharacters===null&&(this._nonTextEndCharacters=new Ne.CharacterSet(`{}|
|
|
40
|
+
\r\\#`),this._notTextEndCharactersChoice=new Ne.CharacterSet(this._nonTextEndCharacters),this._notTextEndCharactersChoice.AddCharacters("[]"),this._notTextEndCharactersString=new Ne.CharacterSet(this._nonTextEndCharacters),this._notTextEndCharactersString.AddCharacters('"'));let s=()=>this.OneOf([this.ParseDivertArrow,this.ParseThreadArrow,this.EndOfLine,this.Glue]),o=null;this.parsingStringExpression?o=this._notTextEndCharactersString:this._parsingChoice?o=this._notTextEndCharactersChoice:o=this._nonTextEndCharacters;let u=this.ParseUntil(s,this._nonTextPauseCharacters,o);return u!==null?u:null},this.MultiDivert=()=>{this.Whitespace();let s=[],o=this.Parse(this.StartThread);if(o)return s=[o],s;let u=this.Interleave(this.ParseDivertArrowOrTunnelOnwards,this.DivertIdentifierWithArguments);if(!u)return null;s=[],this.EndTagIfNecessary(s);for(let l=0;l<u.length;++l)if(l%2===0){if(u[l]==="->->"){l===0||l===u.length-1||l===u.length-2||this.Error("Tunnel onwards '->->' must only come at the begining or the start of a divert");let f=new Rb.TunnelOnwards;if(l<u.length-1){let p=(0, xn.asOrNull)(u[l+1],sr.Divert);f.divertAfter=p;}s.push(f);break}}else {let h=u[l];l<u.length-1&&(h.isTunnel=true),s.push(h);}if(s.length===0&&u.length===1){let l=new sr.Divert(null);l.isEmpty=true,s.push(l),this._parsingChoice||this.Error("Empty diverts (->) are only valid on choices");}return s},this.StartThread=()=>{if(this.Whitespace(),this.ParseThreadArrow()===null)return null;this.Whitespace();let s=this.Expect(this.DivertIdentifierWithArguments,"target for new thread",()=>new sr.Divert(null));return s.isThread=true,s},this.DivertIdentifierWithArguments=()=>{this.Whitespace();let s=this.Parse(this.DotSeparatedDivertPathComponents);if(!s)return null;this.Whitespace();let o=this.Parse(this.ExpressionFunctionCallArguments);this.Whitespace();let u=new k1.Path(s);return new sr.Divert(u,o)},this.SingleDivert=()=>{let s=this.Parse(this.MultiDivert);if(!s||s.length!==1||s[0]instanceof Rb.TunnelOnwards)return null;let u=s[0];return u.isTunnel?null:u},this.DotSeparatedDivertPathComponents=()=>this.Interleave(this.Spaced(this.IdentifierWithMetadata),this.Exclude(this.String("."))),this.ParseDivertArrowOrTunnelOnwards=()=>{let s=0;for(;this.ParseString("->")!==null;)s+=1;return s===0?null:s===1?"->":(s===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 s=this.ParseTempKeyword();this.Whitespace();let o=null;if(s?o=this.Expect(this.IdentifierWithMetadata,"variable name"):o=this.Parse(this.IdentifierWithMetadata),o===null)return null;this.Whitespace();let u=this.ParseString("+")!==null,l=this.ParseString("-")!==null;if(u&&l&&this.Error("Unexpected sequence '+-'"),this.ParseString("=")===null)return s&&this.Error("Expected '='"),null;let c=this.Expect(this.Expression,"value expression to be assigned");return u||l?new ku.IncDecExpression(o,c,u):new Rp.VariableAssignment({variableIdentifier:o,assignedExpression:c,isTemporaryNewDeclaration:s})},this.DisallowIncrement=s=>{s instanceof ku.IncDecExpression&&this.Error("Can't use increment/decrement here. It can only be used on a ~ line");},this.ParseTempKeyword=()=>{let s=this.BeginRule();return this.Parse(this.Identifier)==="temp"?(this.SucceedRule(s),true):(this.FailRule(s),false)},this.ReturnStatement=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!=="return")return null;this.Whitespace();let o=this.Parse(this.Expression);return new Ib.ReturnType(o)},this.Expression=(s=0)=>{this.Whitespace();let o=this.ExpressionUnary();if(o===null)return null;for(this.Whitespace();;){let u=this.BeginRule(),l=this.ParseInfixOperator();if(l!==null&&l.precedence>s){let c=`right side of '${l.type}' expression`,h=this.Expect(()=>this.ExpressionInfixRight(o,l),c);if(h===null)return this.FailRule(u),null;o=this.SucceedRule(u,h);continue}this.FailRule(u);break}return this.Whitespace(),o},this.ExpressionUnary=()=>{let s=this.Parse(this.ExpressionDivertTarget);if(s!==null)return s;let o=this.OneOf([this.String("-"),this.String("!")]);o===null&&(o=this.Parse(this.ExpressionNot)),this.Whitespace();let u=this.OneOf([this.ExpressionList,this.ExpressionParen,this.ExpressionFunctionCall,this.ExpressionVariableName,this.ExpressionLiteral]);if(u===null&&o!==null&&(u=this.ExpressionUnary()),u===null)return null;o!==null&&(u=R1.UnaryExpression.WithInner(u,o)),this.Whitespace();let l=this.OneOf([this.String("++"),this.String("--")]);if(l!==null){let c=l==="++";if(!(u instanceof jp.VariableReference))this.Error(`can only increment and decrement variables, but saw '${u}'.`);else {let h=u;u=new ku.IncDecExpression(h.identifier,c);}}return u},this.ExpressionNot=()=>{let s=this.Identifier();return s==="not"?s:null},this.ExpressionLiteral=()=>this.OneOf([this.ExpressionFloat,this.ExpressionInt,this.ExpressionBool,this.ExpressionString]),this.ExpressionDivertTarget=()=>{this.Whitespace();let s=this.Parse(this.SingleDivert);return !s||s&&s.isThread?null:(this.Whitespace(),new Vp.DivertTarget(s))},this.ExpressionInt=()=>{let s=this.ParseInt();return s===null?null:new Zr.NumberExpression(s,"int")},this.ExpressionFloat=()=>{let s=this.ParseFloat();return s===null?null:new Zr.NumberExpression(s,"float")},this.ExpressionString=()=>{if(this.ParseString('"')===null)return null;this.parsingStringExpression=true;let o=this.Parse(this.MixedTextAndLogic);return this.Expect(this.String('"'),"close quote for string expression"),this.parsingStringExpression=false,o===null?o=[new on.Text("")]:o.find(u=>u instanceof sr.Divert)&&this.Error("String expressions cannot contain diverts (->)"),new Cs.StringExpression(o)},this.ExpressionBool=()=>{let s=this.Parse(this.Identifier);return s==="true"?new Zr.NumberExpression(true,"bool"):s==="false"?new Zr.NumberExpression(false,"bool"):null},this.ExpressionFunctionCall=()=>{let s=this.Parse(this.IdentifierWithMetadata);if(s===null)return null;this.Whitespace();let o=this.Parse(this.ExpressionFunctionCallArguments);return o===null?null:new Iu.FunctionCall(s,o)},this.ExpressionFunctionCallArguments=()=>{if(this.ParseString("(")===null)return null;let s=this.Exclude(this.String(",")),o=this.Interleave(this.Expression,s);return o===null&&(o=[]),this.Whitespace(),this.Expect(this.String(")"),"closing ')' for function call"),o},this.ExpressionVariableName=()=>{let s=this.Interleave(this.IdentifierWithMetadata,this.Exclude(this.Spaced(this.String("."))));return s===null||Vb.Story.IsReservedKeyword(s[0].name)?null:new jp.VariableReference(s)},this.ExpressionParen=()=>{if(this.ParseString("(")===null)return null;let s=this.Parse(this.Expression);return s===null?null:(this.Whitespace(),this.Expect(this.String(")"),"closing parenthesis ')' for expression"),s)},this.ExpressionInfixRight=(s,o)=>{if(!s)return null;this.Whitespace();let u=this.Parse(()=>this.Expression(o.precedence));return u?new v1.BinaryExpression(s,u,o.type):null},this.ParseInfixOperator=()=>{for(let s of this._binaryOperators){let o=this.BeginRule();if(this.ParseString(s.type)!==null){if(s.requireWhitespace&&this.Whitespace()===null){this.FailRule(o);continue}return this.SucceedRule(o,s)}this.FailRule(o);}return null},this.ExpressionList=()=>{if(this.Whitespace(),this.ParseString("(")===null)return null;this.Whitespace();let s=this.SeparatedList(this.ListMember,this.Spaced(this.String(",")));return this.Whitespace(),this.ParseString(")")===null?null:new Nb.List(s)},this.ListMember=()=>{this.Whitespace();let s=this.Parse(this.IdentifierWithMetadata);if(s===null)return null;if(this.ParseString(".")!==null){let u=this.Expect(this.IdentifierWithMetadata,`element name within the set ${s}`);s.name+=`.${u?.name}`;}return this.Whitespace(),s},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=(s,o,u=false)=>{let l=new x1.InfixOperator(s,o,u);this._binaryOperators.push(l),this._maxBinaryOpLength=Math.max(this._maxBinaryOpLength,s.length);},this._openFilenames=[],this.IncludeStatement=()=>{if(this.Whitespace(),this.ParseString("INCLUDE")===null)return null;this.Whitespace();let s=this.Expect(()=>this.ParseUntilCharactersFromString(`
|
|
41
41
|
\r`),"filename for include statement");s=s.replace(new RegExp(/[ \t]+$/g),"");let o=this.fileHandler.ResolveInkFilename(s,this._filename);if(this.FilenameIsAlreadyOpen(o))return this.Error(`Recursive INCLUDE detected: '${o}' is already open.`),this.ParseUntilCharactersFromString(`\r
|
|
42
|
-
`),new
|
|
43
|
-
Error:${c}`);}return l!=null&&(u=new n(l,s,this._externalErrorHandler,this._rootParser,this.fileHandler).ParseStory()),this.RemoveOpenFilename(o),new
|
|
42
|
+
`),new Tb.IncludedFile(null);this.AddOpenFilename(o);let u=null,l="";try{l=this._rootParser.fileHandler.LoadInkFileContents(o,this._filename);}catch(c){this.Error(`Failed to load: '${s}'.
|
|
43
|
+
Error:${c}`);}return l!=null&&(u=new n(l,s,this._externalErrorHandler,this._rootParser,this.fileHandler).ParseStory()),this.RemoveOpenFilename(o),new Tb.IncludedFile(u)},this.FilenameIsAlreadyOpen=s=>this._rootParser._openFilenames.includes(s),this.AddOpenFilename=s=>{this._rootParser._openFilenames.push(s);},this.RemoveOpenFilename=s=>{this._rootParser._openFilenames.splice(this._rootParser._openFilenames.indexOf(s),1);},this.KnotDefinition=()=>{let s=this.Parse(this.KnotDeclaration);if(s===null)return null;this.Expect(this.EndOfLine,"end of line after knot name definition",this.SkipToNextLine);let o=()=>this.StatementsAtLevel(Ye.StatementLevel.Knot),u=this.Expect(o,"at least one line within the knot",this.KnotStitchNoContentRecoveryRule);return new T1.Knot(s.name,u,s.args,s.isFunction)},this.KnotDeclaration=()=>{if(this.Whitespace(),this.KnotTitleEquals()===null)return null;this.Whitespace();let s=this.Parse(this.IdentifierWithMetadata),o,u=s?.name==="function";u?(this.Expect(this.Whitespace,"whitespace after the 'function' keyword"),o=this.Parse(this.IdentifierWithMetadata)):o=s,o===null&&(this.Error(`Expected the name of the ${u?"function":"knot"}`),o=new Ss.Identifier("")),this.Whitespace();let l=this.Parse(this.BracketedKnotDeclArguments);return this.Whitespace(),this.Parse(this.KnotTitleEquals),new xb.FlowDecl(o,l,u)},this.KnotTitleEquals=()=>{let s=this.ParseCharactersFromString("=");return s===null||s.length<=1?null:s},this.StitchDefinition=()=>{let s=this.Parse(this.StitchDeclaration);if(s===null)return null;this.Expect(this.EndOfLine,"end of line after stitch name",this.SkipToNextLine);let o=()=>this.StatementsAtLevel(Ye.StatementLevel.Stitch),u=this.Expect(o,"at least one line within the stitch",this.KnotStitchNoContentRecoveryRule);return new V1.Stitch(s.name,u,s.args,s.isFunction)},this.StitchDeclaration=()=>{if(this.Whitespace(),this.ParseString("=")===null||this.ParseString("=")!==null)return null;this.Whitespace();let s=this.ParseString("function")!==null;s&&this.Whitespace();let o=this.Parse(this.IdentifierWithMetadata);if(o===null)return null;this.Whitespace();let u=this.Parse(this.BracketedKnotDeclArguments);return this.Whitespace(),new xb.FlowDecl(o,u,s)},this.KnotStitchNoContentRecoveryRule=()=>(this.ParseUntil(this.KnotDeclaration,new Ne.CharacterSet("="),null),[new on.Text("<ERROR IN FLOW>")]),this.BracketedKnotDeclArguments=()=>{if(this.ParseString("(")===null)return null;let s=this.Interleave(this.Spaced(this.FlowDeclArgument),this.Exclude(this.String(",")));return this.Expect(this.String(")"),"closing ')' for parameter list"),s===null&&(s=[]),s},this.FlowDeclArgument=()=>{let s=this.Parse(this.IdentifierWithMetadata);this.Whitespace();let o=this.ParseDivertArrow();this.Whitespace();let u=this.Parse(this.IdentifierWithMetadata);if(s==null&&u===null)return null;let l=new g1.Argument;return o!==null&&(l.isDivertTarget=true),s!==null&&s.name==="ref"?(u===null&&this.Error("Expected an parameter name after 'ref'"),l.identifier=u,l.isByReference=true):(l.isDivertTarget?l.identifier=u:l.identifier=s,l.identifier===null&&this.Error("Expected an parameter name"),l.isByReference=false),l},this.ExternalDeclaration=()=>{this.Whitespace();let s=this.Parse(this.IdentifierWithMetadata);if(s===null||s.name!="EXTERNAL")return null;this.Whitespace();let o=this.Expect(this.IdentifierWithMetadata,"name of external function")||new Ss.Identifier("");this.Whitespace();let u=this.Expect(this.BracketedKnotDeclArguments,`declaration of arguments for EXTERNAL, even if empty, i.e. 'EXTERNAL ${o}()'`);u===null&&(u=[]);let l=u.map(c=>{var h;return (h=c.identifier)===null||h===void 0?void 0:h.name}).filter(xn.filterUndef);return new D1.ExternalDeclaration(o,l)},this._identifierCharSet=null,this.LogicLine=()=>{if(this.Whitespace(),this.ParseString("~")===null)return null;this.Whitespace();let s=()=>this.OneOf([this.ReturnStatement,this.TempDeclarationOrAssignment,this.Expression]),o=this.Expect(s,"expression after '~'",this.SkipToNextLine);if(o===null)return new dt.ContentList;o instanceof E1.Expression&&!(o instanceof Iu.FunctionCall||o instanceof ku.IncDecExpression)&&this.Error(`Logic following a '~' can't be that type of expression. It can only be something like:
|
|
44
44
|
~ return
|
|
45
45
|
~ var x = blah
|
|
46
46
|
~ x++
|
|
47
|
-
~ myFunction()`);let u=(0,
|
|
48
|
-
`))),this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),o},this.VariableDeclaration=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!=="VAR")return null;this.Whitespace();let o=this.Expect(this.IdentifierWithMetadata,"variable name");this.Whitespace(),this.Expect(this.String("="),"the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)"),this.Whitespace();let l=this.Expect(this.Expression,"initial value for ");return l?(l instanceof
|
|
49
|
-
`)),new
|
|
50
|
-
\r`),this.ParseNewline(),
|
|
51
|
-
`||h=="\r"?c=true:c&&(l++,c=false);t+=l;}let r=n.FindAll(H1.Knot)(),i=n.FindAll(U1.Stitch)(),a=n.FindAll(G1.Choice)(),s=n.FindAll(J1.Gather)(u=>u.debugMetadata!=null),o=n.FindAll(z1.Divert)();return {words:t,knots:r.length,functions:r.filter(u=>u.isFunction).length,stitches:i.length,gathers:s.length,diverts:o.length-1,choices:a.length}}ku.GenerateStoryStats=X1;});var $0=E(Vu=>{Object.defineProperty(Vu,"__esModule",{value:true});Vu.JsonFileHandler=void 0;var jf=class{constructor(e){this.fileHierarchy=e,this.ResolveInkFilename=t=>{if(Object.keys(this.fileHierarchy).includes(t))return t;throw new Error(`Cannot locate ${t}. Are you trying a relative import ? This is not yet implemented.`)},this.LoadInkFileContents=t=>{if(Object.keys(this.fileHierarchy).includes(t))return this.fileHierarchy[t];throw new Error(`Cannot open ${t}.`)};}};Vu.JsonFileHandler=jf;});var L0=E(We=>{Object.defineProperty(We,"__esModule",{value:true});We.Compiler=We.Story=We.InkList=We.JsonFileHandler=We.StatementLevel=We.InkParser=We.CompilerOptions=void 0;var Y1=_h(),Z1=Hy(),Lf=Ar(),Q1=$f(),eN=ve(),tN=ae(),nN=R0(),rN=_h();Object.defineProperty(We,"CompilerOptions",{enumerable:true,get:function(){return rN.CompilerOptions}});var iN=$f();Object.defineProperty(We,"InkParser",{enumerable:true,get:function(){return iN.InkParser}});var sN=rf();Object.defineProperty(We,"StatementLevel",{enumerable:true,get:function(){return sN.StatementLevel}});var aN=$0();Object.defineProperty(We,"JsonFileHandler",{enumerable:true,get:function(){return aN.JsonFileHandler}});var j0=us();Object.defineProperty(We,"InkList",{enumerable:true,get:function(){return j0.InkList}});Object.defineProperty(We,"Story",{enumerable:true,get:function(){return j0.Story}});var qf=class{get errors(){return this._errors}get warnings(){return this._warnings}get authorMessages(){return this._authorMessages}get inputString(){return this._inputString}get options(){return this._options}get parsedStory(){if(!this._parsedStory)throw new Error;return this._parsedStory}get runtimeStory(){if(!this._runtimeStory)throw new Error("Compilation failed.");return this._runtimeStory}get parser(){if(!this._parser)throw new Error;return this._parser}get debugSourceRanges(){return this._debugSourceRanges}constructor(e,t=null){this._errors=[],this._warnings=[],this._authorMessages=[],this._parsedStory=null,this._runtimeStory=null,this._parser=null,this._debugSourceRanges=[],this.Compile=()=>(this._parser=new Q1.InkParser(this.inputString,this.options.sourceFilename||null,this.OnError,null,this.options.fileHandler),this._parsedStory=this.parser.ParseStory(),this.errors.length===0?(this.parsedStory.countAllVisits=this.options.countAllVisits,this._runtimeStory=this.parsedStory.ExportRuntime(this.OnError)):this._runtimeStory=null,this.runtimeStory),this.RetrieveDebugSourceForLatestContent=()=>{var r;for(let i of this.runtimeStory.state.outputStream){let a=(0, tN.asOrNull)(i,eN.StringValue);if(a!==null){let s=new Z1.DebugSourceRange(((r=a.value)===null||r===void 0?void 0:r.length)||0,a.debugMetadata,a.value||"unknown");this.debugSourceRanges.push(s);}}},this.GenerateStats=()=>this._parsedStory===null?null:(0, nN.GenerateStoryStats)(this._parsedStory),this.DebugMetadataForContentAtOffset=r=>{let i=0,a=null;for(let s of this.debugSourceRanges){if(s.debugMetadata!==null&&(a=s.debugMetadata),r>=i&&r<i+s.length)return a;i+=s.length;}return null},this.OnError=(r,i)=>{switch(i){case Lf.ErrorType.Author:this._authorMessages.push(r);break;case Lf.ErrorType.Warning:this._warnings.push(r);break;case Lf.ErrorType.Error:this._errors.push(r);break}this.options.errorHandler!==null&&this.options.errorHandler(r,i);},this._inputString=e,this._options=t||new Y1.CompilerOptions;}};We.Compiler=qf;});var Me;(n=>(n.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),n.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),n.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),n.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(Me||={});var x=class Z{static init(e){e.loadAssets&&(Z._loadAssets=e.loadAssets),e.soundOperation&&(Z._soundOperation=e.soundOperation),e.imageOperation&&(Z._imageOperation=e.imageOperation),e.videoOperation&&(Z._videoOperation=e.videoOperation),e.imageContainerOperation&&(Z._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(Z._textOperation=e.textOperation),e.canvasElementOperation&&(Z._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(Z._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(Z._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(Z._narrationOperation=e.narrationOperation),e.effectOperation&&(Z._effectOperation=e.effectOperation),e.animateOperation&&(Z._animateOperation=e.animateOperation),e.canvasOperation&&(Z._canvasOperation=e.canvasOperation),e.getLogichValue&&(Z._getLogichValue=e.getLogichValue),e.getConditionalStep&&(Z._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return Z._loadAssets}static _soundOperation=()=>{throw Me.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.")};static get soundOperation(){return Z._soundOperation}static _imageOperation=()=>{throw Me.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.")};static get imageOperation(){return Z._imageOperation}static _videoOperation=()=>{throw Me.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.")};static get videoOperation(){return Z._videoOperation}static _imageContainerOperation=()=>{throw Me.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.")};static get imageContainerOperation(){return Z._imageContainerOperation}static _textOperation=()=>{throw Me.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.")};static get textOperation(){return Z._textOperation}static _canvasElementOperation=()=>{throw Me.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.")};static get canvasElementOperation(){return Z._canvasElementOperation}static _setStorageValue=()=>{throw Me.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.")};static get setStorageValue(){return Z._setStorageValue}static _setInitialStorageValue=()=>{throw Me.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.")};static get setInitialStorageValue(){return Z._setInitialStorageValue}static _narrationOperation=()=>{throw Me.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.")};static get narrationOperation(){return Z._narrationOperation}static _effectOperation=()=>{throw Me.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.")};static get effectOperation(){return Z._effectOperation}static _animateOperation=()=>{throw Me.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.")};static get animateOperation(){return Z._animateOperation}static _canvasOperation=()=>{throw Me.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.")};static get canvasOperation(){return Z._canvasOperation}static _getLogichValue=()=>{throw Me.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.")};static get getLogichValue(){return Z._getLogichValue}static _getConditionalStep=()=>{throw Me.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.")};static get getConditionalStep(){return Z._getConditionalStep}};var Qr;(n=>{n.options={replaceRegex:/\[([^\]]+)\]/};let e=[];function t(l,c){e.unshift({fn:l,opts:c});}n.add=t;function r(l){let c=e.findIndex(h=>h.fn===l);c!==-1&&e.splice(c,1);}n.remove=r;function i(){return e.map(l=>l.opts)}n.info=i;function a(l,c){let h=e.filter(p=>(p.opts.type??"after-translation")===c.type);for(let p of h)l=u(l,p.fn,p.opts.validation);return l}n.replace=a;function s(l){let c=e.filter(h=>h.opts.i18nInterpolation);for(let h of c)l=o(l,h.fn,h.opts);return l}n.runI18nPreStep=s;function o(l,c,h){let{validation:p}=h,f=new RegExp(n.options.replaceRegex.source,"g"),g=[...l.matchAll(f)],y=new Set,C=[];for(let _ of g)y.has(_[1])||(y.add(_[1]),C.push(_[1]));for(let _ of C){if(p==="characterId"){if(!RegisteredCharacters.has(_))continue}else if(p!=="all"){if(p instanceof RegExp){if(!p.test(_))continue}else if(p instanceof ZodType&&!p.safeParse(_).success)continue}c(_)!==void 0&&(l.includes(`{{[${_}]}}`)||(l=l.replaceAll(`[${_}]`,`{{[${_}]}}`)));}return l}function u(l,c,h){let p=new RegExp(n.options.replaceRegex.source,"g"),f=[...l.matchAll(p)],g=new Set,y=[];for(let C of f)g.has(C[1])||(g.add(C[1]),y.push(C[1]));for(let C of y){if(h==="characterId"){if(!RegisteredCharacters.has(C))continue}else if(h!=="all"){if(h instanceof RegExp){if(!h.test(C))continue}else if(h instanceof ZodType&&!h.safeParse(C).success)continue}let _=c(C);_!==void 0&&(l=l.replaceAll(`[${C}]`,_));}return l}})(Qr||={});function rC(n,e={}){let t="";return n.values.forEach(r=>{if(typeof r=="string")t+=r;else {let i=x.getLogichValue(r,e);t+=`${i}`;}}),t}var Yf;(n=>{let e=u=>u;function t(u){return Array.isArray(u)?u.map(l=>r(`${l}`)):r(`${u}`)}n.t=t;function r(u){let l=u;return n.beforeToTranslate&&(l=(0, n.beforeToTranslate)(l)),l=Qr.replace(l,{type:"before-translation"}),l=e(l),n.afterToTranslate&&(l=(0, n.afterToTranslate)(l)),l=Qr.replace(l,{type:"after-translation"}),l}n.translate=r;function i(u){e=u;}n.setTranslate=i;function a(u,l,c){let{defaultValue:h="empty_string"}=c;typeof l=="string"&&(l=[l]),Array.isArray(l)&&l.forEach(p=>{let f=p;if(n.beforeToTranslate&&(f=(0, n.beforeToTranslate)(f)),h==="empty_string")u[f]===void 0&&(u[f]="");else if(h==="copy_key"){let g=p;n.beforeToTranslate&&(g=(0, n.beforeToTranslate)(g));let y=Qr.runI18nPreStep(g);y=Qr.replace(y,{type:"before-translation"}),u[f]=y;}});}function s(u,l=[]){if(typeof u=="object"&&u&&"type"in u)if(u.type==="ifelse")u.then&&s(u.then,l),u.else&&s(u.else,l);else if(u.type==="stepswitch"){if(u.elements)if(Array.isArray(u.elements))u.elements.forEach(c=>{s(c,l);});else if(u.elements.type==="ifelse"){let c=[];s(u.elements,c),c.forEach(h=>{l.push(...h);});}else if(u.elements.type==="stepswitch"){let c=[];s(u.elements,c),c.forEach(h=>{l.push(...h);});}else s(u.elements,l);}else u.type==="resulttocombine"?(u.firstItem&&s(u.firstItem,l),u.secondConditionalItem&&u.secondConditionalItem.forEach(c=>{s(c,l);})):l.push(u);else u&&l.push(u);return l}async function o(u,l={},c={}){let{defaultValue:h="copy_key",operationStringConvert:p}=c,f=u.map(async g=>{if(g.choices){let y=[];Array.isArray(g.choices)?y=[g.choices]:y=s(g.choices),y.forEach(C=>{C.forEach(_=>{if("type"in _){let v=[];_.type==="ifelse"||_.type==="stepswitch"?s(_,v):v=[_],v.map(d=>s(d.text)).forEach(d=>{Array.isArray(d)&&d.forEach(S=>{Array.isArray(S)?S.forEach(m=>{typeof m=="string"?a(l,m,{defaultValue:h}):s(m).forEach(b=>{Array.isArray(b)?b.forEach(w=>{typeof w=="string"&&a(l,w,{defaultValue:h});}):typeof b=="string"&&a(l,b,{defaultValue:h});});}):typeof S=="string"&&a(l,S,{defaultValue:h});});});}});});}if(g.dialogue){let y=[];Array.isArray(g.dialogue)?y=[g.dialogue]:y=s(g.dialogue),y.forEach(C=>{if(typeof C=="string")a(l,C,{defaultValue:h});else if("text"in C){let _=s(C.text);typeof _=="string"&&(_=[_]),_.forEach(v=>{typeof v=="string"?a(l,v,{defaultValue:h}):s(v).forEach(d=>{typeof d=="string"?a(l,d,{defaultValue:h}):Array.isArray(d)&&d.forEach(S=>{typeof S=="string"?a(l,S,{defaultValue:h}):s(S).forEach(m=>{typeof m=="string"&&a(l,m,{defaultValue:h});});});});});}});}if(g.operations)for(let y of g.operations){if(y.type==="operationtoconvert"&&p){let C=rC(y),_=await p(C,g,{});if(!_)return;y=_;}y.type==="text"&&y.operationType==="show"&&a(l,y.text,{defaultValue:h});}g.conditionalStep&&s(g.conditionalStep).forEach(y=>{Array.isArray(y)?o(y,l,c):o([y],l,c);});});return await Promise.all(f),l}n.generateJsonTranslation=o;})(Yf||={});var ht=Yf;async function Zf(n){let e=x.getLogichValue(n,{});if(e)switch(e.type){case "assets":switch(e.operationType){case "load":await Assets.load(e.aliases);break;case "lazyload":Assets.backgroundLoad(e.aliases);break}break;case "bundle":switch(e.operationType){case "load":await Assets.loadBundle(e.aliases);break;case "lazyload":Assets.backgroundLoadBundle(e.aliases);break}break}}var ee;(n=>(n.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),n.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),n.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),n.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(ee||={});async function Es(n,e,t){switch(t.type){case "fade":await showWithFade(e.alias,n,t.props,t.priority);break;case "dissolve":await showWithDissolve(e.alias,n,t.props,t.priority);break;case "movein":case "moveout":await moveIn(e.alias,n,t.props,t.priority);break;case "zoomin":case "zoomout":await zoomIn(e.alias,n,t.props,t.priority);break;case "pushin":case "pushout":await pushIn(e.alias,n,t.props,t.priority);break}}function ei(n){if(n.transition)switch(n.transition.type){case "fade":removeWithFade(n.alias,n.transition.props,n.transition.priority);break;case "dissolve":removeWithDissolve(n.alias,n.transition.props,n.transition.priority);break;case "movein":case "moveout":moveOut(n.alias,n.transition.props,n.transition.priority);break;case "zoomin":case "zoomout":zoomOut(n.alias,n.transition.props,n.transition.priority);break;case "pushin":case "pushout":pushOut(n.alias,n.transition.props,n.transition.priority);break}else canvas.remove(n.alias);}async function Qf(n){switch(n.operationType){case "show":if(n.transition){let e=new ImageSprite(n.props,n.url||n.alias);await Es(e,n,n.transition);}else await showImage(n.alias,n.url,n.props);break;case "edit":{let e=canvas.find(n.alias);e?n.props&&await e.setMemory({...e.memory,...n.props}):ee.error(`Image with alias ${n.alias} not found.`);break}case "remove":ei(n);break}}async function ep(n){switch(n.operationType){case "show":if(n.transition){let e=new VideoSprite(n.props,n.url||n.alias);await Es(e,n,n.transition);}else await showVideo(n.alias,n.url,n.props);break;case "edit":{let e=canvas.find(n.alias);e?n.props&&await e.setMemory({...e.memory,...n.props}):ee.error(`Video with alias ${n.alias} not found.`);break}case "remove":ei(n);break;case "pause":case "resume":{let e=canvas.find(n.alias);e?e.paused=n.operationType==="pause":ee.error(`Video with alias ${n.alias} not found.`);break}}}async function tp(n){switch(n.operationType){case "show":if(n.transition){let e=new ImageContainer(n.props,n.urls);await Es(e,n,n.transition);}else await showImageContainer(n.alias,n.urls,n.props);break;case "edit":{let e=canvas.find(n.alias);e?n.props&&await e.setMemory({...e.memory,...n.props}):ee.error(`ImageContainer with alias ${n.alias} not found.`);break}case "remove":ei(n);break}}async function np(n){switch(n.operationType){case "show":if(n.props=n.props||{},n.props.text=ht.t(n.text),n.transition){let e=new Text(n.props);await Es(e,n,n.transition);}else showText(n.alias,n.text,n.props);break;case "edit":{let e=canvas.find(n.alias);e?n.props&&await e.setMemory({...e.memory,...n.props}):ee.error(`Text with alias ${n.alias} not found.`);break}case "remove":ei(n);break}}async function rp(n){switch(n.operationType){case "edit":try{let e=canvas.find(n.alias);e?n.props&&e.setMemory({...e.memory,...n.props}):ee.error(`Canvas Element with alias ${n.alias} not found.`);}catch(e){ee.error(`There was an error while trying to edit the canvas element with alias ${n.alias}.`,e);}break;case "remove":ei(n);break}}function ip(n){n.operationType==="clear"&&canvas.removeAll();}async function sp(n){n.type==="shake"&&await shakeEffect(n.alias,n.props,n.priority);}function ap(n){switch(n.type){case "animate":canvas.animate(n.alias,n.keyframes,n.options,n.priority);break;case "animate-sequence":canvas.animate(n.alias,n.sequence,n.options,n.priority);break}}function op(n){switch(n.type){case "input":narration.input.request({type:n.valueType},n.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function up(n){switch(n.operationType){case "play":n.url?sound.play(n.alias,n.url,n.props):sound.play(n.alias,n.props);break;case "stop":switch(n.type){case "sound":sound.stop(n.alias);break;case "all":sound.stopAll();break}break;case "pause":switch(n.type){case "sound":sound.pause(n.alias);break;case "channel":sound.channels.find(n.alias).pauseAll();break;case "all":sound.pauseAll();break}break;case "resume":switch(n.type){case "sound":sound.resume(n.alias);break;case "channel":sound.channels.find(n.alias).resumeAll();break;case "all":sound.resumeAll();break}break;case "edit":Object.entries(n.props).forEach(([e,t])=>{let r=sound.find(n.alias);r&&(e==="volume"?r.volume.value=t:r.paused=t);});break}}var Wu="___param___",wC=class Q{static init(e){e.loadAssets&&(Q._loadAssets=e.loadAssets),e.soundOperation&&(Q._soundOperation=e.soundOperation),e.imageOperation&&(Q._imageOperation=e.imageOperation),e.videoOperation&&(Q._videoOperation=e.videoOperation),e.imageContainerOperation&&(Q._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(Q._textOperation=e.textOperation),e.canvasElementOperation&&(Q._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(Q._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(Q._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(Q._narrationOperation=e.narrationOperation),e.effectOperation&&(Q._effectOperation=e.effectOperation),e.animateOperation&&(Q._animateOperation=e.animateOperation),e.canvasOperation&&(Q._canvasOperation=e.canvasOperation),e.getLogichValue&&(Q._getLogichValue=e.getLogichValue),e.getConditionalStep&&(Q._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return Q._loadAssets}static _soundOperation=()=>{throw ee.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.")};static get soundOperation(){return Q._soundOperation}static _imageOperation=()=>{throw ee.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.")};static get imageOperation(){return Q._imageOperation}static _videoOperation=()=>{throw ee.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.")};static get videoOperation(){return Q._videoOperation}static _imageContainerOperation=()=>{throw ee.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.")};static get imageContainerOperation(){return Q._imageContainerOperation}static _textOperation=()=>{throw ee.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.")};static get textOperation(){return Q._textOperation}static _canvasElementOperation=()=>{throw ee.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.")};static get canvasElementOperation(){return Q._canvasElementOperation}static _setStorageValue=()=>{throw ee.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.")};static get setStorageValue(){return Q._setStorageValue}static _setInitialStorageValue=()=>{throw ee.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.")};static get setInitialStorageValue(){return Q._setInitialStorageValue}static _narrationOperation=()=>{throw ee.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.")};static get narrationOperation(){return Q._narrationOperation}static _effectOperation=()=>{throw ee.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.")};static get effectOperation(){return Q._effectOperation}static _animateOperation=()=>{throw ee.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.")};static get animateOperation(){return Q._animateOperation}static _canvasOperation=()=>{throw ee.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.")};static get canvasOperation(){return Q._canvasOperation}static _getLogichValue=()=>{throw ee.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.")};static get getLogichValue(){return Q._getLogichValue}static _getConditionalStep=()=>{throw ee.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.")};static get getConditionalStep(){return Q._getConditionalStep}};function DC(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let t=e[n.functionName];if(typeof t=="function"){let r=n.args.map(i=>wC.getLogichValue(i,e));return t(...r)}else ee.warn(`getLogichValue function ${n.functionName} not found in props`);}}function lp(n,e){let t=x.getLogichValue(n,e);return t&&typeof t=="object"&&"type"in t?x.getLogichValue(t,e):t}function cp(n,e={}){let t=lp(n.value,e);switch(n.storageType){case "flagStorage":storage.flags.set(n.key,n.value);break;case "storage":storage.set(n.key,t);break;case "tempstorage":storage.temp.set(n.key,t);break;case "params":{let r=storage.get(`${Wu}${narration.labels.opened.length-1}`)||[];r.length>n.key&&(r[n.key]=t),storage.temp.set(`${Wu}${narration.labels.opened.length-1}`,r);break}}}function hp(n,e={}){let t=lp(n.value,e);switch(n.storageType){case "storage":case "tempstorage":storage.default={[n.key]:t};break}}function dp(n,e={}){let t=fp(n,e);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return PC(t,e);case "arithmetic":case "arithmeticsingle":return AC(t,e);case "compare":case "union":return OC(t,e);case "function":return DC(t,e)}return t}function AC(n,e){let t=x.getLogichValue(n.leftValue,e);switch(n.type){case "arithmetic":{let r=x.getLogichValue(n.rightValue,e);switch(n.operator){case "*":return t*r;case "/":return t/r;case "+":return typeof t=="string"||typeof r=="string"?`${t}${r}`:Array.isArray(t)&&Array.isArray(r)?[...t,...r]:Array.isArray(t)?[...t,r]:Array.isArray(r)?[t,...r]:t+r;case "-":if(Array.isArray(t)&&Array.isArray(r))return t.filter(i=>!r.includes(i));if(Array.isArray(t))return t.filter(i=>i!==r);if(Array.isArray(r)){ee.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return t-r;case "%":return t%r;case "POW":return t**r;case "RANDOM":return narration.getRandomNumber(t,r);case "INTERSECTION":if(Array.isArray(t)&&Array.isArray(r))return t.filter(i=>r.includes(i));ee.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:ee.warn("getValueFromArithmeticOperations unknown operator",n);return}}case "arithmeticsingle":switch(n.operator){case "INT":return Number(t);case "FLOOR":return Math.floor(t)}break}}function PC(n,e){if(n&&typeof n=="object"&&"type"in n&&n.type==="value"&&n.storageOperationType==="get")switch(n.storageType){case "storage":case "tempstorage":return n.key==="_input_value_"?narration.input.value:storage.get(n.key);case "flagStorage":return storage.flags.get(n.key);case "label":return narration.queries.timesLabelOpened(n.label);case "choice":return narration.queries.timesChoiceMade(n.index);case "logic":return x.getLogichValue(n.operation,e);case "params":{let t=storage.get(`${Wu}${narration.labels.opened.length-1}`)||[];if(t&&t.length>n.key)return t[n.key];ee.warn("getValue params not found");return}}return n}function OC(n,e){if(!n)return false;if(typeof n!="object"||!("type"in n))return !!n;switch(n.type){case "compare":{let t=x.getLogichValue(n.leftValue,e),r=x.getLogichValue(n.rightValue,e);switch(n.operator){case "==":return Array.isArray(t)&&Array.isArray(r)?t.length===r.length&&t.every(i=>r.includes(i)):t===r;case "!=":return Array.isArray(t)&&Array.isArray(r)?t.length!==r.length||!t.every(i=>r.includes(i)):t!==r;case "<":return typeof t=="string"&&typeof r=="string"?t.localeCompare(r)<0:Array.isArray(t)&&Array.isArray(r)?t.length<r.length:t<r;case "<=":return typeof t=="string"&&typeof r=="string"?t.localeCompare(r)<=0:Array.isArray(t)&&Array.isArray(r)?t.length<=r.length:t<=r;case ">":return typeof t=="string"&&typeof r=="string"?t.localeCompare(r)>0:Array.isArray(t)&&Array.isArray(r)?t.length>r.length:t>r;case ">=":return typeof t=="string"&&typeof r=="string"?t.localeCompare(r)>=0:Array.isArray(t)&&Array.isArray(r)?t.length>=r.length:t>=r;case "CONTAINS":return Array.isArray(t)&&Array.isArray(r)?r.every(i=>t.includes(i)):Array.isArray(t)?t.includes(r):t.toString().includes(r.toString())}break}case "value":{let t=x.getLogichValue(n,e);return Array.isArray(t)?t.length>0:t&&typeof t=="object"?Object.keys(t).length>0:!!t}case "union":return xC(n,e)}return !!n}function xC(n,e){if(n.unionType==="not"){let r=dp(n.condition,e);return Array.isArray(r)?r.length===0:r&&typeof r=="object"?Object.keys(r).length===0:!r}let t=r=>x.getLogichValue(r,e)||false;return n.unionType==="and"?n.conditions.every(t):n.conditions.some(t)}function TC(n,e){return Math.floor(Math.random()*(e-n+1)+n)}function fp(n,e={}){if(Array.isArray(n)||!n)return n;if(n&&typeof n=="object"&&"type"in n)switch(n.type){case "resulttocombine":return NC(n,e);case "ifelse":return x.getLogichValue(n.condition,e)?x.getLogichValue(n.then,e):x.getLogichValue(n.else,e);case "stepswitch":{let t=x.getLogichValue(n.elements,e)||[];if(t.length===0){ee.error("getValueFromConditionalStatements elements.length === 0");return}switch(n.choiceType){case "random":{let r=TC(0,t.length-1);return x.getLogichValue(t[r],e)}case "loop":{let r=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return r>t.length-1?(r=r%t.length,x.getLogichValue(t[r],e)):x.getLogichValue(t[r],e)}case "sequential":{let r,i=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return n.end==="lastItem"&&(r=x.getLogichValue(t[t.length-1],e)),i>t.length-1?r:x.getLogichValue(t[i],e)}case "sequentialrandom":{let r=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:n.nestedId,onceOnly:true});if(r===void 0&&n.end==="lastItem"){let i=NarrationManagerStatic.getCurrentStepTimesCounterData(n.nestedId);if(!i?.usedRandomNumbers){ee.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let a=i.usedRandomNumbers[`0-${t.length-1}`];return x.getLogichValue(t[a[a.length-1]],e)}if(r===void 0){ee.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return x.getLogichValue(t[r],e)}}}}return n}function ws(n,e={}){if(n.conditionalStep){let t=createExportableElement(x.getLogichValue(n.conditionalStep,e));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 r={...n,conditionalStep:void 0,...t};return ws(r,e)}else narration.dialogGlue&&(narration.dialogGlue=false);}return n}function NC(n,e){let t=n.firstItem,r=(n.secondConditionalItem??[]).flatMap(a=>Array.isArray(a)?a.map(s=>x.getLogichValue(s,e)):[x.getLogichValue(a,e)]),i=t?[t,...r]:r;if(i.length===0){ee.warn("combinateResult toCheck.length === 0");return}if(typeof i[0]=="string")return ht.t(i);if(typeof i[0]=="object"){let a=i,s,o=false,u=a.map((v,d)=>{v=ws(v,e);let S=x.getLogichValue(v.dialogue,e)||"";return d===0?(s=x.getLogichValue(v.glueEnabled,e)||false,S):(typeof S=="object"&&"text"in S&&(S=`${S.character}: ${S.text}`),s===false&&o&&(S=`
|
|
52
|
-
|
|
53
|
-
${S}`),S&&(o=true),s=x.getLogichValue(v.glueEnabled,e)||false,S)}),l=x.getLogichValue(u[0],e),c=typeof l=="object"&&"character"in l?l.character:void 0,h=u.flatMap(v=>{let d;v&&typeof v=="object"&&"text"in v?d=v.text:d=v;let S;return Array.isArray(d)?S=d.map(m=>{let b=x.getLogichValue(m,e);return ht.t(`${b}`)}):S=x.getLogichValue(d,e)||"",ht.t(S)}),p=a.find(v=>v.end),f=a.find(v=>v.choices),g=false,y=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&(narration.dialogGlue=true),g=a[a.length-1].glueEnabled,y=a.reverse().find(v=>!(v.operations&&(!v.dialogue||!v.choices)))?.goNextStep);let C=a.find(v=>v.labelToOpen),_=[];return a.forEach(v=>{v.operations&&(_=[..._,...v.operations]);}),{dialogue:c?{character:c,text:h}:h,end:p?.end,choices:f?.choices,glueEnabled:g,goNextStep:y,labelToOpen:C?.labelToOpen,operations:_}}}var Ds;(n=>{let e=new Set;function t(a){e.add(a);}n.add=t;function r(){e.clear();}n.clear=r;function i(a,s={}){let o=c=>dp(c,s)??void 0,u=fp(a,s);if(e.size===0)return o(u);let l=o;for(let c of e){let h=l;l=p=>c(p,h)??void 0;}return l(u)}n.getLogichValue=i;})(Ds||={});var VC=Object.create,vp=Object.defineProperty,RC=Object.getOwnPropertyDescriptor,$C=Object.getOwnPropertyNames,jC=Object.getPrototypeOf,LC=Object.prototype.hasOwnProperty,mp=(n=>typeof On<"u"?On:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof On<"u"?On:e)[t]}):n)(function(n){if(typeof On<"u")return On.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')}),Cp=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),qC=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $C(e))!LC.call(n,i)&&i!==t&&vp(n,i,{get:()=>e[i],enumerable:!(r=RC(e,i))||r.enumerable});return n},BC=(n,e,t)=>(t=n!=null?VC(jC(n)):{},qC(vp(t,"default",{value:n,enumerable:true}),n)),WC=Cp((n,e)=>{(function(t,r){typeof n=="object"?e.exports=n=r():typeof define=="function"&&define.amd?define([],r):t.CryptoJS=r();})(n,function(){var t=t||(function(r,i){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof global<"u"&&global.crypto&&(a=global.crypto),!a&&typeof mp=="function")try{a=mp("crypto");}catch{}var s=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function v(){}return function(d){var S;return v.prototype=d,S=new v,v.prototype=null,S}})(),u={},l=u.lib={},c=l.Base=(function(){return {extend:function(v){var d=o(this);return v&&d.mixIn(v),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var v=this.extend();return v.init.apply(v,arguments),v},init:function(){},mixIn:function(v){for(var d in v)v.hasOwnProperty(d)&&(this[d]=v[d]);v.hasOwnProperty("toString")&&(this.toString=v.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=l.WordArray=c.extend({init:function(v,d){v=this.words=v||[],d!=i?this.sigBytes=d:this.sigBytes=v.length*4;},toString:function(v){return (v||f).stringify(this)},concat:function(v){var d=this.words,S=v.words,m=this.sigBytes,b=v.sigBytes;if(this.clamp(),m%4)for(var w=0;w<b;w++){var P=S[w>>>2]>>>24-w%4*8&255;d[m+w>>>2]|=P<<24-(m+w)%4*8;}else for(var O=0;O<b;O+=4)d[m+O>>>2]=S[O>>>2];return this.sigBytes+=b,this},clamp:function(){var v=this.words,d=this.sigBytes;v[d>>>2]&=4294967295<<32-d%4*8,v.length=r.ceil(d/4);},clone:function(){var v=c.clone.call(this);return v.words=this.words.slice(0),v},random:function(v){for(var d=[],S=0;S<v;S+=4)d.push(s());return new h.init(d,v)}}),p=u.enc={},f=p.Hex={stringify:function(v){for(var d=v.words,S=v.sigBytes,m=[],b=0;b<S;b++){var w=d[b>>>2]>>>24-b%4*8&255;m.push((w>>>4).toString(16)),m.push((w&15).toString(16));}return m.join("")},parse:function(v){for(var d=v.length,S=[],m=0;m<d;m+=2)S[m>>>3]|=parseInt(v.substr(m,2),16)<<24-m%8*4;return new h.init(S,d/2)}},g=p.Latin1={stringify:function(v){for(var d=v.words,S=v.sigBytes,m=[],b=0;b<S;b++){var w=d[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(w));}return m.join("")},parse:function(v){for(var d=v.length,S=[],m=0;m<d;m++)S[m>>>2]|=(v.charCodeAt(m)&255)<<24-m%4*8;return new h.init(S,d)}},y=p.Utf8={stringify:function(v){try{return decodeURIComponent(escape(g.stringify(v)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(v){return g.parse(unescape(encodeURIComponent(v)))}},C=l.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(v){typeof v=="string"&&(v=y.parse(v)),this._data.concat(v),this._nDataBytes+=v.sigBytes;},_process:function(v){var d,S=this._data,m=S.words,b=S.sigBytes,w=this.blockSize,P=w*4,O=b/P;v?O=r.ceil(O):O=r.max((O|0)-this._minBufferSize,0);var k=O*w,z=r.min(k*4,b);if(k){for(var ie=0;ie<k;ie+=w)this._doProcessBlock(m,ie);d=m.splice(0,k),S.sigBytes-=z;}return new h.init(d,z)},clone:function(){var v=c.clone.call(this);return v._data=this._data.clone(),v},_minBufferSize:0});l.Hasher=C.extend({cfg:c.extend(),init:function(v){this.cfg=this.cfg.extend(v),this.reset();},reset:function(){C.reset.call(this),this._doReset();},update:function(v){return this._append(v),this._process(),this},finalize:function(v){v&&this._append(v);var d=this._doFinalize();return d},blockSize:16,_createHelper:function(v){return function(d,S){return new v.init(S).finalize(d)}},_createHmacHelper:function(v){return function(d,S){return new _.HMAC.init(v,S).finalize(d)}}});var _=u.algo={};return u})(Math);return t});}),MC=Cp((n,e)=>{(function(t,r){typeof n=="object"?e.exports=n=r(WC()):typeof define=="function"&&define.amd?define(["./core"],r):r(t.CryptoJS);})(n,function(t){return (function(){var r=t,i=r.lib,a=i.WordArray,s=i.Hasher,o=r.algo,u=[],l=o.SHA1=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,h){for(var p=this._hash.words,f=p[0],g=p[1],y=p[2],C=p[3],_=p[4],v=0;v<80;v++){if(v<16)u[v]=c[h+v]|0;else {var d=u[v-3]^u[v-8]^u[v-14]^u[v-16];u[v]=d<<1|d>>>31;}var S=(f<<5|f>>>27)+_+u[v];v<20?S+=(g&y|~g&C)+1518500249:v<40?S+=(g^y^C)+1859775393:v<60?S+=(g&y|g&C|y&C)-1894007588:S+=(g^y^C)-899497514,_=C,C=y,y=g<<30|g>>>2,g=f,f=S;}p[0]=p[0]+f|0,p[1]=p[1]+g|0,p[2]=p[2]+y|0,p[3]=p[3]+C|0,p[4]=p[4]+_|0;},_doFinalize:function(){var c=this._data,h=c.words,p=this._nDataBytes*8,f=c.sigBytes*8;return h[f>>>5]|=128<<24-f%32,h[(f+64>>>9<<4)+14]=Math.floor(p/4294967296),h[(f+64>>>9<<4)+15]=p,c.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var c=s.clone.call(this);return c._hash=this._hash.clone(),c}});r.SHA1=s._createHelper(l),r.HmacSHA1=s._createHmacHelper(l);})(),t.SHA1});}),gp="___param___",Se;(n=>(n.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),n.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),n.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),n.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(Se||={});var GC=class te{static init(e){e.loadAssets&&(te._loadAssets=e.loadAssets),e.soundOperation&&(te._soundOperation=e.soundOperation),e.imageOperation&&(te._imageOperation=e.imageOperation),e.videoOperation&&(te._videoOperation=e.videoOperation),e.imageContainerOperation&&(te._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(te._textOperation=e.textOperation),e.canvasElementOperation&&(te._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(te._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(te._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(te._narrationOperation=e.narrationOperation),e.effectOperation&&(te._effectOperation=e.effectOperation),e.animateOperation&&(te._animateOperation=e.animateOperation),e.canvasOperation&&(te._canvasOperation=e.canvasOperation),e.getLogichValue&&(te._getLogichValue=e.getLogichValue),e.getConditionalStep&&(te._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return te._loadAssets}static _soundOperation=()=>{throw Se.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.")};static get soundOperation(){return te._soundOperation}static _imageOperation=()=>{throw Se.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.")};static get imageOperation(){return te._imageOperation}static _videoOperation=()=>{throw Se.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.")};static get videoOperation(){return te._videoOperation}static _imageContainerOperation=()=>{throw Se.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.")};static get imageContainerOperation(){return te._imageContainerOperation}static _textOperation=()=>{throw Se.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.")};static get textOperation(){return te._textOperation}static _canvasElementOperation=()=>{throw Se.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.")};static get canvasElementOperation(){return te._canvasElementOperation}static _setStorageValue=()=>{throw Se.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.")};static get setStorageValue(){return te._setStorageValue}static _setInitialStorageValue=()=>{throw Se.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.")};static get setInitialStorageValue(){return te._setInitialStorageValue}static _narrationOperation=()=>{throw Se.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.")};static get narrationOperation(){return te._narrationOperation}static _effectOperation=()=>{throw Se.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.")};static get effectOperation(){return te._effectOperation}static _animateOperation=()=>{throw Se.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.")};static get animateOperation(){return te._animateOperation}static _canvasOperation=()=>{throw Se.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.")};static get canvasOperation(){return te._canvasOperation}static _getLogichValue=()=>{throw Se.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.")};static get getLogichValue(){return te._getLogichValue}static _getConditionalStep=()=>{throw Se.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.")};static get getConditionalStep(){return te._getConditionalStep}};function zC(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let t=e[n.functionName];if(typeof t=="function"){let r=n.args.map(i=>GC.getLogichValue(i,e));return t(...r)}else Se.warn(`getLogichValue function ${n.functionName} not found in props`);}}function JC(n,e={}){let t="";return n.values.forEach(r=>{if(typeof r=="string")t+=r;else {let i=x.getLogichValue(r,e);t+=`${i}`;}}),t}async function bp(n,e,t){let r=x.getLogichValue(n,e);if(r)switch(r.type){case "sound":x.soundOperation(r);break;case "assets":case "bundle":await x.loadAssets(r);break;case "image":await x.imageOperation(r);break;case "video":await x.videoOperation(r);break;case "imagecontainer":await x.imageContainerOperation(r);break;case "text":await x.textOperation(r);break;case "canvaselement":await x.canvasElementOperation(r);break;case "canvas":x.canvasOperation(r);break;case "value":x.setStorageValue(r,e);break;case "operationtoconvert":if(t){let i=JC(r,e),a=await t(i);a&&await bp(a,e,t);}break;case "input":case "dialogue":x.narrationOperation(r);break;case "shake":await x.effectOperation(r);break;case "animate":case "animate-sequence":x.animateOperation(r);break;case "function":await zC(r,e);break}}function yp(n){let e=x.getLogichValue(n,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&x.setInitialStorageValue(e);}var HC=BC(MC()),UC=class extends LabelAbstract{constructor(n,e,t,r={}){t||(t={}),t.onLoadingLabel=async()=>{for(let i of e){let a;if(typeof i=="function"?a=i():a=i,a=x.getConditionalStep(a),a.operations)try{let s=a.operations.map(o=>x.loadAssets(o));await Promise.all(s);}catch(s){Se.error("The operation in the onLoadingLabel function of the label has an error:",s);}}},super(n,t),this._steps=e,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(n=>this.stepConverter(n))}get stepCount(){return this._steps.length}getStepById(n){if(n<0||n>=this._steps.length)return;let e=this._steps[n];return this.stepConverter(e)}operationStringConvert;skipEmptyDialogs=false;getStepSha(n){if(n<0||n>=this.steps.length)return;let e=this._steps[n];return (0, HC.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(n,e){let t="";if(Array.isArray(n)){let r=[];n.forEach(i=>{if(typeof i=="string")r.push(i);else if(i&&typeof i=="object"){let a=x.getLogichValue(i,e);a?(a&&!Array.isArray(a)&&typeof a=="object"&&(a=x.getLogichValue(a,e)||""),Array.isArray(a)?r=r.map(s=>`${s}`).concat(a):r.push(`${a}`)):r.push(`${i}`);}else r.push(`${i}`);}),t=r;}else {let r=x.getLogichValue(n,e);r&&!Array.isArray(r)&&typeof r=="object"&&(r=x.getLogichValue(r,e)),r&&Array.isArray(r)?t=r.map(i=>`${i}`):t=`${r}`;}return t}getDialogue(n,e){if(n==null)return;let t=x.getLogichValue(n,e);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:ht.t(this.getDialogueText(t.text,e))}:ht.t(this.getDialogueText(t,e))}getChoices(n,e){return x.getLogichValue(n,e)?.map(t=>x.getLogichValue(t,e)).filter(t=>t!==void 0)}stepConverter(n){return async e=>{let t=typeof n=="function"?n():n;t=createExportableElement(t),t=x.getConditionalStep(t,e);let r=this.operationStringConvert?p=>this.operationStringConvert(p,t,e):void 0,{operations:i=[]}=t;for(let p of i)await bp(p,e,r);let{labelToOpen:a=[]}=t,s=this.getChoices(t.choices,e),o=x.getLogichValue(t.glueEnabled,e),u=this.getDialogue(t.dialogue,e),l=[];Array.isArray(a)||(a=[a]),a.forEach(p=>{let f=x.getLogichValue(p,e);f&&l.push(f);});let c=x.getLogichValue(t.goNextStep,e),h=x.getLogichValue(t.end,e);if(s){let p=s.map(f=>{let g="";if(Array.isArray(f.text)){let y=[];f.text.forEach(C=>{if(typeof C=="string")y.push(ht.t(C));else if(C&&typeof C=="object"){let _=x.getLogichValue(C,e);_&&!Array.isArray(_)&&typeof _=="object"&&(_=x.getLogichValue(_,e)||""),_&&(Array.isArray(_)?y=y.concat(ht.t(_)):y.push(ht.t(_)));}}),g=y;}else typeof f.text=="string"&&(g=ht.t(f.text));return {label:f.label,text:g,props:f.props,type:f.type,oneTime:f.oneTime,onlyHaveNoChoice:f.onlyHaveNoChoice,autoSelect:f.autoSelect}});narration.choices=p;}else narration.choices=void 0;u!==void 0&&(narration.dialogue=u,this.skipEmptyDialogs&&typeof u=="string"&&(u===""||RegExp(/^\s+$/).test(u))&&(c=true)),o?narration.dialogGlue=true:o===false&&(narration.dialogGlue=false);for(let p of l){let f=p.label;typeof f=="object"&&(f=x.getLogichValue(f,e)||"");let g=p.params?.map(y=>x.getLogichValue(y,e));e={...e,...p.props},p.type==="jump"?(narration.labels.opened.length>0&&narration.labels.closeCurrent(),storage.temp.set(`${gp}${narration.labels.opened.length}`,g),await narration.call(f,e)):(storage.temp.set(`${gp}${narration.labels.opened.length}`,g),await narration.call(f,e));}h==="game_end"?(narration.labels.closeAll(),await narration.continue(e,{runNow:true})):h==="label_end"&&narration.labels.closeCurrent(),c&&await narration.continue(e,{runNow:true});}}};async function JN(n,e={}){if(!Array.isArray(n))if(typeof n=="object"||typeof n=="string")n=[n];else {Se.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let t=n.map(a=>{if(typeof a=="string")try{return JSON.parse(a)}catch(s){return Se.error("Error parsing imported Pixi'VN JSON",s),{}}return a}),r=t.map(async a=>{if(a.initialOperations)for(let s of a.initialOperations)s.type==="value"&&(typeof s.value!="object"||!s.value||!("type"in s.value))&&yp(s);return Promise.resolve()});await Promise.all(r);let i=t.map(async a=>{if(a.initialOperations)for(let s of a.initialOperations)(s.type!=="value"||s.type==="value"&&typeof s.value=="object"&&s.value&&"type"in s.value)&&yp(s);if(a.labels){let s=a.labels;for(let o in s)try{let u=s[o],l=new UC(o,u,void 0,e);RegisteredLabels.add(l);}catch(u){Se.error(`Error creating JSON label ${o}`,u);}}return Promise.resolve()});await Promise.all(i);}function QN(){x.init({animateOperation:ap,canvasElementOperation:rp,canvasOperation:ip,effectOperation:sp,imageContainerOperation:tp,imageOperation:Qf,textOperation:np,narrationOperation:op,loadAssets:Zf,soundOperation:up,videoOperation:ep,setStorageValue:cp,setInitialStorageValue:hp,getLogichValue:Ds.getLogichValue,getConditionalStep:ws});}var X;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...s)))(X||={});var XC=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,YC=/[\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]/,ZC=/[\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]/,Mu={Space_Separator:XC,ID_Start:YC,ID_Continue:ZC},be={isSpaceSeparator(n){return typeof n=="string"&&Mu.Space_Separator.test(n)},isIdStartChar(n){return typeof n=="string"&&(n>="a"&&n<="z"||n>="A"&&n<="Z"||n==="$"||n==="_"||Mu.ID_Start.test(n))},isIdContinueChar(n){return typeof n=="string"&&(n>="a"&&n<="z"||n>="A"&&n<="Z"||n>="0"&&n<="9"||n==="$"||n==="_"||n==="\u200C"||n==="\u200D"||Mu.ID_Continue.test(n))},isDigit(n){return typeof n=="string"&&/[0-9]/.test(n)},isHexDigit(n){return typeof n=="string"&&/[0-9A-Fa-f]/.test(n)}},zu,ze,Xt,Ps,on,At,Ae,Uu,ni,QC=function(e,t){zu=String(e),ze="start",Xt=[],Ps=0,on=1,At=0,Ae=void 0,Uu=void 0,ni=void 0;do Ae=eb(),rb[ze]();while(Ae.type!=="eof");return typeof t=="function"?Ju({"":ni},"",t):ni};function Ju(n,e,t){let r=n[e];if(r!=null&&typeof r=="object")if(Array.isArray(r))for(let i=0;i<r.length;i++){let a=String(i),s=Ju(r,a,t);s===void 0?delete r[a]:Object.defineProperty(r,a,{value:s,writable:true,enumerable:true,configurable:true});}else for(let i in r){let a=Ju(r,i,t);a===void 0?delete r[i]:Object.defineProperty(r,i,{value:a,writable:true,enumerable:true,configurable:true});}return t.call(n,e,r)}var L,R,ti,Kt,J;function eb(){for(L="default",R="",ti=false,Kt=1;;){J=Yt();let n=Sp[L]();if(n)return n}}function Yt(){if(zu[Ps])return String.fromCodePoint(zu.codePointAt(Ps))}function A(){let n=Yt();return n===`
|
|
54
|
-
`?(
|
|
55
|
-
`:case "\r":case "\u2028":case "\u2029":A();return;case "/":A(),L="comment";return;case void 0:return A(),
|
|
56
|
-
`:case "\r":case "\u2028":case "\u2029":A(),L="default";return;case void 0:return A(),
|
|
57
|
-
`:case "\r":throw
|
|
58
|
-
`;case "r":return A(),"\r";case "t":return A()," ";case "v":return A(),"\v";case "0":if(A(),
|
|
59
|
-
`:case "\u2028":case "\u2029":return A(),"";case "\r":return A(),
|
|
60
|
-
`&&A(),"";case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":throw
|
|
61
|
-
`+a;
|
|
62
|
-
`+a+
|
|
63
|
-
`+C+"}";}}return i.pop(),a=C,d}function
|
|
64
|
-
`+a,S
|
|
65
|
-
`+a+
|
|
66
|
-
`+C+"]";}return i.pop(),a=C,v}},
|
|
47
|
+
~ myFunction()`);let u=(0, xn.asOrNull)(o,Iu.FunctionCall);return u&&(u.shouldPopReturnedValue=true),o.Find(Iu.FunctionCall)()!==null&&(o=new dt.ContentList(o,new on.Text(`
|
|
48
|
+
`))),this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),o},this.VariableDeclaration=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!=="VAR")return null;this.Whitespace();let o=this.Expect(this.IdentifierWithMetadata,"variable name");this.Whitespace(),this.Expect(this.String("="),"the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)"),this.Whitespace();let l=this.Expect(this.Expression,"initial value for ");return l?(l instanceof Zr.NumberExpression||l instanceof Cs.StringExpression||l instanceof Vp.DivertTarget||l instanceof jp.VariableReference||l instanceof Nb.List||this.Error("initial value for a variable must be a number, constant, list or divert target"),this.Parse(this.ListElementDefinitionSeparator)!==null?this.Error("Unexpected ','. If you're trying to declare a new list, use the LIST keyword, not VAR"):l instanceof Cs.StringExpression&&(l.isSingleString||this.Error("Constant strings cannot contain any logic.")),new Rp.VariableAssignment({assignedExpression:l,isGlobalDeclaration:true,variableIdentifier:o})):null},this.ListDeclaration=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!="LIST")return null;this.Whitespace();let o=this.Expect(this.IdentifierWithMetadata,"list name");this.Whitespace(),this.Expect(this.String("="),"the '=' for an assignment of the list definition"),this.Whitespace();let u=this.Expect(this.ListDefinition,"list item names");return u?(u.identifier=new Ss.Identifier(o.name),new Rp.VariableAssignment({variableIdentifier:o,listDef:u})):null},this.ListDefinition=()=>{this.AnyWhitespace();let s=this.SeparatedList(this.ListElementDefinition,this.ListElementDefinitionSeparator);return s===null?null:new N1.ListDefinition(s)},this.ListElementDefinitionSeparator=()=>(this.AnyWhitespace(),this.ParseString(",")===null?null:(this.AnyWhitespace(),",")),this.ListElementDefinition=()=>{let s=this.ParseString("(")!==null,o=s;this.Whitespace();let u=this.Parse(this.IdentifierWithMetadata);if(u===null)return null;this.Whitespace(),s&&this.ParseString(")")!=null&&(o=false,this.Whitespace());let l=null;if(this.ParseString("=")!==null){this.Whitespace();let c=this.Expect(this.ExpressionInt,"value to be assigned to list item");c!==null&&(l=c.value),o&&(this.Whitespace(),this.ParseString(")")!==null&&(o=false));}return o&&this.Error("Expected closing ')'"),new F1.ListElementDefinition(u,s,l)},this.ConstDeclaration=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!=="CONST")return null;this.Whitespace();let o=this.Expect(this.IdentifierWithMetadata,"constant name");this.Whitespace(),this.Expect(this.String("="),"the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)"),this.Whitespace();let u=this.Expect(this.Expression,"initial value for ");return u instanceof Zr.NumberExpression||u instanceof Vp.DivertTarget||u instanceof Cs.StringExpression?u instanceof Cs.StringExpression&&(u.isSingleString||this.Error("Constant strings cannot contain any logic.")):this.Error("initial value for a constant must be a number or divert target"),new _1.ConstantDeclaration(o,u)},this.InlineLogicOrGlueOrStartTag=()=>this.OneOf([this.InlineLogic,this.Glue,this.StartTag]),this.Glue=()=>this.ParseString("<>")!==null?new O1.Glue(new P1.Glue):null,this.InlineLogic=()=>{if(this.ParseString("{")===null)return null;let s=this.parsingStringExpression,o=this.tagActive;this.Whitespace();let u=this.Expect(this.InnerLogic,"some kind of logic, conditional or sequence within braces: { ... }");if(u===null)return this.parsingStringExpression=s,null;this.DisallowIncrement(u);let l=(0, xn.asOrNull)(u,dt.ContentList);return l||(l=new dt.ContentList(u)),this.Whitespace(),this.Expect(this.String("}"),"closing brace '}' for inline logic"),this.parsingStringExpression=s,o||this.EndTagIfNecessary(l),l},this.InnerLogic=()=>{this.Whitespace();let s=this.ParseObject(this.SequenceTypeAnnotation);if(s!==null){let l=this.Expect(this.InnerSequenceObjects,"sequence elements (for cycle/stoping etc)");return l===null?null:new kb.Sequence(l,s)}let o=this.Parse(this.ConditionExpression);if(o)return this.Expect(()=>this.InnerConditionalContent(o),"conditional content following query");let u=[this.InnerConditionalContent,this.InnerSequence,this.InnerExpression];for(let l of u){let c=this.BeginRule(),h=this.ParseObject(l);if(h)if(this.Peek(this.Spaced(this.String("}")))===null)this.FailRule(c);else return this.SucceedRule(c,h);else this.FailRule(c);}return null},this.InnerExpression=()=>{let s=this.Parse(this.Expression);return s&&(s.outputWhenComplete=true),s},this.IdentifierWithMetadata=()=>{let s=this.Identifier();return s===null?null:new Ss.Identifier(s)},this.Identifier=()=>{let s=this.ParseCharactersFromCharSet(this.identifierCharSet);if(s===null)return null;let o=true;for(let u of s)if(!(u>="0"&&u<="9")){o=false;break}return o?null:s},this._sequenceTypeSymbols=new Ne.CharacterSet("!&~$"),this.InnerSequence=()=>{this.Whitespace();let s=Te.SequenceType.Stopping,o=this.Parse(this.SequenceTypeAnnotation);o!==null&&(s=o);let u=this.Parse(this.InnerSequenceObjects);return u===null||u.length<=1?null:new kb.Sequence(u,s)},this.SequenceTypeAnnotation=()=>{let s=this.Parse(this.SequenceTypeSymbolAnnotation);if(s===null&&(s=this.Parse(this.SequenceTypeWordAnnotation)),s===null)return null;switch(s){case Te.SequenceType.Once:case Te.SequenceType.Cycle:case Te.SequenceType.Stopping:case Te.SequenceType.Shuffle:case Te.SequenceType.Shuffle|Te.SequenceType.Stopping:case Te.SequenceType.Shuffle|Te.SequenceType.Once:break;default:return this.Error(`Sequence type combination not supported: ${s}`),Te.SequenceType.Stopping}return s},this.SequenceTypeSymbolAnnotation=()=>{this._sequenceTypeSymbols===null&&(this._sequenceTypeSymbols=new Ne.CharacterSet("!&~$ "));let s=0,o=this.ParseCharactersFromCharSet(this._sequenceTypeSymbols);if(o===null)return null;for(let u of o)switch(u){case "!":s|=Te.SequenceType.Once;break;case "&":s|=Te.SequenceType.Cycle;break;case "~":s|=Te.SequenceType.Shuffle;break;case "$":s|=Te.SequenceType.Stopping;break}return s===0?null:s},this.SequenceTypeWordAnnotation=()=>{let s=this.Interleave(this.SequenceTypeSingleWord,this.Exclude(this.Whitespace));if(s===null||s.length===0||this.ParseString(":")===null)return null;let o=0;for(let u of s)o|=u;return o},this.SequenceTypeSingleWord=()=>{let s=null,o=this.Parse(this.IdentifierWithMetadata);if(o!==null)switch(o.name){case "once":s=Te.SequenceType.Once;break;case "cycle":s=Te.SequenceType.Cycle;break;case "shuffle":s=Te.SequenceType.Shuffle;break;case "stopping":s=Te.SequenceType.Stopping;break}return s===null?null:s},this.InnerSequenceObjects=()=>{let s=this.Parse(this.Newline)!==null,o=null;return s?o=this.Parse(this.InnerMultilineSequenceObjects):o=this.Parse(this.InnerInlineSequenceObjects),o},this.InnerInlineSequenceObjects=()=>{let s=this.Interleave(this.Optional(this.MixedTextAndLogic),this.String("|"),null,false);if(s===null)return null;let o=[],u=false;for(let l of s)if(l==="|")u||o.push(new dt.ContentList),u=false;else {let c=l;c===null?this.Error(`Expected content, but got ${l} (this is an ink compiler bug!)`):o.push(new dt.ContentList(c)),u=true;}return u||o.push(new dt.ContentList),o},this.InnerMultilineSequenceObjects=()=>{this.MultilineWhitespace();let s=this.OneOrMore(this.SingleMultilineSequenceElement);return s===null?null:s},this.SingleMultilineSequenceElement=()=>{if(this.Whitespace(),this.ParseString("->")!==null||this.ParseString("-")===null)return null;this.Whitespace();let s=this.StatementsAtLevel(Ye.StatementLevel.InnerBlock);return s===null?this.MultilineWhitespace():s.unshift(new on.Text(`
|
|
49
|
+
`)),new dt.ContentList(s)},this._statementRulesAtLevel=[],this._statementBreakRulesAtLevel=[],this.StatementsAtLevel=s=>(s===Ye.StatementLevel.InnerBlock&&this.Parse(this.GatherDashes)!==null&&this.Error("You can't use a gather (the dashes) within the { curly braces } context. For multi-line sequences and conditions, you should only use one dash."),this.Interleave(this.Optional(this.MultilineWhitespace),()=>this.StatementAtLevel(s),()=>this.StatementsBreakForLevel(s))),this.StatementAtLevel=s=>{let o=this._statementRulesAtLevel[s],u=this.OneOf(o);return s===Ye.StatementLevel.Top&&u instanceof Ib.ReturnType&&this.Error("should not have return statement outside of a knot"),u},this.StatementsBreakForLevel=s=>{this.Whitespace();let o=this._statementBreakRulesAtLevel[s],u=this.OneOf(o);return u===null?null:u},this.GenerateStatementLevelRules=()=>{let s=Object.values(Ye.StatementLevel);this._statementRulesAtLevel="f".repeat(s.length).split("f").map(()=>[]),this._statementBreakRulesAtLevel="f".repeat(s.length).split("f").map(()=>[]);for(let o of s){let u=[],l=[];u.push(this.Line(this.MultiDivert)),o>=Ye.StatementLevel.Top&&u.push(this.KnotDefinition),u.push(this.Line(this.Choice)),u.push(this.Line(this.AuthorWarning)),o>Ye.StatementLevel.InnerBlock&&u.push(this.Gather),o>=Ye.StatementLevel.Knot&&u.push(this.StitchDefinition),u.push(this.Line(this.ListDeclaration)),u.push(this.Line(this.VariableDeclaration)),u.push(this.Line(this.ConstDeclaration)),u.push(this.Line(this.ExternalDeclaration)),u.push(this.Line(this.IncludeStatement)),u.push(this.LogicLine),u.push(this.LineOfMixedTextAndLogic),o<=Ye.StatementLevel.Knot&&l.push(this.KnotDeclaration),o<=Ye.StatementLevel.Stitch&&l.push(this.StitchDeclaration),o<=Ye.StatementLevel.InnerBlock&&(l.push(this.ParseDashNotArrow),l.push(this.String("}"))),this._statementRulesAtLevel[o]=u,this._statementBreakRulesAtLevel[o]=l;}},this.SkipToNextLine=()=>(this.ParseUntilCharactersFromString(`
|
|
50
|
+
\r`),this.ParseNewline(),an.ParseSuccess),this.Line=s=>()=>{let o=this.ParseObject(s);return o===null?null:(this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),o)},this.StartTag=()=>{if(this.Whitespace(),this.ParseString("#")===null)return null;this.parsingStringExpression&&this.Error("Tags aren't allowed inside of strings. Please use \\# if you want a hash symbol.");let s=null;if(this.tagActive){let o=new dt.ContentList;o.AddContent(new Yr.Tag(false)),o.AddContent(new Yr.Tag(true)),s=o;}else s=new Yr.Tag(true);return this.tagActive=true,this.Whitespace(),s},this._inlineWhitespaceChars=new Ne.CharacterSet(" "),this.EndOfLine=()=>this.OneOf([this.Newline,this.EndOfFile]),this.Newline=()=>(this.Whitespace(),this.ParseNewline()!==null?an.ParseSuccess:null),this.EndOfFile=()=>(this.Whitespace(),this.endOfInput?an.ParseSuccess:null),this.MultilineWhitespace=()=>{let s=this.OneOrMore(this.Newline);return s===null?null:s.length>=1?an.ParseSuccess:null},this.Whitespace=()=>this.ParseCharactersFromCharSet(this._inlineWhitespaceChars)!==null?an.ParseSuccess:null,this.Spaced=s=>()=>{this.Whitespace();let o=this.ParseObject(s);return o===null?null:(this.Whitespace(),o)},this.AnyWhitespace=()=>{let s=false;for(;this.OneOf([this.Whitespace,this.MultilineWhitespace])!==null;)s=true;return s?an.ParseSuccess:null},this.MultiSpaced=s=>()=>{this.AnyWhitespace();let o=this.ParseObject(s);return o===null?null:(this.AnyWhitespace(),o)},this._filename=null,this._externalErrorHandler=null,this._fileHandler=null,this._filename=t,this.RegisterExpressionOperators(),this.GenerateStatementLevelRules(),this.errorHandler=this.OnStringParserError,this._externalErrorHandler=r,a===null?this._fileHandler=new j1.DefaultFileHandler:this._fileHandler=a,i===null){if(this._rootParser=this,this._openFilenames=[],this._filename!==null){let s=this.fileHandler.ResolveInkFilename(this._filename);this._openFilenames.push(s);}}else this._rootParser=i;}PreProcessInputString(e){return new C1.CommentEliminator(e).Process()}get parsingStringExpression(){return this.GetFlag(Number(Fu.CustomFlags.ParsingString))}set parsingStringExpression(e){this.SetFlag(Number(Fu.CustomFlags.ParsingString),e);}get tagActive(){return this.GetFlag(Number(Fu.CustomFlags.TagActive))}set tagActive(e){this.SetFlag(Number(Fu.CustomFlags.TagActive),e);}get identifierCharSet(){return this._identifierCharSet===null&&((this._identifierCharSet=new Ne.CharacterSet).AddRange("A","Z").AddRange("a","z").AddRange("0","9").Add("_"),this.ExtendIdentifierCharacterRanges(this._identifierCharSet)),this._identifierCharSet}EndTagIfNecessary(e){this.tagActive&&(e!=null&&(e instanceof dt.ContentList?e.AddContent(new Yr.Tag(false)):e.push(new Yr.Tag(false))),this.tagActive=false);}};Vu.InkParser=he;he.LatinBasic=kt.CharacterRange.Define("A","z",new Ne.CharacterSet().AddRange("[","`"));he.LatinExtendedA=kt.CharacterRange.Define("\u0100","\u017F");he.LatinExtendedB=kt.CharacterRange.Define("\u0180","\u024F");he.Greek=kt.CharacterRange.Define("\u0370","\u03FF",new Ne.CharacterSet().AddRange("\u0378","\u0385").AddCharacters("\u0374\u0375\u0378\u0387\u038B\u038D\u03A2"));he.Cyrillic=kt.CharacterRange.Define("\u0400","\u04FF",new Ne.CharacterSet().AddRange("\u0482","\u0489"));he.Armenian=kt.CharacterRange.Define("\u0530","\u058F",new Ne.CharacterSet().AddCharacters("\u0530").AddRange("\u0557","\u0560").AddRange("\u0588","\u058E"));he.Hebrew=kt.CharacterRange.Define("\u0590","\u05FF",new Ne.CharacterSet);he.Arabic=kt.CharacterRange.Define("\u0600","\u06FF",new Ne.CharacterSet);he.Korean=kt.CharacterRange.Define("\uAC00","\uD7AF",new Ne.CharacterSet);he.Latin1Supplement=kt.CharacterRange.Define("\x80","\xFF",new Ne.CharacterSet);he.Chinese=kt.CharacterRange.Define("\u4E00","\u9FFF",new Ne.CharacterSet);he.ListAllCharacterRanges=()=>[he.LatinBasic,he.LatinExtendedA,he.LatinExtendedB,he.Arabic,he.Armenian,he.Cyrillic,he.Greek,he.Hebrew,he.Korean,he.Latin1Supplement,he.Chinese];});var $b=w(Ru=>{Object.defineProperty(Ru,"__esModule",{value:true});Ru.GenerateStoryStats=void 0;var $1=$r(),L1=Wr(),q1=es(),B1=tp(),W1=op(),M1=En();function G1(n){let e=n.FindAll(M1.Text)(),t=0;for(let u of e){let l=0,c=true;for(let h of u.text)h==" "||h==" "||h==`
|
|
51
|
+
`||h=="\r"?c=true:c&&(l++,c=false);t+=l;}let r=n.FindAll(B1.Knot)(),i=n.FindAll(W1.Stitch)(),a=n.FindAll($1.Choice)(),s=n.FindAll(q1.Gather)(u=>u.debugMetadata!=null),o=n.FindAll(L1.Divert)();return {words:t,knots:r.length,functions:r.filter(u=>u.isFunction).length,stitches:i.length,gathers:s.length,diverts:o.length-1,choices:a.length}}Ru.GenerateStoryStats=G1;});var Lb=w(ju=>{Object.defineProperty(ju,"__esModule",{value:true});ju.JsonFileHandler=void 0;var Lp=class{constructor(e){this.fileHierarchy=e,this.ResolveInkFilename=t=>{if(Object.keys(this.fileHierarchy).includes(t))return t;throw new Error(`Cannot locate ${t}. Are you trying a relative import ? This is not yet implemented.`)},this.LoadInkFileContents=t=>{if(Object.keys(this.fileHierarchy).includes(t))return this.fileHierarchy[t];throw new Error(`Cannot open ${t}.`)};}};ju.JsonFileHandler=Lp;});var Bb=w(Ge=>{Object.defineProperty(Ge,"__esModule",{value:true});Ge.Compiler=Ge.Story=Ge.InkList=Ge.JsonFileHandler=Ge.StatementLevel=Ge.InkParser=Ge.CompilerOptions=void 0;var z1=wh(),J1=Ky(),qp=Pr(),H1=$p(),U1=be(),K1=oe(),X1=$b(),Y1=wh();Object.defineProperty(Ge,"CompilerOptions",{enumerable:true,get:function(){return Y1.CompilerOptions}});var Z1=$p();Object.defineProperty(Ge,"InkParser",{enumerable:true,get:function(){return Z1.InkParser}});var Q1=sp();Object.defineProperty(Ge,"StatementLevel",{enumerable:true,get:function(){return Q1.StatementLevel}});var eN=Lb();Object.defineProperty(Ge,"JsonFileHandler",{enumerable:true,get:function(){return eN.JsonFileHandler}});var qb=cs();Object.defineProperty(Ge,"InkList",{enumerable:true,get:function(){return qb.InkList}});Object.defineProperty(Ge,"Story",{enumerable:true,get:function(){return qb.Story}});var Bp=class{get errors(){return this._errors}get warnings(){return this._warnings}get authorMessages(){return this._authorMessages}get inputString(){return this._inputString}get options(){return this._options}get parsedStory(){if(!this._parsedStory)throw new Error;return this._parsedStory}get runtimeStory(){if(!this._runtimeStory)throw new Error("Compilation failed.");return this._runtimeStory}get parser(){if(!this._parser)throw new Error;return this._parser}get debugSourceRanges(){return this._debugSourceRanges}constructor(e,t=null){this._errors=[],this._warnings=[],this._authorMessages=[],this._parsedStory=null,this._runtimeStory=null,this._parser=null,this._debugSourceRanges=[],this.Compile=()=>(this._parser=new H1.InkParser(this.inputString,this.options.sourceFilename||null,this.OnError,null,this.options.fileHandler),this._parsedStory=this.parser.ParseStory(),this.errors.length===0?(this.parsedStory.countAllVisits=this.options.countAllVisits,this._runtimeStory=this.parsedStory.ExportRuntime(this.OnError)):this._runtimeStory=null,this.runtimeStory),this.RetrieveDebugSourceForLatestContent=()=>{var r;for(let i of this.runtimeStory.state.outputStream){let a=(0, K1.asOrNull)(i,U1.StringValue);if(a!==null){let s=new J1.DebugSourceRange(((r=a.value)===null||r===void 0?void 0:r.length)||0,a.debugMetadata,a.value||"unknown");this.debugSourceRanges.push(s);}}},this.GenerateStats=()=>this._parsedStory===null?null:(0, X1.GenerateStoryStats)(this._parsedStory),this.DebugMetadataForContentAtOffset=r=>{let i=0,a=null;for(let s of this.debugSourceRanges){if(s.debugMetadata!==null&&(a=s.debugMetadata),r>=i&&r<i+s.length)return a;i+=s.length;}return null},this.OnError=(r,i)=>{switch(i){case qp.ErrorType.Author:this._authorMessages.push(r);break;case qp.ErrorType.Warning:this._warnings.push(r);break;case qp.ErrorType.Error:this._errors.push(r);break}this.options.errorHandler!==null&&this.options.errorHandler(r,i);},this._inputString=e,this._options=t||new z1.CompilerOptions;}};Ge.Compiler=Bp;});var ze;(n=>(n.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),n.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),n.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),n.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(ze||={});var x=class Q{static init(e){e.loadAssets&&(Q._loadAssets=e.loadAssets),e.soundOperation&&(Q._soundOperation=e.soundOperation),e.imageOperation&&(Q._imageOperation=e.imageOperation),e.videoOperation&&(Q._videoOperation=e.videoOperation),e.imageContainerOperation&&(Q._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(Q._textOperation=e.textOperation),e.canvasElementOperation&&(Q._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(Q._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(Q._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(Q._narrationOperation=e.narrationOperation),e.effectOperation&&(Q._effectOperation=e.effectOperation),e.animateOperation&&(Q._animateOperation=e.animateOperation),e.canvasOperation&&(Q._canvasOperation=e.canvasOperation),e.getLogichValue&&(Q._getLogichValue=e.getLogichValue),e.getConditionalStep&&(Q._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return Q._loadAssets}static _soundOperation=()=>{throw ze.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.")};static get soundOperation(){return Q._soundOperation}static _imageOperation=()=>{throw ze.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.")};static get imageOperation(){return Q._imageOperation}static _videoOperation=()=>{throw ze.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.")};static get videoOperation(){return Q._videoOperation}static _imageContainerOperation=()=>{throw ze.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.")};static get imageContainerOperation(){return Q._imageContainerOperation}static _textOperation=()=>{throw ze.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.")};static get textOperation(){return Q._textOperation}static _canvasElementOperation=()=>{throw ze.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.")};static get canvasElementOperation(){return Q._canvasElementOperation}static _setStorageValue=()=>{throw ze.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.")};static get setStorageValue(){return Q._setStorageValue}static _setInitialStorageValue=()=>{throw ze.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.")};static get setInitialStorageValue(){return Q._setInitialStorageValue}static _narrationOperation=()=>{throw ze.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.")};static get narrationOperation(){return Q._narrationOperation}static _effectOperation=()=>{throw ze.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.")};static get effectOperation(){return Q._effectOperation}static _animateOperation=()=>{throw ze.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.")};static get animateOperation(){return Q._animateOperation}static _canvasOperation=()=>{throw ze.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.")};static get canvasOperation(){return Q._canvasOperation}static _getLogichValue=()=>{throw ze.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.")};static get getLogichValue(){return Q._getLogichValue}static _getConditionalStep=()=>{throw ze.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.")};static get getConditionalStep(){return Q._getConditionalStep}};var ti;(n=>{n.options={replaceRegex:/\[([^\]]+)\]/};let e=[];function t(l,c){e.unshift({fn:l,opts:c});}n.add=t;function r(l){let c=e.findIndex(h=>h.fn===l);c!==-1&&e.splice(c,1);}n.remove=r;function i(){return e.map(l=>l.opts)}n.info=i;function a(l,c){let h=e.filter(f=>(f.opts.type??"after-translation")===c.type);for(let f of h)l=u(l,f.fn,f.opts.validation);return l}n.replace=a;function s(l){let c=e.filter(h=>h.opts.i18nInterpolation);for(let h of c)l=o(l,h.fn,h.opts);return l}n.runI18nPreStep=s;function o(l,c,h){let{validation:f}=h,p=new RegExp(n.options.replaceRegex.source,"g"),g=[...l.matchAll(p)],y=new Set,C=[];for(let S of g)y.has(S[1])||(y.add(S[1]),C.push(S[1]));for(let S of C){if(f==="characterId"){if(!RegisteredCharacters.has(S))continue}else if(f!=="all"){if(f instanceof RegExp){if(!f.test(S))continue}else if(f instanceof ZodType&&!f.safeParse(S).success)continue}c(S)!==void 0&&(l.includes(`{{[${S}]}}`)||(l=l.replaceAll(`[${S}]`,`{{[${S}]}}`)));}return l}function u(l,c,h){let f=new RegExp(n.options.replaceRegex.source,"g"),p=[...l.matchAll(f)],g=new Set,y=[];for(let C of p)g.has(C[1])||(g.add(C[1]),y.push(C[1]));for(let C of y){if(h==="characterId"){if(!RegisteredCharacters.has(C))continue}else if(h!=="all"){if(h instanceof RegExp){if(!h.test(C))continue}else if(h instanceof ZodType&&!h.safeParse(C).success)continue}let S=c(C);S!==void 0&&(l=l.replaceAll(`[${C}]`,S));}return l}})(ti||={});function s0(n,e={}){let t="";return n.values.forEach(r=>{if(typeof r=="string")t+=r;else {let i=x.getLogichValue(r,e);t+=`${i}`;}}),t}var Zp;(n=>{let e=u=>u;function t(u){return Array.isArray(u)?u.map(l=>r(`${l}`)):r(`${u}`)}n.t=t;function r(u){let l=u;return n.beforeToTranslate&&(l=(0, n.beforeToTranslate)(l)),l=ti.replace(l,{type:"before-translation"}),l=e(l),n.afterToTranslate&&(l=(0, n.afterToTranslate)(l)),l=ti.replace(l,{type:"after-translation"}),l}n.translate=r;function i(u){e=u;}n.setTranslate=i;function a(u,l,c){let{defaultValue:h="empty_string"}=c;typeof l=="string"&&(l=[l]),Array.isArray(l)&&l.forEach(f=>{let p=f;if(n.beforeToTranslate&&(p=(0, n.beforeToTranslate)(p)),h==="empty_string")u[p]===void 0&&(u[p]="");else if(h==="copy_key"){let g=f;n.beforeToTranslate&&(g=(0, n.beforeToTranslate)(g));let y=ti.runI18nPreStep(g);y=ti.replace(y,{type:"before-translation"}),u[p]=y;}});}function s(u,l=[]){if(typeof u=="object"&&u&&"type"in u)if(u.type==="ifelse")u.then&&s(u.then,l),u.else&&s(u.else,l);else if(u.type==="stepswitch"){if(u.elements)if(Array.isArray(u.elements))u.elements.forEach(c=>{s(c,l);});else if(u.elements.type==="ifelse"){let c=[];s(u.elements,c),c.forEach(h=>{l.push(...h);});}else if(u.elements.type==="stepswitch"){let c=[];s(u.elements,c),c.forEach(h=>{l.push(...h);});}else s(u.elements,l);}else u.type==="resulttocombine"?(u.firstItem&&s(u.firstItem,l),u.secondConditionalItem&&u.secondConditionalItem.forEach(c=>{s(c,l);})):l.push(u);else u&&l.push(u);return l}async function o(u,l={},c={}){let{defaultValue:h="copy_key",operationStringConvert:f}=c,p=u.map(async g=>{if(g.choices){let y=[];Array.isArray(g.choices)?y=[g.choices]:y=s(g.choices),y.forEach(C=>{C.forEach(S=>{if("type"in S){let v=[];S.type==="ifelse"||S.type==="stepswitch"?s(S,v):v=[S],v.map(d=>s(d.text)).forEach(d=>{Array.isArray(d)&&d.forEach(_=>{Array.isArray(_)?_.forEach(m=>{typeof m=="string"?a(l,m,{defaultValue:h}):s(m).forEach(b=>{Array.isArray(b)?b.forEach(E=>{typeof E=="string"&&a(l,E,{defaultValue:h});}):typeof b=="string"&&a(l,b,{defaultValue:h});});}):typeof _=="string"&&a(l,_,{defaultValue:h});});});}});});}if(g.dialogue){let y=[];Array.isArray(g.dialogue)?y=[g.dialogue]:y=s(g.dialogue),y.forEach(C=>{if(typeof C=="string")a(l,C,{defaultValue:h});else if("text"in C){let S=s(C.text);typeof S=="string"&&(S=[S]),S.forEach(v=>{typeof v=="string"?a(l,v,{defaultValue:h}):s(v).forEach(d=>{typeof d=="string"?a(l,d,{defaultValue:h}):Array.isArray(d)&&d.forEach(_=>{typeof _=="string"?a(l,_,{defaultValue:h}):s(_).forEach(m=>{typeof m=="string"&&a(l,m,{defaultValue:h});});});});});}});}if(g.operations)for(let y of g.operations){if(y.type==="operationtoconvert"&&f){let C=s0(y),S=await f(C,g,{});if(!S)return;y=S;}y.type==="text"&&y.operationType==="show"&&a(l,y.text,{defaultValue:h});}g.conditionalStep&&s(g.conditionalStep).forEach(y=>{Array.isArray(y)?o(y,l,c):o([y],l,c);});});return await Promise.all(p),l}n.generateJsonTranslation=o;})(Zp||={});var pt=Zp;async function Qp(n){let e=x.getLogichValue(n,{});if(e)switch(e.type){case "assets":switch(e.operationType){case "load":await Assets.load(e.aliases);break;case "lazyload":Assets.backgroundLoad(e.aliases);break}break;case "bundle":switch(e.operationType){case "load":await Assets.loadBundle(e.aliases);break;case "lazyload":Assets.backgroundLoadBundle(e.aliases);break}break}}var te;(n=>(n.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),n.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),n.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),n.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(te||={});async function Ds(n,e,t){let{alias:r}=e,{props:i,priority:a}=t;switch(t.type){case "fade":await transitions.showWithFade(r,n,i,a);break;case "dissolve":await transitions.showWithDissolve(r,n,i,a);break;case "movein":case "moveout":await transitions.moveIn(r,n,i,a);break;case "zoomin":case "zoomout":await transitions.zoomIn(r,n,i,a);break;case "pushin":case "pushout":await transitions.pushIn(r,n,i,a);break;case "wipein":case "wipeout":await transitions.wipeIn(r,n,i,a);break;case "irisin":case "irisout":await transitions.irisIn(r,n,i,a);break;case "splitin":case "splitout":await transitions.splitIn(r,n,i,a);break;case "blurin":case "blurout":await transitions.blurIn(r,n,i,a);break;case "pixelatein":case "pixelateout":await transitions.pixelateIn(r,n,i,a);break;case "flashin":case "flashout":await transitions.flashIn(r,n,i,a);break;case "glitchin":case "glitchout":await transitions.glitchIn(r,n,i,a);break;case "twistin":case "twistout":await transitions.twistIn(r,n,i,a);break;case "warpin":case "warpout":await transitions.warpIn(r,n,i,a);break;case "ripplein":case "rippleout":await transitions.rippleIn(r,n,i,a);break;case "noisedissolvein":case "noisedissolveout":await transitions.noiseDissolveIn(r,n,i,a);break;case "tvin":case "tvout":await transitions.tvIn(r,n,i,a);break;case "pinchin":case "pinchout":await transitions.pinchIn(r,n,i,a);break}}function ni(n){let{transition:e,alias:t}=n;if(!e){canvas.remove(t);return}let{props:r,priority:i}=e;switch(e.type){case "fade":transitions.removeWithFade(t,r,i);break;case "dissolve":transitions.removeWithDissolve(t,r,i);break;case "movein":case "moveout":transitions.moveOut(t,r,i);break;case "zoomin":case "zoomout":transitions.zoomOut(t,r,i);break;case "pushin":case "pushout":transitions.pushOut(t,r,i);break;case "wipein":case "wipeout":transitions.wipeOut(t,r,i);break;case "irisin":case "irisout":transitions.irisOut(t,r,i);break;case "splitin":case "splitout":transitions.splitOut(t,r,i);break;case "blurin":case "blurout":transitions.blurOut(t,r,i);break;case "pixelatein":case "pixelateout":transitions.pixelateOut(t,r,i);break;case "flashin":case "flashout":transitions.flashOut(t,r,i);break;case "glitchin":case "glitchout":transitions.glitchOut(t,r,i);break;case "twistin":case "twistout":transitions.twistOut(t,r,i);break;case "warpin":case "warpout":transitions.warpOut(t,r,i);break;case "ripplein":case "rippleout":transitions.rippleOut(t,r,i);break;case "noisedissolvein":case "noisedissolveout":transitions.noiseDissolveOut(t,r,i);break;case "tvin":case "tvout":transitions.tvOut(t,r,i);break;case "pinchin":case "pinchout":transitions.pinchOut(t,r,i);break}}async function ef(n){switch(n.operationType){case "show":if(n.transition){let e=new ImageSprite(n.props,n.url||n.alias);await Ds(e,n,n.transition);}else await showImage(n.alias,n.url,n.props);break;case "edit":{let e=canvas.find(n.alias);e?n.props&&await e.setMemory({...e.memory,...n.props}):te.error(`Image with alias ${n.alias} not found.`);break}case "remove":ni(n);break}}async function tf(n){switch(n.operationType){case "show":if(n.transition){let e=new VideoSprite(n.props,n.url||n.alias);await Ds(e,n,n.transition);}else await showVideo(n.alias,n.url,n.props);break;case "edit":{let e=canvas.find(n.alias);e?n.props&&await e.setMemory({...e.memory,...n.props}):te.error(`Video with alias ${n.alias} not found.`);break}case "remove":ni(n);break;case "pause":case "resume":{let e=canvas.find(n.alias);e?e.paused=n.operationType==="pause":te.error(`Video with alias ${n.alias} not found.`);break}}}async function nf(n){switch(n.operationType){case "show":if(n.transition){let e=new ImageContainer(n.props,n.urls);await Ds(e,n,n.transition);}else await showImageContainer(n.alias,n.urls,n.props);break;case "edit":{let e=canvas.find(n.alias);e?n.props&&await e.setMemory({...e.memory,...n.props}):te.error(`ImageContainer with alias ${n.alias} not found.`);break}case "remove":ni(n);break}}async function rf(n){switch(n.operationType){case "show":if(n.props=n.props||{},n.props.text=pt.t(n.text),n.transition){let e=new Text(n.props);await Ds(e,n,n.transition);}else showText(n.alias,n.text,n.props);break;case "edit":{let e=canvas.find(n.alias);e?n.props&&await e.setMemory({...e.memory,...n.props}):te.error(`Text with alias ${n.alias} not found.`);break}case "remove":ni(n);break}}async function sf(n){switch(n.operationType){case "edit":try{let e=canvas.find(n.alias);e?n.props&&e.setMemory({...e.memory,...n.props}):te.error(`Canvas Element with alias ${n.alias} not found.`);}catch(e){te.error(`There was an error while trying to edit the canvas element with alias ${n.alias}.`,e);}break;case "remove":ni(n);break}}function af(n){n.operationType==="clear"&&canvas.removeAll();}async function of(n){switch(n.type){case "shake":await effects.shakeEffect(n.alias,n.props,n.priority);break;case "bounce":await effects.bounceEffect(n.alias,n.props,n.priority);break;case "pulse":await effects.pulseEffect(n.alias,n.props,n.priority);break;case "hop":await effects.hopEffect(n.alias,n.props,n.priority);break;case "wiggle":await effects.wiggleEffect(n.alias,n.props,n.priority);break;case "nod":await effects.nodEffect(n.alias,n.props,n.priority);break;case "sway":await effects.swayEffect(n.alias,n.props,n.priority);break;case "punch":await effects.punchEffect(n.alias,n.props,n.priority);break;case "glitch":await effects.glitchEffect(n.alias,n.props,n.priority);break;case "chromatic-aberration":await effects.chromaticAberrationEffect(n.alias,n.props,n.priority);break;case "shockwave":await effects.shockwaveEffect(n.alias,n.props,n.priority);break;case "radial-blur":await effects.radialBlurEffect(n.alias,n.props,n.priority);break;case "blur-pulse":await effects.blurPulseEffect(n.alias,n.props,n.priority);break;case "vignette-pulse":await effects.vignettePulseEffect(n.alias,n.props,n.priority);break;case "desaturate":await effects.desaturateEffect(n.alias,n.props,n.priority);break;case "glow-pulse":await effects.glowPulseEffect(n.alias,n.props,n.priority);break}}function uf(n){switch(n.type){case "animate":canvas.animate(n.alias,n.keyframes,n.options,n.priority);break;case "animate-sequence":canvas.animate(n.alias,n.sequence,n.options,n.priority);break}}function lf(n){switch(n.type){case "input":narration.input.request({type:n.valueType},n.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function cf(n){switch(n.operationType){case "play":n.url?sound.play(n.alias,n.url,n.props):sound.play(n.alias,n.props);break;case "stop":switch(n.type){case "sound":sound.stop(n.alias);break;case "all":sound.stopAll();break}break;case "pause":switch(n.type){case "sound":sound.pause(n.alias);break;case "channel":sound.channels.find(n.alias).pauseAll();break;case "all":sound.pauseAll();break}break;case "resume":switch(n.type){case "sound":sound.resume(n.alias);break;case "channel":sound.channels.find(n.alias).resumeAll();break;case "all":sound.resumeAll();break}break;case "edit":{let e=sound.find(n.alias);if(!e)break;for(let[t,r]of Object.entries(n.props))switch(t){case "volume":e.volume.value=r;break;case "playbackRate":e.playbackRate=r;break;case "mute":e.mute=r;break;case "loop":e.loop=r;break;case "paused":e.paused=r;break}break}}}var Gu="___param___",m0=class ee{static init(e){e.loadAssets&&(ee._loadAssets=e.loadAssets),e.soundOperation&&(ee._soundOperation=e.soundOperation),e.imageOperation&&(ee._imageOperation=e.imageOperation),e.videoOperation&&(ee._videoOperation=e.videoOperation),e.imageContainerOperation&&(ee._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(ee._textOperation=e.textOperation),e.canvasElementOperation&&(ee._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(ee._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(ee._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(ee._narrationOperation=e.narrationOperation),e.effectOperation&&(ee._effectOperation=e.effectOperation),e.animateOperation&&(ee._animateOperation=e.animateOperation),e.canvasOperation&&(ee._canvasOperation=e.canvasOperation),e.getLogichValue&&(ee._getLogichValue=e.getLogichValue),e.getConditionalStep&&(ee._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return ee._loadAssets}static _soundOperation=()=>{throw te.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.")};static get soundOperation(){return ee._soundOperation}static _imageOperation=()=>{throw te.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.")};static get imageOperation(){return ee._imageOperation}static _videoOperation=()=>{throw te.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.")};static get videoOperation(){return ee._videoOperation}static _imageContainerOperation=()=>{throw te.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.")};static get imageContainerOperation(){return ee._imageContainerOperation}static _textOperation=()=>{throw te.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.")};static get textOperation(){return ee._textOperation}static _canvasElementOperation=()=>{throw te.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.")};static get canvasElementOperation(){return ee._canvasElementOperation}static _setStorageValue=()=>{throw te.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.")};static get setStorageValue(){return ee._setStorageValue}static _setInitialStorageValue=()=>{throw te.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.")};static get setInitialStorageValue(){return ee._setInitialStorageValue}static _narrationOperation=()=>{throw te.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.")};static get narrationOperation(){return ee._narrationOperation}static _effectOperation=()=>{throw te.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.")};static get effectOperation(){return ee._effectOperation}static _animateOperation=()=>{throw te.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.")};static get animateOperation(){return ee._animateOperation}static _canvasOperation=()=>{throw te.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.")};static get canvasOperation(){return ee._canvasOperation}static _getLogichValue=()=>{throw te.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.")};static get getLogichValue(){return ee._getLogichValue}static _getConditionalStep=()=>{throw te.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.")};static get getConditionalStep(){return ee._getConditionalStep}};function g0(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let t=e[n.functionName];if(typeof t=="function"){let r=n.args.map(i=>m0.getLogichValue(i,e));return t(...r)}else te.warn(`getLogichValue function ${n.functionName} not found in props`);}}function hf(n,e){let t=x.getLogichValue(n,e);return t&&typeof t=="object"&&"type"in t?x.getLogichValue(t,e):t}function df(n,e={}){let t=hf(n.value,e);switch(n.storageType){case "flagStorage":storage.flags.set(n.key,n.value);break;case "storage":storage.set(n.key,t);break;case "tempstorage":storage.temp.set(n.key,t);break;case "params":{let r=storage.get(`${Gu}${narration.labels.opened.length-1}`)||[];r.length>n.key&&(r[n.key]=t),storage.temp.set(`${Gu}${narration.labels.opened.length-1}`,r);break}}}function pf(n,e={}){let t=hf(n.value,e);switch(n.storageType){case "storage":case "tempstorage":storage.default={[n.key]:t};break}}function ff(n,e={}){let t=mf(n,e);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return v0(t,e);case "arithmetic":case "arithmeticsingle":return y0(t,e);case "compare":case "union":return b0(t,e);case "function":return g0(t,e)}return t}function y0(n,e){let t=x.getLogichValue(n.leftValue,e);switch(n.type){case "arithmetic":{let r=x.getLogichValue(n.rightValue,e);switch(n.operator){case "*":return t*r;case "/":return t/r;case "+":return typeof t=="string"||typeof r=="string"?`${t}${r}`:Array.isArray(t)&&Array.isArray(r)?[...t,...r]:Array.isArray(t)?[...t,r]:Array.isArray(r)?[t,...r]:t+r;case "-":if(Array.isArray(t)&&Array.isArray(r))return t.filter(i=>!r.includes(i));if(Array.isArray(t))return t.filter(i=>i!==r);if(Array.isArray(r)){te.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return t-r;case "%":return t%r;case "POW":return t**r;case "RANDOM":return narration.getRandomNumber(t,r);case "INTERSECTION":if(Array.isArray(t)&&Array.isArray(r))return t.filter(i=>r.includes(i));te.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:te.warn("getValueFromArithmeticOperations unknown operator",n);return}}case "arithmeticsingle":switch(n.operator){case "INT":return Number(t);case "FLOOR":return Math.floor(t)}break}}function v0(n,e){if(n&&typeof n=="object"&&"type"in n&&n.type==="value"&&n.storageOperationType==="get")switch(n.storageType){case "storage":case "tempstorage":return n.key==="_input_value_"?narration.input.value:storage.get(n.key);case "flagStorage":return storage.flags.get(n.key);case "label":return narration.queries.timesLabelOpened(n.label);case "choice":return narration.queries.timesChoiceMade(n.index);case "logic":return x.getLogichValue(n.operation,e);case "params":{let t=storage.get(`${Gu}${narration.labels.opened.length-1}`)||[];if(t&&t.length>n.key)return t[n.key];te.warn("getValue params not found");return}}return n}function b0(n,e){if(!n)return false;if(typeof n!="object"||!("type"in n))return !!n;switch(n.type){case "compare":{let t=x.getLogichValue(n.leftValue,e),r=x.getLogichValue(n.rightValue,e);switch(n.operator){case "==":return Array.isArray(t)&&Array.isArray(r)?t.length===r.length&&t.every(i=>r.includes(i)):t===r;case "!=":return Array.isArray(t)&&Array.isArray(r)?t.length!==r.length||!t.every(i=>r.includes(i)):t!==r;case "<":return typeof t=="string"&&typeof r=="string"?t.localeCompare(r)<0:Array.isArray(t)&&Array.isArray(r)?t.length<r.length:t<r;case "<=":return typeof t=="string"&&typeof r=="string"?t.localeCompare(r)<=0:Array.isArray(t)&&Array.isArray(r)?t.length<=r.length:t<=r;case ">":return typeof t=="string"&&typeof r=="string"?t.localeCompare(r)>0:Array.isArray(t)&&Array.isArray(r)?t.length>r.length:t>r;case ">=":return typeof t=="string"&&typeof r=="string"?t.localeCompare(r)>=0:Array.isArray(t)&&Array.isArray(r)?t.length>=r.length:t>=r;case "CONTAINS":return Array.isArray(t)&&Array.isArray(r)?r.every(i=>t.includes(i)):Array.isArray(t)?t.includes(r):t.toString().includes(r.toString())}break}case "value":{let t=x.getLogichValue(n,e);return Array.isArray(t)?t.length>0:t&&typeof t=="object"?Object.keys(t).length>0:!!t}case "union":return C0(n,e)}return !!n}function C0(n,e){if(n.unionType==="not"){let r=ff(n.condition,e);return Array.isArray(r)?r.length===0:r&&typeof r=="object"?Object.keys(r).length===0:!r}let t=r=>x.getLogichValue(r,e)||false;return n.unionType==="and"?n.conditions.every(t):n.conditions.some(t)}function S0(n,e){return Math.floor(Math.random()*(e-n+1)+n)}function mf(n,e={}){if(Array.isArray(n)||!n)return n;if(n&&typeof n=="object"&&"type"in n)switch(n.type){case "resulttocombine":return _0(n,e);case "ifelse":return x.getLogichValue(n.condition,e)?x.getLogichValue(n.then,e):x.getLogichValue(n.else,e);case "stepswitch":{let t=x.getLogichValue(n.elements,e)||[];if(t.length===0){te.error("getValueFromConditionalStatements elements.length === 0");return}switch(n.choiceType){case "random":{let r=S0(0,t.length-1);return x.getLogichValue(t[r],e)}case "loop":{let r=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return r>t.length-1?(r=r%t.length,x.getLogichValue(t[r],e)):x.getLogichValue(t[r],e)}case "sequential":{let r,i=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return n.end==="lastItem"&&(r=x.getLogichValue(t[t.length-1],e)),i>t.length-1?r:x.getLogichValue(t[i],e)}case "sequentialrandom":{let r=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:n.nestedId,onceOnly:true});if(r===void 0&&n.end==="lastItem"){let i=NarrationManagerStatic.getCurrentStepTimesCounterData(n.nestedId);if(!i?.usedRandomNumbers){te.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let a=i.usedRandomNumbers[`0-${t.length-1}`];return x.getLogichValue(t[a[a.length-1]],e)}if(r===void 0){te.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return x.getLogichValue(t[r],e)}}}}return n}function As(n,e={}){if(n.conditionalStep){let t=createExportableElement(x.getLogichValue(n.conditionalStep,e));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 r={...n,conditionalStep:void 0,...t};return As(r,e)}else narration.dialogGlue&&(narration.dialogGlue=false);}return n}function _0(n,e){let t=n.firstItem,r=(n.secondConditionalItem??[]).flatMap(a=>Array.isArray(a)?a.map(s=>x.getLogichValue(s,e)):[x.getLogichValue(a,e)]),i=t?[t,...r]:r;if(i.length===0){te.warn("combinateResult toCheck.length === 0");return}if(typeof i[0]=="string")return pt.t(i);if(typeof i[0]=="object"){let a=i,s,o=false,u=a.map((v,d)=>{v=As(v,e);let _=x.getLogichValue(v.dialogue,e)||"";return d===0?(s=x.getLogichValue(v.glueEnabled,e)||false,_):(typeof _=="object"&&"text"in _&&(_=`${_.character}: ${_.text}`),s===false&&o&&(_=`
|
|
52
|
+
|
|
53
|
+
${_}`),_&&(o=true),s=x.getLogichValue(v.glueEnabled,e)||false,_)}),l=x.getLogichValue(u[0],e),c=typeof l=="object"&&"character"in l?l.character:void 0,h=u.flatMap(v=>{let d;v&&typeof v=="object"&&"text"in v?d=v.text:d=v;let _;return Array.isArray(d)?_=d.map(m=>{let b=x.getLogichValue(m,e);return pt.t(`${b}`)}):_=x.getLogichValue(d,e)||"",pt.t(_)}),f=a.find(v=>v.end),p=a.find(v=>v.choices),g=false,y=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&(narration.dialogGlue=true),g=a[a.length-1].glueEnabled,y=a.reverse().find(v=>!(v.operations&&(!v.dialogue||!v.choices)))?.goNextStep);let C=a.find(v=>v.labelToOpen),S=[];return a.forEach(v=>{v.operations&&(S=[...S,...v.operations]);}),{dialogue:c?{character:c,text:h}:h,end:f?.end,choices:p?.choices,glueEnabled:g,goNextStep:y,labelToOpen:C?.labelToOpen,operations:S}}}var Os;(n=>{let e=new Set;function t(a){e.add(a);}n.add=t;function r(){e.clear();}n.clear=r;function i(a,s={}){let o=c=>ff(c,s)??void 0,u=mf(a,s);if(e.size===0)return o(u);let l=o;for(let c of e){let h=l;l=f=>c(f,h)??void 0;}return l(u)}n.getLogichValue=i;})(Os||={});var A0=Object.create,Cf=Object.defineProperty,O0=Object.getOwnPropertyDescriptor,P0=Object.getOwnPropertyNames,x0=Object.getPrototypeOf,T0=Object.prototype.hasOwnProperty,yf=(n=>typeof Tn<"u"?Tn:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof Tn<"u"?Tn:e)[t]}):n)(function(n){if(typeof Tn<"u")return Tn.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')}),Sf=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),N0=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of P0(e))!T0.call(n,i)&&i!==t&&Cf(n,i,{get:()=>e[i],enumerable:!(r=O0(e,i))||r.enumerable});return n},F0=(n,e,t)=>(t=n!=null?A0(x0(n)):{},N0(Cf(t,"default",{value:n,enumerable:true}),n)),I0=Sf((n,e)=>{(function(t,r){typeof n=="object"?e.exports=n=r():typeof define=="function"&&define.amd?define([],r):t.CryptoJS=r();})(n,function(){var t=t||(function(r,i){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof global<"u"&&global.crypto&&(a=global.crypto),!a&&typeof yf=="function")try{a=yf("crypto");}catch{}var s=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function v(){}return function(d){var _;return v.prototype=d,_=new v,v.prototype=null,_}})(),u={},l=u.lib={},c=l.Base=(function(){return {extend:function(v){var d=o(this);return v&&d.mixIn(v),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var v=this.extend();return v.init.apply(v,arguments),v},init:function(){},mixIn:function(v){for(var d in v)v.hasOwnProperty(d)&&(this[d]=v[d]);v.hasOwnProperty("toString")&&(this.toString=v.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=l.WordArray=c.extend({init:function(v,d){v=this.words=v||[],d!=i?this.sigBytes=d:this.sigBytes=v.length*4;},toString:function(v){return (v||p).stringify(this)},concat:function(v){var d=this.words,_=v.words,m=this.sigBytes,b=v.sigBytes;if(this.clamp(),m%4)for(var E=0;E<b;E++){var O=_[E>>>2]>>>24-E%4*8&255;d[m+E>>>2]|=O<<24-(m+E)%4*8;}else for(var P=0;P<b;P+=4)d[m+P>>>2]=_[P>>>2];return this.sigBytes+=b,this},clamp:function(){var v=this.words,d=this.sigBytes;v[d>>>2]&=4294967295<<32-d%4*8,v.length=r.ceil(d/4);},clone:function(){var v=c.clone.call(this);return v.words=this.words.slice(0),v},random:function(v){for(var d=[],_=0;_<v;_+=4)d.push(s());return new h.init(d,v)}}),f=u.enc={},p=f.Hex={stringify:function(v){for(var d=v.words,_=v.sigBytes,m=[],b=0;b<_;b++){var E=d[b>>>2]>>>24-b%4*8&255;m.push((E>>>4).toString(16)),m.push((E&15).toString(16));}return m.join("")},parse:function(v){for(var d=v.length,_=[],m=0;m<d;m+=2)_[m>>>3]|=parseInt(v.substr(m,2),16)<<24-m%8*4;return new h.init(_,d/2)}},g=f.Latin1={stringify:function(v){for(var d=v.words,_=v.sigBytes,m=[],b=0;b<_;b++){var E=d[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(E));}return m.join("")},parse:function(v){for(var d=v.length,_=[],m=0;m<d;m++)_[m>>>2]|=(v.charCodeAt(m)&255)<<24-m%4*8;return new h.init(_,d)}},y=f.Utf8={stringify:function(v){try{return decodeURIComponent(escape(g.stringify(v)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(v){return g.parse(unescape(encodeURIComponent(v)))}},C=l.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(v){typeof v=="string"&&(v=y.parse(v)),this._data.concat(v),this._nDataBytes+=v.sigBytes;},_process:function(v){var d,_=this._data,m=_.words,b=_.sigBytes,E=this.blockSize,O=E*4,P=b/O;v?P=r.ceil(P):P=r.max((P|0)-this._minBufferSize,0);var k=P*E,z=r.min(k*4,b);if(k){for(var se=0;se<k;se+=E)this._doProcessBlock(m,se);d=m.splice(0,k),_.sigBytes-=z;}return new h.init(d,z)},clone:function(){var v=c.clone.call(this);return v._data=this._data.clone(),v},_minBufferSize:0});l.Hasher=C.extend({cfg:c.extend(),init:function(v){this.cfg=this.cfg.extend(v),this.reset();},reset:function(){C.reset.call(this),this._doReset();},update:function(v){return this._append(v),this._process(),this},finalize:function(v){v&&this._append(v);var d=this._doFinalize();return d},blockSize:16,_createHelper:function(v){return function(d,_){return new v.init(_).finalize(d)}},_createHmacHelper:function(v){return function(d,_){return new S.HMAC.init(v,_).finalize(d)}}});var S=u.algo={};return u})(Math);return t});}),k0=Sf((n,e)=>{(function(t,r){typeof n=="object"?e.exports=n=r(I0()):typeof define=="function"&&define.amd?define(["./core"],r):r(t.CryptoJS);})(n,function(t){return (function(){var r=t,i=r.lib,a=i.WordArray,s=i.Hasher,o=r.algo,u=[],l=o.SHA1=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,h){for(var f=this._hash.words,p=f[0],g=f[1],y=f[2],C=f[3],S=f[4],v=0;v<80;v++){if(v<16)u[v]=c[h+v]|0;else {var d=u[v-3]^u[v-8]^u[v-14]^u[v-16];u[v]=d<<1|d>>>31;}var _=(p<<5|p>>>27)+S+u[v];v<20?_+=(g&y|~g&C)+1518500249:v<40?_+=(g^y^C)+1859775393:v<60?_+=(g&y|g&C|y&C)-1894007588:_+=(g^y^C)-899497514,S=C,C=y,y=g<<30|g>>>2,g=p,p=_;}f[0]=f[0]+p|0,f[1]=f[1]+g|0,f[2]=f[2]+y|0,f[3]=f[3]+C|0,f[4]=f[4]+S|0;},_doFinalize:function(){var c=this._data,h=c.words,f=this._nDataBytes*8,p=c.sigBytes*8;return h[p>>>5]|=128<<24-p%32,h[(p+64>>>9<<4)+14]=Math.floor(f/4294967296),h[(p+64>>>9<<4)+15]=f,c.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var c=s.clone.call(this);return c._hash=this._hash.clone(),c}});r.SHA1=s._createHelper(l),r.HmacSHA1=s._createHmacHelper(l);})(),t.SHA1});}),vf="___param___",we;(n=>(n.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),n.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),n.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),n.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(we||={});var V0=class ne{static init(e){e.loadAssets&&(ne._loadAssets=e.loadAssets),e.soundOperation&&(ne._soundOperation=e.soundOperation),e.imageOperation&&(ne._imageOperation=e.imageOperation),e.videoOperation&&(ne._videoOperation=e.videoOperation),e.imageContainerOperation&&(ne._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(ne._textOperation=e.textOperation),e.canvasElementOperation&&(ne._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(ne._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(ne._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(ne._narrationOperation=e.narrationOperation),e.effectOperation&&(ne._effectOperation=e.effectOperation),e.animateOperation&&(ne._animateOperation=e.animateOperation),e.canvasOperation&&(ne._canvasOperation=e.canvasOperation),e.getLogichValue&&(ne._getLogichValue=e.getLogichValue),e.getConditionalStep&&(ne._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return ne._loadAssets}static _soundOperation=()=>{throw we.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.")};static get soundOperation(){return ne._soundOperation}static _imageOperation=()=>{throw we.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.")};static get imageOperation(){return ne._imageOperation}static _videoOperation=()=>{throw we.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.")};static get videoOperation(){return ne._videoOperation}static _imageContainerOperation=()=>{throw we.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.")};static get imageContainerOperation(){return ne._imageContainerOperation}static _textOperation=()=>{throw we.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.")};static get textOperation(){return ne._textOperation}static _canvasElementOperation=()=>{throw we.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.")};static get canvasElementOperation(){return ne._canvasElementOperation}static _setStorageValue=()=>{throw we.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.")};static get setStorageValue(){return ne._setStorageValue}static _setInitialStorageValue=()=>{throw we.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.")};static get setInitialStorageValue(){return ne._setInitialStorageValue}static _narrationOperation=()=>{throw we.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.")};static get narrationOperation(){return ne._narrationOperation}static _effectOperation=()=>{throw we.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.")};static get effectOperation(){return ne._effectOperation}static _animateOperation=()=>{throw we.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.")};static get animateOperation(){return ne._animateOperation}static _canvasOperation=()=>{throw we.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.")};static get canvasOperation(){return ne._canvasOperation}static _getLogichValue=()=>{throw we.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.")};static get getLogichValue(){return ne._getLogichValue}static _getConditionalStep=()=>{throw we.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.")};static get getConditionalStep(){return ne._getConditionalStep}};function R0(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let t=e[n.functionName];if(typeof t=="function"){let r=n.args.map(i=>V0.getLogichValue(i,e));return t(...r)}else we.warn(`getLogichValue function ${n.functionName} not found in props`);}}function j0(n,e={}){let t="";return n.values.forEach(r=>{if(typeof r=="string")t+=r;else {let i=x.getLogichValue(r,e);t+=`${i}`;}}),t}async function _f(n,e,t){let r=x.getLogichValue(n,e);if(r)switch(r.type){case "sound":x.soundOperation(r);break;case "assets":case "bundle":await x.loadAssets(r);break;case "image":await x.imageOperation(r);break;case "video":await x.videoOperation(r);break;case "imagecontainer":await x.imageContainerOperation(r);break;case "text":await x.textOperation(r);break;case "canvaselement":await x.canvasElementOperation(r);break;case "canvas":x.canvasOperation(r);break;case "value":x.setStorageValue(r,e);break;case "operationtoconvert":if(t){let i=j0(r,e),a=await t(i);a&&await _f(a,e,t);}break;case "input":case "dialogue":x.narrationOperation(r);break;case "shake":await x.effectOperation(r);break;case "animate":case "animate-sequence":x.animateOperation(r);break;case "function":await R0(r,e);break}}function bf(n){let e=x.getLogichValue(n,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&x.setInitialStorageValue(e);}var $0=F0(k0()),L0=class extends LabelAbstract{constructor(n,e,t,r={}){t||(t={}),t.onLoadingLabel=async()=>{for(let i of e){let a;if(typeof i=="function"?a=i():a=i,a=x.getConditionalStep(a),a.operations)try{let s=a.operations.map(o=>x.loadAssets(o));await Promise.all(s);}catch(s){we.error("The operation in the onLoadingLabel function of the label has an error:",s);}}},super(n,t),this._steps=e,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(n=>this.stepConverter(n))}get stepCount(){return this._steps.length}getStepById(n){if(n<0||n>=this._steps.length)return;let e=this._steps[n];return this.stepConverter(e)}operationStringConvert;skipEmptyDialogs=false;getStepSha(n){if(n<0||n>=this.steps.length)return;let e=this._steps[n];return (0, $0.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(n,e){let t="";if(Array.isArray(n)){let r=[];n.forEach(i=>{if(typeof i=="string")r.push(i);else if(i&&typeof i=="object"){let a=x.getLogichValue(i,e);a?(a&&!Array.isArray(a)&&typeof a=="object"&&(a=x.getLogichValue(a,e)||""),Array.isArray(a)?r=r.map(s=>`${s}`).concat(a):r.push(`${a}`)):r.push(`${i}`);}else r.push(`${i}`);}),t=r;}else {let r=x.getLogichValue(n,e);r&&!Array.isArray(r)&&typeof r=="object"&&(r=x.getLogichValue(r,e)),r&&Array.isArray(r)?t=r.map(i=>`${i}`):t=`${r}`;}return t}getDialogue(n,e){if(n==null)return;let t=x.getLogichValue(n,e);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:pt.t(this.getDialogueText(t.text,e))}:pt.t(this.getDialogueText(t,e))}getChoices(n,e){return x.getLogichValue(n,e)?.map(t=>x.getLogichValue(t,e)).filter(t=>t!==void 0)}stepConverter(n){return async e=>{let t=typeof n=="function"?n():n;t=createExportableElement(t),t=x.getConditionalStep(t,e);let r=this.operationStringConvert?f=>this.operationStringConvert(f,t,e):void 0,{operations:i=[]}=t;for(let f of i)await _f(f,e,r);let{labelToOpen:a=[]}=t,s=this.getChoices(t.choices,e),o=x.getLogichValue(t.glueEnabled,e),u=this.getDialogue(t.dialogue,e),l=[];Array.isArray(a)||(a=[a]),a.forEach(f=>{let p=x.getLogichValue(f,e);p&&l.push(p);});let c=x.getLogichValue(t.goNextStep,e),h=x.getLogichValue(t.end,e);if(s){let f=s.map(p=>{let g="";if(Array.isArray(p.text)){let y=[];p.text.forEach(C=>{if(typeof C=="string")y.push(pt.t(C));else if(C&&typeof C=="object"){let S=x.getLogichValue(C,e);S&&!Array.isArray(S)&&typeof S=="object"&&(S=x.getLogichValue(S,e)||""),S&&(Array.isArray(S)?y=y.concat(pt.t(S)):y.push(pt.t(S)));}}),g=y;}else typeof p.text=="string"&&(g=pt.t(p.text));return {label:p.label,text:g,props:p.props,type:p.type,oneTime:p.oneTime,onlyHaveNoChoice:p.onlyHaveNoChoice,autoSelect:p.autoSelect}});narration.choices=f;}else narration.choices=void 0;u!==void 0&&(narration.dialogue=u,this.skipEmptyDialogs&&typeof u=="string"&&(u===""||RegExp(/^\s+$/).test(u))&&(c=true)),o?narration.dialogGlue=true:o===false&&(narration.dialogGlue=false);for(let f of l){let p=f.label;typeof p=="object"&&(p=x.getLogichValue(p,e)||"");let g=f.params?.map(y=>x.getLogichValue(y,e));e={...e,...f.props},f.type==="jump"?(narration.labels.opened.length>0&&narration.labels.closeCurrent(),storage.temp.set(`${vf}${narration.labels.opened.length}`,g),await narration.call(p,e)):(storage.temp.set(`${vf}${narration.labels.opened.length}`,g),await narration.call(p,e));}h==="game_end"?(narration.labels.closeAll(),await narration.continue(e,{runNow:true})):h==="label_end"&&narration.labels.closeCurrent(),c&&await narration.continue(e,{runNow:true});}}};async function qN(n,e={}){if(!Array.isArray(n))if(typeof n=="object"||typeof n=="string")n=[n];else {we.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let t=n.map(a=>{if(typeof a=="string")try{return JSON.parse(a)}catch(s){return we.error("Error parsing imported Pixi'VN JSON",s),{}}return a}),r=t.map(async a=>{if(a.initialOperations)for(let s of a.initialOperations)s.type==="value"&&(typeof s.value!="object"||!s.value||!("type"in s.value))&&bf(s);return Promise.resolve()});await Promise.all(r);let i=t.map(async a=>{if(a.initialOperations)for(let s of a.initialOperations)(s.type!=="value"||s.type==="value"&&typeof s.value=="object"&&s.value&&"type"in s.value)&&bf(s);if(a.labels){let s=a.labels;for(let o in s)try{let u=s[o],l=new L0(o,u,void 0,e);RegisteredLabels.add(l);}catch(u){we.error(`Error creating JSON label ${o}`,u);}}return Promise.resolve()});await Promise.all(i);}function HN(){x.init({animateOperation:uf,canvasElementOperation:sf,canvasOperation:af,effectOperation:of,imageContainerOperation:nf,imageOperation:ef,textOperation:rf,narrationOperation:lf,loadAssets:Qp,soundOperation:cf,videoOperation:tf,setStorageValue:df,setInitialStorageValue:pf,getLogichValue:Os.getLogichValue,getConditionalStep:As});}var Y;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...s)))(Y||={});var B0=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,W0=/[\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]/,M0=/[\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]/,zu={Space_Separator:B0,ID_Start:W0,ID_Continue:M0},Se={isSpaceSeparator(n){return typeof n=="string"&&zu.Space_Separator.test(n)},isIdStartChar(n){return typeof n=="string"&&(n>="a"&&n<="z"||n>="A"&&n<="Z"||n==="$"||n==="_"||zu.ID_Start.test(n))},isIdContinueChar(n){return typeof n=="string"&&(n>="a"&&n<="z"||n>="A"&&n<="Z"||n>="0"&&n<="9"||n==="$"||n==="_"||n==="\u200C"||n==="\u200D"||zu.ID_Continue.test(n))},isDigit(n){return typeof n=="string"&&/[0-9]/.test(n)},isHexDigit(n){return typeof n=="string"&&/[0-9A-Fa-f]/.test(n)}},Hu,He,Zt,xs,ln,Pt,Oe,Xu,ii,G0=function(e,t){Hu=String(e),He="start",Zt=[],xs=0,ln=1,Pt=0,Oe=void 0,Xu=void 0,ii=void 0;do Oe=z0(),U0[He]();while(Oe.type!=="eof");return typeof t=="function"?Uu({"":ii},"",t):ii};function Uu(n,e,t){let r=n[e];if(r!=null&&typeof r=="object")if(Array.isArray(r))for(let i=0;i<r.length;i++){let a=String(i),s=Uu(r,a,t);s===void 0?delete r[a]:Object.defineProperty(r,a,{value:s,writable:true,enumerable:true,configurable:true});}else for(let i in r){let a=Uu(r,i,t);a===void 0?delete r[i]:Object.defineProperty(r,i,{value:a,writable:true,enumerable:true,configurable:true});}return t.call(n,e,r)}var L,R,ri,Yt,H;function z0(){for(L="default",R="",ri=false,Yt=1;;){H=Qt();let n=Ef[L]();if(n)return n}}function Qt(){if(Hu[xs])return String.fromCodePoint(Hu.codePointAt(xs))}function A(){let n=Qt();return n===`
|
|
54
|
+
`?(ln++,Pt=0):n?Pt+=n.length:Pt++,n&&(xs+=n.length),n}var Ef={default(){switch(H){case " ":case "\v":case "\f":case " ":case "\xA0":case "\uFEFF":case `
|
|
55
|
+
`:case "\r":case "\u2028":case "\u2029":A();return;case "/":A(),L="comment";return;case void 0:return A(),de("eof")}if(Se.isSpaceSeparator(H)){A();return}return Ef[He]()},comment(){switch(H){case "*":A(),L="multiLineComment";return;case "/":A(),L="singleLineComment";return}throw pe(A())},multiLineComment(){switch(H){case "*":A(),L="multiLineCommentAsterisk";return;case void 0:throw pe(A())}A();},multiLineCommentAsterisk(){switch(H){case "*":A();return;case "/":A(),L="default";return;case void 0:throw pe(A())}A(),L="multiLineComment";},singleLineComment(){switch(H){case `
|
|
56
|
+
`:case "\r":case "\u2028":case "\u2029":A(),L="default";return;case void 0:return A(),de("eof")}A();},value(){switch(H){case "{":case "[":return de("punctuator",A());case "n":return A(),Nn("ull"),de("null",null);case "t":return A(),Nn("rue"),de("boolean",true);case "f":return A(),Nn("alse"),de("boolean",false);case "-":case "+":A()==="-"&&(Yt=-1),L="sign";return;case ".":R=A(),L="decimalPointLeading";return;case "0":R=A(),L="zero";return;case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":R=A(),L="decimalInteger";return;case "I":return A(),Nn("nfinity"),de("numeric",1/0);case "N":return A(),Nn("aN"),de("numeric",NaN);case '"':case "'":ri=A()==='"',R="",L="string";return}throw pe(A())},identifierNameStartEscape(){if(H!=="u")throw pe(A());A();let n=Ku();switch(n){case "$":case "_":break;default:if(!Se.isIdStartChar(n))throw wf();break}R+=n,L="identifierName";},identifierName(){switch(H){case "$":case "_":case "\u200C":case "\u200D":R+=A();return;case "\\":A(),L="identifierNameEscape";return}if(Se.isIdContinueChar(H)){R+=A();return}return de("identifier",R)},identifierNameEscape(){if(H!=="u")throw pe(A());A();let n=Ku();switch(n){case "$":case "_":case "\u200C":case "\u200D":break;default:if(!Se.isIdContinueChar(n))throw wf();break}R+=n,L="identifierName";},sign(){switch(H){case ".":R=A(),L="decimalPointLeading";return;case "0":R=A(),L="zero";return;case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":R=A(),L="decimalInteger";return;case "I":return A(),Nn("nfinity"),de("numeric",Yt*(1/0));case "N":return A(),Nn("aN"),de("numeric",NaN)}throw pe(A())},zero(){switch(H){case ".":R+=A(),L="decimalPoint";return;case "e":case "E":R+=A(),L="decimalExponent";return;case "x":case "X":R+=A(),L="hexadecimal";return}return de("numeric",Yt*0)},decimalInteger(){switch(H){case ".":R+=A(),L="decimalPoint";return;case "e":case "E":R+=A(),L="decimalExponent";return}if(Se.isDigit(H)){R+=A();return}return de("numeric",Yt*Number(R))},decimalPointLeading(){if(Se.isDigit(H)){R+=A(),L="decimalFraction";return}throw pe(A())},decimalPoint(){switch(H){case "e":case "E":R+=A(),L="decimalExponent";return}if(Se.isDigit(H)){R+=A(),L="decimalFraction";return}return de("numeric",Yt*Number(R))},decimalFraction(){switch(H){case "e":case "E":R+=A(),L="decimalExponent";return}if(Se.isDigit(H)){R+=A();return}return de("numeric",Yt*Number(R))},decimalExponent(){switch(H){case "+":case "-":R+=A(),L="decimalExponentSign";return}if(Se.isDigit(H)){R+=A(),L="decimalExponentInteger";return}throw pe(A())},decimalExponentSign(){if(Se.isDigit(H)){R+=A(),L="decimalExponentInteger";return}throw pe(A())},decimalExponentInteger(){if(Se.isDigit(H)){R+=A();return}return de("numeric",Yt*Number(R))},hexadecimal(){if(Se.isHexDigit(H)){R+=A(),L="hexadecimalInteger";return}throw pe(A())},hexadecimalInteger(){if(Se.isHexDigit(H)){R+=A();return}return de("numeric",Yt*Number(R))},string(){switch(H){case "\\":A(),R+=J0();return;case '"':if(ri)return A(),de("string",R);R+=A();return;case "'":if(!ri)return A(),de("string",R);R+=A();return;case `
|
|
57
|
+
`:case "\r":throw pe(A());case "\u2028":case "\u2029":K0(H);break;case void 0:throw pe(A())}R+=A();},start(){switch(H){case "{":case "[":return de("punctuator",A())}L="value";},beforePropertyName(){switch(H){case "$":case "_":R=A(),L="identifierName";return;case "\\":A(),L="identifierNameStartEscape";return;case "}":return de("punctuator",A());case '"':case "'":ri=A()==='"',L="string";return}if(Se.isIdStartChar(H)){R+=A(),L="identifierName";return}throw pe(A())},afterPropertyName(){if(H===":")return de("punctuator",A());throw pe(A())},beforePropertyValue(){L="value";},afterPropertyValue(){switch(H){case ",":case "}":return de("punctuator",A())}throw pe(A())},beforeArrayValue(){if(H==="]")return de("punctuator",A());L="value";},afterArrayValue(){switch(H){case ",":case "]":return de("punctuator",A())}throw pe(A())},end(){throw pe(A())}};function de(n,e){return {type:n,value:e,line:ln,column:Pt}}function Nn(n){for(let e of n){if(Qt()!==e)throw pe(A());A();}}function J0(){switch(Qt()){case "b":return A(),"\b";case "f":return A(),"\f";case "n":return A(),`
|
|
58
|
+
`;case "r":return A(),"\r";case "t":return A()," ";case "v":return A(),"\v";case "0":if(A(),Se.isDigit(Qt()))throw pe(A());return "\0";case "x":return A(),H0();case "u":return A(),Ku();case `
|
|
59
|
+
`:case "\u2028":case "\u2029":return A(),"";case "\r":return A(),Qt()===`
|
|
60
|
+
`&&A(),"";case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":throw pe(A());case void 0:throw pe(A())}return A()}function H0(){let n="",e=Qt();if(!Se.isHexDigit(e)||(n+=A(),e=Qt(),!Se.isHexDigit(e)))throw pe(A());return n+=A(),String.fromCodePoint(parseInt(n,16))}function Ku(){let n="",e=4;for(;e-- >0;){let t=Qt();if(!Se.isHexDigit(t))throw pe(A());n+=A();}return String.fromCodePoint(parseInt(n,16))}var U0={start(){if(Oe.type==="eof")throw Fn();Ju();},beforePropertyName(){switch(Oe.type){case "identifier":case "string":Xu=Oe.value,He="afterPropertyName";return;case "punctuator":Ps();return;case "eof":throw Fn()}},afterPropertyName(){if(Oe.type==="eof")throw Fn();He="beforePropertyValue";},beforePropertyValue(){if(Oe.type==="eof")throw Fn();Ju();},beforeArrayValue(){if(Oe.type==="eof")throw Fn();if(Oe.type==="punctuator"&&Oe.value==="]"){Ps();return}Ju();},afterPropertyValue(){if(Oe.type==="eof")throw Fn();switch(Oe.value){case ",":He="beforePropertyName";return;case "}":Ps();}},afterArrayValue(){if(Oe.type==="eof")throw Fn();switch(Oe.value){case ",":He="beforeArrayValue";return;case "]":Ps();}},end(){}};function Ju(){let n;switch(Oe.type){case "punctuator":switch(Oe.value){case "{":n={};break;case "[":n=[];break}break;case "null":case "boolean":case "numeric":case "string":n=Oe.value;break}if(ii===void 0)ii=n;else {let e=Zt[Zt.length-1];Array.isArray(e)?e.push(n):Object.defineProperty(e,Xu,{value:n,writable:true,enumerable:true,configurable:true});}if(n!==null&&typeof n=="object")Zt.push(n),Array.isArray(n)?He="beforeArrayValue":He="beforePropertyName";else {let e=Zt[Zt.length-1];e==null?He="end":Array.isArray(e)?He="afterArrayValue":He="afterPropertyValue";}}function Ps(){Zt.pop();let n=Zt[Zt.length-1];n==null?He="end":Array.isArray(n)?He="afterArrayValue":He="afterPropertyValue";}function pe(n){return Ts(n===void 0?`JSON5: invalid end of input at ${ln}:${Pt}`:`JSON5: invalid character '${Df(n)}' at ${ln}:${Pt}`)}function Fn(){return Ts(`JSON5: invalid end of input at ${ln}:${Pt}`)}function wf(){return Pt-=5,Ts(`JSON5: invalid identifier character at ${ln}:${Pt}`)}function K0(n){console.warn(`JSON5: '${Df(n)}' in strings is not valid ECMAScript; consider escaping`);}function Df(n){let e={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(e[n])return e[n];if(n<" "){let t=n.charCodeAt(0).toString(16);return "\\x"+("00"+t).substring(t.length)}return n}function Ts(n){let e=new SyntaxError(n);return e.lineNumber=ln,e.columnNumber=Pt,e}var X0=function(e,t,r){let i=[],a="",s,o,u="",l;if(t!=null&&typeof t=="object"&&!Array.isArray(t)&&(r=t.space,l=t.quote,t=t.replacer),typeof t=="function")o=t;else if(Array.isArray(t)){s=[];for(let y of t){let C;typeof y=="string"?C=y:(typeof y=="number"||y instanceof String||y instanceof Number)&&(C=String(y)),C!==void 0&&s.indexOf(C)<0&&s.push(C);}}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)),u=" ".substr(0,r)):typeof r=="string"&&(u=r.substr(0,10)),c("",{"":e});function c(y,C){let S=C[y];switch(S!=null&&(typeof S.toJSON5=="function"?S=S.toJSON5(y):typeof S.toJSON=="function"&&(S=S.toJSON(y))),o&&(S=o.call(C,y,S)),S instanceof Number?S=Number(S):S instanceof String?S=String(S):S instanceof Boolean&&(S=S.valueOf()),S){case null:return "null";case true:return "true";case false:return "false"}if(typeof S=="string")return h(S);if(typeof S=="number")return String(S);if(typeof S=="object")return Array.isArray(S)?g(S):f(S)}function h(y){let C={"'":.1,'"':.2},S={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},v="";for(let _=0;_<y.length;_++){let m=y[_];switch(m){case "'":case '"':C[m]++,v+=m;continue;case "\0":if(Se.isDigit(y[_+1])){v+="\\x00";continue}}if(S[m]){v+=S[m];continue}if(m<" "){let b=m.charCodeAt(0).toString(16);v+="\\x"+("00"+b).substring(b.length);continue}v+=m;}let d=l||Object.keys(C).reduce((_,m)=>C[_]<C[m]?_:m);return v=v.replace(new RegExp(d,"g"),S[d]),d+v+d}function f(y){if(i.indexOf(y)>=0)throw TypeError("Converting circular structure to JSON5");i.push(y);let C=a;a=a+u;let S=s||Object.keys(y),v=[];for(let _ of S){let m=c(_,y);if(m!==void 0){let b=p(_)+":";u!==""&&(b+=" "),b+=m,v.push(b);}}let d;if(v.length===0)d="{}";else {let _;if(u==="")_=v.join(","),d="{"+_+"}";else {let m=`,
|
|
61
|
+
`+a;_=v.join(m),d=`{
|
|
62
|
+
`+a+_+`,
|
|
63
|
+
`+C+"}";}}return i.pop(),a=C,d}function p(y){if(y.length===0)return h(y);let C=String.fromCodePoint(y.codePointAt(0));if(!Se.isIdStartChar(C))return h(y);for(let S=C.length;S<y.length;S++)if(!Se.isIdContinueChar(String.fromCodePoint(y.codePointAt(S))))return h(y);return y}function g(y){if(i.indexOf(y)>=0)throw TypeError("Converting circular structure to JSON5");i.push(y);let C=a;a=a+u;let S=[];for(let d=0;d<y.length;d++){let _=c(String(d),y);S.push(_!==void 0?_:"null");}let v;if(S.length===0)v="[]";else if(u==="")v="["+S.join(",")+"]";else {let d=`,
|
|
64
|
+
`+a,_=S.join(d);v=`[
|
|
65
|
+
`+a+_+`,
|
|
66
|
+
`+C+"]";}return i.pop(),a=C,v}},Y0={parse:G0,stringify:X0},Z0=Y0,si=Z0;var Q0=["dissolve","fade","movein","moveout","zoomin","zoomout","pushin","pushout","wipein","wipeout","irisin","irisout","splitin","splitout","blurin","blurout","pixelatein","pixelateout","flashin","flashout","glitchin","glitchout","twistin","twistout","warpin","warpout","ripplein","rippleout","noisedissolvein","noisedissolveout","tvin","tvout","pinchin","pinchout"],eC=["shake","bounce","pulse","hop","wiggle","nod","sway","punch","glitch","chromatic-aberration","shockwave","radial-blur","blur-pulse","vignette-pulse","desaturate","glow-pulse"];function tC(n){let e=n.split("-").join(" ");return e.charAt(0).toUpperCase()+e.slice(1)}var Of="\xA7SPACE\xA7",Pf="\xA7DOUBLE_QUOTES\xA7",xf="\xA7QUOTES\xA7",Tf="SPECIAL_\xA7QUOTES\xA7",Nf="\xA7CURLY_BRACKETS1\xA7",nC="\xA7INK_VAR\xA7",Ff="\xA7CURLY_BRACKETS2\xA7",T;(v=>{let n=[],e=[];async function t(d,_){for(let m=0;m<n.length;m++)try{let{validation:b}=n[m].opts;if(b instanceof RegExp){if(!b.test(d.join(" ")))continue}else if(b instanceof ZodType&&!b.safeParse(d).success)continue;let E=await n[m].fn(d,_,h);if(E===!0||typeof E=="string")return E}catch{}return false}function r(d,_={name:"custom-command",validation:/^/}){n.unshift({fn:d,opts:_});}v.add=r;function i(){return [...e.map(d=>d.opts),...n.map(d=>d.opts)]}v.info=i;function a(d,_){e.unshift({fn:d,opts:_});}v.addMapper=a;function s(){n.length=0;}v.clear=s;function o(){e.length=0;}v.clearMappers=o;async function u(d,_,m){try{let b=l(d),E=await t(b,m);return E===!0?void 0:typeof E=="string"?(E.startsWith("#")&&(E=E.substring(1)),await v.run(E,_,m)):c(b,_)}catch(b){throw Y.error("Error parsing ink hashtag-command",d),b}}v.run=u;function l(d,_){if(d=d.replaceAll('\\"',Pf),d=d.replaceAll("\\'",xf),d=d.replaceAll("\\`",Tf),d=d.replaceAll("\\{",Nf),d=d.replaceAll("\\}",Ff),_?.mergeInkVariables){let O;do O=d,d=d.replace(/\{[^{}:]*\}/g,nC);while(d!==O)}d=d.replaceAll("{"," { "),d=d.replaceAll("}"," } "),d=d.replaceAll(Nf,"{"),d=d.replaceAll(Ff,"}");let m=[],b,E="";for(let O=0;O<d.length;O++){let P=d[O];P==='"'||P==="'"||P==="`"?b===void 0?(m.push(E),E="",b=P,E+=P):b===P?(b=void 0,E+=P,m.push(E),E=""):E+=P:E+=P;}return E!==""&&m.push(E),m.forEach((O,P)=>{P%2===1&&(m[P]=O.replaceAll(" ",Of));}),d=m.join(""),m=d.split(" ").filter(O=>O!==""),m=m.map(O=>O.replaceAll(Of," ").replaceAll(Pf,'"').replaceAll(xf,"'").replaceAll(Tf,"`")),m=g(m),m=m.flatMap(O=>S(O)),m=m.map(O=>O.startsWith('"')&&O.endsWith('"')||O.startsWith("'")&&O.endsWith("'")||O.startsWith("`")&&O.endsWith("`")?O.slice(1,-1):O),m}v.convertTagTolist=l;function c(d,_,m){for(let b of e){let{validation:E}=b.opts,O=false;if(E instanceof RegExp?O=E.test(d.join(" ")):E instanceof ZodType&&(O=E.safeParse(d).success),O)return b.fn(d,_)}m?.silent||Y.error("The operation is not valid",d);}v.convertOperation=c;function h(d){if(d.length===0)return {};if(d.length%2!==0)throw Y.error("The props list must have a pair number of elements",d),new Error("The props list must have a pair number of elements");let _="{";d.forEach((m,b)=>{if(b%2===0)_+=`"${m}": `;else {switch(m){case "null":case "undefined":case "true":case "false":_+=`${m}`;break;default:p(m)?(m=f(m),_+=`"${m}"`):m.startsWith("{")&&m.endsWith("}")?_+=`${m}`:m.startsWith('"')&&m.endsWith('"')?_+=`${m}`:Number.isNaN(parseFloat(m))?_+=`"${m}"`:_+=`${m}`;}b<d.length-1&&(_+=", ");}}),_+="}";try{return si.parse(_)}catch(m){throw Y.error("Error parsing ink json",_),m}}v.convertListStringToObj=h;function f(d){return d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'")||d.startsWith("`")&&d.endsWith("`")?d.substring(1,d.length-1):d}function p(d){return !!(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'")||d.startsWith("`")&&d.endsWith("`"))}function g(d){return y(d).tokens}v.mergeJsonBlocks=g;function y(d){let _=[],m=false;for(let b=0;b<d.length;b++){let E=d[b];if(E!=="{"){_.push(E);continue}let O=C(d,b);if(O===-1){_.push(E);continue}let P=y(d.slice(b+1,O)),k=["{",...P.tokens,"}"],z=k.join(" ");if(!P.hasInvalidMatchedBlock)try{si.parse(z),_.push(z),b=O;continue}catch{}m=true,_.push(...k),b=O;}return {tokens:_,hasInvalidMatchedBlock:m}}function C(d,_){let m=0;for(let b=_;b<d.length;b++)if(d[b]==="{")m++;else if(d[b]==="}"&&(m--,m===0))return b;return -1}function S(d){if(d==="["||d==="]")return [d];let _=0,m=d.length,b=[];for(;_<m&&d[_]==="[";)b.push("["),_++;let E=[];for(;m>_&&d[m-1]==="]";)E.unshift("]"),m--;let O=d.slice(_,m);return O===""?[...b,...E]:[...b,O,...E]}})(T||={});function rF(n){T.add(n);}function iF(n={}){let e=n.sections?.canvas??true,t=n.sections?.sound??true,r=n.sections?.narration??true,i=n.sections?.assets??true;function a(p){return p&&p.length>0?D.enum(Object.fromEntries(p.map(g=>[g,g]))):D.string()}if(r&&(T.addMapper((p,g)=>{g.labelToOpen={label:p[1],type:"call"},g.goNextStep=void 0;},{name:"Call",deprecated:true,description:"Calls the label specified by the second token, then returns to the current position.\n\n```ink\n# call label_name\n```",validation:D.tuple([D.literal("call"),D.string()])}),T.addMapper((p,g)=>{g.labelToOpen={label:p[1],type:"jump"},g.goNextStep=void 0;},{name:"Jump",deprecated:true,description:"Jumps to the label specified by the second token without returning.\n\n```ink\n# jump label_name\n```",validation:D.tuple([D.literal("jump"),D.string()])}),T.addMapper((p,g)=>("dialogue"in g&&delete g.dialogue,"goNextStep"in g&&delete g.goNextStep,{type:"dialogue",operationType:"clean"}),{name:"Pause",description:"Clears the current dialogue and waits for user input before advancing.\n\n```ink\n# pause\n```",validation:D.tuple([D.literal("pause")])}),T.addMapper((p,g)=>{g.goNextStep=true,g.glueEnabled=false;},{name:"Continue",description:"Forces the story to proceed to the next step automatically.\n\n```ink\n# continue\n```",validation:D.tuple([D.literal("continue")])})),e&&T.addMapper(p=>({type:"video",operationType:p[0],alias:p[2]}),{name:"Pause/Resume video",description:"Pauses or resumes a video canvas element identified by its alias.\n\n```ink\n# pause video <alias>\n# resume video <alias>\n```",validation:D.tuple([D.enum(["pause","resume"]),D.literal("video"),D.string()])}),i&&T.addMapper(p=>({type:p[1],operationType:p[0],aliases:p.slice(2)}),{name:"Load assets/bundle",description:`Loads (eagerly or lazily) a set of asset or bundle aliases.
|
|
67
67
|
|
|
68
68
|
\`\`\`ink
|
|
69
69
|
# load assets <alias...>
|
|
70
70
|
# lazyload assets <alias...>
|
|
71
71
|
# load bundle <alias...>
|
|
72
72
|
# lazyload bundle <alias...>
|
|
73
|
-
\`\`\``,validation:D.union([D.tuple([D.enum(["load","lazyload"]),D.literal("assets")]).rest(a(n.assetAliasIds)),D.tuple([D.enum(["load","lazyload"]),D.literal("bundle")]).rest(a(n.bundleIds))])}),t&&(T.addMapper(f=>({type:"all",operationType:f[0]}),{name:"Pause/Resume/Stop all sounds",description:"Pauses, resumes, or stops all active sounds at once.\n\n```ink\n# pause all sounds\n# resume all sounds\n# stop all sounds\n```",validation:D.tuple([D.enum(["pause","resume","stop"]),D.literal("all"),D.enum(["sounds","sound"])])}),T.addMapper(f=>({type:"sound",operationType:"pause",alias:f[2]}),{name:"Pause sound",description:"Pauses the sound identified by its alias.\n\n```ink\n# pause sound <alias>\n```",validation:D.tuple([D.literal("pause"),D.literal("sound"),D.string()])}),T.addMapper(f=>({type:"channel",operationType:"pause",alias:f[2]}),{name:"Pause channel",description:"Pauses the audio channel identified by its alias.\n\n```ink\n# pause channel <alias>\n```",validation:D.tuple([D.literal("pause"),D.literal("channel"),D.string()])}),T.addMapper(f=>({type:"sound",operationType:"resume",alias:f[2]}),{name:"Resume sound",description:"Resumes the sound identified by its alias.\n\n```ink\n# resume sound <alias>\n```",validation:D.tuple([D.literal("resume"),D.literal("sound"),D.string()])}),T.addMapper(f=>({type:"channel",operationType:"resume",alias:f[2]}),{name:"Resume channel",description:"Resumes the audio channel identified by its alias.\n\n```ink\n# resume channel <alias>\n```",validation:D.tuple([D.literal("resume"),D.literal("channel"),D.string()])}),T.addMapper(f=>({type:"sound",operationType:"stop",alias:f[2]}),{name:"Stop sound",description:"Stops the sound identified by its alias.\n\n```ink\n# stop sound <alias>\n```",validation:D.tuple([D.literal("stop"),D.literal("sound"),D.string()])}),T.addMapper(f=>({type:"sound",operationType:"stop",alias:f[2]}),{name:"Remove sound",description:"Removes (stops) the sound identified by its alias.\n\n```ink\n# remove sound <alias>\n```",deprecated:true,validation:D.tuple([D.literal("remove"),D.literal("sound"),D.string()])}),T.addMapper(f=>({type:"sound",operationType:"edit",alias:f[2],props:T.convertListStringToObj(f.slice(3))}),{name:"Edit sound",description:"Edits the properties of a sound identified by its alias.\n\n```ink\n# edit sound <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("sound"),D.string()]).rest(D.string()).refine(f=>(f.length-3)%2===0)}),T.addMapper(f=>{let g=f[2],y={type:"sound",operationType:"play",alias:g,url:g};if(f.length>3){let C=T.convertListStringToObj(f.slice(3));"source"in C&&typeof C.source=="string"&&(y.url=C.source,delete C.source),Object.keys(C).length>0&&(y.props=C);}return y},{name:"Play sound",description:"Plays a sound using its alias as the URL, with optional key/value properties. Pass `source <value>` among the key/value properties to use a different URL than the alias.\n\n```ink\n# play sound <alias> [<key> <value> \u2026]\n# play sound <alias> source <url> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("play"),D.literal("sound"),a(n.assetAliasIds)]).rest(D.string()).refine(f=>(f.length-3)%2===0)}),T.addMapper(f=>{let g=f[2],y=f[3],C={type:"sound",operationType:"play",alias:g,url:y};return f.length>4&&(C.props=T.convertListStringToObj(f.slice(4))),C},{name:"Play sound with source",deprecated:true,description:"**Deprecated**: use `# play sound <alias> source <url> [<key> <value> \u2026]` instead, passing the URL as a `source` key/value property rather than as a positional argument.\n\nPlays a sound with an explicit source URL and optional key/value properties.\n\n```ink\n# play sound <alias> <source> [<key> <value> \u2026]\n```\n",validation:D.tuple([D.literal("play"),D.literal("sound"),D.string(),a(n.assetAliasIds)]).rest(D.string()).refine(f=>f.length>3&&(f.length-3)%2!==0)})),e){let f=function(m){let b=[],w=0,P="";for(let O of m)O.startsWith("{")?(w++,P+=O):O.endsWith("}")&&w>0?(w--,P+=O,w===0&&(b.push(P),P="")):w>0?P+=O:b.push(O);return b},g=function(m,b){switch(m){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let w={type:m};if(b.length>0)try{w.props=T.convertListStringToObj(b);}catch{}return w},y=function(m,b,w){let P,O;w.length%2===0?(P=b,O=w):(P=w[0],O=w.slice(1));let k={type:m,operationType:"show",alias:b,url:P};if(O.length>0){if(O.includes("with")&&O.length>O.indexOf("with")+1){let z=O[O.indexOf("with")+1],ie=O.slice(O.indexOf("with")+2);O=O.slice(0,O.indexOf("with"));let ue=g(z,ie);ue!==void 0&&(k.transition=ue);}if(O.length>0){let z=T.convertListStringToObj(O);"source"in z&&typeof z.source=="string"&&(k.url=z.source,delete z.source),Object.keys(z).length>0&&(k.props=z);}}return k},C=function(m,b){let w,P;b.length%2===0?(w=m,P=b):(w=b[0],P=b.slice(1));let O={type:"text",operationType:"show",alias:m,text:w};if(P.length>0){if(P.includes("with")&&P.length>P.indexOf("with")+1){let k=P[P.indexOf("with")+1],z=P.slice(P.indexOf("with")+2);P=P.slice(0,P.indexOf("with"));let ie=g(k,z);ie!==void 0&&(O.transition=ie);}P.length>0&&(O.props=T.convertListStringToObj(P));}return O},_=function(m,b,w){let P={type:m,operationType:"remove",alias:b};if(w.includes("with")&&w.length>w.indexOf("with")+1){let O=w[w.indexOf("with")+1],k=w.slice(w.indexOf("with")+2),z=g(O,k);z!==void 0&&(P.transition=z);}return P},v=function(m,b){let w=ue=>ue.startsWith('"')&&ue.endsWith('"')||ue.startsWith("'")&&ue.endsWith("'")||ue.startsWith("`")&&ue.endsWith("`")?ue.substring(1,ue.length-1):ue,P=b.indexOf("["),O=b.indexOf("]",P+1);if(P===-1||O===-1){X.error("Show imagecontainer must have a list of image ulrs",b);return}let k=b.slice(P+1,O);if(k.length===0){X.error("Show imagecontainer must have a list of image ulrs",b);return}let z={type:"imagecontainer",operationType:"show",alias:m,urls:k.map(ue=>w(ue))},ie=b.slice(O+1);if(ie.length>0){if(ie.includes("with")&&ie.length>ie.indexOf("with")+1){let ue=ie[ie.indexOf("with")+1],an=ie.slice(ie.indexOf("with")+2);ie=ie.slice(0,ie.indexOf("with"));let Yr=g(ue,an);Yr!==void 0&&(z.transition=Yr);}ie.length>0&&(z.props=T.convertListStringToObj(ie));}return z},d=function(m){let b=m.indexOf("]",4);if(b===-1)return;let w=m.slice(4,b),P=m.slice(b+1),O=P.indexOf("with");return O===-1?{urls:w,beforeWith:P,afterWith:[]}:{urls:w,beforeWith:P.slice(0,O),afterWith:P.slice(O+1)}};T.addMapper(m=>({alias:m[1],type:"shake",props:T.convertListStringToObj(m.slice(2))}),{name:"Shake",description:"Applies shake effect to a canvas alias with optional key/value parameters.\n\n```ink\n# shake <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("shake"),D.string()]).rest(D.string()).refine(m=>(m.length-2)%2===0)}),T.addMapper(m=>{let b=m.slice(2),w=b,P=[];if(b.includes("options")){let k=b.indexOf("options");w=b.slice(0,k),P=b.slice(k+1);}return {alias:m[1],type:"animate",keyframes:T.convertListStringToObj(w),options:T.convertListStringToObj(P)}},{name:"Animate",description:"Animates a canvas alias with keyframes and optional options section, both in key/value pairs.\n\n```ink\n# animate <alias> [<key> <value> \u2026] [options <key> <value> \u2026]\n```",validation:D.tuple([D.literal("animate"),D.string()]).rest(D.string()).refine(m=>{let b=m.slice(2),w=b.indexOf("options");if(w===-1)return b.length%2===0;if(b.lastIndexOf("options")!==w)return false;let P=b.slice(0,w),O=b.slice(w+1);return P.length%2===0&&O.length%2===0})}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return y("image",b,w)},{name:"Show image",description:"Shows an image canvas element with optional key/value properties and transition effect. Pass `source <value>` among the key/value properties to use a different URL than the alias.\n\n```ink\n# show image <alias> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n# show image <alias> source <url> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("image"),a(n.assetAliasIds)]).rest(D.string())}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return y("image",b,w)},{name:"Show image with source",deprecated:true,description:"**Deprecated**: use `# show image <alias> source <url> [<key> <value> \u2026]` instead, passing the URL as a `source` key/value property rather than as a positional argument.\n\nShows an image canvas element with an explicit source URL, optional key/value properties, and transition effect.\n\n```ink\n# show image <alias> <source> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("image"),D.string(),a(n.assetAliasIds)]).rest(D.string())});let S=a(n.assetAliasIds);T.addMapper(m=>v(m[2],f(m.slice(3))),{name:"Show imagecontainer",description:"Shows an image-container canvas element with a list of image URLs and optional key/value properties.\n\n```ink\n# show imagecontainer <alias> [ <source1> <ursource2> \u2026 ] [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("show"),D.literal("imagecontainer"),D.string(),D.literal("[")]).rest(D.string()).refine(m=>{let b=d(m);return b===void 0?false:b.urls.length>0&&b.urls.every(w=>S.safeParse(w).success)&&b.afterWith.length===0&&b.beforeWith.length%2===0})}),T.addMapper(m=>v(m[2],f(m.slice(3))),{name:"Show imagecontainer with transition",description:"Shows an image-container canvas element with a list of image URLs, optional properties, and a transition effect.\n\n```ink\n# show imagecontainer <alias> [ <ursource1> <source2> \u2026 ] [<key> <value> \u2026] with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout\n```",validation:D.tuple([D.literal("show"),D.literal("imagecontainer"),D.string(),D.literal("[")]).rest(D.string()).refine(m=>{let b=d(m);return b===void 0?false:b.urls.length>0&&b.urls.every(w=>S.safeParse(w).success)&&b.afterWith.length===1&&b.beforeWith.length%2===0})}),T.addMapper(m=>v(m[2],f(m.slice(3))),{name:"Show imagecontainer with transition and props",description:"Shows an image-container canvas element with a list of image URLs, optional properties, a transition effect, and transition key/value properties.\n\n```ink\n# show imagecontainer <alias> [ <url1> <url2> \u2026 ] [<key> <value> \u2026] with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout <key> <value> \u2026\n```",validation:D.tuple([D.literal("show"),D.literal("imagecontainer"),D.string(),D.literal("[")]).rest(D.string()).refine(m=>{let b=d(m);return b===void 0?false:b.urls.length>0&&b.urls.every(w=>S.safeParse(w).success)&&b.afterWith.length>1&&(b.afterWith.length-1)%2===0&&b.beforeWith.length%2===0})}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return y("video",b,w)},{name:"Show video",description:"Shows a video canvas element with optional key/value properties and transition effect. Pass `source <value>` among the key/value properties to use a different URL than the alias.\n\n```ink\n# show video <alias> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n# show video <alias> source <url> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("video"),a(n.assetAliasIds)]).rest(D.string())}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return y("video",b,w)},{name:"Show video with source",deprecated:true,description:"**Deprecated**: use `# show video <alias> source <url> [<key> <value> \u2026]` instead, passing the URL as a `source` key/value property rather than as a positional argument.\n\nShows a video canvas element with an explicit source URL, optional key/value properties, and transition effect.\n\n```ink\n# show video <alias> <source> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("video"),D.string(),a(n.assetAliasIds)]).rest(D.string())}),T.addMapper(m=>{let b=m[2];return C(b,m.slice(3))},{name:"Show text",description:"Shows a text canvas element with optional text content, key/value properties, and transition effect.\n\n```ink\n# show text <alias> [<text>] [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("text"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return _("image",b,w)},{name:"Remove image",description:"Removes an image canvas element with an optional transition effect.\n\n```ink\n# remove image <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("image"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return _("video",b,w)},{name:"Remove video",description:"Removes a video canvas element with an optional transition effect.\n\n```ink\n# remove video <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("video"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return _("canvaselement",b,w)},{name:"Remove canvas element",description:"Removes a canvas element with an optional transition effect.\n\n```ink\n# remove canvaselement <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("canvaselement"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return _("text",b,w)},{name:"Remove text",description:"Removes a text canvas element with an optional transition effect.\n\n```ink\n# remove text <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("text"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],w=f(m.slice(3));return _("imagecontainer",b,w)},{name:"Remove imagecontainer",description:"Removes an image-container canvas element with an optional transition effect.\n\n```ink\n# remove imagecontainer <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("imagecontainer"),D.string()]).rest(D.string())}),T.addMapper(()=>({type:"canvas",operationType:"clear"}),{name:"Clear canvas",description:"Removes every element currently on the canvas.\n\n```ink\n# clear canvas\n```",validation:D.tuple([D.literal("clear"),D.literal("canvas")])}),T.addMapper(m=>({type:"image",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit image",description:"Edits the properties of an image canvas element identified by its alias.\n\n```ink\n# edit image <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("image"),D.string()]).rest(D.string())}),T.addMapper(m=>({type:"imagecontainer",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit imagecontainer",description:"Edits the properties of an image-container canvas element identified by its alias.\n\n```ink\n# edit imagecontainer <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("imagecontainer"),D.string()]).rest(D.string())}),T.addMapper(m=>({type:"canvaselement",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit canvas element",description:"Edits the properties of a canvas element identified by its alias.\n\n```ink\n# edit canvaselement <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("canvaselement"),D.string()]).rest(D.string())}),T.addMapper(m=>({type:"video",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit video",description:"Edits the properties of a video canvas element identified by its alias.\n\n```ink\n# edit video <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("video"),D.string()]).rest(D.string())}),T.addMapper(m=>({type:"text",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit text",description:"Edits the properties of a text canvas element identified by its alias.\n\n```ink\n# edit text <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("text"),D.string()]).rest(D.string())});}r&&(T.addMapper(f=>({type:"input",operationType:"request"}),{name:"Request input",description:"Requests player input without any additional constraints.\n\n```ink\n# request input\n```",validation:D.tuple([D.literal("request"),D.literal("input")])}),T.addMapper(f=>{let g={type:"input",operationType:"request"};try{let y=T.convertListStringToObj(f.slice(2));"type"in y&&typeof y.type=="string"&&(g.valueType=y.type),"default"in y&&(g.defaultValue=y.default);}catch{}return g},{name:"Request input with params",description:"Requests player input with optional key/value parameters (e.g. type, default).\n\n```ink\n# request input <key> <value> [<key> <value> \u2026]\n# request input type number default 18\n```",validation:D.tuple([D.literal("request"),D.literal("input")]).rest(D.string()).refine(f=>f.length>2&&(f.length-2)%2===0)}));}var xs="global decl",Nn="___external_value___",dF=/\[([^\]]+)\]/;var Np=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],Fp=["+","-","/","*","%","POW","RANDOM","L^"],Ip=["INT","FLOOR","FLOAT"];function ir(n,e){if(n.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(n)&&(n=n.split(".").filter(i=>!i.match(/^[0-9]+$/)).join("."),!n.startsWith(".")))return n.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(n)&&n.includes("g-")){let r=n.split("g-");return Ku(e)+"_|_"+"g-"+r[r.length-1]}let t=0;for(;new RegExp(/^\.\^.*$/).test(n);)t++,n=n.substring(2);if(t=t-1,new RegExp(/^\..*$/).test(n)&&e){let r=n.substring(1);return Ku(e,t)+"_|_"+r.replaceAll(".","_|_")}return n.replaceAll(".","_|_")||Ku(e,t).replaceAll(".","_|_")}function Ku(n,e=0){let t=n.split("_|_");for(;t.length>1&&e>0;)t.pop()?.includes("g-")&&e--,e--;return t.join("_|_")}var kp="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function kt(n){return n.startsWith("^")&&(n=n.substring(1)),n=n.replaceAll("\\\\",kp),n=n.replaceAll("\\n",`
|
|
74
|
-
`),n=n.replaceAll("\\t"," "),n=n.replaceAll(" "," "),n=n.replaceAll(kp,"\\\\"),n}var lb={version:"1.14.0"};var Vp=`https://pixi-vn.com/schemas/${lb.version}/schema.json`,Rp=["==","!=","<","<=",">",">=","CONTAINS"];function un(n,e,t,r){let{functions:i}=r;n=n.map(s=>{if(typeof s=="string")switch(s){case "rnd":return "RANDOM";case "?":return "CONTAINS"}return s});let a=[];return n.forEach(s=>{if(typeof s=="string")switch(s){case "&&":case "||":if(a.length>=2){let o={type:"union",unionType:s==="&&"?"and":"or",conditions:[a[a.length-2],a[a.length-1]]};a.pop(),a.pop(),a.push(o);}break;case "!":if(a.length===0)X.error("Error parsing ink file: Conditional statement is not valid",n);else {let o={type:"union",unionType:"not",condition:a[a.length-1]};a[a.length-1]=o;}break;case "!?":if(a.length>1){let o={type:"union",unionType:"not",condition:{type:"compare",operator:"CONTAINS",leftValue:a[a.length-2],rightValue:a[a.length-1]}};a.pop(),a.pop(),a.push(o);}else X.error("Error parsing ink file: Conditional statement is not valid",n);break;default:if(Rp.includes(s))if(a.length<2)X.error("Error parsing ink file: Conditional statement is not valid",n);else {let o={type:"compare",operator:s,rightValue:a[a.length-1],leftValue:a[a.length-2]};a.pop(),a.pop(),a.push(o);}else if(Fp.includes(s))if(a.length<2)X.error("Error parsing ink file: Conditional statement is not valid",n);else {s==="L^"&&(s="INTERSECTION");let o={type:"arithmetic",operator:s,rightValue:a[a.length-1],leftValue:a[a.length-2]};a.pop(),a.pop(),a.push(o);}else if(Ip.includes(s)){let o={type:"arithmeticsingle",operator:s,leftValue:a[a.length-1]};a.pop(),a.push(o);}else s.startsWith("^")&&a.push(kt(s));}else if(typeof s=="object"&&"CNT?"in s)if(new RegExp(/.*\.[0-9]\..*/).test(s["CNT?"])){let o=s["CNT?"].split("."),u=o.pop(),l=o.pop();if(l===void 0||u===void 0){X.error("Error parsing ink file: Conditional statement is not valid",n);return}let c=Number(l),h=o.join(".");if(h.includes("^.")){let f=h.split("."),g=f[f.length-1].replaceAll(".","_|_");f.pop(),h=`${f.join(".")}.${g}`,u.includes("c-")&&(h=h+"_|_"+u);}else h=h.replaceAll(".","_|_");let p=ir(h,e);if(!p)return;a.push({type:"compare",leftValue:Xu(p),operator:">=",rightValue:{type:"value",value:c}});}else {let o=ir(s["CNT?"],e);if(!o)return;a.push(Xu(o));}else if(typeof s=="object"&&"VAR?"in s)a.push(Fn({key:s["VAR?"],defaultType:"storage"},t));else if(typeof s=="object"&&"f()"in s){let o=s["f()"],u=i.find(c=>c.name===o);if(!u){X.error(`Error parsing ink file: Function ${o} is not defined`,n);return}let l=[];for(let c=0;c<u.args;c++)a.length!==0&&l.push(a.pop());a.push({type:"function",functionName:o,args:l.reverse()});}else if(typeof s=="object"&&"^->"in s)s["^->"].includes("$r")||a.push(s["^->"]);else if(typeof s=="object"&&"list"in s){let o=Object.values(s.list).map(u=>u);a.push(o);}else a.push(s);}),a}function Yu(n,e,t,r){return un(n,e,t,r)}function Fn(n,e,t){let{key:r,defaultType:i}=n,a=e.indexOf(r);return a>=0?{type:"value",storageType:"params",storageOperationType:"get",key:a}:{type:"value",storageOperationType:"get",storageType:i,key:r}}function ii(n,e,t){let{key:r,value:i,defaultType:a,artmeticValue:s}=n,o=e.indexOf(r);if(o>=0)return [{type:"value",storageType:"params",storageOperationType:"set",key:o,value:i}];if(s){if(typeof i=="object"&&"list"in i){let u=Object.values(i.list).map(l=>l);return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:u}]}return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:i}]}else if(typeof i=="object"){if("list"in i&&typeof i.list=="object"){if("origins"in i&&Array.isArray(i.origins)&&i.origins.length>0)return i.origins.reduce(u=>(u.push({type:"value",storageOperationType:"set",storageType:a,key:r,value:Object.values(t.enums[r])}),Object.entries(t.enums[r]).forEach(([l,c])=>{u.push({type:"value",storageOperationType:"set",storageType:a,key:`${r}.${l}`,value:c});}),u),[]);{let u=new Set,l=Object.entries(i.list).reduce((c,[h,p])=>{let[f,g]=h.split(".");return c.push({type:"value",storageOperationType:"set",storageType:a,key:g,value:p}),u.add(f),c},[]);return u.forEach(c=>{l.push({type:"value",storageOperationType:"set",storageType:a,key:c,value:Object.values(t.enums[c])});}),r in t.enums?Object.entries(t.enums[r]).forEach(([c,h])=>{l.push({type:"value",storageOperationType:"set",storageType:a,key:`${r}.${c}`,value:h});}):l.push({type:"value",storageOperationType:"set",storageType:a,key:r,value:Object.values(i.list)}),l}}else if(typeof i=="object"&&"VAR?"in i){if(typeof i["VAR?"]=="string"&&i["VAR?"].includes(".")){let[u,l]=i["VAR?"].split(".");if(u in t.enums&&l in t.enums[u])return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:t.enums[u][l]}]}return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:Fn({key:i["VAR?"],defaultType:"storage"},e)}]}}return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:i}]}function Xu(n){return {type:"value",storageType:"label",storageOperationType:"get",label:n}}function Zu(n,e){return e||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(n)?"call":"jump"}function Ts(n,e){if(e){if(typeof e=="string")e.startsWith("^")&&n.push(kt(e));else if(typeof e=="object"&&"type"in e)switch(e.type){case "value":case "function":console.warn("Warning: trying to add a value or function operation as text. This is likely a mistake, so it will be ignored.");break;default:n.push(e);}}}function Qu(n,e,t,r,i,a={}){let{isNewLine:s=true,isHashtagScript:o=false,isThreads:u=false}=a;return hb(n,e,t,r,i,{isNewLine:s,isHashtagScript:o,isThreads:u})}function hb(n,e,t,r,i,a){if(!e)return;let{isNewLine:s,isHashtagScript:o=false,isThreads:u}=a;if(o){if(Array.isArray(e)&&e.length>0){let l={goNextStep:true},c=[];try{if(e.length===1&&typeof e[0]=="string"){let h=e[0],p=T.convertTagTolist(h),f=T.convertOperation(p,l,{silent:!0});f&&(f.$origin=h,c.push(f));}}catch{}c.length===0&&c.push({type:"operationtoconvert",values:e}),n.push({...l,operations:c});}}else if(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"){if(!s&&n.length>0){let l=n[n.length-1];!l.glueEnabled&&!l.operations&&!l.labelToOpen&&(l.glueEnabled=true,l.labelToOpen||(l.goNextStep=true)),n[n.length-1]=l;}typeof e=="string"?n.push(db(kt(e),r.characterIds)):n.push({dialogue:e});}else if(typeof e=="string"){if(e==="end")n.push({end:"game_end"});else if(e==="done")n.push({end:"label_end",goNextStep:true});else if(e==="<>")if(n.length>0){let l=n[n.length-1];l.glueEnabled=true;let c=l.operations!==void 0&&l.dialogue===void 0;l.labelToOpen||(l.goNextStep=c?true:!s),n[n.length-1]=l;}else n.push({glueEnabled:true,goNextStep:true});}else if(typeof e=="object"){if("type"in e)switch(e.type){case "value":e.storageOperationType==="set"?(typeof e.value=="string"&&e.value.startsWith("^")&&(e.value=kt(e.value)),n.push({goNextStep:true,operations:[e]})):console.warn("Warning: trying to add a value get operation as step. This is likely a mistake, so it will be ignored.");break;case "function":n.push({goNextStep:true,operations:[e]});break;default:if(!s&&n.length>0){let l=n[n.length-1];!l.glueEnabled&&!l.operations&&(l.glueEnabled=true,l.labelToOpen||(l.goNextStep=true)),n[n.length-1]=l;}n.push({conditionalStep:e});}else if("->"in e){let l=s?void 0:true;if(l&&t.includes("c-")&&n.length>0&&n[n.length-1]?.dialogue===void 0&&(l=void 0),!s&&n.length>0){let c=n[n.length-1];c.labelToOpen||(c.goNextStep=true),n[n.length-1]=c;}if(e.params&&e.params.length===0&&delete e.params,e.var)n.push({labelToOpen:{label:Fn({key:e["->"],defaultType:"storage"},i),type:u?"call":"jump",params:e.params},glueEnabled:l});else {let c=ir(e["->"],t);if(!c)return;n.push({labelToOpen:{label:c,type:Zu(c,u),params:e.params},glueEnabled:l});}}else if("->t->"in e){let l=s?void 0:true;if(l&&t.includes("c-")&&n.length>0&&n[n.length-1]?.dialogue===void 0&&(l=void 0),!s&&n.length>0){let h=n[n.length-1];h.labelToOpen||(h.goNextStep=true),n[n.length-1]=h;}e.params&&e.params.length===0&&delete e.params;let c=ir(e["->t->"],t);if(!c)return;n.push({labelToOpen:{label:c,type:"call",params:e.params},glueEnabled:l});}}}function db(n,e){let t;if(n.includes(": ")){let r=n.split(": "),i=r[0],a=r.slice(1).join(": ");(e?.has(i)||RegisteredCharacters.has(i))&&(t=i,n=a);}return t?{dialogue:{character:t,text:n}}:{dialogue:n}}function el(n,e,t,r=true,i=false){return fb(n,e,t,r,i)}function fb(n,e,t,r,i=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"?typeof e=="string"?n.push(kt(e)):n.push(e):typeof e=="object"&&"type"in e&&n.push(e));}function Ns(n,e,t,r){if(n.length===0){X.error("Error parsing ink file: Arithmetic statement is not valid",n);return}let i=un(n,e,t,r);if(i.length===1){let a=i[0];return a&&typeof a=="object"&&"type"in a?{type:"value",storageType:"logic",storageOperationType:"get",operation:a}:a}}function sr(n,e,t,r="",i,a,s=void 0){let o=[],u="sequential",l=false,c=true;n.forEach(f=>{f==="%"&&(u="loop"),f==="seq"&&(u="random"),f==="MIN"&&(l=true);});let h=n[n.length-1];return Object.keys(h).forEach(f=>{let g=h[f];if(Array.isArray(g)&&g.length>3){g=g.slice(1,g.length-2);let y=[];ln(g,r,i,y,e,e,t,ar,s,true,a),y.length===1?o.push(y[0]):o.push({type:"resulttocombine",combine:"cross",secondConditionalItem:y});}else Array.isArray(g)&&g.length===3&&(c=false);}),u==="sequential"?{type:"stepswitch",elements:o,choiceType:u,end:c?"lastItem":void 0,nestedId:s}:l&&u==="random"?{type:"stepswitch",elements:o,choiceType:"sequentialrandom",end:c?"lastItem":void 0,nestedId:s}:{type:"stepswitch",elements:o,choiceType:u}}function ln(n,e,t,r=[],i,a,s,o,u=void 0,l=true,c=[]){let h=false,p=[],f=false,g=false,y=false,C=[],_=[];if(t.preDialog[e]&&(l=false,i(r,`^${t.preDialog[e].text}`,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),t.preDialog[e].glue&&i(r,"<>",e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),delete t.preDialog[e]),n.includes("visit")){let d=sr(n,a,s,e,t,c,u);d&&(!l&&r.length>0&&i(r,"<>",e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}));return}let v=n[0];if(v&&typeof v=="object"&&"temp="in v){for(;n[0]&&typeof n[0]=="object"&&"temp="in n[0];)c.push(n[0]["temp="]),n.shift();c=c.reverse();}if(n.forEach((d,S)=>{if(g){if(typeof d=="string"&&d==="/#"){let m=[];ln(_,e,t,m,el,el,s,o,u,l),i(r,m,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),g=false,_=[];}else _.push(d);return}else if(h)if(Array.isArray(d))p.push(d);else if(d&&typeof d=="object")"CNT?"in d?S>0&&n[S-1]==="ev"?(f=true,C.push(d)):f?C.push(d):(p.push(d),l=false):"VAR="in d||"temp="in d?ii({key:"VAR="in d?d["VAR="]:d["temp="],value:n[S-1],defaultType:"VAR="in d?"storage":"tempstorage"},c,t).forEach(b=>{if(b.value&&typeof b.value=="string"&&b.value==="/str"&&(b.value=n[S-2]),b.value&&typeof b.value=="object"&&"^->"in b.value&&(b.value=b.value["^->"]),p.length>1){let w=Ns(p,e,c,t);p=[],w&&typeof w=="object"&&"type"in w&&w.type==="value"&&"storageType"in w&&w.storageType==="logic"&&(b.value=w.operation);}(typeof b.key!="string"||!b.key.includes("$r"))&&(i(r,b,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=true);}):"VAR?"in d?p.push(d):"^->"in d?d["^->"].includes("$r")||p.push(d):("f()"in d||"list"in d&&typeof d.list=="object")&&p.push(d);else switch(d){case "/ev":f&&C.push(d),h=false,p.push(d);break;case "out":if(p.length>0){let m=p[p.length-1];if(m&&typeof m=="object"&&"VAR?"in m){p.pop();let b=Fn({key:m["VAR?"],defaultType:"storage"},c);i(r,b,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y});}else {let b=[];for(;p.length>0&&p[p.length-1]!=="/ev";)b.push(p.pop());b=b.reverse();let w=Ns(b,e,c,t);p=[],w&&typeof w=="object"&&"type"in w&&w.type==="value"&&"storageType"in w&&w.storageType==="logic"?i(r,{storageOperationType:"get",storageType:"logic",operation:w.operation,type:"value"},e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}):(i(r,"<>",e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),w=`^${w}`,i(r,w,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}));}l=false;}break;case "pop":{let m=p[p.length-1];if(m&&typeof m=="object"&&"f()"in m){let b=[];for(;p.length>0&&p[p.length-1]!=="/ev";)b.push(p.pop());b=b.reverse();let w=un(b,e,c,t);p=[],w.forEach(P=>{P&&typeof P=="object"&&"type"in P&&P.type==="function"?i(r,P,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}):X.warn("Unhandled case: value is not a function",P);}),l=false;}else p.push(d);return}default:p.push(d);}else if(typeof d=="string")if(d.startsWith("^"))i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;else if(d==="ev")h=true;else if(d===`
|
|
75
|
-
`)l=true;else if(d==="done"||d==="end")i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;else if(d==="<>")i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;else if(d==="nop"&&f){let m=$p(C,a,s,e,t,c,u);m&&i(r,m,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),f=false,C=[];}else d==="#"?g=true:d==="thread"&&(y=true);else if(Array.isArray(d))if(f)C.push(d);else if(d.length>1&&typeof d[d.length-2]=="object"&&d[d.length-2]&&"c"in d[d.length-2]&&typeof d[d.length-1]=="object"&&d[d.length-1]&&"b"in d[d.length-1]){p.pop();let m=[],b=[];for(;p.length>0&&p[p.length-1]!=="/ev";)m.push(p.pop());C=[...C,...m.reverse()],f=true,b.push(d.pop()),b.push(d.pop()),C=[...C,...d],C.push(b);}else if(d.length>1&&typeof d[d.length-1]=="object"&&d[d.length-1]&&"#n"in d[d.length-1]){let m=d.pop();if(!m){X.error("Error parsing ink file: el is undefined");return}let b=m["#n"];delete m["#n"],d.push(m),i(r,{"->":e?e+"_|_"+b:b},e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),s({[b]:d},e,t);}else ln(d,e,t,r,i,a,s,o,u,l,c);else if(d&&typeof d=="object")if("->"in d&&typeof d["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(d["->"])){let m=[];p.length>0&&(m=Yu(["ev",...p],e,c,t)),d.params=m,i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;}else if("->t->"in d&&typeof d["->t->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(d["->t->"])){let m=[];p.length>0&&(m=Yu(["ev",...p],e,c,t)),d.params=m,i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;}else if("*"in d&&typeof d["*"]=="string")d["*"].includes("c")&&(p.push(d),l=false);else if("s"in d&&Array.isArray(d.s))p.push(d),l=false;else if("CNT?"in d)p.push(d),l=false;else if("VAR="in d||"temp="in d){let m="VAR="in d?d["VAR="]:d["temp="],b,w=[];if(m!=="$r"){for(p.pop(),p[p.length-1]==="/ev"&&p.pop();p.length>0&&p[p.length-1]!=="/ev";)w.push(p.pop());w=w.reverse(),b=Ns(w,e,c,t),p=[],ii({key:m,value:b,defaultType:"VAR="in d?"storage":"tempstorage",artmeticValue:true},c,t).forEach(O=>{(O.value!==void 0||O.value!==null)&&i(r,O,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y});}),l=false;}}else s(d,e,t);}),o(p,r,e,t,c),e.includes("_|_")&&r.length===2){let d=r[0],S=r[1];d&&S&&typeof d=="object"&&"dialogue"in d&&typeof S=="object"&&"labelToOpen"in S&&d.dialogue===" "&&S.labelToOpen&&(r.shift(),delete S.glueEnabled,r[0]=S);}}function nl(n,e,t,r,i,a){if(e.length===0)return;let s=un(e,r,t,i);if(s.length===1){let o={type:"ifelse",condition:s[0],then:n,else:a};return o.else||delete o.else,o}else if(s.length>1){let o={type:"ifelse",condition:{type:"union",unionType:"and",conditions:s},then:n,else:a};return o.else||delete o.else,o}}function $p(n,e,t,r,i,a,s=void 0){if(n.length===0){X.error("Error parsing ink file: Conditional statement is not valid",n);return}let o=[],u=[];if(n.forEach(h=>{Array.isArray(h)?u.push(h):typeof h=="string"&&h==="du"?i.du?o.push(i.du):i.du=o[o.length-1]:(typeof h!="string"||h!=="/ev")&&o.push(h);}),u.length===0){X.error("Error parsing ink file: Conditional statement is not valid",u);return}let l=tl(u[0],e,t,`${r}${"_|_"}then`,i,a,`${s||""}then`),c;return u.length===2?c=tl(u[1],e,t,`${r}${"_|_"}else`,i,a,`${s||""}else`):u.length>2?(u.shift(),u.push("nop"),u=[{b:u}],c=tl(u,e,t,r,i,a,`${s||""}else`)):c=void 0,i.du=void 0,nl(l,o,a,r,i,c)}function tl(n,e,t,r,i,a,s=void 0){let o=[];for(let l of n)typeof l=="object"&&"b"in l&&(l.b=l.b.filter(c=>c!==null&&!(typeof c=="object"&&"->"in c&&new RegExp(/.*\.[0-9]/).test(c["->"]))),ln(l.b,r,i,o,e,e,t,ar,s,true,a));return o.length===1?o[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:o}}function rl(n="",e=""){let t=Array.isArray(n)?n:[n],r=Array.isArray(e)?e:[e];return [...new Set([...t,...r])]}function ar(n,e,t,r,i){if(n.length>0){let a={};jp(n,a,i,r);for(let[s,o]of Object.entries(a)){let u=t+"_|_"+s,l={text:o.text.length===1?o.text[0]:o.text,label:u,props:{},type:Zu(u,false),oneTime:o.onetime};o.text.length===0&&(l.onlyHaveNoChoice=true,l.autoSelect=true),l.oneTime===false&&delete l.oneTime;let c=nl(l,o.conditions,i,t,r)||l,h=e[e.length-1];if(typeof h=="object"&&h&&"type"in h&&(h={conditionalStep:h}),e.length>0&&typeof h=="object"&&h&&"choices"in h&&h.choices){let p=h.choices;p&&Array.isArray(p)?p.push(c):X.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",o,p),h.choices=p.sort((f,g)=>{try{let y=f.label.split("."),C=y[y.length-1].replaceAll(".","_|_"),_=g.label.split("."),v=_[_.length-1].replaceAll(".","_|_");if(C.includes("c-")&&v.includes("c-")){let d=C.split("c-")[1],S=Number(d),m=v.split("c-")[1],b=Number(m);return S-b}}catch{}return 0});}else e.push({choices:[c]});o.preDialog&&(r.preDialog[u]={...o.preDialog});}}}function jp(n,e,t,r,i){let a=[],s="",o="",u=false,l=[];for(let c=0;c<n.length;c++){let h=n[c];if(typeof h=="string")h.startsWith("^")?a.push(kt(h)):Np.includes(h)&&l.push(h);else if(Array.isArray(h)&&h.includes("visit")){let p=sr(h,Ts,(f,g,y)=>{},i,r,t);a.push(p);}else if(h&&typeof h=="object")if("*"in h&&typeof h["*"]&&typeof h["*"]=="string")h["*"].includes("c")&&(s=`c${h["*"].split("c")[1]}`,h.flg&16&&(u=true));else if("s"in h&&Array.isArray(h.s)){let p=Lp(h.s),f=h.s.includes("<>");p&&(i&&e[i]?(e[i].preDialog={text:p,glue:f},e[i].text=rl(p,e[i].text)):(a.push(p),o=p));}else ("CNT?"in h||"VAR?"in h)&&l.push(h);else l.push(h);if(s){e[s]?e[s].text=rl(a,e[s].text):e[s]={text:a,onetime:u,conditions:l},o&&(e[s].preDialog={text:o,glue:false});let p=n.slice(c+1);jp(p,e,t,r,s);return}}}function Lp(n){for(let e of n)if(typeof e=="string"){if(e.startsWith("^"))return kt(e)}else if(Array.isArray(e)){let t=Lp(e);if(t)return t}}var il;(i=>{function n(a,s={}){let{labelToRemove:o=[],initialVarsToRemove:u=[],enums:l={},functions:c=[],preDialog:h={},characterIds:p}=s,f={$schema:Vp};if(f.labels=e(a.root,{labelToRemove:o,initialVarsToRemove:u,enums:l,functions:c,preDialog:h,characterIds:p}),f.labels&&xs in f.labels){let g=f.labels[xs];delete f.labels[xs],g.forEach(y=>{y.operations&&(f.initialOperations=f.initialOperations?[...f.initialOperations,...y.operations]:[...y.operations]);});}if(f.labels&&Nn in f.labels){let g=f.labels[Nn];delete f.labels[Nn],g.forEach(y=>{y.operations&&(f.initialOperations=f.initialOperations?[...f.initialOperations,...y.operations]:[...y.operations]);});}return o.forEach(g=>{f.labels&&g in f.labels&&delete f.labels[g];}),u.forEach(g=>{f.initialOperations&&(f.initialOperations=f.initialOperations.filter(y=>!(y.type==="value"&&y.key===g)));}),f}i.inkToJson=n;function e(a,s){try{let o={};return t(a,o,s),o}catch(o){X.error("Error parsing ink file",o);}}function t(a,s,o){for(let u of a)if(u)if(Array.isArray(u))if(u.includes("visit")){let l=sr(u,Ts,(c,h,p)=>{},"",o,[]);l&&(o.externalSwitch=l);}else t(u,s,o);else typeof u=="object"&&(u&&"VAR="in u&&o.externalSwitch&&(s[Nn]||(s[Nn]=[]),s[Nn].push({operations:ii({defaultType:"storage",key:u["VAR="],value:o.externalSwitch},[],o)})),r(u,s,"",o));}function r(a,s,o="",u){if(a!==null){for(let[l,c]of Object.entries(a))if(Array.isArray(c)){let h=[],p={},f=(o?o+"_|_":"")+l;ln(c,f,u,h,Qu,Qu,(g,y,C)=>{r(g,p,y,C);},ar);for(let[g,y]of Object.entries(p))s[g]=y;h.length>0&&(s[f]=h);}}}})(il||={});var Gf=Zr(gy(),1),G0=Zr(Jy(),1),z0=Zr(L0(),1),J0=Zr(Ar(),1),oN=/(?:^|<>)\s*#\s*([^\r\n]+)/g,uN=/^=+[ \t]+(?:function[ \t]+)?(\w+)/gm,lN=new Set(["DONE","END"]),cN="_|_",q0=new Map;function H0(n,e){let t=JSON.stringify([e,n]),r=q0.get(t);if(r)return r;let i=new RegExp(n,e);return q0.set(t,i),i}function bs(n,e){if(!e||typeof e!="object")return false;let t=e,r=t.anyOf;if(Array.isArray(r))return r.some(s=>bs(n,s));let i=t.oneOf;if(Array.isArray(i))return i.some(s=>bs(n,s));let a=t.allOf;if(Array.isArray(a))return a.every(s=>bs(n,s));if(typeof t.const=="string")return n===t.const;if(Array.isArray(t.enum))return t.enum.some(s=>typeof s=="string"&&s===n);if(t.type!=="string"||typeof t.minLength=="number"&&n.length<t.minLength||typeof t.maxLength=="number"&&n.length>t.maxLength)return false;if(typeof t.pattern=="string")try{if(!H0(t.pattern,"").test(n))return !1}catch{return false}return true}function Ru(n,e){if(!e||typeof e!="object")return false;let t=e,r=t.anyOf;if(Array.isArray(r))return r.some(o=>Ru(n,o));let i=t.oneOf;if(Array.isArray(i))return i.some(o=>Ru(n,o));let a=t.allOf;if(Array.isArray(a))return a.every(o=>Ru(n,o));if(t.type!=="array"||typeof t.minItems=="number"&&n.length<t.minItems||typeof t.maxItems=="number"&&n.length>t.maxItems)return false;let s=Array.isArray(t.prefixItems)?t.prefixItems:[];if(n.length<s.length)return false;for(let o=0;o<s.length;o++)if(!bs(n[o],s[o]))return false;return n.length===s.length?true:t.items===false||typeof t.items>"u"?false:t.items===true?true:n.slice(s.length).every(o=>bs(o,t.items))}function Bf(n,e){if(e.type==="regexp")try{let t=H0(e.source,e.flags);return t.lastIndex=0,t.test(n.join(" "))}catch{return false}return e.type==="literal"?n.join(" ")===e.value:Ru(n,e.schema)}function $u(n){if(!n||typeof n!="object")return [];let e=n;if(Array.isArray(e.anyOf))return e.anyOf.flatMap($u);if(Array.isArray(e.oneOf))return e.oneOf.flatMap($u);if(Array.isArray(e.allOf)){let t={};for(let r of e.allOf)r&&typeof r=="object"&&Object.assign(t,r);return $u(t)}return e.type==="array"&&Array.isArray(e.prefixItems)?[e]:[]}function B0(n,e){if(n===e)return 1;let t=Math.max(n.length,e.length);return t===0?1:Math.max(0,1-U0(n,e)/t)}function hN(n,e){if(e&&typeof e=="object"){let t=e;if(typeof t.const=="string")return {weight:2,matched:n===void 0?0:2*B0(n,t.const)};if(Array.isArray(t.enum))return {weight:2,matched:2*(n===void 0?0:Math.max(0,...t.enum.filter(i=>typeof i=="string").map(i=>B0(n,i))))}}return {weight:1,matched:n===void 0?0:1}}function dN(n,e){let t=Array.isArray(e.prefixItems)?e.prefixItems:[],r=Math.min(t.length,n.length),i=0,a=0,s=false;for(let o=0;o<r;o++){let u=hN(n[o],t[o]);i+=u.weight,a+=u.matched,u.weight>1&&(s=true);}return {score:i===0?0:a/i,hasDiscriminant:s}}var fN=.8,W0=new Map;function pN(n){let e=JSON.stringify(n),t=W0.get(e);if(t)return t;let r=new G0.default({strict:false,allErrors:true}).compile(n);return W0.set(e,r),r}function mN(n){if("items"in n)return n;let e=Array.isArray(n.prefixItems)?n.prefixItems.length:0;return {...n,minItems:e,maxItems:e,items:false}}function gN(n,e){let[t]=Bu(n.instancePath);if(t!==void 0&&/^\d+$/.test(t)){let r=Number(t);if(r<e.length)return e[r]}return zf(n)}function yN(n){return n.keyword==="const"?`must be "${n.params.allowedValue}"`:n.keyword==="enum"?`must be one of ${(n.params.allowedValues??[]).map(t=>`"${t}"`).join(", ")}`:n.message??"invalid value"}function Wf(n){let e=n.split(/\r?\n/),t=[];for(let r=0;r<e.length;r++){let i=e[r];for(let a of i.matchAll(oN)){let s=(a[1]??"").trim();if(!s)continue;let o=T.convertTagTolist(s,{mergeInkVariables:true});o.length!==0&&t.push({line:r+1,command:s,tokens:o});}}return t}function zf(n){return n.keyword==="required"&&typeof n.params?.missingProperty=="string"?n.params.missingProperty:n.keyword==="additionalProperties"&&typeof n.params?.additionalProperty=="string"?n.params.additionalProperty:n.instancePath.split("/").pop()||"(root)"}function U0(n,e){let t=n.length+1,r=e.length+1,i=Array.from({length:t},(a,s)=>[s,...Array(r-1).fill(0)]);for(let a=1;a<r;a++)i[0][a]=a;for(let a=1;a<t;a++)for(let s=1;s<r;s++){let o=n[a-1]===e[s-1]?0:1;i[a][s]=Math.min(i[a-1][s]+1,i[a][s-1]+1,i[a-1][s-1]+o);}return i[t-1][r-1]}function vN(n,e){let t,r=1/0;for(let a of e){let s=U0(n,a);s<r&&(r=s,t=a);}let i=Math.max(1,Math.floor(n.length/3));return r<=i?t:void 0}function CN(n,e){if(n.keyword==="additionalProperties"&&typeof n.params?.additionalProperty=="string"){let t=n.params.additionalProperty,r=e&&vN(t,e),i=r?` (did you mean "${r}"?)`:"";return `has an unrecognised property "${t}"${i}`}return n.message??"invalid value"}function Bu(n){return n.split("/").filter(Boolean).map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}function bN(n,e){let t=n,r,i=a=>{a&&typeof a=="object"&&typeof a.$origin=="string"&&(r=a.$origin);};i(t);for(let a of Bu(e)){if(t===null||typeof t!="object")break;t=t[a],i(t);}return r}function _N(n,e){let t=Bu(e);for(let r=t.length;r>=0;r--){let i=t.slice(0,r),a=n;for(let s of i){if(a===null||typeof a!="object"){a=void 0;break}a=a[s];}if(a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="string")return {path:`/${i.map(o=>o.replace(/~/g,"~0").replace(/\//g,"~1")).join("/")}`,node:a}}}function Lu(n,e,t=new Set){if(!n||typeof n!="object")return n;let r=n.$ref;if(typeof r!="string")return n;let i=r.match(/^#\/definitions\/([^/]+)$/);return !i?.[1]||t.has(i[1])||!(i[1]in e)?{}:(t.add(i[1]),Lu(e[i[1]],e,t))}function qu(n,e){let t=Lu(n,e);if(!t||typeof t!="object")return;let r=t;if(!(r.anyOf||r.oneOf)){if(Array.isArray(r.allOf)){let i={properties:{},required:[]};for(let a of r.allOf){let s=qu(a,e);if(!s)return;Object.assign(i.properties,s.properties),i.required.push(...s.required);}return i}return {properties:r.properties??{},required:r.required??[]}}}function M0(n,e){if(!n||typeof n!="object")return true;let t=n;return "const"in t?t.const===e:Array.isArray(t.enum)?t.enum.includes(e):true}function SN(n,e){let t=n.definitions??{},r=[];for(let[i,a]of Object.entries(t)){let s=qu(a,t);if(!s)continue;let o=s.properties.type;o&&typeof o=="object"&&("const"in o||Array.isArray(o.enum))&&M0(o,e.type)&&M0(s.properties.operationType,e.operationType)&&r.push(i);}return r}function EN(n,e,t){let r=n.definitions??{},i={definitions:r,...r[e]},a=new Gf.default({strict:false,allErrors:true}).compile(i);return a(t)?[]:a.errors??[]}function wN(n,e,t){let r=n.definitions??{},i=Lu(r[e],r);for(let a of Bu(t)){let o=qu(i,r)?.properties[a];if(o===void 0)return [];i=Lu(o,r);}return Object.keys(qu(i,r)?.properties??{})}function ju(n){let e=n.map(o=>o.instancePath),t=o=>e.some(u=>u!==o&&u.startsWith(`${o}/`)),r=n.filter(o=>!t(o.instancePath)),i=new Map;for(let o of r){let u=i.get(o.instancePath)??[];u.push(o),i.set(o.instancePath,u);}let a=[];for(let o of i.values()){let u=o.filter(l=>l.keyword!=="anyOf"&&l.keyword!=="oneOf");a.push(...u.length>0?u:o);}let s=new Set;return a.filter(o=>{let u=`${zf(o)}|${o.message}`;return s.has(u)?false:(s.add(u),true)})}function Mf(n,e,t){return n.map(r=>({instancePath:r.instancePath||"(root)",element:zf(r),message:CN(r,t?.(r)),origin:bN(e,r.instancePath)}))}function DN(n,e,t){let r=n.map(c=>c.instancePath),i=c=>r.some(h=>h!==c&&h.startsWith(`${c}/`)),a=n.filter(c=>!i(c.instancePath)),s=t&&typeof t=="object"?t:void 0,o=new Map,u=[];for(let c of a){let h=s?_N(e,c.instancePath):void 0;if(!h){u.push(c);continue}let p=o.get(h.path);p?p.errors.push(c):o.set(h.path,{node:h.node,errors:[c]});}let l=Mf(ju(u),e);for(let[c,h]of o){let p=s?SN(s,h.node):[],f=p.length===1?p[0]:void 0;if(!f||!s){l.push(...Mf(ju(h.errors),e));continue}let y=ju(EN(s,f,h.node)).map(C=>({...C,instancePath:`${c}${C.instancePath}`}));l.push(...Mf(y,e,C=>wN(s,f,C.instancePath.slice(c.length))));}return l}var Jf;(h=>{function n(p,f={labelToRemove:[],initialVarsToRemove:[],functions:[],enums:{}}){let g=[];try{return {json:new z0.Compiler(p,{errorHandler:(v,d)=>{let S=v.replace(/^[A-Z]+: line \d+: ?/,""),m=v.match(/line (\d+)/);g.push({message:S,type:d,line:m?Number(m[1]):-1});},countAllVisits:!0,fileHandler:{ResolveInkFilename:v=>v,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:g}}catch{let C=false,_={...f,textSource:p};return e(g,()=>{C=true;},_),C?n(_.textSource,f):{issues:g}}}h.compile=n;function e(p,f,g){let{functions:y,initialVarsToRemove:C,labelToRemove:_}=g,v=p.find(d=>d.type===J0.ErrorType.Error);if(v){if(v.message.includes("Divert target not found")){let d=v.message.match(/Divert target not found: '-> (\w+)'/);if(d?.[1]){let S=d[1],m=`
|
|
73
|
+
\`\`\``,validation:D.union([D.tuple([D.enum(["load","lazyload"]),D.literal("assets")]).rest(a(n.assetAliasIds)),D.tuple([D.enum(["load","lazyload"]),D.literal("bundle")]).rest(a(n.bundleIds))])}),t&&(T.addMapper(p=>({type:"all",operationType:p[0]}),{name:"Pause/Resume/Stop all sounds",description:"Pauses, resumes, or stops all active sounds at once.\n\n```ink\n# pause all sounds\n# resume all sounds\n# stop all sounds\n```",validation:D.tuple([D.enum(["pause","resume","stop"]),D.literal("all"),D.enum(["sounds","sound"])])}),T.addMapper(p=>({type:"sound",operationType:"pause",alias:p[2]}),{name:"Pause sound",description:"Pauses the sound identified by its alias.\n\n```ink\n# pause sound <alias>\n```",validation:D.tuple([D.literal("pause"),D.literal("sound"),D.string()])}),T.addMapper(p=>({type:"channel",operationType:"pause",alias:p[2]}),{name:"Pause channel",description:"Pauses the audio channel identified by its alias.\n\n```ink\n# pause channel <alias>\n```",validation:D.tuple([D.literal("pause"),D.literal("channel"),D.string()])}),T.addMapper(p=>({type:"sound",operationType:"resume",alias:p[2]}),{name:"Resume sound",description:"Resumes the sound identified by its alias.\n\n```ink\n# resume sound <alias>\n```",validation:D.tuple([D.literal("resume"),D.literal("sound"),D.string()])}),T.addMapper(p=>({type:"channel",operationType:"resume",alias:p[2]}),{name:"Resume channel",description:"Resumes the audio channel identified by its alias.\n\n```ink\n# resume channel <alias>\n```",validation:D.tuple([D.literal("resume"),D.literal("channel"),D.string()])}),T.addMapper(p=>({type:"sound",operationType:"stop",alias:p[2]}),{name:"Stop sound",description:"Stops the sound identified by its alias.\n\n```ink\n# stop sound <alias>\n```",validation:D.tuple([D.literal("stop"),D.literal("sound"),D.string()])}),T.addMapper(p=>({type:"sound",operationType:"stop",alias:p[2]}),{name:"Remove sound",description:"Removes (stops) the sound identified by its alias.\n\n```ink\n# remove sound <alias>\n```",deprecated:true,validation:D.tuple([D.literal("remove"),D.literal("sound"),D.string()])}),T.addMapper(p=>({type:"sound",operationType:"edit",alias:p[2],props:T.convertListStringToObj(p.slice(3))}),{name:"Edit sound",description:"Edits the properties of a sound identified by its alias.\n\n```ink\n# edit sound <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("sound"),D.string()]).rest(D.string()).refine(p=>(p.length-3)%2===0)}),T.addMapper(p=>{let g=p[2],y={type:"sound",operationType:"play",alias:g,url:g};if(p.length>3){let C=T.convertListStringToObj(p.slice(3));"source"in C&&typeof C.source=="string"&&(y.url=C.source,delete C.source),Object.keys(C).length>0&&(y.props=C);}return y},{name:"Play sound",description:"Plays a sound using its alias as the URL, with optional key/value properties. Pass `source <value>` among the key/value properties to use a different URL than the alias.\n\n```ink\n# play sound <alias> [<key> <value> \u2026]\n# play sound <alias> source <url> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("play"),D.literal("sound"),a(n.assetAliasIds)]).rest(D.string()).refine(p=>(p.length-3)%2===0)}),T.addMapper(p=>{let g=p[2],y=p[3],C={type:"sound",operationType:"play",alias:g,url:y};return p.length>4&&(C.props=T.convertListStringToObj(p.slice(4))),C},{name:"Play sound with source",deprecated:true,description:"**Deprecated**: use `# play sound <alias> source <url> [<key> <value> \u2026]` instead, passing the URL as a `source` key/value property rather than as a positional argument.\n\nPlays a sound with an explicit source URL and optional key/value properties.\n\n```ink\n# play sound <alias> <source> [<key> <value> \u2026]\n```\n",validation:D.tuple([D.literal("play"),D.literal("sound"),D.string(),a(n.assetAliasIds)]).rest(D.string()).refine(p=>p.length>3&&(p.length-3)%2!==0)})),e){let p=function(m){let b=[],E=0,O="";for(let P of m)P.startsWith("{")?(E++,O+=P):P.endsWith("}")&&E>0?(E--,O+=P,E===0&&(b.push(O),O="")):E>0?O+=P:b.push(P);return b},g=function(m,b){if(!Q0.includes(m))return;let E={type:m};if(b.length>0)try{E.props=T.convertListStringToObj(b);}catch{}return E},y=function(m,b,E){let O,P;E.length%2===0?(O=b,P=E):(O=E[0],P=E.slice(1));let k={type:m,operationType:"show",alias:b,url:O};if(P.length>0){if(P.includes("with")&&P.length>P.indexOf("with")+1){let z=P[P.indexOf("with")+1],se=P.slice(P.indexOf("with")+2);P=P.slice(0,P.indexOf("with"));let le=g(z,se);le!==void 0&&(k.transition=le);}if(P.length>0){let z=T.convertListStringToObj(P);"source"in z&&typeof z.source=="string"&&(k.url=z.source,delete z.source),Object.keys(z).length>0&&(k.props=z);}}return k},C=function(m,b){let E,O;b.length%2===0?(E=m,O=b):(E=b[0],O=b.slice(1));let P={type:"text",operationType:"show",alias:m,text:E};if(O.length>0){if(O.includes("with")&&O.length>O.indexOf("with")+1){let k=O[O.indexOf("with")+1],z=O.slice(O.indexOf("with")+2);O=O.slice(0,O.indexOf("with"));let se=g(k,z);se!==void 0&&(P.transition=se);}O.length>0&&(P.props=T.convertListStringToObj(O));}return P},S=function(m,b,E){let O={type:m,operationType:"remove",alias:b};if(E.includes("with")&&E.length>E.indexOf("with")+1){let P=E[E.indexOf("with")+1],k=E.slice(E.indexOf("with")+2),z=g(P,k);z!==void 0&&(O.transition=z);}return O},v=function(m,b){let E=le=>le.startsWith('"')&&le.endsWith('"')||le.startsWith("'")&&le.endsWith("'")||le.startsWith("`")&&le.endsWith("`")?le.substring(1,le.length-1):le,O=b.indexOf("["),P=b.indexOf("]",O+1);if(O===-1||P===-1){Y.error("Show imagecontainer must have a list of image ulrs",b);return}let k=b.slice(O+1,P);if(k.length===0){Y.error("Show imagecontainer must have a list of image ulrs",b);return}let z={type:"imagecontainer",operationType:"show",alias:m,urls:k.map(le=>E(le))},se=b.slice(P+1);if(se.length>0){if(se.includes("with")&&se.length>se.indexOf("with")+1){let le=se[se.indexOf("with")+1],un=se.slice(se.indexOf("with")+2);se=se.slice(0,se.indexOf("with"));let Qr=g(le,un);Qr!==void 0&&(z.transition=Qr);}se.length>0&&(z.props=T.convertListStringToObj(se));}return z},d=function(m){let b=m.indexOf("]",4);if(b===-1)return;let E=m.slice(4,b),O=m.slice(b+1),P=O.indexOf("with");return P===-1?{urls:E,beforeWith:O,afterWith:[]}:{urls:E,beforeWith:O.slice(0,P),afterWith:O.slice(P+1)}};for(let m of eC)T.addMapper(b=>({alias:b[1],type:m,props:T.convertListStringToObj(b.slice(2))}),{name:tC(m),description:`Applies the ${m} effect to a canvas alias with optional key/value parameters.
|
|
76
74
|
|
|
77
|
-
|
|
75
|
+
\`\`\`ink
|
|
76
|
+
# ${m} <alias> [<key> <value> \u2026]
|
|
77
|
+
\`\`\``,validation:D.tuple([D.literal(m),D.string()]).rest(D.string()).refine(b=>(b.length-2)%2===0)});T.addMapper(m=>{let b=m.slice(2),E=b,O=[];if(b.includes("options")){let k=b.indexOf("options");E=b.slice(0,k),O=b.slice(k+1);}return {alias:m[1],type:"animate",keyframes:T.convertListStringToObj(E),options:T.convertListStringToObj(O)}},{name:"Animate",description:"Animates a canvas alias with keyframes and optional options section, both in key/value pairs.\n\n```ink\n# animate <alias> [<key> <value> \u2026] [options <key> <value> \u2026]\n```",validation:D.tuple([D.literal("animate"),D.string()]).rest(D.string()).refine(m=>{let b=m.slice(2),E=b.indexOf("options");if(E===-1)return b.length%2===0;if(b.lastIndexOf("options")!==E)return false;let O=b.slice(0,E),P=b.slice(E+1);return O.length%2===0&&P.length%2===0})}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return y("image",b,E)},{name:"Show image",description:"Shows an image canvas element with optional key/value properties and transition effect. Pass `source <value>` among the key/value properties to use a different URL than the alias.\n\n```ink\n# show image <alias> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n# show image <alias> source <url> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("image"),a(n.assetAliasIds)]).rest(D.string())}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return y("image",b,E)},{name:"Show image with source",deprecated:true,description:"**Deprecated**: use `# show image <alias> source <url> [<key> <value> \u2026]` instead, passing the URL as a `source` key/value property rather than as a positional argument.\n\nShows an image canvas element with an explicit source URL, optional key/value properties, and transition effect.\n\n```ink\n# show image <alias> <source> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("image"),D.string(),a(n.assetAliasIds)]).rest(D.string())});let _=a(n.assetAliasIds);T.addMapper(m=>v(m[2],p(m.slice(3))),{name:"Show imagecontainer",description:"Shows an image-container canvas element with a list of image URLs and optional key/value properties.\n\n```ink\n# show imagecontainer <alias> [ <source1> <ursource2> \u2026 ] [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("show"),D.literal("imagecontainer"),D.string(),D.literal("[")]).rest(D.string()).refine(m=>{let b=d(m);return b===void 0?false:b.urls.length>0&&b.urls.every(E=>_.safeParse(E).success)&&b.afterWith.length===0&&b.beforeWith.length%2===0})}),T.addMapper(m=>v(m[2],p(m.slice(3))),{name:"Show imagecontainer with transition",description:"Shows an image-container canvas element with a list of image URLs, optional properties, and a transition effect.\n\n```ink\n# show imagecontainer <alias> [ <ursource1> <source2> \u2026 ] [<key> <value> \u2026] with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout\n```",validation:D.tuple([D.literal("show"),D.literal("imagecontainer"),D.string(),D.literal("[")]).rest(D.string()).refine(m=>{let b=d(m);return b===void 0?false:b.urls.length>0&&b.urls.every(E=>_.safeParse(E).success)&&b.afterWith.length===1&&b.beforeWith.length%2===0})}),T.addMapper(m=>v(m[2],p(m.slice(3))),{name:"Show imagecontainer with transition and props",description:"Shows an image-container canvas element with a list of image URLs, optional properties, a transition effect, and transition key/value properties.\n\n```ink\n# show imagecontainer <alias> [ <url1> <url2> \u2026 ] [<key> <value> \u2026] with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout <key> <value> \u2026\n```",validation:D.tuple([D.literal("show"),D.literal("imagecontainer"),D.string(),D.literal("[")]).rest(D.string()).refine(m=>{let b=d(m);return b===void 0?false:b.urls.length>0&&b.urls.every(E=>_.safeParse(E).success)&&b.afterWith.length>1&&(b.afterWith.length-1)%2===0&&b.beforeWith.length%2===0})}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return y("video",b,E)},{name:"Show video",description:"Shows a video canvas element with optional key/value properties and transition effect. Pass `source <value>` among the key/value properties to use a different URL than the alias.\n\n```ink\n# show video <alias> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n# show video <alias> source <url> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("video"),a(n.assetAliasIds)]).rest(D.string())}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return y("video",b,E)},{name:"Show video with source",deprecated:true,description:"**Deprecated**: use `# show video <alias> source <url> [<key> <value> \u2026]` instead, passing the URL as a `source` key/value property rather than as a positional argument.\n\nShows a video canvas element with an explicit source URL, optional key/value properties, and transition effect.\n\n```ink\n# show video <alias> <source> [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("video"),D.string(),a(n.assetAliasIds)]).rest(D.string())}),T.addMapper(m=>{let b=m[2];return C(b,m.slice(3))},{name:"Show text",description:"Shows a text canvas element with optional text content, key/value properties, and transition effect.\n\n```ink\n# show text <alias> [<text>] [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("show"),D.literal("text"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return S("image",b,E)},{name:"Remove image",description:"Removes an image canvas element with an optional transition effect.\n\n```ink\n# remove image <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("image"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return S("video",b,E)},{name:"Remove video",description:"Removes a video canvas element with an optional transition effect.\n\n```ink\n# remove video <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("video"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return S("canvaselement",b,E)},{name:"Remove canvas element",description:"Removes a canvas element with an optional transition effect.\n\n```ink\n# remove canvaselement <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("canvaselement"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return S("text",b,E)},{name:"Remove text",description:"Removes a text canvas element with an optional transition effect.\n\n```ink\n# remove text <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("text"),D.string()]).rest(D.string())}),T.addMapper(m=>{let b=m[2],E=p(m.slice(3));return S("imagecontainer",b,E)},{name:"Remove imagecontainer",description:"Removes an image-container canvas element with an optional transition effect.\n\n```ink\n# remove imagecontainer <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout|wipein|wipeout|irisin|irisout|splitin|splitout|blurin|blurout|pixelatein|pixelateout|flashin|flashout|glitchin|glitchout|twistin|twistout|warpin|warpout|ripplein|rippleout|noisedissolvein|noisedissolveout|tvin|tvout|pinchin|pinchout [<key> <value> \u2026]]\n```",validation:D.tuple([D.literal("remove"),D.literal("imagecontainer"),D.string()]).rest(D.string())}),T.addMapper(()=>({type:"canvas",operationType:"clear"}),{name:"Clear canvas",description:"Removes every element currently on the canvas.\n\n```ink\n# clear canvas\n```",validation:D.tuple([D.literal("clear"),D.literal("canvas")])}),T.addMapper(m=>({type:"image",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit image",description:"Edits the properties of an image canvas element identified by its alias.\n\n```ink\n# edit image <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("image"),D.string()]).rest(D.string())}),T.addMapper(m=>({type:"imagecontainer",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit imagecontainer",description:"Edits the properties of an image-container canvas element identified by its alias.\n\n```ink\n# edit imagecontainer <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("imagecontainer"),D.string()]).rest(D.string())}),T.addMapper(m=>({type:"canvaselement",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit canvas element",description:"Edits the properties of a canvas element identified by its alias.\n\n```ink\n# edit canvaselement <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("canvaselement"),D.string()]).rest(D.string())}),T.addMapper(m=>({type:"video",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit video",description:"Edits the properties of a video canvas element identified by its alias.\n\n```ink\n# edit video <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("video"),D.string()]).rest(D.string())}),T.addMapper(m=>({type:"text",operationType:"edit",alias:m[2],props:T.convertListStringToObj(m.slice(3))}),{name:"Edit text",description:"Edits the properties of a text canvas element identified by its alias.\n\n```ink\n# edit text <alias> [<key> <value> \u2026]\n```",validation:D.tuple([D.literal("edit"),D.literal("text"),D.string()]).rest(D.string())});}r&&(T.addMapper(p=>({type:"input",operationType:"request"}),{name:"Request input",description:"Requests player input without any additional constraints.\n\n```ink\n# request input\n```",validation:D.tuple([D.literal("request"),D.literal("input")])}),T.addMapper(p=>{let g={type:"input",operationType:"request"};try{let y=T.convertListStringToObj(p.slice(2));"type"in y&&typeof y.type=="string"&&(g.valueType=y.type),"default"in y&&(g.defaultValue=y.default);}catch{}return g},{name:"Request input with params",description:"Requests player input with optional key/value parameters (e.g. type, default).\n\n```ink\n# request input <key> <value> [<key> <value> \u2026]\n# request input type number default 18\n```",validation:D.tuple([D.literal("request"),D.literal("input")]).rest(D.string()).refine(p=>p.length>2&&(p.length-2)%2===0)}));}var Ns="global decl",In="___external_value___",aF=/\[([^\]]+)\]/;var If=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],kf=["+","-","/","*","%","POW","RANDOM","L^"],Vf=["INT","FLOOR","FLOAT"];function ar(n,e){if(n.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(n)&&(n=n.split(".").filter(i=>!i.match(/^[0-9]+$/)).join("."),!n.startsWith(".")))return n.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(n)&&n.includes("g-")){let r=n.split("g-");return Yu(e)+"_|_"+"g-"+r[r.length-1]}let t=0;for(;new RegExp(/^\.\^.*$/).test(n);)t++,n=n.substring(2);if(t=t-1,new RegExp(/^\..*$/).test(n)&&e){let r=n.substring(1);return Yu(e,t)+"_|_"+r.replaceAll(".","_|_")}return n.replaceAll(".","_|_")||Yu(e,t).replaceAll(".","_|_")}function Yu(n,e=0){let t=n.split("_|_");for(;t.length>1&&e>0;)t.pop()?.includes("g-")&&e--,e--;return t.join("_|_")}var Rf="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function Rt(n){return n.startsWith("^")&&(n=n.substring(1)),n=n.replaceAll("\\\\",Rf),n=n.replaceAll("\\n",`
|
|
78
|
+
`),n=n.replaceAll("\\t"," "),n=n.replaceAll(" "," "),n=n.replaceAll(Rf,"\\\\"),n}var rC={version:"1.15.0"};var jf=`https://pixi-vn.com/schemas/${rC.version}/schema.json`,$f=["==","!=","<","<=",">",">=","CONTAINS"];function cn(n,e,t,r){let{functions:i}=r;n=n.map(s=>{if(typeof s=="string")switch(s){case "rnd":return "RANDOM";case "?":return "CONTAINS"}return s});let a=[];return n.forEach(s=>{if(typeof s=="string")switch(s){case "&&":case "||":if(a.length>=2){let o={type:"union",unionType:s==="&&"?"and":"or",conditions:[a[a.length-2],a[a.length-1]]};a.pop(),a.pop(),a.push(o);}break;case "!":if(a.length===0)Y.error("Error parsing ink file: Conditional statement is not valid",n);else {let o={type:"union",unionType:"not",condition:a[a.length-1]};a[a.length-1]=o;}break;case "!?":if(a.length>1){let o={type:"union",unionType:"not",condition:{type:"compare",operator:"CONTAINS",leftValue:a[a.length-2],rightValue:a[a.length-1]}};a.pop(),a.pop(),a.push(o);}else Y.error("Error parsing ink file: Conditional statement is not valid",n);break;default:if($f.includes(s))if(a.length<2)Y.error("Error parsing ink file: Conditional statement is not valid",n);else {let o={type:"compare",operator:s,rightValue:a[a.length-1],leftValue:a[a.length-2]};a.pop(),a.pop(),a.push(o);}else if(kf.includes(s))if(a.length<2)Y.error("Error parsing ink file: Conditional statement is not valid",n);else {s==="L^"&&(s="INTERSECTION");let o={type:"arithmetic",operator:s,rightValue:a[a.length-1],leftValue:a[a.length-2]};a.pop(),a.pop(),a.push(o);}else if(Vf.includes(s)){let o={type:"arithmeticsingle",operator:s,leftValue:a[a.length-1]};a.pop(),a.push(o);}else s.startsWith("^")&&a.push(Rt(s));}else if(typeof s=="object"&&"CNT?"in s)if(new RegExp(/.*\.[0-9]\..*/).test(s["CNT?"])){let o=s["CNT?"].split("."),u=o.pop(),l=o.pop();if(l===void 0||u===void 0){Y.error("Error parsing ink file: Conditional statement is not valid",n);return}let c=Number(l),h=o.join(".");if(h.includes("^.")){let p=h.split("."),g=p[p.length-1].replaceAll(".","_|_");p.pop(),h=`${p.join(".")}.${g}`,u.includes("c-")&&(h=h+"_|_"+u);}else h=h.replaceAll(".","_|_");let f=ar(h,e);if(!f)return;a.push({type:"compare",leftValue:Zu(f),operator:">=",rightValue:{type:"value",value:c}});}else {let o=ar(s["CNT?"],e);if(!o)return;a.push(Zu(o));}else if(typeof s=="object"&&"VAR?"in s)a.push(kn({key:s["VAR?"],defaultType:"storage"},t));else if(typeof s=="object"&&"f()"in s){let o=s["f()"],u=i.find(c=>c.name===o);if(!u){Y.error(`Error parsing ink file: Function ${o} is not defined`,n);return}let l=[];for(let c=0;c<u.args;c++)a.length!==0&&l.push(a.pop());a.push({type:"function",functionName:o,args:l.reverse()});}else if(typeof s=="object"&&"^->"in s)s["^->"].includes("$r")||a.push(s["^->"]);else if(typeof s=="object"&&"list"in s){let o=Object.values(s.list).map(u=>u);a.push(o);}else a.push(s);}),a}function Qu(n,e,t,r){return cn(n,e,t,r)}function kn(n,e,t){let{key:r,defaultType:i}=n,a=e.indexOf(r);return a>=0?{type:"value",storageType:"params",storageOperationType:"get",key:a}:{type:"value",storageOperationType:"get",storageType:i,key:r}}function ai(n,e,t){let{key:r,value:i,defaultType:a,artmeticValue:s}=n,o=e.indexOf(r);if(o>=0)return [{type:"value",storageType:"params",storageOperationType:"set",key:o,value:i}];if(s){if(typeof i=="object"&&"list"in i){let u=Object.values(i.list).map(l=>l);return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:u}]}return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:i}]}else if(typeof i=="object"){if("list"in i&&typeof i.list=="object"){if("origins"in i&&Array.isArray(i.origins)&&i.origins.length>0)return i.origins.reduce(u=>(u.push({type:"value",storageOperationType:"set",storageType:a,key:r,value:Object.values(t.enums[r])}),Object.entries(t.enums[r]).forEach(([l,c])=>{u.push({type:"value",storageOperationType:"set",storageType:a,key:`${r}.${l}`,value:c});}),u),[]);{let u=new Set,l=Object.entries(i.list).reduce((c,[h,f])=>{let[p,g]=h.split(".");return c.push({type:"value",storageOperationType:"set",storageType:a,key:g,value:f}),u.add(p),c},[]);return u.forEach(c=>{l.push({type:"value",storageOperationType:"set",storageType:a,key:c,value:Object.values(t.enums[c])});}),r in t.enums?Object.entries(t.enums[r]).forEach(([c,h])=>{l.push({type:"value",storageOperationType:"set",storageType:a,key:`${r}.${c}`,value:h});}):l.push({type:"value",storageOperationType:"set",storageType:a,key:r,value:Object.values(i.list)}),l}}else if(typeof i=="object"&&"VAR?"in i){if(typeof i["VAR?"]=="string"&&i["VAR?"].includes(".")){let[u,l]=i["VAR?"].split(".");if(u in t.enums&&l in t.enums[u])return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:t.enums[u][l]}]}return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:kn({key:i["VAR?"],defaultType:"storage"},e)}]}}return [{type:"value",storageOperationType:"set",storageType:a,key:r,value:i}]}function Zu(n){return {type:"value",storageType:"label",storageOperationType:"get",label:n}}function el(n,e){return e||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(n)?"call":"jump"}function Fs(n,e){if(e){if(typeof e=="string")e.startsWith("^")&&n.push(Rt(e));else if(typeof e=="object"&&"type"in e)switch(e.type){case "value":case "function":console.warn("Warning: trying to add a value or function operation as text. This is likely a mistake, so it will be ignored.");break;default:n.push(e);}}}function tl(n,e,t,r,i,a={}){let{isNewLine:s=true,isHashtagScript:o=false,isThreads:u=false}=a;return sC(n,e,t,r,i,{isNewLine:s,isHashtagScript:o,isThreads:u})}function sC(n,e,t,r,i,a){if(!e)return;let{isNewLine:s,isHashtagScript:o=false,isThreads:u}=a;if(o){if(Array.isArray(e)&&e.length>0){let l={goNextStep:true},c=[];try{if(e.length===1&&typeof e[0]=="string"){let h=e[0],f=T.convertTagTolist(h),p=T.convertOperation(f,l,{silent:!0});p&&(p.$origin=h,c.push(p));}}catch{}c.length===0&&c.push({type:"operationtoconvert",values:e}),n.push({...l,operations:c});}}else if(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"){if(!s&&n.length>0){let l=n[n.length-1];!l.glueEnabled&&!l.operations&&!l.labelToOpen&&(l.glueEnabled=true,l.labelToOpen||(l.goNextStep=true)),n[n.length-1]=l;}typeof e=="string"?n.push(aC(Rt(e),r.characterIds)):n.push({dialogue:e});}else if(typeof e=="string"){if(e==="end")n.push({end:"game_end"});else if(e==="done")n.push({end:"label_end",goNextStep:true});else if(e==="<>")if(n.length>0){let l=n[n.length-1];l.glueEnabled=true;let c=l.operations!==void 0&&l.dialogue===void 0;l.labelToOpen||(l.goNextStep=c?true:!s),n[n.length-1]=l;}else n.push({glueEnabled:true,goNextStep:true});}else if(typeof e=="object"){if("type"in e)switch(e.type){case "value":e.storageOperationType==="set"?(typeof e.value=="string"&&e.value.startsWith("^")&&(e.value=Rt(e.value)),n.push({goNextStep:true,operations:[e]})):console.warn("Warning: trying to add a value get operation as step. This is likely a mistake, so it will be ignored.");break;case "function":n.push({goNextStep:true,operations:[e]});break;default:if(!s&&n.length>0){let l=n[n.length-1];!l.glueEnabled&&!l.operations&&(l.glueEnabled=true,l.labelToOpen||(l.goNextStep=true)),n[n.length-1]=l;}n.push({conditionalStep:e});}else if("->"in e){let l=s?void 0:true;if(l&&t.includes("c-")&&n.length>0&&n[n.length-1]?.dialogue===void 0&&(l=void 0),!s&&n.length>0){let c=n[n.length-1];c.labelToOpen||(c.goNextStep=true),n[n.length-1]=c;}if(e.params&&e.params.length===0&&delete e.params,e.var)n.push({labelToOpen:{label:kn({key:e["->"],defaultType:"storage"},i),type:u?"call":"jump",params:e.params},glueEnabled:l});else {let c=ar(e["->"],t);if(!c)return;n.push({labelToOpen:{label:c,type:el(c,u),params:e.params},glueEnabled:l});}}else if("->t->"in e){let l=s?void 0:true;if(l&&t.includes("c-")&&n.length>0&&n[n.length-1]?.dialogue===void 0&&(l=void 0),!s&&n.length>0){let h=n[n.length-1];h.labelToOpen||(h.goNextStep=true),n[n.length-1]=h;}e.params&&e.params.length===0&&delete e.params;let c=ar(e["->t->"],t);if(!c)return;n.push({labelToOpen:{label:c,type:"call",params:e.params},glueEnabled:l});}}}function aC(n,e){let t;if(n.includes(": ")){let r=n.split(": "),i=r[0],a=r.slice(1).join(": ");(e?.has(i)||RegisteredCharacters.has(i))&&(t=i,n=a);}return t?{dialogue:{character:t,text:n}}:{dialogue:n}}function nl(n,e,t,r=true,i=false){return oC(n,e,t,r,i)}function oC(n,e,t,r,i=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"?typeof e=="string"?n.push(Rt(e)):n.push(e):typeof e=="object"&&"type"in e&&n.push(e));}function Is(n,e,t,r){if(n.length===0){Y.error("Error parsing ink file: Arithmetic statement is not valid",n);return}let i=cn(n,e,t,r);if(i.length===1){let a=i[0];return a&&typeof a=="object"&&"type"in a?{type:"value",storageType:"logic",storageOperationType:"get",operation:a}:a}}function or(n,e,t,r="",i,a,s=void 0){let o=[],u="sequential",l=false,c=true;n.forEach(p=>{p==="%"&&(u="loop"),p==="seq"&&(u="random"),p==="MIN"&&(l=true);});let h=n[n.length-1];return Object.keys(h).forEach(p=>{let g=h[p];if(Array.isArray(g)&&g.length>3){g=g.slice(1,g.length-2);let y=[];hn(g,r,i,y,e,e,t,ur,s,true,a),y.length===1?o.push(y[0]):o.push({type:"resulttocombine",combine:"cross",secondConditionalItem:y});}else Array.isArray(g)&&g.length===3&&(c=false);}),u==="sequential"?{type:"stepswitch",elements:o,choiceType:u,end:c?"lastItem":void 0,nestedId:s}:l&&u==="random"?{type:"stepswitch",elements:o,choiceType:"sequentialrandom",end:c?"lastItem":void 0,nestedId:s}:{type:"stepswitch",elements:o,choiceType:u}}function hn(n,e,t,r=[],i,a,s,o,u=void 0,l=true,c=[]){let h=false,f=[],p=false,g=false,y=false,C=[],S=[];if(t.preDialog[e]&&(l=false,i(r,`^${t.preDialog[e].text}`,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),t.preDialog[e].glue&&i(r,"<>",e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),delete t.preDialog[e]),n.includes("visit")){let d=or(n,a,s,e,t,c,u);d&&(!l&&r.length>0&&i(r,"<>",e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}));return}let v=n[0];if(v&&typeof v=="object"&&"temp="in v){for(;n[0]&&typeof n[0]=="object"&&"temp="in n[0];)c.push(n[0]["temp="]),n.shift();c=c.reverse();}if(n.forEach((d,_)=>{if(g){if(typeof d=="string"&&d==="/#"){let m=[];hn(S,e,t,m,nl,nl,s,o,u,l),i(r,m,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),g=false,S=[];}else S.push(d);return}else if(h)if(Array.isArray(d))f.push(d);else if(d&&typeof d=="object")"CNT?"in d?_>0&&n[_-1]==="ev"?(p=true,C.push(d)):p?C.push(d):(f.push(d),l=false):"VAR="in d||"temp="in d?ai({key:"VAR="in d?d["VAR="]:d["temp="],value:n[_-1],defaultType:"VAR="in d?"storage":"tempstorage"},c,t).forEach(b=>{if(b.value&&typeof b.value=="string"&&b.value==="/str"&&(b.value=n[_-2]),b.value&&typeof b.value=="object"&&"^->"in b.value&&(b.value=b.value["^->"]),f.length>1){let E=Is(f,e,c,t);f=[],E&&typeof E=="object"&&"type"in E&&E.type==="value"&&"storageType"in E&&E.storageType==="logic"&&(b.value=E.operation);}(typeof b.key!="string"||!b.key.includes("$r"))&&(i(r,b,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=true);}):"VAR?"in d?f.push(d):"^->"in d?d["^->"].includes("$r")||f.push(d):("f()"in d||"list"in d&&typeof d.list=="object")&&f.push(d);else switch(d){case "/ev":p&&C.push(d),h=false,f.push(d);break;case "out":if(f.length>0){let m=f[f.length-1];if(m&&typeof m=="object"&&"VAR?"in m){f.pop();let b=kn({key:m["VAR?"],defaultType:"storage"},c);i(r,b,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y});}else {let b=[];for(;f.length>0&&f[f.length-1]!=="/ev";)b.push(f.pop());b=b.reverse();let E=Is(b,e,c,t);f=[],E&&typeof E=="object"&&"type"in E&&E.type==="value"&&"storageType"in E&&E.storageType==="logic"?i(r,{storageOperationType:"get",storageType:"logic",operation:E.operation,type:"value"},e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}):(i(r,"<>",e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),E=`^${E}`,i(r,E,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}));}l=false;}break;case "pop":{let m=f[f.length-1];if(m&&typeof m=="object"&&"f()"in m){let b=[];for(;f.length>0&&f[f.length-1]!=="/ev";)b.push(f.pop());b=b.reverse();let E=cn(b,e,c,t);f=[],E.forEach(O=>{O&&typeof O=="object"&&"type"in O&&O.type==="function"?i(r,O,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}):Y.warn("Unhandled case: value is not a function",O);}),l=false;}else f.push(d);return}default:f.push(d);}else if(typeof d=="string")if(d.startsWith("^"))i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;else if(d==="ev")h=true;else if(d===`
|
|
79
|
+
`)l=true;else if(d==="done"||d==="end")i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;else if(d==="<>")i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;else if(d==="nop"&&p){let m=Lf(C,a,s,e,t,c,u);m&&i(r,m,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),p=false,C=[];}else d==="#"?g=true:d==="thread"&&(y=true);else if(Array.isArray(d))if(p)C.push(d);else if(d.length>1&&typeof d[d.length-2]=="object"&&d[d.length-2]&&"c"in d[d.length-2]&&typeof d[d.length-1]=="object"&&d[d.length-1]&&"b"in d[d.length-1]){f.pop();let m=[],b=[];for(;f.length>0&&f[f.length-1]!=="/ev";)m.push(f.pop());C=[...C,...m.reverse()],p=true,b.push(d.pop()),b.push(d.pop()),C=[...C,...d],C.push(b);}else if(d.length>1&&typeof d[d.length-1]=="object"&&d[d.length-1]&&"#n"in d[d.length-1]){let m=d.pop();if(!m){Y.error("Error parsing ink file: el is undefined");return}let b=m["#n"];delete m["#n"],d.push(m),i(r,{"->":e?e+"_|_"+b:b},e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),s({[b]:d},e,t);}else hn(d,e,t,r,i,a,s,o,u,l,c);else if(d&&typeof d=="object")if("->"in d&&typeof d["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(d["->"])){let m=[];f.length>0&&(m=Qu(["ev",...f],e,c,t)),d.params=m,i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;}else if("->t->"in d&&typeof d["->t->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(d["->t->"])){let m=[];f.length>0&&(m=Qu(["ev",...f],e,c,t)),d.params=m,i(r,d,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y}),l=false;}else if("*"in d&&typeof d["*"]=="string")d["*"].includes("c")&&(f.push(d),l=false);else if("s"in d&&Array.isArray(d.s))f.push(d),l=false;else if("CNT?"in d)f.push(d),l=false;else if("VAR="in d||"temp="in d){let m="VAR="in d?d["VAR="]:d["temp="],b,E=[];if(m!=="$r"){for(f.pop(),f[f.length-1]==="/ev"&&f.pop();f.length>0&&f[f.length-1]!=="/ev";)E.push(f.pop());E=E.reverse(),b=Is(E,e,c,t),f=[],ai({key:m,value:b,defaultType:"VAR="in d?"storage":"tempstorage",artmeticValue:true},c,t).forEach(P=>{(P.value!==void 0||P.value!==null)&&i(r,P,e,t,c,{isNewLine:l,isHashtagScript:g,isThreads:y});}),l=false;}}else s(d,e,t);}),o(f,r,e,t,c),e.includes("_|_")&&r.length===2){let d=r[0],_=r[1];d&&_&&typeof d=="object"&&"dialogue"in d&&typeof _=="object"&&"labelToOpen"in _&&d.dialogue===" "&&_.labelToOpen&&(r.shift(),delete _.glueEnabled,r[0]=_);}}function il(n,e,t,r,i,a){if(e.length===0)return;let s=cn(e,r,t,i);if(s.length===1){let o={type:"ifelse",condition:s[0],then:n,else:a};return o.else||delete o.else,o}else if(s.length>1){let o={type:"ifelse",condition:{type:"union",unionType:"and",conditions:s},then:n,else:a};return o.else||delete o.else,o}}function Lf(n,e,t,r,i,a,s=void 0){if(n.length===0){Y.error("Error parsing ink file: Conditional statement is not valid",n);return}let o=[],u=[];if(n.forEach(h=>{Array.isArray(h)?u.push(h):typeof h=="string"&&h==="du"?i.du?o.push(i.du):i.du=o[o.length-1]:(typeof h!="string"||h!=="/ev")&&o.push(h);}),u.length===0){Y.error("Error parsing ink file: Conditional statement is not valid",u);return}let l=rl(u[0],e,t,`${r}${"_|_"}then`,i,a,`${s||""}then`),c;return u.length===2?c=rl(u[1],e,t,`${r}${"_|_"}else`,i,a,`${s||""}else`):u.length>2?(u.shift(),u.push("nop"),u=[{b:u}],c=rl(u,e,t,r,i,a,`${s||""}else`)):c=void 0,i.du=void 0,il(l,o,a,r,i,c)}function rl(n,e,t,r,i,a,s=void 0){let o=[];for(let l of n)typeof l=="object"&&"b"in l&&(l.b=l.b.filter(c=>c!==null&&!(typeof c=="object"&&"->"in c&&new RegExp(/.*\.[0-9]/).test(c["->"]))),hn(l.b,r,i,o,e,e,t,ur,s,true,a));return o.length===1?o[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:o}}function sl(n="",e=""){let t=Array.isArray(n)?n:[n],r=Array.isArray(e)?e:[e];return [...new Set([...t,...r])]}function ur(n,e,t,r,i){if(n.length>0){let a={};qf(n,a,i,r);for(let[s,o]of Object.entries(a)){let u=t+"_|_"+s,l={text:o.text.length===1?o.text[0]:o.text,label:u,props:{},type:el(u,false),oneTime:o.onetime};o.text.length===0&&(l.onlyHaveNoChoice=true,l.autoSelect=true),l.oneTime===false&&delete l.oneTime;let c=il(l,o.conditions,i,t,r)||l,h=e[e.length-1];if(typeof h=="object"&&h&&"type"in h&&(h={conditionalStep:h}),e.length>0&&typeof h=="object"&&h&&"choices"in h&&h.choices){let f=h.choices;f&&Array.isArray(f)?f.push(c):Y.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",o,f),h.choices=f.sort((p,g)=>{try{let y=p.label.split("."),C=y[y.length-1].replaceAll(".","_|_"),S=g.label.split("."),v=S[S.length-1].replaceAll(".","_|_");if(C.includes("c-")&&v.includes("c-")){let d=C.split("c-")[1],_=Number(d),m=v.split("c-")[1],b=Number(m);return _-b}}catch{}return 0});}else e.push({choices:[c]});o.preDialog&&(r.preDialog[u]={...o.preDialog});}}}function qf(n,e,t,r,i){let a=[],s="",o="",u=false,l=[];for(let c=0;c<n.length;c++){let h=n[c];if(typeof h=="string")h.startsWith("^")?a.push(Rt(h)):If.includes(h)&&l.push(h);else if(Array.isArray(h)&&h.includes("visit")){let f=or(h,Fs,(p,g,y)=>{},i,r,t);a.push(f);}else if(h&&typeof h=="object")if("*"in h&&typeof h["*"]&&typeof h["*"]=="string")h["*"].includes("c")&&(s=`c${h["*"].split("c")[1]}`,h.flg&16&&(u=true));else if("s"in h&&Array.isArray(h.s)){let f=Bf(h.s),p=h.s.includes("<>");f&&(i&&e[i]?(e[i].preDialog={text:f,glue:p},e[i].text=sl(f,e[i].text)):(a.push(f),o=f));}else ("CNT?"in h||"VAR?"in h)&&l.push(h);else l.push(h);if(s){e[s]?e[s].text=sl(a,e[s].text):e[s]={text:a,onetime:u,conditions:l},o&&(e[s].preDialog={text:o,glue:false});let f=n.slice(c+1);qf(f,e,t,r,s);return}}}function Bf(n){for(let e of n)if(typeof e=="string"){if(e.startsWith("^"))return Rt(e)}else if(Array.isArray(e)){let t=Bf(e);if(t)return t}}var al;(i=>{function n(a,s={}){let{labelToRemove:o=[],initialVarsToRemove:u=[],enums:l={},functions:c=[],preDialog:h={},characterIds:f}=s,p={$schema:jf};if(p.labels=e(a.root,{labelToRemove:o,initialVarsToRemove:u,enums:l,functions:c,preDialog:h,characterIds:f}),p.labels&&Ns in p.labels){let g=p.labels[Ns];delete p.labels[Ns],g.forEach(y=>{y.operations&&(p.initialOperations=p.initialOperations?[...p.initialOperations,...y.operations]:[...y.operations]);});}if(p.labels&&In in p.labels){let g=p.labels[In];delete p.labels[In],g.forEach(y=>{y.operations&&(p.initialOperations=p.initialOperations?[...p.initialOperations,...y.operations]:[...y.operations]);});}return o.forEach(g=>{p.labels&&g in p.labels&&delete p.labels[g];}),u.forEach(g=>{p.initialOperations&&(p.initialOperations=p.initialOperations.filter(y=>!(y.type==="value"&&y.key===g)));}),p}i.inkToJson=n;function e(a,s){try{let o={};return t(a,o,s),o}catch(o){Y.error("Error parsing ink file",o);}}function t(a,s,o){for(let u of a)if(u)if(Array.isArray(u))if(u.includes("visit")){let l=or(u,Fs,(c,h,f)=>{},"",o,[]);l&&(o.externalSwitch=l);}else t(u,s,o);else typeof u=="object"&&(u&&"VAR="in u&&o.externalSwitch&&(s[In]||(s[In]=[]),s[In].push({operations:ai({defaultType:"storage",key:u["VAR="],value:o.externalSwitch},[],o)})),r(u,s,"",o));}function r(a,s,o="",u){if(a!==null){for(let[l,c]of Object.entries(a))if(Array.isArray(c)){let h=[],f={},p=(o?o+"_|_":"")+l;hn(c,p,u,h,tl,tl,(g,y,C)=>{r(g,f,y,C);},ur);for(let[g,y]of Object.entries(f))s[g]=y;h.length>0&&(s[p]=h);}}}})(al||={});var zp=ei(vy(),1),Jb=ei(Uy(),1),Hb=ei(Bb(),1),Ub=ei(Pr(),1),tN=/(?:^|<>)\s*#\s*([^\r\n]+)/g,nN=/^=+[ \t]+(?:function[ \t]+)?(\w+)/gm,rN=new Set(["DONE","END"]),iN="_|_",Wb=new Map;function Kb(n,e){let t=JSON.stringify([e,n]),r=Wb.get(t);if(r)return r;let i=new RegExp(n,e);return Wb.set(t,i),i}function _s(n,e){if(!e||typeof e!="object")return false;let t=e,r=t.anyOf;if(Array.isArray(r))return r.some(s=>_s(n,s));let i=t.oneOf;if(Array.isArray(i))return i.some(s=>_s(n,s));let a=t.allOf;if(Array.isArray(a))return a.every(s=>_s(n,s));if(typeof t.const=="string")return n===t.const;if(Array.isArray(t.enum))return t.enum.some(s=>typeof s=="string"&&s===n);if(t.type!=="string"||typeof t.minLength=="number"&&n.length<t.minLength||typeof t.maxLength=="number"&&n.length>t.maxLength)return false;if(typeof t.pattern=="string")try{if(!Kb(t.pattern,"").test(n))return !1}catch{return false}return true}function $u(n,e){if(!e||typeof e!="object")return false;let t=e,r=t.anyOf;if(Array.isArray(r))return r.some(o=>$u(n,o));let i=t.oneOf;if(Array.isArray(i))return i.some(o=>$u(n,o));let a=t.allOf;if(Array.isArray(a))return a.every(o=>$u(n,o));if(t.type!=="array"||typeof t.minItems=="number"&&n.length<t.minItems||typeof t.maxItems=="number"&&n.length>t.maxItems)return false;let s=Array.isArray(t.prefixItems)?t.prefixItems:[];if(n.length<s.length)return false;for(let o=0;o<s.length;o++)if(!_s(n[o],s[o]))return false;return n.length===s.length?true:t.items===false||typeof t.items>"u"?false:t.items===true?true:n.slice(s.length).every(o=>_s(o,t.items))}function Wp(n,e){if(e.type==="regexp")try{let t=Kb(e.source,e.flags);return t.lastIndex=0,t.test(n.join(" "))}catch{return false}return e.type==="literal"?n.join(" ")===e.value:$u(n,e.schema)}function Lu(n){if(!n||typeof n!="object")return [];let e=n;if(Array.isArray(e.anyOf))return e.anyOf.flatMap(Lu);if(Array.isArray(e.oneOf))return e.oneOf.flatMap(Lu);if(Array.isArray(e.allOf)){let t={};for(let r of e.allOf)r&&typeof r=="object"&&Object.assign(t,r);return Lu(t)}return e.type==="array"&&Array.isArray(e.prefixItems)?[e]:[]}function Mb(n,e){if(n===e)return 1;let t=Math.max(n.length,e.length);return t===0?1:Math.max(0,1-Xb(n,e)/t)}function sN(n,e){if(e&&typeof e=="object"){let t=e;if(typeof t.const=="string")return {weight:2,matched:n===void 0?0:2*Mb(n,t.const)};if(Array.isArray(t.enum))return {weight:2,matched:2*(n===void 0?0:Math.max(0,...t.enum.filter(i=>typeof i=="string").map(i=>Mb(n,i))))}}return {weight:1,matched:n===void 0?0:1}}function aN(n,e){let t=Array.isArray(e.prefixItems)?e.prefixItems:[],r=Math.min(t.length,n.length),i=0,a=0,s=false;for(let o=0;o<r;o++){let u=sN(n[o],t[o]);i+=u.weight,a+=u.matched,u.weight>1&&(s=true);}return {score:i===0?0:a/i,hasDiscriminant:s}}var oN=.8,Gb=new Map;function uN(n){let e=JSON.stringify(n),t=Gb.get(e);if(t)return t;let r=new Jb.default({strict:false,allErrors:true}).compile(n);return Gb.set(e,r),r}function lN(n){if("items"in n)return n;let e=Array.isArray(n.prefixItems)?n.prefixItems.length:0;return {...n,minItems:e,maxItems:e,items:false}}function cN(n,e){let[t]=Mu(n.instancePath);if(t!==void 0&&/^\d+$/.test(t)){let r=Number(t);if(r<e.length)return e[r]}return Jp(n)}function hN(n){return n.keyword==="const"?`must be "${n.params.allowedValue}"`:n.keyword==="enum"?`must be one of ${(n.params.allowedValues??[]).map(t=>`"${t}"`).join(", ")}`:n.message??"invalid value"}function Mp(n){let e=n.split(/\r?\n/),t=[];for(let r=0;r<e.length;r++){let i=e[r];for(let a of i.matchAll(tN)){let s=(a[1]??"").trim();if(!s)continue;let o=T.convertTagTolist(s,{mergeInkVariables:true});o.length!==0&&t.push({line:r+1,command:s,tokens:o});}}return t}function Jp(n){return n.keyword==="required"&&typeof n.params?.missingProperty=="string"?n.params.missingProperty:n.keyword==="additionalProperties"&&typeof n.params?.additionalProperty=="string"?n.params.additionalProperty:n.instancePath.split("/").pop()||"(root)"}function Xb(n,e){let t=n.length+1,r=e.length+1,i=Array.from({length:t},(a,s)=>[s,...Array(r-1).fill(0)]);for(let a=1;a<r;a++)i[0][a]=a;for(let a=1;a<t;a++)for(let s=1;s<r;s++){let o=n[a-1]===e[s-1]?0:1;i[a][s]=Math.min(i[a-1][s]+1,i[a][s-1]+1,i[a-1][s-1]+o);}return i[t-1][r-1]}function dN(n,e){let t,r=1/0;for(let a of e){let s=Xb(n,a);s<r&&(r=s,t=a);}let i=Math.max(1,Math.floor(n.length/3));return r<=i?t:void 0}function pN(n,e){if(n.keyword==="additionalProperties"&&typeof n.params?.additionalProperty=="string"){let t=n.params.additionalProperty,r=e&&dN(t,e),i=r?` (did you mean "${r}"?)`:"";return `has an unrecognised property "${t}"${i}`}return n.message??"invalid value"}function Mu(n){return n.split("/").filter(Boolean).map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}function fN(n,e){let t=n,r,i=a=>{a&&typeof a=="object"&&typeof a.$origin=="string"&&(r=a.$origin);};i(t);for(let a of Mu(e)){if(t===null||typeof t!="object")break;t=t[a],i(t);}return r}function mN(n,e){let t=Mu(e);for(let r=t.length;r>=0;r--){let i=t.slice(0,r),a=n;for(let s of i){if(a===null||typeof a!="object"){a=void 0;break}a=a[s];}if(a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="string")return {path:`/${i.map(o=>o.replace(/~/g,"~0").replace(/\//g,"~1")).join("/")}`,node:a}}}function Bu(n,e,t=new Set){if(!n||typeof n!="object")return n;let r=n.$ref;if(typeof r!="string")return n;let i=r.match(/^#\/definitions\/([^/]+)$/);return !i?.[1]||t.has(i[1])||!(i[1]in e)?{}:(t.add(i[1]),Bu(e[i[1]],e,t))}function Wu(n,e){let t=Bu(n,e);if(!t||typeof t!="object")return;let r=t;if(!(r.anyOf||r.oneOf)){if(Array.isArray(r.allOf)){let i={properties:{},required:[]};for(let a of r.allOf){let s=Wu(a,e);if(!s)return;Object.assign(i.properties,s.properties),i.required.push(...s.required);}return i}return {properties:r.properties??{},required:r.required??[]}}}function zb(n,e){if(!n||typeof n!="object")return true;let t=n;return "const"in t?t.const===e:Array.isArray(t.enum)?t.enum.includes(e):true}function gN(n,e){let t=n.definitions??{},r=[];for(let[i,a]of Object.entries(t)){let s=Wu(a,t);if(!s)continue;let o=s.properties.type;o&&typeof o=="object"&&("const"in o||Array.isArray(o.enum))&&zb(o,e.type)&&zb(s.properties.operationType,e.operationType)&&r.push(i);}return r}function yN(n,e,t){let r=n.definitions??{},i={definitions:r,...r[e]},a=new zp.default({strict:false,allErrors:true}).compile(i);return a(t)?[]:a.errors??[]}function vN(n,e,t){let r=n.definitions??{},i=Bu(r[e],r);for(let a of Mu(t)){let o=Wu(i,r)?.properties[a];if(o===void 0)return [];i=Bu(o,r);}return Object.keys(Wu(i,r)?.properties??{})}function qu(n){let e=n.map(o=>o.instancePath),t=o=>e.some(u=>u!==o&&u.startsWith(`${o}/`)),r=n.filter(o=>!t(o.instancePath)),i=new Map;for(let o of r){let u=i.get(o.instancePath)??[];u.push(o),i.set(o.instancePath,u);}let a=[];for(let o of i.values()){let u=o.filter(l=>l.keyword!=="anyOf"&&l.keyword!=="oneOf");a.push(...u.length>0?u:o);}let s=new Set;return a.filter(o=>{let u=`${Jp(o)}|${o.message}`;return s.has(u)?false:(s.add(u),true)})}function Gp(n,e,t){return n.map(r=>({instancePath:r.instancePath||"(root)",element:Jp(r),message:pN(r,t?.(r)),origin:fN(e,r.instancePath)}))}function bN(n,e,t){let r=n.map(c=>c.instancePath),i=c=>r.some(h=>h!==c&&h.startsWith(`${c}/`)),a=n.filter(c=>!i(c.instancePath)),s=t&&typeof t=="object"?t:void 0,o=new Map,u=[];for(let c of a){let h=s?mN(e,c.instancePath):void 0;if(!h){u.push(c);continue}let f=o.get(h.path);f?f.errors.push(c):o.set(h.path,{node:h.node,errors:[c]});}let l=Gp(qu(u),e);for(let[c,h]of o){let f=s?gN(s,h.node):[],p=f.length===1?f[0]:void 0;if(!p||!s){l.push(...Gp(qu(h.errors),e));continue}let y=qu(yN(s,p,h.node)).map(C=>({...C,instancePath:`${c}${C.instancePath}`}));l.push(...Gp(y,e,C=>vN(s,p,C.instancePath.slice(c.length))));}return l}var Hp;(h=>{function n(f,p={labelToRemove:[],initialVarsToRemove:[],functions:[],enums:{}}){let g=[];try{return {json:new Hb.Compiler(f,{errorHandler:(v,d)=>{let _=v.replace(/^[A-Z]+: line \d+: ?/,""),m=v.match(/line (\d+)/);g.push({message:_,type:d,line:m?Number(m[1]):-1});},countAllVisits:!0,fileHandler:{ResolveInkFilename:v=>v,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:g}}catch{let C=false,S={...p,textSource:f};return e(g,()=>{C=true;},S),C?n(S.textSource,p):{issues:g}}}h.compile=n;function e(f,p,g){let{functions:y,initialVarsToRemove:C,labelToRemove:S}=g,v=f.find(d=>d.type===Ub.ErrorType.Error);if(v){if(v.message.includes("Divert target not found")){let d=v.message.match(/Divert target not found: '-> (\w+)'/);if(d?.[1]){let _=d[1],m=`
|
|
80
|
+
|
|
81
|
+
=== ${_} ===
|
|
78
82
|
|
|
79
|
-
-> DONE`;return g.textSource=g.textSource.concat(m),
|
|
83
|
+
-> DONE`;return g.textSource=g.textSource.concat(m),S.push(_),p()}}if(v.message.includes("Unresolved variable")){let d=v.message.match(/Unresolved variable: (\w+)/);if(d?.[1]){let _=d[1],m=`VAR ${_} = ""
|
|
80
84
|
|
|
81
|
-
`;return g.textSource=m.concat(g.textSource),C.push(
|
|
85
|
+
`;return g.textSource=m.concat(g.textSource),C.push(_),p()}}if(v.message.includes("Variable could not be found to assign to")){let d=v.message.match(/Variable could not be found to assign to: (\w+)/);if(d?.[1]){let _=d[1],m=`VAR ${_} = ""
|
|
82
86
|
|
|
83
|
-
`;return g.textSource=m.concat(g.textSource),C.push(
|
|
87
|
+
`;return g.textSource=m.concat(g.textSource),C.push(_),p()}}if(v.message.includes("Variable could not be found to assign to")){let d=v.message.match(/Variable could not be found to assign to: '(\w+)'/);if(d?.[1]){let _=d[1],m=`VAR ${_} = ""
|
|
84
88
|
|
|
85
|
-
`;return g.textSource=m.concat(g.textSource),C.push(
|
|
89
|
+
`;return g.textSource=m.concat(g.textSource),C.push(_),p()}}if(v.message.includes("Function call target not found")){let d=v.message.match(/Function call target not found: '-> (\w+)'/);if(d?.[1]){let _=d[1],m=`
|
|
86
90
|
|
|
87
|
-
=== function ${
|
|
91
|
+
=== function ${_}() ===
|
|
88
92
|
|
|
89
93
|
~ return
|
|
90
94
|
|
|
91
|
-
`;return g.textSource=g.textSource.concat(m),y.push({name:
|
|
95
|
+
`;return g.textSource=g.textSource.concat(m),y.push({name:_,args:0}),S.push(_),p()}}if(v.message.includes(" arguments, but got ")){let d=v.message.match(/Function call to '(\w+)' requires (\d+) arguments, but got (\d+)/);if(d?.[1]){let _=d[1],m=parseInt(d[3]||"0",10),b=m>0?Array.from({length:m},(P,k)=>`arg${k+1}`).join(", "):"",E=`
|
|
92
96
|
|
|
93
|
-
=== function ${
|
|
97
|
+
=== function ${_}(${b}) ===
|
|
94
98
|
|
|
95
99
|
~ return
|
|
96
100
|
|
|
97
101
|
`;g.textSource=g.textSource.replaceAll(`
|
|
98
102
|
|
|
99
|
-
=== function ${
|
|
103
|
+
=== function ${_}() ===
|
|
100
104
|
|
|
101
105
|
~ return
|
|
102
106
|
|
|
103
|
-
`,""),g.textSource=g.textSource.concat(
|
|
107
|
+
`,""),g.textSource=g.textSource.concat(E);let O=y.find(P=>P.name===_);return O?O.args=m:(y.push({name:_,args:m}),S.push(_)),p()}}if(v.message.includes("Could not find target for read count")){let d=v.message.match(/Could not find target for read count: -> (\w+\.\w+)/);if(d?.[1]){let _=d[1],[m,b]=_.split("."),E=`
|
|
104
108
|
|
|
105
109
|
LIST ${m} = ${b}
|
|
106
110
|
|
|
107
|
-
`;return g.textSource=g.textSource.concat(
|
|
111
|
+
`;return g.textSource=g.textSource.concat(E),g.initialVarsToRemove.push(m),g.initialVarsToRemove.push(`${m}.${b}`),p()}}if(v.message.includes("variable for increment could not be found")){let d=v.message.match(/variable for increment could not be found: '(\w+)' after searching:/);if(d?.[1]){let _=d[1],m=`VAR ${_} = 0
|
|
108
112
|
|
|
109
|
-
`;return g.textSource=m.concat(g.textSource),g.initialVarsToRemove.push(
|
|
113
|
+
`;return g.textSource=m.concat(g.textSource),g.initialVarsToRemove.push(_),p()}}return f.forEach(d=>{let _=d.message.match(/Function call to '(\w+)' requires (\d+) arguments, but got (\d+)/);_?.[1]&&(d.message=`The function '${_[1]}' have optional arguments, but in ink all arguments must be required. Please make sure to provide all the required arguments for the function call.`);}),{issues:f}}return {issues:f}}h.getErrors=e;function t(f,p){return Mp(f).filter(({tokens:g})=>!p.some(({validation:y})=>Wp(g,y)))}h.getUnknownHashtagCommands=t;function r(f,p){let g=p.filter(C=>C.validation.type==="zod");if(g.length===0)return [];let y=[];for(let C of Mp(f)){if(p.some(({validation:d})=>Wp(C.tokens,d)))continue;let S;for(let d of g)for(let _ of Lu(d.validation.schema)){let{score:m,hasDiscriminant:b}=aN(C.tokens,_);b&&(!S||m>S.score)&&(S={command:d,branch:_,score:m});}if(!S||S.score<oN)continue;let v=uN(lN(S.branch));if(!v(C.tokens))for(let d of qu(v.errors??[]))y.push({line:C.line,command:C.command,handlerName:S.command.name,instancePath:d.instancePath||"(root)",element:cN(d,C.tokens),message:hN(d),score:S.score});}return y}h.getLikelyUnknownHashtagCommandSchemaIssues=r;function i(f,p){let g=new Set;for(let d of f.matchAll(nN))d[1]&&g.add(d[1]);let y=new Set(p),C=new Set,S=f.split(/\r?\n/),v=[];for(let d=0;d<S.length;d++){let _=(S[d]??"").replace(/\/\/.*$/,"");for(let m of _.matchAll(/->[ \t]+(\w[\w.]*)/g)){let b=m[1];if(!b)continue;let E=b.split(".")[0]??b;rN.has(E)||g.has(E)||y.has(b)||y.has(b.replaceAll(".",iN))||y.has(E)||C.has(b)||(C.add(b),v.push({line:d+1,target:b}));}}return v}h.getUnknownDivertTargets=i;function a(f){return new zp.default({strict:false,allErrors:true}).compile(f)}h.getSchemaValidator=a;function s(f,p){let g=typeof p=="function"?p:a(p);return g(f)?[]:bN(g.errors??[],f,g.schema)}h.validateAgainstJsonSchema=s;function o(f,p){let g=new Set,y=[];for(let d of p){let _=u(d);_!==void 0?y.push(_):g.add(String(d));}y.sort((d,_)=>_-d);let C=[],S=f.length;for(let d=f.length-1;d>=0;d--)g.has(f[d])&&(C.push({key:f[d],sectionTokens:f.slice(d+1,S)}),S=d);C.reverse();let v=[];for(let d of y)d<0||d>=S||(v.push({key:d,sectionTokens:f.slice(d,S)}),S=d-1);return v.reverse(),[...v,...C]}h.extractKeyedSections=o;function u(f){return typeof f=="number"?Number.isInteger(f)&&f>=0?f:void 0:/^\d+$/.test(f)?Number(f):void 0}function l(f,p){let g=o(f,Object.keys(p)),y=[];for(let{key:C,sectionTokens:S}of g){let v;try{v=T.convertListStringToObj(S);}catch(_){y.push({key:C,instancePath:"(root)",element:String(C),message:`could not parse "${C}" section into key/value pairs: ${_ instanceof Error?_.message:String(_)}`});continue}let d=s(v,p[C]);y.push(...d.map(_=>({..._,key:C})));}return y}h.validateKeyedJsonSchemas=l;function c(f,p){let g=[];for(let y of Mp(f)){let C=p.find(({validation:v})=>Wp(y.tokens,v));if(!C?.keySchemas)continue;let S=l(y.tokens,C.keySchemas);g.push(...S.map(v=>({...v,line:y.line,command:y.command})));}return g}h.getHashtagKeySchemaIssues=c;})(Hp||={});var Up=ei(Pr(),1);function Yb(n){if(!n||n.length===0)return;let e=new Set;for(let t of n){let r=typeof t=="string"?t:t?.id;typeof r=="string"&&r.length>0&&e.add(r);}return e.size>0?e:void 0}function Zb(n,e={}){let t={labelToRemove:[],initialVarsToRemove:[],functions:e.functions||[],enums:e.enums||{},textSource:n},{json:r,issues:i}=Hp.compile(n,t);if(i.forEach(({message:s,type:o})=>{o===Up.ErrorType.Error?Y.error(`Ink compilation error: ${s}`):o===Up.ErrorType.Warning?Y.warn(`Ink compilation warning: ${s}`):Y.info(`Ink compilation info: ${s}`);}),!r){Y.error("No JSON generated from ink file");return}let a;try{a=si.parse(r);}catch{Y.error("Error parsing ink file");return}return t.enums=a.listDefs||{},al.inkToJson(a,{...t,characterIds:Yb(e.characters)})}export{w as a,ei as b,ti as c,pt as d,Os as e,qN as f,HN as g,aF as h,T as i,rF as j,iF as k,jf as l,Pr as m,Hp as n,Zb as o};
|