import{E as dt}from"./eventemitter3-2377bf7d.js";import{e as om}from"./earcut-d00ef651.js";import"./@babel-145f18f6.js";import{i as Rh}from"./ismobilejs-0fd54788.js";import{k as am,n as hm,w as lm}from"./@pixi-d0310b5a.js";import{p as um}from"./parse-svg-path-b9e47193.js";let de,J,$,X,Ft,Bh,pe,C,xr,ks,cm=(async()=>{var Eh;(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[t]="fed3f6db-aa9b-49e2-804d-43f8a6ea44bf",i._sentryDebugIdIdentifier="sentry-dbid-fed3f6db-aa9b-49e2-804d-43f8a6ea44bf")}catch{}})();let Ar,Gs,Pr;Ar="modulepreload",Gs={},Pr="/",pe=function(i,t){return!t||t.length===0?i():Promise.all(t.map(e=>{if(e=`${Pr}${e}`,e in Gs)return;Gs[e]=!0;const s=e.endsWith(".css"),r=s?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${r}`))return;const n=document.createElement("link");if(n.rel=s?"stylesheet":Ar,s||(n.as="script",n.crossOrigin=""),n.href=e,document.head.appendChild(n),s)return new Promise((o,a)=>{n.addEventListener("load",o),n.addEventListener("error",()=>a(new Error(`Unable to preload CSS for ${e}`)))})})).then(()=>i())};var x=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i))(x||{});const Us=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},je=(i,t)=>{var e;return(e=Us(i).priority)!=null?e:t},F={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Us).forEach(t=>{t.type.forEach(e=>{var s,r;return(r=(s=this._removeHandlers)[e])==null?void 0:r.call(s,t)})}),this},add(...i){return i.map(Us).forEach(t=>{t.type.forEach(e=>{var n,o;const s=this._addHandlers,r=this._queue;s[e]?(n=s[e])==null||n.call(s,t):(r[e]=r[e]||[],(o=r[e])==null||o.push(t))})}),this},handle(i,t,e){var o;const s=this._addHandlers,r=this._removeHandlers;if(s[i]||r[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,r[i]=e;const n=this._queue;return n[i]&&((o=n[i])==null||o.forEach(a=>t(a)),delete n[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(r=>r.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((r,n)=>je(n.value,e)-je(r.value,e)))},s=>{const r=t.findIndex(n=>n.name===s.name);r!==-1&&t.splice(r,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((r,n)=>je(n,e)-je(r,e)))},s=>{const r=t.indexOf(s.ref);r!==-1&&t.splice(r,1)})}},qh={extension:{type:x.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await pe(()=>Promise.resolve().then(function(){return em}),void 0)}},Zh={extension:{type:x.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await pe(()=>Promise.resolve().then(function(){return sm}),void 0)}};class rt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new rt(t!=null?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))}}const Qh=Math.PI*2,Jh=180/Math.PI,tl=Math.PI/180;$=class{constructor(i=0,t=0){this.x=0,this.y=0,this.x=i,this.y=t}clone(){return new $(this.x,this.y)}copyFrom(i){return this.set(i.x,i.y),this}copyTo(i){return i.set(this.x,this.y),i}equals(i){return i.x===this.x&&i.y===this.y}set(i=0,t=i){return this.x=i,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Fs.x=0,Fs.y=0,Fs}};const Fs=new $;class R{constructor(t=1,e=0,s=0,r=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=r,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,r,n,o){return this.a=t,this.b=e,this.c=s,this.d=r,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new $;const s=t.x,r=t.y;return e.x=this.a*s+this.c*r+this.tx,e.y=this.b*s+this.d*r+this.ty,e}applyInverse(t,e){e=e||new $;const s=this.a,r=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(s*o+n*-r),u=t.x,c=t.y;return e.x=o*l*u+-n*l*c+(h*n-a*o)*l,e.y=s*l*c+-r*l*u+(-h*s+a*r)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),r=this.a,n=this.c,o=this.tx;return this.a=r*e-this.b*s,this.b=r*s+this.b*e,this.c=n*e-this.d*s,this.d=n*s+this.d*e,this.tx=o*e-this.ty*s,this.ty=o*s+this.ty*e,this}append(t){const e=this.a,s=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*s+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*s+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*s+t.ty*n+this.ty,this}appendFrom(t,e){const s=t.a,r=t.b,n=t.c,o=t.d,a=t.tx,h=t.ty,l=e.a,u=e.b,c=e.c,d=e.d;return this.a=s*l+r*c,this.b=s*u+r*d,this.c=n*l+o*c,this.d=n*u+o*d,this.tx=a*l+h*c+e.tx,this.ty=a*u+h*d+e.ty,this}setTransform(t,e,s,r,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(s*this.a+r*this.c),this.ty=e-(s*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,r=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,r=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-r,n),h=Math.atan2(s,e),l=Math.abs(a+h);return l<1e-5||Math.abs(Qh-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(o.x*e+o.y*r),t.position.y=this.ty+(o.x*s+o.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,r=this.d,n=this.tx,o=t*r-e*s;return this.a=r/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-r*n)/o,this.ty=-(t*this.ty-e*n)/o,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 R;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 sl.identity()}static get shared(){return el.identity()}}const el=new R,sl=new R,Ot=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Dt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Lt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Nt=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Os=[],Cr=[],Ke=Math.sign;function il(){for(let i=0;i<16;i++){const t=[];Os.push(t);for(let e=0;e<16;e++){const s=Ke(Ot[i]*Ot[e]+Lt[i]*Dt[e]),r=Ke(Dt[i]*Ot[e]+Nt[i]*Dt[e]),n=Ke(Ot[i]*Lt[e]+Lt[i]*Nt[e]),o=Ke(Dt[i]*Lt[e]+Nt[i]*Nt[e]);for(let a=0;a<16;a++)if(Ot[a]===s&&Dt[a]===r&&Lt[a]===n&&Nt[a]===o){t.push(a);break}}}for(let i=0;i<16;i++){const t=new R;t.set(Ot[i],Dt[i],Lt[i],Nt[i],0,0),Cr.push(t)}}il();const Z={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>Ot[i],uY:i=>Dt[i],vX:i=>Lt[i],vY:i=>Nt[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Os[i][t],sub:(i,t)=>Os[i][Z.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?Z.S:Z.N:Math.abs(t)*2<=Math.abs(i)?i>0?Z.E:Z.W:t>0?i>0?Z.SE:Z.SW:i>0?Z.NE:Z.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const r=Cr[Z.inv(t)];r.tx=e,r.ty=s,i.append(r)}},qe=[new $,new $,new $,new $];X=class{constructor(i=0,t=0,e=0,s=0){this.type="rectangle",this.x=Number(i),this.y=Number(t),this.width=Number(e),this.height=Number(s)}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 X(0,0,0,0)}clone(){return new X(this.x,this.y,this.width,this.height)}copyFromBounds(i){return this.x=i.minX,this.y=i.minY,this.width=i.maxX-i.minX,this.height=i.maxY-i.minY,this}copyFrom(i){return this.x=i.x,this.y=i.y,this.width=i.width,this.height=i.height,this}copyTo(i){return i.copyFrom(this),i}contains(i,t){return this.width<=0||this.height<=0?!1:i>=this.x&&i<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(i,t,e){const{width:s,height:r}=this;if(s<=0||r<=0)return!1;const n=this.x,o=this.y,a=n-e/2,h=n+s+e/2,l=o-e/2,u=o+r+e/2,c=n+e/2,d=n+s-e/2,p=o+e/2,f=o+r-e/2;return i>=a&&i<=h&&t>=l&&t<=u&&!(i>c&&i<d&&t>p&&t<f)}intersects(i,t){if(!t){const E=this.x<i.x?i.x:this.x;if((this.right>i.right?i.right:this.right)<=E)return!1;const P=this.y<i.y?i.y:this.y;return(this.bottom>i.bottom?i.bottom:this.bottom)>P}const e=this.left,s=this.right,r=this.top,n=this.bottom;if(s<=e||n<=r)return!1;const o=qe[0].set(i.left,i.top),a=qe[1].set(i.left,i.bottom),h=qe[2].set(i.right,i.top),l=qe[3].set(i.right,i.bottom);if(h.x<=o.x||a.y<=o.y)return!1;const u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(o,o),t.apply(a,a),t.apply(h,h),t.apply(l,l),Math.max(o.x,a.x,h.x,l.x)<=e||Math.min(o.x,a.x,h.x,l.x)>=s||Math.max(o.y,a.y,h.y,l.y)<=r||Math.min(o.y,a.y,h.y,l.y)>=n))return!1;const c=u*(a.y-o.y),d=u*(o.x-a.x),p=c*e+d*r,f=c*s+d*r,g=c*e+d*n,m=c*s+d*n;if(Math.max(p,f,g,m)<=c*o.x+d*o.y||Math.min(p,f,g,m)>=c*l.x+d*l.y)return!1;const _=u*(o.y-h.y),y=u*(h.x-o.x),b=_*e+y*r,v=_*s+y*r,T=_*e+y*n,A=_*s+y*n;return!(Math.max(b,v,T,A)<=_*o.x+y*o.y||Math.min(b,v,T,A)>=_*l.x+y*l.y)}pad(i=0,t=i){return this.x-=i,this.y-=t,this.width+=i*2,this.height+=t*2,this}fit(i){const t=Math.max(this.x,i.x),e=Math.min(this.x+this.width,i.x+i.width),s=Math.max(this.y,i.y),r=Math.min(this.y+this.height,i.y+i.height);return this.x=t,this.width=Math.max(e-t,0),this.y=s,this.height=Math.max(r-s,0),this}ceil(i=1,t=.001){const e=Math.ceil((this.x+this.width-t)*i)/i,s=Math.ceil((this.y+this.height-t)*i)/i;return this.x=Math.floor((this.x+t)*i)/i,this.y=Math.floor((this.y+t)*i)/i,this.width=e-this.x,this.height=s-this.y,this}enlarge(i){const t=Math.min(this.x,i.x),e=Math.max(this.x+this.width,i.x+i.width),s=Math.min(this.y,i.y),r=Math.max(this.y+this.height,i.y+i.height);return this.x=t,this.width=e-t,this.y=s,this.height=r-s,this}getBounds(i){return i=i||new X,i.copyFrom(this),i}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}};const Ds={default:-1};function Q(i="default"){return Ds[i]===void 0&&(Ds[i]=-1),++Ds[i]}const Mr={},H="8.0.0";function D(i,t,e=3){if(Mr[t])return;let s=new Error().stack;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${i}`):(s=s.split(`
`).splice(e).join(`
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
Deprecated since v${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${i}`),console.warn(s))),Mr[t]=!0}const Rr=()=>{};function qt(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function Br(i){return!(i&i-1)&&!!i}function rl(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const kr=Object.create(null);function nl(i){const t=kr[i];return t===void 0&&(kr[i]=Q("resource")),t}const Ir=class kh extends dt{constructor(t={}){var e,s,r,n,o,a,h;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...kh.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(s=t.addressModeV)!=null?s:this.addressModeV,this.addressModeW=(r=t.addressModeW)!=null?r:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(h=t.maxAnisotropy)!=null?h:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){D(H,"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=nl(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Ir.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ol=Ir;const Gr=class Ih extends dt{constructor(t={}){var e,s,r;super(),this.options=t,this.uid=Q("textureSource"),this._resourceType="textureSource",this._resourceId=Q("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={...Ih.defaultOptions,...t},this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(s=this.resourceWidth)!=null?s:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(r=this.resourceHeight)!=null?r: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 ol(rl(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=Q("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*s),n=Math.round(e*s);return this.width=r/s,this.height=n/s,this._resolution=s,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=Q("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=Br(this.pixelWidth)&&Br(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Gr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let tt=Gr;class Ls extends tt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Ls.extension=x.TextureSource;const Ur=new R;class Fr{constructor(t,e){this.mapCoord=new R,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],o=t[r+1];e[r]=n*s.a+o*s.c+s.tx,e[r+1]=n*s.b+o*s.d+s.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const s=t.orig,r=t.trim;r&&(Ur.set(s.width/r.width,0,0,s.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(Ur));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+h)/n.width,o[1]=(t.frame.y+a+h)/n.height,o[2]=(t.frame.x+t.frame.width-a+h)/n.width,o[3]=(t.frame.y+t.frame.height-a+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}}C=class extends dt{constructor({source:i,label:t,frame:e,orig:s,trim:r,defaultAnchor:n,defaultBorders:o,rotate:a,dynamic:h}={}){var l;if(super(),this.uid=Q("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new X,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=(l=i==null?void 0:i.source)!=null?l:new tt,this.noFrame=!e,e)this.frame.copyFrom(e);else{const{width:u,height:c}=this._source;this.frame.width=u,this.frame.height=c}this.orig=s||this.frame,this.trim=r,this.rotate=a!=null?a:0,this.defaultAnchor=n,this.defaultBorders=o,this.destroyed=!1,this.dynamic=h||!1,this.updateUvs()}set source(i){this._source&&this._source.off("resize",this.update,this),this._source=i,i.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Fr(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:i,frame:t}=this,{width:e,height:s}=this._source,r=t.x/e,n=t.y/s,o=t.width/e,a=t.height/s;let h=this.rotate;if(h){const l=o/2,u=a/2,c=r+l,d=n+u;h=Z.add(h,Z.NW),i.x0=c+l*Z.uX(h),i.y0=d+u*Z.uY(h),h=Z.add(h,2),i.x1=c+l*Z.uX(h),i.y1=d+u*Z.uY(h),h=Z.add(h,2),i.x2=c+l*Z.uX(h),i.y2=d+u*Z.uY(h),h=Z.add(h,2),i.x3=c+l*Z.uX(h),i.y3=d+u*Z.uY(h)}else i.x0=r,i.y0=n,i.x1=r+o,i.y1=n,i.x2=r+o,i.y2=n+a,i.x3=r,i.y3=n+a}destroy(i=!1){this._source&&i&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return D(H,"Texture.baseTexture is now Texture.source"),this._source}},C.EMPTY=new C({label:"EMPTY",source:new tt({label:"EMPTY"})}),C.EMPTY.destroy=Rr,C.WHITE=new C({source:new Ls({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),C.WHITE.destroy=Rr;function Ze(i,t,e,s){const{width:r,height:n}=e.orig,o=e.trim;if(o){const a=o.width,h=o.height;i.minX=o.x-t._x*r-s,i.maxX=i.minX+a,i.minY=o.y-t._y*n-s,i.maxY=i.minY+h}else i.minX=-t._x*r-s,i.maxX=i.minX+r,i.minY=-t._y*n-s,i.maxY=i.minY+n}const Or=new R;class nt{constructor(t=1/0,e=1/0,s=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Or,this.minX=t,this.minY=e,this.maxX=s,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new X);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=Or,this}set(t,e,s,r){this.minX=t,this.minY=e,this.maxX=s,this.maxY=r}addFrame(t,e,s,r,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,u=n.tx,c=n.ty;let d=this.minX,p=this.minY,f=this.maxX,g=this.maxY,m=o*t+h*e+u,_=a*t+l*e+c;m<d&&(d=m),_<p&&(p=_),m>f&&(f=m),_>g&&(g=_),m=o*s+h*e+u,_=a*s+l*e+c,m<d&&(d=m),_<p&&(p=_),m>f&&(f=m),_>g&&(g=_),m=o*t+h*r+u,_=a*t+l*r+c,m<d&&(d=m),_<p&&(p=_),m>f&&(f=m),_>g&&(g=_),m=o*s+h*r+u,_=a*s+l*r+c,m<d&&(d=m),_<p&&(p=_),m>f&&(f=m),_>g&&(g=_),this.minX=d,this.minY=p,this.maxX=f,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,s=this.minY,r=this.maxX,n=this.maxY,{a:o,b:a,c:h,d:l,tx:u,ty:c}=t;let d=o*e+h*s+u,p=a*e+l*s+c;this.minX=d,this.minY=p,this.maxX=d,this.maxY=p,d=o*r+h*s+u,p=a*r+l*s+c,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*e+h*n+u,p=a*e+l*n+c,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*r+h*n+u,p=a*r+l*n+c,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,r){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<s&&(this.minY=s),this.maxY>r&&(this.maxY=r),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new nt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,r){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;r||(r=this.matrix);const l=r.a,u=r.b,c=r.c,d=r.d,p=r.tx,f=r.ty;for(let g=e;g<s;g+=2){const m=t[g],_=t[g+1],y=l*m+c*_+p,b=u*m+d*_+f;n=y<n?y:n,o=b<o?b:o,a=y>a?y:a,h=b>h?b:h}this.minX=n,this.minY=o,this.maxX=a,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}]`}}am([hm]);const Zt=class Xe{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 Xe)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._normalize(t),this._value=this._cloneSource(t))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((r,n)=>r===e[n]);if(t!==null&&e!==null){const r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,r]=this._components;return{r:t,g:e,b:s,a:r}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,r,n]=this._components;return t[0]=e,t[1]=s,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,r]=this._components;return t[0]=e,t[1]=s,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,r,n]=Xe._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,r=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,r,n=255]=t,e/=255,s/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Xe.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=lm(t);o.isValid()&&({r:e,g:s,b:r,a:n}=o.rgba,e/=255,s/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Xe||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}};Zt.shared=new Zt,Zt._temp=new Zt,Zt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let V=Zt;const al={cullArea:null,cullable:!1,cullableChildren:!0};class Ns{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var s;let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class hl{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 Ns(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const L=new hl;function Dr(i,t,e){const s=i.length;let r;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(r=t;r<n;++r)i[r]=i[r+e];i.length=n}const ll={allowChildren:!0,removeChildren(i=0,t){const e=t!=null?t:this.children.length,s=e-i,r=[];if(s>0&&s<=e){for(let o=e-1;o>=i;o--){const a=this.children[o];!a||(r.push(a),a.parent=null)}Dr(this.children,i,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let o=0;o<r.length;++o)this.emit("childRemoved",r[o],this,o),r[o].emit("removed",this);return r}else if(s===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const t=this.getChildAt(i);return this.removeChild(t)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||D(H,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(i.parent){const r=i.parent.children.indexOf(i);if(i.parent===this&&r===t)return i;r!==-1&&i.parent.children.splice(r,1)}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,t),i.emit("added",this),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var i;(i=this.parent)==null||i.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i}};class Qe{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 ul{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const s=this._tests[e];if(s.test(t))return L.get(s.maskClass,t)}return t}returnMaskEffect(t){L.return(t)}}const Hs=new ul;F.handleByList(x.MaskEffect,Hs._effectClasses);const cl={_maskEffect:null,_filterEffect:null,effects:[],addEffect(i){if(this.effects.indexOf(i)!==-1)return;this.effects.push(i),this.effects.sort((e,s)=>e.priority-s.priority);const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const t=this._maskEffect;(t==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),Hs.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=Hs.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},set filters(i){var n;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new Qe);i=i;const e=(i==null?void 0:i.length)>0,s=((n=t.filters)==null?void 0:n.length)>0,r=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i!=null?i:null))},get filters(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new Qe),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},dl={label:null,get name(){return D(H,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){D(H,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s<e.length;s++){const r=e[s];if(r.label===i||i instanceof RegExp&&i.test(r.label))return r}if(t)for(let s=0;s<e.length;s++){const r=e[s].getChildByLabel(i,!0);if(r)return r}return null},getChildrenByLabel(i,t=!1,e=[]){const s=this.children;for(let r=0;r<s.length;r++){const n=s[r];(n.label===i||i instanceof RegExp&&i.test(n.label))&&e.push(n)}if(t)for(let r=0;r<s.length;r++)s[r].getChildrenByLabel(i,!0,e);return e}},Et=new Ns(R),At=new Ns(nt);function zs(i,t,e){e.clear();let s,r;return i.parent?t?s=i.parent.worldTransform:(r=Et.get().identity(),s=Je(i,r)):s=R.IDENTITY,Lr(i,e,s,t),r&&Et.return(r),e.isValid||e.set(0,0,0,0),e}function Lr(i,t,e,s){var a,h;if(!i.visible||!i.measurable)return;let r;s?r=i.worldTransform:(i.updateLocalTransform(),r=Et.get(),r.appendFrom(i.localTransform,e));const n=t,o=!!i.effects.length;if(o&&(t=At.get().clear()),i.boundsArea)t.addRect(i.boundsArea,r);else{i.addBounds&&(t.matrix=r,i.addBounds(t));for(let l=0;l<i.children.length;l++)Lr(i.children[l],t,r,s)}if(o){for(let l=0;l<i.effects.length;l++)(h=(a=i.effects[l]).addBounds)==null||h.call(a,t);n.addBounds(t,R.IDENTITY),At.return(t)}s||Et.return(r)}function Je(i,t){const e=i.parent;return e&&(Je(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}let Ws=0;const Nr=500;function U(...i){Ws!==Nr&&(Ws++,Ws===Nr?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}function Vs(i,t,e){return t.clear(),e||(e=R.IDENTITY),Hr(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function Hr(i,t,e,s,r){var h,l;let n;if(r)n=Et.get(),n=e.copyTo(n);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const u=i.localTransform;n=Et.get(),n.appendFrom(u,e)}const o=t,a=!!i.effects.length;if(a&&(t=At.get().clear()),i.boundsArea)t.addRect(i.boundsArea,n);else{i.renderPipeId&&(t.matrix=n,i.addBounds(t));const u=i.children;for(let c=0;c<u.length;c++)Hr(u[c],t,n,s,!1)}if(a){for(let u=0;u<i.effects.length;u++)(l=(h=i.effects[u]).addLocalBounds)==null||l.call(h,t,s);o.addBounds(t,R.IDENTITY),At.return(t)}Et.return(n)}function zr(i,t){const e=i.children;for(let s=0;s<e.length;s++){const r=e[s],n=r.uid,o=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,r.children.length&&zr(r,t)}return t.didChange}const pl=new R,fl={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=i/t*e:this.scale.x=e},_setHeight(i,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=i/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new nt});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),zr(this,i),i.didChange&&Vs(this,i.localBounds,pl),i.localBounds},getBounds(i,t){return zs(this,i,t||new nt)}},ml={_onRender:null,set onRender(i){const t=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||(t==null||t.addOnRender(this)),this._onRender=i},get onRender(){return this._onRender}},gl={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){!this.sortDirty||(this.sortDirty=!1,this.children.sort(_l))}};function _l(i,t){return i._zIndex-t._zIndex}const xl={getGlobalPosition(i=new $,t=!1){return this.parent?this.parent.toGlobal(this._position,i,t):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,t,e=!1){if(!e){this.updateLocalTransform();const s=Je(this,new R);return s.append(this.localTransform),s.apply(i,t)}return this.worldTransform.apply(i,t)},toLocal(i,t,e,s){if(t&&(i=t.toGlobal(i,e,s)),!s){this.updateLocalTransform();const r=Je(this,new R);return r.append(this.localTransform),r.applyInverse(i,e)}return this.worldTransform.applyInverse(i,e)}};let yl=0;class Wr{constructor(){this.uid=Q("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.tick=0}reset(){this.instructionSize=0,this.tick=yl++}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class bl{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new R,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Wr,this._onRenderContainers=[]}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let s=0;s<e.length;s++)this.removeChild(e[s])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(t.didViewUpdate=!1,this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t))}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender()}destroy(){this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let s=0;s<e.length;s++)this._getChildren(e[s],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const s=t.children;for(let r=0;r<s.length;r++)this._getChildren(s[r],e);return e}}function vl(i,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(i[s]=t[s])}const $s=new rt(null),Xs=new rt(null),Ys=new rt(null,1,1),ts=1,js=2,me=4;J=class extends dt{constructor(i={}){var t,e;super(),this.uid=Q("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 R,this.relativeGroupTransform=new R,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new rt(this,0,0),this._scale=Ys,this._pivot=Xs,this._skew=$s,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=[],vl(this,i,{children:!0,parent:!0,effects:!0}),(t=i.children)==null||t.forEach(s=>this.addChild(s)),(e=i.parent)==null||e.addChild(this)}static mixin(i){Object.defineProperties(J.prototype,Object.getOwnPropertyDescriptors(i))}set _didChangeId(i){this._didViewChangeTick=i>>12&4095,this._didContainerChangeTick=i&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...i){if(this.allowChildren||D(H,"addChild: Only Containers will be allowed to add children in v8.0.0"),i.length>1){for(let s=0;s<i.length;s++)this.addChild(i[s]);return i[0]}const t=i[0];if(t.parent===this)return this.children.splice(this.children.indexOf(t),1),this.children.push(t),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),t;t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t.didViewUpdate=!1,t._updateFlags=15;const e=this.renderGroup||this.parentRenderGroup;return e&&e.addChild(t),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t}removeChild(...i){if(i.length>1){for(let s=0;s<i.length;s++)this.removeChild(i[s]);return i[0]}const t=i[0],e=this.children.indexOf(t);return e>-1&&(this._didViewChangeTick++,this.children.splice(e,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parent=null,this.emit("childRemoved",t,this,e),t.emit("removed",this)),t}_onUpdate(i){i&&i===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(i){!!this.renderGroup!==i&&(i?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const i=this.parentRenderGroup;i==null||i.removeChild(this),this.renderGroup=L.get(bl,this),this.groupTransform=R.IDENTITY,i==null||i.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const i=this.parentRenderGroup;i==null||i.removeChild(this),L.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,i==null||i.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new R),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(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get position(){return this._position}set position(i){this._position.copyFrom(i)}get rotation(){return this._rotation}set rotation(i){this._rotation!==i&&(this._rotation=i,this._onUpdate(this._skew))}get angle(){return this.rotation*Jh}set angle(i){this.rotation=i*tl}get pivot(){return this._pivot===Xs&&(this._pivot=new rt(this,0,0)),this._pivot}set pivot(i){this._pivot===Xs&&(this._pivot=new rt(this,0,0)),typeof i=="number"?this._pivot.set(i):this._pivot.copyFrom(i)}get skew(){return this._skew===$s&&(this._skew=new rt(this,0,0)),this._skew}set skew(i){this._skew===$s&&(this._skew=new rt(this,0,0)),this._skew.copyFrom(i)}get scale(){return this._scale===Ys&&(this._scale=new rt(this,1,1)),this._scale}set scale(i){this._scale===Ys&&(this._scale=new rt(this,0,0)),typeof i=="number"?this._scale.set(i):this._scale.copyFrom(i)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(i){const t=this.getLocalBounds().width;this._setWidth(i,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(i){const t=this.getLocalBounds().height;this._setHeight(i,t)}getSize(i){i||(i={});const t=this.getLocalBounds();return i.width=Math.abs(this.scale.x*t.width),i.height=Math.abs(this.scale.y*t.height),i}setSize(i,t){var s;const e=this.getLocalBounds();typeof i=="object"?(t=(s=i.height)!=null?s:i.width,i=i.width):t!=null||(t=i),i!==void 0&&this._setWidth(i,e.width),t!==void 0&&this._setHeight(t,e.height)}_updateSkew(){const i=this._rotation,t=this._skew;this._cx=Math.cos(i+t._y),this._sx=Math.sin(i+t._y),this._cy=-Math.sin(i-t._x),this._sy=Math.cos(i-t._x)}updateTransform(i){return this.position.set(typeof i.x=="number"?i.x:this.position.x,typeof i.y=="number"?i.y:this.position.y),this.scale.set(typeof i.scaleX=="number"?i.scaleX||1:this.scale.x,typeof i.scaleY=="number"?i.scaleY||1:this.scale.y),this.rotation=typeof i.rotation=="number"?i.rotation:this.rotation,this.skew.set(typeof i.skewX=="number"?i.skewX:this.skew.x,typeof i.skewY=="number"?i.skewY:this.skew.y),this.pivot.set(typeof i.pivotX=="number"?i.pivotX:this.pivot.x,typeof i.pivotY=="number"?i.pivotY:this.pivot.y),this}setFromMatrix(i){i.decompose(this)}updateLocalTransform(){const i=this._didContainerChangeTick;if(this._didLocalTransformChangeId===i)return;this._didLocalTransformChangeId=i;const t=this.localTransform,e=this._scale,s=this._pivot,r=this._position,n=e._x,o=e._y,a=s._x,h=s._y;t.a=this._cx*n,t.b=this._sx*n,t.c=this._cy*o,t.d=this._sy*o,t.tx=r._x-(a*t.a+h*t.c),t.ty=r._y-(a*t.b+h*t.d)}set alpha(i){i!==this.localAlpha&&(this.localAlpha=i,this._updateFlags|=ts,this._onUpdate())}get alpha(){return this.localAlpha}set tint(i){const t=V.shared.setValue(i!=null?i:16777215).toBgrNumber();t!==this.localColor&&(this.localColor=t,this._updateFlags|=ts,this._onUpdate())}get tint(){const i=this.localColor;return((i&255)<<16)+(i&65280)+(i>>16&255)}set blendMode(i){this.localBlendMode!==i&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=js,this.localBlendMode=i,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(i){const t=i?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=me,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(i){const t=i?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=me,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(i){const t=i?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=me,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(i=!1){var e;if(this.destroyed)return;this.destroyed=!0;const t=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 i=="boolean"?i:i==null?void 0:i.children)for(let s=0;s<t.length;++s)t[s].destroy(i);(e=this.renderGroup)==null||e.destroy(),this.renderGroup=null}},J.mixin(ll),J.mixin(xl),J.mixin(ml),J.mixin(fl),J.mixin(cl),J.mixin(dl),J.mixin(gl),J.mixin(al);class Ks extends J{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=0,this._lastInstructionTick=-1,this._bounds=new nt(0,1,0,0),this._boundsDirty=!0}_updateBounds(){}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:s,y:r}=t;return s>=e.minX&&s<=e.maxX&&r>=e.minY&&r<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}Ft=class extends Ks{constructor(i=C.EMPTY){i instanceof C&&(i={texture:i});const{texture:t=C.EMPTY,anchor:e,roundPixels:s,width:r,height:n,...o}=i;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 rt({_onUpdate:()=>{this.onViewUpdate()}}),e?this.anchor=e:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=s!=null?s:!1,r!==void 0&&(this.width=r),n!==void 0&&(this.height=n)}static from(i,t=!1){return i instanceof C?new Ft(i):new Ft(C.from(i,t))}set texture(i){i||(i=C.EMPTY);const t=this._texture;t!==i&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),i.dynamic&&i.on("update",this.onViewUpdate,this),this._texture=i,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(i){const t=this.sourceBounds;return i.x>=t.maxX&&i.x<=t.minX&&i.y>=t.maxY&&i.y<=t.minY}addBounds(i){const t=this._texture.trim?this.sourceBounds:this.bounds;i.addFrame(t.minX,t.minY,t.maxX,t.maxY)}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const i=this.renderGroup||this.parentRenderGroup;i&&i.onChildViewUpdate(this)}_updateBounds(){Ze(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const i=this._anchor,t=this._texture,e=this._sourceBounds,{width:s,height:r}=t.orig;e.maxX=-i._x*s,e.minX=e.maxX+s,e.maxY=-i._y*r,e.minY=e.maxY+r}destroy(i=!1){if(super.destroy(i),typeof i=="boolean"?i:i==null?void 0:i.texture){const t=typeof i=="boolean"?i:i==null?void 0:i.textureSource;this._texture.destroy(t)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(i){typeof i=="number"?this._anchor.set(i):this._anchor.copyFrom(i)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(i){this._setWidth(i,this._texture.orig.width),this._width=i}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(i){this._setHeight(i,this._texture.orig.height),this._height=i}getSize(i){return i||(i={}),i.width=Math.abs(this.scale.x)*this._texture.orig.width,i.height=Math.abs(this.scale.y)*this._texture.orig.height,i}setSize(i,t){var e;typeof i=="object"?(t=(e=i.height)!=null?e:i.width,i=i.width):t!=null||(t=i),i!==void 0&&this._setWidth(i,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}};const Tl=new nt;function Vr(i,t,e){const s=Tl;i.measurable=!0,zs(i,e,s),t.addBoundsMask(s),i.measurable=!1}function $r(i,t,e){const s=At.get();i.measurable=!0;const r=Et.get().identity(),n=Xr(i,e,r);Vs(i,s,n),i.measurable=!1,t.addBoundsMask(s),Et.return(r),At.return(s)}function Xr(i,t,e){return i?(i!==t&&(Xr(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(U("Mask bounds, renderable is not inside the root container"),e)}class Yr{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Ft),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){Vr(this.mask,t,e)}addLocalBounds(t,e){$r(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Ft}}Yr.extension=x.MaskEffect;class jr{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"}}jr.extension=x.MaskEffect;class Kr{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){Vr(this.mask,t,e)}addLocalBounds(t,e){$r(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof J}}Kr.extension=x.MaskEffect;let qr={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var i;return(i=document.baseURI)!=null?i:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};const N={get(){return qr},set(i){qr=i}};class Qt extends tt{constructor(t){t.resource||(t.resource=N.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const r=super.resize(t,e,s);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}}Qt.extension=x.TextureSource;class Jt extends tt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=N.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,U("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}}Jt.extension=x.TextureSource;var te=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(te||{});class qs{constructor(t,e=null,s=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=r}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Zr=class pt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new qs(null,null,1/0),this.deltaMS=1/pt.targetFPMS,this.elapsedMS=1/pt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=te.NORMAL){return this._addListener(new qs(t,e,s))}addOnce(t,e,s=te.NORMAL){return this._addListener(new qs(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*pt.targetFPMS;const s=this._head;let r=s.next;for(;r;)r=r.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),s=Math.min(Math.max(0,e)/1e3,pt.targetFPMS);this._maxElapsedMS=1/s}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!pt._shared){const t=pt._shared=new pt;t.autoStart=!0,t._protected=!0}return pt._shared}static get system(){if(!pt._system){const t=pt._system=new pt;t.autoStart=!0,t._protected=!0}return pt._system}};Zr.targetFPMS=.06;let ot=Zr,ge;async function Qr(){return ge!=null||(ge=(async()=>{var n;const i=document.createElement("canvas").getContext("webgl");if(!i)return"premultiply-alpha-on-upload";const t=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return"premultiply-alpha-on-upload";const e=i.createTexture();i.bindTexture(i.TEXTURE_2D,e);const s=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,s),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t);const r=new Uint8Array(4);return i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,r),i.deleteFramebuffer(s),i.deleteTexture(e),(n=i.getExtension("WEBGL_lose_context"))==null||n.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),ge}const es=class Gh extends tt{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t={...Gh.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"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=ot.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 Qr(),this._load=new Promise((s,r)=>{this.isValid?s(this):(this._resolve=s,this._reject=r,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ot.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||(ot.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ot.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};es.extension=x.TextureSource,es.defaultOptions={...tt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},es.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ss=es;const _t=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class Sl{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||U(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=_t(t);let r;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){r=l.getCacheableAssets(s,e);break}}const n=new Map(Object.entries(r||{}));r||s.forEach(h=>{n.set(h,e)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&U("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){U(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}}const j=new Sl,Zs=[];F.handleByList(x.TextureSource,Zs);function Jr(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let r=0;r<Zs.length;r++){const n=Zs[r];if(n.test(e))return new n(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function wl(i={},t=!1){const e=i&&i.resource,s=e?i.resource:i,r=e?i:{resource:i};if(!t&&j.has(s))return j.get(s);const n=new C({source:Jr(r)});return n.on("destroy",()=>{j.has(s)&&j.remove(s)}),t||j.set(s,n),n}function El(i,t=!1){return typeof i=="string"?j.get(i):i instanceof tt?new C({source:i}):wl(i,t)}C.from=El,tt.from=Jr,F.add(Yr,jr,Kr,ss,Jt,Qt,Ls);var Bt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Bt||{});function xt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function _e(i){return i.split("?")[0].split("#")[0]}function Al(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pl(i,t,e){return i.replace(new RegExp(Al(t),"g"),e)}function Cl(i,t){let e="",s=0,r=-1,n=0,o=-1;for(let a=0;a<=i.length;++a){if(a<i.length)o=i.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(r===a-1||n===1))if(r!==a-1&&n===2){if(e.length<2||s!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),r=a,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,r=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",s=2)}else e.length>0?e+=`/${i.slice(r+1,a)}`:e=i.slice(r+1,a),s=a-r-1;r=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const lt={toPosix(i){return Pl(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){xt(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(xt(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=_e(this.toPosix(t!=null?t:N.get().getBaseUrl())),r=_e(this.toPosix(e!=null?e:this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?lt.join(r,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(xt(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=Cl(i,!1),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return xt(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){var e;if(i.length===0)return".";let t;for(let s=0;s<i.length;++s){const r=i[s];if(xt(r),r.length>0)if(t===void 0)t=r;else{const n=(e=i[s-1])!=null?e:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(xt(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,r=!0;const n=this.getProtocol(i),o=i;i=i.slice(n.length);for(let a=i.length-1;a>=1;--a)if(t=i.charCodeAt(a),t===47){if(!r){s=a;break}}else r=!1;return s===-1?e?"/":this.isUrl(o)?n+i:n:e&&s===1?"//":n+i.slice(0,s)},rootname(i){xt(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){xt(i),t&&xt(t),i=_e(this.toPosix(i));let e=0,s=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let o=t.length-1,a=-1;for(n=i.length-1;n>=0;--n){const h=i.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else a===-1&&(r=!1,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=i.length),i.slice(e,s)}for(n=i.length-1;n>=0;--n)if(i.charCodeAt(n)===47){if(!r){e=n+1;break}}else s===-1&&(r=!1,s=n+1);return s===-1?"":i.slice(e,s)},extname(i){xt(i),i=_e(this.toPosix(i));let t=-1,e=0,s=-1,r=!0,n=0;for(let o=i.length-1;o>=0;--o){const a=i.charCodeAt(o);if(a===47){if(!r){e=o+1;break}continue}s===-1&&(r=!1,s=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){xt(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=_e(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let r;t.root=this.rootname(i),s||this.hasProtocol(i)?r=1:r=0;let n=-1,o=0,a=-1,h=!0,l=i.length-1,u=0;for(;l>=r;--l){if(e=i.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||a===-1||u===0||u===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&s?t.base=t.name=i.slice(1,a):t.base=t.name=i.slice(o,a)):(o===0&&s?(t.name=i.slice(1,n),t.base=i.slice(1,a)):(t.name=i.slice(o,n),t.base=i.slice(o,a)),t.ext=i.slice(n,a)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function tn(i,t,e,s,r){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?tn(i.replace(s[e],a),t,e+1,s,r):r.push(i.replace(s[e],a))}}function Ml(i){const t=/\{(.*?)\}/g,e=i.match(t),s=[];if(e){const r=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");r.push(o)}),tn(i,r,0,e,s)}else s.push(i);return s}const is=i=>!Array.isArray(i);class ee{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){var e,s,r;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(s=t.createBundleAssetId)!=null?s:this._createBundleAssetId,this._extractAssetIdFromBundle=(r=t.extractAssetIdFromBundle)!=null?r:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return _t(e||s,r=>typeof r=="string"?r:Array.isArray(r)?r.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):r!=null&&r.src?r.src:r,!0)}addManifest(t){this._manifest&&U("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),r.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);s.push(l),h=[a,l]}else{const l=a.map(u=>this._createBundleAssetId(t,u));s.push(...l),h=[...a,...l]}this.add({...n,alias:h,src:o})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=r=>{this.hasKey(r)&&U(`[Resolver] already has key: ${r} overwriting`)},_t(e).forEach(r=>{const{src:n}=r;let{data:o,format:a,loadParser:h}=r;const l=_t(n).map(d=>typeof d=="string"?Ml(d):Array.isArray(d)?d:[d]),u=this.getAlias(r);Array.isArray(u)?u.forEach(s):s(u);const c=[];l.forEach(d=>{d.forEach(p=>{var g,m,_;let f={};if(typeof p!="object"){f.src=p;for(let y=0;y<this._parsers.length;y++){const b=this._parsers[y];if(b.test(p)){f=b.parse(p);break}}}else o=(g=p.data)!=null?g:o,a=(m=p.format)!=null?m:a,h=(_=p.loadParser)!=null?_:h,f={...f,...p};if(!u)throw new Error(`[Resolver] alias is undefined for this asset: ${f.src}`);f=this._buildResolvedAsset(f,{aliases:u,data:o,format:a,loadParser:h}),c.push(f)})}),u.forEach(d=>{this._assetMap[d]=c})})}resolveBundle(t){const e=is(t);t=_t(t);const s={};return t.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(r,h)]=l}s[r]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const r in e)s[r]=e[r].src;return s}return e.src}resolve(t){const e=is(t);t=_t(t);const s={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(u=>u[a]?u[a]===h:!1);l.length&&(n=l)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});s[r]=this._resolverHash[r]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const s=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(s.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var a,h;const{aliases:s,data:r,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=lt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(a=s!=null?s:t.alias)!=null?a:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n!=null?n:t.loadParser,t.format=(h=o!=null?o:t.format)!=null?h:Rl(t.src),t}}ee.RETINA_PREFIX=/@([0-9\.]+)x/;function Rl(i){return i.split(".").pop().split("?").shift().split("#").shift()}const Qs=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},en=class Ye{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof C?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const s=parseFloat(e.meta.scale);s?(this.resolution=s,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Ye.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=Ye.BATCH_SIZE;for(;e-t<s&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],o=n.frame;if(o){let a=null,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new X(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?a=new X(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new X(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new X(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[r]=new C({source:this.textureSource,frame:a,orig:u,trim:h,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:r.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let s=0;s<t[e].length;s++){const r=t[e][s];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Ye.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ye.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const s in this.textures)this.textures[s].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};en.BATCH_SIZE=1e3;let sn=en;const Bl=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function rn(i,t,e){const s={};if(i.forEach(r=>{s[r]=t}),Object.keys(t.textures).forEach(r=>{s[r]=t.textures[r]}),!e){const r=lt.dirname(i[0]);t.linkedSheets.forEach((n,o)=>{const a=rn([`${r}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const kl={extension:x.Asset,cache:{test:i=>i instanceof sn,getCacheableAssets:(i,t)=>rn(i,t,!1)},resolver:{extension:{type:x.ResolveParser,name:"resolveSpritesheet"},test:i=>{const t=i.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&Bl.includes(s)},parse:i=>{var e,s;const t=i.split(".");return{resolution:parseFloat((s=(e=ee.RETINA_PREFIX.exec(i))==null?void 0:e[1])!=null?s:"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:x.LoadParser,priority:Bt.Normal,name:"spritesheetLoader"},async testParse(i,t){return lt.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var l,u,c;const{texture:s,imageFilename:r}=(l=t==null?void 0:t.data)!=null?l:{};let n=lt.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let o;if(s instanceof C)o=s;else{const d=Qs(n+(r!=null?r:i.meta.image),t.src);o=(await e.load([d]))[d]}const a=new sn(o.source,i);await a.parse();const h=(u=i==null?void 0:i.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let g=n+f;(c=t.data)!=null&&c.ignoreMultiPack||(g=Qs(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const p=await Promise.all(d);a.linkedSheets=p,p.forEach(f=>{f.linkedSheets=[a].concat(a.linkedSheets.filter(g=>g!==f))})}return a},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};F.add(kl);class xe{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=xe.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new $,this.page=new $,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,s){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,s,r,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}const Il=(Eh=Rh.default)!=null?Eh:Rh,Gl=Il(globalThis.navigator),Ul=9,rs=100,Fl=0,Ol=0,nn=2,on=1,Dl=-1e3,Ll=-1e3,Nl=2;class an{constructor(t,e=Gl){this._mobileInfo=e,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook();const s=document.createElement("div");s.style.width=`${rs}px`,s.style.height=`${rs}px`,s.style.position="absolute",s.style.top=`${Fl}px`,s.style.left=`${Ol}px`,s.style.zIndex=nn.toString(),this._div=s,this._renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const t=document.createElement("button");t.style.width=`${on}px`,t.style.height=`${on}px`,t.style.position="absolute",t.style.top=`${Dl}px`,t.style.left=`${Ll}px`,t.style.zIndex=Nl.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){!this._hookDiv||(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.add(this),(t=this._renderer.view.canvas.parentNode)==null||t.appendChild(this._div))}_deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),(t=this._div.parentNode)==null||t.removeChild(this._div))}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let s=0;s<e.length;s++)this._updateAccessibleObjects(e[s])}init(t){var e;this.debug=(e=t==null?void 0:t.debug)!=null?e:this.debug,this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas))return;this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered);const{x:e,y:s,width:r,height:n}=this._renderer.view.canvas.getBoundingClientRect(),{width:o,height:a,resolution:h}=this._renderer,l=r/o*h,u=n/a*h;let c=this._div;c.style.left=`${e}px`,c.style.top=`${s}px`,c.style.width=`${o}px`,c.style.height=`${a}px`;for(let d=0;d<this._children.length;d++){const p=this._children[d];if(p._renderId!==this._renderId)p._accessibleActive=!1,Dr(this._children,d,1),this._div.removeChild(p._accessibleDiv),this._pool.push(p._accessibleDiv),p._accessibleDiv=null,d--;else{c=p._accessibleDiv;let f=p.hitArea;const g=p.worldTransform;p.hitArea?(c.style.left=`${(g.tx+f.x*g.a)*l}px`,c.style.top=`${(g.ty+f.y*g.d)*u}px`,c.style.width=`${f.width*g.a*l}px`,c.style.height=`${f.height*g.d*u}px`):(f=p.getBounds().rectangle,this._capHitArea(f),c.style.left=`${f.x*l}px`,c.style.top=`${f.y*u}px`,c.style.width=`${f.width*l}px`,c.style.height=`${f.height*u}px`,c.title!==p.accessibleTitle&&p.accessibleTitle!==null&&(c.title=p.accessibleTitle||""),c.getAttribute("aria-label")!==p.accessibleHint&&p.accessibleHint!==null&&c.setAttribute("aria-label",p.accessibleHint||"")),(p.accessibleTitle!==c.title||p.tabIndex!==c.tabIndex)&&(c.title=p.accessibleTitle||"",c.tabIndex=p.tabIndex,this.debug&&this._updateDebugHTML(c))}}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:s}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>s&&(t.height=s-t.y)}_addChild(t){let e=this._pool.pop();e||(e=document.createElement("button"),e.style.width=`${rs}px`,e.style.height=`${rs}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=nn.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{container:s}=t.target,r=this._renderer.events.rootBoundary,n=Object.assign(new xe(r),{target:s});r.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>r.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Ul&&this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}an.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"accessibility"};const Hl={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1},Js=Object.create(null),hn=Object.create(null);function ye(i,t){let e=hn[i];return e===void 0&&(Js[t]===void 0&&(Js[t]=1),hn[i]=e=Js[t]++),e}let se;function ln(){return(!se||(se==null?void 0:se.isContextLost()))&&(se=N.get().createCanvas().getContext("webgl",{})),se}let ns;function zl(){if(!ns){ns="mediump";const i=ln();i&&i.getShaderPrecisionFormat&&(ns=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return ns}function Wl(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),`
        
        #ifdef GL_ES // This checks if it is WebGL1
        #define in varying
        #define finalColor gl_FragColor
        #define texture texture2D
        #endif
        ${i}
        `):`
        
        #ifdef GL_ES // This checks if it is WebGL1
        #define in attribute
        #define out varying
        #endif
        ${i}
        `}function Vl(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&s!=="highp"&&(r="mediump"),`precision ${r} float;
${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function $l(i,t){return t?`#version 300 es
${i}`:i}const Xl={},Yl={};function jl(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Xl:Yl;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`}
${i}`}function Kl(i,t){return t?i.replace("#version 300 es",""):i}const ti={stripVersion:Kl,ensurePrecision:Vl,addProgramDefines:Wl,setProgramName:jl,insertVersion:$l},ei=Object.create(null),un=class yr{constructor(t){t={...yr.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:zl()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(ti).forEach(o=>{const a=s[o];r=ti[o](r,a,!0),n=ti[o](n,a,!1)}),this.fragment=r,this.vertex=n,this._key=ye(`${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 ei[e]||(ei[e]=new yr(t)),ei[e]}};un.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let be=un;const cn={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 ve(i){var t;return(t=cn[i])!=null?t:cn.float32}const ql={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 Zl({source:i,entryPoint:t}){var r;const e={},s=i.indexOf(`fn ${t}`);if(s!==-1){const n=i.indexOf("->",s);if(n!==-1){const o=i.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let h;for(;(h=a.exec(o))!==null;){const l=(r=ql[h[3]])!=null?r:"float32";e[h[2]]={location:parseInt(h[1],10),format:l,stride:ve(l).stride,offset:0,instance:!1,start:0}}}}return e}function si(i){var c,d,p;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(c=i.match(t))==null?void 0:c.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(s)[1],10),name:f.match(r)[2],isUniform:f.match(r)[1]==="<uniform>",type:f.match(n)[1]}));if(!l)return{groups:[],structs:[]};const u=(p=(d=i.match(o))==null?void 0:d.map(f=>{const g=f.match(h)[1],m=f.match(a).reduce((_,y)=>{const[b,v]=y.split(":");return _[b.trim()]=v.trim(),_},{});return m?{name:g,members:m}:null}).filter(({name:f})=>l.some(g=>g.type===f)))!=null?p:[];return{groups:l,structs:u}}var Te=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Te||{});function Ql({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]=[]),s.isUniform?t[s.group].push({binding:s.binding,visibility:Te.VERTEX|Te.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:Te.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"&&t[s.group].push({binding:s.binding,visibility:Te.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function Jl({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]={}),t[s.group][s.name]=s.binding}return t}function tu(i,t){const e=new Set,s=new Set,r=[...i.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...i.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:r,groups:n}}const ii=Object.create(null);class ie{constructor(t){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:r,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=s,e.source===s.source){const l=si(e.source);this.structsAndGroups=l}else{const l=si(s.source),u=si(e.source);this.structsAndGroups=tu(l,u)}this.layout=r!=null?r:Jl(this.structsAndGroups),this.gpuLayout=n!=null?n:Ql(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=ye(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Zl(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 ii[e]||(ii[e]=new ie(t)),ii[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>"],eu=dn.reduce((i,t)=>(i[t]=!0,i),{});function su(i,t){switch(i){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const pn=class Uh{constructor(t,e){var r,n;this._touched=0,this.uid=Q("uniform"),this._resourceType="uniformGroup",this._resourceId=Q("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Uh.defaultOptions,...e},this.uniformStructures=t;const s={};for(const o in t){const a=t[o];if(a.name=o,a.size=(r=a.size)!=null?r:1,!eu[a.type])throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${dn.join(", ")}`);(n=a.value)!=null||(a.value=su(a.type,a.size)),s[o]=a.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=ye(Object.keys(s).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};pn.defaultOptions={ubo:!1,isStatic:!1};let at=pn;class Pt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const r=t[s];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const s=this.resources[e];t!==s&&(s&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var e,s;const t=this.resources;for(const r in t)(s=(e=t[r]).off)==null||s.call(e,"change",this.onResourceChange,this);this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}var yt=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(yt||{});class ft extends dt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:r,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=yt.WEBGPU),s&&(o|=yt.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&a)for(const l in a)for(const u in a[l]){const c=a[l][u];h[c]={group:l,binding:u,name:c}}else if(e&&r&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u})}else if(n){r={},a={},e&&e.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u});let l=0;for(const u in n)h[u]||(r[99]||(r[99]=new Pt,this._ownedBindGroups.push(r[99])),h[u]={group:99,binding:l,name:u},a[99]=a[99]||{},a[99][l]=u,l++);for(const u in n){const c=u;let d=n[u];!d.source&&!d._resourceType&&(d=new at(d));const p=h[c];p&&(r[p.group]||(r[p.group]=new Pt,this._ownedBindGroups.push(r[p.group])),r[p.group].setResource(d,p.binding))}}this.groups=r,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,s){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new Pt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const r in e){const n=e[r];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:s,...r}=t;let n,o;return e&&(n=ie.from(e)),s&&(o=be.from(s)),new ft({gpuProgram:n,glProgram:o,...r})}}const iu={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},ri=0,ni=1,oi=2,ai=3,hi=4,li=5,ui=class Fh{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<ri)}set blend(t){!!(this.data&1<<ri)!==t&&(this.data^=1<<ri)}get offsets(){return!!(this.data&1<<ni)}set offsets(t){!!(this.data&1<<ni)!==t&&(this.data^=1<<ni)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<oi)}set culling(t){!!(this.data&1<<oi)!==t&&(this.data^=1<<oi)}get depthTest(){return!!(this.data&1<<ai)}set depthTest(t){!!(this.data&1<<ai)!==t&&(this.data^=1<<ai)}get depthMask(){return!!(this.data&1<<li)}set depthMask(t){!!(this.data&1<<li)!==t&&(this.data^=1<<li)}get clockwiseFrontFace(){return!!(this.data&1<<hi)}set clockwiseFrontFace(t){!!(this.data&1<<hi)!==t&&(this.data^=1<<hi)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=iu[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new Fh;return t.depthTest=!1,t.blend=!0,t}};ui.default2d=ui.for2d();let Ct=ui;const fn=class br extends ft{constructor(t){t={...br.defaultOptions,...t},super(t),this.enabled=!0,this._state=Ct.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.addResource("uTexture",0,1)}apply(t,e,s,r){t.applyFilter(this,e,s,r)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:e,gl:s,...r}=t;let n,o;return e&&(n=ie.from(e)),s&&(o=be.from(s)),new br({gpuProgram:n,glProgram:o,...r})}};fn.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let ru=fn;const ci=[];F.handleByNamedList(x.Environment,ci);async function nu(i){if(!i)for(let t=0;t<ci.length;t++){const e=ci[t];if(e.value.test()){await e.value.load();return}}}let Se;function mn(){if(typeof Se=="boolean")return Se;try{Se=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Se=!1}return Se}var ut=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))(ut||{});class gn{constructor(t){this.items=[],this._name=t}emit(t,e,s,r,n,o,a,h){const{name:l,items:u}=this;for(let c=0,d=u.length;c<d;c++)u[c][l](t,e,s,r,n,o,a,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 ou=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],_n=class Oh extends dt{constructor(t){var s;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=[...ou,...(s=this.config.runners)!=null?s:[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await nu(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash)t={...this._systemsHash[s].constructor.defaultOptions,...t};t={...Oh.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let s=0;s<this.runners.init.items.length;s++)await this.runners.init.items[s].init(t);this._initOptions=t}render(t,e){let s=t;if(s instanceof J&&(s={container:s},e&&(D(H,"passing a second argument is deprecated, please use render options instead"),s.target=e.renderTexture)),s.target||(s.target=this.view.renderTarget),s.target===this.view.renderTarget&&(this._lastObjectRendered=s.container,s.clearColor=this.background.colorRgba),s.clearColor){const r=Array.isArray(s.clearColor)&&s.clearColor.length===4;s.clearColor=r?s.clearColor:V.shared.setValue(s.clearColor).toArray()}s.transform||(s.container.updateLocalTransform(),s.transform=s.container.localTransform),this.runners.prerender.emit(s),this.runners.renderStart.emit(s),this.runners.render.emit(s),this.runners.renderEnd.emit(s),this.runners.postrender.emit(s)}resize(t,e,s){const r=this.view.resolution;this.view.resize(t,e,s),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),s!==void 0&&s!==r&&this.runners.resolutionChange.emit(s)}clear(t={}){var o;const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),(o=t.clear)!=null||(t.clear=ut.ALL);const{clear:s,clearColor:r,target:n}=t;V.shared.setValue(r!=null?r:this.background.colorRgba),e.renderTarget.clear(n,s,V.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 gn(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const r in this.runners)this.runners[r].add(s);return this}_addPipes(t,e){const s=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,o=r.name,a=s[o];this.renderPipes[o]=new n(this,a?new a: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(!mn())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};_n.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let os=_n,di;function au(i){return di!==void 0||(di=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i!=null?i:os.defaultOptions.failIfMajorPerformanceCaveat};try{if(!N.get().getWebGLRenderingContext())return!1;let s=N.get().createCanvas().getContext("webgl",t);const r=!!((e=s==null?void 0:s.getContextAttributes())!=null&&e.stencil);if(s){const n=s.getExtension("WEBGL_lose_context");n&&n.loseContext()}return s=null,r}catch{return!1}})()),di}let pi;async function hu(i={}){return pi!==void 0||(pi=await(async()=>{const t=N.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),pi}const xn=["webgl","webgpu","canvas"];async function lu(i){var n;let t=[];i.preference?(t.push(i.preference),xn.forEach(o=>{o!==i.preference&&t.push(o)})):t=xn.slice();let e,s={};for(let o=0;o<t.length;o++){const a=t[o];if(a==="webgpu"&&await hu()){const{WebGPURenderer:h}=await pe(()=>Promise.resolve().then(function(){return Bf}),void 0);e=h,s={...i,...i.webgpu};break}else if(a==="webgl"&&au((n=i.failIfMajorPerformanceCaveat)!=null?n:os.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:h}=await pe(()=>Promise.resolve().then(function(){return df}),void 0);e=h,s={...i,...i.webgl};break}else if(a==="canvas")throw s={...i},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(s),r}class yn{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this)}static destroy(){}}yn.extension=x.Application;class bn{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer)}destroy(){this._renderer=null}}bn.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"initHook",priority:-10};const vn=class vr{constructor(...t){this.stage=new J,t[0]!==void 0&&D(H,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await lu(t),vr._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return D(H,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=vr._plugins.slice(0);s.reverse(),s.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};vn._plugins=[],xr=vn,F.handleByList(x.Application,xr._plugins),F.add(yn);class Tn{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{!this._resizeTo||(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;e=r,s=n}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Tn.extension=x.Application;class Sn{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,te.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ot.shared:new ot,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Sn.extension=x.Application;class wn extends dt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return D(H,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return D(H,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return D(H,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return D(H,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return D(H,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}const En=class Tr{constructor(t,e,s,r){this.uid=Q("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=s,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:V.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=Tr.defaultTextureSize,{gradientStops:e}=this,s=N.get().createCanvas();s.width=t,s.height=t;const r=s.getContext("2d"),n=r.createLinearGradient(0,0,Tr.defaultTextureSize,1);for(let g=0;g<e.length;g++){const m=e[g];n.addColorStop(m.offset,m.color)}r.fillStyle=n,r.fillRect(0,0,t,t),this.texture=new C({source:new Jt({resource:s,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:o,y0:a,x1:h,y1:l}=this,u=new R,c=h-o,d=l-a,p=Math.sqrt(c*c+d*d),f=Math.atan2(d,c);u.translate(-o,-a),u.scale(1/t,1/t),u.rotate(-f),u.scale(256/p,1),this.transform=u,this._styleKey=null}get styleKey(){if(this._styleKey)return this._styleKey;const t=this.gradientStops.map(r=>`${r.offset}-${r.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};En.defaultTextureSize=256;let we=En;const An={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 as{constructor(t,e){this.uid=Q("fillPattern"),this.transform=new R,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=An[e].addressModeU,t.source.style.addressModeV=An[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)}}function uu(i,t){const e=um(i),s=[];let r=null,n=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],u=h;switch(l){case"M":n=u[1],o=u[2],t.moveTo(n,o);break;case"m":n+=u[1],o+=u[2],t.moveTo(n,o);break;case"H":n=u[1],t.lineTo(n,o);break;case"h":n+=u[1],t.lineTo(n,o);break;case"V":o=u[1],t.lineTo(n,o);break;case"v":o+=u[1],t.lineTo(n,o);break;case"L":n=u[1],o=u[2],t.lineTo(n,o);break;case"l":n+=u[1],o+=u[2],t.lineTo(n,o);break;case"C":n=u[5],o=u[6],t.bezierCurveTo(u[1],u[2],u[3],u[4],n,o);break;case"c":t.bezierCurveTo(n+u[1],o+u[2],n+u[3],o+u[4],n+u[5],o+u[6]),n+=u[5],o+=u[6];break;case"S":n=u[3],o=u[4],t.bezierCurveToShort(u[1],u[2],n,o);break;case"s":t.bezierCurveToShort(n+u[1],o+u[2],n+u[3],o+u[4]),n+=u[3],o+=u[4];break;case"Q":n=u[3],o=u[4],t.quadraticCurveTo(u[1],u[2],n,o);break;case"q":t.quadraticCurveTo(n+u[1],o+u[2],n+u[3],o+u[4]),n+=u[3],o+=u[4];break;case"T":n=u[1],o=u[2],t.quadraticCurveToShort(n,o);break;case"t":n+=u[1],o+=u[2],t.quadraticCurveToShort(n,o);break;case"A":n=u[6],o=u[7],t.arcToSvg(u[1],u[2],u[3],u[4],u[5],n,o);break;case"a":n+=u[6],o+=u[7],t.arcToSvg(u[1],u[2],u[3],u[4],u[5],n,o);break;case"Z":case"z":t.closePath(),s.length>0&&(r=s.pop(),r?(n=r.startX,o=r.startY):(n=0,o=0)),r=null;break;default:U(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&r===null&&(r={startX:n,startY:o},s.push(r))}return t}class fi{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new fi(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,o=this.radius,a=s/2,h=Math.sqrt(r*r+n*n);return h<o+a&&h>o-a}getBounds(t){return t=t||new X,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 mi{constructor(t=0,e=0,s=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=r}clone(){return new mi(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return s*=s,r*=r,s+r<=1}strokeContains(t,e,s){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const o=s/2,a=r-o,h=n-o,l=r+o,u=n+o,c=t-this.x,d=e-this.y,p=c*c/(a*a)+d*d/(h*h),f=c*c/(l*l)+d*d/(u*u);return p>1&&f<=1}getBounds(t){return t=t||new X,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 cu(i,t,e,s,r,n){const o=i-e,a=t-s,h=r-e,l=n-s,u=o*h+a*l,c=h*h+l*l;let d=-1;c!==0&&(d=u/c);let p,f;d<0?(p=e,f=s):d>1?(p=r,f=n):(p=e+d*h,f=s+d*l);const g=i-p,m=t-f;return g*g+m*m}class Ee{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let r=0,n=e.length;r<n;r++)s.push(e[r].x,e[r].y);e=s}this.points=e,this.closePath=!0}clone(){const t=this.points.slice(),e=new Ee(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const r=this.points.length/2;for(let n=0,o=r-1;n<r;o=n++){const a=this.points[n*2],h=this.points[n*2+1],l=this.points[o*2],u=this.points[o*2+1];h>e!=u>e&&t<(l-a)*((e-h)/(u-h))+a&&(s=!s)}return s}strokeContains(t,e,s){const r=s/2,n=r*r,{points:o}=this,a=o.length-(this.closePath?0:2);for(let h=0;h<a;h+=2){const l=o[h],u=o[h+1],c=o[(h+2)%o.length],d=o[(h+3)%o.length];if(cu(t,e,l,u,c,d)<=n)return!0}return!1}getBounds(t){t=t||new X;const e=this.points;let s=1/0,r=-1/0,n=1/0,o=-1/0;for(let a=0,h=e.length;a<h;a+=2){const l=e[a],u=e[a+1];s=l<s?l:s,r=l>r?l:r,n=u<n?u:n,o=u>o?u:o}return t.x=s,t.width=r-s,t.y=n,t.height=o-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 hs=(i,t,e,s,r,n)=>{const o=i-e,a=t-s,h=Math.sqrt(o*o+a*a);return h>=r-n&&h<=r+n};class gi{constructor(t=0,e=0,s=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=r,this.radius=n}getBounds(t){return t=t||new X,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new gi(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let r=t-(this.x+s),n=e-(this.y+s);const o=s*s;if(r*r+n*n<=o||(r=t-(this.x+this.width-s),r*r+n*n<=o)||(n=e-(this.y+this.height-s),r*r+n*n<=o)||(r=t-(this.x+s),r*r+n*n<=o))return!0}return!1}strokeContains(t,e,s){const{x:r,y:n,width:o,height:a,radius:h}=this,l=s/2,u=r+h,c=n+h,d=o-h*2,p=a-h*2,f=r+o,g=n+a;return(t>=r-l&&t<=r+l||t>=f-l&&t<=f+l)&&e>=c&&e<=c+p||(e>=n-l&&e<=n+l||e>=g-l&&e<=g+l)&&t>=u&&t<=u+d?!0:t<u&&e<c&&hs(t,e,u,c,h,l)||t>f-h&&e<c&&hs(t,e,f-h,c,h,l)||t>f-h&&e>g-h&&hs(t,e,f-h,g-h,h,l)||t<u&&e>g-h&&hs(t,e,u,g-h,h,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const du=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function pu(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=`
else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function fu(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const s=du.replace(/%forloop%/gi,pu(i));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}}finally{t.deleteShader(e)}return i}let re=null;function kt(){var t;if(re)return re;const i=ln();return re=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),re=fu(re,i),(t=i.getExtension("WEBGL_lose_context"))==null||t.loseContext(),re}const Pn={};function _i(i,t){let e=2166136261;for(let s=0;s<t;s++)e^=i[s].uid,e=Math.imul(e,16777619),e>>>=0;return Pn[e]||mu(i,t,e)}let xi=0;function mu(i,t,e){const s={};let r=0;xi||(xi=kt());for(let o=0;o<xi;o++){const a=o<t?i[o]:C.EMPTY.source;s[r++]=a.source,s[r++]=a.style}const n=new Pt(s);return Pn[e]=n,n}class Cn{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 yi(i,t){const e=i.byteLength/8|0,s=new Float64Array(i,0,e);new Float64Array(t,0,e).set(s);const r=i.byteLength-e*8;if(r>0){const n=new Uint8Array(i,e*8,r);new Uint8Array(t,e*8,r).set(n)}}const gu={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var et=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",i[i.NONE=4]="NONE",i))(et||{});function ls(i,t){return t.alphaMode==="no-premultiply-alpha"&&gu[i]||i}class _u{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 xu{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new _u,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Mn=[];let bi=0;function Rn(){return bi>0?Mn[--bi]:new xu}function Bn(i){Mn[bi++]=i}let Ae=0;const kn=class Is{constructor(t={}){var n;this.uid=Q("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._vertexSize=6,this._elements=[],Is.defaultOptions.maxTextures=(n=Is.defaultOptions.maxTextures)!=null?n:kt(),t={...Is.defaultOptions,...t};const{vertexSize:e,indexSize:s,maxTextures:r}=t;this.attributeBuffer=new Cn(e*this._vertexSize*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=r}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Bn(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.location=this.attributeSize,t.batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.vertexSize*this._vertexSize}checkAndUpdateTexture(t,e){const s=t.batch.textures.ids[e._source.uid];return!s&&s!==0?!1:(t.textureId=s,t.texture=e,!0)}updateElement(t){this.dirty=!0,t.packAttributes(this.attributeBuffer.float32View,this.attributeBuffer.uint32View,t.location,t.textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let s=Rn(),r=s.textures;r.clear();const n=e[this.elementStart];let o=ls(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 a=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let u=this._batchIndexSize,c=this._batchIndexStart,d="startBatch";const p=this.maxTextures;for(let f=this.elementStart;f<this.elementSize;++f){const g=e[f];e[f]=null;const m=g.texture._source,_=ls(g.blendMode,m),y=o!==_;if(m._batchTick===Ae&&!y){g.textureId=m._textureBindLocation,u+=g.indexSize,g.packAttributes(a,h,g.location,g.textureId),g.packIndex(l,g.indexStart,g.location/this._vertexSize),g.batch=s;continue}m._batchTick=Ae,(r.count>=p||y)&&(this._finishBatch(s,c,u-c,r,o,t,d),d="renderBatch",c=u,o=_,s=Rn(),r=s.textures,r.clear(),++Ae),g.textureId=m._textureBindLocation=r.count,r.ids[m.uid]=r.count,r.textures[r.count++]=m,g.batch=s,u+=g.indexSize,g.packAttributes(a,h,g.location,g.textureId),g.packIndex(l,g.indexStart,g.location/this._vertexSize)}r.count>0&&(this._finishBatch(s,c,u-c,r,o,t,d),c=u,++Ae),this.elementStart=this.elementSize,this._batchIndexStart=c,this._batchIndexSize=u}_finishBatch(t,e,s,r,n,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=r,t.blendMode=n,t.start=e,t.size=s,++Ae,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new Cn(e);yi(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const r=s>65535?new Uint32Array(s):new Uint16Array(s);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)r[n]=e[n];else yi(e.buffer,r.buffer);this.indexBuffer=r}destroy(){for(let t=0;t<this.batches.length;t++)Bn(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}};kn.defaultOptions={vertexSize:4,indexSize:6,maxTextures:null};let In=kn;var W=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(W||{});class bt extends dt{constructor(t){let{data:e,size:s}=t;const{usage:r,label:n,shrinkToFit:o}=t;super(),this.uid=Q("buffer"),this._resourceType="buffer",this._resourceId=Q("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=s!=null?s:e==null?void 0:e.byteLength;const a=!!e;this.descriptor={size:s,usage:r,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?o:!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&W.STATIC)}set static(t){t?this.descriptor.usage|=W.STATIC:this.descriptor.usage&=~W.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLength<r.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=Q("resource"),this.emit("change",this));return}s&&this.emit("update",this)}update(t){this._updateSize=t!=null?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 Gn(i,t){if(!(i instanceof bt)){let e=t?W.INDEX:W.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=W.INDEX|W.COPY_DST):(i=new Float32Array(i),e=W.VERTEX|W.COPY_DST)),i=new bt({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function yu(i,t,e){const s=i.getAttribute(t);if(!s)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const r=s.buffer.data;let n=1/0,o=1/0,a=-1/0,h=-1/0;const l=r.BYTES_PER_ELEMENT,u=(s.offset||0)/l,c=(s.stride||2*4)/l;for(let d=u;d<r.length;d+=c){const p=r[d],f=r[d+1];p>a&&(a=p),f>h&&(h=f),p<n&&(n=p),f<o&&(o=f)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=h,e}function bu(i){return(i instanceof bt||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=Gn(i.buffer,!1),i}class us extends dt{constructor(t){const{attributes:e,indexBuffer:s,topology:r}=t;super(),this.uid=Q("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new nt,this._boundsDirty=!0,this.attributes=e,this.buffers=[],this.instanceCount=t.instanceCount||1;for(const n in e){const o=e[n]=bu(e[n]);this.buffers.indexOf(o.buffer)===-1&&(this.buffers.push(o.buffer),o.buffer.on("update",this.onBufferUpdate,this),o.buffer.on("change",this.onBufferUpdate,this))}s&&(this.indexBuffer=Gn(s,!0),this.buffers.push(this.indexBuffer)),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,yu(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 vu=new Float32Array(1),Tu=new Uint32Array(1);class Un extends us{constructor(){const t=new bt({data:vu,label:"attribute-batch-buffer",usage:W.VERTEX|W.COPY_DST,shrinkToFit:!1}),e=new bt({data:Tu,label:"index-batch-buffer",usage:W.INDEX|W.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:2*4},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:4*4},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:5*4}},indexBuffer:e})}}function Su(i,t,e,s,r,n,o,a=null){let h=0;e*=t,r*=n;const l=a.a,u=a.b,c=a.c,d=a.d,p=a.tx,f=a.ty;for(;h<o;){const g=i[e],m=i[e+1];s[r]=l*g+c*m+p,s[r+1]=u*g+d*m+f,r+=n,e+=t,h++}}function wu(i,t,e,s){let r=0;for(t*=e;r<s;)i[t]=0,i[t+1]=0,t+=e,r++}function Fn(i,t,e,s,r){const n=t.a,o=t.b,a=t.c,h=t.d,l=t.tx,u=t.ty;e=e||0,s=s||2,r=r||i.length/s-e;let c=e*s;for(let d=0;d<r;d++){const p=i[c],f=i[c+1];i[c]=n*p+a*f+l,i[c+1]=o*p+h*f+u,c+=s}}function Eu(i,t){if(i===16777215||!t)return t;if(t===16777215||!i)return i;const e=i>>16&255,s=i>>8&255,r=i&255,n=t>>16&255,o=t>>8&255,a=t&255,h=e*n/255,l=s*o/255,u=r*a/255;return(h<<16)+(l<<8)+u}class vi{constructor(){this.batcher=null,this.batch=null,this.applyTransform=!0,this.roundPixels=0}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}packIndex(t,e,s){const r=this.geometryData.indices;for(let n=0;n<this.indexSize;n++)t[e++]=r[n+this.indexOffset]+s-this.vertexOffset}packAttributes(t,e,s,r){const n=this.geometryData,o=this.renderable,a=n.vertices,h=n.uvs,l=this.vertexOffset*2,u=(this.vertexOffset+this.vertexSize)*2,c=this.color,d=c>>16|c&65280|(c&255)<<16;if(this.applyTransform){const p=Eu(d,o.groupColor)+(this.alpha*o.groupAlpha*255<<24),f=o.groupTransform,g=r<<16|this.roundPixels&65535,m=f.a,_=f.b,y=f.c,b=f.d,v=f.tx,T=f.ty;for(let A=l;A<u;A+=2){const E=a[A],P=a[A+1];t[s]=m*E+y*P+v,t[s+1]=_*E+b*P+T,t[s+2]=h[A],t[s+3]=h[A+1],e[s+4]=p,e[s+5]=g,s+=6}}else{const p=d+(this.alpha*255<<24);for(let f=l;f<u;f+=2)t[s]=a[f],t[s+1]=a[f+1],t[s+2]=h[f],t[s+3]=h[f+1],e[s+4]=p,e[s+5]=r<<16,s+=6}}get vertSize(){return this.vertexSize}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.vertexOffset=this.vertexOffset,t.vertexSize=this.vertexSize,t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const Pe={extension:{type:x.ShapeBuilder,name:"circle"},build(i,t){let e,s,r,n,o,a;if(i.type==="circle"){const v=i;e=v.x,s=v.y,o=a=v.radius,r=n=0}else if(i.type==="ellipse"){const v=i;e=v.x,s=v.y,o=v.halfWidth,a=v.halfHeight,r=n=0}else{const v=i,T=v.width/2,A=v.height/2;e=v.x+T,s=v.y+A,o=a=Math.max(0,Math.min(v.radius,Math.min(T,A))),r=T-o,n=A-a}if(!(o>=0&&a>=0&&r>=0&&n>=0))return t;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(l===0)return t;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=s+n,t[2]=t[4]=e-r,t[5]=t[7]=s-n,t;let u=0,c=h*4+(r?2:0)+2,d=c,p=l,f=r+o,g=n,m=e+f,_=e-f,y=s+g;if(t[u++]=m,t[u++]=y,t[--c]=y,t[--c]=_,n){const v=s-g;t[d++]=_,t[d++]=v,t[--p]=v,t[--p]=m}for(let v=1;v<h;v++){const T=Math.PI/2*(v/h),A=r+Math.cos(T)*o,E=n+Math.sin(T)*a,P=e+A,S=e-A,w=s+E,Y=s-E;t[u++]=P,t[u++]=w,t[--c]=w,t[--c]=S,t[d++]=S,t[d++]=Y,t[--p]=Y,t[--p]=P}f=r,g=n+a,m=e+f,_=e-f,y=s+g;const b=s-g;return t[u++]=m,t[u++]=y,t[--p]=b,t[--p]=m,r&&(t[u++]=_,t[u++]=y,t[--p]=b,t[--p]=_),t},triangulate(i,t,e,s,r,n){if(i.length===0)return;let o=0,a=0;for(let u=0;u<i.length;u+=2)o+=i[u],a+=i[u+1];o/=i.length/2,a/=i.length/2;let h=s;t[h*e]=o,t[h*e+1]=a;const l=h++;for(let u=0;u<i.length;u+=2)t[h*e]=i[u],t[h*e+1]=i[u+1],u>0&&(r[n++]=h,r[n++]=l,r[n++]=h-1),h++;r[n++]=l+1,r[n++]=l,r[n++]=h-1}},Au={...Pe,extension:{...Pe.extension,name:"ellipse"}},Pu={...Pe,extension:{...Pe.extension,name:"roundedRectangle"}},Cu=1e-4,On=1e-4;function Mu(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,r=i[t-2],n=i[t-1];s<t;s+=2){const o=i[s],a=i[s+1];e+=(o-r)*(a+n),r=o,n=a}return e<0?-1:1}function Dn(i,t,e,s,r,n,o,a){const h=i-e*r,l=t-s*r,u=i+e*n,c=t+s*n;let d,p;o?(d=s,p=-e):(d=-s,p=e);const f=h+d,g=l+p,m=u+d,_=c+p;return a.push(f,g),a.push(m,_),2}function Ht(i,t,e,s,r,n,o,a){const h=e-i,l=s-t;let u=Math.atan2(h,l),c=Math.atan2(r-i,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const p=c-u,f=Math.abs(p),g=Math.sqrt(h*h+l*l),m=(15*f*Math.sqrt(g)/Math.PI>>0)+1,_=p/m;if(d+=_,a){o.push(i,t),o.push(e,s);for(let y=1,b=d;y<m;y++,b+=_)o.push(i,t),o.push(i+Math.sin(b)*g,t+Math.cos(b)*g);o.push(i,t),o.push(r,n)}else{o.push(e,s),o.push(i,t);for(let y=1,b=d;y<m;y++,b+=_)o.push(i+Math.sin(b)*g,t+Math.cos(b)*g),o.push(i,t);o.push(r,n),o.push(i,t)}return m*2}function Ru(i,t,e,s,r,n,o,a,h){const l=Cu;if(i.length===0)return;const u=t;let c=u.alignment;if(t.alignment!==.5){let q=Mu(i);e&&(q*=-1),c=(c-.5)*q+.5}const d=new $(i[0],i[1]),p=new $(i[i.length-2],i[i.length-1]),f=s,g=Math.abs(d.x-p.x)<l&&Math.abs(d.y-p.y)<l;if(f){i=i.slice(),g&&(i.pop(),i.pop(),p.set(i[i.length-2],i[i.length-1]));const q=(d.x+p.x)*.5,Ut=(p.y+d.y)*.5;i.unshift(q,Ut),i.push(q,Ut)}const m=r,_=i.length/2;let y=i.length;const b=m.length/2,v=u.width/2,T=v*v,A=u.miterLimit*u.miterLimit;let E=i[0],P=i[1],S=i[2],w=i[3],Y=0,it=0,B=-(P-w),k=E-S,K=0,O=0,ct=Math.sqrt(B*B+k*k);B/=ct,k/=ct,B*=v,k*=v;const Cs=c,I=(1-Cs)*2,G=Cs*2;f||(u.cap==="round"?y+=Ht(E-B*(I-G)*.5,P-k*(I-G)*.5,E-B*I,P-k*I,E+B*G,P+k*G,m,!0)+2:u.cap==="square"&&(y+=Dn(E,P,B,k,I,G,!0,m))),m.push(E-B*I,P-k*I),m.push(E+B*G,P+k*G);for(let q=1;q<_-1;++q){E=i[(q-1)*2],P=i[(q-1)*2+1],S=i[q*2],w=i[q*2+1],Y=i[(q+1)*2],it=i[(q+1)*2+1],B=-(P-w),k=E-S,ct=Math.sqrt(B*B+k*k),B/=ct,k/=ct,B*=v,k*=v,K=-(w-it),O=S-Y,ct=Math.sqrt(K*K+O*O),K/=ct,O/=ct,K*=v,O*=v;const Ut=S-E,ze=P-w,We=S-Y,Ve=it-w,Ah=Ut*We+ze*Ve,Ms=ze*We-Ve*Ut,$e=Ms<0;if(Math.abs(Ms)<.001*Math.abs(Ah)){m.push(S-B*I,w-k*I),m.push(S+B*G,w+k*G),Ah>=0&&(u.join==="round"?y+=Ht(S,w,S-B*I,w-k*I,S-K*I,w-O*I,m,!1)+4:y+=2,m.push(S-K*G,w-O*G),m.push(S+K*I,w+O*I));continue}const Ph=(-B+E)*(-k+w)-(-B+S)*(-k+P),Ch=(-K+Y)*(-O+w)-(-K+S)*(-O+it),Rs=(Ut*Ch-We*Ph)/Ms,Bs=(Ve*Ph-ze*Ch)/Ms,_r=(Rs-S)*(Rs-S)+(Bs-w)*(Bs-w),Xt=S+(Rs-S)*I,Yt=w+(Bs-w)*I,jt=S-(Rs-S)*G,Kt=w-(Bs-w)*G,rm=Math.min(Ut*Ut+ze*ze,We*We+Ve*Ve),Mh=$e?I:G,nm=rm+Mh*Mh*T;_r<=nm?u.join==="bevel"||_r/T>A?($e?(m.push(Xt,Yt),m.push(S+B*G,w+k*G),m.push(Xt,Yt),m.push(S+K*G,w+O*G)):(m.push(S-B*I,w-k*I),m.push(jt,Kt),m.push(S-K*I,w-O*I),m.push(jt,Kt)),y+=2):u.join==="round"?$e?(m.push(Xt,Yt),m.push(S+B*G,w+k*G),y+=Ht(S,w,S+B*G,w+k*G,S+K*G,w+O*G,m,!0)+4,m.push(Xt,Yt),m.push(S+K*G,w+O*G)):(m.push(S-B*I,w-k*I),m.push(jt,Kt),y+=Ht(S,w,S-B*I,w-k*I,S-K*I,w-O*I,m,!1)+4,m.push(S-K*I,w-O*I),m.push(jt,Kt)):(m.push(Xt,Yt),m.push(jt,Kt)):(m.push(S-B*I,w-k*I),m.push(S+B*G,w+k*G),u.join==="round"?$e?y+=Ht(S,w,S+B*G,w+k*G,S+K*G,w+O*G,m,!0)+2:y+=Ht(S,w,S-B*I,w-k*I,S-K*I,w-O*I,m,!1)+2:u.join==="miter"&&_r/T<=A&&($e?(m.push(jt,Kt),m.push(jt,Kt)):(m.push(Xt,Yt),m.push(Xt,Yt)),y+=2),m.push(S-K*I,w-O*I),m.push(S+K*G,w+O*G),y+=2)}E=i[(_-2)*2],P=i[(_-2)*2+1],S=i[(_-1)*2],w=i[(_-1)*2+1],B=-(P-w),k=E-S,ct=Math.sqrt(B*B+k*k),B/=ct,k/=ct,B*=v,k*=v,m.push(S-B*I,w-k*I),m.push(S+B*G,w+k*G),f||(u.cap==="round"?y+=Ht(S-B*(I-G)*.5,w-k*(I-G)*.5,S-B*I,w-k*I,S+B*G,w+k*G,m,!1)+2:u.cap==="square"&&(y+=Dn(S,w,B,k,I,G,!1,m)));const im=On*On;for(let q=b;q<y+b-2;++q)E=m[q*2],P=m[q*2+1],S=m[(q+1)*2],w=m[(q+1)*2+1],Y=m[(q+2)*2],it=m[(q+2)*2+1],!(Math.abs(E*(w-it)+S*(it-P)+Y*(P-w))<im)&&a.push(q,q+1,q+2)}function Ln(i,t,e,s,r,n,o){const a=om(i,t,2);if(!a)return;for(let l=0;l<a.length;l+=3)n[o++]=a[l]+r,n[o++]=a[l+1]+r,n[o++]=a[l+2]+r;let h=r*s;for(let l=0;l<i.length;l+=2)e[h]=i[l],e[h+1]=i[l+1],h+=s}const Bu=[],ku={extension:{type:x.ShapeBuilder,name:"polygon"},build(i,t){for(let e=0;e<i.points.length;e++)t[e]=i.points[e];return t},triangulate(i,t,e,s,r,n){Ln(i,Bu,t,e,s,r,n)}},Iu={extension:{type:x.ShapeBuilder,name:"rectangle"},build(i,t){const e=i,s=e.x,r=e.y,n=e.width,o=e.height;return n>=0&&o>=0&&(t[0]=s,t[1]=r,t[2]=s+n,t[3]=r,t[4]=s+n,t[5]=r+o,t[6]=s,t[7]=r+o),t},triangulate(i,t,e,s,r,n){let o=0;s*=e,t[s+o]=i[0],t[s+o+1]=i[1],o+=e,t[s+o]=i[2],t[s+o+1]=i[3],o+=e,t[s+o]=i[6],t[s+o+1]=i[7],o+=e,t[s+o]=i[4],t[s+o+1]=i[5],o+=e;const a=s/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2}},Gu={extension:{type:x.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,t},triangulate(i,t,e,s,r,n){let o=0;s*=e,t[s+o]=i[0],t[s+o+1]=i[1],o+=e,t[s+o]=i[2],t[s+o+1]=i[3],o+=e,t[s+o]=i[4],t[s+o+1]=i[5];const a=s/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2}},cs={};F.handleByMap(x.ShapeBuilder,cs),F.add(Iu,ku,Gu,Pe,Au,Pu);const Uu=new X;function Fu(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r<i.instructions.length;r++){const n=i.instructions[r];if(n.action==="texture")Ou(n.data,s,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,h=n.data.style,l=n.data.hole;o&&l&&Nn(l.shapePath,h,null,!0,s,e),Nn(a,h,l,o,s,e)}}}function Ou(i,t,e){const{vertices:s,uvs:r,indices:n}=e,o=n.length,a=s.length/2,h=[],l=cs.rectangle,u=Uu,c=i.image;u.x=i.dx,u.y=i.dy,u.width=i.dw,u.height=i.dh;const d=i.transform;l.build(u,h),d&&Fn(h,d),l.triangulate(h,s,2,a,n,o);const p=c.uvs;r.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const f=L.get(vi);f.indexOffset=o,f.indexSize=n.length-o,f.vertexOffset=a,f.vertexSize=s.length/2-a,f.color=i.style,f.alpha=i.alpha,f.texture=c,f.geometryData=e,t.push(f)}function Nn(i,t,e,s,r,n){const{vertices:o,uvs:a,indices:h}=n,l=i.shapePrimitives.length-1;i.shapePrimitives.forEach(({shape:u,transform:c},d)=>{var v;const p=h.length,f=o.length/2,g=[],m=cs[u.type];if(m.build(u,g),c&&Fn(g,c),s){const T=(v=u.closePath)!=null?v:!0;Ru(g,t,!1,T,o,2,f,h)}else if(e&&l===d){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const T=[],A=g.slice();Du(e.shapePath).forEach(E=>{T.push(A.length/2),A.push(...E)}),Ln(A,T,o,2,f,h,p)}else m.triangulate(g,o,2,f,h,p);const _=a.length/2,y=t.texture;if(y!==C.WHITE){const T=t.matrix;T&&(c&&T.append(c.clone().invert()),Su(o,2,f,a,_,2,o.length/2-f,T))}else wu(a,_,2,o.length/2-f);const b=L.get(vi);b.indexOffset=p,b.indexSize=h.length-p,b.vertexOffset=f,b.vertexSize=o.length/2-f,b.color=t.color,b.alpha=t.alpha,b.texture=y,b.geometryData=n,r.push(b)})}function Du(i){if(!i)return[];const t=i.shapePrimitives,e=[];for(let s=0;s<t.length;s++){const r=t[s].shape,n=[];cs[r.type].build(r,n),e.push(n)}return e}class Lu{constructor(){this.batcher=new In,this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Nu{constructor(){this.geometry=new Un,this.instructions=new Wr}init(){this.instructions.reset()}}const Ti=class Sr{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){var e;Sr.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Sr.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),Fu(t,e);const s=t.batchMode;t.customShader||s==="no-batch"?e.isBatchable=!1:s==="auto"&&(e.isBatchable=e.geometryData.vertices.length<400),t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=L.get(Nu),{batches:s,geometryData:r,batcher:n}=this._gpuContextHash[t.uid],o=r.vertices.length,a=r.indices.length;for(let u=0;u<s.length;u++)s[u].applyTransform=!1;n.ensureAttributeBuffer(o),n.ensureIndexBuffer(a),n.begin();for(let u=0;u<s.length;u++){const c=s[u];n.add(c)}n.finish(e.instructions);const h=e.geometry;h.indexBuffer.setDataWithSize(n.indexBuffer,n.indexSize,!0),h.buffers[0].setDataWithSize(n.attributeBuffer.float32View,n.attributeSize,!0);const l=n.batches;for(let u=0;u<l.length;u++){const c=l[u];c.bindGroup=_i(c.textures.textures,c.textures.count)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new Lu;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]&&(L.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(s=>{L.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Ti.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"graphicsContext"},Ti.defaultOptions={bezierSmoothness:.5};let Si=Ti;const Hu=8,ds=11920929e-14,zu=1;function Hn(i,t,e,s,r,n,o,a,h,l){const u=Math.min(.99,Math.max(0,l!=null?l:Si.defaultOptions.bezierSmoothness));let c=(zu-u)/1;return c*=c,Wu(t,e,s,r,n,o,a,h,i,c),i}function Wu(i,t,e,s,r,n,o,a,h,l){wi(i,t,e,s,r,n,o,a,h,l,0),h.push(o,a)}function wi(i,t,e,s,r,n,o,a,h,l,u){if(u>Hu)return;const c=(i+e)/2,d=(t+s)/2,p=(e+r)/2,f=(s+n)/2,g=(r+o)/2,m=(n+a)/2,_=(c+p)/2,y=(d+f)/2,b=(p+g)/2,v=(f+m)/2,T=(_+b)/2,A=(y+v)/2;if(u>0){let E=o-i,P=a-t;const S=Math.abs((e-o)*P-(s-a)*E),w=Math.abs((r-o)*P-(n-a)*E);if(S>ds&&w>ds){if((S+w)*(S+w)<=l*(E*E+P*P)){h.push(T,A);return}}else if(S>ds){if(S*S<=l*(E*E+P*P)){h.push(T,A);return}}else if(w>ds){if(w*w<=l*(E*E+P*P)){h.push(T,A);return}}else if(E=T-(i+o)/2,P=A-(t+a)/2,E*E+P*P<=l){h.push(T,A);return}}wi(i,t,c,d,_,y,T,A,h,l,u+1),wi(T,A,b,v,g,m,o,a,h,l,u+1)}const Vu=8,$u=11920929e-14,Xu=1;function Yu(i,t,e,s,r,n,o,a){const h=Math.min(.99,Math.max(0,a!=null?a:Si.defaultOptions.bezierSmoothness));let l=(Xu-h)/1;return l*=l,ju(t,e,s,r,n,o,i,l),i}function ju(i,t,e,s,r,n,o,a){Ei(o,i,t,e,s,r,n,a,0),o.push(r,n)}function Ei(i,t,e,s,r,n,o,a,h){if(h>Vu)return;const l=(t+s)/2,u=(e+r)/2,c=(s+n)/2,d=(r+o)/2,p=(l+c)/2,f=(u+d)/2;let g=n-t,m=o-e;const _=Math.abs((s-n)*m-(r-o)*g);if(_>$u){if(_*_<=a*(g*g+m*m)){i.push(p,f);return}}else if(g=p-(t+n)/2,m=f-(e+o)/2,g*g+m*m<=a){i.push(p,f);return}Ei(i,t,e,l,u,p,f,a,h+1),Ei(i,p,f,c,d,n,o,a,h+1)}function zn(i,t,e,s,r,n,o,a){let h=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(h=2*Math.PI-h),a=a||Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI))),a=Math.max(a,3);let l=h/a,u=r;l*=o?-1:1;for(let c=0;c<a+1;c++){const d=Math.cos(u),p=Math.sin(u),f=t+d*s,g=e+p*s;i.push(f,g),u+=l}}function Ku(i,t,e,s,r,n){const o=i[i.length-2],a=i[i.length-1]-e,h=o-t,l=r-e,u=s-t,c=Math.abs(a*u-h*l);if(c<1e-8||n===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const d=a*a+h*h,p=l*l+u*u,f=a*l+h*u,g=n*Math.sqrt(d)/c,m=n*Math.sqrt(p)/c,_=g*f/d,y=m*f/p,b=g*u+m*h,v=g*l+m*a,T=h*(m+_),A=a*(m+_),E=u*(g+y),P=l*(g+y),S=Math.atan2(A-v,T-b),w=Math.atan2(P-v,E-b);zn(i,b+t,v+e,n,S,w,h*l>u*a)}const Ce=Math.PI*2,Ai={centerX:0,centerY:0,ang1:0,ang2:0},Pi=({x:i,y:t},e,s,r,n,o,a,h)=>{i*=e,t*=s;const l=r*i-n*t,u=n*i+r*t;return h.x=l+o,h.y=u+a,h};function qu(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,r=Math.cos(i),n=Math.sin(i),o=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-n*s,y:n+r*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Wn=(i,t,e,s)=>{const r=i*s-t*e<0?-1:1;let n=i*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Zu=(i,t,e,s,r,n,o,a,h,l,u,c,d)=>{const p=Math.pow(r,2),f=Math.pow(n,2),g=Math.pow(u,2),m=Math.pow(c,2);let _=p*f-p*m-f*g;_<0&&(_=0),_/=p*m+f*g,_=Math.sqrt(_)*(o===a?-1:1);const y=_*r/n*c,b=_*-n/r*u,v=l*y-h*b+(i+e)/2,T=h*y+l*b+(t+s)/2,A=(u-y)/r,E=(c-b)/n,P=(-u-y)/r,S=(-c-b)/n,w=Wn(1,0,A,E);let Y=Wn(A,E,P,S);a===0&&Y>0&&(Y-=Ce),a===1&&Y<0&&(Y+=Ce),d.centerX=v,d.centerY=T,d.ang1=w,d.ang2=Y};function Qu(i,t,e,s,r,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const u=Math.sin(a*Ce/360),c=Math.cos(a*Ce/360),d=c*(t-s)/2+u*(e-r)/2,p=-u*(t-s)/2+c*(e-r)/2;if(d===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),Zu(t,e,s,r,n,o,h,l,u,c,d,p,Ai);let{ang1:g,ang2:m}=Ai;const{centerX:_,centerY:y}=Ai;let b=Math.abs(m)/(Ce/4);Math.abs(1-b)<1e-7&&(b=1);const v=Math.max(Math.ceil(b),1);m/=v;let T=i[i.length-2],A=i[i.length-1];const E={x:0,y:0};for(let P=0;P<v;P++){const S=qu(g,m),{x:w,y:Y}=Pi(S[0],n,o,c,u,_,y,E),{x:it,y:B}=Pi(S[1],n,o,c,u,_,y,E),{x:k,y:K}=Pi(S[2],n,o,c,u,_,y,E);Hn(i,T,A,w,Y,it,B,k,K),T=k,A=K,g+=m}}function Ju(i,t,e){var o;const s=(a,h)=>{const l=h.x-a.x,u=h.y-a.y,c=Math.sqrt(l*l+u*u),d=l/c,p=u/c;return{len:c,nx:d,ny:p}},r=(a,h)=>{a===0?i.moveTo(h.x,h.y):i.lineTo(h.x,h.y)};let n=t[t.length-1];for(let a=0;a<t.length;a++){const h=t[a%t.length],l=(o=h.radius)!=null?o:e;if(l<=0){r(a,h),n=h;continue}const u=t[(a+1)%t.length],c=s(h,n),d=s(h,u);if(c.len<1e-4||d.len<1e-4){r(a,h),n=h;continue}let p=Math.asin(c.nx*d.ny-c.ny*d.nx),f=1,g=!1;c.nx*d.nx-c.ny*-d.ny<0?p<0?p=Math.PI+p:(p=Math.PI-p,f=-1,g=!0):p>0&&(f=-1,g=!0);const m=p/2;let _,y=Math.abs(Math.cos(m)*l/Math.sin(m));y>Math.min(c.len/2,d.len/2)?(y=Math.min(c.len/2,d.len/2),_=Math.abs(y*Math.sin(m)/Math.cos(m))):_=l;const b=h.x+d.nx*y+-d.ny*_*f,v=h.y+d.ny*y+d.nx*_*f,T=Math.atan2(c.ny,c.nx)+Math.PI/2*f,A=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&i.moveTo(b+Math.cos(T)*_,v+Math.sin(T)*_),i.arc(b,v,_,T,A,g),n=h}}function tc(i,t,e,s){var a;const r=(h,l)=>Math.sqrt((h.x-l.x)**2+(h.y-l.y)**2),n=(h,l,u)=>({x:h.x+(l.x-h.x)*u,y:h.y+(l.y-h.y)*u}),o=t.length;for(let h=0;h<o;h++){const l=t[(h+1)%o],u=(a=l.radius)!=null?a:e;if(u<=0){h===0?i.moveTo(l.x,l.y):i.lineTo(l.x,l.y);continue}const c=t[h],d=t[(h+2)%o],p=r(c,l);let f;if(p<1e-4)f=l;else{const _=Math.min(p/2,u);f=n(l,c,_/p)}const g=r(d,l);let m;if(g<1e-4)m=l;else{const _=Math.min(g/2,u);m=n(l,d,_/g)}h===0?i.moveTo(f.x,f.y):i.lineTo(f.x,f.y),i.quadraticCurveTo(l.x,l.y,m.x,m.y,s)}}const ec=new X;class sc{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new nt,this._graphicsPath2D=t}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const s=this._currentPoly.points,r=s[s.length-2],n=s[s.length-1];return(r!==t||n!==e)&&s.push(t,e),this}arc(t,e,s,r,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return zn(a,t,e,s,r,n,o),this}arcTo(t,e,s,r,n){this._ensurePoly();const o=this._currentPoly.points;return Ku(o,t,e,s,r,n),this}arcToSvg(t,e,s,r,n,o,a){const h=this._currentPoly.points;return Qu(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,s,r,n),this}bezierCurveTo(t,e,s,r,n,o,a){this._ensurePoly();const h=this._currentPoly;return Hn(this._currentPoly.points,h.lastX,h.lastY,t,e,s,r,n,o,a),this}quadraticCurveTo(t,e,s,r,n){this._ensurePoly();const o=this._currentPoly;return Yu(this._currentPoly.points,o.lastX,o.lastY,t,e,s,r,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));for(let s=0;s<t.instructions.length;s++){const r=t.instructions[s];this[r.action](...r.data)}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,r,n){return this.drawShape(new X(t,e,s,r),n),this}circle(t,e,s,r){return this.drawShape(new fi(t,e,s),r),this}poly(t,e,s){const r=new Ee(t);return r.closePath=e,this.drawShape(r,s),this}regularPoly(t,e,s,r,n=0,o){r=Math.max(r|0,3);const a=-1*Math.PI/2+n,h=Math.PI*2/r,l=[];for(let u=0;u<r;u++){const c=u*h+a;l.push(t+s*Math.cos(c),e+s*Math.sin(c))}return this.poly(l,!0,o),this}roundPoly(t,e,s,r,n,o=0,a){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(t,e,s,r,o);const h=s*Math.sin(Math.PI/r)-.001;n=Math.min(n,h);const l=-1*Math.PI/2+o,u=Math.PI*2/r,c=(r-2)*Math.PI/r/2;for(let d=0;d<r;d++){const p=d*u+l,f=t+s*Math.cos(p),g=e+s*Math.sin(p),m=p+Math.PI+c,_=p-Math.PI-c,y=f+n*Math.cos(m),b=g+n*Math.sin(m),v=f+n*Math.cos(_),T=g+n*Math.sin(_);d===0?this.moveTo(y,b):this.lineTo(y,b),this.quadraticCurveTo(f,g,v,T,a)}return this.closePath()}roundShape(t,e,s=!1,r){return t.length<3?this:(s?tc(this,t,e,r):Ju(this,t,e),this.closePath())}filletRect(t,e,s,r,n){if(n===0)return this.rect(t,e,s,r);const o=Math.min(s,r)/2,a=Math.min(o,Math.max(-o,n)),h=t+s,l=e+r,u=a<0?-a:0,c=Math.abs(a);return this.moveTo(t,e+c).arcTo(t+u,e+u,t+c,e,c).lineTo(h-c,e).arcTo(h-u,e+u,h,e+c,c).lineTo(h,l-c).arcTo(h-u,l-u,t+s-c,l,c).lineTo(t+c,l).arcTo(t+u,l-u,t,l-c,c).closePath()}chamferRect(t,e,s,r,n,o){if(n<=0)return this.rect(t,e,s,r);const a=Math.min(n,Math.min(s,r)/2),h=t+s,l=e+r,u=[t+a,e,h-a,e,h,e+a,h,l-a,h-a,l,t+a,l,t,l-a,t,e+a];for(let c=u.length-1;c>=2;c-=2)u[c]===u[c-2]&&u[c-1]===u[c-3]&&u.splice(c-1,2);return this.poly(u,!0,o)}ellipse(t,e,s,r,n){return this.drawShape(new mi(t,e,s,r),n),this}roundRect(t,e,s,r,n,o){return this.drawShape(new gi(t,e,s,r,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new Ee,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Ee,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=s;s=n.a*s+n.c*r+n.tx,r=n.b*o+n.d*r+n.ty}this._currentPoly.points.push(s,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const s=t.instructions[e];this[s.action](...s.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let s=0;s<e.length;s++){const r=e[s],n=r.shape.getBounds(ec);r.transform?t.addRect(n,r.transform):t.addRect(n)}return t}}class ne{constructor(t){var e;this.instructions=[],this.uid=Q("graphicsPath"),this._dirty=!0,typeof t=="string"?uu(t,this):this.instructions=(e=t==null?void 0:t.slice())!=null?e:[]}get shapePath(){return this._shapePath||(this._shapePath=new sc(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,s,r,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint($.shared);let h=0,l=0;if(!o||o.action!=="bezierCurveTo")h=a.x,l=a.y;else{h=o.data[2],l=o.data[3];const u=a.x,c=a.y;h=u+(u-h),l=c+(c-l)}return this.instructions.push({action:"bezierCurveTo",data:[h,l,t,e,s,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,s){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint($.shared);let o=0,a=0;if(!r||r.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=r.data[0],a=r.data[1];const h=n.x,l=n.y;o=h+(h-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,s]}),this._dirty=!0,this}rect(t,e,s,r,n){return this.instructions.push({action:"rect",data:[t,e,s,r,n]}),this._dirty=!0,this}circle(t,e,s,r){return this.instructions.push({action:"circle",data:[t,e,s,r]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,s,r,n,o,a){n=n||r/2;const h=-1*Math.PI/2+o,l=s*2,u=Math.PI*2/l,c=[];for(let d=0;d<l;d++){const p=d%2?n:r,f=d*u+h;c.push(t+p*Math.cos(f),e+p*Math.sin(f))}return this.poly(c,!0,a),this}clone(t=!1){const e=new ne;if(!t)e.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const r=this.instructions[s];e.instructions.push({action:r.action,data:r.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,s=t.b,r=t.c,n=t.d,o=t.tx,a=t.ty;let h=0,l=0,u=0,c=0,d=0,p=0,f=0,g=0;for(let m=0;m<this.instructions.length;m++){const _=this.instructions[m],y=_.data;switch(_.action){case"moveTo":case"lineTo":h=y[0],l=y[1],y[0]=e*h+r*l+o,y[1]=s*h+n*l+a;break;case"bezierCurveTo":u=y[0],c=y[1],d=y[2],p=y[3],h=y[4],l=y[5],y[0]=e*u+r*c+o,y[1]=s*u+n*c+a,y[2]=e*d+r*p+o,y[3]=s*d+n*p+a,y[4]=e*h+r*l+o,y[5]=s*h+n*l+a;break;case"quadraticCurveTo":u=y[0],c=y[1],h=y[2],l=y[3],y[0]=e*u+r*c+o,y[1]=s*u+n*c+a,y[2]=e*h+r*l+o,y[3]=s*h+n*l+a;break;case"arcToSvg":h=y[5],l=y[6],f=y[0],g=y[1],y[0]=e*f+r*g,y[1]=s*f+n*g,y[5]=e*h+r*l+o,y[6]=s*h+n*l+a;break;case"circle":y[4]=Me(y[3],t);break;case"rect":y[4]=Me(y[4],t);break;case"ellipse":y[8]=Me(y[8],t);break;case"roundRect":y[5]=Me(y[5],t);break;case"addPath":y[0].transform(t);break;case"poly":y[2]=Me(y[2],t);break;default:U("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,s=this.instructions[e];if(!s)return t.x=0,t.y=0,t;for(;s.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;s=this.instructions[e]}switch(s.action){case"moveTo":case"lineTo":t.x=s.data[0],t.y=s.data[1];break;case"quadraticCurveTo":t.x=s.data[2],t.y=s.data[3];break;case"bezierCurveTo":t.x=s.data[4],t.y=s.data[5];break;case"arc":case"arcToSvg":t.x=s.data[5],t.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(t);break}return t}}function Me(i,t){return i?i.prepend(t):t.clone()}function ic(i,t){if(typeof i=="string"){const s=document.createElement("div");s.innerHTML=i.trim(),i=s.querySelector("svg")}const e={context:t,path:new ne};return Vn(i,e,null,null),t}function Vn(i,t,e,s){const r=i.children,{fillStyle:n,strokeStyle:o}=rc(i);n&&e?e={...e,...n}:n&&(e=n),o&&s?s={...s,...o}:o&&(s=o),t.context.fillStyle=e,t.context.strokeStyle=s;let a,h,l,u,c,d,p,f,g,m,_,y,b,v,T,A,E;switch(i.nodeName.toLowerCase()){case"path":v=i.getAttribute("d"),T=new ne(v),t.context.path(T),e&&t.context.fill(),s&&t.context.stroke();break;case"circle":p=st(i,"cx",0),f=st(i,"cy",0),g=st(i,"r",0),t.context.ellipse(p,f,g,g),e&&t.context.fill(),s&&t.context.stroke();break;case"rect":a=st(i,"x",0),h=st(i,"y",0),A=st(i,"width",0),E=st(i,"height",0),m=st(i,"rx",0),_=st(i,"ry",0),m||_?t.context.roundRect(a,h,A,E,m||_):t.context.rect(a,h,A,E),e&&t.context.fill(),s&&t.context.stroke();break;case"ellipse":p=st(i,"cx",0),f=st(i,"cy",0),m=st(i,"rx",0),_=st(i,"ry",0),t.context.beginPath(),t.context.ellipse(p,f,m,_),e&&t.context.fill(),s&&t.context.stroke();break;case"line":l=st(i,"x1",0),u=st(i,"y1",0),c=st(i,"x2",0),d=st(i,"y2",0),t.context.beginPath(),t.context.moveTo(l,u),t.context.lineTo(c,d),s&&t.context.stroke();break;case"polygon":b=i.getAttribute("points"),y=b.match(/\d+/g).map(P=>parseInt(P,10)),t.context.poly(y,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=i.getAttribute("points"),y=b.match(/\d+/g).map(P=>parseInt(P,10)),t.context.poly(y,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}for(let P=0;P<r.length;P++)Vn(r[P],t,e,s)}function st(i,t,e){const s=i.getAttribute(t);return s?Number(s):e}function rc(i){const t=i.getAttribute("style"),e={},s={};let r=!1,n=!1;if(t){const o=t.split(";");for(let a=0;a<o.length;a++){const h=o[a],[l,u]=h.split(":");switch(l){case"stroke":u!=="none"&&(e.color=V.shared.setValue(u).toNumber(),n=!0);break;case"stroke-width":e.width=Number(u);break;case"fill":u!=="none"&&(r=!0,s.color=V.shared.setValue(u).toNumber());break;case"fill-opacity":s.alpha=Number(u);break;case"stroke-opacity":e.alpha=Number(u);break;case"opacity":s.alpha=Number(u),e.alpha=Number(u);break}}}else{const o=i.getAttribute("stroke");o&&o!=="none"&&(n=!0,e.color=V.shared.setValue(o).toNumber(),e.width=st(i,"stroke-width",1));const a=i.getAttribute("fill");a&&a!=="none"&&(r=!0,s.color=V.shared.setValue(a).toNumber())}return{strokeStyle:n?e:null,fillStyle:r?s:null}}function nc(i){return V.isColorLike(i)}function $n(i){return i instanceof as}function Xn(i){return i instanceof we}function oc(i,t,e){const s=V.shared.setValue(t!=null?t:0);return i.color=s.toNumber(),i.alpha=s.alpha===1?e.alpha:s.alpha,i.texture=C.WHITE,{...e,...i}}function Yn(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function jn(i,t,e){return t.buildLinearGradient(),i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function ac(i,t){var r;const e={...t,...i};if(e.texture){if(e.texture!==C.WHITE){const o=((r=e.matrix)==null?void 0:r.invert())||new R;o.translate(e.texture.frame.x,e.texture.frame.y),o.scale(1/e.texture.source.width,1/e.texture.source.height),e.matrix=o}const n=e.texture.source.style;n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update())}const s=V.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e.matrix=e.matrix?e.matrix.clone():null,e}function zt(i,t){if(i==null)return null;const e={},s=i;return nc(i)?oc(e,i,t):$n(i)?Yn(e,i,t):Xn(i)?jn(e,i,t):s.fill&&$n(s.fill)?Yn(s,s.fill,t):s.fill&&Xn(s.fill)?jn(s,s.fill,t):ac(s,t)}function ps(i,t){const{width:e,alignment:s,miterLimit:r,cap:n,join:o,...a}=t,h=zt(i,a);return h?{width:e,alignment:s,miterLimit:r,cap:n,join:o,...h}:null}const hc=new $,Kn=new R,Ci=class wt extends dt{constructor(){super(...arguments),this.uid=Q("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new ne,this._transform=new R,this._fillStyle={...wt.defaultFillStyle},this._strokeStyle={...wt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new nt,this._boundsDirty=!0}clone(){const t=new wt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=zt(t,wt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=ps(t,wt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=zt(t,wt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=zt(t,wt.defaultStrokeStyle),this}texture(t,e,s,r,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:r||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?V.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ne,this}fill(t,e){let s;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r&&r.action==="stroke"?s=r.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(D(H,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=zt(t,wt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint($.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s&&s.action==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=ps(t,wt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,r,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,s,r,n,o),this}arcTo(t,e,s,r,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,n),this}arcToSvg(t,e,s,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,s,r,n,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,s,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*s+h.c*r+h.tx,h.b*s+h.d*r+h.ty,h.a*n+h.c*o+h.tx,h.b*n+h.d*o+h.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,r){return this._tick++,this._activePath.ellipse(t,e,s,r,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,r=this._activePath.instructions,n=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,s,r,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,n),this}rect(t,e,s,r){return this._tick++,this._activePath.rect(t,e,s,r,this._transform.clone()),this}roundRect(t,e,s,r,n){return this._tick++,this._activePath.roundRect(t,e,s,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,r,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,r,n,o),this}roundPoly(t,e,s,r,n,o){return this._tick++,this._activePath.roundPoly(t,e,s,r,n,o),this}roundShape(t,e,s,r){return this._tick++,this._activePath.roundShape(t,e,s,r),this}filletRect(t,e,s,r,n){return this._tick++,this._activePath.filletRect(t,e,s,r,n),this}chamferRect(t,e,s,r,n,o){return this._tick++,this._activePath.chamferRect(t,e,s,r,n,o),this}star(t,e,s,r,n=0,o=0){return this._tick++,this._activePath.star(t,e,s,r,n,o,this._transform.clone()),this}svg(t){return this._tick++,ic(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,s,r,n,o){return t instanceof R?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,r,n,o),this)}transform(t,e,s,r,n,o){return t instanceof R?(this._transform.append(t),this):(Kn.set(t,e,s,r,n,o),this._transform.append(Kn),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const s=this.instructions[e],r=s.action;if(r==="fill"){const n=s.data;t.addBounds(n.path.bounds)}else if(r==="texture"){const n=s.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=s.data,o=n.style.width/2,a=n.path.bounds;t.addFrame(a.minX-o,a.minY-o,a.maxX+o,a.maxY+o)}}return t}containsPoint(t){var r;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let s=!1;for(let n=0;n<e.length;n++){const o=e[n],a=o.data,h=a.path;if(!o.action||!h)continue;const l=a.style,u=h.shapePath.shapePrimitives;for(let c=0;c<u.length;c++){const d=u[c].shape;if(!l||!d)continue;const p=u[c].transform,f=p?p.applyInverse(t,hc):t;o.action==="fill"?s=d.contains(f.x,f.y):s=d.strokeContains(f.x,f.y,l.width);const g=a.hole;if(g){const m=(r=g.shapePath)==null?void 0:r.shapePrimitives;if(m)for(let _=0;_<m.length;_++)m[_].shape.contains(f.x,f.y)&&(s=!1)}if(s)return!0}}return s}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(e),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(e)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Ci.defaultFillStyle={color:16777215,alpha:1,texture:C.WHITE,matrix:null,fill:null},Ci.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:C.WHITE,matrix:null,fill:null};let mt=Ci;const qn=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function Zn(i){const t=[];let e=0;for(let s=0;s<qn.length;s++){const r=`_${qn[s]}`;t[e++]=i[r]}return e=Qn(i._fill,t,e),e=lc(i._stroke,t,e),e=uc(i.dropShadow,t,e),t.join("-")}function Qn(i,t,e){var s;return i&&(t[e++]=i.color,t[e++]=i.alpha,t[e++]=(s=i.fill)==null?void 0:s.styleKey),e}function lc(i,t,e){return i&&(e=Qn(i,t,e),t[e++]=i.width,t[e++]=i.alignment,t[e++]=i.cap,t[e++]=i.join,t[e++]=i.miterLimit),e}function uc(i,t,e){return i&&(t[e++]=i.alpha,t[e++]=i.angle,t[e++]=i.blur,t[e++]=i.distance,t[e++]=V.shared.setValue(i.color).toNumber()),e}const Mi=class fe extends dt{constructor(t={}){super(),cc(t);const e={...fe.defaultTextStyle,...t};for(const s in e){const r=s;this[r]=e[s]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...fe.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...fe.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...mt.defaultFillStyle,...t},()=>{this._fill=zt({...this._originalFill},mt.defaultFillStyle)})),this._fill=zt(t===0?"black":t,mt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...mt.defaultStrokeStyle,...t},()=>{this._stroke=ps({...this._originalStroke},mt.defaultStrokeStyle)})),this._stroke=ps(t,mt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Zn(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=fe.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new fe({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 e,s,r,n;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;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(o),(r=this._stroke)!=null&&r.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,r,n)=>(s[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(V.isColorLike(t)||t instanceof we||t instanceof as)}};Mi.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},Mi.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 Mt=Mi;function cc(i){var e,s,r,n,o;const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const a=Mt.defaultDropShadow;i.dropShadow={alpha:(e=t.dropShadowAlpha)!=null?e:a.alpha,angle:(s=t.dropShadowAngle)!=null?s:a.angle,blur:(r=t.dropShadowBlur)!=null?r:a.blur,color:(n=t.dropShadowColor)!=null?n:a.color,distance:(o=t.dropShadowDistance)!=null?o:a.distance}}if(t.strokeThickness!==void 0){D(H,"strokeThickness is now a part of stroke");const a=t.stroke;let h={};if(V.isColorLike(a))h.color=a;else if(a instanceof we||a instanceof as)h.fill=a;else if(Object.hasOwnProperty.call(a,"color")||Object.hasOwnProperty.call(a,"fill"))h=a;else throw new Error("Invalid stroke value.");i.stroke={...h,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){D(H,"gradient fill is now a fill pattern: `new FillGradient(...)`");let a;i.fontSize==null?i.fontSize=Mt.defaultTextStyle.fontSize:typeof i.fontSize=="string"?a=parseInt(i.fontSize,10):a=i.fontSize;const h=new we(0,0,0,a*1.7),l=t.fillGradientStops.map(u=>V.shared.setValue(u).toNumber());l.forEach((u,c)=>{const d=c/(l.length-1);h.addColorStop(d,u)}),i.fill={fill:h}}}class dc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=N.get().createCanvas();s.width=t,s.height=e;const r=s.getContext("2d");return{canvas:s,context:r}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=qt(t),e=qt(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:r}=e,n=(s<<17)+(r<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Rt=new dc,pc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function fs(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let r=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!pc.includes(r)&&(r=`"${r}"`),e[s]=r}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const Ri={willReadFrequently:!0},vt=class M{static get experimentalLetterSpacingSupported(){let t=M._experimentalLetterSpacingSupported;if(t!==void 0){const e=N.get().getCanvasRenderingContext2D().prototype;t=M._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,r,n,o,a,h,l){this.text=t,this.style=e,this.width=s,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,s=M._canvas,r=e.wordWrap){var m;const n=`${t}:${e.styleKey}`;if(M._measurementCache[n])return M._measurementCache[n];const o=fs(e),a=M.measureFont(o);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const h=M.__context;h.font=o;const l=(r?M._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),u=new Array(l.length);let c=0;for(let _=0;_<l.length;_++){const y=M._measureText(l[_],e.letterSpacing,h);u[_]=y,c=Math.max(c,y)}const d=((m=e._stroke)==null?void 0:m.width)||0;let p=c+d;e.dropShadow&&(p+=e.dropShadow.distance);const f=e.lineHeight||a.fontSize;let g=Math.max(f,a.fontSize+d)+(l.length-1)*(f+e.leading);return e.dropShadow&&(g+=e.dropShadow.distance),new M(t,e,p,g,l,u,f+e.leading,c,a)}static _measureText(t,e,s){let r=!1;M.experimentalLetterSpacingSupported&&(M.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,r=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));let n=s.measureText(t).width;return n>0&&(r?n-=e:n+=(M.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,s=M._canvas){const r=s.getContext("2d",Ri);let n=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:u}=e,c=M._collapseSpaces(u),d=M._collapseNewlines(u);let p=!c;const f=e.wordWrapWidth+l,g=M._tokenize(t);for(let m=0;m<g.length;m++){let _=g[m];if(M._isNewline(_)){if(!d){a+=M._addLine(o),p=!c,o="",n=0;continue}_=" "}if(c){const b=M.isBreakingSpace(_),v=M.isBreakingSpace(o[o.length-1]);if(b&&v)continue}const y=M._getFromCache(_,l,h,r);if(y>f)if(o!==""&&(a+=M._addLine(o),o="",n=0),M.canBreakWords(_,e.breakWords)){const b=M.wordWrapSplit(_);for(let v=0;v<b.length;v++){let T=b[v],A=T,E=1;for(;b[v+E];){const S=b[v+E];if(!M.canBreakChars(A,S,_,v,e.breakWords))T+=S;else break;A=S,E++}v+=E-1;const P=M._getFromCache(T,l,h,r);P+n>f&&(a+=M._addLine(o),p=!1,o="",n=0),o+=T,n+=P}}else{o.length>0&&(a+=M._addLine(o),o="",n=0);const b=m===g.length-1;a+=M._addLine(_,!b),p=!1,o="",n=0}else y+n>f&&(p=!1,a+=M._addLine(o),o="",n=0),(o.length>0||!M.isBreakingSpace(_)||p)&&(o+=_,n+=y)}return a+=M._addLine(o,!1),a}static _addLine(t,e=!0){return t=M._trimRight(t),t=e?`${t}
`:t,t}static _getFromCache(t,e,s,r){let n=s[t];return typeof n!="number"&&(n=M._measureText(t,e,r)+e,s[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!M.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:M._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:M._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],o=t[r+1];if(M.isBreakingSpace(n,o)||M._isNewline(n)){s!==""&&(e.push(s),s=""),e.push(n);continue}s+=n}return s!==""&&e.push(s),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,r,n){return!0}static wordWrapSplit(t){return M.graphemeSegmenter(t)}static measureFont(t){if(M._fonts[t])return M._fonts[t];const e=M._context;e.font=t;const s=e.measureText(M.METRICS_STRING+M.BASELINE_SYMBOL),r={ascent:s.actualBoundingBoxAscent,descent:s.actualBoundingBoxDescent,fontSize:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent};return M._fonts[t]=r,r}static clearMetrics(t=""){t?delete M._fonts[t]:M._fonts={}}static get _canvas(){var t;if(!M.__canvas){let e;try{const s=new OffscreenCanvas(0,0);if((t=s.getContext("2d",Ri))!=null&&t.measureText)return M.__canvas=s,s;e=N.get().createCanvas()}catch{e=N.get().createCanvas()}e.width=e.height=10,M.__canvas=e}return M.__canvas}static get _context(){return M.__context||(M.__context=M._canvas.getContext("2d",Ri)),M.__context}};vt.METRICS_STRING="|\xC9q\xC5",vt.BASELINE_SYMBOL="M",vt.BASELINE_MULTIPLIER=1.4,vt.HEIGHT_MULTIPLIER=2,vt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})(),vt.experimentalLetterSpacing=!1,vt._fonts={},vt._newlines=[10,13],vt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],vt._measurementCache={};let St=vt;function ms(i,t){var e;if(i.texture===C.WHITE&&!i.fill)return V.shared.setValue(i.color).setAlpha((e=i.alpha)!=null?e:1).toHexa();if(i.fill){if(i.fill instanceof as){const s=i.fill,r=t.createPattern(s.texture.source.resource,"repeat"),n=s.transform.copyTo(R.shared);return n.scale(s.texture.frame.width,s.texture.frame.height),r.setTransform(n),r}else if(i.fill instanceof we){const s=i.fill;if(s.type==="linear"){const r=t.createLinearGradient(s.x0,s.y0,s.x1,s.y1);return s.gradientStops.forEach(n=>{r.addColorStop(n.offset,V.shared.setValue(n.color).toHex())}),r}}}else{const s=t.createPattern(i.texture.source.resource,"repeat"),r=i.matrix.copyTo(R.shared);return r.scale(i.texture.frame.width,i.texture.frame.height),s.setTransform(r),s}return U("FillStyle not recognised",i),"red"}function Jn(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e<s;e++){const r=i[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=r[0].charCodeAt(0),o=r[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,h=o;a<=h;a++)t.push(String.fromCharCode(a))}else t.push(...Array.from(r))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const to=class Dh extends wn{constructor(t){var o,a,h;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={...Dh.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;const s=e.style.clone();e.overrideFill&&(s._fill.color=16777215,s._fill.alpha=1,s._fill.texture=C.WHITE,s._fill.fill=null),this.applyFillAsTint=e.overrideFill;const r=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const n=fs(s);e.overrideSize?s._stroke&&(s._stroke.width*=this.baseRenderedFontSize/r):s.fontSize=this.baseRenderedFontSize=r,this._style=s,this._skipKerning=(o=e.skipKerning)!=null?o:!1,this.resolution=(a=e.resolution)!=null?a:1,this._padding=(h=e.padding)!=null?h:4,this.fontMetrics=St.measureFont(n),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(t){var g,m,_,y;const e=Jn(t).filter(b=>!this._currentChars.includes(b)).filter((b,v,T)=>T.indexOf(b)===v);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:r,context:n}=s.canvasAndContext,o=s.texture.source;const a=this._style;let h=this._currentX,l=this._currentY;const u=this.baseRenderedFontSize/this.baseMeasurementFontSize,c=this._padding*u,d=a.fontStyle==="italic"?2:1;let p=0,f=!1;for(let b=0;b<e.length;b++){const v=e[b],T=St.measureText(v,a,r,!1);T.lineHeight=T.height;const A=d*T.width*u,E=T.height*u,P=A+c*2,S=E+c*2;if(f=!1,v!==`
`&&v!=="\r"&&v!=="	"&&v!==" "&&(f=!0,p=Math.ceil(Math.max(S,p))),h+P>this._textureSize&&(l+=p,p=S,h=0,l+p>this._textureSize)){o.update();const Y=this._nextPage();r=Y.canvasAndContext.canvas,n=Y.canvasAndContext.context,o=Y.texture.source,l=0}const w=A/u-((m=(g=a.dropShadow)==null?void 0:g.distance)!=null?m:0)-((y=(_=a._stroke)==null?void 0:_.width)!=null?y:0);if(this.chars[v]={id:v.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:w,kerning:{}},f){this._drawGlyph(n,T,h+c,l+c,u,a);const Y=o.width*u,it=o.height*u,B=new X(h/Y*o.width,l/it*o.height,P/Y*o.width,S/it*o.height);this.chars[v].texture=new C({source:o,frame:B}),h+=Math.ceil(P)}}o.update(),this._currentX=h,this._currentY=l,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return D(H,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const s=this._measureCache;for(let r=0;r<t.length;r++){const n=t[r];for(let o=0;o<this._currentChars.length;o++){const a=this._currentChars[o];let h=s[n];h||(h=s[n]=e.measureText(n).width);let l=s[a];l||(l=s[a]=e.measureText(a).width);let u=e.measureText(n+a).width,c=u-(h+l);c&&(this.chars[n].kerning[a]=c),u=e.measureText(n+a).width,c=u-(h+l),c&&(this.chars[a].kerning[n]=c)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Rt.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const s=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r=new C({source:new Jt({resource:e.canvas,resolution:s,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})}),n={canvasAndContext:e,texture:r};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,s){var o;e.fontSize=this.baseRenderedFontSize,t.scale(s,s),t.font=fs(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const r=e._stroke,n=(o=r==null?void 0:r.width)!=null?o:0;if(r&&(t.lineWidth=n,t.lineJoin=r.join,t.miterLimit=r.miterLimit,t.strokeStyle=ms(r,t)),e._fill&&(t.fillStyle=ms(e._fill,t)),e.dropShadow){const a=e.dropShadow,h=V.shared.setValue(a.color).toArray(),l=a.blur*s,u=a.distance*s;t.shadowColor=`rgba(${h[0]*255},${h[1]*255},${h[2]*255},${a.alpha})`,t.shadowBlur=l,t.shadowOffsetX=Math.cos(a.angle)*u,t.shadowOffsetY=Math.sin(a.angle)*u}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,s,r,n,o){var f,g;const a=e.text,h=e.fontProperties,l=((g=(f=o._stroke)==null?void 0:f.width)!=null?g:0)*n,u=s+l/2,c=r-l/2,d=h.descent*n,p=e.lineHeight*n;o.stroke&&l&&t.strokeText(a,u,c+p-d),o._fill&&t.fillText(a,u,c+p-d)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:s}=this.pages[t];e.canvas.width=e.canvas.width,Rt.returnCanvasAndContext(e),s.destroy(!0)}this.pages=null}};to.defaultOptions={textureSize:512,style:new Mt,mipmap:!0};let eo=to;function so(i,t,e){const s={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};s.offsetY=e.baseLineOffset;let r=s.lines[0],n=null,o=!0;const a={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=p=>{const f=r.width;for(let g=0;g<a.index;g++){const m=p.positions[g];r.chars.push(p.chars[g]),r.charPositions.push(m+f)}r.width+=p.width,o=!1,a.width=0,a.index=0,a.chars.length=0},l=()=>{let p=r.chars.length-1,f=r.chars[p];for(;f===" ";)r.width-=e.chars[f].xAdvance,f=r.chars[--p];s.width=Math.max(s.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,s.lines.push(r),s.height+=e.lineHeight},u=e.baseMeasurementFontSize/t.fontSize,c=t.letterSpacing*u,d=t.wordWrapWidth*u;for(let p=0;p<i.length+1;p++){let f;const g=p===i.length;g||(f=i[p]);const m=e.chars[f]||e.chars[" "];if(/(?:\s)/.test(f)||f==="\r"||f===`
`||g){if(!o&&t.wordWrap&&r.width+a.width-c>d?(l(),h(a),g||r.charPositions.push(0)):(a.start=r.width,h(a),g||r.charPositions.push(0)),f==="\r"||f===`
`)r.width!==0&&l();else if(!g){const _=m.xAdvance+(m.kerning[n]||0)+c;r.width+=_,r.spaceWidth=_,r.spacesIndex.push(r.charPositions.length),r.chars.push(f)}}else{const _=m.kerning[n]||0,y=m.xAdvance+_+c;a.positions[a.index++]=a.width+_,a.chars.push(f),a.width+=y}n=f}return l(),t.align==="center"?fc(s):t.align==="right"?mc(s):t.align==="justify"&&gc(s),s}function fc(i){for(let t=0;t<i.lines.length;t++){const e=i.lines[t],s=i.width/2-e.width/2;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=s}}function mc(i){for(let t=0;t<i.lines.length;t++){const e=i.lines[t],s=i.width-e.width;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=s}}function gc(i){const t=i.width;for(let e=0;e<i.lines.length;e++){const s=i.lines[e];let r=0,n=s.spacesIndex[r++],o=0;const a=s.spacesIndex.length,h=(t-s.width)/a;for(let l=0;l<s.charPositions.length;l++)l===n&&(n=s.spacesIndex[r++],o+=h),s.charPositions[l]+=o}}let gs=0;class _c{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(t,e){var o;let s=`${e.fontFamily}-bitmap`,r=!0;if(e._fill.fill&&!e._stroke)s+=e._fill.fill.styleKey,r=!1;else if(e._stroke||e.dropShadow){let a=e.styleKey;a=a.substring(0,a.lastIndexOf("-")),s=`${a}-bitmap`,r=!1}if(!j.has(s)){const a=new eo({style:e,overrideFill:r,overrideSize:!0,...this.defaultOptions});gs++,gs>50&&U("BitmapText",`You have dynamically created ${gs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{gs--,j.remove(s)}),j.set(s,a)}const n=j.get(s);return(o=n.ensureCharacters)==null||o.call(n,t),n}getLayout(t,e){const s=this.getFont(t,e);return so([...t],e,s)}measureText(t,e){return this.getLayout(t,e)}install(...t){var l,u,c,d;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(l=t[2])==null?void 0:l.chars,resolution:(u=t[2])==null?void 0:u.resolution,padding:(c=t[2])==null?void 0:c.padding,skipKerning:(d=t[2])==null?void 0:d.skipKerning},D(H,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=e==null?void 0:e.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof Mt?r:new Mt(r),o=n._fill.fill!==null&&n._fill.fill!==void 0,a=new eo({style:n,overrideFill:o,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=Jn(e.chars);return a.ensureCharacters(h.join("")),j.set(`${s}-bitmap`,a),a.once("destroy",()=>j.remove(`${s}-bitmap`)),a}uninstall(t){const e=`${t}-bitmap`,s=j.get(e);s&&(j.remove(e),s.destroy())}}const Bi=new _c;class io extends wn{constructor(t,e){var n;super();const{textures:s,data:r}=t;Object.keys(r.pages).forEach(o=>{const a=r.pages[parseInt(o,10)],h=s[a.id];this.pages.push({texture:h})}),Object.keys(r.chars).forEach(o=>{var d;const a=r.chars[o],{frame:h,source:l}=s[a.page],u=new X(a.x+h.x,a.y+h.y,a.width,a.height),c=new C({source:l,frame:u});this.chars[o]={id:o.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:(d=a.kerning)!=null?d:{},texture:c}}),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=(n=r.distanceField)!=null?n:{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){Bi.install(t)}static uninstall(t){Bi.uninstall(t)}}const ki={test(i){return typeof i=="string"&&i.startsWith("info face=")},parse(i){var c,d,p;const t=i.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const f in t){const g=t[f].match(/^[a-z]+/gm)[0],m=t[f].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),_={};for(const y in m){const b=m[y].split("="),v=b[0],T=b[1].replace(/"/gm,""),A=parseFloat(T),E=isNaN(A)?T:A;_[v]=E}e[g].push(_)}const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=e.info,[n]=e.common,[o]=(c=e.distanceField)!=null?c:[];o&&(s.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),s.fontSize=parseInt(r.size,10),s.fontFamily=r.face,s.lineHeight=parseInt(n.lineHeight,10);const a=e.page;for(let f=0;f<a.length;f++)s.pages.push({id:parseInt(a[f].id,10)||0,file:a[f].file});const h={};s.baseLineOffset=s.lineHeight-parseInt(n.base,10);const l=e.char;for(let f=0;f<l.length;f++){const g=l[f],m=parseInt(g.id,10);let _=(p=(d=g.letter)!=null?d:g.char)!=null?p:String.fromCharCode(m);_==="space"&&(_=" "),h[m]=_,s.chars[_]={id:m,page:parseInt(g.page,10)||0,x:parseInt(g.x,10),y:parseInt(g.y,10),width:parseInt(g.width,10),height:parseInt(g.height,10),xOffset:parseInt(g.xoffset,10),yOffset:parseInt(g.yoffset,10),xAdvance:parseInt(g.xadvance,10),kerning:{}}}const u=e.kerning||[];for(let f=0;f<u.length;f++){const g=parseInt(u[f].first,10),m=parseInt(u[f].second,10),_=parseInt(u[f].amount,10);s.chars[h[m]].kerning[h[g]]=_}return s}},ro={test(i){const t=i;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(i){var l,u;const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=i.getElementsByTagName("info")[0],s=i.getElementsByTagName("common")[0],r=i.getElementsByTagName("distanceField")[0];r&&(t.distanceField={type:r.getAttribute("fieldType"),range:parseInt(r.getAttribute("distanceRange"),10)});const n=i.getElementsByTagName("page"),o=i.getElementsByTagName("char"),a=i.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let c=0;c<n.length;c++)t.pages.push({id:parseInt(n[c].getAttribute("id"),10)||0,file:n[c].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(s.getAttribute("base"),10);for(let c=0;c<o.length;c++){const d=o[c],p=parseInt(d.getAttribute("id"),10);let f=(u=(l=d.getAttribute("letter"))!=null?l:d.getAttribute("char"))!=null?u:String.fromCharCode(p);f==="space"&&(f=" "),h[p]=f,t.chars[f]={id:p,page:parseInt(d.getAttribute("page"),10)||0,x:parseInt(d.getAttribute("x"),10),y:parseInt(d.getAttribute("y"),10),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10),xOffset:parseInt(d.getAttribute("xoffset"),10),yOffset:parseInt(d.getAttribute("yoffset"),10),xAdvance:parseInt(d.getAttribute("xadvance"),10),kerning:{}}}for(let c=0;c<a.length;c++){const d=parseInt(a[c].getAttribute("first"),10),p=parseInt(a[c].getAttribute("second"),10),f=parseInt(a[c].getAttribute("amount"),10);t.chars[h[p]].kerning[h[d]]=f}return t}},no={test(i){return typeof i=="string"&&i.includes("<font>")?ro.test(N.get().parseXML(i)):!1},parse(i){return ro.parse(N.get().parseXML(i))}},xc=[".xml",".fnt"],yc={extension:{type:x.CacheParser,name:"cacheBitmapFont"},test:i=>i instanceof io,getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},bc={extension:{type:x.LoadParser,priority:Bt.Normal},name:"loadBitmapFont",test(i){return xc.includes(lt.extname(i).toLowerCase())},async testParse(i){return ki.test(i)||no.test(i)},async parse(i,t,e){const s=ki.test(i)?ki.parse(i):no.parse(i),{src:r}=t,{pages:n}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;u<n.length;++u){const c=n[u].file;let d=lt.join(lt.dirname(r),c);d=Qs(d,r),o.push({src:d,data:a})}const h=await e.load(o),l=o.map(u=>h[u.src]);return new io({data:s,textures:l},r)},async load(i,t){return await(await N.get().fetch(i)).text()},async unload(i,t,e){await Promise.all(i.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),i.destroy()}};class vc{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;s<e;s++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Tc={extension:{type:x.CacheParser,name:"cacheTextureArray"},test:i=>Array.isArray(i)&&i.every(t=>t instanceof C),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((r,n)=>{e[s+(n===0?"":n+1)]=r})}),e}};async function oo(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Sc={extension:{type:x.DetectionParser,priority:1},test:async()=>oo("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},ao=["png","jpg","jpeg"],wc={extension:{type:x.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...ao],remove:async i=>i.filter(t=>!ao.includes(t))},Ec="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ii(i){return Ec?!1:document.createElement("video").canPlayType(i)!==""}const Ac={extension:{type:x.DetectionParser,priority:0},test:async()=>Ii("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},Pc={extension:{type:x.DetectionParser,priority:0},test:async()=>Ii("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},Cc={extension:{type:x.DetectionParser,priority:0},test:async()=>Ii("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Mc={extension:{type:x.DetectionParser,priority:0},test:async()=>oo("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};class Rc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var o,a;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||U(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((o=l.test)==null?void 0:o.call(l,t,e,this))){n=l;break}}if(!n)return U(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await n.load(t,e,this),s.parser=n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((a=l.testParse)==null?void 0:a.call(l,r,e,this))&&(r=await l.parse(r,e,this)||r,s.parser=l)}return r})(),s}async load(t,e){this._parsersValidated||this._validateParsers();let s=0;const r={},n=is(t),o=_t(t,l=>({alias:[l],src:l,data:{}})),a=o.length,h=o.map(async l=>{const u=lt.toAbsolute(l.src);if(!r[l.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,l)),r[l.src]=await this.promiseCache[u].promise,e&&e(++s/a)}catch(c){throw delete this.promiseCache[u],delete r[l.src],new Error(`[Loader.load] Failed to load ${u}.
${c}`)}});return await Promise.all(h),n?r[o[0].src]:r}async unload(t){const e=_t(t,s=>({alias:[s],src:s})).map(async s=>{var o,a;const r=lt.toAbsolute(s.src),n=this.promiseCache[r];if(n){const h=await n.promise;delete this.promiseCache[r],await((a=(o=n.parser)==null?void 0:o.unload)==null?void 0:a.call(o,h,s,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&U(`[Assets] loadParser name conflict "${e.name}"`):U("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function oe(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function ae(i,t){const e=i.split("?")[0],s=lt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const Bc=".json",kc="application/json",Ic={extension:{type:x.LoadParser,priority:Bt.Low},name:"loadJson",test(i){return oe(i,kc)||ae(i,Bc)},async load(i){return await(await N.get().fetch(i)).json()}},Gc=".txt",Uc="text/plain",Fc={name:"loadTxt",extension:{type:x.LoadParser,priority:Bt.Low,name:"loadTxt"},test(i){return oe(i,Uc)||ae(i,Gc)},async load(i){return await(await N.get().fetch(i)).text()}},Oc=["normal","bold","100","200","300","400","500","600","700","800","900"],Dc=[".ttf",".otf",".woff",".woff2"],Lc=["font/ttf","font/otf","font/woff","font/woff2"],Nc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Hc(i){const t=lt.extname(i),e=lt.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let s=e.length>0;for(const n of e)if(!n.match(Nc)){s=!1;break}let r=e.join(" ");return s||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}const zc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Wc(i){return zc.test(i)?i:encodeURI(i)}const Vc={extension:{type:x.LoadParser,priority:Bt.Low},name:"loadWebFont",test(i){return oe(i,Lc)||ae(i,Dc)},async load(i,t){var s,r,n,o,a,h;const e=N.get().getFontFaceSet();if(e){const l=[],u=(r=(s=t.data)==null?void 0:s.family)!=null?r:Hc(i),c=(a=(o=(n=t.data)==null?void 0:n.weights)==null?void 0:o.filter(p=>Oc.includes(p)))!=null?a:["normal"],d=(h=t.data)!=null?h:{};for(let p=0;p<c.length;p++){const f=c[p],g=new FontFace(u,`url(${Wc(i)})`,{...d,weight:f});await g.load(),e.add(g),l.push(g)}return j.set(`${u}-and-url`,{url:i,fontFaces:l}),l.length===1?l[0]:l}return U("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(i){(Array.isArray(i)?i:[i]).forEach(t=>{j.remove(t.family),N.get().getFontFaceSet().delete(t)})}};function Gi(i,t=1){var s;const e=(s=ee.RETINA_PREFIX)==null?void 0:s.exec(i);return e?parseFloat(e[1]):t}function Ui(i,t,e){i.label=e,i._sourceOrigin=e;const s=new C({source:i,label:e}),r=()=>{delete t.promiseCache[e],j.has(e)&&j.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(U("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),s.once("destroy",()=>{i.destroyed||(U("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),s}const $c=".svg",Xc="image/svg+xml",Yc={extension:{type:x.LoadParser,priority:Bt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return oe(i,Xc)||ae(i,$c)},async load(i,t,e){var s;return((s=t.data.parseAsGraphicsContext)!=null?s:this.config.parseAsGraphicsContext)?Kc(i):jc(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function jc(i,t,e,s){var g,m,_,y,b;const r=await(await N.get().fetch(i)).blob(),n=URL.createObjectURL(r),o=new Image;o.src=n,o.crossOrigin=s,await o.decode(),URL.revokeObjectURL(n);const a=document.createElement("canvas"),h=a.getContext("2d"),l=((g=t.data)==null?void 0:g.resolution)||Gi(i),u=(_=(m=t.data)==null?void 0:m.width)!=null?_:o.width,c=(b=(y=t.data)==null?void 0:y.height)!=null?b:o.height;a.width=u*l,a.height=c*l,h.drawImage(o,0,0,u*l,c*l);const{parseAsGraphicsContext:d,...p}=t.data,f=new Jt({resource:a,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return Ui(f,e,i)}async function Kc(i){const t=await(await N.get().fetch(i)).text(),e=new mt;return e.svg(t),e}const qc=`(function () {
    'use strict';

    const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
    async function checkImageBitmap() {
      try {
        if (typeof createImageBitmap !== "function")
          return false;
        const response = await fetch(WHITE_PNG);
        const imageBlob = await response.blob();
        const imageBitmap = await createImageBitmap(imageBlob);
        return imageBitmap.width === 1 && imageBitmap.height === 1;
      } catch (e) {
        return false;
      }
    }
    void checkImageBitmap().then((result) => {
      self.postMessage(result);
    });

})();
`;let he=null;class Fi{constructor(){he||(he=URL.createObjectURL(new Blob([qc],{type:"application/javascript"}))),this.worker=new Worker(he)}}Fi.revokeObjectURL=function(){he&&(URL.revokeObjectURL(he),he=null)};const Zc=`(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 le=null;class ho{constructor(){le||(le=URL.createObjectURL(new Blob([Zc],{type:"application/javascript"}))),this.worker=new Worker(le)}}ho.revokeObjectURL=function(){le&&(URL.revokeObjectURL(le),le=null)};let lo=0,Oi;class Qc{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 Fi;e.addEventListener("message",s=>{e.terminate(),Fi.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Oi===void 0&&(Oi=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Oi&&(this._createdWorkers++,t=new ho().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[lo]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:lo++,id:s})}}const uo=new Qc,Jc=[".jpeg",".jpg",".png",".webp",".avif"],td=["image/jpeg","image/png","image/webp","image/avif"];async function ed(i,t){var r;const e=await N.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return((r=t==null?void 0:t.data)==null?void 0:r.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const co={name:"loadTextures",extension:{type:x.LoadParser,priority:Bt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return oe(i,td)||ae(i,Jc)},async load(i,t,e){var n;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await uo.isImageBitmapSupported()?s=await uo.loadImageBitmap(i,t):s=await ed(i,t):s=await new Promise(o=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=i,s.complete?o(s):s.onload=()=>{o(s)}});const r=new Jt({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||Gi(i),...t.data});return Ui(r,e,i)},unload(i){i.destroy(!0)}},po=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],sd=po.map(i=>`video/${i.substring(1)}`);function id(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=nd(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function rd(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",r),i.load();function s(){n(),t()}function r(o){n(),e(o)}function n(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",r)}})}function nd(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const od={name:"loadVideo",extension:{type:x.LoadParser,name:"loadVideo"},test(i){const t=oe(i,sd),e=ae(i,po);return t||e},async load(i,t,e){var h,l;const s={...ss.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Gi(i),alphaMode:((l=t.data)==null?void 0:l.alphaMode)||await Qr(),...t.data},r=document.createElement("video"),n={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(n).forEach(u=>{const c=n[u];c!==void 0&&r.setAttribute(u,c)}),s.muted===!0&&(r.muted=!0),id(r,i,s.crossorigin);const o=document.createElement("source");let a;if(i.startsWith("data:"))a=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){const u=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();a=ss.MIME_TYPES[u]||`video/${u}`}return o.src=i,a&&(o.type=a),new Promise(u=>{const c=async()=>{const d=new ss({...s,resource:r});r.removeEventListener("canplay",c),t.data.preload&&await rd(r),u(Ui(d,e,i))};r.addEventListener("canplay",c),r.appendChild(o)})},unload(i){i.destroy(!0)}},fo={extension:{type:x.ResolveParser,name:"resolveTexture"},test:co.test,parse:i=>{var t,e;return{resolution:parseFloat((e=(t=ee.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:i.split(".").pop(),src:i}}},ad={extension:{type:x.ResolveParser,priority:-2,name:"resolveJson"},test:i=>ee.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:fo.parse};class hd{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ee,this.loader=new Rc,this.cache=j,this._backgroundLoader=new vc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o,a;if(this._initialized){U("[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 h=t.manifest;typeof h=="string"&&(h=await this.load(h)),this.resolver.addManifest(h)}const e=(o=(n=t.texturePreference)==null?void 0:n.resolution)!=null?o:1,s=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:s}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=is(t),r=_t(t).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(r),o=await this._mapLoadToResolve(n,e);return s?o[r[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},o=Object.keys(r);let a=0,h=0;const l=()=>{e==null||e(++a/h)},u=o.map(c=>{const d=r[c];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(p=>{n[c]=p})});return await Promise.all(u),s?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return j.get(t);const e={};for(let s=0;s<t.length;s++)e[s]=j.get(t[s]);return e}async _mapLoadToResolve(t,e){const s=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const r=await this.loader.load(s,e);this._backgroundLoader.active=!0;const n={};return s.forEach(o=>{const a=r[o.src],h=[o.src];o.alias&&h.push(...o.alias),h.forEach(l=>{n[l]=a}),j.set(h,a)}),n}async unload(t){this._initialized||await this.init();const e=_t(t).map(r=>typeof r!="string"?r.src:r),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=_t(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{j.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,r)=>e.indexOf(s)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{!e.config||Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}de=new hd,F.handleByList(x.LoadParser,de.loader.parsers).handleByList(x.ResolveParser,de.resolver.parsers).handleByList(x.CacheParser,de.cache.parsers).handleByList(x.DetectionParser,de.detections),F.add(Tc,wc,Sc,Mc,Ac,Pc,Cc,Ic,Fc,Vc,Yc,co,od,bc,yc,fo,ad);const mo={loader:x.LoadParser,resolver:x.ResolveParser,cache:x.CacheParser,detection:x.DetectionParser};F.handle(x.Asset,i=>{const t=i.ref;Object.entries(mo).filter(([e])=>!!t[e]).forEach(([e,s])=>{var r;return F.add(Object.assign(t[e],{extension:(r=t[e].extension)!=null?r:s}))})},i=>{const t=i.ref;Object.keys(mo).filter(e=>!!t[e]).forEach(e=>F.remove(t[e]))});class ld{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this._tickerAdded||!this.domElement||(ot.system.add(this._tickerUpdate,this,te.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){!this._tickerAdded||(ot.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}}const It=new ld;class _s extends xe{constructor(){super(...arguments),this.client=new $,this.movement=new $,this.offset=new $,this.global=new $,this.screen=new $}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,s){return t.worldTransform.applyInverse(s||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,s,r,n,o,a,h,l,u,c,d,p,f,g){throw new Error("Method not implemented.")}}class Tt extends _s{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class ue extends _s{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}ue.DOM_DELTA_PIXEL=0,ue.DOM_DELTA_LINE=1,ue.DOM_DELTA_PAGE=2;const ud=2048,cd=new $,Re=new $;class dd{constructor(t){this.dispatch=new dt,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((s,r)=>s.priority-r.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let s=0,r=e.length;s<r;s++)e[s].fn(t);else U(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){It.pauseUpdate=!0;const s=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",r=this[s](this.rootTarget,this.rootTarget.eventMode,cd.set(t,e),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(t,e){if(!t.target)return;const s=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let r=0,n=s.length-1;r<n;r++)if(t.currentTarget=s[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let r=s.length-2;r>=0;r--)if(t.currentTarget=s[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,s=this._allInteractiveElements){if(s.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let n=s.length-1;n>=0;n--)r.forEach(o=>{t.currentTarget=s[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let s=0;s<ud&&t!==this.rootTarget&&t.parent;s++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,s,r,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(It.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,s,r,n,o||n(t,s));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:h&&!n(t,s)&&r(t,s)?l?[t]:[]:null}hitTestRecursive(t,e,s,r,n){if(this._interactivePrune(t)||n(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(It.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children,l=s;for(let u=h.length-1;u>=0;u--){const c=h[u],d=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,l,r,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const p=t.isInteractive();return(d.length>0||p)&&d.push(t),d}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&r(t,s)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.includeInBuild||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,Re),!t.hitArea.contains(Re.x,Re.y)))return!0;if(t.effects&&t.effects.length)for(let s=0;s<t.effects.length;s++){const r=t.effects[s];if(r.containsPoint&&!r.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,Re),t.containsPoint(Re)):!1}notifyTarget(t,e){var n,o;if(!t.currentTarget.isInteractive())return;e=e!=null?e:t.type;const s=`on${e}`;(o=(n=t.currentTarget)[s])==null||o.call(n,t);const r=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,r),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Tt)){U("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const r=e.button===2;this.dispatchEvent(e,r?"rightdown":"mousedown")}const s=this.trackingData(t.pointerId);s.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var h,l,u;if(!(t instanceof Tt)){U("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const s=e.pointerType==="mouse"||e.pointerType==="pen",r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.overTargets);if(((h=r.overTargets)==null?void 0:h.length)>0&&n!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",d=this.createPointerEvent(t,c,n);if(this.dispatchEvent(d,"pointerout"),s&&this.dispatchEvent(d,"mouseout"),!e.composedPath().includes(n)){const p=this.createPointerEvent(t,"pointerleave",n);for(p.eventPhase=p.AT_TARGET;p.target&&!e.composedPath().includes(p.target);)p.currentTarget=p.target,this.notifyTarget(p),s&&this.notifyTarget(p,"mouseleave"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(d)}if(n!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",d=this.clonePointerEvent(e,c);this.dispatchEvent(d,"pointerover"),s&&this.dispatchEvent(d,"mouseover");let p=n==null?void 0:n.parent;for(;p&&p!==this.rootTarget.parent&&p!==e.target;)p=p.parent;if(!p||p===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),s&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(d)}const o=[],a=(l=this.enableGlobalMoveEvents)!=null?l:!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),s&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(u=e.target)==null?void 0:u.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof Tt)){U("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),s=this.createPointerEvent(t),r=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),r&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=(o=s.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(s,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),r&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof Tt)){U("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const s=t.pointerType==="mouse"||t.pointerType==="pen",r=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",r);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Tt)){U("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const a=s.button===2;this.dispatchEvent(s,a?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[t.button]);let o=n;if(n&&!s.composedPath().includes(n)){let a=n;for(;a&&!s.composedPath().includes(a);){if(s.currentTarget=a,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const h=s.button===2;this.notifyTarget(s,h?"rightupoutside":"mouseupoutside")}a=a.parent}delete r.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const h=r.clicksByButton[t.button];if(h.target===a.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=a.target,h.timeStamp=e,a.detail=h.clickCount,a.pointerType==="mouse"){const l=a.button===2;this.dispatchEvent(a,l?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof Tt)){U("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),s=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(s){let n=s;for(;n;)r.currentTarget=n,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(r)}mapWheel(t){if(!(t instanceof ue)){U("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let s=1;s<t.length&&t[s].parent===e;s++)e=t[s];return e}createPointerEvent(t,e,s){var n;const r=this.allocateEvent(Tt);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=(n=s!=null?s:this.hitTest(r.global.x,r.global.y))!=null?n:this._hitElements[0],typeof e=="string"&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(ue);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const s=this.allocateEvent(Tt);return s.nativeEvent=t.nativeEvent,s.originalEvent=t.originalEvent,this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.target=t.target,s.path=t.composedPath().slice(),s.type=e!=null?e:s.type,s}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Tt&&e instanceof Tt&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof _s&&e instanceof _s&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const s=t.currentTarget._events[e];if(s)if("fn"in s)s.once&&t.currentTarget.removeListener(e,s.fn,void 0,!0),s.fn.call(s.context,t);else for(let r=0,n=s.length;r<n&&!t.propagationImmediatelyStopped;r++)s[r].once&&t.currentTarget.removeListener(e,s[r].fn,void 0,!0),s[r].fn.call(s[r].context,t)}}const pd=1,fd={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Di=class wr{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new dd(null),It.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Tt(null),this._rootWheelEvent=new ue(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...wr.defaultEventFeatures},{set:(e,s,r)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),e[s]=r,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var r,n;const{canvas:e,resolution:s}=this.renderer;this.setTargetElement(e),this.resolution=s,wr._defaultEventMode=(r=t.eventMode)!=null?r:"passive",Object.assign(this.features,(n=t.eventFeatures)!=null?n:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const s=this.cursorStyles[t];if(s)switch(typeof s){case"string":e&&(this.domElement.style.cursor=s);break;case"function":s(t);break;case"object":e&&Object.assign(this.domElement.style,s);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let s=0,r=e.length;s<r;s++){const n=e[s],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,It.pointerMoved();const e=this._normalizeToPointerData(t);for(let s=0,r=e.length;s<r;s++){const n=this._bootstrapEvent(this._rootPointerEvent,e[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",r=this._normalizeToPointerData(t);for(let n=0,o=r.length;n<o;n++){const a=this._bootstrapEvent(this._rootPointerEvent,r[n]);a.type+=s,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let s=0,r=e.length;s<r;s++){const n=this._bootstrapEvent(this._rootPointerEvent,e[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,It.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;It.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;It.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,s){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-r.left)*(this.domElement.width/r.width)*n,t.y=(s-r.top)*(this.domElement.height/r.height)*n}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let s=0,r=t.changedTouches.length;s<r;s++){const n=t.changedTouches[s];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const s=t;typeof s.isPrimary>"u"&&(s.isPrimary=!0),typeof s.width>"u"&&(s.width=1),typeof s.height>"u"&&(s.height=1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="mouse"),typeof s.pointerId>"u"&&(s.pointerId=pd),typeof s.pressure>"u"&&(s.pressure=.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),s.isNormalized=!0,e.push(s)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=fd[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};Di.extension={name:"events",type:[x.WebGLSystem,x.CanvasSystem,x.WebGPUSystem],priority:-1},Di.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let go=Di;const md={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(i){this.eventMode=i?"static":"passive"},_internalEventMode:void 0,get eventMode(){var i;return(i=this._internalEventMode)!=null?i:go.defaultEventMode},set eventMode(i){this._internalEventMode=i},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(i,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;i=s?`${i}capture`:i;const a=typeof t=="function"?t:t.handleEvent,h=this;r&&r.addEventListener("abort",()=>{h.off(i,a,o)}),n?h.once(i,a,o):h.on(i,a,o)},removeEventListener(i,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof t=="function"?void 0:t;i=s?`${i}capture`:i,t=typeof t=="function"?t:t.handleEvent,this.off(i,t,r)},dispatchEvent(i){if(!(i instanceof xe))throw new Error("Container cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}};let gd=0;class _d{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1}createTexture(t,e,s){const r=new tt({...this.textureOptions,width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!0});return new C({source:r,label:`texturePool_${gd++}`})}getOptimalTexture(t,e,s=1,r){let n=Math.ceil(t*s-1e-6),o=Math.ceil(e*s-1e-6);n=qt(n),o=qt(o);const a=(n<<17)+(o<<1)+(r?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(n,o,r)),h.source._resolution=s,h.source.width=n/s,h.source.height=o/s,h.source.pixelWidth=n,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture(t.width,t.height,s._resolution,e)}returnTexture(t){const e=this._poolKeyHash[t.uid];this._texturePool[e].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const s=this._texturePool[e];if(s)for(let r=0;r<s.length;r++)s[r].destroy(!0)}this._texturePool={}}}const gt=new _d;class _o{constructor(t){this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}_o.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"filter"};const xd=new R;function yd(i,t){return t.clear(),xo(i,t),t.isValid||t.set(0,0,0,0),i.renderGroup?t.applyMatrix(i.renderGroup.localTransform):t.applyMatrix(i.parentRenderGroup.worldTransform),t}function xo(i,t){if(i.localDisplayStatus!==7||!i.measurable)return;const e=!!i.effects.length;let s=t;if((i.renderGroup||e)&&(s=At.get().clear()),i.boundsArea)t.addRect(i.boundsArea,i.worldTransform);else{if(i.renderPipeId){const n=i.bounds;s.addFrame(n.minX,n.minY,n.maxX,n.maxY,i.groupTransform)}const r=i.children;for(let n=0;n<r.length;n++)xo(r[n],s)}if(e){let r=!1;for(let n=0;n<i.effects.length;n++)i.effects[n].addBounds&&(r||(r=!0,s.applyMatrix(i.parentRenderGroup.worldTransform)),i.effects[n].addBounds(s,!0));r&&(s.applyMatrix(i.parentRenderGroup.worldTransform.copyTo(xd).invert()),t.addBounds(s,i.relativeGroupTransform)),t.addBounds(s),At.return(s)}else i.renderGroup&&(t.addBounds(s,i.relativeGroupTransform),At.return(s))}function bd(i,t){t.clear();const e=t.matrix;for(let s=0;s<i.length;s++){const r=i[s];r.globalDisplayStatus<7||(t.matrix=r.worldTransform,r.addBounds(t))}return t.matrix=e,t}const vd=new us({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class yo{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new at({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Pt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){var p,f;const e=this.renderer,s=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const r=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,s.length===0){r.skip=!0;return}const n=r.bounds;t.renderables?bd(t.renderables,n):t.filterEffect.filterArea?(n.clear(),n.addRect(t.filterEffect.filterArea),n.applyMatrix(t.container.worldTransform)):yd(t.container,n);const o=e.renderTarget.renderTarget.colorTexture.source;let a=1/0,h=0,l=!0,u=!1,c=!1;for(let g=0;g<s.length;g++){const m=s[g];if(a=Math.min(a,m.resolution==="inherit"?o._resolution:m.resolution),h+=m.padding,m.antialias==="off"?l=!1:m.antialias==="inherit"&&l&&(l=o.antialias),!(m.compatibleRenderers&e.type)){c=!1;break}if(m.blendRequired&&!((f=(p=e.backBuffer)==null?void 0:p.useBackBuffer)==null||f)){U("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),c=!1;break}c=m.enabled||c,u=u||m.blendRequired}if(!c){r.skip=!0;return}const d=e.renderTarget.rootViewPort;if(n.scale(a).fitBounds(0,d.width,0,d.height).ceil().scale(1/a).pad(h|0),!n.isPositive){r.skip=!0;return}r.skip=!1,r.bounds=n,r.blendRequired=u,r.container=t.container,r.filterEffect=t.filterEffect,r.previousRenderSurface=e.renderTarget.renderSurface,r.inputTexture=gt.getOptimalTexture(n.width,n.height,a,l),e.renderTarget.bind(r.inputTexture,!0),e.globalUniforms.push({offset:n})}pop(){const t=this.renderer;this._filterStackIndex--;const e=this._filterStack[this._filterStackIndex];if(e.skip)return;this._activeFilterData=e;const s=e.inputTexture,r=e.bounds;let n=C.EMPTY;if(t.renderTarget.finishRenderPass(),e.blendRequired){const a=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,h=t.renderTarget.getRenderTarget(e.previousRenderSurface);n=this.getBackTexture(h,r,a)}e.backTexture=n;const o=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),t.globalUniforms.pop(),o.length===1)o[0].apply(this,s,e.previousRenderSurface,!1),gt.returnTexture(s);else{let a=e.inputTexture,h=gt.getOptimalTexture(r.width,r.height,a.source._resolution,!1),l=0;for(l=0;l<o.length-1;++l){o[l].apply(this,a,h,!0);const u=a;a=h,h=u}o[l].apply(this,a,e.previousRenderSurface,!1),gt.returnTexture(a),gt.returnTexture(h)}e.blendRequired&&gt.returnTexture(n)}getBackTexture(t,e,s){const r=t.colorTexture.source._resolution,n=gt.getOptimalTexture(e.width,e.height,r,!1);let o=e.minX,a=e.minY;s&&(o-=s.minX,a-=s.minY),o=Math.floor(o*r),a=Math.floor(a*r);const h=Math.ceil(e.width*r),l=Math.ceil(e.height*r);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:h,height:l},{x:0,y:0}),n}applyFilter(t,e,s,r){const n=this.renderer,o=this._filterStack[this._filterStackIndex],a=o.bounds,h=$.shared,l=o.previousRenderSurface===s;let u=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._filterStackIndex-1;for(;c>0&&this._filterStack[c].skip;)--c;c>0&&(u=this._filterStack[c].inputTexture.source._resolution);const d=this._filterGlobalUniforms,p=d.uniforms,f=p.uOutputFrame,g=p.uInputSize,m=p.uInputPixel,_=p.uInputClamp,y=p.uGlobalFrame,b=p.uOutputTexture;if(l){let A=this._filterStackIndex;for(;A>0;){A--;const E=this._filterStack[this._filterStackIndex-1];if(!E.skip){h.x=E.bounds.minX,h.y=E.bounds.minY;break}}f[0]=a.minX-h.x,f[1]=a.minY-h.y}else f[0]=0,f[1]=0;f[2]=e.frame.width,f[3]=e.frame.height,g[0]=e.source.width,g[1]=e.source.height,g[2]=1/g[0],g[3]=1/g[1],m[0]=e.source.pixelWidth,m[1]=e.source.pixelHeight,m[2]=1/m[0],m[3]=1/m[1],_[0]=.5*m[2],_[1]=.5*m[3],_[2]=e.frame.width*g[2]-.5*m[2],_[3]=e.frame.height*g[3]-.5*m[3];const v=this.renderer.renderTarget.rootRenderTarget.colorTexture;y[0]=h.x*u,y[1]=h.y*u,y[2]=v.source.width*u,y[3]=v.source.height*u;const T=this.renderer.renderTarget.getRenderTarget(s);if(n.renderTarget.bind(s,!!r),s instanceof C?(b[0]=s.frame.width,b[1]=s.frame.height):(b[0]=T.width,b[1]=T.height),b[2]=T.isRoot?-1:1,d.update(),n.renderPipes.uniformBatch){const A=n.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(A,0)}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:vd,shader:t,state:t._state,topology:"triangle-list"}),n.type===yt.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new nt,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(t,e){const s=this._activeFilterData,r=t.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),n=e.worldTransform.copyTo(R.shared);return n.invert(),r.prepend(n),r.scale(1/e.texture.frame.width,1/e.texture.frame.height),r.translate(e.anchor.x,e.anchor.y),r}}yo.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"filter"};var Td=`in vec2 vMaskCoord;
in vec2 vTextureCoord;

uniform sampler2D uTexture;
uniform sampler2D uMaskTexture;

uniform float uAlpha;
uniform vec4 uMaskClamp;

out vec4 finalColor;

void main(void)
{
    float clip = step(3.5,
        step(uMaskClamp.x, vMaskCoord.x) +
        step(uMaskClamp.y, vMaskCoord.y) +
        step(vMaskCoord.x, uMaskClamp.z) +
        step(vMaskCoord.y, uMaskClamp.w));

    // TODO look into why this is needed
    float npmAlpha = uAlpha; 
    vec4 original = texture(uTexture, vTextureCoord);
    vec4 masky = texture(uMaskTexture, vMaskCoord);
    float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);

    original *= (alphaMul * masky.r * uAlpha * clip);

    finalColor = original;
}
`,Sd=`in vec2 aPosition;

out vec2 vTextureCoord;
out vec2 vMaskCoord;


uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
uniform mat3 uFilterMatrix;

vec4 filterVertexPosition(  vec2 aPosition )
{
    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
       
    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

vec2 filterTextureCoord(  vec2 aPosition )
{
    return aPosition * (uOutputFrame.zw * uInputSize.zw);
}

vec2 getFilterCoord( vec2 aPosition )
{
    return  ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}   

void main(void)
{
    gl_Position = filterVertexPosition(aPosition);
    vTextureCoord = filterTextureCoord(aPosition);
    vMaskCoord = getFilterCoord(aPosition);
}
`,bo=`struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,  
};

struct MaskUniforms {
  uFilterMatrix:mat3x3<f32>,
  uMaskClamp:vec4<f32>,
  uAlpha:f32,
};


@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;

@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>,
    @location(1) filterUv : vec2<f32>,
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;

    position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
}

fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
{
  return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}

fn getSize() -> vec2<f32>
{

  
  return gfu.uGlobalFrame.zw;
}
  
@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition),
   getFilterCoord(aPosition)
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
  @location(1) filterUv: vec2<f32>,
  @builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {

    var maskClamp = filterUniforms.uMaskClamp;

     var clip = step(3.5,
        step(maskClamp.x, filterUv.x) +
        step(maskClamp.y, filterUv.y) +
        step(filterUv.x, maskClamp.z) +
        step(filterUv.y, maskClamp.w));

    var mask = textureSample(uMaskTexture, uSampler, filterUv);
    var source = textureSample(uTexture, uSampler, uv);
    
    var npmAlpha = 0.0;

    var alphaMul = 1.0 - npmAlpha * (1.0 - mask.a);

    var a = (alphaMul * mask.r) * clip;

    return vec4(source.rgb, source.a) * a;
}`;class wd extends ru{constructor(t){const{sprite:e,...s}=t,r=new Fr(e.texture),n=new at({uFilterMatrix:{value:new R,type:"mat3x3<f32>"},uMaskClamp:{value:r.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"}}),o=ie.from({vertex:{source:bo,entryPoint:"mainVertex"},fragment:{source:bo,entryPoint:"mainFragment"}}),a=be.from({vertex:Sd,fragment:Td,name:"mask-filter"});super({...s,gpuProgram:o,glProgram:a,resources:{filterUniforms:n,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=r}apply(t,e,s,r){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,s,r)}}class xs extends Ks{constructor(t){t instanceof mt&&(t={context:t});const{context:e,roundPixels:s,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new mt,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=s!=null?s:!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new xs(this._context.clone()):(this._ownedContext=null,new xs(this._context))}lineStyle(t,e,s){D(H,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),s&&(r.alpha=s),this.context.strokeStyle=r,this}beginFill(t,e){D(H,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){D(H,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==mt.defaultStrokeStyle.width||t.color!==mt.defaultStrokeStyle.color||t.alpha!==mt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return D(H,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return D(H,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return D(H,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return D(H,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return D(H,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return D(H,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const vo=class Lh extends us{constructor(...t){var u;let e=(u=t[0])!=null?u:{};e instanceof Float32Array&&(D(H,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...Lh.defaultOptions,...e};const s=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),r=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),n=e.indices||new Uint32Array([0,1,2,0,2,3]),o=e.shrinkBuffersToFit,a=new bt({data:s,label:"attribute-mesh-positions",shrinkToFit:o,usage:W.VERTEX|W.COPY_DST}),h=new bt({data:r,label:"attribute-mesh-uvs",shrinkToFit:o,usage:W.VERTEX|W.COPY_DST}),l=new bt({data:n,label:"index-mesh-buffer",shrinkToFit:o,usage:W.INDEX|W.COPY_DST});super({attributes:{aPosition:{buffer:a,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:l,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};vo.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Li=vo;ks=class extends Ft{constructor(...i){let t=i[0];Array.isArray(i[0])&&(t={textures:i[0],autoUpdate:i[1]});const{textures:e,autoUpdate:s,...r}=t,[n]=e;super({...r,texture:n instanceof C?n:n.texture}),this._textures=null,this._durations=null,this._autoUpdate=s!=null?s:!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=e}stop(){!this._playing||(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ot.shared.add(this.update,this,te.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(i){this.stop(),this.currentFrame=i}gotoAndPlay(i){this.currentFrame=i,this.play()}update(i){if(!this._playing)return;const t=i.deltaTime,e=this.animationSpeed*t,s=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=e/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const n=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=e;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()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}_updateTexture(){const i=this.currentFrame;this._previousFrame!==i&&(this._previousFrame=i,this.texture=this._textures[i],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(i){const t=[];for(let e=0;e<i.length;++e)t.push(C.from(i[e]));return new ks(t)}static fromImages(i){const t=[];for(let e=0;e<i.length;++e)t.push(C.from(i[e]));return new ks(t)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(i){if(i[0]instanceof C)this._textures=i,this._durations=null;else{this._textures=[],this._durations=[];for(let t=0;t<i.length;t++)this._textures.push(i[t].texture),this._durations.push(i[t].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let i=Math.floor(this._currentTime)%this._textures.length;return i<0&&(i+=this._textures.length),i}set currentFrame(i){if(i<0||i>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${i}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const t=this.currentFrame;this._currentTime=i,t!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(i){i!==this._autoUpdate&&(this._autoUpdate=i,!this._autoUpdate&&this._isConnectedToTicker?(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ot.shared.add(this.update,this),this._isConnectedToTicker=!0))}};class Ed extends Ks{constructor(t,e){const{text:s,resolution:r,style:n,anchor:o,width:a,height:h,roundPixels:l,...u}=t;super({...u}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s!=null?s:"",this.style=n,this.resolution=r!=null?r:null,this.allowChildren=!1,this._anchor=new rt({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=l!=null?l:!1,a!==void 0&&(this.width=a),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){var s;typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-s*this.anchor.y,t.y>=n&&t.y<=n+s)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t==null?void 0:t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function Ad(i,t){var s;let e=(s=i[0])!=null?s:{};return(typeof e=="string"||i[1])&&(D(H,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}Bh=class extends Ed{constructor(...i){const t=Ad(i,"Text");super(t,Mt),this.renderPipeId="text"}_updateBounds(){const i=this._bounds,t=this._anchor,e=St.measureText(this._text,this._style),{width:s,height:r}=e;i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*r,i.maxY=i.minY+r}};function Pd(i){const t=i._stroke,e=i._fill,s=[`div { ${[`color: ${V.shared.setValue(e.color).toHex()}`,`font-size: ${i.fontSize}px`,`font-family: ${i.fontFamily}`,`font-weight: ${i.fontWeight}`,`font-style: ${i.fontStyle}`,`font-variant: ${i.fontVariant}`,`letter-spacing: ${i.letterSpacing}px`,`text-align: ${i.align}`,`padding: ${i.padding}px`,`white-space: ${i.whiteSpace==="pre"&&i.wordWrap?"pre-wrap":i.whiteSpace}`,...i.lineHeight?[`line-height: ${i.lineHeight}px`]:[],...i.wordWrap?[`word-wrap: ${i.breakWords?"break-all":"break-word"}`,`max-width: ${i.wordWrapWidth}px`]:[],...t?[So(t)]:[],...i.dropShadow?[To(i.dropShadow)]:[],...i.cssOverrides].join(";")} }`];return Cd(i.tagStyles,s),s.join(" ")}function To(i){const t=V.shared.setValue(i.color).setAlpha(i.alpha).toHexa(),e=Math.round(Math.cos(i.angle)*i.distance),s=Math.round(Math.sin(i.angle)*i.distance),r=`${e}px ${s}px`;return i.blur>0?`text-shadow: ${r} ${i.blur}px ${t}`:`text-shadow: ${r} ${t}`}function So(i){return[`-webkit-text-stroke-width: ${i.width}px`,`-webkit-text-stroke-color: ${V.shared.setValue(i.color).toHex()}`,`text-stroke-width: ${i.width}px`,`text-stroke-color: ${V.shared.setValue(i.color).toHex()}`,"paint-order: stroke"].join(";")}const wo={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Eo={fill:i=>`color: ${V.shared.setValue(i).toHex()}`,breakWords:i=>`word-wrap: ${i?"break-all":"break-word"}`,stroke:So,dropShadow:To};function Cd(i,t){for(const e in i){const s=i[e],r=[];for(const n in s)Eo[n]?r.push(Eo[n](s[n])):wo[n]&&r.push(wo[n].replace("{{VALUE}}",s[n]));t.push(`${e} { ${r.join(";")} }`)}}class Ni extends Mt{constructor(t={}){var e,s;super(t),this._cssOverrides=[],(e=this.cssOverrides)!=null||(this.cssOverrides=t.cssOverrides),this.tagStyles=(s=t.tagStyles)!=null?s:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Zn(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new Ni({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,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=Pd(this)),this._cssStyle}addOverride(...t){const e=t.filter(s=>!this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(s=>this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(s=>!e.includes(s)),this.update())}set fill(t){typeof t!="string"&&typeof t!="number"&&U("[HTMLTextStyle] only color fill is not supported by HTMLText"),super.fill=t}set stroke(t){t&&typeof t!="string"&&typeof t!="number"&&U("[HTMLTextStyle] only color stroke is not supported by HTMLText"),super.stroke=t}}const Ao="http://www.w3.org/2000/svg",Po="http://www.w3.org/1999/xhtml";class Co{constructor(){this.svgRoot=document.createElementNS(Ao,"svg"),this.foreignObject=document.createElementNS(Ao,"foreignObject"),this.domElement=document.createElementNS(Po,"div"),this.styleElement=document.createElementNS(Po,"style"),this.image=new Image;const{foreignObject:t,svgRoot:e,styleElement:s,domElement:r}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(s),t.appendChild(r)}}let Mo;function Md(i,t,e,s){s=s||Mo||(Mo=new Co);const{domElement:r,styleElement:n,svgRoot:o}=s;r.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${i}</div>`,r.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=r.getBoundingClientRect();o.remove();const h=St.measureFont(t.fontStyle).descent,l=t.padding*2;return{width:a.width-l,height:a.height+h-l}}function Ro(i,t,e){if(i)for(const s in i){const r=s.toLocaleLowerCase(),n=t[r];if(n){let o=i[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}else U(`${s} placement hook does not exist in shader`)}}const Rd=/\{\{(.*?)\}\}/g;function Bo(i){var e,s;const t={};return((s=(e=i.match(Rd))==null?void 0:e.map(r=>r.replace(/[{()}]/g,"")))!=null?s:[]).forEach(r=>{t[r]=[]}),t}function ko(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Io(i,t,e=!1){const s=[];ko(t,s),i.forEach(a=>{a.header&&ko(a.header,s)});const r=s;e&&r.sort();const n=r.map((a,h)=>`       @location(${h}) ${a},`).join(`
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
${n}
`),o}function Go(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Bd(i){const t=/\b(\w+)\s*:/g.exec(i);return t?t[1]:""}function kd(i){const t=/@.*?\s+/g;return i.replace(t,"")}function Id(i,t){const e=[];Go(t,e),i.forEach(h=>{h.header&&Go(h.header,e)});let s=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`,
`),n=e.sort().map(h=>`       var ${kd(h)};`).join(`
`),o=`return VSOutput(
                ${e.sort().map(h=>` ${Bd(h)}`).join(`,
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
${r}
`),a=a.replace("{{start}}",`
${n}
`),a=a.replace("{{return}}",`
${o}
`),a}function Uo(i,t){let e=i;for(const s in t){const r=t[s];r.join(`
`).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
${r.join(`
`)}
//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const Wt=Object.create(null),Hi=new Map;let Gd=0;function Ud({template:i,bits:t}){const e=Fo(i,t);if(Wt[e])return Wt[e];const{vertex:s,fragment:r}=Od(i,t);return Wt[e]=Oo(s,r,t),Wt[e]}function Fd({template:i,bits:t}){const e=Fo(i,t);return Wt[e]||(Wt[e]=Oo(i.vertex,i.fragment,t)),Wt[e]}function Od(i,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let r=Io(e,i.vertex,!0);r=Id(e,r);const n=Io(s,i.fragment,!0);return{vertex:r,fragment:n}}function Fo(i,t){return t.map(e=>(Hi.has(e)||Hi.set(e,Gd++),Hi.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function Oo(i,t,e){const s=Bo(i),r=Bo(t);return e.forEach(n=>{Ro(n.vertex,s,n.name),Ro(n.fragment,r,n.name)}),{vertex:Uo(i,s),fragment:Uo(t,r)}}const Dd=`
    @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}}
    };
`,Ld=`
    @in vUV : vec2<f32>;
    @in vColor : vec4<f32>;
   
    {{header}}

    @fragment
    fn main(
        {{in}}
      ) -> @location(0) vec4<f32> {
        
        {{start}}

        var outColor:vec4<f32>;
      
        {{main}}
        
        return outColor * vColor;
      };
`,Nd=`
    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}}
    }
`,Hd=`
   
    in vec4 vColor;
    in vec2 vUV;

    out vec4 finalColor;

    {{header}}

    void main(void) {
        
        {{start}}

        vec4 outColor;
      
        {{main}}
        
        finalColor = outColor * vColor;
    }
`,zd={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;
        `}},Wd={name:"global-uniforms-bit",vertex:{header:`
          uniform mat3 uProjectionMatrix;
          uniform mat3 uWorldTransformMatrix;
          uniform vec4 uWorldColorAlpha;
          uniform vec2 uResolution;
        `}};function Be({bits:i,name:t}){const e=Ud({template:{fragment:Ld,vertex:Dd},bits:[zd,...i]});return ie.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function ke({bits:i,name:t}){return new be({name:t,...Fd({template:{vertex:Nd,fragment:Hd},bits:[Wd,...i]})})}const zi={name:"color-bit",vertex:{header:`
            @in aColor: vec4<f32>;
        `,main:`
            vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
        `}},Wi={name:"color-bit",vertex:{header:`
            in vec4 aColor;
        `,main:`
            vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
        `}},Vi={};function Vd(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s<i;s++)t.push(`@group(1) @binding(${e++}) var textureSource${s+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
`)}function $d(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<i;e++)e===i-1?t.push("  default:{"):t.push(`  case ${e}:{`),t.push(`      outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push("      break;}");t.push("}")}return t.join(`
`)}function $i(i){return Vi[i]||(Vi[i]={name:"texture-batch-bit",vertex:{header:`
                @in aTextureIdAndRound: vec2<u32>;
                @out @interpolate(flat) vTextureId : u32;
            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1)
                {
                    vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
                }
            `},fragment:{header:`
                @in @interpolate(flat) vTextureId: u32;

                ${Vd(i)}
            `,main:`
                var uvDx = dpdx(vUV);
                var uvDy = dpdy(vUV);

                ${$d(i)}
            `}}),Vi[i]}const Xi={};function Xd(i){const t=[];for(let e=0;e<i;e++)e>0&&t.push("else"),e<i-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(`	outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
`)}function Yi(i){return Xi[i]||(Xi[i]={name:"texture-batch-bit",vertex:{header:`
                in vec2 aTextureIdAndRound;
                out float vTextureId;

            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1.)
                {
                    gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
                }
            `},fragment:{header:`
                in float vTextureId;

                uniform sampler2D uTextures[${i}];

            `,main:`

                ${Xd(i)}
            `}}),Xi[i]}const Ie={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;
            }
        `}},Ge={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;
            }
        `}},Do={};function ji(i){let t=Do[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=Do[i]=new at({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class Lo{constructor(){this._didUpload=!1,this._tempState=Ct.for2d()}init(t){const e=kt(),s=ke({name:"batch",bits:[Wi,Yi(e),Ge]});this._shader=new ft({glProgram:s,resources:{batchSamplers:ji(e)}}),t.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(t,e){const s=t.renderer;s.shader.bind(this._shader,this._didUpload),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,this._shader.glProgram)}execute(t,e){const s=t.renderer;this._didUpload=!0,this._tempState.blendMode=e.blendMode,s.state.set(this._tempState);const r=e.textures.textures;for(let n=0;n<e.textures.count;n++)s.texture.bind(r[n],n);s.geometry.draw("triangle-list",e.size,e.start)}destroy(){this._shader.destroy(!0),this._shader=null}}Lo.extension={type:[x.WebGLPipesAdaptor],name:"batch"};const ys=Ct.for2d();class No{init(){const t=Be({name:"batch",bits:[zi,$i(kt()),Ie]});this._shader=new ft({gpuProgram:t,groups:{}})}start(t,e){const s=t.renderer,r=s.encoder,n=this._shader.gpuProgram;this._geometry=e,r.setGeometry(e,n),ys.blendMode="normal",s.pipeline.getPipeline(e,n,ys);const o=s.globalUniforms.bindGroup;r.resetBindGroup(1),r.setBindGroup(0,o,n)}execute(t,e){const s=this._shader.gpuProgram,r=t.renderer,n=r.encoder;if(!e.bindGroup){const h=e.textures;e.bindGroup=_i(h.textures,h.count)}ys.blendMode=e.blendMode;const o=r.bindGroup.getBindGroup(e.bindGroup,s,1),a=r.pipeline.getPipeline(this._geometry,s,ys);e.bindGroup._touch(r.textureGC.count),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}destroy(){this._shader.destroy(!0),this._shader=null}}No.extension={type:[x.WebGPUPipesAdaptor],name:"batch"};class Ho{constructor(t,e){this.state=Ct.for2d(),this._batches=Object.create(null),this._geometries=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init(this)}buildStart(t){if(!this._batches[t.uid]){const e=new In;this._batches[t.uid]=e,this._geometries[e.uid]=new Un}this._activeBatch=this._batches[t.uid],this._activeGeometry=this._geometries[this._activeBatch.uid],this._activeBatch.begin()}addToBatch(t){this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){const e=this._activeBatch,s=this._activeGeometry;e.finish(t),s.indexBuffer.setDataWithSize(e.indexBuffer,e.indexSize,!0),s.buffers[0].setDataWithSize(e.attributeBuffer.float32View,e.attributeSize,!1)}upload(t){const e=this._batches[t.uid],s=this._geometries[e.uid];e.dirty&&(e.dirty=!1,s.buffers[0].update(e.attributeSize*4))}execute(t){if(t.action==="startBatch"){const e=t.batcher,s=this._geometries[e.uid];this._adaptor.start(this,s)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor.destroy(),this._adaptor=null;for(const t in this._batches)this._batches[t].destroy();this._batches=null;for(const t in this._geometries)this._geometries[t].destroy();this._geometries=null}}Ho.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"batch"};const Ue={name:"local-uniform-bit",vertex:{header:`

            struct LocalUniforms {
                uTransformMatrix:mat3x3<f32>,
                uColor:vec4<f32>,
                uRound:f32,
            }

            @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `}},Yd={...Ue,vertex:{...Ue.vertex,header:Ue.vertex.header.replace("group(1)","group(2)")}},Ki={name:"local-uniform-bit",vertex:{header:`

            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix = uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `}},jd={name:"texture-bit",vertex:{header:`

        struct TextureUniforms {
            uTextureMatrix:mat3x3<f32>,
        }

        @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
        `,main:`
            uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
            @group(2) @binding(0) var uTexture: texture_2d<f32>;
            @group(2) @binding(1) var uSampler: sampler;

         
        `,main:`
            outColor = textureSample(uTexture, uSampler, vUV);
        `}},Kd={name:"texture-bit",vertex:{header:`
            uniform mat3 uTextureMatrix;
        `,main:`
            uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
        uniform sampler2D uTexture;

         
        `,main:`
            outColor = texture(uTexture, vUV);
        `}};function qd(i,t){const e=i.root,s=i.instructionSet;s.reset();const r=t.renderPipes?t:t.batch.renderer,n=r.renderPipes;n.batch.buildStart(s),n.blendMode.buildStart(),n.colorMask.buildStart(),e.sortableChildren&&e.sortChildren(),zo(e,s,r,!0),n.batch.buildEnd(s),n.blendMode.buildEnd(s)}function bs(i,t,e){const s=e.renderPipes?e:e.batch.renderer;i.globalDisplayStatus<7||!i.includeInBuild||(i.sortableChildren&&i.sortChildren(),i.isSimple?Zd(i,t,s):zo(i,t,s,!1))}function Zd(i,t,e){if(i.renderPipeId){const{renderPipes:s,renderableGC:r}=e;s.blendMode.setBlendMode(i,i.groupBlendMode,t),i.didViewUpdate=!1,s[i.renderPipeId].addRenderable(i,t),r.addRenderable(i,t)}if(!i.renderGroup){const s=i.children,r=s.length;for(let n=0;n<r;n++)bs(s[n],t,e)}}function zo(i,t,e,s){const{renderPipes:r,renderableGC:n}=e;if(!s&&i.renderGroup)r.renderGroup.addRenderGroup(i.renderGroup,t);else{for(let h=0;h<i.effects.length;h++){const l=i.effects[h];r[l.pipe].push(l,i,t)}const o=i.renderPipeId;o&&(r.blendMode.setBlendMode(i,i.groupBlendMode,t),i.didViewUpdate=!1,r[o].addRenderable(i,t),n.addRenderable(i,t));const a=i.children;if(a.length)for(let h=0;h<a.length;h++)bs(a[h],t,e);for(let h=i.effects.length-1;h>=0;h--){const l=i.effects[h];r[l.pipe].pop(l,i,t)}}}const Qd=new nt;class Jd extends Qe{constructor(){super(),this.filters=[new wd({sprite:new Ft(C.EMPTY),resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}}class Wo{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,s){const r=this._renderer;if(r.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,canBundle:!1,maskedContainer:e}),t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,bs(n,s,r),n.includeInBuild=!1}r.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,canBundle:!1})}execute(t){const e=this._renderer,s=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const r=L.get(Jd);if(s){t.mask.mask.measurable=!0;const n=zs(t.mask.mask,!0,Qd);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=gt.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const h=r.sprite;h.texture=a,h.worldTransform.tx=n.minX,h.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:t.maskedContainer,filterTexture:a})}else r.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const r=this._activeMaskStage[this._activeMaskStage.length-1];s&&(e.type===yt.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:r.maskedContainer,filterEffect:r.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const r=this._activeMaskStage.pop();s&&gt.returnTexture(r.filterTexture),L.return(r.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Wo.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"alphaMask"};class Vo{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const r=this._colorStack;this._colorStackIndex--;const n=r[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}Vo.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"colorMask"};class $o{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,s){var c;var r;const n=t,o=this._renderer;o.renderPipes.batch.break(s),o.renderPipes.blendMode.setBlendMode(n.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,canBundle:!1});const a=n.mask;a.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const h=this._maskHash.get(n);h.instructionsStart=s.instructionSize,bs(a,s,o),a.includeInBuild=!1,o.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,canBundle:!1});const l=s.instructionSize-h.instructionsStart-1;h.instructionsLength=l;const u=o.renderTarget.renderTarget.uid;(c=(r=this._maskStackHash)[u])!=null||(r[u]=0)}pop(t,e,s){const r=t,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(r.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",canBundle:!1});const o=this._maskHash.get(t);for(let a=0;a<o.instructionsLength;a++)s.instructions[s.instructionSize++]=s.instructions[o.instructionsStart++];s.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var o;var e;const s=this._renderer,r=s.renderTarget.renderTarget.uid;let n=(o=(e=this._maskStackHash)[r])!=null?o:e[r]=0;t.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(et.RENDERING_MASK_ADD,n),n++,s.colorMask.setMask(0)):t.action==="pushMaskEnd"?(s.stencil.setStencilMode(et.MASK_ACTIVE,n),s.colorMask.setMask(15)):t.action==="popMaskBegin"?(s.colorMask.setMask(0),n!==0?s.stencil.setStencilMode(et.RENDERING_MASK_REMOVE,n):(s.renderTarget.clear(null,ut.STENCIL),s.stencil.setStencilMode(et.DISABLED,n)),n--):t.action==="popMaskEnd"&&(s.stencil.setStencilMode(et.MASK_ACTIVE,n),s.colorMask.setMask(15)),this._maskStackHash[r]=n}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}$o.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"stencilMask"};var vs=(i=>(i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i))(vs||{});class tp{constructor(t,e){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class Xo{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=t}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,s=this.getGlBuffer(t);e.bindBuffer(s.type,s.buffer)}bindBufferBase(t,e){const{_gl:s}=this;if(this._boundBufferBases[e]!==t){const r=this.getGlBuffer(t);this._boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,r.buffer)}}bindBufferRange(t,e,s){const{_gl:r}=this;s=s||0;const n=this.getGlBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,n.buffer,s*256,256)}updateBuffer(t){const{_gl:e}=this,s=this.getGlBuffer(t);if(t._updateID===s.updateID)return s;s.updateID=t._updateID,e.bindBuffer(s.type,s.buffer);const r=t.data;if(s.byteLength>=t.data.byteLength)e.bufferSubData(s.type,0,r,0,t._updateSize/r.BYTES_PER_ELEMENT);else{const n=t.descriptor.usage&W.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=r.byteLength,e.bufferData(s.type,r,n)}return s}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const s=this._gpuBuffers[t.uid],r=this._gl;e||r.deleteBuffer(s.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let s=vs.ARRAY_BUFFER;t.descriptor.usage&W.INDEX?s=vs.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&W.UNIFORM&&(s=vs.UNIFORM_BUFFER);const r=new tp(e.createBuffer(),s);return this._gpuBuffers[t.uid]=r,t.on("destroy",this.onBufferDestroy,this),r}}Xo.extension={type:[x.WebGLSystem],name:"buffer"};const qi=class Nh{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){var e,s;if(t={...Nh.defaultOptions,...t},t.context)this.initFromContext(t.context);else{const r=this._renderer.background.alpha<1,n=(e=t.premultipliedAlpha)!=null?e:!0,o=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:r,premultipliedAlpha:n,antialias:o,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(s=t.powerPreference)!=null?s:"default"})}}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof N.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let s;const r=this._renderer.view.canvas;if(t===2&&(s=r.getContext("webgl2",e)),!s&&(s=r.getContext("webgl",e),!s))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=s,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...e,drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")};else{this.extensions={...e,colorBufferFloat:t.getExtension("EXT_color_buffer_float")};const s=t.getExtension("WEBGL_provoking_vertex");s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this._renderer.runners.contextChange.emit(this.gl)}destroy(){var e;const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(e=this.extensions.loseContext)==null||e.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&U("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=this.supports,r=this.webGLVersion===2,n=this.extensions;s.uint32Indices=r||!!n.uint32ElementIndex,s.uniformBufferObject=r,s.vertexArrayObject=r||!!n.vertexArrayObject,s.srgbTextures=r||!!n.srgb,s.nonPowOf2wrapping=r,s.nonPowOf2mipmaps=r,s.msaa=r,s.uint32Indices||U("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};qi.extension={type:[x.WebGLSystem],name:"context"},qi.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2};let ep=qi;function Yo(i,t){var e,s,r;for(const n in i.attributes){const o=i.attributes[n],a=t[n];a?((e=o.format)!=null||(o.format=a.format),(s=o.offset)!=null||(o.offset=a.offset),(r=o.instance)!=null||(o.instance=a.instance)):U(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}sp(i)}function sp(i){var n,o;const{buffers:t,attributes:e}=i,s={},r={};for(const a in t){const h=t[a];s[h.uid]=0,r[h.uid]=0}for(const a in e){const h=e[a];s[h.buffer.uid]+=ve(h.format).stride}for(const a in e){const h=e[a];(n=h.stride)!=null||(h.stride=s[h.buffer.uid]),(o=h.start)!=null||(h.start=r[h.buffer.uid]),r[h.buffer.uid]+=ve(h.format).stride}}var Zi=(i=>(i[i.RGBA=6408]="RGBA",i[i.RGB=6407]="RGB",i[i.RG=33319]="RG",i[i.RED=6403]="RED",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.ALPHA=6406]="ALPHA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i))(Zi||{}),jo=(i=>(i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i))(jo||{}),z=(i=>(i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.BYTE=5120]="BYTE",i[i.SHORT=5122]="SHORT",i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.HALF_FLOAT=36193]="HALF_FLOAT",i))(z||{});const Ko={uint8x2:z.UNSIGNED_BYTE,uint8x4:z.UNSIGNED_BYTE,sint8x2:z.BYTE,sint8x4:z.BYTE,unorm8x2:z.UNSIGNED_BYTE,unorm8x4:z.UNSIGNED_BYTE,snorm8x2:z.BYTE,snorm8x4:z.BYTE,uint16x2:z.UNSIGNED_SHORT,uint16x4:z.UNSIGNED_SHORT,sint16x2:z.SHORT,sint16x4:z.SHORT,unorm16x2:z.UNSIGNED_SHORT,unorm16x4:z.UNSIGNED_SHORT,snorm16x2:z.SHORT,snorm16x4:z.SHORT,float16x2:z.HALF_FLOAT,float16x4:z.HALF_FLOAT,float32:z.FLOAT,float32x2:z.FLOAT,float32x3:z.FLOAT,float32x4:z.FLOAT,uint32:z.UNSIGNED_INT,uint32x2:z.UNSIGNED_INT,uint32x3:z.UNSIGNED_INT,uint32x4:z.UNSIGNED_INT,sint32:z.INT,sint32x2:z.INT,sint32x3:z.INT,sint32x4:z.INT};function ip(i){var t;return(t=Ko[i])!=null?t:Ko.float32}const rp={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class qo{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=r=>e.bindVertexArrayOES(r),t.deleteVertexArray=r=>e.deleteVertexArrayOES(r));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(t.drawArraysInstanced=(r,n,o,a)=>{s.drawArraysInstancedANGLE(r,n,o,a)},t.drawElementsInstanced=(r,n,o,a,h)=>{s.drawElementsInstancedANGLE(r,n,o,a,h)},t.vertexAttribDivisor=(r,n)=>s.vertexAttribDivisorANGLE(r,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const s=this.gl;this._activeGeometry=t;const r=this.getVao(t,e);this._activeVao!==r&&(this._activeVao=r,s.bindVertexArray(r)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let s=0;s<t.buffers.length;s++){const r=t.buffers[s];e.updateBuffer(r)}}checkCompatibility(t,e){const s=t.attributes,r=e._attributeData;for(const n in r)if(!s[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const s=t.attributes,r=e._attributeData,n=["g",t.uid];for(const o in s)r[o]&&n.push(o,r[o].location);return n.join("-")}getVao(t,e){var s;return((s=this._geometryVaoHash[t.uid])==null?void 0:s[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,s=!0){const r=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const o=this.getSignature(t,e);this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this));const a=this._geometryVaoHash[t.uid];let h=a[o];if(h)return a[e._key]=h,h;Yo(t,e._attributeData);const l=t.buffers;h=r.createVertexArray(),r.bindVertexArray(h);for(let u=0;u<l.length;u++){const c=l[u];n.bind(c)}return this.activateVao(t,e),a[e._key]=h,a[o]=h,r.bindVertexArray(null),h}onGeometryDestroy(t,e){const s=this._geometryVaoHash[t.uid],r=this.gl;if(s){if(e)for(const n in s)this._activeVao!==s[n]&&this.unbind(),r.deleteVertexArray(s[n]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const s in this._geometryVaoHash){if(t)for(const r in this._geometryVaoHash[s]){const n=this._geometryVaoHash[s];this._activeVao!==n&&this.unbind(),e.deleteVertexArray(n[r])}this._geometryVaoHash[s]=null}}activateVao(t,e){var a,h;const s=this._renderer.gl,r=this._renderer.buffer,n=t.attributes;t.indexBuffer&&r.bind(t.indexBuffer);let o=null;for(const l in n){const u=n[l],c=u.buffer,d=r.getGlBuffer(c),p=e._attributeData[l];if(p){o!==d&&(r.bind(c),o=d);const f=p.location;s.enableVertexAttribArray(f);const g=ve(u.format),m=ip(u.format);if(((a=p.format)==null?void 0:a.substring(1,4))==="int"?s.vertexAttribIPointer(f,g.size,m,u.stride,u.offset):s.vertexAttribPointer(f,g.size,m,g.normalised,u.stride,u.offset),u.instance)if(this.hasInstance){const _=(h=u.divisor)!=null?h:1;s.vertexAttribDivisor(f,_)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,s,r){const{gl:n}=this._renderer,o=this._activeGeometry,a=rp[o.topology||t];if(r||(r=o.instanceCount),o.indexBuffer){const h=o.indexBuffer.data.BYTES_PER_ELEMENT,l=h===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;r>1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,l,(s||0)*h,r):n.drawElements(a,e||o.indexBuffer.data.length,l,(s||0)*h)}else r>1?n.drawArraysInstanced(a,s||0,e||o.getSize(),r):n.drawArrays(a,s||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}qo.extension={type:[x.WebGLSystem],name:"geometry"};const np=new us({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Qi=class Hh{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:s}={...Hh.defaultOptions,...t};this.useBackBuffer=e,this._antialias=s,this._renderer.context.supports.msaa||(U("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Ct.for2d();const r=new be({vertex:`
                attribute vec2 aPosition;
                out vec2 vUv;

                void main() {
                    gl_Position = vec4(aPosition, 0.0, 1.0);

                    vUv = (aPosition + 1.0) / 2.0;

                    // flip dem UVs
                    vUv.y = 1.0 - vUv.y;
                }`,fragment:`
                in vec2 vUv;
                out vec4 finalColor;

                uniform sampler2D uTexture;

                void main() {
                    finalColor = texture(uTexture, vUv);
                }`,name:"big-triangle"});this._bigTriangleShader=new ft({glProgram:r,resources:{uTexture:C.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const s=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=s.colorTexture,t.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:np,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new C({source:new tt({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};Qi.extension={type:[x.WebGLSystem],name:"backBuffer",priority:1},Qi.defaultOptions={useBackBuffer:!1};let op=Qi;class Zo{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}Zo.extension={type:[x.WebGLSystem],name:"colorMask"};class Qo{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:s,shader:r,state:n,skipSync:o,topology:a,size:h,start:l,instanceCount:u}=t;e.shader.bind(r,o),e.geometry.bind(s,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,h,l,u!=null?u:s.instanceCount)}destroy(){this._renderer=null}}Qo.extension={type:[x.WebGLSystem],name:"encoder"};class ap{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const Vt=[];Vt[et.NONE]=void 0,Vt[et.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Vt[et.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Vt[et.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Vt[et.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};class Jo{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:et.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this._stencilCache.enabled=!1,this._stencilCache.stencilMode=et.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:et.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid],r=this._gl,n=Vt[t],o=this._stencilCache;if(s.stencilMode=t,s.stencilReference=e,t===et.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,r.disable(r.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,r.enable(r.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,r.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),r.stencilOp(r.KEEP,r.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}Jo.extension={type:[x.WebGLSystem],name:"stencil"};class ta{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!mn())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new bt({data:new Float32Array(e.layout.size/4),usage:W.UNIFORM|W.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let s=this._syncFunctionHash[e];if(!s){const r=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(r),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,s){const r=this.getUniformGroupData(t);return t.buffer||(t.buffer=new bt({data:new Float32Array(r.layout.size/4),usage:W.UNIFORM|W.COPY_DST})),e||(e=t.buffer.data),s||(s=0),r.syncFunction(t.uniforms,e,s),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const ea={f32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"mat2x2<f32>":16*2,"mat3x3<f32>":16*3,"mat4x4<f32>":16*4};function hp(i){const t=i.map(n=>({data:n,offset:0,size:0}));let e=0,s=0,r=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=ea[o.data.type],!e)throw new Error(`Unknown type ${o.data.type}`);if(o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.size=e,s%e!==0&&s<16){const a=s%e%16;s+=a,r+=a}s+e>16?(r=Math.ceil(r/16)*16,o.offset=r,r+=e,s=e):(o.offset=r,s+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}const $t=[{type:"mat3x3<f32>",test:i=>i.value.a!==void 0,ubo:`
            var matrix = uv[name].toArray(true);
            data[offset] = matrix[0];
            data[offset + 1] = matrix[1];
            data[offset + 2] = matrix[2];
            data[offset + 4] = matrix[3];
            data[offset + 5] = matrix[4];
            data[offset + 6] = matrix[5];
            data[offset + 8] = matrix[6];
            data[offset + 9] = matrix[7];
            data[offset + 10] = matrix[8];
        `,uniform:`
            gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
        `},{type:"vec4<f32>",test:i=>i.type==="vec4<f32>"&&i.size===1&&i.value.width!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.x;
            data[offset + 1] = v.y;
            data[offset + 2] = v.width;
            data[offset + 3] = v.height;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
                cv[0] = v.x;
                cv[1] = v.y;
                cv[2] = v.width;
                cv[3] = v.height;
                gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
            }
        `},{type:"vec2<f32>",test:i=>i.type==="vec2<f32>"&&i.size===1&&i.value.x!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.x;
            data[offset + 1] = v.y;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.x || cv[1] !== v.y) {
                cv[0] = v.x;
                cv[1] = v.y;
                gl.uniform2f(ud[name].location, v.x, v.y);
            }
        `},{type:"vec4<f32>",test:i=>i.type==="vec4<f32>"&&i.size===1&&i.value.red!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.red;
            data[offset + 1] = v.green;
            data[offset + 2] = v.blue;
            data[offset + 3] = v.alpha;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
                cv[0] = v.red;
                cv[1] = v.green;
                cv[2] = v.blue;
                cv[3] = v.alpha;
                gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
            }
        `},{type:"vec3<f32>",test:i=>i.type==="vec3<f32>"&&i.size===1&&i.value.red!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.red;
            data[offset + 1] = v.green;
            data[offset + 2] = v.blue;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
                cv[0] = v.red;
                cv[1] = v.green;
                cv[2] = v.blue;
                gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
            }
        `}];function sa(i,t,e,s){const r=[`
        var v = null;
        var v2 = null;
        var t = 0;
        var index = 0;
        var name = null;
        var arrayOffset = null;
    `];let n=0;for(let a=0;a<i.length;a++){const h=i[a],l=h.data.name;let u=!1,c=0;for(let d=0;d<$t.length;d++)if($t[d].test(h.data)){c=h.offset/4,r.push(`name = "${l}";`,`offset += ${c-n};`,$t[d][t]||$t[d].ubo),u=!0;break}if(!u)if(h.data.size>1)c=h.offset/4,r.push(e(h,c-n));else{const d=s[h.data.type];c=h.offset/4,r.push(`
                    v = uv.${l};
                    offset += ${c-n};
                    ${d};
                `)}n=c}const o=r.join(`
`);return new Function("uv","data","offset",o)}function ce(i,t){return`
        for (let i = 0; i < ${i*t}; i++) {
            data[offset + (((i / ${i})|0) * 4) + (i % ${i})] = v[i];
        }
    `}const ia={f32:`
        data[offset] = v;`,i32:`
        data[offset] = v;`,"vec2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];`,"vec3<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];`,"vec4<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 3] = v[3];`,"mat2x2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 4] = v[2];
        data[offset + 5] = v[3];`,"mat3x3<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 4] = v[3];
        data[offset + 5] = v[4];
        data[offset + 6] = v[5];
        data[offset + 8] = v[6];
        data[offset + 9] = v[7];
        data[offset + 10] = v[8];`,"mat4x4<f32>":`
        for (let i = 0; i < 16; i++) {
            data[offset + i] = v[i];
        }`,"mat3x2<f32>":ce(3,2),"mat4x2<f32>":ce(4,2),"mat2x3<f32>":ce(2,3),"mat4x3<f32>":ce(4,3),"mat2x4<f32>":ce(2,4),"mat3x4<f32>":ce(3,4)},lp={...ia,"mat2x2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 3] = v[3];
    `};function up(i,t){const e=Math.max(ea[i.data.type]/16,1),s=i.data.value.length/i.data.size,r=(4-s%4)%4;return`
        v = uv.${i.data.name};
        offset += ${t};

        arrayOffset = offset;

        t = 0;

        for(var i=0; i < ${i.data.size*e}; i++)
        {
            for(var j = 0; j < ${s}; j++)
            {
                data[arrayOffset++] = v[t++];
            }
            ${r!==0?`arrayOffset += ${r};`:""}
        }
    `}function cp(i){return sa(i,"uboStd40",up,ia)}class ra extends ta{constructor(){super({createUboElements:hp,generateUboSync:cp})}}ra.extension={type:[x.WebGLSystem],name:"ubo"};class dp{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new X}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new X}copyToTexture(t,e,s,r,n){const o=this._renderTargetSystem,a=this._renderer,h=o.getGpuRenderTarget(t),l=a.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,h.resolveTargetFramebuffer),a.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,n.x,n.y,s.x,s.y,r.width,r.height),e}startRenderPass(t,e=!0,s,r){const n=this._renderTargetSystem,o=t.colorTexture,a=n.getGpuRenderTarget(t);let h=r.y;t.isRoot&&(h=o.pixelHeight-r.height),t.colorTextures.forEach(c=>{this._renderer.texture.unbind(c)});const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,a.framebuffer);const u=this._viewPortCache;(u.x!==r.x||u.y!==h||u.width!==r.width||u.height!==r.height)&&(u.x=r.x,u.y=h,u.width=r.width,u.height=r.height,l.viewport(r.x,h,r.width,r.height)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,s)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,e.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,e.framebuffer),s.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer,s=e.gl,r=new ap;return t.colorTexture.resource===e.gl.canvas?(r.framebuffer=null,r):(this._initColor(t,r),s.bindFramebuffer(s.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(s=>{e.deleteRenderbuffer(s)}),t.msaaRenderBuffer=null}clear(t,e,s){if(!e)return;const r=this._renderTargetSystem;typeof e=="boolean"&&(e=e?ut.ALL:ut.NONE);const n=this._renderer.gl;if(e&ut.COLOR){s!=null||(s=r.defaultClearColor);const o=this._clearColorCache,a=s;(o[0]!==a[0]||o[1]!==a[1]||o[2]!==a[2]||o[3]!==a[3])&&(o[0]=a[0],o[1]=a[1],o[2]=a[2],o[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const s=this._renderer,r=s.gl,n=r.createFramebuffer();if(e.resolveTargetFramebuffer=n,r.bindFramebuffer(r.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{const h=o.source;h.antialias&&(s.context.supports.msaa?e.msaa=!0:U("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),s.texture.bindSource(h,0);const l=s.texture.getGlSource(h).texture;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+a,3553,l,0)}),e.msaa){const o=r.createFramebuffer();e.framebuffer=o,r.bindFramebuffer(r.FRAMEBUFFER,o),t.colorTextures.forEach((a,h)=>{const l=r.createRenderbuffer();e.msaaRenderBuffer[h]=l})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const s=t.colorTexture.source;if(e.width=s.pixelWidth,e.height=s.pixelHeight,t.colorTextures.forEach((r,n)=>{n!==0&&r.source.resize(s.width,s.height,s._resolution)}),e.msaa){const r=this._renderer,n=r.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,h)=>{const l=a.source;r.texture.bindSource(l,0);const u=r.texture.getGlSource(l).internalFormat,c=e.msaaRenderBuffer[h];n.bindRenderbuffer(n.RENDERBUFFER,c),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,u,l.pixelWidth,l.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+h,n.RENDERBUFFER,c)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,s=e.createRenderbuffer();t.depthStencilRenderBuffer=s,e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}}function pp(i,t,e,s,r,n){const o=n?1:-1;return i.identity(),i.a=1/s*2,i.d=o*(1/r*2),i.tx=-1-t*i.a,i.ty=-o-e*i.d,i}const Fe=new Map;function na(i,t){if(!Fe.has(i)){const e=new C({source:new Qt({resource:i,...t})}),s=()=>{Fe.get(i)===e&&Fe.delete(i)};e.once("destroy",s),e.source.once("destroy",s),Fe.set(i,e)}return Fe.get(i)}function fp(i){const t=i.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}const oa=class zh{constructor(t={}){if(this.uid=Q("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t={...zh.defaultOptions,...t},this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new tt({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(s=>s.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof C||t.depthStencilTexture instanceof tt?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new tt({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,s=this.resolution,r=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{r&&o===0||n.source.resize(t,e,s)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,s)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};oa.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Ji=oa;class aa{constructor(t){this.rootViewPort=new X,this.viewport=new X,this.onRenderTargetChange=new gn("onRenderTargetChange"),this.projectionMatrix=new R,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:s,frame:r}){this._renderTargetStack.length=0,this.push(t,e,s,r),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=fp(this.rootRenderTarget)}bind(t,e=!0,s,r){const n=this.getRenderTarget(t),o=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const a=this.getGpuRenderTarget(n);(n.pixelWidth!==a.width||n.pixelHeight!==a.height)&&(this.adaptor.resizeGpuRenderTarget(n),a.width=n.pixelWidth,a.height=n.pixelHeight);const h=n.colorTexture,l=this.viewport,u=h.pixelWidth,c=h.pixelHeight;if(!r&&t instanceof C&&(r=t.frame),r){const d=h._resolution;l.x=r.x*d+.5|0,l.y=r.y*d+.5|0,l.width=r.width*d+.5|0,l.height=r.height*d+.5|0}else l.x=0,l.y=0,l.width=u,l.height=c;return pp(this.projectionMatrix,0,0,l.width/h.resolution,l.height/h.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,s,l),o&&this.onRenderTargetChange.emit(n),n}clear(t,e=ut.ALL,s){!e||(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,s,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=ut.ALL,s,r){const n=this.bind(t,e,s,r);return this._renderTargetStack.push({renderTarget:n,frame:r}),n}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?e:this._initRenderTarget(t)}copyToTexture(t,e,s,r,n){s.x<0&&(r.width+=s.x,n.x-=s.x,s.x=0),s.y<0&&(r.height+=s.y,n.y-=s.y,s.y=0);const{pixelWidth:o,pixelHeight:a}=t;return r.width=Math.min(r.width,o-s.x),r.height=Math.min(r.height,a-s.y),this.adaptor.copyToTexture(t,e,s,r,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Qt.test(t)&&(t=na(t).source),t instanceof Ji?e=t:t instanceof tt&&(e=new Ji({colorTextures:[t]}),Qt.test(t.source.resource)&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const s=this._gpuRenderTargetHash[e.uid];s&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(s))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}}class ha extends aa{constructor(t){super(t),this.adaptor=new dp,this.adaptor.init(t,this)}}ha.extension={type:[x.WebGLSystem],name:"renderTarget"};class tr extends dt{constructor({buffer:t,offset:e,size:s}){super(),this.uid=Q("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=Q("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=Q("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function mp(i,t){const e=[],s=[`
        var g = s.groups;
        var sS = r.shader;
        var p = s.glProgram;
        var ugS = r.uniformGroup;
        var resources;
    `];let r=!1,n=0,o=0;const a=t._getProgramData(i.glProgram);for(const l in i.groups){const u=i.groups[l];e.push(`
            resources = g[${l}].resources;
        `);for(const c in u.resources){const d=u.resources[c];if(d instanceof at)d.ubo?e.push(`
                        sS.bindUniformBlock(
                            resources[${c}],
                            sS._uniformBindMap[${l}[${c}],
                            ${n++}
                        );
                    `):e.push(`
                        ugS.updateUniformGroup(resources[${c}], p, sD);
                    `);else if(d instanceof tr)e.push(`
                    sS.bindUniformBlock(
                        resources[${c}],
                        sS._uniformBindMap[${l}[${c}],
                        ${n++}
                    );
                `);else if(d instanceof tt){const p=i._uniformBindMap[l][c],f=a.uniformData[p];f&&(r||(r=!0,s.push(`
                        var tS = r.texture;
                        `)),t._gl.uniform1i(f.location,o),e.push(`
                        tS.bind(resources[${c}], ${o});
                    `),o++)}}}const h=[...s,...e].join(`
`);return new Function("r","s","sD",h)}class gp{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function la(i,t,e){const s=i.createShader(t);return i.shaderSource(s,e),i.compileShader(s),s}function er(i){const t=new Array(i);for(let e=0;e<t.length;e++)t[e]=!1;return t}function ua(i,t){switch(i){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return er(2*t);case"bvec3":return er(3*t);case"bvec4":return er(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let Ts=null;const ca={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},_p={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function da(i,t){if(!Ts){const e=Object.keys(ca);Ts={};for(let s=0;s<e.length;++s){const r=e[s];Ts[i[r]]=ca[r]}}return Ts[t]}function xp(i,t){const e=da(i,t);return _p[e]||"float32"}function yp(i,t,e=!1){const s={},r=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES);for(let o=0;o<r;o++){const a=t.getActiveAttrib(i,o);if(a.name.startsWith("gl_"))continue;const h=xp(t,a.type);s[a.name]={location:0,format:h,stride:ve(h).stride,offset:0,instance:!1,start:0}}const n=Object.keys(s);if(e){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)s[n[o]].location=o,t.bindAttribLocation(i,o,n[o]);t.linkProgram(i)}else for(let o=0;o<n.length;o++)s[n[o]].location=t.getAttribLocation(i,n[o]);return s}function bp(i,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},s=t.getProgramParameter(i,t.ACTIVE_UNIFORM_BLOCKS);for(let r=0;r<s;r++){const n=t.getActiveUniformBlockName(i,r),o=t.getUniformBlockIndex(i,n),a=t.getActiveUniformBlockParameter(i,r,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:o,size:a}}return e}function vp(i,t){const e={},s=t.getProgramParameter(i,t.ACTIVE_UNIFORMS);for(let r=0;r<s;r++){const n=t.getActiveUniform(i,r),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),h=da(t,n.type);e[o]={name:o,index:r,type:h,size:n.size,isArray:a,value:ua(h,n.size)}}return e}function pa(i,t){const e=i.getShaderSource(t).split(`
`).map((l,u)=>`${u}: ${l}`),s=i.getShaderInfoLog(t),r=s.split(`
`),n={},o=r.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),a=[""];o.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
`);a[0]=h,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Tp(i,t,e,s){i.getProgramParameter(t,i.LINK_STATUS)||(i.getShaderParameter(e,i.COMPILE_STATUS)||pa(i,e),i.getShaderParameter(s,i.COMPILE_STATUS)||pa(i,s),console.error("PixiJS Error: Could not initialize shader."),i.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",i.getProgramInfoLog(t)))}function Sp(i,t){const e=la(i,i.VERTEX_SHADER,t.vertex),s=la(i,i.FRAGMENT_SHADER,t.fragment),r=i.createProgram();i.attachShader(r,e),i.attachShader(r,s);const n=t.transformFeedbackVaryings;n&&(typeof i.transformFeedbackVaryings!="function"?U("TransformFeedback is not supported but TransformFeedbackVaryings are given."):i.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?i.SEPARATE_ATTRIBS:i.INTERLEAVED_ATTRIBS)),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS)||Tp(i,r,e,s),t._attributeData=yp(r,i,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=vp(r,i),t._uniformBlockData=bp(r,i),i.deleteShader(e),i.deleteShader(s);const o={};for(const a in t._uniformData){const h=t._uniformData[a];o[a]={location:i.getUniformLocation(r,a),value:ua(h.type,h.size)}}return new gp(r,o)}const Ss={textureCount:0,blockIndex:0};class fa{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._nextIndex=0,this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._maxBindings=t.MAX_UNIFORM_BUFFER_BINDINGS?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null,this.maxTextures=kt()}bind(t,e){if(this._setProgram(t.glProgram),e)return;Ss.textureCount=0,Ss.blockIndex=0;let s=this._shaderSyncFunctions[t.glProgram._key];s||(s=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),s(this._renderer,t,Ss)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Ss)}bindUniformBlock(t,e,s=0){const r=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o&&this._renderer.ubo.updateUniformGroup(t),r.updateBuffer(t.buffer);let a=this._boundUniformsIdsToIndexHash[t.uid];if(a===void 0){const u=this._nextIndex++%this._maxBindings,c=this._boundIndexToUniformsHash[u];c&&(this._boundUniformsIdsToIndexHash[c.uid]=void 0),a=this._boundUniformsIdsToIndexHash[t.uid]=u,this._boundIndexToUniformsHash[u]=t,o?r.bindBufferRange(t.buffer,u,t.offset):r.bindBufferBase(t.buffer,u)}const h=this._gl,l=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[s]!==a&&(n.uniformBlockBindings[s]=a,h.uniformBlockBinding(n.program,l,a))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=Sp(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(t,e){return mp(t,e)}}fa.extension={type:[x.WebGLSystem],name:"shader"};const wp={f32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1f(location, v);
        }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2f(location, v[0], v[1]);
        }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3f(location, v[0], v[1], v[2]);
        }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4f(location, v[0], v[1], v[2], v[3]);
        }`,i32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,u32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1ui(location, v);
        }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2ui(location, v[0], v[1]);
        }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3ui(location, v[0], v[1], v[2]);
        }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
        }`,bool:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},Ep={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};function Ap(i,t){const e=[`
        var v = null;
        var cv = null;
        var cu = null;
        var t = 0;
        var gl = renderer.gl;
        var name = null;
    `];for(const s in i.uniforms){if(!t[s]){i.uniforms[s]instanceof at?i.uniforms[s].ubo?e.push(`
                        renderer.shader.bindUniformBlock(uv.${s}, "${s}");
                    `):e.push(`
                        renderer.shader.updateUniformGroup(uv.${s});
                    `):i.uniforms[s]instanceof tr&&e.push(`
                        renderer.shader.bindBufferResource(uv.${s}, "${s}");
                    `);continue}const r=i.uniformStructures[s];let n=!1;for(let o=0;o<$t.length;o++){const a=$t[o];if(r.type===a.type&&a.test(r)){e.push(`name = "${s}";`,$t[o].uniform),n=!0;break}}if(!n){const o=(r.size===1?wp:Ep)[r.type].replace("location",`ud["${s}"].location`);e.push(`
            cu = ud["${s}"];
            cv = cu.value;
            v = uv["${s}"];
            ${o};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
`))}class ma{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,s){const r=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==r.uniformDirtyGroups[t.uid])&&(r.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(r.uniformData,t.uniforms,this._renderer,s))}_getUniformSyncFunction(t,e){var s;return((s=this._uniformGroupSyncHash[t._signature])==null?void 0:s[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const s=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),r=this._getSignature(t,e._uniformData,"u");return this._cache[r]||(this._cache[r]=this._generateUniformsSync(t,e._uniformData)),s[e._key]=this._cache[r],s[e._key]}_generateUniformsSync(t,e){return Ap(t,e)}_getSignature(t,e,s){const r=t.uniforms,n=[`${s}-`];for(const o in r)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}ma.extension={type:[x.WebGLSystem],name:"uniformGroup"};function Pp(i){const t={};if(t.normal=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t.add=[i.ONE,i.ONE],t.multiply=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t.screen=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t["screen-npm"]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t.erase=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],!(i instanceof N.get().getWebGLRenderingContext()))t.min=[i.ONE,i.ONE,i.ONE,i.ONE,i.MIN,i.MIN],t.max=[i.ONE,i.ONE,i.ONE,i.ONE,i.MAX,i.MAX];else{const e=i.getExtension("EXT_blend_minmax");e&&(t.min=[i.ONE,i.ONE,i.ONE,i.ONE,e.MIN_EXT,e.MIN_EXT],t.max=[i.ONE,i.ONE,i.ONE,i.ONE,e.MAX_EXT,e.MAX_EXT])}return t}const Cp=0,Mp=1,Rp=2,Bp=3,kp=4,Ip=5,ga=class Er{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[Cp]=this.setBlend,this.map[Mp]=this.setOffset,this.map[Rp]=this.setCullFace,this.map[Bp]=this.setDepthTest,this.map[kp]=this.setFrontFace,this.map[Ip]=this.setDepthMask,this.checks=[],this.defaultState=Ct.for2d()}contextChange(t){this.gl=t,this.blendModesMap=Pp(t),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,s=0;for(;e;)e&1&&this.map[s].call(this,!!(t.data&1<<s)),e=e>>1,s++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this._updateCheck(Er._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(Er._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],s=this.gl;e.length===2?s.blendFunc(e[0],e[1]):s.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,s.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,s.blendEquationSeparate(s.FUNC_ADD,s.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const s=this.checks.indexOf(t);e&&s===-1?this.checks.push(t):!e&&s!==-1&&this.checks.splice(s,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};ga.extension={type:[x.WebGLSystem],name:"state"};let Gp=ga;class Up{constructor(t){this.target=jo.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=z.UNSIGNED_BYTE,this.internalFormat=Zi.RGBA,this.format=Zi.RGBA,this.samplerType=0}}const Fp={id:"buffer",upload(i,t,e){t.width===i.width||t.height===i.height?e.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,t.format,t.type,i.resource):e.texImage2D(t.target,0,t.internalFormat,i.width,i.height,0,t.format,t.type,i.resource),t.width=i.width,t.height=i.height}},Op={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},Dp={id:"compressed",upload(i,t,e){e.pixelStorei(e.UNPACK_ALIGNMENT,4);let s=i.pixelWidth,r=i.pixelHeight;const n=!!Op[i.format];for(let o=0;o<i.resource.length;o++){const a=i.resource[o];n?e.compressedTexImage2D(e.TEXTURE_2D,o,t.internalFormat,s,r,0,a):e.texImage2D(e.TEXTURE_2D,o,t.internalFormat,s,r,0,t.format,t.type,a),s=Math.max(s>>1,1),r=Math.max(r>>1,1)}}},_a={id:"image",upload(i,t,e,s){const r=i.alphaMode==="premultiply-alpha-on-upload";e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r);const n=t.width,o=t.height,a=i.pixelWidth,h=i.pixelHeight,l=i.resourceWidth,u=i.resourceHeight;l<a||u<h?((n!==a||o!==h)&&e.texImage2D(t.target,0,t.internalFormat,a,h,0,t.format,t.type,null),s===2?e.texSubImage2D(e.TEXTURE_2D,0,0,0,l,u,t.format,t.type,i.resource):e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,i.resource)):n===a||o===h?e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,i.resource):s===2?e.texImage2D(t.target,0,t.internalFormat,a,h,0,t.format,t.type,i.resource):e.texImage2D(t.target,0,t.internalFormat,t.format,t.type,i.resource),t.width=a,t.height=h}},Lp={id:"video",upload(i,t,e,s){if(!i.isValid){e.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null);return}_a.upload(i,t,e,s)}},xa={linear:9729,nearest:9728},Np={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},sr={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Hp={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function ya(i,t,e,s,r,n,o,a){const h=n;if(!a||i.addressModeU!=="repeat"||i.addressModeV!=="repeat"||i.addressModeW!=="repeat"){const l=sr[o?"clamp-to-edge":i.addressModeU],u=sr[o?"clamp-to-edge":i.addressModeV],c=sr[o?"clamp-to-edge":i.addressModeW];t[r](h,t.TEXTURE_WRAP_S,l),t[r](h,t.TEXTURE_WRAP_T,u),t.TEXTURE_WRAP_R&&t[r](h,t.TEXTURE_WRAP_R,c)}if((!a||i.magFilter!=="linear")&&t[r](h,t.TEXTURE_MAG_FILTER,xa[i.magFilter]),e){if(!a||i.mipmapFilter!=="linear"){const l=Np[i.minFilter][i.mipmapFilter];t[r](h,t.TEXTURE_MIN_FILTER,l)}}else t[r](h,t.TEXTURE_MIN_FILTER,xa[i.minFilter]);if(s&&i.maxAnisotropy>1){const l=Math.min(i.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[r](h,s.TEXTURE_MAX_ANISOTROPY_EXT,l)}i.compare&&t[r](h,t.TEXTURE_COMPARE_FUNC,Hp[i.compare])}function zp(i){return{r8unorm:i.RED,r8snorm:i.RED,r8uint:i.RED,r8sint:i.RED,r16uint:i.RED,r16sint:i.RED,r16float:i.RED,rg8unorm:i.RG,rg8snorm:i.RG,rg8uint:i.RG,rg8sint:i.RG,r32uint:i.RED,r32sint:i.RED,r32float:i.RED,rg16uint:i.RG,rg16sint:i.RG,rg16float:i.RG,rgba8unorm:i.RGBA,"rgba8unorm-srgb":i.RGBA,rgba8snorm:i.RGBA,rgba8uint:i.RGBA,rgba8sint:i.RGBA,bgra8unorm:i.RGBA,"bgra8unorm-srgb":i.RGBA,rgb9e5ufloat:i.RGB,rgb10a2unorm:i.RGBA,rg11b10ufloat:i.RGB,rg32uint:i.RG,rg32sint:i.RG,rg32float:i.RG,rgba16uint:i.RGBA,rgba16sint:i.RGBA,rgba16float:i.RGBA,rgba32uint:i.RGBA,rgba32sint:i.RGBA,rgba32float:i.RGBA,stencil8:i.STENCIL_INDEX8,depth16unorm:i.DEPTH_COMPONENT,depth24plus:i.DEPTH_COMPONENT,"depth24plus-stencil8":i.DEPTH_STENCIL,depth32float:i.DEPTH_COMPONENT,"depth32float-stencil8":i.DEPTH_STENCIL}}function Wp(i,t){let e={},s=i.RGBA;return i instanceof N.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":i.SRGB8_ALPHA8,"bgra8unorm-srgb":i.SRGB8_ALPHA8},s=i.RGBA8),{r8unorm:i.R8,r8snorm:i.R8_SNORM,r8uint:i.R8UI,r8sint:i.R8I,r16uint:i.R16UI,r16sint:i.R16I,r16float:i.R16F,rg8unorm:i.RG8,rg8snorm:i.RG8_SNORM,rg8uint:i.RG8UI,rg8sint:i.RG8I,r32uint:i.R32UI,r32sint:i.R32I,r32float:i.R32F,rg16uint:i.RG16UI,rg16sint:i.RG16I,rg16float:i.RG16F,rgba8unorm:i.RGBA,...e,rgba8snorm:i.RGBA8_SNORM,rgba8uint:i.RGBA8UI,rgba8sint:i.RGBA8I,bgra8unorm:s,rgb9e5ufloat:i.RGB9_E5,rgb10a2unorm:i.RGB10_A2,rg11b10ufloat:i.R11F_G11F_B10F,rg32uint:i.RG32UI,rg32sint:i.RG32I,rg32float:i.RG32F,rgba16uint:i.RGBA16UI,rgba16sint:i.RGBA16I,rgba16float:i.RGBA16F,rgba32uint:i.RGBA32UI,rgba32sint:i.RGBA32I,rgba32float:i.RGBA32F,stencil8:i.STENCIL_INDEX8,depth16unorm:i.DEPTH_COMPONENT16,depth24plus:i.DEPTH_COMPONENT24,"depth24plus-stencil8":i.DEPTH24_STENCIL8,depth32float:i.DEPTH_COMPONENT32F,"depth32float-stencil8":i.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function Vp(i){return{r8unorm:i.UNSIGNED_BYTE,r8snorm:i.BYTE,r8uint:i.UNSIGNED_BYTE,r8sint:i.BYTE,r16uint:i.UNSIGNED_SHORT,r16sint:i.SHORT,r16float:i.HALF_FLOAT,rg8unorm:i.UNSIGNED_BYTE,rg8snorm:i.BYTE,rg8uint:i.UNSIGNED_BYTE,rg8sint:i.BYTE,r32uint:i.UNSIGNED_INT,r32sint:i.INT,r32float:i.FLOAT,rg16uint:i.UNSIGNED_SHORT,rg16sint:i.SHORT,rg16float:i.HALF_FLOAT,rgba8unorm:i.UNSIGNED_BYTE,"rgba8unorm-srgb":i.UNSIGNED_BYTE,rgba8snorm:i.BYTE,rgba8uint:i.UNSIGNED_BYTE,rgba8sint:i.BYTE,bgra8unorm:i.UNSIGNED_BYTE,"bgra8unorm-srgb":i.UNSIGNED_BYTE,rgb9e5ufloat:i.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:i.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:i.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:i.UNSIGNED_INT,rg32sint:i.INT,rg32float:i.FLOAT,rgba16uint:i.UNSIGNED_SHORT,rgba16sint:i.SHORT,rgba16float:i.HALF_FLOAT,rgba32uint:i.UNSIGNED_INT,rgba32sint:i.INT,rgba32float:i.FLOAT,stencil8:i.UNSIGNED_BYTE,depth16unorm:i.UNSIGNED_SHORT,depth24plus:i.UNSIGNED_INT,"depth24plus-stencil8":i.UNSIGNED_INT_24_8,depth32float:i.FLOAT,"depth32float-stencil8":i.FLOAT_32_UNSIGNED_INT_24_8_REV}}const $p=4;class ba{constructor(t){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:_a,buffer:Fp,video:Lp,compressed:Dp},this._useSeparateSamplers=!1,this._renderer=t}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Wp(t,this._renderer.context.extensions),this._mapFormatToType=Vp(t),this._mapFormatToFormat=zp(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null);for(let e=0;e<16;e++)this.bind(C.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const s=t.source;t?(this.bindSource(s,e),this._useSeparateSamplers&&this._bindSampler(s.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const s=this._gl;if(t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t=t||C.EMPTY.source;const r=this.getGlSource(t);s.bindTexture(r.target,r.texture)}}_bindSampler(t,e=0){const s=this._gl;if(!t){this._boundSamplers[e]=null,s.bindSampler(e,null);return}const r=this._getGlSampler(t);this._boundSamplers[e]!==r&&(this._boundSamplers[e]=r,s.bindSampler(e,r))}unbind(t){const e=t.source,s=this._boundTextures,r=this._gl;for(let n=0;n<s.length;n++)if(s[n]===e){this._activateLocation(n);const o=this.getGlSource(e);r.bindTexture(o.target,null),s[n]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,s=new Up(e.createTexture());if(s.type=this._mapFormatToType[t.format],s.internalFormat=this._mapFormatToInternalFormat[t.format],s.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const r=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(r))+1}return this._glTextures[t.uid]=s,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),this.updateStyle(t,!1),s}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const s=this._gl,r=this.getGlSource(t);s.bindTexture(s.TEXTURE_2D,r.texture),this._boundTextures[this._activeTextureLocation]=t,ya(t.style,s,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",s.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];!e||(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,s=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,s,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const s=this.getGlSource(t);this._gl.generateMipmap(s.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,ya(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:s,height:r}=this.getPixels(t),n=N.get().createCanvas();n.width=s,n.height=r;const o=n.getContext("2d");if(o){const a=o.createImageData(s,r);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,s=t.frame,r=Math.max(Math.round(s.width*e),1),n=Math.max(Math.round(s.height*e),1),o=new Uint8Array($p*r*n),a=this._renderer,h=a.renderTarget.getRenderTarget(t),l=a.renderTarget.getGpuRenderTarget(h),u=a.gl;return u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),u.readPixels(Math.round(s.x*e),Math.round(s.y*e),r,n,u.RGBA,u.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:r,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}}ba.extension={type:[x.WebGLSystem],name:"texture"};class va{init(){const t=new at({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new R,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),e=kt(),s=ke({name:"graphics",bits:[Wi,Yi(e),Ki,Ge]});this.shader=new ft({glProgram:s,resources:{localUniforms:t,batchSamplers:ji(e)}})}execute(t,e){const s=e.context,r=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{geometry:a,instructions:h}=o.getContextRenderData(s);r.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(r),n.geometry.bind(a,r.glProgram);const l=h.instructions;for(let u=0;u<h.instructionSize;u++){const c=l[u];if(c.size){for(let d=0;d<c.textures.count;d++)n.texture.bind(c.textures.textures[d],d);n.geometry.draw("triangle-list",c.size,c.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}va.extension={type:[x.WebGLPipesAdaptor],name:"graphics"};class Ta{init(){const t=ke({name:"mesh",bits:[Ki,Kd,Ge]});this._shader=new ft({glProgram:t,resources:{uTexture:C.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new R}}}})}execute(t,e){const s=t.renderer;let r=e._shader;if(r){if(!r.glProgram){U("Mesh shader has no glProgram",e.shader);return}}else{r=this._shader;const n=e.texture,o=n.source;r.resources.uTexture=o,r.resources.uSampler=o.style,r.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}r.groups[100]=s.globalUniforms.bindGroup,r.groups[101]=t.localUniformsBindGroup,s.encoder.draw({geometry:e._geometry,shader:r,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Ta.extension={type:[x.WebGLPipesAdaptor],name:"mesh"};class Sa{constructor(t){this._renderer=t}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){!t.isRenderable||t.render(this._renderer)}destroy(){this._renderer=null}}Sa.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"customRender"};function wa(i,t){const e=i.instructionSet,s=e.instructions;for(let r=0;r<e.instructionSize;r++){const n=s[r];t[n.renderPipeId].execute(n)}}class Ea{constructor(t){this._renderer=t}addRenderGroup(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){!t.isRenderable||(this._renderer.globalUniforms.push({worldTransformMatrix:t.worldTransform,worldColor:t.worldColorAlpha}),wa(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop())}destroy(){this._renderer=null}}Ea.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"renderGroup"};function ir(i,t){t||(t=0);for(let e=t;e<i.length&&i[e];e++)i[e]=null}function Aa(i,t=[]){t.push(i);for(let e=0;e<i.renderGroupChildren.length;e++)Aa(i.renderGroupChildren[e],t);return t}function Xp(i,t,e){const s=i>>16&255,r=i>>8&255,n=i&255,o=t>>16&255,a=t>>8&255,h=t&255,l=s+(o-s)*e,u=r+(a-r)*e,c=n+(h-n)*e;return(l<<16)+(u<<8)+c}const rr=16777215;function Pa(i,t){return i===rr||t===rr?i+t-rr:Xp(i,t,.5)}const Yp=new J,Ca=me|ts|js;function Ma(i,t=!1){jp(i);const e=i.childrenToUpdate,s=i.updateTick++;for(const r in e){const n=Number(r),o=e[r],a=o.list,h=o.index;for(let l=0;l<h;l++){const u=a[l];u.parentRenderGroup===i&&u.relativeRenderGroupDepth===n&&Ra(u,s,0)}ir(a,h),o.index=0}if(t)for(let r=0;r<i.renderGroupChildren.length;r++)Ma(i.renderGroupChildren[r],t)}function jp(i){const t=i.root;let e;if(i.renderGroupParent){const s=i.renderGroupParent;i.worldTransform.appendFrom(t.relativeGroupTransform,s.worldTransform),i.worldColor=Pa(t.groupColor,s.worldColor),e=t.groupAlpha*s.worldAlpha}else i.worldTransform.copyFrom(t.localTransform),i.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,i.worldAlpha=e,i.worldColorAlpha=i.worldColor+((e*255|0)<<24)}function Ra(i,t,e){if(t===i.updateTick)return;i.updateTick=t,i.didChange=!1;const s=i.localTransform;i.updateLocalTransform();const r=i.parent;if(r&&!r.renderGroup?(e=e|i._updateFlags,i.relativeGroupTransform.appendFrom(s,r.relativeGroupTransform),e&Ca&&Ba(i,r,e)):(e=i._updateFlags,i.relativeGroupTransform.copyFrom(s),e&Ca&&Ba(i,Yp,e)),!i.renderGroup){const n=i.children,o=n.length;for(let h=0;h<o;h++)Ra(n[h],t,e);const a=i.parentRenderGroup;i.renderPipeId&&!a.structureDidChange&&a.updateRenderable(i)}}function Ba(i,t,e){if(e&ts){i.groupColor=Pa(i.localColor,t.groupColor);let s=i.localAlpha*t.groupAlpha;s=s<0?0:s>1?1:s,i.groupAlpha=s,i.groupColorAlpha=i.groupColor+((s*255|0)<<24)}e&js&&(i.groupBlendMode=i.localBlendMode==="inherit"?t.groupBlendMode:i.localBlendMode),e&me&&(i.globalDisplayStatus=i.localDisplayStatus&t.globalDisplayStatus),i._updateFlags=0}function Kp(i,t){const{list:e,index:s}=i.childrenRenderablesToUpdate;let r=!1;for(let n=0;n<s;n++){const o=e[n];if(r=t[o.renderPipeId].validateRenderable(o),r)break}return i.structureDidChange=r,r}const qp=new R;class ka{constructor(t){this._renderer=t}render({container:t,transform:e}){t.isRenderGroup=!0;const s=t.parent,r=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,o=Aa(t.renderGroup,[]);let a=qp;e&&(a=a.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const h=n.renderPipes;for(let l=0;l<o.length;l++){const u=o[l];u.runOnRender(),u.instructionSet.renderPipes=h,u.structureDidChange?ir(u.childrenRenderablesToUpdate.list,0):Kp(u,h),Ma(u),u.structureDidChange?(u.structureDidChange=!1,qd(u,n)):Zp(u),u.childrenRenderablesToUpdate.index=0,n.renderPipes.batch.upload(u.instructionSet)}n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),wa(t.renderGroup,h),h.uniformBatch&&h.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(a),t.parent=s,t.renderGroup.renderGroupParent=r}destroy(){this._renderer=null}}ka.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"renderGroup"};function Zp(i){const{list:t,index:e}=i.childrenRenderablesToUpdate;for(let s=0;s<e;s++){const r=t[s];r.didViewUpdate&&i.updateRenderable(r)}ir(t,e)}class nr{constructor(){this.vertexSize=4,this.indexSize=6,this.location=0,this.batcher=null,this.batch=null,this.roundPixels=0}get blendMode(){return this.renderable.groupBlendMode}packAttributes(t,e,s,r){const n=this.renderable,o=this.texture,a=n.groupTransform,h=a.a,l=a.b,u=a.c,c=a.d,d=a.tx,p=a.ty,f=this.bounds,g=f.maxX,m=f.minX,_=f.maxY,y=f.minY,b=o.uvs,v=n.groupColorAlpha,T=r<<16|this.roundPixels&65535;t[s+0]=h*m+u*y+d,t[s+1]=c*y+l*m+p,t[s+2]=b.x0,t[s+3]=b.y0,e[s+4]=v,e[s+5]=T,t[s+6]=h*g+u*y+d,t[s+7]=c*y+l*g+p,t[s+8]=b.x1,t[s+9]=b.y1,e[s+10]=v,e[s+11]=T,t[s+12]=h*g+u*_+d,t[s+13]=c*_+l*g+p,t[s+14]=b.x2,t[s+15]=b.y2,e[s+16]=v,e[s+17]=T,t[s+18]=h*m+u*_+d,t[s+19]=c*_+l*m+p,t[s+20]=b.x3,t[s+21]=b.y3,e[s+22]=v,e[s+23]=T}packIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}reset(){this.renderable=null,this.texture=null,this.batcher=null,this.batch=null,this.bounds=null}}class Ia{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t}addRenderable(t,e){const s=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,s=this._getGpuSprite(t);return s.texture._source!==e._source?!s.batcher.checkAndUpdateTexture(s,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];L.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.bounds=t.bounds,e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=L.get(nr);return e.renderable=t,e.texture=t._texture,e.bounds=t.bounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t._didSpriteUpdate=!1,t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuSpriteHash)L.return(this._gpuSpriteHash[t]);this._gpuSpriteHash=null,this._renderer=null}}Ia.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"sprite"};const or=class Wh{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new V(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...Wh.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};or.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"background",priority:0},or.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Qp=or;const Oe={};F.handle(x.BlendMode,i=>{if(!i.name)throw new Error("BlendMode extension must have a name property");Oe[i.name]=i.ref},i=>{delete Oe[i.name]});class Ga{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t}setBlendMode(t,e,s){if(this._activeBlendMode===e){this._isAdvanced&&this._renderableList.push(t);return}this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(s),this._isAdvanced=!!Oe[e],this._isAdvanced&&(this._beginAdvancedBlendMode(s),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!Oe[e]){U(`Unable to assign BlendMode: '${e}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let s=this._filterHash[e];s||(s=this._filterHash[e]=new Qe,s.filters=[new Oe[e]]);const r={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:s,canBundle:!1};this._renderableList=r.renderables,t.add(r)}_endAdvancedBlendMode(t){this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}Ga.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"blendMode"};const ar={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},hr=class Vh{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof J||t instanceof C?{target:t,...e}:{...e,...t}}async image(t){const e=new Image;return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,Vh.defaultImageOptions);const{format:e,quality:s}=t,r=this.canvas(t);if(r.toBlob!==void 0)return new Promise((n,o)=>{r.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>n(h.result),h.onerror=o,h.readAsDataURL(a)},ar[e],s)});if(r.toDataURL!==void 0)return r.toDataURL(ar[e],s);if(r.convertToBlob!==void 0){const n=await r.convertToBlob({type:ar[e],quality:s});return new Promise((o,a)=>{const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer;if(e instanceof C)return s.texture.generateCanvas(e);const r=s.textureGenerator.generateTexture(t),n=s.texture.generateCanvas(r);return r.destroy(),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer,r=e instanceof C?e:s.textureGenerator.generateTexture(t),n=s.texture.getPixels(r);return e instanceof J&&r.destroy(),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof C?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var r;t=this._normalizeOptions(t);const e=this.canvas(t),s=document.createElement("a");s.download=(r=t.filename)!=null?r:"image.png",s.href=e.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){var o;const e=(o=t.width)!=null?o:200;t=this._normalizeOptions(t);const s=this.canvas(t),r=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const n=["font-size: 1px;",`padding: ${e}px ${300}px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};hr.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"extract"},hr.defaultImageOptions={format:"png",quality:1};let Jp=hr;class lr extends C{static create(t){return new lr({source:new tt(t)})}resize(t,e,s){return this.source.resize(t,e,s),this}}const tf=new X,ef=new nt,sf=[0,0,0,0];class Ua{constructor(t){this._renderer=t}generateTexture(t){var l;t instanceof J&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,s=t.antialias||this._renderer.view.antialias,r=t.target;let n=t.clearColor;n?n=Array.isArray(n)&&n.length===4?n:V.shared.setValue(n).toArray():n=sf;const o=((l=t.frame)==null?void 0:l.copyTo(tf))||Vs(r,ef).rectangle;o.width=Math.max(o.width,1/e)|0,o.height=Math.max(o.height,1/e)|0;const a=lr.create({...t.textureSourceOptions,width:o.width,height:o.height,resolution:e,antialias:s}),h=R.shared.translate(-o.x,-o.y);return this._renderer.render({container:r,transform:h,target:a,clearColor:n}),a.source.updateMipmaps(),a}destroy(){this._renderer=null}}Ua.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"textureGenerator"};function ws(i,t,e){const s=(i>>24&255)/255;t[e++]=(i&255)/255*s,t[e++]=(i>>8&255)/255*s,t[e++]=(i>>16&255)/255*s,t[e++]=s}class Fa{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:s,worldColor:r,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new R,worldColor:4294967295,offset:new $},h={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:s||a.worldTransformMatrix,worldColor:r||a.worldColor,offset:n||a.offset,bindGroup:null},l=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(l);const u=l.uniforms;u.uProjectionMatrix=h.projectionMatrix,u.uResolution=h.resolution,u.uWorldTransformMatrix.copyFrom(h.worldTransformMatrix),u.uWorldTransformMatrix.tx-=h.offset.x,u.uWorldTransformMatrix.ty-=h.offset.y,ws(h.worldColor,u.uWorldColorAlpha,0),l.update();let c;this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(l,!1):(c=this._bindGroupPool.pop()||new Pt,this._activeBindGroups.push(c),c.setResource(l,0)),h.bindGroup=c,this._currentGlobalUniformData=h}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===yt.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new at({uProjectionMatrix:{value:new R,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new R,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}Fa.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"globalUniforms"};let rf=1;class Oa{constructor(){this._tasks=[]}init(){ot.system.add(this._update,this)}repeat(t,e){const s=rf++;return this._tasks.push({func:t,duration:e,start:performance.now(),last:performance.now(),repeat:!0,id:s}),s}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t){this._tasks.splice(e,1);return}}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const s=this._tasks[e];if(t-s.last>=s.duration){const r=t-s.start;s.func(r),s.last=t}}}destroy(){ot.system.remove(this._update,this),this._tasks.length=0}}Oa.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"scheduler",priority:0};let Da=!1;const La="8.3.4";function nf(i){if(!Da){if(N.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c  %c  %c  %c  %c PixiJS %c v${La} (${i}) http://www.pixijs.com/

`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${La} - ${i} - http://www.pixijs.com/`);Da=!0}}class ur{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===yt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),nf(e)}}}ur.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"hello",priority:-2},ur.defaultOptions={hello:!1};const cr=class $h{constructor(t){this._managedRenderables=[],this._renderer=t}init(t){t={...$h.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime,this._frequency=t.renderableGCFrequency,this.enabled=t.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency):this._renderer.scheduler.cancel(this._handler))}prerender(){this._now=performance.now()}addRenderable(t,e){!this.enabled||(t._lastUsed=this._now,t._lastInstructionTick===-1&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastInstructionTick=e.tick)}run(){var n,o,a,h;const t=performance.now(),e=this._managedRenderables,s=this._renderer.renderPipes;let r=0;for(let l=0;l<e.length;l++){const u=e[l];if(u===null){r++;continue}const c=(h=(a=(o=(n=u.renderGroup)!=null?n:u.parentRenderGroup)==null?void 0:o.instructionSet)==null?void 0:a.tick)!=null?h:-1;u._lastInstructionTick!==c&&t-u._lastUsed>this.maxUnusedTime?(u.destroyed||s[u.renderPipeId].destroyRenderable(u),u._lastInstructionTick=-1,r++,u.off("destroyed",this._removeRenderable,this)):e[l-r]=u}e.length=e.length-r}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}};cr.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"renderableGC"},cr.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let of=cr;const dr=class Xh{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){var e;t={...Xh.defaultOptions,...t},this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=(e=t.textureGCAMaxIdle)!=null?e:t.textureGCMaxIdle,this.active=t.textureGCActive}postrender(){!this._renderer.renderingToScreen||(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e<t.length;e++){const s=t[e];s.autoGarbageCollect&&s.resource&&s._touched>-1&&this.count-s._touched>this.maxIdle&&(s._touched=-1,s.unload())}}destroy(){this._renderer=null}};dr.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"textureGC"},dr.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:60*60,textureGCCheckCountMax:600};let af=dr;const pr=class Yh{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(t){t={...Yh.defaultOptions,...t},t.view&&(D(H,"ViewSystem.view has been renamed to ViewSystem.canvas"),t.canvas=t.view),this.screen=new X(0,0,t.width,t.height),this.canvas=t.canvas||N.get().createCanvas(),this.antialias=!!t.antialias,this.texture=na(this.canvas,t),this.renderTarget=new Ji({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.multiView=!!t.multiView,this.resolution=t.resolution}resize(t,e,s){this.texture.source.resize(t,e,s),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:!!(t!=null&&t.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};pr.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"view",priority:0},pr.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const Na=[Qp,Fa,ur,pr,ka,af,Ua,Jp,bn,of,Oa],Ha=[Ga,Ho,Ia,Ea,Wo,$o,Vo,Sa],hf=[...Na,ra,op,ep,Xo,ba,ha,qo,ma,fa,Qo,Gp,Jo,Zo],lf=[...Ha],uf=[Lo,Ta,va],za=[],Wa=[],Va=[];F.handleByNamedList(x.WebGLSystem,za),F.handleByNamedList(x.WebGLPipes,Wa),F.handleByNamedList(x.WebGLPipesAdaptor,Va),F.add(...hf,...lf,...uf);class cf extends os{constructor(){const t={name:"webgl",type:yt.WEBGL,systems:za,renderPipes:Wa,renderPipeAdaptors:Va};super(t)}}var df=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:cf},Symbol.toStringTag,{value:"Module"}));class $a{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,s){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,s)}_createBindGroup(t,e,s){var u;const r=this._gpu.device,n=e.layout[s],o=[],a=this._renderer;for(const c in n){const d=(u=t.resources[c])!=null?u:t.resources[n[c]];let p;if(d._resourceType==="uniformGroup"){const f=d;a.ubo.updateUniformGroup(f);const g=f.buffer;p={buffer:a.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(d._resourceType==="buffer"){const f=d;p={buffer:a.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(d._resourceType==="bufferResource"){const f=d;p={buffer:a.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(d._resourceType==="textureSampler"){const f=d;p=a.texture.getGpuSampler(f)}else if(d._resourceType==="textureSource"){const f=d;p=a.texture.getGpuSource(f).createView({})}o.push({binding:n[c],resource:p})}const h=a.shader.getProgramData(e).bindGroups[s],l=r.createBindGroup({layout:h,entries:o});return this._hash[t._key]=l,l}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}$a.extension={type:[x.WebGPUSystem],name:"bindGroup"};class Xa{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),s=t.data;return t._updateID&&s&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,s.buffer,0,(t._updateSize||s.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(yi(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}Xa.extension={type:[x.WebGPUSystem],name:"buffer"};class pf{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let s=e+t*4;if(s=Math.ceil(s/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,s>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=s,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let s=0;s<t.length;s++)this.data[e/4+s]=t[s];return e}destroy(){this._buffer.destroy(),this._buffer=null,this.data=null}}class Ya{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}Ya.extension={type:[x.WebGPUSystem],name:"colorMask"};class fr{constructor(t){this._renderer=t}async init(t){return this._initPromise?this._initPromise:(this._initPromise=this._createDeviceAndAdaptor(t).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await N.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),s=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),r=await e.requestDevice({requiredFeatures:s});return{adapter:e,device:r}}destroy(){this.gpu=null,this._renderer=null}}fr.extension={type:[x.WebGPUSystem],name:"device"},fr.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class ja{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,s,r){const n=this._renderer.pipeline.getPipeline(t,e,s,r);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,s){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const r=this._renderer.bindGroup.getBindGroup(e,s,t);this.renderPassEncoder.setBindGroup(t,r)}setGeometry(t,e){const s=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const r in s)this._setVertexBuffer(r,t.attributes[s[r]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const s in t.groups){const r=t.groups[s];e||this._syncBindGroup(r),this.setBindGroup(s,r,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const s=t.resources[e];s.isUniformGroup&&this._renderer.ubo.updateUniformGroup(s)}}draw(t){const{geometry:e,shader:s,state:r,topology:n,size:o,start:a,instanceCount:h,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,s.gpuProgram,r,n),this.setGeometry(e,s.gpuProgram),this._setShaderBindGroups(s,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,h||e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),h||e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,s={...this._boundVertexBuffer},r=this._boundIndexBuffer,n={...this._boundBindGroup};this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in s)this._setVertexBuffer(a,s[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(r)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}ja.extension={type:[x.WebGPUSystem],name:"encoder",priority:1};class Ka{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:et.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid];s.stencilMode=t,s.stencilReference=e;const r=this._renderer;r.pipeline.setStencilMode(t),r.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Ka.extension={type:[x.WebGPUSystem],name:"stencil"};const Es={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function ff(i){const t=i.map(s=>({data:s,offset:0,size:0}));let e=0;for(let s=0;s<t.length;s++){const r=t[s];let n=Es[r.data.type].size;const o=Es[r.data.type].align;if(!Es[r.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${r.data.type}`);r.data.size>1&&(n=Math.max(n,o)*r.data.size),e=Math.ceil(e/o)*o,r.size=n,r.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function mf(i,t){const{size:e,align:s}=Es[i.data.type],r=(s-e)/4;return`
         v = uv.${i.data.name};
         ${t!==0?`offset += ${t};`:""}

         arrayOffset = offset;

         t = 0;

         for(var i=0; i < ${i.data.size*(e/4)}; i++)
         {
             for(var j = 0; j < ${e/4}; j++)
             {
                 data[arrayOffset++] = v[t++];
             }
             ${r!==0?`arrayOffset += ${r};`:""}
         }
     `}function gf(i){return sa(i,"uboWgsl",mf,lp)}class qa extends ta{constructor(){super({createUboElements:ff,generateUboSync:gf})}}qa.extension={type:[x.WebGPUSystem],name:"ubo"};const Gt=128;class Za{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new pf({minUniformOffsetAlignment:Gt});const e=256/Gt;for(let s=0;s<e;s++){let r=W.UNIFORM|W.COPY_DST;s===0&&(r|=W.COPY_SRC),this._buffers.push(new bt({data:this._batchBuffer.data,usage:r}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(const t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const s=t.buffer.data,r=this._batchBuffer.addEmptyGroup(s.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,r/4),this._bindGroupHash[t.uid]=this._getBindGroup(r/Gt),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,s=this._batchBuffer.addGroup(e);return this._getBufferResource(s/Gt)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/Gt)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/Gt;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new tr({buffer:e,offset:(t/2|0)*256,size:Gt})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Pt({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const s=this._renderer.gpu.device.createCommandEncoder();for(let r=1;r<this._buffers.length;r++){const n=this._buffers[r];s.copyBufferToBuffer(t.getGPUBuffer(e),Gt,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([s.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}Za.extension={type:[x.WebGPUPipes],name:"uniformBatch"};const _f={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function xf(i,t,e,s,r){return i<<24|t<<16|e<<10|s<<5|r}function yf(i,t,e,s){return e<<6|i<<3|s<<1|t}class Qa{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(et.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=Vt[t],this._updatePipeHash())}setPipeline(t,e,s,r){const n=this.getPipeline(t,e,s);r.setPipeline(n)}getPipeline(t,e,s,r){t._layoutKey||(Yo(t,e.attributeData),this._generateBufferKey(t)),r=r||t.topology;const n=xf(t._layoutKey,e._layoutKey,s.data,s._blendModeId,_f[r]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,s,r),this._pipeCache[n])}_createPipeline(t,e,s,r){const n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(s);a[0].writeMask=this._stencilMode===et.RENDERING_MASK_ADD?0:this._colorMask;const h=this._renderer.shader.getProgramData(e).pipeline,l={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:r,cullMode:s.cullMode},layout:h,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(l.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:s.depthTest,depthCompare:s.depthTest?"less":"always"}),n.createRenderPipeline(l)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let s=0;const r=Object.keys(t.attributes).sort();for(let o=0;o<r.length;o++){const a=t.attributes[r[o]];e[s++]=a.offset,e[s++]=a.format,e[s++]=a.stride,e[s++]=a.instance}const n=e.join("|");return t._layoutKey=ye(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let s=0;const r=Object.keys(t.attributeData).sort();for(let o=0;o<r.length;o++){const a=t.attributeData[r[o]];e[s++]=a.location}const n=e.join("|");return t._attributeLocationsKey=ye(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const s=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[s])return this._bindingNamesCache[s];const r=this._createVertexBufferLayouts(t,e),n=Object.create(null),o=e.attributeData;for(let a=0;a<r.length;a++)for(const h in o)if(o[h].location===a){n[a]=h;break}return this._bindingNamesCache[s]=n,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const s=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[s])return this._bufferLayoutsCache[s];const r=[];return t.buffers.forEach(n=>{var h;const o={arrayStride:0,stepMode:"vertex",attributes:[]},a=o.attributes;for(const l in e.attributeData){const u=t.attributes[l];((h=u.divisor)!=null?h:1)!==1&&U(`Attribute ${l} has an invalid divisor value of '${u.divisor}'. WebGPU only supports a divisor value of 1`),u.buffer===n&&(o.arrayStride=u.stride,o.stepMode=u.instance?"instance":"vertex",a.push({shaderLocation:e.attributeData[l].location,offset:u.offset,format:u.format}))}a.length&&r.push(o)}),this._bufferLayoutsCache[s]=r,r}_updatePipeHash(){const t=yf(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Qa.extension={type:[x.WebGPUSystem],name:"pipeline"};class bf{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class vf{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,s,r,n){const o=this._renderer,a=this._getGpuColorTexture(t),h=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:s},{texture:h,origin:n},r),e}startRenderPass(t,e=!0,s,r){const n=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,s);n.descriptor=o,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(r)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,s){typeof e=="boolean"&&(e=e?ut.ALL:ut.NONE);const r=this._renderTargetSystem,n=r.getGpuRenderTarget(t),o=t.colorTextures.map((h,l)=>{const u=n.contexts[l];let c,d;u?c=u.getCurrentTexture().createView():c=this._renderer.texture.getGpuSource(h).createView({mipLevelCount:1}),n.msaaTextures[l]&&(d=c,c=this._renderer.texture.getTextureView(n.msaaTextures[l]));const p=e&ut.COLOR?"clear":"load";return s!=null||(s=r.defaultClearColor),{view:c,resolveTarget:d,clearValue:s,storeOp:"store",loadOp:p}});let a;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const h=e&ut.STENCIL?"clear":"load",l=e&ut.DEPTH?"clear":"load";a={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:h,depthClearValue:1,depthLoadOp:l,depthStoreOp:"store"}}return{colorAttachments:o,depthStencilAttachment:a}}clear(t,e=!0,s,r){if(!e)return;const{gpu:n,encoder:o}=this._renderer,a=n.device;if(o.commandEncoder===null){const h=a.createCommandEncoder(),l=this.getDescriptor(t,e,s),u=h.beginRenderPass(l);u.setViewport(r.x,r.y,r.width,r.height,0,1),u.end();const c=h.finish();a.queue.submit([c])}else this.startRenderPass(t,e,s,r)}initGpuRenderTarget(t){t.isRoot=!0;const e=new bf;return t.colorTextures.forEach((s,r)=>{if(Qt.test(s.resource)){const n=s.resource.getContext("webgpu"),o=s.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[r]=n}if(e.msaa=s.source.antialias,s.source.antialias){const n=new tt({width:0,height:0,sampleCount:4});e.msaaTextures[r]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((s,r)=>{var n;(n=e.msaaTextures[r])==null||n.resize(s.source.width,s.source.height,s.source._resolution)})}}class Ja extends aa{constructor(t){super(t),this.adaptor=new vf,this.adaptor.init(t,this)}}Ja.extension={type:[x.WebGPUSystem],name:"renderTarget"};class th{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t,this.maxTextures=t.device.limits.maxSampledTexturesPerShaderStage}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,s=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),r={bindGroupLayouts:s};return this._gpuProgramData[t._layoutKey]={bindGroups:s,pipeline:e.createPipelineLayout(r)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}th.extension={type:[x.WebGPUSystem],name:"shader"};const ht={};ht.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},ht.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},ht.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},ht.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},ht.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},ht.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},ht["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},ht["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},ht["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},ht.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},ht.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},ht.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class eh{constructor(){this.defaultState=new Ct,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){const e=ht[t.blendMode]||ht.normal;return[{format:"bgra8unorm",writeMask:0,blend:e}]}destroy(){this.gpu=null}}eh.extension={type:[x.WebGPUSystem],name:"state"};const Tf={type:"image",upload(i,t,e){const s=i.resource,r=(i.pixelWidth|0)*(i.pixelHeight|0),n=s.byteLength/r;e.device.queue.writeTexture({texture:t},s,{offset:0,rowsPerImage:i.pixelHeight,bytesPerRow:i.pixelHeight*n},{width:i.pixelWidth,height:i.pixelHeight,depthOrArrayLayers:1})}},sh={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},Sf={blockBytes:4,blockWidth:1,blockHeight:1},wf={type:"compressed",upload(i,t,e){let s=i.pixelWidth,r=i.pixelHeight;const n=sh[i.format]||Sf;for(let o=0;o<i.resource.length;o++){const a=i.resource[o],h=Math.ceil(s/n.blockWidth)*n.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:o},a,{offset:0,bytesPerRow:h},{width:Math.ceil(s/n.blockWidth)*n.blockWidth,height:Math.ceil(r/n.blockHeight)*n.blockHeight,depthOrArrayLayers:1}),s=Math.max(s>>1,1),r=Math.max(r>>1,1)}}},ih={type:"image",upload(i,t,e){const s=i.resource;if(!s)return;const r=Math.min(t.width,i.resourceWidth||i.pixelWidth),n=Math.min(t.height,i.resourceHeight||i.pixelHeight),o=i.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:s},{texture:t,premultipliedAlpha:o},{width:r,height:n})}},Ef={type:"video",upload(i,t,e){ih.upload(i,t,e)}};class Af{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
                        var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
                        vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));

                        struct VertexOutput {
                        @builtin(position) position : vec4<f32>,
                        @location(0) texCoord : vec2<f32>,
                        };

                        @vertex
                        fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
                        var output : VertexOutput;
                        output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
                        output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
                        return output;
                        }

                        @group(0) @binding(0) var imgSampler : sampler;
                        @group(0) @binding(1) var img : texture_2d<f32>;

                        @fragment
                        fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
                        return textureSample(img, imgSampler, texCoord);
                        }
                    `})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let s=t;const r=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const h={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:r},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};s=this.device.createTexture(h)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let h=0;h<r;++h){let l=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:h,arrayLayerCount:1}),u=n?1:0;for(let c=1;c<t.mipLevelCount;++c){const d=s.createView({baseMipLevel:u++,mipLevelCount:1,dimension:"2d",baseArrayLayer:h,arrayLayerCount:1}),p=o.beginRenderPass({colorAttachments:[{view:d,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),f=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:l}]});p.setPipeline(e),p.setBindGroup(0,f),p.draw(3,1,0,0),p.end(),l=d}}if(!n){const h={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:r};for(let l=1;l<t.mipLevelCount;++l)o.copyTextureToTexture({texture:s,mipLevel:l-1},{texture:t,mipLevel:l},h),h.width=Math.ceil(h.width/2),h.height=Math.ceil(h.height/2)}return this.device.queue.submit([o.finish()]),n||s.destroy(),t}}class rh{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:ih,buffer:Tf,video:Ef,compressed:wf},this._renderer=t}contextChange(t){this._gpu=t}initSource(t){if(t.autoGenerateMipmaps){const h=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(h))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const s=sh[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(t.pixelWidth/s.blockWidth)*s.blockWidth,n=Math.ceil(t.pixelHeight/s.blockHeight)*s.blockHeight,o={label:t.label,size:{width:r,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},a=this._gpu.device.createTexture(o);return this._gpuSources[t.uid]=a,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),a}onSourceUpdate(t){const e=this.getGpuSource(t);!e||(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new Af(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){var e;return(e=this._bindGroupHash[t.uid])!=null?e:this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Pt({0:e,1:e.style,2:new at({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){var s;const e=t.source;return(s=this._textureViewHash[e.uid])!=null?s:this._createTextureView(e)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,s=e.gpu.device.createCommandEncoder(),r=N.get().createCanvas();r.width=t.source.pixelWidth,r.height=t.source.pixelHeight;const n=r.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:N.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),s.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:r.width,height:r.height}),e.gpu.device.queue.submit([s.finish()]),r}getPixels(t){const e=this.generateCanvas(t),s=Rt.getOptimalCanvasAndContext(e.width,e.height),r=s.context;r.drawImage(e,0,0);const{width:n,height:o}=e,a=r.getImageData(0,0,n,o),h=new Uint8ClampedArray(a.data.buffer);return Rt.returnCanvasAndContext(s),{pixels:h,width:n,height:o}}destroy(){var t;this.managedTextures.slice().forEach(e=>this.onSourceDestroy(e)),this.managedTextures=null;for(const e of Object.keys(this._bindGroupHash)){const s=Number(e);(t=this._bindGroupHash[s])==null||t.destroy(),this._bindGroupHash[s]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}rh.extension={type:[x.WebGPUSystem],name:"texture"};class nh{init(){const t=new at({uTransformMatrix:{value:new R,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),e=Be({name:"graphics",bits:[zi,$i(kt()),Yd,Ie]});this.shader=new ft({gpuProgram:e,resources:{localUniforms:t}})}execute(t,e){const s=e.context,r=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{geometry:a,instructions:h}=o.getContextRenderData(s),l=n.encoder;l.setPipelineFromGeometryProgramAndState(a,r.gpuProgram,t.state),l.setGeometry(a,r.gpuProgram);const u=n.globalUniforms.bindGroup;l.setBindGroup(0,u,r.gpuProgram);const c=n.renderPipes.uniformBatch.getUniformBindGroup(r.resources.localUniforms,!0);l.setBindGroup(2,c,r.gpuProgram);const d=h.instructions;for(let p=0;p<h.instructionSize;p++){const f=d[p];if(r.groups[1]=f.bindGroup,!f.gpuBindGroup){const g=f.textures;f.bindGroup=_i(g.textures,g.count),f.gpuBindGroup=n.bindGroup.getBindGroup(f.bindGroup,r.gpuProgram,1)}l.setBindGroup(1,f.bindGroup,r.gpuProgram),l.renderPassEncoder.drawIndexed(f.size,1,f.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}nh.extension={type:[x.WebGPUPipesAdaptor],name:"graphics"};class oh{init(){const t=Be({name:"mesh",bits:[Ue,jd,Ie]});this._shader=new ft({gpuProgram:t,resources:{uTexture:C.EMPTY._source,uSampler:C.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new R}}}})}execute(t,e){const s=t.renderer;let r=e._shader;if(!r)r=this._shader,r.groups[2]=s.texture.getTextureBindGroup(e.texture);else if(!r.gpuProgram){U("Mesh shader has no gpuProgram",e.shader);return}const n=r.gpuProgram;if(n.autoAssignGlobalUniforms&&(r.groups[0]=s.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;r.groups[1]=s.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}s.encoder.draw({geometry:e._geometry,shader:r,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}oh.extension={type:[x.WebGPUPipesAdaptor],name:"mesh"};const Pf=[...Na,qa,ja,fr,Xa,rh,Ja,th,eh,Qa,Ya,Ka,$a],Cf=[...Ha,Za],Mf=[No,oh,nh],ah=[],hh=[],lh=[];F.handleByNamedList(x.WebGPUSystem,ah),F.handleByNamedList(x.WebGPUPipes,hh),F.handleByNamedList(x.WebGPUPipesAdaptor,lh),F.add(...Pf,...Cf,...Mf);class Rf extends os{constructor(){const t={name:"webgpu",type:yt.WEBGPU,systems:ah,renderPipes:hh,renderPipeAdaptors:lh};super(t)}}var Bf=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:Rf},Symbol.toStringTag,{value:"Module"}));class uh{constructor(t,e){this.state=Ct.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=t.context,s=!!this._graphicsBatchesHash[t.uid],r=this.renderer.graphicsContext.updateGpuContext(e);return!!(r.isBatchable||s!==r.isBatchable)}addRenderable(t,e){const s=this.renderer.graphicsContext.updateGpuContext(t.context);t._didGraphicsUpdate&&(t._didGraphicsUpdate=!1,this._rebuild(t)),s.isBatchable?this._addToBatcher(t):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._graphicsBatchesHash[t.uid];if(e)for(let s=0;s<e.length;s++){const r=e[s];r.batcher.updateElement(r)}}destroyRenderable(t){this._graphicsBatchesHash[t.uid]&&this._removeBatchForRenderable(t.uid),t.off("destroyed",this._destroyRenderableBound)}execute(t){if(!t.isRenderable)return;const e=this.renderer,s=t.context;if(!e.graphicsContext.getGpuContext(s).batches.length)return;const r=s.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const n=r.resources.localUniforms.uniforms;n.uTransformMatrix=t.groupTransform,n.uRound=e._roundPixels|t._roundPixels,ws(t.groupColorAlpha,n.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=!!this._graphicsBatchesHash[t.uid],s=this.renderer.graphicsContext.updateGpuContext(t.context);e&&this._removeBatchForRenderable(t.uid),s.isBatchable&&this._initBatchesForRenderable(t),t.batched=s.isBatchable}_addToBatcher(t){const e=this.renderer.renderPipes.batch,s=this._getBatchesForRenderable(t);for(let r=0;r<s.length;r++){const n=s[r];e.addToBatch(n)}}_getBatchesForRenderable(t){return this._graphicsBatchesHash[t.uid]||this._initBatchesForRenderable(t)}_initBatchesForRenderable(t){const e=t.context,s=this.renderer.graphicsContext.getGpuContext(e),r=this.renderer._roundPixels|t._roundPixels,n=s.batches.map(o=>{const a=L.get(vi);return o.copyTo(a),a.renderable=t,a.roundPixels=r,a});return this._graphicsBatchesHash[t.uid]===void 0&&t.on("destroyed",this._destroyRenderableBound),this._graphicsBatchesHash[t.uid]=n,n}_removeBatchForRenderable(t){this._graphicsBatchesHash[t].forEach(e=>{L.return(e)}),this._graphicsBatchesHash[t]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const t in this._graphicsBatchesHash)this._removeBatchForRenderable(t);this._graphicsBatchesHash=null}}uh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"graphics"};const ch=class jh extends Li{constructor(...t){var s;super({});let e=(s=t[0])!=null?s:{};typeof e=="number"&&(D(H,"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){var c,d,p,f;t={...jh.defaultOptions,...t},this.verticesX=(c=this.verticesX)!=null?c:t.verticesX,this.verticesY=(d=this.verticesY)!=null?d:t.verticesY,this.width=(p=this.width)!=null?p:t.width,this.height=(f=this.height)!=null?f:t.height;const e=this.verticesX*this.verticesY,s=[],r=[],n=[],o=this.verticesX-1,a=this.verticesY-1,h=this.width/o,l=this.height/a;for(let g=0;g<e;g++){const m=g%this.verticesX,_=g/this.verticesX|0;s.push(m*h,_*l),r.push(m/o,_/a)}const u=o*a;for(let g=0;g<u;g++){const m=g%o,_=g/o|0,y=_*this.verticesX+m,b=_*this.verticesX+m+1,v=(_+1)*this.verticesX+m,T=(_+1)*this.verticesX+m+1;n.push(y,b,v,b,T,v)}this.buffers[0].data=new Float32Array(s),this.buffers[1].data=new Float32Array(r),this.indexBuffer.data=new Uint32Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};ch.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let kf=ch;class mr{constructor(){this.batcher=null,this.batch=null,this.roundPixels=0,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.mesh.groupBlendMode}reset(){this.mesh=null,this.texture=null,this.batcher=null,this.batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}packIndex(t,e,s){const r=this.geometry.indices;for(let n=0;n<r.length;n++)t[e++]=r[n]+s}packAttributes(t,e,s,r){const n=this.mesh,o=this.geometry,a=n.groupTransform,h=r<<16|this.roundPixels&65535,l=a.a,u=a.b,c=a.c,d=a.d,p=a.tx,f=a.ty,g=o.positions,m=o.getBuffer("aUV"),_=m.data;let y=_;const b=this.texture.textureMatrix;b.isSimple||(y=this._transformedUvs,(this._textureMatrixUpdateId!==b._updateID||this._uvUpdateId!==m._updateID)&&((!y||y.length<_.length)&&(y=this._transformedUvs=new Float32Array(_.length)),this._textureMatrixUpdateId=b._updateID,this._uvUpdateId=m._updateID,b.multiplyUvs(_,y)));const v=n.groupColorAlpha;for(let T=0;T<g.length;T+=2){const A=g[T],E=g[T+1];t[s]=l*A+c*E+p,t[s+1]=u*A+d*E+f,t[s+2]=y[T],t[s+3]=y[T+1],e[s+4]=v,e[s+5]=h,s+=6}}get vertexSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class dh{constructor(t,e){this.localUniforms=new at({uTransformMatrix:{value:new R,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Pt({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),s=e.batched,r=t.batched;if(e.batched=r,s!==r)return!0;if(r){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t),a=t.texture;if(o.texture._source!==a._source&&o.texture._source!==a._source)return!o.batcher.checkAndUpdateTexture(o,a)}return!1}addRenderable(t,e){const s=this.renderer.renderPipes.batch,{batched:r}=this._getMeshData(t);if(r){const n=this._getBatchableMesh(t);n.texture=t._texture,n.geometry=t._geometry,s.addToBatch(n)}else s.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._gpuBatchableMeshHash[t.uid];e.texture=t._texture,e.geometry=t._geometry,e.batcher.updateElement(e)}}destroyRenderable(t){this._meshDataHash[t.uid]=null;const e=this._gpuBatchableMeshHash[t.uid];e&&(L.return(e),this._gpuBatchableMeshHash[t.uid]=null),t.off("destroyed",this._destroyRenderableBound)}execute(t){if(!t.isRenderable)return;t.state.blendMode=ls(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),ws(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){return this._meshDataHash[t.uid]||this._initMeshData(t)}_initMeshData(t){var e,s;return this._meshDataHash[t.uid]={batched:t.batched,indexSize:(e=t._geometry.indices)==null?void 0:e.length,vertexSize:(s=t._geometry.positions)==null?void 0:s.length},t.on("destroyed",this._destroyRenderableBound),this._meshDataHash[t.uid]}_getBatchableMesh(t){return this._gpuBatchableMeshHash[t.uid]||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=L.get(mr);return e.mesh=t,e.texture=t._texture,e.roundPixels=this.renderer._roundPixels|t._roundPixels,this._gpuBatchableMeshHash[t.uid]=e,e.mesh=t,e}destroy(){for(const t in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[t]&&L.return(this._gpuBatchableMeshHash[t]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}dh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"mesh"};const ph=class Kh extends kf{constructor(t={}){t={...Kh.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e,s,r,n,o,a,h,l;this.width=(e=t.width)!=null?e:this.width,this.height=(s=t.height)!=null?s:this.height,this._originalWidth=(r=t.originalWidth)!=null?r:this._originalWidth,this._originalHeight=(n=t.originalHeight)!=null?n:this._originalHeight,this._leftWidth=(o=t.leftWidth)!=null?o:this._leftWidth,this._rightWidth=(a=t.rightWidth)!=null?a:this._rightWidth,this._topHeight=(h=t.topHeight)!=null?h:this._topHeight,this._bottomHeight=(l=t.bottomHeight)!=null?l:this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,s=this.width>e?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,o=Math.min(s,n);t[9]=t[11]=t[13]=t[15]=this._topHeight*o,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*o,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*o,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*o,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};ph.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let If=ph;class fh{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t}addRenderable(t,e){const s=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,s=this._getGpuSprite(t);return s.texture._source!==e._source?!s.batcher.checkAndUpdateTexture(s,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];L.return(e.geometry),L.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.geometry.update(t),e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=L.get(mr);return e.geometry=L.get(If),e.mesh=t,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._didSpriteUpdate=!0,this._gpuSpriteHash[t.uid]=e,t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}fh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"nineSliceSprite"};const Gf={name:"tiling-bit",vertex:{header:`
            struct TilingUniforms {
                uMapCoord:mat3x3<f32>,
                uClampFrame:vec4<f32>,
                uClampOffset:vec2<f32>,
                uTextureTransform:mat3x3<f32>,
                uSizeAnchor:vec4<f32>
            };

            @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
            @group(2) @binding(1) var uTexture: texture_2d<f32>;
            @group(2) @binding(2) var uSampler: sampler;
        `,main:`
            uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;

            position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
        `},fragment:{header:`
            struct TilingUniforms {
                uMapCoord:mat3x3<f32>,
                uClampFrame:vec4<f32>,
                uClampOffset:vec2<f32>,
                uTextureTransform:mat3x3<f32>,
                uSizeAnchor:vec4<f32>
            };

            @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
            @group(2) @binding(1) var uTexture: texture_2d<f32>;
            @group(2) @binding(2) var uSampler: sampler;
        `,main:`

            var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
            coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
            var unclamped = coord;
            coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);

            var bias = 0.;

            if(unclamped.x == coord.x && unclamped.y == coord.y)
            {
                bias = -32.;
            } 

            outColor = textureSampleBias(uTexture, uSampler, coord, bias);
        `}},Uf={name:"tiling-bit",vertex:{header:`
            uniform mat3 uTextureTransform;
            uniform vec4 uSizeAnchor;
        
        `,main:`
            uv = (uTextureTransform * vec3(aUV, 1.0)).xy;

            position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
        `},fragment:{header:`
            uniform sampler2D uTexture;
            uniform mat3 uMapCoord;
            uniform vec4 uClampFrame;
            uniform vec2 uClampOffset;
        `,main:`

        vec2 coord = vUV + ceil(uClampOffset - vUV);
        coord = (uMapCoord * vec3(coord, 1.0)).xy;
        vec2 unclamped = coord;
        coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
        
        outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
    
        `}};let De,Le;class Ff extends ft{constructor(){De!=null||(De=Be({name:"tiling-sprite-shader",bits:[Ue,Gf,Ie]})),Le!=null||(Le=ke({name:"tiling-sprite-shader",bits:[Ki,Uf,Ge]}));const t=new at({uMapCoord:{value:new R,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new R,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Le,gpuProgram:De,resources:{localUniforms:new at({uTransformMatrix:{value:new R,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:C.EMPTY.source,uSampler:C.EMPTY.source.style}})}updateUniforms(t,e,s,r,n,o){const a=this.resources.tilingUniforms,h=o.width,l=o.height,u=o.textureMatrix,c=a.uniforms.uTextureTransform;c.set(s.a*h/t,s.b*h/e,s.c*l/t,s.d*l/e,s.tx/t,s.ty/e),c.invert(),a.uniforms.uMapCoord=u.mapCoord,a.uniforms.uClampFrame=u.uClampFrame,a.uniforms.uClampOffset=u.uClampOffset,a.uniforms.uTextureTransform=c,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=r,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class Of extends Li{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function Df(i,t){const e=i.anchor.x,s=i.anchor.y;t[0]=-e*i.width,t[1]=-s*i.height,t[2]=(1-e)*i.width,t[3]=-s*i.height,t[4]=(1-e)*i.width,t[5]=(1-s)*i.height,t[6]=-e*i.width,t[7]=(1-s)*i.height}function Lf(i,t,e,s){let r=0;const n=i.length/(t||2),o=s.a,a=s.b,h=s.c,l=s.d,u=s.tx,c=s.ty;for(e*=t;r<n;){const d=i[e],p=i[e+1];i[e]=o*d+h*p+u,i[e+1]=a*d+l*p+c,e+=t,r++}}function Nf(i,t){const e=i.texture,s=e.frame.width,r=e.frame.height;let n=0,o=0;i._applyAnchorToTexture&&(n=i.anchor.x,o=i.anchor.y),t[0]=t[6]=-n,t[2]=t[4]=1-n,t[1]=t[3]=-o,t[5]=t[7]=1-o;const a=R.shared;a.copyFrom(i._tileTransform.matrix),a.tx/=i.width,a.ty/=i.height,a.invert(),a.scale(i.width/s,i.height/r),Lf(t,2,0,a)}const As=new Of;class mh{constructor(t){this._state=Ct.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),s=e.canBatch;this._updateCanBatch(t);const r=e.canBatch;if(r&&r===s){const{batchableMesh:n}=e;if(n&&n.texture._source!==t.texture._source)return!n.batcher.checkAndUpdateTexture(n,t.texture)}return s!==r}addRenderable(t,e){const s=this._renderer.renderPipes.batch;this._updateCanBatch(t);const r=this._getTilingSpriteData(t),{geometry:n,canBatch:o}=r;if(o){r.batchableMesh||(r.batchableMesh=new mr);const a=r.batchableMesh;t._didTilingSpriteUpdate&&(t._didTilingSpriteUpdate=!1,this._updateBatchableMesh(t),a.geometry=n,a.mesh=t,a.texture=t._texture),a.roundPixels=this._renderer._roundPixels|t._roundPixels,s.addToBatch(a)}else s.break(e),r.shader||(r.shader=new Ff),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._tilingSpriteDataHash[t.uid];e.groups[0]=this._renderer.globalUniforms.bindGroup;const s=e.resources.localUniforms.uniforms;s.uTransformMatrix=t.groupTransform,s.uRound=this._renderer._roundPixels|t._roundPixels,ws(t.groupColorAlpha,s.uColor,0),this._state.blendMode=ls(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:As,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:s}=e;if(s){const{batchableMesh:r}=e;t._didTilingSpriteUpdate&&this._updateBatchableMesh(t),r.batcher.updateElement(r)}else if(t._didTilingSpriteUpdate){const{shader:r}=e;r.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}t._didTilingSpriteUpdate=!1}destroyRenderable(t){var s;const e=this._getTilingSpriteData(t);e.batchableMesh=null,(s=e.shader)==null||s.destroy(),this._tilingSpriteDataHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}_getTilingSpriteData(t){return this._tilingSpriteDataHash[t.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new Li({indices:As.indices,positions:As.positions.slice(),uvs:As.uvs.slice()});return this._tilingSpriteDataHash[t.uid]={canBatch:!0,renderable:t,geometry:e},t.on("destroyed",this._destroyRenderableBound),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:s}=e,r=t.texture.source.style;r.addressMode!=="repeat"&&(r.addressMode="repeat",r.update()),Nf(t,s.uvs),Df(t,s.positions)}destroy(){for(const t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),s=t.texture;let r=!0;return this._renderer.type===yt.WEBGL&&(r=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=s.textureMatrix.isSimple&&(r||s.source.isPowerOfTwo),e.canBatch}}mh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"tilingSprite"};const Hf={name:"local-uniform-msdf-bit",vertex:{header:`
            struct LocalUniforms {
                uColor:vec4<f32>,
                uTransformMatrix:mat3x3<f32>,
                uDistance: f32,
                uRound:f32,
            }

            @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `},fragment:{header:`
            struct LocalUniforms {
                uColor:vec4<f32>,
                uTransformMatrix:mat3x3<f32>,
                uDistance: f32
            }

            @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
         `,main:` 
            outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
        `}},zf={name:"local-uniform-msdf-bit",vertex:{header:`
            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix *= uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `},fragment:{header:`
            uniform float uDistance;
         `,main:` 
            outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
        `}},Wf={name:"msdf-bit",fragment:{header:`
            fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
                
                // MSDF
                var median = msdfColor.r + msdfColor.g + msdfColor.b -
                    min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
                    max(msdfColor.r, max(msdfColor.g, msdfColor.b));
            
                // SDF
                median = min(median, msdfColor.a);

                var screenPxDistance = distance * (median - 0.5);
                var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
                if (median < 0.01) {
                    alpha = 0.0;
                } else if (median > 0.99) {
                    alpha = 1.0;
                }

                // Gamma correction for coverage-like alpha
                var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
                var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
                var coverage: f32 = pow(shapeColor.a * alpha, gamma);

                return coverage;
             
            }
        `}},Vf={name:"msdf-bit",fragment:{header:`
            float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
                
                // MSDF
                float median = msdfColor.r + msdfColor.g + msdfColor.b -
                                min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
                                max(msdfColor.r, max(msdfColor.g, msdfColor.b));
               
                // SDF
                median = min(median, msdfColor.a);
            
                float screenPxDistance = distance * (median - 0.5);
                float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
           
                if (median < 0.01) {
                    alpha = 0.0;
                } else if (median > 0.99) {
                    alpha = 1.0;
                }

                // Gamma correction for coverage-like alpha
                float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
                float gamma = mix(1.0, 1.0 / 2.2, luma);
                float coverage = pow(shapeColor.a * alpha, gamma);  
              
                return coverage;
            }
        `}};let Ne,He;class $f extends ft{constructor(){const t=new at({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new R,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=kt();Ne!=null||(Ne=Be({name:"sdf-shader",bits:[zi,$i(e),Hf,Wf,Ie]})),He!=null||(He=ke({name:"sdf-shader",bits:[Wi,Yi(e),zf,Vf,Ge]})),super({glProgram:He,gpuProgram:Ne,resources:{localUniforms:t,batchSamplers:ji(e)}})}}class gh{constructor(t){this._gpuBitmapText={},this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const s=this._getGpuBitmapText(t);_h(t,s),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,s)),this._renderer.renderPipes.graphics.addRenderable(s,e),s.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){const e=this._gpuBitmapText[t].context;e.customShader&&(L.return(e.customShader),e.customShader=null),L.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){const e=this._getGpuBitmapText(t);_h(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:s}=e,r=Bi.getFont(t.text,t._style);s.clear(),r.distanceField.type!=="none"&&(s.customShader||(s.customShader=L.get($f)));const n=Array.from(t.text),o=t._style;let a=r.baseLineOffset;const h=so(n,o,r);let l=0;const u=o.padding,c=h.scale;let d=h.width,p=h.height+h.offsetY;o._stroke&&(d+=o._stroke.width/c,p+=o._stroke.width/c),s.translate(-t._anchor._x*d-u,-t._anchor._y*p-u).scale(c,c);const f=r.applyFillAsTint?o._fill.color:16777215;for(let g=0;g<h.lines.length;g++){const m=h.lines[g];for(let _=0;_<m.charPositions.length;_++){const y=n[l++],b=r.chars[y];b!=null&&b.texture&&s.texture(b.texture,f||"black",Math.round(m.charPositions[_]+b.xOffset),Math.round(a+b.yOffset))}a+=r.lineHeight}}_getGpuBitmapText(t){return this._gpuBitmapText[t.uid]||this.initGpuText(t)}initGpuText(t){const e=L.get(xs);return this._gpuBitmapText[t.uid]=e,this._updateContext(t,e),t.on("destroyed",this._destroyRenderableBound),this._gpuBitmapText[t.uid]}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,s=t._style.fontFamily,r=j.get(`${s}-bitmap`),{a:n,b:o,c:a,d:h}=t.groupTransform,l=Math.sqrt(n*n+o*o),u=Math.sqrt(a*a+h*h),c=(Math.abs(l)+Math.abs(u))/2,d=r.baseRenderedFontSize/t._style.fontSize,p=c*r.distanceField.range*(1/d);e.customShader.resources.localUniforms.uniforms.uDistance=p}destroy(){for(const t in this._gpuBitmapText)this._destroyRenderableByUid(t);this._gpuBitmapText=null,this._renderer=null}}gh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"bitmapText"};function _h(i,t){t.groupTransform=i.groupTransform,t.groupColorAlpha=i.groupColorAlpha,t.groupColor=i.groupColor,t.groupBlendMode=i.groupBlendMode,t.globalDisplayStatus=i.globalDisplayStatus,t.groupTransform=i.groupTransform,t.localDisplayStatus=i.localDisplayStatus,t.groupAlpha=i.groupAlpha,t._roundPixels=i._roundPixels}class xh{constructor(t){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const t in this._gpuText){const e=this._gpuText[t].batchableSprite.renderable;e._autoResolution&&(e._resolution=this._renderer.resolution,e.onViewUpdate())}}validateRenderable(t){const e=this._getGpuText(t),s=t._getKey();return e.textureNeedsUploading?(e.textureNeedsUploading=!1,!0):e.currentKey!==s}addRenderable(t,e){const s=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(s)}updateRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e.batcher.updateElement(e)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.htmlText.decreaseReferenceCount(e.currentKey),L.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),s=this._getGpuText(t),r=s.batchableSprite;s.currentKey!==e&&this._updateGpuText(t).catch(o=>{console.error(o)}),t._didTextUpdate=!1;const n=t._style.padding;Ze(r.bounds,t._anchor,r.texture,n)}async _updateGpuText(t){var h;t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const s=t._getKey();this._renderer.htmlText.decreaseReferenceCount(e.currentKey),e.generatingTexture=!0,e.currentKey=s;const r=(h=t.resolution)!=null?h:this._renderer.resolution,n=await this._renderer.htmlText.getManagedTexture(t.text,r,t._style,t._getKey()),o=e.batchableSprite;o.texture=e.texture=n,e.generatingTexture=!1,e.textureNeedsUploading=!0,t.onViewUpdate();const a=t._style.padding;Ze(o.bounds,t._anchor,o.texture,a)}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:C.EMPTY,currentKey:"--",batchableSprite:L.get(nr),textureNeedsUploading:!1,generatingTexture:!1},s=e.batchableSprite;return s.renderable=t,s.texture=C.EMPTY,s.bounds={minX:0,maxX:1,minY:0,maxY:0},s.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,this._gpuText[t.uid]=e,t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}xh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"htmlText"};function Xf(){const{userAgent:i}=N.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(i)}const Yf=new nt;function yh(i,t,e,s){const r=Yf;r.minX=0,r.minY=0,r.maxX=i.width/s|0,r.maxY=i.height/s|0;const n=gt.getOptimalTexture(r.width,r.height,s,!1);return n.source.uploadMethodId="image",n.source.resource=i,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/s,n.frame.height=e/s,n.source.emit("update",n.source),n.updateUvs(),n}function jf(i,t){const e=t.fontFamily,s=[],r={},n=/font-family:([^;"\s]+)/g,o=i.match(n);function a(h){r[h]||(s.push(h),r[h]=!0)}if(Array.isArray(e))for(let h=0;h<e.length;h++)a(e[h]);else a(e);o&&o.forEach(h=>{const l=h.split(":")[1].trim();a(l)});for(const h in t.tagStyles){const l=t.tagStyles[h].fontFamily;a(l)}return s}async function Kf(i){const t=await(await N.get().fetch(i)).blob(),e=new FileReader;return await new Promise((s,r)=>{e.onloadend=()=>s(e.result),e.onerror=r,e.readAsDataURL(t)})}async function bh(i,t){const e=await Kf(t);return`@font-face {
        font-family: "${i.fontFamily}";
        src: url('${e}');
        font-weight: ${i.fontWeight};
        font-style: ${i.fontStyle};
    }`}const Ps=new Map;async function qf(i,t,e){const s=i.filter(r=>j.has(`${r}-and-url`)).map((r,n)=>{if(!Ps.has(r)){const{url:o}=j.get(`${r}-and-url`);n===0?Ps.set(r,bh({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:r},o)):Ps.set(r,bh({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:r},o))}return Ps.get(r)});return(await Promise.all(s)).join(`
`)}function Zf(i,t,e,s,r){const{domElement:n,styleElement:o,svgRoot:a}=r;n.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${i}</div>`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:h,height:l}=r.image;return a.setAttribute("width",h.toString()),a.setAttribute("height",l.toString()),new XMLSerializer().serializeToString(a)}function Qf(i,t){const e=Rt.getOptimalCanvasAndContext(i.width,i.height,t),{context:s}=e;return s.clearRect(0,0,i.width,i.height),s.drawImage(i,0,0),Rt.returnCanvasAndContext(e),e.canvas}function Jf(i,t,e){return new Promise(async s=>{e&&await new Promise(r=>setTimeout(r,100)),i.onload=()=>{s()},i.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,i.crossOrigin="anonymous"})}class gr{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===yt.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,s,r){if(this._activeTextures[r])return this._increaseReferenceCount(r),this._activeTextures[r].promise;const n=this._buildTexturePromise(t,e,s).then(o=>(this._activeTextures[r].texture=o,o));return this._activeTextures[r]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,s){const r=L.get(Co),n=jf(t,s),o=await qf(n,s,Ni.defaultTextStyle),a=Md(t,s,o,r),h=Math.ceil(Math.ceil(Math.max(1,a.width)+s.padding*2)*e),l=Math.ceil(Math.ceil(Math.max(1,a.height)+s.padding*2)*e),u=r.image,c=2;u.width=(h|0)+c,u.height=(l|0)+c;const d=Zf(t,s,e,o,r);await Jf(u,d,Xf()&&n.length>0);let p=u;this._createCanvas&&(p=Qf(u,e));const f=yh(p,u.width-c,u.height-c,e);return this._createCanvas&&this._renderer.texture.initSource(f.source),L.return(r),f}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];!e||(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e):e.promise.then(s=>{e.texture=s,this._cleanUp(e)}).catch(()=>{U("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[t]=null))}_cleanUp(t){gt.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}gr.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"htmlText"},gr.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"};class vh{constructor(t){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const t in this._gpuText){const e=this._gpuText[t].batchableSprite.renderable;e._autoResolution&&(e._resolution=this._renderer.resolution,e.onViewUpdate())}}validateRenderable(t){const e=this._getGpuText(t),s=t._getKey();if(e.currentKey!==s){const{width:r,height:n}=this._renderer.canvasText.getTextureSize(t.text,t.resolution,t._style);return!(this._renderer.canvasText.getReferenceCount(e.currentKey)===1&&r===e.texture._source.width&&n===e.texture._source.height)}return!1}addRenderable(t,e){const s=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(s)}updateRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e.batcher.updateElement(e)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.canvasText.decreaseReferenceCount(e.currentKey),L.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),s=this._getGpuText(t),r=s.batchableSprite;s.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1;const n=t._style.padding;Ze(r.bounds,t._anchor,r.texture,n)}_updateGpuText(t){const e=this._getGpuText(t),s=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=s.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),s.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:null,currentKey:"--",batchableSprite:L.get(nr)};return e.batchableSprite.renderable=t,e.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},e.batchableSprite.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,this._updateText(t),t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}vh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"text"};function Th(i,t,e){for(let s=0,r=4*e*t;s<t;++s,r+=4)if(i[r+3]!==0)return!1;return!0}function Sh(i,t,e,s,r){const n=4*t;for(let o=s,a=s*n+4*e;o<=r;++o,a+=n)if(i[a+3]!==0)return!1;return!0}function tm(i,t=1){const{width:e,height:s}=i,r=i.getContext("2d",{willReadFrequently:!0});if(r===null)throw new TypeError("Failed to get canvas 2D context");const n=r.getImageData(0,0,e,s).data;let o=0,a=0,h=e-1,l=s-1;for(;a<s&&Th(n,e,a);)++a;if(a===s)return X.EMPTY;for(;Th(n,e,l);)--l;for(;Sh(n,e,o,a,l);)++o;for(;Sh(n,e,h,a,l);)--h;return++h,++l,new X(o/t,a/t,(h-o)/t,(l-a)/t)}class wh{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,s){const r=St.measureText(t||" ",s);let n=Math.ceil(Math.ceil(Math.max(1,r.width)+s.padding*2)*e),o=Math.ceil(Math.ceil(Math.max(1,r.height)+s.padding*2)*e);return n=Math.ceil(n-1e-6),o=Math.ceil(o-1e-6),n=qt(n),o=qt(o),{width:n,height:o}}getTexture(t,e,s,r){typeof t=="string"&&(D("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof Mt||(t.style=new Mt(t.style));const{texture:n,canvasAndContext:o}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(n._source),Rt.returnCanvasAndContext(o),n}createTextureAndCanvas(t){var c;const{text:e,style:s}=t,r=(c=t.resolution)!=null?c:this._renderer.resolution,n=St.measureText(e||" ",s),o=Math.ceil(Math.ceil(Math.max(1,n.width)+s.padding*2)*r),a=Math.ceil(Math.ceil(Math.max(1,n.height)+s.padding*2)*r),h=Rt.getOptimalCanvasAndContext(o,a),{canvas:l}=h;this.renderTextToCanvas(e,s,r,h);const u=yh(l,o,a,r);if(s.trim){const d=tm(l,r);u.frame.copyFrom(d),u.updateUvs()}return{texture:u,canvasAndContext:h}}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t._getKey();if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const{texture:s,canvasAndContext:r}=this.createTextureAndCanvas(t);return this._activeTextures[e]={canvasAndContext:r,texture:s,usageCount:1},s}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];if(e.usageCount--,e.usageCount===0){Rt.returnCanvasAndContext(e.canvasAndContext),gt.returnTexture(e.texture);const s=e.texture.source;s.resource=null,s.uploadMethodId="unknown",s.alphaMode="no-premultiply-alpha",this._activeTextures[t]=null}}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,s,r){var b,v,T,A,E,P,S;const{canvas:n,context:o}=r,a=fs(e),h=St.measureText(t||" ",e),l=h.lines,u=h.lineHeight,c=h.lineWidths,d=h.maxLineWidth,p=h.fontProperties,f=n.height;o.resetTransform(),o.scale(s,s);const g=e.padding*2;if(o.clearRect(0,0,h.width+4+g,h.height+4+g),(b=e._stroke)==null?void 0:b.width){const w=e._stroke;o.lineWidth=w.width,o.miterLimit=w.miterLimit,o.lineJoin=w.join,o.lineCap=w.cap}o.font=a;let m,_;const y=e.dropShadow?2:1;for(let w=0;w<y;++w){const Y=e.dropShadow&&w===0,it=Y?Math.ceil(Math.max(1,f)+e.padding*2):0,B=it*s;if(Y){o.fillStyle="black",o.strokeStyle="black";const O=e.dropShadow,ct=O.color,Cs=O.alpha;o.shadowColor=V.shared.setValue(ct).setAlpha(Cs).toRgbaString();const I=O.blur*s,G=O.distance*s;o.shadowBlur=I,o.shadowOffsetX=Math.cos(O.angle)*G,o.shadowOffsetY=Math.sin(O.angle)*G+B}else o.globalAlpha=(T=(v=e._fill)==null?void 0:v.alpha)!=null?T:1,o.fillStyle=e._fill?ms(e._fill,o):null,(A=e._stroke)!=null&&A.width&&(o.strokeStyle=ms(e._stroke,o)),o.shadowColor="black";let k=(u-p.fontSize)/2;u-p.fontSize<0&&(k=0);const K=(P=(E=e._stroke)==null?void 0:E.width)!=null?P:0;for(let O=0;O<l.length;O++)m=K/2,_=K/2+O*u+p.ascent+k,e.align==="right"?m+=d-c[O]:e.align==="center"&&(m+=(d-c[O])/2),(S=e._stroke)!=null&&S.width&&this._drawLetterSpacing(l[O],e,r,m+e.padding,_+e.padding-it,!0),e._fill!==void 0&&this._drawLetterSpacing(l[O],e,r,m+e.padding,_+e.padding-it)}}_drawLetterSpacing(t,e,s,r,n,o=!1){const{context:a}=s,h=e.letterSpacing;let l=!1;if(St.experimentalLetterSpacingSupported&&(St.experimentalLetterSpacing?(a.letterSpacing=`${h}px`,a.textLetterSpacing=`${h}px`,l=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),h===0||l){o?a.strokeText(t,r,n):a.fillText(t,r,n);return}let u=r;const c=St.graphemeSegmenter(t);let d=a.measureText(t).width,p=0;for(let f=0;f<c.length;++f){const g=c[f];o?a.strokeText(g,u,n):a.fillText(g,u,n);let m="";for(let _=f+1;_<c.length;++_)m+=c[_];p=a.measureText(m).width,u+=d-p+h,d=p}}destroy(){this._activeTextures=null}}wh.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"canvasText"},F.add(qh,Zh),F.add(an),J.mixin(Hl),F.add(Tn),F.add(Sn),F.add(go),J.mixin(md),F.add(uh),F.add(Si),F.add(dh),F.add(wh),F.add(vh),F.add(gh),F.add(gr),F.add(xh),F.add(mh),F.add(fh),F.add(yo),F.add(_o);var em=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),sm=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}))})();export{de as A,J as C,$ as P,X as R,Ft as S,Bh as T,pe as _,cm as __tla,C as a,xr as b,ks as c};
