@drincs/pixi-vn 1.9.2 → 1.9.4

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.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/dist/{ContainerMemory-BpDgacyr.d.cts → ContainerMemory-DNqSVzLY.d.cts} +12 -116
  3. package/dist/{ContainerMemory-BpDgacyr.d.ts → ContainerMemory-DNqSVzLY.d.ts} +12 -116
  4. package/dist/canvas.cjs +2 -2
  5. package/dist/canvas.d.cts +1279 -551
  6. package/dist/canvas.d.ts +1279 -551
  7. package/dist/canvas.mjs +2 -2
  8. package/dist/characters.cjs +1 -1
  9. package/dist/characters.mjs +1 -1
  10. package/dist/{chunk-6GLWL3NH.mjs → chunk-5MVDNAT4.mjs} +1 -1
  11. package/dist/chunk-6OABTG5R.mjs +1 -0
  12. package/dist/chunk-AW5XWF24.mjs +1 -0
  13. package/dist/chunk-LXIKP2K5.mjs +1 -0
  14. package/dist/chunk-S7HZUIEI.mjs +1 -0
  15. package/dist/core.cjs +1 -1
  16. package/dist/core.d.cts +61 -5
  17. package/dist/core.d.ts +61 -5
  18. package/dist/core.mjs +1 -1
  19. package/dist/filters.cjs +1 -0
  20. package/dist/filters.d.cts +182 -0
  21. package/dist/filters.d.ts +182 -0
  22. package/dist/filters.mjs +1 -0
  23. package/dist/history.cjs +1 -1
  24. package/dist/history.d.cts +2 -2
  25. package/dist/history.d.ts +2 -2
  26. package/dist/history.mjs +1 -1
  27. package/dist/index.cjs +2 -2
  28. package/dist/index.d.cts +43 -3
  29. package/dist/index.d.ts +43 -3
  30. package/dist/index.mjs +2 -2
  31. package/dist/motion.cjs +1 -1
  32. package/dist/motion.d.cts +30 -8
  33. package/dist/motion.d.ts +30 -8
  34. package/dist/motion.mjs +1 -1
  35. package/dist/narration.cjs +1 -1
  36. package/dist/narration.d.cts +2 -1
  37. package/dist/narration.d.ts +2 -1
  38. package/dist/narration.mjs +1 -1
  39. package/dist/pixi/browser.js +170 -169
  40. package/dist/sound.mjs +1 -1
  41. package/dist/storage.cjs +1 -1
  42. package/dist/storage.d.cts +1 -1
  43. package/dist/storage.d.ts +1 -1
  44. package/dist/storage.mjs +1 -1
  45. package/dist/tickers.cjs +1 -0
  46. package/dist/tickers.d.cts +555 -0
  47. package/dist/tickers.d.ts +555 -0
  48. package/dist/tickers.mjs +1 -0
  49. package/dist/vite.cjs +6 -4
  50. package/dist/vite.d.cts +64 -0
  51. package/dist/vite.d.ts +64 -0
  52. package/dist/vite.mjs +6 -4
  53. package/dist/worker.cjs +1 -0
  54. package/dist/worker.d.cts +153 -0
  55. package/dist/worker.d.ts +153 -0
  56. package/dist/worker.mjs +1 -0
  57. package/package.json +28 -1
  58. package/dist/chunk-HQQ5WH6C.mjs +0 -1
  59. package/dist/chunk-I7DOUH5V.mjs +0 -1
@@ -0,0 +1,182 @@
1
+ import { AnimationOptions } from '@drincs/pixi-vn/motion';
2
+ import { Filter, AlphaFilter, BlurFilter, NoiseFilter, UPDATE_PRIORITY } from '@drincs/pixi-vn/pixi.js';
3
+ import { AdjustmentFilter, AdvancedBloomFilter, AsciiFilter, BackdropBlurFilter, BevelFilter, BloomFilter, BulgePinchFilter, ColorGradientFilter, ColorOverlayFilter, ColorReplaceFilter, ConvolutionFilter, CRTFilter, CrossHatchFilter, DotFilter, DropShadowFilter, EmbossFilter, GlitchFilter, GlowFilter, GodrayFilter, GrayscaleFilter, HslAdjustmentFilter, KawaseBlurFilter, MotionBlurFilter, MultiColorReplaceFilter, OldFilmFilter, OutlineFilter, PixelateFilter, RadialBlurFilter, ReflectionFilter, RGBSplitFilter, ShockwaveFilter, SimplexNoiseFilter, TiltShiftFilter, TwistFilter, ZoomBlurFilter } from 'pixi-filters';
4
+
5
+ /**
6
+ * Is a decorator that registers a `Filter` class so it can be saved and restored as part of a canvas
7
+ * element's `.filters`. Required for any custom filter you want to survive a save/restore round-trip -
8
+ * built-in ones like `PixelateFilter` (and `BlurFilter`) are already registered by Pixi'VN.
9
+ * @param options.name The id used to identify this filter class in saves (must be unique). Defaults to the class name.
10
+ * @param options.toMemory Reads a live instance's current parameters into a plain, serializable object. It is passed to the class's constructor (as its single argument) to reconstruct the filter on restore.
11
+ * @example
12
+ * ```ts
13
+ * @filterDecorator({ toMemory: (filter: MyFilter) => ({ amount: filter.amount }) })
14
+ * class MyFilter extends Filter {
15
+ * constructor(args: { amount?: number } = {}) {
16
+ * super({ ... });
17
+ * this.amount = args.amount ?? 0;
18
+ * }
19
+ * // ...
20
+ * }
21
+ * ```
22
+ */
23
+ declare function filterDecorator<T extends {
24
+ new (args: any): Filter;
25
+ }>(options: {
26
+ name?: string;
27
+ toMemory: (filter: InstanceType<T>) => any;
28
+ }): (target: T) => void;
29
+ declare namespace RegisteredFilters {
30
+ /**
31
+ * Register a filter class in the game.
32
+ * @param target The class of the filter. Must be constructible from a single, serializable `args` object.
33
+ * @param options.name Name of the filter, by default it will use the class name. If the name is already registered, it will show a warning
34
+ * @param options.toMemory Reads a live instance's current parameters into a plain, serializable object.
35
+ */
36
+ function add<T extends {
37
+ new (args: any): Filter;
38
+ }>(target: T, options: {
39
+ name?: string;
40
+ toMemory: (filter: InstanceType<T>) => any;
41
+ }): void;
42
+ /**
43
+ * Get a filter class by the id.
44
+ * @param filterId The id of the filter.
45
+ * @returns The filter class.
46
+ */
47
+ function get<T = {
48
+ new (args: any): Filter;
49
+ }>(filterId: string): T | undefined;
50
+ /**
51
+ * Get a filter instance by the id, reconstructed from previously saved `args`.
52
+ * @param filterId The id of the filter.
53
+ * @param args The arguments to pass to the filter's constructor, as produced by a previous `toMemory` call.
54
+ * @returns The filter instance, or `undefined` if the filter isn't registered or construction failed.
55
+ */
56
+ function getInstance(filterId: string, args: any): Filter | undefined;
57
+ /**
58
+ * Reads a live filter instance's current parameters into a serializable {@link FilterMemory}, using
59
+ * the `toMemory` function it was registered with.
60
+ * @param filterId The id the filter was registered under (readable on any instance as `filter.pixivnFilterId`).
61
+ * @param filter The live filter instance.
62
+ * @returns The memory object, or `undefined` if the filter isn't registered or conversion failed.
63
+ */
64
+ function toMemory(filterId: string, filter: Filter): {
65
+ filterId: string;
66
+ args: any;
67
+ } | undefined;
68
+ /**
69
+ * Get a list of all filter classes registered.
70
+ * @returns An array of filter classes.
71
+ */
72
+ function values(): {
73
+ new (args: any): Filter;
74
+ }[];
75
+ /**
76
+ * Check if a filter is registered.
77
+ * @param id The id of the filter.
78
+ * @returns True if the filter is registered, false otherwise.
79
+ */
80
+ function has(id: string): boolean;
81
+ /**
82
+ * Get a list of all filter ids registered.
83
+ * @returns An array of filter ids.
84
+ */
85
+ function keys(): string[];
86
+ }
87
+
88
+ /**
89
+ * Serializable representation of a single `Filter` attached to a canvas element's `.filters` array.
90
+ *
91
+ * A live `Filter` instance (PixiJS's own, like `BlurFilter`, or a custom one) generally can't be
92
+ * serialized directly - it doesn't expose its constructor options after creation, and its state lives in
93
+ * GPU-facing resources/uniform groups. `filterId` identifies which registration (see
94
+ * {@link filterDecorator}/{@link RegisteredFilters}) knows how to convert it to and from `args`.
95
+ */
96
+ interface FilterMemory {
97
+ /**
98
+ * The id the filter's class was registered under. Used on restore to look up the class and
99
+ * reconstruct an instance from `args`.
100
+ */
101
+ filterId: string;
102
+ /**
103
+ * The serializable arguments needed to reconstruct the filter, as produced by its registration's
104
+ * `toMemory` function.
105
+ */
106
+ args: any;
107
+ }
108
+
109
+ /**
110
+ * Animate either a `Filter`'s own properties, or a plain numeric "progress" value with no live target
111
+ * (used by the mask-based transitions - wipe/iris/split - which have no filter property to write
112
+ * directly, just a number and a side effect). See `GameUnifier.animateFilter`'s own doc comment for the
113
+ * full parameter reference; this just forwards to it (through the same DI indirection `canvas`'s own
114
+ * animate methods use - `filters` can't import `motion` directly, since `canvas` already depends on
115
+ * `filters` and `motion` depends on `canvas`, so `filters -> motion` would close a cycle).
116
+ * @param components The canvas element alias(es) the filter is attached to, or otherwise associated
117
+ * with this animation.
118
+ * @param filter The `Filter` instance to animate, or `undefined` to animate a plain value instead.
119
+ * @param keyframes The keyframes to animate the filter's properties (or the plain value) with.
120
+ * @param options The animation options.
121
+ * @param priority The update priority of the ticker.
122
+ * @param apply Called on every frame with the current interpolated value - required when `filter` is
123
+ * `undefined`, ignored otherwise.
124
+ * @param cleanup Called once, right before completion handling, to detach/destroy the filter or tear
125
+ * down whatever `apply` was driving.
126
+ * @returns The id of the ticker, or `undefined` if the ticker was not added.
127
+ */
128
+ declare function animate(components: string | string[], filter: Filter | undefined, keyframes: Record<string, any>, options?: AnimationOptions, priority?: UPDATE_PRIORITY, apply?: (value: number) => void, cleanup?: () => void): string | undefined;
129
+ /**
130
+ * Every filter class Pixi'VN registers for save/restore out of the box (see
131
+ * `register-builtin-filters.ts`), grouped in one place so a project can use them without importing
132
+ * from `pixi.js`/`pixi-filters` directly - e.g. `new filters.BloomFilter({...})` - plus
133
+ * {@link animate}. Not every filter `pixi.js`/`pixi-filters` ships is here: a few (`ColorMapFilter`,
134
+ * `SimpleLightmapFilter`, `TiltShiftAxisFilter`, `ColorMatrixFilter`, `DisplacementFilter`, and
135
+ * pixi.js's internal `MaskFilter`/`BlendModeFilter`/`PassthroughFilter`) are deliberately not
136
+ * registered - see that file's doc comment for why. Those are still directly importable from
137
+ * `pixi.js`/`pixi-filters` as usual; they just won't survive a save/restore round-trip unless a project
138
+ * registers its own `toMemory` for them.
139
+ */
140
+ declare const filters: {
141
+ readonly AlphaFilter: typeof AlphaFilter;
142
+ readonly BlurFilter: typeof BlurFilter;
143
+ readonly NoiseFilter: typeof NoiseFilter;
144
+ readonly AdjustmentFilter: typeof AdjustmentFilter;
145
+ readonly AdvancedBloomFilter: typeof AdvancedBloomFilter;
146
+ readonly AsciiFilter: typeof AsciiFilter;
147
+ readonly BackdropBlurFilter: typeof BackdropBlurFilter;
148
+ readonly BevelFilter: typeof BevelFilter;
149
+ readonly BloomFilter: typeof BloomFilter;
150
+ readonly BulgePinchFilter: typeof BulgePinchFilter;
151
+ readonly ColorGradientFilter: typeof ColorGradientFilter;
152
+ readonly ColorOverlayFilter: typeof ColorOverlayFilter;
153
+ readonly ColorReplaceFilter: typeof ColorReplaceFilter;
154
+ readonly ConvolutionFilter: typeof ConvolutionFilter;
155
+ readonly CRTFilter: typeof CRTFilter;
156
+ readonly CrossHatchFilter: typeof CrossHatchFilter;
157
+ readonly DotFilter: typeof DotFilter;
158
+ readonly DropShadowFilter: typeof DropShadowFilter;
159
+ readonly EmbossFilter: typeof EmbossFilter;
160
+ readonly GlitchFilter: typeof GlitchFilter;
161
+ readonly GlowFilter: typeof GlowFilter;
162
+ readonly GodrayFilter: typeof GodrayFilter;
163
+ readonly GrayscaleFilter: typeof GrayscaleFilter;
164
+ readonly HslAdjustmentFilter: typeof HslAdjustmentFilter;
165
+ readonly KawaseBlurFilter: typeof KawaseBlurFilter;
166
+ readonly MotionBlurFilter: typeof MotionBlurFilter;
167
+ readonly MultiColorReplaceFilter: typeof MultiColorReplaceFilter;
168
+ readonly OldFilmFilter: typeof OldFilmFilter;
169
+ readonly OutlineFilter: typeof OutlineFilter;
170
+ readonly PixelateFilter: typeof PixelateFilter;
171
+ readonly RadialBlurFilter: typeof RadialBlurFilter;
172
+ readonly ReflectionFilter: typeof ReflectionFilter;
173
+ readonly RGBSplitFilter: typeof RGBSplitFilter;
174
+ readonly ShockwaveFilter: typeof ShockwaveFilter;
175
+ readonly SimplexNoiseFilter: typeof SimplexNoiseFilter;
176
+ readonly TiltShiftFilter: typeof TiltShiftFilter;
177
+ readonly TwistFilter: typeof TwistFilter;
178
+ readonly ZoomBlurFilter: typeof ZoomBlurFilter;
179
+ readonly animate: typeof animate;
180
+ };
181
+
182
+ export { type FilterMemory, RegisteredFilters, filterDecorator, filters };
@@ -0,0 +1 @@
1
+ import {d as d$1,e}from'./chunk-AW5XWF24.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';import {BlurFilter,AlphaFilter,NoiseFilter}from'@drincs/pixi-vn/pixi.js';import {PixelateFilter,AdjustmentFilter,AdvancedBloomFilter,AsciiFilter,BackdropBlurFilter,BevelFilter,BloomFilter,BulgePinchFilter,ColorGradientFilter,ColorOverlayFilter,ColorReplaceFilter,ConvolutionFilter,CrossHatchFilter,CRTFilter,DotFilter,DropShadowFilter,EmbossFilter,GlitchFilter,GlowFilter,GodrayFilter,GrayscaleFilter,HslAdjustmentFilter,KawaseBlurFilter,MotionBlurFilter,MultiColorReplaceFilter,OldFilmFilter,OutlineFilter,RadialBlurFilter,ReflectionFilter,RGBSplitFilter,ShockwaveFilter,SimplexNoiseFilter,TiltShiftFilter,TwistFilter,ZoomBlurFilter}from'pixi-filters';var d=new d$1({cacheSize:5}),y=new d$1({cacheSize:5});function M(e){return i=>{c.add(i,e);}}var c;($e=>{function e$1(o,a){let{toMemory:l}=a,n=a.name??o.name;d.get(n)&&e.info(`Filter "${n}" already exists, it will be overwritten`),o.prototype.pixivnFilterId=n,d.set(n,o),y.set(n,l);}$e.add=e$1;function i(o){let a=d.get(o);if(!a){e.error(`Filter "${o}" not found, did you forget to register it with the filterDecorator?`);return}return a}$e.get=i;function u(o,a){let l=i(o);if(l)try{return new l(a)}catch(n){e.error(`Error while getting Filter instance "${o}"`,n);return}}$e.getInstance=u;function F(o,a){let l=y.get(o);if(!l){e.error(`Filter "${o}" not found, did you forget to register it with the filterDecorator?`);return}try{return {filterId:o,args:l(a)}}catch(n){e.error(`Error while converting Filter "${o}" to memory`,n);return}}$e.toMemory=F;function g(){return Array.from(d.values())}$e.values=g;function h(o){return d.has(o)}$e.has=h;function p(){return Array.from(d.keys())}$e.keys=p;})(c||={});var t=c;function r(e,i){return {x:e,y:i}}t.add(BlurFilter,{name:"BlurFilter",toMemory:e=>({strengthX:e.strengthX,strengthY:e.strengthY,quality:e.quality,repeatEdgePixels:e.repeatEdgePixels})});t.add(AlphaFilter,{name:"AlphaFilter",toMemory:e=>({alpha:e.alpha})});t.add(NoiseFilter,{name:"NoiseFilter",toMemory:e=>({noise:e.noise,seed:e.seed})});t.add(PixelateFilter,{name:"PixelateFilter",toMemory:e=>[e.sizeX,e.sizeY]});t.add(AdjustmentFilter,{name:"AdjustmentFilter",toMemory:e=>({gamma:e.gamma,contrast:e.contrast,saturation:e.saturation,brightness:e.brightness,red:e.red,green:e.green,blue:e.blue,alpha:e.alpha})});t.add(AdvancedBloomFilter,{name:"AdvancedBloomFilter",toMemory:e=>({threshold:e.threshold,bloomScale:e.bloomScale,brightness:e.brightness,blur:e.blur,kernels:e.kernels,quality:e.quality,pixelSize:r(e.pixelSizeX,e.pixelSizeY)})});t.add(AsciiFilter,{name:"AsciiFilter",toMemory:e=>({size:e.size,color:e.color,replaceColor:e.replaceColor})});t.add(BackdropBlurFilter,{name:"BackdropBlurFilter",toMemory:e=>({strength:e.strength,quality:e.quality})});t.add(BevelFilter,{name:"BevelFilter",toMemory:e=>({rotation:e.rotation,thickness:e.thickness,lightColor:e.lightColor,lightAlpha:e.lightAlpha,shadowColor:e.shadowColor,shadowAlpha:e.shadowAlpha})});t.add(BloomFilter,{name:"BloomFilter",toMemory:e=>({strength:r(e.strengthX,e.strengthY)})});t.add(BulgePinchFilter,{name:"BulgePinchFilter",toMemory:e=>({center:r(e.centerX,e.centerY),radius:e.radius,strength:e.strength})});t.add(ColorGradientFilter,{name:"ColorGradientFilter",toMemory:e=>({type:e.type,stops:e.stops,angle:e.angle,alpha:e.alpha,maxColors:e.maxColors,replace:e.replace})});t.add(ColorOverlayFilter,{name:"ColorOverlayFilter",toMemory:e=>({color:e.color,alpha:e.alpha})});t.add(ColorReplaceFilter,{name:"ColorReplaceFilter",toMemory:e=>({originalColor:e.originalColor,targetColor:e.targetColor,tolerance:e.tolerance})});t.add(ConvolutionFilter,{name:"ConvolutionFilter",toMemory:e=>({matrix:e.matrix,width:e.width,height:e.height})});t.add(CrossHatchFilter,{name:"CrossHatchFilter",toMemory:()=>({})});t.add(CRTFilter,{name:"CRTFilter",toMemory:e=>({curvature:e.curvature,lineWidth:e.lineWidth,lineContrast:e.lineContrast,verticalLine:e.verticalLine,noise:e.noise,noiseSize:e.noiseSize,vignetting:e.vignetting,vignettingAlpha:e.vignettingAlpha,vignettingBlur:e.vignettingBlur,seed:e.seed,time:e.time})});t.add(DotFilter,{name:"DotFilter",toMemory:e=>({scale:e.scale,angle:e.angle,grayscale:e.grayscale})});t.add(DropShadowFilter,{name:"DropShadowFilter",toMemory:e=>({offset:r(e.offsetX,e.offsetY),color:e.color,alpha:e.alpha,shadowOnly:e.shadowOnly,blur:e.blur,quality:e.quality,kernels:e.kernels,pixelSize:r(e.pixelSizeX,e.pixelSizeY)})});t.add(EmbossFilter,{name:"EmbossFilter",toMemory:e=>e.strength});t.add(GlitchFilter,{name:"GlitchFilter",toMemory:e=>({slices:e.slices,offset:e.offset,direction:e.direction,fillMode:e.fillMode,seed:e.seed,average:e.average,minSize:e.minSize,sampleSize:e.sampleSize,red:e.red,green:e.green,blue:e.blue})});t.add(GlowFilter,{name:"GlowFilter",toMemory:e=>({distance:e.distance,outerStrength:e.outerStrength,innerStrength:e.innerStrength,color:e.color,alpha:e.alpha,quality:e.quality,knockout:e.knockout})});t.add(GodrayFilter,{name:"GodrayFilter",toMemory:e=>({angle:e.angle,parallel:e.parallel,center:r(e.centerX,e.centerY),gain:e.gain,lacunarity:e.lacunarity,time:e.time,alpha:e.alpha})});t.add(GrayscaleFilter,{name:"GrayscaleFilter",toMemory:()=>({})});t.add(HslAdjustmentFilter,{name:"HslAdjustmentFilter",toMemory:e=>({hue:e.hue,saturation:e.saturation,lightness:e.lightness,colorize:e.colorize,alpha:e.alpha})});t.add(KawaseBlurFilter,{name:"KawaseBlurFilter",toMemory:e=>({strength:e.strength,quality:e.quality,pixelSize:r(e.pixelSizeX,e.pixelSizeY)})});t.add(MotionBlurFilter,{name:"MotionBlurFilter",toMemory:e=>({velocity:r(e.velocityX,e.velocityY),kernelSize:e.kernelSize,offset:e.offset})});t.add(MultiColorReplaceFilter,{name:"MultiColorReplaceFilter",toMemory:e=>({replacements:e.replacements,tolerance:e.tolerance})});t.add(OldFilmFilter,{name:"OldFilmFilter",toMemory:e=>({sepia:e.sepia,noise:e.noise,noiseSize:e.noiseSize,scratch:e.scratch,scratchDensity:e.scratchDensity,scratchWidth:e.scratchWidth,vignetting:e.vignetting,vignettingAlpha:e.vignettingAlpha,vignettingBlur:e.vignettingBlur,seed:e.seed})});t.add(OutlineFilter,{name:"OutlineFilter",toMemory:e=>({thickness:e.thickness,color:e.color,alpha:e.alpha,quality:e.quality,knockout:e.knockout})});t.add(RadialBlurFilter,{name:"RadialBlurFilter",toMemory:e=>({angle:e.angle,center:r(e.centerX,e.centerY),kernelSize:e.kernelSize,radius:e.radius})});t.add(ReflectionFilter,{name:"ReflectionFilter",toMemory:e=>({mirror:e.mirror,boundary:e.boundary,amplitude:e.amplitude,waveLength:e.waveLength,alpha:e.alpha,time:e.time})});t.add(RGBSplitFilter,{name:"RGBSplitFilter",toMemory:e=>({red:r(e.redX,e.redY),green:r(e.greenX,e.greenY),blue:r(e.blueX,e.blueY)})});t.add(ShockwaveFilter,{name:"ShockwaveFilter",toMemory:e=>({center:r(e.centerX,e.centerY),speed:e.speed,amplitude:e.amplitude,wavelength:e.wavelength,brightness:e.brightness,radius:e.radius,time:e.time})});t.add(SimplexNoiseFilter,{name:"SimplexNoiseFilter",toMemory:e=>({strength:e.strength,noiseScale:e.noiseScale,offsetX:e.offsetX,offsetY:e.offsetY,offsetZ:e.offsetZ,step:e.step})});t.add(TiltShiftFilter,{name:"TiltShiftFilter",toMemory:e=>({blur:e.blur,gradientBlur:e.gradientBlur,start:r(e.startX,e.startY),end:r(e.endX,e.endY)})});t.add(TwistFilter,{name:"TwistFilter",toMemory:e=>({radius:e.radius,angle:e.angle,offset:r(e.offsetX,e.offsetY)})});t.add(ZoomBlurFilter,{name:"ZoomBlurFilter",toMemory:e=>({strength:e.strength,center:r(e.centerX,e.centerY),innerRadius:e.innerRadius,radius:e.radius})});function Ze(e,i,u,F,g,h,p){return GameUnifier.animateFilter(e,i,u,F,g,h,p)}var et={AlphaFilter:AlphaFilter,BlurFilter:BlurFilter,NoiseFilter:NoiseFilter,AdjustmentFilter:AdjustmentFilter,AdvancedBloomFilter:AdvancedBloomFilter,AsciiFilter:AsciiFilter,BackdropBlurFilter:BackdropBlurFilter,BevelFilter:BevelFilter,BloomFilter:BloomFilter,BulgePinchFilter:BulgePinchFilter,ColorGradientFilter:ColorGradientFilter,ColorOverlayFilter:ColorOverlayFilter,ColorReplaceFilter:ColorReplaceFilter,ConvolutionFilter:ConvolutionFilter,CRTFilter:CRTFilter,CrossHatchFilter:CrossHatchFilter,DotFilter:DotFilter,DropShadowFilter:DropShadowFilter,EmbossFilter:EmbossFilter,GlitchFilter:GlitchFilter,GlowFilter:GlowFilter,GodrayFilter:GodrayFilter,GrayscaleFilter:GrayscaleFilter,HslAdjustmentFilter:HslAdjustmentFilter,KawaseBlurFilter:KawaseBlurFilter,MotionBlurFilter:MotionBlurFilter,MultiColorReplaceFilter:MultiColorReplaceFilter,OldFilmFilter:OldFilmFilter,OutlineFilter:OutlineFilter,PixelateFilter:PixelateFilter,RadialBlurFilter:RadialBlurFilter,ReflectionFilter:ReflectionFilter,RGBSplitFilter:RGBSplitFilter,ShockwaveFilter:ShockwaveFilter,SimplexNoiseFilter:SimplexNoiseFilter,TiltShiftFilter:TiltShiftFilter,TwistFilter:TwistFilter,ZoomBlurFilter:ZoomBlurFilter,animate:Ze};export{t as RegisteredFilters,M as filterDecorator,et as filters};
package/dist/history.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var core=require('@drincs/pixi-vn/core');var Qt=Object.defineProperty;var Wt=c=>{throw TypeError(c)};var Zt=(c,t,i)=>t in c?Qt(c,t,{enumerable:true,configurable:true,writable:true,value:i}):c[t]=i;var M=(c,t,i)=>Zt(c,typeof t!="symbol"?t+"":t,i),zt=(c,t,i)=>t.has(c)||Wt("Cannot "+i);var e=(c,t,i)=>(zt(c,t,"read from private field"),i?i.call(c):t.get(c)),S=(c,t,i)=>t.has(c)?Wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,i),p=(c,t,i,s)=>(zt(c,t,"write to private field"),t.set(c,i),i),f=(c,t,i)=>(zt(c,t,"access private method"),i);var Ot=(c,t,i,s)=>({set _(r){p(c,t,r);},get _(){return e(c,t,s)}});var te=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Kt=new Set,Lt=typeof process=="object"&&process?process:{},Pt=(c,t,i,s)=>{typeof Lt.emitWarning=="function"?Lt.emitWarning(c,t,i,s):console.error(`[${i}] ${t}: ${c}`);},Dt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Dt>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Dt=class{constructor(){t();}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 c=Lt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{c&&(c=false,Pt("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 ee=c=>!Kt.has(c);var st=c=>c&&c===Math.floor(c)&&c>0&&isFinite(c),Bt=c=>st(c)?c<=Math.pow(2,8)?Uint8Array:c<=Math.pow(2,16)?Uint16Array:c<=Math.pow(2,32)?Uint32Array:c<=Number.MAX_SAFE_INTEGER?Tt:null:null,Tt=class extends Array{constructor(c){super(c),this.fill(0);}},et,yt,ie=(et=class{heap;length;static create(t){let i=Bt(t);if(!i)return [];p(et,yt,true);let s=new et(t,i);return p(et,yt,false),s}constructor(t,i){if(!e(et,yt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},yt=new WeakMap,S(et,yt,false),et),Vt,Ut,B,j,$,lt,q,gt,mt,J,C,Y,E,x,g,G,V,k,F,X,D,Q,Z,U,K,tt,at,I,bt,l,Gt,ct,it,Ht,P,qt,ft,St,At,rt,ot,It,Ct,Ft,_,Rt,xt,nt,Nt,vt,$t=(vt=class{constructor(t){S(this,l);S(this,B);S(this,j);S(this,$);S(this,lt);S(this,q);S(this,gt);S(this,mt);S(this,J);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");S(this,C);S(this,Y);S(this,E);S(this,x);S(this,g);S(this,G);S(this,V);S(this,k);S(this,F);S(this,X);S(this,D);S(this,Q);S(this,Z);S(this,U);S(this,K);S(this,tt);S(this,at);S(this,I);S(this,bt);S(this,ct,()=>{});S(this,it,()=>{});S(this,Ht,()=>{});S(this,P,()=>false);S(this,ft,t=>{});S(this,St,(t,i,s)=>{});S(this,At,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});M(this,Vt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:d,onInsert:y,disposeAfter:m,noDisposeOnSet:v,noUpdateTTL:T,maxSize:W=0,maxEntrySize:H=0,sizeCalculation:w,fetchMethod:b,memoMethod:z,noDeleteOnFetchRejection:R,noDeleteOnStaleGet:L,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:_t,ignoreFetchAbort:ut,perf:pt}=t;if(pt!==void 0&&typeof pt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(p(this,J,pt??te),i!==0&&!st(i))throw new TypeError("max option must be a nonnegative integer");let dt=i?Bt(i):Array;if(!dt)throw new Error("invalid max value: "+i);if(p(this,B,i),p(this,j,W),this.maxEntrySize=H||e(this,j),this.sizeCalculation=w,this.sizeCalculation){if(!e(this,j)&&!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(z!==void 0&&typeof z!="function")throw new TypeError("memoMethod must be a function if defined");if(p(this,mt,z),b!==void 0&&typeof b!="function")throw new TypeError("fetchMethod must be a function if specified");if(p(this,gt,b),p(this,at,!!b),p(this,E,new Map),p(this,x,new Array(i).fill(void 0)),p(this,g,new Array(i).fill(void 0)),p(this,G,new dt(i)),p(this,V,new dt(i)),p(this,k,0),p(this,F,0),p(this,X,ie.create(i)),p(this,C,0),p(this,Y,0),typeof d=="function"&&p(this,$,d),typeof y=="function"&&p(this,lt,y),typeof m=="function"?(p(this,q,m),p(this,D,[])):(p(this,q,void 0),p(this,D,void 0)),p(this,tt,!!e(this,$)),p(this,bt,!!e(this,lt)),p(this,I,!!e(this,q)),this.noDisposeOnSet=!!v,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!R,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!_t,this.ignoreFetchAbort=!!ut,this.maxEntrySize!==0){if(e(this,j)!==0&&!st(e(this,j)))throw new TypeError("maxSize must be a positive integer if specified");if(!st(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,l,qt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!L,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=st(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!st(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,l,Gt).call(this);}if(e(this,B)===0&&this.ttl===0&&e(this,j)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,B)&&!e(this,j)){let kt="LRU_CACHE_UNBOUNDED";ee(kt)&&(Kt.add(kt),Pt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",kt,vt));}}get perf(){return e(this,J)}static unsafeExposeInternals(t){return {starts:e(t,Z),ttls:e(t,U),autopurgeTimers:e(t,K),sizes:e(t,Q),keyMap:e(t,E),keyList:e(t,x),valList:e(t,g),next:e(t,G),prev:e(t,V),get head(){return e(t,k)},get tail(){return e(t,F)},free:e(t,X),isBackgroundFetch:i=>{var s;return f(s=t,l,_).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return f(n=t,l,Ft).call(n,i,s,r,o)},moveToTail:i=>{var s;return f(s=t,l,xt).call(s,i)},indexes:i=>{var s;return f(s=t,l,rt).call(s,i)},rindexes:i=>{var s;return f(s=t,l,ot).call(s,i)},isStale:i=>{var s;return e(s=t,P).call(s,i)}}}get max(){return e(this,B)}get maxSize(){return e(this,j)}get calculatedSize(){return e(this,Y)}get size(){return e(this,C)}get fetchMethod(){return e(this,gt)}get memoMethod(){return e(this,mt)}get dispose(){return e(this,$)}get onInsert(){return e(this,lt)}get disposeAfter(){return e(this,q)}getRemainingTTL(t){return e(this,E).has(t)?1/0:0}*entries(){for(let t of f(this,l,rt).call(this))e(this,g)[t]!==void 0&&e(this,x)[t]!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield [e(this,x)[t],e(this,g)[t]]);}*rentries(){for(let t of f(this,l,ot).call(this))e(this,g)[t]!==void 0&&e(this,x)[t]!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield [e(this,x)[t],e(this,g)[t]]);}*keys(){for(let t of f(this,l,rt).call(this)){let i=e(this,x)[t];i!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield i);}}*rkeys(){for(let t of f(this,l,ot).call(this)){let i=e(this,x)[t];i!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield i);}}*values(){for(let t of f(this,l,rt).call(this))e(this,g)[t]!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield e(this,g)[t]);}*rvalues(){for(let t of f(this,l,ot).call(this))e(this,g)[t]!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield e(this,g)[t]);}[(Ut=Symbol.iterator,Vt=Symbol.toStringTag,Ut)](){return this.entries()}find(t,i={}){for(let s of f(this,l,rt).call(this)){let r=e(this,g)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,x)[s],this))return this.get(e(this,x)[s],i)}}forEach(t,i=this){for(let s of f(this,l,rt).call(this)){let r=e(this,g)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,x)[s],this);}}rforEach(t,i=this){for(let s of f(this,l,ot).call(this)){let r=e(this,g)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,x)[s],this);}}purgeStale(){let t=false;for(let i of f(this,l,ot).call(this,{allowStale:true}))e(this,P).call(this,i)&&(f(this,l,nt).call(this,e(this,x)[i],"expire"),t=true);return t}info(t){let i=e(this,E).get(t);if(i===void 0)return;let s=e(this,g)[i],r=f(this,l,_).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,U)&&e(this,Z)){let n=e(this,U)[i],a=e(this,Z)[i];if(n&&a){let h=n-(e(this,J).now()-a);o.ttl=h,o.start=Date.now();}}return e(this,Q)&&(o.size=e(this,Q)[i]),o}dump(){let t=[];for(let i of f(this,l,rt).call(this,{allowStale:true})){let s=e(this,x)[i],r=e(this,g)[i],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,U)&&e(this,Z)){n.ttl=e(this,U)[i];let a=e(this,J).now()-e(this,Z)[i];n.start=Math.floor(Date.now()-a);}e(this,Q)&&(n.size=e(this,Q)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,J).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var v,T,W,H;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,y=e(this,At).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&y>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),f(this,l,nt).call(this,t,"set"),this;let m=e(this,C)===0?void 0:e(this,E).get(t);if(m===void 0)m=e(this,C)===0?e(this,F):e(this,X).length!==0?e(this,X).pop():e(this,C)===e(this,B)?f(this,l,Ct).call(this,false):e(this,C),e(this,x)[m]=t,e(this,g)[m]=i,e(this,E).set(t,m),e(this,G)[e(this,F)]=m,e(this,V)[m]=e(this,F),p(this,F,m),Ot(this,C)._++,e(this,St).call(this,m,y,h),h&&(h.set="add"),d=false,e(this,bt)&&((v=e(this,lt))==null||v.call(this,i,t,"add"));else {f(this,l,xt).call(this,m);let w=e(this,g)[m];if(i!==w){if(e(this,at)&&f(this,l,_).call(this,w)){w.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:b}=w;b!==void 0&&!n&&(e(this,tt)&&((T=e(this,$))==null||T.call(this,b,t,"set")),e(this,I)&&e(this,D)?.push([b,t,"set"]));}else n||(e(this,tt)&&((W=e(this,$))==null||W.call(this,w,t,"set")),e(this,I)&&e(this,D)?.push([w,t,"set"]));if(e(this,ft).call(this,m),e(this,St).call(this,m,y,h),e(this,g)[m]=i,h){h.set="replace";let b=w&&f(this,l,_).call(this,w)?w.__staleWhileFetching:w;b!==void 0&&(h.oldValue=b);}}else h&&(h.set="update");e(this,bt)&&this.onInsert?.(i,t,i===w?"update":"replace");}if(r!==0&&!e(this,U)&&f(this,l,Gt).call(this),e(this,U)&&(d||e(this,Ht).call(this,m,r,o),h&&e(this,it).call(this,h,m)),!n&&e(this,I)&&e(this,D)){let w=e(this,D),b;for(;b=w?.shift();)(H=e(this,q))==null||H.call(this,...b);}return this}pop(){var t;try{for(;e(this,C);){let i=e(this,g)[e(this,k)];if(f(this,l,Ct).call(this,!0),f(this,l,_).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,I)&&e(this,D)){let i=e(this,D),s;for(;s=i?.shift();)(t=e(this,q))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,E).get(t);if(o!==void 0){let n=e(this,g)[o];if(f(this,l,_).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,P).call(this,o))r&&(r.has="stale",e(this,it).call(this,r,o));else return s&&e(this,ct).call(this,o),r&&(r.has="hit",e(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,E).get(t);if(r===void 0||!s&&e(this,P).call(this,r))return;let o=e(this,g)[r];return f(this,l,_).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:y=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:v=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:W=this.allowStaleOnFetchAbort,context:H,forceRefresh:w=false,status:b,signal:z}=i;if(!e(this,at))return b&&(b.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:b});let R={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:d,noUpdateTTL:y,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:W,ignoreFetchAbort:T,status:b,signal:z},L=e(this,E).get(t);if(L===void 0){b&&(b.fetch="miss");let A=f(this,l,Ft).call(this,t,L,R,H);return A.__returned=A}else {let A=e(this,g)[L];if(f(this,l,_).call(this,A)){let dt=s&&A.__staleWhileFetching!==void 0;return b&&(b.fetch="inflight",dt&&(b.returnedStale=true)),dt?A.__staleWhileFetching:A.__returned=A}let _t=e(this,P).call(this,L);if(!w&&!_t)return b&&(b.fetch="hit"),f(this,l,xt).call(this,L),r&&e(this,ct).call(this,L),b&&e(this,it).call(this,b,L),A;let ut=f(this,l,Ft).call(this,t,L,R,H),pt=ut.__staleWhileFetching!==void 0&&s;return b&&(b.fetch=_t?"stale":"refresh",pt&&_t&&(b.returnedStale=true)),pt?ut.__staleWhileFetching:ut.__returned=ut}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,mt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=s(t,a,{options:n,context:r});return this.set(t,h,n),h}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,E).get(t);if(a!==void 0){let h=e(this,g)[a],d=f(this,l,_).call(this,h);return n&&e(this,it).call(this,n,a),e(this,P).call(this,a)?(n&&(n.get="stale"),d?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||f(this,l,nt).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),d?h.__staleWhileFetching:(f(this,l,xt).call(this,a),r&&e(this,ct).call(this,a),h))}else n&&(n.get="miss");}delete(t){return f(this,l,nt).call(this,t,"delete")}clear(){return f(this,l,Nt).call(this,"delete")}},B=new WeakMap,j=new WeakMap,$=new WeakMap,lt=new WeakMap,q=new WeakMap,gt=new WeakMap,mt=new WeakMap,J=new WeakMap,C=new WeakMap,Y=new WeakMap,E=new WeakMap,x=new WeakMap,g=new WeakMap,G=new WeakMap,V=new WeakMap,k=new WeakMap,F=new WeakMap,X=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,U=new WeakMap,K=new WeakMap,tt=new WeakMap,at=new WeakMap,I=new WeakMap,bt=new WeakMap,l=new WeakSet,Gt=function(){let t=new Tt(e(this,B)),i=new Tt(e(this,B));p(this,U,t),p(this,Z,i);let s=this.ttlAutopurge?new Array(e(this,B)):void 0;p(this,K,s),p(this,Ht,(a,h,d=e(this,J).now())=>{i[a]=h!==0?d:0,t[a]=h,r(a,h);}),p(this,ct,a=>{i[a]=t[a]!==0?e(this,J).now():0,r(a,t[a]);});let r=this.ttlAutopurge?(a,h)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),h&&h!==0&&s){let d=setTimeout(()=>{e(this,P).call(this,a)&&f(this,l,nt).call(this,e(this,x)[a],"expire");},h+1);d.unref&&d.unref(),s[a]=d;}}:()=>{};p(this,it,(a,h)=>{if(t[h]){let d=t[h],y=i[h];if(!d||!y)return;a.ttl=d,a.start=y,a.now=o||n();let m=a.now-y;a.remainingTTL=d-m;}});let o=0,n=()=>{let a=e(this,J).now();if(this.ttlResolution>0){o=a;let h=setTimeout(()=>o=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=e(this,E).get(a);if(h===void 0)return 0;let d=t[h],y=i[h];if(!d||!y)return 1/0;let m=(o||n())-y;return d-m},p(this,P,a=>{let h=i[a],d=t[a];return !!d&&!!h&&(o||n())-h>d});},ct=new WeakMap,it=new WeakMap,Ht=new WeakMap,P=new WeakMap,qt=function(){let t=new Tt(e(this,B));p(this,Y,0),p(this,Q,t),p(this,ft,i=>{p(this,Y,e(this,Y)-t[i]),t[i]=0;}),p(this,At,(i,s,r,o)=>{if(f(this,l,_).call(this,s))return 0;if(!st(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!st(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}),p(this,St,(i,s,r)=>{if(t[i]=s,e(this,j)){let o=e(this,j)-t[i];for(;e(this,Y)>o;)f(this,l,Ct).call(this,true);}p(this,Y,e(this,Y)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,Y));});},ft=new WeakMap,St=new WeakMap,At=new WeakMap,rt=function*({allowStale:t=this.allowStale}={}){if(e(this,C))for(let i=e(this,F);!(!f(this,l,It).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,k)));)i=e(this,V)[i];},ot=function*({allowStale:t=this.allowStale}={}){if(e(this,C))for(let i=e(this,k);!(!f(this,l,It).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,F)));)i=e(this,G)[i];},It=function(t){return t!==void 0&&e(this,E).get(e(this,x)[t])===t},Ct=function(t){var o;let i=e(this,k),s=e(this,x)[i],r=e(this,g)[i];return e(this,at)&&f(this,l,_).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,tt)||e(this,I))&&(e(this,tt)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,I)&&e(this,D)?.push([r,s,"evict"])),e(this,ft).call(this,i),e(this,K)?.[i]&&(clearTimeout(e(this,K)[i]),e(this,K)[i]=void 0),t&&(e(this,x)[i]=void 0,e(this,g)[i]=void 0,e(this,X).push(i)),e(this,C)===1?(p(this,k,p(this,F,0)),e(this,X).length=0):p(this,k,e(this,G)[i]),e(this,E).delete(s),Ot(this,C)._--,i},Ft=function(t,i,s,r){let o=i===void 0?void 0:e(this,g)[i];if(f(this,l,_).call(this,o))return o;let n=new Dt,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:s,context:r},d=(H,w=false)=>{let{aborted:b}=n.signal,z=s.ignoreFetchAbort&&H!==void 0,R=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&H!==void 0);if(s.status&&(b&&!w?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,z&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),b&&!z&&!w)return m(n.signal.reason,R);let L=T,A=e(this,g)[i];return (A===T||z&&w&&A===void 0)&&(H===void 0?L.__staleWhileFetching!==void 0?e(this,g)[i]=L.__staleWhileFetching:f(this,l,nt).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,H,h.options))),H},y=H=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=H),m(H,false)),m=(H,w)=>{let{aborted:b}=n.signal,z=b&&s.allowStaleOnFetchAbort,R=z||s.allowStaleOnFetchRejection,L=R||s.noDeleteOnFetchRejection,A=T;if(e(this,g)[i]===T&&(!L||!w&&A.__staleWhileFetching===void 0?f(this,l,nt).call(this,t,"fetch"):z||(e(this,g)[i]=A.__staleWhileFetching)),R)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw H},v=(H,w)=>{var z;let b=(z=e(this,gt))==null?void 0:z.call(this,t,o,h);b&&b instanceof Promise&&b.then(R=>H(R===void 0?void 0:R),w),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(H(void 0),s.allowStaleOnFetchAbort&&(H=R=>d(R,true)));});};s.status&&(s.status.fetchDispatched=true);let T=new Promise(v).then(d,y),W=Object.assign(T,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,W,{...h.options,status:void 0}),i=e(this,E).get(t)):e(this,g)[i]=W,W},_=function(t){if(!e(this,at))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Dt},Rt=function(t,i){e(this,V)[i]=t,e(this,G)[t]=i;},xt=function(t){t!==e(this,F)&&(t===e(this,k)?p(this,k,e(this,G)[t]):f(this,l,Rt).call(this,e(this,V)[t],e(this,G)[t]),f(this,l,Rt).call(this,e(this,F),t),p(this,F,t));},nt=function(t,i){var r,o;let s=false;if(e(this,C)!==0){let n=e(this,E).get(t);if(n!==void 0)if(e(this,K)?.[n]&&(clearTimeout(e(this,K)?.[n]),e(this,K)[n]=void 0),s=true,e(this,C)===1)f(this,l,Nt).call(this,i);else {e(this,ft).call(this,n);let a=e(this,g)[n];if(f(this,l,_).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,tt)||e(this,I))&&(e(this,tt)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,I)&&e(this,D)?.push([a,t,i])),e(this,E).delete(t),e(this,x)[n]=void 0,e(this,g)[n]=void 0,n===e(this,F))p(this,F,e(this,V)[n]);else if(n===e(this,k))p(this,k,e(this,G)[n]);else {let h=e(this,V)[n];e(this,G)[h]=e(this,G)[n];let d=e(this,G)[n];e(this,V)[d]=e(this,V)[n];}Ot(this,C)._--,e(this,X).push(n);}}if(e(this,I)&&e(this,D)?.length){let n=e(this,D),a;for(;a=n?.shift();)(o=e(this,q))==null||o.call(this,...a);}return s},Nt=function(t){var i,s;for(let r of f(this,l,ot).call(this,{allowStale:true})){let o=e(this,g)[r];if(f(this,l,_).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,x)[r];e(this,tt)&&((i=e(this,$))==null||i.call(this,o,n,t)),e(this,I)&&e(this,D)?.push([o,n,t]);}}if(e(this,E).clear(),e(this,g).fill(void 0),e(this,x).fill(void 0),e(this,U)&&e(this,Z)){e(this,U).fill(0),e(this,Z).fill(0);for(let r of e(this,K)??[])r!==void 0&&clearTimeout(r);e(this,K)?.fill(void 0);}if(e(this,Q)&&e(this,Q).fill(0),p(this,k,0),p(this,F,0),e(this,X).length=0,p(this,Y,0),p(this,C,0),e(this,I)&&e(this,D)){let r=e(this,D),o;for(;o=r?.shift();)(s=e(this,q))==null||s.call(this,...o);}},vt);var ht=class{cache;map=new Map;constructor(t){this.cache=new $t({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 i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var u=class c{static _diffHistory=new ht({cacheSize:5});static _stepsInfoHistory=new ht({cacheSize:5});static _narrationHistory=new ht({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return c._originalStepData?c._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){c._originalStepData=t;}};var O;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(O||={});function wt(c){try{if(typeof c>"u")return c;let t=JSON.stringify(c);return JSON.parse(t)}catch(t){throw O.error("Error creating exportable element",c,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}function Jt(c,t){let i=wt(c);return t.length>1&&"type"in t[0]&&(t=t.slice().reverse()),t.forEach(s=>{re(i,s);}),i}function re(c,t){let i=c;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":i[s]=t.oldValue;break;case "CREATE":Array.isArray(i)&&typeof s=="number"?i.splice(s,1):delete i[s];break}else i=i[s];}):O.warn("No path found, skipping diff",t);}var Yt=["Date","RegExp","String","Number"],Xt=Object.getOwnPropertyNames(globalThis.Temporal||{});function Mt(c,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(c);for(let a in c){let h=c[a],d=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[d],oldValue:h});continue}let y=t[a],m=typeof h=="object"&&typeof y=="object"&&Array.isArray(h)===Array.isArray(y),v=m&&h?Object.getPrototypeOf(h)?.constructor?.name:void 0;if(h&&y&&m&&!Yt.includes(v)&&!Xt.includes(v)&&(!i.cyclesFix||!s.includes(h))){i.cyclesFix&&s.push(h);let T=Mt(h,y,i,s);i.cyclesFix&&s.pop();for(let W of T)W.path.unshift(d),r.push(W);}else Object.is(h,y)||Xt.includes(v)&&String(h)===String(y)||Yt.includes(v)&&(isNaN(h)?h+""==y+"":+h==+y)||r.push({path:[d],type:"CHANGE",value:y,oldValue:h});}let n=Array.isArray(t);for(let a in t)a in c||r.push({type:"CREATE",path:[n?+a:a],value:t[a]});return r}var Et=class{get stepsInfoMap(){return u._stepsInfoHistory}get diffMap(){return u._diffHistory}get narrationMap(){return u._narrationHistory}get size(){return u._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let t=null;for(let i of this.keys())(t===null||i>t)&&(t=i);return t}get lastDiffKey(){let t=null;for(let i of u._diffHistory.keys())(t===null||i>t)&&(t=i);return t}get goBackMode(){return u.goBackMode}set goBackMode(t){u.goBackMode=t;}keys(){return u._stepsInfoHistory.keys()}get(t){let i=u._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){u._stepsInfoHistory.delete(t),u._diffHistory.delete(t),u._narrationHistory.delete(t);}deleteFromKeyOnward(t){Array.from(this.keys()).filter(i=>i>=t).forEach(i=>{this.delete(i);});}previousCheckpointKey(t){let i=0;for(let s of u._diffHistory.keys())s<t&&s>i&&(i=s);return i}getOldGameState(t,i){if(t<=0||this.size===0)return i;let s=this.lastDiffKey;if(typeof s!="number")return O.warn("You can't go back, there is no step to go back"),i;let r=u._diffHistory.get(s);if(r)try{let o=Jt(i,r),n=this.previousCheckpointKey(s)+1;return core.GameUnifier.stepCounter=n,this.deleteFromKeyOnward(n),this.getOldGameState(t-1,o)}catch(o){return O.error("Error applying diff",o),i}else return O.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){O.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){O.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(core.GameUnifier.runningStepsCount>0){core.GameUnifier.increaseBackRequest(s);return}if(u._diffHistory.size<1){O.warn("You can't go back, there is no step to go back");return}core.GameUnifier.runningStepsCount++;try{let r=wt(this.getOldGameState(s,u.originalStepData));if(r){await core.GameUnifier.restoreGameStepState(r,core.GameUnifier.navigate);let o=core.GameUnifier.stepCounter-1,n=u._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=u._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});u._narrationHistory.set(a.index,h);}}}else O.error("Error going back");u.originalStepData=r;}catch(r){O.error("Error going back",r);}if(core.GameUnifier.runningStepsCount--,core.GameUnifier.runningStepsCount===0&&core.GameUnifier.backRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(t)}isCheckpointStep(t,i){if(u.goBackMode==="step"||t.choices&&t.choices.length>0||t.isRequiredInput)return true;let s=t.openedLabels??[],r=i?.openedLabels??[];return s.length!==r.length?true:s.some((o,n)=>o.label!==r[n]?.label)}add(t,i={}){let s=u.originalStepData,{ignoreSameStep:r}=i,o=core.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey,a=typeof n=="number"?u._stepsInfoHistory.get(n):void 0,h=t.index===0||this.isCheckpointStep(t,a);(async()=>{try{let y=typeof n=="number"?u._narrationHistory.get(n):void 0;if(u._stepsInfoHistory.set(t.index,t),t.index!==0&&h){let T=Mt(s,o);T?u._diffHistory.set(t.index,T):O.warn("It was not possible to create the difference between the two steps");}let m={},v=this.itemMapper({step:t},m);if(u._narrationHistory.set(t.index,v),a&&y&&typeof n=="number"){let T=this.itemMapper({...m,step:a},{});u._narrationHistory.set(n,T);}}catch(y){O.error("Error adding history step",y);}})(),(t.index===0||h)&&(u.originalStepData=o);}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let h=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||h||o){let d=h?.map((y,m)=>{let v=false;return y.oneTime&&s.alreadyMadeChoices?.includes(m)&&(v=true),{text:y.text,type:y.type,isResponse:false,hidden:v}});if(d){if(d.every(y=>y.hidden)){let y=d.find(m=>m.hidden===false);y&&(y.hidden=false);}r!==void 0&&(d[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?core.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:d,stepIndex:s.index,inputValue:o,openedLabelsNumber:s.openedLabels?.length}}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=[],i=Array.from(this.keys()).sort((h,d)=>d-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=u._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((h,d)=>{let y=this.get(h);if(y){if(d===0)return t.push(y),true;let m=u._stepsInfoHistory.get(h);if(!m)return true;let v=m.openedLabels;if(!v||!Array.isArray(v)||v.length===0||v[0].label!==a||v[0].currentStepIndex>n)return false;n=v[0].currentStepIndex,t.push(y);}return true}),t.reverse()}get currentPageParagraphs(){let t=[],i;return this.currentLabelHistory.forEach(s=>{t.length===0||s.openedLabelsNumber!==i?t.push([s]):t[t.length-1].push(s),i=s.openedLabelsNumber;}),t}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.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(){return u._diffHistory.size>0}blockGoBack(){core.GameUnifier.runningStepsCount===0&&u._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return O.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 i=[];return t.forEach(s=>{let r=u._stepsInfoHistory.get(s);if(r){let o=u._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:wt(i),originalStepData:wt(u._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=u._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&u._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{Object.hasOwn(t,"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()):O.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(t,"originalStepData")?u._originalStepData=t.originalStepData:O.warn("Could not import originalStepData data, so will be ignored");}catch(i){O.error("Error importing data",i);}}};var ke=new Et;exports.HistoryManagerStatic=u;exports.stepHistory=ke;
1
+ 'use strict';var core=require('@drincs/pixi-vn/core'),worker=require('@drincs/pixi-vn/worker');var Xt=Object.defineProperty;var kt=f=>{throw TypeError(f)};var Jt=(f,t,i)=>t in f?Xt(f,t,{enumerable:true,configurable:true,writable:true,value:i}):f[t]=i;var R=(f,t,i)=>Jt(f,typeof t!="symbol"?t+"":t,i),Dt=(f,t,i)=>t.has(f)||kt("Cannot "+i);var e=(f,t,i)=>(Dt(f,t,"read from private field"),i?i.call(f):t.get(f)),S=(f,t,i)=>t.has(f)?kt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,i),p=(f,t,i,s)=>(Dt(f,t,"write to private field"),t.set(f,i),i),u=(f,t,i)=>(Dt(f,t,"access private method"),i);var Tt=(f,t,i,s)=>({set _(r){p(f,t,r);},get _(){return e(f,t,s)}});var zt="narration";var Vt={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 Qt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Yt=new Set,Mt=typeof process=="object"&&process?process:{},Wt=(f,t,i,s)=>{typeof Mt.emitWarning=="function"?Mt.emitWarning(f,t,i,s):console.error(`[${i}] ${t}: ${f}`);},Rt=globalThis.AbortController,Ut=globalThis.AbortSignal;if(typeof Rt>"u"){Ut=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Rt=class{constructor(){t();}signal=new Ut;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 f=Mt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=false,Wt("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 Zt=f=>!Yt.has(f);var st=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),jt=f=>st(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Ht:null:null,Ht=class extends Array{constructor(f){super(f),this.fill(0);}},et,gt,te=(et=class{heap;length;static create(t){let i=jt(t);if(!i)return [];p(et,gt,true);let s=new et(t,i);return p(et,gt,false),s}constructor(t,i){if(!e(et,gt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},gt=new WeakMap,S(et,gt,false),et),Kt,Pt,W,z,j,lt,B,yt,mt,q,H,$,T,v,g,L,V,D,x,X,I,J,Q,U,K,Z,at,G,St,h,Nt,ut,it,wt,P,qt,ct,_t,At,rt,nt,Lt,xt,It,E,Gt,vt,ot,Ft,bt,Bt=(bt=class{constructor(t){S(this,h);S(this,W);S(this,z);S(this,j);S(this,lt);S(this,B);S(this,yt);S(this,mt);S(this,q);R(this,"ttl");R(this,"ttlResolution");R(this,"ttlAutopurge");R(this,"updateAgeOnGet");R(this,"updateAgeOnHas");R(this,"allowStale");R(this,"noDisposeOnSet");R(this,"noUpdateTTL");R(this,"maxEntrySize");R(this,"sizeCalculation");R(this,"noDeleteOnFetchRejection");R(this,"noDeleteOnStaleGet");R(this,"allowStaleOnFetchAbort");R(this,"allowStaleOnFetchRejection");R(this,"ignoreFetchAbort");S(this,H);S(this,$);S(this,T);S(this,v);S(this,g);S(this,L);S(this,V);S(this,D);S(this,x);S(this,X);S(this,I);S(this,J);S(this,Q);S(this,U);S(this,K);S(this,Z);S(this,at);S(this,G);S(this,St);S(this,ut,()=>{});S(this,it,()=>{});S(this,wt,()=>{});S(this,P,()=>false);S(this,ct,t=>{});S(this,_t,(t,i,s)=>{});S(this,At,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});R(this,Kt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:l,dispose:d,onInsert:_,disposeAfter:m,noDisposeOnSet:O,noUpdateTTL:Y,maxSize:tt=0,maxEntrySize:w=0,sizeCalculation:b,fetchMethod:y,memoMethod:M,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:Et,ignoreFetchAbort:ft,perf:pt}=t;if(pt!==void 0&&typeof pt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(p(this,q,pt??Qt),i!==0&&!st(i))throw new TypeError("max option must be a nonnegative integer");let dt=i?jt(i):Array;if(!dt)throw new Error("invalid max value: "+i);if(p(this,W,i),p(this,z,tt),this.maxEntrySize=w||e(this,z),this.sizeCalculation=b,this.sizeCalculation){if(!e(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(p(this,mt,M),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(p(this,yt,y),p(this,at,!!y),p(this,T,new Map),p(this,v,new Array(i).fill(void 0)),p(this,g,new Array(i).fill(void 0)),p(this,L,new dt(i)),p(this,V,new dt(i)),p(this,D,0),p(this,x,0),p(this,X,te.create(i)),p(this,H,0),p(this,$,0),typeof d=="function"&&p(this,j,d),typeof _=="function"&&p(this,lt,_),typeof m=="function"?(p(this,B,m),p(this,I,[])):(p(this,B,void 0),p(this,I,void 0)),p(this,Z,!!e(this,j)),p(this,St,!!e(this,lt)),p(this,G,!!e(this,B)),this.noDisposeOnSet=!!O,this.noUpdateTTL=!!Y,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!Et,this.ignoreFetchAbort=!!ft,this.maxEntrySize!==0){if(e(this,z)!==0&&!st(e(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!st(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");u(this,h,qt).call(this);}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=st(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!st(this.ttl))throw new TypeError("ttl must be a positive integer if specified");u(this,h,Nt).call(this);}if(e(this,W)===0&&this.ttl===0&&e(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,W)&&!e(this,z)){let Ct="LRU_CACHE_UNBOUNDED";Zt(Ct)&&(Yt.add(Ct),Wt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ct,bt));}}get perf(){return e(this,q)}static unsafeExposeInternals(t){return {starts:e(t,Q),ttls:e(t,U),autopurgeTimers:e(t,K),sizes:e(t,J),keyMap:e(t,T),keyList:e(t,v),valList:e(t,g),next:e(t,L),prev:e(t,V),get head(){return e(t,D)},get tail(){return e(t,x)},free:e(t,X),isBackgroundFetch:i=>{var s;return u(s=t,h,E).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return u(n=t,h,It).call(n,i,s,r,o)},moveToTail:i=>{var s;return u(s=t,h,vt).call(s,i)},indexes:i=>{var s;return u(s=t,h,rt).call(s,i)},rindexes:i=>{var s;return u(s=t,h,nt).call(s,i)},isStale:i=>{var s;return e(s=t,P).call(s,i)}}}get max(){return e(this,W)}get maxSize(){return e(this,z)}get calculatedSize(){return e(this,$)}get size(){return e(this,H)}get fetchMethod(){return e(this,yt)}get memoMethod(){return e(this,mt)}get dispose(){return e(this,j)}get onInsert(){return e(this,lt)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,T).has(t)?1/0:0}*entries(){for(let t of u(this,h,rt).call(this))e(this,g)[t]!==void 0&&e(this,v)[t]!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield [e(this,v)[t],e(this,g)[t]]);}*rentries(){for(let t of u(this,h,nt).call(this))e(this,g)[t]!==void 0&&e(this,v)[t]!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield [e(this,v)[t],e(this,g)[t]]);}*keys(){for(let t of u(this,h,rt).call(this)){let i=e(this,v)[t];i!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield i);}}*rkeys(){for(let t of u(this,h,nt).call(this)){let i=e(this,v)[t];i!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield i);}}*values(){for(let t of u(this,h,rt).call(this))e(this,g)[t]!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield e(this,g)[t]);}*rvalues(){for(let t of u(this,h,nt).call(this))e(this,g)[t]!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield e(this,g)[t]);}[(Pt=Symbol.iterator,Kt=Symbol.toStringTag,Pt)](){return this.entries()}find(t,i={}){for(let s of u(this,h,rt).call(this)){let r=e(this,g)[s],o=u(this,h,E).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,v)[s],this))return this.get(e(this,v)[s],i)}}forEach(t,i=this){for(let s of u(this,h,rt).call(this)){let r=e(this,g)[s],o=u(this,h,E).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,v)[s],this);}}rforEach(t,i=this){for(let s of u(this,h,nt).call(this)){let r=e(this,g)[s],o=u(this,h,E).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,v)[s],this);}}purgeStale(){let t=false;for(let i of u(this,h,nt).call(this,{allowStale:true}))e(this,P).call(this,i)&&(u(this,h,ot).call(this,e(this,v)[i],"expire"),t=true);return t}info(t){let i=e(this,T).get(t);if(i===void 0)return;let s=e(this,g)[i],r=u(this,h,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,U)&&e(this,Q)){let n=e(this,U)[i],a=e(this,Q)[i];if(n&&a){let l=n-(e(this,q).now()-a);o.ttl=l,o.start=Date.now();}}return e(this,J)&&(o.size=e(this,J)[i]),o}dump(){let t=[];for(let i of u(this,h,rt).call(this,{allowStale:true})){let s=e(this,v)[i],r=e(this,g)[i],o=u(this,h,E).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,U)&&e(this,Q)){n.ttl=e(this,U)[i];let a=e(this,q).now()-e(this,Q)[i];n.start=Math.floor(Date.now()-a);}e(this,J)&&(n.size=e(this,J)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,q).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var O,Y,tt,w;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,_=e(this,At).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&_>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=true),u(this,h,ot).call(this,t,"set"),this;let m=e(this,H)===0?void 0:e(this,T).get(t);if(m===void 0)m=e(this,H)===0?e(this,x):e(this,X).length!==0?e(this,X).pop():e(this,H)===e(this,W)?u(this,h,xt).call(this,false):e(this,H),e(this,v)[m]=t,e(this,g)[m]=i,e(this,T).set(t,m),e(this,L)[e(this,x)]=m,e(this,V)[m]=e(this,x),p(this,x,m),Tt(this,H)._++,e(this,_t).call(this,m,_,l),l&&(l.set="add"),d=false,e(this,St)&&((O=e(this,lt))==null||O.call(this,i,t,"add"));else {u(this,h,vt).call(this,m);let b=e(this,g)[m];if(i!==b){if(e(this,at)&&u(this,h,E).call(this,b)){b.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=b;y!==void 0&&!n&&(e(this,Z)&&((Y=e(this,j))==null||Y.call(this,y,t,"set")),e(this,G)&&e(this,I)?.push([y,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,j))==null||tt.call(this,b,t,"set")),e(this,G)&&e(this,I)?.push([b,t,"set"]));if(e(this,ct).call(this,m),e(this,_t).call(this,m,_,l),e(this,g)[m]=i,l){l.set="replace";let y=b&&u(this,h,E).call(this,b)?b.__staleWhileFetching:b;y!==void 0&&(l.oldValue=y);}}else l&&(l.set="update");e(this,St)&&this.onInsert?.(i,t,i===b?"update":"replace");}if(r!==0&&!e(this,U)&&u(this,h,Nt).call(this),e(this,U)&&(d||e(this,wt).call(this,m,r,o),l&&e(this,it).call(this,l,m)),!n&&e(this,G)&&e(this,I)){let b=e(this,I),y;for(;y=b?.shift();)(w=e(this,B))==null||w.call(this,...y);}return this}pop(){var t;try{for(;e(this,H);){let i=e(this,g)[e(this,D)];if(u(this,h,xt).call(this,!0),u(this,h,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,G)&&e(this,I)){let i=e(this,I),s;for(;s=i?.shift();)(t=e(this,B))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,T).get(t);if(o!==void 0){let n=e(this,g)[o];if(u(this,h,E).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,P).call(this,o))r&&(r.has="stale",e(this,it).call(this,r,o));else return s&&e(this,ut).call(this,o),r&&(r.has="hit",e(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,T).get(t);if(r===void 0||!s&&e(this,P).call(this,r))return;let o=e(this,g)[r];return u(this,h,E).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:_=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:O=this.allowStaleOnFetchRejection,ignoreFetchAbort:Y=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:w,forceRefresh:b=false,status:y,signal:M}=i;if(!e(this,at))return y&&(y.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:y});let k={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:l,sizeCalculation:d,noUpdateTTL:_,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:tt,ignoreFetchAbort:Y,status:y,signal:M},N=e(this,T).get(t);if(N===void 0){y&&(y.fetch="miss");let A=u(this,h,It).call(this,t,N,k,w);return A.__returned=A}else {let A=e(this,g)[N];if(u(this,h,E).call(this,A)){let dt=s&&A.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",dt&&(y.returnedStale=true)),dt?A.__staleWhileFetching:A.__returned=A}let Et=e(this,P).call(this,N);if(!b&&!Et)return y&&(y.fetch="hit"),u(this,h,vt).call(this,N),r&&e(this,ut).call(this,N),y&&e(this,it).call(this,y,N),A;let ft=u(this,h,It).call(this,t,N,k,w),pt=ft.__staleWhileFetching!==void 0&&s;return y&&(y.fetch=Et?"stale":"refresh",pt&&Et&&(y.returnedStale=true)),pt?ft.__staleWhileFetching:ft.__returned=ft}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,mt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let l=s(t,a,{options:n,context:r});return this.set(t,l,n),l}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,T).get(t);if(a!==void 0){let l=e(this,g)[a],d=u(this,h,E).call(this,l);return n&&e(this,it).call(this,n,a),e(this,P).call(this,a)?(n&&(n.get="stale"),d?(n&&s&&l.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?l.__staleWhileFetching:void 0):(o||u(this,h,ot).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?l:void 0)):(n&&(n.get="hit"),d?l.__staleWhileFetching:(u(this,h,vt).call(this,a),r&&e(this,ut).call(this,a),l))}else n&&(n.get="miss");}delete(t){return u(this,h,ot).call(this,t,"delete")}clear(){return u(this,h,Ft).call(this,"delete")}},W=new WeakMap,z=new WeakMap,j=new WeakMap,lt=new WeakMap,B=new WeakMap,yt=new WeakMap,mt=new WeakMap,q=new WeakMap,H=new WeakMap,$=new WeakMap,T=new WeakMap,v=new WeakMap,g=new WeakMap,L=new WeakMap,V=new WeakMap,D=new WeakMap,x=new WeakMap,X=new WeakMap,I=new WeakMap,J=new WeakMap,Q=new WeakMap,U=new WeakMap,K=new WeakMap,Z=new WeakMap,at=new WeakMap,G=new WeakMap,St=new WeakMap,h=new WeakSet,Nt=function(){let t=new Ht(e(this,W)),i=new Ht(e(this,W));p(this,U,t),p(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,W)):void 0;p(this,K,s),p(this,wt,(a,l,d=e(this,q).now())=>{i[a]=l!==0?d:0,t[a]=l,r(a,l);}),p(this,ut,a=>{i[a]=t[a]!==0?e(this,q).now():0,r(a,t[a]);});let r=this.ttlAutopurge?(a,l)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),l&&l!==0&&s){let d=setTimeout(()=>{e(this,P).call(this,a)&&u(this,h,ot).call(this,e(this,v)[a],"expire");},l+1);d.unref&&d.unref(),s[a]=d;}}:()=>{};p(this,it,(a,l)=>{if(t[l]){let d=t[l],_=i[l];if(!d||!_)return;a.ttl=d,a.start=_,a.now=o||n();let m=a.now-_;a.remainingTTL=d-m;}});let o=0,n=()=>{let a=e(this,q).now();if(this.ttlResolution>0){o=a;let l=setTimeout(()=>o=0,this.ttlResolution);l.unref&&l.unref();}return a};this.getRemainingTTL=a=>{let l=e(this,T).get(a);if(l===void 0)return 0;let d=t[l],_=i[l];if(!d||!_)return 1/0;let m=(o||n())-_;return d-m},p(this,P,a=>{let l=i[a],d=t[a];return !!d&&!!l&&(o||n())-l>d});},ut=new WeakMap,it=new WeakMap,wt=new WeakMap,P=new WeakMap,qt=function(){let t=new Ht(e(this,W));p(this,$,0),p(this,J,t),p(this,ct,i=>{p(this,$,e(this,$)-t[i]),t[i]=0;}),p(this,At,(i,s,r,o)=>{if(u(this,h,E).call(this,s))return 0;if(!st(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!st(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}),p(this,_t,(i,s,r)=>{if(t[i]=s,e(this,z)){let o=e(this,z)-t[i];for(;e(this,$)>o;)u(this,h,xt).call(this,true);}p(this,$,e(this,$)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,$));});},ct=new WeakMap,_t=new WeakMap,At=new WeakMap,rt=function*({allowStale:t=this.allowStale}={}){if(e(this,H))for(let i=e(this,x);!(!u(this,h,Lt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,D)));)i=e(this,V)[i];},nt=function*({allowStale:t=this.allowStale}={}){if(e(this,H))for(let i=e(this,D);!(!u(this,h,Lt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,x)));)i=e(this,L)[i];},Lt=function(t){return t!==void 0&&e(this,T).get(e(this,v)[t])===t},xt=function(t){var o;let i=e(this,D),s=e(this,v)[i],r=e(this,g)[i];return e(this,at)&&u(this,h,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,G))&&(e(this,Z)&&((o=e(this,j))==null||o.call(this,r,s,"evict")),e(this,G)&&e(this,I)?.push([r,s,"evict"])),e(this,ct).call(this,i),e(this,K)?.[i]&&(clearTimeout(e(this,K)[i]),e(this,K)[i]=void 0),t&&(e(this,v)[i]=void 0,e(this,g)[i]=void 0,e(this,X).push(i)),e(this,H)===1?(p(this,D,p(this,x,0)),e(this,X).length=0):p(this,D,e(this,L)[i]),e(this,T).delete(s),Tt(this,H)._--,i},It=function(t,i,s,r){let o=i===void 0?void 0:e(this,g)[i];if(u(this,h,E).call(this,o))return o;let n=new Rt,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let l={signal:n.signal,options:s,context:r},d=(w,b=false)=>{let{aborted:y}=n.signal,M=s.ignoreFetchAbort&&w!==void 0,k=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(y&&!b?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),y&&!M&&!b)return m(n.signal.reason,k);let N=Y,A=e(this,g)[i];return (A===Y||M&&b&&A===void 0)&&(w===void 0?N.__staleWhileFetching!==void 0?e(this,g)[i]=N.__staleWhileFetching:u(this,h,ot).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,w,l.options))),w},_=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),m(w,false)),m=(w,b)=>{let{aborted:y}=n.signal,M=y&&s.allowStaleOnFetchAbort,k=M||s.allowStaleOnFetchRejection,N=k||s.noDeleteOnFetchRejection,A=Y;if(e(this,g)[i]===Y&&(!N||!b&&A.__staleWhileFetching===void 0?u(this,h,ot).call(this,t,"fetch"):M||(e(this,g)[i]=A.__staleWhileFetching)),k)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw w},O=(w,b)=>{var M;let y=(M=e(this,yt))==null?void 0:M.call(this,t,o,l);y&&y instanceof Promise&&y.then(k=>w(k===void 0?void 0:k),b),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=k=>d(k,true)));});};s.status&&(s.status.fetchDispatched=true);let Y=new Promise(O).then(d,_),tt=Object.assign(Y,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...l.options,status:void 0}),i=e(this,T).get(t)):e(this,g)[i]=tt,tt},E=function(t){if(!e(this,at))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Rt},Gt=function(t,i){e(this,V)[i]=t,e(this,L)[t]=i;},vt=function(t){t!==e(this,x)&&(t===e(this,D)?p(this,D,e(this,L)[t]):u(this,h,Gt).call(this,e(this,V)[t],e(this,L)[t]),u(this,h,Gt).call(this,e(this,x),t),p(this,x,t));},ot=function(t,i){var r,o;let s=false;if(e(this,H)!==0){let n=e(this,T).get(t);if(n!==void 0)if(e(this,K)?.[n]&&(clearTimeout(e(this,K)?.[n]),e(this,K)[n]=void 0),s=true,e(this,H)===1)u(this,h,Ft).call(this,i);else {e(this,ct).call(this,n);let a=e(this,g)[n];if(u(this,h,E).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,G))&&(e(this,Z)&&((r=e(this,j))==null||r.call(this,a,t,i)),e(this,G)&&e(this,I)?.push([a,t,i])),e(this,T).delete(t),e(this,v)[n]=void 0,e(this,g)[n]=void 0,n===e(this,x))p(this,x,e(this,V)[n]);else if(n===e(this,D))p(this,D,e(this,L)[n]);else {let l=e(this,V)[n];e(this,L)[l]=e(this,L)[n];let d=e(this,L)[n];e(this,V)[d]=e(this,V)[n];}Tt(this,H)._--,e(this,X).push(n);}}if(e(this,G)&&e(this,I)?.length){let n=e(this,I),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},Ft=function(t){var i,s;for(let r of u(this,h,nt).call(this,{allowStale:true})){let o=e(this,g)[r];if(u(this,h,E).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,v)[r];e(this,Z)&&((i=e(this,j))==null||i.call(this,o,n,t)),e(this,G)&&e(this,I)?.push([o,n,t]);}}if(e(this,T).clear(),e(this,g).fill(void 0),e(this,v).fill(void 0),e(this,U)&&e(this,Q)){e(this,U).fill(0),e(this,Q).fill(0);for(let r of e(this,K)??[])r!==void 0&&clearTimeout(r);e(this,K)?.fill(void 0);}if(e(this,J)&&e(this,J).fill(0),p(this,D,0),p(this,x,0),e(this,X).length=0,p(this,$,0),p(this,H,0),e(this,G)&&e(this,I)){let r=e(this,I),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}},bt);var ht=class{cache;map=new Map;constructor(t){this.cache=new Bt({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 i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var c=class f{static _diffHistory=new ht({cacheSize:5});static _stepsInfoHistory=new ht({cacheSize:5});static _narrationHistory=new ht({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return f._originalStepData?f._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){f._originalStepData=t;}};var C;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(C||={});var Ot=class{get stepsInfoMap(){return c._stepsInfoHistory}get diffMap(){return c._diffHistory}get narrationMap(){return c._narrationHistory}get size(){return c._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let t=null;for(let i of this.keys())(t===null||i>t)&&(t=i);return t}get lastDiffKey(){let t=null;for(let i of c._diffHistory.keys())(t===null||i>t)&&(t=i);return t}get goBackMode(){return c.goBackMode}set goBackMode(t){c.goBackMode=t;}keys(){return c._stepsInfoHistory.keys()}get(t){let i=c._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){c._stepsInfoHistory.delete(t),c._diffHistory.delete(t),c._narrationHistory.delete(t);}deleteFromKeyOnward(t){Array.from(this.keys()).filter(i=>i>=t).forEach(i=>{this.delete(i);});}previousCheckpointKey(t){let i=0;for(let s of c._diffHistory.keys())s<t&&s>i&&(i=s);return i}pendingInputRestoreValue;findPreviousInputAnswer(t){if(c._stepsInfoHistory.get(t-1)?.isRequiredInput)return c._stepsInfoHistory.get(t)?.inputValue}async getOldGameState(t,i){if(t<=0||this.size===0)return i;let s=this.lastDiffKey;if(typeof s!="number")return C.warn("You can't go back, there is no step to go back"),i;let r=c._diffHistory.get(s);if(r)try{let o=await worker.restoreDiffMaybeOffloaded(i,r),n=this.previousCheckpointKey(s)+1;return core.GameUnifier.stepCounter=n,t===1&&(this.pendingInputRestoreValue=this.findPreviousInputAnswer(n)),this.deleteFromKeyOnward(n),this.getOldGameState(t-1,o)}catch(o){return C.error("Error applying diff",o),i}else return C.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){C.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){C.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(core.GameUnifier.runningStepsCount>0){core.GameUnifier.increaseBackRequest(s);return}if(c._diffHistory.size<1){C.warn("You can't go back, there is no step to go back");return}core.GameUnifier.runningStepsCount++;try{this.pendingInputRestoreValue=void 0;let r=await this.getOldGameState(s,c.originalStepData);if(r){await core.GameUnifier.restoreGameStepState(r,core.GameUnifier.navigate),this.pendingInputRestoreValue!==void 0&&core.GameUnifier.setVariable(zt,Vt.CURRENT_INPUT_VALUE_MEMORY_KEY,this.pendingInputRestoreValue);let o=core.GameUnifier.stepCounter-1,n=c._stepsInfoHistory.get(o),a=c._narrationHistory.get(o),l=a&&Object.keys(a).length===1&&a.stepIndex!==void 0;if(n&&(l||n.isRequiredInput)){let d=this.itemMapper({step:n,inputValue:n.isRequiredInput?this.pendingInputRestoreValue:void 0});c._narrationHistory.set(n.index,d);}}else C.error("Error going back");c.originalStepData=r;}catch(r){C.error("Error going back",r);}if(core.GameUnifier.runningStepsCount--,core.GameUnifier.runningStepsCount===0&&core.GameUnifier.backRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(t)}isCheckpointStep(t,i){if(c.goBackMode==="step"||t.choices&&t.choices.length>0||t.isRequiredInput)return true;let s=t.openedLabels??[],r=i?.openedLabels??[];return s.length!==r.length?true:s.some((o,n)=>o.label!==r[n]?.label)}async add(t,i={}){let s=c.originalStepData,{ignoreSameStep:r}=i,o=await core.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey,a=typeof n=="number"?c._stepsInfoHistory.get(n):void 0,l=t.index===0||this.isCheckpointStep(t,a);try{let d=typeof n=="number"?c._narrationHistory.get(n):void 0;c._stepsInfoHistory.set(t.index,t);let _={},m=this.itemMapper({step:t},_);if(c._narrationHistory.set(t.index,m),a&&d&&typeof n=="number"){let O=this.itemMapper({..._,step:a},{});c._narrationHistory.set(n,O);}}catch(d){C.error("Error adding history step",d);}t.index!==0&&l&&(async()=>{try{let d=await worker.diffMaybeOffloaded(s,o);d?c._diffHistory.set(t.index,d):C.warn("It was not possible to create the difference between the two steps");}catch(d){C.error("Error adding history step",d);}})(),(t.index===0||l)&&(c.originalStepData=o);}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let l=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||l||o){let d=l?.map((_,m)=>{let O=false;return _.oneTime&&s.alreadyMadeChoices?.includes(m)&&(O=true),{text:_.text,type:_.type,isResponse:false,hidden:O}});if(d){if(d.every(_=>_.hidden)){let _=d.find(m=>m.hidden===false);_&&(_.hidden=false);}r!==void 0&&(d[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?core.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:d,stepIndex:s.index,inputValue:o,openedLabelsNumber:s.openedLabels?.length}}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=[],i=Array.from(this.keys()).sort((l,d)=>d-l);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=c._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((l,d)=>{let _=this.get(l);if(_){if(d===0)return t.push(_),true;let m=c._stepsInfoHistory.get(l);if(!m)return true;let O=m.openedLabels;if(!O||!Array.isArray(O)||O.length===0||O[0].label!==a||O[0].currentStepIndex>n)return false;n=O[0].currentStepIndex,t.push(_);}return true}),t.reverse()}get currentPageParagraphs(){let t=[],i;return this.currentLabelHistory.forEach(s=>{t.length===0||s.openedLabelsNumber!==i?t.push([s]):t[t.length-1].push(s),i=s.openedLabelsNumber;}),t}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.forEach(s=>{c._narrationHistory.delete(s),c._stepsInfoHistory.delete(s),c._diffHistory.delete(s);});}else c._stepsInfoHistory.clear(),c._diffHistory.clear(),c._narrationHistory.clear();}get canGoBack(){return c._diffHistory.size>0}blockGoBack(){core.GameUnifier.runningStepsCount===0&&c._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return C.error("Error comparing opened labels",s),true}return false}clear(){c._stepsInfoHistory.clear(),c._diffHistory.clear(),c._narrationHistory.clear(),c._originalStepData=void 0;}get stepLimitSaved(){return c.stepLimitSaved}set stepLimitSaved(t){c.stepLimitSaved=t;}async export(){let t=Array.from(this.keys()).sort((n,a)=>n-a);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];t.forEach(n=>{let a=c._stepsInfoHistory.get(n);if(a){let l=c._diffHistory.get(n);i.push({...a,diff:l});}});let s=c._originalStepData,[r,o]=await Promise.all([worker.cloneMaybeOffloaded(i),s?worker.cloneMaybeOffloaded(s):void 0]);return {stepsHistory:r,originalStepData:o}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=c._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&c._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{Object.hasOwn(t,"stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&c._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};c._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):C.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(t,"originalStepData")?c._originalStepData=t.originalStepData:C.warn("Could not import originalStepData data, so will be ignored");}catch(i){C.error("Error importing data",i);}}};var Ae=new Ot;exports.HistoryManagerStatic=c;exports.stepHistory=Ae;
@@ -113,7 +113,7 @@ interface HistoryManagerInterface {
113
113
  * If true, the step will not be added to the history if the current step is the same as the last step.
114
114
  */
115
115
  ignoreSameStep?: boolean;
116
- }): void;
116
+ }): Promise<void>;
117
117
  /**
118
118
  * Clear the history.
119
119
  */
@@ -167,7 +167,7 @@ interface HistoryManagerInterface {
167
167
  * Export the history to an object.
168
168
  * @returns The history in an object.
169
169
  */
170
- export(): HistoryGameState;
170
+ export(): Promise<HistoryGameState>;
171
171
  /**
172
172
  * Restore the history from an object.
173
173
  * @param data The history in an object.
package/dist/history.d.ts CHANGED
@@ -113,7 +113,7 @@ interface HistoryManagerInterface {
113
113
  * If true, the step will not be added to the history if the current step is the same as the last step.
114
114
  */
115
115
  ignoreSameStep?: boolean;
116
- }): void;
116
+ }): Promise<void>;
117
117
  /**
118
118
  * Clear the history.
119
119
  */
@@ -167,7 +167,7 @@ interface HistoryManagerInterface {
167
167
  * Export the history to an object.
168
168
  * @returns The history in an object.
169
169
  */
170
- export(): HistoryGameState;
170
+ export(): Promise<HistoryGameState>;
171
171
  /**
172
172
  * Restore the history from an object.
173
173
  * @param data The history in an object.
package/dist/history.mjs CHANGED
@@ -1 +1 @@
1
- import'./chunk-JMOSOAGB.mjs';import {d,e,f}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var i=class d$1{static _diffHistory=new d({cacheSize:5});static _stepsInfoHistory=new d({cacheSize:5});static _narrationHistory=new d({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return d$1._originalStepData?d$1._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){d$1._originalStepData=e;}};function k(d,e){let r=f(d);return e.length>1&&"type"in e[0]&&(e=e.slice().reverse()),e.forEach(t=>{_(r,t);}),r}function _(d,e$1){let r=d;e$1.path&&e$1.path.length>0?e$1.path.forEach((t,n)=>{if(e$1.path&&n===e$1.path.length-1)switch(e$1.type){case "CHANGE":case "REMOVE":r[t]=e$1.oldValue;break;case "CREATE":Array.isArray(r)&&typeof t=="number"?r.splice(t,1):delete r[t];break}else r=r[t];}):e.warn("No path found, skipping diff",e$1);}var v=["Date","RegExp","String","Number"],M=Object.getOwnPropertyNames(globalThis.Temporal||{});function S(d,e,r={cyclesFix:true},t=[]){let n=[],a=Array.isArray(d);for(let s in d){let o=d[s],u=a?+s:s;if(!(s in e)){n.push({type:"REMOVE",path:[u],oldValue:o});continue}let p=e[s],m=typeof o=="object"&&typeof p=="object"&&Array.isArray(o)===Array.isArray(p),l=m&&o?Object.getPrototypeOf(o)?.constructor?.name:void 0;if(o&&p&&m&&!v.includes(l)&&!M.includes(l)&&(!r.cyclesFix||!t.includes(o))){r.cyclesFix&&t.push(o);let g=S(o,p,r,t);r.cyclesFix&&t.pop();for(let x of g)x.path.unshift(u),n.push(x);}else Object.is(o,p)||M.includes(l)&&String(o)===String(p)||v.includes(l)&&(isNaN(o)?o+""==p+"":+o==+p)||n.push({path:[u],type:"CHANGE",value:p,oldValue:o});}let c=Array.isArray(e);for(let s in e)s in d||n.push({type:"CREATE",path:[c?+s:s],value:e[s]});return n}var b=class{get stepsInfoMap(){return i._stepsInfoHistory}get diffMap(){return i._diffHistory}get narrationMap(){return i._narrationHistory}get size(){return i._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let e=null;for(let r of this.keys())(e===null||r>e)&&(e=r);return e}get lastDiffKey(){let e=null;for(let r of i._diffHistory.keys())(e===null||r>e)&&(e=r);return e}get goBackMode(){return i.goBackMode}set goBackMode(e){i.goBackMode=e;}keys(){return i._stepsInfoHistory.keys()}get(e){let r=i._narrationHistory.get(e);if(!(r&&Object.keys(r).length===1&&r.stepIndex!==void 0))return r}delete(e){i._stepsInfoHistory.delete(e),i._diffHistory.delete(e),i._narrationHistory.delete(e);}deleteFromKeyOnward(e){Array.from(this.keys()).filter(r=>r>=e).forEach(r=>{this.delete(r);});}previousCheckpointKey(e){let r=0;for(let t of i._diffHistory.keys())t<e&&t>r&&(r=t);return r}getOldGameState(e$1,r){if(e$1<=0||this.size===0)return r;let t=this.lastDiffKey;if(typeof t!="number")return e.warn("You can't go back, there is no step to go back"),r;let n=i._diffHistory.get(t);if(n)try{let a=k(r,n),c=this.previousCheckpointKey(t)+1;return GameUnifier.stepCounter=c,this.deleteFromKeyOnward(c),this.getOldGameState(e$1-1,a)}catch(a){return e.error("Error applying diff",a),r}else return e.warn("No diff found for the last step, cannot go back"),r}async back(e$1,r={}){let{steps:t=1}=r;if(!Number.isFinite(t)){e.warn(`[back] The parameter steps must be a valid finite number, received: ${t}`);return}if(t<=0){e.warn(`[back] The parameter steps must be greater than 0, received: ${t}`);return}if(GameUnifier.runningStepsCount>0){GameUnifier.increaseBackRequest(t);return}if(i._diffHistory.size<1){e.warn("You can't go back, there is no step to go back");return}GameUnifier.runningStepsCount++;try{let n=f(this.getOldGameState(t,i.originalStepData));if(n){await GameUnifier.restoreGameStepState(n,GameUnifier.navigate);let a=GameUnifier.stepCounter-1,c=i._narrationHistory.get(a);if(c&&Object.keys(c).length===1&&c.stepIndex!==void 0){let s=i._stepsInfoHistory.get(a);if(s){let o=this.itemMapper({step:s});i._narrationHistory.set(s.index,o);}}}else e.error("Error going back");i.originalStepData=n;}catch(n){e.error("Error going back",n);}if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1)}isCheckpointStep(e,r){if(i.goBackMode==="step"||e.choices&&e.choices.length>0||e.isRequiredInput)return true;let t=e.openedLabels??[],n=r?.openedLabels??[];return t.length!==n.length?true:t.some((a,c)=>a.label!==n[c]?.label)}add(e$1,r={}){let t=i.originalStepData,{ignoreSameStep:n}=r,a=GameUnifier.currentGameStepState;if(!n&&this.isSameStep(t,a))return;let c=this.lastKey,s=typeof c=="number"?i._stepsInfoHistory.get(c):void 0,o=e$1.index===0||this.isCheckpointStep(e$1,s);(async()=>{try{let p=typeof c=="number"?i._narrationHistory.get(c):void 0;if(i._stepsInfoHistory.set(e$1.index,e$1),e$1.index!==0&&o){let g=S(t,a);g?i._diffHistory.set(e$1.index,g):e.warn("It was not possible to create the difference between the two steps");}let m={},l=this.itemMapper({step:e$1},m);if(i._narrationHistory.set(e$1.index,l),s&&p&&typeof c=="number"){let g=this.itemMapper({...m,step:s},{});i._narrationHistory.set(c,g);}}catch(p){e.error("Error adding history step",p);}})(),(e$1.index===0||o)&&(i.originalStepData=a);}itemMapper(e,r){let{step:t,choiceIndexMade:n,inputValue:a,removeDialogue:c}=e,s=t.dialogue;r&&t.isGlued&&(r.removeDialogue=true),c&&(s=void 0);let o=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),s||o||a){let u=o?.map((p,m)=>{let l=false;return p.oneTime&&t.alreadyMadeChoices?.includes(m)&&(l=true),{text:p.text,type:p.type,isResponse:false,hidden:l}});if(u){if(u.every(p=>p.hidden)){let p=u.find(m=>m.hidden===false);p&&(p.hidden=false);}n!==void 0&&(u[n].isResponse=true);}return {dialogue:s?{...s,character:s.character?GameUnifier.getCharacter(s.character)||s.character:void 0}:void 0,playerMadeChoice:typeof n=="number",choices:u,stepIndex:t.index,inputValue:a,openedLabelsNumber:t.openedLabels?.length}}return {stepIndex:t.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((t,n)=>t-n).forEach(t=>{let n=this.get(t);n&&e.push(n);}),e}get currentLabelHistory(){let e=[],r=Array.from(this.keys()).sort((o,u)=>u-o);if(r.length===0)return e;let t=r[0];if(typeof t!="number")return e;let n=i._stepsInfoHistory.get(t);if(!n)return e;let a=n.openedLabels;if(!a||!Array.isArray(a)||a.length===0)return e;let c=a[0].currentStepIndex,s=a[0].label;return r.every((o,u)=>{let p=this.get(o);if(p){if(u===0)return e.push(p),true;let m=i._stepsInfoHistory.get(o);if(!m)return true;let l=m.openedLabels;if(!l||!Array.isArray(l)||l.length===0||l[0].label!==s||l[0].currentStepIndex>c)return false;c=l[0].currentStepIndex,e.push(p);}return true}),e.reverse()}get currentPageParagraphs(){let e=[],r;return this.currentLabelHistory.forEach(t=>{e.length===0||t.openedLabelsNumber!==r?e.push([t]):e[e.length-1].push(t),r=t.openedLabelsNumber;}),e}removeNarrativeHistory(e){if(e){let r=Array.from(this.keys()).sort((t,n)=>t-n);r=r.slice(0,e),r.forEach(t=>{i._narrationHistory.delete(t),i._stepsInfoHistory.delete(t),i._diffHistory.delete(t);});}else i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear();}get canGoBack(){return i._diffHistory.size>0}blockGoBack(){GameUnifier.runningStepsCount===0&&i._diffHistory.clear();}isSameStep(e$1,r){if(e$1.openedLabels.length===r.openedLabels.length)try{let t=JSON.stringify(e$1.openedLabels),n=JSON.stringify(r.openedLabels);if(t===n&&e$1.path===r.path&&e$1.labelIndex===r.labelIndex)return !0}catch(t){return e.error("Error comparing opened labels",t),true}return false}clear(){i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear(),i._originalStepData=void 0;}get stepLimitSaved(){return i.stepLimitSaved}set stepLimitSaved(e){i.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((t,n)=>t-n);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let r=[];return e.forEach(t=>{let n=i._stepsInfoHistory.get(t);if(n){let a=i._diffHistory.get(t);r.push({...n,diff:a});}}),{stepsHistory:f(r),originalStepData:f(i._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((t,n)=>t-n),r={};e.forEach(t=>{let n=i._stepsInfoHistory.get(t);if(n){let a={...r};r={};let c=this.itemMapper({step:n,choiceIndexMade:a.choiceIndexMade,inputValue:a.inputValue,removeDialogue:a.removeDialogue},r);c&&i._narrationHistory.set(t,c);}});}async restore(e$1){this.clear();try{Object.hasOwn(e$1,"stepsHistory")?(e$1.stepsHistory.forEach(t=>{t.diff&&i._diffHistory.set(t.index,t.diff);let n={...t,diff:void 0};i._stepsInfoHistory.set(t.index,n);}),this.restoreNarrativeHistory()):e.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(e$1,"originalStepData")?i._originalStepData=e$1.originalStepData:e.warn("Could not import originalStepData data, so will be ignored");}catch(r){e.error("Error importing data",r);}}};var j=new b;export{i as HistoryManagerStatic,j as stepHistory};
1
+ import'./chunk-JMOSOAGB.mjs';import {k,m as m$1}from'./chunk-HD353M4B.mjs';import {d,e}from'./chunk-AW5XWF24.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';import {restoreDiffMaybeOffloaded,diffMaybeOffloaded,cloneMaybeOffloaded}from'@drincs/pixi-vn/worker';var i=class g{static _diffHistory=new d({cacheSize:5});static _stepsInfoHistory=new d({cacheSize:5});static _narrationHistory=new d({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return g._originalStepData?g._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){g._originalStepData=e;}};var m=class{get stepsInfoMap(){return i._stepsInfoHistory}get diffMap(){return i._diffHistory}get narrationMap(){return i._narrationHistory}get size(){return i._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let e=null;for(let r of this.keys())(e===null||r>e)&&(e=r);return e}get lastDiffKey(){let e=null;for(let r of i._diffHistory.keys())(e===null||r>e)&&(e=r);return e}get goBackMode(){return i.goBackMode}set goBackMode(e){i.goBackMode=e;}keys(){return i._stepsInfoHistory.keys()}get(e){let r=i._narrationHistory.get(e);if(!(r&&Object.keys(r).length===1&&r.stepIndex!==void 0))return r}delete(e){i._stepsInfoHistory.delete(e),i._diffHistory.delete(e),i._narrationHistory.delete(e);}deleteFromKeyOnward(e){Array.from(this.keys()).filter(r=>r>=e).forEach(r=>{this.delete(r);});}previousCheckpointKey(e){let r=0;for(let t of i._diffHistory.keys())t<e&&t>r&&(r=t);return r}pendingInputRestoreValue;findPreviousInputAnswer(e){if(i._stepsInfoHistory.get(e-1)?.isRequiredInput)return i._stepsInfoHistory.get(e)?.inputValue}async getOldGameState(e$1,r){if(e$1<=0||this.size===0)return r;let t=this.lastDiffKey;if(typeof t!="number")return e.warn("You can't go back, there is no step to go back"),r;let n=i._diffHistory.get(t);if(n)try{let s=await restoreDiffMaybeOffloaded(r,n),a=this.previousCheckpointKey(t)+1;return GameUnifier.stepCounter=a,e$1===1&&(this.pendingInputRestoreValue=this.findPreviousInputAnswer(a)),this.deleteFromKeyOnward(a),this.getOldGameState(e$1-1,s)}catch(s){return e.error("Error applying diff",s),r}else return e.warn("No diff found for the last step, cannot go back"),r}async back(e$1,r={}){let{steps:t=1}=r;if(!Number.isFinite(t)){e.warn(`[back] The parameter steps must be a valid finite number, received: ${t}`);return}if(t<=0){e.warn(`[back] The parameter steps must be greater than 0, received: ${t}`);return}if(GameUnifier.runningStepsCount>0){GameUnifier.increaseBackRequest(t);return}if(i._diffHistory.size<1){e.warn("You can't go back, there is no step to go back");return}GameUnifier.runningStepsCount++;try{this.pendingInputRestoreValue=void 0;let n=await this.getOldGameState(t,i.originalStepData);if(n){await GameUnifier.restoreGameStepState(n,GameUnifier.navigate),this.pendingInputRestoreValue!==void 0&&GameUnifier.setVariable(k,m$1.CURRENT_INPUT_VALUE_MEMORY_KEY,this.pendingInputRestoreValue);let s=GameUnifier.stepCounter-1,a=i._stepsInfoHistory.get(s),o=i._narrationHistory.get(s),c=o&&Object.keys(o).length===1&&o.stepIndex!==void 0;if(a&&(c||a.isRequiredInput)){let p=this.itemMapper({step:a,inputValue:a.isRequiredInput?this.pendingInputRestoreValue:void 0});i._narrationHistory.set(a.index,p);}}else e.error("Error going back");i.originalStepData=n;}catch(n){e.error("Error going back",n);}if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1)}isCheckpointStep(e,r){if(i.goBackMode==="step"||e.choices&&e.choices.length>0||e.isRequiredInput)return true;let t=e.openedLabels??[],n=r?.openedLabels??[];return t.length!==n.length?true:t.some((s,a)=>s.label!==n[a]?.label)}async add(e$1,r={}){let t=i.originalStepData,{ignoreSameStep:n}=r,s=await GameUnifier.currentGameStepState;if(!n&&this.isSameStep(t,s))return;let a=this.lastKey,o=typeof a=="number"?i._stepsInfoHistory.get(a):void 0,c=e$1.index===0||this.isCheckpointStep(e$1,o);try{let p=typeof a=="number"?i._narrationHistory.get(a):void 0;i._stepsInfoHistory.set(e$1.index,e$1);let u={},y=this.itemMapper({step:e$1},u);if(i._narrationHistory.set(e$1.index,y),o&&p&&typeof a=="number"){let d=this.itemMapper({...u,step:o},{});i._narrationHistory.set(a,d);}}catch(p){e.error("Error adding history step",p);}e$1.index!==0&&c&&(async()=>{try{let p=await diffMaybeOffloaded(t,s);p?i._diffHistory.set(e$1.index,p):e.warn("It was not possible to create the difference between the two steps");}catch(p){e.error("Error adding history step",p);}})(),(e$1.index===0||c)&&(i.originalStepData=s);}itemMapper(e,r){let{step:t,choiceIndexMade:n,inputValue:s,removeDialogue:a}=e,o=t.dialogue;r&&t.isGlued&&(r.removeDialogue=true),a&&(o=void 0);let c=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),o||c||s){let p=c?.map((u,y)=>{let d=false;return u.oneTime&&t.alreadyMadeChoices?.includes(y)&&(d=true),{text:u.text,type:u.type,isResponse:false,hidden:d}});if(p){if(p.every(u=>u.hidden)){let u=p.find(y=>y.hidden===false);u&&(u.hidden=false);}n!==void 0&&(p[n].isResponse=true);}return {dialogue:o?{...o,character:o.character?GameUnifier.getCharacter(o.character)||o.character:void 0}:void 0,playerMadeChoice:typeof n=="number",choices:p,stepIndex:t.index,inputValue:s,openedLabelsNumber:t.openedLabels?.length}}return {stepIndex:t.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((t,n)=>t-n).forEach(t=>{let n=this.get(t);n&&e.push(n);}),e}get currentLabelHistory(){let e=[],r=Array.from(this.keys()).sort((c,p)=>p-c);if(r.length===0)return e;let t=r[0];if(typeof t!="number")return e;let n=i._stepsInfoHistory.get(t);if(!n)return e;let s=n.openedLabels;if(!s||!Array.isArray(s)||s.length===0)return e;let a=s[0].currentStepIndex,o=s[0].label;return r.every((c,p)=>{let u=this.get(c);if(u){if(p===0)return e.push(u),true;let y=i._stepsInfoHistory.get(c);if(!y)return true;let d=y.openedLabels;if(!d||!Array.isArray(d)||d.length===0||d[0].label!==o||d[0].currentStepIndex>a)return false;a=d[0].currentStepIndex,e.push(u);}return true}),e.reverse()}get currentPageParagraphs(){let e=[],r;return this.currentLabelHistory.forEach(t=>{e.length===0||t.openedLabelsNumber!==r?e.push([t]):e[e.length-1].push(t),r=t.openedLabelsNumber;}),e}removeNarrativeHistory(e){if(e){let r=Array.from(this.keys()).sort((t,n)=>t-n);r=r.slice(0,e),r.forEach(t=>{i._narrationHistory.delete(t),i._stepsInfoHistory.delete(t),i._diffHistory.delete(t);});}else i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear();}get canGoBack(){return i._diffHistory.size>0}blockGoBack(){GameUnifier.runningStepsCount===0&&i._diffHistory.clear();}isSameStep(e$1,r){if(e$1.openedLabels.length===r.openedLabels.length)try{let t=JSON.stringify(e$1.openedLabels),n=JSON.stringify(r.openedLabels);if(t===n&&e$1.path===r.path&&e$1.labelIndex===r.labelIndex)return !0}catch(t){return e.error("Error comparing opened labels",t),true}return false}clear(){i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear(),i._originalStepData=void 0;}get stepLimitSaved(){return i.stepLimitSaved}set stepLimitSaved(e){i.stepLimitSaved=e;}async export(){let e=Array.from(this.keys()).sort((a,o)=>a-o);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let r=[];e.forEach(a=>{let o=i._stepsInfoHistory.get(a);if(o){let c=i._diffHistory.get(a);r.push({...o,diff:c});}});let t=i._originalStepData,[n,s]=await Promise.all([cloneMaybeOffloaded(r),t?cloneMaybeOffloaded(t):void 0]);return {stepsHistory:n,originalStepData:s}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((t,n)=>t-n),r={};e.forEach(t=>{let n=i._stepsInfoHistory.get(t);if(n){let s={...r};r={};let a=this.itemMapper({step:n,choiceIndexMade:s.choiceIndexMade,inputValue:s.inputValue,removeDialogue:s.removeDialogue},r);a&&i._narrationHistory.set(t,a);}});}async restore(e$1){this.clear();try{Object.hasOwn(e$1,"stepsHistory")?(e$1.stepsHistory.forEach(t=>{t.diff&&i._diffHistory.set(t.index,t.diff);let n={...t,diff:void 0};i._stepsInfoHistory.set(t.index,n);}),this.restoreNarrativeHistory()):e.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(e$1,"originalStepData")?i._originalStepData=e$1.originalStepData:e.warn("Could not import originalStepData data, so will be ignored");}catch(r){e.error("Error importing data",r);}}};var N=new m;export{i as HistoryManagerStatic,N as stepHistory};