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

297 lines
330 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-CVGpJBCa.js","assets/webworkerAll-CU4P2OK3.js","assets/colorToUniform-BiCyqw1t.js","assets/WebGPURenderer-BJsHNgQI.js","assets/SharedSystems-BKkjBxbn.js","assets/WebGLRenderer-B-VwtzIo.js"])))=>i.map(i=>d[i]);
var Ra=Object.defineProperty;var Fa=(s,t,e)=>t in s?Ra(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var p=(s,t,e)=>Fa(s,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();const La="modulepreload",Da=function(s){return"/"+s},js={},ci=function(t,e,i){let n=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=Promise.allSettled(e.map(h=>{if(h=Da(h),h in js)return;js[h]=!0;const c=h.endsWith(".css"),l=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${l}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":La,c||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((u,g)=>{d.addEventListener("load",u),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return n.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})};var k=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(k||{});const Ji=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},qe=(s,t)=>Ji(s).priority??t,lt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Ji).forEach(t=>{t.type.forEach(e=>{var i,n;return(n=(i=this._removeHandlers)[e])==null?void 0:n.call(i,t)})}),this},add(...s){return s.map(Ji).forEach(t=>{t.type.forEach(e=>{var r,a;const i=this._addHandlers,n=this._queue;i[e]?(a=i[e])==null||a.call(i,t):(n[e]=n[e]||[],(r=n[e])==null||r.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,n=this._removeHandlers;if(i[s]||n[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,n[s]=e;const r=this._queue;return r[s]&&((a=r[s])==null||a.forEach(o=>t(o)),delete r[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(r=>r.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((r,a)=>qe(a.value,e)-qe(r.value,e)))},i=>{const n=t.findIndex(r=>r.name===i.name);n!==-1&&t.splice(n,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,r)=>qe(r,e)-qe(n,e)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})}},za={extension:{type:k.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ci(()=>import("./browserAll-CVGpJBCa.js"),__vite__mapDeps([0,1,2]))}},Ua={extension:{type:k.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ci(()=>import("./webworkerAll-CU4P2OK3.js"),__vite__mapDeps([1,2]))}};class ut{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ut(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 vs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Jn={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function r(h,c,l,d,u){if(typeof l!="function")throw new TypeError("The listener must be a function");var g=new n(l,d||h,u),m=e?e+c:c;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,c){--h._eventsCount===0?h._events=new i:delete h._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,d;if(this._eventsCount===0)return c;for(d in l=this._events)t.call(l,d)&&c.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=e?e+c:c,d=this._events[l];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,g=d.length,m=new Array(g);u<g;u++)m[u]=d[u].fn;return m},o.prototype.listenerCount=function(c){var l=e?e+c:c,d=this._events[l];return d?d.fn?1:d.length:0},o.prototype.emit=function(c,l,d,u,g,m){var y=e?e+c:c;if(!this._events[y])return!1;var x=this._events[y],_=arguments.length,w,b;if(x.fn){switch(x.once&&this.removeListener(c,x.fn,void 0,!0),_){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,l),!0;case 3:return x.fn.call(x.context,l,d),!0;case 4:return x.fn.call(x.context,l,d,u),!0;case 5:return x.fn.call(x.context,l,d,u,g),!0;case 6:return x.fn.call(x.context,l,d,u,g,m),!0}for(b=1,w=new Array(_-1);b<_;b++)w[b-1]=arguments[b];x.fn.apply(x.context,w)}else{var S=x.length,T;for(b=0;b<S;b++)switch(x[b].once&&this.removeListener(c,x[b].fn,void 0,!0),_){case 1:x[b].fn.call(x[b].context);break;case 2:x[b].fn.call(x[b].context,l);break;case 3:x[b].fn.call(x[b].context,l,d);break;case 4:x[b].fn.call(x[b].context,l,d,u);break;default:if(!w)for(T=1,w=new Array(_-1);T<_;T++)w[T-1]=arguments[T];x[b].fn.apply(x[b].context,w)}}return!0},o.prototype.on=function(c,l,d){return r(this,c,l,d,!1)},o.prototype.once=function(c,l,d){return r(this,c,l,d,!0)},o.prototype.removeListener=function(c,l,d,u){var g=e?e+c:c;if(!this._events[g])return this;if(!l)return a(this,g),this;var m=this._events[g];if(m.fn)m.fn===l&&(!u||m.once)&&(!d||m.context===d)&&a(this,g);else{for(var y=0,x=[],_=m.length;y<_;y++)(m[y].fn!==l||u&&!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(c){var l;return c?(l=e?e+c:c,this._events[l]&&a(this,l)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})(Jn);var Wa=Jn.exports;const ft=vs(Wa),Oa=Math.PI*2,Na=180/Math.PI,Ha=Math.PI/180;class ht{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ht(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 Ai.x=0,Ai.y=0,Ai}}const Ai=new ht;class H{constructor(t=1,e=0,i=0,n=1,r=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,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,i,n,r,a){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new ht;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new ht;const i=this.a,n=this.b,r=this.c,a=this.d,o=this.tx,h=this.ty,c=1/(i*a+r*-n),l=t.x,d=t.y;return e.x=a*c*l+-r*c*d+(h*r-o*a)*c,e.y=i*c*d+-n*c*l+(-h*i+o*n)*c,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),i=Math.sin(t),n=this.a,r=this.c,a=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=r*e-this.d*i,this.d=r*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,n=this.c,r=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*r,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*r,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*r+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,r=t.c,a=t.d,o=t.tx,h=t.ty,c=e.a,l=e.b,d=e.c,u=e.d;return this.a=i*c+n*d,this.b=i*l+n*u,this.c=r*c+a*d,this.d=r*l+a*u,this.tx=o*c+h*d+e.tx,this.ty=o*l+h*u+e.ty,this}setTransform(t,e,i,n,r,a,o,h,c){return this.a=Math.cos(o+c)*r,this.b=Math.sin(o+c)*r,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*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 i=this.a,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*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,i=this.b,n=this.c,r=this.d,a=t.pivot,o=-Math.atan2(-n,r),h=Math.atan2(i,e),c=Math.abs(o+h);return c<1e-5||Math.abs(Oa-c)<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+i*i),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*i+a.y*r),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,a=t*n-e*i;return this.a=n/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*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 Va.identity()}static get shared(){return $a.identity()}}const $a=new H,Va=new H,Kt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Zt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Qt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Jt=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],ts=[],tr=[],Ke=Math.sign;function Xa(){for(let s=0;s<16;s++){const t=[];ts.push(t);for(let e=0;e<16;e++){const i=Ke(Kt[s]*Kt[e]+Qt[s]*Zt[e]),n=Ke(Zt[s]*Kt[e]+Jt[s]*Zt[e]),r=Ke(Kt[s]*Qt[e]+Qt[s]*Jt[e]),a=Ke(Zt[s]*Qt[e]+Jt[s]*Jt[e]);for(let o=0;o<16;o++)if(Kt[o]===i&&Zt[o]===n&&Qt[o]===r&&Jt[o]===a){t.push(o);break}}}for(let s=0;s<16;s++){const t=new H;t.set(Kt[s],Zt[s],Qt[s],Jt[s],0,0),tr.push(t)}}Xa();const Y={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:s=>Kt[s],uY:s=>Zt[s],vX:s=>Qt[s],vY:s=>Jt[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>ts[s][t],sub:(s,t)=>ts[s][Y.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?Y.S:Y.N:Math.abs(t)*2<=Math.abs(s)?s>0?Y.E:Y.W:t>0?s>0?Y.SE:Y.SW:s>0?Y.NE:Y.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const n=tr[Y.inv(t)];n.tx=e,n.ty=i,s.append(n)}},Ze=[new ht,new ht,new ht,new ht];class E{constructor(t=0,e=0,i=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new E(0,0,0,0)}clone(){return new E(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i){const{width:n,height:r}=this;if(n<=0||r<=0)return!1;const a=this.x,o=this.y,h=a-i/2,c=a+n+i/2,l=o-i/2,d=o+r+i/2,u=a+i/2,g=a+n-i/2,m=o+i/2,y=o+r-i/2;return t>=h&&t<=c&&e>=l&&e<=d&&!(t>u&&t<g&&e>m&&e<y)}intersects(t,e){if(!e){const G=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=G)return!1;const C=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>C}const i=this.left,n=this.right,r=this.top,a=this.bottom;if(n<=i||a<=r)return!1;const o=Ze[0].set(t.left,t.top),h=Ze[1].set(t.left,t.bottom),c=Ze[2].set(t.right,t.top),l=Ze[3].set(t.right,t.bottom);if(c.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(c,c),e.apply(l,l),Math.max(o.x,h.x,c.x,l.x)<=i||Math.min(o.x,h.x,c.x,l.x)>=n||Math.max(o.y,h.y,c.y,l.y)<=r||Math.min(o.y,h.y,c.y,l.y)>=a))return!1;const u=d*(h.y-o.y),g=d*(o.x-h.x),m=u*i+g*r,y=u*n+g*r,x=u*i+g*a,_=u*n+g*a;if(Math.max(m,y,x,_)<=u*o.x+g*o.y||Math.min(m,y,x,_)>=u*l.x+g*l.y)return!1;const w=d*(o.y-c.y),b=d*(c.x-o.x),S=w*i+b*r,T=w*n+b*r,F=w*i+b*a,P=w*n+b*a;return!(Math.max(S,T,F,P)<=w*o.x+b*o.y||Math.min(S,T,F,P)>=w*l.x+b*l.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=r-n,this}getBounds(t){return t=t||new E,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Mi={default:-1};function nt(s="default"){return Mi[s]===void 0&&(Mi[s]=-1),++Mi[s]}const qs={},O="8.0.0",Ya="8.3.4";function U(s,t,e=3){if(qs[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${s}`):(i=i.split(`
`).splice(e).join(`
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${s}`),console.warn(i))),qs[t]=!0}const er=()=>{};function Ks(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Zs(s){return!(s&s-1)&&!!s}function ja(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Qs=Object.create(null);function qa(s){const t=Qs[s];return t===void 0&&(Qs[s]=nt("resource")),t}const ir=class sr extends ft{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...sr.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=qa(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};ir.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Ka=ir;const nr=class rr extends ft{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={...rr.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Ka(ja(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=nt("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const n=Math.round(t*i),r=Math.round(e*i);return this.width=n/i,this.height=r/i,this._resolution=i,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=nt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=Zs(this.pixelWidth)&&Zs(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};nr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let zt=nr;class Cs extends zt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Cs.extension=k.TextureSource;const Js=new H;class Za{constructor(t,e){this.mapCoord=new H,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let n=0;n<t.length;n+=2){const r=t[n],a=t[n+1];e[n]=r*i.a+a*i.c+i.tx,e[n+1]=r*i.b+a*i.d+i.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 i=t.orig,n=t.trim;n&&(Js.set(i.width/n.width,0,0,i.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Js));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 ft{constructor({source:t,label:e,frame:i,orig:n,trim:r,defaultAnchor:a,defaultBorders:o,rotate:h,dynamic:c}={}){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 E,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new zt,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:l,height:d}=this._source;this.frame.width=l,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=c||!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 Za(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:n}=this._source,r=e.x/i,a=e.y/n,o=e.width/i,h=e.height/n;let c=this.rotate;if(c){const l=o/2,d=h/2,u=r+l,g=a+d;c=Y.add(c,Y.NW),t.x0=u+l*Y.uX(c),t.y0=g+d*Y.uY(c),c=Y.add(c,2),t.x1=u+l*Y.uX(c),t.y1=g+d*Y.uY(c),c=Y.add(c,2),t.x2=u+l*Y.uX(c),t.y2=g+d*Y.uY(c),c=Y.add(c,2),t.x3=u+l*Y.uX(c),t.y3=g+d*Y.uY(c)}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 zt({label:"EMPTY"})});z.EMPTY.destroy=er;z.WHITE=new z({source:new Cs({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});z.WHITE.destroy=er;function Qa(s,t,e,i){const{width:n,height:r}=e.orig,a=e.trim;if(a){const o=a.width,h=a.height;s.minX=a.x-t._x*n-i,s.maxX=s.minX+o,s.minY=a.y-t._y*r-i,s.maxY=s.minY+h}else s.minX=-t._x*n-i,s.maxX=s.minX+n,s.minY=-t._y*r-i,s.maxY=s.minY+r}const tn=new H;class Gt{constructor(t=1/0,e=1/0,i=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=tn,this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new E);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=tn,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,r){r||(r=this.matrix);const a=r.a,o=r.b,h=r.c,c=r.d,l=r.tx,d=r.ty;let u=this.minX,g=this.minY,m=this.maxX,y=this.maxY,x=a*t+h*e+l,_=o*t+c*e+d;x<u&&(u=x),_<g&&(g=_),x>m&&(m=x),_>y&&(y=_),x=a*i+h*e+l,_=o*i+c*e+d,x<u&&(u=x),_<g&&(g=_),x>m&&(m=x),_>y&&(y=_),x=a*t+h*n+l,_=o*t+c*n+d,x<u&&(u=x),_<g&&(g=_),x>m&&(m=x),_>y&&(y=_),x=a*i+h*n+l,_=o*i+c*n+d,x<u&&(u=x),_<g&&(g=_),x>m&&(m=x),_>y&&(y=_),this.minX=u,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,i=this.minY,n=this.maxX,r=this.maxY,{a,b:o,c:h,d:c,tx:l,ty:d}=t;let u=a*e+h*i+l,g=o*e+c*i+d;this.minX=u,this.minY=g,this.maxX=u,this.maxY=g,u=a*n+h*i+l,g=o*n+c*i+d,this.minX=u<this.minX?u:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=g>this.maxY?g:this.maxY,u=a*e+h*r+l,g=o*e+c*r+d,this.minX=u<this.minX?u:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=g>this.maxY?g:this.maxY,u=a*n+h*r+l,g=o*n+c*r+d,this.minX=u<this.minX?u:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=u>this.maxX?u: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,i,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),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 Gt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,n){let r=this.minX,a=this.minY,o=this.maxX,h=this.maxY;n||(n=this.matrix);const c=n.a,l=n.b,d=n.c,u=n.d,g=n.tx,m=n.ty;for(let y=e;y<i;y+=2){const x=t[y],_=t[y+1],w=c*x+d*_+g,b=l*x+u*_+m;r=w<r?w:r,a=b<a?b:a,o=w>o?w:o,h=b>h?b:h}this.minX=r,this.minY=a,this.maxX=o,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}var Ja={grad:.9,turn:360,rad:360/(2*Math.PI)},Bt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},at=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},xt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},ar=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},en=function(s){return{r:xt(s.r,0,255),g:xt(s.g,0,255),b:xt(s.b,0,255),a:xt(s.a)}},Pi=function(s){return{r:at(s.r),g:at(s.g),b:at(s.b),a:at(s.a,3)}},to=/^#([0-9a-f]{3,8})$/i,Qe=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},or=function(s){var t=s.r,e=s.g,i=s.b,n=s.a,r=Math.max(t,e,i),a=r-Math.min(t,e,i),o=a?r===t?(e-i)/a:r===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:r?a/r*100:0,v:r/255*100,a:n}},hr=function(s){var t=s.h,e=s.s,i=s.v,n=s.a;t=t/360*6,e/=100,i/=100;var r=Math.floor(t),a=i*(1-e),o=i*(1-(t-r)*e),h=i*(1-(1-t+r)*e),c=r%6;return{r:255*[i,o,a,a,h,i][c],g:255*[h,i,i,o,a,a][c],b:255*[a,a,h,i,i,o][c],a:n}},sn=function(s){return{h:ar(s.h),s:xt(s.s,0,100),l:xt(s.l,0,100),a:xt(s.a)}},nn=function(s){return{h:at(s.h),s:at(s.s),l:at(s.l),a:at(s.a,3)}},rn=function(s){return hr((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},Fe=function(s){return{h:(t=or(s)).h,s:(n=(200-(e=t.s))*(i=t.v)/100)>0&&n<200?e*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,i,n},eo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,io=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,so=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,no=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,es={string:[[function(s){var t=to.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?at(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?at(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=so.exec(s)||no.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:en({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=eo.exec(s)||io.exec(s);if(!t)return null;var e,i,n=sn({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Ja[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return rn(n)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,n=s.a,r=n===void 0?1:n;return Bt(t)&&Bt(e)&&Bt(i)?en({r:Number(t),g:Number(e),b:Number(i),a:Number(r)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,n=s.a,r=n===void 0?1:n;if(!Bt(t)||!Bt(e)||!Bt(i))return null;var a=sn({h:Number(t),s:Number(e),l:Number(i),a:Number(r)});return rn(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,n=s.a,r=n===void 0?1:n;if(!Bt(t)||!Bt(e)||!Bt(i))return null;var a=function(o){return{h:ar(o.h),s:xt(o.s,0,100),v:xt(o.v,0,100),a:xt(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(r)});return hr(a)},"hsv"]]},an=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},ro=function(s){return typeof s=="string"?an(s.trim(),es.string):typeof s=="object"&&s!==null?an(s,es.object):[null,void 0]},ki=function(s,t){var e=Fe(s);return{h:e.h,s:xt(e.s+100*t,0,100),l:e.l,a:e.a}},Gi=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},on=function(s,t){var e=Fe(s);return{h:e.h,s:e.s,l:xt(e.l+100*t,0,100),a:e.a}},is=function(){function s(t){this.parsed=ro(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return at(Gi(this.rgba),2)},s.prototype.isDark=function(){return Gi(this.rgba)<.5},s.prototype.isLight=function(){return Gi(this.rgba)>=.5},s.prototype.toHex=function(){return t=Pi(this.rgba),e=t.r,i=t.g,n=t.b,a=(r=t.a)<1?Qe(at(255*r)):"","#"+Qe(e)+Qe(i)+Qe(n)+a;var t,e,i,n,r,a},s.prototype.toRgb=function(){return Pi(this.rgba)},s.prototype.toRgbString=function(){return t=Pi(this.rgba),e=t.r,i=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+i+", "+n+", "+r+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,r},s.prototype.toHsl=function(){return nn(Fe(this.rgba))},s.prototype.toHslString=function(){return t=nn(Fe(this.rgba)),e=t.h,i=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+r+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,r},s.prototype.toHsv=function(){return t=or(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},s.prototype.invert=function(){return Tt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),Tt(ki(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),Tt(ki(this.rgba,-t))},s.prototype.grayscale=function(){return Tt(ki(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),Tt(on(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),Tt(on(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?Tt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=Fe(this.rgba);return typeof t=="number"?Tt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},s.prototype.isEqual=function(t){return this.toHex()===Tt(t).toHex()},s}(),Tt=function(s){return s instanceof is?s:new is(s)},hn=[],ao=function(s){s.forEach(function(t){hn.indexOf(t)<0&&(t(is,es),hn.push(t))})};function oo(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var n in e)i[e[n]]=n;var r={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=i[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),d=1/0,u="black";if(!r.length)for(var g in e)r[g]=new s(e[g]).toRgb();for(var m in e){var y=(o=l,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,u=m)}return u}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new s(h).toRgb():null},"name"])}ao([oo]);const ue=class Ie{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 Ie)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 i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="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,i,n]=this._components;return{r:t,g:e,b:i,a:n}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,n,r]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,n,r]=Ie._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(i=i*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,n=(a&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,n,r=255]=t,e/=255,i/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=Ie.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Tt(t);a.isValid()&&({r:e,g:i,b:n,a:r}=a.rgba,e/=255,i/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=n,this._components[3]=r,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Ie||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}};ue.shared=new ue;ue._temp=new ue;ue.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Z=ue;const ho={cullArea:null,cullable:!1,cullableChildren:!0};class Ts{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 i;let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class lo{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new Ts(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const Lt=new lo;function co(s,t,e){const i=s.length;let n;if(t>=i||e===0)return;e=t+e>i?i-t:e;const r=i-e;for(n=t;n<r;++n)s[n]=s[n+e];s.length=r}const uo={allowChildren:!0,removeChildren(s=0,t){const e=t??this.children.length,i=e-s,n=[];if(i>0&&i<=e){for(let a=e-1;a>=s;a--){const o=this.children[a];o&&(n.push(o),o.parent=null)}co(this.children,s,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let a=0;a<n.length;++a)this.emit("childRemoved",n[a],this,a),n[a].emit("removed",this);return n}else if(i===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||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(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const n=s.parent.children.indexOf(s);if(s.parent===this&&n===t)return s;n!==-1&&s.parent.children.splice(n,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s.didViewUpdate=!1,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s}};class ln{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 fo{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 i=this._tests[e];if(i.test(t))return Lt.get(i.maskClass,t)}return t}returnMaskEffect(t){Lt.return(t)}}const ss=new fo;lt.handleByList(k.MaskEffect,ss._effectClasses);const po={_maskEffect:null,_filterEffect:null,effects:[],addEffect(s){if(this.effects.indexOf(s)!==-1)return;this.effects.push(s),this.effects.sort((i,n)=>i.priority-n.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),ss.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=ss.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},set filters(s){var r;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new ln);s=s;const e=(s==null?void 0:s.length)>0,i=((r=t.filters)==null?void 0:r.length)>0,n=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new ln),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},go={label:null,get name(){return U(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){U(O,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const n=e[i];if(n.label===s||s instanceof RegExp&&s.test(n.label))return n}if(t)for(let i=0;i<e.length;i++){const r=e[i].getChildByLabel(s,!0);if(r)return r}return null},getChildrenByLabel(s,t=!1,e=[]){const i=this.children;for(let n=0;n<i.length;n++){const r=i[n];(r.label===s||s instanceof RegExp&&s.test(r.label))&&e.push(r)}if(t)for(let n=0;n<i.length;n++)i[n].getChildrenByLabel(s,!0,e);return e}},Dt=new Ts(H),fe=new Ts(Gt);function lr(s,t,e){e.clear();let i,n;return s.parent?t?i=s.parent.worldTransform:(n=Dt.get().identity(),i=di(s,n)):i=H.IDENTITY,cr(s,e,i,t),n&&Dt.return(n),e.isValid||e.set(0,0,0,0),e}function cr(s,t,e,i){var o,h;if(!s.visible||!s.measurable)return;let n;i?n=s.worldTransform:(s.updateLocalTransform(),n=Dt.get(),n.appendFrom(s.localTransform,e));const r=t,a=!!s.effects.length;if(a&&(t=fe.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.addBounds&&(t.matrix=n,s.addBounds(t));for(let c=0;c<s.children.length;c++)cr(s.children[c],t,n,i)}if(a){for(let c=0;c<s.effects.length;c++)(h=(o=s.effects[c]).addBounds)==null||h.call(o,t);r.addBounds(t,H.IDENTITY),fe.return(t)}i||Dt.return(n)}function di(s,t){const e=s.parent;return e&&(di(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}let Ii=0;const cn=500;function st(...s){Ii!==cn&&(Ii++,Ii===cn?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}function dr(s,t,e){return t.clear(),e||(e=H.IDENTITY),ur(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function ur(s,t,e,i,n){var h,c;let r;if(n)r=Dt.get(),r=e.copyTo(r);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const l=s.localTransform;r=Dt.get(),r.appendFrom(l,e)}const a=t,o=!!s.effects.length;if(o&&(t=fe.get().clear()),s.boundsArea)t.addRect(s.boundsArea,r);else{s.renderPipeId&&(t.matrix=r,s.addBounds(t));const l=s.children;for(let d=0;d<l.length;d++)ur(l[d],t,r,i,!1)}if(o){for(let l=0;l<s.effects.length;l++)(c=(h=s.effects[l]).addLocalBounds)==null||c.call(h,t,i);a.addBounds(t,H.IDENTITY),fe.return(t)}Dt.return(r)}function fr(s,t){const e=s.children;for(let i=0;i<e.length;i++){const n=e[i],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&&fr(n,t)}return t.didChange}const mo=new H,xo={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=s/t*e:this.scale.x=e},_setHeight(s,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=s/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Gt});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didViewChangeTick&&(s.didChange=!0,s.data[0]=this._didViewChangeTick),fr(this,s),s.didChange&&dr(this,s.localBounds,mo),s.localBounds},getBounds(s,t){return lr(this,s,t||new Gt)}},yo={_onRender:null,set onRender(s){const t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},_o={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,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(wo))}};function wo(s,t){return s._zIndex-t._zIndex}const bo={getGlobalPosition(s=new ht,t=!1){return this.parent?this.parent.toGlobal(this._position,s,t):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,t,e=!1){if(!e){this.updateLocalTransform();const i=di(this,new H);return i.append(this.localTransform),i.apply(s,t)}return this.worldTransform.apply(s,t)},toLocal(s,t,e,i){if(t&&(s=t.toGlobal(s,e,i)),!i){this.updateLocalTransform();const n=di(this,new H);return n.append(this.localTransform),n.applyInverse(s,e)}return this.worldTransform.applyInverse(s,e)}};let So=0;class pr{constructor(){this.uid=nt("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.tick=0}reset(){this.instructionSize=0,this.tick=So++}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class vo{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 pr,this._onRenderContainers=[]}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}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 i=0;i<e.length;i++)this.addChild(e[i])}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 i=0;i<e.length;i++)this.removeChild(e[i])}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 i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let n=0;n<i.length;n++)this._getChildren(i[n],e);return e}}function Co(s,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(s[i]=t[i])}const Bi=new ut(null),Ei=new ut(null),Ri=new ut(null,1,1),dn=1,To=2,Fi=4;class J extends ft{constructor(t={}){var e,i;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 ut(this,0,0),this._scale=Ri,this._pivot=Ei,this._skew=Bi,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=[],Co(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(n=>this.addChild(n)),(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(J.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 i=this.renderGroup||this.parentRenderGroup;return i&&i.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],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=Lt.get(vo,this),this.groupTransform=H.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Lt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new H),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Na}set angle(t){this.rotation=t*Ha}get pivot(){return this._pivot===Ei&&(this._pivot=new ut(this,0,0)),this._pivot}set pivot(t){this._pivot===Ei&&(this._pivot=new ut(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Bi&&(this._skew=new ut(this,0,0)),this._skew}set skew(t){this._skew===Bi&&(this._skew=new ut(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Ri&&(this._scale=new ut(this,1,1)),this._scale}set scale(t){this._scale===Ri&&(this._scale=new ut(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,n=this._pivot,r=this._position,a=i._x,o=i._y,h=n._x,c=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+c*e.c),e.ty=r._y-(h*e.b+c*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=dn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Z.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=dn,this._onUpdate())}get tint(){const t=this.localColor;return((t&255)<<16)+(t&65280)+(t>>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=To,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Fi,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|=Fi,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|=Fi,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}}J.mixin(uo);J.mixin(bo);J.mixin(yo);J.mixin(xo);J.mixin(po);J.mixin(go);J.mixin(_o);J.mixin(ho);class mi extends J{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=0,this._lastInstructionTick=-1,this._bounds=new Gt(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:i,y:n}=t;return i>=e.minX&&i<=e.maxX&&n>=e.minY&&n<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class $ extends mi{constructor(t=z.EMPTY){t instanceof z&&(t={texture:t});const{texture:e=z.EMPTY,anchor:i,roundPixels:n,width:r,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new ut({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof 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(){Qa(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:n,height:r}=e.orig;i.maxX=-t._x*n,i.minX=i.maxX+n,i.maxY=-t._y*r,i.minY=i.maxY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const Ao=new Gt;function gr(s,t,e){const i=Ao;s.measurable=!0,lr(s,e,i),t.addBoundsMask(i),s.measurable=!1}function mr(s,t,e){const i=fe.get();s.measurable=!0;const n=Dt.get().identity(),r=xr(s,e,n);dr(s,i,r),s.measurable=!1,t.addBoundsMask(i),Dt.return(n),fe.return(i)}function xr(s,t,e){return s?(s!==t&&(xr(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(st("Mask bounds, renderable is not inside the root container"),e)}class yr{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){gr(this.mask,t,e)}addLocalBounds(t,e){mr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof $}}yr.extension=k.MaskEffect;class _r{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"}}_r.extension=k.MaskEffect;class wr{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){gr(this.mask,t,e)}addLocalBounds(t,e){mr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof J}}wr.extension=k.MaskEffect;const Mo={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let un=Mo;const Q={get(){return un},set(s){un=s}};class br extends zt{constructor(t){t.resource||(t.resource=Q.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const n=super.resize(t,e,i);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}br.extension=k.TextureSource;class ye extends zt{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}}ye.extension=k.TextureSource;var ui=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(ui||{});class Li{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Sr=class pt{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 Li(null,null,1/0),this.deltaMS=1/pt.targetFPMS,this.elapsedMS=1/pt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=ui.NORMAL){return this._addListener(new Li(t,e,i))}addOnce(t,e,i=ui.NORMAL){return this._addListener(new Li(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const r=t-this._lastFrame|0;if(r<this._minElapsedMS)return;this._lastFrame=t-r%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*pt.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.emit(this);i.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),i=Math.min(Math.max(0,e)/1e3,pt.targetFPMS);this._maxElapsedMS=1/i}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(!pt._shared){const t=pt._shared=new pt;t.autoStart=!0,t._protected=!0}return pt._shared}static get system(){if(!pt._system){const t=pt._system=new pt;t.autoStart=!0,t._protected=!0}return pt._system}};Sr.targetFPMS=.06;let Pt=Sr,Di;async function vr(){return Di??(Di=(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 i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(i),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Di}const xi=class Cr extends zt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Cr.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=Pt.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 vr(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Pt.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||(Pt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Pt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};xi.extension=k.TextureSource;xi.defaultOptions={...zt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};xi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let oi=xi;const bt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class Po{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||st(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=bt(t);let n;for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];if(c.test(e)){n=c.getCacheableAssets(i,e);break}}const r=new Map(Object.entries(n||{}));n||i.forEach(h=>{r.set(h,e)});const a=[...r.keys()],o={cacheKeys:a,keys:i};i.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const c=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==c&&st("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){st(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const j=new Po,ns=[];lt.handleByList(k.TextureSource,ns);function Tr(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let n=0;n<ns.length;n++){const r=ns[n];if(r.test(e))return new r(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function ko(s={},t=!1){const e=s&&s.resource,i=e?s.resource:s,n=e?s:{resource:s};if(!t&&j.has(i))return j.get(i);const r=new z({source:Tr(n)});return r.on("destroy",()=>{j.has(i)&&j.remove(i)}),t||j.set(i,r),r}function Go(s,t=!1){return typeof s=="string"?j.get(s):s instanceof zt?new z({source:s}):ko(s,t)}z.from=Go;zt.from=Tr;lt.add(yr,_r,wr,oi,ye,br,Cs);var Ht=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(Ht||{});function wt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function Ae(s){return s.split("?")[0].split("#")[0]}function Io(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bo(s,t,e){return s.replace(new RegExp(Io(t),"g"),e)}function Eo(s,t){let e="",i=0,n=-1,r=0,a=-1;for(let o=0;o<=s.length;++o){if(o<s.length)a=s.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||i!==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="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),n=o,r=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=o,r=0;continue}}}else e.length>0?e+=`/${s.slice(n+1,o)}`:e=s.slice(n+1,o),i=o-n-1;n=o,r=0}else a===46&&r!==-1?++r:r=-1}return e}const gt={toPosix(s){return Bo(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){wt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(wt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=Ae(this.toPosix(t??Q.get().getBaseUrl())),n=Ae(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?gt.join(n,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(wt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=Eo(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return wt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(wt(i),i.length>0)if(t===void 0)t=i;else{const n=s[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(wt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,n=!0;const r=this.getProtocol(s),a=s;s=s.slice(r.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!n){i=o;break}}else n=!1;return i===-1?e?"/":this.isUrl(a)?r+s:r:e&&i===1?"//":r+s.slice(0,i)},rootname(s){wt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){wt(s),t&&wt(t),s=Ae(this.toPosix(s));let e=0,i=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(r=s.length-1;r>=0;--r){const h=s.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else o===-1&&(n=!1,o=r+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(i=r):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(r=s.length-1;r>=0;--r)if(s.charCodeAt(r)===47){if(!n){e=r+1;break}}else i===-1&&(n=!1,i=r+1);return i===-1?"":s.slice(e,i)},extname(s){wt(s),s=Ae(this.toPosix(s));let t=-1,e=0,i=-1,n=!0,r=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}i===-1&&(n=!1,i=a+1),o===46?t===-1?t=a:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||i===-1||r===0||r===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){wt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=Ae(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let n;t.root=this.rootname(s),i||this.hasProtocol(s)?n=1:n=0;let r=-1,a=0,o=-1,h=!0,c=s.length-1,l=0;for(;c>=n;--c){if(e=s.charCodeAt(c),e===47){if(!h){a=c+1;break}continue}o===-1&&(h=!1,o=c+1),e===46?r===-1?r=c:l!==1&&(l=1):r!==-1&&(l=-1)}return r===-1||o===-1||l===0||l===1&&r===o-1&&r===a+1?o!==-1&&(a===0&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,r),t.base=s.slice(1,o)):(t.name=s.slice(a,r),t.base=s.slice(a,o)),t.ext=s.slice(r,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Ar(s,t,e,i,n){const r=t[e];for(let a=0;a<r.length;a++){const o=r[a];e<t.length-1?Ar(s.replace(i[e],o),t,e+1,i,n):n.push(s.replace(i[e],o))}}function Ro(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const n=[];e.forEach(r=>{const a=r.substring(1,r.length-1).split(",");n.push(a)}),Ar(s,n,0,e,i)}else i.push(s);return i}const fi=s=>!Array.isArray(s);class _e{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return bt(e||i,r=>typeof r=="string"?r:Array.isArray(r)?r.map(a=>(a==null?void 0:a.src)??a):r!=null&&r.src?r.src:r,!0)}addManifest(t){this._manifest&&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 i=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,a])=>typeof a=="string"||Array.isArray(a)?{alias:r,src:a}:{alias:r,...a})),n.forEach(r=>{const a=r.src,o=r.alias;let h;if(typeof o=="string"){const c=this._createBundleAssetId(t,o);i.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));i.push(...c),h=[...o,...c]}this.add({...r,alias:h,src:a})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=r=>{this.hasKey(r)&&st(`[Resolver] already has key: ${r} overwriting`)},bt(e).forEach(r=>{const{src:a}=r;let{data:o,format:h,loadParser:c}=r;const l=bt(a).map(g=>typeof g=="string"?Ro(g):Array.isArray(g)?g:[g]),d=this.getAlias(r);Array.isArray(d)?d.forEach(i):i(d);const u=[];l.forEach(g=>{g.forEach(m=>{let y={};if(typeof m!="object"){y.src=m;for(let x=0;x<this._parsers.length;x++){const _=this._parsers[x];if(_.test(m)){y=_.parse(m);break}}}else o=m.data??o,h=m.format??h,c=m.loadParser??c,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:c}),u.push(y)})}),d.forEach(g=>{this._assetMap[g]=u})})}resolveBundle(t){const e=fi(t);t=bt(t);const i={};return t.forEach(n=>{const r=this._bundles[n];if(r){const a=this.resolve(r),o={};for(const h in a){const c=a[h];o[this._extractAssetIdFromBundle(n,h)]=c}i[n]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const n in e)i[n]=e[n].src;return i}return e.src}resolve(t){const e=fi(t);t=bt(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const a=this._getPreferredOrder(r);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const c=r.filter(l=>l[o]?l[o]===h:!1);c.length&&(r=c)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],n=this._preferredOrder.find(r=>r.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:i,data:n,loadParser:r,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=gt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.format=a??t.format??Fo(t.src),t}}_e.RETINA_PREFIX=/@([0-9\.]+)x/;function Fo(s){return s.split(".").pop().split("?").shift().split("#").shift()}const rs=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},Mr=class Be{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof z?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const i=parseFloat(e.meta.scale);i?(this.resolution=i,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Be.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Be.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const n=this._frameKeys[e],r=this._frames[n],a=r.frame;if(a){let o=null,h=null;const c=r.trimmed!==!1&&r.sourceSize?r.sourceSize:r.frame,l=new E(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);r.rotated?o=new E(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 E(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 E(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:l,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 i=0;i<t[e].length;i++){const n=t[e][i];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*Be.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Be.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].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=[]}};Mr.BATCH_SIZE=1e3;let fn=Mr;const Lo=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Pr(s,t,e){const i={};if(s.forEach(n=>{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[n]=t.textures[n]}),!e){const n=gt.dirname(s[0]);t.linkedSheets.forEach((r,a)=>{const o=Pr([`${n}/${t.data.meta.related_multi_packs[a]}`],r,!0);Object.assign(i,o)})}return i}const Do={extension:k.Asset,cache:{test:s=>s instanceof fn,getCacheableAssets:(s,t)=>Pr(s,t,!1)},resolver:{extension:{type:k.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),n=e.pop();return i==="json"&&Lo.includes(n)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=_e.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:k.LoadParser,priority:Ht.Normal,name:"spritesheetLoader"},async testParse(s,t){return gt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var c,l;const{texture:i,imageFilename:n}=(t==null?void 0:t.data)??{};let r=gt.dirname(t.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let a;if(i instanceof z)a=i;else{const d=rs(r+(n??s.meta.image),t.src);a=(await e.load([d]))[d]}const o=new fn(a.source,s);await o.parse();const h=(c=s==null?void 0:s.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const g of h){if(typeof g!="string")continue;let m=r+g;(l=t.data)!=null&&l.ignoreMultiPack||(m=rs(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const u=await Promise.all(d);o.linkedSheets=u,u.forEach(g=>{g.linkedSheets=[o].concat(o.linkedSheets.filter(m=>m!==g))})}return o},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};lt.add(Do);const zi=Object.create(null),pn=Object.create(null);function As(s,t){let e=pn[s];return e===void 0&&(zi[t]===void 0&&(zi[t]=1),pn[s]=e=zi[t]++),e}let ne;function kr(){return(!ne||ne!=null&&ne.isContextLost())&&(ne=Q.get().createCanvas().getContext("webgl",{})),ne}let Je;function zo(){if(!Je){Je="mediump";const s=kr();s&&s.getShaderPrecisionFormat&&(Je=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Je}function Uo(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),`
#ifdef GL_ES // This checks if it is WebGL1
#define in varying
#define finalColor gl_FragColor
#define texture texture2D
#endif
${s}
`):`
#ifdef GL_ES // This checks if it is WebGL1
#define in attribute
#define out varying
#endif
${s}
`}function Wo(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&i!=="highp"&&(n="mediump"),`precision ${n} float;
${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Oo(s,t){return t?`#version 300 es
${s}`:s}const No={},Ho={};function $o(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?No:Ho;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`}
${s}`}function Vo(s,t){return t?s.replace("#version 300 es",""):s}const Ui={stripVersion:Vo,ensurePrecision:Wo,addProgramDefines:Uo,setProgramName:$o,insertVersion:Oo},Wi=Object.create(null),Gr=class as{constructor(t){t={...as.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:zo()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(Ui).forEach(a=>{const o=i[a];n=Ui[a](n,o,!0),r=Ui[a](r,o,!1)}),this.fragment=n,this.vertex=r,this._key=As(`${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 Wi[e]||(Wi[e]=new as(t)),Wi[e]}};Gr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Ir=Gr;const gn={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Xo(s){return gn[s]??gn.float32}const Yo={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:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const n=s.indexOf("->",i);if(n!==-1){const r=s.substring(i,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(r))!==null;){const h=Yo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Xo(h).stride,offset:0,instance:!1,start:0}}}}return e}function Oi(s){var d,u;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=(d=s.match(t))==null?void 0:d.map(g=>({group:parseInt(g.match(e)[1],10),binding:parseInt(g.match(i)[1],10),name:g.match(n)[2],isUniform:g.match(n)[1]==="<uniform>",type:g.match(r)[1]}));if(!c)return{groups:[],structs:[]};const l=((u=s.match(a))==null?void 0:u.map(g=>{const m=g.match(h)[1],y=g.match(o).reduce((x,_)=>{const[w,b]=_.split(":");return x[w.trim()]=b.trim(),x},{});return y?{name:m,members:y}:null}).filter(({name:g})=>c.some(m=>m.type===g)))??[];return{groups:c,structs:l}}var Ee=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(Ee||{});function qo({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:Ee.VERTEX|Ee.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Ee.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:Ee.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function Ko({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Zo(s,t){const e=new Set,i=new Set,n=[...s.structs,...t.structs].filter(a=>e.has(a.name)?!1:(e.add(a.name),!0)),r=[...s.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:n,groups:r}}const Ni=Object.create(null);class yi{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:n,gpuLayout:r,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=i,e.source===i.source){const c=Oi(e.source);this.structsAndGroups=c}else{const c=Oi(i.source),l=Oi(e.source);this.structsAndGroups=Zo(c,l)}this.layout=n??Ko(this.structsAndGroups),this.gpuLayout=r??qo(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=As(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=jo(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Ni[e]||(Ni[e]=new yi(t)),Ni[e]}}const Br=["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>"],Qo=Br.reduce((s,t)=>(s[t]=!0,s),{});function Jo(s,t){switch(s){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 Er=class Rr{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={...Rr.defaultOptions,...e},this.uniformStructures=t;const i={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!Qo[r.type])throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${Br.join(", ")}`);r.value??(r.value=Jo(r.type,r.size)),i[n]=r.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=As(Object.keys(i).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Er.defaultOptions={ubo:!1,isStatic:!1};let Fr=Er;class hi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const n=t[i];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var n,r;const i=this.resources[e];t!==i&&(i&&((n=t.off)==null||n.call(t,"change",this.onResourceChange,this)),(r=t.on)==null||r.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const n=t[i];(e=n.off)==null||e.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var os=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(os||{});class Ms extends ft{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:n,resources:r,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=os.WEBGPU),i&&(a|=os.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 c in o)for(const l in o[c]){const d=o[c][l];h[d]={group:c,binding:l,name:d}}else if(e&&n&&!o){const c=e.structsAndGroups.groups;o={},c.forEach(l=>{o[l.group]=o[l.group]||{},o[l.group][l.binding]=l.name,h[l.name]=l})}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 c=0;for(const l in r)h[l]||(n[99]||(n[99]=new hi,this._ownedBindGroups.push(n[99])),h[l]={group:99,binding:c,name:l},o[99]=o[99]||{},o[99][c]=l,c++);for(const l in r){const d=l;let u=r[l];!u.source&&!u._resourceType&&(u=new Fr(u));const g=h[d];g&&(n[g.group]||(n[g.group]=new hi,this._ownedBindGroups.push(n[g.group])),n[g.group].setResource(u,g.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,i){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[i]||(r[i]=t),this.groups[e]||(this.groups[e]=new hi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const r=e[n];Object.defineProperty(i,r.name,{get(){return t[r.group].getResource(r.binding)},set(a){t[r.group].setResource(a,r.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...n}=t;let r,a;return e&&(r=yi.from(e)),i&&(a=Ir.from(i)),new Ms({gpuProgram:r,glProgram:a,...n})}}const hs=[];lt.handleByNamedList(k.Environment,hs);async function th(s){if(!s)for(let t=0;t<hs.length;t++){const e=hs[t];if(e.value.test()){await e.value.load();return}}}let Me;function eh(){if(typeof Me=="boolean")return Me;try{Me=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Me=!1}return Me}var Ps={exports:{}};Ps.exports=_i;Ps.exports.default=_i;function _i(s,t,e){e=e||2;var i=t&&t.length,n=i?t[0]*e:s.length,r=Lr(s,0,n,e,!0),a=[];if(!r||r.next===r.prev)return a;var o,h,c,l,d,u,g;if(i&&(r=ah(s,t,r,e)),s.length>80*e){o=c=s[0],h=l=s[1];for(var m=e;m<n;m+=e)d=s[m],u=s[m+1],d<o&&(o=d),u<h&&(h=u),d>c&&(c=d),u>l&&(l=u);g=Math.max(c-o,l-h),g=g!==0?32767/g:0}return ze(r,a,e,o,h,g,0),a}function Lr(s,t,e,i,n){var r,a;if(n===ds(s,t,e,i)>0)for(r=t;r<e;r+=i)a=mn(r,s[r],s[r+1],a);else for(r=e-i;r>=t;r-=i)a=mn(r,s[r],s[r+1],a);return a&&wi(a,a.next)&&(We(a),a=a.next),a}function se(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(wi(e,e.next)||q(e.prev,e,e.next)===0)){if(We(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ze(s,t,e,i,n,r,a){if(s){!a&&r&&dh(s,i,n,r);for(var o=s,h,c;s.prev!==s.next;){if(h=s.prev,c=s.next,r?sh(s,i,n,r):ih(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(c.i/e|0),We(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=nh(se(s),t,e),ze(s,t,e,i,n,r,2)):a===2&&rh(s,t,e,i,n,r):ze(se(s),t,e,i,n,r,1);break}}}}function ih(s){var t=s.prev,e=s,i=s.next;if(q(t,e,i)>=0)return!1;for(var n=t.x,r=e.x,a=i.x,o=t.y,h=e.y,c=i.y,l=n<r?n<a?n:a:r<a?r:a,d=o<h?o<c?o:c:h<c?h:c,u=n>r?n>a?n:a:r>a?r:a,g=o>h?o>c?o:c:h>c?h:c,m=i.next;m!==t;){if(m.x>=l&&m.x<=u&&m.y>=d&&m.y<=g&&he(n,o,r,h,a,c,m.x,m.y)&&q(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function sh(s,t,e,i){var n=s.prev,r=s,a=s.next;if(q(n,r,a)>=0)return!1;for(var o=n.x,h=r.x,c=a.x,l=n.y,d=r.y,u=a.y,g=o<h?o<c?o:c:h<c?h:c,m=l<d?l<u?l:u:d<u?d:u,y=o>h?o>c?o:c:h>c?h:c,x=l>d?l>u?l:u:d>u?d:u,_=ls(g,m,t,e,i),w=ls(y,x,t,e,i),b=s.prevZ,S=s.nextZ;b&&b.z>=_&&S&&S.z<=w;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&he(o,l,h,d,c,u,b.x,b.y)&&q(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&he(o,l,h,d,c,u,S.x,S.y)&&q(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=_;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&he(o,l,h,d,c,u,b.x,b.y)&&q(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=w;){if(S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&he(o,l,h,d,c,u,S.x,S.y)&&q(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function nh(s,t,e){var i=s;do{var n=i.prev,r=i.next.next;!wi(n,r)&&Dr(n,i,i.next,r)&&Ue(n,r)&&Ue(r,n)&&(t.push(n.i/e|0),t.push(i.i/e|0),t.push(r.i/e|0),We(i),We(i.next),i=s=r),i=i.next}while(i!==s);return se(i)}function rh(s,t,e,i,n,r){var a=s;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&ph(a,o)){var h=zr(a,o);a=se(a,a.next),h=se(h,h.next),ze(a,t,e,i,n,r,0),ze(h,t,e,i,n,r,0);return}o=o.next}a=a.next}while(a!==s)}function ah(s,t,e,i){var n=[],r,a,o,h,c;for(r=0,a=t.length;r<a;r++)o=t[r]*i,h=r<a-1?t[r+1]*i:s.length,c=Lr(s,o,h,i,!1),c===c.next&&(c.steiner=!0),n.push(fh(c));for(n.sort(oh),r=0;r<n.length;r++)e=hh(n[r],e);return e}function oh(s,t){return s.x-t.x}function hh(s,t){var e=lh(s,t);if(!e)return t;var i=zr(e,s);return se(i,i.next),se(e,e.next)}function lh(s,t){var e=t,i=s.x,n=s.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<=i&&o>r&&(r=o,a=e.x<e.next.x?e:e.next,o===i))return a}e=e.next}while(e!==t);if(!a)return null;var h=a,c=a.x,l=a.y,d=1/0,u;e=a;do i>=e.x&&e.x>=c&&i!==e.x&&he(n<l?i:r,n,c,l,n<l?r:i,n,e.x,e.y)&&(u=Math.abs(n-e.y)/(i-e.x),Ue(e,s)&&(u<d||u===d&&(e.x>a.x||e.x===a.x&&ch(a,e)))&&(a=e,d=u)),e=e.next;while(e!==h);return a}function ch(s,t){return q(s.prev,s,t.prev)<0&&q(t.next,s,s.next)<0}function dh(s,t,e,i){var n=s;do n.z===0&&(n.z=ls(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,uh(n)}function uh(s){var t,e,i,n,r,a,o,h,c=1;do{for(e=s,s=null,r=null,a=0;e;){for(a++,i=e,o=0,t=0;t<c&&(o++,i=i.nextZ,!!i);t++);for(h=c;o>0||h>0&&i;)o!==0&&(h===0||!i||e.z<=i.z)?(n=e,e=e.nextZ,o--):(n=i,i=i.nextZ,h--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;e=i}r.nextZ=null,c*=2}while(a>1);return s}function ls(s,t,e,i,n){return s=(s-e)*n|0,t=(t-i)*n|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function fh(s){var t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function he(s,t,e,i,n,r,a,o){return(n-a)*(t-o)>=(s-a)*(r-o)&&(s-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(n-a)*(i-o)}function ph(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!gh(s,t)&&(Ue(s,t)&&Ue(t,s)&&mh(s,t)&&(q(s.prev,s,t.prev)||q(s,t.prev,t))||wi(s,t)&&q(s.prev,s,s.next)>0&&q(t.prev,t,t.next)>0)}function q(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function wi(s,t){return s.x===t.x&&s.y===t.y}function Dr(s,t,e,i){var n=ei(q(s,t,e)),r=ei(q(s,t,i)),a=ei(q(e,i,s)),o=ei(q(e,i,t));return!!(n!==r&&a!==o||n===0&&ti(s,e,t)||r===0&&ti(s,i,t)||a===0&&ti(e,s,i)||o===0&&ti(e,t,i))}function ti(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function ei(s){return s>0?1:s<0?-1:0}function gh(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&Dr(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Ue(s,t){return q(s.prev,s,s.next)<0?q(s,t,s.next)>=0&&q(s,s.prev,t)>=0:q(s,t,s.prev)<0||q(s,s.next,t)<0}function mh(s,t){var e=s,i=!1,n=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function zr(s,t){var e=new cs(s.i,s.x,s.y),i=new cs(t.i,t.x,t.y),n=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=n,n.prev=e,i.next=e,e.prev=i,r.next=i,i.prev=r,i}function mn(s,t,e,i){var n=new cs(s,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function We(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function cs(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}_i.deviation=function(s,t,e,i){var n=t&&t.length,r=n?t[0]*e:s.length,a=Math.abs(ds(s,0,r,e));if(n)for(var o=0,h=t.length;o<h;o++){var c=t[o]*e,l=o<h-1?t[o+1]*e:s.length;a-=Math.abs(ds(s,c,l,e))}var d=0;for(o=0;o<i.length;o+=3){var u=i[o]*e,g=i[o+1]*e,m=i[o+2]*e;d+=Math.abs((s[u]-s[m])*(s[g+1]-s[u+1])-(s[u]-s[g])*(s[m+1]-s[u+1]))}return a===0&&d===0?0:Math.abs((d-a)/a)};function ds(s,t,e,i){for(var n=0,r=t,a=e-i;r<e;r+=i)n+=(s[a]-s[r])*(s[r+1]+s[a+1]),a=r;return n}_i.flatten=function(s){for(var t=s[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,n=0;n<s.length;n++){for(var r=0;r<s[n].length;r++)for(var a=0;a<t;a++)e.vertices.push(s[n][r][a]);n>0&&(i+=s[n-1].length,e.holes.push(i))}return e};var xh=Ps.exports;const yh=vs(xh);var Ur=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(Ur||{});class _h{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,r,a,o,h){const{name:c,items:l}=this;for(let d=0,u=l.length;d<u;d++)l[d][c](t,e,i,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 wh=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],Wr=class Or extends ft{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=[...wh,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await th(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...Or.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){let i=t;if(i instanceof J&&(i={container:i},e&&(U(O,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor=this.background.colorRgba),i.clearColor){const n=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=n?i.clearColor:Z.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i)}resize(t,e,i){const n=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==n&&this.runners.resolutionChange.emit(i)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=Ur.ALL);const{clear:i,clearColor:n,target:r}=t;Z.shared.setValue(n??this.background.colorRgba),e.renderTarget.clear(r,i,Z.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 _h(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const n in this.runners)this.runners[n].add(i);return this}_addPipes(t,e){const i=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,a=n.name,o=i[a];this.renderPipes[a]=new r(this,o?new o:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!eh())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Wr.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Nr=Wr,ii;function bh(s){return ii!==void 0||(ii=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??Nr.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}})()),ii}let si;async function Sh(s={}){return si!==void 0||(si=await(async()=>{const t=Q.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),si}const xn=["webgl","webgpu","canvas"];async function vh(s){let t=[];s.preference?(t.push(s.preference),xn.forEach(r=>{r!==s.preference&&t.push(r)})):t=xn.slice();let e,i={};for(let r=0;r<t.length;r++){const a=t[r];if(a==="webgpu"&&await Sh()){const{WebGPURenderer:o}=await ci(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-BJsHNgQI.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,i={...s,...s.webgpu};break}else if(a==="webgl"&&bh(s.failIfMajorPerformanceCaveat??Nr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await ci(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-B-VwtzIo.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,i={...s,...s.webgl};break}else if(a==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(i),n}const Hr="8.4.0";class $r{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Hr)}static destroy(){}}$r.extension=k.Application;class Ch{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Hr)}destroy(){this._renderer=null}}Ch.extension={type:[k.WebGLSystem,k.WebGPUSystem],name:"initHook",priority:-10};const Vr=class us{constructor(...t){this.stage=new J,t[0]!==void 0&&U(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await vh(t),us._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 i=us._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Vr._plugins=[];let Xr=Vr;lt.handleByList(k.Application,Xr._plugins);lt.add($r);class Yr extends ft{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 i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}const jr=class fs{constructor(t,e,i,n){this.uid=nt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=i,this.y1=n}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Z.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=fs.defaultTextureSize,{gradientStops:e}=this,i=Q.get().createCanvas();i.width=t,i.height=t;const n=i.getContext("2d"),r=n.createLinearGradient(0,0,fs.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 ye({resource:i,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:a,y0:o,x1:h,y1:c}=this,l=new H,d=h-a,u=c-o,g=Math.sqrt(d*d+u*u),m=Math.atan2(u,d);l.translate(-a,-o),l.scale(1/t,1/t),l.rotate(-m),l.scale(256/g,1),this.transform=l,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,i=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${i}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};jr.defaultTextureSize=256;let Oe=jr;const yn={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class bi{constructor(t,e){this.uid=nt("fillPattern"),this.transform=new H,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=yn[e].addressModeU,t.source.style.addressModeV=yn[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var Th=Mh,Hi={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Ah=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Mh(s){var t=[];return s.replace(Ah,function(e,i,n){var r=i.toLowerCase();for(n=kh(n),r=="m"&&n.length>2&&(t.push([i].concat(n.splice(0,2))),r="l",i=i=="m"?"l":"L");;){if(n.length==Hi[r])return n.unshift(i),t.push(n);if(n.length<Hi[r])throw new Error("malformed path data");t.push([i].concat(n.splice(0,Hi[r])))}}),t}var Ph=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function kh(s){var t=s.match(Ph);return t?t.map(Number):[]}const Gh=vs(Th);function Ih(s,t){const e=Gh(s),i=[];let n=null,r=0,a=0;for(let o=0;o<e.length;o++){const h=e[o],c=h[0],l=h;switch(c){case"M":r=l[1],a=l[2],t.moveTo(r,a);break;case"m":r+=l[1],a+=l[2],t.moveTo(r,a);break;case"H":r=l[1],t.lineTo(r,a);break;case"h":r+=l[1],t.lineTo(r,a);break;case"V":a=l[1],t.lineTo(r,a);break;case"v":a+=l[1],t.lineTo(r,a);break;case"L":r=l[1],a=l[2],t.lineTo(r,a);break;case"l":r+=l[1],a+=l[2],t.lineTo(r,a);break;case"C":r=l[5],a=l[6],t.bezierCurveTo(l[1],l[2],l[3],l[4],r,a);break;case"c":t.bezierCurveTo(r+l[1],a+l[2],r+l[3],a+l[4],r+l[5],a+l[6]),r+=l[5],a+=l[6];break;case"S":r=l[3],a=l[4],t.bezierCurveToShort(l[1],l[2],r,a);break;case"s":t.bezierCurveToShort(r+l[1],a+l[2],r+l[3],a+l[4]),r+=l[3],a+=l[4];break;case"Q":r=l[3],a=l[4],t.quadraticCurveTo(l[1],l[2],r,a);break;case"q":t.quadraticCurveTo(r+l[1],a+l[2],r+l[3],a+l[4]),r+=l[3],a+=l[4];break;case"T":r=l[1],a=l[2],t.quadraticCurveToShort(r,a);break;case"t":r+=l[1],a+=l[2],t.quadraticCurveToShort(r,a);break;case"A":r=l[6],a=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],r,a);break;case"a":r+=l[6],a+=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],r,a);break;case"Z":case"z":t.closePath(),i.length>0&&(n=i.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:st(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&n===null&&(n={startX:r,startY:a},i.push(n))}return t}class ks{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new ks(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const n=this.x-t,r=this.y-e,a=this.radius,o=i/2,h=Math.sqrt(n*n+r*r);return h<a+o&&h>a-o}getBounds(t){return t=t||new E,t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Gs{constructor(t=0,e=0,i=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=n}clone(){return new Gs(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(t,e,i){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const a=i/2,o=n-a,h=r-a,c=n+a,l=r+a,d=t-this.x,u=e-this.y,g=d*d/(o*o)+u*u/(h*h),m=d*d/(c*c)+u*u/(l*l);return g>1&&m<=1}getBounds(t){return t=t||new E,t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Bh(s,t,e,i,n,r){const a=s-e,o=t-i,h=n-e,c=r-i,l=a*h+o*c,d=h*h+c*c;let u=-1;d!==0&&(u=l/d);let g,m;u<0?(g=e,m=i):u>1?(g=n,m=r):(g=e+u*h,m=i+u*c);const y=s-g,x=t-m;return y*y+x*x}class Le{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let n=0,r=e.length;n<r;n++)i.push(e[n].x,e[n].y);e=i}this.points=e,this.closePath=!0}clone(){const t=this.points.slice(),e=new Le(t);return e.closePath=this.closePath,e}contains(t,e){let i=!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],c=this.points[a*2],l=this.points[a*2+1];h>e!=l>e&&t<(c-o)*((e-h)/(l-h))+o&&(i=!i)}return i}strokeContains(t,e,i){const n=i/2,r=n*n,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;h<o;h+=2){const c=a[h],l=a[h+1],d=a[(h+2)%a.length],u=a[(h+3)%a.length];if(Bh(t,e,c,l,d,u)<=r)return!0}return!1}getBounds(t){t=t||new E;const e=this.points;let i=1/0,n=-1/0,r=1/0,a=-1/0;for(let o=0,h=e.length;o<h;o+=2){const c=e[o],l=e[o+1];i=c<i?c:i,n=c>n?c:n,r=l<r?l:r,a=l>a?l:a}return t.x=i,t.width=n-i,t.y=r,t.height=a-r,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const ni=(s,t,e,i,n,r)=>{const a=s-e,o=t-i,h=Math.sqrt(a*a+o*o);return h>=n-r&&h<=n+r};class Is{constructor(t=0,e=0,i=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=r}getBounds(t){return t=t||new E,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Is(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let n=t-(this.x+i),r=e-(this.y+i);const a=i*i;if(n*n+r*r<=a||(n=t-(this.x+this.width-i),n*n+r*r<=a)||(r=e-(this.y+this.height-i),n*n+r*r<=a)||(n=t-(this.x+i),n*n+r*r<=a))return!0}return!1}strokeContains(t,e,i){const{x:n,y:r,width:a,height:o,radius:h}=this,c=i/2,l=n+h,d=r+h,u=a-h*2,g=o-h*2,m=n+a,y=r+o;return(t>=n-c&&t<=n+c||t>=m-c&&t<=m+c)&&e>=d&&e<=d+g||(e>=r-c&&e<=r+c||e>=y-c&&e<=y+c)&&t>=l&&t<=l+u?!0:t<l&&e<d&&ni(t,e,l,d,h,c)||t>m-h&&e<d&&ni(t,e,m-h,d,h,c)||t>m-h&&e>y-h&&ni(t,e,m-h,y-h,h,c)||t<l&&e>y-h&&ni(t,e,l,y-h,h,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Eh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function Rh(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function Fh(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=Eh.replace(/%forloop%/gi,Rh(s));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}}finally{t.deleteShader(e)}return s}let re=null;function qr(){var t;if(re)return re;const s=kr();return re=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),re=Fh(re,s),(t=s.getExtension("WEBGL_lose_context"))==null||t.loseContext(),re}const Kr={};function Lh(s,t){let e=2166136261;for(let i=0;i<t;i++)e^=s[i].uid,e=Math.imul(e,16777619),e>>>=0;return Kr[e]||Dh(s,t,e)}let $i=0;function Dh(s,t,e){const i={};let n=0;$i||($i=qr());for(let a=0;a<$i;a++){const o=a<t?s[a]:z.EMPTY.source;i[n++]=o.source,i[n++]=o.style}const r=new hi(i);return Kr[e]=r,r}class _n{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 wn(s,t){const e=s.byteLength/8|0,i=new Float64Array(s,0,e);new Float64Array(t,0,e).set(i);const r=s.byteLength-e*8;if(r>0){const a=new Uint8Array(s,e*8,r);new Uint8Array(t,e*8,r).set(a)}}const zh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Uh=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",s[s.NONE=4]="NONE",s))(Uh||{});function bn(s,t){return t.alphaMode==="no-premultiply-alpha"&&zh[s]||s}class Wh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class Oh{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Wh,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Zr=[];let ps=0;function Sn(){return ps>0?Zr[--ps]:new Oh}function vn(s){Zr[ps++]=s}let Pe=0;const Qr=class li{constructor(t={}){this.uid=nt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],li.defaultOptions.maxTextures=li.defaultOptions.maxTextures??qr(),t={...li.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:n}=t;this.attributeBuffer=new _n(i*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)vn(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 i=t._batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t._textureId=i,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 i=Sn(),n=i.textures;n.clear();const r=e[this.elementStart];let a=bn(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,c=this.indexBuffer;let l=this._batchIndexSize,d=this._batchIndexStart,u="startBatch";const g=this.maxTextures;for(let m=this.elementStart;m<this.elementSize;++m){const y=e[m];e[m]=null;const _=y.texture._source,w=bn(y.blendMode,_),b=a!==w;if(_._batchTick===Pe&&!b){y._textureId=_._textureBindLocation,l+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,o,h,y._attributeStart,y._textureId),this.packQuadIndex(c,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,o,h,y._attributeStart,y._textureId),this.packIndex(y,c,y._indexStart,y._attributeStart/this.vertexSize)),y._batch=i;continue}_._batchTick=Pe,(n.count>=g||b)&&(this._finishBatch(i,d,l-d,n,a,t,u),u="renderBatch",d=l,a=w,i=Sn(),n=i.textures,n.clear(),++Pe),y._textureId=_._textureBindLocation=n.count,n.ids[_.uid]=n.count,n.textures[n.count++]=_,y._batch=i,l+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,o,h,y._attributeStart,y._textureId),this.packQuadIndex(c,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,o,h,y._attributeStart,y._textureId),this.packIndex(y,c,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(i,d,l-d,n,a,t,u),d=l,++Pe),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=l}_finishBatch(t,e,i,n,r,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=n,t.blendMode=r,t.start=e,t.size=i,++Pe,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new _n(e);wn(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r<e.length;r++)n[r]=e[r];else wn(e.buffer,n.buffer);this.indexBuffer=n}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,n){const r=t.indices,a=t.indexSize,o=t.indexOffset,h=t.attributeOffset;for(let c=0;c<a;c++)e[i++]=n+r[c+o]-h}destroy(){for(let t=0;t<this.batches.length;t++)vn(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}};Qr.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Nh=Qr;var it=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(it||{});class Ot extends ft{constructor(t){let{data:e,size:i}=t;const{usage:n,label:r,shrinkToFit:a}=t;super(),this.uid=nt("buffer"),this._resourceType="buffer",this._resourceId=nt("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i=i??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:n,mappedAtCreation:o,label:r},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&it.STATIC)}set static(t){t?this.descriptor.usage|=it.STATIC:this.descriptor.usage&=~it.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const n=this._data;if(this._data=t,n.length!==t.length){!this.shrinkToFit&&t.byteLength<n.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=nt("resource"),this.emit("change",this));return}i&&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 Jr(s,t){if(!(s instanceof Ot)){let e=t?it.INDEX:it.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=it.INDEX|it.COPY_DST):(s=new Float32Array(s),e=it.VERTEX|it.COPY_DST)),s=new Ot({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return s}function Hh(s,t,e){const i=s.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const n=i.buffer.data;let r=1/0,a=1/0,o=-1/0,h=-1/0;const c=n.BYTES_PER_ELEMENT,l=(i.offset||0)/c,d=(i.stride||2*4)/c;for(let u=l;u<n.length;u+=d){const g=n[u],m=n[u+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 $h(s){return(s instanceof Ot||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=Jr(s.buffer,!1),s}class ta extends ft{constructor(t){const{attributes:e,indexBuffer:i,topology:n}=t;super(),this.uid=nt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Gt,this._boundsDirty=!0,this.attributes=e,this.buffers=[],this.instanceCount=t.instanceCount||1;for(const r in e){const a=e[r]=$h(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))}i&&(this.indexBuffer=Jr(i,!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,Hh(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 Vh=new Float32Array(1),Xh=new Uint32Array(1);class Yh extends ta{constructor(){const e=new Ot({data:Vh,label:"attribute-batch-buffer",usage:it.VERTEX|it.COPY_DST,shrinkToFit:!1}),i=new Ot({data:Xh,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:i})}}function Cn(s,t,e){if(s)for(const i in s){const n=i.toLocaleLowerCase(),r=t[n];if(r){let a=s[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(a)}else st(`${i} placement hook does not exist in shader`)}}const jh=/\{\{(.*?)\}\}/g;function Tn(s){var i;const t={};return(((i=s.match(jh))==null?void 0:i.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function An(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Mn(s,t,e=!1){const i=[];An(t,i),s.forEach(o=>{o.header&&An(o.header,i)});const n=i;e&&n.sort();const r=n.map((o,h)=>` @location(${h}) ${o},`).join(`
`);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",`
${r}
`),a}function Pn(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function qh(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Kh(s){const t=/@.*?\s+/g;return s.replace(t,"")}function Zh(s,t){const e=[];Pn(t,e),s.forEach(h=>{h.header&&Pn(h.header,e)});let i=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`,
`),r=e.sort().map(h=>` var ${Kh(h)};`).join(`
`),a=`return VSOutput(
${e.sort().map(h=>` ${qh(h)}`).join(`,
`)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",`
${n}
`),o=o.replace("{{start}}",`
${r}
`),o=o.replace("{{return}}",`
${a}
`),o}function kn(s,t){let e=s;for(const i in t){const n=t[i];n.join(`
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
${n.join(`
`)}
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const Wt=Object.create(null),Vi=new Map;let Qh=0;function Jh({template:s,bits:t}){const e=ea(s,t);if(Wt[e])return Wt[e];const{vertex:i,fragment:n}=el(s,t);return Wt[e]=ia(i,n,t),Wt[e]}function tl({template:s,bits:t}){const e=ea(s,t);return Wt[e]||(Wt[e]=ia(s.vertex,s.fragment,t)),Wt[e]}function el(s,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let n=Mn(e,s.vertex,!0);n=Zh(e,n);const r=Mn(i,s.fragment,!0);return{vertex:n,fragment:r}}function ea(s,t){return t.map(e=>(Vi.has(e)||Vi.set(e,Qh++),Vi.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function ia(s,t,e){const i=Tn(s),n=Tn(t);return e.forEach(r=>{Cn(r.vertex,i,r.name),Cn(r.fragment,n,r.name)}),{vertex:kn(s,i),fragment:kn(t,n)}}const il=`
@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}}
};
`,sl=`
@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;
};
`,nl=`
in vec2 aPosition;
in vec2 aUV;
out vec4 vColor;
out vec2 vUV;
{{header}}
void main(void){
mat3 worldTransformMatrix = uWorldTransformMatrix;
mat3 modelMatrix = mat3(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
);
vec2 position = aPosition;
vec2 uv = aUV;
{{start}}
vColor = vec4(1.);
{{main}}
vUV = uv;
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
vColor *= uWorldColorAlpha;
{{end}}
}
`,rl=`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
{{end}}
}
`,al={name:"global-uniforms-bit",vertex:{header:`
struct GlobalUniforms {
uProjectionMatrix:mat3x3<f32>,
uWorldTransformMatrix:mat3x3<f32>,
uWorldColorAlpha: vec4<f32>,
uResolution: vec2<f32>,
}
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
`}},ol={name:"global-uniforms-bit",vertex:{header:`
uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform vec4 uWorldColorAlpha;
uniform vec2 uResolution;
`}};function hl({bits:s,name:t}){const e=Jh({template:{fragment:sl,vertex:il},bits:[al,...s]});return yi.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function ll({bits:s,name:t}){return new Ir({name:t,...tl({template:{vertex:nl,fragment:rl},bits:[ol,...s]})})}const cl={name:"color-bit",vertex:{header:`
@in aColor: vec4<f32>;
`,main:`
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
`}},dl={name:"color-bit",vertex:{header:`
in vec4 aColor;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},Xi={};function ul(s){const t=[];if(s===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 i=0;i<s;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(`
`)}function fl(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<s;e++)e===s-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 pl(s){return Xi[s]||(Xi[s]={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;
${ul(s)}
`,main:`
var uvDx = dpdx(vUV);
var uvDy = dpdy(vUV);
${fl(s)}
`}}),Xi[s]}const Yi={};function gl(s){const t=[];for(let e=0;e<s;e++)e>0&&t.push("else"),e<s-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
`)}function ml(s){return Yi[s]||(Yi[s]={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[${s}];
`,main:`
${gl(s)}
`}}),Yi[s]}const xl={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;
}
`}},yl={name:"round-pixels-bit",vertex:{header:`
vec2 roundPixels(vec2 position, vec2 targetSize)
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
`}},Gn={};function _l(s){let t=Gn[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i<s;i++)e[i]=i;return t=Gn[s]=new Fr({uTextures:{value:e,type:"i32",size:s}},{isStatic:!0}),t}class wl extends Ms{constructor(t){const e=ll({name:"batch",bits:[dl,ml(t),yl]}),i=hl({name:"batch",bits:[cl,pl(t),xl]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:_l(t)}})}}let In=null;const sa=class na extends Nh{constructor(){super(...arguments),this.geometry=new Yh,this.shader=In||(In=new wl(this.maxTextures)),this.name=na.extension.name,this.vertexSize=6}packAttributes(t,e,i,n,r){const a=r<<16|t.roundPixels&65535,o=t.transform,h=o.a,c=o.b,l=o.c,d=o.d,u=o.tx,g=o.ty,{positions:m,uvs:y}=t,x=t.color,_=t.attributeOffset,w=_+t.attributeSize;for(let b=_;b<w;b++){const S=b*2,T=m[S],F=m[S+1];e[n++]=h*T+l*F+u,e[n++]=d*F+c*T+g,e[n++]=y[S],e[n++]=y[S+1],i[n++]=x,i[n++]=a}}packQuadAttributes(t,e,i,n,r){const a=t.texture,o=t.transform,h=o.a,c=o.b,l=o.c,d=o.d,u=o.tx,g=o.ty,m=t.bounds,y=m.maxX,x=m.minX,_=m.maxY,w=m.minY,b=a.uvs,S=t.color,T=r<<16|t.roundPixels&65535;e[n+0]=h*x+l*w+u,e[n+1]=d*w+c*x+g,e[n+2]=b.x0,e[n+3]=b.y0,i[n+4]=S,i[n+5]=T,e[n+6]=h*y+l*w+u,e[n+7]=d*w+c*y+g,e[n+8]=b.x1,e[n+9]=b.y1,i[n+10]=S,i[n+11]=T,e[n+12]=h*y+l*_+u,e[n+13]=d*_+c*y+g,e[n+14]=b.x2,e[n+15]=b.y2,i[n+16]=S,i[n+17]=T,e[n+18]=h*x+l*_+u,e[n+19]=d*_+c*x+g,e[n+20]=b.x3,e[n+21]=b.y3,i[n+22]=S,i[n+23]=T}};sa.extension={type:[k.Batcher],name:"default"};let bl=sa;function Sl(s,t,e,i,n,r,a,o=null){let h=0;e*=t,n*=r;const c=o.a,l=o.b,d=o.c,u=o.d,g=o.tx,m=o.ty;for(;h<a;){const y=s[e],x=s[e+1];i[n]=c*y+d*x+g,i[n+1]=l*y+u*x+m,n+=r,e+=t,h++}}function vl(s,t,e,i){let n=0;for(t*=e;n<i;)s[t]=0,s[t+1]=0,t+=e,n++}function ra(s,t,e,i,n){const r=t.a,a=t.b,o=t.c,h=t.d,c=t.tx,l=t.ty;e=e||0,i=i||2,n=n||s.length/i-e;let d=e*i;for(let u=0;u<n;u++){const g=s[d],m=s[d+1];s[d]=r*g+o*m+c,s[d+1]=a*g+h*m+l,d+=i}}function Cl(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;const e=s>>16&255,i=s>>8&255,n=s&255,r=t>>16&255,a=t>>8&255,o=t&255,h=e*r/255,c=i*a/255,l=n*o/255;return(h<<16)+(c<<8)+l}const Tl=new H;class aa{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,i=this.renderable;return i?Cl(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||Tl}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const Ne={extension:{type:k.ShapeBuilder,name:"circle"},build(s,t){let e,i,n,r,a,o;if(s.type==="circle"){const S=s;e=S.x,i=S.y,a=o=S.radius,n=r=0}else if(s.type==="ellipse"){const S=s;e=S.x,i=S.y,a=S.halfWidth,o=S.halfHeight,n=r=0}else{const S=s,T=S.width/2,F=S.height/2;e=S.x+T,i=S.y+F,a=o=Math.max(0,Math.min(S.radius,Math.min(T,F))),n=T-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)),c=h*8+(n?4:0)+(r?4:0);if(c===0)return t;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=i+r,t[2]=t[4]=e-n,t[5]=t[7]=i-r,t;let l=0,d=h*4+(n?2:0)+2,u=d,g=c,m=n+a,y=r,x=e+m,_=e-m,w=i+y;if(t[l++]=x,t[l++]=w,t[--d]=w,t[--d]=_,r){const S=i-y;t[u++]=_,t[u++]=S,t[--g]=S,t[--g]=x}for(let S=1;S<h;S++){const T=Math.PI/2*(S/h),F=n+Math.cos(T)*a,P=r+Math.sin(T)*o,G=e+F,v=e-F,C=i+P,K=i-P;t[l++]=G,t[l++]=C,t[--d]=C,t[--d]=v,t[u++]=v,t[u++]=K,t[--g]=K,t[--g]=G}m=n,y=r+o,x=e+m,_=e-m,w=i+y;const b=i-y;return t[l++]=x,t[l++]=w,t[--g]=b,t[--g]=x,n&&(t[l++]=_,t[l++]=w,t[--g]=b,t[--g]=_),t},triangulate(s,t,e,i,n,r){if(s.length===0)return;let a=0,o=0;for(let l=0;l<s.length;l+=2)a+=s[l],o+=s[l+1];a/=s.length/2,o/=s.length/2;let h=i;t[h*e]=a,t[h*e+1]=o;const c=h++;for(let l=0;l<s.length;l+=2)t[h*e]=s[l],t[h*e+1]=s[l+1],l>0&&(n[r++]=h,n[r++]=c,n[r++]=h-1),h++;n[r++]=c+1,n[r++]=c,n[r++]=h-1}},Al={...Ne,extension:{...Ne.extension,name:"ellipse"}},Ml={...Ne,extension:{...Ne.extension,name:"roundedRectangle"}},Pl=1e-4,Bn=1e-4;function kl(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,n=s[t-2],r=s[t-1];i<t;i+=2){const a=s[i],o=s[i+1];e+=(a-n)*(o+r),n=a,r=o}return e<0?-1:1}function En(s,t,e,i,n,r,a,o){const h=s-e*n,c=t-i*n,l=s+e*r,d=t+i*r;let u,g;a?(u=i,g=-e):(u=-i,g=e);const m=h+u,y=c+g,x=l+u,_=d+g;return o.push(m,y),o.push(x,_),2}function qt(s,t,e,i,n,r,a,o){const h=e-s,c=i-t;let l=Math.atan2(h,c),d=Math.atan2(n-s,r-t);o&&l<d?l+=Math.PI*2:!o&&l>d&&(d+=Math.PI*2);let u=l;const g=d-l,m=Math.abs(g),y=Math.sqrt(h*h+c*c),x=(15*m*Math.sqrt(y)/Math.PI>>0)+1,_=g/x;if(u+=_,o){a.push(s,t),a.push(e,i);for(let w=1,b=u;w<x;w++,b+=_)a.push(s,t),a.push(s+Math.sin(b)*y,t+Math.cos(b)*y);a.push(s,t),a.push(n,r)}else{a.push(e,i),a.push(s,t);for(let w=1,b=u;w<x;w++,b+=_)a.push(s+Math.sin(b)*y,t+Math.cos(b)*y),a.push(s,t);a.push(n,r),a.push(s,t)}return x*2}function Gl(s,t,e,i,n,r,a,o,h){const c=Pl;if(s.length===0)return;const l=t;let d=l.alignment;if(t.alignment!==.5){let V=kl(s);d=(d-.5)*V+.5}const u=new ht(s[0],s[1]),g=new ht(s[s.length-2],s[s.length-1]),m=i,y=Math.abs(u.x-g.x)<c&&Math.abs(u.y-g.y)<c;if(m){s=s.slice(),y&&(s.pop(),s.pop(),g.set(s[s.length-2],s[s.length-1]));const V=(u.x+g.x)*.5,Ut=(g.y+u.y)*.5;s.unshift(V,Ut),s.push(V,Ut)}const x=n,_=s.length/2;let w=s.length;const b=x.length/2,S=l.width/2,T=S*S,F=l.miterLimit*l.miterLimit;let P=s[0],G=s[1],v=s[2],C=s[3],K=0,It=0,L=-(G-C),R=P-v,X=0,tt=0,_t=Math.sqrt(L*L+R*R);L/=_t,R/=_t,L*=S,R*=S;const Hs=d,B=(1-Hs)*2,D=Hs*2;m||(l.cap==="round"?w+=qt(P-L*(B-D)*.5,G-R*(B-D)*.5,P-L*B,G-R*B,P+L*D,G+R*D,x,!0)+2:l.cap==="square"&&(w+=En(P,G,L,R,B,D,!0,x))),x.push(P-L*B,G-R*B),x.push(P+L*D,G+R*D);for(let V=1;V<_-1;++V){P=s[(V-1)*2],G=s[(V-1)*2+1],v=s[V*2],C=s[V*2+1],K=s[(V+1)*2],It=s[(V+1)*2+1],L=-(G-C),R=P-v,_t=Math.sqrt(L*L+R*R),L/=_t,R/=_t,L*=S,R*=S,X=-(C-It),tt=v-K,_t=Math.sqrt(X*X+tt*tt),X/=_t,tt/=_t,X*=S,tt*=S;const Ut=v-P,Se=G-C,ve=v-K,Ce=It-C,$s=Ut*ve+Se*Ce,Xe=Se*ve-Ce*Ut,Te=Xe<0;if(Math.abs(Xe)<.001*Math.abs($s)){x.push(v-L*B,C-R*B),x.push(v+L*D,C+R*D),$s>=0&&(l.join==="round"?w+=qt(v,C,v-L*B,C-R*B,v-X*B,C-tt*B,x,!1)+4:w+=2,x.push(v-X*D,C-tt*D),x.push(v+X*B,C+tt*B));continue}const Vs=(-L+P)*(-R+C)-(-L+v)*(-R+G),Xs=(-X+K)*(-tt+C)-(-X+v)*(-tt+It),Ye=(Ut*Xs-ve*Vs)/Xe,je=(Ce*Vs-Se*Xs)/Xe,Ti=(Ye-v)*(Ye-v)+(je-C)*(je-C),Vt=v+(Ye-v)*B,Xt=C+(je-C)*B,Yt=v-(Ye-v)*D,jt=C-(je-C)*D,Ba=Math.min(Ut*Ut+Se*Se,ve*ve+Ce*Ce),Ys=Te?B:D,Ea=Ba+Ys*Ys*T;Ti<=Ea?l.join==="bevel"||Ti/T>F?(Te?(x.push(Vt,Xt),x.push(v+L*D,C+R*D),x.push(Vt,Xt),x.push(v+X*D,C+tt*D)):(x.push(v-L*B,C-R*B),x.push(Yt,jt),x.push(v-X*B,C-tt*B),x.push(Yt,jt)),w+=2):l.join==="round"?Te?(x.push(Vt,Xt),x.push(v+L*D,C+R*D),w+=qt(v,C,v+L*D,C+R*D,v+X*D,C+tt*D,x,!0)+4,x.push(Vt,Xt),x.push(v+X*D,C+tt*D)):(x.push(v-L*B,C-R*B),x.push(Yt,jt),w+=qt(v,C,v-L*B,C-R*B,v-X*B,C-tt*B,x,!1)+4,x.push(v-X*B,C-tt*B),x.push(Yt,jt)):(x.push(Vt,Xt),x.push(Yt,jt)):(x.push(v-L*B,C-R*B),x.push(v+L*D,C+R*D),l.join==="round"?Te?w+=qt(v,C,v+L*D,C+R*D,v+X*D,C+tt*D,x,!0)+2:w+=qt(v,C,v-L*B,C-R*B,v-X*B,C-tt*B,x,!1)+2:l.join==="miter"&&Ti/T<=F&&(Te?(x.push(Yt,jt),x.push(Yt,jt)):(x.push(Vt,Xt),x.push(Vt,Xt)),w+=2),x.push(v-X*B,C-tt*B),x.push(v+X*D,C+tt*D),w+=2)}P=s[(_-2)*2],G=s[(_-2)*2+1],v=s[(_-1)*2],C=s[(_-1)*2+1],L=-(G-C),R=P-v,_t=Math.sqrt(L*L+R*R),L/=_t,R/=_t,L*=S,R*=S,x.push(v-L*B,C-R*B),x.push(v+L*D,C+R*D),m||(l.cap==="round"?w+=qt(v-L*(B-D)*.5,C-R*(B-D)*.5,v-L*B,C-R*B,v+L*D,C+R*D,x,!1)+2:l.cap==="square"&&(w+=En(v,C,L,R,B,D,!1,x)));const Ia=Bn*Bn;for(let V=b;V<w+b-2;++V)P=x[V*2],G=x[V*2+1],v=x[(V+1)*2],C=x[(V+1)*2+1],K=x[(V+2)*2],It=x[(V+2)*2+1],!(Math.abs(P*(C-It)+v*(It-G)+K*(G-C))<Ia)&&o.push(V,V+1,V+2)}function oa(s,t,e,i,n,r,a){const o=yh(s,t,2);if(!o)return;for(let c=0;c<o.length;c+=3)r[a++]=o[c]+n,r[a++]=o[c+1]+n,r[a++]=o[c+2]+n;let h=n*i;for(let c=0;c<s.length;c+=2)e[h]=s[c],e[h+1]=s[c+1],h+=i}const Il=[],Bl={extension:{type:k.ShapeBuilder,name:"polygon"},build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return t},triangulate(s,t,e,i,n,r){oa(s,Il,t,e,i,n,r)}},El={extension:{type:k.ShapeBuilder,name:"rectangle"},build(s,t){const e=s,i=e.x,n=e.y,r=e.width,a=e.height;return r>=0&&a>=0&&(t[0]=i,t[1]=n,t[2]=i+r,t[3]=n,t[4]=i+r,t[5]=n+a,t[6]=i,t[7]=n+a),t},triangulate(s,t,e,i,n,r){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[6],t[i+a+1]=s[7],a+=e,t[i+a]=s[4],t[i+a+1]=s[5],a+=e;const o=i/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2,n[r++]=o+1,n[r++]=o+3,n[r++]=o+2}},Rl={extension:{type:k.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,t},triangulate(s,t,e,i,n,r){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[4],t[i+a+1]=s[5];const o=i/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2}},Si={};lt.handleByMap(k.ShapeBuilder,Si);lt.add(El,Bl,Rl,Ne,Al,Ml);const Fl=new E;function Ll(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n<s.instructions.length;n++){const r=s.instructions[n];if(r.action==="texture")Dl(r.data,i,e);else if(r.action==="fill"||r.action==="stroke"){const a=r.action==="stroke",o=r.data.path.shapePath,h=r.data.style,c=r.data.hole;a&&c&&Rn(c.shapePath,h,null,!0,i,e),Rn(o,h,c,a,i,e)}}}function Dl(s,t,e){const{vertices:i,uvs:n,indices:r}=e,a=r.length,o=i.length/2,h=[],c=Si.rectangle,l=Fl,d=s.image;l.x=s.dx,l.y=s.dy,l.width=s.dw,l.height=s.dh;const u=s.transform;c.build(l,h),u&&ra(h,u),c.triangulate(h,i,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=Lt.get(aa);m.indexOffset=a,m.indexSize=r.length-a,m.attributeOffset=o,m.attributeSize=i.length/2-o,m.baseColor=s.style,m.alpha=s.alpha,m.texture=d,m.geometryData=e,t.push(m)}function Rn(s,t,e,i,n,r){const{vertices:a,uvs:o,indices:h}=r,c=s.shapePrimitives.length-1;s.shapePrimitives.forEach(({shape:l,transform:d},u)=>{const g=h.length,m=a.length/2,y=[],x=Si[l.type];if(x.build(l,y),d&&ra(y,d),i){const S=l.closePath??!0;Gl(y,t,!1,S,a,2,m,h)}else if(e&&c===u){c!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],T=y.slice();zl(e.shapePath).forEach(P=>{S.push(T.length/2),T.push(...P)}),oa(T,S,a,2,m,h,g)}else x.triangulate(y,a,2,m,h,g);const _=o.length/2,w=t.texture;if(w!==z.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),Sl(a,2,m,o,_,2,a.length/2-m,S))}else vl(o,_,2,a.length/2-m);const b=Lt.get(aa);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=w,b.geometryData=r,n.push(b)})}function zl(s){if(!s)return[];const t=s.shapePrimitives,e=[];for(let i=0;i<t.length;i++){const n=t[i].shape,r=[];Si[n.type].build(n,r),e.push(r)}return e}class Ul{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Wl{constructor(){this.batcher=new bl,this.instructions=new pr}init(){this.instructions.reset()}get geometry(){return U(Ya,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const Bs=class gs{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){gs.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??gs.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),Ll(t,e);const i=t.batchMode;t.customShader||i==="no-batch"?e.isBatchable=!1:i==="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=Lt.get(Wl),{batches:i,geometryData:n}=this._gpuContextHash[t.uid],r=n.vertices.length,a=n.indices.length;for(let l=0;l<i.length;l++)i[l].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(r),o.ensureIndexBuffer(a),o.begin();for(let l=0;l<i.length;l++){const d=i[l];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 c=o.batches;for(let l=0;l<c.length;l++){const d=c[l];d.bindGroup=Lh(d.textures.textures,d.textures.count)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new Ul;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]&&(Lt.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(i=>{Lt.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Bs.extension={type:[k.WebGLSystem,k.WebGPUSystem,k.CanvasSystem],name:"graphicsContext"};Bs.defaultOptions={bezierSmoothness:.5};let ha=Bs;const Ol=8,ri=11920929e-14,Nl=1;function la(s,t,e,i,n,r,a,o,h,c){const d=Math.min(.99,Math.max(0,c??ha.defaultOptions.bezierSmoothness));let u=(Nl-d)/1;return u*=u,Hl(t,e,i,n,r,a,o,h,s,u),s}function Hl(s,t,e,i,n,r,a,o,h,c){ms(s,t,e,i,n,r,a,o,h,c,0),h.push(a,o)}function ms(s,t,e,i,n,r,a,o,h,c,l){if(l>Ol)return;const d=(s+e)/2,u=(t+i)/2,g=(e+n)/2,m=(i+r)/2,y=(n+a)/2,x=(r+o)/2,_=(d+g)/2,w=(u+m)/2,b=(g+y)/2,S=(m+x)/2,T=(_+b)/2,F=(w+S)/2;if(l>0){let P=a-s,G=o-t;const v=Math.abs((e-a)*G-(i-o)*P),C=Math.abs((n-a)*G-(r-o)*P);if(v>ri&&C>ri){if((v+C)*(v+C)<=c*(P*P+G*G)){h.push(T,F);return}}else if(v>ri){if(v*v<=c*(P*P+G*G)){h.push(T,F);return}}else if(C>ri){if(C*C<=c*(P*P+G*G)){h.push(T,F);return}}else if(P=T-(s+a)/2,G=F-(t+o)/2,P*P+G*G<=c){h.push(T,F);return}}ms(s,t,d,u,_,w,T,F,h,c,l+1),ms(T,F,b,S,y,x,a,o,h,c,l+1)}const $l=8,Vl=11920929e-14,Xl=1;function Yl(s,t,e,i,n,r,a,o){const c=Math.min(.99,Math.max(0,o??ha.defaultOptions.bezierSmoothness));let l=(Xl-c)/1;return l*=l,jl(t,e,i,n,r,a,s,l),s}function jl(s,t,e,i,n,r,a,o){xs(a,s,t,e,i,n,r,o,0),a.push(n,r)}function xs(s,t,e,i,n,r,a,o,h){if(h>$l)return;const c=(t+i)/2,l=(e+n)/2,d=(i+r)/2,u=(n+a)/2,g=(c+d)/2,m=(l+u)/2;let y=r-t,x=a-e;const _=Math.abs((i-r)*x-(n-a)*y);if(_>Vl){if(_*_<=o*(y*y+x*x)){s.push(g,m);return}}else if(y=g-(t+r)/2,x=m-(e+a)/2,y*y+x*x<=o){s.push(g,m);return}xs(s,t,e,c,l,g,m,o,h+1),xs(s,g,m,d,u,r,a,o,h+1)}function ca(s,t,e,i,n,r,a,o){let h=Math.abs(n-r);(!a&&n>r||a&&r>n)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=n;c*=a?-1:1;for(let d=0;d<o+1;d++){const u=Math.cos(l),g=Math.sin(l),m=t+u*i,y=e+g*i;s.push(m,y),l+=c}}function ql(s,t,e,i,n,r){const a=s[s.length-2],h=s[s.length-1]-e,c=a-t,l=n-e,d=i-t,u=Math.abs(h*d-c*l);if(u<1e-8||r===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}const g=h*h+c*c,m=l*l+d*d,y=h*l+c*d,x=r*Math.sqrt(g)/u,_=r*Math.sqrt(m)/u,w=x*y/g,b=_*y/m,S=x*d+_*c,T=x*l+_*h,F=c*(_+w),P=h*(_+w),G=d*(x+b),v=l*(x+b),C=Math.atan2(P-T,F-S),K=Math.atan2(v-T,G-S);ca(s,S+t,T+e,r,C,K,c*l>d*h)}const De=Math.PI*2,ji={centerX:0,centerY:0,ang1:0,ang2:0},qi=({x:s,y:t},e,i,n,r,a,o,h)=>{s*=e,t*=i;const c=n*s-r*t,l=r*s+n*t;return h.x=c+a,h.y=l+o,h};function Kl(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,n=Math.cos(s),r=Math.sin(s),a=Math.cos(s+t),o=Math.sin(s+t);return[{x:n-r*i,y:r+n*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const Fn=(s,t,e,i)=>{const n=s*i-t*e<0?-1:1;let r=s*e+t*i;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},Zl=(s,t,e,i,n,r,a,o,h,c,l,d,u)=>{const g=Math.pow(n,2),m=Math.pow(r,2),y=Math.pow(l,2),x=Math.pow(d,2);let _=g*m-g*x-m*y;_<0&&(_=0),_/=g*x+m*y,_=Math.sqrt(_)*(a===o?-1:1);const w=_*n/r*d,b=_*-r/n*l,S=c*w-h*b+(s+e)/2,T=h*w+c*b+(t+i)/2,F=(l-w)/n,P=(d-b)/r,G=(-l-w)/n,v=(-d-b)/r,C=Fn(1,0,F,P);let K=Fn(F,P,G,v);o===0&&K>0&&(K-=De),o===1&&K<0&&(K+=De),u.centerX=S,u.centerY=T,u.ang1=C,u.ang2=K};function Ql(s,t,e,i,n,r,a,o=0,h=0,c=0){if(r===0||a===0)return;const l=Math.sin(o*De/360),d=Math.cos(o*De/360),u=d*(t-i)/2+l*(e-n)/2,g=-l*(t-i)/2+d*(e-n)/2;if(u===0&&g===0)return;r=Math.abs(r),a=Math.abs(a);const m=Math.pow(u,2)/Math.pow(r,2)+Math.pow(g,2)/Math.pow(a,2);m>1&&(r*=Math.sqrt(m),a*=Math.sqrt(m)),Zl(t,e,i,n,r,a,h,c,l,d,u,g,ji);let{ang1:y,ang2:x}=ji;const{centerX:_,centerY:w}=ji;let b=Math.abs(x)/(De/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);x/=S;let T=s[s.length-2],F=s[s.length-1];const P={x:0,y:0};for(let G=0;G<S;G++){const v=Kl(y,x),{x:C,y:K}=qi(v[0],r,a,d,l,_,w,P),{x:It,y:L}=qi(v[1],r,a,d,l,_,w,P),{x:R,y:X}=qi(v[2],r,a,d,l,_,w,P);la(s,T,F,C,K,It,L,R,X),T=R,F=X,y+=x}}function Jl(s,t,e){const i=(a,o)=>{const h=o.x-a.x,c=o.y-a.y,l=Math.sqrt(h*h+c*c),d=h/l,u=c/l;return{len:l,nx:d,ny:u}},n=(a,o)=>{a===0?s.moveTo(o.x,o.y):s.lineTo(o.x,o.y)};let r=t[t.length-1];for(let a=0;a<t.length;a++){const o=t[a%t.length],h=o.radius??e;if(h<=0){n(a,o),r=o;continue}const c=t[(a+1)%t.length],l=i(o,r),d=i(o,c);if(l.len<1e-4||d.len<1e-4){n(a,o),r=o;continue}let u=Math.asin(l.nx*d.ny-l.ny*d.nx),g=1,m=!1;l.nx*d.nx-l.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,g=-1,m=!0):u>0&&(g=-1,m=!0);const y=u/2;let x,_=Math.abs(Math.cos(y)*h/Math.sin(y));_>Math.min(l.len/2,d.len/2)?(_=Math.min(l.len/2,d.len/2),x=Math.abs(_*Math.sin(y)/Math.cos(y))):x=h;const w=o.x+d.nx*_+-d.ny*x*g,b=o.y+d.ny*_+d.nx*x*g,S=Math.atan2(l.ny,l.nx)+Math.PI/2*g,T=Math.atan2(d.ny,d.nx)-Math.PI/2*g;a===0&&s.moveTo(w+Math.cos(S)*x,b+Math.sin(S)*x),s.arc(w,b,x,S,T,m),r=o}}function tc(s,t,e,i){const n=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),r=(o,h,c)=>({x:o.x+(h.x-o.x)*c,y:o.y+(h.y-o.y)*c}),a=t.length;for(let o=0;o<a;o++){const h=t[(o+1)%a],c=h.radius??e;if(c<=0){o===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y);continue}const l=t[o],d=t[(o+2)%a],u=n(l,h);let g;if(u<1e-4)g=h;else{const x=Math.min(u/2,c);g=r(h,l,x/u)}const m=n(d,h);let y;if(m<1e-4)y=h;else{const x=Math.min(m/2,c);y=r(h,d,x/m)}o===0?s.moveTo(g.x,g.y):s.lineTo(g.x,g.y),s.quadraticCurveTo(h.x,h.y,y.x,y.y,i)}}const ec=new E;class ic{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Gt,this._graphicsPath2D=t}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,n=i[i.length-2],r=i[i.length-1];return(n!==t||r!==e)&&i.push(t,e),this}arc(t,e,i,n,r,a){this._ensurePoly(!1);const o=this._currentPoly.points;return ca(o,t,e,i,n,r,a),this}arcTo(t,e,i,n,r){this._ensurePoly();const a=this._currentPoly.points;return ql(a,t,e,i,n,r),this}arcToSvg(t,e,i,n,r,a,o){const h=this._currentPoly.points;return Ql(h,this._currentPoly.lastX,this._currentPoly.lastY,a,o,t,e,i,n,r),this}bezierCurveTo(t,e,i,n,r,a,o){this._ensurePoly();const h=this._currentPoly;return la(this._currentPoly.points,h.lastX,h.lastY,t,e,i,n,r,a,o),this}quadraticCurveTo(t,e,i,n,r){this._ensurePoly();const a=this._currentPoly;return Yl(this._currentPoly.points,a.lastX,a.lastY,t,e,i,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 i=0;i<t.instructions.length;i++){const n=t.instructions[i];this[n.action](...n.data)}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,n,r){return this.drawShape(new E(t,e,i,n),r),this}circle(t,e,i,n){return this.drawShape(new ks(t,e,i),n),this}poly(t,e,i){const n=new Le(t);return n.closePath=e,this.drawShape(n,i),this}regularPoly(t,e,i,n,r=0,a){n=Math.max(n|0,3);const o=-1*Math.PI/2+r,h=Math.PI*2/n,c=[];for(let l=0;l<n;l++){const d=l*h+o;c.push(t+i*Math.cos(d),e+i*Math.sin(d))}return this.poly(c,!0,a),this}roundPoly(t,e,i,n,r,a=0,o){if(n=Math.max(n|0,3),r<=0)return this.regularPoly(t,e,i,n,a);const h=i*Math.sin(Math.PI/n)-.001;r=Math.min(r,h);const c=-1*Math.PI/2+a,l=Math.PI*2/n,d=(n-2)*Math.PI/n/2;for(let u=0;u<n;u++){const g=u*l+c,m=t+i*Math.cos(g),y=e+i*Math.sin(g),x=g+Math.PI+d,_=g-Math.PI-d,w=m+r*Math.cos(x),b=y+r*Math.sin(x),S=m+r*Math.cos(_),T=y+r*Math.sin(_);u===0?this.moveTo(w,b):this.lineTo(w,b),this.quadraticCurveTo(m,y,S,T,o)}return this.closePath()}roundShape(t,e,i=!1,n){return t.length<3?this:(i?tc(this,t,e,n):Jl(this,t,e),this.closePath())}filletRect(t,e,i,n,r){if(r===0)return this.rect(t,e,i,n);const a=Math.min(i,n)/2,o=Math.min(a,Math.max(-a,r)),h=t+i,c=e+n,l=o<0?-o:0,d=Math.abs(o);return this.moveTo(t,e+d).arcTo(t+l,e+l,t+d,e,d).lineTo(h-d,e).arcTo(h-l,e+l,h,e+d,d).lineTo(h,c-d).arcTo(h-l,c-l,t+i-d,c,d).lineTo(t+d,c).arcTo(t+l,c-l,t,c-d,d).closePath()}chamferRect(t,e,i,n,r,a){if(r<=0)return this.rect(t,e,i,n);const o=Math.min(r,Math.min(i,n)/2),h=t+i,c=e+n,l=[t+o,e,h-o,e,h,e+o,h,c-o,h-o,c,t+o,c,t,c-o,t,e+o];for(let d=l.length-1;d>=2;d-=2)l[d]===l[d-2]&&l[d-1]===l[d-3]&&l.splice(d-1,2);return this.poly(l,!0,a)}ellipse(t,e,i,n,r){return this.drawShape(new Gs(t,e,i,n),r),this}roundRect(t,e,i,n,r,a){return this.drawShape(new Is(t,e,i,n,r),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new Le,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Le,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,a=i;i=r.a*i+r.c*n+r.tx,n=r.b*a+r.d*n+r.ty}this._currentPoly.points.push(i,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const n=e[i],r=n.shape.getBounds(ec);n.transform?t.addRect(r,n.transform):t.addRect(r)}return t}}class pe{constructor(t){this.instructions=[],this.uid=nt("graphicsPath"),this._dirty=!0,typeof t=="string"?Ih(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new ic(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,i,n,r){const a=this.instructions[this.instructions.length-1],o=this.getLastPoint(ht.shared);let h=0,c=0;if(!a||a.action!=="bezierCurveTo")h=o.x,c=o.y;else{h=a.data[2],c=a.data[3];const l=o.x,d=o.y;h=l+(l-h),c=d+(d-c)}return this.instructions.push({action:"bezierCurveTo",data:[h,c,t,e,i,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,i){const n=this.instructions[this.instructions.length-1],r=this.getLastPoint(ht.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,c=r.y;a=h+(h-a),o=c+(c-o)}return this.instructions.push({action:"quadraticCurveTo",data:[a,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,n,r){return this.instructions.push({action:"rect",data:[t,e,i,n,r]}),this._dirty=!0,this}circle(t,e,i,n){return this.instructions.push({action:"circle",data:[t,e,i,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,i,n,r,a,o){r=r||n/2;const h=-1*Math.PI/2+a,c=i*2,l=Math.PI*2/c,d=[];for(let u=0;u<c;u++){const g=u%2?r:n,m=u*l+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 pe;if(!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const n=this.instructions[i];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,i=t.b,n=t.c,r=t.d,a=t.tx,o=t.ty;let h=0,c=0,l=0,d=0,u=0,g=0,m=0,y=0;for(let x=0;x<this.instructions.length;x++){const _=this.instructions[x],w=_.data;switch(_.action){case"moveTo":case"lineTo":h=w[0],c=w[1],w[0]=e*h+n*c+a,w[1]=i*h+r*c+o;break;case"bezierCurveTo":l=w[0],d=w[1],u=w[2],g=w[3],h=w[4],c=w[5],w[0]=e*l+n*d+a,w[1]=i*l+r*d+o,w[2]=e*u+n*g+a,w[3]=i*u+r*g+o,w[4]=e*h+n*c+a,w[5]=i*h+r*c+o;break;case"quadraticCurveTo":l=w[0],d=w[1],h=w[2],c=w[3],w[0]=e*l+n*d+a,w[1]=i*l+r*d+o,w[2]=e*h+n*c+a,w[3]=i*h+r*c+o;break;case"arcToSvg":h=w[5],c=w[6],m=w[0],y=w[1],w[0]=e*m+n*y,w[1]=i*m+r*y,w[5]=e*h+n*c+a,w[6]=i*h+r*c+o;break;case"circle":w[4]=ke(w[3],t);break;case"rect":w[4]=ke(w[4],t);break;case"ellipse":w[8]=ke(w[8],t);break;case"roundRect":w[5]=ke(w[5],t);break;case"addPath":w[0].transform(t);break;case"poly":w[2]=ke(w[2],t);break;default:st("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t);break}return t}}function ke(s,t){return s?s.prepend(t):t.clone()}function sc(s,t){if(typeof s=="string"){const i=document.createElement("div");i.innerHTML=s.trim(),s=i.querySelector("svg")}const e={context:t,path:new pe};return da(s,e,null,null),t}function da(s,t,e,i){const n=s.children,{fillStyle:r,strokeStyle:a}=nc(s);r&&e?e={...e,...r}:r&&(e=r),a&&i?i={...i,...a}:a&&(i=a),t.context.fillStyle=e,t.context.strokeStyle=i;let o,h,c,l,d,u,g,m,y,x,_,w,b,S,T,F,P;switch(s.nodeName.toLowerCase()){case"path":S=s.getAttribute("d"),T=new pe(S),t.context.path(T),e&&t.context.fill(),i&&t.context.stroke();break;case"circle":g=rt(s,"cx",0),m=rt(s,"cy",0),y=rt(s,"r",0),t.context.ellipse(g,m,y,y),e&&t.context.fill(),i&&t.context.stroke();break;case"rect":o=rt(s,"x",0),h=rt(s,"y",0),F=rt(s,"width",0),P=rt(s,"height",0),x=rt(s,"rx",0),_=rt(s,"ry",0),x||_?t.context.roundRect(o,h,F,P,x||_):t.context.rect(o,h,F,P),e&&t.context.fill(),i&&t.context.stroke();break;case"ellipse":g=rt(s,"cx",0),m=rt(s,"cy",0),x=rt(s,"rx",0),_=rt(s,"ry",0),t.context.beginPath(),t.context.ellipse(g,m,x,_),e&&t.context.fill(),i&&t.context.stroke();break;case"line":c=rt(s,"x1",0),l=rt(s,"y1",0),d=rt(s,"x2",0),u=rt(s,"y2",0),t.context.beginPath(),t.context.moveTo(c,l),t.context.lineTo(d,u),i&&t.context.stroke();break;case"polygon":b=s.getAttribute("points"),w=b.match(/\d+/g).map(G=>parseInt(G,10)),t.context.poly(w,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":b=s.getAttribute("points"),w=b.match(/\d+/g).map(G=>parseInt(G,10)),t.context.poly(w,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let G=0;G<n.length;G++)da(n[G],t,e,i)}function rt(s,t,e){const i=s.getAttribute(t);return i?Number(i):e}function nc(s){const t=s.getAttribute("style"),e={},i={};let n=!1,r=!1;if(t){const a=t.split(";");for(let o=0;o<a.length;o++){const h=a[o],[c,l]=h.split(":");switch(c){case"stroke":l!=="none"&&(e.color=Z.shared.setValue(l).toNumber(),r=!0);break;case"stroke-width":e.width=Number(l);break;case"fill":l!=="none"&&(n=!0,i.color=Z.shared.setValue(l).toNumber());break;case"fill-opacity":i.alpha=Number(l);break;case"stroke-opacity":e.alpha=Number(l);break;case"opacity":i.alpha=Number(l),e.alpha=Number(l);break}}}else{const a=s.getAttribute("stroke");a&&a!=="none"&&(r=!0,e.color=Z.shared.setValue(a).toNumber(),e.width=rt(s,"stroke-width",1));const o=s.getAttribute("fill");o&&o!=="none"&&(n=!0,i.color=Z.shared.setValue(o).toNumber())}return{strokeStyle:r?e:null,fillStyle:n?i:null}}function rc(s){return Z.isColorLike(s)}function Ln(s){return s instanceof bi}function Dn(s){return s instanceof Oe}function ac(s,t,e){const i=Z.shared.setValue(t??0);return s.color=i.toNumber(),s.alpha=i.alpha===1?e.alpha:i.alpha,s.texture=z.WHITE,{...e,...s}}function zn(s,t,e){return s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,{...e,...s}}function Un(s,t,e){return t.buildLinearGradient(),s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,{...e,...s}}function oc(s,t){var n;const e={...t,...s};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 i=Z.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e.matrix=e.matrix?e.matrix.clone():null,e}function ee(s,t){if(s==null)return null;const e={},i=s;return rc(s)?ac(e,s,t):Ln(s)?zn(e,s,t):Dn(s)?Un(e,s,t):i.fill&&Ln(i.fill)?zn(i,i.fill,t):i.fill&&Dn(i.fill)?Un(i,i.fill,t):oc(i,t)}function pi(s,t){const{width:e,alignment:i,miterLimit:n,cap:r,join:a,...o}=t,h=ee(s,o);return h?{width:e,alignment:i,miterLimit:n,cap:r,join:a,...h}:null}const hc=new ht,Wn=new H,Es=class At extends ft{constructor(){super(...arguments),this.uid=nt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new pe,this._transform=new H,this._fillStyle={...At.defaultFillStyle},this._strokeStyle={...At.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Gt,this._boundsDirty=!0}clone(){const t=new At;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=ee(t,At.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=pi(t,At.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ee(t,At.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ee(t,At.defaultStrokeStyle),this}texture(t,e,i,n,r,a){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:r||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?Z.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new pe,this}fill(t,e){let i;const n=this.instructions[this.instructions.length-1];return this._tick===0&&n&&n.action==="stroke"?i=n.data.path:i=this._activePath.clone(),i?(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=ee(t,At.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(ht.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=pi(t,At.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],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,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,i,n,r,a),this}arcTo(t,e,i,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*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,r),this}arcToSvg(t,e,i,n,r,a,o){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,n,r,h.a*a+h.c*o+h.tx,h.b*a+h.d*o+h.ty),this}bezierCurveTo(t,e,i,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*i+h.c*n+h.tx,h.b*i+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,i,n){return this._tick++,this._activePath.ellipse(t,e,i,n,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,n=this._activePath.instructions,r=i.a*t+i.c*e+i.tx,a=i.b*t+i.d*e+i.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,i,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*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,r),this}rect(t,e,i,n){return this._tick++,this._activePath.rect(t,e,i,n,this._transform.clone()),this}roundRect(t,e,i,n,r){return this._tick++,this._activePath.roundRect(t,e,i,n,r,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,r=0,a){return this._tick++,this._activePath.regularPoly(t,e,i,n,r,a),this}roundPoly(t,e,i,n,r,a){return this._tick++,this._activePath.roundPoly(t,e,i,n,r,a),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,r){return this._tick++,this._activePath.filletRect(t,e,i,n,r),this}chamferRect(t,e,i,n,r,a){return this._tick++,this._activePath.chamferRect(t,e,i,n,r,a),this}star(t,e,i,n,r=0,a=0){return this._tick++,this._activePath.star(t,e,i,n,r,a,this._transform.clone()),this}svg(t){return this._tick++,sc(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,i,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,i,n,r,a),this)}transform(t,e,i,n,r,a){return t instanceof H?(this._transform.append(t),this):(Wn.set(t,e,i,n,r,a),this._transform.append(Wn),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 i=this.instructions[e],n=i.action;if(n==="fill"){const r=i.data;t.addBounds(r.path.bounds)}else if(n==="texture"){const r=i.data;t.addFrame(r.dx,r.dy,r.dx+r.dw,r.dy+r.dh,r.transform)}if(n==="stroke"){const r=i.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 i=!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 c=o.style,l=h.shapePath.shapePrimitives;for(let d=0;d<l.length;d++){const u=l[d].shape;if(!c||!u)continue;const g=l[d].transform,m=g?g.applyInverse(t,hc):t;a.action==="fill"?i=u.contains(m.x,m.y):i=u.strokeContains(m.x,m.y,c.width);const y=o.hole;if(y){const x=(n=y.shapePath)==null?void 0:n.shapePrimitives;if(x)for(let _=0;_<x.length;_++)x[_].shape.contains(m.x,m.y)&&(i=!1)}if(i)return!0}}return i}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 i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(i),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(i)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Es.defaultFillStyle={color:16777215,alpha:1,texture:z.WHITE,matrix:null,fill:null};Es.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:z.WHITE,matrix:null,fill:null};let mt=Es;const On=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function lc(s){const t=[];let e=0;for(let i=0;i<On.length;i++){const n=`_${On[i]}`;t[e++]=s[n]}return e=ua(s._fill,t,e),e=cc(s._stroke,t,e),e=dc(s.dropShadow,t,e),t.join("-")}function ua(s,t,e){var i;return s&&(t[e++]=s.color,t[e++]=s.alpha,t[e++]=(i=s.fill)==null?void 0:i.styleKey),e}function cc(s,t,e){return s&&(e=ua(s,t,e),t[e++]=s.width,t[e++]=s.alignment,t[e++]=s.cap,t[e++]=s.join,t[e++]=s.miterLimit),e}function dc(s,t,e){return s&&(t[e++]=s.alpha,t[e++]=s.angle,t[e++]=s.blur,t[e++]=s.distance,t[e++]=Z.shared.setValue(s.color).toNumber()),e}const Rs=class oe extends ft{constructor(t={}){super(),uc(t);const e={...oe.defaultTextStyle,...t};for(const i in e){const n=i;this[n]=e[i]}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({...oe.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...oe.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({...mt.defaultFillStyle,...t},()=>{this._fill=ee({...this._originalFill},mt.defaultFillStyle)})),this._fill=ee(t===0?"black":t,mt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...mt.defaultStrokeStyle,...t},()=>{this._stroke=pi({...this._originalStroke},mt.defaultStrokeStyle)})),this._stroke=pi(t,mt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=lc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=oe.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new oe({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var i,n,r,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(o),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(o),(r=this._stroke)!=null&&r.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,n,r)=>(i[n]=r,e==null||e(n,r),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Z.isColorLike(t)||t instanceof Oe||t instanceof bi)}};Rs.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Rs.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let N=Rs;function uc(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=N.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){U(O,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Z.isColorLike(e))i.color=e;else if(e instanceof Oe||e instanceof bi)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){U(O,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;s.fontSize==null?s.fontSize=N.defaultTextStyle.fontSize:typeof s.fontSize=="string"?e=parseInt(s.fontSize,10):e=s.fontSize;const i=new Oe(0,0,0,e*1.7),n=t.fillGradientStops.map(r=>Z.shared.setValue(r).toNumber());n.forEach((r,a)=>{const o=a/(n.length-1);i.addColorStop(o,r)}),s.fill={fill:i}}}class fc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=Q.get().createCanvas();i.width=t,i.height=e;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Ks(t),e=Ks(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,r=(i<<17)+(n<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const Nn=new fc,pc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ys(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!pc.includes(n)&&(n=`"${n}"`),e[i]=n}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const Ki={willReadFrequently:!0},vt=class A{static get experimentalLetterSpacingSupported(){let t=A._experimentalLetterSpacingSupported;if(t!==void 0){const e=Q.get().getCanvasRenderingContext2D().prototype;t=A._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,n,r,a,o,h,c){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=r,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,i=A._canvas,n=e.wordWrap){var w;const r=`${t}:${e.styleKey}`;if(A._measurementCache[r])return A._measurementCache[r];const a=ys(e),o=A.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=A.__context;h.font=a;const l=(n?A._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),d=new Array(l.length);let u=0;for(let b=0;b<l.length;b++){const S=A._measureText(l[b],e.letterSpacing,h);d[b]=S,u=Math.max(u,S)}const g=((w=e._stroke)==null?void 0:w.width)||0;let m=u+g;e.dropShadow&&(m+=e.dropShadow.distance);const y=e.lineHeight||o.fontSize;let x=Math.max(y,o.fontSize+g)+(l.length-1)*(y+e.leading);return e.dropShadow&&(x+=e.dropShadow.distance),new A(t,e,m,x,l,d,y+e.leading,u,o)}static _measureText(t,e,i){let n=!1;A.experimentalLetterSpacingSupported&&(A.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let r=i.measureText(t).width;return r>0&&(n?r-=e:r+=(A.graphemeSegmenter(t).length-1)*e),r}static _wordWrap(t,e,i=A._canvas){const n=i.getContext("2d",Ki);let r=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,d=A._collapseSpaces(l),u=A._collapseNewlines(l);let g=!d;const m=e.wordWrapWidth+c,y=A._tokenize(t);for(let x=0;x<y.length;x++){let _=y[x];if(A._isNewline(_)){if(!u){o+=A._addLine(a),g=!d,a="",r=0;continue}_=" "}if(d){const b=A.isBreakingSpace(_),S=A.isBreakingSpace(a[a.length-1]);if(b&&S)continue}const w=A._getFromCache(_,c,h,n);if(w>m)if(a!==""&&(o+=A._addLine(a),a="",r=0),A.canBreakWords(_,e.breakWords)){const b=A.wordWrapSplit(_);for(let S=0;S<b.length;S++){let T=b[S],F=T,P=1;for(;b[S+P];){const v=b[S+P];if(!A.canBreakChars(F,v,_,S,e.breakWords))T+=v;else break;F=v,P++}S+=P-1;const G=A._getFromCache(T,c,h,n);G+r>m&&(o+=A._addLine(a),g=!1,a="",r=0),a+=T,r+=G}}else{a.length>0&&(o+=A._addLine(a),a="",r=0);const b=x===y.length-1;o+=A._addLine(_,!b),g=!1,a="",r=0}else w+r>m&&(g=!1,o+=A._addLine(a),a="",r=0),(a.length>0||!A.isBreakingSpace(_)||g)&&(a+=_,r+=w)}return o+=A._addLine(a,!1),o}static _addLine(t,e=!0){return t=A._trimRight(t),t=e?`${t}
`:t,t}static _getFromCache(t,e,i,n){let r=i[t];return typeof r!="number"&&(r=A._measureText(t,e,n)+e,i[t]=r),r}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!A.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:A._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:A._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let n=0;n<t.length;n++){const r=t[n],a=t[n+1];if(A.isBreakingSpace(r,a)||A._isNewline(r)){i!==""&&(e.push(i),i=""),e.push(r);continue}i+=r}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,r){return!0}static wordWrapSplit(t){return A.graphemeSegmenter(t)}static measureFont(t){if(A._fonts[t])return A._fonts[t];const e=A._context;e.font=t;const i=e.measureText(A.METRICS_STRING+A.BASELINE_SYMBOL),n={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return A._fonts[t]=n,n}static clearMetrics(t=""){t?delete A._fonts[t]:A._fonts={}}static get _canvas(){if(!A.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",Ki);if(i!=null&&i.measureText)return A.__canvas=e,e;t=Q.get().createCanvas()}catch{t=Q.get().createCanvas()}t.width=t.height=10,A.__canvas=t}return A.__canvas}static get _context(){return A.__context||(A.__context=A._canvas.getContext("2d",Ki)),A.__context}};vt.METRICS_STRING="|ÉqÅ";vt.BASELINE_SYMBOL="M";vt.BASELINE_MULTIPLIER=1.4;vt.HEIGHT_MULTIPLIER=2;vt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})();vt.experimentalLetterSpacing=!1;vt._fonts={};vt._newlines=[10,13];vt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];vt._measurementCache={};let _s=vt;function Hn(s,t){if(s.texture===z.WHITE&&!s.fill)return Z.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof bi){const e=s.fill,i=t.createPattern(e.texture.source.resource,"repeat"),n=e.transform.copyTo(H.shared);return n.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(n),i}else if(s.fill instanceof Oe){const e=s.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(n=>{i.addColorStop(n.offset,Z.shared.setValue(n.color).toHex())}),i}}}else{const e=t.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(H.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),e.setTransform(i),e}return st("FillStyle not recognised",s),"red"}function fa(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const n=s[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 pa=class ga extends Yr{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={...ga.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;const i=e.style.clone();e.overrideFill&&(i._fill.color=16777215,i._fill.alpha=1,i._fill.texture=z.WHITE,i._fill.fill=null),this.applyFillAsTint=e.overrideFill;const n=i.fontSize;i.fontSize=this.baseMeasurementFontSize;const r=ys(i);e.overrideSize?i._stroke&&(i._stroke.width*=this.baseRenderedFontSize/n):i.fontSize=this.baseRenderedFontSize=n,this._style=i,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,this.fontMetrics=_s.measureFont(r),this.lineHeight=i.lineHeight||this.fontMetrics.fontSize||i.fontSize}ensureCharacters(t){var y,x;const e=fa(t).filter(_=>!this._currentChars.includes(_)).filter((_,w,b)=>b.indexOf(_)===w);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:n,context:r}=i.canvasAndContext,a=i.texture.source;const o=this._style;let h=this._currentX,c=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*l,u=o.fontStyle==="italic"?2:1;let g=0,m=!1;for(let _=0;_<e.length;_++){const w=e[_],b=_s.measureText(w,o,n,!1);b.lineHeight=b.height;const S=u*b.width*l,T=b.height*l,F=S+d*2,P=T+d*2;if(m=!1,w!==`
`&&w!=="\r"&&w!==" "&&w!==" "&&(m=!0,g=Math.ceil(Math.max(P,g))),h+F>this._textureSize&&(c+=g,g=P,h=0,c+g>this._textureSize)){a.update();const v=this._nextPage();n=v.canvasAndContext.canvas,r=v.canvasAndContext.context,a=v.texture.source,c=0}const G=S/l-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((x=o._stroke)==null?void 0:x.width)??0);if(this.chars[w]={id:w.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:G,kerning:{}},m){this._drawGlyph(r,b,h+d,c+d,l,o);const v=a.width*l,C=a.height*l,K=new E(h/v*a.width,c/C*a.height,F/v*a.width,P/C*a.height);this.chars[w].texture=new z({source:a,frame:K}),h+=Math.ceil(F)}}a.update(),this._currentX=h,this._currentY=c,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 i=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=i[r];h||(h=i[r]=e.measureText(r).width);let c=i[o];c||(c=i[o]=e.measureText(o).width);let l=e.measureText(r+o).width,d=l-(h+c);d&&(this.chars[r].kerning[o]=d),l=e.measureText(r+o).width,d=l-(h+c),d&&(this.chars[o].kerning[r]=d)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Nn.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new z({source:new ye({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})}),r={canvasAndContext:e,texture:n};return this.pages[this._currentPageIndex]=r,r}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=ys(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=Hn(n,t)),e._fill&&(t.fillStyle=Hn(e._fill,t)),e.dropShadow){const a=e.dropShadow,o=Z.shared.setValue(a.color).toArray(),h=a.blur*i,c=a.distance*i;t.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(a.angle)*c,t.shadowOffsetY=Math.sin(a.angle)*c}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,n,r,a){const o=e.text,h=e.fontProperties,c=a._stroke,l=((c==null?void 0:c.width)??0)*r,d=i+l/2,u=n-l/2,g=h.descent*r,m=e.lineHeight*r;a.stroke&&l&&t.strokeText(o,d,u+m-g),a._fill&&t.fillText(o,d,u+m-g)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];e.canvas.width=e.canvas.width,Nn.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};pa.defaultOptions={textureSize:512,style:new N,mipmap:!0};let $n=pa;function gc(s,t,e,i){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:[]},c=m=>{const y=r.width;for(let x=0;x<h.index;x++){const _=m.positions[x];r.chars.push(m.chars[x]),r.charPositions.push(_+y)}r.width+=m.width,o=!1,h.width=0,h.index=0,h.chars.length=0},l=()=>{let m=r.chars.length-1;if(i){let y=r.chars[m];for(;y===" ";)r.width-=e.chars[y].xAdvance,y=r.chars[--m]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,n.lines.push(r),n.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,u=t.letterSpacing*d,g=t.wordWrapWidth*d;for(let m=0;m<s.length+1;m++){let y;const x=m===s.length;x||(y=s[m]);const _=e.chars[y]||e.chars[" "];if(/(?:\s)/.test(y)||y==="\r"||y===`
`||x){if(!o&&t.wordWrap&&r.width+h.width-u>g?(l(),c(h),x||r.charPositions.push(0)):(h.start=r.width,c(h),x||r.charPositions.push(0)),y==="\r"||y===`
`)r.width!==0&&l();else if(!x){const T=_.xAdvance+(_.kerning[a]||0)+u;r.width+=T,r.spaceWidth=T,r.spacesIndex.push(r.charPositions.length),r.chars.push(y)}}else{const S=_.kerning[a]||0,T=_.xAdvance+S+u;h.positions[h.index++]=h.width+S,h.chars.push(y),h.width+=T}a=y}return l(),t.align==="center"?mc(n):t.align==="right"?xc(n):t.align==="justify"&&yc(n),n}function mc(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width/2-e.width/2;for(let n=0;n<e.charPositions.length;n++)e.charPositions[n]+=i}}function xc(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width-e.width;for(let n=0;n<e.charPositions.length;n++)e.charPositions[n]+=i}}function yc(s){const t=s.width;for(let e=0;e<s.lines.length;e++){const i=s.lines[e];let n=0,r=i.spacesIndex[n++],a=0;const o=i.spacesIndex.length,c=(t-i.width)/o;for(let l=0;l<i.charPositions.length;l++)l===r&&(r=i.spacesIndex[n++],a+=c),i.charPositions[l]+=a}}let ai=0;class _c{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 i=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke)i+=e._fill.fill.styleKey,n=!1;else if(e._stroke||e.dropShadow){let o=e.styleKey;o=o.substring(0,o.lastIndexOf("-")),i=`${o}-bitmap`,n=!1}if(!j.has(i)){const o=new $n({style:e,overrideFill:n,overrideSize:!0,...this.defaultOptions});ai++,ai>50&&st("BitmapText",`You have dynamically created ${ai} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{ai--,j.remove(i)}),j.set(i,o)}const r=j.get(i);return(a=r.ensureCharacters)==null||a.call(r,t),r}getLayout(t,e,i=!0){const n=this.getFont(t,e);return gc([...t],e,n,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var c,l,d,u;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(c=t[2])==null?void 0:c.chars,resolution:(l=t[2])==null?void 0:l.resolution,padding:(d=t[2])==null?void 0:d.padding,skipKerning:(u=t[2])==null?void 0:u.skipKerning},U(O,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e==null?void 0:e.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const n=e.style,r=n instanceof N?n:new N(n),a=r._fill.fill!==null&&r._fill.fill!==void 0,o=new $n({style:r,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=fa(e.chars);return o.ensureCharacters(h.join("")),j.set(`${i}-bitmap`,o),o.once("destroy",()=>j.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=j.get(e);i&&(j.remove(e),i.destroy())}}const Vn=new _c;class ma extends Yr{constructor(t,e){super();const{textures:i,data:n}=t;Object.keys(n.pages).forEach(r=>{const a=n.pages[parseInt(r,10)],o=i[a.id];this.pages.push({texture:o})}),Object.keys(n.chars).forEach(r=>{const a=n.chars[r],{frame:o,source:h}=i[a.page],c=new E(a.x+o.x,a.y+o.y,a.width,a.height),l=new z({source:h,frame:c});this.chars[r]={id:r.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:l}}),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){Vn.install(t)}static uninstall(t){Vn.uninstall(t)}}const Zi={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const t=s.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const d in t){const u=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("="),_=x[0],w=x[1].replace(/"/gm,""),b=parseFloat(w),S=isNaN(b)?w:b;m[_]=S}e[u].push(m)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[n]=e.info,[r]=e.common,[a]=e.distanceField??[];a&&(i.distanceField={range:parseInt(a.distanceRange,10),type:a.fieldType}),i.fontSize=parseInt(n.size,10),i.fontFamily=n.face,i.lineHeight=parseInt(r.lineHeight,10);const o=e.page;for(let d=0;d<o.length;d++)i.pages.push({id:parseInt(o[d].id,10)||0,file:o[d].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(r.base,10);const c=e.char;for(let d=0;d<c.length;d++){const u=c[d],g=parseInt(u.id,10);let m=u.letter??u.char??String.fromCharCode(g);m==="space"&&(m=" "),h[g]=m,i.chars[m]={id:g,page:parseInt(u.page,10)||0,x:parseInt(u.x,10),y:parseInt(u.y,10),width:parseInt(u.width,10),height:parseInt(u.height,10),xOffset:parseInt(u.xoffset,10),yOffset:parseInt(u.yoffset,10),xAdvance:parseInt(u.xadvance,10),kerning:{}}}const l=e.kerning||[];for(let d=0;d<l.length;d++){const u=parseInt(l[d].first,10),g=parseInt(l[d].second,10),m=parseInt(l[d].amount,10);i.chars[h[g]].kerning[h[u]]=m}return i}},Xn={test(s){const t=s;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=s.getElementsByTagName("info")[0],i=s.getElementsByTagName("common")[0],n=s.getElementsByTagName("distanceField")[0];n&&(t.distanceField={type:n.getAttribute("fieldType"),range:parseInt(n.getAttribute("distanceRange"),10)});const r=s.getElementsByTagName("page"),a=s.getElementsByTagName("char"),o=s.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let c=0;c<r.length;c++)t.pages.push({id:parseInt(r[c].getAttribute("id"),10)||0,file:r[c].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(i.getAttribute("base"),10);for(let c=0;c<a.length;c++){const l=a[c],d=parseInt(l.getAttribute("id"),10);let u=l.getAttribute("letter")??l.getAttribute("char")??String.fromCharCode(d);u==="space"&&(u=" "),h[d]=u,t.chars[u]={id:d,page:parseInt(l.getAttribute("page"),10)||0,x:parseInt(l.getAttribute("x"),10),y:parseInt(l.getAttribute("y"),10),width:parseInt(l.getAttribute("width"),10),height:parseInt(l.getAttribute("height"),10),xOffset:parseInt(l.getAttribute("xoffset"),10),yOffset:parseInt(l.getAttribute("yoffset"),10),xAdvance:parseInt(l.getAttribute("xadvance"),10),kerning:{}}}for(let c=0;c<o.length;c++){const l=parseInt(o[c].getAttribute("first"),10),d=parseInt(o[c].getAttribute("second"),10),u=parseInt(o[c].getAttribute("amount"),10);t.chars[h[d]].kerning[h[l]]=u}return t}},Yn={test(s){return typeof s=="string"&&s.includes("<font>")?Xn.test(Q.get().parseXML(s)):!1},parse(s){return Xn.parse(Q.get().parseXML(s))}},wc=[".xml",".fnt"],bc={extension:{type:k.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof ma,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Sc={extension:{type:k.LoadParser,priority:Ht.Normal},name:"loadBitmapFont",test(s){return wc.includes(gt.extname(s).toLowerCase())},async testParse(s){return Zi.test(s)||Yn.test(s)},async parse(s,t,e){const i=Zi.test(s)?Zi.parse(s):Yn.parse(s),{src:n}=t,{pages:r}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;d<r.length;++d){const u=r[d].file;let g=gt.join(gt.dirname(n),u);g=rs(g,n),a.push({src:g,data:o})}const h=await e.load(a),c=a.map(d=>h[d.src]);return new ma({data:i,textures:c},n)},async load(s,t){return await(await Q.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}};class vc{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)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 Cc={extension:{type:k.CacheParser,name:"cacheTextureArray"},test:s=>Array.isArray(s)&&s.every(t=>t instanceof z),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((n,r)=>{e[i+(r===0?"":r+1)]=n})}),e}};async function xa(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Tc={extension:{type:k.DetectionParser,priority:1},test:async()=>xa("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},jn=["png","jpg","jpeg"],Ac={extension:{type:k.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...jn],remove:async s=>s.filter(t=>!jn.includes(t))},Mc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Fs(s){return Mc?!1:document.createElement("video").canPlayType(s)!==""}const Pc={extension:{type:k.DetectionParser,priority:0},test:async()=>Fs("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},kc={extension:{type:k.DetectionParser,priority:0},test:async()=>Fs("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},Gc={extension:{type:k.DetectionParser,priority:0},test:async()=>Fs("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},Ic={extension:{type:k.DetectionParser,priority:0},test:async()=>xa("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};class Bc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let n=null,r=null;if(e.loadParser&&(r=this._parserHash[e.loadParser],r||st(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!r){for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];if(c.load&&((a=c.test)!=null&&a.call(c,t,e,this))){r=c;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),i.parser=r;for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];c.parse&&c.parse&&await((o=c.testParse)==null?void 0:o.call(c,n,e,this))&&(n=await c.parse(n,e,this)||n,i.parser=c)}return n})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const n={},r=fi(t),a=bt(t,c=>({alias:[c],src:c,data:{}})),o=a.length,h=a.map(async c=>{const l=gt.toAbsolute(c.src);if(!n[c.src])try{this.promiseCache[l]||(this.promiseCache[l]=this._getLoadPromiseAndParser(l,c)),n[c.src]=await this.promiseCache[l].promise,e&&e(++i/o)}catch(d){throw delete this.promiseCache[l],delete n[c.src],new Error(`[Loader.load] Failed to load ${l}.
${d}`)}});return await Promise.all(h),r?n[a[0].src]:n}async unload(t){const i=bt(t,n=>({alias:[n],src:n})).map(async n=>{var o,h;const r=gt.toAbsolute(n.src),a=this.promiseCache[r];if(a){const c=await a.promise;delete this.promiseCache[r],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,c,n,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&st(`[Assets] loadParser name conflict "${e.name}"`):st("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function we(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function be(s,t){const e=s.split("?")[0],i=gt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Ec=".json",Rc="application/json",Fc={extension:{type:k.LoadParser,priority:Ht.Low},name:"loadJson",test(s){return we(s,Rc)||be(s,Ec)},async load(s){return await(await Q.get().fetch(s)).json()}},Lc=".txt",Dc="text/plain",zc={name:"loadTxt",extension:{type:k.LoadParser,priority:Ht.Low,name:"loadTxt"},test(s){return we(s,Dc)||be(s,Lc)},async load(s){return await(await Q.get().fetch(s)).text()}},Uc=["normal","bold","100","200","300","400","500","600","700","800","900"],Wc=[".ttf",".otf",".woff",".woff2"],Oc=["font/ttf","font/otf","font/woff","font/woff2"],Nc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Hc(s){const t=gt.extname(s),n=gt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let r=n.length>0;for(const o of n)if(!o.match(Nc)){r=!1;break}let a=n.join(" ");return r||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const $c=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Vc(s){return $c.test(s)?s:encodeURI(s)}const Xc={extension:{type:k.LoadParser,priority:Ht.Low},name:"loadWebFont",test(s){return we(s,Oc)||be(s,Wc)},async load(s,t){var i,n,r;const e=Q.get().getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??Hc(s),h=((r=(n=t.data)==null?void 0:n.weights)==null?void 0:r.filter(l=>Uc.includes(l)))??["normal"],c=t.data??{};for(let l=0;l<h.length;l++){const d=h[l],u=new FontFace(o,`url(${Vc(s)})`,{...c,weight:d});await u.load(),e.add(u),a.push(u)}return j.set(`${o}-and-url`,{url:s,fontFaces:a}),a.length===1?a[0]:a}return st("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>{j.remove(t.family),Q.get().getFontFaceSet().delete(t)})}};function Ls(s,t=1){var i;const e=(i=_e.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}function Ds(s,t,e){s.label=e,s._sourceOrigin=e;const i=new z({source:s,label:e}),n=()=>{delete t.promiseCache[e],j.has(e)&&j.remove(e)};return i.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())}),i.once("destroy",()=>{s.destroyed||(st("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),i}const Yc=".svg",jc="image/svg+xml",qc={extension:{type:k.LoadParser,priority:Ht.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return we(s,jc)||be(s,Yc)},async load(s,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Zc(s):Kc(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Kc(s,t,e,i){var x,_,w;const r=await(await Q.get().fetch(s)).blob(),a=URL.createObjectURL(r),o=new Image;o.src=a,o.crossOrigin=i,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((x=t.data)==null?void 0:x.resolution)||Ls(s),d=((_=t.data)==null?void 0:_.width)??o.width,u=((w=t.data)==null?void 0:w.height)??o.height;h.width=d*l,h.height=u*l,c.drawImage(o,0,0,d*l,u*l);const{parseAsGraphicsContext:g,...m}=t.data,y=new ye({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...m});return Ds(y,e,s)}async function Zc(s){const e=await(await Q.get().fetch(s)).text(),i=new mt;return i.svg(e),i}const Qc=`(function () {
'use strict';
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
async function checkImageBitmap() {
try {
if (typeof createImageBitmap !== "function")
return false;
const response = await fetch(WHITE_PNG);
const imageBlob = await response.blob();
const imageBitmap = await createImageBitmap(imageBlob);
return imageBitmap.width === 1 && imageBitmap.height === 1;
} catch (e) {
return false;
}
}
void checkImageBitmap().then((result) => {
self.postMessage(result);
});
})();
`;let le=null,ws=class{constructor(){le||(le=URL.createObjectURL(new Blob([Qc],{type:"application/javascript"}))),this.worker=new Worker(le)}};ws.revokeObjectURL=function(){le&&(URL.revokeObjectURL(le),le=null)};const Jc=`(function () {
'use strict';
async function loadImageBitmap(url, alphaMode) {
const response = await fetch(url);
if (!response.ok) {
throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
}
const imageBlob = await response.blob();
return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
}
self.onmessage = async (event) => {
try {
const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
self.postMessage({
data: imageBitmap,
uuid: event.data.uuid,
id: event.data.id
}, [imageBitmap]);
} catch (e) {
self.postMessage({
error: e,
uuid: event.data.uuid,
id: event.data.id
});
}
};
})();
`;let ce=null;class ya{constructor(){ce||(ce=URL.createObjectURL(new Blob([Jc],{type:"application/javascript"}))),this.worker=new Worker(ce)}}ya.revokeObjectURL=function(){ce&&(URL.revokeObjectURL(ce),ce=null)};let qn=0,Qi;class td{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new ws;e.addEventListener("message",i=>{e.terminate(),ws.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Qi===void 0&&(Qi=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Qi&&(this._createdWorkers++,t=new ya().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 i=new Promise((n,r)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:r})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[qn]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:qn++,id:i})}}const Kn=new td,ed=[".jpeg",".jpg",".png",".webp",".avif"],id=["image/jpeg","image/png","image/webp","image/avif"];async function sd(s,t){var n;const e=await Q.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);const i=await e.blob();return((n=t==null?void 0:t.data)==null?void 0:n.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const _a={name:"loadTextures",extension:{type:k.LoadParser,priority:Ht.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return we(s,id)||be(s,ed)},async load(s,t,e){var r;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Kn.isImageBitmapSupported()?i=await Kn.loadImageBitmap(s,t):i=await sd(s,t):i=await new Promise(a=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?a(i):i.onload=()=>{a(i)}});const n=new ye({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((r=t.data)==null?void 0:r.resolution)||Ls(s),...t.data});return Ds(n,e,s)},unload(s){s.destroy(!0)}},wa=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],nd=wa.map(s=>`video/${s.substring(1)}`);function rd(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=od(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function ad(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",n),s.load();function i(){r(),t()}function n(a){r(),e(a)}function r(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",n)}})}function od(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const hd={name:"loadVideo",extension:{type:k.LoadParser,name:"loadVideo"},test(s){const t=we(s,nd),e=be(s,wa);return t||e},async load(s,t,e){var h,c;const i={...oi.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Ls(s),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await vr(),...t.data},n=document.createElement("video"),r={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(r).forEach(l=>{const d=r[l];d!==void 0&&n.setAttribute(l,d)}),i.muted===!0&&(n.muted=!0),rd(n,s,i.crossorigin);const a=document.createElement("source");let o;if(s.startsWith("data:"))o=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();o=oi.MIME_TYPES[l]||`video/${l}`}return a.src=s,o&&(a.type=o),new Promise(l=>{const d=async()=>{const u=new oi({...i,resource:n});n.removeEventListener("canplay",d),t.data.preload&&await ad(n),l(Ds(u,e,s))};n.addEventListener("canplay",d),n.appendChild(a)})},unload(s){s.destroy(!0)}},ba={extension:{type:k.ResolveParser,name:"resolveTexture"},test:_a.test,parse:s=>{var t;return{resolution:parseFloat(((t=_e.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},ld={extension:{type:k.ResolveParser,priority:-2,name:"resolveJson"},test:s=>_e.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:ba.parse};class cd{constructor(){this._detections=[],this._initialized=!1,this.resolver=new _e,this.loader=new Bc,this.cache=j,this._backgroundLoader=new vc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var r,a;if(this._initialized){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,i=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=fi(t),n=bt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(c=>!this.resolver.hasKey(c))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),r=this.resolver.resolve(n),a=await this._mapLoadToResolve(r,e);return i?a[n[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),r={},a=Object.keys(n);let o=0,h=0;const c=()=>{e==null||e(++o/h)},l=a.map(d=>{const u=n[d];return h+=Object.keys(u).length,this._mapLoadToResolve(u,c).then(g=>{r[d]=g})});return await Promise.all(l),i?r[t[0]]:r}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return j.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=j.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const r={};return i.forEach(a=>{const o=n[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{r[c]=o}),j.set(h,o)}),r}async unload(t){this._initialized||await this.init();const e=bt(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=bt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{j.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,n)=>e.indexOf(i)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Re=new cd;lt.handleByList(k.LoadParser,Re.loader.parsers).handleByList(k.ResolveParser,Re.resolver.parsers).handleByList(k.CacheParser,Re.cache.parsers).handleByList(k.DetectionParser,Re.detections);lt.add(Cc,Ac,Tc,Ic,Pc,kc,Gc,Fc,zc,Xc,qc,_a,hd,Sc,bc,ba,ld);const Zn={loader:k.LoadParser,resolver:k.ResolveParser,cache:k.CacheParser,detection:k.DetectionParser};lt.handle(k.Asset,s=>{const t=s.ref;Object.entries(Zn).filter(([e])=>!!t[e]).forEach(([e,i])=>lt.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(Zn).filter(e=>!!t[e]).forEach(e=>lt.remove(t[e]))});class St extends mi{constructor(t){t instanceof mt&&(t={context:t});const{context:e,roundPixels:i,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new mt,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new St(this._context.clone()):(this._ownedContext=null,new St(this._context))}lineStyle(t,e,i){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),i&&(n.alpha=i),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 i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,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!==mt.defaultStrokeStyle.width||t.color!==mt.defaultStrokeStyle.color||t.alpha!==mt.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 Sa=class va extends ta{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={...va.defaultOptions,...e};const i=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),r=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Ot({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),h=new Ot({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),c=new Ot({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:c,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}};Sa.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let dd=Sa;class He extends ${constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:i,autoUpdate:n,...r}=e,[a]=i;super({...r,texture:a instanceof 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=i}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Pt.shared.add(this.update,this,ui.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,n=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=i/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.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 i=0;i<t.length;++i)e.push(z.from(t[i]));return new He(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(z.from(t[i]));return new He(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?(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Pt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class ud extends mi{constructor(t,e){const{text:i,resolution:n,style:r,anchor:a,width:o,height:h,roundPixels:c,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new ut({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!1,o!==void 0&&(this.width=o),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-i*this.anchor.y,t.y>=r&&t.y<=r+i)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function fd(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(U(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}class W extends ud{constructor(...t){const e=fd(t,"Text");super(e,N),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,i=_s.measureText(this._text,this._style),{width:n,height:r}=i;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}}const Ca=class Ta extends dd{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={...Ta.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;const e=this.verticesX*this.verticesY,i=[],n=[],r=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,c=this.height/o;for(let d=0;d<e;d++){const u=d%this.verticesX,g=d/this.verticesX|0;i.push(u*h,g*c),n.push(u/a,g/o)}const l=a*o;for(let d=0;d<l;d++){const u=d%a,g=d/a|0,m=g*this.verticesX+u,y=g*this.verticesX+u+1,x=(g+1)*this.verticesX+u,_=(g+1)*this.verticesX+u+1;r.push(m,y,x,y,_,x)}this.buffers[0].data=new Float32Array(i),this.buffers[1].data=new Float32Array(n),this.indexBuffer.data=new Uint32Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Ca.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let pd=Ca;const Aa=class Ma extends pd{constructor(t={}){t={...Ma.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,i=this.width>e?1:this.width/e,n=this._topHeight+this._bottomHeight,r=this.height>n?1:this.height/n,a=Math.min(i,r);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};Aa.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ae=Aa;const Pa=class ka extends mi{constructor(t){var d,u,g,m;t instanceof z&&(t={texture:t});const{width:e,height:i,leftWidth:n,rightWidth:r,topHeight:a,bottomHeight:o,texture:h,roundPixels:c,...l}=t;super({label:"NineSliceSprite",...l}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=n??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.left)??ae.defaultOptions.leftWidth,this._topHeight=a??((u=h==null?void 0:h.defaultBorders)==null?void 0:u.top)??ae.defaultOptions.topHeight,this._rightWidth=r??((g=h==null?void 0:h.defaultBorders)==null?void 0:g.right)??ae.defaultOptions.rightWidth,this._bottomHeight=o??((m=h==null?void 0:h.defaultBorders)==null?void 0:m.bottom)??ae.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??ae.defaultOptions.width,this.bounds.maxY=this._height=i??h.height??ae.defaultOptions.height,this.allowChildren=!1,this.texture=h??ka.defaultOptions.texture,this.roundPixels=c??!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 i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null}};Pa.defaultOptions={texture:z.EMPTY};let yt=Pa;lt.add(za,Ua);const I=class I{static async Load(t){return this.text.text="Loading asset: "+t,await Re.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 W({text:"Loading textures. This might take a while.",style:new N({fill:3355443,fontSize:50})});t.x=f.app.canvas.width/2,t.y=f.app.canvas.height/2,t.anchor.set(.5,.5),f.app.stage.addChild(t),this.text=new W({text:"",style:new N({fill:3355443,fontSize:50})}),this.text.x=f.app.canvas.width/2,this.text.y=f.app.canvas.height/2+50,this.text.anchor.set(.5,.5),f.app.stage.addChild(this.text),await Promise.all([this.Load("./aclonica.woff2"),this.Load("./assets/gui/button_01.png").then(e=>this.Button01Texture=e),this.Load("./assets/gui/button_02.png").then(e=>this.Button02Texture=e),this.Load("./assets/gui/button_small.png").then(e=>this.ButtonSmallTexture=e),this.Load("./assets/gui/frame_01.png").then(e=>this.Frame01Texture=e),this.Load("./assets/gui/frame_02.png").then(e=>this.Frame02Texture=e),this.Load("./assets/gui/frame_03.png").then(e=>this.Frame03Texture=e),this.Load("./assets/gui/frame_04.png").then(e=>this.Frame04Texture=e),this.Load("./assets/gui/frame_05.png").then(e=>this.Frame05Texture=e),this.Load("./assets/gui/frame_inv.png").then(e=>this.FrameInventory=e),this.Load("./assets/gui/background_01.png").then(e=>this.FrameBackground=e),this.Load("./assets/gui/background_02.png").then(e=>this.FrameTowerTab=e),this.Load("./assets/gui/frame_violet.png").then(e=>this.VioletBackground=e),this.Load("./assets/gui/frame_red.png").then(e=>this.RedBackground=e),this.Load("./assets/gui/frame_green.png").then(e=>this.GreenBackground=e),this.Load("./assets/gui/frame_blue.png").then(e=>this.BlueBackground=e),this.Load("./assets/gui/banner_01.png").then(e=>this.BannerGemsmith=e),this.Load("./assets/gui/note.png").then(e=>this.EndScreenDialog=e),this.Load("./assets/gui/main_background.jpg").then(e=>this.MainBackground=e),this.Load("./assets/tutorial/tutorial01.jpg").then(e=>this.Tutorial01=e),this.Load("./assets/tutorial/tutorial02.jpg").then(e=>this.Tutorial02=e),this.Load("./assets/tutorial/tutorial03.jpg").then(e=>this.Tutorial03=e),this.Load("./assets/tutorial/tutorial04.jpg").then(e=>this.Tutorial04=e),this.Load("./assets/tutorial/tutorial05.jpg").then(e=>this.Tutorial05=e),this.Load("./assets/gui/heart.png").then(e=>this.HealthTexture=e),this.Load("./assets/gui/money.png").then(e=>this.GoldTexture=e),this.Load("./assets/gui/wave.png").then(e=>this.WaveTexture=e),this.Load("./assets/gui/sword_02.png").then(e=>this.SwordsTexture=e),this.Load("./assets/gui/title01.png").then(e=>this.TitleTexture=e),this.Load("./assets/gui/icons/play.png").then(e=>this.PlayIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/fastforward.png").then(e=>this.FastForwardIconTexture=e),this.Load("./assets/gui/icons/home.png").then(e=>this.HomeIconTexture=e),this.Load("./assets/gui/icons/hammer.png").then(e=>this.HammerIconTexture=e),this.Load("./assets/gui/icons/cross.png").then(e=>this.XIconTexture=e),this.Load("./assets/gui/icons/plus.png").then(e=>this.PlusIconTexture=e),this.LoadMissions(),this.LoadTowers(),this.LoadCreeps(),this.LoadGems()]),t.destroy(),this.text.destroy(),this.text=!0}static async LoadGems(){const e=await(await fetch("./assets/json/Gems.json")).json();this.Gems=e;for(let i=0;i<e.length;i++){const n=this.Gems[i];for(let r=1;r<=n.totalLevels;r++){const a=await this.Load(`./assets/gems/${n.type}/${r}.png`);n.textures[r-1]=a}}for(let i=0;i<7;i++)this.GemAmountIcons[i]=await this.Load(`./assets/gui/gem_amount_${i}.png`)}static async LoadCreeps(){const e=await(await fetch("./assets/json/Creeps.json")).json();this.Creeps=e;for(let i=0;i<this.Creeps.length;i++){const n=this.Creeps[i];for(let r=0;r<n.textureArrayLength;r++){const a=await this.Load(`./assets/creeps/${n.name}/${r}.png`);n.textures[r]=a}}}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 i=0;i<this.Towers.length;i++){const n=this.Towers[i];for(let r=0;r<n.projectileTexturesArrayLength;r++){const a=await this.Load(`./assets/projectiles/${n.sprite}/${r}.png`);n.projectileTextures[r]=a}n.texture=await this.Load(`./assets/towers/${n.sprite}.png`)}}static async LoadMission(t){const i=await(await fetch(t)).json();console.log(`Loading mission: ${t} [${i.name} / ${i.mapImage.url}]`),I.Missions.push(i),I.MissionBackgrounds.push(await this.Load(i.mapImage.url))}};p(I,"MainBackground"),p(I,"Frame01Texture"),p(I,"Frame02Texture"),p(I,"Frame03Texture"),p(I,"Frame04Texture"),p(I,"Frame05Texture"),p(I,"FrameInventory"),p(I,"FrameBackground"),p(I,"FrameTowerTab"),p(I,"VioletBackground"),p(I,"RedBackground"),p(I,"GreenBackground"),p(I,"BlueBackground"),p(I,"Button01Texture"),p(I,"Button02Texture"),p(I,"ButtonSmallTexture"),p(I,"HealthTexture"),p(I,"GoldTexture"),p(I,"WaveTexture"),p(I,"SwordsTexture"),p(I,"TitleTexture"),p(I,"BannerGemsmith"),p(I,"EndScreenDialog"),p(I,"Tutorial01"),p(I,"Tutorial02"),p(I,"Tutorial03"),p(I,"Tutorial04"),p(I,"Tutorial05"),p(I,"PlayIconTexture"),p(I,"PauseIconTexture"),p(I,"ExclamationIconTexture"),p(I,"FastForwardIconTexture"),p(I,"HomeIconTexture"),p(I,"HammerIconTexture"),p(I,"XIconTexture"),p(I,"PlusIconTexture"),p(I,"GemAmountIcons",[]),p(I,"Missions",[]),p(I,"MissionBackgrounds",[]),p(I,"Towers"),p(I,"Creeps"),p(I,"Gems"),p(I,"text");let M=I;class bs{constructor(t,e){p(this,"texture");p(this,"level",1);p(this,"definition");p(this,"id");this.definition=M.Gems[t],this.texture=this.definition.textures[0],e?this.id="":(this.id=f.latestGemId+1,f.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 i=this.definition.genericImprovements[e];t.damageUp+=i.damageUp,t.attackSpeedUp+=i.attackSpeedUp,t.rangeUp+=i.rangeUp,t.timeToLiveUp+=i.timeToLiveUp,t.pierceUp+=i.pierceUp,t.gemValueUp+=i.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]}}const et=class et{static TestSuite(){if(new URLSearchParams(location.href).entries().next().value[1]!="game")return;et.NotificationManager.Notify("Loaded testing suite.","danger");let e=M.Towers[0];et.TowerManager.ToggleChoosingTowerLocation("RESET"),et.TowerManager.PlaceTower(e,6,10,e.behaviour,!0);for(let i=0;i<29;i++)this.GameScene.MissionStats.giveGem(new bs(i%4),!0)}};p(et,"app"),p(et,"GameMaster"),p(et,"Grid"),p(et,"WaveManager"),p(et,"TowerManager"),p(et,"AnimationManager"),p(et,"NotificationManager"),p(et,"GameScene"),p(et,"latestCommit"),p(et,"latestGemId",0),p(et,"GridCellSize",64),p(et,"GridColumns",25),p(et,"GridRows",17),p(et,"MouseX",0),p(et,"MouseY",0);let f=et;class gd{constructor(){p(this,"currentScene");f.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),f.GameMaster.currentScene.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),f.GameMaster.currentScene.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.currentScene=t,this.currentScene.init()}}class Ct{constructor(t){p(this,"name",this.constructor.name);p(this,"_container",new J);p(this,"_events",new ft);p(this,"enabled",!0);p(this,"bb",new E);f.GameMaster._CreateGuiObject(this),t&&(this._container.interactive=!0,this._container.onwheel=e=>{this.enabled&&this.onWheel(e)},this._container.onpointerdown=e=>{this.enabled&&this.onClick(e)})}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}onClick(t){console.warn(`[${this.name} does not implement GuiObject.onClick()]`)}onWheel(t){console.warn(`[${this.name} does not implement GuiObject.onWheel()]`)}setEnabled(t){this.enabled=t}copyContainerToBB(){return this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var ot=(s=>(s[s.Button01=0]="Button01",s[s.Button02=1]="Button02",s))(ot||{});class ct extends Ct{constructor(e,i,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=M.Button01Texture),n==1&&(this.buttonTexture=M.Button02Texture),this.caption=i,this.enabled=r,this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.container.width=this.bounds.width,this.container.height=this.bounds.height,this.buttonSprite=new yt({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 W({text:this.caption,style:new N({fill:16777215,fontSize:24})}),this.container.addChild(this.buttonText),this.buttonText.anchor.set(.5,.5),this.buttonText.x=this.bounds.width/2,this.buttonText.y=this.bounds.height/2,this.container.x=this.bounds.x,this.container.y=this.bounds.y}setCaption(e){this.caption=e,this.buttonText.text=e}getCaption(){return this.caption}CustomButtonLogic(){console.warn(this.name+" - Button.CustomButtonLogic() is not implemented.")}}class vi{constructor(){p(this,"stage",new J);p(this,"gui",[]);p(this,"_events",new ft);f.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this._events.removeAllListeners(),this.gui.forEach(t=>{t.destroy()})}addMainBackground(){const t=new $(M.MainBackground);t.width=f.app.canvas.width,t.height=f.app.canvas.height,this.stage.addChild(t)}get events(){return this._events}init(){}}class md extends vi{constructor(){super(...arguments);p(this,"currentImg",1);p(this,"sprite")}init(){let e=[null,M.Tutorial01,M.Tutorial02,M.Tutorial03,M.Tutorial04,M.Tutorial05];this.sprite=new $({texture:M.Tutorial01,scale:.6,x:250,y:150}),this.stage.addChild(this.sprite);let i=new ct(new E(250,this.sprite.height+160,120,60),"Back",ot.Button01);i.container.alpha=0,i.onClick=()=>{i.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&&(i.container.alpha=0))};let n=new ct(new E(this.sprite.width+130,this.sprite.height+160,120,60),"Next",ot.Button01);n.onClick=()=>{n.container.alpha!=0&&(this.currentImg++,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.currentImg!=1&&(i.container.alpha=1),this.sprite.texture=e[this.currentImg],this.currentImg==5&&(n.container.alpha=0))};const r=new ct(new E(this.sprite.width-540,this.sprite.height+160,200,60),"Main menu",ot.Button01);r.onClick=a=>{f.GameMaster.changeScene(new Ns)}}}class $t{constructor(){p(this,"name",this.constructor.name);p(this,"_container",new J);p(this,"bb",new E);p(this,"_events",new ft)}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 Ft=(s=>(s[s.Restricted=0]="Restricted",s[s.Buildable=1]="Buildable",s[s.Path=9]="Path",s))(Ft||{}),ie=(s=>(s.CreepSpawned="creepSpawned",s.Finished="finished",s.NewWave="newwave",s))(ie||{}),kt=(s=>(s.Died="died",s.TakenDamage="takenDamage",s.Escaped="escaped",s.Moved="moved",s))(kt||{}),$e=(s=>(s.CellMouseOver="cellmouseover",s.CellMouseLeave="cellmouseleave",s))($e||{}),ge=(s=>(s.TowerPlacedEvent="towerPlacedEvent",s.TowerSoldEvent="towerSoldEvent",s))(ge||{}),zs=(s=>(s.GemGivenEvent="gemGivenEvent",s))(zs||{}),Us=(s=>(s.TowerPanelSelectGem="towerTabSelectGem",s))(Us||{});class xd extends $t{constructor(e,i,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,"clickDetector");this.type=e,this.row=i,this.column=n,this.isPath=r,this.bb.x=this.column*f.GridCellSize,this.bb.y=this.row*f.GridCellSize,this.bb.width=f.GridCellSize,this.bb.height=f.GridCellSize,f.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new St({zIndex:99,interactive:!0}),this.g=new St({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=>{f.Grid.gridInteractionEnabled&&(f.TowerManager.isPlacingTower?f.Grid.onGridCellClicked(i,n):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!f.Grid.gridInteractionEnabled||f.GameScene.towerPanel.isShown||f.GameScene.events.emit($e.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!f.Grid.gridInteractionEnabled||f.GameScene.towerPanel.isShown||(f.GameScene.events.emit($e.CellMouseLeave,this),f.Grid.rangePreview.clear())}),f.GameScene.events.on(ge.TowerPlacedEvent,(a,o,h)=>{o==this.row&&h==this.column&&(this.hasTowerPlaced=!0,f.Grid.rangePreview.clear())}),f.GameScene.events.on(ge.TowerSoldEvent,(a,o,h)=>{o==this.row&&h==this.column&&(this.hasTowerPlaced=!1,f.Grid.rangePreview.clear())})}showRangePreview(e,i){let n=16777215;e&&(n=16711680),f.Grid.rangePreview.clear(),f.Grid.rangePreview.circle(this.column*f.GridCellSize+f.GridCellSize/2,this.row*f.GridCellSize+f.GridCellSize/2,i*f.GridCellSize),f.Grid.rangePreview.fill({color:n,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=f.TowerManager.GetTowerByRowAndCol(this.row,this.column);f.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Ft.Path||this.type==Ft.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Ft.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Ft.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Ft.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class yd extends $t{constructor(e,i){super();p(this,"gameMap");p(this,"cells",[]);p(this,"rangePreview");p(this,"creeps",[]);p(this,"gridShown",!1);p(this,"gridInteractionEnabled",!0);this.gameMap=e,f.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=f.GridCellSize*f.GridColumns,this.bb.height=f.GridCellSize*f.GridRows,f.GameMaster.currentScene.stage.addChild(this.container);let n=new $(M.MissionBackgrounds[i]);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(l=>l.some(d=>d[1]===a&&d[0]===r));h&&(o=Ft.Path);let c=new xd(o,a,r,h);this.cells.push(c)}this.rangePreview=new St({zIndex:10}),this.container.addChild(this.rangePreview)}generateCells(){const e=Array.from({length:this.gameMap.rows},()=>Array(this.gameMap.columns).fill(1));this.cells.forEach(i=>{if(i.isPath){e[i.row][i.column]=9;for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++){const a=i.row+n,o=i.column+r;a>=0&&a<this.gameMap.rows&&o>=0&&o<this.gameMap.columns&&e[a][o]!==9&&(e[a][o]=0)}}}),console.log(JSON.stringify(e))}toggleGrid(e){this.cells.forEach(i=>{if(e){e=="hide"?i.gClear():i.gDraw();return}this.gridShown?i.gClear():i.gDraw()}),e=="hide"?this.gridShown=!1:e=="show"?this.gridShown=!0:this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(kt.Died,i=>{this.onCreepDiedOrEscaped(i)}),e.events.on(kt.Escaped,i=>{this.onCreepDiedOrEscaped(i)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(i=>{i.dead?(this.creeps.splice(this.creeps.indexOf(i),1),i=null):i.update(e)})}getCellByRowAndCol(e,i){return this.cells.filter(n=>n.row==e&&n.column==i)[0]}onGridCellClicked(e,i){}}class _d extends $t{constructor(e,i,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 St);p(this,"healthBarWidth",50);p(this,"health");p(this,"maxHealth");p(this,"escaped",!1);p(this,"died",!1);p(this,"x");p(this,"y");p(this,"dead",!1);this.creepType=e,this.stats=structuredClone(M.Creeps[this.creepType].stats),this.sprite=new He(M.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=f.GridCellSize,this.sprite.height=f.GridCellSize,this.bb.width=this.sprite.width,this.speed=this.stats.speed/60,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=i,this.x=i[0][0]*f.GridCellSize+f.GridCellSize/2,this.y=i[0][1]*f.GridCellSize+f.GridCellSize/2,f.GameScene.events.on(kt.TakenDamage,(r,a,o)=>{r==this.id&&(this.health-=a+a*(o.physical-this.stats.resistance.physical),o.fire!=0&&(this.health-=Math.max(a*(o.fire-this.stats.resistance.fire),0)),o.ice!=0&&(this.health-=Math.max(a*(o.ice-this.stats.resistance.ice),0)),o.frostfire!=0&&(this.health-=Math.max(a*(o.frostfire-this.stats.resistance.frostfire),0)),o.divine!=0&&(this.health-=Math.max(a*(o.divine-this.stats.resistance.divine),0)),this.UpdateHealthbar())}),f.Grid.container.addChild(this.container),this.container.addChild(this.healthBarGraphics),this.container.addChild(this.sprite),this.UpdateHealthbar()}UpdateHealthbar(){this.healthBarGraphics.clear();const e=this.health,i=this.maxHealth,n=e/i,r=this.healthBarWidth*n;this.healthBarGraphics.rect(-this.healthBarWidth/2+3,-32,this.healthBarWidth+4,14),this.healthBarGraphics.fill({color:0}),this.healthBarGraphics.rect(-this.healthBarWidth/2+5,-30,r,10),this.healthBarGraphics.fill({color:16711680})}update(e){if(this.dead)return;if(this.health<=0){f.GameScene.events.emit(kt.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(kt.Escaped,this),this.escaped=!0;return}const i=this.path[this.pathIndex],n=this.path[this.pathIndex+1],r=n[0]*f.GridCellSize+f.GridCellSize/2,a=n[1]*f.GridCellSize+f.GridCellSize/2,o=n[0]-i[0],h=n[1]-i[1];o>0?this.direction!=1&&(this.direction=1,this.sprite.scale.x*=-1):o<0&&this.direction!=-1&&(this.direction=-1,this.sprite.scale.x*=-1);let c=this.speed*e*o*f.GameScene.gameSpeedMultiplier,l=this.speed*e*h*f.GameScene.gameSpeedMultiplier,d=!1;c>0&&this.x+c>r&&(c=r-this.x,d=!0),c<0&&this.x+c<r&&(c=r-this.x,d=!0),l>0&&this.y+l>a&&(l=a-this.y,d=!0),l<0&&this.y+l<a&&(l=a-this.y,d=!0),this.x+=c,this.y+=l,d&&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(kt.Died,this))}destroy(){super.destroy(),this.container.removeChildren()}}class wd extends $t{constructor(e,i){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);f.WaveManager=this,this.rounds=e,this.paths=i,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 i=0;this.rounds[e].waves.forEach(n=>{i+=n.firstCreepSpawnTick,n.creeps.forEach(r=>{const a=new _d(r,this.paths[this.pathsIndex],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:i,spawned:!1};i+=n.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e*f.GameScene.gameSpeedMultiplier,this.creeps.forEach(i=>{!i.spawned&&i.tickToSpawnAt<=this.ticks?(i.spawned=!0,this.events.emit(ie.CreepSpawned,i.creep),!this.finished&&this.creeps.every(n=>n.spawned)&&(this.finished=!0,this.events.emit(ie.Finished))):i.spawned&&i.creep.update(e)}))}}class Qn extends Ct{constructor(e,i,n,r,a,o,h,c){if(e>3||i>2||e<0||i<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=i*r+5,this.background=new $({texture:o}),this.iconSprite=new $({texture:c}),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 yt({texture:M.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:r,width:n}),this.container.addChild(this.frameSprite),a.addChild(this.container),f.GameScene.events.on(ge.TowerPlacedEvent,l=>{this.resetTint()}),this.container.onpointermove=l=>{f.Grid.gridInteractionEnabled!=!1&&(f.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=l=>{f.GameScene.tooltip.Hide()}}ShowTooltip(){let e;M.Towers.forEach(i=>{i.name==this.towerName&&(e=i)}),f.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),f.GameScene.tooltip.Show(f.MouseX,f.MouseY)}onClick(e){f.Grid.gridInteractionEnabled!=!1&&(f.TowerManager.isPlacingTower&&f.TowerManager.selectedTower.name!=this.towerName&&(f.GameScene.sidebar.towerTab.resetTint(),f.TowerManager.ResetChooseTower()),f.GameScene.towerPanel.Hide(),f.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,f.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class bd extends Ct{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 yt({texture:M.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 Qn(0,0,70,70,this.container,M.RedBackground,"Basic Tower",M.Towers[0].texture)),this.towerButtons.push(new Qn(3,1,70,70,this.container,M.GreenBackground,"Circle Tower",M.Towers[1].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const te=class te{static init(){te.SidebarRect=new E(f.app.canvas.width-360,0,360,f.app.canvas.height),te.ChangeRoundButtonRect=new E(50,f.app.canvas.height-100,310,100)}};p(te,"SidebarRect"),p(te,"ChangeRoundButtonRect"),p(te,"MaximumPlayerNameLength",20);let Nt=te;function Et(s,t,e,i){const n=e-s,r=i-t;return Math.atan2(r,n)}class Sd extends $t{constructor(e,i,n,r,a,o,h,c,l){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=i,this.timeToLive=h,this.pierce=c,this.damage=a,this.gemResistanceModifications=l,this.sprite=new He({textures:n,scale:.25,rotation:r}),this.sprite.anchor.set(.5,.5),this.sprite.play(),this.container.x=this.x,this.container.y=this.y,this.sprite.tint=o,this.container.addChild(this.sprite),f.GameMaster.currentScene.stage.addChild(this.container),this.angle=r,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>2e3||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();this.timeToLive-=f.GameScene.gameSpeedMultiplier,f.Grid.creeps.forEach(i=>{if(!(this.pierce<=0)&&i&&i.container&&this.checkCollision(i)&&!this.collidedCreepIDs.find(r=>i.id==r.id)){this.collidedCreepIDs.push(i),this.pierce--,this.onCollide(i);return}}),this.x+=Math.cos(this.angle)*this.speed*e*f.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*f.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y}}onCollide(e){f.GameScene.events.emit(kt.TakenDamage,e.id,this.damage,this.gemResistanceModifications)}checkCollision(e){if(e==null||e.container==null||e.container._position==null)return;let i=this.copyContainerToBB(),n=e.copyContainerToBB();return i.getBounds().intersects(n.getBounds())}}function Ga(s,t){s.projectiles.forEach(e=>{e.deleteMe||s.sold?(e.collidedCreepIDs.forEach(()=>{s.damageDealt+=s.computedDamageToDeal}),e.collidedCreepIDs=[],s.projectiles.splice(s.projectiles.indexOf(e),1),e.destroy(),e=null):e.update(t)})}function Ws(s){let t=0,e=0,i=0,n=0,r=0;s.totalGemResistanceModifications={fire:0,frostfire:0,divine:0,ice:0,physical:0},s.slottedGems.forEach(a=>{let o=a.currentGemImprovement();t+=o.damageUp,e+=o.attackSpeedUp,i+=o.rangeUp,n+=o.timeToLiveUp,r+=o.pierceUp;let h=a.currentGemResistanceModifications();s.totalGemResistanceModifications.physical+=h.physical,s.totalGemResistanceModifications.ice+=h.ice,s.totalGemResistanceModifications.fire+=h.fire,s.totalGemResistanceModifications.divine+=h.divine,s.totalGemResistanceModifications.frostfire+=h.frostfire}),s.computedDamageToDeal=s.definition.stats.damage+t,s.computedCooldown=s.definition.stats.cooldown-e,s.computedRange=s.definition.stats.range+i,s.computedTimeToLive=s.definition.stats.timeToLive+n,s.computedPierce=s.definition.stats.pierce+r}function vd(s,t){Ws(s),Ga(s,t),s.millisecondsUntilNextShot>0&&(s.millisecondsUntilNextShot-=t*f.GameScene.gameSpeedMultiplier);let e=s.GetCreepsInRange();if(e.length>0){let i=e[0];if(s.millisecondsUntilNextShot<=0){let n=s.column*f.GridCellSize+f.GridCellSize/2,r=s.row*f.GridCellSize+f.GridCellSize/2;s.millisecondsUntilNextShot=s.computedCooldown,s.Shoot(Et(n,r,i.x,i.y))}}}function Cd(s,t){Ws(s),Ga(s,t),s.millisecondsUntilNextShot>0&&(s.millisecondsUntilNextShot-=t*f.GameScene.gameSpeedMultiplier);let e=s.GetCreepsInRange();if(e.length>0&&(e[0],s.millisecondsUntilNextShot<=0)){s.millisecondsUntilNextShot=s.computedCooldown;let i=s.column*f.GridCellSize+f.GridCellSize/2,n=s.row*f.GridCellSize+f.GridCellSize/2;s.Shoot(Et(i,n,i,n+10)),s.Shoot(Et(i,n,i+10,n)),s.Shoot(Et(i,n,i-10,n)),s.Shoot(Et(i,n,i,n-10)),s.Shoot(Et(i,n,i+10,n+10)),s.Shoot(Et(i,n,i-10,n+10)),s.Shoot(Et(i,n,i-10,n-10)),s.Shoot(Et(i,n,i+10,n-10))}}class Ve extends Ct{constructor(e,i,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*(f.GridCellSize+6)+300,this.background=new $({texture:M.Frame01Texture}),n==null&&!r?a=M.PlusIconTexture:r=="SELL"?a=M.GoldTexture:r=="UPGRADE"?a=M.PlusIconTexture:(a=n.texture,this.gem=n),this.iconSprite=new $({texture:a,zIndex:10}),this.background.width=f.GridCellSize,this.background.height=f.GridCellSize,n==null&&!r?(this.iconSprite.x=f.GridCellSize/2,this.iconSprite.y=f.GridCellSize/2,this.iconSprite.width=f.GridCellSize/2,this.iconSprite.height=f.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):r=="SELL"?(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=f.GridCellSize-8,this.iconSprite.height=f.GridCellSize-8):r=="UPGRADE"?(this.iconSprite.x=f.GridCellSize/2,this.iconSprite.y=f.GridCellSize/2,this.iconSprite.width=f.GridCellSize/2,this.iconSprite.height=f.GridCellSize/2,this.iconSprite.tint=3012919,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=f.GridCellSize-8,this.iconSprite.height=f.GridCellSize-8),this.frame=new $({texture:M.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 W({text:o,zIndex:11,style:{fill:"white",stroke:{color:0,width:5}}});this.container.addChild(h),i.addChild(this.container)}setTint(e){this.frame.tint=e}resetTint(){this.frame.tint=16777215}}class Td extends Ct{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 yt({texture:M.Frame03Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.towerPanel.width=this.bounds.width,this.towerPanel.height=this.bounds.height-this.bounds.height/3.5,this.closeBtn=new ct(new E(-20,-20,60,60),"",ot.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new $({texture:M.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=f.app.canvas.height/2-f.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),f.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new W({x:this.bounds.width/3,y:50,zIndex:5,style:new N({fill:16777215,fontSize:25,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new W({x:10,y:100,zIndex:5,style:new N({fill:16753920,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.damageText),this.attackSpeedText=new W({x:100,y:100,zIndex:5,style:new N({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.attackSpeedText),this.totalDamage=new W({x:10,y:130,zIndex:5,style:new N({fill:16711680,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.totalDamage),this.fireResDamage=new W({x:10,y:170,zIndex:5,style:new N({fill:16536403,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.fireResDamage),this.iceResDamage=new W({x:10,y:190,zIndex:5,style:new N({fill:3335420,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.iceResDamage),this.frostFireResDamage=new W({x:10,y:210,zIndex:5,style:new N({fill:14111740,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.frostFireResDamage),this.divineResDamage=new W({x:10,y:230,zIndex:5,style:new N({fill:16576083,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.divineResDamage),this.physicalResDamage=new W({x:10,y:250,zIndex:5,style:new N({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.physicalResDamage),this.sellButton=new ct(new E(5,this.towerPanel.height-70,this.towerPanel.width-115,60),"Sell",ot.Button02,!0),this.sellButton.container.removeFromParent(),this.container.addChild(this.sellButton.container)}MakeSlots(e){this.vGems.forEach(n=>{n.destroy()}),this.vGems=[];let i=e.definition.stats.gemSlotsAmount;for(let n=0;n<i;n++){console.log("BUILDING TOWER PANEL "+n);let r=e.slottedGems[n];r||(r=null);const a=new Ve(n,this.container,r);a.resetTint(),this.vGems.push(a),a.container.onpointermove=()=>{r&&(f.GameScene.tooltip.SetContentGem(r),f.GameScene.tooltip.Show(f.MouseX,f.MouseY))},a.container.onpointerleave=()=>{f.GameScene.tooltip.Hide()},a.onClick=()=>{f.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",r,a.i,n,e),f.GameScene.events.emit(Us.TowerPanelSelectGem,r,a.i,e),!r&&f.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,Ws(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,f.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/60*100)/100}s`,this.fireResDamage.text=`+${e.totalGemResistanceModifications.fire*100}% Fire damage`,this.iceResDamage.text=`+${e.totalGemResistanceModifications.ice*100}% Ice damage`,this.frostFireResDamage.text=`+${e.totalGemResistanceModifications.frostfire*100}% FrostFire damage`,this.divineResDamage.text=`+${e.totalGemResistanceModifications.divine*100}% Divine damage`,this.physicalResDamage.text=`+${e.totalGemResistanceModifications.physical*100}% Physical damage`,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=Nt.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=-1e3,f.Grid.rangePreview.clear()}}class Ad extends Ct{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 yt({texture:M.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),f.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),f.GameScene.events.on(zs.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,i,n){console.log("TOWER PANEL SELECTING GEM "+i),i<0&&console.error("TOWER PANEL SELECTING GEM INDEX IS LESS THAN 0, ",i),this.isSelectingGem?e==null&&(this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null):(this.isSelectingGem=!0,e==null?(f.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=i,this.selectingGemTowerObject=n):(n.UnslotGem(i),this.RebuildInventoryVisual(),f.GameScene.towerPanel.Hide(),f.GameScene.towerPanel.Show(n),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=f.MouseX-32,this.dragAndDroppingGem.container.y=f.MouseY-32)}isOverlappingGemsmith(e,i,n){let r=e.copyContainerToBB(),a=i.copyContainerToBB(),o=n.x+a.x+f.GameScene.sidebar.container.x,h=n.y+a.y+f.GameScene.sidebar.container.y,c=new E(o,h,a.width,a.height);if(r.getBounds().intersects(c)&&i&&i.gem==null)return!0}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],f.GameScene.MissionStats.getInventory().forEach((e,i)=>{let n=new Ve(0,this.container,e),r=10,a=i%4*70+10,o=i;for(;!(o<=3);)r+=66,o-=4;n.container.x=a,n.container.y=r,n.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(f.GameScene.tooltip.SetContentGem(e),f.GameScene.tooltip.Show(f.MouseX,f.MouseY))},n.container.onpointerleave=()=>{f.GameScene.tooltip.Hide()},n.container.onpointerdown=()=>{if(f.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=f.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=n,n.container.removeFromParent(),f.GameScene.stage.addChild(n.container),this.pointerMoveEvent()},n.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(this.isOverlappingGemsmith(this.dragAndDroppingGem,f.GameScene.sidebar.gemsmith.sellVGem,f.GameScene.sidebar.gemsmith.container)){let d=this.dragAndDroppingGem.gem.definition.initialGemValue+this.dragAndDroppingGem.gem.currentGemImprovement().gemValueUp;f.GameScene.MissionStats.earnGold(Math.ceil(d*.8)),f.NotificationManager.Notify(`Sold Lv. ${this.dragAndDroppingGem.gem.level} ${this.dragAndDroppingGem.gem.definition.name} for ${Math.ceil(d*.8)} gold.`,"info"),f.GameScene.MissionStats.takeGem(this.dragAndDroppingGem.gem),this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(this.isOverlappingGemsmith(this.dragAndDroppingGem,f.GameScene.sidebar.gemsmith.upgradeVGem,f.GameScene.sidebar.gemsmith.container)){if(this.dragAndDroppingGem.gem.isMaxLevel())f.NotificationManager.Notify("Gem is max level.","warn");else{let d=this.dragAndDroppingGem.gem.definition.genericImprovements[this.dragAndDroppingGem.gem.level].gemValueUp;f.GameScene.MissionStats.hasEnoughGold(d)?(f.GameScene.MissionStats.spendGold(d),this.dragAndDroppingGem.gem.levelUp(1),f.NotificationManager.Notify(`Spent ${d} gold to upgrade ${this.dragAndDroppingGem.gem.definition.name} Lv. ${this.dragAndDroppingGem.gem.level-1} -> Lv. ${this.dragAndDroppingGem.gem.level}!`,"warn")):f.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(f.GameScene.towerPanel.vGems.forEach(d=>{if(h||!this.dragAndDroppingGem)return;let u=this.dragAndDroppingGem.copyContainerToBB(),g=d.copyContainerToBB(),m=f.GameScene.towerPanel.container.x+g.x,y=f.GameScene.towerPanel.container.y+g.y,x=new E(m,y,g.width,g.height);u.getBounds().intersects(x)&&d&&d.gem==null&&(h=d)}),h){let d=f.GameScene.MissionStats.takeGem(e);f.GameScene.towerPanel.showingTower.SlotGem(d,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(n)})}}class Md extends Ct{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 i=new $({x:0,y:0,width:this.bounds.width,height:this.bounds.height,texture:M.BannerGemsmith});this.container.addChild(i);let n=new W({x:40,y:this.bounds.height/6.5,text:"Sell gem",style:new N({fill:16767744,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(n);let r=new W({x:155,y:this.bounds.height/6.5,text:"Upgrade gem",style:new N({fill:3012919,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(r),this.sellVGem=new Ve(0,this.container,null,"SELL"),this.sellVGem.container.x=45,this.sellVGem.container.y=this.bounds.height/4,this.upgradeVGem=new Ve(0,this.container,null,"UPGRADE"),this.upgradeVGem.container.x=180,this.upgradeVGem.container.y=this.bounds.height/4}}class Pd extends Ct{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 yt({texture:M.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.sidebarSprite.x=40,this.sidebarSprite.y=-40,this.sidebarSprite.width=this.bounds.width+40,this.sidebarSprite.height=this.bounds.height+80,this.container.addChild(this.sidebarSprite);const i=new E(60,20,this.bounds.width-65,150);this.towerTab=new bd(i),this.container.addChild(this.towerTab.container);const n=new E(60,180,this.bounds.width-65,this.bounds.height-280-255);this.gemTab=new Ad(n),this.container.addChild(this.gemTab.container);const r=new E(60,185+n.height,this.bounds.width-65,this.bounds.height-840);this.gemsmith=new Md(r),this.container.addChild(this.gemsmith.container)}}class kd extends $t{constructor(e,i){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=i,this.container.x=0,this.container.y=20,f.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new W({text:`${this.hp}`,style:new N({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new W({text:`${this.gold}`,style:new N({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new W({text:`0/${f.GameScene.mission.rounds.length}`,style:new N({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const n=new $(M.HealthTexture),r=new $(M.GoldTexture),a=new $(M.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),f.GameScene.events.on(ie.NewWave,o=>{this.waveText.text=`${o}/${f.GameScene.mission.rounds.length}`})}getHP(){return this.hp}hasEnoughGold(e){return e<=this.gold}setHP(e){this.hp=e,this.healthText.text=this.hp}takeDamage(e){this.hp-=e,this.healthText.text=this.hp}setGold(e){this.gold=e,this.goldText.text=this.gold}earnGold(e){this.gold+=e,this.goldText.text=this.gold}spendGold(e){this.gold-=e,this.goldText.text=this.gold}giveGem(e,i){if(this.inventory.length>=32)return f.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),i||f.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),f.GameScene.events.emit(zs.GemGivenEvent,e)}takeGem(e){return this.inventory.splice(this.inventory.indexOf(e),1)[0]}getInventory(){return this.inventory}checkIfPlayerHasAnyGems(){return this.inventory.length>0}getStats(){return{hp:this.hp,gold:this.gold,wavesSurvived:this.wavesSurvived,goldEarned:this.goldEarned,goldSpent:this.goldSpent,score:this.calculateScore()}}calculateScore(){const e=[];for(const i of this.inventory)e.includes(i.definition.name)||e.push(i.definition.name);return this.damageDealt*2+this.hp*10+(this.goldEarned-this.goldSpent)*3+this.wavesSurvived*100+e.length*100}update(){}}function Gd(s,t,e,i){return Math.sqrt((e-s)*(e-s)+(i-t)*(i-t))}class Id extends $t{constructor(e,i,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 St);p(this,"computedDamageToDeal");p(this,"computedCooldown");p(this,"computedRange");p(this,"computedTimeToLive");p(this,"computedPierce");p(this,"totalGemResistanceModifications");p(this,"parent");p(this,"onParentCellEnter",e=>{!f.TowerManager.isPlacingTower&&f.Grid.gridInteractionEnabled&&!f.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.computedRange)});p(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=i,this.behaviour=a,this.definition=r,this.millisecondsUntilNextShot=0,this.parent=f.Grid.getCellByRowAndCol(e,i),this.sprite=new $({texture:n,height:f.GridCellSize,width:f.GridCellSize,zIndex:130}),this.container.addChild(this.sprite),this.computedDamageToDeal=this.definition.stats.damage,this.parent.container.addChild(this.container),this.container.interactiveChildren=!0,this.parent.clickDetector.on("pointerenter",this.onParentCellEnter),this.parent.clickDetector.on("pointerleave",this.onParentCellLeave),f.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,i){this.slottedGems[i]=e,f.GameScene.towerPanel.Hide(),f.GameScene.towerPanel.Show(this)}UnslotGem(e){const i=this.slottedGems.splice(e,1)[0];if(i==null||!i)return console.warn("UnslotGem: Gem is null.");f.GameScene.MissionStats.giveGem(i,!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);f.GameScene.sidebar.gemTab.selectingGemTowerObject=this,this.slottedGems=this.slottedGems.filter(n=>n!=null),f.NotificationManager.Notify(`Lv. ${i.level} ${i.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return f.Grid.creeps.filter(i=>{const n=i.x,r=i.y,a=this.column*f.GridCellSize+f.GridCellSize/2,o=this.row*f.GridCellSize+f.GridCellSize/2,h=this.computedRange*f.GridCellSize;return Gd(a,o,n,r)<h+f.GridCellSize*2/3})}Shoot(e){let i=this.column*f.GridCellSize+f.GridCellSize/2,n=this.row*f.GridCellSize+f.GridCellSize/2,r=new Z("white");if(this.slottedGems.length>0){let h=new Z(this.slottedGems[0].definition.color);for(let c=1;c<this.slottedGems.length;c++){const l=this.slottedGems[c];h.multiply(l.definition.color)}r=h}let a=new Sd(i,n,this.definition.projectileTextures,e,this.computedDamageToDeal,r,this.computedTimeToLive,this.computedPierce,this.totalGemResistanceModifications);const o=new Date().toISOString();return console.log(`${o} ${this.definition.name} shot at ${e} degrees`),this.projectiles.push(a),a}Sell(){this.setAsSold=!0}update(e){this.sold||(this.setAsSold&&(this.sold=!0),this.behaviour==Ss.BasicTowerBehaviour&&vd(this,e),this.behaviour==Ss.CircleTowerBehaviour&&Cd(this,e))}destroy(){super.destroy(),this.parent.clickDetector.off("pointerenter",this.onParentCellEnter),this.parent.clickDetector.off("pointerleave",this.onParentCellLeave),this.graphics.destroy()}}var Ss=(s=>(s.BasicTowerBehaviour="BasicTowerBehaviour",s.CircleTowerBehaviour="CircleTowerBehaviour",s))(Ss||{});class Bd{constructor(){p(this,"isPlacingTower",!1);p(this,"canPlaceTowers",!0);p(this,"selectedTower",null);p(this,"previewSprite",new $({parent:f.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));p(this,"towers",[]);f.TowerManager=this,f.GameScene.events.on($e.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*f.GridCellSize,this.previewSprite.y=t.row*f.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),f.GameScene.events.on($e.CellMouseLeave,t=>{this.previewSprite.texture=null})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,f.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(f.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):M.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 f.NotificationManager.Notify("TowerManager.selectedTower is null when trying to place tower.","danger"),console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let i=null;return this.towers.forEach(n=>{n.row==t&&n.column==e&&(i=n)}),i}PlaceTower(t,e,i,n,r){const a=t.texture;if(!f.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!r)return f.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,i)&&f.Grid.getCellByRowAndCol(e,i).type!=Ft.Path&&f.Grid.getCellByRowAndCol(e,i).type!=Ft.Restricted){r||f.GameScene.MissionStats.spendGold(t.stats.cost);let o=new Id(e,i,a,t,n);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,f.GameScene.events.emit(ge.TowerPlacedEvent,t.name,e,i)}else f.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn"),console.warn("Can not place tower on occupied spot or path. Try again.")}update(t){this.towers.forEach((e,i)=>{if(e.sold){for(e.slottedGems=e.slottedGems.filter(n=>n!=null);e.slottedGems.length>0;)e.UnslotGem(0);f.GameScene.MissionStats.earnGold(e.definition.stats.cost),e.destroy(),this.towers.splice(i,1),f.GameScene.events.emit(ge.TowerSoldEvent,e.name,e.row,e.column)}else e.update(t)})}}class Ed extends Ct{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 yt({texture:M.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new W({x:this.tooltipSprite.width/2,y:-20,zIndex:5,style:new N({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.title=new $({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:M.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new $({texture:M.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new W({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 W({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:M.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new $({texture:M.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new W({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 W({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),f.app.stage.addChildAt(this.container,0)}SetContentTower(e,i,n,r){this.costSprite.alpha=1,this.damageSprite.alpha=1,this.gemAmountSprite.alpha=1,this.costText.alpha=1,this.damageText.alpha=1,this.gemAmount.alpha=1,this.gemDescriptionText.alpha=0,this.titleText.text=e,this.gemAmount.text=`Has ${r} Gem slots.`,this.gemAmountSprite.texture=M.GemAmountIcons[r],this.costText.text=`Costs ${n} gold.`,this.damageText.text=`Deals ${i} base damage.`}SetContentGem(e){this.costSprite.alpha=0,this.damageSprite.alpha=0,this.gemAmountSprite.alpha=0,this.costText.alpha=0,this.damageText.alpha=0,this.gemAmount.alpha=0,this.gemDescriptionText.alpha=1,this.titleText.text=`Lv. ${e.level} `+e.definition.name;let i;e.isMaxLevel()?i="Max level.":i=`Costs ${e.definition.genericImprovements[e.level].gemValueUp} gold to level up.`,this.gemDescriptionText.text=`${i} Valued at ${e.definition.initialGemValue+e.currentGemImprovement().gemValueUp} gold. `+e.definition.description}Show(e,i){this.container.alpha=1,e+this.container.width>f.app.canvas.width?this.container.x=e-this.container.width:this.container.x=e,this.container.y=i}Hide(){this.container.alpha=0,this.container.x=-500,this.container.y=-500}}const dt=class dt{static init(){window.addEventListener("keydown",dt.handleKeyDown)}static onKeyPressed(t){return dt.listeners=[...dt.listeners,t],()=>dt.offKey(t)}static offKey(t){const e=dt.listeners.indexOf(t);e>=0&&(dt.listeners=[...dt.listeners.slice(0,e),...dt.listeners.slice(e+1)])}static handleKeyDown(t){if(dt.listeners.length>0)for(let e=dt.listeners.length-1;e>=0&&(dt.listeners[e](t),!t.defaultPrevented);e--);}};p(dt,"listeners",[]);let me=dt;class Ci extends Ct{constructor(e,i,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,i&&!e.includes(i))throw new Error(`Enter key button "${i}" not found in buttons: ${e}`);this.enterKeyButton=i,this.keyboardManagerUnsubscribe=me.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,i)=>{f.app.stage.addChild(this.container),this.onClosed=n=>{this.destroy(),e(n)}})}createDialogBackground(){return new yt({texture:M.Frame04Texture,leftWidth:60,topHeight:60,rightWidth:60,bottomHeight:60})}getWidth(){}getHeight(){}generate(){if(this.generated)return;this.generated=!0,this.overlay=new St,this.overlay.rect(0,0,f.app.canvas.width,f.app.canvas.height),this.overlay.fill({color:0,alpha:.5}),this.overlay.interactive=!0,this.container.addChild(this.overlay);const e=this.buttonCaptions.map(c=>({caption:c,width:c.length*14+60,height:this.buttonHeight,click:()=>this.close(c)}));this.background=this.createDialogBackground(),this.dialogContent=this.createContent();let i=0;for(const c of e)i>0&&(i+=10),i+=c.width;const n=this.buttonCaptions.length>0?this.buttonHeight+10:0;let r=this.getWidth()||Math.max(i,this.dialogContent.width)+this.background.leftWidth+this.background.rightWidth,a=this.getHeight()||this.dialogContent.height+n+this.background.topHeight+this.background.bottomHeight;const o=new E(f.app.canvas.width/2-r/2,f.app.canvas.height/2-a/2,r,a);this.dialogContainer=new J,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-i/2;for(const c of e){const l=new ct(new E(h,o.height-this.buttonHeight-this.background.bottomHeight,c.width,c.height),c.caption,ot.Button01);l.onClick=c.click,this.buttons.push(l),this.dialogContainer.addChild(l.container),h+=c.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 Rd extends Ct{constructor(e,i){super();p(this,"backgroundSprite");p(this,"text");p(this,"maxLength");p(this,"keyboardManagerUnsubscribe");this.maxLength=i,this.backgroundSprite=new yt({texture:M.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 W({text:"",style:new N({fill:16777215,fontSize:24})}),this.text.x=30,this.text.y=25,this.container.addChild(this.text),this.keyboardManagerUnsubscribe=me.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 Os extends Ci{constructor(e,i,n,r){!r&&i.length>0&&(r=i[0]),!n&&i.length>0&&(n=i[i.length-1]);super(i,n,r);p(this,"caption");this.caption=e}createContent(){return new W({text:this.caption,style:new N({fill:16777215,fontSize:24})})}static show(e,i,n=0){return new Os(e,i).show()}}const Rt=class Rt{constructor(t){p(this,"missionName");p(this,"scores");this.missionName=t,this.scores=this.loadScores(),this.scores.sort((e,i)=>i.score-e.score||e.timestamp-i.timestamp)}loadScores(){const t=localStorage.getItem(Rt.STORAGE_KEY_PREFIX+this.missionName);return Rt.parseStoredScores(t)}saveScores(){localStorage.setItem(Rt.STORAGE_KEY_PREFIX+this.missionName,JSON.stringify(this.scores))}addScore(t){this.scores.push(t),this.scores.sort((e,i)=>i.score-e.score),this.scores.length>Rt.MAX_SCORES&&(this.scores.length=Rt.MAX_SCORES),this.saveScores()}getScores(){return this.scores}static parseStoredScores(t){if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e)&&e.every(i=>typeof i.playerName=="string"&&typeof i.score=="number"&&typeof i.timestamp=="number"))return e.map(i=>({playerName:i.playerName,score:i.score,timestamp:i.timestamp}))}catch(e){console.error("Failed to parse stored scores:",e)}return[]}};p(Rt,"STORAGE_KEY_PREFIX","highscore_"),p(Rt,"MAX_SCORES",10);let gi=Rt;const Ge={Confirm:"OK",Skip:"Skip"};class Fd extends Ci{constructor(e,i,n){super([Ge.Confirm,Ge.Skip],Ge.Confirm,Ge.Skip);p(this,"dialogCaption");p(this,"playerNameTextInput");p(this,"lost");p(this,"highScore");p(this,"missionStats");this.lost=n,this.highScore=new gi(e),this.missionStats=i}generate(){super.generate(),this.dialogCaption=new W({text:this.lost?"You lost!":"You won!",style:new N({fill:16777215,fontSize:36,stroke:{color:0,width:2},dropShadow:{color:0,blur:8,distance:0}})}),this.dialogCaption.anchor.set(.5,.5),this.dialogCaption.x=this.dialogContainer.width/2,this.dialogCaption.y=50,this.dialogContainer.addChild(this.dialogCaption)}createDialogBackground(){return new yt({texture:M.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new J,i=35,n=this.createText("Mission details:","#fee",!0);e.addChild(n);const r=this.missionStats.getStats(),a=this.getWidth()-this.background.leftWidth-this.background.rightWidth-20,o=[this.createText("HP:"),this.createText("Gold:"),this.createText("Waves Survived:"),this.createText("Gold Earned:"),this.createText("Gold Spent:"),this.createText("----"),this.createText("Score:")],h=[this.createText(r.hp.toString(),"yellow"),this.createText(r.gold.toString(),"yellow"),this.createText(r.wavesSurvived.toString(),"yellow"),this.createText(r.goldEarned.toString(),"yellow"),this.createText(r.goldSpent.toString(),"yellow"),this.createText("----","yellow"),this.createText(r.score.toString(),"yellow")],c=300;for(let u=0;u<o.length;u++)if(o[u].text==="----"){const g=new St,m=n.y+n.height+10+u*i+i/2;g.moveTo(10,m),g.lineTo(a,m),g.stroke({color:"yellow",width:2}),e.addChild(g)}else o[u].x=10,o[u].y=n.y+n.height+10+u*i,e.addChild(o[u]),h[u].x=c,h[u].y=n.y+n.height+10+u*i,e.addChild(h[u]);const l=h[h.length-1].y+i+80,d=this.createText("Enter your name:");return d.y=l,e.addChild(d),this.playerNameTextInput=new Rd(a,Nt.MaximumPlayerNameLength),this.playerNameTextInput.container.y=d.y+d.height+10,e.addChild(this.playerNameTextInput.container),e}close(e){e===Ge.Confirm?this.playerNameTextInput.getText().length==0?Os.show("Please enter your name.",["OK"]):(this.highScore.addScore({playerName:this.playerNameTextInput.getText(),score:this.missionStats.getStats().score,timestamp:Date.now()}),super.close(e)):super.close(e)}createText(e,i="#fff",n=!1){return new W({text:e,style:new N({fill:i,fontSize:24,fontWeight:n?"bold":"normal"})})}getWidth(){return 600}getHeight(){return 800}}const Mt={Retry:"Retry",MainMenu:"Main Menu",NextMission:"Next Mission"};class Ld extends Ci{constructor(e,i,n){super([...i?[Mt.Retry]:[],...n?[Mt.NextMission]:[],Mt.MainMenu],i?Mt.Retry:n?Mt.NextMission:Mt.MainMenu,Mt.MainMenu);p(this,"dialogCaption");p(this,"highScore");this.highScore=new gi(e)}generate(){super.generate(),this.dialogCaption=new W({text:"Highscore",style:new N({fill:16777215,fontSize:36,stroke:{color:0,width:2},dropShadow:{color:0,blur:8,distance:0}})}),this.dialogCaption.anchor.set(.5,.5),this.dialogCaption.x=this.dialogContainer.width/2,this.dialogCaption.y=50,this.dialogContainer.addChild(this.dialogCaption)}createDialogBackground(){return new yt({texture:M.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new J,i=this.createText("Mission: "+this.highScore.missionName,"#fee",!0);e.addChild(i);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,u)=>this.createText((u+1).toString()))],o=[this.createText("Player","#fee",!0),...r.map(d=>this.createText(d.playerName))],h=[this.createText("Score","#fee",!0),...r.map(d=>this.createText(d.score.toString()))],c=a.reduce((d,u)=>Math.max(d,u.width),0)+20,l=c+o.reduce((d,u)=>Math.max(d,u.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=c,o[d].y=n+10+d*n,e.addChild(o[d]),h[d].x=l,h[d].y=n+10+d*n,e.addChild(h[d]);return e}createText(e,i="#fff",n=!1){return new W({text:e,style:new N({fill:i,fontSize:24,fontWeight:n?"bold":"normal"})})}getWidth(){return 600}getHeight(){return 800}}class Dd extends Ci{constructor(){super([]);p(this,"btnMainMenu");p(this,"btnRetry");p(this,"btnContinue");p(this,"_unsubKeypress");this._unsubKeypress=me.onKeyPressed(this.onContinueClick.bind(this))}createContent(){const e=new J;return this.btnMainMenu=new ct(new E(0,0,300,60),"Main Menu",ot.Button01),this.btnMainMenu.onClick=this.onMainMenuClick.bind(this),e.addChild(this.btnMainMenu.container),this.btnRetry=new ct(new E(0,70,300,60),"Retry",ot.Button01),this.btnRetry.onClick=this.onRetryClick.bind(this),e.addChild(this.btnRetry.container),this.btnContinue=new ct(new E(0,140,300,60),"Continue",ot.Button01),this.btnContinue.onClick=this.onContinueClick.bind(this),e.addChild(this.btnContinue.container),e}onMainMenuClick(){this.close(),this._unsubKeypress(),f.GameScene.UnpauseGame(),f.GameScene.destroy(),f.GameMaster.changeScene(new de)}onRetryClick(){const e=f.GameScene.mission.name;this.close(),this._unsubKeypress(),f.GameScene.UnpauseGame(),f.GameScene.destroy(),f.GameMaster.changeScene(new de),f.GameMaster.changeScene(new xe(e)),f.NotificationManager.Notify("Retrying mission.","green")}onContinueClick(){this.close(),f.GameScene.UnpauseGame()}}class xe extends vi{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 St({x:0,y:0,zIndex:120}));p(this,"windowTitle");f.GameScene=this,this.windowTitle=document.title,M.Missions.forEach((i,n)=>{i.name==e&&(this.mission=i,this.missionIndex=n)})}init(){f.latestGemId=0,new yd(this.mission.gameMap,this.missionIndex),new Bd,new wd(this.mission.rounds,this.mission.gameMap.paths),f.Grid.onGridCellClicked=(e,i)=>{f.TowerManager.isPlacingTower&&f.TowerManager.PlayerClickOnGrid(e,i)},f.WaveManager.events.on(ie.CreepSpawned,e=>{f.Grid.addCreep(e),e.events.on(kt.Escaped,()=>{this.onCreepEscaped(e)})}),f.WaveManager.events.on(ie.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(kt.Died,(e,i)=>{this.MissionStats.earnGold(e)}),this.towerPanel=new Td(Nt.SidebarRect),this.sidebar=new Pd(Nt.SidebarRect),this.changeRoundButton=new ct(Nt.ChangeRoundButtonRect,"",ot.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),f.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new Ed(new E(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new $({texture:M.PlayIconTexture,x:this.changeRoundButton.container.width/2,y:this.changeRoundButton.container.height/2,scale:.2}),this.changeRoundButton.buttonIcon.anchor.set(.5,.5),this.changeRoundButton.container.addChild(this.changeRoundButton.buttonIcon)},this.changeRoundButton.CustomButtonLogic(),this.changeRoundButton.onClick=()=>{if(this.playerWon)return this.ReturnToMain();if(this.roundMode==1){this.gameSpeedMultiplier!==1?this.UpdateGameSpeedMultiplier(1):this.UpdateGameSpeedMultiplier(2);return}if(this.isGameOver)return f.NotificationManager.Notify("No more waves.","danger");this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=M.FastForwardIconTexture,this.events.emit(ie.NewWave,`${this.currentRound+1}`))},this.MissionStats=new kd(125,450),this.events.on(Us.TowerPanelSelectGem,(e,i,n)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return f.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,i,n)}),this.pauseButton=new ct(new E(5,5,120,80),"",ot.Button01,!0),this.pauseButton.container.removeFromParent(),this.stage.addChild(this.pauseButton.container),this.pauseButton.CustomButtonLogic=()=>{this.pauseButton.buttonIcon=new $({texture:M.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 Pt,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(f.MouseX,f.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}f.WaveManager.update(e),f.Grid.update(e),f.TowerManager.update(e),this.isWaveManagerFinished&&f.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=M.PlayIconTexture,f.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(f.NotificationManager.Notify("Mission victory!!","reward"),this.changeRoundButton.buttonIcon.texture=M.HomeIconTexture,this.playerWon=!0):(this.OfferPlayerGems(),this.currentRound++)),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowEndgameDialog(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowEndgameDialog(!1))}DarkenScreen(){this.dimGraphics.rect(0,0,f.app.canvas.width,f.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){f.Grid.gridInteractionEnabled=!1,f.GameScene.sidebar.towerTab.resetTint(),f.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new yt({width:380,height:150,texture:M.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:f.app.canvas.width/2-190,y:f.app.canvas.height/2-75}),f.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let i=new W({x:f.app.canvas.width/4,y:f.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}}});f.GameMaster.currentScene.stage.addChildAt(i,0),e.forEach((n,r)=>{let a=new bs(n,!0),o=new Ve(0,f.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=()=>{f.GameScene.tooltip.SetContentGem(a),f.GameScene.tooltip.Show(f.MouseX,f.MouseY)},o.container.onpointerleave=()=>{f.GameScene.tooltip.Hide()},o.onClick=()=>{f.GameScene.tooltip.Hide(),i.destroy(),this.PlayerPickedGem(new bs(n))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(i=>i.destroy()),f.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 Dd().show()}async ShowEndgameDialog(e){await new Fd(this.mission.name,this.MissionStats,e).show();const r=await new Ld(this.mission.name,e,!e&&this.missionIndex+1<M.Missions.length).show();r===Mt.MainMenu?this.ReturnToMain():r===Mt.NextMission?(this.destroy(),f.GameMaster.changeScene(new de),f.GameMaster.changeScene(new xe(M.Missions[this.missionIndex+1].name)),f.NotificationManager.Notify("Loading next mission. Good luck.","green")):r===Mt.Retry&&(this.destroy(),f.GameMaster.changeScene(new de),f.GameMaster.changeScene(new xe(this.mission.name)),f.NotificationManager.Notify("Retrying mission.","green"))}onCreepEscaped(e){this.MissionStats.takeDamage(e.health)}setRoundMode(e){this.roundMode=e,this.roundMode==1?f.WaveManager.start(this.currentRound):f.WaveManager.end()}destroy(){super.destroy(),this.isGameOver=!0,this.destroyTicker=!0,f.GameScene=null}ReturnToMain(){f.GameMaster.changeScene(new de)}UpdateGameSpeedMultiplier(e){this.gameSpeedMultiplier=e,e===1?f.NotificationManager.Notify("Regular speed.","info"):f.NotificationManager.Notify("Fast forward activated.","info")}}class de extends vi{init(){this.addMainBackground();const t=new ct(new E(10,10,300,60),"Back to main",ot.Button01);t.onClick=e=>{f.GameMaster.changeScene(new Ns)},M.Missions.forEach((e,i)=>{const n=new ct(new E(f.app.canvas.width/2-150,400+i*70,300,60),e.name,ot.Button01);n.onClick=r=>{f.GameMaster.changeScene(new xe(e.name))}})}}class Ns extends vi{init(){this.addMainBackground();const t={caption:"New Game",rect:new E(f.app.canvas.width/2-300/2,400+0*70,300,60),texture:ot.Button01},e={caption:"How to play",rect:new E(f.app.canvas.width/2-300/2,400+1*70,300,60),texture:ot.Button01};new E(f.app.canvas.width/2-300/2,400+2*70,300,60),ot.Button01;let i=new W({x:0,y:0,text:"Latest commit: "+f.latestCommit,style:{fill:16777215,fontSize:10,fontWeight:"bold"}});this.stage.addChild(i);const n=new ct(t.rect,t.caption,t.texture,!0);n.onClick=a=>{f.GameMaster.changeScene(new de)};let r=new ct(e.rect,e.caption,e.texture,!0);r.onClick=a=>{f.GameMaster.changeScene(new md)}}}class zd{constructor(){p(this,"finished",!1);p(this,"calledBack",!1);p(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Ud extends zd{constructor(e,i,n,r){super();p(this,"fadeType");p(this,"fadeTime");p(this,"pixiObject");p(this,"ticks",0);this.fadeType=e,this.fadeTime=i,this.pixiObject=n,this.callbackFn=r,e=="in"?this.pixiObject.alpha=0:this.pixiObject.alpha=1}update(e){if(super.update(e),this.pixiObject==null)return this.Finish();this.ticks++,this.fadeType=="in"?this.pixiObject.alpha=this.ticks/this.fadeTime:this.pixiObject.alpha-=1/this.fadeTime,this.ticks>=this.fadeTime&&this.Finish()}}class Wd{constructor(){p(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const i=this.AnimationQueue[e];i.finished?(i.callbackFn(),this.AnimationQueue.splice(e,1)):i.update(t)}}}class Od{constructor(t,e,i,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 W({text:t,style:new N({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:i,y:n,zIndex:100}),this.textObj.anchor.set(.5,.5),f.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class Nd extends $t{constructor(){super();p(this,"notifications",[]);p(this,"ticks",0);this.bb.x=f.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,f.app.stage.addChild(this.container)}Notify(e,i){let n=0,r=this.notifications.length*32;this.notifications.push(new Od(e,i,n,r,this.ticks+180))}update(e){this.ticks++;for(let i=this.notifications.length-1;i>=0;i--){const n=this.notifications[i];if(n.destroyed){this.notifications.splice(i,1);continue}this.ticks>=n.ticksToFadeAway&&!n.animating&&(n.animating=!0,f.AnimationManager.Animate(new Ud("out",300,n.textObj,()=>{n.destroy()})))}}}(async()=>{const s=new Xr;f.app=s,await s.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(s.canvas);function t(){const n=window.innerWidth,r=window.innerHeight,a=n/s.screen.width,o=r/s.screen.height,h=Math.min(a,o),c=Math.round(s.screen.width*h),l=Math.round(s.screen.height*h),d=(n-c)/2,u=(r-l)/2;s.canvas.style.width=`${c}px`,s.canvas.style.height=`${l}px`,s.canvas.style.marginLeft=`${d}px`,s.canvas.style.marginTop=`${u}px`,s.canvas.style.marginRight="0",s.canvas.style.marginBottom="0",s.canvas.style.display="block"}f.latestCommit=await fetch("/latest_commit").then(n=>n.text()),window.addEventListener("resize",t),t(),await M.LoadAssets(),Nt.init(),me.init(),new gd,f.AnimationManager=new Wd,f.NotificationManager=new Nd,globalThis.Engine=f,Pt.shared.add(n=>{f.NotificationManager.update(n.elapsedMS),f.AnimationManager.update(n.elapsedMS)}),s.canvas.addEventListener("pointermove",function(n){f.MouseX=(n.clientX-s.canvas.offsetLeft)/s.canvas.offsetWidth*1920,f.MouseY=(n.clientY-s.canvas.offsetTop)/s.canvas.offsetHeight*1080}),f.GameMaster.changeScene(new Ns),new URLSearchParams(location.href).entries().next().value[1]=="game"&&f.GameMaster.changeScene(new xe("The Turn")),f.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":f.TestSuite();let i=!1;window.addEventListener("blur",()=>{console.log("blur"),f.GameScene&&!f.GameScene.isPaused&&(f.GameScene.PauseGame(),i=!0)}),window.addEventListener("focus",()=>{console.log("focus"),f.GameScene&&i&&f.GameScene.isPaused&&(i=!1,f.GameScene.UnpauseGame())})})();export{U as $,Nr as A,it as B,J as C,Q as D,k as E,lr as F,yi as G,Gt as H,ln as I,$ as J,Xo as K,eh as L,H as M,nt as N,E as O,ht as P,_h as Q,os as R,Uh as S,zt as T,ui as U,dn as V,To as W,Fi as X,Z as Y,dr as Z,Hr as _,z as a,O as a0,Ch as a1,ta as a2,ll as a3,dl as a4,ml as a5,yl as a6,_l as a7,fe as a8,N as a9,lc as aa,_s as ab,aa as ac,bn as ad,ae,dd as af,Vn as ag,gc as ah,St as ai,j as aj,Qa as ak,ys as al,Hn as am,ha as an,Pt as b,ft as c,Ot as d,lt as e,wn as f,Lh as g,hi as h,As as i,Ur as j,br as k,Fr as l,Nn as m,Ks as n,hl as o,cl as p,pl as q,co as r,qr as s,xl as t,Ms as u,Ir as v,st as w,Za as x,bl as y,Lt as z};