bastion.overflow.fun/assets/index-WJSjzvvL.js

298 lines
340 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-Bnl4Z-wu.js","assets/webworkerAll-Cp5jyL-l.js","assets/colorToUniform-Dzvfc6yy.js","assets/WebGPURenderer-CNuCBG1t.js","assets/SharedSystems-Cfxyk_gB.js","assets/WebGLRenderer-O3oCvy8A.js"])))=>i.map(i=>d[i]);
var Ua=Object.defineProperty;var Na=(i,t,e)=>t in i?Ua(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var p=(i,t,e)=>Na(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();const Oa="modulepreload",Wa=function(i){return"/"+i},en={},mi=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=Promise.allSettled(e.map(h=>{if(h=Wa(h),h in en)return;en[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":Oa,l||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),l)return new Promise((f,g)=>{d.addEventListener("load",f),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return n.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})};var G=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(G||{});const as=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},ei=(i,t)=>as(i).priority??t,dt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(as).forEach(t=>{t.type.forEach(e=>{var s,n;return(n=(s=this._removeHandlers)[e])==null?void 0:n.call(s,t)})}),this},add(...i){return i.map(as).forEach(t=>{t.type.forEach(e=>{var r,a;const s=this._addHandlers,n=this._queue;s[e]?(a=s[e])==null||a.call(s,t):(n[e]=n[e]||[],(r=n[e])==null||r.push(t))})}),this},handle(i,t,e){var a;const s=this._addHandlers,n=this._removeHandlers;if(s[i]||n[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,n[i]=e;const r=this._queue;return r[i]&&((a=r[i])==null||a.forEach(o=>t(o)),delete r[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(r=>r.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((r,a)=>ei(a.value,e)-ei(r.value,e)))},s=>{const n=t.findIndex(r=>r.name===s.name);n!==-1&&t.splice(n,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((n,r)=>ei(r,e)-ei(n,e)))},s=>{const n=t.indexOf(s.ref);n!==-1&&t.splice(n,1)})}},Ha={extension:{type:G.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await mi(()=>import("./browserAll-Bnl4Z-wu.js"),__vite__mapDeps([0,1,2]))}},$a={extension:{type:G.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await mi(()=>import("./webworkerAll-Cp5jyL-l.js"),__vite__mapDeps([1,2]))}};class pt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new pt(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 Gs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var nr={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,d,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var g=new n(c,d||h,f),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],g]:h._events[m].push(g):(h._events[m]=g,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,d;if(this._eventsCount===0)return l;for(d in c=this._events)t.call(c,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=e?e+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,g=d.length,m=new Array(g);f<g;f++)m[f]=d[f].fn;return m},o.prototype.listenerCount=function(l){var c=e?e+l:l,d=this._events[c];return d?d.fn?1:d.length:0},o.prototype.emit=function(l,c,d,f,g,m){var y=e?e+l:l;if(!this._events[y])return!1;var x=this._events[y],w=arguments.length,_,b;if(x.fn){switch(x.once&&this.removeListener(l,x.fn,void 0,!0),w){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,c),!0;case 3:return x.fn.call(x.context,c,d),!0;case 4:return x.fn.call(x.context,c,d,f),!0;case 5:return x.fn.call(x.context,c,d,f,g),!0;case 6:return x.fn.call(x.context,c,d,f,g,m),!0}for(b=1,_=new Array(w-1);b<w;b++)_[b-1]=arguments[b];x.fn.apply(x.context,_)}else{var S=x.length,A;for(b=0;b<S;b++)switch(x[b].once&&this.removeListener(l,x[b].fn,void 0,!0),w){case 1:x[b].fn.call(x[b].context);break;case 2:x[b].fn.call(x[b].context,c);break;case 3:x[b].fn.call(x[b].context,c,d);break;case 4:x[b].fn.call(x[b].context,c,d,f);break;default:if(!_)for(A=1,_=new Array(w-1);A<w;A++)_[A-1]=arguments[A];x[b].fn.apply(x[b].context,_)}}return!0},o.prototype.on=function(l,c,d){return r(this,l,c,d,!1)},o.prototype.once=function(l,c,d){return r(this,l,c,d,!0)},o.prototype.removeListener=function(l,c,d,f){var g=e?e+l:l;if(!this._events[g])return this;if(!c)return a(this,g),this;var m=this._events[g];if(m.fn)m.fn===c&&(!f||m.once)&&(!d||m.context===d)&&a(this,g);else{for(var y=0,x=[],w=m.length;y<w;y++)(m[y].fn!==c||f&&!m[y].once||d&&m[y].context!==d)&&x.push(m[y]);x.length?this._events[g]=x.length===1?x[0]:x:a(this,g)}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&a(this,c)):(this._events=new s,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,i.exports=o})(nr);var Va=nr.exports;const gt=Gs(Va),Ya=Math.PI*2,Xa=180/Math.PI,ja=Math.PI/180;class lt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new lt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Ei.x=0,Ei.y=0,Ei}}const Ei=new lt;class H{constructor(t=1,e=0,s=0,n=1,r=0,a=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=n,this.tx=r,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,n,r,a){return this.a=t,this.b=e,this.c=s,this.d=n,this.tx=r,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new lt;const s=t.x,n=t.y;return e.x=this.a*s+this.c*n+this.tx,e.y=this.b*s+this.d*n+this.ty,e}applyInverse(t,e){e=e||new lt;const s=this.a,n=this.b,r=this.c,a=this.d,o=this.tx,h=this.ty,l=1/(s*a+r*-n),c=t.x,d=t.y;return e.x=a*l*c+-r*l*d+(h*r-o*a)*l,e.y=s*l*d+-n*l*c+(-h*s+o*n)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),n=this.a,r=this.c,a=this.tx;return this.a=n*e-this.b*s,this.b=n*s+this.b*e,this.c=r*e-this.d*s,this.d=r*s+this.d*e,this.tx=a*e-this.ty*s,this.ty=a*s+this.ty*e,this}append(t){const e=this.a,s=this.b,n=this.c,r=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*s+t.b*r,this.c=t.c*e+t.d*n,this.d=t.c*s+t.d*r,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*s+t.ty*r+this.ty,this}appendFrom(t,e){const s=t.a,n=t.b,r=t.c,a=t.d,o=t.tx,h=t.ty,l=e.a,c=e.b,d=e.c,f=e.d;return this.a=s*l+n*d,this.b=s*c+n*f,this.c=r*l+a*d,this.d=r*c+a*f,this.tx=o*l+h*d+e.tx,this.ty=o*c+h*f+e.ty,this}setTransform(t,e,s,n,r,a,o,h,l){return this.a=Math.cos(o+l)*r,this.b=Math.sin(o+l)*r,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(s*this.a+n*this.c),this.ty=e-(s*this.b+n*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,n=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,n=this.c,r=this.d,a=t.pivot,o=-Math.atan2(-n,r),h=Math.atan2(s,e),l=Math.abs(o+h);return l<1e-5||Math.abs(Ya-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(n*n+r*r),t.position.x=this.tx+(a.x*e+a.y*n),t.position.y=this.ty+(a.x*s+a.y*r),t}invert(){const t=this.a,e=this.b,s=this.c,n=this.d,r=this.tx,a=t*n-e*s;return this.a=n/a,this.b=-e/a,this.c=-s/a,this.d=t/a,this.tx=(s*this.ty-n*r)/a,this.ty=-(t*this.ty-e*r)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new H;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Ka.identity()}static get shared(){return qa.identity()}}const qa=new H,Ka=new H,Jt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],te=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ee=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ie=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],os=[],rr=[],ii=Math.sign;function Za(){for(let i=0;i<16;i++){const t=[];os.push(t);for(let e=0;e<16;e++){const s=ii(Jt[i]*Jt[e]+ee[i]*te[e]),n=ii(te[i]*Jt[e]+ie[i]*te[e]),r=ii(Jt[i]*ee[e]+ee[i]*ie[e]),a=ii(te[i]*ee[e]+ie[i]*ie[e]);for(let o=0;o<16;o++)if(Jt[o]===s&&te[o]===n&&ee[o]===r&&ie[o]===a){t.push(o);break}}}for(let i=0;i<16;i++){const t=new H;t.set(Jt[i],te[i],ee[i],ie[i],0,0),rr.push(t)}}Za();const j={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>Jt[i],uY:i=>te[i],vX:i=>ee[i],vY:i=>ie[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>os[i][t],sub:(i,t)=>os[i][j.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?j.S:j.N:Math.abs(t)*2<=Math.abs(i)?i>0?j.E:j.W:t>0?i>0?j.SE:j.SW:i>0?j.NE:j.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const n=rr[j.inv(t)];n.tx=e,n.ty=s,i.append(n)}},si=[new lt,new lt,new lt,new lt];class I{constructor(t=0,e=0,s=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new I(0,0,0,0)}clone(){return new I(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.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,s){const{width:n,height:r}=this;if(n<=0||r<=0)return!1;const a=this.x,o=this.y,h=a-s/2,l=a+n+s/2,c=o-s/2,d=o+r+s/2,f=a+s/2,g=a+n-s/2,m=o+s/2,y=o+r-s/2;return t>=h&&t<=l&&e>=c&&e<=d&&!(t>f&&t<g&&e>m&&e<y)}intersects(t,e){if(!e){const k=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=k)return!1;const T=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>T}const s=this.left,n=this.right,r=this.top,a=this.bottom;if(n<=s||a<=r)return!1;const o=si[0].set(t.left,t.top),h=si[1].set(t.left,t.bottom),l=si[2].set(t.right,t.top),c=si[3].set(t.right,t.bottom);if(l.x<=o.x||h.y<=o.y)return!1;const d=Math.sign(e.a*e.d-e.b*e.c);if(d===0||(e.apply(o,o),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(o.x,h.x,l.x,c.x)<=s||Math.min(o.x,h.x,l.x,c.x)>=n||Math.max(o.y,h.y,l.y,c.y)<=r||Math.min(o.y,h.y,l.y,c.y)>=a))return!1;const f=d*(h.y-o.y),g=d*(o.x-h.x),m=f*s+g*r,y=f*n+g*r,x=f*s+g*a,w=f*n+g*a;if(Math.max(m,y,x,w)<=f*o.x+g*o.y||Math.min(m,y,x,w)>=f*c.x+g*c.y)return!1;const _=d*(o.y-l.y),b=d*(l.x-o.x),S=_*s+b*r,A=_*n+b*r,F=_*s+b*a,P=_*n+b*a;return!(Math.max(S,A,F,P)<=_*o.x+b*o.y||Math.min(S,A,F,P)>=_*c.x+b*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=r-n,this}getBounds(t){return t=t||new I,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ri={default:-1};function nt(i="default"){return Ri[i]===void 0&&(Ri[i]=-1),++Ri[i]}const sn={},O="8.0.0",Qa="8.3.4";function U(i,t,e=3){if(sn[t])return;let s=new Error().stack;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${i}`):(s=s.split(`
`).splice(e).join(`
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
Deprecated since v${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${i}`),console.warn(s))),sn[t]=!0}const ar=()=>{};function nn(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function rn(i){return!(i&i-1)&&!!i}function Ja(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const an=Object.create(null);function to(i){const t=an[i];return t===void 0&&(an[i]=nt("resource")),t}const or=class hr extends gt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...hr.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){U(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=to(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};or.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let eo=or;const lr=class cr extends gt{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={...cr.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 eo(Ja(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=nt("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const n=Math.round(t*s),r=Math.round(e*s);return this.width=n/s,this.height=r/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=nt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=rn(this.pixelWidth)&&rn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};lr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Nt=lr;class ks extends Nt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}ks.extension=G.TextureSource;const on=new H;class io{constructor(t,e){this.mapCoord=new H,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let n=0;n<t.length;n+=2){const r=t[n],a=t[n+1];e[n]=r*s.a+a*s.c+s.tx,e[n+1]=r*s.b+a*s.d+s.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const s=t.orig,n=t.trim;n&&(on.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(on));const r=t.source,a=this.uClampFrame,o=this.clampMargin/r._resolution,h=this.clampOffset/r._resolution;return a[0]=(t.frame.x+o+h)/r.width,a[1]=(t.frame.y+o+h)/r.height,a[2]=(t.frame.x+t.frame.width-o+h)/r.width,a[3]=(t.frame.y+t.frame.height-o+h)/r.height,this.uClampOffset[0]=this.clampOffset/r.pixelWidth,this.uClampOffset[1]=this.clampOffset/r.pixelHeight,this.isSimple=t.frame.width===r.width&&t.frame.height===r.height&&t.rotate===0,!0}}class z extends gt{constructor({source:t,label:e,frame:s,orig:n,trim:r,defaultAnchor:a,defaultBorders:o,rotate:h,dynamic:l}={}){if(super(),this.uid=nt("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new I,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new Nt,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:c,height:d}=this._source;this.frame.width=c,this.frame.height=d}this.orig=n||this.frame,this.trim=r,this.rotate=h??0,this.defaultAnchor=a,this.defaultBorders=o,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new io(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:s,height:n}=this._source,r=e.x/s,a=e.y/n,o=e.width/s,h=e.height/n;let l=this.rotate;if(l){const c=o/2,d=h/2,f=r+c,g=a+d;l=j.add(l,j.NW),t.x0=f+c*j.uX(l),t.y0=g+d*j.uY(l),l=j.add(l,2),t.x1=f+c*j.uX(l),t.y1=g+d*j.uY(l),l=j.add(l,2),t.x2=f+c*j.uX(l),t.y2=g+d*j.uY(l),l=j.add(l,2),t.x3=f+c*j.uX(l),t.y3=g+d*j.uY(l)}else t.x0=r,t.y0=a,t.x1=r+o,t.y1=a,t.x2=r+o,t.y2=a+h,t.x3=r,t.y3=a+h}destroy(t=!1){this._source&&t&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return U(O,"Texture.baseTexture is now Texture.source"),this._source}}z.EMPTY=new z({label:"EMPTY",source:new Nt({label:"EMPTY"})});z.EMPTY.destroy=ar;z.WHITE=new z({source:new ks({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});z.WHITE.destroy=ar;function so(i,t,e,s){const{width:n,height:r}=e.orig,a=e.trim;if(a){const o=a.width,h=a.height;i.minX=a.x-t._x*n-s,i.maxX=i.minX+o,i.minY=a.y-t._y*r-s,i.maxY=i.minY+h}else i.minX=-t._x*n-s,i.maxX=i.minX+n,i.minY=-t._y*r-s,i.maxY=i.minY+r}const hn=new H;class Et{constructor(t=1/0,e=1/0,s=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=hn,this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new I);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=hn,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,r){r||(r=this.matrix);const a=r.a,o=r.b,h=r.c,l=r.d,c=r.tx,d=r.ty;let f=this.minX,g=this.minY,m=this.maxX,y=this.maxY,x=a*t+h*e+c,w=o*t+l*e+d;x<f&&(f=x),w<g&&(g=w),x>m&&(m=x),w>y&&(y=w),x=a*s+h*e+c,w=o*s+l*e+d,x<f&&(f=x),w<g&&(g=w),x>m&&(m=x),w>y&&(y=w),x=a*t+h*n+c,w=o*t+l*n+d,x<f&&(f=x),w<g&&(g=w),x>m&&(m=x),w>y&&(y=w),x=a*s+h*n+c,w=o*s+l*n+d,x<f&&(f=x),w<g&&(g=w),x>m&&(m=x),w>y&&(y=w),this.minX=f,this.minY=g,this.maxX=m,this.maxY=y}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,s=this.minY,n=this.maxX,r=this.maxY,{a,b:o,c:h,d:l,tx:c,ty:d}=t;let f=a*e+h*s+c,g=o*e+l*s+d;this.minX=f,this.minY=g,this.maxX=f,this.maxY=g,f=a*n+h*s+c,g=o*n+l*s+d,this.minX=f<this.minX?f:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY,f=a*e+h*r+c,g=o*e+l*r+d,this.minX=f<this.minX?f:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY,f=a*n+h*r+c,g=o*n+l*r+d,this.minX=f<this.minX?f:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<s&&(this.minY=s),this.maxY>n&&(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 Et(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,n){let r=this.minX,a=this.minY,o=this.maxX,h=this.maxY;n||(n=this.matrix);const l=n.a,c=n.b,d=n.c,f=n.d,g=n.tx,m=n.ty;for(let y=e;y<s;y+=2){const x=t[y],w=t[y+1],_=l*x+d*w+g,b=c*x+f*w+m;r=_<r?_:r,a=b<a?b:a,o=_>o?_: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 no={grad:.9,turn:360,rad:360/(2*Math.PI)},Ft=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},at=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},wt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},dr=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},ln=function(i){return{r:wt(i.r,0,255),g:wt(i.g,0,255),b:wt(i.b,0,255),a:wt(i.a)}},Fi=function(i){return{r:at(i.r),g:at(i.g),b:at(i.b),a:at(i.a,3)}},ro=/^#([0-9a-f]{3,8})$/i,ni=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},ur=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=Math.max(t,e,s),a=r-Math.min(t,e,s),o=a?r===t?(e-s)/a:r===e?2+(s-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:r?a/r*100:0,v:r/255*100,a:n}},fr=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var r=Math.floor(t),a=s*(1-e),o=s*(1-(t-r)*e),h=s*(1-(1-t+r)*e),l=r%6;return{r:255*[s,o,a,a,h,s][l],g:255*[h,s,s,o,a,a][l],b:255*[a,a,h,s,s,o][l],a:n}},cn=function(i){return{h:dr(i.h),s:wt(i.s,0,100),l:wt(i.l,0,100),a:wt(i.a)}},dn=function(i){return{h:at(i.h),s:at(i.s),l:at(i.l),a:at(i.a,3)}},un=function(i){return fr((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Oe=function(i){return{h:(t=ur(i)).h,s:(n=(200-(e=t.s))*(s=t.v)/100)>0&&n<200?e*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,s,n},ao=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ho=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hs={string:[[function(i){var t=ro.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?at(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?at(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=ho.exec(i)||lo.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:ln({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=ao.exec(i)||oo.exec(i);if(!t)return null;var e,s,n=cn({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(no[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return un(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=n===void 0?1:n;return Ft(t)&&Ft(e)&&Ft(s)?ln({r:Number(t),g:Number(e),b:Number(s),a:Number(r)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,r=n===void 0?1:n;if(!Ft(t)||!Ft(e)||!Ft(s))return null;var a=cn({h:Number(t),s:Number(e),l:Number(s),a:Number(r)});return un(a)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,r=n===void 0?1:n;if(!Ft(t)||!Ft(e)||!Ft(s))return null;var a=function(o){return{h:dr(o.h),s:wt(o.s,0,100),v:wt(o.v,0,100),a:wt(o.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(r)});return fr(a)},"hsv"]]},fn=function(i,t){for(var e=0;e<t.length;e++){var s=t[e][0](i);if(s)return[s,t[e][1]]}return[null,void 0]},co=function(i){return typeof i=="string"?fn(i.trim(),hs.string):typeof i=="object"&&i!==null?fn(i,hs.object):[null,void 0]},Li=function(i,t){var e=Oe(i);return{h:e.h,s:wt(e.s+100*t,0,100),l:e.l,a:e.a}},Di=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},pn=function(i,t){var e=Oe(i);return{h:e.h,s:e.s,l:wt(e.l+100*t,0,100),a:e.a}},ls=function(){function i(t){this.parsed=co(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return i.prototype.isValid=function(){return this.parsed!==null},i.prototype.brightness=function(){return at(Di(this.rgba),2)},i.prototype.isDark=function(){return Di(this.rgba)<.5},i.prototype.isLight=function(){return Di(this.rgba)>=.5},i.prototype.toHex=function(){return t=Fi(this.rgba),e=t.r,s=t.g,n=t.b,a=(r=t.a)<1?ni(at(255*r)):"","#"+ni(e)+ni(s)+ni(n)+a;var t,e,s,n,r,a},i.prototype.toRgb=function(){return Fi(this.rgba)},i.prototype.toRgbString=function(){return t=Fi(this.rgba),e=t.r,s=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+s+", "+n+", "+r+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,r},i.prototype.toHsl=function(){return dn(Oe(this.rgba))},i.prototype.toHslString=function(){return t=dn(Oe(this.rgba)),e=t.h,s=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+r+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,r},i.prototype.toHsv=function(){return t=ur(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},i.prototype.invert=function(){return Pt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),Pt(Li(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Pt(Li(this.rgba,-t))},i.prototype.grayscale=function(){return Pt(Li(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Pt(pn(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Pt(pn(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?Pt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Oe(this.rgba);return typeof t=="number"?Pt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Pt(t).toHex()},i}(),Pt=function(i){return i instanceof ls?i:new ls(i)},gn=[],uo=function(i){i.forEach(function(t){gn.indexOf(t)<0&&(t(ls,hs),gn.push(t))})};function fo(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var n in e)s[e[n]]=n;var r={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=s[this.toHex()];if(l)return l;if(a!=null&&a.closest){var c=this.toRgb(),d=1/0,f="black";if(!r.length)for(var g in e)r[g]=new i(e[g]).toRgb();for(var m in e){var y=(o=c,h=r[m],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));y<d&&(d=y,f=m)}return f}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new i(h).toRgb():null},"name"])}uo([fo]);const me=class De{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof De)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((r,a)=>r===e[a]);if(t!==null&&e!==null){const r=Object.keys(t),a=Object.keys(e);return r.length!==a.length?!1:r.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,n]=this._components;return{r:t,g:e,b:s,a:n}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,n,r]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,n]=this._components;return t[0]=e,t[1]=s,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,n,r]=De._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,s=(a>>8&255)/255,n=(a&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,n,r=255]=t,e/=255,s/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=De.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Pt(t);a.isValid()&&({r:e,g:s,b:n,a:r}=a.rgba,e/=255,s/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=n,this._components[3]=r,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof De||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};me.shared=new me;me._temp=new me;me.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Y=me;const po={cullArea:null,cullable:!1,cullableChildren:!0};class Bs{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var s;let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class go{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 Bs(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const zt=new go;function mo(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const r=s-e;for(n=t;n<r;++n)i[n]=i[n+e];i.length=r}const xo={allowChildren:!0,removeChildren(i=0,t){const e=t??this.children.length,s=e-i,n=[];if(s>0&&s<=e){for(let a=e-1;a>=i;a--){const o=this.children[a];o&&(n.push(o),o.parent=null)}mo(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let a=0;a<n.length;++a)this.emit("childRemoved",n[a],this,a),n[a].emit("removed",this);return n}else if(s===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const t=this.getChildAt(i);return this.removeChild(t)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||U(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(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(i.parent){const n=i.parent.children.indexOf(i);if(i.parent===this&&n===t)return i;n!==-1&&i.parent.children.splice(n,1)}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,t),i.emit("added",this),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var i;(i=this.parent)==null||i.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i}};class mn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class yo{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const s=this._tests[e];if(s.test(t))return zt.get(s.maskClass,t)}return t}returnMaskEffect(t){zt.return(t)}}const cs=new yo;dt.handleByList(G.MaskEffect,cs._effectClasses);const wo={_maskEffect:null,_filterEffect:null,effects:[],addEffect(i){if(this.effects.indexOf(i)!==-1)return;this.effects.push(i),this.effects.sort((s,n)=>s.priority-n.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const t=this._maskEffect;(t==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),cs.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=cs.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},set filters(i){var r;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new mn);i=i;const e=(i==null?void 0:i.length)>0,s=((r=t.filters)==null?void 0:r.length)>0,n=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new mn),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},_o={label:null,get name(){return U(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){U(O,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s<e.length;s++){const n=e[s];if(n.label===i||i instanceof RegExp&&i.test(n.label))return n}if(t)for(let s=0;s<e.length;s++){const r=e[s].getChildByLabel(i,!0);if(r)return r}return null},getChildrenByLabel(i,t=!1,e=[]){const s=this.children;for(let n=0;n<s.length;n++){const r=s[n];(r.label===i||i instanceof RegExp&&i.test(r.label))&&e.push(r)}if(t)for(let n=0;n<s.length;n++)s[n].getChildrenByLabel(i,!0,e);return e}},Ut=new Bs(H),xe=new Bs(Et);function pr(i,t,e){e.clear();let s,n;return i.parent?t?s=i.parent.worldTransform:(n=Ut.get().identity(),s=xi(i,n)):s=H.IDENTITY,gr(i,e,s,t),n&&Ut.return(n),e.isValid||e.set(0,0,0,0),e}function gr(i,t,e,s){var o,h;if(!i.visible||!i.measurable)return;let n;s?n=i.worldTransform:(i.updateLocalTransform(),n=Ut.get(),n.appendFrom(i.localTransform,e));const r=t,a=!!i.effects.length;if(a&&(t=xe.get().clear()),i.boundsArea)t.addRect(i.boundsArea,n);else{i.addBounds&&(t.matrix=n,i.addBounds(t));for(let l=0;l<i.children.length;l++)gr(i.children[l],t,n,s)}if(a){for(let l=0;l<i.effects.length;l++)(h=(o=i.effects[l]).addBounds)==null||h.call(o,t);r.addBounds(t,H.IDENTITY),xe.return(t)}s||Ut.return(n)}function xi(i,t){const e=i.parent;return e&&(xi(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}let zi=0;const xn=500;function st(...i){zi!==xn&&(zi++,zi===xn?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}function mr(i,t,e){return t.clear(),e||(e=H.IDENTITY),xr(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function xr(i,t,e,s,n){var h,l;let r;if(n)r=Ut.get(),r=e.copyTo(r);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const c=i.localTransform;r=Ut.get(),r.appendFrom(c,e)}const a=t,o=!!i.effects.length;if(o&&(t=xe.get().clear()),i.boundsArea)t.addRect(i.boundsArea,r);else{i.renderPipeId&&(t.matrix=r,i.addBounds(t));const c=i.children;for(let d=0;d<c.length;d++)xr(c[d],t,r,s,!1)}if(o){for(let c=0;c<i.effects.length;c++)(l=(h=i.effects[c]).addLocalBounds)==null||l.call(h,t,s);a.addBounds(t,H.IDENTITY),xe.return(t)}Ut.return(r)}function yr(i,t){const e=i.children;for(let s=0;s<e.length;s++){const n=e[s],r=n.uid,a=(n._didViewChangeTick&65535)<<16|n._didContainerChangeTick&65535,o=t.index;(t.data[o]!==r||t.data[o+1]!==a)&&(t.data[t.index]=r,t.data[t.index+1]=a,t.didChange=!0),t.index=o+2,n.children.length&&yr(n,t)}return t.didChange}const bo=new H,So={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=i/t*e:this.scale.x=e},_setHeight(i,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=i/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Et});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),yr(this,i),i.didChange&&mr(this,i.localBounds,bo),i.localBounds},getBounds(i,t){return pr(this,i,t||new Et)}},vo={_onRender:null,set onRender(i){const t=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},Co={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(To))}};function To(i,t){return i._zIndex-t._zIndex}const Ao={getGlobalPosition(i=new lt,t=!1){return this.parent?this.parent.toGlobal(this._position,i,t):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,t,e=!1){if(!e){this.updateLocalTransform();const s=xi(this,new H);return s.append(this.localTransform),s.apply(i,t)}return this.worldTransform.apply(i,t)},toLocal(i,t,e,s){if(t&&(i=t.toGlobal(i,e,s)),!s){this.updateLocalTransform();const n=xi(this,new H);return n.append(this.localTransform),n.applyInverse(i,e)}return this.worldTransform.applyInverse(i,e)}};let Mo=0;class wr{constructor(){this.uid=nt("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.tick=0}reset(){this.instructionSize=0,this.tick=Mo++}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class Po{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new H,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new wr,this._onRenderContainers=[]}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let s=0;s<e.length;s++)this.removeChild(e[s])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(t.didViewUpdate=!1,this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t))}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender()}destroy(){this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let s=0;s<e.length;s++)this._getChildren(e[s],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const s=t.children;for(let n=0;n<s.length;n++)this._getChildren(s[n],e);return e}}function Go(i,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(i[s]=t[s])}const Ui=new pt(null),Ni=new pt(null),Oi=new pt(null,1,1),yn=1,ko=2,Wi=4;class tt extends gt{constructor(t={}){var e,s;super(),this.uid=nt("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.updateTick=-1,this.localTransform=new H,this.relativeGroupTransform=new H,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new pt(this,0,0),this._scale=Oi,this._pivot=Ni,this._skew=Ui,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Go(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(n=>this.addChild(n)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(tt.prototype,Object.getOwnPropertyDescriptors(t))}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||U(O,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n<t.length;n++)this.addChild(t[n]);return t[0]}const e=t[0];if(e.parent===this)return this.children.splice(this.children.indexOf(e),1),this.children.push(e),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),e;e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e.didViewUpdate=!1,e._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e}removeChild(...t){if(t.length>1){for(let n=0;n<t.length;n++)this.removeChild(t[n]);return t[0]}const e=t[0],s=this.children.indexOf(e);return s>-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=zt.get(Po,this),this.groupTransform=H.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),zt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new H),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Xa}set angle(t){this.rotation=t*ja}get pivot(){return this._pivot===Ni&&(this._pivot=new pt(this,0,0)),this._pivot}set pivot(t){this._pivot===Ni&&(this._pivot=new pt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Ui&&(this._skew=new pt(this,0,0)),this._skew}set skew(t){this._skew===Ui&&(this._skew=new pt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Oi&&(this._scale=new pt(this,1,1)),this._scale}set scale(t){this._scale===Oi&&(this._scale=new pt(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,n=this._pivot,r=this._position,a=s._x,o=s._y,h=n._x,l=n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=r._x-(h*e.a+l*e.c),e.ty=r._y-(h*e.b+l*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=yn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Y.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=yn,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|=ko,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Wi,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Wi,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Wi,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var n;if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let r=0;r<e.length;++r)e[r].destroy(t);(n=this.renderGroup)==null||n.destroy(),this.renderGroup=null}}tt.mixin(xo);tt.mixin(Ao);tt.mixin(vo);tt.mixin(So);tt.mixin(wo);tt.mixin(_o);tt.mixin(Co);tt.mixin(po);class vi extends tt{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=0,this._lastInstructionTick=-1,this._bounds=new Et(0,1,0,0),this._boundsDirty=!0}_updateBounds(){}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:s,y:n}=t;return s>=e.minX&&s<=e.maxX&&n>=e.minY&&n<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class $ extends vi{constructor(t=z.EMPTY){t instanceof z&&(t={texture:t});const{texture:e=z.EMPTY,anchor:s,roundPixels:n,width:r,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof z?new $(t):new $(z.from(t,e))}set texture(t){t||(t=z.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_updateBounds(){so(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:n,height:r}=e.orig;s.maxX=-t._x*n,s.minX=s.maxX+n,s.maxY=-t._y*r,s.minY=s.maxY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const Bo=new Et;function _r(i,t,e){const s=Bo;i.measurable=!0,pr(i,e,s),t.addBoundsMask(s),i.measurable=!1}function br(i,t,e){const s=xe.get();i.measurable=!0;const n=Ut.get().identity(),r=Sr(i,e,n);mr(i,s,r),i.measurable=!1,t.addBoundsMask(s),Ut.return(n),xe.return(s)}function Sr(i,t,e){return i?(i!==t&&(Sr(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(st("Mask bounds, renderable is not inside the root container"),e)}class vr{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof $),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){_r(this.mask,t,e)}addLocalBounds(t,e){br(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof $}}vr.extension=G.MaskEffect;class Cr{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"}}Cr.extension=G.MaskEffect;class Tr{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){_r(this.mask,t,e)}addLocalBounds(t,e){br(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof tt}}Tr.extension=G.MaskEffect;const Io={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let wn=Io;const Q={get(){return wn},set(i){wn=i}};class Ar extends Nt{constructor(t){t.resource||(t.resource=Q.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const n=super.resize(t,e,s);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Ar.extension=G.TextureSource;class Ce extends Nt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=Q.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0,t.resource.width,t.resource.height),t.resource=e,st("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}Ce.extension=G.TextureSource;var yi=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(yi||{});class Hi{constructor(t,e=null,s=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Mr=class mt{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 Hi(null,null,1/0),this.deltaMS=1/mt.targetFPMS,this.elapsedMS=1/mt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=yi.NORMAL){return this._addListener(new Hi(t,e,s))}addOnce(t,e,s=yi.NORMAL){return this._addListener(new Hi(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const r=t-this._lastFrame|0;if(r<this._minElapsedMS)return;this._lastFrame=t-r%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*mt.targetFPMS;const s=this._head;let n=s.next;for(;n;)n=n.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),s=Math.min(Math.max(0,e)/1e3,mt.targetFPMS);this._maxElapsedMS=1/s}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!mt._shared){const t=mt._shared=new mt;t.autoStart=!0,t._protected=!0}return mt._shared}static get system(){if(!mt._system){const t=mt._system=new mt;t.autoStart=!0,t._protected=!0}return mt._system}};Mr.targetFPMS=.06;let It=Mr,$i;async function Pr(){return $i??($i=(async()=>{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(s),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),$i}const Ci=class Gr extends Nt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Gr.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=It.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 Pr(),this._load=new Promise((s,n)=>{this.isValid?s(this):(this._resolve=s,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(It.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||(It.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(It.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ci.extension=G.TextureSource;Ci.defaultOptions={...Nt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ci.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let fi=Ci;const vt=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class Eo{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||st(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=vt(t);let n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){n=l.getCacheableAssets(s,e);break}}const r=new Map(Object.entries(n||{}));n||s.forEach(h=>{r.set(h,e)});const a=[...r.keys()],o={cacheKeys:a,keys:s};s.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const l=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&st("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){st(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const q=new Eo,ds=[];dt.handleByList(G.TextureSource,ds);function kr(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n<ds.length;n++){const r=ds[n];if(r.test(e))return new r(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function Ro(i={},t=!1){const e=i&&i.resource,s=e?i.resource:i,n=e?i:{resource:i};if(!t&&q.has(s))return q.get(s);const r=new z({source:kr(n)});return r.on("destroy",()=>{q.has(s)&&q.remove(s)}),t||q.set(s,r),r}function Fo(i,t=!1){return typeof i=="string"?q.get(i):i instanceof Nt?new z({source:i}):Ro(i,t)}z.from=Fo;Nt.from=kr;dt.add(vr,Cr,Tr,fi,Ce,Ar,ks);var Xt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Xt||{});function St(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Ie(i){return i.split("?")[0].split("#")[0]}function Lo(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Do(i,t,e){return i.replace(new RegExp(Lo(t),"g"),e)}function zo(i,t){let e="",s=0,n=-1,r=0,a=-1;for(let o=0;o<=i.length;++o){if(o<i.length)a=i.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(n===o-1||r===1))if(n!==o-1&&r===2){if(e.length<2||s!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),n=o,r=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=o,r=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,o)}`:e=i.slice(n+1,o),s=o-n-1;n=o,r=0}else a===46&&r!==-1?++r:r=-1}return e}const xt={toPosix(i){return Do(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){St(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(St(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Ie(this.toPosix(t??Q.get().getBaseUrl())),n=Ie(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?xt.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(St(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=zo(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return St(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e<i.length;++e){const s=i[e];if(St(s),s.length>0)if(t===void 0)t=s;else{const n=i[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(St(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const r=this.getProtocol(i),a=i;i=i.slice(r.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!n){s=o;break}}else n=!1;return s===-1?e?"/":this.isUrl(a)?r+i:r:e&&s===1?"//":r+i.slice(0,s)},rootname(i){St(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){St(i),t&&St(t),i=Ie(this.toPosix(i));let e=0,s=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let a=t.length-1,o=-1;for(r=i.length-1;r>=0;--r){const h=i.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else o===-1&&(n=!1,o=r+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(s=r):(a=-1,s=o))}return e===s?s=o:s===-1&&(s=i.length),i.slice(e,s)}for(r=i.length-1;r>=0;--r)if(i.charCodeAt(r)===47){if(!n){e=r+1;break}}else s===-1&&(n=!1,s=r+1);return s===-1?"":i.slice(e,s)},extname(i){St(i),i=Ie(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,r=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}s===-1&&(n=!1,s=a+1),o===46?t===-1?t=a:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){St(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Ie(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let n;t.root=this.rootname(i),s||this.hasProtocol(i)?n=1:n=0;let r=-1,a=0,o=-1,h=!0,l=i.length-1,c=0;for(;l>=n;--l){if(e=i.charCodeAt(l),e===47){if(!h){a=l+1;break}continue}o===-1&&(h=!1,o=l+1),e===46?r===-1?r=l:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||o===-1||c===0||c===1&&r===o-1&&r===a+1?o!==-1&&(a===0&&s?t.base=t.name=i.slice(1,o):t.base=t.name=i.slice(a,o)):(a===0&&s?(t.name=i.slice(1,r),t.base=i.slice(1,o)):(t.name=i.slice(a,r),t.base=i.slice(a,o)),t.ext=i.slice(r,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Br(i,t,e,s,n){const r=t[e];for(let a=0;a<r.length;a++){const o=r[a];e<t.length-1?Br(i.replace(s[e],o),t,e+1,s,n):n.push(i.replace(s[e],o))}}function Uo(i){const t=/\{(.*?)\}/g,e=i.match(t),s=[];if(e){const n=[];e.forEach(r=>{const a=r.substring(1,r.length-1).split(",");n.push(a)}),Br(i,n,0,e,s)}else s.push(i);return s}const wi=i=>!Array.isArray(i);class Te{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return vt(e||s,r=>typeof r=="string"?r:Array.isArray(r)?r.map(a=>(a==null?void 0:a.src)??a):r!=null&&r.src?r.src:r,!0)}addManifest(t){this._manifest&&st("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,a])=>typeof a=="string"||Array.isArray(a)?{alias:r,src:a}:{alias:r,...a})),n.forEach(r=>{const a=r.src,o=r.alias;let h;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);s.push(l),h=[o,l]}else{const l=o.map(c=>this._createBundleAssetId(t,c));s.push(...l),h=[...o,...l]}this.add({...r,alias:h,src:a})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=r=>{this.hasKey(r)&&st(`[Resolver] already has key: ${r} overwriting`)},vt(e).forEach(r=>{const{src:a}=r;let{data:o,format:h,loadParser:l}=r;const c=vt(a).map(g=>typeof g=="string"?Uo(g):Array.isArray(g)?g:[g]),d=this.getAlias(r);Array.isArray(d)?d.forEach(s):s(d);const f=[];c.forEach(g=>{g.forEach(m=>{let y={};if(typeof m!="object"){y.src=m;for(let x=0;x<this._parsers.length;x++){const w=this._parsers[x];if(w.test(m)){y=w.parse(m);break}}}else o=m.data??o,h=m.format??h,l=m.loadParser??l,y={...y,...m};if(!d)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this._buildResolvedAsset(y,{aliases:d,data:o,format:h,loadParser:l}),f.push(y)})}),d.forEach(g=>{this._assetMap[g]=f})})}resolveBundle(t){const e=wi(t);t=vt(t);const s={};return t.forEach(n=>{const r=this._bundles[n];if(r){const a=this.resolve(r),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(n,h)]=l}s[n]=o}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const n in e)s[n]=e[n].src;return s}return e.src}resolve(t){const e=wi(t);t=vt(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const a=this._getPreferredOrder(r);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const l=r.filter(c=>c[o]?c[o]===h:!1);l.length&&(r=l)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});s[n]=this._resolverHash[n]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const s=t[0],n=this._preferredOrder.find(r=>r.params.format.includes(s.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:s,data:n,loadParser:r,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=xt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.format=a??t.format??No(t.src),t}}Te.RETINA_PREFIX=/@([0-9\.]+)x/;function No(i){return i.split(".").pop().split("?").shift().split("#").shift()}const us=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},Ir=class ze{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof z?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const s=parseFloat(e.meta.scale);s?(this.resolution=s,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ze.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=ze.BATCH_SIZE;for(;e-t<s&&e<this._frameKeys.length;){const n=this._frameKeys[e],r=this._frames[n],a=r.frame;if(a){let o=null,h=null;const l=r.trimmed!==!1&&r.sourceSize?r.sourceSize:r.frame,c=new I(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);r.rotated?o=new I(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):o=new I(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),r.trimmed!==!1&&r.spriteSourceSize&&(h=new I(Math.floor(r.spriteSourceSize.x)/this.resolution,Math.floor(r.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[n]=new z({source:this.textureSource,frame:o,orig:c,trim:h,rotate:r.rotated?2:0,defaultAnchor:r.anchor,defaultBorders:r.borders,label:n.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let s=0;s<t[e].length;s++){const n=t[e][s];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*ze.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ze.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const s in this.textures)this.textures[s].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Ir.BATCH_SIZE=1e3;let _i=Ir;const Oo=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Er(i,t,e){const s={};if(i.forEach(n=>{s[n]=t}),Object.keys(t.textures).forEach(n=>{s[n]=t.textures[n]}),!e){const n=xt.dirname(i[0]);t.linkedSheets.forEach((r,a)=>{const o=Er([`${n}/${t.data.meta.related_multi_packs[a]}`],r,!0);Object.assign(s,o)})}return s}const Wo={extension:G.Asset,cache:{test:i=>i instanceof _i,getCacheableAssets:(i,t)=>Er(i,t,!1)},resolver:{extension:{type:G.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&Oo.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=Te.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:G.LoadParser,priority:Xt.Normal,name:"spritesheetLoader"},async testParse(i,t){return xt.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var l,c;const{texture:s,imageFilename:n}=(t==null?void 0:t.data)??{};let r=xt.dirname(t.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let a;if(s instanceof z)a=s;else{const d=us(r+(n??i.meta.image),t.src);a=(await e.load([d]))[d]}const o=new _i(a.source,i);await o.parse();const h=(l=i==null?void 0:i.meta)==null?void 0:l.related_multi_packs;if(Array.isArray(h)){const d=[];for(const g of h){if(typeof g!="string")continue;let m=r+g;(c=t.data)!=null&&c.ignoreMultiPack||(m=us(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);o.linkedSheets=f,f.forEach(g=>{g.linkedSheets=[o].concat(o.linkedSheets.filter(m=>m!==g))})}return o},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};dt.add(Wo);const Vi=Object.create(null),_n=Object.create(null);function Is(i,t){let e=_n[i];return e===void 0&&(Vi[t]===void 0&&(Vi[t]=1),_n[i]=e=Vi[t]++),e}let he;function Rr(){return(!he||he!=null&&he.isContextLost())&&(he=Q.get().createCanvas().getContext("webgl",{})),he}let ri;function Ho(){if(!ri){ri="mediump";const i=Rr();i&&i.getShaderPrecisionFormat&&(ri=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return ri}function $o(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),`
#ifdef GL_ES // This checks if it is WebGL1
#define in varying
#define finalColor gl_FragColor
#define texture texture2D
#endif
${i}
`):`
#ifdef GL_ES // This checks if it is WebGL1
#define in attribute
#define out varying
#endif
${i}
`}function Vo(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&s!=="highp"&&(n="mediump"),`precision ${n} float;
${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function Yo(i,t){return t?`#version 300 es
${i}`:i}const Xo={},jo={};function qo(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Xo:jo;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`}
${i}`}function Ko(i,t){return t?i.replace("#version 300 es",""):i}const Yi={stripVersion:Ko,ensurePrecision:Vo,addProgramDefines:$o,setProgramName:qo,insertVersion:Yo},Xi=Object.create(null),Fr=class fs{constructor(t){t={...fs.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ho()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(Yi).forEach(a=>{const o=s[a];n=Yi[a](n,o,!0),r=Yi[a](r,o,!1)}),this.fragment=n,this.vertex=r,this._key=Is(`${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 Xi[e]||(Xi[e]=new fs(t)),Xi[e]}};Fr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Lr=Fr;const bn={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 Zo(i){return bn[i]??bn.float32}const Qo={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function Jo({source:i,entryPoint:t}){const e={},s=i.indexOf(`fn ${t}`);if(s!==-1){const n=i.indexOf("->",s);if(n!==-1){const r=i.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(r))!==null;){const h=Qo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Zo(h).stride,offset:0,instance:!1,start:0}}}}return e}function ji(i){var d,f;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=i.match(t))==null?void 0:d.map(g=>({group:parseInt(g.match(e)[1],10),binding:parseInt(g.match(s)[1],10),name:g.match(n)[2],isUniform:g.match(n)[1]==="<uniform>",type:g.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=((f=i.match(a))==null?void 0:f.map(g=>{const m=g.match(h)[1],y=g.match(o).reduce((x,w)=>{const[_,b]=w.split(":");return x[_.trim()]=b.trim(),x},{});return y?{name:m,members:y}:null}).filter(({name:g})=>l.some(m=>m.type===g)))??[];return{groups:l,structs:c}}var Ue=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Ue||{});function th({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]=[]),s.isUniform?t[s.group].push({binding:s.binding,visibility:Ue.VERTEX|Ue.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:Ue.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"&&t[s.group].push({binding:s.binding,visibility:Ue.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function eh({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]={}),t[s.group][s.name]=s.binding}return t}function ih(i,t){const e=new Set,s=new Set,n=[...i.structs,...t.structs].filter(a=>e.has(a.name)?!1:(e.add(a.name),!0)),r=[...i.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return s.has(o)?!1:(s.add(o),!0)});return{structs:n,groups:r}}const qi=Object.create(null);class Ti{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:r,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=s,e.source===s.source){const l=ji(e.source);this.structsAndGroups=l}else{const l=ji(s.source),c=ji(e.source);this.structsAndGroups=ih(l,c)}this.layout=n??eh(this.structsAndGroups),this.gpuLayout=r??th(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Is(s,"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 qi[e]||(qi[e]=new Ti(t)),qi[e]}}const Dr=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>"],sh=Dr.reduce((i,t)=>(i[t]=!0,i),{});function nh(i,t){switch(i){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const zr=class Ur{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={...Ur.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!sh[r.type])throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${Dr.join(", ")}`);r.value??(r.value=nh(r.type,r.size)),s[n]=r.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Is(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};zr.defaultOptions={ubo:!1,isStatic:!1};let Nr=zr;class pi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const n=t[s];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var n,r;const s=this.resources[e];t!==s&&(s&&((n=t.off)==null||n.call(t,"change",this.onResourceChange,this)),(r=t.on)==null||r.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var e;const t=this.resources;for(const s in t){const n=t[s];(e=n.off)==null||e.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}var ps=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(ps||{});class Es extends gt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:n,resources:r,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=s,a===void 0&&(a=0,e&&(a|=ps.WEBGPU),s&&(a|=ps.WEBGL)),this.compatibleRenderers=a;const h={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const l in o)for(const c in o[l]){const d=o[l][c];h[d]={group:l,binding:c,name:d}}else if(e&&n&&!o){const l=e.structsAndGroups.groups;o={},l.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,h[c.name]=c})}else if(r){n={},o={},e&&e.structsAndGroups.groups.forEach(d=>{o[d.group]=o[d.group]||{},o[d.group][d.binding]=d.name,h[d.name]=d});let l=0;for(const c in r)h[c]||(n[99]||(n[99]=new pi,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:l,name:c},o[99]=o[99]||{},o[99][l]=c,l++);for(const c in r){const d=c;let f=r[c];!f.source&&!f._resourceType&&(f=new Nr(f));const g=h[d];g&&(n[g.group]||(n[g.group]=new pi,this._ownedBindGroups.push(n[g.group])),n[g.group].setResource(f,g.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[s]||(r[s]=t),this.groups[e]||(this.groups[e]=new pi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const r=e[n];Object.defineProperty(s,r.name,{get(){return t[r.group].getResource(r.binding)},set(a){t[r.group].setResource(a,r.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:s,...n}=t;let r,a;return e&&(r=Ti.from(e)),s&&(a=Lr.from(s)),new Es({gpuProgram:r,glProgram:a,...n})}}const gs=[];dt.handleByNamedList(G.Environment,gs);async function rh(i){if(!i)for(let t=0;t<gs.length;t++){const e=gs[t];if(e.value.test()){await e.value.load();return}}}let Ee;function ah(){if(typeof Ee=="boolean")return Ee;try{Ee=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Ee=!1}return Ee}var Rs={exports:{}};Rs.exports=Ai;Rs.exports.default=Ai;function Ai(i,t,e){e=e||2;var s=t&&t.length,n=s?t[0]*e:i.length,r=Or(i,0,n,e,!0),a=[];if(!r||r.next===r.prev)return a;var o,h,l,c,d,f,g;if(s&&(r=dh(i,t,r,e)),i.length>80*e){o=l=i[0],h=c=i[1];for(var m=e;m<n;m+=e)d=i[m],f=i[m+1],d<o&&(o=d),f<h&&(h=f),d>l&&(l=d),f>c&&(c=f);g=Math.max(l-o,c-h),g=g!==0?32767/g:0}return $e(r,a,e,o,h,g,0),a}function Or(i,t,e,s,n){var r,a;if(n===ys(i,t,e,s)>0)for(r=t;r<e;r+=s)a=Sn(r,i[r],i[r+1],a);else for(r=e-s;r>=t;r-=s)a=Sn(r,i[r],i[r+1],a);return a&&Mi(a,a.next)&&(Ye(a),a=a.next),a}function ae(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Mi(e,e.next)||K(e.prev,e,e.next)===0)){if(Ye(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function $e(i,t,e,s,n,r,a){if(i){!a&&r&&mh(i,s,n,r);for(var o=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,r?hh(i,s,n,r):oh(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),Ye(i),i=l.next,o=l.next;continue}if(i=l,i===o){a?a===1?(i=lh(ae(i),t,e),$e(i,t,e,s,n,r,2)):a===2&&ch(i,t,e,s,n,r):$e(ae(i),t,e,s,n,r,1);break}}}}function oh(i){var t=i.prev,e=i,s=i.next;if(K(t,e,s)>=0)return!1;for(var n=t.x,r=e.x,a=s.x,o=t.y,h=e.y,l=s.y,c=n<r?n<a?n:a:r<a?r:a,d=o<h?o<l?o:l:h<l?h:l,f=n>r?n>a?n:a:r>a?r:a,g=o>h?o>l?o:l:h>l?h:l,m=s.next;m!==t;){if(m.x>=c&&m.x<=f&&m.y>=d&&m.y<=g&&ue(n,o,r,h,a,l,m.x,m.y)&&K(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function hh(i,t,e,s){var n=i.prev,r=i,a=i.next;if(K(n,r,a)>=0)return!1;for(var o=n.x,h=r.x,l=a.x,c=n.y,d=r.y,f=a.y,g=o<h?o<l?o:l:h<l?h:l,m=c<d?c<f?c:f:d<f?d:f,y=o>h?o>l?o:l:h>l?h:l,x=c>d?c>f?c:f:d>f?d:f,w=ms(g,m,t,e,s),_=ms(y,x,t,e,s),b=i.prevZ,S=i.nextZ;b&&b.z>=w&&S&&S.z<=_;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&K(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&K(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=w;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&K(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=_;){if(S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&K(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function lh(i,t,e){var s=i;do{var n=s.prev,r=s.next.next;!Mi(n,r)&&Wr(n,s,s.next,r)&&Ve(n,r)&&Ve(r,n)&&(t.push(n.i/e|0),t.push(s.i/e|0),t.push(r.i/e|0),Ye(s),Ye(s.next),s=i=r),s=s.next}while(s!==i);return ae(s)}function ch(i,t,e,s,n,r){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&wh(a,o)){var h=Hr(a,o);a=ae(a,a.next),h=ae(h,h.next),$e(a,t,e,s,n,r,0),$e(h,t,e,s,n,r,0);return}o=o.next}a=a.next}while(a!==i)}function dh(i,t,e,s){var n=[],r,a,o,h,l;for(r=0,a=t.length;r<a;r++)o=t[r]*s,h=r<a-1?t[r+1]*s:i.length,l=Or(i,o,h,s,!1),l===l.next&&(l.steiner=!0),n.push(yh(l));for(n.sort(uh),r=0;r<n.length;r++)e=fh(n[r],e);return e}function uh(i,t){return i.x-t.x}function fh(i,t){var e=ph(i,t);if(!e)return t;var s=Hr(e,i);return ae(s,s.next),ae(e,e.next)}function ph(i,t){var e=t,s=i.x,n=i.y,r=-1/0,a;do{if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){var o=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=s&&o>r&&(r=o,a=e.x<e.next.x?e:e.next,o===s))return a}e=e.next}while(e!==t);if(!a)return null;var h=a,l=a.x,c=a.y,d=1/0,f;e=a;do s>=e.x&&e.x>=l&&s!==e.x&&ue(n<c?s:r,n,l,c,n<c?r:s,n,e.x,e.y)&&(f=Math.abs(n-e.y)/(s-e.x),Ve(e,i)&&(f<d||f===d&&(e.x>a.x||e.x===a.x&&gh(a,e)))&&(a=e,d=f)),e=e.next;while(e!==h);return a}function gh(i,t){return K(i.prev,i,t.prev)<0&&K(t.next,i,i.next)<0}function mh(i,t,e,s){var n=i;do n.z===0&&(n.z=ms(n.x,n.y,t,e,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,xh(n)}function xh(i){var t,e,s,n,r,a,o,h,l=1;do{for(e=i,i=null,r=null,a=0;e;){for(a++,s=e,o=0,t=0;t<l&&(o++,s=s.nextZ,!!s);t++);for(h=l;o>0||h>0&&s;)o!==0&&(h===0||!s||e.z<=s.z)?(n=e,e=e.nextZ,o--):(n=s,s=s.nextZ,h--),r?r.nextZ=n:i=n,n.prevZ=r,r=n;e=s}r.nextZ=null,l*=2}while(a>1);return i}function ms(i,t,e,s,n){return i=(i-e)*n|0,t=(t-s)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function yh(i){var t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function ue(i,t,e,s,n,r,a,o){return(n-a)*(t-o)>=(i-a)*(r-o)&&(i-a)*(s-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(n-a)*(s-o)}function wh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!_h(i,t)&&(Ve(i,t)&&Ve(t,i)&&bh(i,t)&&(K(i.prev,i,t.prev)||K(i,t.prev,t))||Mi(i,t)&&K(i.prev,i,i.next)>0&&K(t.prev,t,t.next)>0)}function K(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Mi(i,t){return i.x===t.x&&i.y===t.y}function Wr(i,t,e,s){var n=oi(K(i,t,e)),r=oi(K(i,t,s)),a=oi(K(e,s,i)),o=oi(K(e,s,t));return!!(n!==r&&a!==o||n===0&&ai(i,e,t)||r===0&&ai(i,s,t)||a===0&&ai(e,i,s)||o===0&&ai(e,t,s))}function ai(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function oi(i){return i>0?1:i<0?-1:0}function _h(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Wr(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Ve(i,t){return K(i.prev,i,i.next)<0?K(i,t,i.next)>=0&&K(i,i.prev,t)>=0:K(i,t,i.prev)<0||K(i,i.next,t)<0}function bh(i,t){var e=i,s=!1,n=(i.x+t.x)/2,r=(i.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Hr(i,t){var e=new xs(i.i,i.x,i.y),s=new xs(t.i,t.x,t.y),n=i.next,r=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,r.next=s,s.prev=r,s}function Sn(i,t,e,s){var n=new xs(i,t,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Ye(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function xs(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ai.deviation=function(i,t,e,s){var n=t&&t.length,r=n?t[0]*e:i.length,a=Math.abs(ys(i,0,r,e));if(n)for(var o=0,h=t.length;o<h;o++){var l=t[o]*e,c=o<h-1?t[o+1]*e:i.length;a-=Math.abs(ys(i,l,c,e))}var d=0;for(o=0;o<s.length;o+=3){var f=s[o]*e,g=s[o+1]*e,m=s[o+2]*e;d+=Math.abs((i[f]-i[m])*(i[g+1]-i[f+1])-(i[f]-i[g])*(i[m+1]-i[f+1]))}return a===0&&d===0?0:Math.abs((d-a)/a)};function ys(i,t,e,s){for(var n=0,r=t,a=e-s;r<e;r+=s)n+=(i[a]-i[r])*(i[r+1]+i[a+1]),a=r;return n}Ai.flatten=function(i){for(var t=i[0][0].length,e={vertices:[],holes:[],dimensions:t},s=0,n=0;n<i.length;n++){for(var r=0;r<i[n].length;r++)for(var a=0;a<t;a++)e.vertices.push(i[n][r][a]);n>0&&(s+=i[n-1].length,e.holes.push(s))}return e};var Sh=Rs.exports;const vh=Gs(Sh);var $r=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))($r||{});class Ch{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,r,a,o,h){const{name:l,items:c}=this;for(let d=0,f=c.length;d<f;d++)c[d][l](t,e,s,n,r,a,o,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const Th=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],Vr=class Yr extends gt{constructor(t){super(),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...Th,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await rh(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash)t={...this._systemsHash[s].constructor.defaultOptions,...t};t={...Yr.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let s=0;s<this.runners.init.items.length;s++)await this.runners.init.items[s].init(t);this._initOptions=t}render(t,e){let s=t;if(s instanceof tt&&(s={container:s},e&&(U(O,"passing a second argument is deprecated, please use render options instead"),s.target=e.renderTexture)),s.target||(s.target=this.view.renderTarget),s.target===this.view.renderTarget&&(this._lastObjectRendered=s.container,s.clearColor=this.background.colorRgba),s.clearColor){const n=Array.isArray(s.clearColor)&&s.clearColor.length===4;s.clearColor=n?s.clearColor:Y.shared.setValue(s.clearColor).toArray()}s.transform||(s.container.updateLocalTransform(),s.transform=s.container.localTransform),this.runners.prerender.emit(s),this.runners.renderStart.emit(s),this.runners.render.emit(s),this.runners.renderEnd.emit(s),this.runners.postrender.emit(s)}resize(t,e,s){const n=this.view.resolution;this.view.resize(t,e,s),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),s!==void 0&&s!==n&&this.runners.resolutionChange.emit(s)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=$r.ALL);const{clear:s,clearColor:n,target:r}=t;Y.shared.setValue(n??this.background.colorRgba),e.renderTarget.clear(r,s,Y.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Ch(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const n in this.runners)this.runners[n].add(s);return this}_addPipes(t,e){const s=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,a=n.name,o=s[a];this.renderPipes[a]=new r(this,o?new o:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ah())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Vr.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Xr=Vr,hi;function Ah(i){return hi!==void 0||(hi=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??Xr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Q.get().getWebGLRenderingContext())return!1;let n=Q.get().createCanvas().getContext("webgl",t);const r=!!((e=n==null?void 0:n.getContextAttributes())!=null&&e.stencil);if(n){const a=n.getExtension("WEBGL_lose_context");a&&a.loseContext()}return n=null,r}catch{return!1}})()),hi}let li;async function Mh(i={}){return li!==void 0||(li=await(async()=>{const t=Q.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),li}const vn=["webgl","webgpu","canvas"];async function Ph(i){let t=[];i.preference?(t.push(i.preference),vn.forEach(r=>{r!==i.preference&&t.push(r)})):t=vn.slice();let e,s={};for(let r=0;r<t.length;r++){const a=t[r];if(a==="webgpu"&&await Mh()){const{WebGPURenderer:o}=await mi(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-CNuCBG1t.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,s={...i,...i.webgpu};break}else if(a==="webgl"&&Ah(i.failIfMajorPerformanceCaveat??Xr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await mi(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-O3oCvy8A.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,s={...i,...i.webgl};break}else if(a==="canvas")throw s={...i},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(s),n}const jr="8.4.0";class qr{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,jr)}static destroy(){}}qr.extension=G.Application;class Gh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,jr)}destroy(){this._renderer=null}}Gh.extension={type:[G.WebGLSystem,G.WebGPUSystem],name:"initHook",priority:-10};const Kr=class ws{constructor(...t){this.stage=new tt,t[0]!==void 0&&U(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await Ph(t),ws._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return U(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 s=ws._plugins.slice(0);s.reverse(),s.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Kr._plugins=[];let Zr=Kr;dt.handleByList(G.Application,Zr._plugins);dt.add(qr);class Qr extends gt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return U(O,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return U(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return U(O,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return U(O,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return U(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 s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}const Jr=class _s{constructor(t,e,s,n){this.uid=nt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=s,this.y1=n}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Y.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=_s.defaultTextureSize,{gradientStops:e}=this,s=Q.get().createCanvas();s.width=t,s.height=t;const n=s.getContext("2d"),r=n.createLinearGradient(0,0,_s.defaultTextureSize,1);for(let y=0;y<e.length;y++){const x=e[y];r.addColorStop(x.offset,x.color)}n.fillStyle=r,n.fillRect(0,0,t,t),this.texture=new z({source:new Ce({resource:s,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:a,y0:o,x1:h,y1:l}=this,c=new H,d=h-a,f=l-o,g=Math.sqrt(d*d+f*f),m=Math.atan2(f,d);c.translate(-a,-o),c.scale(1/t,1/t),c.rotate(-m),c.scale(256/g,1),this.transform=c,this._styleKey=null}get styleKey(){if(this._styleKey)return this._styleKey;const t=this.gradientStops.map(n=>`${n.offset}-${n.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Jr.defaultTextureSize=256;let Xe=Jr;const Cn={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 Pi{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=Cn[e].addressModeU,t.source.style.addressModeV=Cn[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 kh=Ih,Ki={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Bh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Ih(i){var t=[];return i.replace(Bh,function(e,s,n){var r=s.toLowerCase();for(n=Rh(n),r=="m"&&n.length>2&&(t.push([s].concat(n.splice(0,2))),r="l",s=s=="m"?"l":"L");;){if(n.length==Ki[r])return n.unshift(s),t.push(n);if(n.length<Ki[r])throw new Error("malformed path data");t.push([s].concat(n.splice(0,Ki[r])))}}),t}var Eh=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function Rh(i){var t=i.match(Eh);return t?t.map(Number):[]}const Fh=Gs(kh);function Lh(i,t){const e=Fh(i),s=[];let n=null,r=0,a=0;for(let o=0;o<e.length;o++){const h=e[o],l=h[0],c=h;switch(l){case"M":r=c[1],a=c[2],t.moveTo(r,a);break;case"m":r+=c[1],a+=c[2],t.moveTo(r,a);break;case"H":r=c[1],t.lineTo(r,a);break;case"h":r+=c[1],t.lineTo(r,a);break;case"V":a=c[1],t.lineTo(r,a);break;case"v":a+=c[1],t.lineTo(r,a);break;case"L":r=c[1],a=c[2],t.lineTo(r,a);break;case"l":r+=c[1],a+=c[2],t.lineTo(r,a);break;case"C":r=c[5],a=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],r,a);break;case"c":t.bezierCurveTo(r+c[1],a+c[2],r+c[3],a+c[4],r+c[5],a+c[6]),r+=c[5],a+=c[6];break;case"S":r=c[3],a=c[4],t.bezierCurveToShort(c[1],c[2],r,a);break;case"s":t.bezierCurveToShort(r+c[1],a+c[2],r+c[3],a+c[4]),r+=c[3],a+=c[4];break;case"Q":r=c[3],a=c[4],t.quadraticCurveTo(c[1],c[2],r,a);break;case"q":t.quadraticCurveTo(r+c[1],a+c[2],r+c[3],a+c[4]),r+=c[3],a+=c[4];break;case"T":r=c[1],a=c[2],t.quadraticCurveToShort(r,a);break;case"t":r+=c[1],a+=c[2],t.quadraticCurveToShort(r,a);break;case"A":r=c[6],a=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,a);break;case"a":r+=c[6],a+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,a);break;case"Z":case"z":t.closePath(),s.length>0&&(n=s.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:st(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:a},s.push(n))}return t}class Fs{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Fs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const n=this.x-t,r=this.y-e,a=this.radius,o=s/2,h=Math.sqrt(n*n+r*r);return h<a+o&&h>a-o}getBounds(t){return t=t||new I,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 Ls{constructor(t=0,e=0,s=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=n}clone(){return new Ls(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return s*=s,n*=n,s+n<=1}strokeContains(t,e,s){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const a=s/2,o=n-a,h=r-a,l=n+a,c=r+a,d=t-this.x,f=e-this.y,g=d*d/(o*o)+f*f/(h*h),m=d*d/(l*l)+f*f/(c*c);return g>1&&m<=1}getBounds(t){return t=t||new I,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 Dh(i,t,e,s,n,r){const a=i-e,o=t-s,h=n-e,l=r-s,c=a*h+o*l,d=h*h+l*l;let f=-1;d!==0&&(f=c/d);let g,m;f<0?(g=e,m=s):f>1?(g=n,m=r):(g=e+f*h,m=s+f*l);const y=i-g,x=t-m;return y*y+x*x}class We{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let n=0,r=e.length;n<r;n++)s.push(e[n].x,e[n].y);e=s}this.points=e,this.closePath=!0}clone(){const t=this.points.slice(),e=new We(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const n=this.points.length/2;for(let r=0,a=n-1;r<n;a=r++){const o=this.points[r*2],h=this.points[r*2+1],l=this.points[a*2],c=this.points[a*2+1];h>e!=c>e&&t<(l-o)*((e-h)/(c-h))+o&&(s=!s)}return s}strokeContains(t,e,s){const n=s/2,r=n*n,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;h<o;h+=2){const l=a[h],c=a[h+1],d=a[(h+2)%a.length],f=a[(h+3)%a.length];if(Dh(t,e,l,c,d,f)<=r)return!0}return!1}getBounds(t){t=t||new I;const e=this.points;let s=1/0,n=-1/0,r=1/0,a=-1/0;for(let o=0,h=e.length;o<h;o+=2){const l=e[o],c=e[o+1];s=l<s?l:s,n=l>n?l:n,r=c<r?c:r,a=c>a?c:a}return t.x=s,t.width=n-s,t.y=r,t.height=a-r,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const ci=(i,t,e,s,n,r)=>{const a=i-e,o=t-s,h=Math.sqrt(a*a+o*o);return h>=n-r&&h<=n+r};class Ds{constructor(t=0,e=0,s=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=r}getBounds(t){return t=t||new I,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Ds(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let n=t-(this.x+s),r=e-(this.y+s);const a=s*s;if(n*n+r*r<=a||(n=t-(this.x+this.width-s),n*n+r*r<=a)||(r=e-(this.y+this.height-s),n*n+r*r<=a)||(n=t-(this.x+s),n*n+r*r<=a))return!0}return!1}strokeContains(t,e,s){const{x:n,y:r,width:a,height:o,radius:h}=this,l=s/2,c=n+h,d=r+h,f=a-h*2,g=o-h*2,m=n+a,y=r+o;return(t>=n-l&&t<=n+l||t>=m-l&&t<=m+l)&&e>=d&&e<=d+g||(e>=r-l&&e<=r+l||e>=y-l&&e<=y+l)&&t>=c&&t<=c+f?!0:t<c&&e<d&&ci(t,e,c,d,h,l)||t>m-h&&e<d&&ci(t,e,m-h,d,h,l)||t>m-h&&e>y-h&&ci(t,e,m-h,y-h,h,l)||t<c&&e>y-h&&ci(t,e,c,y-h,h,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const zh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function Uh(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=`
else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function Nh(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const s=zh.replace(/%forloop%/gi,Uh(i));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}}finally{t.deleteShader(e)}return i}let le=null;function ta(){var t;if(le)return le;const i=Rr();return le=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),le=Nh(le,i),(t=i.getExtension("WEBGL_lose_context"))==null||t.loseContext(),le}const ea={};function Oh(i,t){let e=2166136261;for(let s=0;s<t;s++)e^=i[s].uid,e=Math.imul(e,16777619),e>>>=0;return ea[e]||Wh(i,t,e)}let Zi=0;function Wh(i,t,e){const s={};let n=0;Zi||(Zi=ta());for(let a=0;a<Zi;a++){const o=a<t?i[a]:z.EMPTY.source;s[n++]=o.source,s[n++]=o.style}const r=new pi(s);return ea[e]=r,r}class Tn{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function An(i,t){const e=i.byteLength/8|0,s=new Float64Array(i,0,e);new Float64Array(t,0,e).set(s);const r=i.byteLength-e*8;if(r>0){const a=new Uint8Array(i,e*8,r);new Uint8Array(t,e*8,r).set(a)}}const Hh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var $h=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",i[i.NONE=4]="NONE",i))($h||{});function Mn(i,t){return t.alphaMode==="no-premultiply-alpha"&&Hh[i]||i}class Vh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class Yh{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Vh,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const ia=[];let bs=0;function Pn(){return bs>0?ia[--bs]:new Yh}function Gn(i){ia[bs++]=i}let Re=0;const sa=class gi{constructor(t={}){this.uid=nt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],gi.defaultOptions.maxTextures=gi.defaultOptions.maxTextures??ta(),t={...gi.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new Tn(s*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Gn(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const s=t._batch.textures.ids[e._source.uid];return!s&&s!==0?!1:(t._textureId=s,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let s=Pn(),n=s.textures;n.clear();const r=e[this.elementStart];let a=Mn(r.blendMode,r.texture._source);this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const o=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,f="startBatch";const g=this.maxTextures;for(let m=this.elementStart;m<this.elementSize;++m){const y=e[m];e[m]=null;const w=y.texture._source,_=Mn(y.blendMode,w),b=a!==_;if(w._batchTick===Re&&!b){y._textureId=w._textureBindLocation,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)),y._batch=s;continue}w._batchTick=Re,(n.count>=g||b)&&(this._finishBatch(s,d,c-d,n,a,t,f),f="renderBatch",d=c,a=_,s=Pn(),n=s.textures,n.clear(),++Re),y._textureId=w._textureBindLocation=n.count,n.ids[w.uid]=n.count,n.textures[n.count++]=w,y._batch=s,c+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,o,h,y._attributeStart,y._textureId),this.packQuadIndex(l,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,o,h,y._attributeStart,y._textureId),this.packIndex(y,l,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,d,c-d,n,a,t,f),d=c,++Re),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,s,n,r,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=n,t.blendMode=r,t.start=e,t.size=s,++Re,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new Tn(e);An(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const n=s>65535?new Uint32Array(s):new Uint16Array(s);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r<e.length;r++)n[r]=e[r];else An(e.buffer,n.buffer);this.indexBuffer=n}packQuadIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}packIndex(t,e,s,n){const r=t.indices,a=t.indexSize,o=t.indexOffset,h=t.attributeOffset;for(let l=0;l<a;l++)e[s++]=n+r[l+o]-h}destroy(){for(let t=0;t<this.batches.length;t++)Gn(this.batches[t]);this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t]._batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}};sa.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Xh=sa;var it=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(it||{});class Vt extends gt{constructor(t){let{data:e,size:s}=t;const{usage:n,label:r,shrinkToFit:a}=t;super(),this.uid=nt("buffer"),this._resourceType="buffer",this._resourceId=nt("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=s??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:s,usage:n,mappedAtCreation:o,label:r},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&it.STATIC)}set static(t){t?this.descriptor.usage|=it.STATIC:this.descriptor.usage&=~it.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const n=this._data;if(this._data=t,n.length!==t.length){!this.shrinkToFit&&t.byteLength<n.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=nt("resource"),this.emit("change",this));return}s&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function na(i,t){if(!(i instanceof Vt)){let e=t?it.INDEX:it.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=it.INDEX|it.COPY_DST):(i=new Float32Array(i),e=it.VERTEX|it.COPY_DST)),i=new Vt({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function jh(i,t,e){const s=i.getAttribute(t);if(!s)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const n=s.buffer.data;let r=1/0,a=1/0,o=-1/0,h=-1/0;const l=n.BYTES_PER_ELEMENT,c=(s.offset||0)/l,d=(s.stride||2*4)/l;for(let f=c;f<n.length;f+=d){const g=n[f],m=n[f+1];g>o&&(o=g),m>h&&(h=m),g<r&&(r=g),m<a&&(a=m)}return e.minX=r,e.minY=a,e.maxX=o,e.maxY=h,e}function qh(i){return(i instanceof Vt||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=na(i.buffer,!1),i}class ra extends gt{constructor(t){const{attributes:e,indexBuffer:s,topology:n}=t;super(),this.uid=nt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Et,this._boundsDirty=!0,this.attributes=e,this.buffers=[],this.instanceCount=t.instanceCount||1;for(const r in e){const a=e[r]=qh(e[r]);this.buffers.indexOf(a.buffer)===-1&&(this.buffers.push(a.buffer),a.buffer.on("update",this.onBufferUpdate,this),a.buffer.on("change",this.onBufferUpdate,this))}s&&(this.indexBuffer=na(s,!0),this.buffers.push(this.indexBuffer)),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,jh(this,"aPosition",this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Kh=new Float32Array(1),Zh=new Uint32Array(1);class Qh extends ra{constructor(){const e=new Vt({data:Kh,label:"attribute-batch-buffer",usage:it.VERTEX|it.COPY_DST,shrinkToFit:!1}),s=new Vt({data:Zh,label:"index-batch-buffer",usage:it.INDEX|it.COPY_DST,shrinkToFit:!1}),n=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:5*4}},indexBuffer:s})}}function kn(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),r=t[n];if(r){let a=i[s];s==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(a)}else st(`${s} placement hook does not exist in shader`)}}const Jh=/\{\{(.*?)\}\}/g;function Bn(i){var s;const t={};return(((s=i.match(Jh))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function In(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function En(i,t,e=!1){const s=[];In(t,s),i.forEach(o=>{o.header&&In(o.header,s)});const n=s;e&&n.sort();const r=n.map((o,h)=>` @location(${h}) ${o},`).join(`
`);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",`
${r}
`),a}function Rn(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function tl(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function el(i){const t=/@.*?\s+/g;return i.replace(t,"")}function il(i,t){const e=[];Rn(t,e),i.forEach(h=>{h.header&&Rn(h.header,e)});let s=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`,
`),r=e.sort().map(h=>` var ${el(h)};`).join(`
`),a=`return VSOutput(
${e.sort().map(h=>` ${tl(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 Fn(i,t){let e=i;for(const s in t){const n=t[s];n.join(`
`).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
${n.join(`
`)}
//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const $t=Object.create(null),Qi=new Map;let sl=0;function nl({template:i,bits:t}){const e=aa(i,t);if($t[e])return $t[e];const{vertex:s,fragment:n}=al(i,t);return $t[e]=oa(s,n,t),$t[e]}function rl({template:i,bits:t}){const e=aa(i,t);return $t[e]||($t[e]=oa(i.vertex,i.fragment,t)),$t[e]}function al(i,t){const e=t.map(a=>a.vertex).filter(a=>!!a),s=t.map(a=>a.fragment).filter(a=>!!a);let n=En(e,i.vertex,!0);n=il(e,n);const r=En(s,i.fragment,!0);return{vertex:n,fragment:r}}function aa(i,t){return t.map(e=>(Qi.has(e)||Qi.set(e,sl++),Qi.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function oa(i,t,e){const s=Bn(i),n=Bn(t);return e.forEach(r=>{kn(r.vertex,s,r.name),kn(r.fragment,n,r.name)}),{vertex:Fn(i,s),fragment:Fn(t,n)}}const ol=`
@in aPosition: vec2<f32>;
@in aUV: vec2<f32>;
@out @builtin(position) vPosition: vec4<f32>;
@out vUV : vec2<f32>;
@out vColor : vec4<f32>;
{{header}}
struct VSOutput {
{{struct}}
};
@vertex
fn main( {{in}} ) -> VSOutput {
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
var modelMatrix = mat3x3<f32>(
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<f32>(1., 1., 1., 1.);
{{main}}
vUV = uv;
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
vColor *= globalUniforms.uWorldColorAlpha;
{{end}}
{{return}}
};
`,hl=`
@in vUV : vec2<f32>;
@in vColor : vec4<f32>;
{{header}}
@fragment
fn main(
{{in}}
) -> @location(0) vec4<f32> {
{{start}}
var outColor:vec4<f32>;
{{main}}
var finalColor:vec4<f32> = outColor * vColor;
{{end}}
return finalColor;
};
`,ll=`
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}}
}
`,cl=`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
{{end}}
}
`,dl={name:"global-uniforms-bit",vertex:{header:`
struct GlobalUniforms {
uProjectionMatrix:mat3x3<f32>,
uWorldTransformMatrix:mat3x3<f32>,
uWorldColorAlpha: vec4<f32>,
uResolution: vec2<f32>,
}
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
`}},ul={name:"global-uniforms-bit",vertex:{header:`
uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform vec4 uWorldColorAlpha;
uniform vec2 uResolution;
`}};function fl({bits:i,name:t}){const e=nl({template:{fragment:hl,vertex:ol},bits:[dl,...i]});return Ti.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function pl({bits:i,name:t}){return new Lr({name:t,...rl({template:{vertex:ll,fragment:cl},bits:[ul,...i]})})}const gl={name:"color-bit",vertex:{header:`
@in aColor: vec4<f32>;
`,main:`
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
`}},ml={name:"color-bit",vertex:{header:`
in vec4 aColor;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},Ji={};function xl(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s<i;s++)t.push(`@group(1) @binding(${e++}) var textureSource${s+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
`)}function yl(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<i;e++)e===i-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
`)}function wl(i){return Ji[i]||(Ji[i]={name:"texture-batch-bit",vertex:{header:`
@in aTextureIdAndRound: vec2<u32>;
@out @interpolate(flat) vTextureId : u32;
`,main:`
vTextureId = aTextureIdAndRound.y;
`,end:`
if(aTextureIdAndRound.x == 1)
{
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
}
`},fragment:{header:`
@in @interpolate(flat) vTextureId: u32;
${xl(i)}
`,main:`
var uvDx = dpdx(vUV);
var uvDy = dpdy(vUV);
${yl(i)}
`}}),Ji[i]}const ts={};function _l(i){const t=[];for(let e=0;e<i;e++)e>0&&t.push("else"),e<i-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
`)}function bl(i){return ts[i]||(ts[i]={name:"texture-batch-bit",vertex:{header:`
in vec2 aTextureIdAndRound;
out float vTextureId;
`,main:`
vTextureId = aTextureIdAndRound.y;
`,end:`
if(aTextureIdAndRound.x == 1.)
{
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
}
`},fragment:{header:`
in float vTextureId;
uniform sampler2D uTextures[${i}];
`,main:`
${_l(i)}
`}}),ts[i]}const Sl={name:"round-pixels-bit",vertex:{header:`
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
`}},vl={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;
}
`}},Ln={};function Cl(i){let t=Ln[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=Ln[i]=new Nr({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class Tl extends Es{constructor(t){const e=pl({name:"batch",bits:[ml,bl(t),vl]}),s=fl({name:"batch",bits:[gl,wl(t),Sl]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Cl(t)}})}}let Dn=null;const ha=class la extends Xh{constructor(){super(...arguments),this.geometry=new Qh,this.shader=Dn||(Dn=new Tl(this.maxTextures)),this.name=la.extension.name,this.vertexSize=6}packAttributes(t,e,s,n,r){const a=r<<16|t.roundPixels&65535,o=t.transform,h=o.a,l=o.b,c=o.c,d=o.d,f=o.tx,g=o.ty,{positions:m,uvs:y}=t,x=t.color,w=t.attributeOffset,_=w+t.attributeSize;for(let b=w;b<_;b++){const S=b*2,A=m[S],F=m[S+1];e[n++]=h*A+c*F+f,e[n++]=d*F+l*A+g,e[n++]=y[S],e[n++]=y[S+1],s[n++]=x,s[n++]=a}}packQuadAttributes(t,e,s,n,r){const a=t.texture,o=t.transform,h=o.a,l=o.b,c=o.c,d=o.d,f=o.tx,g=o.ty,m=t.bounds,y=m.maxX,x=m.minX,w=m.maxY,_=m.minY,b=a.uvs,S=t.color,A=r<<16|t.roundPixels&65535;e[n+0]=h*x+c*_+f,e[n+1]=d*_+l*x+g,e[n+2]=b.x0,e[n+3]=b.y0,s[n+4]=S,s[n+5]=A,e[n+6]=h*y+c*_+f,e[n+7]=d*_+l*y+g,e[n+8]=b.x1,e[n+9]=b.y1,s[n+10]=S,s[n+11]=A,e[n+12]=h*y+c*w+f,e[n+13]=d*w+l*y+g,e[n+14]=b.x2,e[n+15]=b.y2,s[n+16]=S,s[n+17]=A,e[n+18]=h*x+c*w+f,e[n+19]=d*w+l*x+g,e[n+20]=b.x3,e[n+21]=b.y3,s[n+22]=S,s[n+23]=A}};ha.extension={type:[G.Batcher],name:"default"};let Al=ha;function Ml(i,t,e,s,n,r,a,o=null){let h=0;e*=t,n*=r;const l=o.a,c=o.b,d=o.c,f=o.d,g=o.tx,m=o.ty;for(;h<a;){const y=i[e],x=i[e+1];s[n]=l*y+d*x+g,s[n+1]=c*y+f*x+m,n+=r,e+=t,h++}}function Pl(i,t,e,s){let n=0;for(t*=e;n<s;)i[t]=0,i[t+1]=0,t+=e,n++}function ca(i,t,e,s,n){const r=t.a,a=t.b,o=t.c,h=t.d,l=t.tx,c=t.ty;e=e||0,s=s||2,n=n||i.length/s-e;let d=e*s;for(let f=0;f<n;f++){const g=i[d],m=i[d+1];i[d]=r*g+o*m+l,i[d+1]=a*g+h*m+c,d+=s}}function Gl(i,t){if(i===16777215||!t)return t;if(t===16777215||!i)return i;const e=i>>16&255,s=i>>8&255,n=i&255,r=t>>16&255,a=t>>8&255,o=t&255,h=e*r/255,l=s*a/255,c=n*o/255;return(h<<16)+(l<<8)+c}const kl=new H;class da{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?Gl(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||kl}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 je={extension:{type:G.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,r,a,o;if(i.type==="circle"){const S=i;e=S.x,s=S.y,a=o=S.radius,n=r=0}else if(i.type==="ellipse"){const S=i;e=S.x,s=S.y,a=S.halfWidth,o=S.halfHeight,n=r=0}else{const S=i,A=S.width/2,F=S.height/2;e=S.x+A,s=S.y+F,a=o=Math.max(0,Math.min(S.radius,Math.min(A,F))),n=A-a,r=F-o}if(!(a>=0&&o>=0&&n>=0&&r>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),l=h*8+(n?4:0)+(r?4:0);if(l===0)return t;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+r,t[2]=t[4]=e-n,t[5]=t[7]=s-r,t;let c=0,d=h*4+(n?2:0)+2,f=d,g=l,m=n+a,y=r,x=e+m,w=e-m,_=s+y;if(t[c++]=x,t[c++]=_,t[--d]=_,t[--d]=w,r){const S=s-y;t[f++]=w,t[f++]=S,t[--g]=S,t[--g]=x}for(let S=1;S<h;S++){const A=Math.PI/2*(S/h),F=n+Math.cos(A)*a,P=r+Math.sin(A)*o,k=e+F,v=e-F,T=s+P,Z=s-P;t[c++]=k,t[c++]=T,t[--d]=T,t[--d]=v,t[f++]=v,t[f++]=Z,t[--g]=Z,t[--g]=k}m=n,y=r+o,x=e+m,w=e-m,_=s+y;const b=s-y;return t[c++]=x,t[c++]=_,t[--g]=b,t[--g]=x,n&&(t[c++]=w,t[c++]=_,t[--g]=b,t[--g]=w),t},triangulate(i,t,e,s,n,r){if(i.length===0)return;let a=0,o=0;for(let c=0;c<i.length;c+=2)a+=i[c],o+=i[c+1];a/=i.length/2,o/=i.length/2;let h=s;t[h*e]=a,t[h*e+1]=o;const l=h++;for(let c=0;c<i.length;c+=2)t[h*e]=i[c],t[h*e+1]=i[c+1],c>0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},Bl={...je,extension:{...je.extension,name:"ellipse"}},Il={...je,extension:{...je.extension,name:"roundedRectangle"}},El=1e-4,zn=1e-4;function Rl(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],r=i[t-1];s<t;s+=2){const a=i[s],o=i[s+1];e+=(a-n)*(o+r),n=a,r=o}return e<0?-1:1}function Un(i,t,e,s,n,r,a,o){const h=i-e*n,l=t-s*n,c=i+e*r,d=t+s*r;let f,g;a?(f=s,g=-e):(f=-s,g=e);const m=h+f,y=l+g,x=c+f,w=d+g;return o.push(m,y),o.push(x,w),2}function Qt(i,t,e,s,n,r,a,o){const h=e-i,l=s-t;let c=Math.atan2(h,l),d=Math.atan2(n-i,r-t);o&&c<d?c+=Math.PI*2:!o&&c>d&&(d+=Math.PI*2);let f=c;const g=d-c,m=Math.abs(g),y=Math.sqrt(h*h+l*l),x=(15*m*Math.sqrt(y)/Math.PI>>0)+1,w=g/x;if(f+=w,o){a.push(i,t),a.push(e,s);for(let _=1,b=f;_<x;_++,b+=w)a.push(i,t),a.push(i+Math.sin(b)*y,t+Math.cos(b)*y);a.push(i,t),a.push(n,r)}else{a.push(e,s),a.push(i,t);for(let _=1,b=f;_<x;_++,b+=w)a.push(i+Math.sin(b)*y,t+Math.cos(b)*y),a.push(i,t);a.push(n,r),a.push(i,t)}return x*2}function Fl(i,t,e,s,n,r,a,o,h){const l=El;if(i.length===0)return;const c=t;let d=c.alignment;if(t.alignment!==.5){let V=Rl(i);d=(d-.5)*V+.5}const f=new lt(i[0],i[1]),g=new lt(i[i.length-2],i[i.length-1]),m=s,y=Math.abs(f.x-g.x)<l&&Math.abs(f.y-g.y)<l;if(m){i=i.slice(),y&&(i.pop(),i.pop(),g.set(i[i.length-2],i[i.length-1]));const V=(f.x+g.x)*.5,Wt=(g.y+f.y)*.5;i.unshift(V,Wt),i.push(V,Wt)}const x=n,w=i.length/2;let _=i.length;const b=x.length/2,S=c.width/2,A=S*S,F=c.miterLimit*c.miterLimit;let P=i[0],k=i[1],v=i[2],T=i[3],Z=0,Rt=0,L=-(k-T),E=P-v,X=0,et=0,bt=Math.sqrt(L*L+E*E);L/=bt,E/=bt,L*=S,E*=S;const Ks=d,B=(1-Ks)*2,D=Ks*2;m||(c.cap==="round"?_+=Qt(P-L*(B-D)*.5,k-E*(B-D)*.5,P-L*B,k-E*B,P+L*D,k+E*D,x,!0)+2:c.cap==="square"&&(_+=Un(P,k,L,E,B,D,!0,x))),x.push(P-L*B,k-E*B),x.push(P+L*D,k+E*D);for(let V=1;V<w-1;++V){P=i[(V-1)*2],k=i[(V-1)*2+1],v=i[V*2],T=i[V*2+1],Z=i[(V+1)*2],Rt=i[(V+1)*2+1],L=-(k-T),E=P-v,bt=Math.sqrt(L*L+E*E),L/=bt,E/=bt,L*=S,E*=S,X=-(T-Rt),et=v-Z,bt=Math.sqrt(X*X+et*et),X/=bt,et/=bt,X*=S,et*=S;const Wt=v-P,Pe=k-T,Ge=v-Z,ke=Rt-T,Zs=Wt*Ge+Pe*ke,Qe=Pe*Ge-ke*Wt,Be=Qe<0;if(Math.abs(Qe)<.001*Math.abs(Zs)){x.push(v-L*B,T-E*B),x.push(v+L*D,T+E*D),Zs>=0&&(c.join==="round"?_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+4:_+=2,x.push(v-X*D,T-et*D),x.push(v+X*B,T+et*B));continue}const Qs=(-L+P)*(-E+T)-(-L+v)*(-E+k),Js=(-X+Z)*(-et+T)-(-X+v)*(-et+Rt),Je=(Wt*Js-Ge*Qs)/Qe,ti=(ke*Qs-Pe*Js)/Qe,Ii=(Je-v)*(Je-v)+(ti-T)*(ti-T),jt=v+(Je-v)*B,qt=T+(ti-T)*B,Kt=v-(Je-v)*D,Zt=T-(ti-T)*D,Da=Math.min(Wt*Wt+Pe*Pe,Ge*Ge+ke*ke),tn=Be?B:D,za=Da+tn*tn*A;Ii<=za?c.join==="bevel"||Ii/A>F?(Be?(x.push(jt,qt),x.push(v+L*D,T+E*D),x.push(jt,qt),x.push(v+X*D,T+et*D)):(x.push(v-L*B,T-E*B),x.push(Kt,Zt),x.push(v-X*B,T-et*B),x.push(Kt,Zt)),_+=2):c.join==="round"?Be?(x.push(jt,qt),x.push(v+L*D,T+E*D),_+=Qt(v,T,v+L*D,T+E*D,v+X*D,T+et*D,x,!0)+4,x.push(jt,qt),x.push(v+X*D,T+et*D)):(x.push(v-L*B,T-E*B),x.push(Kt,Zt),_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+4,x.push(v-X*B,T-et*B),x.push(Kt,Zt)):(x.push(jt,qt),x.push(Kt,Zt)):(x.push(v-L*B,T-E*B),x.push(v+L*D,T+E*D),c.join==="round"?Be?_+=Qt(v,T,v+L*D,T+E*D,v+X*D,T+et*D,x,!0)+2:_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+2:c.join==="miter"&&Ii/A<=F&&(Be?(x.push(Kt,Zt),x.push(Kt,Zt)):(x.push(jt,qt),x.push(jt,qt)),_+=2),x.push(v-X*B,T-et*B),x.push(v+X*D,T+et*D),_+=2)}P=i[(w-2)*2],k=i[(w-2)*2+1],v=i[(w-1)*2],T=i[(w-1)*2+1],L=-(k-T),E=P-v,bt=Math.sqrt(L*L+E*E),L/=bt,E/=bt,L*=S,E*=S,x.push(v-L*B,T-E*B),x.push(v+L*D,T+E*D),m||(c.cap==="round"?_+=Qt(v-L*(B-D)*.5,T-E*(B-D)*.5,v-L*B,T-E*B,v+L*D,T+E*D,x,!1)+2:c.cap==="square"&&(_+=Un(v,T,L,E,B,D,!1,x)));const La=zn*zn;for(let V=b;V<_+b-2;++V)P=x[V*2],k=x[V*2+1],v=x[(V+1)*2],T=x[(V+1)*2+1],Z=x[(V+2)*2],Rt=x[(V+2)*2+1],!(Math.abs(P*(T-Rt)+v*(Rt-k)+Z*(k-T))<La)&&o.push(V,V+1,V+2)}function ua(i,t,e,s,n,r,a){const o=vh(i,t,2);if(!o)return;for(let l=0;l<o.length;l+=3)r[a++]=o[l]+n,r[a++]=o[l+1]+n,r[a++]=o[l+2]+n;let h=n*s;for(let l=0;l<i.length;l+=2)e[h]=i[l],e[h+1]=i[l+1],h+=s}const Ll=[],Dl={extension:{type:G.ShapeBuilder,name:"polygon"},build(i,t){for(let e=0;e<i.points.length;e++)t[e]=i.points[e];return t},triangulate(i,t,e,s,n,r){ua(i,Ll,t,e,s,n,r)}},zl={extension:{type:G.ShapeBuilder,name:"rectangle"},build(i,t){const e=i,s=e.x,n=e.y,r=e.width,a=e.height;return r>=0&&a>=0&&(t[0]=s,t[1]=n,t[2]=s+r,t[3]=n,t[4]=s+r,t[5]=n+a,t[6]=s,t[7]=n+a),t},triangulate(i,t,e,s,n,r){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[6],t[s+a+1]=i[7],a+=e,t[s+a]=i[4],t[s+a+1]=i[5],a+=e;const o=s/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2,n[r++]=o+1,n[r++]=o+3,n[r++]=o+2}},Ul={extension:{type:G.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,t},triangulate(i,t,e,s,n,r){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[4],t[s+a+1]=i[5];const o=s/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2}},Gi={};dt.handleByMap(G.ShapeBuilder,Gi);dt.add(zl,Dl,Ul,je,Bl,Il);const Nl=new I;function Ol(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n<i.instructions.length;n++){const r=i.instructions[n];if(r.action==="texture")Wl(r.data,s,e);else if(r.action==="fill"||r.action==="stroke"){const a=r.action==="stroke",o=r.data.path.shapePath,h=r.data.style,l=r.data.hole;a&&l&&Nn(l.shapePath,h,null,!0,s,e),Nn(o,h,l,a,s,e)}}}function Wl(i,t,e){const{vertices:s,uvs:n,indices:r}=e,a=r.length,o=s.length/2,h=[],l=Gi.rectangle,c=Nl,d=i.image;c.x=i.dx,c.y=i.dy,c.width=i.dw,c.height=i.dh;const f=i.transform;l.build(c,h),f&&ca(h,f),l.triangulate(h,s,2,o,r,a);const g=d.uvs;n.push(g.x0,g.y0,g.x1,g.y1,g.x3,g.y3,g.x2,g.y2);const m=zt.get(da);m.indexOffset=a,m.indexSize=r.length-a,m.attributeOffset=o,m.attributeSize=s.length/2-o,m.baseColor=i.style,m.alpha=i.alpha,m.texture=d,m.geometryData=e,t.push(m)}function Nn(i,t,e,s,n,r){const{vertices:a,uvs:o,indices:h}=r,l=i.shapePrimitives.length-1;i.shapePrimitives.forEach(({shape:c,transform:d},f)=>{const g=h.length,m=a.length/2,y=[],x=Gi[c.type];if(x.build(c,y),d&&ca(y,d),s){const S=c.closePath??!0;Fl(y,t,!1,S,a,2,m,h)}else if(e&&l===f){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],A=y.slice();Hl(e.shapePath).forEach(P=>{S.push(A.length/2),A.push(...P)}),ua(A,S,a,2,m,h,g)}else x.triangulate(y,a,2,m,h,g);const w=o.length/2,_=t.texture;if(_!==z.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),Ml(a,2,m,o,w,2,a.length/2-m,S))}else Pl(o,w,2,a.length/2-m);const b=zt.get(da);b.indexOffset=g,b.indexSize=h.length-g,b.attributeOffset=m,b.attributeSize=a.length/2-m,b.baseColor=t.color,b.alpha=t.alpha,b.texture=_,b.geometryData=r,n.push(b)})}function Hl(i){if(!i)return[];const t=i.shapePrimitives,e=[];for(let s=0;s<t.length;s++){const n=t[s].shape,r=[];Gi[n.type].build(n,r),e.push(r)}return e}class $l{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Vl{constructor(){this.batcher=new Al,this.instructions=new wr}init(){this.instructions.reset()}get geometry(){return U(Qa,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const zs=class Ss{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){Ss.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??Ss.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),Ol(t,e);const s=t.batchMode;t.customShader||s==="no-batch"?e.isBatchable=!1:s==="auto"&&(e.isBatchable=e.geometryData.vertices.length<400),t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=zt.get(Vl),{batches:s,geometryData:n}=this._gpuContextHash[t.uid],r=n.vertices.length,a=n.indices.length;for(let c=0;c<s.length;c++)s[c].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(r),o.ensureIndexBuffer(a),o.begin();for(let c=0;c<s.length;c++){const d=s[c];o.add(d)}o.finish(e.instructions);const h=o.geometry;h.indexBuffer.setDataWithSize(o.indexBuffer,o.indexSize,!0),h.buffers[0].setDataWithSize(o.attributeBuffer.float32View,o.attributeSize,!0);const l=o.batches;for(let c=0;c<l.length;c++){const d=l[c];d.bindGroup=Oh(d.textures.textures,d.textures.count)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new $l;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(zt.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(s=>{zt.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};zs.extension={type:[G.WebGLSystem,G.WebGPUSystem,G.CanvasSystem],name:"graphicsContext"};zs.defaultOptions={bezierSmoothness:.5};let fa=zs;const Yl=8,di=11920929e-14,Xl=1;function pa(i,t,e,s,n,r,a,o,h,l){const d=Math.min(.99,Math.max(0,l??fa.defaultOptions.bezierSmoothness));let f=(Xl-d)/1;return f*=f,jl(t,e,s,n,r,a,o,h,i,f),i}function jl(i,t,e,s,n,r,a,o,h,l){vs(i,t,e,s,n,r,a,o,h,l,0),h.push(a,o)}function vs(i,t,e,s,n,r,a,o,h,l,c){if(c>Yl)return;const d=(i+e)/2,f=(t+s)/2,g=(e+n)/2,m=(s+r)/2,y=(n+a)/2,x=(r+o)/2,w=(d+g)/2,_=(f+m)/2,b=(g+y)/2,S=(m+x)/2,A=(w+b)/2,F=(_+S)/2;if(c>0){let P=a-i,k=o-t;const v=Math.abs((e-a)*k-(s-o)*P),T=Math.abs((n-a)*k-(r-o)*P);if(v>di&&T>di){if((v+T)*(v+T)<=l*(P*P+k*k)){h.push(A,F);return}}else if(v>di){if(v*v<=l*(P*P+k*k)){h.push(A,F);return}}else if(T>di){if(T*T<=l*(P*P+k*k)){h.push(A,F);return}}else if(P=A-(i+a)/2,k=F-(t+o)/2,P*P+k*k<=l){h.push(A,F);return}}vs(i,t,d,f,w,_,A,F,h,l,c+1),vs(A,F,b,S,y,x,a,o,h,l,c+1)}const ql=8,Kl=11920929e-14,Zl=1;function Ql(i,t,e,s,n,r,a,o){const l=Math.min(.99,Math.max(0,o??fa.defaultOptions.bezierSmoothness));let c=(Zl-l)/1;return c*=c,Jl(t,e,s,n,r,a,i,c),i}function Jl(i,t,e,s,n,r,a,o){Cs(a,i,t,e,s,n,r,o,0),a.push(n,r)}function Cs(i,t,e,s,n,r,a,o,h){if(h>ql)return;const l=(t+s)/2,c=(e+n)/2,d=(s+r)/2,f=(n+a)/2,g=(l+d)/2,m=(c+f)/2;let y=r-t,x=a-e;const w=Math.abs((s-r)*x-(n-a)*y);if(w>Kl){if(w*w<=o*(y*y+x*x)){i.push(g,m);return}}else if(y=g-(t+r)/2,x=m-(e+a)/2,y*y+x*x<=o){i.push(g,m);return}Cs(i,t,e,l,c,g,m,o,h+1),Cs(i,g,m,d,f,r,a,o,h+1)}function ga(i,t,e,s,n,r,a,o){let h=Math.abs(n-r);(!a&&n>r||a&&r>n)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI))),o=Math.max(o,3);let l=h/o,c=n;l*=a?-1:1;for(let d=0;d<o+1;d++){const f=Math.cos(c),g=Math.sin(c),m=t+f*s,y=e+g*s;i.push(m,y),c+=l}}function tc(i,t,e,s,n,r){const a=i[i.length-2],h=i[i.length-1]-e,l=a-t,c=n-e,d=s-t,f=Math.abs(h*d-l*c);if(f<1e-8||r===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const g=h*h+l*l,m=c*c+d*d,y=h*c+l*d,x=r*Math.sqrt(g)/f,w=r*Math.sqrt(m)/f,_=x*y/g,b=w*y/m,S=x*d+w*l,A=x*c+w*h,F=l*(w+_),P=h*(w+_),k=d*(x+b),v=c*(x+b),T=Math.atan2(P-A,F-S),Z=Math.atan2(v-A,k-S);ga(i,S+t,A+e,r,T,Z,l*c>d*h)}const He=Math.PI*2,es={centerX:0,centerY:0,ang1:0,ang2:0},is=({x:i,y:t},e,s,n,r,a,o,h)=>{i*=e,t*=s;const l=n*i-r*t,c=r*i+n*t;return h.x=l+a,h.y=c+o,h};function ec(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),r=Math.sin(i),a=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*s,y:r+n*s},{x:a+o*s,y:o-a*s},{x:a,y:o}]}const On=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let r=i*e+t*s;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},ic=(i,t,e,s,n,r,a,o,h,l,c,d,f)=>{const g=Math.pow(n,2),m=Math.pow(r,2),y=Math.pow(c,2),x=Math.pow(d,2);let w=g*m-g*x-m*y;w<0&&(w=0),w/=g*x+m*y,w=Math.sqrt(w)*(a===o?-1:1);const _=w*n/r*d,b=w*-r/n*c,S=l*_-h*b+(i+e)/2,A=h*_+l*b+(t+s)/2,F=(c-_)/n,P=(d-b)/r,k=(-c-_)/n,v=(-d-b)/r,T=On(1,0,F,P);let Z=On(F,P,k,v);o===0&&Z>0&&(Z-=He),o===1&&Z<0&&(Z+=He),f.centerX=S,f.centerY=A,f.ang1=T,f.ang2=Z};function sc(i,t,e,s,n,r,a,o=0,h=0,l=0){if(r===0||a===0)return;const c=Math.sin(o*He/360),d=Math.cos(o*He/360),f=d*(t-s)/2+c*(e-n)/2,g=-c*(t-s)/2+d*(e-n)/2;if(f===0&&g===0)return;r=Math.abs(r),a=Math.abs(a);const m=Math.pow(f,2)/Math.pow(r,2)+Math.pow(g,2)/Math.pow(a,2);m>1&&(r*=Math.sqrt(m),a*=Math.sqrt(m)),ic(t,e,s,n,r,a,h,l,c,d,f,g,es);let{ang1:y,ang2:x}=es;const{centerX:w,centerY:_}=es;let b=Math.abs(x)/(He/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);x/=S;let A=i[i.length-2],F=i[i.length-1];const P={x:0,y:0};for(let k=0;k<S;k++){const v=ec(y,x),{x:T,y:Z}=is(v[0],r,a,d,c,w,_,P),{x:Rt,y:L}=is(v[1],r,a,d,c,w,_,P),{x:E,y:X}=is(v[2],r,a,d,c,w,_,P);pa(i,A,F,T,Z,Rt,L,E,X),A=E,F=X,y+=x}}function nc(i,t,e){const s=(a,o)=>{const h=o.x-a.x,l=o.y-a.y,c=Math.sqrt(h*h+l*l),d=h/c,f=l/c;return{len:c,nx:d,ny:f}},n=(a,o)=>{a===0?i.moveTo(o.x,o.y):i.lineTo(o.x,o.y)};let r=t[t.length-1];for(let a=0;a<t.length;a++){const o=t[a%t.length],h=o.radius??e;if(h<=0){n(a,o),r=o;continue}const l=t[(a+1)%t.length],c=s(o,r),d=s(o,l);if(c.len<1e-4||d.len<1e-4){n(a,o),r=o;continue}let f=Math.asin(c.nx*d.ny-c.ny*d.nx),g=1,m=!1;c.nx*d.nx-c.ny*-d.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,g=-1,m=!0):f>0&&(g=-1,m=!0);const y=f/2;let x,w=Math.abs(Math.cos(y)*h/Math.sin(y));w>Math.min(c.len/2,d.len/2)?(w=Math.min(c.len/2,d.len/2),x=Math.abs(w*Math.sin(y)/Math.cos(y))):x=h;const _=o.x+d.nx*w+-d.ny*x*g,b=o.y+d.ny*w+d.nx*x*g,S=Math.atan2(c.ny,c.nx)+Math.PI/2*g,A=Math.atan2(d.ny,d.nx)-Math.PI/2*g;a===0&&i.moveTo(_+Math.cos(S)*x,b+Math.sin(S)*x),i.arc(_,b,x,S,A,m),r=o}}function rc(i,t,e,s){const n=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),r=(o,h,l)=>({x:o.x+(h.x-o.x)*l,y:o.y+(h.y-o.y)*l}),a=t.length;for(let o=0;o<a;o++){const h=t[(o+1)%a],l=h.radius??e;if(l<=0){o===0?i.moveTo(h.x,h.y):i.lineTo(h.x,h.y);continue}const c=t[o],d=t[(o+2)%a],f=n(c,h);let g;if(f<1e-4)g=h;else{const x=Math.min(f/2,l);g=r(h,c,x/f)}const m=n(d,h);let y;if(m<1e-4)y=h;else{const x=Math.min(m/2,l);y=r(h,d,x/m)}o===0?i.moveTo(g.x,g.y):i.lineTo(g.x,g.y),i.quadraticCurveTo(h.x,h.y,y.x,y.y,s)}}const ac=new I;class oc{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Et,this._graphicsPath2D=t}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const s=this._currentPoly.points,n=s[s.length-2],r=s[s.length-1];return(n!==t||r!==e)&&s.push(t,e),this}arc(t,e,s,n,r,a){this._ensurePoly(!1);const o=this._currentPoly.points;return ga(o,t,e,s,n,r,a),this}arcTo(t,e,s,n,r){this._ensurePoly();const a=this._currentPoly.points;return tc(a,t,e,s,n,r),this}arcToSvg(t,e,s,n,r,a,o){const h=this._currentPoly.points;return sc(h,this._currentPoly.lastX,this._currentPoly.lastY,a,o,t,e,s,n,r),this}bezierCurveTo(t,e,s,n,r,a,o){this._ensurePoly();const h=this._currentPoly;return pa(this._currentPoly.points,h.lastX,h.lastY,t,e,s,n,r,a,o),this}quadraticCurveTo(t,e,s,n,r){this._ensurePoly();const a=this._currentPoly;return Ql(this._currentPoly.points,a.lastX,a.lastY,t,e,s,n,r),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));for(let s=0;s<t.instructions.length;s++){const n=t.instructions[s];this[n.action](...n.data)}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,n,r){return this.drawShape(new I(t,e,s,n),r),this}circle(t,e,s,n){return this.drawShape(new Fs(t,e,s),n),this}poly(t,e,s){const n=new We(t);return n.closePath=e,this.drawShape(n,s),this}regularPoly(t,e,s,n,r=0,a){n=Math.max(n|0,3);const o=-1*Math.PI/2+r,h=Math.PI*2/n,l=[];for(let c=0;c<n;c++){const d=c*h+o;l.push(t+s*Math.cos(d),e+s*Math.sin(d))}return this.poly(l,!0,a),this}roundPoly(t,e,s,n,r,a=0,o){if(n=Math.max(n|0,3),r<=0)return this.regularPoly(t,e,s,n,a);const h=s*Math.sin(Math.PI/n)-.001;r=Math.min(r,h);const l=-1*Math.PI/2+a,c=Math.PI*2/n,d=(n-2)*Math.PI/n/2;for(let f=0;f<n;f++){const g=f*c+l,m=t+s*Math.cos(g),y=e+s*Math.sin(g),x=g+Math.PI+d,w=g-Math.PI-d,_=m+r*Math.cos(x),b=y+r*Math.sin(x),S=m+r*Math.cos(w),A=y+r*Math.sin(w);f===0?this.moveTo(_,b):this.lineTo(_,b),this.quadraticCurveTo(m,y,S,A,o)}return this.closePath()}roundShape(t,e,s=!1,n){return t.length<3?this:(s?rc(this,t,e,n):nc(this,t,e),this.closePath())}filletRect(t,e,s,n,r){if(r===0)return this.rect(t,e,s,n);const a=Math.min(s,n)/2,o=Math.min(a,Math.max(-a,r)),h=t+s,l=e+n,c=o<0?-o:0,d=Math.abs(o);return this.moveTo(t,e+d).arcTo(t+c,e+c,t+d,e,d).lineTo(h-d,e).arcTo(h-c,e+c,h,e+d,d).lineTo(h,l-d).arcTo(h-c,l-c,t+s-d,l,d).lineTo(t+d,l).arcTo(t+c,l-c,t,l-d,d).closePath()}chamferRect(t,e,s,n,r,a){if(r<=0)return this.rect(t,e,s,n);const o=Math.min(r,Math.min(s,n)/2),h=t+s,l=e+n,c=[t+o,e,h-o,e,h,e+o,h,l-o,h-o,l,t+o,l,t,l-o,t,e+o];for(let d=c.length-1;d>=2;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,a)}ellipse(t,e,s,n,r){return this.drawShape(new Ls(t,e,s,n),r),this}roundRect(t,e,s,n,r,a){return this.drawShape(new Ds(t,e,s,n,r),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new We,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new We,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,a=s;s=r.a*s+r.c*n+r.tx,n=r.b*a+r.d*n+r.ty}this._currentPoly.points.push(s,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const s=t.instructions[e];this[s.action](...s.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let s=0;s<e.length;s++){const n=e[s],r=n.shape.getBounds(ac);n.transform?t.addRect(r,n.transform):t.addRect(r)}return t}}class ye{constructor(t){this.instructions=[],this.uid=nt("graphicsPath"),this._dirty=!0,typeof t=="string"?Lh(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new oc(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,s,n,r){const a=this.instructions[this.instructions.length-1],o=this.getLastPoint(lt.shared);let h=0,l=0;if(!a||a.action!=="bezierCurveTo")h=o.x,l=o.y;else{h=a.data[2],l=a.data[3];const c=o.x,d=o.y;h=c+(c-h),l=d+(d-l)}return this.instructions.push({action:"bezierCurveTo",data:[h,l,t,e,s,n,r]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,s){const n=this.instructions[this.instructions.length-1],r=this.getLastPoint(lt.shared);let a=0,o=0;if(!n||n.action!=="quadraticCurveTo")a=r.x,o=r.y;else{a=n.data[0],o=n.data[1];const h=r.x,l=r.y;a=h+(h-a),o=l+(l-o)}return this.instructions.push({action:"quadraticCurveTo",data:[a,o,t,e,s]}),this._dirty=!0,this}rect(t,e,s,n,r){return this.instructions.push({action:"rect",data:[t,e,s,n,r]}),this._dirty=!0,this}circle(t,e,s,n){return this.instructions.push({action:"circle",data:[t,e,s,n]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,s,n,r,a,o){r=r||n/2;const h=-1*Math.PI/2+a,l=s*2,c=Math.PI*2/l,d=[];for(let f=0;f<l;f++){const g=f%2?r:n,m=f*c+h;d.push(t+g*Math.cos(m),e+g*Math.sin(m))}return this.poly(d,!0,o),this}clone(t=!1){const e=new ye;if(!t)e.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const n=this.instructions[s];e.instructions.push({action:n.action,data:n.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,s=t.b,n=t.c,r=t.d,a=t.tx,o=t.ty;let h=0,l=0,c=0,d=0,f=0,g=0,m=0,y=0;for(let x=0;x<this.instructions.length;x++){const w=this.instructions[x],_=w.data;switch(w.action){case"moveTo":case"lineTo":h=_[0],l=_[1],_[0]=e*h+n*l+a,_[1]=s*h+r*l+o;break;case"bezierCurveTo":c=_[0],d=_[1],f=_[2],g=_[3],h=_[4],l=_[5],_[0]=e*c+n*d+a,_[1]=s*c+r*d+o,_[2]=e*f+n*g+a,_[3]=s*f+r*g+o,_[4]=e*h+n*l+a,_[5]=s*h+r*l+o;break;case"quadraticCurveTo":c=_[0],d=_[1],h=_[2],l=_[3],_[0]=e*c+n*d+a,_[1]=s*c+r*d+o,_[2]=e*h+n*l+a,_[3]=s*h+r*l+o;break;case"arcToSvg":h=_[5],l=_[6],m=_[0],y=_[1],_[0]=e*m+n*y,_[1]=s*m+r*y,_[5]=e*h+n*l+a,_[6]=s*h+r*l+o;break;case"circle":_[4]=Fe(_[3],t);break;case"rect":_[4]=Fe(_[4],t);break;case"ellipse":_[8]=Fe(_[8],t);break;case"roundRect":_[5]=Fe(_[5],t);break;case"addPath":_[0].transform(t);break;case"poly":_[2]=Fe(_[2],t);break;default:st("unknown transform action",w.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,s=this.instructions[e];if(!s)return t.x=0,t.y=0,t;for(;s.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;s=this.instructions[e]}switch(s.action){case"moveTo":case"lineTo":t.x=s.data[0],t.y=s.data[1];break;case"quadraticCurveTo":t.x=s.data[2],t.y=s.data[3];break;case"bezierCurveTo":t.x=s.data[4],t.y=s.data[5];break;case"arc":case"arcToSvg":t.x=s.data[5],t.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(t);break}return t}}function Fe(i,t){return i?i.prepend(t):t.clone()}function hc(i,t){if(typeof i=="string"){const s=document.createElement("div");s.innerHTML=i.trim(),i=s.querySelector("svg")}const e={context:t,path:new ye};return ma(i,e,null,null),t}function ma(i,t,e,s){const n=i.children,{fillStyle:r,strokeStyle:a}=lc(i);r&&e?e={...e,...r}:r&&(e=r),a&&s?s={...s,...a}:a&&(s=a),t.context.fillStyle=e,t.context.strokeStyle=s;let o,h,l,c,d,f,g,m,y,x,w,_,b,S,A,F,P;switch(i.nodeName.toLowerCase()){case"path":S=i.getAttribute("d"),A=new ye(S),t.context.path(A),e&&t.context.fill(),s&&t.context.stroke();break;case"circle":g=rt(i,"cx",0),m=rt(i,"cy",0),y=rt(i,"r",0),t.context.ellipse(g,m,y,y),e&&t.context.fill(),s&&t.context.stroke();break;case"rect":o=rt(i,"x",0),h=rt(i,"y",0),F=rt(i,"width",0),P=rt(i,"height",0),x=rt(i,"rx",0),w=rt(i,"ry",0),x||w?t.context.roundRect(o,h,F,P,x||w):t.context.rect(o,h,F,P),e&&t.context.fill(),s&&t.context.stroke();break;case"ellipse":g=rt(i,"cx",0),m=rt(i,"cy",0),x=rt(i,"rx",0),w=rt(i,"ry",0),t.context.beginPath(),t.context.ellipse(g,m,x,w),e&&t.context.fill(),s&&t.context.stroke();break;case"line":l=rt(i,"x1",0),c=rt(i,"y1",0),d=rt(i,"x2",0),f=rt(i,"y2",0),t.context.beginPath(),t.context.moveTo(l,c),t.context.lineTo(d,f),s&&t.context.stroke();break;case"polygon":b=i.getAttribute("points"),_=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(_,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=i.getAttribute("points"),_=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(_,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}for(let k=0;k<n.length;k++)ma(n[k],t,e,s)}function rt(i,t,e){const s=i.getAttribute(t);return s?Number(s):e}function lc(i){const t=i.getAttribute("style"),e={},s={};let n=!1,r=!1;if(t){const a=t.split(";");for(let o=0;o<a.length;o++){const h=a[o],[l,c]=h.split(":");switch(l){case"stroke":c!=="none"&&(e.color=Y.shared.setValue(c).toNumber(),r=!0);break;case"stroke-width":e.width=Number(c);break;case"fill":c!=="none"&&(n=!0,s.color=Y.shared.setValue(c).toNumber());break;case"fill-opacity":s.alpha=Number(c);break;case"stroke-opacity":e.alpha=Number(c);break;case"opacity":s.alpha=Number(c),e.alpha=Number(c);break}}}else{const a=i.getAttribute("stroke");a&&a!=="none"&&(r=!0,e.color=Y.shared.setValue(a).toNumber(),e.width=rt(i,"stroke-width",1));const o=i.getAttribute("fill");o&&o!=="none"&&(n=!0,s.color=Y.shared.setValue(o).toNumber())}return{strokeStyle:r?e:null,fillStyle:n?s:null}}function cc(i){return Y.isColorLike(i)}function Wn(i){return i instanceof Pi}function Hn(i){return i instanceof Xe}function dc(i,t,e){const s=Y.shared.setValue(t??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?e.alpha:s.alpha,i.texture=z.WHITE,{...e,...i}}function $n(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function Vn(i,t,e){return t.buildLinearGradient(),i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function uc(i,t){var n;const e={...t,...i};if(e.texture){if(e.texture!==z.WHITE){const a=((n=e.matrix)==null?void 0:n.invert())||new H;a.translate(e.texture.frame.x,e.texture.frame.y),a.scale(1/e.texture.source.width,1/e.texture.source.height),e.matrix=a}const r=e.texture.source.style;r.addressMode==="clamp-to-edge"&&(r.addressMode="repeat",r.update())}const s=Y.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e.matrix=e.matrix?e.matrix.clone():null,e}function ne(i,t){if(i==null)return null;const e={},s=i;return cc(i)?dc(e,i,t):Wn(i)?$n(e,i,t):Hn(i)?Vn(e,i,t):s.fill&&Wn(s.fill)?$n(s,s.fill,t):s.fill&&Hn(s.fill)?Vn(s,s.fill,t):uc(s,t)}function bi(i,t){const{width:e,alignment:s,miterLimit:n,cap:r,join:a,...o}=t,h=ne(i,o);return h?{width:e,alignment:s,miterLimit:n,cap:r,join:a,...h}:null}const fc=new lt,Yn=new H,Us=class Gt extends gt{constructor(){super(...arguments),this.uid=nt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new ye,this._transform=new H,this._fillStyle={...Gt.defaultFillStyle},this._strokeStyle={...Gt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Et,this._boundsDirty=!0}clone(){const t=new Gt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=ne(t,Gt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=bi(t,Gt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ne(t,Gt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ne(t,Gt.defaultStrokeStyle),this}texture(t,e,s,n,r,a){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:n||0,dw:r||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?Y.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ye,this}fill(t,e){let s;const n=this.instructions[this.instructions.length-1];return this._tick===0&&n&&n.action==="stroke"?s=n.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(U(O,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=ne(t,Gt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(lt.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s&&s.action==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=bi(t,Gt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,n,r,a){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,s,n,r,a),this}arcTo(t,e,s,n,r){this._tick++;const a=this._transform;return this._activePath.arcTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*s+a.c*n+a.tx,a.b*s+a.d*n+a.ty,r),this}arcToSvg(t,e,s,n,r,a,o){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,s,n,r,h.a*a+h.c*o+h.tx,h.b*a+h.d*o+h.ty),this}bezierCurveTo(t,e,s,n,r,a,o){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*s+h.c*n+h.tx,h.b*s+h.d*n+h.ty,h.a*r+h.c*a+h.tx,h.b*r+h.d*a+h.ty,o),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,n){return this._tick++,this._activePath.ellipse(t,e,s,n,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,n=this._activePath.instructions,r=s.a*t+s.c*e+s.tx,a=s.b*t+s.d*e+s.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=r,n[0].data[1]=a,this):(this._activePath.moveTo(r,a),this)}quadraticCurveTo(t,e,s,n,r){this._tick++;const a=this._transform;return this._activePath.quadraticCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*s+a.c*n+a.tx,a.b*s+a.d*n+a.ty,r),this}rect(t,e,s,n){return this._tick++,this._activePath.rect(t,e,s,n,this._transform.clone()),this}roundRect(t,e,s,n,r){return this._tick++,this._activePath.roundRect(t,e,s,n,r,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,n,r=0,a){return this._tick++,this._activePath.regularPoly(t,e,s,n,r,a),this}roundPoly(t,e,s,n,r,a){return this._tick++,this._activePath.roundPoly(t,e,s,n,r,a),this}roundShape(t,e,s,n){return this._tick++,this._activePath.roundShape(t,e,s,n),this}filletRect(t,e,s,n,r){return this._tick++,this._activePath.filletRect(t,e,s,n,r),this}chamferRect(t,e,s,n,r,a){return this._tick++,this._activePath.chamferRect(t,e,s,n,r,a),this}star(t,e,s,n,r=0,a=0){return this._tick++,this._activePath.star(t,e,s,n,r,a,this._transform.clone()),this}svg(t){return this._tick++,hc(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,s,n,r,a){return t instanceof H?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,n,r,a),this)}transform(t,e,s,n,r,a){return t instanceof H?(this._transform.append(t),this):(Yn.set(t,e,s,n,r,a),this._transform.append(Yn),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const s=this.instructions[e],n=s.action;if(n==="fill"){const r=s.data;t.addBounds(r.path.bounds)}else if(n==="texture"){const r=s.data;t.addFrame(r.dx,r.dy,r.dx+r.dw,r.dy+r.dh,r.transform)}if(n==="stroke"){const r=s.data,a=r.style.width/2,o=r.path.bounds;t.addFrame(o.minX-a,o.minY-a,o.maxX+a,o.maxY+a)}}return t}containsPoint(t){var n;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let s=!1;for(let r=0;r<e.length;r++){const a=e[r],o=a.data,h=o.path;if(!a.action||!h)continue;const l=o.style,c=h.shapePath.shapePrimitives;for(let d=0;d<c.length;d++){const f=c[d].shape;if(!l||!f)continue;const g=c[d].transform,m=g?g.applyInverse(t,fc):t;a.action==="fill"?s=f.contains(m.x,m.y):s=f.strokeContains(m.x,m.y,l.width);const y=o.hole;if(y){const x=(n=y.shapePath)==null?void 0:n.shapePrimitives;if(x)for(let w=0;w<x.length;w++)x[w].shape.contains(m.x,m.y)&&(s=!1)}if(s)return!0}}return s}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(s),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(s)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Us.defaultFillStyle={color:16777215,alpha:1,texture:z.WHITE,matrix:null,fill:null};Us.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:z.WHITE,matrix:null,fill:null};let yt=Us;const Xn=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function pc(i){const t=[];let e=0;for(let s=0;s<Xn.length;s++){const n=`_${Xn[s]}`;t[e++]=i[n]}return e=xa(i._fill,t,e),e=gc(i._stroke,t,e),e=mc(i.dropShadow,t,e),t.join("-")}function xa(i,t,e){var s;return i&&(t[e++]=i.color,t[e++]=i.alpha,t[e++]=(s=i.fill)==null?void 0:s.styleKey),e}function gc(i,t,e){return i&&(e=xa(i,t,e),t[e++]=i.width,t[e++]=i.alignment,t[e++]=i.cap,t[e++]=i.join,t[e++]=i.miterLimit),e}function mc(i,t,e){return i&&(t[e++]=i.alpha,t[e++]=i.angle,t[e++]=i.blur,t[e++]=i.distance,t[e++]=Y.shared.setValue(i.color).toNumber()),e}const Ns=class de extends gt{constructor(t={}){super(),xc(t);const e={...de.defaultTextStyle,...t};for(const s in e){const n=s;this[n]=e[s]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...de.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...de.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...yt.defaultFillStyle,...t},()=>{this._fill=ne({...this._originalFill},yt.defaultFillStyle)})),this._fill=ne(t===0?"black":t,yt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...yt.defaultStrokeStyle,...t},()=>{this._stroke=bi({...this._originalStroke},yt.defaultStrokeStyle)})),this._stroke=bi(t,yt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=pc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=de.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new de({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var s,n,r,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(s=this._fill)!=null&&s.texture&&this._fill.texture.destroy(o),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(o),(r=this._stroke)!=null&&r.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,n,r)=>(s[n]=r,e==null||e(n,r),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Y.isColorLike(t)||t instanceof Xe||t instanceof Pi)}};Ns.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Ns.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 W=Ns;function xc(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=W.defaultDropShadow;i.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){U(O,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Y.isColorLike(e))s.color=e;else if(e instanceof Xe||e instanceof Pi)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){U(O,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;i.fontSize==null?i.fontSize=W.defaultTextStyle.fontSize:typeof i.fontSize=="string"?e=parseInt(i.fontSize,10):e=i.fontSize;const s=new Xe(0,0,0,e*1.7),n=t.fillGradientStops.map(r=>Y.shared.setValue(r).toNumber());n.forEach((r,a)=>{const o=a/(n.length-1);s.addColorStop(o,r)}),i.fill={fill:s}}}class yc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=Q.get().createCanvas();s.width=t,s.height=e;const n=s.getContext("2d");return{canvas:s,context:n}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=nn(t),e=nn(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,r=(s<<17)+(n<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const jn=new yc,wc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Ts(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let n=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!wc.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const ss={willReadFrequently:!0},Tt=class M{static get experimentalLetterSpacingSupported(){let t=M._experimentalLetterSpacingSupported;if(t!==void 0){const e=Q.get().getCanvasRenderingContext2D().prototype;t=M._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,r,a,o,h,l){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=r,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,s=M._canvas,n=e.wordWrap){var _;const r=`${t}:${e.styleKey}`;if(M._measurementCache[r])return M._measurementCache[r];const a=Ts(e),o=M.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=M.__context;h.font=a;const c=(n?M._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),d=new Array(c.length);let f=0;for(let b=0;b<c.length;b++){const S=M._measureText(c[b],e.letterSpacing,h);d[b]=S,f=Math.max(f,S)}const g=((_=e._stroke)==null?void 0:_.width)||0;let m=f+g;e.dropShadow&&(m+=e.dropShadow.distance);const y=e.lineHeight||o.fontSize;let x=Math.max(y,o.fontSize+g)+(c.length-1)*(y+e.leading);return e.dropShadow&&(x+=e.dropShadow.distance),new M(t,e,m,x,c,d,y+e.leading,f,o)}static _measureText(t,e,s){let n=!1;M.experimentalLetterSpacingSupported&&(M.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,n=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));let r=s.measureText(t).width;return r>0&&(n?r-=e:r+=(M.graphemeSegmenter(t).length-1)*e),r}static _wordWrap(t,e,s=M._canvas){const n=s.getContext("2d",ss);let r=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,d=M._collapseSpaces(c),f=M._collapseNewlines(c);let g=!d;const m=e.wordWrapWidth+l,y=M._tokenize(t);for(let x=0;x<y.length;x++){let w=y[x];if(M._isNewline(w)){if(!f){o+=M._addLine(a),g=!d,a="",r=0;continue}w=" "}if(d){const b=M.isBreakingSpace(w),S=M.isBreakingSpace(a[a.length-1]);if(b&&S)continue}const _=M._getFromCache(w,l,h,n);if(_>m)if(a!==""&&(o+=M._addLine(a),a="",r=0),M.canBreakWords(w,e.breakWords)){const b=M.wordWrapSplit(w);for(let S=0;S<b.length;S++){let A=b[S],F=A,P=1;for(;b[S+P];){const v=b[S+P];if(!M.canBreakChars(F,v,w,S,e.breakWords))A+=v;else break;F=v,P++}S+=P-1;const k=M._getFromCache(A,l,h,n);k+r>m&&(o+=M._addLine(a),g=!1,a="",r=0),a+=A,r+=k}}else{a.length>0&&(o+=M._addLine(a),a="",r=0);const b=x===y.length-1;o+=M._addLine(w,!b),g=!1,a="",r=0}else _+r>m&&(g=!1,o+=M._addLine(a),a="",r=0),(a.length>0||!M.isBreakingSpace(w)||g)&&(a+=w,r+=_)}return o+=M._addLine(a,!1),o}static _addLine(t,e=!0){return t=M._trimRight(t),t=e?`${t}
`:t,t}static _getFromCache(t,e,s,n){let r=s[t];return typeof r!="number"&&(r=M._measureText(t,e,n)+e,s[t]=r),r}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!M.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:M._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:M._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let n=0;n<t.length;n++){const r=t[n],a=t[n+1];if(M.isBreakingSpace(r,a)||M._isNewline(r)){s!==""&&(e.push(s),s=""),e.push(r);continue}s+=r}return s!==""&&e.push(s),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,n,r){return!0}static wordWrapSplit(t){return M.graphemeSegmenter(t)}static measureFont(t){if(M._fonts[t])return M._fonts[t];const e=M._context;e.font=t;const s=e.measureText(M.METRICS_STRING+M.BASELINE_SYMBOL),n={ascent:s.actualBoundingBoxAscent,descent:s.actualBoundingBoxDescent,fontSize:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent};return M._fonts[t]=n,n}static clearMetrics(t=""){t?delete M._fonts[t]:M._fonts={}}static get _canvas(){if(!M.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",ss);if(s!=null&&s.measureText)return M.__canvas=e,e;t=Q.get().createCanvas()}catch{t=Q.get().createCanvas()}t.width=t.height=10,M.__canvas=t}return M.__canvas}static get _context(){return M.__context||(M.__context=M._canvas.getContext("2d",ss)),M.__context}};Tt.METRICS_STRING="|ÉqÅ";Tt.BASELINE_SYMBOL="M";Tt.BASELINE_MULTIPLIER=1.4;Tt.HEIGHT_MULTIPLIER=2;Tt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})();Tt.experimentalLetterSpacing=!1;Tt._fonts={};Tt._newlines=[10,13];Tt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];Tt._measurementCache={};let As=Tt;function qn(i,t){if(i.texture===z.WHITE&&!i.fill)return Y.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Pi){const e=i.fill,s=t.createPattern(e.texture.source.resource,"repeat"),n=e.transform.copyTo(H.shared);return n.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(n),s}else if(i.fill instanceof Xe){const e=i.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(n=>{s.addColorStop(n.offset,Y.shared.setValue(n.color).toHex())}),s}}}else{const e=t.createPattern(i.texture.source.resource,"repeat"),s=i.matrix.copyTo(H.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),e.setTransform(s),e}return st("FillStyle not recognised",i),"red"}function ya(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e<s;e++){const n=i[e];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);if(n[0].length===0||n[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const r=n[0].charCodeAt(0),a=n[1].charCodeAt(0);if(a<r)throw new Error("[BitmapFont]: Invalid character range.");for(let o=r,h=a;o<=h;o++)t.push(String.fromCharCode(o))}else t.push(...Array.from(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const wa=class _a extends Qr{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;const e={..._a.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;const s=e.style.clone();e.overrideFill&&(s._fill.color=16777215,s._fill.alpha=1,s._fill.texture=z.WHITE,s._fill.fill=null),this.applyFillAsTint=e.overrideFill;const n=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const r=Ts(s);e.overrideSize?s._stroke&&(s._stroke.width*=this.baseRenderedFontSize/n):s.fontSize=this.baseRenderedFontSize=n,this._style=s,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,this.fontMetrics=As.measureFont(r),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(t){var y,x;const e=ya(t).filter(w=>!this._currentChars.includes(w)).filter((w,_,b)=>b.indexOf(w)===_);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:n,context:r}=s.canvasAndContext,a=s.texture.source;const o=this._style;let h=this._currentX,l=this._currentY;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c,f=o.fontStyle==="italic"?2:1;let g=0,m=!1;for(let w=0;w<e.length;w++){const _=e[w],b=As.measureText(_,o,n,!1);b.lineHeight=b.height;const S=f*b.width*c,A=b.height*c,F=S+d*2,P=A+d*2;if(m=!1,_!==`
`&&_!=="\r"&&_!==" "&&_!==" "&&(m=!0,g=Math.ceil(Math.max(P,g))),h+F>this._textureSize&&(l+=g,g=P,h=0,l+g>this._textureSize)){a.update();const v=this._nextPage();n=v.canvasAndContext.canvas,r=v.canvasAndContext.context,a=v.texture.source,l=0}const k=S/c-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((x=o._stroke)==null?void 0:x.width)??0);if(this.chars[_]={id:_.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},m){this._drawGlyph(r,b,h+d,l+d,c,o);const v=a.width*c,T=a.height*c,Z=new I(h/v*a.width,l/T*a.height,F/v*a.width,P/T*a.height);this.chars[_].texture=new z({source:a,frame:Z}),h+=Math.ceil(F)}}a.update(),this._currentX=h,this._currentY=l,this._skipKerning&&this._applyKerning(e,r)}get pageTextures(){return U(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const s=this._measureCache;for(let n=0;n<t.length;n++){const r=t[n];for(let a=0;a<this._currentChars.length;a++){const o=this._currentChars[a];let h=s[r];h||(h=s[r]=e.measureText(r).width);let l=s[o];l||(l=s[o]=e.measureText(o).width);let c=e.measureText(r+o).width,d=c-(h+l);d&&(this.chars[r].kerning[o]=d),c=e.measureText(r+o).width,d=c-(h+l),d&&(this.chars[o].kerning[r]=d)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=jn.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const s=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new z({source:new Ce({resource:e.canvas,resolution:s,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})}),r={canvasAndContext:e,texture:n};return this.pages[this._currentPageIndex]=r,r}_setupContext(t,e,s){e.fontSize=this.baseRenderedFontSize,t.scale(s,s),t.font=Ts(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const n=e._stroke,r=(n==null?void 0:n.width)??0;if(n&&(t.lineWidth=r,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=qn(n,t)),e._fill&&(t.fillStyle=qn(e._fill,t)),e.dropShadow){const a=e.dropShadow,o=Y.shared.setValue(a.color).toArray(),h=a.blur*s,l=a.distance*s;t.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(a.angle)*l,t.shadowOffsetY=Math.sin(a.angle)*l}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,s,n,r,a){const o=e.text,h=e.fontProperties,l=a._stroke,c=((l==null?void 0:l.width)??0)*r,d=s+c/2,f=n-c/2,g=h.descent*r,m=e.lineHeight*r;a.stroke&&c&&t.strokeText(o,d,f+m-g),a._fill&&t.fillText(o,d,f+m-g)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:s}=this.pages[t];e.canvas.width=e.canvas.width,jn.returnCanvasAndContext(e),s.destroy(!0)}this.pages=null}};wa.defaultOptions={textureSize:512,style:new W,mipmap:!0};let Kn=wa;function _c(i,t,e,s){const n={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};n.offsetY=e.baseLineOffset;let r=n.lines[0],a=null,o=!0;const h={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},l=m=>{const y=r.width;for(let x=0;x<h.index;x++){const w=m.positions[x];r.chars.push(m.chars[x]),r.charPositions.push(w+y)}r.width+=m.width,o=!1,h.width=0,h.index=0,h.chars.length=0},c=()=>{let m=r.chars.length-1;if(s){let y=r.chars[m];for(;y===" ";)r.width-=e.chars[y].xAdvance,y=r.chars[--m]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,n.lines.push(r),n.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,f=t.letterSpacing*d,g=t.wordWrapWidth*d;for(let m=0;m<i.length+1;m++){let y;const x=m===i.length;x||(y=i[m]);const w=e.chars[y]||e.chars[" "];if(/(?:\s)/.test(y)||y==="\r"||y===`
`||x){if(!o&&t.wordWrap&&r.width+h.width-f>g?(c(),l(h),x||r.charPositions.push(0)):(h.start=r.width,l(h),x||r.charPositions.push(0)),y==="\r"||y===`
`)r.width!==0&&c();else if(!x){const A=w.xAdvance+(w.kerning[a]||0)+f;r.width+=A,r.spaceWidth=A,r.spacesIndex.push(r.charPositions.length),r.chars.push(y)}}else{const S=w.kerning[a]||0,A=w.xAdvance+S+f;h.positions[h.index++]=h.width+S,h.chars.push(y),h.width+=A}a=y}return c(),t.align==="center"?bc(n):t.align==="right"?Sc(n):t.align==="justify"&&vc(n),n}function bc(i){for(let t=0;t<i.lines.length;t++){const e=i.lines[t],s=i.width/2-e.width/2;for(let n=0;n<e.charPositions.length;n++)e.charPositions[n]+=s}}function Sc(i){for(let t=0;t<i.lines.length;t++){const e=i.lines[t],s=i.width-e.width;for(let n=0;n<e.charPositions.length;n++)e.charPositions[n]+=s}}function vc(i){const t=i.width;for(let e=0;e<i.lines.length;e++){const s=i.lines[e];let n=0,r=s.spacesIndex[n++],a=0;const o=s.spacesIndex.length,l=(t-s.width)/o;for(let c=0;c<s.charPositions.length;c++)c===r&&(r=s.spacesIndex[n++],a+=l),s.charPositions[c]+=a}}let ui=0;class Cc{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(t,e){var a;let s=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke)s+=e._fill.fill.styleKey,n=!1;else if(e._stroke||e.dropShadow){let o=e.styleKey;o=o.substring(0,o.lastIndexOf("-")),s=`${o}-bitmap`,n=!1}if(!q.has(s)){const o=new Kn({style:e,overrideFill:n,overrideSize:!0,...this.defaultOptions});ui++,ui>50&&st("BitmapText",`You have dynamically created ${ui} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{ui--,q.remove(s)}),q.set(s,o)}const r=q.get(s);return(a=r.ensureCharacters)==null||a.call(r,t),r}getLayout(t,e,s=!0){const n=this.getFont(t,e);return _c([...t],e,n,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var l,c,d,f;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(l=t[2])==null?void 0:l.chars,resolution:(c=t[2])==null?void 0:c.resolution,padding:(d=t[2])==null?void 0:d.padding,skipKerning:(f=t[2])==null?void 0:f.skipKerning},U(O,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=e==null?void 0:e.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const n=e.style,r=n instanceof W?n:new W(n),a=r._fill.fill!==null&&r._fill.fill!==void 0,o=new Kn({style:r,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=ya(e.chars);return o.ensureCharacters(h.join("")),q.set(`${s}-bitmap`,o),o.once("destroy",()=>q.remove(`${s}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,s=q.get(e);s&&(q.remove(e),s.destroy())}}const Zn=new Cc;class ba extends Qr{constructor(t,e){super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(r=>{const a=n.pages[parseInt(r,10)],o=s[a.id];this.pages.push({texture:o})}),Object.keys(n.chars).forEach(r=>{const a=n.chars[r],{frame:o,source:h}=s[a.page],l=new I(a.x+o.x,a.y+o.y,a.width,a.height),c=new z({source:h,frame:l});this.chars[r]={id:r.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:c}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){Zn.install(t)}static uninstall(t){Zn.uninstall(t)}}const ns={test(i){return typeof i=="string"&&i.startsWith("info face=")},parse(i){const t=i.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const d in t){const f=t[d].match(/^[a-z]+/gm)[0],g=t[d].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),m={};for(const y in g){const x=g[y].split("="),w=x[0],_=x[1].replace(/"/gm,""),b=parseFloat(_),S=isNaN(b)?_:b;m[w]=S}e[f].push(m)}const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[n]=e.info,[r]=e.common,[a]=e.distanceField??[];a&&(s.distanceField={range:parseInt(a.distanceRange,10),type:a.fieldType}),s.fontSize=parseInt(n.size,10),s.fontFamily=n.face,s.lineHeight=parseInt(r.lineHeight,10);const o=e.page;for(let d=0;d<o.length;d++)s.pages.push({id:parseInt(o[d].id,10)||0,file:o[d].file});const h={};s.baseLineOffset=s.lineHeight-parseInt(r.base,10);const l=e.char;for(let d=0;d<l.length;d++){const f=l[d],g=parseInt(f.id,10);let m=f.letter??f.char??String.fromCharCode(g);m==="space"&&(m=" "),h[g]=m,s.chars[m]={id:g,page:parseInt(f.page,10)||0,x:parseInt(f.x,10),y:parseInt(f.y,10),width:parseInt(f.width,10),height:parseInt(f.height,10),xOffset:parseInt(f.xoffset,10),yOffset:parseInt(f.yoffset,10),xAdvance:parseInt(f.xadvance,10),kerning:{}}}const c=e.kerning||[];for(let d=0;d<c.length;d++){const f=parseInt(c[d].first,10),g=parseInt(c[d].second,10),m=parseInt(c[d].amount,10);s.chars[h[g]].kerning[h[f]]=m}return s}},Qn={test(i){const t=i;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(i){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=i.getElementsByTagName("info")[0],s=i.getElementsByTagName("common")[0],n=i.getElementsByTagName("distanceField")[0];n&&(t.distanceField={type:n.getAttribute("fieldType"),range:parseInt(n.getAttribute("distanceRange"),10)});const r=i.getElementsByTagName("page"),a=i.getElementsByTagName("char"),o=i.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let l=0;l<r.length;l++)t.pages.push({id:parseInt(r[l].getAttribute("id"),10)||0,file:r[l].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(s.getAttribute("base"),10);for(let l=0;l<a.length;l++){const c=a[l],d=parseInt(c.getAttribute("id"),10);let f=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(d);f==="space"&&(f=" "),h[d]=f,t.chars[f]={id:d,page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xOffset:parseInt(c.getAttribute("xoffset"),10),yOffset:parseInt(c.getAttribute("yoffset"),10),xAdvance:parseInt(c.getAttribute("xadvance"),10),kerning:{}}}for(let l=0;l<o.length;l++){const c=parseInt(o[l].getAttribute("first"),10),d=parseInt(o[l].getAttribute("second"),10),f=parseInt(o[l].getAttribute("amount"),10);t.chars[h[d]].kerning[h[c]]=f}return t}},Jn={test(i){return typeof i=="string"&&i.includes("<font>")?Qn.test(Q.get().parseXML(i)):!1},parse(i){return Qn.parse(Q.get().parseXML(i))}},Tc=[".xml",".fnt"],Ac={extension:{type:G.CacheParser,name:"cacheBitmapFont"},test:i=>i instanceof ba,getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Mc={extension:{type:G.LoadParser,priority:Xt.Normal},name:"loadBitmapFont",test(i){return Tc.includes(xt.extname(i).toLowerCase())},async testParse(i){return ns.test(i)||Jn.test(i)},async parse(i,t,e){const s=ns.test(i)?ns.parse(i):Jn.parse(i),{src:n}=t,{pages:r}=s,a=[],o=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;d<r.length;++d){const f=r[d].file;let g=xt.join(xt.dirname(n),f);g=us(g,n),a.push({src:g,data:o})}const h=await e.load(a),l=a.map(d=>h[d.src]);return new ba({data:s,textures:l},n)},async load(i,t){return await(await Q.get().fetch(i)).text()},async unload(i,t,e){await Promise.all(i.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),i.destroy()}};class Pc{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;s<e;s++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Gc={extension:{type:G.CacheParser,name:"cacheTextureArray"},test:i=>Array.isArray(i)&&i.every(t=>t instanceof z),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((n,r)=>{e[s+(r===0?"":r+1)]=n})}),e}};async function Sa(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const kc={extension:{type:G.DetectionParser,priority:1},test:async()=>Sa("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},tr=["png","jpg","jpeg"],Bc={extension:{type:G.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...tr],remove:async i=>i.filter(t=>!tr.includes(t))},Ic="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Os(i){return Ic?!1:document.createElement("video").canPlayType(i)!==""}const Ec={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},Rc={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},Fc={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Lc={extension:{type:G.DetectionParser,priority:0},test:async()=>Sa("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};class Dc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var a,o;let n=null,r=null;if(e.loadParser&&(r=this._parserHash[e.loadParser],r||st(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!r){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((a=l.test)!=null&&a.call(l,t,e,this))){r=l;break}}if(!r)return st(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}n=await r.load(t,e,this),s.parser=r;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((o=l.testParse)==null?void 0:o.call(l,n,e,this))&&(n=await l.parse(n,e,this)||n,s.parser=l)}return n})(),s}async load(t,e){this._parsersValidated||this._validateParsers();let s=0;const n={},r=wi(t),a=vt(t,l=>({alias:[l],src:l,data:{}})),o=a.length,h=a.map(async l=>{const c=xt.toAbsolute(l.src);if(!n[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),n[l.src]=await this.promiseCache[c].promise,e&&e(++s/o)}catch(d){throw delete this.promiseCache[c],delete n[l.src],new Error(`[Loader.load] Failed to load ${c}.
${d}`)}});return await Promise.all(h),r?n[a[0].src]:n}async unload(t){const s=vt(t,n=>({alias:[n],src:n})).map(async n=>{var o,h;const r=xt.toAbsolute(n.src),a=this.promiseCache[r];if(a){const l=await a.promise;delete this.promiseCache[r],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,l,n,this))}});await Promise.all(s)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&st(`[Assets] loadParser name conflict "${e.name}"`):st("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function Ae(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function Me(i,t){const e=i.split("?")[0],s=xt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const zc=".json",Uc="application/json",Nc={extension:{type:G.LoadParser,priority:Xt.Low},name:"loadJson",test(i){return Ae(i,Uc)||Me(i,zc)},async load(i){return await(await Q.get().fetch(i)).json()}},Oc=".txt",Wc="text/plain",Hc={name:"loadTxt",extension:{type:G.LoadParser,priority:Xt.Low,name:"loadTxt"},test(i){return Ae(i,Wc)||Me(i,Oc)},async load(i){return await(await Q.get().fetch(i)).text()}},$c=["normal","bold","100","200","300","400","500","600","700","800","900"],Vc=[".ttf",".otf",".woff",".woff2"],Yc=["font/ttf","font/otf","font/woff","font/woff2"],Xc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function jc(i){const t=xt.extname(i),n=xt.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let r=n.length>0;for(const o of n)if(!o.match(Xc)){r=!1;break}let a=n.join(" ");return r||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const qc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Kc(i){return qc.test(i)?i:encodeURI(i)}const Zc={extension:{type:G.LoadParser,priority:Xt.Low},name:"loadWebFont",test(i){return Ae(i,Yc)||Me(i,Vc)},async load(i,t){var s,n,r;const e=Q.get().getFontFaceSet();if(e){const a=[],o=((s=t.data)==null?void 0:s.family)??jc(i),h=((r=(n=t.data)==null?void 0:n.weights)==null?void 0:r.filter(c=>$c.includes(c)))??["normal"],l=t.data??{};for(let c=0;c<h.length;c++){const d=h[c],f=new FontFace(o,`url(${Kc(i)})`,{...l,weight:d});await f.load(),e.add(f),a.push(f)}return q.set(`${o}-and-url`,{url:i,fontFaces:a}),a.length===1?a[0]:a}return st("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(i){(Array.isArray(i)?i:[i]).forEach(t=>{q.remove(t.family),Q.get().getFontFaceSet().delete(t)})}};function Ws(i,t=1){var s;const e=(s=Te.RETINA_PREFIX)==null?void 0:s.exec(i);return e?parseFloat(e[1]):t}function Hs(i,t,e){i.label=e,i._sourceOrigin=e;const s=new z({source:i,label:e}),n=()=>{delete t.promiseCache[e],q.has(e)&&q.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(st("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),n())}),s.once("destroy",()=>{i.destroyed||(st("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),s}const Qc=".svg",Jc="image/svg+xml",td={extension:{type:G.LoadParser,priority:Xt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return Ae(i,Jc)||Me(i,Qc)},async load(i,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?id(i):ed(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function ed(i,t,e,s){var x,w,_;const r=await(await Q.get().fetch(i)).blob(),a=URL.createObjectURL(r),o=new Image;o.src=a,o.crossOrigin=s,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),l=h.getContext("2d"),c=((x=t.data)==null?void 0:x.resolution)||Ws(i),d=((w=t.data)==null?void 0:w.width)??o.width,f=((_=t.data)==null?void 0:_.height)??o.height;h.width=d*c,h.height=f*c,l.drawImage(o,0,0,d*c,f*c);const{parseAsGraphicsContext:g,...m}=t.data,y=new Ce({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:c,...m});return Hs(y,e,i)}async function id(i){const e=await(await Q.get().fetch(i)).text(),s=new yt;return s.svg(e),s}const sd=`(function () {
'use strict';
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
async function checkImageBitmap() {
try {
if (typeof createImageBitmap !== "function")
return false;
const response = await fetch(WHITE_PNG);
const imageBlob = await response.blob();
const imageBitmap = await createImageBitmap(imageBlob);
return imageBitmap.width === 1 && imageBitmap.height === 1;
} catch (e) {
return false;
}
}
void checkImageBitmap().then((result) => {
self.postMessage(result);
});
})();
`;let fe=null,Ms=class{constructor(){fe||(fe=URL.createObjectURL(new Blob([sd],{type:"application/javascript"}))),this.worker=new Worker(fe)}};Ms.revokeObjectURL=function(){fe&&(URL.revokeObjectURL(fe),fe=null)};const nd=`(function () {
'use strict';
async function loadImageBitmap(url, alphaMode) {
const response = await fetch(url);
if (!response.ok) {
throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
}
const imageBlob = await response.blob();
return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
}
self.onmessage = async (event) => {
try {
const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
self.postMessage({
data: imageBitmap,
uuid: event.data.uuid,
id: event.data.id
}, [imageBitmap]);
} catch (e) {
self.postMessage({
error: e,
uuid: event.data.uuid,
id: event.data.id
});
}
};
})();
`;let pe=null;class va{constructor(){pe||(pe=URL.createObjectURL(new Blob([nd],{type:"application/javascript"}))),this.worker=new Worker(pe)}}va.revokeObjectURL=function(){pe&&(URL.revokeObjectURL(pe),pe=null)};let er=0,rs;class rd{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 Ms;e.addEventListener("message",s=>{e.terminate(),Ms.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){rs===void 0&&(rs=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<rs&&(this._createdWorkers++,t=new va().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((n,r)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:r})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[er]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:er++,id:s})}}const ir=new rd,ad=[".jpeg",".jpg",".png",".webp",".avif"],od=["image/jpeg","image/png","image/webp","image/avif"];async function hd(i,t){var n;const e=await Q.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return((n=t==null?void 0:t.data)==null?void 0:n.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const Ca={name:"loadTextures",extension:{type:G.LoadParser,priority:Xt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Ae(i,od)||Me(i,ad)},async load(i,t,e){var r;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ir.isImageBitmapSupported()?s=await ir.loadImageBitmap(i,t):s=await hd(i,t):s=await new Promise(a=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=i,s.complete?a(s):s.onload=()=>{a(s)}});const n=new Ce({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((r=t.data)==null?void 0:r.resolution)||Ws(i),...t.data});return Hs(n,e,i)},unload(i){i.destroy(!0)}},Ta=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],ld=Ta.map(i=>`video/${i.substring(1)}`);function cd(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=ud(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function dd(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",n),i.load();function s(){r(),t()}function n(a){r(),e(a)}function r(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",n)}})}function ud(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const fd={name:"loadVideo",extension:{type:G.LoadParser,name:"loadVideo"},test(i){const t=Ae(i,ld),e=Me(i,Ta);return t||e},async load(i,t,e){var h,l;const s={...fi.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Ws(i),alphaMode:((l=t.data)==null?void 0:l.alphaMode)||await Pr(),...t.data},n=document.createElement("video"),r={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(r).forEach(c=>{const d=r[c];d!==void 0&&n.setAttribute(c,d)}),s.muted===!0&&(n.muted=!0),cd(n,i,s.crossorigin);const a=document.createElement("source");let o;if(i.startsWith("data:"))o=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){const c=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();o=fi.MIME_TYPES[c]||`video/${c}`}return a.src=i,o&&(a.type=o),new Promise(c=>{const d=async()=>{const f=new fi({...s,resource:n});n.removeEventListener("canplay",d),t.data.preload&&await dd(n),c(Hs(f,e,i))};n.addEventListener("canplay",d),n.appendChild(a)})},unload(i){i.destroy(!0)}},Aa={extension:{type:G.ResolveParser,name:"resolveTexture"},test:Ca.test,parse:i=>{var t;return{resolution:parseFloat(((t=Te.RETINA_PREFIX.exec(i))==null?void 0:t[1])??"1"),format:i.split(".").pop(),src:i}}},pd={extension:{type:G.ResolveParser,priority:-2,name:"resolveJson"},test:i=>Te.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:Aa.parse};class gd{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Te,this.loader=new Dc,this.cache=q,this._backgroundLoader=new Pc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var r,a;if(this._initialized){st("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((r=t.texturePreference)==null?void 0:r.resolution)??1,s=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:s}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=wi(t),n=vt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(l=>!this.resolver.hasKey(l))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),r=this.resolver.resolve(n),a=await this._mapLoadToResolve(r,e);return s?a[n[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const n=this.resolver.resolveBundle(t),r={},a=Object.keys(n);let o=0,h=0;const l=()=>{e==null||e(++o/h)},c=a.map(d=>{const f=n[d];return h+=Object.keys(f).length,this._mapLoadToResolve(f,l).then(g=>{r[d]=g})});return await Promise.all(c),s?r[t[0]]:r}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return q.get(t);const e={};for(let s=0;s<t.length;s++)e[s]=q.get(t[s]);return e}async _mapLoadToResolve(t,e){const s=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const n=await this.loader.load(s,e);this._backgroundLoader.active=!0;const r={};return s.forEach(a=>{const o=n[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(l=>{r[l]=o}),q.set(h,o)}),r}async unload(t){this._initialized||await this.init();const e=vt(t).map(n=>typeof n!="string"?n.src:n),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=vt(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{q.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,n)=>e.indexOf(s)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Ne=new gd;dt.handleByList(G.LoadParser,Ne.loader.parsers).handleByList(G.ResolveParser,Ne.resolver.parsers).handleByList(G.CacheParser,Ne.cache.parsers).handleByList(G.DetectionParser,Ne.detections);dt.add(Gc,Bc,kc,Lc,Ec,Rc,Fc,Nc,Hc,Zc,td,Ca,fd,Mc,Ac,Aa,pd);const sr={loader:G.LoadParser,resolver:G.ResolveParser,cache:G.CacheParser,detection:G.DetectionParser};dt.handle(G.Asset,i=>{const t=i.ref;Object.entries(sr).filter(([e])=>!!t[e]).forEach(([e,s])=>dt.add(Object.assign(t[e],{extension:t[e].extension??s})))},i=>{const t=i.ref;Object.keys(sr).filter(e=>!!t[e]).forEach(e=>dt.remove(t[e]))});class Ct extends vi{constructor(t){t instanceof yt&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new yt,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new Ct(this._context.clone()):(this._ownedContext=null,new Ct(this._context))}lineStyle(t,e,s){U(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),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){U(O,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){U(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!==yt.defaultStrokeStyle.width||t.color!==yt.defaultStrokeStyle.color||t.alpha!==yt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return U(O,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return U(O,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return U(O,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return U(O,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return U(O,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return U(O,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Ma=class Pa extends ra{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(U(O,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...Pa.defaultOptions,...e};const s=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),r=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Vt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),h=new Vt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),l=new Vt({data:r,label:"index-mesh-buffer",shrinkToFit:a,usage:it.INDEX|it.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:l,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Ma.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let md=Ma;class we extends ${constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:s,autoUpdate:n,...r}=e,[a]=s;super({...r,texture:a instanceof z?a:a.texture}),this._textures=null,this._durations=null,this._autoUpdate=n??!0,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=s}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(It.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(It.shared.add(this.update,this,yi.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,s=this.animationSpeed*e,n=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=s/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=s;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<n||this.animationSpeed<0&&this.currentFrame>n)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;s<t.length;++s)e.push(z.from(t[s]));return new we(e)}static fromImages(t){const e=[];for(let s=0;s<t.length;++s)e.push(z.from(t[s]));return new we(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof z)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.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?(It.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(It.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class xd extends vi{constructor(t,e){const{text:s,resolution:n,style:r,anchor:a,width:o,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=l??!1,o!==void 0&&(this.width=o),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-s*this.anchor.y,t.y>=r&&t.y<=r+s)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function yd(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(U(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class N extends xd{constructor(...t){const e=yd(t,"Text");super(e,W),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=As.measureText(this._text,this._style),{width:n,height:r}=s;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}}const Ga=class ka extends md{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(U(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={...ka.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;const e=this.verticesX*this.verticesY,s=[],n=[],r=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,l=this.height/o;for(let d=0;d<e;d++){const f=d%this.verticesX,g=d/this.verticesX|0;s.push(f*h,g*l),n.push(f/a,g/o)}const c=a*o;for(let d=0;d<c;d++){const f=d%a,g=d/a|0,m=g*this.verticesX+f,y=g*this.verticesX+f+1,x=(g+1)*this.verticesX+f,w=(g+1)*this.verticesX+f+1;r.push(m,y,x,y,w,x)}this.buffers[0].data=new Float32Array(s),this.buffers[1].data=new Float32Array(n),this.indexBuffer.data=new Uint32Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Ga.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let wd=Ga;const Ba=class Ia extends wd{constructor(t={}){t={...Ia.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,s=this.width>e?1:this.width/e,n=this._topHeight+this._bottomHeight,r=this.height>n?1:this.height/n,a=Math.min(s,r);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};Ba.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ce=Ba;const Ea=class Ra extends vi{constructor(t){var d,f,g,m;t instanceof z&&(t={texture:t});const{width:e,height:s,leftWidth:n,rightWidth:r,topHeight:a,bottomHeight:o,texture:h,roundPixels:l,...c}=t;super({label:"NineSliceSprite",...c}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=n??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.left)??ce.defaultOptions.leftWidth,this._topHeight=a??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.top)??ce.defaultOptions.topHeight,this._rightWidth=r??((g=h==null?void 0:h.defaultBorders)==null?void 0:g.right)??ce.defaultOptions.rightWidth,this._bottomHeight=o??((m=h==null?void 0:h.defaultBorders)==null?void 0:m.bottom)??ce.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??ce.defaultOptions.width,this.bounds.maxY=this._height=s??h.height??ce.defaultOptions.height,this.allowChildren=!1,this.texture=h??Ra.defaultOptions.texture,this.roundPixels=l??!1}get bounds(){return this._bounds}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=this._height=t,this.onViewUpdate()}setSize(t,e){typeof t=="object"&&(e=t.height??t.width,t=t.width),this.bounds.maxX=this._width=t,this.bounds.maxY=this._height=e??t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=z.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null}};Ea.defaultOptions={texture:z.EMPTY};let _t=Ea;dt.add(Ha,$a);const R=class R{static async Load(t){return this.text.text=`Loading asset: ${t} (${this.counter}/99)`,this.counter++,await Ne.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 N({text:"Loading textures. This might take a while.",style:new W({fill:3355443,fontSize:50})});t.x=u.app.canvas.width/2,t.y=u.app.canvas.height/2,t.anchor.set(.5,.5),u.app.stage.addChild(t),this.text=new N({text:"",style:new W({fill:3355443,fontSize:50})}),this.text.x=u.app.canvas.width/2,this.text.y=u.app.canvas.height/2+50,this.text.anchor.set(.5,.5),u.app.stage.addChild(this.text),await Promise.all([this.Load("./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/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/background_02.png").then(e=>this.FrameTowerTab=e),this.Load("./assets/gui/frame_red.png").then(e=>this.RedBackground=e),this.Load("./assets/gui/frame_green.png").then(e=>this.GreenBackground=e),this.Load("./assets/gui/frame_blue.png").then(e=>this.BlueBackground=e),this.Load("./assets/gui/frame_yellow.png").then(e=>this.YellowBackground=e),this.Load("./assets/gui/banner_01.png").then(e=>this.BannerGemsmith=e),this.Load("./assets/gui/note.png").then(e=>this.EndScreenDialog=e),this.Load("./assets/gui/main_background.jpg").then(e=>this.MainBackground=e),this.Load("./assets/tutorial/tutorial01.jpg").then(e=>this.Tutorial01=e),this.Load("./assets/tutorial/tutorial02.jpg").then(e=>this.Tutorial02=e),this.Load("./assets/tutorial/tutorial03.jpg").then(e=>this.Tutorial03=e),this.Load("./assets/tutorial/tutorial04.jpg").then(e=>this.Tutorial04=e),this.Load("./assets/tutorial/tutorial05.jpg").then(e=>this.Tutorial05=e),this.Load("./assets/gui/heart.png").then(e=>this.HealthTexture=e),this.Load("./assets/gui/money.png").then(e=>this.GoldTexture=e),this.Load("./assets/gui/wave.png").then(e=>this.WaveTexture=e),this.Load("./assets/gui/sword_02.png").then(e=>this.SwordsTexture=e),this.Load("./assets/gui/title01.png").then(e=>this.TitleTexture=e),this.Load("./assets/gui/icons/play.png").then(e=>this.PlayIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/fastforward.png").then(e=>this.FastForwardIconTexture=e),this.Load("./assets/gui/icons/cross.png").then(e=>this.XIconTexture=e),this.Load("./assets/gui/icons/plus.png").then(e=>this.PlusIconTexture=e),this.LoadMissions(),this.LoadTowers(),this.LoadCreeps(),this.LoadGems()]),t.destroy(),this.text.destroy(),this.text=!0}static async LoadGems(){const e=await(await fetch("./assets/json/Gems.json")).json();this.Gems=e;for(let s=0;s<e.length;s++){const n=this.Gems[s],r=await this.Load(`./assets/gems/${n.type}_spritesheet.png`);for(let a=1;a<=n.totalLevels;a++){const o=new _i(r,{frames:{[`${n.type}_${a}.png`]:{frame:{x:(a-1)*64,y:0,w:64,h:64},rotated:!1,trimmed:!1,spriteSourceSize:{x:0,y:0,w:64,h:64},sourceSize:{w:64,h:64}}},meta:{image:`./assets/gems/${n.type}_spritesheet.png`,format:"RGBA8888",size:{w:64*n.totalLevels,h:64},scale:"1"}});await o.parse(),n.textures[a-1]=o.textures[`${n.type}_${a}.png`]}}for(let s=0;s<7;s++)this.GemAmountIcons[s]=await this.Load(`./assets/gui/gem_amount_${s}.png`)}static async LoadCreeps(){const e=await(await fetch("./assets/json/Creeps.json")).json();this.Creeps=e;for(let s=0;s<this.Creeps.length;s++){const n=this.Creeps[s],r=await this.Load(`./assets/creeps/${n.sprite}_spritesheet.png`);for(let a=0;a<n.textureArrayLength;a++){const o=new _i(r,{frames:{[`${n.sprite}_${a}.png`]:{frame:{x:a*128,y:0,w:128,h:128},rotated:!1,trimmed:!1,spriteSourceSize:{x:0,y:0,w:128,h:128},sourceSize:{w:128,h:128}}},meta:{image:`./assets/creeps/${n.sprite}/spritesheet.png`,format:"RGBA8888",size:{w:128*n.textureArrayLength,h:128},scale:"1"}});await o.parse(),n.textures[a]=o.textures[`${n.sprite}_${a}.png`]}}}static async LoadMissions(){await this.LoadMission("./assets/missions/01_first_steps.json"),await this.LoadMission("./assets/missions/02_the_turn.json"),await this.LoadMission("./assets/missions/03_fork_in_the_road.json"),await this.LoadMission("./assets/missions/04_crossroads.json"),await this.LoadMission("./assets/missions/05_the_maze.json"),await this.LoadMission("./assets/missions/06_multiple_fronts.json"),await this.LoadMission("./assets/missions/07_final_stretch.json")}static async LoadTowers(){const e=await(await fetch("./assets/json/Towers.json")).json();this.Towers=e;for(let s=0;s<this.Towers.length;s++){const n=this.Towers[s];for(let r=0;r<n.projectileTexturesArrayLength;r++){const a=await this.Load(`./assets/projectiles/${n.projectile}/${r}.png`);n.projectileTextures[r]=a}n.texture=await this.Load(`./assets/towers/${n.sprite}.png`)}for(let s=0;s<4;s++)this.SpecialLightning[s]=await this.Load(`./assets/projectiles/lightning/${s}.png`)}static async LoadMission(t){const s=await(await fetch(t)).json();R.Missions.push(s),R.MissionBackgrounds.push(await this.Load(s.mapImage.url))}};p(R,"MainBackground"),p(R,"Frame01Texture"),p(R,"Frame02Texture"),p(R,"Frame03Texture"),p(R,"Frame04Texture"),p(R,"Frame05Texture"),p(R,"FrameTowerTab"),p(R,"RedBackground"),p(R,"GreenBackground"),p(R,"BlueBackground"),p(R,"YellowBackground"),p(R,"Button01Texture"),p(R,"Button02Texture"),p(R,"HealthTexture"),p(R,"GoldTexture"),p(R,"WaveTexture"),p(R,"SwordsTexture"),p(R,"TitleTexture"),p(R,"BannerGemsmith"),p(R,"EndScreenDialog"),p(R,"SpecialLightning",[]),p(R,"Tutorial01"),p(R,"Tutorial02"),p(R,"Tutorial03"),p(R,"Tutorial04"),p(R,"Tutorial05"),p(R,"PlayIconTexture"),p(R,"PauseIconTexture"),p(R,"ExclamationIconTexture"),p(R,"FastForwardIconTexture"),p(R,"XIconTexture"),p(R,"PlusIconTexture"),p(R,"GemAmountIcons",[]),p(R,"Missions",[]),p(R,"MissionBackgrounds",[]),p(R,"Towers"),p(R,"Creeps"),p(R,"Gems"),p(R,"text"),p(R,"counter",0);let C=R;class Ps{constructor(t,e){p(this,"texture");p(this,"level",1);p(this,"definition");p(this,"id");this.definition=C.Gems[t],this.texture=this.definition.textures[0],e?this.id="":(this.id=u.latestGemId+1,u.latestGemId++)}currentGemImprovement(){let t={damageUp:0,attackSpeedUp:0,rangeUp:0,timeToLiveUp:0,pierceUp:0,gemValueUp:0};for(let e=0;e<this.level;e++){const s=this.definition.genericImprovements[e];t.damageUp+=s.damageUp,t.attackSpeedUp+=s.attackSpeedUp,t.rangeUp+=s.rangeUp,t.timeToLiveUp+=s.timeToLiveUp,t.pierceUp+=s.pierceUp,t.gemValueUp+=s.gemValueUp}return t}currentGemResistanceModifications(){return this.definition.gemResistanceModifications[this.level-1]}isMaxLevel(){return this.level==this.definition.totalLevels}levelUp(t){t||(t=1),this.level+=t,this.texture=this.definition.textures[this.level-1]}}var Dt=(i=>(i[i.Restricted=0]="Restricted",i[i.Buildable=1]="Buildable",i[i.Path=9]="Path",i))(Dt||{}),qe=(i=>(i[i.Basic=0]="Basic",i[i.Circle=1]="Circle",i[i.Electric=2]="Electric",i[i.Buff=3]="Buff",i[i.Strong=4]="Strong",i[i.Rail=5]="Rail",i[i.Trapper=6]="Trapper",i[i.Debuff=7]="Debuff",i))(qe||{});const J=class J{static TestSuite(){if(new URLSearchParams(location.href).entries().next().value[1]!="game")return;J.NotificationManager.Notify("Loaded testing suite.","danger");let e=C.Towers[qe.Electric];J.TowerManager.ToggleChoosingTowerLocation("RESET"),J.TowerManager.PlaceTower(e,6,10,e.behaviour,!0);for(let s=0;s<29;s++)this.GameScene.MissionStats.giveGem(new Ps(s%6),!0)}};p(J,"app"),p(J,"GameMaster"),p(J,"Grid"),p(J,"WaveManager"),p(J,"TowerManager"),p(J,"AnimationManager"),p(J,"NotificationManager"),p(J,"DebrisManager"),p(J,"GameScene"),p(J,"latestCommit"),p(J,"latestGemId",0),p(J,"GridCellSize",64),p(J,"GridColumns",25),p(J,"GridRows",17),p(J,"MouseX",0),p(J,"MouseY",0);let u=J;class _d{constructor(){p(this,"currentScene");u.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),u.GameMaster.currentScene.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),u.GameMaster.currentScene.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.currentScene=t,this.currentScene.init()}}class At{constructor(t){p(this,"name",this.constructor.name);p(this,"_container",new tt);p(this,"_events",new gt);p(this,"enabled",!0);p(this,"bb",new I);u.GameMaster._CreateGuiObject(this),t&&(this._container.interactive=!0,this._container.onwheel=e=>{this.enabled&&this.onWheel(e)},this._container.onpointerdown=e=>{this.enabled&&this.onClick(e)})}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}onClick(t){console.warn(`[${this.name} does not implement GuiObject.onClick()]`)}onWheel(t){console.warn(`[${this.name} does not implement GuiObject.onWheel()]`)}setEnabled(t){this.enabled=t}copyContainerToBB(){return this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var ht=(i=>(i[i.Button01=0]="Button01",i[i.Button02=1]="Button02",i))(ht||{});class ut extends At{constructor(e,s,n,r=!0){super(!0);p(this,"caption");p(this,"bounds");p(this,"buttonTexture");p(this,"buttonSprite");p(this,"buttonText");p(this,"buttonIcon");n==0&&(this.buttonTexture=C.Button01Texture),n==1&&(this.buttonTexture=C.Button02Texture),this.caption=s,this.enabled=r,this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.container.width=this.bounds.width,this.container.height=this.bounds.height,this.buttonSprite=new _t({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 N({text:this.caption,style:new W({fill:16777215,fontSize:24})}),this.container.addChild(this.buttonText),this.buttonText.anchor.set(.5,.5),this.buttonText.x=this.bounds.width/2,this.buttonText.y=this.bounds.height/2,this.container.x=this.bounds.x,this.container.y=this.bounds.y}setCaption(e){this.caption=e,this.buttonText.text=e}getCaption(){return this.caption}CustomButtonLogic(){console.warn(this.name+" - Button.CustomButtonLogic() is not implemented.")}}class ki{constructor(){p(this,"stage",new tt);p(this,"gui",[]);p(this,"_events",new gt);u.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this._events.removeAllListeners(),this.gui.forEach(t=>{t.destroy()})}addMainBackground(){const t=new $(C.MainBackground);t.width=u.app.canvas.width,t.height=u.app.canvas.height,this.stage.addChild(t)}get events(){return this._events}init(){}}class bd extends ki{constructor(){super(...arguments);p(this,"currentImg",1);p(this,"sprite")}init(){let e=[null,C.Tutorial01,C.Tutorial02,C.Tutorial03,C.Tutorial04,C.Tutorial05];this.sprite=new $({texture:C.Tutorial01,scale:.6,x:250,y:150}),this.stage.addChild(this.sprite);let s=new ut(new I(250,this.sprite.height+160,120,60),"Back",ht.Button01);s.container.alpha=0,s.onClick=()=>{s.container.alpha==0||this.currentImg==1||(this.currentImg--,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.sprite.texture=e[this.currentImg],this.currentImg==1&&(s.container.alpha=0))};let n=new ut(new I(this.sprite.width+130,this.sprite.height+160,120,60),"Next",ht.Button01);n.onClick=()=>{n.container.alpha!=0&&(this.currentImg++,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.currentImg!=1&&(s.container.alpha=1),this.sprite.texture=e[this.currentImg],this.currentImg==5&&(n.container.alpha=0))};const r=new ut(new I(this.sprite.width-540,this.sprite.height+160,200,60),"Main menu",ht.Button01);r.onClick=a=>{u.GameMaster.changeScene(new qs)}}}class Mt{constructor(){p(this,"name",this.constructor.name);p(this,"_container",new tt);p(this,"bb",new I);p(this,"_events",new gt)}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}copyContainerToBB(){return this.container==null?null:(this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb)}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var re=(i=>(i.CreepSpawned="creepSpawned",i.Finished="finished",i.NewWave="newwave",i))(re||{}),ot=(i=>(i.Died="died",i.TakenDamage="takenDamage",i.GiveEffect="giveEffect",i.Escaped="escaped",i.Moved="moved",i))(ot||{}),Ke=(i=>(i.CellMouseOver="cellmouseover",i.CellMouseLeave="cellmouseleave",i))(Ke||{}),_e=(i=>(i.TowerPlacedEvent="towerPlacedEvent",i.TowerSoldEvent="towerSoldEvent",i))(_e||{}),$s=(i=>(i.GemGivenEvent="gemGivenEvent",i))($s||{}),Vs=(i=>(i.TowerPanelSelectGem="towerTabSelectGem",i))(Vs||{}),kt=(i=>(i.BasicTowerBehaviour="BasicTowerBehaviour",i.CircleTowerBehaviour="CircleTowerBehaviour",i.ElectricTowerBehaviour="ElectricTowerBehaviour",i.BuffTowerBehaviour="BuffTowerBehaviour",i.StrongTowerBehaviour="StrongTowerBehaviour",i.RailTowerBehaviour="RailTowerBehaviour",i.TrapperTowerBehaviour="TrapperTowerBehaviour",i.DebuffTowerBehaviour="DebuffTowerBehaviour",i))(kt||{});class Sd{constructor(){p(this,"isPlacingTower",!1);p(this,"canPlaceTowers",!0);p(this,"selectedTower",null);p(this,"previewSprite",new $({parent:u.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));p(this,"towers",[]);u.TowerManager=this,u.GameScene.events.on(Ke.CellMouseOver,t=>{this.isPlacingTower&&(t.checkIfCantPlace()?(t.showRangePreview(!0,this.selectedTower.stats.range),this.previewSprite.tint=16711680):(t.showRangePreview(!1,this.selectedTower.stats.range),this.previewSprite.tint=16777215),this.previewSprite.x=t.column*u.GridCellSize,this.previewSprite.y=t.row*u.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),u.GameScene.events.on(Ke.CellMouseLeave,t=>{this.previewSprite.texture=null,u.Grid.rangePreview.clear()})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,u.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(u.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):C.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e,console.log(this.selectedTower))}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)return u.NotificationManager.Notify("TowerManager.selectedTower is null when trying to place tower.","danger"),console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let s=null;return this.towers.forEach(n=>{n.row==t&&n.column==e&&(s=n)}),s}PlaceTower(t,e,s,n,r){const a=t.texture;if(!u.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!r)return u.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,s)&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Path&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Restricted){r||u.GameScene.MissionStats.spendGold(t.stats.cost);let o=new Ld(e,s,a,t,n);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,u.GameScene.events.emit(_e.TowerPlacedEvent,t.name,e,s)}else u.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn")}update(t){this.towers.forEach((e,s)=>{if(e.sold){for(e.slottedGems=e.slottedGems.filter(n=>n!=null);e.slottedGems.length>0;)e.UnslotGem(0);u.GameScene.events.emit(_e.TowerSoldEvent,e.definition.name,e.row,e.column),u.GameScene.MissionStats.earnGold(e.definition.stats.cost),e.destroy(),this.towers.splice(s,1)}else e.update(t)})}}function ct(i,t,e,s){const n=e-i,r=s-t;return Math.atan2(r,n)}class Ys extends Mt{constructor(e,s,n,r,a,o,h,l,c){super();p(this,"deleteMe",!1);p(this,"sprite");p(this,"x");p(this,"y");p(this,"angle");p(this,"speed");p(this,"damage");p(this,"pierce",1);p(this,"timeToLive");p(this,"parent");p(this,"gemResistanceModifications");p(this,"collidedCreepIDs",[]);this.x=e,this.y=s,this.timeToLive=h,this.pierce=l,this.damage=a,this.gemResistanceModifications=c,this.sprite=new we({textures:n,scale:.25,rotation:r}),this.sprite.anchor.set(.5,.5),this.sprite.play(),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),u.GameMaster.currentScene.stage.addChild(this.container),this.angle=r,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>1720||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)&&!this.collidedCreepIDs.find(r=>s.id==r.id)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}}),this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y}}onCollide(e,s){u.GameScene.events.emit(ot.TakenDamage,e.id,s.damage,s.gemResistanceModifications)}checkCollision(e){if(e==null||e.container==null||e.container._position==null)return;let s=this.copyContainerToBB(),n=e.copyContainerToBB();return s.getBounds().intersects(n.getBounds())}}class vd extends Ys{constructor(e,s,n,r,a,o,h,l,c){super(e,s,n,r,a,o,h,l,c);p(this,"visuals",[]);p(this,"counter",0);this.pierce=1e3,this.timeToLive=2e3}destroy(){super.destroy(),this.visuals.forEach(e=>e.destroy()),this.visuals=[]}update(e){if(super.update(e),this.counter==2){this.counter=0;let s=new $({x:this.x,y:this.y,rotation:this.angle,texture:this.sprite.texture,scale:.25});s.anchor.set(.5,.5),this.visuals.push(s),this.visuals.forEach(n=>{if(n.scale==null)return n.destroy();n.width&&n.height&&n.alpha&&(n.width-=4,n.height-=4,n.alpha-=.1,(n.width<=0||n.height<=0||n.alpha<=0)&&n.destroy())}),u.GameScene.stage.addChild(s)}else this.counter++}}class Cd extends Ys{constructor(e,s,n,r,a,o,h,l,c,d,f){super(e,s,n,r,h,l,c,d,f);p(this,"visuals",[]);p(this,"counter",0);p(this,"goalX");p(this,"goalY");this.sprite.scale=.5,this.sprite.rotation=Math.random()*Math.PI*2,this.goalX=a,this.goalY=o}destroy(){super.destroy(),this.visuals.forEach(e=>e.destroy()),this.visuals=[]}update(e){if(!this.deleteMe){if(this.x>1720||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();be(this.x,this.y,this.goalX,this.goalY)<25?(this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}})):(this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y)}}}class Td extends Mt{constructor(e,s){super();p(this,"deleteMe",!1);p(this,"c");p(this,"oc");p(this,"Lightning");this.c=e,this.oc=s;let n=ct(e.x,e.y,s.x,s.y);this.Lightning=new we({textures:C.SpecialLightning,x:e.x,y:e.y,width:be(this.c.x,this.c.y,this.oc.x,this.oc.y),height:64,scale:1.2,rotation:n}),this.Lightning.anchor.set(0,.5),this.Lightning.play(),u.GameMaster.currentScene.stage.addChild(this.Lightning),u.DebrisManager.CreateDebris(this,30)}destroy(){this.deleteMe=!0,this.container.destroy(),this.Lightning.destroy()}update(){this.deleteMe||(this.Lightning.x=this.c.x,this.Lightning.y=this.c.y,this.Lightning.width=be(this.c.x,this.c.y,this.oc.x,this.oc.y))}}var Xs=(i=>(i.MovingBackwards="MovingBackwards",i.DebuffTowerDebuff="DebuffTowerDebuff",i))(Xs||{});class Ad{constructor(t,e){p(this,"effectEnum");p(this,"durationInMS");p(this,"ticks",0);this.effectEnum=t,this.durationInMS=e}}class Md extends Mt{constructor(e,s,n){super();p(this,"id");p(this,"creepType");p(this,"sprite");p(this,"path");p(this,"stats");p(this,"pathIndex",0);p(this,"speed");p(this,"direction",1);p(this,"healthBarGraphics",new Ct);p(this,"healthBarWidth",50);p(this,"effects",[]);p(this,"health");p(this,"maxHealth");p(this,"escaped",!1);p(this,"died",!1);p(this,"x");p(this,"y");p(this,"dead",!1);this.creepType=e,this.stats=structuredClone(C.Creeps[this.creepType].stats),this.sprite=new we(C.Creeps[this.creepType].textures),this.sprite.scale.x*=-1,this.sprite.anchor.set(.5,.5),this.sprite.animationSpeed=.3,this.sprite.play(),this.id=n,this.container.x=-70,this.container.y=-50,this.sprite.width=u.GridCellSize,this.sprite.height=u.GridCellSize,this.bb.width=this.sprite.width,this.speed=this.stats.speed/60,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=s,this.x=s[0][0]*u.GridCellSize+u.GridCellSize/2,this.y=s[0][1]*u.GridCellSize+u.GridCellSize/2,u.GameScene.events.on(ot.TakenDamage,(r,a,o)=>{r==this.id&&(this.effects.find(h=>h.effectEnum=="DebuffTowerDebuff")&&(a=a*1.5,console.log("multiplying damage, "+a)),this.health-=a+a*(o.physical-this.stats.resistance.physical),o.fire!=0&&(this.health-=Math.max(a*(o.fire-this.stats.resistance.fire),0)),o.ice!=0&&(this.health-=Math.max(a*(o.ice-this.stats.resistance.ice),0)),o.frostfire!=0&&(this.health-=Math.max(a*(o.frostfire-this.stats.resistance.frostfire),0)),o.divine!=0&&(this.health-=Math.max(a*(o.divine-this.stats.resistance.divine),0)),this.UpdateHealthbar())}),u.GameScene.events.on(ot.GiveEffect,(r,a,o)=>{r==this.id&&(console.log(" I CAUGHT THE EVENT!"),this.effects.find(h=>h.effectEnum==a)==null&&this.effects.push(new Ad(a,o)))}),u.Grid.container.addChild(this.container),this.container.addChild(this.healthBarGraphics),this.container.addChild(this.sprite),this.UpdateHealthbar()}UpdateHealthbar(){this.healthBarGraphics.clear();const e=this.health,s=this.maxHealth,n=Math.max(0,e/s),r=this.healthBarWidth,a=10,o=2,h=-r/2,l=-32;this.healthBarGraphics.rect(h-o,l-o,r+o*2,a+o*2),this.healthBarGraphics.fill({color:0});const c=r*n;this.healthBarGraphics.rect(h,l,c,a),this.healthBarGraphics.fill({color:16711680})}update(e){if(this.dead)return;if(this.health<=0){u.GameScene.events.emit(ot.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(ot.Escaped,this),this.escaped=!0;return}const s=this.path[this.pathIndex],n=this.path[this.pathIndex+1],r=this.pathIndex-1!=0?this.path[this.pathIndex-1]:this.path[0];let a=!1;for(let m=this.effects.length-1;m>=0;m--){let y=this.effects[m];if(y.ticks+=e*u.GameScene.gameSpeedMultiplier,y.ticks>=y.durationInMS)this.effects.splice(m,1);else if(y.effectEnum=="MovingBackwards")return a=!0}let o,h,l,c;a?(o=r[0]*u.GridCellSize+u.GridCellSize/2,h=r[1]*u.GridCellSize+u.GridCellSize/2,l=s[0]-r[0],c=r[1]-s[1]):(o=n[0]*u.GridCellSize+u.GridCellSize/2,h=n[1]*u.GridCellSize+u.GridCellSize/2,l=n[0]-s[0],c=n[1]-s[1]),l>0?this.direction!=1&&(this.direction=1,this.sprite.scale.x*=-1):l<0&&this.direction!=-1&&(this.direction=-1,this.sprite.scale.x*=-1);let d=this.speed*e*l*u.GameScene.gameSpeedMultiplier,f=this.speed*e*c*u.GameScene.gameSpeedMultiplier,g=!1;d>0&&this.x+d>o&&(d=o-this.x,g=!0),d<0&&this.x+d<o&&(d=o-this.x,g=!0),f>0&&this.y+f>h&&(f=h-this.y,g=!0),f<0&&this.y+f<h&&(f=h-this.y,g=!0),this.x+=d,this.y+=f,g&&(a||this.pathIndex++),this.container.x=this.x,this.container.y=this.y}takeDamage(e){this.health-=e,this.health<0&&!this.died&&(this.died=!0,this.events.emit(ot.Died,this))}destroy(){super.destroy(),this.container.removeChildren()}}function oe(i,t){for(let e=i.projectiles.length-1;e>=0;e--){let s=i.projectiles[e];s.deleteMe||i.sold?(s.collidedCreepIDs.forEach(()=>{i.damageDealt+=i.computedDamageToDeal}),s.collidedCreepIDs=[],s.destroy(),i.projectiles.splice(e,1)):s.update(t)}}function Ot(i){let t=0,e=0,s=0,n=0,r=0;if(i.totalGemResistanceModifications={fire:0,frostfire:0,divine:0,ice:0,physical:0},i.slottedGems.forEach(a=>{let o=a.currentGemImprovement();t+=o.damageUp,e+=o.attackSpeedUp,s+=o.rangeUp,n+=o.timeToLiveUp,r+=o.pierceUp;let h=a.currentGemResistanceModifications();i.totalGemResistanceModifications.physical+=Number(h.physical.toFixed(2)),i.totalGemResistanceModifications.ice+=Number(h.ice.toFixed(2)),i.totalGemResistanceModifications.fire+=Number(h.fire.toFixed(2)),i.totalGemResistanceModifications.divine+=Number(h.divine.toFixed(2)),i.totalGemResistanceModifications.frostfire+=Number(h.frostfire.toFixed(2))}),i.computedDamageToDeal=i.definition.stats.damage+t,i.computedCooldown=i.definition.stats.cooldown-e,i.computedRange=i.definition.stats.range+s,i.computedTimeToLive=i.definition.stats.timeToLive+n,i.computedPierce=i.definition.stats.pierce+r,i.parent.isBuffedBy.length>0&&i.definition.name!=C.Towers[qe.Buff].name){let a=i.parent.isBuffedBy[0];i.computedDamageToDeal+=Number((a.computedDamageToDeal/2).toFixed(1)),i.computedCooldown-=Number((a.computedCooldown/5).toFixed(1)),i.computedRange+=Number((a.computedRange/10).toFixed(1)),i.computedTimeToLive+=Number((a.computedTimeToLive/5).toFixed(1)),i.computedPierce+=Number((a.computedPierce/4).toFixed(1)),i.totalGemResistanceModifications.physical+=Number((a.totalGemResistanceModifications.physical/2).toFixed(2)),i.totalGemResistanceModifications.ice+=Number((a.totalGemResistanceModifications.ice/2).toFixed(2)),i.totalGemResistanceModifications.fire+=Number((a.totalGemResistanceModifications.fire/2).toFixed(2)),i.totalGemResistanceModifications.divine+=Number((a.totalGemResistanceModifications.divine/2).toFixed(2)),i.totalGemResistanceModifications.frostfire+=Number((a.totalGemResistanceModifications.frostfire/2).toFixed(2))}}function Pd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ct(n,r,s.x,s.y))}}}function Gd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else if(i.GetCreepsInRange().length>0){i.millisecondsUntilNextShot=i.computedCooldown;let s=i.column*u.GridCellSize+u.GridCellSize/2,n=i.row*u.GridCellSize+u.GridCellSize/2;i.Shoot(ct(s,n,s,n+10)),i.Shoot(ct(s,n,s+10,n)),i.Shoot(ct(s,n,s-10,n)),i.Shoot(ct(s,n,s,n-10)),i.Shoot(ct(s,n,s+10,n+10)),i.Shoot(ct(s,n,s-10,n+10)),i.Shoot(ct(s,n,s-10,n-10)),i.Shoot(ct(s,n,s+10,n-10))}}function kd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{let l=[];h.pierce=0;let c=0;function d(f){if(c>=50){u.GameScene.PauseGame(),u.NotificationManager.Notify("Electric Tower max recursion exceeded! Please tell koneko! (game paused)","danger");return}c++,u.Grid.creeps.forEach(g=>{if(g.id!=o.id){const m=g.x,y=g.y,x=1.5*u.GridCellSize;if(be(f.x,f.y,m,y)<x){if(l.find(_=>_==g.id)!=null)return;l.push(g.id),new Td(f,g),u.GameScene.events.emit(ot.TakenDamage,g.id,Math.round(h.damage/2),h.gemResistanceModifications),d(g)}}})}u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage,h.gemResistanceModifications),l.push(o.id),d(o)}}}}function Bd(i,t){Ot(i)}function Id(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{u.GameScene.events.emit(ot.GiveEffect,o.id,Xs.MovingBackwards,750),u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage/2,h.gemResistanceModifications)}}}}function Ed(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ct(n,r,s.x,s.y))}}}function Rd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{if(u.GameScene.roundMode!=Fa.Combat)return;let e=i.column*u.GridCellSize+u.GridCellSize/2,s=i.row*u.GridCellSize+u.GridCellSize/2,n=u.Grid.GetPathCellsInRange(i.row,i.column,i.computedRange);if(n.length>0){let r=Math.floor(Math.random()*n.length),a=n[r],o=a.column*u.GridCellSize+u.GridCellSize/2,h=a.row*u.GridCellSize+u.GridCellSize/2,l=new Y("white");if(i.slottedGems.length>0){let d=new Y(i.slottedGems[0].definition.color);for(let f=1;f<i.slottedGems.length;f++){const g=i.slottedGems[f];d.multiply(g.definition.color)}l=d}let c=new Cd(e,s,i.definition.projectileTextures,ct(e,s,o,h),o,h,i.computedDamageToDeal,l,i.computedTimeToLive,i.computedPierce,i.totalGemResistanceModifications);i.projectiles.push(c),i.millisecondsUntilNextShot=i.computedCooldown}}}function Fd(i,t){Ot(i),oe(i,t),i.millisecondsUntilNextShot>0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{u.GameScene.events.emit(ot.GiveEffect,o.id,Xs.DebuffTowerDebuff,5e3),u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage/1.5,h.gemResistanceModifications)}}}}function be(i,t,e,s){return Math.sqrt((e-i)*(e-i)+(s-t)*(s-t))}class Ld extends Mt{constructor(e,s,n,r,a){super();p(this,"row");p(this,"column");p(this,"setAsSold",!1);p(this,"sold",!1);p(this,"definition");p(this,"slottedGems",[]);p(this,"damageDealt",0);p(this,"projectiles",[]);p(this,"behaviour");p(this,"sprite");p(this,"millisecondsUntilNextShot");p(this,"graphics",new Ct);p(this,"computedDamageToDeal",0);p(this,"computedCooldown",0);p(this,"computedRange",0);p(this,"computedTimeToLive",0);p(this,"computedPierce",0);p(this,"totalGemResistanceModifications",{fire:0,frostfire:0,divine:0,ice:0,physical:0});p(this,"parent");p(this,"onParentCellEnter",e=>{!u.TowerManager.isPlacingTower&&u.Grid.gridInteractionEnabled&&!u.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.computedRange)});p(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=s,this.behaviour=a,this.definition=r,this.millisecondsUntilNextShot=0,this.parent=u.Grid.getCellByRowAndCol(e,s),this.sprite=new $({texture:n,height:u.GridCellSize,width:u.GridCellSize,zIndex:130}),this.container.addChild(this.sprite),this.computedDamageToDeal=this.definition.stats.damage,this.computedRange=this.definition.stats.range,this.parent.container.addChild(this.container),this.container.interactiveChildren=!0,this.parent.clickDetector.on("pointerenter",this.onParentCellEnter),this.parent.clickDetector.on("pointerleave",this.onParentCellLeave),u.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,s){this.slottedGems[s]=e,u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(this)}UnslotGem(e){const s=this.slottedGems.splice(e,1)[0];if(s==null||!s)return console.warn("UnslotGem: Gem is null.");u.GameScene.MissionStats.giveGem(s,!0);for(let n=e;n<this.slottedGems.length-1;n++)this.slottedGems[n]==null&&(this.slottedGems[n]=this.slottedGems[n+1],this.slottedGems[n+1]=null);u.GameScene.sidebar.gemTab.selectingGemTowerObject=this,this.slottedGems=this.slottedGems.filter(n=>n!=null),u.NotificationManager.Notify(`Lv. ${s.level} ${s.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return u.Grid.creeps.filter(s=>{const n=s.x,r=s.y,a=this.column*u.GridCellSize+u.GridCellSize/2,o=this.row*u.GridCellSize+u.GridCellSize/2,h=this.computedRange*u.GridCellSize;return be(a,o,n,r)<h+u.GridCellSize*2/3})}Shoot(e){let s=this.column*u.GridCellSize+u.GridCellSize/2,n=this.row*u.GridCellSize+u.GridCellSize/2,r=new Y("white");if(this.slottedGems.length>0){let o=new Y(this.slottedGems[0].definition.color);for(let h=1;h<this.slottedGems.length;h++){const l=this.slottedGems[h];o.multiply(l.definition.color)}r=o}let a;return this.behaviour==kt.RailTowerBehaviour?a=new vd(s,n,this.definition.projectileTextures,e,this.computedDamageToDeal,r,this.computedTimeToLive,this.computedPierce,this.totalGemResistanceModifications):a=new Ys(s,n,this.definition.projectileTextures,e,this.computedDamageToDeal,r,this.computedTimeToLive,this.computedPierce,this.totalGemResistanceModifications),this.projectiles.push(a),a}Sell(){this.setAsSold=!0}update(e){this.sold||(this.setAsSold&&(this.sold=!0),this.behaviour==kt.BasicTowerBehaviour&&Pd(this,e),this.behaviour==kt.CircleTowerBehaviour&&Gd(this,e),this.behaviour==kt.ElectricTowerBehaviour&&kd(this,e),this.behaviour==kt.BuffTowerBehaviour&&Bd(this),this.behaviour==kt.StrongTowerBehaviour&&Id(this,e),this.behaviour==kt.RailTowerBehaviour&&Ed(this,e),this.behaviour==kt.TrapperTowerBehaviour&&Rd(this,e),this.behaviour==kt.DebuffTowerBehaviour&&Fd(this,e))}destroy(){super.destroy(),this.parent.clickDetector.off("pointerenter",this.onParentCellEnter),this.parent.clickDetector.off("pointerleave",this.onParentCellLeave),this.graphics.destroy()}}class Dd extends Mt{constructor(e,s,n,r){super();p(this,"type");p(this,"row");p(this,"column");p(this,"isPath",!1);p(this,"g");p(this,"hasTowerPlaced",!1);p(this,"isBuffedBy",[]);p(this,"clickDetector");this.type=e,this.row=s,this.column=n,this.isPath=r,this.bb.x=this.column*u.GridCellSize,this.bb.y=this.row*u.GridCellSize,this.bb.width=u.GridCellSize,this.bb.height=u.GridCellSize,u.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new Ct({zIndex:99,interactive:!0}),this.g=new Ct({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=>{u.Grid.gridInteractionEnabled&&(u.TowerManager.isPlacingTower?u.Grid.onGridCellClicked(s,n):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(Ke.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(Ke.CellMouseLeave,this)}),u.GameScene.events.on(_e.TowerPlacedEvent,(a,o,h)=>{if(o==this.row&&h==this.column)this.hasTowerPlaced=!0,u.Grid.rangePreview.clear();else if(a==C.Towers[qe.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&this.isBuffedBy.push(l)}}),u.GameScene.events.on(_e.TowerSoldEvent,(a,o,h)=>{if(console.log(a,o,h),o==this.row&&h==this.column)this.hasTowerPlaced=!1,u.Grid.rangePreview.clear();else if(a==C.Towers[qe.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&(console.log("REMOVED!"),this.isBuffedBy.splice(this.isBuffedBy.indexOf(l),1),console.log(this.isBuffedBy))}})}showRangePreview(e,s){let n=16777215;e&&(n=16711680),u.Grid.rangePreview.clear(),u.Grid.rangePreview.circle(this.column*u.GridCellSize+u.GridCellSize/2,this.row*u.GridCellSize+u.GridCellSize/2,s*u.GridCellSize),u.Grid.rangePreview.fill({color:n,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=u.TowerManager.GetTowerByRowAndCol(this.row,this.column);u.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Dt.Path||this.type==Dt.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Dt.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Dt.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Dt.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class zd extends Mt{constructor(e,s){super();p(this,"gameMap");p(this,"cells",[]);p(this,"rangePreview");p(this,"creeps",[]);p(this,"gridShown",!1);p(this,"gridInteractionEnabled",!0);this.gameMap=e,u.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=u.GridCellSize*u.GridColumns,this.bb.height=u.GridCellSize*u.GridRows,u.GameMaster.currentScene.stage.addChild(this.container);let n=new $(C.MissionBackgrounds[s]);this.container.addChild(n);for(let r=0;r<this.gameMap.columns;r++)for(let a=0;a<this.gameMap.rows;a++){let o=this.gameMap.cells[a][r];const h=this.gameMap.paths.some(c=>c.some(d=>d[1]===a&&d[0]===r));h&&(o=Dt.Path);let l=new Dd(o,a,r,h);this.cells.push(l)}this.rangePreview=new Ct({zIndex:10,x:0,y:0,width:u.app.canvas.width,height:u.app.canvas.height}),this.container.addChild(this.rangePreview)}generateCells(){const e=Array.from({length:this.gameMap.rows},()=>Array(this.gameMap.columns).fill(1));this.cells.forEach(s=>{if(s.isPath){e[s.row][s.column]=9;for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++){const a=s.row+n,o=s.column+r;a>=0&&a<this.gameMap.rows&&o>=0&&o<this.gameMap.columns&&e[a][o]!==9&&(e[a][o]=0)}}}),console.log(JSON.stringify(e))}IsCellInRangeOfOtherCell(e,s,n,r){n=n*u.GridCellSize;const a=r.column*u.GridCellSize+u.GridCellSize/2,o=r.row*u.GridCellSize+u.GridCellSize/2,h=s*u.GridCellSize+u.GridCellSize/2,l=e*u.GridCellSize+u.GridCellSize/2;return be(h,l,a,o)<n+u.GridCellSize/2}GetPathCellsInRange(e,s,n){let r=[];return this.cells.forEach(a=>{a.isPath&&this.IsCellInRangeOfOtherCell(e,s,n,a)&&r.push(a)}),r}toggleGrid(e){this.cells.forEach(s=>{if(e){e=="hide"?s.gClear():s.gDraw();return}this.gridShown?s.gClear():s.gDraw()}),e=="hide"?this.gridShown=!1:e=="show"?this.gridShown=!0:this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(ot.Died,s=>{this.onCreepDiedOrEscaped(s)}),e.events.on(ot.Escaped,s=>{this.onCreepDiedOrEscaped(s)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(s=>{s.dead?(this.creeps.splice(this.creeps.indexOf(s),1),s=null):s.update(e)})}getCellByRowAndCol(e,s){return this.cells.filter(n=>n.row==e&&n.column==s)[0]}onGridCellClicked(e,s){}}class Ud extends Mt{constructor(e,s){super();p(this,"creeps",[]);p(this,"rounds");p(this,"paths");p(this,"ticks",0);p(this,"started",!1);p(this,"internalCreepId",0);p(this,"pathsIndex");p(this,"finished",!1);u.WaveManager=this,this.rounds=e,this.paths=s,this.pathsIndex=0}start(e){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1,this.pathsIndex+1==this.paths.length?this.pathsIndex=0:this.pathsIndex++;let s=0;this.rounds[e].waves.forEach(n=>{s+=n.firstCreepSpawnTick,n.creeps.forEach(r=>{const a=new Md(r,this.paths[this.pathsIndex],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:s,spawned:!1};s+=n.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e*u.GameScene.gameSpeedMultiplier,this.creeps.forEach(s=>{!s.spawned&&s.tickToSpawnAt<=this.ticks?(s.spawned=!0,this.events.emit(re.CreepSpawned,s.creep),!this.finished&&this.creeps.every(n=>n.spawned)&&(this.finished=!0,this.events.emit(re.Finished))):s.spawned&&s.creep.update(e)}))}}class Ht extends At{constructor(e,s,n,r,a,o,h,l){if(e>3||s>2||e<0||s<0)throw"Index/row out of bounds for TowerButton.";super(!0);p(this,"frameSprite");p(this,"background");p(this,"towerName");p(this,"iconSprite");p(this,"i",0);this.towerName=h,this.container.x=e*n+5,this.container.y=s*r+5,this.background=new $({texture:o}),this.iconSprite=new $({texture:l}),this.background.width=n,this.background.height=r,this.iconSprite.x=n/2,this.iconSprite.y=r/2,this.iconSprite.width=n/2,this.iconSprite.height=r/2,this.iconSprite.anchor.set(.5,.5),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.frameSprite=new _t({texture:C.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:r,width:n}),this.container.addChild(this.frameSprite),a.addChild(this.container),u.GameScene.events.on(_e.TowerPlacedEvent,c=>{this.resetTint()}),this.container.onpointermove=c=>{u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=c=>{u.GameScene.tooltip.Hide()}}ShowTooltip(){let e;C.Towers.forEach(s=>{s.name==this.towerName&&(e=s)}),u.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)}onClick(e){u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower&&u.TowerManager.selectedTower.name!=this.towerName&&(u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower()),u.GameScene.towerPanel.Hide(),u.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,u.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class Nd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"towerTabSprite");p(this,"towerButtons",[]);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new _t({texture:C.FrameTowerTab,leftWidth:500,topHeight:500,rightWidth:500,bottomHeight:500,roundPixels:!0}),this.towerTabSprite.width=this.bounds.width,this.towerTabSprite.height=this.bounds.height,this.container.addChild(this.towerTabSprite),this.towerButtons.push(new Ht(0,0,70,70,this.container,C.RedBackground,C.Towers[0].name,C.Towers[0].texture)),this.towerButtons.push(new Ht(1,0,70,70,this.container,C.RedBackground,C.Towers[1].name,C.Towers[1].texture)),this.towerButtons.push(new Ht(2,0,70,70,this.container,C.BlueBackground,C.Towers[2].name,C.Towers[2].texture)),this.towerButtons.push(new Ht(3,0,70,70,this.container,C.BlueBackground,C.Towers[3].name,C.Towers[3].texture)),this.towerButtons.push(new Ht(0,1,70,70,this.container,C.GreenBackground,C.Towers[4].name,C.Towers[4].texture)),this.towerButtons.push(new Ht(1,1,70,70,this.container,C.GreenBackground,C.Towers[5].name,C.Towers[5].texture)),this.towerButtons.push(new Ht(2,1,70,70,this.container,C.YellowBackground,C.Towers[6].name,C.Towers[6].texture)),this.towerButtons.push(new Ht(3,1,70,70,this.container,C.YellowBackground,C.Towers[7].name,C.Towers[7].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const se=class se{static init(){se.SidebarRect=new I(u.app.canvas.width-360,0,360,u.app.canvas.height),se.ChangeRoundButtonRect=new I(50,u.app.canvas.height-100,310,100)}};p(se,"SidebarRect"),p(se,"ChangeRoundButtonRect"),p(se,"MaximumPlayerNameLength",20);let Yt=se;class Ze extends At{constructor(e,s,n,r){super(!0);p(this,"iconSprite");p(this,"background");p(this,"frame");p(this,"i",0);p(this,"gem",null);let a;this.i=e,this.container.x=10,this.container.y=e*(u.GridCellSize+6)+300,this.background=new $({texture:C.Frame01Texture}),n==null&&!r?a=C.PlusIconTexture:r=="SELL"?a=C.GoldTexture:r=="UPGRADE"?a=C.PlusIconTexture:(a=n.texture,this.gem=n),this.iconSprite=new $({texture:a,zIndex:10}),this.background.width=u.GridCellSize,this.background.height=u.GridCellSize,n==null&&!r?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):r=="SELL"?(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8):r=="UPGRADE"?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.tint=3012919,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8),this.frame=new $({texture:C.Frame05Texture,width:64,height:64}),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.container.addChild(this.frame);let o=n?n.level:"",h=new N({text:o,zIndex:11,style:{fill:"white",stroke:{color:0,width:5}}});this.container.addChild(h),s.addChild(this.container)}setTint(e){this.frame.tint=e}resetTint(){this.frame.tint=16777215}}class Od extends At{constructor(e){super(!1);p(this,"bounds");p(this,"towerPanel");p(this,"closeBtn");p(this,"vGems",[]);p(this,"showingTower",null);p(this,"isShown",!1);p(this,"titleText");p(this,"damageText");p(this,"totalDamage");p(this,"attackSpeedText");p(this,"fireResDamage");p(this,"iceResDamage");p(this,"frostFireResDamage");p(this,"divineResDamage");p(this,"physicalResDamage");p(this,"sellButton");this.bounds=e,this.towerPanel=new _t({texture:C.Frame03Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.towerPanel.width=this.bounds.width,this.towerPanel.height=this.bounds.height-this.bounds.height/3.5,this.closeBtn=new ut(new I(-20,-20,60,60),"",ht.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new $({texture:C.XIconTexture,x:this.closeBtn.container.width/2,y:this.closeBtn.container.height/2,scale:.2}),this.closeBtn.buttonIcon.anchor.set(.5,.5),this.closeBtn.container.addChild(this.closeBtn.buttonIcon)},this.closeBtn.onClick=()=>{this.Hide()},this.Hide(),this.closeBtn.CustomButtonLogic(),this.container.y=u.app.canvas.height/2-u.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),u.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new N({x:this.bounds.width/3,y:50,zIndex:5,style:new W({fill:16777215,fontSize:25,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new N({x:10,y:100,zIndex:5,style:new W({fill:16753920,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.damageText),this.attackSpeedText=new N({x:100,y:100,zIndex:5,style:new W({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.attackSpeedText),this.totalDamage=new N({x:10,y:130,zIndex:5,style:new W({fill:16711680,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.totalDamage),this.fireResDamage=new N({x:10,y:170,zIndex:5,style:new W({fill:16536403,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.fireResDamage),this.iceResDamage=new N({x:10,y:190,zIndex:5,style:new W({fill:3335420,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.iceResDamage),this.frostFireResDamage=new N({x:10,y:210,zIndex:5,style:new W({fill:14111740,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.frostFireResDamage),this.divineResDamage=new N({x:10,y:230,zIndex:5,style:new W({fill:16576083,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.divineResDamage),this.physicalResDamage=new N({x:10,y:250,zIndex:5,style:new W({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.physicalResDamage),this.sellButton=new ut(new I(5,this.towerPanel.height-70,this.towerPanel.width-115,60),"Sell",ht.Button02,!0),this.sellButton.container.removeFromParent(),this.container.addChild(this.sellButton.container)}MakeSlots(e){this.vGems.forEach(n=>{n.destroy()}),this.vGems=[];let s=e.definition.stats.gemSlotsAmount;for(let n=0;n<s;n++){console.log("BUILDING TOWER PANEL "+n);let r=e.slottedGems[n];r||(r=null);const a=new Ze(n,this.container,r);a.resetTint(),this.vGems.push(a),a.container.onpointermove=()=>{r&&(u.GameScene.tooltip.SetContentGem(r),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},a.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},a.onClick=()=>{u.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",r,a.i,n,e),u.GameScene.events.emit(Vs.TowerPanelSelectGem,r,a.i,e),!r&&u.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,Ot(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,u.GameScene.sidebar.gemTab.selectingGemTowerObject=e,e.container.parent.x<1270?this.ShowRight():this.ShowLeft(),e.parent.showRangePreview(!1,e.computedRange)}SetContent(e){this.titleText.text=e.definition.name,this.damageText.text="Deals "+e.computedDamageToDeal+" damage",this.totalDamage.text="Damage dealt: "+e.damageDealt+" damage",this.attackSpeedText.x=this.damageText.width+10,this.attackSpeedText.text=` every ${Math.floor(e.computedCooldown/1e3*100)/100}s`,this.fireResDamage.text=`+${e.totalGemResistanceModifications.fire*100}% Fire damage`,this.iceResDamage.text=`+${e.totalGemResistanceModifications.ice*100}% Ice damage`,this.frostFireResDamage.text=`+${e.totalGemResistanceModifications.frostfire*100}% FrostFire damage`,this.divineResDamage.text=`+${e.totalGemResistanceModifications.divine*100}% Divine damage`,this.physicalResDamage.text=`+${e.totalGemResistanceModifications.physical*100}% Physical damage`,this.sellButton.setCaption("Sell for "+e.definition.stats.cost+" gold"),this.sellButton.onClick=()=>{e.Sell(),this.Hide()}}ShowLeft(){this.towerPanel.x=-100,this.container.x=0,this.container.alpha=1,this.closeBtn.container.x=this.bounds.width-150}ShowRight(){this.towerPanel.x=-10,this.container.x=Yt.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=-1e3,u.Grid.rangePreview.clear()}}class Wd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"gemTabSprite");p(this,"vGems",[]);p(this,"isSelectingGem",!1);p(this,"selectingGemSlotIndex",-1);p(this,"selectingGemTowerObject",null);p(this,"isDragAndDroppingGem",!1);p(this,"dragAndDroppingGem",null);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new _t({texture:C.FrameTowerTab,leftWidth:1e3,topHeight:1e3,rightWidth:1e3,bottomHeight:1e3}),this.gemTabSprite.x=0,this.gemTabSprite.y=0,this.gemTabSprite.width=this.bounds.width,this.gemTabSprite.height=this.bounds.height,this.container.addChild(this.gemTabSprite),u.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),u.GameScene.events.on($s.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,s,n){console.log("TOWER PANEL SELECTING GEM "+s),s<0&&console.error("TOWER PANEL SELECTING GEM INDEX IS LESS THAN 0, ",s),this.isSelectingGem?e==null&&(this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null):(this.isSelectingGem=!0,e==null?(u.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=s,this.selectingGemTowerObject=n):(n.UnslotGem(s),this.RebuildInventoryVisual(),u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(n),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=u.MouseX-32,this.dragAndDroppingGem.container.y=u.MouseY-32)}isOverlappingGemsmith(e,s,n){let r=e.copyContainerToBB(),a=s.copyContainerToBB(),o=n.x+a.x+u.GameScene.sidebar.container.x,h=n.y+a.y+u.GameScene.sidebar.container.y,l=new I(o,h,a.width,a.height);if(r.getBounds().intersects(l)&&s&&s.gem==null)return!0}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],u.GameScene.MissionStats.getInventory().forEach((e,s)=>{let n=new Ze(0,this.container,e),r=10,a=s%4*70+10,o=s;for(;!(o<=3);)r+=66,o-=4;n.container.x=a,n.container.y=r,n.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(u.GameScene.tooltip.SetContentGem(e),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},n.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},n.container.onpointerdown=()=>{if(u.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=u.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=n,n.container.removeFromParent(),u.GameScene.stage.addChild(n.container),this.pointerMoveEvent()},n.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.sellVGem,u.GameScene.sidebar.gemsmith.container)){let d=this.dragAndDroppingGem.gem.definition.initialGemValue+this.dragAndDroppingGem.gem.currentGemImprovement().gemValueUp;u.GameScene.MissionStats.earnGold(Math.ceil(d*.8)),u.NotificationManager.Notify(`Sold Lv. ${this.dragAndDroppingGem.gem.level} ${this.dragAndDroppingGem.gem.definition.name} for ${Math.ceil(d*.8)} gold.`,"info"),u.GameScene.MissionStats.takeGem(this.dragAndDroppingGem.gem),this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.upgradeVGem,u.GameScene.sidebar.gemsmith.container)){if(this.dragAndDroppingGem.gem.isMaxLevel())u.NotificationManager.Notify("Gem is max level.","warn");else{let d=this.dragAndDroppingGem.gem.definition.genericImprovements[this.dragAndDroppingGem.gem.level].gemValueUp;u.GameScene.MissionStats.hasEnoughGold(d)?(u.GameScene.MissionStats.spendGold(d),this.dragAndDroppingGem.gem.levelUp(1),u.NotificationManager.Notify(`Spent ${d} gold to upgrade ${this.dragAndDroppingGem.gem.definition.name} Lv. ${this.dragAndDroppingGem.gem.level-1} -> Lv. ${this.dragAndDroppingGem.gem.level}!`,"warn")):u.NotificationManager.Notify("You don't have enough, you need "+d+" gold to upgrade this gem.","warn")}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(u.GameScene.towerPanel.vGems.forEach(d=>{if(h||!this.dragAndDroppingGem)return;let f=this.dragAndDroppingGem.copyContainerToBB(),g=d.copyContainerToBB(),m=u.GameScene.towerPanel.container.x+g.x,y=u.GameScene.towerPanel.container.y+g.y,x=new I(m,y,g.width,g.height);f.getBounds().intersects(x)&&d&&d.gem==null&&(h=d)}),h){let d=u.GameScene.MissionStats.takeGem(e);u.GameScene.towerPanel.showingTower.SlotGem(d,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(n)})}}class Hd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"sellVGem");p(this,"upgradeVGem");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y;let s=new $({x:0,y:0,width:this.bounds.width,height:this.bounds.height,texture:C.BannerGemsmith});this.container.addChild(s);let n=new N({x:40,y:this.bounds.height/6.5,text:"Sell gem",style:new W({fill:16767744,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(n);let r=new N({x:155,y:this.bounds.height/6.5,text:"Upgrade gem",style:new W({fill:3012919,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(r),this.sellVGem=new Ze(0,this.container,null,"SELL"),this.sellVGem.container.x=45,this.sellVGem.container.y=this.bounds.height/4,this.upgradeVGem=new Ze(0,this.container,null,"UPGRADE"),this.upgradeVGem.container.x=180,this.upgradeVGem.container.y=this.bounds.height/4}}class $d extends At{constructor(e){super(!1);p(this,"towerTab");p(this,"gemTab");p(this,"gemsmith");p(this,"bounds");p(this,"sidebarSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new _t({texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.sidebarSprite.x=40,this.sidebarSprite.y=-40,this.sidebarSprite.width=this.bounds.width+40,this.sidebarSprite.height=this.bounds.height+80,this.container.addChild(this.sidebarSprite);const s=new I(60,20,this.bounds.width-65,150);this.towerTab=new Nd(s),this.container.addChild(this.towerTab.container);const n=new I(60,180,this.bounds.width-65,this.bounds.height-280-255);this.gemTab=new Wd(n),this.container.addChild(this.gemTab.container);const r=new I(60,185+n.height,this.bounds.width-65,this.bounds.height-840);this.gemsmith=new Hd(r),this.container.addChild(this.gemsmith.container)}}class Vd extends Mt{constructor(e,s){super();p(this,"hp",100);p(this,"gold",0);p(this,"goldEarned",0);p(this,"goldSpent",0);p(this,"wavesSurvived",0);p(this,"damageDealt",0);p(this,"creepsKilled",0);p(this,"goldText");p(this,"healthText");p(this,"waveText");p(this,"inventory",[]);this.hp=e,this.gold=s,this.container.x=0,this.container.y=20,u.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new N({text:`${this.hp}`,style:new W({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new N({text:`${this.gold}`,style:new W({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new N({text:`0/${u.GameScene.mission.rounds.length}`,style:new W({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const n=new $(C.HealthTexture),r=new $(C.GoldTexture),a=new $(C.WaveTexture);this.healthText.x=200,this.healthText.y=-15,n.x=160,n.width=36,n.height=32,n.y=-10,this.goldText.x=200,this.goldText.y=20,r.x=150,r.width=56,r.height=56,r.y=15,this.waveText.x=200,this.waveText.y=55,a.x=155,a.width=46,a.height=32,a.y=65,this.container.addChild(this.healthText),this.container.addChild(this.goldText),this.container.addChild(this.waveText),this.container.addChild(n),this.container.addChild(r),this.container.addChild(a),u.GameScene.events.on(re.NewWave,o=>{this.waveText.text=`${o}/${u.GameScene.mission.rounds.length}`})}getHP(){return this.hp}hasEnoughGold(e){return e<=this.gold}setHP(e){this.hp=e,this.healthText.text=this.hp}takeDamage(e){this.hp-=e,this.healthText.text=this.hp}setGold(e){this.gold=e,this.goldText.text=this.gold}earnGold(e){this.gold+=e,this.goldText.text=this.gold}spendGold(e){this.gold-=e,this.goldText.text=this.gold}giveGem(e,s){if(this.inventory.length>=32)return u.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),s||u.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),u.GameScene.events.emit($s.GemGivenEvent,e)}takeGem(e){return this.inventory.splice(this.inventory.indexOf(e),1)[0]}getInventory(){return this.inventory}checkIfPlayerHasAnyGems(){return this.inventory.length>0}getStats(){return{hp:this.hp,gold:this.gold,wavesSurvived:this.wavesSurvived,goldEarned:this.goldEarned,goldSpent:this.goldSpent,score:this.calculateScore()}}calculateScore(){const e=[];for(const s of this.inventory)e.includes(s.definition.name)||e.push(s.definition.name);return this.damageDealt*2+this.hp*10+(this.goldEarned-this.goldSpent)*3+this.wavesSurvived*100+e.length*100}update(){}}class Yd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"tooltipSprite");p(this,"titleText");p(this,"costText");p(this,"damageText");p(this,"gemAmount");p(this,"gemAmountSprite");p(this,"title");p(this,"costSprite");p(this,"damageSprite");p(this,"gemDescriptionText");this.bounds=e,this.container.x=-500,this.container.y=-500,this.container.zIndex=150,this.tooltipSprite=new _t({texture:C.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new N({x:this.tooltipSprite.width/2,y:-20,zIndex:5,style:new W({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.title=new $({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:C.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new $({texture:C.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new N({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 N({x:54,y:65,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"red",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageSprite=new $({texture:C.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new $({texture:C.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new N({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 N({x:10,y:20,text:"",style:{fontSize:18,wordWrap:!0,wordWrapWidth:this.tooltipSprite.width-30,fill:"white",fontWeight:"bold",fontStyle:"italic",stroke:{color:0,width:5}}}),this.container.addChild(this.tooltipSprite),this.container.addChild(this.title),this.container.addChild(this.costSprite),this.container.addChild(this.damageSprite),this.container.addChild(this.gemAmountSprite),this.container.addChild(this.costText),this.container.addChild(this.titleText),this.container.addChild(this.damageText),this.container.addChild(this.gemAmount),this.container.addChild(this.gemDescriptionText),u.app.stage.addChildAt(this.container,0)}SetContentTower(e,s,n,r){this.costSprite.alpha=1,this.damageSprite.alpha=1,this.gemAmountSprite.alpha=1,this.costText.alpha=1,this.damageText.alpha=1,this.gemAmount.alpha=1,this.gemDescriptionText.alpha=0,this.titleText.text=e,this.gemAmount.text=`Has ${r} Gem slots.`,this.gemAmountSprite.texture=C.GemAmountIcons[r],this.costText.text=`Costs ${n} gold.`,this.damageText.text=`Deals ${s} base damage.`}SetContentGem(e){this.costSprite.alpha=0,this.damageSprite.alpha=0,this.gemAmountSprite.alpha=0,this.costText.alpha=0,this.damageText.alpha=0,this.gemAmount.alpha=0,this.gemDescriptionText.alpha=1,this.titleText.text=`Lv. ${e.level} `+e.definition.name;let s;e.isMaxLevel()?s="Max level.":s=`Costs ${e.definition.genericImprovements[e.level].gemValueUp} gold to level up.`,this.gemDescriptionText.text=`${s} Valued at ${e.definition.initialGemValue+e.currentGemImprovement().gemValueUp} gold. `+e.definition.description}Show(e,s){this.container.alpha=1,e+this.container.width>u.app.canvas.width?this.container.x=e-this.container.width:this.container.x=e,this.container.y=s}Hide(){this.container.alpha=0,this.container.x=-500,this.container.y=-500}}const ft=class ft{static init(){window.addEventListener("keydown",ft.handleKeyDown)}static onKeyPressed(t){return ft.listeners=[...ft.listeners,t],()=>ft.offKey(t)}static offKey(t){const e=ft.listeners.indexOf(t);e>=0&&(ft.listeners=[...ft.listeners.slice(0,e),...ft.listeners.slice(e+1)])}static handleKeyDown(t){if(ft.listeners.length>0)for(let e=ft.listeners.length-1;e>=0&&(ft.listeners[e](t),!t.defaultPrevented);e--);}};p(ft,"listeners",[]);let Se=ft;class Bi extends At{constructor(e,s,n){super();p(this,"overlay");p(this,"buttonHeight",65);p(this,"buttonCaptions");p(this,"buttons",[]);p(this,"dialogContent");p(this,"dialogContainer");p(this,"background");p(this,"generated",!1);p(this,"escapeKeyButton");p(this,"enterKeyButton");p(this,"keyboardManagerUnsubscribe");p(this,"onClosed");if(this.buttonCaptions=e,n&&!e.includes(n))throw new Error(`Escape key button "${n}" not found in buttons: ${e}`);if(this.escapeKeyButton=n,s&&!e.includes(s))throw new Error(`Enter key button "${s}" not found in buttons: ${e}`);this.enterKeyButton=s,this.keyboardManagerUnsubscribe=Se.onKeyPressed(this.onKeyPress.bind(this))}show(){return this.generate(),`${Math.round(this.dialogContainer.x)}${Math.round(this.dialogContainer.y)}${Math.round(this.dialogContainer.width)}${Math.round(this.dialogContainer.height)}`,`${Math.round(this.dialogContent.x)}${Math.round(this.dialogContent.y)}${Math.round(this.dialogContent.width)}${Math.round(this.dialogContent.height)}`,new Promise((e,s)=>{u.app.stage.addChild(this.container),this.onClosed=n=>{this.destroy(),e(n)}})}createDialogBackground(){return new _t({texture:C.Frame04Texture,leftWidth:60,topHeight:60,rightWidth:60,bottomHeight:60})}getWidth(){}getHeight(){}generate(){if(this.generated)return;this.generated=!0,this.overlay=new Ct,this.overlay.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.overlay.fill({color:0,alpha:.5}),this.overlay.interactive=!0,this.container.addChild(this.overlay);const e=this.buttonCaptions.map(l=>({caption:l,width:l.length*14+60,height:this.buttonHeight,click:()=>this.close(l)}));this.background=this.createDialogBackground(),this.dialogContent=this.createContent();let s=0;for(const l of e)s>0&&(s+=10),s+=l.width;const n=this.buttonCaptions.length>0?this.buttonHeight+10:0;let r=this.getWidth()||Math.max(s,this.dialogContent.width)+this.background.leftWidth+this.background.rightWidth,a=this.getHeight()||this.dialogContent.height+n+this.background.topHeight+this.background.bottomHeight;const o=new I(u.app.canvas.width/2-r/2,u.app.canvas.height/2-a/2,r,a);this.dialogContainer=new tt,this.dialogContainer.x=o.x,this.dialogContainer.y=o.y,this.background.width=r,this.background.height=a,this.dialogContainer.addChild(this.background),this.dialogContent.width<o.width&&(this.dialogContent.x=o.width/2-this.dialogContent.width/2),this.dialogContent.height<o.height-n-this.background.topHeight-this.background.bottomHeight?this.dialogContent.y=this.background.topHeight+(o.height-n-this.background.topHeight-this.background.bottomHeight)/2-this.dialogContent.height/2:this.dialogContent.y=this.background.topHeight,this.dialogContainer.addChild(this.dialogContent);let h=o.width/2-s/2;for(const l of e){const c=new ut(new I(h,o.height-this.buttonHeight-this.background.bottomHeight,l.width,l.height),l.caption,ht.Button01);c.onClick=l.click,this.buttons.push(c),this.dialogContainer.addChild(c.container),h+=l.width+10}this.container.addChild(this.dialogContainer)}close(e){this.destroy(),this.onClosed&&this.onClosed(e)}destroy(){this.keyboardManagerUnsubscribe(),super.destroy()}onKeyPress(e){this.buttons.length!==0&&(this.escapeKeyButton&&e.key==="Escape"?(e.preventDefault(),this.close(this.escapeKeyButton)):this.enterKeyButton&&e.key==="Enter"&&(e.preventDefault(),this.close(this.enterKeyButton)))}}class Xd extends At{constructor(e,s){super();p(this,"backgroundSprite");p(this,"text");p(this,"maxLength");p(this,"keyboardManagerUnsubscribe");this.maxLength=s,this.backgroundSprite=new _t({texture:C.Frame01Texture,leftWidth:20,topHeight:20,rightWidth:20,bottomHeight:20}),this.backgroundSprite.x=0,this.backgroundSprite.y=0,this.backgroundSprite.width=e,this.backgroundSprite.height=80,this.container.addChild(this.backgroundSprite),this.text=new N({text:"",style:new W({fill:16777215,fontSize:24})}),this.text.x=30,this.text.y=25,this.container.addChild(this.text),this.keyboardManagerUnsubscribe=Se.onKeyPressed(this.onKeyPress.bind(this))}getText(){return this.text.text}onKeyPress(e){e.key=="Backspace"?this.text.text=this.text.text.slice(0,-1):e.key.length==1&&this.text.text.length<this.maxLength&&(this.text.text+=e.key)}}class js extends Bi{constructor(e,s,n,r){!r&&s.length>0&&(r=s[0]),!n&&s.length>0&&(n=s[s.length-1]);super(s,n,r);p(this,"caption");this.caption=e}createContent(){return new N({text:this.caption,style:new W({fill:16777215,fontSize:24})})}static show(e,s,n=0){return new js(e,s).show()}}const Lt=class Lt{constructor(t){p(this,"missionName");p(this,"scores");this.missionName=t,this.scores=this.loadScores(),this.scores.sort((e,s)=>s.score-e.score||e.timestamp-s.timestamp)}loadScores(){const t=localStorage.getItem(Lt.STORAGE_KEY_PREFIX+this.missionName);return Lt.parseStoredScores(t)}saveScores(){localStorage.setItem(Lt.STORAGE_KEY_PREFIX+this.missionName,JSON.stringify(this.scores))}addScore(t){this.scores.push(t),this.scores.sort((e,s)=>s.score-e.score),this.scores.length>Lt.MAX_SCORES&&(this.scores.length=Lt.MAX_SCORES),this.saveScores()}getScores(){return this.scores}static parseStoredScores(t){if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e)&&e.every(s=>typeof s.playerName=="string"&&typeof s.score=="number"&&typeof s.timestamp=="number"))return e.map(s=>({playerName:s.playerName,score:s.score,timestamp:s.timestamp}))}catch(e){console.error("Failed to parse stored scores:",e)}return[]}};p(Lt,"STORAGE_KEY_PREFIX","highscore_"),p(Lt,"MAX_SCORES",10);let Si=Lt;const Le={Confirm:"OK",Skip:"Skip"};class jd extends Bi{constructor(e,s,n){super([Le.Confirm,Le.Skip],Le.Confirm,Le.Skip);p(this,"dialogCaption");p(this,"playerNameTextInput");p(this,"lost");p(this,"highScore");p(this,"missionStats");this.lost=n,this.highScore=new Si(e),this.missionStats=s}generate(){super.generate(),this.dialogCaption=new N({text:this.lost?"You lost!":"You won!",style:new W({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 _t({texture:C.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new tt,s=35,n=this.createText("Mission details:","#fee",!0);e.addChild(n);const r=this.missionStats.getStats(),a=this.getWidth()-this.background.leftWidth-this.background.rightWidth-20,o=[this.createText("HP:"),this.createText("Gold:"),this.createText("Waves Survived:"),this.createText("Gold Earned:"),this.createText("Gold Spent:"),this.createText("----"),this.createText("Score:")],h=[this.createText(r.hp.toString(),"yellow"),this.createText(r.gold.toString(),"yellow"),this.createText(r.wavesSurvived.toString(),"yellow"),this.createText(r.goldEarned.toString(),"yellow"),this.createText(r.goldSpent.toString(),"yellow"),this.createText("----","yellow"),this.createText(r.score.toString(),"yellow")],l=300;for(let f=0;f<o.length;f++)if(o[f].text==="----"){const g=new Ct,m=n.y+n.height+10+f*s+s/2;g.moveTo(10,m),g.lineTo(a,m),g.stroke({color:"yellow",width:2}),e.addChild(g)}else o[f].x=10,o[f].y=n.y+n.height+10+f*s,e.addChild(o[f]),h[f].x=l,h[f].y=n.y+n.height+10+f*s,e.addChild(h[f]);const c=h[h.length-1].y+s+80,d=this.createText("Enter your name:");return d.y=c,e.addChild(d),this.playerNameTextInput=new Xd(a,Yt.MaximumPlayerNameLength),this.playerNameTextInput.container.y=d.y+d.height+10,e.addChild(this.playerNameTextInput.container),e}close(e){e===Le.Confirm?this.playerNameTextInput.getText().length==0?js.show(`Please enter your name.
(Just start typing, input bar is automatically selected.)`,["OK"]):(this.highScore.addScore({playerName:this.playerNameTextInput.getText(),score:this.missionStats.getStats().score,timestamp:Date.now()}),super.close(e)):super.close(e)}createText(e,s="#fff",n=!1){return new N({text:e,style:new W({fill:s,fontSize:24,fontWeight:n?"bold":"normal"})})}getWidth(){return 600}getHeight(){return 800}}const Bt={Retry:"Retry",MainMenu:"Main Menu",NextMission:"Next Mission"};class qd extends Bi{constructor(e,s,n){super([...s?[Bt.Retry]:[],...n?[Bt.NextMission]:[],Bt.MainMenu],s?Bt.Retry:n?Bt.NextMission:Bt.MainMenu,Bt.MainMenu);p(this,"dialogCaption");p(this,"highScore");this.highScore=new Si(e)}generate(){super.generate(),this.dialogCaption=new N({text:"Highscore",style:new W({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 _t({texture:C.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new tt,s=this.createText("Mission: "+this.highScore.missionName,"#fee",!0);e.addChild(s);const n=35,r=this.highScore.getScores();for(;r.length<10;)r.push({playerName:"---",score:0,timestamp:0});const a=[this.createText("#","#fee"),...r.map((d,f)=>this.createText((f+1).toString()))],o=[this.createText("Player","#fee",!0),...r.map(d=>this.createText(d.playerName))],h=[this.createText("Score","#fee",!0),...r.map(d=>this.createText(d.score.toString()))],l=a.reduce((d,f)=>Math.max(d,f.width),0)+20,c=l+o.reduce((d,f)=>Math.max(d,f.width),0)+20;for(let d=0;d<o.length;d++)a[d].x=10,a[d].y=n+10+d*n,e.addChild(a[d]),o[d].x=l,o[d].y=n+10+d*n,e.addChild(o[d]),h[d].x=c,h[d].y=n+10+d*n,e.addChild(h[d]);return e}createText(e,s="#fff",n=!1){return new N({text:e,style:new W({fill:s,fontSize:24,fontWeight:n?"bold":"normal"})})}getWidth(){return 600}getHeight(){return 800}}class Kd extends Bi{constructor(){super([]);p(this,"btnMainMenu");p(this,"btnRetry");p(this,"btnContinue");p(this,"_unsubKeypress");this._unsubKeypress=Se.onKeyPressed(this.onContinueClick.bind(this))}createContent(){const e=new tt;return this.btnMainMenu=new ut(new I(0,0,300,60),"Main Menu",ht.Button01),this.btnMainMenu.onClick=this.onMainMenuClick.bind(this),e.addChild(this.btnMainMenu.container),this.btnRetry=new ut(new I(0,70,300,60),"Retry",ht.Button01),this.btnRetry.onClick=this.onRetryClick.bind(this),e.addChild(this.btnRetry.container),this.btnContinue=new ut(new I(0,140,300,60),"Continue",ht.Button01),this.btnContinue.onClick=this.onContinueClick.bind(this),e.addChild(this.btnContinue.container),e}onMainMenuClick(){this.close(),this._unsubKeypress(),u.GameScene.UnpauseGame(),u.GameScene.destroy(),u.GameMaster.changeScene(new ge)}onRetryClick(){const e=u.GameScene.mission.name;this.close(),this._unsubKeypress(),u.GameScene.UnpauseGame(),u.GameScene.destroy(),u.GameMaster.changeScene(new ge),u.GameMaster.changeScene(new ve(e)),u.NotificationManager.Notify("Retrying mission.","green")}onContinueClick(){this.close(),u.GameScene.UnpauseGame()}}var Fa=(i=>(i[i.Purchase=0]="Purchase",i[i.Combat=1]="Combat",i[i.Misc=2]="Misc",i))(Fa||{});class ve extends ki{constructor(e){super();p(this,"isGameOver",!1);p(this,"mission");p(this,"missionIndex");p(this,"MissionStats");p(this,"roundMode");p(this,"ticker");p(this,"changeRoundButton");p(this,"sidebar");p(this,"tooltip");p(this,"towerPanel");p(this,"isPaused",!1);p(this,"gameSpeedMultiplier",1);p(this,"pauseButton");p(this,"visualGems",[]);p(this,"currentRound",0);p(this,"isWaveManagerFinished",!1);p(this,"playerWon",!1);p(this,"destroyTicker",!1);p(this,"offerGemsSprite");p(this,"dimGraphics",new Ct({x:0,y:0,zIndex:120}));p(this,"windowTitle");u.GameScene=this,this.windowTitle=document.title,C.Missions.forEach((s,n)=>{s.name==e&&(this.mission=s,this.missionIndex=n)})}init(){u.latestGemId=0,new zd(this.mission.gameMap,this.missionIndex),new Sd,new Ud(this.mission.rounds,this.mission.gameMap.paths),u.Grid.onGridCellClicked=(e,s)=>{u.TowerManager.isPlacingTower&&u.TowerManager.PlayerClickOnGrid(e,s)},u.WaveManager.events.on(re.CreepSpawned,e=>{u.Grid.addCreep(e),e.events.on(ot.Escaped,()=>{this.onCreepEscaped(e)})}),u.WaveManager.events.on(re.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(ot.Died,(e,s)=>{this.MissionStats.earnGold(e)}),this.towerPanel=new Od(Yt.SidebarRect),this.sidebar=new $d(Yt.SidebarRect),this.changeRoundButton=new ut(Yt.ChangeRoundButtonRect,"",ht.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),u.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new Yd(new I(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new $({texture:C.PlayIconTexture,x:this.changeRoundButton.container.width/2,y:this.changeRoundButton.container.height/2,scale:.2}),this.changeRoundButton.buttonIcon.anchor.set(.5,.5),this.changeRoundButton.container.addChild(this.changeRoundButton.buttonIcon)},this.changeRoundButton.CustomButtonLogic(),this.changeRoundButton.onClick=()=>{if(this.playerWon)return this.ReturnToMain();if(this.roundMode==1){this.gameSpeedMultiplier!==1?this.UpdateGameSpeedMultiplier(1):this.UpdateGameSpeedMultiplier(2);return}this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=C.FastForwardIconTexture,this.events.emit(re.NewWave,`${this.currentRound+1}`))},this.MissionStats=new Vd(100,250),this.events.on(Vs.TowerPanelSelectGem,(e,s,n)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return u.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,s,n)}),this.pauseButton=new ut(new I(5,5,120,80),"",ht.Button01,!0),this.pauseButton.container.removeFromParent(),this.stage.addChild(this.pauseButton.container),this.pauseButton.CustomButtonLogic=()=>{this.pauseButton.buttonIcon=new $({texture:C.PauseIconTexture,x:this.pauseButton.container.width/2,y:this.pauseButton.container.height/2,scale:.2}),this.pauseButton.buttonIcon.anchor.set(.5,.5),this.pauseButton.container.addChild(this.pauseButton.buttonIcon)},this.pauseButton.CustomButtonLogic(),this.pauseButton.onClick=()=>{this.isPaused?this.UnpauseGame():(this.ShowPauseDialog(),this.PauseGame())},this.ticker=new It,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(u.MouseX,u.MouseY),this.tooltip.Hide(),this.ticker.add(()=>{this.update&&this.update(this.ticker.elapsedMS)}),this.ticker.start()}update(e){if(this.isGameOver){this.destroyTicker&&(this.destroyTicker=!1,this.ticker.destroy());return}u.WaveManager.update(e),u.Grid.update(e),u.TowerManager.update(e),this.isWaveManagerFinished&&u.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=C.PlayIconTexture,u.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(u.NotificationManager.Notify("Mission victory!!","reward"),this.playerWon=!0):(this.OfferPlayerGems(),this.currentRound++)),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowEndgameDialog(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowEndgameDialog(!1))}DarkenScreen(){this.dimGraphics.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){u.Grid.gridInteractionEnabled=!1,u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new _t({width:380,height:150,texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:u.app.canvas.width/2-190,y:u.app.canvas.height/2-75}),u.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let s=new N({x:u.app.canvas.width/4,y:u.app.canvas.height/4,zIndex:this.dimGraphics.zIndex+1,text:"Choose a Gem as your reward for beating this round!",style:{fontSize:40,fill:"orange",fontWeight:"bold",stroke:{color:0,width:5}}});u.GameMaster.currentScene.stage.addChildAt(s,0),e.forEach((n,r)=>{let a=new Ps(n,!0),o=new Ze(0,u.app.stage,a);this.visualGems.push(o),o.container.x=this.offerGemsSprite.x-15+69*(r+1),o.container.y=this.offerGemsSprite.y+40,o.container.onpointermove=()=>{u.GameScene.tooltip.SetContentGem(a),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)},o.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},o.onClick=()=>{u.GameScene.tooltip.Hide(),s.destroy(),this.PlayerPickedGem(new Ps(n))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(s=>s.destroy()),u.Grid.gridInteractionEnabled=!0,this.MissionStats.giveGem(e),this.setRoundMode(0)}PauseGame(){this.isPaused=!0,this.ticker.stop(),document.title="[PAUSED] "+this.windowTitle}UnpauseGame(){this.isPaused=!1,this.ticker.start(),document.title=this.windowTitle}ShowPauseDialog(){new Kd().show()}async ShowEndgameDialog(e){await new jd(this.mission.name,this.MissionStats,e).show();const r=await new qd(this.mission.name,e,!e&&this.missionIndex+1<C.Missions.length).show();r===Bt.MainMenu?this.ReturnToMain():r===Bt.NextMission?(this.destroy(),u.GameMaster.changeScene(new ge),u.GameMaster.changeScene(new ve(C.Missions[this.missionIndex+1].name)),u.NotificationManager.Notify("Loading next mission. Good luck.","green")):r===Bt.Retry&&(this.destroy(),u.GameMaster.changeScene(new ge),u.GameMaster.changeScene(new ve(this.mission.name)),u.NotificationManager.Notify("Retrying mission.","green"))}onCreepEscaped(e){this.MissionStats.takeDamage(e.health)}setRoundMode(e){this.roundMode=e,this.roundMode==1?u.WaveManager.start(this.currentRound):u.WaveManager.end()}destroy(){super.destroy(),this.isGameOver=!0,this.destroyTicker=!0,u.GameScene=null}ReturnToMain(){u.GameMaster.changeScene(new ge)}UpdateGameSpeedMultiplier(e){this.gameSpeedMultiplier=e,e===1?u.NotificationManager.Notify("Regular speed.","info"):u.NotificationManager.Notify("Fast forward activated.","info")}}class ge extends ki{init(){this.addMainBackground();const t=new ut(new I(10,10,300,60),"Back to main",ht.Button01);t.onClick=e=>{u.GameMaster.changeScene(new qs)},C.Missions.forEach((e,s)=>{const n=new ut(new I(u.app.canvas.width/2-150,400+s*70,300,60),e.name,ht.Button01);n.onClick=r=>{u.GameMaster.changeScene(new ve(e.name))}})}}class qs extends ki{init(){this.addMainBackground();const t={caption:"Play",rect:new I(u.app.canvas.width/2-300/2,400+0*70,300,60),texture:ht.Button01},e={caption:"How to play",rect:new I(u.app.canvas.width/2-300/2,400+1*70,300,60),texture:ht.Button01};new I(u.app.canvas.width/2-300/2,400+2*70,300,60),ht.Button01;let s=new N({x:0,y:0,text:"Latest commit: "+u.latestCommit,style:{fill:16777215,fontSize:10,fontWeight:"bold"}});this.stage.addChild(s);const n=new ut(t.rect,t.caption,t.texture,!0);n.onClick=a=>{u.GameMaster.changeScene(new ge)};let r=new ut(e.rect,e.caption,e.texture,!0);r.onClick=a=>{u.GameMaster.changeScene(new bd)}}}class Zd{constructor(){p(this,"finished",!1);p(this,"calledBack",!1);p(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Qd extends Zd{constructor(e,s,n,r){super();p(this,"fadeType");p(this,"fadeTime");p(this,"pixiObject");p(this,"ticks",0);this.fadeType=e,this.fadeTime=s,this.pixiObject=n,this.callbackFn=r,e=="in"?this.pixiObject.alpha=0:this.pixiObject.alpha=1}update(e){if(super.update(e),this.pixiObject==null)return this.Finish();this.ticks++,this.fadeType=="in"?this.pixiObject.alpha=this.ticks/this.fadeTime:this.pixiObject.alpha-=1/this.fadeTime,this.ticks>=this.fadeTime&&this.Finish()}}class Jd{constructor(){p(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const s=this.AnimationQueue[e];s.finished?(s.callbackFn(),this.AnimationQueue.splice(e,1)):s.update(t)}}}class tu{constructor(t,e,s,n,r){p(this,"textObj");p(this,"ticksToFadeAway");p(this,"animating",!1);p(this,"destroyed",!1);let a=16777215;e=="info"?a=2143228:e=="warn"?a=16570144:e=="danger"?a=16517642:e=="reward"?a=14047996:e=="gemaward"?a=16777215:e=="green"&&(a=65280),this.ticksToFadeAway=r,this.textObj=new N({text:t,style:new W({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:s,y:n,zIndex:100}),this.textObj.anchor.set(.5,.5),u.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class eu extends Mt{constructor(){super();p(this,"notifications",[]);p(this,"ticks",0);this.bb.x=u.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,u.app.stage.addChild(this.container)}Notify(e,s){let n=0,r=this.notifications.length*32;this.notifications.push(new tu(e,s,n,r,this.ticks+180))}update(e){this.ticks++;for(let s=this.notifications.length-1;s>=0;s--){const n=this.notifications[s];if(n.destroyed){this.notifications.splice(s,1);continue}this.ticks>=n.ticksToFadeAway&&!n.animating&&(n.animating=!0,u.AnimationManager.Animate(new Qd("out",300,n.textObj,()=>{n.destroy()})))}}}class iu{constructor(t,e){p(this,"ticksToDestroyAt");p(this,"debris");this.debris=t,this.ticksToDestroyAt=e}destroy(){this.debris.destroy()}update(t){this.debris instanceof Mt&&this.debris.update(t)}}class su extends Mt{constructor(){super(...arguments);p(this,"ticks",0);p(this,"debris",[])}update(e){this.ticks++;for(let s=this.debris.length-1;s>=0;s--){const n=this.debris[s];this.ticks>=n.ticksToDestroyAt?(n.destroy(),this.debris.splice(s,1)):n.update(e)}}CreateDebris(e,s){s||(s=120),this.debris.push(new iu(e,this.ticks+s))}}(async()=>{const i=new Zr;u.app=i,await i.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(i.canvas);function t(){const n=window.innerWidth,r=window.innerHeight,a=n/i.screen.width,o=r/i.screen.height,h=Math.min(a,o),l=Math.round(i.screen.width*h),c=Math.round(i.screen.height*h),d=(n-l)/2,f=(r-c)/2;i.canvas.style.width=`${l}px`,i.canvas.style.height=`${c}px`,i.canvas.style.marginLeft=`${d}px`,i.canvas.style.marginTop=`${f}px`,i.canvas.style.marginRight="0",i.canvas.style.marginBottom="0",i.canvas.style.display="block"}u.latestCommit=await fetch("./latest_commit").then(n=>n.text()),window.addEventListener("resize",t),t(),await C.LoadAssets(),Yt.init(),Se.init(),new _d,u.AnimationManager=new Jd,u.NotificationManager=new eu,u.DebrisManager=new su,globalThis.Engine=u,It.shared.add(n=>{u.NotificationManager.update(n.elapsedMS),u.AnimationManager.update(n.elapsedMS),u.DebrisManager.update(n.elapsedMS)}),i.canvas.addEventListener("pointermove",function(n){u.MouseX=(n.clientX-i.canvas.offsetLeft)/i.canvas.offsetWidth*1920,u.MouseY=(n.clientY-i.canvas.offsetTop)/i.canvas.offsetHeight*1080}),u.GameMaster.changeScene(new qs),new URLSearchParams(location.href).entries().next().value[1]=="game"&&u.GameMaster.changeScene(new ve("The Turn")),u.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":u.TestSuite();let s=!1;window.addEventListener("blur",()=>{u.GameScene&&!u.GameScene.isPaused&&(u.GameScene.PauseGame(),s=!0)}),window.addEventListener("focus",()=>{u.GameScene&&s&&u.GameScene.isPaused&&(s=!1,u.GameScene.UnpauseGame())})})();export{U as $,Xr as A,it as B,tt as C,Q as D,G as E,pr as F,Ti as G,Et as H,mn as I,$ as J,Zo as K,ah as L,H as M,nt as N,I as O,lt as P,Ch as Q,ps as R,$h as S,Nt as T,yi as U,yn as V,ko as W,Wi as X,Y,mr as Z,jr as _,z as a,O as a0,Gh as a1,ra as a2,pl as a3,ml as a4,bl as a5,vl as a6,Cl as a7,xe as a8,W as a9,pc as aa,As as ab,da as ac,Mn as ad,ce as ae,md as af,Zn as ag,_c as ah,Ct as ai,q as aj,so as ak,Ts as al,qn as am,fa as an,It as b,gt as c,Vt as d,dt as e,An as f,Oh as g,pi as h,Is as i,$r as j,Ar as k,Nr as l,jn as m,nn as n,fl as o,gl as p,wl as q,mo as r,ta as s,Sl as t,Es as u,Lr as v,st as w,io as x,Al as y,zt as z};