pixi.js 7.0.2 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pixi.min.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  var Za=Object.defineProperty,Qa=Object.defineProperties;var Ja=Object.getOwnPropertyDescriptors;var vi=Object.getOwnPropertySymbols;var _n=Object.prototype.hasOwnProperty,gn=Object.prototype.propertyIsEnumerable;var mn=(i,t,e)=>t in i?Za(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Ht=(i,t)=>{for(var e in t||(t={}))_n.call(t,e)&&mn(i,e,t[e]);if(vi)for(var e of vi(t))gn.call(t,e)&&mn(i,e,t[e]);return i},Ts=(i,t)=>Qa(i,Ja(t));var bs=(i,t)=>{var e={};for(var s in i)_n.call(i,s)&&t.indexOf(s)<0&&(e[s]=i[s]);if(i!=null&&vi)for(var s of vi(i))t.indexOf(s)<0&&gn.call(i,s)&&(e[s]=i[s]);return e};/*!
2
- * pixi.js - v7.0.2
3
- * Compiled Mon, 31 Oct 2022 15:20:53 UTC
2
+ * pixi.js - v7.0.4
3
+ * Compiled Fri, 11 Nov 2022 12:31:03 UTC
4
4
  *
5
5
  * pixi.js is licensed under the MIT License.
6
6
  * http://www.opensource.org/licenses/mit-license
7
- */var se=(i=>(i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",i))(se||{}),xn=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS",i))(xn||{}),yi=(i=>(i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL",i))(yi||{}),k=(i=>(i[i.NORMAL=0]="NORMAL",i[i.ADD=1]="ADD",i[i.MULTIPLY=2]="MULTIPLY",i[i.SCREEN=3]="SCREEN",i[i.OVERLAY=4]="OVERLAY",i[i.DARKEN=5]="DARKEN",i[i.LIGHTEN=6]="LIGHTEN",i[i.COLOR_DODGE=7]="COLOR_DODGE",i[i.COLOR_BURN=8]="COLOR_BURN",i[i.HARD_LIGHT=9]="HARD_LIGHT",i[i.SOFT_LIGHT=10]="SOFT_LIGHT",i[i.DIFFERENCE=11]="DIFFERENCE",i[i.EXCLUSION=12]="EXCLUSION",i[i.HUE=13]="HUE",i[i.SATURATION=14]="SATURATION",i[i.COLOR=15]="COLOR",i[i.LUMINOSITY=16]="LUMINOSITY",i[i.NORMAL_NPM=17]="NORMAL_NPM",i[i.ADD_NPM=18]="ADD_NPM",i[i.SCREEN_NPM=19]="SCREEN_NPM",i[i.NONE=20]="NONE",i[i.SRC_OVER=0]="SRC_OVER",i[i.SRC_IN=21]="SRC_IN",i[i.SRC_OUT=22]="SRC_OUT",i[i.SRC_ATOP=23]="SRC_ATOP",i[i.DST_OVER=24]="DST_OVER",i[i.DST_IN=25]="DST_IN",i[i.DST_OUT=26]="DST_OUT",i[i.DST_ATOP=27]="DST_ATOP",i[i.ERASE=26]="ERASE",i[i.SUBTRACT=28]="SUBTRACT",i[i.XOR=29]="XOR",i))(k||{}),It=(i=>(i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i))(It||{}),C=(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))(C||{}),le=(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))(le||{}),O=(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))(O||{}),Ti=(i=>(i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT",i))(Ti||{}),Xt=(i=>(i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR",i))(Xt||{}),Vt=(i=>(i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i))(Vt||{}),Pt=(i=>(i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL",i))(Pt||{}),Et=(i=>(i[i.NPM=0]="NPM",i[i.UNPACK=1]="UNPACK",i[i.PMA=2]="PMA",i[i.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",i[i.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",i[i.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",i))(Et||{}),Mt=(i=>(i[i.NO=0]="NO",i[i.YES=1]="YES",i[i.AUTO=2]="AUTO",i[i.BLEND=0]="BLEND",i[i.CLEAR=1]="CLEAR",i[i.BLIT=2]="BLIT",i))(Mt||{}),bi=(i=>(i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL",i))(bi||{}),yt=(i=>(i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp",i))(yt||{}),ht=(i=>(i[i.NONE=0]="NONE",i[i.SCISSOR=1]="SCISSOR",i[i.STENCIL=2]="STENCIL",i[i.SPRITE=3]="SPRITE",i[i.COLOR=4]="COLOR",i))(ht||{}),vn=(i=>(i[i.RED=1]="RED",i[i.GREEN=2]="GREEN",i[i.BLUE=4]="BLUE",i[i.ALPHA=8]="ALPHA",i))(vn||{}),nt=(i=>(i[i.NONE=0]="NONE",i[i.LOW=2]="LOW",i[i.MEDIUM=4]="MEDIUM",i[i.HIGH=8]="HIGH",i))(nt||{}),Bt=(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))(Bt||{});const yn={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},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)};var Es=/iPhone/i,Tn=/iPod/i,bn=/iPad/i,En=/\biOS-universal(?:.+)Mac\b/i,ws=/\bAndroid(?:.+)Mobile\b/i,wn=/Android/i,Se=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ei=/Silk/i,$t=/Windows Phone/i,An=/\bWindows(?:.+)ARM\b/i,Sn=/BlackBerry/i,Rn=/BB10/i,Cn=/Opera Mini/i,In=/\b(CriOS|Chrome)(?:.+)Mobile/i,Pn=/Mobile(?:.+)Firefox\b/i,Mn=function(i){return typeof i!="undefined"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream=="undefined"};function th(i){return function(t){return t.test(i)}}function eh(i){var t={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?t.userAgent=i:i&&i.userAgent&&(t={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]!="undefined"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]!="undefined"&&(e=s[0]);var r=th(e),n={apple:{phone:r(Es)&&!r($t),ipod:r(Tn),tablet:!r(Es)&&(r(bn)||Mn(t))&&!r($t),universal:r(En),device:(r(Es)||r(Tn)||r(bn)||r(En)||Mn(t))&&!r($t)},amazon:{phone:r(Se),tablet:!r(Se)&&r(Ei),device:r(Se)||r(Ei)},android:{phone:!r($t)&&r(Se)||!r($t)&&r(ws),tablet:!r($t)&&!r(Se)&&!r(ws)&&(r(Ei)||r(wn)),device:!r($t)&&(r(Se)||r(Ei)||r(ws)||r(wn))||r(/\bokhttp\b/i)},windows:{phone:r($t),tablet:r(An),device:r($t)||r(An)},other:{blackberry:r(Sn),blackberry10:r(Rn),opera:r(Cn),firefox:r(Pn),chrome:r(In),device:r(Sn)||r(Rn)||r(Cn)||r(Pn)||r(In)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const Dt=eh(globalThis.navigator);function ih(){return!Dt.apple.device}function sh(i){let t=!0;if(Dt.tablet||Dt.phone){if(Dt.apple.device){const e=navigator.userAgent.match(/OS (\d+)_(\d+)?/);e&&parseInt(e[1],10)<11&&(t=!1)}if(Dt.android.device){const e=navigator.userAgent.match(/Android\s([0-9.]*)/);e&&parseInt(e[1],10)<7&&(t=!1)}}return t?i:4}const S={ADAPTER:yn,MIPMAP_TEXTURES:Pt.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:nt.NONE,SPRITE_MAX_TEXTURES:sh(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,antialias:!1,autoDensity:!1,backgroundColor:0,backgroundAlpha:1,useContextAlpha:!0,clearBeforeRender:!0,preserveDrawingBuffer:!1,width:800,height:600,legacy:!1,hello:!1},GC_MODE:bi.AUTO,GC_MAX_IDLE:60*60,GC_MAX_CHECK_COUNT:60*10,WRAP_MODE:Vt.CLAMP,SCALE_MODE:Xt.LINEAR,PRECISION_VERTEX:yt.HIGH,PRECISION_FRAGMENT:Dt.apple.device?yt.HIGH:yt.MEDIUM,CAN_UPLOAD_SAME_BUFFER:ih(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};S.PREFER_ENV=se.WEBGL2,S.STRICT_TEXTURE_CACHE=!1;var P=(i=>(i.Renderer="renderer",i.Application="application",i.RendererSystem="renderer-webgl-system",i.RendererPlugin="renderer-webgl-plugin",i.CanvasRendererSystem="renderer-canvas-system",i.CanvasRendererPlugin="renderer-canvas-plugin",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i))(P||{});const Bn=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){const t=typeof i.extension!="object"?{type:i.extension}:i.extension;i=Ts(Ht({},t),{ref:i})}if(typeof i=="object")i=Ht({},i);else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},U={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Bn).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(Bn).forEach(t=>{t.type.forEach(e=>{const s=this._addHandlers,r=this._queue;s[e]?s[e](t):(r[e]=r[e]||[],r[e].push(t))})}),this},handle(i,t,e){const s=this._addHandlers,r=this._removeHandlers;s[i]=t,r[i]=e;const n=this._queue;return n[i]&&(n[i].forEach(o=>t(o)),delete n[i]),this},handleByMap(i,t){return this.handle(i,e=>{t[e.name]=e.ref},e=>{delete t[e.name]})},handleByList(i,t){return this.handle(i,e=>{t.push(e.ref),t.sort((s,r)=>{var n,o;return((n=r.priority)!=null?n:-1)-((o=s.priority)!=null?o:-1)})},e=>{const s=t.indexOf(e.ref);s!==-1&&t.splice(s,1)})}},He=Math.PI*2,Dn=180/Math.PI,Nn=Math.PI/180;var dt=(i=>(i[i.POLY=0]="POLY",i[i.RECT=1]="RECT",i[i.CIRC=2]="CIRC",i[i.ELIP=3]="ELIP",i[i.RREC=4]="RREC",i))(dt||{});class j{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new j(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}const wi=[new j,new j,new j,new j];class V{constructor(t=0,e=0,s=0,r=0){this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(r),this.type=dt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new V(0,0,0,0)}clone(){return new V(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const w=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=w)return!1;const G=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>G}const s=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=s||o<=n)return!1;const a=wi[0].set(t.left,t.top),h=wi[1].set(t.left,t.bottom),l=wi[2].set(t.right,t.top),c=wi[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=s||Math.min(a.x,h.x,l.x,c.x)>=r||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const d=u*(h.y-a.y),f=u*(a.x-h.x),p=d*s+f*n,m=d*r+f*n,_=d*s+f*o,x=d*r+f*o;if(Math.max(p,m,_,x)<=d*a.x+f*a.y||Math.min(p,m,_,x)>=d*c.x+f*c.y)return!1;const y=u*(a.y-l.y),g=u*(l.x-a.x),v=y*s+g*n,b=y*r+g*n,M=y*s+g*o,R=y*r+g*o;return!(Math.max(v,b,M,R)<=y*a.x+g*a.y||Math.min(v,b,M,R)>=y*c.x+g*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=r,this.height=n-r,this}}class ps{constructor(t=0,e=0,s=0){this.x=t,this.y=e,this.radius=s,this.type=dt.CIRC}clone(){return new ps(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}getBounds(){return new V(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}class ms{constructor(t=0,e=0,s=0,r=0){this.x=t,this.y=e,this.width=s,this.height=r,this.type=dt.ELIP}clone(){return new ms(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let s=(t-this.x)/this.width,r=(e-this.y)/this.height;return s*=s,r*=r,s+r<=1}getBounds(){return new V(this.x-this.width,this.y-this.height,this.width,this.height)}}class we{constructor(...t){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.type=dt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new we(t);return e.closeStroke=this.closeStroke,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],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(s=!s)}return s}}class _s{constructor(t=0,e=0,s=0,r=0,n=20){this.x=t,this.y=e,this.width=s,this.height=r,this.radius=n,this.type=dt.RREC}clone(){return new _s(this.x,this.y,this.width,this.height,this.radius)}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}}class Jt{constructor(t,e,s=0,r=0){this._x=s,this._y=r,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new Jt(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}class et{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 j;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 j;const s=1/(this.a*this.d+this.c*-this.b),r=t.x,n=t.y;return e.x=this.d*s*r+-this.c*s*n+(this.ty*this.c-this.tx*this.d)*s,e.y=this.a*s*n+-this.b*s*r+(-this.ty*this.a+this.tx*this.b)*s,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}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(He-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}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 et;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}static get IDENTITY(){return new et}static get TEMP_MATRIX(){return new et}}const ce=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ue=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],de=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],fe=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],As=[],Fn=[],Ai=Math.sign;function rh(){for(let i=0;i<16;i++){const t=[];As.push(t);for(let e=0;e<16;e++){const s=Ai(ce[i]*ce[e]+de[i]*ue[e]),r=Ai(ue[i]*ce[e]+fe[i]*ue[e]),n=Ai(ce[i]*de[e]+de[i]*fe[e]),o=Ai(ue[i]*de[e]+fe[i]*fe[e]);for(let a=0;a<16;a++)if(ce[a]===s&&ue[a]===r&&de[a]===n&&fe[a]===o){t.push(a);break}}}for(let i=0;i<16;i++){const t=new et;t.set(ce[i],ue[i],de[i],fe[i],0,0),Fn.push(t)}}rh();const J={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>ce[i],uY:i=>ue[i],vX:i=>de[i],vY:i=>fe[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>As[i][t],sub:(i,t)=>As[i][J.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?J.S:J.N:Math.abs(t)*2<=Math.abs(i)?i>0?J.E:J.W:t>0?i>0?J.SE:J.SW:i>0?J.NE:J.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const r=Fn[J.inv(t)];r.tx=e,r.ty=s,i.append(r)}},Ln=class{constructor(){this.worldTransform=new et,this.localTransform=new et,this.position=new Jt(this.onChange,this,0,0),this.scale=new Jt(this.onChange,this,1,1),this.pivot=new Jt(this.onChange,this,0,0),this.skew=new Jt(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const i=this.localTransform;this._localID!==this._currentLocalID&&(i.a=this._cx*this.scale.x,i.b=this._sx*this.scale.x,i.c=this._cy*this.scale.y,i.d=this._sy*this.scale.y,i.tx=this.position.x-(this.pivot.x*i.a+this.pivot.y*i.c),i.ty=this.position.y-(this.pivot.x*i.b+this.pivot.y*i.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(i){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==i._worldID){const e=i.worldTransform,s=this.worldTransform;s.a=t.a*e.a+t.b*e.c,s.b=t.a*e.b+t.b*e.d,s.c=t.c*e.a+t.d*e.c,s.d=t.c*e.b+t.d*e.d,s.tx=t.tx*e.a+t.ty*e.c+e.tx,s.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=i._worldID,this._worldID++}}setFromMatrix(i){i.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(i){this._rotation!==i&&(this._rotation=i,this.updateSkew())}};let Xe=Ln;Xe.IDENTITY=new Ln;class Tt{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,s,r,n,o,a,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][l](t,e,s,r,n,o,a,h);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),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}}Object.defineProperties(Tt.prototype,{dispatch:{value:Tt.prototype.emit},run:{value:Tt.prototype.emit}}),S.TARGET_FPMS=.06;var re=(i=>(i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(re||{});class Ss{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}}class Z{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 Ss(null,null,1/0),this.deltaMS=1/S.TARGET_FPMS,this.elapsedMS=1/S.TARGET_FPMS,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=re.NORMAL){return this._addListener(new Ss(t,e,s))}addOnce(t,e,s=re.NORMAL){return this._addListener(new Ss(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*S.TARGET_FPMS;const s=this._head;let r=s.next;for(;r;)r=r.emit(this.deltaTime);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,S.TARGET_FPMS);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(!Z._shared){const t=Z._shared=new Z;t.autoStart=!0,t._protected=!0}return Z._shared}static get system(){if(!Z._system){const t=Z._system=new Z;t.autoStart=!0,t._protected=!0}return Z._system}}class Rs{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,re.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Z.shared:new Z,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Rs.extension=P.Application,U.add(Rs);var Cs=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ip(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Is(i,t,e){return e={path:t,exports:{},require:function(s,r){return nh(s,r==null?e.path:r)}},i(e,e.exports),e.exports}function Pp(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Mp(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")&&Object.keys(i).length===1?i.default:i}function Bp(i){if(i.__esModule)return i;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(i).forEach(function(e){var s=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:function(){return i[e]}})}),t}function nh(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Re=Is(function(i){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function r(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||h,d),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,c,u,d,f,p){var m=e?e+l:l;if(!this._events[m])return!1;var _=this._events[m],x=arguments.length,y,g;if(_.fn){switch(_.once&&this.removeListener(l,_.fn,void 0,!0),x){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,c),!0;case 3:return _.fn.call(_.context,c,u),!0;case 4:return _.fn.call(_.context,c,u,d),!0;case 5:return _.fn.call(_.context,c,u,d,f),!0;case 6:return _.fn.call(_.context,c,u,d,f,p),!0}for(g=1,y=new Array(x-1);g<x;g++)y[g-1]=arguments[g];_.fn.apply(_.context,y)}else{var v=_.length,b;for(g=0;g<v;g++)switch(_[g].once&&this.removeListener(l,_[g].fn,void 0,!0),x){case 1:_[g].fn.call(_[g].context);break;case 2:_[g].fn.call(_[g].context,c);break;case 3:_[g].fn.call(_[g].context,c,u);break;case 4:_[g].fn.call(_[g].context,c,u,d);break;default:if(!y)for(b=1,y=new Array(x-1);b<x;b++)y[b-1]=arguments[b];_[g].fn.apply(_[g].context,y)}}return!0},a.prototype.on=function(l,c,u){return n(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return n(this,l,c,u,!0)},a.prototype.removeListener=function(l,c,u,d){var f=e?e+l:l;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,_=[],x=p.length;m<x;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&_.push(p[m]);_.length?this._events[f]=_.length===1?_[0]:_:o(this,f)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&o(this,c)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,i.exports=a}),Ps=Si,oh=Si;function Si(i,t,e){e=e||2;var s=t&&t.length,r=s?t[0]*e:i.length,n=Un(i,0,r,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,h,l,c,u,d,f;if(s&&(n=uh(i,t,n,e)),i.length>80*e){a=l=i[0],h=c=i[1];for(var p=e;p<r;p+=e)u=i[p],d=i[p+1],u<a&&(a=u),d<h&&(h=d),u>l&&(l=u),d>c&&(c=d);f=Math.max(l-a,c-h),f=f!==0?32767/f:0}return Ve(n,o,e,a,h,f,0),o}function Un(i,t,e,s,r){var n,o;if(r===Ds(i,t,e,s)>0)for(n=t;n<e;n+=s)o=Gn(n,i[n],i[n+1],o);else for(n=e-s;n>=t;n-=s)o=Gn(n,i[n],i[n+1],o);return o&&Ri(o,o.next)&&(We(o),o=o.next),o}function pe(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Ri(e,e.next)||it(e.prev,e,e.next)===0)){if(We(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Ve(i,t,e,s,r,n,o){if(!!i){!o&&n&&_h(i,s,r,n);for(var a=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,n?hh(i,s,r,n):ah(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),We(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=lh(pe(i),t,e),Ve(i,t,e,s,r,n,2)):o===2&&ch(i,t,e,s,r,n):Ve(pe(i),t,e,s,r,n,1);break}}}}function ah(i){var t=i.prev,e=i,s=i.next;if(it(t,e,s)>=0)return!1;for(var r=t.x,n=e.x,o=s.x,a=t.y,h=e.y,l=s.y,c=r<n?r<o?r:o:n<o?n:o,u=a<h?a<l?a:l:h<l?h:l,d=r>n?r>o?r:o:n>o?n:o,f=a>h?a>l?a:l:h>l?h:l,p=s.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&Ce(r,a,n,h,o,l,p.x,p.y)&&it(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function hh(i,t,e,s){var r=i.prev,n=i,o=i.next;if(it(r,n,o)>=0)return!1;for(var a=r.x,h=n.x,l=o.x,c=r.y,u=n.y,d=o.y,f=a<h?a<l?a:l:h<l?h:l,p=c<u?c<d?c:d:u<d?u:d,m=a>h?a>l?a:l:h>l?h:l,_=c>u?c>d?c:d:u>d?u:d,x=Ms(f,p,t,e,s),y=Ms(m,_,t,e,s),g=i.prevZ,v=i.nextZ;g&&g.z>=x&&v&&v.z<=y;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==r&&g!==o&&Ce(a,c,h,u,l,d,g.x,g.y)&&it(g.prev,g,g.next)>=0||(g=g.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==r&&v!==o&&Ce(a,c,h,u,l,d,v.x,v.y)&&it(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;g&&g.z>=x;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==r&&g!==o&&Ce(a,c,h,u,l,d,g.x,g.y)&&it(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;v&&v.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==r&&v!==o&&Ce(a,c,h,u,l,d,v.x,v.y)&&it(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function lh(i,t,e){var s=i;do{var r=s.prev,n=s.next.next;!Ri(r,n)&&On(r,s,s.next,n)&&ze(r,n)&&ze(n,r)&&(t.push(r.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),We(s),We(s.next),s=i=n),s=s.next}while(s!==i);return pe(s)}function ch(i,t,e,s,r,n){var o=i;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&vh(o,a)){var h=kn(o,a);o=pe(o,o.next),h=pe(h,h.next),Ve(o,t,e,s,r,n,0),Ve(h,t,e,s,r,n,0);return}a=a.next}o=o.next}while(o!==i)}function uh(i,t,e,s){var r=[],n,o,a,h,l;for(n=0,o=t.length;n<o;n++)a=t[n]*s,h=n<o-1?t[n+1]*s:i.length,l=Un(i,a,h,s,!1),l===l.next&&(l.steiner=!0),r.push(xh(l));for(r.sort(dh),n=0;n<r.length;n++)e=fh(r[n],e);return e}function dh(i,t){return i.x-t.x}function fh(i,t){var e=ph(i,t);if(!e)return t;var s=kn(e,i);return pe(s,s.next),pe(e,e.next)}function ph(i,t){var e=t,s=i.x,r=i.y,n=-1/0,o;do{if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){var a=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=s&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===s))return o}e=e.next}while(e!==t);if(!o)return null;var h=o,l=o.x,c=o.y,u=1/0,d;e=o;do s>=e.x&&e.x>=l&&s!==e.x&&Ce(r<c?s:n,r,l,c,r<c?n:s,r,e.x,e.y)&&(d=Math.abs(r-e.y)/(s-e.x),ze(e,i)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&mh(o,e)))&&(o=e,u=d)),e=e.next;while(e!==h);return o}function mh(i,t){return it(i.prev,i,t.prev)<0&&it(t.next,i,i.next)<0}function _h(i,t,e,s){var r=i;do r.z===0&&(r.z=Ms(r.x,r.y,t,e,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,gh(r)}function gh(i){var t,e,s,r,n,o,a,h,l=1;do{for(e=i,i=null,n=null,o=0;e;){for(o++,s=e,a=0,t=0;t<l&&(a++,s=s.nextZ,!!s);t++);for(h=l;a>0||h>0&&s;)a!==0&&(h===0||!s||e.z<=s.z)?(r=e,e=e.nextZ,a--):(r=s,s=s.nextZ,h--),n?n.nextZ=r:i=r,r.prevZ=n,n=r;e=s}n.nextZ=null,l*=2}while(o>1);return i}function Ms(i,t,e,s,r){return i=(i-e)*r|0,t=(t-s)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function xh(i){var t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Ce(i,t,e,s,r,n,o,a){return(r-o)*(t-a)>=(i-o)*(n-a)&&(i-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(r-o)*(s-a)}function vh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!yh(i,t)&&(ze(i,t)&&ze(t,i)&&Th(i,t)&&(it(i.prev,i,t.prev)||it(i,t.prev,t))||Ri(i,t)&&it(i.prev,i,i.next)>0&&it(t.prev,t,t.next)>0)}function it(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Ri(i,t){return i.x===t.x&&i.y===t.y}function On(i,t,e,s){var r=Ii(it(i,t,e)),n=Ii(it(i,t,s)),o=Ii(it(e,s,i)),a=Ii(it(e,s,t));return!!(r!==n&&o!==a||r===0&&Ci(i,e,t)||n===0&&Ci(i,s,t)||o===0&&Ci(e,i,s)||a===0&&Ci(e,t,s))}function Ci(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function Ii(i){return i>0?1:i<0?-1:0}function yh(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&On(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function ze(i,t){return it(i.prev,i,i.next)<0?it(i,t,i.next)>=0&&it(i,i.prev,t)>=0:it(i,t,i.prev)<0||it(i,i.next,t)<0}function Th(i,t){var e=i,s=!1,r=(i.x+t.x)/2,n=(i.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function kn(i,t){var e=new Bs(i.i,i.x,i.y),s=new Bs(t.i,t.x,t.y),r=i.next,n=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function Gn(i,t,e,s){var r=new Bs(i,t,e);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function We(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Bs(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Si.deviation=function(i,t,e,s){var r=t&&t.length,n=r?t[0]*e:i.length,o=Math.abs(Ds(i,0,n,e));if(r)for(var a=0,h=t.length;a<h;a++){var l=t[a]*e,c=a<h-1?t[a+1]*e:i.length;o-=Math.abs(Ds(i,l,c,e))}var u=0;for(a=0;a<s.length;a+=3){var d=s[a]*e,f=s[a+1]*e,p=s[a+2]*e;u+=Math.abs((i[d]-i[p])*(i[f+1]-i[d+1])-(i[d]-i[f])*(i[p+1]-i[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Ds(i,t,e,s){for(var r=0,n=t,o=e-s;n<e;n+=s)r+=(i[o]-i[n])*(i[n+1]+i[o+1]),o=n;return r}Si.flatten=function(i){for(var t=i[0][0].length,e={vertices:[],holes:[],dimensions:t},s=0,r=0;r<i.length;r++){for(var n=0;n<i[r].length;n++)for(var o=0;o<t;o++)e.vertices.push(i[r][n][o]);r>0&&(s+=i[r-1].length,e.holes.push(s))}return e},Ps.default=oh;var bh=Is(function(i,t){/*! https://mths.be/punycode v1.3.2 by @mathias */(function(e){var s=t&&!t.nodeType&&t,r=i&&!i.nodeType&&i,n=typeof Cs=="object"&&Cs;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,h=36,l=1,c=26,u=38,d=700,f=72,p=128,m="-",_=/^xn--/,x=/[^\x20-\x7E]/,y=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=h-l,b=Math.floor,M=String.fromCharCode,R;function w(A){throw RangeError(g[A])}function L(A,H){for(var Y=A.length,q=[];Y--;)q[Y]=H(A[Y]);return q}function G(A,H){var Y=A.split("@"),q="";Y.length>1&&(q=Y[0]+"@",A=Y[1]),A=A.replace(y,".");var K=A.split("."),ct=L(K,H).join(".");return q+ct}function I(A){for(var H=[],Y=0,q=A.length,K,ct;Y<q;)K=A.charCodeAt(Y++),K>=55296&&K<=56319&&Y<q?(ct=A.charCodeAt(Y++),(ct&64512)==56320?H.push(((K&1023)<<10)+(ct&1023)+65536):(H.push(K),Y--)):H.push(K);return H}function N(A){return L(A,function(H){var Y="";return H>65535&&(H-=65536,Y+=M(H>>>10&1023|55296),H=56320|H&1023),Y+=M(H),Y}).join("")}function E(A){return A-48<10?A-22:A-65<26?A-65:A-97<26?A-97:h}function T(A,H){return A+22+75*(A<26)-((H!=0)<<5)}function X(A,H,Y){var q=0;for(A=Y?b(A/d):A>>1,A+=b(A/H);A>v*c>>1;q+=h)A=b(A/v);return b(q+(v+1)*A/(A+u))}function z(A){var H=[],Y=A.length,q,K=0,ct=p,ot=f,ut,mt,gt,pt,Q,at,lt,kt,Gt;for(ut=A.lastIndexOf(m),ut<0&&(ut=0),mt=0;mt<ut;++mt)A.charCodeAt(mt)>=128&&w("not-basic"),H.push(A.charCodeAt(mt));for(gt=ut>0?ut+1:0;gt<Y;){for(pt=K,Q=1,at=h;gt>=Y&&w("invalid-input"),lt=E(A.charCodeAt(gt++)),(lt>=h||lt>b((a-K)/Q))&&w("overflow"),K+=lt*Q,kt=at<=ot?l:at>=ot+c?c:at-ot,!(lt<kt);at+=h)Gt=h-kt,Q>b(a/Gt)&&w("overflow"),Q*=Gt;q=H.length+1,ot=X(K-pt,q,pt==0),b(K/q)>a-ct&&w("overflow"),ct+=b(K/q),K%=q,H.splice(K++,0,ct)}return N(H)}function D(A){var H,Y,q,K,ct,ot,ut,mt,gt,pt,Q,at=[],lt,kt,Gt,Ge;for(A=I(A),lt=A.length,H=p,Y=0,ct=f,ot=0;ot<lt;++ot)Q=A[ot],Q<128&&at.push(M(Q));for(q=K=at.length,K&&at.push(m);q<lt;){for(ut=a,ot=0;ot<lt;++ot)Q=A[ot],Q>=H&&Q<ut&&(ut=Q);for(kt=q+1,ut-H>b((a-Y)/kt)&&w("overflow"),Y+=(ut-H)*kt,H=ut,ot=0;ot<lt;++ot)if(Q=A[ot],Q<H&&++Y>a&&w("overflow"),Q==H){for(mt=Y,gt=h;pt=gt<=ct?l:gt>=ct+c?c:gt-ct,!(mt<pt);gt+=h)Ge=mt-pt,Gt=h-pt,at.push(M(T(pt+Ge%Gt,0))),mt=b(Ge/Gt);at.push(M(T(mt,0))),ct=X(Y,kt,q==K),Y=0,++q}++Y,++H}return at.join("")}function $(A){return G(A,function(H){return _.test(H)?z(H.slice(4).toLowerCase()):H})}function st(A){return G(A,function(H){return x.test(H)?"xn--"+D(H):H})}if(o={version:"1.3.2",ucs2:{decode:I,encode:N},decode:z,encode:D,toASCII:st,toUnicode:$},s&&r)if(i.exports==s)r.exports=o;else for(R in o)o.hasOwnProperty(R)&&(s[R]=o[R]);else e.punycode=o})(Cs)}),zt={isString:function(i){return typeof i=="string"},isObject:function(i){return typeof i=="object"&&i!==null},isNull:function(i){return i===null},isNullOrUndefined:function(i){return i==null}};function Eh(i,t){return Object.prototype.hasOwnProperty.call(i,t)}var wh=function(i,t,e,s){t=t||"&",e=e||"=";var r={};if(typeof i!="string"||i.length===0)return r;var n=/\+/g;i=i.split(t);var o=1e3;s&&typeof s.maxKeys=="number"&&(o=s.maxKeys);var a=i.length;o>0&&a>o&&(a=o);for(var h=0;h<a;++h){var l=i[h].replace(n,"%20"),c=l.indexOf(e),u,d,f,p;c>=0?(u=l.substr(0,c),d=l.substr(c+1)):(u=l,d=""),f=decodeURIComponent(u),p=decodeURIComponent(d),Eh(r,f)?Array.isArray(r[f])?r[f].push(p):r[f]=[r[f],p]:r[f]=p}return r},je=function(i){switch(typeof i){case"string":return i;case"boolean":return i?"true":"false";case"number":return isFinite(i)?i:"";default:return""}},Ah=function(i,t,e,s){return t=t||"&",e=e||"=",i===null&&(i=void 0),typeof i=="object"?Object.keys(i).map(function(r){var n=encodeURIComponent(je(r))+e;return Array.isArray(i[r])?i[r].map(function(o){return n+encodeURIComponent(je(o))}).join(t):n+encodeURIComponent(je(i[r]))}).join(t):s?encodeURIComponent(je(s))+e+encodeURIComponent(je(i)):""},Ns=Is(function(i,t){"use strict";t.decode=t.parse=wh,t.encode=t.stringify=Ah}),Hn=Ye,Xn=Uh,Sh=Oh,Vn=Lh,Rh=wt;function wt(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Ch=/^([a-z0-9.+-]+:)/i,Ih=/:[0-9]*$/,Ph=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Mh=["<",">",'"',"`"," ","\r",`
7
+ */var se=(i=>(i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",i))(se||{}),xn=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS",i))(xn||{}),yi=(i=>(i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL",i))(yi||{}),k=(i=>(i[i.NORMAL=0]="NORMAL",i[i.ADD=1]="ADD",i[i.MULTIPLY=2]="MULTIPLY",i[i.SCREEN=3]="SCREEN",i[i.OVERLAY=4]="OVERLAY",i[i.DARKEN=5]="DARKEN",i[i.LIGHTEN=6]="LIGHTEN",i[i.COLOR_DODGE=7]="COLOR_DODGE",i[i.COLOR_BURN=8]="COLOR_BURN",i[i.HARD_LIGHT=9]="HARD_LIGHT",i[i.SOFT_LIGHT=10]="SOFT_LIGHT",i[i.DIFFERENCE=11]="DIFFERENCE",i[i.EXCLUSION=12]="EXCLUSION",i[i.HUE=13]="HUE",i[i.SATURATION=14]="SATURATION",i[i.COLOR=15]="COLOR",i[i.LUMINOSITY=16]="LUMINOSITY",i[i.NORMAL_NPM=17]="NORMAL_NPM",i[i.ADD_NPM=18]="ADD_NPM",i[i.SCREEN_NPM=19]="SCREEN_NPM",i[i.NONE=20]="NONE",i[i.SRC_OVER=0]="SRC_OVER",i[i.SRC_IN=21]="SRC_IN",i[i.SRC_OUT=22]="SRC_OUT",i[i.SRC_ATOP=23]="SRC_ATOP",i[i.DST_OVER=24]="DST_OVER",i[i.DST_IN=25]="DST_IN",i[i.DST_OUT=26]="DST_OUT",i[i.DST_ATOP=27]="DST_ATOP",i[i.ERASE=26]="ERASE",i[i.SUBTRACT=28]="SUBTRACT",i[i.XOR=29]="XOR",i))(k||{}),It=(i=>(i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i))(It||{}),C=(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))(C||{}),le=(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))(le||{}),O=(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))(O||{}),Ti=(i=>(i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT",i))(Ti||{}),Xt=(i=>(i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR",i))(Xt||{}),Vt=(i=>(i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i))(Vt||{}),Pt=(i=>(i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL",i))(Pt||{}),Et=(i=>(i[i.NPM=0]="NPM",i[i.UNPACK=1]="UNPACK",i[i.PMA=2]="PMA",i[i.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",i[i.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",i[i.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",i))(Et||{}),Mt=(i=>(i[i.NO=0]="NO",i[i.YES=1]="YES",i[i.AUTO=2]="AUTO",i[i.BLEND=0]="BLEND",i[i.CLEAR=1]="CLEAR",i[i.BLIT=2]="BLIT",i))(Mt||{}),bi=(i=>(i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL",i))(bi||{}),yt=(i=>(i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp",i))(yt||{}),ht=(i=>(i[i.NONE=0]="NONE",i[i.SCISSOR=1]="SCISSOR",i[i.STENCIL=2]="STENCIL",i[i.SPRITE=3]="SPRITE",i[i.COLOR=4]="COLOR",i))(ht||{}),vn=(i=>(i[i.RED=1]="RED",i[i.GREEN=2]="GREEN",i[i.BLUE=4]="BLUE",i[i.ALPHA=8]="ALPHA",i))(vn||{}),nt=(i=>(i[i.NONE=0]="NONE",i[i.LOW=2]="LOW",i[i.MEDIUM=4]="MEDIUM",i[i.HIGH=8]="HIGH",i))(nt||{}),Bt=(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))(Bt||{});const yn={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},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)};var Es=/iPhone/i,Tn=/iPod/i,bn=/iPad/i,En=/\biOS-universal(?:.+)Mac\b/i,ws=/\bAndroid(?:.+)Mobile\b/i,wn=/Android/i,Se=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ei=/Silk/i,$t=/Windows Phone/i,An=/\bWindows(?:.+)ARM\b/i,Sn=/BlackBerry/i,Rn=/BB10/i,Cn=/Opera Mini/i,In=/\b(CriOS|Chrome)(?:.+)Mobile/i,Pn=/Mobile(?:.+)Firefox\b/i,Mn=function(i){return typeof i!="undefined"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream=="undefined"};function th(i){return function(t){return t.test(i)}}function eh(i){var t={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?t.userAgent=i:i&&i.userAgent&&(t={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]!="undefined"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]!="undefined"&&(e=s[0]);var r=th(e),n={apple:{phone:r(Es)&&!r($t),ipod:r(Tn),tablet:!r(Es)&&(r(bn)||Mn(t))&&!r($t),universal:r(En),device:(r(Es)||r(Tn)||r(bn)||r(En)||Mn(t))&&!r($t)},amazon:{phone:r(Se),tablet:!r(Se)&&r(Ei),device:r(Se)||r(Ei)},android:{phone:!r($t)&&r(Se)||!r($t)&&r(ws),tablet:!r($t)&&!r(Se)&&!r(ws)&&(r(Ei)||r(wn)),device:!r($t)&&(r(Se)||r(Ei)||r(ws)||r(wn))||r(/\bokhttp\b/i)},windows:{phone:r($t),tablet:r(An),device:r($t)||r(An)},other:{blackberry:r(Sn),blackberry10:r(Rn),opera:r(Cn),firefox:r(Pn),chrome:r(In),device:r(Sn)||r(Rn)||r(Cn)||r(Pn)||r(In)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const Dt=eh(globalThis.navigator);function ih(){return!Dt.apple.device}function sh(i){let t=!0;if(Dt.tablet||Dt.phone){if(Dt.apple.device){const e=navigator.userAgent.match(/OS (\d+)_(\d+)?/);e&&parseInt(e[1],10)<11&&(t=!1)}if(Dt.android.device){const e=navigator.userAgent.match(/Android\s([0-9.]*)/);e&&parseInt(e[1],10)<7&&(t=!1)}}return t?i:4}const S={ADAPTER:yn,MIPMAP_TEXTURES:Pt.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:nt.NONE,SPRITE_MAX_TEXTURES:sh(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,antialias:!1,autoDensity:!1,backgroundColor:0,backgroundAlpha:1,useContextAlpha:!0,clearBeforeRender:!0,preserveDrawingBuffer:!1,width:800,height:600,legacy:!1,hello:!1},GC_MODE:bi.AUTO,GC_MAX_IDLE:60*60,GC_MAX_CHECK_COUNT:60*10,WRAP_MODE:Vt.CLAMP,SCALE_MODE:Xt.LINEAR,PRECISION_VERTEX:yt.HIGH,PRECISION_FRAGMENT:Dt.apple.device?yt.HIGH:yt.MEDIUM,CAN_UPLOAD_SAME_BUFFER:ih(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};S.PREFER_ENV=se.WEBGL2,S.STRICT_TEXTURE_CACHE=!1;var P=(i=>(i.Renderer="renderer",i.Application="application",i.RendererSystem="renderer-webgl-system",i.RendererPlugin="renderer-webgl-plugin",i.CanvasRendererSystem="renderer-canvas-system",i.CanvasRendererPlugin="renderer-canvas-plugin",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i))(P||{});const Bn=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){const t=typeof i.extension!="object"?{type:i.extension}:i.extension;i=Ts(Ht({},t),{ref:i})}if(typeof i=="object")i=Ht({},i);else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},U={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Bn).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(Bn).forEach(t=>{t.type.forEach(e=>{const s=this._addHandlers,r=this._queue;s[e]?s[e](t):(r[e]=r[e]||[],r[e].push(t))})}),this},handle(i,t,e){const s=this._addHandlers,r=this._removeHandlers;s[i]=t,r[i]=e;const n=this._queue;return n[i]&&(n[i].forEach(o=>t(o)),delete n[i]),this},handleByMap(i,t){return this.handle(i,e=>{t[e.name]=e.ref},e=>{delete t[e.name]})},handleByList(i,t){return this.handle(i,e=>{t.includes(e.ref)||(t.push(e.ref),t.sort((s,r)=>{var n,o;return((n=r.priority)!=null?n:-1)-((o=s.priority)!=null?o:-1)}))},e=>{const s=t.indexOf(e.ref);s!==-1&&t.splice(s,1)})}},He=Math.PI*2,Dn=180/Math.PI,Nn=Math.PI/180;var dt=(i=>(i[i.POLY=0]="POLY",i[i.RECT=1]="RECT",i[i.CIRC=2]="CIRC",i[i.ELIP=3]="ELIP",i[i.RREC=4]="RREC",i))(dt||{});class j{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new j(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}const wi=[new j,new j,new j,new j];class V{constructor(t=0,e=0,s=0,r=0){this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(r),this.type=dt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new V(0,0,0,0)}clone(){return new V(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const w=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=w)return!1;const G=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>G}const s=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=s||o<=n)return!1;const a=wi[0].set(t.left,t.top),h=wi[1].set(t.left,t.bottom),l=wi[2].set(t.right,t.top),c=wi[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=s||Math.min(a.x,h.x,l.x,c.x)>=r||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const d=u*(h.y-a.y),f=u*(a.x-h.x),p=d*s+f*n,m=d*r+f*n,_=d*s+f*o,x=d*r+f*o;if(Math.max(p,m,_,x)<=d*a.x+f*a.y||Math.min(p,m,_,x)>=d*c.x+f*c.y)return!1;const y=u*(a.y-l.y),g=u*(l.x-a.x),v=y*s+g*n,b=y*r+g*n,M=y*s+g*o,R=y*r+g*o;return!(Math.max(v,b,M,R)<=y*a.x+g*a.y||Math.min(v,b,M,R)>=y*c.x+g*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=r,this.height=n-r,this}}class ps{constructor(t=0,e=0,s=0){this.x=t,this.y=e,this.radius=s,this.type=dt.CIRC}clone(){return new ps(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}getBounds(){return new V(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}class ms{constructor(t=0,e=0,s=0,r=0){this.x=t,this.y=e,this.width=s,this.height=r,this.type=dt.ELIP}clone(){return new ms(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let s=(t-this.x)/this.width,r=(e-this.y)/this.height;return s*=s,r*=r,s+r<=1}getBounds(){return new V(this.x-this.width,this.y-this.height,this.width,this.height)}}class we{constructor(...t){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.type=dt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new we(t);return e.closeStroke=this.closeStroke,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],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(s=!s)}return s}}class _s{constructor(t=0,e=0,s=0,r=0,n=20){this.x=t,this.y=e,this.width=s,this.height=r,this.radius=n,this.type=dt.RREC}clone(){return new _s(this.x,this.y,this.width,this.height,this.radius)}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}}class Jt{constructor(t,e,s=0,r=0){this._x=s,this._y=r,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new Jt(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}class et{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 j;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 j;const s=1/(this.a*this.d+this.c*-this.b),r=t.x,n=t.y;return e.x=this.d*s*r+-this.c*s*n+(this.ty*this.c-this.tx*this.d)*s,e.y=this.a*s*n+-this.b*s*r+(-this.ty*this.a+this.tx*this.b)*s,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}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(He-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}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 et;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}static get IDENTITY(){return new et}static get TEMP_MATRIX(){return new et}}const ce=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ue=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],de=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],fe=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],As=[],Fn=[],Ai=Math.sign;function rh(){for(let i=0;i<16;i++){const t=[];As.push(t);for(let e=0;e<16;e++){const s=Ai(ce[i]*ce[e]+de[i]*ue[e]),r=Ai(ue[i]*ce[e]+fe[i]*ue[e]),n=Ai(ce[i]*de[e]+de[i]*fe[e]),o=Ai(ue[i]*de[e]+fe[i]*fe[e]);for(let a=0;a<16;a++)if(ce[a]===s&&ue[a]===r&&de[a]===n&&fe[a]===o){t.push(a);break}}}for(let i=0;i<16;i++){const t=new et;t.set(ce[i],ue[i],de[i],fe[i],0,0),Fn.push(t)}}rh();const J={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>ce[i],uY:i=>ue[i],vX:i=>de[i],vY:i=>fe[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>As[i][t],sub:(i,t)=>As[i][J.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?J.S:J.N:Math.abs(t)*2<=Math.abs(i)?i>0?J.E:J.W:t>0?i>0?J.SE:J.SW:i>0?J.NE:J.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const r=Fn[J.inv(t)];r.tx=e,r.ty=s,i.append(r)}},Ln=class{constructor(){this.worldTransform=new et,this.localTransform=new et,this.position=new Jt(this.onChange,this,0,0),this.scale=new Jt(this.onChange,this,1,1),this.pivot=new Jt(this.onChange,this,0,0),this.skew=new Jt(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const i=this.localTransform;this._localID!==this._currentLocalID&&(i.a=this._cx*this.scale.x,i.b=this._sx*this.scale.x,i.c=this._cy*this.scale.y,i.d=this._sy*this.scale.y,i.tx=this.position.x-(this.pivot.x*i.a+this.pivot.y*i.c),i.ty=this.position.y-(this.pivot.x*i.b+this.pivot.y*i.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(i){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==i._worldID){const e=i.worldTransform,s=this.worldTransform;s.a=t.a*e.a+t.b*e.c,s.b=t.a*e.b+t.b*e.d,s.c=t.c*e.a+t.d*e.c,s.d=t.c*e.b+t.d*e.d,s.tx=t.tx*e.a+t.ty*e.c+e.tx,s.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=i._worldID,this._worldID++}}setFromMatrix(i){i.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(i){this._rotation!==i&&(this._rotation=i,this.updateSkew())}};let Xe=Ln;Xe.IDENTITY=new Ln;class Tt{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,s,r,n,o,a,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][l](t,e,s,r,n,o,a,h);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),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}}Object.defineProperties(Tt.prototype,{dispatch:{value:Tt.prototype.emit},run:{value:Tt.prototype.emit}}),S.TARGET_FPMS=.06;var re=(i=>(i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(re||{});class Ss{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}}class Z{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 Ss(null,null,1/0),this.deltaMS=1/S.TARGET_FPMS,this.elapsedMS=1/S.TARGET_FPMS,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=re.NORMAL){return this._addListener(new Ss(t,e,s))}addOnce(t,e,s=re.NORMAL){return this._addListener(new Ss(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*S.TARGET_FPMS;const s=this._head;let r=s.next;for(;r;)r=r.emit(this.deltaTime);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,S.TARGET_FPMS);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(!Z._shared){const t=Z._shared=new Z;t.autoStart=!0,t._protected=!0}return Z._shared}static get system(){if(!Z._system){const t=Z._system=new Z;t.autoStart=!0,t._protected=!0}return Z._system}}class Rs{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,re.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Z.shared:new Z,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Rs.extension=P.Application,U.add(Rs);var Cs=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ip(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Is(i,t,e){return e={path:t,exports:{},require:function(s,r){return nh(s,r==null?e.path:r)}},i(e,e.exports),e.exports}function Pp(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Mp(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")&&Object.keys(i).length===1?i.default:i}function Bp(i){if(i.__esModule)return i;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(i).forEach(function(e){var s=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:function(){return i[e]}})}),t}function nh(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Re=Is(function(i){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function r(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||h,d),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,c,u,d,f,p){var m=e?e+l:l;if(!this._events[m])return!1;var _=this._events[m],x=arguments.length,y,g;if(_.fn){switch(_.once&&this.removeListener(l,_.fn,void 0,!0),x){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,c),!0;case 3:return _.fn.call(_.context,c,u),!0;case 4:return _.fn.call(_.context,c,u,d),!0;case 5:return _.fn.call(_.context,c,u,d,f),!0;case 6:return _.fn.call(_.context,c,u,d,f,p),!0}for(g=1,y=new Array(x-1);g<x;g++)y[g-1]=arguments[g];_.fn.apply(_.context,y)}else{var v=_.length,b;for(g=0;g<v;g++)switch(_[g].once&&this.removeListener(l,_[g].fn,void 0,!0),x){case 1:_[g].fn.call(_[g].context);break;case 2:_[g].fn.call(_[g].context,c);break;case 3:_[g].fn.call(_[g].context,c,u);break;case 4:_[g].fn.call(_[g].context,c,u,d);break;default:if(!y)for(b=1,y=new Array(x-1);b<x;b++)y[b-1]=arguments[b];_[g].fn.apply(_[g].context,y)}}return!0},a.prototype.on=function(l,c,u){return n(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return n(this,l,c,u,!0)},a.prototype.removeListener=function(l,c,u,d){var f=e?e+l:l;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,_=[],x=p.length;m<x;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&_.push(p[m]);_.length?this._events[f]=_.length===1?_[0]:_:o(this,f)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&o(this,c)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,i.exports=a}),Ps=Si,oh=Si;function Si(i,t,e){e=e||2;var s=t&&t.length,r=s?t[0]*e:i.length,n=Un(i,0,r,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,h,l,c,u,d,f;if(s&&(n=uh(i,t,n,e)),i.length>80*e){a=l=i[0],h=c=i[1];for(var p=e;p<r;p+=e)u=i[p],d=i[p+1],u<a&&(a=u),d<h&&(h=d),u>l&&(l=u),d>c&&(c=d);f=Math.max(l-a,c-h),f=f!==0?32767/f:0}return Ve(n,o,e,a,h,f,0),o}function Un(i,t,e,s,r){var n,o;if(r===Ds(i,t,e,s)>0)for(n=t;n<e;n+=s)o=Gn(n,i[n],i[n+1],o);else for(n=e-s;n>=t;n-=s)o=Gn(n,i[n],i[n+1],o);return o&&Ri(o,o.next)&&(We(o),o=o.next),o}function pe(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Ri(e,e.next)||it(e.prev,e,e.next)===0)){if(We(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Ve(i,t,e,s,r,n,o){if(!!i){!o&&n&&_h(i,s,r,n);for(var a=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,n?hh(i,s,r,n):ah(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),We(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=lh(pe(i),t,e),Ve(i,t,e,s,r,n,2)):o===2&&ch(i,t,e,s,r,n):Ve(pe(i),t,e,s,r,n,1);break}}}}function ah(i){var t=i.prev,e=i,s=i.next;if(it(t,e,s)>=0)return!1;for(var r=t.x,n=e.x,o=s.x,a=t.y,h=e.y,l=s.y,c=r<n?r<o?r:o:n<o?n:o,u=a<h?a<l?a:l:h<l?h:l,d=r>n?r>o?r:o:n>o?n:o,f=a>h?a>l?a:l:h>l?h:l,p=s.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&Ce(r,a,n,h,o,l,p.x,p.y)&&it(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function hh(i,t,e,s){var r=i.prev,n=i,o=i.next;if(it(r,n,o)>=0)return!1;for(var a=r.x,h=n.x,l=o.x,c=r.y,u=n.y,d=o.y,f=a<h?a<l?a:l:h<l?h:l,p=c<u?c<d?c:d:u<d?u:d,m=a>h?a>l?a:l:h>l?h:l,_=c>u?c>d?c:d:u>d?u:d,x=Ms(f,p,t,e,s),y=Ms(m,_,t,e,s),g=i.prevZ,v=i.nextZ;g&&g.z>=x&&v&&v.z<=y;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==r&&g!==o&&Ce(a,c,h,u,l,d,g.x,g.y)&&it(g.prev,g,g.next)>=0||(g=g.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==r&&v!==o&&Ce(a,c,h,u,l,d,v.x,v.y)&&it(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;g&&g.z>=x;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==r&&g!==o&&Ce(a,c,h,u,l,d,g.x,g.y)&&it(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;v&&v.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==r&&v!==o&&Ce(a,c,h,u,l,d,v.x,v.y)&&it(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function lh(i,t,e){var s=i;do{var r=s.prev,n=s.next.next;!Ri(r,n)&&On(r,s,s.next,n)&&ze(r,n)&&ze(n,r)&&(t.push(r.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),We(s),We(s.next),s=i=n),s=s.next}while(s!==i);return pe(s)}function ch(i,t,e,s,r,n){var o=i;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&vh(o,a)){var h=kn(o,a);o=pe(o,o.next),h=pe(h,h.next),Ve(o,t,e,s,r,n,0),Ve(h,t,e,s,r,n,0);return}a=a.next}o=o.next}while(o!==i)}function uh(i,t,e,s){var r=[],n,o,a,h,l;for(n=0,o=t.length;n<o;n++)a=t[n]*s,h=n<o-1?t[n+1]*s:i.length,l=Un(i,a,h,s,!1),l===l.next&&(l.steiner=!0),r.push(xh(l));for(r.sort(dh),n=0;n<r.length;n++)e=fh(r[n],e);return e}function dh(i,t){return i.x-t.x}function fh(i,t){var e=ph(i,t);if(!e)return t;var s=kn(e,i);return pe(s,s.next),pe(e,e.next)}function ph(i,t){var e=t,s=i.x,r=i.y,n=-1/0,o;do{if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){var a=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=s&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===s))return o}e=e.next}while(e!==t);if(!o)return null;var h=o,l=o.x,c=o.y,u=1/0,d;e=o;do s>=e.x&&e.x>=l&&s!==e.x&&Ce(r<c?s:n,r,l,c,r<c?n:s,r,e.x,e.y)&&(d=Math.abs(r-e.y)/(s-e.x),ze(e,i)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&mh(o,e)))&&(o=e,u=d)),e=e.next;while(e!==h);return o}function mh(i,t){return it(i.prev,i,t.prev)<0&&it(t.next,i,i.next)<0}function _h(i,t,e,s){var r=i;do r.z===0&&(r.z=Ms(r.x,r.y,t,e,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,gh(r)}function gh(i){var t,e,s,r,n,o,a,h,l=1;do{for(e=i,i=null,n=null,o=0;e;){for(o++,s=e,a=0,t=0;t<l&&(a++,s=s.nextZ,!!s);t++);for(h=l;a>0||h>0&&s;)a!==0&&(h===0||!s||e.z<=s.z)?(r=e,e=e.nextZ,a--):(r=s,s=s.nextZ,h--),n?n.nextZ=r:i=r,r.prevZ=n,n=r;e=s}n.nextZ=null,l*=2}while(o>1);return i}function Ms(i,t,e,s,r){return i=(i-e)*r|0,t=(t-s)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function xh(i){var t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Ce(i,t,e,s,r,n,o,a){return(r-o)*(t-a)>=(i-o)*(n-a)&&(i-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(r-o)*(s-a)}function vh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!yh(i,t)&&(ze(i,t)&&ze(t,i)&&Th(i,t)&&(it(i.prev,i,t.prev)||it(i,t.prev,t))||Ri(i,t)&&it(i.prev,i,i.next)>0&&it(t.prev,t,t.next)>0)}function it(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Ri(i,t){return i.x===t.x&&i.y===t.y}function On(i,t,e,s){var r=Ii(it(i,t,e)),n=Ii(it(i,t,s)),o=Ii(it(e,s,i)),a=Ii(it(e,s,t));return!!(r!==n&&o!==a||r===0&&Ci(i,e,t)||n===0&&Ci(i,s,t)||o===0&&Ci(e,i,s)||a===0&&Ci(e,t,s))}function Ci(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function Ii(i){return i>0?1:i<0?-1:0}function yh(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&On(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function ze(i,t){return it(i.prev,i,i.next)<0?it(i,t,i.next)>=0&&it(i,i.prev,t)>=0:it(i,t,i.prev)<0||it(i,i.next,t)<0}function Th(i,t){var e=i,s=!1,r=(i.x+t.x)/2,n=(i.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function kn(i,t){var e=new Bs(i.i,i.x,i.y),s=new Bs(t.i,t.x,t.y),r=i.next,n=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function Gn(i,t,e,s){var r=new Bs(i,t,e);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function We(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Bs(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Si.deviation=function(i,t,e,s){var r=t&&t.length,n=r?t[0]*e:i.length,o=Math.abs(Ds(i,0,n,e));if(r)for(var a=0,h=t.length;a<h;a++){var l=t[a]*e,c=a<h-1?t[a+1]*e:i.length;o-=Math.abs(Ds(i,l,c,e))}var u=0;for(a=0;a<s.length;a+=3){var d=s[a]*e,f=s[a+1]*e,p=s[a+2]*e;u+=Math.abs((i[d]-i[p])*(i[f+1]-i[d+1])-(i[d]-i[f])*(i[p+1]-i[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Ds(i,t,e,s){for(var r=0,n=t,o=e-s;n<e;n+=s)r+=(i[o]-i[n])*(i[n+1]+i[o+1]),o=n;return r}Si.flatten=function(i){for(var t=i[0][0].length,e={vertices:[],holes:[],dimensions:t},s=0,r=0;r<i.length;r++){for(var n=0;n<i[r].length;n++)for(var o=0;o<t;o++)e.vertices.push(i[r][n][o]);r>0&&(s+=i[r-1].length,e.holes.push(s))}return e},Ps.default=oh;var bh=Is(function(i,t){/*! https://mths.be/punycode v1.3.2 by @mathias */(function(e){var s=t&&!t.nodeType&&t,r=i&&!i.nodeType&&i,n=typeof Cs=="object"&&Cs;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,h=36,l=1,c=26,u=38,d=700,f=72,p=128,m="-",_=/^xn--/,x=/[^\x20-\x7E]/,y=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=h-l,b=Math.floor,M=String.fromCharCode,R;function w(A){throw RangeError(g[A])}function L(A,H){for(var Y=A.length,q=[];Y--;)q[Y]=H(A[Y]);return q}function G(A,H){var Y=A.split("@"),q="";Y.length>1&&(q=Y[0]+"@",A=Y[1]),A=A.replace(y,".");var K=A.split("."),ct=L(K,H).join(".");return q+ct}function I(A){for(var H=[],Y=0,q=A.length,K,ct;Y<q;)K=A.charCodeAt(Y++),K>=55296&&K<=56319&&Y<q?(ct=A.charCodeAt(Y++),(ct&64512)==56320?H.push(((K&1023)<<10)+(ct&1023)+65536):(H.push(K),Y--)):H.push(K);return H}function N(A){return L(A,function(H){var Y="";return H>65535&&(H-=65536,Y+=M(H>>>10&1023|55296),H=56320|H&1023),Y+=M(H),Y}).join("")}function E(A){return A-48<10?A-22:A-65<26?A-65:A-97<26?A-97:h}function T(A,H){return A+22+75*(A<26)-((H!=0)<<5)}function X(A,H,Y){var q=0;for(A=Y?b(A/d):A>>1,A+=b(A/H);A>v*c>>1;q+=h)A=b(A/v);return b(q+(v+1)*A/(A+u))}function z(A){var H=[],Y=A.length,q,K=0,ct=p,ot=f,ut,mt,gt,pt,Q,at,lt,kt,Gt;for(ut=A.lastIndexOf(m),ut<0&&(ut=0),mt=0;mt<ut;++mt)A.charCodeAt(mt)>=128&&w("not-basic"),H.push(A.charCodeAt(mt));for(gt=ut>0?ut+1:0;gt<Y;){for(pt=K,Q=1,at=h;gt>=Y&&w("invalid-input"),lt=E(A.charCodeAt(gt++)),(lt>=h||lt>b((a-K)/Q))&&w("overflow"),K+=lt*Q,kt=at<=ot?l:at>=ot+c?c:at-ot,!(lt<kt);at+=h)Gt=h-kt,Q>b(a/Gt)&&w("overflow"),Q*=Gt;q=H.length+1,ot=X(K-pt,q,pt==0),b(K/q)>a-ct&&w("overflow"),ct+=b(K/q),K%=q,H.splice(K++,0,ct)}return N(H)}function D(A){var H,Y,q,K,ct,ot,ut,mt,gt,pt,Q,at=[],lt,kt,Gt,Ge;for(A=I(A),lt=A.length,H=p,Y=0,ct=f,ot=0;ot<lt;++ot)Q=A[ot],Q<128&&at.push(M(Q));for(q=K=at.length,K&&at.push(m);q<lt;){for(ut=a,ot=0;ot<lt;++ot)Q=A[ot],Q>=H&&Q<ut&&(ut=Q);for(kt=q+1,ut-H>b((a-Y)/kt)&&w("overflow"),Y+=(ut-H)*kt,H=ut,ot=0;ot<lt;++ot)if(Q=A[ot],Q<H&&++Y>a&&w("overflow"),Q==H){for(mt=Y,gt=h;pt=gt<=ct?l:gt>=ct+c?c:gt-ct,!(mt<pt);gt+=h)Ge=mt-pt,Gt=h-pt,at.push(M(T(pt+Ge%Gt,0))),mt=b(Ge/Gt);at.push(M(T(mt,0))),ct=X(Y,kt,q==K),Y=0,++q}++Y,++H}return at.join("")}function $(A){return G(A,function(H){return _.test(H)?z(H.slice(4).toLowerCase()):H})}function st(A){return G(A,function(H){return x.test(H)?"xn--"+D(H):H})}if(o={version:"1.3.2",ucs2:{decode:I,encode:N},decode:z,encode:D,toASCII:st,toUnicode:$},s&&r)if(i.exports==s)r.exports=o;else for(R in o)o.hasOwnProperty(R)&&(s[R]=o[R]);else e.punycode=o})(Cs)}),zt={isString:function(i){return typeof i=="string"},isObject:function(i){return typeof i=="object"&&i!==null},isNull:function(i){return i===null},isNullOrUndefined:function(i){return i==null}};function Eh(i,t){return Object.prototype.hasOwnProperty.call(i,t)}var wh=function(i,t,e,s){t=t||"&",e=e||"=";var r={};if(typeof i!="string"||i.length===0)return r;var n=/\+/g;i=i.split(t);var o=1e3;s&&typeof s.maxKeys=="number"&&(o=s.maxKeys);var a=i.length;o>0&&a>o&&(a=o);for(var h=0;h<a;++h){var l=i[h].replace(n,"%20"),c=l.indexOf(e),u,d,f,p;c>=0?(u=l.substr(0,c),d=l.substr(c+1)):(u=l,d=""),f=decodeURIComponent(u),p=decodeURIComponent(d),Eh(r,f)?Array.isArray(r[f])?r[f].push(p):r[f]=[r[f],p]:r[f]=p}return r},je=function(i){switch(typeof i){case"string":return i;case"boolean":return i?"true":"false";case"number":return isFinite(i)?i:"";default:return""}},Ah=function(i,t,e,s){return t=t||"&",e=e||"=",i===null&&(i=void 0),typeof i=="object"?Object.keys(i).map(function(r){var n=encodeURIComponent(je(r))+e;return Array.isArray(i[r])?i[r].map(function(o){return n+encodeURIComponent(je(o))}).join(t):n+encodeURIComponent(je(i[r]))}).join(t):s?encodeURIComponent(je(s))+e+encodeURIComponent(je(i)):""},Ns=Is(function(i,t){"use strict";t.decode=t.parse=wh,t.encode=t.stringify=Ah}),Hn=Ye,Xn=Uh,Sh=Oh,Vn=Lh,Rh=wt;function wt(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Ch=/^([a-z0-9.+-]+:)/i,Ih=/:[0-9]*$/,Ph=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Mh=["<",">",'"',"`"," ","\r",`
8
8
  `," "],Bh=["{","}","|","\\","^","`"].concat(Mh),Fs=["'"].concat(Bh),zn=["%","/","?",";","#"].concat(Fs),Wn=["/","?","#"],Dh=255,jn=/^[+a-z0-9A-Z_-]{0,63}$/,Nh=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Fh={javascript:!0,"javascript:":!0},Ls={javascript:!0,"javascript:":!0},Ie={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Ye(i,t,e){if(i&&zt.isObject(i)&&i instanceof wt)return i;var s=new wt;return s.parse(i,t,e),s}wt.prototype.parse=function(i,t,e){if(!zt.isString(i))throw new TypeError("Parameter 'url' must be a string, not "+typeof i);var s=i.indexOf("?"),r=s!==-1&&s<i.indexOf("#")?"?":"#",n=i.split(r),o=/\\/g;n[0]=n[0].replace(o,"/"),i=n.join(r);var a=i;if(a=a.trim(),!e&&i.split("#").length===1){var h=Ph.exec(a);if(h)return this.path=a,this.href=a,this.pathname=h[1],h[2]?(this.search=h[2],t?this.query=Ns.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var l=Ch.exec(a);if(l){l=l[0];var c=l.toLowerCase();this.protocol=c,a=a.substr(l.length)}if(e||l||a.match(/^\/\/[^@\/]+@[^@\/]+/)){var u=a.substr(0,2)==="//";u&&!(l&&Ls[l])&&(a=a.substr(2),this.slashes=!0)}if(!Ls[l]&&(u||l&&!Ie[l])){for(var d=-1,f=0;f<Wn.length;f++){var p=a.indexOf(Wn[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,_;d===-1?_=a.lastIndexOf("@"):_=a.lastIndexOf("@",d),_!==-1&&(m=a.slice(0,_),a=a.slice(_+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<zn.length;f++){var p=a.indexOf(zn[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var x=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!x)for(var y=this.hostname.split(/\./),f=0,g=y.length;f<g;f++){var v=y[f];if(!!v&&!v.match(jn)){for(var b="",M=0,R=v.length;M<R;M++)v.charCodeAt(M)>127?b+="x":b+=v[M];if(!b.match(jn)){var w=y.slice(0,f),L=y.slice(f+1),G=v.match(Nh);G&&(w.push(G[1]),L.unshift(G[2])),L.length&&(a="/"+L.join(".")+a),this.hostname=w.join(".");break}}}this.hostname.length>Dh?this.hostname="":this.hostname=this.hostname.toLowerCase(),x||(this.hostname=bh.toASCII(this.hostname));var I=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+I,this.href+=this.host,x&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Fh[c])for(var f=0,g=Fs.length;f<g;f++){var E=Fs[f];if(a.indexOf(E)!==-1){var T=encodeURIComponent(E);T===E&&(T=escape(E)),a=a.split(E).join(T)}}var X=a.indexOf("#");X!==-1&&(this.hash=a.substr(X),a=a.slice(0,X));var z=a.indexOf("?");if(z!==-1?(this.search=a.substr(z),this.query=a.substr(z+1),t&&(this.query=Ns.parse(this.query)),a=a.slice(0,z)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Ie[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var I=this.pathname||"",D=this.search||"";this.path=I+D}return this.href=this.format(),this};function Lh(i){return zt.isString(i)&&(i=Ye(i)),i instanceof wt?i.format():wt.prototype.format.call(i)}wt.prototype.format=function(){var i=this.auth||"";i&&(i=encodeURIComponent(i),i=i.replace(/%3A/i,":"),i+="@");var t=this.protocol||"",e=this.pathname||"",s=this.hash||"",r=!1,n="";this.host?r=i+this.host:this.hostname&&(r=i+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(r+=":"+this.port)),this.query&&zt.isObject(this.query)&&Object.keys(this.query).length&&(n=Ns.stringify(this.query));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Ie[t])&&r!==!1?(r="//"+(r||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):r||(r=""),s&&s.charAt(0)!=="#"&&(s="#"+s),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+r+e+o+s};function Uh(i,t){return Ye(i,!1,!0).resolve(t)}wt.prototype.resolve=function(i){return this.resolveObject(Ye(i,!1,!0)).format()};function Oh(i,t){return i?Ye(i,!1,!0).resolveObject(t):t}wt.prototype.resolveObject=function(i){if(zt.isString(i)){var t=new wt;t.parse(i,!1,!0),i=t}for(var e=new wt,s=Object.keys(this),r=0;r<s.length;r++){var n=s[r];e[n]=this[n]}if(e.hash=i.hash,i.href==="")return e.href=e.format(),e;if(i.slashes&&!i.protocol){for(var o=Object.keys(i),a=0;a<o.length;a++){var h=o[a];h!=="protocol"&&(e[h]=i[h])}return Ie[e.protocol]&&e.hostname&&!e.pathname&&(e.path=e.pathname="/"),e.href=e.format(),e}if(i.protocol&&i.protocol!==e.protocol){if(!Ie[i.protocol]){for(var l=Object.keys(i),c=0;c<l.length;c++){var u=l[c];e[u]=i[u]}return e.href=e.format(),e}if(e.protocol=i.protocol,!i.host&&!Ls[i.protocol]){for(var g=(i.pathname||"").split("/");g.length&&!(i.host=g.shift()););i.host||(i.host=""),i.hostname||(i.hostname=""),g[0]!==""&&g.unshift(""),g.length<2&&g.unshift(""),e.pathname=g.join("/")}else e.pathname=i.pathname;if(e.search=i.search,e.query=i.query,e.host=i.host||"",e.auth=i.auth,e.hostname=i.hostname||i.host,e.port=i.port,e.pathname||e.search){var d=e.pathname||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||i.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",m=i.host||i.pathname&&i.pathname.charAt(0)==="/",_=m||p||e.host&&i.pathname,x=_,y=e.pathname&&e.pathname.split("/")||[],g=i.pathname&&i.pathname.split("/")||[],v=e.protocol&&!Ie[e.protocol];if(v&&(e.hostname="",e.port=null,e.host&&(y[0]===""?y[0]=e.host:y.unshift(e.host)),e.host="",i.protocol&&(i.hostname=null,i.port=null,i.host&&(g[0]===""?g[0]=i.host:g.unshift(i.host)),i.host=null),_=_&&(g[0]===""||y[0]==="")),m)e.host=i.host||i.host===""?i.host:e.host,e.hostname=i.hostname||i.hostname===""?i.hostname:e.hostname,e.search=i.search,e.query=i.query,y=g;else if(g.length)y||(y=[]),y.pop(),y=y.concat(g),e.search=i.search,e.query=i.query;else if(!zt.isNullOrUndefined(i.search)){if(v){e.hostname=e.host=y.shift();var b=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;b&&(e.auth=b.shift(),e.host=e.hostname=b.shift())}return e.search=i.search,e.query=i.query,(!zt.isNull(e.pathname)||!zt.isNull(e.search))&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!y.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var M=y.slice(-1)[0],R=(e.host||i.host||y.length>1)&&(M==="."||M==="..")||M==="",w=0,L=y.length;L>=0;L--)M=y[L],M==="."?y.splice(L,1):M===".."?(y.splice(L,1),w++):w&&(y.splice(L,1),w--);if(!_&&!x)for(;w--;w)y.unshift("..");_&&y[0]!==""&&(!y[0]||y[0].charAt(0)!=="/")&&y.unshift(""),R&&y.join("/").substr(-1)!=="/"&&y.push("");var G=y[0]===""||y[0]&&y[0].charAt(0)==="/";if(v){e.hostname=e.host=G?"":y.length?y.shift():"";var b=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;b&&(e.auth=b.shift(),e.host=e.hostname=b.shift())}return _=_||e.host&&y.length,_&&!G&&y.unshift(""),y.length?e.pathname=y.join("/"):(e.pathname=null,e.path=null),(!zt.isNull(e.pathname)||!zt.isNull(e.search))&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=i.auth||e.auth,e.slashes=e.slashes||i.slashes,e.href=e.format(),e},wt.prototype.parseHost=function(){var i=this.host,t=Ih.exec(i);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),i=i.substr(0,i.length-t.length)),i&&(this.hostname=i)};var Dp={parse:Hn,resolve:Xn,resolveObject:Sh,format:Vn,Url:Rh};const Yn={parse:Hn,format:Vn,resolve:Xn};function Nt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function $n(i){return i.split("?")[0].split("#")[0]}function kh(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gh(i,t,e){return i.replace(new RegExp(kh(t),"g"),e)}function Hh(i,t){let e="",s=0,r=-1,n=0,o;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 ft={toPosix(i){return Gh(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)},hasProtocol(i){return/^[^/:]+:\//.test(this.toPosix(i))},getProtocol(i){Nt(i),i=this.toPosix(i);let t="";const e=/^file:\/\/\//.exec(i),s=/^[^/:]+:\/\//.exec(i),r=/^[^/:]+:\//.exec(i);if(e||s||r){const n=(e==null?void 0:e[0])||(s==null?void 0:s[0])||(r==null?void 0:r[0]);t=n,i=i.slice(n.length)}return t},toAbsolute(i,t,e){if(this.isDataUrl(i))return i;const s=$n(this.toPosix(t!=null?t:S.ADAPTER.getBaseUrl())),r=$n(this.toPosix(e!=null?e:this.rootname(s)));return Nt(i),i=this.toPosix(i),i.startsWith("/")?ft.join(r,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(i=this.toPosix(i),Nt(i),i.length===0)return".";let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=Hh(i,!1),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return Nt(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(Nt(r),r.length>0)if(t===void 0)t=r;else{const n=(e=i[s-1])!=null?e:"";this.extname(n)?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(Nt(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){Nt(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){Nt(i),t&&Nt(t),i=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){Nt(i),i=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){Nt(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=this.toPosix(i);let e=i.charCodeAt(0);const s=this.isAbsolute(i);let r;const n="";t.root=this.rootname(i),s||this.hasProtocol(i)?r=1:r=0;let o=-1,a=0,h=-1,l=!0,c=i.length-1,u=0;for(;c>=r;--c){if(e=i.charCodeAt(c),e===47){if(!l){a=c+1;break}continue}h===-1&&(l=!1,h=c+1),e===46?o===-1?o=c:u!==1&&(u=1):o!==-1&&(u=-1)}return o===-1||h===-1||u===0||u===1&&o===h-1&&o===a+1?h!==-1&&(a===0&&s?t.base=t.name=i.slice(1,h):t.base=t.name=i.slice(a,h)):(a===0&&s?(t.name=i.slice(1,o),t.base=i.slice(1,h)):(t.name=i.slice(a,o),t.base=i.slice(a,h)),t.ext=i.slice(o,h)),t.dir=this.dirname(i),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":"};S.RETINA_PREFIX=/@([0-9\.]+)x/,S.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;function Xh(){}function Vh(){}let Us;function qn(){return typeof Us=="undefined"&&(Us=function(){const t={stencil:!0,failIfMajorPerformanceCaveat:S.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!S.ADAPTER.getWebGLRenderingContext())return!1;const e=S.ADAPTER.createCanvas();let s=e.getContext("webgl",t)||e.getContext("experimental-webgl",t);const r=!!(s&&s.getContextAttributes().stencil);if(s){const n=s.getExtension("WEBGL_lose_context");n&&n.loseContext()}return s=null,r}catch(e){return!1}}()),Us}var zh="#f0f8ff",Wh="#faebd7",jh="#00ffff",Yh="#7fffd4",$h="#f0ffff",qh="#f5f5dc",Kh="#ffe4c4",Zh="#000000",Qh="#ffebcd",Jh="#0000ff",tl="#8a2be2",el="#a52a2a",il="#deb887",sl="#5f9ea0",rl="#7fff00",nl="#d2691e",ol="#ff7f50",al="#6495ed",hl="#fff8dc",ll="#dc143c",cl="#00ffff",ul="#00008b",dl="#008b8b",fl="#b8860b",pl="#a9a9a9",ml="#006400",_l="#a9a9a9",gl="#bdb76b",xl="#8b008b",vl="#556b2f",yl="#ff8c00",Tl="#9932cc",bl="#8b0000",El="#e9967a",wl="#8fbc8f",Al="#483d8b",Sl="#2f4f4f",Rl="#2f4f4f",Cl="#00ced1",Il="#9400d3",Pl="#ff1493",Ml="#00bfff",Bl="#696969",Dl="#696969",Nl="#1e90ff",Fl="#b22222",Ll="#fffaf0",Ul="#228b22",Ol="#ff00ff",kl="#dcdcdc",Gl="#f8f8ff",Hl="#daa520",Xl="#ffd700",Vl="#808080",zl="#008000",Wl="#adff2f",jl="#808080",Yl="#f0fff0",$l="#ff69b4",ql="#cd5c5c",Kl="#4b0082",Zl="#fffff0",Ql="#f0e68c",Jl="#fff0f5",tc="#e6e6fa",ec="#7cfc00",ic="#fffacd",sc="#add8e6",rc="#f08080",nc="#e0ffff",oc="#fafad2",ac="#d3d3d3",hc="#90ee90",lc="#d3d3d3",cc="#ffb6c1",uc="#ffa07a",dc="#20b2aa",fc="#87cefa",pc="#778899",mc="#778899",_c="#b0c4de",gc="#ffffe0",xc="#00ff00",vc="#32cd32",yc="#faf0e6",Tc="#ff00ff",bc="#800000",Ec="#66cdaa",wc="#0000cd",Ac="#ba55d3",Sc="#9370db",Rc="#3cb371",Cc="#7b68ee",Ic="#00fa9a",Pc="#48d1cc",Mc="#c71585",Bc="#191970",Dc="#f5fffa",Nc="#ffe4e1",Fc="#ffe4b5",Lc="#ffdead",Uc="#000080",Oc="#fdf5e6",kc="#808000",Gc="#6b8e23",Hc="#ffa500",Xc="#ff4500",Vc="#da70d6",zc="#eee8aa",Wc="#98fb98",jc="#afeeee",Yc="#db7093",$c="#ffefd5",qc="#ffdab9",Kc="#cd853f",Zc="#ffc0cb",Qc="#dda0dd",Jc="#b0e0e6",tu="#800080",eu="#663399",iu="#ff0000",su="#bc8f8f",ru="#4169e1",nu="#8b4513",ou="#fa8072",au="#f4a460",hu="#2e8b57",lu="#fff5ee",cu="#a0522d",uu="#c0c0c0",du="#87ceeb",fu="#6a5acd",pu="#708090",mu="#708090",_u="#fffafa",gu="#00ff7f",xu="#4682b4",vu="#d2b48c",yu="#008080",Tu="#d8bfd8",bu="#ff6347",Eu="#40e0d0",wu="#ee82ee",Au="#f5deb3",Su="#ffffff",Ru="#f5f5f5",Cu="#ffff00",Iu="#9acd32",Pu={aliceblue:zh,antiquewhite:Wh,aqua:jh,aquamarine:Yh,azure:$h,beige:qh,bisque:Kh,black:Zh,blanchedalmond:Qh,blue:Jh,blueviolet:tl,brown:el,burlywood:il,cadetblue:sl,chartreuse:rl,chocolate:nl,coral:ol,cornflowerblue:al,cornsilk:hl,crimson:ll,cyan:cl,darkblue:ul,darkcyan:dl,darkgoldenrod:fl,darkgray:pl,darkgreen:ml,darkgrey:_l,darkkhaki:gl,darkmagenta:xl,darkolivegreen:vl,darkorange:yl,darkorchid:Tl,darkred:bl,darksalmon:El,darkseagreen:wl,darkslateblue:Al,darkslategray:Sl,darkslategrey:Rl,darkturquoise:Cl,darkviolet:Il,deeppink:Pl,deepskyblue:Ml,dimgray:Bl,dimgrey:Dl,dodgerblue:Nl,firebrick:Fl,floralwhite:Ll,forestgreen:Ul,fuchsia:Ol,gainsboro:kl,ghostwhite:Gl,goldenrod:Hl,gold:Xl,gray:Vl,green:zl,greenyellow:Wl,grey:jl,honeydew:Yl,hotpink:$l,indianred:ql,indigo:Kl,ivory:Zl,khaki:Ql,lavenderblush:Jl,lavender:tc,lawngreen:ec,lemonchiffon:ic,lightblue:sc,lightcoral:rc,lightcyan:nc,lightgoldenrodyellow:oc,lightgray:ac,lightgreen:hc,lightgrey:lc,lightpink:cc,lightsalmon:uc,lightseagreen:dc,lightskyblue:fc,lightslategray:pc,lightslategrey:mc,lightsteelblue:_c,lightyellow:gc,lime:xc,limegreen:vc,linen:yc,magenta:Tc,maroon:bc,mediumaquamarine:Ec,mediumblue:wc,mediumorchid:Ac,mediumpurple:Sc,mediumseagreen:Rc,mediumslateblue:Cc,mediumspringgreen:Ic,mediumturquoise:Pc,mediumvioletred:Mc,midnightblue:Bc,mintcream:Dc,mistyrose:Nc,moccasin:Fc,navajowhite:Lc,navy:Uc,oldlace:Oc,olive:kc,olivedrab:Gc,orange:Hc,orangered:Xc,orchid:Vc,palegoldenrod:zc,palegreen:Wc,paleturquoise:jc,palevioletred:Yc,papayawhip:$c,peachpuff:qc,peru:Kc,pink:Zc,plum:Qc,powderblue:Jc,purple:tu,rebeccapurple:eu,red:iu,rosybrown:su,royalblue:ru,saddlebrown:nu,salmon:ou,sandybrown:au,seagreen:hu,seashell:lu,sienna:cu,silver:uu,skyblue:du,slateblue:fu,slategray:pu,slategrey:mu,snow:_u,springgreen:gu,steelblue:xu,tan:vu,teal:yu,thistle:Tu,tomato:bu,turquoise:Eu,violet:wu,wheat:Au,white:Su,whitesmoke:Ru,yellow:Cu,yellowgreen:Iu};function me(i,t=[]){return t[0]=(i>>16&255)/255,t[1]=(i>>8&255)/255,t[2]=(i&255)/255,t}function Os(i){let t=i.toString(16);return t="000000".substring(0,6-t.length)+t,`#${t}`}function Pi(i){if(typeof i=="string"&&(i=Pu[i.toLowerCase()]||i,i[0]==="#"&&(i=i.slice(1)),i.length===3)){const[t,e,s]=i;i=t+t+e+e+s+s}return parseInt(i,16)}function Mu(i){return(i[0]*255<<16)+(i[1]*255<<8)+(i[2]*255|0)}function Bu(){const i=[],t=[];for(let s=0;s<32;s++)i[s]=s,t[s]=s;i[k.NORMAL_NPM]=k.NORMAL,i[k.ADD_NPM]=k.ADD,i[k.SCREEN_NPM]=k.SCREEN,t[k.NORMAL]=k.NORMAL_NPM,t[k.ADD]=k.ADD_NPM,t[k.SCREEN]=k.SCREEN_NPM;const e=[];return e.push(t),e.push(i),e}const ks=Bu();function Gs(i,t){return ks[t?1:0][i]}function Kn(i,t,e,s){return e=e||new Float32Array(4),s||s===void 0?(e[0]=i[0]*t,e[1]=i[1]*t,e[2]=i[2]*t):(e[0]=i[0],e[1]=i[1],e[2]=i[2]),e[3]=t,e}function Mi(i,t){if(t===1)return(t*255<<24)+i;if(t===0)return 0;let e=i>>16&255,s=i>>8&255,r=i&255;return e=e*t+.5|0,s=s*t+.5|0,r=r*t+.5|0,(t*255<<24)+(e<<16)+(s<<8)+r}function Hs(i,t,e,s){return e=e||new Float32Array(4),e[0]=(i>>16&255)/255,e[1]=(i>>8&255)/255,e[2]=(i&255)/255,(s||s===void 0)&&(e[0]*=t,e[1]*=t,e[2]*=t),e[3]=t,e}function Zn(i,t=null){const e=i*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let s=0,r=0;s<e;s+=6,r+=4)t[s+0]=r+0,t[s+1]=r+1,t[s+2]=r+2,t[s+3]=r+0,t[s+4]=r+2,t[s+5]=r+3;return t}function Bi(i){if(i.BYTES_PER_ELEMENT===4)return i instanceof Float32Array?"Float32Array":i instanceof Uint32Array?"Uint32Array":"Int32Array";if(i.BYTES_PER_ELEMENT===2){if(i instanceof Uint16Array)return"Uint16Array"}else if(i.BYTES_PER_ELEMENT===1&&i instanceof Uint8Array)return"Uint8Array";return null}const Du={Float32Array,Uint32Array,Int32Array,Uint8Array};function Nu(i,t){let e=0,s=0;const r={};for(let h=0;h<i.length;h++)s+=t[h],e+=i[h].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let h=0;h<i.length;h++){const l=t[h],c=i[h],u=Bi(c);r[u]||(r[u]=new Du[u](n)),o=r[u];for(let d=0;d<c.length;d++){const f=(d/l|0)*s+a,p=d%l;o[f+p]=c[d]}a+=l}return new Float32Array(n)}function $e(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 Xs(i){return!(i&i-1)&&!!i}function Vs(i){let t=(i>65535?1:0)<<4;i>>>=t;let e=(i>255?1:0)<<3;return i>>>=e,t|=e,e=(i>15?1:0)<<2,i>>>=e,t|=e,e=(i>3?1:0)<<1,i>>>=e,t|=e,t|i>>1}function _e(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}function ge(i){return i===0?0:i<0?-1:1}let Fu=0;function ne(){return++Fu}const Qn={};function Lu(i,t,e=3){if(Qn[t])return;let s=new Error().stack;typeof s=="undefined"?console.warn("PixiJS Deprecation Warning: ",`${t}
9
9
  Deprecated since v${i}`):(s=s.split(`
10
10
  `).splice(e).join(`
11
11
  `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
12
12
  Deprecated since v${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
13
- Deprecated since v${i}`),console.warn(s))),Qn[t]=!0}const zs={},xt=Object.create(null),At=Object.create(null);function Uu(){let i;for(i in xt)xt[i].destroy();for(i in At)At[i].destroy()}function Ou(){let i;for(i in xt)delete xt[i];for(i in At)delete At[i]}class Ws{constructor(t,e,s){this.canvas=S.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=s||S.RESOLUTION,this.resize(t,e)}clear(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)}resize(t,e){this.canvas.width=Math.round(t*this.resolution),this.canvas.height=Math.round(e*this.resolution)}destroy(){this.context=null,this.canvas=null}get width(){return this.canvas.width}set width(t){this.canvas.width=Math.round(t)}get height(){return this.canvas.height}set height(t){this.canvas.height=Math.round(t)}}function Jn(i){let t=i.width,e=i.height;const s=i.getContext("2d",{willReadFrequently:!0}),n=s.getImageData(0,0,t,e).data,o=n.length,a={top:null,left:null,right:null,bottom:null};let h=null,l,c,u;for(l=0;l<o;l+=4)n[l+3]!==0&&(c=l/4%t,u=~~(l/4/t),a.top===null&&(a.top=u),(a.left===null||c<a.left)&&(a.left=c),(a.right===null||a.right<c)&&(a.right=c+1),(a.bottom===null||a.bottom<u)&&(a.bottom=u));return a.top!==null&&(t=a.right-a.left,e=a.bottom-a.top+1,h=s.getImageData(a.left,a.top,t,e)),{height:e,width:t,data:h}}const to=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function ku(i){const t=to.exec(i);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}let Di;function eo(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location,Di||(Di=document.createElement("a")),Di.href=i;const e=Yn.parse(Di.href),s=!e.port&&t.port===""||e.port===t.port;return e.hostname!==t.hostname||!s||e.protocol!==t.protocol?"anonymous":""}function qt(i,t=1){const e=S.RETINA_PREFIX.exec(i);return e?parseFloat(e[1]):t}var Gu={__proto__:null,isMobile:Dt,EventEmitter:Re,earcut:Ps,url:Yn,path:ft,sayHello:Vh,skipHello:Xh,isWebGLSupported:qn,hex2rgb:me,hex2string:Os,rgb2hex:Mu,string2hex:Pi,correctBlendMode:Gs,premultiplyBlendMode:ks,premultiplyRgba:Kn,premultiplyTint:Mi,premultiplyTintToRgba:Hs,createIndicesForQuads:Zn,getBufferType:Bi,interleaveTypedArrays:Nu,isPow2:Xs,log2:Vs,nextPow2:$e,removeItems:_e,sign:ge,uid:ne,deprecation:Lu,BaseTextureCache:At,ProgramCache:zs,TextureCache:xt,clearTextureCache:Ou,destroyTextureCache:Uu,CanvasRenderTarget:Ws,trimCanvas:Jn,decomposeDataUri:ku,determineCrossOrigin:eo,getResolutionOfUrl:qt,DATA_URI:to};const Ni=[];function js(i,t){if(!i)return null;let e="";if(typeof i=="string"){const s=/\.(\w{3,4})(?:$|\?|#)/i.exec(i);s&&(e=s[1].toLowerCase())}for(let s=Ni.length-1;s>=0;--s){const r=Ni[s];if(r.test&&r.test(i,e))return new r(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Pe{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Tt("setRealSize"),this.onUpdate=new Tt("update"),this.onError=new Tt("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,s){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class Me extends Pe{constructor(t,e){const{width:s,height:r}=e||{};if(!s||!r)throw new Error("BufferResource width or height invalid");super(s,r),this.data=t}upload(t,e,s){const r=t.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Et.UNPACK);const n=e.realWidth,o=e.realHeight;return s.width===n&&s.height===o?r.texSubImage2D(e.target,0,0,0,n,o,e.format,s.type,this.data):(s.width=n,s.height=o,r.texImage2D(e.target,0,s.internalFormat,n,o,0,e.format,s.type,this.data)),!0}dispose(){this.data=null}static test(t){return t instanceof Float32Array||t instanceof Uint8Array||t instanceof Uint32Array}}const Hu={scaleMode:Xt.NEAREST,format:C.RGBA,alphaMode:Et.NPM},qe=class extends Re{constructor(i=null,t=null){super(),t=t||{};const{alphaMode:e,mipmap:s,anisotropicLevel:r,scaleMode:n,width:o,height:a,wrapMode:h,format:l,type:c,target:u,resolution:d,resourceOptions:f}=t;i&&!(i instanceof Pe)&&(i=js(i,f),i.internal=!0),this.resolution=d||S.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((a||0)*this.resolution)/this.resolution,this._mipmap=s!=null?s:S.MIPMAP_TEXTURES,this.anisotropicLevel=r!=null?r:S.ANISOTROPIC_LEVEL,this._wrapMode=h||S.WRAP_MODE,this._scaleMode=n!=null?n:S.SCALE_MODE,this.format=l||C.RGBA,this.type=c||O.UNSIGNED_BYTE,this.target=u||le.TEXTURE_2D,this.alphaMode=e!=null?e:Et.UNPACK,this.uid=ne(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&a>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(i)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(i){this._mipmap!==i&&(this._mipmap=i,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(i){this._scaleMode!==i&&(this._scaleMode=i,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(i){this._wrapMode!==i&&(this._wrapMode=i,this.dirtyStyleId++)}setStyle(i,t){let e;return i!==void 0&&i!==this.scaleMode&&(this.scaleMode=i,e=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,e=!0),e&&this.dirtyStyleId++,this}setSize(i,t,e){return e=e||this.resolution,this.setRealSize(i*e,t*e,e)}setRealSize(i,t,e){return this.resolution=e||this.resolution,this.width=Math.round(i)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Xs(this.realWidth)&&Xs(this.realHeight)}setResolution(i){const t=this.resolution;return t===i?this:(this.resolution=i,this.valid&&(this.width=Math.round(this.width*t)/i,this.height=Math.round(this.height*t)/i,this.emit("update",this)),this._refreshPOT(),this)}setResource(i){if(this.resource===i)return this;if(this.resource)throw new Error("Resource can be set only once");return i.bind(this),this.resource=i,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(i){this.emit("error",this,i)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete At[this.cacheId],delete xt[this.cacheId],this.cacheId=null),this.dispose(),qe.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(i,t,e=S.STRICT_TEXTURE_CACHE){const s=typeof i=="string";let r=null;if(s)r=i;else{if(!i._pixiId){const o=(t==null?void 0:t.pixiIdPrefix)||"pixiid";i._pixiId=`${o}_${ne()}`}r=i._pixiId}let n=At[r];if(s&&e&&!n)throw new Error(`The cacheId "${r}" does not exist in BaseTextureCache.`);return n||(n=new qe(i,t),n.cacheId=r,qe.addToCache(n,r)),n}static fromBuffer(i,t,e,s){i=i||new Float32Array(t*e*4);const r=new Me(i,{width:t,height:e}),n=i instanceof Float32Array?O.FLOAT:O.UNSIGNED_BYTE;return new qe(r,Object.assign({},Hu,s||{width:t,height:e,type:n}))}static addToCache(i,t){t&&(i.textureCacheIds.includes(t)||i.textureCacheIds.push(t),At[t]&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),At[t]=i)}static removeFromCache(i){if(typeof i=="string"){const t=At[i];if(t){const e=t.textureCacheIds.indexOf(i);return e>-1&&t.textureCacheIds.splice(e,1),delete At[i],t}}else if(i!=null&&i.textureCacheIds){for(let t=0;t<i.textureCacheIds.length;++t)delete At[i.textureCacheIds[t]];return i.textureCacheIds.length=0,i}return null}};let W=qe;W._globalBatch=0;class Ys extends Pe{constructor(t,e){const{width:s,height:r}=e||{};super(s,r),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new W;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let s=0;s<this.length;s++)!t[s]||(t[s].castToBaseTexture?this.addBaseTextureAt(t[s].castToBaseTexture(),s):t[s]instanceof Pe?this.addResourceAt(t[s],s):this.addResourceAt(js(t[s],e),s))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const e=this.items.map(s=>s.resource).filter(s=>s).map(s=>s.load());return this._load=Promise.all(e).then(()=>{const{realWidth:s,realHeight:r}=this.items[0];return this.resize(s,r),Promise.resolve(this)}),this._load}}class io extends Ys{constructor(t,e){const{width:s,height:r}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:s,height:r}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=le.TEXTURE_2D_ARRAY}upload(t,e,s){const{length:r,itemDirtyIds:n,items:o}=this,{gl:a}=t;s.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,s.internalFormat,this._width,this._height,r,0,e.format,s.type,null);for(let h=0;h<r;h++){const l=o[h];n[h]<l.dirtyId&&(n[h]=l.dirtyId,l.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,s.type,l.resource.source))}return!0}}class Kt extends Pe{constructor(t){const e=t,s=e.naturalWidth||e.videoWidth||e.width,r=e.naturalHeight||e.videoHeight||e.height;super(s,r),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,s){s===void 0&&!e.startsWith("data:")?t.crossOrigin=eo(e):s!==!1&&(t.crossOrigin=typeof s=="string"?s:"anonymous")}upload(t,e,s,r){const n=t.gl,o=e.realWidth,a=e.realHeight;if(r=r||this.source,typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement){if(!r.complete||r.naturalWidth===0)return!1}else if(typeof HTMLVideoElement!="undefined"&&r instanceof HTMLVideoElement&&r.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Et.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&s.width===o&&s.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,s.type,r):(s.width=o,s.height=a,n.texImage2D(e.target,0,s.internalFormat,e.format,s.type,r)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,s=t.naturalHeight||t.videoHeight||t.height;this.resize(e,s),super.update()}dispose(){this.source=null}}class so extends Kt{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Ke=class extends Ys{constructor(i,t){const{width:e,height:s,autoLoad:r,linkBaseTexture:n}=t||{};if(i&&i.length!==Ke.SIDES)throw new Error(`Invalid length. Got ${i.length}, expected 6`);super(6,{width:e,height:s});for(let o=0;o<Ke.SIDES;o++)this.items[o].target=le.TEXTURE_CUBE_MAP_POSITIVE_X+o;this.linkBaseTexture=n!==!1,i&&this.initFromArray(i,t),r!==!1&&this.load()}bind(i){super.bind(i),i.target=le.TEXTURE_CUBE_MAP}addBaseTextureAt(i,t,e){if(e===void 0&&(e=this.linkBaseTexture),!this.items[t])throw new Error(`Index ${t} is out of bounds`);if(!this.linkBaseTexture||i.parentTextureArray||Object.keys(i._glTextures).length>0)if(i.resource)this.addResourceAt(i.resource,t);else throw new Error("CubeResource does not support copying of renderTexture.");else i.target=le.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.parentTextureArray=this.baseTexture,this.items[t]=i;return i.valid&&!this.valid&&this.resize(i.realWidth,i.realHeight),this.items[t]=i,this}upload(i,t,e){const s=this.itemDirtyIds;for(let r=0;r<Ke.SIDES;r++){const n=this.items[r];(s[r]<n.dirtyId||e.dirtyId<t.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(i,n,e),s[r]=n.dirtyId):s[r]<-1&&(i.gl.texImage2D(n.target,0,e.internalFormat,t.realWidth,t.realHeight,0,t.format,e.type,null),s[r]=-1))}return!0}static test(i){return Array.isArray(i)&&i.length===Ke.SIDES}};let $s=Ke;$s.SIDES=6;class qs extends Kt{constructor(t,e){var s;if(e=e||{},typeof t=="string"){const r=new Image;Kt.crossOrigin(r,t,e.crossorigin),r.src=t,t=r}super(t),!t.complete&&!!this._width&&!!this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=((s=e.createBitmap)!=null?s:S.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,s)=>{const r=this.source;this.url=r.src;const n=()=>{this.destroyed||(r.onload=null,r.onerror=null,this.resize(r.width,r.height),this._load=null,this.createBitmap?e(this.process()):e(this))};r.complete&&r.src?n():(r.onload=n,r.onerror=o=>{s(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,s=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:s?"cors":"no-cors"}).then(r=>r.blob()).then(r=>e(r,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Et.UNPACK?"premultiply":"none"})).then(r=>this.destroyed?Promise.reject():(this.bitmap=r,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,s){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,s);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,s,this.bitmap),!this.preserveBitmap){let r=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==s&&a.dirtyId!==e.dirtyId){r=!1;break}}r&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement!="undefined"&&(typeof t=="string"||t instanceof HTMLImageElement)}}const Fi=class extends Kt{constructor(i,t){t=t||{},super(S.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=i,this.scale=t.scale||1,this._overrideWidth=t.width,this._overrideHeight=t.height,this._resolve=null,this._crossorigin=t.crossorigin,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(i=>{if(this._resolve=()=>{this.resize(this.source.width,this.source.height),i(this)},Fi.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const i=new Image;Kt.crossOrigin(i,this.svg,this._crossorigin),i.src=this.svg,i.onerror=t=>{!this._resolve||(i.onerror=null,this.onError.emit(t))},i.onload=()=>{if(!this._resolve)return;const t=i.width,e=i.height;if(!t||!e)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=t*this.scale,r=e*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/e*t,r=this._overrideHeight||this._overrideWidth/t*e),s=Math.round(s),r=Math.round(r);const n=this.source;n.width=s,n.height=r,n._pixiId=`canvas_${ne()}`,n.getContext("2d").drawImage(i,0,0,t,e,0,0,s,r),this._resolve(),this._resolve=null}}static getSize(i){const t=Fi.SVG_SIZE.exec(i),e={};return t&&(e[t[1]]=Math.round(parseFloat(t[3])),e[t[5]]=Math.round(parseFloat(t[7]))),e}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(i,t){return t==="svg"||typeof i=="string"&&i.startsWith("data:image/svg+xml")||typeof i=="string"&&Fi.SVG_XML.test(i)}};let Be=Fi;Be.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Be.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;const Ks=class extends Kt{constructor(i,t){if(t=t||{},!(i instanceof HTMLVideoElement)){const e=document.createElement("video");e.setAttribute("preload","auto"),e.setAttribute("webkit-playsinline",""),e.setAttribute("playsinline",""),typeof i=="string"&&(i=[i]);const s=i[0].src||i[0];Kt.crossOrigin(e,s,t.crossorigin);for(let r=0;r<i.length;++r){const n=document.createElement("source");let{src:o,mime:a}=i[r];o=o||i[r];const h=o.split("?").shift().toLowerCase(),l=h.slice(h.lastIndexOf(".")+1);a=a||Ks.MIME_TYPES[l]||`video/${l}`,n.src=o,n.type=a,e.appendChild(n)}i=e}super(i),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this._load=null,this._resolve=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),t.autoLoad!==!1&&this.load()}update(i=0){if(!this.destroyed){const t=Z.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t),(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}load(){if(this._load)return this._load;const i=this.source;return(i.readyState===i.HAVE_ENOUGH_DATA||i.readyState===i.HAVE_FUTURE_DATA)&&i.width&&i.height&&(i.complete=!0),i.addEventListener("play",this._onPlayStart.bind(this)),i.addEventListener("pause",this._onPlayStop.bind(this)),this._isSourceReady()?this._onCanPlay():(i.addEventListener("canplay",this._onCanPlay),i.addEventListener("canplaythrough",this._onCanPlay),i.addEventListener("error",this._onError,!0)),this._load=new Promise(t=>{this.valid?t(this):(this._resolve=t,i.load())}),this._load}_onError(i){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(i)}_isSourcePlaying(){const i=this.source;return!i.paused&&!i.ended&&this._isSourceReady()}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(Z.shared.add(this.update,this),this._isConnectedToTicker=!0)}_onPlayStop(){this._isConnectedToTicker&&(Z.shared.remove(this.update,this),this._isConnectedToTicker=!1)}_onCanPlay(){const i=this.source;i.removeEventListener("canplay",this._onCanPlay),i.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this.resize(i.videoWidth,i.videoHeight),!t&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&i.play()}dispose(){this._isConnectedToTicker&&(Z.shared.remove(this.update,this),this._isConnectedToTicker=!1);const i=this.source;i&&(i.removeEventListener("error",this._onError,!0),i.pause(),i.src="",i.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(i){i!==this._autoUpdate&&(this._autoUpdate=i,!this._autoUpdate&&this._isConnectedToTicker?(Z.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(Z.shared.add(this.update,this),this._isConnectedToTicker=!0))}get updateFPS(){return this._updateFPS}set updateFPS(i){i!==this._updateFPS&&(this._updateFPS=i)}static test(i,t){return globalThis.HTMLVideoElement&&i instanceof HTMLVideoElement||Ks.TYPES.includes(t)}};let Li=Ks;Li.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Li.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};class Ae extends Kt{constructor(t,e){var r;var s=(...n)=>{super(...n)};e=e||{},typeof t=="string"?(s(Ae.EMPTY),this.url=t):(s(t),this.url=null),this.crossOrigin=(r=e.crossOrigin)!=null?r:!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const s=await S.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const r=await s.blob();if(this.destroyed)return;const n=await createImageBitmap(r,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Et.UNPACK?"premultiply":"none"});if(this.destroyed)return;this.source=n,this.update(),t(this)}catch(s){if(this.destroyed)return;e(s),this.onError.emit(s)}}),this._load)}upload(t,e,s){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,s)):(this.load(),!1)}dispose(){this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap!="undefined"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){var t;return Ae._EMPTY=(t=Ae._EMPTY)!=null?t:S.ADAPTER.createCanvas(0,0),Ae._EMPTY}}Ni.push(Ae,qs,so,Li,Be,Me,$s,io);class Xu extends Me{upload(t,e,s){const r=t.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Et.UNPACK);const n=e.realWidth,o=e.realHeight;return s.width===n&&s.height===o?r.texSubImage2D(e.target,0,0,0,n,o,e.format,s.type,this.data):(s.width=n,s.height=o,r.texImage2D(e.target,0,s.internalFormat,n,o,0,e.format,s.type,this.data)),!0}}class Ui{constructor(t,e){this.width=Math.round(t||100),this.height=Math.round(e||100),this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Tt("disposeFramebuffer"),this.multisample=nt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new W(null,{scaleMode:Xt.NEAREST,resolution:1,mipmap:Pt.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new W(new Xu(null,{width:this.width,height:this.height}),{scaleMode:Xt.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Pt.OFF,format:C.DEPTH_COMPONENT,type:O.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let s=0;s<this.colorTextures.length;s++){const r=this.colorTextures[s],n=r.resolution;r.setSize(t/n,e/n)}if(this.depthTexture){const s=this.depthTexture.resolution;this.depthTexture.setSize(t/s,e/s)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Zs extends W{constructor(t={}){var e;if(typeof t=="number"){const s=arguments[0],r=arguments[1],n=arguments[2],o=arguments[3];t={width:s,height:r,scaleMode:n,resolution:o}}t.width=t.width||100,t.height=t.height||100,(e=t.multisample)!=null||(t.multisample=nt.NONE),super(null,t),this.mipmap=Pt.OFF,this.valid=!0,this.clearColor=[0,0,0,0],this.framebuffer=new Ui(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Qs{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,s){const r=e.width,n=e.height;if(s){const o=t.width/2/r,a=t.height/2/n,h=t.x/r+o,l=t.y/n+a;s=J.add(s,J.NW),this.x0=h+o*J.uX(s),this.y0=l+a*J.uY(s),s=J.add(s,2),this.x1=h+o*J.uX(s),this.y1=l+a*J.uY(s),s=J.add(s,2),this.x2=h+o*J.uX(s),this.y2=l+a*J.uY(s),s=J.add(s,2),this.x3=h+o*J.uX(s),this.y3=l+a*J.uY(s)}else this.x0=t.x/r,this.y0=t.y/n,this.x1=(t.x+t.width)/r,this.y1=t.y/n,this.x2=(t.x+t.width)/r,this.y2=(t.y+t.height)/n,this.x3=t.x/r,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}const ro=new Qs;function Oi(i){i.destroy=function(){},i.on=function(){},i.once=function(){},i.emit=function(){}}class B extends Re{constructor(t,e,s,r,n,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new V(0,0,1,1)),t instanceof B&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this._uvs=ro,this.uvMatrix=null,this.orig=s||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new j(o.x,o.y):new j(0,0),this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;(e==null?void 0:e.url)&&xt[e.url]&&B.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,B.removeFromCache(this),this.textureCacheIds=null}clone(){var r;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),s=new B(this.baseTexture,!this.noFrame&&t,e,(r=this.trim)==null?void 0:r.clone(),this.rotate,this.defaultAnchor);return this.noFrame&&(s._frame=t),s}updateUvs(){this._uvs===ro&&(this._uvs=new Qs),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},s=S.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else if(t instanceof W){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${ne()}`,W.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${ne()}`}n=t._pixiId}let o=xt[n];if(r&&s&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof W)?(e.resolution||(e.resolution=qt(t)),o=new B(new W(t,e)),o.baseTexture.cacheId=n,W.addToCache(o.baseTexture,n),B.addToCache(o,n)):!o&&t instanceof W&&(o=new B(t),B.addToCache(o,n)),o}static fromURL(t,e){const s=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),r=B.from(t,Object.assign({resourceOptions:s},e),!1),n=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):n.load().then(()=>Promise.resolve(r))}static fromBuffer(t,e,s,r){return new B(W.fromBuffer(t,e,s,r))}static fromLoader(t,e,s,r){const n=new W(t,Object.assign({scaleMode:S.SCALE_MODE,resolution:qt(e)},r)),{resource:o}=n;o instanceof qs&&(o.url=e);const a=new B(n);return s||(s=e),W.addToCache(a.baseTexture,s),B.addToCache(a,s),s!==e&&(W.addToCache(a.baseTexture,e),B.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(h=>{a.baseTexture.once("loaded",()=>h(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),xt[e]&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),xt[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=xt[t];if(e){const s=e.textureCacheIds.indexOf(t);return s>-1&&e.textureCacheIds.splice(s,1),delete xt[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)xt[t.textureCacheIds[e]]===t&&delete xt[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:s,width:r,height:n}=t,o=e+r>this.baseTexture.width,a=s+n>this.baseTexture.height;if(o||a){const h=o&&a?"and":"or",l=`X: ${e} + ${r} = ${e+r} > ${this.baseTexture.width}`,c=`Y: ${s} + ${n} = ${s+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${c}`)}this.valid=r&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return B._EMPTY||(B._EMPTY=new B(new W),Oi(B._EMPTY),Oi(B._EMPTY.baseTexture)),B._EMPTY}static get WHITE(){if(!B._WHITE){const t=S.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),B._WHITE=new B(W.from(t)),Oi(B._WHITE),Oi(B._WHITE.baseTexture)}return B._WHITE}}class te extends B{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,s=!0){const r=this.baseTexture.resolution,n=Math.round(t*r)/r,o=Math.round(e*r)/r;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,s&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new te(new Zs(t))}}class Js{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,s=nt.NONE){const r=new Zs(Object.assign({width:t,height:e,resolution:1,multisample:s},this.textureOptions));return new te(r)}getOptimalTexture(t,e,s=1,r=nt.NONE){let n;t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=$e(t),e=$e(e),n=((t&65535)<<16|e&65535)>>>0,r>1&&(n+=r*4294967296)):n=r>1?-r:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,r)),o.filterPoolKey=n,o.setResolution(s),o}getFilterTexture(t,e,s){const r=this.getOptimalTexture(t.width,t.height,e||t.resolution,s||nt.NONE);return r.filterFrame=t.filterFrame,r}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(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={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const s=this.texturePool[e];if(s)for(let r=0;r<s.length;r++)s[r].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Js.SCREEN_KEY=-1;class _i{constructor(t,e=0,s=!1,r=O.FLOAT,n,o,a){this.buffer=t,this.size=e,this.normalized=s,this.type=r,this.stride=n,this.start=o,this.instance=a}destroy(){this.buffer=null}static from(t,e,s,r,n){return new _i(t,e,s,r,n)}}let Vu=0;class rt{constructor(t,e=!0,s=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=s,this.static=e,this.id=Vu++,this.disposeRunner=new Tt("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Bt.ELEMENT_ARRAY_BUFFER:Bt.ARRAY_BUFFER}get index(){return this.type===Bt.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new rt(t)}}const zu={Float32Array,Uint32Array,Int32Array,Uint8Array};function Wu(i,t){let e=0,s=0;const r={};for(let h=0;h<i.length;h++)s+=t[h],e+=i[h].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let h=0;h<i.length;h++){const l=t[h],c=i[h],u=Bi(c);r[u]||(r[u]=new zu[u](n)),o=r[u];for(let d=0;d<c.length;d++){const f=(d/l|0)*s+a,p=d%l;o[f+p]=c[d]}a+=l}return new Float32Array(n)}const no={5126:4,5123:2,5121:1};let ju=0;const Yu={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class ie{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=ju++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Tt("disposeGeometry"),this.refCount=0}addAttribute(t,e,s=0,r=!1,n,o,a,h=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof rt||(e instanceof Array&&(e=new Float32Array(e)),e=new rt(e));const l=t.split("|");if(l.length>1){for(let u=0;u<l.length;u++)this.addAttribute(l[u],e,s,r,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new _i(c,s,r,n,o,a,h),this.instanced=this.instanced||h,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof rt||(t instanceof Array&&(t=new Uint16Array(t)),t=new rt(t)),t.type=Bt.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],s=new rt;let r;for(r in this.attributes){const n=this.attributes[r],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*no[n.type]/4),n.buffer=0}for(s.data=Wu(t,e),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[s],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new ie;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new rt(this.buffers[e].data.slice(0));for(const e in this.attributes){const s=this.attributes[e];t.attributes[e]=new _i(s.buffer,s.size,s.normalized,s.type,s.stride,s.start,s.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Bt.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new ie,s=[],r=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)r[h]=r[h]||0,r[h]+=o.buffers[h].data.length,n[h]=0}for(let a=0;a<o.buffers.length;a++)s[a]=new Yu[Bi(o.buffers[a].data)](r[a]),e.buffers[a]=new rt(s[a]);for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)s[h].set(o.buffers[h].data,n[h]),n[h]+=o.buffers[h].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=Bt.ELEMENT_ARRAY_BUFFER;let a=0,h=0,l=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(h+=d.size*no[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+l]+=a;a+=t[u].buffers[c].data.length/h,l+=d.length}}return e}}class oo extends ie{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class tr extends ie{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new rt(this.vertices),this.uvBuffer=new rt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let s=0,r=0;return this.uvs[0]=s,this.uvs[1]=r,this.uvs[2]=s+e.width/t.width,this.uvs[3]=r,this.uvs[4]=s+e.width/t.width,this.uvs[5]=r+e.height/t.height,this.uvs[6]=s,this.uvs[7]=r+e.height/t.height,s=e.x,r=e.y,this.vertices[0]=s,this.vertices[1]=r,this.vertices[2]=s+e.width,this.vertices[3]=r,this.vertices[4]=s+e.width,this.vertices[5]=r+e.height,this.vertices[6]=s,this.vertices[7]=r+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}let $u=0;class Ct{constructor(t,e,s){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=$u++,this.static=!!e,this.ubo=!!s,t instanceof rt?(this.buffer=t,this.buffer.type=Bt.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new rt(new Float32Array(1)),this.buffer.type=Bt.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,s){if(!this.ubo)this.uniforms[t]=new Ct(e,s);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,s){return new Ct(t,e,s)}static uboFrom(t,e){return new Ct(t,e!=null?e:!0,!0)}}class ao{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=nt.NONE,this.sourceFrame=new V,this.destinationFrame=new V,this.bindingSourceFrame=new V,this.bindingDestinationFrame=new V,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const ki=[new j,new j,new j,new j],er=new et;class ir{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Js,this.statePool=[],this.quad=new oo,this.quadUv=new tr,this.tempRect=new V,this.activeState={},this.globalUniforms=new Ct({outputFrame:new V,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){var p,m;const s=this.renderer,r=this.defaultFilterStack,n=this.statePool.pop()||new ao,o=this.renderer.renderTexture;let a=e[0].resolution,h=e[0].multisample,l=e[0].padding,c=e[0].autoFit,u=(p=e[0].legacy)!=null?p:!0;for(let _=1;_<e.length;_++){const x=e[_];a=Math.min(a,x.resolution),h=Math.min(h,x.multisample),l=this.useMaxPadding?Math.max(l,x.padding):l+x.padding,c=c&&x.autoFit,u=u||((m=x.legacy)!=null?m:!0)}r.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),r.push(n),n.resolution=a,n.multisample=h,n.legacy=u,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(l);const d=this.tempRect.copyFrom(o.sourceFrame);s.projection.transform&&this.transformAABB(er.copyFrom(s.projection.transform).invert(),d),c?(n.sourceFrame.fit(d),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(d)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:s.resolution,o.sourceFrame,o.destinationFrame,s.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,a,h),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const f=this.tempRect;f.x=0,f.y=0,f.width=n.sourceFrame.width,f.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=s.projection.transform,s.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,f),s.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),s=e.filters;this.activeState=e;const r=this.globalUniforms.uniforms;r.outputFrame=e.sourceFrame,r.resolution=e.resolution;const n=r.inputSize,o=r.inputPixel,a=r.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const l=r.filterArea;l[0]=e.destinationFrame.width,l[1]=e.destinationFrame.height,l[2]=e.sourceFrame.x,l[3]=e.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const h=t[t.length-1];if(this.renderer.framebuffer.blit(),s.length===1)s[0].apply(this,e.renderTexture,h.renderTexture,Mt.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let l=e.renderTexture,c=this.getOptimalFilterTexture(l.width,l.height,e.resolution);c.filterFrame=l.filterFrame;let u=0;for(u=0;u<s.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(l.width,l.height,e.resolution),c.filterFrame=l.filterFrame),s[u].apply(this,l,c,Mt.CLEAR,e);const d=l;l=c,c=d}s[u].apply(this,l,h.renderTexture,Mt.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Mt.CLEAR){const{renderTexture:s,state:r}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t!=null&&t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,s.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?s.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=r.stateId&1||this.forceClear;(e===Mt.CLEAR||e===Mt.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,s,r){const n=this.renderer;n.state.set(t.state),this.bindAndClear(s,r),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(It.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(It.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:s,destinationFrame:r}=this.activeState,{orig:n}=e._texture,o=t.set(r.width,0,0,r.height,s.x,s.y),a=e.worldTransform.copyTo(et.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,s=1,r=nt.NONE){return this.texturePool.getOptimalTexture(t,e,s,r)}getFilterTexture(t,e,s){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,s||nt.NONE);return r.filterFrame=t.filterFrame,r}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const s=ki[0],r=ki[1],n=ki[2],o=ki[3];s.set(e.left,e.top),r.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(s,s),t.apply(r,r),t.apply(n,n),t.apply(o,o);const a=Math.min(s.x,r.x,n.x,o.x),h=Math.min(s.y,r.y,n.y,o.y),l=Math.max(s.x,r.x,n.x,o.x),c=Math.max(s.y,r.y,n.y,o.y);e.x=a,e.y=h,e.width=l-a,e.height=c-h}roundFrame(t,e,s,r,n){if(!(t.width<=0||t.height<=0||s.width<=0||s.height<=0)){if(n){const{a:o,b:a,c:h,d:l}=n;if((Math.abs(a)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(l)>1e-4))return}n=n?er.copyFrom(n):er.identity(),n.translate(-s.x,-s.y).scale(r.width/s.width,r.height/s.height).translate(r.x,r.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}ir.extension={type:P.RendererSystem,name:"filter"},U.add(ir);class Ze{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}class sr{constructor(t){this.renderer=t,this.emptyRenderer=new Ze(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:s}=this.renderer.texture;for(let r=e-1;r>=0;--r)t[r]=s[r]||null,t[r]&&(t[r]._batchLocation=r)}boundArray(t,e,s,r){const{elements:n,ids:o,count:a}=t;let h=0;for(let l=0;l<a;l++){const c=n[l],u=c._batchLocation;if(u>=0&&u<r&&e[u]===c){o[l]=u;continue}for(;h<r;){const d=e[h];if(d&&d._batchEnabled===s&&d._batchLocation===h){h++;continue}o[l]=h,c._batchLocation=h,e[h]=c;break}}}destroy(){this.renderer=null}}sr.extension={type:P.RendererSystem,name:"batch"},U.add(sr);let ho=0;class rr{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},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,this.renderer.CONTEXT_UID=ho++,t.isContextLost()&&t.getExtension("WEBGL_lose_context")&&t.getExtension("WEBGL_lose_context").restoreContext()}init(t){var e;if(t.context)this.initFromContext(t.context);else{const s=this.renderer.background.alpha<1,r=(e=t.premultipliedAlpha)!=null?e:!0;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:s,premultipliedAlpha:r,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=ho++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let s;if(S.PREFER_ENV>=se.WEBGL2&&(s=t.getContext("webgl2",e)),s)this.webGLVersion=2;else if(this.webGLVersion=1,s=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!s)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=s,this.getExtensions(),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")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),loseContext:t.getExtension("WEBGL_lose_context"),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")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault()}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),s="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;s&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=s||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}rr.extension={type:P.RendererSystem,name:"context"},U.add(rr);class lo{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=nt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const qu=new V;class nr{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Ui(10,10),this.msaaSamples=null}contextChange(){const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new V,this.hasMRT=!0,this.writeDepthTexture=!0,this.disposeAll(!0),this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,s=this.renderer.context.extensions.depthTexture;S.PREFER_ENV===se.WEBGL_LEGACY&&(e=null,s=null),e?t.drawBuffers=r=>e.drawBuffersWEBGL(r):(this.hasMRT=!1,t.drawBuffers=()=>{}),s||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,s=0){const{gl:r}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,r.bindFramebuffer(r.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==s&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=s),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,s)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>s,a=e.height>>s,h=o/e.width;this.setViewport(e.x*h,e.y*h,o,a)}else{const o=t.width>>s,a=t.height>>s;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,s,r){const n=this.viewport;t=Math.round(t),e=Math.round(e),s=Math.round(s),r=Math.round(r),(n.width!==s||n.height!==r||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=s,n.height=r,this.gl.viewport(t,e,s,r))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,s,r,n=yi.COLOR|yi.DEPTH){const{gl:o}=this;o.clearColor(t,e,s,r),o.clear(n)}initFramebuffer(t){const{gl:e}=this,s=new lo(e.createFramebuffer());return s.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=s,this.managedFramebuffers.push(t),t.disposeRunner.add(this),s}resizeFramebuffer(t){const{gl:e}=this,s=t.glFramebuffers[this.CONTEXT_UID];s.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,s.stencil),s.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,s.multisample,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.width,t.height));const r=t.colorTextures;let n=r.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=r[o],h=a.parentTextureArray||a;this.renderer.texture.bind(h,0),o===0&&s.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,s.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,s.multisample,h._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:s}=this,r=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;s.drawBuffers||(o=Math.min(o,1)),r.multisample>1&&this.canMultisampleFramebuffer(t)?r.msaaBuffer=r.msaaBuffer||s.createRenderbuffer():r.msaaBuffer&&(s.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const a=[];for(let h=0;h<o;h++){const l=n[h],c=l.parentTextureArray||l;this.renderer.texture.bind(c,0),h===0&&r.msaaBuffer?(s.bindRenderbuffer(s.RENDERBUFFER,r.msaaBuffer),s.renderbufferStorageMultisample(s.RENDERBUFFER,r.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,r.msaaBuffer)):(s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+h,l.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(s.COLOR_ATTACHMENT0+h))}if(a.length>1&&s.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}(t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)?(r.stencil=r.stencil||s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,r.stencil),r.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,r.multisample,s.DEPTH24_STENCIL8,t.width,t.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,t.width,t.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,r.stencil)):r.stencil&&(s.deleteRenderbuffer(r.stencil),r.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let s=nt.NONE;if(t<=1||e===null)return s;for(let r=0;r<e.length;r++)if(e[r]<=t){s=e[r];break}return s===1&&(s=nt.NONE),s}blit(t,e,s){const{current:r,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!r)return;const h=r.glFramebuffers[a];if(!h)return;if(!t){if(!h.msaaBuffer)return;const c=r.colorTextures[0];if(!c)return;h.blitFramebuffer||(h.blitFramebuffer=new Ui(r.width,r.height),h.blitFramebuffer.addColorTexture(0,c)),t=h.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==r.width||t.height!==r.height)&&(t.width=r.width,t.height=r.height,t.dirtyId++,t.dirtySize++)}e||(e=qu,e.width=r.width,e.height=r.height),s||(s=e);const l=e.width===s.width&&e.height===s.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,h.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,s.left,s.top,s.right,s.bottom,o.COLOR_BUFFER_BIT,l?o.NEAREST:o.LINEAR)}disposeFramebuffer(t,e){const s=t.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!s)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(r.deleteFramebuffer(s.framebuffer),s.msaaBuffer&&r.deleteRenderbuffer(s.msaaBuffer),s.stencil&&r.deleteRenderbuffer(s.stencil)),s.blitFramebuffer&&s.blitFramebuffer.dispose()}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let s=0;s<e.length;s++)this.disposeFramebuffer(e[s],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil)return;t.stencil=!0;const s=t.width,r=t.height,n=this.gl,o=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,n.DEPTH24_STENCIL8,s,r):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,s,r),e.stencil=o,n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new V}destroy(){this.renderer=null}}nr.extension={type:P.RendererSystem,name:"framebuffer"},U.add(nr);const or={5126:4,5123:2,5121:1};class ar{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let s=this.renderer.context.extensions.vertexArrayObject;S.PREFER_ENV===se.WEBGL_LEGACY&&(s=null),s?(t.createVertexArray=()=>s.createVertexArrayOES(),t.bindVertexArray=r=>s.bindVertexArrayOES(r),t.deleteVertexArray=r=>s.deleteVertexArrayOES(r)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const s=t.getExtension("ANGLE_instanced_arrays");s?(t.vertexAttribDivisor=(r,n)=>s.vertexAttribDivisorANGLE(r,n),t.drawElementsInstanced=(r,n,o,a,h)=>s.drawElementsInstancedANGLE(r,n,o,a,h),t.drawArraysInstanced=(r,n,o,a)=>s.drawArraysInstancedANGLE(r,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:s}=this;let r=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;r||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=r={},n=!0);const o=r[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?s.bindVertexArray(o):this.activateVao(t,e.program)),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.update(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.id];for(const o in s)r[o]&&n.push(o,r[o].location);return n.join("-")}initGeometryVao(t,e,s=!0){const r=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const h=this.getSignature(t,a),l=t.glVertexArrayObjects[this.CONTEXT_UID];let c=l[h];if(c)return l[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*or[d[m].type];for(const m in d){const _=d[m],x=_.size;_.stride===void 0&&(f[_.buffer]===x*or[_.type]?_.stride=0:_.stride=f[_.buffer]),_.start===void 0&&(_.start=p[_.buffer],p[_.buffer]+=x*or[_.type])}c=r.createVertexArray(),r.bindVertexArray(c);for(let m=0;m<u.length;m++){const _=u[m];o.bind(_),s&&_._glBuffers[n].refCount++}return this.activateVao(t,a),l[a.id]=c,l[h]=c,r.bindVertexArray(null),o.unbind(Bt.ARRAY_BUFFER),c}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const s=t.glVertexArrayObjects[this.CONTEXT_UID],r=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!s){if(o)for(let h=0;h<n.length;h++){const l=n[h]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(n[h],e))}if(!e){for(const h in s)if(h[0]==="g"){const l=s[h];this._activeVao===l&&this.unbind(),r.deleteVertexArray(l)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let s=0;s<e.length;s++)this.disposeGeometry(this.managedGeometries[e[s]],t)}activateVao(t,e){const s=this.gl,r=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let h=null;for(const l in a){const c=a[l],u=o[c.buffer],d=u._glBuffers[r];if(e.attributeData[l]){h!==d&&(n.bind(u),h=d);const f=e.attributeData[l].location;if(s.enableVertexAttribArray(f),s.vertexAttribPointer(f,c.size,c.type||s.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)s.vertexAttribDivisor(f,1);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,s,r){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,h=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,h,(s||0)*a,r||1):n.drawElements(t,e||o.indexBuffer.data.length,h,(s||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,s,e||o.getSize(),r||1):n.drawArrays(t,s,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}ar.extension={type:P.RendererSystem,name:"geometry"},U.add(ar);class co{constructor(t=null){this.type=ht.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=S.FILTER_MULTISAMPLE,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=ht.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}function uo(i,t,e){const s=i.createShader(t);return i.shaderSource(s,e),i.compileShader(s),s}function fo(i,t){const e=i.getShaderSource(t).split(`
13
+ Deprecated since v${i}`),console.warn(s))),Qn[t]=!0}const zs={},xt=Object.create(null),At=Object.create(null);function Uu(){let i;for(i in xt)xt[i].destroy();for(i in At)At[i].destroy()}function Ou(){let i;for(i in xt)delete xt[i];for(i in At)delete At[i]}class Ws{constructor(t,e,s){this.canvas=S.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=s||S.RESOLUTION,this.resize(t,e)}clear(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)}resize(t,e){this.canvas.width=Math.round(t*this.resolution),this.canvas.height=Math.round(e*this.resolution)}destroy(){this.context=null,this.canvas=null}get width(){return this.canvas.width}set width(t){this.canvas.width=Math.round(t)}get height(){return this.canvas.height}set height(t){this.canvas.height=Math.round(t)}}function Jn(i){let t=i.width,e=i.height;const s=i.getContext("2d",{willReadFrequently:!0}),n=s.getImageData(0,0,t,e).data,o=n.length,a={top:null,left:null,right:null,bottom:null};let h=null,l,c,u;for(l=0;l<o;l+=4)n[l+3]!==0&&(c=l/4%t,u=~~(l/4/t),a.top===null&&(a.top=u),(a.left===null||c<a.left)&&(a.left=c),(a.right===null||a.right<c)&&(a.right=c+1),(a.bottom===null||a.bottom<u)&&(a.bottom=u));return a.top!==null&&(t=a.right-a.left,e=a.bottom-a.top+1,h=s.getImageData(a.left,a.top,t,e)),{height:e,width:t,data:h}}const to=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function ku(i){const t=to.exec(i);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}let Di;function eo(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location,Di||(Di=document.createElement("a")),Di.href=i;const e=Yn.parse(Di.href),s=!e.port&&t.port===""||e.port===t.port;return e.hostname!==t.hostname||!s||e.protocol!==t.protocol?"anonymous":""}function qt(i,t=1){const e=S.RETINA_PREFIX.exec(i);return e?parseFloat(e[1]):t}var Gu={__proto__:null,isMobile:Dt,EventEmitter:Re,earcut:Ps,url:Yn,path:ft,sayHello:Vh,skipHello:Xh,isWebGLSupported:qn,hex2rgb:me,hex2string:Os,rgb2hex:Mu,string2hex:Pi,correctBlendMode:Gs,premultiplyBlendMode:ks,premultiplyRgba:Kn,premultiplyTint:Mi,premultiplyTintToRgba:Hs,createIndicesForQuads:Zn,getBufferType:Bi,interleaveTypedArrays:Nu,isPow2:Xs,log2:Vs,nextPow2:$e,removeItems:_e,sign:ge,uid:ne,deprecation:Lu,BaseTextureCache:At,ProgramCache:zs,TextureCache:xt,clearTextureCache:Ou,destroyTextureCache:Uu,CanvasRenderTarget:Ws,trimCanvas:Jn,decomposeDataUri:ku,determineCrossOrigin:eo,getResolutionOfUrl:qt,DATA_URI:to};const Ni=[];function js(i,t){if(!i)return null;let e="";if(typeof i=="string"){const s=/\.(\w{3,4})(?:$|\?|#)/i.exec(i);s&&(e=s[1].toLowerCase())}for(let s=Ni.length-1;s>=0;--s){const r=Ni[s];if(r.test&&r.test(i,e))return new r(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Pe{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Tt("setRealSize"),this.onUpdate=new Tt("update"),this.onError=new Tt("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,s){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class Me extends Pe{constructor(t,e){const{width:s,height:r}=e||{};if(!s||!r)throw new Error("BufferResource width or height invalid");super(s,r),this.data=t}upload(t,e,s){const r=t.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Et.UNPACK);const n=e.realWidth,o=e.realHeight;return s.width===n&&s.height===o?r.texSubImage2D(e.target,0,0,0,n,o,e.format,s.type,this.data):(s.width=n,s.height=o,r.texImage2D(e.target,0,s.internalFormat,n,o,0,e.format,s.type,this.data)),!0}dispose(){this.data=null}static test(t){return t instanceof Float32Array||t instanceof Uint8Array||t instanceof Uint32Array}}const Hu={scaleMode:Xt.NEAREST,format:C.RGBA,alphaMode:Et.NPM},qe=class extends Re{constructor(i=null,t=null){super(),t=t||{};const{alphaMode:e,mipmap:s,anisotropicLevel:r,scaleMode:n,width:o,height:a,wrapMode:h,format:l,type:c,target:u,resolution:d,resourceOptions:f}=t;i&&!(i instanceof Pe)&&(i=js(i,f),i.internal=!0),this.resolution=d||S.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((a||0)*this.resolution)/this.resolution,this._mipmap=s!=null?s:S.MIPMAP_TEXTURES,this.anisotropicLevel=r!=null?r:S.ANISOTROPIC_LEVEL,this._wrapMode=h||S.WRAP_MODE,this._scaleMode=n!=null?n:S.SCALE_MODE,this.format=l||C.RGBA,this.type=c||O.UNSIGNED_BYTE,this.target=u||le.TEXTURE_2D,this.alphaMode=e!=null?e:Et.UNPACK,this.uid=ne(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&a>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(i)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(i){this._mipmap!==i&&(this._mipmap=i,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(i){this._scaleMode!==i&&(this._scaleMode=i,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(i){this._wrapMode!==i&&(this._wrapMode=i,this.dirtyStyleId++)}setStyle(i,t){let e;return i!==void 0&&i!==this.scaleMode&&(this.scaleMode=i,e=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,e=!0),e&&this.dirtyStyleId++,this}setSize(i,t,e){return e=e||this.resolution,this.setRealSize(i*e,t*e,e)}setRealSize(i,t,e){return this.resolution=e||this.resolution,this.width=Math.round(i)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Xs(this.realWidth)&&Xs(this.realHeight)}setResolution(i){const t=this.resolution;return t===i?this:(this.resolution=i,this.valid&&(this.width=Math.round(this.width*t)/i,this.height=Math.round(this.height*t)/i,this.emit("update",this)),this._refreshPOT(),this)}setResource(i){if(this.resource===i)return this;if(this.resource)throw new Error("Resource can be set only once");return i.bind(this),this.resource=i,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(i){this.emit("error",this,i)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete At[this.cacheId],delete xt[this.cacheId],this.cacheId=null),this.dispose(),qe.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(i,t,e=S.STRICT_TEXTURE_CACHE){const s=typeof i=="string";let r=null;if(s)r=i;else{if(!i._pixiId){const o=(t==null?void 0:t.pixiIdPrefix)||"pixiid";i._pixiId=`${o}_${ne()}`}r=i._pixiId}let n=At[r];if(s&&e&&!n)throw new Error(`The cacheId "${r}" does not exist in BaseTextureCache.`);return n||(n=new qe(i,t),n.cacheId=r,qe.addToCache(n,r)),n}static fromBuffer(i,t,e,s){i=i||new Float32Array(t*e*4);const r=new Me(i,{width:t,height:e}),n=i instanceof Float32Array?O.FLOAT:O.UNSIGNED_BYTE;return new qe(r,Object.assign({},Hu,s||{width:t,height:e,type:n}))}static addToCache(i,t){t&&(i.textureCacheIds.includes(t)||i.textureCacheIds.push(t),At[t]&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),At[t]=i)}static removeFromCache(i){if(typeof i=="string"){const t=At[i];if(t){const e=t.textureCacheIds.indexOf(i);return e>-1&&t.textureCacheIds.splice(e,1),delete At[i],t}}else if(i!=null&&i.textureCacheIds){for(let t=0;t<i.textureCacheIds.length;++t)delete At[i.textureCacheIds[t]];return i.textureCacheIds.length=0,i}return null}};let W=qe;W._globalBatch=0;class Ys extends Pe{constructor(t,e){const{width:s,height:r}=e||{};super(s,r),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new W;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let s=0;s<this.length;s++)!t[s]||(t[s].castToBaseTexture?this.addBaseTextureAt(t[s].castToBaseTexture(),s):t[s]instanceof Pe?this.addResourceAt(t[s],s):this.addResourceAt(js(t[s],e),s))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const e=this.items.map(s=>s.resource).filter(s=>s).map(s=>s.load());return this._load=Promise.all(e).then(()=>{const{realWidth:s,realHeight:r}=this.items[0];return this.resize(s,r),Promise.resolve(this)}),this._load}}class io extends Ys{constructor(t,e){const{width:s,height:r}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:s,height:r}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=le.TEXTURE_2D_ARRAY}upload(t,e,s){const{length:r,itemDirtyIds:n,items:o}=this,{gl:a}=t;s.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,s.internalFormat,this._width,this._height,r,0,e.format,s.type,null);for(let h=0;h<r;h++){const l=o[h];n[h]<l.dirtyId&&(n[h]=l.dirtyId,l.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,s.type,l.resource.source))}return!0}}class Kt extends Pe{constructor(t){const e=t,s=e.naturalWidth||e.videoWidth||e.width,r=e.naturalHeight||e.videoHeight||e.height;super(s,r),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,s){s===void 0&&!e.startsWith("data:")?t.crossOrigin=eo(e):s!==!1&&(t.crossOrigin=typeof s=="string"?s:"anonymous")}upload(t,e,s,r){const n=t.gl,o=e.realWidth,a=e.realHeight;if(r=r||this.source,typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement){if(!r.complete||r.naturalWidth===0)return!1}else if(typeof HTMLVideoElement!="undefined"&&r instanceof HTMLVideoElement&&r.readyState<=1&&r.buffered.length===0)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Et.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&s.width===o&&s.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,s.type,r):(s.width=o,s.height=a,n.texImage2D(e.target,0,s.internalFormat,e.format,s.type,r)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,s=t.naturalHeight||t.videoHeight||t.height;this.resize(e,s),super.update()}dispose(){this.source=null}}class so extends Kt{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Ke=class extends Ys{constructor(i,t){const{width:e,height:s,autoLoad:r,linkBaseTexture:n}=t||{};if(i&&i.length!==Ke.SIDES)throw new Error(`Invalid length. Got ${i.length}, expected 6`);super(6,{width:e,height:s});for(let o=0;o<Ke.SIDES;o++)this.items[o].target=le.TEXTURE_CUBE_MAP_POSITIVE_X+o;this.linkBaseTexture=n!==!1,i&&this.initFromArray(i,t),r!==!1&&this.load()}bind(i){super.bind(i),i.target=le.TEXTURE_CUBE_MAP}addBaseTextureAt(i,t,e){if(e===void 0&&(e=this.linkBaseTexture),!this.items[t])throw new Error(`Index ${t} is out of bounds`);if(!this.linkBaseTexture||i.parentTextureArray||Object.keys(i._glTextures).length>0)if(i.resource)this.addResourceAt(i.resource,t);else throw new Error("CubeResource does not support copying of renderTexture.");else i.target=le.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.parentTextureArray=this.baseTexture,this.items[t]=i;return i.valid&&!this.valid&&this.resize(i.realWidth,i.realHeight),this.items[t]=i,this}upload(i,t,e){const s=this.itemDirtyIds;for(let r=0;r<Ke.SIDES;r++){const n=this.items[r];(s[r]<n.dirtyId||e.dirtyId<t.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(i,n,e),s[r]=n.dirtyId):s[r]<-1&&(i.gl.texImage2D(n.target,0,e.internalFormat,t.realWidth,t.realHeight,0,t.format,e.type,null),s[r]=-1))}return!0}static test(i){return Array.isArray(i)&&i.length===Ke.SIDES}};let $s=Ke;$s.SIDES=6;class qs extends Kt{constructor(t,e){var s;if(e=e||{},typeof t=="string"){const r=new Image;Kt.crossOrigin(r,t,e.crossorigin),r.src=t,t=r}super(t),!t.complete&&!!this._width&&!!this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=((s=e.createBitmap)!=null?s:S.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,s)=>{const r=this.source;this.url=r.src;const n=()=>{this.destroyed||(r.onload=null,r.onerror=null,this.resize(r.width,r.height),this._load=null,this.createBitmap?e(this.process()):e(this))};r.complete&&r.src?n():(r.onload=n,r.onerror=o=>{s(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,s=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:s?"cors":"no-cors"}).then(r=>r.blob()).then(r=>e(r,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Et.UNPACK?"premultiply":"none"})).then(r=>this.destroyed?Promise.reject():(this.bitmap=r,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,s){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,s);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,s,this.bitmap),!this.preserveBitmap){let r=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==s&&a.dirtyId!==e.dirtyId){r=!1;break}}r&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement!="undefined"&&(typeof t=="string"||t instanceof HTMLImageElement)}}const Fi=class extends Kt{constructor(i,t){t=t||{},super(S.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=i,this.scale=t.scale||1,this._overrideWidth=t.width,this._overrideHeight=t.height,this._resolve=null,this._crossorigin=t.crossorigin,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(i=>{if(this._resolve=()=>{this.resize(this.source.width,this.source.height),i(this)},Fi.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const i=new Image;Kt.crossOrigin(i,this.svg,this._crossorigin),i.src=this.svg,i.onerror=t=>{!this._resolve||(i.onerror=null,this.onError.emit(t))},i.onload=()=>{if(!this._resolve)return;const t=i.width,e=i.height;if(!t||!e)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=t*this.scale,r=e*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/e*t,r=this._overrideHeight||this._overrideWidth/t*e),s=Math.round(s),r=Math.round(r);const n=this.source;n.width=s,n.height=r,n._pixiId=`canvas_${ne()}`,n.getContext("2d").drawImage(i,0,0,t,e,0,0,s,r),this._resolve(),this._resolve=null}}static getSize(i){const t=Fi.SVG_SIZE.exec(i),e={};return t&&(e[t[1]]=Math.round(parseFloat(t[3])),e[t[5]]=Math.round(parseFloat(t[7]))),e}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(i,t){return t==="svg"||typeof i=="string"&&i.startsWith("data:image/svg+xml")||typeof i=="string"&&Fi.SVG_XML.test(i)}};let Be=Fi;Be.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Be.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;const Ks=class extends Kt{constructor(i,t){if(t=t||{},!(i instanceof HTMLVideoElement)){const e=document.createElement("video");e.setAttribute("preload","auto"),e.setAttribute("webkit-playsinline",""),e.setAttribute("playsinline",""),typeof i=="string"&&(i=[i]);const s=i[0].src||i[0];Kt.crossOrigin(e,s,t.crossorigin);for(let r=0;r<i.length;++r){const n=document.createElement("source");let{src:o,mime:a}=i[r];o=o||i[r];const h=o.split("?").shift().toLowerCase(),l=h.slice(h.lastIndexOf(".")+1);a=a||Ks.MIME_TYPES[l]||`video/${l}`,n.src=o,n.type=a,e.appendChild(n)}i=e}super(i),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this._load=null,this._resolve=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),t.autoLoad!==!1&&this.load()}update(i=0){if(!this.destroyed){const t=Z.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t),(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}load(){if(this._load)return this._load;const i=this.source;return(i.readyState===i.HAVE_ENOUGH_DATA||i.readyState===i.HAVE_FUTURE_DATA)&&i.width&&i.height&&(i.complete=!0),i.addEventListener("play",this._onPlayStart.bind(this)),i.addEventListener("pause",this._onPlayStop.bind(this)),this._isSourceReady()?this._onCanPlay():(i.addEventListener("canplay",this._onCanPlay),i.addEventListener("canplaythrough",this._onCanPlay),i.addEventListener("error",this._onError,!0)),this._load=new Promise(t=>{this.valid?t(this):(this._resolve=t,i.load())}),this._load}_onError(i){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(i)}_isSourcePlaying(){const i=this.source;return!i.paused&&!i.ended&&this._isSourceReady()}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(Z.shared.add(this.update,this),this._isConnectedToTicker=!0)}_onPlayStop(){this._isConnectedToTicker&&(Z.shared.remove(this.update,this),this._isConnectedToTicker=!1)}_onCanPlay(){const i=this.source;i.removeEventListener("canplay",this._onCanPlay),i.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this.resize(i.videoWidth,i.videoHeight),!t&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&i.play()}dispose(){this._isConnectedToTicker&&(Z.shared.remove(this.update,this),this._isConnectedToTicker=!1);const i=this.source;i&&(i.removeEventListener("error",this._onError,!0),i.pause(),i.src="",i.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(i){i!==this._autoUpdate&&(this._autoUpdate=i,!this._autoUpdate&&this._isConnectedToTicker?(Z.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(Z.shared.add(this.update,this),this._isConnectedToTicker=!0))}get updateFPS(){return this._updateFPS}set updateFPS(i){i!==this._updateFPS&&(this._updateFPS=i)}static test(i,t){return globalThis.HTMLVideoElement&&i instanceof HTMLVideoElement||Ks.TYPES.includes(t)}};let Li=Ks;Li.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Li.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};class Ae extends Kt{constructor(t,e){var r;var s=(...n)=>{super(...n)};e=e||{},typeof t=="string"?(s(Ae.EMPTY),this.url=t):(s(t),this.url=null),this.crossOrigin=(r=e.crossOrigin)!=null?r:!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const s=await S.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const r=await s.blob();if(this.destroyed)return;const n=await createImageBitmap(r,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Et.UNPACK?"premultiply":"none"});if(this.destroyed)return;this.source=n,this.update(),t(this)}catch(s){if(this.destroyed)return;e(s),this.onError.emit(s)}}),this._load)}upload(t,e,s){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,s)):(this.load(),!1)}dispose(){this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap!="undefined"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){var t;return Ae._EMPTY=(t=Ae._EMPTY)!=null?t:S.ADAPTER.createCanvas(0,0),Ae._EMPTY}}Ni.push(Ae,qs,so,Li,Be,Me,$s,io);class Xu extends Me{upload(t,e,s){const r=t.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Et.UNPACK);const n=e.realWidth,o=e.realHeight;return s.width===n&&s.height===o?r.texSubImage2D(e.target,0,0,0,n,o,e.format,s.type,this.data):(s.width=n,s.height=o,r.texImage2D(e.target,0,s.internalFormat,n,o,0,e.format,s.type,this.data)),!0}}class Ui{constructor(t,e){this.width=Math.round(t||100),this.height=Math.round(e||100),this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Tt("disposeFramebuffer"),this.multisample=nt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new W(null,{scaleMode:Xt.NEAREST,resolution:1,mipmap:Pt.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new W(new Xu(null,{width:this.width,height:this.height}),{scaleMode:Xt.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Pt.OFF,format:C.DEPTH_COMPONENT,type:O.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let s=0;s<this.colorTextures.length;s++){const r=this.colorTextures[s],n=r.resolution;r.setSize(t/n,e/n)}if(this.depthTexture){const s=this.depthTexture.resolution;this.depthTexture.setSize(t/s,e/s)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Zs extends W{constructor(t={}){var e;if(typeof t=="number"){const s=arguments[0],r=arguments[1],n=arguments[2],o=arguments[3];t={width:s,height:r,scaleMode:n,resolution:o}}t.width=t.width||100,t.height=t.height||100,(e=t.multisample)!=null||(t.multisample=nt.NONE),super(null,t),this.mipmap=Pt.OFF,this.valid=!0,this.clearColor=[0,0,0,0],this.framebuffer=new Ui(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Qs{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,s){const r=e.width,n=e.height;if(s){const o=t.width/2/r,a=t.height/2/n,h=t.x/r+o,l=t.y/n+a;s=J.add(s,J.NW),this.x0=h+o*J.uX(s),this.y0=l+a*J.uY(s),s=J.add(s,2),this.x1=h+o*J.uX(s),this.y1=l+a*J.uY(s),s=J.add(s,2),this.x2=h+o*J.uX(s),this.y2=l+a*J.uY(s),s=J.add(s,2),this.x3=h+o*J.uX(s),this.y3=l+a*J.uY(s)}else this.x0=t.x/r,this.y0=t.y/n,this.x1=(t.x+t.width)/r,this.y1=t.y/n,this.x2=(t.x+t.width)/r,this.y2=(t.y+t.height)/n,this.x3=t.x/r,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}const ro=new Qs;function Oi(i){i.destroy=function(){},i.on=function(){},i.once=function(){},i.emit=function(){}}class B extends Re{constructor(t,e,s,r,n,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new V(0,0,1,1)),t instanceof B&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this._uvs=ro,this.uvMatrix=null,this.orig=s||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new j(o.x,o.y):new j(0,0),this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;(e==null?void 0:e.url)&&xt[e.url]&&B.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,B.removeFromCache(this),this.textureCacheIds=null}clone(){var r;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),s=new B(this.baseTexture,!this.noFrame&&t,e,(r=this.trim)==null?void 0:r.clone(),this.rotate,this.defaultAnchor);return this.noFrame&&(s._frame=t),s}updateUvs(){this._uvs===ro&&(this._uvs=new Qs),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},s=S.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else if(t instanceof W){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${ne()}`,W.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${ne()}`}n=t._pixiId}let o=xt[n];if(r&&s&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof W)?(e.resolution||(e.resolution=qt(t)),o=new B(new W(t,e)),o.baseTexture.cacheId=n,W.addToCache(o.baseTexture,n),B.addToCache(o,n)):!o&&t instanceof W&&(o=new B(t),B.addToCache(o,n)),o}static fromURL(t,e){const s=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),r=B.from(t,Object.assign({resourceOptions:s},e),!1),n=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):n.load().then(()=>Promise.resolve(r))}static fromBuffer(t,e,s,r){return new B(W.fromBuffer(t,e,s,r))}static fromLoader(t,e,s,r){const n=new W(t,Object.assign({scaleMode:S.SCALE_MODE,resolution:qt(e)},r)),{resource:o}=n;o instanceof qs&&(o.url=e);const a=new B(n);return s||(s=e),W.addToCache(a.baseTexture,s),B.addToCache(a,s),s!==e&&(W.addToCache(a.baseTexture,e),B.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(h=>{a.baseTexture.once("loaded",()=>h(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),xt[e]&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),xt[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=xt[t];if(e){const s=e.textureCacheIds.indexOf(t);return s>-1&&e.textureCacheIds.splice(s,1),delete xt[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)xt[t.textureCacheIds[e]]===t&&delete xt[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:s,width:r,height:n}=t,o=e+r>this.baseTexture.width,a=s+n>this.baseTexture.height;if(o||a){const h=o&&a?"and":"or",l=`X: ${e} + ${r} = ${e+r} > ${this.baseTexture.width}`,c=`Y: ${s} + ${n} = ${s+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${c}`)}this.valid=r&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return B._EMPTY||(B._EMPTY=new B(new W),Oi(B._EMPTY),Oi(B._EMPTY.baseTexture)),B._EMPTY}static get WHITE(){if(!B._WHITE){const t=S.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),B._WHITE=new B(W.from(t)),Oi(B._WHITE),Oi(B._WHITE.baseTexture)}return B._WHITE}}class te extends B{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,s=!0){const r=this.baseTexture.resolution,n=Math.round(t*r)/r,o=Math.round(e*r)/r;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,s&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new te(new Zs(t))}}class Js{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,s=nt.NONE){const r=new Zs(Object.assign({width:t,height:e,resolution:1,multisample:s},this.textureOptions));return new te(r)}getOptimalTexture(t,e,s=1,r=nt.NONE){let n;t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=$e(t),e=$e(e),n=((t&65535)<<16|e&65535)>>>0,r>1&&(n+=r*4294967296)):n=r>1?-r:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,r)),o.filterPoolKey=n,o.setResolution(s),o}getFilterTexture(t,e,s){const r=this.getOptimalTexture(t.width,t.height,e||t.resolution,s||nt.NONE);return r.filterFrame=t.filterFrame,r}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(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={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const s=this.texturePool[e];if(s)for(let r=0;r<s.length;r++)s[r].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Js.SCREEN_KEY=-1;class _i{constructor(t,e=0,s=!1,r=O.FLOAT,n,o,a){this.buffer=t,this.size=e,this.normalized=s,this.type=r,this.stride=n,this.start=o,this.instance=a}destroy(){this.buffer=null}static from(t,e,s,r,n){return new _i(t,e,s,r,n)}}let Vu=0;class rt{constructor(t,e=!0,s=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=s,this.static=e,this.id=Vu++,this.disposeRunner=new Tt("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Bt.ELEMENT_ARRAY_BUFFER:Bt.ARRAY_BUFFER}get index(){return this.type===Bt.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new rt(t)}}const zu={Float32Array,Uint32Array,Int32Array,Uint8Array};function Wu(i,t){let e=0,s=0;const r={};for(let h=0;h<i.length;h++)s+=t[h],e+=i[h].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let h=0;h<i.length;h++){const l=t[h],c=i[h],u=Bi(c);r[u]||(r[u]=new zu[u](n)),o=r[u];for(let d=0;d<c.length;d++){const f=(d/l|0)*s+a,p=d%l;o[f+p]=c[d]}a+=l}return new Float32Array(n)}const no={5126:4,5123:2,5121:1};let ju=0;const Yu={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class ie{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=ju++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Tt("disposeGeometry"),this.refCount=0}addAttribute(t,e,s=0,r=!1,n,o,a,h=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof rt||(e instanceof Array&&(e=new Float32Array(e)),e=new rt(e));const l=t.split("|");if(l.length>1){for(let u=0;u<l.length;u++)this.addAttribute(l[u],e,s,r,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new _i(c,s,r,n,o,a,h),this.instanced=this.instanced||h,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof rt||(t instanceof Array&&(t=new Uint16Array(t)),t=new rt(t)),t.type=Bt.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],s=new rt;let r;for(r in this.attributes){const n=this.attributes[r],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*no[n.type]/4),n.buffer=0}for(s.data=Wu(t,e),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[s],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new ie;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new rt(this.buffers[e].data.slice(0));for(const e in this.attributes){const s=this.attributes[e];t.attributes[e]=new _i(s.buffer,s.size,s.normalized,s.type,s.stride,s.start,s.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Bt.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new ie,s=[],r=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)r[h]=r[h]||0,r[h]+=o.buffers[h].data.length,n[h]=0}for(let a=0;a<o.buffers.length;a++)s[a]=new Yu[Bi(o.buffers[a].data)](r[a]),e.buffers[a]=new rt(s[a]);for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)s[h].set(o.buffers[h].data,n[h]),n[h]+=o.buffers[h].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=Bt.ELEMENT_ARRAY_BUFFER;let a=0,h=0,l=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(h+=d.size*no[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+l]+=a;a+=t[u].buffers[c].data.length/h,l+=d.length}}return e}}class oo extends ie{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class tr extends ie{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new rt(this.vertices),this.uvBuffer=new rt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let s=0,r=0;return this.uvs[0]=s,this.uvs[1]=r,this.uvs[2]=s+e.width/t.width,this.uvs[3]=r,this.uvs[4]=s+e.width/t.width,this.uvs[5]=r+e.height/t.height,this.uvs[6]=s,this.uvs[7]=r+e.height/t.height,s=e.x,r=e.y,this.vertices[0]=s,this.vertices[1]=r,this.vertices[2]=s+e.width,this.vertices[3]=r,this.vertices[4]=s+e.width,this.vertices[5]=r+e.height,this.vertices[6]=s,this.vertices[7]=r+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}let $u=0;class Ct{constructor(t,e,s){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=$u++,this.static=!!e,this.ubo=!!s,t instanceof rt?(this.buffer=t,this.buffer.type=Bt.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new rt(new Float32Array(1)),this.buffer.type=Bt.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,s){if(!this.ubo)this.uniforms[t]=new Ct(e,s);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,s){return new Ct(t,e,s)}static uboFrom(t,e){return new Ct(t,e!=null?e:!0,!0)}}class ao{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=nt.NONE,this.sourceFrame=new V,this.destinationFrame=new V,this.bindingSourceFrame=new V,this.bindingDestinationFrame=new V,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const ki=[new j,new j,new j,new j],er=new et;class ir{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Js,this.statePool=[],this.quad=new oo,this.quadUv=new tr,this.tempRect=new V,this.activeState={},this.globalUniforms=new Ct({outputFrame:new V,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){var p,m;const s=this.renderer,r=this.defaultFilterStack,n=this.statePool.pop()||new ao,o=this.renderer.renderTexture;let a=e[0].resolution,h=e[0].multisample,l=e[0].padding,c=e[0].autoFit,u=(p=e[0].legacy)!=null?p:!0;for(let _=1;_<e.length;_++){const x=e[_];a=Math.min(a,x.resolution),h=Math.min(h,x.multisample),l=this.useMaxPadding?Math.max(l,x.padding):l+x.padding,c=c&&x.autoFit,u=u||((m=x.legacy)!=null?m:!0)}r.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),r.push(n),n.resolution=a,n.multisample=h,n.legacy=u,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(l);const d=this.tempRect.copyFrom(o.sourceFrame);s.projection.transform&&this.transformAABB(er.copyFrom(s.projection.transform).invert(),d),c?(n.sourceFrame.fit(d),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(d)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:s.resolution,o.sourceFrame,o.destinationFrame,s.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,a,h),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const f=this.tempRect;f.x=0,f.y=0,f.width=n.sourceFrame.width,f.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=s.projection.transform,s.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,f),s.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),s=e.filters;this.activeState=e;const r=this.globalUniforms.uniforms;r.outputFrame=e.sourceFrame,r.resolution=e.resolution;const n=r.inputSize,o=r.inputPixel,a=r.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const l=r.filterArea;l[0]=e.destinationFrame.width,l[1]=e.destinationFrame.height,l[2]=e.sourceFrame.x,l[3]=e.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const h=t[t.length-1];if(this.renderer.framebuffer.blit(),s.length===1)s[0].apply(this,e.renderTexture,h.renderTexture,Mt.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let l=e.renderTexture,c=this.getOptimalFilterTexture(l.width,l.height,e.resolution);c.filterFrame=l.filterFrame;let u=0;for(u=0;u<s.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(l.width,l.height,e.resolution),c.filterFrame=l.filterFrame),s[u].apply(this,l,c,Mt.CLEAR,e);const d=l;l=c,c=d}s[u].apply(this,l,h.renderTexture,Mt.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Mt.CLEAR){const{renderTexture:s,state:r}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t!=null&&t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,s.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?s.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=r.stateId&1||this.forceClear;(e===Mt.CLEAR||e===Mt.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,s,r){const n=this.renderer;n.state.set(t.state),this.bindAndClear(s,r),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(It.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(It.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:s,destinationFrame:r}=this.activeState,{orig:n}=e._texture,o=t.set(r.width,0,0,r.height,s.x,s.y),a=e.worldTransform.copyTo(et.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,s=1,r=nt.NONE){return this.texturePool.getOptimalTexture(t,e,s,r)}getFilterTexture(t,e,s){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,s||nt.NONE);return r.filterFrame=t.filterFrame,r}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const s=ki[0],r=ki[1],n=ki[2],o=ki[3];s.set(e.left,e.top),r.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(s,s),t.apply(r,r),t.apply(n,n),t.apply(o,o);const a=Math.min(s.x,r.x,n.x,o.x),h=Math.min(s.y,r.y,n.y,o.y),l=Math.max(s.x,r.x,n.x,o.x),c=Math.max(s.y,r.y,n.y,o.y);e.x=a,e.y=h,e.width=l-a,e.height=c-h}roundFrame(t,e,s,r,n){if(!(t.width<=0||t.height<=0||s.width<=0||s.height<=0)){if(n){const{a:o,b:a,c:h,d:l}=n;if((Math.abs(a)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(l)>1e-4))return}n=n?er.copyFrom(n):er.identity(),n.translate(-s.x,-s.y).scale(r.width/s.width,r.height/s.height).translate(r.x,r.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}ir.extension={type:P.RendererSystem,name:"filter"},U.add(ir);class Ze{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}class sr{constructor(t){this.renderer=t,this.emptyRenderer=new Ze(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:s}=this.renderer.texture;for(let r=e-1;r>=0;--r)t[r]=s[r]||null,t[r]&&(t[r]._batchLocation=r)}boundArray(t,e,s,r){const{elements:n,ids:o,count:a}=t;let h=0;for(let l=0;l<a;l++){const c=n[l],u=c._batchLocation;if(u>=0&&u<r&&e[u]===c){o[l]=u;continue}for(;h<r;){const d=e[h];if(d&&d._batchEnabled===s&&d._batchLocation===h){h++;continue}o[l]=h,c._batchLocation=h,e[h]=c;break}}}destroy(){this.renderer=null}}sr.extension={type:P.RendererSystem,name:"batch"},U.add(sr);let ho=0;class rr{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},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,this.renderer.CONTEXT_UID=ho++,t.isContextLost()&&t.getExtension("WEBGL_lose_context")&&t.getExtension("WEBGL_lose_context").restoreContext()}init(t){var e;if(t.context)this.initFromContext(t.context);else{const s=this.renderer.background.alpha<1,r=(e=t.premultipliedAlpha)!=null?e:!0;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:s,premultipliedAlpha:r,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=ho++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let s;if(S.PREFER_ENV>=se.WEBGL2&&(s=t.getContext("webgl2",e)),s)this.webGLVersion=2;else if(this.webGLVersion=1,s=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!s)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=s,this.getExtensions(),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")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),loseContext:t.getExtension("WEBGL_lose_context"),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")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault()}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),s="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;s&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=s||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}rr.extension={type:P.RendererSystem,name:"context"},U.add(rr);class lo{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=nt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const qu=new V;class nr{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Ui(10,10),this.msaaSamples=null}contextChange(){const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new V,this.hasMRT=!0,this.writeDepthTexture=!0,this.disposeAll(!0),this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,s=this.renderer.context.extensions.depthTexture;S.PREFER_ENV===se.WEBGL_LEGACY&&(e=null,s=null),e?t.drawBuffers=r=>e.drawBuffersWEBGL(r):(this.hasMRT=!1,t.drawBuffers=()=>{}),s||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,s=0){const{gl:r}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,r.bindFramebuffer(r.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==s&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=s),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,s)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>s,a=e.height>>s,h=o/e.width;this.setViewport(e.x*h,e.y*h,o,a)}else{const o=t.width>>s,a=t.height>>s;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,s,r){const n=this.viewport;t=Math.round(t),e=Math.round(e),s=Math.round(s),r=Math.round(r),(n.width!==s||n.height!==r||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=s,n.height=r,this.gl.viewport(t,e,s,r))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,s,r,n=yi.COLOR|yi.DEPTH){const{gl:o}=this;o.clearColor(t,e,s,r),o.clear(n)}initFramebuffer(t){const{gl:e}=this,s=new lo(e.createFramebuffer());return s.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=s,this.managedFramebuffers.push(t),t.disposeRunner.add(this),s}resizeFramebuffer(t){const{gl:e}=this,s=t.glFramebuffers[this.CONTEXT_UID];s.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,s.stencil),s.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,s.multisample,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.width,t.height));const r=t.colorTextures;let n=r.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=r[o],h=a.parentTextureArray||a;this.renderer.texture.bind(h,0),o===0&&s.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,s.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,s.multisample,h._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:s}=this,r=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;s.drawBuffers||(o=Math.min(o,1)),r.multisample>1&&this.canMultisampleFramebuffer(t)?r.msaaBuffer=r.msaaBuffer||s.createRenderbuffer():r.msaaBuffer&&(s.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const a=[];for(let h=0;h<o;h++){const l=n[h],c=l.parentTextureArray||l;this.renderer.texture.bind(c,0),h===0&&r.msaaBuffer?(s.bindRenderbuffer(s.RENDERBUFFER,r.msaaBuffer),s.renderbufferStorageMultisample(s.RENDERBUFFER,r.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,r.msaaBuffer)):(s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+h,l.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(s.COLOR_ATTACHMENT0+h))}if(a.length>1&&s.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}(t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)?(r.stencil=r.stencil||s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,r.stencil),r.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,r.multisample,s.DEPTH24_STENCIL8,t.width,t.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,t.width,t.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,r.stencil)):r.stencil&&(s.deleteRenderbuffer(r.stencil),r.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let s=nt.NONE;if(t<=1||e===null)return s;for(let r=0;r<e.length;r++)if(e[r]<=t){s=e[r];break}return s===1&&(s=nt.NONE),s}blit(t,e,s){const{current:r,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!r)return;const h=r.glFramebuffers[a];if(!h)return;if(!t){if(!h.msaaBuffer)return;const c=r.colorTextures[0];if(!c)return;h.blitFramebuffer||(h.blitFramebuffer=new Ui(r.width,r.height),h.blitFramebuffer.addColorTexture(0,c)),t=h.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==r.width||t.height!==r.height)&&(t.width=r.width,t.height=r.height,t.dirtyId++,t.dirtySize++)}e||(e=qu,e.width=r.width,e.height=r.height),s||(s=e);const l=e.width===s.width&&e.height===s.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,h.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,s.left,s.top,s.right,s.bottom,o.COLOR_BUFFER_BIT,l?o.NEAREST:o.LINEAR)}disposeFramebuffer(t,e){const s=t.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!s)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(r.deleteFramebuffer(s.framebuffer),s.msaaBuffer&&r.deleteRenderbuffer(s.msaaBuffer),s.stencil&&r.deleteRenderbuffer(s.stencil)),s.blitFramebuffer&&s.blitFramebuffer.dispose()}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let s=0;s<e.length;s++)this.disposeFramebuffer(e[s],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil)return;t.stencil=!0;const s=t.width,r=t.height,n=this.gl,o=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,n.DEPTH24_STENCIL8,s,r):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,s,r),e.stencil=o,n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new V}destroy(){this.renderer=null}}nr.extension={type:P.RendererSystem,name:"framebuffer"},U.add(nr);const or={5126:4,5123:2,5121:1};class ar{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let s=this.renderer.context.extensions.vertexArrayObject;S.PREFER_ENV===se.WEBGL_LEGACY&&(s=null),s?(t.createVertexArray=()=>s.createVertexArrayOES(),t.bindVertexArray=r=>s.bindVertexArrayOES(r),t.deleteVertexArray=r=>s.deleteVertexArrayOES(r)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const s=t.getExtension("ANGLE_instanced_arrays");s?(t.vertexAttribDivisor=(r,n)=>s.vertexAttribDivisorANGLE(r,n),t.drawElementsInstanced=(r,n,o,a,h)=>s.drawElementsInstancedANGLE(r,n,o,a,h),t.drawArraysInstanced=(r,n,o,a)=>s.drawArraysInstancedANGLE(r,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:s}=this;let r=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;r||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=r={},n=!0);const o=r[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?s.bindVertexArray(o):this.activateVao(t,e.program)),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.update(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.id];for(const o in s)r[o]&&n.push(o,r[o].location);return n.join("-")}initGeometryVao(t,e,s=!0){const r=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const h=this.getSignature(t,a),l=t.glVertexArrayObjects[this.CONTEXT_UID];let c=l[h];if(c)return l[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*or[d[m].type];for(const m in d){const _=d[m],x=_.size;_.stride===void 0&&(f[_.buffer]===x*or[_.type]?_.stride=0:_.stride=f[_.buffer]),_.start===void 0&&(_.start=p[_.buffer],p[_.buffer]+=x*or[_.type])}c=r.createVertexArray(),r.bindVertexArray(c);for(let m=0;m<u.length;m++){const _=u[m];o.bind(_),s&&_._glBuffers[n].refCount++}return this.activateVao(t,a),l[a.id]=c,l[h]=c,r.bindVertexArray(null),o.unbind(Bt.ARRAY_BUFFER),c}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const s=t.glVertexArrayObjects[this.CONTEXT_UID],r=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!s){if(o)for(let h=0;h<n.length;h++){const l=n[h]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(n[h],e))}if(!e){for(const h in s)if(h[0]==="g"){const l=s[h];this._activeVao===l&&this.unbind(),r.deleteVertexArray(l)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let s=0;s<e.length;s++)this.disposeGeometry(this.managedGeometries[e[s]],t)}activateVao(t,e){const s=this.gl,r=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let h=null;for(const l in a){const c=a[l],u=o[c.buffer],d=u._glBuffers[r];if(e.attributeData[l]){h!==d&&(n.bind(u),h=d);const f=e.attributeData[l].location;if(s.enableVertexAttribArray(f),s.vertexAttribPointer(f,c.size,c.type||s.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)s.vertexAttribDivisor(f,1);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,s,r){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,h=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,h,(s||0)*a,r||1):n.drawElements(t,e||o.indexBuffer.data.length,h,(s||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,s,e||o.getSize(),r||1):n.drawArrays(t,s,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}ar.extension={type:P.RendererSystem,name:"geometry"},U.add(ar);class co{constructor(t=null){this.type=ht.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=S.FILTER_MULTISAMPLE,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=ht.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}function uo(i,t,e){const s=i.createShader(t);return i.shaderSource(s,e),i.compileShader(s),s}function fo(i,t){const e=i.getShaderSource(t).split(`
14
14
  `).map((l,c)=>`${c}: ${l}`),s=i.getShaderInfoLog(t),r=s.split(`
15
15
  `),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(`
16
16
  `);a[0]=h,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Ku(i,t,e,s){i.getProgramParameter(t,i.LINK_STATUS)||(i.getShaderParameter(e,i.COMPILE_STATUS)||fo(i,e),i.getShaderParameter(s,i.COMPILE_STATUS)||fo(i,s),console.error("PixiJS Error: Could not initialize shader."),i.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",i.getProgramInfoLog(t)))}function hr(i){const t=new Array(i);for(let e=0;e<t.length;e++)t[e]=!1;return t}function po(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 hr(2*t);case"bvec3":return hr(3*t);case"bvec4":return hr(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}const mo={};let De=mo;function _o(){if(De===mo||(De==null?void 0:De.isContextLost())){const i=S.ADAPTER.createCanvas();let t;S.PREFER_ENV>=se.WEBGL2&&(t=i.getContext("webgl2",{})),t||(t=i.getContext("webgl",{})||i.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),De=t}return De}let Gi;function Zu(){if(!Gi){Gi=yt.MEDIUM;const i=_o();i&&i.getShaderPrecisionFormat&&(Gi=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?yt.HIGH:yt.MEDIUM)}return Gi}function go(i,t,e){if(i.substring(0,9)!=="precision"){let s=t;return t===yt.HIGH&&e!==yt.HIGH&&(s=yt.MEDIUM),`precision ${s} float;
@@ -415,7 +415,7 @@ void main(void)
415
415
  `)}}return n.push(`
416
416
  renderer.buffer.update(buffer);
417
417
  `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
418
- `))}}class pd{}class Mo{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function md(i,t){const e={},s=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES);for(let r=0;r<s;r++){const n=t.getActiveAttrib(i,r);if(n.name.startsWith("gl_"))continue;const o=yo(t,n.type),a={type:o,name:n.name,size:xo(o),location:t.getAttribLocation(i,n.name)};e[n.name]=a}return e}function _d(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=yo(t,n.type);e[o]={name:o,index:r,type:h,size:n.size,isArray:a,value:po(h,n.size)}}return e}function Bo(i,t){var h;const e=uo(i,i.VERTEX_SHADER,t.vertexSrc),s=uo(i,i.FRAGMENT_SHADER,t.fragmentSrc),r=i.createProgram();i.attachShader(r,e),i.attachShader(r,s);const n=(h=t.extra)==null?void 0:h.transformFeedbackVaryings;if(n&&(typeof i.transformFeedbackVaryings!="function"||i.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?i.SEPARATE_ATTRIBS:i.INTERLEAVED_ATTRIBS)),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS)||Ku(i,r,e,s),t.attributeData=md(r,i),t.uniformData=_d(r,i),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((c,u)=>c>u?1:-1);for(let c=0;c<l.length;c++)t.attributeData[l[c]].location=c,i.bindAttribLocation(r,c,l[c]);i.linkProgram(r)}i.deleteShader(e),i.deleteShader(s);const o={};for(const l in t.uniformData){const c=t.uniformData[l];o[l]={location:i.getUniformLocation(r,l),value:po(c.type,c.size)}}return new Mo(r,o)}let gd=0;const Wi={textureCount:0,uboCount:0};class yr{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=gd++}systemCheck(){if(!rd())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const s=t.program,r=s.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==s&&(this.program=s,this.gl.useProgram(r.program)),e||(Wi.textureCount=0,Wi.uboCount=0,this.syncUniformGroup(t.uniformGroup,Wi)),r}setUniforms(t){const e=this.shader.program,s=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(s.uniformData,t,this.renderer)}syncUniformGroup(t,e){const s=this.getGlProgram();(!t.static||t.dirtyId!==s.uniformDirtyGroups[t.id])&&(s.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,s,e))}syncUniforms(t,e,s){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,s)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=ed(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const s=this.getGlProgram();if(!t.static||t.dirtyId!==0||!s.uniformGroups[t.id]){t.dirtyId=0;const r=s.uniformGroups[t.id]||this.createSyncBufferGroup(t,s,e);t.buffer.update(),r(s.uniformData,t.uniforms,this.renderer,Wi,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,s.uniformBufferBindings[e])}createSyncBufferGroup(t,e,s){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,s);e.uniformBufferBindings[s]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=Po(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(a.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}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("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,s=t.program,r=Bo(e,s);return s.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}yr.extension={type:P.RendererSystem,name:"shader"},U.add(yr);function xd(i,t=[]){return t[k.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.ADD]=[i.ONE,i.ONE],t[k.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.NONE]=[0,0],t[k.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[k.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[k.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[k.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[k.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[k.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[k.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[k.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[k.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[k.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}const vd=0,yd=1,Td=2,bd=3,Ed=4,wd=5,Tr=class{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=k.NONE,this._blendEq=!1,this.map=[],this.map[vd]=this.setBlend,this.map[yd]=this.setOffset,this.map[Td]=this.setCullFace,this.map[bd]=this.setDepthTest,this.map[Ed]=this.setFrontFace,this.map[wd]=this.setDepthMask,this.checks=[],this.defaultState=new jt,this.defaultState.blend=!0}contextChange(i){this.gl=i,this.blendModes=xd(i),this.set(this.defaultState),this.reset()}set(i){if(i=i||this.defaultState,this.stateId!==i.data){let t=this.stateId^i.data,e=0;for(;t;)t&1&&this.map[e].call(this,!!(i.data&1<<e)),t=t>>1,e++;this.stateId=i.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,i)}forceState(i){i=i||this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(i.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,i);this.stateId=i.data}setBlend(i){this.updateCheck(Tr.checkBlendMode,i),this.gl[i?"enable":"disable"](this.gl.BLEND)}setOffset(i){this.updateCheck(Tr.checkPolygonOffset,i),this.gl[i?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(i){this.gl[i?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(i){this.gl.depthMask(i)}setCullFace(i){this.gl[i?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(i){this.gl.frontFace(this.gl[i?"CW":"CCW"])}setBlendMode(i){if(i===this.blendMode)return;this.blendMode=i;const t=this.blendModes[i],e=this.gl;t.length===2?e.blendFunc(t[0],t[1]):e.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,e.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD))}setPolygonOffset(i,t){this.gl.polygonOffset(i,t)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(i,t){const e=this.checks.indexOf(i);t&&e===-1?this.checks.push(i):!t&&e!==-1&&this.checks.splice(e,1)}static checkBlendMode(i,t){i.setBlendMode(t.blendMode)}static checkPolygonOffset(i,t){i.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null}};let br=Tr;br.extension={type:P.RendererSystem,name:"state"},U.add(br);class Er{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=S.GC_MAX_IDLE,this.checkCountMax=S.GC_MAX_CHECK_COUNT,this.mode=S.GC_MODE}postrender(){!this.renderer.objectRenderer.renderingToScreen||(this.count++,this.mode!==bi.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let s=!1;for(let r=0;r<e.length;r++){const n=e[r];!n.framebuffer&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,s=!0)}if(s){let r=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[r++]=e[n]);e.length=r}}unload(t){const e=this.renderer.texture,s=t._texture;s&&!s.framebuffer&&e.destroyTexture(s);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}}Er.extension={type:P.RendererSystem,name:"textureGC"},U.add(Er);function Ad(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[O.UNSIGNED_BYTE]:{[C.RGBA]:i.RGBA8,[C.RGB]:i.RGB8,[C.RG]:i.RG8,[C.RED]:i.R8,[C.RGBA_INTEGER]:i.RGBA8UI,[C.RGB_INTEGER]:i.RGB8UI,[C.RG_INTEGER]:i.RG8UI,[C.RED_INTEGER]:i.R8UI,[C.ALPHA]:i.ALPHA,[C.LUMINANCE]:i.LUMINANCE,[C.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[O.BYTE]:{[C.RGBA]:i.RGBA8_SNORM,[C.RGB]:i.RGB8_SNORM,[C.RG]:i.RG8_SNORM,[C.RED]:i.R8_SNORM,[C.RGBA_INTEGER]:i.RGBA8I,[C.RGB_INTEGER]:i.RGB8I,[C.RG_INTEGER]:i.RG8I,[C.RED_INTEGER]:i.R8I},[O.UNSIGNED_SHORT]:{[C.RGBA_INTEGER]:i.RGBA16UI,[C.RGB_INTEGER]:i.RGB16UI,[C.RG_INTEGER]:i.RG16UI,[C.RED_INTEGER]:i.R16UI,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[O.SHORT]:{[C.RGBA_INTEGER]:i.RGBA16I,[C.RGB_INTEGER]:i.RGB16I,[C.RG_INTEGER]:i.RG16I,[C.RED_INTEGER]:i.R16I},[O.UNSIGNED_INT]:{[C.RGBA_INTEGER]:i.RGBA32UI,[C.RGB_INTEGER]:i.RGB32UI,[C.RG_INTEGER]:i.RG32UI,[C.RED_INTEGER]:i.R32UI,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[O.INT]:{[C.RGBA_INTEGER]:i.RGBA32I,[C.RGB_INTEGER]:i.RGB32I,[C.RG_INTEGER]:i.RG32I,[C.RED_INTEGER]:i.R32I},[O.FLOAT]:{[C.RGBA]:i.RGBA32F,[C.RGB]:i.RGB32F,[C.RG]:i.RG32F,[C.RED]:i.R32F,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[O.HALF_FLOAT]:{[C.RGBA]:i.RGBA16F,[C.RGB]:i.RGB16F,[C.RG]:i.RG16F,[C.RED]:i.R16F},[O.UNSIGNED_SHORT_5_6_5]:{[C.RGB]:i.RGB565},[O.UNSIGNED_SHORT_4_4_4_4]:{[C.RGBA]:i.RGBA4},[O.UNSIGNED_SHORT_5_5_5_1]:{[C.RGBA]:i.RGB5_A1},[O.UNSIGNED_INT_2_10_10_10_REV]:{[C.RGBA]:i.RGB10_A2,[C.RGBA_INTEGER]:i.RGB10_A2UI},[O.UNSIGNED_INT_10F_11F_11F_REV]:{[C.RGB]:i.R11F_G11F_B10F},[O.UNSIGNED_INT_5_9_9_9_REV]:{[C.RGB]:i.RGB9_E5},[O.UNSIGNED_INT_24_8]:{[C.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[O.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[C.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[O.UNSIGNED_BYTE]:{[C.RGBA]:i.RGBA,[C.RGB]:i.RGB,[C.ALPHA]:i.ALPHA,[C.LUMINANCE]:i.LUMINANCE,[C.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[O.UNSIGNED_SHORT_5_6_5]:{[C.RGB]:i.RGB},[O.UNSIGNED_SHORT_4_4_4_4]:{[C.RGBA]:i.RGBA},[O.UNSIGNED_SHORT_5_5_5_1]:{[C.RGBA]:i.RGBA}},t}class ji{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=O.UNSIGNED_BYTE,this.internalFormat=C.RGBA,this.samplerType=0}}class wr{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new W,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Ad(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const s=new ji(t.createTexture());t.bindTexture(t.TEXTURE_2D,s.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=s,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new ji(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:s}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(s.TEXTURE_2D,this.emptyTextures[s.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:s}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<s.length;r++)s[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<s.length;r++)s[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),s[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:s,CONTEXT_UID:r}=this;if(!!s)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[r].samplerType!==Ti.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new ji(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var s,r;e.internalFormat=(r=(s=this.internalFormats[t.type])==null?void 0:s[t.format])!=null?r:t.format,this.webGLVersion===2&&t.type===O.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var r;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const s=this.renderer;if(this.initTextureType(t,e),(r=t.resource)!=null&&r.upload(s,t,e))e.samplerType!==Ti.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=s.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:s}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),s.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const r=this.managedTextures.indexOf(t);r!==-1&&_e(this.managedTextures,r,1)}}updateTextureStyle(t){var s;const e=t._glTextures[this.CONTEXT_UID];!e||((t.mipmap===Pt.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Vt.CLAMP:e.wrapMode=t.wrapMode,(s=t.resource)!=null&&s.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const s=this.gl;if(e.mipmap&&t.mipmap!==Pt.ON_MANUAL&&s.generateMipmap(t.target),s.texParameteri(t.target,s.TEXTURE_WRAP_S,e.wrapMode),s.texParameteri(t.target,s.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR_MIPMAP_LINEAR:s.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===Xt.LINEAR){const n=Math.min(t.anisotropicLevel,s.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));s.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR:s.NEAREST);s.texParameteri(t.target,s.TEXTURE_MAG_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR:s.NEAREST)}destroy(){this.renderer=null}}wr.extension={type:P.RendererSystem,name:"texture"},U.add(wr);const Sd=new Xe;class Ar{constructor(t){this.renderer=t,this._tempMatrix=new et}generateTexture(t,e){const h=e||{},{region:s}=h,r=bs(h,["region"]),n=s||t.getLocalBounds(null,!0);n.width===0&&(n.width=1),n.height===0&&(n.height=1);const o=te.create(Ht({width:n.width,height:n.height},r));this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const a=t.transform;return t.transform=Sd,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=a,o}destroy(){}}Ar.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"textureGenerator"},U.add(Ar);class Sr{constructor(){this.clearBeforeRender=!0,this._backgroundColor=0,this._backgroundColorRgba=[0,0,0,1],this._backgroundColorString="#000000",this.color=this._backgroundColor,this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender,t.color&&(this.color=typeof t.color=="string"?Pi(t.color):t.color),this.alpha=t.alpha}get color(){return this._backgroundColor}set color(t){this._backgroundColor=t,this._backgroundColorString=Os(t),me(t,this._backgroundColorRgba)}get alpha(){return this._backgroundColorRgba[3]}set alpha(t){this._backgroundColorRgba[3]=t}get colorRgba(){return this._backgroundColorRgba}get colorString(){return this._backgroundColorString}destroy(){}}Sr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"background"},U.add(Sr);class Rr{constructor(t){this.renderer=t}init(t){this.screen=new V(0,0,t.width,t.height),this.element=t.view||S.ADAPTER.createCanvas(),this.resolution=t.resolution||S.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const s=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=s,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${s}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",s,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Rr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_view"},U.add(Rr);class Cr{constructor(t){this.renderer=t,this.plugins={}}init(t){for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Cr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_plugin"},U.add(Cr);class Do extends Re{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){var r;this.addRunners(...t.runners);const e=((r=t.priority)!=null?r:[]).filter(n=>t.systems[n]),s=[...e,...Object.keys(t.systems).filter(n=>!e.includes(n))];for(const n of s)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Tt(e)})}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}emitWithCustomOptions(t,e){const s=Object.keys(this._systemsHash);t.items.forEach(r=>{const n=s.find(o=>this._systemsHash[o]===r);r[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}class Ir{constructor(t){this.renderer=t}run(t){const e=this.renderer;e.emitWithCustomOptions(e.runners.init,t),t.hello&&console.log(`PixiJS 7.0.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(this.renderer.screen.width,this.renderer.screen.height)}destroy(){}}Ir.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"startup"},U.add(Ir);class Pr{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glTransformFeedbacks[s]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:s,renderer:r}=this;e&&r.shader.bind(e),s.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:s,CONTEXT_UID:r}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[r]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];!a||(s.buffer.update(a),a._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const s=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(a,e))}!s||(e||r.deleteTransformFeedback(s),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Pr.extension={type:P.RendererSystem,name:"transformFeedback"},U.add(Pr);const No=[];U.handleByList(P.Renderer,No);function Fo(i){for(const t of No)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var Rd=`attribute vec2 aVertexPosition;
418
+ `))}}class pd{}class Mo{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function md(i,t){const e={},s=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES);for(let r=0;r<s;r++){const n=t.getActiveAttrib(i,r);if(n.name.startsWith("gl_"))continue;const o=yo(t,n.type),a={type:o,name:n.name,size:xo(o),location:t.getAttribLocation(i,n.name)};e[n.name]=a}return e}function _d(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=yo(t,n.type);e[o]={name:o,index:r,type:h,size:n.size,isArray:a,value:po(h,n.size)}}return e}function Bo(i,t){var h;const e=uo(i,i.VERTEX_SHADER,t.vertexSrc),s=uo(i,i.FRAGMENT_SHADER,t.fragmentSrc),r=i.createProgram();i.attachShader(r,e),i.attachShader(r,s);const n=(h=t.extra)==null?void 0:h.transformFeedbackVaryings;if(n&&(typeof i.transformFeedbackVaryings!="function"||i.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?i.SEPARATE_ATTRIBS:i.INTERLEAVED_ATTRIBS)),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS)||Ku(i,r,e,s),t.attributeData=md(r,i),t.uniformData=_d(r,i),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((c,u)=>c>u?1:-1);for(let c=0;c<l.length;c++)t.attributeData[l[c]].location=c,i.bindAttribLocation(r,c,l[c]);i.linkProgram(r)}i.deleteShader(e),i.deleteShader(s);const o={};for(const l in t.uniformData){const c=t.uniformData[l];o[l]={location:i.getUniformLocation(r,l),value:po(c.type,c.size)}}return new Mo(r,o)}let gd=0;const Wi={textureCount:0,uboCount:0};class yr{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=gd++}systemCheck(){if(!rd())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const s=t.program,r=s.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==s&&(this.program=s,this.gl.useProgram(r.program)),e||(Wi.textureCount=0,Wi.uboCount=0,this.syncUniformGroup(t.uniformGroup,Wi)),r}setUniforms(t){const e=this.shader.program,s=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(s.uniformData,t,this.renderer)}syncUniformGroup(t,e){const s=this.getGlProgram();(!t.static||t.dirtyId!==s.uniformDirtyGroups[t.id])&&(s.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,s,e))}syncUniforms(t,e,s){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,s)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=ed(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const s=this.getGlProgram();if(!t.static||t.dirtyId!==0||!s.uniformGroups[t.id]){t.dirtyId=0;const r=s.uniformGroups[t.id]||this.createSyncBufferGroup(t,s,e);t.buffer.update(),r(s.uniformData,t.uniforms,this.renderer,Wi,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,s.uniformBufferBindings[e])}createSyncBufferGroup(t,e,s){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,s);e.uniformBufferBindings[s]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=Po(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(a.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}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("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,s=t.program,r=Bo(e,s);return s.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}yr.extension={type:P.RendererSystem,name:"shader"},U.add(yr);function xd(i,t=[]){return t[k.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.ADD]=[i.ONE,i.ONE],t[k.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.NONE]=[0,0],t[k.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[k.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[k.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[k.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[k.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[k.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[k.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[k.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[k.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[k.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}const vd=0,yd=1,Td=2,bd=3,Ed=4,wd=5,Tr=class{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=k.NONE,this._blendEq=!1,this.map=[],this.map[vd]=this.setBlend,this.map[yd]=this.setOffset,this.map[Td]=this.setCullFace,this.map[bd]=this.setDepthTest,this.map[Ed]=this.setFrontFace,this.map[wd]=this.setDepthMask,this.checks=[],this.defaultState=new jt,this.defaultState.blend=!0}contextChange(i){this.gl=i,this.blendModes=xd(i),this.set(this.defaultState),this.reset()}set(i){if(i=i||this.defaultState,this.stateId!==i.data){let t=this.stateId^i.data,e=0;for(;t;)t&1&&this.map[e].call(this,!!(i.data&1<<e)),t=t>>1,e++;this.stateId=i.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,i)}forceState(i){i=i||this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(i.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,i);this.stateId=i.data}setBlend(i){this.updateCheck(Tr.checkBlendMode,i),this.gl[i?"enable":"disable"](this.gl.BLEND)}setOffset(i){this.updateCheck(Tr.checkPolygonOffset,i),this.gl[i?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(i){this.gl[i?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(i){this.gl.depthMask(i)}setCullFace(i){this.gl[i?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(i){this.gl.frontFace(this.gl[i?"CW":"CCW"])}setBlendMode(i){if(i===this.blendMode)return;this.blendMode=i;const t=this.blendModes[i],e=this.gl;t.length===2?e.blendFunc(t[0],t[1]):e.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,e.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD))}setPolygonOffset(i,t){this.gl.polygonOffset(i,t)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(i,t){const e=this.checks.indexOf(i);t&&e===-1?this.checks.push(i):!t&&e!==-1&&this.checks.splice(e,1)}static checkBlendMode(i,t){i.setBlendMode(t.blendMode)}static checkPolygonOffset(i,t){i.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null}};let br=Tr;br.extension={type:P.RendererSystem,name:"state"},U.add(br);class Er{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=S.GC_MAX_IDLE,this.checkCountMax=S.GC_MAX_CHECK_COUNT,this.mode=S.GC_MODE}postrender(){!this.renderer.objectRenderer.renderingToScreen||(this.count++,this.mode!==bi.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let s=!1;for(let r=0;r<e.length;r++){const n=e[r];!n.framebuffer&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,s=!0)}if(s){let r=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[r++]=e[n]);e.length=r}}unload(t){const e=this.renderer.texture,s=t._texture;s&&!s.framebuffer&&e.destroyTexture(s);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}}Er.extension={type:P.RendererSystem,name:"textureGC"},U.add(Er);function Ad(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[O.UNSIGNED_BYTE]:{[C.RGBA]:i.RGBA8,[C.RGB]:i.RGB8,[C.RG]:i.RG8,[C.RED]:i.R8,[C.RGBA_INTEGER]:i.RGBA8UI,[C.RGB_INTEGER]:i.RGB8UI,[C.RG_INTEGER]:i.RG8UI,[C.RED_INTEGER]:i.R8UI,[C.ALPHA]:i.ALPHA,[C.LUMINANCE]:i.LUMINANCE,[C.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[O.BYTE]:{[C.RGBA]:i.RGBA8_SNORM,[C.RGB]:i.RGB8_SNORM,[C.RG]:i.RG8_SNORM,[C.RED]:i.R8_SNORM,[C.RGBA_INTEGER]:i.RGBA8I,[C.RGB_INTEGER]:i.RGB8I,[C.RG_INTEGER]:i.RG8I,[C.RED_INTEGER]:i.R8I},[O.UNSIGNED_SHORT]:{[C.RGBA_INTEGER]:i.RGBA16UI,[C.RGB_INTEGER]:i.RGB16UI,[C.RG_INTEGER]:i.RG16UI,[C.RED_INTEGER]:i.R16UI,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[O.SHORT]:{[C.RGBA_INTEGER]:i.RGBA16I,[C.RGB_INTEGER]:i.RGB16I,[C.RG_INTEGER]:i.RG16I,[C.RED_INTEGER]:i.R16I},[O.UNSIGNED_INT]:{[C.RGBA_INTEGER]:i.RGBA32UI,[C.RGB_INTEGER]:i.RGB32UI,[C.RG_INTEGER]:i.RG32UI,[C.RED_INTEGER]:i.R32UI,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[O.INT]:{[C.RGBA_INTEGER]:i.RGBA32I,[C.RGB_INTEGER]:i.RGB32I,[C.RG_INTEGER]:i.RG32I,[C.RED_INTEGER]:i.R32I},[O.FLOAT]:{[C.RGBA]:i.RGBA32F,[C.RGB]:i.RGB32F,[C.RG]:i.RG32F,[C.RED]:i.R32F,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[O.HALF_FLOAT]:{[C.RGBA]:i.RGBA16F,[C.RGB]:i.RGB16F,[C.RG]:i.RG16F,[C.RED]:i.R16F},[O.UNSIGNED_SHORT_5_6_5]:{[C.RGB]:i.RGB565},[O.UNSIGNED_SHORT_4_4_4_4]:{[C.RGBA]:i.RGBA4},[O.UNSIGNED_SHORT_5_5_5_1]:{[C.RGBA]:i.RGB5_A1},[O.UNSIGNED_INT_2_10_10_10_REV]:{[C.RGBA]:i.RGB10_A2,[C.RGBA_INTEGER]:i.RGB10_A2UI},[O.UNSIGNED_INT_10F_11F_11F_REV]:{[C.RGB]:i.R11F_G11F_B10F},[O.UNSIGNED_INT_5_9_9_9_REV]:{[C.RGB]:i.RGB9_E5},[O.UNSIGNED_INT_24_8]:{[C.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[O.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[C.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[O.UNSIGNED_BYTE]:{[C.RGBA]:i.RGBA,[C.RGB]:i.RGB,[C.ALPHA]:i.ALPHA,[C.LUMINANCE]:i.LUMINANCE,[C.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[O.UNSIGNED_SHORT_5_6_5]:{[C.RGB]:i.RGB},[O.UNSIGNED_SHORT_4_4_4_4]:{[C.RGBA]:i.RGBA},[O.UNSIGNED_SHORT_5_5_5_1]:{[C.RGBA]:i.RGBA}},t}class ji{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=O.UNSIGNED_BYTE,this.internalFormat=C.RGBA,this.samplerType=0}}class wr{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new W,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Ad(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const s=new ji(t.createTexture());t.bindTexture(t.TEXTURE_2D,s.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=s,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new ji(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:s}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(s.TEXTURE_2D,this.emptyTextures[s.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:s}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<s.length;r++)s[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<s.length;r++)s[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),s[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:s,CONTEXT_UID:r}=this;if(!!s)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[r].samplerType!==Ti.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new ji(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var s,r;e.internalFormat=(r=(s=this.internalFormats[t.type])==null?void 0:s[t.format])!=null?r:t.format,this.webGLVersion===2&&t.type===O.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var r;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const s=this.renderer;if(this.initTextureType(t,e),(r=t.resource)!=null&&r.upload(s,t,e))e.samplerType!==Ti.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=s.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:s}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),s.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const r=this.managedTextures.indexOf(t);r!==-1&&_e(this.managedTextures,r,1)}}updateTextureStyle(t){var s;const e=t._glTextures[this.CONTEXT_UID];!e||((t.mipmap===Pt.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Vt.CLAMP:e.wrapMode=t.wrapMode,(s=t.resource)!=null&&s.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const s=this.gl;if(e.mipmap&&t.mipmap!==Pt.ON_MANUAL&&s.generateMipmap(t.target),s.texParameteri(t.target,s.TEXTURE_WRAP_S,e.wrapMode),s.texParameteri(t.target,s.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR_MIPMAP_LINEAR:s.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===Xt.LINEAR){const n=Math.min(t.anisotropicLevel,s.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));s.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR:s.NEAREST);s.texParameteri(t.target,s.TEXTURE_MAG_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR:s.NEAREST)}destroy(){this.renderer=null}}wr.extension={type:P.RendererSystem,name:"texture"},U.add(wr);const Sd=new Xe;class Ar{constructor(t){this.renderer=t,this._tempMatrix=new et}generateTexture(t,e){const h=e||{},{region:s}=h,r=bs(h,["region"]),n=s||t.getLocalBounds(null,!0);n.width===0&&(n.width=1),n.height===0&&(n.height=1);const o=te.create(Ht({width:n.width,height:n.height},r));this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const a=t.transform;return t.transform=Sd,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=a,o}destroy(){}}Ar.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"textureGenerator"},U.add(Ar);class Sr{constructor(){this.clearBeforeRender=!0,this._backgroundColor=0,this._backgroundColorRgba=[0,0,0,1],this._backgroundColorString="#000000",this.color=this._backgroundColor,this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender,t.color&&(this.color=typeof t.color=="string"?Pi(t.color):t.color),this.alpha=t.alpha}get color(){return this._backgroundColor}set color(t){this._backgroundColor=t,this._backgroundColorString=Os(t),me(t,this._backgroundColorRgba)}get alpha(){return this._backgroundColorRgba[3]}set alpha(t){this._backgroundColorRgba[3]=t}get colorRgba(){return this._backgroundColorRgba}get colorString(){return this._backgroundColorString}destroy(){}}Sr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"background"},U.add(Sr);class Rr{constructor(t){this.renderer=t}init(t){this.screen=new V(0,0,t.width,t.height),this.element=t.view||S.ADAPTER.createCanvas(),this.resolution=t.resolution||S.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const s=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=s,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${s}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",s,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Rr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_view"},U.add(Rr);class Cr{constructor(t){this.renderer=t,this.plugins={}}init(t){for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Cr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_plugin"},U.add(Cr);class Do extends Re{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){var r;this.addRunners(...t.runners);const e=((r=t.priority)!=null?r:[]).filter(n=>t.systems[n]),s=[...e,...Object.keys(t.systems).filter(n=>!e.includes(n))];for(const n of s)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Tt(e)})}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}emitWithCustomOptions(t,e){const s=Object.keys(this._systemsHash);t.items.forEach(r=>{const n=s.find(o=>this._systemsHash[o]===r);r[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}class Ir{constructor(t){this.renderer=t}run(t){const e=this.renderer;e.emitWithCustomOptions(e.runners.init,t),t.hello&&console.log(`PixiJS 7.0.4 - ${e.rendererLogId} - https://pixijs.com`),e.resize(this.renderer.screen.width,this.renderer.screen.height)}destroy(){}}Ir.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"startup"},U.add(Ir);class Pr{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glTransformFeedbacks[s]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:s,renderer:r}=this;e&&r.shader.bind(e),s.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:s,CONTEXT_UID:r}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[r]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];!a||(s.buffer.update(a),a._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const s=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(a,e))}!s||(e||r.deleteTransformFeedback(s),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Pr.extension={type:P.RendererSystem,name:"transformFeedback"},U.add(Pr);const No=[];U.handleByList(P.Renderer,No);function Fo(i){for(const t of No)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var Rd=`attribute vec2 aVertexPosition;
419
419
  attribute vec2 aTextureCoord;
420
420
 
421
421
  uniform mat3 projectionMatrix;
@@ -491,7 +491,7 @@ void main(void){
491
491
  %forloop%
492
492
  gl_FragColor = color * vColor;
493
493
  }
494
- `;const Te=class extends Ze{constructor(i){super(i),this.setShaderGenerator(),this.geometryClass=Dr,this.vertexSize=6,this.state=jt.for2d(),this.size=S.SPRITE_BATCH_SIZE*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.MAX_TEXTURES=1,this.renderer.on("prerender",this.onPrerender,this),i.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultVertexSrc(){return Id}static get defaultFragmentTemplate(){return Pd}setShaderGenerator({vertex:i=Te.defaultVertexSrc,fragment:t=Te.defaultFragmentTemplate}={}){this.shaderGenerator=new Uo(i,t)}contextChange(){const i=this.renderer.gl;S.PREFER_ENV===se.WEBGL_LEGACY?this.MAX_TEXTURES=1:(this.MAX_TEXTURES=Math.min(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),S.SPRITE_MAX_TEXTURES),this.MAX_TEXTURES=To(this.MAX_TEXTURES,i)),this._shader=this.shaderGenerator.generateShader(this.MAX_TEXTURES);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:i,_textureArrayPool:t}=Te,e=this.size/4,s=Math.floor(e/this.MAX_TEXTURES)+1;for(;i.length<e;)i.push(new Yi);for(;t.length<s;)t.push(new $i);for(let r=0;r<this.MAX_TEXTURES;r++)this._tempBoundTextures[r]=null}onPrerender(){this._flushId=0}render(i){!i._texture.valid||(this._vertexCount+i.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=i.vertexData.length/2,this._indexCount+=i.indices.length,this._bufferedTextures[this._bufferSize]=i._texture.baseTexture,this._bufferedElements[this._bufferSize++]=i)}buildTexturesAndDrawCalls(){const{_bufferedTextures:i,MAX_TEXTURES:t}=this,e=Te._textureArrayPool,s=this.renderer.batch,r=this._tempBoundTextures,n=this.renderer.textureGC.count;let o=++W._globalBatch,a=0,h=e[0],l=0;s.copyBoundTextures(r,t);for(let c=0;c<this._bufferSize;++c){const u=i[c];i[c]=null,u._batchEnabled!==o&&(h.count>=t&&(s.boundArray(h,r,o,t),this.buildDrawCalls(h,l,c),l=c,h=e[++a],++o),u._batchEnabled=o,u.touched=n,h.elements[h.count++]=u)}h.count>0&&(s.boundArray(h,r,o,t),this.buildDrawCalls(h,l,this._bufferSize),++a,++o);for(let c=0;c<r.length;c++)r[c]=null;W._globalBatch=o}buildDrawCalls(i,t,e){const{_bufferedElements:s,_attributeBuffer:r,_indexBuffer:n,vertexSize:o}=this,a=Te._drawCallPool;let h=this._dcIndex,l=this._aIndex,c=this._iIndex,u=a[h];u.start=this._iIndex,u.texArray=i;for(let d=t;d<e;++d){const f=s[d],p=f._texture.baseTexture,m=ks[p.alphaMode?1:0][f.blendMode];s[d]=null,t<d&&u.blend!==m&&(u.size=c-u.start,t=d,u=a[++h],u.texArray=i,u.start=c),this.packInterleavedGeometry(f,r,n,l,c),l+=f.vertexData.length/2*o,c+=f.indices.length,u.blend=m}t<e&&(u.size=c-u.start,++h),this._dcIndex=h,this._aIndex=l,this._iIndex=c}bindAndClearTexArray(i){const t=this.renderer.texture;for(let e=0;e<i.count;e++)t.bind(i.elements[e],i.ids[e]),i.elements[e]=null;i.count=0}updateGeometry(){const{_packedGeometries:i,_attributeBuffer:t,_indexBuffer:e}=this;S.CAN_UPLOAD_SAME_BUFFER?(i[this._flushId]._buffer.update(t.rawBinaryData),i[this._flushId]._indexBuffer.update(e),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,i[this._flushId]=new this.geometryClass),i[this._flushId]._buffer.update(t.rawBinaryData),i[this._flushId]._indexBuffer.update(e),this.renderer.geometry.bind(i[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const i=this._dcIndex,{gl:t,state:e}=this.renderer,s=Te._drawCallPool;let r=null;for(let n=0;n<i;n++){const{texArray:o,type:a,size:h,start:l,blend:c}=s[n];r!==o&&(r=o,this.bindAndClearTexArray(o)),this.state.blendMode=c,e.set(this.state),t.drawElements(a,h,t.UNSIGNED_SHORT,l*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.MAX_TEXTURES),this.renderer.shader.bind(this._shader),S.CAN_UPLOAD_SAME_BUFFER&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let i=0;i<this._packedGeometryPoolSize;i++)this._packedGeometries[i]&&this._packedGeometries[i].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(i){const t=$e(Math.ceil(i/8)),e=Vs(t),s=t*8;this._aBuffers.length<=e&&(this._iBuffers.length=e+1);let r=this._aBuffers[s];return r||(this._aBuffers[s]=r=new qi(s*this.vertexSize*4)),r}getIndexBuffer(i){const t=$e(Math.ceil(i/12)),e=Vs(t),s=t*12;this._iBuffers.length<=e&&(this._iBuffers.length=e+1);let r=this._iBuffers[e];return r||(this._iBuffers[e]=r=new Uint16Array(s)),r}packInterleavedGeometry(i,t,e,s,r){const{uint32View:n,float32View:o}=t,a=s/this.vertexSize,h=i.uvs,l=i.indices,c=i.vertexData,u=i._texture.baseTexture._batchLocation,d=Math.min(i.worldAlpha,1),f=d<1&&i._texture.baseTexture.alphaMode?Mi(i._tintRGB,d):i._tintRGB+(d*255<<24);for(let p=0;p<c.length;p+=2)o[s++]=c[p],o[s++]=c[p+1],o[s++]=h[p],o[s++]=h[p+1],n[s++]=f,o[s++]=u;for(let p=0;p<l.length;p++)e[r++]=a+l[p]}};let ti=Te;ti.extension={name:"batch",type:P.RendererPlugin},ti._drawCallPool=[],ti._textureArrayPool=[],U.add(ti);class Md{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new Tt("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}class Bd{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Nr{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:s,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,s){const{gl:r,CONTEXT_UID:n}=this;s=s||0;const o=t._glBuffers[n]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,o.buffer,s*256,256)}update(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const s=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),s&&(e||r.deleteBuffer(s.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let s=0;s<e.length;s++)this.dispose(this.managedBuffers[e[s]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:s}=this;return t._glBuffers[e]=new Bd(s.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Nr.extension={type:P.RendererSystem,name:"buffer"},U.add(Nr);class Fr{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const s=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,s)}else{const s=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,s)}e>=nt.HIGH?this.multisample=nt.HIGH:e>=nt.MEDIUM?this.multisample=nt.MEDIUM:e>=nt.LOW?this.multisample=nt.LOW:this.multisample=nt.NONE}destroy(){}}Fr.extension={type:P.RendererSystem,name:"_multisample"},U.add(Fr);class Lr{constructor(t){this.renderer=t}render(t,e){const s=this.renderer;let r,n,o,a;if(e&&(r=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!r,s.runners.prerender.emit(),s.emit("prerender"),s.projection.transform=o,!s.context.isLost){if(r||(this.lastObjectRendered=t),!a){const h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}s.renderTexture.bind(r),s.batch.currentRenderer.start(),(n!=null?n:s.background.clearBeforeRender)&&s.renderTexture.clear(),t.render(s),s.batch.currentRenderer.flush(),r&&(e.blit&&s.framebuffer.blit(),r.baseTexture.update()),s.runners.postrender.emit(),s.projection.transform=null,s.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Lr.extension={type:P.RendererSystem,name:"objectRenderer"},U.add(Lr);const Dd="7.0.2";var Nd=`varying vec2 vTextureCoord;
494
+ `;const Te=class extends Ze{constructor(i){super(i),this.setShaderGenerator(),this.geometryClass=Dr,this.vertexSize=6,this.state=jt.for2d(),this.size=S.SPRITE_BATCH_SIZE*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.MAX_TEXTURES=1,this.renderer.on("prerender",this.onPrerender,this),i.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultVertexSrc(){return Id}static get defaultFragmentTemplate(){return Pd}setShaderGenerator({vertex:i=Te.defaultVertexSrc,fragment:t=Te.defaultFragmentTemplate}={}){this.shaderGenerator=new Uo(i,t)}contextChange(){const i=this.renderer.gl;S.PREFER_ENV===se.WEBGL_LEGACY?this.MAX_TEXTURES=1:(this.MAX_TEXTURES=Math.min(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),S.SPRITE_MAX_TEXTURES),this.MAX_TEXTURES=To(this.MAX_TEXTURES,i)),this._shader=this.shaderGenerator.generateShader(this.MAX_TEXTURES);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:i,_textureArrayPool:t}=Te,e=this.size/4,s=Math.floor(e/this.MAX_TEXTURES)+1;for(;i.length<e;)i.push(new Yi);for(;t.length<s;)t.push(new $i);for(let r=0;r<this.MAX_TEXTURES;r++)this._tempBoundTextures[r]=null}onPrerender(){this._flushId=0}render(i){!i._texture.valid||(this._vertexCount+i.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=i.vertexData.length/2,this._indexCount+=i.indices.length,this._bufferedTextures[this._bufferSize]=i._texture.baseTexture,this._bufferedElements[this._bufferSize++]=i)}buildTexturesAndDrawCalls(){const{_bufferedTextures:i,MAX_TEXTURES:t}=this,e=Te._textureArrayPool,s=this.renderer.batch,r=this._tempBoundTextures,n=this.renderer.textureGC.count;let o=++W._globalBatch,a=0,h=e[0],l=0;s.copyBoundTextures(r,t);for(let c=0;c<this._bufferSize;++c){const u=i[c];i[c]=null,u._batchEnabled!==o&&(h.count>=t&&(s.boundArray(h,r,o,t),this.buildDrawCalls(h,l,c),l=c,h=e[++a],++o),u._batchEnabled=o,u.touched=n,h.elements[h.count++]=u)}h.count>0&&(s.boundArray(h,r,o,t),this.buildDrawCalls(h,l,this._bufferSize),++a,++o);for(let c=0;c<r.length;c++)r[c]=null;W._globalBatch=o}buildDrawCalls(i,t,e){const{_bufferedElements:s,_attributeBuffer:r,_indexBuffer:n,vertexSize:o}=this,a=Te._drawCallPool;let h=this._dcIndex,l=this._aIndex,c=this._iIndex,u=a[h];u.start=this._iIndex,u.texArray=i;for(let d=t;d<e;++d){const f=s[d],p=f._texture.baseTexture,m=ks[p.alphaMode?1:0][f.blendMode];s[d]=null,t<d&&u.blend!==m&&(u.size=c-u.start,t=d,u=a[++h],u.texArray=i,u.start=c),this.packInterleavedGeometry(f,r,n,l,c),l+=f.vertexData.length/2*o,c+=f.indices.length,u.blend=m}t<e&&(u.size=c-u.start,++h),this._dcIndex=h,this._aIndex=l,this._iIndex=c}bindAndClearTexArray(i){const t=this.renderer.texture;for(let e=0;e<i.count;e++)t.bind(i.elements[e],i.ids[e]),i.elements[e]=null;i.count=0}updateGeometry(){const{_packedGeometries:i,_attributeBuffer:t,_indexBuffer:e}=this;S.CAN_UPLOAD_SAME_BUFFER?(i[this._flushId]._buffer.update(t.rawBinaryData),i[this._flushId]._indexBuffer.update(e),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,i[this._flushId]=new this.geometryClass),i[this._flushId]._buffer.update(t.rawBinaryData),i[this._flushId]._indexBuffer.update(e),this.renderer.geometry.bind(i[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const i=this._dcIndex,{gl:t,state:e}=this.renderer,s=Te._drawCallPool;let r=null;for(let n=0;n<i;n++){const{texArray:o,type:a,size:h,start:l,blend:c}=s[n];r!==o&&(r=o,this.bindAndClearTexArray(o)),this.state.blendMode=c,e.set(this.state),t.drawElements(a,h,t.UNSIGNED_SHORT,l*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.MAX_TEXTURES),this.renderer.shader.bind(this._shader),S.CAN_UPLOAD_SAME_BUFFER&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let i=0;i<this._packedGeometryPoolSize;i++)this._packedGeometries[i]&&this._packedGeometries[i].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(i){const t=$e(Math.ceil(i/8)),e=Vs(t),s=t*8;this._aBuffers.length<=e&&(this._iBuffers.length=e+1);let r=this._aBuffers[s];return r||(this._aBuffers[s]=r=new qi(s*this.vertexSize*4)),r}getIndexBuffer(i){const t=$e(Math.ceil(i/12)),e=Vs(t),s=t*12;this._iBuffers.length<=e&&(this._iBuffers.length=e+1);let r=this._iBuffers[e];return r||(this._iBuffers[e]=r=new Uint16Array(s)),r}packInterleavedGeometry(i,t,e,s,r){const{uint32View:n,float32View:o}=t,a=s/this.vertexSize,h=i.uvs,l=i.indices,c=i.vertexData,u=i._texture.baseTexture._batchLocation,d=Math.min(i.worldAlpha,1),f=d<1&&i._texture.baseTexture.alphaMode?Mi(i._tintRGB,d):i._tintRGB+(d*255<<24);for(let p=0;p<c.length;p+=2)o[s++]=c[p],o[s++]=c[p+1],o[s++]=h[p],o[s++]=h[p+1],n[s++]=f,o[s++]=u;for(let p=0;p<l.length;p++)e[r++]=a+l[p]}};let ti=Te;ti.extension={name:"batch",type:P.RendererPlugin},ti._drawCallPool=[],ti._textureArrayPool=[],U.add(ti);class Md{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new Tt("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}class Bd{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Nr{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:s,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,s){const{gl:r,CONTEXT_UID:n}=this;s=s||0;const o=t._glBuffers[n]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,o.buffer,s*256,256)}update(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const s=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),s&&(e||r.deleteBuffer(s.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let s=0;s<e.length;s++)this.dispose(this.managedBuffers[e[s]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:s}=this;return t._glBuffers[e]=new Bd(s.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Nr.extension={type:P.RendererSystem,name:"buffer"},U.add(Nr);class Fr{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const s=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,s)}else{const s=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,s)}e>=nt.HIGH?this.multisample=nt.HIGH:e>=nt.MEDIUM?this.multisample=nt.MEDIUM:e>=nt.LOW?this.multisample=nt.LOW:this.multisample=nt.NONE}destroy(){}}Fr.extension={type:P.RendererSystem,name:"_multisample"},U.add(Fr);class Lr{constructor(t){this.renderer=t}render(t,e){const s=this.renderer;let r,n,o,a;if(e&&(r=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!r,s.runners.prerender.emit(),s.emit("prerender"),s.projection.transform=o,!s.context.isLost){if(r||(this.lastObjectRendered=t),!a){const h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}s.renderTexture.bind(r),s.batch.currentRenderer.start(),(n!=null?n:s.background.clearBeforeRender)&&s.renderTexture.clear(),t.render(s),s.batch.currentRenderer.flush(),r&&(e.blit&&s.framebuffer.blit(),r.baseTexture.update()),s.runners.postrender.emit(),s.projection.transform=null,s.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Lr.extension={type:P.RendererSystem,name:"objectRenderer"},U.add(Lr);const Dd="7.0.4";var Nd=`varying vec2 vTextureCoord;
495
495
 
496
496
  uniform sampler2D uSampler;
497
497
  uniform float uAlpha;
@@ -831,7 +831,7 @@ void main()
831
831
 
832
832
  gl_FragColor = color;
833
833
  }
834
- `;class Kd extends Rt{constructor(t=.5,e=Math.random()){super(Mr,qd,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}S.SORTABLE_CHILDREN=!1;class ei{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?V.EMPTY:(t=t||new V(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:s,b:r,c:n,d:o,tx:a,ty:h}=t,l=s*e.x+n*e.y+a,c=r*e.x+o*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,s=this.minY,r=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,this.minX=e,this.minY=s,this.maxX=r,this.maxY=n}addFrame(t,e,s,r,n){this.addFrameMatrix(t.worldTransform,e,s,r,n)}addFrameMatrix(t,e,s,r,n){const o=t.a,a=t.b,h=t.c,l=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,_=o*e+h*s+c,x=a*e+l*s+u;d=_<d?_:d,f=x<f?x:f,p=_>p?_:p,m=x>m?x:m,_=o*r+h*s+c,x=a*r+l*s+u,d=_<d?_:d,f=x<f?x:f,p=_>p?_:p,m=x>m?x:m,_=o*e+h*n+c,x=a*e+l*n+u,d=_<d?_:d,f=x<f?x:f,p=_>p?_:p,m=x>m?x:m,_=o*r+h*n+c,x=a*r+l*n+u,d=_<d?_:d,f=x<f?x:f,p=_>p?_:p,m=x>m?x:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,s){let r=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let h=e;h<s;h+=2){const l=t[h],c=t[h+1];r=l<r?l:r,n=c<n?c:n,o=l>o?l:o,a=c>a?c:a}this.minX=r,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,s,r){this.addVerticesMatrix(t.worldTransform,e,s,r)}addVerticesMatrix(t,e,s,r,n=0,o=n){const a=t.a,h=t.b,l=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,_=this.maxY;for(let x=s;x<r;x+=2){const y=e[x],g=e[x+1],v=a*y+l*g+u,b=c*g+h*y+d;f=Math.min(f,v-n),m=Math.max(m,v+n),p=Math.min(p,b-o),_=Math.max(_,b+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=_}addBounds(t){const e=this.minX,s=this.minY,r=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<s?t.minY:s,this.maxX=t.maxX>r?t.maxX:r,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const s=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(s<=n&&r<=o){const a=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=s<a?s:a,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const s=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(s<=n&&r<=o){const a=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=s<a?s:a,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,s,r,n,o){t-=n,e-=o,s+=n,r+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>s?this.maxX:s,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>r?this.maxY:r}}class tt extends Re{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Xe,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new ei,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let s=0;s<e.length;++s){const r=e[s];Object.defineProperty(tt.prototype,r,Object.getOwnPropertyDescriptor(t,r))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new V),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new V),t=this._localBoundsRect),this._localBounds||(this._localBounds=new ei);const e=this.transform,s=this.parent;this.parent=null,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=s,this.transform=e,this._bounds=r,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,s=!1){return s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,s,r){return e&&(t=e.toGlobal(t,s,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,s)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,s=1,r=1,n=0,o=0,a=0,h=0,l=0){return this.position.x=t,this.position.y=e,this.scale.x=s||1,this.scale.y=r||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=h,this.pivot.y=l,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.interactive=!1,this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new Oo),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*Dn}set angle(t){this.transform.rotation=t*Nn}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex=t,this.parent&&(this.parent.sortDirty=!0)}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class Oo extends tt{constructor(){super(...arguments),this.sortDirty=null}}tt.prototype.displayObjectUpdateTransform=tt.prototype.updateTransform;function Zd(i,t){return i.zIndex===t.zIndex?i._lastSortedIndex-t._lastSortedIndex:i.zIndex-t.zIndex}class bt extends tt{constructor(){super(),this.children=[],this.sortableChildren=S.SORTABLE_CHILDREN,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const s=this.getChildIndex(t),r=this.getChildIndex(e);this.children[s]=e,this.children[r]=t,this.onChildrenChange(s<r?s:r)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const s=this.getChildIndex(t);_e(this.children,s,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],s=this.children.indexOf(e);if(s===-1)return null;e.parent=null,e.transform._parentID=-1,_e(this.children,s,1),this._boundsID++,this.onChildrenChange(s),e.emit("removed",this),this.emit("childRemoved",e,this,s)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,_e(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const s=t,r=e,n=r-s;let o;if(n>0&&n<=r){o=this.children.splice(s,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,s=this.children.length;e<s;++e){const r=this.children[e];r._lastSortedIndex=e,!t&&r.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(Zd),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const s=this.children[t];s.visible&&s.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const s=e._mask.isMaskData?e._mask.maskObject:e._mask;s?(s.calculateBounds(),this._bounds.addBoundsMask(e._bounds,s._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const s=super.getLocalBounds(t);if(!e)for(let r=0,n=this.children.length;r<n;++r){const o=this.children[r];o.visible&&o.updateTransform()}return s}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let s,r;if(this.cullArea?(s=this.cullArea,r=this.worldTransform):this._render!==bt.prototype._render&&(s=this.getBounds(!0)),s&&e.intersects(s,r))this._render(t);else if(this.cullArea)return;for(let n=0,o=this.children.length;n<o;++n){const a=this.children[n],h=a.cullable;a.cullable=h||!this.cullArea,a.render(t),a.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||((e=this.filters)==null?void 0:e.length))this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let s=0,r=this.children.length;s<r;++s)this.children[s].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,s=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let h=0;h<e.length;h++)e[h].enabled&&this._enabledFilters.push(e[h])}const r=e&&((n=this._enabledFilters)==null?void 0:n.length)||s&&(!s.isMaskData||s.enabled&&(s.autoDetect||s.type!==ht.NONE));if(r&&t.batch.flush(),e&&((o=this._enabledFilters)==null?void 0:o.length)&&t.filter.push(this,this._enabledFilters),s&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let h=0,l=this.children.length;h<l;++h)this.children[h].render(t)}r&&t.batch.flush(),s&&t.mask.pop(this),e&&((a=this._enabledFilters)==null?void 0:a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,s=this.removeChildren(0,this.children.length);if(e)for(let r=0;r<s.length;++r)s[r].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}}bt.prototype.containerUpdateTransform=bt.prototype.updateTransform;const ii=new j,Qd=new Uint16Array([0,1,2,0,2,3]);class ae extends bt{constructor(t){super(),this._anchor=new Jt(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tint=null,this._tintRGB=null,this.tint=16777215,this.blendMode=k.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||B.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=Qd,this.pluginName="batch",this.isSprite=!0,this._roundPixels=S.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=ge(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=ge(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,s=e.a,r=e.b,n=e.c,o=e.d,a=e.tx,h=e.ty,l=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,m=0,_=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,_=c.y-d._y*u.height,m=_+c.height):(p=-d._x*u.width,f=p+u.width,_=-d._y*u.height,m=_+u.height),l[0]=s*p+n*_+a,l[1]=o*_+r*p+h,l[2]=s*f+n*_+a,l[3]=o*_+r*f+h,l[4]=s*f+n*m+a,l[5]=o*m+r*f+h,l[6]=s*p+n*m+a,l[7]=o*m+r*p+h,this._roundPixels){const x=S.RESOLUTION;for(let y=0;y<l.length;++y)l[y]=Math.round((l[y]*x|0)/x)}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,s=t.orig,r=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty,d=-r._x*s.width,f=d+s.width,p=-r._y*s.height,m=p+s.height;e[0]=o*d+h*p+c,e[1]=l*p+a*d+u,e[2]=o*f+h*p+c,e[3]=l*p+a*f+u,e[4]=o*f+h*m+c,e[5]=l*m+a*f+u,e[6]=o*d+h*m+c,e[7]=l*m+a*d+u}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new ei),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new V),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ii);const e=this._texture.orig.width,s=this._texture.orig.height,r=-e*this.anchor.x;let n=0;return ii.x>=r&&ii.x<r+e&&(n=-s*this.anchor.y,ii.y>=n&&ii.y<n+s)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!s)}this._texture=null}static from(t,e){const s=t instanceof B?t:B.from(t,e);return new ae(s)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=ge(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=ge(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tint}set tint(t){this._tint=t,this._tintRGB=(t>>16)+(t&65280)+((t&255)<<16)}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||B.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const ko=new et;tt.prototype._cacheAsBitmap=!1,tt.prototype._cacheData=null,tt.prototype._cacheAsBitmapResolution=null,tt.prototype._cacheAsBitmapMultisample=null;class Jd{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(tt.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(i){i!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(i){i!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(i){if(this._cacheAsBitmap===i)return;this._cacheAsBitmap=i;let t;i?(this._cacheData||(this._cacheData=new Jd),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),tt.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},tt.prototype._initCachedDisplayObject=function(t){var d,f,p;if((d=this._cacheData)!=null&&d.sprite)return;const e=this.alpha;this.alpha=1,t.batch.flush();const s=this.getLocalBounds(null,!0).clone();if((f=this.filters)!=null&&f.length){const m=this.filters[0].padding;s.pad(m)}s.ceil(S.RESOLUTION);const r=t.renderTexture.current,n=t.renderTexture.sourceFrame.clone(),o=t.renderTexture.destinationFrame.clone(),a=t.projection.transform,h=te.create({width:s.width,height:s.height,resolution:this.cacheAsBitmapResolution||t.resolution,multisample:(p=this.cacheAsBitmapMultisample)!=null?p:t.multisample}),l=`cacheAsBitmap_${ne()}`;this._cacheData.textureCacheId=l,W.addToCache(h.baseTexture,l),B.addToCache(h,l);const c=this.transform.localTransform.copyTo(ko).invert().translate(-s.x,-s.y);this.render=this._cacheData.originalRender,t.render(this,{renderTexture:h,clear:!0,transform:c,skipUpdateTransform:!1}),t.framebuffer.blit(),t.projection.transform=a,t.renderTexture.bind(r,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const u=new ae(h);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(s.x/s.width),u.anchor.y=-(s.y/s.height),u.alpha=e,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},tt.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},tt.prototype._initCachedDisplayObjectCanvas=function(t){var c;if((c=this._cacheData)!=null&&c.sprite)return;const e=this.getLocalBounds(null,!0),s=this.alpha;this.alpha=1;const r=t.canvasContext.activeContext,n=t._projTransform;e.ceil(S.RESOLUTION);const o=te.create({width:e.width,height:e.height}),a=`cacheAsBitmap_${ne()}`;this._cacheData.textureCacheId=a,W.addToCache(o.baseTexture,a),B.addToCache(o,a);const h=ko;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=e.x,h.ty-=e.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,{renderTexture:o,clear:!0,transform:h,skipUpdateTransform:!1}),t.canvasContext.activeContext=r,t._projTransform=n,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=s;const l=new ae(o);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-(e.x/e.width),l.anchor.y=-(e.y/e.height),l.alpha=s,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)},tt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},tt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},tt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,W.removeFromCache(this._cacheData.textureCacheId),B.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},tt.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},tt.prototype.name=null,bt.prototype.getChildByName=function(t,e){for(let s=0,r=this.children.length;s<r;s++)if(this.children[s].name===t)return this.children[s];if(e)for(let s=0,r=this.children.length;s<r;s++){const n=this.children[s];if(!n.getChildByName)continue;const o=n.getChildByName(t,!0);if(o)return o}return null},tt.prototype.getGlobalPosition=function(t=new j,e=!1){return this.parent?this.parent.toGlobal(this.position,t,e):(t.x=this.position.x,t.y=this.position.y),t};const Go={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};class ke{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ke.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new j,this.page=new j,this.AT_TARGET=1,this.BUBBLING_PHASE=2,this.CAPTURING_PHASE=3,this.NONE=0,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}}class si extends ke{constructor(){super(...arguments),this.client=new j,this.movement=new j,this.offset=new j,this.global=new j,this.screen=new j}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,s,r,n,o,a,h,l,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class St extends si{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 Ki extends si{constructor(){super(...arguments),this.DOM_DELTA_LINE=0,this.DOM_DELTA_PAGE=1,this.DOM_DELTA_PIXEL=2}}const tf=2048,ef=new j,kr=new j;class Ho{constructor(t){this.dispatch=new Re,this.moveOnAll=!1,this.mappingState={trackingData:{}},this.eventPool=new Map,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 console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){const s=this.hitTestRecursive(this.rootTarget,this.rootTarget.interactive,ef.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[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.rootTarget){t.eventPhase=t.BUBBLING_PHASE;const r=s.children;if(r)for(let n=0;n<r.length;n++)this.all(t,e,r[n]);t.currentTarget=s,this.notifyTarget(t,e)}propagationPath(t){const e=[t];for(let s=0;s<tf&&t!==this.rootTarget;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}hitTestRecursive(t,e,s,r,n){if(!t||!t.visible||n(t,s))return null;if(t.interactiveChildren&&t.children){const o=t.children;for(let a=o.length-1;a>=0;a--){const h=o[a],l=this.hitTestRecursive(h,e||h.interactive,s,r,n);if(l){if(l.length>0&&!l[l.length-1].parent)continue;return(l.length>0||t.interactive)&&l.push(t),l}}}return e&&r(t,s)?t.interactive?[t]:[]:null}hitPruneFn(t,e){var s;if(t.hitArea&&(t.worldTransform.applyInverse(e,kr),!t.hitArea.contains(kr.x,kr.y)))return!0;if(t._mask){const r=t._mask.isMaskData?t._mask.maskObject:t._mask;if(r&&!((s=r.containsPoint)!=null&&s.call(r,e)))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){e=e!=null?e:t.type;const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof St)){console.warn("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 a;if(!(t instanceof St)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t),s=e.pointerType==="mouse"||e.pointerType==="pen",r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.overTargets);if(r.overTargets&&n!==e.target){const h=t.type==="mousemove"?"mouseout":"pointerout",l=this.createPointerEvent(t,h,n);if(this.dispatchEvent(l,"pointerout"),s&&this.dispatchEvent(l,"mouseout"),!e.composedPath().includes(n)){const c=this.createPointerEvent(t,"pointerleave",n);for(c.eventPhase=c.AT_TARGET;c.target&&!e.composedPath().includes(c.target);)c.currentTarget=c.target,this.notifyTarget(c),s&&this.notifyTarget(c,"mouseleave"),c.target=c.target.parent;this.freeEvent(c)}this.freeEvent(l)}if(n!==e.target){const h=t.type==="mousemove"?"mouseover":"pointerover",l=this.clonePointerEvent(e,h);this.dispatchEvent(l,"pointerover"),s&&this.dispatchEvent(l,"mouseover");let c=n==null?void 0:n.parent;for(;c&&c!==this.rootTarget.parent&&c!==e.target;)c=c.parent;if(!c||c===this.rootTarget.parent){const d=this.clonePointerEvent(e,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==n&&d.target!==this.rootTarget.parent;)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseenter"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(l)}const o=this.moveOnAll?"all":"dispatchEvent";this[o](e,"pointermove"),e.pointerType==="touch"&&this[o](e,"touchmove"),s&&(this[o](e,"mousemove"),this.cursor=(a=e.target)==null?void 0:a.cursor),r.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof St)){console.warn("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 St)){console.warn("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 St)){console.warn("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];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"?this.dispatchEvent(a,"click"):a.pointerType==="touch"&&this.dispatchEvent(a,"tap"),this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof St)){console.warn("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 Ki)){console.warn("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){const r=this.allocateEvent(St);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=s!=null?s:this.hitTest(r.global.x,r.global.y),typeof e=="string"&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(Ki);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(St);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 St&&e instanceof St&&(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 si&&e instanceof si&&(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.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.fn.call(s.context,t);else for(let r=0,n=s.length;r<n&&!t.propagationImmediatelyStopped;r++)s[r].fn.call(s[r].context,t)}}const sf=1,rf={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class Gr{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Ho(null),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new St(null),this.rootWheelEvent=new Ki(null),this.cursorStyles={default:"inherit",pointer:"pointer"},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)}init(){const{view:t,resolution:e}=this.renderer;this.setTargetElement(t),this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=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)}onPointerDown(t){if(this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&t.pointerType==="touch")return;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.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&t.pointerType==="touch")return;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.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&t.pointerType==="touch")return;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.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&t.pointerType==="touch")return;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){const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;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;const t=this.domElement.style;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){let r;this.domElement.parentElement?r=this.domElement.getBoundingClientRect():r={x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0};const 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=="undefined"&&(n.button=0),typeof n.buttons=="undefined"&&(n.buttons=1),typeof n.isPrimary=="undefined"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width=="undefined"&&(n.width=n.radiusX||1),typeof n.height=="undefined"&&(n.height=n.radiusY||1),typeof n.tiltX=="undefined"&&(n.tiltX=0),typeof n.tiltY=="undefined"&&(n.tiltY=0),typeof n.pointerType=="undefined"&&(n.pointerType="touch"),typeof n.pointerId=="undefined"&&(n.pointerId=n.identifier||0),typeof n.pressure=="undefined"&&(n.pressure=n.force||.5),typeof n.twist=="undefined"&&(n.twist=0),typeof n.tangentialPressure=="undefined"&&(n.tangentialPressure=0),typeof n.layerX=="undefined"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY=="undefined"&&(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=="undefined"&&(s.isPrimary=!0),typeof s.width=="undefined"&&(s.width=1),typeof s.height=="undefined"&&(s.height=1),typeof s.tiltX=="undefined"&&(s.tiltX=0),typeof s.tiltY=="undefined"&&(s.tiltY=0),typeof s.pointerType=="undefined"&&(s.pointerType="mouse"),typeof s.pointerId=="undefined"&&(s.pointerId=sf),typeof s.pressure=="undefined"&&(s.pressure=.5),typeof s.twist=="undefined"&&(s.twist=0),typeof s.tangentialPressure=="undefined"&&(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.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,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=rf[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}}Gr.extension={name:"events",type:[P.RendererSystem,P.CanvasRendererSystem]},U.add(Gr);const Xo={interactive:!1,interactiveChildren:!0,hitArea:null,addEventListener(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.on(i,t,r)},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 ke))throw new Error("DisplayObject 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}};tt.mixin(Xo),tt.mixin(Go);const nf=9,Zi=100,of=0,af=0,Vo=2,zo=1,hf=-1e3,lf=-1e3,cf=2;class Hr{constructor(t){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,(Dt.tablet||Dt.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Zi}px`,e.style.height=`${Zi}px`,e.style.position="absolute",e.style.top=`${of}px`,e.style.left=`${af}px`,e.style.zIndex=Vo.toString(),this.div=e,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}createTouchHook(){const t=document.createElement("button");t.style.width=`${zo}px`,t.style.height=`${zo}px`,t.style.position="absolute",t.style.top=`${hf}px`,t.style.left=`${lf}px`,t.style.zIndex=cf.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.on("postrender",this.update,this),(t=this.renderer.view.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.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.interactive&&(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])}update(){const t=performance.now();if(Dt.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:s,width:r,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:h}=this.renderer,l=r/o*h,c=n/a*h;let u=this.div;u.style.left=`${e}px`,u.style.top=`${s}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,_e(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*l}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*l}px`,u.style.height=`${p.height*m.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*l}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*l}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}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=`${Zi}px`,e.style.height=`${Zi}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Vo.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=`displayObject ${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.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:s}=t.target,r=this.renderer.events.rootBoundary,n=Object.assign(new ke(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===nf&&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}}Hr.extension={name:"accessibility",type:[P.RendererPlugin,P.CanvasRendererPlugin]},U.add(Hr);const Xr=class{constructor(i){this.stage=new bt,i=Object.assign({forceCanvas:!1},i),this.renderer=Fo(i),Xr._plugins.forEach(t=>{t.init.call(this,i)})}render(){this.renderer.render(this.stage)}get view(){return this.renderer.view}get screen(){return this.renderer.screen}destroy(i,t){const e=Xr._plugins.slice(0);e.reverse(),e.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(i),this.renderer=null}};let Vr=Xr;Vr._plugins=[],U.handleByList(P.Application,Vr._plugins);class zr{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}}zr.extension=P.Application,U.add(zr);class uf{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 Wt=(i,t)=>(Array.isArray(i)||(i=[i]),t?i.map(e=>typeof e=="string"?t(e):e):i);function Wo(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?Wo(i.replace(s[e],a),t,e+1,s,r):r.push(i.replace(s[e],a))}}function jo(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)}),Wo(i,r,0,e,s)}else s.push(i);return s}const ri=i=>!Array.isArray(i);class df{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}set(t,e){const s=Wt(t);let r;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];if(h.test(e)){r=h.getCacheableAssets(s,e);break}}r||(r={},s.forEach(a=>{r[a]=e}));const n=Object.keys(r),o={cacheKeys:n,keys:s};if(s.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a),this._cache.set(a,r[a])}),e instanceof B){const a=e;s.forEach(h=>{a.baseTexture!==B.EMPTY.baseTexture&&W.addToCache(a.baseTexture,h),B.addToCache(a,h)})}}remove(t){if(this._cacheMap.get(t),!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const Ne=new df;class ff{constructor(){this._parsers=[],this.promiseCache={}}reset(){this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var n,o;let r=null;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];if(h.load&&((n=h.test)==null?void 0:n.call(h,t,e,this))){r=await h.load(t,e,this),s.parser=h;break}}if(!s.parser)return null;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];h.parse&&h.parse&&await((o=h.testParse)==null?void 0:o.call(h,r,e,this))&&(r=await h.parse(r,e,this)||r,s.parser=h)}return r})(),s}async load(t,e){let s=0;const r={},n=ri(t),o=Wt(t,l=>({src:l})),a=o.length,h=o.map(async l=>{const c=ft.toAbsolute(l.src);if(!r[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),r[l.src]=await this.promiseCache[c].promise,e&&e(++s/a)}catch(u){throw delete this.promiseCache[c],delete r[l.src],new Error(`[Loader.load] Failed to load ${c}.
834
+ `;class Kd extends Rt{constructor(t=.5,e=Math.random()){super(Mr,qd,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}S.SORTABLE_CHILDREN=!1;class ei{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?V.EMPTY:(t=t||new V(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:s,b:r,c:n,d:o,tx:a,ty:h}=t,l=s*e.x+n*e.y+a,c=r*e.x+o*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,s=this.minY,r=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,this.minX=e,this.minY=s,this.maxX=r,this.maxY=n}addFrame(t,e,s,r,n){this.addFrameMatrix(t.worldTransform,e,s,r,n)}addFrameMatrix(t,e,s,r,n){const o=t.a,a=t.b,h=t.c,l=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,_=o*e+h*s+c,x=a*e+l*s+u;d=_<d?_:d,f=x<f?x:f,p=_>p?_:p,m=x>m?x:m,_=o*r+h*s+c,x=a*r+l*s+u,d=_<d?_:d,f=x<f?x:f,p=_>p?_:p,m=x>m?x:m,_=o*e+h*n+c,x=a*e+l*n+u,d=_<d?_:d,f=x<f?x:f,p=_>p?_:p,m=x>m?x:m,_=o*r+h*n+c,x=a*r+l*n+u,d=_<d?_:d,f=x<f?x:f,p=_>p?_:p,m=x>m?x:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,s){let r=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let h=e;h<s;h+=2){const l=t[h],c=t[h+1];r=l<r?l:r,n=c<n?c:n,o=l>o?l:o,a=c>a?c:a}this.minX=r,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,s,r){this.addVerticesMatrix(t.worldTransform,e,s,r)}addVerticesMatrix(t,e,s,r,n=0,o=n){const a=t.a,h=t.b,l=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,_=this.maxY;for(let x=s;x<r;x+=2){const y=e[x],g=e[x+1],v=a*y+l*g+u,b=c*g+h*y+d;f=Math.min(f,v-n),m=Math.max(m,v+n),p=Math.min(p,b-o),_=Math.max(_,b+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=_}addBounds(t){const e=this.minX,s=this.minY,r=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<s?t.minY:s,this.maxX=t.maxX>r?t.maxX:r,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const s=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(s<=n&&r<=o){const a=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=s<a?s:a,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const s=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(s<=n&&r<=o){const a=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=s<a?s:a,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,s,r,n,o){t-=n,e-=o,s+=n,r+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>s?this.maxX:s,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>r?this.maxY:r}}class tt extends Re{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Xe,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new ei,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let s=0;s<e.length;++s){const r=e[s];Object.defineProperty(tt.prototype,r,Object.getOwnPropertyDescriptor(t,r))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new V),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new V),t=this._localBoundsRect),this._localBounds||(this._localBounds=new ei);const e=this.transform,s=this.parent;this.parent=null,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=s,this.transform=e,this._bounds=r,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,s=!1){return s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,s,r){return e&&(t=e.toGlobal(t,s,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,s)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,s=1,r=1,n=0,o=0,a=0,h=0,l=0){return this.position.x=t,this.position.y=e,this.scale.x=s||1,this.scale.y=r||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=h,this.pivot.y=l,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.interactive=!1,this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new Oo),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*Dn}set angle(t){this.transform.rotation=t*Nn}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex=t,this.parent&&(this.parent.sortDirty=!0)}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class Oo extends tt{constructor(){super(...arguments),this.sortDirty=null}}tt.prototype.displayObjectUpdateTransform=tt.prototype.updateTransform;function Zd(i,t){return i.zIndex===t.zIndex?i._lastSortedIndex-t._lastSortedIndex:i.zIndex-t.zIndex}class bt extends tt{constructor(){super(),this.children=[],this.sortableChildren=S.SORTABLE_CHILDREN,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const s=this.getChildIndex(t),r=this.getChildIndex(e);this.children[s]=e,this.children[r]=t,this.onChildrenChange(s<r?s:r)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const s=this.getChildIndex(t);_e(this.children,s,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],s=this.children.indexOf(e);if(s===-1)return null;e.parent=null,e.transform._parentID=-1,_e(this.children,s,1),this._boundsID++,this.onChildrenChange(s),e.emit("removed",this),this.emit("childRemoved",e,this,s)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,_e(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const s=t,r=e,n=r-s;let o;if(n>0&&n<=r){o=this.children.splice(s,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,s=this.children.length;e<s;++e){const r=this.children[e];r._lastSortedIndex=e,!t&&r.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(Zd),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const s=this.children[t];s.visible&&s.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const s=e._mask.isMaskData?e._mask.maskObject:e._mask;s?(s.calculateBounds(),this._bounds.addBoundsMask(e._bounds,s._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const s=super.getLocalBounds(t);if(!e)for(let r=0,n=this.children.length;r<n;++r){const o=this.children[r];o.visible&&o.updateTransform()}return s}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let s,r;if(this.cullArea?(s=this.cullArea,r=this.worldTransform):this._render!==bt.prototype._render&&(s=this.getBounds(!0)),s&&e.intersects(s,r))this._render(t);else if(this.cullArea)return;for(let n=0,o=this.children.length;n<o;++n){const a=this.children[n],h=a.cullable;a.cullable=h||!this.cullArea,a.render(t),a.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||((e=this.filters)==null?void 0:e.length))this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let s=0,r=this.children.length;s<r;++s)this.children[s].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,s=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let h=0;h<e.length;h++)e[h].enabled&&this._enabledFilters.push(e[h])}const r=e&&((n=this._enabledFilters)==null?void 0:n.length)||s&&(!s.isMaskData||s.enabled&&(s.autoDetect||s.type!==ht.NONE));if(r&&t.batch.flush(),e&&((o=this._enabledFilters)==null?void 0:o.length)&&t.filter.push(this,this._enabledFilters),s&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let h=0,l=this.children.length;h<l;++h)this.children[h].render(t)}r&&t.batch.flush(),s&&t.mask.pop(this),e&&((a=this._enabledFilters)==null?void 0:a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,s=this.removeChildren(0,this.children.length);if(e)for(let r=0;r<s.length;++r)s[r].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}}bt.prototype.containerUpdateTransform=bt.prototype.updateTransform;const ii=new j,Qd=new Uint16Array([0,1,2,0,2,3]);class ae extends bt{constructor(t){super(),this._anchor=new Jt(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tint=null,this._tintRGB=null,this.tint=16777215,this.blendMode=k.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||B.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=Qd,this.pluginName="batch",this.isSprite=!0,this._roundPixels=S.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=ge(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=ge(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,s=e.a,r=e.b,n=e.c,o=e.d,a=e.tx,h=e.ty,l=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,m=0,_=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,_=c.y-d._y*u.height,m=_+c.height):(p=-d._x*u.width,f=p+u.width,_=-d._y*u.height,m=_+u.height),l[0]=s*p+n*_+a,l[1]=o*_+r*p+h,l[2]=s*f+n*_+a,l[3]=o*_+r*f+h,l[4]=s*f+n*m+a,l[5]=o*m+r*f+h,l[6]=s*p+n*m+a,l[7]=o*m+r*p+h,this._roundPixels){const x=S.RESOLUTION;for(let y=0;y<l.length;++y)l[y]=Math.round(l[y]*x)/x}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,s=t.orig,r=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty,d=-r._x*s.width,f=d+s.width,p=-r._y*s.height,m=p+s.height;e[0]=o*d+h*p+c,e[1]=l*p+a*d+u,e[2]=o*f+h*p+c,e[3]=l*p+a*f+u,e[4]=o*f+h*m+c,e[5]=l*m+a*f+u,e[6]=o*d+h*m+c,e[7]=l*m+a*d+u}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new ei),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new V),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ii);const e=this._texture.orig.width,s=this._texture.orig.height,r=-e*this.anchor.x;let n=0;return ii.x>=r&&ii.x<r+e&&(n=-s*this.anchor.y,ii.y>=n&&ii.y<n+s)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!s)}this._texture=null}static from(t,e){const s=t instanceof B?t:B.from(t,e);return new ae(s)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=ge(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=ge(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tint}set tint(t){this._tint=t,this._tintRGB=(t>>16)+(t&65280)+((t&255)<<16)}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||B.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const ko=new et;tt.prototype._cacheAsBitmap=!1,tt.prototype._cacheData=null,tt.prototype._cacheAsBitmapResolution=null,tt.prototype._cacheAsBitmapMultisample=null;class Jd{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(tt.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(i){i!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(i){i!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(i){if(this._cacheAsBitmap===i)return;this._cacheAsBitmap=i;let t;i?(this._cacheData||(this._cacheData=new Jd),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),tt.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},tt.prototype._initCachedDisplayObject=function(t){var d,f,p;if((d=this._cacheData)!=null&&d.sprite)return;const e=this.alpha;this.alpha=1,t.batch.flush();const s=this.getLocalBounds(null,!0).clone();if((f=this.filters)!=null&&f.length){const m=this.filters[0].padding;s.pad(m)}s.ceil(S.RESOLUTION);const r=t.renderTexture.current,n=t.renderTexture.sourceFrame.clone(),o=t.renderTexture.destinationFrame.clone(),a=t.projection.transform,h=te.create({width:s.width,height:s.height,resolution:this.cacheAsBitmapResolution||t.resolution,multisample:(p=this.cacheAsBitmapMultisample)!=null?p:t.multisample}),l=`cacheAsBitmap_${ne()}`;this._cacheData.textureCacheId=l,W.addToCache(h.baseTexture,l),B.addToCache(h,l);const c=this.transform.localTransform.copyTo(ko).invert().translate(-s.x,-s.y);this.render=this._cacheData.originalRender,t.render(this,{renderTexture:h,clear:!0,transform:c,skipUpdateTransform:!1}),t.framebuffer.blit(),t.projection.transform=a,t.renderTexture.bind(r,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const u=new ae(h);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(s.x/s.width),u.anchor.y=-(s.y/s.height),u.alpha=e,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},tt.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},tt.prototype._initCachedDisplayObjectCanvas=function(t){var c;if((c=this._cacheData)!=null&&c.sprite)return;const e=this.getLocalBounds(null,!0),s=this.alpha;this.alpha=1;const r=t.canvasContext.activeContext,n=t._projTransform;e.ceil(S.RESOLUTION);const o=te.create({width:e.width,height:e.height}),a=`cacheAsBitmap_${ne()}`;this._cacheData.textureCacheId=a,W.addToCache(o.baseTexture,a),B.addToCache(o,a);const h=ko;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=e.x,h.ty-=e.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,{renderTexture:o,clear:!0,transform:h,skipUpdateTransform:!1}),t.canvasContext.activeContext=r,t._projTransform=n,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=s;const l=new ae(o);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-(e.x/e.width),l.anchor.y=-(e.y/e.height),l.alpha=s,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)},tt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},tt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},tt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,W.removeFromCache(this._cacheData.textureCacheId),B.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},tt.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},tt.prototype.name=null,bt.prototype.getChildByName=function(t,e){for(let s=0,r=this.children.length;s<r;s++)if(this.children[s].name===t)return this.children[s];if(e)for(let s=0,r=this.children.length;s<r;s++){const n=this.children[s];if(!n.getChildByName)continue;const o=n.getChildByName(t,!0);if(o)return o}return null},tt.prototype.getGlobalPosition=function(t=new j,e=!1){return this.parent?this.parent.toGlobal(this.position,t,e):(t.x=this.position.x,t.y=this.position.y),t};const Go={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};class ke{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ke.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new j,this.page=new j,this.AT_TARGET=1,this.BUBBLING_PHASE=2,this.CAPTURING_PHASE=3,this.NONE=0,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}}class si extends ke{constructor(){super(...arguments),this.client=new j,this.movement=new j,this.offset=new j,this.global=new j,this.screen=new j}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,s,r,n,o,a,h,l,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class St extends si{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 Ki extends si{constructor(){super(...arguments),this.DOM_DELTA_LINE=0,this.DOM_DELTA_PAGE=1,this.DOM_DELTA_PIXEL=2}}const tf=2048,ef=new j,kr=new j;class Ho{constructor(t){this.dispatch=new Re,this.moveOnAll=!1,this.mappingState={trackingData:{}},this.eventPool=new Map,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 console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){const s=this.hitTestRecursive(this.rootTarget,this.rootTarget.interactive,ef.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[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.rootTarget){t.eventPhase=t.BUBBLING_PHASE;const r=s.children;if(r)for(let n=0;n<r.length;n++)this.all(t,e,r[n]);t.currentTarget=s,this.notifyTarget(t,e)}propagationPath(t){const e=[t];for(let s=0;s<tf&&t!==this.rootTarget;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}hitTestRecursive(t,e,s,r,n){if(!t||!t.visible||n(t,s))return null;if(t.interactiveChildren&&t.children){const o=t.children;for(let a=o.length-1;a>=0;a--){const h=o[a],l=this.hitTestRecursive(h,e||h.interactive,s,r,n);if(l){if(l.length>0&&!l[l.length-1].parent)continue;return(l.length>0||t.interactive)&&l.push(t),l}}}return e&&r(t,s)?t.interactive?[t]:[]:null}hitPruneFn(t,e){var s;if(t.hitArea&&(t.worldTransform.applyInverse(e,kr),!t.hitArea.contains(kr.x,kr.y)))return!0;if(t._mask){const r=t._mask.isMaskData?t._mask.maskObject:t._mask;if(r&&!((s=r.containsPoint)!=null&&s.call(r,e)))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){e=e!=null?e:t.type;const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof St)){console.warn("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 a;if(!(t instanceof St)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t),s=e.pointerType==="mouse"||e.pointerType==="pen",r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.overTargets);if(r.overTargets&&n!==e.target){const h=t.type==="mousemove"?"mouseout":"pointerout",l=this.createPointerEvent(t,h,n);if(this.dispatchEvent(l,"pointerout"),s&&this.dispatchEvent(l,"mouseout"),!e.composedPath().includes(n)){const c=this.createPointerEvent(t,"pointerleave",n);for(c.eventPhase=c.AT_TARGET;c.target&&!e.composedPath().includes(c.target);)c.currentTarget=c.target,this.notifyTarget(c),s&&this.notifyTarget(c,"mouseleave"),c.target=c.target.parent;this.freeEvent(c)}this.freeEvent(l)}if(n!==e.target){const h=t.type==="mousemove"?"mouseover":"pointerover",l=this.clonePointerEvent(e,h);this.dispatchEvent(l,"pointerover"),s&&this.dispatchEvent(l,"mouseover");let c=n==null?void 0:n.parent;for(;c&&c!==this.rootTarget.parent&&c!==e.target;)c=c.parent;if(!c||c===this.rootTarget.parent){const d=this.clonePointerEvent(e,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==n&&d.target!==this.rootTarget.parent;)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseenter"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(l)}const o=this.moveOnAll?"all":"dispatchEvent";this[o](e,"pointermove"),e.pointerType==="touch"&&this[o](e,"touchmove"),s&&(this[o](e,"mousemove"),this.cursor=(a=e.target)==null?void 0:a.cursor),r.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof St)){console.warn("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 St)){console.warn("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 St)){console.warn("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];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"?this.dispatchEvent(a,"click"):a.pointerType==="touch"&&this.dispatchEvent(a,"tap"),this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof St)){console.warn("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 Ki)){console.warn("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){const r=this.allocateEvent(St);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=s!=null?s:this.hitTest(r.global.x,r.global.y),typeof e=="string"&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(Ki);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(St);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 St&&e instanceof St&&(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 si&&e instanceof si&&(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.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.fn.call(s.context,t);else for(let r=0,n=s.length;r<n&&!t.propagationImmediatelyStopped;r++)s[r].fn.call(s[r].context,t)}}const sf=1,rf={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class Gr{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Ho(null),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new St(null),this.rootWheelEvent=new Ki(null),this.cursorStyles={default:"inherit",pointer:"pointer"},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)}init(){const{view:t,resolution:e}=this.renderer;this.setTargetElement(t),this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=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)}onPointerDown(t){if(this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&t.pointerType==="touch")return;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.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&t.pointerType==="touch")return;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.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&t.pointerType==="touch")return;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.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&t.pointerType==="touch")return;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){const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;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;const t=this.domElement.style;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){let r;this.domElement.parentElement?r=this.domElement.getBoundingClientRect():r={x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0};const 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=="undefined"&&(n.button=0),typeof n.buttons=="undefined"&&(n.buttons=1),typeof n.isPrimary=="undefined"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width=="undefined"&&(n.width=n.radiusX||1),typeof n.height=="undefined"&&(n.height=n.radiusY||1),typeof n.tiltX=="undefined"&&(n.tiltX=0),typeof n.tiltY=="undefined"&&(n.tiltY=0),typeof n.pointerType=="undefined"&&(n.pointerType="touch"),typeof n.pointerId=="undefined"&&(n.pointerId=n.identifier||0),typeof n.pressure=="undefined"&&(n.pressure=n.force||.5),typeof n.twist=="undefined"&&(n.twist=0),typeof n.tangentialPressure=="undefined"&&(n.tangentialPressure=0),typeof n.layerX=="undefined"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY=="undefined"&&(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=="undefined"&&(s.isPrimary=!0),typeof s.width=="undefined"&&(s.width=1),typeof s.height=="undefined"&&(s.height=1),typeof s.tiltX=="undefined"&&(s.tiltX=0),typeof s.tiltY=="undefined"&&(s.tiltY=0),typeof s.pointerType=="undefined"&&(s.pointerType="mouse"),typeof s.pointerId=="undefined"&&(s.pointerId=sf),typeof s.pressure=="undefined"&&(s.pressure=.5),typeof s.twist=="undefined"&&(s.twist=0),typeof s.tangentialPressure=="undefined"&&(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.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,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=rf[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}}Gr.extension={name:"events",type:[P.RendererSystem,P.CanvasRendererSystem]},U.add(Gr);const Xo={interactive:!1,interactiveChildren:!0,hitArea:null,addEventListener(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.on(i,t,r)},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 ke))throw new Error("DisplayObject 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}};tt.mixin(Xo),tt.mixin(Go);const nf=9,Zi=100,of=0,af=0,Vo=2,zo=1,hf=-1e3,lf=-1e3,cf=2;class Hr{constructor(t){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,(Dt.tablet||Dt.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Zi}px`,e.style.height=`${Zi}px`,e.style.position="absolute",e.style.top=`${of}px`,e.style.left=`${af}px`,e.style.zIndex=Vo.toString(),this.div=e,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}createTouchHook(){const t=document.createElement("button");t.style.width=`${zo}px`,t.style.height=`${zo}px`,t.style.position="absolute",t.style.top=`${hf}px`,t.style.left=`${lf}px`,t.style.zIndex=cf.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.on("postrender",this.update,this),(t=this.renderer.view.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.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.interactive&&(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])}update(){const t=performance.now();if(Dt.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:s,width:r,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:h}=this.renderer,l=r/o*h,c=n/a*h;let u=this.div;u.style.left=`${e}px`,u.style.top=`${s}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,_e(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*l}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*l}px`,u.style.height=`${p.height*m.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*l}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*l}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}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=`${Zi}px`,e.style.height=`${Zi}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Vo.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=`displayObject ${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.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:s}=t.target,r=this.renderer.events.rootBoundary,n=Object.assign(new ke(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===nf&&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}}Hr.extension={name:"accessibility",type:[P.RendererPlugin,P.CanvasRendererPlugin]},U.add(Hr);const Xr=class{constructor(i){this.stage=new bt,i=Object.assign({forceCanvas:!1},i),this.renderer=Fo(i),Xr._plugins.forEach(t=>{t.init.call(this,i)})}render(){this.renderer.render(this.stage)}get view(){return this.renderer.view}get screen(){return this.renderer.screen}destroy(i,t){const e=Xr._plugins.slice(0);e.reverse(),e.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(i),this.renderer=null}};let Vr=Xr;Vr._plugins=[],U.handleByList(P.Application,Vr._plugins);class zr{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}}zr.extension=P.Application,U.add(zr);class uf{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 Wt=(i,t)=>(Array.isArray(i)||(i=[i]),t?i.map(e=>typeof e=="string"?t(e):e):i);function Wo(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?Wo(i.replace(s[e],a),t,e+1,s,r):r.push(i.replace(s[e],a))}}function jo(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)}),Wo(i,r,0,e,s)}else s.push(i);return s}const ri=i=>!Array.isArray(i);class df{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}set(t,e){const s=Wt(t);let r;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];if(h.test(e)){r=h.getCacheableAssets(s,e);break}}r||(r={},s.forEach(a=>{r[a]=e}));const n=Object.keys(r),o={cacheKeys:n,keys:s};if(s.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a),this._cache.set(a,r[a])}),e instanceof B){const a=e;s.forEach(h=>{a.baseTexture!==B.EMPTY.baseTexture&&W.addToCache(a.baseTexture,h),B.addToCache(a,h)})}}remove(t){if(this._cacheMap.get(t),!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const Ne=new df;class ff{constructor(){this._parsers=[],this.promiseCache={}}reset(){this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var n,o;let r=null;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];if(h.load&&((n=h.test)==null?void 0:n.call(h,t,e,this))){r=await h.load(t,e,this),s.parser=h;break}}if(!s.parser)return null;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];h.parse&&h.parse&&await((o=h.testParse)==null?void 0:o.call(h,r,e,this))&&(r=await h.parse(r,e,this)||r,s.parser=h)}return r})(),s}async load(t,e){let s=0;const r={},n=ri(t),o=Wt(t,l=>({src:l})),a=o.length,h=o.map(async l=>{const c=ft.toAbsolute(l.src);if(!r[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),r[l.src]=await this.promiseCache[c].promise,e&&e(++s/a)}catch(u){throw delete this.promiseCache[c],delete r[l.src],new Error(`[Loader.load] Failed to load ${c}.
835
835
  ${u}`)}});return await Promise.all(h),n?r[o[0].src]:r}async unload(t){const s=Wt(t,r=>({src:r})).map(async r=>{var a,h;const n=ft.toAbsolute(r.src),o=this.promiseCache[n];if(o){const l=await o.promise;(h=(a=o.parser)==null?void 0:a.unload)==null||h.call(a,l,r,this),delete this.promiseCache[n]}});await Promise.all(s)}get parsers(){return this._parsers}}class pf{constructor(){this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}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._preferredOrder=[],this._resolverHash={},this._assetMap={},this._rootPath=null,this._basePath=null,this._manifest=null}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];Array.isArray(e)?e.forEach(r=>{typeof r.name=="string"?s.push(r.name):s.push(...r.name),this.add(r.name,r.srcs)}):Object.keys(e).forEach(r=>{s.push(r),this.add(r,e[r])}),this._bundles[t]=s}add(t,e,s){const r=Wt(t);r.forEach(o=>{this._assetMap[o]}),Array.isArray(e)||(typeof e=="string"?e=jo(e):e=[e]);const n=e.map(o=>{var h;let a=o;if(typeof o=="string"){let l=!1;for(let c=0;c<this._parsers.length;c++){const u=this._parsers[c];if(u.test(o)){a=u.parse(o),l=!0;break}}l||(a={src:o})}return a.format||(a.format=a.src.split(".").pop()),a.alias||(a.alias=r),(this._basePath||this._rootPath)&&(a.src=ft.toAbsolute(a.src,this._basePath,this._rootPath)),a.data=(h=a.data)!=null?h:s,a});r.forEach(o=>{this._assetMap[o]=n})}resolveBundle(t){const e=ri(t);t=Wt(t);const s={};return t.forEach(r=>{const n=this._bundles[r];n&&(s[r]=this.resolve(n))}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const r in e)s[r]=e[r].src;return s}return e.src}resolve(t){const e=ri(t);t=Wt(t);const s={};return t.forEach(r=>{var n;if(!this._resolverHash[r])if(this._assetMap[r]){let o=this._assetMap[r];const a=this._getPreferredOrder(o),h=o[0];a==null||a.priority.forEach(l=>{a.params[l].forEach(c=>{const u=o.filter(d=>d[l]?d[l]===c:!1);u.length&&(o=u)})}),this._resolverHash[r]=(n=o[0])!=null?n:h}else{let o=r;(this._basePath||this._rootPath)&&(o=ft.toAbsolute(o,this._basePath,this._rootPath)),this._resolverHash[r]={src:o}}s[r]=this._resolverHash[r]}),e?s[t[0]]:s}_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]}}class Yo{constructor(){this._detections=[],this._initialized=!1,this.resolver=new pf,this.loader=new ff,this.cache=Ne,this._backgroundLoader=new uf(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o,a,h;if(this._initialized)return;if(this._initialized=!0,t.basePath&&(this.resolver.basePath=t.basePath),t.manifest){let l=t.manifest;typeof l=="string"&&(l=await this.load(l)),this.resolver.addManifest(l)}const e=(o=(n=t.texturePreference)==null?void 0:n.resolution)!=null?o:1,s=typeof e=="number"?[e]:e;let r=[];if((a=t.texturePreference)!=null&&a.format){const l=(h=t.texturePreference)==null?void 0:h.format;r=typeof l=="string"?[l]:l;for(const c of this._detections)await c.test()||(r=await c.remove(r))}else for(const l of this._detections)await l.test()&&(r=await l.add(r));this.resolver.prefer({params:{format:r,resolution:s}})}add(t,e,s){this.resolver.add(t,e,s)}async load(t,e){this._initialized||await this.init();const s=ri(t),r=Wt(t).map(a=>typeof a!="string"?(this.resolver.add(a.src,a),a.src):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)},c=o.map(u=>{const d=r[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(f=>{n[u]=f})});return await Promise.all(c),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 Ne.get(t);const e={};for(let s=0;s<t.length;s++)e[s]=Ne.get(t[s]);return e}async _mapLoadToResolve(t,e){const s=Object.values(t),r=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(s,e);this._backgroundLoader.active=!0;const o={};return s.forEach((a,h)=>{const l=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[r[h]]=l,Ne.set(c,l)}),o}async unload(t){this._initialized||await this.init();const e=Wt(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=Wt(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=>{Ne.remove(s.src)}),await this.loader.unload(e)}get detections(){return this._detections}}const ni=new Yo;U.handleByList(P.LoadParser,ni.loader.parsers).handleByList(P.ResolveParser,ni.resolver.parsers).handleByList(P.CacheParser,ni.cache.parsers).handleByList(P.DetectionParser,ni.detections);const $o={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};U.handle(P.Asset,i=>{const t=i.ref;Object.entries($o).filter(([e])=>!!t[e]).forEach(([e,s])=>{var r;return U.add(Object.assign(t[e],{extension:(r=t[e].extension)!=null?r:s}))})},i=>{const t=i.ref;Object.keys($o).filter(e=>!!t[e]).forEach(e=>U.remove(t[e]))});const qo={extension:P.CacheParser,test:i=>Array.isArray(i)&&i.every(t=>t instanceof B),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((r,n)=>{e[s+(n===0?"":n+1)]=r})}),e}};U.add(qo);var Ft=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Ft||{});const Ko={extension:{type:P.LoadParser,priority:Ft.Low},test(i){return ft.extname(i).includes(".json")},async load(i){return await(await S.ADAPTER.fetch(i)).json()}};U.add(Ko);const Zo={extension:{type:P.LoadParser,priority:Ft.Low},test(i){return ft.extname(i).includes(".txt")},async load(i){return await(await S.ADAPTER.fetch(i)).text()}};U.add(Zo);const mf=["normal","bold","100","200","300","400","500","600","700","800","900"],_f=["woff","woff2","ttf","otf"];function Qo(i){const t=ft.extname(i);return ft.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}const Jo={extension:{type:P.LoadParser,priority:Ft.Low},test(i){const e=i.split("?")[0].split(".").pop();return _f.includes(e)},async load(i,t){var s,r,n,o,a,h;if(!globalThis.navigator.onLine)throw new Error("[loadWebFont] Cannot load font - navigator is offline");const e=S.ADAPTER.getFontFaceSet();if(e){const l=[],c=(r=(s=t.data)==null?void 0:s.family)!=null?r:Qo(i),u=(a=(o=(n=t.data)==null?void 0:n.weights)==null?void 0:o.filter(f=>mf.includes(f)))!=null?a:["normal"],d=(h=t.data)!=null?h:{};for(let f=0;f<u.length;f++){const p=u[f],m=new FontFace(c,`url(${i})`,Ts(Ht({},d),{weight:p}));await m.load(),e.add(m),l.push(m)}return l.length===1?l[0]:l}return null},unload(i){(Array.isArray(i)?i:[i]).forEach(t=>S.ADAPTER.getFontFaceSet().delete(t))}};U.add(Jo);let ta=0,Wr;const gf="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",xf={id:"checkImageBitmap",code:`
836
836
  async function checkImageBitmap()
837
837
  {
@@ -887,7 +887,7 @@ ${u}`)}});return await Promise.all(h),n?r[o[0].src]:r}async unload(t){const s=Wt
887
887
  id: event.data.id,
888
888
  });
889
889
  }
890
- };`};let jr;class yf{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 e=URL.createObjectURL(new Blob([xf.code],{type:"application/javascript"})),s=new Worker(e);s.addEventListener("message",r=>{s.terminate(),URL.revokeObjectURL(e),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Wr===void 0&&(Wr=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Wr&&(jr||(jr=URL.createObjectURL(new Blob([vf.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(jr),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[ta]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:ta++,id:s})}}const ea=new yf;function Qi(i,t){const e=i.split("?")[0],s=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s.toLowerCase()):s.toLowerCase()===t}function oi(i,t,e){const s=new B(i);return s.baseTexture.on("dispose",()=>{delete t.promiseCache[e]}),s}const Yr=[".jpg",".png",".jpeg",".avif",".webp"];async function ia(i){const t=await S.ADAPTER.fetch(i);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Ji={extension:{type:P.LoadParser,priority:Ft.High},config:{preferWorkers:!0},test(i){let t=!1;for(let e=0;e<Yr.length;e++)if(i.startsWith(`data:image/${Yr[e].slice(1)}`)){t=!0;break}return t||Qi(i,Yr)},async load(i,t,e){let s=null;globalThis.createImageBitmap?this.config.preferWorkers&&await ea.isImageBitmapSupported()?s=await ea.loadImageBitmap(i):s=await ia(i):s=await new Promise(n=>{s=new Image,s.crossOrigin="anonymous",s.src=i,s.complete?n(s):s.onload=()=>{n(s)}});const r=new W(s,Ht({resolution:qt(i)},t.data));return r.resource.src=i,oi(r,e,i)},unload(i){i.destroy(!0)}};U.add(Ji);const Tf={extension:{type:P.LoadParser,priority:Ft.High},test(i){return ft.extname(i).includes(".svg")},async testParse(i){return Be.test(i)},async parse(i,t,e){var o,a,h;const s=new Be(i,(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions),r=new W(s,Ht({resolution:qt(i)},t==null?void 0:t.data));r.resource.src=i;const n=oi(r,e,i);return(h=(a=t==null?void 0:t.data)==null?void 0:a.resourceOptions)!=null&&h.autoLoad||await s.load(),n},async load(i,t){return(await S.ADAPTER.fetch(i)).text()},unload:Ji.unload},sa={extension:P.ResolveParser,test:Ji.test,parse:i=>{var t,e;return{resolution:parseFloat((e=(t=S.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:i.split(".").pop(),src:i}}};U.add(sa);const ra={extension:{type:P.DetectionParser,priority:1},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=",t=await S.ADAPTER.fetch(i).then(e=>e.blob());return createImageBitmap(t).then(()=>!0,()=>!1)},add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")};U.add(ra);const na={extension:{type:P.DetectionParser,priority:0},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=",t=await S.ADAPTER.fetch(i).then(e=>e.blob());return createImageBitmap(t).then(()=>!0,()=>!1)},add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};U.add(na);const oa=["png","jpg","jpeg"],aa={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...oa],remove:async i=>i.filter(t=>!oa.includes(t))};U.add(aa);var vt=(i=>(i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i))(vt||{});const ai={[33776]:.5,[33777]:.5,[33778]:1,[33779]:1,[35916]:.5,[35917]:.5,[35918]:1,[35919]:1,[37488]:.5,[37489]:.5,[37490]:1,[37491]:1,[37492]:.5,[37496]:1,[37493]:.5,[37497]:1,[37494]:.5,[37495]:.5,[35840]:.5,[35842]:.5,[35841]:.25,[35843]:.25,[36196]:.5,[35986]:.5,[35986]:1,[34798]:1,[37808]:1};class ha extends Me{constructor(t,e={width:1,height:1,autoLoad:!0}){let s,r;typeof t=="string"?(s=t,r=new Uint8Array):(s=null,r=t),super(r,e),this.origin=s,this.buffer=r?new qi(r):null,this.origin&&e.autoLoad!==!1&&this.load(),r!=null&&r.length&&(this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}async load(){const s=await(await(await fetch(this.origin)).blob()).arrayBuffer();return this.data=new Uint32Array(s),this.buffer=new qi(s),this.loaded=!0,this.onBlobLoaded(s),this.update(),this}}class he extends ha{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=he._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||he._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,s){const r=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;for(let o=0,a=this.levels;o<a;o++){const{levelID:h,levelWidth:l,levelHeight:c,levelBuffer:u}=this._levelBuffers[o];r.compressedTexImage2D(r.TEXTURE_2D,h,this.format,l,c,0,u)}return!0}onBlobLoaded(){this._levelBuffers=he._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,s,r,n,o,a){const h=new Array(s);let l=t.byteOffset,c=o,u=a,d=c+r-1&~(r-1),f=u+n-1&~(n-1),p=d*f*ai[e];for(let m=0;m<s;m++)h[m]={levelID:m,levelWidth:s>1?c:d,levelHeight:s>1?u:f,levelBuffer:new Uint8Array(t.buffer,l,p)},l+=p,c=c>>1||1,u=u>>1||1,d=c+r-1&~(r-1),f=u+n-1&~(n-1),p=d*f*ai[e];return h}}let Zt,Fe;function la(){Fe={s3tc:Zt.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Zt.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:Zt.getExtension("WEBGL_compressed_texture_etc"),etc1:Zt.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:Zt.getExtension("WEBGL_compressed_texture_pvrtc")||Zt.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:Zt.getExtension("WEBGL_compressed_texture_atc"),astc:Zt.getExtension("WEBGL_compressed_texture_astc")}}const ca={extension:{type:P.DetectionParser,priority:2},test:async()=>{const t=S.ADAPTER.createCanvas().getContext("webgl");return t?(Zt=t,!0):!1},add:async i=>{Fe||la();const t=[];for(const e in Fe)!Fe[e]||t.push(e);return[...t,...i]},remove:async i=>(Fe||la(),i.filter(t=>!(t in Fe)))};U.add(ca);const $r=4,ts=124,bf=32,ua=20,Ef=542327876,es={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},wf={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},is={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var Af=(i=>(i[i.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",i[i.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",i[i.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",i[i.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",i[i.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",i[i.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",i[i.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",i[i.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",i[i.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",i[i.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",i[i.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",i[i.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",i[i.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",i[i.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",i[i.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",i[i.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",i[i.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",i[i.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",i[i.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",i[i.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",i[i.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",i[i.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",i[i.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",i[i.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",i[i.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",i[i.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",i[i.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",i[i.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",i[i.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",i[i.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",i[i.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",i[i.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",i[i.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",i[i.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",i[i.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",i[i.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",i[i.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",i[i.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",i[i.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",i[i.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",i[i.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",i[i.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",i[i.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",i[i.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",i[i.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",i[i.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",i[i.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",i[i.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",i[i.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",i[i.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",i[i.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",i[i.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",i[i.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",i[i.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",i[i.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",i[i.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",i[i.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",i[i.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",i[i.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",i[i.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",i[i.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",i[i.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",i[i.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",i[i.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",i[i.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",i[i.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",i[i.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",i[i.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",i[i.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",i[i.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",i[i.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",i[i.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",i[i.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",i[i.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",i[i.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",i[i.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",i[i.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",i[i.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",i[i.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",i[i.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",i[i.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",i[i.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",i[i.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",i[i.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",i[i.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",i[i.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",i[i.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",i[i.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",i[i.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",i[i.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",i[i.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",i[i.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",i[i.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",i[i.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",i[i.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",i[i.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",i[i.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",i[i.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",i[i.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",i[i.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",i[i.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",i[i.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",i[i.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",i[i.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",i[i.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",i[i.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",i[i.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",i[i.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",i[i.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",i[i.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",i[i.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",i[i.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",i[i.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",i[i.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",i[i.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",i[i.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",i[i.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",i[i.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",i[i.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",i[i.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",i[i.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",i[i.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",i))(Af||{}),Sf=(i=>(i[i.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",i[i.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",i[i.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D",i))(Sf||{});const Rf=1,Cf=2,If=4,Pf=64,Mf=512,Bf=131072,Df=827611204,Nf=861165636,Ff=894720068,Lf=808540228,Uf=4,Of={[Df]:vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Nf]:vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Ff]:vt.COMPRESSED_RGBA_S3TC_DXT5_EXT},kf={[70]:vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[71]:vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[73]:vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[74]:vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[76]:vt.COMPRESSED_RGBA_S3TC_DXT5_EXT,[77]:vt.COMPRESSED_RGBA_S3TC_DXT5_EXT,[72]:vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,[75]:vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,[78]:vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function da(i){const t=new Uint32Array(i);if(t[0]!==Ef)throw new Error("Invalid DDS file magic word");const s=new Uint32Array(i,0,ts/Uint32Array.BYTES_PER_ELEMENT),r=s[es.HEIGHT],n=s[es.WIDTH],o=s[es.MIPMAP_COUNT],a=new Uint32Array(i,es.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,bf/Uint32Array.BYTES_PER_ELEMENT),h=a[Rf];if(h&If){const l=a[wf.FOURCC];if(l!==Lf){const g=Of[l],v=$r+ts,b=new Uint8Array(i,v);return[new he(b,{format:g,width:n,height:r,levels:o})]}const c=$r+ts,u=new Uint32Array(t.buffer,c,ua/Uint32Array.BYTES_PER_ELEMENT),d=u[is.DXGI_FORMAT],f=u[is.RESOURCE_DIMENSION],p=u[is.MISC_FLAG],m=u[is.ARRAY_SIZE],_=kf[d];if(_===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${d}`);if(p===Uf)throw new Error("DDSParser does not support cubemap textures");if(f===6)throw new Error("DDSParser does not supported 3D texture data");const x=new Array,y=$r+ts+ua;if(m===1)x.push(new Uint8Array(i,y));else{const g=ai[_];let v=0,b=n,M=r;for(let w=0;w<o;w++){const L=Math.max(1,b+3&-4),G=Math.max(1,M+3&-4);v+=L*G*g,b=b>>>1,M=M>>>1}let R=y;for(let w=0;w<m;w++)x.push(new Uint8Array(i,R,v)),R+=v}return x.map(g=>new he(g,{format:_,width:n,height:r,levels:o}))}throw h&Pf?new Error("DDSParser does not support uncompressed texture data."):h&Mf?new Error("DDSParser does not supported YUV uncompressed texture data."):h&Bf?new Error("DDSParser does not support single-channel (lumninance) texture data!"):h&Cf?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const fa=[171,75,84,88,32,49,49,187,13,10,26,10],Gf=67305985,Lt={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},qr=64,Kr={[O.UNSIGNED_BYTE]:1,[O.UNSIGNED_SHORT]:2,[O.INT]:4,[O.UNSIGNED_INT]:4,[O.FLOAT]:4,[O.HALF_FLOAT]:8},pa={[C.RGBA]:4,[C.RGB]:3,[C.RG]:2,[C.RED]:1,[C.LUMINANCE]:1,[C.LUMINANCE_ALPHA]:2,[C.ALPHA]:1},ma={[O.UNSIGNED_SHORT_4_4_4_4]:2,[O.UNSIGNED_SHORT_5_5_5_1]:2,[O.UNSIGNED_SHORT_5_6_5]:2};function _a(i,t,e=!1){const s=new DataView(t);if(!Hf(i,s))return null;const r=s.getUint32(Lt.ENDIANNESS,!0)===Gf,n=s.getUint32(Lt.GL_TYPE,r),o=s.getUint32(Lt.GL_FORMAT,r),a=s.getUint32(Lt.GL_INTERNAL_FORMAT,r),h=s.getUint32(Lt.PIXEL_WIDTH,r),l=s.getUint32(Lt.PIXEL_HEIGHT,r)||1,c=s.getUint32(Lt.PIXEL_DEPTH,r)||1,u=s.getUint32(Lt.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=s.getUint32(Lt.NUMBER_OF_FACES,r),f=s.getUint32(Lt.NUMBER_OF_MIPMAP_LEVELS,r),p=s.getUint32(Lt.BYTES_OF_KEY_VALUE_DATA,r);if(l===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const m=4,_=4,x=h+3&-4,y=l+3&-4,g=new Array(u);let v=h*l;n===0&&(v=x*y);let b;if(n!==0?Kr[n]?b=Kr[n]*pa[o]:b=ma[n]:b=ai[a],b===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const M=e?Vf(s,p,r):null;let w=v*b,L=h,G=l,I=x,N=y,E=qr+p;for(let T=0;T<f;T++){const X=s.getUint32(E,r);let z=E+4;for(let D=0;D<u;D++){let $=g[D];$||($=g[D]=new Array(f)),$[T]={levelID:T,levelWidth:f>1||n!==0?L:I,levelHeight:f>1||n!==0?G:N,levelBuffer:new Uint8Array(t,z,w)},z+=w}E+=X+4,E=E%4!==0?E+4-E%4:E,L=L>>1||1,G=G>>1||1,I=L+m-1&~(m-1),N=G+_-1&~(_-1),w=I*N*b}return n!==0?{uncompressed:g.map(T=>{let X=T[0].levelBuffer,z=!1;return n===O.FLOAT?X=new Float32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4):n===O.UNSIGNED_INT?(z=!0,X=new Uint32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)):n===O.INT&&(z=!0,X=new Int32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)),{resource:new Me(X,{width:T[0].levelWidth,height:T[0].levelHeight}),type:n,format:z?Xf(o):o}}),kvData:M}:{compressed:g.map(T=>new he(null,{format:a,width:h,height:l,levels:f,levelBuffers:T})),kvData:M}}function Hf(i,t){for(let e=0;e<fa.length;e++)if(t.getUint8(e)!==fa[e])return!1;return!0}function Xf(i){switch(i){case C.RGBA:return C.RGBA_INTEGER;case C.RGB:return C.RGB_INTEGER;case C.RG:return C.RG_INTEGER;case C.RED:return C.RED_INTEGER;default:return i}}function Vf(i,t,e){const s=new Map;let r=0;for(;r<t;){const n=i.getUint32(qr+r,e),o=qr+r+4,a=3-(n+3)%4;if(n===0||n>t-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&i.getUint8(o+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=new TextDecoder().decode(new Uint8Array(i.buffer,o,h)),c=new DataView(i.buffer,o+h+1,n-h-1);s.set(l,c),r+=4+n+a}return s}const ga={extension:{type:P.LoadParser,priority:Ft.High},test(i){return Qi(i,".dds")},async load(i,t,e){const r=await(await S.ADAPTER.fetch(i)).arrayBuffer(),o=da(r).map(a=>{const h=new W(a,Ht({mipmap:Pt.OFF,alphaMode:Et.NO_PREMULTIPLIED_ALPHA,resolution:qt(i)},t.data));return oi(h,e,i)});return o.length===1?o[0]:o},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};U.add(ga);const xa={extension:{type:P.LoadParser,priority:Ft.High},test(i){return Qi(i,".ktx")},async load(i,t,e){const r=await(await S.ADAPTER.fetch(i)).arrayBuffer(),{compressed:n,uncompressed:o,kvData:a}=_a(i,r),h=n!=null?n:o,l=Ht({mipmap:Pt.OFF,alphaMode:Et.NO_PREMULTIPLIED_ALPHA,resolution:qt(i)},t.data),c=h.map(u=>{h===o&&Object.assign(l,{type:u.type,format:u.format});const d=new W(u,l);return d.ktxKeyValueData=a,oi(d,e,i)});return c.length===1?c[0]:c},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};U.add(xa);const va={extension:P.ResolveParser,test:i=>{const e=i.split("?")[0].split(".").pop();return["basis","ktx","dds"].includes(e)},parse:i=>{var s,r,n,o;if(i.split("?")[0].split(".").pop()==="ktx"){const a=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(a.some(h=>i.endsWith(h)))return{resolution:parseFloat((r=(s=S.RETINA_PREFIX.exec(i))==null?void 0:s[1])!=null?r:"1"),format:a.find(h=>i.endsWith(h)),src:i}}return{resolution:parseFloat((o=(n=S.RETINA_PREFIX.exec(i))==null?void 0:n[1])!=null?o:"1"),format:i.split(".").pop(),src:i}}};U.add(va);const ya=new V,Ta=4,Zr=class{constructor(i){this.renderer=i}async image(i,t,e){const s=new Image;return s.src=await this.base64(i,t,e),s}async base64(i,t,e){const s=this.canvas(i);if(s.toDataURL!==void 0)return s.toDataURL(t,e);if(s.convertToBlob!==void 0){const r=await s.convertToBlob({type:t,quality:e});return await new Promise(n=>{const o=new FileReader;o.onload=()=>n(o.result),o.readAsDataURL(r)})}throw new Error("Extract.base64() requires ICanvas.toDataURL or ICanvas.convertToBlob to be implemented")}canvas(i,t){const e=this.renderer;let s,r=!1,n,o=!1;i&&(i instanceof te?n=i:(n=this.renderer.generateTexture(i),o=!0)),n?(s=n.baseTexture.resolution,t=t!=null?t:n.frame,r=!1,e.renderTexture.bind(n)):(s=e.resolution,t||(t=ya,t.width=e.width,t.height=e.height),r=!0,e.renderTexture.bind(null));const a=Math.round(t.width*s),h=Math.round(t.height*s);let l=new Ws(a,h,1);const c=new Uint8Array(Ta*a*h),u=e.gl;u.readPixels(Math.round(t.x*s),Math.round(t.y*s),a,h,u.RGBA,u.UNSIGNED_BYTE,c);const d=l.context.getImageData(0,0,a,h);if(Zr.arrayPostDivide(c,d.data),l.context.putImageData(d,0,0),r){const f=new Ws(l.width,l.height,1);f.context.scale(1,-1),f.context.drawImage(l.canvas,0,-h),l.destroy(),l=f}return o&&n.destroy(!0),l.canvas}pixels(i,t){const e=this.renderer;let s,r,n=!1;i&&(i instanceof te?r=i:(r=this.renderer.generateTexture(i),n=!0)),r?(s=r.baseTexture.resolution,t=t!=null?t:r.frame,e.renderTexture.bind(r)):(s=e.resolution,t||(t=ya,t.width=e.width,t.height=e.height),e.renderTexture.bind(null));const o=Math.round(t.width*s),a=Math.round(t.height*s),h=new Uint8Array(Ta*o*a),l=e.gl;return l.readPixels(Math.round(t.x*s),Math.round(t.y*s),o,a,l.RGBA,l.UNSIGNED_BYTE,h),n&&r.destroy(!0),Zr.arrayPostDivide(h,h),h}destroy(){this.renderer=null}static arrayPostDivide(i,t){for(let e=0;e<i.length;e+=4){const s=t[e+3]=i[e+3];s!==0?(t[e]=Math.round(Math.min(i[e]*255/s,255)),t[e+1]=Math.round(Math.min(i[e+1]*255/s,255)),t[e+2]=Math.round(Math.min(i[e+2]*255/s,255))):(t[e]=i[e],t[e+1]=i[e+1],t[e+2]=i[e+2])}}};let Qr=Zr;Qr.extension={name:"extract",type:P.RendererSystem},U.add(Qr);var Qt=(i=>(i.MITER="miter",i.BEVEL="bevel",i.ROUND="round",i))(Qt||{}),oe=(i=>(i.BUTT="butt",i.ROUND="round",i.SQUARE="square",i))(oe||{});const Le={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(i,t=20){if(!this.adaptive||!i||isNaN(i))return t;let e=Math.ceil(i/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class gi{constructor(){this.color=16777215,this.alpha=1,this.texture=B.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new gi;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=B.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}function ba(i,t=!1){const e=i.length;if(e<6)return;let s=0;for(let r=0,n=i[e-2],o=i[e-1];r<e;r+=2){const a=i[r],h=i[r+1];s+=(a-n)*(h+o),n=a,o=h}if(!t&&s>0||t&&s<=0){const r=e/2;for(let n=r+r%2;n<e;n+=2){const o=e-n-2,a=e-n-1,h=n,l=n+1;[i[o],i[h]]=[i[h],i[o]],[i[a],i[l]]=[i[l],i[a]]}}}const Jr={build(i){i.points=i.shape.points.slice()},triangulate(i,t){let e=i.points;const s=i.holes,r=t.points,n=t.indices;if(e.length>=6){ba(e,!1);const o=[];for(let l=0;l<s.length;l++){const c=s[l];ba(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=Ps(e,o,2);if(!a)return;const h=r.length/2;for(let l=0;l<a.length;l+=3)n.push(a[l]+h),n.push(a[l+1]+h),n.push(a[l+2]+h);for(let l=0;l<e.length;l++)r.push(e[l])}}},hi={build(i){const t=i.points;let e,s,r,n,o,a;if(i.type===dt.CIRC){const p=i.shape;e=p.x,s=p.y,o=a=p.radius,r=n=0}else if(i.type===dt.ELIP){const p=i.shape;e=p.x,s=p.y,o=p.width,a=p.height,r=n=0}else{const p=i.shape,m=p.width/2,_=p.height/2;e=p.x+m,s=p.y+_,o=a=Math.max(0,Math.min(p.radius,Math.min(m,_))),r=m-o,n=_-a}if(!(o>=0&&a>=0&&r>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(t.length=l,l===0)return;if(h===0){t.length=8,t[0]=t[6]=e+r,t[1]=t[3]=s+n,t[2]=t[4]=e-r,t[5]=t[7]=s-n;return}let c=0,u=h*4+(r?2:0)+2,d=u,f=l;{const p=r+o,m=n,_=e+p,x=e-p,y=s+m;if(t[c++]=_,t[c++]=y,t[--u]=y,t[--u]=x,n){const g=s-m;t[d++]=x,t[d++]=g,t[--f]=g,t[--f]=_}}for(let p=1;p<h;p++){const m=Math.PI/2*(p/h),_=r+Math.cos(m)*o,x=n+Math.sin(m)*a,y=e+_,g=e-_,v=s+x,b=s-x;t[c++]=y,t[c++]=v,t[--u]=v,t[--u]=g,t[d++]=g,t[d++]=b,t[--f]=b,t[--f]=y}{const p=r,m=n+a,_=e+p,x=e-p,y=s+m,g=s-m;t[c++]=_,t[c++]=y,t[--f]=g,t[--f]=_,r&&(t[c++]=x,t[c++]=y,t[--f]=g,t[--f]=x)}},triangulate(i,t){const e=i.points,s=t.points,r=t.indices;if(e.length===0)return;let n=s.length/2;const o=n;let a,h;if(i.type!==dt.RREC){const c=i.shape;a=c.x,h=c.y}else{const c=i.shape;a=c.x+c.width/2,h=c.y+c.height/2}const l=i.matrix;s.push(i.matrix?l.a*a+l.c*h+l.tx:a,i.matrix?l.b*a+l.d*h+l.ty:h),n++,s.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)s.push(e[c],e[c+1]),r.push(n++,o,n);r.push(o+1,o,n)}},Ea={build(i){const t=i.shape,e=t.x,s=t.y,r=t.width,n=t.height,o=i.points;o.length=0,r>=0&&n>=0&&o.push(e,s,e+r,s,e+r,s+n,e,s+n)},triangulate(i,t){const e=i.points,s=t.points;if(e.length===0)return;const r=s.length/2;s.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(r,r+1,r+2,r+1,r+2,r+3)}},wa={build(i){hi.build(i)},triangulate(i,t){hi.triangulate(i,t)}};function Aa(i,t,e,s,r,n,o,a){const h=i-e*r,l=t-s*r,c=i+e*n,u=t+s*n;let d,f;o?(d=s,f=-e):(d=-s,f=e);const p=h+d,m=l+f,_=c+d,x=u+f;return a.push(p,m),a.push(_,x),2}function be(i,t,e,s,r,n,o,a){const h=e-i,l=s-t;let c=Math.atan2(h,l),u=Math.atan2(r-i,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(h*h+l*l),_=(15*p*Math.sqrt(m)/Math.PI>>0)+1,x=f/_;if(d+=x,a){o.push(i,t),o.push(e,s);for(let y=1,g=d;y<_;y++,g+=x)o.push(i,t),o.push(i+Math.sin(g)*m,t+Math.cos(g)*m);o.push(i,t),o.push(r,n)}else{o.push(e,s),o.push(i,t);for(let y=1,g=d;y<_;y++,g+=x)o.push(i+Math.sin(g)*m,t+Math.cos(g)*m),o.push(i,t);o.push(r,n),o.push(i,t)}return _*2}function zf(i,t){const e=i.shape;let s=i.points||e.points.slice();const r=t.closePointEps;if(s.length===0)return;const n=i.lineStyle,o=new j(s[0],s[1]),a=new j(s[s.length-2],s[s.length-1]),h=e.type!==dt.POLY||e.closeStroke,l=Math.abs(o.x-a.x)<r&&Math.abs(o.y-a.y)<r;if(h){s=s.slice(),l&&(s.pop(),s.pop(),a.set(s[s.length-2],s[s.length-1]));const D=(o.x+a.x)*.5,$=(a.y+o.y)*.5;s.unshift(D,$),s.push(D,$)}const c=t.points,u=s.length/2;let d=s.length;const f=c.length/2,p=n.width/2,m=p*p,_=n.miterLimit*n.miterLimit;let x=s[0],y=s[1],g=s[2],v=s[3],b=0,M=0,R=-(y-v),w=x-g,L=0,G=0,I=Math.sqrt(R*R+w*w);R/=I,w/=I,R*=p,w*=p;const N=n.alignment,E=(1-N)*2,T=N*2;h||(n.cap===oe.ROUND?d+=be(x-R*(E-T)*.5,y-w*(E-T)*.5,x-R*E,y-w*E,x+R*T,y+w*T,c,!0)+2:n.cap===oe.SQUARE&&(d+=Aa(x,y,R,w,E,T,!0,c))),c.push(x-R*E,y-w*E),c.push(x+R*T,y+w*T);for(let D=1;D<u-1;++D){x=s[(D-1)*2],y=s[(D-1)*2+1],g=s[D*2],v=s[D*2+1],b=s[(D+1)*2],M=s[(D+1)*2+1],R=-(y-v),w=x-g,I=Math.sqrt(R*R+w*w),R/=I,w/=I,R*=p,w*=p,L=-(v-M),G=g-b,I=Math.sqrt(L*L+G*G),L/=I,G/=I,L*=p,G*=p;const $=g-x,st=y-v,A=g-b,H=M-v,Y=$*A+st*H,q=st*A-H*$,K=q<0;if(Math.abs(q)<.001*Math.abs(Y)){c.push(g-R*E,v-w*E),c.push(g+R*T,v+w*T),Y>=0&&(n.join===Qt.ROUND?d+=be(g,v,g-R*E,v-w*E,g-L*E,v-G*E,c,!1)+4:d+=2,c.push(g-L*T,v-G*T),c.push(g+L*E,v+G*E));continue}const ct=(-R+x)*(-w+v)-(-R+g)*(-w+y),ot=(-L+b)*(-G+v)-(-L+g)*(-G+M),ut=($*ot-A*ct)/q,mt=(H*ct-st*ot)/q,gt=(ut-g)*(ut-g)+(mt-v)*(mt-v),pt=g+(ut-g)*E,Q=v+(mt-v)*E,at=g-(ut-g)*T,lt=v-(mt-v)*T,kt=Math.min($*$+st*st,A*A+H*H),Gt=K?E:T,Ge=kt+Gt*Gt*m;gt<=Ge?n.join===Qt.BEVEL||gt/m>_?(K?(c.push(pt,Q),c.push(g+R*T,v+w*T),c.push(pt,Q),c.push(g+L*T,v+G*T)):(c.push(g-R*E,v-w*E),c.push(at,lt),c.push(g-L*E,v-G*E),c.push(at,lt)),d+=2):n.join===Qt.ROUND?K?(c.push(pt,Q),c.push(g+R*T,v+w*T),d+=be(g,v,g+R*T,v+w*T,g+L*T,v+G*T,c,!0)+4,c.push(pt,Q),c.push(g+L*T,v+G*T)):(c.push(g-R*E,v-w*E),c.push(at,lt),d+=be(g,v,g-R*E,v-w*E,g-L*E,v-G*E,c,!1)+4,c.push(g-L*E,v-G*E),c.push(at,lt)):(c.push(pt,Q),c.push(at,lt)):(c.push(g-R*E,v-w*E),c.push(g+R*T,v+w*T),n.join===Qt.ROUND?K?d+=be(g,v,g+R*T,v+w*T,g+L*T,v+G*T,c,!0)+2:d+=be(g,v,g-R*E,v-w*E,g-L*E,v-G*E,c,!1)+2:n.join===Qt.MITER&&gt/m<=_&&(K?(c.push(at,lt),c.push(at,lt)):(c.push(pt,Q),c.push(pt,Q)),d+=2),c.push(g-L*E,v-G*E),c.push(g+L*T,v+G*T),d+=2)}x=s[(u-2)*2],y=s[(u-2)*2+1],g=s[(u-1)*2],v=s[(u-1)*2+1],R=-(y-v),w=x-g,I=Math.sqrt(R*R+w*w),R/=I,w/=I,R*=p,w*=p,c.push(g-R*E,v-w*E),c.push(g+R*T,v+w*T),h||(n.cap===oe.ROUND?d+=be(g-R*(E-T)*.5,v-w*(E-T)*.5,g-R*E,v-w*E,g+R*T,v+w*T,c,!1)+2:n.cap===oe.SQUARE&&(d+=Aa(g,v,R,w,E,T,!1,c)));const X=t.indices,z=Le.epsilon*Le.epsilon;for(let D=f;D<d+f-2;++D)x=c[D*2],y=c[D*2+1],g=c[(D+1)*2],v=c[(D+1)*2+1],b=c[(D+2)*2],M=c[(D+2)*2+1],!(Math.abs(x*(v-M)+g*(M-y)+b*(y-v))<z)&&X.push(D,D+1,D+2)}function Wf(i,t){let e=0;const s=i.shape,r=i.points||s.points,n=s.type!==dt.POLY||s.closeStroke;if(r.length===0)return;const o=t.points,a=t.indices,h=r.length/2,l=o.length/2;let c=l;for(o.push(r[0],r[1]),e=1;e<h;e++)o.push(r[e*2],r[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,l)}function tn(i,t){i.lineStyle.native?Wf(i,t):zf(i,t)}class en{static curveTo(t,e,s,r,n,o){const a=o[o.length-2],l=o[o.length-1]-e,c=a-t,u=r-e,d=s-t,f=Math.abs(l*d-c*u);if(f<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const p=l*l+c*c,m=u*u+d*d,_=l*u+c*d,x=n*Math.sqrt(p)/f,y=n*Math.sqrt(m)/f,g=x*_/p,v=y*_/m,b=x*d+y*c,M=x*u+y*l,R=c*(y+g),w=l*(y+g),L=d*(x+v),G=u*(x+v),I=Math.atan2(w-M,R-b),N=Math.atan2(G-M,L-b);return{cx:b+t,cy:M+e,radius:n,startAngle:I,endAngle:N,anticlockwise:c*u>d*l}}static arc(t,e,s,r,n,o,a,h,l){const c=a-o,u=Le._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/He)*40),d=c/(u*2),f=d*2,p=Math.cos(d),m=Math.sin(d),_=u-1,x=_%1/_;for(let y=0;y<=_;++y){const g=y+x*y,v=d+o+f*g,b=Math.cos(v),M=-Math.sin(v);l.push((p*b+m*M)*n+s,(p*-M+m*b)*n+r)}}}class gs{static curveLength(t,e,s,r,n,o,a,h){let c=0,u=0,d=0,f=0,p=0,m=0,_=0,x=0,y=0,g=0,v=0,b=t,M=e;for(let R=1;R<=10;++R)u=R/10,d=u*u,f=d*u,p=1-u,m=p*p,_=m*p,x=_*t+3*m*u*s+3*p*d*n+f*a,y=_*e+3*m*u*r+3*p*d*o+f*h,g=b-x,v=M-y,b=x,M=y,c+=Math.sqrt(g*g+v*v);return c}static curveTo(t,e,s,r,n,o,a){const h=a[a.length-2],l=a[a.length-1];a.length-=2;const c=Le._segmentsCount(gs.curveLength(h,l,t,e,s,r,n,o));let u=0,d=0,f=0,p=0,m=0;a.push(h,l);for(let _=1,x=0;_<=c;++_)x=_/c,u=1-x,d=u*u,f=d*u,p=x*x,m=p*x,a.push(f*h+3*d*x*t+3*u*p*s+m*n,f*l+3*d*x*e+3*u*p*r+m*o)}}class xs{static curveLength(t,e,s,r,n,o){const a=t-2*s+n,h=e-2*r+o,l=2*s-2*t,c=2*r-2*e,u=4*(a*a+h*h),d=4*(a*l+h*c),f=l*l+c*c,p=2*Math.sqrt(u+d+f),m=Math.sqrt(u),_=2*u*m,x=2*Math.sqrt(f),y=d/m;return(_*p+m*d*(p-x)+(4*f*u-d*d)*Math.log((2*m+y+p)/(y+x)))/(4*_)}static curveTo(t,e,s,r,n){const o=n[n.length-2],a=n[n.length-1],h=Le._segmentsCount(xs.curveLength(o,a,t,e,s,r));let l=0,c=0;for(let u=1;u<=h;++u){const d=u/h;l=o+(t-o)*d,c=a+(e-a)*d,n.push(l+(t+(s-t)*d-l)*d,c+(e+(r-e)*d-c)*d)}}}class Sa{constructor(){this.reset()}begin(t,e,s){this.reset(),this.style=t,this.start=e,this.attribStart=s}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}const ss={[dt.POLY]:Jr,[dt.CIRC]:hi,[dt.ELIP]:hi,[dt.RECT]:Ea,[dt.RREC]:wa},sn=[],li=[];class xi{constructor(t,e=null,s=null,r=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=s,this.fillStyle=e,this.matrix=r,this.type=t.type}clone(){return new xi(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Ue=new j,Ra=class extends Dr{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new ei,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let i=0;i<this.drawCalls.length;i++)this.drawCalls[i].texArray.clear(),li.push(this.drawCalls[i]);this.drawCalls.length=0;for(let i=0;i<this.batches.length;i++){const t=this.batches[i];t.reset(),sn.push(t)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(i,t=null,e=null,s=null){const r=new xi(i,t,e,s);return this.graphicsData.push(r),this.dirty++,this}drawHole(i,t=null){if(!this.graphicsData.length)return null;const e=new xi(i,null,null,t),s=this.graphicsData[this.graphicsData.length-1];return e.lineStyle=s.lineStyle,s.holes.push(e),this.dirty++,this}destroy(){super.destroy();for(let i=0;i<this.graphicsData.length;++i)this.graphicsData[i].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(i){const t=this.graphicsData;for(let e=0;e<t.length;++e){const s=t[e];if(!!s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(i,Ue):Ue.copyFrom(i),s.shape.contains(Ue.x,Ue.y))){let r=!1;if(s.holes){for(let n=0;n<s.holes.length;n++)if(s.holes[n].shape.contains(Ue.x,Ue.y)){r=!0;break}}if(!r)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const i=this.uvs,t=this.graphicsData;let e=null,s=null;this.batches.length>0&&(e=this.batches[this.batches.length-1],s=e.style);for(let a=this.shapeIndex;a<t.length;a++){this.shapeIndex++;const h=t[a],l=h.fillStyle,c=h.lineStyle;ss[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(l.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?l:c;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,_=this.points.length/2;p.wrapMode=Vt.REPEAT,d===0?this.processFill(h):this.processLine(h);const x=this.points.length/2-_;x!==0&&(e&&!this._compareStyles(s,f)&&(e.end(m,_),e=null),e||(e=sn.pop()||new Sa,e.begin(f,m,_),this.batches.push(e),s=f),this.addUvs(this.points,i,f.texture,_,x,f.matrix))}}const r=this.indices.length,n=this.points.length/2;if(e&&e.end(r,n),this.batches.length===0){this.batchable=!0;return}const o=n>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(i,t){return!(!i||!t||i.texture.baseTexture!==t.texture.baseTexture||i.color+i.alpha!==t.color+t.alpha||!!i.native!=!!t.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let i=0,t=this.graphicsData.length;i<t;i++){const e=this.graphicsData[i],s=e.fillStyle,r=e.lineStyle;if(s&&!s.texture.baseTexture.valid||r&&!r.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const i=this.batches;for(let t=0,e=i.length;t<e;t++){const s=i[t];for(let r=0;r<s.size;r++){const n=s.start+r;this.indicesUint16[n]=this.indicesUint16[n]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const i=this.batches;for(let t=0;t<i.length;t++)if(i[t].style.native)return!1;return this.points.length<Ra.BATCHABLE_SIZE*2}buildDrawCalls(){let i=++W._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),li.push(this.drawCalls[c]);this.drawCalls.length=0;const t=this.colors,e=this.textureIds;let s=li.pop();s||(s=new Yi,s.texArray=new $i),s.texArray.count=0,s.start=0,s.size=0,s.type=It.TRIANGLES;let r=0,n=null,o=0,a=!1,h=It.TRIANGLES,l=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const u=this.batches[c],d=8,f=u.style,p=f.texture.baseTexture;a!==!!f.native&&(a=!!f.native,h=a?It.LINES:It.TRIANGLES,n=null,r=d,i++),n!==p&&(n=p,p._batchEnabled!==i&&(r===d&&(i++,r=0,s.size>0&&(s=li.pop(),s||(s=new Yi,s.texArray=new $i),this.drawCalls.push(s)),s.start=l,s.size=0,s.texArray.count=0,s.type=h),p.touched=1,p._batchEnabled=i,p._batchLocation=r,p.wrapMode=Vt.REPEAT,s.texArray.elements[s.texArray.count++]=p,r++)),s.size+=u.size,l+=u.size,o=p._batchLocation,this.addColors(t,f.color,f.alpha,u.attribSize,u.attribStart),this.addTextureIds(e,o,u.attribSize,u.attribStart)}W._globalBatch=i,this.packAttributes()}packAttributes(){const i=this.points,t=this.uvs,e=this.colors,s=this.textureIds,r=new ArrayBuffer(i.length*3*4),n=new Float32Array(r),o=new Uint32Array(r);let a=0;for(let h=0;h<i.length/2;h++)n[a++]=i[h*2],n[a++]=i[h*2+1],n[a++]=t[h*2],n[a++]=t[h*2+1],o[a++]=e[h],n[a++]=s[h];this._buffer.update(r),this._indexBuffer.update(this.indicesUint16)}processFill(i){i.holes.length?Jr.triangulate(i,this):ss[i.type].triangulate(i,this)}processLine(i){tn(i,this);for(let t=0;t<i.holes.length;t++)tn(i.holes[t],this)}processHoles(i){for(let t=0;t<i.length;t++){const e=i[t];ss[e.type].build(e),e.matrix&&this.transformPoints(e.points,e.matrix)}}calculateBounds(){const i=this._bounds;i.clear(),i.addVertexData(this.points,0,this.points.length),i.pad(this.boundsPadding,this.boundsPadding)}transformPoints(i,t){for(let e=0;e<i.length/2;e++){const s=i[e*2],r=i[e*2+1];i[e*2]=t.a*s+t.c*r+t.tx,i[e*2+1]=t.b*s+t.d*r+t.ty}}addColors(i,t,e,s,r=0){const n=(t>>16)+(t&65280)+((t&255)<<16),o=Mi(n,e);i.length=Math.max(i.length,r+s);for(let a=0;a<s;a++)i[r+a]=o}addTextureIds(i,t,e,s=0){i.length=Math.max(i.length,s+e);for(let r=0;r<e;r++)i[s+r]=t}addUvs(i,t,e,s,r,n=null){let o=0;const a=t.length,h=e.frame;for(;o<r;){let c=i[(s+o)*2],u=i[(s+o)*2+1];if(n){const d=n.a*c+n.c*u+n.tx;u=n.b*c+n.d*u+n.ty,c=d}o++,t.push(c/h.width,u/h.height)}const l=e.baseTexture;(h.width<l.width||h.height<l.height)&&this.adjustUvs(t,e,a,r)}adjustUvs(i,t,e,s){const r=t.baseTexture,n=1e-6,o=e+s*2,a=t.frame,h=a.width/r.width,l=a.height/r.height;let c=a.x/a.width,u=a.y/a.height,d=Math.floor(i[e]+n),f=Math.floor(i[e+1]+n);for(let p=e+2;p<o;p+=2)d=Math.min(d,Math.floor(i[p]+n)),f=Math.min(f,Math.floor(i[p+1]+n));c-=d,u-=f;for(let p=e;p<o;p+=2)i[p]=(i[p]+c)*h,i[p+1]=(i[p+1]+u)*l}};let rn=Ra;rn.BATCHABLE_SIZE=100;class vs extends gi{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=oe.BUTT,this.join=Qt.MITER,this.miterLimit=10}clone(){const t=new vs;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1}}const jf=new Float32Array(3),nn={},rs=class extends bt{constructor(i=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new gi,this._lineStyle=new vs,this._matrix=null,this._holeMode=!1,this.state=jt.for2d(),this._geometry=i||new rn,this._geometry.refCount++,this._transformID=-1,this.tint=16777215,this.blendMode=k.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new rs(this._geometry)}set blendMode(i){this.state.blendMode=i}get blendMode(){return this.state.blendMode}get tint(){return this._tint}set tint(i){this._tint=i}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(i=null,t=0,e=1,s=.5,r=!1){return typeof i=="number"&&(i={width:i,color:t,alpha:e,alignment:s,native:r}),this.lineTextureStyle(i)}lineTextureStyle(i){i=Object.assign({width:0,texture:B.WHITE,color:i!=null&&i.texture?16777215:0,alpha:1,matrix:null,alignment:.5,native:!1,cap:oe.BUTT,join:Qt.MITER,miterLimit:10},i),this.currentPath&&this.startPoly();const t=i.width>0&&i.alpha>0;return t?(i.matrix&&(i.matrix=i.matrix.clone(),i.matrix.invert()),Object.assign(this._lineStyle,{visible:t},i)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const i=this.currentPath.points,t=this.currentPath.points.length;t>2&&(this.drawShape(this.currentPath),this.currentPath=new we,this.currentPath.closeStroke=!1,this.currentPath.points.push(i[t-2],i[t-1]))}else this.currentPath=new we,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(i,t){return this.startPoly(),this.currentPath.points[0]=i,this.currentPath.points[1]=t,this}lineTo(i,t){this.currentPath||this.moveTo(0,0);const e=this.currentPath.points,s=e[e.length-2],r=e[e.length-1];return(s!==i||r!==t)&&e.push(i,t),this}_initCurve(i=0,t=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[i,t]):this.moveTo(i,t)}quadraticCurveTo(i,t,e,s){this._initCurve();const r=this.currentPath.points;return r.length===0&&this.moveTo(0,0),xs.curveTo(i,t,e,s,r),this}bezierCurveTo(i,t,e,s,r,n){return this._initCurve(),gs.curveTo(i,t,e,s,r,n,this.currentPath.points),this}arcTo(i,t,e,s,r){this._initCurve(i,t);const n=this.currentPath.points,o=en.curveTo(i,t,e,s,r,n);if(o){const{cx:a,cy:h,radius:l,startAngle:c,endAngle:u,anticlockwise:d}=o;this.arc(a,h,l,c,u,d)}return this}arc(i,t,e,s,r,n=!1){if(s===r)return this;if(!n&&r<=s?r+=He:n&&s<=r&&(s+=He),r-s===0)return this;const a=i+Math.cos(s)*e,h=t+Math.sin(s)*e,l=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-h);u<l&&d<l||c.push(a,h)}else this.moveTo(a,h),c=this.currentPath.points;return en.arc(a,h,i,t,e,s,r,n,c),this}beginFill(i=0,t=1){return this.beginTextureFill({texture:B.WHITE,color:i,alpha:t})}beginTextureFill(i){i=Object.assign({texture:B.WHITE,color:16777215,alpha:1,matrix:null},i),this.currentPath&&this.startPoly();const t=i.alpha>0;return t?(i.matrix&&(i.matrix=i.matrix.clone(),i.matrix.invert()),Object.assign(this._fillStyle,{visible:t},i)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(i,t,e,s){return this.drawShape(new V(i,t,e,s))}drawRoundedRect(i,t,e,s,r){return this.drawShape(new _s(i,t,e,s,r))}drawCircle(i,t,e){return this.drawShape(new ps(i,t,e))}drawEllipse(i,t,e,s){return this.drawShape(new ms(i,t,e,s))}drawPolygon(...i){let t,e=!0;const s=i[0];s.points?(e=s.closeStroke,t=s.points):Array.isArray(i[0])?t=i[0]:t=i;const r=new we(t);return r.closeStroke=e,this.drawShape(r),this}drawShape(i){return this._holeMode?this._geometry.drawHole(i,this._matrix):this._geometry.drawShape(i,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const i=this._geometry.graphicsData;return i.length===1&&i[0].shape.type===dt.RECT&&!i[0].matrix&&!i[0].holes.length&&!(i[0].lineStyle.visible&&i[0].lineStyle.width)}_render(i){this.finishPoly();const t=this._geometry;t.updateBatches(),t.batchable?(this.batchDirty!==t.batchDirty&&this._populateBatches(),this._renderBatched(i)):(i.batch.flush(),this._renderDirect(i))}_populateBatches(){const i=this._geometry,t=this.blendMode,e=i.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=i.batchDirty,this.batches.length=e,this.vertexData=new Float32Array(i.points);for(let s=0;s<e;s++){const r=i.batches[s],n=r.style.color,o=new Float32Array(this.vertexData.buffer,r.attribStart*4*2,r.attribSize*2),a=new Float32Array(i.uvsFloat32.buffer,r.attribStart*4*2,r.attribSize*2),h=new Uint16Array(i.indicesUint16.buffer,r.start*2,r.size),l={vertexData:o,blendMode:t,indices:h,uvs:a,_batchRGB:me(n),_tintRGB:n,_texture:r.style.texture,alpha:r.style.alpha,worldAlpha:1};this.batches[s]=l}}_renderBatched(i){if(!!this.batches.length){i.batch.setObjectRenderer(i.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let t=0,e=this.batches.length;t<e;t++){const s=this.batches[t];s.worldAlpha=this.worldAlpha*s.alpha,i.plugins[this.pluginName].render(s)}}}_renderDirect(i){const t=this._resolveDirectShader(i),e=this._geometry,s=this.tint,r=this.worldAlpha,n=t.uniforms,o=e.drawCalls;n.translationMatrix=this.transform.worldTransform,n.tint[0]=(s>>16&255)/255*r,n.tint[1]=(s>>8&255)/255*r,n.tint[2]=(s&255)/255*r,n.tint[3]=r,i.shader.bind(t),i.geometry.bind(e,t),i.state.set(this.state);for(let a=0,h=o.length;a<h;a++)this._renderDrawCallDirect(i,e.drawCalls[a])}_renderDrawCallDirect(i,t){const{texArray:e,type:s,size:r,start:n}=t,o=e.count;for(let a=0;a<o;a++)i.texture.bind(e.elements[a],a);i.geometry.draw(s,r,n)}_resolveDirectShader(i){let t=this.shader;const e=this.pluginName;if(!t){if(!nn[e]){const{MAX_TEXTURES:s}=i.plugins[e],r=new Int32Array(s);for(let a=0;a<s;a++)r[a]=a;const n={tint:new Float32Array([1,1,1,1]),translationMatrix:new et,default:Ct.from({uSamplers:r},!0)},o=i.plugins[e]._shader.program;nn[e]=new Ot(o,n)}t=nn[e]}return t}_calculateBounds(){this.finishPoly();const i=this._geometry;if(!i.graphicsData.length)return;const{minX:t,minY:e,maxX:s,maxY:r}=i.bounds;this._bounds.addFrame(this.transform,t,e,s,r)}containsPoint(i){return this.worldTransform.applyInverse(i,rs._TEMP_POINT),this._geometry.containsPoint(rs._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this.tint;const i=me(this.tint,jf);for(let t=0;t<this.batches.length;t++){const e=this.batches[t],s=e._batchRGB,r=i[0]*s[0]*255,n=i[1]*s[1]*255,o=i[2]*s[2]*255,a=(r<<16)+(n<<8)+(o|0);e._tintRGB=(a>>16)+(a&65280)+((a&255)<<16)}}}calculateVertices(){const i=this.transform._worldID;if(this._transformID===i)return;this._transformID=i;const t=this.transform.worldTransform,e=t.a,s=t.b,r=t.c,n=t.d,o=t.tx,a=t.ty,h=this._geometry.points,l=this.vertexData;let c=0;for(let u=0;u<h.length;u+=2){const d=h[u],f=h[u+1];l[c++]=e*d+r*f+o,l[c++]=n*f+s*d+a}}closePath(){const i=this.currentPath;return i&&(i.closeStroke=!0,this.finishPoly()),this}setMatrix(i){return this._matrix=i,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(i){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(i)}};let ns=rs;ns._TEMP_POINT=new j;const Yf={buildPoly:Jr,buildCircle:hi,buildRectangle:Ea,buildRoundedRectangle:wa,buildLine:tn,ArcUtils:en,BezierUtils:gs,QuadraticUtils:xs,BatchPart:Sa,FILL_COMMANDS:ss,BATCH_POOL:sn,DRAW_CALL_POOL:li};class Ca{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const on=new j,Ia=new we,Pa=class extends bt{constructor(i,t,e,s=It.TRIANGLES){super(),this.geometry=i,this.shader=t,this.state=e||jt.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=S.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(i){this._geometry!==i&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=i,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(i){this.shader=i}get material(){return this.shader}set blendMode(i){this.state.blendMode=i}get blendMode(){return this.state.blendMode}set roundPixels(i){this._roundPixels!==i&&(this._transformID=-1),this._roundPixels=i}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(i){this.shader.tint=i}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(i){this.shader.texture=i}_render(i){const t=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===It.TRIANGLES&&t.length<Pa.BATCHABLE_SIZE*2?this._renderToBatch(i):this._renderDefault(i)}_renderDefault(i){const t=this.shader;t.alpha=this.worldAlpha,t.update&&t.update(),i.batch.flush(),t.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),i.shader.bind(t),i.state.set(this.state),i.geometry.bind(this.geometry,t),i.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(i){const t=this.geometry,e=this.shader;e.uvMatrix&&(e.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=t.indexBuffer.data,this._tintRGB=e._tintRGB,this._texture=e.texture;const s=this.material.pluginName;i.batch.setObjectRenderer(i.plugins[s]),i.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,s=t._updateID;if(s===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const r=this.transform.worldTransform,n=r.a,o=r.b,a=r.c,h=r.d,l=r.tx,c=r.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+a*p+l,u[d*2+1]=o*f+h*p+c}if(this._roundPixels){const d=S.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round((u[f]*d|0)/d)}this.vertexDirty=s}calculateUvs(){const i=this.geometry.buffers[1],t=this.shader;t.uvMatrix.isSimple?this.uvs=i.data:(this.batchUvs||(this.batchUvs=new Ca(i,t.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(i){if(!this.getBounds().contains(i.x,i.y))return!1;this.worldTransform.applyInverse(i,on);const t=this.geometry.getBuffer("aVertexPosition").data,e=Ia.points,s=this.geometry.getIndex().data,r=s.length,n=this.drawMode===4?3:1;for(let o=0;o+2<r;o+=n){const a=s[o]*2,h=s[o+1]*2,l=s[o+2]*2;if(e[0]=t[a],e[1]=t[a+1],e[2]=t[h],e[3]=t[h+1],e[4]=t[l],e[5]=t[l+1],Ia.contains(on.x,on.y))return!0}return!1}destroy(i){super.destroy(i),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};let Ee=Pa;Ee.BATCHABLE_SIZE=100;var $f=`varying vec2 vTextureCoord;
890
+ };`};let jr;class yf{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 e=URL.createObjectURL(new Blob([xf.code],{type:"application/javascript"})),s=new Worker(e);s.addEventListener("message",r=>{s.terminate(),URL.revokeObjectURL(e),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Wr===void 0&&(Wr=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Wr&&(jr||(jr=URL.createObjectURL(new Blob([vf.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(jr),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[ta]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:ta++,id:s})}}const ea=new yf;function Qi(i,t){const e=i.split("?")[0],s=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s.toLowerCase()):s.toLowerCase()===t}function oi(i,t,e){const s=new B(i);return s.baseTexture.on("dispose",()=>{delete t.promiseCache[e]}),s}const Yr=[".jpg",".png",".jpeg",".avif",".webp"];async function ia(i){const t=await S.ADAPTER.fetch(i);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Ji={extension:{type:P.LoadParser,priority:Ft.High},config:{preferWorkers:!0},test(i){let t=!1;for(let e=0;e<Yr.length;e++)if(i.startsWith(`data:image/${Yr[e].slice(1)}`)){t=!0;break}return t||Qi(i,Yr)},async load(i,t,e){let s=null;globalThis.createImageBitmap?this.config.preferWorkers&&await ea.isImageBitmapSupported()?s=await ea.loadImageBitmap(i):s=await ia(i):s=await new Promise(n=>{s=new Image,s.crossOrigin="anonymous",s.src=i,s.complete?n(s):s.onload=()=>{n(s)}});const r=new W(s,Ht({resolution:qt(i)},t.data));return r.resource.src=i,oi(r,e,i)},unload(i){i.destroy(!0)}};U.add(Ji);const Tf={extension:{type:P.LoadParser,priority:Ft.High},test(i){return ft.extname(i).includes(".svg")},async testParse(i){return Be.test(i)},async parse(i,t,e){var o,a,h;const s=new Be(i,(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions),r=new W(s,Ht({resolution:qt(i)},t==null?void 0:t.data));r.resource.src=i;const n=oi(r,e,i);return(h=(a=t==null?void 0:t.data)==null?void 0:a.resourceOptions)!=null&&h.autoLoad||await s.load(),n},async load(i,t){return(await S.ADAPTER.fetch(i)).text()},unload:Ji.unload},sa={extension:P.ResolveParser,test:Ji.test,parse:i=>{var t,e;return{resolution:parseFloat((e=(t=S.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:i.split(".").pop(),src:i}}};U.add(sa);const ra={extension:{type:P.DetectionParser,priority:1},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=",t=await S.ADAPTER.fetch(i).then(e=>e.blob());return createImageBitmap(t).then(()=>!0,()=>!1)},add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")};U.add(ra);const na={extension:{type:P.DetectionParser,priority:0},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=",t=await S.ADAPTER.fetch(i).then(e=>e.blob());return createImageBitmap(t).then(()=>!0,()=>!1)},add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};U.add(na);const oa=["png","jpg","jpeg"],aa={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...oa],remove:async i=>i.filter(t=>!oa.includes(t))};U.add(aa);var vt=(i=>(i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i))(vt||{});const ai={[33776]:.5,[33777]:.5,[33778]:1,[33779]:1,[35916]:.5,[35917]:.5,[35918]:1,[35919]:1,[37488]:.5,[37489]:.5,[37490]:1,[37491]:1,[37492]:.5,[37496]:1,[37493]:.5,[37497]:1,[37494]:.5,[37495]:.5,[35840]:.5,[35842]:.5,[35841]:.25,[35843]:.25,[36196]:.5,[35986]:.5,[35986]:1,[34798]:1,[37808]:1};class ha extends Me{constructor(t,e={width:1,height:1,autoLoad:!0}){let s,r;typeof t=="string"?(s=t,r=new Uint8Array):(s=null,r=t),super(r,e),this.origin=s,this.buffer=r?new qi(r):null,this.origin&&e.autoLoad!==!1&&this.load(),r!=null&&r.length&&(this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}async load(){const s=await(await(await fetch(this.origin)).blob()).arrayBuffer();return this.data=new Uint32Array(s),this.buffer=new qi(s),this.loaded=!0,this.onBlobLoaded(s),this.update(),this}}class he extends ha{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=he._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||he._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,s){const r=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;for(let o=0,a=this.levels;o<a;o++){const{levelID:h,levelWidth:l,levelHeight:c,levelBuffer:u}=this._levelBuffers[o];r.compressedTexImage2D(r.TEXTURE_2D,h,this.format,l,c,0,u)}return!0}onBlobLoaded(){this._levelBuffers=he._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,s,r,n,o,a){const h=new Array(s);let l=t.byteOffset,c=o,u=a,d=c+r-1&~(r-1),f=u+n-1&~(n-1),p=d*f*ai[e];for(let m=0;m<s;m++)h[m]={levelID:m,levelWidth:s>1?c:d,levelHeight:s>1?u:f,levelBuffer:new Uint8Array(t.buffer,l,p)},l+=p,c=c>>1||1,u=u>>1||1,d=c+r-1&~(r-1),f=u+n-1&~(n-1),p=d*f*ai[e];return h}}let Zt,Fe;function la(){Fe={s3tc:Zt.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Zt.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:Zt.getExtension("WEBGL_compressed_texture_etc"),etc1:Zt.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:Zt.getExtension("WEBGL_compressed_texture_pvrtc")||Zt.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:Zt.getExtension("WEBGL_compressed_texture_atc"),astc:Zt.getExtension("WEBGL_compressed_texture_astc")}}const ca={extension:{type:P.DetectionParser,priority:2},test:async()=>{const t=S.ADAPTER.createCanvas().getContext("webgl");return t?(Zt=t,!0):!1},add:async i=>{Fe||la();const t=[];for(const e in Fe)!Fe[e]||t.push(e);return[...t,...i]},remove:async i=>(Fe||la(),i.filter(t=>!(t in Fe)))};U.add(ca);const $r=4,ts=124,bf=32,ua=20,Ef=542327876,es={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},wf={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},is={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var Af=(i=>(i[i.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",i[i.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",i[i.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",i[i.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",i[i.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",i[i.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",i[i.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",i[i.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",i[i.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",i[i.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",i[i.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",i[i.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",i[i.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",i[i.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",i[i.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",i[i.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",i[i.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",i[i.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",i[i.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",i[i.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",i[i.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",i[i.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",i[i.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",i[i.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",i[i.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",i[i.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",i[i.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",i[i.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",i[i.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",i[i.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",i[i.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",i[i.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",i[i.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",i[i.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",i[i.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",i[i.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",i[i.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",i[i.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",i[i.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",i[i.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",i[i.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",i[i.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",i[i.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",i[i.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",i[i.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",i[i.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",i[i.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",i[i.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",i[i.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",i[i.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",i[i.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",i[i.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",i[i.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",i[i.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",i[i.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",i[i.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",i[i.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",i[i.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",i[i.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",i[i.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",i[i.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",i[i.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",i[i.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",i[i.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",i[i.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",i[i.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",i[i.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",i[i.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",i[i.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",i[i.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",i[i.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",i[i.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",i[i.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",i[i.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",i[i.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",i[i.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",i[i.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",i[i.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",i[i.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",i[i.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",i[i.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",i[i.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",i[i.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",i[i.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",i[i.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",i[i.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",i[i.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",i[i.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",i[i.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",i[i.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",i[i.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",i[i.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",i[i.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",i[i.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",i[i.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",i[i.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",i[i.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",i[i.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",i[i.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",i[i.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",i[i.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",i[i.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",i[i.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",i[i.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",i[i.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",i[i.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",i[i.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",i[i.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",i[i.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",i[i.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",i[i.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",i[i.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",i[i.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",i[i.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",i[i.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",i[i.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",i[i.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",i[i.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",i[i.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",i[i.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",i[i.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",i[i.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",i))(Af||{}),Sf=(i=>(i[i.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",i[i.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",i[i.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D",i))(Sf||{});const Rf=1,Cf=2,If=4,Pf=64,Mf=512,Bf=131072,Df=827611204,Nf=861165636,Ff=894720068,Lf=808540228,Uf=4,Of={[Df]:vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Nf]:vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Ff]:vt.COMPRESSED_RGBA_S3TC_DXT5_EXT},kf={[70]:vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[71]:vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[73]:vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[74]:vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[76]:vt.COMPRESSED_RGBA_S3TC_DXT5_EXT,[77]:vt.COMPRESSED_RGBA_S3TC_DXT5_EXT,[72]:vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,[75]:vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,[78]:vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function da(i){const t=new Uint32Array(i);if(t[0]!==Ef)throw new Error("Invalid DDS file magic word");const s=new Uint32Array(i,0,ts/Uint32Array.BYTES_PER_ELEMENT),r=s[es.HEIGHT],n=s[es.WIDTH],o=s[es.MIPMAP_COUNT],a=new Uint32Array(i,es.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,bf/Uint32Array.BYTES_PER_ELEMENT),h=a[Rf];if(h&If){const l=a[wf.FOURCC];if(l!==Lf){const g=Of[l],v=$r+ts,b=new Uint8Array(i,v);return[new he(b,{format:g,width:n,height:r,levels:o})]}const c=$r+ts,u=new Uint32Array(t.buffer,c,ua/Uint32Array.BYTES_PER_ELEMENT),d=u[is.DXGI_FORMAT],f=u[is.RESOURCE_DIMENSION],p=u[is.MISC_FLAG],m=u[is.ARRAY_SIZE],_=kf[d];if(_===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${d}`);if(p===Uf)throw new Error("DDSParser does not support cubemap textures");if(f===6)throw new Error("DDSParser does not supported 3D texture data");const x=new Array,y=$r+ts+ua;if(m===1)x.push(new Uint8Array(i,y));else{const g=ai[_];let v=0,b=n,M=r;for(let w=0;w<o;w++){const L=Math.max(1,b+3&-4),G=Math.max(1,M+3&-4);v+=L*G*g,b=b>>>1,M=M>>>1}let R=y;for(let w=0;w<m;w++)x.push(new Uint8Array(i,R,v)),R+=v}return x.map(g=>new he(g,{format:_,width:n,height:r,levels:o}))}throw h&Pf?new Error("DDSParser does not support uncompressed texture data."):h&Mf?new Error("DDSParser does not supported YUV uncompressed texture data."):h&Bf?new Error("DDSParser does not support single-channel (lumninance) texture data!"):h&Cf?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const fa=[171,75,84,88,32,49,49,187,13,10,26,10],Gf=67305985,Lt={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},qr=64,Kr={[O.UNSIGNED_BYTE]:1,[O.UNSIGNED_SHORT]:2,[O.INT]:4,[O.UNSIGNED_INT]:4,[O.FLOAT]:4,[O.HALF_FLOAT]:8},pa={[C.RGBA]:4,[C.RGB]:3,[C.RG]:2,[C.RED]:1,[C.LUMINANCE]:1,[C.LUMINANCE_ALPHA]:2,[C.ALPHA]:1},ma={[O.UNSIGNED_SHORT_4_4_4_4]:2,[O.UNSIGNED_SHORT_5_5_5_1]:2,[O.UNSIGNED_SHORT_5_6_5]:2};function _a(i,t,e=!1){const s=new DataView(t);if(!Hf(i,s))return null;const r=s.getUint32(Lt.ENDIANNESS,!0)===Gf,n=s.getUint32(Lt.GL_TYPE,r),o=s.getUint32(Lt.GL_FORMAT,r),a=s.getUint32(Lt.GL_INTERNAL_FORMAT,r),h=s.getUint32(Lt.PIXEL_WIDTH,r),l=s.getUint32(Lt.PIXEL_HEIGHT,r)||1,c=s.getUint32(Lt.PIXEL_DEPTH,r)||1,u=s.getUint32(Lt.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=s.getUint32(Lt.NUMBER_OF_FACES,r),f=s.getUint32(Lt.NUMBER_OF_MIPMAP_LEVELS,r),p=s.getUint32(Lt.BYTES_OF_KEY_VALUE_DATA,r);if(l===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const m=4,_=4,x=h+3&-4,y=l+3&-4,g=new Array(u);let v=h*l;n===0&&(v=x*y);let b;if(n!==0?Kr[n]?b=Kr[n]*pa[o]:b=ma[n]:b=ai[a],b===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const M=e?Vf(s,p,r):null;let w=v*b,L=h,G=l,I=x,N=y,E=qr+p;for(let T=0;T<f;T++){const X=s.getUint32(E,r);let z=E+4;for(let D=0;D<u;D++){let $=g[D];$||($=g[D]=new Array(f)),$[T]={levelID:T,levelWidth:f>1||n!==0?L:I,levelHeight:f>1||n!==0?G:N,levelBuffer:new Uint8Array(t,z,w)},z+=w}E+=X+4,E=E%4!==0?E+4-E%4:E,L=L>>1||1,G=G>>1||1,I=L+m-1&~(m-1),N=G+_-1&~(_-1),w=I*N*b}return n!==0?{uncompressed:g.map(T=>{let X=T[0].levelBuffer,z=!1;return n===O.FLOAT?X=new Float32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4):n===O.UNSIGNED_INT?(z=!0,X=new Uint32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)):n===O.INT&&(z=!0,X=new Int32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)),{resource:new Me(X,{width:T[0].levelWidth,height:T[0].levelHeight}),type:n,format:z?Xf(o):o}}),kvData:M}:{compressed:g.map(T=>new he(null,{format:a,width:h,height:l,levels:f,levelBuffers:T})),kvData:M}}function Hf(i,t){for(let e=0;e<fa.length;e++)if(t.getUint8(e)!==fa[e])return!1;return!0}function Xf(i){switch(i){case C.RGBA:return C.RGBA_INTEGER;case C.RGB:return C.RGB_INTEGER;case C.RG:return C.RG_INTEGER;case C.RED:return C.RED_INTEGER;default:return i}}function Vf(i,t,e){const s=new Map;let r=0;for(;r<t;){const n=i.getUint32(qr+r,e),o=qr+r+4,a=3-(n+3)%4;if(n===0||n>t-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&i.getUint8(o+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=new TextDecoder().decode(new Uint8Array(i.buffer,o,h)),c=new DataView(i.buffer,o+h+1,n-h-1);s.set(l,c),r+=4+n+a}return s}const ga={extension:{type:P.LoadParser,priority:Ft.High},test(i){return Qi(i,".dds")},async load(i,t,e){const r=await(await S.ADAPTER.fetch(i)).arrayBuffer(),o=da(r).map(a=>{const h=new W(a,Ht({mipmap:Pt.OFF,alphaMode:Et.NO_PREMULTIPLIED_ALPHA,resolution:qt(i)},t.data));return oi(h,e,i)});return o.length===1?o[0]:o},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};U.add(ga);const xa={extension:{type:P.LoadParser,priority:Ft.High},test(i){return Qi(i,".ktx")},async load(i,t,e){const r=await(await S.ADAPTER.fetch(i)).arrayBuffer(),{compressed:n,uncompressed:o,kvData:a}=_a(i,r),h=n!=null?n:o,l=Ht({mipmap:Pt.OFF,alphaMode:Et.NO_PREMULTIPLIED_ALPHA,resolution:qt(i)},t.data),c=h.map(u=>{h===o&&Object.assign(l,{type:u.type,format:u.format});const d=new W(u,l);return d.ktxKeyValueData=a,oi(d,e,i)});return c.length===1?c[0]:c},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};U.add(xa);const va={extension:P.ResolveParser,test:i=>{const e=i.split("?")[0].split(".").pop();return["basis","ktx","dds"].includes(e)},parse:i=>{var s,r,n,o;if(i.split("?")[0].split(".").pop()==="ktx"){const a=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(a.some(h=>i.endsWith(h)))return{resolution:parseFloat((r=(s=S.RETINA_PREFIX.exec(i))==null?void 0:s[1])!=null?r:"1"),format:a.find(h=>i.endsWith(h)),src:i}}return{resolution:parseFloat((o=(n=S.RETINA_PREFIX.exec(i))==null?void 0:n[1])!=null?o:"1"),format:i.split(".").pop(),src:i}}};U.add(va);const ya=new V,Ta=4,Zr=class{constructor(i){this.renderer=i}async image(i,t,e){const s=new Image;return s.src=await this.base64(i,t,e),s}async base64(i,t,e){const s=this.canvas(i);if(s.toDataURL!==void 0)return s.toDataURL(t,e);if(s.convertToBlob!==void 0){const r=await s.convertToBlob({type:t,quality:e});return await new Promise(n=>{const o=new FileReader;o.onload=()=>n(o.result),o.readAsDataURL(r)})}throw new Error("Extract.base64() requires ICanvas.toDataURL or ICanvas.convertToBlob to be implemented")}canvas(i,t){const e=this.renderer;let s,r=!1,n,o=!1;i&&(i instanceof te?n=i:(n=this.renderer.generateTexture(i),o=!0)),n?(s=n.baseTexture.resolution,t=t!=null?t:n.frame,r=!1,e.renderTexture.bind(n)):(s=e.resolution,t||(t=ya,t.width=e.width,t.height=e.height),r=!0,e.renderTexture.bind(null));const a=Math.round(t.width*s),h=Math.round(t.height*s);let l=new Ws(a,h,1);const c=new Uint8Array(Ta*a*h),u=e.gl;u.readPixels(Math.round(t.x*s),Math.round(t.y*s),a,h,u.RGBA,u.UNSIGNED_BYTE,c);const d=l.context.getImageData(0,0,a,h);if(Zr.arrayPostDivide(c,d.data),l.context.putImageData(d,0,0),r){const f=new Ws(l.width,l.height,1);f.context.scale(1,-1),f.context.drawImage(l.canvas,0,-h),l.destroy(),l=f}return o&&n.destroy(!0),l.canvas}pixels(i,t){const e=this.renderer;let s,r,n=!1;i&&(i instanceof te?r=i:(r=this.renderer.generateTexture(i),n=!0)),r?(s=r.baseTexture.resolution,t=t!=null?t:r.frame,e.renderTexture.bind(r)):(s=e.resolution,t||(t=ya,t.width=e.width,t.height=e.height),e.renderTexture.bind(null));const o=Math.round(t.width*s),a=Math.round(t.height*s),h=new Uint8Array(Ta*o*a),l=e.gl;return l.readPixels(Math.round(t.x*s),Math.round(t.y*s),o,a,l.RGBA,l.UNSIGNED_BYTE,h),n&&r.destroy(!0),Zr.arrayPostDivide(h,h),h}destroy(){this.renderer=null}static arrayPostDivide(i,t){for(let e=0;e<i.length;e+=4){const s=t[e+3]=i[e+3];s!==0?(t[e]=Math.round(Math.min(i[e]*255/s,255)),t[e+1]=Math.round(Math.min(i[e+1]*255/s,255)),t[e+2]=Math.round(Math.min(i[e+2]*255/s,255))):(t[e]=i[e],t[e+1]=i[e+1],t[e+2]=i[e+2])}}};let Qr=Zr;Qr.extension={name:"extract",type:P.RendererSystem},U.add(Qr);var Qt=(i=>(i.MITER="miter",i.BEVEL="bevel",i.ROUND="round",i))(Qt||{}),oe=(i=>(i.BUTT="butt",i.ROUND="round",i.SQUARE="square",i))(oe||{});const Le={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(i,t=20){if(!this.adaptive||!i||isNaN(i))return t;let e=Math.ceil(i/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class gi{constructor(){this.color=16777215,this.alpha=1,this.texture=B.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new gi;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=B.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}function ba(i,t=!1){const e=i.length;if(e<6)return;let s=0;for(let r=0,n=i[e-2],o=i[e-1];r<e;r+=2){const a=i[r],h=i[r+1];s+=(a-n)*(h+o),n=a,o=h}if(!t&&s>0||t&&s<=0){const r=e/2;for(let n=r+r%2;n<e;n+=2){const o=e-n-2,a=e-n-1,h=n,l=n+1;[i[o],i[h]]=[i[h],i[o]],[i[a],i[l]]=[i[l],i[a]]}}}const Jr={build(i){i.points=i.shape.points.slice()},triangulate(i,t){let e=i.points;const s=i.holes,r=t.points,n=t.indices;if(e.length>=6){ba(e,!1);const o=[];for(let l=0;l<s.length;l++){const c=s[l];ba(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=Ps(e,o,2);if(!a)return;const h=r.length/2;for(let l=0;l<a.length;l+=3)n.push(a[l]+h),n.push(a[l+1]+h),n.push(a[l+2]+h);for(let l=0;l<e.length;l++)r.push(e[l])}}},hi={build(i){const t=i.points;let e,s,r,n,o,a;if(i.type===dt.CIRC){const p=i.shape;e=p.x,s=p.y,o=a=p.radius,r=n=0}else if(i.type===dt.ELIP){const p=i.shape;e=p.x,s=p.y,o=p.width,a=p.height,r=n=0}else{const p=i.shape,m=p.width/2,_=p.height/2;e=p.x+m,s=p.y+_,o=a=Math.max(0,Math.min(p.radius,Math.min(m,_))),r=m-o,n=_-a}if(!(o>=0&&a>=0&&r>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(t.length=l,l===0)return;if(h===0){t.length=8,t[0]=t[6]=e+r,t[1]=t[3]=s+n,t[2]=t[4]=e-r,t[5]=t[7]=s-n;return}let c=0,u=h*4+(r?2:0)+2,d=u,f=l;{const p=r+o,m=n,_=e+p,x=e-p,y=s+m;if(t[c++]=_,t[c++]=y,t[--u]=y,t[--u]=x,n){const g=s-m;t[d++]=x,t[d++]=g,t[--f]=g,t[--f]=_}}for(let p=1;p<h;p++){const m=Math.PI/2*(p/h),_=r+Math.cos(m)*o,x=n+Math.sin(m)*a,y=e+_,g=e-_,v=s+x,b=s-x;t[c++]=y,t[c++]=v,t[--u]=v,t[--u]=g,t[d++]=g,t[d++]=b,t[--f]=b,t[--f]=y}{const p=r,m=n+a,_=e+p,x=e-p,y=s+m,g=s-m;t[c++]=_,t[c++]=y,t[--f]=g,t[--f]=_,r&&(t[c++]=x,t[c++]=y,t[--f]=g,t[--f]=x)}},triangulate(i,t){const e=i.points,s=t.points,r=t.indices;if(e.length===0)return;let n=s.length/2;const o=n;let a,h;if(i.type!==dt.RREC){const c=i.shape;a=c.x,h=c.y}else{const c=i.shape;a=c.x+c.width/2,h=c.y+c.height/2}const l=i.matrix;s.push(i.matrix?l.a*a+l.c*h+l.tx:a,i.matrix?l.b*a+l.d*h+l.ty:h),n++,s.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)s.push(e[c],e[c+1]),r.push(n++,o,n);r.push(o+1,o,n)}},Ea={build(i){const t=i.shape,e=t.x,s=t.y,r=t.width,n=t.height,o=i.points;o.length=0,r>=0&&n>=0&&o.push(e,s,e+r,s,e+r,s+n,e,s+n)},triangulate(i,t){const e=i.points,s=t.points;if(e.length===0)return;const r=s.length/2;s.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(r,r+1,r+2,r+1,r+2,r+3)}},wa={build(i){hi.build(i)},triangulate(i,t){hi.triangulate(i,t)}};function Aa(i,t,e,s,r,n,o,a){const h=i-e*r,l=t-s*r,c=i+e*n,u=t+s*n;let d,f;o?(d=s,f=-e):(d=-s,f=e);const p=h+d,m=l+f,_=c+d,x=u+f;return a.push(p,m),a.push(_,x),2}function be(i,t,e,s,r,n,o,a){const h=e-i,l=s-t;let c=Math.atan2(h,l),u=Math.atan2(r-i,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(h*h+l*l),_=(15*p*Math.sqrt(m)/Math.PI>>0)+1,x=f/_;if(d+=x,a){o.push(i,t),o.push(e,s);for(let y=1,g=d;y<_;y++,g+=x)o.push(i,t),o.push(i+Math.sin(g)*m,t+Math.cos(g)*m);o.push(i,t),o.push(r,n)}else{o.push(e,s),o.push(i,t);for(let y=1,g=d;y<_;y++,g+=x)o.push(i+Math.sin(g)*m,t+Math.cos(g)*m),o.push(i,t);o.push(r,n),o.push(i,t)}return _*2}function zf(i,t){const e=i.shape;let s=i.points||e.points.slice();const r=t.closePointEps;if(s.length===0)return;const n=i.lineStyle,o=new j(s[0],s[1]),a=new j(s[s.length-2],s[s.length-1]),h=e.type!==dt.POLY||e.closeStroke,l=Math.abs(o.x-a.x)<r&&Math.abs(o.y-a.y)<r;if(h){s=s.slice(),l&&(s.pop(),s.pop(),a.set(s[s.length-2],s[s.length-1]));const D=(o.x+a.x)*.5,$=(a.y+o.y)*.5;s.unshift(D,$),s.push(D,$)}const c=t.points,u=s.length/2;let d=s.length;const f=c.length/2,p=n.width/2,m=p*p,_=n.miterLimit*n.miterLimit;let x=s[0],y=s[1],g=s[2],v=s[3],b=0,M=0,R=-(y-v),w=x-g,L=0,G=0,I=Math.sqrt(R*R+w*w);R/=I,w/=I,R*=p,w*=p;const N=n.alignment,E=(1-N)*2,T=N*2;h||(n.cap===oe.ROUND?d+=be(x-R*(E-T)*.5,y-w*(E-T)*.5,x-R*E,y-w*E,x+R*T,y+w*T,c,!0)+2:n.cap===oe.SQUARE&&(d+=Aa(x,y,R,w,E,T,!0,c))),c.push(x-R*E,y-w*E),c.push(x+R*T,y+w*T);for(let D=1;D<u-1;++D){x=s[(D-1)*2],y=s[(D-1)*2+1],g=s[D*2],v=s[D*2+1],b=s[(D+1)*2],M=s[(D+1)*2+1],R=-(y-v),w=x-g,I=Math.sqrt(R*R+w*w),R/=I,w/=I,R*=p,w*=p,L=-(v-M),G=g-b,I=Math.sqrt(L*L+G*G),L/=I,G/=I,L*=p,G*=p;const $=g-x,st=y-v,A=g-b,H=M-v,Y=$*A+st*H,q=st*A-H*$,K=q<0;if(Math.abs(q)<.001*Math.abs(Y)){c.push(g-R*E,v-w*E),c.push(g+R*T,v+w*T),Y>=0&&(n.join===Qt.ROUND?d+=be(g,v,g-R*E,v-w*E,g-L*E,v-G*E,c,!1)+4:d+=2,c.push(g-L*T,v-G*T),c.push(g+L*E,v+G*E));continue}const ct=(-R+x)*(-w+v)-(-R+g)*(-w+y),ot=(-L+b)*(-G+v)-(-L+g)*(-G+M),ut=($*ot-A*ct)/q,mt=(H*ct-st*ot)/q,gt=(ut-g)*(ut-g)+(mt-v)*(mt-v),pt=g+(ut-g)*E,Q=v+(mt-v)*E,at=g-(ut-g)*T,lt=v-(mt-v)*T,kt=Math.min($*$+st*st,A*A+H*H),Gt=K?E:T,Ge=kt+Gt*Gt*m;gt<=Ge?n.join===Qt.BEVEL||gt/m>_?(K?(c.push(pt,Q),c.push(g+R*T,v+w*T),c.push(pt,Q),c.push(g+L*T,v+G*T)):(c.push(g-R*E,v-w*E),c.push(at,lt),c.push(g-L*E,v-G*E),c.push(at,lt)),d+=2):n.join===Qt.ROUND?K?(c.push(pt,Q),c.push(g+R*T,v+w*T),d+=be(g,v,g+R*T,v+w*T,g+L*T,v+G*T,c,!0)+4,c.push(pt,Q),c.push(g+L*T,v+G*T)):(c.push(g-R*E,v-w*E),c.push(at,lt),d+=be(g,v,g-R*E,v-w*E,g-L*E,v-G*E,c,!1)+4,c.push(g-L*E,v-G*E),c.push(at,lt)):(c.push(pt,Q),c.push(at,lt)):(c.push(g-R*E,v-w*E),c.push(g+R*T,v+w*T),n.join===Qt.ROUND?K?d+=be(g,v,g+R*T,v+w*T,g+L*T,v+G*T,c,!0)+2:d+=be(g,v,g-R*E,v-w*E,g-L*E,v-G*E,c,!1)+2:n.join===Qt.MITER&&gt/m<=_&&(K?(c.push(at,lt),c.push(at,lt)):(c.push(pt,Q),c.push(pt,Q)),d+=2),c.push(g-L*E,v-G*E),c.push(g+L*T,v+G*T),d+=2)}x=s[(u-2)*2],y=s[(u-2)*2+1],g=s[(u-1)*2],v=s[(u-1)*2+1],R=-(y-v),w=x-g,I=Math.sqrt(R*R+w*w),R/=I,w/=I,R*=p,w*=p,c.push(g-R*E,v-w*E),c.push(g+R*T,v+w*T),h||(n.cap===oe.ROUND?d+=be(g-R*(E-T)*.5,v-w*(E-T)*.5,g-R*E,v-w*E,g+R*T,v+w*T,c,!1)+2:n.cap===oe.SQUARE&&(d+=Aa(g,v,R,w,E,T,!1,c)));const X=t.indices,z=Le.epsilon*Le.epsilon;for(let D=f;D<d+f-2;++D)x=c[D*2],y=c[D*2+1],g=c[(D+1)*2],v=c[(D+1)*2+1],b=c[(D+2)*2],M=c[(D+2)*2+1],!(Math.abs(x*(v-M)+g*(M-y)+b*(y-v))<z)&&X.push(D,D+1,D+2)}function Wf(i,t){let e=0;const s=i.shape,r=i.points||s.points,n=s.type!==dt.POLY||s.closeStroke;if(r.length===0)return;const o=t.points,a=t.indices,h=r.length/2,l=o.length/2;let c=l;for(o.push(r[0],r[1]),e=1;e<h;e++)o.push(r[e*2],r[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,l)}function tn(i,t){i.lineStyle.native?Wf(i,t):zf(i,t)}class en{static curveTo(t,e,s,r,n,o){const a=o[o.length-2],l=o[o.length-1]-e,c=a-t,u=r-e,d=s-t,f=Math.abs(l*d-c*u);if(f<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const p=l*l+c*c,m=u*u+d*d,_=l*u+c*d,x=n*Math.sqrt(p)/f,y=n*Math.sqrt(m)/f,g=x*_/p,v=y*_/m,b=x*d+y*c,M=x*u+y*l,R=c*(y+g),w=l*(y+g),L=d*(x+v),G=u*(x+v),I=Math.atan2(w-M,R-b),N=Math.atan2(G-M,L-b);return{cx:b+t,cy:M+e,radius:n,startAngle:I,endAngle:N,anticlockwise:c*u>d*l}}static arc(t,e,s,r,n,o,a,h,l){const c=a-o,u=Le._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/He)*40),d=c/(u*2),f=d*2,p=Math.cos(d),m=Math.sin(d),_=u-1,x=_%1/_;for(let y=0;y<=_;++y){const g=y+x*y,v=d+o+f*g,b=Math.cos(v),M=-Math.sin(v);l.push((p*b+m*M)*n+s,(p*-M+m*b)*n+r)}}}class gs{static curveLength(t,e,s,r,n,o,a,h){let c=0,u=0,d=0,f=0,p=0,m=0,_=0,x=0,y=0,g=0,v=0,b=t,M=e;for(let R=1;R<=10;++R)u=R/10,d=u*u,f=d*u,p=1-u,m=p*p,_=m*p,x=_*t+3*m*u*s+3*p*d*n+f*a,y=_*e+3*m*u*r+3*p*d*o+f*h,g=b-x,v=M-y,b=x,M=y,c+=Math.sqrt(g*g+v*v);return c}static curveTo(t,e,s,r,n,o,a){const h=a[a.length-2],l=a[a.length-1];a.length-=2;const c=Le._segmentsCount(gs.curveLength(h,l,t,e,s,r,n,o));let u=0,d=0,f=0,p=0,m=0;a.push(h,l);for(let _=1,x=0;_<=c;++_)x=_/c,u=1-x,d=u*u,f=d*u,p=x*x,m=p*x,a.push(f*h+3*d*x*t+3*u*p*s+m*n,f*l+3*d*x*e+3*u*p*r+m*o)}}class xs{static curveLength(t,e,s,r,n,o){const a=t-2*s+n,h=e-2*r+o,l=2*s-2*t,c=2*r-2*e,u=4*(a*a+h*h),d=4*(a*l+h*c),f=l*l+c*c,p=2*Math.sqrt(u+d+f),m=Math.sqrt(u),_=2*u*m,x=2*Math.sqrt(f),y=d/m;return(_*p+m*d*(p-x)+(4*f*u-d*d)*Math.log((2*m+y+p)/(y+x)))/(4*_)}static curveTo(t,e,s,r,n){const o=n[n.length-2],a=n[n.length-1],h=Le._segmentsCount(xs.curveLength(o,a,t,e,s,r));let l=0,c=0;for(let u=1;u<=h;++u){const d=u/h;l=o+(t-o)*d,c=a+(e-a)*d,n.push(l+(t+(s-t)*d-l)*d,c+(e+(r-e)*d-c)*d)}}}class Sa{constructor(){this.reset()}begin(t,e,s){this.reset(),this.style=t,this.start=e,this.attribStart=s}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}const ss={[dt.POLY]:Jr,[dt.CIRC]:hi,[dt.ELIP]:hi,[dt.RECT]:Ea,[dt.RREC]:wa},sn=[],li=[];class xi{constructor(t,e=null,s=null,r=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=s,this.fillStyle=e,this.matrix=r,this.type=t.type}clone(){return new xi(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Ue=new j,Ra=class extends Dr{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new ei,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let i=0;i<this.drawCalls.length;i++)this.drawCalls[i].texArray.clear(),li.push(this.drawCalls[i]);this.drawCalls.length=0;for(let i=0;i<this.batches.length;i++){const t=this.batches[i];t.reset(),sn.push(t)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(i,t=null,e=null,s=null){const r=new xi(i,t,e,s);return this.graphicsData.push(r),this.dirty++,this}drawHole(i,t=null){if(!this.graphicsData.length)return null;const e=new xi(i,null,null,t),s=this.graphicsData[this.graphicsData.length-1];return e.lineStyle=s.lineStyle,s.holes.push(e),this.dirty++,this}destroy(){super.destroy();for(let i=0;i<this.graphicsData.length;++i)this.graphicsData[i].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(i){const t=this.graphicsData;for(let e=0;e<t.length;++e){const s=t[e];if(!!s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(i,Ue):Ue.copyFrom(i),s.shape.contains(Ue.x,Ue.y))){let r=!1;if(s.holes){for(let n=0;n<s.holes.length;n++)if(s.holes[n].shape.contains(Ue.x,Ue.y)){r=!0;break}}if(!r)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const i=this.uvs,t=this.graphicsData;let e=null,s=null;this.batches.length>0&&(e=this.batches[this.batches.length-1],s=e.style);for(let a=this.shapeIndex;a<t.length;a++){this.shapeIndex++;const h=t[a],l=h.fillStyle,c=h.lineStyle;ss[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(l.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?l:c;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,_=this.points.length/2;p.wrapMode=Vt.REPEAT,d===0?this.processFill(h):this.processLine(h);const x=this.points.length/2-_;x!==0&&(e&&!this._compareStyles(s,f)&&(e.end(m,_),e=null),e||(e=sn.pop()||new Sa,e.begin(f,m,_),this.batches.push(e),s=f),this.addUvs(this.points,i,f.texture,_,x,f.matrix))}}const r=this.indices.length,n=this.points.length/2;if(e&&e.end(r,n),this.batches.length===0){this.batchable=!0;return}const o=n>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(i,t){return!(!i||!t||i.texture.baseTexture!==t.texture.baseTexture||i.color+i.alpha!==t.color+t.alpha||!!i.native!=!!t.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let i=0,t=this.graphicsData.length;i<t;i++){const e=this.graphicsData[i],s=e.fillStyle,r=e.lineStyle;if(s&&!s.texture.baseTexture.valid||r&&!r.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const i=this.batches;for(let t=0,e=i.length;t<e;t++){const s=i[t];for(let r=0;r<s.size;r++){const n=s.start+r;this.indicesUint16[n]=this.indicesUint16[n]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const i=this.batches;for(let t=0;t<i.length;t++)if(i[t].style.native)return!1;return this.points.length<Ra.BATCHABLE_SIZE*2}buildDrawCalls(){let i=++W._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),li.push(this.drawCalls[c]);this.drawCalls.length=0;const t=this.colors,e=this.textureIds;let s=li.pop();s||(s=new Yi,s.texArray=new $i),s.texArray.count=0,s.start=0,s.size=0,s.type=It.TRIANGLES;let r=0,n=null,o=0,a=!1,h=It.TRIANGLES,l=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const u=this.batches[c],d=8,f=u.style,p=f.texture.baseTexture;a!==!!f.native&&(a=!!f.native,h=a?It.LINES:It.TRIANGLES,n=null,r=d,i++),n!==p&&(n=p,p._batchEnabled!==i&&(r===d&&(i++,r=0,s.size>0&&(s=li.pop(),s||(s=new Yi,s.texArray=new $i),this.drawCalls.push(s)),s.start=l,s.size=0,s.texArray.count=0,s.type=h),p.touched=1,p._batchEnabled=i,p._batchLocation=r,p.wrapMode=Vt.REPEAT,s.texArray.elements[s.texArray.count++]=p,r++)),s.size+=u.size,l+=u.size,o=p._batchLocation,this.addColors(t,f.color,f.alpha,u.attribSize,u.attribStart),this.addTextureIds(e,o,u.attribSize,u.attribStart)}W._globalBatch=i,this.packAttributes()}packAttributes(){const i=this.points,t=this.uvs,e=this.colors,s=this.textureIds,r=new ArrayBuffer(i.length*3*4),n=new Float32Array(r),o=new Uint32Array(r);let a=0;for(let h=0;h<i.length/2;h++)n[a++]=i[h*2],n[a++]=i[h*2+1],n[a++]=t[h*2],n[a++]=t[h*2+1],o[a++]=e[h],n[a++]=s[h];this._buffer.update(r),this._indexBuffer.update(this.indicesUint16)}processFill(i){i.holes.length?Jr.triangulate(i,this):ss[i.type].triangulate(i,this)}processLine(i){tn(i,this);for(let t=0;t<i.holes.length;t++)tn(i.holes[t],this)}processHoles(i){for(let t=0;t<i.length;t++){const e=i[t];ss[e.type].build(e),e.matrix&&this.transformPoints(e.points,e.matrix)}}calculateBounds(){const i=this._bounds;i.clear(),i.addVertexData(this.points,0,this.points.length),i.pad(this.boundsPadding,this.boundsPadding)}transformPoints(i,t){for(let e=0;e<i.length/2;e++){const s=i[e*2],r=i[e*2+1];i[e*2]=t.a*s+t.c*r+t.tx,i[e*2+1]=t.b*s+t.d*r+t.ty}}addColors(i,t,e,s,r=0){const n=(t>>16)+(t&65280)+((t&255)<<16),o=Mi(n,e);i.length=Math.max(i.length,r+s);for(let a=0;a<s;a++)i[r+a]=o}addTextureIds(i,t,e,s=0){i.length=Math.max(i.length,s+e);for(let r=0;r<e;r++)i[s+r]=t}addUvs(i,t,e,s,r,n=null){let o=0;const a=t.length,h=e.frame;for(;o<r;){let c=i[(s+o)*2],u=i[(s+o)*2+1];if(n){const d=n.a*c+n.c*u+n.tx;u=n.b*c+n.d*u+n.ty,c=d}o++,t.push(c/h.width,u/h.height)}const l=e.baseTexture;(h.width<l.width||h.height<l.height)&&this.adjustUvs(t,e,a,r)}adjustUvs(i,t,e,s){const r=t.baseTexture,n=1e-6,o=e+s*2,a=t.frame,h=a.width/r.width,l=a.height/r.height;let c=a.x/a.width,u=a.y/a.height,d=Math.floor(i[e]+n),f=Math.floor(i[e+1]+n);for(let p=e+2;p<o;p+=2)d=Math.min(d,Math.floor(i[p]+n)),f=Math.min(f,Math.floor(i[p+1]+n));c-=d,u-=f;for(let p=e;p<o;p+=2)i[p]=(i[p]+c)*h,i[p+1]=(i[p+1]+u)*l}};let rn=Ra;rn.BATCHABLE_SIZE=100;class vs extends gi{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=oe.BUTT,this.join=Qt.MITER,this.miterLimit=10}clone(){const t=new vs;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1}}const jf=new Float32Array(3),nn={},rs=class extends bt{constructor(i=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new gi,this._lineStyle=new vs,this._matrix=null,this._holeMode=!1,this.state=jt.for2d(),this._geometry=i||new rn,this._geometry.refCount++,this._transformID=-1,this.tint=16777215,this.blendMode=k.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new rs(this._geometry)}set blendMode(i){this.state.blendMode=i}get blendMode(){return this.state.blendMode}get tint(){return this._tint}set tint(i){this._tint=i}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(i=null,t=0,e=1,s=.5,r=!1){return typeof i=="number"&&(i={width:i,color:t,alpha:e,alignment:s,native:r}),this.lineTextureStyle(i)}lineTextureStyle(i){i=Object.assign({width:0,texture:B.WHITE,color:i!=null&&i.texture?16777215:0,alpha:1,matrix:null,alignment:.5,native:!1,cap:oe.BUTT,join:Qt.MITER,miterLimit:10},i),this.currentPath&&this.startPoly();const t=i.width>0&&i.alpha>0;return t?(i.matrix&&(i.matrix=i.matrix.clone(),i.matrix.invert()),Object.assign(this._lineStyle,{visible:t},i)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const i=this.currentPath.points,t=this.currentPath.points.length;t>2&&(this.drawShape(this.currentPath),this.currentPath=new we,this.currentPath.closeStroke=!1,this.currentPath.points.push(i[t-2],i[t-1]))}else this.currentPath=new we,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(i,t){return this.startPoly(),this.currentPath.points[0]=i,this.currentPath.points[1]=t,this}lineTo(i,t){this.currentPath||this.moveTo(0,0);const e=this.currentPath.points,s=e[e.length-2],r=e[e.length-1];return(s!==i||r!==t)&&e.push(i,t),this}_initCurve(i=0,t=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[i,t]):this.moveTo(i,t)}quadraticCurveTo(i,t,e,s){this._initCurve();const r=this.currentPath.points;return r.length===0&&this.moveTo(0,0),xs.curveTo(i,t,e,s,r),this}bezierCurveTo(i,t,e,s,r,n){return this._initCurve(),gs.curveTo(i,t,e,s,r,n,this.currentPath.points),this}arcTo(i,t,e,s,r){this._initCurve(i,t);const n=this.currentPath.points,o=en.curveTo(i,t,e,s,r,n);if(o){const{cx:a,cy:h,radius:l,startAngle:c,endAngle:u,anticlockwise:d}=o;this.arc(a,h,l,c,u,d)}return this}arc(i,t,e,s,r,n=!1){if(s===r)return this;if(!n&&r<=s?r+=He:n&&s<=r&&(s+=He),r-s===0)return this;const a=i+Math.cos(s)*e,h=t+Math.sin(s)*e,l=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-h);u<l&&d<l||c.push(a,h)}else this.moveTo(a,h),c=this.currentPath.points;return en.arc(a,h,i,t,e,s,r,n,c),this}beginFill(i=0,t=1){return this.beginTextureFill({texture:B.WHITE,color:i,alpha:t})}beginTextureFill(i){i=Object.assign({texture:B.WHITE,color:16777215,alpha:1,matrix:null},i),this.currentPath&&this.startPoly();const t=i.alpha>0;return t?(i.matrix&&(i.matrix=i.matrix.clone(),i.matrix.invert()),Object.assign(this._fillStyle,{visible:t},i)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(i,t,e,s){return this.drawShape(new V(i,t,e,s))}drawRoundedRect(i,t,e,s,r){return this.drawShape(new _s(i,t,e,s,r))}drawCircle(i,t,e){return this.drawShape(new ps(i,t,e))}drawEllipse(i,t,e,s){return this.drawShape(new ms(i,t,e,s))}drawPolygon(...i){let t,e=!0;const s=i[0];s.points?(e=s.closeStroke,t=s.points):Array.isArray(i[0])?t=i[0]:t=i;const r=new we(t);return r.closeStroke=e,this.drawShape(r),this}drawShape(i){return this._holeMode?this._geometry.drawHole(i,this._matrix):this._geometry.drawShape(i,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const i=this._geometry.graphicsData;return i.length===1&&i[0].shape.type===dt.RECT&&!i[0].matrix&&!i[0].holes.length&&!(i[0].lineStyle.visible&&i[0].lineStyle.width)}_render(i){this.finishPoly();const t=this._geometry;t.updateBatches(),t.batchable?(this.batchDirty!==t.batchDirty&&this._populateBatches(),this._renderBatched(i)):(i.batch.flush(),this._renderDirect(i))}_populateBatches(){const i=this._geometry,t=this.blendMode,e=i.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=i.batchDirty,this.batches.length=e,this.vertexData=new Float32Array(i.points);for(let s=0;s<e;s++){const r=i.batches[s],n=r.style.color,o=new Float32Array(this.vertexData.buffer,r.attribStart*4*2,r.attribSize*2),a=new Float32Array(i.uvsFloat32.buffer,r.attribStart*4*2,r.attribSize*2),h=new Uint16Array(i.indicesUint16.buffer,r.start*2,r.size),l={vertexData:o,blendMode:t,indices:h,uvs:a,_batchRGB:me(n),_tintRGB:n,_texture:r.style.texture,alpha:r.style.alpha,worldAlpha:1};this.batches[s]=l}}_renderBatched(i){if(!!this.batches.length){i.batch.setObjectRenderer(i.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let t=0,e=this.batches.length;t<e;t++){const s=this.batches[t];s.worldAlpha=this.worldAlpha*s.alpha,i.plugins[this.pluginName].render(s)}}}_renderDirect(i){const t=this._resolveDirectShader(i),e=this._geometry,s=this.tint,r=this.worldAlpha,n=t.uniforms,o=e.drawCalls;n.translationMatrix=this.transform.worldTransform,n.tint[0]=(s>>16&255)/255*r,n.tint[1]=(s>>8&255)/255*r,n.tint[2]=(s&255)/255*r,n.tint[3]=r,i.shader.bind(t),i.geometry.bind(e,t),i.state.set(this.state);for(let a=0,h=o.length;a<h;a++)this._renderDrawCallDirect(i,e.drawCalls[a])}_renderDrawCallDirect(i,t){const{texArray:e,type:s,size:r,start:n}=t,o=e.count;for(let a=0;a<o;a++)i.texture.bind(e.elements[a],a);i.geometry.draw(s,r,n)}_resolveDirectShader(i){let t=this.shader;const e=this.pluginName;if(!t){if(!nn[e]){const{MAX_TEXTURES:s}=i.plugins[e],r=new Int32Array(s);for(let a=0;a<s;a++)r[a]=a;const n={tint:new Float32Array([1,1,1,1]),translationMatrix:new et,default:Ct.from({uSamplers:r},!0)},o=i.plugins[e]._shader.program;nn[e]=new Ot(o,n)}t=nn[e]}return t}_calculateBounds(){this.finishPoly();const i=this._geometry;if(!i.graphicsData.length)return;const{minX:t,minY:e,maxX:s,maxY:r}=i.bounds;this._bounds.addFrame(this.transform,t,e,s,r)}containsPoint(i){return this.worldTransform.applyInverse(i,rs._TEMP_POINT),this._geometry.containsPoint(rs._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this.tint;const i=me(this.tint,jf);for(let t=0;t<this.batches.length;t++){const e=this.batches[t],s=e._batchRGB,r=i[0]*s[0]*255,n=i[1]*s[1]*255,o=i[2]*s[2]*255,a=(r<<16)+(n<<8)+(o|0);e._tintRGB=(a>>16)+(a&65280)+((a&255)<<16)}}}calculateVertices(){const i=this.transform._worldID;if(this._transformID===i)return;this._transformID=i;const t=this.transform.worldTransform,e=t.a,s=t.b,r=t.c,n=t.d,o=t.tx,a=t.ty,h=this._geometry.points,l=this.vertexData;let c=0;for(let u=0;u<h.length;u+=2){const d=h[u],f=h[u+1];l[c++]=e*d+r*f+o,l[c++]=n*f+s*d+a}}closePath(){const i=this.currentPath;return i&&(i.closeStroke=!0,this.finishPoly()),this}setMatrix(i){return this._matrix=i,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(i){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(i)}};let ns=rs;ns._TEMP_POINT=new j;const Yf={buildPoly:Jr,buildCircle:hi,buildRectangle:Ea,buildRoundedRectangle:wa,buildLine:tn,ArcUtils:en,BezierUtils:gs,QuadraticUtils:xs,BatchPart:Sa,FILL_COMMANDS:ss,BATCH_POOL:sn,DRAW_CALL_POOL:li};class Ca{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const on=new j,Ia=new we,Pa=class extends bt{constructor(i,t,e,s=It.TRIANGLES){super(),this.geometry=i,this.shader=t,this.state=e||jt.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=S.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(i){this._geometry!==i&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=i,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(i){this.shader=i}get material(){return this.shader}set blendMode(i){this.state.blendMode=i}get blendMode(){return this.state.blendMode}set roundPixels(i){this._roundPixels!==i&&(this._transformID=-1),this._roundPixels=i}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(i){this.shader.tint=i}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(i){this.shader.texture=i}_render(i){const t=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===It.TRIANGLES&&t.length<Pa.BATCHABLE_SIZE*2?this._renderToBatch(i):this._renderDefault(i)}_renderDefault(i){const t=this.shader;t.alpha=this.worldAlpha,t.update&&t.update(),i.batch.flush(),t.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),i.shader.bind(t),i.state.set(this.state),i.geometry.bind(this.geometry,t),i.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(i){const t=this.geometry,e=this.shader;e.uvMatrix&&(e.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=t.indexBuffer.data,this._tintRGB=e._tintRGB,this._texture=e.texture;const s=this.material.pluginName;i.batch.setObjectRenderer(i.plugins[s]),i.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,s=t._updateID;if(s===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const r=this.transform.worldTransform,n=r.a,o=r.b,a=r.c,h=r.d,l=r.tx,c=r.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+a*p+l,u[d*2+1]=o*f+h*p+c}if(this._roundPixels){const d=S.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=s}calculateUvs(){const i=this.geometry.buffers[1],t=this.shader;t.uvMatrix.isSimple?this.uvs=i.data:(this.batchUvs||(this.batchUvs=new Ca(i,t.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(i){if(!this.getBounds().contains(i.x,i.y))return!1;this.worldTransform.applyInverse(i,on);const t=this.geometry.getBuffer("aVertexPosition").data,e=Ia.points,s=this.geometry.getIndex().data,r=s.length,n=this.drawMode===4?3:1;for(let o=0;o+2<r;o+=n){const a=s[o]*2,h=s[o+1]*2,l=s[o+2]*2;if(e[0]=t[a],e[1]=t[a+1],e[2]=t[h],e[3]=t[h+1],e[4]=t[l],e[5]=t[l+1],Ia.contains(on.x,on.y))return!0}return!1}destroy(i){super.destroy(i),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};let Ee=Pa;Ee.BATCHABLE_SIZE=100;var $f=`varying vec2 vTextureCoord;
891
891
  uniform vec4 uColor;
892
892
 
893
893
  uniform sampler2D uSampler;