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};/*! * pixi.js - v7.0.2 * Compiled Mon, 31 Oct 2022 15:20:53 UTC * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license */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.y&&et.right?t.right:this.right)<=S)return!1;const H=this.yt.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;re!=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;u0&&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._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);d80*e){a=l=i[0],h=c=i[1];for(var p=e;pl&&(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=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=rn?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=ah?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=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.x&&e.x>=l&&s!==e.x&&Me(ro.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;t0||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=(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;a0&&(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;$=55296&&Z<=56319&&$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=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,!(utb(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=X&&stb((a-$)/qt)&&S("overflow"),$+=(mt-X)*qt,X=mt,lt=0;lta&&S("overflow"),st==X){for(yt=$,bt=h;gt=bt<=pt?l:bt>=pt+c?c:bt-pt,!(yt0&&a>o&&(a=o);for(var h=0;h=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",` `," "],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&&s127?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;f0?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(a2){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;s0)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>>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=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;ts.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;h0)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{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*\]*(?:\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{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;sPromise.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;ethis.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;r0&&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;r1){for(let u=0;u1&&(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=0&&u=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>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;o1&&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;h1&&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=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;ss.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`${c}: ${l}`),s=i.getShaderInfoLog(t),r=s.split(` `),n={},o=r.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),a=[""];o.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(` `);a[0]=h,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function $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=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; ${i}`}else if(e!==wt.HIGH&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}const Ku={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function _o(i){return Ku[i]}let Wi=null;const go={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function yo(i,t){if(!Wi){const e=Object.keys(go);Wi={};for(let s=0;si.type==="float"&&i.size===1&&!i.isArray,code:i=>` if(uv["${i}"] !== ud["${i}"].value) { ud["${i}"].value = uv["${i}"] gl.uniform1f(ud["${i}"].location, uv["${i}"]) } `},{test:(i,t)=>(i.type==="sampler2D"||i.type==="samplerCube"||i.type==="sampler2DArray")&&i.size===1&&!i.isArray&&(t==null||t.castToBaseTexture!==void 0),code:i=>`t = syncData.textureCount++; renderer.texture.bind(uv["${i}"], t); if(ud["${i}"].value !== t) { ud["${i}"].value = t; gl.uniform1i(ud["${i}"].location, t); ; // eslint-disable-line max-len }`},{test:(i,t)=>i.type==="mat3"&&i.size===1&&!i.isArray&&t.a!==void 0,code:i=>` gl.uniformMatrix3fv(ud["${i}"].location, false, uv["${i}"].toArray(true)); `,codeUbo:i=>` var ${i}_matrix = uv.${i}.toArray(true); data[offset] = ${i}_matrix[0]; data[offset+1] = ${i}_matrix[1]; data[offset+2] = ${i}_matrix[2]; data[offset + 4] = ${i}_matrix[3]; data[offset + 5] = ${i}_matrix[4]; data[offset + 6] = ${i}_matrix[5]; data[offset + 8] = ${i}_matrix[6]; data[offset + 9] = ${i}_matrix[7]; data[offset + 10] = ${i}_matrix[8]; `},{test:(i,t)=>i.type==="vec2"&&i.size===1&&!i.isArray&&t.x!==void 0,code:i=>` cv = ud["${i}"].value; v = uv["${i}"]; if(cv[0] !== v.x || cv[1] !== v.y) { cv[0] = v.x; cv[1] = v.y; gl.uniform2f(ud["${i}"].location, v.x, v.y); }`,codeUbo:i=>` v = uv.${i}; data[offset] = v.x; data[offset+1] = v.y; `},{test:i=>i.type==="vec2"&&i.size===1&&!i.isArray,code:i=>` cv = ud["${i}"].value; v = uv["${i}"]; if(cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2f(ud["${i}"].location, v[0], v[1]); } `},{test:(i,t)=>i.type==="vec4"&&i.size===1&&!i.isArray&&t.width!==void 0,code:i=>` cv = ud["${i}"].value; v = uv["${i}"]; if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) { cv[0] = v.x; cv[1] = v.y; cv[2] = v.width; cv[3] = v.height; gl.uniform4f(ud["${i}"].location, v.x, v.y, v.width, v.height) }`,codeUbo:i=>` v = uv.${i}; data[offset] = v.x; data[offset+1] = v.y; data[offset+2] = v.width; data[offset+3] = v.height; `},{test:i=>i.type==="vec4"&&i.size===1&&!i.isArray,code:i=>` cv = ud["${i}"].value; v = uv["${i}"]; if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4f(ud["${i}"].location, v[0], v[1], v[2], v[3]) }`}],Zu={float:` if (cv !== v) { cu.value = v; gl.uniform1f(location, v); }`,vec2:` if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2f(location, v[0], v[1]) }`,vec3:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3f(location, v[0], v[1], v[2]) }`,vec4:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4f(location, v[0], v[1], v[2], v[3]); }`,int:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,ivec2:` if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2i(location, v[0], v[1]); }`,ivec3:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3i(location, v[0], v[1], v[2]); }`,ivec4:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); }`,uint:` if (cv !== v) { cu.value = v; gl.uniform1ui(location, v); }`,uvec2:` if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2ui(location, v[0], v[1]); }`,uvec3:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3ui(location, v[0], v[1], v[2]); }`,uvec4:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4ui(location, v[0], v[1], v[2], v[3]); }`,bool:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,bvec2:` if (cv[0] != v[0] || cv[1] != v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2i(location, v[0], v[1]); }`,bvec3:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3i(location, v[0], v[1], v[2]); }`,bvec4:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); }`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,samplerCube:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,sampler2DArray:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`},Qu={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function Ju(i,t){var s;const e=[` var v = null; var cv = null; var cu = null; var t = 0; var gl = renderer.gl; `];for(const r in i.uniforms){const n=t[r];if(!n){(s=i.uniforms[r])!=null&&s.group&&(i.uniforms[r].ubo?e.push(` renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}'); `):e.push(` renderer.shader.syncUniformGroup(uv.${r}, syncData); `));continue}const o=i.uniforms[r];let a=!1;for(let h=0;h0&&(t+=` else `),e0?this.maskStack[this.maskStack.length-1]._colorMask:15;s!==e&&this.renderer.gl.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)}destroy(){this.renderer=null}}mr.extension={type:M.RendererSystem,name:"mask"},U.add(mr);class Eo{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,s=this.getStackLength();this.maskStack=t;const r=this.getStackLength();r!==s&&(r===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const bo=new tt,wo=[],$i=class extends Eo{constructor(i){super(i),this.glConst=R.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const i=this.maskStack[this.maskStack.length-1];return i?i._scissorCounter:0}calcScissorRect(i){var o;if(i._scissorRectLocal)return;const t=i._scissorRect,{maskObject:e}=i,{renderer:s}=this,r=s.renderTexture,n=e.getBounds(!0,(o=wo.pop())!=null?o:new z);this.roundFrameToPixels(n,r.current?r.current.resolution:s.resolution,r.sourceFrame,r.destinationFrame,s.projection.transform),t&&n.fit(t),i._scissorRectLocal=n}static isMatrixRotated(i){if(!i)return!1;const{a:t,b:e,c:s,d:r}=i;return(Math.abs(e)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(r)>1e-4)}testScissor(i){const{maskObject:t}=i;if(!t.isFastRect||!t.isFastRect()||$i.isMatrixRotated(t.worldTransform)||$i.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(i);const e=i._scissorRectLocal;return e.width>0&&e.height>0}roundFrameToPixels(i,t,e,s,r){$i.isMatrixRotated(r)||(r=r?bo.copyFrom(r):bo.identity(),r.translate(-e.x,-e.y).scale(s.width/e.width,s.height/e.height).translate(s.x,s.y),this.renderer.filter.transformAABB(r,i),i.fit(s),i.x=Math.round(i.x*t),i.y=Math.round(i.y*t),i.width=Math.round(i.width*t),i.height=Math.round(i.height*t))}push(i){i._scissorRectLocal||this.calcScissorRect(i);const{gl:t}=this.renderer;i._scissorRect||t.enable(t.SCISSOR_TEST),i._scissorCounter++,i._scissorRect=i._scissorRectLocal,this._useCurrent()}pop(i){const{gl:t}=this.renderer;i&&wo.push(i._scissorRectLocal),this.getStackLength()>0?this._useCurrent():t.disable(t.SCISSOR_TEST)}_useCurrent(){const i=this.maskStack[this.maskStack.length-1]._scissorRect;let t;this.renderer.renderTexture.current?t=i.y:t=this.renderer.height-i.height-i.y,this.renderer.gl.scissor(i.x,t,i.width,i.height)}};let _r=$i;_r.extension={type:M.RendererSystem,name:"scissor"},U.add(_r);class gr extends Eo{constructor(t){super(t),this.glConst=R.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:s}=this.renderer,r=t._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),s.clearStencil(0),s.clear(s.STENCIL_BUFFER_BIT),s.enable(s.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,s.colorMask(!1,!1,!1,!1)),s.stencilFunc(s.EQUAL,r,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,s.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,r=s?s._colorMask:15;r!==0&&(s._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,r!==0&&(s._colorMask=r,e.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}gr.extension={type:M.RendererSystem,name:"stencil"},U.add(gr);class yr{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new tt,this.transform=null}update(t,e,s,r){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,s,r),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,s,r){const n=this.projectionMatrix,o=r?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}yr.extension={type:M.RendererSystem,name:"projection"},U.add(yr);const we=new z,ii=new z;class vr{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new z,this.destinationFrame=new z,this.viewportFrame=new z}bind(t=null,e,s){const r=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(we.width=t.frame.width,we.height=t.frame.height,e=we),s||(ii.x=t.frame.x,ii.y=t.frame.y,ii.width=e.width,ii.height=e.height,s=ii),o=n.framebuffer):(a=r.resolution,e||(we.width=r._view.screen.width,we.height=r._view.screen.height,e=we),s||(s=we,s.width=e.width,s.height=e.height));const h=this.viewportFrame;h.x=s.x*a,h.y=s.y*a,h.width=s.width*a,h.height=s.height*a,t||(h.y=r.view.height-(h.y+h.height)),h.ceil(),this.renderer.framebuffer.bind(o,h),this.renderer.projection.update(s,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(s)}clear(t,e){this.current?t=t||this.current.baseTexture.clearColor:t=t||this.renderer.background.colorRgba;const s=this.destinationFrame,r=this.current?this.current.baseTexture:this.renderer._view.screen,n=s.width!==r.width||s.height!==r.height;if(n){let{x:o,y:a,width:h,height:l}=this.viewportFrame;o=Math.round(o),a=Math.round(a),h=Math.round(h),l=Math.round(l),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(o,a,h,l)}this.renderer.framebuffer.clear(t[0],t[1],t[2],t[3],e),n&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}vr.extension={type:M.RendererSystem,name:"renderTexture"},U.add(vr);function cd(i,t,e,s,r){e.buffer.update(r)}const ud={float:` data[offset] = v; `,vec2:` data[offset] = v[0]; data[offset+1] = v[1]; `,vec3:` data[offset] = v[0]; data[offset+1] = v[1]; data[offset+2] = v[2]; `,vec4:` data[offset] = v[0]; data[offset+1] = v[1]; data[offset+2] = v[2]; data[offset+3] = v[3]; `,mat2:` data[offset] = v[0]; data[offset+1] = v[1]; data[offset+4] = v[2]; data[offset+5] = v[3]; `,mat3:` data[offset] = v[0]; data[offset+1] = v[1]; data[offset+2] = v[2]; data[offset + 4] = v[3]; data[offset + 5] = v[4]; data[offset + 6] = v[5]; data[offset + 8] = v[6]; data[offset + 9] = v[7]; data[offset + 10] = v[8]; `,mat4:` for(var i = 0; i < 16; i++) { data[offset + i] = v[i]; } `},So={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function Ao(i){const t=i.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,s=0,r=0;for(let n=0;n1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,s%e!==0&&s<16){const a=s%e%16;s+=a,r+=a}s+e>16?(r=Math.ceil(r/16)*16,o.offset=r,r+=e,s=e):(o.offset=r,s+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}function Ro(i,t){const e=[];for(const s in i)t[s]&&e.push(t[s]);return e.sort((s,r)=>s.index-r.index),e}function Co(i,t){if(!i.autoManage)return{size:0,syncFunc:cd};const e=Ro(i.uniforms,t),{uboElements:s,size:r}=Ao(e),n=[` var v = null; var v2 = null; var cv = null; var t = 0; var gl = renderer.gl var index = 0; var data = buffer.data; `];for(let o=0;o1){const u=_o(a.data.type),d=Math.max(So[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(` cv = ud.${l}.value; v = uv.${l}; offset = ${a.offset/4}; t = 0; for(var i=0; i < ${a.data.size*d}; i++) { for(var j = 0; j < ${f}; j++) { data[offset++] = v[t++]; } offset += ${p}; } `)}else{const u=ud[a.data.type];n.push(` cv = ud.${l}.value; v = uv.${l}; offset = ${a.offset/4}; ${u}; `)}}return n.push(` renderer.buffer.update(buffer); `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(` `))}}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;rc>u?1:-1);for(let c=0;c>1,e++;this.stateId=i.data}for(let t=0;tthis.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let s=!1;for(let r=0;rthis.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,s=!0)}if(s){let r=0;for(let n=0;n=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=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;o0&&(e+=` else `),sthis.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=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=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=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.2";var Bd=`varying vec2 vTextureCoord; uniform sampler2D uSampler; uniform float uAlpha; void main(void) { gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; } `;class Dd extends Mt{constructor(t=1){super(Fo,Bd,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const Fd=` attribute vec2 aVertexPosition; uniform mat3 projectionMatrix; uniform float strength; varying vec2 vBlurTexCoords[%size%]; uniform vec4 inputSize; uniform vec4 outputFrame; vec4 filterVertexPosition( void ) { vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aVertexPosition * (outputFrame.zw * inputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vec2 textureCoord = filterTextureCoord(); %blur% }`;function Nd(i,t){const e=Math.ceil(i/2);let s=Fd,r="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o=e&&(o=i-a-1),h=h.replace("%value%",t[o].toString()),r+=h,r+=` `}return s=s.replace("%blur%",r),s=s.replace("%size%",i.toString()),s}class Or extends Mt{constructor(t,e=8,s=4,r=R.FILTER_RESOLUTION,n=5){const o=Nd(n,t),a=Ud(n);super(o,a),this.horizontal=t,this.resolution=r,this._quality=0,this.quality=s,this.blur=e}apply(t,e,s,r){if(s?this.horizontal?this.uniforms.strength=1/s.width*(s.width/e.width):this.uniforms.strength=1/s.height*(s.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,s,r);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,h=n;this.state.blend=!1,t.applyFilter(this,a,h,Nt.CLEAR);for(let l=1;l 0.0) { c.rgb /= c.a; } vec4 result; result.r = (m[0] * c.r); result.r += (m[1] * c.g); result.r += (m[2] * c.b); result.r += (m[3] * c.a); result.r += m[4]; result.g = (m[5] * c.r); result.g += (m[6] * c.g); result.g += (m[7] * c.b); result.g += (m[8] * c.a); result.g += m[9]; result.b = (m[10] * c.r); result.b += (m[11] * c.g); result.b += (m[12] * c.b); result.b += (m[13] * c.a); result.b += m[14]; result.a = (m[15] * c.r); result.a += (m[16] * c.g); result.a += (m[17] * c.b); result.a += (m[18] * c.a); result.a += m[19]; vec3 rgb = mix(c.rgb, result.rgb, uAlpha); // Premultiply alpha again. rgb *= result.a; gl_FragColor = vec4(rgb, result.a); } `;class Ur extends Mt{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(Mr,kd,t),this.alpha=1}_loadMatrix(t,e=!1){let s=t;e&&(this._multiply(s,this.uniforms.m,t),s=this._colorMatrix(s)),this.uniforms.m=s}_multiply(t,e,s){return t[0]=e[0]*s[0]+e[1]*s[5]+e[2]*s[10]+e[3]*s[15],t[1]=e[0]*s[1]+e[1]*s[6]+e[2]*s[11]+e[3]*s[16],t[2]=e[0]*s[2]+e[1]*s[7]+e[2]*s[12]+e[3]*s[17],t[3]=e[0]*s[3]+e[1]*s[8]+e[2]*s[13]+e[3]*s[18],t[4]=e[0]*s[4]+e[1]*s[9]+e[2]*s[14]+e[3]*s[19]+e[4],t[5]=e[5]*s[0]+e[6]*s[5]+e[7]*s[10]+e[8]*s[15],t[6]=e[5]*s[1]+e[6]*s[6]+e[7]*s[11]+e[8]*s[16],t[7]=e[5]*s[2]+e[6]*s[7]+e[7]*s[12]+e[8]*s[17],t[8]=e[5]*s[3]+e[6]*s[8]+e[7]*s[13]+e[8]*s[18],t[9]=e[5]*s[4]+e[6]*s[9]+e[7]*s[14]+e[8]*s[19]+e[9],t[10]=e[10]*s[0]+e[11]*s[5]+e[12]*s[10]+e[13]*s[15],t[11]=e[10]*s[1]+e[11]*s[6]+e[12]*s[11]+e[13]*s[16],t[12]=e[10]*s[2]+e[11]*s[7]+e[12]*s[12]+e[13]*s[17],t[13]=e[10]*s[3]+e[11]*s[8]+e[12]*s[13]+e[13]*s[18],t[14]=e[10]*s[4]+e[11]*s[9]+e[12]*s[14]+e[13]*s[19]+e[14],t[15]=e[15]*s[0]+e[16]*s[5]+e[17]*s[10]+e[18]*s[15],t[16]=e[15]*s[1]+e[16]*s[6]+e[17]*s[11]+e[18]*s[16],t[17]=e[15]*s[2]+e[16]*s[7]+e[17]*s[12]+e[18]*s[17],t[18]=e[15]*s[3]+e[16]*s[8]+e[17]*s[13]+e[18]*s[18],t[19]=e[15]*s[4]+e[16]*s[9]+e[17]*s[14]+e[18]*s[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const s=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}tint(t,e){const s=t>>16&255,r=t>>8&255,n=t&255,o=[s/255,0,0,0,0,0,r/255,0,0,0,0,0,n/255,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const s=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const s=Math.cos(t),r=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),h=s+(1-s)*o,l=o*(1-s)-a*r,c=o*(1-s)+a*r,u=o*(1-s)+a*r,d=s+o*(1-s),f=o*(1-s)-a*r,p=o*(1-s)-a*r,_=o*(1-s)+a*r,g=s+o*(1-s),v=[h,l,c,0,0,u,d,f,0,0,p,_,g,0,0,0,0,0,1,0];this._loadMatrix(v,e)}contrast(t,e){const s=(t||0)+1,r=-.5*(s-1),n=[s,0,0,0,r,0,s,0,0,r,0,0,s,0,r,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const s=t*2/3+1,r=(s-1)*-.5,n=[s,r,r,0,0,r,s,r,0,0,r,r,s,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,s,r,n){t=t||.2,e=e||.15,s=s||16770432,r=r||3375104;const o=(s>>16&255)/255,a=(s>>8&255)/255,h=(s&255)/255,l=(r>>16&255)/255,c=(r>>8&255)/255,u=(r&255)/255,d=[.3,.59,.11,0,0,o,a,h,t,0,l,c,u,e,0,o-l,a-c,h-u,0,0];this._loadMatrix(d,n)}night(t,e){t=t||.1;const s=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(s,e)}predator(t,e){const s=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(s,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}Ur.prototype.grayscale=Ur.prototype.greyscale;var Hd=`varying vec2 vFilterCoord; varying vec2 vTextureCoord; uniform vec2 scale; uniform mat2 rotation; uniform sampler2D uSampler; uniform sampler2D mapSampler; uniform highp vec4 inputSize; uniform vec4 inputClamp; void main(void) { vec4 map = texture2D(mapSampler, vFilterCoord); map -= 0.5; map.xy = scale * inputSize.zw * (rotation * map.xy); gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw)); } `,Xd=`attribute vec2 aVertexPosition; uniform mat3 projectionMatrix; uniform mat3 filterMatrix; varying vec2 vTextureCoord; varying vec2 vFilterCoord; uniform vec4 inputSize; uniform vec4 outputFrame; vec4 filterVertexPosition( void ) { vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aVertexPosition * (outputFrame.zw * inputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy; } `;class Vd extends Mt{constructor(t,e){const s=new tt;t.renderable=!1,super(Xd,Hd,{mapSampler:t._texture,filterMatrix:s,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=s,e==null&&(e=20),this.scale=new W(e,e)}apply(t,e,s,r){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,s,r)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var zd=` attribute vec2 aVertexPosition; uniform mat3 projectionMatrix; varying vec2 v_rgbNW; varying vec2 v_rgbNE; varying vec2 v_rgbSW; varying vec2 v_rgbSE; varying vec2 v_rgbM; varying vec2 vFragCoord; uniform vec4 inputSize; uniform vec4 outputFrame; vec4 filterVertexPosition( void ) { vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); } void texcoords(vec2 fragCoord, vec2 inverseVP, out vec2 v_rgbNW, out vec2 v_rgbNE, out vec2 v_rgbSW, out vec2 v_rgbSE, out vec2 v_rgbM) { v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP; v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP; v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP; v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP; v_rgbM = vec2(fragCoord * inverseVP); } void main(void) { gl_Position = filterVertexPosition(); vFragCoord = aVertexPosition * outputFrame.zw; texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); } `,Wd=`varying vec2 v_rgbNW; varying vec2 v_rgbNE; varying vec2 v_rgbSW; varying vec2 v_rgbSE; varying vec2 v_rgbM; varying vec2 vFragCoord; uniform sampler2D uSampler; uniform highp vec4 inputSize; /** Basic FXAA implementation based on the code on geeks3d.com with the modification that the texture2DLod stuff was removed since it's unsupported by WebGL. -- From: https://github.com/mitsuhiko/webgl-meincraft Copyright (c) 2011 by Armin Ronacher. Some rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FXAA_REDUCE_MIN #define FXAA_REDUCE_MIN (1.0/ 128.0) #endif #ifndef FXAA_REDUCE_MUL #define FXAA_REDUCE_MUL (1.0 / 8.0) #endif #ifndef FXAA_SPAN_MAX #define FXAA_SPAN_MAX 8.0 #endif //optimized version for mobile, where dependent //texture reads can be a bottleneck vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP, vec2 v_rgbNW, vec2 v_rgbNE, vec2 v_rgbSW, vec2 v_rgbSE, vec2 v_rgbM) { vec4 color; vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; vec4 texColor = texture2D(tex, v_rgbM); vec3 rgbM = texColor.xyz; vec3 luma = vec3(0.299, 0.587, 0.114); float lumaNW = dot(rgbNW, luma); float lumaNE = dot(rgbNE, luma); float lumaSW = dot(rgbSW, luma); float lumaSE = dot(rgbSE, luma); float lumaM = dot(rgbM, luma); float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); mediump vec2 dir; dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * inverseVP; vec3 rgbA = 0.5 * ( texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz); vec3 rgbB = rgbA * 0.5 + 0.25 * ( texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz); float lumaB = dot(rgbB, luma); if ((lumaB < lumaMin) || (lumaB > lumaMax)) color = vec4(rgbA, texColor.a); else color = vec4(rgbB, texColor.a); return color; } void main() { vec4 color; color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); gl_FragColor = color; } `;class jd extends Mt{constructor(){super(zd,Wd)}}var Yd=`precision highp float; varying vec2 vTextureCoord; varying vec4 vColor; uniform float uNoise; uniform float uSeed; uniform sampler2D uSampler; float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } void main() { vec4 color = texture2D(uSampler, vTextureCoord); float randomValue = rand(gl_FragCoord.xy * uSeed); float diff = (randomValue - 0.5) * uNoise; // Un-premultiply alpha before applying the color matrix. See issue #3539. if (color.a > 0.0) { color.rgb /= color.a; } color.r += diff; color.g += diff; color.b += diff; // Premultiply alpha again. color.rgb *= color.a; gl_FragColor = color; } `;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=or?o:r,n=a>n?a:n,o=t[2],a=t[3],e=or?o:r,n=a>n?a:n,o=t[4],a=t[5],e=or?o:r,n=a>n?a:n,o=t[6],a=t[7],e=or?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=gp?g:p,_=v>_?v:_,g=o*r+h*s+c,v=a*r+l*s+u,d=gp?g:p,_=v>_?v:_,g=o*e+h*n+c,v=a*e+l*n+u,d=gp?g:p,_=v>_?v:_,g=o*r+h*n+c,v=a*r+l*n+u,d=gp?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;ho?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;vr?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.maxXl?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.maxXl?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.minXs?this.maxX:s,this.minY=this.minYr?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;s1)for(let e=0;ethis.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=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;e0&&n<=r){o=this.children.splice(s,n);for(let a=0;a1&&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;t0&&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=r&&ni.x=n&&ni.y>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;ss.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=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=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;s0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",r=this.normalizeToPointerData(t);for(let n=0,o=r.length;n{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 title : ${t.title}
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(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{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{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({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}. ${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._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;en.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{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;fR.ADAPTER.getFontFaceSet().delete(t))}};U.add(Zo);let Qo=0,Wr;const mf={id:"checkImageBitmap",code:` async function checkImageBitmap() { try { if (typeof createImageBitmap !== 'function') return false; const response = await fetch('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII='); const imageBlob = await response.blob(); const imageBitmap = await createImageBitmap(imageBlob); return imageBitmap.width === 1 && imageBitmap.height === 1; } catch (e) { return false; } } checkImageBitmap().then((result) => { self.postMessage(result); }); `},_f={id:"loadImageBitmap",code:` async function loadImageBitmap(url) { const response = await fetch(url); if (!response.ok) { throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \` + \`\${response.status} \${response.statusText}\`); } const imageBlob = await response.blob(); const imageBitmap = await createImageBitmap(imageBlob); return imageBitmap; } self.onmessage = async (event) => { try { const imageBitmap = await loadImageBitmap(event.data.data[0]); self.postMessage({ data: imageBitmap, uuid: event.data.uuid, id: event.data.id, }, [imageBitmap]); } catch(e) { self.postMessage({ error: e, uuid: event.data.uuid, id: event.data.id, }); } };`};let 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{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{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=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;_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>>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;E1||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;et-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h{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.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 ethis.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];r0||t&&s<=0){const r=e/2;for(let n=r+r%2;n=6){xa(e,!1);const o=[];for(let l=0;l=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=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&&cu&&(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=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;Fd*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;i0&&(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;i0&&(e=this.batches[this.batches.length-1],s=e.style);for(let a=this.shapeIndex;a65535;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;i65535*2)return!1;const i=this.batches;for(let t=0;t0&&(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>16)+(t&65280)+((t&255)<<16),o=Ni(n,e);i.length=Math.max(i.length,r+s);for(let a=0;a0&&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);u0;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>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>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>16)+(t&65280)+((t&255)<<16),this._colorDirty=!0)}get tint(){return this._tint}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture;Hs(this._tint,this._alpha,this.uniforms.uColor,t.alphaMode)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class mi extends se{constructor(t,e,s){super();const r=new nt(t),n=new nt(e,!0),o=new nt(s,!0,!0);this.addAttribute("aVertexPosition",r,2,!1,G.FLOAT).addAttribute("aTextureCoord",n,2,!1,G.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}class Ia extends mi{constructor(t=100,e=100,s=10,r=10){super(),this.segWidth=s,this.segHeight=r,this.width=t,this.height=e,this.build()}build(){const t=this.segWidth*this.segHeight,e=[],s=[],r=[],n=this.segWidth-1,o=this.segHeight-1,a=this.width/n,h=this.height/o;for(let c=0;c0){const p=h.x-t[d].x,_=h.y-t[d].y,g=Math.sqrt(p*p+_*_);h=t[d],a+=g/l}else a=d/(c-1);n[f]=a,n[f+1]=0,n[f+2]=a,n[f+3]=1}let u=0;for(let d=0;d1&&(u=1);const d=Math.sqrt(r*r+n*n),f=this.textureScale>0?this.textureScale*this._width/2:this._width/2;r/=d,n/=d,r*=f,n*=f,o[c]=l.x+r,o[c+1]=l.y+n,o[c+2]=l.x-r,o[c+3]=l.y-n,e=l}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class Yf extends Ce{constructor(t,e,s=0){const r=new Pa(t.height,e,s),n=new Xe(t);s>0&&(t.baseTexture.wrapMode=zt.REPEAT),super(r,n),this.autoUpdate=!0}_render(t){const e=this.geometry;(this.autoUpdate||e._width!==this.shader.texture.height)&&(e._width=this.shader.texture.height,e.update()),super._render(t)}}class Ma extends Ce{constructor(t,e,s){const r=new Ia(t.width,t.height,e,s),n=new Xe(B.WHITE);super(r,n),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:e,height:s}=this.shader.texture;this.autoResize&&(t.width!==e||t.height!==s)&&(t.width=this.shader.texture.width,t.height=this.shader.texture.height,t.build())}set texture(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))}get texture(){return this.shader.texture}_render(t){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),super._render(t)}destroy(t){this.shader.texture.off("update",this.textureUpdated,this),super.destroy(t)}}class $f extends Ce{constructor(t=B.EMPTY,e,s,r,n){const o=new mi(e,s,r);o.getBuffer("aVertexPosition").static=!1;const a=new Xe(t);super(o,a,null,n),this.autoUpdate=!0}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}_render(t){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),super._render(t)}}const fs=10;class qf extends Ma{constructor(t,e=fs,s=fs,r=fs,n=fs){super(B.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=e,this._rightWidth=r,this._topHeight=s,this._bottomHeight=n,this.texture=t}textureUpdated(){this._textureID=this.shader.texture._updateID,this._refresh()}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}updateHorizontalVertices(){const t=this.vertices,e=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*e,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*e,t[25]=t[27]=t[29]=t[31]=this._height}updateVerticalVertices(){const t=this.vertices,e=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*e,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*e,t[6]=t[14]=t[22]=t[30]=this._width}_getMinScale(){const t=this._leftWidth+this._rightWidth,e=this._width>t?1:this._width/t,s=this._topHeight+this._bottomHeight,r=this._height>s?1:this._height/s;return Math.min(e,r)}get width(){return this._width}set width(t){this._width=t,this._refresh()}get height(){return this._height}set height(t){this._height=t,this._refresh()}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this._refresh()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this._refresh()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this._refresh()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this._refresh()}_refresh(){const t=this.texture,e=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;const s=1/this._origWidth,r=1/this._origHeight;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1,e[2]=e[10]=e[18]=e[26]=s*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-s*this._rightWidth,e[9]=e[11]=e[13]=e[15]=r*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-r*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}}class Kf extends At{constructor(t=1500,e,s=16384,r=!1){super();const n=16384;s>n&&(s=n),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=s,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=k.NORMAL,this.autoResize=r,this.roundPixels=!0,this.baseTexture=null,this.setProperties(e),this._tint=0,this.tintRgb=new Float32Array(4),this.tint=16777215}setProperties(t){t&&(this._properties[0]="vertices"in t||"scale"in t?!!t.vertices||!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="tint"in t||"alpha"in t?!!t.tint||!!t.alpha:this._properties[4])}updateTransform(){this.displayObjectUpdateTransform()}get tint(){return this._tint}set tint(t){this._tint=t,ve(t,this.tintRgb)}render(t){!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",()=>this.onChildrenChange(0))),t.batch.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))}onChildrenChange(t){const e=Math.floor(t/this._batchSize);for(;this._bufferUpdateIDs.lengths&&!t.autoResize&&(o=s);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const h=e[0]._texture.baseTexture,l=h.alphaMode>0;this.state.blendMode=ks(t.blendMode,l),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=$n(t.tintRgb,t.worldAlpha,this.shader.uniforms.uColor,l),this.shader.uniforms.uSampler=h,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;fr&&(_=r),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const g=a[p];g.uploadDynamic(e,f,_);const v=t._bufferUpdateIDs[p]||0;d=d||g._updateID0,c=h.alpha,u=c<1&&l?Ni(h._tintRGB,c):h._tintRGB+(c*255<<24);r[o]=u,r[o+n]=u,r[o+n*2]=u,r[o+n*3]=u,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}an.extension={name:"particle",type:M.RendererPlugin},U.add(an),R.UPLOADS_PER_FRAME=4;var _i=(i=>(i[i.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",i[i.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",i))(_i||{});const hn={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:_i.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},Jf=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];class oe{constructor(t){this.styleID=0,this.reset(),cn(this,t,t)}clone(){const t={};return cn(t,this,hn),new oe(t)}reset(){cn(this,hn,hn)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=ln(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=ln(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){tp(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=ln(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let r=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Jf.includes(r)&&(r=`"${r}"`),e[s]=r}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}}function Da(i){return typeof i=="number"?Us(i):(typeof i=="string"&&i.startsWith("0x")&&(i=i.replace("0x","#")),i)}function ln(i){if(Array.isArray(i)){for(let t=0;tp)if(o!==""&&(a+=L.addLine(o),o="",n=0),L.canBreakWords(v,e.breakWords)){const y=L.wordWrapSplit(v);for(let x=0;xp&&(a+=L.addLine(o),f=!1,o="",n=0),o+=b,n+=C}}else{o.length>0&&(a+=L.addLine(o),o="",n=0);const y=g===_.length-1;a+=L.addLine(v,!y),f=!1,o="",n=0}else T+n>p&&(f=!1,a+=L.addLine(o),o="",n=0),(o.length>0||!L.isBreakingSpace(v)||f)&&(o+=v,n+=T)}return a+=L.addLine(o,!1),a}static addLine(t,e=!0){return t=L.trimRight(t),t=e?`${t} `:t,t}static getFromCache(t,e,s,r){let n=s[t];if(typeof n!="number"){const o=t.length*e;n=r.measureText(t).width+o,s[t]=n}return n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!L.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:L._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:L._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let r=0;ra;--d){for(let _=0;_0&&f>p&&(_=(p+f)/2);const g=p+u,v=e.lineHeight*(d+1);let T=g;d+10}}function ip(i,t){var s;let e=!1;if((s=i==null?void 0:i._textures)!=null&&s.length){for(let r=0;r{!this.queue||this.prepareItems()},this.registerFindHook(ap),this.registerFindHook(hp),this.registerFindHook(ip),this.registerFindHook(sp),this.registerFindHook(rp),this.registerUploadHook(np),this.registerUploadHook(op)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Q.system.addOnce(this.tick,this,ae.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let s=0,r=this.uploadHooks.length;s=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Q.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}}function Oa(i,t){return t instanceof j?(t._glTextures[i.CONTEXT_UID]||i.texture.bind(t),!0):!1}function lp(i,t){if(!(t instanceof ds))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:s}=e;for(let r=0;r{this._callback=i,this._batchIndex=0,this._frameKeys.length<=gi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(i){let t=i;const e=gi.BATCH_SIZE;for(;t-i{this._batchIndex*gi.BATCH_SIZE{s[r]=t}),Object.keys(t.textures).forEach(r=>{s[r]=t.textures[r]}),!e){const r=ft.dirname(i[0]);t.linkedSheets.forEach((n,o)=>{const a=Ua([`${r}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const Ga={extension:M.Asset,cache:{test:i=>i instanceof _s,getCacheableAssets:(i,t)=>Ua(i,t,!1)},resolver:{test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),r=e.pop();return s==="json"&&dp.includes(r)},parse:i=>{var e,s;const t=i.split(".");return{resolution:parseFloat((s=(e=R.RETINA_PREFIX.exec(i))==null?void 0:e[1])!=null?s:"1"),format:t[t.length-2],src:i}}},loader:{extension:{type:M.LoadParser,priority:kt.Normal},async testParse(i,t){return ft.extname(t.src).includes(".json")&&!!i.frames},async parse(i,t,e){var l,c;let s=ft.dirname(t.src);s&&s.lastIndexOf("/")!==s.length-1&&(s+="/");const r=s+i.meta.image,o=(await e.load([r]))[r],a=new _s(o.baseTexture,i,t.src);await a.parse();const h=(l=i==null?void 0:i.meta)==null?void 0:l.related_multi_packs;if(Array.isArray(h)){const u=[];for(const f of h){if(typeof f!="string")continue;const p=s+f;(c=t.data)!=null&&c.ignoreMultiPack||u.push(e.load({src:p,data:{ignoreMultiPack:!0}}))}const d=await Promise.all(u);a.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[a].concat(a.linkedSheets.filter(p=>p!==f))})}return a},unload(i){i.destroy(!0)}}};U.add(Ga);class gs extends le{constructor(t,e=!0){super(t[0]instanceof B?t[0]:t[0].texture),this._textures=null,this._durations=null,this._autoUpdate=e,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=t}stop(){!this._playing||(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Q.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Q.shared.add(this.update,this,ae.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=this.animationSpeed*t,s=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=e/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const n=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=e;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrames&&this.onLoop()),this.updateTexture())}updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this._texture=this._textures[t],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t){this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;sthis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this.updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Q.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Q.shared.add(this.update,this),this._isConnectedToTicker=!0))}}const yi=new W;class dn extends le{constructor(t,e=100,s=100){super(t),this.tileTransform=new ze,this._width=e,this._height=s,this.uvMatrix=this.texture.uvMatrix||new Yi(t),this.pluginName="tilingSprite",this.uvRespectAnchor=!1}get clampMargin(){return this.uvMatrix.clampMargin}set clampMargin(t){this.uvMatrix.clampMargin=t,this.uvMatrix.update(!0)}get tileScale(){return this.tileTransform.scale}set tileScale(t){this.tileTransform.scale.copyFrom(t)}get tilePosition(){return this.tileTransform.position}set tilePosition(t){this.tileTransform.position.copyFrom(t)}_onTextureUpdate(){this.uvMatrix&&(this.uvMatrix.texture=this._texture),this._cachedTint=16777215}_render(t){const e=this._texture;!e||!e.valid||(this.tileTransform.updateLocalTransform(),this.uvMatrix.update(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this))}_calculateBounds(){const t=this._width*-this._anchor._x,e=this._height*-this._anchor._y,s=this._width*(1-this._anchor._x),r=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,e,s,r)}getLocalBounds(t){return this.children.length===0?(this._bounds.minX=this._width*-this._anchor._x,this._bounds.minY=this._height*-this._anchor._y,this._bounds.maxX=this._width*(1-this._anchor._x),this._bounds.maxY=this._height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new z),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,yi);const e=this._width,s=this._height,r=-e*this.anchor._x;if(yi.x>=r&&yi.x=n&&yi.y1?Gt.from(mp,_p,e):Gt.from(ka,pp,e)}render(t){const e=this.renderer,s=this.quad;let r=s.vertices;r[0]=r[6]=t._width*-t.anchor.x,r[1]=r[3]=t._height*-t.anchor.y,r[2]=r[4]=t._width*(1-t.anchor.x),r[5]=r[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;r=s.uvs,r[0]=r[6]=-n,r[1]=r[3]=-o,r[2]=r[4]=1-n,r[5]=r[7]=1-o,s.invalidate();const a=t._texture,h=a.baseTexture,l=h.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=h.isPowerOfTwo&&a.frame.width===h.width&&a.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==zt.CLAMP:h.wrapMode===zt.CLAMP&&(h.wrapMode=zt.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,_=a.height,g=t._width,v=t._height;ys.set(c.a*p/g,c.b*p/v,c.c*_/g,c.d*_/v,c.tx/g,c.ty/v),ys.invert(),d?ys.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=ys.toArray(!0),f.uniforms.uColor=Hs(t.tint,t.worldAlpha,f.uniforms.uColor,l),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(s),this.state.blendMode=ks(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}fn.extension={name:"tilingSprite",type:M.RendererPlugin},U.add(fn);class vi{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class xi{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),h={};for(const l in a){const c=a[l].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;h[u]=p}s[o].push(h)}const r=new vi;return s.info.forEach(n=>r.info.push({face:n.face,size:parseInt(n.size,10)})),s.common.forEach(n=>r.common.push({lineHeight:parseInt(n.lineHeight,10)})),s.page.forEach(n=>r.page.push({id:parseInt(n.id,10),file:n.file})),s.char.forEach(n=>r.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),s.kerning.forEach(n=>r.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),s.distanceField.forEach(n=>r.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),r}}class vs{static test(t){return t instanceof XMLDocument&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new vi,s=t.getElementsByTagName("info"),r=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l")){const e=new globalThis.DOMParser().parseFromString(t,"text/xml");return vs.test(e)}return!1}static parse(t){const e=new globalThis.DOMParser().parseFromString(t,"text/xml");return vs.parse(e)}}const pn=[xi,vs,xs];function Ha(i){for(let t=0;t=a-P*n){if(p===0)throw new Error(`[BitmapFont] textureHeight ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--C,_=null,g=null,v=null,p=0,f=0,T=0;continue}if(T=Math.max(P+O.fontProperties.descent,T),N*n+f>=u){if(f===0)throw new Error(`[BitmapFont] textureWidth ${o}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--C,p+=T*n,p=Math.ceil(p),f=0,T=0;continue}yp(_,g,O,f,p,n,c);const w=Ts(O.text);d.char.push({id:w,page:x.length-1,x:f/n,y:p/n,width:N,height:P,xoffset:0,yoffset:0,xadvance:Math.ceil(H-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0))}),f+=(N+2*r)*n,f=Math.ceil(f)}for(let C=0,S=l.length;C 0.99) {\r alpha = 1.0;\r }\r \r // NPM Textures, NPM outputs\r gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\r \r }\r `,Tp=`// Mesh material default fragment\r attribute vec2 aVertexPosition;\r attribute vec2 aTextureCoord;\r \r uniform mat3 projectionMatrix;\r uniform mat3 translationMatrix;\r uniform mat3 uTextureMatrix;\r \r varying vec2 vTextureCoord;\r \r void main(void)\r {\r gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r \r vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r }\r `;const Va=[],za=[],Wa=[],ja=class extends At{constructor(i,t={}){super(),this._tint=16777215;const{align:e,tint:s,maxWidth:r,letterSpacing:n,fontName:o,fontSize:a}=Object.assign({},ja.styleDefaults,t);if(!vt.available[o])throw new Error(`Missing BitmapFont "${o}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=e,this._tint=s,this._font=void 0,this._fontName=o,this._fontSize=a,this.text=i,this._maxWidth=r,this._maxLineHeight=0,this._letterSpacing=n,this._anchor=new Jt(()=>{this.dirty=!0},this,0,0),this._roundPixels=R.ROUND_PIXELS,this.dirty=!0,this._resolution=R.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var H;const i=vt.available[this._fontName],t=this.fontSize,e=t/i.size,s=new W,r=[],n=[],o=[],a=this._text.replace(/(?:\r\n|\r)/g,` `)||" ",h=Xa(a),l=this._maxWidth*i.size/t,c=i.distanceFieldType==="none"?Va:za;let u=null,d=0,f=0,p=0,_=-1,g=0,v=0,T=0,y=0;for(let P=0;P0&&s.x>l&&(++v,xe(r,1+_-v,1+P-_),P=_,_=-1,n.push(g),o.push(r.length>0?r[r.length-1].prevSpaces:0),f=Math.max(f,g),p++,s.x=0,s.y+=i.lineHeight,u=null,y=0)}const x=h[h.length-1];x!=="\r"&&x!==` `&&(/(?:\s)/.test(x)&&(d=g),n.push(d),f=Math.max(f,d),o.push(-1));const b=[];for(let P=0;P<=p;P++){let N=0;this._align==="right"?N=f-n[P]:this._align==="center"?N=(f-n[P])/2:this._align==="justify"&&(N=o[P]<0?0:(f-n[P])/o[P]),b.push(N)}const D=r.length,C={},S=[],O=this._activePagesMeshData;c.push(...O);for(let P=0;P6*w)||N.vertices.lengtht[r.mesh.texture.baseTexture.uid]).forEach(r=>{r.mesh.texture=B.EMPTY});for(const r in t)t[r].destroy(),delete t[r];this._font=null,this._textureCache=null,super.destroy(i)}};let Ya=ja;Ya.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const Ep=[".xml",".fnt"],$a={extension:{type:M.LoadParser,priority:kt.Normal},test(i){return Ep.includes(ft.extname(i))},async testParse(i){return xi.test(i)||xs.test(i)},async parse(i,t,e){const s=xi.test(i)?xi.parse(i):xs.parse(i),{src:r}=t,{page:n}=s,o=[];for(let l=0;la[l]);return vt.install(s,h,!0)},async load(i,t){return(await R.ADAPTER.fetch(i)).text()},unload(i){i.destroy()}};U.add($a);const bp={AlphaFilter:Dd,BlurFilter:Gd,BlurFilterPass:Or,ColorMatrixFilter:Ur,DisplacementFilter:Vd,FXAAFilter:jd,NoiseFilter:$d};return m.ALPHA_MODES=Rt,m.AbstractMultiResource=Ys,m.AccessibilityManager=Hr,m.AnimatedSprite=gs,m.Application=Vr,m.ArrayResource=to,m.Assets=hi,m.AssetsClass=Wo,m.Attribute=Je,m.BLEND_MODES=k,m.BUFFER_BITS=xt,m.BUFFER_TYPE=Lt,m.BackgroundSystem=Ar,m.BaseImageResource=ee,m.BasePrepare=La,m.BaseRenderTexture=Zs,m.BaseTexture=j,m.BatchDrawCall=Zi,m.BatchGeometry=Dr,m.BatchRenderer=si,m.BatchShaderGenerator=No,m.BatchSystem=sr,m.BatchTextureArray=Qi,m.BitmapFont=vt,m.BitmapFontData=vi,m.BitmapText=Ya,m.BlobResource=oa,m.Bounds=ri,m.BrowserAdapter=yn,m.Buffer=nt,m.BufferResource=Fe,m.BufferSystem=Fr,m.CLEAR_MODES=Nt,m.COLOR_MASK_BITS=gn,m.Cache=Ue,m.CanvasResource=eo,m.Circle=Ai,m.CompressedTextureResource=ce,m.Container=At,m.ContextSystem=rr,m.CountLimiter=Na,m.CubeResource=$s,m.DEG_TO_RAD=Bn,m.DRAW_MODES=Dt,m.DisplayObject=it,m.ENV=J,m.Ellipse=Ri,m.EventBoundary=Go,m.EventSystem=kr,m.ExtensionType=M,m.Extract=Qr,m.FORMATS=I,m.FORMATS_TO_COMPONENTS=da,m.FederatedDisplayObject=ko,m.FederatedEvent=Oe,m.FederatedMouseEvent=oi,m.FederatedPointerEvent=Bt,m.FederatedWheelEvent=ts,m.FillStyle=ui,m.Filter=Mt,m.FilterState=no,m.FilterSystem=ir,m.Framebuffer=Hi,m.FramebufferSystem=nr,m.GC_MODES=bi,m.GLFramebuffer=ao,m.GLProgram=Io,m.GLTexture=Ki,m.GRAPHICS_CURVES=ke,m.GenerateTextureSystem=Sr,m.Geometry=se,m.GeometrySystem=ar,m.Graphics=ds,m.GraphicsData=pi,m.GraphicsGeometry=rn,m.IGLUniformData=dd,m.INSTALLED=Ui,m.INTERNAL_FORMATS=Et,m.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL=ci,m.ImageBitmapResource=Ee,m.ImageResource=qs,m.LINE_CAP=ue,m.LINE_JOIN=ne,m.LineStyle=cs,m.LoaderParserPriority=kt,m.MASK_TYPES=ht,m.MIPMAP_MODES=Ft,m.MSAA_QUALITY=at,m.MaskData=ho,m.MaskSystem=mr,m.Matrix=tt,m.Mesh=Ce,m.MeshBatchUvs=Aa,m.MeshGeometry=mi,m.MeshMaterial=Xe,m.MultisampleSystem=Nr,m.NineSlicePlane=qf,m.ObjectRenderer=ti,m.ObjectRendererSystem=Lr,m.ObservablePoint=Jt,m.PI_2=Ve,m.PRECISION=wt,m.ParticleContainer=Kf,m.ParticleRenderer=an,m.PlaneGeometry=Ia,m.PluginSystem=Cr,m.Point=W,m.Polygon=fe,m.Prepare=un,m.Program=jt,m.ProjectionSystem=yr,m.Quad=ro,m.QuadUv=tr,m.RAD_TO_DEG=Mn,m.RENDERER_TYPE=_t,m.Rectangle=z,m.RenderTexture=ie,m.RenderTexturePool=Js,m.RenderTextureSystem=vr,m.Renderer=Se,m.ResizePlugin=zr,m.Resource=De,m.RopeGeometry=Pa,m.RoundedRectangle=Ci,m.Runner=St,m.SAMPLER_TYPES=Ei,m.SCALE_MODES=Vt,m.SHAPES=dt,m.SVGResource=Ne,m.ScissorSystem=_r,m.Shader=Gt,m.ShaderSystem=xr,m.SimpleMesh=$f,m.SimplePlane=Ma,m.SimpleRope=Yf,m.Sprite=le,m.SpriteMaskFilter=To,m.Spritesheet=_s,m.StartupSystem=Ir,m.State=Yt,m.StateSystem=Er,m.StencilSystem=gr,m.SystemManager=Mo,m.TARGETS=de,m.TEXT_GRADIENT=_i,m.TYPES=G,m.TYPES_TO_BYTES_PER_COMPONENT=Kr,m.TYPES_TO_BYTES_PER_PIXEL=fa,m.TemporaryDisplayObject=Lo,m.Text=ms,m.TextFormat=xi,m.TextMetrics=L,m.TextStyle=oe,m.Texture=B,m.TextureGCSystem=br,m.TextureMatrix=Yi,m.TextureSystem=wr,m.TextureUvs=Qs,m.Ticker=Q,m.TickerPlugin=Rs,m.TilingSprite=dn,m.TilingSpriteRenderer=fn,m.TimeLimiter=up,m.Transform=ze,m.TransformFeedback=Id,m.TransformFeedbackSystem=Pr,m.UPDATE_PRIORITY=ae,m.UniformGroup=Pt,m.VERSION=Md,m.VideoResource=ki,m.ViewSystem=Rr,m.ViewableBuffer=Ji,m.WRAP_MODES=zt,m.XMLFormat=vs,m.XMLStringFormat=xs,m.accessibleTarget=Uo,m.autoDetectFormat=Ha,m.autoDetectRenderer=Do,m.autoDetectResource=js,m.cacheTextureArray=Yo,m.checkExtension=is,m.checkMaxIfStatementsInShader=vo,m.convertToList=$t,m.createStringVariations=zo,m.createTexture=li,m.createUBOElements=Ao,m.defaultFilterVertex=Mr,m.defaultVertex=Fo,m.detectAvif=ia,m.detectCompressedTextures=ha,m.detectDefaults=na,m.detectWebp=sa,m.extensions=U,m.filters=bp,m.generateProgram=Po,m.generateUniformBufferSync=Co,m.getFontFamilyName=Ko,m.getTestContext=po,m.getUBOData=Ro,m.graphicsUtils=zf,m.groupD8=et,m.isMobile=Ot,m.isSingleItem=ai,m.loadBitmapFont=$a,m.loadDDS=ma,m.loadImageBitmap=ta,m.loadJson=$o,m.loadKTX=_a,m.loadSVG=yf,m.loadTextures=ss,m.loadTxt=qo,m.loadWebFont=Zo,m.parseDDS=ca,m.parseKTX=pa,m.resolveCompressedTextureUrl=ga,m.resolveTextureUrl=ea,m.settings=R,m.spritesheetAsset=Ga,m.uniformParsers=be,m.utils=Uu,Object.defineProperty(m,"__esModule",{value:!0}),m}({}); //# sourceMappingURL=pixi.min.js.map