@drincs/pixi-vn 1.3.13 → 1.3.15
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/{classes/index.d.cts → CachedMap-DZLvJAnA.d.cts} +1 -1
- package/dist/{classes/index.d.ts → CachedMap-DZLvJAnA.d.ts} +1 -1
- package/dist/{OpenedLabel-DxlOwJKw.d.ts → HistoryChoiceMenuOption-BjnxDyK5.d.cts} +47 -2
- package/dist/{OpenedLabel-Dgkgemkv.d.cts → HistoryChoiceMenuOption-ZdrL_kYX.d.ts} +47 -2
- package/dist/{StorageElementType-DTGcnkzF.d.ts → StorageElementType-dAIVJeiw.d.cts} +1 -1
- package/dist/{StorageElementType-DTGcnkzF.d.cts → StorageElementType-dAIVJeiw.d.ts} +1 -1
- package/dist/history.cjs +1 -0
- package/dist/{history/index.d.ts → history.d.cts} +14 -8
- package/dist/{history/index.d.cts → history.d.ts} +14 -8
- package/dist/history.mjs +1 -0
- package/dist/index.cjs +143 -143
- package/dist/index.d.cts +3076 -216
- package/dist/index.d.ts +3076 -216
- package/dist/index.mjs +143 -143
- package/dist/narration.cjs +2 -0
- package/dist/{index-_rD16ks5.d.ts → narration.d.cts} +27 -44
- package/dist/{index-Bl9hiHQR.d.cts → narration.d.ts} +27 -44
- package/dist/narration.mjs +2 -0
- package/dist/storage.cjs +1 -0
- package/dist/{storage/index.d.ts → storage.d.cts} +75 -6
- package/dist/{storage/index.d.cts → storage.d.ts} +75 -6
- package/dist/storage.mjs +1 -0
- package/dist/unifier.cjs +1 -0
- package/dist/unifier.d.cts +230 -0
- package/dist/unifier.d.ts +230 -0
- package/dist/unifier.mjs +1 -0
- package/package.json +29 -2
- package/dist/ContainerMemory-CrY9QSo2.d.cts +0 -106
- package/dist/ContainerMemory-DrijxCcD.d.ts +0 -106
- package/dist/HistoryChoiceMenuOption-Kj_P28ke.d.ts +0 -49
- package/dist/HistoryChoiceMenuOption-unaLLfKR.d.cts +0 -49
- package/dist/HistoryGameState-i_gx3rGM.d.ts +0 -12
- package/dist/HistoryGameState-qeIMl_DH.d.cts +0 -12
- package/dist/NarrationGameState-CqDh48n_.d.ts +0 -24
- package/dist/NarrationGameState-Cu-OYzph.d.cts +0 -24
- package/dist/SoundGameState-BG_iPwjt.d.cts +0 -85
- package/dist/SoundGameState-BG_iPwjt.d.ts +0 -85
- package/dist/StorageGameState-B2kz-u_2.d.cts +0 -19
- package/dist/StorageGameState-Cnfj75sk.d.ts +0 -19
- package/dist/StoredClassModel-CjdhvNgB.d.cts +0 -56
- package/dist/StoredClassModel-CjdhvNgB.d.ts +0 -56
- package/dist/TickersSequence-Cf1Vcu22.d.cts +0 -133
- package/dist/TickersSequence-Cf1Vcu22.d.ts +0 -133
- package/dist/canvas/index.cjs +0 -3316
- package/dist/canvas/index.d.cts +0 -8
- package/dist/canvas/index.d.ts +0 -8
- package/dist/canvas/index.mjs +0 -3316
- package/dist/canvas/tickers/index.cjs +0 -3316
- package/dist/canvas/tickers/index.d.cts +0 -467
- package/dist/canvas/tickers/index.d.ts +0 -467
- package/dist/canvas/tickers/index.mjs +0 -3316
- package/dist/character/index.cjs +0 -572
- package/dist/character/index.d.cts +0 -3
- package/dist/character/index.d.ts +0 -3
- package/dist/character/index.mjs +0 -572
- package/dist/classes/index.cjs +0 -1
- package/dist/classes/index.mjs +0 -1
- package/dist/history/index.cjs +0 -1
- package/dist/history/index.mjs +0 -1
- package/dist/index-B4F3XaWz.d.cts +0 -1767
- package/dist/index-Cax-mGq_.d.cts +0 -216
- package/dist/index-Cvdua0o-.d.ts +0 -216
- package/dist/index-Czfdktw9.d.ts +0 -93
- package/dist/index-DZ1shoNp.d.cts +0 -93
- package/dist/index-DvpfJ2VQ.d.ts +0 -1767
- package/dist/interfaces/index.cjs +0 -1
- package/dist/interfaces/index.d.cts +0 -55
- package/dist/interfaces/index.d.ts +0 -55
- package/dist/interfaces/index.mjs +0 -0
- package/dist/narration/index.cjs +0 -573
- package/dist/narration/index.d.cts +0 -8
- package/dist/narration/index.d.ts +0 -8
- package/dist/narration/index.mjs +0 -573
- package/dist/sound/index.cjs +0 -572
- package/dist/sound/index.d.cts +0 -3
- package/dist/sound/index.d.ts +0 -3
- package/dist/sound/index.mjs +0 -572
- package/dist/storage/index.cjs +0 -1
- package/dist/storage/index.mjs +0 -1
- package/dist/utils/index.cjs +0 -1
- package/dist/utils/index.d.cts +0 -8
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.mjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChoiceInterface, CharacterInterface, GameStepState } from '@drincs/pixi-vn';
|
|
2
2
|
import deepDiff from 'deep-diff';
|
|
3
3
|
import { Difference } from 'microdiff';
|
|
4
|
-
import {
|
|
4
|
+
import { a as StorageElementType } from './StorageElementType-dAIVJeiw.cjs';
|
|
5
5
|
|
|
6
6
|
type CloseType = "close";
|
|
7
7
|
declare const Close: CloseType;
|
|
@@ -116,4 +116,49 @@ interface OpenedLabel {
|
|
|
116
116
|
currentStepIndex: number;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
interface NarrationHistory {
|
|
120
|
+
/**
|
|
121
|
+
* Dialogue to be shown in the game
|
|
122
|
+
*/
|
|
123
|
+
dialogue?: DialogueInterface;
|
|
124
|
+
/**
|
|
125
|
+
* List of choices asked of the player
|
|
126
|
+
*/
|
|
127
|
+
choices?: HistoryChoiceMenuOption[];
|
|
128
|
+
/**
|
|
129
|
+
* The player made a choice
|
|
130
|
+
*/
|
|
131
|
+
playerMadeChoice?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The index of the step in the history.
|
|
134
|
+
*/
|
|
135
|
+
stepIndex: number;
|
|
136
|
+
/**
|
|
137
|
+
* The input value of the player
|
|
138
|
+
*/
|
|
139
|
+
inputValue?: StorageElementType;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* HistoryChoiceMenuOption is a type that contains the history information of a choice menu option.
|
|
144
|
+
*/
|
|
145
|
+
type HistoryChoiceMenuOption = {
|
|
146
|
+
/**
|
|
147
|
+
* Text to be displayed in the menu
|
|
148
|
+
*/
|
|
149
|
+
text: string | string[];
|
|
150
|
+
/**
|
|
151
|
+
* Method used to open the label, or close the menu.
|
|
152
|
+
*/
|
|
153
|
+
type: CloseType | LabelRunModeType;
|
|
154
|
+
/**
|
|
155
|
+
* This choice is a response
|
|
156
|
+
*/
|
|
157
|
+
isResponse: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* The choice is hidden
|
|
160
|
+
*/
|
|
161
|
+
hidden: boolean;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export { type ChoiceOptionInterface as C, type DialogueInterface as D, type HistoryStep as H, type LabelIdType as L, type NarrationHistory as N, type OpenedLabel as O, type StoredIndexedChoiceInterface as S, type LabelRunModeType as a, type CloseChoiceOptionInterface as b, type CloseType as c, type StoredChoiceInterface as d, Close as e, type HistoryChoiceMenuOption as f };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChoiceInterface, CharacterInterface, GameStepState } from '@drincs/pixi-vn';
|
|
2
2
|
import deepDiff from 'deep-diff';
|
|
3
3
|
import { Difference } from 'microdiff';
|
|
4
|
-
import {
|
|
4
|
+
import { a as StorageElementType } from './StorageElementType-dAIVJeiw.js';
|
|
5
5
|
|
|
6
6
|
type CloseType = "close";
|
|
7
7
|
declare const Close: CloseType;
|
|
@@ -116,4 +116,49 @@ interface OpenedLabel {
|
|
|
116
116
|
currentStepIndex: number;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
interface NarrationHistory {
|
|
120
|
+
/**
|
|
121
|
+
* Dialogue to be shown in the game
|
|
122
|
+
*/
|
|
123
|
+
dialogue?: DialogueInterface;
|
|
124
|
+
/**
|
|
125
|
+
* List of choices asked of the player
|
|
126
|
+
*/
|
|
127
|
+
choices?: HistoryChoiceMenuOption[];
|
|
128
|
+
/**
|
|
129
|
+
* The player made a choice
|
|
130
|
+
*/
|
|
131
|
+
playerMadeChoice?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The index of the step in the history.
|
|
134
|
+
*/
|
|
135
|
+
stepIndex: number;
|
|
136
|
+
/**
|
|
137
|
+
* The input value of the player
|
|
138
|
+
*/
|
|
139
|
+
inputValue?: StorageElementType;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* HistoryChoiceMenuOption is a type that contains the history information of a choice menu option.
|
|
144
|
+
*/
|
|
145
|
+
type HistoryChoiceMenuOption = {
|
|
146
|
+
/**
|
|
147
|
+
* Text to be displayed in the menu
|
|
148
|
+
*/
|
|
149
|
+
text: string | string[];
|
|
150
|
+
/**
|
|
151
|
+
* Method used to open the label, or close the menu.
|
|
152
|
+
*/
|
|
153
|
+
type: CloseType | LabelRunModeType;
|
|
154
|
+
/**
|
|
155
|
+
* This choice is a response
|
|
156
|
+
*/
|
|
157
|
+
isResponse: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* The choice is hidden
|
|
160
|
+
*/
|
|
161
|
+
hidden: boolean;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export { type ChoiceOptionInterface as C, type DialogueInterface as D, type HistoryStep as H, type LabelIdType as L, type NarrationHistory as N, type OpenedLabel as O, type StoredIndexedChoiceInterface as S, type LabelRunModeType as a, type CloseChoiceOptionInterface as b, type CloseType as c, type StoredChoiceInterface as d, Close as e, type HistoryChoiceMenuOption as f };
|
|
@@ -11,4 +11,4 @@ type StorageElementType = StorageElementInternalType | Record<string | number |
|
|
|
11
11
|
*/
|
|
12
12
|
type StorageObjectType = Record<string | number | symbol, StorageElementType>;
|
|
13
13
|
|
|
14
|
-
export type {
|
|
14
|
+
export type { StorageObjectType as S, StorageElementType as a };
|
|
@@ -11,4 +11,4 @@ type StorageElementType = StorageElementInternalType | Record<string | number |
|
|
|
11
11
|
*/
|
|
12
12
|
type StorageObjectType = Record<string | number | symbol, StorageElementType>;
|
|
13
13
|
|
|
14
|
-
export type {
|
|
14
|
+
export type { StorageObjectType as S, StorageElementType as a };
|
package/dist/history.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var unifier=require('@drincs/pixi-vn/unifier');var Xt=Object.defineProperty;var jt=f=>{throw TypeError(f)};var Qt=(f,t,e)=>t in f?Xt(f,t,{enumerable:true,configurable:true,writable:true,value:e}):f[t]=e;var w=(f,t,e)=>Qt(f,typeof t!="symbol"?t+"":t,e),Nt=(f,t,e)=>t.has(f)||jt("Cannot "+e);var i=(f,t,e)=>(Nt(f,t,"read from private field"),e?e.call(f):t.get(f)),b=(f,t,e)=>t.has(f)?jt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,e),d=(f,t,e,s)=>(Nt(f,t,"write to private field"),t.set(f,e),e),c=(f,t,e)=>(Nt(f,t,"access private method"),e);var vt=(f,t,e,s)=>({set _(r){d(f,t,r);},get _(){return i(f,t,s)}});var Zt={Date:true,RegExp:true,String:true,Number:true};function Ot(f,t,e={cyclesFix:true},s=[]){let r=[],n=Array.isArray(f);for(let l in f){let h=f[l],y=n?+l:l;if(!(l in t)){r.push({type:"REMOVE",path:[y],oldValue:f[l]});continue}let m=t[l],S=typeof h=="object"&&typeof m=="object"&&Array.isArray(h)===Array.isArray(m);h&&m&&S&&!Zt[Object.getPrototypeOf(h)?.constructor?.name]&&(!e.cyclesFix||!s.includes(h))?r.push.apply(r,Ot(h,m,e,e.cyclesFix?s.concat([h]):[]).map(_=>(_.path.unshift(y),_))):h!==m&&!(Number.isNaN(h)&&Number.isNaN(m))&&!(S&&(isNaN(h)?h+""==m+"":+h==+m))&&r.push({path:[y],type:"CHANGE",value:m,oldValue:h});}let o=Array.isArray(t);for(let l in t)l in f||r.push({type:"CREATE",path:[o?+l:l],value:t[l]});return r}var x;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(x||(x={}));function Z(f){try{if(typeof f>"u")return f;let t=JSON.stringify(f);return JSON.parse(t)}catch(t){throw x.error("Error creating exportable element",f,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}function Ut(f,t){let e=Z(f);return t.length>1&&"type"in t[0]&&(t=t.reverse()),t.forEach(s=>{"type"in s?te(e,s):ee(e,s);}),e}function te(f,t){let e=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":e[s]=t.oldValue;break;case "CREATE":Array.isArray(e)&&typeof s=="number"?e.splice(s,1):delete e[s];break}else e=e[s];}):x.warn("No path found, skipping diff",t);}function ee(f,t){let e=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1){if(t.kind==="E"||t.kind==="D")e[s]=t.lhs;else if(t.kind==="N")Number.isInteger(s)?Array.isArray(e)&&e.splice(s,1):typeof s=="string"&&delete e[s];else if(t.kind==="A"){let n=t.index;t.item.kind==="N"?e[s].splice(n,1):t.item.kind==="E"||t.item.kind==="D"?e[s][n]=t.item.lhs:t.item.kind==="A"?x.warn("Nested array found, skipping diff",t):x.warn("No array found, skipping diff",t);}}else e=e[s];}):x.warn("No path found, skipping diff",t);}var dt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,$t=new Set,Rt=typeof process=="object"&&process?process:{},Yt=(f,t,e,s)=>{typeof Rt.emitWarning=="function"?Rt.emitWarning(f,t,e,s):console.error(`[${e}] ${t}: ${f}`);},zt=globalThis.AbortController,Pt=globalThis.AbortSignal;if(typeof zt>"u"){Pt=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},zt=class{constructor(){w(this,"signal",new Pt);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let f=Rt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=false,Yt("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 ie=f=>!$t.has(f),et=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Jt=f=>et(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?pt:null:null,pt=class extends Array{constructor(t){super(t),this.fill(0);}},gt,at=class at{constructor(t,e){w(this,"heap");w(this,"length");if(!i(at,gt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Jt(t);if(!e)return [];d(at,gt,true);let s=new at(t,e);return d(at,gt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};gt=new WeakMap,b(at,gt,false);var kt=at,Kt,Bt,U,M,P,ht,K,yt,mt,O,B,v,E,p,I,G,C,D,$,F,Y,J,L,q,nt,N,St,a,Mt,lt,tt,Et,W,qt,ft,bt,Ht,it,st,Gt,Dt,Ft,A,Lt,At,rt,Wt,Vt=class Vt{constructor(t){b(this,a);b(this,U);b(this,M);b(this,P);b(this,ht);b(this,K);b(this,yt);b(this,mt);w(this,"ttl");w(this,"ttlResolution");w(this,"ttlAutopurge");w(this,"updateAgeOnGet");w(this,"updateAgeOnHas");w(this,"allowStale");w(this,"noDisposeOnSet");w(this,"noUpdateTTL");w(this,"maxEntrySize");w(this,"sizeCalculation");w(this,"noDeleteOnFetchRejection");w(this,"noDeleteOnStaleGet");w(this,"allowStaleOnFetchAbort");w(this,"allowStaleOnFetchRejection");w(this,"ignoreFetchAbort");b(this,O);b(this,B);b(this,v);b(this,E);b(this,p);b(this,I);b(this,G);b(this,C);b(this,D);b(this,$);b(this,F);b(this,Y);b(this,J);b(this,L);b(this,q);b(this,nt);b(this,N);b(this,St);b(this,lt,()=>{});b(this,tt,()=>{});b(this,Et,()=>{});b(this,W,()=>false);b(this,ft,t=>{});b(this,bt,(t,e,s)=>{});b(this,Ht,(t,e,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,Kt,"LRUCache");let{max:e=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:h,dispose:y,onInsert:m,disposeAfter:S,noDisposeOnSet:_,noUpdateTTL:V,maxSize:Q=0,maxEntrySize:T=0,sizeCalculation:H,fetchMethod:g,memoMethod:R,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:z,allowStaleOnFetchRejection:j,allowStaleOnFetchAbort:_t,ignoreFetchAbort:ct}=t;if(e!==0&&!et(e))throw new TypeError("max option must be a nonnegative integer");let Tt=e?Jt(e):Array;if(!Tt)throw new Error("invalid max value: "+e);if(d(this,U,e),d(this,M,Q),this.maxEntrySize=T||i(this,M),this.sizeCalculation=H,this.sizeCalculation){if(!i(this,M)&&!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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(d(this,mt,R),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(d(this,yt,g),d(this,nt,!!g),d(this,v,new Map),d(this,E,new Array(e).fill(void 0)),d(this,p,new Array(e).fill(void 0)),d(this,I,new Tt(e)),d(this,G,new Tt(e)),d(this,C,0),d(this,D,0),d(this,$,kt.create(e)),d(this,O,0),d(this,B,0),typeof y=="function"&&d(this,P,y),typeof m=="function"&&d(this,ht,m),typeof S=="function"?(d(this,K,S),d(this,F,[])):(d(this,K,void 0),d(this,F,void 0)),d(this,q,!!i(this,P)),d(this,St,!!i(this,ht)),d(this,N,!!i(this,K)),this.noDisposeOnSet=!!_,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!j,this.allowStaleOnFetchAbort=!!_t,this.ignoreFetchAbort=!!ct,this.maxEntrySize!==0){if(i(this,M)!==0&&!et(i(this,M)))throw new TypeError("maxSize must be a positive integer if specified");if(!et(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,qt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!z,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=et(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!et(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,Mt).call(this);}if(i(this,U)===0&&this.ttl===0&&i(this,M)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,U)&&!i(this,M)){let ut="LRU_CACHE_UNBOUNDED";ie(ut)&&($t.add(ut),Yt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ut,Vt));}}static unsafeExposeInternals(t){return {starts:i(t,J),ttls:i(t,L),sizes:i(t,Y),keyMap:i(t,v),keyList:i(t,E),valList:i(t,p),next:i(t,I),prev:i(t,G),get head(){return i(t,C)},get tail(){return i(t,D)},free:i(t,$),isBackgroundFetch:e=>{var s;return c(s=t,a,A).call(s,e)},backgroundFetch:(e,s,r,n)=>{var o;return c(o=t,a,Ft).call(o,e,s,r,n)},moveToTail:e=>{var s;return c(s=t,a,At).call(s,e)},indexes:e=>{var s;return c(s=t,a,it).call(s,e)},rindexes:e=>{var s;return c(s=t,a,st).call(s,e)},isStale:e=>{var s;return i(s=t,W).call(s,e)}}}get max(){return i(this,U)}get maxSize(){return i(this,M)}get calculatedSize(){return i(this,B)}get size(){return i(this,O)}get fetchMethod(){return i(this,yt)}get memoMethod(){return i(this,mt)}get dispose(){return i(this,P)}get onInsert(){return i(this,ht)}get disposeAfter(){return i(this,K)}getRemainingTTL(t){return i(this,v).has(t)?1/0:0}*entries(){for(let t of c(this,a,it).call(this))i(this,p)[t]!==void 0&&i(this,E)[t]!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield [i(this,E)[t],i(this,p)[t]]);}*rentries(){for(let t of c(this,a,st).call(this))i(this,p)[t]!==void 0&&i(this,E)[t]!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield [i(this,E)[t],i(this,p)[t]]);}*keys(){for(let t of c(this,a,it).call(this)){let e=i(this,E)[t];e!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield e);}}*rkeys(){for(let t of c(this,a,st).call(this)){let e=i(this,E)[t];e!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield e);}}*values(){for(let t of c(this,a,it).call(this))i(this,p)[t]!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield i(this,p)[t]);}*rvalues(){for(let t of c(this,a,st).call(this))i(this,p)[t]!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield i(this,p)[t]);}[(Bt=Symbol.iterator,Kt=Symbol.toStringTag,Bt)](){return this.entries()}find(t,e={}){for(let s of c(this,a,it).call(this)){let r=i(this,p)[s],n=c(this,a,A).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&t(n,i(this,E)[s],this))return this.get(i(this,E)[s],e)}}forEach(t,e=this){for(let s of c(this,a,it).call(this)){let r=i(this,p)[s],n=c(this,a,A).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,i(this,E)[s],this);}}rforEach(t,e=this){for(let s of c(this,a,st).call(this)){let r=i(this,p)[s],n=c(this,a,A).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,i(this,E)[s],this);}}purgeStale(){let t=false;for(let e of c(this,a,st).call(this,{allowStale:true}))i(this,W).call(this,e)&&(c(this,a,rt).call(this,i(this,E)[e],"expire"),t=true);return t}info(t){let e=i(this,v).get(t);if(e===void 0)return;let s=i(this,p)[e],r=c(this,a,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(i(this,L)&&i(this,J)){let o=i(this,L)[e],l=i(this,J)[e];if(o&&l){let h=o-(dt.now()-l);n.ttl=h,n.start=Date.now();}}return i(this,Y)&&(n.size=i(this,Y)[e]),n}dump(){let t=[];for(let e of c(this,a,it).call(this,{allowStale:true})){let s=i(this,E)[e],r=i(this,p)[e],n=c(this,a,A).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(i(this,L)&&i(this,J)){o.ttl=i(this,L)[e];let l=dt.now()-i(this,J)[e];o.start=Math.floor(Date.now()-l);}i(this,Y)&&(o.size=i(this,Y)[e]),t.unshift([s,o]);}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let r=Date.now()-s.start;s.start=dt.now()-r;}this.set(e,s.value,s);}}set(t,e,s={}){var _,V,Q,T;if(e===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:h}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,m=i(this,Ht).call(this,t,e,s.size||0,l);if(this.maxEntrySize&&m>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),c(this,a,rt).call(this,t,"set"),this;let S=i(this,O)===0?void 0:i(this,v).get(t);if(S===void 0)S=i(this,O)===0?i(this,D):i(this,$).length!==0?i(this,$).pop():i(this,O)===i(this,U)?c(this,a,Dt).call(this,false):i(this,O),i(this,E)[S]=t,i(this,p)[S]=e,i(this,v).set(t,S),i(this,I)[i(this,D)]=S,i(this,G)[S]=i(this,D),d(this,D,S),vt(this,O)._++,i(this,bt).call(this,S,m,h),h&&(h.set="add"),y=false,i(this,St)&&((_=i(this,ht))==null||_.call(this,e,t,"add"));else {c(this,a,At).call(this,S);let H=i(this,p)[S];if(e!==H){if(i(this,nt)&&c(this,a,A).call(this,H)){H.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=H;g!==void 0&&!o&&(i(this,q)&&((V=i(this,P))==null||V.call(this,g,t,"set")),i(this,N)&&i(this,F)?.push([g,t,"set"]));}else o||(i(this,q)&&((Q=i(this,P))==null||Q.call(this,H,t,"set")),i(this,N)&&i(this,F)?.push([H,t,"set"]));if(i(this,ft).call(this,S),i(this,bt).call(this,S,m,h),i(this,p)[S]=e,h){h.set="replace";let g=H&&c(this,a,A).call(this,H)?H.__staleWhileFetching:H;g!==void 0&&(h.oldValue=g);}}else h&&(h.set="update");i(this,St)&&this.onInsert?.(e,t,e===H?"update":"replace");}if(r!==0&&!i(this,L)&&c(this,a,Mt).call(this),i(this,L)&&(y||i(this,Et).call(this,S,r,n),h&&i(this,tt).call(this,h,S)),!o&&i(this,N)&&i(this,F)){let H=i(this,F),g;for(;g=H?.shift();)(T=i(this,K))==null||T.call(this,...g);}return this}pop(){var t;try{for(;i(this,O);){let e=i(this,p)[i(this,C)];if(c(this,a,Dt).call(this,!0),c(this,a,A).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,N)&&i(this,F)){let e=i(this,F),s;for(;s=e?.shift();)(t=i(this,K))==null||t.call(this,...s);}}}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=e,n=i(this,v).get(t);if(n!==void 0){let o=i(this,p)[n];if(c(this,a,A).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(i(this,W).call(this,n))r&&(r.has="stale",i(this,tt).call(this,r,n));else return s&&i(this,lt).call(this,n),r&&(r.has="hit",i(this,tt).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(t,e={}){let{allowStale:s=this.allowStale}=e,r=i(this,v).get(t);if(r===void 0||!s&&i(this,W).call(this,r))return;let n=i(this,p)[r];return c(this,a,A).call(this,n)?n.__staleWhileFetching:n}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:h=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:Q=this.allowStaleOnFetchAbort,context:T,forceRefresh:H=false,status:g,signal:R}=e;if(!i(this,nt))return g&&(g.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let k={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:l,size:h,sizeCalculation:y,noUpdateTTL:m,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:Q,ignoreFetchAbort:V,status:g,signal:R},z=i(this,v).get(t);if(z===void 0){g&&(g.fetch="miss");let j=c(this,a,Ft).call(this,t,z,k,T);return j.__returned=j}else {let j=i(this,p)[z];if(c(this,a,A).call(this,j)){let It=s&&j.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",It&&(g.returnedStale=true)),It?j.__staleWhileFetching:j.__returned=j}let _t=i(this,W).call(this,z);if(!H&&!_t)return g&&(g.fetch="hit"),c(this,a,At).call(this,z),r&&i(this,lt).call(this,z),g&&i(this,tt).call(this,g,z),j;let ct=c(this,a,Ft).call(this,t,z,k,T),ut=ct.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=_t?"stale":"refresh",ut&&_t&&(g.returnedStale=true)),ut?ct.__staleWhileFetching:ct.__returned=ct}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=i(this,mt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=e,l=this.get(t,o);if(!n&&l!==void 0)return l;let h=s(t,l,{options:o,context:r});return this.set(t,h,o),h}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=e,l=i(this,v).get(t);if(l!==void 0){let h=i(this,p)[l],y=c(this,a,A).call(this,h);return o&&i(this,tt).call(this,o,l),i(this,W).call(this,l)?(o&&(o.get="stale"),y?(o&&s&&h.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?h.__staleWhileFetching:void 0):(n||c(this,a,rt).call(this,t,"expire"),o&&s&&(o.returnedStale=true),s?h:void 0)):(o&&(o.get="hit"),y?h.__staleWhileFetching:(c(this,a,At).call(this,l),r&&i(this,lt).call(this,l),h))}else o&&(o.get="miss");}delete(t){return c(this,a,rt).call(this,t,"delete")}clear(){return c(this,a,Wt).call(this,"delete")}};U=new WeakMap,M=new WeakMap,P=new WeakMap,ht=new WeakMap,K=new WeakMap,yt=new WeakMap,mt=new WeakMap,O=new WeakMap,B=new WeakMap,v=new WeakMap,E=new WeakMap,p=new WeakMap,I=new WeakMap,G=new WeakMap,C=new WeakMap,D=new WeakMap,$=new WeakMap,F=new WeakMap,Y=new WeakMap,J=new WeakMap,L=new WeakMap,q=new WeakMap,nt=new WeakMap,N=new WeakMap,St=new WeakMap,a=new WeakSet,Mt=function(){let t=new pt(i(this,U)),e=new pt(i(this,U));d(this,L,t),d(this,J,e),d(this,Et,(n,o,l=dt.now())=>{if(e[n]=o!==0?l:0,t[n]=o,o!==0&&this.ttlAutopurge){let h=setTimeout(()=>{i(this,W).call(this,n)&&c(this,a,rt).call(this,i(this,E)[n],"expire");},o+1);h.unref&&h.unref();}}),d(this,lt,n=>{e[n]=t[n]!==0?dt.now():0;}),d(this,tt,(n,o)=>{if(t[o]){let l=t[o],h=e[o];if(!l||!h)return;n.ttl=l,n.start=h,n.now=s||r();let y=n.now-h;n.remainingTTL=l-y;}});let s=0,r=()=>{let n=dt.now();if(this.ttlResolution>0){s=n;let o=setTimeout(()=>s=0,this.ttlResolution);o.unref&&o.unref();}return n};this.getRemainingTTL=n=>{let o=i(this,v).get(n);if(o===void 0)return 0;let l=t[o],h=e[o];if(!l||!h)return 1/0;let y=(s||r())-h;return l-y},d(this,W,n=>{let o=e[n],l=t[n];return !!l&&!!o&&(s||r())-o>l});},lt=new WeakMap,tt=new WeakMap,Et=new WeakMap,W=new WeakMap,qt=function(){let t=new pt(i(this,U));d(this,B,0),d(this,Y,t),d(this,ft,e=>{d(this,B,i(this,B)-t[e]),t[e]=0;}),d(this,Ht,(e,s,r,n)=>{if(c(this,a,A).call(this,s))return 0;if(!et(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,e),!et(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}),d(this,bt,(e,s,r)=>{if(t[e]=s,i(this,M)){let n=i(this,M)-t[e];for(;i(this,B)>n;)c(this,a,Dt).call(this,true);}d(this,B,i(this,B)+t[e]),r&&(r.entrySize=s,r.totalCalculatedSize=i(this,B));});},ft=new WeakMap,bt=new WeakMap,Ht=new WeakMap,it=function*({allowStale:t=this.allowStale}={}){if(i(this,O))for(let e=i(this,D);!(!c(this,a,Gt).call(this,e)||((t||!i(this,W).call(this,e))&&(yield e),e===i(this,C)));)e=i(this,G)[e];},st=function*({allowStale:t=this.allowStale}={}){if(i(this,O))for(let e=i(this,C);!(!c(this,a,Gt).call(this,e)||((t||!i(this,W).call(this,e))&&(yield e),e===i(this,D)));)e=i(this,I)[e];},Gt=function(t){return t!==void 0&&i(this,v).get(i(this,E)[t])===t},Dt=function(t){var n;let e=i(this,C),s=i(this,E)[e],r=i(this,p)[e];return i(this,nt)&&c(this,a,A).call(this,r)?r.__abortController.abort(new Error("evicted")):(i(this,q)||i(this,N))&&(i(this,q)&&((n=i(this,P))==null||n.call(this,r,s,"evict")),i(this,N)&&i(this,F)?.push([r,s,"evict"])),i(this,ft).call(this,e),t&&(i(this,E)[e]=void 0,i(this,p)[e]=void 0,i(this,$).push(e)),i(this,O)===1?(d(this,C,d(this,D,0)),i(this,$).length=0):d(this,C,i(this,I)[e]),i(this,v).delete(s),vt(this,O)._--,e},Ft=function(t,e,s,r){let n=e===void 0?void 0:i(this,p)[e];if(c(this,a,A).call(this,n))return n;let o=new zt,{signal:l}=s;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let h={signal:o.signal,options:s,context:r},y=(T,H=false)=>{let{aborted:g}=o.signal,R=s.ignoreFetchAbort&&T!==void 0;if(s.status&&(g&&!H?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,R&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!R&&!H)return S(o.signal.reason);let k=V;return i(this,p)[e]===V&&(T===void 0?k.__staleWhileFetching?i(this,p)[e]=k.__staleWhileFetching:c(this,a,rt).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,T,h.options))),T},m=T=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=T),S(T)),S=T=>{let{aborted:H}=o.signal,g=H&&s.allowStaleOnFetchAbort,R=g||s.allowStaleOnFetchRejection,k=R||s.noDeleteOnFetchRejection,z=V;if(i(this,p)[e]===V&&(!k||z.__staleWhileFetching===void 0?c(this,a,rt).call(this,t,"fetch"):g||(i(this,p)[e]=z.__staleWhileFetching)),R)return s.status&&z.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),z.__staleWhileFetching;if(z.__returned===z)throw T},_=(T,H)=>{var R;let g=(R=i(this,yt))==null?void 0:R.call(this,t,n,h);g&&g instanceof Promise&&g.then(k=>T(k===void 0?void 0:k),H),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(T(void 0),s.allowStaleOnFetchAbort&&(T=k=>y(k,true)));});};s.status&&(s.status.fetchDispatched=true);let V=new Promise(_).then(y,m),Q=Object.assign(V,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,Q,{...h.options,status:void 0}),e=i(this,v).get(t)):i(this,p)[e]=Q,Q},A=function(t){if(!i(this,nt))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof zt},Lt=function(t,e){i(this,G)[e]=t,i(this,I)[t]=e;},At=function(t){t!==i(this,D)&&(t===i(this,C)?d(this,C,i(this,I)[t]):c(this,a,Lt).call(this,i(this,G)[t],i(this,I)[t]),c(this,a,Lt).call(this,i(this,D),t),d(this,D,t));},rt=function(t,e){var r,n;let s=false;if(i(this,O)!==0){let o=i(this,v).get(t);if(o!==void 0)if(s=true,i(this,O)===1)c(this,a,Wt).call(this,e);else {i(this,ft).call(this,o);let l=i(this,p)[o];if(c(this,a,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(i(this,q)||i(this,N))&&(i(this,q)&&((r=i(this,P))==null||r.call(this,l,t,e)),i(this,N)&&i(this,F)?.push([l,t,e])),i(this,v).delete(t),i(this,E)[o]=void 0,i(this,p)[o]=void 0,o===i(this,D))d(this,D,i(this,G)[o]);else if(o===i(this,C))d(this,C,i(this,I)[o]);else {let h=i(this,G)[o];i(this,I)[h]=i(this,I)[o];let y=i(this,I)[o];i(this,G)[y]=i(this,G)[o];}vt(this,O)._--,i(this,$).push(o);}}if(i(this,N)&&i(this,F)?.length){let o=i(this,F),l;for(;l=o?.shift();)(n=i(this,K))==null||n.call(this,...l);}return s},Wt=function(t){var e,s;for(let r of c(this,a,st).call(this,{allowStale:true})){let n=i(this,p)[r];if(c(this,a,A).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=i(this,E)[r];i(this,q)&&((e=i(this,P))==null||e.call(this,n,o,t)),i(this,N)&&i(this,F)?.push([n,o,t]);}}if(i(this,v).clear(),i(this,p).fill(void 0),i(this,E).fill(void 0),i(this,L)&&i(this,J)&&(i(this,L).fill(0),i(this,J).fill(0)),i(this,Y)&&i(this,Y).fill(0),d(this,C,0),d(this,D,0),i(this,$).length=0,d(this,B,0),d(this,O,0),i(this,N)&&i(this,F)){let r=i(this,F),n;for(;n=r?.shift();)(s=i(this,K))==null||s.call(this,...n);}};var Ct=Vt;var ot=class{constructor(t){w(this,"cache");w(this,"map",new Map);this.cache=new Ct({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return 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 X=class X{static get originalStepData(){return X._originalStepData?Z(X._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){X._originalStepData=Z(t);}};w(X,"_diffHistory",new ot({cacheSize:5})),w(X,"_stepsInfoHistory",new ot({cacheSize:5})),w(X,"_narrationHistory",new ot({cacheSize:50})),w(X,"stepLimitSaved",20),w(X,"goBackRunning",false),w(X,"_originalStepData");var u=X;var xt=class{get stepsInfoMap(){return u._stepsInfoHistory}get diffMap(){return u._diffHistory}get narrationMap(){return u._narrationHistory}get size(){return u._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return u._stepsInfoHistory.keys()}get(t){let e=u._narrationHistory.get(t);if(!(e&&Object.keys(e).length===1&&e.stepIndex!==void 0))return e}delete(t){u._stepsInfoHistory.delete(t),u._diffHistory.delete(t),u._narrationHistory.delete(t);}internalRestoreOldGameState(t,e){if(t<=0||this.size==0)return e;let s=this.lastKey;if(typeof s!="number")return x.error("You can't go back, there is no step to go back"),e;let r=u._diffHistory.get(s);if(r)try{let n=Ut(e,r);return unifier.GameUnifier.stepCounter=s,this.delete(s),this.internalRestoreOldGameState(t-1,n)}catch(n){return x.error("Error applying diff",n),e}else return x.error("You can't go back, there is no step to go back"),e}async goBack(t,e=1){if(e<=0){x.warn("The parameter steps must be greater than 0");return}if(u._diffHistory.size<1){x.warn("You can't go back, there is no step to go back");return}if(u.goBackRunning){x.warn("Go back is already running");return}u.goBackRunning=true;try{let s=Z(this.internalRestoreOldGameState(e,u.originalStepData));if(s){await unifier.GameUnifier.restoreGameStepState(s,t);let r=unifier.GameUnifier.stepCounter-1,n=u._narrationHistory.get(r);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let o=u._stepsInfoHistory.get(r);if(o){let l=this.itemMapper({step:o});u._narrationHistory.set(o.index,l);}}}else x.error("Error going back");u.originalStepData=s,u.goBackRunning=!1;}catch(s){x.error("Error going back",s),u.goBackRunning=false;}}add(t,e={}){let s=u.originalStepData,{ignoreSameStep:r}=e,n=unifier.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,n))return;let o=this.lastKey;(async()=>{try{let h,y;if(typeof o=="number"&&(h=u._stepsInfoHistory.get(o),y=u._narrationHistory.get(o)),u._stepsInfoHistory.set(t.index,t),t.index!==0){let _=Ot(s,n);_?u._diffHistory.set(t.index,_):x.warn("It was not possible to create the difference between the two steps");}let m={},S=this.itemMapper({step:t},m);if(u._narrationHistory.set(t.index,S),h&&y&&typeof o=="number"){let _=this.itemMapper({...m,step:h},{});u._narrationHistory.set(o,_);}}catch(h){x.error("Error adding history step",h);}})(),u.originalStepData=n;}itemMapper(t,e){let{step:s,choiceIndexMade:r,inputValue:n,removeDialogue:o}=t,l=s.dialogue||s.dialoge;e&&s.isGlued&&(e.removeDialogue=true),o&&(l=void 0);let h=s.choices;if(e&&s.currentLabel&&s.choiceIndexMade!==void 0&&(e.choiceIndexMade=s.choiceIndexMade),s.inputValue&&e&&(e.inputValue=s.inputValue),l||h||n){let y=h?.map((m,S)=>{let _=false;return m.oneTime&&s.alreadyMadeChoices&&s.alreadyMadeChoices.includes(S)&&(_=true),{text:m.text,type:m.type,isResponse:false,hidden:_}});if(y){if(y.every(m=>m.hidden)){let m=y.find(S=>S.hidden===false);m&&(m.hidden=false);}r!==void 0&&(y[r].isResponse=true);}return {dialogue:l?{...l,character:l.character?unifier.GameUnifier.getCharacter(l.character)||l.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:y,stepIndex:s.index,inputValue:n}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],e=Array.from(this.keys()).sort((h,y)=>y-h);if(e.length===0)return t;let s=e[0];if(typeof s!="number")return t;let r=u._stepsInfoHistory.get(s);if(!r)return t;let n=r.openedLabels;if(!n||!Array.isArray(n)||n.length===0)return t;let o=n[0].currentStepIndex,l=n[0].label;return e.every((h,y)=>{let m=this.get(h);if(m){if(y===0)return t.push(m),true;let S=u._stepsInfoHistory.get(h);if(!S)return true;let _=S.openedLabels;if(!_||!Array.isArray(_)||_.length===0||_[0].label!==l||_[0].currentStepIndex>=o)return false;o=_[0].currentStepIndex,t.push(m);}return true}),t.reverse()}removeNarrativeHistory(t){if(t){let e=Array.from(this.keys()).sort((s,r)=>s-r);e=e.slice(0,t),e.forEach(s=>{u._narrationHistory.delete(s),u._stepsInfoHistory.delete(s),u._diffHistory.delete(s);});}else u._stepsInfoHistory.clear(),u._diffHistory.clear(),u._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:u._diffHistory.has(t)}blockGoBack(){unifier.GameUnifier.currentStepsRunningNumber===0&&u._diffHistory.clear();}isSameStep(t,e){if(t.openedLabels.length===e.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(e.openedLabels);if(s===r&&t.path===e.path&&t.labelIndex===e.labelIndex)return !0}catch(s){return x.error("Error comparing opened labels",s),true}return false}clear(){u._stepsInfoHistory.clear(),u._diffHistory.clear(),u._narrationHistory.clear(),u._originalStepData=void 0;}get stepLimitSaved(){return u.stepLimitSaved}set stepLimitSaved(t){u.stepLimitSaved=t;}export(){let t=Array.from(this.keys()).sort((s,r)=>s-r);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let e=[];return t.forEach(s=>{let r=u._stepsInfoHistory.get(s);if(r){let n=u._diffHistory.get(s);e.push({...r,diff:n});}}),{stepsHistory:Z(e),originalStepData:Z(u._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),e={};t.forEach(s=>{let r=u._stepsInfoHistory.get(s);if(r){let n={...e};e={};let o=this.itemMapper({step:r,choiceIndexMade:n.choiceIndexMade,inputValue:n.inputValue,removeDialogue:n.removeDialogue},e);o&&u._narrationHistory.set(s,o);}});}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&u._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};u._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):x.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?u._originalStepData=t.originalStepData:x.warn("Could not import originalStepData data, so will be ignored");}catch(e){x.error("Error importing data",e);}}};var Re=new xt;exports.HistoryManagerStatic=u;exports.stepHistory=Re;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GameStepState, HistoryInfo } from '@drincs/pixi-vn';
|
|
2
2
|
import deepDiff from 'deep-diff';
|
|
3
3
|
import { Difference } from 'microdiff';
|
|
4
|
-
import { CachedMap } from '
|
|
5
|
-
import { H as
|
|
6
|
-
import { H as HistoryStep } from '../OpenedLabel-DxlOwJKw.js';
|
|
7
|
-
import { N as NarrationHistory } from '../HistoryChoiceMenuOption-Kj_P28ke.js';
|
|
4
|
+
import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
|
|
5
|
+
import { H as HistoryStep, N as NarrationHistory } from './HistoryChoiceMenuOption-BjnxDyK5.cjs';
|
|
8
6
|
import 'lru-cache';
|
|
9
|
-
import '
|
|
7
|
+
import './StorageElementType-dAIVJeiw.cjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Interface exported step data
|
|
11
|
+
*/
|
|
12
|
+
interface HistoryGameState {
|
|
13
|
+
stepsHistory: HistoryStep[];
|
|
14
|
+
originalStepData: GameStepState | undefined;
|
|
15
|
+
}
|
|
10
16
|
|
|
11
17
|
interface HistoryManagerInterface {
|
|
12
18
|
/**
|
|
@@ -131,7 +137,7 @@ interface HistoryManagerInterface {
|
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
declare class HistoryManagerStatic {
|
|
134
|
-
static _diffHistory: CachedMap<number, deepDiff.Diff<GameStepState, GameStepState>[]
|
|
140
|
+
static _diffHistory: CachedMap<number, Difference[] | deepDiff.Diff<GameStepState, GameStepState>[]>;
|
|
135
141
|
static _stepsInfoHistory: CachedMap<number, Omit<HistoryStep, "diff">>;
|
|
136
142
|
static _narrationHistory: CachedMap<number, NarrationHistory>;
|
|
137
143
|
static stepLimitSaved: number;
|
|
@@ -146,4 +152,4 @@ declare class HistoryManagerStatic {
|
|
|
146
152
|
|
|
147
153
|
declare const stepHistory: HistoryManagerInterface;
|
|
148
154
|
|
|
149
|
-
export { HistoryGameState, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };
|
|
155
|
+
export { type HistoryGameState, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GameStepState, HistoryInfo } from '@drincs/pixi-vn';
|
|
2
2
|
import deepDiff from 'deep-diff';
|
|
3
3
|
import { Difference } from 'microdiff';
|
|
4
|
-
import { CachedMap } from '
|
|
5
|
-
import { H as
|
|
6
|
-
import { H as HistoryStep } from '../OpenedLabel-Dgkgemkv.cjs';
|
|
7
|
-
import { N as NarrationHistory } from '../HistoryChoiceMenuOption-unaLLfKR.cjs';
|
|
4
|
+
import { C as CachedMap } from './CachedMap-DZLvJAnA.js';
|
|
5
|
+
import { H as HistoryStep, N as NarrationHistory } from './HistoryChoiceMenuOption-ZdrL_kYX.js';
|
|
8
6
|
import 'lru-cache';
|
|
9
|
-
import '
|
|
7
|
+
import './StorageElementType-dAIVJeiw.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Interface exported step data
|
|
11
|
+
*/
|
|
12
|
+
interface HistoryGameState {
|
|
13
|
+
stepsHistory: HistoryStep[];
|
|
14
|
+
originalStepData: GameStepState | undefined;
|
|
15
|
+
}
|
|
10
16
|
|
|
11
17
|
interface HistoryManagerInterface {
|
|
12
18
|
/**
|
|
@@ -131,7 +137,7 @@ interface HistoryManagerInterface {
|
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
declare class HistoryManagerStatic {
|
|
134
|
-
static _diffHistory: CachedMap<number, deepDiff.Diff<GameStepState, GameStepState>[]
|
|
140
|
+
static _diffHistory: CachedMap<number, Difference[] | deepDiff.Diff<GameStepState, GameStepState>[]>;
|
|
135
141
|
static _stepsInfoHistory: CachedMap<number, Omit<HistoryStep, "diff">>;
|
|
136
142
|
static _narrationHistory: CachedMap<number, NarrationHistory>;
|
|
137
143
|
static stepLimitSaved: number;
|
|
@@ -146,4 +152,4 @@ declare class HistoryManagerStatic {
|
|
|
146
152
|
|
|
147
153
|
declare const stepHistory: HistoryManagerInterface;
|
|
148
154
|
|
|
149
|
-
export { HistoryGameState, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };
|
|
155
|
+
export { type HistoryGameState, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };
|
package/dist/history.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {GameUnifier}from'@drincs/pixi-vn/unifier';var Xt=Object.defineProperty;var jt=f=>{throw TypeError(f)};var Qt=(f,t,e)=>t in f?Xt(f,t,{enumerable:true,configurable:true,writable:true,value:e}):f[t]=e;var w=(f,t,e)=>Qt(f,typeof t!="symbol"?t+"":t,e),Nt=(f,t,e)=>t.has(f)||jt("Cannot "+e);var i=(f,t,e)=>(Nt(f,t,"read from private field"),e?e.call(f):t.get(f)),b=(f,t,e)=>t.has(f)?jt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,e),d=(f,t,e,s)=>(Nt(f,t,"write to private field"),t.set(f,e),e),c=(f,t,e)=>(Nt(f,t,"access private method"),e);var vt=(f,t,e,s)=>({set _(r){d(f,t,r);},get _(){return i(f,t,s)}});var Zt={Date:true,RegExp:true,String:true,Number:true};function Ot(f,t,e={cyclesFix:true},s=[]){let r=[],n=Array.isArray(f);for(let l in f){let h=f[l],y=n?+l:l;if(!(l in t)){r.push({type:"REMOVE",path:[y],oldValue:f[l]});continue}let m=t[l],S=typeof h=="object"&&typeof m=="object"&&Array.isArray(h)===Array.isArray(m);h&&m&&S&&!Zt[Object.getPrototypeOf(h)?.constructor?.name]&&(!e.cyclesFix||!s.includes(h))?r.push.apply(r,Ot(h,m,e,e.cyclesFix?s.concat([h]):[]).map(_=>(_.path.unshift(y),_))):h!==m&&!(Number.isNaN(h)&&Number.isNaN(m))&&!(S&&(isNaN(h)?h+""==m+"":+h==+m))&&r.push({path:[y],type:"CHANGE",value:m,oldValue:h});}let o=Array.isArray(t);for(let l in t)l in f||r.push({type:"CREATE",path:[o?+l:l],value:t[l]});return r}var x;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(x||(x={}));function Z(f){try{if(typeof f>"u")return f;let t=JSON.stringify(f);return JSON.parse(t)}catch(t){throw x.error("Error creating exportable element",f,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}function Ut(f,t){let e=Z(f);return t.length>1&&"type"in t[0]&&(t=t.reverse()),t.forEach(s=>{"type"in s?te(e,s):ee(e,s);}),e}function te(f,t){let e=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":e[s]=t.oldValue;break;case "CREATE":Array.isArray(e)&&typeof s=="number"?e.splice(s,1):delete e[s];break}else e=e[s];}):x.warn("No path found, skipping diff",t);}function ee(f,t){let e=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1){if(t.kind==="E"||t.kind==="D")e[s]=t.lhs;else if(t.kind==="N")Number.isInteger(s)?Array.isArray(e)&&e.splice(s,1):typeof s=="string"&&delete e[s];else if(t.kind==="A"){let n=t.index;t.item.kind==="N"?e[s].splice(n,1):t.item.kind==="E"||t.item.kind==="D"?e[s][n]=t.item.lhs:t.item.kind==="A"?x.warn("Nested array found, skipping diff",t):x.warn("No array found, skipping diff",t);}}else e=e[s];}):x.warn("No path found, skipping diff",t);}var dt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,$t=new Set,Rt=typeof process=="object"&&process?process:{},Yt=(f,t,e,s)=>{typeof Rt.emitWarning=="function"?Rt.emitWarning(f,t,e,s):console.error(`[${e}] ${t}: ${f}`);},zt=globalThis.AbortController,Pt=globalThis.AbortSignal;if(typeof zt>"u"){Pt=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},zt=class{constructor(){w(this,"signal",new Pt);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let f=Rt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=false,Yt("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 ie=f=>!$t.has(f),et=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Jt=f=>et(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?pt:null:null,pt=class extends Array{constructor(t){super(t),this.fill(0);}},gt,at=class at{constructor(t,e){w(this,"heap");w(this,"length");if(!i(at,gt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Jt(t);if(!e)return [];d(at,gt,true);let s=new at(t,e);return d(at,gt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};gt=new WeakMap,b(at,gt,false);var kt=at,Kt,Bt,U,M,P,ht,K,yt,mt,O,B,v,E,p,I,G,C,D,$,F,Y,J,L,q,nt,N,St,a,Mt,lt,tt,Et,W,qt,ft,bt,Ht,it,st,Gt,Dt,Ft,A,Lt,At,rt,Wt,Vt=class Vt{constructor(t){b(this,a);b(this,U);b(this,M);b(this,P);b(this,ht);b(this,K);b(this,yt);b(this,mt);w(this,"ttl");w(this,"ttlResolution");w(this,"ttlAutopurge");w(this,"updateAgeOnGet");w(this,"updateAgeOnHas");w(this,"allowStale");w(this,"noDisposeOnSet");w(this,"noUpdateTTL");w(this,"maxEntrySize");w(this,"sizeCalculation");w(this,"noDeleteOnFetchRejection");w(this,"noDeleteOnStaleGet");w(this,"allowStaleOnFetchAbort");w(this,"allowStaleOnFetchRejection");w(this,"ignoreFetchAbort");b(this,O);b(this,B);b(this,v);b(this,E);b(this,p);b(this,I);b(this,G);b(this,C);b(this,D);b(this,$);b(this,F);b(this,Y);b(this,J);b(this,L);b(this,q);b(this,nt);b(this,N);b(this,St);b(this,lt,()=>{});b(this,tt,()=>{});b(this,Et,()=>{});b(this,W,()=>false);b(this,ft,t=>{});b(this,bt,(t,e,s)=>{});b(this,Ht,(t,e,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,Kt,"LRUCache");let{max:e=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:h,dispose:y,onInsert:m,disposeAfter:S,noDisposeOnSet:_,noUpdateTTL:V,maxSize:Q=0,maxEntrySize:T=0,sizeCalculation:H,fetchMethod:g,memoMethod:R,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:z,allowStaleOnFetchRejection:j,allowStaleOnFetchAbort:_t,ignoreFetchAbort:ct}=t;if(e!==0&&!et(e))throw new TypeError("max option must be a nonnegative integer");let Tt=e?Jt(e):Array;if(!Tt)throw new Error("invalid max value: "+e);if(d(this,U,e),d(this,M,Q),this.maxEntrySize=T||i(this,M),this.sizeCalculation=H,this.sizeCalculation){if(!i(this,M)&&!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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(d(this,mt,R),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(d(this,yt,g),d(this,nt,!!g),d(this,v,new Map),d(this,E,new Array(e).fill(void 0)),d(this,p,new Array(e).fill(void 0)),d(this,I,new Tt(e)),d(this,G,new Tt(e)),d(this,C,0),d(this,D,0),d(this,$,kt.create(e)),d(this,O,0),d(this,B,0),typeof y=="function"&&d(this,P,y),typeof m=="function"&&d(this,ht,m),typeof S=="function"?(d(this,K,S),d(this,F,[])):(d(this,K,void 0),d(this,F,void 0)),d(this,q,!!i(this,P)),d(this,St,!!i(this,ht)),d(this,N,!!i(this,K)),this.noDisposeOnSet=!!_,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!j,this.allowStaleOnFetchAbort=!!_t,this.ignoreFetchAbort=!!ct,this.maxEntrySize!==0){if(i(this,M)!==0&&!et(i(this,M)))throw new TypeError("maxSize must be a positive integer if specified");if(!et(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,qt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!z,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=et(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!et(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,Mt).call(this);}if(i(this,U)===0&&this.ttl===0&&i(this,M)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,U)&&!i(this,M)){let ut="LRU_CACHE_UNBOUNDED";ie(ut)&&($t.add(ut),Yt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ut,Vt));}}static unsafeExposeInternals(t){return {starts:i(t,J),ttls:i(t,L),sizes:i(t,Y),keyMap:i(t,v),keyList:i(t,E),valList:i(t,p),next:i(t,I),prev:i(t,G),get head(){return i(t,C)},get tail(){return i(t,D)},free:i(t,$),isBackgroundFetch:e=>{var s;return c(s=t,a,A).call(s,e)},backgroundFetch:(e,s,r,n)=>{var o;return c(o=t,a,Ft).call(o,e,s,r,n)},moveToTail:e=>{var s;return c(s=t,a,At).call(s,e)},indexes:e=>{var s;return c(s=t,a,it).call(s,e)},rindexes:e=>{var s;return c(s=t,a,st).call(s,e)},isStale:e=>{var s;return i(s=t,W).call(s,e)}}}get max(){return i(this,U)}get maxSize(){return i(this,M)}get calculatedSize(){return i(this,B)}get size(){return i(this,O)}get fetchMethod(){return i(this,yt)}get memoMethod(){return i(this,mt)}get dispose(){return i(this,P)}get onInsert(){return i(this,ht)}get disposeAfter(){return i(this,K)}getRemainingTTL(t){return i(this,v).has(t)?1/0:0}*entries(){for(let t of c(this,a,it).call(this))i(this,p)[t]!==void 0&&i(this,E)[t]!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield [i(this,E)[t],i(this,p)[t]]);}*rentries(){for(let t of c(this,a,st).call(this))i(this,p)[t]!==void 0&&i(this,E)[t]!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield [i(this,E)[t],i(this,p)[t]]);}*keys(){for(let t of c(this,a,it).call(this)){let e=i(this,E)[t];e!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield e);}}*rkeys(){for(let t of c(this,a,st).call(this)){let e=i(this,E)[t];e!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield e);}}*values(){for(let t of c(this,a,it).call(this))i(this,p)[t]!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield i(this,p)[t]);}*rvalues(){for(let t of c(this,a,st).call(this))i(this,p)[t]!==void 0&&!c(this,a,A).call(this,i(this,p)[t])&&(yield i(this,p)[t]);}[(Bt=Symbol.iterator,Kt=Symbol.toStringTag,Bt)](){return this.entries()}find(t,e={}){for(let s of c(this,a,it).call(this)){let r=i(this,p)[s],n=c(this,a,A).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&t(n,i(this,E)[s],this))return this.get(i(this,E)[s],e)}}forEach(t,e=this){for(let s of c(this,a,it).call(this)){let r=i(this,p)[s],n=c(this,a,A).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,i(this,E)[s],this);}}rforEach(t,e=this){for(let s of c(this,a,st).call(this)){let r=i(this,p)[s],n=c(this,a,A).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,i(this,E)[s],this);}}purgeStale(){let t=false;for(let e of c(this,a,st).call(this,{allowStale:true}))i(this,W).call(this,e)&&(c(this,a,rt).call(this,i(this,E)[e],"expire"),t=true);return t}info(t){let e=i(this,v).get(t);if(e===void 0)return;let s=i(this,p)[e],r=c(this,a,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(i(this,L)&&i(this,J)){let o=i(this,L)[e],l=i(this,J)[e];if(o&&l){let h=o-(dt.now()-l);n.ttl=h,n.start=Date.now();}}return i(this,Y)&&(n.size=i(this,Y)[e]),n}dump(){let t=[];for(let e of c(this,a,it).call(this,{allowStale:true})){let s=i(this,E)[e],r=i(this,p)[e],n=c(this,a,A).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(i(this,L)&&i(this,J)){o.ttl=i(this,L)[e];let l=dt.now()-i(this,J)[e];o.start=Math.floor(Date.now()-l);}i(this,Y)&&(o.size=i(this,Y)[e]),t.unshift([s,o]);}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let r=Date.now()-s.start;s.start=dt.now()-r;}this.set(e,s.value,s);}}set(t,e,s={}){var _,V,Q,T;if(e===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:h}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,m=i(this,Ht).call(this,t,e,s.size||0,l);if(this.maxEntrySize&&m>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),c(this,a,rt).call(this,t,"set"),this;let S=i(this,O)===0?void 0:i(this,v).get(t);if(S===void 0)S=i(this,O)===0?i(this,D):i(this,$).length!==0?i(this,$).pop():i(this,O)===i(this,U)?c(this,a,Dt).call(this,false):i(this,O),i(this,E)[S]=t,i(this,p)[S]=e,i(this,v).set(t,S),i(this,I)[i(this,D)]=S,i(this,G)[S]=i(this,D),d(this,D,S),vt(this,O)._++,i(this,bt).call(this,S,m,h),h&&(h.set="add"),y=false,i(this,St)&&((_=i(this,ht))==null||_.call(this,e,t,"add"));else {c(this,a,At).call(this,S);let H=i(this,p)[S];if(e!==H){if(i(this,nt)&&c(this,a,A).call(this,H)){H.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=H;g!==void 0&&!o&&(i(this,q)&&((V=i(this,P))==null||V.call(this,g,t,"set")),i(this,N)&&i(this,F)?.push([g,t,"set"]));}else o||(i(this,q)&&((Q=i(this,P))==null||Q.call(this,H,t,"set")),i(this,N)&&i(this,F)?.push([H,t,"set"]));if(i(this,ft).call(this,S),i(this,bt).call(this,S,m,h),i(this,p)[S]=e,h){h.set="replace";let g=H&&c(this,a,A).call(this,H)?H.__staleWhileFetching:H;g!==void 0&&(h.oldValue=g);}}else h&&(h.set="update");i(this,St)&&this.onInsert?.(e,t,e===H?"update":"replace");}if(r!==0&&!i(this,L)&&c(this,a,Mt).call(this),i(this,L)&&(y||i(this,Et).call(this,S,r,n),h&&i(this,tt).call(this,h,S)),!o&&i(this,N)&&i(this,F)){let H=i(this,F),g;for(;g=H?.shift();)(T=i(this,K))==null||T.call(this,...g);}return this}pop(){var t;try{for(;i(this,O);){let e=i(this,p)[i(this,C)];if(c(this,a,Dt).call(this,!0),c(this,a,A).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,N)&&i(this,F)){let e=i(this,F),s;for(;s=e?.shift();)(t=i(this,K))==null||t.call(this,...s);}}}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=e,n=i(this,v).get(t);if(n!==void 0){let o=i(this,p)[n];if(c(this,a,A).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(i(this,W).call(this,n))r&&(r.has="stale",i(this,tt).call(this,r,n));else return s&&i(this,lt).call(this,n),r&&(r.has="hit",i(this,tt).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(t,e={}){let{allowStale:s=this.allowStale}=e,r=i(this,v).get(t);if(r===void 0||!s&&i(this,W).call(this,r))return;let n=i(this,p)[r];return c(this,a,A).call(this,n)?n.__staleWhileFetching:n}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:h=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:Q=this.allowStaleOnFetchAbort,context:T,forceRefresh:H=false,status:g,signal:R}=e;if(!i(this,nt))return g&&(g.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let k={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:l,size:h,sizeCalculation:y,noUpdateTTL:m,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:Q,ignoreFetchAbort:V,status:g,signal:R},z=i(this,v).get(t);if(z===void 0){g&&(g.fetch="miss");let j=c(this,a,Ft).call(this,t,z,k,T);return j.__returned=j}else {let j=i(this,p)[z];if(c(this,a,A).call(this,j)){let It=s&&j.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",It&&(g.returnedStale=true)),It?j.__staleWhileFetching:j.__returned=j}let _t=i(this,W).call(this,z);if(!H&&!_t)return g&&(g.fetch="hit"),c(this,a,At).call(this,z),r&&i(this,lt).call(this,z),g&&i(this,tt).call(this,g,z),j;let ct=c(this,a,Ft).call(this,t,z,k,T),ut=ct.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=_t?"stale":"refresh",ut&&_t&&(g.returnedStale=true)),ut?ct.__staleWhileFetching:ct.__returned=ct}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=i(this,mt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=e,l=this.get(t,o);if(!n&&l!==void 0)return l;let h=s(t,l,{options:o,context:r});return this.set(t,h,o),h}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=e,l=i(this,v).get(t);if(l!==void 0){let h=i(this,p)[l],y=c(this,a,A).call(this,h);return o&&i(this,tt).call(this,o,l),i(this,W).call(this,l)?(o&&(o.get="stale"),y?(o&&s&&h.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?h.__staleWhileFetching:void 0):(n||c(this,a,rt).call(this,t,"expire"),o&&s&&(o.returnedStale=true),s?h:void 0)):(o&&(o.get="hit"),y?h.__staleWhileFetching:(c(this,a,At).call(this,l),r&&i(this,lt).call(this,l),h))}else o&&(o.get="miss");}delete(t){return c(this,a,rt).call(this,t,"delete")}clear(){return c(this,a,Wt).call(this,"delete")}};U=new WeakMap,M=new WeakMap,P=new WeakMap,ht=new WeakMap,K=new WeakMap,yt=new WeakMap,mt=new WeakMap,O=new WeakMap,B=new WeakMap,v=new WeakMap,E=new WeakMap,p=new WeakMap,I=new WeakMap,G=new WeakMap,C=new WeakMap,D=new WeakMap,$=new WeakMap,F=new WeakMap,Y=new WeakMap,J=new WeakMap,L=new WeakMap,q=new WeakMap,nt=new WeakMap,N=new WeakMap,St=new WeakMap,a=new WeakSet,Mt=function(){let t=new pt(i(this,U)),e=new pt(i(this,U));d(this,L,t),d(this,J,e),d(this,Et,(n,o,l=dt.now())=>{if(e[n]=o!==0?l:0,t[n]=o,o!==0&&this.ttlAutopurge){let h=setTimeout(()=>{i(this,W).call(this,n)&&c(this,a,rt).call(this,i(this,E)[n],"expire");},o+1);h.unref&&h.unref();}}),d(this,lt,n=>{e[n]=t[n]!==0?dt.now():0;}),d(this,tt,(n,o)=>{if(t[o]){let l=t[o],h=e[o];if(!l||!h)return;n.ttl=l,n.start=h,n.now=s||r();let y=n.now-h;n.remainingTTL=l-y;}});let s=0,r=()=>{let n=dt.now();if(this.ttlResolution>0){s=n;let o=setTimeout(()=>s=0,this.ttlResolution);o.unref&&o.unref();}return n};this.getRemainingTTL=n=>{let o=i(this,v).get(n);if(o===void 0)return 0;let l=t[o],h=e[o];if(!l||!h)return 1/0;let y=(s||r())-h;return l-y},d(this,W,n=>{let o=e[n],l=t[n];return !!l&&!!o&&(s||r())-o>l});},lt=new WeakMap,tt=new WeakMap,Et=new WeakMap,W=new WeakMap,qt=function(){let t=new pt(i(this,U));d(this,B,0),d(this,Y,t),d(this,ft,e=>{d(this,B,i(this,B)-t[e]),t[e]=0;}),d(this,Ht,(e,s,r,n)=>{if(c(this,a,A).call(this,s))return 0;if(!et(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,e),!et(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}),d(this,bt,(e,s,r)=>{if(t[e]=s,i(this,M)){let n=i(this,M)-t[e];for(;i(this,B)>n;)c(this,a,Dt).call(this,true);}d(this,B,i(this,B)+t[e]),r&&(r.entrySize=s,r.totalCalculatedSize=i(this,B));});},ft=new WeakMap,bt=new WeakMap,Ht=new WeakMap,it=function*({allowStale:t=this.allowStale}={}){if(i(this,O))for(let e=i(this,D);!(!c(this,a,Gt).call(this,e)||((t||!i(this,W).call(this,e))&&(yield e),e===i(this,C)));)e=i(this,G)[e];},st=function*({allowStale:t=this.allowStale}={}){if(i(this,O))for(let e=i(this,C);!(!c(this,a,Gt).call(this,e)||((t||!i(this,W).call(this,e))&&(yield e),e===i(this,D)));)e=i(this,I)[e];},Gt=function(t){return t!==void 0&&i(this,v).get(i(this,E)[t])===t},Dt=function(t){var n;let e=i(this,C),s=i(this,E)[e],r=i(this,p)[e];return i(this,nt)&&c(this,a,A).call(this,r)?r.__abortController.abort(new Error("evicted")):(i(this,q)||i(this,N))&&(i(this,q)&&((n=i(this,P))==null||n.call(this,r,s,"evict")),i(this,N)&&i(this,F)?.push([r,s,"evict"])),i(this,ft).call(this,e),t&&(i(this,E)[e]=void 0,i(this,p)[e]=void 0,i(this,$).push(e)),i(this,O)===1?(d(this,C,d(this,D,0)),i(this,$).length=0):d(this,C,i(this,I)[e]),i(this,v).delete(s),vt(this,O)._--,e},Ft=function(t,e,s,r){let n=e===void 0?void 0:i(this,p)[e];if(c(this,a,A).call(this,n))return n;let o=new zt,{signal:l}=s;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let h={signal:o.signal,options:s,context:r},y=(T,H=false)=>{let{aborted:g}=o.signal,R=s.ignoreFetchAbort&&T!==void 0;if(s.status&&(g&&!H?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,R&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!R&&!H)return S(o.signal.reason);let k=V;return i(this,p)[e]===V&&(T===void 0?k.__staleWhileFetching?i(this,p)[e]=k.__staleWhileFetching:c(this,a,rt).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,T,h.options))),T},m=T=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=T),S(T)),S=T=>{let{aborted:H}=o.signal,g=H&&s.allowStaleOnFetchAbort,R=g||s.allowStaleOnFetchRejection,k=R||s.noDeleteOnFetchRejection,z=V;if(i(this,p)[e]===V&&(!k||z.__staleWhileFetching===void 0?c(this,a,rt).call(this,t,"fetch"):g||(i(this,p)[e]=z.__staleWhileFetching)),R)return s.status&&z.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),z.__staleWhileFetching;if(z.__returned===z)throw T},_=(T,H)=>{var R;let g=(R=i(this,yt))==null?void 0:R.call(this,t,n,h);g&&g instanceof Promise&&g.then(k=>T(k===void 0?void 0:k),H),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(T(void 0),s.allowStaleOnFetchAbort&&(T=k=>y(k,true)));});};s.status&&(s.status.fetchDispatched=true);let V=new Promise(_).then(y,m),Q=Object.assign(V,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,Q,{...h.options,status:void 0}),e=i(this,v).get(t)):i(this,p)[e]=Q,Q},A=function(t){if(!i(this,nt))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof zt},Lt=function(t,e){i(this,G)[e]=t,i(this,I)[t]=e;},At=function(t){t!==i(this,D)&&(t===i(this,C)?d(this,C,i(this,I)[t]):c(this,a,Lt).call(this,i(this,G)[t],i(this,I)[t]),c(this,a,Lt).call(this,i(this,D),t),d(this,D,t));},rt=function(t,e){var r,n;let s=false;if(i(this,O)!==0){let o=i(this,v).get(t);if(o!==void 0)if(s=true,i(this,O)===1)c(this,a,Wt).call(this,e);else {i(this,ft).call(this,o);let l=i(this,p)[o];if(c(this,a,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(i(this,q)||i(this,N))&&(i(this,q)&&((r=i(this,P))==null||r.call(this,l,t,e)),i(this,N)&&i(this,F)?.push([l,t,e])),i(this,v).delete(t),i(this,E)[o]=void 0,i(this,p)[o]=void 0,o===i(this,D))d(this,D,i(this,G)[o]);else if(o===i(this,C))d(this,C,i(this,I)[o]);else {let h=i(this,G)[o];i(this,I)[h]=i(this,I)[o];let y=i(this,I)[o];i(this,G)[y]=i(this,G)[o];}vt(this,O)._--,i(this,$).push(o);}}if(i(this,N)&&i(this,F)?.length){let o=i(this,F),l;for(;l=o?.shift();)(n=i(this,K))==null||n.call(this,...l);}return s},Wt=function(t){var e,s;for(let r of c(this,a,st).call(this,{allowStale:true})){let n=i(this,p)[r];if(c(this,a,A).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=i(this,E)[r];i(this,q)&&((e=i(this,P))==null||e.call(this,n,o,t)),i(this,N)&&i(this,F)?.push([n,o,t]);}}if(i(this,v).clear(),i(this,p).fill(void 0),i(this,E).fill(void 0),i(this,L)&&i(this,J)&&(i(this,L).fill(0),i(this,J).fill(0)),i(this,Y)&&i(this,Y).fill(0),d(this,C,0),d(this,D,0),i(this,$).length=0,d(this,B,0),d(this,O,0),i(this,N)&&i(this,F)){let r=i(this,F),n;for(;n=r?.shift();)(s=i(this,K))==null||s.call(this,...n);}};var Ct=Vt;var ot=class{constructor(t){w(this,"cache");w(this,"map",new Map);this.cache=new Ct({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return 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 X=class X{static get originalStepData(){return X._originalStepData?Z(X._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){X._originalStepData=Z(t);}};w(X,"_diffHistory",new ot({cacheSize:5})),w(X,"_stepsInfoHistory",new ot({cacheSize:5})),w(X,"_narrationHistory",new ot({cacheSize:50})),w(X,"stepLimitSaved",20),w(X,"goBackRunning",false),w(X,"_originalStepData");var u=X;var xt=class{get stepsInfoMap(){return u._stepsInfoHistory}get diffMap(){return u._diffHistory}get narrationMap(){return u._narrationHistory}get size(){return u._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return u._stepsInfoHistory.keys()}get(t){let e=u._narrationHistory.get(t);if(!(e&&Object.keys(e).length===1&&e.stepIndex!==void 0))return e}delete(t){u._stepsInfoHistory.delete(t),u._diffHistory.delete(t),u._narrationHistory.delete(t);}internalRestoreOldGameState(t,e){if(t<=0||this.size==0)return e;let s=this.lastKey;if(typeof s!="number")return x.error("You can't go back, there is no step to go back"),e;let r=u._diffHistory.get(s);if(r)try{let n=Ut(e,r);return GameUnifier.stepCounter=s,this.delete(s),this.internalRestoreOldGameState(t-1,n)}catch(n){return x.error("Error applying diff",n),e}else return x.error("You can't go back, there is no step to go back"),e}async goBack(t,e=1){if(e<=0){x.warn("The parameter steps must be greater than 0");return}if(u._diffHistory.size<1){x.warn("You can't go back, there is no step to go back");return}if(u.goBackRunning){x.warn("Go back is already running");return}u.goBackRunning=true;try{let s=Z(this.internalRestoreOldGameState(e,u.originalStepData));if(s){await GameUnifier.restoreGameStepState(s,t);let r=GameUnifier.stepCounter-1,n=u._narrationHistory.get(r);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let o=u._stepsInfoHistory.get(r);if(o){let l=this.itemMapper({step:o});u._narrationHistory.set(o.index,l);}}}else x.error("Error going back");u.originalStepData=s,u.goBackRunning=!1;}catch(s){x.error("Error going back",s),u.goBackRunning=false;}}add(t,e={}){let s=u.originalStepData,{ignoreSameStep:r}=e,n=GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,n))return;let o=this.lastKey;(async()=>{try{let h,y;if(typeof o=="number"&&(h=u._stepsInfoHistory.get(o),y=u._narrationHistory.get(o)),u._stepsInfoHistory.set(t.index,t),t.index!==0){let _=Ot(s,n);_?u._diffHistory.set(t.index,_):x.warn("It was not possible to create the difference between the two steps");}let m={},S=this.itemMapper({step:t},m);if(u._narrationHistory.set(t.index,S),h&&y&&typeof o=="number"){let _=this.itemMapper({...m,step:h},{});u._narrationHistory.set(o,_);}}catch(h){x.error("Error adding history step",h);}})(),u.originalStepData=n;}itemMapper(t,e){let{step:s,choiceIndexMade:r,inputValue:n,removeDialogue:o}=t,l=s.dialogue||s.dialoge;e&&s.isGlued&&(e.removeDialogue=true),o&&(l=void 0);let h=s.choices;if(e&&s.currentLabel&&s.choiceIndexMade!==void 0&&(e.choiceIndexMade=s.choiceIndexMade),s.inputValue&&e&&(e.inputValue=s.inputValue),l||h||n){let y=h?.map((m,S)=>{let _=false;return m.oneTime&&s.alreadyMadeChoices&&s.alreadyMadeChoices.includes(S)&&(_=true),{text:m.text,type:m.type,isResponse:false,hidden:_}});if(y){if(y.every(m=>m.hidden)){let m=y.find(S=>S.hidden===false);m&&(m.hidden=false);}r!==void 0&&(y[r].isResponse=true);}return {dialogue:l?{...l,character:l.character?GameUnifier.getCharacter(l.character)||l.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:y,stepIndex:s.index,inputValue:n}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],e=Array.from(this.keys()).sort((h,y)=>y-h);if(e.length===0)return t;let s=e[0];if(typeof s!="number")return t;let r=u._stepsInfoHistory.get(s);if(!r)return t;let n=r.openedLabels;if(!n||!Array.isArray(n)||n.length===0)return t;let o=n[0].currentStepIndex,l=n[0].label;return e.every((h,y)=>{let m=this.get(h);if(m){if(y===0)return t.push(m),true;let S=u._stepsInfoHistory.get(h);if(!S)return true;let _=S.openedLabels;if(!_||!Array.isArray(_)||_.length===0||_[0].label!==l||_[0].currentStepIndex>=o)return false;o=_[0].currentStepIndex,t.push(m);}return true}),t.reverse()}removeNarrativeHistory(t){if(t){let e=Array.from(this.keys()).sort((s,r)=>s-r);e=e.slice(0,t),e.forEach(s=>{u._narrationHistory.delete(s),u._stepsInfoHistory.delete(s),u._diffHistory.delete(s);});}else u._stepsInfoHistory.clear(),u._diffHistory.clear(),u._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:u._diffHistory.has(t)}blockGoBack(){GameUnifier.currentStepsRunningNumber===0&&u._diffHistory.clear();}isSameStep(t,e){if(t.openedLabels.length===e.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(e.openedLabels);if(s===r&&t.path===e.path&&t.labelIndex===e.labelIndex)return !0}catch(s){return x.error("Error comparing opened labels",s),true}return false}clear(){u._stepsInfoHistory.clear(),u._diffHistory.clear(),u._narrationHistory.clear(),u._originalStepData=void 0;}get stepLimitSaved(){return u.stepLimitSaved}set stepLimitSaved(t){u.stepLimitSaved=t;}export(){let t=Array.from(this.keys()).sort((s,r)=>s-r);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let e=[];return t.forEach(s=>{let r=u._stepsInfoHistory.get(s);if(r){let n=u._diffHistory.get(s);e.push({...r,diff:n});}}),{stepsHistory:Z(e),originalStepData:Z(u._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),e={};t.forEach(s=>{let r=u._stepsInfoHistory.get(s);if(r){let n={...e};e={};let o=this.itemMapper({step:r,choiceIndexMade:n.choiceIndexMade,inputValue:n.inputValue,removeDialogue:n.removeDialogue},e);o&&u._narrationHistory.set(s,o);}});}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&u._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};u._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):x.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?u._originalStepData=t.originalStepData:x.warn("Could not import originalStepData data, so will be ignored");}catch(e){x.error("Error importing data",e);}}};var Re=new xt;export{u as HistoryManagerStatic,Re as stepHistory};
|