"use strict";(self.webpackChunkcoinflip=self.webpackChunkcoinflip||[]).push([[306],{4306:(t,e,i)=>{i.r(e),i.d(e,{ALPHA_MODES:()=>n.iw,AbstractMultiResource:()=>n.M4,AccessibilityManager:()=>I,AlphaFilter:()=>l,AnimatedSprite:()=>Wt.K,Application:()=>B.M,ArrayResource:()=>n.$N,Assets:()=>O.de,AssetsClass:()=>O.d7,Attribute:()=>n.ah,BLEND_MODES:()=>n.T$,BUFFER_BITS:()=>n.V0,BUFFER_TYPE:()=>n.mr,BackgroundSystem:()=>n.YP,BaseImageResource:()=>n.bg,BasePrepare:()=>Nt,BaseRenderTexture:()=>n.jd,BaseTexture:()=>n.VL,BatchDrawCall:()=>n.a$,BatchGeometry:()=>n.JZ,BatchRenderer:()=>n.Bv,BatchShaderGenerator:()=>n.Zk,BatchSystem:()=>n.Sj,BatchTextureArray:()=>n.Ie,BitmapFont:()=>qt.UP,BitmapFontData:()=>qt.d0,BitmapText:()=>qt.Xz,BlobResource:()=>X,BlurFilter:()=>d,BlurFilterPass:()=>c,Bounds:()=>r.YZ,BrowserAdapter:()=>n.ZQ,Buffer:()=>n.lW,BufferResource:()=>n.qm,BufferSystem:()=>n.P,CLEAR_MODES:()=>n.yl,COLOR_MASK_BITS:()=>n.V3,Cache:()=>O.Ct,CanvasResource:()=>n.Y8,Circle:()=>n.Cd,Color:()=>n.Il,ColorMatrixFilter:()=>p,CompressedTextureResource:()=>H,Container:()=>r.W2,ContextSystem:()=>n.lH,CountLimiter:()=>Mt,CubeResource:()=>n.TA,DEG_TO_RAD:()=>n.ZX,DRAW_MODES:()=>n.lg,DisplacementFilter:()=>m,DisplayObject:()=>r.s$,ENV:()=>n.Vi,Ellipse:()=>n.Pj,EventBoundary:()=>P,EventSystem:()=>M,ExtensionType:()=>n.nw,Extract:()=>bt,FORMATS:()=>n.I2,FORMATS_TO_COMPONENTS:()=>pt,FXAAFilter:()=>v,FederatedDisplayObject:()=>D,FederatedEvent:()=>E,FederatedMouseEvent:()=>y,FederatedPointerEvent:()=>T,FederatedWheelEvent:()=>b,FillStyle:()=>St.ft,Filter:()=>n.wn,FilterState:()=>n.jV,FilterSystem:()=>n.kV,Framebuffer:()=>n.AI,FramebufferSystem:()=>n.WB,GC_MODES:()=>n.UN,GLFramebuffer:()=>n.tT,GLProgram:()=>n.Ei,GLTexture:()=>n.fy,GRAPHICS_CURVES:()=>St.wA,GenerateTextureSystem:()=>n.zV,Geometry:()=>n.wG,GeometrySystem:()=>n.TO,Graphics:()=>St.TC,GraphicsData:()=>St.iM,GraphicsGeometry:()=>St.RB,HTMLText:()=>te,HTMLTextStyle:()=>Qt,IGLUniformData:()=>n.W1,INSTALLED:()=>n.e_,INTERNAL_FORMATS:()=>L,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:()=>F,ImageBitmapResource:()=>n._w,ImageResource:()=>n.PA,LINE_CAP:()=>St.$o,LINE_JOIN:()=>St.S,LineStyle:()=>St.TD,LoaderParserPriority:()=>O.Q2,MASK_TYPES:()=>n.A7,MIPMAP_MODES:()=>n.KI,MSAA_QUALITY:()=>n.G5,MaskData:()=>n.HI,MaskSystem:()=>n.zj,Matrix:()=>n.y3,Mesh:()=>xt.Kj,MeshBatchUvs:()=>xt.wQ,MeshGeometry:()=>xt.xc,MeshMaterial:()=>xt.rY,MultisampleSystem:()=>n.XR,NineSlicePlane:()=>Pt.ZT,NoiseFilter:()=>g,ObjectRenderer:()=>n.bO,ObjectRendererSystem:()=>n.i0,ObservablePoint:()=>n.AB,PI_2:()=>n._b,PRECISION:()=>n.cB,ParticleContainer:()=>At.T,ParticleRenderer:()=>At.P,PlaneGeometry:()=>Pt._1,PluginSystem:()=>n.hN,Point:()=>n.E9,Polygon:()=>n.mg,Prepare:()=>Xt,Program:()=>n.$r,ProjectionSystem:()=>n.NW,Quad:()=>n.lD,QuadUv:()=>n.ud,RAD_TO_DEG:()=>n.jl,RENDERER_TYPE:()=>n.N3,Rectangle:()=>n.Ae,RenderTexture:()=>n.TI,RenderTexturePool:()=>n.uW,RenderTextureSystem:()=>n.J$,Renderer:()=>n.Th,ResizePlugin:()=>B.x,Resource:()=>n._z,RopeGeometry:()=>Pt.Au,RoundedRectangle:()=>n.c9,Runner:()=>n.RC,SAMPLER_TYPES:()=>n.oT,SCALE_MODES:()=>n.aH,SHAPES:()=>n.HS,SVGResource:()=>n.pX,ScissorSystem:()=>n.id,Shader:()=>n.ex,ShaderSystem:()=>n.p,SimpleMesh:()=>Pt.AL,SimplePlane:()=>Pt.VJ,SimpleRope:()=>Pt.IE,Sprite:()=>s.j,SpriteMaskFilter:()=>n.z9,Spritesheet:()=>jt,StartupSystem:()=>n.fD,State:()=>n.ZM,StateSystem:()=>n.zI,StencilSystem:()=>n.Ld,SystemManager:()=>n.Od,TARGETS:()=>n.sp,TEXT_GRADIENT:()=>wt.M_,TYPES:()=>n.vK,TYPES_TO_BYTES_PER_COMPONENT:()=>dt,TYPES_TO_BYTES_PER_PIXEL:()=>mt,TemporaryDisplayObject:()=>r.Ql,Text:()=>wt.xv,TextFormat:()=>qt.SQ,TextMetrics:()=>wt._A,TextStyle:()=>wt.pn,Texture:()=>n.xE,TextureGCSystem:()=>n.wr,TextureMatrix:()=>n.UX,TextureSystem:()=>n.CT,TextureUvs:()=>n.aF,Ticker:()=>n.vB,TickerPlugin:()=>n.Sb,TilingSprite:()=>Yt.o,TilingSpriteRenderer:()=>Yt.S,TimeLimiter:()=>Ht,Transform:()=>n.wx,TransformFeedback:()=>n.k7,TransformFeedbackSystem:()=>n.oR,UPDATE_PRIORITY:()=>n.uF,UniformGroup:()=>n.oo,VERSION:()=>n.q4,VideoResource:()=>n.eH,ViewSystem:()=>n.ls,ViewableBuffer:()=>n.Rv,WRAP_MODES:()=>n.Nt,XMLFormat:()=>qt.Lq,XMLStringFormat:()=>qt.lx,accessibleTarget:()=>C,autoDetectFormat:()=>qt.jv,autoDetectRenderer:()=>n.e6,autoDetectResource:()=>n.pb,cacheTextureArray:()=>O.FR,checkDataUrl:()=>O.VT,checkExtension:()=>O.gN,checkMaxIfStatementsInShader:()=>n.a7,convertToList:()=>O.Sf,copySearchParams:()=>O.uz,createStringVariations:()=>O.ew,createTexture:()=>O.cU,createUBOElements:()=>n.TF,curves:()=>St.yw,defaultFilterVertex:()=>n.Y9,defaultVertex:()=>n.kP,detectAvif:()=>O.H2,detectCompressedTextures:()=>U,detectDefaults:()=>O.Ut,detectWebp:()=>O.vP,extensions:()=>n.Rw,filters:()=>_,generateProgram:()=>n.qw,generateUniformBufferSync:()=>n.K0,getFontFamilyName:()=>O.qG,getTestContext:()=>n.Kc,getUBOData:()=>n.DL,graphicsUtils:()=>St.yR,groupD8:()=>n.Lv,isMobile:()=>n.tq,isSingleItem:()=>O.Xp,loadBitmapFont:()=>qt.A0,loadDDS:()=>_t,loadImageBitmap:()=>O.gy,loadJson:()=>O._l,loadKTX:()=>ft,loadSVG:()=>O.XN,loadTextures:()=>O.jU,loadTxt:()=>O.W4,loadWebFont:()=>O.sx,parseDDS:()=>at,parseKTX:()=>vt,resolveCompressedTextureUrl:()=>Et,resolveTextureUrl:()=>O.$m,settings:()=>n.Xd,spritesheetAsset:()=>Kt,uniformParsers:()=>n.sg,unsafeEvalSupported:()=>n.O2,utils:()=>n.P6});var n=i(6951),r=i(8820),s=i(2274);const o=new n.y3;r.s$.prototype._cacheAsBitmap=!1,r.s$.prototype._cacheData=null,r.s$.prototype._cacheAsBitmapResolution=null,r.s$.prototype._cacheAsBitmapMultisample=null;class a{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(r.s$.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(t){t!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=t,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(t){t!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=t,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(t){if(this._cacheAsBitmap===t)return;let e;this._cacheAsBitmap=t,t?(this._cacheData||(this._cacheData=new a),e=this._cacheData,e.originalRender=this.render,e.originalRenderCanvas=this.renderCanvas,e.originalUpdateTransform=this.updateTransform,e.originalCalculateBounds=this.calculateBounds,e.originalGetLocalBounds=this.getLocalBounds,e.originalDestroy=this.destroy,e.originalContainsPoint=this.containsPoint,e.originalMask=this._mask,e.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(e=this._cacheData,e.sprite&&this._destroyCachedDisplayObject(),this.render=e.originalRender,this.renderCanvas=e.originalRenderCanvas,this.calculateBounds=e.originalCalculateBounds,this.getLocalBounds=e.originalGetLocalBounds,this.destroy=e.originalDestroy,this.updateTransform=e.originalUpdateTransform,this.containsPoint=e.originalContainsPoint,this._mask=e.originalMask,this.filterArea=e.originalFilterArea)}}}),r.s$.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))},r.s$.prototype._initCachedDisplayObject=function(t){if(this._cacheData?.sprite)return;const e=this.alpha;this.alpha=1,t.batch.flush();const i=this.getLocalBounds(null,!0).clone();if(this.filters?.length){const t=this.filters[0].padding;i.pad(t)}i.ceil(n.Xd.RESOLUTION);const r=t.renderTexture.current,a=t.renderTexture.sourceFrame.clone(),l=t.renderTexture.destinationFrame.clone(),h=t.projection.transform,u=n.TI.create({width:i.width,height:i.height,resolution:this.cacheAsBitmapResolution||t.resolution,multisample:this.cacheAsBitmapMultisample??t.multisample}),c=`cacheAsBitmap_${n.P6.uid()}`;this._cacheData.textureCacheId=c,n.VL.addToCache(u.baseTexture,c),n.xE.addToCache(u,c);const d=this.transform.localTransform.copyTo(o).invert().translate(-i.x,-i.y);this.render=this._cacheData.originalRender,t.render(this,{renderTexture:u,clear:!0,transform:d,skipUpdateTransform:!1}),t.framebuffer.blit(),t.projection.transform=h,t.renderTexture.bind(r,a,l),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 p=new s.j(u);p.transform.worldTransform=this.transform.worldTransform,p.anchor.x=-i.x/i.width,p.anchor.y=-i.y/i.height,p.alpha=e,p._bounds=this._bounds,this._cacheData.sprite=p,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=p.containsPoint.bind(p)},r.s$.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))},r.s$.prototype._initCachedDisplayObjectCanvas=function(t){if(this._cacheData?.sprite)return;const e=this.getLocalBounds(null,!0),i=this.alpha;this.alpha=1;const r=t.canvasContext.activeContext,a=t._projTransform;e.ceil(n.Xd.RESOLUTION);const l=n.TI.create({width:e.width,height:e.height}),h=`cacheAsBitmap_${n.P6.uid()}`;this._cacheData.textureCacheId=h,n.VL.addToCache(l.baseTexture,h),n.xE.addToCache(l,h);const u=o;this.transform.localTransform.copyTo(u),u.invert(),u.tx-=e.x,u.ty-=e.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,{renderTexture:l,clear:!0,transform:u,skipUpdateTransform:!1}),t.canvasContext.activeContext=r,t._projTransform=a,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=i;const c=new s.j(l);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-e.x/e.width,c.anchor.y=-e.y/e.height,c.alpha=i,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=c.containsPoint.bind(c)},r.s$.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},r.s$.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},r.s$.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,n.VL.removeFromCache(this._cacheData.textureCacheId),n.xE.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},r.s$.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},r.s$.prototype.name=null,r.W2.prototype.getChildByName=function(t,e){for(let e=0,i=this.children.length;e=i&&(n=t-r-1),o=o.replace("%value%",e[n].toString()),s+=o,s+="\n"}return r=r.replace("%blur%",s),r=r.replace("%size%",t.toString()),r}(s);super(o,a),this.horizontal=t,this.resolution=r,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,r){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.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,1===this.passes)t.applyFilter(this,e,i,r);else{const s=t.getFilterTexture(),o=t.renderer;let a=e,l=s;this.state.blend=!1,t.applyFilter(this,a,l,n.yl.CLEAR);for(let e=1;e 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n",t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[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 i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,r,s]=n.Il.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,r,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){this._loadMatrix([.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),n=Math.sin(t),r=1/3,s=(0,Math.sqrt)(r),o=[i+(1-i)*r,r*(1-i)-s*n,r*(1-i)+s*n,0,0,r*(1-i)+s*n,i+r*(1-i),r*(1-i)-s*n,0,0,r*(1-i)-s*n,r*(1-i)+s*n,i+r*(1-i),0,0,0,0,0,1,0];this._loadMatrix(o,e)}contrast(t,e){const i=(t||0)+1,n=-.5*(i-1),r=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(r,e)}saturate(t=0,e){const i=2*t/3+1,n=-.5*(i-1),r=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(r,e)}desaturate(){this.saturate(-1)}negative(t){this._loadMatrix([-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],t)}sepia(t){this._loadMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],t)}technicolor(t){this._loadMatrix([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],t)}polaroid(t){this._loadMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],t)}toBGR(t){this._loadMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t)}kodachrome(t){this._loadMatrix([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],t)}browni(t){this._loadMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],t)}vintage(t){this._loadMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],t)}colorTone(t,e,i,r,s){t=t||.2,e=e||.15,i=i||16770432,r=r||3375104;const o=n.Il.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(r).toArray(),p=[.3,.59,.11,0,0,a,l,h,t,0,u,c,d,e,0,a-u,l-c,h-d,0,0];this._loadMatrix(p,s)}night(t,e){const i=[-2*(t=t||.1),-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[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(i,e)}lsd(t){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],t)}reset(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!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}}p.prototype.grayscale=p.prototype.greyscale;class m extends n.wn{constructor(t,e){const i=new n.y3;t.renderable=!1,super("attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\nuniform mat3 filterMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vFilterCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n\tgl_Position = filterVertexPosition();\n\tvTextureCoord = filterTextureCoord();\n\tvFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;\n}\n","varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\nuniform mat2 rotation;\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform highp vec4 inputSize;\nuniform vec4 inputClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy = scale * inputSize.zw * (rotation * map.xy);\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));\n}\n",{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,null==e&&(e=20),this.scale=new n.E9(e,e)}apply(t,e,i,n){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const r=this.maskSprite.worldTransform,s=Math.sqrt(r.a*r.a+r.b*r.b),o=Math.sqrt(r.c*r.c+r.d*r.d);0!==s&&0!==o&&(this.uniforms.rotation[0]=r.a/s,this.uniforms.rotation[1]=r.b/s,this.uniforms.rotation[2]=r.c/o,this.uniforms.rotation[3]=r.d/o),t.applyFilter(this,e,i,n)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}class v extends n.wn{constructor(){super("\nattribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vFragCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvoid texcoords(vec2 fragCoord, vec2 inverseVP,\n out vec2 v_rgbNW, out vec2 v_rgbNE,\n out vec2 v_rgbSW, out vec2 v_rgbSE,\n out vec2 v_rgbM) {\n v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\n v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\n v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\n v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\n v_rgbM = vec2(fragCoord * inverseVP);\n}\n\nvoid main(void) {\n\n gl_Position = filterVertexPosition();\n\n vFragCoord = aVertexPosition * outputFrame.zw;\n\n texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}\n",'varying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vFragCoord;\nuniform sampler2D uSampler;\nuniform highp vec4 inputSize;\n\n\n/**\n Basic FXAA implementation based on the code on geeks3d.com with the\n modification that the texture2DLod stuff was removed since it\'s\n unsupported by WebGL.\n\n --\n\n From:\n https://github.com/mitsuhiko/webgl-meincraft\n\n Copyright (c) 2011 by Armin Ronacher.\n\n Some rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are\n met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n\n * The names of the contributors may not be used to endorse or\n promote products derived from this software without specific\n prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef FXAA_REDUCE_MIN\n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n#define FXAA_SPAN_MAX 8.0\n#endif\n\n//optimized version for mobile, where dependent\n//texture reads can be a bottleneck\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,\n vec2 v_rgbNW, vec2 v_rgbNE,\n vec2 v_rgbSW, vec2 v_rgbSE,\n vec2 v_rgbM) {\n vec4 color;\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n\n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\nvoid main() {\n\n vec4 color;\n\n color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n gl_FragColor = color;\n}\n')}}class g extends n.wn{constructor(t=.5,e=Math.random()){super(n.Y9,"precision highp float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform float uNoise;\nuniform float uSeed;\nuniform sampler2D uSampler;\n\nfloat rand(vec2 co)\n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float randomValue = rand(gl_FragCoord.xy * uSeed);\n float diff = (randomValue - 0.5) * uNoise;\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (color.a > 0.0) {\n color.rgb /= color.a;\n }\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n // Premultiply alpha again.\n color.rgb *= color.a;\n\n gl_FragColor = color;\n}\n",{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}}const _={AlphaFilter:l,BlurFilter:d,BlurFilterPass:c,ColorMatrixFilter:p,DisplacementFilter:m,FXAAFilter:v,NoiseFilter:g};Object.entries(_).forEach((([t,e])=>{Object.defineProperty(_,t,{get:()=>(n.P6.deprecation("7.1.0",`filters.${t} has moved to ${t}`),e)})}));const f=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){!this.tickerAdded&&this.domElement&&(n.vB.system.add(this.tickerUpdate,this,n.uF.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(n.vB.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,this._deltaTimet.priority-e.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 i=0,n=e.length;i=0;n--)if(t.currentTarget=i[n],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(0===i.length)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(e)?e:[e];for(let e=i.length-1;e>=0;e--)n.forEach((n=>{t.currentTarget=i[e],this.notifyTarget(t,n)}))}propagationPath(t){const e=[t];for(let i=0;i<2048&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,n,r,s=!1){let o=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(f.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let l=a.length-1;l>=0;l--){const h=a[l],u=this.hitTestMoveRecursive(h,this._isInteractive(e)?e:h.eventMode,i,n,r,s||r(t,i));if(u){if(u.length>0&&!u[u.length-1].parent)continue;const e=t.isInteractive();(u.length>0||e)&&(e&&this._allInteractiveElements.push(t),u.push(t)),0===this._hitElements.length&&(this._hitElements=u),o=!0}}}const a=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),s||this._hitElements.length>0?null:o?this._hitElements:a&&!r(t,i)&&n(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,n,r){if(this._interactivePrune(t)||r(t,i))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(f.pauseUpdate=!1),t.interactiveChildren&&t.children){const s=t.children;for(let o=s.length-1;o>=0;o--){const a=s[o],l=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,i,n,r);if(l){if(l.length>0&&!l[l.length-1].parent)continue;const e=t.isInteractive();return(l.length>0||e)&&l.push(t),l}}}const s=this._isInteractive(e),o=t.isInteractive();return s&&n(t,i)?o?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&!t.isMask&&t.visible&&t.renderable)||"none"===t.eventMode||"passive"===t.eventMode&&!t.interactiveChildren||!!t.isMask}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,x),!t.hitArea.contains(x.x,x.y)))return!0;if(t._mask){const i=t._mask.isMaskData?t._mask.maskObject:t._mask;if(i&&!i.containsPoint?.(e))return!0}return!1}hitTestFn(t,e){return"passive"!==t.eventMode&&(!!t.hitArea||!!t.containsPoint&&t.containsPoint(e))}notifyTarget(t,e){const i=`on${e=e??t.type}`;t.currentTarget[i]?.(t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof T))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof T))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i="mouse"===e.pointerType||"pen"===e.pointerType,n=this.trackingData(t.pointerId),r=this.findMountedTarget(n.overTargets);if(n.overTargets?.length>0&&r!==e.target){const n="mousemove"===t.type?"mouseout":"pointerout",s=this.createPointerEvent(t,n,r);if(this.dispatchEvent(s,"pointerout"),i&&this.dispatchEvent(s,"mouseout"),!e.composedPath().includes(r)){const n=this.createPointerEvent(t,"pointerleave",r);for(n.eventPhase=n.AT_TARGET;n.target&&!e.composedPath().includes(n.target);)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;this.freeEvent(n)}this.freeEvent(s)}if(r!==e.target){const n="mousemove"===t.type?"mouseover":"pointerover",s=this.clonePointerEvent(e,n);this.dispatchEvent(s,"pointerover"),i&&this.dispatchEvent(s,"mouseover");let o=r?.parent;for(;o&&o!==this.rootTarget.parent&&o!==e.target;)o=o.parent;if(!o||o===this.rootTarget.parent){const t=this.clonePointerEvent(e,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==r&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),i&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(s)}const s=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?s.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&s.push("globalpointermove"),"touch"===e.pointerType&&(this.moveOnAll?s.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&s.push("globaltouchmove")),i&&(this.moveOnAll?s.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&s.push("globalmousemove"),this.cursor=e.target?.cursor),s.length>0&&this.all(e,s),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof T))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n="mouse"===i.pointerType||"pen"===i.pointerType;this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),"mouse"===i.pointerType&&(this.cursor=i.target?.cursor);const r=this.clonePointerEvent(i,"pointerenter");for(r.eventPhase=r.AT_TARGET;r.target&&r.target!==this.rootTarget.parent;)r.currentTarget=r.target,this.notifyTarget(r),n&&this.notifyTarget(r,"mouseenter"),r.target=r.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(r)}mapPointerOut(t){if(!(t instanceof T))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,n=this.findMountedTarget(e.overTargets),r=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(r),i&&this.dispatchEvent(r,"mouseout");const s=this.createPointerEvent(t,"pointerleave",n);for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),i&&this.notifyTarget(s,"mouseleave"),s.target=s.target.parent;e.overTargets=null,this.freeEvent(r),this.freeEvent(s)}this.cursor=null}mapPointerUp(t){if(!(t instanceof T))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),r=this.findMountedTarget(n.pressTargetsByButton[t.button]);let s=r;if(r&&!i.composedPath().includes(r)){let e=r;for(;e&&!i.composedPath().includes(e);){if(i.currentTarget=e,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.notifyTarget(i,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete n.pressTargetsByButton[t.button],s=e}if(s){const r=this.clonePointerEvent(i,"click");r.target=s,r.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:r.target,timeStamp:e});const o=n.clicksByButton[t.button];if(o.target===r.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=r.target,o.timeStamp=e,r.detail=o.clickCount,"mouse"===r.pointerType){const t=2===r.button;this.dispatchEvent(r,t?"rightclick":"click")}else"touch"===r.pointerType&&this.dispatchEvent(r,"tap");this.dispatchEvent(r,"pointertap"),this.freeEvent(r)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof T))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let r=i;for(;r;)n.currentTarget=r,this.notifyTarget(n,"pointerupoutside"),"touch"===n.pointerType?this.notifyTarget(n,"touchendoutside"):"mouse"!==n.pointerType&&"pen"!==n.pointerType||this.notifyTarget(n,2===n.button?"rightupoutside":"mouseupoutside"),r=r.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof b))return void console.warn("EventBoundary cannot map a non-wheel event as a wheel event");const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=i),t[e]=i,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,w._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;if(this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&"touch"===t.pointerType)return;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let t=0,i=e.length;t0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",n=this.normalizeToPointerData(t);for(let t=0,e=n.length;t{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(){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),this.renderer.view.parentNode?.appendChild(this.div))}deactivate(){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),this.div.parentNode?.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let t=0;t 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:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2..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&&null!==t.accessibleTitle?e.title=t.accessibleTitle:t.accessibleHint&&null!==t.accessibleHint||(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&null!==t.accessibleHint&&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:i}=t.target,n=this.renderer.events.rootBoundary,r=Object.assign(new E(n),{target:i});n.rootTarget=this.renderer.lastObjectRendered,e.forEach((t=>n.dispatchEvent(r,t)))}_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){9===t.keyCode&&this.activate()}_onMouseMove(t){0===t.movementX&&0===t.movementY||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}}I.extension={name:"accessibility",type:[n.nw.RendererPlugin,n.nw.CanvasRendererPlugin]},n.Rw.add(I);var B=i(8440),O=i(2770),L=(t=>(t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t))(L||{});const F={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};let N,G;function k(){G={s3tc:N.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:N.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:N.getExtension("WEBGL_compressed_texture_etc"),etc1:N.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:N.getExtension("WEBGL_compressed_texture_pvrtc")||N.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:N.getExtension("WEBGL_compressed_texture_atc"),astc:N.getExtension("WEBGL_compressed_texture_astc")}}const U={extension:{type:n.nw.DetectionParser,priority:2},test:async()=>{const t=n.Xd.ADAPTER.createCanvas().getContext("webgl");return t?(N=t,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async t=>{G||k();const e=[];for(const t in G)G[t]&&e.push(t);return[...e,...t]},remove:async t=>(G||k(),t.filter((t=>!(t in G))))};n.Rw.add(U);class X extends n.qm{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,r;"string"==typeof t?(i=t,r=new Uint8Array):(i=null,r=t),super(r,e),this.origin=i,this.buffer=r?new n.Rv(r):null,this._load=null,this.loaded=!1,null!==this.origin&&!1!==e.autoLoad&&this.load(),null===this.origin&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load||(this._load=fetch(this.origin).then((t=>t.blob())).then((t=>t.arrayBuffer())).then((t=>(this.data=new Uint32Array(t),this.buffer=new n.Rv(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)))),this._load}}class H extends X{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=H._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||H._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const n=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 t=0,e=this.levels;t=33776&&t<=33779)return"s3tc";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,i,n,r,s,o){const a=new Array(i);let l=t.byteOffset,h=s,u=o,c=h+n-1&~(n-1),d=u+r-1&~(r-1),p=c*d*F[e];for(let s=0;s1?h:c,levelHeight:i>1?u:d,levelBuffer:new Uint8Array(t.buffer,l,p)},l+=p,h=h>>1||1,u=u>>1||1,c=h+n-1&~(n-1),d=u+r-1&~(r-1),p=c*d*F[e];return a}}const W=4,Y=124,V=32,j=20,z=542327876,$={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},K={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},q={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Z=1,Q=2,J=4,tt=64,et=512,it=131072,nt=808540228,rt=4,st={827611204:L.COMPRESSED_RGBA_S3TC_DXT1_EXT,861165636:L.COMPRESSED_RGBA_S3TC_DXT3_EXT,894720068:L.COMPRESSED_RGBA_S3TC_DXT5_EXT},ot={70:L.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:L.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:L.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:L.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:L.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:L.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:L.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:L.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:L.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function at(t){const e=new Uint32Array(t);if(e[0]!==z)throw new Error("Invalid DDS file magic word");const i=new Uint32Array(t,0,Y/Uint32Array.BYTES_PER_ELEMENT),n=i[$.HEIGHT],r=i[$.WIDTH],s=i[$.MIPMAP_COUNT],o=new Uint32Array(t,$.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,V/Uint32Array.BYTES_PER_ELEMENT),a=o[Z];if(a&J){const i=o[K.FOURCC];if(i!==nt){const e=st[i],o=new Uint8Array(t,W+Y);return[new H(o,{format:e,width:r,height:n,levels:s})]}const a=W+Y,l=new Uint32Array(e.buffer,a,j/Uint32Array.BYTES_PER_ELEMENT),h=l[q.DXGI_FORMAT],u=l[q.RESOURCE_DIMENSION],c=l[q.MISC_FLAG],d=l[q.ARRAY_SIZE],p=ot[h];if(void 0===p)throw new Error(`DDSParser cannot parse texture data with DXGI format ${h}`);if(c===rt)throw new Error("DDSParser does not support cubemap textures");if(6===u)throw new Error("DDSParser does not supported 3D texture data");const m=new Array,v=W+Y+j;if(1===d)m.push(new Uint8Array(t,v));else{const e=F[p];let i=0,o=r,a=n;for(let t=0;t>>=1,a>>>=1;let l=v;for(let e=0;enew H(t,{format:p,width:r,height:n,levels:s})))}if(a&tt)throw new Error("DDSParser does not support uncompressed texture data.");if(a&et)throw new Error("DDSParser does not supported YUV uncompressed texture data.");if(a&it)throw new Error("DDSParser does not support single-channel (lumninance) texture data!");if(a&Q)throw new Error("DDSParser does not support single-channel (alpha) texture data!");throw new Error("DDSParser failed to load a texture file due to an unknown reason!")}const lt=[171,75,84,88,32,49,49,187,13,10,26,10],ht=67305985,ut={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},ct=64,dt={[n.vK.UNSIGNED_BYTE]:1,[n.vK.UNSIGNED_SHORT]:2,[n.vK.INT]:4,[n.vK.UNSIGNED_INT]:4,[n.vK.FLOAT]:4,[n.vK.HALF_FLOAT]:8},pt={[n.I2.RGBA]:4,[n.I2.RGB]:3,[n.I2.RG]:2,[n.I2.RED]:1,[n.I2.LUMINANCE]:1,[n.I2.LUMINANCE_ALPHA]:2,[n.I2.ALPHA]:1},mt={[n.vK.UNSIGNED_SHORT_4_4_4_4]:2,[n.vK.UNSIGNED_SHORT_5_5_5_1]:2,[n.vK.UNSIGNED_SHORT_5_6_5]:2};function vt(t,e,i=!1){const r=new DataView(e);if(!function(t,e){for(let i=0;ie-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l1||0!==o?S:P,levelHeight:m>1||0!==o?x:A,levelBuffer:new Uint8Array(e,n,b)},n+=b}w+=i+4,w=w%4!=0?w+4-w%4:w,S=S>>1||1,x=x>>1||1,P=S+4-1&-4,A=x+4-1&-4,b=P*A*E}return 0!==o?{uncompressed:f.map((t=>{let e=t[0].levelBuffer,i=!1;return o===n.vK.FLOAT?e=new Float32Array(t[0].levelBuffer.buffer,t[0].levelBuffer.byteOffset,t[0].levelBuffer.byteLength/4):o===n.vK.UNSIGNED_INT?(i=!0,e=new Uint32Array(t[0].levelBuffer.buffer,t[0].levelBuffer.byteOffset,t[0].levelBuffer.byteLength/4)):o===n.vK.INT&&(i=!0,e=new Int32Array(t[0].levelBuffer.buffer,t[0].levelBuffer.byteOffset,t[0].levelBuffer.byteLength/4)),{resource:new n.qm(e,{width:t[0].levelWidth,height:t[0].levelHeight}),type:o,format:i?gt(a):a}})),kvData:T}:{compressed:f.map((t=>new H(null,{format:l,width:h,height:u,levels:m,levelBuffers:t}))),kvData:T}}function gt(t){switch(t){case n.I2.RGBA:return n.I2.RGBA_INTEGER;case n.I2.RGB:return n.I2.RGB_INTEGER;case n.I2.RG:return n.I2.RG_INTEGER;case n.I2.RED:return n.I2.RED_INTEGER;default:return t}}const _t={extension:{type:n.nw.LoadParser,priority:O.Q2.High},name:"loadDDS",test:t=>(0,O.gN)(t,".dds"),async load(t,e,i){const r=await n.Xd.ADAPTER.fetch(t),s=at(await r.arrayBuffer()).map((r=>{const s=new n.VL(r,{mipmap:n.KI.OFF,alphaMode:n.iw.NO_PREMULTIPLIED_ALPHA,resolution:n.P6.getResolutionOfUrl(t),...e.data});return(0,O.cU)(s,i,t)}));return 1===s.length?s[0]:s},unload(t){Array.isArray(t)?t.forEach((t=>t.destroy(!0))):t.destroy(!0)}};n.Rw.add(_t);const ft={extension:{type:n.nw.LoadParser,priority:O.Q2.High},name:"loadKTX",test:t=>(0,O.gN)(t,".ktx"),async load(t,e,i){const r=await n.Xd.ADAPTER.fetch(t),s=await r.arrayBuffer(),{compressed:o,uncompressed:a,kvData:l}=vt(t,s),h=o??a,u={mipmap:n.KI.OFF,alphaMode:n.iw.NO_PREMULTIPLIED_ALPHA,resolution:n.P6.getResolutionOfUrl(t),...e.data},c=h.map((e=>{h===a&&Object.assign(u,{type:e.type,format:e.format});const r=new n.VL(e,u);return r.ktxKeyValueData=l,(0,O.cU)(r,i,t)}));return 1===c.length?c[0]:c},unload(t){Array.isArray(t)?t.forEach((t=>t.destroy(!0))):t.destroy(!0)}};n.Rw.add(ft);const Et={extension:n.nw.ResolveParser,test:t=>{const e=t.split("?")[0].split(".").pop();return["basis","ktx","dds"].includes(e)},parse:t=>{if("ktx"===t.split("?")[0].split(".").pop()){const e=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(e.some((e=>t.endsWith(e))))return{resolution:parseFloat(n.Xd.RETINA_PREFIX.exec(t)?.[1]??"1"),format:e.find((e=>t.endsWith(e))),src:t}}return{resolution:parseFloat(n.Xd.RETINA_PREFIX.exec(t)?.[1]??"1"),format:t.split(".").pop(),src:t}}};n.Rw.add(Et);const yt=new n.Ae,Tt=class{constructor(t){this.renderer=t}async image(t,e,i){const n=new Image;return n.src=await this.base64(t,e,i),n}async base64(t,e,i){const n=this.canvas(t);if(void 0!==n.toBlob)return new Promise(((t,r)=>{n.toBlob((e=>{if(!e)return void r(new Error("ICanvas.toBlob failed!"));const i=new FileReader;i.onload=()=>t(i.result),i.onerror=r,i.readAsDataURL(e)}),e,i)}));if(void 0!==n.toDataURL)return n.toDataURL(e,i);if(void 0!==n.convertToBlob){const t=await n.convertToBlob({type:e,quality:i});return new Promise(((e,i)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=i,n.readAsDataURL(t)}))}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:r,height:s,flipY:o}=this._rawPixels(t,e);o&&Tt._flipY(i,r,s),Tt._unpremultiplyAlpha(i);const a=new n.P6.CanvasRenderTarget(r,s,1),l=new ImageData(new Uint8ClampedArray(i.buffer),r,s);return a.context.putImageData(l,0,0),a.canvas}pixels(t,e){const{pixels:i,width:n,height:r,flipY:s}=this._rawPixels(t,e);return s&&Tt._flipY(i,n,r),Tt._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let r,s,o=!1,a=!1;if(t&&(t instanceof n.TI?s=t:(s=i.generateTexture(t,{resolution:i.resolution,multisample:i.multisample}),a=!0)),s){if(r=s.baseTexture.resolution,e=e??s.frame,o=!1,!a){i.renderTexture.bind(s);const t=s.framebuffer.glFramebuffers[i.CONTEXT_UID];t.blitFramebuffer&&i.framebuffer.bind(t.blitFramebuffer)}}else r=i.resolution,e||((e=yt).width=i.width/r,e.height=i.height/r),o=!0,i.renderTexture.bind();const l=Math.round(e.width*r),h=Math.round(e.height*r),u=new Uint8Array(4*l*h),c=i.gl;return c.readPixels(Math.round(e.x*r),Math.round(e.y*r),l,h,c.RGBA,c.UNSIGNED_BYTE,u),a&&s?.destroy(!0),{pixels:u,width:l,height:h,flipY:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const n=e<<2,r=i>>1,s=new Uint8Array(n);for(let e=0;e0}}function Rt(t,e){let i=!1;if(t?._textures?.length)for(let r=0;r{this.queue&&this.prepareItems()},this.registerFindHook(Ot),this.registerFindHook(Lt),this.registerFindHook(Rt),this.registerFindHook(Dt),this.registerFindHook(Ct),this.registerUploadHook(It),this.registerUploadHook(Bt)}upload(t){return new Promise((e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,n.vB.system.addOnce(this.tick,this,n.uF.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 i=0,n=this.uploadHooks.length;i=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&n.vB.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}};let Nt=Ft;function Gt(t,e){return e instanceof n.VL&&(e._glTextures[t.CONTEXT_UID]||t.texture.bind(e),!0)}function kt(t,e){if(!(e instanceof St.TC))return!1;const{geometry:i}=e;e.finishPoly(),i.updateBatches();const{batches:n}=i;for(let e=0;eNt.uploadsPerFrame,set(t){n.P6.deprecation("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Nt.uploadsPerFrame=t}}});class Xt extends Nt{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(Ut),this.registerUploadHook(Gt),this.registerUploadHook(kt)}}Xt.extension={name:"prepare",type:n.nw.RendererSystem},n.Rw.add(Xt);class Ht{constructor(t){this.maxMilliseconds=t,this.frameStart=0}beginFrame(){this.frameStart=Date.now()}allowedToUpload(){return Date.now()-this.frameStart{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Vt.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()}))}_processFrames(t){let e=t;const i=Vt.BATCH_SIZE;for(;e-t{this._batchIndex*Vt.BATCH_SIZE{r[t]=e})),Object.keys(e.textures).forEach((t=>{r[t]=e.textures[t]})),!i){const i=n.P6.path.dirname(t[0]);e.linkedSheets.forEach(((t,n)=>{const s=$t([`${i}/${e.data.meta.related_multi_packs[n]}`],t,!0);Object.assign(r,s)}))}return r}const Kt={extension:n.nw.Asset,cache:{test:t=>t instanceof jt,getCacheableAssets:(t,e)=>$t(t,e,!1)},resolver:{test:t=>{const e=t.split("?")[0].split("."),i=e.pop(),n=e.pop();return"json"===i&&zt.includes(n)},parse:t=>{const e=t.split(".");return{resolution:parseFloat(n.Xd.RETINA_PREFIX.exec(t)?.[1]??"1"),format:e[e.length-2],src:t}}},loader:{name:"spritesheetLoader",extension:{type:n.nw.LoadParser,priority:O.Q2.Normal},testParse:async(t,e)=>".json"===n.P6.path.extname(e.src).toLowerCase()&&!!t.frames,async parse(t,e,i){let r=n.P6.path.dirname(e.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let s=r+t.meta.image;s=(0,O.uz)(s,e.src);const o=(await i.load([s]))[s],a=new jt(o.baseTexture,t,e.src);await a.parse();const l=t?.meta?.related_multi_packs;if(Array.isArray(l)){const t=[];for(const n of l){if("string"!=typeof n)continue;let s=r+n;e.data?.ignoreMultiPack||(s=(0,O.uz)(s,e.src),t.push(i.load({src:s,data:{ignoreMultiPack:!0}})))}const n=await Promise.all(t);a.linkedSheets=n,n.forEach((t=>{t.linkedSheets=[a].concat(a.linkedSheets.filter((e=>e!==t)))}))}return a},unload(t){t.destroy(!0)}}};n.Rw.add(Kt);var qt=i(5884);const Zt=class extends wt.pn{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Zt(Object.keys(Zt.defaultOptions).reduce(((e,i)=>({...e,[i]:t[i]})),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach((t=>{URL.revokeObjectURL(t.src),t.refs--,0===t.refs&&(t.fontFace&&document.fonts.delete(t.fontFace),delete Zt.availableFonts[t.originalUrl])})),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=Zt;if(i[t]){const e=i[t];return this._fonts.push(e),e.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return n.Xd.ADAPTER.fetch(t).then((t=>t.blob())).then((async t=>new Promise(((e,i)=>{const n=URL.createObjectURL(t),r=new FileReader;r.onload=()=>e([n,r.result]),r.onerror=i,r.readAsDataURL(t)})))).then((async([r,s])=>{const o=Object.assign({family:n.P6.path.basename(t,n.P6.path.extname(t)),weight:"normal",style:"normal",src:r,dataSrc:s,refs:1,originalUrl:t,fontFace:null},e);i[t]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0}))}addOverride(...t){const e=t.filter((t=>!this._overrides.includes(t)));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter((t=>this._overrides.includes(t)));e.length>0&&(this._overrides=this._overrides.filter((t=>!e.includes(t))),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?["word-wrap: "+(this.breakWords?"break-all":"break-word"),`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce(((t,e)=>`${t}\n @font-face {\n font-family: "${e.family}";\n src: url('${e.dataSrc}');\n font-weight: ${e.weight};\n font-style: ${e.style}; \n }`),this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=n.P6.rgb2hex(t)),"number"==typeof t?n.P6.hex2string(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(255*e|0).toString(16).padStart(2,"0"));const r=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${r} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${r} ${t}`}reset(){Object.assign(this,Zt.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise((t=>setTimeout(t,100))):Promise.resolve()}get isSafari(){const{userAgent:t}=n.Xd.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};let Qt=Zt;Qt.availableFonts={},Qt.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};const Jt=class extends s.j{constructor(t="",e={}){super(n.xE.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this._loading=!1,this.localStyleID=-1,this.dirty=!1,this.ownsStyle=!1;const i=new Image,r=n.xE.from(i,{scaleMode:n.Xd.SCALE_MODE,resourceOptions:{autoLoad:!1}});r.orig=new n.Ae,r.trim=new n.Ae,this.texture=r;const s="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(s,"svg"),l=document.createElementNS(s,"foreignObject"),h=document.createElementNS(o,"div"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Jt.defaultMaxWidth,this.maxHeight=Jt.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Jt.defaultAutoResolution,this._resolution=Jt.defaultResolution??n.Xd.RESOLUTION,this.text=t,this.style=e}measureText(t){const{text:e,style:i,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(n)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const r=this._domElement.getBoundingClientRect();this._svgRoot.remove();const s=Math.min(this.maxWidth,Math.ceil(r.width)),o=Math.min(this.maxHeight,Math.ceil(r.height));return this._svgRoot.setAttribute("width",s.toString()),this._svgRoot.setAttribute("height",o.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:this._style?.toCSS(n)}),this._styleElement.textContent=this._style?.toGlobalCSS()),{width:s+2*i.padding,height:o+2*i.padding}}async updateText(t=!0){const{style:e,_image:i,_loadImage:n}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:r,height:s}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,r)),i.height=n.height=Math.ceil(Math.max(1,s)),this._loading||(this._loading=!0,await new Promise((t=>{n.onload=async()=>{await e.onBeforeDraw(),this._loading=!1,i.src=n.src,n.onload=null,n.src="",this.updateTexture(),t()};const r=(new XMLSerializer).serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(r)}`})))}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:n}=this,{padding:r}=t,{baseTexture:s}=e;e.trim.width=e._frame.width=i.width/n,e.trim.height=e._frame.height=i.height/n,e.trim.x=-r,e.trim.y=-r,e.orig.width=e._frame.width-2*r,e.orig.height=e._frame.height-2*r,this._onTextureUpdate(),s.setRealSize(i.width,i.height,n),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){"boolean"==typeof t&&(t={children:t}),t=Object.assign({},Jt.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&this._style?.cleanFonts(),this._style=e,this._svgRoot?.remove(),this._svgRoot=e,this._domElement?.remove(),this._domElement=e,this._foreignObject?.remove(),this._foreignObject=e,this._styleElement?.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=n.P6.sign(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=n.P6.sign(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&((t=t||{})instanceof Qt?(this.ownsStyle=!1,this._style=t):t instanceof wt.pn?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Qt.from(t)):(this.ownsStyle=!0,this._style=new Qt(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/
/gi,"
").replace(/
/gi,"
").replace(/ /gi," ")}};let te=Jt;te.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},te.defaultMaxWidth=2024,te.defaultMaxHeight=2024,te.defaultAutoResolution=!0}}]);