@drincs/pixi-vn 1.8.9 → 1.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas.cjs +2 -10
- package/dist/canvas.mjs +2 -10
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-IFPF4NRX.mjs → chunk-6GLWL3NH.mjs} +1 -1
- package/dist/chunk-GIYMPXBT.mjs +1 -0
- package/dist/chunk-HQQ5WH6C.mjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +1 -1
- package/dist/history.d.ts +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/motion.cjs +1 -1
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +2 -2
- package/dist/narration.d.cts +350 -350
- package/dist/narration.d.ts +350 -350
- package/dist/narration.mjs +2 -2
- package/dist/sound.cjs +1 -1
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-3M6A7TU2.mjs +0 -1
- package/dist/chunk-BQRPDCUT.mjs +0 -1
package/dist/narration.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a}from'./chunk-IFPF4NRX.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {e,d,c,f,g as g$1}from'./chunk-3M6A7TU2.mjs';import {GameUnifier,PixiError}from'./core.mjs';var I=new e({cacheSize:10}),M;(a=>{function y(p){let u=I.get(p);if(!u){f.error(`Label "${p}" not found`);return}return u}a.get=y;function e(p){if(Array.isArray(p)){p.forEach(u=>{e(u);});return}I.has(p.id)&&f.info(`Label "${p.id}" already exists, it will be overwritten`),I.set(p.id,p);}a.add=e;function t(){return Array.from(I.values())}a.values=t;function r(p){return I.has(p)}a.has=r;function n(){return Array.from(I.keys())}a.keys=n;})(M||={});var L=M;var i=class i{constructor(){}static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=i.currentLabelStepIndex;if(t===null)return f.error("currentLabelStepIndex is null"),null;let r=`${t}${e}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return f.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let p=a.getStepSha(t)||"error",u=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n$1]||(u[n$1]={}),(!u[n$1][r]||u[n$1][r].stepSha1!==p)&&(u[n$1][r]={stepSha1:p}),u[n$1][r]}static setCurrentStepTimesCounterData(e="",t){let r=i.currentLabelStepIndex,n$1=r+e,a=i.currentLabelId;if(!a||r===null){f.error("currentLabelId or currentLabelStepIndex is null");return}let p=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};p[a]||(p[a]={}),p[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,p);}static getCurrentStepTimesCounter(e=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e);if(!r)return f.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(p=>p===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let p=i.getCurrentStepTimesCounterData(n);if(!p)return;let u=p.usedRandomNumbers||{},S=Array.from({length:t-e+1},(_,w)=>w+e).filter(_=>!u[`${e}-${t}`]?.includes(_));if(S.length===0)return;let m=Math.floor(Math.random()*S.length),b=S[m];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(b),p.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,p),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=i.currentLabelStepIndex,r=t+e,n$1=i.currentLabelId;if(!n$1||t===null){f.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){i._stepCounter++;}static get openedLabels(){return g$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=g$1(e);}static get originalOpenedLabels(){return g$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=g$1(e);}static get _currentLabel(){if(i.currentLabelId)return L.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,p=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);p<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[p].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!L.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}};d(i,"choiceMadeTemp"),d(i,"lastHistoryStep",null),d(i,"_stepCounter",0),d(i,"_openedLabels",[]),d(i,"_originalOpenedLabels",[]),d(i,"_onStepStart"),d(i,"onLoadingLabel"),d(i,"onStepEnd");var o=i;var R=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,p,u,S=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let m=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:p,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:S,openedLabels:m};o.originalOpenedLabels=m,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){f.warn("No label to close");return}if(!this.currentLabel){f.error("currentLabel not found");return}let e=o.openedLabels;e.pop(),o.openedLabels=e,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=L.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=o.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let r=t.getStepSha(e);return r||(f.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&f.warn("The player must make a choice"),false):this.isRequiredInput?(t&&f.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){f.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){f.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(p){throw f.error("Error continuing",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e,{labelId:"end"});f.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){f.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){f.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){f.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e);return}let p=a.getStepById(n);if(!p){f.error("step not found");return}let u=a.getStepSha(n);u||(f.warn("stepSha not found, setting to ERROR"),u="error");let S,m;try{S=await p(e,{labelId:a.id});}catch(b){f.error("Error running step",b),m=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let _=b[0];S=await this.selectChoice(_,e);}}catch(b){f.error("Error auto-selecting choice",b),m||(m=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(u=b.stepSha1,u||(f.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){f.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){f.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){f.warn("Error running onStepEnd",b);}return m&&this.onStepError&&await this.onStepError(m,e),S}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;f.error("currentLabelId not found");}}async call(e,t,r){let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let p;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw f.error("Error calling label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let p;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw f.error("Error jumping to label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async selectChoice(e,t){this.choices=void 0;let r=e.type;switch(r){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw f.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw f.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e.choiceIndex=="number"&&(r=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e,t)=>{try{await GameUnifier.runOnError(e,t);}catch(r){f.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e.text)?r=[...r,...e.text]:r=[...r,e.text],e.text=r,e.character=e.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,g$1({...e,character:typeof e.character=="string"?e.character:e.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw f.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,p)=>({...a,choiceIndex:p})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,p)=>a.oneTime&&n?.includes(p)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,g$1(e)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw f.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:g$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=L.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(o.openedLabels=e.openedLabels,o.originalOpenedLabels=o.openedLabels):f.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?o._stepCounter=e.stepCounter:f.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){f.error("Error running onLoadingLabel",r);}}catch(r){f.error("Error importing data",r);}}};function Y(y,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:y,type:r?.type||"call"}}var x="close";function V(y,e){return {...e,type:x,text:y}}var N=c(a(),1);var g=class{constructor(e,t){d(this,"id");d(this,"_onStepStart");d(this,"_onLoadingLabel");d(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var E=class extends g{constructor(t,r,n){super(t,n);d(this,"_steps");this._steps=r;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return f.warn("stepSha not found, setting to ERROR"),"error";try{let r=this.steps[t];return (0,N.default)(r.toString().toLocaleLowerCase()).toString()}catch(r){return f.warn("stepSha not found, setting to ERROR",r),"error"}}};function A(y,e,t){let r=new E(y,e,t);return L.add(r),r}var he=new R;
|
|
2
|
-
export{
|
|
1
|
+
import {a}from'./chunk-6GLWL3NH.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {d,c,e,f as f$1}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'./core.mjs';var h=new d({cacheSize:10}),R;(a=>{function i(p){let u=h.get(p);if(!u){e.error(`Label "${p}" not found`);return}return u}a.get=i;function e$1(p){if(Array.isArray(p)){p.forEach(u=>{e$1(u);});return}h.has(p.id)&&e.info(`Label "${p.id}" already exists, it will be overwritten`),h.set(p.id,p);}a.add=e$1;function t(){return Array.from(h.values())}a.values=t;function r(p){return h.has(p)}a.has=r;function n(){return Array.from(h.keys())}a.keys=n;})(R||={});var f=R;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e$1=""){let t=i.currentLabelStepIndex;if(t===null)return e.error("currentLabelStepIndex is null"),null;let r=`${t}${e$1}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return e.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let p=a.getStepSha(t)||"error",u=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n$1]||(u[n$1]={}),(!u[n$1][r]||u[n$1][r].stepSha1!==p)&&(u[n$1][r]={stepSha1:p}),u[n$1][r]}static setCurrentStepTimesCounterData(e$1="",t){let r=i.currentLabelStepIndex,n$1=r+e$1,a=i.currentLabelId;if(!a||r===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let p=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};p[a]||(p[a]={}),p[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,p);}static getCurrentStepTimesCounter(e$1=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e$1);if(!r)return e.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(p=>p===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e$1,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let p=i.getCurrentStepTimesCounterData(n);if(!p)return;let u=p.usedRandomNumbers||{},m=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!u[`${e}-${t}`]?.includes(E));if(m.length===0)return;let L=Math.floor(Math.random()*m.length),b=m[L];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(b),p.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,p),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e$1=""){let t=i.currentLabelStepIndex,r=t+e$1,n$1=i.currentLabelId;if(!n$1||t===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return f$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=f$1(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return f$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=f$1(e);}static get _currentLabel(){if(i.currentLabelId)return f.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,p=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);p<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[p].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!f.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}static onLoadingLabel;static onStepEnd};var C=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,p,u,m=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:p,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:m,openedLabels:L};o.originalOpenedLabels=L,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){e.warn("No label to close");return}if(!this.currentLabel){e.error("currentLabel not found");return}let e$1=o.openedLabels;e$1.pop(),o.openedLabels=e$1,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=f.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e$1=o.currentLabelStepIndex,t=this.currentLabel;if(e$1===null||!t)return;let r=t.getStepSha(e$1);return r||(e.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e$1&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e$1){let t=e$1?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&e.warn("The player must make a choice"),false):this.isRequiredInput?(t&&e.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e$1,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){e.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){e.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e$1,t);}catch(p){throw e.error("Error continuing",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e$1)||a}async afterRunCurrentStep(e$1){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e$1,{labelId:"end"});e.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e$1,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){e.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){e.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){e.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e$1);return}let p=a.getStepById(n);if(!p){e.error("step not found");return}let u=a.getStepSha(n);u||(e.warn("stepSha not found, setting to ERROR"),u="error");let m,L;try{m=await p(e$1,{labelId:a.id});}catch(b){e.error("Error running step",b),L=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let E=b[0];m=await this.selectChoice(E,e$1);}}catch(b){e.error("Error auto-selecting choice",b),L||(L=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(u=b.stepSha1,u||(e.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){e.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){e.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){e.warn("Error running onStepEnd",b);}return L&&this.onStepError&&await this.onStepError(L,e$1),m}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e$1,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;e.error("currentLabelId not found");}}async call(e$1,t,r){let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let p;try{let u=f.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw e.error("Error calling label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async jump(e$1,t,r){if(this.stepCounter===0)return await this.call(e$1,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let p;try{let u=f.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw e.error("Error jumping to label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async selectChoice(e$1,t){this.choices=void 0;let r=e$1.type;switch(r){case "call":return await this.call(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "jump":return await this.jump(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "close":return await this.closeChoiceMenu(e$1,{...e$1.props,...t});default:throw e.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e$1,t){if(e$1.type!=="close")throw e.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e$1.choiceIndex=="number"&&(r=e$1.choiceIndex),e$1.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e$1,t)=>{try{await GameUnifier.runOnError(e$1,t);}catch(r){e.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e$1){if(e$1===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e$1=="string"||Array.isArray(e$1))&&(e$1={text:e$1}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e$1.text)?r=[...r,...e$1.text]:r=[...r,e$1.text],e$1.text=r,e$1.character=e$1.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,f$1({...e$1,character:typeof e$1.character=="string"?e$1.character:e$1.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,p)=>({...a,choiceIndex:p})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,p)=>a.oneTime&&n?.includes(p)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e$1){if(!e$1||e$1.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,f$1(e$1)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:f$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=f.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e$1,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e$1,"openedLabels")?(o.openedLabels=e$1.openedLabels,o.originalOpenedLabels=o.openedLabels):e.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e$1,"stepCounter")?o._stepCounter=e$1.stepCounter:e.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){e.error("Error running onLoadingLabel",r);}}catch(r){e.error("Error importing data",r);}}};function D(i,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:i,type:r?.type||"call"}}var O="close";function U(i,e){return {...e,type:O,text:i}}var M=c(a(),1);var I=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var g=class extends I{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,r){super(e,r),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e$1){if(e$1<0||e$1>=this.steps.length)return e.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e$1];return (0,M.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return e.warn("stepSha not found, setting to ERROR",t),"error"}}};function x(i,e,t){let r=new g(i,e,t);return f.add(r),r}var fe=new C;
|
|
2
|
+
export{g as Label,I as LabelAbstract,o as NarrationManagerStatic,f as RegisteredLabels,fe as narration,D as newChoiceOption,U as newCloseChoiceOption,x as newLabel};
|
package/dist/sound.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('./core.cjs'),kt=require('./pixi/index.js'),B=require('tone');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var kt__default=/*#__PURE__*/_interopDefault(kt);var B__namespace=/*#__PURE__*/_interopNamespace(B);var Rt=Object.defineProperty;var wt=o=>{throw TypeError(o)};var Nt=(o,t,e)=>t in o?Rt(o,t,{enumerable:true,configurable:true,writable:true,value:e}):o[t]=e;var m=(o,t,e)=>Nt(o,typeof t!="symbol"?t+"":t,e),ze=(o,t,e)=>t.has(o)||wt("Cannot "+e);var i=(o,t,e)=>(ze(o,t,"read from private field"),e?e.call(o):t.get(o)),v=(o,t,e)=>t.has(o)?wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),c=(o,t,e,n)=>(ze(o,t,"write to private field"),t.set(o,e),e),d=(o,t,e)=>(ze(o,t,"access private method"),e);var De=(o,t,e,n)=>({set _(s){c(o,t,s);},get _(){return i(o,t,n)}});var Tt="general";var Gt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ot=new Set,qe=typeof process=="object"&&process?process:{},_t=(o,t,e,n)=>{typeof qe.emitWarning=="function"?qe.emitWarning(o,t,e,n):console.error(`[${e}] ${t}: ${o}`);},Re=globalThis.AbortController,At=globalThis.AbortSignal;if(typeof Re>"u"){At=class{constructor(){m(this,"onabort");m(this,"_onabort",[]);m(this,"reason");m(this,"aborted",false);}addEventListener(e,n){this._onabort.push(n);}},Re=class{constructor(){m(this,"signal",new At);t();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let n of this.signal._onabort)n(e);this.signal.onabort?.(e);}}};let o=qe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{o&&(o=false,_t("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var Lt=o=>!Ot.has(o);var se=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),Ct=o=>se(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Ie:null:null,Ie=class extends Array{constructor(o){super(o),this.fill(0);}},te,fe,zt=(te=class{constructor(t,e){m(this,"heap");m(this,"length");if(!i(te,fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Ct(t);if(!e)return [];c(te,fe,true);let n=new te(t,e);return c(te,fe,false),n}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},fe=new WeakMap,v(te,fe,false),te),St,Ft,j,q,K,he,$,ye,ge,H,E,X,_,S,f,N,U,I,P,Q,x,Z,J,W,V,ee,le,G,ve,h,Ue,ue,ie,Fe,Y,Pt,de,be,Oe,ae,re,We,Me,ke,A,Ve,Se,oe,Ye,we,Et=(we=class{constructor(t){v(this,h);v(this,j);v(this,q);v(this,K);v(this,he);v(this,$);v(this,ye);v(this,ge);v(this,H);m(this,"ttl");m(this,"ttlResolution");m(this,"ttlAutopurge");m(this,"updateAgeOnGet");m(this,"updateAgeOnHas");m(this,"allowStale");m(this,"noDisposeOnSet");m(this,"noUpdateTTL");m(this,"maxEntrySize");m(this,"sizeCalculation");m(this,"noDeleteOnFetchRejection");m(this,"noDeleteOnStaleGet");m(this,"allowStaleOnFetchAbort");m(this,"allowStaleOnFetchRejection");m(this,"ignoreFetchAbort");v(this,E);v(this,X);v(this,_);v(this,S);v(this,f);v(this,N);v(this,U);v(this,I);v(this,P);v(this,Q);v(this,x);v(this,Z);v(this,J);v(this,W);v(this,V);v(this,ee);v(this,le);v(this,G);v(this,ve);v(this,ue,()=>{});v(this,ie,()=>{});v(this,Fe,()=>{});v(this,Y,()=>false);v(this,de,t=>{});v(this,be,(t,e,n)=>{});v(this,Oe,(t,e,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});m(this,St,"LRUCache");let{max:e=0,ttl:n,ttlResolution:s=1,ttlAutopurge:r,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:u,dispose:g,onInsert:w,disposeAfter:b,noDisposeOnSet:M,noUpdateTTL:D,maxSize:z=0,maxEntrySize:F=0,sizeCalculation:T,fetchMethod:y,memoMethod:k,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:Ae,ignoreFetchAbort:ce,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,H,pe??Gt),e!==0&&!se(e))throw new TypeError("max option must be a nonnegative integer");let me=e?Ct(e):Array;if(!me)throw new Error("invalid max value: "+e);if(c(this,j,e),c(this,q,z),this.maxEntrySize=F||i(this,q),this.sizeCalculation=T,this.sizeCalculation){if(!i(this,q)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(c(this,ge,k),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,ye,y),c(this,le,!!y),c(this,_,new Map),c(this,S,new Array(e).fill(void 0)),c(this,f,new Array(e).fill(void 0)),c(this,N,new me(e)),c(this,U,new me(e)),c(this,I,0),c(this,P,0),c(this,Q,zt.create(e)),c(this,E,0),c(this,X,0),typeof g=="function"&&c(this,K,g),typeof w=="function"&&c(this,he,w),typeof b=="function"?(c(this,$,b),c(this,x,[])):(c(this,$,void 0),c(this,x,void 0)),c(this,ee,!!i(this,K)),c(this,ve,!!i(this,he)),c(this,G,!!i(this,$)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!Ae,this.ignoreFetchAbort=!!ce,this.maxEntrySize!==0){if(i(this,q)!==0&&!se(i(this,q)))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,h,Pt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=se(s)||s===0?s:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,h,Ue).call(this);}if(i(this,j)===0&&this.ttl===0&&i(this,q)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,j)&&!i(this,q)){let Le="LRU_CACHE_UNBOUNDED";Lt(Le)&&(Ot.add(Le),_t("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,we));}}get perf(){return i(this,H)}static unsafeExposeInternals(t){return {starts:i(t,J),ttls:i(t,W),autopurgeTimers:i(t,V),sizes:i(t,Z),keyMap:i(t,_),keyList:i(t,S),valList:i(t,f),next:i(t,N),prev:i(t,U),get head(){return i(t,I)},get tail(){return i(t,P)},free:i(t,Q),isBackgroundFetch:e=>{var n;return d(n=t,h,A).call(n,e)},backgroundFetch:(e,n,s,r)=>{var a;return d(a=t,h,ke).call(a,e,n,s,r)},moveToTail:e=>{var n;return d(n=t,h,Se).call(n,e)},indexes:e=>{var n;return d(n=t,h,ae).call(n,e)},rindexes:e=>{var n;return d(n=t,h,re).call(n,e)},isStale:e=>{var n;return i(n=t,Y).call(n,e)}}}get max(){return i(this,j)}get maxSize(){return i(this,q)}get calculatedSize(){return i(this,X)}get size(){return i(this,E)}get fetchMethod(){return i(this,ye)}get memoMethod(){return i(this,ge)}get dispose(){return i(this,K)}get onInsert(){return i(this,he)}get disposeAfter(){return i(this,$)}getRemainingTTL(t){return i(this,_).has(t)?1/0:0}*entries(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&i(this,S)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,S)[t],i(this,f)[t]]);}*rentries(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&i(this,S)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,S)[t],i(this,f)[t]]);}*keys(){for(let t of d(this,h,ae).call(this)){let e=i(this,S)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*rkeys(){for(let t of d(this,h,re).call(this)){let e=i(this,S)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*values(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}*rvalues(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}[(Ft=Symbol.iterator,St=Symbol.toStringTag,Ft)](){return this.entries()}find(t,e={}){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(r!==void 0&&t(r,i(this,S)[n],this))return this.get(i(this,S)[n],e)}}forEach(t,e=this){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,S)[n],this);}}rforEach(t,e=this){for(let n of d(this,h,re).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,S)[n],this);}}purgeStale(){let t=false;for(let e of d(this,h,re).call(this,{allowStale:true}))i(this,Y).call(this,e)&&(d(this,h,oe).call(this,i(this,S)[e],"expire"),t=true);return t}info(t){let e=i(this,_).get(t);if(e===void 0)return;let n=i(this,f)[e],s=d(this,h,A).call(this,n)?n.__staleWhileFetching:n;if(s===void 0)return;let r={value:s};if(i(this,W)&&i(this,J)){let a=i(this,W)[e],l=i(this,J)[e];if(a&&l){let u=a-(i(this,H).now()-l);r.ttl=u,r.start=Date.now();}}return i(this,Z)&&(r.size=i(this,Z)[e]),r}dump(){let t=[];for(let e of d(this,h,ae).call(this,{allowStale:true})){let n=i(this,S)[e],s=i(this,f)[e],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0||n===void 0)continue;let a={value:r};if(i(this,W)&&i(this,J)){a.ttl=i(this,W)[e];let l=i(this,H).now()-i(this,J)[e];a.start=Math.floor(Date.now()-l);}i(this,Z)&&(a.size=i(this,Z)[e]),t.unshift([n,a]);}return t}load(t){this.clear();for(let[e,n]of t){if(n.start){let s=Date.now()-n.start;n.start=i(this,H).now()-s;}this.set(e,n.value,n);}}set(t,e,n={}){var M,D,z,F;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:r,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n,{noUpdateTTL:g=this.noUpdateTTL}=n,w=i(this,Oe).call(this,t,e,n.size||0,l);if(this.maxEntrySize&&w>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),d(this,h,oe).call(this,t,"set"),this;let b=i(this,E)===0?void 0:i(this,_).get(t);if(b===void 0)b=i(this,E)===0?i(this,P):i(this,Q).length!==0?i(this,Q).pop():i(this,E)===i(this,j)?d(this,h,Me).call(this,false):i(this,E),i(this,S)[b]=t,i(this,f)[b]=e,i(this,_).set(t,b),i(this,N)[i(this,P)]=b,i(this,U)[b]=i(this,P),c(this,P,b),De(this,E)._++,i(this,be).call(this,b,w,u),u&&(u.set="add"),g=false,i(this,ve)&&((M=i(this,he))==null||M.call(this,e,t,"add"));else {d(this,h,Se).call(this,b);let T=i(this,f)[b];if(e!==T){if(i(this,le)&&d(this,h,A).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=T;y!==void 0&&!a&&(i(this,ee)&&((D=i(this,K))==null||D.call(this,y,t,"set")),i(this,G)&&i(this,x)?.push([y,t,"set"]));}else a||(i(this,ee)&&((z=i(this,K))==null||z.call(this,T,t,"set")),i(this,G)&&i(this,x)?.push([T,t,"set"]));if(i(this,de).call(this,b),i(this,be).call(this,b,w,u),i(this,f)[b]=e,u){u.set="replace";let y=T&&d(this,h,A).call(this,T)?T.__staleWhileFetching:T;y!==void 0&&(u.oldValue=y);}}else u&&(u.set="update");i(this,ve)&&this.onInsert?.(e,t,e===T?"update":"replace");}if(s!==0&&!i(this,W)&&d(this,h,Ue).call(this),i(this,W)&&(g||i(this,Fe).call(this,b,s,r),u&&i(this,ie).call(this,u,b)),!a&&i(this,G)&&i(this,x)){let T=i(this,x),y;for(;y=T?.shift();)(F=i(this,$))==null||F.call(this,...y);}return this}pop(){var t;try{for(;i(this,E);){let e=i(this,f)[i(this,I)];if(d(this,h,Me).call(this,!0),d(this,h,A).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,G)&&i(this,x)){let e=i(this,x),n;for(;n=e?.shift();)(t=i(this,$))==null||t.call(this,...n);}}}has(t,e={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=e,r=i(this,_).get(t);if(r!==void 0){let a=i(this,f)[r];if(d(this,h,A).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(i(this,Y).call(this,r))s&&(s.has="stale",i(this,ie).call(this,s,r));else return n&&i(this,ue).call(this,r),s&&(s.has="hit",i(this,ie).call(this,s,r)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:n=this.allowStale}=e,s=i(this,_).get(t);if(s===void 0||!n&&i(this,Y).call(this,s))return;let r=i(this,f)[s];return d(this,h,A).call(this,r)?r.__staleWhileFetching:r}async fetch(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:w=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:z=this.allowStaleOnFetchAbort,context:F,forceRefresh:T=false,status:y,signal:k}=e;if(!i(this,le))return y&&(y.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,status:y});let L={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,ttl:a,noDisposeOnSet:l,size:u,sizeCalculation:g,noUpdateTTL:w,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:z,ignoreFetchAbort:D,status:y,signal:k},R=i(this,_).get(t);if(R===void 0){y&&(y.fetch="miss");let O=d(this,h,ke).call(this,t,R,L,F);return O.__returned=O}else {let O=i(this,f)[R];if(d(this,h,A).call(this,O)){let me=n&&O.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",me&&(y.returnedStale=true)),me?O.__staleWhileFetching:O.__returned=O}let Ae=i(this,Y).call(this,R);if(!T&&!Ae)return y&&(y.fetch="hit"),d(this,h,Se).call(this,R),s&&i(this,ue).call(this,R),y&&i(this,ie).call(this,y,R),O;let ce=d(this,h,ke).call(this,t,R,L,F),pe=ce.__staleWhileFetching!==void 0&&n;return y&&(y.fetch=Ae?"stale":"refresh",pe&&Ae&&(y.returnedStale=true)),pe?ce.__staleWhileFetching:ce.__returned=ce}}async forceFetch(t,e={}){let n=await this.fetch(t,e);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,e={}){let n=i(this,ge);if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:r,...a}=e,l=this.get(t,a);if(!r&&l!==void 0)return l;let u=n(t,l,{options:a,context:s});return this.set(t,u,a),u}get(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:a}=e,l=i(this,_).get(t);if(l!==void 0){let u=i(this,f)[l],g=d(this,h,A).call(this,u);return a&&i(this,ie).call(this,a,l),i(this,Y).call(this,l)?(a&&(a.get="stale"),g?(a&&n&&u.__staleWhileFetching!==void 0&&(a.returnedStale=true),n?u.__staleWhileFetching:void 0):(r||d(this,h,oe).call(this,t,"expire"),a&&n&&(a.returnedStale=true),n?u:void 0)):(a&&(a.get="hit"),g?u.__staleWhileFetching:(d(this,h,Se).call(this,l),s&&i(this,ue).call(this,l),u))}else a&&(a.get="miss");}delete(t){return d(this,h,oe).call(this,t,"delete")}clear(){return d(this,h,Ye).call(this,"delete")}},j=new WeakMap,q=new WeakMap,K=new WeakMap,he=new WeakMap,$=new WeakMap,ye=new WeakMap,ge=new WeakMap,H=new WeakMap,E=new WeakMap,X=new WeakMap,_=new WeakMap,S=new WeakMap,f=new WeakMap,N=new WeakMap,U=new WeakMap,I=new WeakMap,P=new WeakMap,Q=new WeakMap,x=new WeakMap,Z=new WeakMap,J=new WeakMap,W=new WeakMap,V=new WeakMap,ee=new WeakMap,le=new WeakMap,G=new WeakMap,ve=new WeakMap,h=new WeakSet,Ue=function(){let t=new Ie(i(this,j)),e=new Ie(i(this,j));c(this,W,t),c(this,J,e);let n=this.ttlAutopurge?new Array(i(this,j)):void 0;c(this,V,n),c(this,Fe,(l,u,g=i(this,H).now())=>{e[l]=u!==0?g:0,t[l]=u,s(l,u);}),c(this,ue,l=>{e[l]=t[l]!==0?i(this,H).now():0,s(l,t[l]);});let s=this.ttlAutopurge?(l,u)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),u&&u!==0&&n){let g=setTimeout(()=>{i(this,Y).call(this,l)&&d(this,h,oe).call(this,i(this,S)[l],"expire");},u+1);g.unref&&g.unref(),n[l]=g;}}:()=>{};c(this,ie,(l,u)=>{if(t[u]){let g=t[u],w=e[u];if(!g||!w)return;l.ttl=g,l.start=w,l.now=r||a();let b=l.now-w;l.remainingTTL=g-b;}});let r=0,a=()=>{let l=i(this,H).now();if(this.ttlResolution>0){r=l;let u=setTimeout(()=>r=0,this.ttlResolution);u.unref&&u.unref();}return l};this.getRemainingTTL=l=>{let u=i(this,_).get(l);if(u===void 0)return 0;let g=t[u],w=e[u];if(!g||!w)return 1/0;let b=(r||a())-w;return g-b},c(this,Y,l=>{let u=e[l],g=t[l];return !!g&&!!u&&(r||a())-u>g});},ue=new WeakMap,ie=new WeakMap,Fe=new WeakMap,Y=new WeakMap,Pt=function(){let t=new Ie(i(this,j));c(this,X,0),c(this,Z,t),c(this,de,e=>{c(this,X,i(this,X)-t[e]),t[e]=0;}),c(this,Oe,(e,n,s,r)=>{if(d(this,h,A).call(this,n))return 0;if(!se(s))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(s=r(n,e),!se(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s}),c(this,be,(e,n,s)=>{if(t[e]=n,i(this,q)){let r=i(this,q)-t[e];for(;i(this,X)>r;)d(this,h,Me).call(this,true);}c(this,X,i(this,X)+t[e]),s&&(s.entrySize=n,s.totalCalculatedSize=i(this,X));});},de=new WeakMap,be=new WeakMap,Oe=new WeakMap,ae=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,P);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,I)));)e=i(this,U)[e];},re=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,I);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,P)));)e=i(this,N)[e];},We=function(t){return t!==void 0&&i(this,_).get(i(this,S)[t])===t},Me=function(t){var r;let e=i(this,I),n=i(this,S)[e],s=i(this,f)[e];return i(this,le)&&d(this,h,A).call(this,s)?s.__abortController.abort(new Error("evicted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((r=i(this,K))==null||r.call(this,s,n,"evict")),i(this,G)&&i(this,x)?.push([s,n,"evict"])),i(this,de).call(this,e),i(this,V)?.[e]&&(clearTimeout(i(this,V)[e]),i(this,V)[e]=void 0),t&&(i(this,S)[e]=void 0,i(this,f)[e]=void 0,i(this,Q).push(e)),i(this,E)===1?(c(this,I,c(this,P,0)),i(this,Q).length=0):c(this,I,i(this,N)[e]),i(this,_).delete(n),De(this,E)._--,e},ke=function(t,e,n,s){let r=e===void 0?void 0:i(this,f)[e];if(d(this,h,A).call(this,r))return r;let a=new Re,{signal:l}=n;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let u={signal:a.signal,options:n,context:s},g=(F,T=false)=>{let{aborted:y}=a.signal,k=n.ignoreFetchAbort&&F!==void 0,L=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&F!==void 0);if(n.status&&(y&&!T?(n.status.fetchAborted=true,n.status.fetchError=a.signal.reason,k&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),y&&!k&&!T)return b(a.signal.reason,L);let R=D,O=i(this,f)[e];return (O===D||k&&T&&O===void 0)&&(F===void 0?R.__staleWhileFetching!==void 0?i(this,f)[e]=R.__staleWhileFetching:d(this,h,oe).call(this,t,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(t,F,u.options))),F},w=F=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=F),b(F,false)),b=(F,T)=>{let{aborted:y}=a.signal,k=y&&n.allowStaleOnFetchAbort,L=k||n.allowStaleOnFetchRejection,R=L||n.noDeleteOnFetchRejection,O=D;if(i(this,f)[e]===D&&(!R||!T&&O.__staleWhileFetching===void 0?d(this,h,oe).call(this,t,"fetch"):k||(i(this,f)[e]=O.__staleWhileFetching)),L)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw F},M=(F,T)=>{var k;let y=(k=i(this,ye))==null?void 0:k.call(this,t,r,u);y&&y instanceof Promise&&y.then(L=>F(L===void 0?void 0:L),T),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(F(void 0),n.allowStaleOnFetchAbort&&(F=L=>g(L,true)));});};n.status&&(n.status.fetchDispatched=true);let D=new Promise(M).then(g,w),z=Object.assign(D,{__abortController:a,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,z,{...u.options,status:void 0}),e=i(this,_).get(t)):i(this,f)[e]=z,z},A=function(t){if(!i(this,le))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Re},Ve=function(t,e){i(this,U)[e]=t,i(this,N)[t]=e;},Se=function(t){t!==i(this,P)&&(t===i(this,I)?c(this,I,i(this,N)[t]):d(this,h,Ve).call(this,i(this,U)[t],i(this,N)[t]),d(this,h,Ve).call(this,i(this,P),t),c(this,P,t));},oe=function(t,e){var s,r;let n=false;if(i(this,E)!==0){let a=i(this,_).get(t);if(a!==void 0)if(i(this,V)?.[a]&&(clearTimeout(i(this,V)?.[a]),i(this,V)[a]=void 0),n=true,i(this,E)===1)d(this,h,Ye).call(this,e);else {i(this,de).call(this,a);let l=i(this,f)[a];if(d(this,h,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((s=i(this,K))==null||s.call(this,l,t,e)),i(this,G)&&i(this,x)?.push([l,t,e])),i(this,_).delete(t),i(this,S)[a]=void 0,i(this,f)[a]=void 0,a===i(this,P))c(this,P,i(this,U)[a]);else if(a===i(this,I))c(this,I,i(this,N)[a]);else {let u=i(this,U)[a];i(this,N)[u]=i(this,N)[a];let g=i(this,N)[a];i(this,U)[g]=i(this,U)[a];}De(this,E)._--,i(this,Q).push(a);}}if(i(this,G)&&i(this,x)?.length){let a=i(this,x),l;for(;l=a?.shift();)(r=i(this,$))==null||r.call(this,...l);}return n},Ye=function(t){var e,n;for(let s of d(this,h,re).call(this,{allowStale:true})){let r=i(this,f)[s];if(d(this,h,A).call(this,r))r.__abortController.abort(new Error("deleted"));else {let a=i(this,S)[s];i(this,ee)&&((e=i(this,K))==null||e.call(this,r,a,t)),i(this,G)&&i(this,x)?.push([r,a,t]);}}if(i(this,_).clear(),i(this,f).fill(void 0),i(this,S).fill(void 0),i(this,W)&&i(this,J)){i(this,W).fill(0),i(this,J).fill(0);for(let s of i(this,V)??[])s!==void 0&&clearTimeout(s);i(this,V)?.fill(void 0);}if(i(this,Z)&&i(this,Z).fill(0),c(this,I,0),c(this,P,0),i(this,Q).length=0,c(this,X,0),c(this,E,0),i(this,G)&&i(this,x)){let s=i(this,x),r;for(;r=s?.shift();)(n=i(this,$))==null||n.call(this,...r);}},we);var _e=class{constructor(t){m(this,"cache");m(this,"map",new Map);this.cache=new Et({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var xt;(r=>(r.mediaInstances=new Map,r.channels=new Map,r.transients=new Set,r.systemPausedAliases=new Set,r.bufferRegistry=new _e({cacheSize:10})))(xt||={});var p=xt;var C;(s=>(s.log=(r,...a)=>console.log(`[Pixi\u2019VN] ${r}`,...a),s.warn=(r,...a)=>console.warn(`[Pixi\u2019VN] ${r}`,...a),s.error=(r,...a)=>console.error(`[Pixi\u2019VN] ${r}`,...a),s.info=(r,...a)=>console.info(`[Pixi\u2019VN] ${r}`,...a)))(C||={});function Ne(o){return o.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new B.Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new B.FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new B.BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new B.Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new B.Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new B.Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new B.FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new B.Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new B.Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new B.GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new B.GreaterThanZero);break;case "LimiterFilter":t.push(new B.Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new B.MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new B.MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new B.Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new B.Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new B.StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new B.PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new B.AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new B.BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new B.OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new B.Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new B.Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new B.Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new B.Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new B.AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function It(o){if(o)return Array.from(o).reduce((t,e)=>(e instanceof B.Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:B.Time(e.decay).toSeconds(),preDelay:B.Time(e.preDelay).toSeconds()}):e instanceof B.PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof B.FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof B.BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof B.Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof B.Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof B.Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof B.FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof B.Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof B.Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof B.GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof B.GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof B.Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof B.MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof B.MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof B.Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof B.Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof B.StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof B.AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof B.Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof B.Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof B.Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof B.AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof B.BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof B.OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof B.Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):C.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function gt(o){return o instanceof B.Reverb||o instanceof B.FeedbackDelay||o instanceof B.PingPongDelay||o instanceof B.BitCrusher||o instanceof B.Compressor||o instanceof B.Delay||o instanceof B.Distortion||o instanceof B.FeedbackCombFilter||o instanceof B.Freeverb||o instanceof B.Gate||o instanceof B.GreaterThan||o instanceof B.GreaterThanZero||o instanceof B.Limiter||o instanceof B.MidSideCompressor||o instanceof B.MultibandCompressor||o instanceof B.Panner3D||o instanceof B.Phaser||o instanceof B.StereoWidener||o instanceof B.AutoFilter||o instanceof B.Chorus||o instanceof B.Vibrato||o instanceof B.Tremolo||o instanceof B.AutoPanner||o instanceof B.BiquadFilter||o instanceof B.OnePoleFilter||o instanceof B.Filter}function ne(o){return o<=0?-1/0:20*Math.log10(o)}function Te(o){return o<=-1/0?0:10**(o/20)}async function Ge(o){if(p.bufferRegistry.has(o))return;let t=o;try{let e=kt__default.default.Assets.resolver.resolve(o);e?.src&&(t=e.src);}catch{}try{let e=await B.ToneAudioBuffer.load(t),n=new B.ToneAudioBuffer(e);p.bufferRegistry.set(o,n);}catch(e){C.warn(`Failed to load audio buffer for "${o}" (url: "${t}"): ${e instanceof Error?e.message:e}`),p.bufferRegistry.set(o,new B.ToneAudioBuffer);}}var Ee=class extends B.Player{constructor(e,n,s,r,a={},l){super(a);m(this,"alias",e);m(this,"channelAlias",n);m(this,"soundAlias",s);m(this,"stepCounter",r);m(this,"delay",l);m(this,"options");m(this,"filters",new Set);m(this,"pausedAt");m(this,"playStartTime",B.now());this.options=a,this.playStartTime=B.now()+(l??0);}get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:B.now()-this.playStartTime),n=this.paused;return n&&p.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:Te(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==ne(e.volume??1)&&(this.volume.value=ne(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=B.now(),n==="started"&&super.stop();else {let s;typeof this.pausedAt=="number"&&(s=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,s):this.start(void 0,s));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return p.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,s){let r=B.now(),a=r;if(typeof e=="number")a=e;else if(typeof e=="string"&&e.startsWith("+")){let u=Number(e.slice(1));Number.isNaN(u)||(a=r+u);}let l=typeof n=="number"?n:0;return this.playStartTime=a-l,super.start(e,n,s)}chain(...e){return e.forEach(n=>{gt(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return gt(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var Pe=class{constructor(t,e={}){m(this,"alias",t);m(this,"toneChannel");m(this,"background");this.background=e.background??false,this.toneChannel=new B.Channel({volume:ne(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return Te(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=ne(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let s=p.bufferRegistry.get(e);if(!s)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:r,elapsed:a,filters:l=[],muted:u,autostart:g=true,speed:w,volume:b,...M}=n;u!==void 0&&(C.warn(`MediaInstance "${t}" is being created with muted=${u}. This will override the channel's muted state (${this.muted}).`),M.mute=u),w!==void 0&&(C.warn(`MediaInstance "${t}" is being created with speed=${w}. This will override the default playback speed of 1.`),M.playbackRate=w);let D=new Ee(t,this.alias,e,core.GameUnifier.stepCounter,{...M,volume:b!==void 0?ne(b):void 0,url:s},r).chain(...l,this.toneChannel),z=a!==void 0?Math.max(0,a):void 0;return g&&(r?D.start(`+${r}`,z):D.start(void 0,z)),D}async play(t,e,n){let s,r;if(typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.mediaInstances.has(s)){let l=p.mediaInstances.get(s);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await Ge(r);let a=this._createPlayer(s,r,n);return p.mediaInstances.set(s,a),a}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(p.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of p.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{p.mediaInstances.delete(e);}),this}};function Mt(o){try{if(typeof o>"u")return o;let t=JSON.stringify(o);return JSON.parse(t)}catch(t){throw C.error("Error creating exportable element",o,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var xe=class{constructor(){m(this,"_speedAll",1);m(this,"_defaultChannelAlias",Tt);}get volumeAll(){return Te(B__namespace.getDestination().volume.value)}set volumeAll(t){B__namespace.getDestination().volume.value=ne(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of p.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!p.bufferRegistry.has(t)){let n=new B__namespace.ToneAudioBuffer(e);p.bufferRegistry.set(t,n);}}pauseAll(){for(let t of p.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return B__namespace.getDestination().mute}toggleMuteAll(){let t=!B__namespace.getDestination().mute;return B__namespace.getDestination().mute=t,t}muteAll(){return B__namespace.getDestination().mute=true,this}unmuteAll(){return B__namespace.getDestination().mute=false,this}stopAll(){for(let t of p.mediaInstances.values())t.stop();return p.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of p.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,p.systemPausedAliases.add(e));if(!t){for(let e of p.transients)e.stop();p.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of p.systemPausedAliases){let s=p.mediaInstances.get(n);if(!s){e.push(n);continue}t&&s.channelAlias!==t||(s.paused=false,e.push(n));}for(let n of e)p.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of p.transients)t.stop();return p.transients.clear(),this}async play(t,e,n){let s,r;typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.bufferRegistry.has(r)||await this.load(r);let{channel:a=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(a).play(s,r,l)}async playTransient(t,e){p.bufferRegistry.has(t)||await this.load(t);let n=p.bufferRegistry.get(t);if(!n)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:s=true,...r}=e??{},a=new B__namespace.Player({...r,url:n}).toDestination();return s&&a.start(),p.transients.add(a),a.onstop=()=>{a.dispose(),p.transients.delete(a);},a}find(t){return p.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),p.mediaInstances.delete(t)):C.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){C.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){C.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return p.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(Ge);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{C.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=kt__default.default.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await kt__default.default.Assets.loadBundle(t),s=[];for(let r in n)p.bufferRegistry.has(r)||s.push(this.load(r));await Promise.all(s);}catch(n){C.error("Error loading sound bundle",n);}}).catch(n=>{C.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(s=>{let r={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(s,r);});return}if(p.channels.has(t)){C.warn(`Channel with alias ${t} already exists.`);return}let n=new Pe(t,e);return p.channels.set(t,n),n}findChannel(t){let e=p.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(p.channels.values())}export(){let t=Array.from(p.mediaInstances.entries()).reduce((e,[n,s])=>(e[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,paused:s.paused,options:{...s.memory,filters:It(s.filters)}},e),{});return {mediaInstances:Mt(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async s=>{await this.load(s),await this.play(s);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,s=Object.values(e).map(async({soundAlias:a,channelAlias:l})=>(n.add(l),await this.load(a)));await Promise.all(s),this.channels.forEach(a=>{(!a.background||!n.has(a.alias))&&a.stopAll();});let r=Object.keys(e).map(async a=>{let l=e[a],u=this.findChannel(l.channelAlias),g=l.options.paused??l.paused??!1;if(u.background)if(l.stepCounter===core.GameUnifier.stepCounter||!this.find(a)){let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Ne(l.options.filters||[]),delay:l.options.delay});w.paused=g;}else {let w=p.mediaInstances.get(a);if(!w){C.warn(`No media instance found with alias ${a} while restoring background state.`);return}w.memory={...l.options,paused:g},[...w.filters].forEach(M=>{w.disconnect(M),M.dispose();}),w.chain(...Ne(l.options.filters||[]));}else {let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Ne(l.options.filters||[]),delay:l.options.delay});w.paused=g;}});await Promise.all(r);}}}catch(e){C.error("Error importing data",e);}}};var bt=new xe;core.GameUnifier.addOnPreContinue(async()=>{try{p.channels.forEach(o=>{o.background||o.stopAll();});}catch{}});if(typeof document<"u"){let o=false;document.addEventListener("visibilitychange",()=>{document.hidden?bt.muted||(bt.muteAll(),o=true):o&&(bt.unmuteAll(),o=false);});}exports.SoundRegistry=p;exports.sound=bt;
|
|
1
|
+
'use strict';var core=require('./core.cjs'),kt=require('./pixi/index.js'),B=require('tone');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var kt__default=/*#__PURE__*/_interopDefault(kt);var B__namespace=/*#__PURE__*/_interopNamespace(B);var Rt=Object.defineProperty;var wt=o=>{throw TypeError(o)};var Nt=(o,t,e)=>t in o?Rt(o,t,{enumerable:true,configurable:true,writable:true,value:e}):o[t]=e;var x=(o,t,e)=>Nt(o,typeof t!="symbol"?t+"":t,e),ze=(o,t,e)=>t.has(o)||wt("Cannot "+e);var i=(o,t,e)=>(ze(o,t,"read from private field"),e?e.call(o):t.get(o)),g=(o,t,e)=>t.has(o)?wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),c=(o,t,e,n)=>(ze(o,t,"write to private field"),t.set(o,e),e),d=(o,t,e)=>(ze(o,t,"access private method"),e);var De=(o,t,e,n)=>({set _(s){c(o,t,s);},get _(){return i(o,t,n)}});var Tt="general";var Gt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ot=new Set,qe=typeof process=="object"&&process?process:{},_t=(o,t,e,n)=>{typeof qe.emitWarning=="function"?qe.emitWarning(o,t,e,n):console.error(`[${e}] ${t}: ${o}`);},Re=globalThis.AbortController,At=globalThis.AbortSignal;if(typeof Re>"u"){At=class{onabort;_onabort=[];reason;aborted=false;addEventListener(e,n){this._onabort.push(n);}},Re=class{constructor(){t();}signal=new At;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let n of this.signal._onabort)n(e);this.signal.onabort?.(e);}}};let o=qe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{o&&(o=false,_t("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var Lt=o=>!Ot.has(o);var se=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),Ct=o=>se(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Ie:null:null,Ie=class extends Array{constructor(o){super(o),this.fill(0);}},te,fe,zt=(te=class{heap;length;static create(t){let e=Ct(t);if(!e)return [];c(te,fe,true);let n=new te(t,e);return c(te,fe,false),n}constructor(t,e){if(!i(te,fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},fe=new WeakMap,g(te,fe,false),te),St,Ft,j,q,K,he,$,ye,ge,H,C,X,O,A,m,N,U,I,E,Q,P,Z,J,W,V,ee,le,G,ve,h,Ue,ue,ie,Fe,Y,Pt,de,be,Oe,ae,re,We,Me,ke,T,Ve,Se,oe,Ye,we,Et=(we=class{constructor(t){g(this,h);g(this,j);g(this,q);g(this,K);g(this,he);g(this,$);g(this,ye);g(this,ge);g(this,H);x(this,"ttl");x(this,"ttlResolution");x(this,"ttlAutopurge");x(this,"updateAgeOnGet");x(this,"updateAgeOnHas");x(this,"allowStale");x(this,"noDisposeOnSet");x(this,"noUpdateTTL");x(this,"maxEntrySize");x(this,"sizeCalculation");x(this,"noDeleteOnFetchRejection");x(this,"noDeleteOnStaleGet");x(this,"allowStaleOnFetchAbort");x(this,"allowStaleOnFetchRejection");x(this,"ignoreFetchAbort");g(this,C);g(this,X);g(this,O);g(this,A);g(this,m);g(this,N);g(this,U);g(this,I);g(this,E);g(this,Q);g(this,P);g(this,Z);g(this,J);g(this,W);g(this,V);g(this,ee);g(this,le);g(this,G);g(this,ve);g(this,ue,()=>{});g(this,ie,()=>{});g(this,Fe,()=>{});g(this,Y,()=>false);g(this,de,t=>{});g(this,be,(t,e,n)=>{});g(this,Oe,(t,e,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});x(this,St,"LRUCache");let{max:e=0,ttl:n,ttlResolution:s=1,ttlAutopurge:r,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:u,dispose:y,onInsert:b,disposeAfter:v,noDisposeOnSet:M,noUpdateTTL:D,maxSize:z=0,maxEntrySize:S=0,sizeCalculation:w,fetchMethod:f,memoMethod:k,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:Ae,ignoreFetchAbort:ce,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,H,pe??Gt),e!==0&&!se(e))throw new TypeError("max option must be a nonnegative integer");let me=e?Ct(e):Array;if(!me)throw new Error("invalid max value: "+e);if(c(this,j,e),c(this,q,z),this.maxEntrySize=S||i(this,q),this.sizeCalculation=w,this.sizeCalculation){if(!i(this,q)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(c(this,ge,k),f!==void 0&&typeof f!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,ye,f),c(this,le,!!f),c(this,O,new Map),c(this,A,new Array(e).fill(void 0)),c(this,m,new Array(e).fill(void 0)),c(this,N,new me(e)),c(this,U,new me(e)),c(this,I,0),c(this,E,0),c(this,Q,zt.create(e)),c(this,C,0),c(this,X,0),typeof y=="function"&&c(this,K,y),typeof b=="function"&&c(this,he,b),typeof v=="function"?(c(this,$,v),c(this,P,[])):(c(this,$,void 0),c(this,P,void 0)),c(this,ee,!!i(this,K)),c(this,ve,!!i(this,he)),c(this,G,!!i(this,$)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!Ae,this.ignoreFetchAbort=!!ce,this.maxEntrySize!==0){if(i(this,q)!==0&&!se(i(this,q)))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,h,Pt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=se(s)||s===0?s:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,h,Ue).call(this);}if(i(this,j)===0&&this.ttl===0&&i(this,q)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,j)&&!i(this,q)){let Le="LRU_CACHE_UNBOUNDED";Lt(Le)&&(Ot.add(Le),_t("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,we));}}get perf(){return i(this,H)}static unsafeExposeInternals(t){return {starts:i(t,J),ttls:i(t,W),autopurgeTimers:i(t,V),sizes:i(t,Z),keyMap:i(t,O),keyList:i(t,A),valList:i(t,m),next:i(t,N),prev:i(t,U),get head(){return i(t,I)},get tail(){return i(t,E)},free:i(t,Q),isBackgroundFetch:e=>{var n;return d(n=t,h,T).call(n,e)},backgroundFetch:(e,n,s,r)=>{var a;return d(a=t,h,ke).call(a,e,n,s,r)},moveToTail:e=>{var n;return d(n=t,h,Se).call(n,e)},indexes:e=>{var n;return d(n=t,h,ae).call(n,e)},rindexes:e=>{var n;return d(n=t,h,re).call(n,e)},isStale:e=>{var n;return i(n=t,Y).call(n,e)}}}get max(){return i(this,j)}get maxSize(){return i(this,q)}get calculatedSize(){return i(this,X)}get size(){return i(this,C)}get fetchMethod(){return i(this,ye)}get memoMethod(){return i(this,ge)}get dispose(){return i(this,K)}get onInsert(){return i(this,he)}get disposeAfter(){return i(this,$)}getRemainingTTL(t){return i(this,O).has(t)?1/0:0}*entries(){for(let t of d(this,h,ae).call(this))i(this,m)[t]!==void 0&&i(this,A)[t]!==void 0&&!d(this,h,T).call(this,i(this,m)[t])&&(yield [i(this,A)[t],i(this,m)[t]]);}*rentries(){for(let t of d(this,h,re).call(this))i(this,m)[t]!==void 0&&i(this,A)[t]!==void 0&&!d(this,h,T).call(this,i(this,m)[t])&&(yield [i(this,A)[t],i(this,m)[t]]);}*keys(){for(let t of d(this,h,ae).call(this)){let e=i(this,A)[t];e!==void 0&&!d(this,h,T).call(this,i(this,m)[t])&&(yield e);}}*rkeys(){for(let t of d(this,h,re).call(this)){let e=i(this,A)[t];e!==void 0&&!d(this,h,T).call(this,i(this,m)[t])&&(yield e);}}*values(){for(let t of d(this,h,ae).call(this))i(this,m)[t]!==void 0&&!d(this,h,T).call(this,i(this,m)[t])&&(yield i(this,m)[t]);}*rvalues(){for(let t of d(this,h,re).call(this))i(this,m)[t]!==void 0&&!d(this,h,T).call(this,i(this,m)[t])&&(yield i(this,m)[t]);}[(Ft=Symbol.iterator,St=Symbol.toStringTag,Ft)](){return this.entries()}find(t,e={}){for(let n of d(this,h,ae).call(this)){let s=i(this,m)[n],r=d(this,h,T).call(this,s)?s.__staleWhileFetching:s;if(r!==void 0&&t(r,i(this,A)[n],this))return this.get(i(this,A)[n],e)}}forEach(t,e=this){for(let n of d(this,h,ae).call(this)){let s=i(this,m)[n],r=d(this,h,T).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,A)[n],this);}}rforEach(t,e=this){for(let n of d(this,h,re).call(this)){let s=i(this,m)[n],r=d(this,h,T).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,A)[n],this);}}purgeStale(){let t=false;for(let e of d(this,h,re).call(this,{allowStale:true}))i(this,Y).call(this,e)&&(d(this,h,oe).call(this,i(this,A)[e],"expire"),t=true);return t}info(t){let e=i(this,O).get(t);if(e===void 0)return;let n=i(this,m)[e],s=d(this,h,T).call(this,n)?n.__staleWhileFetching:n;if(s===void 0)return;let r={value:s};if(i(this,W)&&i(this,J)){let a=i(this,W)[e],l=i(this,J)[e];if(a&&l){let u=a-(i(this,H).now()-l);r.ttl=u,r.start=Date.now();}}return i(this,Z)&&(r.size=i(this,Z)[e]),r}dump(){let t=[];for(let e of d(this,h,ae).call(this,{allowStale:true})){let n=i(this,A)[e],s=i(this,m)[e],r=d(this,h,T).call(this,s)?s.__staleWhileFetching:s;if(r===void 0||n===void 0)continue;let a={value:r};if(i(this,W)&&i(this,J)){a.ttl=i(this,W)[e];let l=i(this,H).now()-i(this,J)[e];a.start=Math.floor(Date.now()-l);}i(this,Z)&&(a.size=i(this,Z)[e]),t.unshift([n,a]);}return t}load(t){this.clear();for(let[e,n]of t){if(n.start){let s=Date.now()-n.start;n.start=i(this,H).now()-s;}this.set(e,n.value,n);}}set(t,e,n={}){var M,D,z,S;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:r,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n,{noUpdateTTL:y=this.noUpdateTTL}=n,b=i(this,Oe).call(this,t,e,n.size||0,l);if(this.maxEntrySize&&b>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),d(this,h,oe).call(this,t,"set"),this;let v=i(this,C)===0?void 0:i(this,O).get(t);if(v===void 0)v=i(this,C)===0?i(this,E):i(this,Q).length!==0?i(this,Q).pop():i(this,C)===i(this,j)?d(this,h,Me).call(this,false):i(this,C),i(this,A)[v]=t,i(this,m)[v]=e,i(this,O).set(t,v),i(this,N)[i(this,E)]=v,i(this,U)[v]=i(this,E),c(this,E,v),De(this,C)._++,i(this,be).call(this,v,b,u),u&&(u.set="add"),y=false,i(this,ve)&&((M=i(this,he))==null||M.call(this,e,t,"add"));else {d(this,h,Se).call(this,v);let w=i(this,m)[v];if(e!==w){if(i(this,le)&&d(this,h,T).call(this,w)){w.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=w;f!==void 0&&!a&&(i(this,ee)&&((D=i(this,K))==null||D.call(this,f,t,"set")),i(this,G)&&i(this,P)?.push([f,t,"set"]));}else a||(i(this,ee)&&((z=i(this,K))==null||z.call(this,w,t,"set")),i(this,G)&&i(this,P)?.push([w,t,"set"]));if(i(this,de).call(this,v),i(this,be).call(this,v,b,u),i(this,m)[v]=e,u){u.set="replace";let f=w&&d(this,h,T).call(this,w)?w.__staleWhileFetching:w;f!==void 0&&(u.oldValue=f);}}else u&&(u.set="update");i(this,ve)&&this.onInsert?.(e,t,e===w?"update":"replace");}if(s!==0&&!i(this,W)&&d(this,h,Ue).call(this),i(this,W)&&(y||i(this,Fe).call(this,v,s,r),u&&i(this,ie).call(this,u,v)),!a&&i(this,G)&&i(this,P)){let w=i(this,P),f;for(;f=w?.shift();)(S=i(this,$))==null||S.call(this,...f);}return this}pop(){var t;try{for(;i(this,C);){let e=i(this,m)[i(this,I)];if(d(this,h,Me).call(this,!0),d(this,h,T).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,G)&&i(this,P)){let e=i(this,P),n;for(;n=e?.shift();)(t=i(this,$))==null||t.call(this,...n);}}}has(t,e={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=e,r=i(this,O).get(t);if(r!==void 0){let a=i(this,m)[r];if(d(this,h,T).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(i(this,Y).call(this,r))s&&(s.has="stale",i(this,ie).call(this,s,r));else return n&&i(this,ue).call(this,r),s&&(s.has="hit",i(this,ie).call(this,s,r)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:n=this.allowStale}=e,s=i(this,O).get(t);if(s===void 0||!n&&i(this,Y).call(this,s))return;let r=i(this,m)[s];return d(this,h,T).call(this,r)?r.__staleWhileFetching:r}async fetch(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:b=this.noUpdateTTL,noDeleteOnFetchRejection:v=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:z=this.allowStaleOnFetchAbort,context:S,forceRefresh:w=false,status:f,signal:k}=e;if(!i(this,le))return f&&(f.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,status:f});let L={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,ttl:a,noDisposeOnSet:l,size:u,sizeCalculation:y,noUpdateTTL:b,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:z,ignoreFetchAbort:D,status:f,signal:k},R=i(this,O).get(t);if(R===void 0){f&&(f.fetch="miss");let F=d(this,h,ke).call(this,t,R,L,S);return F.__returned=F}else {let F=i(this,m)[R];if(d(this,h,T).call(this,F)){let me=n&&F.__staleWhileFetching!==void 0;return f&&(f.fetch="inflight",me&&(f.returnedStale=true)),me?F.__staleWhileFetching:F.__returned=F}let Ae=i(this,Y).call(this,R);if(!w&&!Ae)return f&&(f.fetch="hit"),d(this,h,Se).call(this,R),s&&i(this,ue).call(this,R),f&&i(this,ie).call(this,f,R),F;let ce=d(this,h,ke).call(this,t,R,L,S),pe=ce.__staleWhileFetching!==void 0&&n;return f&&(f.fetch=Ae?"stale":"refresh",pe&&Ae&&(f.returnedStale=true)),pe?ce.__staleWhileFetching:ce.__returned=ce}}async forceFetch(t,e={}){let n=await this.fetch(t,e);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,e={}){let n=i(this,ge);if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:r,...a}=e,l=this.get(t,a);if(!r&&l!==void 0)return l;let u=n(t,l,{options:a,context:s});return this.set(t,u,a),u}get(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:a}=e,l=i(this,O).get(t);if(l!==void 0){let u=i(this,m)[l],y=d(this,h,T).call(this,u);return a&&i(this,ie).call(this,a,l),i(this,Y).call(this,l)?(a&&(a.get="stale"),y?(a&&n&&u.__staleWhileFetching!==void 0&&(a.returnedStale=true),n?u.__staleWhileFetching:void 0):(r||d(this,h,oe).call(this,t,"expire"),a&&n&&(a.returnedStale=true),n?u:void 0)):(a&&(a.get="hit"),y?u.__staleWhileFetching:(d(this,h,Se).call(this,l),s&&i(this,ue).call(this,l),u))}else a&&(a.get="miss");}delete(t){return d(this,h,oe).call(this,t,"delete")}clear(){return d(this,h,Ye).call(this,"delete")}},j=new WeakMap,q=new WeakMap,K=new WeakMap,he=new WeakMap,$=new WeakMap,ye=new WeakMap,ge=new WeakMap,H=new WeakMap,C=new WeakMap,X=new WeakMap,O=new WeakMap,A=new WeakMap,m=new WeakMap,N=new WeakMap,U=new WeakMap,I=new WeakMap,E=new WeakMap,Q=new WeakMap,P=new WeakMap,Z=new WeakMap,J=new WeakMap,W=new WeakMap,V=new WeakMap,ee=new WeakMap,le=new WeakMap,G=new WeakMap,ve=new WeakMap,h=new WeakSet,Ue=function(){let t=new Ie(i(this,j)),e=new Ie(i(this,j));c(this,W,t),c(this,J,e);let n=this.ttlAutopurge?new Array(i(this,j)):void 0;c(this,V,n),c(this,Fe,(l,u,y=i(this,H).now())=>{e[l]=u!==0?y:0,t[l]=u,s(l,u);}),c(this,ue,l=>{e[l]=t[l]!==0?i(this,H).now():0,s(l,t[l]);});let s=this.ttlAutopurge?(l,u)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),u&&u!==0&&n){let y=setTimeout(()=>{i(this,Y).call(this,l)&&d(this,h,oe).call(this,i(this,A)[l],"expire");},u+1);y.unref&&y.unref(),n[l]=y;}}:()=>{};c(this,ie,(l,u)=>{if(t[u]){let y=t[u],b=e[u];if(!y||!b)return;l.ttl=y,l.start=b,l.now=r||a();let v=l.now-b;l.remainingTTL=y-v;}});let r=0,a=()=>{let l=i(this,H).now();if(this.ttlResolution>0){r=l;let u=setTimeout(()=>r=0,this.ttlResolution);u.unref&&u.unref();}return l};this.getRemainingTTL=l=>{let u=i(this,O).get(l);if(u===void 0)return 0;let y=t[u],b=e[u];if(!y||!b)return 1/0;let v=(r||a())-b;return y-v},c(this,Y,l=>{let u=e[l],y=t[l];return !!y&&!!u&&(r||a())-u>y});},ue=new WeakMap,ie=new WeakMap,Fe=new WeakMap,Y=new WeakMap,Pt=function(){let t=new Ie(i(this,j));c(this,X,0),c(this,Z,t),c(this,de,e=>{c(this,X,i(this,X)-t[e]),t[e]=0;}),c(this,Oe,(e,n,s,r)=>{if(d(this,h,T).call(this,n))return 0;if(!se(s))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(s=r(n,e),!se(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s}),c(this,be,(e,n,s)=>{if(t[e]=n,i(this,q)){let r=i(this,q)-t[e];for(;i(this,X)>r;)d(this,h,Me).call(this,true);}c(this,X,i(this,X)+t[e]),s&&(s.entrySize=n,s.totalCalculatedSize=i(this,X));});},de=new WeakMap,be=new WeakMap,Oe=new WeakMap,ae=function*({allowStale:t=this.allowStale}={}){if(i(this,C))for(let e=i(this,E);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,I)));)e=i(this,U)[e];},re=function*({allowStale:t=this.allowStale}={}){if(i(this,C))for(let e=i(this,I);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,E)));)e=i(this,N)[e];},We=function(t){return t!==void 0&&i(this,O).get(i(this,A)[t])===t},Me=function(t){var r;let e=i(this,I),n=i(this,A)[e],s=i(this,m)[e];return i(this,le)&&d(this,h,T).call(this,s)?s.__abortController.abort(new Error("evicted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((r=i(this,K))==null||r.call(this,s,n,"evict")),i(this,G)&&i(this,P)?.push([s,n,"evict"])),i(this,de).call(this,e),i(this,V)?.[e]&&(clearTimeout(i(this,V)[e]),i(this,V)[e]=void 0),t&&(i(this,A)[e]=void 0,i(this,m)[e]=void 0,i(this,Q).push(e)),i(this,C)===1?(c(this,I,c(this,E,0)),i(this,Q).length=0):c(this,I,i(this,N)[e]),i(this,O).delete(n),De(this,C)._--,e},ke=function(t,e,n,s){let r=e===void 0?void 0:i(this,m)[e];if(d(this,h,T).call(this,r))return r;let a=new Re,{signal:l}=n;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let u={signal:a.signal,options:n,context:s},y=(S,w=false)=>{let{aborted:f}=a.signal,k=n.ignoreFetchAbort&&S!==void 0,L=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&S!==void 0);if(n.status&&(f&&!w?(n.status.fetchAborted=true,n.status.fetchError=a.signal.reason,k&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),f&&!k&&!w)return v(a.signal.reason,L);let R=D,F=i(this,m)[e];return (F===D||k&&w&&F===void 0)&&(S===void 0?R.__staleWhileFetching!==void 0?i(this,m)[e]=R.__staleWhileFetching:d(this,h,oe).call(this,t,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(t,S,u.options))),S},b=S=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=S),v(S,false)),v=(S,w)=>{let{aborted:f}=a.signal,k=f&&n.allowStaleOnFetchAbort,L=k||n.allowStaleOnFetchRejection,R=L||n.noDeleteOnFetchRejection,F=D;if(i(this,m)[e]===D&&(!R||!w&&F.__staleWhileFetching===void 0?d(this,h,oe).call(this,t,"fetch"):k||(i(this,m)[e]=F.__staleWhileFetching)),L)return n.status&&F.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),F.__staleWhileFetching;if(F.__returned===F)throw S},M=(S,w)=>{var k;let f=(k=i(this,ye))==null?void 0:k.call(this,t,r,u);f&&f instanceof Promise&&f.then(L=>S(L===void 0?void 0:L),w),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(S(void 0),n.allowStaleOnFetchAbort&&(S=L=>y(L,true)));});};n.status&&(n.status.fetchDispatched=true);let D=new Promise(M).then(y,b),z=Object.assign(D,{__abortController:a,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,z,{...u.options,status:void 0}),e=i(this,O).get(t)):i(this,m)[e]=z,z},T=function(t){if(!i(this,le))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Re},Ve=function(t,e){i(this,U)[e]=t,i(this,N)[t]=e;},Se=function(t){t!==i(this,E)&&(t===i(this,I)?c(this,I,i(this,N)[t]):d(this,h,Ve).call(this,i(this,U)[t],i(this,N)[t]),d(this,h,Ve).call(this,i(this,E),t),c(this,E,t));},oe=function(t,e){var s,r;let n=false;if(i(this,C)!==0){let a=i(this,O).get(t);if(a!==void 0)if(i(this,V)?.[a]&&(clearTimeout(i(this,V)?.[a]),i(this,V)[a]=void 0),n=true,i(this,C)===1)d(this,h,Ye).call(this,e);else {i(this,de).call(this,a);let l=i(this,m)[a];if(d(this,h,T).call(this,l)?l.__abortController.abort(new Error("deleted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((s=i(this,K))==null||s.call(this,l,t,e)),i(this,G)&&i(this,P)?.push([l,t,e])),i(this,O).delete(t),i(this,A)[a]=void 0,i(this,m)[a]=void 0,a===i(this,E))c(this,E,i(this,U)[a]);else if(a===i(this,I))c(this,I,i(this,N)[a]);else {let u=i(this,U)[a];i(this,N)[u]=i(this,N)[a];let y=i(this,N)[a];i(this,U)[y]=i(this,U)[a];}De(this,C)._--,i(this,Q).push(a);}}if(i(this,G)&&i(this,P)?.length){let a=i(this,P),l;for(;l=a?.shift();)(r=i(this,$))==null||r.call(this,...l);}return n},Ye=function(t){var e,n;for(let s of d(this,h,re).call(this,{allowStale:true})){let r=i(this,m)[s];if(d(this,h,T).call(this,r))r.__abortController.abort(new Error("deleted"));else {let a=i(this,A)[s];i(this,ee)&&((e=i(this,K))==null||e.call(this,r,a,t)),i(this,G)&&i(this,P)?.push([r,a,t]);}}if(i(this,O).clear(),i(this,m).fill(void 0),i(this,A).fill(void 0),i(this,W)&&i(this,J)){i(this,W).fill(0),i(this,J).fill(0);for(let s of i(this,V)??[])s!==void 0&&clearTimeout(s);i(this,V)?.fill(void 0);}if(i(this,Z)&&i(this,Z).fill(0),c(this,I,0),c(this,E,0),i(this,Q).length=0,c(this,X,0),c(this,C,0),i(this,G)&&i(this,P)){let s=i(this,P),r;for(;r=s?.shift();)(n=i(this,$))==null||n.call(this,...r);}},we);var _e=class{cache;map=new Map;constructor(t){this.cache=new Et({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var xt;(r=>(r.mediaInstances=new Map,r.channels=new Map,r.transients=new Set,r.systemPausedAliases=new Set,r.bufferRegistry=new _e({cacheSize:10})))(xt||={});var p=xt;var _;(s=>(s.log=(r,...a)=>console.log(`[Pixi\u2019VN] ${r}`,...a),s.warn=(r,...a)=>console.warn(`[Pixi\u2019VN] ${r}`,...a),s.error=(r,...a)=>console.error(`[Pixi\u2019VN] ${r}`,...a),s.info=(r,...a)=>console.info(`[Pixi\u2019VN] ${r}`,...a)))(_||={});function Ne(o){return o.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new B.Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new B.FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new B.BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new B.Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new B.Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new B.Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new B.FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new B.Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new B.Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new B.GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new B.GreaterThanZero);break;case "LimiterFilter":t.push(new B.Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new B.MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new B.MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new B.Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new B.Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new B.StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new B.PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new B.AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new B.BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new B.OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new B.Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new B.Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new B.Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new B.Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new B.AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function It(o){if(o)return Array.from(o).reduce((t,e)=>(e instanceof B.Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:B.Time(e.decay).toSeconds(),preDelay:B.Time(e.preDelay).toSeconds()}):e instanceof B.PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof B.FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof B.BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof B.Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof B.Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof B.Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof B.FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof B.Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof B.Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof B.GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof B.GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof B.Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof B.MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof B.MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof B.Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof B.Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof B.StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof B.AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof B.Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof B.Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof B.Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof B.AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof B.BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof B.OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof B.Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):_.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function gt(o){return o instanceof B.Reverb||o instanceof B.FeedbackDelay||o instanceof B.PingPongDelay||o instanceof B.BitCrusher||o instanceof B.Compressor||o instanceof B.Delay||o instanceof B.Distortion||o instanceof B.FeedbackCombFilter||o instanceof B.Freeverb||o instanceof B.Gate||o instanceof B.GreaterThan||o instanceof B.GreaterThanZero||o instanceof B.Limiter||o instanceof B.MidSideCompressor||o instanceof B.MultibandCompressor||o instanceof B.Panner3D||o instanceof B.Phaser||o instanceof B.StereoWidener||o instanceof B.AutoFilter||o instanceof B.Chorus||o instanceof B.Vibrato||o instanceof B.Tremolo||o instanceof B.AutoPanner||o instanceof B.BiquadFilter||o instanceof B.OnePoleFilter||o instanceof B.Filter}function ne(o){return o<=0?-1/0:20*Math.log10(o)}function Te(o){return o<=-1/0?0:10**(o/20)}async function Ge(o){if(p.bufferRegistry.has(o))return;let t=o;try{let e=kt__default.default.Assets.resolver.resolve(o);e?.src&&(t=e.src);}catch{}try{let e=await B.ToneAudioBuffer.load(t),n=new B.ToneAudioBuffer(e);p.bufferRegistry.set(o,n);}catch(e){_.warn(`Failed to load audio buffer for "${o}" (url: "${t}"): ${e instanceof Error?e.message:e}`),p.bufferRegistry.set(o,new B.ToneAudioBuffer);}}var Ee=class extends B.Player{constructor(e,n,s,r,a={},l){super(a);this.alias=e;this.channelAlias=n;this.soundAlias=s;this.stepCounter=r;this.delay=l;this.options=a,this.playStartTime=B.now()+(l??0);}alias;channelAlias;soundAlias;stepCounter;delay;options;filters=new Set;pausedAt=void 0;playStartTime=B.now();get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:B.now()-this.playStartTime),n=this.paused;return n&&p.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:Te(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==ne(e.volume??1)&&(this.volume.value=ne(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=B.now(),n==="started"&&super.stop();else {let s;typeof this.pausedAt=="number"&&(s=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,s):this.start(void 0,s));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return p.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,s){let r=B.now(),a=r;if(typeof e=="number")a=e;else if(typeof e=="string"&&e.startsWith("+")){let u=Number(e.slice(1));Number.isNaN(u)||(a=r+u);}let l=typeof n=="number"?n:0;return this.playStartTime=a-l,super.start(e,n,s)}chain(...e){return e.forEach(n=>{gt(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return gt(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var Pe=class{constructor(t,e={}){this.alias=t;this.background=e.background??false,this.toneChannel=new B.Channel({volume:ne(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}alias;toneChannel;get volume(){return Te(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=ne(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}background;_createPlayer(t,e,n={}){let s=p.bufferRegistry.get(e);if(!s)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:r,elapsed:a,filters:l=[],muted:u,autostart:y=true,speed:b,volume:v,...M}=n;u!==void 0&&(_.warn(`MediaInstance "${t}" is being created with muted=${u}. This will override the channel's muted state (${this.muted}).`),M.mute=u),b!==void 0&&(_.warn(`MediaInstance "${t}" is being created with speed=${b}. This will override the default playback speed of 1.`),M.playbackRate=b);let D=new Ee(t,this.alias,e,core.GameUnifier.stepCounter,{...M,volume:v!==void 0?ne(v):void 0,url:s},r).chain(...l,this.toneChannel),z=a!==void 0?Math.max(0,a):void 0;return y&&(r?D.start(`+${r}`,z):D.start(void 0,z)),D}async play(t,e,n){let s,r;if(typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.mediaInstances.has(s)){let l=p.mediaInstances.get(s);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await Ge(r);let a=this._createPlayer(s,r,n);return p.mediaInstances.set(s,a),a}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(p.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of p.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{p.mediaInstances.delete(e);}),this}};function Mt(o){try{if(typeof o>"u")return o;let t=JSON.stringify(o);return JSON.parse(t)}catch(t){throw _.error("Error creating exportable element",o,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var xe=class{get volumeAll(){return Te(B__namespace.getDestination().volume.value)}set volumeAll(t){B__namespace.getDestination().volume.value=ne(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of p.mediaInstances.values())e.speed=t;}_speedAll=1;_defaultChannelAlias=Tt;get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!p.bufferRegistry.has(t)){let n=new B__namespace.ToneAudioBuffer(e);p.bufferRegistry.set(t,n);}}pauseAll(){for(let t of p.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return B__namespace.getDestination().mute}toggleMuteAll(){let t=!B__namespace.getDestination().mute;return B__namespace.getDestination().mute=t,t}muteAll(){return B__namespace.getDestination().mute=true,this}unmuteAll(){return B__namespace.getDestination().mute=false,this}stopAll(){for(let t of p.mediaInstances.values())t.stop();return p.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of p.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,p.systemPausedAliases.add(e));if(!t){for(let e of p.transients)e.stop();p.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of p.systemPausedAliases){let s=p.mediaInstances.get(n);if(!s){e.push(n);continue}t&&s.channelAlias!==t||(s.paused=false,e.push(n));}for(let n of e)p.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of p.transients)t.stop();return p.transients.clear(),this}async play(t,e,n){let s,r;typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.bufferRegistry.has(r)||await this.load(r);let{channel:a=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(a).play(s,r,l)}async playTransient(t,e){p.bufferRegistry.has(t)||await this.load(t);let n=p.bufferRegistry.get(t);if(!n)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:s=true,...r}=e??{},a=new B__namespace.Player({...r,url:n}).toDestination();return s&&a.start(),p.transients.add(a),a.onstop=()=>{a.dispose(),p.transients.delete(a);},a}find(t){return p.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),p.mediaInstances.delete(t)):_.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){_.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){_.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return p.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(Ge);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{_.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=kt__default.default.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await kt__default.default.Assets.loadBundle(t),s=[];for(let r in n)p.bufferRegistry.has(r)||s.push(this.load(r));await Promise.all(s);}catch(n){_.error("Error loading sound bundle",n);}}).catch(n=>{_.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(s=>{let r={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(s,r);});return}if(p.channels.has(t)){_.warn(`Channel with alias ${t} already exists.`);return}let n=new Pe(t,e);return p.channels.set(t,n),n}findChannel(t){let e=p.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(p.channels.values())}export(){let t=Array.from(p.mediaInstances.entries()).reduce((e,[n,s])=>(e[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,paused:s.paused,options:{...s.memory,filters:It(s.filters)}},e),{});return {mediaInstances:Mt(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async s=>{await this.load(s),await this.play(s);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,s=Object.values(e).map(async({soundAlias:a,channelAlias:l})=>(n.add(l),await this.load(a)));await Promise.all(s),this.channels.forEach(a=>{(!a.background||!n.has(a.alias))&&a.stopAll();});let r=Object.keys(e).map(async a=>{let l=e[a],u=this.findChannel(l.channelAlias),y=l.options.paused??l.paused??!1;if(u.background)if(l.stepCounter===core.GameUnifier.stepCounter||!this.find(a)){let b=await u.play(a,l.soundAlias,{...l.options,autostart:!y,filters:Ne(l.options.filters||[]),delay:l.options.delay});b.paused=y;}else {let b=p.mediaInstances.get(a);if(!b){_.warn(`No media instance found with alias ${a} while restoring background state.`);return}b.memory={...l.options,paused:y},[...b.filters].forEach(M=>{b.disconnect(M),M.dispose();}),b.chain(...Ne(l.options.filters||[]));}else {let b=await u.play(a,l.soundAlias,{...l.options,autostart:!y,filters:Ne(l.options.filters||[]),delay:l.options.delay});b.paused=y;}});await Promise.all(r);}}}catch(e){_.error("Error importing data",e);}}};var bt=new xe;core.GameUnifier.addOnPreContinue(async()=>{try{p.channels.forEach(o=>{o.background||o.stopAll();});}catch{}});if(typeof document<"u"){let o=false;document.addEventListener("visibilitychange",()=>{document.hidden?bt.muted||(bt.muteAll(),o=true):o&&(bt.unmuteAll(),o=false);});}exports.SoundRegistry=p;exports.sound=bt;
|
package/dist/sound.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {e,d,f,g as g$1}from'./chunk-3M6A7TU2.mjs';import {GameUnifier,PixiError}from'./core.mjs';import le from'./pixi/index.js';import*as c from'tone';import {ToneAudioBuffer,Channel,Reverb,Time,PingPongDelay,FeedbackDelay,BitCrusher,Compressor,Delay,Distortion,FeedbackCombFilter,Freeverb,Gate,GreaterThan,GreaterThanZero,Limiter,MidSideCompressor,MultibandCompressor,Panner3D,Phaser,StereoWidener,AutoFilter,Chorus,Tremolo,Vibrato,AutoPanner,BiquadFilter,OnePoleFilter,Filter,Player,now}from'tone';var re;(s=>(s.mediaInstances=new Map,s.channels=new Map,s.transients=new Set,s.systemPausedAliases=new Set,s.bufferRegistry=new e({cacheSize:10})))(re||={});var i=re;function T(a){return a.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new GreaterThanZero);break;case "LimiterFilter":t.push(new Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function se(a){if(a)return Array.from(a).reduce((t,e)=>(e instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:Time(e.decay).toSeconds(),preDelay:Time(e.preDelay).toSeconds()}):e instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):f.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function J(a){return a instanceof Reverb||a instanceof FeedbackDelay||a instanceof PingPongDelay||a instanceof BitCrusher||a instanceof Compressor||a instanceof Delay||a instanceof Distortion||a instanceof FeedbackCombFilter||a instanceof Freeverb||a instanceof Gate||a instanceof GreaterThan||a instanceof GreaterThanZero||a instanceof Limiter||a instanceof MidSideCompressor||a instanceof MultibandCompressor||a instanceof Panner3D||a instanceof Phaser||a instanceof StereoWidener||a instanceof AutoFilter||a instanceof Chorus||a instanceof Vibrato||a instanceof Tremolo||a instanceof AutoPanner||a instanceof BiquadFilter||a instanceof OnePoleFilter||a instanceof Filter}function h(a){return a<=0?-1/0:20*Math.log10(a)}function g(a){return a<=-1/0?0:10**(a/20)}async function P(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=le.Assets.resolver.resolve(a);e?.src&&(t=e.src);}catch{}try{let e=await ToneAudioBuffer.load(t),n=new ToneAudioBuffer(e);i.bufferRegistry.set(a,n);}catch(e){f.warn(`Failed to load audio buffer for "${a}" (url: "${t}"): ${e instanceof Error?e.message:e}`),i.bufferRegistry.set(a,new ToneAudioBuffer);}}var v=class extends Player{constructor(e,n,r,s,o={},l){super(o);d(this,"alias",e);d(this,"channelAlias",n);d(this,"soundAlias",r);d(this,"stepCounter",s);d(this,"delay",l);d(this,"options");d(this,"filters",new Set);d(this,"pausedAt");d(this,"playStartTime",now());this.options=o,this.playStartTime=now()+(l??0);}get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:now()-this.playStartTime),n=this.paused;return n&&i.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:g(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==h(e.volume??1)&&(this.volume.value=h(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=now(),n==="started"&&super.stop();else {let r;typeof this.pausedAt=="number"&&(r=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,r):this.start(void 0,r));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return i.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,r){let s=now(),o=s;if(typeof e=="number")o=e;else if(typeof e=="string"&&e.startsWith("+")){let m=Number(e.slice(1));Number.isNaN(m)||(o=s+m);}let l=typeof n=="number"?n:0;return this.playStartTime=o-l,super.start(e,n,r)}chain(...e){return e.forEach(n=>{J(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return J(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var F=class{constructor(t,e={}){d(this,"alias",t);d(this,"toneChannel");d(this,"background");this.background=e.background??false,this.toneChannel=new Channel({volume:h(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return g(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=h(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let r=i.bufferRegistry.get(e);if(!r)throw new PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:s,elapsed:o,filters:l=[],muted:m,autostart:y=true,speed:p,volume:A,...f$1}=n;m!==void 0&&(f.warn(`MediaInstance "${t}" is being created with muted=${m}. This will override the channel's muted state (${this.muted}).`),f$1.mute=m),p!==void 0&&(f.warn(`MediaInstance "${t}" is being created with speed=${p}. This will override the default playback speed of 1.`),f$1.playbackRate=p);let O=new v(t,this.alias,e,GameUnifier.stepCounter,{...f$1,volume:A!==void 0?h(A):void 0,url:r},s).chain(...l,this.toneChannel),te=o!==void 0?Math.max(0,o):void 0;return y&&(s?O.start(`+${s}`,te):O.start(void 0,te)),O}async play(t,e,n){let r,s;if(typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.mediaInstances.has(r)){let l=i.mediaInstances.get(r);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await P(s);let o=this._createPlayer(r,s,n);return i.mediaInstances.set(r,o),o}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of i.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{i.mediaInstances.delete(e);}),this}};var w=class{constructor(){d(this,"_speedAll",1);d(this,"_defaultChannelAlias",i$1);}get volumeAll(){return g(c.getDestination().volume.value)}set volumeAll(t){c.getDestination().volume.value=h(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of i.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!i.bufferRegistry.has(t)){let n=new c.ToneAudioBuffer(e);i.bufferRegistry.set(t,n);}}pauseAll(){for(let t of i.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return c.getDestination().mute}toggleMuteAll(){let t=!c.getDestination().mute;return c.getDestination().mute=t,t}muteAll(){return c.getDestination().mute=true,this}unmuteAll(){return c.getDestination().mute=false,this}stopAll(){for(let t of i.mediaInstances.values())t.stop();return i.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of i.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,i.systemPausedAliases.add(e));if(!t){for(let e of i.transients)e.stop();i.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of i.systemPausedAliases){let r=i.mediaInstances.get(n);if(!r){e.push(n);continue}t&&r.channelAlias!==t||(r.paused=false,e.push(n));}for(let n of e)i.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of i.transients)t.stop();return i.transients.clear(),this}async play(t,e,n){let r,s;typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.bufferRegistry.has(s)||await this.load(s);let{channel:o=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(o).play(r,s,l)}async playTransient(t,e){i.bufferRegistry.has(t)||await this.load(t);let n=i.bufferRegistry.get(t);if(!n)throw new PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:r=true,...s}=e??{},o=new c.Player({...s,url:n}).toDestination();return r&&o.start(),i.transients.add(o),o.onstop=()=>{o.dispose(),i.transients.delete(o);},o}find(t){return i.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),i.mediaInstances.delete(t)):f.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){f.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){f.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return i.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(P);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{f.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=le.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await le.Assets.loadBundle(t),r=[];for(let s in n)i.bufferRegistry.has(s)||r.push(this.load(s));await Promise.all(r);}catch(n){f.error("Error loading sound bundle",n);}}).catch(n=>{f.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(r=>{let s={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(r,s);});return}if(i.channels.has(t)){f.warn(`Channel with alias ${t} already exists.`);return}let n=new F(t,e);return i.channels.set(t,n),n}findChannel(t){let e=i.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(i.channels.values())}export(){let t=Array.from(i.mediaInstances.entries()).reduce((e,[n,r])=>(e[n]={channelAlias:r.channelAlias,soundAlias:r.soundAlias,stepCounter:r.stepCounter,paused:r.paused,options:{...r.memory,filters:se(r.filters)}},e),{});return {mediaInstances:g$1(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async r=>{await this.load(r),await this.play(r);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,r=Object.values(e).map(async({soundAlias:o,channelAlias:l})=>(n.add(l),await this.load(o)));await Promise.all(r),this.channels.forEach(o=>{(!o.background||!n.has(o.alias))&&o.stopAll();});let s=Object.keys(e).map(async o=>{let l=e[o],m=this.findChannel(l.channelAlias),y=l.options.paused??l.paused??!1;if(m.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(o)){let p=await m.play(o,l.soundAlias,{...l.options,autostart:!y,filters:T(l.options.filters||[]),delay:l.options.delay});p.paused=y;}else {let p=i.mediaInstances.get(o);if(!p){f.warn(`No media instance found with alias ${o} while restoring background state.`);return}p.memory={...l.options,paused:y},[...p.filters].forEach(f=>{p.disconnect(f),f.dispose();}),p.chain(...T(l.options.filters||[]));}else {let p=await m.play(o,l.soundAlias,{...l.options,autostart:!y,filters:T(l.options.filters||[]),delay:l.options.delay});p.paused=y;}});await Promise.all(s);}}}catch(e){f.error("Error importing data",e);}}};var ee=new w;GameUnifier.addOnPreContinue(async()=>{try{i.channels.forEach(a=>{a.background||a.stopAll();});}catch{}});if(typeof document<"u"){let a=false;document.addEventListener("visibilitychange",()=>{document.hidden?ee.muted||(ee.muteAll(),a=true):a&&(ee.unmuteAll(),a=false);});}export{i as SoundRegistry,ee as sound};
|
|
1
|
+
import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {d,e,f as f$1}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'./core.mjs';import se from'./pixi/index.js';import*as p from'tone';import {ToneAudioBuffer,Channel,Reverb,Time,PingPongDelay,FeedbackDelay,BitCrusher,Compressor,Delay,Distortion,FeedbackCombFilter,Freeverb,Gate,GreaterThan,GreaterThanZero,Limiter,MidSideCompressor,MultibandCompressor,Panner3D,Phaser,StereoWidener,AutoFilter,Chorus,Tremolo,Vibrato,AutoPanner,BiquadFilter,OnePoleFilter,Filter,Player,now}from'tone';var ie;(s=>(s.mediaInstances=new Map,s.channels=new Map,s.transients=new Set,s.systemPausedAliases=new Set,s.bufferRegistry=new d({cacheSize:10})))(ie||={});var i=ie;function w(a){return a.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new GreaterThanZero);break;case "LimiterFilter":t.push(new Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function oe(a){if(a)return Array.from(a).reduce((t,e$1)=>(e$1 instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e$1.wet.value,decay:Time(e$1.decay).toSeconds(),preDelay:Time(e$1.preDelay).toSeconds()}):e$1 instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e$1.wet.value,delayTime:e$1.delayTime.value,feedback:e$1.feedback.value}):e$1 instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e$1.feedback.value,delayTime:e$1.delayTime.value,wet:e$1.wet.value}):e$1 instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e$1.bits.value,wet:e$1.wet.value}):e$1 instanceof Compressor?t.push({filterType:"CompressorFilter",attack:e$1.attack.value,knee:e$1.knee.value,ratio:e$1.ratio.value,release:e$1.release.value,threshold:e$1.threshold.value}):e$1 instanceof Delay?t.push({filterType:"DelayFilter",delayTime:e$1.delayTime.value,maxDelay:e$1.maxDelay}):e$1 instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e$1.distortion,oversample:e$1.oversample,wet:e$1.wet.value}):e$1 instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e$1.delayTime.value,resonance:e$1.resonance.value}):e$1 instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e$1.roomSize.value,dampening:e$1.dampening,wet:e$1.wet.value}):e$1 instanceof Gate?t.push({filterType:"GateFilter",threshold:e$1.threshold,smoothing:e$1.smoothing}):e$1 instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e$1.comparator.value,convert:e$1.convert,maxValue:e$1.maxValue,minValue:e$1.minValue}):e$1 instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e$1 instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e$1.threshold.value}):e$1 instanceof MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e$1.mid.attack.value,knee:e$1.mid.knee.value,ratio:e$1.mid.ratio.value,release:e$1.mid.release.value,threshold:e$1.mid.threshold.value},side:{attack:e$1.side.attack.value,knee:e$1.side.knee.value,ratio:e$1.side.ratio.value,release:e$1.side.release.value,threshold:e$1.side.threshold.value}}):e$1 instanceof MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e$1.lowFrequency.value,highFrequency:e$1.highFrequency.value,low:{attack:e$1.low.attack.value,knee:e$1.low.knee.value,ratio:e$1.low.ratio.value,release:e$1.low.release.value,threshold:e$1.low.threshold.value},mid:{attack:e$1.mid.attack.value,knee:e$1.mid.knee.value,ratio:e$1.mid.ratio.value,release:e$1.mid.release.value,threshold:e$1.mid.threshold.value},high:{attack:e$1.high.attack.value,knee:e$1.high.knee.value,ratio:e$1.high.ratio.value,release:e$1.high.release.value,threshold:e$1.high.threshold.value}}):e$1 instanceof Panner3D?t.push({filterType:"Panner3DFilter",positionX:e$1.positionX.value,positionY:e$1.positionY.value,positionZ:e$1.positionZ.value,orientationX:e$1.orientationX.value,orientationY:e$1.orientationY.value,orientationZ:e$1.orientationZ.value,coneInnerAngle:e$1.coneInnerAngle,coneOuterAngle:e$1.coneOuterAngle,coneOuterGain:e$1.coneOuterGain,distanceModel:e$1.distanceModel,maxDistance:e$1.maxDistance,refDistance:e$1.refDistance,rolloffFactor:e$1.rolloffFactor,panningModel:e$1.panningModel}):e$1 instanceof Phaser?t.push({filterType:"PhaserFilter",frequency:e$1.frequency.value,octaves:e$1.octaves,baseFrequency:e$1.baseFrequency,wet:e$1.wet.value,Q:e$1.Q.value}):e$1 instanceof StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e$1.width.value,wet:e$1.wet.value}):e$1 instanceof AutoFilter?t.push({filterType:"AutoFilterFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,baseFrequency:e$1.baseFrequency,octaves:e$1.octaves,filter:{Q:e$1.filter.Q.value,type:e$1.filter.type,rolloff:e$1.filter.rolloff},wet:e$1.wet.value}):e$1 instanceof Chorus?t.push({filterType:"ChorusFilter",type:e$1.type,frequency:e$1.frequency.value,delayTime:e$1.delayTime,depth:e$1.depth,spread:e$1.spread,feedback:e$1.feedback.value,wet:e$1.wet.value}):e$1 instanceof Tremolo?t.push({filterType:"TremoloFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,spread:e$1.spread,wet:e$1.wet.value}):e$1 instanceof Vibrato?t.push({filterType:"VibratoFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,wet:e$1.wet.value}):e$1 instanceof AutoPanner?t.push({filterType:"AutoPannerFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,channelCount:e$1.channelCount,wet:e$1.wet.value}):e$1 instanceof BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e$1.type,frequency:e$1.frequency.value,detune:e$1.detune.value,Q:e$1.Q.value,gain:e$1.gain.value}):e$1 instanceof OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e$1.type}):e$1 instanceof Filter?t.push({filterType:"CustomFilter",type:e$1.type,frequency:e$1.frequency.value,Q:e$1.Q.value,detune:e$1.detune.value,gain:e$1.gain.value,rolloff:e$1.rolloff}):e.warn(`Unsupported filter type for serialisation: ${e$1?.constructor?.name??e$1}, please report this to the developers if you encounter it.`),t),[])}function H(a){return a instanceof Reverb||a instanceof FeedbackDelay||a instanceof PingPongDelay||a instanceof BitCrusher||a instanceof Compressor||a instanceof Delay||a instanceof Distortion||a instanceof FeedbackCombFilter||a instanceof Freeverb||a instanceof Gate||a instanceof GreaterThan||a instanceof GreaterThanZero||a instanceof Limiter||a instanceof MidSideCompressor||a instanceof MultibandCompressor||a instanceof Panner3D||a instanceof Phaser||a instanceof StereoWidener||a instanceof AutoFilter||a instanceof Chorus||a instanceof Vibrato||a instanceof Tremolo||a instanceof AutoPanner||a instanceof BiquadFilter||a instanceof OnePoleFilter||a instanceof Filter}function m(a){return a<=0?-1/0:20*Math.log10(a)}function f(a){return a<=-1/0?0:10**(a/20)}async function T(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=se.Assets.resolver.resolve(a);e?.src&&(t=e.src);}catch{}try{let e=await ToneAudioBuffer.load(t),n=new ToneAudioBuffer(e);i.bufferRegistry.set(a,n);}catch(e$1){e.warn(`Failed to load audio buffer for "${a}" (url: "${t}"): ${e$1 instanceof Error?e$1.message:e$1}`),i.bufferRegistry.set(a,new ToneAudioBuffer);}}var b=class extends Player{constructor(e,n,r,s,o={},l){super(o);this.alias=e;this.channelAlias=n;this.soundAlias=r;this.stepCounter=s;this.delay=l;this.options=o,this.playStartTime=now()+(l??0);}alias;channelAlias;soundAlias;stepCounter;delay;options;filters=new Set;pausedAt=void 0;playStartTime=now();get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:now()-this.playStartTime),n=this.paused;return n&&i.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:f(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==m(e.volume??1)&&(this.volume.value=m(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=now(),n==="started"&&super.stop();else {let r;typeof this.pausedAt=="number"&&(r=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,r):this.start(void 0,r));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return i.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,r){let s=now(),o=s;if(typeof e=="number")o=e;else if(typeof e=="string"&&e.startsWith("+")){let c=Number(e.slice(1));Number.isNaN(c)||(o=s+c);}let l=typeof n=="number"?n:0;return this.playStartTime=o-l,super.start(e,n,r)}chain(...e){return e.forEach(n=>{H(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return H(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var v=class{constructor(t,e={}){this.alias=t;this.background=e.background??false,this.toneChannel=new Channel({volume:m(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}alias;toneChannel;get volume(){return f(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=m(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}background;_createPlayer(t,e$1,n={}){let r=i.bufferRegistry.get(e$1);if(!r)throw new PixiError("unregistered_asset",`Sound buffer for alias "${e$1}" is not loaded. Call sound.load() first.`);let{delay:s,elapsed:o,filters:l=[],muted:c,autostart:h=true,speed:d,volume:P,...y}=n;c!==void 0&&(e.warn(`MediaInstance "${t}" is being created with muted=${c}. This will override the channel's muted state (${this.muted}).`),y.mute=c),d!==void 0&&(e.warn(`MediaInstance "${t}" is being created with speed=${d}. This will override the default playback speed of 1.`),y.playbackRate=d);let A=new b(t,this.alias,e$1,GameUnifier.stepCounter,{...y,volume:P!==void 0?m(P):void 0,url:r},s).chain(...l,this.toneChannel),ee=o!==void 0?Math.max(0,o):void 0;return h&&(s?A.start(`+${s}`,ee):A.start(void 0,ee)),A}async play(t,e,n){let r,s;if(typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.mediaInstances.has(r)){let l=i.mediaInstances.get(r);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await T(s);let o=this._createPlayer(r,s,n);return i.mediaInstances.set(r,o),o}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of i.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{i.mediaInstances.delete(e);}),this}};var F=class{get volumeAll(){return f(p.getDestination().volume.value)}set volumeAll(t){p.getDestination().volume.value=m(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of i.mediaInstances.values())e.speed=t;}_speedAll=1;_defaultChannelAlias=i$1;get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!i.bufferRegistry.has(t)){let n=new p.ToneAudioBuffer(e);i.bufferRegistry.set(t,n);}}pauseAll(){for(let t of i.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return p.getDestination().mute}toggleMuteAll(){let t=!p.getDestination().mute;return p.getDestination().mute=t,t}muteAll(){return p.getDestination().mute=true,this}unmuteAll(){return p.getDestination().mute=false,this}stopAll(){for(let t of i.mediaInstances.values())t.stop();return i.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of i.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,i.systemPausedAliases.add(e));if(!t){for(let e of i.transients)e.stop();i.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of i.systemPausedAliases){let r=i.mediaInstances.get(n);if(!r){e.push(n);continue}t&&r.channelAlias!==t||(r.paused=false,e.push(n));}for(let n of e)i.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of i.transients)t.stop();return i.transients.clear(),this}async play(t,e,n){let r,s;typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.bufferRegistry.has(s)||await this.load(s);let{channel:o=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(o).play(r,s,l)}async playTransient(t,e){i.bufferRegistry.has(t)||await this.load(t);let n=i.bufferRegistry.get(t);if(!n)throw new PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:r=true,...s}=e??{},o=new p.Player({...s,url:n}).toDestination();return r&&o.start(),i.transients.add(o),o.onstop=()=>{o.dispose(),i.transients.delete(o);},o}find(t){return i.mediaInstances.get(t)}stop(t){let e$1=this.find(t);e$1?(e$1.stop(),i.mediaInstances.delete(t)):e.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e$1=this.find(t);if(!e$1){e.warn(`No media instance found with alias ${t} to pause.`);return}return e$1.paused=true,e$1}resume(t){let e$1=this.find(t);if(!e$1){e.warn(`No media instance found with alias ${t} to resume.`);return}return e$1.paused=false,e$1}duration(t){return i.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(T);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e$1=>{e.error("Error background-loading sound",e$1);})}backgroundLoadBundle(t){let e$1=se.Assets.backgroundLoadBundle(t);return e$1.then(async()=>{try{let n=await se.Assets.loadBundle(t),r=[];for(let s in n)i.bufferRegistry.has(s)||r.push(this.load(s));await Promise.all(r);}catch(n){e.error("Error loading sound bundle",n);}}).catch(n=>{e.error("Error background-loading sound bundle",n);}),e$1}clear(){this.stopAll();}addChannel(t,e$1={}){if(typeof t!="string"){t.forEach(r=>{let s={...e$1,filters:e$1.filters?[...e$1.filters]:e$1.filters};this.addChannel(r,s);});return}if(i.channels.has(t)){e.warn(`Channel with alias ${t} already exists.`);return}let n=new v(t,e$1);return i.channels.set(t,n),n}findChannel(t){let e=i.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(i.channels.values())}export(){let t=Array.from(i.mediaInstances.entries()).reduce((e,[n,r])=>(e[n]={channelAlias:r.channelAlias,soundAlias:r.soundAlias,stepCounter:r.stepCounter,paused:r.paused,options:{...r.memory,filters:oe(r.filters)}},e),{});return {mediaInstances:f$1(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async r=>{await this.load(r),await this.play(r);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e$1=t.mediaInstances;if(e$1){let n=new Set,r=Object.values(e$1).map(async({soundAlias:o,channelAlias:l})=>(n.add(l),await this.load(o)));await Promise.all(r),this.channels.forEach(o=>{(!o.background||!n.has(o.alias))&&o.stopAll();});let s=Object.keys(e$1).map(async o=>{let l=e$1[o],c=this.findChannel(l.channelAlias),h=l.options.paused??l.paused??!1;if(c.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(o)){let d=await c.play(o,l.soundAlias,{...l.options,autostart:!h,filters:w(l.options.filters||[]),delay:l.options.delay});d.paused=h;}else {let d=i.mediaInstances.get(o);if(!d){e.warn(`No media instance found with alias ${o} while restoring background state.`);return}d.memory={...l.options,paused:h},[...d.filters].forEach(y=>{d.disconnect(y),y.dispose();}),d.chain(...w(l.options.filters||[]));}else {let d=await c.play(o,l.soundAlias,{...l.options,autostart:!h,filters:w(l.options.filters||[]),delay:l.options.delay});d.paused=h;}});await Promise.all(s);}}}catch(e$1){e.error("Error importing data",e$1);}}};var K=new F;GameUnifier.addOnPreContinue(async()=>{try{i.channels.forEach(a=>{a.background||a.stopAll();});}catch{}});if(typeof document<"u"){let a=false;document.addEventListener("visibilitychange",()=>{document.hidden?K.muted||(K.muteAll(),a=true):a&&(K.unmuteAll(),a=false);});}export{i as SoundRegistry,K as sound};
|
package/dist/storage.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('./core.cjs');var te=Object.defineProperty;var Ht=u=>{throw TypeError(u)};var ee=(u,e,i)=>e in u?te(u,e,{enumerable:true,configurable:true,writable:true,value:i}):u[e]=i;var E=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),Ut=(u,e,i)=>e.has(u)||Ht("Cannot "+i);var t=(u,e,i)=>(Ut(u,e,"read from private field"),i?i.call(u):e.get(u)),d=(u,e,i)=>e.has(u)?Ht("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(Ut(u,e,"write to private field"),e.set(u,i),i),l=(u,e,i)=>(Ut(u,e,"access private method"),i);var It=(u,e,i,s)=>({set _(r){f(u,e,r);},get _(){return t(u,e,s)}});var st="storage",ht="temp",H="narration",Nt="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ie=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Bt=new Set,zt=typeof process=="object"&&process?process:{},Xt=(u,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Gt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Gt>"u"){jt=class{constructor(){E(this,"onabort");E(this,"_onabort",[]);E(this,"reason");E(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){E(this,"signal",new jt);e();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let u=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,Xt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var se=u=>!Bt.has(u);var rt=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),Jt=u=>rt(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(u){super(u),this.fill(0);}},et,dt,re=(et=class{constructor(e,i){E(this,"heap");E(this,"length");if(!t(et,dt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=Jt(e);if(!i)return [];f(et,dt,true);let s=new et(e,i);return f(et,dt,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},dt=new WeakMap,d(et,dt,false),et),$t,kt,$,z,k,ct,B,St,mt,X,D,J,R,v,p,V,Y,C,N,q,F,Q,Z,P,K,tt,lt,L,Et,n,Yt,ut,it,vt,W,Qt,ft,Tt,xt,at,ot,Pt,Ct,Mt,w,Kt,wt,nt,Wt,bt,qt=(bt=class{constructor(e){d(this,n);d(this,$);d(this,z);d(this,k);d(this,ct);d(this,B);d(this,St);d(this,mt);d(this,X);E(this,"ttl");E(this,"ttlResolution");E(this,"ttlAutopurge");E(this,"updateAgeOnGet");E(this,"updateAgeOnHas");E(this,"allowStale");E(this,"noDisposeOnSet");E(this,"noUpdateTTL");E(this,"maxEntrySize");E(this,"sizeCalculation");E(this,"noDeleteOnFetchRejection");E(this,"noDeleteOnStaleGet");E(this,"allowStaleOnFetchAbort");E(this,"allowStaleOnFetchRejection");E(this,"ignoreFetchAbort");d(this,D);d(this,J);d(this,R);d(this,v);d(this,p);d(this,V);d(this,Y);d(this,C);d(this,N);d(this,q);d(this,F);d(this,Q);d(this,Z);d(this,P);d(this,K);d(this,tt);d(this,lt);d(this,L);d(this,Et);d(this,ut,()=>{});d(this,it,()=>{});d(this,vt,()=>{});d(this,W,()=>false);d(this,ft,e=>{});d(this,Tt,(e,i,s)=>{});d(this,xt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});E(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:c,dispose:m,onInsert:I,disposeAfter:g,noDisposeOnSet:A,noUpdateTTL:b,maxSize:T=0,maxEntrySize:y=0,sizeCalculation:O,fetchMethod:_,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:Ot,ignoreFetchAbort:pt,perf:gt}=e;if(gt!==void 0&&typeof gt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,gt??ie),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let _t=i?Jt(i):Array;if(!_t)throw new Error("invalid max value: "+i);if(f(this,$,i),f(this,z,T),this.maxEntrySize=y||t(this,z),this.sizeCalculation=O,this.sizeCalculation){if(!t(this,z)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,mt,M),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,St,_),f(this,lt,!!_),f(this,R,new Map),f(this,v,new Array(i).fill(void 0)),f(this,p,new Array(i).fill(void 0)),f(this,V,new _t(i)),f(this,Y,new _t(i)),f(this,C,0),f(this,N,0),f(this,q,re.create(i)),f(this,D,0),f(this,J,0),typeof m=="function"&&f(this,k,m),typeof I=="function"&&f(this,ct,I),typeof g=="function"?(f(this,B,g),f(this,F,[])):(f(this,B,void 0),f(this,F,void 0)),f(this,tt,!!t(this,k)),f(this,Et,!!t(this,ct)),f(this,L,!!t(this,B)),this.noDisposeOnSet=!!A,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!Ot,this.ignoreFetchAbort=!!pt,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,Qt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Yt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,z)){let Lt="LRU_CACHE_UNBOUNDED";se(Lt)&&(Bt.add(Lt),Xt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Lt,bt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,P),autopurgeTimers:t(e,K),sizes:t(e,Q),keyMap:t(e,R),keyList:t(e,v),valList:t(e,p),next:t(e,V),prev:t(e,Y),get head(){return t(e,C)},get tail(){return t(e,N)},free:t(e,q),isBackgroundFetch:i=>{var s;return l(s=e,n,w).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return l(a=e,n,Mt).call(a,i,s,r,o)},moveToTail:i=>{var s;return l(s=e,n,wt).call(s,i)},indexes:i=>{var s;return l(s=e,n,at).call(s,i)},rindexes:i=>{var s;return l(s=e,n,ot).call(s,i)},isStale:i=>{var s;return t(s=e,W).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,D)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,mt)}get dispose(){return t(this,k)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&t(this,v)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield [t(this,v)[e],t(this,p)[e]]);}*rentries(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&t(this,v)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield [t(this,v)[e],t(this,p)[e]]);}*keys(){for(let e of l(this,n,at).call(this)){let i=t(this,v)[e];i!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,ot).call(this)){let i=t(this,v)[e];i!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield i);}}*values(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}*rvalues(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}[(kt=Symbol.iterator,$t=Symbol.toStringTag,kt)](){return this.entries()}find(e,i={}){for(let s of l(this,n,at).call(this)){let r=t(this,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,v)[s],this))return this.get(t(this,v)[s],i)}}forEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,v)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,v)[s],this);}}purgeStale(){let e=false;for(let i of l(this,n,ot).call(this,{allowStale:true}))t(this,W).call(this,i)&&(l(this,n,nt).call(this,t(this,v)[i],"expire"),e=true);return e}info(e){let i=t(this,R).get(e);if(i===void 0)return;let s=t(this,p)[i],r=l(this,n,w).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,P)&&t(this,Z)){let a=t(this,P)[i],h=t(this,Z)[i];if(a&&h){let c=a-(t(this,X).now()-h);o.ttl=c,o.start=Date.now();}}return t(this,Q)&&(o.size=t(this,Q)[i]),o}dump(){let e=[];for(let i of l(this,n,at).call(this,{allowStale:true})){let s=t(this,v)[i],r=t(this,p)[i],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,P)&&t(this,Z)){a.ttl=t(this,P)[i];let h=t(this,X).now()-t(this,Z)[i];a.start=Math.floor(Date.now()-h);}t(this,Q)&&(a.size=t(this,Q)[i]),e.unshift([s,a]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var A,b,T,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:m=this.noUpdateTTL}=s,I=t(this,xt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&I>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let g=t(this,D)===0?void 0:t(this,R).get(e);if(g===void 0)g=t(this,D)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,D)===t(this,$)?l(this,n,Ct).call(this,false):t(this,D),t(this,v)[g]=e,t(this,p)[g]=i,t(this,R).set(e,g),t(this,V)[t(this,N)]=g,t(this,Y)[g]=t(this,N),f(this,N,g),It(this,D)._++,t(this,Tt).call(this,g,I,c),c&&(c.set="add"),m=false,t(this,Et)&&((A=t(this,ct))==null||A.call(this,i,e,"add"));else {l(this,n,wt).call(this,g);let O=t(this,p)[g];if(i!==O){if(t(this,lt)&&l(this,n,w).call(this,O)){O.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:_}=O;_!==void 0&&!a&&(t(this,tt)&&((b=t(this,k))==null||b.call(this,_,e,"set")),t(this,L)&&t(this,F)?.push([_,e,"set"]));}else a||(t(this,tt)&&((T=t(this,k))==null||T.call(this,O,e,"set")),t(this,L)&&t(this,F)?.push([O,e,"set"]));if(t(this,ft).call(this,g),t(this,Tt).call(this,g,I,c),t(this,p)[g]=i,c){c.set="replace";let _=O&&l(this,n,w).call(this,O)?O.__staleWhileFetching:O;_!==void 0&&(c.oldValue=_);}}else c&&(c.set="update");t(this,Et)&&this.onInsert?.(i,e,i===O?"update":"replace");}if(r!==0&&!t(this,P)&&l(this,n,Yt).call(this),t(this,P)&&(m||t(this,vt).call(this,g,r,o),c&&t(this,it).call(this,c,g)),!a&&t(this,L)&&t(this,F)){let O=t(this,F),_;for(;_=O?.shift();)(y=t(this,B))==null||y.call(this,..._);}return this}pop(){var e;try{for(;t(this,D);){let i=t(this,p)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,w).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,L)&&t(this,F)){let i=t(this,F),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,R).get(e);if(o!==void 0){let a=t(this,p)[o];if(l(this,n,w).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,W).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,ut).call(this,o),r&&(r.has="hit",t(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,R).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let o=t(this,p)[r];return l(this,n,w).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:m=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:A=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:y,forceRefresh:O=false,status:_,signal:M}=i;if(!t(this,lt))return _&&(_.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:_});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:c,sizeCalculation:m,noUpdateTTL:I,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:T,ignoreFetchAbort:b,status:_,signal:M},G=t(this,R).get(e);if(G===void 0){_&&(_.fetch="miss");let x=l(this,n,Mt).call(this,e,G,U,y);return x.__returned=x}else {let x=t(this,p)[G];if(l(this,n,w).call(this,x)){let _t=s&&x.__staleWhileFetching!==void 0;return _&&(_.fetch="inflight",_t&&(_.returnedStale=true)),_t?x.__staleWhileFetching:x.__returned=x}let Ot=t(this,W).call(this,G);if(!O&&!Ot)return _&&(_.fetch="hit"),l(this,n,wt).call(this,G),r&&t(this,ut).call(this,G),_&&t(this,it).call(this,_,G),x;let pt=l(this,n,Mt).call(this,e,G,U,y),gt=pt.__staleWhileFetching!==void 0&&s;return _&&(_.fetch=Ot?"stale":"refresh",gt&&Ot&&(_.returnedStale=true)),gt?pt.__staleWhileFetching:pt.__returned=pt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,mt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,h=this.get(e,a);if(!o&&h!==void 0)return h;let c=s(e,h,{options:a,context:r});return this.set(e,c,a),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,h=t(this,R).get(e);if(h!==void 0){let c=t(this,p)[h],m=l(this,n,w).call(this,c);return a&&t(this,it).call(this,a,h),t(this,W).call(this,h)?(a&&(a.get="stale"),m?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||l(this,n,nt).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),m?c.__staleWhileFetching:(l(this,n,wt).call(this,h),r&&t(this,ut).call(this,h),c))}else a&&(a.get="miss");}delete(e){return l(this,n,nt).call(this,e,"delete")}clear(){return l(this,n,Wt).call(this,"delete")}},$=new WeakMap,z=new WeakMap,k=new WeakMap,ct=new WeakMap,B=new WeakMap,St=new WeakMap,mt=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,R=new WeakMap,v=new WeakMap,p=new WeakMap,V=new WeakMap,Y=new WeakMap,C=new WeakMap,N=new WeakMap,q=new WeakMap,F=new WeakMap,Q=new WeakMap,Z=new WeakMap,P=new WeakMap,K=new WeakMap,tt=new WeakMap,lt=new WeakMap,L=new WeakMap,Et=new WeakMap,n=new WeakSet,Yt=function(){let e=new Ft(t(this,$)),i=new Ft(t(this,$));f(this,P,e),f(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,K,s),f(this,vt,(h,c,m=t(this,X).now())=>{i[h]=c!==0?m:0,e[h]=c,r(h,c);}),f(this,ut,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let m=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,v)[h],"expire");},c+1);m.unref&&m.unref(),s[h]=m;}}:()=>{};f(this,it,(h,c)=>{if(e[c]){let m=e[c],I=i[c];if(!m||!I)return;h.ttl=m,h.start=I,h.now=o||a();let g=h.now-I;h.remainingTTL=m-g;}});let o=0,a=()=>{let h=t(this,X).now();if(this.ttlResolution>0){o=h;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=t(this,R).get(h);if(c===void 0)return 0;let m=e[c],I=i[c];if(!m||!I)return 1/0;let g=(o||a())-I;return m-g},f(this,W,h=>{let c=i[h],m=e[h];return !!m&&!!c&&(o||a())-c>m});},ut=new WeakMap,it=new WeakMap,vt=new WeakMap,W=new WeakMap,Qt=function(){let e=new Ft(t(this,$));f(this,J,0),f(this,Q,e),f(this,ft,i=>{f(this,J,t(this,J)-e[i]),e[i]=0;}),f(this,xt,(i,s,r,o)=>{if(l(this,n,w).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),f(this,Tt,(i,s,r)=>{if(e[i]=s,t(this,z)){let o=t(this,z)-e[i];for(;t(this,J)>o;)l(this,n,Ct).call(this,true);}f(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},ft=new WeakMap,Tt=new WeakMap,xt=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(t(this,D))for(let i=t(this,N);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,C)));)i=t(this,Y)[i];},ot=function*({allowStale:e=this.allowStale}={}){if(t(this,D))for(let i=t(this,C);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,V)[i];},Pt=function(e){return e!==void 0&&t(this,R).get(t(this,v)[e])===e},Ct=function(e){var o;let i=t(this,C),s=t(this,v)[i],r=t(this,p)[i];return t(this,lt)&&l(this,n,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,L)&&t(this,F)?.push([r,s,"evict"])),t(this,ft).call(this,i),t(this,K)?.[i]&&(clearTimeout(t(this,K)[i]),t(this,K)[i]=void 0),e&&(t(this,v)[i]=void 0,t(this,p)[i]=void 0,t(this,q).push(i)),t(this,D)===1?(f(this,C,f(this,N,0)),t(this,q).length=0):f(this,C,t(this,V)[i]),t(this,R).delete(s),It(this,D)._--,i},Mt=function(e,i,s,r){let o=i===void 0?void 0:t(this,p)[i];if(l(this,n,w).call(this,o))return o;let a=new Gt,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},m=(y,O=false)=>{let{aborted:_}=a.signal,M=s.ignoreFetchAbort&&y!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(_&&!O?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),_&&!M&&!O)return g(a.signal.reason,U);let G=b,x=t(this,p)[i];return (x===b||M&&O&&x===void 0)&&(y===void 0?G.__staleWhileFetching!==void 0?t(this,p)[i]=G.__staleWhileFetching:l(this,n,nt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},I=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),g(y,false)),g=(y,O)=>{let{aborted:_}=a.signal,M=_&&s.allowStaleOnFetchAbort,U=M||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,x=b;if(t(this,p)[i]===b&&(!G||!O&&x.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):M||(t(this,p)[i]=x.__staleWhileFetching)),U)return s.status&&x.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),x.__staleWhileFetching;if(x.__returned===x)throw y},A=(y,O)=>{var M;let _=(M=t(this,St))==null?void 0:M.call(this,e,o,c);_&&_ instanceof Promise&&_.then(U=>y(U===void 0?void 0:U),O),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=U=>m(U,true)));});};s.status&&(s.status.fetchDispatched=true);let b=new Promise(A).then(m,I),T=Object.assign(b,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,T,{...c.options,status:void 0}),i=t(this,R).get(e)):t(this,p)[i]=T,T},w=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Kt=function(e,i){t(this,Y)[i]=e,t(this,V)[e]=i;},wt=function(e){e!==t(this,N)&&(e===t(this,C)?f(this,C,t(this,V)[e]):l(this,n,Kt).call(this,t(this,Y)[e],t(this,V)[e]),l(this,n,Kt).call(this,t(this,N),e),f(this,N,e));},nt=function(e,i){var r,o;let s=false;if(t(this,D)!==0){let a=t(this,R).get(e);if(a!==void 0)if(t(this,K)?.[a]&&(clearTimeout(t(this,K)?.[a]),t(this,K)[a]=void 0),s=true,t(this,D)===1)l(this,n,Wt).call(this,i);else {t(this,ft).call(this,a);let h=t(this,p)[a];if(l(this,n,w).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,L)&&t(this,F)?.push([h,e,i])),t(this,R).delete(e),t(this,v)[a]=void 0,t(this,p)[a]=void 0,a===t(this,N))f(this,N,t(this,Y)[a]);else if(a===t(this,C))f(this,C,t(this,V)[a]);else {let c=t(this,Y)[a];t(this,V)[c]=t(this,V)[a];let m=t(this,V)[a];t(this,Y)[m]=t(this,Y)[a];}It(this,D)._--,t(this,q).push(a);}}if(t(this,L)&&t(this,F)?.length){let a=t(this,F),h;for(;h=a?.shift();)(o=t(this,B))==null||o.call(this,...h);}return s},Wt=function(e){var i,s;for(let r of l(this,n,ot).call(this,{allowStale:true})){let o=t(this,p)[r];if(l(this,n,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,v)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,L)&&t(this,F)?.push([o,a,e]);}}if(t(this,R).clear(),t(this,p).fill(void 0),t(this,v).fill(void 0),t(this,P)&&t(this,Z)){t(this,P).fill(0),t(this,Z).fill(0);for(let r of t(this,K)??[])r!==void 0&&clearTimeout(r);t(this,K)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),f(this,C,0),f(this,N,0),t(this,q).length=0,f(this,J,0),f(this,D,0),t(this,L)&&t(this,F)){let r=t(this,F),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}},bt);var At=class{constructor(e){E(this,"cache");E(this,"map",new Map);this.cache=new qt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var yt;(r=>(r.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),r.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),r.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),r.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(yt||={});function Rt(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw yt.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Zt;(g=>{g.storage=new At({cacheSize:50}),g.defaultStorage=new At({cacheSize:10}),g.tempStorageDeadlines=new Map;let s;function r(A){g.tempStorageDeadlines.forEach((b,T)=>{b>A&&(g.storage.delete(`${ht}:${T}`),s?.onClearOldTempVariable?.(T),g.tempStorageDeadlines.delete(T));});}g.clearOldTempVariables=r;function o(A){s=A;}g.setExternalStoreHandler=o;function a(A,b,T){T==null?g.storage.delete(`${A}:${b}`):g.storage.set(`${A}:${b}`,T),s?.onSetVariable?.(b,T);}g.setVariable=a;function h(A,b){let T=g.storage.get(`${A}:${b}`);return Rt(T)}g.getVariable=h;function c(A,b){g.storage.delete(`${A}:${b}`),s?.onRemoveVariable?.(b);}g.removeVariable=c;function m(A,b){let T=g.storage.get(Nt)||[];if(b)T.includes(A)||T.push(A);else {let y=T.indexOf(A);y>-1&&T.splice(y,1);}g.storage.set(Nt,T);}g.setFlag=m;function I(A){return (g.storage.get(Nt)||[]).includes(A)}g.getFlag=I;})(Zt||={});var S=Zt;var Dt=class{get base(){return S.storage.map}get cache(){return S.storage.cache}get tempStorageDeadlines(){return S.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{S.defaultStorage.map.set(i,s);});}set(e,i){return S.setVariable(st,e,i)}get(e){let i=S.getVariable(ht,e);return i===void 0&&(i=S.getVariable(st,e)),i===void 0&&(i=Rt(S.defaultStorage.get(e))),i}remove(e){return this.removeTempVariable(e),S.removeVariable(st,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else S.setVariable(ht,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){S.removeVariable(ht,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return S.setFlag(e,i)}getFlag(e){return S.getFlag(e)}setStorageHandler(e){S.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...S.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Rt({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":S.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":S.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":S.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":S.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":S.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":S.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":S.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":S.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":S.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":S.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":S.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:S.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{S.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{S.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.tempStorageDeadlines.set(i.key,i.value);})):yt.warn("No storage data found");}catch(i){yt.error("Error importing data",i);}}};var Vt=class{constructor(e,i){E(this,"id");E(this,"categoryId");this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=S.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{S.setVariable(this.categoryId,`${s}:${o}`,a);});}),S.removeVariable(st,e));}setStorageProperty(e,i){S.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return S.getVariable(this.categoryId,`${i}:${e}`)}};var Ve=new Dt;exports.StorageRegistry=S;exports.StoredClassModel=Vt;exports.storage=Ve;
|
|
1
|
+
'use strict';var core=require('./core.cjs');var te=Object.defineProperty;var Ht=u=>{throw TypeError(u)};var ee=(u,e,i)=>e in u?te(u,e,{enumerable:true,configurable:true,writable:true,value:i}):u[e]=i;var F=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),Ut=(u,e,i)=>e.has(u)||Ht("Cannot "+i);var t=(u,e,i)=>(Ut(u,e,"read from private field"),i?i.call(u):e.get(u)),d=(u,e,i)=>e.has(u)?Ht("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(Ut(u,e,"write to private field"),e.set(u,i),i),l=(u,e,i)=>(Ut(u,e,"access private method"),i);var It=(u,e,i,s)=>({set _(r){f(u,e,r);},get _(){return t(u,e,s)}});var st="storage",ht="temp",H="narration",Nt="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ie=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Bt=new Set,zt=typeof process=="object"&&process?process:{},Xt=(u,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Gt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Gt>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){e();}signal=new jt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let u=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,Xt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var se=u=>!Bt.has(u);var rt=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),Jt=u=>rt(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(u){super(u),this.fill(0);}},et,dt,re=(et=class{heap;length;static create(e){let i=Jt(e);if(!i)return [];f(et,dt,true);let s=new et(e,i);return f(et,dt,false),s}constructor(e,i){if(!t(et,dt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},dt=new WeakMap,d(et,dt,false),et),$t,kt,$,z,k,ct,B,St,mt,X,R,J,x,w,p,V,Y,C,I,q,N,Q,Z,P,K,tt,lt,L,Et,n,Yt,ut,it,vt,W,Qt,ft,Tt,xt,at,ot,Pt,Ct,Mt,O,Kt,wt,nt,Wt,bt,qt=(bt=class{constructor(e){d(this,n);d(this,$);d(this,z);d(this,k);d(this,ct);d(this,B);d(this,St);d(this,mt);d(this,X);F(this,"ttl");F(this,"ttlResolution");F(this,"ttlAutopurge");F(this,"updateAgeOnGet");F(this,"updateAgeOnHas");F(this,"allowStale");F(this,"noDisposeOnSet");F(this,"noUpdateTTL");F(this,"maxEntrySize");F(this,"sizeCalculation");F(this,"noDeleteOnFetchRejection");F(this,"noDeleteOnStaleGet");F(this,"allowStaleOnFetchAbort");F(this,"allowStaleOnFetchRejection");F(this,"ignoreFetchAbort");d(this,R);d(this,J);d(this,x);d(this,w);d(this,p);d(this,V);d(this,Y);d(this,C);d(this,I);d(this,q);d(this,N);d(this,Q);d(this,Z);d(this,P);d(this,K);d(this,tt);d(this,lt);d(this,L);d(this,Et);d(this,ut,()=>{});d(this,it,()=>{});d(this,vt,()=>{});d(this,W,()=>false);d(this,ft,e=>{});d(this,Tt,(e,i,s)=>{});d(this,xt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});F(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:c,dispose:m,onInsert:D,disposeAfter:g,noDisposeOnSet:b,noUpdateTTL:T,maxSize:E=0,maxEntrySize:A=0,sizeCalculation:y,fetchMethod:_,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:Ot,ignoreFetchAbort:pt,perf:gt}=e;if(gt!==void 0&&typeof gt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,gt??ie),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let _t=i?Jt(i):Array;if(!_t)throw new Error("invalid max value: "+i);if(f(this,$,i),f(this,z,E),this.maxEntrySize=A||t(this,z),this.sizeCalculation=y,this.sizeCalculation){if(!t(this,z)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,mt,M),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,St,_),f(this,lt,!!_),f(this,x,new Map),f(this,w,new Array(i).fill(void 0)),f(this,p,new Array(i).fill(void 0)),f(this,V,new _t(i)),f(this,Y,new _t(i)),f(this,C,0),f(this,I,0),f(this,q,re.create(i)),f(this,R,0),f(this,J,0),typeof m=="function"&&f(this,k,m),typeof D=="function"&&f(this,ct,D),typeof g=="function"?(f(this,B,g),f(this,N,[])):(f(this,B,void 0),f(this,N,void 0)),f(this,tt,!!t(this,k)),f(this,Et,!!t(this,ct)),f(this,L,!!t(this,B)),this.noDisposeOnSet=!!b,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!Ot,this.ignoreFetchAbort=!!pt,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,Qt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Yt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,z)){let Lt="LRU_CACHE_UNBOUNDED";se(Lt)&&(Bt.add(Lt),Xt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Lt,bt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,P),autopurgeTimers:t(e,K),sizes:t(e,Q),keyMap:t(e,x),keyList:t(e,w),valList:t(e,p),next:t(e,V),prev:t(e,Y),get head(){return t(e,C)},get tail(){return t(e,I)},free:t(e,q),isBackgroundFetch:i=>{var s;return l(s=e,n,O).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return l(a=e,n,Mt).call(a,i,s,r,o)},moveToTail:i=>{var s;return l(s=e,n,wt).call(s,i)},indexes:i=>{var s;return l(s=e,n,at).call(s,i)},rindexes:i=>{var s;return l(s=e,n,ot).call(s,i)},isStale:i=>{var s;return t(s=e,W).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,R)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,mt)}get dispose(){return t(this,k)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,x).has(e)?1/0:0}*entries(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&t(this,w)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield [t(this,w)[e],t(this,p)[e]]);}*rentries(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&t(this,w)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield [t(this,w)[e],t(this,p)[e]]);}*keys(){for(let e of l(this,n,at).call(this)){let i=t(this,w)[e];i!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,ot).call(this)){let i=t(this,w)[e];i!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield i);}}*values(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}*rvalues(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}[(kt=Symbol.iterator,$t=Symbol.toStringTag,kt)](){return this.entries()}find(e,i={}){for(let s of l(this,n,at).call(this)){let r=t(this,p)[s],o=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,w)[s],this))return this.get(t(this,w)[s],i)}}forEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,p)[s],o=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,w)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,p)[s],o=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,w)[s],this);}}purgeStale(){let e=false;for(let i of l(this,n,ot).call(this,{allowStale:true}))t(this,W).call(this,i)&&(l(this,n,nt).call(this,t(this,w)[i],"expire"),e=true);return e}info(e){let i=t(this,x).get(e);if(i===void 0)return;let s=t(this,p)[i],r=l(this,n,O).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,P)&&t(this,Z)){let a=t(this,P)[i],h=t(this,Z)[i];if(a&&h){let c=a-(t(this,X).now()-h);o.ttl=c,o.start=Date.now();}}return t(this,Q)&&(o.size=t(this,Q)[i]),o}dump(){let e=[];for(let i of l(this,n,at).call(this,{allowStale:true})){let s=t(this,w)[i],r=t(this,p)[i],o=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,P)&&t(this,Z)){a.ttl=t(this,P)[i];let h=t(this,X).now()-t(this,Z)[i];a.start=Math.floor(Date.now()-h);}t(this,Q)&&(a.size=t(this,Q)[i]),e.unshift([s,a]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var b,T,E,A;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:m=this.noUpdateTTL}=s,D=t(this,xt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&D>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let g=t(this,R)===0?void 0:t(this,x).get(e);if(g===void 0)g=t(this,R)===0?t(this,I):t(this,q).length!==0?t(this,q).pop():t(this,R)===t(this,$)?l(this,n,Ct).call(this,false):t(this,R),t(this,w)[g]=e,t(this,p)[g]=i,t(this,x).set(e,g),t(this,V)[t(this,I)]=g,t(this,Y)[g]=t(this,I),f(this,I,g),It(this,R)._++,t(this,Tt).call(this,g,D,c),c&&(c.set="add"),m=false,t(this,Et)&&((b=t(this,ct))==null||b.call(this,i,e,"add"));else {l(this,n,wt).call(this,g);let y=t(this,p)[g];if(i!==y){if(t(this,lt)&&l(this,n,O).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:_}=y;_!==void 0&&!a&&(t(this,tt)&&((T=t(this,k))==null||T.call(this,_,e,"set")),t(this,L)&&t(this,N)?.push([_,e,"set"]));}else a||(t(this,tt)&&((E=t(this,k))==null||E.call(this,y,e,"set")),t(this,L)&&t(this,N)?.push([y,e,"set"]));if(t(this,ft).call(this,g),t(this,Tt).call(this,g,D,c),t(this,p)[g]=i,c){c.set="replace";let _=y&&l(this,n,O).call(this,y)?y.__staleWhileFetching:y;_!==void 0&&(c.oldValue=_);}}else c&&(c.set="update");t(this,Et)&&this.onInsert?.(i,e,i===y?"update":"replace");}if(r!==0&&!t(this,P)&&l(this,n,Yt).call(this),t(this,P)&&(m||t(this,vt).call(this,g,r,o),c&&t(this,it).call(this,c,g)),!a&&t(this,L)&&t(this,N)){let y=t(this,N),_;for(;_=y?.shift();)(A=t(this,B))==null||A.call(this,..._);}return this}pop(){var e;try{for(;t(this,R);){let i=t(this,p)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,O).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,L)&&t(this,N)){let i=t(this,N),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,x).get(e);if(o!==void 0){let a=t(this,p)[o];if(l(this,n,O).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,W).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,ut).call(this,o),r&&(r.has="hit",t(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,x).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let o=t(this,p)[r];return l(this,n,O).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:m=this.sizeCalculation,noUpdateTTL:D=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:b=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:E=this.allowStaleOnFetchAbort,context:A,forceRefresh:y=false,status:_,signal:M}=i;if(!t(this,lt))return _&&(_.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:_});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:c,sizeCalculation:m,noUpdateTTL:D,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:E,ignoreFetchAbort:T,status:_,signal:M},G=t(this,x).get(e);if(G===void 0){_&&(_.fetch="miss");let v=l(this,n,Mt).call(this,e,G,U,A);return v.__returned=v}else {let v=t(this,p)[G];if(l(this,n,O).call(this,v)){let _t=s&&v.__staleWhileFetching!==void 0;return _&&(_.fetch="inflight",_t&&(_.returnedStale=true)),_t?v.__staleWhileFetching:v.__returned=v}let Ot=t(this,W).call(this,G);if(!y&&!Ot)return _&&(_.fetch="hit"),l(this,n,wt).call(this,G),r&&t(this,ut).call(this,G),_&&t(this,it).call(this,_,G),v;let pt=l(this,n,Mt).call(this,e,G,U,A),gt=pt.__staleWhileFetching!==void 0&&s;return _&&(_.fetch=Ot?"stale":"refresh",gt&&Ot&&(_.returnedStale=true)),gt?pt.__staleWhileFetching:pt.__returned=pt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,mt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,h=this.get(e,a);if(!o&&h!==void 0)return h;let c=s(e,h,{options:a,context:r});return this.set(e,c,a),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,h=t(this,x).get(e);if(h!==void 0){let c=t(this,p)[h],m=l(this,n,O).call(this,c);return a&&t(this,it).call(this,a,h),t(this,W).call(this,h)?(a&&(a.get="stale"),m?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||l(this,n,nt).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),m?c.__staleWhileFetching:(l(this,n,wt).call(this,h),r&&t(this,ut).call(this,h),c))}else a&&(a.get="miss");}delete(e){return l(this,n,nt).call(this,e,"delete")}clear(){return l(this,n,Wt).call(this,"delete")}},$=new WeakMap,z=new WeakMap,k=new WeakMap,ct=new WeakMap,B=new WeakMap,St=new WeakMap,mt=new WeakMap,X=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,w=new WeakMap,p=new WeakMap,V=new WeakMap,Y=new WeakMap,C=new WeakMap,I=new WeakMap,q=new WeakMap,N=new WeakMap,Q=new WeakMap,Z=new WeakMap,P=new WeakMap,K=new WeakMap,tt=new WeakMap,lt=new WeakMap,L=new WeakMap,Et=new WeakMap,n=new WeakSet,Yt=function(){let e=new Ft(t(this,$)),i=new Ft(t(this,$));f(this,P,e),f(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,K,s),f(this,vt,(h,c,m=t(this,X).now())=>{i[h]=c!==0?m:0,e[h]=c,r(h,c);}),f(this,ut,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let m=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,w)[h],"expire");},c+1);m.unref&&m.unref(),s[h]=m;}}:()=>{};f(this,it,(h,c)=>{if(e[c]){let m=e[c],D=i[c];if(!m||!D)return;h.ttl=m,h.start=D,h.now=o||a();let g=h.now-D;h.remainingTTL=m-g;}});let o=0,a=()=>{let h=t(this,X).now();if(this.ttlResolution>0){o=h;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=t(this,x).get(h);if(c===void 0)return 0;let m=e[c],D=i[c];if(!m||!D)return 1/0;let g=(o||a())-D;return m-g},f(this,W,h=>{let c=i[h],m=e[h];return !!m&&!!c&&(o||a())-c>m});},ut=new WeakMap,it=new WeakMap,vt=new WeakMap,W=new WeakMap,Qt=function(){let e=new Ft(t(this,$));f(this,J,0),f(this,Q,e),f(this,ft,i=>{f(this,J,t(this,J)-e[i]),e[i]=0;}),f(this,xt,(i,s,r,o)=>{if(l(this,n,O).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),f(this,Tt,(i,s,r)=>{if(e[i]=s,t(this,z)){let o=t(this,z)-e[i];for(;t(this,J)>o;)l(this,n,Ct).call(this,true);}f(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},ft=new WeakMap,Tt=new WeakMap,xt=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,I);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,C)));)i=t(this,Y)[i];},ot=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,C);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,I)));)i=t(this,V)[i];},Pt=function(e){return e!==void 0&&t(this,x).get(t(this,w)[e])===e},Ct=function(e){var o;let i=t(this,C),s=t(this,w)[i],r=t(this,p)[i];return t(this,lt)&&l(this,n,O).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,L)&&t(this,N)?.push([r,s,"evict"])),t(this,ft).call(this,i),t(this,K)?.[i]&&(clearTimeout(t(this,K)[i]),t(this,K)[i]=void 0),e&&(t(this,w)[i]=void 0,t(this,p)[i]=void 0,t(this,q).push(i)),t(this,R)===1?(f(this,C,f(this,I,0)),t(this,q).length=0):f(this,C,t(this,V)[i]),t(this,x).delete(s),It(this,R)._--,i},Mt=function(e,i,s,r){let o=i===void 0?void 0:t(this,p)[i];if(l(this,n,O).call(this,o))return o;let a=new Gt,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},m=(A,y=false)=>{let{aborted:_}=a.signal,M=s.ignoreFetchAbort&&A!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&A!==void 0);if(s.status&&(_&&!y?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),_&&!M&&!y)return g(a.signal.reason,U);let G=T,v=t(this,p)[i];return (v===T||M&&y&&v===void 0)&&(A===void 0?G.__staleWhileFetching!==void 0?t(this,p)[i]=G.__staleWhileFetching:l(this,n,nt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,A,c.options))),A},D=A=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=A),g(A,false)),g=(A,y)=>{let{aborted:_}=a.signal,M=_&&s.allowStaleOnFetchAbort,U=M||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,v=T;if(t(this,p)[i]===T&&(!G||!y&&v.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):M||(t(this,p)[i]=v.__staleWhileFetching)),U)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw A},b=(A,y)=>{var M;let _=(M=t(this,St))==null?void 0:M.call(this,e,o,c);_&&_ instanceof Promise&&_.then(U=>A(U===void 0?void 0:U),y),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(A(void 0),s.allowStaleOnFetchAbort&&(A=U=>m(U,true)));});};s.status&&(s.status.fetchDispatched=true);let T=new Promise(b).then(m,D),E=Object.assign(T,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,E,{...c.options,status:void 0}),i=t(this,x).get(e)):t(this,p)[i]=E,E},O=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Kt=function(e,i){t(this,Y)[i]=e,t(this,V)[e]=i;},wt=function(e){e!==t(this,I)&&(e===t(this,C)?f(this,C,t(this,V)[e]):l(this,n,Kt).call(this,t(this,Y)[e],t(this,V)[e]),l(this,n,Kt).call(this,t(this,I),e),f(this,I,e));},nt=function(e,i){var r,o;let s=false;if(t(this,R)!==0){let a=t(this,x).get(e);if(a!==void 0)if(t(this,K)?.[a]&&(clearTimeout(t(this,K)?.[a]),t(this,K)[a]=void 0),s=true,t(this,R)===1)l(this,n,Wt).call(this,i);else {t(this,ft).call(this,a);let h=t(this,p)[a];if(l(this,n,O).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,L)&&t(this,N)?.push([h,e,i])),t(this,x).delete(e),t(this,w)[a]=void 0,t(this,p)[a]=void 0,a===t(this,I))f(this,I,t(this,Y)[a]);else if(a===t(this,C))f(this,C,t(this,V)[a]);else {let c=t(this,Y)[a];t(this,V)[c]=t(this,V)[a];let m=t(this,V)[a];t(this,Y)[m]=t(this,Y)[a];}It(this,R)._--,t(this,q).push(a);}}if(t(this,L)&&t(this,N)?.length){let a=t(this,N),h;for(;h=a?.shift();)(o=t(this,B))==null||o.call(this,...h);}return s},Wt=function(e){var i,s;for(let r of l(this,n,ot).call(this,{allowStale:true})){let o=t(this,p)[r];if(l(this,n,O).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,w)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,L)&&t(this,N)?.push([o,a,e]);}}if(t(this,x).clear(),t(this,p).fill(void 0),t(this,w).fill(void 0),t(this,P)&&t(this,Z)){t(this,P).fill(0),t(this,Z).fill(0);for(let r of t(this,K)??[])r!==void 0&&clearTimeout(r);t(this,K)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),f(this,C,0),f(this,I,0),t(this,q).length=0,f(this,J,0),f(this,R,0),t(this,L)&&t(this,N)){let r=t(this,N),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}},bt);var At=class{cache;map=new Map;constructor(e){this.cache=new qt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var yt;(r=>(r.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),r.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),r.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),r.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(yt||={});function Rt(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw yt.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Zt;(g=>{g.storage=new At({cacheSize:50}),g.defaultStorage=new At({cacheSize:10}),g.tempStorageDeadlines=new Map;let s;function r(b){g.tempStorageDeadlines.forEach((T,E)=>{T>b&&(g.storage.delete(`${ht}:${E}`),s?.onClearOldTempVariable?.(E),g.tempStorageDeadlines.delete(E));});}g.clearOldTempVariables=r;function o(b){s=b;}g.setExternalStoreHandler=o;function a(b,T,E){E==null?g.storage.delete(`${b}:${T}`):g.storage.set(`${b}:${T}`,E),s?.onSetVariable?.(T,E);}g.setVariable=a;function h(b,T){let E=g.storage.get(`${b}:${T}`);return Rt(E)}g.getVariable=h;function c(b,T){g.storage.delete(`${b}:${T}`),s?.onRemoveVariable?.(T);}g.removeVariable=c;function m(b,T){let E=g.storage.get(Nt)||[];if(T)E.includes(b)||E.push(b);else {let A=E.indexOf(b);A>-1&&E.splice(A,1);}g.storage.set(Nt,E);}g.setFlag=m;function D(b){return (g.storage.get(Nt)||[]).includes(b)}g.getFlag=D;})(Zt||={});var S=Zt;var Dt=class{get base(){return S.storage.map}get cache(){return S.storage.cache}get tempStorageDeadlines(){return S.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{S.defaultStorage.map.set(i,s);});}set(e,i){return S.setVariable(st,e,i)}get(e){let i=S.getVariable(ht,e);return i===void 0&&(i=S.getVariable(st,e)),i===void 0&&(i=Rt(S.defaultStorage.get(e))),i}remove(e){return this.removeTempVariable(e),S.removeVariable(st,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else S.setVariable(ht,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){S.removeVariable(ht,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return S.setFlag(e,i)}getFlag(e){return S.getFlag(e)}setStorageHandler(e){S.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...S.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Rt({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":S.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":S.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":S.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":S.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":S.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":S.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":S.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":S.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":S.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":S.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":S.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:S.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{S.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{S.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.tempStorageDeadlines.set(i.key,i.value);})):yt.warn("No storage data found");}catch(i){yt.error("Error importing data",i);}}};var Vt=class{constructor(e,i){this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=S.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{S.setVariable(this.categoryId,`${s}:${o}`,a);});}),S.removeVariable(st,e));}id;categoryId;setStorageProperty(e,i){S.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return S.getVariable(this.categoryId,`${i}:${e}`)}};var Me=new Dt;exports.StorageRegistry=S;exports.StoredClassModel=Vt;exports.storage=Me;
|
package/dist/storage.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as StorageRegistry,b as StoredClassModel,c as storage}from'./chunk-
|
|
1
|
+
export{a as StorageRegistry,b as StoredClassModel,c as storage}from'./chunk-GIYMPXBT.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-HQQ5WH6C.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drincs/pixi-vn",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pixi'VN is a npm package that provides various features for creating visual novels.",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"format": "biome format --write",
|
|
21
21
|
"test": "vitest",
|
|
22
22
|
"docs": "typedoc",
|
|
23
|
-
"sandbox": "npm run build &&
|
|
23
|
+
"sandbox": "npm run build && node scripts/sync-sandbox.mjs && npm run start --workspace=sandbox"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|