const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-C3vN8kSD.js","assets/webworkerAll-C8kqtn2i.js","assets/colorToUniform-C1jQKuTl.js","assets/WebGPURenderer-C3uezquN.js","assets/SharedSystems-BDLhnKJG.js","assets/WebGLRenderer-De8XiEKN.js"])))=>i.map(i=>d[i]); var Ra=Object.defineProperty;var Fa=(s,t,e)=>t in s?Ra(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var g=(s,t,e)=>Fa(s,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"]'))i(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"&&i(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 i(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();const La="modulepreload",Da=function(s){return"/"+s},Ys={},ci=function(t,e,i){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=Da(h),h in Ys)return;Ys[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":La,l||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),l)return new Promise((u,f)=>{d.addEventListener("load",u),d.addEventListener("error",()=>f(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 P=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(P||{});const Zi=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},je=(s,t)=>Zi(s).priority??t,ht={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Zi).forEach(t=>{t.type.forEach(e=>{var i,n;return(n=(i=this._removeHandlers)[e])==null?void 0:n.call(i,t)})}),this},add(...s){return s.map(Zi).forEach(t=>{t.type.forEach(e=>{var r,a;const i=this._addHandlers,n=this._queue;i[e]?(a=i[e])==null||a.call(i,t):(n[e]=n[e]||[],(r=n[e])==null||r.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,n=this._removeHandlers;if(i[s]||n[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,n[s]=e;const r=this._queue;return r[s]&&((a=r[s])==null||a.forEach(o=>t(o)),delete r[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(r=>r.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((r,a)=>je(a.value,e)-je(r.value,e)))},i=>{const n=t.findIndex(r=>r.name===i.name);n!==-1&&t.splice(n,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,r)=>je(r,e)-je(n,e)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})}},za={extension:{type:P.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ci(()=>import("./browserAll-C3vN8kSD.js"),__vite__mapDeps([0,1,2]))}},Ua={extension:{type:P.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ci(()=>import("./webworkerAll-C8kqtn2i.js"),__vite__mapDeps([1,2]))}};class ct{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ct(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 bs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Qn={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,d,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new n(c,d||h,u),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],f]:h._events[m].push(f):(h._events[m]=f,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function o(){this._events=new i,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 u=0,f=d.length,m=new Array(f);uqt[s],uY:s=>Kt[s],vX:s=>Zt[s],vY:s=>Qt[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Qi[s][t],sub:(s,t)=>Qi[s][Y.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?Y.S:Y.N:Math.abs(t)*2<=Math.abs(s)?s>0?Y.E:Y.W:t>0?s>0?Y.SE:Y.SW:s>0?Y.NE:Y.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const n=Jn[Y.inv(t)];n.tx=e,n.ty=i,s.append(n)}},Ke=[new ot,new ot,new ot,new ot];class z{constructor(t=0,e=0,i=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),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 z(0,0,0,0)}clone(){return new z(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>u&&tm&&et.right?t.right:this.right)<=k)return!1;const C=this.yt.bottom?t.bottom:this.bottom)>C}const i=this.left,n=this.right,r=this.top,a=this.bottom;if(n<=i||a<=r)return!1;const o=Ke[0].set(t.left,t.top),h=Ke[1].set(t.left,t.bottom),l=Ke[2].set(t.right,t.top),c=Ke[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)<=i||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 u=d*(h.y-o.y),f=d*(o.x-h.x),m=u*i+f*r,y=u*n+f*r,x=u*i+f*a,_=u*n+f*a;if(Math.max(m,y,x,_)<=u*o.x+f*o.y||Math.min(m,y,x,_)>=u*c.x+f*c.y)return!1;const w=d*(o.y-l.y),b=d*(l.x-o.x),S=w*i+b*r,T=w*n+b*r,E=w*i+b*a,M=w*n+b*a;return!(Math.max(S,T,E,M)<=w*o.x+b*o.y||Math.min(S,T,E,M)>=w*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),i=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(i-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const i=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=i-this.x,this.height=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=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=i-e,this.y=n,this.height=r-n,this}getBounds(t){return t=t||new z,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ti={default:-1};function nt(s="default"){return Ti[s]===void 0&&(Ti[s]=-1),++Ti[s]}const js={},O="8.0.0",Ya="8.3.4";function W(s,t,e=3){if(js[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${s}`):(i=i.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${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${s}`),console.warn(i))),js[t]=!0}const tr=()=>{};function qs(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Ks(s){return!(s&s-1)&&!!s}function ja(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Zs=Object.create(null);function qa(s){const t=Zs[s];return t===void 0&&(Zs[s]=nt("resource")),t}const er=class ir extends dt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...ir.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){W(O,"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=qa(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};er.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Ka=er;const sr=class nr extends dt{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={...nr.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 Ka(ja(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.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,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const n=Math.round(t*i),r=Math.round(e*i);return this.width=n/i,this.height=r/i,this._resolution=i,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=Ks(this.pixelWidth)&&Ks(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};sr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Lt=sr;class Ss extends Lt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),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}}Ss.extension=P.TextureSource;const Qs=new H;class Za{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 i=this.mapCoord;for(let n=0;nthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new z);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=Js,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,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 u=this.minX,f=this.minY,m=this.maxX,y=this.maxY,x=a*t+h*e+c,_=o*t+l*e+d;xm&&(m=x),_>y&&(y=_),x=a*i+h*e+c,_=o*i+l*e+d,xm&&(m=x),_>y&&(y=_),x=a*t+h*n+c,_=o*t+l*n+d,xm&&(m=x),_>y&&(y=_),x=a*i+h*n+c,_=o*i+l*n+d,xm&&(m=x),_>y&&(y=_),this.minX=u,this.minY=f,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?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY,u=a*e+h*r+c,f=o*e+l*r+d,this.minX=uthis.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY,u=a*n+h*r+c,f=o*n+l*r+d,this.minX=uthis.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,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 Pt(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,i,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,u=n.d,f=n.tx,m=n.ty;for(let y=e;yo?w: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 Ja={grad:.9,turn:360,rad:360/(2*Math.PI)},Gt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},at=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},gt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},rr=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},tn=function(s){return{r:gt(s.r,0,255),g:gt(s.g,0,255),b:gt(s.b,0,255),a:gt(s.a)}},Ai=function(s){return{r:at(s.r),g:at(s.g),b:at(s.b),a:at(s.a,3)}},to=/^#([0-9a-f]{3,8})$/i,Ze=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},ar=function(s){var t=s.r,e=s.g,i=s.b,n=s.a,r=Math.max(t,e,i),a=r-Math.min(t,e,i),o=a?r===t?(e-i)/a:r===e?2+(i-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}},or=function(s){var t=s.h,e=s.s,i=s.v,n=s.a;t=t/360*6,e/=100,i/=100;var r=Math.floor(t),a=i*(1-e),o=i*(1-(t-r)*e),h=i*(1-(1-t+r)*e),l=r%6;return{r:255*[i,o,a,a,h,i][l],g:255*[h,i,i,o,a,a][l],b:255*[a,a,h,i,i,o][l],a:n}},en=function(s){return{h:rr(s.h),s:gt(s.s,0,100),l:gt(s.l,0,100),a:gt(s.a)}},sn=function(s){return{h:at(s.h),s:at(s.s),l:at(s.l),a:at(s.a,3)}},nn=function(s){return or((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},Ie=function(s){return{h:(t=ar(s)).h,s:(n=(200-(e=t.s))*(i=t.v)/100)>0&&n<200?e*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,i,n},eo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,io=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,so=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,no=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ji={string:[[function(s){var t=to.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?at(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?at(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=so.exec(s)||no.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:tn({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(s){var t=eo.exec(s)||io.exec(s);if(!t)return null;var e,i,n=en({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Ja[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return nn(n)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,n=s.a,r=n===void 0?1:n;return Gt(t)&&Gt(e)&&Gt(i)?tn({r:Number(t),g:Number(e),b:Number(i),a:Number(r)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,n=s.a,r=n===void 0?1:n;if(!Gt(t)||!Gt(e)||!Gt(i))return null;var a=en({h:Number(t),s:Number(e),l:Number(i),a:Number(r)});return nn(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,n=s.a,r=n===void 0?1:n;if(!Gt(t)||!Gt(e)||!Gt(i))return null;var a=function(o){return{h:rr(o.h),s:gt(o.s,0,100),v:gt(o.v,0,100),a:gt(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(r)});return or(a)},"hsv"]]},rn=function(s,t){for(var e=0;e=.5},s.prototype.toHex=function(){return t=Ai(this.rgba),e=t.r,i=t.g,n=t.b,a=(r=t.a)<1?Ze(at(255*r)):"","#"+Ze(e)+Ze(i)+Ze(n)+a;var t,e,i,n,r,a},s.prototype.toRgb=function(){return Ai(this.rgba)},s.prototype.toRgbString=function(){return t=Ai(this.rgba),e=t.r,i=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+i+", "+n+", "+r+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,r},s.prototype.toHsl=function(){return sn(Ie(this.rgba))},s.prototype.toHslString=function(){return t=sn(Ie(this.rgba)),e=t.h,i=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+r+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,r},s.prototype.toHsv=function(){return t=ar(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},s.prototype.invert=function(){return vt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),vt(Mi(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),vt(Mi(this.rgba,-t))},s.prototype.grayscale=function(){return vt(Mi(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),vt(an(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),vt(an(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?vt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=Ie(this.rgba);return typeof t=="number"?vt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},s.prototype.isEqual=function(t){return this.toHex()===vt(t).toHex()},s}(),vt=function(s){return s instanceof ts?s:new ts(s)},on=[],ao=function(s){s.forEach(function(t){on.indexOf(t)<0&&(t(ts,Ji),on.push(t))})};function oo(s,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"},i={};for(var n in e)i[e[n]]=n;var r={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=i[this.toHex()];if(l)return l;if(a!=null&&a.closest){var c=this.toRgb(),d=1/0,u="black";if(!r.length)for(var f in e)r[f]=new s(e[f]).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,i,n]=this._components;return{r:t,g:e,b:i,a:n}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,n,r]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,n,r]=Me._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,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 i=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(i=i*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(i<<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,i,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(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,i,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,i,n,r=255]=t,e/=255,i/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=Me.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=vt(t);a.isValid()&&({r:e,g:i,b:n,a:r}=a.rgba,e/=255,i/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,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,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Me||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}};de.shared=new de;de._temp=new de;de.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Z=de;const ho={cullArea:null,cullable:!1,cullableChildren:!0};class vs{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,(i=e.init)==null||i.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 lo{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 vs(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const Rt=new lo;function co(s,t,e){const i=s.length;let n;if(t>=i||e===0)return;e=t+e>i?i-t:e;const r=i-e;for(n=t;n0&&i<=e){for(let a=e-1;a>=s;a--){const o=this.children[a];o&&(n.push(o),o.parent=null)}co(this.children,s,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let a=0;a=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||W(O,"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(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const n=s.parent.children.indexOf(s);if(s.parent===this&&n===t)return s;n!==-1&&s.parent.children.splice(n,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s.didViewUpdate=!1,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s}};class hn{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;ei.priority-n.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),es.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=es.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},set filters(s){var r;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new hn);s=s;const e=(s==null?void 0:s.length)>0,i=((r=t.filters)==null?void 0:r.length)>0,n=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new hn),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},go={label:null,get name(){return W(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){W(O,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i-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 i=0;i0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(n)),(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(st.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||W(O,"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(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),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=Rt.get(vo,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),Rt.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*Na}set angle(t){this.rotation=t*Ha}get pivot(){return this._pivot===Ii&&(this._pivot=new ct(this,0,0)),this._pivot}set pivot(t){this._pivot===Ii&&(this._pivot=new ct(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Gi&&(this._skew=new ct(this,0,0)),this._skew}set skew(t){this._skew===Gi&&(this._skew=new ct(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Bi&&(this._scale=new ct(this,1,1)),this._scale}set scale(t){this._scale===Bi&&(this._scale=new ct(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 i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.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,i=this._scale,n=this._pivot,r=this._position,a=i._x,o=i._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|=cn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Z.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=cn,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|=To,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|=Ei,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|=Ei,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|=Ei,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&&i<=e.maxX&&n>=e.minY&&n<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class V extends mi{constructor(t=D.EMPTY){t instanceof D&&(t={texture:t});const{texture:e=D.EMPTY,anchor:i,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 ct({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i: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 D?new V(t):new V(D.from(t,e))}set texture(t){t||(t=D.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(){Qa(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:n,height:r}=e.orig;i.maxX=-t._x*n,i.minX=i.maxX+n,i.maxY=-t._y*r,i.minY=i.maxY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}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 Ao=new Pt;function pr(s,t,e){const i=Ao;s.measurable=!0,hr(s,e,i),t.addBoundsMask(i),s.measurable=!1}function gr(s,t,e){const i=ue.get();s.measurable=!0;const n=Ft.get().identity(),r=mr(s,e,n);cr(s,i,r),s.measurable=!1,t.addBoundsMask(i),Ft.return(n),ue.return(i)}function mr(s,t,e){return s?(s!==t&&(mr(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(it("Mask bounds, renderable is not inside the root container"),e)}class xr{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 V),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){pr(this.mask,t,e)}addLocalBounds(t,e){gr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof V}}xr.extension=P.MaskEffect;class yr{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"}}yr.extension=P.MaskEffect;class _r{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){pr(this.mask,t,e)}addLocalBounds(t,e){gr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof st}}_r.extension=P.MaskEffect;const Mo={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let dn=Mo;const Q={get(){return dn},set(s){dn=s}};class wr extends Lt{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,i=this._resolution){const n=super.resize(t,e,i);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"))}}wr.extension=P.TextureSource;class pe extends Lt{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,it("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}}pe.extension=P.TextureSource;var ui=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(ui||{});class Ri{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,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 br=class ut{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 Ri(null,null,1/0),this.deltaMS=1/ut.targetFPMS,this.elapsedMS=1/ut.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,i=ui.NORMAL){return this._addListener(new Ri(t,e,i))}addOnce(t,e,i=ui.NORMAL){return this._addListener(new Ri(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.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 i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,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(i),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Fi}const xi=class vr extends Lt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...vr.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=At.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 Sr(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,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&&(At.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||(At.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(At.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};xi.extension=P.TextureSource;xi.defaultOptions={...Lt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};xi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ai=xi;const _t=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class Po{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||it(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=_t(t);let n;for(let h=0;h{r.set(h,e)});const a=[...r.keys()],o={cacheKeys:a,keys:i};i.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&&it("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){it(`[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 Po,is=[];ht.handleByList(P.TextureSource,is);function Cr(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let n=0;n{j.has(i)&&j.remove(i)}),t||j.set(i,r),r}function Go(s,t=!1){return typeof s=="string"?j.get(s):s instanceof Lt?new D({source:s}):ko(s,t)}D.from=Go;Lt.from=Cr;ht.add(xr,yr,_r,ai,pe,wr,Ss);var Nt=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(Nt||{});function yt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function Se(s){return s.split("?")[0].split("#")[0]}function Io(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bo(s,t,e){return s.replace(new RegExp(Io(t),"g"),e)}function Eo(s,t){let e="",i=0,n=-1,r=0,a=-1;for(let o=0;o<=s.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),n=o,r=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=o,r=0;continue}}}else e.length>0?e+=`/${s.slice(n+1,o)}`:e=s.slice(n+1,o),i=o-n-1;n=o,r=0}else a===46&&r!==-1?++r:r=-1}return e}const ft={toPosix(s){return Bo(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){yt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(yt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=Se(this.toPosix(t??Q.get().getBaseUrl())),n=Se(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?ft.join(n,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(yt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=Eo(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return yt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=i;else{const n=s[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(yt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,n=!0;const r=this.getProtocol(s),a=s;s=s.slice(r.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!n){i=o;break}}else n=!1;return i===-1?e?"/":this.isUrl(a)?r+s:r:e&&i===1?"//":r+s.slice(0,i)},rootname(s){yt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){yt(s),t&&yt(t),s=Se(this.toPosix(s));let e=0,i=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(r=s.length-1;r>=0;--r){const h=s.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&&(i=r):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(r=s.length-1;r>=0;--r)if(s.charCodeAt(r)===47){if(!n){e=r+1;break}}else i===-1&&(n=!1,i=r+1);return i===-1?"":s.slice(e,i)},extname(s){yt(s),s=Se(this.toPosix(s));let t=-1,e=0,i=-1,n=!0,r=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}i===-1&&(n=!1,i=a+1),o===46?t===-1?t=a:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||i===-1||r===0||r===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){yt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=Se(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let n;t.root=this.rootname(s),i||this.hasProtocol(s)?n=1:n=0;let r=-1,a=0,o=-1,h=!0,l=s.length-1,c=0;for(;l>=n;--l){if(e=s.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&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,r),t.base=s.slice(1,o)):(t.name=s.slice(a,r),t.base=s.slice(a,o)),t.ext=s.slice(r,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Tr(s,t,e,i,n){const r=t[e];for(let a=0;a{const a=r.substring(1,r.length-1).split(",");n.push(a)}),Tr(s,n,0,e,i)}else i.push(s);return i}const fi=s=>!Array.isArray(s);class ge{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(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return _t(e||i,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&&it("[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 i=[];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);i.push(l),h=[o,l]}else{const l=o.map(c=>this._createBundleAssetId(t,c));i.push(...l),h=[...o,...l]}this.add({...r,alias:h,src:a})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=r=>{this.hasKey(r)&&it(`[Resolver] already has key: ${r} overwriting`)},_t(e).forEach(r=>{const{src:a}=r;let{data:o,format:h,loadParser:l}=r;const c=_t(a).map(f=>typeof f=="string"?Ro(f):Array.isArray(f)?f:[f]),d=this.getAlias(r);Array.isArray(d)?d.forEach(i):i(d);const u=[];c.forEach(f=>{f.forEach(m=>{let y={};if(typeof m!="object"){y.src=m;for(let x=0;x{this._assetMap[f]=u})})}resolveBundle(t){const e=fi(t);t=_t(t);const i={};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}i[n]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const n in e)i[n]=e[n].src;return i}return e.src}resolve(t){const e=fi(t);t=_t(t);const i={};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},{});i[n]=this._resolverHash[n]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;er.params.format.includes(i.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:i,data:n,loadParser:r,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=ft.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??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??Fo(t.src),t}}ge.RETINA_PREFIX=/@([0-9\.]+)x/;function Fo(s){return s.split(".").pop().split("?").shift().split("#").shift()}const ss=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},Ar=class Pe{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof D?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const i=parseFloat(e.meta.scale);i?(this.resolution=i,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<=Pe.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Pe.BATCH_SIZE;for(;e-t{this._batchIndex*Pe.BATCH_SIZE{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[n]=t.textures[n]}),!e){const n=ft.dirname(s[0]);t.linkedSheets.forEach((r,a)=>{const o=Mr([`${n}/${t.data.meta.related_multi_packs[a]}`],r,!0);Object.assign(i,o)})}return i}const Do={extension:P.Asset,cache:{test:s=>s instanceof un,getCacheableAssets:(s,t)=>Mr(s,t,!1)},resolver:{extension:{type:P.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),n=e.pop();return i==="json"&&Lo.includes(n)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=ge.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:P.LoadParser,priority:Nt.Normal,name:"spritesheetLoader"},async testParse(s,t){return ft.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var l,c;const{texture:i,imageFilename:n}=(t==null?void 0:t.data)??{};let r=ft.dirname(t.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let a;if(i instanceof D)a=i;else{const d=ss(r+(n??s.meta.image),t.src);a=(await e.load([d]))[d]}const o=new un(a.source,s);await o.parse();const h=(l=s==null?void 0:s.meta)==null?void 0:l.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let m=r+f;(c=t.data)!=null&&c.ignoreMultiPack||(m=ss(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const u=await Promise.all(d);o.linkedSheets=u,u.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(m=>m!==f))})}return o},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};ht.add(Do);const Li=Object.create(null),fn=Object.create(null);function Cs(s,t){let e=fn[s];return e===void 0&&(Li[t]===void 0&&(Li[t]=1),fn[s]=e=Li[t]++),e}let ne;function Pr(){return(!ne||ne!=null&&ne.isContextLost())&&(ne=Q.get().createCanvas().getContext("webgl",{})),ne}let Qe;function zo(){if(!Qe){Qe="mediump";const s=Pr();s&&s.getShaderPrecisionFormat&&(Qe=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Qe}function Uo(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying #define finalColor gl_FragColor #define texture texture2D #endif ${s} `):` #ifdef GL_ES // This checks if it is WebGL1 #define in attribute #define out varying #endif ${s} `}function Wo(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&i!=="highp"&&(n="mediump"),`precision ${n} float; ${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Oo(s,t){return t?`#version 300 es ${s}`:s}const No={},Ho={};function $o(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?No:Ho;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`} ${s}`}function Vo(s,t){return t?s.replace("#version 300 es",""):s}const Di={stripVersion:Vo,ensurePrecision:Wo,addProgramDefines:Uo,setProgramName:$o,insertVersion:Oo},zi=Object.create(null),kr=class ns{constructor(t){t={...ns.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:zo()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(Di).forEach(a=>{const o=i[a];n=Di[a](n,o,!0),r=Di[a](r,o,!1)}),this.fragment=n,this.vertex=r,this._key=Cs(`${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 zi[e]||(zi[e]=new ns(t)),zi[e]}};kr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Gr=kr;const pn={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 Xo(s){return pn[s]??pn.float32}const Yo={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 jo({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const n=s.indexOf("->",i);if(n!==-1){const r=s.substring(i,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=Yo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Xo(h).stride,offset:0,instance:!1,start:0}}}}return e}function Ui(s){var d,u;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@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=s.match(t))==null?void 0:d.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(i)[1],10),name:f.match(n)[2],isUniform:f.match(n)[1]==="",type:f.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=((u=s.match(a))==null?void 0:u.map(f=>{const m=f.match(h)[1],y=f.match(o).reduce((x,_)=>{const[w,b]=_.split(":");return x[w.trim()]=b.trim(),x},{});return y?{name:m,members:y}:null}).filter(({name:f})=>l.some(m=>m.type===f)))??[];return{groups:l,structs:c}}var ke=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(ke||{});function qo({groups:s}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),r=[...s.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:n,groups:r}}const Wi=Object.create(null);class yi{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:n,gpuLayout:r,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=i,e.source===i.source){const l=Ui(e.source);this.structsAndGroups=l}else{const l=Ui(i.source),c=Ui(e.source);this.structsAndGroups=Zo(l,c)}this.layout=n??Ko(this.structsAndGroups),this.gpuLayout=r??qo(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,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Cs(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=jo(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 Wi[e]||(Wi[e]=new yi(t)),Wi[e]}}const Ir=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],Qo=Ir.reduce((s,t)=>(s[t]=!0,s),{});function Jo(s,t){switch(s){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 Br=class Er{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={...Er.defaultOptions,...e},this.uniformStructures=t;const i={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!Qo[r.type])throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${Ir.join(", ")}`);r.value??(r.value=Jo(r.type,r.size)),i[n]=r.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Cs(Object.keys(i).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Br.defaultOptions={ubo:!1,isStatic:!1};let Rr=Br;class oi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const n=t[i];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var n,r;const i=this.resources[e];t!==i&&(i&&((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 i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const n=t[i];(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 i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var rs=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(rs||{});class Ts extends dt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:n,resources:r,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=rs.WEBGPU),i&&(a|=rs.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 oi,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 u=r[c];!u.source&&!u._resourceType&&(u=new Rr(u));const f=h[d];f&&(n[f.group]||(n[f.group]=new oi,this._ownedBindGroups.push(n[f.group])),n[f.group].setResource(u,f.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,i){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[i]||(r[i]=t),this.groups[e]||(this.groups[e]=new oi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const r=e[n];Object.defineProperty(i,r.name,{get(){return t[r.group].getResource(r.binding)},set(a){t[r.group].setResource(a,r.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.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:i,...n}=t;let r,a;return e&&(r=yi.from(e)),i&&(a=Gr.from(i)),new Ts({gpuProgram:r,glProgram:a,...n})}}const as=[];ht.handleByNamedList(P.Environment,as);async function th(s){if(!s)for(let t=0;t80*e){o=l=s[0],h=c=s[1];for(var m=e;ml&&(l=d),u>c&&(c=u);f=Math.max(l-o,c-h),f=f!==0?32767/f:0}return Re(r,a,e,o,h,f,0),a}function Fr(s,t,e,i,n){var r,a;if(n===ls(s,t,e,i)>0)for(r=t;r=t;r-=i)a=gn(r,s[r],s[r+1],a);return a&&wi(a,a.next)&&(Le(a),a=a.next),a}function ie(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(wi(e,e.next)||q(e.prev,e,e.next)===0)){if(Le(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Re(s,t,e,i,n,r,a){if(s){!a&&r&&dh(s,i,n,r);for(var o=s,h,l;s.prev!==s.next;){if(h=s.prev,l=s.next,r?sh(s,i,n,r):ih(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(l.i/e|0),Le(s),s=l.next,o=l.next;continue}if(s=l,s===o){a?a===1?(s=nh(ie(s),t,e),Re(s,t,e,i,n,r,2)):a===2&&rh(s,t,e,i,n,r):Re(ie(s),t,e,i,n,r,1);break}}}}function ih(s){var t=s.prev,e=s,i=s.next;if(q(t,e,i)>=0)return!1;for(var n=t.x,r=e.x,a=i.x,o=t.y,h=e.y,l=i.y,c=nr?n>a?n:a:r>a?r:a,f=o>h?o>l?o:l:h>l?h:l,m=i.next;m!==t;){if(m.x>=c&&m.x<=u&&m.y>=d&&m.y<=f&&he(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 sh(s,t,e,i){var n=s.prev,r=s,a=s.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,u=a.y,f=oh?o>l?o:l:h>l?h:l,x=c>d?c>u?c:u:d>u?d:u,_=os(f,m,t,e,i),w=os(y,x,t,e,i),b=s.prevZ,S=s.nextZ;b&&b.z>=_&&S&&S.z<=w;){if(b.x>=f&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&he(o,c,h,d,l,u,b.x,b.y)&&q(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=f&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&he(o,c,h,d,l,u,S.x,S.y)&&q(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=_;){if(b.x>=f&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&he(o,c,h,d,l,u,b.x,b.y)&&q(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=w;){if(S.x>=f&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&he(o,c,h,d,l,u,S.x,S.y)&&q(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function nh(s,t,e){var i=s;do{var n=i.prev,r=i.next.next;!wi(n,r)&&Lr(n,i,i.next,r)&&Fe(n,r)&&Fe(r,n)&&(t.push(n.i/e|0),t.push(i.i/e|0),t.push(r.i/e|0),Le(i),Le(i.next),i=s=r),i=i.next}while(i!==s);return ie(i)}function rh(s,t,e,i,n,r){var a=s;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&ph(a,o)){var h=Dr(a,o);a=ie(a,a.next),h=ie(h,h.next),Re(a,t,e,i,n,r,0),Re(h,t,e,i,n,r,0);return}o=o.next}a=a.next}while(a!==s)}function ah(s,t,e,i){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<=i&&o>r&&(r=o,a=e.x=e.x&&e.x>=l&&i!==e.x&&he(na.x||e.x===a.x&&ch(a,e)))&&(a=e,d=u)),e=e.next;while(e!==h);return a}function ch(s,t){return q(s.prev,s,t.prev)<0&&q(t.next,s,s.next)<0}function dh(s,t,e,i){var n=s;do n.z===0&&(n.z=os(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,uh(n)}function uh(s){var t,e,i,n,r,a,o,h,l=1;do{for(e=s,s=null,r=null,a=0;e;){for(a++,i=e,o=0,t=0;t0||h>0&&i;)o!==0&&(h===0||!i||e.z<=i.z)?(n=e,e=e.nextZ,o--):(n=i,i=i.nextZ,h--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;e=i}r.nextZ=null,l*=2}while(a>1);return s}function os(s,t,e,i,n){return s=(s-e)*n|0,t=(t-i)*n|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function fh(s){var t=s,e=s;do(t.x=(s-a)*(r-o)&&(s-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(n-a)*(i-o)}function ph(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!gh(s,t)&&(Fe(s,t)&&Fe(t,s)&&mh(s,t)&&(q(s.prev,s,t.prev)||q(s,t.prev,t))||wi(s,t)&&q(s.prev,s,s.next)>0&&q(t.prev,t,t.next)>0)}function q(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function wi(s,t){return s.x===t.x&&s.y===t.y}function Lr(s,t,e,i){var n=ti(q(s,t,e)),r=ti(q(s,t,i)),a=ti(q(e,i,s)),o=ti(q(e,i,t));return!!(n!==r&&a!==o||n===0&&Je(s,e,t)||r===0&&Je(s,i,t)||a===0&&Je(e,s,i)||o===0&&Je(e,t,i))}function Je(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function ti(s){return s>0?1:s<0?-1:0}function gh(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&Lr(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Fe(s,t){return q(s.prev,s,s.next)<0?q(s,t,s.next)>=0&&q(s,s.prev,t)>=0:q(s,t,s.prev)<0||q(s,s.next,t)<0}function mh(s,t){var e=s,i=!1,n=(s.x+t.x)/2,r=(s.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&&(i=!i),e=e.next;while(e!==s);return i}function Dr(s,t){var e=new hs(s.i,s.x,s.y),i=new hs(t.i,t.x,t.y),n=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=n,n.prev=e,i.next=e,e.prev=i,r.next=i,i.prev=r,i}function gn(s,t,e,i){var n=new hs(s,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Le(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function hs(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}_i.deviation=function(s,t,e,i){var n=t&&t.length,r=n?t[0]*e:s.length,a=Math.abs(ls(s,0,r,e));if(n)for(var o=0,h=t.length;o0&&(i+=s[n-1].length,e.holes.push(i))}return e};var xh=As.exports;const yh=bs(xh);var zr=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(zr||{});class _h{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,r,a,o,h){const{name:l,items:c}=this;for(let d=0,u=c.length;d{this.runners[e]=new _h(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const n in this.runners)this.runners[n].add(i);return this}_addPipes(t,e){const i=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,a=n.name,o=i[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(!eh())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Ur.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Or=Ur,ei;function bh(s){return ei!==void 0||(ei=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??Or.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}})()),ei}let ii;async function Sh(s={}){return ii!==void 0||(ii=await(async()=>{const t=Q.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),ii}const mn=["webgl","webgpu","canvas"];async function vh(s){let t=[];s.preference?(t.push(s.preference),mn.forEach(r=>{r!==s.preference&&t.push(r)})):t=mn.slice();let e,i={};for(let r=0;r{const{WebGPURenderer:h}=await import("./WebGPURenderer-C3uezquN.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,i={...s,...s.webgpu};break}else if(a==="webgl"&&bh(s.failIfMajorPerformanceCaveat??Or.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await ci(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-De8XiEKN.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,i={...s,...s.webgl};break}else if(a==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(i),n}const Nr="8.4.0";class Hr{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Nr)}static destroy(){}}Hr.extension=P.Application;class Ch{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Nr)}destroy(){this._renderer=null}}Ch.extension={type:[P.WebGLSystem,P.WebGPUSystem],name:"initHook",priority:-10};const $r=class cs{constructor(...t){this.stage=new st,t[0]!==void 0&&W(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await vh(t),cs._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return W(O,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=cs._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};$r._plugins=[];let Vr=$r;ht.handleByList(P.Application,Vr._plugins);ht.add(Hr);class Xr extends dt{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 W(O,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return W(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return W(O,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return W(O,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return W(O,"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 i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}const Yr=class ds{constructor(t,e,i,n){this.uid=nt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=i,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=ds.defaultTextureSize,{gradientStops:e}=this,i=Q.get().createCanvas();i.width=t,i.height=t;const n=i.getContext("2d"),r=n.createLinearGradient(0,0,ds.defaultTextureSize,1);for(let y=0;y`${n.offset}-${n.color}`).join("-"),e=this.texture.uid,i=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${i}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Yr.defaultTextureSize=256;let De=Yr;const xn={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 bi{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=xn[e].addressModeU,t.source.style.addressModeV=xn[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 Th=Mh,Oi={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Ah=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Mh(s){var t=[];return s.replace(Ah,function(e,i,n){var r=i.toLowerCase();for(n=kh(n),r=="m"&&n.length>2&&(t.push([i].concat(n.splice(0,2))),r="l",i=i=="m"?"l":"L");;){if(n.length==Oi[r])return n.unshift(i),t.push(n);if(n.length0&&(n=i.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:it(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:a},i.push(n))}return t}class Ms{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Ms(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const n=this.x-t,r=this.y-e,a=this.radius,o=i/2,h=Math.sqrt(n*n+r*r);return ha-o}getBounds(t){return t=t||new z,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 Ps{constructor(t=0,e=0,i=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=n}clone(){return new Ps(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(t,e,i){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const a=i/2,o=n-a,h=r-a,l=n+a,c=r+a,d=t-this.x,u=e-this.y,f=d*d/(o*o)+u*u/(h*h),m=d*d/(l*l)+u*u/(c*c);return f>1&&m<=1}getBounds(t){return t=t||new z,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 Bh(s,t,e,i,n,r){const a=s-e,o=t-i,h=n-e,l=r-i,c=a*h+o*l,d=h*h+l*l;let u=-1;d!==0&&(u=c/d);let f,m;u<0?(f=e,m=i):u>1?(f=n,m=r):(f=e+u*h,m=i+u*l);const y=s-f,x=t-m;return y*y+x*x}class Be{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let n=0,r=e.length;ne!=c>e&&t<(l-o)*((e-h)/(c-h))+o&&(i=!i)}return i}strokeContains(t,e,i){const n=i/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=i,t.width=n-i,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 si=(s,t,e,i,n,r)=>{const a=s-e,o=t-i,h=Math.sqrt(a*a+o*o);return h>=n-r&&h<=n+r};class ks{constructor(t=0,e=0,i=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=r}getBounds(t){return t=t||new z,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new ks(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 i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let n=t-(this.x+i),r=e-(this.y+i);const a=i*i;if(n*n+r*r<=a||(n=t-(this.x+this.width-i),n*n+r*r<=a)||(r=e-(this.y+this.height-i),n*n+r*r<=a)||(n=t-(this.x+i),n*n+r*r<=a))return!0}return!1}strokeContains(t,e,i){const{x:n,y:r,width:a,height:o,radius:h}=this,l=i/2,c=n+h,d=r+h,u=a-h*2,f=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+f||(e>=r-l&&e<=r+l||e>=y-l&&e<=y+l)&&t>=c&&t<=c+u?!0:tm-h&&em-h&&e>y-h&&si(t,e,m-h,y-h,h,l)||ty-h&&si(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 Eh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function Rh(s){let t="";for(let e=0;e0&&(t+=` else `),e>>=0;return qr[e]||Dh(s,t,e)}let Ni=0;function Dh(s,t,e){const i={};let n=0;Ni||(Ni=jr());for(let a=0;a0){const a=new Uint8Array(s,e*8,r);new Uint8Array(t,e*8,r).set(a)}}const zh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Uh=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",s[s.NONE=4]="NONE",s))(Uh||{});function wn(s,t){return t.alphaMode==="no-premultiply-alpha"&&zh[s]||s}class Wh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?Kr[--us]:new Oh}function Sn(s){Kr[us++]=s}let Ce=0;const Zr=class hi{constructor(t={}){this.uid=nt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],hi.defaultOptions.maxTextures=hi.defaultOptions.maxTextures??jr(),t={...hi.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:n}=t;this.attributeBuffer=new yn(i*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,u="startBatch";const f=this.maxTextures;for(let m=this.elementStart;m=f||b)&&(this._finishBatch(i,d,c-d,n,a,t,u),u="renderBatch",d=c,a=w,i=bn(),n=i.textures,n.clear(),++Ce),y._textureId=_._textureBindLocation=n.count,n.ids[_.uid]=n.count,n.textures[n.count++]=_,y._batch=i,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(i,d,c-d,n,a,t,u),d=c,++Ce),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,i,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=i,++Ce,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),i=new yn(e);_n(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(et||{});class Ut extends dt{constructor(t){let{data:e,size:i}=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,i=i??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,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&et.STATIC)}set static(t){t?this.descriptor.usage|=et.STATIC:this.descriptor.usage&=~et.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const n=this._data;if(this._data=t,n.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=f),m>h&&(h=m),fe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Vh=new Float32Array(1),Xh=new Uint32Array(1);class Yh extends Jr{constructor(){const e=new Ut({data:Vh,label:"attribute-batch-buffer",usage:et.VERTEX|et.COPY_DST,shrinkToFit:!1}),i=new Ut({data:Xh,label:"index-batch-buffer",usage:et.INDEX|et.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:i})}}function vn(s,t,e){if(s)for(const i in s){const n=i.toLocaleLowerCase(),r=t[n];if(r){let a=s[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(a)}else it(`${i} placement hook does not exist in shader`)}}const jh=/\{\{(.*?)\}\}/g;function Cn(s){var i;const t={};return(((i=s.match(jh))==null?void 0:i.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function Tn(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function An(s,t,e=!1){const i=[];Tn(t,i),s.forEach(o=>{o.header&&Tn(o.header,i)});const n=i;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 Mn(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function qh(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Kh(s){const t=/@.*?\s+/g;return s.replace(t,"")}function Zh(s,t){const e=[];Mn(t,e),s.forEach(h=>{h.header&&Mn(h.header,e)});let i=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`, `),r=e.sort().map(h=>` var ${Kh(h)};`).join(` `),a=`return VSOutput( ${e.sort().map(h=>` ${qh(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 Pn(s,t){let e=s;for(const i in t){const n=t[i];n.join(` `).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----// ${n.join(` `)} //----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const zt=Object.create(null),Hi=new Map;let Qh=0;function Jh({template:s,bits:t}){const e=ta(s,t);if(zt[e])return zt[e];const{vertex:i,fragment:n}=el(s,t);return zt[e]=ea(i,n,t),zt[e]}function tl({template:s,bits:t}){const e=ta(s,t);return zt[e]||(zt[e]=ea(s.vertex,s.fragment,t)),zt[e]}function el(s,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let n=An(e,s.vertex,!0);n=Zh(e,n);const r=An(i,s.fragment,!0);return{vertex:n,fragment:r}}function ta(s,t){return t.map(e=>(Hi.has(e)||Hi.set(e,Qh++),Hi.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function ea(s,t,e){const i=Cn(s),n=Cn(t);return e.forEach(r=>{vn(r.vertex,i,r.name),vn(r.fragment,n,r.name)}),{vertex:Pn(s,i),fragment:Pn(t,n)}}const il=` @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}} }; `,sl=` @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; }; `,nl=` 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}} } `,rl=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,al={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},ol={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};function hl({bits:s,name:t}){const e=Jh({template:{fragment:sl,vertex:il},bits:[al,...s]});return yi.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function ll({bits:s,name:t}){return new Gr({name:t,...tl({template:{vertex:nl,fragment:rl},bits:[ol,...s]})})}const cl={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},dl={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},$i={};function ul(s){const t=[];if(s===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 i=0;i;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` `)}function fl(s){const t=[];if(s===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; ${ul(s)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${fl(s)} `}}),$i[s]}const Vi={};function gl(s){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; } `}},yl={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; } `}},kn={};function _l(s){let t=kn[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i>16&255,i=s>>8&255,n=s&255,r=t>>16&255,a=t>>8&255,o=t&255,h=e*r/255,l=i*a/255,c=n*o/255;return(h<<16)+(l<<8)+c}const Tl=new H;class ra{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,i=this.renderable;return i?Cl(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||Tl}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 ze={extension:{type:P.ShapeBuilder,name:"circle"},build(s,t){let e,i,n,r,a,o;if(s.type==="circle"){const S=s;e=S.x,i=S.y,a=o=S.radius,n=r=0}else if(s.type==="ellipse"){const S=s;e=S.x,i=S.y,a=S.halfWidth,o=S.halfHeight,n=r=0}else{const S=s,T=S.width/2,E=S.height/2;e=S.x+T,i=S.y+E,a=o=Math.max(0,Math.min(S.radius,Math.min(T,E))),n=T-a,r=E-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]=i+r,t[2]=t[4]=e-n,t[5]=t[7]=i-r,t;let c=0,d=h*4+(n?2:0)+2,u=d,f=l,m=n+a,y=r,x=e+m,_=e-m,w=i+y;if(t[c++]=x,t[c++]=w,t[--d]=w,t[--d]=_,r){const S=i-y;t[u++]=_,t[u++]=S,t[--f]=S,t[--f]=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}},Al={...ze,extension:{...ze.extension,name:"ellipse"}},Ml={...ze,extension:{...ze.extension,name:"roundedRectangle"}},Pl=1e-4,In=1e-4;function kl(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,n=s[t-2],r=s[t-1];id&&(d+=Math.PI*2);let u=c;const f=d-c,m=Math.abs(f),y=Math.sqrt(h*h+l*l),x=(15*m*Math.sqrt(y)/Math.PI>>0)+1,_=f/x;if(u+=_,o){a.push(s,t),a.push(e,i);for(let w=1,b=u;w=0&&(c.join==="round"?w+=jt(v,C,v-R*I,C-B*I,v-X*I,C-J*I,x,!1)+4:w+=2,x.push(v-X*F,C-J*F),x.push(v+X*I,C+J*I));continue}const $s=(-R+M)*(-B+C)-(-R+v)*(-B+k),Vs=(-X+K)*(-J+C)-(-X+v)*(-J+kt),Xe=(Dt*Vs-_e*$s)/Ve,Ye=(we*$s-ye*Vs)/Ve,vi=(Xe-v)*(Xe-v)+(Ye-C)*(Ye-C),$t=v+(Xe-v)*I,Vt=C+(Ye-C)*I,Xt=v-(Xe-v)*F,Yt=C-(Ye-C)*F,Ba=Math.min(Dt*Dt+ye*ye,_e*_e+we*we),Xs=be?I:F,Ea=Ba+Xs*Xs*T;vi<=Ea?c.join==="bevel"||vi/T>E?(be?(x.push($t,Vt),x.push(v+R*F,C+B*F),x.push($t,Vt),x.push(v+X*F,C+J*F)):(x.push(v-R*I,C-B*I),x.push(Xt,Yt),x.push(v-X*I,C-J*I),x.push(Xt,Yt)),w+=2):c.join==="round"?be?(x.push($t,Vt),x.push(v+R*F,C+B*F),w+=jt(v,C,v+R*F,C+B*F,v+X*F,C+J*F,x,!0)+4,x.push($t,Vt),x.push(v+X*F,C+J*F)):(x.push(v-R*I,C-B*I),x.push(Xt,Yt),w+=jt(v,C,v-R*I,C-B*I,v-X*I,C-J*I,x,!1)+4,x.push(v-X*I,C-J*I),x.push(Xt,Yt)):(x.push($t,Vt),x.push(Xt,Yt)):(x.push(v-R*I,C-B*I),x.push(v+R*F,C+B*F),c.join==="round"?be?w+=jt(v,C,v+R*F,C+B*F,v+X*F,C+J*F,x,!0)+2:w+=jt(v,C,v-R*I,C-B*I,v-X*I,C-J*I,x,!1)+2:c.join==="miter"&&vi/T<=E&&(be?(x.push(Xt,Yt),x.push(Xt,Yt)):(x.push($t,Vt),x.push($t,Vt)),w+=2),x.push(v-X*I,C-J*I),x.push(v+X*F,C+J*F),w+=2)}M=s[(_-2)*2],k=s[(_-2)*2+1],v=s[(_-1)*2],C=s[(_-1)*2+1],R=-(k-C),B=M-v,xt=Math.sqrt(R*R+B*B),R/=xt,B/=xt,R*=S,B*=S,x.push(v-R*I,C-B*I),x.push(v+R*F,C+B*F),m||(c.cap==="round"?w+=jt(v-R*(I-F)*.5,C-B*(I-F)*.5,v-R*I,C-B*I,v+R*F,C+B*F,x,!1)+2:c.cap==="square"&&(w+=Bn(v,C,R,B,I,F,!1,x)));const Ia=In*In;for(let $=b;$=0&&a>=0&&(t[0]=i,t[1]=n,t[2]=i+r,t[3]=n,t[4]=i+r,t[5]=n+a,t[6]=i,t[7]=n+a),t},triangulate(s,t,e,i,n,r){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[6],t[i+a+1]=s[7],a+=e,t[i+a]=s[4],t[i+a+1]=s[5],a+=e;const o=i/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2,n[r++]=o+1,n[r++]=o+3,n[r++]=o+2}},Rl={extension:{type:P.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,t},triangulate(s,t,e,i,n,r){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[4],t[i+a+1]=s[5];const o=i/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2}},Si={};ht.handleByMap(P.ShapeBuilder,Si);ht.add(El,Bl,Rl,ze,Al,Ml);const Fl=new z;function Ll(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n{const f=h.length,m=a.length/2,y=[],x=Si[c.type];if(x.build(c,y),d&&na(y,d),i){const S=c.closePath??!0;Gl(y,t,!1,S,a,2,m,h)}else if(e&&l===u){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],T=y.slice();zl(e.shapePath).forEach(M=>{S.push(T.length/2),T.push(...M)}),aa(T,S,a,2,m,h,f)}else x.triangulate(y,a,2,m,h,f);const _=o.length/2,w=t.texture;if(w!==D.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),Sl(a,2,m,o,_,2,a.length/2-m,S))}else vl(o,_,2,a.length/2-m);const b=Rt.get(ra);b.indexOffset=f,b.indexSize=h.length-f,b.attributeOffset=m,b.attributeSize=a.length/2-m,b.baseColor=t.color,b.alpha=t.alpha,b.texture=w,b.geometryData=r,n.push(b)})}function zl(s){if(!s)return[];const t=s.shapePrimitives,e=[];for(let i=0;i{Rt.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Gs.extension={type:[P.WebGLSystem,P.WebGPUSystem,P.CanvasSystem],name:"graphicsContext"};Gs.defaultOptions={bezierSmoothness:.5};let oa=Gs;const Ol=8,ni=11920929e-14,Nl=1;function ha(s,t,e,i,n,r,a,o,h,l){const d=Math.min(.99,Math.max(0,l??oa.defaultOptions.bezierSmoothness));let u=(Nl-d)/1;return u*=u,Hl(t,e,i,n,r,a,o,h,s,u),s}function Hl(s,t,e,i,n,r,a,o,h,l){ps(s,t,e,i,n,r,a,o,h,l,0),h.push(a,o)}function ps(s,t,e,i,n,r,a,o,h,l,c){if(c>Ol)return;const d=(s+e)/2,u=(t+i)/2,f=(e+n)/2,m=(i+r)/2,y=(n+a)/2,x=(r+o)/2,_=(d+f)/2,w=(u+m)/2,b=(f+y)/2,S=(m+x)/2,T=(_+b)/2,E=(w+S)/2;if(c>0){let M=a-s,k=o-t;const v=Math.abs((e-a)*k-(i-o)*M),C=Math.abs((n-a)*k-(r-o)*M);if(v>ni&&C>ni){if((v+C)*(v+C)<=l*(M*M+k*k)){h.push(T,E);return}}else if(v>ni){if(v*v<=l*(M*M+k*k)){h.push(T,E);return}}else if(C>ni){if(C*C<=l*(M*M+k*k)){h.push(T,E);return}}else if(M=T-(s+a)/2,k=E-(t+o)/2,M*M+k*k<=l){h.push(T,E);return}}ps(s,t,d,u,_,w,T,E,h,l,c+1),ps(T,E,b,S,y,x,a,o,h,l,c+1)}const $l=8,Vl=11920929e-14,Xl=1;function Yl(s,t,e,i,n,r,a,o){const l=Math.min(.99,Math.max(0,o??oa.defaultOptions.bezierSmoothness));let c=(Xl-l)/1;return c*=c,jl(t,e,i,n,r,a,s,c),s}function jl(s,t,e,i,n,r,a,o){gs(a,s,t,e,i,n,r,o,0),a.push(n,r)}function gs(s,t,e,i,n,r,a,o,h){if(h>$l)return;const l=(t+i)/2,c=(e+n)/2,d=(i+r)/2,u=(n+a)/2,f=(l+d)/2,m=(c+u)/2;let y=r-t,x=a-e;const _=Math.abs((i-r)*x-(n-a)*y);if(_>Vl){if(_*_<=o*(y*y+x*x)){s.push(f,m);return}}else if(y=f-(t+r)/2,x=m-(e+a)/2,y*y+x*x<=o){s.push(f,m);return}gs(s,t,e,l,c,f,m,o,h+1),gs(s,f,m,d,u,r,a,o,h+1)}function la(s,t,e,i,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(i,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 Ee=Math.PI*2,Xi={centerX:0,centerY:0,ang1:0,ang2:0},Yi=({x:s,y:t},e,i,n,r,a,o,h)=>{s*=e,t*=i;const l=n*s-r*t,c=r*s+n*t;return h.x=l+a,h.y=c+o,h};function Kl(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,n=Math.cos(s),r=Math.sin(s),a=Math.cos(s+t),o=Math.sin(s+t);return[{x:n-r*i,y:r+n*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const Rn=(s,t,e,i)=>{const n=s*i-t*e<0?-1:1;let r=s*e+t*i;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},Zl=(s,t,e,i,n,r,a,o,h,l,c,d,u)=>{const f=Math.pow(n,2),m=Math.pow(r,2),y=Math.pow(c,2),x=Math.pow(d,2);let _=f*m-f*x-m*y;_<0&&(_=0),_/=f*x+m*y,_=Math.sqrt(_)*(a===o?-1:1);const w=_*n/r*d,b=_*-r/n*c,S=l*w-h*b+(s+e)/2,T=h*w+l*b+(t+i)/2,E=(c-w)/n,M=(d-b)/r,k=(-c-w)/n,v=(-d-b)/r,C=Rn(1,0,E,M);let K=Rn(E,M,k,v);o===0&&K>0&&(K-=Ee),o===1&&K<0&&(K+=Ee),u.centerX=S,u.centerY=T,u.ang1=C,u.ang2=K};function Ql(s,t,e,i,n,r,a,o=0,h=0,l=0){if(r===0||a===0)return;const c=Math.sin(o*Ee/360),d=Math.cos(o*Ee/360),u=d*(t-i)/2+c*(e-n)/2,f=-c*(t-i)/2+d*(e-n)/2;if(u===0&&f===0)return;r=Math.abs(r),a=Math.abs(a);const m=Math.pow(u,2)/Math.pow(r,2)+Math.pow(f,2)/Math.pow(a,2);m>1&&(r*=Math.sqrt(m),a*=Math.sqrt(m)),Zl(t,e,i,n,r,a,h,l,c,d,u,f,Xi);let{ang1:y,ang2:x}=Xi;const{centerX:_,centerY:w}=Xi;let b=Math.abs(x)/(Ee/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);x/=S;let T=s[s.length-2],E=s[s.length-1];const M={x:0,y:0};for(let k=0;k{const h=o.x-a.x,l=o.y-a.y,c=Math.sqrt(h*h+l*l),d=h/c,u=l/c;return{len:c,nx:d,ny:u}},n=(a,o)=>{a===0?s.moveTo(o.x,o.y):s.lineTo(o.x,o.y)};let r=t[t.length-1];for(let a=0;a0&&(f=-1,m=!0);const y=u/2;let x,_=Math.abs(Math.cos(y)*h/Math.sin(y));_>Math.min(c.len/2,d.len/2)?(_=Math.min(c.len/2,d.len/2),x=Math.abs(_*Math.sin(y)/Math.cos(y))):x=h;const w=o.x+d.nx*_+-d.ny*x*f,b=o.y+d.ny*_+d.nx*x*f,S=Math.atan2(c.ny,c.nx)+Math.PI/2*f,T=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&s.moveTo(w+Math.cos(S)*x,b+Math.sin(S)*x),s.arc(w,b,x,S,T,m),r=o}}function tc(s,t,e,i){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,i,n,r){return this.drawShape(new Ps(t,e,i,n),r),this}roundRect(t,e,i,n,r,a){return this.drawShape(new ks(t,e,i,n,r),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new Be,i.points.push(t,e),this._currentPoly=i,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 Be,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,a=i;i=r.a*i+r.c*n+r.tx,n=r.b*a+r.d*n+r.ty}this._currentPoly.points.push(i,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(k,10)),t.context.poly(w,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":b=s.getAttribute("points"),w=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(w,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let k=0;k{this._fill=te({...this._originalFill},pt.defaultFillStyle)})),this._fill=te(t===0?"black":t,pt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...pt.defaultStrokeStyle,...t},()=>{this._stroke=pi({...this._originalStroke},pt.defaultStrokeStyle)})),this._stroke=pi(t,pt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=lc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=oe.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new oe({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 i,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;(i=this._fill)!=null&&i.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:(i,n,r)=>(i[n]=r,e==null||e(n,r),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Z.isColorLike(t)||t instanceof De||t instanceof bi)}};Bs.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Bs.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=Bs;function uc(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=N.defaultDropShadow;s.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){W(O,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Z.isColorLike(e))i.color=e;else if(e instanceof De||e instanceof bi)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){W(O,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;s.fontSize==null?s.fontSize=N.defaultTextStyle.fontSize:typeof s.fontSize=="string"?e=parseInt(s.fontSize,10):e=s.fontSize;const i=new De(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);i.addColorStop(o,r)}),s.fill={fill:i}}}class fc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=Q.get().createCanvas();i.width=t,i.height=e;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=qs(t),e=qs(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:i,height:n}=e,r=(i<<17)+(n<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const On=new fc,pc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ms(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!pc.includes(n)&&(n=`"${n}"`),e[i]=n}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const ji={willReadFrequently:!0},bt=class A{static get experimentalLetterSpacingSupported(){let t=A._experimentalLetterSpacingSupported;if(t!==void 0){const e=Q.get().getCanvasRenderingContext2D().prototype;t=A._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,n,r,a,o,h,l){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=r,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,i=A._canvas,n=e.wordWrap){var w;const r=`${t}:${e.styleKey}`;if(A._measurementCache[r])return A._measurementCache[r];const a=ms(e),o=A.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=A.__context;h.font=a;const c=(n?A._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),d=new Array(c.length);let u=0;for(let b=0;b0&&(n?r-=e:r+=(A.graphemeSegmenter(t).length-1)*e),r}static _wordWrap(t,e,i=A._canvas){const n=i.getContext("2d",ji);let r=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,d=A._collapseSpaces(c),u=A._collapseNewlines(c);let f=!d;const m=e.wordWrapWidth+l,y=A._tokenize(t);for(let x=0;xm)if(a!==""&&(o+=A._addLine(a),a="",r=0),A.canBreakWords(_,e.breakWords)){const b=A.wordWrapSplit(_);for(let S=0;Sm&&(o+=A._addLine(a),f=!1,a="",r=0),a+=T,r+=k}}else{a.length>0&&(o+=A._addLine(a),a="",r=0);const b=x===y.length-1;o+=A._addLine(_,!b),f=!1,a="",r=0}else w+r>m&&(f=!1,o+=A._addLine(a),a="",r=0),(a.length>0||!A.isBreakingSpace(_)||f)&&(a+=_,r+=w)}return o+=A._addLine(a,!1),o}static _addLine(t,e=!0){return t=A._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,i,n){let r=i[t];return typeof r!="number"&&(r=A._measureText(t,e,n)+e,i[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 i=t[e];if(!A.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:A._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:A._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let n=0;n{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})();bt.experimentalLetterSpacing=!1;bt._fonts={};bt._newlines=[10,13];bt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];bt._measurementCache={};let xs=bt;function Nn(s,t){if(s.texture===D.WHITE&&!s.fill)return Z.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof bi){const e=s.fill,i=t.createPattern(e.texture.source.resource,"repeat"),n=e.transform.copyTo(H.shared);return n.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(n),i}else if(s.fill instanceof De){const e=s.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(n=>{i.addColorStop(n.offset,Z.shared.setValue(n.color).toHex())}),i}}}else{const e=t.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(H.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),e.setTransform(i),e}return it("FillStyle not recognised",s),"red"}function ua(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e!this._currentChars.includes(_)).filter((_,w,b)=>b.indexOf(_)===w);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:n,context:r}=i.canvasAndContext,a=i.texture.source;const o=this._style;let h=this._currentX,l=this._currentY;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c,u=o.fontStyle==="italic"?2:1;let f=0,m=!1;for(let _=0;_this._textureSize&&(l+=f,f=M,h=0,l+f>this._textureSize)){a.update();const v=this._nextPage();n=v.canvasAndContext.canvas,r=v.canvasAndContext.context,a=v.texture.source,l=0}const k=S/c-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((x=o._stroke)==null?void 0:x.width)??0);if(this.chars[w]={id:w.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},m){this._drawGlyph(r,b,h+d,l+d,c,o);const v=a.width*c,C=a.height*c,K=new z(h/v*a.width,l/C*a.height,E/v*a.width,M/C*a.height);this.chars[w].texture=new D({source:a,frame:K}),h+=Math.ceil(E)}}a.update(),this._currentX=h,this._currentY=l,this._skipKerning&&this._applyKerning(e,r)}get pageTextures(){return W(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let n=0;n{const y=r.width;for(let x=0;x{let m=r.chars.length-1;if(i){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,u=t.letterSpacing*d,f=t.wordWrapWidth*d;for(let m=0;mf?(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 T=_.xAdvance+(_.kerning[a]||0)+u;r.width+=T,r.spaceWidth=T,r.spacesIndex.push(r.charPositions.length),r.chars.push(y)}}else{const S=_.kerning[a]||0,T=_.xAdvance+S+u;h.positions[h.index++]=h.width+S,h.chars.push(y),h.width+=T}a=y}return c(),t.align==="center"?mc(n):t.align==="right"?xc(n):t.align==="justify"&&yc(n),n}function mc(s){for(let t=0;t50&&it("BitmapText",`You have dynamically created ${ri} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{ri--,j.remove(i)}),j.set(i,o)}const r=j.get(i);return(a=r.ensureCharacters)==null||a.call(r,t),r}getLayout(t,e,i=!0){const n=this.getFont(t,e);return gc([...t],e,n,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var l,c,d,u;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:(u=t[2])==null?void 0:u.skipKerning},W(O,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e==null?void 0:e.name;if(!i)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 Hn({style:r,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=ua(e.chars);return o.ensureCharacters(h.join("")),j.set(`${i}-bitmap`,o),o.once("destroy",()=>j.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=j.get(e);i&&(j.remove(e),i.destroy())}}const $n=new _c;class ga extends Xr{constructor(t,e){super();const{textures:i,data:n}=t;Object.keys(n.pages).forEach(r=>{const a=n.pages[parseInt(r,10)],o=i[a.id];this.pages.push({texture:o})}),Object.keys(n.chars).forEach(r=>{const a=n.chars[r],{frame:o,source:h}=i[a.page],l=new z(a.x+o.x,a.y+o.y,a.width,a.height),c=new D({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")?Vn.test(Q.get().parseXML(s)):!1},parse(s){return Vn.parse(Q.get().parseXML(s))}},wc=[".xml",".fnt"],bc={extension:{type:P.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof ga,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Sc={extension:{type:P.LoadParser,priority:Nt.Normal},name:"loadBitmapFont",test(s){return wc.includes(ft.extname(s).toLowerCase())},async testParse(s){return qi.test(s)||Xn.test(s)},async parse(s,t,e){const i=qi.test(s)?qi.parse(s):Xn.parse(s),{src:n}=t,{pages:r}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;dh[d.src]);return new ga({data:i,textures:l},n)},async load(s,t){return await(await Q.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}};class vc{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 i=0;iArray.isArray(s)&&s.every(t=>t instanceof D),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((n,r)=>{e[i+(r===0?"":r+1)]=n})}),e}};async function ma(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Tc={extension:{type:P.DetectionParser,priority:1},test:async()=>ma("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},Yn=["png","jpg","jpeg"],Ac={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Yn],remove:async s=>s.filter(t=>!Yn.includes(t))},Mc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Es(s){return Mc?!1:document.createElement("video").canPlayType(s)!==""}const Pc={extension:{type:P.DetectionParser,priority:0},test:async()=>Es("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},kc={extension:{type:P.DetectionParser,priority:0},test:async()=>Es("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},Gc={extension:{type:P.DetectionParser,priority:0},test:async()=>Es("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},Ic={extension:{type:P.DetectionParser,priority:0},test:async()=>ma("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};class Bc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let n=null,r=null;if(e.loadParser&&(r=this._parserHash[e.loadParser],r||it(`[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=ft.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(++i/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 i=_t(t,n=>({alias:[n],src:n})).map(async n=>{var o,h;const r=ft.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(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&it(`[Assets] loadParser name conflict "${e.name}"`):it("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function me(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function xe(s,t){const e=s.split("?")[0],i=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Ec=".json",Rc="application/json",Fc={extension:{type:P.LoadParser,priority:Nt.Low},name:"loadJson",test(s){return me(s,Rc)||xe(s,Ec)},async load(s){return await(await Q.get().fetch(s)).json()}},Lc=".txt",Dc="text/plain",zc={name:"loadTxt",extension:{type:P.LoadParser,priority:Nt.Low,name:"loadTxt"},test(s){return me(s,Dc)||xe(s,Lc)},async load(s){return await(await Q.get().fetch(s)).text()}},Uc=["normal","bold","100","200","300","400","500","600","700","800","900"],Wc=[".ttf",".otf",".woff",".woff2"],Oc=["font/ttf","font/otf","font/woff","font/woff2"],Nc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Hc(s){const t=ft.extname(s),n=ft.basename(s,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(Nc)){r=!1;break}let a=n.join(" ");return r||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const $c=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Vc(s){return $c.test(s)?s:encodeURI(s)}const Xc={extension:{type:P.LoadParser,priority:Nt.Low},name:"loadWebFont",test(s){return me(s,Oc)||xe(s,Wc)},async load(s,t){var i,n,r;const e=Q.get().getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??Hc(s),h=((r=(n=t.data)==null?void 0:n.weights)==null?void 0:r.filter(c=>Uc.includes(c)))??["normal"],l=t.data??{};for(let c=0;c{j.remove(t.family),Q.get().getFontFaceSet().delete(t)})}};function Rs(s,t=1){var i;const e=(i=ge.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}function Fs(s,t,e){s.label=e,s._sourceOrigin=e;const i=new D({source:s,label:e}),n=()=>{delete t.promiseCache[e],j.has(e)&&j.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(it("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),n())}),i.once("destroy",()=>{s.destroyed||(it("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),i}const Yc=".svg",jc="image/svg+xml",qc={extension:{type:P.LoadParser,priority:Nt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return me(s,jc)||xe(s,Yc)},async load(s,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Zc(s):Kc(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Kc(s,t,e,i){var x,_,w;const r=await(await Q.get().fetch(s)).blob(),a=URL.createObjectURL(r),o=new Image;o.src=a,o.crossOrigin=i,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),l=h.getContext("2d"),c=((x=t.data)==null?void 0:x.resolution)||Rs(s),d=((_=t.data)==null?void 0:_.width)??o.width,u=((w=t.data)==null?void 0:w.height)??o.height;h.width=d*c,h.height=u*c,l.drawImage(o,0,0,d*c,u*c);const{parseAsGraphicsContext:f,...m}=t.data,y=new pe({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:c,...m});return Fs(y,e,s)}async function Zc(s){const e=await(await Q.get().fetch(s)).text(),i=new pt;return i.svg(e),i}const Qc=`(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 le=null,ys=class{constructor(){le||(le=URL.createObjectURL(new Blob([Qc],{type:"application/javascript"}))),this.worker=new Worker(le)}};ys.revokeObjectURL=function(){le&&(URL.revokeObjectURL(le),le=null)};const Jc=`(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 ce=null;class xa{constructor(){ce||(ce=URL.createObjectURL(new Blob([Jc],{type:"application/javascript"}))),this.worker=new Worker(ce)}}xa.revokeObjectURL=function(){ce&&(URL.revokeObjectURL(ce),ce=null)};let jn=0,Ki;class td{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 ys;e.addEventListener("message",i=>{e.terminate(),ys.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Ki===void 0&&(Ki=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 i=new Promise((n,r)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:r})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[jn]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:jn++,id:i})}}const qn=new td,ed=[".jpeg",".jpg",".png",".webp",".avif"],id=["image/jpeg","image/png","image/webp","image/avif"];async function sd(s,t){var n;const e=await Q.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);const i=await e.blob();return((n=t==null?void 0:t.data)==null?void 0:n.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const ya={name:"loadTextures",extension:{type:P.LoadParser,priority:Nt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return me(s,id)||xe(s,ed)},async load(s,t,e){var r;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await qn.isImageBitmapSupported()?i=await qn.loadImageBitmap(s,t):i=await sd(s,t):i=await new Promise(a=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?a(i):i.onload=()=>{a(i)}});const n=new pe({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((r=t.data)==null?void 0:r.resolution)||Rs(s),...t.data});return Fs(n,e,s)},unload(s){s.destroy(!0)}},_a=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],nd=_a.map(s=>`video/${s.substring(1)}`);function rd(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=od(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function ad(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",n),s.load();function i(){r(),t()}function n(a){r(),e(a)}function r(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",n)}})}function od(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const hd={name:"loadVideo",extension:{type:P.LoadParser,name:"loadVideo"},test(s){const t=me(s,nd),e=xe(s,_a);return t||e},async load(s,t,e){var h,l;const i={...ai.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Rs(s),alphaMode:((l=t.data)==null?void 0:l.alphaMode)||await Sr(),...t.data},n=document.createElement("video"),r={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(r).forEach(c=>{const d=r[c];d!==void 0&&n.setAttribute(c,d)}),i.muted===!0&&(n.muted=!0),rd(n,s,i.crossorigin);const a=document.createElement("source");let o;if(s.startsWith("data:"))o=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const c=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();o=ai.MIME_TYPES[c]||`video/${c}`}return a.src=s,o&&(a.type=o),new Promise(c=>{const d=async()=>{const u=new ai({...i,resource:n});n.removeEventListener("canplay",d),t.data.preload&&await ad(n),c(Fs(u,e,s))};n.addEventListener("canplay",d),n.appendChild(a)})},unload(s){s.destroy(!0)}},wa={extension:{type:P.ResolveParser,name:"resolveTexture"},test:ya.test,parse:s=>{var t;return{resolution:parseFloat(((t=ge.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},ld={extension:{type:P.ResolveParser,priority:-2,name:"resolveJson"},test:s=>ge.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:wa.parse};class cd{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ge,this.loader=new Bc,this.cache=j,this._backgroundLoader=new vc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var r,a;if(this._initialized){it("[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,i=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:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=fi(t),n=_t(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 i?a[n[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!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 u=n[d];return h+=Object.keys(u).length,this._mapLoadToResolve(u,l).then(f=>{r[d]=f})});return await Promise.all(c),i?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(i=>{this._backgroundLoader.add(Object.values(i))})}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 i=0;i{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=_t(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=_t(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{j.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,n)=>e.indexOf(i)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Ge=new cd;ht.handleByList(P.LoadParser,Ge.loader.parsers).handleByList(P.ResolveParser,Ge.resolver.parsers).handleByList(P.CacheParser,Ge.cache.parsers).handleByList(P.DetectionParser,Ge.detections);ht.add(Cc,Ac,Tc,Ic,Pc,kc,Gc,Fc,zc,Xc,qc,ya,hd,Sc,bc,wa,ld);const Kn={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};ht.handle(P.Asset,s=>{const t=s.ref;Object.entries(Kn).filter(([e])=>!!t[e]).forEach(([e,i])=>ht.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(Kn).filter(e=>!!t[e]).forEach(e=>ht.remove(t[e]))});class wt extends mi{constructor(t){t instanceof pt&&(t={context:t});const{context:e,roundPixels:i,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new pt,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!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 wt(this._context.clone()):(this._ownedContext=null,new wt(this._context))}lineStyle(t,e,i){W(O,"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),i&&(n.alpha=i),this.context.strokeStyle=n,this}beginFill(t,e){W(O,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){W(O,"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!==pt.defaultStrokeStyle.width||t.color!==pt.defaultStrokeStyle.color||t.alpha!==pt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return W(O,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return W(O,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return W(O,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return W(O,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return W(O,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return W(O,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const ba=class Sa extends Jr{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(W(O,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...Sa.defaultOptions,...e};const i=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 Ut({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:et.VERTEX|et.COPY_DST}),h=new Ut({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:et.VERTEX|et.COPY_DST}),l=new Ut({data:r,label:"index-mesh-buffer",shrinkToFit:a,usage:et.INDEX|et.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}};ba.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let dd=ba;class Ue extends V{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:i,autoUpdate:n,...r}=e,[a]=i;super({...r,texture:a instanceof D?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=i}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(At.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(At.shared.add(this.update,this,ui.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,i=this.animationSpeed*e,n=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=i/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+=i;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 i=0;ithis.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?(At.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(At.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class ud extends mi{constructor(t,e){const{text:i,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=i??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new ct({_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,i=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-i*this.anchor.y,t.y>=r&&t.y<=r+i)}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 fd(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(W(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}class U extends ud{constructor(...t){const e=fd(t,"Text");super(e,N),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,i=xs.measureText(this._text,this._style),{width:n,height:r}=i;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}}const va=class Ca extends dd{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(W(O,"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={...Ca.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,i=[],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(i,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,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};Ta.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ae=Ta;const Ma=class Pa extends mi{constructor(t){var d,u,f,m;t instanceof D&&(t={texture:t});const{width:e,height:i,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)??ae.defaultOptions.leftWidth,this._topHeight=a??((u=h==null?void 0:h.defaultBorders)==null?void 0:u.top)??ae.defaultOptions.topHeight,this._rightWidth=r??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.right)??ae.defaultOptions.rightWidth,this._bottomHeight=o??((m=h==null?void 0:h.defaultBorders)==null?void 0:m.bottom)??ae.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??ae.defaultOptions.width,this.bounds.maxY=this._height=i??h.height??ae.defaultOptions.height,this.allowChildren=!1,this.texture=h??Pa.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=D.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 i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null}};Ma.defaultOptions={texture:D.EMPTY};let mt=Ma;ht.add(za,Ua);const L=class L{static async Load(t){return this.text.text="Loading asset: "+t,await Ge.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 U({text:"Loading textures. This might take a while.",style:new N({fill:3355443,fontSize:50})});t.x=p.app.canvas.width/2,t.y=p.app.canvas.height/2,t.anchor.set(.5,.5),p.app.stage.addChild(t),this.text=new U({text:"",style:new N({fill:3355443,fontSize:50})}),this.text.x=p.app.canvas.width/2,this.text.y=p.app.canvas.height/2+50,this.text.anchor.set(.5,.5),p.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/banner_01.png").then(e=>this.BannerGemsmith=e),this.Load("./assets/gui/note.png").then(e=>this.EndScreenDialog=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/exclamation.png").then(e=>this.ExclamationIconTexture=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 i=0;i{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=(s=>(s[s.Button01=0]="Button01",s[s.Button02=1]="Button02",s))(Ot||{});class se extends St{constructor(e,i,n,r=!0){super(!0);g(this,"caption");g(this,"bounds");g(this,"buttonTexture");g(this,"buttonSprite");g(this,"buttonText");g(this,"buttonIcon");n==0&&(this.buttonTexture=G.Button01Texture),n==1&&(this.buttonTexture=G.Button02Texture),this.caption=i,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 mt({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 U({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 Ht{constructor(){g(this,"name",this.constructor.name);g(this,"_container",new st);g(this,"bb",new z);g(this,"_events",new dt)}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 Et=(s=>(s[s.Restricted=0]="Restricted",s[s.Buildable=1]="Buildable",s[s.Path=9]="Path",s))(Et||{}),ee=(s=>(s.CreepSpawned="creepSpawned",s.Finished="finished",s.NewWave="newwave",s))(ee||{}),Mt=(s=>(s.Died="died",s.TakenDamage="takenDamage",s.Escaped="escaped",s.Moved="moved",s))(Mt||{}),We=(s=>(s.CellMouseOver="cellmouseover",s.CellMouseLeave="cellmouseleave",s))(We||{}),Oe=(s=>(s.TowerPlacedEvent="towerPlacedEvent",s.TowerSoldEvent="towerSoldEvent",s))(Oe||{}),Ls=(s=>(s.GemGivenEvent="gemGivenEvent",s))(Ls||{}),Ds=(s=>(s.TowerPanelSelectGem="towerTabSelectGem",s))(Ds||{});class md extends Ht{constructor(e,i,n,r){super();g(this,"type");g(this,"row");g(this,"column");g(this,"isPath",!1);g(this,"g");g(this,"hasTowerPlaced",!1);g(this,"clickDetector");this.type=e,this.row=i,this.column=n,this.isPath=r,this.bb.x=this.column*p.GridCellSize,this.bb.y=this.row*p.GridCellSize,this.bb.width=p.GridCellSize,this.bb.height=p.GridCellSize,p.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new wt({zIndex:99,interactive:!0}),this.g=new wt({zIndex:5}),this.clickDetector.rect(0,0,this.bb.width,this.bb.height),this.clickDetector.fill({color:16711680,alpha:0}),this.container.addChild(this.clickDetector),this.container.addChild(this.g),this.clickDetector.on("pointerup",a=>{p.Grid.gridInteractionEnabled&&(p.TowerManager.isPlacingTower?p.Grid.onGridCellClicked(i,n):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!p.Grid.gridInteractionEnabled||p.GameScene.towerPanel.isShown||p.GameScene.events.emit(We.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!p.Grid.gridInteractionEnabled||p.GameScene.towerPanel.isShown||(p.GameScene.events.emit(We.CellMouseLeave,this),p.Grid.rangePreview.clear())}),p.GameScene.events.on(Oe.TowerPlacedEvent,(a,o,h)=>{o==this.row&&h==this.column&&(this.hasTowerPlaced=!0,p.Grid.rangePreview.clear())}),p.GameScene.events.on(Oe.TowerSoldEvent,(a,o,h)=>{o==this.row&&h==this.column&&(this.hasTowerPlaced=!1)})}showRangePreview(e,i){let n=16777215;e&&(n=16711680),p.Grid.rangePreview.clear(),p.Grid.rangePreview.circle(this.column*p.GridCellSize+p.GridCellSize/2,this.row*p.GridCellSize+p.GridCellSize/2,i*p.GridCellSize),p.Grid.rangePreview.fill({color:n,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=p.TowerManager.GetTowerByRowAndCol(this.row,this.column);p.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Et.Path||this.type==Et.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Et.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Et.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Et.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class xd extends Ht{constructor(e,i){super();g(this,"gameMap");g(this,"cells",[]);g(this,"rangePreview");g(this,"creeps",[]);g(this,"gridShown",!1);g(this,"gridInteractionEnabled",!0);this.gameMap=e,p.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=p.GridCellSize*p.GridColumns,this.bb.height=p.GridCellSize*p.GridRows,p.GameMaster.currentScene.stage.addChild(this.container);let n=new V(G.MissionBackgrounds[i]);this.container.addChild(n);for(let r=0;rc.some(d=>d[1]===a&&d[0]===r));h&&(o=Et.Path);let l=new md(o,a,r,h);this.cells.push(l)}this.rangePreview=new wt({zIndex:10}),this.container.addChild(this.rangePreview)}generateCells(){const e=Array.from({length:this.gameMap.rows},()=>Array(this.gameMap.columns).fill(1));this.cells.forEach(i=>{if(i.isPath){e[i.row][i.column]=9;for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++){const a=i.row+n,o=i.column+r;a>=0&&a=0&&o{if(e){e=="hide"?i.gClear():i.gDraw();return}this.gridShown?i.gClear():i.gDraw()}),e=="hide"?this.gridShown=!1:e=="show"?this.gridShown=!0:this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(Mt.Died,i=>{this.onCreepDiedOrEscaped(i)}),e.events.on(Mt.Escaped,i=>{this.onCreepDiedOrEscaped(i)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(i=>{i.dead?(this.creeps.splice(this.creeps.indexOf(i),1),i=null):i.update(e)})}getCellByRowAndCol(e,i){return this.cells.filter(n=>n.row==e&&n.column==i)[0]}onGridCellClicked(e,i){}}class yd extends Ht{constructor(e,i,n){super();g(this,"id");g(this,"creepType");g(this,"sprite");g(this,"path");g(this,"stats");g(this,"pathIndex",0);g(this,"speed");g(this,"direction",1);g(this,"healthBarGraphics",new wt);g(this,"healthBarWidth",50);g(this,"health");g(this,"maxHealth");g(this,"escaped",!1);g(this,"died",!1);g(this,"x");g(this,"y");g(this,"dead",!1);this.creepType=e,this.stats=structuredClone(G.Creeps[this.creepType].stats),this.sprite=new Ue(G.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=p.GridCellSize,this.sprite.height=p.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=i,this.x=i[0][0]*p.GridCellSize+p.GridCellSize/2,this.y=i[0][1]*p.GridCellSize+p.GridCellSize/2,p.GameScene.events.on(Mt.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())}),p.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,i=this.maxHealth,n=e/i,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){p.GameScene.events.emit(Mt.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(Mt.Escaped,this),this.escaped=!0;return}const i=this.path[this.pathIndex],n=this.path[this.pathIndex+1],r=n[0]*p.GridCellSize+p.GridCellSize/2,a=n[1]*p.GridCellSize+p.GridCellSize/2,o=n[0]-i[0],h=n[1]-i[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,c=this.speed*e*h,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{i+=n.firstCreepSpawnTick,n.creeps.forEach(r=>{const a=new yd(r,this.paths[this.pathsIndex],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:i,spawned:!1};i+=n.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e,this.creeps.forEach(i=>{!i.spawned&&i.tickToSpawnAt<=this.ticks?(i.spawned=!0,this.events.emit(ee.CreepSpawned,i.creep),!this.finished&&this.creeps.every(n=>n.spawned)&&(this.finished=!0,this.events.emit(ee.Finished))):i.spawned&&i.creep.update(e)}))}}class Zn extends St{constructor(e,i,n,r,a,o,h,l){if(e>3||i>2||e<0||i<0)throw"Index/row out of bounds for TowerButton.";super(!0);g(this,"frameSprite");g(this,"background");g(this,"towerName");g(this,"iconSprite");g(this,"i",0);this.towerName=h,this.container.x=e*n+5,this.container.y=i*r+5,this.background=new V({texture:o}),this.iconSprite=new V({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 mt({texture:G.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:r,width:n}),this.container.addChild(this.frameSprite),a.addChild(this.container),p.GameScene.events.on(Oe.TowerPlacedEvent,c=>{this.resetTint()}),this.container.onpointermove=c=>{p.Grid.gridInteractionEnabled!=!1&&(p.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=c=>{p.GameScene.tooltip.Hide()}}ShowTooltip(){let e;G.Towers.forEach(i=>{i.name==this.towerName&&(e=i)}),p.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),p.GameScene.tooltip.Show(p.MouseX,p.MouseY)}onClick(e){p.Grid.gridInteractionEnabled!=!1&&(p.TowerManager.isPlacingTower&&p.TowerManager.selectedTower.name!=this.towerName&&(p.GameScene.sidebar.towerTab.resetTint(),p.TowerManager.ResetChooseTower()),p.GameScene.towerPanel.Hide(),p.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,p.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class wd extends St{constructor(e){super(!1);g(this,"bounds");g(this,"towerTabSprite");g(this,"towerButtons",[]);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new mt({texture:G.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 Zn(0,0,70,70,this.container,G.RedBackground,"Basic Tower",G.Towers[0].texture)),this.towerButtons.push(new Zn(3,1,70,70,this.container,G.GreenBackground,"Circle Tower",G.Towers[1].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const Jt=class Jt{static init(){Jt.SidebarRect=new z(p.app.canvas.width-360,0,360,p.app.canvas.height),Jt.ChangeRoundButtonRect=new z(50,p.app.canvas.height-100,310,100)}};g(Jt,"SidebarRect"),g(Jt,"ChangeRoundButtonRect"),g(Jt,"MaximumPlayerNameLength",20);let Wt=Jt;function It(s,t,e,i){const n=e-s,r=i-t;return Math.atan2(r,n)}class bd extends Ht{constructor(e,i,n,r,a,o,h,l,c){super();g(this,"deleteMe",!1);g(this,"sprite");g(this,"x");g(this,"y");g(this,"angle");g(this,"speed");g(this,"damage");g(this,"pierce",1);g(this,"timeToLive");g(this,"parent");g(this,"gemResistanceModifications");g(this,"collidedCreepIDs",[]);this.x=e,this.y=i,this.timeToLive=h,this.pierce=l,this.damage=a,this.gemResistanceModifications=c,this.sprite=new Ue({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.sprite.tint=o,this.container.addChild(this.sprite),p.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--,p.Grid.creeps.forEach(i=>{if(!(this.pierce<=0)&&i&&i.container&&this.checkCollision(i)&&!this.collidedCreepIDs.find(r=>i.id==r.id)){this.collidedCreepIDs.push(i),this.pierce--,this.onCollide(i);return}}),this.x+=Math.cos(this.angle)*this.speed*e,this.y+=Math.sin(this.angle)*this.speed*e,this.container.x=this.x,this.container.y=this.y}}onCollide(e){p.GameScene.events.emit(Mt.TakenDamage,e.id,this.damage,this.gemResistanceModifications)}checkCollision(e){if(console.debug(e),e==null||e.container==null||e.container._position==null)return;let i=this.copyContainerToBB(),n=e.copyContainerToBB();return i.getBounds().intersects(n.getBounds())}}function ka(s,t){s.projectiles.forEach(e=>{e.deleteMe?(e.collidedCreepIDs.forEach(()=>{s.damageDealt+=s.computedDamageToDeal}),s.projectiles.splice(s.projectiles.indexOf(e),1),e=null):e.update(t)})}function zs(s){let t=0,e=0,i=0,n=0,r=0;s.totalGemResistanceModifications={fire:0,frostfire:0,divine:0,ice:0,physical:0},s.slottedGems.forEach(a=>{let o=a.currentGemImprovement();t+=o.damageUp,e+=o.attackSpeedUp,i+=o.rangeUp,n+=o.timeToLiveUp,r+=o.pierceUp;let h=a.currentGemResistanceModifications();s.totalGemResistanceModifications.physical+=h.physical,s.totalGemResistanceModifications.ice+=h.ice,s.totalGemResistanceModifications.fire+=h.fire,s.totalGemResistanceModifications.divine+=h.divine,s.totalGemResistanceModifications.frostfire+=h.frostfire}),s.computedDamageToDeal=s.definition.stats.damage+t,s.computedAttackSpeed=s.definition.stats.cooldown-e,s.computedRange=s.definition.stats.range+i,s.computedTimeToLive=s.definition.stats.timeToLive+n,s.computedPierce=s.definition.stats.pierce+r}function Sd(s,t){s.ticksUntilNextShot%2==0&&zs(s),ka(s,t),s.ticksUntilNextShot>0&&s.ticksUntilNextShot--;let e=s.GetCreepsInRange();if(e.length>0){let i=e[0];if(s.ticksUntilNextShot<=0){let n=s.column*p.GridCellSize+p.GridCellSize/2,r=s.row*p.GridCellSize+p.GridCellSize/2;s.ticksUntilNextShot=s.computedAttackSpeed,s.Shoot(It(n,r,i.x,i.y))}}}function vd(s,t){s.ticksUntilNextShot%2==0&&zs(s),ka(s,t),s.ticksUntilNextShot>0&&s.ticksUntilNextShot--;let e=s.GetCreepsInRange();if(e.length>0&&(e[0],s.ticksUntilNextShot<=0)){s.ticksUntilNextShot=s.computedAttackSpeed;let i=s.column*p.GridCellSize+p.GridCellSize/2,n=s.row*p.GridCellSize+p.GridCellSize/2;s.Shoot(It(i,n,i,n+10)),s.Shoot(It(i,n,i+10,n)),s.Shoot(It(i,n,i-10,n)),s.Shoot(It(i,n,i,n-10)),s.Shoot(It(i,n,i+10,n+10)),s.Shoot(It(i,n,i-10,n+10)),s.Shoot(It(i,n,i-10,n-10)),s.Shoot(It(i,n,i+10,n-10))}}class Ne extends St{constructor(e,i,n,r){super(!0);g(this,"iconSprite");g(this,"background");g(this,"frame");g(this,"i",0);g(this,"gem",null);let a;this.i=e,this.container.x=10,this.container.y=e*(p.GridCellSize+6)+300,this.background=new V({texture:G.Frame01Texture}),n==null&&!r?a=G.PlusIconTexture:r=="SELL"?a=G.GoldTexture:r=="UPGRADE"?a=G.PlusIconTexture:(a=n.texture,this.gem=n),this.iconSprite=new V({texture:a,zIndex:10}),this.background.width=p.GridCellSize,this.background.height=p.GridCellSize,n==null&&!r?(this.iconSprite.x=p.GridCellSize/2,this.iconSprite.y=p.GridCellSize/2,this.iconSprite.width=p.GridCellSize/2,this.iconSprite.height=p.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):r=="SELL"?(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=p.GridCellSize-8,this.iconSprite.height=p.GridCellSize-8):r=="UPGRADE"?(this.iconSprite.x=p.GridCellSize/2,this.iconSprite.y=p.GridCellSize/2,this.iconSprite.width=p.GridCellSize/2,this.iconSprite.height=p.GridCellSize/2,this.iconSprite.tint=3012919,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=p.GridCellSize-8,this.iconSprite.height=p.GridCellSize-8),this.frame=new V({texture:G.Frame05Texture,width:64,height:64}),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.container.addChild(this.frame);let o=n?n.id:"",h=new U({text:o,zIndex:11,style:{fill:"white",stroke:{color:0,width:5}}});this.container.addChild(h),i.addChild(this.container)}setTint(e){this.frame.tint=e}resetTint(){this.frame.tint=16777215}}class Cd extends St{constructor(e){super(!1);g(this,"bounds");g(this,"towerPanel");g(this,"closeBtn");g(this,"vGems",[]);g(this,"showingTower",null);g(this,"isShown",!1);g(this,"titleText");g(this,"damageText");g(this,"totalDamage");g(this,"attackSpeedText");g(this,"fireResDamage");g(this,"iceResDamage");g(this,"frostFireResDamage");g(this,"divineResDamage");g(this,"physicalResDamage");this.bounds=e,this.towerPanel=new mt({texture:G.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 se(new z(-20,-20,60,60),"",Ot.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new V({texture:G.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=p.app.canvas.height/2-p.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),p.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new U({x:this.bounds.width/3,y:50,zIndex:5,style:new N({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new U({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 U({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 U({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 U({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 U({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 U({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 U({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 U({x:10,y:250,zIndex:5,style:new N({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.physicalResDamage)}MakeSlots(e){this.vGems.forEach(n=>{n.destroy()}),this.vGems=[];let i=e.definition.stats.gemSlotsAmount;for(let n=0;n{r&&(p.GameScene.tooltip.SetContentGem(r),p.GameScene.tooltip.Show(p.MouseX,p.MouseY))},a.container.onpointerleave=()=>{p.GameScene.tooltip.Hide()},a.onClick=()=>{p.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",r,a.i,n,e),p.GameScene.events.emit(Ds.TowerPanelSelectGem,r,a.i,e),!r&&p.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,zs(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,p.GameScene.sidebar.gemTab.selectingGemTowerObject=e,e.container.parent.x<900?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.computedAttackSpeed/60*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`}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=Wt.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=-1e3,p.Grid.rangePreview.clear()}}class Td extends St{constructor(e){super(!1);g(this,"bounds");g(this,"gemTabSprite");g(this,"vGems",[]);g(this,"isSelectingGem",!1);g(this,"selectingGemSlotIndex",-1);g(this,"selectingGemTowerObject",null);g(this,"isDragAndDroppingGem",!1);g(this,"dragAndDroppingGem",null);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new mt({texture:G.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),p.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),p.GameScene.events.on(Ls.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,i,n){console.log("TOWER PANEL SELECTING GEM "+i),i<0&&console.error("TOWER PANEL SELECTING GEM INDEX IS LESS THAN 0, ",i),this.isSelectingGem?e==null&&(this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null):(this.isSelectingGem=!0,e==null?(p.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=i,this.selectingGemTowerObject=n):(n.UnslotGem(i),this.RebuildInventoryVisual(),p.GameScene.towerPanel.Hide(),p.GameScene.towerPanel.Show(n),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=p.MouseX-32,this.dragAndDroppingGem.container.y=p.MouseY-32)}isOverlappingGemsmith(e,i,n){let r=e.copyContainerToBB(),a=i.copyContainerToBB(),o=n.x+a.x+p.GameScene.sidebar.container.x,h=n.y+a.y+p.GameScene.sidebar.container.y,l=new z(o,h,a.width,a.height);if(r.getBounds().intersects(l)&&i&&i.gem==null)return!0}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],p.GameScene.MissionStats.getInventory().forEach((e,i)=>{let n=new Ne(0,this.container,e),r=10,a=i%4*70+10,o=i;for(;!(o<=3);)r+=66,o-=4;n.container.x=a,n.container.y=r,n.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(p.GameScene.tooltip.SetContentGem(e),p.GameScene.tooltip.Show(p.MouseX,p.MouseY))},n.container.onpointerleave=()=>{p.GameScene.tooltip.Hide()},n.container.onpointerdown=()=>{if(p.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=p.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=n,n.container.removeFromParent(),p.GameScene.stage.addChild(n.container),this.pointerMoveEvent()},n.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(this.isOverlappingGemsmith(this.dragAndDroppingGem,p.GameScene.sidebar.gemsmith.sellVGem,p.GameScene.sidebar.gemsmith.container)){let d=this.dragAndDroppingGem.gem.definition.initialGemValue+this.dragAndDroppingGem.gem.currentGemImprovement().gemValueUp;p.GameScene.MissionStats.earnGold(Math.ceil(d*.8)),p.NotificationManager.Notify(`Sold Lv. ${this.dragAndDroppingGem.gem.level} ${this.dragAndDroppingGem.gem.definition.name} for ${Math.ceil(d*.8)} gold.`,"info"),p.GameScene.MissionStats.takeGem(this.dragAndDroppingGem.gem),this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(this.isOverlappingGemsmith(this.dragAndDroppingGem,p.GameScene.sidebar.gemsmith.upgradeVGem,p.GameScene.sidebar.gemsmith.container)){if(this.dragAndDroppingGem.gem.isMaxLevel())p.NotificationManager.Notify("Gem is max level.","warn");else{let d=this.dragAndDroppingGem.gem.definition.genericImprovements[this.dragAndDroppingGem.gem.level].gemValueUp;p.GameScene.MissionStats.hasEnoughGold(d)?(p.GameScene.MissionStats.spendGold(d),this.dragAndDroppingGem.gem.levelUp(1),p.NotificationManager.Notify(`Spent ${d} gold to upgrade ${this.dragAndDroppingGem.gem.definition.name} Lv. ${this.dragAndDroppingGem.gem.level-1} -> Lv. ${this.dragAndDroppingGem.gem.level}!`,"warn")):p.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(p.GameScene.towerPanel.vGems.forEach(d=>{if(h||!this.dragAndDroppingGem)return;let u=this.dragAndDroppingGem.copyContainerToBB(),f=d.copyContainerToBB(),m=p.GameScene.towerPanel.container.x+f.x,y=p.GameScene.towerPanel.container.y+f.y,x=new z(m,y,f.width,f.height);u.getBounds().intersects(x)&&d&&d.gem==null&&(h=d)}),h){let d=p.GameScene.MissionStats.takeGem(e);p.GameScene.towerPanel.showingTower.SlotGem(d,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(n)})}}class Ad extends St{constructor(e){super(!1);g(this,"bounds");g(this,"sellVGem");g(this,"upgradeVGem");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y;let i=new V({x:0,y:0,width:this.bounds.width,height:this.bounds.height,texture:G.BannerGemsmith});this.container.addChild(i);let n=new U({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 U({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 Ne(0,this.container,null,"SELL"),this.sellVGem.container.x=45,this.sellVGem.container.y=this.bounds.height/4,this.upgradeVGem=new Ne(0,this.container,null,"UPGRADE"),this.upgradeVGem.container.x=180,this.upgradeVGem.container.y=this.bounds.height/4}}class Md extends St{constructor(e){super(!1);g(this,"towerTab");g(this,"gemTab");g(this,"gemsmith");g(this,"bounds");g(this,"sidebarSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new mt({texture:G.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 i=new z(60,20,this.bounds.width-65,150);this.towerTab=new wd(i),this.container.addChild(this.towerTab.container);const n=new z(60,180,this.bounds.width-65,this.bounds.height-280-255);this.gemTab=new Td(n),this.container.addChild(this.gemTab.container);const r=new z(60,185+n.height,this.bounds.width-65,this.bounds.height-840);this.gemsmith=new Ad(r),this.container.addChild(this.gemsmith.container)}}class Us{constructor(){g(this,"stage",new st);g(this,"gui",[]);g(this,"_events",new dt);p.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this._events.removeAllListeners(),this.gui.forEach(t=>{t.destroy()})}get events(){return this._events}init(){}}class Pd extends Ht{constructor(e,i){super();g(this,"hp",100);g(this,"gold",0);g(this,"goldEarned",0);g(this,"goldSpent",0);g(this,"wavesSurvived",0);g(this,"damageDealt",0);g(this,"creepsKilled",0);g(this,"goldText");g(this,"healthText");g(this,"waveText");g(this,"inventory",[]);this.hp=e,this.gold=i,this.container.x=0,this.container.y=20,p.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new U({text:`${this.hp}`,style:new N({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new U({text:`${this.gold}`,style:new N({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new U({text:`0/${p.GameScene.mission.rounds.length}`,style:new N({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const n=new V(G.HealthTexture),r=new V(G.GoldTexture),a=new V(G.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),p.GameScene.events.on(ee.NewWave,o=>{this.waveText.text=`${o}/${p.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,i){if(this.inventory.length>=32)return p.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),i||p.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),p.GameScene.events.emit(Ls.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 i of this.inventory)e.includes(i.definition.name)||e.push(i.definition.name);return this.damageDealt*2+this.hp*10+(this.goldEarned-this.goldSpent)*3+this.wavesSurvived*100+e.length*100}update(){}}function kd(s,t,e,i){return Math.sqrt((e-s)*(e-s)+(i-t)*(i-t))}class Gd extends Ht{constructor(e,i,n,r,a){super();g(this,"row");g(this,"column");g(this,"definition");g(this,"slottedGems",[]);g(this,"damageDealt",0);g(this,"projectiles",[]);g(this,"behaviour");g(this,"sprite");g(this,"ticksUntilNextShot");g(this,"graphics",new wt);g(this,"computedDamageToDeal");g(this,"computedAttackSpeed");g(this,"computedRange");g(this,"computedTimeToLive");g(this,"computedPierce");g(this,"totalGemResistanceModifications");g(this,"parent");g(this,"onParentCellEnter",e=>{!p.TowerManager.isPlacingTower&&p.Grid.gridInteractionEnabled&&!p.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.computedRange)});g(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=i,this.behaviour=a,this.definition=r,this.ticksUntilNextShot=0,this.parent=p.Grid.getCellByRowAndCol(e,i),this.sprite=new V({texture:n,height:p.GridCellSize,width:p.GridCellSize,zIndex:130}),this.container.addChild(this.sprite),this.computedDamageToDeal=this.definition.stats.damage,this.parent.container.addChild(this.container),this.container.interactiveChildren=!0,this.parent.clickDetector.on("pointerenter",this.onParentCellEnter),this.parent.clickDetector.on("pointerleave",this.onParentCellLeave),p.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,i){this.slottedGems[i]=e,p.GameScene.towerPanel.Hide(),p.GameScene.towerPanel.Show(this)}UnslotGem(e){const i=this.slottedGems.splice(e,1)[0];p.GameScene.MissionStats.giveGem(i,!0);for(let n=e;nn!=null),p.NotificationManager.Notify(`Lv. ${i.level} ${i.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return p.Grid.creeps.filter(i=>{const n=i.x,r=i.y,a=this.column*p.GridCellSize+p.GridCellSize/2,o=this.row*p.GridCellSize+p.GridCellSize/2,h=this.computedRange*p.GridCellSize;return kd(a,o,n,r)0){let o=new Z(this.slottedGems[0].definition.color);for(let h=1;h(s.BasicTowerBehaviour="BasicTowerBehaviour",s.CircleTowerBehaviour="CircleTowerBehaviour",s))(ws||{});class Id{constructor(){g(this,"isPlacingTower",!1);g(this,"canPlaceTowers",!0);g(this,"selectedTower",null);g(this,"previewSprite",new V({parent:p.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));g(this,"towers",[]);p.TowerManager=this,p.GameScene.events.on(We.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*p.GridCellSize,this.previewSprite.y=t.row*p.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),p.GameScene.events.on(We.CellMouseLeave,t=>{this.previewSprite.texture=null})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,p.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(p.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):G.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 p.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 i=null;return this.towers.forEach(n=>{n.row==t&&n.column==e&&(i=n)}),i}PlaceTower(t,e,i,n,r){const a=t.texture;if(!p.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!r)return p.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,i)&&p.Grid.getCellByRowAndCol(e,i).type!=Et.Path&&p.Grid.getCellByRowAndCol(e,i).type!=Et.Restricted){r||p.GameScene.MissionStats.spendGold(t.stats.cost);let o=new Gd(e,i,a,t,n);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,p.GameScene.events.emit(Oe.TowerPlacedEvent,t.name,e,i)}else p.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn"),console.warn("Can not place tower on occupied spot or path. Try again.")}update(t){this.towers.forEach(e=>{e.update(t)})}}class Bd extends St{constructor(e){super(!1);g(this,"bounds");g(this,"tooltipSprite");g(this,"titleText");g(this,"costText");g(this,"damageText");g(this,"gemAmount");g(this,"gemAmountSprite");g(this,"title");g(this,"costSprite");g(this,"damageSprite");g(this,"gemDescriptionText");this.bounds=e,this.container.x=-500,this.container.y=-500,this.container.zIndex=150,this.tooltipSprite=new mt({texture:G.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new U({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 V({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:G.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new V({texture:G.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new U({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 U({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 V({texture:G.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new V({texture:G.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new U({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 U({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),p.app.stage.addChildAt(this.container,0)}SetContentTower(e,i,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=G.GemAmountIcons[r],this.costText.text=`Costs ${n} gold.`,this.damageText.text=`Deals ${i} 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,this.gemDescriptionText.text=`Valued at ${e.definition.initialGemValue+e.currentGemImprovement().gemValueUp} gold. `+e.definition.description}Show(e,i){this.container.alpha=1,e+this.container.width>p.app.canvas.width?this.container.x=e-this.container.width:this.container.x=e,this.container.y=i}Hide(){this.container.alpha=0,this.container.x=-500,this.container.y=-500}}const lt=class lt{static init(){window.addEventListener("keydown",lt.handleKeyDown)}static onKeyPressed(t){return lt.listeners=[...lt.listeners,t],()=>lt.offKey(t)}static offKey(t){const e=lt.listeners.indexOf(t);e>=0&&(lt.listeners=[...lt.listeners.slice(0,e),...lt.listeners.slice(e+1)])}static handleKeyDown(t){if(lt.listeners.length>0){console.log(`Key down: ${t.key}`);for(let e=lt.listeners.length-1;e>=0&&(lt.listeners[e](t),!t.defaultPrevented);e--);}}};g(lt,"listeners",[]);let He=lt;class Ws extends St{constructor(e,i,n){super();g(this,"overlay");g(this,"buttonHeight",65);g(this,"buttonCaptions");g(this,"buttons",[]);g(this,"dialogContent");g(this,"dialogContainer");g(this,"background");g(this,"generated",!1);g(this,"escapeKeyButton");g(this,"enterKeyButton");g(this,"keyboardManagerUnsubscribe");g(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,i&&!e.includes(i))throw new Error(`Enter key button "${i}" not found in buttons: ${e}`);this.enterKeyButton=i,this.keyboardManagerUnsubscribe=He.onKeyPressed(this.onKeyPress.bind(this))}show(){this.generate();const e=`x: ${Math.round(this.dialogContainer.x)}, y: ${Math.round(this.dialogContainer.y)}, width: ${Math.round(this.dialogContainer.width)}, height: ${Math.round(this.dialogContainer.height)}`,i=`x: ${Math.round(this.dialogContent.x)}, y: ${Math.round(this.dialogContent.y)}, width: ${Math.round(this.dialogContent.width)}, height: ${Math.round(this.dialogContent.height)}`;return console.debug(`ModalDialogBase.show(dialog: ${e}, content: ${i}, buttons: ${this.buttonCaptions})`),new Promise((n,r)=>{p.app.stage.addChild(this.container),this.onClosed=a=>{this.destroy(),n(a)}})}createDialogBackground(){return new mt({texture:G.Frame04Texture,leftWidth:60,topHeight:60,rightWidth:60,bottomHeight:60})}getWidth(){}getHeight(){}generate(){if(this.generated)return;this.generated=!0,this.overlay=new wt,this.overlay.rect(0,0,p.app.canvas.width,p.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 i=0;for(const l of e)i>0&&(i+=10),i+=l.width;const n=this.buttonCaptions.length>0?this.buttonHeight+10:0;let r=this.getWidth()||Math.max(i,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 z(p.app.canvas.width/2-r/2,p.app.canvas.height/2-a/2,r,a);this.dialogContainer=new st,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=i[0]),!n&&i.length>0&&(n=i[i.length-1]);super(i,n,r);g(this,"caption");this.caption=e}createContent(){return new U({text:this.caption,style:new N({fill:16777215,fontSize:24})})}static show(e,i,n=0){return new Os(e,i).show()}}const Bt=class Bt{constructor(t){g(this,"missionName");g(this,"scores");this.missionName=t,this.scores=this.loadScores(),this.scores.sort((e,i)=>i.score-e.score||e.timestamp-i.timestamp)}loadScores(){const t=localStorage.getItem(Bt.STORAGE_KEY_PREFIX+this.missionName);return Bt.parseStoredScores(t)}saveScores(){localStorage.setItem(Bt.STORAGE_KEY_PREFIX+this.missionName,JSON.stringify(this.scores))}addScore(t){this.scores.push(t),this.scores.sort((e,i)=>i.score-e.score),this.scores.length>Bt.MAX_SCORES&&(this.scores.length=Bt.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(i=>typeof i.playerName=="string"&&typeof i.score=="number"&&typeof i.timestamp=="number"))return e.map(i=>({playerName:i.playerName,score:i.score,timestamp:i.timestamp}))}catch(e){console.error("Failed to parse stored scores:",e)}return[]}};g(Bt,"STORAGE_KEY_PREFIX","highscore_"),g(Bt,"MAX_SCORES",10);let gi=Bt;const Ae={Confirm:"OK",Skip:"Skip"};class Rd extends Ws{constructor(e,i,n){super([Ae.Confirm,Ae.Skip],Ae.Confirm,Ae.Skip);g(this,"dialogCaption");g(this,"playerNameTextInput");g(this,"lost");g(this,"highScore");g(this,"missionStats");this.lost=n,this.highScore=new gi(e),this.missionStats=i}generate(){super.generate(),this.dialogCaption=new U({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 mt({texture:G.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new st,i=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 u=0;uthis.createText((u+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,u)=>Math.max(d,u.width),0)+20,c=l+o.reduce((d,u)=>Math.max(d,u.width),0)+20;for(let d=0;d{i.name==e&&(this.mission=i,this.missionIndex=n)})}init(){p.latestGemId=0,new xd(this.mission.gameMap,this.missionIndex),new Id,new _d(this.mission.rounds,this.mission.gameMap.paths),p.Grid.onGridCellClicked=(e,i)=>{p.TowerManager.isPlacingTower&&p.TowerManager.PlayerClickOnGrid(e,i)},p.WaveManager.events.on(ee.CreepSpawned,e=>{p.Grid.addCreep(e),e.events.on(Mt.Escaped,()=>{this.onCreepEscaped(e)})}),p.WaveManager.events.on(ee.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(Mt.Died,(e,i)=>{this.MissionStats.earnGold(e)}),this.towerPanel=new Cd(Wt.SidebarRect),this.sidebar=new Md(Wt.SidebarRect),this.changeRoundButton=new se(Wt.ChangeRoundButtonRect,"",Ot.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),p.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new Bd(new z(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new V({texture:G.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)return p.NotificationManager.Notify("Wave is already in progress.","warn");if(this.isGameOver)return p.NotificationManager.Notify("No more waves.","danger");this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=G.ExclamationIconTexture,this.events.emit(ee.NewWave,`${this.currentRound+1}`))},this.MissionStats=new Pd(100,200),this.events.on(Ds.TowerPanelSelectGem,(e,i,n)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return p.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,i,n)}),this.ticker=new At,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(p.MouseX,p.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}p.WaveManager.update(e),p.Grid.update(e),p.TowerManager.update(e),this.isWaveManagerFinished&&p.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=G.PlayIconTexture,p.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(p.NotificationManager.Notify("Mission victory!!","reward"),this.changeRoundButton.buttonIcon.texture=G.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,p.app.canvas.width,p.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){p.Grid.gridInteractionEnabled=!1,p.GameScene.sidebar.towerTab.resetTint(),p.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new mt({width:380,height:150,texture:G.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:p.app.canvas.width/2-190,y:p.app.canvas.height/2-75}),p.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let i=new U({x:p.app.canvas.width/4,y:p.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}}});p.GameMaster.currentScene.stage.addChildAt(i,0),e.forEach((n,r)=>{let a=new _s(n,!0),o=new Ne(0,p.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=()=>{p.GameScene.tooltip.SetContentGem(a),p.GameScene.tooltip.Show(p.MouseX,p.MouseY)},o.container.onpointerleave=()=>{p.GameScene.tooltip.Hide()},o.onClick=()=>{p.GameScene.tooltip.Hide(),i.destroy(),this.PlayerPickedGem(new _s(n))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(i=>i.destroy()),p.Grid.gridInteractionEnabled=!0,this.MissionStats.giveGem(e),this.setRoundMode(0)}async ShowEndgameDialog(e){await new Rd(this.mission.name,this.MissionStats,e).show();const r=await new Fd(this.mission.name,e,!e&&this.missionIndex+1{p.GameMaster.changeScene(new Ga)},G.Missions.forEach((e,i)=>{const n=new se(new z(p.app.canvas.width/2-150,p.app.canvas.height/5+i*80,300,60),e.name,Ot.Button01);n.onClick=r=>{p.GameMaster.changeScene(new $e(e.name))}})}}class Ga extends Us{init(){const t={caption:"New Game",rect:new z(p.app.canvas.width/2-150,p.app.canvas.height/5+240,300,60),texture:Ot.Button02},e={caption:"Settings",rect:new z(p.app.canvas.width/2-300/2,p.app.canvas.height/5+4*80,300,60),texture:Ot.Button02};let i=new U({x:p.app.canvas.width/2-300/2,y:p.app.canvas.height/5+1*80,text:"BASTION",style:{fill:16755200,fontFamily:"Aclonica",fontSize:100}});i.x=i.x-i.width/5,p.GameMaster.currentScene.stage.addChild(i);let n=new U({x:0,y:0,text:"Latest commit: "+p.latestCommit,style:{fill:0,fontSize:10,fontWeight:"bold"}});p.GameMaster.currentScene.stage.addChild(n);const r=new se(t.rect,t.caption,t.texture,!0);r.onClick=o=>{p.GameMaster.currentScene.stage.removeChild(i),p.GameMaster.currentScene.stage.removeChild(n),p.GameMaster.changeScene(new li)};let a=new se(e.rect,e.caption,e.texture,!0);a.onClick=o=>{p.NotificationManager.Notify("Not finished.","info")}}}class Ld{constructor(){g(this,"finished",!1);g(this,"calledBack",!1);g(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Dd extends Ld{constructor(e,i,n,r){super();g(this,"fadeType");g(this,"fadeTime");g(this,"pixiObject");g(this,"ticks",0);this.fadeType=e,this.fadeTime=i,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 zd{constructor(){g(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const i=this.AnimationQueue[e];i.finished?(i.callbackFn(),this.AnimationQueue.splice(e,1)):i.update(t)}}}class Ud{constructor(t,e,i,n,r){g(this,"textObj");g(this,"ticksToFadeAway");g(this,"animating",!1);g(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 U({text:t,style:new N({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:i,y:n,zIndex:100}),this.textObj.anchor.set(.5,.5),p.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class Wd extends Ht{constructor(){super();g(this,"notifications",[]);g(this,"ticks",0);this.bb.x=p.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,p.app.stage.addChild(this.container)}Notify(e,i){let n=0,r=this.notifications.length*32;this.notifications.push(new Ud(e,i,n,r,this.ticks+180))}update(e){this.ticks++;for(let i=this.notifications.length-1;i>=0;i--){const n=this.notifications[i];if(n.destroyed){this.notifications.splice(i,1);continue}this.ticks>=n.ticksToFadeAway&&!n.animating&&(n.animating=!0,p.AnimationManager.Animate(new Dd("out",300,n.textObj,()=>{n.destroy()})))}}}(async()=>{const s=new Vr;p.app=s,await s.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(s.canvas);function t(){const i=window.innerWidth,n=window.innerHeight,r=i/s.screen.width,a=n/s.screen.height,o=Math.min(r,a),h=Math.round(s.screen.width*o),l=Math.round(s.screen.height*o),c=(i-h)/2,d=(n-l)/2;s.canvas.style.width=`${h}px`,s.canvas.style.height=`${l}px`,s.canvas.style.marginLeft=`${c}px`,s.canvas.style.marginTop=`${d}px`,s.canvas.style.marginRight="0",s.canvas.style.marginBottom="0",s.canvas.style.display="block"}p.latestCommit=await fetch("/latest_commit").then(i=>i.text()),window.addEventListener("resize",t),t(),await G.LoadAssets(),Wt.init(),He.init(),new gd,p.AnimationManager=new zd,p.NotificationManager=new Wd,globalThis.Engine=p,At.shared.add(i=>{p.NotificationManager.update(i.elapsedMS),p.AnimationManager.update(i.elapsedMS)}),s.canvas.addEventListener("pointermove",function(i){p.MouseX=(i.clientX-s.canvas.offsetLeft)/s.canvas.offsetWidth*1920,p.MouseY=(i.clientY-s.canvas.offsetTop)/s.canvas.offsetHeight*1080}),p.GameMaster.changeScene(new Ga),new URLSearchParams(location.href).entries().next().value[1]=="game"&&p.GameMaster.changeScene(new $e("The Turn")),p.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":p.TestSuite()})();export{W as $,Or as A,et as B,st as C,Q as D,P as E,hr as F,yi as G,Pt as H,hn as I,V as J,Xo as K,eh as L,H as M,nt as N,z as O,ot as P,_h as Q,rs as R,Uh as S,Lt as T,ui as U,cn as V,To as W,Ei as X,Z as Y,cr as Z,Nr as _,D as a,O as a0,Ch as a1,Jr as a2,ll as a3,dl as a4,ml as a5,yl as a6,_l as a7,ue as a8,N as a9,lc as aa,xs as ab,ra as ac,wn as ad,ae,dd as af,$n as ag,gc as ah,wt as ai,j as aj,Qa as ak,ms as al,Nn as am,oa as an,At as b,dt as c,Ut as d,ht as e,_n as f,Lh as g,oi as h,Cs as i,zr as j,wr as k,Rr as l,On as m,qs as n,hl as o,cl as p,pl as q,co as r,jr as s,xl as t,Ts as u,Gr as v,it as w,Za as x,bl as y,Rt as z};