297 lines
285 KiB
JavaScript
297 lines
285 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-C-zGRIVb.js","assets/webworkerAll-BETg11Rx.js","assets/colorToUniform-DVGFSxpO.js","assets/WebGPURenderer-DcdHFDcE.js","assets/SharedSystems-BwpoOVEH.js","assets/WebGLRenderer-BQgw1Xbz.js"])))=>i.map(i=>d[i]);
|
|
var xa=Object.defineProperty;var ya=(s,t,e)=>t in s?xa(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var b=(s,t,e)=>ya(s,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"]'))i(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"&&i(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 i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();const _a="modulepreload",ba=function(s){return"/"+s},Pi={},Qe=function(t,e,i){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=ba(h),h in Pi)return;Pi[h]=!0;const c=h.endsWith(".css"),l=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${l}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":_a,c||(u.as="script"),u.crossOrigin="",u.href=h,o&&u.setAttribute("nonce",o),document.head.appendChild(u),c)return new Promise((d,f)=>{u.addEventListener("load",d),u.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=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(P||{});const Os=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},ze=(s,t)=>Os(s).priority??t,rt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Os).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(Os).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,r=this._queue;i[e]?(a=i[e])==null||a.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((a=n[s])==null||a.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,a)=>ze(a.value,e)-ze(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>ze(n,e)-ze(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}},wa={extension:{type:P.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Qe(()=>import("./browserAll-C-zGRIVb.js"),__vite__mapDeps([0,1,2]))}},va={extension:{type:P.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Qe(()=>import("./webworkerAll-BETg11Rx.js"),__vite__mapDeps([1,2]))}};class nt{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new nt(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 ai(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ir={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,u,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var f=new r(l,u||h,d),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 i:delete h._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,u;if(this._eventsCount===0)return c;for(u in l=this._events)t.call(l,u)&&c.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=e?e+c:c,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},o.prototype.listenerCount=function(c){var l=e?e+c:c,u=this._events[l];return u?u.fn?1:u.length:0},o.prototype.emit=function(c,l,u,d,f,p){var m=e?e+c:c;if(!this._events[m])return!1;var g=this._events[m],x=arguments.length,y,_;if(g.fn){switch(g.once&&this.removeListener(c,g.fn,void 0,!0),x){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,u),!0;case 4:return g.fn.call(g.context,l,u,d),!0;case 5:return g.fn.call(g.context,l,u,d,f),!0;case 6:return g.fn.call(g.context,l,u,d,f,p),!0}for(_=1,y=new Array(x-1);_<x;_++)y[_-1]=arguments[_];g.fn.apply(g.context,y)}else{var v=g.length,C;for(_=0;_<v;_++)switch(g[_].once&&this.removeListener(c,g[_].fn,void 0,!0),x){case 1:g[_].fn.call(g[_].context);break;case 2:g[_].fn.call(g[_].context,l);break;case 3:g[_].fn.call(g[_].context,l,u);break;case 4:g[_].fn.call(g[_].context,l,u,d);break;default:if(!y)for(C=1,y=new Array(x-1);C<x;C++)y[C-1]=arguments[C];g[_].fn.apply(g[_].context,y)}}return!0},o.prototype.on=function(c,l,u){return n(this,c,l,u,!1)},o.prototype.once=function(c,l,u){return n(this,c,l,u,!0)},o.prototype.removeListener=function(c,l,u,d){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&&(!d||p.once)&&(!u||p.context===u)&&a(this,f);else{for(var m=0,g=[],x=p.length;m<x;m++)(p[m].fn!==l||d&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);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 i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})(Ir);var Sa=Ir.exports;const at=ai(Sa),Aa=Math.PI*2,Ca=180/Math.PI,Ta=Math.PI/180;class it{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new it(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 us.x=0,us.y=0,us}}const us=new it;class O{constructor(t=1,e=0,i=0,r=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,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,i,r,n,a){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new it;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new it;const i=this.a,r=this.b,n=this.c,a=this.d,o=this.tx,h=this.ty,c=1/(i*a+n*-r),l=t.x,u=t.y;return e.x=a*c*l+-n*c*u+(h*n-o*a)*c,e.y=i*c*u+-r*c*l+(-h*i+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),i=Math.sin(t),r=this.a,n=this.c,a=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,r=t.b,n=t.c,a=t.d,o=t.tx,h=t.ty,c=e.a,l=e.b,u=e.c,d=e.d;return this.a=i*c+r*u,this.b=i*l+r*d,this.c=n*c+a*u,this.d=n*l+a*d,this.tx=o*c+h*u+e.tx,this.ty=o*l+h*d+e.ty,this}setTransform(t,e,i,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-(i*this.a+r*this.c),this.ty=e-(i*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 i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*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,i=this.b,r=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-r,n),h=Math.atan2(i,e),c=Math.abs(o+h);return c<1e-5||Math.abs(Aa-c)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(a.x*e+a.y*r),t.position.y=this.ty+(a.x*i+a.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*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 O;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 Pa.identity()}static get shared(){return Ma.identity()}}const Ma=new O,Pa=new O,zt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ot=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Wt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ut=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ws=[],Fr=[],Oe=Math.sign;function ka(){for(let s=0;s<16;s++){const t=[];Ws.push(t);for(let e=0;e<16;e++){const i=Oe(zt[s]*zt[e]+Wt[s]*Ot[e]),r=Oe(Ot[s]*zt[e]+Ut[s]*Ot[e]),n=Oe(zt[s]*Wt[e]+Wt[s]*Ut[e]),a=Oe(Ot[s]*Wt[e]+Ut[s]*Ut[e]);for(let o=0;o<16;o++)if(zt[o]===i&&Ot[o]===r&&Wt[o]===n&&Ut[o]===a){t.push(o);break}}}for(let s=0;s<16;s++){const t=new O;t.set(zt[s],Ot[s],Wt[s],Ut[s],0,0),Fr.push(t)}}ka();const N={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:s=>zt[s],uY:s=>Ot[s],vX:s=>Wt[s],vY:s=>Ut[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Ws[s][t],sub:(s,t)=>Ws[s][N.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?N.S:N.N:Math.abs(t)*2<=Math.abs(s)?s>0?N.E:N.W:t>0?s>0?N.SE:N.SW:s>0?N.NE:N.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=Fr[N.inv(t)];r.tx=e,r.ty=i,s.append(r)}},We=[new it,new it,new it,new it];class W{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),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 W(0,0,0,0)}clone(){return new W(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i){const{width:r,height:n}=this;if(r<=0||n<=0)return!1;const a=this.x,o=this.y,h=a-i/2,c=a+r+i/2,l=o-i/2,u=o+n+i/2,d=a+i/2,f=a+r-i/2,p=o+i/2,m=o+n-i/2;return t>=h&&t<=c&&e>=l&&e<=u&&!(t>d&&t<f&&e>p&&e<m)}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 i=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=i||a<=n)return!1;const o=We[0].set(t.left,t.top),h=We[1].set(t.left,t.bottom),c=We[2].set(t.right,t.top),l=We[3].set(t.right,t.bottom);if(c.x<=o.x||h.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(o,o),e.apply(h,h),e.apply(c,c),e.apply(l,l),Math.max(o.x,h.x,c.x,l.x)<=i||Math.min(o.x,h.x,c.x,l.x)>=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 d=u*(h.y-o.y),f=u*(o.x-h.x),p=d*i+f*n,m=d*r+f*n,g=d*i+f*a,x=d*r+f*a;if(Math.max(p,m,g,x)<=d*o.x+f*o.y||Math.min(p,m,g,x)>=d*l.x+f*l.y)return!1;const y=u*(o.y-c.y),_=u*(c.x-o.x),v=y*i+_*n,C=y*r+_*n,I=y*i+_*a,M=y*r+_*a;return!(Math.max(v,C,I,M)<=y*o.x+_*o.y||Math.min(v,C,I,M)>=y*l.x+_*l.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),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(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=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=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=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=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t=t||new W,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const ds={default:-1};function J(s="default"){return ds[s]===void 0&&(ds[s]=-1),++ds[s]}const ki={},z="8.0.0",Ba="8.3.4";function L(s,t,e=3){if(ki[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
Deprecated since v${s}`):(i=i.split(`
|
|
`).splice(e).join(`
|
|
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
|
|
Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
Deprecated since v${s}`),console.warn(i))),ki[t]=!0}const Rr=()=>{};function Bi(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Ei(s){return!(s&s-1)&&!!s}function Ea(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Ii=Object.create(null);function Ia(s){const t=Ii[s];return t===void 0&&(Ii[s]=J("resource")),t}const Gr=class Lr extends at{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Lr.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){L(z,"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=Ia(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Gr.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Fa=Gr;const zr=class Or extends at{constructor(t={}){super(),this.options=t,this.uid=J("textureSource"),this._resourceType="textureSource",this._resourceId=J("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={...Or.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 Fa(Ea(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=J("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=J("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=Ei(this.pixelWidth)&&Ei(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};zr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Tt=zr;class oi extends Tt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}oi.extension=P.TextureSource;const Fi=new O;class Ra{constructor(t,e){this.mapCoord=new O,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],a=t[r+1];e[r]=n*i.a+a*i.c+i.tx,e[r+1]=n*i.b+a*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,r=t.trim;r&&(Fi.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(Fi));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 G extends at{constructor({source:t,label:e,frame:i,orig:r,trim:n,defaultAnchor:a,defaultBorders:o,rotate:h,dynamic:c}={}){if(super(),this.uid=J("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new W,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new Tt,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:l,height:u}=this._source;this.frame.width=l,this.frame.height=u}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 Ra(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:r}=this._source,n=e.x/i,a=e.y/r,o=e.width/i,h=e.height/r;let c=this.rotate;if(c){const l=o/2,u=h/2,d=n+l,f=a+u;c=N.add(c,N.NW),t.x0=d+l*N.uX(c),t.y0=f+u*N.uY(c),c=N.add(c,2),t.x1=d+l*N.uX(c),t.y1=f+u*N.uY(c),c=N.add(c,2),t.x2=d+l*N.uX(c),t.y2=f+u*N.uY(c),c=N.add(c,2),t.x3=d+l*N.uX(c),t.y3=f+u*N.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 L(z,"Texture.baseTexture is now Texture.source"),this._source}}G.EMPTY=new G({label:"EMPTY",source:new Tt({label:"EMPTY"})});G.EMPTY.destroy=Rr;G.WHITE=new G({source:new oi({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});G.WHITE.destroy=Rr;function Ga(s,t,e,i){const{width:r,height:n}=e.orig,a=e.trim;if(a){const o=a.width,h=a.height;s.minX=a.x-t._x*r-i,s.maxX=s.minX+o,s.minY=a.y-t._y*n-i,s.maxY=s.minY+h}else s.minX=-t._x*r-i,s.maxX=s.minX+r,s.minY=-t._y*n-i,s.maxY=s.minY+n}const Ri=new O;class bt{constructor(t=1/0,e=1/0,i=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Ri,this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new W);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=Ri,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const a=n.a,o=n.b,h=n.c,c=n.d,l=n.tx,u=n.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=a*t+h*e+l,x=o*t+c*e+u;g<d&&(d=g),x<f&&(f=x),g>p&&(p=g),x>m&&(m=x),g=a*i+h*e+l,x=o*i+c*e+u,g<d&&(d=g),x<f&&(f=x),g>p&&(p=g),x>m&&(m=x),g=a*t+h*r+l,x=o*t+c*r+u,g<d&&(d=g),x<f&&(f=x),g>p&&(p=g),x>m&&(m=x),g=a*i+h*r+l,x=o*i+c*r+u,g<d&&(d=g),x<f&&(f=x),g>p&&(p=g),x>m&&(m=x),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,{a,b:o,c:h,d:c,tx:l,ty:u}=t;let d=a*e+h*i+l,f=o*e+c*i+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=a*r+h*i+l,f=o*r+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*e+h*n+l,f=o*e+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+h*n+l,f=o*r+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d: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,i,r){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),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 bt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,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,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let m=e;m<i;m+=2){const g=t[m],x=t[m+1],y=c*g+u*x+f,_=l*g+d*x+p;n=y<n?y:n,a=_<a?_:a,o=y>o?y:o,h=_>h?_: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 La={grad:.9,turn:360,rad:360/(2*Math.PI)},vt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},et=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},ut=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Wr=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Gi=function(s){return{r:ut(s.r,0,255),g:ut(s.g,0,255),b:ut(s.b,0,255),a:ut(s.a)}},fs=function(s){return{r:et(s.r),g:et(s.g),b:et(s.b),a:et(s.a,3)}},za=/^#([0-9a-f]{3,8})$/i,Ue=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Ur=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-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}},Dr=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),c=n%6;return{r:255*[i,o,a,a,h,i][c],g:255*[h,i,i,o,a,a][c],b:255*[a,a,h,i,i,o][c],a:r}},Li=function(s){return{h:Wr(s.h),s:ut(s.s,0,100),l:ut(s.l,0,100),a:ut(s.a)}},zi=function(s){return{h:et(s.h),s:et(s.s),l:et(s.l),a:et(s.a,3)}},Oi=function(s){return Dr((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},be=function(s){return{h:(t=Ur(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Oa=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Wa=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ua=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Da=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Us={string:[[function(s){var t=za.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?et(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?et(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=Ua.exec(s)||Da.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Gi({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=Oa.exec(s)||Wa.exec(s);if(!t)return null;var e,i,r=Li({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(La[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Oi(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return vt(t)&&vt(e)&&vt(i)?Gi({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!vt(t)||!vt(e)||!vt(i))return null;var a=Li({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Oi(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!vt(t)||!vt(e)||!vt(i))return null;var a=function(o){return{h:Wr(o.h),s:ut(o.s,0,100),v:ut(o.v,0,100),a:ut(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Dr(a)},"hsv"]]},Wi=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},Na=function(s){return typeof s=="string"?Wi(s.trim(),Us.string):typeof s=="object"&&s!==null?Wi(s,Us.object):[null,void 0]},ps=function(s,t){var e=be(s);return{h:e.h,s:ut(e.s+100*t,0,100),l:e.l,a:e.a}},gs=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},Ui=function(s,t){var e=be(s);return{h:e.h,s:e.s,l:ut(e.l+100*t,0,100),a:e.a}},Ds=function(){function s(t){this.parsed=Na(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return et(gs(this.rgba),2)},s.prototype.isDark=function(){return gs(this.rgba)<.5},s.prototype.isLight=function(){return gs(this.rgba)>=.5},s.prototype.toHex=function(){return t=fs(this.rgba),e=t.r,i=t.g,r=t.b,a=(n=t.a)<1?Ue(et(255*n)):"","#"+Ue(e)+Ue(i)+Ue(r)+a;var t,e,i,r,n,a},s.prototype.toRgb=function(){return fs(this.rgba)},s.prototype.toRgbString=function(){return t=fs(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return zi(be(this.rgba))},s.prototype.toHslString=function(){return t=zi(be(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=Ur(this.rgba),{h:et(t.h),s:et(t.s),v:et(t.v),a:et(t.a,3)};var t},s.prototype.invert=function(){return xt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),xt(ps(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),xt(ps(this.rgba,-t))},s.prototype.grayscale=function(){return xt(ps(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),xt(Ui(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),xt(Ui(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?xt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):et(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=be(this.rgba);return typeof t=="number"?xt({h:t,s:e.s,l:e.l,a:e.a}):et(e.h)},s.prototype.isEqual=function(t){return this.toHex()===xt(t).toHex()},s}(),xt=function(s){return s instanceof Ds?s:new Ds(s)},Di=[],Ha=function(s){s.forEach(function(t){Di.indexOf(t)<0&&(t(Ds,Us),Di.push(t))})};function $a(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=i[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var p in e){var m=(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));m<u&&(u=m,d=p)}return d}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new s(h).toRgb():null},"name"])}Ha([$a]);const Jt=class me{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 me)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((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,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=me._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,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 i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<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,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(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,i,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,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=me.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=xt(t);a.isValid()&&({r:e,g:i,b:r,a:n}=a.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,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,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof me||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};Jt.shared=new Jt;Jt._temp=new Jt;Jt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Z=Jt;const Va={cullArea:null,cullable:!1,cullableChildren:!0};class hi{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var i;let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class Ya{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 hi(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const St=new Ya;function ja(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n}const Xa={allowChildren:!0,removeChildren(s=0,t){const e=t??this.children.length,i=e-s,r=[];if(i>0&&i<=e){for(let a=e-1;a>=s;a--){const o=this.children[a];o&&(r.push(o),o.parent=null)}ja(this.children,s,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(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||L(z,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s.didViewUpdate=!1,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s}};class Ni{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 qa{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return St.get(i.maskClass,t)}return t}returnMaskEffect(t){St.return(t)}}const Ns=new qa;rt.handleByList(P.MaskEffect,Ns._effectClasses);const Ka={_maskEffect:null,_filterEffect:null,effects:[],addEffect(s){if(this.effects.indexOf(s)!==-1)return;this.effects.push(s),this.effects.sort((i,r)=>i.priority-r.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Ns.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Ns.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new Ni);s=s;const e=(s==null?void 0:s.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Ni),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},Za={label:null,get name(){return L(z,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){L(z,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const r=e[i];if(r.label===s||s instanceof RegExp&&s.test(r.label))return r}if(t)for(let i=0;i<e.length;i++){const n=e[i].getChildByLabel(s,!0);if(n)return n}return null},getChildrenByLabel(s,t=!1,e=[]){const i=this.children;for(let r=0;r<i.length;r++){const n=i[r];(n.label===s||s instanceof RegExp&&s.test(n.label))&&e.push(n)}if(t)for(let r=0;r<i.length;r++)i[r].getChildrenByLabel(s,!0,e);return e}},At=new hi(O),te=new hi(bt);function Nr(s,t,e){e.clear();let i,r;return s.parent?t?i=s.parent.worldTransform:(r=At.get().identity(),i=Je(s,r)):i=O.IDENTITY,Hr(s,e,i,t),r&&At.return(r),e.isValid||e.set(0,0,0,0),e}function Hr(s,t,e,i){var o,h;if(!s.visible||!s.measurable)return;let r;i?r=s.worldTransform:(s.updateLocalTransform(),r=At.get(),r.appendFrom(s.localTransform,e));const n=t,a=!!s.effects.length;if(a&&(t=te.get().clear()),s.boundsArea)t.addRect(s.boundsArea,r);else{s.addBounds&&(t.matrix=r,s.addBounds(t));for(let c=0;c<s.children.length;c++)Hr(s.children[c],t,r,i)}if(a){for(let c=0;c<s.effects.length;c++)(h=(o=s.effects[c]).addBounds)==null||h.call(o,t);n.addBounds(t,O.IDENTITY),te.return(t)}i||At.return(r)}function Je(s,t){const e=s.parent;return e&&(Je(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}let ms=0;const Hi=500;function Q(...s){ms!==Hi&&(ms++,ms===Hi?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}function $r(s,t,e){return t.clear(),e||(e=O.IDENTITY),Vr(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function Vr(s,t,e,i,r){var h,c;let n;if(r)n=At.get(),n=e.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const l=s.localTransform;n=At.get(),n.appendFrom(l,e)}const a=t,o=!!s.effects.length;if(o&&(t=te.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.renderPipeId&&(t.matrix=n,s.addBounds(t));const l=s.children;for(let u=0;u<l.length;u++)Vr(l[u],t,n,i,!1)}if(o){for(let l=0;l<s.effects.length;l++)(c=(h=s.effects[l]).addLocalBounds)==null||c.call(h,t,i);a.addBounds(t,O.IDENTITY),te.return(t)}At.return(n)}function Yr(s,t){const e=s.children;for(let i=0;i<e.length;i++){const r=e[i],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&&Yr(r,t)}return t.didChange}const Qa=new O,Ja={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=s/t*e:this.scale.x=e},_setHeight(s,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=s/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new bt});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didViewChangeTick&&(s.didChange=!0,s.data[0]=this._didViewChangeTick),Yr(this,s),s.didChange&&$r(this,s.localBounds,Qa),s.localBounds},getBounds(s,t){return Nr(this,s,t||new bt)}},to={_onRender:null,set onRender(s){const t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},eo={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(so))}};function so(s,t){return s._zIndex-t._zIndex}const io={getGlobalPosition(s=new it,t=!1){return this.parent?this.parent.toGlobal(this._position,s,t):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,t,e=!1){if(!e){this.updateLocalTransform();const i=Je(this,new O);return i.append(this.localTransform),i.apply(s,t)}return this.worldTransform.apply(s,t)},toLocal(s,t,e,i){if(t&&(s=t.toGlobal(s,e,i)),!i){this.updateLocalTransform();const r=Je(this,new O);return r.append(this.localTransform),r.applyInverse(s,e)}return this.worldTransform.applyInverse(s,e)}};let ro=0;class jr{constructor(){this.uid=J("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.tick=0}reset(){this.instructionSize=0,this.tick=ro++}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class no{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new O,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 jr,this._onRenderContainers=[]}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(t.didViewUpdate=!1,this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t))}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender()}destroy(){this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let r=0;r<i.length;r++)this._getChildren(i[r],e);return e}}function ao(s,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(s[i]=t[i])}const xs=new nt(null),ys=new nt(null),_s=new nt(null,1,1),$i=1,oo=2,bs=4;class st extends at{constructor(t={}){var e,i;super(),this.uid=J("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 O,this.relativeGroupTransform=new O,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new nt(this,0,0),this._scale=_s,this._pivot=ys,this._skew=xs,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=[],ao(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(r=>this.addChild(r)),(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(st.prototype,Object.getOwnPropertyDescriptors(t))}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||L(z,"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 i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e}removeChild(...t){if(t.length>1){for(let r=0;r<t.length;r++)this.removeChild(t[r]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=St.get(no,this),this.groupTransform=O.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),St.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 O),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*Ca}set angle(t){this.rotation=t*Ta}get pivot(){return this._pivot===ys&&(this._pivot=new nt(this,0,0)),this._pivot}set pivot(t){this._pivot===ys&&(this._pivot=new nt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===xs&&(this._skew=new nt(this,0,0)),this._skew}set skew(t){this._skew===xs&&(this._skew=new nt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===_s&&(this._scale=new nt(this,1,1)),this._scale}set scale(t){this._scale===_s&&(this._scale=new nt(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,r=this._pivot,n=this._position,a=i._x,o=i._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|=$i,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Z.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=$i,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|=oo,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|=bs,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|=bs,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|=bs,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}}st.mixin(Xa);st.mixin(io);st.mixin(to);st.mixin(Ja);st.mixin(Ka);st.mixin(Za);st.mixin(eo);st.mixin(Va);class is extends st{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=0,this._lastInstructionTick=-1,this._bounds=new bt(0,1,0,0),this._boundsDirty=!0}_updateBounds(){}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:r}=t;return i>=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class dt extends is{constructor(t=G.EMPTY){t instanceof G&&(t={texture:t});const{texture:e=G.EMPTY,anchor:i,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 nt({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i: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 G?new dt(t):new dt(G.from(t,e))}set texture(t){t||(t=G.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(){Ga(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:r,height:n}=e.orig;i.maxX=-t._x*r,i.minX=i.maxX+r,i.maxY=-t._y*n,i.minY=i.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const ho=new bt;function Xr(s,t,e){const i=ho;s.measurable=!0,Nr(s,e,i),t.addBoundsMask(i),s.measurable=!1}function qr(s,t,e){const i=te.get();s.measurable=!0;const r=At.get().identity(),n=Kr(s,e,r);$r(s,i,n),s.measurable=!1,t.addBoundsMask(i),At.return(r),te.return(i)}function Kr(s,t,e){return s?(s!==t&&(Kr(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(Q("Mask bounds, renderable is not inside the root container"),e)}class Zr{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 dt),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){Xr(this.mask,t,e)}addLocalBounds(t,e){qr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof dt}}Zr.extension=P.MaskEffect;class Qr{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"}}Qr.extension=P.MaskEffect;class Jr{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){Xr(this.mask,t,e)}addLocalBounds(t,e){qr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof st}}Jr.extension=P.MaskEffect;const lo={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let Vi=lo;const X={get(){return Vi},set(s){Vi=s}};class tn extends Tt{constructor(t){t.resource||(t.resource=X.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const r=super.resize(t,e,i);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"))}}tn.extension=P.TextureSource;class re extends Tt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=X.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,Q("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}}re.extension=P.TextureSource;var ts=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(ts||{});class ws{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,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 en=class ot{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 ws(null,null,1/0),this.deltaMS=1/ot.targetFPMS,this.elapsedMS=1/ot.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=ts.NORMAL){return this._addListener(new ws(t,e,i))}addOnce(t,e,i=ts.NORMAL){return this._addListener(new ws(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*ot.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,ot.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!ot._shared){const t=ot._shared=new ot;t.autoStart=!0,t._protected=!0}return ot._shared}static get system(){if(!ot._system){const t=ot._system=new ot;t.autoStart=!0,t._protected=!0}return ot._system}};en.targetFPMS=.06;let _t=en,vs;async function sn(){return vs??(vs=(async()=>{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),vs}const rs=class rn extends Tt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...rn.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=_t.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 sn(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,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&&(_t.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||(_t.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(_t.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};rs.extension=P.TextureSource;rs.defaultOptions={...Tt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};rs.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let qe=rs;const gt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class co{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||Q(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=gt(t);let r;for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];if(c.test(e)){r=c.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(r||{}));r||i.forEach(h=>{n.set(h,e)});const a=[...n.keys()],o={cacheKeys:a,keys:i};i.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&&Q("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){Q(`[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 H=new co,Hs=[];rt.handleByList(P.TextureSource,Hs);function nn(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r<Hs.length;r++){const n=Hs[r];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function uo(s={},t=!1){const e=s&&s.resource,i=e?s.resource:s,r=e?s:{resource:s};if(!t&&H.has(i))return H.get(i);const n=new G({source:nn(r)});return n.on("destroy",()=>{H.has(i)&&H.remove(i)}),t||H.set(i,n),n}function fo(s,t=!1){return typeof s=="string"?H.get(s):s instanceof Tt?new G({source:s}):uo(s,t)}G.from=fo;Tt.from=nn;rt.add(Zr,Qr,Jr,qe,re,tn,oi);var Bt=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(Bt||{});function pt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function de(s){return s.split("?")[0].split("#")[0]}function po(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function go(s,t,e){return s.replace(new RegExp(po(t),"g"),e)}function mo(s,t){let e="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=s.length;++o){if(o<s.length)a=s.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||n===1))if(r!==o-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,o)}`:e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const ht={toPosix(s){return go(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){pt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(pt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=de(this.toPosix(t??X.get().getBaseUrl())),r=de(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?ht.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(pt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=mo(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return pt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(pt(i),i.length>0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(pt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),a=s;s=s.slice(n.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?e?"/":this.isUrl(a)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){pt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){pt(s),t&&pt(t),s=de(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(n=s.length-1;n>=0;--n){const h=s.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&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){pt(s),s=de(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}i===-1&&(r=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){pt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=de(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,c=s.length-1,l=0;for(;c>=r;--c){if(e=s.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&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,o)):(t.name=s.slice(a,n),t.base=s.slice(a,o)),t.ext=s.slice(n,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function an(s,t,e,i,r){const n=t[e];for(let a=0;a<n.length;a++){const o=n[a];e<t.length-1?an(s.replace(i[e],o),t,e+1,i,r):r.push(s.replace(i[e],o))}}function xo(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const a=n.substring(1,n.length-1).split(",");r.push(a)}),an(s,r,0,e,i)}else i.push(s);return i}const es=s=>!Array.isArray(s);class ne{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return gt(e||i,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&&Q("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let 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);i.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));i.push(...c),h=[...o,...c]}this.add({...n,alias:h,src:a})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&Q(`[Resolver] already has key: ${n} overwriting`)},gt(e).forEach(n=>{const{src:a}=n;let{data:o,format:h,loadParser:c}=n;const l=gt(a).map(f=>typeof f=="string"?xo(f):Array.isArray(f)?f:[f]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const d=[];l.forEach(f=>{f.forEach(p=>{let m={};if(typeof p!="object"){m.src=p;for(let g=0;g<this._parsers.length;g++){const x=this._parsers[g];if(x.test(p)){m=x.parse(p);break}}}else o=p.data??o,h=p.format??h,c=p.loadParser??c,m={...m,...p};if(!u)throw new Error(`[Resolver] alias is undefined for this asset: ${m.src}`);m=this._buildResolvedAsset(m,{aliases:u,data:o,format:h,loadParser:c}),d.push(m)})}),u.forEach(f=>{this._assetMap[f]=d})})}resolveBundle(t){const e=es(t);t=gt(t);const i={};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}i[r]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=es(t);t=gt(t);const i={};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},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(i.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:i,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=ht.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??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??yo(t.src),t}}ne.RETINA_PREFIX=/@([0-9\.]+)x/;function yo(s){return s.split(".").pop().split("?").shift().split("#").shift()}const $s=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},on=class xe{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof G?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const i=parseFloat(e.meta.scale);i?(this.resolution=i,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=xe.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=xe.BATCH_SIZE;for(;e-t<i&&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 W(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);n.rotated?o=new W(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 W(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 W(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 G({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 i=0;i<t[e].length;i++){const r=t[e][i];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*xe.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*xe.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};on.BATCH_SIZE=1e3;let Yi=on;const _o=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function hn(s,t,e){const i={};if(s.forEach(r=>{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[r]=t.textures[r]}),!e){const r=ht.dirname(s[0]);t.linkedSheets.forEach((n,a)=>{const o=hn([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(i,o)})}return i}const bo={extension:P.Asset,cache:{test:s=>s instanceof Yi,getCacheableAssets:(s,t)=>hn(s,t,!1)},resolver:{extension:{type:P.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&_o.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=ne.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:P.LoadParser,priority:Bt.Normal,name:"spritesheetLoader"},async testParse(s,t){return ht.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var c,l;const{texture:i,imageFilename:r}=(t==null?void 0:t.data)??{};let n=ht.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a;if(i instanceof G)a=i;else{const u=$s(n+(r??s.meta.image),t.src);a=(await e.load([u]))[u]}const o=new Yi(a.source,s);await o.parse();const h=(c=s==null?void 0:s.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const u=[];for(const f of h){if(typeof f!="string")continue;let p=n+f;(l=t.data)!=null&&l.ignoreMultiPack||(p=$s(p,t.src),u.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const d=await Promise.all(u);o.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==f))})}return o},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};rt.add(bo);const Ss=Object.create(null),ji=Object.create(null);function li(s,t){let e=ji[s];return e===void 0&&(Ss[t]===void 0&&(Ss[t]=1),ji[s]=e=Ss[t]++),e}let Vt;function ln(){return(!Vt||Vt!=null&&Vt.isContextLost())&&(Vt=X.get().createCanvas().getContext("webgl",{})),Vt}let De;function wo(){if(!De){De="mediump";const s=ln();s&&s.getShaderPrecisionFormat&&(De=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return De}function vo(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),`
|
|
|
|
#ifdef GL_ES // This checks if it is WebGL1
|
|
#define in varying
|
|
#define finalColor gl_FragColor
|
|
#define texture texture2D
|
|
#endif
|
|
${s}
|
|
`):`
|
|
|
|
#ifdef GL_ES // This checks if it is WebGL1
|
|
#define in attribute
|
|
#define out varying
|
|
#endif
|
|
${s}
|
|
`}function So(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float;
|
|
${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Ao(s,t){return t?`#version 300 es
|
|
${s}`:s}const Co={},To={};function Mo(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?Co:To;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`}
|
|
${s}`}function Po(s,t){return t?s.replace("#version 300 es",""):s}const As={stripVersion:Po,ensurePrecision:So,addProgramDefines:vo,setProgramName:Mo,insertVersion:Ao},Cs=Object.create(null),cn=class Vs{constructor(t){t={...Vs.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:wo()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(As).forEach(a=>{const o=i[a];r=As[a](r,o,!0),n=As[a](n,o,!1)}),this.fragment=r,this.vertex=n,this._key=li(`${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 Cs[e]||(Cs[e]=new Vs(t)),Cs[e]}};cn.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let un=cn;const Xi={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 ko(s){return Xi[s]??Xi.float32}const Bo={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 Eo({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,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=Bo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:ko(h).stride,offset:0,instance:!1,start:0}}}}return e}function Ts(s){var u,d;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@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=(u=s.match(t))==null?void 0:u.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(i)[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=((d=s.match(a))==null?void 0:d.map(f=>{const p=f.match(h)[1],m=f.match(o).reduce((g,x)=>{const[y,_]=x.split(":");return g[y.trim()]=_.trim(),g},{});return m?{name:p,members:m}:null}).filter(({name:f})=>c.some(p=>p.type===f)))??[];return{groups:c,structs:l}}var ye=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(ye||{});function Io({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:ye.VERTEX|ye.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:ye.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:ye.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function Fo({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Ro(s,t){const e=new Set,i=new Set,r=[...s.structs,...t.structs].filter(a=>e.has(a.name)?!1:(e.add(a.name),!0)),n=[...s.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:r,groups:n}}const Ms=Object.create(null);class ns{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=i,e.source===i.source){const c=Ts(e.source);this.structsAndGroups=c}else{const c=Ts(i.source),l=Ts(e.source);this.structsAndGroups=Ro(c,l)}this.layout=r??Fo(this.structsAndGroups),this.gpuLayout=n??Io(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=li(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Eo(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 Ms[e]||(Ms[e]=new ns(t)),Ms[e]}}const dn=["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>"],Go=dn.reduce((s,t)=>(s[t]=!0,s),{});function Lo(s,t){switch(s){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const fn=class pn{constructor(t,e){this._touched=0,this.uid=J("uniform"),this._resourceType="uniformGroup",this._resourceId=J("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...pn.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Go[n.type])throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${dn.join(", ")}`);n.value??(n.value=Lo(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=li(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};fn.defaultOptions={ubo:!1,isStatic:!1};let gn=fn;class Ke{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const i=this.resources[e];t!==i&&(i&&((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 i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(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 i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Ys=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Ys||{});class ci extends at{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=Ys.WEBGPU),i&&(a|=Ys.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 u=o[c][l];h[u]={group:c,binding:l,name:u}}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(u=>{o[u.group]=o[u.group]||{},o[u.group][u.binding]=u.name,h[u.name]=u});let c=0;for(const l in n)h[l]||(r[99]||(r[99]=new Ke,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 u=l;let d=n[l];!d.source&&!d._resourceType&&(d=new gn(d));const f=h[u];f&&(r[f.group]||(r[f.group]=new Ke,this._ownedBindGroups.push(r[f.group])),r[f.group].setResource(d,f.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Ke,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(a){t[n.group].setResource(a,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...r}=t;let n,a;return e&&(n=ns.from(e)),i&&(a=un.from(i)),new ci({gpuProgram:n,glProgram:a,...r})}}const js=[];rt.handleByNamedList(P.Environment,js);async function zo(s){if(!s)for(let t=0;t<js.length;t++){const e=js[t];if(e.value.test()){await e.value.load();return}}}let fe;function Oo(){if(typeof fe=="boolean")return fe;try{fe=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{fe=!1}return fe}var ui={exports:{}};ui.exports=as;ui.exports.default=as;function as(s,t,e){e=e||2;var i=t&&t.length,r=i?t[0]*e:s.length,n=mn(s,0,r,e,!0),a=[];if(!n||n.next===n.prev)return a;var o,h,c,l,u,d,f;if(i&&(n=Ho(s,t,n,e)),s.length>80*e){o=c=s[0],h=l=s[1];for(var p=e;p<r;p+=e)u=s[p],d=s[p+1],u<o&&(o=u),d<h&&(h=d),u>c&&(c=u),d>l&&(l=d);f=Math.max(c-o,l-h),f=f!==0?32767/f:0}return Ae(n,a,e,o,h,f,0),a}function mn(s,t,e,i,r){var n,a;if(r===Ks(s,t,e,i)>0)for(n=t;n<e;n+=i)a=qi(n,s[n],s[n+1],a);else for(n=e-i;n>=t;n-=i)a=qi(n,s[n],s[n+1],a);return a&&os(a,a.next)&&(Te(a),a=a.next),a}function Ht(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(os(e,e.next)||$(e.prev,e,e.next)===0)){if(Te(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Ae(s,t,e,i,r,n,a){if(s){!a&&n&&Xo(s,i,r,n);for(var o=s,h,c;s.prev!==s.next;){if(h=s.prev,c=s.next,n?Uo(s,i,r,n):Wo(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(c.i/e|0),Te(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=Do(Ht(s),t,e),Ae(s,t,e,i,r,n,2)):a===2&&No(s,t,e,i,r,n):Ae(Ht(s),t,e,i,r,n,1);break}}}}function Wo(s){var t=s.prev,e=s,i=s.next;if($(t,e,i)>=0)return!1;for(var r=t.x,n=e.x,a=i.x,o=t.y,h=e.y,c=i.y,l=r<n?r<a?r:a:n<a?n:a,u=o<h?o<c?o:c:h<c?h:c,d=r>n?r>a?r:a:n>a?n:a,f=o>h?o>c?o:c:h>c?h:c,p=i.next;p!==t;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&qt(r,o,n,h,a,c,p.x,p.y)&&$(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Uo(s,t,e,i){var r=s.prev,n=s,a=s.next;if($(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,c=a.x,l=r.y,u=n.y,d=a.y,f=o<h?o<c?o:c:h<c?h:c,p=l<u?l<d?l:d:u<d?u:d,m=o>h?o>c?o:c:h>c?h:c,g=l>u?l>d?l:d:u>d?u:d,x=Xs(f,p,t,e,i),y=Xs(m,g,t,e,i),_=s.prevZ,v=s.nextZ;_&&_.z>=x&&v&&v.z<=y;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==r&&_!==a&&qt(o,l,h,u,c,d,_.x,_.y)&&$(_.prev,_,_.next)>=0||(_=_.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==r&&v!==a&&qt(o,l,h,u,c,d,v.x,v.y)&&$(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;_&&_.z>=x;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==r&&_!==a&&qt(o,l,h,u,c,d,_.x,_.y)&&$(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;v&&v.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==r&&v!==a&&qt(o,l,h,u,c,d,v.x,v.y)&&$(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Do(s,t,e){var i=s;do{var r=i.prev,n=i.next.next;!os(r,n)&&xn(r,i,i.next,n)&&Ce(r,n)&&Ce(n,r)&&(t.push(r.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Te(i),Te(i.next),i=s=n),i=i.next}while(i!==s);return Ht(i)}function No(s,t,e,i,r,n){var a=s;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Zo(a,o)){var h=yn(a,o);a=Ht(a,a.next),h=Ht(h,h.next),Ae(a,t,e,i,r,n,0),Ae(h,t,e,i,r,n,0);return}o=o.next}a=a.next}while(a!==s)}function Ho(s,t,e,i){var r=[],n,a,o,h,c;for(n=0,a=t.length;n<a;n++)o=t[n]*i,h=n<a-1?t[n+1]*i:s.length,c=mn(s,o,h,i,!1),c===c.next&&(c.steiner=!0),r.push(Ko(c));for(r.sort($o),n=0;n<r.length;n++)e=Vo(r[n],e);return e}function $o(s,t){return s.x-t.x}function Vo(s,t){var e=Yo(s,t);if(!e)return t;var i=yn(e,s);return Ht(i,i.next),Ht(e,e.next)}function Yo(s,t){var e=t,i=s.x,r=s.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<=i&&o>n&&(n=o,a=e.x<e.next.x?e:e.next,o===i))return a}e=e.next}while(e!==t);if(!a)return null;var h=a,c=a.x,l=a.y,u=1/0,d;e=a;do i>=e.x&&e.x>=c&&i!==e.x&&qt(r<l?i:n,r,c,l,r<l?n:i,r,e.x,e.y)&&(d=Math.abs(r-e.y)/(i-e.x),Ce(e,s)&&(d<u||d===u&&(e.x>a.x||e.x===a.x&&jo(a,e)))&&(a=e,u=d)),e=e.next;while(e!==h);return a}function jo(s,t){return $(s.prev,s,t.prev)<0&&$(t.next,s,s.next)<0}function Xo(s,t,e,i){var r=s;do r.z===0&&(r.z=Xs(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,qo(r)}function qo(s){var t,e,i,r,n,a,o,h,c=1;do{for(e=s,s=null,n=null,a=0;e;){for(a++,i=e,o=0,t=0;t<c&&(o++,i=i.nextZ,!!i);t++);for(h=c;o>0||h>0&&i;)o!==0&&(h===0||!i||e.z<=i.z)?(r=e,e=e.nextZ,o--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;e=i}n.nextZ=null,c*=2}while(a>1);return s}function Xs(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function Ko(s){var t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function qt(s,t,e,i,r,n,a,o){return(r-a)*(t-o)>=(s-a)*(n-o)&&(s-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(i-o)}function Zo(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Qo(s,t)&&(Ce(s,t)&&Ce(t,s)&&Jo(s,t)&&($(s.prev,s,t.prev)||$(s,t.prev,t))||os(s,t)&&$(s.prev,s,s.next)>0&&$(t.prev,t,t.next)>0)}function $(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function os(s,t){return s.x===t.x&&s.y===t.y}function xn(s,t,e,i){var r=He($(s,t,e)),n=He($(s,t,i)),a=He($(e,i,s)),o=He($(e,i,t));return!!(r!==n&&a!==o||r===0&&Ne(s,e,t)||n===0&&Ne(s,i,t)||a===0&&Ne(e,s,i)||o===0&&Ne(e,t,i))}function Ne(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function He(s){return s>0?1:s<0?-1:0}function Qo(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&xn(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Ce(s,t){return $(s.prev,s,s.next)<0?$(s,t,s.next)>=0&&$(s,s.prev,t)>=0:$(s,t,s.prev)<0||$(s,s.next,t)<0}function Jo(s,t){var e=s,i=!1,r=(s.x+t.x)/2,n=(s.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&&(i=!i),e=e.next;while(e!==s);return i}function yn(s,t){var e=new qs(s.i,s.x,s.y),i=new qs(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function qi(s,t,e,i){var r=new qs(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Te(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function qs(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}as.deviation=function(s,t,e,i){var r=t&&t.length,n=r?t[0]*e:s.length,a=Math.abs(Ks(s,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:s.length;a-=Math.abs(Ks(s,c,l,e))}var u=0;for(o=0;o<i.length;o+=3){var d=i[o]*e,f=i[o+1]*e,p=i[o+2]*e;u+=Math.abs((s[d]-s[p])*(s[f+1]-s[d+1])-(s[d]-s[f])*(s[p+1]-s[d+1]))}return a===0&&u===0?0:Math.abs((u-a)/a)};function Ks(s,t,e,i){for(var r=0,n=t,a=e-i;n<e;n+=i)r+=(s[a]-s[n])*(s[n+1]+s[a+1]),a=n;return r}as.flatten=function(s){for(var t=s[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,r=0;r<s.length;r++){for(var n=0;n<s[r].length;n++)for(var a=0;a<t;a++)e.vertices.push(s[r][n][a]);r>0&&(i+=s[r-1].length,e.holes.push(i))}return e};var th=ui.exports;const eh=ai(th);var _n=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(_n||{});class sh{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,a,o,h){const{name:c,items:l}=this;for(let u=0,d=l.length;u<d;u++)l[u][c](t,e,i,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 ih=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],bn=class wn extends at{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=[...ih,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await zo(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...wn.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){let i=t;if(i instanceof st&&(i={container:i},e&&(L(z,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor=this.background.colorRgba),i.clearColor){const r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:Z.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i)}resize(t,e,i){const r=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==r&&this.runners.resolutionChange.emit(i)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=_n.ALL);const{clear:i,clearColor:r,target:n}=t;Z.shared.setValue(r??this.background.colorRgba),e.renderTarget.clear(n,i,Z.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new sh(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,a=r.name,o=i[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(!Oo())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};bn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let vn=bn,$e;function rh(s){return $e!==void 0||($e=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??vn.defaultOptions.failIfMajorPerformanceCaveat};try{if(!X.get().getWebGLRenderingContext())return!1;let r=X.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}})()),$e}let Ve;async function nh(s={}){return Ve!==void 0||(Ve=await(async()=>{const t=X.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Ve}const Ki=["webgl","webgpu","canvas"];async function ah(s){let t=[];s.preference?(t.push(s.preference),Ki.forEach(n=>{n!==s.preference&&t.push(n)})):t=Ki.slice();let e,i={};for(let n=0;n<t.length;n++){const a=t[n];if(a==="webgpu"&&await nh()){const{WebGPURenderer:o}=await Qe(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-DcdHFDcE.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,i={...s,...s.webgpu};break}else if(a==="webgl"&&rh(s.failIfMajorPerformanceCaveat??vn.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await Qe(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-BQgw1Xbz.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,i={...s,...s.webgl};break}else if(a==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const Sn="8.4.0";class An{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Sn)}static destroy(){}}An.extension=P.Application;class oh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Sn)}destroy(){this._renderer=null}}oh.extension={type:[P.WebGLSystem,P.WebGPUSystem],name:"initHook",priority:-10};const Cn=class Zs{constructor(...t){this.stage=new st,t[0]!==void 0&&L(z,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await ah(t),Zs._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return L(z,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Zs._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Cn._plugins=[];let Tn=Cn;rt.handleByList(P.Application,Tn._plugins);rt.add(An);class Mn extends at{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 L(z,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return L(z,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return L(z,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return L(z,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return L(z,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}const Pn=class Qs{constructor(t,e,i,r){this.uid=J("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=i,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Z.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=Qs.defaultTextureSize,{gradientStops:e}=this,i=X.get().createCanvas();i.width=t,i.height=t;const r=i.getContext("2d"),n=r.createLinearGradient(0,0,Qs.defaultTextureSize,1);for(let m=0;m<e.length;m++){const g=e[m];n.addColorStop(g.offset,g.color)}r.fillStyle=n,r.fillRect(0,0,t,t),this.texture=new G({source:new re({resource:i,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:a,y0:o,x1:h,y1:c}=this,l=new O,u=h-a,d=c-o,f=Math.sqrt(u*u+d*d),p=Math.atan2(d,u);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,i=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${i}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Pn.defaultTextureSize=256;let Me=Pn;const Zi={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 hs{constructor(t,e){this.uid=J("fillPattern"),this.transform=new O,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Zi[e].addressModeU,t.source.style.addressModeV=Zi[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 hh=ch,Ps={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},lh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function ch(s){var t=[];return s.replace(lh,function(e,i,r){var n=i.toLowerCase();for(r=dh(r),n=="m"&&r.length>2&&(t.push([i].concat(r.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(r.length==Ps[n])return r.unshift(i),t.push(r);if(r.length<Ps[n])throw new Error("malformed path data");t.push([i].concat(r.splice(0,Ps[n])))}}),t}var uh=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function dh(s){var t=s.match(uh);return t?t.map(Number):[]}const fh=ai(hh);function ph(s,t){const e=fh(s),i=[];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(),i.length>0&&(r=i.pop(),r?(n=r.startX,a=r.startY):(n=0,a=0)),r=null;break;default:Q(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&r===null&&(r={startX:n,startY:a},i.push(r))}return t}class di{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new di(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,a=this.radius,o=i/2,h=Math.sqrt(r*r+n*n);return h<a+o&&h>a-o}getBounds(t){return t=t||new W,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 fi{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new fi(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const a=i/2,o=r-a,h=n-a,c=r+a,l=n+a,u=t-this.x,d=e-this.y,f=u*u/(o*o)+d*d/(h*h),p=u*u/(c*c)+d*d/(l*l);return f>1&&p<=1}getBounds(t){return t=t||new W,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 gh(s,t,e,i,r,n){const a=s-e,o=t-i,h=r-e,c=n-i,l=a*h+o*c,u=h*h+c*c;let d=-1;u!==0&&(d=l/u);let f,p;d<0?(f=e,p=i):d>1?(f=r,p=n):(f=e+d*h,p=i+d*c);const m=s-f,g=t-p;return m*m+g*g}class we{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i}this.points=e,this.closePath=!0}clone(){const t=this.points.slice(),e=new we(t);return e.closePath=this.closePath,e}contains(t,e){let i=!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&&(i=!i)}return i}strokeContains(t,e,i){const r=i/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],u=a[(h+2)%a.length],d=a[(h+3)%a.length];if(gh(t,e,c,l,u,d)<=n)return!0}return!1}getBounds(t){t=t||new W;const e=this.points;let i=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];i=c<i?c:i,r=c>r?c:r,n=l<n?l:n,a=l>a?l:a}return t.x=i,t.width=r-i,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 Ye=(s,t,e,i,r,n)=>{const a=s-e,o=t-i,h=Math.sqrt(a*a+o*o);return h>=r-n&&h<=r+n};class pi{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t=t||new W,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new pi(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(r*r+n*n<=a||(r=t-(this.x+this.width-i),r*r+n*n<=a)||(n=e-(this.y+this.height-i),r*r+n*n<=a)||(r=t-(this.x+i),r*r+n*n<=a))return!0}return!1}strokeContains(t,e,i){const{x:r,y:n,width:a,height:o,radius:h}=this,c=i/2,l=r+h,u=n+h,d=a-h*2,f=o-h*2,p=r+a,m=n+o;return(t>=r-c&&t<=r+c||t>=p-c&&t<=p+c)&&e>=u&&e<=u+f||(e>=n-c&&e<=n+c||e>=m-c&&e<=m+c)&&t>=l&&t<=l+d?!0:t<l&&e<u&&Ye(t,e,l,u,h,c)||t>p-h&&e<u&&Ye(t,e,p-h,u,h,c)||t>p-h&&e>m-h&&Ye(t,e,p-h,m-h,h,c)||t<l&&e>m-h&&Ye(t,e,l,m-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 mh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
`);function xh(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
|
|
else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function yh(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=mh.replace(/%forloop%/gi,xh(s));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}}finally{t.deleteShader(e)}return s}let Yt=null;function kn(){var t;if(Yt)return Yt;const s=ln();return Yt=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),Yt=yh(Yt,s),(t=s.getExtension("WEBGL_lose_context"))==null||t.loseContext(),Yt}const Bn={};function _h(s,t){let e=2166136261;for(let i=0;i<t;i++)e^=s[i].uid,e=Math.imul(e,16777619),e>>>=0;return Bn[e]||bh(s,t,e)}let ks=0;function bh(s,t,e){const i={};let r=0;ks||(ks=kn());for(let a=0;a<ks;a++){const o=a<t?s[a]:G.EMPTY.source;i[r++]=o.source,i[r++]=o.style}const n=new Ke(i);return Bn[e]=n,n}class Qi{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 Ji(s,t){const e=s.byteLength/8|0,i=new Float64Array(s,0,e);new Float64Array(t,0,e).set(i);const n=s.byteLength-e*8;if(n>0){const a=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(a)}}const wh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var vh=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",s[s.NONE=4]="NONE",s))(vh||{});function tr(s,t){return t.alphaMode==="no-premultiply-alpha"&&wh[s]||s}class Sh{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 Ah{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Sh,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const En=[];let Js=0;function er(){return Js>0?En[--Js]:new Ah}function sr(s){En[Js++]=s}let pe=0;const In=class Ze{constructor(t={}){this.uid=J("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],Ze.defaultOptions.maxTextures=Ze.defaultOptions.maxTextures??kn(),t={...Ze.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new Qi(i*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++)sr(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=er(),r=i.textures;r.clear();const n=e[this.elementStart];let a=tr(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,u=this._batchIndexStart,d="startBatch";const f=this.maxTextures;for(let p=this.elementStart;p<this.elementSize;++p){const m=e[p];e[p]=null;const x=m.texture._source,y=tr(m.blendMode,x),_=a!==y;if(x._batchTick===pe&&!_){m._textureId=x._textureBindLocation,l+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,o,h,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,o,h,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize)),m._batch=i;continue}x._batchTick=pe,(r.count>=f||_)&&(this._finishBatch(i,u,l-u,r,a,t,d),d="renderBatch",u=l,a=y,i=er(),r=i.textures,r.clear(),++pe),m._textureId=x._textureBindLocation=r.count,r.ids[x.uid]=r.count,r.textures[r.count++]=x,m._batch=i,l+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,o,h,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,o,h,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,u,l-u,r,a,t,d),u=l,++pe),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=l}_finishBatch(t,e,i,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=i,++pe,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new Qi(e);Ji(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)r[n]=e[n];else Ji(e.buffer,r.buffer);this.indexBuffer=r}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,r){const n=t.indices,a=t.indexSize,o=t.indexOffset,h=t.attributeOffset;for(let c=0;c<a;c++)e[i++]=r+n[c+o]-h}destroy(){for(let t=0;t<this.batches.length;t++)sr(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}};In.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Ch=In;var K=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(K||{});class kt extends at{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:a}=t;super(),this.uid=J("buffer"),this._resourceType="buffer",this._resourceId=J("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i=i??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage: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&K.STATIC)}set static(t){t?this.descriptor.usage|=K.STATIC:this.descriptor.usage&=~K.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLength<r.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=J("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Fn(s,t){if(!(s instanceof kt)){let e=t?K.INDEX:K.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=K.INDEX|K.COPY_DST):(s=new Float32Array(s),e=K.VERTEX|K.COPY_DST)),s=new kt({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return s}function Th(s,t,e){const i=s.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const r=i.buffer.data;let n=1/0,a=1/0,o=-1/0,h=-1/0;const c=r.BYTES_PER_ELEMENT,l=(i.offset||0)/c,u=(i.stride||2*4)/c;for(let d=l;d<r.length;d+=u){const f=r[d],p=r[d+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 Mh(s){return(s instanceof kt||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=Fn(s.buffer,!1),s}class Rn extends at{constructor(t){const{attributes:e,indexBuffer:i,topology:r}=t;super(),this.uid=J("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new bt,this._boundsDirty=!0,this.attributes=e,this.buffers=[],this.instanceCount=t.instanceCount||1;for(const n in e){const a=e[n]=Mh(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))}i&&(this.indexBuffer=Fn(i,!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,Th(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 Ph=new Float32Array(1),kh=new Uint32Array(1);class Bh extends Rn{constructor(){const e=new kt({data:Ph,label:"attribute-batch-buffer",usage:K.VERTEX|K.COPY_DST,shrinkToFit:!1}),i=new kt({data:kh,label:"index-batch-buffer",usage:K.INDEX|K.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:i})}}function ir(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let a=s[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(a)}else Q(`${i} placement hook does not exist in shader`)}}const Eh=/\{\{(.*?)\}\}/g;function rr(s){var i;const t={};return(((i=s.match(Eh))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function nr(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function ar(s,t,e=!1){const i=[];nr(t,i),s.forEach(o=>{o.header&&nr(o.header,i)});const r=i;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 or(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Ih(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Fh(s){const t=/@.*?\s+/g;return s.replace(t,"")}function Rh(s,t){const e=[];or(t,e),s.forEach(h=>{h.header&&or(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`,
|
|
`),n=e.sort().map(h=>` var ${Fh(h)};`).join(`
|
|
`),a=`return VSOutput(
|
|
${e.sort().map(h=>` ${Ih(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 hr(s,t){let e=s;for(const i in t){const r=t[i];r.join(`
|
|
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
|
|
${r.join(`
|
|
`)}
|
|
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const Pt=Object.create(null),Bs=new Map;let Gh=0;function Lh({template:s,bits:t}){const e=Gn(s,t);if(Pt[e])return Pt[e];const{vertex:i,fragment:r}=Oh(s,t);return Pt[e]=Ln(i,r,t),Pt[e]}function zh({template:s,bits:t}){const e=Gn(s,t);return Pt[e]||(Pt[e]=Ln(s.vertex,s.fragment,t)),Pt[e]}function Oh(s,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let r=ar(e,s.vertex,!0);r=Rh(e,r);const n=ar(i,s.fragment,!0);return{vertex:r,fragment:n}}function Gn(s,t){return t.map(e=>(Bs.has(e)||Bs.set(e,Gh++),Bs.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function Ln(s,t,e){const i=rr(s),r=rr(t);return e.forEach(n=>{ir(n.vertex,i,n.name),ir(n.fragment,r,n.name)}),{vertex:hr(s,i),fragment:hr(t,r)}}const Wh=`
|
|
@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}}
|
|
};
|
|
`,Uh=`
|
|
@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;
|
|
};
|
|
`,Dh=`
|
|
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}}
|
|
}
|
|
`,Nh=`
|
|
|
|
in vec4 vColor;
|
|
in vec2 vUV;
|
|
|
|
out vec4 finalColor;
|
|
|
|
{{header}}
|
|
|
|
void main(void) {
|
|
|
|
{{start}}
|
|
|
|
vec4 outColor;
|
|
|
|
{{main}}
|
|
|
|
finalColor = outColor * vColor;
|
|
|
|
{{end}}
|
|
}
|
|
`,Hh={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;
|
|
`}},$h={name:"global-uniforms-bit",vertex:{header:`
|
|
uniform mat3 uProjectionMatrix;
|
|
uniform mat3 uWorldTransformMatrix;
|
|
uniform vec4 uWorldColorAlpha;
|
|
uniform vec2 uResolution;
|
|
`}};function Vh({bits:s,name:t}){const e=Lh({template:{fragment:Uh,vertex:Wh},bits:[Hh,...s]});return ns.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Yh({bits:s,name:t}){return new un({name:t,...zh({template:{vertex:Dh,fragment:Nh},bits:[$h,...s]})})}const jh={name:"color-bit",vertex:{header:`
|
|
@in aColor: vec4<f32>;
|
|
`,main:`
|
|
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
`}},Xh={name:"color-bit",vertex:{header:`
|
|
in vec4 aColor;
|
|
`,main:`
|
|
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
`}},Es={};function qh(s){const t=[];if(s===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i<s;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(`
|
|
`)}function Kh(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<s;e++)e===s-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
|
|
`)}function Zh(s){return Es[s]||(Es[s]={name:"texture-batch-bit",vertex:{header:`
|
|
@in aTextureIdAndRound: vec2<u32>;
|
|
@out @interpolate(flat) vTextureId : u32;
|
|
`,main:`
|
|
vTextureId = aTextureIdAndRound.y;
|
|
`,end:`
|
|
if(aTextureIdAndRound.x == 1)
|
|
{
|
|
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
}
|
|
`},fragment:{header:`
|
|
@in @interpolate(flat) vTextureId: u32;
|
|
|
|
${qh(s)}
|
|
`,main:`
|
|
var uvDx = dpdx(vUV);
|
|
var uvDy = dpdy(vUV);
|
|
|
|
${Kh(s)}
|
|
`}}),Es[s]}const Is={};function Qh(s){const t=[];for(let e=0;e<s;e++)e>0&&t.push("else"),e<s-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
|
|
`)}function Jh(s){return Is[s]||(Is[s]={name:"texture-batch-bit",vertex:{header:`
|
|
in vec2 aTextureIdAndRound;
|
|
out float vTextureId;
|
|
|
|
`,main:`
|
|
vTextureId = aTextureIdAndRound.y;
|
|
`,end:`
|
|
if(aTextureIdAndRound.x == 1.)
|
|
{
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
}
|
|
`},fragment:{header:`
|
|
in float vTextureId;
|
|
|
|
uniform sampler2D uTextures[${s}];
|
|
|
|
`,main:`
|
|
|
|
${Qh(s)}
|
|
`}}),Is[s]}const tl={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;
|
|
}
|
|
`}},el={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;
|
|
}
|
|
`}},lr={};function sl(s){let t=lr[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i<s;i++)e[i]=i;return t=lr[s]=new gn({uTextures:{value:e,type:"i32",size:s}},{isStatic:!0}),t}class il extends ci{constructor(t){const e=Yh({name:"batch",bits:[Xh,Jh(t),el]}),i=Vh({name:"batch",bits:[jh,Zh(t),tl]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:sl(t)}})}}let cr=null;const zn=class On extends Ch{constructor(){super(...arguments),this.geometry=new Bh,this.shader=cr||(cr=new il(this.maxTextures)),this.name=On.extension.name,this.vertexSize=6}packAttributes(t,e,i,r,n){const a=n<<16|t.roundPixels&65535,o=t.transform,h=o.a,c=o.b,l=o.c,u=o.d,d=o.tx,f=o.ty,{positions:p,uvs:m}=t,g=t.color,x=t.attributeOffset,y=x+t.attributeSize;for(let _=x;_<y;_++){const v=_*2,C=p[v],I=p[v+1];e[r++]=h*C+l*I+d,e[r++]=u*I+c*C+f,e[r++]=m[v],e[r++]=m[v+1],i[r++]=g,i[r++]=a}}packQuadAttributes(t,e,i,r,n){const a=t.texture,o=t.transform,h=o.a,c=o.b,l=o.c,u=o.d,d=o.tx,f=o.ty,p=t.bounds,m=p.maxX,g=p.minX,x=p.maxY,y=p.minY,_=a.uvs,v=t.color,C=n<<16|t.roundPixels&65535;e[r+0]=h*g+l*y+d,e[r+1]=u*y+c*g+f,e[r+2]=_.x0,e[r+3]=_.y0,i[r+4]=v,i[r+5]=C,e[r+6]=h*m+l*y+d,e[r+7]=u*y+c*m+f,e[r+8]=_.x1,e[r+9]=_.y1,i[r+10]=v,i[r+11]=C,e[r+12]=h*m+l*x+d,e[r+13]=u*x+c*m+f,e[r+14]=_.x2,e[r+15]=_.y2,i[r+16]=v,i[r+17]=C,e[r+18]=h*g+l*x+d,e[r+19]=u*x+c*g+f,e[r+20]=_.x3,e[r+21]=_.y3,i[r+22]=v,i[r+23]=C}};zn.extension={type:[P.Batcher],name:"default"};let rl=zn;function nl(s,t,e,i,r,n,a,o=null){let h=0;e*=t,r*=n;const c=o.a,l=o.b,u=o.c,d=o.d,f=o.tx,p=o.ty;for(;h<a;){const m=s[e],g=s[e+1];i[r]=c*m+u*g+f,i[r+1]=l*m+d*g+p,r+=n,e+=t,h++}}function al(s,t,e,i){let r=0;for(t*=e;r<i;)s[t]=0,s[t+1]=0,t+=e,r++}function Wn(s,t,e,i,r){const n=t.a,a=t.b,o=t.c,h=t.d,c=t.tx,l=t.ty;e=e||0,i=i||2,r=r||s.length/i-e;let u=e*i;for(let d=0;d<r;d++){const f=s[u],p=s[u+1];s[u]=n*f+o*p+c,s[u+1]=a*f+h*p+l,u+=i}}function ol(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;const e=s>>16&255,i=s>>8&255,r=s&255,n=t>>16&255,a=t>>8&255,o=t&255,h=e*n/255,c=i*a/255,l=r*o/255;return(h<<16)+(c<<8)+l}const hl=new O;class Un{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,i=this.renderable;return i?ol(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||hl}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 Pe={extension:{type:P.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,a,o;if(s.type==="circle"){const v=s;e=v.x,i=v.y,a=o=v.radius,r=n=0}else if(s.type==="ellipse"){const v=s;e=v.x,i=v.y,a=v.halfWidth,o=v.halfHeight,r=n=0}else{const v=s,C=v.width/2,I=v.height/2;e=v.x+C,i=v.y+I,a=o=Math.max(0,Math.min(v.radius,Math.min(C,I))),r=C-a,n=I-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]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,t;let l=0,u=h*4+(r?2:0)+2,d=u,f=c,p=r+a,m=n,g=e+p,x=e-p,y=i+m;if(t[l++]=g,t[l++]=y,t[--u]=y,t[--u]=x,n){const v=i-m;t[d++]=x,t[d++]=v,t[--f]=v,t[--f]=g}for(let v=1;v<h;v++){const C=Math.PI/2*(v/h),I=r+Math.cos(C)*a,M=n+Math.sin(C)*o,k=e+I,S=e-I,A=i+M,Y=i-M;t[l++]=k,t[l++]=A,t[--u]=A,t[--u]=S,t[d++]=S,t[d++]=Y,t[--f]=Y,t[--f]=k}p=r,m=n+o,g=e+p,x=e-p,y=i+m;const _=i-m;return t[l++]=g,t[l++]=y,t[--f]=_,t[--f]=g,r&&(t[l++]=x,t[l++]=y,t[--f]=_,t[--f]=x),t},triangulate(s,t,e,i,r,n){if(s.length===0)return;let a=0,o=0;for(let l=0;l<s.length;l+=2)a+=s[l],o+=s[l+1];a/=s.length/2,o/=s.length/2;let h=i;t[h*e]=a,t[h*e+1]=o;const c=h++;for(let l=0;l<s.length;l+=2)t[h*e]=s[l],t[h*e+1]=s[l+1],l>0&&(r[n++]=h,r[n++]=c,r[n++]=h-1),h++;r[n++]=c+1,r[n++]=c,r[n++]=h-1}},ll={...Pe,extension:{...Pe.extension,name:"ellipse"}},cl={...Pe,extension:{...Pe.extension,name:"roundedRectangle"}},ul=1e-4,ur=1e-4;function dl(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];i<t;i+=2){const a=s[i],o=s[i+1];e+=(a-r)*(o+n),r=a,n=o}return e<0?-1:1}function dr(s,t,e,i,r,n,a,o){const h=s-e*r,c=t-i*r,l=s+e*n,u=t+i*n;let d,f;a?(d=i,f=-e):(d=-i,f=e);const p=h+d,m=c+f,g=l+d,x=u+f;return o.push(p,m),o.push(g,x),2}function Lt(s,t,e,i,r,n,a,o){const h=e-s,c=i-t;let l=Math.atan2(h,c),u=Math.atan2(r-s,n-t);o&&l<u?l+=Math.PI*2:!o&&l>u&&(u+=Math.PI*2);let d=l;const f=u-l,p=Math.abs(f),m=Math.sqrt(h*h+c*c),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,x=f/g;if(d+=x,o){a.push(s,t),a.push(e,i);for(let y=1,_=d;y<g;y++,_+=x)a.push(s,t),a.push(s+Math.sin(_)*m,t+Math.cos(_)*m);a.push(s,t),a.push(r,n)}else{a.push(e,i),a.push(s,t);for(let y=1,_=d;y<g;y++,_+=x)a.push(s+Math.sin(_)*m,t+Math.cos(_)*m),a.push(s,t);a.push(r,n),a.push(s,t)}return g*2}function fl(s,t,e,i,r,n,a,o,h){const c=ul;if(s.length===0)return;const l=t;let u=l.alignment;if(t.alignment!==.5){let U=dl(s);u=(u-.5)*U+.5}const d=new it(s[0],s[1]),f=new it(s[s.length-2],s[s.length-1]),p=i,m=Math.abs(d.x-f.x)<c&&Math.abs(d.y-f.y)<c;if(p){s=s.slice(),m&&(s.pop(),s.pop(),f.set(s[s.length-2],s[s.length-1]));const U=(d.x+f.x)*.5,Mt=(f.y+d.y)*.5;s.unshift(U,Mt),s.push(U,Mt)}const g=r,x=s.length/2;let y=s.length;const _=g.length/2,v=l.width/2,C=v*v,I=l.miterLimit*l.miterLimit;let M=s[0],k=s[1],S=s[2],A=s[3],Y=0,wt=0,F=-(k-A),E=M-S,D=0,q=0,ft=Math.sqrt(F*F+E*E);F/=ft,E/=ft,F*=v,E*=v;const Si=u,B=(1-Si)*2,R=Si*2;p||(l.cap==="round"?y+=Lt(M-F*(B-R)*.5,k-E*(B-R)*.5,M-F*B,k-E*B,M+F*R,k+E*R,g,!0)+2:l.cap==="square"&&(y+=dr(M,k,F,E,B,R,!0,g))),g.push(M-F*B,k-E*B),g.push(M+F*R,k+E*R);for(let U=1;U<x-1;++U){M=s[(U-1)*2],k=s[(U-1)*2+1],S=s[U*2],A=s[U*2+1],Y=s[(U+1)*2],wt=s[(U+1)*2+1],F=-(k-A),E=M-S,ft=Math.sqrt(F*F+E*E),F/=ft,E/=ft,F*=v,E*=v,D=-(A-wt),q=S-Y,ft=Math.sqrt(D*D+q*q),D/=ft,q/=ft,D*=v,q*=v;const Mt=S-M,he=k-A,le=S-Y,ce=wt-A,Ai=Mt*le+he*ce,Re=he*le-ce*Mt,ue=Re<0;if(Math.abs(Re)<.001*Math.abs(Ai)){g.push(S-F*B,A-E*B),g.push(S+F*R,A+E*R),Ai>=0&&(l.join==="round"?y+=Lt(S,A,S-F*B,A-E*B,S-D*B,A-q*B,g,!1)+4:y+=2,g.push(S-D*R,A-q*R),g.push(S+D*B,A+q*B));continue}const Ci=(-F+M)*(-E+A)-(-F+S)*(-E+k),Ti=(-D+Y)*(-q+A)-(-D+S)*(-q+wt),Ge=(Mt*Ti-le*Ci)/Re,Le=(ce*Ci-he*Ti)/Re,cs=(Ge-S)*(Ge-S)+(Le-A)*(Le-A),It=S+(Ge-S)*B,Ft=A+(Le-A)*B,Rt=S-(Ge-S)*R,Gt=A-(Le-A)*R,ga=Math.min(Mt*Mt+he*he,le*le+ce*ce),Mi=ue?B:R,ma=ga+Mi*Mi*C;cs<=ma?l.join==="bevel"||cs/C>I?(ue?(g.push(It,Ft),g.push(S+F*R,A+E*R),g.push(It,Ft),g.push(S+D*R,A+q*R)):(g.push(S-F*B,A-E*B),g.push(Rt,Gt),g.push(S-D*B,A-q*B),g.push(Rt,Gt)),y+=2):l.join==="round"?ue?(g.push(It,Ft),g.push(S+F*R,A+E*R),y+=Lt(S,A,S+F*R,A+E*R,S+D*R,A+q*R,g,!0)+4,g.push(It,Ft),g.push(S+D*R,A+q*R)):(g.push(S-F*B,A-E*B),g.push(Rt,Gt),y+=Lt(S,A,S-F*B,A-E*B,S-D*B,A-q*B,g,!1)+4,g.push(S-D*B,A-q*B),g.push(Rt,Gt)):(g.push(It,Ft),g.push(Rt,Gt)):(g.push(S-F*B,A-E*B),g.push(S+F*R,A+E*R),l.join==="round"?ue?y+=Lt(S,A,S+F*R,A+E*R,S+D*R,A+q*R,g,!0)+2:y+=Lt(S,A,S-F*B,A-E*B,S-D*B,A-q*B,g,!1)+2:l.join==="miter"&&cs/C<=I&&(ue?(g.push(Rt,Gt),g.push(Rt,Gt)):(g.push(It,Ft),g.push(It,Ft)),y+=2),g.push(S-D*B,A-q*B),g.push(S+D*R,A+q*R),y+=2)}M=s[(x-2)*2],k=s[(x-2)*2+1],S=s[(x-1)*2],A=s[(x-1)*2+1],F=-(k-A),E=M-S,ft=Math.sqrt(F*F+E*E),F/=ft,E/=ft,F*=v,E*=v,g.push(S-F*B,A-E*B),g.push(S+F*R,A+E*R),p||(l.cap==="round"?y+=Lt(S-F*(B-R)*.5,A-E*(B-R)*.5,S-F*B,A-E*B,S+F*R,A+E*R,g,!1)+2:l.cap==="square"&&(y+=dr(S,A,F,E,B,R,!1,g)));const pa=ur*ur;for(let U=_;U<y+_-2;++U)M=g[U*2],k=g[U*2+1],S=g[(U+1)*2],A=g[(U+1)*2+1],Y=g[(U+2)*2],wt=g[(U+2)*2+1],!(Math.abs(M*(A-wt)+S*(wt-k)+Y*(k-A))<pa)&&o.push(U,U+1,U+2)}function Dn(s,t,e,i,r,n,a){const o=eh(s,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*i;for(let c=0;c<s.length;c+=2)e[h]=s[c],e[h+1]=s[c+1],h+=i}const pl=[],gl={extension:{type:P.ShapeBuilder,name:"polygon"},build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return t},triangulate(s,t,e,i,r,n){Dn(s,pl,t,e,i,r,n)}},ml={extension:{type:P.ShapeBuilder,name:"rectangle"},build(s,t){const e=s,i=e.x,r=e.y,n=e.width,a=e.height;return n>=0&&a>=0&&(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+a,t[6]=i,t[7]=r+a),t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[6],t[i+a+1]=s[7],a+=e,t[i+a]=s[4],t[i+a+1]=s[5],a+=e;const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2,r[n++]=o+1,r[n++]=o+3,r[n++]=o+2}},xl={extension:{type:P.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[4],t[i+a+1]=s[5];const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2}},ls={};rt.handleByMap(P.ShapeBuilder,ls);rt.add(ml,gl,xl,Pe,ll,cl);const yl=new W;function _l(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r<s.instructions.length;r++){const n=s.instructions[r];if(n.action==="texture")bl(n.data,i,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&&fr(c.shapePath,h,null,!0,i,e),fr(o,h,c,a,i,e)}}}function bl(s,t,e){const{vertices:i,uvs:r,indices:n}=e,a=n.length,o=i.length/2,h=[],c=ls.rectangle,l=yl,u=s.image;l.x=s.dx,l.y=s.dy,l.width=s.dw,l.height=s.dh;const d=s.transform;c.build(l,h),d&&Wn(h,d),c.triangulate(h,i,2,o,n,a);const f=u.uvs;r.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=St.get(Un);p.indexOffset=a,p.indexSize=n.length-a,p.attributeOffset=o,p.attributeSize=i.length/2-o,p.baseColor=s.style,p.alpha=s.alpha,p.texture=u,p.geometryData=e,t.push(p)}function fr(s,t,e,i,r,n){const{vertices:a,uvs:o,indices:h}=n,c=s.shapePrimitives.length-1;s.shapePrimitives.forEach(({shape:l,transform:u},d)=>{const f=h.length,p=a.length/2,m=[],g=ls[l.type];if(g.build(l,m),u&&Wn(m,u),i){const v=l.closePath??!0;fl(m,t,!1,v,a,2,p,h)}else if(e&&c===d){c!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const v=[],C=m.slice();wl(e.shapePath).forEach(M=>{v.push(C.length/2),C.push(...M)}),Dn(C,v,a,2,p,h,f)}else g.triangulate(m,a,2,p,h,f);const x=o.length/2,y=t.texture;if(y!==G.WHITE){const v=t.matrix;v&&(u&&v.append(u.clone().invert()),nl(a,2,p,o,x,2,a.length/2-p,v))}else al(o,x,2,a.length/2-p);const _=St.get(Un);_.indexOffset=f,_.indexSize=h.length-f,_.attributeOffset=p,_.attributeSize=a.length/2-p,_.baseColor=t.color,_.alpha=t.alpha,_.texture=y,_.geometryData=n,r.push(_)})}function wl(s){if(!s)return[];const t=s.shapePrimitives,e=[];for(let i=0;i<t.length;i++){const r=t[i].shape,n=[];ls[r.type].build(r,n),e.push(n)}return e}class vl{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Sl{constructor(){this.batcher=new rl,this.instructions=new jr}init(){this.instructions.reset()}get geometry(){return L(Ba,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const gi=class ti{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){ti.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??ti.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),_l(t,e);const i=t.batchMode;t.customShader||i==="no-batch"?e.isBatchable=!1:i==="auto"&&(e.isBatchable=e.geometryData.vertices.length<400),t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=St.get(Sl),{batches:i,geometryData:r}=this._gpuContextHash[t.uid],n=r.vertices.length,a=r.indices.length;for(let l=0;l<i.length;l++)i[l].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(n),o.ensureIndexBuffer(a),o.begin();for(let l=0;l<i.length;l++){const u=i[l];o.add(u)}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 u=c[l];u.bindGroup=_h(u.textures.textures,u.textures.count)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new vl;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]&&(St.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(i=>{St.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};gi.extension={type:[P.WebGLSystem,P.WebGPUSystem,P.CanvasSystem],name:"graphicsContext"};gi.defaultOptions={bezierSmoothness:.5};let Nn=gi;const Al=8,je=11920929e-14,Cl=1;function Hn(s,t,e,i,r,n,a,o,h,c){const u=Math.min(.99,Math.max(0,c??Nn.defaultOptions.bezierSmoothness));let d=(Cl-u)/1;return d*=d,Tl(t,e,i,r,n,a,o,h,s,d),s}function Tl(s,t,e,i,r,n,a,o,h,c){ei(s,t,e,i,r,n,a,o,h,c,0),h.push(a,o)}function ei(s,t,e,i,r,n,a,o,h,c,l){if(l>Al)return;const u=(s+e)/2,d=(t+i)/2,f=(e+r)/2,p=(i+n)/2,m=(r+a)/2,g=(n+o)/2,x=(u+f)/2,y=(d+p)/2,_=(f+m)/2,v=(p+g)/2,C=(x+_)/2,I=(y+v)/2;if(l>0){let M=a-s,k=o-t;const S=Math.abs((e-a)*k-(i-o)*M),A=Math.abs((r-a)*k-(n-o)*M);if(S>je&&A>je){if((S+A)*(S+A)<=c*(M*M+k*k)){h.push(C,I);return}}else if(S>je){if(S*S<=c*(M*M+k*k)){h.push(C,I);return}}else if(A>je){if(A*A<=c*(M*M+k*k)){h.push(C,I);return}}else if(M=C-(s+a)/2,k=I-(t+o)/2,M*M+k*k<=c){h.push(C,I);return}}ei(s,t,u,d,x,y,C,I,h,c,l+1),ei(C,I,_,v,m,g,a,o,h,c,l+1)}const Ml=8,Pl=11920929e-14,kl=1;function Bl(s,t,e,i,r,n,a,o){const c=Math.min(.99,Math.max(0,o??Nn.defaultOptions.bezierSmoothness));let l=(kl-c)/1;return l*=l,El(t,e,i,r,n,a,s,l),s}function El(s,t,e,i,r,n,a,o){si(a,s,t,e,i,r,n,o,0),a.push(r,n)}function si(s,t,e,i,r,n,a,o,h){if(h>Ml)return;const c=(t+i)/2,l=(e+r)/2,u=(i+n)/2,d=(r+a)/2,f=(c+u)/2,p=(l+d)/2;let m=n-t,g=a-e;const x=Math.abs((i-n)*g-(r-a)*m);if(x>Pl){if(x*x<=o*(m*m+g*g)){s.push(f,p);return}}else if(m=f-(t+n)/2,g=p-(e+a)/2,m*m+g*g<=o){s.push(f,p);return}si(s,t,e,c,l,f,p,o,h+1),si(s,f,p,u,d,n,a,o,h+1)}function $n(s,t,e,i,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(i,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=r;c*=a?-1:1;for(let u=0;u<o+1;u++){const d=Math.cos(l),f=Math.sin(l),p=t+d*i,m=e+f*i;s.push(p,m),l+=c}}function Il(s,t,e,i,r,n){const a=s[s.length-2],h=s[s.length-1]-e,c=a-t,l=r-e,u=i-t,d=Math.abs(h*u-c*l);if(d<1e-8||n===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}const f=h*h+c*c,p=l*l+u*u,m=h*l+c*u,g=n*Math.sqrt(f)/d,x=n*Math.sqrt(p)/d,y=g*m/f,_=x*m/p,v=g*u+x*c,C=g*l+x*h,I=c*(x+y),M=h*(x+y),k=u*(g+_),S=l*(g+_),A=Math.atan2(M-C,I-v),Y=Math.atan2(S-C,k-v);$n(s,v+t,C+e,n,A,Y,c*l>u*h)}const ve=Math.PI*2,Fs={centerX:0,centerY:0,ang1:0,ang2:0},Rs=({x:s,y:t},e,i,r,n,a,o,h)=>{s*=e,t*=i;const c=r*s-n*t,l=n*s+r*t;return h.x=c+a,h.y=l+o,h};function Fl(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),a=Math.cos(s+t),o=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const pr=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Rl=(s,t,e,i,r,n,a,o,h,c,l,u,d)=>{const f=Math.pow(r,2),p=Math.pow(n,2),m=Math.pow(l,2),g=Math.pow(u,2);let x=f*p-f*g-p*m;x<0&&(x=0),x/=f*g+p*m,x=Math.sqrt(x)*(a===o?-1:1);const y=x*r/n*u,_=x*-n/r*l,v=c*y-h*_+(s+e)/2,C=h*y+c*_+(t+i)/2,I=(l-y)/r,M=(u-_)/n,k=(-l-y)/r,S=(-u-_)/n,A=pr(1,0,I,M);let Y=pr(I,M,k,S);o===0&&Y>0&&(Y-=ve),o===1&&Y<0&&(Y+=ve),d.centerX=v,d.centerY=C,d.ang1=A,d.ang2=Y};function Gl(s,t,e,i,r,n,a,o=0,h=0,c=0){if(n===0||a===0)return;const l=Math.sin(o*ve/360),u=Math.cos(o*ve/360),d=u*(t-i)/2+l*(e-r)/2,f=-l*(t-i)/2+u*(e-r)/2;if(d===0&&f===0)return;n=Math.abs(n),a=Math.abs(a);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(a,2);p>1&&(n*=Math.sqrt(p),a*=Math.sqrt(p)),Rl(t,e,i,r,n,a,h,c,l,u,d,f,Fs);let{ang1:m,ang2:g}=Fs;const{centerX:x,centerY:y}=Fs;let _=Math.abs(g)/(ve/4);Math.abs(1-_)<1e-7&&(_=1);const v=Math.max(Math.ceil(_),1);g/=v;let C=s[s.length-2],I=s[s.length-1];const M={x:0,y:0};for(let k=0;k<v;k++){const S=Fl(m,g),{x:A,y:Y}=Rs(S[0],n,a,u,l,x,y,M),{x:wt,y:F}=Rs(S[1],n,a,u,l,x,y,M),{x:E,y:D}=Rs(S[2],n,a,u,l,x,y,M);Hn(s,C,I,A,Y,wt,F,E,D),C=E,I=D,m+=g}}function Ll(s,t,e){const i=(a,o)=>{const h=o.x-a.x,c=o.y-a.y,l=Math.sqrt(h*h+c*c),u=h/l,d=c/l;return{len:l,nx:u,ny:d}},r=(a,o)=>{a===0?s.moveTo(o.x,o.y):s.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=i(o,n),u=i(o,c);if(l.len<1e-4||u.len<1e-4){r(a,o),n=o;continue}let d=Math.asin(l.nx*u.ny-l.ny*u.nx),f=1,p=!1;l.nx*u.nx-l.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,f=-1,p=!0):d>0&&(f=-1,p=!0);const m=d/2;let g,x=Math.abs(Math.cos(m)*h/Math.sin(m));x>Math.min(l.len/2,u.len/2)?(x=Math.min(l.len/2,u.len/2),g=Math.abs(x*Math.sin(m)/Math.cos(m))):g=h;const y=o.x+u.nx*x+-u.ny*g*f,_=o.y+u.ny*x+u.nx*g*f,v=Math.atan2(l.ny,l.nx)+Math.PI/2*f,C=Math.atan2(u.ny,u.nx)-Math.PI/2*f;a===0&&s.moveTo(y+Math.cos(v)*g,_+Math.sin(v)*g),s.arc(y,_,g,v,C,p),n=o}}function zl(s,t,e,i){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?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y);continue}const l=t[o],u=t[(o+2)%a],d=r(l,h);let f;if(d<1e-4)f=h;else{const g=Math.min(d/2,c);f=n(h,l,g/d)}const p=r(u,h);let m;if(p<1e-4)m=h;else{const g=Math.min(p/2,c);m=n(h,u,g/p)}o===0?s.moveTo(f.x,f.y):s.lineTo(f.x,f.y),s.quadraticCurveTo(h.x,h.y,m.x,m.y,i)}}const Ol=new W;class Wl{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new bt,this._graphicsPath2D=t}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,r=i[i.length-2],n=i[i.length-1];return(r!==t||n!==e)&&i.push(t,e),this}arc(t,e,i,r,n,a){this._ensurePoly(!1);const o=this._currentPoly.points;return $n(o,t,e,i,r,n,a),this}arcTo(t,e,i,r,n){this._ensurePoly();const a=this._currentPoly.points;return Il(a,t,e,i,r,n),this}arcToSvg(t,e,i,r,n,a,o){const h=this._currentPoly.points;return Gl(h,this._currentPoly.lastX,this._currentPoly.lastY,a,o,t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,a,o){this._ensurePoly();const h=this._currentPoly;return Hn(this._currentPoly.points,h.lastX,h.lastY,t,e,i,r,n,a,o),this}quadraticCurveTo(t,e,i,r,n){this._ensurePoly();const a=this._currentPoly;return Bl(this._currentPoly.points,a.lastX,a.lastY,t,e,i,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 i=0;i<t.instructions.length;i++){const r=t.instructions[i];this[r.action](...r.data)}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,r,n){return this.drawShape(new W(t,e,i,r),n),this}circle(t,e,i,r){return this.drawShape(new di(t,e,i),r),this}poly(t,e,i){const r=new we(t);return r.closePath=e,this.drawShape(r,i),this}regularPoly(t,e,i,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 u=l*h+o;c.push(t+i*Math.cos(u),e+i*Math.sin(u))}return this.poly(c,!0,a),this}roundPoly(t,e,i,r,n,a=0,o){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(t,e,i,r,a);const h=i*Math.sin(Math.PI/r)-.001;n=Math.min(n,h);const c=-1*Math.PI/2+a,l=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let d=0;d<r;d++){const f=d*l+c,p=t+i*Math.cos(f),m=e+i*Math.sin(f),g=f+Math.PI+u,x=f-Math.PI-u,y=p+n*Math.cos(g),_=m+n*Math.sin(g),v=p+n*Math.cos(x),C=m+n*Math.sin(x);d===0?this.moveTo(y,_):this.lineTo(y,_),this.quadraticCurveTo(p,m,v,C,o)}return this.closePath()}roundShape(t,e,i=!1,r){return t.length<3?this:(i?zl(this,t,e,r):Ll(this,t,e),this.closePath())}filletRect(t,e,i,r,n){if(n===0)return this.rect(t,e,i,r);const a=Math.min(i,r)/2,o=Math.min(a,Math.max(-a,n)),h=t+i,c=e+r,l=o<0?-o:0,u=Math.abs(o);return this.moveTo(t,e+u).arcTo(t+l,e+l,t+u,e,u).lineTo(h-u,e).arcTo(h-l,e+l,h,e+u,u).lineTo(h,c-u).arcTo(h-l,c-l,t+i-u,c,u).lineTo(t+u,c).arcTo(t+l,c-l,t,c-u,u).closePath()}chamferRect(t,e,i,r,n,a){if(n<=0)return this.rect(t,e,i,r);const o=Math.min(n,Math.min(i,r)/2),h=t+i,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 u=l.length-1;u>=2;u-=2)l[u]===l[u-2]&&l[u-1]===l[u-3]&&l.splice(u-1,2);return this.poly(l,!0,a)}ellipse(t,e,i,r,n){return this.drawShape(new fi(t,e,i,r),n),this}roundRect(t,e,i,r,n,a){return this.drawShape(new pi(t,e,i,r,n),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new we,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new we,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,a=i;i=n.a*i+n.c*r+n.tx,r=n.b*a+n.d*r+n.ty}this._currentPoly.points.push(i,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 i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const r=e[i],n=r.shape.getBounds(Ol);r.transform?t.addRect(n,r.transform):t.addRect(n)}return t}}class ee{constructor(t){this.instructions=[],this.uid=J("graphicsPath"),this._dirty=!0,typeof t=="string"?ph(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new Wl(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,r,n){const a=this.instructions[this.instructions.length-1],o=this.getLastPoint(it.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,u=o.y;h=l+(l-h),c=u+(u-c)}return this.instructions.push({action:"bezierCurveTo",data:[h,c,t,e,i,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,i){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(it.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,i]}),this._dirty=!0,this}rect(t,e,i,r,n){return this.instructions.push({action:"rect",data:[t,e,i,r,n]}),this._dirty=!0,this}circle(t,e,i,r){return this.instructions.push({action:"circle",data:[t,e,i,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,i,r,n,a,o){n=n||r/2;const h=-1*Math.PI/2+a,c=i*2,l=Math.PI*2/c,u=[];for(let d=0;d<c;d++){const f=d%2?n:r,p=d*l+h;u.push(t+f*Math.cos(p),e+f*Math.sin(p))}return this.poly(u,!0,o),this}clone(t=!1){const e=new ee;if(!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const r=this.instructions[i];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,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty;let h=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;for(let g=0;g<this.instructions.length;g++){const x=this.instructions[g],y=x.data;switch(x.action){case"moveTo":case"lineTo":h=y[0],c=y[1],y[0]=e*h+r*c+a,y[1]=i*h+n*c+o;break;case"bezierCurveTo":l=y[0],u=y[1],d=y[2],f=y[3],h=y[4],c=y[5],y[0]=e*l+r*u+a,y[1]=i*l+n*u+o,y[2]=e*d+r*f+a,y[3]=i*d+n*f+o,y[4]=e*h+r*c+a,y[5]=i*h+n*c+o;break;case"quadraticCurveTo":l=y[0],u=y[1],h=y[2],c=y[3],y[0]=e*l+r*u+a,y[1]=i*l+n*u+o,y[2]=e*h+r*c+a,y[3]=i*h+n*c+o;break;case"arcToSvg":h=y[5],c=y[6],p=y[0],m=y[1],y[0]=e*p+r*m,y[1]=i*p+n*m,y[5]=e*h+r*c+a,y[6]=i*h+n*c+o;break;case"circle":y[4]=ge(y[3],t);break;case"rect":y[4]=ge(y[4],t);break;case"ellipse":y[8]=ge(y[8],t);break;case"roundRect":y[5]=ge(y[5],t);break;case"addPath":y[0].transform(t);break;case"poly":y[2]=ge(y[2],t);break;default:Q("unknown transform action",x.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t);break}return t}}function ge(s,t){return s?s.prepend(t):t.clone()}function Ul(s,t){if(typeof s=="string"){const i=document.createElement("div");i.innerHTML=s.trim(),s=i.querySelector("svg")}const e={context:t,path:new ee};return Vn(s,e,null,null),t}function Vn(s,t,e,i){const r=s.children,{fillStyle:n,strokeStyle:a}=Dl(s);n&&e?e={...e,...n}:n&&(e=n),a&&i?i={...i,...a}:a&&(i=a),t.context.fillStyle=e,t.context.strokeStyle=i;let o,h,c,l,u,d,f,p,m,g,x,y,_,v,C,I,M;switch(s.nodeName.toLowerCase()){case"path":v=s.getAttribute("d"),C=new ee(v),t.context.path(C),e&&t.context.fill(),i&&t.context.stroke();break;case"circle":f=tt(s,"cx",0),p=tt(s,"cy",0),m=tt(s,"r",0),t.context.ellipse(f,p,m,m),e&&t.context.fill(),i&&t.context.stroke();break;case"rect":o=tt(s,"x",0),h=tt(s,"y",0),I=tt(s,"width",0),M=tt(s,"height",0),g=tt(s,"rx",0),x=tt(s,"ry",0),g||x?t.context.roundRect(o,h,I,M,g||x):t.context.rect(o,h,I,M),e&&t.context.fill(),i&&t.context.stroke();break;case"ellipse":f=tt(s,"cx",0),p=tt(s,"cy",0),g=tt(s,"rx",0),x=tt(s,"ry",0),t.context.beginPath(),t.context.ellipse(f,p,g,x),e&&t.context.fill(),i&&t.context.stroke();break;case"line":c=tt(s,"x1",0),l=tt(s,"y1",0),u=tt(s,"x2",0),d=tt(s,"y2",0),t.context.beginPath(),t.context.moveTo(c,l),t.context.lineTo(u,d),i&&t.context.stroke();break;case"polygon":_=s.getAttribute("points"),y=_.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(y,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":_=s.getAttribute("points"),y=_.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(y,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let k=0;k<r.length;k++)Vn(r[k],t,e,i)}function tt(s,t,e){const i=s.getAttribute(t);return i?Number(i):e}function Dl(s){const t=s.getAttribute("style"),e={},i={};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=Z.shared.setValue(l).toNumber(),n=!0);break;case"stroke-width":e.width=Number(l);break;case"fill":l!=="none"&&(r=!0,i.color=Z.shared.setValue(l).toNumber());break;case"fill-opacity":i.alpha=Number(l);break;case"stroke-opacity":e.alpha=Number(l);break;case"opacity":i.alpha=Number(l),e.alpha=Number(l);break}}}else{const a=s.getAttribute("stroke");a&&a!=="none"&&(n=!0,e.color=Z.shared.setValue(a).toNumber(),e.width=tt(s,"stroke-width",1));const o=s.getAttribute("fill");o&&o!=="none"&&(r=!0,i.color=Z.shared.setValue(o).toNumber())}return{strokeStyle:n?e:null,fillStyle:r?i:null}}function Nl(s){return Z.isColorLike(s)}function gr(s){return s instanceof hs}function mr(s){return s instanceof Me}function Hl(s,t,e){const i=Z.shared.setValue(t??0);return s.color=i.toNumber(),s.alpha=i.alpha===1?e.alpha:i.alpha,s.texture=G.WHITE,{...e,...s}}function xr(s,t,e){return s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,{...e,...s}}function yr(s,t,e){return t.buildLinearGradient(),s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,{...e,...s}}function $l(s,t){var r;const e={...t,...s};if(e.texture){if(e.texture!==G.WHITE){const a=((r=e.matrix)==null?void 0:r.invert())||new O;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 i=Z.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e.matrix=e.matrix?e.matrix.clone():null,e}function Dt(s,t){if(s==null)return null;const e={},i=s;return Nl(s)?Hl(e,s,t):gr(s)?xr(e,s,t):mr(s)?yr(e,s,t):i.fill&&gr(i.fill)?xr(i,i.fill,t):i.fill&&mr(i.fill)?yr(i,i.fill,t):$l(i,t)}function ss(s,t){const{width:e,alignment:i,miterLimit:r,cap:n,join:a,...o}=t,h=Dt(s,o);return h?{width:e,alignment:i,miterLimit:r,cap:n,join:a,...h}:null}const Vl=new it,_r=new O,mi=class yt extends at{constructor(){super(...arguments),this.uid=J("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new ee,this._transform=new O,this._fillStyle={...yt.defaultFillStyle},this._strokeStyle={...yt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new bt,this._boundsDirty=!0}clone(){const t=new yt;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=Dt(t,yt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=ss(t,yt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Dt(t,yt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Dt(t,yt.defaultStrokeStyle),this}texture(t,e,i,r,n,a){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:r||0,dw:n||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?Z.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ee,this}fill(t,e){let i;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r&&r.action==="stroke"?i=r.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(L(z,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=Dt(t,yt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(it.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=ss(t,yt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,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,i,r,n,a),this}arcTo(t,e,i,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*i+a.c*r+a.tx,a.b*i+a.d*r+a.ty,n),this}arcToSvg(t,e,i,r,n,a,o){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,r,n,h.a*a+h.c*o+h.tx,h.b*a+h.d*o+h.ty),this}bezierCurveTo(t,e,i,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*i+h.c*r+h.tx,h.b*i+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,i,r){return this._tick++,this._activePath.ellipse(t,e,i,r,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,r=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,a=i.b*t+i.d*e+i.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,i,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*i+a.c*r+a.tx,a.b*i+a.d*r+a.ty,n),this}rect(t,e,i,r){return this._tick++,this._activePath.rect(t,e,i,r,this._transform.clone()),this}roundRect(t,e,i,r,n){return this._tick++,this._activePath.roundRect(t,e,i,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,r,n=0,a){return this._tick++,this._activePath.regularPoly(t,e,i,r,n,a),this}roundPoly(t,e,i,r,n,a){return this._tick++,this._activePath.roundPoly(t,e,i,r,n,a),this}roundShape(t,e,i,r){return this._tick++,this._activePath.roundShape(t,e,i,r),this}filletRect(t,e,i,r,n){return this._tick++,this._activePath.filletRect(t,e,i,r,n),this}chamferRect(t,e,i,r,n,a){return this._tick++,this._activePath.chamferRect(t,e,i,r,n,a),this}star(t,e,i,r,n=0,a=0){return this._tick++,this._activePath.star(t,e,i,r,n,a,this._transform.clone()),this}svg(t){return this._tick++,Ul(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,r,n,a){return t instanceof O?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,r,n,a),this)}transform(t,e,i,r,n,a){return t instanceof O?(this._transform.append(t),this):(_r.set(t,e,i,r,n,a),this._transform.append(_r),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],r=i.action;if(r==="fill"){const n=i.data;t.addBounds(n.path.bounds)}else if(r==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=i.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 i=!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 u=0;u<l.length;u++){const d=l[u].shape;if(!c||!d)continue;const f=l[u].transform,p=f?f.applyInverse(t,Vl):t;a.action==="fill"?i=d.contains(p.x,p.y):i=d.strokeContains(p.x,p.y,c.width);const m=o.hole;if(m){const g=(r=m.shapePath)==null?void 0:r.shapePrimitives;if(g)for(let x=0;x<g.length;x++)g[x].shape.contains(p.x,p.y)&&(i=!1)}if(i)return!0}}return i}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(i),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(i)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};mi.defaultFillStyle={color:16777215,alpha:1,texture:G.WHITE,matrix:null,fill:null};mi.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:G.WHITE,matrix:null,fill:null};let ct=mi;const br=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function Yl(s){const t=[];let e=0;for(let i=0;i<br.length;i++){const r=`_${br[i]}`;t[e++]=s[r]}return e=Yn(s._fill,t,e),e=jl(s._stroke,t,e),e=Xl(s.dropShadow,t,e),t.join("-")}function Yn(s,t,e){var i;return s&&(t[e++]=s.color,t[e++]=s.alpha,t[e++]=(i=s.fill)==null?void 0:i.styleKey),e}function jl(s,t,e){return s&&(e=Yn(s,t,e),t[e++]=s.width,t[e++]=s.alignment,t[e++]=s.cap,t[e++]=s.join,t[e++]=s.miterLimit),e}function Xl(s,t,e){return s&&(t[e++]=s.alpha,t[e++]=s.angle,t[e++]=s.blur,t[e++]=s.distance,t[e++]=Z.shared.setValue(s.color).toNumber()),e}const xi=class Xt extends at{constructor(t={}){super(),ql(t);const e={...Xt.defaultTextStyle,...t};for(const i in e){const r=i;this[r]=e[i]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...Xt.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Xt.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({...ct.defaultFillStyle,...t},()=>{this._fill=Dt({...this._originalFill},ct.defaultFillStyle)})),this._fill=Dt(t===0?"black":t,ct.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ct.defaultStrokeStyle,...t},()=>{this._stroke=ss({...this._originalStroke},ct.defaultStrokeStyle)})),this._stroke=ss(t,ct.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Yl(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=Xt.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new Xt({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var i,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;(i=this._fill)!=null&&i.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:(i,r,n)=>(i[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Z.isColorLike(t)||t instanceof Me||t instanceof hs)}};xi.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};xi.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 lt=xi;function ql(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=lt.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){L(z,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Z.isColorLike(e))i.color=e;else if(e instanceof Me||e instanceof hs)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){L(z,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;s.fontSize==null?s.fontSize=lt.defaultTextStyle.fontSize:typeof s.fontSize=="string"?e=parseInt(s.fontSize,10):e=s.fontSize;const i=new Me(0,0,0,e*1.7),r=t.fillGradientStops.map(n=>Z.shared.setValue(n).toNumber());r.forEach((n,a)=>{const o=a/(r.length-1);i.addColorStop(o,n)}),s.fill={fill:i}}}class Kl{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=X.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Bi(t),e=Bi(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:i,height:r}=e,n=(i<<17)+(r<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const wr=new Kl,Zl=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ii(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Zl.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const Gs={willReadFrequently:!0},mt=class T{static get experimentalLetterSpacingSupported(){let t=T._experimentalLetterSpacingSupported;if(t!==void 0){const e=X.get().getCanvasRenderingContext2D().prototype;t=T._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,a,o,h,c){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,i=T._canvas,r=e.wordWrap){var y;const n=`${t}:${e.styleKey}`;if(T._measurementCache[n])return T._measurementCache[n];const a=ii(e),o=T.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=T.__context;h.font=a;const l=(r?T._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(l.length);let d=0;for(let _=0;_<l.length;_++){const v=T._measureText(l[_],e.letterSpacing,h);u[_]=v,d=Math.max(d,v)}const f=((y=e._stroke)==null?void 0:y.width)||0;let p=d+f;e.dropShadow&&(p+=e.dropShadow.distance);const m=e.lineHeight||o.fontSize;let g=Math.max(m,o.fontSize+f)+(l.length-1)*(m+e.leading);return e.dropShadow&&(g+=e.dropShadow.distance),new T(t,e,p,g,l,u,m+e.leading,d,o)}static _measureText(t,e,i){let r=!1;T.experimentalLetterSpacingSupported&&(T.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(r?n-=e:n+=(T.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,i=T._canvas){const r=i.getContext("2d",Gs);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,u=T._collapseSpaces(l),d=T._collapseNewlines(l);let f=!u;const p=e.wordWrapWidth+c,m=T._tokenize(t);for(let g=0;g<m.length;g++){let x=m[g];if(T._isNewline(x)){if(!d){o+=T._addLine(a),f=!u,a="",n=0;continue}x=" "}if(u){const _=T.isBreakingSpace(x),v=T.isBreakingSpace(a[a.length-1]);if(_&&v)continue}const y=T._getFromCache(x,c,h,r);if(y>p)if(a!==""&&(o+=T._addLine(a),a="",n=0),T.canBreakWords(x,e.breakWords)){const _=T.wordWrapSplit(x);for(let v=0;v<_.length;v++){let C=_[v],I=C,M=1;for(;_[v+M];){const S=_[v+M];if(!T.canBreakChars(I,S,x,v,e.breakWords))C+=S;else break;I=S,M++}v+=M-1;const k=T._getFromCache(C,c,h,r);k+n>p&&(o+=T._addLine(a),f=!1,a="",n=0),a+=C,n+=k}}else{a.length>0&&(o+=T._addLine(a),a="",n=0);const _=g===m.length-1;o+=T._addLine(x,!_),f=!1,a="",n=0}else y+n>p&&(f=!1,o+=T._addLine(a),a="",n=0),(a.length>0||!T.isBreakingSpace(x)||f)&&(a+=x,n+=y)}return o+=T._addLine(a,!1),o}static _addLine(t,e=!0){return t=T._trimRight(t),t=e?`${t}
|
|
`:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=T._measureText(t,e,r)+e,i[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 i=t[e];if(!T.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:T._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:T._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],a=t[r+1];if(T.isBreakingSpace(n,a)||T._isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return T.graphemeSegmenter(t)}static measureFont(t){if(T._fonts[t])return T._fonts[t];const e=T._context;e.font=t;const i=e.measureText(T.METRICS_STRING+T.BASELINE_SYMBOL),r={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return T._fonts[t]=r,r}static clearMetrics(t=""){t?delete T._fonts[t]:T._fonts={}}static get _canvas(){if(!T.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",Gs);if(i!=null&&i.measureText)return T.__canvas=e,e;t=X.get().createCanvas()}catch{t=X.get().createCanvas()}t.width=t.height=10,T.__canvas=t}return T.__canvas}static get _context(){return T.__context||(T.__context=T._canvas.getContext("2d",Gs)),T.__context}};mt.METRICS_STRING="|ÉqÅ";mt.BASELINE_SYMBOL="M";mt.BASELINE_MULTIPLIER=1.4;mt.HEIGHT_MULTIPLIER=2;mt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})();mt.experimentalLetterSpacing=!1;mt._fonts={};mt._newlines=[10,13];mt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];mt._measurementCache={};let ri=mt;function vr(s,t){if(s.texture===G.WHITE&&!s.fill)return Z.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof hs){const e=s.fill,i=t.createPattern(e.texture.source.resource,"repeat"),r=e.transform.copyTo(O.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(r),i}else if(s.fill instanceof Me){const e=s.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(r=>{i.addColorStop(r.offset,Z.shared.setValue(r.color).toHex())}),i}}}else{const e=t.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(O.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),e.setTransform(i),e}return Q("FillStyle not recognised",s),"red"}function jn(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const r=s[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 Xn=class qn extends Mn{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={...qn.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;const i=e.style.clone();e.overrideFill&&(i._fill.color=16777215,i._fill.alpha=1,i._fill.texture=G.WHITE,i._fill.fill=null),this.applyFillAsTint=e.overrideFill;const r=i.fontSize;i.fontSize=this.baseMeasurementFontSize;const n=ii(i);e.overrideSize?i._stroke&&(i._stroke.width*=this.baseRenderedFontSize/r):i.fontSize=this.baseRenderedFontSize=r,this._style=i,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,this.fontMetrics=ri.measureFont(n),this.lineHeight=i.lineHeight||this.fontMetrics.fontSize||i.fontSize}ensureCharacters(t){var m,g;const e=jn(t).filter(x=>!this._currentChars.includes(x)).filter((x,y,_)=>_.indexOf(x)===y);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:r,context:n}=i.canvasAndContext,a=i.texture.source;const o=this._style;let h=this._currentX,c=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*l,d=o.fontStyle==="italic"?2:1;let f=0,p=!1;for(let x=0;x<e.length;x++){const y=e[x],_=ri.measureText(y,o,r,!1);_.lineHeight=_.height;const v=d*_.width*l,C=_.height*l,I=v+u*2,M=C+u*2;if(p=!1,y!==`
|
|
`&&y!=="\r"&&y!==" "&&y!==" "&&(p=!0,f=Math.ceil(Math.max(M,f))),h+I>this._textureSize&&(c+=f,f=M,h=0,c+f>this._textureSize)){a.update();const S=this._nextPage();r=S.canvasAndContext.canvas,n=S.canvasAndContext.context,a=S.texture.source,c=0}const k=v/l-(((m=o.dropShadow)==null?void 0:m.distance)??0)-(((g=o._stroke)==null?void 0:g.width)??0);if(this.chars[y]={id:y.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},p){this._drawGlyph(n,_,h+u,c+u,l,o);const S=a.width*l,A=a.height*l,Y=new W(h/S*a.width,c/A*a.height,I/S*a.width,M/A*a.height);this.chars[y].texture=new G({source:a,frame:Y}),h+=Math.ceil(I)}}a.update(),this._currentX=h,this._currentY=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return L(z,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=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=i[n];h||(h=i[n]=e.measureText(n).width);let c=i[o];c||(c=i[o]=e.measureText(o).width);let l=e.measureText(n+o).width,u=l-(h+c);u&&(this.chars[n].kerning[o]=u),l=e.measureText(n+o).width,u=l-(h+c),u&&(this.chars[o].kerning[n]=u)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=wr.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r=new G({source:new re({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})}),n={canvasAndContext:e,texture:r};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=ii(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=vr(r,t)),e._fill&&(t.fillStyle=vr(e._fill,t)),e.dropShadow){const a=e.dropShadow,o=Z.shared.setValue(a.color).toArray(),h=a.blur*i,c=a.distance*i;t.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(a.angle)*c,t.shadowOffsetY=Math.sin(a.angle)*c}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,r,n,a){const o=e.text,h=e.fontProperties,c=a._stroke,l=((c==null?void 0:c.width)??0)*n,u=i+l/2,d=r-l/2,f=h.descent*n,p=e.lineHeight*n;a.stroke&&l&&t.strokeText(o,u,d+p-f),a._fill&&t.fillText(o,u,d+p-f)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];e.canvas.width=e.canvas.width,wr.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};Xn.defaultOptions={textureSize:512,style:new lt,mipmap:!0};let Sr=Xn;function Ql(s,t,e,i){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 m=n.width;for(let g=0;g<h.index;g++){const x=p.positions[g];n.chars.push(p.chars[g]),n.charPositions.push(x+m)}n.width+=p.width,o=!1,h.width=0,h.index=0,h.chars.length=0},l=()=>{let p=n.chars.length-1;if(i){let m=n.chars[p];for(;m===" ";)n.width-=e.chars[m].xAdvance,m=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},u=e.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*u,f=t.wordWrapWidth*u;for(let p=0;p<s.length+1;p++){let m;const g=p===s.length;g||(m=s[p]);const x=e.chars[m]||e.chars[" "];if(/(?:\s)/.test(m)||m==="\r"||m===`
|
|
`||g){if(!o&&t.wordWrap&&n.width+h.width-d>f?(l(),c(h),g||n.charPositions.push(0)):(h.start=n.width,c(h),g||n.charPositions.push(0)),m==="\r"||m===`
|
|
`)n.width!==0&&l();else if(!g){const C=x.xAdvance+(x.kerning[a]||0)+d;n.width+=C,n.spaceWidth=C,n.spacesIndex.push(n.charPositions.length),n.chars.push(m)}}else{const v=x.kerning[a]||0,C=x.xAdvance+v+d;h.positions[h.index++]=h.width+v,h.chars.push(m),h.width+=C}a=m}return l(),t.align==="center"?Jl(r):t.align==="right"?tc(r):t.align==="justify"&&ec(r),r}function Jl(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width/2-e.width/2;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i}}function tc(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width-e.width;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i}}function ec(s){const t=s.width;for(let e=0;e<s.lines.length;e++){const i=s.lines[e];let r=0,n=i.spacesIndex[r++],a=0;const o=i.spacesIndex.length,c=(t-i.width)/o;for(let l=0;l<i.charPositions.length;l++)l===n&&(n=i.spacesIndex[r++],a+=c),i.charPositions[l]+=a}}let Xe=0;class sc{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(t,e){var a;let i=`${e.fontFamily}-bitmap`,r=!0;if(e._fill.fill&&!e._stroke)i+=e._fill.fill.styleKey,r=!1;else if(e._stroke||e.dropShadow){let o=e.styleKey;o=o.substring(0,o.lastIndexOf("-")),i=`${o}-bitmap`,r=!1}if(!H.has(i)){const o=new Sr({style:e,overrideFill:r,overrideSize:!0,...this.defaultOptions});Xe++,Xe>50&&Q("BitmapText",`You have dynamically created ${Xe} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{Xe--,H.remove(i)}),H.set(i,o)}const n=H.get(i);return(a=n.ensureCharacters)==null||a.call(n,t),n}getLayout(t,e,i=!0){const r=this.getFont(t,e);return Ql([...t],e,r,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var c,l,u,d;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:(u=t[2])==null?void 0:u.padding,skipKerning:(d=t[2])==null?void 0:d.skipKerning},L(z,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e==null?void 0:e.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof lt?r:new lt(r),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new Sr({style:n,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=jn(e.chars);return o.ensureCharacters(h.join("")),H.set(`${i}-bitmap`,o),o.once("destroy",()=>H.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=H.get(e);i&&(H.remove(e),i.destroy())}}const Ar=new sc;class Kn extends Mn{constructor(t,e){super();const{textures:i,data:r}=t;Object.keys(r.pages).forEach(n=>{const a=r.pages[parseInt(n,10)],o=i[a.id];this.pages.push({texture:o})}),Object.keys(r.chars).forEach(n=>{const a=r.chars[n],{frame:o,source:h}=i[a.page],c=new W(a.x+o.x,a.y+o.y,a.width,a.height),l=new G({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){Ar.install(t)}static uninstall(t){Ar.uninstall(t)}}const Ls={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const t=s.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in t){const d=t[u].match(/^[a-z]+/gm)[0],f=t[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),p={};for(const m in f){const g=f[m].split("="),x=g[0],y=g[1].replace(/"/gm,""),_=parseFloat(y),v=isNaN(_)?y:_;p[x]=v}e[d].push(p)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=e.info,[n]=e.common,[a]=e.distanceField??[];a&&(i.distanceField={range:parseInt(a.distanceRange,10),type:a.fieldType}),i.fontSize=parseInt(r.size,10),i.fontFamily=r.face,i.lineHeight=parseInt(n.lineHeight,10);const o=e.page;for(let u=0;u<o.length;u++)i.pages.push({id:parseInt(o[u].id,10)||0,file:o[u].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const c=e.char;for(let u=0;u<c.length;u++){const d=c[u],f=parseInt(d.id,10);let p=d.letter??d.char??String.fromCharCode(f);p==="space"&&(p=" "),h[f]=p,i.chars[p]={id:f,page:parseInt(d.page,10)||0,x:parseInt(d.x,10),y:parseInt(d.y,10),width:parseInt(d.width,10),height:parseInt(d.height,10),xOffset:parseInt(d.xoffset,10),yOffset:parseInt(d.yoffset,10),xAdvance:parseInt(d.xadvance,10),kerning:{}}}const l=e.kerning||[];for(let u=0;u<l.length;u++){const d=parseInt(l[u].first,10),f=parseInt(l[u].second,10),p=parseInt(l[u].amount,10);i.chars[h[f]].kerning[h[d]]=p}return i}},Cr={test(s){const t=s;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=s.getElementsByTagName("info")[0],i=s.getElementsByTagName("common")[0],r=s.getElementsByTagName("distanceField")[0];r&&(t.distanceField={type:r.getAttribute("fieldType"),range:parseInt(r.getAttribute("distanceRange"),10)});const n=s.getElementsByTagName("page"),a=s.getElementsByTagName("char"),o=s.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let c=0;c<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(i.getAttribute("base"),10);for(let c=0;c<a.length;c++){const l=a[c],u=parseInt(l.getAttribute("id"),10);let d=l.getAttribute("letter")??l.getAttribute("char")??String.fromCharCode(u);d==="space"&&(d=" "),h[u]=d,t.chars[d]={id:u,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),u=parseInt(o[c].getAttribute("second"),10),d=parseInt(o[c].getAttribute("amount"),10);t.chars[h[u]].kerning[h[l]]=d}return t}},Tr={test(s){return typeof s=="string"&&s.includes("<font>")?Cr.test(X.get().parseXML(s)):!1},parse(s){return Cr.parse(X.get().parseXML(s))}},ic=[".xml",".fnt"],rc={extension:{type:P.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof Kn,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},nc={extension:{type:P.LoadParser,priority:Bt.Normal},name:"loadBitmapFont",test(s){return ic.includes(ht.extname(s).toLowerCase())},async testParse(s){return Ls.test(s)||Tr.test(s)},async parse(s,t,e){const i=Ls.test(s)?Ls.parse(s):Tr.parse(s),{src:r}=t,{pages:n}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;u<n.length;++u){const d=n[u].file;let f=ht.join(ht.dirname(r),d);f=$s(f,r),a.push({src:f,data:o})}const h=await e.load(a),c=a.map(u=>h[u.src]);return new Kn({data:i,textures:c},r)},async load(s,t){return await(await X.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}};class ac{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const oc={extension:{type:P.CacheParser,name:"cacheTextureArray"},test:s=>Array.isArray(s)&&s.every(t=>t instanceof G),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};async function Zn(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const hc={extension:{type:P.DetectionParser,priority:1},test:async()=>Zn("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},Mr=["png","jpg","jpeg"],lc={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Mr],remove:async s=>s.filter(t=>!Mr.includes(t))},cc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function yi(s){return cc?!1:document.createElement("video").canPlayType(s)!==""}const uc={extension:{type:P.DetectionParser,priority:0},test:async()=>yi("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},dc={extension:{type:P.DetectionParser,priority:0},test:async()=>yi("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},fc={extension:{type:P.DetectionParser,priority:0},test:async()=>yi("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},pc={extension:{type:P.DetectionParser,priority:0},test:async()=>Zn("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};class gc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||Q(`[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 Q(`[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),i.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,i.parser=c)}return r})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const r={},n=es(t),a=gt(t,c=>({alias:[c],src:c,data:{}})),o=a.length,h=a.map(async c=>{const l=ht.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(++i/o)}catch(u){throw delete this.promiseCache[l],delete r[c.src],new Error(`[Loader.load] Failed to load ${l}.
|
|
${u}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const i=gt(t,r=>({alias:[r],src:r})).map(async r=>{var o,h;const n=ht.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(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&Q(`[Assets] loadParser name conflict "${e.name}"`):Q("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function ae(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function oe(s,t){const e=s.split("?")[0],i=ht.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const mc=".json",xc="application/json",yc={extension:{type:P.LoadParser,priority:Bt.Low},name:"loadJson",test(s){return ae(s,xc)||oe(s,mc)},async load(s){return await(await X.get().fetch(s)).json()}},_c=".txt",bc="text/plain",wc={name:"loadTxt",extension:{type:P.LoadParser,priority:Bt.Low,name:"loadTxt"},test(s){return ae(s,bc)||oe(s,_c)},async load(s){return await(await X.get().fetch(s)).text()}},vc=["normal","bold","100","200","300","400","500","600","700","800","900"],Sc=[".ttf",".otf",".woff",".woff2"],Ac=["font/ttf","font/otf","font/woff","font/woff2"],Cc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Tc(s){const t=ht.extname(s),r=ht.basename(s,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(Cc)){n=!1;break}let a=r.join(" ");return n||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const Mc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Pc(s){return Mc.test(s)?s:encodeURI(s)}const kc={extension:{type:P.LoadParser,priority:Bt.Low},name:"loadWebFont",test(s){return ae(s,Ac)||oe(s,Sc)},async load(s,t){var i,r,n;const e=X.get().getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??Tc(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(l=>vc.includes(l)))??["normal"],c=t.data??{};for(let l=0;l<h.length;l++){const u=h[l],d=new FontFace(o,`url(${Pc(s)})`,{...c,weight:u});await d.load(),e.add(d),a.push(d)}return H.set(`${o}-and-url`,{url:s,fontFaces:a}),a.length===1?a[0]:a}return Q("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>{H.remove(t.family),X.get().getFontFaceSet().delete(t)})}};function _i(s,t=1){var i;const e=(i=ne.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}function bi(s,t,e){s.label=e,s._sourceOrigin=e;const i=new G({source:s,label:e}),r=()=>{delete t.promiseCache[e],H.has(e)&&H.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(Q("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),i.once("destroy",()=>{s.destroyed||(Q("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const Bc=".svg",Ec="image/svg+xml",Ic={extension:{type:P.LoadParser,priority:Bt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return ae(s,Ec)||oe(s,Bc)},async load(s,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Rc(s):Fc(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Fc(s,t,e,i){var g,x,y;const n=await(await X.get().fetch(s)).blob(),a=URL.createObjectURL(n),o=new Image;o.src=a,o.crossOrigin=i,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((g=t.data)==null?void 0:g.resolution)||_i(s),u=((x=t.data)==null?void 0:x.width)??o.width,d=((y=t.data)==null?void 0:y.height)??o.height;h.width=u*l,h.height=d*l,c.drawImage(o,0,0,u*l,d*l);const{parseAsGraphicsContext:f,...p}=t.data,m=new re({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return bi(m,e,s)}async function Rc(s){const e=await(await X.get().fetch(s)).text(),i=new ct;return i.svg(e),i}const Gc=`(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 Zt=null,ni=class{constructor(){Zt||(Zt=URL.createObjectURL(new Blob([Gc],{type:"application/javascript"}))),this.worker=new Worker(Zt)}};ni.revokeObjectURL=function(){Zt&&(URL.revokeObjectURL(Zt),Zt=null)};const Lc=`(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 Qt=null;class Qn{constructor(){Qt||(Qt=URL.createObjectURL(new Blob([Lc],{type:"application/javascript"}))),this.worker=new Worker(Qt)}}Qn.revokeObjectURL=function(){Qt&&(URL.revokeObjectURL(Qt),Qt=null)};let Pr=0,zs;class zc{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 ni;e.addEventListener("message",i=>{e.terminate(),ni.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){zs===void 0&&(zs=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<zs&&(this._createdWorkers++,t=new Qn().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[Pr]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Pr++,id:i})}}const kr=new zc,Oc=[".jpeg",".jpg",".png",".webp",".avif"],Wc=["image/jpeg","image/png","image/webp","image/avif"];async function Uc(s,t){var r;const e=await X.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);const i=await e.blob();return((r=t==null?void 0:t.data)==null?void 0:r.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const Jn={name:"loadTextures",extension:{type:P.LoadParser,priority:Bt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return ae(s,Wc)||oe(s,Oc)},async load(s,t,e){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await kr.isImageBitmapSupported()?i=await kr.loadImageBitmap(s,t):i=await Uc(s,t):i=await new Promise(a=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?a(i):i.onload=()=>{a(i)}});const r=new re({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||_i(s),...t.data});return bi(r,e,s)},unload(s){s.destroy(!0)}},ta=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],Dc=ta.map(s=>`video/${s.substring(1)}`);function Nc(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=$c(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function Hc(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t()}function r(a){n(),e(a)}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r)}})}function $c(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const Vc={name:"loadVideo",extension:{type:P.LoadParser,name:"loadVideo"},test(s){const t=ae(s,Dc),e=oe(s,ta);return t||e},async load(s,t,e){var h,c;const i={...qe.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||_i(s),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await sn(),...t.data},r=document.createElement("video"),n={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{const u=n[l];u!==void 0&&r.setAttribute(l,u)}),i.muted===!0&&(r.muted=!0),Nc(r,s,i.crossorigin);const a=document.createElement("source");let o;if(s.startsWith("data:"))o=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();o=qe.MIME_TYPES[l]||`video/${l}`}return a.src=s,o&&(a.type=o),new Promise(l=>{const u=async()=>{const d=new qe({...i,resource:r});r.removeEventListener("canplay",u),t.data.preload&&await Hc(r),l(bi(d,e,s))};r.addEventListener("canplay",u),r.appendChild(a)})},unload(s){s.destroy(!0)}},ea={extension:{type:P.ResolveParser,name:"resolveTexture"},test:Jn.test,parse:s=>{var t;return{resolution:parseFloat(((t=ne.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},Yc={extension:{type:P.ResolveParser,priority:-2,name:"resolveJson"},test:s=>ne.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:ea.parse};class jc{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ne,this.loader=new gc,this.cache=H,this._backgroundLoader=new ac(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){Q("[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,i=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:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=es(t),r=gt(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 i?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const 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(u=>{const d=r[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,c).then(f=>{n[u]=f})});return await Promise.all(l),i?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(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return H.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=H.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const r=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.forEach(a=>{const o=r[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{n[c]=o}),H.set(h,o)}),n}async unload(t){this._initialized||await this.init();const e=gt(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=gt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{H.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const _e=new jc;rt.handleByList(P.LoadParser,_e.loader.parsers).handleByList(P.ResolveParser,_e.resolver.parsers).handleByList(P.CacheParser,_e.cache.parsers).handleByList(P.DetectionParser,_e.detections);rt.add(oc,lc,hc,pc,uc,dc,fc,yc,wc,kc,Ic,Jn,Vc,nc,rc,ea,Yc);const Br={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};rt.handle(P.Asset,s=>{const t=s.ref;Object.entries(Br).filter(([e])=>!!t[e]).forEach(([e,i])=>rt.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(Br).filter(e=>!!t[e]).forEach(e=>rt.remove(t[e]))});class $t extends is{constructor(t){t instanceof ct&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new ct,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new $t(this._context.clone()):(this._ownedContext=null,new $t(this._context))}lineStyle(t,e,i){L(z,"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),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){L(z,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){L(z,"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!==ct.defaultStrokeStyle.width||t.color!==ct.defaultStrokeStyle.color||t.alpha!==ct.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return L(z,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return L(z,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return L(z,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return L(z,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return L(z,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return L(z,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const sa=class ia extends Rn{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(L(z,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...ia.defaultOptions,...e};const i=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 kt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:K.VERTEX|K.COPY_DST}),h=new kt({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:K.VERTEX|K.COPY_DST}),c=new kt({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:K.INDEX|K.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:c,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};sa.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Xc=sa;class ke extends dt{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:i,autoUpdate:r,...n}=e,[a]=i;super({...n,texture:a instanceof G?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=i}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(_t.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(_t.shared.add(this.update,this,ts.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,r=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/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+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):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 i=0;i<t.length;++i)e.push(G.from(t[i]));return new ke(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(G.from(t[i]));return new ke(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof G)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?(_t.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(_t.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class qc extends is{constructor(t,e){const{text:i,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=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new nt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!1,o!==void 0&&(this.width=o),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function Kc(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(L(z,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}class Ct extends qc{constructor(...t){const e=Kc(t,"Text");super(e,lt),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,i=ri.measureText(this._text,this._style),{width:r,height:n}=i;t.minX=-e._x*r,t.maxX=t.minX+r,t.minY=-e._y*n,t.maxY=t.minY+n}}const ra=class na extends Xc{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(L(z,"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={...na.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;const e=this.verticesX*this.verticesY,i=[],r=[],n=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,c=this.height/o;for(let u=0;u<e;u++){const d=u%this.verticesX,f=u/this.verticesX|0;i.push(d*h,f*c),r.push(d/a,f/o)}const l=a*o;for(let u=0;u<l;u++){const d=u%a,f=u/a|0,p=f*this.verticesX+d,m=f*this.verticesX+d+1,g=(f+1)*this.verticesX+d,x=(f+1)*this.verticesX+d+1;n.push(p,m,g,m,x,g)}this.buffers[0].data=new Float32Array(i),this.buffers[1].data=new Float32Array(r),this.indexBuffer.data=new Uint32Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};ra.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Zc=ra;const aa=class oa extends Zc{constructor(t={}){t={...oa.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,i=this.width>e?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,a=Math.min(i,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,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};aa.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let jt=aa;const ha=class la extends is{constructor(t){var u,d,f,p;t instanceof G&&(t={texture:t});const{width:e,height:i,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??((u=h==null?void 0:h.defaultBorders)==null?void 0:u.left)??jt.defaultOptions.leftWidth,this._topHeight=a??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.top)??jt.defaultOptions.topHeight,this._rightWidth=n??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.right)??jt.defaultOptions.rightWidth,this._bottomHeight=o??((p=h==null?void 0:h.defaultBorders)==null?void 0:p.bottom)??jt.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??jt.defaultOptions.width,this.bounds.maxY=this._height=i??h.height??jt.defaultOptions.height,this.allowChildren=!1,this.texture=h??la.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=G.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null}};ha.defaultOptions={texture:G.EMPTY};let Ie=ha;rt.add(wa,va);class w{}b(w,"app"),b(w,"GameMaster"),b(w,"Grid"),b(w,"WaveManager"),b(w,"TowerManager"),b(w,"AnimationManager"),b(w,"NotificationManager"),b(w,"GameScene"),b(w,"latestCommit"),b(w,"GridCellSize",64),b(w,"GridColumns",25),b(w,"GridRows",17);class Qc{constructor(){b(this,"currentScene");b(this,"GameObjects",[]);w.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),w.GameMaster.currentScene.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),w.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()}}const j=class j{static async Load(t){return this.text.text="Loading asset: "+t,console.log("LOADING "+t),await _e.load({src:t})}static async LoadAssets(){if(this.text)throw"Do not call GameAssets.LoadAssets() more than once.";console.log("Loading Texture Assets");const t=new Ct({text:"Loading textures. This might take a while.",style:new lt({fill:3355443,fontSize:50})});t.x=w.app.canvas.width/2,t.y=w.app.canvas.height/2,t.anchor.set(.5,.5),w.app.stage.addChild(t),this.text=new Ct({text:"",style:new lt({fill:3355443,fontSize:50})}),this.text.x=w.app.canvas.width/2,this.text.y=w.app.canvas.height/2+50,this.text.anchor.set(.5,.5),w.app.stage.addChild(this.text),await this.Load("/aclonica.woff2"),this.Button01Texture=await this.Load("/assets/gui/button_01.png"),this.Button02Texture=await this.Load("/assets/gui/button_02.png"),this.Frame01Texture=await this.Load("/assets/gui/frame_01.png"),this.Frame02Texture=await this.Load("/assets/gui/frame_02.png"),this.Frame03Texture=await this.Load("/assets/gui/frame_03.png"),this.FrameBackground=await this.Load("/assets/gui/background_01.png"),this.FrameTowerTab=await this.Load("/assets/gui/background_02.png"),this.VioletBackground=await this.Load("/assets/gui/frame_violet.png"),this.RedBackground=await this.Load("/assets/gui/frame_red.png"),this.GreenBackground=await this.Load("/assets/gui/frame_green.png"),this.HealthTexture=await this.Load("/assets/gui/heart.png"),this.GoldTexture=await this.Load("/assets/gui/money.png"),this.WaveTexture=await this.Load("/assets/gui/wave.png"),await this.LoadMissions(),await this.LoadTowers(),await this.LoadCreeps(),t.destroy(),this.text.destroy(),this.text=!0}static async LoadCreeps(){const e=await(await fetch("/assets/json/Creeps.json")).json();this.Creeps=e;for(let i=0;i<this.Creeps.length;i++){const r=this.Creeps[i];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(){j.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,console.log(this.Towers);for(let i=0;i<this.Towers.length;i++){const r=this.Towers[i];for(let n=0;n<r.projectileTexturesArrayLength;n++){console.log(`WANT TO LOAD /assets/projectiles/${r.sprite}/${n}.png`);const a=await this.Load(`/assets/projectiles/${r.sprite}/${n}.png`);r.projectileTextures[n]=a,console.log(r.projectileTextures)}}e.forEach(async i=>{let r=this.TowerSprites.length-1;r==-1&&(r=0),this.TowerSprites[r]=await this.Load(`/assets/towers/${i.sprite}.png`)})}static async LoadMission(t){const i=await(await fetch(t)).json();return await this.LoadBackground(i.mapImage.url),i}static async LoadBackground(t){let e=this.MissionBackgrounds.length-1;e==-1&&(e=0),this.MissionBackgrounds[e]=await this.Load(t)}};b(j,"Frame01Texture"),b(j,"Frame02Texture"),b(j,"Frame03Texture"),b(j,"FrameBackground"),b(j,"FrameTowerTab"),b(j,"VioletBackground"),b(j,"RedBackground"),b(j,"GreenBackground"),b(j,"Button01Texture"),b(j,"Button02Texture"),b(j,"HealthTexture"),b(j,"GoldTexture"),b(j,"WaveTexture"),b(j,"Missions"),b(j,"MissionBackgrounds",[]),b(j,"TowerSprites",[]),b(j,"Towers"),b(j,"Creeps"),b(j,"text");let V=j;class Fe{constructor(t){b(this,"name",this.constructor.name);b(this,"_container",new st);b(this,"_events",new at);b(this,"enabled",!0);w.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}}var se=(s=>(s[s.Button01=0]="Button01",s[s.Button02=1]="Button02",s))(se||{});class Be extends Fe{constructor(e,i,r,n=!0){super(!0);b(this,"caption");b(this,"bounds");b(this,"buttonTexture");b(this,"buttonSprite");b(this,"buttonText");r==0&&(this.buttonTexture=V.Button01Texture),r==1&&(this.buttonTexture=V.Button02Texture),this.caption=i,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 Ie({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 Ct({text:this.caption,style:new lt({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}}class Et{constructor(){b(this,"name",this.constructor.name);b(this,"_container",new st);b(this,"bb",new W);b(this,"_events",new at)}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 ie=(s=>(s.Died="died",s.TakenDamage="takenDamage",s.Escaped="escaped",s.Moved="moved",s))(ie||{});class Jc extends Et{constructor(e,i,r){super();b(this,"id");b(this,"creepType");b(this,"sprite");b(this,"path");b(this,"stats");b(this,"pathIndex",0);b(this,"speed");b(this,"direction",1);b(this,"healthBarGraphics",new $t);b(this,"healthBarWidth",50);b(this,"health");b(this,"maxHealth");b(this,"escaped",!1);b(this,"died",!1);b(this,"x");b(this,"y");b(this,"dead",!1);this.creepType=e,this.stats=structuredClone(V.Creeps[this.creepType].stats),this.sprite=new ke(V.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=w.GridCellSize,this.sprite.height=w.GridCellSize,this.bb.width=this.sprite.width,this.speed=this.stats.speed/60,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=i,this.x=i[0][1]*w.GridCellSize+w.GridCellSize/2,this.y=i[0][0]*w.GridCellSize+w.GridCellSize/2,w.GameScene.events.on("takenDamage",(n,a)=>{n==this.id&&(this.health-=a,this.UpdateHealthbar())}),w.Grid.container.addChild(this.container),this.container.addChild(this.healthBarGraphics),this.container.addChild(this.sprite),this.UpdateHealthbar()}UpdateHealthbar(){this.healthBarGraphics.clear();const e=this.health,i=this.maxHealth,r=e/i,n=this.healthBarWidth*r;this.healthBarGraphics.rect(-this.healthBarWidth/2+5,-30,this.healthBarWidth,10),this.healthBarGraphics.fill({color:65280}),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){w.GameScene.events.emit("died",this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit("escaped",this),this.escaped=!0;return}const i=this.path[this.pathIndex],r=this.path[this.pathIndex+1],n=r[1]*w.GridCellSize+w.GridCellSize/2,a=r[0]*w.GridCellSize+w.GridCellSize/2,o=r[1]-i[1],h=r[0]-i[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,u=!1;c>0&&this.x+c>n&&(c=n-this.x,u=!0),c<0&&this.x+c<n&&(c=n-this.x,u=!0),l>0&&this.y+l>a&&(l=a-this.y,u=!0),l<0&&this.y+l<a&&(l=a-this.y,u=!0),this.x+=c,this.y+=l,u&&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("died",this))}destroy(){super.destroy(),this.container.removeChildren()}}var Nt=(s=>(s[s.Restricted=0]="Restricted",s[s.Buildable=1]="Buildable",s[s.Path=9]="Path",s))(Nt||{});class tu extends Et{constructor(e,i,r,n){super();b(this,"type");b(this,"row");b(this,"column");b(this,"isPath",!1);b(this,"g");b(this,"clickDetector");this.type=e,this.row=i,this.column=r,this.isPath=n,this.bb.x=this.column*w.GridCellSize,this.bb.y=this.row*w.GridCellSize,this.bb.width=w.GridCellSize,this.bb.height=w.GridCellSize,w.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new $t({zIndex:99,interactive:!0}),this.clickDetector.rect(0,0,this.bb.width,this.bb.height),this.clickDetector.fill({color:16711680,alpha:0}),this.container.addChild(this.clickDetector),this.clickDetector.onpointerdown=a=>{w.Grid.onGridCellClicked(i,r)}}gDraw(){switch(this.g=new $t({zIndex:5}),this.g.rect(0,0,this.bb.width,this.bb.height),this.type){case Nt.Restricted:this.g.fill({color:2236962,alpha:.5});break;case Nt.Path:this.g.fill({color:2236962,alpha:.5});break;case Nt.Buildable:this.g.stroke({color:65280,alpha:.9});break}this.container.addChild(this.g)}gClear(){this.g!=null&&(this.container.removeChild(this.g),this.g.destroy())}update(){}}class eu extends Et{constructor(e,i){super();b(this,"gameMap");b(this,"cells",[]);b(this,"creeps",[]);b(this,"gridShown",!1);this.gameMap=e,w.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=w.GridCellSize*w.GridColumns,this.bb.height=w.GridCellSize*w.GridRows,w.GameMaster.currentScene.stage.addChild(this.container);let r=new dt(V.MissionBackgrounds[i]);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(u=>u[0]===a&&u[1]===n));h&&(o=Nt.Path);let c=new tu(o,a,n,h);this.cells.push(c)}}toggleGrid(){this.cells.forEach(e=>{this.gridShown?e.gClear():e.gDraw()}),this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(ie.Died,i=>{this.onCreepDiedOrEscaped(i)}),e.events.on(ie.Escaped,i=>{this.onCreepDiedOrEscaped(i)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(i=>{i.dead?(this.creeps.splice(this.creeps.indexOf(i),1),i=null):i.update(e)})}getCellByRowAndCol(e,i){return this.cells.filter(r=>r.row==e&&r.column==i)[0]}onGridCellClicked(e,i){}}var Se=(s=>(s.CreepSpawned="creepSpawned",s.Finished="finished",s.NewWave="newwave",s))(Se||{});class su extends Et{constructor(e,i){super();b(this,"creeps",[]);b(this,"rounds");b(this,"paths");b(this,"ticks",0);b(this,"started",!1);b(this,"finished",!1);b(this,"internalCreepId",0);w.WaveManager=this,this.rounds=e,this.paths=i}start(e){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1;let i=0;this.rounds[e].waves.forEach(r=>{i+=r.firstCreepSpawnTick,r.creeps.forEach(n=>{const a=new Jc(n,this.paths[0],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:i,spawned:!1};console.log("CREAWTASEDASD"),i+=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(i=>{!i.spawned&&i.tickToSpawnAt<=this.ticks?(i.spawned=!0,this.events.emit("creepSpawned",i.creep),console.log("Wave manager creep spawned, ",i,this.ticks),!this.finished&&this.creeps.every(r=>r.spawned)&&(this.finished=!0,console.log("wave maanger finisehd"),this.events.emit("finished"))):i.spawned&&i.creep.update(e)}))}}var ca=(s=>(s.BasicTowerBehaviour="BasicTowerBehaviour",s))(ca||{});class iu{constructor(){b(this,"isPlacingTower",!1);b(this,"canPlaceTowers",!0);b(this,"selectedTower",null);b(this,"towers",[]);w.TowerManager=this}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(w.Grid.toggleGrid(),this.isPlacingTower?this.selectedTower=null:V.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e)}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)throw w.NotificationManager.Notify("TowerManager.selectedTower is null when trying to place tower.","danger"),console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let i=null;return this.towers.forEach(r=>{r.row==t&&r.column==e&&(i=r)}),i}PlaceTower(t,e,i,r,n){let a=0;V.Towers.forEach((h,c)=>{h.sprite==t.sprite&&(a=c)});const o=V.TowerSprites[a];if(!w.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!n)return console.warn("Does not have enough gold.");if(!this.GetTowerByRowAndCol(e,i)&&w.Grid.getCellByRowAndCol(e,i).type!=Nt.Path&&w.Grid.getCellByRowAndCol(e,i).type!=Nt.Restricted){w.GameScene.MissionStats.spendGold(t.stats.cost);let h=new ou(e,i,o,t,r);this.towers.push(h),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,w.GameScene.events.emit(wi.TowerPlacedEvent,t.name)}else w.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)})}}function ru(s,t,e,i){const r=e-s,n=i-t;return Math.atan2(n,r)}class nu extends Et{constructor(e,i,r,n,a){super();b(this,"deleteMe",!1);b(this,"sprite");b(this,"x");b(this,"y");b(this,"angle");b(this,"speed");b(this,"damage");b(this,"timeToLive",1);this.x=e,this.y=i,this.damage=a,this.sprite=new ke({textures:r,scale:.25,rotation:n}),this.sprite.anchor.set(.5),this.sprite.play(),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),w.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();w.Grid.creeps.forEach(i=>{if(!(this.timeToLive<=0)&&i.container&&this.checkCollision(i)){this.timeToLive--,this.onCollide(i);return}}),this.x+=Math.cos(this.angle)*this.speed*e,this.y+=Math.sin(this.angle)*this.speed*e,this.container.x=this.x,this.container.y=this.y}}onCollide(e){w.GameScene.events.emit(ie.TakenDamage,e.id,this.damage)}checkCollision(e){if(e==null)return;let i=this.copyContainerToBB(),r=e.copyContainerToBB();return i.getBounds().intersects(r.getBounds())}}function au(s,t,e,i){return Math.sqrt((e-s)*(e-s)+(i-t)*(i-t))}var wi=(s=>(s.TowerPlacedEvent="towerPlacedEvent",s))(wi||{});class ou extends Et{constructor(e,i,r,n,a){super();b(this,"row");b(this,"column");b(this,"projectiles",[]);b(this,"behaviour");b(this,"definition");b(this,"sprite");b(this,"ticksUntilNextShot");b(this,"graphics",new $t);this.row=e,this.column=i,this.behaviour=a,this.definition=n,this.ticksUntilNextShot=0;let o=w.Grid.getCellByRowAndCol(e,i);this.sprite=new dt({texture:r,height:w.GridCellSize,width:w.GridCellSize,zIndex:10}),this.container.addChild(this.sprite),o.container.addChild(this.container),o.clickDetector.onmouseenter=h=>{this.showRangeDisplay()},o.clickDetector.onmouseleave=h=>{this.graphics.clear()},w.GameMaster.currentScene.stage.addChild(this.graphics),this.showRangeDisplay()}showRangeDisplay(){this.graphics.circle(this.column*w.GridCellSize+w.GridCellSize/2,this.row*w.GridCellSize+w.GridCellSize/2,this.definition.stats.range*w.GridCellSize),this.graphics.fill({color:16711680,alpha:.5})}GetCreepsInRange(){return w.Grid.creeps.filter(i=>{const r=i.x,n=i.y,a=this.column*w.GridCellSize+w.GridCellSize/2,o=this.row*w.GridCellSize+w.GridCellSize/2,h=this.definition.stats.range*w.GridCellSize;return au(a,o,r,n)<h+w.GridCellSize*2/3})}Shoot(e){let i=this.column*w.GridCellSize+w.GridCellSize/2,r=this.row*w.GridCellSize+w.GridCellSize/2,n=ru(i,r,e.x,e.y);this.projectiles.push(new nu(i,r,this.definition.projectileTextures,n,this.definition.stats.damage))}update(e){if(this.projectiles.forEach(i=>{i.deleteMe?(this.projectiles.splice(this.projectiles.indexOf(i),1),i=null):i.update(e)}),this.behaviour==ca.BasicTowerBehaviour){this.ticksUntilNextShot>0&&this.ticksUntilNextShot--;let i=this.GetCreepsInRange();if(i.length>0){let r=i[0];this.ticksUntilNextShot==0&&(this.ticksUntilNextShot=this.definition.stats.cooldown,this.Shoot(r))}}}}class Er extends Fe{constructor(e,i,r,n,a,o,h){if(e>3||i>2||e<0||i<0)throw"Index/row out of bounds for TowerButton.";super(!0);b(this,"frameSprite");b(this,"background");b(this,"towerName");b(this,"i",0);this.towerName=h,this.container.x=e*r+5,this.container.y=i*n+5,this.background=new dt({texture:o}),this.background.width=r,this.background.height=n,this.container.addChild(this.background),this.frameSprite=new Ie({texture:V.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:n,width:r}),this.container.addChild(this.frameSprite),a.addChild(this.container),w.GameScene.events.on(wi.TowerPlacedEvent,c=>{this.frameSprite.tint=16777215}),this.container.onmouseenter=c=>{},this.container.onmouseleave=c=>{}}onClick(e){this.frameSprite.tint==65280?this.frameSprite.tint=16777215:this.frameSprite.tint=65280,w.TowerManager.ToggleChoosingTowerLocation(this.towerName)}}class hu extends Fe{constructor(e){super(!1);b(this,"bounds");b(this,"towerTabSprite");b(this,"towerList",[]);this.bounds=e,V.Towers.forEach(i=>{let r={name:i.name,description:i.description,cost:i.stats.cost};this.towerList.push(r)}),this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new Ie({texture:V.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),new Er(0,0,70,70,this.container,V.RedBackground,"Basic Tower"),new Er(0,1,70,70,this.container,V.GreenBackground,"Basic Tower")}}class lu extends Fe{constructor(e){super(!1);b(this,"bounds");b(this,"gemTabSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new Ie({texture:V.FrameTowerTab,leftWidth:1e3,topHeight:1e3,rightWidth:1e3,bottomHeight:1e3}),this.gemTabSprite.x=0,this.gemTabSprite.y=0,this.gemTabSprite.width=this.bounds.width,this.gemTabSprite.height=this.bounds.height,this.container.addChild(this.gemTabSprite)}}class cu extends Fe{constructor(e){super(!1);b(this,"bounds");b(this,"sidebarSprite");b(this,"towerTab");b(this,"gemTab");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new Ie({texture:V.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.sidebarSprite.x=40,this.sidebarSprite.y=-40,this.sidebarSprite.width=this.bounds.width+40,this.sidebarSprite.height=this.bounds.height+80,this.container.addChild(this.sidebarSprite);const i=new W(60,20,this.bounds.width-65,150);this.towerTab=new hu(i),this.container.addChild(this.towerTab.container);const r=new W(60,180,this.bounds.width-65,this.bounds.height-280);this.gemTab=new lu(r),this.container.addChild(this.gemTab.container)}}class vi{constructor(){b(this,"stage",new st);b(this,"gui",[]);b(this,"_events",new at);w.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this.gui.forEach(t=>{t.destroy()})}get events(){return this._events}init(){}}class uu extends Et{constructor(e,i){super();b(this,"hp",100);b(this,"gold",0);b(this,"goldText");b(this,"healthText");b(this,"waveText");this.hp=e,this.gold=i,this.container.x=0,this.container.y=20,w.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new Ct({text:`${this.hp}`,style:new lt({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new Ct({text:`${this.gold}`,style:new lt({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new Ct({text:`0/${w.GameScene.mission.rounds.length}`,style:new lt({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const r=new dt(V.HealthTexture),n=new dt(V.GoldTexture),a=new dt(V.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),w.GameScene.events.on(Se.NewWave,o=>{this.waveText.text=`${o}/${w.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}update(){}}const Kt=class Kt{static init(){Kt.SidebarRect=new W(w.app.canvas.width-360,0,360,w.app.canvas.height),Kt.ChangeRoundButtonRect=new W(50,w.app.canvas.height-100,310,100)}};b(Kt,"SidebarRect"),b(Kt,"ChangeRoundButtonRect");let Ee=Kt;class ua extends vi{constructor(e){super();b(this,"isGameOver",!1);b(this,"mission");b(this,"missionIndex");b(this,"MissionStats");b(this,"roundMode");b(this,"ticker");b(this,"changeRoundButton");b(this,"sidebar");b(this,"currentRound",0);b(this,"isWaveManagerFinished",!1);b(this,"playerWon",!1);b(this,"destroyTicker",!1);w.GameScene=this,V.Missions.forEach((i,r)=>{i.name==e&&(this.mission=i,this.missionIndex=r)})}init(){this.ticker=new _t,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.ticker.add(()=>{this.update&&this.update(this.ticker.elapsedMS)}),this.ticker.start(),new eu(this.mission.gameMap,this.missionIndex),new iu,new su(this.mission.rounds,this.mission.gameMap.paths),w.Grid.onGridCellClicked=(e,i)=>{w.TowerManager.isPlacingTower&&w.TowerManager.PlayerClickOnGrid(e,i)},w.WaveManager.events.on(Se.CreepSpawned,e=>{w.Grid.addCreep(e),e.events.on(ie.Escaped,()=>{this.onCreepEscaped(e)})}),w.WaveManager.events.on(Se.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(ie.Died,(e,i)=>{this.MissionStats.earnGold(e)}),this.sidebar=new cu(Ee.SidebarRect),this.changeRoundButton=new Be(Ee.ChangeRoundButtonRect,"Start",se.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),this.changeRoundButton.onClick=()=>{if(this.playerWon)return this.ReturnToMain();if(this.isGameOver)return w.NotificationManager.Notify("No more waves.","warn");this.changeRoundButton.setEnabled(!1),this.changeRoundButton.setCaption("WAVE IN PROGRESS"),this.setRoundMode(1),this.events.emit(Se.NewWave,`${this.currentRound+1}`)},this.MissionStats=new uu(100,200)}update(e){if(this.isGameOver){this.destroyTicker&&(this.destroyTicker=!1,this.ticker.destroy());return}w.WaveManager.update(e),w.Grid.update(e),w.TowerManager.update(e),this.isWaveManagerFinished&&w.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.changeRoundButton.setEnabled(!0),this.changeRoundButton.setCaption("Start"),this.setRoundMode(0),w.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound==this.mission.rounds.length&&w.NotificationManager.Notify("Final round.","danger"),this.currentRound+1==this.mission.rounds.length?(w.NotificationManager.Notify("Mission victory!!","reward"),this.changeRoundButton.setCaption("Return to menu"),this.playerWon=!0):this.currentRound++),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowScoreScreen(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowScoreScreen(!1))}ShowScoreScreen(e){console.log(e?"LOSE!":"WIN!")}onCreepEscaped(e){this.MissionStats.takeDamage(e.health)}setRoundMode(e){this.roundMode=e,this.roundMode==1?w.WaveManager.start(this.currentRound):w.WaveManager.end()}destroy(){super.destroy(),this.isGameOver=!0,this.destroyTicker=!0,w.GameScene=null}ReturnToMain(){this.destroy(),w.GameMaster.currentScene.stage.removeChildren(),w.GameMaster.changeScene(new da)}onTowerPlaced(){}}class da extends vi{init(){const t=new Be(new W(0,0,300,60),"Back to main",se.Button01);t.onClick=e=>{w.GameMaster.changeScene(new fa)},V.Missions.forEach((e,i)=>{const r=new Be(new W(w.app.canvas.width/2-150,w.app.canvas.height/5+i*80,300,60),e.name,se.Button01);r.onClick=n=>{w.GameMaster.changeScene(new ua(e.name))}})}}class fa extends vi{init(){const t={caption:"New Game",rect:new W(w.app.canvas.width/2-150,w.app.canvas.height/5+240,300,60),texture:se.Button02},e={caption:"Settings",rect:new W(w.app.canvas.width/2-300/2,w.app.canvas.height/5+4*80,300,60),texture:se.Button02};let i=new Ct({x:w.app.canvas.width/2-300/2,y:w.app.canvas.height/5+1*80,text:"BASTION",style:{fill:16755200,fontFamily:"Aclonica",fontSize:100}});i.x=i.x-i.width/5,w.GameMaster.currentScene.stage.addChild(i);let r=new Ct({x:0,y:0,text:"Latest commit: "+w.latestCommit,style:{fill:0,fontSize:10,fontWeight:"bold"}});w.GameMaster.currentScene.stage.addChild(r);const n=new Be(t.rect,t.caption,t.texture,!0);n.onClick=o=>{w.GameMaster.currentScene.stage.removeChild(i),w.GameMaster.currentScene.stage.removeChild(r),w.GameMaster.changeScene(new da)};let a=new Be(e.rect,e.caption,e.texture,!0);a.onClick=o=>{w.NotificationManager.Notify("Not finished.","info")}}}class du{constructor(){b(this,"finished",!1);b(this,"calledBack",!1);b(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class fu extends du{constructor(e,i,r,n){super();b(this,"fadeType");b(this,"fadeTime");b(this,"pixiObject");b(this,"ticks",0);this.fadeType=e,this.fadeTime=i,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 pu{constructor(){b(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const i=this.AnimationQueue[e];i.finished?(i.callbackFn(),this.AnimationQueue.splice(e,1)):i.update(t)}}}class gu{constructor(t,e,i,r,n){b(this,"textObj");b(this,"ticksToFadeAway");b(this,"animating",!1);b(this,"destroyed",!1);let a=16777215;e=="info"?a=2143228:e=="warn"?a=16570144:e=="danger"?a=16517642:e=="reward"&&(a=14047996),this.ticksToFadeAway=n,this.textObj=new Ct({text:t,style:new lt({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:i,y:r,zIndex:100}),this.textObj.anchor.set(.5,.5),w.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class mu extends Et{constructor(){super();b(this,"notifications",[]);b(this,"ticks",0);this.bb.x=w.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=100,w.app.stage.addChild(this.container)}Notify(e,i){let r=0,n=this.notifications.length*32;this.notifications.push(new gu(e,i,r,n,this.ticks+180))}update(e){this.ticks++;for(let i=this.notifications.length-1;i>=0;i--){const r=this.notifications[i];if(r.destroyed){this.notifications.splice(i,1);continue}this.ticks>=r.ticksToFadeAway&&!r.animating&&(r.animating=!0,w.AnimationManager.Animate(new fu("out",240,r.textObj,()=>{r.destroy()})))}}}(async()=>{const s=new Tn;w.app=s,await s.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(s.canvas);function t(){const i=window.innerWidth,r=window.innerHeight,n=i/s.screen.width,a=r/s.screen.height,o=Math.min(n,a),h=Math.round(s.screen.width*o),c=Math.round(s.screen.height*o),l=(i-h)/2,u=(r-c)/2;s.canvas.style.width=`${h}px`,s.canvas.style.height=`${c}px`,s.canvas.style.marginLeft=`${l}px`,s.canvas.style.marginTop=`${u}px`,s.canvas.style.marginRight="0",s.canvas.style.marginBottom="0",s.canvas.style.display="block"}w.latestCommit=await fetch("/latest_commit").then(i=>i.text()),window.addEventListener("resize",t),t(),await V.LoadAssets(),Ee.init(),new Qc,w.AnimationManager=new pu,w.NotificationManager=new mu,globalThis.Engine=w,_t.shared.add(i=>{w.NotificationManager.update(i.elapsedMS),w.AnimationManager.update(i.elapsedMS)}),w.GameMaster.changeScene(new fa),new URLSearchParams(location.href).entries().next().value[1]=="game"&&w.GameMaster.changeScene(new ua("Mission 1")),w.latestCommit!="DEVELOPMENT"&&(window.onbeforeunload=()=>"You are about to leave.")})();export{L as $,vn as A,K as B,st as C,X as D,P as E,Nr as F,ns as G,bt as H,Ni as I,dt as J,ko as K,Oo as L,O as M,J as N,W as O,it as P,sh as Q,Ys as R,vh as S,Tt as T,ts as U,$i as V,oo as W,bs as X,Z as Y,$r as Z,Sn as _,G as a,z as a0,oh as a1,Rn as a2,Yh as a3,Xh as a4,Jh as a5,el as a6,sl as a7,te as a8,lt as a9,Yl as aa,ri as ab,Un as ac,tr as ad,jt as ae,Xc as af,Ar as ag,Ql as ah,$t as ai,H as aj,Ga as ak,ii as al,vr as am,Nn as an,_t as b,at as c,kt as d,rt as e,Ji as f,_h as g,Ke as h,li as i,_n as j,tn as k,gn as l,wr as m,Bi as n,Vh as o,jh as p,Zh as q,ja as r,kn as s,tl as t,ci as u,un as v,Q as w,Ra as x,rl as y,St as z};
|