const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-D1aXoOVq.js","assets/webworkerAll-ClyFdN3X.js","assets/colorToUniform-Bwj443Az.js","assets/WebGPURenderer-DnAx_Qia.js","assets/SharedSystems-CRmOW3Kq.js","assets/WebGLRenderer-D9P4BJeq.js"])))=>i.map(i=>d[i]); var La=Object.defineProperty;var Da=(i,t,e)=>t in i?La(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var p=(i,t,e)=>Da(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();const za="modulepreload",Ua=function(i){return"/"+i},Qs={},mi=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=Promise.allSettled(e.map(h=>{if(h=Ua(h),h in Qs)return;Qs[h]=!0;const l=h.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${c}`))return;const d=document.createElement("link");if(d.rel=l?"stylesheet":za,l||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),l)return new Promise((f,g)=>{d.addEventListener("load",f),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return n.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})};var k=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(k||{});const rs=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},ei=(i,t)=>rs(i).priority??t,lt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(rs).forEach(t=>{t.type.forEach(e=>{var s,n;return(n=(s=this._removeHandlers)[e])==null?void 0:n.call(s,t)})}),this},add(...i){return i.map(rs).forEach(t=>{t.type.forEach(e=>{var r,a;const s=this._addHandlers,n=this._queue;s[e]?(a=s[e])==null||a.call(s,t):(n[e]=n[e]||[],(r=n[e])==null||r.push(t))})}),this},handle(i,t,e){var a;const s=this._addHandlers,n=this._removeHandlers;if(s[i]||n[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,n[i]=e;const r=this._queue;return r[i]&&((a=r[i])==null||a.forEach(o=>t(o)),delete r[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(r=>r.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((r,a)=>ei(a.value,e)-ei(r.value,e)))},s=>{const n=t.findIndex(r=>r.name===s.name);n!==-1&&t.splice(n,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((n,r)=>ei(r,e)-ei(n,e)))},s=>{const n=t.indexOf(s.ref);n!==-1&&t.splice(n,1)})}},Oa={extension:{type:k.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await mi(()=>import("./browserAll-D1aXoOVq.js"),__vite__mapDeps([0,1,2]))}},Wa={extension:{type:k.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await mi(()=>import("./webworkerAll-ClyFdN3X.js"),__vite__mapDeps([1,2]))}};class ft{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new ft(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=0 y=0 scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function Ps(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ir={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,d,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var g=new n(c,d||h,f),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],g]:h._events[m].push(g):(h._events[m]=g,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,d;if(this._eventsCount===0)return l;for(d in c=this._events)t.call(c,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=e?e+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,g=d.length,m=new Array(g);fJt[i],uY:i=>te[i],vX:i=>ee[i],vY:i=>ie[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>as[i][t],sub:(i,t)=>as[i][X.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?X.S:X.N:Math.abs(t)*2<=Math.abs(i)?i>0?X.E:X.W:t>0?i>0?X.SE:X.SW:i>0?X.NE:X.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const n=sr[X.inv(t)];n.tx=e,n.ty=s,i.append(n)}},si=[new ht,new ht,new ht,new ht];class E{constructor(t=0,e=0,s=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new E(0,0,0,0)}clone(){return new E(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&e=h&&t<=l&&e>=c&&e<=d&&!(t>f&&tm&&et.right?t.right:this.right)<=G)return!1;const T=this.yt.bottom?t.bottom:this.bottom)>T}const s=this.left,n=this.right,r=this.top,a=this.bottom;if(n<=s||a<=r)return!1;const o=si[0].set(t.left,t.top),h=si[1].set(t.left,t.bottom),l=si[2].set(t.right,t.top),c=si[3].set(t.right,t.bottom);if(l.x<=o.x||h.y<=o.y)return!1;const d=Math.sign(e.a*e.d-e.b*e.c);if(d===0||(e.apply(o,o),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(o.x,h.x,l.x,c.x)<=s||Math.min(o.x,h.x,l.x,c.x)>=n||Math.max(o.y,h.y,l.y,c.y)<=r||Math.min(o.y,h.y,l.y,c.y)>=a))return!1;const f=d*(h.y-o.y),g=d*(o.x-h.x),m=f*s+g*r,y=f*n+g*r,x=f*s+g*a,w=f*n+g*a;if(Math.max(m,y,x,w)<=f*o.x+g*o.y||Math.min(m,y,x,w)>=f*c.x+g*c.y)return!1;const _=d*(o.y-l.y),b=d*(l.x-o.x),S=_*s+b*r,A=_*n+b*r,F=_*s+b*a,P=_*n+b*a;return!(Math.max(S,A,F,P)<=_*o.x+b*o.y||Math.min(S,A,F,P)>=_*c.x+b*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=r-n,this}getBounds(t){return t=t||new E,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ei={default:-1};function nt(i="default"){return Ei[i]===void 0&&(Ei[i]=-1),++Ei[i]}const Js={},W="8.0.0",qa="8.3.4";function U(i,t,e=3){if(Js[t])return;let s=new Error().stack;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${i}`):(s=s.split(` `).splice(e).join(` `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t} Deprecated since v${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${i}`),console.warn(s))),Js[t]=!0}const nr=()=>{};function tn(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function en(i){return!(i&i-1)&&!!i}function Ka(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const sn=Object.create(null);function Za(i){const t=sn[i];return t===void 0&&(sn[i]=nt("resource")),t}const rr=class ar extends pt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...ar.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){U(W,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Za(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};rr.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Qa=rr;const or=class hr extends pt{constructor(t={}){super(),this.options=t,this.uid=nt("textureSource"),this._resourceType="textureSource",this._resourceId=nt("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...hr.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Qa(Ka(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=nt("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const n=Math.round(t*s),r=Math.round(e*s);return this.width=n/s,this.height=r/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=nt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=en(this.pixelWidth)&&en(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};or.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Ot=or;class ks extends Ot{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}ks.extension=k.TextureSource;const nn=new H;class Ja{constructor(t,e){this.mapCoord=new H,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let n=0;nthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new E);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=rn,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,r){r||(r=this.matrix);const a=r.a,o=r.b,h=r.c,l=r.d,c=r.tx,d=r.ty;let f=this.minX,g=this.minY,m=this.maxX,y=this.maxY,x=a*t+h*e+c,w=o*t+l*e+d;xm&&(m=x),w>y&&(y=w),x=a*s+h*e+c,w=o*s+l*e+d,xm&&(m=x),w>y&&(y=w),x=a*t+h*n+c,w=o*t+l*n+d,xm&&(m=x),w>y&&(y=w),x=a*s+h*n+c,w=o*s+l*n+d,xm&&(m=x),w>y&&(y=w),this.minX=f,this.minY=g,this.maxX=m,this.maxY=y}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY,f=a*e+h*r+c,g=o*e+l*r+d,this.minX=fthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY,f=a*n+h*r+c,g=o*n+l*r+d,this.minX=fthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,n){return this.minXe&&(this.maxX=e),this.minYn&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new It(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,n){let r=this.minX,a=this.minY,o=this.maxX,h=this.maxY;n||(n=this.matrix);const l=n.a,c=n.b,d=n.c,f=n.d,g=n.tx,m=n.ty;for(let y=e;yo?_:o,h=b>h?b:h}this.minX=r,this.minY=a,this.maxX=o,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}var eo={grad:.9,turn:360,rad:360/(2*Math.PI)},Rt=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},at=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},yt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},lr=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},an=function(i){return{r:yt(i.r,0,255),g:yt(i.g,0,255),b:yt(i.b,0,255),a:yt(i.a)}},Ri=function(i){return{r:at(i.r),g:at(i.g),b:at(i.b),a:at(i.a,3)}},io=/^#([0-9a-f]{3,8})$/i,ni=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},cr=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=Math.max(t,e,s),a=r-Math.min(t,e,s),o=a?r===t?(e-s)/a:r===e?2+(s-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:r?a/r*100:0,v:r/255*100,a:n}},dr=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var r=Math.floor(t),a=s*(1-e),o=s*(1-(t-r)*e),h=s*(1-(1-t+r)*e),l=r%6;return{r:255*[s,o,a,a,h,s][l],g:255*[h,s,s,o,a,a][l],b:255*[a,a,h,s,s,o][l],a:n}},on=function(i){return{h:lr(i.h),s:yt(i.s,0,100),l:yt(i.l,0,100),a:yt(i.a)}},hn=function(i){return{h:at(i.h),s:at(i.s),l:at(i.l),a:at(i.a,3)}},ln=function(i){return dr((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Oe=function(i){return{h:(t=cr(i)).h,s:(n=(200-(e=t.s))*(s=t.v)/100)>0&&n<200?e*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,s,n},so=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,no=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ro=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ao=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,os={string:[[function(i){var t=io.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?at(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?at(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=ro.exec(i)||ao.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:an({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=so.exec(i)||no.exec(i);if(!t)return null;var e,s,n=on({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(eo[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ln(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=n===void 0?1:n;return Rt(t)&&Rt(e)&&Rt(s)?an({r:Number(t),g:Number(e),b:Number(s),a:Number(r)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,r=n===void 0?1:n;if(!Rt(t)||!Rt(e)||!Rt(s))return null;var a=on({h:Number(t),s:Number(e),l:Number(s),a:Number(r)});return ln(a)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,r=n===void 0?1:n;if(!Rt(t)||!Rt(e)||!Rt(s))return null;var a=function(o){return{h:lr(o.h),s:yt(o.s,0,100),v:yt(o.v,0,100),a:yt(o.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(r)});return dr(a)},"hsv"]]},cn=function(i,t){for(var e=0;e=.5},i.prototype.toHex=function(){return t=Ri(this.rgba),e=t.r,s=t.g,n=t.b,a=(r=t.a)<1?ni(at(255*r)):"","#"+ni(e)+ni(s)+ni(n)+a;var t,e,s,n,r,a},i.prototype.toRgb=function(){return Ri(this.rgba)},i.prototype.toRgbString=function(){return t=Ri(this.rgba),e=t.r,s=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+s+", "+n+", "+r+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,r},i.prototype.toHsl=function(){return hn(Oe(this.rgba))},i.prototype.toHslString=function(){return t=hn(Oe(this.rgba)),e=t.h,s=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+r+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,r},i.prototype.toHsv=function(){return t=cr(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},i.prototype.invert=function(){return Pt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),Pt(Fi(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Pt(Fi(this.rgba,-t))},i.prototype.grayscale=function(){return Pt(Fi(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Pt(dn(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Pt(dn(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?Pt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Oe(this.rgba);return typeof t=="number"?Pt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Pt(t).toHex()},i}(),Pt=function(i){return i instanceof hs?i:new hs(i)},un=[],ho=function(i){i.forEach(function(t){un.indexOf(t)<0&&(t(hs,os),un.push(t))})};function lo(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var n in e)s[e[n]]=n;var r={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=s[this.toHex()];if(l)return l;if(a!=null&&a.closest){var c=this.toRgb(),d=1/0,f="black";if(!r.length)for(var g in e)r[g]=new i(e[g]).toRgb();for(var m in e){var y=(o=c,h=r[m],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));yr===e[a]);if(t!==null&&e!==null){const r=Object.keys(t),a=Object.keys(e);return r.length!==a.length?!1:r.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,n]=this._components;return{r:t,g:e,b:s,a:n}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,n,r]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,n]=this._components;return t[0]=e,t[1]=s,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,n,r]=Le._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,s=(a>>8&255)/255,n=(a&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,n,r=255]=t,e/=255,s/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=Le.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Pt(t);a.isValid()&&({r:e,g:s,b:n,a:r}=a.rgba,e/=255,s/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=n,this._components[3]=r,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Le||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};me.shared=new me;me._temp=new me;me.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Z=me;const co={cullArea:null,cullable:!1,cullableChildren:!0};class Gs{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?e=this._pool[--this._index]:e=new this._classType,(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class uo{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new Gs(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const zt=new uo;function fo(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const r=s-e;for(n=t;n0&&s<=e){for(let a=e-1;a>=i;a--){const o=this.children[a];o&&(n.push(o),o.parent=null)}fo(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let a=0;a=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||U(W,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(i.parent){const n=i.parent.children.indexOf(i);if(i.parent===this&&n===t)return i;n!==-1&&i.parent.children.splice(n,1)}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,t),i.emit("added",this),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var i;(i=this.parent)==null||i.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i}};class fn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;es.priority-n.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const t=this._maskEffect;(t==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),ls.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=ls.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},set filters(i){var r;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new fn);i=i;const e=(i==null?void 0:i.length)>0,s=((r=t.filters)==null?void 0:r.length)>0,n=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new fn),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},xo={label:null,get name(){return U(W,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){U(W,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(n)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(tt.prototype,Object.getOwnPropertyDescriptors(t))}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||U(W,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n1){for(let n=0;n-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=zt.get(To,this),this.groupTransform=H.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),zt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new H),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*$a}set angle(t){this.rotation=t*Va}get pivot(){return this._pivot===Ui&&(this._pivot=new ft(this,0,0)),this._pivot}set pivot(t){this._pivot===Ui&&(this._pivot=new ft(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===zi&&(this._skew=new ft(this,0,0)),this._skew}set skew(t){this._skew===zi&&(this._skew=new ft(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Oi&&(this._scale=new ft(this,1,1)),this._scale}set scale(t){this._scale===Oi&&(this._scale=new ft(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,n=this._pivot,r=this._position,a=s._x,o=s._y,h=n._x,l=n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=r._x-(h*e.a+l*e.c),e.ty=r._y-(h*e.b+l*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=gn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Z.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=gn,this._onUpdate())}get tint(){const t=this.localColor;return((t&255)<<16)+(t&65280)+(t>>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Mo,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Wi,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Wi,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Wi,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var n;if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let r=0;r=e.minX&&s<=e.maxX&&n>=e.minY&&n<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class $ extends Si{constructor(t=z.EMPTY){t instanceof z&&(t={texture:t});const{texture:e=z.EMPTY,anchor:s,roundPixels:n,width:r,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new ft({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof z?new $(t):new $(z.from(t,e))}set texture(t){t||(t=z.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_updateBounds(){to(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:n,height:r}=e.orig;s.maxX=-t._x*n,s.minX=s.maxX+n,s.maxY=-t._y*r,s.minY=s.maxY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const Po=new It;function yr(i,t,e){const s=Po;i.measurable=!0,ur(i,e,s),t.addBoundsMask(s),i.measurable=!1}function wr(i,t,e){const s=xe.get();i.measurable=!0;const n=Ut.get().identity(),r=_r(i,e,n);pr(i,s,r),i.measurable=!1,t.addBoundsMask(s),Ut.return(n),xe.return(s)}function _r(i,t,e){return i?(i!==t&&(_r(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(st("Mask bounds, renderable is not inside the root container"),e)}class br{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof $),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){yr(this.mask,t,e)}addLocalBounds(t,e){wr(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof $}}br.extension=k.MaskEffect;class Sr{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Sr.extension=k.MaskEffect;class vr{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){yr(this.mask,t,e)}addLocalBounds(t,e){wr(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof tt}}vr.extension=k.MaskEffect;const ko={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let mn=ko;const Q={get(){return mn},set(i){mn=i}};class Cr extends Ot{constructor(t){t.resource||(t.resource=Q.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const n=super.resize(t,e,s);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Cr.extension=k.TextureSource;class ve extends Ot{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=Q.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0,t.resource.width,t.resource.height),t.resource=e,st("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ve.extension=k.TextureSource;var yi=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(yi||{});class Ni{constructor(t,e=null,s=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Tr=class gt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Ni(null,null,1/0),this.deltaMS=1/gt.targetFPMS,this.elapsedMS=1/gt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=yi.NORMAL){return this._addListener(new Ni(t,e,s))}addOnce(t,e,s=yi.NORMAL){return this._addListener(new Ni(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const r=t-this._lastFrame|0;if(r{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(s),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Hi}const vi=class Mr extends Ot{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Mr.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Bt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Ar(),this._load=new Promise((s,n)=>{this.isValid?s(this):(this._resolve=s,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Bt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Bt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Bt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};vi.extension=k.TextureSource;vi.defaultOptions={...Ot.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};vi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let fi=vi;const Ct=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class Go{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||st(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=Ct(t);let n;for(let h=0;h{r.set(h,e)});const a=[...r.keys()],o={cacheKeys:a,keys:s};s.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const l=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&st("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){st(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const j=new Go,cs=[];lt.handleByList(k.TextureSource,cs);function Pr(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n{j.has(s)&&j.remove(s)}),t||j.set(s,r),r}function Io(i,t=!1){return typeof i=="string"?j.get(i):i instanceof Ot?new z({source:i}):Bo(i,t)}z.from=Io;Ot.from=Pr;lt.add(br,Sr,vr,fi,ve,Cr,ks);var Xt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Xt||{});function vt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Be(i){return i.split("?")[0].split("#")[0]}function Eo(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ro(i,t,e){return i.replace(new RegExp(Eo(t),"g"),e)}function Fo(i,t){let e="",s=0,n=-1,r=0,a=-1;for(let o=0;o<=i.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),n=o,r=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=o,r=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,o)}`:e=i.slice(n+1,o),s=o-n-1;n=o,r=0}else a===46&&r!==-1?++r:r=-1}return e}const mt={toPosix(i){return Ro(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){vt(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(vt(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Be(this.toPosix(t??Q.get().getBaseUrl())),n=Be(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?mt.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(vt(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=Fo(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return vt(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=s;else{const n=i[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(vt(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const r=this.getProtocol(i),a=i;i=i.slice(r.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!n){s=o;break}}else n=!1;return s===-1?e?"/":this.isUrl(a)?r+i:r:e&&s===1?"//":r+i.slice(0,s)},rootname(i){vt(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){vt(i),t&&vt(t),i=Be(this.toPosix(i));let e=0,s=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let a=t.length-1,o=-1;for(r=i.length-1;r>=0;--r){const h=i.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else o===-1&&(n=!1,o=r+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(s=r):(a=-1,s=o))}return e===s?s=o:s===-1&&(s=i.length),i.slice(e,s)}for(r=i.length-1;r>=0;--r)if(i.charCodeAt(r)===47){if(!n){e=r+1;break}}else s===-1&&(n=!1,s=r+1);return s===-1?"":i.slice(e,s)},extname(i){vt(i),i=Be(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,r=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}s===-1&&(n=!1,s=a+1),o===46?t===-1?t=a:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){vt(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Be(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let n;t.root=this.rootname(i),s||this.hasProtocol(i)?n=1:n=0;let r=-1,a=0,o=-1,h=!0,l=i.length-1,c=0;for(;l>=n;--l){if(e=i.charCodeAt(l),e===47){if(!h){a=l+1;break}continue}o===-1&&(h=!1,o=l+1),e===46?r===-1?r=l:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||o===-1||c===0||c===1&&r===o-1&&r===a+1?o!==-1&&(a===0&&s?t.base=t.name=i.slice(1,o):t.base=t.name=i.slice(a,o)):(a===0&&s?(t.name=i.slice(1,r),t.base=i.slice(1,o)):(t.name=i.slice(a,r),t.base=i.slice(a,o)),t.ext=i.slice(r,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function kr(i,t,e,s,n){const r=t[e];for(let a=0;a{const a=r.substring(1,r.length-1).split(",");n.push(a)}),kr(i,n,0,e,s)}else s.push(i);return s}const wi=i=>!Array.isArray(i);class Ce{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return Ct(e||s,r=>typeof r=="string"?r:Array.isArray(r)?r.map(a=>(a==null?void 0:a.src)??a):r!=null&&r.src?r.src:r,!0)}addManifest(t){this._manifest&&st("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,a])=>typeof a=="string"||Array.isArray(a)?{alias:r,src:a}:{alias:r,...a})),n.forEach(r=>{const a=r.src,o=r.alias;let h;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);s.push(l),h=[o,l]}else{const l=o.map(c=>this._createBundleAssetId(t,c));s.push(...l),h=[...o,...l]}this.add({...r,alias:h,src:a})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=r=>{this.hasKey(r)&&st(`[Resolver] already has key: ${r} overwriting`)},Ct(e).forEach(r=>{const{src:a}=r;let{data:o,format:h,loadParser:l}=r;const c=Ct(a).map(g=>typeof g=="string"?Lo(g):Array.isArray(g)?g:[g]),d=this.getAlias(r);Array.isArray(d)?d.forEach(s):s(d);const f=[];c.forEach(g=>{g.forEach(m=>{let y={};if(typeof m!="object"){y.src=m;for(let x=0;x{this._assetMap[g]=f})})}resolveBundle(t){const e=wi(t);t=Ct(t);const s={};return t.forEach(n=>{const r=this._bundles[n];if(r){const a=this.resolve(r),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(n,h)]=l}s[n]=o}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const n in e)s[n]=e[n].src;return s}return e.src}resolve(t){const e=wi(t);t=Ct(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const a=this._getPreferredOrder(r);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const l=r.filter(c=>c[o]?c[o]===h:!1);l.length&&(r=l)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});s[n]=this._resolverHash[n]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;er.params.format.includes(s.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:s,data:n,loadParser:r,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=mt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.format=a??t.format??Do(t.src),t}}Ce.RETINA_PREFIX=/@([0-9\.]+)x/;function Do(i){return i.split(".").pop().split("?").shift().split("#").shift()}const ds=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},Gr=class De{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof z?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const s=parseFloat(e.meta.scale);s?(this.resolution=s,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=De.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=De.BATCH_SIZE;for(;e-t{this._batchIndex*De.BATCH_SIZE{s[n]=t}),Object.keys(t.textures).forEach(n=>{s[n]=t.textures[n]}),!e){const n=mt.dirname(i[0]);t.linkedSheets.forEach((r,a)=>{const o=Br([`${n}/${t.data.meta.related_multi_packs[a]}`],r,!0);Object.assign(s,o)})}return s}const Uo={extension:k.Asset,cache:{test:i=>i instanceof xn,getCacheableAssets:(i,t)=>Br(i,t,!1)},resolver:{extension:{type:k.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&zo.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=Ce.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:k.LoadParser,priority:Xt.Normal,name:"spritesheetLoader"},async testParse(i,t){return mt.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var l,c;const{texture:s,imageFilename:n}=(t==null?void 0:t.data)??{};let r=mt.dirname(t.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let a;if(s instanceof z)a=s;else{const d=ds(r+(n??i.meta.image),t.src);a=(await e.load([d]))[d]}const o=new xn(a.source,i);await o.parse();const h=(l=i==null?void 0:i.meta)==null?void 0:l.related_multi_packs;if(Array.isArray(h)){const d=[];for(const g of h){if(typeof g!="string")continue;let m=r+g;(c=t.data)!=null&&c.ignoreMultiPack||(m=ds(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);o.linkedSheets=f,f.forEach(g=>{g.linkedSheets=[o].concat(o.linkedSheets.filter(m=>m!==g))})}return o},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};lt.add(Uo);const $i=Object.create(null),yn=Object.create(null);function Bs(i,t){let e=yn[i];return e===void 0&&($i[t]===void 0&&($i[t]=1),yn[i]=e=$i[t]++),e}let he;function Ir(){return(!he||he!=null&&he.isContextLost())&&(he=Q.get().createCanvas().getContext("webgl",{})),he}let ri;function Oo(){if(!ri){ri="mediump";const i=Ir();i&&i.getShaderPrecisionFormat&&(ri=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return ri}function Wo(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying #define finalColor gl_FragColor #define texture texture2D #endif ${i} `):` #ifdef GL_ES // This checks if it is WebGL1 #define in attribute #define out varying #endif ${i} `}function No(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&s!=="highp"&&(n="mediump"),`precision ${n} float; ${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function Ho(i,t){return t?`#version 300 es ${i}`:i}const $o={},Vo={};function Yo(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?$o:Vo;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`} ${i}`}function Xo(i,t){return t?i.replace("#version 300 es",""):i}const Vi={stripVersion:Xo,ensurePrecision:No,addProgramDefines:Wo,setProgramName:Yo,insertVersion:Ho},Yi=Object.create(null),Er=class us{constructor(t){t={...us.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Oo()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(Vi).forEach(a=>{const o=s[a];n=Vi[a](n,o,!0),r=Vi[a](r,o,!1)}),this.fragment=n,this.vertex=r,this._key=Bs(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Yi[e]||(Yi[e]=new us(t)),Yi[e]}};Er.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Rr=Er;const wn={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function jo(i){return wn[i]??wn.float32}const qo={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function Ko({source:i,entryPoint:t}){const e={},s=i.indexOf(`fn ${t}`);if(s!==-1){const n=i.indexOf("->",s);if(n!==-1){const r=i.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(r))!==null;){const h=qo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:jo(h).stride,offset:0,instance:!1,start:0}}}}return e}function Xi(i){var d,f;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=i.match(t))==null?void 0:d.map(g=>({group:parseInt(g.match(e)[1],10),binding:parseInt(g.match(s)[1],10),name:g.match(n)[2],isUniform:g.match(n)[1]==="",type:g.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=((f=i.match(a))==null?void 0:f.map(g=>{const m=g.match(h)[1],y=g.match(o).reduce((x,w)=>{const[_,b]=w.split(":");return x[_.trim()]=b.trim(),x},{});return y?{name:m,members:y}:null}).filter(({name:g})=>l.some(m=>m.type===g)))??[];return{groups:l,structs:c}}var ze=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(ze||{});function Zo({groups:i}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),r=[...i.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return s.has(o)?!1:(s.add(o),!0)});return{structs:n,groups:r}}const ji=Object.create(null);class Ci{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:r,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=s,e.source===s.source){const l=Xi(e.source);this.structsAndGroups=l}else{const l=Xi(s.source),c=Xi(e.source);this.structsAndGroups=Jo(l,c)}this.layout=n??Qo(this.structsAndGroups),this.gpuLayout=r??Zo(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Bs(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Ko(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return ji[e]||(ji[e]=new Ci(t)),ji[e]}}const Fr=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],th=Fr.reduce((i,t)=>(i[t]=!0,i),{});function eh(i,t){switch(i){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Lr=class Dr{constructor(t,e){this._touched=0,this.uid=nt("uniform"),this._resourceType="uniformGroup",this._resourceId=nt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Dr.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!th[r.type])throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${Fr.join(", ")}`);r.value??(r.value=eh(r.type,r.size)),s[n]=r.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Bs(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Lr.defaultOptions={ubo:!1,isStatic:!1};let zr=Lr;class pi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const n=t[s];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var n,r;const s=this.resources[e];t!==s&&(s&&((n=t.off)==null||n.call(t,"change",this.onResourceChange,this)),(r=t.on)==null||r.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var e;const t=this.resources;for(const s in t){const n=t[s];(e=n.off)==null||e.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}var fs=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(fs||{});class Is extends pt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:n,resources:r,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=s,a===void 0&&(a=0,e&&(a|=fs.WEBGPU),s&&(a|=fs.WEBGL)),this.compatibleRenderers=a;const h={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const l in o)for(const c in o[l]){const d=o[l][c];h[d]={group:l,binding:c,name:d}}else if(e&&n&&!o){const l=e.structsAndGroups.groups;o={},l.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,h[c.name]=c})}else if(r){n={},o={},e&&e.structsAndGroups.groups.forEach(d=>{o[d.group]=o[d.group]||{},o[d.group][d.binding]=d.name,h[d.name]=d});let l=0;for(const c in r)h[c]||(n[99]||(n[99]=new pi,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:l,name:c},o[99]=o[99]||{},o[99][l]=c,l++);for(const c in r){const d=c;let f=r[c];!f.source&&!f._resourceType&&(f=new zr(f));const g=h[d];g&&(n[g.group]||(n[g.group]=new pi,this._ownedBindGroups.push(n[g.group])),n[g.group].setResource(f,g.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[s]||(r[s]=t),this.groups[e]||(this.groups[e]=new pi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const r=e[n];Object.defineProperty(s,r.name,{get(){return t[r.group].getResource(r.binding)},set(a){t[r.group].setResource(a,r.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:s,...n}=t;let r,a;return e&&(r=Ci.from(e)),s&&(a=Rr.from(s)),new Is({gpuProgram:r,glProgram:a,...n})}}const ps=[];lt.handleByNamedList(k.Environment,ps);async function ih(i){if(!i)for(let t=0;t80*e){o=l=i[0],h=c=i[1];for(var m=e;ml&&(l=d),f>c&&(c=f);g=Math.max(l-o,c-h),g=g!==0?32767/g:0}return He(r,a,e,o,h,g,0),a}function Ur(i,t,e,s,n){var r,a;if(n===xs(i,t,e,s)>0)for(r=t;r=t;r-=s)a=_n(r,i[r],i[r+1],a);return a&&Ai(a,a.next)&&(Ve(a),a=a.next),a}function ae(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Ai(e,e.next)||q(e.prev,e,e.next)===0)){if(Ve(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function He(i,t,e,s,n,r,a){if(i){!a&&r&&fh(i,s,n,r);for(var o=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,r?rh(i,s,n,r):nh(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),Ve(i),i=l.next,o=l.next;continue}if(i=l,i===o){a?a===1?(i=ah(ae(i),t,e),He(i,t,e,s,n,r,2)):a===2&&oh(i,t,e,s,n,r):He(ae(i),t,e,s,n,r,1);break}}}}function nh(i){var t=i.prev,e=i,s=i.next;if(q(t,e,s)>=0)return!1;for(var n=t.x,r=e.x,a=s.x,o=t.y,h=e.y,l=s.y,c=nr?n>a?n:a:r>a?r:a,g=o>h?o>l?o:l:h>l?h:l,m=s.next;m!==t;){if(m.x>=c&&m.x<=f&&m.y>=d&&m.y<=g&&ue(n,o,r,h,a,l,m.x,m.y)&&q(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function rh(i,t,e,s){var n=i.prev,r=i,a=i.next;if(q(n,r,a)>=0)return!1;for(var o=n.x,h=r.x,l=a.x,c=n.y,d=r.y,f=a.y,g=oh?o>l?o:l:h>l?h:l,x=c>d?c>f?c:f:d>f?d:f,w=gs(g,m,t,e,s),_=gs(y,x,t,e,s),b=i.prevZ,S=i.nextZ;b&&b.z>=w&&S&&S.z<=_;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&q(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&q(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=w;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&q(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=_;){if(S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&q(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function ah(i,t,e){var s=i;do{var n=s.prev,r=s.next.next;!Ai(n,r)&&Or(n,s,s.next,r)&&$e(n,r)&&$e(r,n)&&(t.push(n.i/e|0),t.push(s.i/e|0),t.push(r.i/e|0),Ve(s),Ve(s.next),s=i=r),s=s.next}while(s!==i);return ae(s)}function oh(i,t,e,s,n,r){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&mh(a,o)){var h=Wr(a,o);a=ae(a,a.next),h=ae(h,h.next),He(a,t,e,s,n,r,0),He(h,t,e,s,n,r,0);return}o=o.next}a=a.next}while(a!==i)}function hh(i,t,e,s){var n=[],r,a,o,h,l;for(r=0,a=t.length;r=e.next.y&&e.next.y!==e.y){var o=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=s&&o>r&&(r=o,a=e.x=e.x&&e.x>=l&&s!==e.x&&ue(na.x||e.x===a.x&&uh(a,e)))&&(a=e,d=f)),e=e.next;while(e!==h);return a}function uh(i,t){return q(i.prev,i,t.prev)<0&&q(t.next,i,i.next)<0}function fh(i,t,e,s){var n=i;do n.z===0&&(n.z=gs(n.x,n.y,t,e,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,ph(n)}function ph(i){var t,e,s,n,r,a,o,h,l=1;do{for(e=i,i=null,r=null,a=0;e;){for(a++,s=e,o=0,t=0;t0||h>0&&s;)o!==0&&(h===0||!s||e.z<=s.z)?(n=e,e=e.nextZ,o--):(n=s,s=s.nextZ,h--),r?r.nextZ=n:i=n,n.prevZ=r,r=n;e=s}r.nextZ=null,l*=2}while(a>1);return i}function gs(i,t,e,s,n){return i=(i-e)*n|0,t=(t-s)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function gh(i){var t=i,e=i;do(t.x=(i-a)*(r-o)&&(i-a)*(s-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(n-a)*(s-o)}function mh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!xh(i,t)&&($e(i,t)&&$e(t,i)&&yh(i,t)&&(q(i.prev,i,t.prev)||q(i,t.prev,t))||Ai(i,t)&&q(i.prev,i,i.next)>0&&q(t.prev,t,t.next)>0)}function q(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Ai(i,t){return i.x===t.x&&i.y===t.y}function Or(i,t,e,s){var n=oi(q(i,t,e)),r=oi(q(i,t,s)),a=oi(q(e,s,i)),o=oi(q(e,s,t));return!!(n!==r&&a!==o||n===0&&ai(i,e,t)||r===0&&ai(i,s,t)||a===0&&ai(e,i,s)||o===0&&ai(e,t,s))}function ai(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function oi(i){return i>0?1:i<0?-1:0}function xh(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Or(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function $e(i,t){return q(i.prev,i,i.next)<0?q(i,t,i.next)>=0&&q(i,i.prev,t)>=0:q(i,t,i.prev)<0||q(i,i.next,t)<0}function yh(i,t){var e=i,s=!1,n=(i.x+t.x)/2,r=(i.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Wr(i,t){var e=new ms(i.i,i.x,i.y),s=new ms(t.i,t.x,t.y),n=i.next,r=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,r.next=s,s.prev=r,s}function _n(i,t,e,s){var n=new ms(i,t,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Ve(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ms(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ti.deviation=function(i,t,e,s){var n=t&&t.length,r=n?t[0]*e:i.length,a=Math.abs(xs(i,0,r,e));if(n)for(var o=0,h=t.length;o0&&(s+=i[n-1].length,e.holes.push(s))}return e};var wh=Es.exports;const _h=Ps(wh);var Nr=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))(Nr||{});class bh{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,r,a,o,h){const{name:l,items:c}=this;for(let d=0,f=c.length;d{this.runners[e]=new bh(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const n in this.runners)this.runners[n].add(s);return this}_addPipes(t,e){const s=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,a=n.name,o=s[a];this.renderPipes[a]=new r(this,o?new o:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!sh())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Hr.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Vr=Hr,hi;function vh(i){return hi!==void 0||(hi=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??Vr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Q.get().getWebGLRenderingContext())return!1;let n=Q.get().createCanvas().getContext("webgl",t);const r=!!((e=n==null?void 0:n.getContextAttributes())!=null&&e.stencil);if(n){const a=n.getExtension("WEBGL_lose_context");a&&a.loseContext()}return n=null,r}catch{return!1}})()),hi}let li;async function Ch(i={}){return li!==void 0||(li=await(async()=>{const t=Q.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),li}const bn=["webgl","webgpu","canvas"];async function Th(i){let t=[];i.preference?(t.push(i.preference),bn.forEach(r=>{r!==i.preference&&t.push(r)})):t=bn.slice();let e,s={};for(let r=0;r{const{WebGPURenderer:h}=await import("./WebGPURenderer-DnAx_Qia.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,s={...i,...i.webgpu};break}else if(a==="webgl"&&vh(i.failIfMajorPerformanceCaveat??Vr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await mi(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-D9P4BJeq.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,s={...i,...i.webgl};break}else if(a==="canvas")throw s={...i},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(s),n}const Yr="8.4.0";class Xr{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Yr)}static destroy(){}}Xr.extension=k.Application;class Ah{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Yr)}destroy(){this._renderer=null}}Ah.extension={type:[k.WebGLSystem,k.WebGPUSystem],name:"initHook",priority:-10};const jr=class ys{constructor(...t){this.stage=new tt,t[0]!==void 0&&U(W,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await Th(t),ys._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return U(W,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=ys._plugins.slice(0);s.reverse(),s.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};jr._plugins=[];let qr=jr;lt.handleByList(k.Application,qr._plugins);lt.add(Xr);class Kr extends pt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return U(W,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return U(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return U(W,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return U(W,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return U(W,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}const Zr=class ws{constructor(t,e,s,n){this.uid=nt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=s,this.y1=n}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Z.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=ws.defaultTextureSize,{gradientStops:e}=this,s=Q.get().createCanvas();s.width=t,s.height=t;const n=s.getContext("2d"),r=n.createLinearGradient(0,0,ws.defaultTextureSize,1);for(let y=0;y`${n.offset}-${n.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Zr.defaultTextureSize=256;let Ye=Zr;const Sn={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Mi{constructor(t,e){this.uid=nt("fillPattern"),this.transform=new H,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Sn[e].addressModeU,t.source.style.addressModeV=Sn[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var Mh=kh,qi={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Ph=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function kh(i){var t=[];return i.replace(Ph,function(e,s,n){var r=s.toLowerCase();for(n=Bh(n),r=="m"&&n.length>2&&(t.push([s].concat(n.splice(0,2))),r="l",s=s=="m"?"l":"L");;){if(n.length==qi[r])return n.unshift(s),t.push(n);if(n.length0&&(n=s.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:st(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:a},s.push(n))}return t}class Rs{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Rs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const n=this.x-t,r=this.y-e,a=this.radius,o=s/2,h=Math.sqrt(n*n+r*r);return ha-o}getBounds(t){return t=t||new E,t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Fs{constructor(t=0,e=0,s=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=n}clone(){return new Fs(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return s*=s,n*=n,s+n<=1}strokeContains(t,e,s){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const a=s/2,o=n-a,h=r-a,l=n+a,c=r+a,d=t-this.x,f=e-this.y,g=d*d/(o*o)+f*f/(h*h),m=d*d/(l*l)+f*f/(c*c);return g>1&&m<=1}getBounds(t){return t=t||new E,t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Rh(i,t,e,s,n,r){const a=i-e,o=t-s,h=n-e,l=r-s,c=a*h+o*l,d=h*h+l*l;let f=-1;d!==0&&(f=c/d);let g,m;f<0?(g=e,m=s):f>1?(g=n,m=r):(g=e+f*h,m=s+f*l);const y=i-g,x=t-m;return y*y+x*x}class We{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let n=0,r=e.length;ne!=c>e&&t<(l-o)*((e-h)/(c-h))+o&&(s=!s)}return s}strokeContains(t,e,s){const n=s/2,r=n*n,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;hn?l:n,r=ca?c:a}return t.x=s,t.width=n-s,t.y=r,t.height=a-r,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const ci=(i,t,e,s,n,r)=>{const a=i-e,o=t-s,h=Math.sqrt(a*a+o*o);return h>=n-r&&h<=n+r};class Ls{constructor(t=0,e=0,s=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=r}getBounds(t){return t=t||new E,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Ls(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let n=t-(this.x+s),r=e-(this.y+s);const a=s*s;if(n*n+r*r<=a||(n=t-(this.x+this.width-s),n*n+r*r<=a)||(r=e-(this.y+this.height-s),n*n+r*r<=a)||(n=t-(this.x+s),n*n+r*r<=a))return!0}return!1}strokeContains(t,e,s){const{x:n,y:r,width:a,height:o,radius:h}=this,l=s/2,c=n+h,d=r+h,f=a-h*2,g=o-h*2,m=n+a,y=r+o;return(t>=n-l&&t<=n+l||t>=m-l&&t<=m+l)&&e>=d&&e<=d+g||(e>=r-l&&e<=r+l||e>=y-l&&e<=y+l)&&t>=c&&t<=c+f?!0:tm-h&&em-h&&e>y-h&&ci(t,e,m-h,y-h,h,l)||ty-h&&ci(t,e,c,y-h,h,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Fh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function Lh(i){let t="";for(let e=0;e0&&(t+=` else `),e>>=0;return Jr[e]||Uh(i,t,e)}let Ki=0;function Uh(i,t,e){const s={};let n=0;Ki||(Ki=Qr());for(let a=0;a0){const a=new Uint8Array(i,e*8,r);new Uint8Array(t,e*8,r).set(a)}}const Oh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Wh=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",i[i.NONE=4]="NONE",i))(Wh||{});function Tn(i,t){return t.alphaMode==="no-premultiply-alpha"&&Oh[i]||i}class Nh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?ta[--_s]:new Hh}function Mn(i){ta[_s++]=i}let Ee=0;const ea=class gi{constructor(t={}){this.uid=nt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],gi.defaultOptions.maxTextures=gi.defaultOptions.maxTextures??Qr(),t={...gi.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new vn(s*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const o=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,f="startBatch";const g=this.maxTextures;for(let m=this.elementStart;m=g||b)&&(this._finishBatch(s,d,c-d,n,a,t,f),f="renderBatch",d=c,a=_,s=An(),n=s.textures,n.clear(),++Ee),y._textureId=w._textureBindLocation=n.count,n.ids[w.uid]=n.count,n.textures[n.count++]=w,y._batch=s,c+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,o,h,y._attributeStart,y._textureId),this.packQuadIndex(l,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,o,h,y._attributeStart,y._textureId),this.packIndex(y,l,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,d,c-d,n,a,t,f),d=c,++Ee),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,s,n,r,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=n,t.blendMode=r,t.start=e,t.size=s,++Ee,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new vn(e);Cn(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const n=s>65535?new Uint32Array(s):new Uint16Array(s);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(it||{});class Vt extends pt{constructor(t){let{data:e,size:s}=t;const{usage:n,label:r,shrinkToFit:a}=t;super(),this.uid=nt("buffer"),this._resourceType="buffer",this._resourceId=nt("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=s??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:s,usage:n,mappedAtCreation:o,label:r},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&it.STATIC)}set static(t){t?this.descriptor.usage|=it.STATIC:this.descriptor.usage&=~it.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const n=this._data;if(this._data=t,n.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=g),m>h&&(h=m),ge.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Xh=new Float32Array(1),jh=new Uint32Array(1);class qh extends sa{constructor(){const e=new Vt({data:Xh,label:"attribute-batch-buffer",usage:it.VERTEX|it.COPY_DST,shrinkToFit:!1}),s=new Vt({data:jh,label:"index-batch-buffer",usage:it.INDEX|it.COPY_DST,shrinkToFit:!1}),n=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:5*4}},indexBuffer:s})}}function Pn(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),r=t[n];if(r){let a=i[s];s==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(a)}else st(`${s} placement hook does not exist in shader`)}}const Kh=/\{\{(.*?)\}\}/g;function kn(i){var s;const t={};return(((s=i.match(Kh))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function Gn(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Bn(i,t,e=!1){const s=[];Gn(t,s),i.forEach(o=>{o.header&&Gn(o.header,s)});const n=s;e&&n.sort();const r=n.map((o,h)=>` @location(${h}) ${o},`).join(` `);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",` ${r} `),a}function In(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Zh(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function Qh(i){const t=/@.*?\s+/g;return i.replace(t,"")}function Jh(i,t){const e=[];In(t,e),i.forEach(h=>{h.header&&In(h.header,e)});let s=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`, `),r=e.sort().map(h=>` var ${Qh(h)};`).join(` `),a=`return VSOutput( ${e.sort().map(h=>` ${Zh(h)}`).join(`, `)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",` ${n} `),o=o.replace("{{start}}",` ${r} `),o=o.replace("{{return}}",` ${a} `),o}function En(i,t){let e=i;for(const s in t){const n=t[s];n.join(` `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----// ${n.join(` `)} //----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const $t=Object.create(null),Zi=new Map;let tl=0;function el({template:i,bits:t}){const e=na(i,t);if($t[e])return $t[e];const{vertex:s,fragment:n}=sl(i,t);return $t[e]=ra(s,n,t),$t[e]}function il({template:i,bits:t}){const e=na(i,t);return $t[e]||($t[e]=ra(i.vertex,i.fragment,t)),$t[e]}function sl(i,t){const e=t.map(a=>a.vertex).filter(a=>!!a),s=t.map(a=>a.fragment).filter(a=>!!a);let n=Bn(e,i.vertex,!0);n=Jh(e,n);const r=Bn(s,i.fragment,!0);return{vertex:n,fragment:r}}function na(i,t){return t.map(e=>(Zi.has(e)||Zi.set(e,tl++),Zi.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function ra(i,t,e){const s=kn(i),n=kn(t);return e.forEach(r=>{Pn(r.vertex,s,r.name),Pn(r.fragment,n,r.name)}),{vertex:En(i,s),fragment:En(t,n)}}const nl=` @in aPosition: vec2; @in aUV: vec2; @out @builtin(position) vPosition: vec4; @out vUV : vec2; @out vColor : vec4; {{header}} struct VSOutput { {{struct}} }; @vertex fn main( {{in}} ) -> VSOutput { var worldTransformMatrix = globalUniforms.uWorldTransformMatrix; var modelMatrix = mat3x3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); var position = aPosition; var uv = aUV; {{start}} vColor = vec4(1., 1., 1., 1.); {{main}} vUV = uv; var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix; vPosition = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= globalUniforms.uWorldColorAlpha; {{end}} {{return}} }; `,rl=` @in vUV : vec2; @in vColor : vec4; {{header}} @fragment fn main( {{in}} ) -> @location(0) vec4 { {{start}} var outColor:vec4; {{main}} var finalColor:vec4 = outColor * vColor; {{end}} return finalColor; }; `,al=` in vec2 aPosition; in vec2 aUV; out vec4 vColor; out vec2 vUV; {{header}} void main(void){ mat3 worldTransformMatrix = uWorldTransformMatrix; mat3 modelMatrix = mat3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); vec2 position = aPosition; vec2 uv = aUV; {{start}} vColor = vec4(1.); {{main}} vUV = uv; mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix; gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= uWorldColorAlpha; {{end}} } `,ol=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,hl={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},ll={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};function cl({bits:i,name:t}){const e=el({template:{fragment:rl,vertex:nl},bits:[hl,...i]});return Ci.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function dl({bits:i,name:t}){return new Rr({name:t,...il({template:{vertex:al,fragment:ol},bits:[ll,...i]})})}const ul={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},fl={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Qi={};function pl(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(` `)}function gl(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @out @interpolate(flat) vTextureId : u32; `,main:` vTextureId = aTextureIdAndRound.y; `,end:` if(aTextureIdAndRound.x == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; ${pl(i)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${gl(i)} `}}),Qi[i]}const Ji={};function xl(i){const t=[];for(let e=0;e0&&t.push("else"),e, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},_l={name:"round-pixels-bit",vertex:{header:` vec2 roundPixels(vec2 position, vec2 targetSize) { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},Rn={};function bl(i){let t=Rn[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s>16&255,s=i>>8&255,n=i&255,r=t>>16&255,a=t>>8&255,o=t&255,h=e*r/255,l=s*a/255,c=n*o/255;return(h<<16)+(l<<8)+c}const Ml=new H;class la{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?Al(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||Ml}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const Xe={extension:{type:k.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,r,a,o;if(i.type==="circle"){const S=i;e=S.x,s=S.y,a=o=S.radius,n=r=0}else if(i.type==="ellipse"){const S=i;e=S.x,s=S.y,a=S.halfWidth,o=S.halfHeight,n=r=0}else{const S=i,A=S.width/2,F=S.height/2;e=S.x+A,s=S.y+F,a=o=Math.max(0,Math.min(S.radius,Math.min(A,F))),n=A-a,r=F-o}if(!(a>=0&&o>=0&&n>=0&&r>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),l=h*8+(n?4:0)+(r?4:0);if(l===0)return t;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+r,t[2]=t[4]=e-n,t[5]=t[7]=s-r,t;let c=0,d=h*4+(n?2:0)+2,f=d,g=l,m=n+a,y=r,x=e+m,w=e-m,_=s+y;if(t[c++]=x,t[c++]=_,t[--d]=_,t[--d]=w,r){const S=s-y;t[f++]=w,t[f++]=S,t[--g]=S,t[--g]=x}for(let S=1;S0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},Pl={...Xe,extension:{...Xe.extension,name:"ellipse"}},kl={...Xe,extension:{...Xe.extension,name:"roundedRectangle"}},Gl=1e-4,Ln=1e-4;function Bl(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],r=i[t-1];sd&&(d+=Math.PI*2);let f=c;const g=d-c,m=Math.abs(g),y=Math.sqrt(h*h+l*l),x=(15*m*Math.sqrt(y)/Math.PI>>0)+1,w=g/x;if(f+=w,o){a.push(i,t),a.push(e,s);for(let _=1,b=f;_=0&&(c.join==="round"?_+=Qt(v,T,v-L*I,T-R*I,v-Y*I,T-et*I,x,!1)+4:_+=2,x.push(v-Y*D,T-et*D),x.push(v+Y*I,T+et*I));continue}const qs=(-L+P)*(-R+T)-(-L+v)*(-R+G),Ks=(-Y+K)*(-et+T)-(-Y+v)*(-et+Et),Je=(Nt*Ks-Pe*qs)/Qe,ti=(ke*qs-Me*Ks)/Qe,Bi=(Je-v)*(Je-v)+(ti-T)*(ti-T),jt=v+(Je-v)*I,qt=T+(ti-T)*I,Kt=v-(Je-v)*D,Zt=T-(ti-T)*D,Ra=Math.min(Nt*Nt+Me*Me,Pe*Pe+ke*ke),Zs=Ge?I:D,Fa=Ra+Zs*Zs*A;Bi<=Fa?c.join==="bevel"||Bi/A>F?(Ge?(x.push(jt,qt),x.push(v+L*D,T+R*D),x.push(jt,qt),x.push(v+Y*D,T+et*D)):(x.push(v-L*I,T-R*I),x.push(Kt,Zt),x.push(v-Y*I,T-et*I),x.push(Kt,Zt)),_+=2):c.join==="round"?Ge?(x.push(jt,qt),x.push(v+L*D,T+R*D),_+=Qt(v,T,v+L*D,T+R*D,v+Y*D,T+et*D,x,!0)+4,x.push(jt,qt),x.push(v+Y*D,T+et*D)):(x.push(v-L*I,T-R*I),x.push(Kt,Zt),_+=Qt(v,T,v-L*I,T-R*I,v-Y*I,T-et*I,x,!1)+4,x.push(v-Y*I,T-et*I),x.push(Kt,Zt)):(x.push(jt,qt),x.push(Kt,Zt)):(x.push(v-L*I,T-R*I),x.push(v+L*D,T+R*D),c.join==="round"?Ge?_+=Qt(v,T,v+L*D,T+R*D,v+Y*D,T+et*D,x,!0)+2:_+=Qt(v,T,v-L*I,T-R*I,v-Y*I,T-et*I,x,!1)+2:c.join==="miter"&&Bi/A<=F&&(Ge?(x.push(Kt,Zt),x.push(Kt,Zt)):(x.push(jt,qt),x.push(jt,qt)),_+=2),x.push(v-Y*I,T-et*I),x.push(v+Y*D,T+et*D),_+=2)}P=i[(w-2)*2],G=i[(w-2)*2+1],v=i[(w-1)*2],T=i[(w-1)*2+1],L=-(G-T),R=P-v,St=Math.sqrt(L*L+R*R),L/=St,R/=St,L*=S,R*=S,x.push(v-L*I,T-R*I),x.push(v+L*D,T+R*D),m||(c.cap==="round"?_+=Qt(v-L*(I-D)*.5,T-R*(I-D)*.5,v-L*I,T-R*I,v+L*D,T+R*D,x,!1)+2:c.cap==="square"&&(_+=Dn(v,T,L,R,I,D,!1,x)));const Ea=Ln*Ln;for(let V=b;V<_+b-2;++V)P=x[V*2],G=x[V*2+1],v=x[(V+1)*2],T=x[(V+1)*2+1],K=x[(V+2)*2],Et=x[(V+2)*2+1],!(Math.abs(P*(T-Et)+v*(Et-G)+K*(G-T))=0&&a>=0&&(t[0]=s,t[1]=n,t[2]=s+r,t[3]=n,t[4]=s+r,t[5]=n+a,t[6]=s,t[7]=n+a),t},triangulate(i,t,e,s,n,r){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[6],t[s+a+1]=i[7],a+=e,t[s+a]=i[4],t[s+a+1]=i[5],a+=e;const o=s/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2,n[r++]=o+1,n[r++]=o+3,n[r++]=o+2}},Ll={extension:{type:k.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,t},triangulate(i,t,e,s,n,r){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[4],t[s+a+1]=i[5];const o=s/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2}},Pi={};lt.handleByMap(k.ShapeBuilder,Pi);lt.add(Fl,Rl,Ll,Xe,Pl,kl);const Dl=new E;function zl(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n{const g=h.length,m=a.length/2,y=[],x=Pi[c.type];if(x.build(c,y),d&&ha(y,d),s){const S=c.closePath??!0;Il(y,t,!1,S,a,2,m,h)}else if(e&&l===f){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],A=y.slice();Ol(e.shapePath).forEach(P=>{S.push(A.length/2),A.push(...P)}),ca(A,S,a,2,m,h,g)}else x.triangulate(y,a,2,m,h,g);const w=o.length/2,_=t.texture;if(_!==z.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),Cl(a,2,m,o,w,2,a.length/2-m,S))}else Tl(o,w,2,a.length/2-m);const b=zt.get(la);b.indexOffset=g,b.indexSize=h.length-g,b.attributeOffset=m,b.attributeSize=a.length/2-m,b.baseColor=t.color,b.alpha=t.alpha,b.texture=_,b.geometryData=r,n.push(b)})}function Ol(i){if(!i)return[];const t=i.shapePrimitives,e=[];for(let s=0;s{zt.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Ds.extension={type:[k.WebGLSystem,k.WebGPUSystem,k.CanvasSystem],name:"graphicsContext"};Ds.defaultOptions={bezierSmoothness:.5};let da=Ds;const Hl=8,di=11920929e-14,$l=1;function ua(i,t,e,s,n,r,a,o,h,l){const d=Math.min(.99,Math.max(0,l??da.defaultOptions.bezierSmoothness));let f=($l-d)/1;return f*=f,Vl(t,e,s,n,r,a,o,h,i,f),i}function Vl(i,t,e,s,n,r,a,o,h,l){Ss(i,t,e,s,n,r,a,o,h,l,0),h.push(a,o)}function Ss(i,t,e,s,n,r,a,o,h,l,c){if(c>Hl)return;const d=(i+e)/2,f=(t+s)/2,g=(e+n)/2,m=(s+r)/2,y=(n+a)/2,x=(r+o)/2,w=(d+g)/2,_=(f+m)/2,b=(g+y)/2,S=(m+x)/2,A=(w+b)/2,F=(_+S)/2;if(c>0){let P=a-i,G=o-t;const v=Math.abs((e-a)*G-(s-o)*P),T=Math.abs((n-a)*G-(r-o)*P);if(v>di&&T>di){if((v+T)*(v+T)<=l*(P*P+G*G)){h.push(A,F);return}}else if(v>di){if(v*v<=l*(P*P+G*G)){h.push(A,F);return}}else if(T>di){if(T*T<=l*(P*P+G*G)){h.push(A,F);return}}else if(P=A-(i+a)/2,G=F-(t+o)/2,P*P+G*G<=l){h.push(A,F);return}}Ss(i,t,d,f,w,_,A,F,h,l,c+1),Ss(A,F,b,S,y,x,a,o,h,l,c+1)}const Yl=8,Xl=11920929e-14,jl=1;function ql(i,t,e,s,n,r,a,o){const l=Math.min(.99,Math.max(0,o??da.defaultOptions.bezierSmoothness));let c=(jl-l)/1;return c*=c,Kl(t,e,s,n,r,a,i,c),i}function Kl(i,t,e,s,n,r,a,o){vs(a,i,t,e,s,n,r,o,0),a.push(n,r)}function vs(i,t,e,s,n,r,a,o,h){if(h>Yl)return;const l=(t+s)/2,c=(e+n)/2,d=(s+r)/2,f=(n+a)/2,g=(l+d)/2,m=(c+f)/2;let y=r-t,x=a-e;const w=Math.abs((s-r)*x-(n-a)*y);if(w>Xl){if(w*w<=o*(y*y+x*x)){i.push(g,m);return}}else if(y=g-(t+r)/2,x=m-(e+a)/2,y*y+x*x<=o){i.push(g,m);return}vs(i,t,e,l,c,g,m,o,h+1),vs(i,g,m,d,f,r,a,o,h+1)}function fa(i,t,e,s,n,r,a,o){let h=Math.abs(n-r);(!a&&n>r||a&&r>n)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI))),o=Math.max(o,3);let l=h/o,c=n;l*=a?-1:1;for(let d=0;dd*h)}const Ne=Math.PI*2,ts={centerX:0,centerY:0,ang1:0,ang2:0},es=({x:i,y:t},e,s,n,r,a,o,h)=>{i*=e,t*=s;const l=n*i-r*t,c=r*i+n*t;return h.x=l+a,h.y=c+o,h};function Ql(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),r=Math.sin(i),a=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*s,y:r+n*s},{x:a+o*s,y:o-a*s},{x:a,y:o}]}const Un=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let r=i*e+t*s;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},Jl=(i,t,e,s,n,r,a,o,h,l,c,d,f)=>{const g=Math.pow(n,2),m=Math.pow(r,2),y=Math.pow(c,2),x=Math.pow(d,2);let w=g*m-g*x-m*y;w<0&&(w=0),w/=g*x+m*y,w=Math.sqrt(w)*(a===o?-1:1);const _=w*n/r*d,b=w*-r/n*c,S=l*_-h*b+(i+e)/2,A=h*_+l*b+(t+s)/2,F=(c-_)/n,P=(d-b)/r,G=(-c-_)/n,v=(-d-b)/r,T=Un(1,0,F,P);let K=Un(F,P,G,v);o===0&&K>0&&(K-=Ne),o===1&&K<0&&(K+=Ne),f.centerX=S,f.centerY=A,f.ang1=T,f.ang2=K};function tc(i,t,e,s,n,r,a,o=0,h=0,l=0){if(r===0||a===0)return;const c=Math.sin(o*Ne/360),d=Math.cos(o*Ne/360),f=d*(t-s)/2+c*(e-n)/2,g=-c*(t-s)/2+d*(e-n)/2;if(f===0&&g===0)return;r=Math.abs(r),a=Math.abs(a);const m=Math.pow(f,2)/Math.pow(r,2)+Math.pow(g,2)/Math.pow(a,2);m>1&&(r*=Math.sqrt(m),a*=Math.sqrt(m)),Jl(t,e,s,n,r,a,h,l,c,d,f,g,ts);let{ang1:y,ang2:x}=ts;const{centerX:w,centerY:_}=ts;let b=Math.abs(x)/(Ne/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);x/=S;let A=i[i.length-2],F=i[i.length-1];const P={x:0,y:0};for(let G=0;G{const h=o.x-a.x,l=o.y-a.y,c=Math.sqrt(h*h+l*l),d=h/c,f=l/c;return{len:c,nx:d,ny:f}},n=(a,o)=>{a===0?i.moveTo(o.x,o.y):i.lineTo(o.x,o.y)};let r=t[t.length-1];for(let a=0;a0&&(g=-1,m=!0);const y=f/2;let x,w=Math.abs(Math.cos(y)*h/Math.sin(y));w>Math.min(c.len/2,d.len/2)?(w=Math.min(c.len/2,d.len/2),x=Math.abs(w*Math.sin(y)/Math.cos(y))):x=h;const _=o.x+d.nx*w+-d.ny*x*g,b=o.y+d.ny*w+d.nx*x*g,S=Math.atan2(c.ny,c.nx)+Math.PI/2*g,A=Math.atan2(d.ny,d.nx)-Math.PI/2*g;a===0&&i.moveTo(_+Math.cos(S)*x,b+Math.sin(S)*x),i.arc(_,b,x,S,A,m),r=o}}function ic(i,t,e,s){const n=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),r=(o,h,l)=>({x:o.x+(h.x-o.x)*l,y:o.y+(h.y-o.y)*l}),a=t.length;for(let o=0;o=2;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,a)}ellipse(t,e,s,n,r){return this.drawShape(new Fs(t,e,s,n),r),this}roundRect(t,e,s,n,r,a){return this.drawShape(new Ls(t,e,s,n,r),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new We,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new We,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,a=s;s=r.a*s+r.c*n+r.tx,n=r.b*a+r.d*n+r.ty}this._currentPoly.points.push(s,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;eparseInt(G,10)),t.context.poly(_,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=i.getAttribute("points"),_=b.match(/\d+/g).map(G=>parseInt(G,10)),t.context.poly(_,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}for(let G=0;G{this._fill=ne({...this._originalFill},xt.defaultFillStyle)})),this._fill=ne(t===0?"black":t,xt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...xt.defaultStrokeStyle,...t},()=>{this._stroke=_i({...this._originalStroke},xt.defaultStrokeStyle)})),this._stroke=_i(t,xt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=dc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=de.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new de({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var s,n,r,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(s=this._fill)!=null&&s.texture&&this._fill.texture.destroy(o),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(o),(r=this._stroke)!=null&&r.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,n,r)=>(s[n]=r,e==null||e(n,r),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Z.isColorLike(t)||t instanceof Ye||t instanceof Mi)}};Us.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Us.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let N=Us;function pc(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=N.defaultDropShadow;i.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){U(W,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Z.isColorLike(e))s.color=e;else if(e instanceof Ye||e instanceof Mi)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){U(W,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;i.fontSize==null?i.fontSize=N.defaultTextStyle.fontSize:typeof i.fontSize=="string"?e=parseInt(i.fontSize,10):e=i.fontSize;const s=new Ye(0,0,0,e*1.7),n=t.fillGradientStops.map(r=>Z.shared.setValue(r).toNumber());n.forEach((r,a)=>{const o=a/(n.length-1);s.addColorStop(o,r)}),i.fill={fill:s}}}class gc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=Q.get().createCanvas();s.width=t,s.height=e;const n=s.getContext("2d");return{canvas:s,context:n}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=tn(t),e=tn(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,r=(s<<17)+(n<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const Yn=new gc,mc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Cs(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let n=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!mc.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const is={willReadFrequently:!0},At=class M{static get experimentalLetterSpacingSupported(){let t=M._experimentalLetterSpacingSupported;if(t!==void 0){const e=Q.get().getCanvasRenderingContext2D().prototype;t=M._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,r,a,o,h,l){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=r,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,s=M._canvas,n=e.wordWrap){var _;const r=`${t}:${e.styleKey}`;if(M._measurementCache[r])return M._measurementCache[r];const a=Cs(e),o=M.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=M.__context;h.font=a;const c=(n?M._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),d=new Array(c.length);let f=0;for(let b=0;b0&&(n?r-=e:r+=(M.graphemeSegmenter(t).length-1)*e),r}static _wordWrap(t,e,s=M._canvas){const n=s.getContext("2d",is);let r=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,d=M._collapseSpaces(c),f=M._collapseNewlines(c);let g=!d;const m=e.wordWrapWidth+l,y=M._tokenize(t);for(let x=0;xm)if(a!==""&&(o+=M._addLine(a),a="",r=0),M.canBreakWords(w,e.breakWords)){const b=M.wordWrapSplit(w);for(let S=0;Sm&&(o+=M._addLine(a),g=!1,a="",r=0),a+=A,r+=G}}else{a.length>0&&(o+=M._addLine(a),a="",r=0);const b=x===y.length-1;o+=M._addLine(w,!b),g=!1,a="",r=0}else _+r>m&&(g=!1,o+=M._addLine(a),a="",r=0),(a.length>0||!M.isBreakingSpace(w)||g)&&(a+=w,r+=_)}return o+=M._addLine(a,!1),o}static _addLine(t,e=!0){return t=M._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,s,n){let r=s[t];return typeof r!="number"&&(r=M._measureText(t,e,n)+e,s[t]=r),r}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!M.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:M._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:M._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let n=0;n{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})();At.experimentalLetterSpacing=!1;At._fonts={};At._newlines=[10,13];At._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];At._measurementCache={};let Ts=At;function Xn(i,t){if(i.texture===z.WHITE&&!i.fill)return Z.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Mi){const e=i.fill,s=t.createPattern(e.texture.source.resource,"repeat"),n=e.transform.copyTo(H.shared);return n.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(n),s}else if(i.fill instanceof Ye){const e=i.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(n=>{s.addColorStop(n.offset,Z.shared.setValue(n.color).toHex())}),s}}}else{const e=t.createPattern(i.texture.source.resource,"repeat"),s=i.matrix.copyTo(H.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),e.setTransform(s),e}return st("FillStyle not recognised",i),"red"}function ma(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e!this._currentChars.includes(w)).filter((w,_,b)=>b.indexOf(w)===_);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:n,context:r}=s.canvasAndContext,a=s.texture.source;const o=this._style;let h=this._currentX,l=this._currentY;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c,f=o.fontStyle==="italic"?2:1;let g=0,m=!1;for(let w=0;wthis._textureSize&&(l+=g,g=P,h=0,l+g>this._textureSize)){a.update();const v=this._nextPage();n=v.canvasAndContext.canvas,r=v.canvasAndContext.context,a=v.texture.source,l=0}const G=S/c-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((x=o._stroke)==null?void 0:x.width)??0);if(this.chars[_]={id:_.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:G,kerning:{}},m){this._drawGlyph(r,b,h+d,l+d,c,o);const v=a.width*c,T=a.height*c,K=new E(h/v*a.width,l/T*a.height,F/v*a.width,P/T*a.height);this.chars[_].texture=new z({source:a,frame:K}),h+=Math.ceil(F)}}a.update(),this._currentX=h,this._currentY=l,this._skipKerning&&this._applyKerning(e,r)}get pageTextures(){return U(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const s=this._measureCache;for(let n=0;n{const y=r.width;for(let x=0;x{let m=r.chars.length-1;if(s){let y=r.chars[m];for(;y===" ";)r.width-=e.chars[y].xAdvance,y=r.chars[--m]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,n.lines.push(r),n.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,f=t.letterSpacing*d,g=t.wordWrapWidth*d;for(let m=0;mg?(c(),l(h),x||r.charPositions.push(0)):(h.start=r.width,l(h),x||r.charPositions.push(0)),y==="\r"||y===` `)r.width!==0&&c();else if(!x){const A=w.xAdvance+(w.kerning[a]||0)+f;r.width+=A,r.spaceWidth=A,r.spacesIndex.push(r.charPositions.length),r.chars.push(y)}}else{const S=w.kerning[a]||0,A=w.xAdvance+S+f;h.positions[h.index++]=h.width+S,h.chars.push(y),h.width+=A}a=y}return c(),t.align==="center"?yc(n):t.align==="right"?wc(n):t.align==="justify"&&_c(n),n}function yc(i){for(let t=0;t50&&st("BitmapText",`You have dynamically created ${ui} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{ui--,j.remove(s)}),j.set(s,o)}const r=j.get(s);return(a=r.ensureCharacters)==null||a.call(r,t),r}getLayout(t,e,s=!0){const n=this.getFont(t,e);return xc([...t],e,n,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var l,c,d,f;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(l=t[2])==null?void 0:l.chars,resolution:(c=t[2])==null?void 0:c.resolution,padding:(d=t[2])==null?void 0:d.padding,skipKerning:(f=t[2])==null?void 0:f.skipKerning},U(W,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=e==null?void 0:e.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const n=e.style,r=n instanceof N?n:new N(n),a=r._fill.fill!==null&&r._fill.fill!==void 0,o=new jn({style:r,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=ma(e.chars);return o.ensureCharacters(h.join("")),j.set(`${s}-bitmap`,o),o.once("destroy",()=>j.remove(`${s}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,s=j.get(e);s&&(j.remove(e),s.destroy())}}const qn=new bc;class wa extends Kr{constructor(t,e){super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(r=>{const a=n.pages[parseInt(r,10)],o=s[a.id];this.pages.push({texture:o})}),Object.keys(n.chars).forEach(r=>{const a=n.chars[r],{frame:o,source:h}=s[a.page],l=new E(a.x+o.x,a.y+o.y,a.width,a.height),c=new z({source:h,frame:l});this.chars[r]={id:r.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:c}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?Kn.test(Q.get().parseXML(i)):!1},parse(i){return Kn.parse(Q.get().parseXML(i))}},Sc=[".xml",".fnt"],vc={extension:{type:k.CacheParser,name:"cacheBitmapFont"},test:i=>i instanceof wa,getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Cc={extension:{type:k.LoadParser,priority:Xt.Normal},name:"loadBitmapFont",test(i){return Sc.includes(mt.extname(i).toLowerCase())},async testParse(i){return ss.test(i)||Zn.test(i)},async parse(i,t,e){const s=ss.test(i)?ss.parse(i):Zn.parse(i),{src:n}=t,{pages:r}=s,a=[],o=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;dh[d.src]);return new wa({data:s,textures:l},n)},async load(i,t){return await(await Q.get().fetch(i)).text()},async unload(i,t,e){await Promise.all(i.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),i.destroy()}};class Tc{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;sArray.isArray(i)&&i.every(t=>t instanceof z),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((n,r)=>{e[s+(r===0?"":r+1)]=n})}),e}};async function _a(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Mc={extension:{type:k.DetectionParser,priority:1},test:async()=>_a("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},Qn=["png","jpg","jpeg"],Pc={extension:{type:k.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...Qn],remove:async i=>i.filter(t=>!Qn.includes(t))},kc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Os(i){return kc?!1:document.createElement("video").canPlayType(i)!==""}const Gc={extension:{type:k.DetectionParser,priority:0},test:async()=>Os("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},Bc={extension:{type:k.DetectionParser,priority:0},test:async()=>Os("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},Ic={extension:{type:k.DetectionParser,priority:0},test:async()=>Os("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Ec={extension:{type:k.DetectionParser,priority:0},test:async()=>_a("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};class Rc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var a,o;let n=null,r=null;if(e.loadParser&&(r=this._parserHash[e.loadParser],r||st(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!r){for(let h=0;h({alias:[l],src:l,data:{}})),o=a.length,h=a.map(async l=>{const c=mt.toAbsolute(l.src);if(!n[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),n[l.src]=await this.promiseCache[c].promise,e&&e(++s/o)}catch(d){throw delete this.promiseCache[c],delete n[l.src],new Error(`[Loader.load] Failed to load ${c}. ${d}`)}});return await Promise.all(h),r?n[a[0].src]:n}async unload(t){const s=Ct(t,n=>({alias:[n],src:n})).map(async n=>{var o,h;const r=mt.toAbsolute(n.src),a=this.promiseCache[r];if(a){const l=await a.promise;delete this.promiseCache[r],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,l,n,this))}});await Promise.all(s)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&st(`[Assets] loadParser name conflict "${e.name}"`):st("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function Te(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function Ae(i,t){const e=i.split("?")[0],s=mt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const Fc=".json",Lc="application/json",Dc={extension:{type:k.LoadParser,priority:Xt.Low},name:"loadJson",test(i){return Te(i,Lc)||Ae(i,Fc)},async load(i){return await(await Q.get().fetch(i)).json()}},zc=".txt",Uc="text/plain",Oc={name:"loadTxt",extension:{type:k.LoadParser,priority:Xt.Low,name:"loadTxt"},test(i){return Te(i,Uc)||Ae(i,zc)},async load(i){return await(await Q.get().fetch(i)).text()}},Wc=["normal","bold","100","200","300","400","500","600","700","800","900"],Nc=[".ttf",".otf",".woff",".woff2"],Hc=["font/ttf","font/otf","font/woff","font/woff2"],$c=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Vc(i){const t=mt.extname(i),n=mt.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let r=n.length>0;for(const o of n)if(!o.match($c)){r=!1;break}let a=n.join(" ");return r||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const Yc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Xc(i){return Yc.test(i)?i:encodeURI(i)}const jc={extension:{type:k.LoadParser,priority:Xt.Low},name:"loadWebFont",test(i){return Te(i,Hc)||Ae(i,Nc)},async load(i,t){var s,n,r;const e=Q.get().getFontFaceSet();if(e){const a=[],o=((s=t.data)==null?void 0:s.family)??Vc(i),h=((r=(n=t.data)==null?void 0:n.weights)==null?void 0:r.filter(c=>Wc.includes(c)))??["normal"],l=t.data??{};for(let c=0;c{j.remove(t.family),Q.get().getFontFaceSet().delete(t)})}};function Ws(i,t=1){var s;const e=(s=Ce.RETINA_PREFIX)==null?void 0:s.exec(i);return e?parseFloat(e[1]):t}function Ns(i,t,e){i.label=e,i._sourceOrigin=e;const s=new z({source:i,label:e}),n=()=>{delete t.promiseCache[e],j.has(e)&&j.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(st("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),n())}),s.once("destroy",()=>{i.destroyed||(st("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),s}const qc=".svg",Kc="image/svg+xml",Zc={extension:{type:k.LoadParser,priority:Xt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return Te(i,Kc)||Ae(i,qc)},async load(i,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Jc(i):Qc(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function Qc(i,t,e,s){var x,w,_;const r=await(await Q.get().fetch(i)).blob(),a=URL.createObjectURL(r),o=new Image;o.src=a,o.crossOrigin=s,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),l=h.getContext("2d"),c=((x=t.data)==null?void 0:x.resolution)||Ws(i),d=((w=t.data)==null?void 0:w.width)??o.width,f=((_=t.data)==null?void 0:_.height)??o.height;h.width=d*c,h.height=f*c,l.drawImage(o,0,0,d*c,f*c);const{parseAsGraphicsContext:g,...m}=t.data,y=new ve({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:c,...m});return Ns(y,e,i)}async function Jc(i){const e=await(await Q.get().fetch(i)).text(),s=new xt;return s.svg(e),s}const td=`(function () { 'use strict'; const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII="; async function checkImageBitmap() { try { if (typeof createImageBitmap !== "function") return false; const response = await fetch(WHITE_PNG); const imageBlob = await response.blob(); const imageBitmap = await createImageBitmap(imageBlob); return imageBitmap.width === 1 && imageBitmap.height === 1; } catch (e) { return false; } } void checkImageBitmap().then((result) => { self.postMessage(result); }); })(); `;let fe=null,As=class{constructor(){fe||(fe=URL.createObjectURL(new Blob([td],{type:"application/javascript"}))),this.worker=new Worker(fe)}};As.revokeObjectURL=function(){fe&&(URL.revokeObjectURL(fe),fe=null)};const ed=`(function () { 'use strict'; async function loadImageBitmap(url, alphaMode) { const response = await fetch(url); if (!response.ok) { throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`); } const imageBlob = await response.blob(); return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob); } self.onmessage = async (event) => { try { const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]); self.postMessage({ data: imageBitmap, uuid: event.data.uuid, id: event.data.id }, [imageBitmap]); } catch (e) { self.postMessage({ error: e, uuid: event.data.uuid, id: event.data.id }); } }; })(); `;let pe=null;class ba{constructor(){pe||(pe=URL.createObjectURL(new Blob([ed],{type:"application/javascript"}))),this.worker=new Worker(pe)}}ba.revokeObjectURL=function(){pe&&(URL.revokeObjectURL(pe),pe=null)};let Jn=0,ns;class id{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new As;e.addEventListener("message",s=>{e.terminate(),As.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){ns===void 0&&(ns=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((n,r)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:r})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[Jn]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Jn++,id:s})}}const tr=new id,sd=[".jpeg",".jpg",".png",".webp",".avif"],nd=["image/jpeg","image/png","image/webp","image/avif"];async function rd(i,t){var n;const e=await Q.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return((n=t==null?void 0:t.data)==null?void 0:n.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const Sa={name:"loadTextures",extension:{type:k.LoadParser,priority:Xt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Te(i,nd)||Ae(i,sd)},async load(i,t,e){var r;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await tr.isImageBitmapSupported()?s=await tr.loadImageBitmap(i,t):s=await rd(i,t):s=await new Promise(a=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=i,s.complete?a(s):s.onload=()=>{a(s)}});const n=new ve({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((r=t.data)==null?void 0:r.resolution)||Ws(i),...t.data});return Ns(n,e,i)},unload(i){i.destroy(!0)}},va=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],ad=va.map(i=>`video/${i.substring(1)}`);function od(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=ld(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function hd(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",n),i.load();function s(){r(),t()}function n(a){r(),e(a)}function r(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",n)}})}function ld(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const cd={name:"loadVideo",extension:{type:k.LoadParser,name:"loadVideo"},test(i){const t=Te(i,ad),e=Ae(i,va);return t||e},async load(i,t,e){var h,l;const s={...fi.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Ws(i),alphaMode:((l=t.data)==null?void 0:l.alphaMode)||await Ar(),...t.data},n=document.createElement("video"),r={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(r).forEach(c=>{const d=r[c];d!==void 0&&n.setAttribute(c,d)}),s.muted===!0&&(n.muted=!0),od(n,i,s.crossorigin);const a=document.createElement("source");let o;if(i.startsWith("data:"))o=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){const c=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();o=fi.MIME_TYPES[c]||`video/${c}`}return a.src=i,o&&(a.type=o),new Promise(c=>{const d=async()=>{const f=new fi({...s,resource:n});n.removeEventListener("canplay",d),t.data.preload&&await hd(n),c(Ns(f,e,i))};n.addEventListener("canplay",d),n.appendChild(a)})},unload(i){i.destroy(!0)}},Ca={extension:{type:k.ResolveParser,name:"resolveTexture"},test:Sa.test,parse:i=>{var t;return{resolution:parseFloat(((t=Ce.RETINA_PREFIX.exec(i))==null?void 0:t[1])??"1"),format:i.split(".").pop(),src:i}}},dd={extension:{type:k.ResolveParser,priority:-2,name:"resolveJson"},test:i=>Ce.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:Ca.parse};class ud{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Ce,this.loader=new Rc,this.cache=j,this._backgroundLoader=new Tc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var r,a;if(this._initialized){st("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((r=t.texturePreference)==null?void 0:r.resolution)??1,s=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:s}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=wi(t),n=Ct(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(l=>!this.resolver.hasKey(l))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),r=this.resolver.resolve(n),a=await this._mapLoadToResolve(r,e);return s?a[n[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const n=this.resolver.resolveBundle(t),r={},a=Object.keys(n);let o=0,h=0;const l=()=>{e==null||e(++o/h)},c=a.map(d=>{const f=n[d];return h+=Object.keys(f).length,this._mapLoadToResolve(f,l).then(g=>{r[d]=g})});return await Promise.all(c),s?r[t[0]]:r}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return j.get(t);const e={};for(let s=0;s{const o=n[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(l=>{r[l]=o}),j.set(h,o)}),r}async unload(t){this._initialized||await this.init();const e=Ct(t).map(n=>typeof n!="string"?n.src:n),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=Ct(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{j.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,n)=>e.indexOf(s)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Ue=new ud;lt.handleByList(k.LoadParser,Ue.loader.parsers).handleByList(k.ResolveParser,Ue.resolver.parsers).handleByList(k.CacheParser,Ue.cache.parsers).handleByList(k.DetectionParser,Ue.detections);lt.add(Ac,Pc,Mc,Ec,Gc,Bc,Ic,Dc,Oc,jc,Zc,Sa,cd,Cc,vc,Ca,dd);const er={loader:k.LoadParser,resolver:k.ResolveParser,cache:k.CacheParser,detection:k.DetectionParser};lt.handle(k.Asset,i=>{const t=i.ref;Object.entries(er).filter(([e])=>!!t[e]).forEach(([e,s])=>lt.add(Object.assign(t[e],{extension:t[e].extension??s})))},i=>{const t=i.ref;Object.keys(er).filter(e=>!!t[e]).forEach(e=>lt.remove(t[e]))});class Tt extends Si{constructor(t){t instanceof xt&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new xt,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new Tt(this._context.clone()):(this._ownedContext=null,new Tt(this._context))}lineStyle(t,e,s){U(W,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){U(W,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){U(W,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==xt.defaultStrokeStyle.width||t.color!==xt.defaultStrokeStyle.color||t.alpha!==xt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return U(W,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return U(W,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return U(W,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return U(W,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return U(W,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return U(W,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Ta=class Aa extends sa{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(U(W,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...Aa.defaultOptions,...e};const s=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),r=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Vt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),h=new Vt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),l=new Vt({data:r,label:"index-mesh-buffer",shrinkToFit:a,usage:it.INDEX|it.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:l,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Ta.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let fd=Ta;class we extends ${constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:s,autoUpdate:n,...r}=e,[a]=s;super({...r,texture:a instanceof z?a:a.texture}),this._textures=null,this._durations=null,this._autoUpdate=n??!0,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=s}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Bt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Bt.shared.add(this.update,this,yi.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,s=this.animationSpeed*e,n=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=s/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=s;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramen)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;sthis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Bt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Bt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class pd extends Si{constructor(t,e){const{text:s,resolution:n,style:r,anchor:a,width:o,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new ft({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=l??!1,o!==void 0&&(this.width=o),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-s*this.anchor.y,t.y>=r&&t.y<=r+s)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function gd(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(U(W,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class O extends pd{constructor(...t){const e=gd(t,"Text");super(e,N),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=Ts.measureText(this._text,this._style),{width:n,height:r}=s;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}}const Ma=class Pa extends fd{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(U(W,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(t){t={...Pa.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;const e=this.verticesX*this.verticesY,s=[],n=[],r=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,l=this.height/o;for(let d=0;de?1:this.width/e,n=this._topHeight+this._bottomHeight,r=this.height>n?1:this.height/n,a=Math.min(s,r);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};ka.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ce=ka;const Ba=class Ia extends Si{constructor(t){var d,f,g,m;t instanceof z&&(t={texture:t});const{width:e,height:s,leftWidth:n,rightWidth:r,topHeight:a,bottomHeight:o,texture:h,roundPixels:l,...c}=t;super({label:"NineSliceSprite",...c}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=n??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.left)??ce.defaultOptions.leftWidth,this._topHeight=a??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.top)??ce.defaultOptions.topHeight,this._rightWidth=r??((g=h==null?void 0:h.defaultBorders)==null?void 0:g.right)??ce.defaultOptions.rightWidth,this._bottomHeight=o??((m=h==null?void 0:h.defaultBorders)==null?void 0:m.bottom)??ce.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??ce.defaultOptions.width,this.bounds.maxY=this._height=s??h.height??ce.defaultOptions.height,this.allowChildren=!1,this.texture=h??Ia.defaultOptions.texture,this.roundPixels=l??!1}get bounds(){return this._bounds}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=this._height=t,this.onViewUpdate()}setSize(t,e){typeof t=="object"&&(e=t.height??t.width,t=t.width),this.bounds.maxX=this._width=t,this.bounds.maxY=this._height=e??t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=z.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null}};Ba.defaultOptions={texture:z.EMPTY};let bt=Ba;lt.add(Oa,Wa);const B=class B{static async Load(t){return this.text.text="Loading asset: "+t,await Ue.load({src:t})}static async LoadAssets(){if(this.text){console.warn("Do not call GameAssets.LoadAssets() more than once.");return}console.log("Loading Texture Assets");const t=new O({text:"Loading textures. This might take a while.",style:new N({fill:3355443,fontSize:50})});t.x=u.app.canvas.width/2,t.y=u.app.canvas.height/2,t.anchor.set(.5,.5),u.app.stage.addChild(t),this.text=new O({text:"",style:new N({fill:3355443,fontSize:50})}),this.text.x=u.app.canvas.width/2,this.text.y=u.app.canvas.height/2+50,this.text.anchor.set(.5,.5),u.app.stage.addChild(this.text),await Promise.all([this.Load("./aclonica.woff2"),this.Load("./assets/gui/button_01.png").then(e=>this.Button01Texture=e),this.Load("./assets/gui/button_02.png").then(e=>this.Button02Texture=e),this.Load("./assets/gui/button_small.png").then(e=>this.ButtonSmallTexture=e),this.Load("./assets/gui/frame_01.png").then(e=>this.Frame01Texture=e),this.Load("./assets/gui/frame_02.png").then(e=>this.Frame02Texture=e),this.Load("./assets/gui/frame_03.png").then(e=>this.Frame03Texture=e),this.Load("./assets/gui/frame_04.png").then(e=>this.Frame04Texture=e),this.Load("./assets/gui/frame_05.png").then(e=>this.Frame05Texture=e),this.Load("./assets/gui/frame_inv.png").then(e=>this.FrameInventory=e),this.Load("./assets/gui/background_01.png").then(e=>this.FrameBackground=e),this.Load("./assets/gui/background_02.png").then(e=>this.FrameTowerTab=e),this.Load("./assets/gui/frame_violet.png").then(e=>this.VioletBackground=e),this.Load("./assets/gui/frame_red.png").then(e=>this.RedBackground=e),this.Load("./assets/gui/frame_green.png").then(e=>this.GreenBackground=e),this.Load("./assets/gui/frame_blue.png").then(e=>this.BlueBackground=e),this.Load("./assets/gui/frame_yellow.png").then(e=>this.YellowBackground=e),this.Load("./assets/gui/banner_01.png").then(e=>this.BannerGemsmith=e),this.Load("./assets/gui/note.png").then(e=>this.EndScreenDialog=e),this.Load("./assets/gui/main_background.jpg").then(e=>this.MainBackground=e),this.Load("./assets/tutorial/tutorial01.jpg").then(e=>this.Tutorial01=e),this.Load("./assets/tutorial/tutorial02.jpg").then(e=>this.Tutorial02=e),this.Load("./assets/tutorial/tutorial03.jpg").then(e=>this.Tutorial03=e),this.Load("./assets/tutorial/tutorial04.jpg").then(e=>this.Tutorial04=e),this.Load("./assets/tutorial/tutorial05.jpg").then(e=>this.Tutorial05=e),this.Load("./assets/gui/heart.png").then(e=>this.HealthTexture=e),this.Load("./assets/gui/money.png").then(e=>this.GoldTexture=e),this.Load("./assets/gui/wave.png").then(e=>this.WaveTexture=e),this.Load("./assets/gui/sword_02.png").then(e=>this.SwordsTexture=e),this.Load("./assets/gui/title01.png").then(e=>this.TitleTexture=e),this.Load("./assets/gui/icons/play.png").then(e=>this.PlayIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/fastforward.png").then(e=>this.FastForwardIconTexture=e),this.Load("./assets/gui/icons/home.png").then(e=>this.HomeIconTexture=e),this.Load("./assets/gui/icons/hammer.png").then(e=>this.HammerIconTexture=e),this.Load("./assets/gui/icons/cross.png").then(e=>this.XIconTexture=e),this.Load("./assets/gui/icons/plus.png").then(e=>this.PlusIconTexture=e),this.LoadMissions(),this.LoadTowers(),this.LoadCreeps(),this.LoadGems()]),t.destroy(),this.text.destroy(),this.text=!0}static async LoadGems(){const e=await(await fetch("./assets/json/Gems.json")).json();this.Gems=e;for(let s=0;s(i[i.Restricted=0]="Restricted",i[i.Buildable=1]="Buildable",i[i.Path=9]="Path",i))(Dt||{}),je=(i=>(i[i.Basic=0]="Basic",i[i.Circle=1]="Circle",i[i.Electric=2]="Electric",i[i.Buff=3]="Buff",i[i.Strong=4]="Strong",i[i.Rail=5]="Rail",i[i.Trapper=6]="Trapper",i[i.Debuff=7]="Debuff",i))(je||{});const J=class J{static TestSuite(){if(new URLSearchParams(location.href).entries().next().value[1]!="game")return;J.NotificationManager.Notify("Loaded testing suite.","danger");let e=C.Towers[je.Electric];J.TowerManager.ToggleChoosingTowerLocation("RESET"),J.TowerManager.PlaceTower(e,6,10,e.behaviour,!0);for(let s=0;s<29;s++)this.GameScene.MissionStats.giveGem(new Ms(s%4),!0)}};p(J,"app"),p(J,"GameMaster"),p(J,"Grid"),p(J,"WaveManager"),p(J,"TowerManager"),p(J,"AnimationManager"),p(J,"NotificationManager"),p(J,"DebrisManager"),p(J,"GameScene"),p(J,"latestCommit"),p(J,"latestGemId",0),p(J,"GridCellSize",64),p(J,"GridColumns",25),p(J,"GridRows",17),p(J,"MouseX",0),p(J,"MouseY",0);let u=J;class xd{constructor(){p(this,"currentScene");u.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),u.GameMaster.currentScene.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),u.GameMaster.currentScene.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.currentScene=t,this.currentScene.init()}}class Mt{constructor(t){p(this,"name",this.constructor.name);p(this,"_container",new tt);p(this,"_events",new pt);p(this,"enabled",!0);p(this,"bb",new E);u.GameMaster._CreateGuiObject(this),t&&(this._container.interactive=!0,this._container.onwheel=e=>{this.enabled&&this.onWheel(e)},this._container.onpointerdown=e=>{this.enabled&&this.onClick(e)})}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}onClick(t){console.warn(`[${this.name} does not implement GuiObject.onClick()]`)}onWheel(t){console.warn(`[${this.name} does not implement GuiObject.onWheel()]`)}setEnabled(t){this.enabled=t}copyContainerToBB(){return this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var ot=(i=>(i[i.Button01=0]="Button01",i[i.Button02=1]="Button02",i))(ot||{});class ct extends Mt{constructor(e,s,n,r=!0){super(!0);p(this,"caption");p(this,"bounds");p(this,"buttonTexture");p(this,"buttonSprite");p(this,"buttonText");p(this,"buttonIcon");n==0&&(this.buttonTexture=C.Button01Texture),n==1&&(this.buttonTexture=C.Button02Texture),this.caption=s,this.enabled=r,this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.container.width=this.bounds.width,this.container.height=this.bounds.height,this.buttonSprite=new bt({texture:this.buttonTexture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.buttonSprite.x=0,this.buttonSprite.y=0,this.buttonSprite.width=this.bounds.width,this.buttonSprite.height=this.bounds.height,this.container.addChild(this.buttonSprite),this.buttonText=new O({text:this.caption,style:new N({fill:16777215,fontSize:24})}),this.container.addChild(this.buttonText),this.buttonText.anchor.set(.5,.5),this.buttonText.x=this.bounds.width/2,this.buttonText.y=this.bounds.height/2,this.container.x=this.bounds.x,this.container.y=this.bounds.y}setCaption(e){this.caption=e,this.buttonText.text=e}getCaption(){return this.caption}CustomButtonLogic(){console.warn(this.name+" - Button.CustomButtonLogic() is not implemented.")}}class ki{constructor(){p(this,"stage",new tt);p(this,"gui",[]);p(this,"_events",new pt);u.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this._events.removeAllListeners(),this.gui.forEach(t=>{t.destroy()})}addMainBackground(){const t=new $(C.MainBackground);t.width=u.app.canvas.width,t.height=u.app.canvas.height,this.stage.addChild(t)}get events(){return this._events}init(){}}class yd extends ki{constructor(){super(...arguments);p(this,"currentImg",1);p(this,"sprite")}init(){let e=[null,C.Tutorial01,C.Tutorial02,C.Tutorial03,C.Tutorial04,C.Tutorial05];this.sprite=new $({texture:C.Tutorial01,scale:.6,x:250,y:150}),this.stage.addChild(this.sprite);let s=new ct(new E(250,this.sprite.height+160,120,60),"Back",ot.Button01);s.container.alpha=0,s.onClick=()=>{s.container.alpha==0||this.currentImg==1||(this.currentImg--,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.sprite.texture=e[this.currentImg],this.currentImg==1&&(s.container.alpha=0))};let n=new ct(new E(this.sprite.width+130,this.sprite.height+160,120,60),"Next",ot.Button01);n.onClick=()=>{n.container.alpha!=0&&(this.currentImg++,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.currentImg!=1&&(s.container.alpha=1),this.sprite.texture=e[this.currentImg],this.currentImg==5&&(n.container.alpha=0))};const r=new ct(new E(this.sprite.width-540,this.sprite.height+160,200,60),"Main menu",ot.Button01);r.onClick=a=>{u.GameMaster.changeScene(new Ys)}}}class _t{constructor(){p(this,"name",this.constructor.name);p(this,"_container",new tt);p(this,"bb",new E);p(this,"_events",new pt)}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}copyContainerToBB(){return this.container==null?null:(this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb)}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var re=(i=>(i.CreepSpawned="creepSpawned",i.Finished="finished",i.NewWave="newwave",i))(re||{}),wt=(i=>(i.Died="died",i.TakenDamage="takenDamage",i.Escaped="escaped",i.Moved="moved",i))(wt||{}),qe=(i=>(i.CellMouseOver="cellmouseover",i.CellMouseLeave="cellmouseleave",i))(qe||{}),_e=(i=>(i.TowerPlacedEvent="towerPlacedEvent",i.TowerSoldEvent="towerSoldEvent",i))(_e||{}),Hs=(i=>(i.GemGivenEvent="gemGivenEvent",i))(Hs||{}),$s=(i=>(i.TowerPanelSelectGem="towerTabSelectGem",i))($s||{}),Ft=(i=>(i.BasicTowerBehaviour="BasicTowerBehaviour",i.CircleTowerBehaviour="CircleTowerBehaviour",i.ElectricTowerBehaviour="ElectricTowerBehaviour",i.BuffTowerBehaviour="BuffTowerBehaviour",i.StrongTowerBehaviour="StrongTowerBehaviour",i.RailTowerBehaviour="RailTowerBehaviour",i.TrapperTowerBehaviour="TrapperTowerBehaviour",i.DebuffTowerBehaviour="DebuffTowerBehaviour",i))(Ft||{});class wd{constructor(){p(this,"isPlacingTower",!1);p(this,"canPlaceTowers",!0);p(this,"selectedTower",null);p(this,"previewSprite",new $({parent:u.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));p(this,"towers",[]);u.TowerManager=this,u.GameScene.events.on(qe.CellMouseOver,t=>{this.isPlacingTower&&(t.checkIfCantPlace()?(t.showRangePreview(!0,this.selectedTower.stats.range),this.previewSprite.tint=16711680):(t.showRangePreview(!1,this.selectedTower.stats.range),this.previewSprite.tint=16777215),this.previewSprite.x=t.column*u.GridCellSize,this.previewSprite.y=t.row*u.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),u.GameScene.events.on(qe.CellMouseLeave,t=>{this.previewSprite.texture=null,u.Grid.rangePreview.clear()})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,u.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(u.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):C.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e,console.log(this.selectedTower))}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)return u.NotificationManager.Notify("TowerManager.selectedTower is null when trying to place tower.","danger"),console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let s=null;return this.towers.forEach(n=>{n.row==t&&n.column==e&&(s=n)}),s}PlaceTower(t,e,s,n,r){const a=t.texture;if(!u.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!r)return u.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,s)&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Path&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Restricted){r||u.GameScene.MissionStats.spendGold(t.stats.cost);let o=new Gd(e,s,a,t,n);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,u.GameScene.events.emit(_e.TowerPlacedEvent,t.name,e,s)}else u.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn")}update(t){this.towers.forEach((e,s)=>{if(e.sold){for(e.slottedGems=e.slottedGems.filter(n=>n!=null);e.slottedGems.length>0;)e.UnslotGem(0);u.GameScene.events.emit(_e.TowerSoldEvent,e.definition.name,e.row,e.column),u.GameScene.MissionStats.earnGold(e.definition.stats.cost),e.destroy(),this.towers.splice(s,1)}else e.update(t)})}}function ut(i,t,e,s){const n=e-i,r=s-t;return Math.atan2(r,n)}class _d extends _t{constructor(e,s,n,r,a,o,h,l,c){super();p(this,"deleteMe",!1);p(this,"sprite");p(this,"x");p(this,"y");p(this,"angle");p(this,"speed");p(this,"damage");p(this,"pierce",1);p(this,"timeToLive");p(this,"parent");p(this,"gemResistanceModifications");p(this,"collidedCreepIDs",[]);this.x=e,this.y=s,this.timeToLive=h,this.pierce=l,this.damage=a,this.gemResistanceModifications=c,this.sprite=new we({textures:n,scale:.25,rotation:r}),this.sprite.anchor.set(.5,.5),this.sprite.play(),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),u.GameMaster.currentScene.stage.addChild(this.container),this.angle=r,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>2e3||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)&&!this.collidedCreepIDs.find(r=>s.id==r.id)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}}),this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y}}onCollide(e,s){u.GameScene.events.emit(wt.TakenDamage,e.id,s.damage,s.gemResistanceModifications)}checkCollision(e){if(e==null||e.container==null||e.container._position==null)return;let s=this.copyContainerToBB(),n=e.copyContainerToBB();return s.getBounds().intersects(n.getBounds())}}class bd extends _t{constructor(e,s){super();p(this,"deleteMe",!1);p(this,"c");p(this,"oc");p(this,"Lightning");this.c=e,this.oc=s;let n=ut(e.x,e.y,s.x,s.y);this.Lightning=new we({textures:C.SpecialLightning,x:e.x,y:e.y,width:Ke(this.c.x,this.c.y,this.oc.x,this.oc.y),height:64,scale:1.2,rotation:n}),this.Lightning.anchor.set(0,.5),this.Lightning.play(),u.GameMaster.currentScene.stage.addChild(this.Lightning),u.DebrisManager.CreateDebris(this,30)}destroy(){this.deleteMe=!0,this.container.destroy(),this.Lightning.destroy()}update(){this.deleteMe||(this.Lightning.x=this.c.x,this.Lightning.y=this.c.y,this.Lightning.width=Ke(this.c.x,this.c.y,this.oc.x,this.oc.y))}}function oe(i,t){i.projectiles.forEach(e=>{e.deleteMe||i.sold?(e.collidedCreepIDs.forEach(()=>{i.damageDealt+=i.computedDamageToDeal}),e.collidedCreepIDs=[],i.projectiles.splice(i.projectiles.indexOf(e),1),e.destroy(),e=null):e.update(t)})}function Wt(i){let t=0,e=0,s=0,n=0,r=0;if(i.totalGemResistanceModifications={fire:0,frostfire:0,divine:0,ice:0,physical:0},i.slottedGems.forEach(a=>{let o=a.currentGemImprovement();t+=o.damageUp,e+=o.attackSpeedUp,s+=o.rangeUp,n+=o.timeToLiveUp,r+=o.pierceUp;let h=a.currentGemResistanceModifications();i.totalGemResistanceModifications.physical+=h.physical,i.totalGemResistanceModifications.ice+=h.ice,i.totalGemResistanceModifications.fire+=h.fire,i.totalGemResistanceModifications.divine+=h.divine,i.totalGemResistanceModifications.frostfire+=h.frostfire}),i.computedDamageToDeal=i.definition.stats.damage+t,i.computedCooldown=i.definition.stats.cooldown-e,i.computedRange=i.definition.stats.range+s,i.computedTimeToLive=i.definition.stats.timeToLive+n,i.computedPierce=i.definition.stats.pierce+r,i.parent.isBuffedBy.length>0&&i.definition.name!=C.Towers[je.Buff].name){let a=i.parent.isBuffedBy[0];i.computedDamageToDeal+=Number((a.computedDamageToDeal/2).toFixed(1)),i.computedCooldown-=a.computedCooldown*100/5/100,i.computedRange+=Number((a.computedRange/10).toFixed(1)),i.computedTimeToLive+=a.computedTimeToLive*100/5/100,i.computedPierce+=a.computedPierce*100/4/100,i.totalGemResistanceModifications.physical+=a.totalGemResistanceModifications.physical*100/2/100,i.totalGemResistanceModifications.ice+=a.totalGemResistanceModifications.ice*100/2/100,i.totalGemResistanceModifications.fire+=a.totalGemResistanceModifications.fire*100/2/100,i.totalGemResistanceModifications.divine+=a.totalGemResistanceModifications.divine*100/2/100,i.totalGemResistanceModifications.frostfire+=a.totalGemResistanceModifications.frostfire*100/2/100}}function Sd(i,t){Wt(i),oe(i,t),i.millisecondsUntilNextShot>0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ut(n,r,s.x,s.y))}}}function vd(i,t){if(Wt(i),oe(i,t),i.millisecondsUntilNextShot>0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier),i.GetCreepsInRange().length>0&&i.millisecondsUntilNextShot<=0){i.millisecondsUntilNextShot=i.computedCooldown;let s=i.column*u.GridCellSize+u.GridCellSize/2,n=i.row*u.GridCellSize+u.GridCellSize/2;i.Shoot(ut(s,n,s,n+10)),i.Shoot(ut(s,n,s+10,n)),i.Shoot(ut(s,n,s-10,n)),i.Shoot(ut(s,n,s,n-10)),i.Shoot(ut(s,n,s+10,n+10)),i.Shoot(ut(s,n,s-10,n+10)),i.Shoot(ut(s,n,s-10,n-10)),i.Shoot(ut(s,n,s+10,n-10))}}function Cd(i,t){Wt(i),oe(i,t),i.millisecondsUntilNextShot>0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ut(n,r,s.x,s.y));a.onCollide=(o,h)=>{let l=[];h.pierce=0;function c(d){u.Grid.creeps.filter(g=>{if(g.id!=o.id){const m=g.x,y=g.y,x=1.5*u.GridCellSize;return Ke(d.x,d.y,m,y){if(!l.find(m=>m==g.id))l.push(g.id);else return;c(g),new bd(d,g),u.GameScene.events.emit(wt.TakenDamage,g.id,Math.round(h.damage/2),h.gemResistanceModifications)})}c(o),u.GameScene.events.emit(wt.TakenDamage,o.id,h.damage,h.gemResistanceModifications)}}}}function Td(i,t){Wt(i)}function Ad(i,t){Wt(i),oe(i,t),i.millisecondsUntilNextShot>0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ut(n,r,s.x,s.y))}}}function Md(i,t){Wt(i),oe(i,t),i.millisecondsUntilNextShot>0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ut(n,r,s.x,s.y))}}}function Pd(i,t){Wt(i),oe(i,t),i.millisecondsUntilNextShot>0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier)}function kd(i,t){Wt(i),oe(i,t),i.millisecondsUntilNextShot>0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ut(n,r,s.x,s.y))}}}function Ke(i,t,e,s){return Math.sqrt((e-i)*(e-i)+(s-t)*(s-t))}class Gd extends _t{constructor(e,s,n,r,a){super();p(this,"row");p(this,"column");p(this,"setAsSold",!1);p(this,"sold",!1);p(this,"definition");p(this,"slottedGems",[]);p(this,"damageDealt",0);p(this,"projectiles",[]);p(this,"behaviour");p(this,"sprite");p(this,"millisecondsUntilNextShot");p(this,"graphics",new Tt);p(this,"computedDamageToDeal",0);p(this,"computedCooldown",0);p(this,"computedRange",0);p(this,"computedTimeToLive",0);p(this,"computedPierce",0);p(this,"totalGemResistanceModifications",{fire:0,frostfire:0,divine:0,ice:0,physical:0});p(this,"parent");p(this,"onParentCellEnter",e=>{!u.TowerManager.isPlacingTower&&u.Grid.gridInteractionEnabled&&!u.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.computedRange)});p(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=s,this.behaviour=a,this.definition=r,this.millisecondsUntilNextShot=0,this.parent=u.Grid.getCellByRowAndCol(e,s),this.sprite=new $({texture:n,height:u.GridCellSize,width:u.GridCellSize,zIndex:130}),this.container.addChild(this.sprite),this.computedDamageToDeal=this.definition.stats.damage,this.computedRange=this.definition.stats.range,this.parent.container.addChild(this.container),this.container.interactiveChildren=!0,this.parent.clickDetector.on("pointerenter",this.onParentCellEnter),this.parent.clickDetector.on("pointerleave",this.onParentCellLeave),u.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,s){this.slottedGems[s]=e,u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(this)}UnslotGem(e){const s=this.slottedGems.splice(e,1)[0];if(s==null||!s)return console.warn("UnslotGem: Gem is null.");u.GameScene.MissionStats.giveGem(s,!0);for(let n=e;nn!=null),u.NotificationManager.Notify(`Lv. ${s.level} ${s.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return u.Grid.creeps.filter(s=>{const n=s.x,r=s.y,a=this.column*u.GridCellSize+u.GridCellSize/2,o=this.row*u.GridCellSize+u.GridCellSize/2,h=this.computedRange*u.GridCellSize;return Ke(a,o,n,r)0){let o=new Z(this.slottedGems[0].definition.color);for(let h=1;h{u.Grid.gridInteractionEnabled&&(u.TowerManager.isPlacingTower?u.Grid.onGridCellClicked(s,n):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(qe.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(qe.CellMouseLeave,this)}),u.GameScene.events.on(_e.TowerPlacedEvent,(a,o,h)=>{if(o==this.row&&h==this.column)this.hasTowerPlaced=!0,u.Grid.rangePreview.clear();else if(a==C.Towers[je.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&this.isBuffedBy.push(l)}}),u.GameScene.events.on(_e.TowerSoldEvent,(a,o,h)=>{if(console.log(a,o,h),o==this.row&&h==this.column)this.hasTowerPlaced=!1,u.Grid.rangePreview.clear();else if(a==C.Towers[je.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&(console.log("REMOVED!"),this.isBuffedBy.splice(this.isBuffedBy.indexOf(l),1),console.log(this.isBuffedBy))}})}showRangePreview(e,s){let n=16777215;e&&(n=16711680),u.Grid.rangePreview.clear(),u.Grid.rangePreview.circle(this.column*u.GridCellSize+u.GridCellSize/2,this.row*u.GridCellSize+u.GridCellSize/2,s*u.GridCellSize),u.Grid.rangePreview.fill({color:n,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=u.TowerManager.GetTowerByRowAndCol(this.row,this.column);u.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Dt.Path||this.type==Dt.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Dt.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Dt.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Dt.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class Id extends _t{constructor(e,s){super();p(this,"gameMap");p(this,"cells",[]);p(this,"rangePreview");p(this,"creeps",[]);p(this,"gridShown",!1);p(this,"gridInteractionEnabled",!0);this.gameMap=e,u.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=u.GridCellSize*u.GridColumns,this.bb.height=u.GridCellSize*u.GridRows,u.GameMaster.currentScene.stage.addChild(this.container);let n=new $(C.MissionBackgrounds[s]);this.container.addChild(n);for(let r=0;rc.some(d=>d[1]===a&&d[0]===r));h&&(o=Dt.Path);let l=new Bd(o,a,r,h);this.cells.push(l)}this.rangePreview=new Tt({zIndex:10,x:0,y:0,width:u.app.canvas.width,height:u.app.canvas.height}),this.container.addChild(this.rangePreview)}generateCells(){const e=Array.from({length:this.gameMap.rows},()=>Array(this.gameMap.columns).fill(1));this.cells.forEach(s=>{if(s.isPath){e[s.row][s.column]=9;for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++){const a=s.row+n,o=s.column+r;a>=0&&a=0&&o{if(e){e=="hide"?s.gClear():s.gDraw();return}this.gridShown?s.gClear():s.gDraw()}),e=="hide"?this.gridShown=!1:e=="show"?this.gridShown=!0:this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(wt.Died,s=>{this.onCreepDiedOrEscaped(s)}),e.events.on(wt.Escaped,s=>{this.onCreepDiedOrEscaped(s)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(s=>{s.dead?(this.creeps.splice(this.creeps.indexOf(s),1),s=null):s.update(e)})}getCellByRowAndCol(e,s){return this.cells.filter(n=>n.row==e&&n.column==s)[0]}onGridCellClicked(e,s){}}class Ed extends _t{constructor(e,s,n){super();p(this,"id");p(this,"creepType");p(this,"sprite");p(this,"path");p(this,"stats");p(this,"pathIndex",0);p(this,"speed");p(this,"direction",1);p(this,"healthBarGraphics",new Tt);p(this,"healthBarWidth",50);p(this,"health");p(this,"maxHealth");p(this,"escaped",!1);p(this,"died",!1);p(this,"x");p(this,"y");p(this,"dead",!1);this.creepType=e,this.stats=structuredClone(C.Creeps[this.creepType].stats),this.sprite=new we(C.Creeps[this.creepType].textures),this.sprite.scale.x*=-1,this.sprite.anchor.set(.5,.5),this.sprite.animationSpeed=.3,this.sprite.play(),this.id=n,this.container.x=-70,this.container.y=-50,this.sprite.width=u.GridCellSize,this.sprite.height=u.GridCellSize,this.bb.width=this.sprite.width,this.speed=this.stats.speed/60,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=s,this.x=s[0][0]*u.GridCellSize+u.GridCellSize/2,this.y=s[0][1]*u.GridCellSize+u.GridCellSize/2,u.GameScene.events.on(wt.TakenDamage,(r,a,o)=>{r==this.id&&(this.health-=a+a*(o.physical-this.stats.resistance.physical),o.fire!=0&&(this.health-=Math.max(a*(o.fire-this.stats.resistance.fire),0)),o.ice!=0&&(this.health-=Math.max(a*(o.ice-this.stats.resistance.ice),0)),o.frostfire!=0&&(this.health-=Math.max(a*(o.frostfire-this.stats.resistance.frostfire),0)),o.divine!=0&&(this.health-=Math.max(a*(o.divine-this.stats.resistance.divine),0)),this.UpdateHealthbar())}),u.Grid.container.addChild(this.container),this.container.addChild(this.healthBarGraphics),this.container.addChild(this.sprite),this.UpdateHealthbar()}UpdateHealthbar(){this.healthBarGraphics.clear();const e=this.health,s=this.maxHealth,n=e/s,r=this.healthBarWidth*n;this.healthBarGraphics.rect(-this.healthBarWidth/2+3,-32,this.healthBarWidth+4,14),this.healthBarGraphics.fill({color:0}),this.healthBarGraphics.rect(-this.healthBarWidth/2+5,-30,r,10),this.healthBarGraphics.fill({color:16711680})}update(e){if(this.dead)return;if(this.health<=0){u.GameScene.events.emit(wt.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(wt.Escaped,this),this.escaped=!0;return}const s=this.path[this.pathIndex],n=this.path[this.pathIndex+1],r=n[0]*u.GridCellSize+u.GridCellSize/2,a=n[1]*u.GridCellSize+u.GridCellSize/2,o=n[0]-s[0],h=n[1]-s[1];o>0?this.direction!=1&&(this.direction=1,this.sprite.scale.x*=-1):o<0&&this.direction!=-1&&(this.direction=-1,this.sprite.scale.x*=-1);let l=this.speed*e*o*u.GameScene.gameSpeedMultiplier,c=this.speed*e*h*u.GameScene.gameSpeedMultiplier,d=!1;l>0&&this.x+l>r&&(l=r-this.x,d=!0),l<0&&this.x+l0&&this.y+c>a&&(c=a-this.y,d=!0),c<0&&this.y+c{s+=n.firstCreepSpawnTick,n.creeps.forEach(r=>{const a=new Ed(r,this.paths[this.pathsIndex],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:s,spawned:!1};s+=n.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e*u.GameScene.gameSpeedMultiplier,this.creeps.forEach(s=>{!s.spawned&&s.tickToSpawnAt<=this.ticks?(s.spawned=!0,this.events.emit(re.CreepSpawned,s.creep),!this.finished&&this.creeps.every(n=>n.spawned)&&(this.finished=!0,this.events.emit(re.Finished))):s.spawned&&s.creep.update(e)}))}}class Ht extends Mt{constructor(e,s,n,r,a,o,h,l){if(e>3||s>2||e<0||s<0)throw"Index/row out of bounds for TowerButton.";super(!0);p(this,"frameSprite");p(this,"background");p(this,"towerName");p(this,"iconSprite");p(this,"i",0);this.towerName=h,this.container.x=e*n+5,this.container.y=s*r+5,this.background=new $({texture:o}),this.iconSprite=new $({texture:l}),this.background.width=n,this.background.height=r,this.iconSprite.x=n/2,this.iconSprite.y=r/2,this.iconSprite.width=n/2,this.iconSprite.height=r/2,this.iconSprite.anchor.set(.5,.5),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.frameSprite=new bt({texture:C.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:r,width:n}),this.container.addChild(this.frameSprite),a.addChild(this.container),u.GameScene.events.on(_e.TowerPlacedEvent,c=>{this.resetTint()}),this.container.onpointermove=c=>{u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=c=>{u.GameScene.tooltip.Hide()}}ShowTooltip(){let e;C.Towers.forEach(s=>{s.name==this.towerName&&(e=s)}),u.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)}onClick(e){u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower&&u.TowerManager.selectedTower.name!=this.towerName&&(u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower()),u.GameScene.towerPanel.Hide(),u.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,u.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class Fd extends Mt{constructor(e){super(!1);p(this,"bounds");p(this,"towerTabSprite");p(this,"towerButtons",[]);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new bt({texture:C.FrameTowerTab,leftWidth:500,topHeight:500,rightWidth:500,bottomHeight:500,roundPixels:!0}),this.towerTabSprite.width=this.bounds.width,this.towerTabSprite.height=this.bounds.height,this.container.addChild(this.towerTabSprite),this.towerButtons.push(new Ht(0,0,70,70,this.container,C.RedBackground,C.Towers[0].name,C.Towers[0].texture)),this.towerButtons.push(new Ht(1,0,70,70,this.container,C.RedBackground,C.Towers[1].name,C.Towers[1].texture)),this.towerButtons.push(new Ht(2,0,70,70,this.container,C.BlueBackground,C.Towers[2].name,C.Towers[2].texture)),this.towerButtons.push(new Ht(3,0,70,70,this.container,C.BlueBackground,C.Towers[3].name,C.Towers[3].texture)),this.towerButtons.push(new Ht(0,1,70,70,this.container,C.GreenBackground,C.Towers[4].name,C.Towers[4].texture)),this.towerButtons.push(new Ht(1,1,70,70,this.container,C.GreenBackground,C.Towers[5].name,C.Towers[5].texture)),this.towerButtons.push(new Ht(2,1,70,70,this.container,C.YellowBackground,C.Towers[6].name,C.Towers[6].texture)),this.towerButtons.push(new Ht(3,1,70,70,this.container,C.YellowBackground,C.Towers[7].name,C.Towers[7].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const se=class se{static init(){se.SidebarRect=new E(u.app.canvas.width-360,0,360,u.app.canvas.height),se.ChangeRoundButtonRect=new E(50,u.app.canvas.height-100,310,100)}};p(se,"SidebarRect"),p(se,"ChangeRoundButtonRect"),p(se,"MaximumPlayerNameLength",20);let Yt=se;class Ze extends Mt{constructor(e,s,n,r){super(!0);p(this,"iconSprite");p(this,"background");p(this,"frame");p(this,"i",0);p(this,"gem",null);let a;this.i=e,this.container.x=10,this.container.y=e*(u.GridCellSize+6)+300,this.background=new $({texture:C.Frame01Texture}),n==null&&!r?a=C.PlusIconTexture:r=="SELL"?a=C.GoldTexture:r=="UPGRADE"?a=C.PlusIconTexture:(a=n.texture,this.gem=n),this.iconSprite=new $({texture:a,zIndex:10}),this.background.width=u.GridCellSize,this.background.height=u.GridCellSize,n==null&&!r?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):r=="SELL"?(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8):r=="UPGRADE"?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.tint=3012919,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8),this.frame=new $({texture:C.Frame05Texture,width:64,height:64}),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.container.addChild(this.frame);let o=n?n.level:"",h=new O({text:o,zIndex:11,style:{fill:"white",stroke:{color:0,width:5}}});this.container.addChild(h),s.addChild(this.container)}setTint(e){this.frame.tint=e}resetTint(){this.frame.tint=16777215}}class Ld extends Mt{constructor(e){super(!1);p(this,"bounds");p(this,"towerPanel");p(this,"closeBtn");p(this,"vGems",[]);p(this,"showingTower",null);p(this,"isShown",!1);p(this,"titleText");p(this,"damageText");p(this,"totalDamage");p(this,"attackSpeedText");p(this,"fireResDamage");p(this,"iceResDamage");p(this,"frostFireResDamage");p(this,"divineResDamage");p(this,"physicalResDamage");p(this,"sellButton");this.bounds=e,this.towerPanel=new bt({texture:C.Frame03Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.towerPanel.width=this.bounds.width,this.towerPanel.height=this.bounds.height-this.bounds.height/3.5,this.closeBtn=new ct(new E(-20,-20,60,60),"",ot.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new $({texture:C.XIconTexture,x:this.closeBtn.container.width/2,y:this.closeBtn.container.height/2,scale:.2}),this.closeBtn.buttonIcon.anchor.set(.5,.5),this.closeBtn.container.addChild(this.closeBtn.buttonIcon)},this.closeBtn.onClick=()=>{this.Hide()},this.Hide(),this.closeBtn.CustomButtonLogic(),this.container.y=u.app.canvas.height/2-u.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),u.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new O({x:this.bounds.width/3,y:50,zIndex:5,style:new N({fill:16777215,fontSize:25,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new O({x:10,y:100,zIndex:5,style:new N({fill:16753920,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.damageText),this.attackSpeedText=new O({x:100,y:100,zIndex:5,style:new N({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.attackSpeedText),this.totalDamage=new O({x:10,y:130,zIndex:5,style:new N({fill:16711680,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.totalDamage),this.fireResDamage=new O({x:10,y:170,zIndex:5,style:new N({fill:16536403,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.fireResDamage),this.iceResDamage=new O({x:10,y:190,zIndex:5,style:new N({fill:3335420,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.iceResDamage),this.frostFireResDamage=new O({x:10,y:210,zIndex:5,style:new N({fill:14111740,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.frostFireResDamage),this.divineResDamage=new O({x:10,y:230,zIndex:5,style:new N({fill:16576083,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.divineResDamage),this.physicalResDamage=new O({x:10,y:250,zIndex:5,style:new N({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.physicalResDamage),this.sellButton=new ct(new E(5,this.towerPanel.height-70,this.towerPanel.width-115,60),"Sell",ot.Button02,!0),this.sellButton.container.removeFromParent(),this.container.addChild(this.sellButton.container)}MakeSlots(e){this.vGems.forEach(n=>{n.destroy()}),this.vGems=[];let s=e.definition.stats.gemSlotsAmount;for(let n=0;n{r&&(u.GameScene.tooltip.SetContentGem(r),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},a.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},a.onClick=()=>{u.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",r,a.i,n,e),u.GameScene.events.emit($s.TowerPanelSelectGem,r,a.i,e),!r&&u.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,Wt(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,u.GameScene.sidebar.gemTab.selectingGemTowerObject=e,e.container.parent.x<1270?this.ShowRight():this.ShowLeft(),e.parent.showRangePreview(!1,e.computedRange)}SetContent(e){this.titleText.text=e.definition.name,this.damageText.text="Deals "+e.computedDamageToDeal+" damage",this.totalDamage.text="Damage dealt: "+e.damageDealt+" damage",this.attackSpeedText.x=this.damageText.width+10,this.attackSpeedText.text=` every ${Math.floor(e.computedCooldown/1e3*100)/100}s`,this.fireResDamage.text=`+${e.totalGemResistanceModifications.fire*100}% Fire damage`,this.iceResDamage.text=`+${e.totalGemResistanceModifications.ice*100}% Ice damage`,this.frostFireResDamage.text=`+${e.totalGemResistanceModifications.frostfire*100}% FrostFire damage`,this.divineResDamage.text=`+${e.totalGemResistanceModifications.divine*100}% Divine damage`,this.physicalResDamage.text=`+${e.totalGemResistanceModifications.physical*100}% Physical damage`,this.sellButton.setCaption("Sell for "+e.definition.stats.cost+" gold"),this.sellButton.onClick=()=>{e.Sell(),this.Hide()}}ShowLeft(){this.towerPanel.x=-100,this.container.x=0,this.container.alpha=1,this.closeBtn.container.x=this.bounds.width-150}ShowRight(){this.towerPanel.x=-10,this.container.x=Yt.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=-1e3,u.Grid.rangePreview.clear()}}class Dd extends Mt{constructor(e){super(!1);p(this,"bounds");p(this,"gemTabSprite");p(this,"vGems",[]);p(this,"isSelectingGem",!1);p(this,"selectingGemSlotIndex",-1);p(this,"selectingGemTowerObject",null);p(this,"isDragAndDroppingGem",!1);p(this,"dragAndDroppingGem",null);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new bt({texture:C.FrameTowerTab,leftWidth:1e3,topHeight:1e3,rightWidth:1e3,bottomHeight:1e3}),this.gemTabSprite.x=0,this.gemTabSprite.y=0,this.gemTabSprite.width=this.bounds.width,this.gemTabSprite.height=this.bounds.height,this.container.addChild(this.gemTabSprite),u.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),u.GameScene.events.on(Hs.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,s,n){console.log("TOWER PANEL SELECTING GEM "+s),s<0&&console.error("TOWER PANEL SELECTING GEM INDEX IS LESS THAN 0, ",s),this.isSelectingGem?e==null&&(this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null):(this.isSelectingGem=!0,e==null?(u.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=s,this.selectingGemTowerObject=n):(n.UnslotGem(s),this.RebuildInventoryVisual(),u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(n),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=u.MouseX-32,this.dragAndDroppingGem.container.y=u.MouseY-32)}isOverlappingGemsmith(e,s,n){let r=e.copyContainerToBB(),a=s.copyContainerToBB(),o=n.x+a.x+u.GameScene.sidebar.container.x,h=n.y+a.y+u.GameScene.sidebar.container.y,l=new E(o,h,a.width,a.height);if(r.getBounds().intersects(l)&&s&&s.gem==null)return!0}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],u.GameScene.MissionStats.getInventory().forEach((e,s)=>{let n=new Ze(0,this.container,e),r=10,a=s%4*70+10,o=s;for(;!(o<=3);)r+=66,o-=4;n.container.x=a,n.container.y=r,n.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(u.GameScene.tooltip.SetContentGem(e),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},n.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},n.container.onpointerdown=()=>{if(u.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=u.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=n,n.container.removeFromParent(),u.GameScene.stage.addChild(n.container),this.pointerMoveEvent()},n.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.sellVGem,u.GameScene.sidebar.gemsmith.container)){let d=this.dragAndDroppingGem.gem.definition.initialGemValue+this.dragAndDroppingGem.gem.currentGemImprovement().gemValueUp;u.GameScene.MissionStats.earnGold(Math.ceil(d*.8)),u.NotificationManager.Notify(`Sold Lv. ${this.dragAndDroppingGem.gem.level} ${this.dragAndDroppingGem.gem.definition.name} for ${Math.ceil(d*.8)} gold.`,"info"),u.GameScene.MissionStats.takeGem(this.dragAndDroppingGem.gem),this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.upgradeVGem,u.GameScene.sidebar.gemsmith.container)){if(this.dragAndDroppingGem.gem.isMaxLevel())u.NotificationManager.Notify("Gem is max level.","warn");else{let d=this.dragAndDroppingGem.gem.definition.genericImprovements[this.dragAndDroppingGem.gem.level].gemValueUp;u.GameScene.MissionStats.hasEnoughGold(d)?(u.GameScene.MissionStats.spendGold(d),this.dragAndDroppingGem.gem.levelUp(1),u.NotificationManager.Notify(`Spent ${d} gold to upgrade ${this.dragAndDroppingGem.gem.definition.name} Lv. ${this.dragAndDroppingGem.gem.level-1} -> Lv. ${this.dragAndDroppingGem.gem.level}!`,"warn")):u.NotificationManager.Notify("You don't have enough, you need "+d+" gold to upgrade this gem.","warn")}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(u.GameScene.towerPanel.vGems.forEach(d=>{if(h||!this.dragAndDroppingGem)return;let f=this.dragAndDroppingGem.copyContainerToBB(),g=d.copyContainerToBB(),m=u.GameScene.towerPanel.container.x+g.x,y=u.GameScene.towerPanel.container.y+g.y,x=new E(m,y,g.width,g.height);f.getBounds().intersects(x)&&d&&d.gem==null&&(h=d)}),h){let d=u.GameScene.MissionStats.takeGem(e);u.GameScene.towerPanel.showingTower.SlotGem(d,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(n)})}}class zd extends Mt{constructor(e){super(!1);p(this,"bounds");p(this,"sellVGem");p(this,"upgradeVGem");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y;let s=new $({x:0,y:0,width:this.bounds.width,height:this.bounds.height,texture:C.BannerGemsmith});this.container.addChild(s);let n=new O({x:40,y:this.bounds.height/6.5,text:"Sell gem",style:new N({fill:16767744,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(n);let r=new O({x:155,y:this.bounds.height/6.5,text:"Upgrade gem",style:new N({fill:3012919,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(r),this.sellVGem=new Ze(0,this.container,null,"SELL"),this.sellVGem.container.x=45,this.sellVGem.container.y=this.bounds.height/4,this.upgradeVGem=new Ze(0,this.container,null,"UPGRADE"),this.upgradeVGem.container.x=180,this.upgradeVGem.container.y=this.bounds.height/4}}class Ud extends Mt{constructor(e){super(!1);p(this,"towerTab");p(this,"gemTab");p(this,"gemsmith");p(this,"bounds");p(this,"sidebarSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new bt({texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.sidebarSprite.x=40,this.sidebarSprite.y=-40,this.sidebarSprite.width=this.bounds.width+40,this.sidebarSprite.height=this.bounds.height+80,this.container.addChild(this.sidebarSprite);const s=new E(60,20,this.bounds.width-65,150);this.towerTab=new Fd(s),this.container.addChild(this.towerTab.container);const n=new E(60,180,this.bounds.width-65,this.bounds.height-280-255);this.gemTab=new Dd(n),this.container.addChild(this.gemTab.container);const r=new E(60,185+n.height,this.bounds.width-65,this.bounds.height-840);this.gemsmith=new zd(r),this.container.addChild(this.gemsmith.container)}}class Od extends _t{constructor(e,s){super();p(this,"hp",100);p(this,"gold",0);p(this,"goldEarned",0);p(this,"goldSpent",0);p(this,"wavesSurvived",0);p(this,"damageDealt",0);p(this,"creepsKilled",0);p(this,"goldText");p(this,"healthText");p(this,"waveText");p(this,"inventory",[]);this.hp=e,this.gold=s,this.container.x=0,this.container.y=20,u.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new O({text:`${this.hp}`,style:new N({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new O({text:`${this.gold}`,style:new N({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new O({text:`0/${u.GameScene.mission.rounds.length}`,style:new N({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const n=new $(C.HealthTexture),r=new $(C.GoldTexture),a=new $(C.WaveTexture);this.healthText.x=200,this.healthText.y=-15,n.x=160,n.width=36,n.height=32,n.y=-10,this.goldText.x=200,this.goldText.y=20,r.x=150,r.width=56,r.height=56,r.y=15,this.waveText.x=200,this.waveText.y=55,a.x=155,a.width=46,a.height=32,a.y=65,this.container.addChild(this.healthText),this.container.addChild(this.goldText),this.container.addChild(this.waveText),this.container.addChild(n),this.container.addChild(r),this.container.addChild(a),u.GameScene.events.on(re.NewWave,o=>{this.waveText.text=`${o}/${u.GameScene.mission.rounds.length}`})}getHP(){return this.hp}hasEnoughGold(e){return e<=this.gold}setHP(e){this.hp=e,this.healthText.text=this.hp}takeDamage(e){this.hp-=e,this.healthText.text=this.hp}setGold(e){this.gold=e,this.goldText.text=this.gold}earnGold(e){this.gold+=e,this.goldText.text=this.gold}spendGold(e){this.gold-=e,this.goldText.text=this.gold}giveGem(e,s){if(this.inventory.length>=32)return u.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),s||u.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),u.GameScene.events.emit(Hs.GemGivenEvent,e)}takeGem(e){return this.inventory.splice(this.inventory.indexOf(e),1)[0]}getInventory(){return this.inventory}checkIfPlayerHasAnyGems(){return this.inventory.length>0}getStats(){return{hp:this.hp,gold:this.gold,wavesSurvived:this.wavesSurvived,goldEarned:this.goldEarned,goldSpent:this.goldSpent,score:this.calculateScore()}}calculateScore(){const e=[];for(const s of this.inventory)e.includes(s.definition.name)||e.push(s.definition.name);return this.damageDealt*2+this.hp*10+(this.goldEarned-this.goldSpent)*3+this.wavesSurvived*100+e.length*100}update(){}}class Wd extends Mt{constructor(e){super(!1);p(this,"bounds");p(this,"tooltipSprite");p(this,"titleText");p(this,"costText");p(this,"damageText");p(this,"gemAmount");p(this,"gemAmountSprite");p(this,"title");p(this,"costSprite");p(this,"damageSprite");p(this,"gemDescriptionText");this.bounds=e,this.container.x=-500,this.container.y=-500,this.container.zIndex=150,this.tooltipSprite=new bt({texture:C.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new O({x:this.tooltipSprite.width/2,y:-20,zIndex:5,style:new N({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.title=new $({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:C.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new $({texture:C.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new O({x:54,y:26,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"gold",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageText=new O({x:54,y:65,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"red",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageSprite=new $({texture:C.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new $({texture:C.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new O({x:54,y:105,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"white",fontWeight:"bold",stroke:{color:0,width:5}}}),this.gemDescriptionText=new O({x:10,y:20,text:"",style:{fontSize:18,wordWrap:!0,wordWrapWidth:this.tooltipSprite.width-30,fill:"white",fontWeight:"bold",fontStyle:"italic",stroke:{color:0,width:5}}}),this.container.addChild(this.tooltipSprite),this.container.addChild(this.title),this.container.addChild(this.costSprite),this.container.addChild(this.damageSprite),this.container.addChild(this.gemAmountSprite),this.container.addChild(this.costText),this.container.addChild(this.titleText),this.container.addChild(this.damageText),this.container.addChild(this.gemAmount),this.container.addChild(this.gemDescriptionText),u.app.stage.addChildAt(this.container,0)}SetContentTower(e,s,n,r){this.costSprite.alpha=1,this.damageSprite.alpha=1,this.gemAmountSprite.alpha=1,this.costText.alpha=1,this.damageText.alpha=1,this.gemAmount.alpha=1,this.gemDescriptionText.alpha=0,this.titleText.text=e,this.gemAmount.text=`Has ${r} Gem slots.`,this.gemAmountSprite.texture=C.GemAmountIcons[r],this.costText.text=`Costs ${n} gold.`,this.damageText.text=`Deals ${s} base damage.`}SetContentGem(e){this.costSprite.alpha=0,this.damageSprite.alpha=0,this.gemAmountSprite.alpha=0,this.costText.alpha=0,this.damageText.alpha=0,this.gemAmount.alpha=0,this.gemDescriptionText.alpha=1,this.titleText.text=`Lv. ${e.level} `+e.definition.name;let s;e.isMaxLevel()?s="Max level.":s=`Costs ${e.definition.genericImprovements[e.level].gemValueUp} gold to level up.`,this.gemDescriptionText.text=`${s} Valued at ${e.definition.initialGemValue+e.currentGemImprovement().gemValueUp} gold. `+e.definition.description}Show(e,s){this.container.alpha=1,e+this.container.width>u.app.canvas.width?this.container.x=e-this.container.width:this.container.x=e,this.container.y=s}Hide(){this.container.alpha=0,this.container.x=-500,this.container.y=-500}}const dt=class dt{static init(){window.addEventListener("keydown",dt.handleKeyDown)}static onKeyPressed(t){return dt.listeners=[...dt.listeners,t],()=>dt.offKey(t)}static offKey(t){const e=dt.listeners.indexOf(t);e>=0&&(dt.listeners=[...dt.listeners.slice(0,e),...dt.listeners.slice(e+1)])}static handleKeyDown(t){if(dt.listeners.length>0)for(let e=dt.listeners.length-1;e>=0&&(dt.listeners[e](t),!t.defaultPrevented);e--);}};p(dt,"listeners",[]);let be=dt;class Gi extends Mt{constructor(e,s,n){super();p(this,"overlay");p(this,"buttonHeight",65);p(this,"buttonCaptions");p(this,"buttons",[]);p(this,"dialogContent");p(this,"dialogContainer");p(this,"background");p(this,"generated",!1);p(this,"escapeKeyButton");p(this,"enterKeyButton");p(this,"keyboardManagerUnsubscribe");p(this,"onClosed");if(this.buttonCaptions=e,n&&!e.includes(n))throw new Error(`Escape key button "${n}" not found in buttons: ${e}`);if(this.escapeKeyButton=n,s&&!e.includes(s))throw new Error(`Enter key button "${s}" not found in buttons: ${e}`);this.enterKeyButton=s,this.keyboardManagerUnsubscribe=be.onKeyPressed(this.onKeyPress.bind(this))}show(){return this.generate(),`${Math.round(this.dialogContainer.x)}${Math.round(this.dialogContainer.y)}${Math.round(this.dialogContainer.width)}${Math.round(this.dialogContainer.height)}`,`${Math.round(this.dialogContent.x)}${Math.round(this.dialogContent.y)}${Math.round(this.dialogContent.width)}${Math.round(this.dialogContent.height)}`,new Promise((e,s)=>{u.app.stage.addChild(this.container),this.onClosed=n=>{this.destroy(),e(n)}})}createDialogBackground(){return new bt({texture:C.Frame04Texture,leftWidth:60,topHeight:60,rightWidth:60,bottomHeight:60})}getWidth(){}getHeight(){}generate(){if(this.generated)return;this.generated=!0,this.overlay=new Tt,this.overlay.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.overlay.fill({color:0,alpha:.5}),this.overlay.interactive=!0,this.container.addChild(this.overlay);const e=this.buttonCaptions.map(l=>({caption:l,width:l.length*14+60,height:this.buttonHeight,click:()=>this.close(l)}));this.background=this.createDialogBackground(),this.dialogContent=this.createContent();let s=0;for(const l of e)s>0&&(s+=10),s+=l.width;const n=this.buttonCaptions.length>0?this.buttonHeight+10:0;let r=this.getWidth()||Math.max(s,this.dialogContent.width)+this.background.leftWidth+this.background.rightWidth,a=this.getHeight()||this.dialogContent.height+n+this.background.topHeight+this.background.bottomHeight;const o=new E(u.app.canvas.width/2-r/2,u.app.canvas.height/2-a/2,r,a);this.dialogContainer=new tt,this.dialogContainer.x=o.x,this.dialogContainer.y=o.y,this.background.width=r,this.background.height=a,this.dialogContainer.addChild(this.background),this.dialogContent.width0&&(r=s[0]),!n&&s.length>0&&(n=s[s.length-1]);super(s,n,r);p(this,"caption");this.caption=e}createContent(){return new O({text:this.caption,style:new N({fill:16777215,fontSize:24})})}static show(e,s,n=0){return new Vs(e,s).show()}}const Lt=class Lt{constructor(t){p(this,"missionName");p(this,"scores");this.missionName=t,this.scores=this.loadScores(),this.scores.sort((e,s)=>s.score-e.score||e.timestamp-s.timestamp)}loadScores(){const t=localStorage.getItem(Lt.STORAGE_KEY_PREFIX+this.missionName);return Lt.parseStoredScores(t)}saveScores(){localStorage.setItem(Lt.STORAGE_KEY_PREFIX+this.missionName,JSON.stringify(this.scores))}addScore(t){this.scores.push(t),this.scores.sort((e,s)=>s.score-e.score),this.scores.length>Lt.MAX_SCORES&&(this.scores.length=Lt.MAX_SCORES),this.saveScores()}getScores(){return this.scores}static parseStoredScores(t){if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e)&&e.every(s=>typeof s.playerName=="string"&&typeof s.score=="number"&&typeof s.timestamp=="number"))return e.map(s=>({playerName:s.playerName,score:s.score,timestamp:s.timestamp}))}catch(e){console.error("Failed to parse stored scores:",e)}return[]}};p(Lt,"STORAGE_KEY_PREFIX","highscore_"),p(Lt,"MAX_SCORES",10);let bi=Lt;const Fe={Confirm:"OK",Skip:"Skip"};class Hd extends Gi{constructor(e,s,n){super([Fe.Confirm,Fe.Skip],Fe.Confirm,Fe.Skip);p(this,"dialogCaption");p(this,"playerNameTextInput");p(this,"lost");p(this,"highScore");p(this,"missionStats");this.lost=n,this.highScore=new bi(e),this.missionStats=s}generate(){super.generate(),this.dialogCaption=new O({text:this.lost?"You lost!":"You won!",style:new N({fill:16777215,fontSize:36,stroke:{color:0,width:2},dropShadow:{color:0,blur:8,distance:0}})}),this.dialogCaption.anchor.set(.5,.5),this.dialogCaption.x=this.dialogContainer.width/2,this.dialogCaption.y=50,this.dialogContainer.addChild(this.dialogCaption)}createDialogBackground(){return new bt({texture:C.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new tt,s=35,n=this.createText("Mission details:","#fee",!0);e.addChild(n);const r=this.missionStats.getStats(),a=this.getWidth()-this.background.leftWidth-this.background.rightWidth-20,o=[this.createText("HP:"),this.createText("Gold:"),this.createText("Waves Survived:"),this.createText("Gold Earned:"),this.createText("Gold Spent:"),this.createText("----"),this.createText("Score:")],h=[this.createText(r.hp.toString(),"yellow"),this.createText(r.gold.toString(),"yellow"),this.createText(r.wavesSurvived.toString(),"yellow"),this.createText(r.goldEarned.toString(),"yellow"),this.createText(r.goldSpent.toString(),"yellow"),this.createText("----","yellow"),this.createText(r.score.toString(),"yellow")],l=300;for(let f=0;fthis.createText((f+1).toString()))],o=[this.createText("Player","#fee",!0),...r.map(d=>this.createText(d.playerName))],h=[this.createText("Score","#fee",!0),...r.map(d=>this.createText(d.score.toString()))],l=a.reduce((d,f)=>Math.max(d,f.width),0)+20,c=l+o.reduce((d,f)=>Math.max(d,f.width),0)+20;for(let d=0;d{s.name==e&&(this.mission=s,this.missionIndex=n)})}init(){u.latestGemId=0,new Id(this.mission.gameMap,this.missionIndex),new wd,new Rd(this.mission.rounds,this.mission.gameMap.paths),u.Grid.onGridCellClicked=(e,s)=>{u.TowerManager.isPlacingTower&&u.TowerManager.PlayerClickOnGrid(e,s)},u.WaveManager.events.on(re.CreepSpawned,e=>{u.Grid.addCreep(e),e.events.on(wt.Escaped,()=>{this.onCreepEscaped(e)})}),u.WaveManager.events.on(re.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(wt.Died,(e,s)=>{this.MissionStats.earnGold(e)}),this.towerPanel=new Ld(Yt.SidebarRect),this.sidebar=new Ud(Yt.SidebarRect),this.changeRoundButton=new ct(Yt.ChangeRoundButtonRect,"",ot.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),u.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new Wd(new E(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new $({texture:C.PlayIconTexture,x:this.changeRoundButton.container.width/2,y:this.changeRoundButton.container.height/2,scale:.2}),this.changeRoundButton.buttonIcon.anchor.set(.5,.5),this.changeRoundButton.container.addChild(this.changeRoundButton.buttonIcon)},this.changeRoundButton.CustomButtonLogic(),this.changeRoundButton.onClick=()=>{if(this.playerWon)return this.ReturnToMain();if(this.roundMode==1){this.gameSpeedMultiplier!==1?this.UpdateGameSpeedMultiplier(1):this.UpdateGameSpeedMultiplier(2);return}if(this.isGameOver)return u.NotificationManager.Notify("No more waves.","danger");this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=C.FastForwardIconTexture,this.events.emit(re.NewWave,`${this.currentRound+1}`))},this.MissionStats=new Od(125,450),this.events.on($s.TowerPanelSelectGem,(e,s,n)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return u.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,s,n)}),this.pauseButton=new ct(new E(5,5,120,80),"",ot.Button01,!0),this.pauseButton.container.removeFromParent(),this.stage.addChild(this.pauseButton.container),this.pauseButton.CustomButtonLogic=()=>{this.pauseButton.buttonIcon=new $({texture:C.PauseIconTexture,x:this.pauseButton.container.width/2,y:this.pauseButton.container.height/2,scale:.2}),this.pauseButton.buttonIcon.anchor.set(.5,.5),this.pauseButton.container.addChild(this.pauseButton.buttonIcon)},this.pauseButton.CustomButtonLogic(),this.pauseButton.onClick=()=>{this.isPaused?this.UnpauseGame():(this.ShowPauseDialog(),this.PauseGame())},this.ticker=new Bt,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(u.MouseX,u.MouseY),this.tooltip.Hide(),this.ticker.add(()=>{this.update&&this.update(this.ticker.elapsedMS)}),this.ticker.start()}update(e){if(this.isGameOver){this.destroyTicker&&(this.destroyTicker=!1,this.ticker.destroy());return}u.WaveManager.update(e),u.Grid.update(e),u.TowerManager.update(e),this.isWaveManagerFinished&&u.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=C.PlayIconTexture,u.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(u.NotificationManager.Notify("Mission victory!!","reward"),this.changeRoundButton.buttonIcon.texture=C.HomeIconTexture,this.playerWon=!0):(this.OfferPlayerGems(),this.currentRound++)),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowEndgameDialog(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowEndgameDialog(!1))}DarkenScreen(){this.dimGraphics.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){u.Grid.gridInteractionEnabled=!1,u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new bt({width:380,height:150,texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:u.app.canvas.width/2-190,y:u.app.canvas.height/2-75}),u.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let s=new O({x:u.app.canvas.width/4,y:u.app.canvas.height/4,zIndex:this.dimGraphics.zIndex+1,text:"Choose a Gem as your reward for beating this round!",style:{fontSize:40,fill:"orange",fontWeight:"bold",stroke:{color:0,width:5}}});u.GameMaster.currentScene.stage.addChildAt(s,0),e.forEach((n,r)=>{let a=new Ms(n,!0),o=new Ze(0,u.app.stage,a);this.visualGems.push(o),o.container.x=this.offerGemsSprite.x-15+69*(r+1),o.container.y=this.offerGemsSprite.y+40,o.container.onpointermove=()=>{u.GameScene.tooltip.SetContentGem(a),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)},o.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},o.onClick=()=>{u.GameScene.tooltip.Hide(),s.destroy(),this.PlayerPickedGem(new Ms(n))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(s=>s.destroy()),u.Grid.gridInteractionEnabled=!0,this.MissionStats.giveGem(e),this.setRoundMode(0)}PauseGame(){this.isPaused=!0,this.ticker.stop(),document.title="[PAUSED] "+this.windowTitle}UnpauseGame(){this.isPaused=!1,this.ticker.start(),document.title=this.windowTitle}ShowPauseDialog(){new Vd().show()}async ShowEndgameDialog(e){await new Hd(this.mission.name,this.MissionStats,e).show();const r=await new $d(this.mission.name,e,!e&&this.missionIndex+1{u.GameMaster.changeScene(new Ys)},C.Missions.forEach((e,s)=>{const n=new ct(new E(u.app.canvas.width/2-150,400+s*70,300,60),e.name,ot.Button01);n.onClick=r=>{u.GameMaster.changeScene(new Se(e.name))}})}}class Ys extends ki{init(){this.addMainBackground();const t={caption:"New Game",rect:new E(u.app.canvas.width/2-300/2,400+0*70,300,60),texture:ot.Button01},e={caption:"How to play",rect:new E(u.app.canvas.width/2-300/2,400+1*70,300,60),texture:ot.Button01};new E(u.app.canvas.width/2-300/2,400+2*70,300,60),ot.Button01;let s=new O({x:0,y:0,text:"Latest commit: "+u.latestCommit,style:{fill:16777215,fontSize:10,fontWeight:"bold"}});this.stage.addChild(s);const n=new ct(t.rect,t.caption,t.texture,!0);n.onClick=a=>{u.GameMaster.changeScene(new ge)};let r=new ct(e.rect,e.caption,e.texture,!0);r.onClick=a=>{u.GameMaster.changeScene(new yd)}}}class Yd{constructor(){p(this,"finished",!1);p(this,"calledBack",!1);p(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Xd extends Yd{constructor(e,s,n,r){super();p(this,"fadeType");p(this,"fadeTime");p(this,"pixiObject");p(this,"ticks",0);this.fadeType=e,this.fadeTime=s,this.pixiObject=n,this.callbackFn=r,e=="in"?this.pixiObject.alpha=0:this.pixiObject.alpha=1}update(e){if(super.update(e),this.pixiObject==null)return this.Finish();this.ticks++,this.fadeType=="in"?this.pixiObject.alpha=this.ticks/this.fadeTime:this.pixiObject.alpha-=1/this.fadeTime,this.ticks>=this.fadeTime&&this.Finish()}}class jd{constructor(){p(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const s=this.AnimationQueue[e];s.finished?(s.callbackFn(),this.AnimationQueue.splice(e,1)):s.update(t)}}}class qd{constructor(t,e,s,n,r){p(this,"textObj");p(this,"ticksToFadeAway");p(this,"animating",!1);p(this,"destroyed",!1);let a=16777215;e=="info"?a=2143228:e=="warn"?a=16570144:e=="danger"?a=16517642:e=="reward"?a=14047996:e=="gemaward"?a=16777215:e=="green"&&(a=65280),this.ticksToFadeAway=r,this.textObj=new O({text:t,style:new N({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:s,y:n,zIndex:100}),this.textObj.anchor.set(.5,.5),u.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class Kd extends _t{constructor(){super();p(this,"notifications",[]);p(this,"ticks",0);this.bb.x=u.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,u.app.stage.addChild(this.container)}Notify(e,s){let n=0,r=this.notifications.length*32;this.notifications.push(new qd(e,s,n,r,this.ticks+180))}update(e){this.ticks++;for(let s=this.notifications.length-1;s>=0;s--){const n=this.notifications[s];if(n.destroyed){this.notifications.splice(s,1);continue}this.ticks>=n.ticksToFadeAway&&!n.animating&&(n.animating=!0,u.AnimationManager.Animate(new Xd("out",300,n.textObj,()=>{n.destroy()})))}}}class Zd{constructor(t,e){p(this,"ticksToDestroyAt");p(this,"debris");this.debris=t,this.ticksToDestroyAt=e}destroy(){this.debris.destroy()}update(t){console.log(this.debris instanceof _t),this.debris instanceof _t&&this.debris.update(t)}}class Qd extends _t{constructor(){super(...arguments);p(this,"ticks",0);p(this,"debris",[])}update(e){this.ticks++;for(let s=this.debris.length-1;s>=0;s--){const n=this.debris[s];this.ticks>=n.ticksToDestroyAt?(n.destroy(),this.debris.splice(s,1)):n.update(e)}}CreateDebris(e,s){s||(s=120),this.debris.push(new Zd(e,this.ticks+s))}}(async()=>{const i=new qr;u.app=i,await i.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(i.canvas);function t(){const n=window.innerWidth,r=window.innerHeight,a=n/i.screen.width,o=r/i.screen.height,h=Math.min(a,o),l=Math.round(i.screen.width*h),c=Math.round(i.screen.height*h),d=(n-l)/2,f=(r-c)/2;i.canvas.style.width=`${l}px`,i.canvas.style.height=`${c}px`,i.canvas.style.marginLeft=`${d}px`,i.canvas.style.marginTop=`${f}px`,i.canvas.style.marginRight="0",i.canvas.style.marginBottom="0",i.canvas.style.display="block"}u.latestCommit=await fetch("./latest_commit").then(n=>n.text()),window.addEventListener("resize",t),t(),await C.LoadAssets(),Yt.init(),be.init(),new xd,u.AnimationManager=new jd,u.NotificationManager=new Kd,u.DebrisManager=new Qd,globalThis.Engine=u,Bt.shared.add(n=>{u.NotificationManager.update(n.elapsedMS),u.AnimationManager.update(n.elapsedMS),u.DebrisManager.update(n.elapsedMS)}),i.canvas.addEventListener("pointermove",function(n){u.MouseX=(n.clientX-i.canvas.offsetLeft)/i.canvas.offsetWidth*1920,u.MouseY=(n.clientY-i.canvas.offsetTop)/i.canvas.offsetHeight*1080}),u.GameMaster.changeScene(new Ys),new URLSearchParams(location.href).entries().next().value[1]=="game"&&u.GameMaster.changeScene(new Se("The Turn")),u.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":u.TestSuite();let s=!1;window.addEventListener("blur",()=>{u.GameScene&&!u.GameScene.isPaused&&(u.GameScene.PauseGame(),s=!0)}),window.addEventListener("focus",()=>{u.GameScene&&s&&u.GameScene.isPaused&&(s=!1,u.GameScene.UnpauseGame())})})();export{U as $,Vr as A,it as B,tt as C,Q as D,k as E,ur as F,Ci as G,It as H,fn as I,$ as J,jo as K,sh as L,H as M,nt as N,E as O,ht as P,bh as Q,fs as R,Wh as S,Ot as T,yi as U,gn as V,Mo as W,Wi as X,Z as Y,pr as Z,Yr as _,z as a,W as a0,Ah as a1,sa as a2,dl as a3,fl as a4,yl as a5,_l as a6,bl as a7,xe as a8,N as a9,dc as aa,Ts as ab,la as ac,Tn as ad,ce as ae,fd as af,qn as ag,xc as ah,Tt as ai,j as aj,to as ak,Cs as al,Xn as am,da as an,Bt as b,pt as c,Vt as d,lt as e,Cn as f,zh as g,pi as h,Bs as i,Nr as j,Cr as k,zr as l,Yn as m,tn as n,cl as o,ul as p,ml as q,fo as r,Qr as s,wl as t,Is as u,Rr as v,st as w,Ja as x,vl as y,zt as z};