'use strict';var pixiVn=require('@drincs/pixi-vn');var ce=Object.create;var K=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty;var z=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var U=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var he=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of de(t))!ye.call(i,a)&&a!==e&&K(i,a,{get:()=>t[a],enumerable:!(r=ue(t,a))||r.enumerable});return i};var me=(i,t,e)=>(e=i!=null?ce(ge(i)):{},he(K(e,"default",{value:i,enumerable:!0}),i));var q=U((I,X)=>{(function(i,t){typeof I=="object"?X.exports=I=t():typeof define=="function"&&define.amd?define([],t):i.CryptoJS=t();})(I,function(){var i=i||function(t,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof z=="function")try{r=z("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function n(){}return function(o){var g;return n.prototype=o,g=new n,n.prototype=null,g}}(),u={},p=u.lib={},d=p.Base=function(){return {extend:function(n){var o=l(this);return n&&o.mixIn(n),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var o in n)n.hasOwnProperty(o)&&(this[o]=n[o]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),y=p.WordArray=d.extend({init:function(n,o){n=this.words=n||[],o!=e?this.sigBytes=o:this.sigBytes=n.length*4;},toString:function(n){return (n||c).stringify(this)},concat:function(n){var o=this.words,g=n.words,h=this.sigBytes,V=n.sigBytes;if(this.clamp(),h%4)for(var P=0;P>>2]>>>24-P%4*8&255;o[h+P>>>2]|=$<<24-(h+P)%4*8;}else for(var C=0;C>>2]=g[C>>>2];return this.sigBytes+=V,this},clamp:function(){var n=this.words,o=this.sigBytes;n[o>>>2]&=4294967295<<32-o%4*8,n.length=t.ceil(o/4);},clone:function(){var n=d.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var o=[],g=0;g>>2]>>>24-V%4*8&255;h.push((P>>>4).toString(16)),h.push((P&15).toString(16));}return h.join("")},parse:function(n){for(var o=n.length,g=[],h=0;h>>3]|=parseInt(n.substr(h,2),16)<<24-h%8*4;return new y.init(g,o/2)}},m=f.Latin1={stringify:function(n){for(var o=n.words,g=n.sigBytes,h=[],V=0;V>>2]>>>24-V%4*8&255;h.push(String.fromCharCode(P));}return h.join("")},parse:function(n){for(var o=n.length,g=[],h=0;h>>2]|=(n.charCodeAt(h)&255)<<24-h%4*8;return new y.init(g,o)}},x=f.Utf8={stringify:function(n){try{return decodeURIComponent(escape(m.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return m.parse(unescape(encodeURIComponent(n)))}},T=p.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=x.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var o,g=this._data,h=g.words,V=g.sigBytes,P=this.blockSize,$=P*4,C=V/$;n?C=t.ceil(C):C=t.max((C|0)-this._minBufferSize,0);var _=C*P,j=t.min(_*4,V);if(_){for(var F=0;F<_;F+=P)this._doProcessBlock(h,F);o=h.splice(0,_),g.sigBytes-=j;}return new y.init(o,j)},clone:function(){var n=d.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});p.Hasher=T.extend({cfg:d.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){T.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(n){return function(o,g){return new n.init(g).finalize(o)}},_createHmacHelper:function(n){return function(o,g){return new N.HMAC.init(n,g).finalize(o)}}});var N=u.algo={};return u}(Math);return i});});var Z=U((D,Y)=>{(function(i,t){typeof D=="object"?Y.exports=D=t(q()):typeof define=="function"&&define.amd?define(["./core"],t):t(i.CryptoJS);})(D,function(i){return function(){var t=i,e=t.lib,r=e.WordArray,a=e.Hasher,l=t.algo,u=[],p=l.SHA1=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,y){for(var f=this._hash.words,c=f[0],m=f[1],x=f[2],T=f[3],b=f[4],N=0;N<80;N++){if(N<16)u[N]=d[y+N]|0;else {var n=u[N-3]^u[N-8]^u[N-14]^u[N-16];u[N]=n<<1|n>>>31;}var o=(c<<5|c>>>27)+b+u[N];N<20?o+=(m&x|~m&T)+1518500249:N<40?o+=(m^x^T)+1859775393:N<60?o+=(m&x|m&T|x&T)-1894007588:o+=(m^x^T)-899497514,b=T,T=x,x=m<<30|m>>>2,m=c,c=o;}f[0]=f[0]+c|0,f[1]=f[1]+m|0,f[2]=f[2]+x|0,f[3]=f[3]+T|0,f[4]=f[4]+b|0;},_doFinalize:function(){var d=this._data,y=d.words,f=this._nDataBytes*8,c=d.sigBytes*8;return y[c>>>5]|=128<<24-c%32,y[(c+64>>>9<<4)+14]=Math.floor(f/4294967296),y[(c+64>>>9<<4)+15]=f,d.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var d=a.clone.call(this);return d._hash=this._hash.clone(),d}});t.SHA1=a._createHelper(p),t.HmacSHA1=a._createHmacHelper(p);}(),i.SHA1});});var pe=me(Z());var E="___param___";var J=class i{static _beforeToTranslate=void 0;static _translate=t=>t;static _afterToTranslate=void 0;static t(t){return Array.isArray(t)?t.map(e=>i.translate(`${e}`)):i.translate(`${t}`)}static set beforeToTranslate(t){i._beforeToTranslate=t;}static set translate(t){i._translate=t;}static get translate(){return t=>{let e=t;return i._beforeToTranslate&&(e=i._beforeToTranslate(e)),e=i._translate(e),i._afterToTranslate&&(e=i._afterToTranslate(e)),e}}static set afterToTranslate(t){i._afterToTranslate=t;}static addKey(t,e,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{t[l]===void 0&&(a==="empty_string"?t[l]="":a==="copy_key"&&(i._beforeToTranslate?t[l]=i._beforeToTranslate(l):t[l]=l));});}static getConditionalsThenElse(t,e=[]){if(typeof t=="object"&&t&&"type"in t)if(t.type==="ifelse")t.then&&i.getConditionalsThenElse(t.then,e),t.else&&i.getConditionalsThenElse(t.else,e);else if(t.type==="stepswitch"){if(t.elements)if(Array.isArray(t.elements))t.elements.forEach(r=>{i.getConditionalsThenElse(r,e);});else if(t.elements.type==="ifelse"){let r=[];i.getConditionalsThenElse(t.elements,r),r.forEach(a=>{e.push(...a);});}else if(t.elements.type==="stepswitch"){let r=[];i.getConditionalsThenElse(t.elements,r),r.forEach(a=>{e.push(...a);});}else i.getConditionalsThenElse(t.elements,e);}else t.type==="resulttocombine"?(t.firstItem&&i.getConditionalsThenElse(t.firstItem,e),t.secondConditionalItem&&t.secondConditionalItem.forEach(r=>{i.getConditionalsThenElse(r,e);})):e.push(t);else t&&e.push(t);return e}static generateJsonTranslation(t,e={},r={}){return t.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=i.getConditionalsThenElse(a.choices),l.forEach(u=>u.forEach(p=>{if("type"in p){let d=[];p.type==="ifelse"||p.type==="stepswitch"?i.getConditionalsThenElse(p,d):d=[p],d.map(f=>i.getConditionalsThenElse(f.text)).forEach(f=>{Array.isArray(f)&&f.forEach(c=>{Array.isArray(c)?c.forEach(m=>{typeof m=="string"?i.addKey(e,m,r):i.getConditionalsThenElse(m).forEach(x=>{Array.isArray(x)?x.forEach(T=>{typeof T=="string"&&i.addKey(e,T,r);}):typeof x=="string"&&i.addKey(e,x,r);});}):typeof c=="string"&&i.addKey(e,c,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=i.getConditionalsThenElse(a.dialogue),l.forEach(u=>{typeof u=="string"?i.addKey(e,u,r):"text"in u&&Array.isArray(u.text)&&u.text.forEach(p=>{typeof p=="string"?i.addKey(e,p,r):i.getConditionalsThenElse(p).forEach(y=>{typeof y=="string"?i.addKey(e,y,r):Array.isArray(y)&&y.forEach(f=>{typeof f=="string"?i.addKey(e,f,r):i.getConditionalsThenElse(f).forEach(c=>{typeof c=="string"&&i.addKey(e,c,r);});});});});});}a.conditionalStep&&i.getConditionalsThenElse(a.conditionalStep).forEach(u=>{Array.isArray(u)?i.generateJsonTranslation(u,e,r):i.generateJsonTranslation([u],e,r);});}),e}};var R=J;function Te(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function be(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"resulttocombine":return Ve(i);case"ifelse":return s(i.condition)?s(i.then):s(i.else);case"stepswitch":let e=s(i.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case"random":let r=Te(0,e.length-1);return s(e[r]);case"loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),s(e[a]);case"sequential":let l,u=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(l=s(e[e.length-1])),u>e.length-1?l:s(e[u]);case"sequentialrandom":let p=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:!0});if(p==null&&i.end=="lastItem"){let d=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!d||!d?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let y=d.usedRandomNumbers[`0-${e.length-1}`];return s(e[y[y.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(e[p])}}return i}function G(i){if(i.conditionalStep){let t=pixiVn.createExportableElement(s(i.conditionalStep));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operations===void 0&&delete t?.operations,t){let e={...i,conditionalStep:void 0,...t};return G(e)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return i}function Ve(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let u=s(l);e.push(u);});else {let l=s(a);e.push(l);}});let r=t?[t,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return R.t(r).join("");if(typeof r[0]=="object"){let a=r,l,u=a.map((n,o)=>{n=G(n);let g=s(n.dialogue)||"";return o===0?(l=s(n.glueEnabled)||!1,g):(typeof g=="object"&&"text"in g&&(g=g.character+": "+g.text),l===!1&&(g=` `+g),l=s(n.glueEnabled)||!1,g)}),p=s(u[0]),d=typeof p=="object"&&"character"in p?p.character:void 0,y=u.map(n=>{let o;n&&typeof n=="object"&&"text"in n?o=n.text:o=n;let g;return Array.isArray(o)?g=o.map(h=>{let V=s(h);return R.t(`${V}`)}).join(""):g=s(o)||"",R.t(g)}).join(""),f=a.find(n=>n.end),c=a.find(n=>n.choices),m=!1,x=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),m=a[a.length-1].glueEnabled,x=a.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let T=a.find(n=>n.labelToOpen),b=[];return a.forEach(n=>{n.operations&&b.forEach(o=>{b.push(o);});}),{dialogue:d?{character:d,text:y}:y,end:f?.end,choices:c?.choices,glueEnabled:m,goNextStep:x,labelToOpen:T?.labelToOpen,operations:b}}}function Ne(i){if(!i)return !1;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case"compare":let t=s(i.leftValue),e=s(i.rightValue);switch(i.operator){case"==":return t===e;case"!=":return t!==e;case"<":return t":return t>e;case">=":return t>=e;case"CONTAINS":return t.toString().includes(e.toString())}break;case"valueCondition":return !!s(i.value);case"union":return Je(i)}return !!i}function Pe(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(i.key);case"flagStorage":return pixiVn.getFlag(i.key);case"label":return pixiVn.narration.getTimesLabelOpened(i.label);case"choice":return pixiVn.narration.getTimesChoiceMade(i.index);case"logic":return s(i.operation);case"params":let t=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return i}function Je(i){if(i.unionType==="not")return !s(i.condition);let t=i.unionType==="and";for(let e=0;e=i.key&&(r[i.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,r);break}}function s(i){let t=be(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"value":return Pe(t);case"arithmetic":case"arithmeticsingle":return Se(t);case"compare":case"valueCondition":case"union":return Ne(t)}return t}function Se(i){let t=s(i.leftValue);switch(i.type){case"arithmetic":let e=s(i.rightValue);switch(i.operator){case"*":return t*e;case"/":return t/e;case"+":return t+e;case"-":return t-e;case"%":return t%e;case"POW":return Math.pow(t,e);case"RANDOM":return pixiVn.narration.getRandomNumber(t,e)}case"arithmeticsingle":switch(i.operator){case"INT":return parseInt(t);case"FLOOR":return Math.floor(t);case"FLOAT":return parseFloat(t)}break}}async function L(i,t){let e=s(i);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(e.alias);break;case"pause":pixiVn.sound.pause(e.alias);break;case"resume":pixiVn.sound.resume(e.alias);break;case"volume":pixiVn.sound.volume(e.alias,e.value);break}break;case"assets":switch(e.operationType){case"load":await pixiVn.Assets.load(e.assets);break}break;case"image":switch(e.operationType){case"show":let p=new pixiVn.CanvasImage(e.props,e.url);if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,p,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,p,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,p,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,p,e.transition.props,e.transition.priority);break;case"pushin":case"pushout":await pixiVn.pushIn(e.alias,p,e.transition.props,e.transition.priority);break}else pixiVn.canvas.add(e.alias,p),await p.load();break;case"edit":let d=pixiVn.canvas.find(e.alias);d?e.props&&(d.memory={...d.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":if(e.transition)switch(e.transition.type){case"fade":pixiVn.removeWithFadeTransition(e.alias,e.transition.props,e.transition.priority);break;case"dissolve":pixiVn.removeWithDissolveTransition(e.alias,e.transition.props,e.transition.priority);break;case"movein":case"moveout":pixiVn.moveOut(e.alias,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":pixiVn.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case"pushin":case"pushout":pixiVn.pushOut(e.alias,e.transition.props,e.transition.priority);break}else pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":let p=new pixiVn.CanvasVideo(e.props,e.url);if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,p,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,p,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,p,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,p,e.transition.props,e.transition.priority);break}else pixiVn.canvas.add(e.alias,p),await p.load();break;case"edit":let d=pixiVn.canvas.find(e.alias);d?e.props&&(d.memory={...d.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":if(e.transition)switch(e.transition.type){case"fade":pixiVn.removeWithFadeTransition(e.alias,e.transition.props,e.transition.priority);break;case"dissolve":pixiVn.removeWithDissolveTransition(e.alias,e.transition.props,e.transition.priority);break;case"movein":case"moveout":pixiVn.moveOut(e.alias,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":pixiVn.zoomOut(e.alias,e.transition.props,e.transition.priority);break}else pixiVn.canvas.remove(e.alias);break;case"pause":let y=pixiVn.canvas.find(e.alias);y?y.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let f=pixiVn.canvas.find(e.alias);f?f.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":W(e);break;case"operationtoconvert":if(t){let p="";e.values.forEach(y=>{if(typeof y=="string")p+=y;else {let f=s(y);p+=`${f}`;}});let d=await t(p);d&&await L(d,t);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType}),pixiVn.narration.inputValue=e.defaultValue;break}break;case"fade":let r=new pixiVn.FadeAlphaTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,r);break;case"move":let a=new pixiVn.MoveTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,a);break;case"rotate":let l=new pixiVn.RotateTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,l);break;case"zoom":let u=new pixiVn.ZoomTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,u);break;case"shake":await pixiVn.shakeEffect(e.alias,e.props,e.priority);break}}var O=class extends pixiVn.LabelAbstract{constructor(t,e,r,a={}){super(t,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(t=>this.stepConverter(t))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(t){if(t<0||t>=this.steps.length)return;let e=this._steps[t];return (0, pe.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let e="";if(Array.isArray(t)){let r=[];t.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=s(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=s(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=s(t)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=s(r)||""),e=r;}return `${e}`}getDialogue(t){if(t==null)return;let e=s(t);return e==null?"":typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:J.t(this.getDialogueText(e.text))}:J.t(this.getDialogueText(e))}getChoices(t){return s(t)?.map(a=>s(a)).filter(a=>a!==void 0)}stepConverter(t){return async e=>{let r;if(typeof t=="function"?r=t():r=t,r=G(r),r.operations)for(let f of r.operations)await L(f,this.operationStringConvert?c=>this.operationStringConvert(c,r,e):void 0);let a=this.getChoices(r.choices),l=s(r.glueEnabled),u=this.getDialogue(r.dialogue),p=[];r.labelToOpen&&(Array.isArray(r.labelToOpen)||(r.labelToOpen=[r.labelToOpen]),r.labelToOpen.forEach(f=>{let c=s(f);c&&p.push(c);}));let d=s(r.goNextStep),y=s(r.end);if(a){let f=a.map(c=>{let m="";if(Array.isArray(c.text)){let x=[];c.text.forEach(T=>{if(typeof T=="string")x.push(J.t(T));else if(T&&typeof T=="object"){let b=s(T);b&&!Array.isArray(b)&&typeof b=="object"&&(b=s(b)||""),b&&(Array.isArray(b)?x=x.concat(J.t(b)):x.push(J.t(b)));}}),m=x.join();}else typeof c.text=="string"&&(m=J.t(c.text));return new pixiVn.ChoiceMenuOption(m,c.label,c.props,{type:c.type,oneTime:c.oneTime,onlyHaveNoChoice:c.onlyHaveNoChoice,autoSelect:c.autoSelect})});pixiVn.narration.choiceMenuOptions=f;}else pixiVn.narration.choiceMenuOptions=void 0;u!==void 0&&(pixiVn.narration.dialogue=u,this.skipEmptyDialogs&&typeof u=="string"&&(u===""||RegExp(/^\s+$/).test(u))&&(d=!0)),l?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):l===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let f of p){let c=f.label;typeof c=="object"&&(c=s(c)||"");let m=f.params?.map(x=>s(x));e={...e,...f.props},f.type==="jump"?(pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,m),await pixiVn.narration.callLabel(c,e)):(pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,m),await pixiVn.narration.callLabel(c,e));}y==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e)):y==="label_end"&&pixiVn.narration.closeCurrentLabel(),d&&await pixiVn.narration.goNext(e);}}};function He(i,t={}){let e=t?.operationStringConvert;try{typeof i=="string"&&(i=JSON.parse(i));}catch(r){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",r);return}if(typeof i!="object"){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON: data is not an object");return}if(i.initialOperations){for(let r of i.initialOperations)L(r,e?a=>e(a,{},{}):void 0);pixiVn.StorageManagerStatic.saveStorageAsBasicStorage();}if(i.labels){let r=i.labels;for(let a in r)try{let l=r[a],u=new O(a,l,void 0,t);pixiVn.saveLabel(u);}catch(l){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${a}`,l);}}}exports.LabelJson=O;exports.PIXIVNJSON_PARAM_ID=E;exports.geLogichValue=s;exports.importPixiVNJson=He;exports.setStorageJson=W;exports.translator=R;