297 lines
306 KiB
JavaScript
297 lines
306 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-Eg6uxDeY.js","assets/webworkerAll-DEamYlci.js","assets/colorToUniform-DwU_M1hs.js","assets/WebGPURenderer-DokXFXmq.js","assets/SharedSystems-DiuMoF5l.js","assets/WebGLRenderer-DUH4HgYd.js"])))=>i.map(i=>d[i]);
|
|
var Ta=Object.defineProperty;var Ca=(i,t,e)=>t in i?Ta(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var x=(i,t,e)=>Ca(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();const Ma="modulepreload",Pa=function(i){return"/"+i},Fs={},ei=function(t,e,s){let r=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"));r=Promise.allSettled(e.map(h=>{if(h=Pa(h),h in Fs)return;Fs[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":Ma,c||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((u,f)=>{d.addEventListener("load",u),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return t().catch(n)})};var P=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(P||{});const Ui=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},We=(i,t)=>Ui(i).priority??t,ht={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Ui).forEach(t=>{t.type.forEach(e=>{var s,r;return(r=(s=this._removeHandlers)[e])==null?void 0:r.call(s,t)})}),this},add(...i){return i.map(Ui).forEach(t=>{t.type.forEach(e=>{var n,a;const s=this._addHandlers,r=this._queue;s[e]?(a=s[e])==null||a.call(s,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(i,t,e){var a;const s=this._addHandlers,r=this._removeHandlers;if(s[i]||r[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,r[i]=e;const n=this._queue;return n[i]&&((a=n[i])==null||a.forEach(o=>t(o)),delete n[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(n=>n.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((n,a)=>We(a.value,e)-We(n.value,e)))},s=>{const r=t.findIndex(n=>n.name===s.name);r!==-1&&t.splice(r,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((r,n)=>We(n,e)-We(r,e)))},s=>{const r=t.indexOf(s.ref);r!==-1&&t.splice(r,1)})}},ka={extension:{type:P.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ei(()=>import("./browserAll-Eg6uxDeY.js"),__vite__mapDeps([0,1,2]))}},Ga={extension:{type:P.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ei(()=>import("./webworkerAll-DEamYlci.js"),__vite__mapDeps([1,2]))}};class lt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new lt(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 cs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Or={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,d,u){if(typeof l!="function")throw new TypeError("The listener must be a function");var f=new r(l,d||h,u),p=e?e+c:c;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,c){--h._eventsCount===0?h._events=new s:delete h._events[c]}function o(){this._events=new s,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,f=d.length,p=new Array(f);u<f;u++)p[u]=d[u].fn;return p},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,f,p){var y=e?e+c:c;if(!this._events[y])return!1;var g=this._events[y],_=arguments.length,w,b;if(g.fn){switch(g.once&&this.removeListener(c,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,l),!0;case 3:return g.fn.call(g.context,l,d),!0;case 4:return g.fn.call(g.context,l,d,u),!0;case 5:return g.fn.call(g.context,l,d,u,f),!0;case 6:return g.fn.call(g.context,l,d,u,f,p),!0}for(b=1,w=new Array(_-1);b<_;b++)w[b-1]=arguments[b];g.fn.apply(g.context,w)}else{var S=g.length,T;for(b=0;b<S;b++)switch(g[b].once&&this.removeListener(c,g[b].fn,void 0,!0),_){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,l);break;case 3:g[b].fn.call(g[b].context,l,d);break;case 4:g[b].fn.call(g[b].context,l,d,u);break;default:if(!w)for(T=1,w=new Array(_-1);T<_;T++)w[T-1]=arguments[T];g[b].fn.apply(g[b].context,w)}}return!0},o.prototype.on=function(c,l,d){return n(this,c,l,d,!1)},o.prototype.once=function(c,l,d){return n(this,c,l,d,!0)},o.prototype.removeListener=function(c,l,d,u){var f=e?e+c:c;if(!this._events[f])return this;if(!l)return a(this,f),this;var p=this._events[f];if(p.fn)p.fn===l&&(!u||p.once)&&(!d||p.context===d)&&a(this,f);else{for(var y=0,g=[],_=p.length;y<_;y++)(p[y].fn!==l||u&&!p[y].once||d&&p[y].context!==d)&&g.push(p[y]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}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 s,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,i.exports=o})(Or);var Ia=Or.exports;const ct=cs(Ia),Ba=Math.PI*2,Ea=180/Math.PI,Fa=Math.PI/180;class ot{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ot(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 pi.x=0,pi.y=0,pi}}const pi=new ot;class U{constructor(t=1,e=0,s=0,r=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=r,this.tx=n,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,r,n,a){return this.a=t,this.b=e,this.c=s,this.d=r,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new ot;const s=t.x,r=t.y;return e.x=this.a*s+this.c*r+this.tx,e.y=this.b*s+this.d*r+this.ty,e}applyInverse(t,e){e=e||new ot;const s=this.a,r=this.b,n=this.c,a=this.d,o=this.tx,h=this.ty,c=1/(s*a+n*-r),l=t.x,d=t.y;return e.x=a*c*l+-n*c*d+(h*n-o*a)*c,e.y=s*c*d+-r*c*l+(-h*s+o*r)*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),s=Math.sin(t),r=this.a,n=this.c,a=this.tx;return this.a=r*e-this.b*s,this.b=r*s+this.b*e,this.c=n*e-this.d*s,this.d=n*s+this.d*e,this.tx=a*e-this.ty*s,this.ty=a*s+this.ty*e,this}append(t){const e=this.a,s=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*s+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*s+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*s+t.ty*n+this.ty,this}appendFrom(t,e){const s=t.a,r=t.b,n=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=s*c+r*d,this.b=s*l+r*u,this.c=n*c+a*d,this.d=n*l+a*u,this.tx=o*c+h*d+e.tx,this.ty=o*l+h*u+e.ty,this}setTransform(t,e,s,r,n,a,o,h,c){return this.a=Math.cos(o+c)*n,this.b=Math.sin(o+c)*n,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(s*this.a+r*this.c),this.ty=e-(s*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,r=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,r=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-r,n),h=Math.atan2(s,e),c=Math.abs(o+h);return c<1e-5||Math.abs(Ba-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+s*s),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(a.x*e+a.y*r),t.position.y=this.ty+(a.x*s+a.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,r=this.d,n=this.tx,a=t*r-e*s;return this.a=r/a,this.b=-e/a,this.c=-s/a,this.d=t/a,this.tx=(s*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/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 U;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 La.identity()}static get shared(){return Ra.identity()}}const Ra=new U,La=new U,$t=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Vt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Xt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Yt=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Hi=[],Wr=[],Ue=Math.sign;function za(){for(let i=0;i<16;i++){const t=[];Hi.push(t);for(let e=0;e<16;e++){const s=Ue($t[i]*$t[e]+Xt[i]*Vt[e]),r=Ue(Vt[i]*$t[e]+Yt[i]*Vt[e]),n=Ue($t[i]*Xt[e]+Xt[i]*Yt[e]),a=Ue(Vt[i]*Xt[e]+Yt[i]*Yt[e]);for(let o=0;o<16;o++)if($t[o]===s&&Vt[o]===r&&Xt[o]===n&&Yt[o]===a){t.push(o);break}}}for(let i=0;i<16;i++){const t=new U;t.set($t[i],Vt[i],Xt[i],Yt[i],0,0),Wr.push(t)}}za();const $={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>$t[i],uY:i=>Vt[i],vX:i=>Xt[i],vY:i=>Yt[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Hi[i][t],sub:(i,t)=>Hi[i][$.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?$.S:$.N:Math.abs(t)*2<=Math.abs(i)?i>0?$.E:$.W:t>0?i>0?$.SE:$.SW:i>0?$.NE:$.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const r=Wr[$.inv(t)];r.tx=e,r.ty=s,i.append(r)}},He=[new ot,new ot,new ot,new ot];class O{constructor(t=0,e=0,s=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(r)}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 O(0,0,0,0)}clone(){return new O(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,s){const{width:r,height:n}=this;if(r<=0||n<=0)return!1;const a=this.x,o=this.y,h=a-s/2,c=a+r+s/2,l=o-s/2,d=o+n+s/2,u=a+s/2,f=a+r-s/2,p=o+s/2,y=o+n-s/2;return t>=h&&t<=c&&e>=l&&e<=d&&!(t>u&&t<f&&e>p&&e<y)}intersects(t,e){if(!e){const k=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=k)return!1;const A=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>A}const s=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=s||a<=n)return!1;const o=He[0].set(t.left,t.top),h=He[1].set(t.left,t.bottom),c=He[2].set(t.right,t.top),l=He[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)<=s||Math.min(o.x,h.x,c.x,l.x)>=r||Math.max(o.y,h.y,c.y,l.y)<=n||Math.min(o.y,h.y,c.y,l.y)>=a))return!1;const u=d*(h.y-o.y),f=d*(o.x-h.x),p=u*s+f*n,y=u*r+f*n,g=u*s+f*a,_=u*r+f*a;if(Math.max(p,y,g,_)<=u*o.x+f*o.y||Math.min(p,y,g,_)>=u*l.x+f*l.y)return!1;const w=d*(o.y-c.y),b=d*(c.x-o.x),S=w*s+b*n,T=w*r+b*n,B=w*s+b*a,M=w*r+b*a;return!(Math.max(S,T,B,M)<=w*o.x+b*o.y||Math.min(S,T,B,M)>=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),s=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=r,this.height=n-r,this}getBounds(t){return t=t||new O,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 it(i="default"){return mi[i]===void 0&&(mi[i]=-1),++mi[i]}const Rs={},W="8.0.0",Da="8.3.4";function D(i,t,e=3){if(Rs[t])return;let s=new Error().stack;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
Deprecated since v${i}`):(s=s.split(`
|
|
`).splice(e).join(`
|
|
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
|
|
Deprecated since v${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
Deprecated since v${i}`),console.warn(s))),Rs[t]=!0}const Ur=()=>{};function Ls(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function zs(i){return!(i&i-1)&&!!i}function Oa(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const Ds=Object.create(null);function Wa(i){const t=Ds[i];return t===void 0&&(Ds[i]=it("resource")),t}const Hr=class Nr extends ct{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Nr.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){D(W,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Wa(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Hr.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Ua=Hr;const $r=class Vr extends ct{constructor(t={}){super(),this.options=t,this.uid=it("textureSource"),this._resourceType="textureSource",this._resourceId=it("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={...Vr.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 Ua(Oa(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=it("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*s),n=Math.round(e*s);return this.width=r/s,this.height=n/s,this._resolution=s,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=it("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")}};$r.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Gt=$r;class ds extends Gt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}ds.extension=P.TextureSource;const Os=new U;class Ha{constructor(t,e){this.mapCoord=new U,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],a=t[r+1];e[r]=n*s.a+a*s.c+s.tx,e[r+1]=n*s.b+a*s.d+s.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const s=t.orig,r=t.trim;r&&(Os.set(s.width/r.width,0,0,s.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(Os));const n=t.source,a=this.uClampFrame,o=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return a[0]=(t.frame.x+o+h)/n.width,a[1]=(t.frame.y+o+h)/n.height,a[2]=(t.frame.x+t.frame.width-o+h)/n.width,a[3]=(t.frame.y+t.frame.height-o+h)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class L extends ct{constructor({source:t,label:e,frame:s,orig:r,trim:n,defaultAnchor:a,defaultBorders:o,rotate:h,dynamic:c}={}){if(super(),this.uid=it("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new O,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new Gt,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:l,height:d}=this._source;this.frame.width=l,this.frame.height=d}this.orig=r||this.frame,this.trim=n,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 Ha(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:s,height:r}=this._source,n=e.x/s,a=e.y/r,o=e.width/s,h=e.height/r;let c=this.rotate;if(c){const l=o/2,d=h/2,u=n+l,f=a+d;c=$.add(c,$.NW),t.x0=u+l*$.uX(c),t.y0=f+d*$.uY(c),c=$.add(c,2),t.x1=u+l*$.uX(c),t.y1=f+d*$.uY(c),c=$.add(c,2),t.x2=u+l*$.uX(c),t.y2=f+d*$.uY(c),c=$.add(c,2),t.x3=u+l*$.uX(c),t.y3=f+d*$.uY(c)}else t.x0=n,t.y0=a,t.x1=n+o,t.y1=a,t.x2=n+o,t.y2=a+h,t.x3=n,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 D(W,"Texture.baseTexture is now Texture.source"),this._source}}L.EMPTY=new L({label:"EMPTY",source:new Gt({label:"EMPTY"})});L.EMPTY.destroy=Ur;L.WHITE=new L({source:new ds({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});L.WHITE.destroy=Ur;function Na(i,t,e,s){const{width:r,height:n}=e.orig,a=e.trim;if(a){const o=a.width,h=a.height;i.minX=a.x-t._x*r-s,i.maxX=i.minX+o,i.minY=a.y-t._y*n-s,i.maxY=i.minY+h}else i.minX=-t._x*r-s,i.maxX=i.minX+r,i.minY=-t._y*n-s,i.maxY=i.minY+n}const Ws=new U;class vt{constructor(t=1/0,e=1/0,s=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Ws,this.minX=t,this.minY=e,this.maxX=s,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new O);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=Ws,this}set(t,e,s,r){this.minX=t,this.minY=e,this.maxX=s,this.maxY=r}addFrame(t,e,s,r,n){n||(n=this.matrix);const a=n.a,o=n.b,h=n.c,c=n.d,l=n.tx,d=n.ty;let u=this.minX,f=this.minY,p=this.maxX,y=this.maxY,g=a*t+h*e+l,_=o*t+c*e+d;g<u&&(u=g),_<f&&(f=_),g>p&&(p=g),_>y&&(y=_),g=a*s+h*e+l,_=o*s+c*e+d,g<u&&(u=g),_<f&&(f=_),g>p&&(p=g),_>y&&(y=_),g=a*t+h*r+l,_=o*t+c*r+d,g<u&&(u=g),_<f&&(f=_),g>p&&(p=g),_>y&&(y=_),g=a*s+h*r+l,_=o*s+c*r+d,g<u&&(u=g),_<f&&(f=_),g>p&&(p=g),_>y&&(y=_),this.minX=u,this.minY=f,this.maxX=p,this.maxY=y}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,s=this.minY,r=this.maxX,n=this.maxY,{a,b:o,c:h,d:c,tx:l,ty:d}=t;let u=a*e+h*s+l,f=o*e+c*s+d;this.minX=u,this.minY=f,this.maxX=u,this.maxY=f,u=a*r+h*s+l,f=o*r+c*s+d,this.minX=u<this.minX?u:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY,u=a*e+h*n+l,f=o*e+c*n+d,this.minX=u<this.minX?u:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY,u=a*r+h*n+l,f=o*r+c*n+d,this.minX=u<this.minX?u:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,r){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<s&&(this.minY=s),this.maxY>r&&(this.maxY=r),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 vt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,r){let n=this.minX,a=this.minY,o=this.maxX,h=this.maxY;r||(r=this.matrix);const c=r.a,l=r.b,d=r.c,u=r.d,f=r.tx,p=r.ty;for(let y=e;y<s;y+=2){const g=t[y],_=t[y+1],w=c*g+d*_+f,b=l*g+u*_+p;n=w<n?w:n,a=b<a?b:a,o=w>o?w:o,h=b>h?b:h}this.minX=n,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 $a={grad:.9,turn:360,rad:360/(2*Math.PI)},Tt=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},rt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},pt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},Xr=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},Us=function(i){return{r:pt(i.r,0,255),g:pt(i.g,0,255),b:pt(i.b,0,255),a:pt(i.a)}},gi=function(i){return{r:rt(i.r),g:rt(i.g),b:rt(i.b),a:rt(i.a,3)}},Va=/^#([0-9a-f]{3,8})$/i,Ne=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},Yr=function(i){var t=i.r,e=i.g,s=i.b,r=i.a,n=Math.max(t,e,s),a=n-Math.min(t,e,s),o=a?n===t?(e-s)/a:n===e?2+(s-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},jr=function(i){var t=i.h,e=i.s,s=i.v,r=i.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),a=s*(1-e),o=s*(1-(t-n)*e),h=s*(1-(1-t+n)*e),c=n%6;return{r:255*[s,o,a,a,h,s][c],g:255*[h,s,s,o,a,a][c],b:255*[a,a,h,s,s,o][c],a:r}},Hs=function(i){return{h:Xr(i.h),s:pt(i.s,0,100),l:pt(i.l,0,100),a:pt(i.a)}},Ns=function(i){return{h:rt(i.h),s:rt(i.s),l:rt(i.l),a:rt(i.a,3)}},$s=function(i){return jr((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Ce=function(i){return{h:(t=Yr(i)).h,s:(r=(200-(e=t.s))*(s=t.v)/100)>0&&r<200?e*s/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,s,r},Xa=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ya=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ja=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qa=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ni={string:[[function(i){var t=Va.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?rt(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?rt(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=ja.exec(i)||qa.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:Us({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=Xa.exec(i)||Ya.exec(i);if(!t)return null;var e,s,r=Hs({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*($a[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return $s(r)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,r=i.a,n=r===void 0?1:r;return Tt(t)&&Tt(e)&&Tt(s)?Us({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,r=i.a,n=r===void 0?1:r;if(!Tt(t)||!Tt(e)||!Tt(s))return null;var a=Hs({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return $s(a)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,r=i.a,n=r===void 0?1:r;if(!Tt(t)||!Tt(e)||!Tt(s))return null;var a=function(o){return{h:Xr(o.h),s:pt(o.s,0,100),v:pt(o.v,0,100),a:pt(o.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return jr(a)},"hsv"]]},Vs=function(i,t){for(var e=0;e<t.length;e++){var s=t[e][0](i);if(s)return[s,t[e][1]]}return[null,void 0]},Ka=function(i){return typeof i=="string"?Vs(i.trim(),Ni.string):typeof i=="object"&&i!==null?Vs(i,Ni.object):[null,void 0]},xi=function(i,t){var e=Ce(i);return{h:e.h,s:pt(e.s+100*t,0,100),l:e.l,a:e.a}},yi=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},Xs=function(i,t){var e=Ce(i);return{h:e.h,s:e.s,l:pt(e.l+100*t,0,100),a:e.a}},$i=function(){function i(t){this.parsed=Ka(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return i.prototype.isValid=function(){return this.parsed!==null},i.prototype.brightness=function(){return rt(yi(this.rgba),2)},i.prototype.isDark=function(){return yi(this.rgba)<.5},i.prototype.isLight=function(){return yi(this.rgba)>=.5},i.prototype.toHex=function(){return t=gi(this.rgba),e=t.r,s=t.g,r=t.b,a=(n=t.a)<1?Ne(rt(255*n)):"","#"+Ne(e)+Ne(s)+Ne(r)+a;var t,e,s,r,n,a},i.prototype.toRgb=function(){return gi(this.rgba)},i.prototype.toRgbString=function(){return t=gi(this.rgba),e=t.r,s=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+r+", "+n+")":"rgb("+e+", "+s+", "+r+")";var t,e,s,r,n},i.prototype.toHsl=function(){return Ns(Ce(this.rgba))},i.prototype.toHslString=function(){return t=Ns(Ce(this.rgba)),e=t.h,s=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+r+"%, "+n+")":"hsl("+e+", "+s+"%, "+r+"%)";var t,e,s,r,n},i.prototype.toHsv=function(){return t=Yr(this.rgba),{h:rt(t.h),s:rt(t.s),v:rt(t.v),a:rt(t.a,3)};var t},i.prototype.invert=function(){return _t({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),_t(xi(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),_t(xi(this.rgba,-t))},i.prototype.grayscale=function(){return _t(xi(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),_t(Xs(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),_t(Xs(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?_t({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):rt(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Ce(this.rgba);return typeof t=="number"?_t({h:t,s:e.s,l:e.l,a:e.a}):rt(e.h)},i.prototype.isEqual=function(t){return this.toHex()===_t(t).toHex()},i}(),_t=function(i){return i instanceof $i?i:new $i(i)},Ys=[],Za=function(i){i.forEach(function(t){Ys.indexOf(t)<0&&(t($i,Ni),Ys.push(t))})};function Qa(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var r in e)s[e[r]]=r;var n={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=s[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),d=1/0,u="black";if(!n.length)for(var f in e)n[f]=new i(e[f]).toRgb();for(var p in e){var y=(o=l,h=n[p],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=p)}return u}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new i(h).toRgb():null},"name"])}Za([Qa]);const ae=class Se{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 Se)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((n,a)=>n===e[a]);if(t!==null&&e!==null){const n=Object.keys(t),a=Object.keys(e);return n.length!==a.length?!1:n.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,r]=this._components;return{r:t,g:e,b:s,a:r}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,r,n]=this._components;return t[0]=e,t[1]=s,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,r]=this._components;return t[0]=e,t[1]=s,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,r,n]=Se._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,s=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,r,n=255]=t,e/=255,s/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=Se.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=_t(t);a.isValid()&&({r:e,g:s,b:r,a:n}=a.rgba,e/=255,s/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Se||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}};ae.shared=new ae;ae._temp=new ae;ae.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let J=ae;const Ja={cullArea:null,cullable:!1,cullableChildren:!0};class us{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var s;let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class to{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 us(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const Mt=new to;function eo(i,t,e){const s=i.length;let r;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(r=t;r<n;++r)i[r]=i[r+e];i.length=n}const io={allowChildren:!0,removeChildren(i=0,t){const e=t??this.children.length,s=e-i,r=[];if(s>0&&s<=e){for(let a=e-1;a>=i;a--){const o=this.children[a];o&&(r.push(o),o.parent=null)}eo(this.children,i,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let a=0;a<r.length;++a)this.emit("childRemoved",r[a],this,a),r[a].emit("removed",this);return r}else if(s===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const t=this.getChildAt(i);return this.removeChild(t)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||D(W,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(i.parent){const r=i.parent.children.indexOf(i);if(i.parent===this&&r===t)return i;r!==-1&&i.parent.children.splice(r,1)}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,t),i.emit("added",this),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var i;(i=this.parent)==null||i.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i}};class js{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 so{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const s=this._tests[e];if(s.test(t))return Mt.get(s.maskClass,t)}return t}returnMaskEffect(t){Mt.return(t)}}const Vi=new so;ht.handleByList(P.MaskEffect,Vi._effectClasses);const ro={_maskEffect:null,_filterEffect:null,effects:[],addEffect(i){if(this.effects.indexOf(i)!==-1)return;this.effects.push(i),this.effects.sort((s,r)=>s.priority-r.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const t=this._maskEffect;(t==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),Vi.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=Vi.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},set filters(i){var n;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new js);i=i;const e=(i==null?void 0:i.length)>0,s=((n=t.filters)==null?void 0:n.length)>0,r=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new js),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},no={label:null,get name(){return D(W,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){D(W,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s<e.length;s++){const r=e[s];if(r.label===i||i instanceof RegExp&&i.test(r.label))return r}if(t)for(let s=0;s<e.length;s++){const n=e[s].getChildByLabel(i,!0);if(n)return n}return null},getChildrenByLabel(i,t=!1,e=[]){const s=this.children;for(let r=0;r<s.length;r++){const n=s[r];(n.label===i||i instanceof RegExp&&i.test(n.label))&&e.push(n)}if(t)for(let r=0;r<s.length;r++)s[r].getChildrenByLabel(i,!0,e);return e}},Pt=new us(U),oe=new us(vt);function qr(i,t,e){e.clear();let s,r;return i.parent?t?s=i.parent.worldTransform:(r=Pt.get().identity(),s=ii(i,r)):s=U.IDENTITY,Kr(i,e,s,t),r&&Pt.return(r),e.isValid||e.set(0,0,0,0),e}function Kr(i,t,e,s){var o,h;if(!i.visible||!i.measurable)return;let r;s?r=i.worldTransform:(i.updateLocalTransform(),r=Pt.get(),r.appendFrom(i.localTransform,e));const n=t,a=!!i.effects.length;if(a&&(t=oe.get().clear()),i.boundsArea)t.addRect(i.boundsArea,r);else{i.addBounds&&(t.matrix=r,i.addBounds(t));for(let c=0;c<i.children.length;c++)Kr(i.children[c],t,r,s)}if(a){for(let c=0;c<i.effects.length;c++)(h=(o=i.effects[c]).addBounds)==null||h.call(o,t);n.addBounds(t,U.IDENTITY),oe.return(t)}s||Pt.return(r)}function ii(i,t){const e=i.parent;return e&&(ii(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}let _i=0;const qs=500;function tt(...i){_i!==qs&&(_i++,_i===qs?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}function Zr(i,t,e){return t.clear(),e||(e=U.IDENTITY),Qr(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function Qr(i,t,e,s,r){var h,c;let n;if(r)n=Pt.get(),n=e.copyTo(n);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const l=i.localTransform;n=Pt.get(),n.appendFrom(l,e)}const a=t,o=!!i.effects.length;if(o&&(t=oe.get().clear()),i.boundsArea)t.addRect(i.boundsArea,n);else{i.renderPipeId&&(t.matrix=n,i.addBounds(t));const l=i.children;for(let d=0;d<l.length;d++)Qr(l[d],t,n,s,!1)}if(o){for(let l=0;l<i.effects.length;l++)(c=(h=i.effects[l]).addLocalBounds)==null||c.call(h,t,s);a.addBounds(t,U.IDENTITY),oe.return(t)}Pt.return(n)}function Jr(i,t){const e=i.children;for(let s=0;s<e.length;s++){const r=e[s],n=r.uid,a=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,o=t.index;(t.data[o]!==n||t.data[o+1]!==a)&&(t.data[t.index]=n,t.data[t.index+1]=a,t.didChange=!0),t.index=o+2,r.children.length&&Jr(r,t)}return t.didChange}const ao=new U,oo={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=i/t*e:this.scale.x=e},_setHeight(i,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=i/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new vt});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),Jr(this,i),i.didChange&&Zr(this,i.localBounds,ao),i.localBounds},getBounds(i,t){return qr(this,i,t||new vt)}},ho={_onRender:null,set onRender(i){const t=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},lo={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(co))}};function co(i,t){return i._zIndex-t._zIndex}const uo={getGlobalPosition(i=new ot,t=!1){return this.parent?this.parent.toGlobal(this._position,i,t):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,t,e=!1){if(!e){this.updateLocalTransform();const s=ii(this,new U);return s.append(this.localTransform),s.apply(i,t)}return this.worldTransform.apply(i,t)},toLocal(i,t,e,s){if(t&&(i=t.toGlobal(i,e,s)),!s){this.updateLocalTransform();const r=ii(this,new U);return r.append(this.localTransform),r.applyInverse(i,e)}return this.worldTransform.applyInverse(i,e)}};let fo=0;class tn{constructor(){this.uid=it("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.tick=0}reset(){this.instructionSize=0,this.tick=fo++}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class po{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new U,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 tn,this._onRenderContainers=[]}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let s=0;s<e.length;s++)this.removeChild(e[s])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(t.didViewUpdate=!1,this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t))}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender()}destroy(){this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let s=0;s<e.length;s++)this._getChildren(e[s],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const s=t.children;for(let r=0;r<s.length;r++)this._getChildren(s[r],e);return e}}function mo(i,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(i[s]=t[s])}const wi=new lt(null),bi=new lt(null),Si=new lt(null,1,1),Ks=1,go=2,vi=4;class at extends ct{constructor(t={}){var e,s;super(),this.uid=it("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 U,this.relativeGroupTransform=new U,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new lt(this,0,0),this._scale=Si,this._pivot=bi,this._skew=wi,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=[],mo(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(r=>this.addChild(r)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(at.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||D(W,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r<t.length;r++)this.addChild(t[r]);return t[0]}const e=t[0];if(e.parent===this)return this.children.splice(this.children.indexOf(e),1),this.children.push(e),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),e;e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e.didViewUpdate=!1,e._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e}removeChild(...t){if(t.length>1){for(let r=0;r<t.length;r++)this.removeChild(t[r]);return t[0]}const e=t[0],s=this.children.indexOf(e);return s>-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=Mt.get(po,this),this.groupTransform=U.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Mt.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 U),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*Ea}set angle(t){this.rotation=t*Fa}get pivot(){return this._pivot===bi&&(this._pivot=new lt(this,0,0)),this._pivot}set pivot(t){this._pivot===bi&&(this._pivot=new lt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===wi&&(this._skew=new lt(this,0,0)),this._skew}set skew(t){this._skew===wi&&(this._skew=new lt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Si&&(this._scale=new lt(this,1,1)),this._scale}set scale(t){this._scale===Si&&(this._scale=new lt(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,r=this._pivot,n=this._position,a=s._x,o=s._y,h=r._x,c=r._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=n._x-(h*e.a+c*e.c),e.ty=n._y-(h*e.b+c*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Ks,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=J.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=Ks,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|=go,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|=vi,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|=vi,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|=vi,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var r;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 n=0;n<e.length;++n)e[n].destroy(t);(r=this.renderGroup)==null||r.destroy(),this.renderGroup=null}}at.mixin(io);at.mixin(uo);at.mixin(ho);at.mixin(oo);at.mixin(ro);at.mixin(no);at.mixin(lo);at.mixin(Ja);class ai extends at{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=0,this._lastInstructionTick=-1,this._bounds=new vt(0,1,0,0),this._boundsDirty=!0}_updateBounds(){}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:s,y:r}=t;return s>=e.minX&&s<=e.maxX&&r>=e.minY&&r<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class Y extends ai{constructor(t=L.EMPTY){t instanceof L&&(t={texture:t});const{texture:e=L.EMPTY,anchor:s,roundPixels:r,width:n,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 lt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof L?new Y(t):new Y(L.from(t,e))}set texture(t){t||(t=L.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(){Na(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:r,height:n}=e.orig;s.maxX=-t._x*r,s.minX=s.maxX+r,s.maxY=-t._y*n,s.minY=s.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const xo=new vt;function en(i,t,e){const s=xo;i.measurable=!0,qr(i,e,s),t.addBoundsMask(s),i.measurable=!1}function sn(i,t,e){const s=oe.get();i.measurable=!0;const r=Pt.get().identity(),n=rn(i,e,r);Zr(i,s,n),i.measurable=!1,t.addBoundsMask(s),Pt.return(r),oe.return(s)}function rn(i,t,e){return i?(i!==t&&(rn(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(tt("Mask bounds, renderable is not inside the root container"),e)}class nn{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 Y),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){en(this.mask,t,e)}addLocalBounds(t,e){sn(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Y}}nn.extension=P.MaskEffect;class an{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"}}an.extension=P.MaskEffect;class on{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){en(this.mask,t,e)}addLocalBounds(t,e){sn(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof at}}on.extension=P.MaskEffect;const yo={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let Zs=yo;const q={get(){return Zs},set(i){Zs=i}};class hn extends Gt{constructor(t){t.resource||(t.resource=q.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const r=super.resize(t,e,s);return r&&this.resizeCanvas(),r}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"))}}hn.extension=P.TextureSource;class ce extends Gt{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,tt("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ce.extension=P.TextureSource;var si=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(si||{});class Ai{constructor(t,e=null,s=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=r}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 ln=class dt{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 Ai(null,null,1/0),this.deltaMS=1/dt.targetFPMS,this.elapsedMS=1/dt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=si.NORMAL){return this._addListener(new Ai(t,e,s))}addOnce(t,e,s=si.NORMAL){return this._addListener(new Ai(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*dt.targetFPMS;const s=this._head;let r=s.next;for(;r;)r=r.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),s=Math.min(Math.max(0,e)/1e3,dt.targetFPMS);this._maxElapsedMS=1/s}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!dt._shared){const t=dt._shared=new dt;t.autoStart=!0,t._protected=!0}return dt._shared}static get system(){if(!dt._system){const t=dt._system=new dt;t.autoStart=!0,t._protected=!0}return dt._system}};ln.targetFPMS=.06;let bt=ln,Ti;async function cn(){return Ti??(Ti=(async()=>{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(s),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Ti}const oi=class dn extends Gt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...dn.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=bt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await cn(),this._load=new Promise((s,r)=>{this.isValid?s(this):(this._resolve=s,this._reject=r,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(bt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(bt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(bt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};oi.extension=P.TextureSource;oi.defaultOptions={...Gt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};oi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Qe=oi;const xt=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class _o{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||tt(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=xt(t);let r;for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];if(c.test(e)){r=c.getCacheableAssets(s,e);break}}const n=new Map(Object.entries(r||{}));r||s.forEach(h=>{n.set(h,e)});const a=[...n.keys()],o={cacheKeys:a,keys:s};s.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const c=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==c&&tt("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){tt(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const V=new _o,Xi=[];ht.handleByList(P.TextureSource,Xi);function un(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let r=0;r<Xi.length;r++){const n=Xi[r];if(n.test(e))return new n(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function wo(i={},t=!1){const e=i&&i.resource,s=e?i.resource:i,r=e?i:{resource:i};if(!t&&V.has(s))return V.get(s);const n=new L({source:un(r)});return n.on("destroy",()=>{V.has(s)&&V.remove(s)}),t||V.set(s,n),n}function bo(i,t=!1){return typeof i=="string"?V.get(i):i instanceof Gt?new L({source:i}):wo(i,t)}L.from=bo;Gt.from=un;ht.add(nn,an,on,Qe,ce,hn,ds);var Rt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Rt||{});function gt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function ye(i){return i.split("?")[0].split("#")[0]}function So(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vo(i,t,e){return i.replace(new RegExp(So(t),"g"),e)}function Ao(i,t){let e="",s=0,r=-1,n=0,a=-1;for(let o=0;o<=i.length;++o){if(o<i.length)a=i.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||n===1))if(r!==o-1&&n===2){if(e.length<2||s!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,r=o,n=0;continue}}}else e.length>0?e+=`/${i.slice(r+1,o)}`:e=i.slice(r+1,o),s=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const ut={toPosix(i){return vo(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){gt(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(gt(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=ye(this.toPosix(t??q.get().getBaseUrl())),r=ye(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?ut.join(r,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(gt(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=Ao(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return gt(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e<i.length;++e){const s=i[e];if(gt(s),s.length>0)if(t===void 0)t=s;else{const r=i[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(gt(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,r=!0;const n=this.getProtocol(i),a=i;i=i.slice(n.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!r){s=o;break}}else r=!1;return s===-1?e?"/":this.isUrl(a)?n+i:n:e&&s===1?"//":n+i.slice(0,s)},rootname(i){gt(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){gt(i),t&>(t),i=ye(this.toPosix(i));let e=0,s=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let a=t.length-1,o=-1;for(n=i.length-1;n>=0;--n){const h=i.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(s=n):(a=-1,s=o))}return e===s?s=o:s===-1&&(s=i.length),i.slice(e,s)}for(n=i.length-1;n>=0;--n)if(i.charCodeAt(n)===47){if(!r){e=n+1;break}}else s===-1&&(r=!1,s=n+1);return s===-1?"":i.slice(e,s)},extname(i){gt(i),i=ye(this.toPosix(i));let t=-1,e=0,s=-1,r=!0,n=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}s===-1&&(r=!1,s=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){gt(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=ye(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let r;t.root=this.rootname(i),s||this.hasProtocol(i)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,c=i.length-1,l=0;for(;c>=r;--c){if(e=i.charCodeAt(c),e===47){if(!h){a=c+1;break}continue}o===-1&&(h=!1,o=c+1),e===46?n===-1?n=c:l!==1&&(l=1):n!==-1&&(l=-1)}return n===-1||o===-1||l===0||l===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&s?t.base=t.name=i.slice(1,o):t.base=t.name=i.slice(a,o)):(a===0&&s?(t.name=i.slice(1,n),t.base=i.slice(1,o)):(t.name=i.slice(a,n),t.base=i.slice(a,o)),t.ext=i.slice(n,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function fn(i,t,e,s,r){const n=t[e];for(let a=0;a<n.length;a++){const o=n[a];e<t.length-1?fn(i.replace(s[e],o),t,e+1,s,r):r.push(i.replace(s[e],o))}}function To(i){const t=/\{(.*?)\}/g,e=i.match(t),s=[];if(e){const r=[];e.forEach(n=>{const a=n.substring(1,n.length-1).split(",");r.push(a)}),fn(i,r,0,e,s)}else s.push(i);return s}const ri=i=>!Array.isArray(i);class de{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return xt(e||s,n=>typeof n=="string"?n:Array.isArray(n)?n.map(a=>(a==null?void 0:a.src)??a):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&tt("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,a])=>typeof a=="string"||Array.isArray(a)?{alias:n,src:a}:{alias:n,...a})),r.forEach(n=>{const a=n.src,o=n.alias;let h;if(typeof o=="string"){const c=this._createBundleAssetId(t,o);s.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));s.push(...c),h=[...o,...c]}this.add({...n,alias:h,src:a})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=n=>{this.hasKey(n)&&tt(`[Resolver] already has key: ${n} overwriting`)},xt(e).forEach(n=>{const{src:a}=n;let{data:o,format:h,loadParser:c}=n;const l=xt(a).map(f=>typeof f=="string"?To(f):Array.isArray(f)?f:[f]),d=this.getAlias(n);Array.isArray(d)?d.forEach(s):s(d);const u=[];l.forEach(f=>{f.forEach(p=>{let y={};if(typeof p!="object"){y.src=p;for(let g=0;g<this._parsers.length;g++){const _=this._parsers[g];if(_.test(p)){y=_.parse(p);break}}}else o=p.data??o,h=p.format??h,c=p.loadParser??c,y={...y,...p};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(f=>{this._assetMap[f]=u})})}resolveBundle(t){const e=ri(t);t=xt(t);const s={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const c=a[h];o[this._extractAssetIdFromBundle(r,h)]=c}s[r]=o}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const r in e)s[r]=e[r].src;return s}return e.src}resolve(t){const e=ri(t);t=xt(t);const s={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const a=this._getPreferredOrder(n);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const c=n.filter(l=>l[o]?l[o]===h:!1);c.length&&(n=c)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});s[r]=this._resolverHash[r]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const s=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(s.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:s,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=ut.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??Co(t.src),t}}de.RETINA_PREFIX=/@([0-9\.]+)x/;function Co(i){return i.split(".").pop().split("?").shift().split("#").shift()}const Yi=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},pn=class ve{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof L?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const s=parseFloat(e.meta.scale);s?(this.resolution=s,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ve.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=ve.BATCH_SIZE;for(;e-t<s&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],a=n.frame;if(a){let o=null,h=null;const c=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,l=new O(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);n.rotated?o=new O(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 O(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new O(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[r]=new L({source:this.textureSource,frame:o,orig:l,trim:h,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:r.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let s=0;s<t[e].length;s++){const r=t[e][s];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*ve.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ve.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const s in this.textures)this.textures[s].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};pn.BATCH_SIZE=1e3;let Qs=pn;const Mo=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function mn(i,t,e){const s={};if(i.forEach(r=>{s[r]=t}),Object.keys(t.textures).forEach(r=>{s[r]=t.textures[r]}),!e){const r=ut.dirname(i[0]);t.linkedSheets.forEach((n,a)=>{const o=mn([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(s,o)})}return s}const Po={extension:P.Asset,cache:{test:i=>i instanceof Qs,getCacheableAssets:(i,t)=>mn(i,t,!1)},resolver:{extension:{type:P.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),r=e.pop();return s==="json"&&Mo.includes(r)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=de.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:P.LoadParser,priority:Rt.Normal,name:"spritesheetLoader"},async testParse(i,t){return ut.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var c,l;const{texture:s,imageFilename:r}=(t==null?void 0:t.data)??{};let n=ut.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a;if(s instanceof L)a=s;else{const d=Yi(n+(r??i.meta.image),t.src);a=(await e.load([d]))[d]}const o=new Qs(a.source,i);await o.parse();const h=(c=i==null?void 0:i.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let p=n+f;(l=t.data)!=null&&l.ignoreMultiPack||(p=Yi(p,t.src),d.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const u=await Promise.all(d);o.linkedSheets=u,u.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==f))})}return o},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};ht.add(Po);const Ci=Object.create(null),Js=Object.create(null);function fs(i,t){let e=Js[i];return e===void 0&&(Ci[t]===void 0&&(Ci[t]=1),Js[i]=e=Ci[t]++),e}let Qt;function gn(){return(!Qt||Qt!=null&&Qt.isContextLost())&&(Qt=q.get().createCanvas().getContext("webgl",{})),Qt}let $e;function ko(){if(!$e){$e="mediump";const i=gn();i&&i.getShaderPrecisionFormat&&($e=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return $e}function Go(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),`
|
|
|
|
#ifdef GL_ES // This checks if it is WebGL1
|
|
#define in varying
|
|
#define finalColor gl_FragColor
|
|
#define texture texture2D
|
|
#endif
|
|
${i}
|
|
`):`
|
|
|
|
#ifdef GL_ES // This checks if it is WebGL1
|
|
#define in attribute
|
|
#define out varying
|
|
#endif
|
|
${i}
|
|
`}function Io(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&s!=="highp"&&(r="mediump"),`precision ${r} float;
|
|
${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function Bo(i,t){return t?`#version 300 es
|
|
${i}`:i}const Eo={},Fo={};function Ro(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Eo:Fo;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`}
|
|
${i}`}function Lo(i,t){return t?i.replace("#version 300 es",""):i}const Mi={stripVersion:Lo,ensurePrecision:Io,addProgramDefines:Go,setProgramName:Ro,insertVersion:Bo},Pi=Object.create(null),xn=class ji{constructor(t){t={...ji.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ko()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(Mi).forEach(a=>{const o=s[a];r=Mi[a](r,o,!0),n=Mi[a](n,o,!1)}),this.fragment=r,this.vertex=n,this._key=fs(`${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 Pi[e]||(Pi[e]=new ji(t)),Pi[e]}};xn.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let yn=xn;const tr={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function zo(i){return tr[i]??tr.float32}const Do={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 Oo({source:i,entryPoint:t}){const e={},s=i.indexOf(`fn ${t}`);if(s!==-1){const r=i.indexOf("->",s);if(r!==-1){const n=i.substring(s,r),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(n))!==null;){const h=Do[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:zo(h).stride,offset:0,instance:!1,start:0}}}}return e}function ki(i){var d,u;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=(d=i.match(t))==null?void 0:d.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(s)[1],10),name:f.match(r)[2],isUniform:f.match(r)[1]==="<uniform>",type:f.match(n)[1]}));if(!c)return{groups:[],structs:[]};const l=((u=i.match(a))==null?void 0:u.map(f=>{const p=f.match(h)[1],y=f.match(o).reduce((g,_)=>{const[w,b]=_.split(":");return g[w.trim()]=b.trim(),g},{});return y?{name:p,members:y}:null}).filter(({name:f})=>c.some(p=>p.type===f)))??[];return{groups:c,structs:l}}var Ae=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Ae||{});function Wo({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]=[]),s.isUniform?t[s.group].push({binding:s.binding,visibility:Ae.VERTEX|Ae.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:Ae.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"&&t[s.group].push({binding:s.binding,visibility:Ae.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function Uo({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]={}),t[s.group][s.name]=s.binding}return t}function Ho(i,t){const e=new Set,s=new Set,r=[...i.structs,...t.structs].filter(a=>e.has(a.name)?!1:(e.add(a.name),!0)),n=[...i.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return s.has(o)?!1:(s.add(o),!0)});return{structs:r,groups:n}}const Gi=Object.create(null);class hi{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:r,gpuLayout:n,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=s,e.source===s.source){const c=ki(e.source);this.structsAndGroups=c}else{const c=ki(s.source),l=ki(e.source);this.structsAndGroups=Ho(c,l)}this.layout=r??Uo(this.structsAndGroups),this.gpuLayout=n??Wo(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=fs(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Oo(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 Gi[e]||(Gi[e]=new hi(t)),Gi[e]}}const _n=["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>"],No=_n.reduce((i,t)=>(i[t]=!0,i),{});function $o(i,t){switch(i){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const wn=class bn{constructor(t,e){this._touched=0,this.uid=it("uniform"),this._resourceType="uniformGroup",this._resourceId=it("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...bn.defaultOptions,...e},this.uniformStructures=t;const s={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!No[n.type])throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${_n.join(", ")}`);n.value??(n.value=$o(n.type,n.size)),s[r]=n.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=fs(Object.keys(s).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};wn.defaultOptions={ubo:!1,isStatic:!1};let Sn=wn;class Je{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const r=t[s];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const s=this.resources[e];t!==s&&(s&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var e;const t=this.resources;for(const s in t){const r=t[s];(e=r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}var qi=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(qi||{});class ps extends ct{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:r,resources:n,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=s,a===void 0&&(a=0,e&&(a|=qi.WEBGPU),s&&(a|=qi.WEBGL)),this.compatibleRenderers=a;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&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&&r&&!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(n){r={},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 n)h[l]||(r[99]||(r[99]=new Je,this._ownedBindGroups.push(r[99])),h[l]={group:99,binding:c,name:l},o[99]=o[99]||{},o[99][c]=l,c++);for(const l in n){const d=l;let u=n[l];!u.source&&!u._resourceType&&(u=new Sn(u));const f=h[d];f&&(r[f.group]||(r[f.group]=new Je,this._ownedBindGroups.push(r[f.group])),r[f.group].setResource(u,f.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,s){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new Je,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const r in e){const n=e[r];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(a){t[n.group].setResource(a,n.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:s,...r}=t;let n,a;return e&&(n=hi.from(e)),s&&(a=yn.from(s)),new ps({gpuProgram:n,glProgram:a,...r})}}const Ki=[];ht.handleByNamedList(P.Environment,Ki);async function Vo(i){if(!i)for(let t=0;t<Ki.length;t++){const e=Ki[t];if(e.value.test()){await e.value.load();return}}}let _e;function Xo(){if(typeof _e=="boolean")return _e;try{_e=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{_e=!1}return _e}var ms={exports:{}};ms.exports=li;ms.exports.default=li;function li(i,t,e){e=e||2;var s=t&&t.length,r=s?t[0]*e:i.length,n=vn(i,0,r,e,!0),a=[];if(!n||n.next===n.prev)return a;var o,h,c,l,d,u,f;if(s&&(n=Zo(i,t,n,e)),i.length>80*e){o=c=i[0],h=l=i[1];for(var p=e;p<r;p+=e)d=i[p],u=i[p+1],d<o&&(o=d),u<h&&(h=u),d>c&&(c=d),u>l&&(l=u);f=Math.max(c-o,l-h),f=f!==0?32767/f:0}return ke(n,a,e,o,h,f,0),a}function vn(i,t,e,s,r){var n,a;if(r===Ji(i,t,e,s)>0)for(n=t;n<e;n+=s)a=er(n,i[n],i[n+1],a);else for(n=e-s;n>=t;n-=s)a=er(n,i[n],i[n+1],a);return a&&ci(a,a.next)&&(Ie(a),a=a.next),a}function Kt(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(ci(e,e.next)||X(e.prev,e,e.next)===0)){if(Ie(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function ke(i,t,e,s,r,n,a){if(i){!a&&n&&ih(i,s,r,n);for(var o=i,h,c;i.prev!==i.next;){if(h=i.prev,c=i.next,n?jo(i,s,r,n):Yo(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(c.i/e|0),Ie(i),i=c.next,o=c.next;continue}if(i=c,i===o){a?a===1?(i=qo(Kt(i),t,e),ke(i,t,e,s,r,n,2)):a===2&&Ko(i,t,e,s,r,n):ke(Kt(i),t,e,s,r,n,1);break}}}}function Yo(i){var t=i.prev,e=i,s=i.next;if(X(t,e,s)>=0)return!1;for(var r=t.x,n=e.x,a=s.x,o=t.y,h=e.y,c=s.y,l=r<n?r<a?r:a:n<a?n:a,d=o<h?o<c?o:c:h<c?h:c,u=r>n?r>a?r:a:n>a?n:a,f=o>h?o>c?o:c:h>c?h:c,p=s.next;p!==t;){if(p.x>=l&&p.x<=u&&p.y>=d&&p.y<=f&&ie(r,o,n,h,a,c,p.x,p.y)&&X(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function jo(i,t,e,s){var r=i.prev,n=i,a=i.next;if(X(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,c=a.x,l=r.y,d=n.y,u=a.y,f=o<h?o<c?o:c:h<c?h:c,p=l<d?l<u?l:u:d<u?d:u,y=o>h?o>c?o:c:h>c?h:c,g=l>d?l>u?l:u:d>u?d:u,_=Zi(f,p,t,e,s),w=Zi(y,g,t,e,s),b=i.prevZ,S=i.nextZ;b&&b.z>=_&&S&&S.z<=w;){if(b.x>=f&&b.x<=y&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&ie(o,l,h,d,c,u,b.x,b.y)&&X(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=f&&S.x<=y&&S.y>=p&&S.y<=g&&S!==r&&S!==a&&ie(o,l,h,d,c,u,S.x,S.y)&&X(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=_;){if(b.x>=f&&b.x<=y&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&ie(o,l,h,d,c,u,b.x,b.y)&&X(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=w;){if(S.x>=f&&S.x<=y&&S.y>=p&&S.y<=g&&S!==r&&S!==a&&ie(o,l,h,d,c,u,S.x,S.y)&&X(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function qo(i,t,e){var s=i;do{var r=s.prev,n=s.next.next;!ci(r,n)&&An(r,s,s.next,n)&&Ge(r,n)&&Ge(n,r)&&(t.push(r.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),Ie(s),Ie(s.next),s=i=n),s=s.next}while(s!==i);return Kt(s)}function Ko(i,t,e,s,r,n){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&nh(a,o)){var h=Tn(a,o);a=Kt(a,a.next),h=Kt(h,h.next),ke(a,t,e,s,r,n,0),ke(h,t,e,s,r,n,0);return}o=o.next}a=a.next}while(a!==i)}function Zo(i,t,e,s){var r=[],n,a,o,h,c;for(n=0,a=t.length;n<a;n++)o=t[n]*s,h=n<a-1?t[n+1]*s:i.length,c=vn(i,o,h,s,!1),c===c.next&&(c.steiner=!0),r.push(rh(c));for(r.sort(Qo),n=0;n<r.length;n++)e=Jo(r[n],e);return e}function Qo(i,t){return i.x-t.x}function Jo(i,t){var e=th(i,t);if(!e)return t;var s=Tn(e,i);return Kt(s,s.next),Kt(e,e.next)}function th(i,t){var e=t,s=i.x,r=i.y,n=-1/0,a;do{if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){var o=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=s&&o>n&&(n=o,a=e.x<e.next.x?e:e.next,o===s))return a}e=e.next}while(e!==t);if(!a)return null;var h=a,c=a.x,l=a.y,d=1/0,u;e=a;do s>=e.x&&e.x>=c&&s!==e.x&&ie(r<l?s:n,r,c,l,r<l?n:s,r,e.x,e.y)&&(u=Math.abs(r-e.y)/(s-e.x),Ge(e,i)&&(u<d||u===d&&(e.x>a.x||e.x===a.x&&eh(a,e)))&&(a=e,d=u)),e=e.next;while(e!==h);return a}function eh(i,t){return X(i.prev,i,t.prev)<0&&X(t.next,i,i.next)<0}function ih(i,t,e,s){var r=i;do r.z===0&&(r.z=Zi(r.x,r.y,t,e,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,sh(r)}function sh(i){var t,e,s,r,n,a,o,h,c=1;do{for(e=i,i=null,n=null,a=0;e;){for(a++,s=e,o=0,t=0;t<c&&(o++,s=s.nextZ,!!s);t++);for(h=c;o>0||h>0&&s;)o!==0&&(h===0||!s||e.z<=s.z)?(r=e,e=e.nextZ,o--):(r=s,s=s.nextZ,h--),n?n.nextZ=r:i=r,r.prevZ=n,n=r;e=s}n.nextZ=null,c*=2}while(a>1);return i}function Zi(i,t,e,s,r){return i=(i-e)*r|0,t=(t-s)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function rh(i){var t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function ie(i,t,e,s,r,n,a,o){return(r-a)*(t-o)>=(i-a)*(n-o)&&(i-a)*(s-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(s-o)}function nh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!ah(i,t)&&(Ge(i,t)&&Ge(t,i)&&oh(i,t)&&(X(i.prev,i,t.prev)||X(i,t.prev,t))||ci(i,t)&&X(i.prev,i,i.next)>0&&X(t.prev,t,t.next)>0)}function X(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function ci(i,t){return i.x===t.x&&i.y===t.y}function An(i,t,e,s){var r=Xe(X(i,t,e)),n=Xe(X(i,t,s)),a=Xe(X(e,s,i)),o=Xe(X(e,s,t));return!!(r!==n&&a!==o||r===0&&Ve(i,e,t)||n===0&&Ve(i,s,t)||a===0&&Ve(e,i,s)||o===0&&Ve(e,t,s))}function Ve(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function Xe(i){return i>0?1:i<0?-1:0}function ah(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&An(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Ge(i,t){return X(i.prev,i,i.next)<0?X(i,t,i.next)>=0&&X(i,i.prev,t)>=0:X(i,t,i.prev)<0||X(i,i.next,t)<0}function oh(i,t){var e=i,s=!1,r=(i.x+t.x)/2,n=(i.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Tn(i,t){var e=new Qi(i.i,i.x,i.y),s=new Qi(t.i,t.x,t.y),r=i.next,n=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function er(i,t,e,s){var r=new Qi(i,t,e);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function Ie(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Qi(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}li.deviation=function(i,t,e,s){var r=t&&t.length,n=r?t[0]*e:i.length,a=Math.abs(Ji(i,0,n,e));if(r)for(var o=0,h=t.length;o<h;o++){var c=t[o]*e,l=o<h-1?t[o+1]*e:i.length;a-=Math.abs(Ji(i,c,l,e))}var d=0;for(o=0;o<s.length;o+=3){var u=s[o]*e,f=s[o+1]*e,p=s[o+2]*e;d+=Math.abs((i[u]-i[p])*(i[f+1]-i[u+1])-(i[u]-i[f])*(i[p+1]-i[u+1]))}return a===0&&d===0?0:Math.abs((d-a)/a)};function Ji(i,t,e,s){for(var r=0,n=t,a=e-s;n<e;n+=s)r+=(i[a]-i[n])*(i[n+1]+i[a+1]),a=n;return r}li.flatten=function(i){for(var t=i[0][0].length,e={vertices:[],holes:[],dimensions:t},s=0,r=0;r<i.length;r++){for(var n=0;n<i[r].length;n++)for(var a=0;a<t;a++)e.vertices.push(i[r][n][a]);r>0&&(s+=i[r-1].length,e.holes.push(s))}return e};var hh=ms.exports;const lh=cs(hh);var Cn=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))(Cn||{});class ch{constructor(t){this.items=[],this._name=t}emit(t,e,s,r,n,a,o,h){const{name:c,items:l}=this;for(let d=0,u=l.length;d<u;d++)l[d][c](t,e,s,r,n,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 dh=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],Mn=class Pn extends ct{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=[...dh,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Vo(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash)t={...this._systemsHash[s].constructor.defaultOptions,...t};t={...Pn.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let s=0;s<this.runners.init.items.length;s++)await this.runners.init.items[s].init(t);this._initOptions=t}render(t,e){let s=t;if(s instanceof at&&(s={container:s},e&&(D(W,"passing a second argument is deprecated, please use render options instead"),s.target=e.renderTexture)),s.target||(s.target=this.view.renderTarget),s.target===this.view.renderTarget&&(this._lastObjectRendered=s.container,s.clearColor=this.background.colorRgba),s.clearColor){const r=Array.isArray(s.clearColor)&&s.clearColor.length===4;s.clearColor=r?s.clearColor:J.shared.setValue(s.clearColor).toArray()}s.transform||(s.container.updateLocalTransform(),s.transform=s.container.localTransform),this.runners.prerender.emit(s),this.runners.renderStart.emit(s),this.runners.render.emit(s),this.runners.renderEnd.emit(s),this.runners.postrender.emit(s)}resize(t,e,s){const r=this.view.resolution;this.view.resize(t,e,s),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),s!==void 0&&s!==r&&this.runners.resolutionChange.emit(s)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=Cn.ALL);const{clear:s,clearColor:r,target:n}=t;J.shared.setValue(r??this.background.colorRgba),e.renderTarget.clear(n,s,J.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new ch(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const r in this.runners)this.runners[r].add(s);return this}_addPipes(t,e){const s=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,a=r.name,o=s[a];this.renderPipes[a]=new n(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(!Xo())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Mn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let kn=Mn,Ye;function uh(i){return Ye!==void 0||(Ye=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??kn.defaultOptions.failIfMajorPerformanceCaveat};try{if(!q.get().getWebGLRenderingContext())return!1;let r=q.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const a=r.getExtension("WEBGL_lose_context");a&&a.loseContext()}return r=null,n}catch{return!1}})()),Ye}let je;async function fh(i={}){return je!==void 0||(je=await(async()=>{const t=q.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),je}const ir=["webgl","webgpu","canvas"];async function ph(i){let t=[];i.preference?(t.push(i.preference),ir.forEach(n=>{n!==i.preference&&t.push(n)})):t=ir.slice();let e,s={};for(let n=0;n<t.length;n++){const a=t[n];if(a==="webgpu"&&await fh()){const{WebGPURenderer:o}=await ei(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-DokXFXmq.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,s={...i,...i.webgpu};break}else if(a==="webgl"&&uh(i.failIfMajorPerformanceCaveat??kn.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await ei(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-DUH4HgYd.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,s={...i,...i.webgl};break}else if(a==="canvas")throw s={...i},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(s),r}const Gn="8.4.0";class In{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Gn)}static destroy(){}}In.extension=P.Application;class mh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Gn)}destroy(){this._renderer=null}}mh.extension={type:[P.WebGLSystem,P.WebGPUSystem],name:"initHook",priority:-10};const Bn=class ts{constructor(...t){this.stage=new at,t[0]!==void 0&&D(W,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await ph(t),ts._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return D(W,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=ts._plugins.slice(0);s.reverse(),s.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Bn._plugins=[];let En=Bn;ht.handleByList(P.Application,En._plugins);ht.add(In);class Fn extends ct{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 D(W,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return D(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return D(W,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return D(W,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return D(W,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}const Rn=class es{constructor(t,e,s,r){this.uid=it("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=s,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:J.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=es.defaultTextureSize,{gradientStops:e}=this,s=q.get().createCanvas();s.width=t,s.height=t;const r=s.getContext("2d"),n=r.createLinearGradient(0,0,es.defaultTextureSize,1);for(let y=0;y<e.length;y++){const g=e[y];n.addColorStop(g.offset,g.color)}r.fillStyle=n,r.fillRect(0,0,t,t),this.texture=new L({source:new ce({resource:s,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:a,y0:o,x1:h,y1:c}=this,l=new U,d=h-a,u=c-o,f=Math.sqrt(d*d+u*u),p=Math.atan2(u,d);l.translate(-a,-o),l.scale(1/t,1/t),l.rotate(-p),l.scale(256/f,1),this.transform=l,this._styleKey=null}get styleKey(){if(this._styleKey)return this._styleKey;const t=this.gradientStops.map(r=>`${r.offset}-${r.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Rn.defaultTextureSize=256;let Be=Rn;const sr={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 di{constructor(t,e){this.uid=it("fillPattern"),this.transform=new U,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=sr[e].addressModeU,t.source.style.addressModeV=sr[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 gh=yh,Ii={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},xh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function yh(i){var t=[];return i.replace(xh,function(e,s,r){var n=s.toLowerCase();for(r=wh(r),n=="m"&&r.length>2&&(t.push([s].concat(r.splice(0,2))),n="l",s=s=="m"?"l":"L");;){if(r.length==Ii[n])return r.unshift(s),t.push(r);if(r.length<Ii[n])throw new Error("malformed path data");t.push([s].concat(r.splice(0,Ii[n])))}}),t}var _h=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function wh(i){var t=i.match(_h);return t?t.map(Number):[]}const bh=cs(gh);function Sh(i,t){const e=bh(i),s=[];let r=null,n=0,a=0;for(let o=0;o<e.length;o++){const h=e[o],c=h[0],l=h;switch(c){case"M":n=l[1],a=l[2],t.moveTo(n,a);break;case"m":n+=l[1],a+=l[2],t.moveTo(n,a);break;case"H":n=l[1],t.lineTo(n,a);break;case"h":n+=l[1],t.lineTo(n,a);break;case"V":a=l[1],t.lineTo(n,a);break;case"v":a+=l[1],t.lineTo(n,a);break;case"L":n=l[1],a=l[2],t.lineTo(n,a);break;case"l":n+=l[1],a+=l[2],t.lineTo(n,a);break;case"C":n=l[5],a=l[6],t.bezierCurveTo(l[1],l[2],l[3],l[4],n,a);break;case"c":t.bezierCurveTo(n+l[1],a+l[2],n+l[3],a+l[4],n+l[5],a+l[6]),n+=l[5],a+=l[6];break;case"S":n=l[3],a=l[4],t.bezierCurveToShort(l[1],l[2],n,a);break;case"s":t.bezierCurveToShort(n+l[1],a+l[2],n+l[3],a+l[4]),n+=l[3],a+=l[4];break;case"Q":n=l[3],a=l[4],t.quadraticCurveTo(l[1],l[2],n,a);break;case"q":t.quadraticCurveTo(n+l[1],a+l[2],n+l[3],a+l[4]),n+=l[3],a+=l[4];break;case"T":n=l[1],a=l[2],t.quadraticCurveToShort(n,a);break;case"t":n+=l[1],a+=l[2],t.quadraticCurveToShort(n,a);break;case"A":n=l[6],a=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],n,a);break;case"a":n+=l[6],a+=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],n,a);break;case"Z":case"z":t.closePath(),s.length>0&&(r=s.pop(),r?(n=r.startX,a=r.startY):(n=0,a=0)),r=null;break;default:tt(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&r===null&&(r={startX:n,startY:a},s.push(r))}return t}class gs{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new gs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,a=this.radius,o=s/2,h=Math.sqrt(r*r+n*n);return h<a+o&&h>a-o}getBounds(t){return t=t||new O,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 xs{constructor(t=0,e=0,s=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=r}clone(){return new xs(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return s*=s,r*=r,s+r<=1}strokeContains(t,e,s){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const a=s/2,o=r-a,h=n-a,c=r+a,l=n+a,d=t-this.x,u=e-this.y,f=d*d/(o*o)+u*u/(h*h),p=d*d/(c*c)+u*u/(l*l);return f>1&&p<=1}getBounds(t){return t=t||new O,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 vh(i,t,e,s,r,n){const a=i-e,o=t-s,h=r-e,c=n-s,l=a*h+o*c,d=h*h+c*c;let u=-1;d!==0&&(u=l/d);let f,p;u<0?(f=e,p=s):u>1?(f=r,p=n):(f=e+u*h,p=s+u*c);const y=i-f,g=t-p;return y*y+g*g}class Me{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let r=0,n=e.length;r<n;r++)s.push(e[r].x,e[r].y);e=s}this.points=e,this.closePath=!0}clone(){const t=this.points.slice(),e=new Me(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const r=this.points.length/2;for(let n=0,a=r-1;n<r;a=n++){const o=this.points[n*2],h=this.points[n*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&&(s=!s)}return s}strokeContains(t,e,s){const r=s/2,n=r*r,{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(vh(t,e,c,l,d,u)<=n)return!0}return!1}getBounds(t){t=t||new O;const e=this.points;let s=1/0,r=-1/0,n=1/0,a=-1/0;for(let o=0,h=e.length;o<h;o+=2){const c=e[o],l=e[o+1];s=c<s?c:s,r=c>r?c:r,n=l<n?l:n,a=l>a?l:a}return t.x=s,t.width=r-s,t.y=n,t.height=a-n,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 qe=(i,t,e,s,r,n)=>{const a=i-e,o=t-s,h=Math.sqrt(a*a+o*o);return h>=r-n&&h<=r+n};class ys{constructor(t=0,e=0,s=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=r,this.radius=n}getBounds(t){return t=t||new O,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new ys(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let r=t-(this.x+s),n=e-(this.y+s);const a=s*s;if(r*r+n*n<=a||(r=t-(this.x+this.width-s),r*r+n*n<=a)||(n=e-(this.y+this.height-s),r*r+n*n<=a)||(r=t-(this.x+s),r*r+n*n<=a))return!0}return!1}strokeContains(t,e,s){const{x:r,y:n,width:a,height:o,radius:h}=this,c=s/2,l=r+h,d=n+h,u=a-h*2,f=o-h*2,p=r+a,y=n+o;return(t>=r-c&&t<=r+c||t>=p-c&&t<=p+c)&&e>=d&&e<=d+f||(e>=n-c&&e<=n+c||e>=y-c&&e<=y+c)&&t>=l&&t<=l+u?!0:t<l&&e<d&&qe(t,e,l,d,h,c)||t>p-h&&e<d&&qe(t,e,p-h,d,h,c)||t>p-h&&e>y-h&&qe(t,e,p-h,y-h,h,c)||t<l&&e>y-h&&qe(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 Ah=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
`);function Th(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=`
|
|
else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function Ch(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const s=Ah.replace(/%forloop%/gi,Th(i));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}}finally{t.deleteShader(e)}return i}let Jt=null;function Ln(){var t;if(Jt)return Jt;const i=gn();return Jt=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),Jt=Ch(Jt,i),(t=i.getExtension("WEBGL_lose_context"))==null||t.loseContext(),Jt}const zn={};function Mh(i,t){let e=2166136261;for(let s=0;s<t;s++)e^=i[s].uid,e=Math.imul(e,16777619),e>>>=0;return zn[e]||Ph(i,t,e)}let Bi=0;function Ph(i,t,e){const s={};let r=0;Bi||(Bi=Ln());for(let a=0;a<Bi;a++){const o=a<t?i[a]:L.EMPTY.source;s[r++]=o.source,s[r++]=o.style}const n=new Je(s);return zn[e]=n,n}class rr{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 nr(i,t){const e=i.byteLength/8|0,s=new Float64Array(i,0,e);new Float64Array(t,0,e).set(s);const n=i.byteLength-e*8;if(n>0){const a=new Uint8Array(i,e*8,n);new Uint8Array(t,e*8,n).set(a)}}const kh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Gh=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",i[i.NONE=4]="NONE",i))(Gh||{});function ar(i,t){return t.alphaMode==="no-premultiply-alpha"&&kh[i]||i}class Ih{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 Bh{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Ih,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Dn=[];let is=0;function or(){return is>0?Dn[--is]:new Bh}function hr(i){Dn[is++]=i}let we=0;const On=class ti{constructor(t={}){this.uid=it("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],ti.defaultOptions.maxTextures=ti.defaultOptions.maxTextures??Ln(),t={...ti.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:r}=t;this.attributeBuffer=new rr(s*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)hr(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const s=t._batch.textures.ids[e._source.uid];return!s&&s!==0?!1:(t._textureId=s,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let s=or(),r=s.textures;r.clear();const n=e[this.elementStart];let a=ar(n.blendMode,n.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 f=this.maxTextures;for(let p=this.elementStart;p<this.elementSize;++p){const y=e[p];e[p]=null;const _=y.texture._source,w=ar(y.blendMode,_),b=a!==w;if(_._batchTick===we&&!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=s;continue}_._batchTick=we,(r.count>=f||b)&&(this._finishBatch(s,d,l-d,r,a,t,u),u="renderBatch",d=l,a=w,s=or(),r=s.textures,r.clear(),++we),y._textureId=_._textureBindLocation=r.count,r.ids[_.uid]=r.count,r.textures[r.count++]=_,y._batch=s,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))}r.count>0&&(this._finishBatch(s,d,l-d,r,a,t,u),d=l,++we),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=l}_finishBatch(t,e,s,r,n,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=r,t.blendMode=n,t.start=e,t.size=s,++we,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new rr(e);nr(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const r=s>65535?new Uint32Array(s):new Uint16Array(s);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)r[n]=e[n];else nr(e.buffer,r.buffer);this.indexBuffer=r}packQuadIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}packIndex(t,e,s,r){const n=t.indices,a=t.indexSize,o=t.indexOffset,h=t.attributeOffset;for(let c=0;c<a;c++)e[s++]=r+n[c+o]-h}destroy(){for(let t=0;t<this.batches.length;t++)hr(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}};On.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Eh=On;var Z=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(Z||{});class Et extends ct{constructor(t){let{data:e,size:s}=t;const{usage:r,label:n,shrinkToFit:a}=t;super(),this.uid=it("buffer"),this._resourceType="buffer",this._resourceId=it("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=s??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:s,usage:r,mappedAtCreation:o,label:n},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&Z.STATIC)}set static(t){t?this.descriptor.usage|=Z.STATIC:this.descriptor.usage&=~Z.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLength<r.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=it("resource"),this.emit("change",this));return}s&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Wn(i,t){if(!(i instanceof Et)){let e=t?Z.INDEX:Z.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=Z.INDEX|Z.COPY_DST):(i=new Float32Array(i),e=Z.VERTEX|Z.COPY_DST)),i=new Et({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function Fh(i,t,e){const s=i.getAttribute(t);if(!s)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const r=s.buffer.data;let n=1/0,a=1/0,o=-1/0,h=-1/0;const c=r.BYTES_PER_ELEMENT,l=(s.offset||0)/c,d=(s.stride||2*4)/c;for(let u=l;u<r.length;u+=d){const f=r[u],p=r[u+1];f>o&&(o=f),p>h&&(h=p),f<n&&(n=f),p<a&&(a=p)}return e.minX=n,e.minY=a,e.maxX=o,e.maxY=h,e}function Rh(i){return(i instanceof Et||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=Wn(i.buffer,!1),i}class Un extends ct{constructor(t){const{attributes:e,indexBuffer:s,topology:r}=t;super(),this.uid=it("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new vt,this._boundsDirty=!0,this.attributes=e,this.buffers=[],this.instanceCount=t.instanceCount||1;for(const n in e){const a=e[n]=Rh(e[n]);this.buffers.indexOf(a.buffer)===-1&&(this.buffers.push(a.buffer),a.buffer.on("update",this.onBufferUpdate,this),a.buffer.on("change",this.onBufferUpdate,this))}s&&(this.indexBuffer=Wn(s,!0),this.buffers.push(this.indexBuffer)),this.topology=r||"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,Fh(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 Lh=new Float32Array(1),zh=new Uint32Array(1);class Dh extends Un{constructor(){const e=new Et({data:Lh,label:"attribute-batch-buffer",usage:Z.VERTEX|Z.COPY_DST,shrinkToFit:!1}),s=new Et({data:zh,label:"index-batch-buffer",usage:Z.INDEX|Z.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4}},indexBuffer:s})}}function lr(i,t,e){if(i)for(const s in i){const r=s.toLocaleLowerCase(),n=t[r];if(n){let a=i[s];s==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(a)}else tt(`${s} placement hook does not exist in shader`)}}const Oh=/\{\{(.*?)\}\}/g;function cr(i){var s;const t={};return(((s=i.match(Oh))==null?void 0:s.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function dr(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function ur(i,t,e=!1){const s=[];dr(t,s),i.forEach(o=>{o.header&&dr(o.header,s)});const r=s;e&&r.sort();const n=r.map((o,h)=>` @location(${h}) ${o},`).join(`
|
|
`);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",`
|
|
${n}
|
|
`),a}function fr(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Wh(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function Uh(i){const t=/@.*?\s+/g;return i.replace(t,"")}function Hh(i,t){const e=[];fr(t,e),i.forEach(h=>{h.header&&fr(h.header,e)});let s=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`,
|
|
`),n=e.sort().map(h=>` var ${Uh(h)};`).join(`
|
|
`),a=`return VSOutput(
|
|
${e.sort().map(h=>` ${Wh(h)}`).join(`,
|
|
`)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",`
|
|
${r}
|
|
`),o=o.replace("{{start}}",`
|
|
${n}
|
|
`),o=o.replace("{{return}}",`
|
|
${a}
|
|
`),o}function pr(i,t){let e=i;for(const s in t){const r=t[s];r.join(`
|
|
`).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
|
|
${r.join(`
|
|
`)}
|
|
//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const Bt=Object.create(null),Ei=new Map;let Nh=0;function $h({template:i,bits:t}){const e=Hn(i,t);if(Bt[e])return Bt[e];const{vertex:s,fragment:r}=Xh(i,t);return Bt[e]=Nn(s,r,t),Bt[e]}function Vh({template:i,bits:t}){const e=Hn(i,t);return Bt[e]||(Bt[e]=Nn(i.vertex,i.fragment,t)),Bt[e]}function Xh(i,t){const e=t.map(a=>a.vertex).filter(a=>!!a),s=t.map(a=>a.fragment).filter(a=>!!a);let r=ur(e,i.vertex,!0);r=Hh(e,r);const n=ur(s,i.fragment,!0);return{vertex:r,fragment:n}}function Hn(i,t){return t.map(e=>(Ei.has(e)||Ei.set(e,Nh++),Ei.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function Nn(i,t,e){const s=cr(i),r=cr(t);return e.forEach(n=>{lr(n.vertex,s,n.name),lr(n.fragment,r,n.name)}),{vertex:pr(i,s),fragment:pr(t,r)}}const Yh=`
|
|
@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}}
|
|
};
|
|
`,jh=`
|
|
@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;
|
|
};
|
|
`,qh=`
|
|
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}}
|
|
}
|
|
`,Kh=`
|
|
|
|
in vec4 vColor;
|
|
in vec2 vUV;
|
|
|
|
out vec4 finalColor;
|
|
|
|
{{header}}
|
|
|
|
void main(void) {
|
|
|
|
{{start}}
|
|
|
|
vec4 outColor;
|
|
|
|
{{main}}
|
|
|
|
finalColor = outColor * vColor;
|
|
|
|
{{end}}
|
|
}
|
|
`,Zh={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;
|
|
`}},Qh={name:"global-uniforms-bit",vertex:{header:`
|
|
uniform mat3 uProjectionMatrix;
|
|
uniform mat3 uWorldTransformMatrix;
|
|
uniform vec4 uWorldColorAlpha;
|
|
uniform vec2 uResolution;
|
|
`}};function Jh({bits:i,name:t}){const e=$h({template:{fragment:jh,vertex:Yh},bits:[Zh,...i]});return hi.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function tl({bits:i,name:t}){return new yn({name:t,...Vh({template:{vertex:qh,fragment:Kh},bits:[Qh,...i]})})}const el={name:"color-bit",vertex:{header:`
|
|
@in aColor: vec4<f32>;
|
|
`,main:`
|
|
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
`}},il={name:"color-bit",vertex:{header:`
|
|
in vec4 aColor;
|
|
`,main:`
|
|
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
`}},Fi={};function sl(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s<i;s++)t.push(`@group(1) @binding(${e++}) var textureSource${s+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
|
|
`)}function rl(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<i;e++)e===i-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
|
|
`)}function nl(i){return Fi[i]||(Fi[i]={name:"texture-batch-bit",vertex:{header:`
|
|
@in aTextureIdAndRound: vec2<u32>;
|
|
@out @interpolate(flat) vTextureId : u32;
|
|
`,main:`
|
|
vTextureId = aTextureIdAndRound.y;
|
|
`,end:`
|
|
if(aTextureIdAndRound.x == 1)
|
|
{
|
|
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
}
|
|
`},fragment:{header:`
|
|
@in @interpolate(flat) vTextureId: u32;
|
|
|
|
${sl(i)}
|
|
`,main:`
|
|
var uvDx = dpdx(vUV);
|
|
var uvDy = dpdy(vUV);
|
|
|
|
${rl(i)}
|
|
`}}),Fi[i]}const Ri={};function al(i){const t=[];for(let e=0;e<i;e++)e>0&&t.push("else"),e<i-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
|
|
`)}function ol(i){return Ri[i]||(Ri[i]={name:"texture-batch-bit",vertex:{header:`
|
|
in vec2 aTextureIdAndRound;
|
|
out float vTextureId;
|
|
|
|
`,main:`
|
|
vTextureId = aTextureIdAndRound.y;
|
|
`,end:`
|
|
if(aTextureIdAndRound.x == 1.)
|
|
{
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
}
|
|
`},fragment:{header:`
|
|
in float vTextureId;
|
|
|
|
uniform sampler2D uTextures[${i}];
|
|
|
|
`,main:`
|
|
|
|
${al(i)}
|
|
`}}),Ri[i]}const hl={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;
|
|
}
|
|
`}},ll={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;
|
|
}
|
|
`}},mr={};function cl(i){let t=mr[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=mr[i]=new Sn({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class dl extends ps{constructor(t){const e=tl({name:"batch",bits:[il,ol(t),ll]}),s=Jh({name:"batch",bits:[el,nl(t),hl]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:cl(t)}})}}let gr=null;const $n=class Vn extends Eh{constructor(){super(...arguments),this.geometry=new Dh,this.shader=gr||(gr=new dl(this.maxTextures)),this.name=Vn.extension.name,this.vertexSize=6}packAttributes(t,e,s,r,n){const a=n<<16|t.roundPixels&65535,o=t.transform,h=o.a,c=o.b,l=o.c,d=o.d,u=o.tx,f=o.ty,{positions:p,uvs:y}=t,g=t.color,_=t.attributeOffset,w=_+t.attributeSize;for(let b=_;b<w;b++){const S=b*2,T=p[S],B=p[S+1];e[r++]=h*T+l*B+u,e[r++]=d*B+c*T+f,e[r++]=y[S],e[r++]=y[S+1],s[r++]=g,s[r++]=a}}packQuadAttributes(t,e,s,r,n){const a=t.texture,o=t.transform,h=o.a,c=o.b,l=o.c,d=o.d,u=o.tx,f=o.ty,p=t.bounds,y=p.maxX,g=p.minX,_=p.maxY,w=p.minY,b=a.uvs,S=t.color,T=n<<16|t.roundPixels&65535;e[r+0]=h*g+l*w+u,e[r+1]=d*w+c*g+f,e[r+2]=b.x0,e[r+3]=b.y0,s[r+4]=S,s[r+5]=T,e[r+6]=h*y+l*w+u,e[r+7]=d*w+c*y+f,e[r+8]=b.x1,e[r+9]=b.y1,s[r+10]=S,s[r+11]=T,e[r+12]=h*y+l*_+u,e[r+13]=d*_+c*y+f,e[r+14]=b.x2,e[r+15]=b.y2,s[r+16]=S,s[r+17]=T,e[r+18]=h*g+l*_+u,e[r+19]=d*_+c*g+f,e[r+20]=b.x3,e[r+21]=b.y3,s[r+22]=S,s[r+23]=T}};$n.extension={type:[P.Batcher],name:"default"};let ul=$n;function fl(i,t,e,s,r,n,a,o=null){let h=0;e*=t,r*=n;const c=o.a,l=o.b,d=o.c,u=o.d,f=o.tx,p=o.ty;for(;h<a;){const y=i[e],g=i[e+1];s[r]=c*y+d*g+f,s[r+1]=l*y+u*g+p,r+=n,e+=t,h++}}function pl(i,t,e,s){let r=0;for(t*=e;r<s;)i[t]=0,i[t+1]=0,t+=e,r++}function Xn(i,t,e,s,r){const n=t.a,a=t.b,o=t.c,h=t.d,c=t.tx,l=t.ty;e=e||0,s=s||2,r=r||i.length/s-e;let d=e*s;for(let u=0;u<r;u++){const f=i[d],p=i[d+1];i[d]=n*f+o*p+c,i[d+1]=a*f+h*p+l,d+=s}}function ml(i,t){if(i===16777215||!t)return t;if(t===16777215||!i)return i;const e=i>>16&255,s=i>>8&255,r=i&255,n=t>>16&255,a=t>>8&255,o=t&255,h=e*n/255,c=s*a/255,l=r*o/255;return(h<<16)+(c<<8)+l}const gl=new U;class Yn{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?ml(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||gl}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 Ee={extension:{type:P.ShapeBuilder,name:"circle"},build(i,t){let e,s,r,n,a,o;if(i.type==="circle"){const S=i;e=S.x,s=S.y,a=o=S.radius,r=n=0}else if(i.type==="ellipse"){const S=i;e=S.x,s=S.y,a=S.halfWidth,o=S.halfHeight,r=n=0}else{const S=i,T=S.width/2,B=S.height/2;e=S.x+T,s=S.y+B,a=o=Math.max(0,Math.min(S.radius,Math.min(T,B))),r=T-a,n=B-o}if(!(a>=0&&o>=0&&r>=0&&n>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),c=h*8+(r?4:0)+(n?4:0);if(c===0)return t;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=s+n,t[2]=t[4]=e-r,t[5]=t[7]=s-n,t;let l=0,d=h*4+(r?2:0)+2,u=d,f=c,p=r+a,y=n,g=e+p,_=e-p,w=s+y;if(t[l++]=g,t[l++]=w,t[--d]=w,t[--d]=_,n){const S=s-y;t[u++]=_,t[u++]=S,t[--f]=S,t[--f]=g}for(let S=1;S<h;S++){const T=Math.PI/2*(S/h),B=r+Math.cos(T)*a,M=n+Math.sin(T)*o,k=e+B,v=e-B,A=s+M,j=s-M;t[l++]=k,t[l++]=A,t[--d]=A,t[--d]=v,t[u++]=v,t[u++]=j,t[--f]=j,t[--f]=k}p=r,y=n+o,g=e+p,_=e-p,w=s+y;const b=s-y;return t[l++]=g,t[l++]=w,t[--f]=b,t[--f]=g,r&&(t[l++]=_,t[l++]=w,t[--f]=b,t[--f]=_),t},triangulate(i,t,e,s,r,n){if(i.length===0)return;let a=0,o=0;for(let l=0;l<i.length;l+=2)a+=i[l],o+=i[l+1];a/=i.length/2,o/=i.length/2;let h=s;t[h*e]=a,t[h*e+1]=o;const c=h++;for(let l=0;l<i.length;l+=2)t[h*e]=i[l],t[h*e+1]=i[l+1],l>0&&(r[n++]=h,r[n++]=c,r[n++]=h-1),h++;r[n++]=c+1,r[n++]=c,r[n++]=h-1}},xl={...Ee,extension:{...Ee.extension,name:"ellipse"}},yl={...Ee,extension:{...Ee.extension,name:"roundedRectangle"}},_l=1e-4,xr=1e-4;function wl(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,r=i[t-2],n=i[t-1];s<t;s+=2){const a=i[s],o=i[s+1];e+=(a-r)*(o+n),r=a,n=o}return e<0?-1:1}function yr(i,t,e,s,r,n,a,o){const h=i-e*r,c=t-s*r,l=i+e*n,d=t+s*n;let u,f;a?(u=s,f=-e):(u=-s,f=e);const p=h+u,y=c+f,g=l+u,_=d+f;return o.push(p,y),o.push(g,_),2}function Nt(i,t,e,s,r,n,a,o){const h=e-i,c=s-t;let l=Math.atan2(h,c),d=Math.atan2(r-i,n-t);o&&l<d?l+=Math.PI*2:!o&&l>d&&(d+=Math.PI*2);let u=l;const f=d-l,p=Math.abs(f),y=Math.sqrt(h*h+c*c),g=(15*p*Math.sqrt(y)/Math.PI>>0)+1,_=f/g;if(u+=_,o){a.push(i,t),a.push(e,s);for(let w=1,b=u;w<g;w++,b+=_)a.push(i,t),a.push(i+Math.sin(b)*y,t+Math.cos(b)*y);a.push(i,t),a.push(r,n)}else{a.push(e,s),a.push(i,t);for(let w=1,b=u;w<g;w++,b+=_)a.push(i+Math.sin(b)*y,t+Math.cos(b)*y),a.push(i,t);a.push(r,n),a.push(i,t)}return g*2}function bl(i,t,e,s,r,n,a,o,h){const c=_l;if(i.length===0)return;const l=t;let d=l.alignment;if(t.alignment!==.5){let H=wl(i);d=(d-.5)*H+.5}const u=new ot(i[0],i[1]),f=new ot(i[i.length-2],i[i.length-1]),p=s,y=Math.abs(u.x-f.x)<c&&Math.abs(u.y-f.y)<c;if(p){i=i.slice(),y&&(i.pop(),i.pop(),f.set(i[i.length-2],i[i.length-1]));const H=(u.x+f.x)*.5,It=(f.y+u.y)*.5;i.unshift(H,It),i.push(H,It)}const g=r,_=i.length/2;let w=i.length;const b=g.length/2,S=l.width/2,T=S*S,B=l.miterLimit*l.miterLimit;let M=i[0],k=i[1],v=i[2],A=i[3],j=0,At=0,E=-(k-A),I=M-v,N=0,K=0,mt=Math.sqrt(E*E+I*I);E/=mt,I/=mt,E*=S,I*=S;const ks=d,G=(1-ks)*2,R=ks*2;p||(l.cap==="round"?w+=Nt(M-E*(G-R)*.5,k-I*(G-R)*.5,M-E*G,k-I*G,M+E*R,k+I*R,g,!0)+2:l.cap==="square"&&(w+=yr(M,k,E,I,G,R,!0,g))),g.push(M-E*G,k-I*G),g.push(M+E*R,k+I*R);for(let H=1;H<_-1;++H){M=i[(H-1)*2],k=i[(H-1)*2+1],v=i[H*2],A=i[H*2+1],j=i[(H+1)*2],At=i[(H+1)*2+1],E=-(k-A),I=M-v,mt=Math.sqrt(E*E+I*I),E/=mt,I/=mt,E*=S,I*=S,N=-(A-At),K=v-j,mt=Math.sqrt(N*N+K*K),N/=mt,K/=mt,N*=S,K*=S;const It=v-M,pe=k-A,me=v-j,ge=At-A,Gs=It*me+pe*ge,ze=pe*me-ge*It,xe=ze<0;if(Math.abs(ze)<.001*Math.abs(Gs)){g.push(v-E*G,A-I*G),g.push(v+E*R,A+I*R),Gs>=0&&(l.join==="round"?w+=Nt(v,A,v-E*G,A-I*G,v-N*G,A-K*G,g,!1)+4:w+=2,g.push(v-N*R,A-K*R),g.push(v+N*G,A+K*G));continue}const Is=(-E+M)*(-I+A)-(-E+v)*(-I+k),Bs=(-N+j)*(-K+A)-(-N+v)*(-K+At),De=(It*Bs-me*Is)/ze,Oe=(ge*Is-pe*Bs)/ze,fi=(De-v)*(De-v)+(Oe-A)*(Oe-A),Ot=v+(De-v)*G,Wt=A+(Oe-A)*G,Ut=v-(De-v)*R,Ht=A-(Oe-A)*R,va=Math.min(It*It+pe*pe,me*me+ge*ge),Es=xe?G:R,Aa=va+Es*Es*T;fi<=Aa?l.join==="bevel"||fi/T>B?(xe?(g.push(Ot,Wt),g.push(v+E*R,A+I*R),g.push(Ot,Wt),g.push(v+N*R,A+K*R)):(g.push(v-E*G,A-I*G),g.push(Ut,Ht),g.push(v-N*G,A-K*G),g.push(Ut,Ht)),w+=2):l.join==="round"?xe?(g.push(Ot,Wt),g.push(v+E*R,A+I*R),w+=Nt(v,A,v+E*R,A+I*R,v+N*R,A+K*R,g,!0)+4,g.push(Ot,Wt),g.push(v+N*R,A+K*R)):(g.push(v-E*G,A-I*G),g.push(Ut,Ht),w+=Nt(v,A,v-E*G,A-I*G,v-N*G,A-K*G,g,!1)+4,g.push(v-N*G,A-K*G),g.push(Ut,Ht)):(g.push(Ot,Wt),g.push(Ut,Ht)):(g.push(v-E*G,A-I*G),g.push(v+E*R,A+I*R),l.join==="round"?xe?w+=Nt(v,A,v+E*R,A+I*R,v+N*R,A+K*R,g,!0)+2:w+=Nt(v,A,v-E*G,A-I*G,v-N*G,A-K*G,g,!1)+2:l.join==="miter"&&fi/T<=B&&(xe?(g.push(Ut,Ht),g.push(Ut,Ht)):(g.push(Ot,Wt),g.push(Ot,Wt)),w+=2),g.push(v-N*G,A-K*G),g.push(v+N*R,A+K*R),w+=2)}M=i[(_-2)*2],k=i[(_-2)*2+1],v=i[(_-1)*2],A=i[(_-1)*2+1],E=-(k-A),I=M-v,mt=Math.sqrt(E*E+I*I),E/=mt,I/=mt,E*=S,I*=S,g.push(v-E*G,A-I*G),g.push(v+E*R,A+I*R),p||(l.cap==="round"?w+=Nt(v-E*(G-R)*.5,A-I*(G-R)*.5,v-E*G,A-I*G,v+E*R,A+I*R,g,!1)+2:l.cap==="square"&&(w+=yr(v,A,E,I,G,R,!1,g)));const Sa=xr*xr;for(let H=b;H<w+b-2;++H)M=g[H*2],k=g[H*2+1],v=g[(H+1)*2],A=g[(H+1)*2+1],j=g[(H+2)*2],At=g[(H+2)*2+1],!(Math.abs(M*(A-At)+v*(At-k)+j*(k-A))<Sa)&&o.push(H,H+1,H+2)}function jn(i,t,e,s,r,n,a){const o=lh(i,t,2);if(!o)return;for(let c=0;c<o.length;c+=3)n[a++]=o[c]+r,n[a++]=o[c+1]+r,n[a++]=o[c+2]+r;let h=r*s;for(let c=0;c<i.length;c+=2)e[h]=i[c],e[h+1]=i[c+1],h+=s}const Sl=[],vl={extension:{type:P.ShapeBuilder,name:"polygon"},build(i,t){for(let e=0;e<i.points.length;e++)t[e]=i.points[e];return t},triangulate(i,t,e,s,r,n){jn(i,Sl,t,e,s,r,n)}},Al={extension:{type:P.ShapeBuilder,name:"rectangle"},build(i,t){const e=i,s=e.x,r=e.y,n=e.width,a=e.height;return n>=0&&a>=0&&(t[0]=s,t[1]=r,t[2]=s+n,t[3]=r,t[4]=s+n,t[5]=r+a,t[6]=s,t[7]=r+a),t},triangulate(i,t,e,s,r,n){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[6],t[s+a+1]=i[7],a+=e,t[s+a]=i[4],t[s+a+1]=i[5],a+=e;const o=s/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2,r[n++]=o+1,r[n++]=o+3,r[n++]=o+2}},Tl={extension:{type:P.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,t},triangulate(i,t,e,s,r,n){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[4],t[s+a+1]=i[5];const o=s/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2}},ui={};ht.handleByMap(P.ShapeBuilder,ui);ht.add(Al,vl,Tl,Ee,xl,yl);const Cl=new O;function Ml(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r<i.instructions.length;r++){const n=i.instructions[r];if(n.action==="texture")Pl(n.data,s,e);else if(n.action==="fill"||n.action==="stroke"){const a=n.action==="stroke",o=n.data.path.shapePath,h=n.data.style,c=n.data.hole;a&&c&&_r(c.shapePath,h,null,!0,s,e),_r(o,h,c,a,s,e)}}}function Pl(i,t,e){const{vertices:s,uvs:r,indices:n}=e,a=n.length,o=s.length/2,h=[],c=ui.rectangle,l=Cl,d=i.image;l.x=i.dx,l.y=i.dy,l.width=i.dw,l.height=i.dh;const u=i.transform;c.build(l,h),u&&Xn(h,u),c.triangulate(h,s,2,o,n,a);const f=d.uvs;r.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=Mt.get(Yn);p.indexOffset=a,p.indexSize=n.length-a,p.attributeOffset=o,p.attributeSize=s.length/2-o,p.baseColor=i.style,p.alpha=i.alpha,p.texture=d,p.geometryData=e,t.push(p)}function _r(i,t,e,s,r,n){const{vertices:a,uvs:o,indices:h}=n,c=i.shapePrimitives.length-1;i.shapePrimitives.forEach(({shape:l,transform:d},u)=>{const f=h.length,p=a.length/2,y=[],g=ui[l.type];if(g.build(l,y),d&&Xn(y,d),s){const S=l.closePath??!0;bl(y,t,!1,S,a,2,p,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();kl(e.shapePath).forEach(M=>{S.push(T.length/2),T.push(...M)}),jn(T,S,a,2,p,h,f)}else g.triangulate(y,a,2,p,h,f);const _=o.length/2,w=t.texture;if(w!==L.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),fl(a,2,p,o,_,2,a.length/2-p,S))}else pl(o,_,2,a.length/2-p);const b=Mt.get(Yn);b.indexOffset=f,b.indexSize=h.length-f,b.attributeOffset=p,b.attributeSize=a.length/2-p,b.baseColor=t.color,b.alpha=t.alpha,b.texture=w,b.geometryData=n,r.push(b)})}function kl(i){if(!i)return[];const t=i.shapePrimitives,e=[];for(let s=0;s<t.length;s++){const r=t[s].shape,n=[];ui[r.type].build(r,n),e.push(n)}return e}class Gl{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Il{constructor(){this.batcher=new ul,this.instructions=new tn}init(){this.instructions.reset()}get geometry(){return D(Da,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const _s=class ss{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){ss.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??ss.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),Ml(t,e);const s=t.batchMode;t.customShader||s==="no-batch"?e.isBatchable=!1:s==="auto"&&(e.isBatchable=e.geometryData.vertices.length<400),t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=Mt.get(Il),{batches:s,geometryData:r}=this._gpuContextHash[t.uid],n=r.vertices.length,a=r.indices.length;for(let l=0;l<s.length;l++)s[l].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(n),o.ensureIndexBuffer(a),o.begin();for(let l=0;l<s.length;l++){const d=s[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=Mh(d.textures.textures,d.textures.count)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new Gl;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]&&(Mt.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(s=>{Mt.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};_s.extension={type:[P.WebGLSystem,P.WebGPUSystem,P.CanvasSystem],name:"graphicsContext"};_s.defaultOptions={bezierSmoothness:.5};let qn=_s;const Bl=8,Ke=11920929e-14,El=1;function Kn(i,t,e,s,r,n,a,o,h,c){const d=Math.min(.99,Math.max(0,c??qn.defaultOptions.bezierSmoothness));let u=(El-d)/1;return u*=u,Fl(t,e,s,r,n,a,o,h,i,u),i}function Fl(i,t,e,s,r,n,a,o,h,c){rs(i,t,e,s,r,n,a,o,h,c,0),h.push(a,o)}function rs(i,t,e,s,r,n,a,o,h,c,l){if(l>Bl)return;const d=(i+e)/2,u=(t+s)/2,f=(e+r)/2,p=(s+n)/2,y=(r+a)/2,g=(n+o)/2,_=(d+f)/2,w=(u+p)/2,b=(f+y)/2,S=(p+g)/2,T=(_+b)/2,B=(w+S)/2;if(l>0){let M=a-i,k=o-t;const v=Math.abs((e-a)*k-(s-o)*M),A=Math.abs((r-a)*k-(n-o)*M);if(v>Ke&&A>Ke){if((v+A)*(v+A)<=c*(M*M+k*k)){h.push(T,B);return}}else if(v>Ke){if(v*v<=c*(M*M+k*k)){h.push(T,B);return}}else if(A>Ke){if(A*A<=c*(M*M+k*k)){h.push(T,B);return}}else if(M=T-(i+a)/2,k=B-(t+o)/2,M*M+k*k<=c){h.push(T,B);return}}rs(i,t,d,u,_,w,T,B,h,c,l+1),rs(T,B,b,S,y,g,a,o,h,c,l+1)}const Rl=8,Ll=11920929e-14,zl=1;function Dl(i,t,e,s,r,n,a,o){const c=Math.min(.99,Math.max(0,o??qn.defaultOptions.bezierSmoothness));let l=(zl-c)/1;return l*=l,Ol(t,e,s,r,n,a,i,l),i}function Ol(i,t,e,s,r,n,a,o){ns(a,i,t,e,s,r,n,o,0),a.push(r,n)}function ns(i,t,e,s,r,n,a,o,h){if(h>Rl)return;const c=(t+s)/2,l=(e+r)/2,d=(s+n)/2,u=(r+a)/2,f=(c+d)/2,p=(l+u)/2;let y=n-t,g=a-e;const _=Math.abs((s-n)*g-(r-a)*y);if(_>Ll){if(_*_<=o*(y*y+g*g)){i.push(f,p);return}}else if(y=f-(t+n)/2,g=p-(e+a)/2,y*y+g*g<=o){i.push(f,p);return}ns(i,t,e,c,l,f,p,o,h+1),ns(i,f,p,d,u,n,a,o,h+1)}function Zn(i,t,e,s,r,n,a,o){let h=Math.abs(r-n);(!a&&r>n||a&&n>r)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=r;c*=a?-1:1;for(let d=0;d<o+1;d++){const u=Math.cos(l),f=Math.sin(l),p=t+u*s,y=e+f*s;i.push(p,y),l+=c}}function Wl(i,t,e,s,r,n){const a=i[i.length-2],h=i[i.length-1]-e,c=a-t,l=r-e,d=s-t,u=Math.abs(h*d-c*l);if(u<1e-8||n===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const f=h*h+c*c,p=l*l+d*d,y=h*l+c*d,g=n*Math.sqrt(f)/u,_=n*Math.sqrt(p)/u,w=g*y/f,b=_*y/p,S=g*d+_*c,T=g*l+_*h,B=c*(_+w),M=h*(_+w),k=d*(g+b),v=l*(g+b),A=Math.atan2(M-T,B-S),j=Math.atan2(v-T,k-S);Zn(i,S+t,T+e,n,A,j,c*l>d*h)}const Pe=Math.PI*2,Li={centerX:0,centerY:0,ang1:0,ang2:0},zi=({x:i,y:t},e,s,r,n,a,o,h)=>{i*=e,t*=s;const c=r*i-n*t,l=n*i+r*t;return h.x=c+a,h.y=l+o,h};function Ul(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,r=Math.cos(i),n=Math.sin(i),a=Math.cos(i+t),o=Math.sin(i+t);return[{x:r-n*s,y:n+r*s},{x:a+o*s,y:o-a*s},{x:a,y:o}]}const wr=(i,t,e,s)=>{const r=i*s-t*e<0?-1:1;let n=i*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Hl=(i,t,e,s,r,n,a,o,h,c,l,d,u)=>{const f=Math.pow(r,2),p=Math.pow(n,2),y=Math.pow(l,2),g=Math.pow(d,2);let _=f*p-f*g-p*y;_<0&&(_=0),_/=f*g+p*y,_=Math.sqrt(_)*(a===o?-1:1);const w=_*r/n*d,b=_*-n/r*l,S=c*w-h*b+(i+e)/2,T=h*w+c*b+(t+s)/2,B=(l-w)/r,M=(d-b)/n,k=(-l-w)/r,v=(-d-b)/n,A=wr(1,0,B,M);let j=wr(B,M,k,v);o===0&&j>0&&(j-=Pe),o===1&&j<0&&(j+=Pe),u.centerX=S,u.centerY=T,u.ang1=A,u.ang2=j};function Nl(i,t,e,s,r,n,a,o=0,h=0,c=0){if(n===0||a===0)return;const l=Math.sin(o*Pe/360),d=Math.cos(o*Pe/360),u=d*(t-s)/2+l*(e-r)/2,f=-l*(t-s)/2+d*(e-r)/2;if(u===0&&f===0)return;n=Math.abs(n),a=Math.abs(a);const p=Math.pow(u,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(a,2);p>1&&(n*=Math.sqrt(p),a*=Math.sqrt(p)),Hl(t,e,s,r,n,a,h,c,l,d,u,f,Li);let{ang1:y,ang2:g}=Li;const{centerX:_,centerY:w}=Li;let b=Math.abs(g)/(Pe/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);g/=S;let T=i[i.length-2],B=i[i.length-1];const M={x:0,y:0};for(let k=0;k<S;k++){const v=Ul(y,g),{x:A,y:j}=zi(v[0],n,a,d,l,_,w,M),{x:At,y:E}=zi(v[1],n,a,d,l,_,w,M),{x:I,y:N}=zi(v[2],n,a,d,l,_,w,M);Kn(i,T,B,A,j,At,E,I,N),T=I,B=N,y+=g}}function $l(i,t,e){const s=(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}},r=(a,o)=>{a===0?i.moveTo(o.x,o.y):i.lineTo(o.x,o.y)};let n=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){r(a,o),n=o;continue}const c=t[(a+1)%t.length],l=s(o,n),d=s(o,c);if(l.len<1e-4||d.len<1e-4){r(a,o),n=o;continue}let u=Math.asin(l.nx*d.ny-l.ny*d.nx),f=1,p=!1;l.nx*d.nx-l.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,f=-1,p=!0):u>0&&(f=-1,p=!0);const y=u/2;let g,_=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),g=Math.abs(_*Math.sin(y)/Math.cos(y))):g=h;const w=o.x+d.nx*_+-d.ny*g*f,b=o.y+d.ny*_+d.nx*g*f,S=Math.atan2(l.ny,l.nx)+Math.PI/2*f,T=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&i.moveTo(w+Math.cos(S)*g,b+Math.sin(S)*g),i.arc(w,b,g,S,T,p),n=o}}function Vl(i,t,e,s){const r=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),n=(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?i.moveTo(h.x,h.y):i.lineTo(h.x,h.y);continue}const l=t[o],d=t[(o+2)%a],u=r(l,h);let f;if(u<1e-4)f=h;else{const g=Math.min(u/2,c);f=n(h,l,g/u)}const p=r(d,h);let y;if(p<1e-4)y=h;else{const g=Math.min(p/2,c);y=n(h,d,g/p)}o===0?i.moveTo(f.x,f.y):i.lineTo(f.x,f.y),i.quadraticCurveTo(h.x,h.y,y.x,y.y,s)}}const Xl=new O;class Yl{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new vt,this._graphicsPath2D=t}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const s=this._currentPoly.points,r=s[s.length-2],n=s[s.length-1];return(r!==t||n!==e)&&s.push(t,e),this}arc(t,e,s,r,n,a){this._ensurePoly(!1);const o=this._currentPoly.points;return Zn(o,t,e,s,r,n,a),this}arcTo(t,e,s,r,n){this._ensurePoly();const a=this._currentPoly.points;return Wl(a,t,e,s,r,n),this}arcToSvg(t,e,s,r,n,a,o){const h=this._currentPoly.points;return Nl(h,this._currentPoly.lastX,this._currentPoly.lastY,a,o,t,e,s,r,n),this}bezierCurveTo(t,e,s,r,n,a,o){this._ensurePoly();const h=this._currentPoly;return Kn(this._currentPoly.points,h.lastX,h.lastY,t,e,s,r,n,a,o),this}quadraticCurveTo(t,e,s,r,n){this._ensurePoly();const a=this._currentPoly;return Dl(this._currentPoly.points,a.lastX,a.lastY,t,e,s,r,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));for(let s=0;s<t.instructions.length;s++){const r=t.instructions[s];this[r.action](...r.data)}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,r,n){return this.drawShape(new O(t,e,s,r),n),this}circle(t,e,s,r){return this.drawShape(new gs(t,e,s),r),this}poly(t,e,s){const r=new Me(t);return r.closePath=e,this.drawShape(r,s),this}regularPoly(t,e,s,r,n=0,a){r=Math.max(r|0,3);const o=-1*Math.PI/2+n,h=Math.PI*2/r,c=[];for(let l=0;l<r;l++){const d=l*h+o;c.push(t+s*Math.cos(d),e+s*Math.sin(d))}return this.poly(c,!0,a),this}roundPoly(t,e,s,r,n,a=0,o){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(t,e,s,r,a);const h=s*Math.sin(Math.PI/r)-.001;n=Math.min(n,h);const c=-1*Math.PI/2+a,l=Math.PI*2/r,d=(r-2)*Math.PI/r/2;for(let u=0;u<r;u++){const f=u*l+c,p=t+s*Math.cos(f),y=e+s*Math.sin(f),g=f+Math.PI+d,_=f-Math.PI-d,w=p+n*Math.cos(g),b=y+n*Math.sin(g),S=p+n*Math.cos(_),T=y+n*Math.sin(_);u===0?this.moveTo(w,b):this.lineTo(w,b),this.quadraticCurveTo(p,y,S,T,o)}return this.closePath()}roundShape(t,e,s=!1,r){return t.length<3?this:(s?Vl(this,t,e,r):$l(this,t,e),this.closePath())}filletRect(t,e,s,r,n){if(n===0)return this.rect(t,e,s,r);const a=Math.min(s,r)/2,o=Math.min(a,Math.max(-a,n)),h=t+s,c=e+r,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+s-d,c,d).lineTo(t+d,c).arcTo(t+l,c-l,t,c-d,d).closePath()}chamferRect(t,e,s,r,n,a){if(n<=0)return this.rect(t,e,s,r);const o=Math.min(n,Math.min(s,r)/2),h=t+s,c=e+r,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,s,r,n){return this.drawShape(new xs(t,e,s,r),n),this}roundRect(t,e,s,r,n,a){return this.drawShape(new ys(t,e,s,r,n),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new Me,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Me,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,a=s;s=n.a*s+n.c*r+n.tx,r=n.b*a+n.d*r+n.ty}this._currentPoly.points.push(s,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const s=t.instructions[e];this[s.action](...s.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let s=0;s<e.length;s++){const r=e[s],n=r.shape.getBounds(Xl);r.transform?t.addRect(n,r.transform):t.addRect(n)}return t}}class he{constructor(t){this.instructions=[],this.uid=it("graphicsPath"),this._dirty=!0,typeof t=="string"?Sh(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new Yl(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,s,r,n){const a=this.instructions[this.instructions.length-1],o=this.getLastPoint(ot.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,s,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,s){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(ot.shared);let a=0,o=0;if(!r||r.action!=="quadraticCurveTo")a=n.x,o=n.y;else{a=r.data[0],o=r.data[1];const h=n.x,c=n.y;a=h+(h-a),o=c+(c-o)}return this.instructions.push({action:"quadraticCurveTo",data:[a,o,t,e,s]}),this._dirty=!0,this}rect(t,e,s,r,n){return this.instructions.push({action:"rect",data:[t,e,s,r,n]}),this._dirty=!0,this}circle(t,e,s,r){return this.instructions.push({action:"circle",data:[t,e,s,r]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,s,r,n,a,o){n=n||r/2;const h=-1*Math.PI/2+a,c=s*2,l=Math.PI*2/c,d=[];for(let u=0;u<c;u++){const f=u%2?n:r,p=u*l+h;d.push(t+f*Math.cos(p),e+f*Math.sin(p))}return this.poly(d,!0,o),this}clone(t=!1){const e=new he;if(!t)e.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const r=this.instructions[s];e.instructions.push({action:r.action,data:r.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,s=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty;let h=0,c=0,l=0,d=0,u=0,f=0,p=0,y=0;for(let g=0;g<this.instructions.length;g++){const _=this.instructions[g],w=_.data;switch(_.action){case"moveTo":case"lineTo":h=w[0],c=w[1],w[0]=e*h+r*c+a,w[1]=s*h+n*c+o;break;case"bezierCurveTo":l=w[0],d=w[1],u=w[2],f=w[3],h=w[4],c=w[5],w[0]=e*l+r*d+a,w[1]=s*l+n*d+o,w[2]=e*u+r*f+a,w[3]=s*u+n*f+o,w[4]=e*h+r*c+a,w[5]=s*h+n*c+o;break;case"quadraticCurveTo":l=w[0],d=w[1],h=w[2],c=w[3],w[0]=e*l+r*d+a,w[1]=s*l+n*d+o,w[2]=e*h+r*c+a,w[3]=s*h+n*c+o;break;case"arcToSvg":h=w[5],c=w[6],p=w[0],y=w[1],w[0]=e*p+r*y,w[1]=s*p+n*y,w[5]=e*h+r*c+a,w[6]=s*h+n*c+o;break;case"circle":w[4]=be(w[3],t);break;case"rect":w[4]=be(w[4],t);break;case"ellipse":w[8]=be(w[8],t);break;case"roundRect":w[5]=be(w[5],t);break;case"addPath":w[0].transform(t);break;case"poly":w[2]=be(w[2],t);break;default:tt("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,s=this.instructions[e];if(!s)return t.x=0,t.y=0,t;for(;s.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;s=this.instructions[e]}switch(s.action){case"moveTo":case"lineTo":t.x=s.data[0],t.y=s.data[1];break;case"quadraticCurveTo":t.x=s.data[2],t.y=s.data[3];break;case"bezierCurveTo":t.x=s.data[4],t.y=s.data[5];break;case"arc":case"arcToSvg":t.x=s.data[5],t.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(t);break}return t}}function be(i,t){return i?i.prepend(t):t.clone()}function jl(i,t){if(typeof i=="string"){const s=document.createElement("div");s.innerHTML=i.trim(),i=s.querySelector("svg")}const e={context:t,path:new he};return Qn(i,e,null,null),t}function Qn(i,t,e,s){const r=i.children,{fillStyle:n,strokeStyle:a}=ql(i);n&&e?e={...e,...n}:n&&(e=n),a&&s?s={...s,...a}:a&&(s=a),t.context.fillStyle=e,t.context.strokeStyle=s;let o,h,c,l,d,u,f,p,y,g,_,w,b,S,T,B,M;switch(i.nodeName.toLowerCase()){case"path":S=i.getAttribute("d"),T=new he(S),t.context.path(T),e&&t.context.fill(),s&&t.context.stroke();break;case"circle":f=st(i,"cx",0),p=st(i,"cy",0),y=st(i,"r",0),t.context.ellipse(f,p,y,y),e&&t.context.fill(),s&&t.context.stroke();break;case"rect":o=st(i,"x",0),h=st(i,"y",0),B=st(i,"width",0),M=st(i,"height",0),g=st(i,"rx",0),_=st(i,"ry",0),g||_?t.context.roundRect(o,h,B,M,g||_):t.context.rect(o,h,B,M),e&&t.context.fill(),s&&t.context.stroke();break;case"ellipse":f=st(i,"cx",0),p=st(i,"cy",0),g=st(i,"rx",0),_=st(i,"ry",0),t.context.beginPath(),t.context.ellipse(f,p,g,_),e&&t.context.fill(),s&&t.context.stroke();break;case"line":c=st(i,"x1",0),l=st(i,"y1",0),d=st(i,"x2",0),u=st(i,"y2",0),t.context.beginPath(),t.context.moveTo(c,l),t.context.lineTo(d,u),s&&t.context.stroke();break;case"polygon":b=i.getAttribute("points"),w=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(w,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=i.getAttribute("points"),w=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(w,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}for(let k=0;k<r.length;k++)Qn(r[k],t,e,s)}function st(i,t,e){const s=i.getAttribute(t);return s?Number(s):e}function ql(i){const t=i.getAttribute("style"),e={},s={};let r=!1,n=!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=J.shared.setValue(l).toNumber(),n=!0);break;case"stroke-width":e.width=Number(l);break;case"fill":l!=="none"&&(r=!0,s.color=J.shared.setValue(l).toNumber());break;case"fill-opacity":s.alpha=Number(l);break;case"stroke-opacity":e.alpha=Number(l);break;case"opacity":s.alpha=Number(l),e.alpha=Number(l);break}}}else{const a=i.getAttribute("stroke");a&&a!=="none"&&(n=!0,e.color=J.shared.setValue(a).toNumber(),e.width=st(i,"stroke-width",1));const o=i.getAttribute("fill");o&&o!=="none"&&(r=!0,s.color=J.shared.setValue(o).toNumber())}return{strokeStyle:n?e:null,fillStyle:r?s:null}}function Kl(i){return J.isColorLike(i)}function br(i){return i instanceof di}function Sr(i){return i instanceof Be}function Zl(i,t,e){const s=J.shared.setValue(t??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?e.alpha:s.alpha,i.texture=L.WHITE,{...e,...i}}function vr(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function Ar(i,t,e){return t.buildLinearGradient(),i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function Ql(i,t){var r;const e={...t,...i};if(e.texture){if(e.texture!==L.WHITE){const a=((r=e.matrix)==null?void 0:r.invert())||new U;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 n=e.texture.source.style;n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update())}const s=J.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e.matrix=e.matrix?e.matrix.clone():null,e}function jt(i,t){if(i==null)return null;const e={},s=i;return Kl(i)?Zl(e,i,t):br(i)?vr(e,i,t):Sr(i)?Ar(e,i,t):s.fill&&br(s.fill)?vr(s,s.fill,t):s.fill&&Sr(s.fill)?Ar(s,s.fill,t):Ql(s,t)}function ni(i,t){const{width:e,alignment:s,miterLimit:r,cap:n,join:a,...o}=t,h=jt(i,o);return h?{width:e,alignment:s,miterLimit:r,cap:n,join:a,...h}:null}const Jl=new ot,Tr=new U,ws=class wt extends ct{constructor(){super(...arguments),this.uid=it("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new he,this._transform=new U,this._fillStyle={...wt.defaultFillStyle},this._strokeStyle={...wt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new vt,this._boundsDirty=!0}clone(){const t=new wt;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=jt(t,wt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=ni(t,wt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=jt(t,wt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=jt(t,wt.defaultStrokeStyle),this}texture(t,e,s,r,n,a){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:r||0,dw:n||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?J.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new he,this}fill(t,e){let s;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r&&r.action==="stroke"?s=r.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(D(W,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=jt(t,wt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(ot.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s&&s.action==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=ni(t,wt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,r,n,a){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,s,r,n,a),this}arcTo(t,e,s,r,n){this._tick++;const a=this._transform;return this._activePath.arcTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*s+a.c*r+a.tx,a.b*s+a.d*r+a.ty,n),this}arcToSvg(t,e,s,r,n,a,o){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,s,r,n,h.a*a+h.c*o+h.tx,h.b*a+h.d*o+h.ty),this}bezierCurveTo(t,e,s,r,n,a,o){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*s+h.c*r+h.tx,h.b*s+h.d*r+h.ty,h.a*n+h.c*a+h.tx,h.b*n+h.d*a+h.ty,o),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,r){return this._tick++,this._activePath.ellipse(t,e,s,r,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,r=this._activePath.instructions,n=s.a*t+s.c*e+s.tx,a=s.b*t+s.d*e+s.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=a,this):(this._activePath.moveTo(n,a),this)}quadraticCurveTo(t,e,s,r,n){this._tick++;const a=this._transform;return this._activePath.quadraticCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*s+a.c*r+a.tx,a.b*s+a.d*r+a.ty,n),this}rect(t,e,s,r){return this._tick++,this._activePath.rect(t,e,s,r,this._transform.clone()),this}roundRect(t,e,s,r,n){return this._tick++,this._activePath.roundRect(t,e,s,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,r,n=0,a){return this._tick++,this._activePath.regularPoly(t,e,s,r,n,a),this}roundPoly(t,e,s,r,n,a){return this._tick++,this._activePath.roundPoly(t,e,s,r,n,a),this}roundShape(t,e,s,r){return this._tick++,this._activePath.roundShape(t,e,s,r),this}filletRect(t,e,s,r,n){return this._tick++,this._activePath.filletRect(t,e,s,r,n),this}chamferRect(t,e,s,r,n,a){return this._tick++,this._activePath.chamferRect(t,e,s,r,n,a),this}star(t,e,s,r,n=0,a=0){return this._tick++,this._activePath.star(t,e,s,r,n,a,this._transform.clone()),this}svg(t){return this._tick++,jl(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,s,r,n,a){return t instanceof U?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,r,n,a),this)}transform(t,e,s,r,n,a){return t instanceof U?(this._transform.append(t),this):(Tr.set(t,e,s,r,n,a),this._transform.append(Tr),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const s=this.instructions[e],r=s.action;if(r==="fill"){const n=s.data;t.addBounds(n.path.bounds)}else if(r==="texture"){const n=s.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=s.data,a=n.style.width/2,o=n.path.bounds;t.addFrame(o.minX-a,o.minY-a,o.maxX+a,o.maxY+a)}}return t}containsPoint(t){var r;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let s=!1;for(let n=0;n<e.length;n++){const a=e[n],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 f=l[d].transform,p=f?f.applyInverse(t,Jl):t;a.action==="fill"?s=u.contains(p.x,p.y):s=u.strokeContains(p.x,p.y,c.width);const y=o.hole;if(y){const g=(r=y.shapePath)==null?void 0:r.shapePrimitives;if(g)for(let _=0;_<g.length;_++)g[_].shape.contains(p.x,p.y)&&(s=!1)}if(s)return!0}}return s}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(s),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(s)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};ws.defaultFillStyle={color:16777215,alpha:1,texture:L.WHITE,matrix:null,fill:null};ws.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:L.WHITE,matrix:null,fill:null};let ft=ws;const Cr=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function tc(i){const t=[];let e=0;for(let s=0;s<Cr.length;s++){const r=`_${Cr[s]}`;t[e++]=i[r]}return e=Jn(i._fill,t,e),e=ec(i._stroke,t,e),e=ic(i.dropShadow,t,e),t.join("-")}function Jn(i,t,e){var s;return i&&(t[e++]=i.color,t[e++]=i.alpha,t[e++]=(s=i.fill)==null?void 0:s.styleKey),e}function ec(i,t,e){return i&&(e=Jn(i,t,e),t[e++]=i.width,t[e++]=i.alignment,t[e++]=i.cap,t[e++]=i.join,t[e++]=i.miterLimit),e}function ic(i,t,e){return i&&(t[e++]=i.alpha,t[e++]=i.angle,t[e++]=i.blur,t[e++]=i.distance,t[e++]=J.shared.setValue(i.color).toNumber()),e}const bs=class ee extends ct{constructor(t={}){super(),sc(t);const e={...ee.defaultTextStyle,...t};for(const s in e){const r=s;this[r]=e[s]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...ee.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...ee.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({...ft.defaultFillStyle,...t},()=>{this._fill=jt({...this._originalFill},ft.defaultFillStyle)})),this._fill=jt(t===0?"black":t,ft.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ft.defaultStrokeStyle,...t},()=>{this._stroke=ni({...this._originalStroke},ft.defaultStrokeStyle)})),this._stroke=ni(t,ft.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=tc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=ee.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new ee({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var s,r,n,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(s=this._fill)!=null&&s.texture&&this._fill.texture.destroy(o),(r=this._originalFill)!=null&&r.texture&&this._originalFill.texture.destroy(o),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,r,n)=>(s[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(J.isColorLike(t)||t instanceof Be||t instanceof di)}};bs.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};bs.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let nt=bs;function sc(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=nt.defaultDropShadow;i.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){D(W,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(J.isColorLike(e))s.color=e;else if(e instanceof Be||e instanceof di)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){D(W,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;i.fontSize==null?i.fontSize=nt.defaultTextStyle.fontSize:typeof i.fontSize=="string"?e=parseInt(i.fontSize,10):e=i.fontSize;const s=new Be(0,0,0,e*1.7),r=t.fillGradientStops.map(n=>J.shared.setValue(n).toNumber());r.forEach((n,a)=>{const o=a/(r.length-1);s.addColorStop(o,n)}),i.fill={fill:s}}}class rc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=q.get().createCanvas();s.width=t,s.height=e;const r=s.getContext("2d");return{canvas:s,context:r}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=Ls(t),e=Ls(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:r}=e,n=(s<<17)+(r<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Mr=new rc,nc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function as(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let r=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!nc.includes(r)&&(r=`"${r}"`),e[s]=r}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const Di={willReadFrequently:!0},yt=class C{static get experimentalLetterSpacingSupported(){let t=C._experimentalLetterSpacingSupported;if(t!==void 0){const e=q.get().getCanvasRenderingContext2D().prototype;t=C._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,r,n,a,o,h,c){this.text=t,this.style=e,this.width=s,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,s=C._canvas,r=e.wordWrap){var w;const n=`${t}:${e.styleKey}`;if(C._measurementCache[n])return C._measurementCache[n];const a=as(e),o=C.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=C.__context;h.font=a;const l=(r?C._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),d=new Array(l.length);let u=0;for(let b=0;b<l.length;b++){const S=C._measureText(l[b],e.letterSpacing,h);d[b]=S,u=Math.max(u,S)}const f=((w=e._stroke)==null?void 0:w.width)||0;let p=u+f;e.dropShadow&&(p+=e.dropShadow.distance);const y=e.lineHeight||o.fontSize;let g=Math.max(y,o.fontSize+f)+(l.length-1)*(y+e.leading);return e.dropShadow&&(g+=e.dropShadow.distance),new C(t,e,p,g,l,d,y+e.leading,u,o)}static _measureText(t,e,s){let r=!1;C.experimentalLetterSpacingSupported&&(C.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,r=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));let n=s.measureText(t).width;return n>0&&(r?n-=e:n+=(C.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,s=C._canvas){const r=s.getContext("2d",Di);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,d=C._collapseSpaces(l),u=C._collapseNewlines(l);let f=!d;const p=e.wordWrapWidth+c,y=C._tokenize(t);for(let g=0;g<y.length;g++){let _=y[g];if(C._isNewline(_)){if(!u){o+=C._addLine(a),f=!d,a="",n=0;continue}_=" "}if(d){const b=C.isBreakingSpace(_),S=C.isBreakingSpace(a[a.length-1]);if(b&&S)continue}const w=C._getFromCache(_,c,h,r);if(w>p)if(a!==""&&(o+=C._addLine(a),a="",n=0),C.canBreakWords(_,e.breakWords)){const b=C.wordWrapSplit(_);for(let S=0;S<b.length;S++){let T=b[S],B=T,M=1;for(;b[S+M];){const v=b[S+M];if(!C.canBreakChars(B,v,_,S,e.breakWords))T+=v;else break;B=v,M++}S+=M-1;const k=C._getFromCache(T,c,h,r);k+n>p&&(o+=C._addLine(a),f=!1,a="",n=0),a+=T,n+=k}}else{a.length>0&&(o+=C._addLine(a),a="",n=0);const b=g===y.length-1;o+=C._addLine(_,!b),f=!1,a="",n=0}else w+n>p&&(f=!1,o+=C._addLine(a),a="",n=0),(a.length>0||!C.isBreakingSpace(_)||f)&&(a+=_,n+=w)}return o+=C._addLine(a,!1),o}static _addLine(t,e=!0){return t=C._trimRight(t),t=e?`${t}
|
|
`:t,t}static _getFromCache(t,e,s,r){let n=s[t];return typeof n!="number"&&(n=C._measureText(t,e,r)+e,s[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!C.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:C._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:C._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],a=t[r+1];if(C.isBreakingSpace(n,a)||C._isNewline(n)){s!==""&&(e.push(s),s=""),e.push(n);continue}s+=n}return s!==""&&e.push(s),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,r,n){return!0}static wordWrapSplit(t){return C.graphemeSegmenter(t)}static measureFont(t){if(C._fonts[t])return C._fonts[t];const e=C._context;e.font=t;const s=e.measureText(C.METRICS_STRING+C.BASELINE_SYMBOL),r={ascent:s.actualBoundingBoxAscent,descent:s.actualBoundingBoxDescent,fontSize:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent};return C._fonts[t]=r,r}static clearMetrics(t=""){t?delete C._fonts[t]:C._fonts={}}static get _canvas(){if(!C.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",Di);if(s!=null&&s.measureText)return C.__canvas=e,e;t=q.get().createCanvas()}catch{t=q.get().createCanvas()}t.width=t.height=10,C.__canvas=t}return C.__canvas}static get _context(){return C.__context||(C.__context=C._canvas.getContext("2d",Di)),C.__context}};yt.METRICS_STRING="|ÉqÅ";yt.BASELINE_SYMBOL="M";yt.BASELINE_MULTIPLIER=1.4;yt.HEIGHT_MULTIPLIER=2;yt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})();yt.experimentalLetterSpacing=!1;yt._fonts={};yt._newlines=[10,13];yt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];yt._measurementCache={};let os=yt;function Pr(i,t){if(i.texture===L.WHITE&&!i.fill)return J.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof di){const e=i.fill,s=t.createPattern(e.texture.source.resource,"repeat"),r=e.transform.copyTo(U.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(r),s}else if(i.fill instanceof Be){const e=i.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(r=>{s.addColorStop(r.offset,J.shared.setValue(r.color).toHex())}),s}}}else{const e=t.createPattern(i.texture.source.resource,"repeat"),s=i.matrix.copyTo(U.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),e.setTransform(s),e}return tt("FillStyle not recognised",i),"red"}function ta(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e<s;e++){const r=i[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=r[0].charCodeAt(0),a=r[1].charCodeAt(0);if(a<n)throw new Error("[BitmapFont]: Invalid character range.");for(let o=n,h=a;o<=h;o++)t.push(String.fromCharCode(o))}else t.push(...Array.from(r))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const ea=class ia extends Fn{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={...ia.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;const s=e.style.clone();e.overrideFill&&(s._fill.color=16777215,s._fill.alpha=1,s._fill.texture=L.WHITE,s._fill.fill=null),this.applyFillAsTint=e.overrideFill;const r=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const n=as(s);e.overrideSize?s._stroke&&(s._stroke.width*=this.baseRenderedFontSize/r):s.fontSize=this.baseRenderedFontSize=r,this._style=s,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,this.fontMetrics=os.measureFont(n),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(t){var y,g;const e=ta(t).filter(_=>!this._currentChars.includes(_)).filter((_,w,b)=>b.indexOf(_)===w);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:r,context:n}=s.canvasAndContext,a=s.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 f=0,p=!1;for(let _=0;_<e.length;_++){const w=e[_],b=os.measureText(w,o,r,!1);b.lineHeight=b.height;const S=u*b.width*l,T=b.height*l,B=S+d*2,M=T+d*2;if(p=!1,w!==`
|
|
`&&w!=="\r"&&w!==" "&&w!==" "&&(p=!0,f=Math.ceil(Math.max(M,f))),h+B>this._textureSize&&(c+=f,f=M,h=0,c+f>this._textureSize)){a.update();const v=this._nextPage();r=v.canvasAndContext.canvas,n=v.canvasAndContext.context,a=v.texture.source,c=0}const k=S/l-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((g=o._stroke)==null?void 0:g.width)??0);if(this.chars[w]={id:w.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},p){this._drawGlyph(n,b,h+d,c+d,l,o);const v=a.width*l,A=a.height*l,j=new O(h/v*a.width,c/A*a.height,B/v*a.width,M/A*a.height);this.chars[w].texture=new L({source:a,frame:j}),h+=Math.ceil(B)}}a.update(),this._currentX=h,this._currentY=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return D(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const s=this._measureCache;for(let r=0;r<t.length;r++){const n=t[r];for(let a=0;a<this._currentChars.length;a++){const o=this._currentChars[a];let h=s[n];h||(h=s[n]=e.measureText(n).width);let c=s[o];c||(c=s[o]=e.measureText(o).width);let l=e.measureText(n+o).width,d=l-(h+c);d&&(this.chars[n].kerning[o]=d),l=e.measureText(n+o).width,d=l-(h+c),d&&(this.chars[o].kerning[n]=d)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Mr.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const s=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r=new L({source:new ce({resource:e.canvas,resolution:s,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})}),n={canvasAndContext:e,texture:r};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,s){e.fontSize=this.baseRenderedFontSize,t.scale(s,s),t.font=as(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const r=e._stroke,n=(r==null?void 0:r.width)??0;if(r&&(t.lineWidth=n,t.lineJoin=r.join,t.miterLimit=r.miterLimit,t.strokeStyle=Pr(r,t)),e._fill&&(t.fillStyle=Pr(e._fill,t)),e.dropShadow){const a=e.dropShadow,o=J.shared.setValue(a.color).toArray(),h=a.blur*s,c=a.distance*s;t.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(a.angle)*c,t.shadowOffsetY=Math.sin(a.angle)*c}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,s,r,n,a){const o=e.text,h=e.fontProperties,c=a._stroke,l=((c==null?void 0:c.width)??0)*n,d=s+l/2,u=r-l/2,f=h.descent*n,p=e.lineHeight*n;a.stroke&&l&&t.strokeText(o,d,u+p-f),a._fill&&t.fillText(o,d,u+p-f)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:s}=this.pages[t];e.canvas.width=e.canvas.width,Mr.returnCanvasAndContext(e),s.destroy(!0)}this.pages=null}};ea.defaultOptions={textureSize:512,style:new nt,mipmap:!0};let kr=ea;function ac(i,t,e,s){const r={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=e.baseLineOffset;let n=r.lines[0],a=null,o=!0;const h={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},c=p=>{const y=n.width;for(let g=0;g<h.index;g++){const _=p.positions[g];n.chars.push(p.chars[g]),n.charPositions.push(_+y)}n.width+=p.width,o=!1,h.width=0,h.index=0,h.chars.length=0},l=()=>{let p=n.chars.length-1;if(s){let y=n.chars[p];for(;y===" ";)n.width-=e.chars[y].xAdvance,y=n.chars[--p]}r.width=Math.max(r.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,r.lines.push(n),r.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,u=t.letterSpacing*d,f=t.wordWrapWidth*d;for(let p=0;p<i.length+1;p++){let y;const g=p===i.length;g||(y=i[p]);const _=e.chars[y]||e.chars[" "];if(/(?:\s)/.test(y)||y==="\r"||y===`
|
|
`||g){if(!o&&t.wordWrap&&n.width+h.width-u>f?(l(),c(h),g||n.charPositions.push(0)):(h.start=n.width,c(h),g||n.charPositions.push(0)),y==="\r"||y===`
|
|
`)n.width!==0&&l();else if(!g){const T=_.xAdvance+(_.kerning[a]||0)+u;n.width+=T,n.spaceWidth=T,n.spacesIndex.push(n.charPositions.length),n.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"?oc(r):t.align==="right"?hc(r):t.align==="justify"&&lc(r),r}function oc(i){for(let t=0;t<i.lines.length;t++){const e=i.lines[t],s=i.width/2-e.width/2;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=s}}function hc(i){for(let t=0;t<i.lines.length;t++){const e=i.lines[t],s=i.width-e.width;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=s}}function lc(i){const t=i.width;for(let e=0;e<i.lines.length;e++){const s=i.lines[e];let r=0,n=s.spacesIndex[r++],a=0;const o=s.spacesIndex.length,c=(t-s.width)/o;for(let l=0;l<s.charPositions.length;l++)l===n&&(n=s.spacesIndex[r++],a+=c),s.charPositions[l]+=a}}let Ze=0;class cc{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(t,e){var a;let s=`${e.fontFamily}-bitmap`,r=!0;if(e._fill.fill&&!e._stroke)s+=e._fill.fill.styleKey,r=!1;else if(e._stroke||e.dropShadow){let o=e.styleKey;o=o.substring(0,o.lastIndexOf("-")),s=`${o}-bitmap`,r=!1}if(!V.has(s)){const o=new kr({style:e,overrideFill:r,overrideSize:!0,...this.defaultOptions});Ze++,Ze>50&&tt("BitmapText",`You have dynamically created ${Ze} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{Ze--,V.remove(s)}),V.set(s,o)}const n=V.get(s);return(a=n.ensureCharacters)==null||a.call(n,t),n}getLayout(t,e,s=!0){const r=this.getFont(t,e);return ac([...t],e,r,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}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},D(W,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=e==null?void 0:e.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof nt?r:new nt(r),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new kr({style:n,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=ta(e.chars);return o.ensureCharacters(h.join("")),V.set(`${s}-bitmap`,o),o.once("destroy",()=>V.remove(`${s}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,s=V.get(e);s&&(V.remove(e),s.destroy())}}const Gr=new cc;class sa extends Fn{constructor(t,e){super();const{textures:s,data:r}=t;Object.keys(r.pages).forEach(n=>{const a=r.pages[parseInt(n,10)],o=s[a.id];this.pages.push({texture:o})}),Object.keys(r.chars).forEach(n=>{const a=r.chars[n],{frame:o,source:h}=s[a.page],c=new O(a.x+o.x,a.y+o.y,a.width,a.height),l=new L({source:h,frame:c});this.chars[n]={id:n.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:l}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.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){Gr.install(t)}static uninstall(t){Gr.uninstall(t)}}const Oi={test(i){return typeof i=="string"&&i.startsWith("info face=")},parse(i){const t=i.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const d in t){const u=t[d].match(/^[a-z]+/gm)[0],f=t[d].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),p={};for(const y in f){const g=f[y].split("="),_=g[0],w=g[1].replace(/"/gm,""),b=parseFloat(w),S=isNaN(b)?w:b;p[_]=S}e[u].push(p)}const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=e.info,[n]=e.common,[a]=e.distanceField??[];a&&(s.distanceField={range:parseInt(a.distanceRange,10),type:a.fieldType}),s.fontSize=parseInt(r.size,10),s.fontFamily=r.face,s.lineHeight=parseInt(n.lineHeight,10);const o=e.page;for(let d=0;d<o.length;d++)s.pages.push({id:parseInt(o[d].id,10)||0,file:o[d].file});const h={};s.baseLineOffset=s.lineHeight-parseInt(n.base,10);const c=e.char;for(let d=0;d<c.length;d++){const u=c[d],f=parseInt(u.id,10);let p=u.letter??u.char??String.fromCharCode(f);p==="space"&&(p=" "),h[f]=p,s.chars[p]={id:f,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),f=parseInt(l[d].second,10),p=parseInt(l[d].amount,10);s.chars[h[f]].kerning[h[u]]=p}return s}},Ir={test(i){const t=i;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(i){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=i.getElementsByTagName("info")[0],s=i.getElementsByTagName("common")[0],r=i.getElementsByTagName("distanceField")[0];r&&(t.distanceField={type:r.getAttribute("fieldType"),range:parseInt(r.getAttribute("distanceRange"),10)});const n=i.getElementsByTagName("page"),a=i.getElementsByTagName("char"),o=i.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let c=0;c<n.length;c++)t.pages.push({id:parseInt(n[c].getAttribute("id"),10)||0,file:n[c].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(s.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}},Br={test(i){return typeof i=="string"&&i.includes("<font>")?Ir.test(q.get().parseXML(i)):!1},parse(i){return Ir.parse(q.get().parseXML(i))}},dc=[".xml",".fnt"],uc={extension:{type:P.CacheParser,name:"cacheBitmapFont"},test:i=>i instanceof sa,getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},fc={extension:{type:P.LoadParser,priority:Rt.Normal},name:"loadBitmapFont",test(i){return dc.includes(ut.extname(i).toLowerCase())},async testParse(i){return Oi.test(i)||Br.test(i)},async parse(i,t,e){const s=Oi.test(i)?Oi.parse(i):Br.parse(i),{src:r}=t,{pages:n}=s,a=[],o=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;d<n.length;++d){const u=n[d].file;let f=ut.join(ut.dirname(r),u);f=Yi(f,r),a.push({src:f,data:o})}const h=await e.load(a),c=a.map(d=>h[d.src]);return new sa({data:s,textures:c},r)},async load(i,t){return await(await q.get().fetch(i)).text()},async unload(i,t,e){await Promise.all(i.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),i.destroy()}};class pc{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;s<e;s++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const mc={extension:{type:P.CacheParser,name:"cacheTextureArray"},test:i=>Array.isArray(i)&&i.every(t=>t instanceof L),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((r,n)=>{e[s+(n===0?"":n+1)]=r})}),e}};async function ra(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const gc={extension:{type:P.DetectionParser,priority:1},test:async()=>ra("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},Er=["png","jpg","jpeg"],xc={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...Er],remove:async i=>i.filter(t=>!Er.includes(t))},yc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ss(i){return yc?!1:document.createElement("video").canPlayType(i)!==""}const _c={extension:{type:P.DetectionParser,priority:0},test:async()=>Ss("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},wc={extension:{type:P.DetectionParser,priority:0},test:async()=>Ss("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},bc={extension:{type:P.DetectionParser,priority:0},test:async()=>Ss("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Sc={extension:{type:P.DetectionParser,priority:0},test:async()=>ra("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};class vc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||tt(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){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))){n=c;break}}if(!n)return tt(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await n.load(t,e,this),s.parser=n;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,r,e,this))&&(r=await c.parse(r,e,this)||r,s.parser=c)}return r})(),s}async load(t,e){this._parsersValidated||this._validateParsers();let s=0;const r={},n=ri(t),a=xt(t,c=>({alias:[c],src:c,data:{}})),o=a.length,h=a.map(async c=>{const l=ut.toAbsolute(c.src);if(!r[c.src])try{this.promiseCache[l]||(this.promiseCache[l]=this._getLoadPromiseAndParser(l,c)),r[c.src]=await this.promiseCache[l].promise,e&&e(++s/o)}catch(d){throw delete this.promiseCache[l],delete r[c.src],new Error(`[Loader.load] Failed to load ${l}.
|
|
${d}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const s=xt(t,r=>({alias:[r],src:r})).map(async r=>{var o,h;const n=ut.toAbsolute(r.src),a=this.promiseCache[n];if(a){const c=await a.promise;delete this.promiseCache[n],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,c,r,this))}});await Promise.all(s)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&tt(`[Assets] loadParser name conflict "${e.name}"`):tt("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function ue(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function fe(i,t){const e=i.split("?")[0],s=ut.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const Ac=".json",Tc="application/json",Cc={extension:{type:P.LoadParser,priority:Rt.Low},name:"loadJson",test(i){return ue(i,Tc)||fe(i,Ac)},async load(i){return await(await q.get().fetch(i)).json()}},Mc=".txt",Pc="text/plain",kc={name:"loadTxt",extension:{type:P.LoadParser,priority:Rt.Low,name:"loadTxt"},test(i){return ue(i,Pc)||fe(i,Mc)},async load(i){return await(await q.get().fetch(i)).text()}},Gc=["normal","bold","100","200","300","400","500","600","700","800","900"],Ic=[".ttf",".otf",".woff",".woff2"],Bc=["font/ttf","font/otf","font/woff","font/woff2"],Ec=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Fc(i){const t=ut.extname(i),r=ut.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let n=r.length>0;for(const o of r)if(!o.match(Ec)){n=!1;break}let a=r.join(" ");return n||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const Rc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Lc(i){return Rc.test(i)?i:encodeURI(i)}const zc={extension:{type:P.LoadParser,priority:Rt.Low},name:"loadWebFont",test(i){return ue(i,Bc)||fe(i,Ic)},async load(i,t){var s,r,n;const e=q.get().getFontFaceSet();if(e){const a=[],o=((s=t.data)==null?void 0:s.family)??Fc(i),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(l=>Gc.includes(l)))??["normal"],c=t.data??{};for(let l=0;l<h.length;l++){const d=h[l],u=new FontFace(o,`url(${Lc(i)})`,{...c,weight:d});await u.load(),e.add(u),a.push(u)}return V.set(`${o}-and-url`,{url:i,fontFaces:a}),a.length===1?a[0]:a}return tt("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(i){(Array.isArray(i)?i:[i]).forEach(t=>{V.remove(t.family),q.get().getFontFaceSet().delete(t)})}};function vs(i,t=1){var s;const e=(s=de.RETINA_PREFIX)==null?void 0:s.exec(i);return e?parseFloat(e[1]):t}function As(i,t,e){i.label=e,i._sourceOrigin=e;const s=new L({source:i,label:e}),r=()=>{delete t.promiseCache[e],V.has(e)&&V.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(tt("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),s.once("destroy",()=>{i.destroyed||(tt("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),s}const Dc=".svg",Oc="image/svg+xml",Wc={extension:{type:P.LoadParser,priority:Rt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return ue(i,Oc)||fe(i,Dc)},async load(i,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Hc(i):Uc(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function Uc(i,t,e,s){var g,_,w;const n=await(await q.get().fetch(i)).blob(),a=URL.createObjectURL(n),o=new Image;o.src=a,o.crossOrigin=s,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((g=t.data)==null?void 0:g.resolution)||vs(i),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:f,...p}=t.data,y=new ce({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return As(y,e,i)}async function Hc(i){const e=await(await q.get().fetch(i)).text(),s=new ft;return s.svg(e),s}const Nc=`(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 re=null,hs=class{constructor(){re||(re=URL.createObjectURL(new Blob([Nc],{type:"application/javascript"}))),this.worker=new Worker(re)}};hs.revokeObjectURL=function(){re&&(URL.revokeObjectURL(re),re=null)};const $c=`(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 ne=null;class na{constructor(){ne||(ne=URL.createObjectURL(new Blob([$c],{type:"application/javascript"}))),this.worker=new Worker(ne)}}na.revokeObjectURL=function(){ne&&(URL.revokeObjectURL(ne),ne=null)};let Fr=0,Wi;class Vc{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 hs;e.addEventListener("message",s=>{e.terminate(),hs.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Wi===void 0&&(Wi=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Wi&&(this._createdWorkers++,t=new na().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[Fr]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Fr++,id:s})}}const Rr=new Vc,Xc=[".jpeg",".jpg",".png",".webp",".avif"],Yc=["image/jpeg","image/png","image/webp","image/avif"];async function jc(i,t){var r;const e=await q.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return((r=t==null?void 0:t.data)==null?void 0:r.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const aa={name:"loadTextures",extension:{type:P.LoadParser,priority:Rt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return ue(i,Yc)||fe(i,Xc)},async load(i,t,e){var n;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Rr.isImageBitmapSupported()?s=await Rr.loadImageBitmap(i,t):s=await jc(i,t):s=await new Promise(a=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=i,s.complete?a(s):s.onload=()=>{a(s)}});const r=new ce({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||vs(i),...t.data});return As(r,e,i)},unload(i){i.destroy(!0)}},oa=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],qc=oa.map(i=>`video/${i.substring(1)}`);function Kc(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=Qc(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function Zc(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",r),i.load();function s(){n(),t()}function r(a){n(),e(a)}function n(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",r)}})}function Qc(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const Jc={name:"loadVideo",extension:{type:P.LoadParser,name:"loadVideo"},test(i){const t=ue(i,qc),e=fe(i,oa);return t||e},async load(i,t,e){var h,c;const s={...Qe.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||vs(i),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await cn(),...t.data},r=document.createElement("video"),n={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{const d=n[l];d!==void 0&&r.setAttribute(l,d)}),s.muted===!0&&(r.muted=!0),Kc(r,i,s.crossorigin);const a=document.createElement("source");let o;if(i.startsWith("data:"))o=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){const l=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();o=Qe.MIME_TYPES[l]||`video/${l}`}return a.src=i,o&&(a.type=o),new Promise(l=>{const d=async()=>{const u=new Qe({...s,resource:r});r.removeEventListener("canplay",d),t.data.preload&&await Zc(r),l(As(u,e,i))};r.addEventListener("canplay",d),r.appendChild(a)})},unload(i){i.destroy(!0)}},ha={extension:{type:P.ResolveParser,name:"resolveTexture"},test:aa.test,parse:i=>{var t;return{resolution:parseFloat(((t=de.RETINA_PREFIX.exec(i))==null?void 0:t[1])??"1"),format:i.split(".").pop(),src:i}}},td={extension:{type:P.ResolveParser,priority:-2,name:"resolveJson"},test:i=>de.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:ha.parse};class ed{constructor(){this._detections=[],this._initialized=!1,this.resolver=new de,this.loader=new vc,this.cache=V,this._backgroundLoader=new pc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){tt("[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=((n=t.texturePreference)==null?void 0:n.resolution)??1,s=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:s}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=ri(t),r=xt(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}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return s?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const c=()=>{e==null||e(++o/h)},l=a.map(d=>{const u=r[d];return h+=Object.keys(u).length,this._mapLoadToResolve(u,c).then(f=>{n[d]=f})});return await Promise.all(l),s?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return V.get(t);const e={};for(let s=0;s<t.length;s++)e[s]=V.get(t[s]);return e}async _mapLoadToResolve(t,e){const s=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const r=await this.loader.load(s,e);this._backgroundLoader.active=!0;const n={};return s.forEach(a=>{const o=r[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{n[c]=o}),V.set(h,o)}),n}async unload(t){this._initialized||await this.init();const e=xt(t).map(r=>typeof r!="string"?r.src:r),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=xt(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{V.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,r)=>e.indexOf(s)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Te=new ed;ht.handleByList(P.LoadParser,Te.loader.parsers).handleByList(P.ResolveParser,Te.resolver.parsers).handleByList(P.CacheParser,Te.cache.parsers).handleByList(P.DetectionParser,Te.detections);ht.add(mc,xc,gc,Sc,_c,wc,bc,Cc,kc,zc,Wc,aa,Jc,fc,uc,ha,td);const Lr={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};ht.handle(P.Asset,i=>{const t=i.ref;Object.entries(Lr).filter(([e])=>!!t[e]).forEach(([e,s])=>ht.add(Object.assign(t[e],{extension:t[e].extension??s})))},i=>{const t=i.ref;Object.keys(Lr).filter(e=>!!t[e]).forEach(e=>ht.remove(t[e]))});class kt extends ai{constructor(t){t instanceof ft&&(t={context:t});const{context:e,roundPixels:s,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new ft,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new kt(this._context.clone()):(this._ownedContext=null,new kt(this._context))}lineStyle(t,e,s){D(W,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),s&&(r.alpha=s),this.context.strokeStyle=r,this}beginFill(t,e){D(W,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){D(W,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==ft.defaultStrokeStyle.width||t.color!==ft.defaultStrokeStyle.color||t.alpha!==ft.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return D(W,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return D(W,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return D(W,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return D(W,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return D(W,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return D(W,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const la=class ca extends Un{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(D(W,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...ca.defaultOptions,...e};const s=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),r=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),n=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Et({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:Z.VERTEX|Z.COPY_DST}),h=new Et({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:Z.VERTEX|Z.COPY_DST}),c=new Et({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:Z.INDEX|Z.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}};la.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let id=la;class Fe extends Y{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:s,autoUpdate:r,...n}=e,[a]=s;super({...n,texture:a instanceof L?a:a.texture}),this._textures=null,this._durations=null,this._autoUpdate=r??!0,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=s}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(bt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(bt.shared.add(this.update,this,si.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,s=this.animationSpeed*e,r=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=s/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=s;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):r!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<r||this.animationSpeed<0&&this.currentFrame>r)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;s<t.length;++s)e.push(L.from(t[s]));return new Fe(e)}static fromImages(t){const e=[];for(let s=0;s<t.length;++s)e.push(L.from(t[s]));return new Fe(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof L)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?(bt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(bt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class sd extends ai{constructor(t,e){const{text:s,resolution:r,style:n,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=s??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new lt({_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,s=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-s*this.anchor.y,t.y>=n&&t.y<=n+s)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function rd(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(D(W,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class Q extends sd{constructor(...t){const e=rd(t,"Text");super(e,nt),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=os.measureText(this._text,this._style),{width:r,height:n}=s;t.minX=-e._x*r,t.maxX=t.minX+r,t.minY=-e._y*n,t.maxY=t.minY+n}}const da=class ua extends id{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(D(W,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(t){t={...ua.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;const e=this.verticesX*this.verticesY,s=[],r=[],n=[],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,f=d/this.verticesX|0;s.push(u*h,f*c),r.push(u/a,f/o)}const l=a*o;for(let d=0;d<l;d++){const u=d%a,f=d/a|0,p=f*this.verticesX+u,y=f*this.verticesX+u+1,g=(f+1)*this.verticesX+u,_=(f+1)*this.verticesX+u+1;n.push(p,y,g,y,_,g)}this.buffers[0].data=new Float32Array(s),this.buffers[1].data=new Float32Array(r),this.indexBuffer.data=new Uint32Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};da.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let nd=da;const fa=class pa extends nd{constructor(t={}){t={...pa.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,s=this.width>e?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,a=Math.min(s,n);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};fa.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let te=fa;const ma=class ga extends ai{constructor(t){var d,u,f,p;t instanceof L&&(t={texture:t});const{width:e,height:s,leftWidth:r,rightWidth:n,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=r??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.left)??te.defaultOptions.leftWidth,this._topHeight=a??((u=h==null?void 0:h.defaultBorders)==null?void 0:u.top)??te.defaultOptions.topHeight,this._rightWidth=n??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.right)??te.defaultOptions.rightWidth,this._bottomHeight=o??((p=h==null?void 0:h.defaultBorders)==null?void 0:p.bottom)??te.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??te.defaultOptions.width,this.bounds.maxY=this._height=s??h.height??te.defaultOptions.height,this.allowChildren=!1,this.texture=h??ga.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=L.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null}};ma.defaultOptions={texture:L.EMPTY};let Lt=ma;ht.add(ka,Ga);const z=class z{static async Load(t){return this.text.text="Loading asset: "+t,await Te.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 Q({text:"Loading textures. This might take a while.",style:new nt({fill:3355443,fontSize:50})});t.x=m.app.canvas.width/2,t.y=m.app.canvas.height/2,t.anchor.set(.5,.5),m.app.stage.addChild(t),this.text=new Q({text:"",style:new nt({fill:3355443,fontSize:50})}),this.text.x=m.app.canvas.width/2,this.text.y=m.app.canvas.height/2+50,this.text.anchor.set(.5,.5),m.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/gem_frame.png").then(e=>this.GemFrame=e),this.Load("./assets/gui/heart.png").then(e=>this.HealthTexture=e),this.Load("./assets/gui/money.png").then(e=>this.GoldTexture=e),this.Load("./assets/gui/wave.png").then(e=>this.WaveTexture=e),this.Load("./assets/gui/sword_02.png").then(e=>this.SwordsTexture=e),this.Load("./assets/gui/title01.png").then(e=>this.TitleTexture=e),this.Load("./assets/gui/icons/play.png").then(e=>this.PlayIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/exclamation.png").then(e=>this.ExclamationIconTexture=e),this.Load("./assets/gui/icons/home.png").then(e=>this.HomeIconTexture=e),this.Load("./assets/gui/icons/hammer.png").then(e=>this.HammerIconTexture=e),this.Load("./assets/gui/icons/cross.png").then(e=>this.XIconTexture=e),this.Load("./assets/gui/icons/plus.png").then(e=>this.PlusIconTexture=e),this.LoadMissions(),this.LoadTowers(),this.LoadCreeps(),this.LoadGems()]),t.destroy(),this.text.destroy(),this.text=!0}static async LoadGems(){const e=await(await fetch("./assets/json/Gems.json")).json();this.Gems=e;for(let s=0;s<e.length;s++){const r=this.Gems[s];for(let n=1;n<=r.totalLevels;n++){const a=await this.Load(`./assets/gems/${r.type}/${n}.png`);r.textures[n-1]=a}}for(let s=0;s<7;s++)this.GemAmountIcons[s]=await this.Load(`./assets/gui/gem_amount_${s}.png`)}static async LoadCreeps(){const e=await(await fetch("./assets/json/Creeps.json")).json();this.Creeps=e;for(let s=0;s<this.Creeps.length;s++){const r=this.Creeps[s];for(let n=0;n<r.textureArrayLength;n++){const a=await this.Load(`./assets/creeps/${r.name}/${n}.png`);r.textures[n]=a}}}static async LoadMissions(){z.Missions=[await this.LoadMission("./assets/missions/mission_01.json")]}static async LoadTowers(){const e=await(await fetch("./assets/json/Towers.json")).json();this.Towers=e;for(let s=0;s<this.Towers.length;s++){const r=this.Towers[s];for(let n=0;n<r.projectileTexturesArrayLength;n++){const a=await this.Load(`./assets/projectiles/${r.sprite}/${n}.png`);r.projectileTextures[n]=a}r.texture=await this.Load(`./assets/towers/${r.sprite}.png`)}}static async LoadMission(t){const s=await(await fetch(t)).json();return await this.LoadBackground(s.mapImage.url),s}static async LoadBackground(t){let e=this.MissionBackgrounds.length-1;e==-1&&(e=0),this.MissionBackgrounds[e]=await this.Load(t)}};x(z,"Frame01Texture"),x(z,"Frame02Texture"),x(z,"Frame03Texture"),x(z,"Frame04Texture"),x(z,"Frame05Texture"),x(z,"FrameInventory"),x(z,"FrameBackground"),x(z,"FrameTowerTab"),x(z,"VioletBackground"),x(z,"RedBackground"),x(z,"GreenBackground"),x(z,"BlueBackground"),x(z,"Button01Texture"),x(z,"Button02Texture"),x(z,"ButtonSmallTexture"),x(z,"HealthTexture"),x(z,"GoldTexture"),x(z,"WaveTexture"),x(z,"SwordsTexture"),x(z,"TitleTexture"),x(z,"GemFrame"),x(z,"PlayIconTexture"),x(z,"PauseIconTexture"),x(z,"ExclamationIconTexture"),x(z,"HomeIconTexture"),x(z,"HammerIconTexture"),x(z,"XIconTexture"),x(z,"PlusIconTexture"),x(z,"GemAmountIcons",[]),x(z,"Missions"),x(z,"MissionBackgrounds",[]),x(z,"Towers"),x(z,"Creeps"),x(z,"Gems"),x(z,"text");let F=z,zr=0;class ls{constructor(t,e){x(this,"texture");x(this,"level",1);x(this,"definition");x(this,"id");this.definition=F.Gems[t],this.texture=this.definition.textures[0],e?this.id="":(this.id=zr+1,zr++)}currentGemImprovement(){let t={damageUp:0,attackSpeedUp:0,rangeUp:0,timeToLiveUp:0,pierceUp:0};for(let e=0;e<this.level;e++){const s=this.definition.genericImprovements[e];t.damageUp+=s.damageUp,t.attackSpeedUp+=s.attackSpeedUp,t.rangeUp+=s.rangeUp,t.timeToLiveUp+=s.timeToLiveUp,t.pierceUp+=s.pierceUp}return t}currentGemResistanceModifications(){return this.definition.gemResistanceModifications[this.level-1]}}const et=class et{static TestSuite(){et.NotificationManager.Notify("Loaded testing suite.","danger"),et.TowerManager.ToggleChoosingTowerLocation("RESET"),et.TowerManager.PlaceTower(F.Towers[1],8,10,F.Towers[0].behaviour,!0);for(let t=0;t<29;t++)this.GameScene.MissionStats.giveGem(new ls(t%4),!0)}};x(et,"app"),x(et,"GameMaster"),x(et,"Grid"),x(et,"WaveManager"),x(et,"TowerManager"),x(et,"AnimationManager"),x(et,"NotificationManager"),x(et,"GameScene"),x(et,"latestCommit"),x(et,"GridCellSize",64),x(et,"GridColumns",25),x(et,"GridRows",17),x(et,"MouseX",0),x(et,"MouseY",0);let m=et;class ad{constructor(){x(this,"currentScene");x(this,"GameObjects",[]);m.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),m.GameMaster.currentScene.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),m.GameMaster.currentScene.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.GameObjects.forEach(e=>{e.destroy()}),this.currentScene=t,this.currentScene.init()}}class zt{constructor(t){x(this,"name",this.constructor.name);x(this,"_container",new at);x(this,"_events",new ct);x(this,"enabled",!0);x(this,"bb",new O);m.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 Zt=(i=>(i[i.Button01=0]="Button01",i[i.Button02=1]="Button02",i))(Zt||{});class le extends zt{constructor(e,s,r,n=!0){super(!0);x(this,"caption");x(this,"bounds");x(this,"buttonTexture");x(this,"buttonSprite");x(this,"buttonText");x(this,"buttonIcon");r==0&&(this.buttonTexture=F.Button01Texture),r==1&&(this.buttonTexture=F.Button02Texture),this.caption=s,this.enabled=n,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 Lt({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 Q({text:this.caption,style:new nt({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}CustomButtonLogic(){console.warn(this.name+" - Button.CustomButtonLogic() is not implemented.")}}class Dt{constructor(){x(this,"name",this.constructor.name);x(this,"_container",new at);x(this,"bb",new O);x(this,"_events",new ct)}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.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 Ct=(i=>(i[i.Restricted=0]="Restricted",i[i.Buildable=1]="Buildable",i[i.Path=9]="Path",i))(Ct||{}),qt=(i=>(i.CreepSpawned="creepSpawned",i.Finished="finished",i.NewWave="newwave",i))(qt||{}),St=(i=>(i.Died="died",i.TakenDamage="takenDamage",i.Escaped="escaped",i.Moved="moved",i))(St||{}),Re=(i=>(i.CellMouseOver="cellmouseover",i.CellMouseLeave="cellmouseleave",i))(Re||{}),Le=(i=>(i.TowerPlacedEvent="towerPlacedEvent",i.TowerSoldEvent="towerSoldEvent",i))(Le||{}),Ts=(i=>(i.GemGivenEvent="gemGivenEvent",i))(Ts||{}),Cs=(i=>(i.TowerPanelSelectGem="towerTabSelectGem",i))(Cs||{});class od extends Dt{constructor(e,s,r,n){super();x(this,"type");x(this,"row");x(this,"column");x(this,"isPath",!1);x(this,"g");x(this,"hasTowerPlaced",!1);x(this,"clickDetector");this.type=e,this.row=s,this.column=r,this.isPath=n,this.bb.x=this.column*m.GridCellSize,this.bb.y=this.row*m.GridCellSize,this.bb.width=m.GridCellSize,this.bb.height=m.GridCellSize,m.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new kt({zIndex:99,interactive:!0}),this.g=new kt({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=>{m.Grid.gridInteractionEnabled&&(m.TowerManager.isPlacingTower?m.Grid.onGridCellClicked(s,r):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!m.Grid.gridInteractionEnabled||m.GameScene.towerPanel.isShown||m.GameScene.events.emit(Re.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!m.Grid.gridInteractionEnabled||m.GameScene.towerPanel.isShown||(m.GameScene.events.emit(Re.CellMouseLeave,this),m.Grid.rangePreview.clear())}),m.GameScene.events.on(Le.TowerPlacedEvent,(a,o,h)=>{o==this.row&&h==this.column&&(this.hasTowerPlaced=!0,m.Grid.rangePreview.clear())}),m.GameScene.events.on(Le.TowerSoldEvent,(a,o,h)=>{o==this.row&&h==this.column&&(this.hasTowerPlaced=!1)})}showRangePreview(e,s){let r=16777215;e&&(r=16711680),m.Grid.rangePreview.clear(),m.Grid.rangePreview.circle(this.column*m.GridCellSize+m.GridCellSize/2,this.row*m.GridCellSize+m.GridCellSize/2,s*m.GridCellSize),m.Grid.rangePreview.fill({color:r,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=m.TowerManager.GetTowerByRowAndCol(this.row,this.column);m.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Ct.Path||this.type==Ct.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Ct.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Ct.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Ct.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class hd extends Dt{constructor(e,s){super();x(this,"gameMap");x(this,"cells",[]);x(this,"rangePreview");x(this,"creeps",[]);x(this,"gridShown",!1);x(this,"gridInteractionEnabled",!0);this.gameMap=e,m.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=m.GridCellSize*m.GridColumns,this.bb.height=m.GridCellSize*m.GridRows,m.GameMaster.currentScene.stage.addChild(this.container);let r=new Y(F.MissionBackgrounds[s]);this.container.addChild(r);for(let n=0;n<this.gameMap.columns;n++)for(let a=0;a<this.gameMap.rows;a++){let o=this.gameMap.cells[a][n];o||(o=1);const h=this.gameMap.paths.some(l=>l.some(d=>d[0]===a&&d[1]===n));h&&(o=Ct.Path);let c=new od(o,a,n,h);this.cells.push(c)}this.rangePreview=new kt({zIndex:10}),this.container.addChild(this.rangePreview)}toggleGrid(e){this.cells.forEach(s=>{if(e){e=="hide"?s.gClear():s.gDraw();return}this.gridShown?s.gClear():s.gDraw()}),e=="hide"?this.gridShown=!1:e=="show"?this.gridShown=!0:this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(St.Died,s=>{this.onCreepDiedOrEscaped(s)}),e.events.on(St.Escaped,s=>{this.onCreepDiedOrEscaped(s)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(s=>{s.dead?(this.creeps.splice(this.creeps.indexOf(s),1),s=null):s.update(e)})}getCellByRowAndCol(e,s){return this.cells.filter(r=>r.row==e&&r.column==s)[0]}onGridCellClicked(e,s){}}class ld extends Dt{constructor(e,s,r){super();x(this,"id");x(this,"creepType");x(this,"sprite");x(this,"path");x(this,"stats");x(this,"pathIndex",0);x(this,"speed");x(this,"direction",1);x(this,"healthBarGraphics",new kt);x(this,"healthBarWidth",50);x(this,"health");x(this,"maxHealth");x(this,"escaped",!1);x(this,"died",!1);x(this,"x");x(this,"y");x(this,"dead",!1);this.creepType=e,this.stats=structuredClone(F.Creeps[this.creepType].stats),this.sprite=new Fe(F.Creeps[this.creepType].textures),this.sprite.scale.x*=-1,this.sprite.anchor.set(.5,.5),this.sprite.animationSpeed=.3,this.sprite.play(),this.id=r,this.container.x=-70,this.container.y=-50,this.sprite.width=m.GridCellSize,this.sprite.height=m.GridCellSize,this.bb.width=this.sprite.width,this.speed=this.stats.speed/60,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=s,this.x=s[0][1]*m.GridCellSize+m.GridCellSize/2,this.y=s[0][0]*m.GridCellSize+m.GridCellSize/2,m.GameScene.events.on(St.TakenDamage,(n,a)=>{n==this.id&&(this.health-=a,this.UpdateHealthbar())}),m.Grid.container.addChild(this.container),this.container.addChild(this.healthBarGraphics),this.container.addChild(this.sprite),this.UpdateHealthbar()}UpdateHealthbar(){this.healthBarGraphics.clear();const e=this.health,s=this.maxHealth,r=e/s,n=this.healthBarWidth*r;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,n,10),this.healthBarGraphics.fill({color:16711680})}update(e){if(this.dead)return;if(this.health<=0){m.GameScene.events.emit(St.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(St.Escaped,this),this.escaped=!0;return}const s=this.path[this.pathIndex],r=this.path[this.pathIndex+1],n=r[1]*m.GridCellSize+m.GridCellSize/2,a=r[0]*m.GridCellSize+m.GridCellSize/2,o=r[1]-s[1],h=r[0]-s[0];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,l=this.speed*e*h,d=!1;c>0&&this.x+c>n&&(c=n-this.x,d=!0),c<0&&this.x+c<n&&(c=n-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(St.Died,this))}destroy(){super.destroy(),this.container.removeChildren()}}class cd extends Dt{constructor(e,s){super();x(this,"creeps",[]);x(this,"rounds");x(this,"paths");x(this,"ticks",0);x(this,"started",!1);x(this,"finished",!1);x(this,"internalCreepId",0);m.WaveManager=this,this.rounds=e,this.paths=s}start(e){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1;let s=0;this.rounds[e].waves.forEach(r=>{s+=r.firstCreepSpawnTick,r.creeps.forEach(n=>{const a=new ld(n,this.paths[0],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:s,spawned:!1};console.log("CREAWTASEDASD"),s+=r.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e,this.creeps.forEach(s=>{!s.spawned&&s.tickToSpawnAt<=this.ticks?(s.spawned=!0,this.events.emit(qt.CreepSpawned,s.creep),console.log("Wave manager creep spawned, ",s,this.ticks),!this.finished&&this.creeps.every(r=>r.spawned)&&(this.finished=!0,console.log("wave maanger finisehd"),this.events.emit(qt.Finished))):s.spawned&&s.creep.update(e)}))}}class Dr extends zt{constructor(e,s,r,n,a,o,h,c){if(e>3||s>2||e<0||s<0)throw"Index/row out of bounds for TowerButton.";super(!0);x(this,"frameSprite");x(this,"background");x(this,"towerName");x(this,"iconSprite");x(this,"i",0);this.towerName=h,this.container.x=e*r+5,this.container.y=s*n+5,this.background=new Y({texture:o}),this.iconSprite=new Y({texture:c}),this.background.width=r,this.background.height=n,this.iconSprite.x=r/2,this.iconSprite.y=n/2,this.iconSprite.width=r/2,this.iconSprite.height=n/2,this.iconSprite.anchor.set(.5,.5),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.frameSprite=new Lt({texture:F.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:n,width:r}),this.container.addChild(this.frameSprite),a.addChild(this.container),m.GameScene.events.on(Le.TowerPlacedEvent,l=>{this.resetTint()}),this.container.onpointermove=l=>{m.Grid.gridInteractionEnabled!=!1&&(m.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=l=>{m.GameScene.tooltip.Hide()}}ShowTooltip(){let e;F.Towers.forEach(s=>{s.name==this.towerName&&(e=s)}),m.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),m.GameScene.tooltip.Show(m.MouseX,m.MouseY)}onClick(e){m.Grid.gridInteractionEnabled!=!1&&(m.TowerManager.isPlacingTower&&m.TowerManager.selectedTower.name!=this.towerName&&(m.GameScene.sidebar.towerTab.resetTint(),m.TowerManager.ResetChooseTower()),m.GameScene.towerPanel.Hide(),m.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,m.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class dd extends zt{constructor(e){super(!1);x(this,"bounds");x(this,"towerTabSprite");x(this,"towerButtons",[]);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new Lt({texture:F.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 Dr(0,0,70,70,this.container,F.RedBackground,"Basic Tower",F.Towers[0].texture)),this.towerButtons.push(new Dr(3,1,70,70,this.container,F.GreenBackground,"Circle Tower",F.Towers[1].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const se=class se{static init(){se.SidebarRect=new O(m.app.canvas.width-360,0,360,m.app.canvas.height),se.ChangeRoundButtonRect=new O(50,m.app.canvas.height-100,310,100)}};x(se,"SidebarRect"),x(se,"ChangeRoundButtonRect");let Ft=se;function ud(i,t){i.projectiles.forEach(e=>{e.deleteMe?(i.damageDealt+=i.computedDamageToDeal,i.projectiles.splice(i.projectiles.indexOf(e),1),e=null):e.update(t)})}function xa(i){let t=0;i.slottedGems.forEach(e=>{t+=e.currentGemImprovement().damageUp}),i.computedDamageToDeal=i.definition.stats.damage+t}function fd(i,t){i.ticksUntilNextShot%2==0&&xa(i),ud(i,t),i.ticksUntilNextShot>0&&i.ticksUntilNextShot--;let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];i.ticksUntilNextShot==0&&(i.ticksUntilNextShot=i.definition.stats.cooldown,i.Shoot(s))}}class Ms extends zt{constructor(e,s,r){super(!0);x(this,"iconSprite");x(this,"background");x(this,"frame");x(this,"i",0);x(this,"gem",null);let n;this.i=e,this.container.x=10,this.container.y=e*(m.GridCellSize+6)+300,this.background=new Y({texture:F.Frame01Texture}),r==null?n=F.PlusIconTexture:(n=r.texture,this.gem=r),this.iconSprite=new Y({texture:n,zIndex:10}),this.background.width=m.GridCellSize,this.background.height=m.GridCellSize,r==null?(this.iconSprite.x=m.GridCellSize/2,this.iconSprite.y=m.GridCellSize/2,this.iconSprite.width=m.GridCellSize/2,this.iconSprite.height=m.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=m.GridCellSize-8,this.iconSprite.height=m.GridCellSize-8),this.frame=new Y({texture:F.Frame05Texture,width:64,height:64}),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.container.addChild(this.frame);let a=r?r.id:"",o=new Q({text:a,zIndex:11,style:{fill:"white",stroke:{color:0,width:5}}});this.container.addChild(o),s.addChild(this.container)}setTint(e){this.frame.tint=e}resetTint(){this.frame.tint=16777215}}class pd extends zt{constructor(e){super(!1);x(this,"bounds");x(this,"towerPanel");x(this,"closeBtn");x(this,"vGems",[]);x(this,"showingTower",null);x(this,"isShown",!1);x(this,"titleText");x(this,"damageText");x(this,"totalDamage");x(this,"attackSpeedText");this.bounds=e,this.towerPanel=new Lt({texture:F.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 le(new O(-20,-20,60,60),"",Zt.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new Y({texture:F.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=m.app.canvas.height/2-m.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),m.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new Q({x:this.bounds.width/3,y:50,zIndex:5,style:new nt({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new Q({x:10,y:100,zIndex:5,style:new nt({fill:16753920,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.damageText),this.attackSpeedText=new Q({x:100,y:100,zIndex:5,style:new nt({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.attackSpeedText),this.totalDamage=new Q({x:10,y:130,zIndex:5,style:new nt({fill:16711680,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.totalDamage)}MakeSlots(e){this.vGems.forEach(r=>{r.destroy()}),this.vGems=[];let s=e.definition.stats.gemSlotsAmount;for(let r=0;r<s;r++){console.log("BUILDING TOWER PANEL "+r);let n=e.slottedGems[r];n||(n=null);const a=new Ms(r,this.container,n);a.resetTint(),this.vGems.push(a),a.container.onpointermove=()=>{n&&(m.GameScene.tooltip.SetContentGem(n),m.GameScene.tooltip.Show(m.MouseX,m.MouseY))},a.container.onpointerleave=()=>{m.GameScene.tooltip.Hide()},a.onClick=()=>{m.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",n,a.i,r,e),m.GameScene.events.emit(Cs.TowerPanelSelectGem,n,a.i,e),!n&&m.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,xa(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,m.GameScene.sidebar.gemTab.selectingGemTowerObject=e,e.container.parent.x<900?this.ShowRight():this.ShowLeft(),e.parent.showRangePreview(!1,e.definition.stats.range)}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.definition.stats.cooldown/60)}s`}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=Ft.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=Ft.SidebarRect.x+10,m.Grid.rangePreview.clear()}}class md extends zt{constructor(e){super(!1);x(this,"bounds");x(this,"gemTabSprite");x(this,"vGems",[]);x(this,"isSelectingGem",!1);x(this,"selectingGemSlotIndex",-1);x(this,"selectingGemTowerObject",null);x(this,"isDragAndDroppingGem",!1);x(this,"dragAndDroppingGem",null);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new Lt({texture:F.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-255,this.container.addChild(this.gemTabSprite),m.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),m.GameScene.events.on(Ts.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,s,r){console.log("TOWER PANEL SELECTING GEM "+s),s<0&&console.error("TOWER PANEL SELECTING GEM INDEX IS LESS THAN 0, ",s),this.isSelectingGem?e==null&&(this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null):(this.isSelectingGem=!0,e==null?(m.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=s,this.selectingGemTowerObject=r):(r.UnslotGem(s),this.RebuildInventoryVisual(),m.GameScene.towerPanel.Hide(),m.GameScene.towerPanel.Show(r),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!m.GameScene.towerPanel.isShown||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=m.MouseX-32,this.dragAndDroppingGem.container.y=m.MouseY-32)}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],m.GameScene.MissionStats.getInventory().forEach((e,s)=>{let r=new Ms(0,this.container,e),n=10,a=s%4*70+10,o=s;for(;!(o<=3);)n+=66,o-=4;r.container.x=a,r.container.y=n,r.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(m.GameScene.tooltip.SetContentGem(e),m.GameScene.tooltip.Show(m.MouseX,m.MouseY))},r.container.onpointerleave=()=>{m.GameScene.tooltip.Hide()},r.container.onpointerdown=()=>{if(m.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=m.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else{if(!m.GameScene.towerPanel.isShown)return;this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=r,r.container.removeFromParent(),m.GameScene.stage.addChild(r.container),this.pointerMoveEvent()}},r.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(m.GameScene.towerPanel.vGems.forEach(c=>{if(h||!this.dragAndDroppingGem)return;let l=this.dragAndDroppingGem.copyContainerToBB(),d=c.copyContainerToBB(),u=m.GameScene.towerPanel.container.x+d.x,f=m.GameScene.towerPanel.container.y+d.y,p=new O(u,f,d.width,d.height);console.log(l,p,l.getBounds().intersects(p)),l.getBounds().intersects(p)&&c&&c.gem==null&&(h=c)}),h){let c=m.GameScene.MissionStats.takeGem(e);m.GameScene.towerPanel.showingTower.SlotGem(c,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(r)})}}class gd extends zt{constructor(e){super(!1);x(this,"towerTab");x(this,"gemTab");x(this,"bounds");x(this,"sidebarSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new Lt({texture:F.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.sidebarSprite.x=40,this.sidebarSprite.y=-40,this.sidebarSprite.width=this.bounds.width+40,this.sidebarSprite.height=this.bounds.height+80,this.container.addChild(this.sidebarSprite);const s=new O(60,20,this.bounds.width-65,150);this.towerTab=new dd(s),this.container.addChild(this.towerTab.container);const r=new O(60,180,this.bounds.width-65,this.bounds.height-280);this.gemTab=new md(r),this.container.addChild(this.gemTab.container)}}class Ps{constructor(){x(this,"stage",new at);x(this,"gui",[]);x(this,"_events",new ct);m.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this.gui.forEach(t=>{t.destroy()})}get events(){return this._events}init(){}}class xd extends Dt{constructor(e,s){super();x(this,"hp",100);x(this,"gold",0);x(this,"goldText");x(this,"healthText");x(this,"waveText");x(this,"inventory",[]);x(this,"score",0);this.hp=e,this.gold=s,this.container.x=0,this.container.y=20,m.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new Q({text:`${this.hp}`,style:new nt({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new Q({text:`${this.gold}`,style:new nt({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new Q({text:`0/${m.GameScene.mission.rounds.length}`,style:new nt({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const r=new Y(F.HealthTexture),n=new Y(F.GoldTexture),a=new Y(F.WaveTexture);this.healthText.x=200,this.healthText.y=-15,r.x=160,r.width=36,r.height=32,r.y=-10,this.goldText.x=200,this.goldText.y=20,n.x=150,n.width=56,n.height=56,n.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(r),this.container.addChild(n),this.container.addChild(a),m.GameScene.events.on(qt.NewWave,o=>{this.waveText.text=`${o}/${m.GameScene.mission.rounds.length}`})}getHP(){return this.hp}hasEnoughGold(e){return e<=this.gold}setHP(e){this.hp=e,this.healthText.text=this.hp}takeDamage(e){this.hp-=e,this.healthText.text=this.hp}setGold(e){this.gold=e,this.goldText.text=this.gold}earnGold(e){this.gold+=e,this.goldText.text=this.gold}spendGold(e){this.gold-=e,this.goldText.text=this.gold}giveGem(e,s){if(this.inventory.length>=32)return m.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),s||m.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),m.GameScene.events.emit(Ts.GemGivenEvent,e)}takeGem(e){return this.inventory.splice(this.inventory.indexOf(e),1)[0]}getInventory(){return this.inventory}checkIfPlayerHasAnyGems(){return this.inventory.length>0}update(){}}function yd(i,t,e,s){const r=e-i,n=s-t;return Math.atan2(n,r)}class _d extends Dt{constructor(e,s,r,n,a,o,h){super();x(this,"deleteMe",!1);x(this,"sprite");x(this,"x");x(this,"y");x(this,"angle");x(this,"speed");x(this,"damage");x(this,"timeToLive",1);x(this,"parent");this.x=e,this.y=s,this.parent=h,this.damage=a,this.sprite=new Fe({textures:r,scale:.25,rotation:n}),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),m.GameMaster.currentScene.stage.addChild(this.container),this.angle=n,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.timeToLive<=0)return this.destroy();m.Grid.creeps.forEach(s=>{if(!(this.timeToLive<=0)&&s.container&&this.checkCollision(s)){this.timeToLive--,this.onCollide(s);return}}),this.x+=Math.cos(this.angle)*this.speed*e,this.y+=Math.sin(this.angle)*this.speed*e,this.container.x=this.x,this.container.y=this.y}}onCollide(e){m.GameScene.events.emit(St.TakenDamage,e.id,this.damage)}checkCollision(e){if(e==null)return;let s=this.copyContainerToBB(),r=e.copyContainerToBB();return s.getBounds().intersects(r.getBounds())}}function wd(i,t,e,s){return Math.sqrt((e-i)*(e-i)+(s-t)*(s-t))}class bd extends Dt{constructor(e,s,r,n,a){super();x(this,"row");x(this,"column");x(this,"definition");x(this,"slottedGems",[]);x(this,"damageDealt",0);x(this,"projectiles",[]);x(this,"behaviour");x(this,"sprite");x(this,"ticksUntilNextShot");x(this,"graphics",new kt);x(this,"computedDamageToDeal");x(this,"parent");x(this,"onParentCellEnter",e=>{!m.TowerManager.isPlacingTower&&m.Grid.gridInteractionEnabled&&!m.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.definition.stats.range)});x(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=s,this.behaviour=a,this.definition=n,this.ticksUntilNextShot=0,this.parent=m.Grid.getCellByRowAndCol(e,s),this.sprite=new Y({texture:r,height:m.GridCellSize,width:m.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),m.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,s){console.log("ATTEMPTING TO SLOT ",e,s),this.slottedGems[s]=e,m.GameScene.towerPanel.Hide(),m.GameScene.towerPanel.Show(this)}UnslotGem(e){const s=this.slottedGems.splice(e,1)[0];m.GameScene.MissionStats.giveGem(s,!0);for(let r=e;r<this.slottedGems.length-1;r++)this.slottedGems[r]==null&&(this.slottedGems[r]=this.slottedGems[r+1],this.slottedGems[r+1]=null);m.GameScene.sidebar.gemTab.selectingGemTowerObject=this,this.slottedGems=this.slottedGems.filter(r=>r!=null),m.NotificationManager.Notify(`Lv. ${s.level} ${s.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return m.Grid.creeps.filter(s=>{const r=s.x,n=s.y,a=this.column*m.GridCellSize+m.GridCellSize/2,o=this.row*m.GridCellSize+m.GridCellSize/2,h=this.definition.stats.range*m.GridCellSize;return wd(a,o,r,n)<h+m.GridCellSize*2/3})}Shoot(e){let s=this.column*m.GridCellSize+m.GridCellSize/2,r=this.row*m.GridCellSize+m.GridCellSize/2,n=yd(s,r,e.x,e.y),a=16777215;this.slottedGems.forEach(o=>{o.definition.type.toString()=="Fire"&&(a=16711680)}),this.projectiles.push(new _d(s,r,this.definition.projectileTextures,n,this.computedDamageToDeal,a,this))}update(e){this.behaviour==ya.BasicTowerBehaviour&&fd(this,e)}destroy(){super.destroy(),this.parent.clickDetector.off("pointerenter",this.onParentCellEnter),this.parent.clickDetector.off("pointerleave",this.onParentCellLeave),this.graphics.destroy()}}var ya=(i=>(i.BasicTowerBehaviour="BasicTowerBehaviour",i))(ya||{});class Sd{constructor(){x(this,"isPlacingTower",!1);x(this,"canPlaceTowers",!0);x(this,"selectedTower",null);x(this,"previewSprite",new Y({parent:m.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));x(this,"towers",[]);m.TowerManager=this,m.GameScene.events.on(Re.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*m.GridCellSize,this.previewSprite.y=t.row*m.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),m.GameScene.events.on(Re.CellMouseLeave,t=>{this.previewSprite.texture=null})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,m.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(m.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):F.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 m.NotificationManager.Notify("TowerManager.selectedTower is null when trying to place tower.","danger"),console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let s=null;return this.towers.forEach(r=>{r.row==t&&r.column==e&&(s=r)}),s}PlaceTower(t,e,s,r,n){const a=t.texture;if(!m.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!n)return m.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,s)&&m.Grid.getCellByRowAndCol(e,s).type!=Ct.Path&&m.Grid.getCellByRowAndCol(e,s).type!=Ct.Restricted){n||m.GameScene.MissionStats.spendGold(t.stats.cost);let o=new bd(e,s,a,t,r);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,m.GameScene.events.emit(Le.TowerPlacedEvent,t.name,e,s)}else m.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn"),console.warn("Can not place tower on occupied spot or path. Try again.")}update(t){this.towers.forEach(e=>{e.update(t)})}}class vd extends zt{constructor(e){super(!1);x(this,"bounds");x(this,"tooltipSprite");x(this,"titleText");x(this,"costText");x(this,"damageText");x(this,"gemAmount");x(this,"gemAmountSprite");x(this,"title");x(this,"costSprite");x(this,"damageSprite");x(this,"gemDescriptionText");this.bounds=e,this.container.x=-500,this.container.y=-500,this.container.zIndex=150,this.tooltipSprite=new Lt({texture:F.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new Q({x:this.tooltipSprite.width/2,y:-20,zIndex:5,style:new nt({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.title=new Y({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:F.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new Y({texture:F.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new Q({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 Q({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 Y({texture:F.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new Y({texture:F.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new Q({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 Q({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),m.app.stage.addChildAt(this.container,0)}SetContentTower(e,s,r,n){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 ${n} Gem slots.`,this.gemAmountSprite.texture=F.GemAmountIcons[n],this.costText.text=`Costs ${r} gold.`,this.damageText.text=`Deals ${s} base damage.`}SetContentGem(e){this.costSprite.alpha=0,this.damageSprite.alpha=0,this.gemAmountSprite.alpha=0,this.costText.alpha=0,this.damageText.alpha=0,this.gemAmount.alpha=0,this.gemDescriptionText.alpha=1,this.titleText.text=`Lv. ${e.level} `+e.definition.name,this.gemDescriptionText.text=e.definition.description}Show(e,s){this.container.alpha=1,e+this.container.width>m.app.canvas.width?this.container.x=e-this.container.width:this.container.x=e,this.container.y=s}Hide(){this.container.alpha=0,this.container.x=-500,this.container.y=-500}}class _a extends Ps{constructor(e){super();x(this,"isGameOver",!1);x(this,"mission");x(this,"missionIndex");x(this,"MissionStats");x(this,"roundMode");x(this,"ticker");x(this,"changeRoundButton");x(this,"sidebar");x(this,"tooltip");x(this,"towerPanel");x(this,"visualGems",[]);x(this,"currentRound",0);x(this,"isWaveManagerFinished",!1);x(this,"playerWon",!1);x(this,"destroyTicker",!1);x(this,"offerGemsSprite");x(this,"dimGraphics",new kt({x:0,y:0,zIndex:120}));m.GameScene=this,F.Missions.forEach((s,r)=>{s.name==e&&(this.mission=s,this.missionIndex=r)})}init(){new hd(this.mission.gameMap,this.missionIndex),new Sd,new cd(this.mission.rounds,this.mission.gameMap.paths),m.Grid.onGridCellClicked=(e,s)=>{m.TowerManager.isPlacingTower&&m.TowerManager.PlayerClickOnGrid(e,s)},m.WaveManager.events.on(qt.CreepSpawned,e=>{m.Grid.addCreep(e),e.events.on(St.Escaped,()=>{this.onCreepEscaped(e)})}),m.WaveManager.events.on(qt.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(St.Died,(e,s)=>{this.MissionStats.earnGold(e)}),this.towerPanel=new pd(Ft.SidebarRect),this.sidebar=new gd(Ft.SidebarRect),this.changeRoundButton=new le(Ft.ChangeRoundButtonRect,"",Zt.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),m.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new vd(new O(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new Y({texture:F.PlayIconTexture,x:this.changeRoundButton.container.width/2,y:this.changeRoundButton.container.height/2,scale:.2}),this.changeRoundButton.buttonIcon.anchor.set(.5,.5),this.changeRoundButton.container.addChild(this.changeRoundButton.buttonIcon)},this.changeRoundButton.CustomButtonLogic(),this.changeRoundButton.onClick=()=>{if(this.playerWon)return this.ReturnToMain();if(this.roundMode==1)return m.NotificationManager.Notify("Wave is already in progress.","warn");if(this.isGameOver)return m.NotificationManager.Notify("No more waves.","danger");this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=F.ExclamationIconTexture,this.events.emit(qt.NewWave,`${this.currentRound+1}`))},this.MissionStats=new xd(100,200),this.events.on(Cs.TowerPanelSelectGem,(e,s,r)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return m.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,s,r)}),this.ticker=new bt,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(m.MouseX,m.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}m.WaveManager.update(e),m.Grid.update(e),m.TowerManager.update(e),this.isWaveManagerFinished&&m.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=F.PlayIconTexture,m.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(m.NotificationManager.Notify("Mission victory!!","reward"),this.changeRoundButton.buttonIcon.texture=F.HomeIconTexture,this.playerWon=!0):(this.OfferPlayerGems(),this.currentRound++)),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowScoreScreen(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowScoreScreen(!1))}DarkenScreen(){this.dimGraphics.rect(0,0,m.app.canvas.width,m.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){m.Grid.gridInteractionEnabled=!1,m.GameScene.sidebar.towerTab.resetTint(),m.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new Lt({width:380,height:150,texture:F.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:m.app.canvas.width/2-190,y:m.app.canvas.height/2-75}),m.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let s=new Q({x:m.app.canvas.width/4,y:m.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}}});m.GameMaster.currentScene.stage.addChildAt(s,0),e.forEach((r,n)=>{let a=new ls(r,!0),o=new Ms(0,m.app.stage,a);this.visualGems.push(o),o.container.x=this.offerGemsSprite.x-15+69*(n+1),o.container.y=this.offerGemsSprite.y+40,o.container.onpointermove=()=>{m.GameScene.tooltip.SetContentGem(a),m.GameScene.tooltip.Show(m.MouseX,m.MouseY)},o.container.onpointerleave=()=>{m.GameScene.tooltip.Hide()},o.onClick=()=>{m.GameScene.tooltip.Hide(),s.destroy(),this.PlayerPickedGem(new ls(r))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(s=>s.destroy()),m.Grid.gridInteractionEnabled=!0,this.MissionStats.giveGem(e),this.setRoundMode(0)}ShowScoreScreen(e){console.log(e?"LOSE!":"WIN!")}onCreepEscaped(e){this.MissionStats.takeDamage(e.health)}setRoundMode(e){this.roundMode=e,this.roundMode==1?m.WaveManager.start(this.currentRound):m.WaveManager.end()}destroy(){super.destroy(),this.isGameOver=!0,this.destroyTicker=!0,m.GameScene=null}ReturnToMain(){this.destroy(),m.GameMaster.currentScene.stage.removeChildren(),m.GameMaster.changeScene(new wa)}}class wa extends Ps{init(){const t=new le(new O(0,0,300,60),"Back to main",Zt.Button01);t.onClick=e=>{m.GameMaster.changeScene(new ba)},F.Missions.forEach((e,s)=>{const r=new le(new O(m.app.canvas.width/2-150,m.app.canvas.height/5+s*80,300,60),e.name,Zt.Button01);r.onClick=n=>{m.GameMaster.changeScene(new _a(e.name))}})}}class ba extends Ps{init(){const t={caption:"New Game",rect:new O(m.app.canvas.width/2-150,m.app.canvas.height/5+240,300,60),texture:Zt.Button02},e={caption:"Settings",rect:new O(m.app.canvas.width/2-300/2,m.app.canvas.height/5+4*80,300,60),texture:Zt.Button02};let s=new Q({x:m.app.canvas.width/2-300/2,y:m.app.canvas.height/5+1*80,text:"BASTION",style:{fill:16755200,fontFamily:"Aclonica",fontSize:100}});s.x=s.x-s.width/5,m.GameMaster.currentScene.stage.addChild(s);let r=new Q({x:0,y:0,text:"Latest commit: "+m.latestCommit,style:{fill:0,fontSize:10,fontWeight:"bold"}});m.GameMaster.currentScene.stage.addChild(r);const n=new le(t.rect,t.caption,t.texture,!0);n.onClick=o=>{m.GameMaster.currentScene.stage.removeChild(s),m.GameMaster.currentScene.stage.removeChild(r),m.GameMaster.changeScene(new wa)};let a=new le(e.rect,e.caption,e.texture,!0);a.onClick=o=>{m.NotificationManager.Notify("Not finished.","info")}}}class Ad{constructor(){x(this,"finished",!1);x(this,"calledBack",!1);x(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Td extends Ad{constructor(e,s,r,n){super();x(this,"fadeType");x(this,"fadeTime");x(this,"pixiObject");x(this,"ticks",0);this.fadeType=e,this.fadeTime=s,this.pixiObject=r,this.callbackFn=n,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 Cd{constructor(){x(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const s=this.AnimationQueue[e];s.finished?(s.callbackFn(),this.AnimationQueue.splice(e,1)):s.update(t)}}}class Md{constructor(t,e,s,r,n){x(this,"textObj");x(this,"ticksToFadeAway");x(this,"animating",!1);x(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),this.ticksToFadeAway=n,this.textObj=new Q({text:t,style:new nt({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:s,y:r,zIndex:100}),this.textObj.anchor.set(.5,.5),m.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class Pd extends Dt{constructor(){super();x(this,"notifications",[]);x(this,"ticks",0);this.bb.x=m.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,m.app.stage.addChild(this.container)}Notify(e,s){let r=0,n=this.notifications.length*32;this.notifications.push(new Md(e,s,r,n,this.ticks+180))}update(e){this.ticks++;for(let s=this.notifications.length-1;s>=0;s--){const r=this.notifications[s];if(r.destroyed){this.notifications.splice(s,1);continue}this.ticks>=r.ticksToFadeAway&&!r.animating&&(r.animating=!0,m.AnimationManager.Animate(new Td("out",300,r.textObj,()=>{r.destroy()})))}}}(async()=>{const i=new En;m.app=i,await i.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(i.canvas);function t(){const s=window.innerWidth,r=window.innerHeight,n=s/i.screen.width,a=r/i.screen.height,o=Math.min(n,a),h=Math.round(i.screen.width*o),c=Math.round(i.screen.height*o),l=(s-h)/2,d=(r-c)/2;i.canvas.style.width=`${h}px`,i.canvas.style.height=`${c}px`,i.canvas.style.marginLeft=`${l}px`,i.canvas.style.marginTop=`${d}px`,i.canvas.style.marginRight="0",i.canvas.style.marginBottom="0",i.canvas.style.display="block"}m.latestCommit=await fetch("/latest_commit").then(s=>s.text()),window.addEventListener("resize",t),t(),await F.LoadAssets(),Ft.init(),new ad,m.AnimationManager=new Cd,m.NotificationManager=new Pd,globalThis.Engine=m,bt.shared.add(s=>{m.NotificationManager.update(s.elapsedMS),m.AnimationManager.update(s.elapsedMS)}),i.canvas.addEventListener("pointermove",function(s){m.MouseX=(s.clientX-i.canvas.offsetLeft)/i.canvas.offsetWidth*1920,m.MouseY=(s.clientY-i.canvas.offsetTop)/i.canvas.offsetHeight*1080}),m.GameMaster.changeScene(new ba),new URLSearchParams(location.href).entries().next().value[1]=="game"&&m.GameMaster.changeScene(new _a("Mission 1")),m.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":m.TestSuite()})();export{D as $,kn as A,Z as B,at as C,q as D,P as E,qr as F,hi as G,vt as H,js as I,Y as J,zo as K,Xo as L,U as M,it as N,O,ot as P,ch as Q,qi as R,Gh as S,Gt as T,si as U,Ks as V,go as W,vi as X,J as Y,Zr as Z,Gn as _,L as a,W as a0,mh as a1,Un as a2,tl as a3,il as a4,ol as a5,ll as a6,cl as a7,oe as a8,nt as a9,tc as aa,os as ab,Yn as ac,ar as ad,te as ae,id as af,Gr as ag,ac as ah,kt as ai,V as aj,Na as ak,as as al,Pr as am,qn as an,bt as b,ct as c,Et as d,ht as e,nr as f,Mh as g,Je as h,fs as i,Cn as j,hn as k,Sn as l,Mr as m,Ls as n,Jh as o,el as p,nl as q,eo as r,Ln as s,hl as t,ps as u,yn as v,tt as w,Ha as x,ul as y,Mt as z};
|