@drincs/pixi-vn 1.9.0 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/canvas.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {a}from'./chunk-6GLWL3NH.mjs';import'./chunk-JMOSOAGB.mjs';import {e,d as d$1,g as g$1,b,c as c$1,f as f$1,a as a$1}from'./chunk-HD353M4B.mjs';import {c,d,e as e$1,f as f$2}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';import B,{Container}from'@drincs/pixi-vn/pixi.js';import {initDevtools}from'@pixi/devtools';var Fe={extension:{type:"sceneProperties",name:"additional-positions"},testNode(t){return "xAlign"in t||"yAlign"in t||"percentageX"in t||"percentageY"in t||"positionType"in t},testProp(t){switch(t){case "xAlign":case "yAlign":case "percentageX":case "percentageY":case "positionType":return true;default:return false}},setProperty(t,e,i){switch(e){case "xAlign":"xAlign"in t&&(t.xAlign=i/100);break;case "yAlign":"yAlign"in t&&(t.yAlign=i/100);break;case "percentageX":"percentageX"in t&&(t.percentageX=i/100);break;case "percentageY":"percentageY"in t&&(t.percentageY=i/100);break}},getProperties(t){return [{value:t.positionType,prop:"positionType",entry:{section:"Transform",type:"text",label:"Position Type"}},{value:t.xAlign*100,prop:"xAlign",entry:{section:"Transform",type:"range",label:"X Align",tooltip:"0% is left, 100% is right",options:{min:0,max:100}}},{value:t.yAlign*100,prop:"yAlign",entry:{section:"Transform",type:"range",label:"Y Align",tooltip:"0% is top, 100% is bottom",options:{min:0,max:100}}},{value:t.percentageX*100,prop:"percentageX",entry:{section:"Transform",type:"range",label:"X Percentage Position",tooltip:"0% is left, 100% is right",options:{min:0,max:100}}},{value:t.percentageY*100,prop:"percentageY",entry:{section:"Transform",type:"range",label:"Y Percentage Position",tooltip:"0% is top, 100% is bottom",options:{min:0,max:100}}}]}},be=Fe;function Ae(t,e){let i=0;return async(...n)=>{let r=Date.now();if(r-i>=e)return i=r,await t(...n)}}var _e=c(a(),1),g=class t{constructor(){}static _app=void 0;static get app(){if(!t._app)throw e$1.error("The canvas is not initialized"),new PixiError("invalid_usage","CanvasManagerStatic.app is undefined");return t._app}static get gameLayer(){let e=t.app.stage.getChildByLabel(a$1);return e||(e=new B.Container,e.label=a$1,t.app.stage.addChild(e)),e}static htmlLayers=[];static canvasWidth=300;static canvasHeight=300;static _isInitialized=false;static async init(e,i,n){let{id:r="pixi-vn-canvas",width:a=800,height:o=600,resolution:p=1,autoDensity:d=true,resizeMode:s="contain",...c}=i||{};return t.canvasWidth=a,t.canvasHeight=o,t._app=new B.Application,t.app.init({width:a,height:o,resolution:p,autoDensity:d,...c}).then(()=>{let{app:l=t.app,extensions:u=[],...y}=n||{};if(initDevtools({app:l,extensions:[be,...u],...y}),t._isInitialized=true,t.addCanvasIntoHTMLElement(e,r),s==="contain"){let x=Ae(async()=>{requestAnimationFrame(()=>t.resize());},10);new ResizeObserver(x).observe(e),t.resize(),setTimeout(()=>t.resize(),750);}t.gameLayer;})}static addCanvasIntoHTMLElement(e,i){t._isInitialized?(e.appendChild(t.app.canvas),t.app.canvas.id=i):e$1.error("GameWindowManager is not initialized");}static addHtmlLayer(e,i,n={}){let{position:r="absolute",pointerEvents:a="none",userSelect:o="none"}=n,p=document.createElement("div");p.setAttribute("id",e),p.style.position=r,p.style.pointerEvents=a,p.style.userSelect=o;let d=i.appendChild(p);return t.htmlLayers.push(p),t.resize(),d}static removeHtmlLayer(e){let i=t.htmlLayers.find(n=>n.id===e);i&&(i.remove(),t.htmlLayers=t.htmlLayers.filter(n=>n.id!==e));}static getHtmlLayer(e){return t.htmlLayers.find(i=>i.id===e)}static async resize(){let e=t.canvasWidth,i=t.canvasHeight,n=t.app.resizeTo,r=t.app.canvas.style;n instanceof HTMLElement||(n=document.documentElement);let a,o;if(n===document.body||n===document.documentElement)a=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight;else {let u=n.getBoundingClientRect();a=u.width||n.clientWidth,o=u.height||n.clientHeight;}let p=Math.min(a/e,o/i),d=Math.floor(p*e),s=Math.floor(p*i);r.width=`${d}px`,r.height=`${s}px`;let c=(a-d)/2,l=(o-s)/2;r.marginLeft=`${c}px`,r.marginRight=`${c}px`,r.marginTop=`${l}px`,r.marginBottom=`${l}px`,t.htmlLayers.forEach(u=>{u.style.width=`${d}px`,u.style.height=`${s}px`,u.style.marginLeft=`${c}px`,u.style.marginRight=`${c}px`,u.style.marginTop=`${l}px`,u.style.marginBottom=`${l}px`;});}static get childrenAliasesOrder(){return t.gameLayer.children.filter(e=>e.label).sort((e,i)=>t.gameLayer.getChildIndex(e)-t.gameLayer.getChildIndex(i)).map(e=>e.label)}static get currentTickersWithoutCreatedBySteps(){return Object.fromEntries(Array.from(t._currentTickers.entries()).filter(([e,i])=>!i.createdByTicketSteps).map(([e,i])=>[e,{id:i.ticker.alias,args:i.ticker.args,canvasElementAliases:i.ticker.canvasElementAliases,priority:i.ticker.priority,duration:i.ticker.duration,paused:i.ticker.paused}]))}static _currentTickers=new Map;static _currentTickersSequence=new Map;static get currentTickersSequence(){return Object.fromEntries(Array.from(t._currentTickersSequence.entries()).map(([e,i])=>[e,Object.fromEntries(i)]))}static _currentTickersTimeouts=new Map;static _tickersToCompleteOnStepEnd={tikersIds:[],stepAlias:[]};static generateTickerId(...e){try{return `${(0,_e.default)(JSON.stringify(e)).toString()}_${Math.random().toString(36).substring(7)}`}catch(i){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${i}`)}}static addTickerTimeoutInfo(e,i,n,r){typeof e=="string"&&(e=[e]),t._currentTickersTimeouts.set(n,{aliases:e,ticker:i,canBeDeletedBeforeEnd:r});}static removeTickerTimeoutInfo(e){typeof e!="string"&&(e=e.toString()),t._currentTickersTimeouts.delete(e);}static removeTickerTimeout(e){typeof e!="string"&&(e=e.toString()),clearTimeout(Number(e)),t.removeTickerTimeoutInfo(e);}static removeTickerTimeoutsByAlias(e,i){t._currentTickersTimeouts.forEach((n,r)=>{let a=n.aliases.filter(o=>o!==e);if(a.length===0){let o=n.canBeDeletedBeforeEnd;(!i||o)&&t.removeTickerTimeout(r);}else n.aliases=a;});}};var ue=Symbol("SerializableEvent"),X=new d({cacheSize:5});function Ze(t){return (e,i,n)=>{let r=n.value;fe.add(r,t||`${i}`);}}var fe;(a=>{function t(o,p){o[ue]=p,X.get(p)&&e$1.info(`Event "${p}" already exists, it will be overwritten`),X.set(p,o);}a.add=t;function e(o){try{let p=X.get(o);if(!p){e$1.error(`Event "${o}" not found, did you forget to register it with the eventDecorator?`);return}return p}catch(p){e$1.error(`Error while getting Event "${o}"`,p);return}}a.get=e;function i(){return Array.from(X.values())}a.values=i;function n(o){return X.has(o)}a.has=n;function r(){return Array.from(X.keys())}a.keys=r;})(fe||={});var ge=fe;async function we(t,e){if("onEvents"in e)for(let i in e.onEvents){let n=e.onEvents[i],r=ge.get(n);r&&t.on(i,r);}}function Oe(t){let{onEventsHandlers:e={}}=t;return e}function O(t,e,i){let n=i[ue];return n&&typeof n=="string"?(e.onEventsHandlers[t]=n,true):(e$1.warn(`The event handler for event "${t}" is not registered with the eventDecorator, it will not be saved in the memory and it will not work after loading the game. Please register the event handler with the eventDecorator to avoid this warning. Read more about it here: https://pixi-vn.com/start/canvas-functions#add-a-listener-to-an-event`),false)}var q=new d({cacheSize:5}),Be=new d({cacheSize:2}),Le=new d({cacheSize:2});function Je(t={}){return e=>{he.add(e,t);}}async function S(t,e,i){let n=i?.ignoreScale||false,r=i?.end;"isRenderGroup"in e&&e.isRenderGroup!==void 0&&(t.isRenderGroup=e.isRenderGroup),"blendMode"in e&&e.blendMode!==void 0&&(t.blendMode=e.blendMode),"tint"in e&&e.tint!==void 0&&(t.tint=e.tint),"alpha"in e&&e.alpha!==void 0&&(t.alpha=e.alpha),"angle"in e&&e.angle!==void 0&&(t.angle=e.angle),"renderable"in e&&e.renderable!==void 0&&(t.renderable=e.renderable),"rotation"in e&&e.rotation!==void 0&&(t.rotation=e.rotation),!n&&"scale"in e&&e.scale!==void 0&&(typeof e.scale=="number"?t.scale.set(e.scale,e.scale):t.scale.set(e.scale.x,e.scale.y)),"pivot"in e&&e.pivot!==void 0&&(typeof e.pivot=="number"?t.pivot.set(e.pivot,e.pivot):t.pivot.set(e.pivot.x,e.pivot.y)),"position"in e&&e.position!==void 0&&t.position.set(e.position.x,e.position.y),"skew"in e&&e.skew!==void 0&&t.skew.set(e.skew.x,e.skew.y),"visible"in e&&e.visible!==void 0&&(t.visible=e.visible),"x"in e&&e.x!==void 0&&(t.x=e.x),"y"in e&&e.y!==void 0&&(t.y=e.y),"boundsArea"in e&&e.boundsArea!==void 0&&(t.boundsArea=e.boundsArea),"cursor"in e&&e.cursor!==void 0&&(t.cursor=e.cursor),"eventMode"in e&&e.eventMode!==void 0&&(t.eventMode=e.eventMode),"interactive"in e&&e.interactive!==void 0&&(t.interactive=e.interactive),"interactiveChildren"in e&&e.interactiveChildren!==void 0&&(t.interactiveChildren=e.interactiveChildren),"hitArea"in e&&e.hitArea!==void 0&&(t.hitArea=e.hitArea),we(t,e),"align"in e&&e.align!==void 0&&"align"in t&&(t.align=e.align),"percentagePosition"in e&&e.percentagePosition!==void 0&&"percentagePosition"in t&&(t.percentagePosition=e.percentagePosition),r&&await r(),n||("width"in e&&e.width!==void 0&&(t.width=e.width),"height"in e&&e.height!==void 0&&(t.height=e.height));}var he;(p=>{function t(d,s={}){let{name:c=d.name,getInstance:l=async(y,x)=>{let T=new y;return await T.setMemory(x),T},copyProperty:u=async(y,x)=>{await y.setMemory(x);}}=s;q.get(c)&&e$1.warn(`CanvasElement "${c}" already registered`),d.prototype.pixivnId=c,q.set(c,d),Be.set(c,l),Le.set(c,u);}p.add=t;function e(d){let s=q.get(d);if(!s){e$1.error(`CanvasElement "${d}" not found, did you forget to register it with the canvasComponentDecorator?`);return}return s}p.get=e;async function i(d,s){let c=e(d),l=Be.get(d);if(!c||!l){e$1.error(`CanvasElement "${d}" not found, did you forget to register it with the canvasComponentDecorator?`);return}try{return await l(c,s)}catch(u){e$1.error(`Error while getting CanvasElement instance "${d}"`,u);}}p.getInstance=i;async function n(d,s,c){let l=Le.get(d);if(!l){e$1.error(`CanvasElement "${d}" not found, did you forget to register it with the canvasComponentDecorator?`);return}try{await l(s,c);}catch(u){e$1.error(`Error while copying properties of CanvasElement "${d}"`,u);}}p.copyProperty=n;function r(){return Array.from(q.values())}p.values=r;function a(d){return q.has(d)}p.has=a;function o(){return Array.from(q.keys())}p.keys=o;})(he||={});var k=he;async function J(t){let e=await k.getInstance(t.pixivnId,t);if(!e)throw new PixiError("unregistered_element",`The element ${t.pixivnId} could not be created`,"canvas",t);return e}function ye(t){return "memory"in t?t.memory:t instanceof B.Text?Te(t):t instanceof B.Sprite?xe(t):L(t)}function et(t){let e=t.parent;return {width:t.width,height:t.height,isRenderGroup:t.isRenderGroup,blendMode:t.blendMode,tint:t.tint,alpha:t.alpha,angle:t.angle,renderable:t.renderable,rotation:t.rotation,scale:{x:t.scale.x,y:t.scale.y},pivot:{x:t.pivot.x,y:t.pivot.y},position:{x:t.position.x,y:t.position.y},skew:{x:t.skew.x,y:t.skew.y},visible:t.visible,x:t.x,y:t.y,boundsArea:t.boundsArea,cursor:t.cursor,eventMode:t.eventMode,interactive:t.interactive,interactiveChildren:t.interactiveChildren,hitArea:t.hitArea,index:e?.getChildIndex(t),parentLabel:e?.label,label:t.label}}function me(t,e){return {url:t.source.label,alias:e===t.source.label?void 0:e}}function L(t,e){let i=tt(t,b),r=e?.childrenExport||false?t.children.sort((a,o)=>t.getChildIndex(a)-t.getChildIndex(o)).map(a=>ye(a)):[];return {pixivnId:i,elements:r,onEvents:Oe(t),...et(t)}}function xe(t){let e$1=L(t),i=e$1.pixivnId??e,n="assetsAliases"in t&&Array.isArray(t.assetsAliases)?me(t.texture,t.assetsAliases[0]):"textureAlias"in t?me(t.texture,t.textureAlias):me(t.texture);return {...e$1,pixivnId:i,textureData:n,anchor:{x:t.anchor.x,y:t.anchor.y},roundPixels:t.roundPixels}}function Te(t){let e=L(t),i=e.pixivnId??f$1;return {...e,pixivnId:i,anchor:{x:t.anchor.x,y:t.anchor.y},text:t.text,resolution:t.resolution,style:st(t.style),roundPixels:t.roundPixels}}function tt(t,e){return Object.hasOwn(t,"pixivnId")?t.pixivnId:e}function Q(t){switch(t.type){case "linear":return {type:"linear",colorStops:t.colorStops,end:{x:t.end.x,y:t.end.y},start:{x:t.start.x,y:t.start.y},textureSpace:t.textureSpace,wrapMode:t.texture.source.wrapMode,textureSize:t.texture.source.width/t.texture.source.height};case "radial":return {type:"radial",colorStops:t.colorStops,textureSpace:t.textureSpace,center:{x:t.center.x,y:t.center.y},innerRadius:t.innerRadius,outerCenter:{x:t.outerCenter.x,y:t.outerCenter.y},outerRadius:t.outerRadius,rotation:t.rotation,scale:t.scale,wrapMode:t.texture.source.wrapMode,textureSize:t.texture.source.width/t.texture.source.height}}}function it(t){if(t!=null){{if(typeof t=="number")return t;if(typeof t=="string"||Array.isArray(t))return t;if(t instanceof B.FillGradient)return Q(t);if(typeof t=="object"&&"fill"in t&&typeof t.fill!="function"&&t.fill){if(!(t.fill instanceof B.FillPattern))return Q(t.fill)}}e$1.warn("Unsupported property type for Text.style.fill.",t);}}function rt(t){if(typeof t=="number")return t;if(typeof t=="string")return t;if(Array.isArray(t))return t;if(t instanceof B.Color)return t.toNumber();e$1.warn("Unsupported color type.",t);}function nt(t){if(t!=null){{if(typeof t=="number")return t;if(typeof t=="string"||Array.isArray(t))return t;if(t instanceof B.FillGradient)return Q(t);if(typeof t=="object"&&"alignment"in t)return {alignment:t.alignment,alpha:t.alpha,color:rt(t.color),join:t.join,miterLimit:t.miterLimit,width:t.width,cap:t.cap,pixelLine:t.pixelLine,textureSpace:t.textureSpace};if(typeof t=="object"&&"fill"in t&&typeof t.fill!="function"&&t.fill){if(!(t.fill instanceof B.FillPattern))return Q(t.fill)}}e$1.warn("Unsupported property type for Text.style.stroke.",t);}}function st(t){return {align:t.align,breakWords:t.breakWords,dropShadow:t.dropShadow,fill:it(t.fill),fontFamily:t.fontFamily,fontSize:t.fontSize,fontStyle:t.fontStyle,fontVariant:t.fontVariant,fontWeight:t.fontWeight,leading:t.leading,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,padding:t.padding,stroke:nt(t.stroke),textBaseline:t.textBaseline,trim:t.trim,whiteSpace:t.whiteSpace,wordWrap:t.wordWrap,wordWrapWidth:t.wordWrapWidth}}var Re=c(a(),1);var ee=class{constructor(e,i){this.alias=this.constructor.prototype.id;let{duration:n,priority:r,id:a=this.generateTickerId(this.alias,i),canvasElementAliases:o=[]}=i||{};this.args=e,this.duration=n,this.priority=r,this.id=a,this.canvasElementAliases=o;}alias;id;args;duration;priority;ticker=new B.Ticker;canvasElementAliases=[];generateTickerId(...e){try{return (0,Re.default)(JSON.stringify(e)).toString()+"_"+Math.random().toString(36).substring(7)}catch(i){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${i}`)}}fnValue;complete(e){this.stop();}stop(){let e=this.fnValue;if(!e){e$1.warn("TickerBase.stop() called without fnValue set. This may cause issues.");return}this.ticker.remove(e,null);}start(){let e=this.id,i=()=>this.fn(this.ticker,this.args,this.canvasElementAliases,e);this.fnValue=i,this.ticker.add(i,null,this.priority),this.ticker.start();}pause(){this.ticker.stop();}play(){this.ticker.start();}get paused(){return !this.ticker.started}};var R=new d({cacheSize:5});function ct(t){return function(e){ve.add(e,t);}}var ve;(o=>{function t(p,d){d||(d=p.name),R.get(d)&&e$1.info(`Ticker "${d}" already exists, it will be overwritten`),p.prototype.id=d,R.set(d,p);}o.add=t;function e(p){try{let d=R.get(p);if(!d){e$1.error(`Event "${p}" not found, did you forget to register it with the tickerDecorator?`);return}return d}catch(d){e$1.error(`Error while getting Event "${p}"`,d);return}}o.get=e;function i(p,d,s){try{let c=R.get(p);if(!c){e$1.error(`Ticker "${p}" not found, did you forget to register it with the tickerDecorator?`);return}return new c(d,s)}catch(c){e$1.error(`Error while getting Ticker "${p}"`,c);return}}o.getInstance=i;function n(){return Array.from(R.values())}o.values=n;function r(p){return R.has(p)}o.has=r;function a(){return Array.from(R.keys())}o.keys=a;})(ve||={});var D=ve;var De="aliasToRemoveAfter";var G=class{tickersPausedByGameLayerRender=[];get app(){return g.app}get gameLayer(){return g.gameLayer}get isInitialized(){return g._isInitialized}get width(){return g.canvasWidth}get height(){return g.canvasHeight}set width(e){g.canvasWidth=e;}set height(e){g.canvasHeight=e;}get screen(){return this.app.screen}async init(e,i,n){return await g.init(e,i,n)}get children(){return g.gameLayer.children}async copyCanvasElementProperty(e,i,n={}){let r=["isRenderGroup","scale","visible","boundsArea","text","resolution","style","height","width"],{ignoreProperties:a=d=>d}=n;if(typeof i=="string"){let d=this.find(i);if(d)i=d;else {e$1.error(`Canvas element ${i} not found`);return}}if(typeof e=="string"){let d=this.find(e);if(d)e=d;else {e$1.error(`Canvas element ${e} not found`);return}}e instanceof B.Container&&(e=e.memory);let o=a(r),p={...e};o.forEach(d=>{d in p&&delete p[d];}),await k.copyProperty(i.pixivnId,i,p);}add(e,i,n={}){if(e===a$1){e$1.error(`The alias ${a$1} is reserved`);return}let r=this.find(e),a=n?.ignoreOldStyle;r&&!a&&this.copyCanvasElementProperty(r,i);let{zIndex:o=r?.parent?.getChildIndex(r)}=n;r&&!this.canvasElementIsOnCanvas(r)?e$1.error(`The canvas element ${e} exist in the memory but it is not on the canvas, so the zIndex is not set`):r&&this.remove(e,{ignoreTickers:true}),o!==void 0?(i.label=e,this.gameLayer.addChildAt(i,o)):(i.label=e,this.gameLayer.addChild(i));}remove(e,i={}){if(e===a$1){e$1.error(`The alias ${a$1} is reserved`);return}let n=i.ignoreTickers;typeof e=="string"&&(e=[e]),e.forEach(r=>{this.gameLayer.getChildrenByLabel(r).forEach(a=>{this.gameLayer.removeChild(a),!n&&this.unlinkComponentFromTickerInternal(r);});});}find(e){if(e===a$1)return this.gameLayer;let i=this.gameLayer.getChildByLabel(e);if(i)return i}canvasElementIsOnCanvas(e){return this.gameLayer.children.includes(e)}removeAll(){this.gameLayer.removeChildren();}editAlias(e,i,n={}){let r=this.find(e);r&&(r.label=i),!n.ignoreTickers&&this.transferTickersInternal(e,i,"move");}get currentTickers(){return this.tickers.currentTickers}get currentTickersSteps(){return this.tickers.currentTickersSteps}findTicker(e){return this.findTickerInternal(e)}findTickerInternal(e){let i=g._currentTickers.get(e);if(i)return i.ticker}addTicker(e,i){return this.addTickerInternal(e,i)}addTickerInternal(e,i){let n=i.id,r=i.alias;if(typeof e=="string"&&(e=[e]),i.canvasElementAliases=e,!D.has(r)){e$1.error(`Ticker ${r} not found`);return}let a={ticker:i};if(g._currentTickers.set(n,a),a.ticker.start(),i.duration){let o=setTimeout(()=>{g.removeTickerTimeoutInfo(o),g._currentTickersTimeouts.get(o.toString())&&a.ticker.complete({ignoreTickerSteps:true});},i.duration*1e3);g.addTickerTimeoutInfo(e,r,o.toString(),true);}return n}addTickersSequence(e,i,n=0){if(i.length===0){e$1.warn("The steps of the tickers is empty");return}g._currentTickersSequence.has(e)||g._currentTickersSequence.set(e,new Map);let r={currentStepNumber:n,steps:i.map(o=>({ticker:o.alias,args:f$2(o.args),duration:o.duration}))},a=g.generateTickerId(r);return g._currentTickersSequence.get(e)?.set(a,r),this.runTickersSequence(e,a),a}runTickersSequence(e,i){let n=g._currentTickersSequence.get(e);if(!n?.has(i))return;let r=n.get(i).steps[n.get(i).currentStepNumber],a=D.getInstance(r.ticker,r.args,{canvasElementAliases:[e],duration:r.duration,priority:r.priority});if(!a){e$1.error(`Ticker ${r.ticker} not found`);return}let o=a.alias,p=a.id;a.canvasElementAliases=[e];let d={createdByTicketSteps:{canvasElementAlias:e,id:i},ticker:a};if(g._currentTickers.set(p,d),d.ticker.start(),a.duration){let s=setTimeout(()=>{let c=g._currentTickersTimeouts.get(s.toString());c&&(d.ticker.complete({ignoreTickerSteps:true}),c.aliases.forEach(l=>{this.nextTickerStep(l,i);})),g.removeTickerTimeoutInfo(s);},a.duration*1e3);g.addTickerTimeoutInfo(e,o,s.toString(),false);}}nextTickerStep(e,i){let n=g._currentTickersSequence.get(e);if(n?.has(i)){let r=n.get(i);r.currentStepNumber+1<r.steps.length?(r.currentStepNumber++,n.set(i,r),this.runTickersSequence(e,i)):i&&n.has(i)&&(n.delete(i),g._currentTickers.forEach((a,o)=>{a.createdByTicketSteps?.canvasElementAlias===e&&a.createdByTicketSteps.id===i&&this.removeTickerInternal(o);}));}}onTickerComplete(e,i){return this.onTickerCompleteInternal(e,i)}onTickerCompleteInternal(e,i){let{stopTicker:n=true,aliasToRemoveAfter:r,tickerAliasToResume:a,tickerIdToResume:o}=i,p=g._currentTickers.get(e),d=i.ignoreTickerSteps||false;this.remove(r),a.forEach(s=>{this.resumeTickerInternal({canvasAlias:s});}),this.resumeTickerInternal({id:o}),p&&(this.removeTickerInternal(e,{stopTicker:n}),!d&&p.ticker.duration===void 0&&p.createdByTicketSteps&&this.nextTickerStep(p.createdByTicketSteps.canvasElementAlias,p.createdByTicketSteps.id));}unlinkComponentFromTicker(e,i){return this.unlinkComponentFromTickerInternal(e,i)}unlinkComponentFromTickerInternal(e,i){if(typeof e=="string"&&(e=[e]),!i){e.forEach(r=>{g._currentTickers.forEach((a,o)=>{a.ticker.canvasElementAliases.includes(r)&&(a.ticker.canvasElementAliases.length===1?this.removeTickerInternal(o):a.ticker.canvasElementAliases=a.ticker.canvasElementAliases.filter(p=>p!==r));}),g._currentTickersSequence.has(r)&&g._currentTickersSequence.delete(r),g.removeTickerTimeoutsByAlias(r,false);});return}let n;typeof i=="string"?n=i:n=i.prototype.id,e.forEach(r=>{let a=g._currentTickersSequence.get(r);a&&a.forEach((o,p)=>{o.steps.find(d=>typeof d=="object"&&"ticker"in d&&d.ticker===n)&&a.delete(p);});}),g._currentTickers.forEach(r=>{r.ticker.alias===n&&(r.ticker.canvasElementAliases=r.ticker.canvasElementAliases.filter(a=>!e.includes(a)));}),g._currentTickersTimeouts.forEach(r=>{r.ticker===n&&r.canBeDeletedBeforeEnd&&(r.aliases=r.aliases.filter(a=>!e.includes(a)));}),this.removeTickersWithoutAssociatedCanvasElement();}removeTickersWithoutAssociatedCanvasElement(){g._currentTickers.forEach(e=>{e.ticker.canvasElementAliases=e.ticker.canvasElementAliases.filter(i=>this.find(i)),e.ticker.canvasElementAliases.length===0&&e.ticker.complete({ignoreTickerSteps:true});}),g._currentTickersSequence.forEach((e,i)=>{e===void 0&&g._currentTickersSequence.delete(i);}),Array.from(g._currentTickersTimeouts.keys()).forEach(e=>{let i=g._currentTickersTimeouts.get(e);i&&i.aliases.length===0&&g.removeTickerTimeout(e);});}removeAllTickers(){return this.removeAllTickersInternal()}removeAllTickersInternal(){this.tickersPausedByGameLayerRender=[],g._currentTickersSequence.clear(),Array.from(g._currentTickers.keys()).forEach(e=>{this.removeTickerInternal(e);}),g._currentTickers.clear(),Array.from(g._currentTickersTimeouts.keys()).forEach(e=>{g.removeTickerTimeout(e);}),g._tickersToCompleteOnStepEnd.tikersIds.length=0,g._tickersToCompleteOnStepEnd.stepAlias.length=0;}removeTicker(e,i={stopTicker:true}){return this.removeTickerInternal(e,i)}removeTickerInternal(e,i={stopTicker:true}){typeof e=="string"&&(e=[e]),e.forEach(n=>{let r=g._currentTickers.get(n);r&&(i.stopTicker&&r.ticker.stop(),g._currentTickers.delete(n));});}pauseTicker(e){return this.pauseTickerInternal(e)}pauseTickerInternal(e){let i=[];if("canvasAlias"in e){let{canvasAlias:n,tickerIdsExcluded:r=[]}=e;g._currentTickers.forEach((a,o)=>{a.ticker.canvasElementAliases.includes(n)&&!r.includes(a.ticker.alias)&&a.ticker.paused===false&&(a.ticker.pause(),i.push(o));});}else if("id"in e){let{id:n}=e;typeof n=="string"&&(n=[n]),[...new Set(n)].forEach(r=>{let a=g._currentTickers.get(r);a?a.ticker.paused===false&&(a.ticker.pause(),i.push(r)):e$1.error(`Ticker with id ${r} not found`);});}return i}resumeTicker(e){return this.resumeTickerInternal(e)}resumeTickerInternal(e){if("canvasAlias"in e){let{canvasAlias:i}=e;g._currentTickers.forEach(n=>{n.ticker.canvasElementAliases.includes(i)&&n.ticker.play();});}else if("id"in e){let{id:i}=e;typeof i=="string"&&(i=[i]),[...new Set(i)].forEach(n=>{let r=g._currentTickers.get(n);r?r.ticker.play():e$1.error(`Ticker with id ${n} not found`);});}}isTickerPaused(e,i){return this.isTickerPausedInternal(e,i)}isTickerPausedInternal(e,i){return false}pause(){this.gameLayer.renderable!==false&&(this.gameLayer.renderable=false,this.tickersPausedByGameLayerRender=this.pauseTickerInternal({id:Array.from(g._currentTickers.keys())}));}resume(){if(this.gameLayer.renderable===true)return;this.gameLayer.renderable=true;let e=this.tickersPausedByGameLayerRender.filter(i=>g._currentTickers.has(i));e.length>0&&this.resumeTickerInternal({id:e}),this.tickersPausedByGameLayerRender=[];}transferTickers(e,i,n="move"){return this.transferTickersInternal(e,i,n)}transferTickersInternal(e,i,n="move"){let r=g._currentTickersSequence.get(e);if(r){let o=new Map(Array.from(r.entries()).map(([p,d])=>[p,f$2(d)]));g._currentTickersSequence.set(i,o);}g._currentTickers.forEach((o,p)=>{if(o.createdByTicketSteps?.canvasElementAlias===e&&this.removeTickerInternal(p),o.ticker.canvasElementAliases.includes(e)){let d=D.getInstance(o.ticker.alias,f$2(o.ticker.args),{duration:o.ticker.duration,priority:o.ticker.priority,canvasElementAliases:[i]});if(d?(this.addTickerInternal(i,d),o.ticker.paused&&d.pause()):e$1.error(`Ticker ${o.ticker.alias} not found`),n==="move"&&(o.ticker.canvasElementAliases=o.ticker.canvasElementAliases.filter(s=>s!==e)),Object.hasOwn(o.ticker.args,De)){let s=o.ticker.args.aliasToRemoveAfter;typeof s=="string"&&(s=[s]),Array.isArray(s)&&(n==="move"?o.ticker.args.aliasToRemoveAfter=s.map(c=>c===e?i:c):n==="duplicate"&&s.find(c=>c===e)&&(o.ticker.args.aliasToRemoveAfter=[...s,i]));}}}),g._currentTickersTimeouts.forEach(o=>{o.aliases.includes(e)&&(n==="move"?o.aliases=o.aliases.map(p=>p===e?i:p):n==="duplicate"&&o.aliases.find(p=>p===e)&&o.aliases.push(i));});let a=g._currentTickersSequence.get(i);if(a&&a.forEach((o,p)=>{this.runTickersSequence(i,p);}),n==="duplicate"){let o=g._currentTickersSequence.get(e);o&&o.forEach((p,d)=>{this.runTickersSequence(e,d);});}}completeTickerOnStepEnd(e){return this.completeTickerOnStepEndInternal(e)}completeTickerOnStepEndInternal(e){e.alias?g._tickersToCompleteOnStepEnd.stepAlias.push({id:e.id,alias:e.alias}):g._tickersToCompleteOnStepEnd.tikersIds.push({id:e.id});}async forceCompletionOfTicker(e,i){return this.forceCompletionOfTickerInternal(e,i)}async forceCompletionOfTickerInternal(e,i){if(i){let n=g._currentTickersSequence.get(i),r=n?.get(e);if(n&&r){let a=r.steps.map(o=>{if(typeof o=="object"&&"ticker"in o){let p=D.getInstance(o.ticker,o.args,{duration:o.duration,canvasElementAliases:[i],priority:o.priority});if(p)return p.complete()}return Promise.resolve()});await Promise.all(a);}}else {let n=g._currentTickers.get(e);n&&await n.ticker.complete();}}tickers={transfer:(e,i,n)=>this.transferTickersInternal(e,i,n),get currentTickers(){return g._currentTickers},get currentTickersSteps(){return g._currentTickersSequence},find:e=>this.findTickerInternal(e),add:(e,i)=>this.addTickerInternal(e,i),addSequence:(e,i,n)=>this.addTickersSequence(e,i,n),unlinkComponent:(e,i)=>this.unlinkComponentFromTickerInternal(e,i),removeAll:()=>this.removeAllTickersInternal(),remove:e=>this.removeTickerInternal(e),pause:e=>this.pauseTickerInternal(e),resume:e=>this.resumeTickerInternal(e),isPaused:(e,i)=>this.isTickerPausedInternal(e,i),completeOnStepEnd:e=>this.completeTickerOnStepEndInternal(e),forceCompletion:(e,i)=>this.forceCompletionOfTickerInternal(e,i),onComplete:(e,i)=>this.onTickerCompleteInternal(e,i)};animate(e,i,n,r){return GameUnifier.animate(e,i,n,r)}addLayerInternal(e,i){if(e===a$1){e$1.error(`The alias ${a$1} is reserved`);return}return i.label=e,g.app.stage.addChild(i)}getLayerInternal(e){return g.app.stage.getChildByLabel(e)}removeLayerInternal(e){let i=g.app.stage.getChildByLabel(e);i&&g.app.stage.removeChild(i);}addHtmlLayerInternal(e,i,n){return g.addHtmlLayer(e,i,n)}removeHtmlLayerInternal(e){return g.removeHtmlLayer(e)}getHtmlLayerInternal(e){return g.getHtmlLayer(e)}addLayer(e,i){return this.addLayerInternal(e,i)}getLayer(e){return this.getLayerInternal(e)}removeLayer(e){return this.removeLayerInternal(e)}addHtmlLayer(e,i,n){return this.addHtmlLayerInternal(e,i,n)}removeHtmlLayer(e){return this.removeHtmlLayerInternal(e)}getHtmlLayer(e){return this.getHtmlLayerInternal(e)}layers={get gameLayer(){return g.gameLayer},add:(e,i)=>this.addLayerInternal(e,i),get:e=>this.getLayerInternal(e),remove:e=>this.removeLayerInternal(e)};htmlLayers={add:(e,i,n)=>this.addHtmlLayerInternal(e,i,n),get:e=>this.getHtmlLayerInternal(e),remove:e=>this.removeHtmlLayerInternal(e)};async extractImage(){let e=this.gameLayer.renderable===false;e&&this.resume();let i;try{i=this.app.renderer.extract.image(this.app.stage);}finally{e&&this.pause();}return (await i).src}clear(){this.removeAllTickersInternal(),this.removeAll();}export(){let e=this.gameLayer.renderable===false;e&&this.resume();try{let i={};return this.children.forEach(n=>{n.label&&(i[n.label]=ye(n));}),{tickers:f$2(g.currentTickersWithoutCreatedBySteps),tickersSteps:f$2(g.currentTickersSequence),elements:f$2(i),stage:f$2(L(this.gameLayer)),elementAliasesOrder:f$2(g.childrenAliasesOrder),tickersToCompleteOnStepEnd:f$2(g._tickersToCompleteOnStepEnd)}}finally{e&&this.pause();}}async restore(e){this.clear();try{if(Object.hasOwn(e,"elements")&&Object.hasOwn(e,"elementAliasesOrder")){let i=e.elementAliasesOrder,n={},r=Object.entries(e.elements).map(async([a,o])=>{n[a]=await J(o);});await Promise.all(r),i.forEach(a=>{let o=n[a];o&&this.add(a,o);});}else {e$1.error("The data does not have the properties elementAliasesOrder and elements");return}if(Object.hasOwn(e,"stage")&&Object.hasOwn(e,"stage")?S(this.gameLayer,e.stage,{ignoreScale:!0}):e$1.error("The data does not have the properties stage"),Object.hasOwn(e,"tickers")){let i=e.tickers;Object.entries(i).forEach(([n,r])=>{let a=r.canvasElementAliases;if(a.length!==0){let o=D.getInstance(r.id,r.args,{duration:r.duration,priority:r.priority,id:n,canvasElementAliases:a});o?(o.canvasElementAliases=a,this.addTickerInternal(a,o),r.paused&&o.pause()):e$1.error(`Ticker ${r.id} not found`);}});}if(Object.hasOwn(e,"tickersSteps")){let i=e.tickersSteps;Object.entries(i).forEach(([n,r])=>{g._currentTickersSequence.set(n,new Map(Object.entries(r))),Object.keys(r).forEach(a=>{this.runTickersSequence(n,a);});});}if(Object.hasOwn(e,"tickersToCompleteOnStepEnd")){let i=e.tickersToCompleteOnStepEnd,n=i.tikersIds,r=i.stepAlias.map(a=>({id:a.id,alias:a.alias}));g._tickersToCompleteOnStepEnd.tikersIds.length=0,g._tickersToCompleteOnStepEnd.tikersIds.push(...n),g._tickersToCompleteOnStepEnd.stepAlias.length=0,g._tickersToCompleteOnStepEnd.stepAlias.push(...r);}}catch(i){e$1.error("Error importing data",i);}}};var I=class t{static init(e){t._getScreen=e.getScreen;}static _getScreen;static get screen(){return t._getScreen()}};var h;(d=>{function t(s,c,l,u,y,x=0){return y?s==="width"?c*(I.screen.width-l)+l-u-x*l:c*(I.screen.height-l)+l-u-x*l:s==="width"?c*(I.screen.width-l)+u+x*l:c*(I.screen.height-l)+u+x*l}d.calculatePositionByAlign=t;function e(s,c,l,u,y,x=0){return y?s==="width"?(c-l+u+x*l)/(I.screen.width-l):(c-l+u+x*l)/(I.screen.height-l):s==="width"?(c-u-x*l)/(I.screen.width-l):(c-u-x*l)/(I.screen.height-l)}d.calculateAlignByPosition=e;function i(s,c){return s==="width"?c*I.screen.width:c*I.screen.height}d.calculatePositionByPercentagePosition=i;function n(s,c){return s==="width"?c/I.screen.width:c/I.screen.height}d.calculatePercentagePositionByPosition=n;function r(s,c){if(c=c%360,c<0&&(c+=360),c===0)return {x:s.x,y:s.y};if(c===90)return {x:-s.y,y:s.x};if(c===180)return {x:-s.x,y:-s.y};if(c===270)return {x:s.y,y:-s.x};if(c>0&&c<90){let l=c*Math.PI/180,u=Math.cos(l),y=Math.sin(l),x=s.x*u-s.y*y,T=s.x*y+s.y*u;return s.x!==0&&Math.sign(x)!==Math.sign(s.x)&&(x=-x),s.y!==0&&Math.sign(T)!==Math.sign(s.y)&&(T=-T),{x,y:T}}else if(c>90&&c<180){let l=(c-90)*Math.PI/180,u=Math.cos(l),y=Math.sin(l),x=-s.y*y-s.x*u,T=s.y*u-s.x*y;return s.x!==0&&Math.sign(x)!==Math.sign(s.x)&&(x=-x),s.y!==0&&Math.sign(T)!==Math.sign(s.y)&&(T=-T),{x,y:T}}else if(c>180&&c<270){let l=(c-180)*Math.PI/180,u=Math.cos(l),y=Math.sin(l),x=-s.x*u+s.y*y,T=-s.x*y-s.y*u;return s.x!==0&&Math.sign(x)!==Math.sign(s.x)&&(x=-x),s.y!==0&&Math.sign(T)!==Math.sign(s.y)&&(T=-T),{x,y:T}}else if(c>270&&c<360){let l=(c-270)*Math.PI/180,u=Math.cos(l),y=Math.sin(l),x=s.y*y-s.x*u,T=-s.y*u-s.x*y;return s.x!==0&&Math.sign(x)!==Math.sign(s.x)&&(x=-x),s.y!==0&&Math.sign(T)!==Math.sign(s.y)&&(T=-T),{x,y:T}}return {x:0,y:0}}d.getSuperPoint=r;function a(s,c){if(c=c%360,c<0&&(c+=360),c===0)return {x:s.x,y:s.y};if(c===90)return {x:s.y,y:-s.x};if(c===180)return {x:-s.x,y:-s.y};if(c===270)return {x:-s.y,y:s.x};if(c>0&&c<90){let l=c*Math.PI/180,u=Math.cos(l),y=Math.sin(l);return {x:s.x*u+s.y*y,y:-s.x*y+s.y*u}}else if(c>90&&c<180){let l=(c-90)*Math.PI/180,u=Math.cos(l),y=Math.sin(l);return {x:s.y*u-s.x*y,y:-s.y*y-s.x*u}}else if(c>180&&c<270){let l=(c-180)*Math.PI/180,u=Math.cos(l),y=Math.sin(l);return {x:-s.x*u-s.y*y,y:s.x*y-s.y*u}}else if(c>270&&c<360){let l=(c-270)*Math.PI/180,u=Math.cos(l),y=Math.sin(l);return {x:-s.y*u+s.x*y,y:s.y*y+s.x*u}}return {x:0,y:0}}d.getPointBySuperPoint=a;function o(s){let c=s.width,l=s.height,u=s.angle%360;return u<0&&(u+=360),u===0||u===180?c:u===90||u===270?l:Math.abs(c*Math.cos(u*Math.PI/180))+Math.abs(l*Math.sin(u*Math.PI/180))}d.getSuperWidth=o;function p(s){let c=s.width,l=s.height,u=s.angle%360;return u<0&&(u+=360),u===0||u===180?l:u===90||u===270?c:Math.abs(l*Math.cos(u*Math.PI/180))+Math.abs(c*Math.sin(u*Math.PI/180))}d.getSuperHeight=p;})(h||={});async function N(t){if(t!=="EMPTY"){if(!t)throw e$1.error("Texture not found",t),new PixiError("unregistered_asset","Texture not found");if(B.Assets.cache.has(t)){let e=B.Assets.get(t);if(e)return e}return B.Assets.load(t).then(e=>{if(!e)throw e$1.error("Texture not found",t),new PixiError("unregistered_asset","Texture not found");if(!(e instanceof B.Texture))throw e$1.error("File is not a Texture",t),new PixiError("unregistered_asset","File is not a Texture");return e}).catch(e=>{throw e$1.error("Error loading file",e),new PixiError("unknown_element","Error loading file")})}}function A(t){return t&&(typeof t.align!="number"&&(t.xAlign!==void 0&&(t.align===void 0?(t.align={x:t.xAlign},delete t.xAlign):(t.align.x=t.xAlign,delete t.xAlign)),t.yAlign!==void 0&&(t.align===void 0?(t.align={y:t.yAlign},delete t.yAlign):(t.align.y=t.yAlign,delete t.yAlign))),typeof t.percentagePosition!="number"&&(t.percentageX!==void 0&&(t.percentagePosition===void 0?(t.percentagePosition={x:t.percentageX},delete t.percentageX):(t.percentagePosition.x=t.percentageX,delete t.percentageX)),t.percentageY!==void 0&&(t.percentagePosition===void 0?(t.percentagePosition={y:t.percentageY},delete t.percentageY):(t.percentagePosition.y=t.percentageY,delete t.percentageY))),t)}var H=class t extends B.Sprite{constructor(e$1){if(e$1 instanceof B.Texture)super(e$1);else {let{align:i,percentagePosition:n,...r}=A(e$1)||{};super(r),i&&(this.align=i),n&&(this.percentagePosition=n);}this.pixivnId=this.constructor.prototype.pixivnId||e;}pixivnId=e;get memory(){return {...xe(this),pixivnId:this.pixivnId,align:this._align,percentagePosition:this._percentagePosition}}async setMemory(e){return await ne(this,e)}static from(e,i){let n=B.Sprite.from(e,i),r=new t;return r.texture=n.texture,r}onEventsHandlers={};on(e,i,n){return O(e,this,i),super.on(e,(...r)=>i(...r,this),n)}_align=void 0;set align(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),typeof e=="number"?(this._align.x=e,this._align.y=e):(e.x!==void 0&&(this._align.x=e.x),e.y!==void 0&&(this._align.y=e.y)),this.reloadPosition();}get align(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return {x:h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x),y:h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y)}}set xAlign(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),this._align.x=e,this.reloadPosition();}get xAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x)}set yAlign(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),this._align.y=e,this.reloadPosition();}get yAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y)}_percentagePosition=void 0;set percentagePosition(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),typeof e=="number"?(this._percentagePosition.x=e,this._percentagePosition.y=e):(e.x!==void 0&&(this._percentagePosition.x=e.x),e.y!==void 0&&(this._percentagePosition.y=e.y)),this.reloadPosition();}get percentagePosition(){return {x:h.calculatePercentagePositionByPosition("width",this.x),y:h.calculatePercentagePositionByPosition("height",this.y)}}get percentageX(){return h.calculatePercentagePositionByPosition("width",this.x)}set percentageX(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.x=e,this.reloadPosition();}get percentageY(){return h.calculatePercentagePositionByPosition("height",this.y)}set percentageY(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.y=e,this.reloadPosition();}get positionType(){return this._align?"align":this._percentagePosition?"percentage":"pixel"}get positionInfo(){switch(this.positionType){case "align":return {x:this.xAlign,y:this.yAlign,type:"align"};case "percentage":return {x:this.percentageX,y:this.percentageY,type:"percentage"};default:return {x:this.x,y:this.y,type:"pixel"}}}set positionInfo(e){e.type==="align"?this.align={x:e.x,y:e.y}:e.type==="percentage"?this.percentagePosition={x:e.x,y:e.y}:this.position.set(e.x,e.y);}reloadPosition(){if(this._align){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);this._align.x!==void 0&&(super.x=h.calculatePositionByAlign("width",this._align.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x)),this._align.y!==void 0&&(super.y=h.calculatePositionByAlign("height",this._align.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y));}else this._percentagePosition&&(this._percentagePosition.x!==void 0&&(super.x=h.calculatePositionByPercentagePosition("width",this._percentagePosition.x)),this._percentagePosition.y!==void 0&&(super.y=h.calculatePositionByPercentagePosition("height",this._percentagePosition.y)));}get position(){return super.position}set position(e){this._align=void 0,this._percentagePosition=void 0,super.position=e;}get x(){return super.x}set x(e){this._align=void 0,this._percentagePosition=void 0,super.x=e;}get y(){return super.y}set y(e){this._align=void 0,this._percentagePosition=void 0,super.y=e;}};k.add(H,{name:e,copyProperty:async(t,e)=>{await ne(t,e,{ignoreTexture:true});}});async function ne(t,e,i){e=A(e);let n=i?.ignoreTexture||false;if(await S(t,e),!n){let a;if("textureData"in e&&e.textureData&&(a=e.textureData),a&&a.url!=="EMPTY"){let o=a.url;a.alias&&B.Assets.resolver.hasKey(a.alias)&&(o=a.alias);try{let p=await N(o);p&&(t.texture=p);}catch(p){e$1.error("Error in Sprite.setMemorySprite() while loading texture"),p=new PixiError("unregistered_asset",`Error loading image ${o}`,"canvas",e),GameUnifier.runOnError(p,{});}}}let r=i?.half;r&&await r(),"anchor"in e&&e.anchor!==void 0&&(typeof e.anchor=="number"?t.anchor.set(e.anchor,e.anchor):t.anchor.set(e.anchor.x,e.anchor.y)),"align"in e&&e.align!==void 0&&(t.align=e.align),"percentagePosition"in e&&e.percentagePosition!==void 0&&(t.percentagePosition=e.percentagePosition),"roundPixels"in e&&e.roundPixels!==void 0&&(t.roundPixels=e.roundPixels);}var v=class t extends H{_textureAlias;get textureAlias(){return this._textureAlias?this._textureAlias:this.texture.source.label}pixivnId=d$1;constructor(e,i){super(e),i&&(this._textureAlias=i);}get memory(){return {...super.memory,pixivnId:this.pixivnId,loadIsStarted:this._loadIsStarted}}async setMemory(e){let i;"textureData"in e&&e.textureData&&(i=e.textureData),"assetsData"in e&&Array.isArray(e.assetsData)&&e.assetsData.length>0&&(i=e.assetsData[0]),i&&i.alias&&(this._textureAlias=i.alias),await se(this,e),this.reloadPosition();}static from(e,i){let n=B.Sprite.from(e,i),r=new t;return r.texture=n.texture,r}_loadIsStarted=false;get loadIsStarted(){return this._loadIsStarted}async load(){return this._loadIsStarted=true,N(this.textureAlias).then(e=>{this._loadIsStarted=false,e&&(this.texture=e);}).catch(e=>{this._loadIsStarted=false,e$1.error("Error into ImageSprite.load()"),e=new PixiError("unregistered_asset",`Error loading image ${this.textureAlias}`,"canvas",{...this.memory,label:this.textureAlias},this),GameUnifier.runOnError(e,{});})}set texture(e){super.texture=e,this.reloadPosition();}get texture(){return super.texture}get haveEmptyTexture(){return this.texture._source.label==="EMPTY"}};k.add(v,{name:d$1,copyProperty:async(t,e)=>{await se(t,e,{ignoreTexture:true});}});async function se(t,e,i){return await ne(t,e,{half:async()=>{"loadIsStarted"in e&&e.loadIsStarted&&await t.load();},ignoreTexture:i?.ignoreTexture})}var M=class t extends v{constructor(e,i){if(e instanceof B.Texture){super(e,i);return}let{loop:n,paused:r,currentTime:a,...o}=e||{};super(o,i),n&&(this.loop=n),r&&(this.paused=r),a&&(this.currentTime=a);}pixivnId=g$1;get memory(){return {...super.memory,pixivnId:this.pixivnId,loop:this.loop,paused:this._paused,currentTime:this.currentTime}}async setMemory(e){await ze(this,e),this.reloadPosition();}static from(e,i){let n=B.Sprite.from(e,i),r=new t;return r.texture=n.texture,r}async load(){await super.load(),this.loop=this._looop,this.currentTime=this._currentTime,this.paused=this._paused;}_looop=false;get loop(){return this.texture?.source?.resource?.loop||false}set loop(e){this._looop=e,this.texture?.source?.resource&&(this.texture.source.resource.loop=e);}_paused=false;get paused(){return this.texture?.source?.resource?.paused||false}set paused(e){e?this.pause():this.play();}pause(){this._paused=true,this.texture?.source?.resource&&this.texture.source.resource.pause();}play(){this._paused=false,this.texture?.source?.resource?.play&&typeof this.texture.source.resource.play=="function"&&this.texture.source.resource.play();}_currentTime=0;get currentTime(){return this.texture?.source?.resource?.currentTime||0}set currentTime(e){let i=this.duration;i&&e>=i&&(e=0),this._currentTime=e,this.texture?.source?.resource&&(this.texture.source.resource.currentTime=e);}restart(){this.currentTime=0;}get duration(){if(this.texture?.source?.resource)return this.texture.source.resource.duration||0}};k.add(M,{name:g$1,getInstance:async(t,e)=>{let i;"textureData"in e&&e.textureData&&(i=e.textureData);let n=new t(void 0,i?.alias);return await n.setMemory(e),n},copyProperty:async(t,e)=>{await ze(t,e,{ignoreTexture:true});}});async function ze(t,e,i){await se(t,e,{ignoreTexture:i?.ignoreTexture}),"loop"in e&&e.loop!==void 0&&(t.loop=e.loop),"currentTime"in e&&e.currentTime!==void 0&&(t.currentTime=e.currentTime),"paused"in e&&e.paused!==void 0&&(t.paused=e.paused);}var _=class extends Container{constructor(e){let{anchor:i,align:n,percentagePosition:r,...a}=A(e)||{};super(a),this.pixivnId=this.constructor.prototype.pixivnId||b,i&&(this.anchor=i),n&&(this.align=n),r&&(this.percentagePosition=r);}pixivnId=b;get memory(){return {...L(this,{childrenExport:true}),anchor:this._anchor?this.anchor:void 0,align:this._align,percentagePosition:this._percentagePosition}}async setMemory(e){await this.importChildren(e),await S(this,e),this.reloadAnchor(),this.reloadPosition();}async importChildren(e){for(let i=0;i<e.elements.length;i++){let n=e.elements[i],r=await J(n);this.addChild(r);}}onEventsHandlers={};on(e,i,n){return O(e,this,i),super.on(e,(...r)=>i(...r,this),n)}_anchor;get anchor(){let e=super.pivot.x/this.width,i=super.pivot.y/this.height;return {x:e,y:i}}set anchor(e){typeof e=="number"?this._anchor={x:e,y:e}:this._anchor=e,this.reloadAnchor();}reloadAnchor(){this._anchor&&super.pivot.set(this._anchor.x*this.width,this._anchor.y*this.height);}get pivot(){return super.pivot}set pivot(e){this._anchor=void 0,super.pivot=e;}_align=void 0;set align(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),typeof e=="number"?(this._align.x=e,this._align.y=e):(e.x!==void 0&&(this._align.x=e.x),e.y!==void 0&&(this._align.y=e.y)),this.reloadPosition();}get align(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return {x:h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0),y:h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0)}}set xAlign(e){this._percentagePosition&&(this._percentagePosition=void 0),this._align===void 0&&(this._align={}),this._align.x=e,this.reloadPosition();}get xAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0)}set yAlign(e){this._percentagePosition&&(this._percentagePosition=void 0),this._align===void 0&&(this._align={}),this._align.y=e,this.reloadPosition();}get yAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0)}_percentagePosition=void 0;set percentagePosition(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),typeof e=="number"?(this._percentagePosition.x=e,this._percentagePosition.y=e):(e.x!==void 0&&(this._percentagePosition.x=e.x),e.y!==void 0&&(this._percentagePosition.y=e.y)),this.reloadPosition();}get percentagePosition(){return {x:h.calculatePercentagePositionByPosition("width",this.x),y:h.calculatePercentagePositionByPosition("height",this.y)}}set percentageX(e){this._align&&(this._align=void 0),this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.x=e,this.reloadPosition();}get percentageX(){return h.calculatePercentagePositionByPosition("width",this.x)}set percentageY(e){this._align&&(this._align=void 0),this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.y=e,this.reloadPosition();}get percentageY(){return h.calculatePercentagePositionByPosition("height",this.y)}get positionType(){return this._align?"align":this._percentagePosition?"percentage":"pixel"}get positionInfo(){switch(this.positionType){case "align":return {x:this.xAlign,y:this.yAlign,type:"align"};case "percentage":return {x:this.percentageX,y:this.percentageY,type:"percentage"};default:return {x:this.x,y:this.y,type:"pixel"}}}set positionInfo(e){e.type==="align"?this.align={x:e.x,y:e.y}:e.type==="percentage"?this.percentagePosition={x:e.x,y:e.y}:this.position.set(e.x,e.y);}reloadPosition(){if(this._align){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);this._align.x!==void 0&&(super.x=h.calculatePositionByAlign("width",this._align.x,h.getSuperWidth(this),e.x,i.x<0)),this._align.y!==void 0&&(super.y=h.calculatePositionByAlign("height",this._align.y,h.getSuperHeight(this),e.y,i.y<0));}else this._percentagePosition&&(this._percentagePosition.x!==void 0&&(super.x=h.calculatePositionByPercentagePosition("width",this._percentagePosition.x)),this._percentagePosition.y!==void 0&&(super.y=h.calculatePositionByPercentagePosition("height",this._percentagePosition.y)));}get position(){return super.position}set position(e){this._align=void 0,this._percentagePosition=void 0,super.position=e;}get x(){return super.x}set x(e){this._align=void 0,this._percentagePosition=void 0,super.x=e;}get y(){return super.y}set y(e){this._align=void 0,this._percentagePosition=void 0,super.y=e;}};k.add(_,{name:b,copyProperty:async(t,e)=>await S(t,e)});var yt=new Set(["mp4","webm","ogg","ogv","avi","mov","wmv","flv","mkv","m4v","3gp","3g2","ts","mts"]);function U(t){let e=B.Assets.cache.has(t)?B.Assets.get(t):null;return e instanceof B.Texture&&(t=e.source?.label||t),xt(t)}function xt(t){let e=t.split(".").pop()?.toLowerCase();return e!==void 0&&yt.has(e)}var P=class extends _{constructor(e,i){let{anchor:n,align:r,percentagePosition:a,...o}=A(e)||{};super(o),i&&i.forEach(p=>{U(p)?this.addChild(new M(void 0,p)):this.addChild(new v(void 0,p));}),n&&(this.anchor=n),r&&(this.align=r),a&&(this.percentagePosition=a);}get memory(){return {...super.memory,pixivnId:c$1,loadIsStarted:this._loadIsStarted}}async setMemory(e){await this.importChildren(e),await Ve(this,e),this.reloadAnchor(),this.reloadPosition();}pixivnId=c$1;_loadIsStarted=false;get loadIsStarted(){return this._loadIsStarted}async load(){this._loadIsStarted=true;let e=this.children.map(i=>i.load());return Promise.all(e).then(()=>{this._loadIsStarted=false,this.reloadAnchor(),this.reloadPosition();}).catch(i=>{this._loadIsStarted=false,e$1.error("Error into ImageContainer.load()",i);})}get texture(){return this.children.length>0?this.children[0].texture:new B.Texture}get haveEmptyTexture(){return this.children.some(e=>e.texture._source.label==="EMPTY")}};k.add(P,{name:c$1,copyProperty:async(t,e)=>await Ve(t,e)});async function Ve(t,e){e=A(e)||{},S(t,e,{end:async()=>{"loadIsStarted"in e&&e.loadIsStarted&&await t.load();}});}var ae=class{constructor(...e){}get memory(){throw new PixiError("not_implemented","The method CanvasBaseItem.memory must be overridden")}setMemory(e){throw new PixiError("not_implemented","The method CanvasBaseItem.setMemory must be overridden")}pixivnId="canvas_element_id_not_set"};var z=class extends B.Text{constructor(e){let{align:i,percentagePosition:n,...r}=A(e)||{};super(r),this.pixivnId=this.constructor.prototype.pixivnId||f$1,i&&(this.align=i),n&&(this.percentagePosition=n);}pixivnId=f$1;get memory(){return {...Te(this),pixivnId:this.pixivnId,align:this._align,percentagePosition:this._percentagePosition}}async setMemory(e){await Pt(this,e),this.reloadPosition();}onEventsHandlers={};on(e,i,n){return O(e,this,i),super.on(e,(...r)=>i(...r,this),n)}_align=void 0;set align(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),typeof e=="number"?(this._align.x=e,this._align.y=e):(e.x!==void 0&&(this._align.x=e.x),e.y!==void 0&&(this._align.y=e.y)),this.reloadPosition();}get align(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return {x:h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x),y:h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y)}}set xAlign(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),this._align.x=e,this.reloadPosition();}get xAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x)}set yAlign(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),this._align.y=e,this.reloadPosition();}get yAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y)}_percentagePosition=void 0;set percentagePosition(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),typeof e=="number"?(this._percentagePosition.x=e,this._percentagePosition.y=e):(e.x!==void 0&&(this._percentagePosition.x=e.x),e.y!==void 0&&(this._percentagePosition.y=e.y)),this.reloadPosition();}get percentagePosition(){return {x:h.calculatePercentagePositionByPosition("width",this.x),y:h.calculatePercentagePositionByPosition("height",this.y)}}get percentageX(){return h.calculatePercentagePositionByPosition("width",this.x)}set percentageX(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.x=e,this.reloadPosition();}get percentageY(){return h.calculatePercentagePositionByPosition("height",this.y)}set percentageY(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.y=e,this.reloadPosition();}get positionType(){return this._align?"align":this._percentagePosition?"percentage":"pixel"}get positionInfo(){switch(this.positionType){case "align":return {x:this.xAlign,y:this.yAlign,type:"align"};case "percentage":return {x:this.percentageX,y:this.percentageY,type:"percentage"};default:return {x:this.x,y:this.y,type:"pixel"}}}set positionInfo(e){e.type==="align"?this.align={x:e.x,y:e.y}:e.type==="percentage"?this.percentagePosition={x:e.x,y:e.y}:this.position.set(e.x,e.y);}reloadPosition(){if(this._align){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);this._align.x!==void 0&&(super.x=h.calculatePositionByAlign("width",this._align.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x)),this._align.y!==void 0&&(super.y=h.calculatePositionByAlign("height",this._align.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y));}else this._percentagePosition&&(this._percentagePosition.x!==void 0&&(super.x=h.calculatePositionByPercentagePosition("width",this._percentagePosition.x)),this._percentagePosition.y!==void 0&&(super.y=h.calculatePositionByPercentagePosition("height",this._percentagePosition.y)));}get position(){return super.position}set position(e){this._align=void 0,this._percentagePosition=void 0,super.position=e;}get x(){return super.x}set x(e){this._align=void 0,this._percentagePosition=void 0,super.x=e;}get y(){return super.y}set y(e){this._align=void 0,this._percentagePosition=void 0,super.y=e;}};k.add(z,{name:f$1});async function Pt(t,e){"text"in e&&e.text!==void 0&&(t.text=e.text),await S(t,e,{end:()=>{"style"in e&&e.style!==void 0&&(t.style=e.style);}}),"anchor"in e&&e.anchor!==void 0&&(typeof e.anchor=="number"?t.anchor.set(e.anchor,e.anchor):t.anchor.set(e.anchor.x,e.anchor.y)),"resolution"in e&&e.resolution!==void 0&&(t.resolution=e.resolution),"anchor"in e&&e.anchor!==void 0&&(typeof e.anchor=="number"?t.anchor.set(e.anchor,e.anchor):t.anchor.set(e.anchor.x,e.anchor.y)),"align"in e&&e.align!==void 0&&(t.align=e.align),"percentagePosition"in e&&e.percentagePosition!==void 0&&(t.percentagePosition=e.percentagePosition),"roundPixels"in e&&e.roundPixels!==void 0&&(t.roundPixels=e.roundPixels);}async function It(t,e={},i){let n=f.find(t);if(!n){e$1.error(`The element with the alias ${t} does not exist. So the shake effect can't be applied.`);return}let r={x:n.position.x,y:n.position.y},{shakeType:a="horizontal",maxShockSize:o=10,shocksNumber:p=10,...d}=e,s=p-1;if(s<2){e$1.error("The number of shocks must be at least 3.");return}let c=Math.floor(s/2),l=Math.ceil(s/2),u=[];for(let T=0;T<c;T++){let C=o*(T+1)/c;a==="horizontal"?T%2!==0?u.push(r.x+C):u.push(r.x-C):T%2!==0?u.push(r.y+C):u.push(r.y-C);}let y=c%2===0;for(let T=l;T>0;T--){let C=o*(T+1)/(l-1);a==="horizontal"?T%2===0&&!y||T%2!==0&&y?u.push(r.x-C):u.push(r.x+C):T%2===0&&!y||T%2!==0&&y?u.push(r.y-C):u.push(r.y+C);}let x;if(a==="horizontal"?(u.push(r.x),x=f.animate(t,{x:u},d,i)):(u.push(r.y),x=f.animate(t,{y:u},d,i)),x)return [x]}function oe(t,e,i){let n={...f.find(t)?.memory,...i},r=new P(i,e);return n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}async function kt(t,e,i){let n={...f.find(t)?.memory,...i},r=new P(i,e);return r.label=t,await r.load(),n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}function ce(t,e,i){if(!e)if(B.Assets.resolver.hasKey(t))e=t;else throw new PixiError("unregistered_asset",`The image ${t} does not exist in the cache.`,"canvas",{pixivnId:d$1,...i,label:t});let n={...f.find(t)?.memory,...i},r=new v(i,e);return n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}async function Ct(t,e,i){if(!e)if(B.Assets.resolver.hasKey(t))e=t;else throw new PixiError("unregistered_asset",`The image ${t} does not exist in the cache.`,"canvas",{pixivnId:d$1,...i,label:t});let n={...f.find(t)?.memory,...i},r=new v(i,e);return r.label=t,await r.load(),n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}function de(t,e,i){if(!e)if(B.Assets.resolver.hasKey(t))e=t;else throw new PixiError("unregistered_asset",`The video ${t} does not exist in the cache.`,"canvas",{pixivnId:g$1,...i,label:t});let n={...f.find(t)?.memory,...i},r=new M(i,e);return n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}async function St(t,e,i){if(!e)if(B.Assets.resolver.hasKey(t))e=t;else throw new PixiError("unregistered_asset",`The video ${t} does not exist in the cache.`,"canvas",{pixivnId:g$1,...i,label:t});let n={...f.find(t)?.memory,...i},r=new M(i,e);return r.label=t,await r.load(),n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}function Ie(t){switch(t.type){case "align":return {xAlign:t.x,yAlign:t.y};case "percentage":return {percentageX:t.x,percentageY:t.y};default:return {x:t.x,y:t.y}}}function F(t,e,i){if(typeof e=="string")return U(e)?de(t,e,i):ce(t,e,i);if(Array.isArray(e))return oe(t,e,i);if(typeof e=="object"&&"value"in e&&"options"in e){if(typeof e.value=="string")return U(e.value)?de(t,e.value,{...e.options,zIndex:i.zIndex}):ce(t,e.value,{...e.options,zIndex:i.zIndex});if(Array.isArray(e.value))return oe(t,e.value,{...e.options,zIndex:i.zIndex})}return f.add(t,e,i),e}async function qe(t,e,i={},n){let{completeOnContinue:r=true,tickerIdToResume:a=[],...o}=i,p=[];e||(e=t),typeof a=="string"&&(a=[a]);let d,s=f.find(t);if(s&&(d=`${t}_temp_disolve`,f.editAlias(t,d)),e=F(t,e,{zIndex:s?s.parent?.getChildIndex(s):void 0}),s?.parent?.setChildIndex(s,s.parent.getChildIndex(s)-.1),d&&f.copyCanvasElementProperty(d,t),d&&f.tickers.transfer(d,t,"duplicate"),e.alpha=0,d){let l=pe(d,{...i,autoplay:false,completeOnContinue:r},n);l&&(p.push(...l),a.push(...l));}let c=f.animate(t,{alpha:1},{...o,tickerIdToResume:a,completeOnContinue:r},n);if(c&&p.push(c),(e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),p.length>0)return p}function pe(t,e={},i){let{completeOnContinue:n=true,aliasToRemoveAfter:r=[],...a}=e;typeof r=="string"&&(r=[r]),r.push(t);let o=f.animate(t,{alpha:0},{...a,aliasToRemoveAfter:r,completeOnContinue:n},i);if(o)return [o]}async function bt(t,e,i={},n){let{completeOnContinue:r=true,aliasToRemoveAfter:a=[],...o}=i,p=[];e||(e=t),typeof a=="string"&&(a=[a]);let d=f.find(t);if(!d)return qe(t,e,i,n);let s=`${t}_temp_fade`;f.editAlias(t,s),a.push(s),e=F(t,e,{zIndex:d?d.parent?.getChildIndex(d):void 0}),d?.parent?.setChildIndex(d,d.parent.getChildIndex(d)-.1),s&&f.copyCanvasElementProperty(s,t),s&&f.tickers.transfer(s,t,"duplicate"),e.alpha=0;let c=f.animate(t,{alpha:1},{...o,aliasToRemoveAfter:a,completeOnContinue:r},n);if(c){let l=pe(s,{...i,tickerIdToResume:c,completeOnContinue:r},n);l&&p.push(...l),p.push(c),f.tickers.pause({id:c});}if((e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),p.length>0)return p}function At(t,e={},i){return pe(t,e,i)}async function Et(t,e,i={},n){let{direction:r="right",completeOnContinue:a=true,tickerIdToResume:o=[],aliasToRemoveAfter:p=[],removeOldComponentWithMoveOut:d,...s}=i,c=[],l;e||(e=t),typeof o=="string"&&(o=[o]),typeof p=="string"&&(p=[p]);let u,y=f.find(t);if(y&&(u=`${t}_temp_movein`,f.editAlias(t,u),y instanceof v||y instanceof P?l=y.positionInfo:l={x:y.x,y:y.y,type:"pixel"}),e=F(t,e,{zIndex:y?y.parent?.getChildIndex(y):void 0}),y?.parent?.setChildIndex(y,y.parent.getChildIndex(y)-.1),u&&f.copyCanvasElementProperty(u,t),u&&f.tickers.transfer(u,t,"move"),l||(e instanceof v||e instanceof P?l=e.positionInfo:l={x:e.x,y:e.y,type:"pixel"}),u)if(d){let C=ke(u,{...i,autoplay:false,completeOnContinue:a},n);C&&(c.push(...C),o.push(...C));}else p.push(u);switch((e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),r){case "up":e.y=f.height+e.height;break;case "down":e.y=-e.height;break;case "left":e.x=f.width+e.width;break;case "right":e.x=-e.width;break}let x=f.tickers.pause({canvasAlias:t});o.push(...x);let T=f.animate(t,Ie(l),{...s,tickerIdToResume:o,aliasToRemoveAfter:p,completeOnContinue:a},n);if(T&&c.push(T),c.length>0)return c}function ke(t,e={},i){let{direction:n="right",completeOnContinue:r=true,aliasToRemoveAfter:a=[],...o}=e;typeof a=="string"&&(a=[a]),a.push(t);let p=f.find(t);if(!p){e$1.warn(`The canvas component "${t}" is not found.`);return}let d={x:p.x,y:p.y};switch(n){case "up":d.y=-p.height;break;case "down":d.y=f.height+p.height;break;case "left":d.x=-p.width;break;case "right":d.x=f.width+p.width;break}f.tickers.pause({canvasAlias:t});let s=f.animate(t,d,{...o,aliasToRemoveAfter:a,completeOnContinue:r},i);if(s)return [s]}async function Mt(t,e,i={},n){let{direction:r="right",completeOnContinue:a=true,tickerIdToResume:o=[],aliasToRemoveAfter:p=[],...d}=i,s=[],c;e||(e=t),typeof o=="string"&&(o=[o]),typeof p=="string"&&(p=[p]);let l,u=f.find(t);u&&(l=`${t}_temp_zoom`,f.editAlias(t,l),u instanceof v||u instanceof P?c=u.positionInfo:c={x:u.x,y:u.y,type:"pixel"}),e=F(t,e,{zIndex:u?u.parent?.getChildIndex(u):void 0}),u?.parent?.setChildIndex(u,u.parent.getChildIndex(u)-.1),l&&f.copyCanvasElementProperty(l,t),l&&f.tickers.transfer(l,t,"move"),c||(e instanceof v||e instanceof P?c=e.positionInfo:c={x:e.x,y:e.y,type:"pixel"});let y={x:e.pivot.x,y:e.pivot.y},x={x:e.scale.x,y:e.scale.y};if(l)if(i.removeOldComponentWithZoomOut){let le=Ge(l,{...i,autoplay:false,completeOnContinue:a},n);le&&(s.push(...le),o.push(...le));}else p.push(l);(e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),r==="up"?(e.pivot.y=f.height-e.y,e.pivot.x=f.width/2-e.x,e.y=f.height,e.x=f.width/2):r==="down"?(e.pivot.y=0-e.y,e.pivot.x=f.width/2-e.x,e.y=0,e.x=f.width/2):r==="left"?(e.pivot.x=f.width-e.x,e.pivot.y=f.height/2-e.y,e.x=f.width,e.y=f.height/2):r==="right"&&(e.pivot.x=0-e.x,e.pivot.y=f.height/2-e.y,e.x=0,e.y=f.height/2),e.pivot=h.getPointBySuperPoint(e.pivot,e.angle),e.scale.set(0);let T=f.tickers.pause({canvasAlias:t});o.push(...T);let C=f.animate(t,{...Ie(c),pivotX:y.x,pivotY:y.y,scaleX:x.x,scaleY:x.y},{...d,tickerIdToResume:o,aliasToRemoveAfter:p,completeOnContinue:a},n);if(C&&s.push(C),s.length>0)return s}function Ge(t,e={},i){let{direction:n="right",completeOnContinue:r=true,aliasToRemoveAfter:a=[],...o}=e;typeof a=="string"&&(a=[a]),a.push(t);let p=f.find(t);if(!p){e$1.warn(`The canvas component "${t}" is not found.`);return}let d={x:p.x,y:p.y},s={x:p.pivot.x,y:p.pivot.y};n==="down"?(d.y=f.height,d.x=f.width/2,s.y=f.height-d.y,s.x=f.width/2-d.x):n==="up"?(d.y=0,d.x=f.width/2,s.y=0-d.y,s.x=f.width/2-d.x):n==="right"?(d.x=f.width,d.y=f.height/2,s.x=f.width-d.x,s.y=f.height/2-d.y):n==="left"&&(d.x=0,d.y=f.height/2,s.x=0-d.x,s.y=f.height/2-d.y),s=h.getPointBySuperPoint(s,p.angle),f.tickers.pause({canvasAlias:t});let c=f.animate(t,{...d,pivotX:s.x,pivotY:s.y,scaleX:0,scaleY:0},{...o,aliasToRemoveAfter:a,completeOnContinue:r},i);if(c)return [c]}async function _t(t,e,i={},n){let{direction:r="right",completeOnContinue:a=true,tickerIdToResume:o=[],...p}=i,d=[],s;e||(e=t),typeof o=="string"&&(o=[o]);let c,l=f.find(t);switch(l&&(c=`${t}_temp_push`,f.editAlias(t,c),l instanceof v||l instanceof P?s=l.positionInfo:s={x:l.x,y:l.y,type:"pixel"}),e=F(t,e,{zIndex:l?l.parent?.getChildIndex(l):void 0}),l?.parent?.setChildIndex(l,l.parent.getChildIndex(l)-.1),c&&f.copyCanvasElementProperty(c,t),c&&f.tickers.transfer(c,t,"move"),s||((e instanceof v||e instanceof P)&&e.haveEmptyTexture?s=e.positionInfo:s={x:e.x,y:e.y,type:"pixel"}),(e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),r){case "up":e.y=f.height+e.height;break;case "down":e.y=-e.height;break;case "left":e.x=f.width+e.width;break;case "right":e.x=-e.width;break}let u=f.tickers.pause({canvasAlias:t});if(o.push(...u),c){let x=Ne(c,{...i,direction:r,completeOnContinue:a});x&&d.push(...x);}let y=f.animate(t,Ie(s),{...p,tickerIdToResume:o,completeOnContinue:a},n);if(y&&d.push(y),d.length>0)return d}function Ne(t,e={direction:"right"},i){return ke(t,e,i)}var K=class extends _{constructor(i){super(i);this._memory=i;this.pixivnId=i.pixivnId;}_memory;pixivnId;get memory(){return {...this._memory,...super.memory,elements:[],pixivnId:this.pixivnId}}};function wt(){return async(e,i)=>{try{let n=e.canvasElementInfo;if(n){let r=new K(n),a=n.zIndex;r.groupColor=16711680;let o=new B.Graphics;o.rect(0,0,300,100).fill({color:16711680,alpha:.5}),r.addChild(o);let p=new B.Text({text:`Error: ${n.label}`,x:10,y:10});r.addChild(p);let d=e.parent;if(d&&"addChild"in d)a!==void 0?d.addChildAt(r,a):d.addChild(r);else {let s=n.parentLabel?f.find(n.parentLabel):void 0;if(s)a!==void 0?s.addChildAt(r,a):s.addChild(r);else {let c=n.label??n.pixivnId;f.add(c,r,{zIndex:a});}}}}catch{}}}function Ot(t,e,i){let n={...f.find(t)?.memory,...i},r=new z({text:e,...i});return n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}var {Assets:Mn,Color:_n,Rectangle:wn,TextStyle:On,Texture:Bn,UPDATE_PRIORITY:Ln}=B,f=new G;I.init({getScreen:()=>f.screen});GameUnifier.addOnPreContinue(async()=>{try{let t=g._tickersToCompleteOnStepEnd.tikersIds,e=g._tickersToCompleteOnStepEnd.stepAlias,i=(async()=>{for(;t.length;){let{id:r}=t.pop()||{};r&&await f.tickers.forceCompletion(r);}})(),n=(async()=>{for(;e.length;){let{alias:r,id:a}=e.pop()||{};r&&a&&await f.tickers.forceCompletion(a,r);}})();await Promise.all([i,n]),g._tickersToCompleteOnStepEnd.tikersIds.length=0,g._tickersToCompleteOnStepEnd.stepAlias.length=0;}catch{}});
1
+ import {a}from'./chunk-6GLWL3NH.mjs';import'./chunk-JMOSOAGB.mjs';import {e,d as d$1,g as g$1,b,c as c$1,f as f$1,a as a$1}from'./chunk-HD353M4B.mjs';import {c,d,e as e$1,f as f$2}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';import B,{Container}from'@drincs/pixi-vn/pixi.js';import {initDevtools}from'@pixi/devtools';var Fe={extension:{type:"sceneProperties",name:"additional-positions"},testNode(t){return "xAlign"in t||"yAlign"in t||"percentageX"in t||"percentageY"in t||"positionType"in t},testProp(t){switch(t){case "xAlign":case "yAlign":case "percentageX":case "percentageY":case "positionType":return true;default:return false}},setProperty(t,e,i){switch(e){case "xAlign":"xAlign"in t&&(t.xAlign=i/100);break;case "yAlign":"yAlign"in t&&(t.yAlign=i/100);break;case "percentageX":"percentageX"in t&&(t.percentageX=i/100);break;case "percentageY":"percentageY"in t&&(t.percentageY=i/100);break}},getProperties(t){return [{value:t.positionType,prop:"positionType",entry:{section:"Transform",type:"text",label:"Position Type"}},{value:t.xAlign*100,prop:"xAlign",entry:{section:"Transform",type:"range",label:"X Align",tooltip:"0% is left, 100% is right",options:{min:0,max:100}}},{value:t.yAlign*100,prop:"yAlign",entry:{section:"Transform",type:"range",label:"Y Align",tooltip:"0% is top, 100% is bottom",options:{min:0,max:100}}},{value:t.percentageX*100,prop:"percentageX",entry:{section:"Transform",type:"range",label:"X Percentage Position",tooltip:"0% is left, 100% is right",options:{min:0,max:100}}},{value:t.percentageY*100,prop:"percentageY",entry:{section:"Transform",type:"range",label:"Y Percentage Position",tooltip:"0% is top, 100% is bottom",options:{min:0,max:100}}}]}},be=Fe;function Ae(t,e){let i=0;return async(...n)=>{let r=Date.now();if(r-i>=e)return i=r,await t(...n)}}var _e=c(a(),1),g=class t{constructor(){}static _app=void 0;static get app(){if(!t._app)throw e$1.error("The canvas is not initialized"),new PixiError("invalid_usage","CanvasManagerStatic.app is undefined");return t._app}static get gameLayer(){let e=t.app.stage.getChildByLabel(a$1);return e||(e=new B.Container,e.label=a$1,t.app.stage.addChild(e)),e}static htmlLayers=[];static canvasWidth=300;static canvasHeight=300;static _isInitialized=false;static async init(e,i,n){let{id:r="pixi-vn-canvas",width:a=800,height:o=600,resolution:p=1,autoDensity:d=true,resizeMode:s="contain",...c}=i||{};return t.canvasWidth=a,t.canvasHeight=o,t._app=new B.Application,t.app.init({width:a,height:o,resolution:p,autoDensity:d,...c}).then(()=>{let{app:l=t.app,extensions:u=[],...y}=n||{};if(initDevtools({app:l,extensions:[be,...u],...y}),t._isInitialized=true,t.addCanvasIntoHTMLElement(e,r),s==="contain"){let x=Ae(async()=>{requestAnimationFrame(()=>t.resize());},10);new ResizeObserver(x).observe(e),t.resize(),setTimeout(()=>t.resize(),750);}t.gameLayer;})}static addCanvasIntoHTMLElement(e,i){t._isInitialized?(e.appendChild(t.app.canvas),t.app.canvas.id=i):e$1.error("GameWindowManager is not initialized");}static addHtmlLayer(e,i,n={}){let{position:r="absolute",pointerEvents:a="none",userSelect:o="none"}=n,p=document.createElement("div");p.setAttribute("id",e),p.style.position=r,p.style.pointerEvents=a,p.style.userSelect=o;let d=i.appendChild(p);return t.htmlLayers.push(p),t.resize(),d}static removeHtmlLayer(e){let i=t.htmlLayers.find(n=>n.id===e);i&&(i.remove(),t.htmlLayers=t.htmlLayers.filter(n=>n.id!==e));}static getHtmlLayer(e){return t.htmlLayers.find(i=>i.id===e)}static async resize(){let e=t.canvasWidth,i=t.canvasHeight,n=t.app.resizeTo,r=t.app.canvas.style;n instanceof HTMLElement||(n=document.documentElement);let a,o;if(n===document.body||n===document.documentElement)a=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight;else {let u=n.getBoundingClientRect();a=u.width||n.clientWidth,o=u.height||n.clientHeight;}let p=Math.min(a/e,o/i),d=Math.floor(p*e),s=Math.floor(p*i);r.width=`${d}px`,r.height=`${s}px`;let c=(a-d)/2,l=(o-s)/2;r.marginLeft=`${c}px`,r.marginRight=`${c}px`,r.marginTop=`${l}px`,r.marginBottom=`${l}px`,t.htmlLayers.forEach(u=>{u.style.width=`${d}px`,u.style.height=`${s}px`,u.style.marginLeft=`${c}px`,u.style.marginRight=`${c}px`,u.style.marginTop=`${l}px`,u.style.marginBottom=`${l}px`;});}static get childrenAliasesOrder(){return t.gameLayer.children.filter(e=>e.label).sort((e,i)=>t.gameLayer.getChildIndex(e)-t.gameLayer.getChildIndex(i)).map(e=>e.label)}static get currentTickersWithoutCreatedBySteps(){return Object.fromEntries(Array.from(t._currentTickers.entries()).filter(([e,i])=>!i.createdByTicketSteps).map(([e,i])=>[e,{id:i.ticker.alias,args:i.ticker.args,canvasElementAliases:i.ticker.canvasElementAliases,priority:i.ticker.priority,duration:i.ticker.duration,paused:i.ticker.paused}]))}static _currentTickers=new Map;static _currentTickersSequence=new Map;static get currentTickersSequence(){return Object.fromEntries(Array.from(t._currentTickersSequence.entries()).map(([e,i])=>[e,Object.fromEntries(i)]))}static _currentTickersTimeouts=new Map;static _tickersToCompleteOnStepEnd={tikersIds:[],stepAlias:[]};static generateTickerId(...e){try{return `${(0,_e.default)(JSON.stringify(e)).toString()}_${Math.random().toString(36).substring(7)}`}catch(i){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${i}`)}}static addTickerTimeoutInfo(e,i,n,r){typeof e=="string"&&(e=[e]),t._currentTickersTimeouts.set(n,{aliases:e,ticker:i,canBeDeletedBeforeEnd:r});}static removeTickerTimeoutInfo(e){typeof e!="string"&&(e=e.toString()),t._currentTickersTimeouts.delete(e);}static removeTickerTimeout(e){typeof e!="string"&&(e=e.toString()),clearTimeout(Number(e)),t.removeTickerTimeoutInfo(e);}static removeTickerTimeoutsByAlias(e,i){t._currentTickersTimeouts.forEach((n,r)=>{let a=n.aliases.filter(o=>o!==e);if(a.length===0){let o=n.canBeDeletedBeforeEnd;(!i||o)&&t.removeTickerTimeout(r);}else n.aliases=a;});}};var ue=Symbol("SerializableEvent"),X=new d({cacheSize:5});function Ze(t){return (e,i,n)=>{let r=n.value;fe.add(r,t||`${i}`);}}var fe;(a=>{function t(o,p){o[ue]=p,X.get(p)&&e$1.info(`Event "${p}" already exists, it will be overwritten`),X.set(p,o);}a.add=t;function e(o){try{let p=X.get(o);if(!p){e$1.error(`Event "${o}" not found, did you forget to register it with the eventDecorator?`);return}return p}catch(p){e$1.error(`Error while getting Event "${o}"`,p);return}}a.get=e;function i(){return Array.from(X.values())}a.values=i;function n(o){return X.has(o)}a.has=n;function r(){return Array.from(X.keys())}a.keys=r;})(fe||={});var ge=fe;async function we(t,e){if("onEvents"in e)for(let i in e.onEvents){let n=e.onEvents[i],r=ge.get(n);r&&t.on(i,r);}}function Oe(t){let{onEventsHandlers:e={}}=t;return e}function O(t,e,i){let n=i[ue];return n&&typeof n=="string"?(e.onEventsHandlers[t]=n,true):(e$1.warn(`The event handler for event "${t}" is not registered with the eventDecorator, it will not be saved in the memory and it will not work after loading the game. Please register the event handler with the eventDecorator to avoid this warning. Read more about it here: https://pixi-vn.com/start/canvas-functions#add-a-listener-to-an-event`),false)}var q=new d({cacheSize:5}),Be=new d({cacheSize:2}),Le=new d({cacheSize:2});function Je(t={}){return e=>{he.add(e,t);}}async function S(t,e,i){let n=i?.ignoreScale||false,r=i?.end;"isRenderGroup"in e&&e.isRenderGroup!==void 0&&(t.isRenderGroup=e.isRenderGroup),"blendMode"in e&&e.blendMode!==void 0&&(t.blendMode=e.blendMode),"tint"in e&&e.tint!==void 0&&(t.tint=e.tint),"alpha"in e&&e.alpha!==void 0&&(t.alpha=e.alpha),"angle"in e&&e.angle!==void 0&&(t.angle=e.angle),"renderable"in e&&e.renderable!==void 0&&(t.renderable=e.renderable),"rotation"in e&&e.rotation!==void 0&&(t.rotation=e.rotation),!n&&"scale"in e&&e.scale!==void 0&&(typeof e.scale=="number"?t.scale.set(e.scale,e.scale):t.scale.set(e.scale.x,e.scale.y)),"pivot"in e&&e.pivot!==void 0&&(typeof e.pivot=="number"?t.pivot.set(e.pivot,e.pivot):t.pivot.set(e.pivot.x,e.pivot.y)),"position"in e&&e.position!==void 0&&t.position.set(e.position.x,e.position.y),"skew"in e&&e.skew!==void 0&&t.skew.set(e.skew.x,e.skew.y),"visible"in e&&e.visible!==void 0&&(t.visible=e.visible),"x"in e&&e.x!==void 0&&(t.x=e.x),"y"in e&&e.y!==void 0&&(t.y=e.y),"boundsArea"in e&&e.boundsArea!==void 0&&(t.boundsArea=e.boundsArea),"cursor"in e&&e.cursor!==void 0&&(t.cursor=e.cursor),"eventMode"in e&&e.eventMode!==void 0&&(t.eventMode=e.eventMode),"interactive"in e&&e.interactive!==void 0&&(t.interactive=e.interactive),"interactiveChildren"in e&&e.interactiveChildren!==void 0&&(t.interactiveChildren=e.interactiveChildren),"hitArea"in e&&e.hitArea!==void 0&&(t.hitArea=e.hitArea),we(t,e),"align"in e&&e.align!==void 0&&"align"in t&&(t.align=e.align),"percentagePosition"in e&&e.percentagePosition!==void 0&&"percentagePosition"in t&&(t.percentagePosition=e.percentagePosition),r&&await r(),n||("width"in e&&e.width!==void 0&&(t.width=e.width),"height"in e&&e.height!==void 0&&(t.height=e.height));}var he;(p=>{function t(d,s={}){let{name:c=d.name,getInstance:l=async(y,x)=>{let T=new y;return await T.setMemory(x),T},copyProperty:u=async(y,x)=>{await y.setMemory(x);}}=s;q.get(c)&&e$1.warn(`CanvasElement "${c}" already registered`),d.prototype.pixivnId=c,q.set(c,d),Be.set(c,l),Le.set(c,u);}p.add=t;function e(d){let s=q.get(d);if(!s){e$1.error(`CanvasElement "${d}" not found, did you forget to register it with the canvasComponentDecorator?`);return}return s}p.get=e;async function i(d,s){let c=e(d),l=Be.get(d);if(!c||!l){e$1.error(`CanvasElement "${d}" not found, did you forget to register it with the canvasComponentDecorator?`);return}try{return await l(c,s)}catch(u){e$1.error(`Error while getting CanvasElement instance "${d}"`,u);}}p.getInstance=i;async function n(d,s,c){let l=Le.get(d);if(!l){e$1.error(`CanvasElement "${d}" not found, did you forget to register it with the canvasComponentDecorator?`);return}try{await l(s,c);}catch(u){e$1.error(`Error while copying properties of CanvasElement "${d}"`,u);}}p.copyProperty=n;function r(){return Array.from(q.values())}p.values=r;function a(d){return q.has(d)}p.has=a;function o(){return Array.from(q.keys())}p.keys=o;})(he||={});var k=he;async function J(t){let e=await k.getInstance(t.pixivnId,t);if(!e)throw new PixiError("unregistered_element",`The element ${t.pixivnId} could not be created`,"canvas",t);return e}function ye(t){return "memory"in t?t.memory:t instanceof B.Text?Te(t):t instanceof B.Sprite?xe(t):L(t)}function et(t){let e=t.parent;return {width:t.width,height:t.height,isRenderGroup:t.isRenderGroup,blendMode:t.blendMode,tint:t.tint,alpha:t.alpha,angle:t.angle,renderable:t.renderable,rotation:t.rotation,scale:{x:t.scale.x,y:t.scale.y},pivot:{x:t.pivot.x,y:t.pivot.y},position:{x:t.position.x,y:t.position.y},skew:{x:t.skew.x,y:t.skew.y},visible:t.visible,x:t.x,y:t.y,boundsArea:t.boundsArea,cursor:t.cursor,eventMode:t.eventMode,interactive:t.interactive,interactiveChildren:t.interactiveChildren,hitArea:t.hitArea,index:e?.getChildIndex(t),parentLabel:e?.label,label:t.label}}function me(t,e){return {url:t.source.label,alias:e===t.source.label?void 0:e}}function L(t,e){let i=tt(t,b),r=e?.childrenExport||false?t.children.sort((a,o)=>t.getChildIndex(a)-t.getChildIndex(o)).map(a=>ye(a)):[];return {pixivnId:i,elements:r,onEvents:Oe(t),...et(t)}}function xe(t){let e$1=L(t),i=e$1.pixivnId??e,n="assetsAliases"in t&&Array.isArray(t.assetsAliases)?me(t.texture,t.assetsAliases[0]):"textureAlias"in t?me(t.texture,t.textureAlias):me(t.texture);return {...e$1,pixivnId:i,textureData:n,anchor:{x:t.anchor.x,y:t.anchor.y},roundPixels:t.roundPixels}}function Te(t){let e=L(t),i=e.pixivnId??f$1;return {...e,pixivnId:i,anchor:{x:t.anchor.x,y:t.anchor.y},text:t.text,resolution:t.resolution,style:st(t.style),roundPixels:t.roundPixels}}function tt(t,e){return Object.hasOwn(t,"pixivnId")?t.pixivnId:e}function Q(t){switch(t.type){case "linear":return {type:"linear",colorStops:t.colorStops,end:{x:t.end.x,y:t.end.y},start:{x:t.start.x,y:t.start.y},textureSpace:t.textureSpace,wrapMode:t.texture.source.wrapMode,textureSize:t.texture.source.width/t.texture.source.height};case "radial":return {type:"radial",colorStops:t.colorStops,textureSpace:t.textureSpace,center:{x:t.center.x,y:t.center.y},innerRadius:t.innerRadius,outerCenter:{x:t.outerCenter.x,y:t.outerCenter.y},outerRadius:t.outerRadius,rotation:t.rotation,scale:t.scale,wrapMode:t.texture.source.wrapMode,textureSize:t.texture.source.width/t.texture.source.height}}}function it(t){if(t!=null){{if(typeof t=="number")return t;if(typeof t=="string"||Array.isArray(t))return t;if(t instanceof B.FillGradient)return Q(t);if(typeof t=="object"&&"fill"in t&&typeof t.fill!="function"&&t.fill){if(!(t.fill instanceof B.FillPattern))return Q(t.fill)}}e$1.warn("Unsupported property type for Text.style.fill.",t);}}function rt(t){if(typeof t=="number")return t;if(typeof t=="string")return t;if(Array.isArray(t))return t;if(t instanceof B.Color)return t.toNumber();e$1.warn("Unsupported color type.",t);}function nt(t){if(t!=null){{if(typeof t=="number")return t;if(typeof t=="string"||Array.isArray(t))return t;if(t instanceof B.FillGradient)return Q(t);if(typeof t=="object"&&"alignment"in t)return {alignment:t.alignment,alpha:t.alpha,color:rt(t.color),join:t.join,miterLimit:t.miterLimit,width:t.width,cap:t.cap,pixelLine:t.pixelLine,textureSpace:t.textureSpace};if(typeof t=="object"&&"fill"in t&&typeof t.fill!="function"&&t.fill){if(!(t.fill instanceof B.FillPattern))return Q(t.fill)}}e$1.warn("Unsupported property type for Text.style.stroke.",t);}}function st(t){return {align:t.align,breakWords:t.breakWords,dropShadow:t.dropShadow,fill:it(t.fill),fontFamily:t.fontFamily,fontSize:t.fontSize,fontStyle:t.fontStyle,fontVariant:t.fontVariant,fontWeight:t.fontWeight,leading:t.leading,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,padding:t.padding,stroke:nt(t.stroke),textBaseline:t.textBaseline,trim:t.trim,whiteSpace:t.whiteSpace,wordWrap:t.wordWrap,wordWrapWidth:t.wordWrapWidth}}var Re=c(a(),1);var ee=class{constructor(e,i){this.alias=this.constructor.prototype.id;let{duration:n,priority:r,id:a=this.generateTickerId(this.alias,i),canvasElementAliases:o=[]}=i||{};this.args=e,this.duration=n,this.priority=r,this.id=a,this.canvasElementAliases=o;}alias;id;args;duration;priority;ticker=new B.Ticker;canvasElementAliases=[];generateTickerId(...e){try{return (0,Re.default)(JSON.stringify(e)).toString()+"_"+Math.random().toString(36).substring(7)}catch(i){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${i}`)}}fnValue;complete(e){this.stop();}stop(){let e=this.fnValue;if(!e){e$1.warn("TickerBase.stop() called without fnValue set. This may cause issues.");return}this.ticker.remove(e,null);}start(){let e=this.id,i=()=>this.fn(this.ticker,this.args,this.canvasElementAliases,e);this.fnValue=i,this.ticker.add(i,null,this.priority),this.ticker.start();}pause(){this.ticker.stop();}play(){this.ticker.start();}get paused(){return !this.ticker.started}};var R=new d({cacheSize:5});function ct(t){return function(e){ve.add(e,t);}}var ve;(o=>{function t(p,d){d||(d=p.name),R.get(d)&&e$1.info(`Ticker "${d}" already exists, it will be overwritten`),p.prototype.id=d,R.set(d,p);}o.add=t;function e(p){try{let d=R.get(p);if(!d){e$1.error(`Event "${p}" not found, did you forget to register it with the tickerDecorator?`);return}return d}catch(d){e$1.error(`Error while getting Event "${p}"`,d);return}}o.get=e;function i(p,d,s){try{let c=R.get(p);if(!c){e$1.error(`Ticker "${p}" not found, did you forget to register it with the tickerDecorator?`);return}return new c(d,s)}catch(c){e$1.error(`Error while getting Ticker "${p}"`,c);return}}o.getInstance=i;function n(){return Array.from(R.values())}o.values=n;function r(p){return R.has(p)}o.has=r;function a(){return Array.from(R.keys())}o.keys=a;})(ve||={});var D=ve;var De="aliasToRemoveAfter";var G=class{tickersPausedByGameLayerRender=[];get app(){return g.app}get gameLayer(){return g.gameLayer}get isInitialized(){return g._isInitialized}get width(){return g.canvasWidth}get height(){return g.canvasHeight}get screen(){return this.app.screen}async init(e,i,n){return await g.init(e,i,n)}get children(){return g.gameLayer.children}async copyCanvasElementProperty(e,i,n={}){let r=["isRenderGroup","scale","visible","boundsArea","text","resolution","style","height","width"],{ignoreProperties:a=d=>d}=n;if(typeof i=="string"){let d=this.find(i);if(d)i=d;else {e$1.error(`Canvas element ${i} not found`);return}}if(typeof e=="string"){let d=this.find(e);if(d)e=d;else {e$1.error(`Canvas element ${e} not found`);return}}e instanceof B.Container&&(e=e.memory);let o=a(r),p={...e};o.forEach(d=>{d in p&&delete p[d];}),await k.copyProperty(i.pixivnId,i,p);}add(e,i,n={}){if(e===a$1){e$1.error(`The alias ${a$1} is reserved`);return}let r=this.find(e),a=n?.ignoreOldStyle;r&&!a&&this.copyCanvasElementProperty(r,i);let{zIndex:o=r?.parent?.getChildIndex(r)}=n;r&&!this.canvasElementIsOnCanvas(r)?e$1.error(`The canvas element ${e} exist in the memory but it is not on the canvas, so the zIndex is not set`):r&&this.remove(e,{ignoreTickers:true}),o!==void 0?(i.label=e,this.gameLayer.addChildAt(i,o)):(i.label=e,this.gameLayer.addChild(i));}remove(e,i={}){if(e===a$1){e$1.error(`The alias ${a$1} is reserved`);return}let n=i.ignoreTickers;typeof e=="string"&&(e=[e]),e.forEach(r=>{this.gameLayer.getChildrenByLabel(r).forEach(a=>{this.gameLayer.removeChild(a),!n&&this.unlinkComponentFromTickerInternal(r);});});}find(e){if(e===a$1)return this.gameLayer;let i=this.gameLayer.getChildByLabel(e);if(i)return i}canvasElementIsOnCanvas(e){return this.gameLayer.children.includes(e)}removeAll(){this.gameLayer.removeChildren();}editAlias(e,i,n={}){let r=this.find(e);r&&(r.label=i),!n.ignoreTickers&&this.transferTickersInternal(e,i,"move");}get currentTickers(){return this.tickers.currentTickers}get currentTickersSteps(){return this.tickers.currentTickersSteps}findTicker(e){return this.findTickerInternal(e)}findTickerInternal(e){let i=g._currentTickers.get(e);if(i)return i.ticker}addTicker(e,i){return this.addTickerInternal(e,i)}addTickerInternal(e,i){let n=i.id,r=i.alias;if(typeof e=="string"&&(e=[e]),i.canvasElementAliases=e,!D.has(r)){e$1.error(`Ticker ${r} not found`);return}let a={ticker:i};if(g._currentTickers.set(n,a),a.ticker.start(),i.duration){let o=setTimeout(()=>{g.removeTickerTimeoutInfo(o),g._currentTickersTimeouts.get(o.toString())&&a.ticker.complete({ignoreTickerSteps:true});},i.duration*1e3);g.addTickerTimeoutInfo(e,r,o.toString(),true);}return n}addTickersSequence(e,i,n=0){if(i.length===0){e$1.warn("The steps of the tickers is empty");return}g._currentTickersSequence.has(e)||g._currentTickersSequence.set(e,new Map);let r={currentStepNumber:n,steps:i.map(o=>({ticker:o.alias,args:f$2(o.args),duration:o.duration}))},a=g.generateTickerId(r);return g._currentTickersSequence.get(e)?.set(a,r),this.runTickersSequence(e,a),a}runTickersSequence(e,i){let n=g._currentTickersSequence.get(e);if(!n?.has(i))return;let r=n.get(i).steps[n.get(i).currentStepNumber],a=D.getInstance(r.ticker,r.args,{canvasElementAliases:[e],duration:r.duration,priority:r.priority});if(!a){e$1.error(`Ticker ${r.ticker} not found`);return}let o=a.alias,p=a.id;a.canvasElementAliases=[e];let d={createdByTicketSteps:{canvasElementAlias:e,id:i},ticker:a};if(g._currentTickers.set(p,d),d.ticker.start(),a.duration){let s=setTimeout(()=>{let c=g._currentTickersTimeouts.get(s.toString());c&&(d.ticker.complete({ignoreTickerSteps:true}),c.aliases.forEach(l=>{this.nextTickerStep(l,i);})),g.removeTickerTimeoutInfo(s);},a.duration*1e3);g.addTickerTimeoutInfo(e,o,s.toString(),false);}}nextTickerStep(e,i){let n=g._currentTickersSequence.get(e);if(n?.has(i)){let r=n.get(i);r.currentStepNumber+1<r.steps.length?(r.currentStepNumber++,n.set(i,r),this.runTickersSequence(e,i)):i&&n.has(i)&&(n.delete(i),g._currentTickers.forEach((a,o)=>{a.createdByTicketSteps?.canvasElementAlias===e&&a.createdByTicketSteps.id===i&&this.removeTickerInternal(o);}));}}onTickerComplete(e,i){return this.onTickerCompleteInternal(e,i)}onTickerCompleteInternal(e,i){let{stopTicker:n=true,aliasToRemoveAfter:r,tickerAliasToResume:a,tickerIdToResume:o}=i,p=g._currentTickers.get(e),d=i.ignoreTickerSteps||false;this.remove(r),a.forEach(s=>{this.resumeTickerInternal({canvasAlias:s});}),this.resumeTickerInternal({id:o}),p&&(this.removeTickerInternal(e,{stopTicker:n}),!d&&p.ticker.duration===void 0&&p.createdByTicketSteps&&this.nextTickerStep(p.createdByTicketSteps.canvasElementAlias,p.createdByTicketSteps.id));}unlinkComponentFromTicker(e,i){return this.unlinkComponentFromTickerInternal(e,i)}unlinkComponentFromTickerInternal(e,i){if(typeof e=="string"&&(e=[e]),!i){e.forEach(r=>{g._currentTickers.forEach((a,o)=>{a.ticker.canvasElementAliases.includes(r)&&(a.ticker.canvasElementAliases.length===1?this.removeTickerInternal(o):a.ticker.canvasElementAliases=a.ticker.canvasElementAliases.filter(p=>p!==r));}),g._currentTickersSequence.has(r)&&g._currentTickersSequence.delete(r),g.removeTickerTimeoutsByAlias(r,false);});return}let n;typeof i=="string"?n=i:n=i.prototype.id,e.forEach(r=>{let a=g._currentTickersSequence.get(r);a&&a.forEach((o,p)=>{o.steps.find(d=>typeof d=="object"&&"ticker"in d&&d.ticker===n)&&a.delete(p);});}),g._currentTickers.forEach(r=>{r.ticker.alias===n&&(r.ticker.canvasElementAliases=r.ticker.canvasElementAliases.filter(a=>!e.includes(a)));}),g._currentTickersTimeouts.forEach(r=>{r.ticker===n&&r.canBeDeletedBeforeEnd&&(r.aliases=r.aliases.filter(a=>!e.includes(a)));}),this.removeTickersWithoutAssociatedCanvasElement();}removeTickersWithoutAssociatedCanvasElement(){g._currentTickers.forEach(e=>{e.ticker.canvasElementAliases=e.ticker.canvasElementAliases.filter(i=>this.find(i)),e.ticker.canvasElementAliases.length===0&&e.ticker.complete({ignoreTickerSteps:true});}),g._currentTickersSequence.forEach((e,i)=>{e===void 0&&g._currentTickersSequence.delete(i);}),Array.from(g._currentTickersTimeouts.keys()).forEach(e=>{let i=g._currentTickersTimeouts.get(e);i&&i.aliases.length===0&&g.removeTickerTimeout(e);});}removeAllTickers(){return this.removeAllTickersInternal()}removeAllTickersInternal(){this.tickersPausedByGameLayerRender=[],g._currentTickersSequence.clear(),Array.from(g._currentTickers.keys()).forEach(e=>{this.removeTickerInternal(e);}),g._currentTickers.clear(),Array.from(g._currentTickersTimeouts.keys()).forEach(e=>{g.removeTickerTimeout(e);}),g._tickersToCompleteOnStepEnd.tikersIds.length=0,g._tickersToCompleteOnStepEnd.stepAlias.length=0;}removeTicker(e,i={stopTicker:true}){return this.removeTickerInternal(e,i)}removeTickerInternal(e,i={stopTicker:true}){typeof e=="string"&&(e=[e]),e.forEach(n=>{let r=g._currentTickers.get(n);r&&(i.stopTicker&&r.ticker.stop(),g._currentTickers.delete(n));});}pauseTicker(e){return this.pauseTickerInternal(e)}pauseTickerInternal(e){let i=[];if("canvasAlias"in e){let{canvasAlias:n,tickerIdsExcluded:r=[]}=e;g._currentTickers.forEach((a,o)=>{a.ticker.canvasElementAliases.includes(n)&&!r.includes(a.ticker.alias)&&a.ticker.paused===false&&(a.ticker.pause(),i.push(o));});}else if("id"in e){let{id:n}=e;typeof n=="string"&&(n=[n]),[...new Set(n)].forEach(r=>{let a=g._currentTickers.get(r);a?a.ticker.paused===false&&(a.ticker.pause(),i.push(r)):e$1.error(`Ticker with id ${r} not found`);});}return i}resumeTicker(e){return this.resumeTickerInternal(e)}resumeTickerInternal(e){if("canvasAlias"in e){let{canvasAlias:i}=e;g._currentTickers.forEach(n=>{n.ticker.canvasElementAliases.includes(i)&&n.ticker.play();});}else if("id"in e){let{id:i}=e;typeof i=="string"&&(i=[i]),[...new Set(i)].forEach(n=>{let r=g._currentTickers.get(n);r?r.ticker.play():e$1.error(`Ticker with id ${n} not found`);});}}isTickerPaused(e,i){return this.isTickerPausedInternal(e,i)}isTickerPausedInternal(e,i){return false}pause(){this.gameLayer.renderable!==false&&(this.gameLayer.renderable=false,this.tickersPausedByGameLayerRender=this.pauseTickerInternal({id:Array.from(g._currentTickers.keys())}));}resume(){if(this.gameLayer.renderable===true)return;this.gameLayer.renderable=true;let e=this.tickersPausedByGameLayerRender.filter(i=>g._currentTickers.has(i));e.length>0&&this.resumeTickerInternal({id:e}),this.tickersPausedByGameLayerRender=[];}transferTickers(e,i,n="move"){return this.transferTickersInternal(e,i,n)}transferTickersInternal(e,i,n="move"){let r=g._currentTickersSequence.get(e);if(r){let o=new Map(Array.from(r.entries()).map(([p,d])=>[p,f$2(d)]));g._currentTickersSequence.set(i,o);}g._currentTickers.forEach((o,p)=>{if(o.createdByTicketSteps?.canvasElementAlias===e&&this.removeTickerInternal(p),o.ticker.canvasElementAliases.includes(e)){let d=D.getInstance(o.ticker.alias,f$2(o.ticker.args),{duration:o.ticker.duration,priority:o.ticker.priority,canvasElementAliases:[i]});if(d?(this.addTickerInternal(i,d),o.ticker.paused&&d.pause()):e$1.error(`Ticker ${o.ticker.alias} not found`),n==="move"&&(o.ticker.canvasElementAliases=o.ticker.canvasElementAliases.filter(s=>s!==e)),Object.hasOwn(o.ticker.args,De)){let s=o.ticker.args.aliasToRemoveAfter;typeof s=="string"&&(s=[s]),Array.isArray(s)&&(n==="move"?o.ticker.args.aliasToRemoveAfter=s.map(c=>c===e?i:c):n==="duplicate"&&s.find(c=>c===e)&&(o.ticker.args.aliasToRemoveAfter=[...s,i]));}}}),g._currentTickersTimeouts.forEach(o=>{o.aliases.includes(e)&&(n==="move"?o.aliases=o.aliases.map(p=>p===e?i:p):n==="duplicate"&&o.aliases.find(p=>p===e)&&o.aliases.push(i));});let a=g._currentTickersSequence.get(i);if(a&&a.forEach((o,p)=>{this.runTickersSequence(i,p);}),n==="duplicate"){let o=g._currentTickersSequence.get(e);o&&o.forEach((p,d)=>{this.runTickersSequence(e,d);});}}completeTickerOnStepEnd(e){return this.completeTickerOnStepEndInternal(e)}completeTickerOnStepEndInternal(e){e.alias?g._tickersToCompleteOnStepEnd.stepAlias.push({id:e.id,alias:e.alias}):g._tickersToCompleteOnStepEnd.tikersIds.push({id:e.id});}async forceCompletionOfTicker(e,i){return this.forceCompletionOfTickerInternal(e,i)}async forceCompletionOfTickerInternal(e,i){if(i){let n=g._currentTickersSequence.get(i),r=n?.get(e);if(n&&r){let a=r.steps.map(o=>{if(typeof o=="object"&&"ticker"in o){let p=D.getInstance(o.ticker,o.args,{duration:o.duration,canvasElementAliases:[i],priority:o.priority});if(p)return p.complete()}return Promise.resolve()});await Promise.all(a);}}else {let n=g._currentTickers.get(e);n&&await n.ticker.complete();}}tickers={transfer:(e,i,n)=>this.transferTickersInternal(e,i,n),get currentTickers(){return g._currentTickers},get currentTickersSteps(){return g._currentTickersSequence},find:e=>this.findTickerInternal(e),add:(e,i)=>this.addTickerInternal(e,i),addSequence:(e,i,n)=>this.addTickersSequence(e,i,n),unlinkComponent:(e,i)=>this.unlinkComponentFromTickerInternal(e,i),removeAll:()=>this.removeAllTickersInternal(),remove:e=>this.removeTickerInternal(e),pause:e=>this.pauseTickerInternal(e),resume:e=>this.resumeTickerInternal(e),isPaused:(e,i)=>this.isTickerPausedInternal(e,i),completeOnStepEnd:e=>this.completeTickerOnStepEndInternal(e),forceCompletion:(e,i)=>this.forceCompletionOfTickerInternal(e,i),onComplete:(e,i)=>this.onTickerCompleteInternal(e,i)};animate(e,i,n,r){return GameUnifier.animate(e,i,n,r)}addLayerInternal(e,i){if(e===a$1){e$1.error(`The alias ${a$1} is reserved`);return}return i.label=e,g.app.stage.addChild(i)}getLayerInternal(e){return g.app.stage.getChildByLabel(e)}removeLayerInternal(e){let i=g.app.stage.getChildByLabel(e);i&&g.app.stage.removeChild(i);}addHtmlLayerInternal(e,i,n){return g.addHtmlLayer(e,i,n)}removeHtmlLayerInternal(e){return g.removeHtmlLayer(e)}getHtmlLayerInternal(e){return g.getHtmlLayer(e)}addLayer(e,i){return this.addLayerInternal(e,i)}getLayer(e){return this.getLayerInternal(e)}removeLayer(e){return this.removeLayerInternal(e)}addHtmlLayer(e,i,n){return this.addHtmlLayerInternal(e,i,n)}removeHtmlLayer(e){return this.removeHtmlLayerInternal(e)}getHtmlLayer(e){return this.getHtmlLayerInternal(e)}layers={get gameLayer(){return g.gameLayer},add:(e,i)=>this.addLayerInternal(e,i),get:e=>this.getLayerInternal(e),remove:e=>this.removeLayerInternal(e)};htmlLayers={add:(e,i,n)=>this.addHtmlLayerInternal(e,i,n),get:e=>this.getHtmlLayerInternal(e),remove:e=>this.removeHtmlLayerInternal(e)};async extractImage(){let e=this.gameLayer.renderable===false;e&&this.resume();let i;try{i=this.app.renderer.extract.image(this.app.stage);}finally{e&&this.pause();}return (await i).src}clear(){this.removeAllTickersInternal(),this.removeAll();}export(){let e=this.gameLayer.renderable===false;e&&this.resume();try{let i={};return this.children.forEach(n=>{n.label&&(i[n.label]=ye(n));}),{tickers:f$2(g.currentTickersWithoutCreatedBySteps),tickersSteps:f$2(g.currentTickersSequence),elements:f$2(i),stage:f$2(L(this.gameLayer)),elementAliasesOrder:f$2(g.childrenAliasesOrder),tickersToCompleteOnStepEnd:f$2(g._tickersToCompleteOnStepEnd)}}finally{e&&this.pause();}}async restore(e){this.clear();try{if(Object.hasOwn(e,"elements")&&Object.hasOwn(e,"elementAliasesOrder")){let i=e.elementAliasesOrder,n={},r=Object.entries(e.elements).map(async([a,o])=>{n[a]=await J(o);});await Promise.all(r),i.forEach(a=>{let o=n[a];o&&this.add(a,o);});}else {e$1.error("The data does not have the properties elementAliasesOrder and elements");return}if(Object.hasOwn(e,"stage")&&Object.hasOwn(e,"stage")?S(this.gameLayer,e.stage,{ignoreScale:!0}):e$1.error("The data does not have the properties stage"),Object.hasOwn(e,"tickers")){let i=e.tickers;Object.entries(i).forEach(([n,r])=>{let a=r.canvasElementAliases;if(a.length!==0){let o=D.getInstance(r.id,r.args,{duration:r.duration,priority:r.priority,id:n,canvasElementAliases:a});o?(o.canvasElementAliases=a,this.addTickerInternal(a,o),r.paused&&o.pause()):e$1.error(`Ticker ${r.id} not found`);}});}if(Object.hasOwn(e,"tickersSteps")){let i=e.tickersSteps;Object.entries(i).forEach(([n,r])=>{g._currentTickersSequence.set(n,new Map(Object.entries(r))),Object.keys(r).forEach(a=>{this.runTickersSequence(n,a);});});}if(Object.hasOwn(e,"tickersToCompleteOnStepEnd")){let i=e.tickersToCompleteOnStepEnd,n=i.tikersIds,r=i.stepAlias.map(a=>({id:a.id,alias:a.alias}));g._tickersToCompleteOnStepEnd.tikersIds.length=0,g._tickersToCompleteOnStepEnd.tikersIds.push(...n),g._tickersToCompleteOnStepEnd.stepAlias.length=0,g._tickersToCompleteOnStepEnd.stepAlias.push(...r);}}catch(i){e$1.error("Error importing data",i);}}};var I=class t{static init(e){t._getScreen=e.getScreen;}static _getScreen;static get screen(){return t._getScreen()}};var h;(d=>{function t(s,c,l,u,y,x=0){return y?s==="width"?c*(I.screen.width-l)+l-u-x*l:c*(I.screen.height-l)+l-u-x*l:s==="width"?c*(I.screen.width-l)+u+x*l:c*(I.screen.height-l)+u+x*l}d.calculatePositionByAlign=t;function e(s,c,l,u,y,x=0){return y?s==="width"?(c-l+u+x*l)/(I.screen.width-l):(c-l+u+x*l)/(I.screen.height-l):s==="width"?(c-u-x*l)/(I.screen.width-l):(c-u-x*l)/(I.screen.height-l)}d.calculateAlignByPosition=e;function i(s,c){return s==="width"?c*I.screen.width:c*I.screen.height}d.calculatePositionByPercentagePosition=i;function n(s,c){return s==="width"?c/I.screen.width:c/I.screen.height}d.calculatePercentagePositionByPosition=n;function r(s,c){if(c=c%360,c<0&&(c+=360),c===0)return {x:s.x,y:s.y};if(c===90)return {x:-s.y,y:s.x};if(c===180)return {x:-s.x,y:-s.y};if(c===270)return {x:s.y,y:-s.x};if(c>0&&c<90){let l=c*Math.PI/180,u=Math.cos(l),y=Math.sin(l),x=s.x*u-s.y*y,T=s.x*y+s.y*u;return s.x!==0&&Math.sign(x)!==Math.sign(s.x)&&(x=-x),s.y!==0&&Math.sign(T)!==Math.sign(s.y)&&(T=-T),{x,y:T}}else if(c>90&&c<180){let l=(c-90)*Math.PI/180,u=Math.cos(l),y=Math.sin(l),x=-s.y*y-s.x*u,T=s.y*u-s.x*y;return s.x!==0&&Math.sign(x)!==Math.sign(s.x)&&(x=-x),s.y!==0&&Math.sign(T)!==Math.sign(s.y)&&(T=-T),{x,y:T}}else if(c>180&&c<270){let l=(c-180)*Math.PI/180,u=Math.cos(l),y=Math.sin(l),x=-s.x*u+s.y*y,T=-s.x*y-s.y*u;return s.x!==0&&Math.sign(x)!==Math.sign(s.x)&&(x=-x),s.y!==0&&Math.sign(T)!==Math.sign(s.y)&&(T=-T),{x,y:T}}else if(c>270&&c<360){let l=(c-270)*Math.PI/180,u=Math.cos(l),y=Math.sin(l),x=s.y*y-s.x*u,T=-s.y*u-s.x*y;return s.x!==0&&Math.sign(x)!==Math.sign(s.x)&&(x=-x),s.y!==0&&Math.sign(T)!==Math.sign(s.y)&&(T=-T),{x,y:T}}return {x:0,y:0}}d.getSuperPoint=r;function a(s,c){if(c=c%360,c<0&&(c+=360),c===0)return {x:s.x,y:s.y};if(c===90)return {x:s.y,y:-s.x};if(c===180)return {x:-s.x,y:-s.y};if(c===270)return {x:-s.y,y:s.x};if(c>0&&c<90){let l=c*Math.PI/180,u=Math.cos(l),y=Math.sin(l);return {x:s.x*u+s.y*y,y:-s.x*y+s.y*u}}else if(c>90&&c<180){let l=(c-90)*Math.PI/180,u=Math.cos(l),y=Math.sin(l);return {x:s.y*u-s.x*y,y:-s.y*y-s.x*u}}else if(c>180&&c<270){let l=(c-180)*Math.PI/180,u=Math.cos(l),y=Math.sin(l);return {x:-s.x*u-s.y*y,y:s.x*y-s.y*u}}else if(c>270&&c<360){let l=(c-270)*Math.PI/180,u=Math.cos(l),y=Math.sin(l);return {x:-s.y*u+s.x*y,y:s.y*y+s.x*u}}return {x:0,y:0}}d.getPointBySuperPoint=a;function o(s){let c=s.width,l=s.height,u=s.angle%360;return u<0&&(u+=360),u===0||u===180?c:u===90||u===270?l:Math.abs(c*Math.cos(u*Math.PI/180))+Math.abs(l*Math.sin(u*Math.PI/180))}d.getSuperWidth=o;function p(s){let c=s.width,l=s.height,u=s.angle%360;return u<0&&(u+=360),u===0||u===180?l:u===90||u===270?c:Math.abs(l*Math.cos(u*Math.PI/180))+Math.abs(c*Math.sin(u*Math.PI/180))}d.getSuperHeight=p;})(h||={});async function N(t){if(t!=="EMPTY"){if(!t)throw e$1.error("Texture not found",t),new PixiError("unregistered_asset","Texture not found");if(B.Assets.cache.has(t)){let e=B.Assets.get(t);if(e)return e}return B.Assets.load(t).then(e=>{if(!e)throw e$1.error("Texture not found",t),new PixiError("unregistered_asset","Texture not found");if(!(e instanceof B.Texture))throw e$1.error("File is not a Texture",t),new PixiError("unregistered_asset","File is not a Texture");return e}).catch(e=>{throw e$1.error("Error loading file",e),new PixiError("unknown_element","Error loading file")})}}function A(t){return t&&(typeof t.align!="number"&&(t.xAlign!==void 0&&(t.align===void 0?(t.align={x:t.xAlign},delete t.xAlign):(t.align.x=t.xAlign,delete t.xAlign)),t.yAlign!==void 0&&(t.align===void 0?(t.align={y:t.yAlign},delete t.yAlign):(t.align.y=t.yAlign,delete t.yAlign))),typeof t.percentagePosition!="number"&&(t.percentageX!==void 0&&(t.percentagePosition===void 0?(t.percentagePosition={x:t.percentageX},delete t.percentageX):(t.percentagePosition.x=t.percentageX,delete t.percentageX)),t.percentageY!==void 0&&(t.percentagePosition===void 0?(t.percentagePosition={y:t.percentageY},delete t.percentageY):(t.percentagePosition.y=t.percentageY,delete t.percentageY))),t)}var H=class t extends B.Sprite{constructor(e$1){if(e$1 instanceof B.Texture)super(e$1);else {let{align:i,percentagePosition:n,...r}=A(e$1)||{};super(r),i&&(this.align=i),n&&(this.percentagePosition=n);}this.pixivnId=this.constructor.prototype.pixivnId||e;}pixivnId=e;get memory(){return {...xe(this),pixivnId:this.pixivnId,align:this._align,percentagePosition:this._percentagePosition}}async setMemory(e){return await ne(this,e)}static from(e,i){let n=B.Sprite.from(e,i),r=new t;return r.texture=n.texture,r}onEventsHandlers={};on(e,i,n){return O(e,this,i),super.on(e,(...r)=>i(...r,this),n)}_align=void 0;set align(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),typeof e=="number"?(this._align.x=e,this._align.y=e):(e.x!==void 0&&(this._align.x=e.x),e.y!==void 0&&(this._align.y=e.y)),this.reloadPosition();}get align(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return {x:h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x),y:h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y)}}set xAlign(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),this._align.x=e,this.reloadPosition();}get xAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x)}set yAlign(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),this._align.y=e,this.reloadPosition();}get yAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y)}_percentagePosition=void 0;set percentagePosition(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),typeof e=="number"?(this._percentagePosition.x=e,this._percentagePosition.y=e):(e.x!==void 0&&(this._percentagePosition.x=e.x),e.y!==void 0&&(this._percentagePosition.y=e.y)),this.reloadPosition();}get percentagePosition(){return {x:h.calculatePercentagePositionByPosition("width",this.x),y:h.calculatePercentagePositionByPosition("height",this.y)}}get percentageX(){return h.calculatePercentagePositionByPosition("width",this.x)}set percentageX(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.x=e,this.reloadPosition();}get percentageY(){return h.calculatePercentagePositionByPosition("height",this.y)}set percentageY(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.y=e,this.reloadPosition();}get positionType(){return this._align?"align":this._percentagePosition?"percentage":"pixel"}get positionInfo(){switch(this.positionType){case "align":return {x:this.xAlign,y:this.yAlign,type:"align"};case "percentage":return {x:this.percentageX,y:this.percentageY,type:"percentage"};default:return {x:this.x,y:this.y,type:"pixel"}}}set positionInfo(e){e.type==="align"?this.align={x:e.x,y:e.y}:e.type==="percentage"?this.percentagePosition={x:e.x,y:e.y}:this.position.set(e.x,e.y);}reloadPosition(){if(this._align){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);this._align.x!==void 0&&(super.x=h.calculatePositionByAlign("width",this._align.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x)),this._align.y!==void 0&&(super.y=h.calculatePositionByAlign("height",this._align.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y));}else this._percentagePosition&&(this._percentagePosition.x!==void 0&&(super.x=h.calculatePositionByPercentagePosition("width",this._percentagePosition.x)),this._percentagePosition.y!==void 0&&(super.y=h.calculatePositionByPercentagePosition("height",this._percentagePosition.y)));}get position(){return super.position}set position(e){this._align=void 0,this._percentagePosition=void 0,super.position=e;}get x(){return super.x}set x(e){this._align=void 0,this._percentagePosition=void 0,super.x=e;}get y(){return super.y}set y(e){this._align=void 0,this._percentagePosition=void 0,super.y=e;}};k.add(H,{name:e,copyProperty:async(t,e)=>{await ne(t,e,{ignoreTexture:true});}});async function ne(t,e,i){e=A(e);let n=i?.ignoreTexture||false;if(await S(t,e),!n){let a;if("textureData"in e&&e.textureData&&(a=e.textureData),a&&a.url!=="EMPTY"){let o=a.url;a.alias&&B.Assets.resolver.hasKey(a.alias)&&(o=a.alias);try{let p=await N(o);p&&(t.texture=p);}catch(p){e$1.error("Error in Sprite.setMemorySprite() while loading texture"),p=new PixiError("unregistered_asset",`Error loading image ${o}`,"canvas",e),GameUnifier.runOnError(p,{});}}}let r=i?.half;r&&await r(),"anchor"in e&&e.anchor!==void 0&&(typeof e.anchor=="number"?t.anchor.set(e.anchor,e.anchor):t.anchor.set(e.anchor.x,e.anchor.y)),"align"in e&&e.align!==void 0&&(t.align=e.align),"percentagePosition"in e&&e.percentagePosition!==void 0&&(t.percentagePosition=e.percentagePosition),"roundPixels"in e&&e.roundPixels!==void 0&&(t.roundPixels=e.roundPixels);}var v=class t extends H{_textureAlias;get textureAlias(){return this._textureAlias?this._textureAlias:this.texture.source.label}pixivnId=d$1;constructor(e,i){super(e),i&&(this._textureAlias=i);}get memory(){return {...super.memory,pixivnId:this.pixivnId,loadIsStarted:this._loadIsStarted}}async setMemory(e){let i;"textureData"in e&&e.textureData&&(i=e.textureData),"assetsData"in e&&Array.isArray(e.assetsData)&&e.assetsData.length>0&&(i=e.assetsData[0]),i&&i.alias&&(this._textureAlias=i.alias),await se(this,e),this.reloadPosition();}static from(e,i){let n=B.Sprite.from(e,i),r=new t;return r.texture=n.texture,r}_loadIsStarted=false;get loadIsStarted(){return this._loadIsStarted}async load(){return this._loadIsStarted=true,N(this.textureAlias).then(e=>{this._loadIsStarted=false,e&&(this.texture=e);}).catch(e=>{this._loadIsStarted=false,e$1.error("Error into ImageSprite.load()"),e=new PixiError("unregistered_asset",`Error loading image ${this.textureAlias}`,"canvas",{...this.memory,label:this.textureAlias},this),GameUnifier.runOnError(e,{});})}set texture(e){super.texture=e,this.reloadPosition();}get texture(){return super.texture}get haveEmptyTexture(){return this.texture._source.label==="EMPTY"}};k.add(v,{name:d$1,copyProperty:async(t,e)=>{await se(t,e,{ignoreTexture:true});}});async function se(t,e,i){return await ne(t,e,{half:async()=>{"loadIsStarted"in e&&e.loadIsStarted&&await t.load();},ignoreTexture:i?.ignoreTexture})}var M=class t extends v{constructor(e,i){if(e instanceof B.Texture){super(e,i);return}let{loop:n,paused:r,currentTime:a,...o}=e||{};super(o,i),n&&(this.loop=n),r&&(this.paused=r),a&&(this.currentTime=a);}pixivnId=g$1;get memory(){return {...super.memory,pixivnId:this.pixivnId,loop:this.loop,paused:this._paused,currentTime:this.currentTime}}async setMemory(e){await ze(this,e),this.reloadPosition();}static from(e,i){let n=B.Sprite.from(e,i),r=new t;return r.texture=n.texture,r}async load(){await super.load(),this.loop=this._looop,this.currentTime=this._currentTime,this.paused=this._paused;}_looop=false;get loop(){return this.texture?.source?.resource?.loop||false}set loop(e){this._looop=e,this.texture?.source?.resource&&(this.texture.source.resource.loop=e);}_paused=false;get paused(){return this.texture?.source?.resource?.paused||false}set paused(e){e?this.pause():this.play();}pause(){this._paused=true,this.texture?.source?.resource&&this.texture.source.resource.pause();}play(){this._paused=false,this.texture?.source?.resource?.play&&typeof this.texture.source.resource.play=="function"&&this.texture.source.resource.play();}_currentTime=0;get currentTime(){return this.texture?.source?.resource?.currentTime||0}set currentTime(e){let i=this.duration;i&&e>=i&&(e=0),this._currentTime=e,this.texture?.source?.resource&&(this.texture.source.resource.currentTime=e);}restart(){this.currentTime=0;}get duration(){if(this.texture?.source?.resource)return this.texture.source.resource.duration||0}};k.add(M,{name:g$1,getInstance:async(t,e)=>{let i;"textureData"in e&&e.textureData&&(i=e.textureData);let n=new t(void 0,i?.alias);return await n.setMemory(e),n},copyProperty:async(t,e)=>{await ze(t,e,{ignoreTexture:true});}});async function ze(t,e,i){await se(t,e,{ignoreTexture:i?.ignoreTexture}),"loop"in e&&e.loop!==void 0&&(t.loop=e.loop),"currentTime"in e&&e.currentTime!==void 0&&(t.currentTime=e.currentTime),"paused"in e&&e.paused!==void 0&&(t.paused=e.paused);}var _=class extends Container{constructor(e){let{anchor:i,align:n,percentagePosition:r,...a}=A(e)||{};super(a),this.pixivnId=this.constructor.prototype.pixivnId||b,i&&(this.anchor=i),n&&(this.align=n),r&&(this.percentagePosition=r);}pixivnId=b;get memory(){return {...L(this,{childrenExport:true}),anchor:this._anchor?this.anchor:void 0,align:this._align,percentagePosition:this._percentagePosition}}async setMemory(e){await this.importChildren(e),await S(this,e),this.reloadAnchor(),this.reloadPosition();}async importChildren(e){for(let i=0;i<e.elements.length;i++){let n=e.elements[i],r=await J(n);this.addChild(r);}}onEventsHandlers={};on(e,i,n){return O(e,this,i),super.on(e,(...r)=>i(...r,this),n)}_anchor;get anchor(){let e=super.pivot.x/this.width,i=super.pivot.y/this.height;return {x:e,y:i}}set anchor(e){typeof e=="number"?this._anchor={x:e,y:e}:this._anchor=e,this.reloadAnchor();}reloadAnchor(){this._anchor&&super.pivot.set(this._anchor.x*this.width,this._anchor.y*this.height);}get pivot(){return super.pivot}set pivot(e){this._anchor=void 0,super.pivot=e;}_align=void 0;set align(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),typeof e=="number"?(this._align.x=e,this._align.y=e):(e.x!==void 0&&(this._align.x=e.x),e.y!==void 0&&(this._align.y=e.y)),this.reloadPosition();}get align(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return {x:h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0),y:h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0)}}set xAlign(e){this._percentagePosition&&(this._percentagePosition=void 0),this._align===void 0&&(this._align={}),this._align.x=e,this.reloadPosition();}get xAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0)}set yAlign(e){this._percentagePosition&&(this._percentagePosition=void 0),this._align===void 0&&(this._align={}),this._align.y=e,this.reloadPosition();}get yAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0)}_percentagePosition=void 0;set percentagePosition(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),typeof e=="number"?(this._percentagePosition.x=e,this._percentagePosition.y=e):(e.x!==void 0&&(this._percentagePosition.x=e.x),e.y!==void 0&&(this._percentagePosition.y=e.y)),this.reloadPosition();}get percentagePosition(){return {x:h.calculatePercentagePositionByPosition("width",this.x),y:h.calculatePercentagePositionByPosition("height",this.y)}}set percentageX(e){this._align&&(this._align=void 0),this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.x=e,this.reloadPosition();}get percentageX(){return h.calculatePercentagePositionByPosition("width",this.x)}set percentageY(e){this._align&&(this._align=void 0),this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.y=e,this.reloadPosition();}get percentageY(){return h.calculatePercentagePositionByPosition("height",this.y)}get positionType(){return this._align?"align":this._percentagePosition?"percentage":"pixel"}get positionInfo(){switch(this.positionType){case "align":return {x:this.xAlign,y:this.yAlign,type:"align"};case "percentage":return {x:this.percentageX,y:this.percentageY,type:"percentage"};default:return {x:this.x,y:this.y,type:"pixel"}}}set positionInfo(e){e.type==="align"?this.align={x:e.x,y:e.y}:e.type==="percentage"?this.percentagePosition={x:e.x,y:e.y}:this.position.set(e.x,e.y);}reloadPosition(){if(this._align){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);this._align.x!==void 0&&(super.x=h.calculatePositionByAlign("width",this._align.x,h.getSuperWidth(this),e.x,i.x<0)),this._align.y!==void 0&&(super.y=h.calculatePositionByAlign("height",this._align.y,h.getSuperHeight(this),e.y,i.y<0));}else this._percentagePosition&&(this._percentagePosition.x!==void 0&&(super.x=h.calculatePositionByPercentagePosition("width",this._percentagePosition.x)),this._percentagePosition.y!==void 0&&(super.y=h.calculatePositionByPercentagePosition("height",this._percentagePosition.y)));}get position(){return super.position}set position(e){this._align=void 0,this._percentagePosition=void 0,super.position=e;}get x(){return super.x}set x(e){this._align=void 0,this._percentagePosition=void 0,super.x=e;}get y(){return super.y}set y(e){this._align=void 0,this._percentagePosition=void 0,super.y=e;}};k.add(_,{name:b,copyProperty:async(t,e)=>await S(t,e)});var yt=new Set(["mp4","webm","ogg","ogv","avi","mov","wmv","flv","mkv","m4v","3gp","3g2","ts","mts"]);function U(t){let e=B.Assets.cache.has(t)?B.Assets.get(t):null;return e instanceof B.Texture&&(t=e.source?.label||t),xt(t)}function xt(t){let e=t.split(".").pop()?.toLowerCase();return e!==void 0&&yt.has(e)}var P=class extends _{constructor(e,i){let{anchor:n,align:r,percentagePosition:a,...o}=A(e)||{};super(o),i&&i.forEach(p=>{U(p)?this.addChild(new M(void 0,p)):this.addChild(new v(void 0,p));}),n&&(this.anchor=n),r&&(this.align=r),a&&(this.percentagePosition=a);}get memory(){return {...super.memory,pixivnId:c$1,loadIsStarted:this._loadIsStarted}}async setMemory(e){await this.importChildren(e),await Ve(this,e),this.reloadAnchor(),this.reloadPosition();}pixivnId=c$1;_loadIsStarted=false;get loadIsStarted(){return this._loadIsStarted}async load(){this._loadIsStarted=true;let e=this.children.map(i=>i.load());return Promise.all(e).then(()=>{this._loadIsStarted=false,this.reloadAnchor(),this.reloadPosition();}).catch(i=>{this._loadIsStarted=false,e$1.error("Error into ImageContainer.load()",i);})}get texture(){return this.children.length>0?this.children[0].texture:new B.Texture}get haveEmptyTexture(){return this.children.some(e=>e.texture._source.label==="EMPTY")}};k.add(P,{name:c$1,copyProperty:async(t,e)=>await Ve(t,e)});async function Ve(t,e){e=A(e)||{},S(t,e,{end:async()=>{"loadIsStarted"in e&&e.loadIsStarted&&await t.load();}});}var ae=class{constructor(...e){}get memory(){throw new PixiError("not_implemented","The method CanvasBaseItem.memory must be overridden")}setMemory(e){throw new PixiError("not_implemented","The method CanvasBaseItem.setMemory must be overridden")}pixivnId="canvas_element_id_not_set"};var z=class extends B.Text{constructor(e){let{align:i,percentagePosition:n,...r}=A(e)||{};super(r),this.pixivnId=this.constructor.prototype.pixivnId||f$1,i&&(this.align=i),n&&(this.percentagePosition=n);}pixivnId=f$1;get memory(){return {...Te(this),pixivnId:this.pixivnId,align:this._align,percentagePosition:this._percentagePosition}}async setMemory(e){await Pt(this,e),this.reloadPosition();}onEventsHandlers={};on(e,i,n){return O(e,this,i),super.on(e,(...r)=>i(...r,this),n)}_align=void 0;set align(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),typeof e=="number"?(this._align.x=e,this._align.y=e):(e.x!==void 0&&(this._align.x=e.x),e.y!==void 0&&(this._align.y=e.y)),this.reloadPosition();}get align(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return {x:h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x),y:h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y)}}set xAlign(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),this._align.x=e,this.reloadPosition();}get xAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("width",this.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x)}set yAlign(e){this._percentagePosition=void 0,this._align===void 0&&(this._align={}),this._align.y=e,this.reloadPosition();}get yAlign(){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);return h.calculateAlignByPosition("height",this.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y)}_percentagePosition=void 0;set percentagePosition(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),typeof e=="number"?(this._percentagePosition.x=e,this._percentagePosition.y=e):(e.x!==void 0&&(this._percentagePosition.x=e.x),e.y!==void 0&&(this._percentagePosition.y=e.y)),this.reloadPosition();}get percentagePosition(){return {x:h.calculatePercentagePositionByPosition("width",this.x),y:h.calculatePercentagePositionByPosition("height",this.y)}}get percentageX(){return h.calculatePercentagePositionByPosition("width",this.x)}set percentageX(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.x=e,this.reloadPosition();}get percentageY(){return h.calculatePercentagePositionByPosition("height",this.y)}set percentageY(e){this._align=void 0,this._percentagePosition===void 0&&(this._percentagePosition={}),this._percentagePosition.y=e,this.reloadPosition();}get positionType(){return this._align?"align":this._percentagePosition?"percentage":"pixel"}get positionInfo(){switch(this.positionType){case "align":return {x:this.xAlign,y:this.yAlign,type:"align"};case "percentage":return {x:this.percentageX,y:this.percentageY,type:"percentage"};default:return {x:this.x,y:this.y,type:"pixel"}}}set positionInfo(e){e.type==="align"?this.align={x:e.x,y:e.y}:e.type==="percentage"?this.percentagePosition={x:e.x,y:e.y}:this.position.set(e.x,e.y);}reloadPosition(){if(this._align){let e=h.getSuperPoint(this.pivot,this.angle),i=h.getSuperPoint(this.scale,this.angle);this._align.x!==void 0&&(super.x=h.calculatePositionByAlign("width",this._align.x,h.getSuperWidth(this),e.x,i.x<0,this.anchor.x)),this._align.y!==void 0&&(super.y=h.calculatePositionByAlign("height",this._align.y,h.getSuperHeight(this),e.y,i.y<0,this.anchor.y));}else this._percentagePosition&&(this._percentagePosition.x!==void 0&&(super.x=h.calculatePositionByPercentagePosition("width",this._percentagePosition.x)),this._percentagePosition.y!==void 0&&(super.y=h.calculatePositionByPercentagePosition("height",this._percentagePosition.y)));}get position(){return super.position}set position(e){this._align=void 0,this._percentagePosition=void 0,super.position=e;}get x(){return super.x}set x(e){this._align=void 0,this._percentagePosition=void 0,super.x=e;}get y(){return super.y}set y(e){this._align=void 0,this._percentagePosition=void 0,super.y=e;}};k.add(z,{name:f$1});async function Pt(t,e){"text"in e&&e.text!==void 0&&(t.text=e.text),await S(t,e,{end:()=>{"style"in e&&e.style!==void 0&&(t.style=e.style);}}),"anchor"in e&&e.anchor!==void 0&&(typeof e.anchor=="number"?t.anchor.set(e.anchor,e.anchor):t.anchor.set(e.anchor.x,e.anchor.y)),"resolution"in e&&e.resolution!==void 0&&(t.resolution=e.resolution),"anchor"in e&&e.anchor!==void 0&&(typeof e.anchor=="number"?t.anchor.set(e.anchor,e.anchor):t.anchor.set(e.anchor.x,e.anchor.y)),"align"in e&&e.align!==void 0&&(t.align=e.align),"percentagePosition"in e&&e.percentagePosition!==void 0&&(t.percentagePosition=e.percentagePosition),"roundPixels"in e&&e.roundPixels!==void 0&&(t.roundPixels=e.roundPixels);}async function It(t,e={},i){let n=f.find(t);if(!n){e$1.error(`The element with the alias ${t} does not exist. So the shake effect can't be applied.`);return}let r={x:n.position.x,y:n.position.y},{shakeType:a="horizontal",maxShockSize:o=10,shocksNumber:p=10,...d}=e,s=p-1;if(s<2){e$1.error("The number of shocks must be at least 3.");return}let c=Math.floor(s/2),l=Math.ceil(s/2),u=[];for(let T=0;T<c;T++){let C=o*(T+1)/c;a==="horizontal"?T%2!==0?u.push(r.x+C):u.push(r.x-C):T%2!==0?u.push(r.y+C):u.push(r.y-C);}let y=c%2===0;for(let T=l;T>0;T--){let C=o*(T+1)/(l-1);a==="horizontal"?T%2===0&&!y||T%2!==0&&y?u.push(r.x-C):u.push(r.x+C):T%2===0&&!y||T%2!==0&&y?u.push(r.y-C):u.push(r.y+C);}let x;if(a==="horizontal"?(u.push(r.x),x=f.animate(t,{x:u},d,i)):(u.push(r.y),x=f.animate(t,{y:u},d,i)),x)return [x]}function oe(t,e,i){let n={...f.find(t)?.memory,...i},r=new P(i,e);return n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}async function kt(t,e,i){let n={...f.find(t)?.memory,...i},r=new P(i,e);return r.label=t,await r.load(),n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}function ce(t,e,i){if(!e)if(B.Assets.resolver.hasKey(t))e=t;else throw new PixiError("unregistered_asset",`The image ${t} does not exist in the cache.`,"canvas",{pixivnId:d$1,...i,label:t});let n={...f.find(t)?.memory,...i},r=new v(i,e);return n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}async function Ct(t,e,i){if(!e)if(B.Assets.resolver.hasKey(t))e=t;else throw new PixiError("unregistered_asset",`The image ${t} does not exist in the cache.`,"canvas",{pixivnId:d$1,...i,label:t});let n={...f.find(t)?.memory,...i},r=new v(i,e);return r.label=t,await r.load(),n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}function de(t,e,i){if(!e)if(B.Assets.resolver.hasKey(t))e=t;else throw new PixiError("unregistered_asset",`The video ${t} does not exist in the cache.`,"canvas",{pixivnId:g$1,...i,label:t});let n={...f.find(t)?.memory,...i},r=new M(i,e);return n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}async function St(t,e,i){if(!e)if(B.Assets.resolver.hasKey(t))e=t;else throw new PixiError("unregistered_asset",`The video ${t} does not exist in the cache.`,"canvas",{pixivnId:g$1,...i,label:t});let n={...f.find(t)?.memory,...i},r=new M(i,e);return r.label=t,await r.load(),n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}function Ie(t){switch(t.type){case "align":return {xAlign:t.x,yAlign:t.y};case "percentage":return {percentageX:t.x,percentageY:t.y};default:return {x:t.x,y:t.y}}}function F(t,e,i){if(typeof e=="string")return U(e)?de(t,e,i):ce(t,e,i);if(Array.isArray(e))return oe(t,e,i);if(typeof e=="object"&&"value"in e&&"options"in e){if(typeof e.value=="string")return U(e.value)?de(t,e.value,{...e.options,zIndex:i.zIndex}):ce(t,e.value,{...e.options,zIndex:i.zIndex});if(Array.isArray(e.value))return oe(t,e.value,{...e.options,zIndex:i.zIndex})}return f.add(t,e,i),e}async function qe(t,e,i={},n){let{completeOnContinue:r=true,tickerIdToResume:a=[],...o}=i,p=[];e||(e=t),typeof a=="string"&&(a=[a]);let d,s=f.find(t);if(s&&(d=`${t}_temp_disolve`,f.editAlias(t,d)),e=F(t,e,{zIndex:s?s.parent?.getChildIndex(s):void 0}),s?.parent?.setChildIndex(s,s.parent.getChildIndex(s)-.1),d&&f.copyCanvasElementProperty(d,t),d&&f.tickers.transfer(d,t,"duplicate"),e.alpha=0,d){let l=pe(d,{...i,autoplay:false,completeOnContinue:r},n);l&&(p.push(...l),a.push(...l));}let c=f.animate(t,{alpha:1},{...o,tickerIdToResume:a,completeOnContinue:r},n);if(c&&p.push(c),(e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),p.length>0)return p}function pe(t,e={},i){let{completeOnContinue:n=true,aliasToRemoveAfter:r=[],...a}=e;typeof r=="string"&&(r=[r]),r.push(t);let o=f.animate(t,{alpha:0},{...a,aliasToRemoveAfter:r,completeOnContinue:n},i);if(o)return [o]}async function bt(t,e,i={},n){let{completeOnContinue:r=true,aliasToRemoveAfter:a=[],...o}=i,p=[];e||(e=t),typeof a=="string"&&(a=[a]);let d=f.find(t);if(!d)return qe(t,e,i,n);let s=`${t}_temp_fade`;f.editAlias(t,s),a.push(s),e=F(t,e,{zIndex:d?d.parent?.getChildIndex(d):void 0}),d?.parent?.setChildIndex(d,d.parent.getChildIndex(d)-.1),s&&f.copyCanvasElementProperty(s,t),s&&f.tickers.transfer(s,t,"duplicate"),e.alpha=0;let c=f.animate(t,{alpha:1},{...o,aliasToRemoveAfter:a,completeOnContinue:r},n);if(c){let l=pe(s,{...i,tickerIdToResume:c,completeOnContinue:r},n);l&&p.push(...l),p.push(c),f.tickers.pause({id:c});}if((e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),p.length>0)return p}function At(t,e={},i){return pe(t,e,i)}async function Et(t,e,i={},n){let{direction:r="right",completeOnContinue:a=true,tickerIdToResume:o=[],aliasToRemoveAfter:p=[],removeOldComponentWithMoveOut:d,...s}=i,c=[],l;e||(e=t),typeof o=="string"&&(o=[o]),typeof p=="string"&&(p=[p]);let u,y=f.find(t);if(y&&(u=`${t}_temp_movein`,f.editAlias(t,u),y instanceof v||y instanceof P?l=y.positionInfo:l={x:y.x,y:y.y,type:"pixel"}),e=F(t,e,{zIndex:y?y.parent?.getChildIndex(y):void 0}),y?.parent?.setChildIndex(y,y.parent.getChildIndex(y)-.1),u&&f.copyCanvasElementProperty(u,t),u&&f.tickers.transfer(u,t,"move"),l||(e instanceof v||e instanceof P?l=e.positionInfo:l={x:e.x,y:e.y,type:"pixel"}),u)if(d){let C=ke(u,{...i,autoplay:false,completeOnContinue:a},n);C&&(c.push(...C),o.push(...C));}else p.push(u);switch((e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),r){case "up":e.y=f.height+e.height;break;case "down":e.y=-e.height;break;case "left":e.x=f.width+e.width;break;case "right":e.x=-e.width;break}let x=f.tickers.pause({canvasAlias:t});o.push(...x);let T=f.animate(t,Ie(l),{...s,tickerIdToResume:o,aliasToRemoveAfter:p,completeOnContinue:a},n);if(T&&c.push(T),c.length>0)return c}function ke(t,e={},i){let{direction:n="right",completeOnContinue:r=true,aliasToRemoveAfter:a=[],...o}=e;typeof a=="string"&&(a=[a]),a.push(t);let p=f.find(t);if(!p){e$1.warn(`The canvas component "${t}" is not found.`);return}let d={x:p.x,y:p.y};switch(n){case "up":d.y=-p.height;break;case "down":d.y=f.height+p.height;break;case "left":d.x=-p.width;break;case "right":d.x=f.width+p.width;break}f.tickers.pause({canvasAlias:t});let s=f.animate(t,d,{...o,aliasToRemoveAfter:a,completeOnContinue:r},i);if(s)return [s]}async function Mt(t,e,i={},n){let{direction:r="right",completeOnContinue:a=true,tickerIdToResume:o=[],aliasToRemoveAfter:p=[],...d}=i,s=[],c;e||(e=t),typeof o=="string"&&(o=[o]),typeof p=="string"&&(p=[p]);let l,u=f.find(t);u&&(l=`${t}_temp_zoom`,f.editAlias(t,l),u instanceof v||u instanceof P?c=u.positionInfo:c={x:u.x,y:u.y,type:"pixel"}),e=F(t,e,{zIndex:u?u.parent?.getChildIndex(u):void 0}),u?.parent?.setChildIndex(u,u.parent.getChildIndex(u)-.1),l&&f.copyCanvasElementProperty(l,t),l&&f.tickers.transfer(l,t,"move"),c||(e instanceof v||e instanceof P?c=e.positionInfo:c={x:e.x,y:e.y,type:"pixel"});let y={x:e.pivot.x,y:e.pivot.y},x={x:e.scale.x,y:e.scale.y};if(l)if(i.removeOldComponentWithZoomOut){let le=Ge(l,{...i,autoplay:false,completeOnContinue:a},n);le&&(s.push(...le),o.push(...le));}else p.push(l);(e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),r==="up"?(e.pivot.y=f.height-e.y,e.pivot.x=f.width/2-e.x,e.y=f.height,e.x=f.width/2):r==="down"?(e.pivot.y=0-e.y,e.pivot.x=f.width/2-e.x,e.y=0,e.x=f.width/2):r==="left"?(e.pivot.x=f.width-e.x,e.pivot.y=f.height/2-e.y,e.x=f.width,e.y=f.height/2):r==="right"&&(e.pivot.x=0-e.x,e.pivot.y=f.height/2-e.y,e.x=0,e.y=f.height/2),e.pivot=h.getPointBySuperPoint(e.pivot,e.angle),e.scale.set(0);let T=f.tickers.pause({canvasAlias:t});o.push(...T);let C=f.animate(t,{...Ie(c),pivotX:y.x,pivotY:y.y,scaleX:x.x,scaleY:x.y},{...d,tickerIdToResume:o,aliasToRemoveAfter:p,completeOnContinue:a},n);if(C&&s.push(C),s.length>0)return s}function Ge(t,e={},i){let{direction:n="right",completeOnContinue:r=true,aliasToRemoveAfter:a=[],...o}=e;typeof a=="string"&&(a=[a]),a.push(t);let p=f.find(t);if(!p){e$1.warn(`The canvas component "${t}" is not found.`);return}let d={x:p.x,y:p.y},s={x:p.pivot.x,y:p.pivot.y};n==="down"?(d.y=f.height,d.x=f.width/2,s.y=f.height-d.y,s.x=f.width/2-d.x):n==="up"?(d.y=0,d.x=f.width/2,s.y=0-d.y,s.x=f.width/2-d.x):n==="right"?(d.x=f.width,d.y=f.height/2,s.x=f.width-d.x,s.y=f.height/2-d.y):n==="left"&&(d.x=0,d.y=f.height/2,s.x=0-d.x,s.y=f.height/2-d.y),s=h.getPointBySuperPoint(s,p.angle),f.tickers.pause({canvasAlias:t});let c=f.animate(t,{...d,pivotX:s.x,pivotY:s.y,scaleX:0,scaleY:0},{...o,aliasToRemoveAfter:a,completeOnContinue:r},i);if(c)return [c]}async function _t(t,e,i={},n){let{direction:r="right",completeOnContinue:a=true,tickerIdToResume:o=[],...p}=i,d=[],s;e||(e=t),typeof o=="string"&&(o=[o]);let c,l=f.find(t);switch(l&&(c=`${t}_temp_push`,f.editAlias(t,c),l instanceof v||l instanceof P?s=l.positionInfo:s={x:l.x,y:l.y,type:"pixel"}),e=F(t,e,{zIndex:l?l.parent?.getChildIndex(l):void 0}),l?.parent?.setChildIndex(l,l.parent.getChildIndex(l)-.1),c&&f.copyCanvasElementProperty(c,t),c&&f.tickers.transfer(c,t,"move"),s||((e instanceof v||e instanceof P)&&e.haveEmptyTexture?s=e.positionInfo:s={x:e.x,y:e.y,type:"pixel"}),(e instanceof v||e instanceof P)&&e.haveEmptyTexture&&await e.load(),r){case "up":e.y=f.height+e.height;break;case "down":e.y=-e.height;break;case "left":e.x=f.width+e.width;break;case "right":e.x=-e.width;break}let u=f.tickers.pause({canvasAlias:t});if(o.push(...u),c){let x=Ne(c,{...i,direction:r,completeOnContinue:a});x&&d.push(...x);}let y=f.animate(t,Ie(s),{...p,tickerIdToResume:o,completeOnContinue:a},n);if(y&&d.push(y),d.length>0)return d}function Ne(t,e={direction:"right"},i){return ke(t,e,i)}var K=class extends _{constructor(i){super(i);this._memory=i;this.pixivnId=i.pixivnId;}_memory;pixivnId;get memory(){return {...this._memory,...super.memory,elements:[],pixivnId:this.pixivnId}}};function wt(){return async(e,i)=>{try{let n=e.canvasElementInfo;if(n){let r=new K(n),a=n.zIndex;r.groupColor=16711680;let o=new B.Graphics;o.rect(0,0,300,100).fill({color:16711680,alpha:.5}),r.addChild(o);let p=new B.Text({text:`Error: ${n.label}`,x:10,y:10});r.addChild(p);let d=e.parent;if(d&&"addChild"in d)a!==void 0?d.addChildAt(r,a):d.addChild(r);else {let s=n.parentLabel?f.find(n.parentLabel):void 0;if(s)a!==void 0?s.addChildAt(r,a):s.addChild(r);else {let c=n.label??n.pixivnId;f.add(c,r,{zIndex:a});}}}}catch{}}}function Ot(t,e,i){let n={...f.find(t)?.memory,...i},r=new z({text:e,...i});return n&&f.copyCanvasElementProperty(n,r),f.add(t,r,{ignoreOldStyle:true,zIndex:i?.zIndex}),r}var {Assets:Mn,Color:_n,Rectangle:wn,TextStyle:On,Texture:Bn,UPDATE_PRIORITY:Ln}=B,f=new G;I.init({getScreen:()=>f.screen});GameUnifier.addOnPreContinue(async()=>{try{let t=g._tickersToCompleteOnStepEnd.tikersIds,e=g._tickersToCompleteOnStepEnd.stepAlias,i=(async()=>{for(;t.length;){let{id:r}=t.pop()||{};r&&await f.tickers.forceCompletion(r);}})(),n=(async()=>{for(;e.length;){let{alias:r,id:a}=e.pop()||{};r&&a&&await f.tickers.forceCompletion(a,r);}})();await Promise.all([i,n]),g._tickersToCompleteOnStepEnd.tikersIds.length=0,g._tickersToCompleteOnStepEnd.stepAlias.length=0;}catch{}});
2
2
  export{Mn as Assets,ae as CanvasBaseItem,g as CanvasManagerStatic,h as CanvasPropertyUtility,_n as Color,_ as Container,P as ImageContainer,v as ImageSprite,wn as Rectangle,k as RegisteredCanvasComponents,ge as RegisteredEvents,D as RegisteredTickers,H as Sprite,z as Text,On as TextStyle,Bn as Texture,ee as TickerBase,Ln as UPDATE_PRIORITY,M as VideoSprite,ce as addImage,oe as addImageCointainer,O as addListenerHandler,de as addVideo,A as analizePositionsExtensionProps,f as canvas,Je as canvasComponentDecorator,wt as drawCanvasErrorHandler,Ze as eventDecorator,N as getTexture,Et as moveIn,ke as moveOut,_t as pushIn,Ne as pushOut,pe as removeWithDissolve,At as removeWithFade,S as setMemoryContainer,It as shakeEffect,Ct as showImage,kt as showImageContainer,Ot as showText,St as showVideo,qe as showWithDissolve,bt as showWithFade,ct as tickerDecorator,Mt as zoomIn,Ge as zoomOut};
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var M=require('@drincs/pixi-vn/canvas'),qt=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),st=require('@drincs/pixi-vn/history'),O=require('@drincs/pixi-vn/narration'),ut=require('@drincs/pixi-vn/sound'),z=require('@drincs/pixi-vn/storage'),motion=require('@drincs/pixi-vn/motion');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var M__namespace=/*#__PURE__*/_interopNamespace(M);var qt__namespace=/*#__PURE__*/_interopNamespace(qt);var st__namespace=/*#__PURE__*/_interopNamespace(st);var O__namespace=/*#__PURE__*/_interopNamespace(O);var ut__namespace=/*#__PURE__*/_interopNamespace(ut);var z__namespace=/*#__PURE__*/_interopNamespace(z);var $t=Object.defineProperty;var Bt=l=>{throw TypeError(l)};var de=(l,e,i)=>e in l?$t(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var pe=(l,e)=>{for(var i in e)$t(l,i,{get:e[i],enumerable:true});};var N=(l,e,i)=>de(l,typeof e!="symbol"?e+"":e,i),jt=(l,e,i)=>e.has(l)||Bt("Cannot "+i);var t=(l,e,i)=>(jt(l,e,"read from private field"),i?i.call(l):e.get(l)),_=(l,e,i)=>e.has(l)?Bt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),u=(l,e,i,s)=>(jt(l,e,"write to private field"),e.set(l,i),i),c=(l,e,i)=>(jt(l,e,"access private method"),i);var Rt=(l,e,i,s)=>({set _(r){u(l,e,r);},get _(){return t(l,e,s)}});var ue=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zt=new Set,Pt=typeof process=="object"&&process?process:{},te=(l,e,i,s)=>{typeof Pt.emitWarning=="function"?Pt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Nt=globalThis.AbortController,Xt=globalThis.AbortSignal;if(typeof Nt>"u"){Xt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Nt=class{constructor(){e();}signal=new Xt;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 l=Pt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,te("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var fe=l=>!Zt.has(l);var lt=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),ee=l=>lt(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?Lt:null:null,Lt=class extends Array{constructor(l){super(l),this.fill(0);}},rt,vt,me=(rt=class{heap;length;static create(e){let i=ee(e);if(!i)return [];u(rt,vt,true);let s=new rt(e,i);return u(rt,vt,false),s}constructor(e,i){if(!t(rt,vt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},vt=new WeakMap,_(rt,vt,false),rt),Jt,Qt,q,V,B,ft,X,St,yt,J,R,Q,U,x,m,j,W,F,D,Z,C,tt,et,Y,H,it,pt,P,bt,a,Mt,mt,nt,Tt,K,se,gt,xt,Ut,ht,ct,zt,Dt,Ct,b,Gt,At,dt,Vt,Et,ie=(Et=class{constructor(e){_(this,a);_(this,q);_(this,V);_(this,B);_(this,ft);_(this,X);_(this,St);_(this,yt);_(this,J);N(this,"ttl");N(this,"ttlResolution");N(this,"ttlAutopurge");N(this,"updateAgeOnGet");N(this,"updateAgeOnHas");N(this,"allowStale");N(this,"noDisposeOnSet");N(this,"noUpdateTTL");N(this,"maxEntrySize");N(this,"sizeCalculation");N(this,"noDeleteOnFetchRejection");N(this,"noDeleteOnStaleGet");N(this,"allowStaleOnFetchAbort");N(this,"allowStaleOnFetchRejection");N(this,"ignoreFetchAbort");_(this,R);_(this,Q);_(this,U);_(this,x);_(this,m);_(this,j);_(this,W);_(this,F);_(this,D);_(this,Z);_(this,C);_(this,tt);_(this,et);_(this,Y);_(this,H);_(this,it);_(this,pt);_(this,P);_(this,bt);_(this,mt,()=>{});_(this,nt,()=>{});_(this,Tt,()=>{});_(this,K,()=>false);_(this,gt,e=>{});_(this,xt,(e,i,s)=>{});_(this,Ut,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});N(this,Jt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:d,dispose:v,onInsert:L,disposeAfter:S,noDisposeOnSet:ot,noUpdateTTL:G,maxSize:$=0,maxEntrySize:E=0,sizeCalculation:y,fetchMethod:g,memoMethod:f,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:A,ignoreFetchAbort:I,perf:k}=e;if(k!==void 0&&typeof k?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,J,k??ue),i!==0&&!lt(i))throw new TypeError("max option must be a nonnegative integer");let _t=i?ee(i):Array;if(!_t)throw new Error("invalid max value: "+i);if(u(this,q,i),u(this,V,$),this.maxEntrySize=E||t(this,V),this.sizeCalculation=y,this.sizeCalculation){if(!t(this,V)&&!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(f!==void 0&&typeof f!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,yt,f),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,St,g),u(this,pt,!!g),u(this,U,new Map),u(this,x,new Array(i).fill(void 0)),u(this,m,new Array(i).fill(void 0)),u(this,j,new _t(i)),u(this,W,new _t(i)),u(this,F,0),u(this,D,0),u(this,Z,me.create(i)),u(this,R,0),u(this,Q,0),typeof v=="function"&&u(this,B,v),typeof L=="function"&&u(this,ft,L),typeof S=="function"?(u(this,X,S),u(this,C,[])):(u(this,X,void 0),u(this,C,void 0)),u(this,it,!!t(this,B)),u(this,bt,!!t(this,ft)),u(this,P,!!t(this,X)),this.noDisposeOnSet=!!ot,this.noUpdateTTL=!!G,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!p,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!I,this.maxEntrySize!==0){if(t(this,V)!==0&&!lt(t(this,V)))throw new TypeError("maxSize must be a positive integer if specified");if(!lt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,se).call(this);}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=lt(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!lt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,Mt).call(this);}if(t(this,q)===0&&this.ttl===0&&t(this,V)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,q)&&!t(this,V)){let Ft="LRU_CACHE_UNBOUNDED";fe(Ft)&&(Zt.add(Ft),te("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ft,Et));}}get perf(){return t(this,J)}static unsafeExposeInternals(e){return {starts:t(e,et),ttls:t(e,Y),autopurgeTimers:t(e,H),sizes:t(e,tt),keyMap:t(e,U),keyList:t(e,x),valList:t(e,m),next:t(e,j),prev:t(e,W),get head(){return t(e,F)},get tail(){return t(e,D)},free:t(e,Z),isBackgroundFetch:i=>{var s;return c(s=e,a,b).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return c(o=e,a,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return c(s=e,a,At).call(s,i)},indexes:i=>{var s;return c(s=e,a,ht).call(s,i)},rindexes:i=>{var s;return c(s=e,a,ct).call(s,i)},isStale:i=>{var s;return t(s=e,K).call(s,i)}}}get max(){return t(this,q)}get maxSize(){return t(this,V)}get calculatedSize(){return t(this,Q)}get size(){return t(this,R)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,yt)}get dispose(){return t(this,B)}get onInsert(){return t(this,ft)}get disposeAfter(){return t(this,X)}getRemainingTTL(e){return t(this,U).has(e)?1/0:0}*entries(){for(let e of c(this,a,ht).call(this))t(this,m)[e]!==void 0&&t(this,x)[e]!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield [t(this,x)[e],t(this,m)[e]]);}*rentries(){for(let e of c(this,a,ct).call(this))t(this,m)[e]!==void 0&&t(this,x)[e]!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield [t(this,x)[e],t(this,m)[e]]);}*keys(){for(let e of c(this,a,ht).call(this)){let i=t(this,x)[e];i!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield i);}}*rkeys(){for(let e of c(this,a,ct).call(this)){let i=t(this,x)[e];i!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield i);}}*values(){for(let e of c(this,a,ht).call(this))t(this,m)[e]!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}*rvalues(){for(let e of c(this,a,ct).call(this))t(this,m)[e]!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}[(Qt=Symbol.iterator,Jt=Symbol.toStringTag,Qt)](){return this.entries()}find(e,i={}){for(let s of c(this,a,ht).call(this)){let r=t(this,m)[s],n=c(this,a,b).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,t(this,x)[s],this))return this.get(t(this,x)[s],i)}}forEach(e,i=this){for(let s of c(this,a,ht).call(this)){let r=t(this,m)[s],n=c(this,a,b).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,x)[s],this);}}rforEach(e,i=this){for(let s of c(this,a,ct).call(this)){let r=t(this,m)[s],n=c(this,a,b).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,x)[s],this);}}purgeStale(){let e=false;for(let i of c(this,a,ct).call(this,{allowStale:true}))t(this,K).call(this,i)&&(c(this,a,dt).call(this,t(this,x)[i],"expire"),e=true);return e}info(e){let i=t(this,U).get(e);if(i===void 0)return;let s=t(this,m)[i],r=c(this,a,b).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(t(this,Y)&&t(this,et)){let o=t(this,Y)[i],h=t(this,et)[i];if(o&&h){let d=o-(t(this,J).now()-h);n.ttl=d,n.start=Date.now();}}return t(this,tt)&&(n.size=t(this,tt)[i]),n}dump(){let e=[];for(let i of c(this,a,ht).call(this,{allowStale:true})){let s=t(this,x)[i],r=t(this,m)[i],n=c(this,a,b).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(t(this,Y)&&t(this,et)){o.ttl=t(this,Y)[i];let h=t(this,J).now()-t(this,et)[i];o.start=Math.floor(Date.now()-h);}t(this,tt)&&(o.size=t(this,tt)[i]),e.unshift([s,o]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,J).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var ot,G,$,E;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:d}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,L=t(this,Ut).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&L>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),c(this,a,dt).call(this,e,"set"),this;let S=t(this,R)===0?void 0:t(this,U).get(e);if(S===void 0)S=t(this,R)===0?t(this,D):t(this,Z).length!==0?t(this,Z).pop():t(this,R)===t(this,q)?c(this,a,Dt).call(this,false):t(this,R),t(this,x)[S]=e,t(this,m)[S]=i,t(this,U).set(e,S),t(this,j)[t(this,D)]=S,t(this,W)[S]=t(this,D),u(this,D,S),Rt(this,R)._++,t(this,xt).call(this,S,L,d),d&&(d.set="add"),v=false,t(this,bt)&&((ot=t(this,ft))==null||ot.call(this,i,e,"add"));else {c(this,a,At).call(this,S);let y=t(this,m)[S];if(i!==y){if(t(this,pt)&&c(this,a,b).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=y;g!==void 0&&!o&&(t(this,it)&&((G=t(this,B))==null||G.call(this,g,e,"set")),t(this,P)&&t(this,C)?.push([g,e,"set"]));}else o||(t(this,it)&&(($=t(this,B))==null||$.call(this,y,e,"set")),t(this,P)&&t(this,C)?.push([y,e,"set"]));if(t(this,gt).call(this,S),t(this,xt).call(this,S,L,d),t(this,m)[S]=i,d){d.set="replace";let g=y&&c(this,a,b).call(this,y)?y.__staleWhileFetching:y;g!==void 0&&(d.oldValue=g);}}else d&&(d.set="update");t(this,bt)&&this.onInsert?.(i,e,i===y?"update":"replace");}if(r!==0&&!t(this,Y)&&c(this,a,Mt).call(this),t(this,Y)&&(v||t(this,Tt).call(this,S,r,n),d&&t(this,nt).call(this,d,S)),!o&&t(this,P)&&t(this,C)){let y=t(this,C),g;for(;g=y?.shift();)(E=t(this,X))==null||E.call(this,...g);}return this}pop(){var e;try{for(;t(this,R);){let i=t(this,m)[t(this,F)];if(c(this,a,Dt).call(this,!0),c(this,a,b).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,P)&&t(this,C)){let i=t(this,C),s;for(;s=i?.shift();)(e=t(this,X))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=t(this,U).get(e);if(n!==void 0){let o=t(this,m)[n];if(c(this,a,b).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,K).call(this,n))r&&(r.has="stale",t(this,nt).call(this,r,n));else return s&&t(this,mt).call(this,n),r&&(r.has="hit",t(this,nt).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,U).get(e);if(r===void 0||!s&&t(this,K).call(this,r))return;let n=t(this,m)[r];return c(this,a,b).call(this,n)?n.__staleWhileFetching:n}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:d=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:L=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:ot=this.allowStaleOnFetchRejection,ignoreFetchAbort:G=this.ignoreFetchAbort,allowStaleOnFetchAbort:$=this.allowStaleOnFetchAbort,context:E,forceRefresh:y=false,status:g,signal:f}=i;if(!t(this,pt))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let w={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:h,size:d,sizeCalculation:v,noUpdateTTL:L,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:ot,allowStaleOnFetchAbort:$,ignoreFetchAbort:G,status:g,signal:f},T=t(this,U).get(e);if(T===void 0){g&&(g.fetch="miss");let p=c(this,a,Ct).call(this,e,T,w,E);return p.__returned=p}else {let p=t(this,m)[T];if(c(this,a,b).call(this,p)){let _t=s&&p.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",_t&&(g.returnedStale=true)),_t?p.__staleWhileFetching:p.__returned=p}let A=t(this,K).call(this,T);if(!y&&!A)return g&&(g.fetch="hit"),c(this,a,At).call(this,T),r&&t(this,mt).call(this,T),g&&t(this,nt).call(this,g,T),p;let I=c(this,a,Ct).call(this,e,T,w,E),k=I.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=A?"stale":"refresh",k&&A&&(g.returnedStale=true)),k?I.__staleWhileFetching:I.__returned=I}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,yt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,h=this.get(e,o);if(!n&&h!==void 0)return h;let d=s(e,h,{options:o,context:r});return this.set(e,d,o),d}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,h=t(this,U).get(e);if(h!==void 0){let d=t(this,m)[h],v=c(this,a,b).call(this,d);return o&&t(this,nt).call(this,o,h),t(this,K).call(this,h)?(o&&(o.get="stale"),v?(o&&s&&d.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?d.__staleWhileFetching:void 0):(n||c(this,a,dt).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?d:void 0)):(o&&(o.get="hit"),v?d.__staleWhileFetching:(c(this,a,At).call(this,h),r&&t(this,mt).call(this,h),d))}else o&&(o.get="miss");}delete(e){return c(this,a,dt).call(this,e,"delete")}clear(){return c(this,a,Vt).call(this,"delete")}},q=new WeakMap,V=new WeakMap,B=new WeakMap,ft=new WeakMap,X=new WeakMap,St=new WeakMap,yt=new WeakMap,J=new WeakMap,R=new WeakMap,Q=new WeakMap,U=new WeakMap,x=new WeakMap,m=new WeakMap,j=new WeakMap,W=new WeakMap,F=new WeakMap,D=new WeakMap,Z=new WeakMap,C=new WeakMap,tt=new WeakMap,et=new WeakMap,Y=new WeakMap,H=new WeakMap,it=new WeakMap,pt=new WeakMap,P=new WeakMap,bt=new WeakMap,a=new WeakSet,Mt=function(){let e=new Lt(t(this,q)),i=new Lt(t(this,q));u(this,Y,e),u(this,et,i);let s=this.ttlAutopurge?new Array(t(this,q)):void 0;u(this,H,s),u(this,Tt,(h,d,v=t(this,J).now())=>{i[h]=d!==0?v:0,e[h]=d,r(h,d);}),u(this,mt,h=>{i[h]=e[h]!==0?t(this,J).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,d)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),d&&d!==0&&s){let v=setTimeout(()=>{t(this,K).call(this,h)&&c(this,a,dt).call(this,t(this,x)[h],"expire");},d+1);v.unref&&v.unref(),s[h]=v;}}:()=>{};u(this,nt,(h,d)=>{if(e[d]){let v=e[d],L=i[d];if(!v||!L)return;h.ttl=v,h.start=L,h.now=n||o();let S=h.now-L;h.remainingTTL=v-S;}});let n=0,o=()=>{let h=t(this,J).now();if(this.ttlResolution>0){n=h;let d=setTimeout(()=>n=0,this.ttlResolution);d.unref&&d.unref();}return h};this.getRemainingTTL=h=>{let d=t(this,U).get(h);if(d===void 0)return 0;let v=e[d],L=i[d];if(!v||!L)return 1/0;let S=(n||o())-L;return v-S},u(this,K,h=>{let d=i[h],v=e[h];return !!v&&!!d&&(n||o())-d>v});},mt=new WeakMap,nt=new WeakMap,Tt=new WeakMap,K=new WeakMap,se=function(){let e=new Lt(t(this,q));u(this,Q,0),u(this,tt,e),u(this,gt,i=>{u(this,Q,t(this,Q)-e[i]),e[i]=0;}),u(this,Ut,(i,s,r,n)=>{if(c(this,a,b).call(this,s))return 0;if(!lt(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!lt(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}),u(this,xt,(i,s,r)=>{if(e[i]=s,t(this,V)){let n=t(this,V)-e[i];for(;t(this,Q)>n;)c(this,a,Dt).call(this,true);}u(this,Q,t(this,Q)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,Q));});},gt=new WeakMap,xt=new WeakMap,Ut=new WeakMap,ht=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,D);!(!c(this,a,zt).call(this,i)||((e||!t(this,K).call(this,i))&&(yield i),i===t(this,F)));)i=t(this,W)[i];},ct=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,F);!(!c(this,a,zt).call(this,i)||((e||!t(this,K).call(this,i))&&(yield i),i===t(this,D)));)i=t(this,j)[i];},zt=function(e){return e!==void 0&&t(this,U).get(t(this,x)[e])===e},Dt=function(e){var n;let i=t(this,F),s=t(this,x)[i],r=t(this,m)[i];return t(this,pt)&&c(this,a,b).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,it)||t(this,P))&&(t(this,it)&&((n=t(this,B))==null||n.call(this,r,s,"evict")),t(this,P)&&t(this,C)?.push([r,s,"evict"])),t(this,gt).call(this,i),t(this,H)?.[i]&&(clearTimeout(t(this,H)[i]),t(this,H)[i]=void 0),e&&(t(this,x)[i]=void 0,t(this,m)[i]=void 0,t(this,Z).push(i)),t(this,R)===1?(u(this,F,u(this,D,0)),t(this,Z).length=0):u(this,F,t(this,j)[i]),t(this,U).delete(s),Rt(this,R)._--,i},Ct=function(e,i,s,r){let n=i===void 0?void 0:t(this,m)[i];if(c(this,a,b).call(this,n))return n;let o=new Nt,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let d={signal:o.signal,options:s,context:r},v=(E,y=false)=>{let{aborted:g}=o.signal,f=s.ignoreFetchAbort&&E!==void 0,w=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&E!==void 0);if(s.status&&(g&&!y?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,f&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!f&&!y)return S(o.signal.reason,w);let T=G,p=t(this,m)[i];return (p===G||f&&y&&p===void 0)&&(E===void 0?T.__staleWhileFetching!==void 0?t(this,m)[i]=T.__staleWhileFetching:c(this,a,dt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,E,d.options))),E},L=E=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=E),S(E,false)),S=(E,y)=>{let{aborted:g}=o.signal,f=g&&s.allowStaleOnFetchAbort,w=f||s.allowStaleOnFetchRejection,T=w||s.noDeleteOnFetchRejection,p=G;if(t(this,m)[i]===G&&(!T||!y&&p.__staleWhileFetching===void 0?c(this,a,dt).call(this,e,"fetch"):f||(t(this,m)[i]=p.__staleWhileFetching)),w)return s.status&&p.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),p.__staleWhileFetching;if(p.__returned===p)throw E},ot=(E,y)=>{var f;let g=(f=t(this,St))==null?void 0:f.call(this,e,n,d);g&&g instanceof Promise&&g.then(w=>E(w===void 0?void 0:w),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(E(void 0),s.allowStaleOnFetchAbort&&(E=w=>v(w,true)));});};s.status&&(s.status.fetchDispatched=true);let G=new Promise(ot).then(v,L),$=Object.assign(G,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,$,{...d.options,status:void 0}),i=t(this,U).get(e)):t(this,m)[i]=$,$},b=function(e){if(!t(this,pt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt},Gt=function(e,i){t(this,W)[i]=e,t(this,j)[e]=i;},At=function(e){e!==t(this,D)&&(e===t(this,F)?u(this,F,t(this,j)[e]):c(this,a,Gt).call(this,t(this,W)[e],t(this,j)[e]),c(this,a,Gt).call(this,t(this,D),e),u(this,D,e));},dt=function(e,i){var r,n;let s=false;if(t(this,R)!==0){let o=t(this,U).get(e);if(o!==void 0)if(t(this,H)?.[o]&&(clearTimeout(t(this,H)?.[o]),t(this,H)[o]=void 0),s=true,t(this,R)===1)c(this,a,Vt).call(this,i);else {t(this,gt).call(this,o);let h=t(this,m)[o];if(c(this,a,b).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,it)||t(this,P))&&(t(this,it)&&((r=t(this,B))==null||r.call(this,h,e,i)),t(this,P)&&t(this,C)?.push([h,e,i])),t(this,U).delete(e),t(this,x)[o]=void 0,t(this,m)[o]=void 0,o===t(this,D))u(this,D,t(this,W)[o]);else if(o===t(this,F))u(this,F,t(this,j)[o]);else {let d=t(this,W)[o];t(this,j)[d]=t(this,j)[o];let v=t(this,j)[o];t(this,W)[v]=t(this,W)[o];}Rt(this,R)._--,t(this,Z).push(o);}}if(t(this,P)&&t(this,C)?.length){let o=t(this,C),h;for(;h=o?.shift();)(n=t(this,X))==null||n.call(this,...h);}return s},Vt=function(e){var i,s;for(let r of c(this,a,ct).call(this,{allowStale:true})){let n=t(this,m)[r];if(c(this,a,b).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=t(this,x)[r];t(this,it)&&((i=t(this,B))==null||i.call(this,n,o,e)),t(this,P)&&t(this,C)?.push([n,o,e]);}}if(t(this,U).clear(),t(this,m).fill(void 0),t(this,x).fill(void 0),t(this,Y)&&t(this,et)){t(this,Y).fill(0),t(this,et).fill(0);for(let r of t(this,H)??[])r!==void 0&&clearTimeout(r);t(this,H)?.fill(void 0);}if(t(this,tt)&&t(this,tt).fill(0),u(this,F,0),u(this,D,0),t(this,Z).length=0,u(this,Q,0),u(this,R,0),t(this,P)&&t(this,C)){let r=t(this,C),n;for(;n=r?.shift();)(s=t(this,X))==null||s.call(this,...n);}},Et);var It=class{cache;map=new Map;constructor(e){this.cache=new ie({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ot="1.9.0";var Wt={version:Ot};var Yt="__game_layer__";var ge={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 oe={};var Ht={};pe(Ht,{createExportableElement:()=>ne});var wt;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(wt||={});function ne(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw wt.error("Error creating exportable element",l,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ve=typeof window<"u"&&typeof document<"u",ae=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Wt.version}`],le=31,Se="background:#2f90da;color:#fff;font-weight:bold;",ye="background:#c832bb;color:#fff;font-weight:bold;",be="background:transparent;font-weight:bold;",Kt=` v${Wt.version}`;function he(){if(!ve)return;let l=[],e=[];for(let i=0;i<ae.length;i++){let s=ae[i],r=s.endsWith(Kt),n=r?s.slice(0,-Kt.length):s,o=n.slice(0,le),h=n.slice(le),d=r?"%c%s%c%s%c%s":"%c%s%c%s";l.push(d),e.push(Se,o,ye,h),r&&e.push(be,Kt);}console.info(l.join(`
2
- `),...e);}function kt(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}he();exports.Game=void 0;(g=>{async function l(f,w,T){if(core.GameUnifier.init({navigate:w?.navigate,getCurrentGameStepState:()=>{let p=M__namespace.canvas.isInitialized?M__namespace.canvas.export():{};return {path:kt(),storage:z__namespace.storage.export(),canvas:p,sound:ut__namespace.sound.export(),labelIndex:O__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:O__namespace.narration.openedLabels}},restoreGameStepState:async(p,A)=>{st__namespace.HistoryManagerStatic._originalStepData=p,O__namespace.NarrationManagerStatic.openedLabels=p.openedLabels,z__namespace.storage.restore(p.storage);try{M__namespace.canvas.isInitialized&&await M__namespace.canvas.restore(p.canvas),await ut__namespace.sound.restore(p.sound);}catch(I){wt.error("Error restoring game step state:",I);}await A(p.path);},getStepCounter:()=>O__namespace.narration.stepCounter,setStepCounter:p=>{O__namespace.NarrationManagerStatic._stepCounter=p;},getOpenedLabels:()=>O__namespace.narration.openedLabels.length,addHistoryItem:(p,A)=>st__namespace.stepHistory.add(p,A),getCharacter:p=>qt__namespace.RegisteredCharacters.get(p),processNavigationRequests:(p,A)=>{let I=p,k=Promise.resolve();return p>0?(I--,k=O__namespace.narration.continue(A)):p<0&&(I=0,k=st__namespace.stepHistory.back(A,{steps:p*-1})),{newValue:I,result:k}},animate:(p,A,I,k)=>motion.motion.animate(p,A,I,k),getVariable:(p,A)=>z__namespace.StorageRegistry.getVariable(p,A),setVariable:(p,A,I)=>z__namespace.StorageRegistry.setVariable(p,A,I),removeVariable:(p,A)=>z__namespace.StorageRegistry.removeVariable(p,A),getFlag:p=>z__namespace.storage.flags.get(p),setFlag:(p,A)=>z__namespace.storage.flags.set(p,A),onLabelClosing:p=>z__namespace.StorageRegistry.clearOldTempVariables(p)}),!f||!w){wt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await M__namespace.canvas.init(f,w,T)}g.init=l;function e(){z__namespace.storage.clear(),M__namespace.canvas.isInitialized&&M__namespace.canvas.clear(),ut__namespace.sound.clear(),O__namespace.narration.clear(),st__namespace.stepHistory.clear();}g.clear=e;function i(){let f=M__namespace.canvas.isInitialized?M__namespace.canvas.export():{};return {pixivn_version:Ot,stepData:O__namespace.narration.export(),storageData:z__namespace.storage.export(),canvasData:f,soundData:ut__namespace.sound.export(),historyData:st__namespace.stepHistory.export(),path:kt()}}g.exportGameState=i;async function s(f){st__namespace.stepHistory.restore(f.historyData);let w=st__namespace.stepHistory.lastKey;if(typeof w=="number"){let T=st__namespace.stepHistory.stepsInfoMap.get(w)||null;await O__namespace.narration.restore(f.stepData,T);}z__namespace.storage.restore(f.storageData);try{M__namespace.canvas.isInitialized&&await M__namespace.canvas.restore(f.canvasData),await ut__namespace.sound.restore(f.soundData);}catch{}await core.GameUnifier.navigate(f.path);}g.restoreGameState=s;async function r(f,w){return g.clear(),await O__namespace.narration.call(f,w)}g.start=r;function n(f){return JSON.parse(f)}g.jsonToGameState=n;function o(f){core.GameUnifier.onEnd=f;}g.onEnd=o;function h(f){return core.GameUnifier.addOnError(f)}g.addOnError=h;function d(f){return core.GameUnifier.removeOnError(f)}g.removeOnError=d;function v(f){O__namespace.NarrationManagerStatic.onStepStart=f;}g.onStepStart=v;function L(f){O__namespace.NarrationManagerStatic.onLoadingLabel=f;}g.onLoadingLabel=L;function S(f){O__namespace.NarrationManagerStatic.onStepEnd=f;}g.onStepEnd=S;function ot(f){O__namespace.NarrationManagerStatic.onLabelStarting=f;}g.onLabelStarting=ot;function G(f){O__namespace.NarrationManagerStatic.onLabelClosing=f;}g.onLabelClosing=G;function $(f){core.GameUnifier.navigate=f;}g.onNavigate=$;function E(f){return core.GameUnifier.addOnPreContinue(f)}g.addOnPreContinue=E;function y(f){return core.GameUnifier.removeOnPreContinue(f)}g.removeOnPreContinue=y;})(exports.Game||={});var Je={characterUtils:qt__namespace,canvasUtils:M__namespace,narrationUtils:O__namespace,soundUtils:ut__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Yt,PIXIVN_VERSION:Ot,...Ht,...oe,canvas:M__namespace.canvas,narration:O__namespace.narration,sound:ut__namespace.sound,storage:z__namespace.storage,history:st__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Yt;exports.CachedMap=It;exports.PIXIVN_VERSION=Ot;exports.SYSTEM_RESERVED_STORAGE_KEYS=ge;exports.createExportableElement=ne;exports.default=Je;Object.keys(M).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return M[k]}})});Object.keys(qt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return qt[k]}})});Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(st).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return st[k]}})});Object.keys(O).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return O[k]}})});Object.keys(ut).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return ut[k]}})});Object.keys(z).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return z[k]}})});
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var k=require('@drincs/pixi-vn/canvas'),$t=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),ot=require('@drincs/pixi-vn/history'),L=require('@drincs/pixi-vn/narration'),gt=require('@drincs/pixi-vn/sound'),K=require('@drincs/pixi-vn/storage'),motion=require('@drincs/pixi-vn/motion');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var k__namespace=/*#__PURE__*/_interopNamespace(k);var $t__namespace=/*#__PURE__*/_interopNamespace($t);var ot__namespace=/*#__PURE__*/_interopNamespace(ot);var L__namespace=/*#__PURE__*/_interopNamespace(L);var gt__namespace=/*#__PURE__*/_interopNamespace(gt);var K__namespace=/*#__PURE__*/_interopNamespace(K);var Xt=Object.defineProperty;var Jt=l=>{throw TypeError(l)};var me=(l,e,i)=>e in l?Xt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var ge=(l,e)=>{for(var i in e)Xt(l,i,{get:e[i],enumerable:true});};var N=(l,e,i)=>me(l,typeof e!="symbol"?e+"":e,i),Ft=(l,e,i)=>e.has(l)||Jt("Cannot "+i);var t=(l,e,i)=>(Ft(l,e,"read from private field"),i?i.call(l):e.get(l)),b=(l,e,i)=>e.has(l)?Jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),p=(l,e,i,s)=>(Ft(l,e,"write to private field"),e.set(l,i),i),c=(l,e,i)=>(Ft(l,e,"access private method"),i);var Rt=(l,e,i,s)=>({set _(r){p(l,e,r);},get _(){return t(l,e,s)}});var _e=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ee=new Set,Mt=typeof process=="object"&&process?process:{},ie=(l,e,i,s)=>{typeof Mt.emitWarning=="function"?Mt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Gt=globalThis.AbortController,Qt=globalThis.AbortSignal;if(typeof Gt>"u"){Qt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){e();}signal=new Qt;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 l=Mt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,ie("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var ve=l=>!ee.has(l);var ct=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),se=l=>ct(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?Pt:null:null,Pt=class extends Array{constructor(l){super(l),this.fill(0);}},at,bt,ye=(at=class{heap;length;static create(e){let i=se(e);if(!i)return [];p(at,bt,true);let s=new at(e,i);return p(at,bt,false),s}constructor(e,i){if(!t(at,bt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},bt=new WeakMap,b(at,bt,false),at),Zt,te,J,W,Q,_t,Z,St,Tt,tt,I,et,R,x,g,z,Y,M,C,it,G,st,rt,q,B,nt,ft,V,wt,a,zt,vt,lt,At,$,ne,yt,xt,Ot,dt,pt,Vt,It,Ct,w,Ht,Ut,ut,kt,Et,re=(Et=class{constructor(e){b(this,a);b(this,J);b(this,W);b(this,Q);b(this,_t);b(this,Z);b(this,St);b(this,Tt);b(this,tt);N(this,"ttl");N(this,"ttlResolution");N(this,"ttlAutopurge");N(this,"updateAgeOnGet");N(this,"updateAgeOnHas");N(this,"allowStale");N(this,"noDisposeOnSet");N(this,"noUpdateTTL");N(this,"maxEntrySize");N(this,"sizeCalculation");N(this,"noDeleteOnFetchRejection");N(this,"noDeleteOnStaleGet");N(this,"allowStaleOnFetchAbort");N(this,"allowStaleOnFetchRejection");N(this,"ignoreFetchAbort");b(this,I);b(this,et);b(this,R);b(this,x);b(this,g);b(this,z);b(this,Y);b(this,M);b(this,C);b(this,it);b(this,G);b(this,st);b(this,rt);b(this,q);b(this,B);b(this,nt);b(this,ft);b(this,V);b(this,wt);b(this,vt,()=>{});b(this,lt,()=>{});b(this,At,()=>{});b(this,$,()=>false);b(this,yt,e=>{});b(this,xt,(e,i,s)=>{});b(this,Ot,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});N(this,Zt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:h,allowStale:d,dispose:y,onInsert:O,disposeAfter:S,noDisposeOnSet:j,noUpdateTTL:D,maxSize:H=0,maxEntrySize:f=0,sizeCalculation:_,fetchMethod:m,memoMethod:U,noDeleteOnFetchRejection:u,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:v,ignoreFetchAbort:A,perf:F}=e;if(F!==void 0&&typeof F?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(p(this,tt,F??_e),i!==0&&!ct(i))throw new TypeError("max option must be a nonnegative integer");let X=i?se(i):Array;if(!X)throw new Error("invalid max value: "+i);if(p(this,J,i),p(this,W,H),this.maxEntrySize=f||t(this,W),this.sizeCalculation=_,this.sizeCalculation){if(!t(this,W)&&!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(U!==void 0&&typeof U!="function")throw new TypeError("memoMethod must be a function if defined");if(p(this,Tt,U),m!==void 0&&typeof m!="function")throw new TypeError("fetchMethod must be a function if specified");if(p(this,St,m),p(this,ft,!!m),p(this,R,new Map),p(this,x,new Array(i).fill(void 0)),p(this,g,new Array(i).fill(void 0)),p(this,z,new X(i)),p(this,Y,new X(i)),p(this,M,0),p(this,C,0),p(this,it,ye.create(i)),p(this,I,0),p(this,et,0),typeof y=="function"&&p(this,Q,y),typeof O=="function"&&p(this,_t,O),typeof S=="function"?(p(this,Z,S),p(this,G,[])):(p(this,Z,void 0),p(this,G,void 0)),p(this,nt,!!t(this,Q)),p(this,wt,!!t(this,_t)),p(this,V,!!t(this,Z)),this.noDisposeOnSet=!!j,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!u,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!A,this.maxEntrySize!==0){if(t(this,W)!==0&&!ct(t(this,W)))throw new TypeError("maxSize must be a positive integer if specified");if(!ct(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,ne).call(this);}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!h,this.ttlResolution=ct(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!ct(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,zt).call(this);}if(t(this,J)===0&&this.ttl===0&&t(this,W)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,J)&&!t(this,W)){let jt="LRU_CACHE_UNBOUNDED";ve(jt)&&(ee.add(jt),ie("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",jt,Et));}}get perf(){return t(this,tt)}static unsafeExposeInternals(e){return {starts:t(e,rt),ttls:t(e,q),autopurgeTimers:t(e,B),sizes:t(e,st),keyMap:t(e,R),keyList:t(e,x),valList:t(e,g),next:t(e,z),prev:t(e,Y),get head(){return t(e,M)},get tail(){return t(e,C)},free:t(e,it),isBackgroundFetch:i=>{var s;return c(s=e,a,w).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return c(n=e,a,Ct).call(n,i,s,r,o)},moveToTail:i=>{var s;return c(s=e,a,Ut).call(s,i)},indexes:i=>{var s;return c(s=e,a,dt).call(s,i)},rindexes:i=>{var s;return c(s=e,a,pt).call(s,i)},isStale:i=>{var s;return t(s=e,$).call(s,i)}}}get max(){return t(this,J)}get maxSize(){return t(this,W)}get calculatedSize(){return t(this,et)}get size(){return t(this,I)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,Tt)}get dispose(){return t(this,Q)}get onInsert(){return t(this,_t)}get disposeAfter(){return t(this,Z)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of c(this,a,dt).call(this))t(this,g)[e]!==void 0&&t(this,x)[e]!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield [t(this,x)[e],t(this,g)[e]]);}*rentries(){for(let e of c(this,a,pt).call(this))t(this,g)[e]!==void 0&&t(this,x)[e]!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield [t(this,x)[e],t(this,g)[e]]);}*keys(){for(let e of c(this,a,dt).call(this)){let i=t(this,x)[e];i!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of c(this,a,pt).call(this)){let i=t(this,x)[e];i!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of c(this,a,dt).call(this))t(this,g)[e]!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of c(this,a,pt).call(this))t(this,g)[e]!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(te=Symbol.iterator,Zt=Symbol.toStringTag,te)](){return this.entries()}find(e,i={}){for(let s of c(this,a,dt).call(this)){let r=t(this,g)[s],o=c(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,x)[s],this))return this.get(t(this,x)[s],i)}}forEach(e,i=this){for(let s of c(this,a,dt).call(this)){let r=t(this,g)[s],o=c(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,x)[s],this);}}rforEach(e,i=this){for(let s of c(this,a,pt).call(this)){let r=t(this,g)[s],o=c(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,x)[s],this);}}purgeStale(){let e=false;for(let i of c(this,a,pt).call(this,{allowStale:true}))t(this,$).call(this,i)&&(c(this,a,ut).call(this,t(this,x)[i],"expire"),e=true);return e}info(e){let i=t(this,R).get(e);if(i===void 0)return;let s=t(this,g)[i],r=c(this,a,w).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,q)&&t(this,rt)){let n=t(this,q)[i],h=t(this,rt)[i];if(n&&h){let d=n-(t(this,tt).now()-h);o.ttl=d,o.start=Date.now();}}return t(this,st)&&(o.size=t(this,st)[i]),o}dump(){let e=[];for(let i of c(this,a,dt).call(this,{allowStale:true})){let s=t(this,x)[i],r=t(this,g)[i],o=c(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(t(this,q)&&t(this,rt)){n.ttl=t(this,q)[i];let h=t(this,tt).now()-t(this,rt)[i];n.start=Math.floor(Date.now()-h);}t(this,st)&&(n.size=t(this,st)[i]),e.unshift([s,n]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,tt).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var j,D,H,f;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:d}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,O=t(this,Ot).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&O>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),c(this,a,ut).call(this,e,"set"),this;let S=t(this,I)===0?void 0:t(this,R).get(e);if(S===void 0)S=t(this,I)===0?t(this,C):t(this,it).length!==0?t(this,it).pop():t(this,I)===t(this,J)?c(this,a,It).call(this,false):t(this,I),t(this,x)[S]=e,t(this,g)[S]=i,t(this,R).set(e,S),t(this,z)[t(this,C)]=S,t(this,Y)[S]=t(this,C),p(this,C,S),Rt(this,I)._++,t(this,xt).call(this,S,O,d),d&&(d.set="add"),y=false,t(this,wt)&&((j=t(this,_t))==null||j.call(this,i,e,"add"));else {c(this,a,Ut).call(this,S);let _=t(this,g)[S];if(i!==_){if(t(this,ft)&&c(this,a,w).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=_;m!==void 0&&!n&&(t(this,nt)&&((D=t(this,Q))==null||D.call(this,m,e,"set")),t(this,V)&&t(this,G)?.push([m,e,"set"]));}else n||(t(this,nt)&&((H=t(this,Q))==null||H.call(this,_,e,"set")),t(this,V)&&t(this,G)?.push([_,e,"set"]));if(t(this,yt).call(this,S),t(this,xt).call(this,S,O,d),t(this,g)[S]=i,d){d.set="replace";let m=_&&c(this,a,w).call(this,_)?_.__staleWhileFetching:_;m!==void 0&&(d.oldValue=m);}}else d&&(d.set="update");t(this,wt)&&this.onInsert?.(i,e,i===_?"update":"replace");}if(r!==0&&!t(this,q)&&c(this,a,zt).call(this),t(this,q)&&(y||t(this,At).call(this,S,r,o),d&&t(this,lt).call(this,d,S)),!n&&t(this,V)&&t(this,G)){let _=t(this,G),m;for(;m=_?.shift();)(f=t(this,Z))==null||f.call(this,...m);}return this}pop(){var e;try{for(;t(this,I);){let i=t(this,g)[t(this,M)];if(c(this,a,It).call(this,!0),c(this,a,w).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,V)&&t(this,G)){let i=t(this,G),s;for(;s=i?.shift();)(e=t(this,Z))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,R).get(e);if(o!==void 0){let n=t(this,g)[o];if(c(this,a,w).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(t(this,$).call(this,o))r&&(r.has="stale",t(this,lt).call(this,r,o));else return s&&t(this,vt).call(this,o),r&&(r.has="hit",t(this,lt).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,R).get(e);if(r===void 0||!s&&t(this,$).call(this,r))return;let o=t(this,g)[r];return c(this,a,w).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:d=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:O=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:j=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:H=this.allowStaleOnFetchAbort,context:f,forceRefresh:_=false,status:m,signal:U}=i;if(!t(this,ft))return m&&(m.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:m});let u={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:h,size:d,sizeCalculation:y,noUpdateTTL:O,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:j,allowStaleOnFetchAbort:H,ignoreFetchAbort:D,status:m,signal:U},E=t(this,R).get(e);if(E===void 0){m&&(m.fetch="miss");let T=c(this,a,Ct).call(this,e,E,u,f);return T.__returned=T}else {let T=t(this,g)[E];if(c(this,a,w).call(this,T)){let X=s&&T.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",X&&(m.returnedStale=true)),X?T.__staleWhileFetching:T.__returned=T}let v=t(this,$).call(this,E);if(!_&&!v)return m&&(m.fetch="hit"),c(this,a,Ut).call(this,E),r&&t(this,vt).call(this,E),m&&t(this,lt).call(this,m,E),T;let A=c(this,a,Ct).call(this,e,E,u,f),F=A.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=v?"stale":"refresh",F&&v&&(m.returnedStale=true)),F?A.__staleWhileFetching:A.__returned=A}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,Tt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,h=this.get(e,n);if(!o&&h!==void 0)return h;let d=s(e,h,{options:n,context:r});return this.set(e,d,n),d}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,h=t(this,R).get(e);if(h!==void 0){let d=t(this,g)[h],y=c(this,a,w).call(this,d);return n&&t(this,lt).call(this,n,h),t(this,$).call(this,h)?(n&&(n.get="stale"),y?(n&&s&&d.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?d.__staleWhileFetching:void 0):(o||c(this,a,ut).call(this,e,"expire"),n&&s&&(n.returnedStale=true),s?d:void 0)):(n&&(n.get="hit"),y?d.__staleWhileFetching:(c(this,a,Ut).call(this,h),r&&t(this,vt).call(this,h),d))}else n&&(n.get="miss");}delete(e){return c(this,a,ut).call(this,e,"delete")}clear(){return c(this,a,kt).call(this,"delete")}},J=new WeakMap,W=new WeakMap,Q=new WeakMap,_t=new WeakMap,Z=new WeakMap,St=new WeakMap,Tt=new WeakMap,tt=new WeakMap,I=new WeakMap,et=new WeakMap,R=new WeakMap,x=new WeakMap,g=new WeakMap,z=new WeakMap,Y=new WeakMap,M=new WeakMap,C=new WeakMap,it=new WeakMap,G=new WeakMap,st=new WeakMap,rt=new WeakMap,q=new WeakMap,B=new WeakMap,nt=new WeakMap,ft=new WeakMap,V=new WeakMap,wt=new WeakMap,a=new WeakSet,zt=function(){let e=new Pt(t(this,J)),i=new Pt(t(this,J));p(this,q,e),p(this,rt,i);let s=this.ttlAutopurge?new Array(t(this,J)):void 0;p(this,B,s),p(this,At,(h,d,y=t(this,tt).now())=>{i[h]=d!==0?y:0,e[h]=d,r(h,d);}),p(this,vt,h=>{i[h]=e[h]!==0?t(this,tt).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,d)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),d&&d!==0&&s){let y=setTimeout(()=>{t(this,$).call(this,h)&&c(this,a,ut).call(this,t(this,x)[h],"expire");},d+1);y.unref&&y.unref(),s[h]=y;}}:()=>{};p(this,lt,(h,d)=>{if(e[d]){let y=e[d],O=i[d];if(!y||!O)return;h.ttl=y,h.start=O,h.now=o||n();let S=h.now-O;h.remainingTTL=y-S;}});let o=0,n=()=>{let h=t(this,tt).now();if(this.ttlResolution>0){o=h;let d=setTimeout(()=>o=0,this.ttlResolution);d.unref&&d.unref();}return h};this.getRemainingTTL=h=>{let d=t(this,R).get(h);if(d===void 0)return 0;let y=e[d],O=i[d];if(!y||!O)return 1/0;let S=(o||n())-O;return y-S},p(this,$,h=>{let d=i[h],y=e[h];return !!y&&!!d&&(o||n())-d>y});},vt=new WeakMap,lt=new WeakMap,At=new WeakMap,$=new WeakMap,ne=function(){let e=new Pt(t(this,J));p(this,et,0),p(this,st,e),p(this,yt,i=>{p(this,et,t(this,et)-e[i]),e[i]=0;}),p(this,Ot,(i,s,r,o)=>{if(c(this,a,w).call(this,s))return 0;if(!ct(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!ct(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,xt,(i,s,r)=>{if(e[i]=s,t(this,W)){let o=t(this,W)-e[i];for(;t(this,et)>o;)c(this,a,It).call(this,true);}p(this,et,t(this,et)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,et));});},yt=new WeakMap,xt=new WeakMap,Ot=new WeakMap,dt=function*({allowStale:e=this.allowStale}={}){if(t(this,I))for(let i=t(this,C);!(!c(this,a,Vt).call(this,i)||((e||!t(this,$).call(this,i))&&(yield i),i===t(this,M)));)i=t(this,Y)[i];},pt=function*({allowStale:e=this.allowStale}={}){if(t(this,I))for(let i=t(this,M);!(!c(this,a,Vt).call(this,i)||((e||!t(this,$).call(this,i))&&(yield i),i===t(this,C)));)i=t(this,z)[i];},Vt=function(e){return e!==void 0&&t(this,R).get(t(this,x)[e])===e},It=function(e){var o;let i=t(this,M),s=t(this,x)[i],r=t(this,g)[i];return t(this,ft)&&c(this,a,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,nt)||t(this,V))&&(t(this,nt)&&((o=t(this,Q))==null||o.call(this,r,s,"evict")),t(this,V)&&t(this,G)?.push([r,s,"evict"])),t(this,yt).call(this,i),t(this,B)?.[i]&&(clearTimeout(t(this,B)[i]),t(this,B)[i]=void 0),e&&(t(this,x)[i]=void 0,t(this,g)[i]=void 0,t(this,it).push(i)),t(this,I)===1?(p(this,M,p(this,C,0)),t(this,it).length=0):p(this,M,t(this,z)[i]),t(this,R).delete(s),Rt(this,I)._--,i},Ct=function(e,i,s,r){let o=i===void 0?void 0:t(this,g)[i];if(c(this,a,w).call(this,o))return o;let n=new Gt,{signal:h}=s;h?.addEventListener("abort",()=>n.abort(h.reason),{signal:n.signal});let d={signal:n.signal,options:s,context:r},y=(f,_=false)=>{let{aborted:m}=n.signal,U=s.ignoreFetchAbort&&f!==void 0,u=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&f!==void 0);if(s.status&&(m&&!_?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,U&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),m&&!U&&!_)return S(n.signal.reason,u);let E=D,T=t(this,g)[i];return (T===D||U&&_&&T===void 0)&&(f===void 0?E.__staleWhileFetching!==void 0?t(this,g)[i]=E.__staleWhileFetching:c(this,a,ut).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,f,d.options))),f},O=f=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=f),S(f,false)),S=(f,_)=>{let{aborted:m}=n.signal,U=m&&s.allowStaleOnFetchAbort,u=U||s.allowStaleOnFetchRejection,E=u||s.noDeleteOnFetchRejection,T=D;if(t(this,g)[i]===D&&(!E||!_&&T.__staleWhileFetching===void 0?c(this,a,ut).call(this,e,"fetch"):U||(t(this,g)[i]=T.__staleWhileFetching)),u)return s.status&&T.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),T.__staleWhileFetching;if(T.__returned===T)throw f},j=(f,_)=>{var U;let m=(U=t(this,St))==null?void 0:U.call(this,e,o,d);m&&m instanceof Promise&&m.then(u=>f(u===void 0?void 0:u),_),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(f(void 0),s.allowStaleOnFetchAbort&&(f=u=>y(u,true)));});};s.status&&(s.status.fetchDispatched=true);let D=new Promise(j).then(y,O),H=Object.assign(D,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,H,{...d.options,status:void 0}),i=t(this,R).get(e)):t(this,g)[i]=H,H},w=function(e){if(!t(this,ft))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Ht=function(e,i){t(this,Y)[i]=e,t(this,z)[e]=i;},Ut=function(e){e!==t(this,C)&&(e===t(this,M)?p(this,M,t(this,z)[e]):c(this,a,Ht).call(this,t(this,Y)[e],t(this,z)[e]),c(this,a,Ht).call(this,t(this,C),e),p(this,C,e));},ut=function(e,i){var r,o;let s=false;if(t(this,I)!==0){let n=t(this,R).get(e);if(n!==void 0)if(t(this,B)?.[n]&&(clearTimeout(t(this,B)?.[n]),t(this,B)[n]=void 0),s=true,t(this,I)===1)c(this,a,kt).call(this,i);else {t(this,yt).call(this,n);let h=t(this,g)[n];if(c(this,a,w).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,nt)||t(this,V))&&(t(this,nt)&&((r=t(this,Q))==null||r.call(this,h,e,i)),t(this,V)&&t(this,G)?.push([h,e,i])),t(this,R).delete(e),t(this,x)[n]=void 0,t(this,g)[n]=void 0,n===t(this,C))p(this,C,t(this,Y)[n]);else if(n===t(this,M))p(this,M,t(this,z)[n]);else {let d=t(this,Y)[n];t(this,z)[d]=t(this,z)[n];let y=t(this,z)[n];t(this,Y)[y]=t(this,Y)[n];}Rt(this,I)._--,t(this,it).push(n);}}if(t(this,V)&&t(this,G)?.length){let n=t(this,G),h;for(;h=n?.shift();)(o=t(this,Z))==null||o.call(this,...h);}return s},kt=function(e){var i,s;for(let r of c(this,a,pt).call(this,{allowStale:true})){let o=t(this,g)[r];if(c(this,a,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=t(this,x)[r];t(this,nt)&&((i=t(this,Q))==null||i.call(this,o,n,e)),t(this,V)&&t(this,G)?.push([o,n,e]);}}if(t(this,R).clear(),t(this,g).fill(void 0),t(this,x).fill(void 0),t(this,q)&&t(this,rt)){t(this,q).fill(0),t(this,rt).fill(0);for(let r of t(this,B)??[])r!==void 0&&clearTimeout(r);t(this,B)?.fill(void 0);}if(t(this,st)&&t(this,st).fill(0),p(this,M,0),p(this,C,0),t(this,it).length=0,p(this,et,0),p(this,I,0),t(this,V)&&t(this,G)){let r=t(this,G),o;for(;o=r?.shift();)(s=t(this,Z))==null||s.call(this,...o);}},Et);var Dt=class{cache;map=new Map;constructor(e){this.cache=new re({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Lt="1.9.2";var Kt={version:Lt};var Wt="__game_layer__";var be={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 ae={};var Yt={};ge(Yt,{createExportableElement:()=>le});var mt;(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)))(mt||={});function le(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw mt.error("Error creating exportable element",l,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}function ce(l){let e,i={},s={};function r(y){i=y;}function o(y){s=y;}function n(y){e&&h();let O=y?.windowKey??"pixiVN",S=[],j=f=>({...i,...f}),D={Game:l,narration:L__namespace.narration,storage:K__namespace.storage,stepHistory:ot__namespace.stepHistory,get props(){return i},start:(f,_)=>s.start?s.start(f,_):l.start(f,j(_)),continue:(f,_)=>s.continue?s.continue():L__namespace.narration.continue(j(f),_),call:(f,_)=>s.call?s.call(f,_):L__namespace.narration.call(f,j(_)),jump:(f,_)=>s.jump?s.jump(f,_):L__namespace.narration.jump(f,j(_)),selectChoice:(f,_)=>{let m=L__namespace.narration.choices.list?.find(U=>U.choiceIndex===f);if(!m){let U=L__namespace.narration.choices.list?.map(u=>u.choiceIndex).join(", ")??"none (no choice menu is open)";throw new Error(`Game.testing: no open choice with index ${f}. Available: ${U}`)}return s.selectChoice?s.selectChoice(m):L__namespace.narration.choices.select(m,j(_))},setInput:f=>{L__namespace.narration.input.value=f;},goBack:(f,_)=>s.back?s.back():ot__namespace.stepHistory.back(j(f),_),closeCurrentLabel:()=>L__namespace.narration.labels.closeCurrent(),closeAllLabels:()=>L__namespace.narration.labels.closeAll(),getState:()=>({dialogue:L__namespace.narration.dialogue,dialogueGlue:L__namespace.narration.dialogGlue,choices:L__namespace.narration.choices.list,input:{isRequired:L__namespace.narration.input.isRequired,type:L__namespace.narration.input.type,value:L__namespace.narration.input.value},canContinue:L__namespace.narration.canContinue,canGoBack:ot__namespace.stepHistory.canGoBack,labelsOpened:L__namespace.narration.labels.opened,currentLabelId:L__namespace.narration.labels.current?.id,stepCounter:L__namespace.narration.stepCounter}),get errors(){return S.slice()},clearErrors:()=>{S.length=0;}},H=f=>{S.push({error:f,timestamp:Date.now()});};return l.addOnError(H),typeof window<"u"?window[O]=D:mt.warn('Game.testing.enable(): "window" is not defined, so the API was not attached globally (it was still returned).'),e={api:D,windowKey:O,errorHandler:H},D}function h(){e&&(l.removeOnError(e.errorHandler),typeof window<"u"&&window[e.windowKey]===e.api&&delete window[e.windowKey],e=void 0);}function d(){return e!==void 0}return {setProps:r,setActions:o,enable:n,disable:h,isEnabled:d}}var Te=typeof window<"u"&&typeof document<"u",de=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Kt.version}`],pe=31,we="background:#2f90da;color:#fff;font-weight:bold;",xe="background:#c832bb;color:#fff;font-weight:bold;",Ee="background:transparent;font-weight:bold;",qt=` v${Kt.version}`;function ue(){if(!Te)return;let l=[],e=[];for(let i=0;i<de.length;i++){let s=de[i],r=s.endsWith(qt),o=r?s.slice(0,-qt.length):s,n=o.slice(0,pe),h=o.slice(pe),d=r?"%c%s%c%s%c%s":"%c%s%c%s";l.push(d),e.push(we,n,xe,h),r&&e.push(Ee,qt);}console.info(l.join(`
2
+ `),...e);}function Bt(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}ue();exports.Game=void 0;(U=>{async function l(u,E,T){if(core.GameUnifier.init({navigate:E?.navigate,getCurrentGameStepState:()=>{let v=k__namespace.canvas.isInitialized?k__namespace.canvas.export():{};return {path:Bt(),storage:K__namespace.storage.export(),canvas:v,sound:gt__namespace.sound.export(),labelIndex:L__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:L__namespace.narration.openedLabels}},restoreGameStepState:async(v,A)=>{ot__namespace.HistoryManagerStatic._originalStepData=v,L__namespace.NarrationManagerStatic.openedLabels=v.openedLabels,K__namespace.storage.restore(v.storage);try{k__namespace.canvas.isInitialized&&await k__namespace.canvas.restore(v.canvas),await gt__namespace.sound.restore(v.sound);}catch(F){mt.error("Error restoring game step state:",F);}await A(v.path);},getStepCounter:()=>L__namespace.narration.stepCounter,setStepCounter:v=>{L__namespace.NarrationManagerStatic._stepCounter=v;},getOpenedLabels:()=>L__namespace.narration.openedLabels.length,addHistoryItem:(v,A)=>ot__namespace.stepHistory.add(v,A),getCharacter:v=>$t__namespace.RegisteredCharacters.get(v),processNavigationRequests:(v,A)=>{let F=v,X=Promise.resolve();return v>0?(F--,X=L__namespace.narration.continue(A)):v<0&&(F=0,X=ot__namespace.stepHistory.back(A,{steps:v*-1})),{newValue:F,result:X}},animate:(v,A,F,X)=>motion.motion.animate(v,A,F,X),getVariable:(v,A)=>K__namespace.StorageRegistry.getVariable(v,A),setVariable:(v,A,F)=>K__namespace.StorageRegistry.setVariable(v,A,F),removeVariable:(v,A)=>K__namespace.StorageRegistry.removeVariable(v,A),getFlag:v=>K__namespace.storage.flags.get(v),setFlag:(v,A)=>K__namespace.storage.flags.set(v,A),onLabelClosing:v=>K__namespace.StorageRegistry.clearOldTempVariables(v)}),!u||!E){mt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await k__namespace.canvas.init(u,E,T)}U.init=l;function e(){K__namespace.storage.clear(),k__namespace.canvas.isInitialized&&k__namespace.canvas.clear(),gt__namespace.sound.clear(),L__namespace.narration.clear(),ot__namespace.stepHistory.clear();}U.clear=e;function i(){let u=k__namespace.canvas.isInitialized?k__namespace.canvas.export():{};return {pixivn_version:Lt,stepData:L__namespace.narration.export(),storageData:K__namespace.storage.export(),canvasData:u,soundData:gt__namespace.sound.export(),historyData:ot__namespace.stepHistory.export(),path:Bt()}}U.exportGameState=i;async function s(u){ot__namespace.stepHistory.restore(u.historyData);let E=ot__namespace.stepHistory.lastKey;if(typeof E=="number"){let T=ot__namespace.stepHistory.stepsInfoMap.get(E)||null;await L__namespace.narration.restore(u.stepData,T);}K__namespace.storage.restore(u.storageData);try{k__namespace.canvas.isInitialized&&await k__namespace.canvas.restore(u.canvasData),await gt__namespace.sound.restore(u.soundData);}catch{}await core.GameUnifier.navigate(u.path);}U.restoreGameState=s;async function r(u,E){return U.clear(),await L__namespace.narration.call(u,E)}U.start=r;function o(u){return JSON.parse(u)}U.jsonToGameState=o;function n(u){core.GameUnifier.onEnd=u;}U.onEnd=n;function h(u){return core.GameUnifier.addOnError(u)}U.addOnError=h;function d(u){return core.GameUnifier.removeOnError(u)}U.removeOnError=d;function y(u){L__namespace.NarrationManagerStatic.onStepStart=u;}U.onStepStart=y;function O(u){L__namespace.NarrationManagerStatic.onLoadingLabel=u;}U.onLoadingLabel=O;function S(u){L__namespace.NarrationManagerStatic.onStepEnd=u;}U.onStepEnd=S;function j(u){L__namespace.NarrationManagerStatic.onLabelStarting=u;}U.onLabelStarting=j;function D(u){L__namespace.NarrationManagerStatic.onLabelClosing=u;}U.onLabelClosing=D;function H(u){core.GameUnifier.navigate=u;}U.onNavigate=H;function f(u){return core.GameUnifier.addOnPreContinue(u)}U.addOnPreContinue=f;function _(u){return core.GameUnifier.removeOnPreContinue(u)}U.removeOnPreContinue=_,U.testing=ce(U);})(exports.Game||={});var ri={characterUtils:$t__namespace,canvasUtils:k__namespace,narrationUtils:L__namespace,soundUtils:gt__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Wt,PIXIVN_VERSION:Lt,...Yt,...ae,canvas:k__namespace.canvas,narration:L__namespace.narration,sound:gt__namespace.sound,storage:K__namespace.storage,history:ot__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Wt;exports.CachedMap=Dt;exports.PIXIVN_VERSION=Lt;exports.SYSTEM_RESERVED_STORAGE_KEYS=be;exports.createExportableElement=le;exports.default=ri;Object.keys(k).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return k[k]}})});Object.keys($t).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return $t[k]}})});Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(ot).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return ot[k]}})});Object.keys(L).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return L[k]}})});Object.keys(gt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return gt[k]}})});Object.keys(K).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return K[k]}})});