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.js +10 -7
- package/dist/pixi.js.map +1 -1
- package/dist/pixi.min.js +8 -8
- package/dist/pixi.min.js.map +1 -1
- package/dist/pixi.min.mjs +8 -8
- package/dist/pixi.min.mjs.map +1 -1
- package/dist/pixi.mjs +10 -7
- package/dist/pixi.mjs.map +1 -1
- package/package.json +31 -31
package/dist/pixi.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var wp=Object.defineProperty,Sp=Object.defineProperties;var Ap=Object.getOwnPropertyDescriptors;var Es=Object.getOwnPropertySymbols;var Ka=Object.prototype.hasOwnProperty,Za=Object.prototype.propertyIsEnumerable;var qa=(m,J,_t)=>J in m?wp(m,J,{enumerable:!0,configurable:!0,writable:!0,value:_t}):m[J]=_t,Zt=(m,J)=>{for(var _t in J||(J={}))Ka.call(J,_t)&&qa(m,_t,J[_t]);if(Es)for(var _t of Es(J))Za.call(J,_t)&&qa(m,_t,J[_t]);return m},mn=(m,J)=>Sp(m,Ap(J));var _n=(m,J)=>{var _t={};for(var xt in m)Ka.call(m,xt)&&J.indexOf(xt)<0&&(_t[xt]=m[xt]);if(m!=null&&Es)for(var xt of Es(m))J.indexOf(xt)<0&&Za.call(m,xt)&&(_t[xt]=m[xt]);return _t};/*!
|
|
2
|
-
* pixi.js - v7.0.
|
|
3
|
-
* Compiled
|
|
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 PIXI=function(m){"use strict";var J=(i=>(i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",i))(J||{}),_t=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS",i))(_t||{}),xt=(i=>(i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL",i))(xt||{}),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||{}),Dt=(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))(Dt||{}),I=(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))(I||{}),de=(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))(de||{}),G=(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))(G||{}),Ei=(i=>(i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT",i))(Ei||{}),Vt=(i=>(i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR",i))(Vt||{}),zt=(i=>(i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i))(zt||{}),Ft=(i=>(i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL",i))(Ft||{}),Rt=(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))(Rt||{}),Nt=(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))(Nt||{}),bi=(i=>(i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL",i))(bi||{}),wt=(i=>(i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp",i))(wt||{}),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||{}),gn=(i=>(i[i.RED=1]="RED",i[i.GREEN=2]="GREEN",i[i.BLUE=4]="BLUE",i[i.ALPHA=8]="ALPHA",i))(gn||{}),at=(i=>(i[i.NONE=0]="NONE",i[i.LOW=2]="LOW",i[i.MEDIUM=4]="MEDIUM",i[i.HIGH=8]="HIGH",i))(at||{}),Lt=(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))(Lt||{});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 bs=/iPhone/i,vn=/iPod/i,xn=/iPad/i,Tn=/\biOS-universal(?:.+)Mac\b/i,ws=/\bAndroid(?:.+)Mobile\b/i,En=/Android/i,Ie=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,wi=/Silk/i,Qt=/Windows Phone/i,bn=/\bWindows(?:.+)ARM\b/i,wn=/BlackBerry/i,Sn=/BB10/i,An=/Opera Mini/i,Rn=/\b(CriOS|Chrome)(?:.+)Mobile/i,Cn=/Mobile(?:.+)Firefox\b/i,In=function(i){return typeof i!="undefined"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream=="undefined"};function Qa(i){return function(t){return t.test(i)}}function Ja(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=Qa(e),n={apple:{phone:r(bs)&&!r(Qt),ipod:r(vn),tablet:!r(bs)&&(r(xn)||In(t))&&!r(Qt),universal:r(Tn),device:(r(bs)||r(vn)||r(xn)||r(Tn)||In(t))&&!r(Qt)},amazon:{phone:r(Ie),tablet:!r(Ie)&&r(wi),device:r(Ie)||r(wi)},android:{phone:!r(Qt)&&r(Ie)||!r(Qt)&&r(ws),tablet:!r(Qt)&&!r(Ie)&&!r(ws)&&(r(wi)||r(En)),device:!r(Qt)&&(r(Ie)||r(wi)||r(ws)||r(En))||r(/\bokhttp\b/i)},windows:{phone:r(Qt),tablet:r(bn),device:r(Qt)||r(bn)},other:{blackberry:r(wn),blackberry10:r(Sn),opera:r(An),firefox:r(Cn),chrome:r(Rn),device:r(wn)||r(Sn)||r(An)||r(Cn)||r(Rn)},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 Ot=Ja(globalThis.navigator);function th(){return!Ot.apple.device}function eh(i){let t=!0;if(Ot.tablet||Ot.phone){if(Ot.apple.device){const e=navigator.userAgent.match(/OS (\d+)_(\d+)?/);e&&parseInt(e[1],10)<11&&(t=!1)}if(Ot.android.device){const e=navigator.userAgent.match(/Android\s([0-9.]*)/);e&&parseInt(e[1],10)<7&&(t=!1)}}return t?i:4}const R={ADAPTER:yn,MIPMAP_TEXTURES:Ft.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:at.NONE,SPRITE_MAX_TEXTURES:eh(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:zt.CLAMP,SCALE_MODE:Vt.LINEAR,PRECISION_VERTEX:wt.HIGH,PRECISION_FRAGMENT:Ot.apple.device?wt.HIGH:wt.MEDIUM,CAN_UPLOAD_SAME_BUFFER:th(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};R.PREFER_ENV=J.WEBGL2,R.STRICT_TEXTURE_CACHE=!1;var M=(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))(M||{});const Pn=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){const t=typeof i.extension!="object"?{type:i.extension}:i.extension;i=mn(Zt({},t),{ref:i})}if(typeof i=="object")i=Zt({},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(Pn).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(Pn).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)})}},Ve=Math.PI*2,Mn=180/Math.PI,Bn=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 W{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new W(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 Si=[new W,new W,new W,new W];class z{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 z(0,0,0,0)}clone(){return new z(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 S=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=S)return!1;const H=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>H}const s=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=s||o<=n)return!1;const a=Si[0].set(t.left,t.top),h=Si[1].set(t.left,t.bottom),l=Si[2].set(t.right,t.top),c=Si[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,_=d*r+f*n,g=d*s+f*o,v=d*r+f*o;if(Math.max(p,_,g,v)<=d*a.x+f*a.y||Math.min(p,_,g,v)>=d*c.x+f*c.y)return!1;const T=u*(a.y-l.y),y=u*(l.x-a.x),x=T*s+y*n,b=T*r+y*n,D=T*s+y*o,C=T*r+y*o;return!(Math.max(x,b,D,C)<=T*a.x+y*a.y||Math.min(x,b,D,C)>=T*c.x+y*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 Ai{constructor(t=0,e=0,s=0){this.x=t,this.y=e,this.radius=s,this.type=dt.CIRC}clone(){return new Ai(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 z(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}class Ri{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 Ri(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 z(this.x-this.width,this.y-this.height,this.width,this.height)}}class fe{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 fe(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 Ci{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 Ci(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 tt{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 W;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 W;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(Ve-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 tt;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 tt}static get TEMP_MATRIX(){return new tt}}const pe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],me=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],_e=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ge=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ss=[],Dn=[],Ii=Math.sign;function ih(){for(let i=0;i<16;i++){const t=[];Ss.push(t);for(let e=0;e<16;e++){const s=Ii(pe[i]*pe[e]+_e[i]*me[e]),r=Ii(me[i]*pe[e]+ge[i]*me[e]),n=Ii(pe[i]*_e[e]+_e[i]*ge[e]),o=Ii(me[i]*_e[e]+ge[i]*ge[e]);for(let a=0;a<16;a++)if(pe[a]===s&&me[a]===r&&_e[a]===n&&ge[a]===o){t.push(a);break}}}for(let i=0;i<16;i++){const t=new tt;t.set(pe[i],me[i],_e[i],ge[i],0,0),Dn.push(t)}}ih();const et={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=>pe[i],uY:i=>me[i],vX:i=>_e[i],vY:i=>ge[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Ss[i][t],sub:(i,t)=>Ss[i][et.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?et.S:et.N:Math.abs(t)*2<=Math.abs(i)?i>0?et.E:et.W:t>0?i>0?et.SE:et.SW:i>0?et.NE:et.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const r=Dn[et.inv(t)];r.tx=e,r.ty=s,i.append(r)}},Fn=class{constructor(){this.worldTransform=new tt,this.localTransform=new tt,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 ze=Fn;ze.IDENTITY=new Fn;class St{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(St.prototype,{dispatch:{value:St.prototype.emit},run:{value:St.prototype.emit}}),R.TARGET_FPMS=.06;var ae=(i=>(i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(ae||{});class As{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 Q{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 As(null,null,1/0),this.deltaMS=1/R.TARGET_FPMS,this.elapsedMS=1/R.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=ae.NORMAL){return this._addListener(new As(t,e,s))}addOnce(t,e,s=ae.NORMAL){return this._addListener(new As(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*R.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,R.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(!Q._shared){const t=Q._shared=new Q;t.autoStart=!0,t._protected=!0}return Q._shared}static get system(){if(!Q._system){const t=Q._system=new Q;t.autoStart=!0,t._protected=!0}return Q._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,ae.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Q.shared:new Q,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Rs.extension=M.Application,U.add(Rs);var Cs=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Rp(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 sh(s,r==null?e.path:r)}},i(e,e.exports),e.exports}function Cp(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Ip(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")&&Object.keys(i).length===1?i.default:i}function Pp(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 sh(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Pe=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 _=e?e+l:l;if(!this._events[_])return!1;var g=this._events[_],v=arguments.length,T,y;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),v){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(y=1,T=new Array(v-1);y<v;y++)T[y-1]=arguments[y];g.fn.apply(g.context,T)}else{var x=g.length,b;for(y=0;y<x;y++)switch(g[y].once&&this.removeListener(l,g[y].fn,void 0,!0),v){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,c);break;case 3:g[y].fn.call(g[y].context,c,u);break;case 4:g[y].fn.call(g[y].context,c,u,d);break;default:if(!T)for(b=1,T=new Array(v-1);b<v;b++)T[b-1]=arguments[b];g[y].fn.apply(g[y].context,T)}}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 _=0,g=[],v=p.length;_<v;_++)(p[_].fn!==c||d&&!p[_].once||u&&p[_].context!==u)&&g.push(p[_]);g.length?this._events[f]=g.length===1?g[0]:g: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=Pi,rh=Pi;function Pi(i,t,e){e=e||2;var s=t&&t.length,r=s?t[0]*e:i.length,n=Nn(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=lh(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 We(n,o,e,a,h,f,0),o}function Nn(i,t,e,s,r){var n,o;if(r===Ds(i,t,e,s)>0)for(n=t;n<e;n+=s)o=Un(n,i[n],i[n+1],o);else for(n=e-s;n>=t;n-=s)o=Un(n,i[n],i[n+1],o);return o&&Mi(o,o.next)&&(Ye(o),o=o.next),o}function ye(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Mi(e,e.next)||rt(e.prev,e,e.next)===0)){if(Ye(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function We(i,t,e,s,r,n,o){if(!!i){!o&&n&&ph(i,s,r,n);for(var a=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,n?oh(i,s,r,n):nh(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),Ye(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=ah(ye(i),t,e),We(i,t,e,s,r,n,2)):o===2&&hh(i,t,e,s,r,n):We(ye(i),t,e,s,r,n,1);break}}}}function nh(i){var t=i.prev,e=i,s=i.next;if(rt(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&&Me(r,a,n,h,o,l,p.x,p.y)&&rt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function oh(i,t,e,s){var r=i.prev,n=i,o=i.next;if(rt(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,_=a>h?a>l?a:l:h>l?h:l,g=c>u?c>d?c:d:u>d?u:d,v=Ms(f,p,t,e,s),T=Ms(_,g,t,e,s),y=i.prevZ,x=i.nextZ;y&&y.z>=v&&x&&x.z<=T;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=g&&y!==r&&y!==o&&Me(a,c,h,u,l,d,y.x,y.y)&&rt(y.prev,y,y.next)>=0||(y=y.prevZ,x.x>=f&&x.x<=_&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Me(a,c,h,u,l,d,x.x,x.y)&&rt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;y&&y.z>=v;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=g&&y!==r&&y!==o&&Me(a,c,h,u,l,d,y.x,y.y)&&rt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=T;){if(x.x>=f&&x.x<=_&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Me(a,c,h,u,l,d,x.x,x.y)&&rt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function ah(i,t,e){var s=i;do{var r=s.prev,n=s.next.next;!Mi(r,n)&&Ln(r,s,s.next,n)&&je(r,n)&&je(n,r)&&(t.push(r.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),Ye(s),Ye(s.next),s=i=n),s=s.next}while(s!==i);return ye(s)}function hh(i,t,e,s,r,n){var o=i;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&gh(o,a)){var h=On(o,a);o=ye(o,o.next),h=ye(h,h.next),We(o,t,e,s,r,n,0),We(h,t,e,s,r,n,0);return}a=a.next}o=o.next}while(o!==i)}function lh(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=Nn(i,a,h,s,!1),l===l.next&&(l.steiner=!0),r.push(_h(l));for(r.sort(ch),n=0;n<r.length;n++)e=uh(r[n],e);return e}function ch(i,t){return i.x-t.x}function uh(i,t){var e=dh(i,t);if(!e)return t;var s=On(e,i);return ye(s,s.next),ye(e,e.next)}function dh(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&&Me(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),je(e,i)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&fh(o,e)))&&(o=e,u=d)),e=e.next;while(e!==h);return o}function fh(i,t){return rt(i.prev,i,t.prev)<0&&rt(t.next,i,i.next)<0}function ph(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,mh(r)}function mh(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 _h(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 Me(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 gh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!yh(i,t)&&(je(i,t)&&je(t,i)&&vh(i,t)&&(rt(i.prev,i,t.prev)||rt(i,t.prev,t))||Mi(i,t)&&rt(i.prev,i,i.next)>0&&rt(t.prev,t,t.next)>0)}function rt(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Mi(i,t){return i.x===t.x&&i.y===t.y}function Ln(i,t,e,s){var r=Di(rt(i,t,e)),n=Di(rt(i,t,s)),o=Di(rt(e,s,i)),a=Di(rt(e,s,t));return!!(r!==n&&o!==a||r===0&&Bi(i,e,t)||n===0&&Bi(i,s,t)||o===0&&Bi(e,i,s)||a===0&&Bi(e,t,s))}function Bi(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 Di(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&&Ln(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function je(i,t){return rt(i.prev,i,i.next)<0?rt(i,t,i.next)>=0&&rt(i,i.prev,t)>=0:rt(i,t,i.prev)<0||rt(i,i.next,t)<0}function vh(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 On(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 Un(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 Ye(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}Pi.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}Pi.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=rh;var xh=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,_="-",g=/^xn--/,v=/[^\x20-\x7E]/,T=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=h-l,b=Math.floor,D=String.fromCharCode,C;function S(A){throw RangeError(y[A])}function O(A,X){for(var $=A.length,K=[];$--;)K[$]=X(A[$]);return K}function H(A,X){var $=A.split("@"),K="";$.length>1&&(K=$[0]+"@",A=$[1]),A=A.replace(T,".");var Z=A.split("."),pt=O(Z,X).join(".");return K+pt}function P(A){for(var X=[],$=0,K=A.length,Z,pt;$<K;)Z=A.charCodeAt($++),Z>=55296&&Z<=56319&&$<K?(pt=A.charCodeAt($++),(pt&64512)==56320?X.push(((Z&1023)<<10)+(pt&1023)+65536):(X.push(Z),$--)):X.push(Z);return X}function N(A){return O(A,function(X){var $="";return X>65535&&(X-=65536,$+=D(X>>>10&1023|55296),X=56320|X&1023),$+=D(X),$}).join("")}function w(A){return A-48<10?A-22:A-65<26?A-65:A-97<26?A-97:h}function E(A,X){return A+22+75*(A<26)-((X!=0)<<5)}function V(A,X,$){var K=0;for(A=$?b(A/d):A>>1,A+=b(A/X);A>x*c>>1;K+=h)A=b(A/x);return b(K+(x+1)*A/(A+u))}function Y(A){var X=[],$=A.length,K,Z=0,pt=p,lt=f,mt,yt,bt,gt,st,ct,ut,qt,Kt;for(mt=A.lastIndexOf(_),mt<0&&(mt=0),yt=0;yt<mt;++yt)A.charCodeAt(yt)>=128&&S("not-basic"),X.push(A.charCodeAt(yt));for(bt=mt>0?mt+1:0;bt<$;){for(gt=Z,st=1,ct=h;bt>=$&&S("invalid-input"),ut=w(A.charCodeAt(bt++)),(ut>=h||ut>b((a-Z)/st))&&S("overflow"),Z+=ut*st,qt=ct<=lt?l:ct>=lt+c?c:ct-lt,!(ut<qt);ct+=h)Kt=h-qt,st>b(a/Kt)&&S("overflow"),st*=Kt;K=X.length+1,lt=V(Z-gt,K,gt==0),b(Z/K)>a-pt&&S("overflow"),pt+=b(Z/K),Z%=K,X.splice(Z++,0,pt)}return N(X)}function F(A){var X,$,K,Z,pt,lt,mt,yt,bt,gt,st,ct=[],ut,qt,Kt,Ti;for(A=P(A),ut=A.length,X=p,$=0,pt=f,lt=0;lt<ut;++lt)st=A[lt],st<128&&ct.push(D(st));for(K=Z=ct.length,Z&&ct.push(_);K<ut;){for(mt=a,lt=0;lt<ut;++lt)st=A[lt],st>=X&&st<mt&&(mt=st);for(qt=K+1,mt-X>b((a-$)/qt)&&S("overflow"),$+=(mt-X)*qt,X=mt,lt=0;lt<ut;++lt)if(st=A[lt],st<X&&++$>a&&S("overflow"),st==X){for(yt=$,bt=h;gt=bt<=pt?l:bt>=pt+c?c:bt-pt,!(yt<gt);bt+=h)Ti=yt-gt,Kt=h-gt,ct.push(D(E(gt+Ti%Kt,0))),yt=b(Ti/Kt);ct.push(D(E(yt,0))),pt=V($,qt,K==Z),$=0,++K}++$,++X}return ct.join("")}function q(A){return H(A,function(X){return g.test(X)?Y(X.slice(4).toLowerCase()):X})}function ot(A){return H(A,function(X){return v.test(X)?"xn--"+F(X):X})}if(o={version:"1.3.2",ucs2:{decode:P,encode:N},decode:Y,encode:F,toASCII:ot,toUnicode:q},s&&r)if(i.exports==s)r.exports=o;else for(C in o)o.hasOwnProperty(C)&&(s[C]=o[C]);else e.punycode=o})(Cs)}),Wt={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 Th(i,t){return Object.prototype.hasOwnProperty.call(i,t)}var Eh=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),Th(r,f)?Array.isArray(r[f])?r[f].push(p):r[f]=[r[f],p]:r[f]=p}return r},$e=function(i){switch(typeof i){case"string":return i;case"boolean":return i?"true":"false";case"number":return isFinite(i)?i:"";default:return""}},bh=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($e(r))+e;return Array.isArray(i[r])?i[r].map(function(o){return n+encodeURIComponent($e(o))}).join(t):n+encodeURIComponent($e(i[r]))}).join(t):s?encodeURIComponent($e(s))+e+encodeURIComponent($e(i)):""},Fs=Is(function(i,t){"use strict";t.decode=t.parse=Eh,t.encode=t.stringify=bh}),Gn=qe,kn=Nh,wh=Lh,Hn=Fh,Sh=Ct;function Ct(){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 Ah=/^([a-z0-9.+-]+:)/i,Rh=/:[0-9]*$/,Ch=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Ih=["<",">",'"',"`"," ","\r",`
|
|
7
|
+
*/var PIXI=function(m){"use strict";var J=(i=>(i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",i))(J||{}),_t=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS",i))(_t||{}),xt=(i=>(i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL",i))(xt||{}),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||{}),Dt=(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))(Dt||{}),I=(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))(I||{}),de=(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))(de||{}),G=(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))(G||{}),Ei=(i=>(i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT",i))(Ei||{}),Vt=(i=>(i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR",i))(Vt||{}),zt=(i=>(i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i))(zt||{}),Ft=(i=>(i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL",i))(Ft||{}),Rt=(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))(Rt||{}),Nt=(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))(Nt||{}),bi=(i=>(i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL",i))(bi||{}),wt=(i=>(i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp",i))(wt||{}),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||{}),gn=(i=>(i[i.RED=1]="RED",i[i.GREEN=2]="GREEN",i[i.BLUE=4]="BLUE",i[i.ALPHA=8]="ALPHA",i))(gn||{}),at=(i=>(i[i.NONE=0]="NONE",i[i.LOW=2]="LOW",i[i.MEDIUM=4]="MEDIUM",i[i.HIGH=8]="HIGH",i))(at||{}),Lt=(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))(Lt||{});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 bs=/iPhone/i,vn=/iPod/i,xn=/iPad/i,Tn=/\biOS-universal(?:.+)Mac\b/i,ws=/\bAndroid(?:.+)Mobile\b/i,En=/Android/i,Ie=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,wi=/Silk/i,Qt=/Windows Phone/i,bn=/\bWindows(?:.+)ARM\b/i,wn=/BlackBerry/i,Sn=/BB10/i,An=/Opera Mini/i,Rn=/\b(CriOS|Chrome)(?:.+)Mobile/i,Cn=/Mobile(?:.+)Firefox\b/i,In=function(i){return typeof i!="undefined"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream=="undefined"};function Qa(i){return function(t){return t.test(i)}}function Ja(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=Qa(e),n={apple:{phone:r(bs)&&!r(Qt),ipod:r(vn),tablet:!r(bs)&&(r(xn)||In(t))&&!r(Qt),universal:r(Tn),device:(r(bs)||r(vn)||r(xn)||r(Tn)||In(t))&&!r(Qt)},amazon:{phone:r(Ie),tablet:!r(Ie)&&r(wi),device:r(Ie)||r(wi)},android:{phone:!r(Qt)&&r(Ie)||!r(Qt)&&r(ws),tablet:!r(Qt)&&!r(Ie)&&!r(ws)&&(r(wi)||r(En)),device:!r(Qt)&&(r(Ie)||r(wi)||r(ws)||r(En))||r(/\bokhttp\b/i)},windows:{phone:r(Qt),tablet:r(bn),device:r(Qt)||r(bn)},other:{blackberry:r(wn),blackberry10:r(Sn),opera:r(An),firefox:r(Cn),chrome:r(Rn),device:r(wn)||r(Sn)||r(An)||r(Cn)||r(Rn)},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 Ot=Ja(globalThis.navigator);function th(){return!Ot.apple.device}function eh(i){let t=!0;if(Ot.tablet||Ot.phone){if(Ot.apple.device){const e=navigator.userAgent.match(/OS (\d+)_(\d+)?/);e&&parseInt(e[1],10)<11&&(t=!1)}if(Ot.android.device){const e=navigator.userAgent.match(/Android\s([0-9.]*)/);e&&parseInt(e[1],10)<7&&(t=!1)}}return t?i:4}const R={ADAPTER:yn,MIPMAP_TEXTURES:Ft.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:at.NONE,SPRITE_MAX_TEXTURES:eh(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:zt.CLAMP,SCALE_MODE:Vt.LINEAR,PRECISION_VERTEX:wt.HIGH,PRECISION_FRAGMENT:Ot.apple.device?wt.HIGH:wt.MEDIUM,CAN_UPLOAD_SAME_BUFFER:th(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};R.PREFER_ENV=J.WEBGL2,R.STRICT_TEXTURE_CACHE=!1;var M=(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))(M||{});const Pn=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){const t=typeof i.extension!="object"?{type:i.extension}:i.extension;i=mn(Zt({},t),{ref:i})}if(typeof i=="object")i=Zt({},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(Pn).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(Pn).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)})}},Ve=Math.PI*2,Mn=180/Math.PI,Bn=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 W{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new W(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 Si=[new W,new W,new W,new W];class z{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 z(0,0,0,0)}clone(){return new z(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 S=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=S)return!1;const H=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>H}const s=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=s||o<=n)return!1;const a=Si[0].set(t.left,t.top),h=Si[1].set(t.left,t.bottom),l=Si[2].set(t.right,t.top),c=Si[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,_=d*r+f*n,g=d*s+f*o,v=d*r+f*o;if(Math.max(p,_,g,v)<=d*a.x+f*a.y||Math.min(p,_,g,v)>=d*c.x+f*c.y)return!1;const T=u*(a.y-l.y),y=u*(l.x-a.x),x=T*s+y*n,b=T*r+y*n,D=T*s+y*o,C=T*r+y*o;return!(Math.max(x,b,D,C)<=T*a.x+y*a.y||Math.min(x,b,D,C)>=T*c.x+y*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 Ai{constructor(t=0,e=0,s=0){this.x=t,this.y=e,this.radius=s,this.type=dt.CIRC}clone(){return new Ai(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 z(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}class Ri{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 Ri(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 z(this.x-this.width,this.y-this.height,this.width,this.height)}}class fe{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 fe(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 Ci{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 Ci(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 tt{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 W;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 W;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(Ve-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 tt;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 tt}static get TEMP_MATRIX(){return new tt}}const pe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],me=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],_e=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ge=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ss=[],Dn=[],Ii=Math.sign;function ih(){for(let i=0;i<16;i++){const t=[];Ss.push(t);for(let e=0;e<16;e++){const s=Ii(pe[i]*pe[e]+_e[i]*me[e]),r=Ii(me[i]*pe[e]+ge[i]*me[e]),n=Ii(pe[i]*_e[e]+_e[i]*ge[e]),o=Ii(me[i]*_e[e]+ge[i]*ge[e]);for(let a=0;a<16;a++)if(pe[a]===s&&me[a]===r&&_e[a]===n&&ge[a]===o){t.push(a);break}}}for(let i=0;i<16;i++){const t=new tt;t.set(pe[i],me[i],_e[i],ge[i],0,0),Dn.push(t)}}ih();const et={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=>pe[i],uY:i=>me[i],vX:i=>_e[i],vY:i=>ge[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Ss[i][t],sub:(i,t)=>Ss[i][et.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?et.S:et.N:Math.abs(t)*2<=Math.abs(i)?i>0?et.E:et.W:t>0?i>0?et.SE:et.SW:i>0?et.NE:et.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const r=Dn[et.inv(t)];r.tx=e,r.ty=s,i.append(r)}},Fn=class{constructor(){this.worldTransform=new tt,this.localTransform=new tt,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 ze=Fn;ze.IDENTITY=new Fn;class St{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(St.prototype,{dispatch:{value:St.prototype.emit},run:{value:St.prototype.emit}}),R.TARGET_FPMS=.06;var ae=(i=>(i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(ae||{});class As{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 Q{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 As(null,null,1/0),this.deltaMS=1/R.TARGET_FPMS,this.elapsedMS=1/R.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=ae.NORMAL){return this._addListener(new As(t,e,s))}addOnce(t,e,s=ae.NORMAL){return this._addListener(new As(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*R.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,R.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(!Q._shared){const t=Q._shared=new Q;t.autoStart=!0,t._protected=!0}return Q._shared}static get system(){if(!Q._system){const t=Q._system=new Q;t.autoStart=!0,t._protected=!0}return Q._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,ae.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Q.shared:new Q,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Rs.extension=M.Application,U.add(Rs);var Cs=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Rp(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 sh(s,r==null?e.path:r)}},i(e,e.exports),e.exports}function Cp(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Ip(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")&&Object.keys(i).length===1?i.default:i}function Pp(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 sh(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Pe=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 _=e?e+l:l;if(!this._events[_])return!1;var g=this._events[_],v=arguments.length,T,y;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),v){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(y=1,T=new Array(v-1);y<v;y++)T[y-1]=arguments[y];g.fn.apply(g.context,T)}else{var x=g.length,b;for(y=0;y<x;y++)switch(g[y].once&&this.removeListener(l,g[y].fn,void 0,!0),v){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,c);break;case 3:g[y].fn.call(g[y].context,c,u);break;case 4:g[y].fn.call(g[y].context,c,u,d);break;default:if(!T)for(b=1,T=new Array(v-1);b<v;b++)T[b-1]=arguments[b];g[y].fn.apply(g[y].context,T)}}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 _=0,g=[],v=p.length;_<v;_++)(p[_].fn!==c||d&&!p[_].once||u&&p[_].context!==u)&&g.push(p[_]);g.length?this._events[f]=g.length===1?g[0]:g: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=Pi,rh=Pi;function Pi(i,t,e){e=e||2;var s=t&&t.length,r=s?t[0]*e:i.length,n=Nn(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=lh(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 We(n,o,e,a,h,f,0),o}function Nn(i,t,e,s,r){var n,o;if(r===Ds(i,t,e,s)>0)for(n=t;n<e;n+=s)o=Un(n,i[n],i[n+1],o);else for(n=e-s;n>=t;n-=s)o=Un(n,i[n],i[n+1],o);return o&&Mi(o,o.next)&&(Ye(o),o=o.next),o}function ye(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Mi(e,e.next)||rt(e.prev,e,e.next)===0)){if(Ye(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function We(i,t,e,s,r,n,o){if(!!i){!o&&n&&ph(i,s,r,n);for(var a=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,n?oh(i,s,r,n):nh(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),Ye(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=ah(ye(i),t,e),We(i,t,e,s,r,n,2)):o===2&&hh(i,t,e,s,r,n):We(ye(i),t,e,s,r,n,1);break}}}}function nh(i){var t=i.prev,e=i,s=i.next;if(rt(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&&Me(r,a,n,h,o,l,p.x,p.y)&&rt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function oh(i,t,e,s){var r=i.prev,n=i,o=i.next;if(rt(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,_=a>h?a>l?a:l:h>l?h:l,g=c>u?c>d?c:d:u>d?u:d,v=Ms(f,p,t,e,s),T=Ms(_,g,t,e,s),y=i.prevZ,x=i.nextZ;y&&y.z>=v&&x&&x.z<=T;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=g&&y!==r&&y!==o&&Me(a,c,h,u,l,d,y.x,y.y)&&rt(y.prev,y,y.next)>=0||(y=y.prevZ,x.x>=f&&x.x<=_&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Me(a,c,h,u,l,d,x.x,x.y)&&rt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;y&&y.z>=v;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=g&&y!==r&&y!==o&&Me(a,c,h,u,l,d,y.x,y.y)&&rt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=T;){if(x.x>=f&&x.x<=_&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Me(a,c,h,u,l,d,x.x,x.y)&&rt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function ah(i,t,e){var s=i;do{var r=s.prev,n=s.next.next;!Mi(r,n)&&Ln(r,s,s.next,n)&&je(r,n)&&je(n,r)&&(t.push(r.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),Ye(s),Ye(s.next),s=i=n),s=s.next}while(s!==i);return ye(s)}function hh(i,t,e,s,r,n){var o=i;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&gh(o,a)){var h=On(o,a);o=ye(o,o.next),h=ye(h,h.next),We(o,t,e,s,r,n,0),We(h,t,e,s,r,n,0);return}a=a.next}o=o.next}while(o!==i)}function lh(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=Nn(i,a,h,s,!1),l===l.next&&(l.steiner=!0),r.push(_h(l));for(r.sort(ch),n=0;n<r.length;n++)e=uh(r[n],e);return e}function ch(i,t){return i.x-t.x}function uh(i,t){var e=dh(i,t);if(!e)return t;var s=On(e,i);return ye(s,s.next),ye(e,e.next)}function dh(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&&Me(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),je(e,i)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&fh(o,e)))&&(o=e,u=d)),e=e.next;while(e!==h);return o}function fh(i,t){return rt(i.prev,i,t.prev)<0&&rt(t.next,i,i.next)<0}function ph(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,mh(r)}function mh(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 _h(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 Me(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 gh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!yh(i,t)&&(je(i,t)&&je(t,i)&&vh(i,t)&&(rt(i.prev,i,t.prev)||rt(i,t.prev,t))||Mi(i,t)&&rt(i.prev,i,i.next)>0&&rt(t.prev,t,t.next)>0)}function rt(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Mi(i,t){return i.x===t.x&&i.y===t.y}function Ln(i,t,e,s){var r=Di(rt(i,t,e)),n=Di(rt(i,t,s)),o=Di(rt(e,s,i)),a=Di(rt(e,s,t));return!!(r!==n&&o!==a||r===0&&Bi(i,e,t)||n===0&&Bi(i,s,t)||o===0&&Bi(e,i,s)||a===0&&Bi(e,t,s))}function Bi(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 Di(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&&Ln(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function je(i,t){return rt(i.prev,i,i.next)<0?rt(i,t,i.next)>=0&&rt(i,i.prev,t)>=0:rt(i,t,i.prev)<0||rt(i,i.next,t)<0}function vh(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 On(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 Un(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 Ye(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}Pi.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}Pi.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=rh;var xh=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,_="-",g=/^xn--/,v=/[^\x20-\x7E]/,T=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=h-l,b=Math.floor,D=String.fromCharCode,C;function S(A){throw RangeError(y[A])}function O(A,X){for(var $=A.length,K=[];$--;)K[$]=X(A[$]);return K}function H(A,X){var $=A.split("@"),K="";$.length>1&&(K=$[0]+"@",A=$[1]),A=A.replace(T,".");var Z=A.split("."),pt=O(Z,X).join(".");return K+pt}function P(A){for(var X=[],$=0,K=A.length,Z,pt;$<K;)Z=A.charCodeAt($++),Z>=55296&&Z<=56319&&$<K?(pt=A.charCodeAt($++),(pt&64512)==56320?X.push(((Z&1023)<<10)+(pt&1023)+65536):(X.push(Z),$--)):X.push(Z);return X}function N(A){return O(A,function(X){var $="";return X>65535&&(X-=65536,$+=D(X>>>10&1023|55296),X=56320|X&1023),$+=D(X),$}).join("")}function w(A){return A-48<10?A-22:A-65<26?A-65:A-97<26?A-97:h}function E(A,X){return A+22+75*(A<26)-((X!=0)<<5)}function V(A,X,$){var K=0;for(A=$?b(A/d):A>>1,A+=b(A/X);A>x*c>>1;K+=h)A=b(A/x);return b(K+(x+1)*A/(A+u))}function Y(A){var X=[],$=A.length,K,Z=0,pt=p,lt=f,mt,yt,bt,gt,st,ct,ut,qt,Kt;for(mt=A.lastIndexOf(_),mt<0&&(mt=0),yt=0;yt<mt;++yt)A.charCodeAt(yt)>=128&&S("not-basic"),X.push(A.charCodeAt(yt));for(bt=mt>0?mt+1:0;bt<$;){for(gt=Z,st=1,ct=h;bt>=$&&S("invalid-input"),ut=w(A.charCodeAt(bt++)),(ut>=h||ut>b((a-Z)/st))&&S("overflow"),Z+=ut*st,qt=ct<=lt?l:ct>=lt+c?c:ct-lt,!(ut<qt);ct+=h)Kt=h-qt,st>b(a/Kt)&&S("overflow"),st*=Kt;K=X.length+1,lt=V(Z-gt,K,gt==0),b(Z/K)>a-pt&&S("overflow"),pt+=b(Z/K),Z%=K,X.splice(Z++,0,pt)}return N(X)}function F(A){var X,$,K,Z,pt,lt,mt,yt,bt,gt,st,ct=[],ut,qt,Kt,Ti;for(A=P(A),ut=A.length,X=p,$=0,pt=f,lt=0;lt<ut;++lt)st=A[lt],st<128&&ct.push(D(st));for(K=Z=ct.length,Z&&ct.push(_);K<ut;){for(mt=a,lt=0;lt<ut;++lt)st=A[lt],st>=X&&st<mt&&(mt=st);for(qt=K+1,mt-X>b((a-$)/qt)&&S("overflow"),$+=(mt-X)*qt,X=mt,lt=0;lt<ut;++lt)if(st=A[lt],st<X&&++$>a&&S("overflow"),st==X){for(yt=$,bt=h;gt=bt<=pt?l:bt>=pt+c?c:bt-pt,!(yt<gt);bt+=h)Ti=yt-gt,Kt=h-gt,ct.push(D(E(gt+Ti%Kt,0))),yt=b(Ti/Kt);ct.push(D(E(yt,0))),pt=V($,qt,K==Z),$=0,++K}++$,++X}return ct.join("")}function q(A){return H(A,function(X){return g.test(X)?Y(X.slice(4).toLowerCase()):X})}function ot(A){return H(A,function(X){return v.test(X)?"xn--"+F(X):X})}if(o={version:"1.3.2",ucs2:{decode:P,encode:N},decode:Y,encode:F,toASCII:ot,toUnicode:q},s&&r)if(i.exports==s)r.exports=o;else for(C in o)o.hasOwnProperty(C)&&(s[C]=o[C]);else e.punycode=o})(Cs)}),Wt={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 Th(i,t){return Object.prototype.hasOwnProperty.call(i,t)}var Eh=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),Th(r,f)?Array.isArray(r[f])?r[f].push(p):r[f]=[r[f],p]:r[f]=p}return r},$e=function(i){switch(typeof i){case"string":return i;case"boolean":return i?"true":"false";case"number":return isFinite(i)?i:"";default:return""}},bh=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($e(r))+e;return Array.isArray(i[r])?i[r].map(function(o){return n+encodeURIComponent($e(o))}).join(t):n+encodeURIComponent($e(i[r]))}).join(t):s?encodeURIComponent($e(s))+e+encodeURIComponent($e(i)):""},Fs=Is(function(i,t){"use strict";t.decode=t.parse=Eh,t.encode=t.stringify=bh}),Gn=qe,kn=Nh,wh=Lh,Hn=Fh,Sh=Ct;function Ct(){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 Ah=/^([a-z0-9.+-]+:)/i,Rh=/:[0-9]*$/,Ch=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Ih=["<",">",'"',"`"," ","\r",`
|
|
8
8
|
`," "],Ph=["{","}","|","\\","^","`"].concat(Ih),Ns=["'"].concat(Ph),Xn=["%","/","?",";","#"].concat(Ns),Vn=["/","?","#"],Mh=255,zn=/^[+a-z0-9A-Z_-]{0,63}$/,Bh=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Dh={javascript:!0,"javascript:":!0},Ls={javascript:!0,"javascript:":!0},Be={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function qe(i,t,e){if(i&&Wt.isObject(i)&&i instanceof Ct)return i;var s=new Ct;return s.parse(i,t,e),s}Ct.prototype.parse=function(i,t,e){if(!Wt.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=Ch.exec(a);if(h)return this.path=a,this.href=a,this.pathname=h[1],h[2]?(this.search=h[2],t?this.query=Fs.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var l=Ah.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&&!Be[l])){for(var d=-1,f=0;f<Vn.length;f++){var p=a.indexOf(Vn[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var _,g;d===-1?g=a.lastIndexOf("@"):g=a.lastIndexOf("@",d),g!==-1&&(_=a.slice(0,g),a=a.slice(g+1),this.auth=decodeURIComponent(_)),d=-1;for(var f=0;f<Xn.length;f++){var p=a.indexOf(Xn[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 v=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!v)for(var T=this.hostname.split(/\./),f=0,y=T.length;f<y;f++){var x=T[f];if(!!x&&!x.match(zn)){for(var b="",D=0,C=x.length;D<C;D++)x.charCodeAt(D)>127?b+="x":b+=x[D];if(!b.match(zn)){var S=T.slice(0,f),O=T.slice(f+1),H=x.match(Bh);H&&(S.push(H[1]),O.unshift(H[2])),O.length&&(a="/"+O.join(".")+a),this.hostname=S.join(".");break}}}this.hostname.length>Mh?this.hostname="":this.hostname=this.hostname.toLowerCase(),v||(this.hostname=xh.toASCII(this.hostname));var P=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+P,this.href+=this.host,v&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Dh[c])for(var f=0,y=Ns.length;f<y;f++){var w=Ns[f];if(a.indexOf(w)!==-1){var E=encodeURIComponent(w);E===w&&(E=escape(w)),a=a.split(w).join(E)}}var V=a.indexOf("#");V!==-1&&(this.hash=a.substr(V),a=a.slice(0,V));var Y=a.indexOf("?");if(Y!==-1?(this.search=a.substr(Y),this.query=a.substr(Y+1),t&&(this.query=Fs.parse(this.query)),a=a.slice(0,Y)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Be[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var P=this.pathname||"",F=this.search||"";this.path=P+F}return this.href=this.format(),this};function Fh(i){return Wt.isString(i)&&(i=qe(i)),i instanceof Ct?i.format():Ct.prototype.format.call(i)}Ct.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&&Wt.isObject(this.query)&&Object.keys(this.query).length&&(n=Fs.stringify(this.query));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Be[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 Nh(i,t){return qe(i,!1,!0).resolve(t)}Ct.prototype.resolve=function(i){return this.resolveObject(qe(i,!1,!0)).format()};function Lh(i,t){return i?qe(i,!1,!0).resolveObject(t):t}Ct.prototype.resolveObject=function(i){if(Wt.isString(i)){var t=new Ct;t.parse(i,!1,!0),i=t}for(var e=new Ct,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 Be[e.protocol]&&e.hostname&&!e.pathname&&(e.path=e.pathname="/"),e.href=e.format(),e}if(i.protocol&&i.protocol!==e.protocol){if(!Be[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 y=(i.pathname||"").split("/");y.length&&!(i.host=y.shift()););i.host||(i.host=""),i.hostname||(i.hostname=""),y[0]!==""&&y.unshift(""),y.length<2&&y.unshift(""),e.pathname=y.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)==="/",_=i.host||i.pathname&&i.pathname.charAt(0)==="/",g=_||p||e.host&&i.pathname,v=g,T=e.pathname&&e.pathname.split("/")||[],y=i.pathname&&i.pathname.split("/")||[],x=e.protocol&&!Be[e.protocol];if(x&&(e.hostname="",e.port=null,e.host&&(T[0]===""?T[0]=e.host:T.unshift(e.host)),e.host="",i.protocol&&(i.hostname=null,i.port=null,i.host&&(y[0]===""?y[0]=i.host:y.unshift(i.host)),i.host=null),g=g&&(y[0]===""||T[0]==="")),_)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,T=y;else if(y.length)T||(T=[]),T.pop(),T=T.concat(y),e.search=i.search,e.query=i.query;else if(!Wt.isNullOrUndefined(i.search)){if(x){e.hostname=e.host=T.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,(!Wt.isNull(e.pathname)||!Wt.isNull(e.search))&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!T.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var D=T.slice(-1)[0],C=(e.host||i.host||T.length>1)&&(D==="."||D==="..")||D==="",S=0,O=T.length;O>=0;O--)D=T[O],D==="."?T.splice(O,1):D===".."?(T.splice(O,1),S++):S&&(T.splice(O,1),S--);if(!g&&!v)for(;S--;S)T.unshift("..");g&&T[0]!==""&&(!T[0]||T[0].charAt(0)!=="/")&&T.unshift(""),C&&T.join("/").substr(-1)!=="/"&&T.push("");var H=T[0]===""||T[0]&&T[0].charAt(0)==="/";if(x){e.hostname=e.host=H?"":T.length?T.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 g=g||e.host&&T.length,g&&!H&&T.unshift(""),T.length?e.pathname=T.join("/"):(e.pathname=null,e.path=null),(!Wt.isNull(e.pathname)||!Wt.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},Ct.prototype.parseHost=function(){var i=this.host,t=Rh.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 Mp={parse:Gn,resolve:kn,resolveObject:wh,format:Hn,Url:Sh};const Wn={parse:Gn,format:Hn,resolve:kn};function Ut(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function jn(i){return i.split("?")[0].split("#")[0]}function Oh(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Uh(i,t,e){return i.replace(new RegExp(Oh(t),"g"),e)}function Gh(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 Uh(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){Ut(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=jn(this.toPosix(t!=null?t:R.ADAPTER.getBaseUrl())),r=jn(this.toPosix(e!=null?e:this.rootname(s)));return Ut(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),Ut(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=Gh(i,!1),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return Ut(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(Ut(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(Ut(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){Ut(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){Ut(i),t&&Ut(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){Ut(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){Ut(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:":"};R.RETINA_PREFIX=/@([0-9\.]+)x/,R.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;function kh(){}function Hh(){}let Os;function Yn(){return typeof Os=="undefined"&&(Os=function(){const t={stencil:!0,failIfMajorPerformanceCaveat:R.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!R.ADAPTER.getWebGLRenderingContext())return!1;const e=R.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}}()),Os}var Xh="#f0f8ff",Vh="#faebd7",zh="#00ffff",Wh="#7fffd4",jh="#f0ffff",Yh="#f5f5dc",$h="#ffe4c4",qh="#000000",Kh="#ffebcd",Zh="#0000ff",Qh="#8a2be2",Jh="#a52a2a",tl="#deb887",el="#5f9ea0",il="#7fff00",sl="#d2691e",rl="#ff7f50",nl="#6495ed",ol="#fff8dc",al="#dc143c",hl="#00ffff",ll="#00008b",cl="#008b8b",ul="#b8860b",dl="#a9a9a9",fl="#006400",pl="#a9a9a9",ml="#bdb76b",_l="#8b008b",gl="#556b2f",yl="#ff8c00",vl="#9932cc",xl="#8b0000",Tl="#e9967a",El="#8fbc8f",bl="#483d8b",wl="#2f4f4f",Sl="#2f4f4f",Al="#00ced1",Rl="#9400d3",Cl="#ff1493",Il="#00bfff",Pl="#696969",Ml="#696969",Bl="#1e90ff",Dl="#b22222",Fl="#fffaf0",Nl="#228b22",Ll="#ff00ff",Ol="#dcdcdc",Ul="#f8f8ff",Gl="#daa520",kl="#ffd700",Hl="#808080",Xl="#008000",Vl="#adff2f",zl="#808080",Wl="#f0fff0",jl="#ff69b4",Yl="#cd5c5c",$l="#4b0082",ql="#fffff0",Kl="#f0e68c",Zl="#fff0f5",Ql="#e6e6fa",Jl="#7cfc00",tc="#fffacd",ec="#add8e6",ic="#f08080",sc="#e0ffff",rc="#fafad2",nc="#d3d3d3",oc="#90ee90",ac="#d3d3d3",hc="#ffb6c1",lc="#ffa07a",cc="#20b2aa",uc="#87cefa",dc="#778899",fc="#778899",pc="#b0c4de",mc="#ffffe0",_c="#00ff00",gc="#32cd32",yc="#faf0e6",vc="#ff00ff",xc="#800000",Tc="#66cdaa",Ec="#0000cd",bc="#ba55d3",wc="#9370db",Sc="#3cb371",Ac="#7b68ee",Rc="#00fa9a",Cc="#48d1cc",Ic="#c71585",Pc="#191970",Mc="#f5fffa",Bc="#ffe4e1",Dc="#ffe4b5",Fc="#ffdead",Nc="#000080",Lc="#fdf5e6",Oc="#808000",Uc="#6b8e23",Gc="#ffa500",kc="#ff4500",Hc="#da70d6",Xc="#eee8aa",Vc="#98fb98",zc="#afeeee",Wc="#db7093",jc="#ffefd5",Yc="#ffdab9",$c="#cd853f",qc="#ffc0cb",Kc="#dda0dd",Zc="#b0e0e6",Qc="#800080",Jc="#663399",tu="#ff0000",eu="#bc8f8f",iu="#4169e1",su="#8b4513",ru="#fa8072",nu="#f4a460",ou="#2e8b57",au="#fff5ee",hu="#a0522d",lu="#c0c0c0",cu="#87ceeb",uu="#6a5acd",du="#708090",fu="#708090",pu="#fffafa",mu="#00ff7f",_u="#4682b4",gu="#d2b48c",yu="#008080",vu="#d8bfd8",xu="#ff6347",Tu="#40e0d0",Eu="#ee82ee",bu="#f5deb3",wu="#ffffff",Su="#f5f5f5",Au="#ffff00",Ru="#9acd32",Cu={aliceblue:Xh,antiquewhite:Vh,aqua:zh,aquamarine:Wh,azure:jh,beige:Yh,bisque:$h,black:qh,blanchedalmond:Kh,blue:Zh,blueviolet:Qh,brown:Jh,burlywood:tl,cadetblue:el,chartreuse:il,chocolate:sl,coral:rl,cornflowerblue:nl,cornsilk:ol,crimson:al,cyan:hl,darkblue:ll,darkcyan:cl,darkgoldenrod:ul,darkgray:dl,darkgreen:fl,darkgrey:pl,darkkhaki:ml,darkmagenta:_l,darkolivegreen:gl,darkorange:yl,darkorchid:vl,darkred:xl,darksalmon:Tl,darkseagreen:El,darkslateblue:bl,darkslategray:wl,darkslategrey:Sl,darkturquoise:Al,darkviolet:Rl,deeppink:Cl,deepskyblue:Il,dimgray:Pl,dimgrey:Ml,dodgerblue:Bl,firebrick:Dl,floralwhite:Fl,forestgreen:Nl,fuchsia:Ll,gainsboro:Ol,ghostwhite:Ul,goldenrod:Gl,gold:kl,gray:Hl,green:Xl,greenyellow:Vl,grey:zl,honeydew:Wl,hotpink:jl,indianred:Yl,indigo:$l,ivory:ql,khaki:Kl,lavenderblush:Zl,lavender:Ql,lawngreen:Jl,lemonchiffon:tc,lightblue:ec,lightcoral:ic,lightcyan:sc,lightgoldenrodyellow:rc,lightgray:nc,lightgreen:oc,lightgrey:ac,lightpink:hc,lightsalmon:lc,lightseagreen:cc,lightskyblue:uc,lightslategray:dc,lightslategrey:fc,lightsteelblue:pc,lightyellow:mc,lime:_c,limegreen:gc,linen:yc,magenta:vc,maroon:xc,mediumaquamarine:Tc,mediumblue:Ec,mediumorchid:bc,mediumpurple:wc,mediumseagreen:Sc,mediumslateblue:Ac,mediumspringgreen:Rc,mediumturquoise:Cc,mediumvioletred:Ic,midnightblue:Pc,mintcream:Mc,mistyrose:Bc,moccasin:Dc,navajowhite:Fc,navy:Nc,oldlace:Lc,olive:Oc,olivedrab:Uc,orange:Gc,orangered:kc,orchid:Hc,palegoldenrod:Xc,palegreen:Vc,paleturquoise:zc,palevioletred:Wc,papayawhip:jc,peachpuff:Yc,peru:$c,pink:qc,plum:Kc,powderblue:Zc,purple:Qc,rebeccapurple:Jc,red:tu,rosybrown:eu,royalblue:iu,saddlebrown:su,salmon:ru,sandybrown:nu,seagreen:ou,seashell:au,sienna:hu,silver:lu,skyblue:cu,slateblue:uu,slategray:du,slategrey:fu,snow:pu,springgreen:mu,steelblue:_u,tan:gu,teal:yu,thistle:vu,tomato:xu,turquoise:Tu,violet:Eu,wheat:bu,white:wu,whitesmoke:Su,yellow:Au,yellowgreen:Ru};function ve(i,t=[]){return t[0]=(i>>16&255)/255,t[1]=(i>>8&255)/255,t[2]=(i&255)/255,t}function Us(i){let t=i.toString(16);return t="000000".substring(0,6-t.length)+t,`#${t}`}function Fi(i){if(typeof i=="string"&&(i=Cu[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 Iu(i){return(i[0]*255<<16)+(i[1]*255<<8)+(i[2]*255|0)}function Pu(){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 Gs=Pu();function ks(i,t){return Gs[t?1:0][i]}function $n(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 Ni(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 qn(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 Li(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 Mu={Float32Array,Uint32Array,Int32Array,Uint8Array};function Bu(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=Li(c);r[u]||(r[u]=new Mu[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 Ke(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 xe(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 Te(i){return i===0?0:i<0?-1:1}let Du=0;function he(){return++Du}const Kn={};function Fu(i,t,e=3){if(Kn[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))),Kn[t]=!0}const zs={},Tt=Object.create(null),It=Object.create(null);function Nu(){let i;for(i in Tt)Tt[i].destroy();for(i in It)It[i].destroy()}function Lu(){let i;for(i in Tt)delete Tt[i];for(i in It)delete It[i]}class Ws{constructor(t,e,s){this.canvas=R.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=s||R.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 Zn(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 Qn=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Ou(i){const t=Qn.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 Oi;function Jn(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location,Oi||(Oi=document.createElement("a")),Oi.href=i;const e=Wn.parse(Oi.href),s=!e.port&&t.port===""||e.port===t.port;return e.hostname!==t.hostname||!s||e.protocol!==t.protocol?"anonymous":""}function te(i,t=1){const e=R.RETINA_PREFIX.exec(i);return e?parseFloat(e[1]):t}var Uu={__proto__:null,isMobile:Ot,EventEmitter:Pe,earcut:Ps,url:Wn,path:ft,sayHello:Hh,skipHello:kh,isWebGLSupported:Yn,hex2rgb:ve,hex2string:Us,rgb2hex:Iu,string2hex:Fi,correctBlendMode:ks,premultiplyBlendMode:Gs,premultiplyRgba:$n,premultiplyTint:Ni,premultiplyTintToRgba:Hs,createIndicesForQuads:qn,getBufferType:Li,interleaveTypedArrays:Bu,isPow2:Xs,log2:Vs,nextPow2:Ke,removeItems:xe,sign:Te,uid:he,deprecation:Fu,BaseTextureCache:It,ProgramCache:zs,TextureCache:Tt,clearTextureCache:Lu,destroyTextureCache:Nu,CanvasRenderTarget:Ws,trimCanvas:Zn,decomposeDataUri:Ou,determineCrossOrigin:Jn,getResolutionOfUrl:te,DATA_URI:Qn};const Ui=[];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=Ui.length-1;s>=0;--s){const r=Ui[s];if(r.test&&r.test(i,e))return new r(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class De{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new St("setRealSize"),this.onUpdate=new St("update"),this.onError=new St("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 Fe extends De{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===Rt.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 Gu={scaleMode:Vt.NEAREST,format:I.RGBA,alphaMode:Rt.NPM},Ze=class extends Pe{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 De)&&(i=js(i,f),i.internal=!0),this.resolution=d||R.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:R.MIPMAP_TEXTURES,this.anisotropicLevel=r!=null?r:R.ANISOTROPIC_LEVEL,this._wrapMode=h||R.WRAP_MODE,this._scaleMode=n!=null?n:R.SCALE_MODE,this.format=l||I.RGBA,this.type=c||G.UNSIGNED_BYTE,this.target=u||de.TEXTURE_2D,this.alphaMode=e!=null?e:Rt.UNPACK,this.uid=he(),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 It[this.cacheId],delete Tt[this.cacheId],this.cacheId=null),this.dispose(),Ze.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(i,t,e=R.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}_${he()}`}r=i._pixiId}let n=It[r];if(s&&e&&!n)throw new Error(`The cacheId "${r}" does not exist in BaseTextureCache.`);return n||(n=new Ze(i,t),n.cacheId=r,Ze.addToCache(n,r)),n}static fromBuffer(i,t,e,s){i=i||new Float32Array(t*e*4);const r=new Fe(i,{width:t,height:e}),n=i instanceof Float32Array?G.FLOAT:G.UNSIGNED_BYTE;return new Ze(r,Object.assign({},Gu,s||{width:t,height:e,type:n}))}static addToCache(i,t){t&&(i.textureCacheIds.includes(t)||i.textureCacheIds.push(t),It[t]&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),It[t]=i)}static removeFromCache(i){if(typeof i=="string"){const t=It[i];if(t){const e=t.textureCacheIds.indexOf(i);return e>-1&&t.textureCacheIds.splice(e,1),delete It[i],t}}else if(i!=null&&i.textureCacheIds){for(let t=0;t<i.textureCacheIds.length;++t)delete It[i.textureCacheIds[t]];return i.textureCacheIds.length=0,i}return null}};let j=Ze;j._globalBatch=0;class Ys extends De{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 j;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 De?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 to 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=de.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 ee extends De{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=Jn(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===Rt.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 eo extends ee{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Qe=class extends Ys{constructor(i,t){const{width:e,height:s,autoLoad:r,linkBaseTexture:n}=t||{};if(i&&i.length!==Qe.SIDES)throw new Error(`Invalid length. Got ${i.length}, expected 6`);super(6,{width:e,height:s});for(let o=0;o<Qe.SIDES;o++)this.items[o].target=de.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=de.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=de.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<Qe.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===Qe.SIDES}};let $s=Qe;$s.SIDES=6;class qs extends ee{constructor(t,e){var s;if(e=e||{},typeof t=="string"){const r=new Image;ee.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:R.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===Rt.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 Gi=class extends ee{constructor(i,t){t=t||{},super(R.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)},Gi.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;ee.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_${he()}`,n.getContext("2d").drawImage(i,0,0,t,e,0,0,s,r),this._resolve(),this._resolve=null}}static getSize(i){const t=Gi.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"&&Gi.SVG_XML.test(i)}};let Ne=Gi;Ne.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Ne.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;const Ks=class extends ee{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];ee.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=Q.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&&(Q.shared.add(this.update,this),this._isConnectedToTicker=!0)}_onPlayStop(){this._isConnectedToTicker&&(Q.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&&(Q.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?(Q.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(Q.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 ki=Ks;ki.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],ki.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};class Ee extends ee{constructor(t,e){var r;var s=(...n)=>{super(...n)};e=e||{},typeof t=="string"?(s(Ee.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 R.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===Rt.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 Ee._EMPTY=(t=Ee._EMPTY)!=null?t:R.ADAPTER.createCanvas(0,0),Ee._EMPTY}}Ui.push(Ee,qs,eo,ki,Ne,Fe,$s,to);class ku extends Fe{upload(t,e,s){const r=t.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Rt.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 Hi{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 St("disposeFramebuffer"),this.multisample=at.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new j(null,{scaleMode:Vt.NEAREST,resolution:1,mipmap:Ft.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new j(new ku(null,{width:this.width,height:this.height}),{scaleMode:Vt.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Ft.OFF,format:I.DEPTH_COMPONENT,type:G.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 j{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=at.NONE),super(null,t),this.mipmap=Ft.OFF,this.valid=!0,this.clearColor=[0,0,0,0],this.framebuffer=new Hi(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=et.add(s,et.NW),this.x0=h+o*et.uX(s),this.y0=l+a*et.uY(s),s=et.add(s,2),this.x1=h+o*et.uX(s),this.y1=l+a*et.uY(s),s=et.add(s,2),this.x2=h+o*et.uX(s),this.y2=l+a*et.uY(s),s=et.add(s,2),this.x3=h+o*et.uX(s),this.y3=l+a*et.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 io=new Qs;function Xi(i){i.destroy=function(){},i.on=function(){},i.once=function(){},i.emit=function(){}}class B extends Pe{constructor(t,e,s,r,n,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new z(0,0,1,1)),t instanceof B&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this._uvs=io,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 W(o.x,o.y):new W(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)&&Tt[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===io&&(this._uvs=new Qs),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},s=R.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else if(t instanceof j){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${he()}`,j.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${he()}`}n=t._pixiId}let o=Tt[n];if(r&&s&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof j)?(e.resolution||(e.resolution=te(t)),o=new B(new j(t,e)),o.baseTexture.cacheId=n,j.addToCache(o.baseTexture,n),B.addToCache(o,n)):!o&&t instanceof j&&(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(j.fromBuffer(t,e,s,r))}static fromLoader(t,e,s,r){const n=new j(t,Object.assign({scaleMode:R.SCALE_MODE,resolution:te(e)},r)),{resource:o}=n;o instanceof qs&&(o.url=e);const a=new B(n);return s||(s=e),j.addToCache(a.baseTexture,s),B.addToCache(a,s),s!==e&&(j.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),Tt[e]&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Tt[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Tt[t];if(e){const s=e.textureCacheIds.indexOf(t);return s>-1&&e.textureCacheIds.splice(s,1),delete Tt[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Tt[t.textureCacheIds[e]]===t&&delete Tt[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 j),Xi(B._EMPTY),Xi(B._EMPTY.baseTexture)),B._EMPTY}static get WHITE(){if(!B._WHITE){const t=R.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(j.from(t)),Xi(B._WHITE),Xi(B._WHITE.baseTexture)}return B._WHITE}}class ie 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 ie(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=at.NONE){const r=new Zs(Object.assign({width:t,height:e,resolution:1,multisample:s},this.textureOptions));return new ie(r)}getOptimalTexture(t,e,s=1,r=at.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=Ke(t),e=Ke(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||at.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 Je{constructor(t,e=0,s=!1,r=G.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 Je(t,e,s,r,n)}}let Hu=0;class nt{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=Hu++,this.disposeRunner=new St("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?Lt.ELEMENT_ARRAY_BUFFER:Lt.ARRAY_BUFFER}get index(){return this.type===Lt.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new nt(t)}}const Xu={Float32Array,Uint32Array,Int32Array,Uint8Array};function Vu(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=Li(c);r[u]||(r[u]=new Xu[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 so={5126:4,5123:2,5121:1};let zu=0;const Wu={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class se{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=zu++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new St("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 nt||(e instanceof Array&&(e=new Float32Array(e)),e=new nt(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 Je(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 nt||(t instanceof Array&&(t=new Uint16Array(t)),t=new nt(t)),t.type=Lt.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 nt;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*so[n.type]/4),n.buffer=0}for(s.data=Vu(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 se;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new nt(this.buffers[e].data.slice(0));for(const e in this.attributes){const s=this.attributes[e];t.attributes[e]=new Je(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=Lt.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new se,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 Wu[Li(o.buffers[a].data)](r[a]),e.buffers[a]=new nt(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=Lt.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*so[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 ro extends se{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class tr extends se{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 nt(this.vertices),this.uvBuffer=new nt(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 ju=0;class Pt{constructor(t,e,s){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=ju++,this.static=!!e,this.ubo=!!s,t instanceof nt?(this.buffer=t,this.buffer.type=Lt.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new nt(new Float32Array(1)),this.buffer.type=Lt.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 Pt(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 Pt(t,e,s)}static uboFrom(t,e){return new Pt(t,e!=null?e:!0,!0)}}class no{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=at.NONE,this.sourceFrame=new z,this.destinationFrame=new z,this.bindingSourceFrame=new z,this.bindingDestinationFrame=new z,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Vi=[new W,new W,new W,new W],er=new tt;class ir{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Js,this.statePool=[],this.quad=new ro,this.quadUv=new tr,this.tempRect=new z,this.activeState={},this.globalUniforms=new Pt({outputFrame:new z,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,_;const s=this.renderer,r=this.defaultFilterStack,n=this.statePool.pop()||new no,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 g=1;g<e.length;g++){const v=e[g];a=Math.min(a,v.resolution),h=Math.min(h,v.multisample),l=this.useMaxPadding?Math.max(l,v.padding):l+v.padding,c=c&&v.autoFit,u=u||((_=v.legacy)!=null?_:!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,Nt.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,Nt.CLEAR,e);const d=l;l=c,c=d}s[u].apply(this,l,h.renderTexture,Nt.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=Nt.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===Nt.CLEAR||e===Nt.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(Dt.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Dt.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(tt.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=at.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||at.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=Vi[0],r=Vi[1],n=Vi[2],o=Vi[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:M.RendererSystem,name:"filter"},U.add(ir);class ti{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 ti(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:M.RendererSystem,name:"batch"},U.add(sr);let oo=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=oo++,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=oo++,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(R.PREFER_ENV>=J.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:M.RendererSystem,name:"context"},U.add(rr);class ao{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=at.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Yu=new z;class nr{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Hi(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 z,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;R.PREFER_ENV===J.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=xt.COLOR|xt.DEPTH){const{gl:o}=this;o.clearColor(t,e,s,r),o.clear(n)}initFramebuffer(t){const{gl:e}=this,s=new ao(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=at.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=at.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 Hi(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=Yu,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 z}destroy(){this.renderer=null}}nr.extension={type:M.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;R.PREFER_ENV===J.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 _ in u)f[_]=0,p[_]=0;for(const _ in d)!d[_].size&&a.attributeData[_]?d[_].size=a.attributeData[_].size:d[_].size||console.warn(`PIXI Geometry attribute '${_}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[_].buffer]+=d[_].size*or[d[_].type];for(const _ in d){const g=d[_],v=g.size;g.stride===void 0&&(f[g.buffer]===v*or[g.type]?g.stride=0:g.stride=f[g.buffer]),g.start===void 0&&(g.start=p[g.buffer],p[g.buffer]+=v*or[g.type])}c=r.createVertexArray(),r.bindVertexArray(c);for(let _=0;_<u.length;_++){const g=u[_];o.bind(g),s&&g._glBuffers[n].refCount++}return this.activateVao(t,a),l[a.id]=c,l[h]=c,r.bindVertexArray(null),o.unbind(Lt.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:M.RendererSystem,name:"geometry"},U.add(ar);class ho{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=R.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 lo(i,t,e){const s=i.createShader(t);return i.shaderSource(s,e),i.compileShader(s),s}function co(i,t){const e=i.getShaderSource(t).split(`
|
|
13
|
+
Deprecated since v${i}`),console.warn(s))),Kn[t]=!0}const zs={},Tt=Object.create(null),It=Object.create(null);function Nu(){let i;for(i in Tt)Tt[i].destroy();for(i in It)It[i].destroy()}function Lu(){let i;for(i in Tt)delete Tt[i];for(i in It)delete It[i]}class Ws{constructor(t,e,s){this.canvas=R.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=s||R.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 Zn(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 Qn=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Ou(i){const t=Qn.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 Oi;function Jn(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location,Oi||(Oi=document.createElement("a")),Oi.href=i;const e=Wn.parse(Oi.href),s=!e.port&&t.port===""||e.port===t.port;return e.hostname!==t.hostname||!s||e.protocol!==t.protocol?"anonymous":""}function te(i,t=1){const e=R.RETINA_PREFIX.exec(i);return e?parseFloat(e[1]):t}var Uu={__proto__:null,isMobile:Ot,EventEmitter:Pe,earcut:Ps,url:Wn,path:ft,sayHello:Hh,skipHello:kh,isWebGLSupported:Yn,hex2rgb:ve,hex2string:Us,rgb2hex:Iu,string2hex:Fi,correctBlendMode:ks,premultiplyBlendMode:Gs,premultiplyRgba:$n,premultiplyTint:Ni,premultiplyTintToRgba:Hs,createIndicesForQuads:qn,getBufferType:Li,interleaveTypedArrays:Bu,isPow2:Xs,log2:Vs,nextPow2:Ke,removeItems:xe,sign:Te,uid:he,deprecation:Fu,BaseTextureCache:It,ProgramCache:zs,TextureCache:Tt,clearTextureCache:Lu,destroyTextureCache:Nu,CanvasRenderTarget:Ws,trimCanvas:Zn,decomposeDataUri:Ou,determineCrossOrigin:Jn,getResolutionOfUrl:te,DATA_URI:Qn};const Ui=[];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=Ui.length-1;s>=0;--s){const r=Ui[s];if(r.test&&r.test(i,e))return new r(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class De{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new St("setRealSize"),this.onUpdate=new St("update"),this.onError=new St("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 Fe extends De{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===Rt.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 Gu={scaleMode:Vt.NEAREST,format:I.RGBA,alphaMode:Rt.NPM},Ze=class extends Pe{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 De)&&(i=js(i,f),i.internal=!0),this.resolution=d||R.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:R.MIPMAP_TEXTURES,this.anisotropicLevel=r!=null?r:R.ANISOTROPIC_LEVEL,this._wrapMode=h||R.WRAP_MODE,this._scaleMode=n!=null?n:R.SCALE_MODE,this.format=l||I.RGBA,this.type=c||G.UNSIGNED_BYTE,this.target=u||de.TEXTURE_2D,this.alphaMode=e!=null?e:Rt.UNPACK,this.uid=he(),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 It[this.cacheId],delete Tt[this.cacheId],this.cacheId=null),this.dispose(),Ze.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(i,t,e=R.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}_${he()}`}r=i._pixiId}let n=It[r];if(s&&e&&!n)throw new Error(`The cacheId "${r}" does not exist in BaseTextureCache.`);return n||(n=new Ze(i,t),n.cacheId=r,Ze.addToCache(n,r)),n}static fromBuffer(i,t,e,s){i=i||new Float32Array(t*e*4);const r=new Fe(i,{width:t,height:e}),n=i instanceof Float32Array?G.FLOAT:G.UNSIGNED_BYTE;return new Ze(r,Object.assign({},Gu,s||{width:t,height:e,type:n}))}static addToCache(i,t){t&&(i.textureCacheIds.includes(t)||i.textureCacheIds.push(t),It[t]&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),It[t]=i)}static removeFromCache(i){if(typeof i=="string"){const t=It[i];if(t){const e=t.textureCacheIds.indexOf(i);return e>-1&&t.textureCacheIds.splice(e,1),delete It[i],t}}else if(i!=null&&i.textureCacheIds){for(let t=0;t<i.textureCacheIds.length;++t)delete It[i.textureCacheIds[t]];return i.textureCacheIds.length=0,i}return null}};let j=Ze;j._globalBatch=0;class Ys extends De{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 j;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 De?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 to 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=de.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 ee extends De{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=Jn(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===Rt.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 eo extends ee{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Qe=class extends Ys{constructor(i,t){const{width:e,height:s,autoLoad:r,linkBaseTexture:n}=t||{};if(i&&i.length!==Qe.SIDES)throw new Error(`Invalid length. Got ${i.length}, expected 6`);super(6,{width:e,height:s});for(let o=0;o<Qe.SIDES;o++)this.items[o].target=de.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=de.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=de.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<Qe.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===Qe.SIDES}};let $s=Qe;$s.SIDES=6;class qs extends ee{constructor(t,e){var s;if(e=e||{},typeof t=="string"){const r=new Image;ee.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:R.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===Rt.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 Gi=class extends ee{constructor(i,t){t=t||{},super(R.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)},Gi.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;ee.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_${he()}`,n.getContext("2d").drawImage(i,0,0,t,e,0,0,s,r),this._resolve(),this._resolve=null}}static getSize(i){const t=Gi.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"&&Gi.SVG_XML.test(i)}};let Ne=Gi;Ne.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Ne.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;const Ks=class extends ee{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];ee.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=Q.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&&(Q.shared.add(this.update,this),this._isConnectedToTicker=!0)}_onPlayStop(){this._isConnectedToTicker&&(Q.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&&(Q.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?(Q.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(Q.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 ki=Ks;ki.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],ki.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};class Ee extends ee{constructor(t,e){var r;var s=(...n)=>{super(...n)};e=e||{},typeof t=="string"?(s(Ee.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 R.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===Rt.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 Ee._EMPTY=(t=Ee._EMPTY)!=null?t:R.ADAPTER.createCanvas(0,0),Ee._EMPTY}}Ui.push(Ee,qs,eo,ki,Ne,Fe,$s,to);class ku extends Fe{upload(t,e,s){const r=t.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Rt.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 Hi{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 St("disposeFramebuffer"),this.multisample=at.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new j(null,{scaleMode:Vt.NEAREST,resolution:1,mipmap:Ft.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new j(new ku(null,{width:this.width,height:this.height}),{scaleMode:Vt.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Ft.OFF,format:I.DEPTH_COMPONENT,type:G.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 j{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=at.NONE),super(null,t),this.mipmap=Ft.OFF,this.valid=!0,this.clearColor=[0,0,0,0],this.framebuffer=new Hi(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=et.add(s,et.NW),this.x0=h+o*et.uX(s),this.y0=l+a*et.uY(s),s=et.add(s,2),this.x1=h+o*et.uX(s),this.y1=l+a*et.uY(s),s=et.add(s,2),this.x2=h+o*et.uX(s),this.y2=l+a*et.uY(s),s=et.add(s,2),this.x3=h+o*et.uX(s),this.y3=l+a*et.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 io=new Qs;function Xi(i){i.destroy=function(){},i.on=function(){},i.once=function(){},i.emit=function(){}}class B extends Pe{constructor(t,e,s,r,n,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new z(0,0,1,1)),t instanceof B&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this._uvs=io,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 W(o.x,o.y):new W(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)&&Tt[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===io&&(this._uvs=new Qs),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},s=R.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else if(t instanceof j){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${he()}`,j.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${he()}`}n=t._pixiId}let o=Tt[n];if(r&&s&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof j)?(e.resolution||(e.resolution=te(t)),o=new B(new j(t,e)),o.baseTexture.cacheId=n,j.addToCache(o.baseTexture,n),B.addToCache(o,n)):!o&&t instanceof j&&(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(j.fromBuffer(t,e,s,r))}static fromLoader(t,e,s,r){const n=new j(t,Object.assign({scaleMode:R.SCALE_MODE,resolution:te(e)},r)),{resource:o}=n;o instanceof qs&&(o.url=e);const a=new B(n);return s||(s=e),j.addToCache(a.baseTexture,s),B.addToCache(a,s),s!==e&&(j.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),Tt[e]&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Tt[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Tt[t];if(e){const s=e.textureCacheIds.indexOf(t);return s>-1&&e.textureCacheIds.splice(s,1),delete Tt[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Tt[t.textureCacheIds[e]]===t&&delete Tt[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 j),Xi(B._EMPTY),Xi(B._EMPTY.baseTexture)),B._EMPTY}static get WHITE(){if(!B._WHITE){const t=R.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(j.from(t)),Xi(B._WHITE),Xi(B._WHITE.baseTexture)}return B._WHITE}}class ie 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 ie(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=at.NONE){const r=new Zs(Object.assign({width:t,height:e,resolution:1,multisample:s},this.textureOptions));return new ie(r)}getOptimalTexture(t,e,s=1,r=at.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=Ke(t),e=Ke(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||at.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 Je{constructor(t,e=0,s=!1,r=G.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 Je(t,e,s,r,n)}}let Hu=0;class nt{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=Hu++,this.disposeRunner=new St("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?Lt.ELEMENT_ARRAY_BUFFER:Lt.ARRAY_BUFFER}get index(){return this.type===Lt.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new nt(t)}}const Xu={Float32Array,Uint32Array,Int32Array,Uint8Array};function Vu(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=Li(c);r[u]||(r[u]=new Xu[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 so={5126:4,5123:2,5121:1};let zu=0;const Wu={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class se{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=zu++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new St("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 nt||(e instanceof Array&&(e=new Float32Array(e)),e=new nt(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 Je(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 nt||(t instanceof Array&&(t=new Uint16Array(t)),t=new nt(t)),t.type=Lt.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 nt;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*so[n.type]/4),n.buffer=0}for(s.data=Vu(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 se;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new nt(this.buffers[e].data.slice(0));for(const e in this.attributes){const s=this.attributes[e];t.attributes[e]=new Je(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=Lt.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new se,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 Wu[Li(o.buffers[a].data)](r[a]),e.buffers[a]=new nt(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=Lt.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*so[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 ro extends se{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class tr extends se{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 nt(this.vertices),this.uvBuffer=new nt(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 ju=0;class Pt{constructor(t,e,s){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=ju++,this.static=!!e,this.ubo=!!s,t instanceof nt?(this.buffer=t,this.buffer.type=Lt.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new nt(new Float32Array(1)),this.buffer.type=Lt.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 Pt(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 Pt(t,e,s)}static uboFrom(t,e){return new Pt(t,e!=null?e:!0,!0)}}class no{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=at.NONE,this.sourceFrame=new z,this.destinationFrame=new z,this.bindingSourceFrame=new z,this.bindingDestinationFrame=new z,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Vi=[new W,new W,new W,new W],er=new tt;class ir{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Js,this.statePool=[],this.quad=new ro,this.quadUv=new tr,this.tempRect=new z,this.activeState={},this.globalUniforms=new Pt({outputFrame:new z,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,_;const s=this.renderer,r=this.defaultFilterStack,n=this.statePool.pop()||new no,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 g=1;g<e.length;g++){const v=e[g];a=Math.min(a,v.resolution),h=Math.min(h,v.multisample),l=this.useMaxPadding?Math.max(l,v.padding):l+v.padding,c=c&&v.autoFit,u=u||((_=v.legacy)!=null?_:!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,Nt.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,Nt.CLEAR,e);const d=l;l=c,c=d}s[u].apply(this,l,h.renderTexture,Nt.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=Nt.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===Nt.CLEAR||e===Nt.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(Dt.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Dt.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(tt.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=at.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||at.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=Vi[0],r=Vi[1],n=Vi[2],o=Vi[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:M.RendererSystem,name:"filter"},U.add(ir);class ti{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 ti(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:M.RendererSystem,name:"batch"},U.add(sr);let oo=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=oo++,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=oo++,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(R.PREFER_ENV>=J.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:M.RendererSystem,name:"context"},U.add(rr);class ao{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=at.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Yu=new z;class nr{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Hi(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 z,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;R.PREFER_ENV===J.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=xt.COLOR|xt.DEPTH){const{gl:o}=this;o.clearColor(t,e,s,r),o.clear(n)}initFramebuffer(t){const{gl:e}=this,s=new ao(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=at.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=at.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 Hi(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=Yu,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 z}destroy(){this.renderer=null}}nr.extension={type:M.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;R.PREFER_ENV===J.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 _ in u)f[_]=0,p[_]=0;for(const _ in d)!d[_].size&&a.attributeData[_]?d[_].size=a.attributeData[_].size:d[_].size||console.warn(`PIXI Geometry attribute '${_}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[_].buffer]+=d[_].size*or[d[_].type];for(const _ in d){const g=d[_],v=g.size;g.stride===void 0&&(f[g.buffer]===v*or[g.type]?g.stride=0:g.stride=f[g.buffer]),g.start===void 0&&(g.start=p[g.buffer],p[g.buffer]+=v*or[g.type])}c=r.createVertexArray(),r.bindVertexArray(c);for(let _=0;_<u.length;_++){const g=u[_];o.bind(g),s&&g._glBuffers[n].refCount++}return this.activateVao(t,a),l[a.id]=c,l[h]=c,r.bindVertexArray(null),o.unbind(Lt.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:M.RendererSystem,name:"geometry"},U.add(ar);class ho{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=R.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 lo(i,t,e){const s=i.createShader(t);return i.shaderSource(s,e),i.compileShader(s),s}function co(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 $u(i,t,e,s){i.getProgramParameter(t,i.LINK_STATUS)||(i.getShaderParameter(e,i.COMPILE_STATUS)||co(i,e),i.getShaderParameter(s,i.COMPILE_STATUS)||co(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 uo(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 fo={};let Le=fo;function po(){if(Le===fo||(Le==null?void 0:Le.isContextLost())){const i=R.ADAPTER.createCanvas();let t;R.PREFER_ENV>=J.WEBGL2&&(t=i.getContext("webgl2",{})),t||(t=i.getContext("webgl",{})||i.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Le=t}return Le}let zi;function qu(){if(!zi){zi=wt.MEDIUM;const i=po();i&&i.getShaderPrecisionFormat&&(zi=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?wt.HIGH:wt.MEDIUM)}return zi}function mo(i,t,e){if(i.substring(0,9)!=="precision"){let s=t;return t===wt.HIGH&&e!==wt.HIGH&&(s=wt.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 dd{}class Io{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 fd(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:_o(o),location:t.getAttribLocation(i,n.name)};e[n.name]=a}return e}function pd(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:uo(h,n.size)}}return e}function Po(i,t){var h;const e=lo(i,i.VERTEX_SHADER,t.vertexSrc),s=lo(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)||$u(i,r,e,s),t.attributeData=fd(r,i),t.uniformData=pd(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:uo(c.type,c.size)}}return new Io(r,o)}let md=0;const qi={textureCount:0,uboCount:0};class xr{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=md++}systemCheck(){if(!id())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||(qi.textureCount=0,qi.uboCount=0,this.syncUniformGroup(t.uniformGroup,qi)),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]=Ju(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,qi,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]=Co(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=Po(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}}xr.extension={type:M.RendererSystem,name:"shader"},U.add(xr);function _d(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 gd=0,yd=1,vd=2,xd=3,Td=4,Ed=5,Tr=class{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=k.NONE,this._blendEq=!1,this.map=[],this.map[gd]=this.setBlend,this.map[yd]=this.setOffset,this.map[vd]=this.setCullFace,this.map[xd]=this.setDepthTest,this.map[Td]=this.setFrontFace,this.map[Ed]=this.setDepthMask,this.checks=[],this.defaultState=new Yt,this.defaultState.blend=!0}contextChange(i){this.gl=i,this.blendModes=_d(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 Er=Tr;Er.extension={type:M.RendererSystem,name:"state"},U.add(Er);class br{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=R.GC_MAX_IDLE,this.checkCountMax=R.GC_MAX_CHECK_COUNT,this.mode=R.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}}br.extension={type:M.RendererSystem,name:"textureGC"},U.add(br);function bd(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[G.UNSIGNED_BYTE]:{[I.RGBA]:i.RGBA8,[I.RGB]:i.RGB8,[I.RG]:i.RG8,[I.RED]:i.R8,[I.RGBA_INTEGER]:i.RGBA8UI,[I.RGB_INTEGER]:i.RGB8UI,[I.RG_INTEGER]:i.RG8UI,[I.RED_INTEGER]:i.R8UI,[I.ALPHA]:i.ALPHA,[I.LUMINANCE]:i.LUMINANCE,[I.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[G.BYTE]:{[I.RGBA]:i.RGBA8_SNORM,[I.RGB]:i.RGB8_SNORM,[I.RG]:i.RG8_SNORM,[I.RED]:i.R8_SNORM,[I.RGBA_INTEGER]:i.RGBA8I,[I.RGB_INTEGER]:i.RGB8I,[I.RG_INTEGER]:i.RG8I,[I.RED_INTEGER]:i.R8I},[G.UNSIGNED_SHORT]:{[I.RGBA_INTEGER]:i.RGBA16UI,[I.RGB_INTEGER]:i.RGB16UI,[I.RG_INTEGER]:i.RG16UI,[I.RED_INTEGER]:i.R16UI,[I.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[G.SHORT]:{[I.RGBA_INTEGER]:i.RGBA16I,[I.RGB_INTEGER]:i.RGB16I,[I.RG_INTEGER]:i.RG16I,[I.RED_INTEGER]:i.R16I},[G.UNSIGNED_INT]:{[I.RGBA_INTEGER]:i.RGBA32UI,[I.RGB_INTEGER]:i.RGB32UI,[I.RG_INTEGER]:i.RG32UI,[I.RED_INTEGER]:i.R32UI,[I.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[G.INT]:{[I.RGBA_INTEGER]:i.RGBA32I,[I.RGB_INTEGER]:i.RGB32I,[I.RG_INTEGER]:i.RG32I,[I.RED_INTEGER]:i.R32I},[G.FLOAT]:{[I.RGBA]:i.RGBA32F,[I.RGB]:i.RGB32F,[I.RG]:i.RG32F,[I.RED]:i.R32F,[I.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[G.HALF_FLOAT]:{[I.RGBA]:i.RGBA16F,[I.RGB]:i.RGB16F,[I.RG]:i.RG16F,[I.RED]:i.R16F},[G.UNSIGNED_SHORT_5_6_5]:{[I.RGB]:i.RGB565},[G.UNSIGNED_SHORT_4_4_4_4]:{[I.RGBA]:i.RGBA4},[G.UNSIGNED_SHORT_5_5_5_1]:{[I.RGBA]:i.RGB5_A1},[G.UNSIGNED_INT_2_10_10_10_REV]:{[I.RGBA]:i.RGB10_A2,[I.RGBA_INTEGER]:i.RGB10_A2UI},[G.UNSIGNED_INT_10F_11F_11F_REV]:{[I.RGB]:i.R11F_G11F_B10F},[G.UNSIGNED_INT_5_9_9_9_REV]:{[I.RGB]:i.RGB9_E5},[G.UNSIGNED_INT_24_8]:{[I.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[G.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[I.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[G.UNSIGNED_BYTE]:{[I.RGBA]:i.RGBA,[I.RGB]:i.RGB,[I.ALPHA]:i.ALPHA,[I.LUMINANCE]:i.LUMINANCE,[I.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[G.UNSIGNED_SHORT_5_6_5]:{[I.RGB]:i.RGB},[G.UNSIGNED_SHORT_4_4_4_4]:{[I.RGBA]:i.RGBA},[G.UNSIGNED_SHORT_5_5_5_1]:{[I.RGBA]:i.RGBA}},t}class Ki{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=G.UNSIGNED_BYTE,this.internalFormat=I.RGBA,this.samplerType=0}}class wr{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new j,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=bd(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 Ki(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 Ki(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!==Ei.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Ki(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===G.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!==Ei.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&&xe(this.managedTextures,r,1)}}updateTextureStyle(t){var s;const e=t._glTextures[this.CONTEXT_UID];!e||((t.mipmap===Ft.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=zt.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!==Ft.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===Vt.LINEAR?s.LINEAR_MIPMAP_LINEAR:s.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===Vt.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===Vt.LINEAR?s.LINEAR:s.NEAREST);s.texParameteri(t.target,s.TEXTURE_MAG_FILTER,t.scaleMode===Vt.LINEAR?s.LINEAR:s.NEAREST)}destroy(){this.renderer=null}}wr.extension={type:M.RendererSystem,name:"texture"},U.add(wr);const wd=new ze;class Sr{constructor(t){this.renderer=t,this._tempMatrix=new tt}generateTexture(t,e){const h=e||{},{region:s}=h,r=_n(h,["region"]),n=s||t.getLocalBounds(null,!0);n.width===0&&(n.width=1),n.height===0&&(n.height=1);const o=ie.create(Zt({width:n.width,height:n.height},r));this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const a=t.transform;return t.transform=wd,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=a,o}destroy(){}}Sr.extension={type:[M.RendererSystem,M.CanvasRendererSystem],name:"textureGenerator"},U.add(Sr);class Ar{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"?Fi(t.color):t.color),this.alpha=t.alpha}get color(){return this._backgroundColor}set color(t){this._backgroundColor=t,this._backgroundColorString=Us(t),ve(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(){}}Ar.extension={type:[M.RendererSystem,M.CanvasRendererSystem],name:"background"},U.add(Ar);class Rr{constructor(t){this.renderer=t}init(t){this.screen=new z(0,0,t.width,t.height),this.element=t.view||R.ADAPTER.createCanvas(),this.resolution=t.resolution||R.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:[M.RendererSystem,M.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:[M.RendererSystem,M.CanvasRendererSystem],name:"_plugin"},U.add(Cr);class Mo extends Pe{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 St(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:[M.RendererSystem,M.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:M.RendererSystem,name:"transformFeedback"},U.add(Pr);const Bo=[];U.handleByList(M.Renderer,Bo);function Do(i){for(const t of Bo)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var Sd=`attribute vec2 aVertexPosition;
|
|
418
|
+
`))}}class dd{}class Io{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 fd(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:_o(o),location:t.getAttribLocation(i,n.name)};e[n.name]=a}return e}function pd(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:uo(h,n.size)}}return e}function Po(i,t){var h;const e=lo(i,i.VERTEX_SHADER,t.vertexSrc),s=lo(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)||$u(i,r,e,s),t.attributeData=fd(r,i),t.uniformData=pd(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:uo(c.type,c.size)}}return new Io(r,o)}let md=0;const qi={textureCount:0,uboCount:0};class xr{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=md++}systemCheck(){if(!id())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||(qi.textureCount=0,qi.uboCount=0,this.syncUniformGroup(t.uniformGroup,qi)),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]=Ju(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,qi,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]=Co(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=Po(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}}xr.extension={type:M.RendererSystem,name:"shader"},U.add(xr);function _d(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 gd=0,yd=1,vd=2,xd=3,Td=4,Ed=5,Tr=class{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=k.NONE,this._blendEq=!1,this.map=[],this.map[gd]=this.setBlend,this.map[yd]=this.setOffset,this.map[vd]=this.setCullFace,this.map[xd]=this.setDepthTest,this.map[Td]=this.setFrontFace,this.map[Ed]=this.setDepthMask,this.checks=[],this.defaultState=new Yt,this.defaultState.blend=!0}contextChange(i){this.gl=i,this.blendModes=_d(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 Er=Tr;Er.extension={type:M.RendererSystem,name:"state"},U.add(Er);class br{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=R.GC_MAX_IDLE,this.checkCountMax=R.GC_MAX_CHECK_COUNT,this.mode=R.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}}br.extension={type:M.RendererSystem,name:"textureGC"},U.add(br);function bd(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[G.UNSIGNED_BYTE]:{[I.RGBA]:i.RGBA8,[I.RGB]:i.RGB8,[I.RG]:i.RG8,[I.RED]:i.R8,[I.RGBA_INTEGER]:i.RGBA8UI,[I.RGB_INTEGER]:i.RGB8UI,[I.RG_INTEGER]:i.RG8UI,[I.RED_INTEGER]:i.R8UI,[I.ALPHA]:i.ALPHA,[I.LUMINANCE]:i.LUMINANCE,[I.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[G.BYTE]:{[I.RGBA]:i.RGBA8_SNORM,[I.RGB]:i.RGB8_SNORM,[I.RG]:i.RG8_SNORM,[I.RED]:i.R8_SNORM,[I.RGBA_INTEGER]:i.RGBA8I,[I.RGB_INTEGER]:i.RGB8I,[I.RG_INTEGER]:i.RG8I,[I.RED_INTEGER]:i.R8I},[G.UNSIGNED_SHORT]:{[I.RGBA_INTEGER]:i.RGBA16UI,[I.RGB_INTEGER]:i.RGB16UI,[I.RG_INTEGER]:i.RG16UI,[I.RED_INTEGER]:i.R16UI,[I.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[G.SHORT]:{[I.RGBA_INTEGER]:i.RGBA16I,[I.RGB_INTEGER]:i.RGB16I,[I.RG_INTEGER]:i.RG16I,[I.RED_INTEGER]:i.R16I},[G.UNSIGNED_INT]:{[I.RGBA_INTEGER]:i.RGBA32UI,[I.RGB_INTEGER]:i.RGB32UI,[I.RG_INTEGER]:i.RG32UI,[I.RED_INTEGER]:i.R32UI,[I.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[G.INT]:{[I.RGBA_INTEGER]:i.RGBA32I,[I.RGB_INTEGER]:i.RGB32I,[I.RG_INTEGER]:i.RG32I,[I.RED_INTEGER]:i.R32I},[G.FLOAT]:{[I.RGBA]:i.RGBA32F,[I.RGB]:i.RGB32F,[I.RG]:i.RG32F,[I.RED]:i.R32F,[I.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[G.HALF_FLOAT]:{[I.RGBA]:i.RGBA16F,[I.RGB]:i.RGB16F,[I.RG]:i.RG16F,[I.RED]:i.R16F},[G.UNSIGNED_SHORT_5_6_5]:{[I.RGB]:i.RGB565},[G.UNSIGNED_SHORT_4_4_4_4]:{[I.RGBA]:i.RGBA4},[G.UNSIGNED_SHORT_5_5_5_1]:{[I.RGBA]:i.RGB5_A1},[G.UNSIGNED_INT_2_10_10_10_REV]:{[I.RGBA]:i.RGB10_A2,[I.RGBA_INTEGER]:i.RGB10_A2UI},[G.UNSIGNED_INT_10F_11F_11F_REV]:{[I.RGB]:i.R11F_G11F_B10F},[G.UNSIGNED_INT_5_9_9_9_REV]:{[I.RGB]:i.RGB9_E5},[G.UNSIGNED_INT_24_8]:{[I.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[G.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[I.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[G.UNSIGNED_BYTE]:{[I.RGBA]:i.RGBA,[I.RGB]:i.RGB,[I.ALPHA]:i.ALPHA,[I.LUMINANCE]:i.LUMINANCE,[I.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[G.UNSIGNED_SHORT_5_6_5]:{[I.RGB]:i.RGB},[G.UNSIGNED_SHORT_4_4_4_4]:{[I.RGBA]:i.RGBA},[G.UNSIGNED_SHORT_5_5_5_1]:{[I.RGBA]:i.RGBA}},t}class Ki{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=G.UNSIGNED_BYTE,this.internalFormat=I.RGBA,this.samplerType=0}}class wr{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new j,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=bd(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 Ki(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 Ki(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!==Ei.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Ki(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===G.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!==Ei.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&&xe(this.managedTextures,r,1)}}updateTextureStyle(t){var s;const e=t._glTextures[this.CONTEXT_UID];!e||((t.mipmap===Ft.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=zt.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!==Ft.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===Vt.LINEAR?s.LINEAR_MIPMAP_LINEAR:s.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===Vt.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===Vt.LINEAR?s.LINEAR:s.NEAREST);s.texParameteri(t.target,s.TEXTURE_MAG_FILTER,t.scaleMode===Vt.LINEAR?s.LINEAR:s.NEAREST)}destroy(){this.renderer=null}}wr.extension={type:M.RendererSystem,name:"texture"},U.add(wr);const wd=new ze;class Sr{constructor(t){this.renderer=t,this._tempMatrix=new tt}generateTexture(t,e){const h=e||{},{region:s}=h,r=_n(h,["region"]),n=s||t.getLocalBounds(null,!0);n.width===0&&(n.width=1),n.height===0&&(n.height=1);const o=ie.create(Zt({width:n.width,height:n.height},r));this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const a=t.transform;return t.transform=wd,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=a,o}destroy(){}}Sr.extension={type:[M.RendererSystem,M.CanvasRendererSystem],name:"textureGenerator"},U.add(Sr);class Ar{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"?Fi(t.color):t.color),this.alpha=t.alpha}get color(){return this._backgroundColor}set color(t){this._backgroundColor=t,this._backgroundColorString=Us(t),ve(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(){}}Ar.extension={type:[M.RendererSystem,M.CanvasRendererSystem],name:"background"},U.add(Ar);class Rr{constructor(t){this.renderer=t}init(t){this.screen=new z(0,0,t.width,t.height),this.element=t.view||R.ADAPTER.createCanvas(),this.resolution=t.resolution||R.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:[M.RendererSystem,M.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:[M.RendererSystem,M.CanvasRendererSystem],name:"_plugin"},U.add(Cr);class Mo extends Pe{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 St(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:[M.RendererSystem,M.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:M.RendererSystem,name:"transformFeedback"},U.add(Pr);const Bo=[];U.handleByList(M.Renderer,Bo);function Do(i){for(const t of Bo)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var Sd=`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 Ae=class extends ti{constructor(i){super(i),this.setShaderGenerator(),this.geometryClass=Dr,this.vertexSize=6,this.state=Yt.for2d(),this.size=R.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 Rd}static get defaultFragmentTemplate(){return Cd}setShaderGenerator({vertex:i=Ae.defaultVertexSrc,fragment:t=Ae.defaultFragmentTemplate}={}){this.shaderGenerator=new No(i,t)}contextChange(){const i=this.renderer.gl;R.PREFER_ENV===J.WEBGL_LEGACY?this.MAX_TEXTURES=1:(this.MAX_TEXTURES=Math.min(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),R.SPRITE_MAX_TEXTURES),this.MAX_TEXTURES=vo(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}=Ae,e=this.size/4,s=Math.floor(e/this.MAX_TEXTURES)+1;for(;i.length<e;)i.push(new Zi);for(;t.length<s;)t.push(new Qi);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=Ae._textureArrayPool,s=this.renderer.batch,r=this._tempBoundTextures,n=this.renderer.textureGC.count;let o=++j._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;j._globalBatch=o}buildDrawCalls(i,t,e){const{_bufferedElements:s,_attributeBuffer:r,_indexBuffer:n,vertexSize:o}=this,a=Ae._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,_=Gs[p.alphaMode?1:0][f.blendMode];s[d]=null,t<d&&u.blend!==_&&(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=_}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;R.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=Ae._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),R.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=Ke(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 Ji(s*this.vertexSize*4)),r}getIndexBuffer(i){const t=Ke(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?Ni(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 si=Ae;si.extension={name:"batch",type:M.RendererPlugin},si._drawCallPool=[],si._textureArrayPool=[],U.add(si);class Id{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new St("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}class Pd{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Fr{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 Pd(s.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Fr.extension={type:M.RendererSystem,name:"buffer"},U.add(Fr);class Nr{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>=at.HIGH?this.multisample=at.HIGH:e>=at.MEDIUM?this.multisample=at.MEDIUM:e>=at.LOW?this.multisample=at.LOW:this.multisample=at.NONE}destroy(){}}Nr.extension={type:M.RendererSystem,name:"_multisample"},U.add(Nr);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:M.RendererSystem,name:"objectRenderer"},U.add(Lr);const Md="7.0.
|
|
494
|
+
`;const Ae=class extends ti{constructor(i){super(i),this.setShaderGenerator(),this.geometryClass=Dr,this.vertexSize=6,this.state=Yt.for2d(),this.size=R.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 Rd}static get defaultFragmentTemplate(){return Cd}setShaderGenerator({vertex:i=Ae.defaultVertexSrc,fragment:t=Ae.defaultFragmentTemplate}={}){this.shaderGenerator=new No(i,t)}contextChange(){const i=this.renderer.gl;R.PREFER_ENV===J.WEBGL_LEGACY?this.MAX_TEXTURES=1:(this.MAX_TEXTURES=Math.min(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),R.SPRITE_MAX_TEXTURES),this.MAX_TEXTURES=vo(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}=Ae,e=this.size/4,s=Math.floor(e/this.MAX_TEXTURES)+1;for(;i.length<e;)i.push(new Zi);for(;t.length<s;)t.push(new Qi);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=Ae._textureArrayPool,s=this.renderer.batch,r=this._tempBoundTextures,n=this.renderer.textureGC.count;let o=++j._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;j._globalBatch=o}buildDrawCalls(i,t,e){const{_bufferedElements:s,_attributeBuffer:r,_indexBuffer:n,vertexSize:o}=this,a=Ae._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,_=Gs[p.alphaMode?1:0][f.blendMode];s[d]=null,t<d&&u.blend!==_&&(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=_}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;R.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=Ae._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),R.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=Ke(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 Ji(s*this.vertexSize*4)),r}getIndexBuffer(i){const t=Ke(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?Ni(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 si=Ae;si.extension={name:"batch",type:M.RendererPlugin},si._drawCallPool=[],si._textureArrayPool=[],U.add(si);class Id{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new St("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}class Pd{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Fr{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 Pd(s.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Fr.extension={type:M.RendererSystem,name:"buffer"},U.add(Fr);class Nr{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>=at.HIGH?this.multisample=at.HIGH:e>=at.MEDIUM?this.multisample=at.MEDIUM:e>=at.LOW?this.multisample=at.LOW:this.multisample=at.NONE}destroy(){}}Nr.extension={type:M.RendererSystem,name:"_multisample"},U.add(Nr);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:M.RendererSystem,name:"objectRenderer"},U.add(Lr);const Md="7.0.4";var Bd=`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 $d extends Mt{constructor(t=.5,e=Math.random()){super(Mr,Yd,{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}}R.SORTABLE_CHILDREN=!1;class ri{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?z.EMPTY:(t=t||new z(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,_=this.maxY,g=o*e+h*s+c,v=a*e+l*s+u;d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*r+h*s+c,v=a*r+l*s+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*e+h*n+c,v=a*e+l*n+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*r+h*n+c,v=a*r+l*n+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,this.minX=d,this.minY=f,this.maxX=p,this.maxY=_}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,_=this.maxX,g=this.maxY;for(let v=s;v<r;v+=2){const T=e[v],y=e[v+1],x=a*T+l*y+u,b=c*y+h*T+d;f=Math.min(f,x-n),_=Math.max(_,x+n),p=Math.min(p,b-o),g=Math.max(g,b+o)}this.minX=f,this.minY=p,this.maxX=_,this.maxY=g}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 it extends Pe{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new ze,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 ri,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(it.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 z),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new z),t=this._localBoundsRect),this._localBounds||(this._localBounds=new ri);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 Lo),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*Mn}set angle(t){this.transform.rotation=t*Bn}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 Lo extends it{constructor(){super(...arguments),this.sortDirty=null}}it.prototype.displayObjectUpdateTransform=it.prototype.updateTransform;function qd(i,t){return i.zIndex===t.zIndex?i._lastSortedIndex-t._lastSortedIndex:i.zIndex-t.zIndex}class At extends it{constructor(){super(),this.children=[],this.sortableChildren=R.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);xe(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,xe(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,xe(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(qd),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!==At.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}}At.prototype.containerUpdateTransform=At.prototype.updateTransform;const ni=new W,Kd=new Uint16Array([0,1,2,0,2,3]);class le extends At{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=Kd,this.pluginName="batch",this.isSprite=!0,this._roundPixels=R.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Te(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Te(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,_=0,g=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,g=c.y-d._y*u.height,_=g+c.height):(p=-d._x*u.width,f=p+u.width,g=-d._y*u.height,_=g+u.height),l[0]=s*p+n*g+a,l[1]=o*g+r*p+h,l[2]=s*f+n*g+a,l[3]=o*g+r*f+h,l[4]=s*f+n*_+a,l[5]=o*_+r*f+h,l[6]=s*p+n*_+a,l[7]=o*_+r*p+h,this._roundPixels){const v=R.RESOLUTION;for(let T=0;T<l.length;++T)l[T]=Math.round((l[T]*v|0)/v)}}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,_=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*_+c,e[5]=l*_+a*f+u,e[6]=o*d+h*_+c,e[7]=l*_+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 ri),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 z),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ni);const e=this._texture.orig.width,s=this._texture.orig.height,r=-e*this.anchor.x;let n=0;return ni.x>=r&&ni.x<r+e&&(n=-s*this.anchor.y,ni.y>=n&&ni.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 le(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=Te(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=Te(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 Oo=new tt;it.prototype._cacheAsBitmap=!1,it.prototype._cacheData=null,it.prototype._cacheAsBitmapResolution=null,it.prototype._cacheAsBitmapMultisample=null;class Zd{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(it.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 Zd),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)}}}),it.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))},it.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 _=this.filters[0].padding;s.pad(_)}s.ceil(R.RESOLUTION);const r=t.renderTexture.current,n=t.renderTexture.sourceFrame.clone(),o=t.renderTexture.destinationFrame.clone(),a=t.projection.transform,h=ie.create({width:s.width,height:s.height,resolution:this.cacheAsBitmapResolution||t.resolution,multisample:(p=this.cacheAsBitmapMultisample)!=null?p:t.multisample}),l=`cacheAsBitmap_${he()}`;this._cacheData.textureCacheId=l,j.addToCache(h.baseTexture,l),B.addToCache(h,l);const c=this.transform.localTransform.copyTo(Oo).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 le(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)},it.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))},it.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(R.RESOLUTION);const o=ie.create({width:e.width,height:e.height}),a=`cacheAsBitmap_${he()}`;this._cacheData.textureCacheId=a,j.addToCache(o.baseTexture,a),B.addToCache(o,a);const h=Oo;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 le(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)},it.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},it.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},it.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,j.removeFromCache(this._cacheData.textureCacheId),B.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},it.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},it.prototype.name=null,At.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},it.prototype.getGlobalPosition=function(t=new W,e=!1){return this.parent?this.parent.toGlobal(this.position,t,e):(t.x=this.position.x,t.y=this.position.y),t};const Uo={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};class Oe{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Oe.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new W,this.page=new W,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 oi extends Oe{constructor(){super(...arguments),this.client=new W,this.movement=new W,this.offset=new W,this.global=new W,this.screen=new W}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,_){throw new Error("Method not implemented.")}}class Bt extends oi{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 ts extends oi{constructor(){super(...arguments),this.DOM_DELTA_LINE=0,this.DOM_DELTA_PAGE=1,this.DOM_DELTA_PIXEL=2}}const Qd=2048,Jd=new W,Gr=new W;class Go{constructor(t){this.dispatch=new Pe,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,Jd.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<Qd&&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,Gr),!t.hitArea.contains(Gr.x,Gr.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 Bt)){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 Bt)){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 Bt)){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 Bt)){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 Bt)){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 Bt)){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 ts)){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(Bt);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(ts);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(Bt);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 Bt&&e instanceof Bt&&(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 oi&&e instanceof oi&&(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 tf=1,ef={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class kr{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Go(null),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Bt(null),this.rootWheelEvent=new ts(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=tf),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=ef[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}}kr.extension={name:"events",type:[M.RendererSystem,M.CanvasRendererSystem]},U.add(kr);const ko={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 Oe))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}};it.mixin(ko),it.mixin(Uo);const sf=9,es=100,rf=0,nf=0,Ho=2,Xo=1,of=-1e3,af=-1e3,hf=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,(Ot.tablet||Ot.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${es}px`,e.style.height=`${es}px`,e.style.position="absolute",e.style.top=`${rf}px`,e.style.left=`${nf}px`,e.style.zIndex=Ho.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=`${Xo}px`,t.style.height=`${Xo}px`,t.style.position="absolute",t.style.top=`${of}px`,t.style.left=`${af}px`,t.style.zIndex=hf.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(Ot.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,xe(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 _=f.worldTransform;f.hitArea?(u.style.left=`${(_.tx+p.x*_.a)*l}px`,u.style.top=`${(_.ty+p.y*_.d)*c}px`,u.style.width=`${p.width*_.a*l}px`,u.style.height=`${p.height*_.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=`${es}px`,e.style.height=`${es}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Ho.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 Oe(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===sf&&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:[M.RendererPlugin,M.CanvasRendererPlugin]},U.add(Hr);const Xr=class{constructor(i){this.stage=new At,i=Object.assign({forceCanvas:!1},i),this.renderer=Do(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(M.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=M.Application,U.add(zr);class lf{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 $t=(i,t)=>(Array.isArray(i)||(i=[i]),t?i.map(e=>typeof e=="string"?t(e):e):i);function Vo(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?Vo(i.replace(s[e],a),t,e+1,s,r):r.push(i.replace(s[e],a))}}function zo(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)}),Vo(i,r,0,e,s)}else s.push(i);return s}const ai=i=>!Array.isArray(i);class cf{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=$t(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&&j.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 Ue=new cf;class uf{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=ai(t),o=$t(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 $d extends Mt{constructor(t=.5,e=Math.random()){super(Mr,Yd,{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}}R.SORTABLE_CHILDREN=!1;class ri{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?z.EMPTY:(t=t||new z(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,_=this.maxY,g=o*e+h*s+c,v=a*e+l*s+u;d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*r+h*s+c,v=a*r+l*s+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*e+h*n+c,v=a*e+l*n+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*r+h*n+c,v=a*r+l*n+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,this.minX=d,this.minY=f,this.maxX=p,this.maxY=_}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,_=this.maxX,g=this.maxY;for(let v=s;v<r;v+=2){const T=e[v],y=e[v+1],x=a*T+l*y+u,b=c*y+h*T+d;f=Math.min(f,x-n),_=Math.max(_,x+n),p=Math.min(p,b-o),g=Math.max(g,b+o)}this.minX=f,this.minY=p,this.maxX=_,this.maxY=g}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 it extends Pe{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new ze,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 ri,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(it.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 z),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new z),t=this._localBoundsRect),this._localBounds||(this._localBounds=new ri);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 Lo),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*Mn}set angle(t){this.transform.rotation=t*Bn}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 Lo extends it{constructor(){super(...arguments),this.sortDirty=null}}it.prototype.displayObjectUpdateTransform=it.prototype.updateTransform;function qd(i,t){return i.zIndex===t.zIndex?i._lastSortedIndex-t._lastSortedIndex:i.zIndex-t.zIndex}class At extends it{constructor(){super(),this.children=[],this.sortableChildren=R.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);xe(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,xe(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,xe(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(qd),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!==At.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}}At.prototype.containerUpdateTransform=At.prototype.updateTransform;const ni=new W,Kd=new Uint16Array([0,1,2,0,2,3]);class le extends At{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=Kd,this.pluginName="batch",this.isSprite=!0,this._roundPixels=R.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Te(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Te(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,_=0,g=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,g=c.y-d._y*u.height,_=g+c.height):(p=-d._x*u.width,f=p+u.width,g=-d._y*u.height,_=g+u.height),l[0]=s*p+n*g+a,l[1]=o*g+r*p+h,l[2]=s*f+n*g+a,l[3]=o*g+r*f+h,l[4]=s*f+n*_+a,l[5]=o*_+r*f+h,l[6]=s*p+n*_+a,l[7]=o*_+r*p+h,this._roundPixels){const v=R.RESOLUTION;for(let T=0;T<l.length;++T)l[T]=Math.round(l[T]*v)/v}}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,_=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*_+c,e[5]=l*_+a*f+u,e[6]=o*d+h*_+c,e[7]=l*_+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 ri),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 z),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ni);const e=this._texture.orig.width,s=this._texture.orig.height,r=-e*this.anchor.x;let n=0;return ni.x>=r&&ni.x<r+e&&(n=-s*this.anchor.y,ni.y>=n&&ni.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 le(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=Te(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=Te(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 Oo=new tt;it.prototype._cacheAsBitmap=!1,it.prototype._cacheData=null,it.prototype._cacheAsBitmapResolution=null,it.prototype._cacheAsBitmapMultisample=null;class Zd{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(it.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 Zd),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)}}}),it.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))},it.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 _=this.filters[0].padding;s.pad(_)}s.ceil(R.RESOLUTION);const r=t.renderTexture.current,n=t.renderTexture.sourceFrame.clone(),o=t.renderTexture.destinationFrame.clone(),a=t.projection.transform,h=ie.create({width:s.width,height:s.height,resolution:this.cacheAsBitmapResolution||t.resolution,multisample:(p=this.cacheAsBitmapMultisample)!=null?p:t.multisample}),l=`cacheAsBitmap_${he()}`;this._cacheData.textureCacheId=l,j.addToCache(h.baseTexture,l),B.addToCache(h,l);const c=this.transform.localTransform.copyTo(Oo).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 le(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)},it.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))},it.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(R.RESOLUTION);const o=ie.create({width:e.width,height:e.height}),a=`cacheAsBitmap_${he()}`;this._cacheData.textureCacheId=a,j.addToCache(o.baseTexture,a),B.addToCache(o,a);const h=Oo;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 le(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)},it.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},it.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},it.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,j.removeFromCache(this._cacheData.textureCacheId),B.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},it.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},it.prototype.name=null,At.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},it.prototype.getGlobalPosition=function(t=new W,e=!1){return this.parent?this.parent.toGlobal(this.position,t,e):(t.x=this.position.x,t.y=this.position.y),t};const Uo={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};class Oe{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Oe.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new W,this.page=new W,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 oi extends Oe{constructor(){super(...arguments),this.client=new W,this.movement=new W,this.offset=new W,this.global=new W,this.screen=new W}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,_){throw new Error("Method not implemented.")}}class Bt extends oi{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 ts extends oi{constructor(){super(...arguments),this.DOM_DELTA_LINE=0,this.DOM_DELTA_PAGE=1,this.DOM_DELTA_PIXEL=2}}const Qd=2048,Jd=new W,Gr=new W;class Go{constructor(t){this.dispatch=new Pe,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,Jd.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<Qd&&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,Gr),!t.hitArea.contains(Gr.x,Gr.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 Bt)){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 Bt)){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 Bt)){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 Bt)){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 Bt)){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 Bt)){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 ts)){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(Bt);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(ts);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(Bt);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 Bt&&e instanceof Bt&&(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 oi&&e instanceof oi&&(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 tf=1,ef={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class kr{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Go(null),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Bt(null),this.rootWheelEvent=new ts(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=tf),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=ef[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}}kr.extension={name:"events",type:[M.RendererSystem,M.CanvasRendererSystem]},U.add(kr);const ko={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 Oe))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}};it.mixin(ko),it.mixin(Uo);const sf=9,es=100,rf=0,nf=0,Ho=2,Xo=1,of=-1e3,af=-1e3,hf=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,(Ot.tablet||Ot.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${es}px`,e.style.height=`${es}px`,e.style.position="absolute",e.style.top=`${rf}px`,e.style.left=`${nf}px`,e.style.zIndex=Ho.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=`${Xo}px`,t.style.height=`${Xo}px`,t.style.position="absolute",t.style.top=`${of}px`,t.style.left=`${af}px`,t.style.zIndex=hf.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(Ot.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,xe(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 _=f.worldTransform;f.hitArea?(u.style.left=`${(_.tx+p.x*_.a)*l}px`,u.style.top=`${(_.ty+p.y*_.d)*c}px`,u.style.width=`${p.width*_.a*l}px`,u.style.height=`${p.height*_.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=`${es}px`,e.style.height=`${es}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Ho.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 Oe(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===sf&&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:[M.RendererPlugin,M.CanvasRendererPlugin]},U.add(Hr);const Xr=class{constructor(i){this.stage=new At,i=Object.assign({forceCanvas:!1},i),this.renderer=Do(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(M.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=M.Application,U.add(zr);class lf{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 $t=(i,t)=>(Array.isArray(i)||(i=[i]),t?i.map(e=>typeof e=="string"?t(e):e):i);function Vo(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?Vo(i.replace(s[e],a),t,e+1,s,r):r.push(i.replace(s[e],a))}}function zo(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)}),Vo(i,r,0,e,s)}else s.push(i);return s}const ai=i=>!Array.isArray(i);class cf{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=$t(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&&j.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 Ue=new cf;class uf{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=ai(t),o=$t(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=$t(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 df{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=$t(t);r.forEach(o=>{this._assetMap[o]}),Array.isArray(e)||(typeof e=="string"?e=zo(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=ai(t);t=$t(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=ai(t);t=$t(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 Wo{constructor(){this._detections=[],this._initialized=!1,this.resolver=new df,this.loader=new uf,this.cache=Ue,this._backgroundLoader=new lf(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=ai(t),r=$t(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 Ue.get(t);const e={};for(let s=0;s<t.length;s++)e[s]=Ue.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,Ue.set(c,l)}),o}async unload(t){this._initialized||await this.init();const e=$t(t).map(r=>typeof r!="string"?r.src:r),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=$t(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{Ue.remove(s.src)}),await this.loader.unload(e)}get detections(){return this._detections}}const hi=new Wo;U.handleByList(M.LoadParser,hi.loader.parsers).handleByList(M.ResolveParser,hi.resolver.parsers).handleByList(M.CacheParser,hi.cache.parsers).handleByList(M.DetectionParser,hi.detections);const jo={loader:M.LoadParser,resolver:M.ResolveParser,cache:M.CacheParser,detection:M.DetectionParser};U.handle(M.Asset,i=>{const t=i.ref;Object.entries(jo).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(jo).filter(e=>!!t[e]).forEach(e=>U.remove(t[e]))});const Yo={extension:M.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(Yo);var kt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(kt||{});const $o={extension:{type:M.LoadParser,priority:kt.Low},test(i){return ft.extname(i).includes(".json")},async load(i){return await(await R.ADAPTER.fetch(i)).json()}};U.add($o);const qo={extension:{type:M.LoadParser,priority:kt.Low},test(i){return ft.extname(i).includes(".txt")},async load(i){return await(await R.ADAPTER.fetch(i)).text()}};U.add(qo);const ff=["normal","bold","100","200","300","400","500","600","700","800","900"],pf=["woff","woff2","ttf","otf"];function Ko(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 Zo={extension:{type:M.LoadParser,priority:kt.Low},test(i){const e=i.split("?")[0].split(".").pop();return pf.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=R.ADAPTER.getFontFaceSet();if(e){const l=[],c=(r=(s=t.data)==null?void 0:s.family)!=null?r:Ko(i),u=(a=(o=(n=t.data)==null?void 0:n.weights)==null?void 0:o.filter(f=>ff.includes(f)))!=null?a:["normal"],d=(h=t.data)!=null?h:{};for(let f=0;f<u.length;f++){const p=u[f],_=new FontFace(c,`url(${i})`,mn(Zt({},d),{weight:p}));await _.load(),e.add(_),l.push(_)}return l.length===1?l[0]:l}return null},unload(i){(Array.isArray(i)?i:[i]).forEach(t=>R.ADAPTER.getFontFaceSet().delete(t))}};U.add(Zo);let Qo=0,Wr;const mf={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=$t
|
|
|
887
887
|
id: event.data.id,
|
|
888
888
|
});
|
|
889
889
|
}
|
|
890
|
-
};`};let jr;class gf{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([mf.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([_f.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[Qo]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Qo++,id:s})}}const Jo=new gf;function is(i,t){const e=i.split("?")[0],s=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s.toLowerCase()):s.toLowerCase()===t}function li(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 ta(i){const t=await R.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 ss={extension:{type:M.LoadParser,priority:kt.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||is(i,Yr)},async load(i,t,e){let s=null;globalThis.createImageBitmap?this.config.preferWorkers&&await Jo.isImageBitmapSupported()?s=await Jo.loadImageBitmap(i):s=await ta(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 j(s,Zt({resolution:te(i)},t.data));return r.resource.src=i,li(r,e,i)},unload(i){i.destroy(!0)}};U.add(ss);const yf={extension:{type:M.LoadParser,priority:kt.High},test(i){return ft.extname(i).includes(".svg")},async testParse(i){return Ne.test(i)},async parse(i,t,e){var o,a,h;const s=new Ne(i,(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions),r=new j(s,Zt({resolution:te(i)},t==null?void 0:t.data));r.resource.src=i;const n=li(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 R.ADAPTER.fetch(i)).text()},unload:ss.unload},ea={extension:M.ResolveParser,test:ss.test,parse:i=>{var t,e;return{resolution:parseFloat((e=(t=R.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:i.split(".").pop(),src:i}}};U.add(ea);const ia={extension:{type:M.DetectionParser,priority:1},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=",t=await R.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(ia);const sa={extension:{type:M.DetectionParser,priority:0},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=",t=await R.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(sa);const ra=["png","jpg","jpeg"],na={extension:{type:M.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...ra],remove:async i=>i.filter(t=>!ra.includes(t))};U.add(na);var Et=(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))(Et||{});const ci={[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 oa extends Fe{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 Ji(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 Ji(s),this.loaded=!0,this.onBlobLoaded(s),this.update(),this}}class ce extends oa{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=ce._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ce._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=ce._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*ci[e];for(let _=0;_<s;_++)h[_]={levelID:_,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*ci[e];return h}}let re,Ge;function aa(){Ge={s3tc:re.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:re.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:re.getExtension("WEBGL_compressed_texture_etc"),etc1:re.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:re.getExtension("WEBGL_compressed_texture_pvrtc")||re.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:re.getExtension("WEBGL_compressed_texture_atc"),astc:re.getExtension("WEBGL_compressed_texture_astc")}}const ha={extension:{type:M.DetectionParser,priority:2},test:async()=>{const t=R.ADAPTER.createCanvas().getContext("webgl");return t?(re=t,!0):!1},add:async i=>{Ge||aa();const t=[];for(const e in Ge)!Ge[e]||t.push(e);return[...t,...i]},remove:async i=>(Ge||aa(),i.filter(t=>!(t in Ge)))};U.add(ha);const $r=4,rs=124,vf=32,la=20,xf=542327876,ns={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},Tf={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},os={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var Ef=(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))(Ef||{}),bf=(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))(bf||{});const wf=1,Sf=2,Af=4,Rf=64,Cf=512,If=131072,Pf=827611204,Mf=861165636,Bf=894720068,Df=808540228,Ff=4,Nf={[Pf]:Et.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Mf]:Et.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Bf]:Et.COMPRESSED_RGBA_S3TC_DXT5_EXT},Lf={[70]:Et.COMPRESSED_RGBA_S3TC_DXT1_EXT,[71]:Et.COMPRESSED_RGBA_S3TC_DXT1_EXT,[73]:Et.COMPRESSED_RGBA_S3TC_DXT3_EXT,[74]:Et.COMPRESSED_RGBA_S3TC_DXT3_EXT,[76]:Et.COMPRESSED_RGBA_S3TC_DXT5_EXT,[77]:Et.COMPRESSED_RGBA_S3TC_DXT5_EXT,[72]:Et.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,[75]:Et.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,[78]:Et.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function ca(i){const t=new Uint32Array(i);if(t[0]!==xf)throw new Error("Invalid DDS file magic word");const s=new Uint32Array(i,0,rs/Uint32Array.BYTES_PER_ELEMENT),r=s[ns.HEIGHT],n=s[ns.WIDTH],o=s[ns.MIPMAP_COUNT],a=new Uint32Array(i,ns.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,vf/Uint32Array.BYTES_PER_ELEMENT),h=a[wf];if(h&Af){const l=a[Tf.FOURCC];if(l!==Df){const y=Nf[l],x=$r+rs,b=new Uint8Array(i,x);return[new ce(b,{format:y,width:n,height:r,levels:o})]}const c=$r+rs,u=new Uint32Array(t.buffer,c,la/Uint32Array.BYTES_PER_ELEMENT),d=u[os.DXGI_FORMAT],f=u[os.RESOURCE_DIMENSION],p=u[os.MISC_FLAG],_=u[os.ARRAY_SIZE],g=Lf[d];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${d}`);if(p===Ff)throw new Error("DDSParser does not support cubemap textures");if(f===6)throw new Error("DDSParser does not supported 3D texture data");const v=new Array,T=$r+rs+la;if(_===1)v.push(new Uint8Array(i,T));else{const y=ci[g];let x=0,b=n,D=r;for(let S=0;S<o;S++){const O=Math.max(1,b+3&-4),H=Math.max(1,D+3&-4);x+=O*H*y,b=b>>>1,D=D>>>1}let C=T;for(let S=0;S<_;S++)v.push(new Uint8Array(i,C,x)),C+=x}return v.map(y=>new ce(y,{format:g,width:n,height:r,levels:o}))}throw h&Rf?new Error("DDSParser does not support uncompressed texture data."):h&Cf?new Error("DDSParser does not supported YUV uncompressed texture data."):h&If?new Error("DDSParser does not support single-channel (lumninance) texture data!"):h&Sf?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 ua=[171,75,84,88,32,49,49,187,13,10,26,10],Of=67305985,Ht={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={[G.UNSIGNED_BYTE]:1,[G.UNSIGNED_SHORT]:2,[G.INT]:4,[G.UNSIGNED_INT]:4,[G.FLOAT]:4,[G.HALF_FLOAT]:8},da={[I.RGBA]:4,[I.RGB]:3,[I.RG]:2,[I.RED]:1,[I.LUMINANCE]:1,[I.LUMINANCE_ALPHA]:2,[I.ALPHA]:1},fa={[G.UNSIGNED_SHORT_4_4_4_4]:2,[G.UNSIGNED_SHORT_5_5_5_1]:2,[G.UNSIGNED_SHORT_5_6_5]:2};function pa(i,t,e=!1){const s=new DataView(t);if(!Uf(i,s))return null;const r=s.getUint32(Ht.ENDIANNESS,!0)===Of,n=s.getUint32(Ht.GL_TYPE,r),o=s.getUint32(Ht.GL_FORMAT,r),a=s.getUint32(Ht.GL_INTERNAL_FORMAT,r),h=s.getUint32(Ht.PIXEL_WIDTH,r),l=s.getUint32(Ht.PIXEL_HEIGHT,r)||1,c=s.getUint32(Ht.PIXEL_DEPTH,r)||1,u=s.getUint32(Ht.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=s.getUint32(Ht.NUMBER_OF_FACES,r),f=s.getUint32(Ht.NUMBER_OF_MIPMAP_LEVELS,r),p=s.getUint32(Ht.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 _=4,g=4,v=h+3&-4,T=l+3&-4,y=new Array(u);let x=h*l;n===0&&(x=v*T);let b;if(n!==0?Kr[n]?b=Kr[n]*da[o]:b=fa[n]:b=ci[a],b===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const D=e?kf(s,p,r):null;let S=x*b,O=h,H=l,P=v,N=T,w=qr+p;for(let E=0;E<f;E++){const V=s.getUint32(w,r);let Y=w+4;for(let F=0;F<u;F++){let q=y[F];q||(q=y[F]=new Array(f)),q[E]={levelID:E,levelWidth:f>1||n!==0?O:P,levelHeight:f>1||n!==0?H:N,levelBuffer:new Uint8Array(t,Y,S)},Y+=S}w+=V+4,w=w%4!==0?w+4-w%4:w,O=O>>1||1,H=H>>1||1,P=O+_-1&~(_-1),N=H+g-1&~(g-1),S=P*N*b}return n!==0?{uncompressed:y.map(E=>{let V=E[0].levelBuffer,Y=!1;return n===G.FLOAT?V=new Float32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4):n===G.UNSIGNED_INT?(Y=!0,V=new Uint32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)):n===G.INT&&(Y=!0,V=new Int32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)),{resource:new Fe(V,{width:E[0].levelWidth,height:E[0].levelHeight}),type:n,format:Y?Gf(o):o}}),kvData:D}:{compressed:y.map(E=>new ce(null,{format:a,width:h,height:l,levels:f,levelBuffers:E})),kvData:D}}function Uf(i,t){for(let e=0;e<ua.length;e++)if(t.getUint8(e)!==ua[e])return!1;return!0}function Gf(i){switch(i){case I.RGBA:return I.RGBA_INTEGER;case I.RGB:return I.RGB_INTEGER;case I.RG:return I.RG_INTEGER;case I.RED:return I.RED_INTEGER;default:return i}}function kf(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 ma={extension:{type:M.LoadParser,priority:kt.High},test(i){return is(i,".dds")},async load(i,t,e){const r=await(await R.ADAPTER.fetch(i)).arrayBuffer(),o=ca(r).map(a=>{const h=new j(a,Zt({mipmap:Ft.OFF,alphaMode:Rt.NO_PREMULTIPLIED_ALPHA,resolution:te(i)},t.data));return li(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(ma);const _a={extension:{type:M.LoadParser,priority:kt.High},test(i){return is(i,".ktx")},async load(i,t,e){const r=await(await R.ADAPTER.fetch(i)).arrayBuffer(),{compressed:n,uncompressed:o,kvData:a}=pa(i,r),h=n!=null?n:o,l=Zt({mipmap:Ft.OFF,alphaMode:Rt.NO_PREMULTIPLIED_ALPHA,resolution:te(i)},t.data),c=h.map(u=>{h===o&&Object.assign(l,{type:u.type,format:u.format});const d=new j(u,l);return d.ktxKeyValueData=a,li(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(_a);const ga={extension:M.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=R.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=R.RETINA_PREFIX.exec(i))==null?void 0:n[1])!=null?o:"1"),format:i.split(".").pop(),src:i}}};U.add(ga);const ya=new z,va=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 ie?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(va*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 ie?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(va*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:M.RendererSystem},U.add(Qr);var ne=(i=>(i.MITER="miter",i.BEVEL="bevel",i.ROUND="round",i))(ne||{}),ue=(i=>(i.BUTT="butt",i.ROUND="round",i.SQUARE="square",i))(ue||{});const ke={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 ui{constructor(){this.color=16777215,this.alpha=1,this.texture=B.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new ui;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 xa(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){xa(e,!1);const o=[];for(let l=0;l<s.length;l++){const c=s[l];xa(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])}}},di={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,_=p.width/2,g=p.height/2;e=p.x+_,s=p.y+g,o=a=Math.max(0,Math.min(p.radius,Math.min(_,g))),r=_-o,n=g-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,_=n,g=e+p,v=e-p,T=s+_;if(t[c++]=g,t[c++]=T,t[--u]=T,t[--u]=v,n){const y=s-_;t[d++]=v,t[d++]=y,t[--f]=y,t[--f]=g}}for(let p=1;p<h;p++){const _=Math.PI/2*(p/h),g=r+Math.cos(_)*o,v=n+Math.sin(_)*a,T=e+g,y=e-g,x=s+v,b=s-v;t[c++]=T,t[c++]=x,t[--u]=x,t[--u]=y,t[d++]=y,t[d++]=b,t[--f]=b,t[--f]=T}{const p=r,_=n+a,g=e+p,v=e-p,T=s+_,y=s-_;t[c++]=g,t[c++]=T,t[--f]=y,t[--f]=g,r&&(t[c++]=v,t[c++]=T,t[--f]=y,t[--f]=v)}},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)}},Ta={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)}},Ea={build(i){di.build(i)},triangulate(i,t){di.triangulate(i,t)}};function ba(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,_=l+f,g=c+d,v=u+f;return a.push(p,_),a.push(g,v),2}function Re(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),_=Math.sqrt(h*h+l*l),g=(15*p*Math.sqrt(_)/Math.PI>>0)+1,v=f/g;if(d+=v,a){o.push(i,t),o.push(e,s);for(let T=1,y=d;T<g;T++,y+=v)o.push(i,t),o.push(i+Math.sin(y)*_,t+Math.cos(y)*_);o.push(i,t),o.push(r,n)}else{o.push(e,s),o.push(i,t);for(let T=1,y=d;T<g;T++,y+=v)o.push(i+Math.sin(y)*_,t+Math.cos(y)*_),o.push(i,t);o.push(r,n),o.push(i,t)}return g*2}function Hf(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 W(s[0],s[1]),a=new W(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 F=(o.x+a.x)*.5,q=(a.y+o.y)*.5;s.unshift(F,q),s.push(F,q)}const c=t.points,u=s.length/2;let d=s.length;const f=c.length/2,p=n.width/2,_=p*p,g=n.miterLimit*n.miterLimit;let v=s[0],T=s[1],y=s[2],x=s[3],b=0,D=0,C=-(T-x),S=v-y,O=0,H=0,P=Math.sqrt(C*C+S*S);C/=P,S/=P,C*=p,S*=p;const N=n.alignment,w=(1-N)*2,E=N*2;h||(n.cap===ue.ROUND?d+=Re(v-C*(w-E)*.5,T-S*(w-E)*.5,v-C*w,T-S*w,v+C*E,T+S*E,c,!0)+2:n.cap===ue.SQUARE&&(d+=ba(v,T,C,S,w,E,!0,c))),c.push(v-C*w,T-S*w),c.push(v+C*E,T+S*E);for(let F=1;F<u-1;++F){v=s[(F-1)*2],T=s[(F-1)*2+1],y=s[F*2],x=s[F*2+1],b=s[(F+1)*2],D=s[(F+1)*2+1],C=-(T-x),S=v-y,P=Math.sqrt(C*C+S*S),C/=P,S/=P,C*=p,S*=p,O=-(x-D),H=y-b,P=Math.sqrt(O*O+H*H),O/=P,H/=P,O*=p,H*=p;const q=y-v,ot=T-x,A=y-b,X=D-x,$=q*A+ot*X,K=ot*A-X*q,Z=K<0;if(Math.abs(K)<.001*Math.abs($)){c.push(y-C*w,x-S*w),c.push(y+C*E,x+S*E),$>=0&&(n.join===ne.ROUND?d+=Re(y,x,y-C*w,x-S*w,y-O*w,x-H*w,c,!1)+4:d+=2,c.push(y-O*E,x-H*E),c.push(y+O*w,x+H*w));continue}const pt=(-C+v)*(-S+x)-(-C+y)*(-S+T),lt=(-O+b)*(-H+x)-(-O+y)*(-H+D),mt=(q*lt-A*pt)/K,yt=(X*pt-ot*lt)/K,bt=(mt-y)*(mt-y)+(yt-x)*(yt-x),gt=y+(mt-y)*w,st=x+(yt-x)*w,ct=y-(mt-y)*E,ut=x-(yt-x)*E,qt=Math.min(q*q+ot*ot,A*A+X*X),Kt=Z?w:E,Ti=qt+Kt*Kt*_;bt<=Ti?n.join===ne.BEVEL||bt/_>g?(Z?(c.push(gt,st),c.push(y+C*E,x+S*E),c.push(gt,st),c.push(y+O*E,x+H*E)):(c.push(y-C*w,x-S*w),c.push(ct,ut),c.push(y-O*w,x-H*w),c.push(ct,ut)),d+=2):n.join===ne.ROUND?Z?(c.push(gt,st),c.push(y+C*E,x+S*E),d+=Re(y,x,y+C*E,x+S*E,y+O*E,x+H*E,c,!0)+4,c.push(gt,st),c.push(y+O*E,x+H*E)):(c.push(y-C*w,x-S*w),c.push(ct,ut),d+=Re(y,x,y-C*w,x-S*w,y-O*w,x-H*w,c,!1)+4,c.push(y-O*w,x-H*w),c.push(ct,ut)):(c.push(gt,st),c.push(ct,ut)):(c.push(y-C*w,x-S*w),c.push(y+C*E,x+S*E),n.join===ne.ROUND?Z?d+=Re(y,x,y+C*E,x+S*E,y+O*E,x+H*E,c,!0)+2:d+=Re(y,x,y-C*w,x-S*w,y-O*w,x-H*w,c,!1)+2:n.join===ne.MITER&&bt/_<=g&&(Z?(c.push(ct,ut),c.push(ct,ut)):(c.push(gt,st),c.push(gt,st)),d+=2),c.push(y-O*w,x-H*w),c.push(y+O*E,x+H*E),d+=2)}v=s[(u-2)*2],T=s[(u-2)*2+1],y=s[(u-1)*2],x=s[(u-1)*2+1],C=-(T-x),S=v-y,P=Math.sqrt(C*C+S*S),C/=P,S/=P,C*=p,S*=p,c.push(y-C*w,x-S*w),c.push(y+C*E,x+S*E),h||(n.cap===ue.ROUND?d+=Re(y-C*(w-E)*.5,x-S*(w-E)*.5,y-C*w,x-S*w,y+C*E,x+S*E,c,!1)+2:n.cap===ue.SQUARE&&(d+=ba(y,x,C,S,w,E,!1,c)));const V=t.indices,Y=ke.epsilon*ke.epsilon;for(let F=f;F<d+f-2;++F)v=c[F*2],T=c[F*2+1],y=c[(F+1)*2],x=c[(F+1)*2+1],b=c[(F+2)*2],D=c[(F+2)*2+1],!(Math.abs(v*(x-D)+y*(D-T)+b*(T-x))<Y)&&V.push(F,F+1,F+2)}function Xf(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?Xf(i,t):Hf(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,_=u*u+d*d,g=l*u+c*d,v=n*Math.sqrt(p)/f,T=n*Math.sqrt(_)/f,y=v*g/p,x=T*g/_,b=v*d+T*c,D=v*u+T*l,C=c*(T+y),S=l*(T+y),O=d*(v+x),H=u*(v+x),P=Math.atan2(S-D,C-b),N=Math.atan2(H-D,O-b);return{cx:b+t,cy:D+e,radius:n,startAngle:P,endAngle:N,anticlockwise:c*u>d*l}}static arc(t,e,s,r,n,o,a,h,l){const c=a-o,u=ke._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/Ve)*40),d=c/(u*2),f=d*2,p=Math.cos(d),_=Math.sin(d),g=u-1,v=g%1/g;for(let T=0;T<=g;++T){const y=T+v*T,x=d+o+f*y,b=Math.cos(x),D=-Math.sin(x);l.push((p*b+_*D)*n+s,(p*-D+_*b)*n+r)}}}class as{static curveLength(t,e,s,r,n,o,a,h){let c=0,u=0,d=0,f=0,p=0,_=0,g=0,v=0,T=0,y=0,x=0,b=t,D=e;for(let C=1;C<=10;++C)u=C/10,d=u*u,f=d*u,p=1-u,_=p*p,g=_*p,v=g*t+3*_*u*s+3*p*d*n+f*a,T=g*e+3*_*u*r+3*p*d*o+f*h,y=b-v,x=D-T,b=v,D=T,c+=Math.sqrt(y*y+x*x);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=ke._segmentsCount(as.curveLength(h,l,t,e,s,r,n,o));let u=0,d=0,f=0,p=0,_=0;a.push(h,l);for(let g=1,v=0;g<=c;++g)v=g/c,u=1-v,d=u*u,f=d*u,p=v*v,_=p*v,a.push(f*h+3*d*v*t+3*u*p*s+_*n,f*l+3*d*v*e+3*u*p*r+_*o)}}class hs{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),_=Math.sqrt(u),g=2*u*_,v=2*Math.sqrt(f),T=d/_;return(g*p+_*d*(p-v)+(4*f*u-d*d)*Math.log((2*_+T+p)/(T+v)))/(4*g)}static curveTo(t,e,s,r,n){const o=n[n.length-2],a=n[n.length-1],h=ke._segmentsCount(hs.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 wa{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 ls={[dt.POLY]:Jr,[dt.CIRC]:di,[dt.ELIP]:di,[dt.RECT]:Ta,[dt.RREC]:Ea},sn=[],fi=[];class pi{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 pi(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 He=new W,Sa=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 ri,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(),fi.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 pi(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 pi(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,He):He.copyFrom(i),s.shape.contains(He.x,He.y))){let r=!1;if(s.holes){for(let n=0;n<s.holes.length;n++)if(s.holes[n].shape.contains(He.x,He.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;ls[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,_=this.indices.length,g=this.points.length/2;p.wrapMode=zt.REPEAT,d===0?this.processFill(h):this.processLine(h);const v=this.points.length/2-g;v!==0&&(e&&!this._compareStyles(s,f)&&(e.end(_,g),e=null),e||(e=sn.pop()||new wa,e.begin(f,_,g),this.batches.push(e),s=f),this.addUvs(this.points,i,f.texture,g,v,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<Sa.BATCHABLE_SIZE*2}buildDrawCalls(){let i=++j._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),fi.push(this.drawCalls[c]);this.drawCalls.length=0;const t=this.colors,e=this.textureIds;let s=fi.pop();s||(s=new Zi,s.texArray=new Qi),s.texArray.count=0,s.start=0,s.size=0,s.type=Dt.TRIANGLES;let r=0,n=null,o=0,a=!1,h=Dt.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?Dt.LINES:Dt.TRIANGLES,n=null,r=d,i++),n!==p&&(n=p,p._batchEnabled!==i&&(r===d&&(i++,r=0,s.size>0&&(s=fi.pop(),s||(s=new Zi,s.texArray=new Qi),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=zt.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)}j._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):ls[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];ls[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=Ni(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=Sa;rn.BATCHABLE_SIZE=100;class cs extends ui{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=ue.BUTT,this.join=ne.MITER,this.miterLimit=10}clone(){const t=new cs;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 Vf=new Float32Array(3),nn={},us=class extends At{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 ui,this._lineStyle=new cs,this._matrix=null,this._holeMode=!1,this.state=Yt.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 us(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:ue.BUTT,join:ne.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 fe,this.currentPath.closeStroke=!1,this.currentPath.points.push(i[t-2],i[t-1]))}else this.currentPath=new fe,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),hs.curveTo(i,t,e,s,r),this}bezierCurveTo(i,t,e,s,r,n){return this._initCurve(),as.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+=Ve:n&&s<=r&&(s+=Ve),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 z(i,t,e,s))}drawRoundedRect(i,t,e,s,r){return this.drawShape(new Ci(i,t,e,s,r))}drawCircle(i,t,e){return this.drawShape(new Ai(i,t,e))}drawEllipse(i,t,e,s){return this.drawShape(new Ri(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 fe(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:ve(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 tt,default:Pt.from({uSamplers:r},!0)},o=i.plugins[e]._shader.program;nn[e]=new Gt(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,us._TEMP_POINT),this._geometry.containsPoint(us._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this.tint;const i=ve(this.tint,Vf);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 ds=us;ds._TEMP_POINT=new W;const zf={buildPoly:Jr,buildCircle:di,buildRectangle:Ta,buildRoundedRectangle:Ea,buildLine:tn,ArcUtils:en,BezierUtils:as,QuadraticUtils:hs,BatchPart:wa,FILL_COMMANDS:ls,BATCH_POOL:sn,DRAW_CALL_POOL:fi};class Aa{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 W,Ra=new fe,Ca=class extends At{constructor(i,t,e,s=Dt.TRIANGLES){super(),this.geometry=i,this.shader=t,this.state=e||Yt.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=R.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===Dt.TRIANGLES&&t.length<Ca.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=R.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 Aa(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=Ra.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],Ra.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 Ce=Ca;Ce.BATCHABLE_SIZE=100;var Wf=`varying vec2 vTextureCoord;
|
|
890
|
+
};`};let jr;class gf{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([mf.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([_f.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[Qo]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Qo++,id:s})}}const Jo=new gf;function is(i,t){const e=i.split("?")[0],s=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s.toLowerCase()):s.toLowerCase()===t}function li(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 ta(i){const t=await R.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 ss={extension:{type:M.LoadParser,priority:kt.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||is(i,Yr)},async load(i,t,e){let s=null;globalThis.createImageBitmap?this.config.preferWorkers&&await Jo.isImageBitmapSupported()?s=await Jo.loadImageBitmap(i):s=await ta(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 j(s,Zt({resolution:te(i)},t.data));return r.resource.src=i,li(r,e,i)},unload(i){i.destroy(!0)}};U.add(ss);const yf={extension:{type:M.LoadParser,priority:kt.High},test(i){return ft.extname(i).includes(".svg")},async testParse(i){return Ne.test(i)},async parse(i,t,e){var o,a,h;const s=new Ne(i,(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions),r=new j(s,Zt({resolution:te(i)},t==null?void 0:t.data));r.resource.src=i;const n=li(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 R.ADAPTER.fetch(i)).text()},unload:ss.unload},ea={extension:M.ResolveParser,test:ss.test,parse:i=>{var t,e;return{resolution:parseFloat((e=(t=R.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:i.split(".").pop(),src:i}}};U.add(ea);const ia={extension:{type:M.DetectionParser,priority:1},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=",t=await R.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(ia);const sa={extension:{type:M.DetectionParser,priority:0},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=",t=await R.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(sa);const ra=["png","jpg","jpeg"],na={extension:{type:M.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...ra],remove:async i=>i.filter(t=>!ra.includes(t))};U.add(na);var Et=(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))(Et||{});const ci={[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 oa extends Fe{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 Ji(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 Ji(s),this.loaded=!0,this.onBlobLoaded(s),this.update(),this}}class ce extends oa{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=ce._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ce._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=ce._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*ci[e];for(let _=0;_<s;_++)h[_]={levelID:_,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*ci[e];return h}}let re,Ge;function aa(){Ge={s3tc:re.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:re.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:re.getExtension("WEBGL_compressed_texture_etc"),etc1:re.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:re.getExtension("WEBGL_compressed_texture_pvrtc")||re.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:re.getExtension("WEBGL_compressed_texture_atc"),astc:re.getExtension("WEBGL_compressed_texture_astc")}}const ha={extension:{type:M.DetectionParser,priority:2},test:async()=>{const t=R.ADAPTER.createCanvas().getContext("webgl");return t?(re=t,!0):!1},add:async i=>{Ge||aa();const t=[];for(const e in Ge)!Ge[e]||t.push(e);return[...t,...i]},remove:async i=>(Ge||aa(),i.filter(t=>!(t in Ge)))};U.add(ha);const $r=4,rs=124,vf=32,la=20,xf=542327876,ns={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},Tf={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},os={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var Ef=(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))(Ef||{}),bf=(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))(bf||{});const wf=1,Sf=2,Af=4,Rf=64,Cf=512,If=131072,Pf=827611204,Mf=861165636,Bf=894720068,Df=808540228,Ff=4,Nf={[Pf]:Et.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Mf]:Et.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Bf]:Et.COMPRESSED_RGBA_S3TC_DXT5_EXT},Lf={[70]:Et.COMPRESSED_RGBA_S3TC_DXT1_EXT,[71]:Et.COMPRESSED_RGBA_S3TC_DXT1_EXT,[73]:Et.COMPRESSED_RGBA_S3TC_DXT3_EXT,[74]:Et.COMPRESSED_RGBA_S3TC_DXT3_EXT,[76]:Et.COMPRESSED_RGBA_S3TC_DXT5_EXT,[77]:Et.COMPRESSED_RGBA_S3TC_DXT5_EXT,[72]:Et.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,[75]:Et.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,[78]:Et.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function ca(i){const t=new Uint32Array(i);if(t[0]!==xf)throw new Error("Invalid DDS file magic word");const s=new Uint32Array(i,0,rs/Uint32Array.BYTES_PER_ELEMENT),r=s[ns.HEIGHT],n=s[ns.WIDTH],o=s[ns.MIPMAP_COUNT],a=new Uint32Array(i,ns.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,vf/Uint32Array.BYTES_PER_ELEMENT),h=a[wf];if(h&Af){const l=a[Tf.FOURCC];if(l!==Df){const y=Nf[l],x=$r+rs,b=new Uint8Array(i,x);return[new ce(b,{format:y,width:n,height:r,levels:o})]}const c=$r+rs,u=new Uint32Array(t.buffer,c,la/Uint32Array.BYTES_PER_ELEMENT),d=u[os.DXGI_FORMAT],f=u[os.RESOURCE_DIMENSION],p=u[os.MISC_FLAG],_=u[os.ARRAY_SIZE],g=Lf[d];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${d}`);if(p===Ff)throw new Error("DDSParser does not support cubemap textures");if(f===6)throw new Error("DDSParser does not supported 3D texture data");const v=new Array,T=$r+rs+la;if(_===1)v.push(new Uint8Array(i,T));else{const y=ci[g];let x=0,b=n,D=r;for(let S=0;S<o;S++){const O=Math.max(1,b+3&-4),H=Math.max(1,D+3&-4);x+=O*H*y,b=b>>>1,D=D>>>1}let C=T;for(let S=0;S<_;S++)v.push(new Uint8Array(i,C,x)),C+=x}return v.map(y=>new ce(y,{format:g,width:n,height:r,levels:o}))}throw h&Rf?new Error("DDSParser does not support uncompressed texture data."):h&Cf?new Error("DDSParser does not supported YUV uncompressed texture data."):h&If?new Error("DDSParser does not support single-channel (lumninance) texture data!"):h&Sf?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 ua=[171,75,84,88,32,49,49,187,13,10,26,10],Of=67305985,Ht={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={[G.UNSIGNED_BYTE]:1,[G.UNSIGNED_SHORT]:2,[G.INT]:4,[G.UNSIGNED_INT]:4,[G.FLOAT]:4,[G.HALF_FLOAT]:8},da={[I.RGBA]:4,[I.RGB]:3,[I.RG]:2,[I.RED]:1,[I.LUMINANCE]:1,[I.LUMINANCE_ALPHA]:2,[I.ALPHA]:1},fa={[G.UNSIGNED_SHORT_4_4_4_4]:2,[G.UNSIGNED_SHORT_5_5_5_1]:2,[G.UNSIGNED_SHORT_5_6_5]:2};function pa(i,t,e=!1){const s=new DataView(t);if(!Uf(i,s))return null;const r=s.getUint32(Ht.ENDIANNESS,!0)===Of,n=s.getUint32(Ht.GL_TYPE,r),o=s.getUint32(Ht.GL_FORMAT,r),a=s.getUint32(Ht.GL_INTERNAL_FORMAT,r),h=s.getUint32(Ht.PIXEL_WIDTH,r),l=s.getUint32(Ht.PIXEL_HEIGHT,r)||1,c=s.getUint32(Ht.PIXEL_DEPTH,r)||1,u=s.getUint32(Ht.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=s.getUint32(Ht.NUMBER_OF_FACES,r),f=s.getUint32(Ht.NUMBER_OF_MIPMAP_LEVELS,r),p=s.getUint32(Ht.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 _=4,g=4,v=h+3&-4,T=l+3&-4,y=new Array(u);let x=h*l;n===0&&(x=v*T);let b;if(n!==0?Kr[n]?b=Kr[n]*da[o]:b=fa[n]:b=ci[a],b===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const D=e?kf(s,p,r):null;let S=x*b,O=h,H=l,P=v,N=T,w=qr+p;for(let E=0;E<f;E++){const V=s.getUint32(w,r);let Y=w+4;for(let F=0;F<u;F++){let q=y[F];q||(q=y[F]=new Array(f)),q[E]={levelID:E,levelWidth:f>1||n!==0?O:P,levelHeight:f>1||n!==0?H:N,levelBuffer:new Uint8Array(t,Y,S)},Y+=S}w+=V+4,w=w%4!==0?w+4-w%4:w,O=O>>1||1,H=H>>1||1,P=O+_-1&~(_-1),N=H+g-1&~(g-1),S=P*N*b}return n!==0?{uncompressed:y.map(E=>{let V=E[0].levelBuffer,Y=!1;return n===G.FLOAT?V=new Float32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4):n===G.UNSIGNED_INT?(Y=!0,V=new Uint32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)):n===G.INT&&(Y=!0,V=new Int32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)),{resource:new Fe(V,{width:E[0].levelWidth,height:E[0].levelHeight}),type:n,format:Y?Gf(o):o}}),kvData:D}:{compressed:y.map(E=>new ce(null,{format:a,width:h,height:l,levels:f,levelBuffers:E})),kvData:D}}function Uf(i,t){for(let e=0;e<ua.length;e++)if(t.getUint8(e)!==ua[e])return!1;return!0}function Gf(i){switch(i){case I.RGBA:return I.RGBA_INTEGER;case I.RGB:return I.RGB_INTEGER;case I.RG:return I.RG_INTEGER;case I.RED:return I.RED_INTEGER;default:return i}}function kf(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 ma={extension:{type:M.LoadParser,priority:kt.High},test(i){return is(i,".dds")},async load(i,t,e){const r=await(await R.ADAPTER.fetch(i)).arrayBuffer(),o=ca(r).map(a=>{const h=new j(a,Zt({mipmap:Ft.OFF,alphaMode:Rt.NO_PREMULTIPLIED_ALPHA,resolution:te(i)},t.data));return li(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(ma);const _a={extension:{type:M.LoadParser,priority:kt.High},test(i){return is(i,".ktx")},async load(i,t,e){const r=await(await R.ADAPTER.fetch(i)).arrayBuffer(),{compressed:n,uncompressed:o,kvData:a}=pa(i,r),h=n!=null?n:o,l=Zt({mipmap:Ft.OFF,alphaMode:Rt.NO_PREMULTIPLIED_ALPHA,resolution:te(i)},t.data),c=h.map(u=>{h===o&&Object.assign(l,{type:u.type,format:u.format});const d=new j(u,l);return d.ktxKeyValueData=a,li(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(_a);const ga={extension:M.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=R.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=R.RETINA_PREFIX.exec(i))==null?void 0:n[1])!=null?o:"1"),format:i.split(".").pop(),src:i}}};U.add(ga);const ya=new z,va=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 ie?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(va*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 ie?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(va*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:M.RendererSystem},U.add(Qr);var ne=(i=>(i.MITER="miter",i.BEVEL="bevel",i.ROUND="round",i))(ne||{}),ue=(i=>(i.BUTT="butt",i.ROUND="round",i.SQUARE="square",i))(ue||{});const ke={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 ui{constructor(){this.color=16777215,this.alpha=1,this.texture=B.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new ui;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 xa(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){xa(e,!1);const o=[];for(let l=0;l<s.length;l++){const c=s[l];xa(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])}}},di={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,_=p.width/2,g=p.height/2;e=p.x+_,s=p.y+g,o=a=Math.max(0,Math.min(p.radius,Math.min(_,g))),r=_-o,n=g-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,_=n,g=e+p,v=e-p,T=s+_;if(t[c++]=g,t[c++]=T,t[--u]=T,t[--u]=v,n){const y=s-_;t[d++]=v,t[d++]=y,t[--f]=y,t[--f]=g}}for(let p=1;p<h;p++){const _=Math.PI/2*(p/h),g=r+Math.cos(_)*o,v=n+Math.sin(_)*a,T=e+g,y=e-g,x=s+v,b=s-v;t[c++]=T,t[c++]=x,t[--u]=x,t[--u]=y,t[d++]=y,t[d++]=b,t[--f]=b,t[--f]=T}{const p=r,_=n+a,g=e+p,v=e-p,T=s+_,y=s-_;t[c++]=g,t[c++]=T,t[--f]=y,t[--f]=g,r&&(t[c++]=v,t[c++]=T,t[--f]=y,t[--f]=v)}},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)}},Ta={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)}},Ea={build(i){di.build(i)},triangulate(i,t){di.triangulate(i,t)}};function ba(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,_=l+f,g=c+d,v=u+f;return a.push(p,_),a.push(g,v),2}function Re(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),_=Math.sqrt(h*h+l*l),g=(15*p*Math.sqrt(_)/Math.PI>>0)+1,v=f/g;if(d+=v,a){o.push(i,t),o.push(e,s);for(let T=1,y=d;T<g;T++,y+=v)o.push(i,t),o.push(i+Math.sin(y)*_,t+Math.cos(y)*_);o.push(i,t),o.push(r,n)}else{o.push(e,s),o.push(i,t);for(let T=1,y=d;T<g;T++,y+=v)o.push(i+Math.sin(y)*_,t+Math.cos(y)*_),o.push(i,t);o.push(r,n),o.push(i,t)}return g*2}function Hf(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 W(s[0],s[1]),a=new W(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 F=(o.x+a.x)*.5,q=(a.y+o.y)*.5;s.unshift(F,q),s.push(F,q)}const c=t.points,u=s.length/2;let d=s.length;const f=c.length/2,p=n.width/2,_=p*p,g=n.miterLimit*n.miterLimit;let v=s[0],T=s[1],y=s[2],x=s[3],b=0,D=0,C=-(T-x),S=v-y,O=0,H=0,P=Math.sqrt(C*C+S*S);C/=P,S/=P,C*=p,S*=p;const N=n.alignment,w=(1-N)*2,E=N*2;h||(n.cap===ue.ROUND?d+=Re(v-C*(w-E)*.5,T-S*(w-E)*.5,v-C*w,T-S*w,v+C*E,T+S*E,c,!0)+2:n.cap===ue.SQUARE&&(d+=ba(v,T,C,S,w,E,!0,c))),c.push(v-C*w,T-S*w),c.push(v+C*E,T+S*E);for(let F=1;F<u-1;++F){v=s[(F-1)*2],T=s[(F-1)*2+1],y=s[F*2],x=s[F*2+1],b=s[(F+1)*2],D=s[(F+1)*2+1],C=-(T-x),S=v-y,P=Math.sqrt(C*C+S*S),C/=P,S/=P,C*=p,S*=p,O=-(x-D),H=y-b,P=Math.sqrt(O*O+H*H),O/=P,H/=P,O*=p,H*=p;const q=y-v,ot=T-x,A=y-b,X=D-x,$=q*A+ot*X,K=ot*A-X*q,Z=K<0;if(Math.abs(K)<.001*Math.abs($)){c.push(y-C*w,x-S*w),c.push(y+C*E,x+S*E),$>=0&&(n.join===ne.ROUND?d+=Re(y,x,y-C*w,x-S*w,y-O*w,x-H*w,c,!1)+4:d+=2,c.push(y-O*E,x-H*E),c.push(y+O*w,x+H*w));continue}const pt=(-C+v)*(-S+x)-(-C+y)*(-S+T),lt=(-O+b)*(-H+x)-(-O+y)*(-H+D),mt=(q*lt-A*pt)/K,yt=(X*pt-ot*lt)/K,bt=(mt-y)*(mt-y)+(yt-x)*(yt-x),gt=y+(mt-y)*w,st=x+(yt-x)*w,ct=y-(mt-y)*E,ut=x-(yt-x)*E,qt=Math.min(q*q+ot*ot,A*A+X*X),Kt=Z?w:E,Ti=qt+Kt*Kt*_;bt<=Ti?n.join===ne.BEVEL||bt/_>g?(Z?(c.push(gt,st),c.push(y+C*E,x+S*E),c.push(gt,st),c.push(y+O*E,x+H*E)):(c.push(y-C*w,x-S*w),c.push(ct,ut),c.push(y-O*w,x-H*w),c.push(ct,ut)),d+=2):n.join===ne.ROUND?Z?(c.push(gt,st),c.push(y+C*E,x+S*E),d+=Re(y,x,y+C*E,x+S*E,y+O*E,x+H*E,c,!0)+4,c.push(gt,st),c.push(y+O*E,x+H*E)):(c.push(y-C*w,x-S*w),c.push(ct,ut),d+=Re(y,x,y-C*w,x-S*w,y-O*w,x-H*w,c,!1)+4,c.push(y-O*w,x-H*w),c.push(ct,ut)):(c.push(gt,st),c.push(ct,ut)):(c.push(y-C*w,x-S*w),c.push(y+C*E,x+S*E),n.join===ne.ROUND?Z?d+=Re(y,x,y+C*E,x+S*E,y+O*E,x+H*E,c,!0)+2:d+=Re(y,x,y-C*w,x-S*w,y-O*w,x-H*w,c,!1)+2:n.join===ne.MITER&&bt/_<=g&&(Z?(c.push(ct,ut),c.push(ct,ut)):(c.push(gt,st),c.push(gt,st)),d+=2),c.push(y-O*w,x-H*w),c.push(y+O*E,x+H*E),d+=2)}v=s[(u-2)*2],T=s[(u-2)*2+1],y=s[(u-1)*2],x=s[(u-1)*2+1],C=-(T-x),S=v-y,P=Math.sqrt(C*C+S*S),C/=P,S/=P,C*=p,S*=p,c.push(y-C*w,x-S*w),c.push(y+C*E,x+S*E),h||(n.cap===ue.ROUND?d+=Re(y-C*(w-E)*.5,x-S*(w-E)*.5,y-C*w,x-S*w,y+C*E,x+S*E,c,!1)+2:n.cap===ue.SQUARE&&(d+=ba(y,x,C,S,w,E,!1,c)));const V=t.indices,Y=ke.epsilon*ke.epsilon;for(let F=f;F<d+f-2;++F)v=c[F*2],T=c[F*2+1],y=c[(F+1)*2],x=c[(F+1)*2+1],b=c[(F+2)*2],D=c[(F+2)*2+1],!(Math.abs(v*(x-D)+y*(D-T)+b*(T-x))<Y)&&V.push(F,F+1,F+2)}function Xf(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?Xf(i,t):Hf(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,_=u*u+d*d,g=l*u+c*d,v=n*Math.sqrt(p)/f,T=n*Math.sqrt(_)/f,y=v*g/p,x=T*g/_,b=v*d+T*c,D=v*u+T*l,C=c*(T+y),S=l*(T+y),O=d*(v+x),H=u*(v+x),P=Math.atan2(S-D,C-b),N=Math.atan2(H-D,O-b);return{cx:b+t,cy:D+e,radius:n,startAngle:P,endAngle:N,anticlockwise:c*u>d*l}}static arc(t,e,s,r,n,o,a,h,l){const c=a-o,u=ke._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/Ve)*40),d=c/(u*2),f=d*2,p=Math.cos(d),_=Math.sin(d),g=u-1,v=g%1/g;for(let T=0;T<=g;++T){const y=T+v*T,x=d+o+f*y,b=Math.cos(x),D=-Math.sin(x);l.push((p*b+_*D)*n+s,(p*-D+_*b)*n+r)}}}class as{static curveLength(t,e,s,r,n,o,a,h){let c=0,u=0,d=0,f=0,p=0,_=0,g=0,v=0,T=0,y=0,x=0,b=t,D=e;for(let C=1;C<=10;++C)u=C/10,d=u*u,f=d*u,p=1-u,_=p*p,g=_*p,v=g*t+3*_*u*s+3*p*d*n+f*a,T=g*e+3*_*u*r+3*p*d*o+f*h,y=b-v,x=D-T,b=v,D=T,c+=Math.sqrt(y*y+x*x);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=ke._segmentsCount(as.curveLength(h,l,t,e,s,r,n,o));let u=0,d=0,f=0,p=0,_=0;a.push(h,l);for(let g=1,v=0;g<=c;++g)v=g/c,u=1-v,d=u*u,f=d*u,p=v*v,_=p*v,a.push(f*h+3*d*v*t+3*u*p*s+_*n,f*l+3*d*v*e+3*u*p*r+_*o)}}class hs{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),_=Math.sqrt(u),g=2*u*_,v=2*Math.sqrt(f),T=d/_;return(g*p+_*d*(p-v)+(4*f*u-d*d)*Math.log((2*_+T+p)/(T+v)))/(4*g)}static curveTo(t,e,s,r,n){const o=n[n.length-2],a=n[n.length-1],h=ke._segmentsCount(hs.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 wa{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 ls={[dt.POLY]:Jr,[dt.CIRC]:di,[dt.ELIP]:di,[dt.RECT]:Ta,[dt.RREC]:Ea},sn=[],fi=[];class pi{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 pi(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 He=new W,Sa=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 ri,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(),fi.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 pi(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 pi(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,He):He.copyFrom(i),s.shape.contains(He.x,He.y))){let r=!1;if(s.holes){for(let n=0;n<s.holes.length;n++)if(s.holes[n].shape.contains(He.x,He.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;ls[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,_=this.indices.length,g=this.points.length/2;p.wrapMode=zt.REPEAT,d===0?this.processFill(h):this.processLine(h);const v=this.points.length/2-g;v!==0&&(e&&!this._compareStyles(s,f)&&(e.end(_,g),e=null),e||(e=sn.pop()||new wa,e.begin(f,_,g),this.batches.push(e),s=f),this.addUvs(this.points,i,f.texture,g,v,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<Sa.BATCHABLE_SIZE*2}buildDrawCalls(){let i=++j._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),fi.push(this.drawCalls[c]);this.drawCalls.length=0;const t=this.colors,e=this.textureIds;let s=fi.pop();s||(s=new Zi,s.texArray=new Qi),s.texArray.count=0,s.start=0,s.size=0,s.type=Dt.TRIANGLES;let r=0,n=null,o=0,a=!1,h=Dt.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?Dt.LINES:Dt.TRIANGLES,n=null,r=d,i++),n!==p&&(n=p,p._batchEnabled!==i&&(r===d&&(i++,r=0,s.size>0&&(s=fi.pop(),s||(s=new Zi,s.texArray=new Qi),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=zt.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)}j._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):ls[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];ls[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=Ni(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=Sa;rn.BATCHABLE_SIZE=100;class cs extends ui{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=ue.BUTT,this.join=ne.MITER,this.miterLimit=10}clone(){const t=new cs;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 Vf=new Float32Array(3),nn={},us=class extends At{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 ui,this._lineStyle=new cs,this._matrix=null,this._holeMode=!1,this.state=Yt.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 us(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:ue.BUTT,join:ne.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 fe,this.currentPath.closeStroke=!1,this.currentPath.points.push(i[t-2],i[t-1]))}else this.currentPath=new fe,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),hs.curveTo(i,t,e,s,r),this}bezierCurveTo(i,t,e,s,r,n){return this._initCurve(),as.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+=Ve:n&&s<=r&&(s+=Ve),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 z(i,t,e,s))}drawRoundedRect(i,t,e,s,r){return this.drawShape(new Ci(i,t,e,s,r))}drawCircle(i,t,e){return this.drawShape(new Ai(i,t,e))}drawEllipse(i,t,e,s){return this.drawShape(new Ri(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 fe(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:ve(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 tt,default:Pt.from({uSamplers:r},!0)},o=i.plugins[e]._shader.program;nn[e]=new Gt(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,us._TEMP_POINT),this._geometry.containsPoint(us._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this.tint;const i=ve(this.tint,Vf);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 ds=us;ds._TEMP_POINT=new W;const zf={buildPoly:Jr,buildCircle:di,buildRectangle:Ta,buildRoundedRectangle:Ea,buildLine:tn,ArcUtils:en,BezierUtils:as,QuadraticUtils:hs,BatchPart:wa,FILL_COMMANDS:ls,BATCH_POOL:sn,DRAW_CALL_POOL:fi};class Aa{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 W,Ra=new fe,Ca=class extends At{constructor(i,t,e,s=Dt.TRIANGLES){super(),this.geometry=i,this.shader=t,this.state=e||Yt.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=R.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===Dt.TRIANGLES&&t.length<Ca.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=R.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 Aa(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=Ra.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],Ra.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 Ce=Ca;Ce.BATCHABLE_SIZE=100;var Wf=`varying vec2 vTextureCoord;
|
|
891
891
|
uniform vec4 uColor;
|
|
892
892
|
|
|
893
893
|
uniform sampler2D uSampler;
|