@drincs/pixi-vn-json 1.13.5 → 1.13.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import {getValueFromConditionalStatements,getLogichValue,getConditionalStep,setInitialStorageValue,setStorageValue,videoOperation,soundOperation,loadAssets,narrationOperation,textOperation,imageOperation,imageContainerOperation,effectOperation,canvasElementOperation,animateOperation}from'@drincs/pixi-vn-json/actions';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {ZodType}from'zod';export*from'@drincs/pixi-vn-json/interpreter';var g;(v=>{let n=new Set;function o(m){n.add(m);}v.add=o;function h(){n.clear();}v.clear=h;function y(m,x={}){let p=a=>getLogichValue(a,x)??void 0,u=getValueFromConditionalStatements(m,x);if(n.size===0)return p(u);let c=p;for(let a of n){let e=c;c=i=>a(i,e)??void 0;}return c(u)}v.getLogichValue=y;})(g||(g={}));var b={version:"1.13.5"};var _="___param___",N=`https://pixi-vn.com/schemas/${b.version}/schema.json`,T=["==","!=","<","<=",">",">=","CONTAINS"];var O;(a=>{a.options={replaceRegex:/\[([^\]]+)\]/};let o=[],h=false,y=false;function v(e,i){o.unshift({fn:e,opts:i});let t=i.type??"before-translation";t==="before-translation"&&!h?(translator$1.beforeToTranslate=r=>p(r,{type:"before-translation"}),h=true):t==="after-translation"&&!y&&(translator$1.afterToTranslate=r=>p(r,{type:"after-translation"}),y=true);}a.add=v;function m(e){let i=o.findIndex(t=>t.fn===e);i!==-1&&o.splice(i,1);}a.remove=m;function x(){return o.map(e=>e.opts)}a.info=x;function p(e,i){for(let r of o.filter(d=>d.opts.i18nInterpolation))e=u(e,r.fn,r.opts.validation);let t=o.filter(r=>(r.opts.type??"before-translation")===i.type);for(let r of t)e=c(e,r.fn,r.opts.validation);return e}a.replace=p;function u(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof ZodType&&!t.safeParse(s).success)continue}i(s)!==void 0&&(e=e.replace(`[${s}]`,`{{[${s}]}}`));}return e}function c(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof ZodType&&!t.safeParse(s).success)continue}let j=i(s);j!==void 0&&(e=e.replaceAll(`[${s}]`,j));}return e}})(O||(O={}));function pe(){JsonUnifier.init({animateOperation:animateOperation,canvasElementOperation:canvasElementOperation,effectOperation:effectOperation,imageContainerOperation:imageContainerOperation,imageOperation:imageOperation,textOperation:textOperation,narrationOperation:narrationOperation,loadAssets:loadAssets,soundOperation:soundOperation,videoOperation:videoOperation,setStorageValue:setStorageValue,setInitialStorageValue:setInitialStorageValue,getLogichValue:g.getLogichValue,getConditionalStep:getConditionalStep});}
1
+ import {getValueFromConditionalStatements,getLogichValue,getConditionalStep,setInitialStorageValue,setStorageValue,videoOperation,soundOperation,loadAssets,narrationOperation,textOperation,imageOperation,imageContainerOperation,effectOperation,canvasElementOperation,animateOperation}from'@drincs/pixi-vn-json/actions';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {ZodType}from'zod';export*from'@drincs/pixi-vn-json/interpreter';var g;(v=>{let n=new Set;function o(m){n.add(m);}v.add=o;function h(){n.clear();}v.clear=h;function y(m,x={}){let p=a=>getLogichValue(a,x)??void 0,u=getValueFromConditionalStatements(m,x);if(n.size===0)return p(u);let c=p;for(let a of n){let e=c;c=i=>a(i,e)??void 0;}return c(u)}v.getLogichValue=y;})(g||(g={}));var b={version:"1.13.7"};var _="___param___",N=`https://pixi-vn.com/schemas/${b.version}/schema.json`,T=["==","!=","<","<=",">",">=","CONTAINS"];var O;(a=>{a.options={replaceRegex:/\[([^\]]+)\]/};let o=[],h=false,y=false;function v(e,i){o.unshift({fn:e,opts:i});let t=i.type??"before-translation";t==="before-translation"&&!h?(translator$1.beforeToTranslate=r=>p(r,{type:"before-translation"}),h=true):t==="after-translation"&&!y&&(translator$1.afterToTranslate=r=>p(r,{type:"after-translation"}),y=true);}a.add=v;function m(e){let i=o.findIndex(t=>t.fn===e);i!==-1&&o.splice(i,1);}a.remove=m;function x(){return o.map(e=>e.opts)}a.info=x;function p(e,i){for(let r of o.filter(d=>d.opts.i18nInterpolation))e=u(e,r.fn,r.opts.validation);let t=o.filter(r=>(r.opts.type??"before-translation")===i.type);for(let r of t)e=c(e,r.fn,r.opts.validation);return e}a.replace=p;function u(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof ZodType&&!t.safeParse(s).success)continue}i(s)!==void 0&&(e=e.replace(`[${s}]`,`{{[${s}]}}`));}return e}function c(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof ZodType&&!t.safeParse(s).success)continue}let j=i(s);j!==void 0&&(e=e.replaceAll(`[${s}]`,j));}return e}})(O||(O={}));function pe(){JsonUnifier.init({animateOperation:animateOperation,canvasElementOperation:canvasElementOperation,effectOperation:effectOperation,imageContainerOperation:imageContainerOperation,imageOperation:imageOperation,textOperation:textOperation,narrationOperation:narrationOperation,loadAssets:loadAssets,soundOperation:soundOperation,videoOperation:videoOperation,setStorageValue:setStorageValue,setInitialStorageValue:setInitialStorageValue,getLogichValue:g.getLogichValue,getConditionalStep:getConditionalStep});}
2
2
  export{_ as PIXIVNJSON_PARAM_ID,N as PIXIVNJSON_SCHEMA_URL,T as PixiVNJsonComparationOperators,O as TextReplaces,g as VariableGetter,pe as init};
@@ -1 +1 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},g=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!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 i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=g.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var B=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=B<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=g.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},m=d.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,B=b*4,j=S/B;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var k=0;k<E;k+=b)this._doProcessBlock(l,k);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=g.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=m.extend({cfg:g.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){m.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((z,Y)=>{(function(s,e){typeof z=="object"?Y.exports=z=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(z,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],m=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=g[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&m)+1518500249:P<40?o+=(N^C^m)+1859775393:P<60?o+=(N&C|N&m|C&m)-1894007588:o+=(N^C^m)-899497514,x=m,m=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+m|0,f[4]=f[4]+x|0;},_doFinalize:function(){var g=this._data,v=g.words,f=this._nDataBytes*8,J=g.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,g.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var g=n.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_imageOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_videoOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_imageContainerOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_textOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_canvasElementOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_setStorageValue",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_setInitialStorageValue",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_narrationOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_effectOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_animateOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_getLogichValue",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_getConditionalStep",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=core.JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=core.JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":core.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await core.JsonUnifier.loadAssets(t);break;case "image":await core.JsonUnifier.imageOperation(t);break;case "video":await core.JsonUnifier.videoOperation(t);break;case "imagecontainer":await core.JsonUnifier.imageContainerOperation(t);break;case "text":await core.JsonUnifier.textOperation(t);break;case "canvaselement":await core.JsonUnifier.canvasElementOperation(t);break;case "value":core.JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":core.JsonUnifier.narrationOperation(t);break;case "shake":await core.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":core.JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=core.JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&core.JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends narration.LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=core.JsonUnifier.getConditionalStep(d),d.operations)try{let g=d.operations.map(v=>core.JsonUnifier.loadAssets(v));await Promise.all(g);}catch(g){h.error("The operation in the onLoadingLabel function of the label has an error:",g);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=core.JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=core.JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(g=>`${g}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=core.JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=core.JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=core.JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.translator.t(this.getDialogueText(n.text,t))}:translator.translator.t(this.getDialogueText(n,t))}getChoices(r,t){return core.JsonUnifier.getLogichValue(r,t)?.map(a=>core.JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=pixiVn.createExportableElement(n),n=core.JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?m=>this.operationStringConvert(m,n,t):void 0,{operations:a=[]}=n;for(let m of a)await $(m,t,p);let{labelToOpen:d=[]}=n,g=this.getChoices(n.choices,t),v=core.JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(m=>{let x=core.JsonUnifier.getLogichValue(m,t);x&&J.push(x);});let N=core.JsonUnifier.getLogichValue(n.goNextStep,t),C=core.JsonUnifier.getLogichValue(n.end,t);if(g){let m=g.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.translator.t(u));else if(u&&typeof u=="object"){let l=core.JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=core.JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.translator.t(l)):o.push(translator.translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.narration.choices=m;}else narration.narration.choices=void 0;f!==void 0&&(narration.narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.narration.dialogGlue=true:v===false&&(narration.narration.dialogGlue=false);for(let m of J){let x=m.label;typeof x=="object"&&(x=core.JsonUnifier.getLogichValue(x,t)||"");let P=m.params?.map(i=>core.JsonUnifier.getLogichValue(i,t));t={...t,...m.props},m.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t)):(storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t));}C==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(t,{runNow:true})):C==="label_end"&&narration.narration.closeCurrentLabel(),N&&await narration.narration.continue(t,{runNow:true});}}};async function ge(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let g=a[d],v=new _(d,g,void 0,e);narration.RegisteredLabels.add(v);}catch(g){h.error(`Error creating JSON label ${d}`,g);}}return Promise.resolve()});await Promise.all(n);}exports.LabelJson=_;exports.importPixiVNJson=ge;
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},m=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!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 i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=m.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var B=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=B<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},g=d.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,B=b*4,j=S/B;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var k=0;k<E;k+=b)this._doProcessBlock(l,k);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=g.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((z,Y)=>{(function(s,e){typeof z=="object"?Y.exports=z=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(z,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],g=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=m[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&g)+1518500249:P<40?o+=(N^C^g)+1859775393:P<60?o+=(N&C|N&g|C&g)-1894007588:o+=(N^C^g)-899497514,x=g,g=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+g|0,f[4]=f[4]+x|0;},_doFinalize:function(){var m=this._data,v=m.words,f=this._nDataBytes*8,J=m.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,m.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var m=n.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_imageOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_videoOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_imageContainerOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_textOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_canvasElementOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_setStorageValue",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_setInitialStorageValue",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_narrationOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_effectOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_animateOperation",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_getLogichValue",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),V(c,"_getConditionalStep",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=core.JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=core.JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":core.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await core.JsonUnifier.loadAssets(t);break;case "image":await core.JsonUnifier.imageOperation(t);break;case "video":await core.JsonUnifier.videoOperation(t);break;case "imagecontainer":await core.JsonUnifier.imageContainerOperation(t);break;case "text":await core.JsonUnifier.textOperation(t);break;case "canvaselement":await core.JsonUnifier.canvasElementOperation(t);break;case "value":core.JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":core.JsonUnifier.narrationOperation(t);break;case "shake":await core.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":core.JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=core.JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&core.JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends narration.LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=core.JsonUnifier.getConditionalStep(d),d.operations)try{let m=d.operations.map(v=>core.JsonUnifier.loadAssets(v));await Promise.all(m);}catch(m){h.error("The operation in the onLoadingLabel function of the label has an error:",m);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=core.JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=core.JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(m=>`${m}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=core.JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=core.JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=core.JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.translator.t(this.getDialogueText(n.text,t))}:translator.translator.t(this.getDialogueText(n,t))}getChoices(r,t){return core.JsonUnifier.getLogichValue(r,t)?.map(a=>core.JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=pixiVn.createExportableElement(n),n=core.JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?g=>this.operationStringConvert(g,n,t):void 0,{operations:a=[]}=n;for(let g of a)await $(g,t,p);let{labelToOpen:d=[]}=n,m=this.getChoices(n.choices,t),v=core.JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(g=>{let x=core.JsonUnifier.getLogichValue(g,t);x&&J.push(x);});let N=core.JsonUnifier.getLogichValue(n.goNextStep,t),C=core.JsonUnifier.getLogichValue(n.end,t);if(m){let g=m.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.translator.t(u));else if(u&&typeof u=="object"){let l=core.JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=core.JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.translator.t(l)):o.push(translator.translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.narration.choices=g;}else narration.narration.choices=void 0;f!==void 0&&(narration.narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.narration.dialogGlue=true:v===false&&(narration.narration.dialogGlue=false);for(let g of J){let x=g.label;typeof x=="object"&&(x=core.JsonUnifier.getLogichValue(x,t)||"");let P=g.params?.map(i=>core.JsonUnifier.getLogichValue(i,t));t={...t,...g.props},g.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t)):(storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t));}C==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(t,{runNow:true})):C==="label_end"&&narration.narration.closeCurrentLabel(),N&&await narration.narration.continue(t,{runNow:true});}}};async function me(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let m=a[d],v=new _(d,m,void 0,e);narration.RegisteredLabels.add(v);}catch(m){h.error(`Error creating JSON label ${d}`,m);}}return Promise.resolve()});await Promise.all(n);}exports.LabelJson=_;exports.importPixiVNJson=me;
@@ -1,43 +1,10 @@
1
- import { n as PixiVNJsonLabelStep, w as PixiVNJsonValueSet, k as PixiVNJsonIfElse, q as PixiVNJsonOperation } from './PixiVNJsonLabelStep-B7SEp127.cjs';
1
+ import { F as PixiVNJsonLabelStep, L as PixiVNJsonOperation } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
2
2
  import { LabelAbstract, LabelProps, StepLabelPropsType, StepLabelType } from '@drincs/pixi-vn/narration';
3
+ import { PixiVNJson } from './schema.cjs';
3
4
  import '@drincs/pixi-vn';
4
5
  import '@drincs/pixi-vn/motion';
5
6
  import 'pixi.js';
6
7
 
7
- /**
8
- * Collection of labels to be used in the narrative.
9
- */
10
- type PixiVNJsonLabels = {
11
- [labelId: string]: PixiVNJsonLabelStep[];
12
- };
13
-
14
- /**
15
- * PixiVNJson It can be defined as a programming language to write a narrative written in json.
16
- */
17
- interface PixiVNJson {
18
- /**
19
- * The URI of the JSON Schema that describes and validates this document.
20
- *
21
- * You can point to a specific version of the schema, for example:
22
- * - `"https://pixi-vn.com/schemas/1.13.0/schema.json"` — pin to a specific version
23
- * - `"https://pixi-vn.com/schemas/latest/schema.json"` — always use the latest version
24
- *
25
- * Most editors (VS Code, WebStorm, etc.) use this field to provide
26
- * auto-completion, hover documentation, and validation for the document.
27
- */
28
- $schema?: string;
29
- /**
30
- * The operations to be executed before the narrative starts.
31
- * For the set storage: They will be set only if there are no variables with the same key already.
32
- * For the det tempstorage: if there are variables with the same key already, they will be overwritten.
33
- */
34
- initialOperations?: (PixiVNJsonValueSet | PixiVNJsonIfElse<PixiVNJsonValueSet>)[];
35
- /**
36
- * The labels to be used in the narrative. They will be added to the system
37
- */
38
- labels?: PixiVNJsonLabels;
39
- }
40
-
41
8
  type LabelJsonOptions = {
42
9
  /**
43
10
  * Function that converts a string to a {@link PixiVNJsonOperation}.
@@ -1,43 +1,10 @@
1
- import { n as PixiVNJsonLabelStep, w as PixiVNJsonValueSet, k as PixiVNJsonIfElse, q as PixiVNJsonOperation } from './PixiVNJsonLabelStep-B7SEp127.js';
1
+ import { F as PixiVNJsonLabelStep, L as PixiVNJsonOperation } from './PixiVNJsonLabelStep-DJgORyFd.js';
2
2
  import { LabelAbstract, LabelProps, StepLabelPropsType, StepLabelType } from '@drincs/pixi-vn/narration';
3
+ import { PixiVNJson } from './schema.js';
3
4
  import '@drincs/pixi-vn';
4
5
  import '@drincs/pixi-vn/motion';
5
6
  import 'pixi.js';
6
7
 
7
- /**
8
- * Collection of labels to be used in the narrative.
9
- */
10
- type PixiVNJsonLabels = {
11
- [labelId: string]: PixiVNJsonLabelStep[];
12
- };
13
-
14
- /**
15
- * PixiVNJson It can be defined as a programming language to write a narrative written in json.
16
- */
17
- interface PixiVNJson {
18
- /**
19
- * The URI of the JSON Schema that describes and validates this document.
20
- *
21
- * You can point to a specific version of the schema, for example:
22
- * - `"https://pixi-vn.com/schemas/1.13.0/schema.json"` — pin to a specific version
23
- * - `"https://pixi-vn.com/schemas/latest/schema.json"` — always use the latest version
24
- *
25
- * Most editors (VS Code, WebStorm, etc.) use this field to provide
26
- * auto-completion, hover documentation, and validation for the document.
27
- */
28
- $schema?: string;
29
- /**
30
- * The operations to be executed before the narrative starts.
31
- * For the set storage: They will be set only if there are no variables with the same key already.
32
- * For the det tempstorage: if there are variables with the same key already, they will be overwritten.
33
- */
34
- initialOperations?: (PixiVNJsonValueSet | PixiVNJsonIfElse<PixiVNJsonValueSet>)[];
35
- /**
36
- * The labels to be used in the narrative. They will be added to the system
37
- */
38
- labels?: PixiVNJsonLabels;
39
- }
40
-
41
8
  type LabelJsonOptions = {
42
9
  /**
43
10
  * Function that converts a string to a {@link PixiVNJsonOperation}.
@@ -1 +1 @@
1
- import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator}from'@drincs/pixi-vn-json/translator';import {LabelAbstract,narration,RegisteredLabels}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},g=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!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 i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=g.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var B=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=B<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=g.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},m=d.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,B=b*4,j=S/B;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var k=0;k<E;k+=b)this._doProcessBlock(l,k);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=g.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=m.extend({cfg:g.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){m.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((z,Y)=>{(function(s,e){typeof z=="object"?Y.exports=z=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(z,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],m=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=g[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&m)+1518500249:P<40?o+=(N^C^m)+1859775393:P<60?o+=(N&C|N&m|C&m)-1894007588:o+=(N^C^m)-899497514,x=m,m=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+m|0,f[4]=f[4]+x|0;},_doFinalize:function(){var g=this._data,v=g.words,f=this._nDataBytes*8,J=g.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,g.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var g=n.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.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.")}),V(c,"_imageOperation",()=>{throw h.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.")}),V(c,"_videoOperation",()=>{throw h.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.")}),V(c,"_imageContainerOperation",()=>{throw h.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.")}),V(c,"_textOperation",()=>{throw h.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.")}),V(c,"_canvasElementOperation",()=>{throw h.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.")}),V(c,"_setStorageValue",()=>{throw h.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.")}),V(c,"_setInitialStorageValue",()=>{throw h.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.")}),V(c,"_narrationOperation",()=>{throw h.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.")}),V(c,"_effectOperation",()=>{throw h.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.")}),V(c,"_animateOperation",()=>{throw h.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.")}),V(c,"_getLogichValue",()=>{throw h.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.")}),V(c,"_getConditionalStep",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=JsonUnifier.getConditionalStep(d),d.operations)try{let g=d.operations.map(v=>JsonUnifier.loadAssets(v));await Promise.all(g);}catch(g){h.error("The operation in the onLoadingLabel function of the label has an error:",g);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(g=>`${g}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.t(this.getDialogueText(n.text,t))}:translator.t(this.getDialogueText(n,t))}getChoices(r,t){return JsonUnifier.getLogichValue(r,t)?.map(a=>JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=createExportableElement(n),n=JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?m=>this.operationStringConvert(m,n,t):void 0,{operations:a=[]}=n;for(let m of a)await $(m,t,p);let{labelToOpen:d=[]}=n,g=this.getChoices(n.choices,t),v=JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(m=>{let x=JsonUnifier.getLogichValue(m,t);x&&J.push(x);});let N=JsonUnifier.getLogichValue(n.goNextStep,t),C=JsonUnifier.getLogichValue(n.end,t);if(g){let m=g.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.t(u));else if(u&&typeof u=="object"){let l=JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.t(l)):o.push(translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.choices=m;}else narration.choices=void 0;f!==void 0&&(narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.dialogGlue=true:v===false&&(narration.dialogGlue=false);for(let m of J){let x=m.label;typeof x=="object"&&(x=JsonUnifier.getLogichValue(x,t)||"");let P=m.params?.map(i=>JsonUnifier.getLogichValue(i,t));t={...t,...m.props},m.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t)):(storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t));}C==="game_end"?(narration.closeAllLabels(),await narration.continue(t,{runNow:true})):C==="label_end"&&narration.closeCurrentLabel(),N&&await narration.continue(t,{runNow:true});}}};async function ge(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let g=a[d],v=new _(d,g,void 0,e);RegisteredLabels.add(v);}catch(g){h.error(`Error creating JSON label ${d}`,g);}}return Promise.resolve()});await Promise.all(n);}export{_ as LabelJson,ge as importPixiVNJson};
1
+ import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator}from'@drincs/pixi-vn-json/translator';import {LabelAbstract,narration,RegisteredLabels}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},m=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!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 i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=m.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var B=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=B<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},g=d.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,B=b*4,j=S/B;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var k=0;k<E;k+=b)this._doProcessBlock(l,k);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=g.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((z,Y)=>{(function(s,e){typeof z=="object"?Y.exports=z=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(z,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],g=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=m[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&g)+1518500249:P<40?o+=(N^C^g)+1859775393:P<60?o+=(N&C|N&g|C&g)-1894007588:o+=(N^C^g)-899497514,x=g,g=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+g|0,f[4]=f[4]+x|0;},_doFinalize:function(){var m=this._data,v=m.words,f=this._nDataBytes*8,J=m.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,m.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var m=n.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.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.")}),V(c,"_imageOperation",()=>{throw h.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.")}),V(c,"_videoOperation",()=>{throw h.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.")}),V(c,"_imageContainerOperation",()=>{throw h.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.")}),V(c,"_textOperation",()=>{throw h.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.")}),V(c,"_canvasElementOperation",()=>{throw h.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.")}),V(c,"_setStorageValue",()=>{throw h.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.")}),V(c,"_setInitialStorageValue",()=>{throw h.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.")}),V(c,"_narrationOperation",()=>{throw h.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.")}),V(c,"_effectOperation",()=>{throw h.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.")}),V(c,"_animateOperation",()=>{throw h.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.")}),V(c,"_getLogichValue",()=>{throw h.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.")}),V(c,"_getConditionalStep",()=>{throw h.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=JsonUnifier.getConditionalStep(d),d.operations)try{let m=d.operations.map(v=>JsonUnifier.loadAssets(v));await Promise.all(m);}catch(m){h.error("The operation in the onLoadingLabel function of the label has an error:",m);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(m=>`${m}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.t(this.getDialogueText(n.text,t))}:translator.t(this.getDialogueText(n,t))}getChoices(r,t){return JsonUnifier.getLogichValue(r,t)?.map(a=>JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=createExportableElement(n),n=JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?g=>this.operationStringConvert(g,n,t):void 0,{operations:a=[]}=n;for(let g of a)await $(g,t,p);let{labelToOpen:d=[]}=n,m=this.getChoices(n.choices,t),v=JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(g=>{let x=JsonUnifier.getLogichValue(g,t);x&&J.push(x);});let N=JsonUnifier.getLogichValue(n.goNextStep,t),C=JsonUnifier.getLogichValue(n.end,t);if(m){let g=m.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.t(u));else if(u&&typeof u=="object"){let l=JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.t(l)):o.push(translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.choices=g;}else narration.choices=void 0;f!==void 0&&(narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.dialogGlue=true:v===false&&(narration.dialogGlue=false);for(let g of J){let x=g.label;typeof x=="object"&&(x=JsonUnifier.getLogichValue(x,t)||"");let P=g.params?.map(i=>JsonUnifier.getLogichValue(i,t));t={...t,...g.props},g.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t)):(storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t));}C==="game_end"?(narration.closeAllLabels(),await narration.continue(t,{runNow:true})):C==="label_end"&&narration.closeCurrentLabel(),N&&await narration.continue(t,{runNow:true});}}};async function me(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let m=a[d],v=new _(d,m,void 0,e);RegisteredLabels.add(v);}catch(m){h.error(`Error creating JSON label ${d}`,m);}}return Promise.resolve()});await Promise.all(n);}export{_ as LabelJson,me as importPixiVNJson};