@doki-land/live2d 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/l2d.umd.js CHANGED
@@ -1,63 +1,21 @@
1
- (function(qr,Is){typeof exports=="object"&&typeof module<"u"?Is(exports):typeof define=="function"&&define.amd?define(["exports"],Is):(qr=typeof globalThis<"u"?globalThis:qr||self,Is(qr.l2d={}))})(this,function(qr){"use strict";(function(){var Xt=!0;function s(){Xt||(this._$MT=null,this._$5S=null,this._$NP=0,s._$42++,this._$5S=new dt(this))}s._$0s=1,s._$4s=2,s._$42=0,s._$62=function(l,w){try{if(w instanceof ArrayBuffer&&(w=new DataView(w)),!(w instanceof DataView))throw new Hr("_$SS#loadModel(b) / b _$x be DataView or ArrayBuffer");var M=new de(w),L=M._$ST(),O=M._$ST(),N=M._$ST(),e;if(L==109&&O==111&&N==99)e=M._$ST();else throw new Hr("_$gi _$C _$li , _$Q0 _$P0.");if(M._$gr(e),e>ht._$T7){l._$NP|=s._$4s;var H=ht._$T7,W="_$gi _$C _$li , _$n0 _$_ version _$li ( SDK : "+H+" < _$f0 : "+e+` )@_$SS#loadModel()
2
- `;throw new Hr(W)}var rt=M._$nP();if(e>=ht._$s7){var R=M._$9T(),ct=M._$9T();if(R!=-30584||ct!=-30584)throw l._$NP|=s._$0s,new Hr("_$gi _$C _$li , _$0 _$6 _$Ui.")}l._$KS(rt);var j=l.getModelContext();j.setDrawParam(l.getDrawParam()),j.init()}catch(v){h._$Rb(v)}},s.prototype._$KS=function(l){this._$MT=l},s.prototype.getModelImpl=function(){return this._$MT==null&&(this._$MT=new $,this._$MT._$zP()),this._$MT},s.prototype.getCanvasWidth=function(){return this._$MT==null?0:this._$MT.getCanvasWidth()},s.prototype.getCanvasHeight=function(){return this._$MT==null?0:this._$MT.getCanvasHeight()},s.prototype.getParamFloat=function(l){return typeof l!="number"&&(l=this._$5S.getParamIndex(x.getID(l))),this._$5S.getParamFloat(l)},s.prototype.setParamFloat=function(l,w,M){typeof l!="number"&&(l=this._$5S.getParamIndex(x.getID(l))),arguments.length<3&&(M=1),this._$5S.setParamFloat(l,this._$5S.getParamFloat(l)*(1-M)+w*M)},s.prototype.addToParamFloat=function(l,w,M){typeof l!="number"&&(l=this._$5S.getParamIndex(x.getID(l))),arguments.length<3&&(M=1),this._$5S.setParamFloat(l,this._$5S.getParamFloat(l)+w*M)},s.prototype.multParamFloat=function(l,w,M){typeof l!="number"&&(l=this._$5S.getParamIndex(x.getID(l))),arguments.length<3&&(M=1),this._$5S.setParamFloat(l,this._$5S.getParamFloat(l)*(1+(w-1)*M))},s.prototype.getParamIndex=function(l){return this._$5S.getParamIndex(x.getID(l))},s.prototype.loadParam=function(){this._$5S.loadParam()},s.prototype.saveParam=function(){this._$5S.saveParam()},s.prototype.init=function(){this._$5S.init()},s.prototype.update=function(){this._$5S.update()},s.prototype._$Rs=function(){return h._$li("_$60 _$PT _$Rs()"),-1},s.prototype._$Ds=function(l){h._$li(`_$60 _$PT _$SS#_$Ds()
3
- `)},s.prototype._$K2=function(){},s.prototype.draw=function(){},s.prototype.getModelContext=function(){return this._$5S},s.prototype._$s2=function(){return this._$NP},s.prototype._$P7=function(l,w,M,L){var O=-1,N=0,e=this,H=.5,W=.15;if(M==0){for(var rt=0;rt<l.length;rt++){var R=l[rt],ct=w[rt],j=e.getParamFloat(R)!=0;e.setPartsOpacity(ct,j?1:0)}return}else if(l.length==1){var R=l[0],v=e.getParamFloat(R)!=0,ct=w[0],St=e.getPartsOpacity(ct),yt=M/L;v?(St+=yt,St>1&&(St=1)):(St-=yt,St<0&&(St=0)),e.setPartsOpacity(ct,St)}else{for(var rt=0;rt<l.length;rt++){var R=l[rt],j=e.getParamFloat(R)!=0;if(j){if(O>=0)break;O=rt;var ct=w[rt];N=e.getPartsOpacity(ct),N+=M/L,N>1&&(N=1)}}O<0&&(console.log("No _$wi _$q0/ _$U default[%s]",l[0]),O=0,N=1,e.loadParam(),e.setParamFloat(l[O],N),e.saveParam());for(var rt=0;rt<l.length;rt++){var ct=w[rt];if(O==rt)e.setPartsOpacity(ct,N);else{var Mt=e.getPartsOpacity(ct),Ft;N<H?Ft=N*(H-1)/H+1:Ft=(1-N)*H/(1-H);{var Nt=(1-Ft)*(1-N);Nt>W&&(Ft=1-W/(1-N))}Mt>Ft&&(Mt=Ft),e.setPartsOpacity(ct,Mt)}}}},s.prototype.setPartsOpacity=function(l,w){typeof l!="number"&&(l=this._$5S.getPartsDataIndex(T.getID(l))),this._$5S.setPartsOpacity(l,w)},s.prototype.getPartsDataIndex=function(l){return l instanceof T||(l=T.getID(l)),this._$5S.getPartsDataIndex(l)},s.prototype.getPartsOpacity=function(l){return typeof l!="number"&&(l=this._$5S.getPartsDataIndex(T.getID(l))),l<0?0:this._$5S.getPartsOpacity(l)},s.prototype.getDrawParam=function(){},s.prototype.getDrawDataIndex=function(l){return this._$5S.getDrawDataIndex(nt.getID(l))},s.prototype.getDrawData=function(l){return this._$5S.getDrawData(l)},s.prototype.getTransformedPoints=function(l){var w=this._$5S._$C2(l);return w instanceof Li?w.getTransformedPoints():null},s.prototype.getIndexArray=function(l){if(l<0||l>=this._$5S._$aS.length)return null;var w=this._$5S._$aS[l];return w!=null&&w.getType()==Bt._$wb&&w instanceof ze?w.getIndexArray():null};function t(l){if(!Xt){this.clipContextList=new Array,this.glcontext=l.gl,this.dp_webgl=l,this.curFrameNo=0,this.firstError_clipInNotUpdate=!0,this.colorBuffer=0,this.isInitGLFBFunc=!1,this.tmpBoundsOnModel=new Q,Pt.glContext.length>Pt.frameBuffers.length&&(this.curFrameNo=this.getMaskRenderTexture()),this.tmpModelToViewMatrix=new st,this.tmpMatrix2=new st,this.tmpMatrixForMask=new st,this.tmpMatrixForDraw=new st,this.CHANNEL_COLORS=new Array;var w=new Dt;w=new Dt,w.r=0,w.g=0,w.b=0,w.a=1,this.CHANNEL_COLORS.push(w),w=new Dt,w.r=1,w.g=0,w.b=0,w.a=0,this.CHANNEL_COLORS.push(w),w=new Dt,w.r=0,w.g=1,w.b=0,w.a=0,this.CHANNEL_COLORS.push(w),w=new Dt,w.r=0,w.g=0,w.b=1,w.a=0,this.CHANNEL_COLORS.push(w);for(var M=0;M<this.CHANNEL_COLORS.length;M++)this.dp_webgl.setChannelFlagAsColor(M,this.CHANNEL_COLORS[M])}}t.CHANNEL_COUNT=4,t.RENDER_TEXTURE_USE_MIPMAP=!1,t.NOT_USED_FRAME=-100,t.prototype._$L7=function(){if(this.tmpModelToViewMatrix&&(this.tmpModelToViewMatrix=null),this.tmpMatrix2&&(this.tmpMatrix2=null),this.tmpMatrixForMask&&(this.tmpMatrixForMask=null),this.tmpMatrixForDraw&&(this.tmpMatrixForDraw=null),this.tmpBoundsOnModel&&(this.tmpBoundsOnModel=null),this.CHANNEL_COLORS){for(var l=this.CHANNEL_COLORS.length-1;l>=0;--l)this.CHANNEL_COLORS.splice(l,1);this.CHANNEL_COLORS=[]}this.releaseShader()},t.prototype.releaseShader=function(){for(var l=Pt.frameBuffers.length,w=0;w<l;w++)this.gl.deleteFramebuffer(Pt.frameBuffers[w].framebuffer);Pt.frameBuffers=[],Pt.glContext=[]},t.prototype.init=function(l,w,M){for(var L=0;L<w.length;L++){var O=w[L].getClipIDList();if(O!=null){var N=this.findSameClip(O);N==null&&(N=new r(this,l,O),this.clipContextList.push(N));var e=w[L].getDrawDataID(),H=l.getDrawDataIndex(e);N.addClippedDrawData(e,H);var W=M[L];W.clipBufPre_clipContext=N}}},t.prototype.getMaskRenderTexture=function(){var l=null;return l=this.dp_webgl.createFramebuffer(),Pt.frameBuffers[this.dp_webgl.glno]=l,this.dp_webgl.glno},t.prototype.setupClip=function(l,w){for(var M=0,L=0;L<this.clipContextList.length;L++){var O=this.clipContextList[L];this.calcClippedDrawTotalBounds(l,O),O.isUsing&&M++}if(M>0){var N=w.gl.getParameter(w.gl.FRAMEBUFFER_BINDING),e=new Array(4);e[0]=0,e[1]=0,e[2]=w.gl.canvas.width,e[3]=w.gl.canvas.height,w.gl.viewport(0,0,Pt.clippingMaskBufferSize,Pt.clippingMaskBufferSize),this.setupLayoutBounds(M),w.gl.bindFramebuffer(w.gl.FRAMEBUFFER,Pt.frameBuffers[this.curFrameNo].framebuffer),w.gl.clearColor(0,0,0,0),w.gl.clear(w.gl.COLOR_BUFFER_BIT);for(var L=0;L<this.clipContextList.length;L++){var O=this.clipContextList[L],H=O.allClippedDrawRect;O.layoutChannelNo;var W=O.layoutBounds,rt=.05;this.tmpBoundsOnModel._$jL(H),this.tmpBoundsOnModel.expand(H.width*rt,H.height*rt);var R=W.width/this.tmpBoundsOnModel.width,ct=W.height/this.tmpBoundsOnModel.height;this.tmpMatrix2.identity(),this.tmpMatrix2.translate(-1,-1,0),this.tmpMatrix2.scale(2,2,1),this.tmpMatrix2.translate(W.x,W.y,0),this.tmpMatrix2.scale(R,ct,1),this.tmpMatrix2.translate(-this.tmpBoundsOnModel.x,-this.tmpBoundsOnModel.y,0),this.tmpMatrixForMask.setMatrix(this.tmpMatrix2.m),this.tmpMatrix2.identity(),this.tmpMatrix2.translate(W.x,W.y,0),this.tmpMatrix2.scale(R,ct,1),this.tmpMatrix2.translate(-this.tmpBoundsOnModel.x,-this.tmpBoundsOnModel.y,0),this.tmpMatrixForDraw.setMatrix(this.tmpMatrix2.m);for(var j=this.tmpMatrixForMask.getArray(),v=0;v<16;v++)O.matrixForMask[v]=j[v];for(var St=this.tmpMatrixForDraw.getArray(),v=0;v<16;v++)O.matrixForDraw[v]=St[v];for(var yt=O.clippingMaskDrawIndexList.length,Mt=0;Mt<yt;Mt++){var Ft=O.clippingMaskDrawIndexList[Mt],Nt=l.getDrawData(Ft),Lt=l._$C2(Ft);w.setClipBufPre_clipContextForMask(O),Nt.draw(w,l,Lt)}}w.gl.bindFramebuffer(w.gl.FRAMEBUFFER,N),w.setClipBufPre_clipContextForMask(null),w.gl.viewport(e[0],e[1],e[2],e[3])}},t.prototype.getColorBuffer=function(){return this.colorBuffer},t.prototype.findSameClip=function(l){for(var w=0;w<this.clipContextList.length;w++){var M=this.clipContextList[w],L=M.clipIDList.length;if(L==l.length){for(var O=0,N=0;N<L;N++)for(var e=M.clipIDList[N],H=0;H<L;H++)if(l[H]==e){O++;break}if(O==L)return M}}return null},t.prototype.calcClippedDrawTotalBounds=function(l,w){for(var M=l._$Ri.getModelImpl().getCanvasWidth(),L=l._$Ri.getModelImpl().getCanvasHeight(),O=M>L?M:L,N=O,e=O,H=0,W=0,rt=w.clippedDrawContextList.length,R=0;R<rt;R++){var ct=w.clippedDrawContextList[R],j=ct.drawDataIndex,v=l._$C2(j);if(v._$yo()){for(var St=v.getTransformedPoints(),yt=St.length,Mt=[],Ft=[],Nt=0,Lt=ot._$i2;Lt<yt;Lt+=ot._$No)Mt[Nt]=St[Lt],Ft[Nt]=St[Lt+1],Nt++;var re=Math.min.apply(null,Mt),Zt=Math.min.apply(null,Ft),K=Math.max.apply(null,Mt),Vt=Math.max.apply(null,Ft);re<N&&(N=re),Zt<e&&(e=Zt),K>H&&(H=K),Vt>W&&(W=Vt)}}if(N==O)w.allClippedDrawRect.x=0,w.allClippedDrawRect.y=0,w.allClippedDrawRect.width=0,w.allClippedDrawRect.height=0,w.isUsing=!1;else{var jt=H-N,vt=W-e;w.allClippedDrawRect.x=N,w.allClippedDrawRect.y=e,w.allClippedDrawRect.width=jt,w.allClippedDrawRect.height=vt,w.isUsing=!0}},t.prototype.setupLayoutBounds=function(l){var w=l/t.CHANNEL_COUNT,M=l%t.CHANNEL_COUNT;w=~~w,M=~~M;for(var L=0,O=0;O<t.CHANNEL_COUNT;O++){var N=w+(O<M?1:0);if(N!=0)if(N==1){var e=this.clipContextList[L++];e.layoutChannelNo=O,e.layoutBounds.x=0,e.layoutBounds.y=0,e.layoutBounds.width=1,e.layoutBounds.height=1}else if(N==2)for(var H=0;H<N;H++){var W=H%2,rt=0;W=~~W;var e=this.clipContextList[L++];e.layoutChannelNo=O,e.layoutBounds.x=W*.5,e.layoutBounds.y=0,e.layoutBounds.width=.5,e.layoutBounds.height=1}else if(N<=4)for(var H=0;H<N;H++){var W=H%2,rt=H/2;W=~~W,rt=~~rt;var e=this.clipContextList[L++];e.layoutChannelNo=O,e.layoutBounds.x=W*.5,e.layoutBounds.y=rt*.5,e.layoutBounds.width=.5,e.layoutBounds.height=.5}else if(N<=9)for(var H=0;H<N;H++){var W=H%3,rt=H/3;W=~~W,rt=~~rt;var e=this.clipContextList[L++];e.layoutChannelNo=O,e.layoutBounds.x=W/3,e.layoutBounds.y=rt/3,e.layoutBounds.width=1/3,e.layoutBounds.height=1/3}else h._$li("_$6 _$0P mask count : %d",N)}};function r(l,w,M){this.clipIDList=new Array,this.clipIDList=M,this.clippingMaskDrawIndexList=new Array;for(var L=0;L<M.length;L++)this.clippingMaskDrawIndexList.push(w.getDrawDataIndex(M[L]));this.clippedDrawContextList=new Array,this.isUsing=!0,this.layoutChannelNo=0,this.layoutBounds=new Q,this.allClippedDrawRect=new Q,this.matrixForMask=new Float32Array(16),this.matrixForDraw=new Float32Array(16),this.owner=l}r.prototype.addClippedDrawData=function(l,w){var M=new i(l,w);this.clippedDrawContextList.push(M)};function i(l,w){this._$gP=l,this.drawDataIndex=w}function n(){Xt||(this.color=null)}function o(){Xt||(this._$dP=null,this._$eo=null,this._$V0=null,this._$dP=1e3,this._$eo=1e3,this._$V0=1,this._$a0())}o._$JT=function(l,w,M){var L=l/w,O=M/w,N=O,e=1/3,H=2/3,W=1-(1-O)*(1-O),rt=1-(1-N)*(1-N),R=0,ct=(1-O)*e*W+(N*H+(1-N)*e)*(1-W),j=(N+(1-N)*H)*rt+(O*e+(1-O)*H)*(1-rt),v=1,St=v-3*j+3*ct-R,yt=3*j-6*ct+3*R,Mt=3*ct-3*R,Ft=R;if(L<=0)return 0;if(L>=1)return 1;var Nt=L,Lt=Nt*Nt,re=Nt*Lt,Zt=St*re+yt*Lt+Mt*Nt+Ft;return Zt},o.prototype._$a0=function(){},o.prototype.setFadeIn=function(l){this._$dP=l},o.prototype.setFadeOut=function(l){this._$eo=l},o.prototype._$pT=function(l){this._$V0=l},o.prototype.getFadeOut=function(){return this._$eo},o.prototype._$4T=function(){return this._$eo},o.prototype._$mT=function(){return this._$V0},o.prototype.getDurationMSec=function(){return-1},o.prototype.getLoopDurationMSec=function(){return-1},o.prototype.updateParam=function(l,w){if(!(!w._$AT||w._$9L)){var M=pt.getUserTimeMSec();if(w._$z2<0){w._$z2=M,w._$bs=M;var L=this.getDurationMSec();w._$Do<0&&(w._$Do=L<=0?-1:w._$z2+L)}var O=this._$V0,N=this._$dP==0?1:wr._$r2((M-w._$bs)/this._$dP),e=this._$eo==0||w._$Do<0?1:wr._$r2((w._$Do-M)/this._$eo);O=O*N*e,0<=O&&O<=1||console.log("### assert!! ### "),this.updateParamExe(l,M,O,w),w._$Do>0&&w._$Do<M&&(w._$9L=!0)}},o.prototype.updateParamExe=function(l,w,M,L){};function h(){}h._$8s=0,h._$fT=new Object,h.start=function(l){var w=h._$fT[l];w==null&&(w=new c,w._$r=l,h._$fT[l]=w),w._$0S=pt.getSystemTimeMSec()},h.dump=function(l){var w=h._$fT[l];if(w!=null){var M=pt.getSystemTimeMSec(),L=M-w._$0S;return console.log(l+" : "+L+"ms"),L}else return-1},h.end=function(l){var w=h._$fT[l];if(w!=null){var M=pt.getSystemTimeMSec();return M-w._$0S}else return-1},h._$li=function(l,w){console.log("_$li : "+l+`
4
- `,w)},h._$Ji=function(l,w){console.log(l,w)},h._$dL=function(l,w){console.log(l,w),console.log(`
5
- `)},h._$KL=function(l,w){for(var M=0;M<w;M++)M%16==0&&M>0?console.log(`
6
- `):M%8==0&&M>0&&console.log(" "),console.log("%02X ",l[M]&255);console.log(`
7
- `)},h._$nr=function(l,w,M){console.log(`%s
8
- `,l);for(var L=w.length,O=0;O<L;++O)console.log("%5d",w[O]),console.log(`%s
9
- `,M),console.log(",");console.log(`
10
- `)},h._$Rb=function(l){console.log("dump exception : "+l),console.log("stack :: "+l.stack)};function c(){this._$r=null,this._$0S=null}function b(){Xt||(this.x=null,this.y=null,this.width=null,this.height=null)}b.prototype._$8P=function(){return .5*(this.x+this.x+this.width)},b.prototype._$6P=function(){return .5*(this.y+this.y+this.height)},b.prototype._$EL=function(){return this.x+this.width},b.prototype._$5T=function(){return this.y+this.height},b.prototype._$jL=function(l,w,M,L){this.x=l,this.y=w,this.width=M,this.height=L},b.prototype._$jL=function(l){this.x=l.x,this.y=l.y,this.width=l.width,this.height=l.height};function T(l){Xt||xr.prototype.constructor.call(this,l)}T.prototype=new xr,T._$tP=new Object,T._$27=function(){T._$tP.clear()},T.getID=function(l){var w=T._$tP[l];return w==null&&(w=new T(l),T._$tP[l]=w),w},T.prototype._$3s=function(){return new T};function C(){}function x(l){Xt||xr.prototype.constructor.call(this,l)}x.prototype=new xr,x._$tP=new Object,x._$27=function(){x._$tP.clear()},x.getID=function(l){var w=x._$tP[l];return w==null&&(w=new x(l),x._$tP[l]=w),w},x.prototype._$3s=function(){return new x};function $(){Xt||(this._$vo=null,this._$F2=null,this._$ao=400,this._$1S=400,$._$42++)}$._$42=0,$.prototype._$zP=function(){this._$vo==null&&(this._$vo=new Fi),this._$F2==null&&(this._$F2=new Array)},$.prototype.getCanvasWidth=function(){return this._$ao},$.prototype.getCanvasHeight=function(){return this._$1S},$.prototype._$F0=function(l){this._$vo=l._$nP(),this._$F2=l._$nP(),this._$ao=l._$6L(),this._$1S=l._$6L()},$.prototype._$6S=function(l){this._$F2.push(l)},$.prototype._$Xr=function(){return this._$F2},$.prototype._$E2=function(){return this._$vo};function I(){Xt||(this.p1=new B,this.p2=new B,this._$Fo=0,this._$Db=0,this._$L2=0,this._$M2=0,this._$ks=0,this._$9b=0,this._$iP=0,this._$iT=0,this._$lL=new Array,this._$qP=new Array,this.setup(.3,.5,.1))}I.prototype.setup=function(l,w,M){this._$ks=this._$Yb(),this.p2._$xT(),arguments.length==3&&(this._$Fo=l,this._$L2=w,this.p1._$p=M,this.p2._$p=M,this.p2.y=l,this.setup())},I.prototype.getPhysicsPoint1=function(){return this.p1},I.prototype.getPhysicsPoint2=function(){return this.p2},I.prototype._$qr=function(){return this._$Db},I.prototype._$pr=function(l){this._$Db=l},I.prototype._$5r=function(){return this._$M2},I.prototype._$Cs=function(){return this._$9b},I.prototype._$Yb=function(){return-180*Math.atan2(this.p1.x-this.p2.x,-(this.p1.y-this.p2.y))/Math.PI},I.prototype.addSrcParam=function(l,w,M,L){var O=new G(l,w,M,L);this._$lL.push(O)},I.prototype.addTargetParam=function(l,w,M,L){var O=new J(l,w,M,L);this._$qP.push(O)},I.prototype.update=function(l,w){if(this._$iP==0){this._$iP=this._$iT=w,this._$Fo=Math.sqrt((this.p1.x-this.p2.x)*(this.p1.x-this.p2.x)+(this.p1.y-this.p2.y)*(this.p1.y-this.p2.y));return}var M=(w-this._$iT)/1e3;if(M!=0){for(var L=this._$lL.length-1;L>=0;--L){var O=this._$lL[L];O._$oP(l,this)}this._$oo(l,M),this._$M2=this._$Yb(),this._$9b=(this._$M2-this._$ks)/M,this._$ks=this._$M2}for(var L=this._$qP.length-1;L>=0;--L){var N=this._$qP[L];N._$YS(l,this)}this._$iT=w},I.prototype._$oo=function(l,w){w<.033&&(w=.033);var M=1/w;this.p1.vx=(this.p1.x-this.p1._$s0)*M,this.p1.vy=(this.p1.y-this.p1._$70)*M,this.p1.ax=(this.p1.vx-this.p1._$7L)*M,this.p1.ay=(this.p1.vy-this.p1._$HL)*M,this.p1.fx=this.p1.ax*this.p1._$p,this.p1.fy=this.p1.ay*this.p1._$p,this.p1._$xT();var L=-Math.atan2(this.p1.y-this.p2.y,this.p1.x-this.p2.x),O,N,e=Math.cos(L),H=Math.sin(L),W=9.8*this.p2._$p,rt=this._$Db*Xe._$bS,R=W*Math.cos(L-rt);O=R*H,N=R*e;var ct=-this.p1.fx*H*H,j=-this.p1.fy*H*e,v=-this.p2.vx*this._$L2,St=-this.p2.vy*this._$L2;this.p2.fx=O+ct+v,this.p2.fy=N+j+St,this.p2.ax=this.p2.fx/this.p2._$p,this.p2.ay=this.p2.fy/this.p2._$p,this.p2.vx+=this.p2.ax*w,this.p2.vy+=this.p2.ay*w,this.p2.x+=this.p2.vx*w,this.p2.y+=this.p2.vy*w;var yt=Math.sqrt((this.p1.x-this.p2.x)*(this.p1.x-this.p2.x)+(this.p1.y-this.p2.y)*(this.p1.y-this.p2.y));this.p2.x=this.p1.x+this._$Fo*(this.p2.x-this.p1.x)/yt,this.p2.y=this.p1.y+this._$Fo*(this.p2.y-this.p1.y)/yt,this.p2.vx=(this.p2.x-this.p2._$s0)*M,this.p2.vy=(this.p2.y-this.p2._$70)*M,this.p2._$xT()};function B(){this._$p=1,this.x=0,this.y=0,this.vx=0,this.vy=0,this.ax=0,this.ay=0,this.fx=0,this.fy=0,this._$s0=0,this._$70=0,this._$7L=0,this._$HL=0}B.prototype._$xT=function(){this._$s0=this.x,this._$70=this.y,this._$7L=this.vx,this._$HL=this.vy};function U(l,w,M){this._$wL=null,this.scale=null,this._$V0=null,this._$wL=l,this.scale=w,this._$V0=M}U.prototype._$oP=function(l,w){};function G(l,w,M,L){U.prototype.constructor.call(this,w,M,L),this._$tL=null,this._$tL=l}G.prototype=new U,G.prototype._$oP=function(l,w){var M=this.scale*l.getParamFloat(this._$wL),L=w.getPhysicsPoint1();switch(this._$tL){default:case I.Src.SRC_TO_X:L.x=L.x+(M-L.x)*this._$V0;break;case I.Src.SRC_TO_Y:L.y=L.y+(M-L.y)*this._$V0;break;case I.Src.SRC_TO_G_ANGLE:var O=w._$qr();O=O+(M-O)*this._$V0,w._$pr(O);break}};function z(l,w,M){this._$wL=null,this.scale=null,this._$V0=null,this._$wL=l,this.scale=w,this._$V0=M}z.prototype._$YS=function(l,w){};function J(l,w,M,L){z.prototype.constructor.call(this,w,M,L),this._$YP=null,this._$YP=l}J.prototype=new z,J.prototype._$YS=function(l,w){switch(this._$YP){default:case I.Target.TARGET_FROM_ANGLE:l.setParamFloat(this._$wL,this.scale*w._$5r(),this._$V0);break;case I.Target.TARGET_FROM_ANGLE_V:l.setParamFloat(this._$wL,this.scale*w._$Cs(),this._$V0);break}},I.Src=function(){},I.Src.SRC_TO_X="SRC_TO_X",I.Src.SRC_TO_Y="SRC_TO_Y",I.Src.SRC_TO_G_ANGLE="SRC_TO_G_ANGLE",I.Target=function(){},I.Target.TARGET_FROM_ANGLE="TARGET_FROM_ANGLE",I.Target.TARGET_FROM_ANGLE_V="TARGET_FROM_ANGLE_V";function Z(){Xt||(this._$fL=0,this._$gL=0,this._$B0=1,this._$z0=1,this._$qT=0,this.reflectX=!1,this.reflectY=!1)}Z.prototype.init=function(l){this._$fL=l._$fL,this._$gL=l._$gL,this._$B0=l._$B0,this._$z0=l._$z0,this._$qT=l._$qT,this.reflectX=l.reflectX,this.reflectY=l.reflectY},Z.prototype._$F0=function(l){this._$fL=l._$_T(),this._$gL=l._$_T(),this._$B0=l._$_T(),this._$z0=l._$_T(),this._$qT=l._$_T(),l.getFormatVersion()>=ht.LIVE2D_FORMAT_VERSION_V2_10_SDK2&&(this.reflectX=l._$po(),this.reflectY=l._$po())},Z.prototype._$e=function(){};var it=function(){};it._$ni=function(l,w,M,L,O,N,e,H,W){var rt=e*N-H*O;if(rt==0)return null;var R=((l-M)*N-(w-L)*O)/rt,ct;return O!=0?ct=(l-M-R*e)/O:ct=(w-L-R*H)/N,isNaN(ct)&&(ct=(l-M-R*e)/O,isNaN(ct)&&(ct=(w-L-R*H)/N),isNaN(ct)&&(console.log("a is NaN @UtVector#_$ni() "),console.log("v1x : "+O),console.log("v1x != 0 ? "+(O!=0)))),W==null?new Array(ct,R):(W[0]=ct,W[1]=R,W)};function Q(){Xt||(this.x=null,this.y=null,this.width=null,this.height=null)}Q.prototype._$8P=function(){return this.x+.5*this.width},Q.prototype._$6P=function(){return this.y+.5*this.height},Q.prototype._$EL=function(){return this.x+this.width},Q.prototype._$5T=function(){return this.y+this.height},Q.prototype._$jL=function(l,w,M,L){this.x=l,this.y=w,this.width=M,this.height=L},Q.prototype._$jL=function(l){this.x=l.x,this.y=l.y,this.width=l.width,this.height=l.height},Q.prototype.contains=function(l,w){return this.x<=this.x&&this.y<=this.y&&this.x<=this.x+this.width&&this.y<=this.y+this.height},Q.prototype.expand=function(l,w){this.x-=l,this.y-=w,this.width+=l*2,this.height+=w*2};function _t(){}_t._$Z2=function(l,w,M,L){var O=w._$Q2(l,M),N=l._$vs(),e=l._$Tr();if(w._$zr(N,e,O),O<=0)return L[N[0]];if(O==1){var H=L[N[0]],W=L[N[1]],rt=e[0];return H+(W-H)*rt|0}else if(O==2){var H=L[N[0]],W=L[N[1]],R=L[N[2]],ct=L[N[3]],rt=e[0],j=e[1],v=H+(W-H)*rt|0,St=R+(ct-R)*rt|0;return v+(St-v)*j|0}else if(O==3){var yt=L[N[0]],Mt=L[N[1]],Ft=L[N[2]],Nt=L[N[3]],Lt=L[N[4]],re=L[N[5]],Zt=L[N[6]],K=L[N[7]],rt=e[0],j=e[1],Vt=e[2],H=yt+(Mt-yt)*rt|0,W=Ft+(Nt-Ft)*rt|0,R=Lt+(re-Lt)*rt|0,ct=Zt+(K-Zt)*rt|0,v=H+(W-H)*j|0,St=R+(ct-R)*j|0;return v+(St-v)*Vt|0}else if(O==4){var jt=L[N[0]],vt=L[N[1]],Ut=L[N[2]],Fe=L[N[3]],We=L[N[4]],ge=L[N[5]],me=L[N[6]],ve=L[N[7]],Ce=L[N[8]],Ee=L[N[9]],Me=L[N[10]],ee=L[N[11]],ye=L[N[12]],ie=L[N[13]],he=L[N[14]],ke=L[N[15]],rt=e[0],j=e[1],Vt=e[2],lr=e[3],yt=jt+(vt-jt)*rt|0,Mt=Ut+(Fe-Ut)*rt|0,Ft=We+(ge-We)*rt|0,Nt=me+(ve-me)*rt|0,Lt=Ce+(Ee-Ce)*rt|0,re=Me+(ee-Me)*rt|0,Zt=ye+(ie-ye)*rt|0,K=he+(ke-he)*rt|0,H=yt+(Mt-yt)*j|0,W=Ft+(Nt-Ft)*j|0,R=Lt+(re-Lt)*j|0,ct=Zt+(K-Zt)*j|0,v=H+(W-H)*Vt|0,St=R+(ct-R)*Vt|0;return v+(St-v)*lr|0}else{for(var qe=1<<O,Le=new Float32Array(qe),ir=0;ir<qe;ir++){for(var Ze=ir,gr=1,Je=0;Je<O;Je++)gr*=Ze%2==0?1-e[Je]:e[Je],Ze/=2;Le[ir]=gr}for(var mr=new Float32Array(qe),ur=0;ur<qe;ur++)mr[ur]=L[N[ur]];for(var kr=0,ur=0;ur<qe;ur++)kr+=Le[ur]*mr[ur];return kr+.5|0}},_t._$br=function(l,w,M,L){var O=w._$Q2(l,M),N=l._$vs(),e=l._$Tr();if(w._$zr(N,e,O),O<=0)return L[N[0]];if(O==1){var H=L[N[0]],W=L[N[1]],rt=e[0];return H+(W-H)*rt}else if(O==2){var H=L[N[0]],W=L[N[1]],R=L[N[2]],ct=L[N[3]],rt=e[0],j=e[1];return(1-j)*(H+(W-H)*rt)+j*(R+(ct-R)*rt)}else if(O==3){var v=L[N[0]],St=L[N[1]],yt=L[N[2]],Mt=L[N[3]],Ft=L[N[4]],Nt=L[N[5]],Lt=L[N[6]],re=L[N[7]],rt=e[0],j=e[1],Zt=e[2];return(1-Zt)*((1-j)*(v+(St-v)*rt)+j*(yt+(Mt-yt)*rt))+Zt*((1-j)*(Ft+(Nt-Ft)*rt)+j*(Lt+(re-Lt)*rt))}else if(O==4){var K=L[N[0]],Vt=L[N[1]],jt=L[N[2]],vt=L[N[3]],Ut=L[N[4]],Fe=L[N[5]],We=L[N[6]],ge=L[N[7]],me=L[N[8]],ve=L[N[9]],Ce=L[N[10]],Ee=L[N[11]],Me=L[N[12]],ee=L[N[13]],ye=L[N[14]],ie=L[N[15]],rt=e[0],j=e[1],Zt=e[2],he=e[3];return(1-he)*((1-Zt)*((1-j)*(K+(Vt-K)*rt)+j*(jt+(vt-jt)*rt))+Zt*((1-j)*(Ut+(Fe-Ut)*rt)+j*(We+(ge-We)*rt)))+he*((1-Zt)*((1-j)*(me+(ve-me)*rt)+j*(Ce+(Ee-Ce)*rt))+Zt*((1-j)*(Me+(ee-Me)*rt)+j*(ye+(ie-ye)*rt)))}else{for(var ke=1<<O,lr=new Float32Array(ke),qe=0;qe<ke;qe++){for(var Le=qe,ir=1,Ze=0;Ze<O;Ze++)ir*=Le%2==0?1-e[Ze]:e[Ze],Le/=2;lr[qe]=ir}for(var gr=new Float32Array(ke),Je=0;Je<ke;Je++)gr[Je]=L[N[Je]];for(var mr=0,Je=0;Je<ke;Je++)mr+=lr[Je]*gr[Je];return mr}},_t._$Vr=function(l,w,M,L,O,N,e,H){var W=w._$Q2(l,M),rt=l._$vs(),R=l._$Tr();w._$zr(rt,R,W);var ct=L*2,j=e;if(W<=0){var v=rt[0],St=O[v];if(H==2&&e==0)pt._$jT(St,0,N,0,ct);else for(var yt=0;yt<ct;)N[j]=St[yt++],N[j+1]=St[yt++],j+=H}else if(W==1)for(var St=O[rt[0]],Mt=O[rt[1]],Ft=R[0],Nt=1-Ft,yt=0;yt<ct;)N[j]=St[yt]*Nt+Mt[yt]*Ft,++yt,N[j+1]=St[yt]*Nt+Mt[yt]*Ft,++yt,j+=H;else if(W==2)for(var St=O[rt[0]],Mt=O[rt[1]],Lt=O[rt[2]],re=O[rt[3]],Ft=R[0],Zt=R[1],Nt=1-Ft,K=1-Zt,Vt=K*Nt,jt=K*Ft,vt=Zt*Nt,Ut=Zt*Ft,yt=0;yt<ct;)N[j]=Vt*St[yt]+jt*Mt[yt]+vt*Lt[yt]+Ut*re[yt],++yt,N[j+1]=Vt*St[yt]+jt*Mt[yt]+vt*Lt[yt]+Ut*re[yt],++yt,j+=H;else if(W==3)for(var Fe=O[rt[0]],We=O[rt[1]],ge=O[rt[2]],me=O[rt[3]],ve=O[rt[4]],Ce=O[rt[5]],Ee=O[rt[6]],Me=O[rt[7]],Ft=R[0],Zt=R[1],ee=R[2],Nt=1-Ft,K=1-Zt,ye=1-ee,ie=ye*K*Nt,he=ye*K*Ft,ke=ye*Zt*Nt,lr=ye*Zt*Ft,qe=ee*K*Nt,Le=ee*K*Ft,ir=ee*Zt*Nt,Ze=ee*Zt*Ft,yt=0;yt<ct;)N[j]=ie*Fe[yt]+he*We[yt]+ke*ge[yt]+lr*me[yt]+qe*ve[yt]+Le*Ce[yt]+ir*Ee[yt]+Ze*Me[yt],++yt,N[j+1]=ie*Fe[yt]+he*We[yt]+ke*ge[yt]+lr*me[yt]+qe*ve[yt]+Le*Ce[yt]+ir*Ee[yt]+Ze*Me[yt],++yt,j+=H;else if(W==4)for(var gr=O[rt[0]],Je=O[rt[1]],mr=O[rt[2]],ur=O[rt[3]],kr=O[rt[4]],hi=O[rt[5]],Yr=O[rt[6]],jr=O[rt[7]],cr=O[rt[8]],es=O[rt[9]],rs=O[rt[10]],Kr=O[rt[11]],ki=O[rt[12]],li=O[rt[13]],Qe=O[rt[14]],vo=O[rt[15]],Ft=R[0],Zt=R[1],ee=R[2],vi=R[3],Nt=1-Ft,K=1-Zt,ye=1-ee,Bi=1-vi,xo=Bi*ye*K*Nt,bo=Bi*ye*K*Ft,Ao=Bi*ye*Zt*Nt,wo=Bi*ye*Zt*Ft,To=Bi*ee*K*Nt,Eo=Bi*ee*K*Ft,Co=Bi*ee*Zt*Nt,Rs=Bi*ee*Zt*Ft,So=vi*ye*K*Nt,Po=vi*ye*K*Ft,Br=vi*ye*Zt*Nt,$o=vi*ye*Zt*Ft,a=vi*ee*K*Nt,p=vi*ee*K*Ft,P=vi*ee*Zt*Nt,_=vi*ee*Zt*Ft,yt=0;yt<ct;)N[j]=xo*gr[yt]+bo*Je[yt]+Ao*mr[yt]+wo*ur[yt]+To*kr[yt]+Eo*hi[yt]+Co*Yr[yt]+Rs*jr[yt]+So*cr[yt]+Po*es[yt]+Br*rs[yt]+$o*Kr[yt]+a*ki[yt]+p*li[yt]+P*Qe[yt]+_*vo[yt],++yt,N[j+1]=xo*gr[yt]+bo*Je[yt]+Ao*mr[yt]+wo*ur[yt]+To*kr[yt]+Eo*hi[yt]+Co*Yr[yt]+Rs*jr[yt]+So*cr[yt]+Po*es[yt]+Br*rs[yt]+$o*Kr[yt]+a*ki[yt]+p*li[yt]+P*Qe[yt]+_*vo[yt],++yt,j+=H;else{for(var f=1<<W,E=new Float32Array(f),u=0;u<f;u++){for(var d=u,g=1,y=0;y<W;y++)g*=d%2==0?1-R[y]:R[y],d/=2;E[u]=g}for(var A=new Float32Array(f),S=0;S<f;S++)A[S]=O[rt[S]];for(var yt=0;yt<ct;){for(var D=0,F=0,k=yt+1,S=0;S<f;S++)D+=E[S]*A[S][yt],F+=E[S]*A[S][k];yt+=2,N[j]=D,N[j+1]=F,j+=H}}};function et(){Xt||(this.x=null,this.y=null)}et.prototype._$HT=function(l,w){this.x=l,this.y=w},et.prototype._$HT=function(l){this.x=l.x,this.y=l.y};function ft(){Xt||(this._$gP=null,this._$dr=null,this._$GS=null,this._$qb=null,this._$Lb=null,this._$mS=null,this.clipID=null,this.clipIDList=new Array)}ft._$ur=-2,ft._$ES=500,ft._$wb=2,ft._$8S=3,ft._$52=ft._$ES,ft._$R2=ft._$ES,ft._$or=function(){return ft._$52},ft._$Pr=function(){return ft._$R2},ft.prototype.convertClipIDForV2_11=function(l){var w=[];return l==null||l.length==0?null:/,/.test(l)?(w=l.id.split(","),w):(w.push(l.id),w)},ft.prototype._$F0=function(l){this._$gP=l._$nP(),this._$dr=l._$nP(),this._$GS=l._$nP(),this._$qb=l._$6L(),this._$Lb=l._$cS(),this._$mS=l._$Tb(),l.getFormatVersion()>=ht._$T7?(this.clipID=l._$nP(),this.clipIDList=this.convertClipIDForV2_11(this.clipID)):this.clipIDList=[],this._$MS(this._$Lb)},ft.prototype.getClipIDList=function(){return this.clipIDList},ft.prototype.init=function(l){},ft.prototype._$Nr=function(l,w){if(w._$IS[0]=!1,w._$Us=_t._$Z2(l,this._$GS,w._$IS,this._$Lb),!Pt._$Zs){if(w._$IS[0])return}w._$7s=_t._$br(l,this._$GS,w._$IS,this._$mS)},ft.prototype._$2b=function(l,w){},ft.prototype.getDrawDataID=function(){return this._$gP},ft.prototype._$j2=function(l){this._$gP=l},ft.prototype.getOpacity=function(l,w){return w._$7s},ft.prototype._$zS=function(l,w){return w._$Us},ft.prototype._$MS=function(l){for(var w=l.length-1;w>=0;--w){var M=l[w];M<ft._$52?ft._$52=M:M>ft._$R2&&(ft._$R2=M)}},ft.prototype.getTargetBaseDataID=function(){return this._$dr},ft.prototype._$gs=function(l){this._$dr=l},ft.prototype._$32=function(){return this._$dr!=null&&this._$dr!=at._$2o()},ft.prototype.preDraw=function(l,w,M){},ft.prototype.draw=function(l,w,M){},ft.prototype.getType=function(){},ft.prototype._$B2=function(l,w,M){};function wt(){Xt||(this._$Eb=wt._$ps,this._$lT=1,this._$C0=1,this._$tT=1,this._$WL=1,this.culling=!1,this.matrix4x4=new Float32Array(16),this.premultipliedAlpha=!1,this.anisotropy=0,this.clippingProcess=wt.CLIPPING_PROCESS_NONE,this.clipBufPre_clipContextMask=null,this.clipBufPre_clipContextDraw=null,this.CHANNEL_COLORS=new Array)}wt._$ps=32,wt.CLIPPING_PROCESS_NONE=0,wt.CLIPPING_PROCESS_OVERWRITE_ALPHA=1,wt.CLIPPING_PROCESS_MULTIPLY_ALPHA=2,wt.CLIPPING_PROCESS_DRAW=3,wt.CLIPPING_PROCESS_CLEAR_ALPHA=4,wt.prototype.setChannelFlagAsColor=function(l,w){this.CHANNEL_COLORS[l]=w},wt.prototype.getChannelFlagAsColor=function(l){return this.CHANNEL_COLORS[l]},wt.prototype._$ZT=function(){},wt.prototype._$Uo=function(l,w,M,L,O,N,e){},wt.prototype._$Rs=function(){return-1},wt.prototype._$Ds=function(l){},wt.prototype.setBaseColor=function(l,w,M,L){l<0?l=0:l>1&&(l=1),w<0?w=0:w>1&&(w=1),M<0?M=0:M>1&&(M=1),L<0?L=0:L>1&&(L=1),this._$lT=l,this._$C0=w,this._$tT=M,this._$WL=L},wt.prototype._$WP=function(l){this.culling=l},wt.prototype.setMatrix=function(l){for(var w=0;w<16;w++)this.matrix4x4[w]=l[w]},wt.prototype._$IT=function(){return this.matrix4x4},wt.prototype.setPremultipliedAlpha=function(l){this.premultipliedAlpha=l},wt.prototype.isPremultipliedAlpha=function(){return this.premultipliedAlpha},wt.prototype.setAnisotropy=function(l){this.anisotropy=l},wt.prototype.getAnisotropy=function(){return this.anisotropy},wt.prototype.getClippingProcess=function(){return this.clippingProcess},wt.prototype.setClippingProcess=function(l){this.clippingProcess=l},wt.prototype.setClipBufPre_clipContextForMask=function(l){this.clipBufPre_clipContextMask=l},wt.prototype.getClipBufPre_clipContextMask=function(){return this.clipBufPre_clipContextMask},wt.prototype.setClipBufPre_clipContextForDraw=function(l){this.clipBufPre_clipContextDraw=l},wt.prototype.getClipBufPre_clipContextDraw=function(){return this.clipBufPre_clipContextDraw};function Dt(){Xt||(this.a=1,this.r=1,this.g=1,this.b=1,this.scale=1,this._$ho=1,this.blendMode=Pt.L2D_COLOR_BLEND_MODE_MULT)}function Rt(){Xt||(this._$kP=null,this._$dr=null,this._$Ai=!0,this._$mS=null)}Rt._$ur=-2,Rt._$c2=1,Rt._$_b=2,Rt.prototype._$F0=function(l){this._$kP=l._$nP(),this._$dr=l._$nP()},Rt.prototype.readV2_opacity=function(l){l.getFormatVersion()>=ht.LIVE2D_FORMAT_VERSION_V2_10_SDK2&&(this._$mS=l._$Tb())},Rt.prototype.init=function(l){},Rt.prototype._$Nr=function(l,w){},Rt.prototype.interpolateOpacity=function(l,w,M,L){this._$mS==null?M.setInterpolatedOpacity(1):M.setInterpolatedOpacity(_t._$br(l,w,L,this._$mS))},Rt.prototype._$2b=function(l,w){},Rt.prototype._$nb=function(l,w,M,L,O,N,e){},Rt.prototype.getType=function(){},Rt.prototype._$gs=function(l){this._$dr=l},Rt.prototype._$a2=function(l){this._$kP=l},Rt.prototype.getTargetBaseDataID=function(){return this._$dr},Rt.prototype.getBaseDataID=function(){return this._$kP},Rt.prototype._$32=function(){return this._$dr!=null&&this._$dr!=at._$2o()};function pt(){}pt._$W2=0,pt._$CS=pt._$W2,pt._$Mo=function(){return!0},pt._$XP=function(l){try{for(var w=getTimeMSec();getTimeMSec()-w<l;);}catch(M){M._$Rb()}},pt.getUserTimeMSec=function(){return pt._$CS==pt._$W2?pt.getSystemTimeMSec():pt._$CS},pt.setUserTimeMSec=function(l){pt._$CS=l},pt.updateUserTimeMSec=function(){return pt._$CS=pt.getSystemTimeMSec()},pt.getTimeMSec=function(){return new Date().getTime()},pt.getSystemTimeMSec=function(){return new Date().getTime()},pt._$Q=function(l){},pt._$jT=function(l,w,M,L,O){for(var N=0;N<O;N++)M[L+N]=l[w+N]};function xt(){Xt||(this._$VP=0,this._$wL=null,this._$GP=null,this._$8o=xt._$ds,this._$2r=-1,this._$O2=0,this._$ri=0)}xt._$ds=-2,xt.prototype._$F0=function(l){this._$wL=l._$nP(),this._$VP=l._$6L(),this._$GP=l._$nP()},xt.prototype.getParamIndex=function(l){return this._$2r!=l&&(this._$8o=xt._$ds),this._$8o},xt.prototype._$Pb=function(l,w){this._$8o=l,this._$2r=w},xt.prototype.getParamID=function(){return this._$wL},xt.prototype._$yP=function(l){this._$wL=l},xt.prototype._$N2=function(){return this._$VP},xt.prototype._$d2=function(){return this._$GP},xt.prototype._$t2=function(l,w){this._$VP=l,this._$GP=w},xt.prototype._$Lr=function(){return this._$O2},xt.prototype._$wr=function(l){this._$O2=l},xt.prototype._$SL=function(){return this._$ri},xt.prototype._$AL=function(l){this._$ri=l};function Ct(){}Ct.startsWith=function(l,w,M){var L=w+M.length;if(L>=l.length)return!1;for(var O=w;O<L;O++)if(Ct.getChar(l,O)!=M.charAt(O-w))return!1;return!0},Ct.getChar=function(l,w){return String.fromCharCode(l.getUint8(w))},Ct.createString=function(l,w,M){for(var L=new ArrayBuffer(M*2),O=new Uint16Array(L),N=0;N<M;N++)O[N]=l.getUint8(w+N);return String.fromCharCode.apply(null,O)},Ct._$LS=function(l,w,M,L){l instanceof ArrayBuffer&&(l=new DataView(l));var O=M,N=!1,e=!1,H=0,W=Ct.getChar(l,O);W=="-"&&(N=!0,O++);for(var rt=!1;O<w;O++){switch(W=Ct.getChar(l,O),W){case"0":H=H*10;break;case"1":H=H*10+1;break;case"2":H=H*10+2;break;case"3":H=H*10+3;break;case"4":H=H*10+4;break;case"5":H=H*10+5;break;case"6":H=H*10+6;break;case"7":H=H*10+7;break;case"8":H=H*10+8;break;case"9":H=H*10+9;break;case".":e=!0,O++,rt=!0;break;default:rt=!0;break}if(rt)break}if(e)for(var R=.1,ct=!1;O<w;O++){switch(W=Ct.getChar(l,O),W){case"0":break;case"1":H+=R*1;break;case"2":H+=R*2;break;case"3":H+=R*3;break;case"4":H+=R*4;break;case"5":H+=R*5;break;case"6":H+=R*6;break;case"7":H+=R*7;break;case"8":H+=R*8;break;case"9":H+=R*9;break;default:ct=!0;break}if(R*=.1,ct)break}return N&&(H=-H),L[0]=O,H};function Gt(){Xt||(this._$Ob=null)}Gt.prototype._$zP=function(){this._$Ob=new Array},Gt.prototype._$F0=function(l){this._$Ob=l._$nP()},Gt.prototype._$Ur=function(l){if(l._$WS())return!0;for(var w=l._$v2(),M=this._$Ob.length-1;M>=0;--M){var L=this._$Ob[M].getParamIndex(w);if(L==xt._$ds&&(L=l.getParamIndex(this._$Ob[M].getParamID())),l._$Xb(L))return!0}return!1},Gt.prototype._$Q2=function(l,w){for(var M=this._$Ob.length,L=l._$v2(),O=0,N,e,H=0;H<M;H++){var W=this._$Ob[H];if(N=W.getParamIndex(L),N==xt._$ds&&(N=l.getParamIndex(W.getParamID()),W._$Pb(N,L)),N<0)throw new Exception("err 23242 : "+W.getParamID());var rt=N<0?0:l.getParamFloat(N);e=W._$N2();var R=W._$d2(),ct=-1,j=0,v,St;if(!(e<1))if(e==1)v=R[0],v-ot._$J<rt&&rt<v+ot._$J?(ct=0,j=0):(ct=0,w[0]=!0);else if(v=R[0],rt<v-ot._$J)ct=0,w[0]=!0;else if(rt<v+ot._$J)ct=0;else{for(var yt=!1,Mt=1;Mt<e;++Mt){if(St=R[Mt],rt<St+ot._$J){St-ot._$J<rt?ct=Mt:(ct=Mt-1,j=(rt-v)/(St-v),O++),yt=!0;break}v=St}yt||(ct=e-1,j=0,w[0]=!0)}W._$wr(ct),W._$AL(j)}return O},Gt.prototype._$zr=function(l,w,M){var L=1<<M;L+1>ot._$Qb&&console.log(`err 23245
11
- `);for(var O=this._$Ob.length,N=1,e=1,H=0,W=0;W<L;++W)l[W]=0;for(var rt=0;rt<O;++rt){var R=this._$Ob[rt];if(R._$SL()==0){var ct=R._$Lr()*N;if(ct<0&&Pt._$3T)throw new Exception("err 23246");for(var W=0;W<L;++W)l[W]+=ct}else{for(var ct=N*R._$Lr(),j=N*(R._$Lr()+1),W=0;W<L;++W)l[W]+=(W/e|0)%2==0?ct:j;w[H++]=R._$SL(),e*=2}N*=R._$N2()}l[L]=65535,w[H]=-1},Gt.prototype._$h2=function(l,w,M){for(var L=new Float32Array(w),O=0;O<w;++O)L[O]=M[O];var N=new xt;N._$yP(l),N._$t2(w,L),this._$Ob.push(N)},Gt.prototype._$J2=function(l){for(var w=l,M=this._$Ob.length,L=0;L<M;++L){var O=this._$Ob[L],N=O._$N2(),e=w%O._$N2(),H=O._$d2()[e];console.log("%s[%d]=%7.2f / ",O.getParamID(),e,H),w/=N}console.log(`
12
- `)},Gt.prototype.getParamCount=function(){return this._$Ob.length},Gt.prototype._$zs=function(){return this._$Ob};function st(){this.m=new Float32Array(16),this.identity()}st.prototype.identity=function(){for(var l=0;l<16;l++)this.m[l]=l%5==0?1:0},st.prototype.getArray=function(){return this.m},st.prototype.getCopyMatrix=function(){return new Float32Array(this.m)},st.prototype.setMatrix=function(l){if(!(l==null||l.length!=16))for(var w=0;w<16;w++)this.m[w]=l[w]},st.prototype.mult=function(l,w,M){return w==null?null:(this==w?this.mult_safe(this.m,l.m,w.m,M):this.mult_fast(this.m,l.m,w.m,M),w)},st.prototype.mult_safe=function(l,w,M,L){if(l==M){var O=new Array(16);this.mult_fast(l,w,O,L);for(var N=15;N>=0;--N)M[N]=O[N]}else this.mult_fast(l,w,M,L)},st.prototype.mult_fast=function(l,w,M,L){L?(M[0]=l[0]*w[0]+l[4]*w[1]+l[8]*w[2],M[4]=l[0]*w[4]+l[4]*w[5]+l[8]*w[6],M[8]=l[0]*w[8]+l[4]*w[9]+l[8]*w[10],M[12]=l[0]*w[12]+l[4]*w[13]+l[8]*w[14]+l[12],M[1]=l[1]*w[0]+l[5]*w[1]+l[9]*w[2],M[5]=l[1]*w[4]+l[5]*w[5]+l[9]*w[6],M[9]=l[1]*w[8]+l[5]*w[9]+l[9]*w[10],M[13]=l[1]*w[12]+l[5]*w[13]+l[9]*w[14]+l[13],M[2]=l[2]*w[0]+l[6]*w[1]+l[10]*w[2],M[6]=l[2]*w[4]+l[6]*w[5]+l[10]*w[6],M[10]=l[2]*w[8]+l[6]*w[9]+l[10]*w[10],M[14]=l[2]*w[12]+l[6]*w[13]+l[10]*w[14]+l[14],M[3]=M[7]=M[11]=0,M[15]=1):(M[0]=l[0]*w[0]+l[4]*w[1]+l[8]*w[2]+l[12]*w[3],M[4]=l[0]*w[4]+l[4]*w[5]+l[8]*w[6]+l[12]*w[7],M[8]=l[0]*w[8]+l[4]*w[9]+l[8]*w[10]+l[12]*w[11],M[12]=l[0]*w[12]+l[4]*w[13]+l[8]*w[14]+l[12]*w[15],M[1]=l[1]*w[0]+l[5]*w[1]+l[9]*w[2]+l[13]*w[3],M[5]=l[1]*w[4]+l[5]*w[5]+l[9]*w[6]+l[13]*w[7],M[9]=l[1]*w[8]+l[5]*w[9]+l[9]*w[10]+l[13]*w[11],M[13]=l[1]*w[12]+l[5]*w[13]+l[9]*w[14]+l[13]*w[15],M[2]=l[2]*w[0]+l[6]*w[1]+l[10]*w[2]+l[14]*w[3],M[6]=l[2]*w[4]+l[6]*w[5]+l[10]*w[6]+l[14]*w[7],M[10]=l[2]*w[8]+l[6]*w[9]+l[10]*w[10]+l[14]*w[11],M[14]=l[2]*w[12]+l[6]*w[13]+l[10]*w[14]+l[14]*w[15],M[3]=l[3]*w[0]+l[7]*w[1]+l[11]*w[2]+l[15]*w[3],M[7]=l[3]*w[4]+l[7]*w[5]+l[11]*w[6]+l[15]*w[7],M[11]=l[3]*w[8]+l[7]*w[9]+l[11]*w[10]+l[15]*w[11],M[15]=l[3]*w[12]+l[7]*w[13]+l[11]*w[14]+l[15]*w[15])},st.prototype.translate=function(l,w,M){this.m[12]=this.m[0]*l+this.m[4]*w+this.m[8]*M+this.m[12],this.m[13]=this.m[1]*l+this.m[5]*w+this.m[9]*M+this.m[13],this.m[14]=this.m[2]*l+this.m[6]*w+this.m[10]*M+this.m[14],this.m[15]=this.m[3]*l+this.m[7]*w+this.m[11]*M+this.m[15]},st.prototype.scale=function(l,w,M){this.m[0]*=l,this.m[4]*=w,this.m[8]*=M,this.m[1]*=l,this.m[5]*=w,this.m[9]*=M,this.m[2]*=l,this.m[6]*=w,this.m[10]*=M,this.m[3]*=l,this.m[7]*=w,this.m[11]*=M},st.prototype.rotateX=function(l){var w=Xe.fcos(l),M=Xe._$9(l),L=this.m[4];this.m[4]=L*w+this.m[8]*M,this.m[8]=L*-M+this.m[8]*w,L=this.m[5],this.m[5]=L*w+this.m[9]*M,this.m[9]=L*-M+this.m[9]*w,L=this.m[6],this.m[6]=L*w+this.m[10]*M,this.m[10]=L*-M+this.m[10]*w,L=this.m[7],this.m[7]=L*w+this.m[11]*M,this.m[11]=L*-M+this.m[11]*w},st.prototype.rotateY=function(l){var w=Xe.fcos(l),M=Xe._$9(l),L=this.m[0];this.m[0]=L*w+this.m[8]*-M,this.m[8]=L*M+this.m[8]*w,L=this.m[1],this.m[1]=L*w+this.m[9]*-M,this.m[9]=L*M+this.m[9]*w,L=m[2],this.m[2]=L*w+this.m[10]*-M,this.m[10]=L*M+this.m[10]*w,L=m[3],this.m[3]=L*w+this.m[11]*-M,this.m[11]=L*M+this.m[11]*w},st.prototype.rotateZ=function(l){var w=Xe.fcos(l),M=Xe._$9(l),L=this.m[0];this.m[0]=L*w+this.m[4]*M,this.m[4]=L*-M+this.m[4]*w,L=this.m[1],this.m[1]=L*w+this.m[5]*M,this.m[5]=L*-M+this.m[5]*w,L=this.m[2],this.m[2]=L*w+this.m[6]*M,this.m[6]=L*-M+this.m[6]*w,L=this.m[3],this.m[3]=L*w+this.m[7]*M,this.m[7]=L*-M+this.m[7]*w};function nt(l){Xt||xr.prototype.constructor.call(this,l)}nt.prototype=new xr,nt._$tP=new Object,nt._$27=function(){nt._$tP.clear()},nt.getID=function(l){var w=nt._$tP[l];return w==null&&(w=new nt(l),nt._$tP[l]=w),w},nt.prototype._$3s=function(){return new nt};function Y(){Xt||(this._$7=1,this._$f=0,this._$H=0,this._$g=1,this._$k=0,this._$w=0,this._$hi=STATE_IDENTITY,this._$Z=_$pS)}Y._$kS=-1,Y._$pS=0,Y._$hb=1,Y.STATE_IDENTITY=0,Y._$gb=1,Y._$fo=2,Y._$go=4,Y.prototype.transform=function(l,w,M){var L,O,N,e,H,W,rt=0,R=0;switch(this._$hi){default:return;case Y._$go|Y._$fo|Y._$gb:for(L=this._$7,O=this._$H,N=this._$k,e=this._$f,H=this._$g,W=this._$w;--M>=0;){var ct=l[rt++],j=l[rt++];w[R++]=L*ct+O*j+N,w[R++]=e*ct+H*j+W}return;case Y._$go|Y._$fo:for(L=this._$7,O=this._$H,e=this._$f,H=this._$g;--M>=0;){var ct=l[rt++],j=l[rt++];w[R++]=L*ct+O*j,w[R++]=e*ct+H*j}return;case Y._$go|Y._$gb:for(O=this._$H,N=this._$k,e=this._$f,W=this._$w;--M>=0;){var ct=l[rt++];w[R++]=O*l[rt++]+N,w[R++]=e*ct+W}return;case Y._$go:for(O=this._$H,e=this._$f;--M>=0;){var ct=l[rt++];w[R++]=O*l[rt++],w[R++]=e*ct}return;case Y._$fo|Y._$gb:for(L=this._$7,N=this._$k,H=this._$g,W=this._$w;--M>=0;)w[R++]=L*l[rt++]+N,w[R++]=H*l[rt++]+W;return;case Y._$fo:for(L=this._$7,H=this._$g;--M>=0;)w[R++]=L*l[rt++],w[R++]=H*l[rt++];return;case Y._$gb:for(N=this._$k,W=this._$w;--M>=0;)w[R++]=l[rt++]+N,w[R++]=l[rt++]+W;return;case Y.STATE_IDENTITY:(l!=w||rt!=R)&&pt._$jT(l,rt,w,R,M*2);return}},Y.prototype.update=function(){this._$H==0&&this._$f==0?this._$7==1&&this._$g==1?this._$k==0&&this._$w==0?(this._$hi=Y.STATE_IDENTITY,this._$Z=Y._$pS):(this._$hi=Y._$gb,this._$Z=Y._$hb):this._$k==0&&this._$w==0?(this._$hi=Y._$fo,this._$Z=Y._$kS):(this._$hi=Y._$fo|Y._$gb,this._$Z=Y._$kS):this._$7==0&&this._$g==0?this._$k==0&&this._$w==0?(this._$hi=Y._$go,this._$Z=Y._$kS):(this._$hi=Y._$go|Y._$gb,this._$Z=Y._$kS):this._$k==0&&this._$w==0?(this._$hi=Y._$go|Y._$fo,this._$Z=Y._$kS):(this._$hi=Y._$go|Y._$fo|Y._$gb,this._$Z=Y._$kS)},Y.prototype._$RT=function(l){this._$IT(l);var w=l[0],M=l[2],L=l[1],O=l[3],N=Math.sqrt(w*w+L*L),e=w*O-M*L;N==0?Pt._$so&&console.log("affine._$RT() / rt==0"):(l[0]=N,l[1]=e/N,l[2]=(L*O+w*M)/e,l[3]=Math.atan2(L,w))},Y.prototype._$ho=function(l,w,M,L){var O=new Float32Array(6),N=new Float32Array(6);l._$RT(O),w._$RT(N);var e=new Float32Array(6);e[0]=O[0]+(N[0]-O[0])*M,e[1]=O[1]+(N[1]-O[1])*M,e[2]=O[2]+(N[2]-O[2])*M,e[3]=O[3]+(N[3]-O[3])*M,e[4]=O[4]+(N[4]-O[4])*M,e[5]=O[5]+(N[5]-O[5])*M,L._$CT(e)},Y.prototype._$CT=function(l){var w=Math.cos(l[3]),M=Math.sin(l[3]);this._$7=l[0]*w,this._$f=l[0]*M,this._$H=l[1]*(l[2]*w-M),this._$g=l[1]*(l[2]*M+w),this._$k=l[4],this._$w=l[5],this.update()},Y.prototype._$IT=function(l){l[0]=this._$7,l[1]=this._$f,l[2]=this._$H,l[3]=this._$g,l[4]=this._$k,l[5]=this._$w};function gt(){Xt||(o.prototype.constructor.call(this),this.motions=new Array,this._$7r=null,this._$7r=gt._$Co++,this._$D0=30,this._$yT=0,this._$E=!0,this.loopFadeIn=!0,this._$AS=-1,_$a0())}gt.prototype=new o,gt._$cs="VISIBLE:",gt._$ar="LAYOUT:",gt._$Co=0,gt._$D2=[],gt._$1T=1,gt.loadMotion=function(l){var w=new gt,M=[0],L=l.length;w._$yT=0;for(var O=0;O<L;++O){var N=l[O]&255;if(!(N==`
13
- `||N=="\r")){if(N=="#"){for(;O<L&&!(l[O]==`
14
- `||l[O]=="\r");++O);continue}if(N=="$"){for(var e=O,H=-1;O<L&&(N=l[O]&255,!(N=="\r"||N==`
15
- `));++O)if(N=="="){H=O;break}var W=!1;if(H>=0){for(H==e+4&&l[e+1]=="f"&&l[e+2]=="p"&&l[e+3]=="s"&&(W=!0),O=H+1;O<L&&(N=l[O]&255,!(N=="\r"||N==`
16
- `));++O)if(!(N==","||N==" "||N==" ")){var rt=Ct._$LS(l,L,O,M);M[0]>0&&W&&5<rt&&rt<121&&(w._$D0=rt),O=M[0]}}for(;O<L&&!(l[O]==`
17
- `||l[O]=="\r");++O);continue}if("a"<=N&&N<="z"||"A"<=N&&N<="Z"||N=="_"){for(var e=O,H=-1;O<L&&(N=l[O]&255,!(N=="\r"||N==`
18
- `));++O)if(N=="="){H=O;break}if(H>=0){var R=new te;Ct.startsWith(l,e,gt._$cs)?(R._$RP=te._$hs,R._$4P=new String(l,e,H-e)):Ct.startsWith(l,e,gt._$ar)?(R._$4P=new String(l,e+7,H-e-7),Ct.startsWith(l,e+7,"ANCHOR_X")?R._$RP=te._$xs:Ct.startsWith(l,e+7,"ANCHOR_Y")?R._$RP=te._$us:Ct.startsWith(l,e+7,"SCALE_X")?R._$RP=te._$qs:Ct.startsWith(l,e+7,"SCALE_Y")?R._$RP=te._$Ys:Ct.startsWith(l,e+7,"X")?R._$RP=te._$ws:Ct.startsWith(l,e+7,"Y")&&(R._$RP=te._$Ns)):(R._$RP=te._$Fr,R._$4P=new String(l,e,H-e)),w.motions.push(R);var ct=0;for(gt._$D2.clear(),O=H+1;O<L&&(N=l[O]&255,!(N=="\r"||N==`
19
- `));++O)if(!(N==","||N==" "||N==" ")){var rt=Ct._$LS(l,L,O,M);if(M[0]>0){gt._$D2.push(rt),ct++;var j=M[0];if(j<O){console.log(`_$n0 _$hi . @Live2DMotion loadMotion()
20
- `);break}O=j}}R._$I0=gt._$D2._$BL(),ct>w._$yT&&(w._$yT=ct)}}}}return w._$AS=1e3*w._$yT/w._$D0|0,w},gt.prototype.getDurationMSec=function(){return this._$AS},gt.prototype.dump=function(){for(var l=0;l<this.motions.length;l++){var w=this.motions[l];console.log("_$wL[%s] [%d]. ",w._$4P,w._$I0.length);for(var M=0;M<w._$I0.length&&M<10;M++)console.log("%5.2f ,",w._$I0[M]);console.log(`
21
- `)}},gt.prototype.updateParamExe=function(l,w,M,L){for(var O=w-L._$z2,N=O*this._$D0/1e3,e=N|0,H=N-e,W=0;W<this.motions.length;W++){var rt=this.motions[W],R=rt._$I0.length,ct=rt._$4P;if(rt._$RP==te._$hs){var j=rt._$I0[e>=R?R-1:e];l.setParamFloat(ct,j)}else if(!(te._$ws<=rt._$RP&&rt._$RP<=te._$Ys)){var v=l.getParamFloat(ct),St=rt._$I0[e>=R?R-1:e],yt=rt._$I0[e+1>=R?R-1:e+1],Mt=St+(yt-St)*H,Ft=v+(Mt-v)*M;l.setParamFloat(ct,Ft)}}e>=this._$yT&&(this._$E?(L._$z2=w,this.loopFadeIn&&(L._$bs=w)):L._$9L=!0)},gt.prototype._$r0=function(){return this._$E},gt.prototype._$aL=function(l){this._$E=l},gt.prototype.isLoopFadeIn=function(){return this.loopFadeIn},gt.prototype.setLoopFadeIn=function(l){this.loopFadeIn=l},$e.prototype.clear=function(){this.size=0},$e.prototype.add=function(l){if(this._$P.length<=this.size){var w=new Float32Array(this.size*2);pt._$jT(this._$P,0,w,0,this.size),this._$P=w}this._$P[this.size++]=l},$e.prototype._$BL=function(){var l=new Float32Array(this.size);return pt._$jT(this._$P,0,l,0,this.size),l},te._$Fr=0,te._$hs=1,te._$ws=100,te._$Ns=101,te._$xs=102,te._$us=103,te._$qs=104,te._$Ys=105;function ot(){}ot._$Ms=1,ot._$Qs=2,ot._$i2=0,ot._$No=2,ot._$do=ot._$Ms,ot._$Ls=!0,ot._$1r=5,ot._$Qb=65,ot._$J=1e-4,ot._$FT=.001,ot._$Ss=3;function ht(){}ht._$o7=6,ht._$S7=7,ht._$s7=8,ht._$77=9,ht.LIVE2D_FORMAT_VERSION_V2_10_SDK2=10,ht.LIVE2D_FORMAT_VERSION_V2_11_SDK2_1=11,ht._$T7=ht.LIVE2D_FORMAT_VERSION_V2_11_SDK2_1,ht._$Is=-2004318072,ht._$h0=0,ht._$4L=23,ht._$7P=33,ht._$uT=function(l){console.log(`_$bo :: _$6 _$mo _$E0 : %d
22
- `,l)},ht._$9o=function(l){if(l<40)return ht._$uT(l),null;if(l<50)return ht._$uT(l),null;if(l<60)return ht._$uT(l),null;if(l<100)switch(l){case 65:return new Ie;case 66:return new Gt;case 67:return new xt;case 68:return new It;case 69:return new Z;case 70:return new ze;default:return ht._$uT(l),null}else if(l<150)switch(l){case 131:return new Wr;case 133:return new ae;case 136:return new $;case 137:return new Fi;case 142:return new se}return ht._$uT(l),null};function dt(l){Xt||(this._$QT=!0,this._$co=-1,this._$qo=0,this._$pb=new Array(dt._$is),this._$_2=new Float32Array(dt._$is),this._$vr=new Float32Array(dt._$is),this._$Rr=new Float32Array(dt._$is),this._$Or=new Float32Array(dt._$is),this._$fs=new Float32Array(dt._$is),this._$Js=new Array(dt._$is),this._$3S=new Array,this._$aS=new Array,this._$Bo=null,this._$F2=new Array,this._$db=new Array,this._$8b=new Array,this._$Hr=new Array,this._$Ws=null,this._$Vs=null,this._$Er=null,this._$Es=new Int16Array(ot._$Qb),this._$ZP=new Float32Array(ot._$1r*2),this._$Ri=l,this._$b0=dt._$HP++,this.clipManager=null,this.dp_webgl=null)}dt._$HP=0,dt._$_0=!0,dt._$V2=-1,dt._$W0=-1,dt._$jr=!1,dt._$ZS=!0,dt._$tr=-1e6,dt._$lr=1e6,dt._$is=32,dt._$e=!1,dt.prototype.getDrawDataIndex=function(l){for(var w=this._$aS.length-1;w>=0;--w)if(this._$aS[w]!=null&&this._$aS[w].getDrawDataID()==l)return w;return-1},dt.prototype.getDrawData=function(l){if(l instanceof nt){if(this._$Bo==null){this._$Bo=new Object;for(var w=this._$aS.length,M=0;M<w;M++){var L=this._$aS[M],O=L.getDrawDataID();O!=null&&(this._$Bo[O]=L)}}return this._$Bo[id]}else return l<this._$aS.length?this._$aS[l]:null},dt.prototype.release=function(){this._$3S.clear(),this._$aS.clear(),this._$F2.clear(),this._$Bo!=null&&this._$Bo.clear(),this._$db.clear(),this._$8b.clear(),this._$Hr.clear()},dt.prototype.init=function(){this._$co++,this._$F2.length>0&&this.release();for(var l=this._$Ri.getModelImpl(),w=l._$Xr(),M=w.length,L=new Array,O=new Array,N=0;N<M;++N){var e=w[N];this._$F2.push(e),this._$Hr.push(e.init(this));for(var H=e.getBaseData(),W=H.length,rt=0;rt<W;++rt)L.push(H[rt]);for(var rt=0;rt<W;++rt){var R=H[rt].init(this);R._$l2(N),O.push(R)}for(var ct=e.getDrawData(),j=ct.length,rt=0;rt<j;++rt){var v=ct[rt],St=v.init(this);St._$IP=N,this._$aS.push(v),this._$8b.push(St)}}for(var yt=L.length,Mt=at._$2o();;){for(var Ft=!1,N=0;N<yt;++N){var Nt=L[N];if(Nt!=null){var Lt=Nt.getTargetBaseDataID();(Lt==null||Lt==Mt||this.getBaseDataIndex(Lt)>=0)&&(this._$3S.push(Nt),this._$db.push(O[N]),L[N]=null,Ft=!0)}}if(!Ft)break}var re=l._$E2();if(re!=null){var Zt=re._$1s();if(Zt!=null)for(var K=Zt.length,N=0;N<K;++N){var Vt=Zt[N];Vt!=null&&this._$02(Vt.getParamID(),Vt.getDefaultValue(),Vt.getMinValue(),Vt.getMaxValue())}}this.clipManager=new t(this.dp_webgl),this.clipManager.init(this,this._$aS,this._$8b),this._$QT=!0},dt.prototype.update=function(){dt._$e&&h.start("_$zL");for(var l=this._$_2.length,w=0;w<l;w++)this._$_2[w]!=this._$vr[w]&&(this._$Js[w]=dt._$ZS,this._$vr[w]=this._$_2[w]);var M=!1,L=this._$3S.length,O=this._$aS.length,N=Bt._$or(),e=Bt._$Pr(),H=e-N+1;(this._$Ws==null||this._$Ws.length<H)&&(this._$Ws=new Int16Array(H),this._$Vs=new Int16Array(H));for(var w=0;w<H;w++)this._$Ws[w]=dt._$V2,this._$Vs[w]=dt._$V2;(this._$Er==null||this._$Er.length<O)&&(this._$Er=new Int16Array(O));for(var w=0;w<O;w++)this._$Er[w]=dt._$W0;dt._$e&&h.dump("_$zL"),dt._$e&&h.start("_$UL");for(var W=null,rt=0;rt<L;++rt){var R=this._$3S[rt],ct=this._$db[rt];try{R._$Nr(this,ct),R._$2b(this,ct)}catch(Nt){W==null&&(W=Nt)}}W!=null&&dt._$_0&&h._$Rb(W),dt._$e&&h.dump("_$UL"),dt._$e&&h.start("_$DL");for(var j=null,v=0;v<O;++v){var St=this._$aS[v],yt=this._$8b[v];try{if(St._$Nr(this,yt),yt._$u2())continue;St._$2b(this,yt);var Mt=Math.floor(St._$zS(this,yt)-N),Ft;try{Ft=this._$Vs[Mt]}catch(Nt){console.log(`_$li :: %s / %s @@_$fS
23
- `,Nt.toString(),St.getDrawDataID().toString()),Mt=Math.floor(St._$zS(this,yt)-N);continue}Ft==dt._$V2?this._$Ws[Mt]=v:this._$Er[Ft]=v,this._$Vs[Mt]=v}catch(Nt){j==null&&(j=Nt,Pt._$sT(Pt._$H7))}}j!=null&&dt._$_0&&h._$Rb(j),dt._$e&&h.dump("_$DL"),dt._$e&&h.start("_$eL");for(var w=this._$Js.length-1;w>=0;w--)this._$Js[w]=dt._$jr;return this._$QT=!1,dt._$e&&h.dump("_$eL"),M},dt.prototype.preDraw=function(l){this.clipManager!=null&&(l._$ZT(),this.clipManager.setupClip(this,l))},dt.prototype.draw=function(l){if(this._$Ws==null){h._$li("call _$Ri.update() before _$Ri.draw() ");return}var w=this._$Ws.length;l._$ZT();for(var M=0;M<w;++M){var L=this._$Ws[M];if(L!=dt._$V2)do{var O=this._$aS[L],N=this._$8b[L];if(N._$yo()){var e=N._$IP,H=this._$Hr[e];N._$VS=H.getPartsOpacity(),O.draw(l,this,N)}var W=this._$Er[L];if(W<=L||W==dt._$W0)break;L=W}while(!0)}},dt.prototype.getParamIndex=function(l){for(var w=this._$pb.length-1;w>=0;--w)if(this._$pb[w]==l)return w;return this._$02(l,0,dt._$tr,dt._$lr)},dt.prototype._$BS=function(l){return this.getBaseDataIndex(l)},dt.prototype.getBaseDataIndex=function(l){for(var w=this._$3S.length-1;w>=0;--w)if(this._$3S[w]!=null&&this._$3S[w].getBaseDataID()==l)return w;return-1},dt.prototype._$UT=function(l,w){var M=new Float32Array(w);return pt._$jT(l,0,M,0,l.length),M},dt.prototype._$02=function(l,w,M,L){if(this._$qo>=this._$pb.length){var O=this._$pb.length,N=new Array(O*2);pt._$jT(this._$pb,0,N,0,O),this._$pb=N,this._$_2=this._$UT(this._$_2,O*2),this._$vr=this._$UT(this._$vr,O*2),this._$Rr=this._$UT(this._$Rr,O*2),this._$Or=this._$UT(this._$Or,O*2);var e=new Array;pt._$jT(this._$Js,0,e,0,O),this._$Js=e}return this._$pb[this._$qo]=l,this._$_2[this._$qo]=w,this._$vr[this._$qo]=w,this._$Rr[this._$qo]=M,this._$Or[this._$qo]=L,this._$Js[this._$qo]=dt._$ZS,this._$qo++},dt.prototype._$Zo=function(l,w){this._$3S[l]=w},dt.prototype.setParamFloat=function(l,w){w<this._$Rr[l]&&(w=this._$Rr[l]),w>this._$Or[l]&&(w=this._$Or[l]),this._$_2[l]=w},dt.prototype.loadParam=function(){var l=this._$_2.length;l>this._$fs.length&&(l=this._$fs.length),pt._$jT(this._$fs,0,this._$_2,0,l)},dt.prototype.saveParam=function(){var l=this._$_2.length;l>this._$fs.length&&(this._$fs=new Float32Array(l)),pt._$jT(this._$_2,0,this._$fs,0,l)},dt.prototype._$v2=function(){return this._$co},dt.prototype._$WS=function(){return this._$QT},dt.prototype._$Xb=function(l){return this._$Js[l]==dt._$ZS},dt.prototype._$vs=function(){return this._$Es},dt.prototype._$Tr=function(){return this._$ZP},dt.prototype.getBaseData=function(l){return this._$3S[l]},dt.prototype.getParamFloat=function(l){return this._$_2[l]},dt.prototype.getParamMax=function(l){return this._$Or[l]},dt.prototype.getParamMin=function(l){return this._$Rr[l]},dt.prototype.setPartsOpacity=function(l,w){var M=this._$Hr[l];M.setPartsOpacity(w)},dt.prototype.getPartsOpacity=function(l){var w=this._$Hr[l];return w.getPartsOpacity()},dt.prototype.getPartsDataIndex=function(l){for(var w=this._$F2.length-1;w>=0;--w)if(this._$F2[w]!=null&&this._$F2[w]._$p2()==l)return w;return-1},dt.prototype._$q2=function(l){return this._$db[l]},dt.prototype._$C2=function(l){return this._$8b[l]},dt.prototype._$Bb=function(l){return this._$Hr[l]},dt.prototype._$5s=function(l,w){for(var M=this._$Ws.length,L=l,O=0;O<M;++O){var N=this._$Ws[O];if(N!=dt._$V2)do{var e=this._$8b[N];e._$yo()&&(e._$GT()._$B2(this,e,L),L+=w);var H=this._$Er[N];if(H<=N||H==dt._$W0)break;N=H}while(!0)}},dt.prototype.setDrawParam=function(l){this.dp_webgl=l},dt.prototype.getDrawParam=function(){return this.dp_webgl};function At(){}At._$0T=function(l){return At._$0T(new _$5(l))},At._$0T=function(l){if(!l.exists())throw new _$ls(l._$3b());for(var w=l.length(),M=new Int8Array(w),L=new _$Xs(new _$kb(l),8192),O,N=0;(O=L.read(M,N,w-N))>0;)N+=O;return M},At._$C=function(l){var w=null,M=null;try{w=l instanceof Array?l:new _$Xs(l,8192),M=new _$js;for(var L=1e3,O,N=new Int8Array(L);(O=w.read(N))>0;)M.write(N,0,O);return M._$TS()}finally{l!=null&&l.close(),M!=null&&(M.flush(),M.close())}};function Et(){Xt||(wt.prototype.constructor.call(this),this._$sb=new Int32Array(Et._$As),this._$U2=new Array,this.transform=null,this.gl=null,Et._$NT==null&&(Et._$NT=Et._$9r(256),Et._$vS=Et._$9r(256),Et._$no=Et._$vb(256)))}Et.prototype=new wt,Et._$As=32,Et._$Gr=!1,Et._$NT=null,Et._$vS=null,Et._$no=null,Et._$9r=function(l){var w=new Float32Array(l);return w},Et._$vb=function(l){var w=new Int16Array(l);return w},Et._$cr=function(l,w){return l==null||l._$yL()<w.length?(l=Et._$9r(w.length*2),l.put(w),l._$oT(0)):(l.clear(),l.put(w),l._$oT(0)),l},Et._$mb=function(l,w){return l==null||l._$yL()<w.length?(l=Et._$vb(w.length*2),l.put(w),l._$oT(0)):(l.clear(),l.put(w),l._$oT(0)),l},Et._$Hs=function(){return Et._$Gr},Et._$as=function(l){Et._$Gr=l},Et.prototype.setGL=function(l){this.gl=l},Et.prototype.setTransform=function(l){this.transform=l},Et.prototype._$ZT=function(){},Et.prototype._$Uo=function(l,w,M,L,O,N,e,H){if(!(N<.01)){var W=this._$U2[l],rt=N>.9?Pt.EXPAND_W:0;this.gl.drawElements(W,M,L,O,N,rt,this.transform,H)}},Et.prototype._$Rs=function(){throw new Error("_$Rs")},Et.prototype._$Ds=function(l){throw new Error("_$Ds")},Et.prototype._$K2=function(){for(var l=0;l<this._$sb.length;l++){var w=this._$sb[l];w!=0&&(this.gl._$Sr(1,this._$sb,l),this._$sb[l]=0)}},Et.prototype.setTexture=function(l,w){this._$sb.length<l+1&&this._$nS(l),this._$sb[l]=w},Et.prototype.setTexture=function(l,w){this._$sb.length<l+1&&this._$nS(l),this._$U2[l]=w},Et.prototype._$nS=function(l){var w=Math.max(this._$sb.length*2,l+1+10),M=new Int32Array(w);pt._$jT(this._$sb,0,M,0,this._$sb.length),this._$sb=M;var L=new Array;pt._$jT(this._$U2,0,L,0,this._$U2.length),this._$U2=L};function It(){Xt||(Rt.prototype.constructor.call(this),this._$GS=null,this._$Y0=null)}It.prototype=new Rt,It._$Xo=new Float32Array(2),It._$io=new Float32Array(2),It._$0o=new Float32Array(2),It._$Lo=new Float32Array(2),It._$To=new Float32Array(2),It._$Po=new Float32Array(2),It._$gT=new Array,It.prototype._$zP=function(){this._$GS=new Gt,this._$GS._$zP(),this._$Y0=new Array},It.prototype.getType=function(){return Rt._$c2},It.prototype._$F0=function(l){Rt.prototype._$F0.call(this,l),this._$GS=l._$nP(),this._$Y0=l._$nP(),Rt.prototype.readV2_opacity.call(this,l)},It.prototype.init=function(l){var w=new oe(this);return w._$Yr=new Z,this._$32()&&(w._$Wr=new Z),w},It.prototype._$Nr=function(l,w){this!=w._$GT()&&console.log("### assert!! ### ");var M=w;if(this._$GS._$Ur(l)){var L=It._$gT;L[0]=!1;var O=this._$GS._$Q2(l,L);w._$Ib(L[0]),this.interpolateOpacity(l,this._$GS,w,L);var N=l._$vs(),e=l._$Tr();if(this._$GS._$zr(N,e,O),O<=0){var Qe=this._$Y0[N[0]];M._$Yr.init(Qe)}else if(O==1){var Qe=this._$Y0[N[0]],H=this._$Y0[N[1]],W=e[0];M._$Yr._$fL=Qe._$fL+(H._$fL-Qe._$fL)*W,M._$Yr._$gL=Qe._$gL+(H._$gL-Qe._$gL)*W,M._$Yr._$B0=Qe._$B0+(H._$B0-Qe._$B0)*W,M._$Yr._$z0=Qe._$z0+(H._$z0-Qe._$z0)*W,M._$Yr._$qT=Qe._$qT+(H._$qT-Qe._$qT)*W}else if(O==2){var Qe=this._$Y0[N[0]],H=this._$Y0[N[1]],rt=this._$Y0[N[2]],R=this._$Y0[N[3]],W=e[0],ct=e[1],j=Qe._$fL+(H._$fL-Qe._$fL)*W,v=rt._$fL+(R._$fL-rt._$fL)*W;M._$Yr._$fL=j+(v-j)*ct,j=Qe._$gL+(H._$gL-Qe._$gL)*W,v=rt._$gL+(R._$gL-rt._$gL)*W,M._$Yr._$gL=j+(v-j)*ct,j=Qe._$B0+(H._$B0-Qe._$B0)*W,v=rt._$B0+(R._$B0-rt._$B0)*W,M._$Yr._$B0=j+(v-j)*ct,j=Qe._$z0+(H._$z0-Qe._$z0)*W,v=rt._$z0+(R._$z0-rt._$z0)*W,M._$Yr._$z0=j+(v-j)*ct,j=Qe._$qT+(H._$qT-Qe._$qT)*W,v=rt._$qT+(R._$qT-rt._$qT)*W,M._$Yr._$qT=j+(v-j)*ct}else if(O==3){var St=this._$Y0[N[0]],yt=this._$Y0[N[1]],Mt=this._$Y0[N[2]],Ft=this._$Y0[N[3]],Nt=this._$Y0[N[4]],Lt=this._$Y0[N[5]],re=this._$Y0[N[6]],Zt=this._$Y0[N[7]],W=e[0],ct=e[1],K=e[2],j=St._$fL+(yt._$fL-St._$fL)*W,v=Mt._$fL+(Ft._$fL-Mt._$fL)*W,Vt=Nt._$fL+(Lt._$fL-Nt._$fL)*W,jt=re._$fL+(Zt._$fL-re._$fL)*W;M._$Yr._$fL=(1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct),j=St._$gL+(yt._$gL-St._$gL)*W,v=Mt._$gL+(Ft._$gL-Mt._$gL)*W,Vt=Nt._$gL+(Lt._$gL-Nt._$gL)*W,jt=re._$gL+(Zt._$gL-re._$gL)*W,M._$Yr._$gL=(1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct),j=St._$B0+(yt._$B0-St._$B0)*W,v=Mt._$B0+(Ft._$B0-Mt._$B0)*W,Vt=Nt._$B0+(Lt._$B0-Nt._$B0)*W,jt=re._$B0+(Zt._$B0-re._$B0)*W,M._$Yr._$B0=(1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct),j=St._$z0+(yt._$z0-St._$z0)*W,v=Mt._$z0+(Ft._$z0-Mt._$z0)*W,Vt=Nt._$z0+(Lt._$z0-Nt._$z0)*W,jt=re._$z0+(Zt._$z0-re._$z0)*W,M._$Yr._$z0=(1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct),j=St._$qT+(yt._$qT-St._$qT)*W,v=Mt._$qT+(Ft._$qT-Mt._$qT)*W,Vt=Nt._$qT+(Lt._$qT-Nt._$qT)*W,jt=re._$qT+(Zt._$qT-re._$qT)*W,M._$Yr._$qT=(1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct)}else if(O==4){var vt=this._$Y0[N[0]],Ut=this._$Y0[N[1]],Fe=this._$Y0[N[2]],We=this._$Y0[N[3]],ge=this._$Y0[N[4]],me=this._$Y0[N[5]],ve=this._$Y0[N[6]],Ce=this._$Y0[N[7]],Ee=this._$Y0[N[8]],Me=this._$Y0[N[9]],ee=this._$Y0[N[10]],ye=this._$Y0[N[11]],ie=this._$Y0[N[12]],he=this._$Y0[N[13]],ke=this._$Y0[N[14]],lr=this._$Y0[N[15]],W=e[0],ct=e[1],K=e[2],qe=e[3],j=vt._$fL+(Ut._$fL-vt._$fL)*W,v=Fe._$fL+(We._$fL-Fe._$fL)*W,Vt=ge._$fL+(me._$fL-ge._$fL)*W,jt=ve._$fL+(Ce._$fL-ve._$fL)*W,Le=Ee._$fL+(Me._$fL-Ee._$fL)*W,ir=ee._$fL+(ye._$fL-ee._$fL)*W,Ze=ie._$fL+(he._$fL-ie._$fL)*W,gr=ke._$fL+(lr._$fL-ke._$fL)*W;M._$Yr._$fL=(1-qe)*((1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct))+qe*((1-K)*(Le+(ir-Le)*ct)+K*(Ze+(gr-Ze)*ct)),j=vt._$gL+(Ut._$gL-vt._$gL)*W,v=Fe._$gL+(We._$gL-Fe._$gL)*W,Vt=ge._$gL+(me._$gL-ge._$gL)*W,jt=ve._$gL+(Ce._$gL-ve._$gL)*W,Le=Ee._$gL+(Me._$gL-Ee._$gL)*W,ir=ee._$gL+(ye._$gL-ee._$gL)*W,Ze=ie._$gL+(he._$gL-ie._$gL)*W,gr=ke._$gL+(lr._$gL-ke._$gL)*W,M._$Yr._$gL=(1-qe)*((1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct))+qe*((1-K)*(Le+(ir-Le)*ct)+K*(Ze+(gr-Ze)*ct)),j=vt._$B0+(Ut._$B0-vt._$B0)*W,v=Fe._$B0+(We._$B0-Fe._$B0)*W,Vt=ge._$B0+(me._$B0-ge._$B0)*W,jt=ve._$B0+(Ce._$B0-ve._$B0)*W,Le=Ee._$B0+(Me._$B0-Ee._$B0)*W,ir=ee._$B0+(ye._$B0-ee._$B0)*W,Ze=ie._$B0+(he._$B0-ie._$B0)*W,gr=ke._$B0+(lr._$B0-ke._$B0)*W,M._$Yr._$B0=(1-qe)*((1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct))+qe*((1-K)*(Le+(ir-Le)*ct)+K*(Ze+(gr-Ze)*ct)),j=vt._$z0+(Ut._$z0-vt._$z0)*W,v=Fe._$z0+(We._$z0-Fe._$z0)*W,Vt=ge._$z0+(me._$z0-ge._$z0)*W,jt=ve._$z0+(Ce._$z0-ve._$z0)*W,Le=Ee._$z0+(Me._$z0-Ee._$z0)*W,ir=ee._$z0+(ye._$z0-ee._$z0)*W,Ze=ie._$z0+(he._$z0-ie._$z0)*W,gr=ke._$z0+(lr._$z0-ke._$z0)*W,M._$Yr._$z0=(1-qe)*((1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct))+qe*((1-K)*(Le+(ir-Le)*ct)+K*(Ze+(gr-Ze)*ct)),j=vt._$qT+(Ut._$qT-vt._$qT)*W,v=Fe._$qT+(We._$qT-Fe._$qT)*W,Vt=ge._$qT+(me._$qT-ge._$qT)*W,jt=ve._$qT+(Ce._$qT-ve._$qT)*W,Le=Ee._$qT+(Me._$qT-Ee._$qT)*W,ir=ee._$qT+(ye._$qT-ee._$qT)*W,Ze=ie._$qT+(he._$qT-ie._$qT)*W,gr=ke._$qT+(lr._$qT-ke._$qT)*W,M._$Yr._$qT=(1-qe)*((1-K)*(j+(v-j)*ct)+K*(Vt+(jt-Vt)*ct))+qe*((1-K)*(Le+(ir-Le)*ct)+K*(Ze+(gr-Ze)*ct))}else{for(var Je=Math.pow(2,O)|0,mr=new Float32Array(Je),ur=0;ur<Je;ur++){for(var kr=ur,hi=1,Yr=0;Yr<O;Yr++)hi*=kr%2==0?1-e[Yr]:e[Yr],kr/=2;mr[ur]=hi}for(var jr=new Array,cr=0;cr<Je;cr++)jr[cr]=this._$Y0[N[cr]];for(var es=0,rs=0,Kr=0,ki=0,li=0,cr=0;cr<Je;cr++)es+=mr[cr]*jr[cr]._$fL,rs+=mr[cr]*jr[cr]._$gL,Kr+=mr[cr]*jr[cr]._$B0,ki+=mr[cr]*jr[cr]._$z0,li+=mr[cr]*jr[cr]._$qT;M._$Yr._$fL=es,M._$Yr._$gL=rs,M._$Yr._$B0=Kr,M._$Yr._$z0=ki,M._$Yr._$qT=li}var Qe=this._$Y0[N[0]];M._$Yr.reflectX=Qe.reflectX,M._$Yr.reflectY=Qe.reflectY}},It.prototype._$2b=function(l,w){this!=w._$GT()&&console.log("### assert!! ### ");var M=w;if(M._$hS(!0),!this._$32())M.setTotalScale_notForClient(M._$Yr._$B0),M.setTotalOpacity(M.getInterpolatedOpacity());else{var L=this.getTargetBaseDataID();if(M._$8r==Rt._$ur&&(M._$8r=l.getBaseDataIndex(L)),M._$8r<0)Pt._$so&&h._$li("_$L _$0P _$G :: %s",L),M._$hS(!1);else{var O=l.getBaseData(M._$8r);if(O!=null){var N=l._$q2(M._$8r),e=It._$Xo;e[0]=M._$Yr._$fL,e[1]=M._$Yr._$gL;var H=It._$io;H[0]=0,H[1]=-.1;var W=N._$GT().getType();W==Rt._$c2?H[1]=-10:H[1]=-.1;var rt=It._$0o;this._$Jr(l,O,N,e,H,rt);var R=Xe._$92(H,rt);O._$nb(l,N,e,e,1,0,2),M._$Wr._$fL=e[0],M._$Wr._$gL=e[1],M._$Wr._$B0=M._$Yr._$B0,M._$Wr._$z0=M._$Yr._$z0,M._$Wr._$qT=M._$Yr._$qT-R*Xe._$NS;var ct=N.getTotalScale();M.setTotalScale_notForClient(ct*M._$Wr._$B0);var j=N.getTotalOpacity();M.setTotalOpacity(j*M.getInterpolatedOpacity()),M._$Wr.reflectX=M._$Yr.reflectX,M._$Wr.reflectY=M._$Yr.reflectY,M._$hS(N._$yo())}else M._$hS(!1)}}},It.prototype._$nb=function(l,w,M,L,O,N,e){this!=w._$GT()&&console.log("### assert!! ### ");for(var H=w,W=H._$Wr!=null?H._$Wr:H._$Yr,rt=Math.sin(Xe._$bS*W._$qT),R=Math.cos(Xe._$bS*W._$qT),ct=H.getTotalScale(),j=W.reflectX?-1:1,v=W.reflectY?-1:1,St=R*ct*j,yt=-rt*ct*v,Mt=rt*ct*j,Ft=R*ct*v,Nt=W._$fL,Lt=W._$gL,re,Zt,K=O*e,Vt=N;Vt<K;Vt+=e)re=M[Vt],Zt=M[Vt+1],L[Vt]=St*re+yt*Zt+Nt,L[Vt+1]=Mt*re+Ft*Zt+Lt},It.prototype._$Jr=function(l,w,M,L,O,N){w!=M._$GT()&&console.log("### assert!! ### ");var e=It._$Lo;It._$Lo[0]=L[0],It._$Lo[1]=L[1],w._$nb(l,M,e,e,1,0,2);for(var H=It._$To,W=It._$Po,rt=10,R=1,ct=0;ct<rt;ct++){if(W[0]=L[0]+R*O[0],W[1]=L[1]+R*O[1],w._$nb(l,M,W,H,1,0,2),H[0]-=e[0],H[1]-=e[1],H[0]!=0||H[1]!=0){N[0]=H[0],N[1]=H[1];return}if(W[0]=L[0]-R*O[0],W[1]=L[1]-R*O[1],w._$nb(l,M,W,H,1,0,2),H[0]-=e[0],H[1]-=e[1],H[0]!=0||H[1]!=0){H[0]=-H[0],H[0]=-H[0],N[0]=H[0],N[1]=H[1];return}R*=.1}Pt._$so&&console.log(`_$L0 to transform _$SP
24
- `)};function oe(l){dr.prototype.constructor.call(this,l),this._$8r=Rt._$ur,this._$Yr=null,this._$Wr=null}oe.prototype=new dr;function Bt(){Xt||(ft.prototype.constructor.call(this),this._$gP=null,this._$dr=null,this._$GS=null,this._$qb=null,this._$Lb=null,this._$mS=null)}Bt.prototype=new ft,Bt._$ur=-2,Bt._$ES=500,Bt._$wb=2,Bt._$8S=3,Bt._$os=4,Bt._$52=Bt._$ES,Bt._$R2=Bt._$ES,Bt._$Sb=function(l){for(var w=l.length-1;w>=0;--w){var M=l[w];M<Bt._$52?Bt._$52=M:M>Bt._$R2&&(Bt._$R2=M)}},Bt._$or=function(){return Bt._$52},Bt._$Pr=function(){return Bt._$R2},Bt.prototype._$F0=function(l){this._$gP=l._$nP(),this._$dr=l._$nP(),this._$GS=l._$nP(),this._$qb=l._$6L(),this._$Lb=l._$cS(),this._$mS=l._$Tb(),l.getFormatVersion()>=ht._$T7?(this.clipID=l._$nP(),this.clipIDList=this.convertClipIDForV2_11(this.clipID)):this.clipIDList=null,Bt._$Sb(this._$Lb)},Bt.prototype.getClipIDList=function(){return this.clipIDList},Bt.prototype._$Nr=function(l,w){if(w._$IS[0]=!1,w._$Us=_t._$Z2(l,this._$GS,w._$IS,this._$Lb),!Pt._$Zs){if(w._$IS[0])return}w._$7s=_t._$br(l,this._$GS,w._$IS,this._$mS)},Bt.prototype._$2b=function(l){},Bt.prototype.getDrawDataID=function(){return this._$gP},Bt.prototype._$j2=function(l){this._$gP=l},Bt.prototype.getOpacity=function(l,w){return w._$7s},Bt.prototype._$zS=function(l,w){return w._$Us},Bt.prototype.getTargetBaseDataID=function(){return this._$dr},Bt.prototype._$gs=function(l){this._$dr=l},Bt.prototype._$32=function(){return this._$dr!=null&&this._$dr!=at._$2o()},Bt.prototype.getType=function(){};function se(){Xt||(this._$NL=null,this._$3S=null,this._$aS=null,se._$42++)}se._$42=0,se.prototype._$1b=function(){return this._$3S},se.prototype.getDrawDataList=function(){return this._$aS},se.prototype._$F0=function(l){this._$NL=l._$nP(),this._$aS=l._$nP(),this._$3S=l._$nP()},se.prototype._$kr=function(l){l._$Zo(this._$3S),l._$xo(this._$aS),this._$3S=null,this._$aS=null};function Jt(){Xt||(s.prototype.constructor.call(this),this._$zo=new Et)}Jt.prototype=new s,Jt.loadModel=function(l){var w=new Jt;return s._$62(w,l),w},Jt.loadModel=function(l){var w=new Jt;return s._$62(w,l),w},Jt._$to=function(){var l=new Jt;return l},Jt._$er=function(l){var w=new _$5("../_$_r/_$t0/_$Ri/_$_P._$d");if(w.exists()==!1)throw new _$ls("_$t0 _$_ _$6 _$Ui :: "+w._$PL());for(var M=["../_$_r/_$t0/_$Ri/_$_P.512/_$CP._$1","../_$_r/_$t0/_$Ri/_$_P.512/_$vP._$1","../_$_r/_$t0/_$Ri/_$_P.512/_$EP._$1","../_$_r/_$t0/_$Ri/_$_P.512/_$pP._$1"],L=Jt.loadModel(w._$3b()),O=0;O<M.length;O++){var N=new _$5(M[O]);if(N.exists()==!1)throw new _$ls("_$t0 _$_ _$6 _$Ui :: "+N._$PL());L.setTexture(O,_$nL._$_o(l,N._$3b()))}return L},Jt.prototype.setGL=function(l){this._$zo.setGL(l)},Jt.prototype.setTransform=function(l){this._$zo.setTransform(l)},Jt.prototype.draw=function(){this._$5S.draw(this._$zo)},Jt.prototype._$K2=function(){this._$zo._$K2()},Jt.prototype.setTexture=function(l,w){this._$zo==null&&h._$li("_$Yi for QT _$ki / _$XS() is _$6 _$ui!!"),this._$zo.setTexture(l,w)},Jt.prototype.setTexture=function(l,w){this._$zo==null&&h._$li("_$Yi for QT _$ki / _$XS() is _$6 _$ui!!"),this._$zo.setTexture(l,w)},Jt.prototype._$Rs=function(){return this._$zo._$Rs()},Jt.prototype._$Ds=function(l){this._$zo._$Ds(l)},Jt.prototype.getDrawParam=function(){return this._$zo};function zt(){Xt||(o.prototype.constructor.call(this),this.motions=new Array,this._$o2=null,this._$7r=zt._$Co++,this._$D0=30,this._$yT=0,this._$E=!1,this.loopFadeIn=!0,this._$rr=-1,this._$eP=0)}zt.prototype=new o,zt._$cs="VISIBLE:",zt._$ar="LAYOUT:",zt.MTN_PREFIX_FADEIN="FADEIN:",zt.MTN_PREFIX_FADEOUT="FADEOUT:",zt._$Co=0,zt._$1T=1,zt.loadMotion=function(l){var w=At._$C(l),M=zt.loadMotion(w);return M};function _e(l,w){return String.fromCharCode(l.getUint8(w))}zt.loadMotion=function(l){l instanceof ArrayBuffer&&(l=new DataView(l));var w=new zt,M=[0],L=l.byteLength;w._$yT=0;for(var O=0;O<L;++O){var N=_e(l,O),e=N.charCodeAt(0);if(!(N==`
25
- `||N=="\r")){if(N=="#"){for(;O<L&&!(_e(l,O)==`
26
- `||_e(l,O)=="\r");++O);continue}if(N=="$"){for(var H=O,W=-1;O<L&&(N=_e(l,O),!(N=="\r"||N==`
27
- `));++O)if(N=="="){W=O;break}var rt=!1;if(W>=0){for(W==H+4&&_e(l,H+1)=="f"&&_e(l,H+2)=="p"&&_e(l,H+3)=="s"&&(rt=!0),O=W+1;O<L&&(N=_e(l,O),!(N=="\r"||N==`
28
- `));++O)if(!(N==","||N==" "||N==" ")){var R=Ct._$LS(l,L,O,M);M[0]>0&&rt&&5<R&&R<121&&(w._$D0=R),O=M[0]}}for(;O<L&&!(_e(l,O)==`
29
- `||_e(l,O)=="\r");++O);continue}if(97<=e&&e<=122||65<=e&&e<=90||N=="_"){for(var H=O,W=-1;O<L&&(N=_e(l,O),!(N=="\r"||N==`
30
- `));++O)if(N=="="){W=O;break}if(W>=0){var ct=new te;Ct.startsWith(l,H,zt._$cs)?(ct._$RP=te._$hs,ct._$4P=Ct.createString(l,H,W-H)):Ct.startsWith(l,H,zt._$ar)?(ct._$4P=Ct.createString(l,H+7,W-H-7),Ct.startsWith(l,H+7,"ANCHOR_X")?ct._$RP=te._$xs:Ct.startsWith(l,H+7,"ANCHOR_Y")?ct._$RP=te._$us:Ct.startsWith(l,H+7,"SCALE_X")?ct._$RP=te._$qs:Ct.startsWith(l,H+7,"SCALE_Y")?ct._$RP=te._$Ys:Ct.startsWith(l,H+7,"X")?ct._$RP=te._$ws:Ct.startsWith(l,H+7,"Y")&&(ct._$RP=te._$Ns)):(ct._$RP=te._$Fr,ct._$4P=Ct.createString(l,H,W-H)),w.motions.push(ct);var j=0,v=[];for(O=W+1;O<L&&(N=_e(l,O),!(N=="\r"||N==`
31
- `));++O)if(!(N==","||N==" "||N==" ")){var R=Ct._$LS(l,L,O,M);if(M[0]>0){v.push(R),j++;var St=M[0];if(St<O){console.log(`_$n0 _$hi . @Live2DMotion loadMotion()
32
- `);break}O=St-1}}ct._$I0=new Float32Array(v),j>w._$yT&&(w._$yT=j)}}}}return w._$rr=1e3*w._$yT/w._$D0|0,w},zt.prototype.getDurationMSec=function(){return this._$E?-1:this._$rr},zt.prototype.getLoopDurationMSec=function(){return this._$rr},zt.prototype.dump=function(){for(var l=0;l<this.motions.length;l++){var w=this.motions[l];console.log("_$wL[%s] [%d]. ",w._$4P,w._$I0.length);for(var M=0;M<w._$I0.length&&M<10;M++)console.log("%5.2f ,",w._$I0[M]);console.log(`
33
- `)}},zt.prototype.updateParamExe=function(l,w,M,L){for(var O=w-L._$z2,N=O*this._$D0/1e3,e=N|0,H=N-e,W=0;W<this.motions.length;W++){var rt=this.motions[W],R=rt._$I0.length,ct=rt._$4P;if(rt._$RP==te._$hs){var j=rt._$I0[e>=R?R-1:e];l.setParamFloat(ct,j)}else if(!(te._$ws<=rt._$RP&&rt._$RP<=te._$Ys)){var v=l.getParamIndex(ct),St=l.getModelContext(),yt=St.getParamMax(v),Mt=St.getParamMin(v),Ft=.4,Nt=Ft*(yt-Mt),Lt=St.getParamFloat(v),re=rt._$I0[e>=R?R-1:e],Zt=rt._$I0[e+1>=R?R-1:e+1],K;re<Zt&&Zt-re>Nt||re>Zt&&re-Zt>Nt?K=re:K=re+(Zt-re)*H;var Vt=Lt+(K-Lt)*M;l.setParamFloat(ct,Vt)}}e>=this._$yT&&(this._$E?(L._$z2=w,this.loopFadeIn&&(L._$bs=w)):L._$9L=!0),this._$eP=M},zt.prototype._$r0=function(){return this._$E},zt.prototype._$aL=function(l){this._$E=l},zt.prototype._$S0=function(){return this._$D0},zt.prototype._$U0=function(l){this._$D0=l},zt.prototype.isLoopFadeIn=function(){return this.loopFadeIn},zt.prototype.setLoopFadeIn=function(l){this.loopFadeIn=l};function $e(){this._$P=new Float32Array(100),this.size=0}$e.prototype.clear=function(){this.size=0},$e.prototype.add=function(l){if(this._$P.length<=this.size){var w=new Float32Array(this.size*2);pt._$jT(this._$P,0,w,0,this.size),this._$P=w}this._$P[this.size++]=l},$e.prototype._$BL=function(){var l=new Float32Array(this.size);return pt._$jT(this._$P,0,l,0,this.size),l};function te(){this._$4P=null,this._$I0=null,this._$RP=null}te._$Fr=0,te._$hs=1,te._$ws=100,te._$Ns=101,te._$xs=102,te._$us=103,te._$qs=104,te._$Ys=105;function Ie(){Xt||(Rt.prototype.constructor.call(this),this._$o=0,this._$A=0,this._$GS=null,this._$Eo=null)}Ie.prototype=new Rt,Ie._$gT=new Array,Ie.prototype._$zP=function(){this._$GS=new Gt,this._$GS._$zP()},Ie.prototype._$F0=function(l){Rt.prototype._$F0.call(this,l),this._$A=l._$6L(),this._$o=l._$6L(),this._$GS=l._$nP(),this._$Eo=l._$nP(),Rt.prototype.readV2_opacity.call(this,l)},Ie.prototype.init=function(l){var w=new xe(this),M=(this._$o+1)*(this._$A+1);return w._$Cr!=null&&(w._$Cr=null),w._$Cr=new Float32Array(M*2),w._$hr!=null&&(w._$hr=null),this._$32()?w._$hr=new Float32Array(M*2):w._$hr=null,w},Ie.prototype._$Nr=function(l,w){var M=w;if(this._$GS._$Ur(l)){var L=this._$VT(),O=Ie._$gT;O[0]=!1,_t._$Vr(l,this._$GS,O,L,this._$Eo,M._$Cr,0,2),w._$Ib(O[0]),this.interpolateOpacity(l,this._$GS,w,O)}},Ie.prototype._$2b=function(l,w){var M=w;if(M._$hS(!0),!this._$32())M.setTotalOpacity(M.getInterpolatedOpacity());else{var L=this.getTargetBaseDataID();if(M._$8r==Rt._$ur&&(M._$8r=l.getBaseDataIndex(L)),M._$8r<0)Pt._$so&&h._$li("_$L _$0P _$G :: %s",L),M._$hS(!1);else{var O=l.getBaseData(M._$8r),N=l._$q2(M._$8r);if(O!=null&&N._$yo()){var e=N.getTotalScale();M.setTotalScale_notForClient(e);var H=N.getTotalOpacity();M.setTotalOpacity(H*M.getInterpolatedOpacity()),O._$nb(l,N,M._$Cr,M._$hr,this._$VT(),0,2),M._$hS(!0)}else M._$hS(!1)}}},Ie.prototype._$nb=function(l,w,M,L,O,N,e){{var H=w,W=H._$hr!=null?H._$hr:H._$Cr;Ie.transformPoints_sdk2(M,L,O,N,e,W,this._$o,this._$A)}},Ie.transformPoints_sdk2=function(l,w,M,L,O,N,e,H){for(var W=M*O,rt,R,ct,j=0,v=0,St=0,yt=0,Mt=0,Ft=0,Nt=!1,Lt=L;Lt<W;Lt+=O){var re,Zt,K,Vt;if(K=l[Lt],Vt=l[Lt+1],re=K*e,Zt=Vt*H,re<0||Zt<0||e<=re||H<=Zt){var jt=e+1;if(!Nt){Nt=!0,j=.25*(N[(0+0*jt)*2]+N[(e+0*jt)*2]+N[(0+H*jt)*2]+N[(e+H*jt)*2]),v=.25*(N[(0+0*jt)*2+1]+N[(e+0*jt)*2+1]+N[(0+H*jt)*2+1]+N[(e+H*jt)*2+1]);var vt=N[(e+H*jt)*2]-N[(0+0*jt)*2],Ut=N[(e+H*jt)*2+1]-N[(0+0*jt)*2+1],Fe=N[(e+0*jt)*2]-N[(0+H*jt)*2],We=N[(e+0*jt)*2+1]-N[(0+H*jt)*2+1];St=(vt+Fe)*.5,yt=(Ut+We)*.5,Mt=(vt-Fe)*.5,Ft=(Ut-We)*.5,j-=.5*(St+Mt),v-=.5*(yt+Ft)}if(-2<K&&K<3&&-2<Vt&&Vt<3)if(K<=0)if(Vt<=0){var ge=N[(0+0*jt)*2],me=N[(0+0*jt)*2+1],ve=j-2*St,Ce=v-2*yt,Ee=j-2*Mt,Me=v-2*Ft,ee=j-2*St-2*Mt,ye=v-2*yt-2*Ft,ie=.5*(K- -2),he=.5*(Vt- -2);ie+he<=1?(w[Lt]=ee+(Ee-ee)*ie+(ve-ee)*he,w[Lt+1]=ye+(Me-ye)*ie+(Ce-ye)*he):(w[Lt]=ge+(ve-ge)*(1-ie)+(Ee-ge)*(1-he),w[Lt+1]=me+(Ce-me)*(1-ie)+(Me-me)*(1-he))}else if(Vt>=1){var Ee=N[(0+H*jt)*2],Me=N[(0+H*jt)*2+1],ee=j-2*St+1*Mt,ye=v-2*yt+1*Ft,ge=j+3*Mt,me=v+3*Ft,ve=j-2*St+3*Mt,Ce=v-2*yt+3*Ft,ie=.5*(K- -2),he=.5*(Vt-1);ie+he<=1?(w[Lt]=ee+(Ee-ee)*ie+(ve-ee)*he,w[Lt+1]=ye+(Me-ye)*ie+(Ce-ye)*he):(w[Lt]=ge+(ve-ge)*(1-ie)+(Ee-ge)*(1-he),w[Lt+1]=me+(Ce-me)*(1-ie)+(Me-me)*(1-he))}else{var ke=Zt|0;ke==H&&(ke=H-1);var ie=.5*(K- -2),he=Zt-ke,lr=ke/H,qe=(ke+1)/H,Ee=N[(0+ke*jt)*2],Me=N[(0+ke*jt)*2+1],ge=N[(0+(ke+1)*jt)*2],me=N[(0+(ke+1)*jt)*2+1],ee=j-2*St+lr*Mt,ye=v-2*yt+lr*Ft,ve=j-2*St+qe*Mt,Ce=v-2*yt+qe*Ft;ie+he<=1?(w[Lt]=ee+(Ee-ee)*ie+(ve-ee)*he,w[Lt+1]=ye+(Me-ye)*ie+(Ce-ye)*he):(w[Lt]=ge+(ve-ge)*(1-ie)+(Ee-ge)*(1-he),w[Lt+1]=me+(Ce-me)*(1-ie)+(Me-me)*(1-he))}else if(1<=K)if(Vt<=0){var ve=N[(e+0*jt)*2],Ce=N[(e+0*jt)*2+1],ge=j+3*St,me=v+3*yt,ee=j+1*St-2*Mt,ye=v+1*yt-2*Ft,Ee=j+3*St-2*Mt,Me=v+3*yt-2*Ft,ie=.5*(K-1),he=.5*(Vt- -2);ie+he<=1?(w[Lt]=ee+(Ee-ee)*ie+(ve-ee)*he,w[Lt+1]=ye+(Me-ye)*ie+(Ce-ye)*he):(w[Lt]=ge+(ve-ge)*(1-ie)+(Ee-ge)*(1-he),w[Lt+1]=me+(Ce-me)*(1-ie)+(Me-me)*(1-he))}else if(Vt>=1){var ee=N[(e+H*jt)*2],ye=N[(e+H*jt)*2+1],Ee=j+3*St+1*Mt,Me=v+3*yt+1*Ft,ve=j+1*St+3*Mt,Ce=v+1*yt+3*Ft,ge=j+3*St+3*Mt,me=v+3*yt+3*Ft,ie=.5*(K-1),he=.5*(Vt-1);ie+he<=1?(w[Lt]=ee+(Ee-ee)*ie+(ve-ee)*he,w[Lt+1]=ye+(Me-ye)*ie+(Ce-ye)*he):(w[Lt]=ge+(ve-ge)*(1-ie)+(Ee-ge)*(1-he),w[Lt+1]=me+(Ce-me)*(1-ie)+(Me-me)*(1-he))}else{var ke=Zt|0;ke==H&&(ke=H-1);var ie=.5*(K-1),he=Zt-ke,lr=ke/H,qe=(ke+1)/H,ee=N[(e+ke*jt)*2],ye=N[(e+ke*jt)*2+1],ve=N[(e+(ke+1)*jt)*2],Ce=N[(e+(ke+1)*jt)*2+1],Ee=j+3*St+lr*Mt,Me=v+3*yt+lr*Ft,ge=j+3*St+qe*Mt,me=v+3*yt+qe*Ft;ie+he<=1?(w[Lt]=ee+(Ee-ee)*ie+(ve-ee)*he,w[Lt+1]=ye+(Me-ye)*ie+(Ce-ye)*he):(w[Lt]=ge+(ve-ge)*(1-ie)+(Ee-ge)*(1-he),w[Lt+1]=me+(Ce-me)*(1-ie)+(Me-me)*(1-he))}else if(Vt<=0){var Le=re|0;Le==e&&(Le=e-1);var ie=re-Le,he=.5*(Vt- -2),ir=Le/e,Ze=(Le+1)/e,ve=N[(Le+0*jt)*2],Ce=N[(Le+0*jt)*2+1],ge=N[(Le+1+0*jt)*2],me=N[(Le+1+0*jt)*2+1],ee=j+ir*St-2*Mt,ye=v+ir*yt-2*Ft,Ee=j+Ze*St-2*Mt,Me=v+Ze*yt-2*Ft;ie+he<=1?(w[Lt]=ee+(Ee-ee)*ie+(ve-ee)*he,w[Lt+1]=ye+(Me-ye)*ie+(Ce-ye)*he):(w[Lt]=ge+(ve-ge)*(1-ie)+(Ee-ge)*(1-he),w[Lt+1]=me+(Ce-me)*(1-ie)+(Me-me)*(1-he))}else if(Vt>=1){var Le=re|0;Le==e&&(Le=e-1);var ie=re-Le,he=.5*(Vt-1),ir=Le/e,Ze=(Le+1)/e,ee=N[(Le+H*jt)*2],ye=N[(Le+H*jt)*2+1],Ee=N[(Le+1+H*jt)*2],Me=N[(Le+1+H*jt)*2+1],ve=j+ir*St+3*Mt,Ce=v+ir*yt+3*Ft,ge=j+Ze*St+3*Mt,me=v+Ze*yt+3*Ft;ie+he<=1?(w[Lt]=ee+(Ee-ee)*ie+(ve-ee)*he,w[Lt+1]=ye+(Me-ye)*ie+(Ce-ye)*he):(w[Lt]=ge+(ve-ge)*(1-ie)+(Ee-ge)*(1-he),w[Lt+1]=me+(Ce-me)*(1-ie)+(Me-me)*(1-he))}else System.err.printf(`_$li calc : %.4f , %.4f @@BDBoxGrid
34
- `,K,Vt);else w[Lt]=j+K*St+Vt*Mt,w[Lt+1]=v+K*yt+Vt*Ft}else R=re-(re|0),ct=Zt-(Zt|0),rt=2*((re|0)+(Zt|0)*(e+1)),R+ct<1?(w[Lt]=N[rt]*(1-R-ct)+N[rt+2]*R+N[rt+2*(e+1)]*ct,w[Lt+1]=N[rt+1]*(1-R-ct)+N[rt+3]*R+N[rt+2*(e+1)+1]*ct):(w[Lt]=N[rt+2*(e+1)+2]*(R-1+ct)+N[rt+2*(e+1)]*(1-R)+N[rt+2]*(1-ct),w[Lt+1]=N[rt+2*(e+1)+3]*(R-1+ct)+N[rt+2*(e+1)+1]*(1-R)+N[rt+3]*(1-ct))}},Ie.prototype.transformPoints_sdk1=function(l,w,M,L,O,N,e){for(var H=w,W,rt,R=this._$o,ct=this._$A,j=O*e,v,St,yt,Mt,Ft,Nt=H._$hr!=null?H._$hr:H._$Cr,Lt=N;Lt<j;Lt+=e)Pt._$ts?(W=M[Lt],rt=M[Lt+1],W<0?W=0:W>1&&(W=1),rt<0?rt=0:rt>1&&(rt=1),W*=R,rt*=ct,v=W|0,St=rt|0,v>R-1&&(v=R-1),St>ct-1&&(St=ct-1),Mt=W-v,Ft=rt-St,yt=2*(v+St*(R+1))):(W=M[Lt]*R,rt=M[Lt+1]*ct,Mt=W-(W|0),Ft=rt-(rt|0),yt=2*((W|0)+(rt|0)*(R+1))),Mt+Ft<1?(L[Lt]=Nt[yt]*(1-Mt-Ft)+Nt[yt+2]*Mt+Nt[yt+2*(R+1)]*Ft,L[Lt+1]=Nt[yt+1]*(1-Mt-Ft)+Nt[yt+3]*Mt+Nt[yt+2*(R+1)+1]*Ft):(L[Lt]=Nt[yt+2*(R+1)+2]*(Mt-1+Ft)+Nt[yt+2*(R+1)]*(1-Mt)+Nt[yt+2]*(1-Ft),L[Lt+1]=Nt[yt+2*(R+1)+3]*(Mt-1+Ft)+Nt[yt+2*(R+1)+1]*(1-Mt)+Nt[yt+3]*(1-Ft))},Ie.prototype._$VT=function(){return(this._$o+1)*(this._$A+1)},Ie.prototype.getType=function(){return Rt._$_b};function xe(l){dr.prototype.constructor.call(this,l),this._$8r=Rt._$ur,this._$Cr=null,this._$hr=null}xe.prototype=new dr;function ae(){Xt||(this.visible=!0,this._$g0=!1,this._$NL=null,this._$3S=null,this._$aS=null,ae._$42++)}ae._$42=0,ae.prototype._$zP=function(){this._$3S=new Array,this._$aS=new Array},ae.prototype._$F0=function(l){this._$g0=l._$8L(),this.visible=l._$8L(),this._$NL=l._$nP(),this._$3S=l._$nP(),this._$aS=l._$nP()},ae.prototype.init=function(l){var w=new Lr(this);return w.setPartsOpacity(this.isVisible()?1:0),w},ae.prototype._$6o=function(l){if(this._$3S==null)throw new Error("_$3S _$6 _$Wo@_$6o");this._$3S.push(l)},ae.prototype._$3o=function(l){if(this._$aS==null)throw new Error("_$aS _$6 _$Wo@_$3o");this._$aS.push(l)},ae.prototype._$Zo=function(l){this._$3S=l},ae.prototype._$xo=function(l){this._$aS=l},ae.prototype.isVisible=function(){return this.visible},ae.prototype._$uL=function(){return this._$g0},ae.prototype._$KP=function(l){this.visible=l},ae.prototype._$ET=function(l){this._$g0=l},ae.prototype.getBaseData=function(){return this._$3S},ae.prototype.getDrawData=function(){return this._$aS},ae.prototype._$p2=function(){return this._$NL},ae.prototype._$ob=function(l){this._$NL=l},ae.prototype.getPartsID=function(){return this._$NL},ae.prototype._$MP=function(l){this._$NL=l};function Lr(l){this._$VS=null,this._$e0=null,this._$e0=l}Lr.prototype=new C,Lr.prototype.getPartsOpacity=function(){return this._$VS},Lr.prototype.setPartsOpacity=function(l){this._$VS=l};function xr(l){Xt||(this.id=l)}xr._$L7=function(){x._$27(),at._$27(),nt._$27(),T._$27()},xr.prototype.toString=function(){return this.id};function Fi(){Xt||(this._$4S=null)}Fi.prototype._$1s=function(){return this._$4S},Fi.prototype._$zP=function(){this._$4S=new Array},Fi.prototype._$F0=function(l){this._$4S=l._$nP()},Fi.prototype._$Ks=function(l){this._$4S.push(l)};function sr(l,w){this.canvas=l,this.context=w,this.viewport=new Array(0,0,l.width,l.height),this._$6r=1,this._$xP=0,this._$3r=1,this._$uP=0,this._$Qo=-1,this.cacheImages={}}sr.tr=new $t,sr._$50=new $t,sr._$Ti=new Array(0,0),sr._$Pi=new Array(0,0),sr._$B=new Array(0,0),sr.prototype._$lP=function(l,w,M,L){this.viewport=new Array(l,w,M,L)},sr.prototype._$bL=function(){this.context.save();var l=this.viewport;l!=null&&(this.context.beginPath(),this.context._$Li(l[0],l[1],l[2],l[3]),this.context.clip())},sr.prototype._$ei=function(){this.context.restore()},sr.prototype.drawElements=function(l,w,M,L,O,N,e,H){try{O!=this._$Qo&&(this._$Qo=O,this.context.globalAlpha=O);for(var W=w.length,rt=l.width,R=l.height,ct=this.context,j=this._$xP,v=this._$uP,St=this._$6r,yt=this._$3r,Mt=sr.tr,Ft=sr._$Ti,Nt=sr._$Pi,Lt=sr._$B,re=0;re<W;re+=3){ct.save();var Zt=w[re],K=w[re+1],Vt=w[re+2],jt=j+St*M[Zt*2],vt=v+yt*M[Zt*2+1],Ut=j+St*M[K*2],Fe=v+yt*M[K*2+1],We=j+St*M[Vt*2],ge=v+yt*M[Vt*2+1];e&&(e._$PS(jt,vt,Lt),jt=Lt[0],vt=Lt[1],e._$PS(Ut,Fe,Lt),Ut=Lt[0],Fe=Lt[1],e._$PS(We,ge,Lt),We=Lt[0],ge=Lt[1]);var me=rt*L[Zt*2],ve=R-R*L[Zt*2+1],Ce=rt*L[K*2],Ee=R-R*L[K*2+1],Me=rt*L[Vt*2],ee=R-R*L[Vt*2+1],ye=Math.atan2(Ee-ve,Ce-me),ie=Math.atan2(Fe-vt,Ut-jt),he=Ut-jt,ke=Fe-vt,lr=Math.sqrt(he*he+ke*ke),qe=Ce-me,Le=Ee-ve,ir=Math.sqrt(qe*qe+Le*Le),Ze=lr/ir;it._$ni(Me,ee,me,ve,Ce-me,Ee-ve,-(Ee-ve),Ce-me,Ft),it._$ni(We,ge,jt,vt,Ut-jt,Fe-vt,-(Fe-vt),Ut-jt,Nt);var gr=(Nt[0]-Ft[0])/Ft[1],Je=Math.min(me,Ce,Me),mr=Math.max(me,Ce,Me),ur=Math.min(ve,Ee,ee),kr=Math.max(ve,Ee,ee),hi=Math.floor(Je),Yr=Math.floor(ur),jr=Math.ceil(mr),cr=Math.ceil(kr);Mt.identity(),Mt.translate(jt,vt),Mt.rotate(ie),Mt.scale(1,Nt[1]/Ft[1]),Mt.shear(gr,0),Mt.scale(Ze,Ze),Mt.rotate(-ye),Mt.translate(-me,-ve),Mt.setContext(ct);var es=!0,rs=1.2;if(N||(N=es?rs:0),Pt.IGNORE_EXPAND&&(N=0),Pt.USE_CACHED_POLYGON_IMAGE){var Kr=H._$e0;if(Kr.gl_cacheImage=Kr.gl_cacheImage||{},!Kr.gl_cacheImage[re]){var ki=sr.createCanvas(jr-hi,cr-Yr);Pt.DEBUG_DATA.LDGL_CANVAS_MB=Pt.DEBUG_DATA.LDGL_CANVAS_MB||0,Pt.DEBUG_DATA.LDGL_CANVAS_MB+=(jr-hi)*(cr-Yr)*4;var li=ki.getContext("2d");li.translate(-hi,-Yr),sr.clip(li,Mt,N,lr,me,ve,Ce,Ee,Me,ee,jt,vt,Ut,Fe,We,ge),li.drawImage(l,0,0),Kr.gl_cacheImage[re]={cacheCanvas:ki,cacheContext:li}}ct.drawImage(Kr.gl_cacheImage[re].cacheCanvas,hi,Yr)}else Pt.IGNORE_CLIP||sr.clip(ct,Mt,N,lr,me,ve,Ce,Ee,Me,ee,jt,vt,Ut,Fe,We,ge),Pt.USE_ADJUST_TRANSLATION&&(Je=0,mr=rt,ur=0,kr=R),ct.drawImage(l,Je,ur,mr-Je,kr-ur,Je,ur,mr-Je,kr-ur);ct.restore()}}catch(Qe){h._$Rb(Qe)}},sr.clip=function(l,w,M,L,O,N,e,H,W,rt,R,ct,j,v,St,yt){M>.02?sr.expandClip(l,w,M,L,R,ct,j,v,St,yt):sr.clipWithTransform(l,null,O,N,e,H,W,rt)},sr.expandClip=function(l,w,M,L,O,N,e,H,W,rt){var R=e-O,ct=H-N,j=W-O,v=rt-N,St=R*v-ct*j>0?M:-M,yt=-ct,Mt=R,Ft=W-e,Nt=rt-H,Lt=-Nt,re=Ft,Zt=Math.sqrt(Ft*Ft+Nt*Nt),K=-v,Vt=j,jt=Math.sqrt(j*j+v*v),vt=O-St*yt/L,Ut=N-St*Mt/L,Fe=e-St*yt/L,We=H-St*Mt/L,ge=e-St*Lt/Zt,me=H-St*re/Zt,ve=W-St*Lt/Zt,Ce=rt-St*re/Zt,Ee=O+St*K/jt,Me=N+St*Vt/jt,ee=W+St*K/jt,ye=rt+St*Vt/jt,ie=sr._$50,he=w._$P2(ie);return he==null?!1:(sr.clipWithTransform(l,ie,vt,Ut,Fe,We,ge,me,ve,Ce,ee,ye,Ee,Me),!0)},sr.clipWithTransform=function(l,w,M,L,O,N,e,H){if(arguments.length<1+3*2){h._$li("err : @LDGL.clip()");return}if(!(arguments[1]instanceof $t)){h._$li("err : a[0] is _$6 LDTransform @LDGL.clip()");return}var W=sr._$B,rt=w,R=arguments;if(l.beginPath(),rt){rt._$PS(R[2],R[3],W),l.moveTo(W[0],W[1]);for(var ct=4;ct<R.length;ct+=2)rt._$PS(R[ct],R[ct+1],W),l.lineTo(W[0],W[1])}else{l.moveTo(R[2],R[3]);for(var ct=4;ct<R.length;ct+=2)l.lineTo(R[ct],R[ct+1])}l.clip()},sr.createCanvas=function(l,w){var M=document.createElement("canvas");return M.setAttribute("width",l),M.setAttribute("height",w),M||h._$li("err : "+M),M},sr.dumpValues=function(){for(var l="",w=0;w<arguments.length;w++)l+="["+w+"]= "+arguments[w].toFixed(3)+" , ";console.log(l)};function Wr(){Xt||(this._$TT=null,this._$LT=null,this._$FS=null,this._$wL=null)}Wr.prototype._$F0=function(l){this._$TT=l._$_T(),this._$LT=l._$_T(),this._$FS=l._$_T(),this._$wL=l._$nP()},Wr.prototype.getMinValue=function(){return this._$TT},Wr.prototype.getMaxValue=function(){return this._$LT},Wr.prototype.getDefaultValue=function(){return this._$FS},Wr.prototype.getParamID=function(){return this._$wL};function dr(l){Xt||(this._$e0=null,this._$IP=null,this._$JS=!1,this._$AT=!0,this._$e0=l,this.totalScale=1,this._$7s=1,this.totalOpacity=1)}dr.prototype._$yo=function(){return this._$AT&&!this._$JS},dr.prototype._$hS=function(l){this._$AT=l},dr.prototype._$GT=function(){return this._$e0},dr.prototype._$l2=function(l){this._$IP=l},dr.prototype.getPartsIndex=function(){return this._$IP},dr.prototype._$x2=function(){return this._$JS},dr.prototype._$Ib=function(l){this._$JS=l},dr.prototype.getTotalScale=function(){return this.totalScale},dr.prototype.setTotalScale_notForClient=function(l){this.totalScale=l},dr.prototype.getInterpolatedOpacity=function(){return this._$7s},dr.prototype.setInterpolatedOpacity=function(l){this._$7s=l},dr.prototype.getTotalOpacity=function(l){return this.totalOpacity},dr.prototype.setTotalOpacity=function(l){this.totalOpacity=l};function Pt(){}Pt._$2s="2.1.00_1",Pt._$Kr=201001e3,Pt._$sP=!0,Pt._$so=!0,Pt._$cb=!1,Pt._$3T=!0,Pt._$Ts=!0,Pt._$fb=!0,Pt._$ts=!0,Pt.L2D_DEFORMER_EXTEND=!0,Pt._$Wb=!1,Pt._$yr=!1,Pt._$Zs=!1,Pt.L2D_NO_ERROR=0,Pt._$i7=1e3,Pt._$9s=1001,Pt._$es=1100,Pt._$r7=2e3,Pt._$07=2001,Pt._$b7=2002,Pt._$H7=4e3,Pt.L2D_COLOR_BLEND_MODE_MULT=0,Pt.L2D_COLOR_BLEND_MODE_ADD=1,Pt.L2D_COLOR_BLEND_MODE_INTERPOLATE=2,Pt._$6b=!0,Pt._$cT=0,Pt.clippingMaskBufferSize=256,Pt.glContext=new Array,Pt.frameBuffers=new Array,Pt.fTexture=new Array,Pt.IGNORE_CLIP=!1,Pt.IGNORE_EXPAND=!1,Pt.EXPAND_W=2,Pt.USE_ADJUST_TRANSLATION=!0,Pt.USE_CANVAS_TRANSFORM=!0,Pt.USE_CACHED_POLYGON_IMAGE=!1,Pt.DEBUG_DATA={},Pt.PROFILE_IOS_SPEED={PROFILE_NAME:"iOS Speed",USE_ADJUST_TRANSLATION:!0,USE_CACHED_POLYGON_IMAGE:!0,EXPAND_W:4},Pt.PROFILE_IOS_QUALITY={PROFILE_NAME:"iOS HiQ",USE_ADJUST_TRANSLATION:!0,USE_CACHED_POLYGON_IMAGE:!1,EXPAND_W:2},Pt.PROFILE_IOS_DEFAULT=Pt.PROFILE_IOS_QUALITY,Pt.PROFILE_ANDROID={PROFILE_NAME:"Android",USE_ADJUST_TRANSLATION:!1,USE_CACHED_POLYGON_IMAGE:!1,EXPAND_W:2},Pt.PROFILE_DESKTOP={PROFILE_NAME:"Desktop",USE_ADJUST_TRANSLATION:!1,USE_CACHED_POLYGON_IMAGE:!1,EXPAND_W:2},Pt.initProfile=function(){Qt.isIOS()?Pt.setupProfile(Pt.PROFILE_IOS_DEFAULT):Qt.isAndroid()?Pt.setupProfile(Pt.PROFILE_ANDROID):Pt.setupProfile(Pt.PROFILE_DESKTOP)},Pt.setupProfile=function(l,w){if(typeof l=="number")switch(l){case 9901:l=Pt.PROFILE_IOS_SPEED;break;case 9902:l=Pt.PROFILE_IOS_QUALITY;break;case 9903:l=Pt.PROFILE_IOS_DEFAULT;break;case 9904:l=Pt.PROFILE_ANDROID;break;case 9905:l=Pt.PROFILE_DESKTOP;break;default:alert("profile _$6 _$Ui : "+l);break}arguments.length<2&&(w=!0),w&&console.log("profile : "+l.PROFILE_NAME);for(var M in l)Pt[M]=l[M],w&&console.log(" ["+M+"] = "+l[M])},Pt.init=function(){Pt._$6b&&(console.log("Live2D %s",Pt._$2s),Pt._$6b=!1,Pt.initProfile())},Pt.getVersionStr=function(){return Pt._$2s},Pt.getVersionNo=function(){return Pt._$Kr},Pt._$sT=function(l){Pt._$cT=l},Pt.getError=function(){var l=Pt._$cT;return Pt._$cT=0,l},Pt.dispose=function(){Pt.glContext=[],Pt.frameBuffers=[],Pt.fTexture=[]},Pt.setGL=function(l,w){var M=w||0;Pt.glContext[M]=l},Pt.getGL=function(l){return Pt.glContext[l]},Pt.setClippingMaskBufferSize=function(l){Pt.clippingMaskBufferSize=l},Pt.getClippingMaskBufferSize=function(){return Pt.clippingMaskBufferSize},Pt.deleteBuffer=function(l){var w=Pt.getGL(l);w.deleteFramebuffer(Pt.frameBuffers[l].framebuffer),delete Pt.frameBuffers[l],delete Pt.glContext[l]};function wr(){}wr._$r2=function(l){return l<0?0:l>1?1:.5-.5*Math.cos(l*Xe.PI_F)};function Hr(l){Xt||(this._$ib=l)}Hr._$fr=-1,Hr.prototype.toString=function(){return this._$ib};function ze(){Xt||(Bt.prototype.constructor.call(this),this._$LP=-1,this._$d0=0,this._$Yo=0,this._$JP=null,this._$5P=null,this._$BP=null,this._$Eo=null,this._$Qi=null,this._$6s=ze._$ms,this.culling=!0,this.gl_cacheImage=null,this.instanceNo=ze._$42++)}ze.prototype=new Bt,ze._$42=0,ze._$Os=30,ze._$ms=0,ze._$ns=1,ze._$_s=2,ze._$gT=new Array,ze.prototype._$_S=function(l){this._$LP=l},ze.prototype.getTextureNo=function(){return this._$LP},ze.prototype._$ZL=function(){return this._$Qi},ze.prototype._$H2=function(){return this._$JP},ze.prototype.getNumPoints=function(){return this._$d0},ze.prototype.getType=function(){return Bt._$wb},ze.prototype._$B2=function(l,w,M){var L=w,O=L._$hr!=null?L._$hr:L._$Cr,N=ot._$do;switch(N){default:case ot._$Ms:throw new Error("_$L _$ro ");case ot._$Qs:for(var e=this._$d0-1;e>=0;--e){var H=e*ot._$No;O[H+4]=M}break}},ze.prototype._$zP=function(){this._$GS=new Gt,this._$GS._$zP()},ze.prototype._$F0=function(l){Bt.prototype._$F0.call(this,l),this._$LP=l._$6L(),this._$d0=l._$6L(),this._$Yo=l._$6L();var w=l._$nP();this._$BP=new Int16Array(this._$Yo*3);for(var M=this._$Yo*3-1;M>=0;--M)this._$BP[M]=w[M];if(this._$Eo=l._$nP(),this._$Qi=l._$nP(),l.getFormatVersion()>=ht._$s7){if(this._$JP=l._$6L(),this._$JP!=0){if((this._$JP&1)!=0){var L=l._$6L();this._$5P==null&&(this._$5P=new Object),this._$5P._$Hb=parseInt(L)}(this._$JP&ze._$Os)!=0?this._$6s=(this._$JP&ze._$Os)>>1:this._$6s=ze._$ms,(this._$JP&32)!=0&&(this.culling=!1)}}else this._$JP=0},ze.prototype.init=function(l){var w=new Li(this),M=this._$d0*ot._$No,L=this._$32();w._$Cr!=null&&(w._$Cr=null),w._$Cr=new Float32Array(M),w._$hr!=null&&(w._$hr=null),w._$hr=L?new Float32Array(M):null;var O=ot._$do;switch(O){default:case ot._$Ms:if(ot._$Ls)for(var N=this._$d0-1;N>=0;--N){var e=N<<1;this._$Qi[e+1]=1-this._$Qi[e+1]}break;case ot._$Qs:for(var N=this._$d0-1;N>=0;--N){var e=N<<1,H=N*ot._$No,W=this._$Qi[e],rt=this._$Qi[e+1];w._$Cr[H]=W,w._$Cr[H+1]=rt,w._$Cr[H+4]=0,L&&(w._$hr[H]=W,w._$hr[H+1]=rt,w._$hr[H+4]=0)}break}return w},ze.prototype._$Nr=function(l,w){var M=w;if(this!=M._$GT()&&console.log("### assert!! ### "),!!this._$GS._$Ur(l)&&(Bt.prototype._$Nr.call(this,l,M),!M._$IS[0])){var L=ze._$gT;L[0]=!1,_t._$Vr(l,this._$GS,L,this._$d0,this._$Eo,M._$Cr,ot._$i2,ot._$No)}},ze.prototype._$2b=function(l,w){try{this!=w._$GT()&&console.log("### assert!! ### ");var M=!1;w._$IS[0]&&(M=!0);var L=w;if(!M&&(Bt.prototype._$2b.call(this,l),this._$32())){var O=this.getTargetBaseDataID();if(L._$8r==Bt._$ur&&(L._$8r=l.getBaseDataIndex(O)),L._$8r<0)Pt._$so&&h._$li("_$L _$0P _$G :: %s",O);else{var N=l.getBaseData(L._$8r),e=l._$q2(L._$8r);N!=null&&!e._$x2()?(N._$nb(l,e,L._$Cr,L._$hr,this._$d0,ot._$i2,ot._$No),L._$AT=!0):L._$AT=!1,L.baseOpacity=e.getTotalOpacity()}}}catch(H){throw H}},ze.prototype.draw=function(l,w,M){if(this!=M._$GT()&&console.log("### assert!! ### "),!M._$IS[0]){var L=M,O=this._$LP;O<0&&(O=1);var N=this.getOpacity(w,L)*M._$VS*M.baseOpacity,e=L._$hr!=null?L._$hr:L._$Cr;l.setClipBufPre_clipContextForDraw(M.clipBufPre_clipContext),l._$WP(this.culling),l._$Uo(O,3*this._$Yo,this._$BP,e,this._$Qi,N,this._$6s,L)}},ze.prototype.dump=function(){console.log(` _$yi( %d ) , _$d0( %d ) , _$Yo( %d )
35
- `,this._$LP,this._$d0,this._$Yo),console.log(" _$Oi _$di = { ");for(var l=0;l<this._$BP.length;l++)console.log("%5d ,",this._$BP[l]);console.log(`
36
- _$5i _$30`);for(var l=0;l<this._$Eo.length;l++){console.log(`
37
- _$30[%d] = `,l);for(var w=this._$Eo[l],M=0;M<w.length;M++)console.log("%6.2f, ",w[M])}console.log(`
38
- `)},ze.prototype._$72=function(l){return this._$5P==null?null:this._$5P[l]},ze.prototype.getIndexArray=function(){return this._$BP};function Li(l){je.prototype.constructor.call(this,l),this._$8r=Bt._$ur,this._$Cr=null,this._$hr=null}Li.prototype=new je,Li.prototype.getTransformedPoints=function(){return this._$hr!=null?this._$hr:this._$Cr};function Ds(){Xt||(this.x=null,this.y=null)}Ds.prototype._$HT=function(l){this.x=l.x,this.y=l.y},Ds.prototype._$HT=function(l,w){this.x=l,this.y=w};function hr(l){Xt||(s.prototype.constructor.call(this),this.drawParamWebGL=new lt(l),this.drawParamWebGL.setGL(Pt.getGL(l)))}hr.prototype=new s,hr.loadModel=function(l){var w=new hr;return s._$62(w,l),w},hr.loadModel=function(l,w){var M=w||0,L=new hr(M);return s._$62(L,l),L},hr._$to=function(){var l=new hr;return l},hr._$er=function(l){var w=new _$5("../_$_r/_$t0/_$Ri/_$_P._$d");if(w.exists()==!1)throw new _$ls("_$t0 _$_ _$6 _$Ui :: "+w._$PL());for(var M=["../_$_r/_$t0/_$Ri/_$_P.512/_$CP._$1","../_$_r/_$t0/_$Ri/_$_P.512/_$vP._$1","../_$_r/_$t0/_$Ri/_$_P.512/_$EP._$1","../_$_r/_$t0/_$Ri/_$_P.512/_$pP._$1"],L=hr.loadModel(w._$3b()),O=0;O<M.length;O++){var N=new _$5(M[O]);if(N.exists()==!1)throw new _$ls("_$t0 _$_ _$6 _$Ui :: "+N._$PL());L.setTexture(O,_$nL._$_o(l,N._$3b()))}return L},hr.prototype.setGL=function(l){Pt.setGL(l)},hr.prototype.setTransform=function(l){this.drawParamWebGL.setTransform(l)},hr.prototype.update=function(){this._$5S.update(),this._$5S.preDraw(this.drawParamWebGL)},hr.prototype.draw=function(){this._$5S.draw(this.drawParamWebGL)},hr.prototype._$K2=function(){this.drawParamWebGL._$K2()},hr.prototype.setTexture=function(l,w){this.drawParamWebGL==null&&h._$li("_$Yi for QT _$ki / _$XS() is _$6 _$ui!!"),this.drawParamWebGL.setTexture(l,w)},hr.prototype.setTexture=function(l,w){this.drawParamWebGL==null&&h._$li("_$Yi for QT _$ki / _$XS() is _$6 _$ui!!"),this.drawParamWebGL.setTexture(l,w)},hr.prototype._$Rs=function(){return this.drawParamWebGL._$Rs()},hr.prototype._$Ds=function(l){this.drawParamWebGL._$Ds(l)},hr.prototype.getDrawParam=function(){return this.drawParamWebGL},hr.prototype.setMatrix=function(l){this.drawParamWebGL.setMatrix(l)},hr.prototype.setPremultipliedAlpha=function(l){this.drawParamWebGL.setPremultipliedAlpha(l)},hr.prototype.isPremultipliedAlpha=function(){return this.drawParamWebGL.isPremultipliedAlpha()},hr.prototype.setAnisotropy=function(l){this.drawParamWebGL.setAnisotropy(l)},hr.prototype.getAnisotropy=function(){return this.drawParamWebGL.getAnisotropy()};function Qr(){Xt||(this.motions=null,this._$eb=!1,this.motions=new Array)}Qr.prototype._$tb=function(){return this.motions},Qr.prototype.startMotion=function(l,w){for(var M=null,L=this.motions.length,O=0;O<L;++O)M=this.motions[O],M!=null&&(M._$qS(M._$w0.getFadeOut()),this._$eb&&h._$Ji(`MotionQueueManager[size:%2d]->startMotion() / start _$K _$3 (m%d)
39
- `,L,M._$sr));if(l==null)return-1;M=new Tt,M._$w0=l,this.motions.push(M);var N=M._$sr;return this._$eb&&h._$Ji(`MotionQueueManager[size:%2d]->startMotion() / new _$w0 (m%d)
40
- `,L,N),N},Qr.prototype.updateParam=function(l){try{for(var w=!1,M=0;M<this.motions.length;M++){var L=this.motions[M];if(L==null){this.motions.splice(M,1),M--;continue}var O=L._$w0;if(O==null){this.motions=this.motions.splice(M,1),M--;continue}O.updateParam(l,L),w=!0,L.isFinished()&&(this._$eb&&h._$Ji(`MotionQueueManager[size:%2d]->updateParam() / _$T0 _$w0 (m%d)
41
- `,this.motions.length-1,L._$sr),this.motions.splice(M,1),M--)}return w}catch(N){return h._$li(N),!0}},Qr.prototype.isFinished=function(l){if(arguments.length>=1){for(var w=0;w<this.motions.length;w++){var M=this.motions[w];if(M!=null&&M._$sr==l&&!M.isFinished())return!1}return!0}else{for(var w=0;w<this.motions.length;w++){var M=this.motions[w];if(M==null){this.motions.splice(w,1),w--;continue}var L=M._$w0;if(L==null){this.motions.splice(w,1),w--;continue}if(!M.isFinished())return!1}return!0}},Qr.prototype.stopAllMotions=function(){for(var l=0;l<this.motions.length;l++){var w=this.motions[l];if(w==null){this.motions.splice(l,1),l--;continue}var M=w._$w0;if(M==null){this.motions.splice(l,1),l--;continue}this.motions.splice(l,1),l--}},Qr.prototype._$Zr=function(l){this._$eb=l},Qr.prototype._$e=function(){console.log(`-- _$R --
42
- `);for(var l=0;l<this.motions.length;l++){var w=this.motions[l],M=w._$w0;console.log(`MotionQueueEnt[%d] :: %s
43
- `,this.motions.length,M.toString())}};function Tt(){this._$w0=null,this._$AT=!0,this._$9L=!1,this._$z2=-1,this._$bs=-1,this._$Do=-1,this._$sr=null,this._$sr=Tt._$Gs++}Tt._$Gs=0,Tt.prototype.isFinished=function(){return this._$9L},Tt.prototype._$qS=function(l){var w=pt.getUserTimeMSec(),M=w+l;(this._$Do<0||M<this._$Do)&&(this._$Do=M)},Tt.prototype._$Bs=function(){return this._$sr};function $t(){this.m=new Array(1,0,0,0,1,0,0,0,1)}$t.prototype.setContext=function(l){var w=this.m;l.transform(w[0],w[1],w[3],w[4],w[6],w[7])},$t.prototype.toString=function(){for(var l="LDTransform { ",w=0;w<9;w++)l+=this.m[w].toFixed(2)+" ,";return l+=" }",l},$t.prototype.identity=function(){var l=this.m;l[0]=l[4]=l[8]=1,l[1]=l[2]=l[3]=l[5]=l[6]=l[7]=0},$t.prototype._$PS=function(l,w,M){M==null&&(M=new Array(0,0));var L=this.m;return M[0]=L[0]*l+L[3]*w+L[6],M[1]=L[1]*l+L[4]*w+L[7],M},$t.prototype._$P2=function(l){l||(l=new $t);var w=this.m,M=w[0],L=w[1],O=w[2],N=w[3],e=w[4],H=w[5],W=w[6],rt=w[7],R=w[8],ct=M*e*R+L*H*W+O*N*rt-M*H*rt-O*e*W-L*N*R;if(ct==0)return null;var j=1/ct;return l.m[0]=j*(e*R-rt*H),l.m[1]=j*(rt*O-L*R),l.m[2]=j*(L*H-e*O),l.m[3]=j*(W*H-N*R),l.m[4]=j*(M*R-W*O),l.m[5]=j*(N*O-M*H),l.m[6]=j*(N*rt-W*e),l.m[7]=j*(W*L-M*rt),l.m[8]=j*(M*e-N*L),l},$t.prototype.transform=function(l,w,M){M==null&&(M=new Array(0,0));var L=this.m;return M[0]=L[0]*l+L[3]*w+L[6],M[1]=L[1]*l+L[4]*w+L[7],M},$t.prototype.translate=function(l,w){var M=this.m;M[6]=M[0]*l+M[3]*w+M[6],M[7]=M[1]*l+M[4]*w+M[7],M[8]=M[2]*l+M[5]*w+M[8]},$t.prototype.scale=function(l,w){var M=this.m;M[0]*=l,M[1]*=l,M[2]*=l,M[3]*=w,M[4]*=w,M[5]*=w},$t.prototype.shear=function(l,w){var M=this.m,L=M[0]+M[3]*w,O=M[1]+M[4]*w,N=M[2]+M[5]*w;M[3]=M[0]*l+M[3],M[4]=M[1]*l+M[4],M[5]=M[2]*l+M[5],M[0]=L,M[1]=O,M[2]=N},$t.prototype.rotate=function(l){var w=this.m,M=Math.cos(l),L=Math.sin(l),O=w[0]*M+w[3]*L,N=w[1]*M+w[4]*L,e=w[2]*M+w[5]*L;w[3]=-w[0]*L+w[3]*M,w[4]=-w[1]*L+w[4]*M,w[5]=-w[2]*L+w[5]*M,w[0]=O,w[1]=N,w[2]=e},$t.prototype.concatenate=function(l){var w=this.m,M=l.m,L=w[0]*M[0]+w[3]*M[1]+w[6]*M[2],O=w[1]*M[0]+w[4]*M[1]+w[7]*M[2],N=w[2]*M[0]+w[5]*M[1]+w[8]*M[2],e=w[0]*M[3]+w[3]*M[4]+w[6]*M[5],H=w[1]*M[3]+w[4]*M[4]+w[7]*M[5],W=w[2]*M[3]+w[5]*M[4]+w[8]*M[5],rt=w[0]*M[6]+w[3]*M[7]+w[6]*M[8],R=w[1]*M[6]+w[4]*M[7]+w[7]*M[8],ct=w[2]*M[6]+w[5]*M[7]+w[8]*M[8];m[0]=L,m[1]=O,m[2]=N,m[3]=e,m[4]=H,m[5]=W,m[6]=rt,m[7]=R,m[8]=ct};function at(l){Xt||xr.prototype.constructor.call(this,l)}at.prototype=new xr,at._$eT=null,at._$tP=new Object,at._$2o=function(){return at._$eT==null&&(at._$eT=at.getID("DST_BASE")),at._$eT},at._$27=function(){at._$tP.clear(),at._$eT=null},at.getID=function(l){var w=at._$tP[l];return w==null&&(w=new at(l),at._$tP[l]=w),w},at.prototype._$3s=function(){return new at};function lt(l){Xt||(wt.prototype.constructor.call(this),this.textures=new Array,this.transform=null,this.gl=null,this.glno=l,this.firstDraw=!0,this.anisotropyExt=null,this.maxAnisotropy=0,this._$As=32,this._$Gr=!1,this._$NT=null,this._$vS=null,this._$no=null,this.vertShader=null,this.fragShader=null,this.vertShaderOff=null,this.fragShaderOff=null)}lt.prototype=new wt,lt._$9r=function(l){var w=new Float32Array(l);return w},lt._$vb=function(l){var w=new Int16Array(l);return w},lt._$cr=function(l,w){return l==null||l._$yL()<w.length?(l=lt._$9r(w.length*2),l.put(w),l._$oT(0)):(l.clear(),l.put(w),l._$oT(0)),l},lt._$mb=function(l,w){return l==null||l._$yL()<w.length?(l=lt._$vb(w.length*2),l.put(w),l._$oT(0)):(l.clear(),l.put(w),l._$oT(0)),l},lt._$Hs=function(){return this._$Gr},lt._$as=function(l){this._$Gr=l},lt.prototype.getGL=function(){return this.gl},lt.prototype.setGL=function(l){this.gl=l},lt.prototype.setTransform=function(l){this.transform=l},lt.prototype._$ZT=function(){var l=this.gl;this.firstDraw&&(this.initShader(),this.firstDraw=!1,this.anisotropyExt=l.getExtension("EXT_texture_filter_anisotropic")||l.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||l.getExtension("MOZ_EXT_texture_filter_anisotropic"),this.anisotropyExt&&(this.maxAnisotropy=l.getParameter(this.anisotropyExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),l.disable(l.SCISSOR_TEST),l.disable(l.STENCIL_TEST),l.disable(l.DEPTH_TEST),l.frontFace(l.CW),l.enable(l.BLEND),l.colorMask(1,1,1,1),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)},lt.prototype._$Uo=function(l,w,M,L,O,N,e,H){if(!(N<.01&&this.clipBufPre_clipContextMask==null)){N>.9&&Pt.EXPAND_W;var W=this.gl;if(this.gl==null)throw new Error("gl is null");var rt=!1,R=1,ct=1,j=1,v=this._$C0*R*N,St=this._$tT*ct*N,yt=this._$WL*j*N,Mt=this._$lT*N;if(this.clipBufPre_clipContextMask!=null){W.frontFace(W.CCW),W.useProgram(this.shaderProgram),this._$vS=Wt(W,this._$vS,L),this._$no=Ae(W,this._$no,M),W.enableVertexAttribArray(this.a_position_Loc),W.vertexAttribPointer(this.a_position_Loc,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc,1),W.enableVertexAttribArray(this.a_texCoord_Loc),W.vertexAttribPointer(this.a_texCoord_Loc,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_matrix_Loc,!1,this.getClipBufPre_clipContextMask().matrixForMask);var Ft=this.getClipBufPre_clipContextMask().layoutChannelNo,Nt=this.getChannelFlagAsColor(Ft);W.uniform4f(this.u_channelFlag,Nt.r,Nt.g,Nt.b,Nt.a);var Lt=this.getClipBufPre_clipContextMask().layoutBounds;W.uniform4f(this.u_baseColor_Loc,Lt.x*2-1,Lt.y*2-1,Lt._$EL()*2-1,Lt._$5T()*2-1),W.uniform1i(this.u_maskFlag_Loc,!0)}else if(rt=this.getClipBufPre_clipContextDraw()!=null,rt){W.useProgram(this.shaderProgramOff),this._$vS=Wt(W,this._$vS,L),this._$no=Ae(W,this._$no,M),W.enableVertexAttribArray(this.a_position_Loc_Off),W.vertexAttribPointer(this.a_position_Loc_Off,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc_Off,1),W.enableVertexAttribArray(this.a_texCoord_Loc_Off),W.vertexAttribPointer(this.a_texCoord_Loc_Off,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_clipMatrix_Loc_Off,!1,this.getClipBufPre_clipContextDraw().matrixForDraw),W.uniformMatrix4fv(this.u_matrix_Loc_Off,!1,this.matrix4x4),W.activeTexture(W.TEXTURE2),W.bindTexture(W.TEXTURE_2D,Pt.fTexture[this.glno]),W.uniform1i(this.s_texture1_Loc_Off,2);var Ft=this.getClipBufPre_clipContextDraw().layoutChannelNo,Nt=this.getChannelFlagAsColor(Ft);W.uniform4f(this.u_channelFlag_Loc_Off,Nt.r,Nt.g,Nt.b,Nt.a),W.uniform4f(this.u_baseColor_Loc_Off,v,St,yt,Mt)}else W.useProgram(this.shaderProgram),this._$vS=Wt(W,this._$vS,L),this._$no=Ae(W,this._$no,M),W.enableVertexAttribArray(this.a_position_Loc),W.vertexAttribPointer(this.a_position_Loc,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc,1),W.enableVertexAttribArray(this.a_texCoord_Loc),W.vertexAttribPointer(this.a_texCoord_Loc,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_matrix_Loc,!1,this.matrix4x4),W.uniform4f(this.u_baseColor_Loc,v,St,yt,Mt),W.uniform1i(this.u_maskFlag_Loc,!1);this.culling?this.gl.enable(W.CULL_FACE):this.gl.disable(W.CULL_FACE),this.gl.enable(W.BLEND);var re,Zt,K,Vt;if(this.clipBufPre_clipContextMask!=null)re=W.ONE,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ONE,Vt=W.ONE_MINUS_SRC_ALPHA;else switch(e){case ze._$ms:re=W.ONE,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ONE,Vt=W.ONE_MINUS_SRC_ALPHA;break;case ze._$ns:re=W.ONE,Zt=W.ONE,K=W.ZERO,Vt=W.ONE;break;case ze._$_s:re=W.DST_COLOR,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ZERO,Vt=W.ONE;break}W.blendEquationSeparate(W.FUNC_ADD,W.FUNC_ADD),W.blendFuncSeparate(re,Zt,K,Vt),this.anisotropyExt&&W.texParameteri(W.TEXTURE_2D,this.anisotropyExt.TEXTURE_MAX_ANISOTROPY_EXT,this.maxAnisotropy);var jt=M.length;W.drawElements(W.TRIANGLES,jt,W.UNSIGNED_SHORT,0),W.bindTexture(W.TEXTURE_2D,null)}};function Wt(l,w,M){return w==null&&(w=l.createBuffer()),l.bindBuffer(l.ARRAY_BUFFER,w),l.bufferData(l.ARRAY_BUFFER,M,l.DYNAMIC_DRAW),w}function Ae(l,w,M){return w==null&&(w=l.createBuffer()),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,w),l.bufferData(l.ELEMENT_ARRAY_BUFFER,M,l.DYNAMIC_DRAW),w}lt.prototype._$Rs=function(){throw new Error("_$Rs")},lt.prototype._$Ds=function(l){throw new Error("_$Ds")},lt.prototype._$K2=function(){for(var l=0;l<this.textures.length;l++){var w=this.textures[l];w!=0&&(this.gl._$K2(1,this.textures,l),this.textures[l]=null)}},lt.prototype.setTexture=function(l,w){this.textures[l]=w},lt.prototype.initShader=function(){var l=this.gl;this.loadShaders2(),this.a_position_Loc=l.getAttribLocation(this.shaderProgram,"a_position"),this.a_texCoord_Loc=l.getAttribLocation(this.shaderProgram,"a_texCoord"),this.u_matrix_Loc=l.getUniformLocation(this.shaderProgram,"u_mvpMatrix"),this.s_texture0_Loc=l.getUniformLocation(this.shaderProgram,"s_texture0"),this.u_channelFlag=l.getUniformLocation(this.shaderProgram,"u_channelFlag"),this.u_baseColor_Loc=l.getUniformLocation(this.shaderProgram,"u_baseColor"),this.u_maskFlag_Loc=l.getUniformLocation(this.shaderProgram,"u_maskFlag"),this.a_position_Loc_Off=l.getAttribLocation(this.shaderProgramOff,"a_position"),this.a_texCoord_Loc_Off=l.getAttribLocation(this.shaderProgramOff,"a_texCoord"),this.u_matrix_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_mvpMatrix"),this.u_clipMatrix_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_ClipMatrix"),this.s_texture0_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"s_texture0"),this.s_texture1_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"s_texture1"),this.u_channelFlag_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_channelFlag"),this.u_baseColor_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_baseColor")},lt.prototype.disposeShader=function(){var l=this.gl;this.shaderProgram&&(l.deleteProgram(this.shaderProgram),this.shaderProgram=null),this.shaderProgramOff&&(l.deleteProgram(this.shaderProgramOff),this.shaderProgramOff=null)},lt.prototype.compileShader=function(l,w){var M=this.gl,N,L=w,O=M.createShader(l);if(O==null)return h._$Ji("_$L0 to create shader"),null;M.shaderSource(O,L),M.compileShader(O);var N=M.getShaderParameter(O,M.COMPILE_STATUS);if(!N){var e=M.getShaderInfoLog(O);return h._$Ji("_$L0 to compile shader : "+e),M.deleteShader(O),null}return O},lt.prototype.loadShaders2=function(){var l=this.gl;if(this.shaderProgram=l.createProgram(),!this.shaderProgram||(this.shaderProgramOff=l.createProgram(),!this.shaderProgramOff))return!1;var w="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform mat4 u_mvpMatrix;void main(){ gl_Position = u_mvpMatrix * a_position; v_ClipPos = u_mvpMatrix * a_position; v_texCoord = a_texCoord;}",M="precision mediump float;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform sampler2D s_texture0;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform bool u_maskFlag;void main(){ vec4 smpColor; if(u_maskFlag){ float isInside = step(u_baseColor.x, v_ClipPos.x/v_ClipPos.w) * step(u_baseColor.y, v_ClipPos.y/v_ClipPos.w) * step(v_ClipPos.x/v_ClipPos.w, u_baseColor.z) * step(v_ClipPos.y/v_ClipPos.w, u_baseColor.w); smpColor = u_channelFlag * texture2D(s_texture0 , v_texCoord).a * isInside; }else{ smpColor = texture2D(s_texture0 , v_texCoord) * u_baseColor; } gl_FragColor = smpColor;}",L="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform mat4 u_mvpMatrix;uniform mat4 u_ClipMatrix;void main(){ gl_Position = u_mvpMatrix * a_position; v_ClipPos = u_ClipMatrix * a_position; v_texCoord = a_texCoord ;}",O="precision mediump float ;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor ;void main(){ vec4 col_formask = texture2D(s_texture0, v_texCoord) * u_baseColor; vec4 clipMask = texture2D(s_texture1, v_ClipPos.xy / v_ClipPos.w) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}";if(this.vertShader=this.compileShader(l.VERTEX_SHADER,w),!this.vertShader)return h._$Ji("Vertex shader compile _$li!"),!1;if(this.vertShaderOff=this.compileShader(l.VERTEX_SHADER,L),!this.vertShaderOff)return h._$Ji("OffVertex shader compile _$li!"),!1;if(this.fragShader=this.compileShader(l.FRAGMENT_SHADER,M),!this.fragShader)return h._$Ji("Fragment shader compile _$li!"),!1;if(this.fragShaderOff=this.compileShader(l.FRAGMENT_SHADER,O),!this.fragShaderOff)return h._$Ji("OffFragment shader compile _$li!"),!1;l.attachShader(this.shaderProgram,this.vertShader),l.attachShader(this.shaderProgram,this.fragShader),l.attachShader(this.shaderProgramOff,this.vertShaderOff),l.attachShader(this.shaderProgramOff,this.fragShaderOff),l.linkProgram(this.shaderProgram),l.linkProgram(this.shaderProgramOff);var N=l.getProgramParameter(this.shaderProgram,l.LINK_STATUS);if(!N){var e=l.getProgramInfoLog(this.shaderProgram);return h._$Ji("_$L0 to link program: "+e),this.vertShader&&(l.deleteShader(this.vertShader),this.vertShader=0),this.fragShader&&(l.deleteShader(this.fragShader),this.fragShader=0),this.shaderProgram&&(l.deleteProgram(this.shaderProgram),this.shaderProgram=0),this.vertShaderOff&&(l.deleteShader(this.vertShaderOff),this.vertShaderOff=0),this.fragShaderOff&&(l.deleteShader(this.fragShaderOff),this.fragShaderOff=0),this.shaderProgramOff&&(l.deleteProgram(this.shaderProgramOff),this.shaderProgramOff=0),!1}return!0},lt.prototype.createFramebuffer=function(){var l=this.gl,w=Pt.clippingMaskBufferSize,M=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,M);var L=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,L),l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,w,w),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.RENDERBUFFER,L);var O=l.createTexture();return l.bindTexture(l.TEXTURE_2D,O),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,w,w,0,l.RGBA,l.UNSIGNED_BYTE,null),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,O,0),l.bindTexture(l.TEXTURE_2D,null),l.bindRenderbuffer(l.RENDERBUFFER,null),l.bindFramebuffer(l.FRAMEBUFFER,null),Pt.fTexture[this.glno]=O,{framebuffer:M,renderbuffer:L,texture:Pt.fTexture[this.glno]}};function de(l){Xt||(this._$P=new Int8Array(8),this._$R0=new DataView(this._$P.buffer),this._$3i=new Int8Array(1e3),this._$hL=0,this._$v0=0,this._$S2=0,this._$Ko=new Array,this._$T=l,this._$F=0)}de.prototype._$fP=function(){var l=this._$ST(),w,M,L;if((l&128)==0)return l&255;if(((w=this._$ST())&128)==0)return(l&127)<<7|w&127;if(((M=this._$ST())&128)==0)return(l&127)<<14|(w&127)<<7|M&255;if(((L=this._$ST())&128)==0)return(l&127)<<21|(w&127)<<14|(M&127)<<7|L&255;throw new Hr("_$L _$0P _")},de.prototype.getFormatVersion=function(){return this._$S2},de.prototype._$gr=function(l){this._$S2=l},de.prototype._$3L=function(){return this._$fP()},de.prototype._$mP=function(){return this._$zT(),this._$F+=8,this._$T.getFloat64(this._$F-8)},de.prototype._$_T=function(){return this._$zT(),this._$F+=4,this._$T.getFloat32(this._$F-4)},de.prototype._$6L=function(){return this._$zT(),this._$F+=4,this._$T.getInt32(this._$F-4)},de.prototype._$ST=function(){return this._$zT(),this._$T.getInt8(this._$F++)},de.prototype._$9T=function(){return this._$zT(),this._$F+=2,this._$T.getInt16(this._$F-2)},de.prototype._$2T=function(){throw this._$zT(),this._$F+=8,new Hr("_$L _$q read long")},de.prototype._$po=function(){return this._$zT(),this._$T.getInt8(this._$F++)!=0};var Yt=!0;de.prototype._$bT=function(){this._$zT();var l=this._$3L(),w=null;if(Yt)try{var M=new ArrayBuffer(l*2);w=new Uint16Array(M);for(var L=0;L<l;++L)w[L]=this._$T.getUint8(this._$F++);return String.fromCharCode.apply(null,w)}catch{Yt=!1}try{var O=new Array;if(w==null)for(var L=0;L<l;++L)O[L]=this._$T.getUint8(this._$F++);else for(var L=0;L<l;++L)O[L]=w[L];return String.fromCharCode.apply(null,O)}catch(N){console.log("read utf8 / _$rT _$L0 !! : "+N)}},de.prototype._$cS=function(){this._$zT();for(var l=this._$3L(),w=new Int32Array(l),M=0;M<l;M++)w[M]=this._$T.getInt32(this._$F),this._$F+=4;return w},de.prototype._$Tb=function(){this._$zT();for(var l=this._$3L(),w=new Float32Array(l),M=0;M<l;M++)w[M]=this._$T.getFloat32(this._$F),this._$F+=4;return w},de.prototype._$5b=function(){this._$zT();for(var l=this._$3L(),w=new Float64Array(l),M=0;M<l;M++)w[M]=this._$T.getFloat64(this._$F),this._$F+=8;return w},de.prototype._$nP=function(){return this._$Jb(-1)},de.prototype._$Jb=function(l){if(this._$zT(),l<0&&(l=this._$3L()),l==ht._$7P){var w=this._$6L();if(0<=w&&w<this._$Ko.length)return this._$Ko[w];throw new Hr("_$sL _$4i @_$m0")}else{var M=this._$4b(l);return this._$Ko.push(M),M}},de.prototype._$4b=function(l){if(l==0)return null;if(l==50){var w=this._$bT(),M=nt.getID(w);return M}else if(l==51){var w=this._$bT(),M=at.getID(w);return M}else if(l==134){var w=this._$bT(),M=T.getID(w);return M}else if(l==60){var w=this._$bT(),M=x.getID(w);return M}if(l>=48){var L=ht._$9o(l);return L!=null?(L._$F0(this),L):null}switch(l){case 1:return this._$bT();case 10:return this._$6L(),new n;case 11:return new Q(this._$mP(),this._$mP(),this._$mP(),this._$mP());case 12:return new Q(this._$_T(),this._$_T(),this._$_T(),this._$_T());case 13:return new et(this._$mP(),this._$mP());case 14:return new et(this._$_T(),this._$_T());case 15:for(var O=this._$3L(),M=new Array(O),N=0;N<O;N++)M[N]=this._$nP();return M;case 17:var M=new Y(this._$mP(),this._$mP(),this._$mP(),this._$mP(),this._$mP(),this._$mP());return M;case 21:return new b(this._$6L(),this._$6L(),this._$6L(),this._$6L());case 22:return new Ds(this._$6L(),this._$6L());case 23:throw new Error("_$L _$ro ");case 16:case 25:return this._$cS();case 26:return this._$5b();case 27:return this._$Tb();case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 18:case 19:case 20:case 24:case 28:throw new Hr("_$6 _$q : _$nP() of 2-9 ,18,19,20,24,28 : "+l);default:throw new Hr("_$6 _$q : _$nP() NO _$i : "+l)}},de.prototype._$8L=function(){return this._$hL==0?this._$v0=this._$ST():this._$hL==8&&(this._$v0=this._$ST(),this._$hL=0),(this._$v0>>7-this._$hL++&1)==1},de.prototype._$zT=function(){this._$hL!=0&&(this._$hL=0)};function Xe(){}Xe._$2S=Math.PI/180,Xe._$bS=Math.PI/180,Xe._$wS=180/Math.PI,Xe._$NS=180/Math.PI,Xe.PI_F=Math.PI,Xe._$kT=[0,.012368,.024734,.037097,.049454,.061803,.074143,.086471,.098786,.111087,.12337,.135634,.147877,.160098,.172295,.184465,.196606,.208718,.220798,.232844,.244854,.256827,.268761,.280654,.292503,.304308,.316066,.327776,.339436,.351044,.362598,.374097,.385538,.396921,.408243,.419502,.430697,.441826,.452888,.463881,.474802,.485651,.496425,.507124,.517745,.528287,.538748,.549126,.559421,.56963,.579752,.589785,.599728,.609579,.619337,.629,.638567,.648036,.657406,.666676,.675843,.684908,.693867,.70272,.711466,.720103,.72863,.737045,.745348,.753536,.76161,.769566,.777405,.785125,.792725,.800204,.807561,.814793,.821901,.828884,.835739,.842467,.849066,.855535,.861873,.868079,.874153,.880093,.885898,.891567,.897101,.902497,.907754,.912873,.917853,.922692,.92739,.931946,.936359,.940629,.944755,.948737,.952574,.956265,.959809,.963207,.966457,.96956,.972514,.97532,.977976,.980482,.982839,.985045,.987101,.989006,.990759,.992361,.993811,.995109,.996254,.997248,.998088,.998776,.999312,.999694,.999924,1],Xe._$92=function(l,w){var M=Math.atan2(l[1],l[0]),L=Math.atan2(w[1],w[0]);return Xe._$tS(M,L)},Xe._$tS=function(l,w){for(var M=l-w;M<-Math.PI;)M+=2*Math.PI;for(;M>Math.PI;)M-=2*Math.PI;return M},Xe._$9=function(l){return Math.sin(l)},Xe.fcos=function(l){return Math.cos(l)};function je(l){Xt||(this._$e0=null,this._$IP=null,this._$Us=null,this._$7s=null,this._$IS=[!1],this._$VS=null,this._$AT=!0,this.baseOpacity=1,this.clipBufPre_clipContext=null,this._$e0=l)}je.prototype._$u2=function(){return this._$IS[0]},je.prototype._$yo=function(){return this._$AT&&!this._$IS[0]},je.prototype._$GT=function(){return this._$e0};function Qt(){}Qt._$W2=0,Qt.SYSTEM_INFO=null,Qt.USER_AGENT=navigator.userAgent,Qt.isIPhone=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone},Qt.isIOS=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone||Qt.SYSTEM_INFO._isIPad},Qt.isAndroid=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isAndroid},Qt.getOSVersion=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO.version},Qt.getOS=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone||Qt.SYSTEM_INFO._isIPad?"iOS":Qt.SYSTEM_INFO._isAndroid?"Android":"_$Q0 OS"},Qt.setup=function(){var l=Qt.USER_AGENT;function w(O,N){for(var e=O.substring(N).split(/[ _,;\.]/),H=0,W=0;W<=2&&!isNaN(e[W]);W++){var rt=parseInt(e[W]);if(rt<0||rt>999){h._$li("err : "+rt+" @UtHtml5.setup()"),H=0;break}H+=rt*Math.pow(1e3,2-W)}return H}var M,L=Qt.SYSTEM_INFO={userAgent:l};if((M=l.indexOf("iPhone OS "))>=0)L.os="iPhone",L._isIPhone=!0,L.version=w(l,M+10);else if((M=l.indexOf("iPad"))>=0){if(M=l.indexOf("CPU OS"),M<0){h._$li(" err : "+l+" @UtHtml5.setup()");return}L.os="iPad",L._isIPad=!0,L.version=w(l,M+7)}else(M=l.indexOf("Android"))>=0?(L.os="Android",L._isAndroid=!0,L.version=w(l,M+8)):(L.os="-",L.version=-1)},window.UtSystem=pt,window.UtDebug=h,window.LDTransform=$t,window.LDGL=sr,window.Live2D=Pt,window.Live2DModelWebGL=hr,window.Live2DModelJS=Jt,window.Live2DMotion=zt,window.MotionQueueManager=Qr,window.PhysicsHair=I,window.AMotion=o,window.PartsDataID=T,window.DrawDataID=nt,window.BaseDataID=at,window.ParamID=x,Pt.init();var Xt=!1})();var Is;(function(s){var t,r=function(){function C(){}return C.getVersion=function(){return T.ccall("csmGetVersion","number",[],[])},C.getLatestMocVersion=function(){return T.ccall("csmGetLatestMocVersion","number",[],[])},C.getMocVersion=function(x,$){return T.ccall("csmGetMocVersion","number",["number","number"],[x,$])},C.getLogFunction=function(){return T.ccall("csmGetLogFunction","number",[],[])},C.getSizeofModel=function(x){return T.ccall("csmGetSizeofModel","number",["number"],[x])},C.reviveMocInPlace=function(x,$){return T.ccall("csmReviveMocInPlace","number",["number","number"],[x,$])},C.initializeModelInPlace=function(x,$,I){return T.ccall("csmInitializeModelInPlace","number",["number","number","number"],[x,$,I])},C.hasMocConsistency=function(x,$){return T.ccall("csmHasMocConsistency","number",["number","number"],[x,$])},C.getParameterCount=function(x){return T.ccall("csmGetParameterCount","number",["number"],[x])},C.getParameterIds=function(x){return T.ccall("csmGetParameterIds","number",["number"],[x])},C.getParameterMinimumValues=function(x){return T.ccall("csmGetParameterMinimumValues","number",["number"],[x])},C.getParameterTypes=function(x){return T.ccall("csmGetParameterTypes","number",["number"],[x])},C.getParameterMaximumValues=function(x){return T.ccall("csmGetParameterMaximumValues","number",["number"],[x])},C.getParameterDefaultValues=function(x){return T.ccall("csmGetParameterDefaultValues","number",["number"],[x])},C.getParameterValues=function(x){return T.ccall("csmGetParameterValues","number",["number"],[x])},C.getParameterKeyCounts=function(x){return T.ccall("csmGetParameterKeyCounts","number",["number"],[x])},C.getParameterKeyValues=function(x){return T.ccall("csmGetParameterKeyValues","number",["number"],[x])},C.getPartCount=function(x){return T.ccall("csmGetPartCount","number",["number"],[x])},C.getPartIds=function(x){return T.ccall("csmGetPartIds","number",["number"],[x])},C.getPartOpacities=function(x){return T.ccall("csmGetPartOpacities","number",["number"],[x])},C.getPartParentPartIndices=function(x){return T.ccall("csmGetPartParentPartIndices","number",["number"],[x])},C.getDrawableCount=function(x){return T.ccall("csmGetDrawableCount","number",["number"],[x])},C.getDrawableIds=function(x){return T.ccall("csmGetDrawableIds","number",["number"],[x])},C.getDrawableConstantFlags=function(x){return T.ccall("csmGetDrawableConstantFlags","number",["number"],[x])},C.getDrawableDynamicFlags=function(x){return T.ccall("csmGetDrawableDynamicFlags","number",["number"],[x])},C.getDrawableTextureIndices=function(x){return T.ccall("csmGetDrawableTextureIndices","number",["number"],[x])},C.getDrawableDrawOrders=function(x){return T.ccall("csmGetDrawableDrawOrders","number",["number"],[x])},C.getDrawableRenderOrders=function(x){return T.ccall("csmGetDrawableRenderOrders","number",["number"],[x])},C.getDrawableOpacities=function(x){return T.ccall("csmGetDrawableOpacities","number",["number"],[x])},C.getDrawableMaskCounts=function(x){return T.ccall("csmGetDrawableMaskCounts","number",["number"],[x])},C.getDrawableMasks=function(x){return T.ccall("csmGetDrawableMasks","number",["number"],[x])},C.getDrawableVertexCounts=function(x){return T.ccall("csmGetDrawableVertexCounts","number",["number"],[x])},C.getDrawableVertexPositions=function(x){return T.ccall("csmGetDrawableVertexPositions","number",["number"],[x])},C.getDrawableVertexUvs=function(x){return T.ccall("csmGetDrawableVertexUvs","number",["number"],[x])},C.getDrawableIndexCounts=function(x){return T.ccall("csmGetDrawableIndexCounts","number",["number"],[x])},C.getDrawableIndices=function(x){return T.ccall("csmGetDrawableIndices","number",["number"],[x])},C.getDrawableMultiplyColors=function(x){return T.ccall("csmGetDrawableMultiplyColors","number",["number"],[x])},C.getDrawableScreenColors=function(x){return T.ccall("csmGetDrawableScreenColors","number",["number"],[x])},C.getDrawableParentPartIndices=function(x){return T.ccall("csmGetDrawableParentPartIndices","number",["number"],[x])},C.mallocMoc=function(x){return T.ccall("csmMallocMoc","number",["number"],[x])},C.mallocModelAndInitialize=function(x){return T.ccall("csmMallocModelAndInitialize","number",["number"],[x])},C.malloc=function(x){return T.ccall("csmMalloc","number",["number"],[x])},C.setLogFunction=function(x){T.ccall("csmSetLogFunction",null,["number"],[x])},C.updateModel=function(x){T.ccall("csmUpdateModel",null,["number"],[x])},C.readCanvasInfo=function(x,$,I,B){T.ccall("csmReadCanvasInfo",null,["number","number","number","number"],[x,$,I,B])},C.resetDrawableDynamicFlags=function(x){T.ccall("csmResetDrawableDynamicFlags",null,["number"],[x])},C.free=function(x){T.ccall("csmFree",null,["number"],[x])},C.initializeAmountOfMemory=function(x){T.ccall("csmInitializeAmountOfMemory",null,["number"],[x])},C}(),c=(s.AlignofMoc=64,s.AlignofModel=16,s.MocVersion_Unknown=0,s.MocVersion_30=1,s.MocVersion_33=2,s.MocVersion_40=3,s.MocVersion_42=4,s.MocVersion_50=5,s.ParameterType_Normal=0,s.ParameterType_BlendShape=1,function(){function C(){}return C.csmGetVersion=function(){return r.getVersion()},C.csmGetLatestMocVersion=function(){return r.getLatestMocVersion()},C.csmGetMocVersion=function(x,$){return r.getMocVersion(x._ptr,$.byteLength)},C}()),c=(s.Version=c,function(){function C(){}return C.csmSetLogFunction=function(x){C.logFunction=x,x=T.addFunction(C.wrapLogFunction,"vi"),r.setLogFunction(x)},C.csmGetLogFunction=function(){return C.logFunction},C.wrapLogFunction=function(x){x=T.UTF8ToString(x),C.logFunction(x)},C}()),c=(s.Logging=c,function(){function C(x){var $=r.mallocMoc(x.byteLength);$&&(new Uint8Array(T.HEAPU8.buffer,$,x.byteLength).set(new Uint8Array(x)),this._ptr=r.reviveMocInPlace($,x.byteLength),this._ptr||r.free($))}return C.prototype.hasMocConsistency=function(x){var $=r.mallocMoc(x.byteLength);if($)return new Uint8Array(T.HEAPU8.buffer,$,x.byteLength).set(new Uint8Array(x)),x=r.hasMocConsistency($,x.byteLength),r.free($),x},C.fromArrayBuffer=function(x){return x&&(x=new C(x))._ptr?x:null},C.prototype._release=function(){r.free(this._ptr),this._ptr=0},C}()),c=(s.Moc=c,function(){function C(x){this._ptr=r.mallocModelAndInitialize(x._ptr),this._ptr&&(this.parameters=new n(this._ptr),this.parts=new o(this._ptr),this.drawables=new h(this._ptr),this.canvasinfo=new i(this._ptr))}return C.fromMoc=function(x){return x=new C(x),x._ptr?x:null},C.prototype.update=function(){r.updateModel(this._ptr)},C.prototype.release=function(){r.free(this._ptr),this._ptr=0},C}()),i=(s.Model=c,function(C){var x,$,I,B,U,G,z;C&&(I=(x=new Float32Array(2)).length*x.BYTES_PER_ELEMENT,$=r.malloc(I),($=new Uint8Array(T.HEAPU8.buffer,$,I)).set(new Uint8Array(x.buffer)),U=(I=new Float32Array(2)).length*I.BYTES_PER_ELEMENT,B=r.malloc(U),(B=new Uint8Array(T.HEAPU8.buffer,B,U)).set(new Uint8Array(I.buffer)),G=(U=new Float32Array(1)).length*U.BYTES_PER_ELEMENT,z=r.malloc(G),(z=new Uint8Array(T.HEAPU8.buffer,z,G)).set(new Uint8Array(U.buffer)),r.readCanvasInfo(C,$.byteOffset,B.byteOffset,z.byteOffset),x=new Float32Array($.buffer,$.byteOffset,$.length),I=new Float32Array(B.buffer,B.byteOffset,B.length),U=new Float32Array(z.buffer,z.byteOffset,z.length),this.CanvasWidth=x[0],this.CanvasHeight=x[1],this.CanvasOriginX=I[0],this.CanvasOriginY=I[1],this.PixelsPerUnit=U[0],r.free($.byteOffset),r.free(B.byteOffset),r.free(z.byteOffset))}),n=(s.CanvasInfo=i,function(C){this.count=r.getParameterCount(C),x=r.getParameterCount(C),this.ids=new Array(x);for(var x,$,I=new Uint32Array(T.HEAPU32.buffer,r.getParameterIds(C),x),B=0;B<I.length;B++)this.ids[B]=T.UTF8ToString(I[B]);x=r.getParameterCount(C),this.minimumValues=new Float32Array(T.HEAPF32.buffer,r.getParameterMinimumValues(C),x),x=r.getParameterCount(C),this.types=new Int32Array(T.HEAP32.buffer,r.getParameterTypes(C),x),x=r.getParameterCount(C),this.maximumValues=new Float32Array(T.HEAPF32.buffer,r.getParameterMaximumValues(C),x),x=r.getParameterCount(C),this.defaultValues=new Float32Array(T.HEAPF32.buffer,r.getParameterDefaultValues(C),x),x=r.getParameterCount(C),this.values=new Float32Array(T.HEAPF32.buffer,r.getParameterValues(C),x),x=r.getParameterCount(C),this.keyCounts=new Int32Array(T.HEAP32.buffer,r.getParameterKeyCounts(C),x),x=r.getParameterCount(C),$=new Int32Array(T.HEAP32.buffer,r.getParameterKeyCounts(C),x),this.keyValues=new Array(x);for(var U=new Uint32Array(T.HEAPU32.buffer,r.getParameterKeyValues(C),x),B=0;B<U.length;B++)this.keyValues[B]=new Float32Array(T.HEAPF32.buffer,U[B],$[B])}),o=(s.Parameters=n,function(C){this.count=r.getPartCount(C),x=r.getPartCount(C),this.ids=new Array(x);for(var x,$=new Uint32Array(T.HEAPU32.buffer,r.getPartIds(C),x),I=0;I<$.length;I++)this.ids[I]=T.UTF8ToString($[I]);x=r.getPartCount(C),this.opacities=new Float32Array(T.HEAPF32.buffer,r.getPartOpacities(C),x),x=r.getPartCount(C),this.parentIndices=new Int32Array(T.HEAP32.buffer,r.getPartParentPartIndices(C),x)}),h=(s.Parts=o,function(){function C(x){this._modelPtr=x;for(var $,I=null,B=(this.count=r.getDrawableCount(x),$=r.getDrawableCount(x),this.ids=new Array($),new Uint32Array(T.HEAPU32.buffer,r.getDrawableIds(x),$)),U=0;U<B.length;U++)this.ids[U]=T.UTF8ToString(B[U]);$=r.getDrawableCount(x),this.constantFlags=new Uint8Array(T.HEAPU8.buffer,r.getDrawableConstantFlags(x),$),$=r.getDrawableCount(x),this.dynamicFlags=new Uint8Array(T.HEAPU8.buffer,r.getDrawableDynamicFlags(x),$),$=r.getDrawableCount(x),this.textureIndices=new Int32Array(T.HEAP32.buffer,r.getDrawableTextureIndices(x),$),$=r.getDrawableCount(x),this.drawOrders=new Int32Array(T.HEAP32.buffer,r.getDrawableDrawOrders(x),$),$=r.getDrawableCount(x),this.renderOrders=new Int32Array(T.HEAP32.buffer,r.getDrawableRenderOrders(x),$),$=r.getDrawableCount(x),this.opacities=new Float32Array(T.HEAPF32.buffer,r.getDrawableOpacities(x),$),$=r.getDrawableCount(x),this.maskCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableMaskCounts(x),$),$=r.getDrawableCount(x),this.vertexCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),$),$=r.getDrawableCount(x),this.indexCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableIndexCounts(x),$),$=r.getDrawableCount(x),this.multiplyColors=new Float32Array(T.HEAPF32.buffer,r.getDrawableMultiplyColors(x),4*$),$=r.getDrawableCount(x),this.screenColors=new Float32Array(T.HEAPF32.buffer,r.getDrawableScreenColors(x),4*$),$=r.getDrawableCount(x),this.parentPartIndices=new Int32Array(T.HEAP32.buffer,r.getDrawableParentPartIndices(x),$),$=r.getDrawableCount(x),I=new Int32Array(T.HEAP32.buffer,r.getDrawableMaskCounts(x),$),this.masks=new Array($);for(var G=new Uint32Array(T.HEAPU32.buffer,r.getDrawableMasks(x),$),U=0;U<G.length;U++)this.masks[U]=new Int32Array(T.HEAP32.buffer,G[U],I[U]);$=r.getDrawableCount(x),I=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),$),this.vertexPositions=new Array($);for(var z=new Uint32Array(T.HEAPU32.buffer,r.getDrawableVertexPositions(x),$),U=0;U<z.length;U++)this.vertexPositions[U]=new Float32Array(T.HEAPF32.buffer,z[U],2*I[U]);$=r.getDrawableCount(x),I=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),$),this.vertexUvs=new Array($);for(var J=new Uint32Array(T.HEAPU32.buffer,r.getDrawableVertexUvs(x),$),U=0;U<J.length;U++)this.vertexUvs[U]=new Float32Array(T.HEAPF32.buffer,J[U],2*I[U]);$=r.getDrawableCount(x),I=new Int32Array(T.HEAP32.buffer,r.getDrawableIndexCounts(x),$),this.indices=new Array($);for(var Z=new Uint32Array(T.HEAPU32.buffer,r.getDrawableIndices(x),$),U=0;U<Z.length;U++)this.indices[U]=new Uint16Array(T.HEAPU16.buffer,Z[U],I[U])}return C.prototype.resetDynamicFlags=function(){r.resetDrawableDynamicFlags(this._modelPtr)},C}()),c=(s.Drawables=h,function(){function C(){}return C.hasBlendAdditiveBit=function(x){return(1&x)==1},C.hasBlendMultiplicativeBit=function(x){return(2&x)==2},C.hasIsDoubleSidedBit=function(x){return(4&x)==4},C.hasIsInvertedMaskBit=function(x){return(8&x)==8},C.hasIsVisibleBit=function(x){return(1&x)==1},C.hasVisibilityDidChangeBit=function(x){return(2&x)==2},C.hasOpacityDidChangeBit=function(x){return(4&x)==4},C.hasDrawOrderDidChangeBit=function(x){return(8&x)==8},C.hasRenderOrderDidChangeBit=function(x){return(16&x)==16},C.hasVertexPositionsDidChangeBit=function(x){return(32&x)==32},C.hasBlendColorDidChangeBit=function(x){return(64&x)==64},C}()),c=(s.Utils=c,function(){function C(){}return C.initializeAmountOfMemory=function(x){16777216<x&&r.initializeAmountOfMemory(x)},C}()),b=(s.Memory=c,t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,function(C){C=C||{};var x,$,I={};for($ in x=x||(C!==void 0?C:{}))x.hasOwnProperty($)&&(I[$]=x[$]);var B,U,G,z,it=!1,J=typeof window=="object",Z=typeof importScripts=="function",it=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!J&&!Z,Q=!J&&!it&&!Z,wr="",_t=(it?(wr=__dirname+"/",G=function(Tt,$t){var at=Wr(Tt);return at||(B=B||require("fs"),Tt=(U=U||require("path")).normalize(Tt),at=B.readFileSync(Tt)),$t?at:at.toString()},z=function(Tt){return Ct((Tt=(Tt=G(Tt,!0)).buffer?Tt:new Uint8Array(Tt)).buffer),Tt},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(Tt){throw Tt}),process.on("unhandledRejection",te),x.inspect=function(){return"[Emscripten Module object]"}):Q?(typeof read<"u"&&(G=function(Tt){var $t=Wr(Tt);return $t?Fi($t):read(Tt)}),z=function(Tt){var $t;if(!($t=Wr(Tt))){if(typeof readbuffer=="function")return new Uint8Array(readbuffer(Tt));Ct(typeof($t=read(Tt,"binary"))=="object")}return $t},typeof print<"u"&&((console=typeof console>"u"?{}:console).log=print,console.warn=console.error=typeof printErr<"u"?printErr:print)):(J||Z)&&(Z?wr=self.location.href:document.currentScript&&(wr=document.currentScript.src),wr=(wr=t||wr).indexOf("blob:")!==0?wr.substr(0,wr.lastIndexOf("/")+1):"",G=function(Tt){try{var $t=new XMLHttpRequest;return $t.open("GET",Tt,!1),$t.send(null),$t.responseText}catch(at){if(Tt=Wr(Tt))return Fi(Tt);throw at}},Z)&&(z=function(Tt){try{var $t=new XMLHttpRequest;return $t.open("GET",Tt,!1),$t.responseType="arraybuffer",$t.send(null),new Uint8Array($t.response)}catch(at){if(Tt=Wr(Tt))return Tt;throw at}}),x.print||console.log.bind(console)),et=x.printErr||console.warn.bind(console);for($ in I)I.hasOwnProperty($)&&(x[$]=I[$]);function ft(){return{exports:function(Tt,$t,at){var lt=new ArrayBuffer(8),Wt=new Int32Array(lt),Ae=new Float32Array(lt),de=new Float64Array(lt);function Yt(a,p){Wt[a]=p}function Xe(){return de[0]}function je(a){de[0]=a}function Qt(a){Ae[0]=a}function Xt(){return Ae[0]}lt=$t.buffer;var jt,l,w,M,L,O,N,e,H,W,rt,R,ct,j,v,St,yt,Mt,Ft,Nt,Lt,re,Zt,K,Vt,jt=new Uint8Array(lt);return(lt=function(a,p){var P,_;if(typeof Buffer>"u")for(P=atob(p),_=0;_<P.length;_++)jt[a+_]=P.charCodeAt(_);else for(P=Buffer.from(p,"base64"),_=0;_<P.length;_++)jt[a+_]=P[_]})(1024,"QW4gZXJyb3Igb2NjdXJyZWQgaW4gdGhlIGludGVycG9sYXRpb24gZm9yIGJsZW5kIHNoYXBlcy4gQ29tYmluYXRpb25Db3VudCBpcyAlZC4ACgBbQ1NNXSBbRV1XYXJwRGVmb3JtZXI6OlRyYW5zZm9ybVRhcmdldCgpIGVycm9yLiBbJWRdIHAwMT0oJS40ZiAsICUuNGYpCgBbQ1NNXSBbRV1Jbml0aWFsaXplRGVmb3JtZXJzKCk6IFVua25vd24gRGVmb3JtZXIgVHlwZS4KAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBUaGlzIG1vYzMgc2l6ZSBpcyBpbnZhbGlkLgoAW0NTTV0gW0VdJXM6ICVzCgBbQ1NNXSBbV11Sb3RhdGlvbkRlZm9ybWVyOiBOb3QgZm91bmQgdHJhbnNmb3JtZWQgRGlyZWN0aW9uLgoAW0NTTV0gW0VdVXBkYXRlRGVmb3JtZXJIaWVyYXJjaHkoKTogVW5rbm93biBEZWZvcm1lciBUeXBlLgoAJXMKACAgAE1PQzMAImFkZHJlc3MiIGlzIG51bGwuACUwMlggAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBGaWxlVHlwZSBpcyBpbnZhbGlkLgoAImFkZHJlc3MiIGFsaWdubWVudCBpcyBpbnZhbGlkLgBbQ1NNXSBbRV1jc21IYXNNb2NDb25zaXN0ZW5jeTogVGhpcyBtb2MzIHZlciBpcyBpbnZhbGlkIFt2ZXI6JWRdLgoAInNpemUiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBUaGUgQ29yZSB1bnN1cHBvcnQgbGF0ZXIgdGhhbiBtb2MzIHZlcjpbJWRdLiBUaGlzIG1vYzMgdmVyIGlzIFslZF0uCgAibW9kZWwiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBIZWFkZXIgc2VjdGlvbiBpcyBpbnZhbGlkLgoAIm91dFNpemVJblBpeGVscyIgaXMgbnVsbC4AW0NTTV0gW0VdY3NtSGFzTW9jQ29uc2lzdGVuY3k6IERhdGEgc2VjdGlvbiBpcyBpbnZhbGlkLgoAIm91dE9yaWdpbkluUGl4ZWxzIiBpcyBudWxsLgBbQ1NNXSBbRV1jc21SZXZpdmVNb2NJblBsYWNlIGlzIGZhaWxlZC4gQ29ycnVwdGVkICBtb2MzIGZpbGUuCgAib3V0UGl4ZWxzUGVyVW5pdCIgaXMgbnVsbC4AW0NTTV0gW0VdY3NtUmV2aXZlTW9jSW5QbGFjZSBpcyBmYWlsZWQuIFRoZSBDb3JlIHVuc3VwcG9ydCBsYXRlciB0aGFuIG1vYzMgdmVyOlslZF0uIFRoaXMgbW9jMyB2ZXIgaXMgWyVkXS4KACJtb2MiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUdldE1vY1ZlcnNpb24gaXMgZmFpbGVkLiBDb3JydXB0ZWQgbW9jMyBmaWxlLgoAInNpemUiIGlzIGludmFsaWQATGl2ZTJEIEN1YmlzbSBTREsgQ29yZSBWZXJzaW9uICVkLiVkLiVkAGNzbUdldE1vY1ZlcnNpb24AY3NtSGFzTW9jQ29uc2lzdGVuY3kAY3NtUmV2aXZlTW9jSW5QbGFjZQBjc21SZWFkQ2FudmFzSW5mbwBjc21HZXRTaXplb2ZNb2RlbABjc21Jbml0aWFsaXplTW9kZWxJblBsYWNlAGNzbVVwZGF0ZU1vZGVsAGNzbUdldFBhcmFtZXRlckNvdW50AGNzbUdldFBhcmFtZXRlcklkcwBjc21HZXRQYXJhbWV0ZXJUeXBlcwBjc21HZXRQYXJhbWV0ZXJNaW5pbXVtVmFsdWVzAGNzbUdldFBhcmFtZXRlck1heGltdW1WYWx1ZXMAY3NtR2V0UGFyYW1ldGVyRGVmYXVsdFZhbHVlcwBjc21HZXRQYXJhbWV0ZXJWYWx1ZXMAY3NtR2V0UGFydENvdW50AGNzbUdldFBhcnRJZHMAY3NtR2V0UGFydE9wYWNpdGllcwBjc21HZXRQYXJ0UGFyZW50UGFydEluZGljZXMAY3NtR2V0RHJhd2FibGVDb3VudABjc21HZXREcmF3YWJsZUlkcwBjc21HZXREcmF3YWJsZUNvbnN0YW50RmxhZ3MAY3NtR2V0RHJhd2FibGVEeW5hbWljRmxhZ3MAY3NtR2V0RHJhd2FibGVUZXh0dXJlSW5kaWNlcwBjc21HZXREcmF3YWJsZURyYXdPcmRlcnMAY3NtR2V0RHJhd2FibGVSZW5kZXJPcmRlcnMAY3NtR2V0RHJhd2FibGVPcGFjaXRpZXMAY3NtR2V0RHJhd2FibGVNYXNrQ291bnRzAGNzbUdldERyYXdhYmxlTWFza3MAY3NtR2V0RHJhd2FibGVWZXJ0ZXhDb3VudHMAY3NtR2V0RHJhd2FibGVWZXJ0ZXhQb3NpdGlvbnMAY3NtR2V0RHJhd2FibGVWZXJ0ZXhVdnMAY3NtR2V0RHJhd2FibGVJbmRleENvdW50cwBjc21HZXREcmF3YWJsZUluZGljZXMAY3NtR2V0RHJhd2FibGVNdWx0aXBseUNvbG9ycwBjc21HZXREcmF3YWJsZVNjcmVlbkNvbG9ycwBjc21HZXREcmF3YWJsZVBhcmVudFBhcnRJbmRpY2VzAGNzbVJlc2V0RHJhd2FibGVEeW5hbWljRmxhZ3MAY3NtR2V0UGFyYW1ldGVyS2V5Q291bnRzAGNzbUdldFBhcmFtZXRlcktleVZhbHVlcw=="),lt(3228,"Cg=="),lt(3267,"//////8="),lt(3336,"LSsgICAwWDB4AChudWxsKQ=="),lt(3360,"EQAKABEREQAAAAAFAAAAAAAACQAAAAAL"),lt(3392,"EQAPChEREQMKBwABEwkLCwAACQYLAAALAAYRAAAAERER"),lt(3441,"Cw=="),lt(3450,"EQAKChEREQAKAAACAAkLAAAACQALAAAL"),lt(3499,"DA=="),lt(3511,"DAAAAAAMAAAAAAkMAAAAAAAMAAAM"),lt(3557,"Dg=="),lt(3569,"DQAAAAQNAAAAAAkOAAAAAAAOAAAO"),lt(3615,"EA=="),lt(3627,"DwAAAAAPAAAAAAkQAAAAAAAQAAAQAAASAAAAEhIS"),lt(3682,"EgAAABISEgAAAAAAAAk="),lt(3731,"Cw=="),lt(3743,"CgAAAAAKAAAAAAkLAAAAAAALAAAL"),lt(3789,"DA=="),lt(3801,"DAAAAAAMAAAAAAkMAAAAAAAMAAAMAAAwMTIzNDU2Nzg5QUJDREVGLTBYKzBYIDBYLTB4KzB4IDB4AGluZgBJTkYAbmFuAE5BTgAuAAAAAKgaAAAAAAAAAwAAAAQAAAAEAAAABgAAAIP5ogBETm4A/CkVANFXJwDdNPUAYtvAADyZlQBBkEMAY1H+ALveqwC3YcUAOm4kANJNQgBJBuAACeouAByS0QDrHf4AKbEcAOg+pwD1NYIARLsuAJzphAC0JnAAQX5fANaROQBTgzkAnPQ5AItfhAAo+b0A+B87AN7/lwAPmAUAES/vAApaiwBtH20Az342AAnLJwBGT7cAnmY/AC3qXwC6J3UA5evHAD178QD3OQcAklKKAPtr6gAfsV8ACF2NADADVgB7/EYA8KtrACC8zwA29JoA46kdAF5hkQAIG+YAhZllAKAUXwCNQGgAgNj/ACdzTQAGBjEAylYVAMmocwB74mAAa4zAABnERwDNZ8MACejcAFmDKgCLdsQAphyWAESv3QAZV9EApT4FAAUH/wAzfj8AwjLoAJhP3gC7fTIAJj3DAB5r7wCf+F4ANR86AH/yygDxhx0AfJAhAGokfADVbvoAMC13ABU7QwC1FMYAwxmdAK3EwgAsTUEADABdAIZ9RgDjcS0Am8aaADNiAAC00nwAtKeXADdV1QDXPvYAoxAYAE12/ABknSoAcNerAGN8+AB6sFcAFxXnAMBJVgA71tkAp4Q4ACQjywDWincAWlQjAAAfuQDxChsAGc7fAJ8x/wBmHmoAmVdhAKz7RwB+f9gAImW3ADLoiQDmv2AA78TNAGw2CQBdP9QAFt7XAFg73gDem5IA0iIoACiG6ADiWE0AxsoyAAjjFgDgfcsAF8BQAPMdpwAY4FsALhM0AIMSYgCDSAEA9Y5bAK2wfwAe6fIASEpDABBn0wCq3dgArl9CAGphzgAKKKQA05m0AAam8gBcd38Ao8KDAGE8iACKc3gAr4xaAG/XvQAtpmMA9L/LAI2B7wAmwWcAVcpFAMrZNgAoqNIAwmGNABLJdwAEJhQAEkabAMRZxADIxUQATbKRAAAX8wDUQ60AKUnlAP3VEAAAvvwAHpTMAHDO7gATPvUA7PGAALPnwwDH+CgAkwWUAMFxPgAuCbMAC0XzAIgSnACrIHsALrWfAEeSwgB7Mi8ADFVtAHKnkABr5x8AMcuWAHkWSgBBeeIA9N+JAOiUlwDi5oQAmTGXAIjtawBfXzYAu/0OAEiatABnpGwAcXJCAI1dMgCfFbgAvOUJAI0xJQD3dDkAMAUcAA0MAQBLCGgALO5YAEeqkAB05wIAvdYkAPd9pgBuSHIAnxbvAI6UpgC0kfYA0VNRAM8K8gAgmDMA9Ut+ALJjaADdPl8AQF0DAIWJfwBVUikAN2TAAG3YEAAySDIAW0x1AE5x1ABFVG4ACwnBACr1aQAUZtUAJwedAF0EUAC0O9sA6nbFAIf5FwBJa30AHSe6AJZpKQDGzKwArRRUAJDiagCI2YkALHJQAASkvgB3B5QA8zBwAAD8JwDqcagAZsJJAGTgPQCX3YMAoz+XAEOU/QANhowAMUHeAJI5nQDdcIwAF7fnAAjfOwAVNysAXICgAFqAkwAQEZIAD+jYAGyArwDb/0sAOJAPAFkYdgBipRUAYcu7AMeJuQAQQL0A0vIEAEl1JwDrtvYA2yK7AAoUqgCJJi8AZIN2AAk7MwAOlBoAUTqqAB2jwgCv7a4AXCYSAG3CTQAtepwAwFaXAAM/gwAJ8PYAK0CMAG0xmQA5tAcADCAVANjDWwD1ksQAxq1LAE7KpQCnN80A5qk2AKuSlADdQmgAGWPeAHaM7wBoi1IA/Ns3AK6hqwDfFTEAAK6hAAz72gBkTWYA7QW3ACllMABXVr8AR/86AGr5uQB1vvMAKJPfAKuAMABmjPYABMsVAPoiBgDZ5B0APbOkAFcbjwA2zQkATkLpABO+pAAzI7UA8KoaAE9lqADSwaUACz8PAFt4zQAj+XYAe4sEAIkXcgDGplMAb27iAO/rAACbSlgAxNq3AKpmugB2z88A0QIdALHxLQCMmcEAw613AIZI2gD3XaAAxoD0AKzwLwDd7JoAP1y8ANDebQCQxx8AKtu2AKMlOgAAr5oArVOTALZXBAApLbQAS4B+ANoHpwB2qg4Ae1mhABYSKgDcty0A+uX9AInb/gCJvv0A5HZsAAap/AA+gHAAhW4VAP2H/wAoPgcAYWczACoYhgBNveoAs+evAI9tbgCVZzkAMb9bAITXSAAw3xYAxy1DACVhNQDJcM4AMMu4AL9s/QCkAKIABWzkAFrdoAAhb0cAYhLSALlchABwYUkAa1bgAJlSAQBQVTcAHtW3ADPxxAATbl8AXTDkAIUuqQAdssMAoTI2AAi3pADqsdQAFvchAI9p5AAn/3cADAOAAI1ALQBPzaAAIKWZALOi0wAvXQoAtPlCABHaywB9vtAAm9vBAKsXvQDKooEACGpcAC5VFwAnAFUAfxTwAOEHhgAUC2QAlkGNAIe+3gDa/SoAayW2AHuJNAAF8/4Aub+eAGhqTwBKKqgAT8RaAC34vADXWpgA9MeVAA1NjQAgOqYApFdfABQ/sQCAOJUAzCABAHHdhgDJ3rYAv2D1AE1lEQABB2sAjLCsALLA0ABRVUgAHvsOAJVywwCjBjsAwEA1AAbcewDgRcwATin6ANbKyADo80EAfGTeAJtk2ADZvjEApJfDAHdY1ABp48UA8NoTALo6PABGGEYAVXVfANK99QBuksYArC5dAA5E7QAcPkIAYcSHACn96QDn1vMAInzKAG+RNQAI4MUA/9eNAG5q4gCw/cYAkwjBAHxddABrrbIAzW6dAD5yewDGEWoA98+pAClz3wC1yboAtwBRAOKyDQB0uiQA5X1gAHTYigANFSwAgRgMAH5mlAABKRYAn3p2AP39vgBWRe8A2X42AOzZEwCLurkAxJf8ADGoJwDxbsMAlMU2ANioVgC0qLUAz8wOABKJLQBvVzQALFaJAJnO4wDWILkAa16qAD4qnAARX8wA/QtKAOH0+wCOO20A4oYsAOnUhAD8tKkA7+7RAC41yQAvOWEAOCFEABvZyACB/AoA+0pqAC8c2ABTtIQATpmMAFQizAAqVdwAwMbWAAsZlgAacLgAaZVkACZaYAA/Uu4AfxEPAPS1EQD8y/UANLwtADS87gDoXcwA3V5gAGeOmwCSM+8AyRe4AGFYmwDhV7wAUYPGANg+EADdcUgALRzdAK8YoQAhLEYAWfPXANl6mACeVMAAT4b6AFYG/ADlea4AiSI2ADitIgBnk9wAVeiqAIImOADK55sAUQ2kAJkzsQCp1w4AaQVIAGWy8AB/iKcAiEyXAPnRNgAhkrMAe4JKAJjPIQBAn9wA3EdVAOF0OgBn60IA/p3fAF7UXwB7Z6QAuqx6AFX2ogAriCMAQbpVAFluCAAhKoYAOUeDAInj5gDlntQASftAAP9W6QAcD8oAxVmKAJT6KwDTwcUAD8XPANtargBHxYYAhUNiACGGOwAseZQAEGGHACpMewCALBoAQ78SAIgmkAB4PIkAqMTkAOXbewDEOsIAJvTqAPdnigANkr8AZaMrAD2TsQC9fAsApFHcACfdYwBp4d0AmpQZAKgplQBozigACe20AESfIABOmMoAcIJjAH58IwAPuTIAp/WOABRW5wAh8QgAtZ0qAG9+TQClGVEAtfmrAILf1gCW3WEAFjYCAMQ6nwCDoqEAcu1tADmNegCCuKkAazJcAEYnWwAANO0A0gB3APz0VQABWU0A4HGA"),lt(6675,"QPsh+T8AAAAALUR0PgAAAICYRvg8AAAAYFHMeDsAAACAgxvwOQAAAEAgJXo4AAAAgCKC4zYAAAAAHfNpNThj7T7aD0k/Xph7P9oPyT9pN6wxaCEiM7QPFDNoIaIz2w9JP9sPSb/kyxZA5MsWwAAAAAAAAACA2w9JQNsPScAAAIA/AADAPwAAAADcz9E1AAAAAADAFT8="),lt(6824,"BQ=="),lt(6836,"DQ=="),lt(6860,"DgAAAA8AAABYHAAAAAQ="),lt(6884,"AQ=="),lt(6899,"Cv////8="),lt(7156,"gCA="),l={Int8Array,Int16Array,Int32Array,Uint8Array,Uint16Array,Uint32Array,Float32Array,Float64Array,NaN:NaN,Infinity:1/0,Math},w=$t.buffer,M=(lt=Tt).memory,L=at,O=new l.Int8Array(w),N=new l.Int16Array(w),e=new l.Int32Array(w),H=new l.Uint8Array(w),W=new l.Uint16Array(w),rt=new l.Uint32Array(w),R=new l.Float32Array(w),ct=new l.Float64Array(w),j=l.Math.imul,v=l.Math.fround,St=l.Math.abs,yt=l.Math.clz32,Mt=l.Math.min,l.Math.max,Ft=l.Math.floor,l.Math.ceil,l.Math.sqrt,lt.abort,l.NaN,Nt=l.Infinity,Lt=lt.a,re=lt.b,Zt=lt.c,K=5251744,Vt=0,L[1]=function(a,p,P,_,f){a|=0,p|=0,P|=0,_|=0,f|=0;var E,u,d,g,y,A,S,D,F,k,V,X,q,tt,ut,mt,kt,Ht,ce,we,Ue,Ye,pe,tr,Ot=0,fe=v(0),Te=v(0),Be=0,Ne=v(0),er=v(0),ar=v(0),Tr=v(0),Er=v(0),Cr=v(0),Sr=v(0),Pr=v(0),Dr=v(0),Or=v(0),Nr=v(0),Jr=v(0),ti=v(0),xi=v(0),bi=v(0),Oi=v(0),Ni=v(0),is=v(0),ss=v(0),y2=(v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),0);if(K=tr=K-32|0,1<=(0|f))for(E=e[16+(e[a+308>>2]+(p<<5)|0)>>2],Ot=e[a+60>>2]+j(E,24)|0,p=(u=e[Ot+8>>2])+-1|0,X=(y=e[Ot+4>>2])+-1|0,q=F=(E=e[e[a+152>>2]+(E<<2)>>2])+(u<<3)|0,tt=k=E+((D=j(y,d=u+1|0))<<3)|0,ut=V=E+(u+D<<3)|0,pe=e[Ot+12>>2],A=v(0|y),S=v(0|u),a=0;ar=R[4+(Ot=(g=a<<3)+P|0)>>2],Te=v(ar*A),Tr=R[Ot>>2],fe=v(Tr*S),Ot=ar>=v(1),Te=!(ar<v(0)^1)||Ot|Tr>=v(1)|Tr<v(0)?(y2||(Dr=R[4+ut>>2],mt=R[E+4>>2],Er=v(Dr-mt),kt=R[4+q>>2],Ht=R[4+tt>>2],Cr=v(kt-Ht),Or=v(v(Er-Cr)*v(.5)),ce=R[V>>2],we=R[E>>2],Sr=v(ce-we),Ue=R[F>>2],Ye=R[k>>2],Pr=v(Ue-Ye),Nr=v(v(Sr-Pr)*v(.5)),Cr=v(v(Cr+Er)*v(.5)),Pr=v(v(Pr+Sr)*v(.5)),y2=1,Er=v(v(v(v(v(mt+kt)+Ht)+Dr)*v(.25))-v(Er*v(.5))),Sr=v(v(v(v(v(we+Ue)+Ye)+ce)*v(.25))-v(Sr*v(.5)))),ar<v(3)^1|Tr>v(-2)^1|(Tr<v(3)^1|ar>v(-2)^1)?(R[_+g>>2]=v(ar*Nr)+v(v(Tr*Pr)+Sr),fe=v(ar*Or),v(v(Tr*Cr)+Er)):(Tr<=v(0)?ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ne=v(v(Tr+v(2))*v(.5)),fe=v(Or+Or),is=v(Er-fe),Te=v(Nr+Nr),ss=v(Sr-Te),Oi=v(Er-v(Cr+Cr)),Jr=v(Oi-fe),Ni=v(Sr-v(Pr+Pr)),ti=v(Ni-Te),xi=R[E+4>>2],bi=R[E>>2]):Ot?(fe=v(Or*v(3)),Te=v(Er-v(Cr+Cr)),Oi=v(fe+Te),Jr=v(Nr*v(3)),ti=v(Sr-v(Pr+Pr)),Ni=v(Jr+ti),er=v(v(ar+v(-1))*v(.5)),Ne=v(v(Tr+v(2))*v(.5)),xi=v(fe+Er),bi=v(Jr+Sr),Jr=v(Or+Te),ti=v(Nr+ti),is=R[4+tt>>2],ss=R[k>>2]):(fe=v(Er-v(Cr+Cr)),Ot=X,Be=v(St(Te))<v(2147483648)?~~Te:-2147483648,er=v(0|(Ot=(0|Be)==(0|y)?Ot:Be)),Ne=v(er/A),Jr=v(v(Ne*Or)+fe),Dr=v(Ne*Nr),Ne=v(Sr-v(Pr+Pr)),ti=v(Dr+Ne),ar=v(v(0|(Be=Ot+1|0))/A),Oi=v(v(ar*Or)+fe),Ni=v(v(ar*Nr)+Ne),Ne=v(v(Tr+v(2))*v(.5)),er=v(Te-er),Ot=E+(j(Ot,d)<<3)|0,is=R[Ot+4>>2],ss=R[Ot>>2],Ot=E+(j(Be,d)<<3)|0,xi=R[Ot+4>>2],bi=R[Ot>>2]):Tr>=v(1)?ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ne=v(v(Tr+v(-1))*v(.5)),fe=v(Or+Or),Jr=v(v(Cr+Er)-fe),Te=v(Nr+Nr),ti=v(v(Pr+Sr)-Te),xi=v(v(Cr*v(3))+Er),is=v(xi-fe),bi=v(v(Pr*v(3))+Sr),ss=v(bi-Te),Oi=R[4+q>>2],Ni=R[F>>2]):Ot?(fe=v(Or*v(3)),Oi=v(fe+v(Cr+Er)),Te=v(Nr*v(3)),Ni=v(Te+v(Pr+Sr)),Dr=fe,fe=v(v(Cr*v(3))+Er),xi=v(Dr+fe),Dr=Te,Te=v(v(Pr*v(3))+Sr),bi=v(Dr+Te),er=v(v(ar+v(-1))*v(.5)),Ne=v(v(Tr+v(-1))*v(.5)),is=v(Or+fe),ss=v(Nr+Te),Jr=R[4+ut>>2],ti=R[V>>2]):(fe=v(v(Cr*v(3))+Er),Ot=X,Be=v(St(Te))<v(2147483648)?~~Te:-2147483648,er=v(0|(Ot=(0|Be)==(0|y)?Ot:Be)),Ne=v(er/A),is=v(v(Ne*Or)+fe),Dr=v(Ne*Nr),Ne=v(v(Pr*v(3))+Sr),ss=v(Dr+Ne),ar=v(v(0|(Be=Ot+1|0))/A),xi=v(v(ar*Or)+fe),bi=v(v(ar*Nr)+Ne),Ne=v(v(Tr+v(-1))*v(.5)),er=v(Te-er),Ot=E+(j(Ot,d)+u<<3)|0,Jr=R[Ot+4>>2],ti=R[Ot>>2],Ot=E+(j(Be,d)+u<<3)|0,Oi=R[Ot+4>>2],Ni=R[Ot>>2]):ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ot=p,Be=v(St(Te=fe))<v(2147483648)?~~fe:-2147483648,fe=v(0|(Ot=(0|Be)==(0|u)?Ot:Be)),Ne=v(Te-fe),fe=v(fe/S),Te=v(Or+Or),Jr=v(v(v(fe*Cr)+Er)-Te),Dr=v(v(fe*Pr)+Sr),fe=v(Nr+Nr),ti=v(Dr-fe),ar=v(v(0|(Be=Ot+1|0))/S),is=v(v(v(ar*Cr)+Er)-Te),ss=v(v(v(ar*Pr)+Sr)-fe),Oi=R[4+(Ot=E+(Ot<<3)|0)>>2],Ni=R[Ot>>2],xi=R[4+(Ot=E+(Be<<3)|0)>>2],bi=R[Ot>>2]):Ot?(Dr=Te=v(Or*v(3)),Ot=p,Be=v(St(fe))<v(2147483648)?~~fe:-2147483648,Ne=v(0|(Ot=(0|Be)==(0|u)?Ot:Be)),er=v(Ne/S),Oi=v(Dr+v(v(er*Cr)+Er)),Tr=v(Nr*v(3)),Ni=v(Tr+v(v(er*Pr)+Sr)),Dr=Te,Te=v(v(0|(Be=Ot+1|0))/S),xi=v(Dr+v(v(Te*Cr)+Er)),bi=v(Tr+v(v(Te*Pr)+Sr)),er=v(v(ar+v(-1))*v(.5)),Ne=v(fe-Ne),Jr=R[4+(Ot=E+(Ot+D<<3)|0)>>2],ti=R[Ot>>2],is=R[4+(Ot=E+(Be+D<<3)|0)>>2],ss=R[Ot>>2]):(ct[16+tr>>3]=ar,e[tr>>2]=a,ct[8+tr>>3]=Tr,Ut(4,1107,tr)),v(Ne+er)<=v(1)?(R[_+g>>2]=v(ti+v(v(ss-ti)*Ne))+v(v(Ni-ti)*er),fe=v(Jr+v(v(is-Jr)*Ne)),v(v(Oi-Jr)*er)):(fe=v(v(1)-Ne),Te=v(v(1)-er),R[_+g>>2]=v(bi+v(v(Ni-bi)*fe))+v(v(ss-bi)*Te),fe=v(xi+v(v(Oi-xi)*fe)),v(v(is-xi)*Te)))):(Ot=v(St(Dr=Te))<v(2147483648)?~~Te:-2147483648,er=v(Dr-v(0|Ot)),Be=v(St(Te=fe))<v(2147483648)?~~fe:-2147483648,Ne=v(Te-v(0|Be)),Ot=Be+j(Ot,d)|0,pe?(fe=v(v(1)-er),Te=v(v(1)-Ne),Be=E+(Ot<<3)|0,Ot=E+(Ot+d<<3)|0,R[_+g>>2]=v(v(v(fe*v(Te*R[Be>>2]))+v(fe*v(Ne*R[Be+8>>2])))+v(er*v(Te*R[Ot>>2])))+v(er*v(Ne*R[Ot+8>>2])),fe=v(v(v(fe*v(Te*R[Be+4>>2]))+v(fe*v(Ne*R[Be+12>>2])))+v(er*v(Te*R[Ot+4>>2]))),v(er*v(Ne*R[Ot+12>>2]))):v(Ne+er)<=v(1)?(fe=v(v(v(1)-Ne)-er),Be=E+(Ot<<3)|0,Ot=E+(Ot+d<<3)|0,R[_+g>>2]=v(v(fe*R[Be>>2])+v(Ne*R[Be+8>>2]))+v(er*R[Ot>>2]),fe=v(v(fe*R[Be+4>>2])+v(Ne*R[Be+12>>2])),v(er*R[Ot+4>>2])):(fe=v(v(Ne+v(-1))+er),Be=E+(Ot+d<<3)|0,Te=v(v(1)-Ne),ar=v(v(1)-er),Ot=E+(Ot<<3)|0,R[_+g>>2]=v(v(fe*R[Be+8>>2])+v(Te*R[Be>>2]))+v(ar*R[Ot+8>>2]),fe=v(v(fe*R[Be+12>>2])+v(Te*R[Be+4>>2])),v(ar*R[Ot+12>>2]))),R[4+(_+g|0)>>2]=fe+Te,(0|f)!=(0|(a=a+1|0)););K=32+tr|0},L[2]=function(a,p){a|=0,p|=0;var A=0,P=0,_=0,y=0,S=0,f=v(0),E=0,u=0,d=(v(0),0),g=0,y=e[a+320>>2],A=e[a+316>>2],S=e[a+308>>2];(0|(P=e[8+(_=S+(p<<5)|0)>>2]))==-1?(e[(g=A)+(A=p<<2)>>2]=e[e[a+148>>2]+(e[_+16>>2]<<2)>>2],e[A+y>>2]=1065353216):(E=e[_+16>>2],u=e[e[a+152>>2]+(E<<2)>>2],L[e[24+(S+(P<<5)|0)>>2]](a,P,u,u,e[16+(e[a+60>>2]+j(E,24)|0)>>2]),f=R[e[a+148>>2]+(e[_+16>>2]<<2)>>2],_=e[_+8>>2]<<2,R[(P=p<<2)+A>>2]=f*R[_+A>>2],e[P+y>>2]=e[_+y>>2]),4<=H[e[a>>2]+4|0]&&(y=p<<2,A=e[a+308>>2]+(p<<5)|0,P=e[A+16>>2]<<2,_=e[a+328>>2],p=e[a+324>>2],(0|(S=e[A+8>>2]))==-1?(S=e[a+156>>2],e[(A=y<<2)+p>>2]=e[S+(P<<=2)>>2],e[(E=4|A)+p>>2]=e[(u=4|P)+S>>2],e[(d=8|A)+p>>2]=e[S+(g=8|P)>>2],e[p+((y|=3)<<2)>>2]=1065353216,a=e[a+160>>2],e[A+_>>2]=e[a+P>>2],e[_+E>>2]=e[a+u>>2],e[_+d>>2]=e[a+g>>2]):(P=(u=P<<2)+e[a+156>>2]|0,R[(A=(E=y<<2)+p|0)>>2]=R[P>>2]*R[(S=(d=S<<4)+p|0)>>2],R[A+4>>2]=R[P+4>>2]*R[S+4>>2],R[A+8>>2]=R[P+8>>2]*R[S+8>>2],e[p+((y|=3)<<2)>>2]=1065353216,a=u+e[a+160>>2]|0,g=R[a>>2],f=R[(A=_+d|0)>>2],R[(p=_+E|0)>>2]=v(g+f)-v(g*f),g=R[a+4>>2],f=R[A+4>>2],R[p+4>>2]=v(g+f)-v(g*f),g=R[a+8>>2],f=R[A+8>>2],R[p+8>>2]=v(g+f)-v(g*f)),e[_+(y<<2)>>2]=1065353216)},L[3]=function(a,p,P,_,f){a|=0,p|=0,P|=0,_|=0,f|=0;var E,u,d,g,y,A=0,A=(v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),(p=e[16+(e[a+308>>2]+(p<<5)|0)>>2])<<2),S=function(V){var X,q,tt,ut,mt=v(0);K=tt=K-16|0,Qt(V);r:if((X=2147483647&(ut=Wt[0]))>>>0<=1061752794)mt=v(1),X>>>0<964689920||(mt=ve(+V));else if(X>>>0<=1081824209)q=+V,mt=1075235812<=X>>>0?v(-ve(((0|ut)<0?3.141592653589793:-3.141592653589793)+q)):me((0|ut)<=-1?1.5707963267948966+q:1.5707963267948966-q);else if(X>>>0<=1088565717)mt=1085271520<=X>>>0?ve(+V+((0|ut)<0?6.283185307179586:-6.283185307179586)):me((0|ut)<=-1?-4.71238898038469-+V:+V-4.71238898038469);else if(mt=v(V-V),!(2139095040<=X>>>0))if((X=3&Qe(V,8+tt|0))>>>0<=2){switch(X-1|0){default:mt=ve(ct[8+tt>>3]);break r;case 0:mt=me(-ct[8+tt>>3]);break r;case 1:}mt=v(-ve(ct[8+tt>>3]))}else mt=me(ct[8+tt>>3]);return K=16+tt|0,mt}(k=v(v(v(R[4+(e[a+168>>2]+j(p,12)|0)>>2]+R[A+e[a+284>>2]>>2])*v(3.1415927410125732))/v(180))),D=R[A+e[a+272>>2]>>2],F=e[A+e[a+292>>2]>>2],k=function(V){var X,q,tt,ut=0;K=q=K-16|0,Qt(V);r:if((X=2147483647&(tt=Wt[0]))>>>0<=1061752794)X>>>0<964689920||(V=me(+V));else if(X>>>0<=1081824209)ut=+V,V=X>>>0<=1075235811?(0|tt)<=-1?v(-ve(ut+1.5707963267948966)):ve(ut+-1.5707963267948966):me(-(((0|tt)<0?3.141592653589793:-3.141592653589793)+ut));else if(X>>>0<=1088565717)ut=+V,V=X>>>0<=1085271519?(0|tt)<=-1?ve(ut+4.71238898038469):v(-ve(ut+-4.71238898038469)):me(((0|tt)<0?6.283185307179586:-6.283185307179586)+ut);else if(2139095040<=X>>>0)V=v(V-V);else if((X=3&Qe(V,8+q|0))>>>0<=2){switch(X-1|0){default:V=me(ct[8+q>>3]);break r;case 0:V=ve(ct[8+q>>3]);break r;case 1:}V=me(-ct[8+q>>3])}else V=v(-ve(ct[8+q>>3]));return K=16+q|0,V}(k);if((p=0)<(0|f))for(S=v(D*S),u=v(F?-1:1),g=v(S*u),E=e[A+e[a+288>>2]>>2]?v(-1):v(1),y=v(v(D*k)*E),S=v(S*E),D=v(v(D*v(-k))*u),k=R[A+e[a+280>>2]>>2],u=R[A+e[a+276>>2]>>2];A=(a=p<<3)+_|0,E=R[(a=a+P|0)>>2],d=R[a+4>>2],R[A+4>>2]=k+v(v(y*E)+v(g*d)),R[A>>2]=u+v(v(S*E)+v(D*d)),(0|f)!=(0|(p=p+1|0)););},L[4]=function(a,p){a|=0,p|=0;var P,_,f,E,u,d,g=0,y=0,A=0,S=v(0),D=0,F=0,k=v(0),V=0,X=0,q=0;if(v(0),v(0),v(0),v(0),K=d=K+-64|0,V=e[a+320>>2],X=e[a+316>>2],y=e[a+308>>2],(0|(D=e[8+(A=y+(p<<5)|0)>>2]))==-1)g=e[A+16>>2]<<2,e[(y=p<<2)+X>>2]=e[g+e[a+268>>2]>>2],e[y+V>>2]=e[g+e[a+272>>2]>>2];else{g=e[A+16>>2]<<2,q=e[g+e[a+276>>2]>>2],e[24+d>>2]=q,g=e[g+e[a+280>>2]>>2],e[28+d>>2]=g,e[16+d>>2]=0,_=e[12+(F=y+(D<<5)|0)>>2]==1?v(-10):v(-.10000000149011612),R[20+d>>2]=_,e[60+d>>2]=g,e[56+d>>2]=q,L[e[F+24>>2]](a,D,56+d|0,48+d|0,1),S=v(1),y=9;r:{for(;;){if(g=y,k=v(S*v(0)),R[32+d>>2]=k+R[56+d>>2],P=v(_*S),R[36+d>>2]=P+R[60+d>>2],L[e[F+24>>2]](a,D,32+d|0,40+d|0,1),f=v(R[44+d>>2]-R[52+d>>2]),R[44+d>>2]=f,E=v(R[40+d>>2]-R[48+d>>2]),R[40+d>>2]=E,f!=v(0)||E!=v(0)){y=e[44+d>>2],e[8+d>>2]=e[40+d>>2],e[12+d>>2]=y;break r}if(R[32+d>>2]=R[56+d>>2]-k,R[36+d>>2]=R[60+d>>2]-P,L[e[F+24>>2]](a,D,32+d|0,40+d|0,1),k=v(R[40+d>>2]-R[48+d>>2]),R[40+d>>2]=k,P=v(R[44+d>>2]-R[52+d>>2]),(R[44+d>>2]=P)!=v(0)||k!=v(0)){R[12+d>>2]=-P,R[8+d>>2]=-k;break r}if(y=g+-1|0,S=v(S*v(.10000000149011612)),!g)break}Ut(3,1311,0)}S=function(tt,ut){var mt=v(0);if((mt=v(ki(R[4+tt>>2],R[tt>>2])-ki(R[4+ut>>2],R[ut>>2])))<v(-3.1415927410125732))for(;(mt=v(mt+v(6.2831854820251465)))<v(-3.1415927410125732););if(mt>v(3.1415927410125732))for(;(mt=v(mt+v(-6.2831854820251465)))>v(3.1415927410125732););return mt}(16+d|0,8+d|0),L[e[F+24>>2]](a,e[A+8>>2],24+d|0,24+d|0,1),y=e[A+16>>2]<<2,e[y+e[a+276>>2]>>2]=e[24+d>>2],e[y+e[a+280>>2]>>2]=e[28+d>>2],g=y+e[a+284>>2]|0,R[g>>2]=R[g>>2]+v(v(S*v(-180))/v(3.1415927410125732)),A=e[A+8>>2]<<2,R[(g=p<<2)+X>>2]=R[y+e[a+268>>2]>>2]*R[A+X>>2],y=y+e[a+272>>2]|0,S=v(R[y>>2]*R[A+V>>2]),R[g+V>>2]=S,R[y>>2]=S}4<=H[e[a>>2]+4|0]&&(g=p<<2,A=e[a+308>>2]+(p<<5)|0,D=e[A+16>>2]<<2,y=e[a+328>>2],p=e[a+324>>2],(0|(F=e[A+8>>2]))==-1?(F=e[a+296>>2],e[(A=g<<2)+p>>2]=e[F+(D<<=2)>>2],e[(V=4|A)+p>>2]=e[(X=4|D)+F>>2],e[(q=8|A)+p>>2]=e[F+(u=8|D)>>2],e[p+((g|=3)<<2)>>2]=1065353216,a=e[a+300>>2],e[y+A>>2]=e[a+D>>2],e[y+V>>2]=e[a+X>>2],e[y+q>>2]=e[a+u>>2]):(D=(X=D<<2)+e[a+296>>2]|0,R[(A=(V=g<<2)+p|0)>>2]=R[D>>2]*R[(F=(q=F<<4)+p|0)>>2],R[A+4>>2]=R[D+4>>2]*R[F+4>>2],R[A+8>>2]=R[D+8>>2]*R[F+8>>2],e[p+((g|=3)<<2)>>2]=1065353216,a=X+e[a+300>>2]|0,S=R[a>>2],k=R[(A=y+q|0)>>2],R[(p=y+V|0)>>2]=v(S+k)-v(S*k),S=R[a+4>>2],k=R[A+4>>2],R[p+4>>2]=v(S+k)-v(S*k),S=R[a+8>>2],k=R[A+8>>2],R[p+8>>2]=v(S+k)-v(S*k)),e[y+(g<<2)>>2]=1065353216),K=64+d|0},L[5]=function(a,p){return a|=0,p|=0,v(0),v(0),0|((a=R[a>>2])<(p=R[p>>2])?-1:p<a)},L[6]=function(a,p,P,_){a|=0,p|=0,P|=0,_|=0;var f=0,E=0,u=v(0),d=0,g=0,y=0,A=0,S=0;if(1<=(0|(d=e[a+8>>2])))for(y=e[a+12>>2],g=e[a+20>>2];R[(E=f<<2)+y>>2]=R[p+E>>2]*R[E+g>>2],(0|(f=f+1|0))<(0|d););if(!((0|(d=e[a>>2]))<1))if(y=e[a+4>>2],_)for(E=p=0;;){if(e[_>>2]){if((0|(f=e[(g=p<<2)+e[a+16>>2]>>2]))<1)u=v(0);else for(A=f+E|0,S=e[a+12>>2],u=v(0),f=E;u=v(u+R[S+(f<<2)>>2]),(0|(f=f+1|0))<(0|A););R[P+g>>2]=u}if(_=_+4|0,E=e[y+(p<<2)>>2]+E|0,!((0|(p=p+1|0))<(0|d)))break}else for(g=e[a+16>>2],p=_=0;;){if((0|(f=e[(E=_<<2)+g>>2]))<=0)u=v(0);else for(A=p+f|0,S=e[a+12>>2],u=v(0),f=p;u=v(u+R[S+(f<<2)>>2]),(0|(f=f+1|0))<(0|A););if(R[P+E>>2]=u,p=e[E+y>>2]+p|0,!((0|(_=_+1|0))<(0|d)))break}},L[7]=function(a,p,P,_){a|=0,p|=0,P|=0,_|=0;var f=0,E=v(0),u=0,d=0,g=0,y=0,A=0;if(1<=(0|(y=e[a+8>>2])))for(d=e[a+12>>2],g=e[a+20>>2];R[(u=f<<2)+d>>2]=R[p+u>>2]*R[u+g>>2],(0|(f=f+1|0))<(0|y););if(!((0|(f=e[a>>2]))<1))if(y=e[a+4>>2],_)for(u=p=0;;){if(e[_>>2]){if((0|(f=e[(d=p<<2)+e[a+16>>2]>>2]))<1)E=v(0);else for(g=f+u|0,A=e[a+12>>2],E=v(0),f=u;E=v(E+R[A+(f<<2)>>2]),(0|(f=f+1|0))<(0|g););f=P+d|0,E=v(E+v(.0010000000474974513)),d=v(St(E))<v(2147483648)?~~E:-2147483648,e[f>>2]=d,f=e[a>>2]}if(_=_+4|0,u=e[y+(p<<2)>>2]+u|0,!((0|(p=p+1|0))<(0|f)))break}else for(d=e[a+16>>2],p=_=0;;){if((0|(f=e[(u=_<<2)+d>>2]))<=0)E=v(0);else for(g=p+f|0,A=e[a+12>>2],E=v(0),f=p;E=v(E+R[A+(f<<2)>>2]),(0|(f=f+1|0))<(0|g););if(f=P+u|0,E=v(E+v(.0010000000474974513)),g=v(St(E))<v(2147483648)?~~E:-2147483648,e[f>>2]=g,p=e[u+y>>2]+p|0,!((0|(_=_+1|0))<e[a>>2]))break}},L[8]=function(a,p,P,_,f,E){a|=0,p|=0,P|=0,_|=0,f|=0,E|=0;var u,d,g=0,y=0,A=0,S=0,D=0,F=0,k=0,V=0,X=0,q=0,tt=v(0),ut=0,mt=e[a>>2];if(!((0|mt)<1))if(u=f<<2,d=e[a+4>>2],E)for(;;){if(e[E>>2]&&(A=e[(g=S<<2)+e[a+16>>2]>>2],k=e[P+g>>2],y=e[_+g>>2],(g=(0|(V=j(y,f)))<1)||Ce(k,0,j(y,u)),!(g|(0|A)<1)))for(X=A+F|0,q=e[a+20>>2],g=F;;){for(tt=R[(y=g<<2)+q>>2],ut=e[p+y>>2],D=0;R[(y=(A=D<<2)+k|0)>>2]=R[y>>2]+v(tt*R[A+ut>>2]),(0|V)!=(0|(D=D+1|0)););if(!((0|(g=g+1|0))<(0|X)))break}if(E=E+4|0,F=e[(S<<2)+d>>2]+F|0,!((0|(S=S+1|0))<(0|mt)))break}else for(E=0;;){if(A=e[(S=E<<2)+e[a+16>>2]>>2],k=e[P+S>>2],y=e[_+S>>2],(g=(0|(V=j(y,f)))<1)||Ce(k,0,j(y,u)),!(g|(0|A)<=0))for(X=A+F|0,q=e[a+20>>2],g=F;;){for(tt=R[(y=g<<2)+q>>2],ut=e[p+y>>2],D=0;R[(y=(A=D<<2)+k|0)>>2]=R[y>>2]+v(tt*R[A+ut>>2]),(0|V)!=(0|(D=D+1|0)););if(!((0|(g=g+1|0))<(0|X)))break}if(F=e[S+d>>2]+F|0,!((0|(E=E+1|0))<(0|mt)))break}},L[9]=function(a){var p,P,_,f=0,E=0,u=0,d=0;if(!(e[(a|=0)+648>>2]||(0|(f=e[a+332>>2]))<1))for(P=(E=e[a+336>>2])+j(f,20)|0,f=e[a+424>>2],d=e[a+444>>2];;){if(e[f>>2]&&!((0|(u=e[E+16>>2]))<(a=1)))for(u<<=1,_=e[d>>2];R[(p=(a<<2)+_|0)>>2]=-R[p>>2],(0|(a=a+2|0))<(0|u););if(d=d+4|0,f=f+4|0,!((E=E+20|0)>>>0<P>>>0))break}},L[10]=function(a,p,P){var _;return ge(_=e[20+(a|=0)>>2],p|=0,p=(P|=0)>>>0<(p=e[a+16>>2]-_|0)>>>0?P:p),e[a+20>>2]=p+e[a+20>>2],0|P},L[11]=function(a,p,P,_,f,E){a|=0,p=+p,P|=0,_|=0,f|=0,E|=0;var u,d,g,y,A=0,S=0,D=0,F=0,k=0,V=0,X=0,q=0,tt=0,ut=0,mt=0,kt=0,Ht=0,ce=0,we=0;if(e[44+(K=g=K-560|0)>>2]=0,je(+p),A=0|Wt[1],d=4294967295<Wt[0]>>>0?0:1,y=(0|A)<-1||(0|A)<=-1&&d?(je(p=-p),A=0|Wt[1],Wt[0],ce=1,3840):2048&f?(ce=1,3843):(ce=1&f)?3846:3841,(2146435072&A)==2146435072)We(a,32,P,V=ce+3|0,-65537&f),Fe(a,y,ce),_=E>>>5&1,Fe(a,p!=p?_?3867:3871:_?3859:3863,3);else if(p=function Ue(Ye,pe){var tr,Ot,fe=0;if(je(+Ye),fe=0|Wt[1],tr=0|Wt[0],(0|(fe=(Ot=fe)>>>20&2047))!=2047){if(!fe)return fe=pe,pe=Ye==0?0:(Ye=Ue(18446744073709552e3*Ye,pe),e[pe>>2]+-64|0),e[fe>>2]=pe,Ye;e[pe>>2]=fe+-1022,Yt(0,0|tr),Yt(1,-2146435073&Ot|1071644672),Ye=+Xe()}return Ye}(p,44+g|0),(p+=p)!=0&&(e[44+g>>2]=e[44+g>>2]+-1),u=16+g|0,(0|(d=32|E))==97){if(mt=(ut=32&E)?9+y|0:y,!(11<_>>>0)&&(A=12-_|0)){for(kt=8;kt*=16,A=A+-1|0;);p=H[0|mt]==45?-(kt+(-p-kt)):p+kt-kt}for((0|u)==(0|(A=ye((D=(A=e[44+g>>2])>>31)^A+D,0,u)))&&(O[15+g|0]=48,A=15+g|0),k=2|ce,D=e[44+g>>2],O[0|(tt=A+-2|0)]=E+15,O[A+-1|0]=(0|D)<0?45:43,A=8&f,S=16+g|0;E=S,q=ut,D=St(p)<2147483648?~~p:-2147483648,O[0|S]=q|H[D+3824|0],((S=E+1|0)-(16+g|0)|0)!=1|((p=16*(p-(0|D)))==0?!(A|0<(0|_)):0)||(O[E+1|0]=46,S=E+2|0),p!=0;);We(a,32,P,V=(E=!_|(0|_)<=((S-g|0)-18|0)?((u-(16+g|0)|0)-tt|0)+S|0:2+((_+u|0)-tt|0)|0)+k|0,f),Fe(a,mt,k),We(a,48,P,V,65536^f),Fe(a,16+g|0,_=S-(16+g|0)|0),We(a,48,E-((A=_)+(_=u-tt|0)|0)|0,0,0),Fe(a,tt,_)}else{for(A=(0|_)<0,p==0?F=e[44+g>>2]:(F=e[44+g>>2]+-28|0,e[44+g>>2]=F,p*=268435456),X=A?6:_,D=ut=(0|F)<0?48+g|0:336+g|0;D=(_=D)+4|0,(p=1e9*(p-((e[_>>2]=A=p<4294967296&0<=p?~~p>>>0:0)>>>0)))!=0;);if((0|F)<1)A=D,S=ut;else for(S=ut;;){if(tt=(0|F)<29?F:29,!((A=D+-4|0)>>>0<S>>>0)){for(_=tt,q=0;we=q,q=e[(mt=A)>>2],k=31&_,k=32<=(63&_)>>>(V=0)?(F=q<<k,0):(F=(1<<k)-1&q>>>32-k,q<<k),V=F+V|0,V=(q=we+k|0)>>>0<k>>>0?V+1|0:V,we=mt,mt=So(q=Po(k=q,V,1e9),Vt,1e9),e[we>>2]=k-mt,S>>>0<=(A=A+-4|0)>>>0;);(_=q)&&(e[(S=S+-4|0)>>2]=_)}for(;S>>>0<(A=D)>>>0&&!e[(D=A+-4|0)>>2];);if(F=e[44+g>>2]-tt|0,D=A,!(0<(0|(e[44+g>>2]=F))))break}if((0|F)<=-1)for(Ht=1+((X+25|0)/9|0)|0,tt=(0|d)==102;;){if(q=(0|F)<-9?9:0-F|0,A>>>0<=S>>>0)S=e[S>>2]?S:S+4|0;else{for(mt=1e9>>>q,k=-1<<q^-1,F=0,D=S;_=e[D>>2],e[D>>2]=(_>>>q)+F,F=j(mt,_&k),(D=D+4|0)>>>0<A>>>0;);S=e[S>>2]?S:S+4|0,F&&(e[A>>2]=F,A=A+4|0)}if(F=q+e[44+g>>2]|0,A=(0|Ht)<A-(_=tt?ut:S)>>2?_+(Ht<<2)|0:A,!((0|(e[44+g>>2]=F))<0))break}if(!(A>>>(D=0)<=S>>>0||(D=j(ut-S>>2,9),(_=e[S>>2])>>>0<(F=10))))for(;D=D+1|0,(F=j(F,10))>>>0<=_>>>0;);if((0|(_=(X-((0|d)==102?0:D)|0)-((0|d)==103&(0|X)!=0)|0))<(j(A-ut>>2,9)+-9|0)){if(V=(ut+((_=(0|(k=_+9216|0))/9|0)<<2)|0)-4092|0,F=10,(0|(_=1+(k-j(_,9)|0)|0))<=8)for(;F=j(F,10),(0|(_=_+1|0))!=9;);if(Ht=V+4|0,((tt=(mt=e[V>>2])-j(F,k=(mt>>>0)/(F>>>0)|0)|0)||(0|Ht)!=(0|A))&&(kt=tt>>>0<(_=F>>>1)>>>0?.5:(0|A)==(0|Ht)&&(0|_)==(0|tt)?1:1.5,p=1&k?9007199254740994:9007199254740992,!ce|H[0|y]!=45||(kt=-kt,p=-p),e[V>>2]=_=mt-tt|0,p+kt!=p)){if(1e9<=(e[V>>2]=_=_+F|0)>>>0)for(;(V=V+-4|(e[V>>2]=0))>>>0<S>>>0&&(e[(S=S+-4|0)>>2]=0),_=e[V>>2]+1|0,999999999<(e[V>>2]=_)>>>0;);if(D=j(ut-S>>2,9),!((_=e[S>>2])>>>0<(F=10)))for(;D=D+1|0,(F=j(F,10))>>>0<=_>>>0;);}A=(_=V+4|0)>>>0<A>>>0?_:A}r:{for(;;){if((tt=A)>>>(mt=0)<=S>>>0)break r;if(e[(A=tt+-4|0)>>2])break}mt=1}if((0|d)!=103)k=8&f;else if(X=((_=(0|D)<(0|(A=X||1))&-5<(0|D))?-1^D:-1)+A|0,E=(_?-1:-2)+E|0,!(k=8&f)){if(A=9,mt&&(k=e[tt+-4>>2])&&!((k>>>(A=0))%(_=10)))for(;A=A+1|0,!((k>>>0)%((_=j(_,10))>>>0)););_=j(tt-ut>>2,9)+-9|0,X=(32|E)==102?((k=0)|X)<(0|(_=0<(0|(_=_-A|0))?_:0))?X:_:((k=0)|X)<(0|(_=0<(0|(_=(_+D|0)-A|0))?_:0))?X:_}if(V=(0|(F=X|k))!=0,_=a,we=P,A=0<(0|D)?D:0,(0|(q=32|E))!=102){if((u-(A=ye((A=D>>31)+D^A,0,u))|0)<=1)for(;O[0|(A=A+-1|0)]=48,(u-A|0)<2;);O[0|(Ht=A+-2|0)]=E,O[A+-1|0]=(0|D)<0?45:43,A=u-Ht|0}if(We(_,32,we,V=1+(A+(V+(X+ce|0)|0)|0)|0,f),Fe(a,y,ce),We(a,48,P,V,65536^f),(0|q)==102){for(_=16+g|8,D=16+g|9,S=E=ut>>>0<S>>>0?ut:S;;){if(A=ye(e[S>>2],0,D),(0|E)!=(0|S)){if(!(A>>>0<=16+g>>>0))for(;O[0|(A=A+-1|0)]=48,16+g>>>0<A>>>0;);}else(0|A)==(0|D)&&(O[24+g|0]=48,A=_);if(Fe(a,A,D-A|0),!((S=S+4|0)>>>0<=ut>>>0))break}F&&Fe(a,3875,1);r:if(!((0|X)<1|tt>>>0<=S>>>0))for(;;){if(16+g>>>0<(A=ye(e[S>>2],0,D))>>>0)for(;O[0|(A=A+-1|0)]=48,16+g>>>0<A>>>0;);if(Fe(a,A,(0|X)<9?X:9),X=X+-9|0,tt>>>0<=(S=S+4|0)>>>0)break r;if(!(0<(0|X)))break}We(a,48,X+9|0,9,0)}else{r:if(!((0|X)<0))for(E=mt?tt:S+4|0,_=16+g|8,ut=16+g|9,D=S;;){if((0|ut)==(0|(A=ye(e[D>>2],0,ut)))&&(O[24+g|0]=48,A=_),(0|S)!=(0|D)){if(!(A>>>0<=16+g>>>0))for(;O[0|(A=A+-1|0)]=48,16+g>>>0<A>>>0;);}else Fe(a,A,1),A=A+1|0,(0|X)<1&&!k||Fe(a,3875,1);if(Fe(a,q=A,(0|(A=ut-A|0))<(0|X)?A:X),X=X-A|0,E>>>0<=(D=D+4|0)>>>0)break r;if(!(-1<(0|X)))break}We(a,48,X+18|0,18,0),Fe(a,Ht,u-Ht|0)}}return We(a,32,P,V,8192^f),K=560+g|0,0|((0|V)<(0|P)?P:V)},L[12]=function(a,p){a|=0;var P=p|=0;p=e[p>>2]+15&-16,e[P>>2]=p+16,P=a,a=function(_,f,E,u){var d,g,y=0,A=0,S=0,D=0;return K=g=K-32|0,y=(D=y=2147483647&u)-1006698496|0,A=y=(d=A=S=E)>>>0<0?y+1|0:y,y=D-1140785152|0,(0|(y=S>>>0<0?y+1|0:y))==(0|A)&d>>>0<S>>>0|A>>>0<y>>>0?(y=u<<4|E>>>28,E=E<<4|f>>>28,(0|(S=f&=268435455))==134217728&1<=_>>>0|134217728<f>>>0?(y=y+1073741824|0,(_=E+1|0)>>>0<1&&(y=y+1|0),A=_):(y=y-(((A=E)>>>0<0)+-1073741824|0)|0,_|134217728^S||((_=A+(1&A)|0)>>>0<A>>>0&&(y=y+1|0),A=_))):(!S&(0|D)==2147418112?!(_|f):(0|D)==2147418112&S>>>0<0|D>>>0<2147418112)?(y=2146435072,((A=0)|D)==1140785151&4294967295<S>>>0|1140785151<D>>>0||(S=D>>>16)>>>(y=0)<15249||(function(F,k,V,X,q,tt){var ut,mt,kt=0,Ht=0;64&tt?(k=31&(V=tt-64|0),k=32<=(63&V)>>>0?(V=0,q>>>k):(V=q>>>k,((1<<k)-1&q)<<32-k|X>>>k),q=X=0):tt&&(Ht=q,kt=31&(mt=64-tt|0),mt=32<=(63&mt)>>>0?(Ht=X<<kt,0):(Ht=(1<<kt)-1&X>>>32-kt|Ht<<kt,X<<kt),ut=k,k=31&(kt=tt),k=32<=(63&kt)>>>0?(kt=0,V>>>k):(kt=V>>>k,((1<<k)-1&V)<<32-k|ut>>>k),k|=mt,V=kt|Ht,kt=X,X=31&tt,X=32<=(63&tt)>>>0?(Ht=0,q>>>X):(Ht=q>>>X,((1<<X)-1&q)<<32-X|kt>>>X),q=Ht),e[F>>2]=k,e[4+F>>2]=V,e[8+F>>2]=X,e[12+F>>2]=q}(g,_,f,E,y=65535&u|65536,15361-S|0),function(F,k,V,X,q,tt){var ut,mt,kt=0;64&tt?(X=k,k=31&(q=tt+-64|0),32<=(63&q)>>>0?(q=X<<k,X=0):(q=(1<<k)-1&X>>>32-k|V<<k,X<<=k),V=k=0):tt&&(mt=X,X=31&(ut=tt),mt=32<=(63&tt)>>>0?(kt=mt<<X,0):(kt=(1<<X)-1&mt>>>32-X|q<<X,mt<<X),X=V,q=31&(tt=64-tt|0),32<=(63&tt)>>>0?(tt=0,X>>>=q):(tt=X>>>q,X=((1<<q)-1&X)<<32-q|k>>>q),X|=mt,q=tt|kt,tt=k,k=31&ut,k=32<=(63&ut)>>>0?(kt=tt<<k,0):(kt=(1<<k)-1&tt>>>32-k|V<<k,tt<<k),V=kt),e[F>>2]=k,e[4+F>>2]=V,e[8+F>>2]=X,e[12+F>>2]=q}(16+g|0,_,f,E,y,S+-15233|0),E=e[4+g>>2],_=e[8+g>>2],y=e[12+g>>2]<<4|_>>>28,A=_<<4|E>>>28,(0|(E=_=268435455&E))==134217728&1<=(f=e[g>>2]|((e[16+g>>2]|e[24+g>>2])!=0|(e[20+g>>2]|e[28+g>>2])!=0))>>>0|134217728<_>>>0?((_=A+1|0)>>>0<1&&(y=y+1|0),A=_):f|134217728^E||((_=A+(1&A)|0)>>>0<A>>>0&&(y=y+1|0),A=_))):(A=E<<4|f>>>28,y=524287&(y=u<<4|E>>>28)|2146959360),K=32+g|0,Yt(0,0|A),Yt(1,-2147483648&u|y),+Xe()}(e[p>>2],e[p+4>>2],e[p+8>>2],e[p+12>>2]),ct[P>>3]=a},L[13]=function(a){return 0},L[14]=function(a,p,P){p|=0,P|=0;var _,f,E=0,u=0,d=0,g=0;for(K=f=K-32|0,E=e[28+(a|=0)>>2],e[16+f>>2]=E,d=e[a+20>>2],e[28+f>>2]=P,e[24+f>>2]=p,d=(e[20+f>>2]=p=d-E|0)+P|0,g=2,p=16+f|0;;){r:{if((u=(E=0)|Zt(e[a+60>>2],0|p,0|g,12+f|0))&&(e[2086]=u,E=-1),(0|(E=E?e[12+f>>2]=-1:e[12+f>>2]))==(0|d))p=e[a+44>>2],e[a+28>>2]=p,e[a+20>>2]=p,e[a+16>>2]=p+e[a+48>>2],a=P;else{if(-1<(0|E))break r;e[a+28>>2]=0,e[a+16>>2]=0,e[a+20>>2]=0,e[a>>2]=32|e[a>>2],((a=0)|g)!=2&&(a=P-e[p+4>>2]|0)}return K=32+f|0,0|a}u=e[p+4>>2],e[(p=(_=u>>>0<E>>>0)?p+8|0:p)>>2]=(u=E-(_?u:0)|0)+e[p>>2],e[p+4>>2]=e[p+4>>2]-u,d=d-E|0,g=g-_|0}},L[15]=function(a,p,P,_){return Vt=0},{d:function(){},e:function(){return e[1805]},f:function(){return 83886080},g:function(){return 5},h:function(a,p){return p|=0,K=p=K-16|0,a=(a|=0)?ur(a)?(Ut(4,2150,0),0):H[a+4|0]:(e[p+4>>2]=1444,e[p>>2]=2267,Ut(4,1294,p),0),K=p+16|0,0|a},i:function(a,p){var P;return p|=0,K=P=K-48|0,a=(a|=0)?(a+63&-64)!=(0|a)?(e[36+P>>2]=1522,e[32+P>>2]=2284,Ut(4,1294,32+P|0),0):(p+63&-64)==(0|p)&&p?function(_,f){var E,u=0,d=0,g=0,y=0,A=0,S=0,D=0,F=0,k=0,V=0,X=0,q=0,tt=0,ut=0,mt=0,kt=0,Ht=0,ce=0,we=0,Ue=0,Ye=0;K=A=(E=d=K)-704&-64;r:if(f>>>0<=1343)Ut(4,1235,0);else if(ur(_))Ut(4,1469,0);else if(d=H[0|(Ue=_+4|0)]){if(!(6<=d>>>0)){(kt=(0|!H[_+5|0])==1)||(Ee(Ue,1),vt(_- -64|0,4,160)),Ce(A- -64|0,0,640),ir(_,A- -64|0),d=_+f|0,f=e[A+64>>2];t:{e:{i:{if(5<=(mt=H[_+4|0])>>>0){if(f>>>0<_>>>0|d>>>0<f>>>0||(y=f+256|0)>>>0<_>>>0)break e;if(y>>>0<=d>>>0)break i;break e}if(f>>>0<_>>>0|d>>>0<f>>>0||(y=f+128|0)>>>0<_>>>0|d>>>0<y>>>0)break e}if(!((g=e[A+68>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<y>>>0||(g=g- -64|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(V=e[f>>2]))<0||(y=e[A+72>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(u=y)+(y=V<<2)|0)>>>0<_>>>0|d>>>0<g>>>0||(D=e[A+76>>2])>>>0<_>>>0|d>>>0<D>>>0|D>>>0<g>>>0||(u=(V<<6)+D|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+80>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+84>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+88>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+92>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+96>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+100>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+4>>2]))<0||(y=e[A+104>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(S=(g=y)+(y=u<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(g=e[A+108>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<S>>>0||(u=g+(u<<6)|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+112>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+116>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+120>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+124>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+128>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+132>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+136>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+8>>2]))<0||(y=e[A+140>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(X=u<<2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+144>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+X|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+148>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+X|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+156>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+X|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+160>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+X|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+164>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+X|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+12>>2]))<0||(y=e[A+172>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(q=u<<2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+176>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+q|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+180>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+q|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+188>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=y+q|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(g=e[f+16>>2]))<0||(y=e[A+192>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(S=(u=y)+(y=g<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+196>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+200>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+204>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+208>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+(g<<6)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+212>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+216>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+220>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+228>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+232>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+236>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+240>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+244>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+248>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(u=u+g|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+252>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+256>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+260>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+264>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+268>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+272>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(S=e[f+20>>2]))<0||(g=e[A+276>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(tt=(u=g)+(g=S<<2)|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[A+280>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(S=u+(S<<6)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+284>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+288>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+292>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+296>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+300>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+308>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+312>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[f+24>>2]))<0||(u=e[A+336>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+(tt<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[f+28>>2]))<0||(u=e[A+340>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=(ce=tt<<2)+u|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[A+344>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+ce|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[f+32>>2]))<0||(u=e[A+356>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(tt=(S=tt<<2)+u|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[A+360>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[A+364>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[A+368>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[A+372>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[A+376>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[A+380>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(0|(F=e[f+36>>2]))<0||(u=e[A+392>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(F=(tt=F<<2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[A+396>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+tt|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[A+400>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+tt|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+40>>2]))<0||(u=e[A+412>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(k<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+44>>2]))<0||(u=e[A+424>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(k<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+48>>2]))<0||(u=e[A+428>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=(k<<=2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[A+432>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+k|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+52>>2]))<0||(u=e[A+416>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=(k<<=2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[A+420>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+k|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+56>>2]))<0||(u=e[A+552>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(k<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+60>>2]))<0||(u=e[A+556>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(k<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+64>>2]))<0||(u=e[A+560>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(k<<1)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+68>>2]))<0||(u=e[A+564>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(k<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+72>>2]))<0||(u=e[A+568>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(k=(F=u)+(u=k<<2)|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+572>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+576>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+580>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+584>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+76>>2]))<0||(u=e[A+588>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(k=(F=k<<2)+u|0)>>>0<_>>>0|d>>>0<k>>>0||(u=e[A+592>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(u=e[A+596>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<k>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+80>>2]))<0||(u=e[A+600>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(ut=(F=u)+(u=k<<2)|0)>>>0<_>>>0|d>>>0<ut>>>0||(F=e[A+604>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<ut>>>0||(k=F+(k<<6)|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+608>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+612>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+616>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+620>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+624>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+628>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(k=u+F|0)>>>0<_>>>0|d>>>0<k>>>0||(F=e[A+632>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<k>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+84>>2]))<0||(u=e[A+636>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(k<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[A+640>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(k<<1)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(k=e[f+88>>2]))<0||(u=e[A+644>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(u=u+(k<<2)|0)>>>0<_>>>0|d>>>0<u>>>0)){if(!(mt>>>0<2)&&((F=e[A+168>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<u>>>0||(u=F+X|0)>>>0<_>>>0|d>>>0<u>>>0||!(mt>>>0<4)&&((F=e[A+324>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<u>>>0||(F=g+F|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[A+328>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+g|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[A+332>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+g|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[A+152>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(X=u+X|0)>>>0<_>>>0|d>>>0<X>>>0||(u=e[A+184>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<X>>>0||(X=u+q|0)>>>0<_>>>0|d>>>0<X>>>0||(u=e[A+224>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<X>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(X=e[f+92>>2]))<0||(y=e[A+648>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(X=(u=X<<2)+y|0)>>>0<_>>>0|d>>>0<X>>>0||(y=e[A+652>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<X>>>0||(X=u+y|0)>>>0<_>>>0|d>>>0<X>>>0||(y=e[A+656>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<X>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(X=e[f+96>>2]))<0||(y=e[A+660>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(X=(u=X<<2)+y|0)>>>0<_>>>0|d>>>0<X>>>0||(y=e[A+664>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<X>>>0||(X=u+y|0)>>>0<_>>>0|d>>>0<X>>>0||(y=e[A+668>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<X>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+304>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+316>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+320>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+100>>2]))<0||(y=e[A+436>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+440>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+444>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+104>>2]))<0||(y=e[A+448>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=y)+(y=u<<2)|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+452>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+456>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+460>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[A+464>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+108>>2]))<0||(y=e[A+480>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+484>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+488>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+112>>2]))<0||(y=e[A+504>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+508>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+512>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+116>>2]))<0||(y=e[A+528>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+(u<<2)|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+120>>2]))<0||(y=e[A+532>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+536>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+540>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+124>>2]))<0||(y=e[A+544>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(u<<=2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+548>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0)))break e;if(mt>>>0<5||!((y=e[A+348>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=y+ce|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+352>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+ce|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+384>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+S|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+388>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+S|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+404>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+tt|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[A+408>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+tt|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+128>>2]))<0||(y=e[A+468>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+472>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+476>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+132>>2]))<0||(y=e[A+492>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+496>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+500>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[f+136>>2]))<0||(y=e[A+516>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+520>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[A+524>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(y=g+y|0)>>>0<_>>>0)&&y>>>0<=d>>>0)break t}}Ut(4,1760,0),Ee(Ue,1),vt(_- -64|0,4,160);break r}kt||(es(_),O[_+5|0]=0,f=e[A+64>>2],V=e[f>>2],D=e[A+76>>2],mt=H[_+4|0]);t:{if((_=0)<(0|V)){for(;;){if(63<he((_<<6)+D|0)>>>0)break t;if((0|V)==(0|(_=_+1|0)))break}if(u=f+48|0,(d=0)<(0|(_=e[f>>2]))){for(y=e[f+48>>2],g=e[A+80>>2];;){if((0|(D=e[g+(d<<2)>>2]))<0|(0|y)<=(0|D))break t;if((0|_)==(0|(d=d+1|0)))break}for(tt=f+24|0,y=e[f+24>>2],S=e[A+88>>2],V=e[A+84>>2],d=0;;){if((g=e[(D=d<<2)+S>>2])&&((0|g)<0|(0|y)<(0|g)||(0|(D=e[D+V>>2]))<0|(0|y)<=(0|D)||(g=g+D|0)>>>31|(0|y)<(0|g)))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[A+92>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[A+96>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[A+100>>2];;){if((0|(g=e[y+(d<<2)>>2]))<-1|(0|_)<=(0|g))break t;if((0|_)==(0|(d=d+1|0)))break}}else tt=f+24|0}else tt=f+24|0,u=f+48|0;if((_=0)<(0|(d=e[f+4>>2]))){for(y=e[A+108>>2];;){if(63<he(y+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(S=(y=e[f+48>>2])+-1|0,!(((d=0)|(_=e[f+4>>2]))<=0)){for(g=e[A+112>>2];;){if((0|(D=e[g+(d<<2)>>2]))<0|(0|y)<=(0|D))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[A+116>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[A+120>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(y=e[f>>2],d=0,g=e[A+124>>2];;){if((0|(D=e[g+(d<<2)>>2]))<-1|(0|y)<=(0|D))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[A+128>>2];;){if((0|(g=e[y+(d<<2)>>2]))<-1|(0|_)<=(0|g))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[A+132>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(g=f+8|0,D=f+12|0,V=e[A+136>>2],d=0;;){if(1<(q=e[(X=d<<2)+y>>2])>>>0||(0|(X=e[V+X>>2]))<0|(0|X)>=e[(q-1|0?g:D)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}}}else S=e[u>>2]+-1|0;if((_=0)<(0|(d=e[f+8>>2]))){for(y=e[A+140>>2];;){if((0|(g=e[y+(_<<2)>>2]))<0|(0|S)<(0|g))break t;if((0|d)==(0|(_=_+1|0)))break}for(ce=f+28|0,y=e[f+28>>2],V=e[A+148>>2],X=e[A+144>>2],_=0;;){if((g=e[(D=_<<2)+V>>2])&&((0|g)<0|(0|y)<(0|g)||(0|(D=e[D+X>>2]))<0|(0|y)<=(0|D)||(g=g+D|0)>>>31|(0|y)<(0|g)))break t;if((0|d)==(0|(_=_+1|0)))break}for(_=0,g=e[A+156>>2],D=e[A+164>>2],V=e[A+160>>2];;){if((0|(X=e[(y=_<<2)+V>>2]))<1||(0|(q=e[y+D>>2]))<1||(0|(y=e[g+y>>2]))<1|(0|y)!=(0|j(q+1|0,X+1|0)))break t;if((0|d)==(0|(_=_+1|0)))break}}else ce=f+28|0;if((_=0)<(0|(g=e[f+12>>2]))){for(d=e[A+172>>2];;){if((0|(y=e[d+(_<<2)>>2]))<0|(0|S)<(0|y))break t;if((0|g)==(0|(_=_+1|0)))break}for(F=f+32|0,d=e[f+32>>2],S=e[A+180>>2],V=e[A+176>>2],_=0;;){if((y=e[(D=_<<2)+S>>2])&&((0|y)<0|(0|d)<(0|y)||(0|(D=e[D+V>>2]))<0|(0|d)<=(0|D)||(y=y+D|0)>>>31|(0|d)<(0|y)))break t;if((0|g)==(0|(_=_+1|0)))break}}else F=f+32|0;y=f+16|0;e:{i:{if(!(((_=0)|(d=e[f+16>>2]))<=0)){for(g=e[A+208>>2];;){if(63<he(g+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(!(((d=0)|(_=e[y>>2]))<=0)){for(g=e[u>>2],D=e[A+212>>2];;){if((0|(S=e[D+(d<<2)>>2]))<0|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(Ue=f+36|0,g=e[f+36>>2],V=e[A+220>>2],X=e[A+216>>2],d=0;;){if((D=e[(S=d<<2)+V>>2])&&((0|D)<0|(0|g)<(0|D)||(0|(S=e[S+X>>2]))<0|(0|g)<=(0|S)||(D=D+S|0)>>>31|(0|g)<(0|D)))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[A+228>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[A+232>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[f>>2],d=0,D=e[A+236>>2];;){if((0|(S=e[D+(d<<2)>>2]))<-1|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[f+4>>2],d=0,D=e[A+240>>2];;){if((0|(S=e[D+(d<<2)>>2]))<-1|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[A+244>>2],d=0;;){if(e[g+(d<<2)>>2]<0)break t;if((0|_)==(0|(d=d+1|0)))break}break i}}D=f+68|0,Ue=f+36|0;break e}for(g=e[A+252>>2],d=0;;){if(e[g+(d<<2)>>2]<0)break t;if((0|_)==(0|(d=d+1|0)))break}for(D=e[f+60>>2],d=0,S=e[A+256>>2];;){if((V=e[(V=d<<2)+S>>2]+(e[g+V>>2]<<1)|0)>>>31|(0|D)<(0|V))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[f+64>>2],V=e[A+264>>2],X=e[A+260>>2],d=0;;){if((D=e[(S=d<<2)+V>>2])&&((0|D)<0|(0|g)<(0|D)||(0|(S=e[S+X>>2]))<0|(0|g)<=(0|S)||(D=D+S|0)>>>31|(0|g)<(0|D)))break t;if((0|_)==(0|(d=d+1|0)))break}for(D=f+68|0,g=e[f+68>>2],X=e[A+272>>2],q=e[A+268>>2],d=0;;){if((S=e[(V=d<<2)+X>>2])&&((0|S)<0|(0|g)<(0|S)||(0|(V=e[V+q>>2]))<0|(0|g)<=(0|V)||(S=S+V|0)>>>31|(0|g)<(0|S)))break t;if((0|_)==(0|(d=d+1|0)))break}}e:{i:{if(!(((_=0)|(d=e[f+20>>2]))<=0)){for(g=e[A+280>>2];;){if(63<he(g+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(!(((_=0)|(d=e[f+20>>2]))<=0)){for(g=e[A+296>>2];;){if(1<rt[g+(_<<2)>>2])break t;if((0|d)==(0|(_=_+1|0)))break}for(g=e[A+300>>2],_=0;;){if(e[g+(_<<2)>>2]<0)break t;if((0|d)==(0|(_=_+1|0)))break}break i}}_=e[f+52>>2];break e}for(_=e[f+52>>2],X=e[A+312>>2],q=e[A+308>>2],S=0;;){if((g=e[(V=S<<2)+X>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(V=e[V+q>>2]))<0|(0|_)<=(0|V)||(g=g+V|0)>>>31|(0|_)<(0|g)))break t;if((0|d)==(0|(S=S+1|0)))break}}if(g=e[f+40>>2],(d=0)<(0|(S=e[f+8>>2])))for(V=e[A+344>>2],X=e[A+156>>2];;){if((q=e[(q=d<<2)+V>>2]+(e[X+q>>2]<<1)|0)>>>31|(0|g)<(0|q))break t;if((0|S)==(0|(d=d+1|0)))break}if((d=0)<(0|(S=e[F>>2]))){for(V=e[A+376>>2];;){if(1<rt[V+(d<<2)>>2])break t;if((0|S)==(0|(d=d+1|0)))break}for(d=0,V=e[A+380>>2];;){if(1<rt[V+(d<<2)>>2])break t;if((0|S)==(0|(d=d+1|0)))break}}if((d=0)<(0|(S=e[y>>2])))for(V=e[A+400>>2],X=e[A+252>>2];;){if((q=e[(q=d<<2)+V>>2]+(e[X+q>>2]<<1)|0)>>>31|(0|g)<(0|q))break t;if((0|S)==(0|(d=d+1|0)))break}if((d=0)<(0|(g=e[f+44>>2])))for(V=e[A+424>>2];;){if((0|(X=e[V+(d<<2)>>2]))<0|(0|_)<=(0|X))break t;if((0|g)==(0|(d=d+1|0)))break}if(1<=(0|(X=e[u>>2])))for(d=0,q=e[A+432>>2],k=e[A+428>>2];;){if((u=e[(V=d<<2)+q>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(V=e[k+V>>2]))<0|(0|g)<=(0|V)||(u=u+V|0)>>>31|(0|g)<(0|u)))break t;if((0|X)==(0|(d=d+1|0)))break}if(1<=(0|_))for(g=e[f+56>>2],d=0,X=e[A+420>>2],q=e[A+416>>2];;){if((u=e[(V=d<<2)+X>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(V=e[V+q>>2]))<0|(0|g)<=(0|V)||(u=u+V|0)>>>31|(0|g)<(0|u)))break t;if((0|(d=d+1|0))==(0|_))break}if((_=0)<(0|(d=e[D>>2])))for(g=e[A+564>>2];;){if((0|(D=e[g+(_<<2)>>2]))<-1|(0|S)<=(0|D))break t;if((0|d)==(0|(_=_+1|0)))break}if(_=e[f+76>>2],1<=(0|(D=e[f+72>>2])))for(d=0,S=e[A+572>>2],V=e[A+568>>2];;){if((g=e[(u=d<<2)+S>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+V>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|D)==(0|(d=d+1|0)))break}if((d=0)<(0|_)){for(g=e[A+588>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(u=e[A+592>>2],d=0;;){if(1<(V=e[(S=d<<2)+g>>2])>>>0||(0|(S=e[u+S>>2]))<0|(0|S)>=e[(V-1|0?y:f)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[A+596>>2];;){if((0|(u=e[g+(d<<2)>>2]))<-1|(0|D)<=(0|u))break t;if((0|_)==(0|(d=d+1|0)))break}}e:{if(!(((_=0)|(S=e[f+80>>2]))<=0)){for(d=e[A+604>>2];;){if(63<he(d+(_<<6)|0)>>>0)break t;if((0|S)==(0|(_=_+1|0)))break}if(!(((_=0)|(S=e[f+80>>2]))<=0)){for(d=e[f+48>>2],g=e[A+608>>2];;){if((0|(D=e[g+(_<<2)>>2]))<0|(0|d)<=(0|D))break t;if((0|S)==(0|(_=_+1|0)))break}for(X=e[f+88>>2],D=e[A+616>>2],u=e[A+612>>2],_=0;;){if((d=e[(g=_<<2)+D>>2])&&((0|d)<0|(0|X)<(0|d)||(0|(g=e[u+g>>2]))<0|(0|X)<=(0|g)||(d=d+g|0)>>>31|(0|X)<(0|d)))break t;if((0|S)==(0|(_=_+1|0)))break}for(y=e[y>>2],D=e[A+620>>2],_=0;;){if((0|(d=e[D+(_<<2)>>2]))<0|(0|y)<=(0|d))break t;if((0|S)==(0|(_=_+1|0)))break}for(u=e[A+624>>2],_=0;;){if((0|(d=e[u+(_<<2)>>2]))<0|(0|y)<=(0|d))break t;if((0|S)==(0|(_=_+1|0)))break}for(d=e[f+84>>2],V=e[A+632>>2],q=e[A+628>>2],_=0;;){if((g=e[(k=_<<2)+V>>2])&&((0|g)<0|(0|d)<(0|g)||(0|(k=e[k+q>>2]))<0|(0|d)<=(0|k)||(g=g+k|0)>>>31|(0|d)<(0|g)))break t;if((0|S)==(0|(_=_+1|0)))break}for(ut=e[A+640>>2],d=e[A+252>>2],g=0;;){if(0<(0|(kt=e[(_=g<<2)+V>>2])))for(k=ut+(e[_+q>>2]<<1)|0,Ye=e[d+(e[_+u>>2]<<2)>>2],Ht=e[d+(e[_+D>>2]<<2)>>2],_=0;;){if((0|Ye)<=W[k+(2|(we=_<<1))>>1]|(0|Ht)<=W[k+we>>1])break t;if(!((0|(_=_+2|0))<(0|kt)))break}if((0|S)==(0|(g=g+1|0)))break}break e}}y=e[f+16>>2],X=e[f+88>>2]}if(!((255&mt)>>>0<2)){if((_=0)<(0|(V=e[f+8>>2])))for(d=e[A+168>>2];;){if(1<rt[d+(_<<2)>>2])break t;if((0|V)==(0|(_=_+1|0)))break}if(!((255&mt)>>>0<4)){if(D=e[f+56>>2],1<=(0|(q=e[f+20>>2])))for(u=e[A+332>>2],k=e[A+328>>2],_=0;;){if((d=e[(g=_<<2)+u>>2])&&((0|d)<0|(0|D)<(0|d)||(0|(g=e[g+k>>2]))<0|(0|D)<=(0|g)||(d=d+g|0)>>>31|(0|D)<(0|d)))break t;if((0|q)==(0|(_=_+1|0)))break}if((0|(_=e[f+92>>2]))!=e[f+96>>2])break t;if(1<=(0|V))for(k=e[A+152>>2],d=0,ut=e[A+148>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+k>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|V)==(0|(d=d+1|0)))break}if(1<=(0|(Ye=e[f+12>>2])))for(k=e[A+184>>2],d=0,ut=e[A+180>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+k>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|Ye)==(0|(d=d+1|0)))break}if(1<=(0|y))for(k=e[A+224>>2],d=0,ut=e[A+220>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+k>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|y)==(0|(d=d+1|0)))break}if((d=0)<(0|q)){for(g=e[A+304>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|q)==(0|(d=d+1|0)))break}for(g=e[f+100>>2],ut=e[A+320>>2],kt=e[A+316>>2],d=0;;){if((u=e[(k=d<<2)+ut>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(k=e[k+kt>>2]))<0|(0|g)<=(0|k)||(u=u+k|0)>>>31|(0|g)<(0|u)))break t;if((0|q)==(0|(d=d+1|0)))break}}else g=e[f+100>>2];if(1<=(0|g)){for(k=e[A+440>>2],d=0,kt=e[A+436>>2];;){if((u=e[(ut=d<<2)+k>>2])&&((0|u)<0|(0|D)<(0|u)||(0|(ut=e[ut+kt>>2]))<0|(0|D)<=(0|ut)||(u=u+ut|0)>>>31|(0|D)<(0|u)))break t;if((0|g)==(0|(d=d+1|0)))break}for(D=e[A+444>>2],d=0;;){if((0|(ut=e[(u=d<<2)+D>>2]))<0|(0|ut)>=e[u+k>>2])break t;if((0|g)==(0|(d=d+1|0)))break}}if((D=0)<(0|(d=e[f+104>>2]))){for(u=e[A+448>>2];;){if((0|(k=e[u+(D<<2)>>2]))<0|(0|g)<=(0|k))break t;if((0|d)==(0|(D=D+1|0)))break}for(u=e[f+116>>2],ut=e[A+464>>2],kt=e[A+460>>2],g=0;;){if((D=e[(k=g<<2)+ut>>2])&&((0|D)<0|(0|u)<(0|D)||(0|(k=e[k+kt>>2]))<0|(0|u)<=(0|k)||(D=D+k|0)>>>31|(0|u)<(0|D)))break t;if((0|d)==(0|(g=g+1|0)))break}}else u=e[f+116>>2];if((g=0)<(0|(k=e[f+108>>2]))){for(D=e[A+480>>2];;){if((0|(ut=e[D+(g<<2)>>2]))<0|(0|V)<=(0|ut))break t;if((0|k)==(0|(g=g+1|0)))break}for(ut=e[A+488>>2],Ht=e[A+484>>2],g=0;;){if((D=e[(V=g<<2)+ut>>2])&&((0|D)<0|(0|d)<(0|D)||(0|(V=e[V+Ht>>2]))<0|(0|d)<=(0|V)||(D=D+V|0)>>>31|(0|d)<(0|D)))break t;if((0|k)==(0|(g=g+1|0)))break}for(ut=e[ce>>2],g=e[A+456>>2],V=e[A+452>>2],D=0;;){if(we=e[Ht+(D<<2)>>2]<<2,(kt=e[we+g>>2])&&((0|kt)<0|(0|ut)<(0|kt)||(0|(we=e[V+we>>2]))<0|(0|ut)<=(0|we)||(0|(kt=kt+we|0))<0|(0|ut)<(0|kt)))break t;if((0|k)==(0|(D=D+1|0)))break}}else g=e[A+456>>2],V=e[A+452>>2];if((D=0)<(0|(k=e[f+112>>2]))){for(ut=e[A+504>>2];;){if((0|(kt=e[ut+(D<<2)>>2]))<0|(0|y)<=(0|kt))break t;if((0|k)==(0|(D=D+1|0)))break}for(Ht=e[A+512>>2],kt=e[A+508>>2],y=0;;){if((D=e[(ut=y<<2)+Ht>>2])&&((0|D)<0|(0|d)<(0|D)||(0|(ut=e[ut+kt>>2]))<0|(0|d)<=(0|ut)||(D=D+ut|0)>>>31|(0|d)<(0|D)))break t;if((0|k)==(0|(y=y+1|0)))break}for(D=e[Ue>>2],y=0;;){if(Ht=e[kt+(y<<2)>>2]<<2,(ut=e[Ht+g>>2])&&((0|ut)<0|(0|D)<(0|ut)||(0|(Ht=e[V+Ht>>2]))<0|(0|D)<=(0|Ht)||(0|(ut=ut+Ht|0))<0|(0|D)<(0|ut)))break t;if((0|k)==(0|(y=y+1|0)))break}}if(D=e[f+120>>2],(y=0)<(0|u))for(k=e[A+528>>2];;){if((0|(ut=e[k+(y<<2)>>2]))<0|(0|D)<=(0|ut))break t;if((0|(y=y+1|0))==(0|u))break}if((y=0)<(0|D)){for(u=e[A+532>>2];;){if((0|(k=e[u+(y<<2)>>2]))<-1|(0|q)<=(0|k))break t;if((0|D)==(0|(y=y+1|0)))break}for(u=e[f+124>>2],ut=e[A+540>>2],kt=e[A+536>>2],y=0;;){if((q=e[(k=y<<2)+ut>>2])&&((0|q)<0|(0|u)<(0|q)||(0|(k=e[k+kt>>2]))<0|(0|u)<=(0|k)||(q=k+q|0)>>>31|(0|u)<(0|q)))break t;if((0|D)==(0|(y=y+1|0)))break}}if(!((255&mt)>>>0<5)){if((y=0)<(0|(mt=e[ce>>2]))){for(D=e[A+348>>2];;){if((0|(u=e[D+(y<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|mt)==(0|(y=y+1|0)))break}for(D=e[A+352>>2],y=0;;){if((0|(u=e[D+(y<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|mt)==(0|(y=y+1|0)))break}}if((mt=0)<(0|(y=e[F>>2]))){for(D=e[A+384>>2];;){if((0|(u=e[D+(mt<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|y)==(0|(mt=mt+1|0)))break}for(D=e[A+388>>2],mt=0;;){if((0|(u=e[D+(mt<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|y)==(0|(mt=mt+1|0)))break}}if((mt=0)<(0|(D=e[Ue>>2]))){for(u=e[A+404>>2];;){if((0|(q=e[u+(mt<<2)>>2]))<0|(0|_)<(0|q))break t;if((0|D)==(0|(mt=mt+1|0)))break}for(u=e[A+408>>2],mt=0;;){if((0|(q=e[u+(mt<<2)>>2]))<0|(0|_)<(0|q))break t;if((0|D)==(0|(mt=mt+1|0)))break}}if((_=0)<(0|(mt=e[f+128>>2]))){for(D=e[f>>2],u=e[A+468>>2];;){if((0|(q=e[u+(_<<2)>>2]))<0|(0|D)<=(0|q))break t;if((0|mt)==(0|(_=_+1|0)))break}for(ce=e[A+476>>2],q=e[A+472>>2],_=0;;){if((D=e[(u=_<<2)+ce>>2])&&((0|D)<0|(0|d)<(0|D)||(0|(u=e[u+q>>2]))<0|(0|d)<=(0|u)||(D=u+D|0)>>>31|(0|d)<(0|D)))break t;if((0|mt)==(0|(_=_+1|0)))break}for(D=e[tt>>2],_=0;;){if(tt=e[q+(_<<2)>>2]<<2,(u=e[tt+g>>2])&&((0|u)<0|(0|D)<(0|u)||(0|(tt=e[V+tt>>2]))<0|(0|D)<=(0|tt)||(0|(u=u+tt|0))<0|(0|D)<(0|u)))break t;if((0|mt)==(0|(_=_+1|0)))break}}if((_=0)<(0|(mt=e[f+132>>2]))){for(D=e[A+492>>2];;){if((0|(u=e[D+(_<<2)>>2]))<0|(0|Ye)<=(0|u))break t;if((0|mt)==(0|(_=_+1|0)))break}for(tt=e[A+500>>2],u=e[A+496>>2],_=0;;){if((D=e[(q=_<<2)+tt>>2])&&((0|D)<0|(0|d)<(0|D)||(0|(q=e[u+q>>2]))<0|(0|d)<=(0|q)||(D=D+q|0)>>>31|(0|d)<(0|D)))break t;if((0|mt)==(0|(_=_+1|0)))break}for(_=0;;){if(q=e[u+(_<<2)>>2]<<2,(D=e[q+g>>2])&&((0|D)<0|(0|y)<(0|D)||(0|(q=e[V+q>>2]))<0|(0|y)<=(0|q)||(0|(D=D+q|0))<0|(0|y)<(0|D)))break t;if((0|mt)==(0|(_=_+1|0)))break}}if(!(((_=0)|(f=e[f+136>>2]))<=0)){for(y=e[A+516>>2];;){if((0|(mt=e[y+(_<<2)>>2]))<0|(0|S)<=(0|mt))break t;if((0|f)==(0|(_=_+1|0)))break}for(D=e[A+524>>2],y=e[A+520>>2],_=0;;){if((A=e[(mt=_<<2)+D>>2])&&((0|A)<0|(0|d)<(0|A)||(0|(mt=e[y+mt>>2]))<0|(0|d)<=(0|mt)||(A=A+mt|0)>>>31|(0|d)<(0|A)))break t;if((0|f)==(0|(_=_+1|0)))break}for(_=0;;){if(A=e[y+(_<<2)>>2]<<2,(d=e[A+g>>2])&&((0|d)<0|(0|X)<(0|d)||(0|(A=e[A+V>>2]))<0|(0|X)<=(0|A)||(0|(d=d+A|0))<0|(0|X)<(0|d)))break t;if((0|f)==(0|(_=_+1|0)))break}}}}}return K=E,1}return Ut(4,1846,0),K=E,0}e[A+52>>2]=d,e[A+48>>2]=5,Ut(4,1640,A+48|0)}else e[A+32>>2]=d,Ut(4,1554,A+32|0);return K=E,0}(a,p):(e[20+P>>2]=1621,e[16+P>>2]=2284,Ut(4,1294,16+P|0),0):(e[4+P>>2]=1444,e[P>>2]=2284,Ut(4,1294,P),0),K=48+P|0,0|a},j:function(a){e[1805]=a|=0},k:function(a,p){var P;return p|=0,K=P=K-48|0,a=(a|=0)?(a+63&-64)!=(0|a)?(e[36+P>>2]=1522,e[32+P>>2]=2305,Ut(4,1294,32+P|0),0):(p+63&-64)==(0|p)&&p?function(_){var f,E,u,d,g=0,y=0,A=0,S=0,D=0,F=0,k=0,V=0;e[24+(K=f=K-32|0)>>2]=0,e[16+f>>2]=5,e[20+f>>2]=0,Ao(16+(K=d=K-272|0)|0,2227,e[12+d>>2]=16+f|0),function(X){var q;e[(K=q=K-16|0)>>2]=X,function(tt,ut){var mt;e[12+(K=mt=K-16|0)>>2]=ut,bo(tt,1432,ut,0,0),K=16+mt|0}(e[970],q),K=16+q|0}(16+d|0),K=272+d|0;r:{if(ur(_))Ut(4,1932,0);else{if(!(6<=(A=H[_+4|0])>>>0)){if((0|!H[_+5|0])!=1?(Ee(_+4|0,1),vt(_- -64|0,4,160),ir(_,_+704|(O[_+5|0]=0)),es(_)):ir(_,_+704|0),H[7224]||(e[1807]=6,O[7224]=1,e[1808]=7,e[1809]=8,e[1810]=9),y=e[_+704>>2],1<=(0|(A=e[y+16>>2]))){for(V=(S=e[_+912>>2])+(A<<2)|0,D=e[_+908>>2];;){k=e[_+1204>>2]+(e[D>>2]<<2)|0;t:if(!(((y=0)|(g=(A=e[S>>2])+-1|0))<1))e:for(;;){for(;;){if(e[(F=k+(y<<2)|0)>>2]<=-1){if(function(X,q,tt){var ut=0,mt=0;i:if((0|X)!=(0|q)){if(!(X>>>0<q+tt>>>0&&q>>>0<(mt=X+tt|0)>>>0))return ge(X,q,tt);if(ut=3&(X^q),X>>>0<q>>>0){if(!ut){if(3&X)for(;;){if(!tt)break i;if(O[0|X]=H[0|q],q=q+1|0,tt=tt+-1|0,!(3&(X=X+1|0)))break}if(!(tt>>>0<=3)){for(ut=tt;e[X>>2]=e[q>>2],q=q+4|0,X=X+4|0,3<(ut=ut+-4|0)>>>0;);tt&=3}}if(tt)for(;O[0|X]=H[0|q],X=X+1|0,q=q+1|0,tt=tt+-1|0;);}else{if(!ut){if(3&mt)for(;;){if(!tt)break i;if(O[0|(ut=(tt=tt+-1|0)+X|0)]=H[q+tt|0],!(3&ut))break}if(!(tt>>>0<=3))for(;e[(tt=tt+-4|0)+X>>2]=e[q+tt>>2],3<tt>>>0;);}if(tt)for(;O[(tt=tt+-1|0)+X|0]=H[q+tt|0],tt;);}}}(F,F+4|0,(-1^y)+A<<2),(0|y)<(0|(g=(A=g)+-1|0)))continue e;break t}if(!((0|(y=y+1|0))<(0|g)))break}break}if(y=S,0<(0|A)&&(A=e[k+(g<<2)>>2]<0?g:A),e[y>>2]=A,D=D+4|0,!((S=S+4|0)>>>0<V>>>0))break}y=e[_+704>>2]}if(1<=e[y>>2])for(g=0;e[e[_+712>>2]+(g<<2)>>2]=e[_+716>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y>>2];);if(1<=e[y+4>>2])for(g=0;e[e[_+744>>2]+(g<<2)>>2]=e[_+748>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+4>>2];);if(1<=e[y+16>>2])for(g=0;e[(A=g<<2)+e[_+832>>2]>>2]=e[_+848>>2]+(g<<6),e[A+e[_+836>>2]>>2]=e[_+1196>>2]+(e[A+e[_+896>>2]>>2]<<2),e[A+e[_+840>>2]>>2]=e[_+1200>>2]+(e[A+e[_+900>>2]>>2]<<1),e[A+e[_+844>>2]>>2]=e[_+1204>>2]+(e[A+e[_+908>>2]>>2]<<2),y=e[_+704>>2],(0|(g=g+1|0))<e[y+16>>2];);if(1<=e[y+20>>2])for(g=0;e[e[_+916>>2]+(g<<2)>>2]=e[_+920>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+20>>2];);if(1<=e[y+80>>2])for(g=0;e[e[_+1240>>2]+(g<<2)>>2]=e[_+1244>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+80>>2];);if(1&O[e[_+708>>2]+20|0]||(0|(S=e[y+16>>2]))<1)break r;for(g=e[_+904>>2],k=e[_+900>>2],F=e[_+1200>>2],D=0;;){if(0<(0|(V=e[(A=D<<2)+g>>2]+-1|0)))for(E=F+(e[A+k>>2]<<1)|0,y=0;u=W[(A=E+(y<<1)|0)>>1],N[A>>1]=W[A+4>>1],N[A+4>>1]=u,(0|(y=y+3|0))<(0|V););if((0|S)==(0|(D=D+1|0)))break}for(A=e[_+892>>2],D=e[_+896>>2],k=e[_+1196>>2],g=0;;){if(1<=(0|(F=e[(y=g<<2)+A>>2])))for(F=(y=k+(e[y+D>>2]<<2)|0)+(F<<3)|0,y=y+4|0;R[y>>2]=v(1)-R[y>>2],(y=y+8|0)>>>0<F>>>0;);if((0|S)==(0|(g=g+1|0)))break}break r}e[4+f>>2]=A,e[f>>2]=5,Ut(4,2023,f)}_=0}return K=32+f|0,_}(a):(e[20+P>>2]=1621,e[16+P>>2]=2305,Ut(4,1294,16+P|0),0):(e[4+P>>2]=1444,e[P>>2]=2305,Ut(4,1294,P),0),K=48+P|0,0|a},l:function(a,p,P,_){var f;p|=0,P|=0,_|=0,K=f=K+-64|0,(a|=0)?p?P?_?(a=e[e[a>>2]+708>>2],e[p>>2]=e[a+12>>2],e[p+4>>2]=e[a+16>>2],e[P>>2]=e[a+4>>2],e[P+4>>2]=e[a+8>>2],e[_>>2]=e[a>>2]):(e[52+f>>2]=1995,e[48+f>>2]=2325,Ut(4,1294,48+f|0)):(e[36+f>>2]=1903,e[32+f>>2]=2325,Ut(4,1294,32+f|0)):(e[20+f>>2]=1819,e[16+f>>2]=2325,Ut(4,1294,16+f|0)):(e[4+f>>2]=1740,e[f>>2]=2325,Ut(4,1294,f)),K=64+f|0},m:cr,n:jr,o:function(a){var p;K=p=K-16|0,(a|=0)?hi(a):(e[4+p>>2]=1740,e[p>>2]=2387,Ut(4,1294,p)),K=16+p|0},p:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+540>>2]:(e[4+p>>2]=1740,e[p>>2]=2402,Ut(4,1294,p),-1),K=16+p|0,0|a},q:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+916>>2]:(e[4+p>>2]=1740,e[p>>2]=2423,Ut(4,1294,p),0),K=16+p|0,0|a},r:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+548>>2]:(e[4+p>>2]=1740,e[p>>2]=2442,Ut(4,1294,p),0),K=16+p|0,0|a},s:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+928>>2]:(e[4+p>>2]=1740,e[p>>2]=2463,Ut(4,1294,p),0),K=16+p|0,0|a},t:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+924>>2]:(e[4+p>>2]=1740,e[p>>2]=2492,Ut(4,1294,p),0),K=16+p|0,0|a},u:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+932>>2]:(e[4+p>>2]=1740,e[p>>2]=2521,Ut(4,1294,p),0),K=16+p|0,0|a},v:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+552>>2]:(e[4+p>>2]=1740,e[p>>2]=2550,Ut(4,1294,p),0),K=16+p|0,0|a},w:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+4>>2]:(e[4+p>>2]=1740,e[p>>2]=2572,Ut(4,1294,p),-1),K=16+p|0,0|a},x:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+712>>2]:(e[4+p>>2]=1740,e[p>>2]=2588,Ut(4,1294,p),0),K=16+p|0,0|a},y:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+52>>2]:(e[4+p>>2]=1740,e[p>>2]=2602,Ut(4,1294,p),0),K=16+p|0,0|a},z:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+740>>2]:(e[4+p>>2]=1740,e[p>>2]=2622,Ut(4,1294,p),0),K=16+p|0,0|a},A:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+332>>2]:(e[4+p>>2]=1740,e[p>>2]=2650,Ut(4,1294,p),-1),K=16+p|0,0|a},B:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+832>>2]:(e[4+p>>2]=1740,e[p>>2]=2670,Ut(4,1294,p),0),K=16+p|0,0|a},C:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+888>>2]:(e[4+p>>2]=1740,e[p>>2]=2688,Ut(4,1294,p),0),K=16+p|0,0|a},D:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+432>>2]:(e[4+p>>2]=1740,e[p>>2]=2716,Ut(4,1294,p),0),K=16+p|0,0|a},E:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+884>>2]:(e[4+p>>2]=1740,e[p>>2]=2743,Ut(4,1294,p),0),K=16+p|0,0|a},F:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+440>>2]:(e[4+p>>2]=1740,e[p>>2]=2772,Ut(4,1294,p),0),K=16+p|0,0|a},G:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+436>>2]:(e[4+p>>2]=1740,e[p>>2]=2797,Ut(4,1294,p),0),K=16+p|0,0|a},H:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+448>>2]:(e[4+p>>2]=1740,e[p>>2]=2824,Ut(4,1294,p),0),K=16+p|0,0|a},I:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+912>>2]:(e[4+p>>2]=1740,e[p>>2]=2848,Ut(4,1294,p),0),K=16+p|0,0|a},J:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+844>>2]:(e[4+p>>2]=1740,e[p>>2]=2873,Ut(4,1294,p),0),K=16+p|0,0|a},K:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+892>>2]:(e[4+p>>2]=1740,e[p>>2]=2893,Ut(4,1294,p),0),K=16+p|0,0|a},L:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+444>>2]:(e[4+p>>2]=1740,e[p>>2]=2920,Ut(4,1294,p),0),K=16+p|0,0|a},M:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+836>>2]:(e[4+p>>2]=1740,e[p>>2]=2950,Ut(4,1294,p),0),K=16+p|0,0|a},N:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+904>>2]:(e[4+p>>2]=1740,e[p>>2]=2974,Ut(4,1294,p),0),K=16+p|0,0|a},O:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+840>>2]:(e[4+p>>2]=1740,e[p>>2]=3e3,Ut(4,1294,p),0),K=16+p|0,0|a},P:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+452>>2]:(e[4+p>>2]=1740,e[p>>2]=3022,Ut(4,1294,p),0),K=16+p|0,0|a},Q:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+456>>2]:(e[4+p>>2]=1740,e[p>>2]=3051,Ut(4,1294,p),0),K=16+p|0,0|a},R:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+876>>2]:(e[4+p>>2]=1740,e[p>>2]=3078,Ut(4,1294,p),0),K=16+p|0,0|a},S:function(a){var p;K=p=K-16|0,(a|=0)?e[a+428>>2]=1:(e[4+p>>2]=1740,e[p>>2]=3110,Ut(4,1294,p)),K=16+p|0},T:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+640>>2]:(e[4+p>>2]=1740,e[p>>2]=3139,Ut(4,1294,p),0),K=16+p|0,0|a},U:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+636>>2]:(e[4+p>>2]=1740,e[p>>2]=3164,Ut(4,1294,p),0),K=16+p|0,0|a},V:function(a){var p;return Ze(12+(K=p=K-16|0)|0,64,a|=0),K=16+p|0,e[12+p>>2]},W:function(a){var p,P,_=0;return K=P=K-16|0,!(a|=0)||Ze(12+P|0,16,p=cr(a))||(_=jr(a,e[12+P>>2],p))||(gr(e[12+P>>2]),_=0),K=16+P|0,0|_},X:function(a){return 0|Je(a|=0)},Y:function(a){gr(a|=0)},Z:function(a){var p;Ze(12+(K=p=K-16|0)|0,64,a|=0),gr(e[12+p>>2]),K=16+p|0},_:function(){return 0|K},$:function(a){return 0|(K=K-(0|a)&-16)},aa:function(a){K=0|a},ba:function(a){return 0|(a=0|(a|=0),(P=0|$o())<(a=P+(a|=0)|0)&&a<65536&&(a=new ArrayBuffer(j(a,65536)),(p=new l.Int8Array(a)).set(O),O=p,O=new l.Int8Array(a),N=new l.Int16Array(a),e=new l.Int32Array(a),H=new l.Uint8Array(a),W=new l.Uint16Array(a),rt=new l.Uint32Array(a),R=new l.Float32Array(a),ct=new l.Float64Array(a),w=a,M.buffer=a),P);var p,P},ca:function(a,p){L[a|=0](p|=0)}};function vt(a,p,P){var _,f,E=0;if(P)for(;;){if(P=P+-1|0,a>>>0<(E=(_=a+p|0)-1|0)>>>0)for(;f=H[0|a],O[0|a]=H[0|E],O[0|E]=f,(a=a+1|0)>>>0<(E=E+-1|0)>>>0;);if(a=_,!P)break}}function Ut(a,p,P){var _;K=_=K-272|0,rt[1804]>a>>>0||(a=e[1805])&&(Ao(16+_|0,p,e[12+_>>2]=P),L[a](16+_|0)),K=272+_|0}function Fe(a,p,P){32&H[0|a]||function(_,f,E){var u=0,d=0,g=0;r:{if(!(u=e[E+16>>2])){if(function(y){var A;return A=H[y+74|0],O[y+74|0]=A+-1|A,8&(A=e[y>>2])?(e[y>>2]=32|A,1):(e[y+4>>2]=0,e[y+8>>2]=0,A=e[y+44>>2],e[y+28>>2]=A,e[y+20>>2]=A,e[y+16>>2]=A+e[y+48>>2],0)}(E))break r;u=e[E+16>>2]}if(u-(g=e[E+20>>2])>>>0<f>>>0)return L[e[E+36>>2]](E,_,f);t:if(!(O[E+75|0]<0)){for(u=f;;){if(!(d=u))break t;if(H[(u=d+-1|0)+_|0]==10)break}if(L[e[E+36>>2]](E,_,d)>>>0<d>>>0)break r;f=f-d|0,_=_+d|0,g=e[E+20>>2]}ge(g,_,f),e[E+20>>2]=e[E+20>>2]+f}}(p,P,a)}function We(a,p,P,_,f){var E,u,d;if(K=d=K-256|0,!(73728&f|(0|P)<=(0|_))){if(Ce(d,p,(E=(f=P-_|0)>>>0<256)?f:256),p=a,u=d,!E){for(P=P-_|0;Fe(a,d,256),255<(f=f+-256|0)>>>0;);f=255&P}Fe(p,u,f)}K=256+d|0}function ge(a,p,P){var _,f=0;if(8192<=P>>>0)Lt(0|a,0|p,0|P);else{if(_=a+P|0,3&(a^p))if(_>>>0<4)P=a;else if((f=_-4|0)>>>0<a>>>0)P=a;else for(P=a;O[0|P]=H[0|p],O[P+1|0]=H[p+1|0],O[P+2|0]=H[p+2|0],O[P+3|0]=H[p+3|0],p=p+4|0,(P=P+4|0)>>>0<=f>>>0;);else{r:if((0|P)<1)P=a;else if(3&a)for(P=a;;){if(O[0|P]=H[0|p],p=p+1|0,_>>>0<=(P=P+1|0)>>>0)break r;if(!(3&P))break}else P=a;if(!((a=-4&_)>>>0<64||(f=a+-64|0)>>>0<P>>>0))for(;e[P>>2]=e[p>>2],e[P+4>>2]=e[p+4>>2],e[P+8>>2]=e[p+8>>2],e[P+12>>2]=e[p+12>>2],e[P+16>>2]=e[p+16>>2],e[P+20>>2]=e[p+20>>2],e[P+24>>2]=e[p+24>>2],e[P+28>>2]=e[p+28>>2],e[P+32>>2]=e[p+32>>2],e[P+36>>2]=e[p+36>>2],e[P+40>>2]=e[p+40>>2],e[P+44>>2]=e[p+44>>2],e[P+48>>2]=e[p+48>>2],e[P+52>>2]=e[p+52>>2],e[P+56>>2]=e[p+56>>2],e[P+60>>2]=e[p+60>>2],p=p- -64|0,(P=P- -64|0)>>>0<=f>>>0;);if(!(a>>>0<=P>>>0))for(;e[P>>2]=e[p>>2],p=p+4|0,(P=P+4|0)>>>0<a>>>0;);}if(P>>>0<_>>>0)for(;O[0|P]=H[0|p],p=p+1|0,(0|_)!=(0|(P=P+1|0)););}}function me(a){var p,P;return v((p=a*a)*p*(P=p*a)*(2718311493989822e-21*p-.00019839334836096632)+(P*(.008333329385889463*p-.16666666641626524)+a))}function ve(a){var p;return v(-.499999997251031*(a*=a)+1+.04166662332373906*(p=a*a)+a*p*(2439044879627741e-20*a-.001388676377460993))}function Ce(a,p,P){var _,f,E,u;if(P&&(O[(_=a+P|0)-1|0]=p,O[0|a]=p,!(P>>>0<3||(O[_-2|0]=p,O[a+1|0]=p,O[_-3|0]=p,O[a+2|0]=p,P>>>0<7)||(O[_-4|0]=p,O[a+3|0]=p,P>>>0<9)||(f=(_=0-a&3)+a|0,p=j(255&p,16843009),e[f>>2]=p,e[(_=(P=P-_&-4)+f|0)-4>>2]=p,P>>>0<9)||(e[8+f>>2]=p,e[4+f>>2]=p,e[_-8>>2]=p,e[_-12>>2]=p,P>>>0<25)||(e[24+f>>2]=p,e[20+f>>2]=p,e[16+f>>2]=p,e[12+f>>2]=p,e[_-16>>2]=p,e[_-20>>2]=p,e[_-24>>2]=p,e[_-28>>2]=p,(P=P-(u=4&f|24)|0)>>>0<32))))for(E=_=p,p=f+u|0;e[p+24>>2]=E,e[p+28>>2]=_,e[p+16>>2]=E,e[p+20>>2]=_,e[p+8>>2]=E,e[p+12>>2]=_,e[p>>2]=E,e[p+4>>2]=_,p=p+32|0,31<(P=P+-32|0)>>>0;);return a}function Ee(a,p){var P;if(a>>>0<(p=(a+p|0)-1|0)>>>0)for(;P=H[0|a],O[0|a]=H[0|p],O[0|p]=P,(a=a+1|0)>>>0<(p=p+-1|0)>>>0;);}function Me(a){var p,P=$o();return(a=(p=e[2216])+a|0)>>>0<=P<<16>>>0||re(0|a)?(e[2216]=a,p):(e[2086]=48,-1)}function ee(a,p,P,_,f,E,u){var d,g,y,A,S,D,F,k,V,X,q=0,tt=v(0),ut=v(0),mt=v(0);if(v(0),v(0),v(0),v(0),K=X=K-16|0,1<=(0|a))for(D=j(a,12)+p|0;;){if(1<=(0|(g=e[p+4>>2])))for(F=(a=e[p+8>>2])+j(g,48)|0,g=(d=e[p>>2]<<4)+u|0,y=(8|d)+u|0,d=(4|d)+u|0;(q=e[a+8>>2])&&((k=q+-1|0)>>>0<=1?(V=(e[a+4>>2]<<2)+P|0,q=e[V+(e[a+12>>2]<<2)>>2]<<2,tt=R[q+E>>2],S=R[f+q>>2],ut=R[_+q>>2],k-1?(mt=ut,ut=R[a+20>>2],R[g>>2]=R[g>>2]+v(R[a+44>>2]*v(mt*ut)),R[d>>2]=R[d>>2]+v(v(S*ut)*R[a+44>>2]),R[y>>2]=R[y>>2]+v(v(tt*ut)*R[a+44>>2])):(q=e[(e[a+16>>2]<<2)+V>>2]<<2,k=R[q+E>>2],V=R[f+q>>2],mt=ut,ut=R[a+20>>2],A=R[a+24>>2],R[g>>2]=R[g>>2]+v(R[a+44>>2]*v(v(mt*ut)+v(R[_+q>>2]*A))),R[d>>2]=R[d>>2]+v(v(v(S*ut)+v(V*A))*R[a+44>>2]),R[y>>2]=R[y>>2]+v(v(v(tt*ut)+v(k*A))*R[a+44>>2]))):(e[X>>2]=q,Ut(4,1024,X))),(a=a+48|0)>>>0<F>>>0;);if(a=(e[p>>2]<<4)+u|0,tt=R[a>>2],R[a>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),tt=R[a+4>>2],R[a+4>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),tt=R[a+8>>2],R[a+8>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),!((p=p+12|0)>>>0<D>>>0))break}K=16+X|0}function ye(a,p,P){var _,f,E=0;if((0|p)==1&a>>>0<0|p>>>0<1)E=a;else for(;_=So(E=Po(a,p,10),f=Vt,10),O[0|(P=P+-1|0)]=a-_|48,_=(0|p)==9&4294967295<a>>>0|9<p>>>0,a=E,p=f,_;);if(E)for(;O[0|(P=P+-1|0)]=E-j(a=(E>>>0)/10|0,10)|48,p=9<E>>>0,E=a,p;);return P}function ie(a){return a+-48>>>0<10}function he(a){var p;return(p=wo(a,64))?p-a|0:64}function ke(a,p){var P=0;return 1024<=(0|p)?(a*=898846567431158e293,p=(0|(P=p+-1023|0))<1024?P:(a*=898846567431158e293,((0|p)<3069?p:3069)+-2046|0)):-1023<(0|p)||(a*=22250738585072014e-324,p=-1023<(0|(P=p+1022|0))?P:(a*=22250738585072014e-324,(-3066<(0|p)?p:-3066)+2044|0)),Yt(0,0),Yt(1,p+1023<<20),a*+Xe()}function lr(a,p){var P=0,_=a,f=p>>>0<=31?(P=e[a+4>>2],e[a>>2]):(P=e[a>>2],e[a+4>>2]=P,p=p+-32|(e[a>>2]=0),0);e[_>>2]=f<<p,e[a+4>>2]=P<<p|f>>>32-p}function qe(a,p,P,_,f){var E,u=0,d=0,g=0;K=E=K-240|0,u=e[p>>2],e[232+E>>2]=u,p=e[p+4>>2],e[E>>2]=a,d=1;r:{t:{e:{if(((e[236+E>>2]=p)||(0|u)!=1)&&(u=a-e[(P<<2)+f>>2]|0,!((0|L[5](u,a))<1))){for(g=!_;;){i:{if(p=u,!(!g|(0|P)<2)&&(_=e[((P<<2)+f|0)-8>>2],-1<(0|L[5](u=a+-4|0,p))||-1<(0|L[5](u-_|0,p))))break i;if(e[(d<<2)+E>>2]=p,d=d+1|0,Le(232+E|0,a=Co(232+E|0)),P=a+P|0,!e[236+E>>2]&&e[232+E>>2]==1)break t;if(g=1,u=(a=p)-e[(P<<2)+f>>2]|(_=0),0<(0|L[5](u,e[E>>2])))continue;break e}break}p=a;break t}p=a}if(_)break r}Eo(E,d),kr(p,P,f)}K=240+E|0}function Le(a,p){var P=0,_=a,f=p>>>0<=31?(P=e[a>>2],e[a+4>>2]):(P=e[a+4>>2],e[a+4>>2]=0,e[a>>2]=P,p=p+-32|0,0);e[_+4>>2]=f>>>p,e[a>>2]=f<<32-p|P>>>p}function ir(a,p){var P=H[a+4|0];e[p>>2]=e[a+64>>2]+a,e[p+4>>2]=e[a+68>>2]+a,e[p+8>>2]=e[a+72>>2]+a,e[p+12>>2]=e[a+76>>2]+a,e[p+16>>2]=e[a+80>>2]+a,e[p+20>>2]=e[a+84>>2]+a,e[p+24>>2]=e[a+88>>2]+a,e[p+28>>2]=e[a+92>>2]+a,e[p+32>>2]=e[a+96>>2]+a,e[p+36>>2]=e[a+100>>2]+a,e[p+40>>2]=e[a+104>>2]+a,e[p+44>>2]=e[a+108>>2]+a,e[p+48>>2]=e[a+112>>2]+a,e[p+52>>2]=e[a+116>>2]+a,e[p+56>>2]=e[a+120>>2]+a,e[p+60>>2]=e[a+124>>2]+a,e[p- -64>>2]=e[a+128>>2]+a,e[p+68>>2]=e[a+132>>2]+a,e[p+72>>2]=e[a+136>>2]+a,e[p+76>>2]=e[a+140>>2]+a,e[p+80>>2]=e[a+144>>2]+a,e[p+84>>2]=e[a+148>>2]+a,e[p+92>>2]=e[a+152>>2]+a,e[p+96>>2]=e[a+156>>2]+a,e[p+100>>2]=e[a+160>>2]+a,e[p+108>>2]=e[a+164>>2]+a,e[p+112>>2]=e[a+168>>2]+a,e[p+116>>2]=e[a+172>>2]+a,e[p+124>>2]=e[a+176>>2]+a,e[p+128>>2]=e[a+180>>2]+a,e[p+132>>2]=e[a+184>>2]+a,e[p+136>>2]=e[a+188>>2]+a,e[p+140>>2]=e[a+192>>2]+a,e[p+144>>2]=e[a+196>>2]+a,e[p+148>>2]=e[a+200>>2]+a,e[p+152>>2]=e[a+204>>2]+a,e[p+156>>2]=e[a+208>>2]+a,e[p+164>>2]=e[a+212>>2]+a,e[p+168>>2]=e[a+216>>2]+a,e[p+172>>2]=e[a+220>>2]+a,e[p+176>>2]=e[a+224>>2]+a,e[p+180>>2]=e[a+228>>2]+a,e[p+184>>2]=e[a+232>>2]+a,e[p+188>>2]=e[a+236>>2]+a,e[p+192>>2]=e[a+240>>2]+a,e[p+196>>2]=e[a+244>>2]+a,e[p+200>>2]=e[a+248>>2]+a,e[p+204>>2]=e[a+252>>2]+a,e[p+208>>2]=e[a+256>>2]+a,e[p+212>>2]=e[a+260>>2]+a,e[p+216>>2]=e[a+264>>2]+a,e[p+220>>2]=e[a+268>>2]+a,e[p+224>>2]=e[a+272>>2]+a,e[p+228>>2]=e[a+276>>2]+a,e[p+232>>2]=e[a+280>>2]+a,e[p+236>>2]=e[a+284>>2]+a,e[p+244>>2]=e[a+288>>2]+a,e[p+248>>2]=e[a+292>>2]+a,e[p+272>>2]=e[a+296>>2]+a,e[p+276>>2]=e[a+300>>2]+a,e[p+280>>2]=e[a+304>>2]+a,e[p+292>>2]=e[a+308>>2]+a,e[p+296>>2]=e[a+312>>2]+a,e[p+300>>2]=e[a+316>>2]+a,e[p+304>>2]=e[a+320>>2]+a,e[p+308>>2]=e[a+324>>2]+a,e[p+312>>2]=e[a+328>>2]+a,e[p+316>>2]=e[a+332>>2]+a,e[p+328>>2]=e[a+336>>2]+a,e[p+332>>2]=e[a+340>>2]+a,e[p+336>>2]=e[a+344>>2]+a,e[p+348>>2]=e[a+348>>2]+a,e[p+360>>2]=e[a+352>>2]+a,e[p+364>>2]=e[a+356>>2]+a,e[p+368>>2]=e[a+360>>2]+a,e[p+352>>2]=e[a+364>>2]+a,e[p+356>>2]=e[a+368>>2]+a,e[p+488>>2]=e[a+372>>2]+a,e[p+492>>2]=e[a+376>>2]+a,e[p+496>>2]=e[a+380>>2]+a,e[p+500>>2]=e[a+384>>2]+a,e[p+504>>2]=e[a+388>>2]+a,e[p+508>>2]=e[a+392>>2]+a,e[p+512>>2]=e[a+396>>2]+a,e[p+516>>2]=e[a+400>>2]+a,e[p+520>>2]=e[a+404>>2]+a,e[p+524>>2]=e[a+408>>2]+a,e[p+528>>2]=e[a+412>>2]+a,e[p+532>>2]=e[a+416>>2]+a,e[p+536>>2]=e[a+420>>2]+a,e[p+540>>2]=e[a+424>>2]+a,e[p+544>>2]=e[a+428>>2]+a,e[p+548>>2]=e[a+432>>2]+a,e[p+552>>2]=e[a+436>>2]+a,e[p+556>>2]=e[a+440>>2]+a,e[p+560>>2]=e[a+444>>2]+a,e[p+564>>2]=e[a+448>>2]+a,e[p+568>>2]=e[a+452>>2]+a,e[p+572>>2]=e[a+456>>2]+a,e[p+576>>2]=e[a+460>>2]+a,e[p+580>>2]=e[a+464>>2]+a,P>>>0<2||(e[p+104>>2]=e[a+468>>2]+a,P>>>0<4)||(e[p+260>>2]=e[a+472>>2]+a,e[p+264>>2]=e[a+476>>2]+a,e[p+268>>2]=e[a+480>>2]+a,e[p+88>>2]=e[a+484>>2]+a,e[p+120>>2]=e[a+488>>2]+a,e[p+160>>2]=e[a+492>>2]+a,e[p+584>>2]=e[a+496>>2]+a,e[p+588>>2]=e[a+500>>2]+a,e[p+592>>2]=e[a+504>>2]+a,e[p+596>>2]=e[a+508>>2]+a,e[p+600>>2]=e[a+512>>2]+a,e[p+604>>2]=e[a+516>>2]+a,e[p+240>>2]=e[a+520>>2]+a,e[p+252>>2]=e[a+524>>2]+a,e[p+256>>2]=e[a+528>>2]+a,e[p+372>>2]=e[a+532>>2]+a,e[p+376>>2]=e[a+536>>2]+a,e[p+380>>2]=e[a+540>>2]+a,e[p+384>>2]=e[a+544>>2]+a,e[p+388>>2]=e[a+548>>2]+a,e[p+392>>2]=e[a+552>>2]+a,e[p+396>>2]=e[a+556>>2]+a,e[p+400>>2]=e[a+560>>2]+a,e[p+416>>2]=e[a+564>>2]+a,e[p+420>>2]=e[a+568>>2]+a,e[p+424>>2]=e[a+572>>2]+a,e[p+440>>2]=e[a+576>>2]+a,e[p+444>>2]=e[a+580>>2]+a,e[p+448>>2]=e[a+584>>2]+a,e[p+464>>2]=e[a+588>>2]+a,e[p+468>>2]=e[a+592>>2]+a,e[p+472>>2]=e[a+596>>2]+a,e[p+476>>2]=e[a+600>>2]+a,e[p+480>>2]=e[a+604>>2]+a,e[p+484>>2]=e[a+608>>2]+a,(0|P)!=4&&(e[p+284>>2]=e[a+612>>2]+a,e[p+288>>2]=e[a+616>>2]+a,e[p+320>>2]=e[a+620>>2]+a,e[p+324>>2]=e[a+624>>2]+a,e[p+340>>2]=e[a+628>>2]+a,e[p+344>>2]=e[a+632>>2]+a,e[p+404>>2]=e[a+636>>2]+a,e[p+408>>2]=e[a+640>>2]+a,e[p+412>>2]=e[a+644>>2]+a,e[p+428>>2]=e[a+648>>2]+a,e[p+432>>2]=e[a+652>>2]+a,e[p+436>>2]=e[a+656>>2]+a,e[p+452>>2]=e[a+660>>2]+a,e[p+456>>2]=e[a+664>>2]+a,e[p+460>>2]=e[a+668>>2]+a))}function Ze(a,p,P){var _=0;r:{if((0|p)==8)p=Je(P);else{if(_=28,3&p|(0|function(f){for(var E=0,u=0;u=E,f;)f&=f-1,E=E+1|0;return u}(p>>>2))!=1||(_=48,-64-p>>>0<P>>>0))break r;p=function(f,E){var u,d,g=0,y=0,A=0;if((y=f>>>0>(g=16)?f:16)+-1&y)for(;g=(f=g)<<1,f>>>0<y>>>0;);else f=y;return-64-f>>>0<=E>>>0?(e[2086]=48,0):(g=Je(12+((y=E>>>0<11?16:E+11&-8)+f|0)|0))?(E=g+-8|0,g&f+-1?(A=(-8&(d=e[(u=g+-4|0)>>2]))-(g=(f=15<(g=((f+g|0)-1&0-f)-8|0)-E>>>0?g:f+g|0)-E|0)|0,3&d?(e[f+4>>2]=A|1&e[f+4>>2]|2,e[4+(A=f+A|0)>>2]=1|e[4+A>>2],e[u>>2]=g|1&e[u>>2]|2,e[f+4>>2]=1|e[f+4>>2],rs(E,g)):(E=e[E>>2],e[f+4>>2]=A,e[f>>2]=E+g)):f=E,3&(E=e[f+4>>2])&&((g=-8&E)>>>0<=y+16>>>0||(e[f+4>>2]=y|1&E|2,e[(E=f+y|0)+4>>2]=3|(y=g-y|0),e[4+(g=f+g|0)>>2]=1|e[g+4>>2],rs(E,y))),f+8|0):0}(16<p>>>0?p:16,P)}if(!p)return 1;e[a>>2]=p,_=0}return _}function gr(a){var p,P=0,_=0,f=0,E=0,u=0,d=0,g=0;r:if(a){p=(f=a+-8|0)+(a=-8&(_=e[a+-4>>2]))|0;t:if(!(1&_)){if(!(3&_)||(f=f-(_=e[f>>2])|0)>>>0<rt[2091])break r;if(a=a+_|0,e[2092]!=(0|f))if(_>>>0<=255)E=e[f+8>>2],_>>>=3,(0|(P=e[f+12>>2]))==(0|E)?(g=e[2087]&Br(_),e[2087]=g):(e[E+12>>2]=P,e[P+8>>2]=E);else{if(d=e[f+24>>2],(0|f)!=(0|(_=e[f+12>>2])))P=e[f+8>>2],e[P+12>>2]=_,e[_+8>>2]=P;else if(P=(P=e[(E=f+20|0)>>2])||e[(E=f+16|0)>>2]){for(;u=E,(P=e[(E=(_=P)+20|0)>>2])||(E=_+16|0,P=e[_+16>>2]););e[u>>2]=0}else _=0;if(d){E=e[f+28>>2];e:{if(e[(P=8652+(E<<2)|0)>>2]==(0|f)){if(e[P>>2]=_)break e;g=e[2088]&Br(E),e[2088]=g;break t}if(!(e[d+(e[d+16>>2]==(0|f)?16:20)>>2]=_))break t}e[_+24>>2]=d,(P=e[f+16>>2])&&(e[_+16>>2]=P,e[P+24>>2]=_),(P=e[f+20>>2])&&(e[_+20>>2]=P,e[P+24>>2]=_)}}else if((3&(_=e[4+p>>2]))==3)return e[2089]=a,e[4+p>>2]=-2&_,e[f+4>>2]=1|a,e[a+f>>2]=a}if(!(p>>>0<=f>>>0)&&1&(_=e[4+p>>2])){t:{if(!(2&_)){if(e[2093]==(0|p)){if(e[2093]=f,a=e[2090]+a|0,e[2090]=a,e[f+4>>2]=1|a,e[2092]!=(0|f))break r;return e[2089]=0,e[2092]=0}if(e[2092]==(0|p))return e[2092]=f,a=e[2089]+a|0,e[2089]=a,e[f+4>>2]=1|a,e[a+f>>2]=a;a=(-8&_)+a|0;e:if(_>>>0<=255)_>>>=3,(0|(P=e[8+p>>2]))==(0|(E=e[12+p>>2]))?(g=e[2087]&Br(_),e[2087]=g):(e[P+12>>2]=E,e[E+8>>2]=P);else{if(d=e[24+p>>2],(0|p)!=(0|(_=e[12+p>>2])))P=e[8+p>>2],e[P+12>>2]=_,e[_+8>>2]=P;else if(P=(P=e[(E=20+p|0)>>2])||e[(E=16+p|0)>>2]){for(;u=E,(P=e[(E=(_=P)+20|0)>>2])||(E=_+16|0,P=e[_+16>>2]););e[u>>2]=0}else _=0;if(d){E=e[28+p>>2];i:{if(e[(P=8652+(E<<2)|0)>>2]==(0|p)){if(e[P>>2]=_)break i;g=e[2088]&Br(E),e[2088]=g;break e}if(!(e[d+(e[d+16>>2]==(0|p)?16:20)>>2]=_))break e}e[_+24>>2]=d,(P=e[16+p>>2])&&(e[_+16>>2]=P,e[P+24>>2]=_),(P=e[20+p>>2])&&(e[_+20>>2]=P,e[P+24>>2]=_)}}if(e[f+4>>2]=1|a,e[a+f>>2]=a,e[2092]!=(0|f))break t;return e[2089]=a}e[4+p>>2]=-2&_,e[f+4>>2]=1|a,e[a+f>>2]=a}if(a>>>0<=255)return _=8388+((a>>>=3)<<3)|0,a=(P=e[2087])&(a=1<<a)?e[_+8>>2]:(e[2087]=a|P,_),e[_+8>>2]=f,e[a+12>>2]=f,e[f+12>>2]=_,e[f+8>>2]=a;e[f+16>>2]=0,P=e[f+20>>2]=0,(E=a>>>8)&&(P=31,16777215<a>>>0||(P=E,P=28+((P=((P=(P<<=E=E+1048320>>>16&8)<<(d=P+520192>>>16&4))<<(u=P+245760>>>16&2)>>>15)-(u|E|d)|0)<<1|a>>>P+21&1)|0)),u=8652+((e[(_=f)+28>>2]=P)<<2)|0;t:if((E=e[2088])&(_=1<<P)){E=a<<((0|P)==31?0:25-(P>>>1)|0),_=e[u>>2];e:{for(;;){if((-8&e[(P=_)+4>>2])==(0|a))break e;if(_=E>>>29,E<<=1,!(_=e[16+(u=P+(4&_)|0)>>2]))break}e[u+16>>2]=f,e[f+12>>2]=f,e[f+24>>2]=P,e[f+8>>2]=f;break t}a=e[P+8>>2],e[a+12>>2]=f,e[P+8>>2]=f,e[f+24>>2]=0,e[f+12>>2]=P,e[f+8>>2]=a}else e[2088]=_|E,e[u>>2]=f,e[f+12>>2]=f,e[f+24>>2]=u,e[f+8>>2]=f;if(a=e[2095]+-1|0,!(e[2095]=a)){for(f=8804;f=(a=e[f>>2])+8|0,a;);e[2095]=-1}}}}function Je(a){var p,P=0,_=0,f=0,E=0,u=0,d=0,g=0,y=0,A=0,S=0,D=0;K=p=K-16|0;r:{t:{e:{i:{s:{o:{n:{c:{f:{l:{a:{if(a>>>0<=244){if(3&(P=(u=e[2087])>>>(a=(d=a>>>0<11?16:a+11&-8)>>>3))){a=(P=e[8396+(E=(_=a+(1&(-1^P))|0)<<3)>>2])+8|0,(0|(f=e[P+8>>2]))==(0|(E=E+8388|0))?(D=Br(_)&u,e[2087]=D):(e[f+12>>2]=E,e[E+8>>2]=f),e[P+4>>2]=3|(_<<=3),e[4+(P=P+_|0)>>2]=1|e[P+4>>2];break r}if(d>>>0<=(y=e[2089])>>>0)break a;if(P){_=P=(a=(0-(a=(0-(_=2<<a)|_)&P<<a)&a)-1|0)>>>12&16,P=e[8396+(f=(_=((_=(_|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)|0)<<3)>>2],(0|(a=e[P+8>>2]))==(0|(f=f+8388|0))?(u=Br(_)&u,e[2087]=u):(e[a+12>>2]=f,e[f+8>>2]=a),a=P+8|0,e[P+4>>2]=3|d,e[4+(g=P+d|0)>>2]=1|(E=(_<<=3)-d|0),e[P+_>>2]=E,y&&(P=8388+((_=y>>>3)<<3)|0,f=e[2092],_=(_=1<<_)&u?e[P+8>>2]:(e[2087]=_|u,P),e[P+8>>2]=f,e[_+12>>2]=f,e[f+12>>2]=P,e[f+8>>2]=_),e[2092]=g,e[2089]=E;break r}if(!(S=e[2088]))break a;for(_=P=(a=(S&0-S)-1|0)>>>12&16,P=e[8652+(((_=(_|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)<<2)>>2],f=(-8&e[P+4>>2])-d|0,_=P;a=(a=e[_+16>>2])||e[_+20>>2];)f=(_=(E=(-8&e[a+4>>2])-d|0)>>>0<f>>>0)?E:f,P=_?a:P,_=a;if(A=e[P+24>>2],(0|(E=e[P+12>>2]))!=(0|P)){a=e[P+8>>2],e[a+12>>2]=E,e[E+8>>2]=a;break t}if(!(a=e[(_=P+20|0)>>2])){if(!(a=e[P+16>>2]))break l;_=P+16|0}for(;g=_,(a=e[(_=(E=a)+20|0)>>2])||(_=E+16|0,a=e[E+16>>2]););e[g>>2]=0;break t}if(d=-1,!(4294967231<a>>>0)&&(d=-8&(P=a+11|0),y=e[2088])){_=0-d|0,u=0,(P>>>=8)&&(u=31,16777215<d>>>0||(u=28+((a=((u=(P<<=f=P+1048320>>>16&8)<<(a=P+520192>>>16&4))<<(P=u+245760>>>16&2)>>>15)-(P|a|f)|0)<<1|d>>>a+21&1)|0));d:{p:{if(f=e[8652+(u<<2)>>2])for(P=d<<((0|u)==31?0:25-(u>>>1)|0),a=0;;){if(!(_>>>0<=(g=(-8&e[f+4>>2])-d|0)>>>0||(E=f,_=g))){_=0,a=f;break p}if(g=e[f+20>>2],f=e[16+((P>>>29&4)+f|0)>>2],a=g&&(0|g)!=(0|f)?g:a,P<<=(0|f)!=0,!f)break}else a=0;if(!(a|E)){if(!(a=(0-(a=2<<u)|a)&y))break a;f=P=(a=(a&0-a)-1|0)>>>12&16,a=e[8652+(((f=(f|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)<<2)>>2]}if(!a)break d}for(;_=(P=(f=(-8&e[a+4>>2])-d|0)>>>0<_>>>0)?f:_,E=P?a:E,a=(P=e[a+16>>2])||e[a+20>>2];);}if(!(!E|_>>>0>=e[2089]-d>>>0)){if(g=e[E+24>>2],(0|E)!=(0|(P=e[E+12>>2]))){a=e[E+8>>2],e[a+12>>2]=P,e[P+8>>2]=a;break e}if(!(a=e[(f=E+20|0)>>2])){if(!(a=e[E+16>>2]))break f;f=E+16|0}for(;u=f,(a=e[(f=(P=a)+20|0)>>2])||(f=P+16|0,a=e[P+16>>2]););e[u>>2]=0;break e}}}if(d>>>0<=(P=e[2089])>>>0){a=e[2092],16<=(_=P-d|0)>>>0?(e[2089]=_,e[2092]=f=a+d|0,e[f+4>>2]=1|_,e[a+P>>2]=_,e[a+4>>2]=3|d):(e[2092]=0,e[2089]=0,e[a+4>>2]=3|P,e[4+(P=a+P|0)>>2]=1|e[P+4>>2]),a=a+8|0;break r}if(d>>>0<(f=e[2090])>>>0){e[2090]=P=f-d|0,a=e[2093],e[2093]=_=a+d|0,e[_+4>>2]=1|P,e[a+4>>2]=3|d,a=a+8|0;break r}if((_=(u=(_=E=d+47|(a=0))+(P=e[2205]?e[2207]:(e[2208]=-1,e[2209]=-1,e[2206]=4096,e[2207]=4096,e[2205]=12+p&-16^1431655768,e[2210]=0,e[2198]=0,4096))|0)&(g=0-P|0))>>>0<=d>>>0||(P=e[2197])&&(A=(y=e[2195])+_|0)>>>0<=y>>>0|P>>>0<A>>>0)break r;if(4&H[8792])break o;a:{d:{if(P=e[2093])for(a=8796;;){if((y=e[a>>2])+e[a+4>>2]>>>0>P>>>0&&y>>>0<=P>>>0)break d;if(!(a=e[a+8>>2]))break}if((0|(P=Me(0)))==-1||(u=_,(u=(f=(a=e[2206])+-1|0)&P?(_-P|0)+(P+f&0-a)|0:u)>>>0<=d>>>0|2147483646<u>>>0)||(a=e[2197])&&(g=(f=e[2195])+u|0)>>>0<=f>>>0|a>>>0<g>>>0)break n;if((0|P)!=(0|(a=Me(u))))break a;break s}if(2147483646<(u=g&u-f)>>>0)break n;if((0|(P=Me(u)))==(e[a>>2]+e[a+4>>2]|0))break c;a=P}if(!(d+48>>>0<=u>>>0|2147483646<u>>>0|(0|(P=a))==-1)){if(2147483646<(a=(a=e[2207])+(E-u|0)&0-a)>>>0)break s;if((0|Me(a))!=-1){u=a+u|0;break s}Me(0-u|0);break n}if((0|P)!=-1)break s;break n}E=0;break t}P=0;break e}if((0|P)!=-1)break s}e[2198]=4|e[2198]}if(2147483646<_>>>0||(P=Me(_),(a=Me(0))>>>0<=P>>>0|(0|P)==-1|(0|a)==-1)||(u=a-P|0)>>>0<=d+40>>>0)break i}a=e[2195]+u|0,(e[2195]=a)>>>0>rt[2196]&&(e[2196]=a);s:{o:{n:{if(_=e[2093]){for(a=8796;;){if(((f=e[a>>2])+(E=e[a+4>>2])|0)==(0|P))break n;if(!(a=e[a+8>>2]))break}break o}for((a=e[2091])>>>0<=P>>>0&&a||(e[2091]=P),a=0,e[2200]=u,e[2199]=P,e[2095]=-1,e[2096]=e[2205],e[2202]=0;e[8396+(_=a<<3)>>2]=f=_+8388|0,e[_+8400>>2]=f,(0|(a=a+1|0))!=32;);e[2090]=f=(a=u+-40|0)-(_=P+8&7?-8-P&7:0)|0,e[2093]=_=P+_|0,e[_+4>>2]=1|f,e[4+(a+P|0)>>2]=40,e[2094]=e[2209];break s}if(!(8&H[a+12|0]|P>>>0<=_>>>0|_>>>0<f>>>0)){e[a+4>>2]=E+u,e[2093]=P=(a=_+8&7?-8-_&7:0)+_|0,f=e[2090]+u|0,e[2090]=a=f-a|0,e[P+4>>2]=1|a,e[4+(_+f|0)>>2]=40,e[2094]=e[2209];break s}}P>>>0<(E=e[2091])>>>0&&(e[2091]=P,E=0),f=P+u|0,a=8796;o:{n:{c:{f:{l:{a:{for(;(0|f)!=e[a>>2];)if(!(a=e[a+8>>2]))break a;if(!(8&H[a+12|0]))break l}for(a=8796;;){if((f=e[a>>2])>>>0<=_>>>0&&_>>>0<(E=f+e[a+4>>2]|0)>>>0)break f;a=e[a+8>>2]}}if(e[a>>2]=P,e[a+4>>2]=e[a+4>>2]+u,e[4+(A=(P+8&7?-8-P&7:0)+P|0)>>2]=3|d,a=((P=f+(f+8&7?-8-f&7:0)|0)-A|0)-d|0,g=d+A|0,(0|P)==(0|_)){e[2093]=g,a=e[2090]+a|0,e[2090]=a,e[g+4>>2]=1|a;break n}if(e[2092]==(0|P)){e[2092]=g,a=e[2089]+a|0,e[2089]=a,e[g+4>>2]=1|a,e[a+g>>2]=a;break n}if((3&(_=e[P+4>>2]))==1){S=-8&_;l:if(_>>>0<=255)E=_>>>3,_=e[P+8>>2],(0|(f=e[P+12>>2]))==(0|_)?(D=e[2087]&Br(E),e[2087]=D):(e[_+12>>2]=f,e[f+8>>2]=_);else{if(y=e[P+24>>2],(0|(u=e[P+12>>2]))!=(0|P))_=e[P+8>>2],e[_+12>>2]=u,e[u+8>>2]=_;else if(d=(d=e[(f=P+20|0)>>2])||e[(f=P+16|0)>>2]){for(;_=f,(d=e[(f=(u=d)+20|0)>>2])||(f=u+16|0,d=e[u+16>>2]););e[_>>2]=0}else u=0;if(y){_=e[P+28>>2];a:{if(e[(f=8652+(_<<2)|0)>>2]==(0|P)){if(e[f>>2]=u)break a;D=e[2088]&Br(_),e[2088]=D;break l}if(!(e[y+(e[y+16>>2]==(0|P)?16:20)>>2]=u))break l}e[u+24>>2]=y,(_=e[P+16>>2])&&(e[u+16>>2]=_,e[_+24>>2]=u),(_=e[P+20>>2])&&(e[u+20>>2]=_,e[_+24>>2]=u)}}P=P+S|0,a=a+S|0}if(e[P+4>>2]=-2&e[P+4>>2],e[g+4>>2]=1|a,(e[a+g>>2]=a)>>>0<=255){a=8388+((P=a>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|_,a),e[a+8>>2]=g,e[P+12>>2]=g,e[g+12>>2]=a,e[g+8>>2]=P;break n}if(P=0,(f=a>>>8)&&(P=31,16777215<a>>>0||(P=28+((P=((d=(f<<=E=f+1048320>>>16&8)<<(P=f+520192>>>16&4))<<(f=d+245760>>>16&2)>>>15)-(f|P|E)|0)<<1|a>>>P+21&1)|0)),e[(_=g)+28>>2]=P,e[g+16>>2]=0,_=8652+(P<<2)|(e[g+20>>2]=0),(f=e[2088])&(E=1<<P)){for(f=a<<((0|P)==31?0:25-(P>>>1)|0),P=e[_>>2];;){if((-8&e[(_=P)+4>>2])==(0|a))break c;if(P=f>>>29,f<<=1,!(P=e[16+(E=(4&P)+_|0)>>2]))break}e[E+16>>2]=g}else e[2088]=f|E,e[_>>2]=g;e[g+24>>2]=_,e[g+12>>2]=g,e[g+8>>2]=g;break n}for(e[2090]=g=(a=u+-40|0)-(f=P+8&7?-8-P&7:0)|0,e[2093]=f=P+f|0,e[f+4>>2]=1|g,e[4+(a+P|0)>>2]=40,e[2094]=e[2209],e[(f=(a=(E+(E+-39&7?39-E&7:0)|0)-47|0)>>>0<_+16>>>0?_:a)+4>>2]=27,a=e[2202],e[f+16>>2]=e[2201],e[f+20>>2]=a,a=e[2200],e[f+8>>2]=e[2199],e[f+12>>2]=a,e[2201]=f+8,e[2200]=u,e[2199]=P,a=f+24|(e[2202]=0);e[a+4>>2]=7,P=a+8|0,a=a+4|0,P>>>0<E>>>0;);if((0|_)==(0|f))break s;if(e[f+4>>2]=-2&e[f+4>>2],e[_+4>>2]=1|(E=f-_|0),(e[f>>2]=E)>>>0<=255){a=8388+((P=E>>>3)<<3)|0,P=(f=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|f,a),e[a+8>>2]=_,e[P+12>>2]=_,e[_+12>>2]=a,e[_+8>>2]=P;break s}if(e[_+16>>2]=0,a=e[_+20>>2]=0,(f=E>>>8)&&(a=31,16777215<E>>>0||(a=28+((a=((g=(f<<=u=f+1048320>>>16&8)<<(a=f+520192>>>16&4))<<(f=g+245760>>>16&2)>>>15)-(f|a|u)|0)<<1|E>>>a+21&1)|0)),P=8652+((e[(P=_)+28>>2]=a)<<2)|0,(f=e[2088])&(u=1<<a)){for(a=E<<((0|a)==31?0:25-(a>>>1)|0),P=e[P>>2];;){if((0|E)==(-8&e[(f=P)+4>>2]))break o;if(P=a>>>29,a<<=1,!(P=e[16+(u=f+(4&P)|0)>>2]))break}e[u+16>>2]=_,e[_+24>>2]=f}else e[2088]=f|u,e[P>>2]=_,e[_+24>>2]=P;e[_+12>>2]=_,e[_+8>>2]=_;break s}a=e[_+8>>2],e[a+12>>2]=g,e[_+8>>2]=g,e[g+24>>2]=0,e[g+12>>2]=_,e[g+8>>2]=a}a=A+8|0;break r}a=e[f+8>>2],e[a+12>>2]=_,e[f+8>>2]=_,e[_+24>>2]=0,e[_+12>>2]=f,e[_+8>>2]=a}if(!((a=e[2090])>>>0<=d>>>0)){e[2090]=P=a-d|0,a=e[2093],e[2093]=_=a+d|0,e[_+4>>2]=1|P,e[a+4>>2]=3|d,a=a+8|0;break r}}e[2086]=48,a=0;break r}e:if(g){a=e[E+28>>2];i:{if(e[(f=8652+(a<<2)|0)>>2]==(0|E)){if(e[f>>2]=P)break i;y=Br(a)&y,e[2088]=y;break e}if(!(e[g+(e[g+16>>2]==(0|E)?16:20)>>2]=P))break e}e[P+24>>2]=g,(a=e[E+16>>2])&&(e[P+16>>2]=a,e[a+24>>2]=P),(a=e[E+20>>2])&&(e[P+20>>2]=a,e[a+24>>2]=P)}e:if(_>>>0<=15)e[E+4>>2]=3|(a=_+d|0),e[4+(a=a+E|0)>>2]=1|e[a+4>>2];else if(e[E+4>>2]=3|d,e[4+(f=E+d|0)>>2]=1|_,(e[_+f>>2]=_)>>>0<=255)a=8388+((P=_>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|_,a),e[a+8>>2]=f,e[P+12>>2]=f,e[f+12>>2]=a,e[f+8>>2]=P;else{a=0,(d=_>>>8)&&(a=31,16777215<_>>>0||(a=28+((a=((g=(d<<=u=d+1048320>>>16&8)<<(a=d+520192>>>16&4))<<(d=g+245760>>>16&2)>>>15)-(d|a|u)|0)<<1|_>>>a+21&1)|0)),e[(P=f)+28>>2]=a,e[f+16>>2]=0,P=8652+(a<<2)|(e[f+20>>2]=0);i:{if((d=1<<a)&y){for(a=_<<((0|a)==31?0:25-(a>>>1)|0),d=e[P>>2];;){if((-8&e[(P=d)+4>>2])==(0|_))break i;if(d=a>>>29,a<<=1,!(d=e[16+(u=(4&d)+P|0)>>2]))break}e[u+16>>2]=f}else e[2088]=d|y,e[P>>2]=f;e[f+24>>2]=P,e[f+12>>2]=f,e[f+8>>2]=f;break e}a=e[P+8>>2],e[a+12>>2]=f,e[P+8>>2]=f,e[f+24>>2]=0,e[f+12>>2]=P,e[f+8>>2]=a}a=E+8|0;break r}t:if(A){a=e[P+28>>2];e:{if(e[(_=8652+(a<<2)|0)>>2]==(0|P)){if(e[_>>2]=E)break e;D=Br(a)&S,e[2088]=D;break t}if(!(e[A+(e[A+16>>2]==(0|P)?16:20)>>2]=E))break t}e[E+24>>2]=A,(a=e[P+16>>2])&&(e[E+16>>2]=a,e[a+24>>2]=E),(a=e[P+20>>2])&&(e[E+20>>2]=a,e[a+24>>2]=E)}f>>>0<=15?(e[P+4>>2]=3|(a=f+d|0),e[4+(a=a+P|0)>>2]=1|e[a+4>>2]):(e[P+4>>2]=3|d,e[4+(d=P+d|0)>>2]=1|f,e[f+d>>2]=f,y&&(a=8388+((_=y>>>3)<<3)|0,E=e[2092],_=(_=1<<_)&u?e[a+8>>2]:(e[2087]=_|u,a),e[a+8>>2]=E,e[_+12>>2]=E,e[E+12>>2]=a,e[E+8>>2]=_),e[2092]=d,e[2089]=f),a=P+8|0}return K=16+p|0,a}function mr(a,p,P,_,f,E,u){var d,g,y,A=0,S=0,D=0,F=0,k=0,V=0,X=0,q=0,tt=0,ut=0,mt=0,kt=0;e[76+(K=y=K-80|0)>>2]=p,g=55+y|0,d=56+y|0,p=0;r:{t:{e:for(;;){(0|tt)<0||(tt=(2147483647-tt|0)<(0|p)?(e[2086]=61,-1):p+tt|0);i:{s:{o:{n:{c:{f:{l:{a:{d:{p:{m:{y:{_:{if(F=e[76+y>>2],D=H[0|(p=F)]){for(;;){v:{x:{h:if(A=255&D){if((0|A)!=37)break x;for(D=p;;){if(H[p+1|0]!=37)break h;if(e[76+y>>2]=A=p+2|0,D=D+1|0,S=H[p+2|0],p=A,(0|S)!=37)break}}else D=p;if(p=D-F|0,a&&Fe(a,F,p),p)continue e;ut=-1,k=!ie(O[e[76+(A=y)>>2]+(D=1)|0]),p=e[76+y>>2],k|H[p+2|0]!=36||(ut=O[p+1|0]+-48|0,mt=1,D=3),e[A+76>>2]=p=D+p|0;h:if(31<(S=(X=O[(D=0)|p])+-32|0)>>>0)A=p;else if(A=p,75913&(S=1<<S))for(;;){if(e[76+y>>2]=A=p+1|0,D|=S,31<(S=(X=O[p+1|0])+-32|0)>>>0)break h;if(p=A,!(75913&(S=1<<S)))break}if((0|X)==42){if(k=y,ie(O[A+1|0])&&(p=e[76+y>>2],H[p+2|0]==36))e[((O[p+1|0]<<2)+f|0)-192>>2]=10,q=e[((O[p+1|0]<<3)+_|0)-384>>2],mt=1,p=p+3|0;else{if(mt)break t;q=mt=0,a&&(p=e[P>>2],e[P>>2]=p+4,q=e[p>>2]),p=e[76+y>>2]+1|0}e[k+76>>2]=p,-1<(0|q)||(q=0-q|0,D|=8192)}else{if((0|(q=xo(76+y|0)))<0)break t;p=e[76+y>>2]}if(S=-1,H[0|p]==46)if(H[p+1|0]==42)if(ie(O[p+2|0])&&(p=e[76+y>>2],H[p+3|0]==36))e[((O[p+2|0]<<2)+f|0)-192>>2]=10,S=e[((O[p+2|0]<<3)+_|0)-384>>2],e[76+y>>2]=p=p+4|0;else{if(mt)break t;S=a?(p=e[P>>2],e[P>>2]=p+4,e[p>>2]):0,p=e[76+y>>2]+2|0,e[76+y>>2]=p}else e[76+y>>2]=p+1,S=xo(76+y|0),p=e[76+y>>2];for(A=0;;){if(kt=A,V=-1,57<O[0|p]+-65>>>0)break r;if(e[76+y>>2]=X=p+1|0,A=O[0|p],p=X,!((A=H[3295+(A+j(kt,58)|0)|0])+-1>>>0<8))break}if(!A)break r;h:{u:{g:{if((0|A)==19){if((0|ut)<=-1)break g;break r}if((0|ut)<0)break u;e[(ut<<2)+f>>2]=A,A=e[4+(p=(ut<<3)+_|0)>>2],e[64+y>>2]=e[p>>2],e[68+y>>2]=A}if(p=0,a)break h;continue e}if(!a)break i;Bi(64+y|0,A,P,u),X=e[76+y>>2]}if(k=-65537&D,D=8192&D?k:D,ut=3336,A=d,p=O[X+-1|(V=0)],(X=(p=kt&&(15&p)==3?-33&p:p)+-88|0)>>>0<=32)break v;h:{u:{g:{b:{if(6<(k=p+-65|0)>>>0){if((0|p)!=83)break s;if(!S)break b;A=e[64+y>>2];break u}switch(k-1|0){case 1:break g;case 0:case 2:break s;default:break _}}We(a,32,q,p=0,D);break h}e[12+y>>2]=0,e[8+y>>2]=e[64+y>>2],e[64+y>>2]=8+y,S=-1,A=8+y|0}p=0;u:{for(;;){if(!(F=e[A>>2]))break u;if((k=(0|(F=vo(4+y|0,F)))<0)|S-p>>>0<F>>>0)break;if(A=A+4|0,!((p=p+F|0)>>>0<S>>>0))break u}if(V=-1,k)break r}if(We(a,32,q,p,D),p)for(S=0,A=e[64+y>>2];;){if(!(F=e[A>>2])||(0|p)<(0|(S=(F=vo(4+y|0,F))+S|0)))break h;if(Fe(a,4+y|0,F),A=A+4|0,!(S>>>0<p>>>0))break}else p=0}We(a,32,q,p,8192^D),p=(0|p)<(0|q)?q:p;continue e}e[76+y>>2]=A=p+1|0,D=H[p+1|0],p=A;continue}break}switch(X-1|0){case 28:break c;case 21:break f;case 23:break a;case 22:break d;case 11:case 16:break p;case 10:break m;case 26:break y;case 8:case 12:case 13:case 14:break _;case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 9:case 15:case 17:case 18:case 19:case 20:case 24:case 25:case 27:case 29:case 30:break s;default:break l}}if(V=tt,a)break r;if(!mt)break i;for(p=1;;){if(a=e[(p<<2)+f>>2]){if(Bi((p<<3)+_|0,a,P,u),(0|(p=p+(V=1)|0))!=10)continue;break r}break}if(V=1,9<p>>>0||(V=-1,e[(p<<2)+f>>2]))break r;for(;!e[((p=p+1|0)<<2)+f>>2]&&(0|p)!=10;);V=p>>>0<10?-1:1;break r}p=0|L[E](a,ct[64+y>>3],q,S,D,p);continue}A=(p=wo(F=(p=e[64+y>>2])||3346,S))||S+F|0,D=k,S=p?p-F|0:S;break s}O[55+y|0]=e[64+y>>2],S=1,F=g,D=k;break s}if(p=k=e[68+y>>2],F=e[64+y>>2],(0|p)<-1||(0|p)<=-1&&!(4294967295<F>>>0)){p=0-(p+(0<F>>>0)|0)|0,e[64+y>>2]=F=0-F|0,e[68+y>>2]=p,V=1,ut=3336;break n}if(2048&D){V=1,ut=3337;break n}ut=(V=1&D)?3338:3336;break n}if(F=function(Ht,ce,we){if(Ht|ce)for(;O[0|(we=we+-1|0)]=7&Ht|48,(Ht=(7&ce)<<29|Ht>>>3)|(ce>>>=3););return we}(e[64+y>>2],e[68+y>>2],d),!(8&D))break o;S=(0|(p=d-F|0))<(0|S)?S:p+1|0;break o}S=8<S>>>0?S:8,D|=8,p=120}if(F=function(Ht,ce,we,Ue){if(Ht|ce)for(;O[0|(we=we+-1|0)]=H[3824+(15&Ht)|0]|Ue,(Ht=(15&ce)<<28|Ht>>>4)|(ce>>>=4););return we}(e[64+y>>2],e[68+y>>2],d,32&p),!(8&D)|!(e[64+y>>2]|e[68+y>>2]))break o;ut=3336+(p>>>4)|0,V=2;break o}if(7<(A=255&kt)>>>(p=0))continue;switch(A-1|0){default:case 0:e[e[64+y>>2]>>2]=tt;continue;case 1:A=e[64+y>>2],e[A>>2]=tt,e[A+4>>2]=tt>>31;continue;case 2:N[e[64+y>>2]>>1]=tt;continue;case 3:O[e[64+y>>2]]=tt;continue;case 5:e[e[64+y>>2]>>2]=tt;continue;case 4:continue;case 6:}A=e[64+y>>2],e[A>>2]=tt,e[A+4>>2]=tt>>31;continue}F=e[64+y>>2],p=e[68+y>>2],ut=3336}F=ye(F,p,d)}D=-1<(0|S)?-65537&D:D,S=!!((k=p=e[68+y>>2])|(X=e[64+y>>2]))|S?(0|(p=!(k|X)+(d-F|0)|0))<(0|S)?S:p:(F=d,0)}We(a,32,p=(0|q)<(0|(A=(S=(0|S)<(0|(k=A-F|0))?k:S)+V|0))?A:q,A,D),Fe(a,ut,V),We(a,48,p,A,65536^D),We(a,48,S,k,0),Fe(a,F,k),We(a,32,p,A,8192^D);continue}break}V=0;break r}V=-1}return K=80+y|0,V}function ur(a){var p,P=0,E=0,f=0,_=0,f=4,E=1439;r:if(P=H[0|a]){for(;!((0|(p=H[0|E]))!=(0|P)||!(f=f+-1|0)|!p);)if(E=E+1|0,P=H[a+1|0],a=a+1|0,!P)break r;_=P}return(255&_)-H[0|E]|0}function kr(a,p,P){var _,f,E=0,u=0,d=0;e[(K=f=K-240|0)>>2]=a,u=1;r:if(!((0|p)<2))for(E=a;;){if(E=(_=E+-4|0)-e[((d=p+-2|0)<<2)+P>>2]|0,0<=(0|L[5](a,E))&&-1<(0|L[5](a,_))||(a=(u<<2)+f|0,0<=(0|L[5](E,_))?(e[a>>2]=E,d=p+-1|0):E=e[a>>2]=_,u=u+1|0,(0|d)<2))break r;a=e[f>>2],p=d}Eo(f,u),K=240+f|0}function hi(a){var p,P,_=0;if(v(0),function(f){var E,u;e[f+428>>2]&&(u=e[f+332>>2],ge(e[f+460>>2],e[f+436>>2],E=u<<2),ge(e[f+464>>2],e[f+440>>2],E),ge(e[f+468>>2],e[f+448>>2],E),H[e[f>>2]+4|0]<4||(ge(e[f+472>>2],e[f+452>>2],E=u<<4),ge(e[f+476>>2],e[f+456>>2],E)))}(a),function(f){var E,u,d,g=0,y=v(0),A=v(0),S=0,D=v(0);if(v(0),v(0),1<=(0|(S=e[f>>2])))for(d=(g=e[f+4>>2])+j(S,52)|0,f=e[f+12>>2];y=R[f>>2],R[g+44>>2]!=(y=(E=e[g+16>>2])?(A=y,y=R[g+4>>2],D=R[g+12>>2],A=v(v(A-y)/D),u=v(Ft(A)),S=v(St(u))<v(2147483648)?~~u:-2147483648,v(y+v(D*v(A-v(0|S))))):(D=R[g+4>>2],A=R[g+8>>2],y<D?D:A<y?A:y))?(R[g+44>>2]=y,e[g+48>>2]=1):e[g+48>>2]=0,E||(R[f>>2]=y),f=f+4|0,(g=g+52|0)>>>0<d>>>0;);}(a+540|0),function(f){var E,u,d,g,y,A,S=0,D=0,F=v(0),k=0,V=v(0),X=(v(0),v(0),0),q=v(0),tt=0,ut=0,mt=0;if(v(0),1<=(0|(k=e[f+540>>2])))for(y=(X=e[f+544>>2])+j(k,52)|0,A=e[f+644>>2];;){r:if(!(e[X>>2]||(0|(k=e[X+32>>2]))<1))if(d=(f=e[X+28>>2])+j(k,28)|0,g=R[X+24>>2],u=R[X+20>>2],E=R[X+44>>2],A)for(;;){q=v(ut=0);t:{e:{i:{if((0|(D=e[f>>2]))<1)S=k=0;else if(tt=e[f+4>>2],V=R[tt>>2],F=v(V-u),(0|D)==1)k=E<v(u+V)^1|F<E^1,S=0;else{if(E<F){k=1,S=0;break e}if(k=0,E<v(u+V))S=0;else{if(S=1,F=R[tt+4>>2],!(E<v(u+F)))for(;;){if((0|D)==(0|(S=S+1|0)))break i;if(V=F,F=R[tt+(S<<2)>>2],E<v(u+F))break}v(F-u)<E||(S=S+-1|0,(F=v(F-V))<g)||(q=v(v(E-V)/F))}}if(k)break e;if(tt=D=1,e[f+16>>2])break t;break e}S=D+-1|0,k=1}tt=(D=(V=R[f+12>>2])!=q)&(q==v(0)|V==v(0))|e[f+8>>2]!=(0|S),ut=k}if(e[f+20>>2]=tt,e[f+24>>2]=D,R[f+12>>2]=q,e[f+16>>2]=ut,e[f+8>>2]=S,!((f=f+28|0)>>>0<d>>>0))break}else{if(!e[X+48>>2]){for(;;)if(e[f+20>>2]=0,!((f=f+28|(e[f+24>>2]=0))>>>0<d>>>0))break r}for(;;){q=v(ut=0);t:{e:{i:{s:if(!(((D=0)|(S=e[(tt=f)>>2]))<1)){if(k=e[f+4>>2],V=R[k>>2],F=v(V-u),(0|S)!=1){if(!(E<F)){if(D=0,E<v(u+V))break s;D=1;o:if(F=R[k+4>>2],!(E<v(u+F))){for(S=S+-1|0;V=F,(0|S)!=(0|D);)if(F=R[k+((D=D+1|0)<<2)>>2],E<v(u+F))break o;k=1;break e}if(k=0,v(F-u)<E){S=D;break i}if(S=D+-1|0,(F=v(F-V))<g)break i;q=v(v(E-V)/F);break i}k=1,S=0;break e}D=E<v(u+V)^1|F<E^1}k=D,S=0}if(!k&&(mt=D=1,e[f+16>>2]))break t}ut=k,mt=(D=(V=R[f+12>>2])!=q)&(q==v(0)|V==v(0))|e[f+8>>2]!=(0|S)}if(e[tt+20>>2]=mt,e[f+24>>2]=D,R[f+12>>2]=q,e[f+16>>2]=ut,e[f+8>>2]=S,!((f=f+28|0)>>>0<d>>>0))break}}if(!((X=X+52|0)>>>0<y>>>0))break}}(a),function(f){var E,u,d,g,y,A=0,S=v(0),D=0,F=0,k=v(0),V=0,X=v(0);if(v(0),!(H[e[f>>2]+4|0]<4||(0|(A=e[f+540>>2]))<1))for(g=(V=e[f+544>>2])+j(A,52)|0,y=e[f+644>>2];;){r:if(e[V>>2]==1&&!((0|(A=e[V+40>>2]))<1))if(u=(f=e[V+36>>2])+j(A,28)|0,E=R[V+44>>2],y)for(;;){X=v(A=0);t:if(!((0|(F=e[f>>2]))<2||(D=e[f+4>>2],E<=(S=R[D>>2])))){A=1;e:if(!(E<(k=R[D+4>>2]))){for(;S=k,(0|F)!=(0|(A=A+1|0));)if(E<(k=R[D+(A<<2)>>2]))break e;A=F+-1|0;break t}X=v(v(E-S)/v(k-S)),A=A+-1|0}if(S=R[f+16>>2],R[f+16>>2]=X,F=e[f+12>>2],e[f+12>>2]=A,e[f+24>>2]=D=S!=X,e[f+20>>2]=D&(X==v(0)|S==v(0))|(0|A)!=(0|F),!((f=f+28|0)>>>0<u>>>0))break}else{if(!e[V+48>>2]){for(;;)if(e[f+20>>2]=0,!((f=f+28|(e[f+24>>2]=0))>>>0<u>>>0))break r}for(;;){X=v(F=0);t:if(!((0|(d=e[f>>2]))<2||(D=e[f+4>>2],E<=(S=R[D>>2])))){if(A=1,!(E<(k=R[D+4>>2])))for(F=d+-1|0;;){if(S=k,(0|A)==(0|F))break t;if(E<(k=R[D+((A=A+1|0)<<2)>>2]))break}X=v(v(E-S)/v(k-S)),F=A+-1|0}if(S=R[f+16>>2],R[f+16>>2]=X,A=e[f+12>>2],e[f+12>>2]=F,e[f+24>>2]=D=S!=X,e[f+20>>2]=D&(X==v(0)|S==v(0))|(0|A)!=(0|F),!((f=f+28|0)>>>0<u>>>0))break}}if(!((V=V+52|0)>>>0<g>>>0))break}}(a),function(f){var E,u,d,g,y,A,S,D=0,F=0,k=0,V=0,X=0,q=0,tt=0,ut=v(0),mt=0,kt=0,Ht=0,ce=0,we=0;if(1<=(0|(F=e[f+564>>2])))for(A=(X=e[f+568>>2])+j(F,36)|0,g=e[f+644>>2];;){r:{if(!(q=((k=V=F=0)|(u=e[X+4>>2]))<1))for(mt=e[X>>2],f=ce=0;;){if(D=e[mt+(f<<2)>>2],e[D+16>>2]){D=1,we=0;break r}if(k=k||e[D+24>>2],F=F||e[D+20>>2],V=(R[D+12>>2]!=v(0))+V|0,(0|u)==(0|(f=f+1|0)))break}if(D=0,(ce=g?1:k)|(we=g?1:F)&&(e[X+12>>2]=mt=1<<V,(0|V)!=31)){for(F=e[X+20>>2],y=e[X>>2],k=(f=e[X+16>>2])+(tt=mt<<2)|0,k=Ce(f,0,4+((-1^f)+((f=f+4|0)>>>0<k>>>0?k:f)|0)&-4),tt=F+tt|0,f=F;e[f>>2]=1065353216,(f=f+4|0)>>>0<tt>>>0;);if(!q){if(q=0,tt=D=1,V)for(;;){if(V=e[(q<<2)+y>>2],kt=e[V+8>>2],Ht=j(kt,D),(ut=R[V+12>>2])!=v(f=0)){for(e[k>>2]=Ht+e[k>>2],R[F>>2]=v(v(1)-ut)*R[F>>2],kt=j(kt+(f=1)|0,D);ut=R[V+12>>2],S=e[(d=(E=f<<2)+k|0)>>2],e[d>>2]=S+((d=f&tt)?kt:Ht),R[(E=F+E|0)>>2]=(d?ut:v(v(1)-ut))*R[E>>2],(0|mt)!=(0|(f=f+1|0)););tt<<=1}else for(;e[(kt=k+(f<<2)|0)>>2]=Ht+e[kt>>2],(0|mt)!=(0|(f=f+1|0)););if(D=j(e[V>>2],D),(0|u)==(0|(q=q+1|0)))break}else for(;;){if(V=e[(q<<2)+y>>2],tt=j(e[V+8>>2],D),(ut=R[V+12>>2])!=v(f=0))e[k>>2]=tt+e[k>>2],R[F>>2]=v(v(1)-ut)*R[F>>2];else for(;e[(Ht=k+(f<<2)|0)>>2]=tt+e[Ht>>2],(0|mt)!=(0|(f=f+1|0)););if(D=j(e[V>>2],D),(0|u)==(0|(q=q+1|0)))break}D=0}}}if(e[X+32>>2]=D,e[X+24>>2]=we,e[X+28>>2]=ce,!((X=X+36|0)>>>0<A>>>0))break}}(a),function(f){var E,u,d,g,y=v(0),A=0,S=0,D=0,F=0,k=0,V=v(0),X=v(0),q=v(0),tt=0,ut=0,mt=0;if(!(H[e[f>>2]+4|0]<4||(0|(A=e[f+588>>2]))<1))for(g=(D=e[f+592>>2])+j(A,48)|0,E=e[f+644>>2];;){if(f=e[D>>2],(ut=E?1:e[f+20>>2])|(mt=E?1:e[f+24>>2])){r:{t:{k=D,F=e[f+8>>2],A=e[f+12>>2],y=R[f+16>>2],f=(0|F)!=(0|A);e:{if(y!=v(0)){if(f=A+1|0,(0|A)==(0|F)){e[D+8>>2]=ut=1,y=v(v(1)-y),mt=1;break e}f=(0|f)==(0|F)?1:2}if(e[k+8>>2]=f,!mt)break t;f=A}R[D+24>>2]=y,R[D+20>>2]=v(1)-y;break r}mt=0,f=A}ut?(e[D+12>>2]=f,e[D+16>>2]=f+1):ut=0}else ut=mt=0;r:if((0|(u=e[D+36>>2]))<1)q=v(1);else{if(d=e[D+40>>2],f=0,q=v(1),!E)for(;;){t:{e:{if(A=e[(f<<2)+d>>2],S=e[A>>2]){if(!e[S+48>>2]){y=R[A+16>>2];break t}if((0|(F=e[A+12>>2]))<1){y=v(1),R[A+16>>2]=1;break t}if(tt=e[A+8>>2],(0|F)!=1&&(V=R[S+44>>2],k=e[A+4>>2],!(V<=(X=R[k>>2]))))break e;y=R[tt>>2],R[A+16>>2]=y;break t}e[A+16>>2]=1065353216,y=v(1);break t}S=1;e:if(!(V<(y=R[k+4>>2]))){for(;X=y,(0|F)!=(0|(S=S+1|0));)if(V<(y=R[k+(S<<2)>>2]))break e;y=R[(tt+(F<<2)|0)-4>>2],R[A+16>>2]=y;break t}k=A,y=v(v(V-X)/v(y-X)),y=v(v(y*R[(A=tt+(S<<2)|0)>>2])+v(R[A+-4>>2]*v(v(1)-y))),R[k+16>>2]=y}if(q=q<y?q:y,(0|u)==(0|(f=f+1|0)))break r}for(;;){A=e[(f<<2)+d>>2],S=e[A>>2],y=v(1);t:if(S&&(tt=e[A+12>>2],y=v(1),!((0|tt)<1))&&(F=e[A+8>>2],y=R[F>>2],(0|tt)!=1)){e:{if(V=R[S+44>>2],k=e[A+4>>2],V<=(X=R[k>>2])){y=R[F>>2];break t}if(S=1,!(V<(y=R[k+4>>2]))){for(;X=y,(0|tt)!=(0|(S=S+1|0));)if(V<(y=R[k+(S<<2)>>2]))break e;y=R[(F+(tt<<2)|0)-4>>2];break t}}y=v(v(V-X)/v(y-X)),y=v(v(y*R[(S=F+(S<<2)|0)>>2])+v(R[S+-4>>2]*v(v(1)-y)))}if(q=q<(R[A+16>>2]=y)?q:y,(0|u)==(0|(f=f+1|0)))break}}if(e[D+32>>2]=mt,e[D+28>>2]=ut,R[D+44>>2]=q,!((D=D+48|0)>>>0<g>>>0))break}}(a),1<=(0|(p=e[a+4>>2])))for(p=(_=e[a+52>>2])+(p<<2)|0;P=R[_>>2],R[_>>2]=P<v(0)?v(0):v(Mt(P,v(1))),(_=_+4|0)>>>0<p>>>0;);(function(f){var E,u,d,g=0,y=0;if(1<=(0|(y=e[f+4>>2])))for(d=(g=e[f+8>>2])+j(y,12)|0,f=E=e[f+40>>2];y=0,e[g+8>>2]&&(u=e[g+4>>2],!e[(u<<2)+E>>2]&&(0|u)!=-1||(y=!e[e[g>>2]+32>>2])),e[f>>2]=y,f=f+4|0,(g=g+12|0)>>>0<d>>>0;);})(a),function(f){var E,u,d,g,y,A,S,D=0,F=0,k=0,V=0,X=0;if(1<=(0|(u=e[f+4>>2])))for(g=e[f+8>>2],d=e[f>>2],y=e[d+724>>2];;){if(E=e[j(V,12)+g>>2],(e[E+28>>2]||e[E+24>>2])&&(e[(D=V<<2)+e[f+28>>2]>>2]=e[E+12>>2],e[E+24>>2])&&!((0|(k=e[E+12>>2]))<1))for(k=(F=e[E+16>>2])+(k<<2)|0,A=e[D+y>>2],D=e[f+36>>2]+(X<<2)|0,S=e[d+976>>2];e[D>>2]=e[(e[F>>2]+A<<2)+S>>2],D=D+4|0,(F=F+4|0)>>>0<k>>>0;);if(e[E+28>>2]&&!((0|(D=e[E+12>>2]))<1))for(k=(F=e[E+20>>2])+(D<<2)|0,D=e[f+32>>2]+(X<<2)|0;e[D>>2]=e[F>>2],D=D+4|0,(F=F+4|0)>>>0<k>>>0;);if(X=e[E+8>>2]+X|0,(0|u)==(0|(V=V+1|0)))break}}(a),L[e[1808]](a+12|0,e[a+36>>2],e[a+44>>2],e[a+40>>2]),function(f){var E,u,d,g,y,A,S=0,D=0,F=0;if(1<=(0|(F=e[f+304>>2])))for(d=(S=e[f+308>>2])+(F<<5)|0,g=e[f+264>>2],y=e[f+144>>2],A=e[f+40>>2],F=u=e[f+312>>2];E=F,D=0,f=D=!e[S+28>>2]||(0|(f=e[S+4>>2]))!=-1&&(D=0,!e[(f<<2)+A>>2])||(0|(f=e[S+8>>2]))!=-1&&(D=0,!e[(f<<2)+u>>2])?D:!e[e[S>>2]+32>>2],e[E>>2]=f,(E=e[S+12>>2])>>>0<=1?E-1?e[(e[S+16>>2]<<2)+y>>2]=f:e[(e[S+16>>2]<<2)+g>>2]=f:Ut(4,1372,0),F=F+4|0,(S=S+32|0)>>>0<d>>>0;);}(a),function(f){var E,u,d,g,y,A,S,D,F,k=0,V=0,X=0,q=0,pe=0,tt=0,ut=0,mt=0,kt=0,Ht=0,ce=0,we=0,Ue=0,Ye=0,pe=e[f>>2];if(1<=(0|(mt=e[f+56>>2]))){for(kt=e[f+60>>2],Ht=e[pe+1052>>2],ce=e[pe+784>>2];;){if(k=e[kt+j(tt,24)>>2],(e[k+28>>2]||e[k+24>>2])&&(e[(V=tt<<2)+e[f+80>>2]>>2]=e[k+12>>2],e[k+24>>2])&&!((0|(q=e[k+12>>2]))<1))for(we=(X=e[k+16>>2])+(q<<2)|0,Ue=e[V+ce>>2],V=(q=ut<<2)+e[f+92>>2]|0,q=q+e[f+88>>2]|0;Ye=Ue+e[X>>2]<<2,e[V>>2]=Ht+(e[Ye+e[pe+984>>2]>>2]<<2),e[q>>2]=e[Ye+e[pe+980>>2]>>2],q=q+4|0,V=V+4|0,(X=X+4|0)>>>0<we>>>0;);if(e[k+28>>2]&&!((0|(V=e[k+12>>2]))<1))for(q=(X=e[k+20>>2])+(V<<2)|0,V=e[f+84>>2]+(ut<<2)|0;e[V>>2]=e[X>>2],V=V+4|0,(X=X+4|0)>>>0<q>>>0;);if(ut=e[k+8>>2]+ut|0,(0|mt)==(0|(tt=tt+1|0)))break}pe=e[f>>2]}if(!(H[pe+4|0]<4||(0|(Ue=e[f+56>>2]))<1))for(Ye=e[pe+792>>2],E=e[f+60>>2],X=ut=0;;){if(tt=e[j(X,24)+E>>2],e[tt+24>>2]&&!((0|(k=e[tt+12>>2]))<1))for(u=(V=e[tt+16>>2])+(k<<2)|0,d=e[Ye+(X<<2)>>2],q=(k=ut<<2)+e[f+96>>2]|0,mt=k+e[f+100>>2]|0,kt=k+e[f+104>>2]|0,Ht=k+e[f+108>>2]|0,ce=k+e[f+112>>2]|0,we=k+e[f+116>>2]|0,g=e[pe+1308>>2],y=e[pe+1304>>2],A=e[pe+1300>>2],S=e[pe+1296>>2],D=e[pe+1292>>2],F=e[pe+1288>>2];k=e[V>>2]+d<<2,e[q>>2]=e[k+F>>2],e[mt>>2]=e[k+D>>2],e[kt>>2]=e[k+S>>2],e[Ht>>2]=e[k+A>>2],e[ce>>2]=e[k+y>>2],e[we>>2]=e[k+g>>2],we=we+4|0,ce=ce+4|0,Ht=Ht+4|0,kt=kt+4|0,mt=mt+4|0,q=q+4|0,(V=V+4|0)>>>0<u>>>0;);if(ut=e[tt+8>>2]+ut|0,(0|Ue)==(0|(X=X+1|0)))break}}(a),function(f){var E=0,u=0,d=0,g=0,y=0,A=0,S=0,D=0,F=0,k=0,V=0,X=0,q=0,tt=0,ut=0,mt=0,kt=0,Ht=0,ce=0,we=0,Ue=0,Ye=e[f+168>>2],pe=e[f>>2];if(1<=(0|(q=e[f+164>>2])))for(ut=e[pe+816>>2];;){if(d=e[j(S,12)+Ye>>2],(e[d+28>>2]||e[d+24>>2])&&(e[(D=S<<2)+e[f+188>>2]>>2]=e[d+12>>2],e[d+24>>2])){if(u=e[d+16>>2],tt=e[D+ut>>2],1<=(0|(E=e[d+12>>2])))for(mt=u+(E<<2)|0,g=(E=A<<2)+e[f+200>>2]|0,F=E+e[f+204>>2]|0,k=E+e[f+208>>2]|0,V=E+e[f+212>>2]|0,X=E+e[f+196>>2]|0,kt=e[pe+996>>2],Ht=e[pe+1012>>2],ce=e[pe+1008>>2],we=e[pe+1004>>2],Ue=e[pe+1e3>>2],E=u;y=tt+e[E>>2]<<2,e[g>>2]=e[y+Ue>>2],e[F>>2]=e[y+we>>2],e[k>>2]=e[y+ce>>2],e[V>>2]=e[y+Ht>>2],e[X>>2]=e[y+kt>>2],X=X+4|0,V=V+4|0,k=k+4|0,F=F+4|0,g=g+4|0,(E=E+4|0)>>>0<mt>>>0;);E=tt+e[u>>2]<<2,e[D+e[f+288>>2]>>2]=e[E+e[pe+1016>>2]>>2],e[D+e[f+292>>2]>>2]=e[E+e[pe+1020>>2]>>2]}if(e[d+28>>2]&&!((0|(u=e[d+12>>2]))<1))for(u=(E=e[d+20>>2])+(u<<2)|0,g=e[f+192>>2]+(A<<2)|0;e[g>>2]=e[E>>2],g=g+4|0,(E=E+4|0)>>>0<u>>>0;);if(A=e[d+8>>2]+A|0,(0|q)==(0|(S=S+1|0)))break}if(!(H[pe+4|0]<4||(0|(D=e[f+164>>2]))<1))for(tt=e[pe+824>>2],A=d=0;;){if(y=e[j(A,12)+Ye>>2],e[y+24>>2]&&!((0|(E=e[y+12>>2]))<1))for(q=(g=e[y+16>>2])+(E<<2)|0,ut=e[tt+(A<<2)>>2],F=(u=d<<2)+e[f+216>>2]|0,k=u+e[f+220>>2]|0,V=u+e[f+224>>2]|0,X=u+e[f+228>>2]|0,E=u+e[f+232>>2]|0,S=u+e[f+236>>2]|0,mt=e[pe+1308>>2],kt=e[pe+1304>>2],Ht=e[pe+1300>>2],ce=e[pe+1296>>2],we=e[pe+1292>>2],Ue=e[pe+1288>>2];u=ut+e[g>>2]<<2,e[F>>2]=e[u+Ue>>2],e[k>>2]=e[u+we>>2],e[V>>2]=e[u+ce>>2],e[X>>2]=e[u+Ht>>2],e[E>>2]=e[u+kt>>2],e[S>>2]=e[u+mt>>2],S=S+4|0,E=E+4|0,X=X+4|0,V=V+4|0,k=k+4|0,F=F+4|0,(g=g+4|0)>>>0<q>>>0;);if(d=e[y+8>>2]+d|0,(0|D)==(0|(A=A+1|0)))break}}(a),function(f){var E,F=0,u=0,d=0,g=0,y=0,A=0,S=0,D=0,F=f- -64|0;if(L[e[1807]](F,e[f+88>>2],e[f+148>>2],e[f+144>>2]),L[e[1809]](F,e[f+92>>2],e[f+152>>2],e[e[f>>2]+796>>2],2,e[f+144>>2]),!(H[e[f>>2]+4|0]<4||(L[e[1807]](F,e[f+96>>2],e[f+120>>2],e[f+144>>2]),L[e[1807]](F,e[f+100>>2],e[f+124>>2],e[f+144>>2]),L[e[1807]](F,e[f+104>>2],e[f+128>>2],e[f+144>>2]),L[e[1807]](F,e[f+108>>2],e[f+132>>2],e[f+144>>2]),L[e[1807]](F,e[f+112>>2],e[f+136>>2],e[f+144>>2]),L[e[1807]](F,e[f+116>>2],e[f+140>>2],e[f+144>>2]),(0|(A=e[f+56>>2]))<1))){for(S=e[f+128>>2],D=e[f+124>>2],E=e[f+120>>2],u=e[f+156>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+D>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|A)!=(0|(F=F+1|0)););for(u=e[f+160>>2],y=e[f+140>>2],S=e[f+136>>2],D=e[f+132>>2],F=f=0;e[(g=f<<2)+u>>2]=e[(d=F<<2)+D>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],f=f+4|0,(0|A)!=(0|(F=F+1|0)););}}(a),function(f){var E,F=0,u=0,d=0,g=0,y=0,A=0,S=0,D=0,F=f+172|0;if(L[e[1807]](F,e[f+196>>2],e[f+268>>2],e[f+264>>2]),L[e[1807]](F,e[f+200>>2],e[f+284>>2],e[f+264>>2]),L[e[1807]](F,e[f+204>>2],e[f+276>>2],e[f+264>>2]),L[e[1807]](F,e[f+208>>2],e[f+280>>2],e[f+264>>2]),L[e[1807]](F,e[f+212>>2],e[f+272>>2],e[f+264>>2]),!(H[e[f>>2]+4|0]<4||(L[e[1807]](F,e[f+216>>2],e[f+240>>2],e[f+264>>2]),L[e[1807]](F,e[f+220>>2],e[f+244>>2],e[f+264>>2]),L[e[1807]](F,e[f+224>>2],e[f+248>>2],e[f+264>>2]),L[e[1807]](F,e[f+228>>2],e[f+252>>2],e[f+264>>2]),L[e[1807]](F,e[f+232>>2],e[f+256>>2],e[f+264>>2]),L[e[1807]](F,e[f+236>>2],e[f+260>>2],e[f+264>>2]),(0|(A=e[f+164>>2]))<1))){for(S=e[f+248>>2],D=e[f+244>>2],E=e[f+240>>2],u=e[f+296>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+D>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|A)!=(0|(F=F+1|0)););for(u=e[f+300>>2],y=e[f+260>>2],S=e[f+256>>2],D=e[f+252>>2],F=f=0;e[(g=f<<2)+u>>2]=e[(d=F<<2)+D>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],f=f+4|0,(0|A)!=(0|(F=F+1|0)););}}(a),function(f){var E,u,d,g=0,y=0,A=0;if(1<=(0|(y=e[f+332>>2])))for(E=(g=e[f+336>>2])+j(y,20)|0,u=e[f+312>>2],d=e[f+40>>2],f=e[f+424>>2];y=0,e[g+12>>2]&&(A=e[g+4>>2],e[(A<<2)+d>>2]||(0|A)==-1)&&(A=e[g+8>>2],e[(A<<2)+u>>2]||(0|A)==-1)&&(y=!e[e[g>>2]+32>>2]),e[f>>2]=y,f=f+4|0,(g=g+20|0)>>>0<E>>>0;);}(a),function(f){var E,u,d,g,y,A,S,D,F=0,k=0,V=0,pe=0,X=0,q=0,tt=0,ut=0,mt=0,kt=0,Ht=0,ce=0,we=0,Ue=0,Ye=0,pe=e[f>>2];if(1<=(0|(kt=e[f+332>>2]))){for(Ht=e[f+336>>2],ce=e[pe+1052>>2],we=e[pe+856>>2];;){if(F=e[Ht+j(tt,20)>>2],(e[F+28>>2]||e[F+24>>2])&&(e[(k=tt<<2)+e[f+356>>2]>>2]=e[F+12>>2],e[F+24>>2])&&!((0|(X=e[F+12>>2]))<1))for(Ue=(V=e[F+16>>2])+(X<<2)|0,Ye=e[k+we>>2],k=(q=ut<<2)+e[f+372>>2]|0,X=q+e[f+364>>2]|0,q=q+e[f+368>>2]|0;mt=Ye+e[V>>2]<<2,e[k>>2]=ce+(e[mt+e[pe+1040>>2]>>2]<<2),e[X>>2]=e[mt+e[pe+1032>>2]>>2],e[q>>2]=e[mt+e[pe+1036>>2]>>2],q=q+4|0,X=X+4|0,k=k+4|0,(V=V+4|0)>>>0<Ue>>>0;);if(e[F+28>>2]&&!((0|(k=e[F+12>>2]))<1))for(X=(V=e[F+20>>2])+(k<<2)|0,k=e[f+360>>2]+(ut<<2)|0;e[k>>2]=e[V>>2],k=k+4|0,(V=V+4|0)>>>0<X>>>0;);if(ut=e[F+8>>2]+ut|0,(0|kt)==(0|(tt=tt+1|0)))break}pe=e[f>>2]}if(!(H[pe+4|0]<4||(0|(we=e[f+332>>2]))<1))for(Ue=e[pe+864>>2],Ye=e[f+336>>2],V=ut=0;;){if(tt=e[Ye+j(V,20)>>2],e[tt+24>>2]&&!((0|(F=e[tt+12>>2]))<1))for(E=(k=e[tt+16>>2])+(F<<2)|0,u=e[Ue+(V<<2)>>2],X=(F=ut<<2)+e[f+376>>2]|0,q=F+e[f+380>>2]|0,mt=F+e[f+384>>2]|0,kt=F+e[f+388>>2]|0,Ht=F+e[f+392>>2]|0,ce=F+e[f+396>>2]|0,d=e[pe+1308>>2],g=e[pe+1304>>2],y=e[pe+1300>>2],A=e[pe+1296>>2],S=e[pe+1292>>2],D=e[pe+1288>>2];F=e[k>>2]+u<<2,e[X>>2]=e[F+D>>2],e[q>>2]=e[F+S>>2],e[mt>>2]=e[F+A>>2],e[kt>>2]=e[F+y>>2],e[Ht>>2]=e[F+g>>2],e[ce>>2]=e[F+d>>2],ce=ce+4|0,Ht=Ht+4|0,kt=kt+4|0,mt=mt+4|0,q=q+4|0,X=X+4|0,(k=k+4|0)>>>0<E>>>0;);if(ut=e[tt+8>>2]+ut|0,(0|we)==(0|(V=V+1|0)))break}}(a),function(f){var E,F=0,u=0,d=0,g=0,y=0,A=0,S=0,D=0,F=f+340|0;if(L[e[1807]](F,e[f+364>>2],e[f+448>>2],e[f+424>>2]),L[e[1808]](F,e[f+368>>2],e[f+440>>2],e[f+424>>2]),L[e[1809]](F,e[f+372>>2],e[f+444>>2],e[e[f>>2]+892>>2],2,e[f+424>>2]),!(H[e[f>>2]+4|0]<4||(L[e[1807]](F,e[f+376>>2],e[f+400>>2],e[f+424>>2]),L[e[1807]](F,e[f+380>>2],e[f+404>>2],e[f+424>>2]),L[e[1807]](F,e[f+384>>2],e[f+408>>2],e[f+424>>2]),L[e[1807]](F,e[f+388>>2],e[f+412>>2],e[f+424>>2]),L[e[1807]](F,e[f+392>>2],e[f+416>>2],e[f+424>>2]),L[e[1807]](F,e[f+396>>2],e[f+420>>2],e[f+424>>2]),(0|(A=e[f+332>>2]))<1))){for(S=e[f+408>>2],D=e[f+404>>2],E=e[f+400>>2],u=e[f+452>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+D>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|A)!=(0|(F=F+1|0)););for(u=e[f+456>>2],y=e[f+420>>2],S=e[f+416>>2],D=e[f+412>>2],F=f=0;e[(g=f<<2)+u>>2]=e[(d=F<<2)+D>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],f=f+4|0,(0|A)!=(0|(F=F+1|0)););}}(a),function(f){var E,u,d,g,y,A,S,D=0,F=0,k=0,V=0,X=0;if(1<=(0|(u=e[f+500>>2])))for(g=e[f+504>>2],d=e[f>>2],y=e[d+1252>>2];;){if(E=e[j(V,24)+g>>2],(e[E+28>>2]||e[E+24>>2])&&(e[(D=V<<2)+e[f+524>>2]>>2]=e[E+12>>2],e[E+24>>2])&&!((0|(k=e[E+12>>2]))<1))for(k=(F=e[E+16>>2])+(k<<2)|0,A=e[D+y>>2],D=e[f+532>>2]+(X<<2)|0,S=e[d+1284>>2];e[D>>2]=e[(e[F>>2]+A<<2)+S>>2],D=D+4|0,(F=F+4|0)>>>0<k>>>0;);if(e[E+28>>2]&&!((0|(D=e[E+12>>2]))<1))for(k=(F=e[E+20>>2])+(D<<2)|0,D=e[f+528>>2]+(X<<2)|0;e[D>>2]=e[F>>2],D=D+4|0,(F=F+4|0)>>>0<k>>>0;);if(X=e[E+8>>2]+X|0,(0|u)==(0|(V=V+1|0)))break}}(a),L[e[1807]](a+508|0,e[a+532>>2],e[a+536>>2],0),function(f){var E,u,d,g,y,A,S=v(0),D=0,F=0,k=0,V=0;if(v(0),K=E=K-16|0,k=e[f>>2],!(H[k+4|0]<5||(0|(V=e[f+596>>2]))<1))for(g=(F=e[f+600>>2])+j(V,12)|0,y=e[f+44>>2],V=e[k+976>>2];;){if(k=(e[F>>2]<<2)+y|0,S=v(e[k>>2]),1<=(0|(D=e[F+4>>2])))for(A=(f=e[F+8>>2])+j(D,48)|0;(D=e[f+8>>2])&&((u=D+-1|0)>>>0<=1?(D=e[f+4>>2],d=R[V+(D+e[f+12>>2]<<2)>>2],S=v(u-1?S+v(R[f+44>>2]*v(d*R[f+20>>2])):S+v(R[f+44>>2]*v(v(d*R[f+20>>2])+v(R[V+(D+e[f+16>>2]<<2)>>2]*R[f+24>>2]))))):(e[E>>2]=D,Ut(4,1024,E))),(f=f+48|0)>>>0<A>>>0;);if(S=(S=v(S+v(.0010000000474974513)))<v(0)?v(0):v(Mt(S,v(1e3))),f=v(St(S))<v(2147483648)?~~S:-2147483648,e[k>>2]=f,!((F=F+12|0)>>>0<g>>>0))break}K=16+E|0}(a),function(f){var E,u,d,g,y,A,S,D,F,k=0,V=0,X=0,q=0,tt=0,ut=v(0);if(K=E=K-16|0,k=e[f>>2],!(H[k+4|0]<4||(Yr(f,e[f+604>>2],e[f+608>>2],e[k+984>>2],e[f+152>>2],e[k+796>>2]),V=e[f>>2],H[V+4|0]<5))){if(X=e[f+608>>2],y=e[V+992>>2],A=e[V+988>>2],1<=(0|(k=e[f+604>>2]))){for(S=j(k,12)+X|0,D=e[f+148>>2],u=e[V+980>>2];;){if(d=(e[X>>2]<<2)+D|0,tt=e[d>>2],1<=(0|(q=e[X+4>>2])))for(F=(k=e[X+8>>2])+j(q,48)|0;(q=e[k+8>>2])&&((g=q+-1|0)>>>0<=1?(q=e[k+4>>2],ut=R[(q+e[k+12>>2]<<2)+u>>2],Qt(v(g-1?v(R[k+44>>2]*v(ut*R[k+20>>2]))+(Yt(0,tt),Xt()):v(R[k+44>>2]*v(v(ut*R[k+20>>2])+v(R[(q+e[k+16>>2]<<2)+u>>2]*R[k+24>>2])))+(Yt(0,tt),Xt()))),tt=Wt[0]):(e[E>>2]=q,Ut(4,1024,E))),(k=k+48|0)>>>0<F>>>0;);if(Yt(0,tt),ut=Xt(),R[d>>2]=ut<v(0)?v(0):v(Mt(ut,v(1))),!((X=X+12|0)>>>0<S>>>0))break}X=e[f+608>>2],k=e[f+604>>2]}ee(k,X,A,e[V+1288>>2],e[V+1292>>2],e[V+1296>>2],e[f+156>>2]),ee(e[f+604>>2],e[f+608>>2],y,e[V+1300>>2],e[V+1304>>2],e[V+1308>>2],e[f+160>>2])}K=16+E|0}(a),function(f){var E,u=0,d=0,g=0,y=0,A=0,S=v(0),D=0,F=0,k=0,V=0,X=0,q=0,tt=0,ut=0;if(K=E=K-80|0,A=e[f>>2],!(H[A+4|0]<5)){if(q=e[A+1028>>2],tt=e[A+1024>>2],g=d=e[f+616>>2],!((0|(u=e[f+612>>2]))<1)){for(F=j(u,12)+d|0,k=e[f+276>>2],D=e[A+1004>>2];;){if(V=k+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((X=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=R[D+(y+e[u+12>>2]<<2)>>2],Qt(v(X-1?v(R[u+44>>2]*v(S*R[u+20>>2]))+(Yt(0,g),Xt()):v(R[u+44>>2]*v(v(S*R[u+20>>2])+v(R[D+(y+e[u+16>>2]<<2)>>2]*R[u+24>>2])))+(Yt(0,g),Xt()))),g=Wt[0]):(e[64+E>>2]=y,Ut(4,1024,64+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(e[V>>2]=g,!((d=d+12|0)>>>0<F>>>0))break}if(g=d=e[f+616>>2],!((0|(u=e[f+612>>2]))<1)){for(F=j(u,12)+d|0,k=e[f+280>>2],D=e[e[f>>2]+1008>>2];;){if(V=k+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((X=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=R[D+(y+e[u+12>>2]<<2)>>2],Qt(v(X-1?v(R[u+44>>2]*v(S*R[u+20>>2]))+(Yt(0,g),Xt()):v(R[u+44>>2]*v(v(S*R[u+20>>2])+v(R[D+(y+e[u+16>>2]<<2)>>2]*R[u+24>>2])))+(Yt(0,g),Xt()))),g=Wt[0]):(e[48+E>>2]=y,Ut(4,1024,48+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(e[V>>2]=g,!((d=d+12|0)>>>0<F>>>0))break}if(g=d=e[f+616>>2],!((0|(u=e[f+612>>2]))<1)){for(F=j(u,12)+d|0,k=e[f+268>>2],D=e[e[f>>2]+996>>2];;){if(V=k+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((X=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=R[D+(y+e[u+12>>2]<<2)>>2],Qt(v(X-1?v(R[u+44>>2]*v(S*R[u+20>>2]))+(Yt(0,g),Xt()):v(R[u+44>>2]*v(v(S*R[u+20>>2])+v(R[D+(y+e[u+16>>2]<<2)>>2]*R[u+24>>2])))+(Yt(0,g),Xt()))),g=Wt[0]):(e[32+E>>2]=y,Ut(4,1024,32+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(Yt(0,g),S=Xt(),R[V>>2]=S<v(0)?v(0):v(Mt(S,v(1))),!((d=d+12|0)>>>0<F>>>0))break}u=e[f+612>>2],g=e[f+616>>2]}}}if(ee(u,g,tt,e[A+1288>>2],e[A+1292>>2],e[A+1296>>2],e[f+296>>2]),ee(e[f+612>>2],e[f+616>>2],q,e[A+1300>>2],e[A+1304>>2],e[A+1308>>2],e[f+300>>2]),!((0|(u=e[f+612>>2]))<1)){for(y=(d=e[f+616>>2])+j(u,12)|0,q=e[f+284>>2],A=e[e[f>>2]+1e3>>2];;){if(tt=q+(e[d>>2]<<2)|0,g=e[tt>>2],1<=(0|(D=e[d+4>>2])))for(F=(u=e[d+8>>2])+j(D,48)|0;(D=e[u+8>>2])&&((k=D+-1|0)>>>0<=1?(D=e[u+4>>2],S=R[A+(D+e[u+12>>2]<<2)>>2],Qt(v(k-1?v(R[u+44>>2]*v(S*R[u+20>>2]))+(Yt(0,g),Xt()):v(R[u+44>>2]*v(v(S*R[u+20>>2])+v(R[A+(D+e[u+16>>2]<<2)>>2]*R[u+24>>2])))+(Yt(0,g),Xt()))),g=Wt[0]):(e[16+E>>2]=D,Ut(4,1024,16+E|0))),(u=u+48|0)>>>0<F>>>0;);if(Yt(0,g),S=Xt(),R[tt>>2]=S<v(-3600)?v(-3600):v(Mt(S,v(3600))),!((d=d+12|0)>>>0<y>>>0))break}if(!((0|(u=e[f+612>>2]))<1))for(D=(d=e[f+616>>2])+j(u,12)|0,y=e[f+272>>2],f=e[e[f>>2]+1012>>2];;){if(q=y+(e[d>>2]<<2)|0,g=e[q>>2],1<=(0|(A=e[d+4>>2])))for(tt=(u=e[d+8>>2])+j(A,48)|0;(A=e[u+8>>2])&&((F=A+-1|0)>>>0<=1?(A=e[u+4>>2],S=R[f+(A+e[u+12>>2]<<2)>>2],Qt(v(F-1?v(R[u+44>>2]*v(S*R[u+20>>2]))+(Yt(0,g),Xt()):v(R[u+44>>2]*v(v(S*R[u+20>>2])+v(R[f+(A+e[u+16>>2]<<2)>>2]*R[u+24>>2])))+(Yt(0,g),Xt()))),g=Wt[0]):(e[E>>2]=A,Ut(4,1024,E))),(u=u+48|0)>>>0<tt>>>0;);if(Yt(0,g),S=Xt(),R[q>>2]=S<v(9999999747378752e-20)?v(9999999747378752e-20):v(Mt(S,v(100))),!((d=d+12|0)>>>0<D>>>0))break}}}K=80+E|0}(a),function(f){var E,u,d,g,y,A=0,S=0,D=0,F=0,k=v(0),V=0,X=0,q=0,tt=0,ut=0,mt=0;if(v(0),K=E=K-32|0,D=e[f>>2],!(H[D+4|0]<4||(Yr(f,e[f+620>>2],e[f+624>>2],e[D+1040>>2],e[f+444>>2],e[D+892>>2]),V=e[f>>2],H[V+4|0]<5))){if(g=e[V+1048>>2],y=e[V+1044>>2],D=F=e[f+624>>2],!((0|(A=e[f+620>>2]))<1)){for(ut=j(A,12)+F|0,mt=e[f+440>>2],X=e[V+1036>>2];;){if(D=mt+(e[F>>2]<<2)|0,k=v(e[D>>2]),1<=(0|(S=e[F+4>>2])))for(q=(A=e[F+8>>2])+j(S,48)|0;(S=e[A+8>>2])&&((tt=S+-1|0)>>>0<=1?(S=e[A+4>>2],u=R[X+(S+e[A+12>>2]<<2)>>2],k=v(tt-1?k+v(R[A+44>>2]*v(u*R[A+20>>2])):k+v(R[A+44>>2]*v(v(u*R[A+20>>2])+v(R[X+(S+e[A+16>>2]<<2)>>2]*R[A+24>>2]))))):(e[16+E>>2]=S,Ut(4,1024,16+E|0))),(A=A+48|0)>>>0<q>>>0;);if(k=(k=v(k+v(.0010000000474974513)))<v(0)?v(0):v(Mt(k,v(1e3))),A=v(St(k))<v(2147483648)?~~k:-2147483648,e[D>>2]=A,!((F=F+12|0)>>>0<ut>>>0))break}if(D=F=e[f+624>>2],!((0|(A=e[f+620>>2]))<1)){for(ut=j(A,12)+F|0,mt=e[f+448>>2],X=e[e[f>>2]+1032>>2];;){if(q=mt+(e[F>>2]<<2)|0,D=e[q>>2],1<=(0|(S=e[F+4>>2])))for(tt=(A=e[F+8>>2])+j(S,48)|0;(S=e[A+8>>2])&&((d=S+-1|0)>>>0<=1?(S=e[A+4>>2],k=R[X+(S+e[A+12>>2]<<2)>>2],Qt(v(d-1?v(R[A+44>>2]*v(k*R[A+20>>2]))+(Yt(0,D),Xt()):v(R[A+44>>2]*v(v(k*R[A+20>>2])+v(R[X+(S+e[A+16>>2]<<2)>>2]*R[A+24>>2])))+(Yt(0,D),Xt()))),D=Wt[0]):(e[E>>2]=S,Ut(4,1024,E))),(A=A+48|0)>>>0<tt>>>0;);if(Yt(0,D),k=Xt(),R[q>>2]=k<v(0)?v(0):v(Mt(k,v(1))),!((F=F+12|0)>>>0<ut>>>0))break}A=e[f+620>>2],D=e[f+624>>2]}}ee(A,D,y,e[V+1288>>2],e[V+1292>>2],e[V+1296>>2],e[f+452>>2]),ee(e[f+620>>2],e[f+624>>2],g,e[V+1300>>2],e[V+1304>>2],e[V+1308>>2],e[f+456>>2])}K=32+E|0}(a),function(f){var E,u,d,g,y,A,S=0,D=0,F=0,k=0,V=v(0);if(K=E=K-16|0,D=e[f>>2],!(H[D+4|0]<5||(0|(k=e[f+628>>2]))<1))for(g=(F=e[f+632>>2])+j(k,12)|0,y=e[f+536>>2],k=e[D+1284>>2];;){if(u=(e[F>>2]<<2)+y|0,D=e[u>>2],1<=(0|(S=e[F+4>>2])))for(A=(f=e[F+8>>2])+j(S,48)|0;(S=e[f+8>>2])&&((d=S+-1|0)>>>0<=1?(S=e[f+4>>2],V=R[k+(S+e[f+12>>2]<<2)>>2],Qt(v(d-1?v(R[f+44>>2]*v(V*R[f+20>>2]))+(Yt(0,D),Xt()):v(R[f+44>>2]*v(v(V*R[f+20>>2])+v(R[k+(S+e[f+16>>2]<<2)>>2]*R[f+24>>2])))+(Yt(0,D),Xt()))),D=Wt[0]):(e[E>>2]=S,Ut(4,1024,E))),(f=f+48|0)>>>0<A>>>0;);if(Yt(0,D),V=Xt(),R[u>>2]=V<v(0)?v(0):v(Mt(V,v(1))),!((F=F+12|0)>>>0<g>>>0))break}K=16+E|0}(a),function(f){var E,u,d=0,g=0,y=0,A=v(0),S=0;if(1<=(0|(d=e[f+4>>2])))for(u=(g=e[f+8>>2])+j(d,12)|0,d=e[f+40>>2],y=e[f+52>>2],f=E=e[f+48>>2];e[d>>2]&&(A=R[y>>2],R[f>>2]=A,(0|(S=e[g+4>>2]))!=-1)&&(R[f>>2]=A*R[(S<<2)+E>>2]),f=f+4|0,y=y+4|0,d=d+4|0,(g=g+12|0)>>>0<u>>>0;);}(a),function(f){var E,u=0,d=0,g=0;if(1<=(0|(E=e[f+304>>2])))for(u=e[f+308>>2],d=e[f+312>>2];e[d>>2]&&L[e[u+20>>2]](f,g),d=d+4|0,u=u+32|0,(0|E)!=(0|(g=g+1|0)););}(a),function(f){var E,u,d,g,y,A=0,S=0,D=(v(0),v(0),0),F=0,k=0,V=(v(0),0),X=0,q=0;if(1<=(0|(A=e[f+332>>2])))for(X=(S=e[f+336>>2])+j(A,20)|0,q=e[f+308>>2],V=e[f+316>>2],y=e[f+48>>2],A=e[f+448>>2],D=e[f+444>>2],k=e[f+424>>2];e[k>>2]&&((0|(F=e[S+4>>2]))!=-1&&(R[A>>2]=R[(F<<2)+y>>2]*R[A>>2]),(0|(F=e[S+8>>2]))!=-1)&&(R[A>>2]=R[V+(F<<2)>>2]*R[A>>2],g=e[D>>2],L[e[24+(q+(F<<5)|0)>>2]](f,F,g,g,e[S+16>>2])),D=D+4|0,A=A+4|0,k=k+4|0,(S=S+20|0)>>>0<X>>>0;);if(!(H[e[f>>2]+4|0]<4||(0|(A=e[f+332>>2]))<1))for(F=(D=e[f+336>>2])+j(A,20)|0,X=e[f+328>>2],q=e[f+324>>2],S=e[f+452>>2],A=e[f+456>>2],k=e[f+424>>2];e[k>>2]&&(0|(f=e[D+8>>2]))!=-1&&(f=(V=f<<4)+q|0,E=v(R[S>>2]*R[f>>2]),R[S>>2]=E,u=v(R[S+4>>2]*R[f+4>>2]),R[S+4>>2]=u,d=R[f+8>>2],e[S+12>>2]=1065353216,R[S+4>>2]=u<v(0)?v(0):v(Mt(u,v(1))),R[S>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=v(d*R[S+8>>2]),R[S+8>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=R[A>>2],u=R[(f=X+V|0)>>2],E=v(v(E+u)-v(E*u)),R[A>>2]=E,u=R[A+4>>2],d=R[f+4>>2],u=v(v(u+d)-v(u*d)),R[A+4>>2]=u,d=R[f+8>>2],e[A+12>>2]=1065353216,R[A+4>>2]=u<v(0)?v(0):v(Mt(u,v(1))),R[A>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=R[A+8>>2],E=v(v(d+E)-v(E*d)),R[A+8>>2]=E<v(0)?v(0):v(Mt(E,v(1)))),A=A+16|0,S=S+16|0,k=k+4|0,(D=D+20|0)>>>0<F>>>0;);}(a),function(f){var E,u,d,g,y,A,S,D,F,k,V,X,q,tt,ut,mt,kt,Ht,ce,we,Ue=0;if(v(0),v(0),v(0),v(0),v(0),v(0),v(0),1<=(0|(D=e[f+500>>2])))for(ce=e[f+536>>2],F=e[f+444>>2],we=e[f+504>>2];;){if(f=j(Ue,24)+we|0,0<(0|(k=e[f+12>>2])))for(d=R[(Ue<<2)+ce>>2],V=e[f+20>>2],X=e[f+16>>2],q=e[(e[f+4>>2]<<2)+F>>2],tt=e[(e[f+8>>2]<<2)+F>>2],f=0;ut=R[((E=1|f)<<2)+X>>2],u=W[(f<<1)+V>>1]<<3&262136,g=R[(mt=(4|u)+q|0)>>2],E=W[(E<<1)+V>>1]<<3&262136,y=R[(kt=(4|E)+tt|0)>>2],A=R[(u=u+q|0)>>2],Ht=R[(f<<2)+X>>2],S=R[(E=E+tt|0)>>2],R[u>>2]=A+v(d*v(Ht*v(S-A))),R[mt>>2]=g+v(d*v(Ht*v(y-g))),R[E>>2]=S+v(d*v(ut*v(A-S))),R[kt>>2]=y+v(d*v(ut*v(g-y))),(0|(f=f+2|0))<(0|k););if(!((0|(Ue=Ue+1|0))<(0|D)))break}}(a),L[e[1810]](a),function(f){var E,u,d,g,y=0,A=0,S=0,D=0,F=0,k=0,V=0,X=0,q=0,tt=0,ut=0;if(!((0|(E=e[f+480>>2]))<1)){for(D=(u=e[f+484>>2])+j(E,28)|0,V=e[f+424>>2],X=e[f+40>>2],F=e[f+44>>2],ut=e[f+440>>2],y=u;;){if(1<=(0|(k=e[y+4>>2])))for(tt=y+20|0,q=e[y+12>>2],A=0;d=e[4+(S=q+(A<<4)|0)>>2]<<2,S=e[(g=S)>>2]==1,e[g+12>>2]=e[(e[(S?X:V)+d>>2]?(S?F:ut)+d|0:tt)>>2],(0|(A=A+1|0))<(0|k););if(!((y=y+28|0)>>>0<D>>>0))break}if(!((0|E)<1))for(ut=e[f+436>>2],X=0;;){if(D=j(X,28)+u|0,!(e[(V=D)+24>>2]<1)){for(S=e[f+488>>2],A=0;e[S+(A<<2)>>2]=-1,(0|(A=A+1|0))<(0|(y=e[V+24>>2])););if(!((0|y)<1))for(y=e[f+496>>2],A=0;e[y+(A<<2)>>2]=-1,(0|(A=A+1|0))<e[V+24>>2];);}if(!(e[D+4>>2]<1)){for(F=e[f+492>>2],A=0;e[F+(A<<2)>>2]=-1,(0|(A=A+1|0))<(0|(y=e[D+4>>2])););if(!((0|y)<1))for(k=e[D+12>>2],tt=e[f+496>>2],A=0;q=e[12+(k+(A<<4)|0)>>2]-e[D+20>>2]<<2,y=(0|(y=e[(S=q+tt|0)>>2]))==-1?q+e[f+488>>2]|0:F+(y<<2)|0,e[y>>2]=A,(0|(A=(e[S>>2]=A)+1|0))<e[D+4>>2];);}if(1<=(0|(y=e[V+24>>2])))for(F=e[D+8>>2],tt=e[f+488>>2],k=0;;){if((0|(A=e[tt+(k<<2)>>2]))!=-1){for(q=e[f+492>>2],S=e[D+12>>2];F=(y=e[(y=S+(A<<4)|0)>>2]==1?(y=j(e[y+8>>2],28)+u|0,e[y+8>>2]=F,e[y>>2]):(e[ut+(e[y+4>>2]<<2)>>2]=F,1))+F|0,(0|A)<(0|(y=e[q+(A<<2)>>2]))&&(0|(A=y))!=-1;);y=e[V+24>>2]}if(!((0|(k=k+1|0))<(0|y)))break}if((0|E)==(0|(X=X+1|0)))break}}}(a),function(f){var E=0,u=0,d=0,g=0,y=0,A=v(0),S=0,D=0,F=e[f+332>>2];if(e[f+644>>2]){if(!(((e[f+428>>2]=0)|F)<1))for(;E=126,S=e[f+432>>2]+d|0,!e[(u=d<<2)+e[f+424>>2]>>2]|R[u+e[f+448>>2]>>2]==v(0)||(E=127),O[0|S]=E,(0|F)!=(0|(d=d+1|0)););}else if(e[f+428>>2]){if(E=H[e[f>>2]+4|0],!(((e[f+428>>2]=0)|F)<1))if(4<=E>>>0)for(;A=R[(E=d<<2)+e[f+448>>2]>>2],g=e[E+e[f+424>>2]>>2],u=A!=v(0)&(0|g)!=0,S=e[f+432>>2]+d|0,u=(0|u)==(1&O[0|S])?u:2|u,u=A!=R[E+e[f+468>>2]>>2]?4|u:u,u=e[E+e[f+440>>2]>>2]==e[E+e[f+464>>2]>>2]?u:8|u,E=e[E+e[f+436>>2]>>2]==e[E+e[f+460>>2]>>2]?u:16|u,E=g?32|E:E,g=(u=D<<2)+e[f+452>>2]|0,y=u+e[f+472>>2]|0,(R[g>>2]!=R[y>>2]|R[g+4>>2]!=R[y+4>>2]|(R[g+8>>2]!=R[y+8>>2]|R[g+12>>2]!=R[y+12>>2])||(g=u+e[f+456>>2]|0,u=u+e[f+476>>2]|0,R[g>>2]!=R[u>>2]|R[g+4>>2]!=R[u+4>>2]|R[g+8>>2]!=R[u+8>>2])||R[g+12>>2]!=R[u+12>>2])&&(E|=64),O[0|S]=E,D=D+4|0,(0|F)!=(0|(d=d+1|0)););else for(;A=R[(E=d<<2)+e[f+448>>2]>>2],g=e[E+e[f+424>>2]>>2],u=A!=v(0)&(0|g)!=0,y=e[f+432>>2]+d|0,u=(0|u)==(1&O[0|y])?u:2|u,u=A!=R[E+e[f+468>>2]>>2]?4|u:u,u=e[E+e[f+440>>2]>>2]==e[E+e[f+464>>2]>>2]?u:8|u,E=e[E+e[f+436>>2]>>2]==e[E+e[f+460>>2]>>2]?u:16|u,O[0|y]=g?32|E:E,(0|F)!=(0|(d=d+1|0)););}else if(!((0|F)<1))for(;!e[(E=d<<2)+e[f+424>>2]>>2]|R[E+e[f+448>>2]>>2]==v(0)?(E=e[f+432>>2]+d|0,O[0|E]=254&H[0|E]):(E=e[f+432>>2]+d|0,O[0|E]=1|H[0|E]),(0|F)!=(0|(d=d+1|0)););}(a),e[a+644>>2]=0}function Yr(a,p,P,_,f,E){var u,d,g,y,A,S,D,F=0,k=0,V=0,X=0;if(K=S=K-32|0,1<=(0|p))for(A=j(p,12)+P|0;;){if(!((0|(F=e[P+4>>2]))<1))if(u=(p=e[P+8>>2])+j(F,48)|0,F=e[P>>2]<<2,1<=(0|(D=e[F+E>>2])))for(D<<=1,d=e[e[a>>2]+1052>>2],g=e[f+F>>2];;){r:if(F=e[p+8>>2]){t:{if((k=F+-1|0)>>>0<=1){if(F=(e[p+4>>2]<<2)+_|0,X=(e[F+(e[p+12>>2]<<2)>>2]<<2)+d|0,k-1)break t;for(V=(e[F+(e[p+16>>2]<<2)>>2]<<2)+d|0,F=0;R[(y=(k=F<<2)+g|0)>>2]=R[y>>2]+v(R[p+44>>2]*v(v(R[k+X>>2]*R[p+20>>2])+v(R[k+V>>2]*R[p+24>>2]))),(0|D)!=(0|(F=F+1|0)););break r}e[S>>2]=F,Ut(4,1024,S);break r}for(F=0;R[(V=(k=F<<2)+g|0)>>2]=R[V>>2]+v(R[p+44>>2]*v(R[k+X>>2]*R[p+20>>2])),(0|D)!=(0|(F=F+1|0)););}if(!((p=p+48|0)>>>0<u>>>0))break}else for(;3<=(F=e[p+8>>2])>>>0&&(e[16+S>>2]=F,Ut(4,1024,16+S|0)),(p=p+48|0)>>>0<u>>>0;);if(!((P=P+12|0)>>>0<A>>>0))break}K=32+S|0}function jr(a,p,P){var _;p|=0,P|=0,K=_=K+-64|0;r:{if(a|=0)if(p)if((p+15&-16)!=(0|p))e[52+_>>2]=1522,e[48+_>>2]=2361,Ut(4,1294,48+_|0);else{if(p=function(f,E,u){var d,g=0,y=0,A=0,S=0,D=0,F=0,k=0,V=0,X=0,q=0,tt=0,ut=0,mt=0,kt=v(0),Ht=0,ce=0,we=0,Ue=0,Ye=0;if(Ce(16+(K=d=K-576|0)|0,0,560),vi(f,16+d|0,12+d|0),(S=e[12+d>>2])>>>0<=u>>>0){if(g=(y=Ce(E,0,S))+e[16+d>>2]|0,e[g+8>>2]=y+e[20+d>>2],e[g+40>>2]=y+e[24+d>>2],e[g+44>>2]=y+e[28+d>>2],e[g+48>>2]=y+e[32+d>>2],e[g+52>>2]=y+e[36+d>>2],e[g+16>>2]=y+e[40+d>>2],e[g+24>>2]=y+e[44+d>>2],e[g+28>>2]=y+e[48+d>>2],e[g+32>>2]=y+e[52+d>>2],e[g+36>>2]=y+e[56+d>>2],E=e[f+704>>2],e[g+308>>2]=y+e[60+d>>2],e[g+312>>2]=y+e[64+d>>2],e[g+316>>2]=y+e[68+d>>2],e[g+320>>2]=y+e[72+d>>2],e[g+324>>2]=y+e[76+d>>2],e[g+328>>2]=y+e[80+d>>2],e[g+60>>2]=y+e[84+d>>2],e[g+144>>2]=y+e[88+d>>2],e[g+148>>2]=y+e[92+d>>2],u=y+e[96+d>>2]|0,e[g+152>>2]=u,!((0|(S=e[E+8>>2]))<1)&&(E=y+e[100+d>>2]|0,e[u>>2]=E,(0|S)!=1))for(u=1;E=(15+(e[e[f+796>>2]+(A<<2)>>2]<<3)&-16)+E|0,e[e[g+152>>2]+(u<<2)>>2]=E,(0|S)!=(0|(u=(A=u)+1|0)););if(e[g+156>>2]=y+e[104+d>>2],e[g+160>>2]=y+e[108+d>>2],e[g+68>>2]=y+e[112+d>>2],e[g+76>>2]=y+e[116+d>>2],e[g+80>>2]=y+e[120+d>>2],e[g+84>>2]=y+e[124+d>>2],e[g+88>>2]=y+e[128+d>>2],e[g+92>>2]=y+e[132+d>>2],e[g+96>>2]=y+e[136+d>>2],e[g+100>>2]=y+e[140+d>>2],e[g+104>>2]=y+e[144+d>>2],e[g+108>>2]=y+e[148+d>>2],e[g+112>>2]=y+e[152+d>>2],e[g+116>>2]=y+e[156+d>>2],e[g+120>>2]=y+e[160+d>>2],e[g+124>>2]=y+e[164+d>>2],e[g+128>>2]=y+e[168+d>>2],e[g+132>>2]=y+e[172+d>>2],e[g+136>>2]=y+e[176+d>>2],e[g+140>>2]=y+e[180+d>>2],e[g+168>>2]=y+e[184+d>>2],e[g+264>>2]=y+e[188+d>>2],e[g+268>>2]=y+e[192+d>>2],e[g+272>>2]=y+e[196+d>>2],e[g+276>>2]=y+e[200+d>>2],e[g+280>>2]=y+e[204+d>>2],e[g+284>>2]=y+e[208+d>>2],e[g+288>>2]=y+e[212+d>>2],e[g+292>>2]=y+e[216+d>>2],e[g+296>>2]=y+e[220+d>>2],e[g+300>>2]=y+e[224+d>>2],e[g+176>>2]=y+e[228+d>>2],e[g+184>>2]=y+e[232+d>>2],e[g+188>>2]=y+e[236+d>>2],e[g+192>>2]=y+e[240+d>>2],e[g+196>>2]=y+e[244+d>>2],e[g+200>>2]=y+e[248+d>>2],e[g+204>>2]=y+e[252+d>>2],e[g+208>>2]=y+e[256+d>>2],e[g+212>>2]=y+e[260+d>>2],e[g+216>>2]=y+e[264+d>>2],e[g+220>>2]=y+e[268+d>>2],e[g+224>>2]=y+e[272+d>>2],e[g+228>>2]=y+e[276+d>>2],e[g+232>>2]=y+e[280+d>>2],e[g+236>>2]=y+e[284+d>>2],e[g+240>>2]=y+e[288+d>>2],e[g+244>>2]=y+e[292+d>>2],e[g+248>>2]=y+e[296+d>>2],e[g+252>>2]=y+e[300+d>>2],e[g+256>>2]=y+e[304+d>>2],e[g+260>>2]=y+e[308+d>>2],E=e[f+704>>2],e[g+336>>2]=y+e[312+d>>2],e[g+424>>2]=y+e[316+d>>2],e[g+432>>2]=y+e[320+d>>2],e[g+436>>2]=y+e[324+d>>2],e[g+440>>2]=y+e[328+d>>2],u=y+e[332+d>>2]|0,e[g+444>>2]=u,!((0|(S=e[E+16>>2]))<1)&&(A=y+e[336+d>>2]|0,e[u>>2]=A,(u=1)!=(0|S)))for(E=0;A=(15+(e[e[f+892>>2]+(E<<2)>>2]<<3)&-16)+A|0,e[e[g+444>>2]+(u<<2)>>2]=A,(0|S)!=(0|(u=(E=u)+1|0)););if(e[g+448>>2]=y+e[340+d>>2],e[g+452>>2]=y+e[344+d>>2],e[g+456>>2]=y+e[348+d>>2],e[g+460>>2]=y+e[352+d>>2],e[g+464>>2]=y+e[356+d>>2],e[g+468>>2]=y+e[360+d>>2],e[g+472>>2]=y+e[364+d>>2],e[g+476>>2]=y+e[368+d>>2],e[g+344>>2]=y+e[372+d>>2],e[g+352>>2]=y+e[376+d>>2],e[g+356>>2]=y+e[380+d>>2],e[g+360>>2]=y+e[384+d>>2],e[g+364>>2]=y+e[388+d>>2],e[g+368>>2]=y+e[392+d>>2],e[g+372>>2]=y+e[396+d>>2],e[g+376>>2]=y+e[400+d>>2],e[g+380>>2]=y+e[404+d>>2],e[g+384>>2]=y+e[408+d>>2],e[g+388>>2]=y+e[412+d>>2],e[g+392>>2]=y+e[416+d>>2],e[g+396>>2]=y+e[420+d>>2],e[g+400>>2]=y+e[424+d>>2],e[g+404>>2]=y+e[428+d>>2],e[g+408>>2]=y+e[432+d>>2],e[g+412>>2]=y+e[436+d>>2],e[g+416>>2]=y+e[440+d>>2],e[g+420>>2]=y+e[444+d>>2],E=e[448+d>>2],u=e[452+d>>2],e[g+552>>2]=y+e[456+d>>2],e[g+548>>2]=u+y,e[g+544>>2]=E+y,e[g+560>>2]=y+e[460+d>>2],E=e[f+704>>2],k=y+e[464+d>>2]|0,e[g+568>>2]=k,1<=(0|(F=e[E+48>>2])))for(A=y+e[468+d>>2]|0,E=y+e[472+d>>2]|0,D=y+e[476+d>>2]|0,V=e[f+1072>>2],u=0;S=k+j(u,36)|0,e[S+20>>2]=D,e[S+16>>2]=E,e[S>>2]=A,A=((S=e[V+(u<<2)>>2])<<2)+A|0,D=(S=1<<S<<2)+D|0,E=E+S|0,(0|F)!=(0|(u=u+1|0)););if(E=e[f+704>>2],S=y+e[516+d>>2]|0,e[g+484>>2]=S,1<=(0|(E=e[E+72>>2])))for(A=y+e[520+d>>2]|0,D=e[f+1212>>2],u=0;e[12+(S+j(u,28)|0)>>2]=A,A=(e[D+(u<<2)>>2]<<4)+A|0,(0|E)!=(0|(u=u+1|0)););e[g+488>>2]=y+e[524+d>>2],e[g+492>>2]=y+e[528+d>>2],e[g+496>>2]=y+e[532+d>>2],e[g+504>>2]=y+e[536+d>>2],e[g+536>>2]=y+e[540+d>>2],e[g+512>>2]=y+e[544+d>>2],e[g+520>>2]=y+e[548+d>>2],e[g+524>>2]=y+e[552+d>>2],e[g+528>>2]=y+e[556+d>>2],e[g+532>>2]=y+e[560+d>>2];t:{if(4<=(F=H[f+4|0])>>>0){if(e[g+576>>2]=y+e[480+d>>2],e[g+584>>2]=y+e[484+d>>2],E=e[f+704>>2],u=e[492+d>>2],S=y+e[488+d>>2]|0,e[g+592>>2]=S,1<=(0|(E=e[E+104>>2])))for(A=u+y|0,D=e[f+1104>>2],u=0;e[40+(S+j(u,48)|0)>>2]=A,A=(e[D+(u<<2)>>2]<<2)+A|0,(0|E)!=(0|(u=u+1|0)););e[g+608>>2]=y+e[500+d>>2],e[g+624>>2]=y+e[508+d>>2]}else{if(E=e[572+d>>2],u=e[568+d>>2],e[g+636>>2]=y+e[564+d>>2],e[g+640>>2]=u+y,e[e[f+704>>2]+20>>2]<1)break t;for(S=E+y|0,k=0;;){e:{if((0|(A=e[(E=k<<2)+e[f+952>>2]>>2]))<=0)E=E+e[g+636>>2]|0;else{for(D=A+(u=e[E+e[f+948>>2]>>2])|0,V=e[f+1060>>2],A=0;A=e[V+(u<<2)>>2]+A|0,(0|(u=u+1|0))<(0|D););if(E=E+e[g+636>>2]|0,u=S,A)break e}u=A=0}if(e[E>>2]=u,S=(A<<2)+S|0,!((0|(k=k+1|0))<e[e[f+704>>2]+20>>2]))break}}F>>>0<5||(e[g+600>>2]=y+e[496+d>>2],e[g+616>>2]=y+e[504+d>>2],e[g+632>>2]=y+e[512+d>>2])}e[g+644>>2]=1,e[g>>2]=f,e[g+648>>2]=1&O[e[f+708>>2]+20|0],y=e[f+704>>2],k=e[y+20>>2];t:if(!((0|(e[g+540>>2]=k))<1)){if(E=k+-1|0,V=e[f+952>>2],X=e[f+940>>2],q=e[f+932>>2],tt=e[f+936>>2],ut=e[f+924>>2],mt=e[f+928>>2],Ht=e[g+552>>2],we=e[g+544>>2],F>>>0<4){for(;;)if(u=we+j(E,52)|0,A=(S=E<<2)+mt|(e[u>>2]=0),e[u+4>>2]=e[A>>2],e[u+8>>2]=e[(D=S+ut|0)>>2],R[u+12>>2]=R[D>>2]-R[A>>2],e[u+16>>2]=e[S+tt>>2],e[u+44>>2]=e[(A=S+q|0)>>2],kt=Kr(v(e[S+X>>2])),R[u+20>>2]=kt,R[u+24>>2]=kt*v(1.5),ce=e[S+V>>2],D=0,D=(e[u+32>>2]=ce)?e[g+560>>2]+j(e[S+e[f+948>>2]>>2],28)|0:D,e[u+48>>2]=1,e[u+28>>2]=D,e[S+Ht>>2]=e[A>>2],u=0<(0|E),E=E+-1|0,!u)break t}for(ce=e[f+960>>2],Ye=e[f+944>>2];u=we+j(E,52)|0,e[u>>2]=e[(A=E<<2)+Ye>>2],e[u+4>>2]=e[(S=A+mt|0)>>2],e[u+8>>2]=e[(D=A+ut|0)>>2],R[u+12>>2]=R[D>>2]-R[S>>2],e[u+16>>2]=e[A+tt>>2],e[u+44>>2]=e[(Ue=A+q|0)>>2],kt=Kr(v(e[A+X>>2])),R[u+20>>2]=kt,R[u+24>>2]=kt*v(1.5),D=e[A+V>>2],e[u+32>>2]=D,e[u+28>>2]=D?e[g+560>>2]+j(e[A+e[f+948>>2]>>2],28)|0:0,S=e[A+ce>>2],S=(e[u+40>>2]=S)?e[g+584>>2]+j(e[A+e[f+956>>2]>>2],28)|0:0,e[u+48>>2]=1,e[u+36>>2]=S,e[A+Ht>>2]=e[Ue>>2],u=0<(0|E),E=E+-1|0,u;);}if(4<=F>>>0?(e[g+548>>2]=e[f+944>>2],S=f):(Ce(e[g+548>>2],0,k<<2),S=e[g>>2],y=e[S+704>>2]),A=e[y+52>>2],1<=(0|(e[g+556>>2]=A)))for(u=e[S+1056>>2],D=e[S+1192>>2],k=e[S+1060>>2],F=e[g+560>>2];E=F+j(A=A+-1|0,28)|0,e[E>>2]=e[(V=A<<2)+k>>2],V=e[u+V>>2],e[E+24>>2]=1,e[E+16>>2]=0,e[E+20>>2]=1,e[E+8>>2]=0,e[E+12>>2]=0,e[E+4>>2]=D+(V<<2),0<(0|A););if(A=e[y+48>>2],1<=(0|(e[g+564>>2]=A))){for(;;){if(E=e[g+568>>2]+j(A=A+-1|0,36)|0,D=e[(y=A<<2)+e[S+1072>>2]>>2],1<=(0|(e[E+4>>2]=D)))for(u=0;e[e[E>>2]+(u<<2)>>2]=e[g+560>>2]+j(e[e[S+1064>>2]+(e[y+e[S+1068>>2]>>2]+u<<2)>>2],28),(0|D)!=(0|(u=u+1|0)););if(e[E+24>>2]=1,e[E+28>>2]=1,e[E+8>>2]=1<<D,!(0<(0|A)))break}S=e[g>>2],y=e[S+704>>2]}if(E=e[y>>2],(0|(e[g+4>>2]=E))<1)u=0;else{for(V=e[S+732>>2],X=e[S+736>>2],q=e[S+740>>2],D=e[S+720>>2],tt=e[g+52>>2],k=e[g+568>>2],ut=e[g+8>>2],A=E;F=ut+j(A=A+-1|0,12)|0,e[F>>2]=k+j(e[(u=A<<2)+D>>2],36),e[F+4>>2]=e[u+q>>2],e[F+8>>2]=e[u+X>>2],R[u+tt>>2]=e[u+V>>2]?v(1):v(0),0<(0|A););for(F=e[g+16>>2],u=0;A=e[8+(k+j(e[(V=(E=E+-1|0)<<2)+D>>2],36)|0)>>2],u=u+(e[F+V>>2]=A)|0,0<(0|E););E=e[g+4>>2]}if(e[g+12>>2]=E,e[g+20>>2]=u,E=e[y+4>>2],1<=(0|(e[g+304>>2]=E))){for(;u=e[g+308>>2]+((E=E+-1|0)<<5)|0,e[u>>2]=e[g+568>>2]+j(e[(A=E<<2)+e[S+752>>2]>>2],36),e[u+4>>2]=e[A+e[S+764>>2]>>2],e[u+8>>2]=e[A+e[S+768>>2]>>2],D=e[A+e[S+772>>2]>>2],e[u+12>>2]=D,y=e[A+e[S+776>>2]>>2],e[u+16>>2]=y,e[u+28>>2]=e[A+e[S+760>>2]>>2],D>>>0<=1?D-1?(e[20+(e[g+60>>2]+j(y,24)|0)>>2]=E,e[u+24>>2]=1,e[u+20>>2]=2):(e[8+(e[g+168>>2]+j(y,12)|0)>>2]=E,e[u+24>>2]=3,e[u+20>>2]=4):Ut(4,1179,0),0<(0|E););S=e[g>>2],y=e[S+704>>2]}A=e[y+8>>2];t:if(!((0|(e[g+56>>2]=A))<1)){if(u=A+-1|0,k=e[S+796>>2],F=e[S+804>>2],V=e[S+800>>2],X=e[S+780>>2],q=e[g+568>>2],tt=e[g+60>>2],H[S+4|0]<2){for(;;)if(E=tt+j(u,24)|0,e[E>>2]=q+j(e[(D=u<<2)+X>>2],36),e[E+4>>2]=e[D+V>>2],e[E+8>>2]=e[D+F>>2],D=e[D+k>>2],e[E+12>>2]=0,e[E+16>>2]=D,E=0<(0|u),u=u+-1|0,!E)break t}for(ut=e[S+808>>2];E=tt+j(u,24)|0,e[E>>2]=q+j(e[(D=u<<2)+X>>2],36),e[E+4>>2]=e[D+V>>2],e[E+8>>2]=e[D+F>>2],e[E+16>>2]=e[D+k>>2],e[E+12>>2]=e[D+ut>>2],E=0<(0|u),u=u+-1|0,E;);}if(u=e[y+12>>2],1<=(0|(e[g+164>>2]=u)))for(D=e[S+828>>2],k=e[S+812>>2],F=e[g+568>>2],V=e[g+168>>2],E=u;X=V+j(E=E+-1|0,12)|0,e[X>>2]=F+j(e[(q=E<<2)+k>>2],36),e[X+4>>2]=e[D+q>>2],0<(0|E););if(((E=0)|A)<1)D=0;else{for(k=e[g+68>>2],F=e[g+60>>2],D=0;u=e[e[F+j(A=A+-1|0,24)>>2]+8>>2],D=(e[k+(A<<2)>>2]=u)+D|0,0<(0|A););u=e[g+164>>2],A=e[g+56>>2]}if(e[g+64>>2]=A,e[g+72>>2]=D,A=g,1<=(0|u)){for(k=e[g+176>>2],F=e[g+168>>2];D=e[e[F+j(u=u+-1|0,12)>>2]+8>>2],E=E+(e[k+(u<<2)>>2]=D)|0,0<(0|u););u=e[g+164>>2]}if(e[A+172>>2]=u,e[g+180>>2]=E,D=e[y+16>>2],1<=(0|(e[g+332>>2]=D))){for(V=e[S+872>>2],X=e[S+892>>2],q=e[S+880>>2],tt=e[S+876>>2],k=e[S+852>>2],F=e[g+568>>2],ut=e[g+336>>2],E=D;u=ut+j(E=E+-1|0,20)|0,e[u>>2]=F+j(e[(A=E<<2)+k>>2],36),e[u+4>>2]=e[A+tt>>2],e[u+8>>2]=e[A+q>>2],e[u+16>>2]=e[A+X>>2],e[u+12>>2]=e[A+V>>2],0<(0|E););for(A=e[g+344>>2],u=0;E=e[8+(F+j(e[(V=(D=D+-1|0)<<2)+k>>2],36)|0)>>2],u=(e[A+V>>2]=E)+u|0,0<(0|D););if(e[g+348>>2]=u,D=e[g+332>>2],!((0|(e[g+340>>2]=D))<1))for(u=D<<2,A=e[g+456>>2],k=e[g+452>>2];e[(F=(E=u+-4|0)<<2)+k>>2]=1065353216,e[(V=(u<<=2)-4|0)+k>>2]=1065353216,e[(X=(u=u+-12|0)+k|0)>>2]=1065353216,e[X+4>>2]=1065353216,e[A+F>>2]=0,e[A+V>>2]=1065353216,e[(u=u+A|0)>>2]=0,e[u+4>>2]=0,u=E,0<(0|(D=D+-1|0)););}else e[g+340>>2]=D,e[g+348>>2]=0;if(D=e[y+72>>2],1<=(0|(e[g+480>>2]=D)))for(V=e[S+1208>>2],X=e[S+1224>>2],q=e[S+1220>>2],tt=e[S+1216>>2],ut=e[S+1212>>2],mt=e[g+484>>2],A=0;;){if(E=mt+j(A,28)|0,k=e[(u=A<<2)+ut>>2],e[E+4>>2]=k,e[E>>2]=e[u+tt>>2],F=e[u+q>>2],e[E+16>>2]=F,Ht=e[u+X>>2],e[E+20>>2]=Ht,e[E+8>>2]=0,e[E+24>>2]=1+(F-Ht|0),1<=(0|k))for(Ht=e[u+V>>2],we=e[E+12>>2],ce=e[S+1236>>2],Ye=e[S+1228>>2],Ue=e[S+1232>>2],u=0;e[4+(E=we+(u<<4)|0)>>2]=e[(F=u+Ht<<2)+Ue>>2],e[E>>2]=e[F+Ye>>2],F=e[F+ce>>2],e[E+12>>2]=0,e[E+8>>2]=F,(0|k)!=(0|(u=u+1|0)););if((0|D)==(0|(A=A+1|0)))break}if(u=e[y+80>>2],(0|(e[g+500>>2]=u))<1)A=0;else{for(F=e[S+1280>>2],V=e[S+1268>>2],X=e[S+1276>>2],q=e[S+1272>>2],tt=e[S+1264>>2],ut=e[S+1260>>2],D=e[S+1248>>2],k=e[g+568>>2],mt=e[g+504>>2];E=mt+j(u=u+-1|0,24)|0,e[E>>2]=k+j(e[(A=u<<2)+D>>2],36),e[E+4>>2]=e[A+ut>>2],e[E+8>>2]=e[A+tt>>2],e[E+12>>2]=e[A+q>>2],A=e[A+V>>2],e[E+20>>2]=F+(A<<1),e[E+16>>2]=X+(A<<2),0<(0|u););if((0|(u=e[g+500>>2]))<1)A=0;else{for(F=e[g+512>>2],A=0;E=e[8+(k+j(e[(V=(u=u+-1|0)<<2)+D>>2],36)|0)>>2],A=(e[F+V>>2]=E)+A|0,0<(0|u););u=e[g+500>>2]}}e[g+508>>2]=u,e[g+516>>2]=A;t:if(4<=H[f+4|0]){if(!((D=H[S+4|0])>>>0<4)){if(u=e[y+120>>2],1<=(0|(e[g+572>>2]=u))){for(F=e[S+1172>>2],V=e[g+576>>2];D=(0|(y=e[(E=(u=u+-1|0)<<2)+F>>2]))<0?y=k=A=0:(A=(D=e[E+e[S+1176>>2]>>2]<<2)+e[S+1188>>2]|0,k=e[E+e[S+1180>>2]>>2],y=e[g+544>>2]+j(y,52)|0,D+e[S+1184>>2]|0),E=V+j(u,20)|0,e[E+12>>2]=k,e[E+8>>2]=A,e[E+4>>2]=D,e[E>>2]=y,0<(0|u););if(S=e[g>>2],(D=H[S+4|0])>>>0<4)break t}if(y=e[S+704>>2],A=e[y+100>>2],1<=(0|(e[g+580>>2]=A)))for(k=e[S+1084>>2],F=e[S+1076>>2],V=e[S+1192>>2],X=e[S+1080>>2],q=e[g+584>>2];E=q+j(A=A+-1|0,28)|0,e[E>>2]=e[(u=A<<2)+X>>2],e[E+4>>2]=V+(e[u+F>>2]<<2),u=e[u+k>>2],e[E+20>>2]=1,e[E+24>>2]=1,e[E+12>>2]=0,e[E+16>>2]=0,e[E+8>>2]=u,0<(0|A););if(A=e[y+104>>2],1<=(0|(e[g+588>>2]=A))){for(;;){if(E=e[g+592>>2]+j(A=A+-1|0,48)|0,e[E>>2]=e[g+584>>2]+j(e[(D=A<<2)+e[S+1088>>2]>>2],28),u=e[D+e[S+1092>>2]>>2],e[E+28>>2]=1,e[E+32>>2]=1,e[E+8>>2]=0,e[E+4>>2]=u,y=e[D+e[S+1104>>2]>>2],1<=(0|(e[E+36>>2]=y)))for(u=0;e[e[E+40>>2]+(u<<2)>>2]=e[g+576>>2]+j(e[e[S+1168>>2]+(e[D+e[S+1100>>2]>>2]+u<<2)>>2],20),(0|y)!=(0|(u=u+1|0)););if(!(1<=(0|A)))break}S=e[g>>2],D=H[S+4|0]}if(!(D>>>0<4)){if(D=e[f+704>>2],u=e[D+108>>2],1<=(0|(e[g+604>>2]=u)))for(y=e[f+1124>>2],k=e[f+1128>>2],F=e[f+1120>>2],V=e[g+592>>2],X=e[g+608>>2];E=X+j(u=u+-1|0,12)|0,e[E>>2]=e[(A=u<<2)+F>>2],e[E+4>>2]=e[A+k>>2],e[E+8>>2]=V+j(e[y+A>>2],48),0<(0|u););if(u=e[D+112>>2],1<=(0|(e[g+620>>2]=u)))for(D=e[f+1148>>2],y=e[f+1152>>2],k=e[f+1144>>2],F=e[g+592>>2],V=e[g+624>>2];E=V+j(u=u+-1|0,12)|0,e[E>>2]=e[(A=u<<2)+k>>2],e[E+4>>2]=e[y+A>>2],e[E+8>>2]=F+j(e[A+D>>2],48),0<(0|u););if(A=e[S+1192>>2],E=e[e[S+704>>2]+20>>2],e[g+640>>2]=e[S+972>>2],D=e[S+964>>2],e[g+636>>2]=D,!((0|E)<(u=1))&&(e[D>>2]=A+(e[e[S+968>>2]>>2]<<2),(0|E)!=1))for(;e[(D=u<<2)+e[g+636>>2]>>2]=A+(e[D+e[S+968>>2]>>2]<<2),(0|E)!=(0|(u=u+1|0)););}}}else if(!(e[y+20>>2]<1))for(y=0;;){if(A=e[(k=y<<2)+e[g+636>>2]>>2],1<=((E=0)|(u=e[k+e[S+952>>2]>>2])))for(X=u+(F=e[k+e[S+948>>2]>>2])|0,q=e[S+1060>>2],tt=e[S+1056>>2];;){if(1<=(0|(V=e[(u=F<<2)+q>>2])))for(ut=V+(D=e[u+tt>>2])|0,mt=e[S+1192>>2];;){V=A+(E<<2)|0,kt=R[mt+(D<<2)>>2],u=A;e:{if(0<(0|E))for(;;){if(R[u>>2]==kt)break e;if(!((u=u+4|0)>>>0<V>>>0))break}R[V>>2]=kt,E=E+1|0}if(!((0|(D=D+1|0))<(0|ut)))break}if(!((0|(F=F+1|0))<(0|X)))break}if(function(pe,tr){var Ot,fe,Te=0,Be=0,Ne=0;e[8+(K=Ot=K-208|0)>>2]=1,e[12+Ot>>2]=0;e:if(fe=tr<<2){for(e[16+Ot>>2]=4,Ne=tr=e[20+Ot>>2]=4,Te=2;tr=(Ne+4|0)+(Be=tr)|0,e[(16+Ot|0)+(Te<<2)>>2]=tr,Te=Te+1|0,Ne=Be,tr>>>0<fe>>>0;);if((Be=(pe+fe|0)-4|0)>>>0<=pe>>>0)tr=Te=1;else for(tr=Te=1;tr=(3&Te)==3?(kr(pe,tr,16+Ot|0),Le(8+Ot|0,2),tr+2|0):(rt[(16+Ot|0)+((Ne=tr+-1|0)<<2)>>2]>=Be-pe>>>0?qe(pe,8+Ot|0,tr,0,16+Ot|0):kr(pe,tr,16+Ot|0),(0|tr)==1?(lr(8+Ot|0,1),0):(lr(8+Ot|0,Ne),1)),Te=1|e[8+Ot>>2],e[8+Ot>>2]=Te,(pe=pe+4|0)>>>0<Be>>>0;);for(qe(pe,8+Ot|0,tr,0,16+Ot|0);;){i:{s:{o:{if(!((0|tr)!=1|(0|Te)!=1)){if(e[12+Ot>>2])break o;break e}if(1<(0|tr))break s}Le(8+Ot|0,Be=Co(8+Ot|0)),Te=e[8+Ot>>2],tr=tr+Be|0;break i}lr(8+Ot|0,2),e[8+Ot>>2]=7^e[8+Ot>>2],Le(8+Ot|0,1),qe((Ne=pe+-4|0)-e[(16+Ot|0)+((Be=tr+-2|0)<<2)>>2]|0,8+Ot|0,tr+-1|0,1,16+Ot|0),lr(8+Ot|0,1),Te=1|e[8+Ot>>2],e[8+Ot>>2]=Te,qe(Ne,8+Ot|0,Be,1,16+Ot|0),tr=Be}pe=pe+-4|0}}K=208+Ot|0}(A,E),e[k+e[g+640>>2]>>2]=E,!((0|(y=y+1|0))<e[e[S+704>>2]+20>>2]))break}if(!(H[f+4|0]<5|H[e[g>>2]+4|0]<4)){if(E=e[f+704>>2],u=e[E+128>>2],1<=(0|(e[g+596>>2]=u)))for(D=e[f+1112>>2],y=e[f+1116>>2],k=e[f+1108>>2],F=e[g+592>>2],V=e[g+600>>2];S=V+j(u=u+-1|0,12)|0,e[S>>2]=e[(A=u<<2)+k>>2],e[S+4>>2]=e[y+A>>2],e[S+8>>2]=F+j(e[A+D>>2],48),0<(0|u););if(u=e[E+132>>2],1<=(0|(e[g+612>>2]=u)))for(D=e[f+1136>>2],y=e[f+1140>>2],k=e[f+1132>>2],F=e[g+592>>2],V=e[g+616>>2];S=V+j(u=u+-1|0,12)|0,e[S>>2]=e[(A=u<<2)+k>>2],e[S+4>>2]=e[y+A>>2],e[S+8>>2]=F+j(e[A+D>>2],48),0<(0|u););if(u=e[E+136>>2],!((0|(e[g+628>>2]=u))<1))for(S=e[f+1160>>2],A=e[f+1164>>2],D=e[f+1156>>2],y=e[g+592>>2],k=e[g+632>>2];f=k+j(u=u+-1|0,12)|0,e[f>>2]=e[(E=u<<2)+D>>2],e[f+4>>2]=e[E+A>>2],e[f+8>>2]=y+j(e[E+S>>2],48),0<(0|u););}hi(g)}return K=576+d|0,g}(a,p,P))break r;e[36+_>>2]=2209,e[32+_>>2]=2361,Ut(4,1294,32+_|0)}else e[20+_>>2]=1444,e[16+_>>2]=2361,Ut(4,1294,16+_|0);else e[4+_>>2]=2132,e[_>>2]=2361,Ut(4,1294,_);p=0}return K=64+_|0,0|p}function cr(a){var p;return K=p=K-16|0,a=(a|=0)?function(P){var _;return Ce(16+(K=_=K-576|0)|0,0,560),vi(P,16+_|0,12+_|0),K=576+_|0,e[12+_>>2]}(a):(e[4+p>>2]=2132,e[p>>2]=2343,Ut(4,1294,p),0),K=16+p|0,0|a}function es(a){var p=H[a+4|0];vt(e[a+704>>2],4,64),Ee(e[a+708>>2],4),Ee(e[a+708>>2]+4|0,4),Ee(e[a+708>>2]+8|0,4),Ee(e[a+708>>2]+12|0,4),Ee(e[a+708>>2]+16|0,4),Ee(e[a+708>>2]+20|0,1),vt(e[a+720>>2],4,e[e[a+704>>2]>>2]),vt(e[a+724>>2],4,e[e[a+704>>2]>>2]),vt(e[a+728>>2],4,e[e[a+704>>2]>>2]),vt(e[a+732>>2],4,e[e[a+704>>2]>>2]),vt(e[a+736>>2],4,e[e[a+704>>2]>>2]),vt(e[a+740>>2],4,e[e[a+704>>2]>>2]),vt(e[a+752>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+756>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+760>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+764>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+768>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+772>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+776>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+780>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+784>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+788>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+796>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+800>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+804>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+812>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+816>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+820>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+828>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+852>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+856>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+860>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+868>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+872>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+876>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+880>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+884>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+888>>2],1,e[e[a+704>>2]+16>>2]),vt(e[a+892>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+896>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+900>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+904>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+908>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+912>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+924>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+928>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+932>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+936>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+940>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+948>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+952>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+976>>2],4,e[e[a+704>>2]+24>>2]),vt(e[a+980>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+984>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+996>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1e3>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1004>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1008>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1012>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1016>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1020>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1032>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1036>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1040>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1052>>2],4,e[e[a+704>>2]+40>>2]),vt(e[a+1064>>2],4,e[e[a+704>>2]+44>>2]),vt(e[a+1068>>2],4,e[e[a+704>>2]+48>>2]),vt(e[a+1072>>2],4,e[e[a+704>>2]+48>>2]),vt(e[a+1056>>2],4,e[e[a+704>>2]+52>>2]),vt(e[a+1060>>2],4,e[e[a+704>>2]+52>>2]),vt(e[a+1192>>2],4,e[e[a+704>>2]+56>>2]),vt(e[a+1196>>2],4,e[e[a+704>>2]+60>>2]),vt(e[a+1200>>2],2,e[e[a+704>>2]+64>>2]),vt(e[a+1204>>2],4,e[e[a+704>>2]+68>>2]),vt(e[a+1208>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1212>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1216>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1220>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1224>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1228>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1232>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1236>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1248>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1252>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1256>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1260>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1264>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1268>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1272>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1276>>2],4,e[e[a+704>>2]+84>>2]),vt(e[a+1280>>2],2,e[e[a+704>>2]+84>>2]),vt(e[a+1284>>2],4,e[e[a+704>>2]+88>>2]),p>>>0<2||(vt(e[a+808>>2],4,e[e[a+704>>2]+8>>2]),p>>>0<4)||(vt(e[a+968>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+972>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+792>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+824>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+864>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+1288>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1292>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1296>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1300>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+1304>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+1308>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+944>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+956>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+960>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+1076>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1080>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1084>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1088>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1092>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1096>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1100>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1104>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1120>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1124>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1128>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1144>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1148>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1152>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1168>>2],4,e[e[a+704>>2]+116>>2]),vt(e[a+1172>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1176>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1180>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1184>>2],4,e[e[a+704>>2]+124>>2]),vt(e[a+1188>>2],4,e[e[a+704>>2]+124>>2]),(0|p)!=4&&(vt(e[a+988>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+992>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+1024>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1028>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1044>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1048>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1108>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1112>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1116>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1132>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1136>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1140>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1156>>2],4,e[e[a+704>>2]+136>>2]),vt(e[a+1160>>2],4,e[e[a+704>>2]+136>>2]),vt(e[a+1164>>2],4,e[e[a+704>>2]+136>>2])))}function rs(a,p){var P=0,_=0,f=0,E=0,u=0,d=0,g=a+p|0;r:{t:if(!(1&(P=e[a+4>>2]))){if(!(3&P))break r;if(p=(P=e[a>>2])+p|0,(0|(a=a-P|0))!=e[2092])if(P>>>0<=255)f=P>>>3,P=e[a+8>>2],(0|(_=e[a+12>>2]))==(0|P)?(d=e[2087]&Br(f),e[2087]=d):(e[P+12>>2]=_,e[_+8>>2]=P);else{if(u=e[a+24>>2],(0|(P=e[a+12>>2]))!=(0|a))_=e[a+8>>2],e[_+12>>2]=P,e[P+8>>2]=_;else if(f=(f=e[(_=a+20|0)>>2])||e[(_=a+16|0)>>2]){for(;E=_,(f=e[(_=(P=f)+20|0)>>2])||(_=P+16|0,f=e[P+16>>2]););e[E>>2]=0}else P=0;if(u){_=e[a+28>>2];e:{if(e[(f=8652+(_<<2)|0)>>2]==(0|a)){if(e[f>>2]=P)break e;d=e[2088]&Br(_),e[2088]=d;break t}if(!(e[u+(e[u+16>>2]==(0|a)?16:20)>>2]=P))break t}e[P+24>>2]=u,(_=e[a+16>>2])&&(e[P+16>>2]=_,e[_+24>>2]=P),(_=e[a+20>>2])&&(e[P+20>>2]=_,e[_+24>>2]=P)}}else if((3&(P=e[4+g>>2]))==3)return e[2089]=p,e[4+g>>2]=-2&P,e[a+4>>2]=1|p,e[g>>2]=p}t:{if(!(2&(P=e[4+g>>2]))){if(e[2093]==(0|g)){if(e[2093]=a,p=e[2090]+p|0,e[2090]=p,e[a+4>>2]=1|p,e[2092]!=(0|a))break r;return e[2089]=0,e[2092]=0}if(e[2092]==(0|g))return e[2092]=a,p=e[2089]+p|0,e[2089]=p,e[a+4>>2]=1|p,e[a+p>>2]=p;p=(-8&P)+p|0;e:if(P>>>0<=255)f=P>>>3,P=e[8+g>>2],(0|(_=e[12+g>>2]))==(0|P)?(d=e[2087]&Br(f),e[2087]=d):(e[P+12>>2]=_,e[_+8>>2]=P);else{if(u=e[24+g>>2],(0|g)!=(0|(P=e[12+g>>2])))_=e[8+g>>2],e[_+12>>2]=P,e[P+8>>2]=_;else if(f=(f=e[(_=20+g|0)>>2])||e[(_=16+g|0)>>2]){for(;E=_,(f=e[(_=(P=f)+20|0)>>2])||(_=P+16|0,f=e[P+16>>2]););e[E>>2]=0}else P=0;if(u){_=e[28+g>>2];i:{if(e[(f=8652+(_<<2)|0)>>2]==(0|g)){if(e[f>>2]=P)break i;d=e[2088]&Br(_),e[2088]=d;break e}if(!(e[u+(e[u+16>>2]==(0|g)?16:20)>>2]=P))break e}e[P+24>>2]=u,(_=e[16+g>>2])&&(e[P+16>>2]=_,e[_+24>>2]=P),(_=e[20+g>>2])&&(e[P+20>>2]=_,e[_+24>>2]=P)}}if(e[a+4>>2]=1|p,e[a+p>>2]=p,e[2092]!=(0|a))break t;return e[2089]=p}e[4+g>>2]=-2&P,e[a+4>>2]=1|p,e[a+p>>2]=p}if(p>>>0<=255)return p=8388+((P=p>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[p+8>>2]:(e[2087]=P|_,p),e[p+8>>2]=a,e[P+12>>2]=a,e[a+12>>2]=p,e[a+8>>2]=P;e[a+16>>2]=0,P=e[a+20>>2]=0,(f=p>>>8)&&(P=31,16777215<p>>>0||(P=28+((P=((g=(f<<=E=f+1048320>>>16&8)<<(P=f+520192>>>16&4))<<(f=245760+g>>>16&2)>>>15)-(f|P|E)|0)<<1|p>>>P+21&1)|0)),f=8652+((e[(_=a)+28>>2]=P)<<2)|0;t:{if((_=e[2088])&(E=1<<P)){for(_=p<<((0|P)==31?0:25-(P>>>1)|0),P=e[f>>2];;){if((-8&e[(f=P)+4>>2])==(0|p))break t;if(P=_>>>29,_<<=1,!(P=e[16+(E=f+(4&P)|0)>>2]))break}e[E+16>>2]=a}else e[2088]=_|E,e[f>>2]=a;return e[a+24>>2]=f,e[a+12>>2]=a,e[a+8>>2]=a}p=e[f+8>>2],e[p+12>>2]=a,e[f+8>>2]=a,e[a+24>>2]=0,e[a+12>>2]=f,e[a+8>>2]=p}}function Kr(a){var p,P,_,f,E,u,d,g,y=v(0),A=(v(0),0),S=0,D=(v(0),v(0),v(0),v(0),0);v(0),v(0);r:{t:{if(Qt(a),S=2147483647&(A=Wt[0])){if(!(S>>>0<2139095041))return v(v(.10000000149011612)+a);if((0|S)==1065353216)return v(-1<(0|A)?.10000000149011612:10);if((0|S)==2139095040)return v(-1<(0|A)?0:-a);if((0|A)==1073741824)return v(.010000000707805157);if((0|A)==1056964608)return v(.3162277638912201);if(1291845633<=S>>>0)return v((0|A)<0?Nt:0);if(p=R[1701],g=v(v(1.600000023841858)-p),P=v(v(1)/v(p+v(1.600000023841858))),Yt(0,-4096&(Qt(d=v(g*P)),Wt[0])),y=Xt(),_=v(y*y),E=R[1705],p=v(P*v(v(g-v((f=y)*v(3.099609375)))-v(y*v(v(1.600000023841858)-v(v(3.099609375)-p))))),P=v(v(d+y)*p),y=v(d*d),g=v(P+v(v(y*y)*v(v(y*v(v(y*v(v(y*v(v(y*v(v(y*v(.20697501301765442))+v(.23066075146198273)))+v(.2727281153202057)))+v(.3333333432674408)))+v(.4285714328289032)))+v(.6000000238418579)))),Yt(0,-4096&(Qt(v(v(_+v(3))+g)),Wt[0])),y=Xt(),P=v(f*y),d=v(v(p*y)+v(d*v(g-v(v(y+v(-3))-_)))),Yt(0,-4096&(Qt(v(P+d)),Wt[0])),y=Xt(),p=v(y*v(.9619140625)),_=v(R[1703]+v(v(v(d-v(y-P))*v(.9617967009544373))+v(y*v(-.00011736857413779944)))),Yt(0,-4096&(Qt(v(v(E+v(p+_))+v(-4))),Wt[0])),d=Xt(),Yt(0,-4096&A),g=Xt(),y=v(d*g),a=v(v(v(_-v(v(v(d-v(-4))-E)-p))*a)+v(v(a-g)*d)),Qt(d=v(y+a)),1124073473<=(0|(A=Wt[0])))break t;e:{if((S=1124073472)==(0|A)){if(v(a+v(4299566569443414e-23))>v(d-y))break t}else{if(S=2147483647&A,!(a<=v(d-y)^1|(0|A)!=-1021968384)|1125515265<=S>>>0)break r;if(S>>>0<1056964609)break e}D=(8388607&(S=(8388608>>>(S>>>23)-126)+A|0)|8388608)>>>150-(u=S>>>23&255),D=(0|A)<0?0-D|0:D,y=v(y-(Yt(0,S&-8388608>>u-127),Xt())),Qt(v(a+y)),A=Wt[0]}Yt(0,-32768&A),d=Xt(),p=v(d*v(.693145751953125)),d=v(v(d*v(14286065379565116e-22))+v(v(a-v(d-y))*v(.6931471824645996))),a=v(p+d),y=v(a*a),y=v(a-v(y*v(v(y*v(v(y*v(v(y*v(v(y*v(4138136944220605e-23))+v(-16533901998627698e-22)))+v(661375597701408e-19)))+v(-.0027777778450399637)))+v(.1666666716337204)))),f=v(v(a*y)/v(y+v(-2))),y=v(d-v(a-p)),a=(0|(A=0|(Qt(a=v(v(a-v(f-v(y+v(a*y))))+v(1))),Wt[0]+(D<<23))))<=8388607?function(F,k){var V=0;return 128<=(0|k)?(F=v(F*v(17014118346046923e22)),k=(0|(V=k+-127|0))<128?V:(F=v(F*v(17014118346046923e22)),((0|k)<381?k:381)+-254|0)):-127<(0|k)||(F=v(F*v(11754943508222875e-54)),k=-127<(0|(V=k+126|0))?V:(F=v(F*v(11754943508222875e-54)),(-378<(0|k)?k:-378)+252|0)),v(F*(Yt(0,1065353216+(k<<23)|0),Xt()))}(a,D):(Yt(0,A),Xt()),a=v(v(1)*a)}else a=v(1);return a}return v(Nt)}return v(0)}function ki(a,p){var P,_,f,E=0,u=0,d=v(0);if(Qt(p),!((f=2147483647&(_=Wt[0]))>>>0<=2139095040&&(Qt(a),(E=2147483647&(u=Wt[0]))>>>0<2139095041)))return v(a+p);if((0|_)==1065353216)return li(a);_=(P=_>>>30&2)|u>>>31;r:{t:{e:{i:{if(!E){switch(_-2|0){case 0:break i;case 1:break;default:break e}return v(-3.1415927410125732)}if((0|f)!=2139095040){if(!f|!(E>>>0<=218103808+f>>>0&&(0|E)!=2139095040))break r;if(a=d=E+218103808>>>0<f>>>0&&(d=v(0),P)?d:li(v(St(v(a/p)))),_>>>0<=2){switch(_-1|0){case 0:return v(-a);case 1:break;default:break e}return v(v(3.1415927410125732)-v(a+v(8742277657347586e-23)))}return v(v(a+v(8742277657347586e-23))+v(-3.1415927410125732))}if((0|E)==2139095040)break t;return R[6784+(_<<2)>>2]}a=v(3.1415927410125732)}return a}return R[6768+(_<<2)>>2]}return v((0|u)<0?-1.5707963705062866:1.5707963705062866)}function li(a){v(0);var p,P,_,f,E,u=0;v(0),v(0),Qt(a);r:{if(1283457024<=(f=2147483647&(E=Wt[0]))>>>0){if(2139095040<f>>>0)break r;return v((0|E)<0?-1.570796251296997:1.570796251296997)}t:{if(f>>>0<=1054867455){if(u=-1,964689920<=f>>>0)break t;break r}a=v(St(a)),u=f>>>0<=1066926079?f>>>0<=1060110335?(a=v(v(v(a+a)+v(-1))/v(a+v(2))),0):(a=v(v(a+v(-1))/v(a+v(1))),1):f>>>0<=1075576831?(a=v(v(a+v(-1.5))/v(v(a*v(1.5))+v(1))),2):(a=v(v(-1)/a),3)}if(f=u,P=v(a*a),p=v(P*P),_=v(p*v(v(p*v(-.106480173766613))+v(-.19999158382415771))),p=v(P*v(v(p*v(v(p*v(.06168760731816292))+v(.14253635704517365)))+v(.333333283662796))),(0|f)<=-1)return v(a-v(a*v(_+p)));a=v(R[6736+(f<<=2)>>2]-v(v(v(a*v(_+p))-R[6752+f>>2])-a)),a=(0|E)<0?v(-a):a}return a}function Qe(a,p){var P,_,f,E=0,u=0;return K=_=K-16|0,Qt(a),(E=2147483647&(f=Wt[0]))>>>0<=1305022426?(ct[p>>3]=(P=+a)+-1.5707963109016418*(u=.6366197723675814*P+6755399441055744-6755399441055744)+-15893254773528196e-24*u,E=St(u)<2147483648?~~u:-2147483648):2139095040<=E>>>0?(ct[p>>3]=v(a-a),E=0):(P=E,ct[8+_>>3]=(Yt(0,P-((E=(E>>>23)-150|0)<<23)|0),Xt()),E=function(d,g,y){var A,S,D,F,k,V,X=0,q=0,tt=0,ut=0,mt=0,kt=0,Ht=0,ce=0,we=0,Ue=0,Ye=0;if(K=A=K-560|0,Ht=(q=y)+j(D=0<(0|(y=(y+-3|0)/24|0))?y:0,-24)|0,0<=(0|(S=e[972])))for(q=S+1|0,y=D;ct[(320+A|0)+(tt<<3)>>3]=(0|y)<0?0:+e[3904+(y<<2)>>2],y=y+1|0,(0|q)!=(0|(tt=tt+1|0)););for(mt=Ht+-24|0,q=0;;){for(X=y=0;X+=ct[(y<<3)+d>>3]*ct[(320+A|0)+(q-y<<3)>>3],(0|(y=y+1|0))!=1;);if(ct[(q<<3)+A>>3]=X,y=(0|q)<(0|S),q=q+1|0,!y)break}V=23-mt|0,F=24-mt|0,q=S;r:{for(;;){if(X=ct[(q<<3)+A>>3],!(we=((y=0)|(tt=q))<1))for(;kt=(480+A|0)+(y<<2)|0,ce=X,ut=St(X*=5960464477539063e-23)<2147483648?~~X:-2147483648,ut=St(ce+=-16777216*(X=0|ut))<2147483648?~~ce:-2147483648,e[kt>>2]=ut,X=ct[((tt=tt+-1|0)<<3)+A>>3]+X,(0|q)!=(0|(y=y+1|0)););X=ke(X,mt),X=(X+=-8*Ft(.125*X))-(0|(kt=St(X)<2147483648?~~X:-2147483648));t:{e:{i:{if(Ye=(0|mt)<1){if(mt)break i;ut=e[476+((q<<2)+A|0)>>2]>>23}else ut=e[476+(tt=(q<<2)+A|0)>>2],Ue=tt,tt=ut-((y=ut>>F)<<F)|0,kt=y+kt|0,ut=(e[Ue+476>>2]=tt)>>V;if((0|ut)<1)break t;break e}if(ut=2,!(.5<=X)){ut=0;break t}}if(tt=y=0,!we)for(;;){we=e[(k=(480+A|0)+(y<<2)|0)>>2],Ue=16777215;e:{i:{if(!tt){if(!we)break i;Ue=16777216,tt=1}e[k>>2]=Ue-we;break e}tt=0}if((0|q)==(0|(y=y+1|0)))break}Ye||1<(y=mt+-1|0)>>>0||(e[476+(y=(q<<2)+A|0)>>2]=y-1?8388607&e[y+476>>2]:4194303&e[y+476>>2]),kt=kt+1|0,(0|ut)==2&&(X=1-X,ut=2,tt)&&(X-=ke(1,mt))}if(X!=0)break;if(!(((tt=0)|(y=q))<=(0|S))){for(;tt=e[(480+A|0)+((y=y+-1|0)<<2)>>2]|tt,(0|S)<(0|y););if(tt){for(Ht=mt;Ht=Ht+-24|0,!e[(480+A|0)+((q=q+-1|0)<<2)>>2];);break r}}for(y=1;y=(tt=y)+1|0,!e[(480+A|0)+(S-tt<<2)>>2];);for(tt=q+tt|0;;){for(q=kt=q+1|0,ct[(320+A|0)+(kt<<3)>>3]=e[3904+(D+q<<2)>>2],X=y=0;X+=ct[(y<<3)+d>>3]*ct[(320+A|0)+(kt-y<<3)>>3],(0|(y=y+1|0))!=1;);if(ct[(q<<3)+A>>3]=X,!((0|q)<(0|tt)))break}q=tt}16777216<=(X=ke(X,0-mt|0))?(d=(480+A|0)+(q<<2)|0,ce=X,y=St(X*=5960464477539063e-23)<2147483648?~~X:-2147483648,tt=St(X=ce+-16777216*(0|y))<2147483648?~~X:-2147483648,e[d>>2]=tt,q=q+1|0):(y=St(X)<2147483648?~~X:-2147483648,Ht=mt),e[(480+A|0)+(q<<2)>>2]=y}if(X=ke(1,Ht),!((0|q)<=-1)){for(y=q;ct[(y<<3)+A>>3]=X*+e[(480+A|0)+(y<<2)>>2],X*=5960464477539063e-23,d=0<(0|y),y=y+-1|0,d;);if(!((0|q)<=-1))for(y=q;;){for(mt=q-(d=y)|0,y=X=0;X+=ct[6672+(y<<3)>>3]*ct[(d+y<<3)+A>>3],!((0|S)<=(0|y))&&(Ht=y>>>0<mt>>>0,y=y+1|0,Ht););if(ct[(160+A|0)+(mt<<3)>>3]=X,y=d+-1|0,!(0<(0|d)))break}}if(0<=(q|(X=0)))for(;X+=ct[(160+A|0)+(q<<3)>>3],d=0<(0|q),q=q+-1|0,d;);return ct[g>>3]=ut?-X:X,K=560+A|0,7&kt}(8+_|0,_,E),u=ct[_>>3],(0|f)<=-1?(ct[p>>3]=-u,E=0-E|0):ct[p>>3]=u),K=16+_|0,E}function vo(a,p){return a?function(P,_){r:{if(P){if(_>>>0<=127)break r;if(e[e[1789]>>2]){if(_>>>0<=2047)return O[P+1|0]=63&_|128,O[0|P]=_>>>6|192,2;if(!((-8192&_)!=57344&&55296<=_>>>0))return O[P+2|0]=63&_|128,O[0|P]=_>>>12|224,O[P+1|0]=_>>>6&63|128,3;if(_+-65536>>>0<=1048575)return O[P+3|0]=63&_|128,O[0|P]=_>>>18|240,O[P+2|0]=_>>>6&63|128,O[P+1|0]=_>>>12&63|128,4}else if((-128&_)==57216)break r;e[2086]=25,P=-1}else P=1;return P}return O[0|P]=_,1}(a,p):0}function vi(a,p,P){var _,f,E=0,u=0,d=0,g=0,y=0,A=0,S=0,D=0,F=0,k=H[a+4|0];if(e[p>>2]=652,u=e[a+704>>2],1<=(0|(g=e[u>>2]))){for(y=e[a+720>>2],S=e[a+1072>>2];d=(1<<e[S+(e[y+(E<<2)>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+4>>2]=j(g,12),e[p+8>>2]=e[u>>2]<<2,e[p+12>>2]=e[u>>2]<<2,e[p+16>>2]=e[u>>2]<<2,e[p+20>>2]=e[u>>2]<<2,d=e[u>>2],e[p+28>>2]=E,e[p+24>>2]=d<<2,d=e[u>>2],e[p+40>>2]=E,e[p+36>>2]=E,e[p+32>>2]=d<<2,e[p+44>>2]=e[u+4>>2]<<5,e[p+48>>2]=e[u+4>>2]<<2,e[p+52>>2]=e[u+4>>2]<<2,e[p+56>>2]=e[u+4>>2]<<2,e[p+60>>2]=e[u+4>>2]<<4,e[p+64>>2]=e[u+4>>2]<<4,1<=((E=0)|(g=e[u+8>>2]))){for(y=e[a+780>>2],S=e[a+1072>>2],F=e[a+796>>2],d=0;A=(15+(e[(D=E<<2)+F>>2]<<3)&-16)+A|0,d=(1<<e[S+(e[y+D>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+68>>2]=j(g,24),e[p+72>>2]=e[u+8>>2]<<2,e[p+76>>2]=e[u+8>>2]<<2,d=e[u+8>>2],e[p+84>>2]=A,e[p+80>>2]=d<<2,e[p+88>>2]=e[u+8>>2]<<4,e[p+92>>2]=e[u+8>>2]<<4,d=e[u+8>>2],e[p+100>>2]=E,e[p+96>>2]=d<<2,d=e[u+8>>2],e[p+140>>2]=E,e[p+136>>2]=E,e[p+132>>2]=E,e[p+128>>2]=E,e[p+124>>2]=E,e[p+120>>2]=E,e[p+116>>2]=E,e[p+112>>2]=E,e[p+108>>2]=E,e[p+104>>2]=d<<2,e[p+144>>2]=e[u+8>>2]<<2,e[p+148>>2]=e[u+8>>2]<<2,e[p+152>>2]=e[u+8>>2]<<2,e[p+156>>2]=e[u+8>>2]<<2,e[p+160>>2]=e[u+8>>2]<<2,e[p+164>>2]=e[u+8>>2]<<2,1<=((E=A=0)|(g=e[u+12>>2]))){for(y=e[a+812>>2],S=e[a+1072>>2],d=0;d=(1<<e[S+(e[y+(E<<2)>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+168>>2]=j(g,12),e[p+172>>2]=e[u+12>>2]<<2,e[p+176>>2]=e[u+12>>2]<<2,e[p+180>>2]=e[u+12>>2]<<2,e[p+184>>2]=e[u+12>>2]<<2,e[p+188>>2]=e[u+12>>2]<<2,e[p+192>>2]=e[u+12>>2]<<2,e[p+196>>2]=e[u+12>>2]<<2,e[p+200>>2]=e[u+12>>2]<<2,e[p+204>>2]=e[u+12>>2]<<4,e[p+208>>2]=e[u+12>>2]<<4,d=e[u+12>>2],e[p+216>>2]=E,e[p+212>>2]=d<<2,d=e[u+12>>2],e[p+268>>2]=E,e[p+264>>2]=E,e[p+260>>2]=E,e[p+256>>2]=E,e[p+252>>2]=E,e[p+248>>2]=E,e[p+244>>2]=E,e[p+240>>2]=E,e[p+236>>2]=E,e[p+232>>2]=E,e[p+228>>2]=E,e[p+224>>2]=E,e[p+220>>2]=d<<2,e[p+272>>2]=e[u+12>>2]<<2,e[p+276>>2]=e[u+12>>2]<<2,e[p+280>>2]=e[u+12>>2]<<2,e[p+284>>2]=e[u+12>>2]<<2,e[p+288>>2]=e[u+12>>2]<<2,e[p+292>>2]=e[u+12>>2]<<2,1<=((E=0)|(d=e[u+16>>2]))){for(y=e[a+852>>2],S=e[a+1072>>2],F=e[a+892>>2],g=0;A=(15+(e[(D=E<<2)+F>>2]<<3)&-16)+A|0,g=(1<<e[S+(e[y+D>>2]<<2)>>2])+g|0,(0|d)!=(0|(E=E+1|0)););E=g<<2}if(e[p+296>>2]=j(d,20),e[p+300>>2]=e[u+16>>2]<<2,e[p+304>>2]=e[u+16>>2],e[p+308>>2]=e[u+16>>2]<<2,e[p+312>>2]=e[u+16>>2]<<2,d=e[u+16>>2],e[p+320>>2]=A,e[p+316>>2]=d<<2,e[p+324>>2]=e[u+16>>2]<<2,e[p+328>>2]=e[u+16>>2]<<4,e[p+332>>2]=e[u+16>>2]<<4,e[p+336>>2]=e[u+16>>2]<<2,e[p+340>>2]=e[u+16>>2]<<2,e[p+344>>2]=e[u+16>>2]<<2,e[p+348>>2]=e[u+16>>2]<<4,e[p+352>>2]=e[u+16>>2]<<4,d=e[u+16>>2],e[p+360>>2]=E,e[p+356>>2]=d<<2,d=e[u+16>>2],e[p+404>>2]=E,e[p+400>>2]=E,e[p+396>>2]=E,e[p+392>>2]=E,e[p+388>>2]=E,e[p+384>>2]=E,e[p+380>>2]=E,e[p+376>>2]=E,e[p+372>>2]=E,e[p+368>>2]=E,e[p+364>>2]=d<<2,e[p+408>>2]=e[u+16>>2]<<2,e[p+412>>2]=e[u+16>>2]<<2,e[p+416>>2]=e[u+16>>2]<<2,e[p+420>>2]=e[u+16>>2]<<2,e[p+424>>2]=e[u+16>>2]<<2,e[p+428>>2]=e[u+16>>2]<<2,y=e[a+704>>2],e[p+432>>2]=j(e[y+20>>2],52),e[p+436>>2]=k>>>(E=g=0)<=3?e[y+20>>2]<<2:0,e[p+440>>2]=e[y+20>>2]<<2,e[p+444>>2]=j(e[y+52>>2],28),1<=(0|(u=e[y+48>>2]))){for(d=e[a+1072>>2],A=0;A=(S=e[d+(E<<2)>>2])+A|0,g=(1<<S)+g|0,(0|u)!=(0|(E=E+1|0)););E=g<<2,g=A<<2}if(e[p+460>>2]=E,e[p+456>>2]=E,e[p+452>>2]=g,e[p+448>>2]=j(u,36),e[p+500>>2]=j(e[y+72>>2],28),1<=((A=E=d=0)|(S=e[y+72>>2]))){for(F=e[a+1224>>2],D=e[a+1220>>2],f=e[a+1212>>2],g=0;g=(0|(_=e[(u=A<<2)+D>>2]-e[u+F>>2]|0))<(0|g)?g:1+_|0,E=(0|E)<(0|(u=e[u+f>>2]))?u:E,(0|S)!=(0|(A=A+1|0)););A=E<<2,E=g<<2}if(u=e[y+76>>2],e[p+516>>2]=E,e[p+512>>2]=A,e[p+508>>2]=E,e[p+504>>2]=u<<4,1<=(0|(u=e[y+80>>2]))){for(d=e[a+1248>>2],A=e[a+1072>>2],g=E=0;g=(1<<e[A+(e[d+(E<<2)>>2]<<2)>>2])+g|0,(0|u)!=(0|(E=E+1|0)););d=g<<2}if(e[p+520>>2]=j(u,24),e[p+524>>2]=e[y+80>>2]<<2,u=e[y+80>>2],e[p+532>>2]=d,e[p+528>>2]=u<<2,u=e[y+80>>2],e[p+544>>2]=d,e[p+540>>2]=d,e[p+536>>2]=u<<2,u=p,4<=k>>>0){if(e[p+464>>2]=j(e[y+120>>2],20),e[p+468>>2]=j(e[y+100>>2],28),d=p,1<=((E=A=0)|(S=e[y+104>>2]))){for(a=e[a+1104>>2],g=0;g=e[a+(E<<2)>>2]+g|0,(0|S)!=(0|(E=E+1|0)););a=g<<2}else a=0;e[d+476>>2]=a,e[p+472>>2]=j(S,48),e[p+484>>2]=j(e[y+108>>2],12),a=e[y+112>>2],e[p+552>>2]=0,e[p+492>>2]=j(a,12),a=0}else{if((0|(A=e[y+20>>2]))<1)g=0;else for(S=e[a+1060>>2],F=e[a+952>>2],a=e[a+948>>2],d=g=0;;){if(1<=(0|(D=e[(E=d<<2)+F>>2])))for(D=(E=S+(e[a+E>>2]<<2)|0)+(D<<2)|0;g=e[E>>2]+g|0,(E=E+4|0)>>>0<D>>>0;);if((0|A)==(0|(d=d+1|0)))break}e[p+552>>2]=A<<2,A=e[y+20>>2]<<2,a=g<<2}for(e[u+556>>2]=a,e[p+548>>2]=A,4<k>>>0&&(e[p+480>>2]=j(e[y+128>>2],12),e[p+488>>2]=j(e[y+132>>2],12),e[p+496>>2]=j(e[y+136>>2],12)),E=g=0;E=((u=e[(a=(g<<2)+p|0)>>2])+15&-16)+(e[a>>2]=E)|0,(0|(g=g+1|0))!=140;);e[P>>2]=E}function Bi(a,p,P,_){r:{if(!(20<p>>>0||9<(p=p+-9|0)>>>0)){switch(p-1|0){default:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=e[p>>2];case 0:return p=e[P>>2],e[P>>2]=p+4,p=e[p>>2],e[a>>2]=p,e[a+4>>2]=p>>31;case 1:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=e[p>>2],e[a+4>>2]=0;case 3:return p=e[P>>2],e[P>>2]=p+4,p=N[p>>1],e[a>>2]=p,e[a+4>>2]=p>>31;case 4:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=W[p>>1],e[a+4>>2]=0;case 5:return p=e[P>>2],e[P>>2]=p+4,p=O[0|p],e[a>>2]=p,e[a+4>>2]=p>>31;case 6:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=H[0|p],e[a+4>>2]=0;case 2:case 7:break r;case 8:}L[_](a,P)}return}p=e[P>>2]+7&-8,e[P>>2]=p+8,P=e[p+4>>2],e[a>>2]=e[p>>2],e[a+4>>2]=P}function xo(a){var p,P,_=0;if(ie(O[e[a>>2]]))for(;p=e[a>>2],P=O[0|p],e[a>>2]=p+1,_=(j(_,10)+P|0)-48|0,ie(O[p+1|0]););return _}function bo(a,p,P,_,f){var E,u;e[204+(K=u=K-208|0)>>2]=P,Ce(160+u|(P=0),0,40),e[200+u>>2]=e[204+u>>2],(0|mr(0,p,200+u|0,80+u|0,160+u|0,_,f))<0||(P=0<=e[a+76>>2]?1:P,P=e[a>>2],O[a+74|0]<=0&&(e[a>>2]=-33&P),E=32&P,e[a+48>>2]?mr(a,p,200+u|0,80+u|0,160+u|0,_,f):(e[a+48>>2]=80,e[a+16>>2]=80+u,e[a+28>>2]=u,e[a+20>>2]=u,P=e[a+44>>2],mr(a,p,200+(e[a+44>>2]=u)|0,80+u|0,160+u|0,_,f),P&&(L[e[a+36>>2]](a,0,0),e[a+48>>2]=0,e[a+44>>2]=P,e[a+28>>2]=0,e[a+16>>2]=0,e[a+20>>2]=0)),e[a>>2]=e[a>>2]|E),K=208+u|0}function Ao(a,p,P){var _,f;ge(8+(K=f=K-160|0)|0,3192,144),e[52+f>>2]=a,e[28+f>>2]=a,e[56+f>>2]=_=(_=-2-a|0)>>>0<256?_:256,e[36+f>>2]=a=a+_|0,e[24+f>>2]=a,bo(8+f|0,p,P,11,12),_&&(a=e[28+f>>2],O[a-((0|a)==e[24+f>>2])|0]=0),K=160+f|0}function wo(a,p){var P,_,f=0,f=(0|p)!=0;r:{t:{e:{i:if(!(!p|!(3&a)))for(;;){if(!H[0|a])break e;if(a=a+1|0,f=(0|(p=p+-1|0))!=0,!p)break i;if(!(3&a))break}if(!f)break t}if(!H[0|a])break r;e:{if(4<=p>>>0){for(f=(f=p+-4|0)-(P=-4&f)|0,P=4+(a+P|0)|0;;){if((-1^(_=e[a>>2]))&_+-16843009&-2139062144)break e;if(a=a+4|0,!(3<(p=p+-4|0)>>>0))break}p=f,a=P}if(!p)break t}for(;;){if(!H[0|a])break r;if(a=a+1|0,!(p=p+-1|0))break}}return 0}return a}function To(a){var p,P=0;if(!a)return 32;if(!(1&a))for(;P=P+1|0,p=2&a,a>>>=1,!p;);return P}function Eo(a,p){var P,_,f,E,u=0,d=0,d=4;K=E=K-256|0;r:if(!((0|p)<2))for(u=e[(f=(p<<2)+a|0)>>2]=E;;){for(ge(u,e[a>>2],P=d>>>0<256?d:256),u=0;ge(e[(_=(u<<2)+a|0)>>2],e[((u=u+1|0)<<2)+a>>2],P),e[_>>2]=e[_>>2]+P,(0|p)!=(0|u););if(!(d=d-P|0))break r;u=e[f>>2]}K=256+E|0}function Co(a){return To(e[a>>2]+-1|0)||((a=To(e[a+4>>2]))?a+32|0:0)}function Rs(a,p){p|=0,Wt[0]=a|=0,Wt[1]=p}function So(a,p,P){return function(_,f,E){var u,d,g,y,A=j(d=E>>>16,g=_>>>16);return _=(65535&(g=((u=j(y=65535&E,_&=65535))>>>16)+j(g,y)|0))+j(_,d)|0,Vt=((A+j(f,E)|0)+(g>>>16)|0)+(_>>>16)|0,65535&u|_<<16}(a,p,P)}function Po(a,p,P){return function(_,f,E){var u,d,g=0,y=0,A=0,S=0,D=0,F=0,k=0;r:{t:{e:{i:{s:{if(!(y=f))return Rs((f=_)-j(_=(_>>>0)/(E>>>0)|0,E)|0,0),Vt=0,_;if(g=E){if(!((S=g+-1|0)&g))break s;D=0-(S=(yt(g)+33|0)-yt(y)|0)|0;break e}if(!_)return Rs(0,y-j(_=(y>>>0)/0|0,0)|0),Vt=0,_;if((g=32-yt(y)|0)>>>0<31)break i;break t}if(Rs(_&S,0),(0|g)==1)break r;return E=31&(g=g?31-yt(g+-1^g)|0:32),_=32<=(63&g)>>>0?(y=0,f>>>E):(y=f>>>E,((1<<E)-1&f)<<32-E|_>>>E),Vt=y,_}S=g+1|0,D=63-g|0}if(g=f,A=31&(y=63&S),A=32<=y>>>0?(y=0,g>>>A):(y=g>>>A,((1<<A)-1&g)<<32-A|_>>>A),g=31&(D&=63),32<=D>>>0?(f=_<<g,_=0):(f=(1<<g)-1&_>>>32-g|f<<g,_<<=g),S)for((D=E+(g=-1)|0)>>>0<4294967295&&(g=0);A=(d=F=A<<1|f>>>31)-(u=E&(F=g-((y=y<<1|A>>>31)+(D>>>0<F>>>0)|0)>>31))|0,y=y-(d>>>0<u>>>0)|0,f=f<<1|_>>>31,_=k|_<<1,k=F&=1,S=S+-1|0;);return Rs(A,y),Vt=f<<1|_>>>31,F|_<<1}Rs(_,f),f=_=0}return Vt=f,_}(a,p,P)}function Br(a){var p;return(-1>>>(p=31&a)&-2)<<p|(-1<<(a=0-a&31)&-2)>>>a}function $o(){return w.byteLength/65536|0}}(Pt,Rt,pt)}}I=null,x.wasmBinary&&(Dt=x.wasmBinary);var wt={},Dt=[];typeof wt!="object"&&et("no native wasm support detected");var Rt,pt=new function(Tt){var $t=Array(16);return $t.grow=function(){17<=$t.length&&te("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."),$t.push(null)},$t.set=function(at,lt){$t[at]=lt},$t.get=function(at){return $t[at]},$t},xt=!1;function Ct(Tt,$t){Tt||te("Assertion failed: "+$t)}var Gt,st,nt,Y,gt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ot(Tt,$t,at){var lt=$t+at;for(at=$t;Tt[at]&&!(lt<=at);)++at;if(16<at-$t&&Tt.subarray&&gt)return gt.decode(Tt.subarray($t,at));for(lt="";$t<at;){var Wt,Ae,de=Tt[$t++];128&de?(Wt=63&Tt[$t++],(224&de)==192?lt+=String.fromCharCode((31&de)<<6|Wt):(Ae=63&Tt[$t++],(de=(240&de)==224?(15&de)<<12|Wt<<6|Ae:(7&de)<<18|Wt<<12|Ae<<6|63&Tt[$t++])<65536?lt+=String.fromCharCode(de):(de-=65536,lt+=String.fromCharCode(55296|de>>10,56320|1023&de)))):lt+=String.fromCharCode(de)}return lt}function ht(Tt,$t){return Tt?ot(nt,Tt,$t):""}function dt(Tt){return 0<Tt%65536&&(Tt+=65536-Tt%65536),Tt}function At(Tt){Gt=Tt,x.HEAP8=st=new Int8Array(Tt),x.HEAP16=new Int16Array(Tt),x.HEAP32=Y=new Int32Array(Tt),x.HEAPU8=nt=new Uint8Array(Tt),x.HEAPU16=new Uint16Array(Tt),x.HEAPU32=new Uint32Array(Tt),x.HEAPF32=new Float32Array(Tt),x.HEAPF64=new Float64Array(Tt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");var Et=x.TOTAL_MEMORY||16777216;function It(Tt){for(;0<Tt.length;){var $t,at=Tt.shift();typeof at=="function"?at():typeof($t=at.ea)=="number"?at.da===void 0?x.dynCall_v($t):x.dynCall_vi($t,at.da):$t(at.da===void 0?null:at.da)}}(Rt=x.wasmMemory||new function(){return{buffer:new ArrayBuffer(Et/65536*65536),grow:function(Tt){return hr(Tt)}}})&&(Gt=Rt.buffer),Gt.byteLength,At(Gt),Y[2216]=5251936;var oe,Bt=[],se=[],Jt=[],zt=[],_e=(Math.imul&&Math.imul(4294967295,5)===-5||(Math.imul=function(Tt,$t){var at=65535&Tt,lt=65535&$t;return at*lt+((Tt>>>16)*lt+at*($t>>>16)<<16)|0}),Math.fround||(oe=new Float32Array(1),Math.fround=function(Tt){return oe[0]=Tt,oe[0]}),Math.clz32||(Math.clz32=function(Tt){var $t=32,at=Tt>>16;return at&&($t-=16,Tt=at),(at=Tt>>8)&&($t-=8,Tt=at),(at=Tt>>4)&&($t-=4,Tt=at),(at=Tt>>2)&&($t-=2,Tt=at),Tt>>1?$t-2:$t-Tt}),Math.trunc||(Math.trunc=function(Tt){return Tt<0?Math.ceil(Tt):Math.floor(Tt)}),0),$e=null;function te(Tt){throw x.onAbort&&x.onAbort(Tt),_t(Tt),et(Tt),xt=!0,"abort("+Tt+"). Build with -s ASSERTIONS=1 for more info."}x.preloadedImages={},x.preloadedAudios={};var Ie="data:application/octet-stream;base64,";function xe(Tt){return String.prototype.startsWith?Tt.startsWith(Ie):Tt.indexOf(Ie)===0}var ae="_em_module.wasm";function Lr(){try{if(Dt)return new Uint8Array(Dt);var Tt=Wr(ae);if(Tt)return Tt;if(z)return z(ae);throw"both async and sync fetching of the wasm failed"}catch($t){te($t)}}xe(ae)||(Q=ae,ae=x.locateFile?x.locateFile(Q,wr):wr+Q),se.push({ea:function(){Hr()}});var xr=[null,[],[]];function Fi(Tt){for(var $t=[],at=0;at<Tt.length;at++){var lt=Tt[at];255<lt&&(lt&=255),$t.push(String.fromCharCode(lt))}return $t.join("")}var sr=typeof atob=="function"?atob:function(Tt){var $t="",at=0;Tt=Tt.replace(/[^A-Za-z0-9\+\/=]/g,"");do var Ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),Wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),Ae=Ae<<2|de>>4,de=(15&de)<<4|lt>>2,Yt=(3&lt)<<6|Wt;while($t+=String.fromCharCode(Ae),lt!==64&&($t+=String.fromCharCode(de)),Wt!==64&&($t+=String.fromCharCode(Yt)),at<Tt.length);return $t};function Wr(Tt){if(xe(Tt)){if(Tt=Tt.slice(Ie.length),typeof it=="boolean"&&it){try{var $t=Buffer.from(Tt,"base64")}catch{$t=new Buffer(Tt,"base64")}var at=new Uint8Array($t.buffer,$t.byteOffset,$t.byteLength)}else try{for(var lt=sr(Tt),Wt=new Uint8Array(lt.length),$t=0;$t<lt.length;++$t)Wt[$t]=lt.charCodeAt($t);at=Wt}catch{throw Error("Converting base64 string to bytes failed.")}return at}}var dr,Pt={a:function(Tt,$t,at){nt.set(nt.subarray($t,$t+at),Tt)},b:function(Tt){if(2147418112<Tt)return!1;for(var $t=Math.max(st.length,16777216);$t<Tt;)$t=$t<=536870912?dt(2*$t):Math.min(dt((3*$t+2147483648)/4),2147418112);r:{try{Rt.grow($t-Gt.byteLength+65535>>16),At(Rt.buffer);var at=1;break r}catch{}at=void 0}return!!at},c:function(Tt,$t,at,lt){try{for(var Wt=0,Ae=0;Ae<at;Ae++){for(var de=Y[$t+8*Ae>>2],Yt=Y[$t+(8*Ae+4)>>2],Xe=0;Xe<Yt;Xe++){var je=nt[de+Xe],Qt=xr[Tt];je===0||je===10?((Tt===1?_t:et)(ot(Qt,0)),Qt.length=0):Qt.push(je)}Wt+=Yt}return Y[lt>>2]=Wt,0}catch(Xt){return typeof FS<"u"&&Xt instanceof FS.fa||te(Xt),Xt.ga}},memory:Rt,table:pt},wr=function(){function Tt(Wt){x.asm=Wt.exports,_e--,x.monitorRunDependencies&&x.monitorRunDependencies(_e),_e==0&&$e&&(Wt=$e,$e=null,Wt())}function $t(Wt){Tt(Wt.instance)}function at(Wt){(Dt||!J&&!Z||typeof fetch!="function"?new Promise(function(Ae){Ae(Lr())}):fetch(ae,{credentials:"same-origin"}).then(function(Ae){if(Ae.ok)return Ae.arrayBuffer();throw"failed to load wasm binary file at '"+ae+"'"}).catch(Lr)).then(function(){return{then:function(Ae){Ae({instance:new ft})}}}).then(Wt,function(Ae){et("failed to asynchronously prepare wasm: "+Ae),te(Ae)})}var lt={env:Pt,wasi_unstable:Pt};if(_e++,x.monitorRunDependencies&&x.monitorRunDependencies(_e),x.instantiateWasm)try{return x.instantiateWasm(lt,Tt)}catch(Wt){return et("Module.instantiateWasm callback failed with error: "+Wt),!1}return Dt||typeof wt.instantiateStreaming!="function"||xe(ae)||typeof fetch!="function"?at($t):fetch(ae,{credentials:"same-origin"}).then(function(Wt){return wt.instantiateStreaming(Wt,lt).then($t,function(Ae){et("wasm streaming compile failed: "+Ae),et("falling back to ArrayBuffer instantiation"),at($t)})}),{}}(),Hr=(x.asm=wr,x.___wasm_call_ctors=function(){return x.asm.d.apply(null,arguments)}),ze=(x._csmGetLogFunction=function(){return x.asm.e.apply(null,arguments)},x._csmGetVersion=function(){return x.asm.f.apply(null,arguments)},x._csmGetLatestMocVersion=function(){return x.asm.g.apply(null,arguments)},x._csmGetMocVersion=function(){return x.asm.h.apply(null,arguments)},x._csmHasMocConsistency=function(){return x.asm.i.apply(null,arguments)},x._csmSetLogFunction=function(){return x.asm.j.apply(null,arguments)},x._csmReviveMocInPlace=function(){return x.asm.k.apply(null,arguments)},x._csmReadCanvasInfo=function(){return x.asm.l.apply(null,arguments)},x._csmGetSizeofModel=function(){return x.asm.m.apply(null,arguments)},x._csmInitializeModelInPlace=function(){return x.asm.n.apply(null,arguments)},x._csmUpdateModel=function(){return x.asm.o.apply(null,arguments)},x._csmGetParameterCount=function(){return x.asm.p.apply(null,arguments)},x._csmGetParameterIds=function(){return x.asm.q.apply(null,arguments)},x._csmGetParameterTypes=function(){return x.asm.r.apply(null,arguments)},x._csmGetParameterMinimumValues=function(){return x.asm.s.apply(null,arguments)},x._csmGetParameterMaximumValues=function(){return x.asm.t.apply(null,arguments)},x._csmGetParameterDefaultValues=function(){return x.asm.u.apply(null,arguments)},x._csmGetParameterValues=function(){return x.asm.v.apply(null,arguments)},x._csmGetPartCount=function(){return x.asm.w.apply(null,arguments)},x._csmGetPartIds=function(){return x.asm.x.apply(null,arguments)},x._csmGetPartOpacities=function(){return x.asm.y.apply(null,arguments)},x._csmGetPartParentPartIndices=function(){return x.asm.z.apply(null,arguments)},x._csmGetDrawableCount=function(){return x.asm.A.apply(null,arguments)},x._csmGetDrawableIds=function(){return x.asm.B.apply(null,arguments)},x._csmGetDrawableConstantFlags=function(){return x.asm.C.apply(null,arguments)},x._csmGetDrawableDynamicFlags=function(){return x.asm.D.apply(null,arguments)},x._csmGetDrawableTextureIndices=function(){return x.asm.E.apply(null,arguments)},x._csmGetDrawableDrawOrders=function(){return x.asm.F.apply(null,arguments)},x._csmGetDrawableRenderOrders=function(){return x.asm.G.apply(null,arguments)},x._csmGetDrawableOpacities=function(){return x.asm.H.apply(null,arguments)},x._csmGetDrawableMaskCounts=function(){return x.asm.I.apply(null,arguments)},x._csmGetDrawableMasks=function(){return x.asm.J.apply(null,arguments)},x._csmGetDrawableVertexCounts=function(){return x.asm.K.apply(null,arguments)},x._csmGetDrawableVertexPositions=function(){return x.asm.L.apply(null,arguments)},x._csmGetDrawableVertexUvs=function(){return x.asm.M.apply(null,arguments)},x._csmGetDrawableIndexCounts=function(){return x.asm.N.apply(null,arguments)},x._csmGetDrawableIndices=function(){return x.asm.O.apply(null,arguments)},x._csmGetDrawableMultiplyColors=function(){return x.asm.P.apply(null,arguments)},x._csmGetDrawableScreenColors=function(){return x.asm.Q.apply(null,arguments)},x._csmGetDrawableParentPartIndices=function(){return x.asm.R.apply(null,arguments)},x._csmResetDrawableDynamicFlags=function(){return x.asm.S.apply(null,arguments)},x._csmGetParameterKeyCounts=function(){return x.asm.T.apply(null,arguments)},x._csmGetParameterKeyValues=function(){return x.asm.U.apply(null,arguments)},x._csmMallocMoc=function(){return x.asm.V.apply(null,arguments)},x._csmMallocModelAndInitialize=function(){return x.asm.W.apply(null,arguments)},x._csmMalloc=function(){return x.asm.X.apply(null,arguments)},x._csmFree=function(){return x.asm.Y.apply(null,arguments)},x._csmInitializeAmountOfMemory=function(){return x.asm.Z.apply(null,arguments)},x.stackSave=function(){return x.asm._.apply(null,arguments)}),Li=x.stackAlloc=function(){return x.asm.$.apply(null,arguments)},Ds=x.stackRestore=function(){return x.asm.aa.apply(null,arguments)},hr=x.__growWasmMemory=function(){return x.asm.ba.apply(null,arguments)};function Qr(){function Tt(){if(!dr&&(dr=!0,!xt)){if(It(se),It(Jt),x.onRuntimeInitialized&&x.onRuntimeInitialized(),x.postRun)for(typeof x.postRun=="function"&&(x.postRun=[x.postRun]);x.postRun.length;){var $t=x.postRun.shift();zt.unshift($t)}It(zt)}}if(!(0<_e)){if(x.preRun)for(typeof x.preRun=="function"&&(x.preRun=[x.preRun]);x.preRun.length;)(function(){var $t=x.preRun.shift();Bt.unshift($t)})();It(Bt),0<_e||(x.setStatus?(x.setStatus("Running..."),setTimeout(function(){setTimeout(function(){x.setStatus("")},1),Tt()},1)):Tt())}}if(x.dynCall_vi=function(){return x.asm.ca.apply(null,arguments)},x.asm=wr,x.ccall=function(Tt,$t,at,lt){var Wt={string:function(je){var Qt=0;if(je!=null&&je!==0){var Xt=1+(je.length<<2),l=Qt=Li(Xt),w=nt;if(0<Xt){for(var Xt=l+Xt-1,M=0;M<je.length;++M){var L=je.charCodeAt(M);if((L=55296<=L&&L<=57343?65536+((1023&L)<<10)|1023&je.charCodeAt(++M):L)<=127){if(Xt<=l)break;w[l++]=L}else{if(L<=2047){if(Xt<=l+1)break;w[l++]=192|L>>6}else{if(L<=65535){if(Xt<=l+2)break;w[l++]=224|L>>12}else{if(Xt<=l+3)break;w[l++]=240|L>>18,w[l++]=128|L>>12&63}w[l++]=128|L>>6&63}w[l++]=128|63&L}}w[l]=0}}return Qt},array:function(je){var Qt=Li(je.length);return st.set(je,Qt),Qt}},Ae=function(je){var Qt=x["_"+je];return Ct(Qt,"Cannot call unknown function "+je+", make sure it is exported"),Qt}(Tt),de=[];if(Tt=0,lt)for(var Yt=0;Yt<lt.length;Yt++){var Xe=Wt[at[Yt]];Xe?(Tt===0&&(Tt=ze()),de[Yt]=Xe(lt[Yt])):de[Yt]=lt[Yt]}return at=function(je){return $t==="string"?ht(je):$t==="boolean"?!!je:je}(at=Ae.apply(null,de)),Tt!==0&&Ds(Tt),at},x.UTF8ToString=ht,x.addFunction=function(Tt,$t){var at=pt.length;try{pt.grow(1)}catch(lt){throw!lt instanceof RangeError?lt:"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}try{pt.set(at,Tt)}catch(lt){if(!lt instanceof TypeError)throw lt;Ct($t!==void 0,"Missing signature argument to addFunction"),pt.set(at,Tt)}return at},x.then=function(Tt){var $t;return dr?Tt(x):($t=x.onRuntimeInitialized,x.onRuntimeInitialized=function(){$t&&$t(),Tt(x)}),x},$e=function Tt(){dr||Qr(),dr||($e=Tt)},x.run=Qr,x.preInit)for(typeof x.preInit=="function"&&(x.preInit=[x.preInit]);0<x.preInit.length;)x.preInit.pop()();return Qr(),C}),T=(typeof qr=="object"&&typeof module=="object"?module.exports=b:typeof define=="function"&&define.amd?define([],function(){return b}):typeof qr=="object"&&(qr._em_module=b),b())})(Is=Is||{}),window.Live2DCubismCore=Is;var ys=(s=>(s[s.WEBGL_LEGACY=0]="WEBGL_LEGACY",s[s.WEBGL=1]="WEBGL",s[s.WEBGL2=2]="WEBGL2",s))(ys||{}),qa=(s=>(s[s.UNKNOWN=0]="UNKNOWN",s[s.WEBGL=1]="WEBGL",s[s.CANVAS=2]="CANVAS",s))(qa||{}),Lo=(s=>(s[s.COLOR=16384]="COLOR",s[s.DEPTH=256]="DEPTH",s[s.STENCIL=1024]="STENCIL",s))(Lo||{}),De=(s=>(s[s.NORMAL=0]="NORMAL",s[s.ADD=1]="ADD",s[s.MULTIPLY=2]="MULTIPLY",s[s.SCREEN=3]="SCREEN",s[s.OVERLAY=4]="OVERLAY",s[s.DARKEN=5]="DARKEN",s[s.LIGHTEN=6]="LIGHTEN",s[s.COLOR_DODGE=7]="COLOR_DODGE",s[s.COLOR_BURN=8]="COLOR_BURN",s[s.HARD_LIGHT=9]="HARD_LIGHT",s[s.SOFT_LIGHT=10]="SOFT_LIGHT",s[s.DIFFERENCE=11]="DIFFERENCE",s[s.EXCLUSION=12]="EXCLUSION",s[s.HUE=13]="HUE",s[s.SATURATION=14]="SATURATION",s[s.COLOR=15]="COLOR",s[s.LUMINOSITY=16]="LUMINOSITY",s[s.NORMAL_NPM=17]="NORMAL_NPM",s[s.ADD_NPM=18]="ADD_NPM",s[s.SCREEN_NPM=19]="SCREEN_NPM",s[s.NONE=20]="NONE",s[s.SRC_OVER=0]="SRC_OVER",s[s.SRC_IN=21]="SRC_IN",s[s.SRC_OUT=22]="SRC_OUT",s[s.SRC_ATOP=23]="SRC_ATOP",s[s.DST_OVER=24]="DST_OVER",s[s.DST_IN=25]="DST_IN",s[s.DST_OUT=26]="DST_OUT",s[s.DST_ATOP=27]="DST_ATOP",s[s.ERASE=26]="ERASE",s[s.SUBTRACT=28]="SUBTRACT",s[s.XOR=29]="XOR",s))(De||{}),Ai=(s=>(s[s.POINTS=0]="POINTS",s[s.LINES=1]="LINES",s[s.LINE_LOOP=2]="LINE_LOOP",s[s.LINE_STRIP=3]="LINE_STRIP",s[s.TRIANGLES=4]="TRIANGLES",s[s.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",s[s.TRIANGLE_FAN=6]="TRIANGLE_FAN",s))(Ai||{}),qt=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(qt||{}),Fs=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(Fs||{}),Pe=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(Pe||{}),le=(s=>(s[s.FLOAT=0]="FLOAT",s[s.INT=1]="INT",s[s.UINT=2]="UINT",s))(le||{}),Gi=(s=>(s[s.NEAREST=0]="NEAREST",s[s.LINEAR=1]="LINEAR",s))(Gi||{}),Vi=(s=>(s[s.CLAMP=33071]="CLAMP",s[s.REPEAT=10497]="REPEAT",s[s.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",s))(Vi||{}),wi=(s=>(s[s.OFF=0]="OFF",s[s.POW2=1]="POW2",s[s.ON=2]="ON",s[s.ON_MANUAL=3]="ON_MANUAL",s))(wi||{}),Vr=(s=>(s[s.NPM=0]="NPM",s[s.UNPACK=1]="UNPACK",s[s.PMA=2]="PMA",s[s.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",s[s.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",s[s.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",s))(Vr||{}),Ti=(s=>(s[s.NO=0]="NO",s[s.YES=1]="YES",s[s.AUTO=2]="AUTO",s[s.BLEND=0]="BLEND",s[s.CLEAR=1]="CLEAR",s[s.BLIT=2]="BLIT",s))(Ti||{}),ko=(s=>(s[s.AUTO=0]="AUTO",s[s.MANUAL=1]="MANUAL",s))(ko||{}),ri=(s=>(s.LOW="lowp",s.MEDIUM="mediump",s.HIGH="highp",s))(ri||{}),br=(s=>(s[s.NONE=0]="NONE",s[s.SCISSOR=1]="SCISSOR",s[s.STENCIL=2]="STENCIL",s[s.SPRITE=3]="SPRITE",s[s.COLOR=4]="COLOR",s))(br||{}),Nu=(s=>(s[s.RED=1]="RED",s[s.GREEN=2]="GREEN",s[s.BLUE=4]="BLUE",s[s.ALPHA=8]="ALPHA",s))(Nu||{}),yr=(s=>(s[s.NONE=0]="NONE",s[s.LOW=2]="LOW",s[s.MEDIUM=4]="MEDIUM",s[s.HIGH=8]="HIGH",s))(yr||{}),Ei=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(Ei||{});const Uu={createCanvas:(s,t)=>{const r=document.createElement("canvas");return r.width=s,r.height=t,r},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")},ue={ADAPTER:Uu,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Za=/iPhone/i,Gu=/iPod/i,Vu=/iPad/i,Xu=/\biOS-universal(?:.+)Mac\b/i,Qa=/\bAndroid(?:.+)Mobile\b/i,zu=/Android/i,Ks=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Bo=/Silk/i,os=/Windows Phone/i,Wu=/\bWindows(?:.+)ARM\b/i,Hu=/BlackBerry/i,Yu=/BB10/i,ju=/Opera Mini/i,qu=/\b(CriOS|Chrome)(?:.+)Mobile/i,Zu=/Mobile(?:.+)Firefox\b/i,Qu=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function T2(s){return function(t){return t.test(s)}}function Ku(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var r=t.userAgent,i=r.split("[FBAN");typeof i[1]<"u"&&(r=i[0]),i=r.split("Twitter"),typeof i[1]<"u"&&(r=i[0]);var n=T2(r),o={apple:{phone:n(Za)&&!n(os),ipod:n(Gu),tablet:!n(Za)&&(n(Vu)||Qu(t))&&!n(os),universal:n(Xu),device:(n(Za)||n(Gu)||n(Vu)||n(Xu)||Qu(t))&&!n(os)},amazon:{phone:n(Ks),tablet:!n(Ks)&&n(Bo),device:n(Ks)||n(Bo)},android:{phone:!n(os)&&n(Ks)||!n(os)&&n(Qa),tablet:!n(os)&&!n(Ks)&&!n(Qa)&&(n(Bo)||n(zu)),device:!n(os)&&(n(Ks)||n(Bo)||n(Qa)||n(zu))||n(/\bokhttp\b/i)},windows:{phone:n(os),tablet:n(Wu),device:n(os)||n(Wu)},other:{blackberry:n(Hu),blackberry10:n(Yu),opera:n(ju),firefox:n(Zu),chrome:n(qu),device:n(Hu)||n(Yu)||n(ju)||n(Zu)||n(qu)},any:!1,phone:!1,tablet:!1};return o.any=o.apple.device||o.android.device||o.windows.device||o.other.device,o.phone=o.apple.phone||o.android.phone||o.windows.phone,o.tablet=o.apple.tablet||o.android.tablet||o.windows.tablet,o}const E2=Ku.default??Ku,Ci=E2(globalThis.navigator);ue.RETINA_PREFIX=/@([0-9\.]+)x/,ue.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Ka=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ju(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function C2(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var r=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var n=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return s[i]}})}),r}var Ja={exports:{}},tc;function S2(){return tc||(tc=1,function(s){var t=Object.prototype.hasOwnProperty,r="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function n(b,T,C){this.fn=b,this.context=T,this.once=C||!1}function o(b,T,C,x,$){if(typeof C!="function")throw new TypeError("The listener must be a function");var I=new n(C,x||b,$),B=r?r+T:T;return b._events[B]?b._events[B].fn?b._events[B]=[b._events[B],I]:b._events[B].push(I):(b._events[B]=I,b._eventsCount++),b}function h(b,T){--b._eventsCount===0?b._events=new i:delete b._events[T]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var T=[],C,x;if(this._eventsCount===0)return T;for(x in C=this._events)t.call(C,x)&&T.push(r?x.slice(1):x);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(C)):T},c.prototype.listeners=function(T){var C=r?r+T:T,x=this._events[C];if(!x)return[];if(x.fn)return[x.fn];for(var $=0,I=x.length,B=new Array(I);$<I;$++)B[$]=x[$].fn;return B},c.prototype.listenerCount=function(T){var C=r?r+T:T,x=this._events[C];return x?x.fn?1:x.length:0},c.prototype.emit=function(T,C,x,$,I,B){var U=r?r+T:T;if(!this._events[U])return!1;var G=this._events[U],z=arguments.length,J,Z;if(G.fn){switch(G.once&&this.removeListener(T,G.fn,void 0,!0),z){case 1:return G.fn.call(G.context),!0;case 2:return G.fn.call(G.context,C),!0;case 3:return G.fn.call(G.context,C,x),!0;case 4:return G.fn.call(G.context,C,x,$),!0;case 5:return G.fn.call(G.context,C,x,$,I),!0;case 6:return G.fn.call(G.context,C,x,$,I,B),!0}for(Z=1,J=new Array(z-1);Z<z;Z++)J[Z-1]=arguments[Z];G.fn.apply(G.context,J)}else{var it=G.length,Q;for(Z=0;Z<it;Z++)switch(G[Z].once&&this.removeListener(T,G[Z].fn,void 0,!0),z){case 1:G[Z].fn.call(G[Z].context);break;case 2:G[Z].fn.call(G[Z].context,C);break;case 3:G[Z].fn.call(G[Z].context,C,x);break;case 4:G[Z].fn.call(G[Z].context,C,x,$);break;default:if(!J)for(Q=1,J=new Array(z-1);Q<z;Q++)J[Q-1]=arguments[Q];G[Z].fn.apply(G[Z].context,J)}}return!0},c.prototype.on=function(T,C,x){return o(this,T,C,x,!1)},c.prototype.once=function(T,C,x){return o(this,T,C,x,!0)},c.prototype.removeListener=function(T,C,x,$){var I=r?r+T:T;if(!this._events[I])return this;if(!C)return h(this,I),this;var B=this._events[I];if(B.fn)B.fn===C&&(!$||B.once)&&(!x||B.context===x)&&h(this,I);else{for(var U=0,G=[],z=B.length;U<z;U++)(B[U].fn!==C||$&&!B[U].once||x&&B[U].context!==x)&&G.push(B[U]);G.length?this._events[I]=G.length===1?G[0]:G:h(this,I)}return this},c.prototype.removeAllListeners=function(T){var C;return T?(C=r?r+T:T,this._events[C]&&h(this,C)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,s.exports=c}(Ja)),Ja.exports}var P2=S2();const Xi=Ju(P2);var Oo={exports:{}},ec;function $2(){if(ec)return Oo.exports;ec=1,Oo.exports=s,Oo.exports.default=s;function s(st,nt,Y){Y=Y||2;var gt=nt&&nt.length,ot=gt?nt[0]*Y:st.length,ht=t(st,0,ot,Y,!0),dt=[];if(!ht||ht.next===ht.prev)return dt;var At,Et,It,oe,Bt,se,Jt;if(gt&&(ht=b(st,nt,ht,Y)),st.length>80*Y){At=It=st[0],Et=oe=st[1];for(var zt=Y;zt<ot;zt+=Y)Bt=st[zt],se=st[zt+1],Bt<At&&(At=Bt),se<Et&&(Et=se),Bt>It&&(It=Bt),se>oe&&(oe=se);Jt=Math.max(It-At,oe-Et),Jt=Jt!==0?32767/Jt:0}return i(ht,dt,Y,At,Et,Jt,0),dt}function t(st,nt,Y,gt,ot){var ht,dt;if(ot===Gt(st,nt,Y,gt)>0)for(ht=nt;ht<Y;ht+=gt)dt=pt(ht,st[ht],st[ht+1],dt);else for(ht=Y-gt;ht>=nt;ht-=gt)dt=pt(ht,st[ht],st[ht+1],dt);return dt&&it(dt,dt.next)&&(xt(dt),dt=dt.next),dt}function r(st,nt){if(!st)return st;nt||(nt=st);var Y=st,gt;do if(gt=!1,!Y.steiner&&(it(Y,Y.next)||Z(Y.prev,Y,Y.next)===0)){if(xt(Y),Y=nt=Y.prev,Y===Y.next)break;gt=!0}else Y=Y.next;while(gt||Y!==nt);return nt}function i(st,nt,Y,gt,ot,ht,dt){if(st){!dt&&ht&&I(st,gt,ot,ht);for(var At=st,Et,It;st.prev!==st.next;){if(Et=st.prev,It=st.next,ht?o(st,gt,ot,ht):n(st)){nt.push(Et.i/Y|0),nt.push(st.i/Y|0),nt.push(It.i/Y|0),xt(st),st=It.next,At=It.next;continue}if(st=It,st===At){dt?dt===1?(st=h(r(st),nt,Y),i(st,nt,Y,gt,ot,ht,2)):dt===2&&c(st,nt,Y,gt,ot,ht):i(r(st),nt,Y,gt,ot,ht,1);break}}}}function n(st){var nt=st.prev,Y=st,gt=st.next;if(Z(nt,Y,gt)>=0)return!1;for(var ot=nt.x,ht=Y.x,dt=gt.x,At=nt.y,Et=Y.y,It=gt.y,oe=ot<ht?ot<dt?ot:dt:ht<dt?ht:dt,Bt=At<Et?At<It?At:It:Et<It?Et:It,se=ot>ht?ot>dt?ot:dt:ht>dt?ht:dt,Jt=At>Et?At>It?At:It:Et>It?Et:It,zt=gt.next;zt!==nt;){if(zt.x>=oe&&zt.x<=se&&zt.y>=Bt&&zt.y<=Jt&&z(ot,At,ht,Et,dt,It,zt.x,zt.y)&&Z(zt.prev,zt,zt.next)>=0)return!1;zt=zt.next}return!0}function o(st,nt,Y,gt){var ot=st.prev,ht=st,dt=st.next;if(Z(ot,ht,dt)>=0)return!1;for(var At=ot.x,Et=ht.x,It=dt.x,oe=ot.y,Bt=ht.y,se=dt.y,Jt=At<Et?At<It?At:It:Et<It?Et:It,zt=oe<Bt?oe<se?oe:se:Bt<se?Bt:se,_e=At>Et?At>It?At:It:Et>It?Et:It,$e=oe>Bt?oe>se?oe:se:Bt>se?Bt:se,te=U(Jt,zt,nt,Y,gt),Ie=U(_e,$e,nt,Y,gt),xe=st.prevZ,ae=st.nextZ;xe&&xe.z>=te&&ae&&ae.z<=Ie;){if(xe.x>=Jt&&xe.x<=_e&&xe.y>=zt&&xe.y<=$e&&xe!==ot&&xe!==dt&&z(At,oe,Et,Bt,It,se,xe.x,xe.y)&&Z(xe.prev,xe,xe.next)>=0||(xe=xe.prevZ,ae.x>=Jt&&ae.x<=_e&&ae.y>=zt&&ae.y<=$e&&ae!==ot&&ae!==dt&&z(At,oe,Et,Bt,It,se,ae.x,ae.y)&&Z(ae.prev,ae,ae.next)>=0))return!1;ae=ae.nextZ}for(;xe&&xe.z>=te;){if(xe.x>=Jt&&xe.x<=_e&&xe.y>=zt&&xe.y<=$e&&xe!==ot&&xe!==dt&&z(At,oe,Et,Bt,It,se,xe.x,xe.y)&&Z(xe.prev,xe,xe.next)>=0)return!1;xe=xe.prevZ}for(;ae&&ae.z<=Ie;){if(ae.x>=Jt&&ae.x<=_e&&ae.y>=zt&&ae.y<=$e&&ae!==ot&&ae!==dt&&z(At,oe,Et,Bt,It,se,ae.x,ae.y)&&Z(ae.prev,ae,ae.next)>=0)return!1;ae=ae.nextZ}return!0}function h(st,nt,Y){var gt=st;do{var ot=gt.prev,ht=gt.next.next;!it(ot,ht)&&Q(ot,gt,gt.next,ht)&&wt(ot,ht)&&wt(ht,ot)&&(nt.push(ot.i/Y|0),nt.push(gt.i/Y|0),nt.push(ht.i/Y|0),xt(gt),xt(gt.next),gt=st=ht),gt=gt.next}while(gt!==st);return r(gt)}function c(st,nt,Y,gt,ot,ht){var dt=st;do{for(var At=dt.next.next;At!==dt.prev;){if(dt.i!==At.i&&J(dt,At)){var Et=Rt(dt,At);dt=r(dt,dt.next),Et=r(Et,Et.next),i(dt,nt,Y,gt,ot,ht,0),i(Et,nt,Y,gt,ot,ht,0);return}At=At.next}dt=dt.next}while(dt!==st)}function b(st,nt,Y,gt){var ot=[],ht,dt,At,Et,It;for(ht=0,dt=nt.length;ht<dt;ht++)At=nt[ht]*gt,Et=ht<dt-1?nt[ht+1]*gt:st.length,It=t(st,At,Et,gt,!1),It===It.next&&(It.steiner=!0),ot.push(G(It));for(ot.sort(T),ht=0;ht<ot.length;ht++)Y=C(ot[ht],Y);return Y}function T(st,nt){return st.x-nt.x}function C(st,nt){var Y=x(st,nt);if(!Y)return nt;var gt=Rt(Y,st);return r(gt,gt.next),r(Y,Y.next)}function x(st,nt){var Y=nt,gt=st.x,ot=st.y,ht=-1/0,dt;do{if(ot<=Y.y&&ot>=Y.next.y&&Y.next.y!==Y.y){var At=Y.x+(ot-Y.y)*(Y.next.x-Y.x)/(Y.next.y-Y.y);if(At<=gt&&At>ht&&(ht=At,dt=Y.x<Y.next.x?Y:Y.next,At===gt))return dt}Y=Y.next}while(Y!==nt);if(!dt)return null;var Et=dt,It=dt.x,oe=dt.y,Bt=1/0,se;Y=dt;do gt>=Y.x&&Y.x>=It&&gt!==Y.x&&z(ot<oe?gt:ht,ot,It,oe,ot<oe?ht:gt,ot,Y.x,Y.y)&&(se=Math.abs(ot-Y.y)/(gt-Y.x),wt(Y,st)&&(se<Bt||se===Bt&&(Y.x>dt.x||Y.x===dt.x&&$(dt,Y)))&&(dt=Y,Bt=se)),Y=Y.next;while(Y!==Et);return dt}function $(st,nt){return Z(st.prev,st,nt.prev)<0&&Z(nt.next,st,st.next)<0}function I(st,nt,Y,gt){var ot=st;do ot.z===0&&(ot.z=U(ot.x,ot.y,nt,Y,gt)),ot.prevZ=ot.prev,ot.nextZ=ot.next,ot=ot.next;while(ot!==st);ot.prevZ.nextZ=null,ot.prevZ=null,B(ot)}function B(st){var nt,Y,gt,ot,ht,dt,At,Et,It=1;do{for(Y=st,st=null,ht=null,dt=0;Y;){for(dt++,gt=Y,At=0,nt=0;nt<It&&(At++,gt=gt.nextZ,!!gt);nt++);for(Et=It;At>0||Et>0&&gt;)At!==0&&(Et===0||!gt||Y.z<=gt.z)?(ot=Y,Y=Y.nextZ,At--):(ot=gt,gt=gt.nextZ,Et--),ht?ht.nextZ=ot:st=ot,ot.prevZ=ht,ht=ot;Y=gt}ht.nextZ=null,It*=2}while(dt>1);return st}function U(st,nt,Y,gt,ot){return st=(st-Y)*ot|0,nt=(nt-gt)*ot|0,st=(st|st<<8)&16711935,st=(st|st<<4)&252645135,st=(st|st<<2)&858993459,st=(st|st<<1)&1431655765,nt=(nt|nt<<8)&16711935,nt=(nt|nt<<4)&252645135,nt=(nt|nt<<2)&858993459,nt=(nt|nt<<1)&1431655765,st|nt<<1}function G(st){var nt=st,Y=st;do(nt.x<Y.x||nt.x===Y.x&&nt.y<Y.y)&&(Y=nt),nt=nt.next;while(nt!==st);return Y}function z(st,nt,Y,gt,ot,ht,dt,At){return(ot-dt)*(nt-At)>=(st-dt)*(ht-At)&&(st-dt)*(gt-At)>=(Y-dt)*(nt-At)&&(Y-dt)*(ht-At)>=(ot-dt)*(gt-At)}function J(st,nt){return st.next.i!==nt.i&&st.prev.i!==nt.i&&!ft(st,nt)&&(wt(st,nt)&&wt(nt,st)&&Dt(st,nt)&&(Z(st.prev,st,nt.prev)||Z(st,nt.prev,nt))||it(st,nt)&&Z(st.prev,st,st.next)>0&&Z(nt.prev,nt,nt.next)>0)}function Z(st,nt,Y){return(nt.y-st.y)*(Y.x-nt.x)-(nt.x-st.x)*(Y.y-nt.y)}function it(st,nt){return st.x===nt.x&&st.y===nt.y}function Q(st,nt,Y,gt){var ot=et(Z(st,nt,Y)),ht=et(Z(st,nt,gt)),dt=et(Z(Y,gt,st)),At=et(Z(Y,gt,nt));return!!(ot!==ht&&dt!==At||ot===0&&_t(st,Y,nt)||ht===0&&_t(st,gt,nt)||dt===0&&_t(Y,st,gt)||At===0&&_t(Y,nt,gt))}function _t(st,nt,Y){return nt.x<=Math.max(st.x,Y.x)&&nt.x>=Math.min(st.x,Y.x)&&nt.y<=Math.max(st.y,Y.y)&&nt.y>=Math.min(st.y,Y.y)}function et(st){return st>0?1:st<0?-1:0}function ft(st,nt){var Y=st;do{if(Y.i!==st.i&&Y.next.i!==st.i&&Y.i!==nt.i&&Y.next.i!==nt.i&&Q(Y,Y.next,st,nt))return!0;Y=Y.next}while(Y!==st);return!1}function wt(st,nt){return Z(st.prev,st,st.next)<0?Z(st,nt,st.next)>=0&&Z(st,st.prev,nt)>=0:Z(st,nt,st.prev)<0||Z(st,st.next,nt)<0}function Dt(st,nt){var Y=st,gt=!1,ot=(st.x+nt.x)/2,ht=(st.y+nt.y)/2;do Y.y>ht!=Y.next.y>ht&&Y.next.y!==Y.y&&ot<(Y.next.x-Y.x)*(ht-Y.y)/(Y.next.y-Y.y)+Y.x&&(gt=!gt),Y=Y.next;while(Y!==st);return gt}function Rt(st,nt){var Y=new Ct(st.i,st.x,st.y),gt=new Ct(nt.i,nt.x,nt.y),ot=st.next,ht=nt.prev;return st.next=nt,nt.prev=st,Y.next=ot,ot.prev=Y,gt.next=Y,Y.prev=gt,ht.next=gt,gt.prev=ht,gt}function pt(st,nt,Y,gt){var ot=new Ct(st,nt,Y);return gt?(ot.next=gt.next,ot.prev=gt,gt.next.prev=ot,gt.next=ot):(ot.prev=ot,ot.next=ot),ot}function xt(st){st.next.prev=st.prev,st.prev.next=st.next,st.prevZ&&(st.prevZ.nextZ=st.nextZ),st.nextZ&&(st.nextZ.prevZ=st.prevZ)}function Ct(st,nt,Y){this.i=st,this.x=nt,this.y=Y,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}s.deviation=function(st,nt,Y,gt){var ot=nt&&nt.length,ht=ot?nt[0]*Y:st.length,dt=Math.abs(Gt(st,0,ht,Y));if(ot)for(var At=0,Et=nt.length;At<Et;At++){var It=nt[At]*Y,oe=At<Et-1?nt[At+1]*Y:st.length;dt-=Math.abs(Gt(st,It,oe,Y))}var Bt=0;for(At=0;At<gt.length;At+=3){var se=gt[At]*Y,Jt=gt[At+1]*Y,zt=gt[At+2]*Y;Bt+=Math.abs((st[se]-st[zt])*(st[Jt+1]-st[se+1])-(st[se]-st[Jt])*(st[zt+1]-st[se+1]))}return dt===0&&Bt===0?0:Math.abs((Bt-dt)/dt)};function Gt(st,nt,Y,gt){for(var ot=0,ht=nt,dt=Y-gt;ht<Y;ht+=gt)ot+=(st[dt]-st[ht])*(st[ht+1]+st[dt+1]),dt=ht;return ot}return s.flatten=function(st){for(var nt=st[0][0].length,Y={vertices:[],holes:[],dimensions:nt},gt=0,ot=0;ot<st.length;ot++){for(var ht=0;ht<st[ot].length;ht++)for(var dt=0;dt<nt;dt++)Y.vertices.push(st[ot][ht][dt]);ot>0&&(gt+=st[ot-1].length,Y.holes.push(gt))}return Y},Oo.exports}var M2=$2();const rc=Ju(M2);var Ls={},Sn={exports:{}};var D2=Sn.exports,ic;function R2(){return ic||(ic=1,function(s,t){(function(r){var i=t&&!t.nodeType&&t,n=s&&!s.nodeType&&s,o=typeof Ka=="object"&&Ka;(o.global===o||o.window===o||o.self===o)&&(r=o);var h,c=2147483647,b=36,T=1,C=26,x=38,$=700,I=72,B=128,U="-",G=/^xn--/,z=/[^\x20-\x7E]/,J=/[\x2E\u3002\uFF0E\uFF61]/g,Z={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},it=b-T,Q=Math.floor,_t=String.fromCharCode,et;function ft(ot){throw new RangeError(Z[ot])}function wt(ot,ht){for(var dt=ot.length,At=[];dt--;)At[dt]=ht(ot[dt]);return At}function Dt(ot,ht){var dt=ot.split("@"),At="";dt.length>1&&(At=dt[0]+"@",ot=dt[1]),ot=ot.replace(J,".");var Et=ot.split("."),It=wt(Et,ht).join(".");return At+It}function Rt(ot){for(var ht=[],dt=0,At=ot.length,Et,It;dt<At;)Et=ot.charCodeAt(dt++),Et>=55296&&Et<=56319&&dt<At?(It=ot.charCodeAt(dt++),(It&64512)==56320?ht.push(((Et&1023)<<10)+(It&1023)+65536):(ht.push(Et),dt--)):ht.push(Et);return ht}function pt(ot){return wt(ot,function(ht){var dt="";return ht>65535&&(ht-=65536,dt+=_t(ht>>>10&1023|55296),ht=56320|ht&1023),dt+=_t(ht),dt}).join("")}function xt(ot){return ot-48<10?ot-22:ot-65<26?ot-65:ot-97<26?ot-97:b}function Ct(ot,ht){return ot+22+75*(ot<26)-((ht!=0)<<5)}function Gt(ot,ht,dt){var At=0;for(ot=dt?Q(ot/$):ot>>1,ot+=Q(ot/ht);ot>it*C>>1;At+=b)ot=Q(ot/it);return Q(At+(it+1)*ot/(ot+x))}function st(ot){var ht=[],dt=ot.length,At,Et=0,It=B,oe=I,Bt,se,Jt,zt,_e,$e,te,Ie,xe;for(Bt=ot.lastIndexOf(U),Bt<0&&(Bt=0),se=0;se<Bt;++se)ot.charCodeAt(se)>=128&&ft("not-basic"),ht.push(ot.charCodeAt(se));for(Jt=Bt>0?Bt+1:0;Jt<dt;){for(zt=Et,_e=1,$e=b;Jt>=dt&&ft("invalid-input"),te=xt(ot.charCodeAt(Jt++)),(te>=b||te>Q((c-Et)/_e))&&ft("overflow"),Et+=te*_e,Ie=$e<=oe?T:$e>=oe+C?C:$e-oe,!(te<Ie);$e+=b)xe=b-Ie,_e>Q(c/xe)&&ft("overflow"),_e*=xe;At=ht.length+1,oe=Gt(Et-zt,At,zt==0),Q(Et/At)>c-It&&ft("overflow"),It+=Q(Et/At),Et%=At,ht.splice(Et++,0,It)}return pt(ht)}function nt(ot){var ht,dt,At,Et,It,oe,Bt,se,Jt,zt,_e,$e=[],te,Ie,xe,ae;for(ot=Rt(ot),te=ot.length,ht=B,dt=0,It=I,oe=0;oe<te;++oe)_e=ot[oe],_e<128&&$e.push(_t(_e));for(At=Et=$e.length,Et&&$e.push(U);At<te;){for(Bt=c,oe=0;oe<te;++oe)_e=ot[oe],_e>=ht&&_e<Bt&&(Bt=_e);for(Ie=At+1,Bt-ht>Q((c-dt)/Ie)&&ft("overflow"),dt+=(Bt-ht)*Ie,ht=Bt,oe=0;oe<te;++oe)if(_e=ot[oe],_e<ht&&++dt>c&&ft("overflow"),_e==ht){for(se=dt,Jt=b;zt=Jt<=It?T:Jt>=It+C?C:Jt-It,!(se<zt);Jt+=b)ae=se-zt,xe=b-zt,$e.push(_t(Ct(zt+ae%xe,0))),se=Q(ae/xe);$e.push(_t(Ct(se,0))),It=Gt(dt,Ie,At==Et),dt=0,++At}++dt,++ht}return $e.join("")}function Y(ot){return Dt(ot,function(ht){return G.test(ht)?st(ht.slice(4).toLowerCase()):ht})}function gt(ot){return Dt(ot,function(ht){return z.test(ht)?"xn--"+nt(ht):ht})}if(h={version:"1.4.1",ucs2:{decode:Rt,encode:pt},decode:st,encode:nt,toASCII:gt,toUnicode:Y},i&&n)if(s.exports==i)n.exports=h;else for(et in h)h.hasOwnProperty(et)&&(i[et]=h[et]);else r.punycode=h})(D2)}(Sn,Sn.exports)),Sn.exports}var th,sc;function I2(){return sc||(sc=1,th=Error),th}var eh,nc;function F2(){return nc||(nc=1,eh=EvalError),eh}var rh,oc;function L2(){return oc||(oc=1,rh=RangeError),rh}var ih,ac;function k2(){return ac||(ac=1,ih=ReferenceError),ih}var sh,hc;function lc(){return hc||(hc=1,sh=SyntaxError),sh}var nh,uc;function Pn(){return uc||(uc=1,nh=TypeError),nh}var oh,cc;function B2(){return cc||(cc=1,oh=URIError),oh}var ah,fc;function O2(){return fc||(fc=1,ah=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),i=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var n=42;t[r]=n;for(r in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var h=Object.getOwnPropertyDescriptor(t,r);if(h.value!==n||h.enumerable!==!0)return!1}return!0}),ah}var hh,dc;function N2(){if(dc)return hh;dc=1;var s=typeof Symbol<"u"&&Symbol,t=O2();return hh=function(){return typeof s!="function"||typeof Symbol!="function"||typeof s("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},hh}var lh,pc;function U2(){if(pc)return lh;pc=1;var s={__proto__:null,foo:{}},t=Object;return lh=function(){return{__proto__:s}.foo===s.foo&&!(s instanceof t)},lh}var uh,_c;function G2(){if(_c)return uh;_c=1;var s="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,i="[object Function]",n=function(b,T){for(var C=[],x=0;x<b.length;x+=1)C[x]=b[x];for(var $=0;$<T.length;$+=1)C[$+b.length]=T[$];return C},o=function(b,T){for(var C=[],x=T,$=0;x<b.length;x+=1,$+=1)C[$]=b[x];return C},h=function(c,b){for(var T="",C=0;C<c.length;C+=1)T+=c[C],C+1<c.length&&(T+=b);return T};return uh=function(b){var T=this;if(typeof T!="function"||t.apply(T)!==i)throw new TypeError(s+T);for(var C=o(arguments,1),x,$=function(){if(this instanceof x){var z=T.apply(this,n(C,arguments));return Object(z)===z?z:this}return T.apply(b,n(C,arguments))},I=r(0,T.length-C.length),B=[],U=0;U<I;U++)B[U]="$"+U;if(x=Function("binder","return function ("+h(B,",")+"){ return binder.apply(this,arguments); }")($),T.prototype){var G=function(){};G.prototype=T.prototype,x.prototype=new G,G.prototype=null}return x},uh}var ch,gc;function fh(){if(gc)return ch;gc=1;var s=G2();return ch=Function.prototype.bind||s,ch}var dh,mc;function V2(){if(mc)return dh;mc=1;var s=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=fh();return dh=r.call(s,t),dh}var ph,yc;function Js(){if(yc)return ph;yc=1;var s,t=I2(),r=F2(),i=L2(),n=k2(),o=lc(),h=Pn(),c=B2(),b=Function,T=function(nt){try{return b('"use strict"; return ('+nt+").constructor;")()}catch{}},C=Object.getOwnPropertyDescriptor;if(C)try{C({},"")}catch{C=null}var x=function(){throw new h},$=C?function(){try{return arguments.callee,x}catch{try{return C(arguments,"callee").get}catch{return x}}}():x,I=N2()(),B=U2()(),U=Object.getPrototypeOf||(B?function(nt){return nt.__proto__}:null),G={},z=typeof Uint8Array>"u"||!U?s:U(Uint8Array),J={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?s:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?s:ArrayBuffer,"%ArrayIteratorPrototype%":I&&U?U([][Symbol.iterator]()):s,"%AsyncFromSyncIteratorPrototype%":s,"%AsyncFunction%":G,"%AsyncGenerator%":G,"%AsyncGeneratorFunction%":G,"%AsyncIteratorPrototype%":G,"%Atomics%":typeof Atomics>"u"?s:Atomics,"%BigInt%":typeof BigInt>"u"?s:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?s:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?s:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?s:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":r,"%Float32Array%":typeof Float32Array>"u"?s:Float32Array,"%Float64Array%":typeof Float64Array>"u"?s:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?s:FinalizationRegistry,"%Function%":b,"%GeneratorFunction%":G,"%Int8Array%":typeof Int8Array>"u"?s:Int8Array,"%Int16Array%":typeof Int16Array>"u"?s:Int16Array,"%Int32Array%":typeof Int32Array>"u"?s:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":I&&U?U(U([][Symbol.iterator]())):s,"%JSON%":typeof JSON=="object"?JSON:s,"%Map%":typeof Map>"u"?s:Map,"%MapIteratorPrototype%":typeof Map>"u"||!I||!U?s:U(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?s:Promise,"%Proxy%":typeof Proxy>"u"?s:Proxy,"%RangeError%":i,"%ReferenceError%":n,"%Reflect%":typeof Reflect>"u"?s:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?s:Set,"%SetIteratorPrototype%":typeof Set>"u"||!I||!U?s:U(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?s:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":I&&U?U(""[Symbol.iterator]()):s,"%Symbol%":I?Symbol:s,"%SyntaxError%":o,"%ThrowTypeError%":$,"%TypedArray%":z,"%TypeError%":h,"%Uint8Array%":typeof Uint8Array>"u"?s:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?s:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?s:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?s:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap>"u"?s:WeakMap,"%WeakRef%":typeof WeakRef>"u"?s:WeakRef,"%WeakSet%":typeof WeakSet>"u"?s:WeakSet};if(U)try{null.error}catch(nt){var Z=U(U(nt));J["%Error.prototype%"]=Z}var it=function nt(Y){var gt;if(Y==="%AsyncFunction%")gt=T("async function () {}");else if(Y==="%GeneratorFunction%")gt=T("function* () {}");else if(Y==="%AsyncGeneratorFunction%")gt=T("async function* () {}");else if(Y==="%AsyncGenerator%"){var ot=nt("%AsyncGeneratorFunction%");ot&&(gt=ot.prototype)}else if(Y==="%AsyncIteratorPrototype%"){var ht=nt("%AsyncGenerator%");ht&&U&&(gt=U(ht.prototype))}return J[Y]=gt,gt},Q={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},_t=fh(),et=V2(),ft=_t.call(Function.call,Array.prototype.concat),wt=_t.call(Function.apply,Array.prototype.splice),Dt=_t.call(Function.call,String.prototype.replace),Rt=_t.call(Function.call,String.prototype.slice),pt=_t.call(Function.call,RegExp.prototype.exec),xt=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ct=/\\(\\)?/g,Gt=function(Y){var gt=Rt(Y,0,1),ot=Rt(Y,-1);if(gt==="%"&&ot!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(ot==="%"&&gt!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var ht=[];return Dt(Y,xt,function(dt,At,Et,It){ht[ht.length]=Et?Dt(It,Ct,"$1"):At||dt}),ht},st=function(Y,gt){var ot=Y,ht;if(et(Q,ot)&&(ht=Q[ot],ot="%"+ht[0]+"%"),et(J,ot)){var dt=J[ot];if(dt===G&&(dt=it(ot)),typeof dt>"u"&&!gt)throw new h("intrinsic "+Y+" exists, but is not available. Please file an issue!");return{alias:ht,name:ot,value:dt}}throw new o("intrinsic "+Y+" does not exist!")};return ph=function(Y,gt){if(typeof Y!="string"||Y.length===0)throw new h("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof gt!="boolean")throw new h('"allowMissing" argument must be a boolean');if(pt(/^%?[^%]*%?$/,Y)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var ot=Gt(Y),ht=ot.length>0?ot[0]:"",dt=st("%"+ht+"%",gt),At=dt.name,Et=dt.value,It=!1,oe=dt.alias;oe&&(ht=oe[0],wt(ot,ft([0,1],oe)));for(var Bt=1,se=!0;Bt<ot.length;Bt+=1){var Jt=ot[Bt],zt=Rt(Jt,0,1),_e=Rt(Jt,-1);if((zt==='"'||zt==="'"||zt==="`"||_e==='"'||_e==="'"||_e==="`")&&zt!==_e)throw new o("property names with quotes must have matching quotes");if((Jt==="constructor"||!se)&&(It=!0),ht+="."+Jt,At="%"+ht+"%",et(J,At))Et=J[At];else if(Et!=null){if(!(Jt in Et)){if(!gt)throw new h("base intrinsic for "+Y+" exists, but the property is not available.");return}if(C&&Bt+1>=ot.length){var $e=C(Et,Jt);se=!!$e,se&&"get"in $e&&!("originalValue"in $e.get)?Et=$e.get:Et=Et[Jt]}else se=et(Et,Jt),Et=Et[Jt];se&&!It&&(J[At]=Et)}}return Et},ph}var _h={exports:{}},gh,vc;function mh(){if(vc)return gh;vc=1;var s=Js(),t=s("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return gh=t,gh}var yh,xc;function bc(){if(xc)return yh;xc=1;var s=Js(),t=s("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch{t=null}return yh=t,yh}var vh,Ac;function X2(){if(Ac)return vh;Ac=1;var s=mh(),t=lc(),r=Pn(),i=bc();return vh=function(o,h,c){if(!o||typeof o!="object"&&typeof o!="function")throw new r("`obj` must be an object or a function`");if(typeof h!="string"&&typeof h!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var b=arguments.length>3?arguments[3]:null,T=arguments.length>4?arguments[4]:null,C=arguments.length>5?arguments[5]:null,x=arguments.length>6?arguments[6]:!1,$=!!i&&i(o,h);if(s)s(o,h,{configurable:C===null&&$?$.configurable:!C,enumerable:b===null&&$?$.enumerable:!b,value:c,writable:T===null&&$?$.writable:!T});else if(x||!b&&!T&&!C)o[h]=c;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},vh}var xh,wc;function z2(){if(wc)return xh;wc=1;var s=mh(),t=function(){return!!s};return t.hasArrayLengthDefineBug=function(){if(!s)return null;try{return s([],"length",{value:1}).length!==1}catch{return!0}},xh=t,xh}var bh,Tc;function W2(){if(Tc)return bh;Tc=1;var s=Js(),t=X2(),r=z2()(),i=bc(),n=Pn(),o=s("%Math.floor%");return bh=function(c,b){if(typeof c!="function")throw new n("`fn` is not a function");if(typeof b!="number"||b<0||b>4294967295||o(b)!==b)throw new n("`length` must be a positive 32-bit integer");var T=arguments.length>2&&!!arguments[2],C=!0,x=!0;if("length"in c&&i){var $=i(c,"length");$&&!$.configurable&&(C=!1),$&&!$.writable&&(x=!1)}return(C||x||!T)&&(r?t(c,"length",b,!0,!0):t(c,"length",b)),c},bh}var Ec;function H2(){return Ec||(Ec=1,function(s){var t=fh(),r=Js(),i=W2(),n=Pn(),o=r("%Function.prototype.apply%"),h=r("%Function.prototype.call%"),c=r("%Reflect.apply%",!0)||t.call(h,o),b=mh(),T=r("%Math.max%");s.exports=function($){if(typeof $!="function")throw new n("a function is required");var I=c(t,h,arguments);return i(I,1+T(0,$.length-(arguments.length-1)),!0)};var C=function(){return c(t,o,arguments)};b?b(s.exports,"apply",{value:C}):s.exports.apply=C}(_h)),_h.exports}var Ah,Cc;function Y2(){if(Cc)return Ah;Cc=1;var s=Js(),t=H2(),r=t(s("String.prototype.indexOf"));return Ah=function(n,o){var h=s(n,!!o);return typeof h=="function"&&r(n,".prototype.")>-1?t(h):h},Ah}const j2=C2(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var wh,Sc;function q2(){if(Sc)return wh;Sc=1;var s=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&s?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,r=s&&t&&typeof t.get=="function"?t.get:null,i=s&&Map.prototype.forEach,n=typeof Set=="function"&&Set.prototype,o=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,h=n&&o&&typeof o.get=="function"?o.get:null,c=n&&Set.prototype.forEach,b=typeof WeakMap=="function"&&WeakMap.prototype,T=b?WeakMap.prototype.has:null,C=typeof WeakSet=="function"&&WeakSet.prototype,x=C?WeakSet.prototype.has:null,$=typeof WeakRef=="function"&&WeakRef.prototype,I=$?WeakRef.prototype.deref:null,B=Boolean.prototype.valueOf,U=Object.prototype.toString,G=Function.prototype.toString,z=String.prototype.match,J=String.prototype.slice,Z=String.prototype.replace,it=String.prototype.toUpperCase,Q=String.prototype.toLowerCase,_t=RegExp.prototype.test,et=Array.prototype.concat,ft=Array.prototype.join,wt=Array.prototype.slice,Dt=Math.floor,Rt=typeof BigInt=="function"?BigInt.prototype.valueOf:null,pt=Object.getOwnPropertySymbols,xt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ct=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Gt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ct||!0)?Symbol.toStringTag:null,st=Object.prototype.propertyIsEnumerable,nt=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(at){return at.__proto__}:null);function Y(at,lt){if(at===1/0||at===-1/0||at!==at||at&&at>-1e3&&at<1e3||_t.call(/e/,lt))return lt;var Wt=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof at=="number"){var Ae=at<0?-Dt(-at):Dt(at);if(Ae!==at){var de=String(Ae),Yt=J.call(lt,de.length+1);return Z.call(de,Wt,"$&_")+"."+Z.call(Z.call(Yt,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Z.call(lt,Wt,"$&_")}var gt=j2,ot=gt.custom,ht=_e(ot)?ot:null;wh=function at(lt,Wt,Ae,de){var Yt=Wt||{};if(Ie(Yt,"quoteStyle")&&Yt.quoteStyle!=="single"&&Yt.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ie(Yt,"maxStringLength")&&(typeof Yt.maxStringLength=="number"?Yt.maxStringLength<0&&Yt.maxStringLength!==1/0:Yt.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Xe=Ie(Yt,"customInspect")?Yt.customInspect:!0;if(typeof Xe!="boolean"&&Xe!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ie(Yt,"indent")&&Yt.indent!==null&&Yt.indent!==" "&&!(parseInt(Yt.indent,10)===Yt.indent&&Yt.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ie(Yt,"numericSeparator")&&typeof Yt.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var je=Yt.numericSeparator;if(typeof lt>"u")return"undefined";if(lt===null)return"null";if(typeof lt=="boolean")return lt?"true":"false";if(typeof lt=="string")return wr(lt,Yt);if(typeof lt=="number"){if(lt===0)return 1/0/lt>0?"0":"-0";var Qt=String(lt);return je?Y(lt,Qt):Qt}if(typeof lt=="bigint"){var Xt=String(lt)+"n";return je?Y(lt,Xt):Xt}var l=typeof Yt.depth>"u"?5:Yt.depth;if(typeof Ae>"u"&&(Ae=0),Ae>=l&&l>0&&typeof lt=="object")return Et(lt)?"[Array]":"[Object]";var w=Qr(Yt,Ae);if(typeof de>"u")de=[];else if(Lr(de,lt)>=0)return"[Circular]";function M(Lt,re,Zt){if(re&&(de=wt.call(de),de.push(re)),Zt){var K={depth:Yt.depth};return Ie(Yt,"quoteStyle")&&(K.quoteStyle=Yt.quoteStyle),at(Lt,K,Ae+1,de)}return at(Lt,Yt,Ae+1,de)}if(typeof lt=="function"&&!oe(lt)){var L=ae(lt),O=$t(lt,M);return"[Function"+(L?": "+L:" (anonymous)")+"]"+(O.length>0?" { "+ft.call(O,", ")+" }":"")}if(_e(lt)){var N=Ct?Z.call(String(lt),/^(Symbol\(.*\))_[^)]*$/,"$1"):xt.call(lt);return typeof lt=="object"&&!Ct?ze(N):N}if(Pt(lt)){for(var e="<"+Q.call(String(lt.nodeName)),H=lt.attributes||[],W=0;W<H.length;W++)e+=" "+H[W].name+"="+dt(At(H[W].value),"double",Yt);return e+=">",lt.childNodes&&lt.childNodes.length&&(e+="..."),e+="</"+Q.call(String(lt.nodeName))+">",e}if(Et(lt)){if(lt.length===0)return"[]";var rt=$t(lt,M);return w&&!hr(rt)?"["+Tt(rt,w)+"]":"[ "+ft.call(rt,", ")+" ]"}if(Bt(lt)){var R=$t(lt,M);return!("cause"in Error.prototype)&&"cause"in lt&&!st.call(lt,"cause")?"{ ["+String(lt)+"] "+ft.call(et.call("[cause]: "+M(lt.cause),R),", ")+" }":R.length===0?"["+String(lt)+"]":"{ ["+String(lt)+"] "+ft.call(R,", ")+" }"}if(typeof lt=="object"&&Xe){if(ht&&typeof lt[ht]=="function"&&gt)return gt(lt,{depth:l-Ae});if(Xe!=="symbol"&&typeof lt.inspect=="function")return lt.inspect()}if(xr(lt)){var ct=[];return i&&i.call(lt,function(Lt,re){ct.push(M(re,lt,!0)+" => "+M(Lt,lt))}),Ds("Map",r.call(lt),ct,w)}if(Wr(lt)){var j=[];return c&&c.call(lt,function(Lt){j.push(M(Lt,lt))}),Ds("Set",h.call(lt),j,w)}if(Fi(lt))return Li("WeakMap");if(dr(lt))return Li("WeakSet");if(sr(lt))return Li("WeakRef");if(Jt(lt))return ze(M(Number(lt)));if($e(lt))return ze(M(Rt.call(lt)));if(zt(lt))return ze(B.call(lt));if(se(lt))return ze(M(String(lt)));if(typeof window<"u"&&lt===window)return"{ [object Window] }";if(lt===Ka)return"{ [object globalThis] }";if(!It(lt)&&!oe(lt)){var v=$t(lt,M),St=nt?nt(lt)===Object.prototype:lt instanceof Object||lt.constructor===Object,yt=lt instanceof Object?"":"null prototype",Mt=!St&&Gt&&Object(lt)===lt&&Gt in lt?J.call(xe(lt),8,-1):yt?"Object":"",Ft=St||typeof lt.constructor!="function"?"":lt.constructor.name?lt.constructor.name+" ":"",Nt=Ft+(Mt||yt?"["+ft.call(et.call([],Mt||[],yt||[]),": ")+"] ":"");return v.length===0?Nt+"{}":w?Nt+"{"+Tt(v,w)+"}":Nt+"{ "+ft.call(v,", ")+" }"}return String(lt)};function dt(at,lt,Wt){var Ae=(Wt.quoteStyle||lt)==="double"?'"':"'";return Ae+at+Ae}function At(at){return Z.call(String(at),/"/g,"&quot;")}function Et(at){return xe(at)==="[object Array]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function It(at){return xe(at)==="[object Date]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function oe(at){return xe(at)==="[object RegExp]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function Bt(at){return xe(at)==="[object Error]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function se(at){return xe(at)==="[object String]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function Jt(at){return xe(at)==="[object Number]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function zt(at){return xe(at)==="[object Boolean]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function _e(at){if(Ct)return at&&typeof at=="object"&&at instanceof Symbol;if(typeof at=="symbol")return!0;if(!at||typeof at!="object"||!xt)return!1;try{return xt.call(at),!0}catch{}return!1}function $e(at){if(!at||typeof at!="object"||!Rt)return!1;try{return Rt.call(at),!0}catch{}return!1}var te=Object.prototype.hasOwnProperty||function(at){return at in this};function Ie(at,lt){return te.call(at,lt)}function xe(at){return U.call(at)}function ae(at){if(at.name)return at.name;var lt=z.call(G.call(at),/^function\s*([\w$]+)/);return lt?lt[1]:null}function Lr(at,lt){if(at.indexOf)return at.indexOf(lt);for(var Wt=0,Ae=at.length;Wt<Ae;Wt++)if(at[Wt]===lt)return Wt;return-1}function xr(at){if(!r||!at||typeof at!="object")return!1;try{r.call(at);try{h.call(at)}catch{return!0}return at instanceof Map}catch{}return!1}function Fi(at){if(!T||!at||typeof at!="object")return!1;try{T.call(at,T);try{x.call(at,x)}catch{return!0}return at instanceof WeakMap}catch{}return!1}function sr(at){if(!I||!at||typeof at!="object")return!1;try{return I.call(at),!0}catch{}return!1}function Wr(at){if(!h||!at||typeof at!="object")return!1;try{h.call(at);try{r.call(at)}catch{return!0}return at instanceof Set}catch{}return!1}function dr(at){if(!x||!at||typeof at!="object")return!1;try{x.call(at,x);try{T.call(at,T)}catch{return!0}return at instanceof WeakSet}catch{}return!1}function Pt(at){return!at||typeof at!="object"?!1:typeof HTMLElement<"u"&&at instanceof HTMLElement?!0:typeof at.nodeName=="string"&&typeof at.getAttribute=="function"}function wr(at,lt){if(at.length>lt.maxStringLength){var Wt=at.length-lt.maxStringLength,Ae="... "+Wt+" more character"+(Wt>1?"s":"");return wr(J.call(at,0,lt.maxStringLength),lt)+Ae}var de=Z.call(Z.call(at,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Hr);return dt(de,"single",lt)}function Hr(at){var lt=at.charCodeAt(0),Wt={8:"b",9:"t",10:"n",12:"f",13:"r"}[lt];return Wt?"\\"+Wt:"\\x"+(lt<16?"0":"")+it.call(lt.toString(16))}function ze(at){return"Object("+at+")"}function Li(at){return at+" { ? }"}function Ds(at,lt,Wt,Ae){var de=Ae?Tt(Wt,Ae):ft.call(Wt,", ");return at+" ("+lt+") {"+de+"}"}function hr(at){for(var lt=0;lt<at.length;lt++)if(Lr(at[lt],`
44
- `)>=0)return!1;return!0}function Qr(at,lt){var Wt;if(at.indent===" ")Wt=" ";else if(typeof at.indent=="number"&&at.indent>0)Wt=ft.call(Array(at.indent+1)," ");else return null;return{base:Wt,prev:ft.call(Array(lt+1),Wt)}}function Tt(at,lt){if(at.length===0)return"";var Wt=`
45
- `+lt.prev+lt.base;return Wt+ft.call(at,","+Wt)+`
46
- `+lt.prev}function $t(at,lt){var Wt=Et(at),Ae=[];if(Wt){Ae.length=at.length;for(var de=0;de<at.length;de++)Ae[de]=Ie(at,de)?lt(at[de],at):""}var Yt=typeof pt=="function"?pt(at):[],Xe;if(Ct){Xe={};for(var je=0;je<Yt.length;je++)Xe["$"+Yt[je]]=Yt[je]}for(var Qt in at)Ie(at,Qt)&&(Wt&&String(Number(Qt))===Qt&&Qt<at.length||Ct&&Xe["$"+Qt]instanceof Symbol||(_t.call(/[^\w$]/,Qt)?Ae.push(lt(Qt,at)+": "+lt(at[Qt],at)):Ae.push(Qt+": "+lt(at[Qt],at))));if(typeof pt=="function")for(var Xt=0;Xt<Yt.length;Xt++)st.call(at,Yt[Xt])&&Ae.push("["+lt(Yt[Xt])+"]: "+lt(at[Yt[Xt]],at));return Ae}return wh}var Th,Pc;function Z2(){if(Pc)return Th;Pc=1;var s=Js(),t=Y2(),r=q2(),i=Pn(),n=s("%WeakMap%",!0),o=s("%Map%",!0),h=t("WeakMap.prototype.get",!0),c=t("WeakMap.prototype.set",!0),b=t("WeakMap.prototype.has",!0),T=t("Map.prototype.get",!0),C=t("Map.prototype.set",!0),x=t("Map.prototype.has",!0),$=function(G,z){for(var J=G,Z;(Z=J.next)!==null;J=Z)if(Z.key===z)return J.next=Z.next,Z.next=G.next,G.next=Z,Z},I=function(G,z){var J=$(G,z);return J&&J.value},B=function(G,z,J){var Z=$(G,z);Z?Z.value=J:G.next={key:z,next:G.next,value:J}},U=function(G,z){return!!$(G,z)};return Th=function(){var z,J,Z,it={assert:function(Q){if(!it.has(Q))throw new i("Side channel does not contain "+r(Q))},get:function(Q){if(n&&Q&&(typeof Q=="object"||typeof Q=="function")){if(z)return h(z,Q)}else if(o){if(J)return T(J,Q)}else if(Z)return I(Z,Q)},has:function(Q){if(n&&Q&&(typeof Q=="object"||typeof Q=="function")){if(z)return b(z,Q)}else if(o){if(J)return x(J,Q)}else if(Z)return U(Z,Q);return!1},set:function(Q,_t){n&&Q&&(typeof Q=="object"||typeof Q=="function")?(z||(z=new n),c(z,Q,_t)):o?(J||(J=new o),C(J,Q,_t)):(Z||(Z={key:{},next:null}),B(Z,Q,_t))}};return it},Th}var Eh,$c;function Ch(){if($c)return Eh;$c=1;var s=String.prototype.replace,t=/%20/g,r={RFC1738:"RFC1738",RFC3986:"RFC3986"};return Eh={default:r.RFC3986,formatters:{RFC1738:function(i){return s.call(i,t,"+")},RFC3986:function(i){return String(i)}},RFC1738:r.RFC1738,RFC3986:r.RFC3986},Eh}var Sh,Mc;function Dc(){if(Mc)return Sh;Mc=1;var s=Ch(),t=Object.prototype.hasOwnProperty,r=Array.isArray,i=function(){for(var G=[],z=0;z<256;++z)G.push("%"+((z<16?"0":"")+z.toString(16)).toUpperCase());return G}(),n=function(z){for(;z.length>1;){var J=z.pop(),Z=J.obj[J.prop];if(r(Z)){for(var it=[],Q=0;Q<Z.length;++Q)typeof Z[Q]<"u"&&it.push(Z[Q]);J.obj[J.prop]=it}}},o=function(z,J){for(var Z=J&&J.plainObjects?Object.create(null):{},it=0;it<z.length;++it)typeof z[it]<"u"&&(Z[it]=z[it]);return Z},h=function G(z,J,Z){if(!J)return z;if(typeof J!="object"){if(r(z))z.push(J);else if(z&&typeof z=="object")(Z&&(Z.plainObjects||Z.allowPrototypes)||!t.call(Object.prototype,J))&&(z[J]=!0);else return[z,J];return z}if(!z||typeof z!="object")return[z].concat(J);var it=z;return r(z)&&!r(J)&&(it=o(z,Z)),r(z)&&r(J)?(J.forEach(function(Q,_t){if(t.call(z,_t)){var et=z[_t];et&&typeof et=="object"&&Q&&typeof Q=="object"?z[_t]=G(et,Q,Z):z.push(Q)}else z[_t]=Q}),z):Object.keys(J).reduce(function(Q,_t){var et=J[_t];return t.call(Q,_t)?Q[_t]=G(Q[_t],et,Z):Q[_t]=et,Q},it)},c=function(z,J){return Object.keys(J).reduce(function(Z,it){return Z[it]=J[it],Z},z)},b=function(G,z,J){var Z=G.replace(/\+/g," ");if(J==="iso-8859-1")return Z.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(Z)}catch{return Z}},T=1024,C=function(z,J,Z,it,Q){if(z.length===0)return z;var _t=z;if(typeof z=="symbol"?_t=Symbol.prototype.toString.call(z):typeof z!="string"&&(_t=String(z)),Z==="iso-8859-1")return escape(_t).replace(/%u[0-9a-f]{4}/gi,function(xt){return"%26%23"+parseInt(xt.slice(2),16)+"%3B"});for(var et="",ft=0;ft<_t.length;ft+=T){for(var wt=_t.length>=T?_t.slice(ft,ft+T):_t,Dt=[],Rt=0;Rt<wt.length;++Rt){var pt=wt.charCodeAt(Rt);if(pt===45||pt===46||pt===95||pt===126||pt>=48&&pt<=57||pt>=65&&pt<=90||pt>=97&&pt<=122||Q===s.RFC1738&&(pt===40||pt===41)){Dt[Dt.length]=wt.charAt(Rt);continue}if(pt<128){Dt[Dt.length]=i[pt];continue}if(pt<2048){Dt[Dt.length]=i[192|pt>>6]+i[128|pt&63];continue}if(pt<55296||pt>=57344){Dt[Dt.length]=i[224|pt>>12]+i[128|pt>>6&63]+i[128|pt&63];continue}Rt+=1,pt=65536+((pt&1023)<<10|wt.charCodeAt(Rt)&1023),Dt[Dt.length]=i[240|pt>>18]+i[128|pt>>12&63]+i[128|pt>>6&63]+i[128|pt&63]}et+=Dt.join("")}return et},x=function(z){for(var J=[{obj:{o:z},prop:"o"}],Z=[],it=0;it<J.length;++it)for(var Q=J[it],_t=Q.obj[Q.prop],et=Object.keys(_t),ft=0;ft<et.length;++ft){var wt=et[ft],Dt=_t[wt];typeof Dt=="object"&&Dt!==null&&Z.indexOf(Dt)===-1&&(J.push({obj:_t,prop:wt}),Z.push(Dt))}return n(J),z},$=function(z){return Object.prototype.toString.call(z)==="[object RegExp]"},I=function(z){return!z||typeof z!="object"?!1:!!(z.constructor&&z.constructor.isBuffer&&z.constructor.isBuffer(z))},B=function(z,J){return[].concat(z,J)},U=function(z,J){if(r(z)){for(var Z=[],it=0;it<z.length;it+=1)Z.push(J(z[it]));return Z}return J(z)};return Sh={arrayToObject:o,assign:c,combine:B,compact:x,decode:b,encode:C,isBuffer:I,isRegExp:$,maybeMap:U,merge:h},Sh}var Ph,Rc;function Q2(){if(Rc)return Ph;Rc=1;var s=Z2(),t=Dc(),r=Ch(),i=Object.prototype.hasOwnProperty,n={brackets:function(G){return G+"[]"},comma:"comma",indices:function(G,z){return G+"["+z+"]"},repeat:function(G){return G}},o=Array.isArray,h=Array.prototype.push,c=function(U,G){h.apply(U,o(G)?G:[G])},b=Date.prototype.toISOString,T=r.default,C={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:t.encode,encodeValuesOnly:!1,format:T,formatter:r.formatters[T],indices:!1,serializeDate:function(G){return b.call(G)},skipNulls:!1,strictNullHandling:!1},x=function(G){return typeof G=="string"||typeof G=="number"||typeof G=="boolean"||typeof G=="symbol"||typeof G=="bigint"},$={},I=function U(G,z,J,Z,it,Q,_t,et,ft,wt,Dt,Rt,pt,xt,Ct,Gt,st,nt){for(var Y=G,gt=nt,ot=0,ht=!1;(gt=gt.get($))!==void 0&&!ht;){var dt=gt.get(G);if(ot+=1,typeof dt<"u"){if(dt===ot)throw new RangeError("Cyclic object value");ht=!0}typeof gt.get($)>"u"&&(ot=0)}if(typeof wt=="function"?Y=wt(z,Y):Y instanceof Date?Y=pt(Y):J==="comma"&&o(Y)&&(Y=t.maybeMap(Y,function(xe){return xe instanceof Date?pt(xe):xe})),Y===null){if(Q)return ft&&!Gt?ft(z,C.encoder,st,"key",xt):z;Y=""}if(x(Y)||t.isBuffer(Y)){if(ft){var At=Gt?z:ft(z,C.encoder,st,"key",xt);return[Ct(At)+"="+Ct(ft(Y,C.encoder,st,"value",xt))]}return[Ct(z)+"="+Ct(String(Y))]}var Et=[];if(typeof Y>"u")return Et;var It;if(J==="comma"&&o(Y))Gt&&ft&&(Y=t.maybeMap(Y,ft)),It=[{value:Y.length>0?Y.join(",")||null:void 0}];else if(o(wt))It=wt;else{var oe=Object.keys(Y);It=Dt?oe.sort(Dt):oe}var Bt=et?z.replace(/\./g,"%2E"):z,se=Z&&o(Y)&&Y.length===1?Bt+"[]":Bt;if(it&&o(Y)&&Y.length===0)return se+"[]";for(var Jt=0;Jt<It.length;++Jt){var zt=It[Jt],_e=typeof zt=="object"&&typeof zt.value<"u"?zt.value:Y[zt];if(!(_t&&_e===null)){var $e=Rt&&et?zt.replace(/\./g,"%2E"):zt,te=o(Y)?typeof J=="function"?J(se,$e):se:se+(Rt?"."+$e:"["+$e+"]");nt.set(G,ot);var Ie=s();Ie.set($,nt),c(Et,U(_e,te,J,Z,it,Q,_t,et,J==="comma"&&Gt&&o(Y)?null:ft,wt,Dt,Rt,pt,xt,Ct,Gt,st,Ie))}}return Et},B=function(G){if(!G)return C;if(typeof G.allowEmptyArrays<"u"&&typeof G.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof G.encodeDotInKeys<"u"&&typeof G.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(G.encoder!==null&&typeof G.encoder<"u"&&typeof G.encoder!="function")throw new TypeError("Encoder has to be a function.");var z=G.charset||C.charset;if(typeof G.charset<"u"&&G.charset!=="utf-8"&&G.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var J=r.default;if(typeof G.format<"u"){if(!i.call(r.formatters,G.format))throw new TypeError("Unknown format option provided.");J=G.format}var Z=r.formatters[J],it=C.filter;(typeof G.filter=="function"||o(G.filter))&&(it=G.filter);var Q;if(G.arrayFormat in n?Q=G.arrayFormat:"indices"in G?Q=G.indices?"indices":"repeat":Q=C.arrayFormat,"commaRoundTrip"in G&&typeof G.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var _t=typeof G.allowDots>"u"?G.encodeDotInKeys===!0?!0:C.allowDots:!!G.allowDots;return{addQueryPrefix:typeof G.addQueryPrefix=="boolean"?G.addQueryPrefix:C.addQueryPrefix,allowDots:_t,allowEmptyArrays:typeof G.allowEmptyArrays=="boolean"?!!G.allowEmptyArrays:C.allowEmptyArrays,arrayFormat:Q,charset:z,charsetSentinel:typeof G.charsetSentinel=="boolean"?G.charsetSentinel:C.charsetSentinel,commaRoundTrip:G.commaRoundTrip,delimiter:typeof G.delimiter>"u"?C.delimiter:G.delimiter,encode:typeof G.encode=="boolean"?G.encode:C.encode,encodeDotInKeys:typeof G.encodeDotInKeys=="boolean"?G.encodeDotInKeys:C.encodeDotInKeys,encoder:typeof G.encoder=="function"?G.encoder:C.encoder,encodeValuesOnly:typeof G.encodeValuesOnly=="boolean"?G.encodeValuesOnly:C.encodeValuesOnly,filter:it,format:J,formatter:Z,serializeDate:typeof G.serializeDate=="function"?G.serializeDate:C.serializeDate,skipNulls:typeof G.skipNulls=="boolean"?G.skipNulls:C.skipNulls,sort:typeof G.sort=="function"?G.sort:null,strictNullHandling:typeof G.strictNullHandling=="boolean"?G.strictNullHandling:C.strictNullHandling}};return Ph=function(U,G){var z=U,J=B(G),Z,it;typeof J.filter=="function"?(it=J.filter,z=it("",z)):o(J.filter)&&(it=J.filter,Z=it);var Q=[];if(typeof z!="object"||z===null)return"";var _t=n[J.arrayFormat],et=_t==="comma"&&J.commaRoundTrip;Z||(Z=Object.keys(z)),J.sort&&Z.sort(J.sort);for(var ft=s(),wt=0;wt<Z.length;++wt){var Dt=Z[wt];J.skipNulls&&z[Dt]===null||c(Q,I(z[Dt],Dt,_t,et,J.allowEmptyArrays,J.strictNullHandling,J.skipNulls,J.encodeDotInKeys,J.encode?J.encoder:null,J.filter,J.sort,J.allowDots,J.serializeDate,J.format,J.formatter,J.encodeValuesOnly,J.charset,ft))}var Rt=Q.join(J.delimiter),pt=J.addQueryPrefix===!0?"?":"";return J.charsetSentinel&&(J.charset==="iso-8859-1"?pt+="utf8=%26%2310003%3B&":pt+="utf8=%E2%9C%93&"),Rt.length>0?pt+Rt:""},Ph}var $h,Ic;function K2(){if(Ic)return $h;Ic=1;var s=Dc(),t=Object.prototype.hasOwnProperty,r=Array.isArray,i={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:s.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},n=function($){return $.replace(/&#(\d+);/g,function(I,B){return String.fromCharCode(parseInt(B,10))})},o=function($,I){return $&&typeof $=="string"&&I.comma&&$.indexOf(",")>-1?$.split(","):$},h="utf8=%26%2310003%3B",c="utf8=%E2%9C%93",b=function(I,B){var U={__proto__:null},G=B.ignoreQueryPrefix?I.replace(/^\?/,""):I;G=G.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var z=B.parameterLimit===1/0?void 0:B.parameterLimit,J=G.split(B.delimiter,z),Z=-1,it,Q=B.charset;if(B.charsetSentinel)for(it=0;it<J.length;++it)J[it].indexOf("utf8=")===0&&(J[it]===c?Q="utf-8":J[it]===h&&(Q="iso-8859-1"),Z=it,it=J.length);for(it=0;it<J.length;++it)if(it!==Z){var _t=J[it],et=_t.indexOf("]="),ft=et===-1?_t.indexOf("="):et+1,wt,Dt;ft===-1?(wt=B.decoder(_t,i.decoder,Q,"key"),Dt=B.strictNullHandling?null:""):(wt=B.decoder(_t.slice(0,ft),i.decoder,Q,"key"),Dt=s.maybeMap(o(_t.slice(ft+1),B),function(pt){return B.decoder(pt,i.decoder,Q,"value")})),Dt&&B.interpretNumericEntities&&Q==="iso-8859-1"&&(Dt=n(Dt)),_t.indexOf("[]=")>-1&&(Dt=r(Dt)?[Dt]:Dt);var Rt=t.call(U,wt);Rt&&B.duplicates==="combine"?U[wt]=s.combine(U[wt],Dt):(!Rt||B.duplicates==="last")&&(U[wt]=Dt)}return U},T=function($,I,B,U){for(var G=U?I:o(I,B),z=$.length-1;z>=0;--z){var J,Z=$[z];if(Z==="[]"&&B.parseArrays)J=B.allowEmptyArrays&&(G===""||B.strictNullHandling&&G===null)?[]:[].concat(G);else{J=B.plainObjects?Object.create(null):{};var it=Z.charAt(0)==="["&&Z.charAt(Z.length-1)==="]"?Z.slice(1,-1):Z,Q=B.decodeDotInKeys?it.replace(/%2E/g,"."):it,_t=parseInt(Q,10);!B.parseArrays&&Q===""?J={0:G}:!isNaN(_t)&&Z!==Q&&String(_t)===Q&&_t>=0&&B.parseArrays&&_t<=B.arrayLimit?(J=[],J[_t]=G):Q!=="__proto__"&&(J[Q]=G)}G=J}return G},C=function(I,B,U,G){if(I){var z=U.allowDots?I.replace(/\.([^.[]+)/g,"[$1]"):I,J=/(\[[^[\]]*])/,Z=/(\[[^[\]]*])/g,it=U.depth>0&&J.exec(z),Q=it?z.slice(0,it.index):z,_t=[];if(Q){if(!U.plainObjects&&t.call(Object.prototype,Q)&&!U.allowPrototypes)return;_t.push(Q)}for(var et=0;U.depth>0&&(it=Z.exec(z))!==null&&et<U.depth;){if(et+=1,!U.plainObjects&&t.call(Object.prototype,it[1].slice(1,-1))&&!U.allowPrototypes)return;_t.push(it[1])}if(it){if(U.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+U.depth+" and strictDepth is true");_t.push("["+z.slice(it.index)+"]")}return T(_t,B,U,G)}},x=function(I){if(!I)return i;if(typeof I.allowEmptyArrays<"u"&&typeof I.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof I.decodeDotInKeys<"u"&&typeof I.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(I.decoder!==null&&typeof I.decoder<"u"&&typeof I.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof I.charset<"u"&&I.charset!=="utf-8"&&I.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var B=typeof I.charset>"u"?i.charset:I.charset,U=typeof I.duplicates>"u"?i.duplicates:I.duplicates;if(U!=="combine"&&U!=="first"&&U!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var G=typeof I.allowDots>"u"?I.decodeDotInKeys===!0?!0:i.allowDots:!!I.allowDots;return{allowDots:G,allowEmptyArrays:typeof I.allowEmptyArrays=="boolean"?!!I.allowEmptyArrays:i.allowEmptyArrays,allowPrototypes:typeof I.allowPrototypes=="boolean"?I.allowPrototypes:i.allowPrototypes,allowSparse:typeof I.allowSparse=="boolean"?I.allowSparse:i.allowSparse,arrayLimit:typeof I.arrayLimit=="number"?I.arrayLimit:i.arrayLimit,charset:B,charsetSentinel:typeof I.charsetSentinel=="boolean"?I.charsetSentinel:i.charsetSentinel,comma:typeof I.comma=="boolean"?I.comma:i.comma,decodeDotInKeys:typeof I.decodeDotInKeys=="boolean"?I.decodeDotInKeys:i.decodeDotInKeys,decoder:typeof I.decoder=="function"?I.decoder:i.decoder,delimiter:typeof I.delimiter=="string"||s.isRegExp(I.delimiter)?I.delimiter:i.delimiter,depth:typeof I.depth=="number"||I.depth===!1?+I.depth:i.depth,duplicates:U,ignoreQueryPrefix:I.ignoreQueryPrefix===!0,interpretNumericEntities:typeof I.interpretNumericEntities=="boolean"?I.interpretNumericEntities:i.interpretNumericEntities,parameterLimit:typeof I.parameterLimit=="number"?I.parameterLimit:i.parameterLimit,parseArrays:I.parseArrays!==!1,plainObjects:typeof I.plainObjects=="boolean"?I.plainObjects:i.plainObjects,strictDepth:typeof I.strictDepth=="boolean"?!!I.strictDepth:i.strictDepth,strictNullHandling:typeof I.strictNullHandling=="boolean"?I.strictNullHandling:i.strictNullHandling}};return $h=function($,I){var B=x(I);if($===""||$===null||typeof $>"u")return B.plainObjects?Object.create(null):{};for(var U=typeof $=="string"?b($,B):$,G=B.plainObjects?Object.create(null):{},z=Object.keys(U),J=0;J<z.length;++J){var Z=z[J],it=C(Z,U[Z],B,typeof $=="string");G=s.merge(G,it,B)}return B.allowSparse===!0?G:s.compact(G)},$h}var Mh,Fc;function J2(){if(Fc)return Mh;Fc=1;var s=Q2(),t=K2(),r=Ch();return Mh={formats:r,parse:t,stringify:s},Mh}var Lc;function tp(){if(Lc)return Ls;Lc=1;var s=R2();function t(){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 r=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,n=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,o=["<",">",'"',"`"," ","\r",`
47
- `," "],h=["{","}","|","\\","^","`"].concat(o),c=["'"].concat(h),b=["%","/","?",";","#"].concat(c),T=["/","?","#"],C=255,x=/^[+a-z0-9A-Z_-]{0,63}$/,$=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,I={javascript:!0,"javascript:":!0},B={javascript:!0,"javascript:":!0},U={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},G=J2();function z(Q,_t,et){if(Q&&typeof Q=="object"&&Q instanceof t)return Q;var ft=new t;return ft.parse(Q,_t,et),ft}t.prototype.parse=function(Q,_t,et){if(typeof Q!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof Q);var ft=Q.indexOf("?"),wt=ft!==-1&&ft<Q.indexOf("#")?"?":"#",Dt=Q.split(wt),Rt=/\\/g;Dt[0]=Dt[0].replace(Rt,"/"),Q=Dt.join(wt);var pt=Q;if(pt=pt.trim(),!et&&Q.split("#").length===1){var xt=n.exec(pt);if(xt)return this.path=pt,this.href=pt,this.pathname=xt[1],xt[2]?(this.search=xt[2],_t?this.query=G.parse(this.search.substr(1)):this.query=this.search.substr(1)):_t&&(this.search="",this.query={}),this}var Ct=r.exec(pt);if(Ct){Ct=Ct[0];var Gt=Ct.toLowerCase();this.protocol=Gt,pt=pt.substr(Ct.length)}if(et||Ct||pt.match(/^\/\/[^@/]+@[^@/]+/)){var st=pt.substr(0,2)==="//";st&&!(Ct&&B[Ct])&&(pt=pt.substr(2),this.slashes=!0)}if(!B[Ct]&&(st||Ct&&!U[Ct])){for(var nt=-1,Y=0;Y<T.length;Y++){var gt=pt.indexOf(T[Y]);gt!==-1&&(nt===-1||gt<nt)&&(nt=gt)}var ot,ht;nt===-1?ht=pt.lastIndexOf("@"):ht=pt.lastIndexOf("@",nt),ht!==-1&&(ot=pt.slice(0,ht),pt=pt.slice(ht+1),this.auth=decodeURIComponent(ot)),nt=-1;for(var Y=0;Y<b.length;Y++){var gt=pt.indexOf(b[Y]);gt!==-1&&(nt===-1||gt<nt)&&(nt=gt)}nt===-1&&(nt=pt.length),this.host=pt.slice(0,nt),pt=pt.slice(nt),this.parseHost(),this.hostname=this.hostname||"";var dt=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!dt)for(var At=this.hostname.split(/\./),Y=0,Et=At.length;Y<Et;Y++){var It=At[Y];if(It&&!It.match(x)){for(var oe="",Bt=0,se=It.length;Bt<se;Bt++)It.charCodeAt(Bt)>127?oe+="x":oe+=It[Bt];if(!oe.match(x)){var Jt=At.slice(0,Y),zt=At.slice(Y+1),_e=It.match($);_e&&(Jt.push(_e[1]),zt.unshift(_e[2])),zt.length&&(pt="/"+zt.join(".")+pt),this.hostname=Jt.join(".");break}}}this.hostname.length>C?this.hostname="":this.hostname=this.hostname.toLowerCase(),dt||(this.hostname=s.toASCII(this.hostname));var $e=this.port?":"+this.port:"",te=this.hostname||"";this.host=te+$e,this.href+=this.host,dt&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),pt[0]!=="/"&&(pt="/"+pt))}if(!I[Gt])for(var Y=0,Et=c.length;Y<Et;Y++){var Ie=c[Y];if(pt.indexOf(Ie)!==-1){var xe=encodeURIComponent(Ie);xe===Ie&&(xe=escape(Ie)),pt=pt.split(Ie).join(xe)}}var ae=pt.indexOf("#");ae!==-1&&(this.hash=pt.substr(ae),pt=pt.slice(0,ae));var Lr=pt.indexOf("?");if(Lr!==-1?(this.search=pt.substr(Lr),this.query=pt.substr(Lr+1),_t&&(this.query=G.parse(this.query)),pt=pt.slice(0,Lr)):_t&&(this.search="",this.query={}),pt&&(this.pathname=pt),U[Gt]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var $e=this.pathname||"",xr=this.search||"";this.path=$e+xr}return this.href=this.format(),this};function J(Q){return typeof Q=="string"&&(Q=z(Q)),Q instanceof t?Q.format():t.prototype.format.call(Q)}t.prototype.format=function(){var Q=this.auth||"";Q&&(Q=encodeURIComponent(Q),Q=Q.replace(/%3A/i,":"),Q+="@");var _t=this.protocol||"",et=this.pathname||"",ft=this.hash||"",wt=!1,Dt="";this.host?wt=Q+this.host:this.hostname&&(wt=Q+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(wt+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(Dt=G.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var Rt=this.search||Dt&&"?"+Dt||"";return _t&&_t.substr(-1)!==":"&&(_t+=":"),this.slashes||(!_t||U[_t])&&wt!==!1?(wt="//"+(wt||""),et&&et.charAt(0)!=="/"&&(et="/"+et)):wt||(wt=""),ft&&ft.charAt(0)!=="#"&&(ft="#"+ft),Rt&&Rt.charAt(0)!=="?"&&(Rt="?"+Rt),et=et.replace(/[?#]/g,function(pt){return encodeURIComponent(pt)}),Rt=Rt.replace("#","%23"),_t+wt+et+Rt+ft};function Z(Q,_t){return z(Q,!1,!0).resolve(_t)}t.prototype.resolve=function(Q){return this.resolveObject(z(Q,!1,!0)).format()};function it(Q,_t){return Q?z(Q,!1,!0).resolveObject(_t):_t}return t.prototype.resolveObject=function(Q){if(typeof Q=="string"){var _t=new t;_t.parse(Q,!1,!0),Q=_t}for(var et=new t,ft=Object.keys(this),wt=0;wt<ft.length;wt++){var Dt=ft[wt];et[Dt]=this[Dt]}if(et.hash=Q.hash,Q.href==="")return et.href=et.format(),et;if(Q.slashes&&!Q.protocol){for(var Rt=Object.keys(Q),pt=0;pt<Rt.length;pt++){var xt=Rt[pt];xt!=="protocol"&&(et[xt]=Q[xt])}return U[et.protocol]&&et.hostname&&!et.pathname&&(et.pathname="/",et.path=et.pathname),et.href=et.format(),et}if(Q.protocol&&Q.protocol!==et.protocol){if(!U[Q.protocol]){for(var Ct=Object.keys(Q),Gt=0;Gt<Ct.length;Gt++){var st=Ct[Gt];et[st]=Q[st]}return et.href=et.format(),et}if(et.protocol=Q.protocol,!Q.host&&!B[Q.protocol]){for(var Et=(Q.pathname||"").split("/");Et.length&&!(Q.host=Et.shift()););Q.host||(Q.host=""),Q.hostname||(Q.hostname=""),Et[0]!==""&&Et.unshift(""),Et.length<2&&Et.unshift(""),et.pathname=Et.join("/")}else et.pathname=Q.pathname;if(et.search=Q.search,et.query=Q.query,et.host=Q.host||"",et.auth=Q.auth,et.hostname=Q.hostname||Q.host,et.port=Q.port,et.pathname||et.search){var nt=et.pathname||"",Y=et.search||"";et.path=nt+Y}return et.slashes=et.slashes||Q.slashes,et.href=et.format(),et}var gt=et.pathname&&et.pathname.charAt(0)==="/",ot=Q.host||Q.pathname&&Q.pathname.charAt(0)==="/",ht=ot||gt||et.host&&Q.pathname,dt=ht,At=et.pathname&&et.pathname.split("/")||[],Et=Q.pathname&&Q.pathname.split("/")||[],It=et.protocol&&!U[et.protocol];if(It&&(et.hostname="",et.port=null,et.host&&(At[0]===""?At[0]=et.host:At.unshift(et.host)),et.host="",Q.protocol&&(Q.hostname=null,Q.port=null,Q.host&&(Et[0]===""?Et[0]=Q.host:Et.unshift(Q.host)),Q.host=null),ht=ht&&(Et[0]===""||At[0]==="")),ot)et.host=Q.host||Q.host===""?Q.host:et.host,et.hostname=Q.hostname||Q.hostname===""?Q.hostname:et.hostname,et.search=Q.search,et.query=Q.query,At=Et;else if(Et.length)At||(At=[]),At.pop(),At=At.concat(Et),et.search=Q.search,et.query=Q.query;else if(Q.search!=null){if(It){et.host=At.shift(),et.hostname=et.host;var oe=et.host&&et.host.indexOf("@")>0?et.host.split("@"):!1;oe&&(et.auth=oe.shift(),et.hostname=oe.shift(),et.host=et.hostname)}return et.search=Q.search,et.query=Q.query,(et.pathname!==null||et.search!==null)&&(et.path=(et.pathname?et.pathname:"")+(et.search?et.search:"")),et.href=et.format(),et}if(!At.length)return et.pathname=null,et.search?et.path="/"+et.search:et.path=null,et.href=et.format(),et;for(var Bt=At.slice(-1)[0],se=(et.host||Q.host||At.length>1)&&(Bt==="."||Bt==="..")||Bt==="",Jt=0,zt=At.length;zt>=0;zt--)Bt=At[zt],Bt==="."?At.splice(zt,1):Bt===".."?(At.splice(zt,1),Jt++):Jt&&(At.splice(zt,1),Jt--);if(!ht&&!dt)for(;Jt--;Jt)At.unshift("..");ht&&At[0]!==""&&(!At[0]||At[0].charAt(0)!=="/")&&At.unshift(""),se&&At.join("/").substr(-1)!=="/"&&At.push("");var _e=At[0]===""||At[0]&&At[0].charAt(0)==="/";if(It){et.hostname=_e?"":At.length?At.shift():"",et.host=et.hostname;var oe=et.host&&et.host.indexOf("@")>0?et.host.split("@"):!1;oe&&(et.auth=oe.shift(),et.hostname=oe.shift(),et.host=et.hostname)}return ht=ht||et.host&&At.length,ht&&!_e&&At.unshift(""),At.length>0?et.pathname=At.join("/"):(et.pathname=null,et.path=null),(et.pathname!==null||et.search!==null)&&(et.path=(et.pathname?et.pathname:"")+(et.search?et.search:"")),et.auth=Q.auth||et.auth,et.slashes=et.slashes||Q.slashes,et.href=et.format(),et},t.prototype.parseHost=function(){var Q=this.host,_t=i.exec(Q);_t&&(_t=_t[0],_t!==":"&&(this.port=_t.substr(1)),Q=Q.substr(0,Q.length-_t.length)),Q&&(this.hostname=Q)},Ls.parse=z,Ls.resolve=Z,Ls.resolveObject=it,Ls.format=J,Ls.Url=t,Ls}var Dh=tp();const kc={};function Oe(s,t,r=3){if(kc[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
1
+ (function(ae,Zt){typeof exports=="object"&&typeof module<"u"?Zt(exports,require("../lib/cubism2.min.js"),require("../lib/cubism5.min.js")):typeof define=="function"&&define.amd?define(["exports","../lib/cubism2.min","../lib/cubism5.min"],Zt):(ae=typeof globalThis<"u"?globalThis:ae||self,Zt(ae.l2d={}))})(this,function(ae){"use strict";var Zt=(s=>(s[s.WEBGL_LEGACY=0]="WEBGL_LEGACY",s[s.WEBGL=1]="WEBGL",s[s.WEBGL2=2]="WEBGL2",s))(Zt||{}),bn=(s=>(s[s.UNKNOWN=0]="UNKNOWN",s[s.WEBGL=1]="WEBGL",s[s.CANVAS=2]="CANVAS",s))(bn||{}),rs=(s=>(s[s.COLOR=16384]="COLOR",s[s.DEPTH=256]="DEPTH",s[s.STENCIL=1024]="STENCIL",s))(rs||{}),nt=(s=>(s[s.NORMAL=0]="NORMAL",s[s.ADD=1]="ADD",s[s.MULTIPLY=2]="MULTIPLY",s[s.SCREEN=3]="SCREEN",s[s.OVERLAY=4]="OVERLAY",s[s.DARKEN=5]="DARKEN",s[s.LIGHTEN=6]="LIGHTEN",s[s.COLOR_DODGE=7]="COLOR_DODGE",s[s.COLOR_BURN=8]="COLOR_BURN",s[s.HARD_LIGHT=9]="HARD_LIGHT",s[s.SOFT_LIGHT=10]="SOFT_LIGHT",s[s.DIFFERENCE=11]="DIFFERENCE",s[s.EXCLUSION=12]="EXCLUSION",s[s.HUE=13]="HUE",s[s.SATURATION=14]="SATURATION",s[s.COLOR=15]="COLOR",s[s.LUMINOSITY=16]="LUMINOSITY",s[s.NORMAL_NPM=17]="NORMAL_NPM",s[s.ADD_NPM=18]="ADD_NPM",s[s.SCREEN_NPM=19]="SCREEN_NPM",s[s.NONE=20]="NONE",s[s.SRC_OVER=0]="SRC_OVER",s[s.SRC_IN=21]="SRC_IN",s[s.SRC_OUT=22]="SRC_OUT",s[s.SRC_ATOP=23]="SRC_ATOP",s[s.DST_OVER=24]="DST_OVER",s[s.DST_IN=25]="DST_IN",s[s.DST_OUT=26]="DST_OUT",s[s.DST_ATOP=27]="DST_ATOP",s[s.ERASE=26]="ERASE",s[s.SUBTRACT=28]="SUBTRACT",s[s.XOR=29]="XOR",s))(nt||{}),oe=(s=>(s[s.POINTS=0]="POINTS",s[s.LINES=1]="LINES",s[s.LINE_LOOP=2]="LINE_LOOP",s[s.LINE_STRIP=3]="LINE_STRIP",s[s.TRIANGLES=4]="TRIANGLES",s[s.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",s[s.TRIANGLE_FAN=6]="TRIANGLE_FAN",s))(oe||{}),H=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(H||{}),ui=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(ui||{}),it=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(it||{}),Y=(s=>(s[s.FLOAT=0]="FLOAT",s[s.INT=1]="INT",s[s.UINT=2]="UINT",s))(Y||{}),be=(s=>(s[s.NEAREST=0]="NEAREST",s[s.LINEAR=1]="LINEAR",s))(be||{}),Te=(s=>(s[s.CLAMP=33071]="CLAMP",s[s.REPEAT=10497]="REPEAT",s[s.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",s))(Te||{}),he=(s=>(s[s.OFF=0]="OFF",s[s.POW2=1]="POW2",s[s.ON=2]="ON",s[s.ON_MANUAL=3]="ON_MANUAL",s))(he||{}),Nt=(s=>(s[s.NPM=0]="NPM",s[s.UNPACK=1]="UNPACK",s[s.PMA=2]="PMA",s[s.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",s[s.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",s[s.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",s))(Nt||{}),le=(s=>(s[s.NO=0]="NO",s[s.YES=1]="YES",s[s.AUTO=2]="AUTO",s[s.BLEND=0]="BLEND",s[s.CLEAR=1]="CLEAR",s[s.BLIT=2]="BLIT",s))(le||{}),ss=(s=>(s[s.AUTO=0]="AUTO",s[s.MANUAL=1]="MANUAL",s))(ss||{}),Xt=(s=>(s.LOW="lowp",s.MEDIUM="mediump",s.HIGH="highp",s))(Xt||{}),It=(s=>(s[s.NONE=0]="NONE",s[s.SCISSOR=1]="SCISSOR",s[s.STENCIL=2]="STENCIL",s[s.SPRITE=3]="SPRITE",s[s.COLOR=4]="COLOR",s))(It||{}),bh=(s=>(s[s.RED=1]="RED",s[s.GREEN=2]="GREEN",s[s.BLUE=4]="BLUE",s[s.ALPHA=8]="ALPHA",s))(bh||{}),St=(s=>(s[s.NONE=0]="NONE",s[s.LOW=2]="LOW",s[s.MEDIUM=4]="MEDIUM",s[s.HIGH=8]="HIGH",s))(St||{}),ue=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(ue||{});const Th={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")},q={ADAPTER:Th,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Tn=/iPhone/i,Eh=/iPod/i,wh=/iPad/i,Ch=/\biOS-universal(?:.+)Mac\b/i,En=/\bAndroid(?:.+)Mobile\b/i,Ah=/Android/i,Mi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,ns=/Silk/i,Oe=/Windows Phone/i,Sh=/\bWindows(?:.+)ARM\b/i,Ph=/BlackBerry/i,Mh=/BB10/i,Ih=/Opera Mini/i,Rh=/\b(CriOS|Chrome)(?:.+)Mobile/i,Dh=/Mobile(?:.+)Firefox\b/i,Fh=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function ff(s){return function(t){return t.test(s)}}function Bh(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var r=ff(e),n={apple:{phone:r(Tn)&&!r(Oe),ipod:r(Eh),tablet:!r(Tn)&&(r(wh)||Fh(t))&&!r(Oe),universal:r(Ch),device:(r(Tn)||r(Eh)||r(wh)||r(Ch)||Fh(t))&&!r(Oe)},amazon:{phone:r(Mi),tablet:!r(Mi)&&r(ns),device:r(Mi)||r(ns)},android:{phone:!r(Oe)&&r(Mi)||!r(Oe)&&r(En),tablet:!r(Oe)&&!r(Mi)&&!r(En)&&(r(ns)||r(Ah)),device:!r(Oe)&&(r(Mi)||r(ns)||r(En)||r(Ah))||r(/\bokhttp\b/i)},windows:{phone:r(Oe),tablet:r(Sh),device:r(Oe)||r(Sh)},other:{blackberry:r(Ph),blackberry10:r(Mh),opera:r(Ih),firefox:r(Dh),chrome:r(Rh),device:r(Ph)||r(Mh)||r(Ih)||r(Dh)||r(Rh)},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 pf=Bh.default??Bh,ce=pf(globalThis.navigator);q.RETINA_PREFIX=/@([0-9\.]+)x/,q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var wn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function mf(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var r=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return s[i]}})}),e}var Cn={exports:{}},Oh;function gf(){return Oh||(Oh=1,function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,l,u){this.fn=h,this.context=l,this.once=u||!1}function n(h,l,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new r(u,c||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 a(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],u,c;if(this._eventsCount===0)return l;for(c in u=this._events)t.call(u,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},o.prototype.listeners=function(l){var u=e?e+l:l,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,f=c.length,p=new Array(f);d<f;d++)p[d]=c[d].fn;return p},o.prototype.listenerCount=function(l){var u=e?e+l:l,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(l,u,c,d,f,p){var g=e?e+l:l;if(!this._events[g])return!1;var m=this._events[g],_=arguments.length,b,y;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),_){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,u),!0;case 3:return m.fn.call(m.context,u,c),!0;case 4:return m.fn.call(m.context,u,c,d),!0;case 5:return m.fn.call(m.context,u,c,d,f),!0;case 6:return m.fn.call(m.context,u,c,d,f,p),!0}for(y=1,b=new Array(_-1);y<_;y++)b[y-1]=arguments[y];m.fn.apply(m.context,b)}else{var E=m.length,v;for(y=0;y<E;y++)switch(m[y].once&&this.removeListener(l,m[y].fn,void 0,!0),_){case 1:m[y].fn.call(m[y].context);break;case 2:m[y].fn.call(m[y].context,u);break;case 3:m[y].fn.call(m[y].context,u,c);break;case 4:m[y].fn.call(m[y].context,u,c,d);break;default:if(!b)for(v=1,b=new Array(_-1);v<_;v++)b[v-1]=arguments[v];m[y].fn.apply(m[y].context,b)}}return!0},o.prototype.on=function(l,u,c){return n(this,l,u,c,!1)},o.prototype.once=function(l,u,c){return n(this,l,u,c,!0)},o.prototype.removeListener=function(l,u,c,d){var f=e?e+l:l;if(!this._events[f])return this;if(!u)return a(this,f),this;var p=this._events[f];if(p.fn)p.fn===u&&(!d||p.once)&&(!c||p.context===c)&&a(this,f);else{for(var g=0,m=[],_=p.length;g<_;g++)(p[g].fn!==u||d&&!p[g].once||c&&p[g].context!==c)&&m.push(p[g]);m.length?this._events[f]=m.length===1?m[0]:m:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var u;return l?(u=e?e+l:l,this._events[u]&&a(this,u)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o}(Cn)),Cn.exports}var _f=gf();const Ee=Lh(_f);var as={exports:{}},kh;function yf(){if(kh)return as.exports;kh=1,as.exports=s,as.exports.default=s;function s(w,C,x){x=x||2;var R=C&&C.length,A=R?C[0]*x:w.length,S=t(w,0,A,x,!0),F=[];if(!S||S.next===S.prev)return F;var L,U,X,J,Z,tt,st;if(R&&(S=h(w,C,S,x)),w.length>80*x){L=X=w[0],U=J=w[1];for(var K=x;K<A;K+=x)Z=w[K],tt=w[K+1],Z<L&&(L=Z),tt<U&&(U=tt),Z>X&&(X=Z),tt>J&&(J=tt);st=Math.max(X-L,J-U),st=st!==0?32767/st:0}return i(S,F,x,L,U,st,0),F}function t(w,C,x,R,A){var S,F;if(A===W(w,C,x,R)>0)for(S=C;S<x;S+=R)F=D(S,w[S],w[S+1],F);else for(S=x-R;S>=C;S-=R)F=D(S,w[S],w[S+1],F);return F&&E(F,F.next)&&(O(F),F=F.next),F}function e(w,C){if(!w)return w;C||(C=w);var x=w,R;do if(R=!1,!x.steiner&&(E(x,x.next)||y(x.prev,x,x.next)===0)){if(O(x),x=C=x.prev,x===x.next)break;R=!0}else x=x.next;while(R||x!==C);return C}function i(w,C,x,R,A,S,F){if(w){!F&&S&&f(w,R,A,S);for(var L=w,U,X;w.prev!==w.next;){if(U=w.prev,X=w.next,S?n(w,R,A,S):r(w)){C.push(U.i/x|0),C.push(w.i/x|0),C.push(X.i/x|0),O(w),w=X.next,L=X.next;continue}if(w=X,w===L){F?F===1?(w=a(e(w),C,x),i(w,C,x,R,A,S,2)):F===2&&o(w,C,x,R,A,S):i(e(w),C,x,R,A,S,1);break}}}}function r(w){var C=w.prev,x=w,R=w.next;if(y(C,x,R)>=0)return!1;for(var A=C.x,S=x.x,F=R.x,L=C.y,U=x.y,X=R.y,J=A<S?A<F?A:F:S<F?S:F,Z=L<U?L<X?L:X:U<X?U:X,tt=A>S?A>F?A:F:S>F?S:F,st=L>U?L>X?L:X:U>X?U:X,K=R.next;K!==C;){if(K.x>=J&&K.x<=tt&&K.y>=Z&&K.y<=st&&_(A,L,S,U,F,X,K.x,K.y)&&y(K.prev,K,K.next)>=0)return!1;K=K.next}return!0}function n(w,C,x,R){var A=w.prev,S=w,F=w.next;if(y(A,S,F)>=0)return!1;for(var L=A.x,U=S.x,X=F.x,J=A.y,Z=S.y,tt=F.y,st=L<U?L<X?L:X:U<X?U:X,K=J<Z?J<tt?J:tt:Z<tt?Z:tt,ht=L>U?L>X?L:X:U>X?U:X,dt=J>Z?J>tt?J:tt:Z>tt?Z:tt,bt=g(st,K,C,x,R),_t=g(ht,dt,C,x,R),rt=w.prevZ,ct=w.nextZ;rt&&rt.z>=bt&&ct&&ct.z<=_t;){if(rt.x>=st&&rt.x<=ht&&rt.y>=K&&rt.y<=dt&&rt!==A&&rt!==F&&_(L,J,U,Z,X,tt,rt.x,rt.y)&&y(rt.prev,rt,rt.next)>=0||(rt=rt.prevZ,ct.x>=st&&ct.x<=ht&&ct.y>=K&&ct.y<=dt&&ct!==A&&ct!==F&&_(L,J,U,Z,X,tt,ct.x,ct.y)&&y(ct.prev,ct,ct.next)>=0))return!1;ct=ct.nextZ}for(;rt&&rt.z>=bt;){if(rt.x>=st&&rt.x<=ht&&rt.y>=K&&rt.y<=dt&&rt!==A&&rt!==F&&_(L,J,U,Z,X,tt,rt.x,rt.y)&&y(rt.prev,rt,rt.next)>=0)return!1;rt=rt.prevZ}for(;ct&&ct.z<=_t;){if(ct.x>=st&&ct.x<=ht&&ct.y>=K&&ct.y<=dt&&ct!==A&&ct!==F&&_(L,J,U,Z,X,tt,ct.x,ct.y)&&y(ct.prev,ct,ct.next)>=0)return!1;ct=ct.nextZ}return!0}function a(w,C,x){var R=w;do{var A=R.prev,S=R.next.next;!E(A,S)&&v(A,R,R.next,S)&&N(A,S)&&N(S,A)&&(C.push(A.i/x|0),C.push(R.i/x|0),C.push(S.i/x|0),O(R),O(R.next),R=w=S),R=R.next}while(R!==w);return e(R)}function o(w,C,x,R,A,S){var F=w;do{for(var L=F.next.next;L!==F.prev;){if(F.i!==L.i&&b(F,L)){var U=z(F,L);F=e(F,F.next),U=e(U,U.next),i(F,C,x,R,A,S,0),i(U,C,x,R,A,S,0);return}L=L.next}F=F.next}while(F!==w)}function h(w,C,x,R){var A=[],S,F,L,U,X;for(S=0,F=C.length;S<F;S++)L=C[S]*R,U=S<F-1?C[S+1]*R:w.length,X=t(w,L,U,R,!1),X===X.next&&(X.steiner=!0),A.push(m(X));for(A.sort(l),S=0;S<A.length;S++)x=u(A[S],x);return x}function l(w,C){return w.x-C.x}function u(w,C){var x=c(w,C);if(!x)return C;var R=z(x,w);return e(R,R.next),e(x,x.next)}function c(w,C){var x=C,R=w.x,A=w.y,S=-1/0,F;do{if(A<=x.y&&A>=x.next.y&&x.next.y!==x.y){var L=x.x+(A-x.y)*(x.next.x-x.x)/(x.next.y-x.y);if(L<=R&&L>S&&(S=L,F=x.x<x.next.x?x:x.next,L===R))return F}x=x.next}while(x!==C);if(!F)return null;var U=F,X=F.x,J=F.y,Z=1/0,tt;x=F;do R>=x.x&&x.x>=X&&R!==x.x&&_(A<J?R:S,A,X,J,A<J?S:R,A,x.x,x.y)&&(tt=Math.abs(A-x.y)/(R-x.x),N(x,w)&&(tt<Z||tt===Z&&(x.x>F.x||x.x===F.x&&d(F,x)))&&(F=x,Z=tt)),x=x.next;while(x!==U);return F}function d(w,C){return y(w.prev,w,C.prev)<0&&y(C.next,w,w.next)<0}function f(w,C,x,R){var A=w;do A.z===0&&(A.z=g(A.x,A.y,C,x,R)),A.prevZ=A.prev,A.nextZ=A.next,A=A.next;while(A!==w);A.prevZ.nextZ=null,A.prevZ=null,p(A)}function p(w){var C,x,R,A,S,F,L,U,X=1;do{for(x=w,w=null,S=null,F=0;x;){for(F++,R=x,L=0,C=0;C<X&&(L++,R=R.nextZ,!!R);C++);for(U=X;L>0||U>0&&R;)L!==0&&(U===0||!R||x.z<=R.z)?(A=x,x=x.nextZ,L--):(A=R,R=R.nextZ,U--),S?S.nextZ=A:w=A,A.prevZ=S,S=A;x=R}S.nextZ=null,X*=2}while(F>1);return w}function g(w,C,x,R,A){return w=(w-x)*A|0,C=(C-R)*A|0,w=(w|w<<8)&16711935,w=(w|w<<4)&252645135,w=(w|w<<2)&858993459,w=(w|w<<1)&1431655765,C=(C|C<<8)&16711935,C=(C|C<<4)&252645135,C=(C|C<<2)&858993459,C=(C|C<<1)&1431655765,w|C<<1}function m(w){var C=w,x=w;do(C.x<x.x||C.x===x.x&&C.y<x.y)&&(x=C),C=C.next;while(C!==w);return x}function _(w,C,x,R,A,S,F,L){return(A-F)*(C-L)>=(w-F)*(S-L)&&(w-F)*(R-L)>=(x-F)*(C-L)&&(x-F)*(S-L)>=(A-F)*(R-L)}function b(w,C){return w.next.i!==C.i&&w.prev.i!==C.i&&!P(w,C)&&(N(w,C)&&N(C,w)&&G(w,C)&&(y(w.prev,w,C.prev)||y(w,C.prev,C))||E(w,C)&&y(w.prev,w,w.next)>0&&y(C.prev,C,C.next)>0)}function y(w,C,x){return(C.y-w.y)*(x.x-C.x)-(C.x-w.x)*(x.y-C.y)}function E(w,C){return w.x===C.x&&w.y===C.y}function v(w,C,x,R){var A=T(y(w,C,x)),S=T(y(w,C,R)),F=T(y(x,R,w)),L=T(y(x,R,C));return!!(A!==S&&F!==L||A===0&&M(w,x,C)||S===0&&M(w,R,C)||F===0&&M(x,w,R)||L===0&&M(x,C,R))}function M(w,C,x){return C.x<=Math.max(w.x,x.x)&&C.x>=Math.min(w.x,x.x)&&C.y<=Math.max(w.y,x.y)&&C.y>=Math.min(w.y,x.y)}function T(w){return w>0?1:w<0?-1:0}function P(w,C){var x=w;do{if(x.i!==w.i&&x.next.i!==w.i&&x.i!==C.i&&x.next.i!==C.i&&v(x,x.next,w,C))return!0;x=x.next}while(x!==w);return!1}function N(w,C){return y(w.prev,w,w.next)<0?y(w,C,w.next)>=0&&y(w,w.prev,C)>=0:y(w,C,w.prev)<0||y(w,w.next,C)<0}function G(w,C){var x=w,R=!1,A=(w.x+C.x)/2,S=(w.y+C.y)/2;do x.y>S!=x.next.y>S&&x.next.y!==x.y&&A<(x.next.x-x.x)*(S-x.y)/(x.next.y-x.y)+x.x&&(R=!R),x=x.next;while(x!==w);return R}function z(w,C){var x=new V(w.i,w.x,w.y),R=new V(C.i,C.x,C.y),A=w.next,S=C.prev;return w.next=C,C.prev=w,x.next=A,A.prev=x,R.next=x,x.prev=R,S.next=R,R.prev=S,R}function D(w,C,x,R){var A=new V(w,C,x);return R?(A.next=R.next,A.prev=R,R.next.prev=A,R.next=A):(A.prev=A,A.next=A),A}function O(w){w.next.prev=w.prev,w.prev.next=w.next,w.prevZ&&(w.prevZ.nextZ=w.nextZ),w.nextZ&&(w.nextZ.prevZ=w.prevZ)}function V(w,C,x){this.i=w,this.x=C,this.y=x,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}s.deviation=function(w,C,x,R){var A=C&&C.length,S=A?C[0]*x:w.length,F=Math.abs(W(w,0,S,x));if(A)for(var L=0,U=C.length;L<U;L++){var X=C[L]*x,J=L<U-1?C[L+1]*x:w.length;F-=Math.abs(W(w,X,J,x))}var Z=0;for(L=0;L<R.length;L+=3){var tt=R[L]*x,st=R[L+1]*x,K=R[L+2]*x;Z+=Math.abs((w[tt]-w[K])*(w[st+1]-w[tt+1])-(w[tt]-w[st])*(w[K+1]-w[tt+1]))}return F===0&&Z===0?0:Math.abs((Z-F)/F)};function W(w,C,x,R){for(var A=0,S=C,F=x-R;S<x;S+=R)A+=(w[F]-w[S])*(w[S+1]+w[F+1]),F=S;return A}return s.flatten=function(w){for(var C=w[0][0].length,x={vertices:[],holes:[],dimensions:C},R=0,A=0;A<w.length;A++){for(var S=0;S<w[A].length;S++)for(var F=0;F<C;F++)x.vertices.push(w[A][S][F]);A>0&&(R+=w[A-1].length,x.holes.push(R))}return x},as.exports}var vf=yf();const Nh=Lh(vf);var ci={},nr={exports:{}};var xf=nr.exports,Uh;function bf(){return Uh||(Uh=1,function(s,t){(function(e){var i=t&&!t.nodeType&&t,r=s&&!s.nodeType&&s,n=typeof wn=="object"&&wn;(n.global===n||n.window===n||n.self===n)&&(e=n);var a,o=2147483647,h=36,l=1,u=26,c=38,d=700,f=72,p=128,g="-",m=/^xn--/,_=/[^\x20-\x7E]/,b=/[\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"},E=h-l,v=Math.floor,M=String.fromCharCode,T;function P(A){throw new RangeError(y[A])}function N(A,S){for(var F=A.length,L=[];F--;)L[F]=S(A[F]);return L}function G(A,S){var F=A.split("@"),L="";F.length>1&&(L=F[0]+"@",A=F[1]),A=A.replace(b,".");var U=A.split("."),X=N(U,S).join(".");return L+X}function z(A){for(var S=[],F=0,L=A.length,U,X;F<L;)U=A.charCodeAt(F++),U>=55296&&U<=56319&&F<L?(X=A.charCodeAt(F++),(X&64512)==56320?S.push(((U&1023)<<10)+(X&1023)+65536):(S.push(U),F--)):S.push(U);return S}function D(A){return N(A,function(S){var F="";return S>65535&&(S-=65536,F+=M(S>>>10&1023|55296),S=56320|S&1023),F+=M(S),F}).join("")}function O(A){return A-48<10?A-22:A-65<26?A-65:A-97<26?A-97:h}function V(A,S){return A+22+75*(A<26)-((S!=0)<<5)}function W(A,S,F){var L=0;for(A=F?v(A/d):A>>1,A+=v(A/S);A>E*u>>1;L+=h)A=v(A/E);return v(L+(E+1)*A/(A+c))}function w(A){var S=[],F=A.length,L,U=0,X=p,J=f,Z,tt,st,K,ht,dt,bt,_t,rt;for(Z=A.lastIndexOf(g),Z<0&&(Z=0),tt=0;tt<Z;++tt)A.charCodeAt(tt)>=128&&P("not-basic"),S.push(A.charCodeAt(tt));for(st=Z>0?Z+1:0;st<F;){for(K=U,ht=1,dt=h;st>=F&&P("invalid-input"),bt=O(A.charCodeAt(st++)),(bt>=h||bt>v((o-U)/ht))&&P("overflow"),U+=bt*ht,_t=dt<=J?l:dt>=J+u?u:dt-J,!(bt<_t);dt+=h)rt=h-_t,ht>v(o/rt)&&P("overflow"),ht*=rt;L=S.length+1,J=W(U-K,L,K==0),v(U/L)>o-X&&P("overflow"),X+=v(U/L),U%=L,S.splice(U++,0,X)}return D(S)}function C(A){var S,F,L,U,X,J,Z,tt,st,K,ht,dt=[],bt,_t,rt,ct;for(A=z(A),bt=A.length,S=p,F=0,X=f,J=0;J<bt;++J)ht=A[J],ht<128&&dt.push(M(ht));for(L=U=dt.length,U&&dt.push(g);L<bt;){for(Z=o,J=0;J<bt;++J)ht=A[J],ht>=S&&ht<Z&&(Z=ht);for(_t=L+1,Z-S>v((o-F)/_t)&&P("overflow"),F+=(Z-S)*_t,S=Z,J=0;J<bt;++J)if(ht=A[J],ht<S&&++F>o&&P("overflow"),ht==S){for(tt=F,st=h;K=st<=X?l:st>=X+u?u:st-X,!(tt<K);st+=h)ct=tt-K,rt=h-K,dt.push(M(V(K+ct%rt,0))),tt=v(ct/rt);dt.push(M(V(tt,0))),X=W(F,_t,L==U),F=0,++L}++F,++S}return dt.join("")}function x(A){return G(A,function(S){return m.test(S)?w(S.slice(4).toLowerCase()):S})}function R(A){return G(A,function(S){return _.test(S)?"xn--"+C(S):S})}if(a={version:"1.4.1",ucs2:{decode:z,encode:D},decode:w,encode:C,toASCII:R,toUnicode:x},i&&r)if(s.exports==i)r.exports=a;else for(T in a)a.hasOwnProperty(T)&&(i[T]=a[T]);else e.punycode=a})(xf)}(nr,nr.exports)),nr.exports}var An,Gh;function Tf(){return Gh||(Gh=1,An=Error),An}var Sn,Vh;function Ef(){return Vh||(Vh=1,Sn=EvalError),Sn}var Pn,Hh;function wf(){return Hh||(Hh=1,Pn=RangeError),Pn}var Mn,Xh;function Cf(){return Xh||(Xh=1,Mn=ReferenceError),Mn}var In,zh;function Wh(){return zh||(zh=1,In=SyntaxError),In}var Rn,$h;function ar(){return $h||($h=1,Rn=TypeError),Rn}var Dn,jh;function Af(){return jh||(jh=1,Dn=URIError),Dn}var Fn,Yh;function Sf(){return Yh||(Yh=1,Fn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var r=42;t[e]=r;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==r||a.enumerable!==!0)return!1}return!0}),Fn}var Bn,qh;function Pf(){if(qh)return Bn;qh=1;var s=typeof Symbol<"u"&&Symbol,t=Sf();return Bn=function(){return typeof s!="function"||typeof Symbol!="function"||typeof s("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Bn}var Ln,Kh;function Mf(){if(Kh)return Ln;Kh=1;var s={__proto__:null,foo:{}},t=Object;return Ln=function(){return{__proto__:s}.foo===s.foo&&!(s instanceof t)},Ln}var On,Zh;function If(){if(Zh)return On;Zh=1;var s="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,e=Math.max,i="[object Function]",r=function(h,l){for(var u=[],c=0;c<h.length;c+=1)u[c]=h[c];for(var d=0;d<l.length;d+=1)u[d+h.length]=l[d];return u},n=function(h,l){for(var u=[],c=l,d=0;c<h.length;c+=1,d+=1)u[d]=h[c];return u},a=function(o,h){for(var l="",u=0;u<o.length;u+=1)l+=o[u],u+1<o.length&&(l+=h);return l};return On=function(h){var l=this;if(typeof l!="function"||t.apply(l)!==i)throw new TypeError(s+l);for(var u=n(arguments,1),c,d=function(){if(this instanceof c){var _=l.apply(this,r(u,arguments));return Object(_)===_?_:this}return l.apply(h,r(u,arguments))},f=e(0,l.length-u.length),p=[],g=0;g<f;g++)p[g]="$"+g;if(c=Function("binder","return function ("+a(p,",")+"){ return binder.apply(this,arguments); }")(d),l.prototype){var m=function(){};m.prototype=l.prototype,c.prototype=new m,m.prototype=null}return c},On}var kn,Jh;function Nn(){if(Jh)return kn;Jh=1;var s=If();return kn=Function.prototype.bind||s,kn}var Un,Qh;function Rf(){if(Qh)return Un;Qh=1;var s=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=Nn();return Un=e.call(s,t),Un}var Gn,tl;function Ii(){if(tl)return Gn;tl=1;var s,t=Tf(),e=Ef(),i=wf(),r=Cf(),n=Wh(),a=ar(),o=Af(),h=Function,l=function(C){try{return h('"use strict"; return ('+C+").constructor;")()}catch{}},u=Object.getOwnPropertyDescriptor;if(u)try{u({},"")}catch{u=null}var c=function(){throw new a},d=u?function(){try{return arguments.callee,c}catch{try{return u(arguments,"callee").get}catch{return c}}}():c,f=Pf()(),p=Mf()(),g=Object.getPrototypeOf||(p?function(C){return C.__proto__}:null),m={},_=typeof Uint8Array>"u"||!g?s:g(Uint8Array),b={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?s:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?s:ArrayBuffer,"%ArrayIteratorPrototype%":f&&g?g([][Symbol.iterator]()):s,"%AsyncFromSyncIteratorPrototype%":s,"%AsyncFunction%":m,"%AsyncGenerator%":m,"%AsyncGeneratorFunction%":m,"%AsyncIteratorPrototype%":m,"%Atomics%":typeof Atomics>"u"?s:Atomics,"%BigInt%":typeof BigInt>"u"?s:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?s:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?s:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?s:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":e,"%Float32Array%":typeof Float32Array>"u"?s:Float32Array,"%Float64Array%":typeof Float64Array>"u"?s:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?s:FinalizationRegistry,"%Function%":h,"%GeneratorFunction%":m,"%Int8Array%":typeof Int8Array>"u"?s:Int8Array,"%Int16Array%":typeof Int16Array>"u"?s:Int16Array,"%Int32Array%":typeof Int32Array>"u"?s:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":f&&g?g(g([][Symbol.iterator]())):s,"%JSON%":typeof JSON=="object"?JSON:s,"%Map%":typeof Map>"u"?s:Map,"%MapIteratorPrototype%":typeof Map>"u"||!f||!g?s:g(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?s:Promise,"%Proxy%":typeof Proxy>"u"?s:Proxy,"%RangeError%":i,"%ReferenceError%":r,"%Reflect%":typeof Reflect>"u"?s:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?s:Set,"%SetIteratorPrototype%":typeof Set>"u"||!f||!g?s:g(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?s:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":f&&g?g(""[Symbol.iterator]()):s,"%Symbol%":f?Symbol:s,"%SyntaxError%":n,"%ThrowTypeError%":d,"%TypedArray%":_,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array>"u"?s:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?s:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?s:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?s:Uint32Array,"%URIError%":o,"%WeakMap%":typeof WeakMap>"u"?s:WeakMap,"%WeakRef%":typeof WeakRef>"u"?s:WeakRef,"%WeakSet%":typeof WeakSet>"u"?s:WeakSet};if(g)try{null.error}catch(C){var y=g(g(C));b["%Error.prototype%"]=y}var E=function C(x){var R;if(x==="%AsyncFunction%")R=l("async function () {}");else if(x==="%GeneratorFunction%")R=l("function* () {}");else if(x==="%AsyncGeneratorFunction%")R=l("async function* () {}");else if(x==="%AsyncGenerator%"){var A=C("%AsyncGeneratorFunction%");A&&(R=A.prototype)}else if(x==="%AsyncIteratorPrototype%"){var S=C("%AsyncGenerator%");S&&g&&(R=g(S.prototype))}return b[x]=R,R},v={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},M=Nn(),T=Rf(),P=M.call(Function.call,Array.prototype.concat),N=M.call(Function.apply,Array.prototype.splice),G=M.call(Function.call,String.prototype.replace),z=M.call(Function.call,String.prototype.slice),D=M.call(Function.call,RegExp.prototype.exec),O=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,V=/\\(\\)?/g,W=function(x){var R=z(x,0,1),A=z(x,-1);if(R==="%"&&A!=="%")throw new n("invalid intrinsic syntax, expected closing `%`");if(A==="%"&&R!=="%")throw new n("invalid intrinsic syntax, expected opening `%`");var S=[];return G(x,O,function(F,L,U,X){S[S.length]=U?G(X,V,"$1"):L||F}),S},w=function(x,R){var A=x,S;if(T(v,A)&&(S=v[A],A="%"+S[0]+"%"),T(b,A)){var F=b[A];if(F===m&&(F=E(A)),typeof F>"u"&&!R)throw new a("intrinsic "+x+" exists, but is not available. Please file an issue!");return{alias:S,name:A,value:F}}throw new n("intrinsic "+x+" does not exist!")};return Gn=function(x,R){if(typeof x!="string"||x.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof R!="boolean")throw new a('"allowMissing" argument must be a boolean');if(D(/^%?[^%]*%?$/,x)===null)throw new n("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var A=W(x),S=A.length>0?A[0]:"",F=w("%"+S+"%",R),L=F.name,U=F.value,X=!1,J=F.alias;J&&(S=J[0],N(A,P([0,1],J)));for(var Z=1,tt=!0;Z<A.length;Z+=1){var st=A[Z],K=z(st,0,1),ht=z(st,-1);if((K==='"'||K==="'"||K==="`"||ht==='"'||ht==="'"||ht==="`")&&K!==ht)throw new n("property names with quotes must have matching quotes");if((st==="constructor"||!tt)&&(X=!0),S+="."+st,L="%"+S+"%",T(b,L))U=b[L];else if(U!=null){if(!(st in U)){if(!R)throw new a("base intrinsic for "+x+" exists, but the property is not available.");return}if(u&&Z+1>=A.length){var dt=u(U,st);tt=!!dt,tt&&"get"in dt&&!("originalValue"in dt.get)?U=dt.get:U=U[st]}else tt=T(U,st),U=U[st];tt&&!X&&(b[L]=U)}}return U},Gn}var Vn={exports:{}},Hn,el;function Xn(){if(el)return Hn;el=1;var s=Ii(),t=s("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Hn=t,Hn}var zn,il;function rl(){if(il)return zn;il=1;var s=Ii(),t=s("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch{t=null}return zn=t,zn}var Wn,sl;function Df(){if(sl)return Wn;sl=1;var s=Xn(),t=Wh(),e=ar(),i=rl();return Wn=function(n,a,o){if(!n||typeof n!="object"&&typeof n!="function")throw new e("`obj` must be an object or a function`");if(typeof a!="string"&&typeof a!="symbol")throw new e("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new e("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new e("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new e("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new e("`loose`, if provided, must be a boolean");var h=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,c=arguments.length>6?arguments[6]:!1,d=!!i&&i(n,a);if(s)s(n,a,{configurable:u===null&&d?d.configurable:!u,enumerable:h===null&&d?d.enumerable:!h,value:o,writable:l===null&&d?d.writable:!l});else if(c||!h&&!l&&!u)n[a]=o;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Wn}var $n,nl;function Ff(){if(nl)return $n;nl=1;var s=Xn(),t=function(){return!!s};return t.hasArrayLengthDefineBug=function(){if(!s)return null;try{return s([],"length",{value:1}).length!==1}catch{return!0}},$n=t,$n}var jn,al;function Bf(){if(al)return jn;al=1;var s=Ii(),t=Df(),e=Ff()(),i=rl(),r=ar(),n=s("%Math.floor%");return jn=function(o,h){if(typeof o!="function")throw new r("`fn` is not a function");if(typeof h!="number"||h<0||h>4294967295||n(h)!==h)throw new r("`length` must be a positive 32-bit integer");var l=arguments.length>2&&!!arguments[2],u=!0,c=!0;if("length"in o&&i){var d=i(o,"length");d&&!d.configurable&&(u=!1),d&&!d.writable&&(c=!1)}return(u||c||!l)&&(e?t(o,"length",h,!0,!0):t(o,"length",h)),o},jn}var ol;function Lf(){return ol||(ol=1,function(s){var t=Nn(),e=Ii(),i=Bf(),r=ar(),n=e("%Function.prototype.apply%"),a=e("%Function.prototype.call%"),o=e("%Reflect.apply%",!0)||t.call(a,n),h=Xn(),l=e("%Math.max%");s.exports=function(d){if(typeof d!="function")throw new r("a function is required");var f=o(t,a,arguments);return i(f,1+l(0,d.length-(arguments.length-1)),!0)};var u=function(){return o(t,n,arguments)};h?h(s.exports,"apply",{value:u}):s.exports.apply=u}(Vn)),Vn.exports}var Yn,hl;function Of(){if(hl)return Yn;hl=1;var s=Ii(),t=Lf(),e=t(s("String.prototype.indexOf"));return Yn=function(r,n){var a=s(r,!!n);return typeof a=="function"&&e(r,".prototype.")>-1?t(a):a},Yn}const kf=mf(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var qn,ll;function Nf(){if(ll)return qn;ll=1;var s=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&s?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,e=s&&t&&typeof t.get=="function"?t.get:null,i=s&&Map.prototype.forEach,r=typeof Set=="function"&&Set.prototype,n=Object.getOwnPropertyDescriptor&&r?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,a=r&&n&&typeof n.get=="function"?n.get:null,o=r&&Set.prototype.forEach,h=typeof WeakMap=="function"&&WeakMap.prototype,l=h?WeakMap.prototype.has:null,u=typeof WeakSet=="function"&&WeakSet.prototype,c=u?WeakSet.prototype.has:null,d=typeof WeakRef=="function"&&WeakRef.prototype,f=d?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,g=Object.prototype.toString,m=Function.prototype.toString,_=String.prototype.match,b=String.prototype.slice,y=String.prototype.replace,E=String.prototype.toUpperCase,v=String.prototype.toLowerCase,M=RegExp.prototype.test,T=Array.prototype.concat,P=Array.prototype.join,N=Array.prototype.slice,G=Math.floor,z=typeof BigInt=="function"?BigInt.prototype.valueOf:null,D=Object.getOwnPropertySymbols,O=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,V=typeof Symbol=="function"&&typeof Symbol.iterator=="object",W=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===V||!0)?Symbol.toStringTag:null,w=Object.prototype.propertyIsEnumerable,C=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(B){return B.__proto__}:null);function x(B,k){if(B===1/0||B===-1/0||B!==B||B&&B>-1e3&&B<1e3||M.call(/e/,k))return k;var yt=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof B=="number"){var Tt=B<0?-G(-B):G(B);if(Tt!==B){var Mt=String(Tt),pt=b.call(k,Mt.length+1);return y.call(Mt,yt,"$&_")+"."+y.call(y.call(pt,/([0-9]{3})/g,"$&_"),/_$/,"")}}return y.call(k,yt,"$&_")}var R=kf,A=R.custom,S=ht(A)?A:null;qn=function B(k,yt,Tt,Mt){var pt=yt||{};if(_t(pt,"quoteStyle")&&pt.quoteStyle!=="single"&&pt.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(_t(pt,"maxStringLength")&&(typeof pt.maxStringLength=="number"?pt.maxStringLength<0&&pt.maxStringLength!==1/0:pt.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var hi=_t(pt,"customInspect")?pt.customInspect:!0;if(typeof hi!="boolean"&&hi!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(_t(pt,"indent")&&pt.indent!==null&&pt.indent!==" "&&!(parseInt(pt.indent,10)===pt.indent&&pt.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(_t(pt,"numericSeparator")&&typeof pt.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Pi=pt.numericSeparator;if(typeof k>"u")return"undefined";if(k===null)return"null";if(typeof k=="boolean")return k?"true":"false";if(typeof k=="string")return Jd(k,pt);if(typeof k=="number"){if(k===0)return 1/0/k>0?"0":"-0";var qt=String(k);return Pi?x(k,qt):qt}if(typeof k=="bigint"){var li=String(k)+"n";return Pi?x(k,li):li}var nh=typeof pt.depth>"u"?5:pt.depth;if(typeof Tt>"u"&&(Tt=0),Tt>=nh&&nh>0&&typeof k=="object")return U(k)?"[Array]":"[Object]";var Ji=bv(pt,Tt);if(typeof Mt>"u")Mt=[];else if(Ye(Mt,k)>=0)return"[Circular]";function ve(Qi,fn,Ev){if(fn&&(Mt=N.call(Mt),Mt.push(fn)),Ev){var hf={depth:pt.depth};return _t(pt,"quoteStyle")&&(hf.quoteStyle=pt.quoteStyle),B(Qi,hf,Tt+1,Mt)}return B(Qi,pt,Tt+1,Mt)}if(typeof k=="function"&&!J(k)){var tf=ct(k),ef=cn(k,ve);return"[Function"+(tf?": "+tf:" (anonymous)")+"]"+(ef.length>0?" { "+P.call(ef,", ")+" }":"")}if(ht(k)){var rf=V?y.call(String(k),/^(Symbol\(.*\))_[^)]*$/,"$1"):O.call(k);return typeof k=="object"&&!V?Kr(rf):rf}if(yv(k)){for(var Zr="<"+v.call(String(k.nodeName)),ah=k.attributes||[],dn=0;dn<ah.length;dn++)Zr+=" "+ah[dn].name+"="+F(L(ah[dn].value),"double",pt);return Zr+=">",k.childNodes&&k.childNodes.length&&(Zr+="..."),Zr+="</"+v.call(String(k.nodeName))+">",Zr}if(U(k)){if(k.length===0)return"[]";var oh=cn(k,ve);return Ji&&!xv(oh)?"["+sh(oh,Ji)+"]":"[ "+P.call(oh,", ")+" ]"}if(Z(k)){var hh=cn(k,ve);return!("cause"in Error.prototype)&&"cause"in k&&!w.call(k,"cause")?"{ ["+String(k)+"] "+P.call(T.call("[cause]: "+ve(k.cause),hh),", ")+" }":hh.length===0?"["+String(k)+"]":"{ ["+String(k)+"] "+P.call(hh,", ")+" }"}if(typeof k=="object"&&hi){if(S&&typeof k[S]=="function"&&R)return R(k,{depth:nh-Tt});if(hi!=="symbol"&&typeof k.inspect=="function")return k.inspect()}if(oi(k)){var sf=[];return i&&i.call(k,function(Qi,fn){sf.push(ve(fn,k,!0)+" => "+ve(Qi,k))}),Qd("Map",e.call(k),sf,Ji)}if(gv(k)){var nf=[];return o&&o.call(k,function(Qi){nf.push(ve(Qi,k))}),Qd("Set",a.call(k),nf,Ji)}if(pv(k))return rh("WeakMap");if(_v(k))return rh("WeakSet");if(mv(k))return rh("WeakRef");if(st(k))return Kr(ve(Number(k)));if(dt(k))return Kr(ve(z.call(k)));if(K(k))return Kr(p.call(k));if(tt(k))return Kr(ve(String(k)));if(typeof window<"u"&&k===window)return"{ [object Window] }";if(k===wn)return"{ [object globalThis] }";if(!X(k)&&!J(k)){var lh=cn(k,ve),af=C?C(k)===Object.prototype:k instanceof Object||k.constructor===Object,uh=k instanceof Object?"":"null prototype",of=!af&&W&&Object(k)===k&&W in k?b.call(rt(k),8,-1):uh?"Object":"",Tv=af||typeof k.constructor!="function"?"":k.constructor.name?k.constructor.name+" ":"",ch=Tv+(of||uh?"["+P.call(T.call([],of||[],uh||[]),": ")+"] ":"");return lh.length===0?ch+"{}":Ji?ch+"{"+sh(lh,Ji)+"}":ch+"{ "+P.call(lh,", ")+" }"}return String(k)};function F(B,k,yt){var Tt=(yt.quoteStyle||k)==="double"?'"':"'";return Tt+B+Tt}function L(B){return y.call(String(B),/"/g,"&quot;")}function U(B){return rt(B)==="[object Array]"&&(!W||!(typeof B=="object"&&W in B))}function X(B){return rt(B)==="[object Date]"&&(!W||!(typeof B=="object"&&W in B))}function J(B){return rt(B)==="[object RegExp]"&&(!W||!(typeof B=="object"&&W in B))}function Z(B){return rt(B)==="[object Error]"&&(!W||!(typeof B=="object"&&W in B))}function tt(B){return rt(B)==="[object String]"&&(!W||!(typeof B=="object"&&W in B))}function st(B){return rt(B)==="[object Number]"&&(!W||!(typeof B=="object"&&W in B))}function K(B){return rt(B)==="[object Boolean]"&&(!W||!(typeof B=="object"&&W in B))}function ht(B){if(V)return B&&typeof B=="object"&&B instanceof Symbol;if(typeof B=="symbol")return!0;if(!B||typeof B!="object"||!O)return!1;try{return O.call(B),!0}catch{}return!1}function dt(B){if(!B||typeof B!="object"||!z)return!1;try{return z.call(B),!0}catch{}return!1}var bt=Object.prototype.hasOwnProperty||function(B){return B in this};function _t(B,k){return bt.call(B,k)}function rt(B){return g.call(B)}function ct(B){if(B.name)return B.name;var k=_.call(m.call(B),/^function\s*([\w$]+)/);return k?k[1]:null}function Ye(B,k){if(B.indexOf)return B.indexOf(k);for(var yt=0,Tt=B.length;yt<Tt;yt++)if(B[yt]===k)return yt;return-1}function oi(B){if(!e||!B||typeof B!="object")return!1;try{e.call(B);try{a.call(B)}catch{return!0}return B instanceof Map}catch{}return!1}function pv(B){if(!l||!B||typeof B!="object")return!1;try{l.call(B,l);try{c.call(B,c)}catch{return!0}return B instanceof WeakMap}catch{}return!1}function mv(B){if(!f||!B||typeof B!="object")return!1;try{return f.call(B),!0}catch{}return!1}function gv(B){if(!a||!B||typeof B!="object")return!1;try{a.call(B);try{e.call(B)}catch{return!0}return B instanceof Set}catch{}return!1}function _v(B){if(!c||!B||typeof B!="object")return!1;try{c.call(B,c);try{l.call(B,l)}catch{return!0}return B instanceof WeakSet}catch{}return!1}function yv(B){return!B||typeof B!="object"?!1:typeof HTMLElement<"u"&&B instanceof HTMLElement?!0:typeof B.nodeName=="string"&&typeof B.getAttribute=="function"}function Jd(B,k){if(B.length>k.maxStringLength){var yt=B.length-k.maxStringLength,Tt="... "+yt+" more character"+(yt>1?"s":"");return Jd(b.call(B,0,k.maxStringLength),k)+Tt}var Mt=y.call(y.call(B,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,vv);return F(Mt,"single",k)}function vv(B){var k=B.charCodeAt(0),yt={8:"b",9:"t",10:"n",12:"f",13:"r"}[k];return yt?"\\"+yt:"\\x"+(k<16?"0":"")+E.call(k.toString(16))}function Kr(B){return"Object("+B+")"}function rh(B){return B+" { ? }"}function Qd(B,k,yt,Tt){var Mt=Tt?sh(yt,Tt):P.call(yt,", ");return B+" ("+k+") {"+Mt+"}"}function xv(B){for(var k=0;k<B.length;k++)if(Ye(B[k],`
2
+ `)>=0)return!1;return!0}function bv(B,k){var yt;if(B.indent===" ")yt=" ";else if(typeof B.indent=="number"&&B.indent>0)yt=P.call(Array(B.indent+1)," ");else return null;return{base:yt,prev:P.call(Array(k+1),yt)}}function sh(B,k){if(B.length===0)return"";var yt=`
3
+ `+k.prev+k.base;return yt+P.call(B,","+yt)+`
4
+ `+k.prev}function cn(B,k){var yt=U(B),Tt=[];if(yt){Tt.length=B.length;for(var Mt=0;Mt<B.length;Mt++)Tt[Mt]=_t(B,Mt)?k(B[Mt],B):""}var pt=typeof D=="function"?D(B):[],hi;if(V){hi={};for(var Pi=0;Pi<pt.length;Pi++)hi["$"+pt[Pi]]=pt[Pi]}for(var qt in B)_t(B,qt)&&(yt&&String(Number(qt))===qt&&qt<B.length||V&&hi["$"+qt]instanceof Symbol||(M.call(/[^\w$]/,qt)?Tt.push(k(qt,B)+": "+k(B[qt],B)):Tt.push(qt+": "+k(B[qt],B))));if(typeof D=="function")for(var li=0;li<pt.length;li++)w.call(B,pt[li])&&Tt.push("["+k(pt[li])+"]: "+k(B[pt[li]],B));return Tt}return qn}var Kn,ul;function Uf(){if(ul)return Kn;ul=1;var s=Ii(),t=Of(),e=Nf(),i=ar(),r=s("%WeakMap%",!0),n=s("%Map%",!0),a=t("WeakMap.prototype.get",!0),o=t("WeakMap.prototype.set",!0),h=t("WeakMap.prototype.has",!0),l=t("Map.prototype.get",!0),u=t("Map.prototype.set",!0),c=t("Map.prototype.has",!0),d=function(m,_){for(var b=m,y;(y=b.next)!==null;b=y)if(y.key===_)return b.next=y.next,y.next=m.next,m.next=y,y},f=function(m,_){var b=d(m,_);return b&&b.value},p=function(m,_,b){var y=d(m,_);y?y.value=b:m.next={key:_,next:m.next,value:b}},g=function(m,_){return!!d(m,_)};return Kn=function(){var _,b,y,E={assert:function(v){if(!E.has(v))throw new i("Side channel does not contain "+e(v))},get:function(v){if(r&&v&&(typeof v=="object"||typeof v=="function")){if(_)return a(_,v)}else if(n){if(b)return l(b,v)}else if(y)return f(y,v)},has:function(v){if(r&&v&&(typeof v=="object"||typeof v=="function")){if(_)return h(_,v)}else if(n){if(b)return c(b,v)}else if(y)return g(y,v);return!1},set:function(v,M){r&&v&&(typeof v=="object"||typeof v=="function")?(_||(_=new r),o(_,v,M)):n?(b||(b=new n),u(b,v,M)):(y||(y={key:{},next:null}),p(y,v,M))}};return E},Kn}var Zn,cl;function Jn(){if(cl)return Zn;cl=1;var s=String.prototype.replace,t=/%20/g,e={RFC1738:"RFC1738",RFC3986:"RFC3986"};return Zn={default:e.RFC3986,formatters:{RFC1738:function(i){return s.call(i,t,"+")},RFC3986:function(i){return String(i)}},RFC1738:e.RFC1738,RFC3986:e.RFC3986},Zn}var Qn,dl;function fl(){if(dl)return Qn;dl=1;var s=Jn(),t=Object.prototype.hasOwnProperty,e=Array.isArray,i=function(){for(var m=[],_=0;_<256;++_)m.push("%"+((_<16?"0":"")+_.toString(16)).toUpperCase());return m}(),r=function(_){for(;_.length>1;){var b=_.pop(),y=b.obj[b.prop];if(e(y)){for(var E=[],v=0;v<y.length;++v)typeof y[v]<"u"&&E.push(y[v]);b.obj[b.prop]=E}}},n=function(_,b){for(var y=b&&b.plainObjects?Object.create(null):{},E=0;E<_.length;++E)typeof _[E]<"u"&&(y[E]=_[E]);return y},a=function m(_,b,y){if(!b)return _;if(typeof b!="object"){if(e(_))_.push(b);else if(_&&typeof _=="object")(y&&(y.plainObjects||y.allowPrototypes)||!t.call(Object.prototype,b))&&(_[b]=!0);else return[_,b];return _}if(!_||typeof _!="object")return[_].concat(b);var E=_;return e(_)&&!e(b)&&(E=n(_,y)),e(_)&&e(b)?(b.forEach(function(v,M){if(t.call(_,M)){var T=_[M];T&&typeof T=="object"&&v&&typeof v=="object"?_[M]=m(T,v,y):_.push(v)}else _[M]=v}),_):Object.keys(b).reduce(function(v,M){var T=b[M];return t.call(v,M)?v[M]=m(v[M],T,y):v[M]=T,v},E)},o=function(_,b){return Object.keys(b).reduce(function(y,E){return y[E]=b[E],y},_)},h=function(m,_,b){var y=m.replace(/\+/g," ");if(b==="iso-8859-1")return y.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(y)}catch{return y}},l=1024,u=function(_,b,y,E,v){if(_.length===0)return _;var M=_;if(typeof _=="symbol"?M=Symbol.prototype.toString.call(_):typeof _!="string"&&(M=String(_)),y==="iso-8859-1")return escape(M).replace(/%u[0-9a-f]{4}/gi,function(O){return"%26%23"+parseInt(O.slice(2),16)+"%3B"});for(var T="",P=0;P<M.length;P+=l){for(var N=M.length>=l?M.slice(P,P+l):M,G=[],z=0;z<N.length;++z){var D=N.charCodeAt(z);if(D===45||D===46||D===95||D===126||D>=48&&D<=57||D>=65&&D<=90||D>=97&&D<=122||v===s.RFC1738&&(D===40||D===41)){G[G.length]=N.charAt(z);continue}if(D<128){G[G.length]=i[D];continue}if(D<2048){G[G.length]=i[192|D>>6]+i[128|D&63];continue}if(D<55296||D>=57344){G[G.length]=i[224|D>>12]+i[128|D>>6&63]+i[128|D&63];continue}z+=1,D=65536+((D&1023)<<10|N.charCodeAt(z)&1023),G[G.length]=i[240|D>>18]+i[128|D>>12&63]+i[128|D>>6&63]+i[128|D&63]}T+=G.join("")}return T},c=function(_){for(var b=[{obj:{o:_},prop:"o"}],y=[],E=0;E<b.length;++E)for(var v=b[E],M=v.obj[v.prop],T=Object.keys(M),P=0;P<T.length;++P){var N=T[P],G=M[N];typeof G=="object"&&G!==null&&y.indexOf(G)===-1&&(b.push({obj:M,prop:N}),y.push(G))}return r(b),_},d=function(_){return Object.prototype.toString.call(_)==="[object RegExp]"},f=function(_){return!_||typeof _!="object"?!1:!!(_.constructor&&_.constructor.isBuffer&&_.constructor.isBuffer(_))},p=function(_,b){return[].concat(_,b)},g=function(_,b){if(e(_)){for(var y=[],E=0;E<_.length;E+=1)y.push(b(_[E]));return y}return b(_)};return Qn={arrayToObject:n,assign:o,combine:p,compact:c,decode:h,encode:u,isBuffer:f,isRegExp:d,maybeMap:g,merge:a},Qn}var ta,pl;function Gf(){if(pl)return ta;pl=1;var s=Uf(),t=fl(),e=Jn(),i=Object.prototype.hasOwnProperty,r={brackets:function(m){return m+"[]"},comma:"comma",indices:function(m,_){return m+"["+_+"]"},repeat:function(m){return m}},n=Array.isArray,a=Array.prototype.push,o=function(g,m){a.apply(g,n(m)?m:[m])},h=Date.prototype.toISOString,l=e.default,u={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:t.encode,encodeValuesOnly:!1,format:l,formatter:e.formatters[l],indices:!1,serializeDate:function(m){return h.call(m)},skipNulls:!1,strictNullHandling:!1},c=function(m){return typeof m=="string"||typeof m=="number"||typeof m=="boolean"||typeof m=="symbol"||typeof m=="bigint"},d={},f=function g(m,_,b,y,E,v,M,T,P,N,G,z,D,O,V,W,w,C){for(var x=m,R=C,A=0,S=!1;(R=R.get(d))!==void 0&&!S;){var F=R.get(m);if(A+=1,typeof F<"u"){if(F===A)throw new RangeError("Cyclic object value");S=!0}typeof R.get(d)>"u"&&(A=0)}if(typeof N=="function"?x=N(_,x):x instanceof Date?x=D(x):b==="comma"&&n(x)&&(x=t.maybeMap(x,function(rt){return rt instanceof Date?D(rt):rt})),x===null){if(v)return P&&!W?P(_,u.encoder,w,"key",O):_;x=""}if(c(x)||t.isBuffer(x)){if(P){var L=W?_:P(_,u.encoder,w,"key",O);return[V(L)+"="+V(P(x,u.encoder,w,"value",O))]}return[V(_)+"="+V(String(x))]}var U=[];if(typeof x>"u")return U;var X;if(b==="comma"&&n(x))W&&P&&(x=t.maybeMap(x,P)),X=[{value:x.length>0?x.join(",")||null:void 0}];else if(n(N))X=N;else{var J=Object.keys(x);X=G?J.sort(G):J}var Z=T?_.replace(/\./g,"%2E"):_,tt=y&&n(x)&&x.length===1?Z+"[]":Z;if(E&&n(x)&&x.length===0)return tt+"[]";for(var st=0;st<X.length;++st){var K=X[st],ht=typeof K=="object"&&typeof K.value<"u"?K.value:x[K];if(!(M&&ht===null)){var dt=z&&T?K.replace(/\./g,"%2E"):K,bt=n(x)?typeof b=="function"?b(tt,dt):tt:tt+(z?"."+dt:"["+dt+"]");C.set(m,A);var _t=s();_t.set(d,C),o(U,g(ht,bt,b,y,E,v,M,T,b==="comma"&&W&&n(x)?null:P,N,G,z,D,O,V,W,w,_t))}}return U},p=function(m){if(!m)return u;if(typeof m.allowEmptyArrays<"u"&&typeof m.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof m.encodeDotInKeys<"u"&&typeof m.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(m.encoder!==null&&typeof m.encoder<"u"&&typeof m.encoder!="function")throw new TypeError("Encoder has to be a function.");var _=m.charset||u.charset;if(typeof m.charset<"u"&&m.charset!=="utf-8"&&m.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var b=e.default;if(typeof m.format<"u"){if(!i.call(e.formatters,m.format))throw new TypeError("Unknown format option provided.");b=m.format}var y=e.formatters[b],E=u.filter;(typeof m.filter=="function"||n(m.filter))&&(E=m.filter);var v;if(m.arrayFormat in r?v=m.arrayFormat:"indices"in m?v=m.indices?"indices":"repeat":v=u.arrayFormat,"commaRoundTrip"in m&&typeof m.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var M=typeof m.allowDots>"u"?m.encodeDotInKeys===!0?!0:u.allowDots:!!m.allowDots;return{addQueryPrefix:typeof m.addQueryPrefix=="boolean"?m.addQueryPrefix:u.addQueryPrefix,allowDots:M,allowEmptyArrays:typeof m.allowEmptyArrays=="boolean"?!!m.allowEmptyArrays:u.allowEmptyArrays,arrayFormat:v,charset:_,charsetSentinel:typeof m.charsetSentinel=="boolean"?m.charsetSentinel:u.charsetSentinel,commaRoundTrip:m.commaRoundTrip,delimiter:typeof m.delimiter>"u"?u.delimiter:m.delimiter,encode:typeof m.encode=="boolean"?m.encode:u.encode,encodeDotInKeys:typeof m.encodeDotInKeys=="boolean"?m.encodeDotInKeys:u.encodeDotInKeys,encoder:typeof m.encoder=="function"?m.encoder:u.encoder,encodeValuesOnly:typeof m.encodeValuesOnly=="boolean"?m.encodeValuesOnly:u.encodeValuesOnly,filter:E,format:b,formatter:y,serializeDate:typeof m.serializeDate=="function"?m.serializeDate:u.serializeDate,skipNulls:typeof m.skipNulls=="boolean"?m.skipNulls:u.skipNulls,sort:typeof m.sort=="function"?m.sort:null,strictNullHandling:typeof m.strictNullHandling=="boolean"?m.strictNullHandling:u.strictNullHandling}};return ta=function(g,m){var _=g,b=p(m),y,E;typeof b.filter=="function"?(E=b.filter,_=E("",_)):n(b.filter)&&(E=b.filter,y=E);var v=[];if(typeof _!="object"||_===null)return"";var M=r[b.arrayFormat],T=M==="comma"&&b.commaRoundTrip;y||(y=Object.keys(_)),b.sort&&y.sort(b.sort);for(var P=s(),N=0;N<y.length;++N){var G=y[N];b.skipNulls&&_[G]===null||o(v,f(_[G],G,M,T,b.allowEmptyArrays,b.strictNullHandling,b.skipNulls,b.encodeDotInKeys,b.encode?b.encoder:null,b.filter,b.sort,b.allowDots,b.serializeDate,b.format,b.formatter,b.encodeValuesOnly,b.charset,P))}var z=v.join(b.delimiter),D=b.addQueryPrefix===!0?"?":"";return b.charsetSentinel&&(b.charset==="iso-8859-1"?D+="utf8=%26%2310003%3B&":D+="utf8=%E2%9C%93&"),z.length>0?D+z:""},ta}var ea,ml;function Vf(){if(ml)return ea;ml=1;var s=fl(),t=Object.prototype.hasOwnProperty,e=Array.isArray,i={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:s.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},r=function(d){return d.replace(/&#(\d+);/g,function(f,p){return String.fromCharCode(parseInt(p,10))})},n=function(d,f){return d&&typeof d=="string"&&f.comma&&d.indexOf(",")>-1?d.split(","):d},a="utf8=%26%2310003%3B",o="utf8=%E2%9C%93",h=function(f,p){var g={__proto__:null},m=p.ignoreQueryPrefix?f.replace(/^\?/,""):f;m=m.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var _=p.parameterLimit===1/0?void 0:p.parameterLimit,b=m.split(p.delimiter,_),y=-1,E,v=p.charset;if(p.charsetSentinel)for(E=0;E<b.length;++E)b[E].indexOf("utf8=")===0&&(b[E]===o?v="utf-8":b[E]===a&&(v="iso-8859-1"),y=E,E=b.length);for(E=0;E<b.length;++E)if(E!==y){var M=b[E],T=M.indexOf("]="),P=T===-1?M.indexOf("="):T+1,N,G;P===-1?(N=p.decoder(M,i.decoder,v,"key"),G=p.strictNullHandling?null:""):(N=p.decoder(M.slice(0,P),i.decoder,v,"key"),G=s.maybeMap(n(M.slice(P+1),p),function(D){return p.decoder(D,i.decoder,v,"value")})),G&&p.interpretNumericEntities&&v==="iso-8859-1"&&(G=r(G)),M.indexOf("[]=")>-1&&(G=e(G)?[G]:G);var z=t.call(g,N);z&&p.duplicates==="combine"?g[N]=s.combine(g[N],G):(!z||p.duplicates==="last")&&(g[N]=G)}return g},l=function(d,f,p,g){for(var m=g?f:n(f,p),_=d.length-1;_>=0;--_){var b,y=d[_];if(y==="[]"&&p.parseArrays)b=p.allowEmptyArrays&&(m===""||p.strictNullHandling&&m===null)?[]:[].concat(m);else{b=p.plainObjects?Object.create(null):{};var E=y.charAt(0)==="["&&y.charAt(y.length-1)==="]"?y.slice(1,-1):y,v=p.decodeDotInKeys?E.replace(/%2E/g,"."):E,M=parseInt(v,10);!p.parseArrays&&v===""?b={0:m}:!isNaN(M)&&y!==v&&String(M)===v&&M>=0&&p.parseArrays&&M<=p.arrayLimit?(b=[],b[M]=m):v!=="__proto__"&&(b[v]=m)}m=b}return m},u=function(f,p,g,m){if(f){var _=g.allowDots?f.replace(/\.([^.[]+)/g,"[$1]"):f,b=/(\[[^[\]]*])/,y=/(\[[^[\]]*])/g,E=g.depth>0&&b.exec(_),v=E?_.slice(0,E.index):_,M=[];if(v){if(!g.plainObjects&&t.call(Object.prototype,v)&&!g.allowPrototypes)return;M.push(v)}for(var T=0;g.depth>0&&(E=y.exec(_))!==null&&T<g.depth;){if(T+=1,!g.plainObjects&&t.call(Object.prototype,E[1].slice(1,-1))&&!g.allowPrototypes)return;M.push(E[1])}if(E){if(g.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+g.depth+" and strictDepth is true");M.push("["+_.slice(E.index)+"]")}return l(M,p,g,m)}},c=function(f){if(!f)return i;if(typeof f.allowEmptyArrays<"u"&&typeof f.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof f.decodeDotInKeys<"u"&&typeof f.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(f.decoder!==null&&typeof f.decoder<"u"&&typeof f.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof f.charset<"u"&&f.charset!=="utf-8"&&f.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var p=typeof f.charset>"u"?i.charset:f.charset,g=typeof f.duplicates>"u"?i.duplicates:f.duplicates;if(g!=="combine"&&g!=="first"&&g!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var m=typeof f.allowDots>"u"?f.decodeDotInKeys===!0?!0:i.allowDots:!!f.allowDots;return{allowDots:m,allowEmptyArrays:typeof f.allowEmptyArrays=="boolean"?!!f.allowEmptyArrays:i.allowEmptyArrays,allowPrototypes:typeof f.allowPrototypes=="boolean"?f.allowPrototypes:i.allowPrototypes,allowSparse:typeof f.allowSparse=="boolean"?f.allowSparse:i.allowSparse,arrayLimit:typeof f.arrayLimit=="number"?f.arrayLimit:i.arrayLimit,charset:p,charsetSentinel:typeof f.charsetSentinel=="boolean"?f.charsetSentinel:i.charsetSentinel,comma:typeof f.comma=="boolean"?f.comma:i.comma,decodeDotInKeys:typeof f.decodeDotInKeys=="boolean"?f.decodeDotInKeys:i.decodeDotInKeys,decoder:typeof f.decoder=="function"?f.decoder:i.decoder,delimiter:typeof f.delimiter=="string"||s.isRegExp(f.delimiter)?f.delimiter:i.delimiter,depth:typeof f.depth=="number"||f.depth===!1?+f.depth:i.depth,duplicates:g,ignoreQueryPrefix:f.ignoreQueryPrefix===!0,interpretNumericEntities:typeof f.interpretNumericEntities=="boolean"?f.interpretNumericEntities:i.interpretNumericEntities,parameterLimit:typeof f.parameterLimit=="number"?f.parameterLimit:i.parameterLimit,parseArrays:f.parseArrays!==!1,plainObjects:typeof f.plainObjects=="boolean"?f.plainObjects:i.plainObjects,strictDepth:typeof f.strictDepth=="boolean"?!!f.strictDepth:i.strictDepth,strictNullHandling:typeof f.strictNullHandling=="boolean"?f.strictNullHandling:i.strictNullHandling}};return ea=function(d,f){var p=c(f);if(d===""||d===null||typeof d>"u")return p.plainObjects?Object.create(null):{};for(var g=typeof d=="string"?h(d,p):d,m=p.plainObjects?Object.create(null):{},_=Object.keys(g),b=0;b<_.length;++b){var y=_[b],E=u(y,g[y],p,typeof d=="string");m=s.merge(m,E,p)}return p.allowSparse===!0?m:s.compact(m)},ea}var ia,gl;function Hf(){if(gl)return ia;gl=1;var s=Gf(),t=Vf(),e=Jn();return ia={formats:e,parse:t,stringify:s},ia}var _l;function Xf(){if(_l)return ci;_l=1;var s=bf();function t(){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 e=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,r=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,n=["<",">",'"',"`"," ","\r",`
5
+ `," "],a=["{","}","|","\\","^","`"].concat(n),o=["'"].concat(a),h=["%","/","?",";","#"].concat(o),l=["/","?","#"],u=255,c=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,f={javascript:!0,"javascript:":!0},p={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=Hf();function _(v,M,T){if(v&&typeof v=="object"&&v instanceof t)return v;var P=new t;return P.parse(v,M,T),P}t.prototype.parse=function(v,M,T){if(typeof v!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof v);var P=v.indexOf("?"),N=P!==-1&&P<v.indexOf("#")?"?":"#",G=v.split(N),z=/\\/g;G[0]=G[0].replace(z,"/"),v=G.join(N);var D=v;if(D=D.trim(),!T&&v.split("#").length===1){var O=r.exec(D);if(O)return this.path=D,this.href=D,this.pathname=O[1],O[2]?(this.search=O[2],M?this.query=m.parse(this.search.substr(1)):this.query=this.search.substr(1)):M&&(this.search="",this.query={}),this}var V=e.exec(D);if(V){V=V[0];var W=V.toLowerCase();this.protocol=W,D=D.substr(V.length)}if(T||V||D.match(/^\/\/[^@/]+@[^@/]+/)){var w=D.substr(0,2)==="//";w&&!(V&&p[V])&&(D=D.substr(2),this.slashes=!0)}if(!p[V]&&(w||V&&!g[V])){for(var C=-1,x=0;x<l.length;x++){var R=D.indexOf(l[x]);R!==-1&&(C===-1||R<C)&&(C=R)}var A,S;C===-1?S=D.lastIndexOf("@"):S=D.lastIndexOf("@",C),S!==-1&&(A=D.slice(0,S),D=D.slice(S+1),this.auth=decodeURIComponent(A)),C=-1;for(var x=0;x<h.length;x++){var R=D.indexOf(h[x]);R!==-1&&(C===-1||R<C)&&(C=R)}C===-1&&(C=D.length),this.host=D.slice(0,C),D=D.slice(C),this.parseHost(),this.hostname=this.hostname||"";var F=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!F)for(var L=this.hostname.split(/\./),x=0,U=L.length;x<U;x++){var X=L[x];if(X&&!X.match(c)){for(var J="",Z=0,tt=X.length;Z<tt;Z++)X.charCodeAt(Z)>127?J+="x":J+=X[Z];if(!J.match(c)){var st=L.slice(0,x),K=L.slice(x+1),ht=X.match(d);ht&&(st.push(ht[1]),K.unshift(ht[2])),K.length&&(D="/"+K.join(".")+D),this.hostname=st.join(".");break}}}this.hostname.length>u?this.hostname="":this.hostname=this.hostname.toLowerCase(),F||(this.hostname=s.toASCII(this.hostname));var dt=this.port?":"+this.port:"",bt=this.hostname||"";this.host=bt+dt,this.href+=this.host,F&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),D[0]!=="/"&&(D="/"+D))}if(!f[W])for(var x=0,U=o.length;x<U;x++){var _t=o[x];if(D.indexOf(_t)!==-1){var rt=encodeURIComponent(_t);rt===_t&&(rt=escape(_t)),D=D.split(_t).join(rt)}}var ct=D.indexOf("#");ct!==-1&&(this.hash=D.substr(ct),D=D.slice(0,ct));var Ye=D.indexOf("?");if(Ye!==-1?(this.search=D.substr(Ye),this.query=D.substr(Ye+1),M&&(this.query=m.parse(this.query)),D=D.slice(0,Ye)):M&&(this.search="",this.query={}),D&&(this.pathname=D),g[W]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var dt=this.pathname||"",oi=this.search||"";this.path=dt+oi}return this.href=this.format(),this};function b(v){return typeof v=="string"&&(v=_(v)),v instanceof t?v.format():t.prototype.format.call(v)}t.prototype.format=function(){var v=this.auth||"";v&&(v=encodeURIComponent(v),v=v.replace(/%3A/i,":"),v+="@");var M=this.protocol||"",T=this.pathname||"",P=this.hash||"",N=!1,G="";this.host?N=v+this.host:this.hostname&&(N=v+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(N+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(G=m.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var z=this.search||G&&"?"+G||"";return M&&M.substr(-1)!==":"&&(M+=":"),this.slashes||(!M||g[M])&&N!==!1?(N="//"+(N||""),T&&T.charAt(0)!=="/"&&(T="/"+T)):N||(N=""),P&&P.charAt(0)!=="#"&&(P="#"+P),z&&z.charAt(0)!=="?"&&(z="?"+z),T=T.replace(/[?#]/g,function(D){return encodeURIComponent(D)}),z=z.replace("#","%23"),M+N+T+z+P};function y(v,M){return _(v,!1,!0).resolve(M)}t.prototype.resolve=function(v){return this.resolveObject(_(v,!1,!0)).format()};function E(v,M){return v?_(v,!1,!0).resolveObject(M):M}return t.prototype.resolveObject=function(v){if(typeof v=="string"){var M=new t;M.parse(v,!1,!0),v=M}for(var T=new t,P=Object.keys(this),N=0;N<P.length;N++){var G=P[N];T[G]=this[G]}if(T.hash=v.hash,v.href==="")return T.href=T.format(),T;if(v.slashes&&!v.protocol){for(var z=Object.keys(v),D=0;D<z.length;D++){var O=z[D];O!=="protocol"&&(T[O]=v[O])}return g[T.protocol]&&T.hostname&&!T.pathname&&(T.pathname="/",T.path=T.pathname),T.href=T.format(),T}if(v.protocol&&v.protocol!==T.protocol){if(!g[v.protocol]){for(var V=Object.keys(v),W=0;W<V.length;W++){var w=V[W];T[w]=v[w]}return T.href=T.format(),T}if(T.protocol=v.protocol,!v.host&&!p[v.protocol]){for(var U=(v.pathname||"").split("/");U.length&&!(v.host=U.shift()););v.host||(v.host=""),v.hostname||(v.hostname=""),U[0]!==""&&U.unshift(""),U.length<2&&U.unshift(""),T.pathname=U.join("/")}else T.pathname=v.pathname;if(T.search=v.search,T.query=v.query,T.host=v.host||"",T.auth=v.auth,T.hostname=v.hostname||v.host,T.port=v.port,T.pathname||T.search){var C=T.pathname||"",x=T.search||"";T.path=C+x}return T.slashes=T.slashes||v.slashes,T.href=T.format(),T}var R=T.pathname&&T.pathname.charAt(0)==="/",A=v.host||v.pathname&&v.pathname.charAt(0)==="/",S=A||R||T.host&&v.pathname,F=S,L=T.pathname&&T.pathname.split("/")||[],U=v.pathname&&v.pathname.split("/")||[],X=T.protocol&&!g[T.protocol];if(X&&(T.hostname="",T.port=null,T.host&&(L[0]===""?L[0]=T.host:L.unshift(T.host)),T.host="",v.protocol&&(v.hostname=null,v.port=null,v.host&&(U[0]===""?U[0]=v.host:U.unshift(v.host)),v.host=null),S=S&&(U[0]===""||L[0]==="")),A)T.host=v.host||v.host===""?v.host:T.host,T.hostname=v.hostname||v.hostname===""?v.hostname:T.hostname,T.search=v.search,T.query=v.query,L=U;else if(U.length)L||(L=[]),L.pop(),L=L.concat(U),T.search=v.search,T.query=v.query;else if(v.search!=null){if(X){T.host=L.shift(),T.hostname=T.host;var J=T.host&&T.host.indexOf("@")>0?T.host.split("@"):!1;J&&(T.auth=J.shift(),T.hostname=J.shift(),T.host=T.hostname)}return T.search=v.search,T.query=v.query,(T.pathname!==null||T.search!==null)&&(T.path=(T.pathname?T.pathname:"")+(T.search?T.search:"")),T.href=T.format(),T}if(!L.length)return T.pathname=null,T.search?T.path="/"+T.search:T.path=null,T.href=T.format(),T;for(var Z=L.slice(-1)[0],tt=(T.host||v.host||L.length>1)&&(Z==="."||Z==="..")||Z==="",st=0,K=L.length;K>=0;K--)Z=L[K],Z==="."?L.splice(K,1):Z===".."?(L.splice(K,1),st++):st&&(L.splice(K,1),st--);if(!S&&!F)for(;st--;st)L.unshift("..");S&&L[0]!==""&&(!L[0]||L[0].charAt(0)!=="/")&&L.unshift(""),tt&&L.join("/").substr(-1)!=="/"&&L.push("");var ht=L[0]===""||L[0]&&L[0].charAt(0)==="/";if(X){T.hostname=ht?"":L.length?L.shift():"",T.host=T.hostname;var J=T.host&&T.host.indexOf("@")>0?T.host.split("@"):!1;J&&(T.auth=J.shift(),T.hostname=J.shift(),T.host=T.hostname)}return S=S||T.host&&L.length,S&&!ht&&L.unshift(""),L.length>0?T.pathname=L.join("/"):(T.pathname=null,T.path=null),(T.pathname!==null||T.search!==null)&&(T.path=(T.pathname?T.pathname:"")+(T.search?T.search:"")),T.auth=v.auth||T.auth,T.slashes=T.slashes||v.slashes,T.href=T.format(),T},t.prototype.parseHost=function(){var v=this.host,M=i.exec(v);M&&(M=M[0],M!==":"&&(this.port=M.substr(1)),v=v.substr(0,v.length-M.length)),v&&(this.hostname=v)},ci.parse=_,ci.resolve=y,ci.resolveObject=E,ci.format=b,ci.Url=t,ci}var ra=Xf();const yl={};function ot(s,t,e=3){if(yl[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
48
6
  Deprecated since v${s}`):(i=i.split(`
49
- `).splice(r).join(`
7
+ `).splice(e).join(`
50
8
  `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
51
9
  Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
52
- Deprecated since v${s}`),console.warn(i))),kc[t]=!0}const No={get parse(){return Oe("7.3.0","utils.url.parse is deprecated, use native URL API instead."),Dh.parse},get format(){return Oe("7.3.0","utils.url.format is deprecated, use native URL API instead."),Dh.format},get resolve(){return Oe("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),Dh.resolve}};function Si(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function $n(s){return s.split("?")[0].split("#")[0]}function ep(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rp(s,t,r){return s.replace(new RegExp(ep(t),"g"),r)}function ip(s,t){let r="",i=0,n=-1,o=0,h=-1;for(let c=0;c<=s.length;++c){if(c<s.length)h=s.charCodeAt(c);else{if(h===47)break;h=47}if(h===47){if(!(n===c-1||o===1))if(n!==c-1&&o===2){if(r.length<2||i!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){const b=r.lastIndexOf("/");if(b!==r.length-1){b===-1?(r="",i=0):(r=r.slice(0,b),i=r.length-1-r.lastIndexOf("/")),n=c,o=0;continue}}else if(r.length===2||r.length===1){r="",i=0,n=c,o=0;continue}}}else r.length>0?r+=`/${s.slice(n+1,c)}`:r=s.slice(n+1,c),i=c-n-1;n=c,o=0}else h===46&&o!==-1?++o:o=-1}return r}const $r={toPosix(s){return rp(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){Si(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const r=/^[^/:]+:\/{0,2}/.exec(s);return r?r[0]:""},toAbsolute(s,t,r){if(Si(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=$n(this.toPosix(t??ue.ADAPTER.getBaseUrl())),n=$n(this.toPosix(r??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?$r.join(n,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(Si(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const r=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=ip(s),s.length>0&&i&&(s+="/"),r?`/${s}`:t+s},isAbsolute(s){return Si(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let r=0;r<s.length;++r){const i=s[r];if(Si(i),i.length>0)if(t===void 0)t=i;else{const n=s[r-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(Si(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const r=t===47;let i=-1,n=!0;const o=this.getProtocol(s),h=s;s=s.slice(o.length);for(let c=s.length-1;c>=1;--c)if(t=s.charCodeAt(c),t===47){if(!n){i=c;break}}else n=!1;return i===-1?r?"/":this.isUrl(h)?o+s:o:r&&i===1?"//":o+s.slice(0,i)},rootname(s){Si(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const r=s.indexOf("/",t.length);r!==-1?t=s.slice(0,r):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){Si(s),t&&Si(t),s=$n(this.toPosix(s));let r=0,i=-1,n=!0,o;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let h=t.length-1,c=-1;for(o=s.length-1;o>=0;--o){const b=s.charCodeAt(o);if(b===47){if(!n){r=o+1;break}}else c===-1&&(n=!1,c=o+1),h>=0&&(b===t.charCodeAt(h)?--h===-1&&(i=o):(h=-1,i=c))}return r===i?i=c:i===-1&&(i=s.length),s.slice(r,i)}for(o=s.length-1;o>=0;--o)if(s.charCodeAt(o)===47){if(!n){r=o+1;break}}else i===-1&&(n=!1,i=o+1);return i===-1?"":s.slice(r,i)},extname(s){Si(s),s=$n(this.toPosix(s));let t=-1,r=0,i=-1,n=!0,o=0;for(let h=s.length-1;h>=0;--h){const c=s.charCodeAt(h);if(c===47){if(!n){r=h+1;break}continue}i===-1&&(n=!1,i=h+1),c===46?t===-1?t=h:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||i===-1||o===0||o===1&&t===i-1&&t===r+1?"":s.slice(t,i)},parse(s){Si(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=$n(this.toPosix(s));let r=s.charCodeAt(0);const i=this.isAbsolute(s);let n;t.root=this.rootname(s),i||this.hasProtocol(s)?n=1:n=0;let o=-1,h=0,c=-1,b=!0,T=s.length-1,C=0;for(;T>=n;--T){if(r=s.charCodeAt(T),r===47){if(!b){h=T+1;break}continue}c===-1&&(b=!1,c=T+1),r===46?o===-1?o=T:C!==1&&(C=1):o!==-1&&(C=-1)}return o===-1||c===-1||C===0||C===1&&o===c-1&&o===h+1?c!==-1&&(h===0&&i?t.base=t.name=s.slice(1,c):t.base=t.name=s.slice(h,c)):(h===0&&i?(t.name=s.slice(1,o),t.base=s.slice(1,c)):(t.name=s.slice(h,o),t.base=s.slice(h,c)),t.ext=s.slice(o,c)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let Rh;async function Bc(){return Rh??(Rh=(async()=>{var o;const s=document.createElement("canvas").getContext("webgl");if(!s)return Vr.UNPACK;const t=await new Promise(h=>{const c=document.createElement("video");c.onloadeddata=()=>h(c),c.onerror=()=>h(null),c.autoplay=!1,c.crossOrigin="anonymous",c.preload="auto",c.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",c.load()});if(!t)return Vr.UNPACK;const r=s.createTexture();s.bindTexture(s.TEXTURE_2D,r);const i=s.createFramebuffer();s.bindFramebuffer(s.FRAMEBUFFER,i),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,r,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t);const n=new Uint8Array(4);return s.readPixels(0,0,1,1,s.RGBA,s.UNSIGNED_BYTE,n),s.deleteFramebuffer(i),s.deleteTexture(r),(o=s.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?Vr.PMA:Vr.UNPACK})()),Rh}function sp(){Oe("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")}function np(){Oe("7.0.0",`sayHello is deprecated, please use Renderer's "hello" option`)}let Ih;function Oc(){return typeof Ih>"u"&&(Ih=function(){var t;const s={stencil:!0,failIfMajorPerformanceCaveat:ue.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!ue.ADAPTER.getWebGLRenderingContext())return!1;const r=ue.ADAPTER.createCanvas();let i=r.getContext("webgl",s)||r.getContext("experimental-webgl",s);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const o=i.getExtension("WEBGL_lose_context");o&&o.loseContext()}return i=null,n}catch{return!1}}()),Ih}var op={grad:.9,turn:360,rad:360/(2*Math.PI)},as=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Rr=function(s,t,r){return t===void 0&&(t=0),r===void 0&&(r=Math.pow(10,t)),Math.round(r*s)/r+0},ci=function(s,t,r){return t===void 0&&(t=0),r===void 0&&(r=1),s>r?r:s>t?s:t},Nc=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Uc=function(s){return{r:ci(s.r,0,255),g:ci(s.g,0,255),b:ci(s.b,0,255),a:ci(s.a)}},Fh=function(s){return{r:Rr(s.r),g:Rr(s.g),b:Rr(s.b),a:Rr(s.a,3)}},ap=/^#([0-9a-f]{3,8})$/i,Uo=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Gc=function(s){var t=s.r,r=s.g,i=s.b,n=s.a,o=Math.max(t,r,i),h=o-Math.min(t,r,i),c=h?o===t?(r-i)/h:o===r?2+(i-t)/h:4+(t-r)/h:0;return{h:60*(c<0?c+6:c),s:o?h/o*100:0,v:o/255*100,a:n}},Vc=function(s){var t=s.h,r=s.s,i=s.v,n=s.a;t=t/360*6,r/=100,i/=100;var o=Math.floor(t),h=i*(1-r),c=i*(1-(t-o)*r),b=i*(1-(1-t+o)*r),T=o%6;return{r:255*[i,c,h,h,b,i][T],g:255*[b,i,i,c,h,h][T],b:255*[h,h,b,i,i,c][T],a:n}},Xc=function(s){return{h:Nc(s.h),s:ci(s.s,0,100),l:ci(s.l,0,100),a:ci(s.a)}},zc=function(s){return{h:Rr(s.h),s:Rr(s.s),l:Rr(s.l),a:Rr(s.a,3)}},Wc=function(s){return Vc((r=(t=s).s,{h:t.h,s:(r*=((i=t.l)<50?i:100-i)/100)>0?2*r/(i+r)*100:0,v:i+r,a:t.a}));var t,r,i},Mn=function(s){return{h:(t=Gc(s)).h,s:(n=(200-(r=t.s))*(i=t.v)/100)>0&&n<200?r*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,r,i,n},hp=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lp=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,up=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cp=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lh={string:[[function(s){var t=ap.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?Rr(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?Rr(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=up.exec(s)||cp.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Uc({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=hp.exec(s)||lp.exec(s);if(!t)return null;var r,i,n=Xc({h:(r=t[1],i=t[2],i===void 0&&(i="deg"),Number(r)*(op[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Wc(n)},"hsl"]],object:[[function(s){var t=s.r,r=s.g,i=s.b,n=s.a,o=n===void 0?1:n;return as(t)&&as(r)&&as(i)?Uc({r:Number(t),g:Number(r),b:Number(i),a:Number(o)}):null},"rgb"],[function(s){var t=s.h,r=s.s,i=s.l,n=s.a,o=n===void 0?1:n;if(!as(t)||!as(r)||!as(i))return null;var h=Xc({h:Number(t),s:Number(r),l:Number(i),a:Number(o)});return Wc(h)},"hsl"],[function(s){var t=s.h,r=s.s,i=s.v,n=s.a,o=n===void 0?1:n;if(!as(t)||!as(r)||!as(i))return null;var h=function(c){return{h:Nc(c.h),s:ci(c.s,0,100),v:ci(c.v,0,100),a:ci(c.a)}}({h:Number(t),s:Number(r),v:Number(i),a:Number(o)});return Vc(h)},"hsv"]]},Hc=function(s,t){for(var r=0;r<t.length;r++){var i=t[r][0](s);if(i)return[i,t[r][1]]}return[null,void 0]},fp=function(s){return typeof s=="string"?Hc(s.trim(),Lh.string):typeof s=="object"&&s!==null?Hc(s,Lh.object):[null,void 0]},kh=function(s,t){var r=Mn(s);return{h:r.h,s:ci(r.s+100*t,0,100),l:r.l,a:r.a}},Bh=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},Yc=function(s,t){var r=Mn(s);return{h:r.h,s:r.s,l:ci(r.l+100*t,0,100),a:r.a}},Oh=function(){function s(t){this.parsed=fp(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return Rr(Bh(this.rgba),2)},s.prototype.isDark=function(){return Bh(this.rgba)<.5},s.prototype.isLight=function(){return Bh(this.rgba)>=.5},s.prototype.toHex=function(){return t=Fh(this.rgba),r=t.r,i=t.g,n=t.b,h=(o=t.a)<1?Uo(Rr(255*o)):"","#"+Uo(r)+Uo(i)+Uo(n)+h;var t,r,i,n,o,h},s.prototype.toRgb=function(){return Fh(this.rgba)},s.prototype.toRgbString=function(){return t=Fh(this.rgba),r=t.r,i=t.g,n=t.b,(o=t.a)<1?"rgba("+r+", "+i+", "+n+", "+o+")":"rgb("+r+", "+i+", "+n+")";var t,r,i,n,o},s.prototype.toHsl=function(){return zc(Mn(this.rgba))},s.prototype.toHslString=function(){return t=zc(Mn(this.rgba)),r=t.h,i=t.s,n=t.l,(o=t.a)<1?"hsla("+r+", "+i+"%, "+n+"%, "+o+")":"hsl("+r+", "+i+"%, "+n+"%)";var t,r,i,n,o},s.prototype.toHsv=function(){return t=Gc(this.rgba),{h:Rr(t.h),s:Rr(t.s),v:Rr(t.v),a:Rr(t.a,3)};var t},s.prototype.invert=function(){return zi({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),zi(kh(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),zi(kh(this.rgba,-t))},s.prototype.grayscale=function(){return zi(kh(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),zi(Yc(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),zi(Yc(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?zi({r:(r=this.rgba).r,g:r.g,b:r.b,a:t}):Rr(this.rgba.a,3);var r},s.prototype.hue=function(t){var r=Mn(this.rgba);return typeof t=="number"?zi({h:t,s:r.s,l:r.l,a:r.a}):Rr(r.h)},s.prototype.isEqual=function(t){return this.toHex()===zi(t).toHex()},s}(),zi=function(s){return s instanceof Oh?s:new Oh(s)},jc=[],dp=function(s){s.forEach(function(t){jc.indexOf(t)<0&&(t(Oh,Lh),jc.push(t))})};function pp(s,t){var r={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var n in r)i[r[n]]=n;var o={};s.prototype.toName=function(h){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var c,b,T=i[this.toHex()];if(T)return T;if(h!=null&&h.closest){var C=this.toRgb(),x=1/0,$="black";if(!o.length)for(var I in r)o[I]=new s(r[I]).toRgb();for(var B in r){var U=(c=C,b=o[B],Math.pow(c.r-b.r,2)+Math.pow(c.g-b.g,2)+Math.pow(c.b-b.b,2));U<x&&(x=U,$=B)}return $}},t.string.push([function(h){var c=h.toLowerCase(),b=c==="transparent"?"#0000":r[c];return b?new s(b).toRgb():null},"name"])}dp([pp]);const tn=class Va{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Va)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,r){const i=typeof t;if(i!==typeof r)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===r;if(Array.isArray(t)&&Array.isArray(r)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(r))return t.length!==r.length?!1:t.every((n,o)=>n===r[o]);if(t!==null&&r!==null){const n=Object.keys(t),o=Object.keys(r);return n.length!==o.length?!1:n.every(h=>t[h]===r[h])}return t===r}toRgba(){const[t,r,i,n]=this._components;return{r:t,g:r,b:i,a:n}}toRgb(){const[t,r,i]=this._components;return{r:t,g:r,b:i}}toRgbaString(){const[t,r,i]=this.toUint8RgbArray();return`rgba(${t},${r},${i},${this.alpha})`}toUint8RgbArray(t){const[r,i,n]=this._components;return t=t??[],t[0]=Math.round(r*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toRgbArray(t){t=t??[];const[r,i,n]=this._components;return t[0]=r,t[1]=i,t[2]=n,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[r,i,n,o]=Va.temp.setValue(t)._components;return this._components[0]*=r,this._components[1]*=i,this._components[2]*=n,this._components[3]*=o,this.refreshInt(),this._value=null,this}premultiply(t,r=!0){return r&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,r=!0){if(t===1)return(255<<24)+this._int;if(t===0)return r?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,o=this._int&255;return r&&(i=i*t+.5|0,n=n*t+.5|0,o=o*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+o}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[r,i,n]=this._components;return this._components[0]=Math.round(r*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(n*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[r,i,n,o]=this._components;return t[0]=r,t[1]=i,t[2]=n,t[3]=o,t}normalize(t){let r,i,n,o;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const h=t;r=(h>>16&255)/255,i=(h>>8&255)/255,n=(h&255)/255,o=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[r,i,n,o=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[r,i,n,o=255]=t,r/=255,i/=255,n/=255,o/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const c=Va.HEX_PATTERN.exec(t);c&&(t=`#${c[2]}`)}const h=zi(t);h.isValid()&&({r,g:i,b:n,a:o}=h.rgba,r/=255,i/=255,n/=255)}if(r!==void 0)this._components[0]=r,this._components[1]=i,this._components[2]=n,this._components[3]=o,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,r,i]=this._components;this._int=(t*255<<16)+(r*255<<8)+(i*255|0)}_clamp(t,r=0,i=1){return typeof t=="number"?Math.min(Math.max(t,r),i):(t.forEach((n,o)=>{t[o]=Math.min(Math.max(n,r),i)}),t)}};tn.shared=new tn,tn.temp=new tn,tn.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let rr=tn;function _p(s,t=[]){return Oe("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),rr.shared.setValue(s).toRgbArray(t)}function qc(s){return Oe("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),rr.shared.setValue(s).toHex()}function gp(s){return Oe("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),rr.shared.setValue(s).toNumber()}function Zc(s){return Oe("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),rr.shared.setValue(s).toNumber()}function mp(){const s=[],t=[];for(let i=0;i<32;i++)s[i]=i,t[i]=i;s[De.NORMAL_NPM]=De.NORMAL,s[De.ADD_NPM]=De.ADD,s[De.SCREEN_NPM]=De.SCREEN,t[De.NORMAL]=De.NORMAL_NPM,t[De.ADD]=De.ADD_NPM,t[De.SCREEN]=De.SCREEN_NPM;const r=[];return r.push(t),r.push(s),r}const Nh=mp();function Uh(s,t){return Nh[t?1:0][s]}function yp(s,t,r,i=!0){return Oe("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),rr.shared.setValue(s).premultiply(t,i).toArray(r??new Float32Array(4))}function vp(s,t){return Oe("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),rr.shared.setValue(s).toPremultiplied(t)}function xp(s,t,r,i=!0){return Oe("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),rr.shared.setValue(s).premultiply(t,i).toArray(r??new Float32Array(4))}const Qc=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Kc(s,t=null){const r=s*6;if(t=t||new Uint16Array(r),t.length!==r)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${r}`);for(let i=0,n=0;i<r;i+=6,n+=4)t[i+0]=n+0,t[i+1]=n+1,t[i+2]=n+2,t[i+3]=n+0,t[i+4]=n+2,t[i+5]=n+3;return t}function Go(s){if(s.BYTES_PER_ELEMENT===4)return s instanceof Float32Array?"Float32Array":s instanceof Uint32Array?"Uint32Array":"Int32Array";if(s.BYTES_PER_ELEMENT===2){if(s instanceof Uint16Array)return"Uint16Array"}else if(s.BYTES_PER_ELEMENT===1&&s instanceof Uint8Array)return"Uint8Array";return null}const bp={Float32Array,Uint32Array,Int32Array,Uint8Array};function Ap(s,t){let r=0,i=0;const n={};for(let b=0;b<s.length;b++)i+=t[b],r+=s[b].length;const o=new ArrayBuffer(r*4);let h=null,c=0;for(let b=0;b<s.length;b++){const T=t[b],C=s[b],x=Go(C);n[x]||(n[x]=new bp[x](o)),h=n[x];for(let $=0;$<C.length;$++){const I=($/T|0)*i+c,B=$%T;h[I+B]=C[$]}c+=T}return new Float32Array(o)}function Dn(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Gh(s){return!(s&s-1)&&!!s}function Vh(s){let t=(s>65535?1:0)<<4;s>>>=t;let r=(s>255?1:0)<<3;return s>>>=r,t|=r,r=(s>15?1:0)<<2,s>>>=r,t|=r,r=(s>3?1:0)<<1,s>>>=r,t|=r,t|s>>1}function ks(s,t,r){const i=s.length;let n;if(t>=i||r===0)return;r=t+r>i?i-t:r;const o=i-r;for(n=t;n<o;++n)s[n]=s[n+r];s.length=o}function hs(s){return s===0?0:s<0?-1:1}let wp=0;function vs(){return++wp}const Xh=class{constructor(s,t,r,i){this.left=s,this.top=t,this.right=r,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};Xh.EMPTY=new Xh(0,0,0,0);let zh=Xh;const Wh={},Xr=Object.create(null),ii=Object.create(null);function Tp(){let s;for(s in Xr)Xr[s].destroy();for(s in ii)ii[s].destroy()}function Ep(){let s;for(s in Xr)delete Xr[s];for(s in ii)delete ii[s]}class Jc{constructor(t,r,i){this._canvas=ue.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||ue.RESOLUTION,this.resize(t,r)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,r){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(r*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function t0(s,t,r){for(let i=0,n=4*r*t;i<t;++i,n+=4)if(s[n+3]!==0)return!1;return!0}function e0(s,t,r,i,n){const o=4*t;for(let h=i,c=i*o+4*r;h<=n;++h,c+=o)if(s[c+3]!==0)return!1;return!0}function r0(s){const{width:t,height:r}=s,i=s.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const n=i.getImageData(0,0,t,r).data;let o=0,h=0,c=t-1,b=r-1;for(;h<r&&t0(n,t,h);)++h;if(h===r)return zh.EMPTY;for(;t0(n,t,b);)--b;for(;e0(n,t,o,h,b);)++o;for(;e0(n,t,c,h,b);)--c;return++c,++b,new zh(o,h,c,b)}function i0(s){const t=r0(s),{width:r,height:i}=t;let n=null;if(!t.isEmpty()){const o=s.getContext("2d");if(o===null)throw new TypeError("Failed to get canvas 2D context");n=o.getImageData(t.left,t.top,r,i)}return{width:r,height:i,data:n}}function Cp(s){const t=Qc.exec(s);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}function s0(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const r=new URL(s,document.baseURI);return r.hostname!==t.hostname||r.port!==t.port||r.protocol!==t.protocol?"anonymous":""}function Wi(s,t=1){var i;const r=(i=ue.RETINA_PREFIX)==null?void 0:i.exec(s);return r?parseFloat(r[1]):t}const Sp=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:ii,BoundingBox:zh,CanvasRenderTarget:Jc,DATA_URI:Qc,EventEmitter:Xi,ProgramCache:Wh,TextureCache:Xr,clearTextureCache:Ep,correctBlendMode:Uh,createIndicesForQuads:Kc,decomposeDataUri:Cp,deprecation:Oe,destroyTextureCache:Tp,detectVideoAlphaMode:Bc,determineCrossOrigin:s0,earcut:rc,getBufferType:Go,getCanvasBoundingBox:r0,getResolutionOfUrl:Wi,hex2rgb:_p,hex2string:qc,interleaveTypedArrays:Ap,isMobile:Ci,isPow2:Gh,isWebGLSupported:Oc,log2:Vh,nextPow2:Dn,path:$r,premultiplyBlendMode:Nh,premultiplyRgba:yp,premultiplyTint:vp,premultiplyTintToRgba:xp,removeItems:ks,rgb2hex:Zc,sayHello:np,sign:hs,skipHello:sp,string2hex:gp,trimCanvas:i0,uid:vs,url:No},Symbol.toStringTag,{value:"Module"}));var Kt=(s=>(s.Renderer="renderer",s.Application="application",s.RendererSystem="renderer-webgl-system",s.RendererPlugin="renderer-webgl-plugin",s.CanvasRendererSystem="renderer-canvas-system",s.CanvasRendererPlugin="renderer-canvas-plugin",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s))(Kt||{});const Hh=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},n0=(s,t)=>Hh(s).priority??t,be={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Hh).forEach(t=>{t.type.forEach(r=>{var i,n;return(n=(i=this._removeHandlers)[r])==null?void 0:n.call(i,t)})}),this},add(...s){return s.map(Hh).forEach(t=>{t.type.forEach(r=>{var o,h;const i=this._addHandlers,n=this._queue;i[r]?(o=i[r])==null||o.call(i,t):(n[r]=n[r]||[],(h=n[r])==null||h.push(t))})}),this},handle(s,t,r){var h;const i=this._addHandlers,n=this._removeHandlers;if(i[s]||n[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,n[s]=r;const o=this._queue;return o[s]&&((h=o[s])==null||h.forEach(c=>t(c)),delete o[s]),this},handleByMap(s,t){return this.handle(s,r=>{r.name&&(t[r.name]=r.ref)},r=>{r.name&&delete t[r.name]})},handleByList(s,t,r=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,o)=>n0(o,r)-n0(n,r)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})}};class Vo{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const Pp=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
53
- `);function $p(s){let t="";for(let r=0;r<s;++r)r>0&&(t+=`
54
- else `),r<s-1&&(t+=`if(test == ${r}.0){}`);return t}function o0(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const r=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=Pp.replace(/%forloop%/gi,$p(s));if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))s=s/2|0;else break}return s}const Yh=0,jh=1,qh=2,Zh=3,Qh=4,Kh=5;class Pi{constructor(){this.data=0,this.blendMode=De.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Yh)}set blend(t){!!(this.data&1<<Yh)!==t&&(this.data^=1<<Yh)}get offsets(){return!!(this.data&1<<jh)}set offsets(t){!!(this.data&1<<jh)!==t&&(this.data^=1<<jh)}get culling(){return!!(this.data&1<<qh)}set culling(t){!!(this.data&1<<qh)!==t&&(this.data^=1<<qh)}get depthTest(){return!!(this.data&1<<Zh)}set depthTest(t){!!(this.data&1<<Zh)!==t&&(this.data^=1<<Zh)}get depthMask(){return!!(this.data&1<<Kh)}set depthMask(t){!!(this.data&1<<Kh)!==t&&(this.data^=1<<Kh)}get clockwiseFrontFace(){return!!(this.data&1<<Qh)}set clockwiseFrontFace(t){!!(this.data&1<<Qh)!==t&&(this.data^=1<<Qh)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==De.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Pi;return t.depthTest=!1,t.blend=!0,t}}Pi.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Xo=[];function Jh(s,t){if(!s)return null;let r="";if(typeof s=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(s);i&&(r=i[1].toLowerCase())}for(let i=Xo.length-1;i>=0;--i){const n=Xo[i];if(n.test&&n.test(s,r))return new n(s,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class si{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,r,i,n,o,h,c,b){if(arguments.length>8)throw new Error("max arguments reached");const{name:T,items:C}=this;this._aliasCount++;for(let x=0,$=C.length;x<$;x++)C[x][T](t,r,i,n,o,h,c,b);return C===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const r=this.items.indexOf(t);return r!==-1&&(this.ensureNonAliasedItems(),this.items.splice(r,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(si.prototype,{dispatch:{value:si.prototype.emit},run:{value:si.prototype.emit}});class en{constructor(t=0,r=0){this._width=t,this._height=r,this.destroyed=!1,this.internal=!1,this.onResize=new si("setRealSize"),this.onUpdate=new si("update"),this.onError=new si("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,r){(t!==this._width||r!==this._height)&&(this._width=t,this._height=r,this.onResize.emit(t,r))}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,r,i){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,r){return!1}}class Rn extends en{constructor(t,r){const{width:i,height:n}=r||{};if(!i||!n)throw new Error("BufferResource width or height invalid");super(i,n),this.data=t,this.unpackAlignment=r.unpackAlignment??4}upload(t,r,i){const n=t.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,this.unpackAlignment),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Vr.UNPACK);const o=r.realWidth,h=r.realHeight;return i.width===o&&i.height===h?n.texSubImage2D(r.target,0,0,0,o,h,r.format,i.type,this.data):(i.width=o,i.height=h,n.texImage2D(r.target,0,i.internalFormat,o,h,0,r.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const Mp={scaleMode:Gi.NEAREST,alphaMode:Vr.NPM},tl=class An extends Xi{constructor(t=null,r=null){super(),r=Object.assign({},An.defaultOptions,r);const{alphaMode:i,mipmap:n,anisotropicLevel:o,scaleMode:h,width:c,height:b,wrapMode:T,format:C,type:x,target:$,resolution:I,resourceOptions:B}=r;t&&!(t instanceof en)&&(t=Jh(t,B),t.internal=!0),this.resolution=I||ue.RESOLUTION,this.width=Math.round((c||0)*this.resolution)/this.resolution,this.height=Math.round((b||0)*this.resolution)/this.resolution,this._mipmap=n,this.anisotropicLevel=o,this._wrapMode=T,this._scaleMode=h,this.format=C,this.type=x,this.target=$,this.alphaMode=i,this.uid=vs(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=c>0&&b>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}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(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,r){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),r!==void 0&&r!==this.mipmap&&(this.mipmap=r,i=!0),i&&this.dirtyStyleId++,this}setSize(t,r,i){return i=i||this.resolution,this.setRealSize(t*i,r*i,i)}setRealSize(t,r,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(r)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Gh(this.realWidth)&&Gh(this.realHeight)}setResolution(t){const r=this.resolution;return r===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*r)/t,this.height=Math.round(this.height*r)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,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(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete ii[this.cacheId],delete Xr[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),An.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,r,i=ue.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let o=null;if(n)o=t;else{if(!t._pixiId){const c=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t._pixiId=`${c}_${vs()}`}o=t._pixiId}let h=ii[o];if(n&&i&&!h)throw new Error(`The cacheId "${o}" does not exist in BaseTextureCache.`);return h||(h=new An(t,r),h.cacheId=o,An.addToCache(h,o)),h}static fromBuffer(t,r,i,n){t=t||new Float32Array(r*i*4);const o=new Rn(t,{width:r,height:i,...n==null?void 0:n.resourceOptions});let h,c;return t instanceof Float32Array?(h=qt.RGBA,c=Pe.FLOAT):t instanceof Int32Array?(h=qt.RGBA_INTEGER,c=Pe.INT):t instanceof Uint32Array?(h=qt.RGBA_INTEGER,c=Pe.UNSIGNED_INT):t instanceof Int16Array?(h=qt.RGBA_INTEGER,c=Pe.SHORT):t instanceof Uint16Array?(h=qt.RGBA_INTEGER,c=Pe.UNSIGNED_SHORT):t instanceof Int8Array?(h=qt.RGBA,c=Pe.BYTE):(h=qt.RGBA,c=Pe.UNSIGNED_BYTE),o.internal=!0,new An(o,Object.assign({},Mp,{type:c,format:h},n))}static addToCache(t,r){r&&(t.textureCacheIds.includes(r)||t.textureCacheIds.push(r),ii[r]&&ii[r]!==t&&console.warn(`BaseTexture added to the cache with an id [${r}] that already had an entry`),ii[r]=t)}static removeFromCache(t){if(typeof t=="string"){const r=ii[t];if(r){const i=r.textureCacheIds.indexOf(t);return i>-1&&r.textureCacheIds.splice(i,1),delete ii[t],r}}else if(t!=null&&t.textureCacheIds){for(let r=0;r<t.textureCacheIds.length;++r)delete ii[t.textureCacheIds[r]];return t.textureCacheIds.length=0,t}return null}};tl.defaultOptions={mipmap:wi.POW2,anisotropicLevel:0,scaleMode:Gi.LINEAR,wrapMode:Vi.CLAMP,alphaMode:Vr.UNPACK,target:Fs.TEXTURE_2D,format:qt.RGBA,type:Pe.UNSIGNED_BYTE},tl._globalBatch=0;let Ge=tl;class zo{constructor(){this.texArray=null,this.blend=0,this.type=Ai.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Dp=0,Ar=class v2{constructor(t,r=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=r,this.id=Dp++,this.disposeRunner=new si("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Ei.ELEMENT_ARRAY_BUFFER:Ei.ARRAY_BUFFER}get index(){return this.type===Ei.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new v2(t)}};class In{constructor(t,r=0,i=!1,n=Pe.FLOAT,o,h,c,b=1){this.buffer=t,this.size=r,this.normalized=i,this.type=n,this.stride=o,this.start=h,this.instance=c,this.divisor=b}destroy(){this.buffer=null}static from(t,r,i,n,o){return new In(t,r,i,n,o)}}const Rp={Float32Array,Uint32Array,Int32Array,Uint8Array};function Ip(s,t){let r=0,i=0;const n={};for(let b=0;b<s.length;b++)i+=t[b],r+=s[b].length;const o=new ArrayBuffer(r*4);let h=null,c=0;for(let b=0;b<s.length;b++){const T=t[b],C=s[b],x=Go(C);n[x]||(n[x]=new Rp[x](o)),h=n[x];for(let $=0;$<C.length;$++){const I=($/T|0)*i+c,B=$%T;h[I+B]=C[$]}c+=T}return new Float32Array(o)}const a0={5126:4,5123:2,5121:1};let Fp=0;const Lp={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class ls{constructor(t=[],r={}){this.buffers=t,this.indexBuffer=null,this.attributes=r,this.glVertexArrayObjects={},this.id=Fp++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new si("disposeGeometry"),this.refCount=0}addAttribute(t,r,i=0,n=!1,o,h,c,b=!1){if(!r)throw new Error("You must pass a buffer when creating an attribute");r instanceof Ar||(r instanceof Array&&(r=new Float32Array(r)),r=new Ar(r));const T=t.split("|");if(T.length>1){for(let x=0;x<T.length;x++)this.addAttribute(T[x],r,i,n,o);return this}let C=this.buffers.indexOf(r);return C===-1&&(this.buffers.push(r),C=this.buffers.length-1),this.attributes[t]=new In(C,i,n,o,h,c,b),this.instanced=this.instanced||b,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Ar||(t instanceof Array&&(t=new Uint16Array(t)),t=new Ar(t)),t.type=Ei.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],r=[],i=new Ar;let n;for(n in this.attributes){const o=this.attributes[n],h=this.buffers[o.buffer];t.push(h.data),r.push(o.size*a0[o.type]/4),o.buffer=0}for(i.data=Ip(t,r),n=0;n<this.buffers.length;n++)this.buffers[n]!==this.indexBuffer&&this.buffers[n].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const r=this.attributes[t];return this.buffers[r.buffer].data.length/(r.stride/4||r.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new ls;for(let r=0;r<this.buffers.length;r++)t.buffers[r]=new Ar(this.buffers[r].data.slice(0));for(const r in this.attributes){const i=this.attributes[r];t.attributes[r]=new In(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Ei.ELEMENT_ARRAY_BUFFER),t}static merge(t){const r=new ls,i=[],n=[],o=[];let h;for(let c=0;c<t.length;c++){h=t[c];for(let b=0;b<h.buffers.length;b++)n[b]=n[b]||0,n[b]+=h.buffers[b].data.length,o[b]=0}for(let c=0;c<h.buffers.length;c++)i[c]=new Lp[Go(h.buffers[c].data)](n[c]),r.buffers[c]=new Ar(i[c]);for(let c=0;c<t.length;c++){h=t[c];for(let b=0;b<h.buffers.length;b++)i[b].set(h.buffers[b].data,o[b]),o[b]+=h.buffers[b].data.length}if(r.attributes=h.attributes,h.indexBuffer){r.indexBuffer=r.buffers[h.buffers.indexOf(h.indexBuffer)],r.indexBuffer.type=Ei.ELEMENT_ARRAY_BUFFER;let c=0,b=0,T=0,C=0;for(let x=0;x<h.buffers.length;x++)if(h.buffers[x]!==h.indexBuffer){C=x;break}for(const x in h.attributes){const $=h.attributes[x];($.buffer|0)===C&&(b+=$.size*a0[$.type]/4)}for(let x=0;x<t.length;x++){const $=t[x].indexBuffer.data;for(let I=0;I<$.length;I++)r.indexBuffer.data[I+T]+=c;c+=t[x].buffers[C].data.length/b,T+=$.length}}return r}}class el extends ls{constructor(t=!1){super(),this._buffer=new Ar(null,t,!1),this._indexBuffer=new Ar(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Pe.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Pe.FLOAT).addAttribute("aColor",this._buffer,4,!0,Pe.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Pe.FLOAT).addIndex(this._indexBuffer)}}const Fn=Math.PI*2,h0=180/Math.PI,l0=Math.PI/180;var Ir=(s=>(s[s.POLY=0]="POLY",s[s.RECT=1]="RECT",s[s.CIRC=2]="CIRC",s[s.ELIP=3]="ELIP",s[s.RREC=4]="RREC",s))(Ir||{});class He{constructor(t=0,r=0){this.x=0,this.y=0,this.x=t,this.y=r}clone(){return new He(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,r=t){return this.x=t,this.y=r,this}}He.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Wo=[new He,new He,new He,new He];class Ve{constructor(t=0,r=0,i=0,n=0){this.x=Number(t),this.y=Number(r),this.width=Number(i),this.height=Number(n),this.type=Ir.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 Ve(0,0,0,0)}clone(){return new Ve(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,r){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&r>=this.y&&r<this.y+this.height}intersects(t,r){if(!r){const ft=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=ft)return!1;const wt=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>wt}const i=this.left,n=this.right,o=this.top,h=this.bottom;if(n<=i||h<=o)return!1;const c=Wo[0].set(t.left,t.top),b=Wo[1].set(t.left,t.bottom),T=Wo[2].set(t.right,t.top),C=Wo[3].set(t.right,t.bottom);if(T.x<=c.x||b.y<=c.y)return!1;const x=Math.sign(r.a*r.d-r.b*r.c);if(x===0||(r.apply(c,c),r.apply(b,b),r.apply(T,T),r.apply(C,C),Math.max(c.x,b.x,T.x,C.x)<=i||Math.min(c.x,b.x,T.x,C.x)>=n||Math.max(c.y,b.y,T.y,C.y)<=o||Math.min(c.y,b.y,T.y,C.y)>=h))return!1;const $=x*(b.y-c.y),I=x*(c.x-b.x),B=$*i+I*o,U=$*n+I*o,G=$*i+I*h,z=$*n+I*h;if(Math.max(B,U,G,z)<=$*c.x+I*c.y||Math.min(B,U,G,z)>=$*C.x+I*C.y)return!1;const J=x*(c.y-T.y),Z=x*(T.x-c.x),it=J*i+Z*o,Q=J*n+Z*o,_t=J*i+Z*h,et=J*n+Z*h;return!(Math.max(it,Q,_t,et)<=J*c.x+Z*c.y||Math.min(it,Q,_t,et)>=J*C.x+Z*C.y)}pad(t=0,r=t){return this.x-=t,this.y-=r,this.width+=t*2,this.height+=r*2,this}fit(t){const r=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),o=Math.min(this.y+this.height,t.y+t.height);return this.x=r,this.width=Math.max(i-r,0),this.y=n,this.height=Math.max(o-n,0),this}ceil(t=1,r=.001){const i=Math.ceil((this.x+this.width-r)*t)/t,n=Math.ceil((this.y+this.height-r)*t)/t;return this.x=Math.floor((this.x+r)*t)/t,this.y=Math.floor((this.y+r)*t)/t,this.width=i-this.x,this.height=n-this.y,this}enlarge(t){const r=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),o=Math.max(this.y+this.height,t.y+t.height);return this.x=r,this.width=i-r,this.y=n,this.height=o-n,this}}Ve.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ln{constructor(t=0,r=0,i=0){this.x=t,this.y=r,this.radius=i,this.type=Ir.CIRC}clone(){return new Ln(this.x,this.y,this.radius)}contains(t,r){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,o=this.y-r;return n*=n,o*=o,n+o<=i}getBounds(){return new Ve(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Ln.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class kn{constructor(t=0,r=0,i=0,n=0){this.x=t,this.y=r,this.width=i,this.height=n,this.type=Ir.ELIP}clone(){return new kn(this.x,this.y,this.width,this.height)}contains(t,r){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,n=(r-this.y)/this.height;return i*=i,n*=n,i+n<=1}getBounds(){return new Ve(this.x-this.width,this.y-this.height,this.width,this.height)}}kn.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class xs{constructor(...t){let r=Array.isArray(t[0])?t[0]:t;if(typeof r[0]!="number"){const i=[];for(let n=0,o=r.length;n<o;n++)i.push(r[n].x,r[n].y);r=i}this.points=r,this.type=Ir.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),r=new xs(t);return r.closeStroke=this.closeStroke,r}contains(t,r){let i=!1;const n=this.points.length/2;for(let o=0,h=n-1;o<n;h=o++){const c=this.points[o*2],b=this.points[o*2+1],T=this.points[h*2],C=this.points[h*2+1];b>r!=C>r&&t<(T-c)*((r-b)/(C-b))+c&&(i=!i)}return i}}xs.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((s,t)=>`${s}, ${t}`,"")}]`};class Bn{constructor(t=0,r=0,i=0,n=0,o=20){this.x=t,this.y=r,this.width=i,this.height=n,this.radius=o,this.type=Ir.RREC}clone(){return new Bn(this.x,this.y,this.width,this.height,this.radius)}contains(t,r){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&r>=this.y&&r<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(r>=this.y+i&&r<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let n=t-(this.x+i),o=r-(this.y+i);const h=i*i;if(n*n+o*o<=h||(n=t-(this.x+this.width-i),n*n+o*o<=h)||(o=r-(this.y+this.height-i),n*n+o*o<=h)||(n=t-(this.x+i),n*n+o*o<=h))return!0}return!1}}Bn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class nr{constructor(t=1,r=0,i=0,n=1,o=0,h=0){this.array=null,this.a=t,this.b=r,this.c=i,this.d=n,this.tx=o,this.ty=h}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,r,i,n,o,h){return this.a=t,this.b=r,this.c=i,this.d=n,this.tx=o,this.ty=h,this}toArray(t,r){this.array||(this.array=new Float32Array(9));const i=r||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,r){r=r||new He;const i=t.x,n=t.y;return r.x=this.a*i+this.c*n+this.tx,r.y=this.b*i+this.d*n+this.ty,r}applyInverse(t,r){r=r||new He;const i=1/(this.a*this.d+this.c*-this.b),n=t.x,o=t.y;return r.x=this.d*i*n+-this.c*i*o+(this.ty*this.c-this.tx*this.d)*i,r.y=this.a*i*o+-this.b*i*n+(-this.ty*this.a+this.tx*this.b)*i,r}translate(t,r){return this.tx+=t,this.ty+=r,this}scale(t,r){return this.a*=t,this.d*=r,this.c*=t,this.b*=r,this.tx*=t,this.ty*=r,this}rotate(t){const r=Math.cos(t),i=Math.sin(t),n=this.a,o=this.c,h=this.tx;return this.a=n*r-this.b*i,this.b=n*i+this.b*r,this.c=o*r-this.d*i,this.d=o*i+this.d*r,this.tx=h*r-this.ty*i,this.ty=h*i+this.ty*r,this}append(t){const r=this.a,i=this.b,n=this.c,o=this.d;return this.a=t.a*r+t.b*n,this.b=t.a*i+t.b*o,this.c=t.c*r+t.d*n,this.d=t.c*i+t.d*o,this.tx=t.tx*r+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*o+this.ty,this}setTransform(t,r,i,n,o,h,c,b,T){return this.a=Math.cos(c+T)*o,this.b=Math.sin(c+T)*o,this.c=-Math.sin(c-b)*h,this.d=Math.cos(c-b)*h,this.tx=t-(i*this.a+n*this.c),this.ty=r-(i*this.b+n*this.d),this}prepend(t){const r=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*t.b+this.d*t.d}return this.tx=r*t.a+this.ty*t.c+t.tx,this.ty=r*t.b+this.ty*t.d+t.ty,this}decompose(t){const r=this.a,i=this.b,n=this.c,o=this.d,h=t.pivot,c=-Math.atan2(-n,o),b=Math.atan2(i,r),T=Math.abs(c+b);return T<1e-5||Math.abs(Fn-T)<1e-5?(t.rotation=b,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=c,t.skew.y=b),t.scale.x=Math.sqrt(r*r+i*i),t.scale.y=Math.sqrt(n*n+o*o),t.position.x=this.tx+(h.x*r+h.y*n),t.position.y=this.ty+(h.x*i+h.y*o),t}invert(){const t=this.a,r=this.b,i=this.c,n=this.d,o=this.tx,h=t*n-r*i;return this.a=n/h,this.b=-r/h,this.c=-i/h,this.d=t/h,this.tx=(i*this.ty-n*o)/h,this.ty=-(t*this.ty-r*o)/h,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 nr;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 nr}static get TEMP_MATRIX(){return new nr}}nr.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Bs=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Os=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ns=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Us=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],rl=[],u0=[],Ho=Math.sign;function kp(){for(let s=0;s<16;s++){const t=[];rl.push(t);for(let r=0;r<16;r++){const i=Ho(Bs[s]*Bs[r]+Ns[s]*Os[r]),n=Ho(Os[s]*Bs[r]+Us[s]*Os[r]),o=Ho(Bs[s]*Ns[r]+Ns[s]*Us[r]),h=Ho(Os[s]*Ns[r]+Us[s]*Us[r]);for(let c=0;c<16;c++)if(Bs[c]===i&&Os[c]===n&&Ns[c]===o&&Us[c]===h){t.push(c);break}}}for(let s=0;s<16;s++){const t=new nr;t.set(Bs[s],Os[s],Ns[s],Us[s],0,0),u0.push(t)}}kp();const pr={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:s=>Bs[s],uY:s=>Os[s],vX:s=>Ns[s],vY:s=>Us[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>rl[s][t],sub:(s,t)=>rl[s][pr.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?pr.S:pr.N:Math.abs(t)*2<=Math.abs(s)?s>0?pr.E:pr.W:t>0?s>0?pr.SE:pr.SW:s>0?pr.NE:pr.NW,matrixAppendRotationInv:(s,t,r=0,i=0)=>{const n=u0[pr.inv(t)];n.tx=r,n.ty=i,s.append(n)}};class $i{constructor(t,r,i=0,n=0){this._x=i,this._y=n,this.cb=t,this.scope=r}clone(t=this.cb,r=this.scope){return new $i(t,r,this._x,this._y)}set(t=0,r=t){return(this._x!==t||this._y!==r)&&(this._x=t,this._y=r,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))}}$i.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const il=class{constructor(){this.worldTransform=new nr,this.localTransform=new nr,this.position=new $i(this.onChange,this,0,0),this.scale=new $i(this.onChange,this,1,1),this.pivot=new $i(this.onChange,this,0,0),this.skew=new $i(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 s=this.localTransform;this._localID!==this._currentLocalID&&(s.a=this._cx*this.scale.x,s.b=this._sx*this.scale.x,s.c=this._cy*this.scale.y,s.d=this._sy*this.scale.y,s.tx=this.position.x-(this.pivot.x*s.a+this.pivot.y*s.c),s.ty=this.position.y-(this.pivot.x*s.b+this.pivot.y*s.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(s){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!==s._worldID){const r=s.worldTransform,i=this.worldTransform;i.a=t.a*r.a+t.b*r.c,i.b=t.a*r.b+t.b*r.d,i.c=t.c*r.a+t.d*r.c,i.d=t.c*r.b+t.d*r.d,i.tx=t.tx*r.a+t.ty*r.c+r.tx,i.ty=t.tx*r.b+t.ty*r.d+r.ty,this._parentID=s._worldID,this._worldID++}}setFromMatrix(s){s.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(s){this._rotation!==s&&(this._rotation=s,this.updateSkew())}};il.IDENTITY=new il;let rn=il;rn.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var Bp=`varying vec2 vTextureCoord;
10
+ Deprecated since v${s}`),console.warn(i))),yl[t]=!0}const os={get parse(){return ot("7.3.0","utils.url.parse is deprecated, use native URL API instead."),ra.parse},get format(){return ot("7.3.0","utils.url.format is deprecated, use native URL API instead."),ra.format},get resolve(){return ot("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),ra.resolve}};function de(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function or(s){return s.split("?")[0].split("#")[0]}function zf(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wf(s,t,e){return s.replace(new RegExp(zf(t),"g"),e)}function $f(s,t){let e="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=s.length;++o){if(o<s.length)a=s.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||n===1))if(r!==o-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,o)}`:e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const Rt={toPosix(s){return Wf(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){de(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(de(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=or(this.toPosix(t??q.ADAPTER.getBaseUrl())),r=or(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?Rt.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(de(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=$f(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return de(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(de(i),i.length>0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(de(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),a=s;s=s.slice(n.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?e?"/":this.isUrl(a)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){de(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){de(s),t&&de(t),s=or(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){de(s),s=or(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}i===-1&&(r=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){de(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=or(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,l=s.length-1,u=0;for(;l>=r;--l){if(e=s.charCodeAt(l),e===47){if(!h){a=l+1;break}continue}o===-1&&(h=!1,o=l+1),e===46?n===-1?n=l:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||o===-1||u===0||u===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,o)):(t.name=s.slice(a,n),t.base=s.slice(a,o)),t.ext=s.slice(n,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let sa;async function vl(){return sa??(sa=(async()=>{var n;const s=document.createElement("canvas").getContext("webgl");if(!s)return Nt.UNPACK;const t=await new Promise(a=>{const o=document.createElement("video");o.onloadeddata=()=>a(o),o.onerror=()=>a(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!t)return Nt.UNPACK;const e=s.createTexture();s.bindTexture(s.TEXTURE_2D,e);const i=s.createFramebuffer();s.bindFramebuffer(s.FRAMEBUFFER,i),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t);const r=new Uint8Array(4);return s.readPixels(0,0,1,1,s.RGBA,s.UNSIGNED_BYTE,r),s.deleteFramebuffer(i),s.deleteTexture(e),(n=s.getExtension("WEBGL_lose_context"))==null||n.loseContext(),r[0]<=r[3]?Nt.PMA:Nt.UNPACK})()),sa}function jf(){ot("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")}function Yf(){ot("7.0.0",`sayHello is deprecated, please use Renderer's "hello" option`)}let na;function xl(){return typeof na>"u"&&(na=function(){var t;const s={stencil:!0,failIfMajorPerformanceCaveat:q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!q.ADAPTER.getWebGLRenderingContext())return!1;const e=q.ADAPTER.createCanvas();let i=e.getContext("webgl",s)||e.getContext("experimental-webgl",s);const r=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,r}catch{return!1}}()),na}var qf={grad:.9,turn:360,rad:360/(2*Math.PI)},ke=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Ft=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},Jt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},bl=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Tl=function(s){return{r:Jt(s.r,0,255),g:Jt(s.g,0,255),b:Jt(s.b,0,255),a:Jt(s.a)}},aa=function(s){return{r:Ft(s.r),g:Ft(s.g),b:Ft(s.b),a:Ft(s.a,3)}},Kf=/^#([0-9a-f]{3,8})$/i,hs=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},El=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},wl=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,o,a,a,h,i][l],g:255*[h,i,i,o,a,a][l],b:255*[a,a,h,i,i,o][l],a:r}},Cl=function(s){return{h:bl(s.h),s:Jt(s.s,0,100),l:Jt(s.l,0,100),a:Jt(s.a)}},Al=function(s){return{h:Ft(s.h),s:Ft(s.s),l:Ft(s.l),a:Ft(s.a,3)}},Sl=function(s){return wl((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},hr=function(s){return{h:(t=El(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Zf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tp=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oa={string:[[function(s){var t=Kf.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?Ft(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?Ft(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=Qf.exec(s)||tp.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Tl({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=Zf.exec(s)||Jf.exec(s);if(!t)return null;var e,i,r=Cl({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(qf[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Sl(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return ke(t)&&ke(e)&&ke(i)?Tl({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!ke(t)||!ke(e)||!ke(i))return null;var a=Cl({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Sl(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!ke(t)||!ke(e)||!ke(i))return null;var a=function(o){return{h:bl(o.h),s:Jt(o.s,0,100),v:Jt(o.v,0,100),a:Jt(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return wl(a)},"hsv"]]},Pl=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},ep=function(s){return typeof s=="string"?Pl(s.trim(),oa.string):typeof s=="object"&&s!==null?Pl(s,oa.object):[null,void 0]},ha=function(s,t){var e=hr(s);return{h:e.h,s:Jt(e.s+100*t,0,100),l:e.l,a:e.a}},la=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},Ml=function(s,t){var e=hr(s);return{h:e.h,s:e.s,l:Jt(e.l+100*t,0,100),a:e.a}},ua=function(){function s(t){this.parsed=ep(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return Ft(la(this.rgba),2)},s.prototype.isDark=function(){return la(this.rgba)<.5},s.prototype.isLight=function(){return la(this.rgba)>=.5},s.prototype.toHex=function(){return t=aa(this.rgba),e=t.r,i=t.g,r=t.b,a=(n=t.a)<1?hs(Ft(255*n)):"","#"+hs(e)+hs(i)+hs(r)+a;var t,e,i,r,n,a},s.prototype.toRgb=function(){return aa(this.rgba)},s.prototype.toRgbString=function(){return t=aa(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return Al(hr(this.rgba))},s.prototype.toHslString=function(){return t=Al(hr(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=El(this.rgba),{h:Ft(t.h),s:Ft(t.s),v:Ft(t.v),a:Ft(t.a,3)};var t},s.prototype.invert=function(){return we({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),we(ha(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),we(ha(this.rgba,-t))},s.prototype.grayscale=function(){return we(ha(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),we(Ml(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),we(Ml(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?we({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Ft(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=hr(this.rgba);return typeof t=="number"?we({h:t,s:e.s,l:e.l,a:e.a}):Ft(e.h)},s.prototype.isEqual=function(t){return this.toHex()===we(t).toHex()},s}(),we=function(s){return s instanceof ua?s:new ua(s)},Il=[],ip=function(s){s.forEach(function(t){Il.indexOf(t)<0&&(t(ua,oa),Il.push(t))})};function rp(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=i[this.toHex()];if(l)return l;if(a!=null&&a.closest){var u=this.toRgb(),c=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var p in e){var g=(o=u,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));g<c&&(c=g,d=p)}return d}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new s(h).toRgb():null},"name"])}ip([rp]);const Ri=class pn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof pn)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((r,n)=>r===e[n]);if(t!==null&&e!==null){const r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toRgbArray(t){t=t??[];const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=pn.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,r]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(r*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=pn.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=we(t);a.isValid()&&({r:e,g:i,b:r,a:n}=a.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}};Ri.shared=new Ri,Ri.temp=new Ri,Ri.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let gt=Ri;function sp(s,t=[]){return ot("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),gt.shared.setValue(s).toRgbArray(t)}function Rl(s){return ot("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),gt.shared.setValue(s).toHex()}function np(s){return ot("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),gt.shared.setValue(s).toNumber()}function Dl(s){return ot("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),gt.shared.setValue(s).toNumber()}function ap(){const s=[],t=[];for(let i=0;i<32;i++)s[i]=i,t[i]=i;s[nt.NORMAL_NPM]=nt.NORMAL,s[nt.ADD_NPM]=nt.ADD,s[nt.SCREEN_NPM]=nt.SCREEN,t[nt.NORMAL]=nt.NORMAL_NPM,t[nt.ADD]=nt.ADD_NPM,t[nt.SCREEN]=nt.SCREEN_NPM;const e=[];return e.push(t),e.push(s),e}const ca=ap();function da(s,t){return ca[t?1:0][s]}function op(s,t,e,i=!0){return ot("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),gt.shared.setValue(s).premultiply(t,i).toArray(e??new Float32Array(4))}function hp(s,t){return ot("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),gt.shared.setValue(s).toPremultiplied(t)}function lp(s,t,e,i=!0){return ot("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),gt.shared.setValue(s).premultiply(t,i).toArray(e??new Float32Array(4))}const Fl=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Bl(s,t=null){const e=s*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 i=0,r=0;i<e;i+=6,r+=4)t[i+0]=r+0,t[i+1]=r+1,t[i+2]=r+2,t[i+3]=r+0,t[i+4]=r+2,t[i+5]=r+3;return t}function ls(s){if(s.BYTES_PER_ELEMENT===4)return s instanceof Float32Array?"Float32Array":s instanceof Uint32Array?"Uint32Array":"Int32Array";if(s.BYTES_PER_ELEMENT===2){if(s instanceof Uint16Array)return"Uint16Array"}else if(s.BYTES_PER_ELEMENT===1&&s instanceof Uint8Array)return"Uint8Array";return null}const up={Float32Array,Uint32Array,Int32Array,Uint8Array};function cp(s,t){let e=0,i=0;const r={};for(let h=0;h<s.length;h++)i+=t[h],e+=s[h].length;const n=new ArrayBuffer(e*4);let a=null,o=0;for(let h=0;h<s.length;h++){const l=t[h],u=s[h],c=ls(u);r[c]||(r[c]=new up[c](n)),a=r[c];for(let d=0;d<u.length;d++){const f=(d/l|0)*i+o,p=d%l;a[f+p]=u[d]}o+=l}return new Float32Array(n)}function lr(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function fa(s){return!(s&s-1)&&!!s}function pa(s){let t=(s>65535?1:0)<<4;s>>>=t;let e=(s>255?1:0)<<3;return s>>>=e,t|=e,e=(s>15?1:0)<<2,s>>>=e,t|=e,e=(s>3?1:0)<<1,s>>>=e,t|=e,t|s>>1}function di(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n}function Ne(s){return s===0?0:s<0?-1:1}let dp=0;function qe(){return++dp}const ma=class{constructor(s,t,e,i){this.left=s,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};ma.EMPTY=new ma(0,0,0,0);let ga=ma;const _a={},Ut=Object.create(null),zt=Object.create(null);function fp(){let s;for(s in Ut)Ut[s].destroy();for(s in zt)zt[s].destroy()}function pp(){let s;for(s in Ut)delete Ut[s];for(s in zt)delete zt[s]}class Ll{constructor(t,e,i){this._canvas=q.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||q.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function Ol(s,t,e){for(let i=0,r=4*e*t;i<t;++i,r+=4)if(s[r+3]!==0)return!1;return!0}function kl(s,t,e,i,r){const n=4*t;for(let a=i,o=i*n+4*e;a<=r;++a,o+=n)if(s[o+3]!==0)return!1;return!0}function Nl(s){const{width:t,height:e}=s,i=s.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const r=i.getImageData(0,0,t,e).data;let n=0,a=0,o=t-1,h=e-1;for(;a<e&&Ol(r,t,a);)++a;if(a===e)return ga.EMPTY;for(;Ol(r,t,h);)--h;for(;kl(r,t,n,a,h);)++n;for(;kl(r,t,o,a,h);)--o;return++o,++h,new ga(n,a,o,h)}function Ul(s){const t=Nl(s),{width:e,height:i}=t;let r=null;if(!t.isEmpty()){const n=s.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");r=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:r}}function mp(s){const t=Fl.exec(s);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}function Gl(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function Ce(s,t=1){var i;const e=(i=q.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}const gp=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:zt,BoundingBox:ga,CanvasRenderTarget:Ll,DATA_URI:Fl,EventEmitter:Ee,ProgramCache:_a,TextureCache:Ut,clearTextureCache:pp,correctBlendMode:da,createIndicesForQuads:Bl,decomposeDataUri:mp,deprecation:ot,destroyTextureCache:fp,detectVideoAlphaMode:vl,determineCrossOrigin:Gl,earcut:Nh,getBufferType:ls,getCanvasBoundingBox:Nl,getResolutionOfUrl:Ce,hex2rgb:sp,hex2string:Rl,interleaveTypedArrays:cp,isMobile:ce,isPow2:fa,isWebGLSupported:xl,log2:pa,nextPow2:lr,path:Rt,premultiplyBlendMode:ca,premultiplyRgba:op,premultiplyTint:hp,premultiplyTintToRgba:lp,removeItems:di,rgb2hex:Dl,sayHello:Yf,sign:Ne,skipHello:jf,string2hex:np,trimCanvas:Ul,uid:qe,url:os},Symbol.toStringTag,{value:"Module"}));var $=(s=>(s.Renderer="renderer",s.Application="application",s.RendererSystem="renderer-webgl-system",s.RendererPlugin="renderer-webgl-plugin",s.CanvasRendererSystem="renderer-canvas-system",s.CanvasRendererPlugin="renderer-canvas-plugin",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s))($||{});const ya=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Vl=(s,t)=>ya(s).priority??t,Q={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(ya).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(ya).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,r=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(r[e]=r[e]||[],(a=r[e])==null||a.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((a=n[s])==null||a.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>Vl(n,e)-Vl(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}};class us{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const _p=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
+ `);function yp(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
12
+ else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function Hl(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=_p.replace(/%forloop%/gi,yp(s));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}return s}const va=0,xa=1,ba=2,Ta=3,Ea=4,wa=5;class fe{constructor(){this.data=0,this.blendMode=nt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<va)}set blend(t){!!(this.data&1<<va)!==t&&(this.data^=1<<va)}get offsets(){return!!(this.data&1<<xa)}set offsets(t){!!(this.data&1<<xa)!==t&&(this.data^=1<<xa)}get culling(){return!!(this.data&1<<ba)}set culling(t){!!(this.data&1<<ba)!==t&&(this.data^=1<<ba)}get depthTest(){return!!(this.data&1<<Ta)}set depthTest(t){!!(this.data&1<<Ta)!==t&&(this.data^=1<<Ta)}get depthMask(){return!!(this.data&1<<wa)}set depthMask(t){!!(this.data&1<<wa)!==t&&(this.data^=1<<wa)}get clockwiseFrontFace(){return!!(this.data&1<<Ea)}set clockwiseFrontFace(t){!!(this.data&1<<Ea)!==t&&(this.data^=1<<Ea)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==nt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new fe;return t.depthTest=!1,t.blend=!0,t}}fe.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const cs=[];function Ca(s,t){if(!s)return null;let e="";if(typeof s=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(s);i&&(e=i[1].toLowerCase())}for(let i=cs.length-1;i>=0;--i){const r=cs[i];if(r.test&&r.test(s,e))return new r(s,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Wt{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,r,n,a,o,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][l](t,e,i,r,n,a,o,h);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(Wt.prototype,{dispatch:{value:Wt.prototype.emit},run:{value:Wt.prototype.emit}});class Di{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Wt("setRealSize"),this.onUpdate=new Wt("update"),this.onError=new Wt("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,i){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 ur extends Di{constructor(t,e){const{width:i,height:r}=e||{};if(!i||!r)throw new Error("BufferResource width or height invalid");super(i,r),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const r=t.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,this.unpackAlignment),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Nt.UNPACK);const n=e.realWidth,a=e.realHeight;return i.width===n&&i.height===a?r.texSubImage2D(e.target,0,0,0,n,a,e.format,i.type,this.data):(i.width=n,i.height=a,r.texImage2D(e.target,0,i.internalFormat,n,a,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const vp={scaleMode:be.NEAREST,alphaMode:Nt.NPM},Aa=class tr extends Ee{constructor(t=null,e=null){super(),e=Object.assign({},tr.defaultOptions,e);const{alphaMode:i,mipmap:r,anisotropicLevel:n,scaleMode:a,width:o,height:h,wrapMode:l,format:u,type:c,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof Di)&&(t=Ca(t,p),t.internal=!0),this.resolution=f||q.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((h||0)*this.resolution)/this.resolution,this._mipmap=r,this.anisotropicLevel=n,this._wrapMode=l,this._scaleMode=a,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=qe(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&h>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}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(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=fa(this.realWidth)&&fa(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,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(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete zt[this.cacheId],delete Ut[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),tr.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=q.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${qe()}`}n=t._pixiId}let a=zt[n];if(r&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return a||(a=new tr(t,e),a.cacheId=n,tr.addToCache(a,n)),a}static fromBuffer(t,e,i,r){t=t||new Float32Array(e*i*4);const n=new ur(t,{width:e,height:i,...r==null?void 0:r.resourceOptions});let a,o;return t instanceof Float32Array?(a=H.RGBA,o=it.FLOAT):t instanceof Int32Array?(a=H.RGBA_INTEGER,o=it.INT):t instanceof Uint32Array?(a=H.RGBA_INTEGER,o=it.UNSIGNED_INT):t instanceof Int16Array?(a=H.RGBA_INTEGER,o=it.SHORT):t instanceof Uint16Array?(a=H.RGBA_INTEGER,o=it.UNSIGNED_SHORT):t instanceof Int8Array?(a=H.RGBA,o=it.BYTE):(a=H.RGBA,o=it.UNSIGNED_BYTE),n.internal=!0,new tr(n,Object.assign({},vp,{type:o,format:a},r))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),zt[e]&&zt[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),zt[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=zt[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete zt[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete zt[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Aa.defaultOptions={mipmap:he.POW2,anisotropicLevel:0,scaleMode:be.LINEAR,wrapMode:Te.CLAMP,alphaMode:Nt.UNPACK,target:ui.TEXTURE_2D,format:H.RGBA,type:it.UNSIGNED_BYTE},Aa._globalBatch=0;let lt=Aa;class ds{constructor(){this.texArray=null,this.blend=0,this.type=oe.TRIANGLES,this.start=0,this.size=0,this.data=null}}let xp=0;class At{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=xp++,this.disposeRunner=new Wt("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?ue.ELEMENT_ARRAY_BUFFER:ue.ARRAY_BUFFER}get index(){return this.type===ue.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new At(t)}}class cr{constructor(t,e=0,i=!1,r=it.FLOAT,n,a,o,h=1){this.buffer=t,this.size=e,this.normalized=i,this.type=r,this.stride=n,this.start=a,this.instance=o,this.divisor=h}destroy(){this.buffer=null}static from(t,e,i,r,n){return new cr(t,e,i,r,n)}}const bp={Float32Array,Uint32Array,Int32Array,Uint8Array};function Tp(s,t){let e=0,i=0;const r={};for(let h=0;h<s.length;h++)i+=t[h],e+=s[h].length;const n=new ArrayBuffer(e*4);let a=null,o=0;for(let h=0;h<s.length;h++){const l=t[h],u=s[h],c=ls(u);r[c]||(r[c]=new bp[c](n)),a=r[c];for(let d=0;d<u.length;d++){const f=(d/l|0)*i+o,p=d%l;a[f+p]=u[d]}o+=l}return new Float32Array(n)}const Xl={5126:4,5123:2,5121:1};let Ep=0;const wp={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Ue{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Ep++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Wt("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,r=!1,n,a,o,h=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof At||(e instanceof Array&&(e=new Float32Array(e)),e=new At(e));const l=t.split("|");if(l.length>1){for(let c=0;c<l.length;c++)this.addAttribute(l[c],e,i,r,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new cr(u,i,r,n,a,o,h),this.instanced=this.instanced||h,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof At||(t instanceof Array&&(t=new Uint16Array(t)),t=new At(t)),t.type=ue.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new At;let r;for(r in this.attributes){const n=this.attributes[r],a=this.buffers[n.buffer];t.push(a.data),e.push(n.size*Xl[n.type]/4),n.buffer=0}for(i.data=Tp(t,e),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Ue;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new At(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new cr(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=ue.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Ue,i=[],r=[],n=[];let a;for(let o=0;o<t.length;o++){a=t[o];for(let h=0;h<a.buffers.length;h++)r[h]=r[h]||0,r[h]+=a.buffers[h].data.length,n[h]=0}for(let o=0;o<a.buffers.length;o++)i[o]=new wp[ls(a.buffers[o].data)](r[o]),e.buffers[o]=new At(i[o]);for(let o=0;o<t.length;o++){a=t[o];for(let h=0;h<a.buffers.length;h++)i[h].set(a.buffers[h].data,n[h]),n[h]+=a.buffers[h].data.length}if(e.attributes=a.attributes,a.indexBuffer){e.indexBuffer=e.buffers[a.buffers.indexOf(a.indexBuffer)],e.indexBuffer.type=ue.ELEMENT_ARRAY_BUFFER;let o=0,h=0,l=0,u=0;for(let c=0;c<a.buffers.length;c++)if(a.buffers[c]!==a.indexBuffer){u=c;break}for(const c in a.attributes){const d=a.attributes[c];(d.buffer|0)===u&&(h+=d.size*Xl[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+l]+=o;o+=t[c].buffers[u].data.length/h,l+=d.length}}return e}}class Sa extends Ue{constructor(t=!1){super(),this._buffer=new At(null,t,!1),this._indexBuffer=new At(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,it.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,it.FLOAT).addAttribute("aColor",this._buffer,4,!0,it.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,it.FLOAT).addIndex(this._indexBuffer)}}const dr=Math.PI*2,zl=180/Math.PI,Wl=Math.PI/180;var Bt=(s=>(s[s.POLY=0]="POLY",s[s.RECT=1]="RECT",s[s.CIRC=2]="CIRC",s[s.ELIP=3]="ELIP",s[s.RREC=4]="RREC",s))(Bt||{});class ft{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ft(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}}ft.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const fs=[new ft,new ft,new ft,new ft];class ut{constructor(t=0,e=0,i=0,r=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r),this.type=Bt.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 ut(0,0,0,0)}clone(){return new ut(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const P=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=P)return!1;const N=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>N}const i=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=i||a<=n)return!1;const o=fs[0].set(t.left,t.top),h=fs[1].set(t.left,t.bottom),l=fs[2].set(t.right,t.top),u=fs[3].set(t.right,t.bottom);if(l.x<=o.x||h.y<=o.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(o,o),e.apply(h,h),e.apply(l,l),e.apply(u,u),Math.max(o.x,h.x,l.x,u.x)<=i||Math.min(o.x,h.x,l.x,u.x)>=r||Math.max(o.y,h.y,l.y,u.y)<=n||Math.min(o.y,h.y,l.y,u.y)>=a))return!1;const d=c*(h.y-o.y),f=c*(o.x-h.x),p=d*i+f*n,g=d*r+f*n,m=d*i+f*a,_=d*r+f*a;if(Math.max(p,g,m,_)<=d*o.x+f*o.y||Math.min(p,g,m,_)>=d*u.x+f*u.y)return!1;const b=c*(o.y-l.y),y=c*(l.x-o.x),E=b*i+y*n,v=b*r+y*n,M=b*i+y*a,T=b*r+y*a;return!(Math.max(E,v,M,T)<=b*o.x+y*o.y||Math.min(E,v,M,T)>=b*u.x+y*u.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),i=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(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=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=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=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=i-e,this.y=r,this.height=n-r,this}}ut.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class fr{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Bt.CIRC}clone(){return new fr(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}getBounds(){return new ut(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}fr.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class pr{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.width=i,this.height=r,this.type=Bt.ELIP}clone(){return new pr(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,r=(e-this.y)/this.height;return i*=i,r*=r,i+r<=1}getBounds(){return new ut(this.x-this.width,this.y-this.height,this.width,this.height)}}pr.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ke{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i}this.points=e,this.type=Bt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Ke(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let n=0,a=r-1;n<r;a=n++){const o=this.points[n*2],h=this.points[n*2+1],l=this.points[a*2],u=this.points[a*2+1];h>e!=u>e&&t<(l-o)*((e-h)/(u-h))+o&&(i=!i)}return i}}Ke.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((s,t)=>`${s}, ${t}`,"")}]`};class mr{constructor(t=0,e=0,i=0,r=0,n=20){this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n,this.type=Bt.RREC}clone(){return new mr(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 i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(r*r+n*n<=a||(r=t-(this.x+this.width-i),r*r+n*n<=a)||(n=e-(this.y+this.height-i),r*r+n*n<=a)||(r=t-(this.x+i),r*r+n*n<=a))return!0}return!1}}mr.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class vt{constructor(t=1,e=0,i=0,r=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a}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,i,r,n,a){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new ft;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new ft;const i=1/(this.a*this.d+this.c*-this.b),r=t.x,n=t.y;return e.x=this.d*i*r+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*r+(-this.ty*this.a+this.tx*this.b)*i,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),i=Math.sin(t),r=this.a,n=this.c,a=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,r,n,a,o,h,l){return this.a=Math.cos(o+l)*n,this.b=Math.sin(o+l)*n,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*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 i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*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,i=this.b,r=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-r,n),h=Math.atan2(i,e),l=Math.abs(o+h);return l<1e-5||Math.abs(dr-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(a.x*e+a.y*r),t.position.y=this.ty+(a.x*i+a.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,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 vt;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 vt}static get TEMP_MATRIX(){return new vt}}vt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const fi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],pi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],mi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],gi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Pa=[],$l=[],ps=Math.sign;function Cp(){for(let s=0;s<16;s++){const t=[];Pa.push(t);for(let e=0;e<16;e++){const i=ps(fi[s]*fi[e]+mi[s]*pi[e]),r=ps(pi[s]*fi[e]+gi[s]*pi[e]),n=ps(fi[s]*mi[e]+mi[s]*gi[e]),a=ps(pi[s]*mi[e]+gi[s]*gi[e]);for(let o=0;o<16;o++)if(fi[o]===i&&pi[o]===r&&mi[o]===n&&gi[o]===a){t.push(o);break}}}for(let s=0;s<16;s++){const t=new vt;t.set(fi[s],pi[s],mi[s],gi[s],0,0),$l.push(t)}}Cp();const wt={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:s=>fi[s],uY:s=>pi[s],vX:s=>mi[s],vY:s=>gi[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Pa[s][t],sub:(s,t)=>Pa[s][wt.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?wt.S:wt.N:Math.abs(t)*2<=Math.abs(s)?s>0?wt.E:wt.W:t>0?s>0?wt.SE:wt.SW:s>0?wt.NE:wt.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=$l[wt.inv(t)];r.tx=e,r.ty=i,s.append(r)}};class pe{constructor(t,e,i=0,r=0){this._x=i,this._y=r,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new pe(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))}}pe.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Ma=class{constructor(){this.worldTransform=new vt,this.localTransform=new vt,this.position=new pe(this.onChange,this,0,0),this.scale=new pe(this.onChange,this,1,1),this.pivot=new pe(this.onChange,this,0,0),this.skew=new pe(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 s=this.localTransform;this._localID!==this._currentLocalID&&(s.a=this._cx*this.scale.x,s.b=this._sx*this.scale.x,s.c=this._cy*this.scale.y,s.d=this._sy*this.scale.y,s.tx=this.position.x-(this.pivot.x*s.a+this.pivot.y*s.c),s.ty=this.position.y-(this.pivot.x*s.b+this.pivot.y*s.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(s){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!==s._worldID){const e=s.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=s._worldID,this._worldID++}}setFromMatrix(s){s.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(s){this._rotation!==s&&(this._rotation=s,this.updateSkew())}};Ma.IDENTITY=new Ma;let Fi=Ma;Fi.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var Ap=`varying vec2 vTextureCoord;
55
13
 
56
14
  uniform sampler2D uSampler;
57
15
 
58
16
  void main(void){
59
17
  gl_FragColor *= texture2D(uSampler, vTextureCoord);
60
- }`,Op=`attribute vec2 aVertexPosition;
18
+ }`,Sp=`attribute vec2 aVertexPosition;
61
19
  attribute vec2 aTextureCoord;
62
20
 
63
21
  uniform mat3 projectionMatrix;
@@ -68,7 +26,7 @@ void main(void){
68
26
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
69
27
  vTextureCoord = aTextureCoord;
70
28
  }
71
- `;function c0(s,t,r){const i=s.createShader(t);return s.shaderSource(i,r),s.compileShader(i),i}function sl(s){const t=new Array(s);for(let r=0;r<t.length;r++)t[r]=!1;return t}function f0(s,t){switch(s){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return sl(2*t);case"bvec3":return sl(3*t);case"bvec4":return sl(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Gs=[{test:s=>s.type==="float"&&s.size===1&&!s.isArray,code:s=>`
29
+ `;function jl(s,t,e){const i=s.createShader(t);return s.shaderSource(i,e),s.compileShader(i),i}function Ia(s){const t=new Array(s);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Yl(s,t){switch(s){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Ia(2*t);case"bvec3":return Ia(3*t);case"bvec4":return Ia(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const _i=[{test:s=>s.type==="float"&&s.size===1&&!s.isArray,code:s=>`
72
30
  if(uv["${s}"] !== ud["${s}"].value)
73
31
  {
74
32
  ud["${s}"].value = uv["${s}"]
@@ -188,7 +146,7 @@ void main(void){
188
146
  cv[3] = v[3];
189
147
 
190
148
  gl.uniform4f(ud["${s}"].location, v[0], v[1], v[2], v[3])
191
- }`}],Np={float:`
149
+ }`}],Pp={float:`
192
150
  if (cv !== v)
193
151
  {
194
152
  cu.value = v;
@@ -324,36 +282,36 @@ void main(void){
324
282
  cu.value = v;
325
283
 
326
284
  gl.uniform1i(location, v);
327
- }`},Up={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 Gp(s,t){var i;const r=[`
285
+ }`},Mp={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 Ip(s,t){var i;const e=[`
328
286
  var v = null;
329
287
  var cv = null;
330
288
  var cu = null;
331
289
  var t = 0;
332
290
  var gl = renderer.gl;
333
- `];for(const n in s.uniforms){const o=t[n];if(!o){((i=s.uniforms[n])==null?void 0:i.group)===!0&&(s.uniforms[n].ubo?r.push(`
334
- renderer.shader.syncUniformBufferGroup(uv.${n}, '${n}');
335
- `):r.push(`
336
- renderer.shader.syncUniformGroup(uv.${n}, syncData);
337
- `));continue}const h=s.uniforms[n];let c=!1;for(let b=0;b<Gs.length;b++)if(Gs[b].test(o,h)){r.push(Gs[b].code(n,h)),c=!0;break}if(!c){const b=(o.size===1&&!o.isArray?Np:Up)[o.type].replace("location",`ud["${n}"].location`);r.push(`
338
- cu = ud["${n}"];
291
+ `];for(const r in s.uniforms){const n=t[r];if(!n){((i=s.uniforms[r])==null?void 0:i.group)===!0&&(s.uniforms[r].ubo?e.push(`
292
+ renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}');
293
+ `):e.push(`
294
+ renderer.shader.syncUniformGroup(uv.${r}, syncData);
295
+ `));continue}const a=s.uniforms[r];let o=!1;for(let h=0;h<_i.length;h++)if(_i[h].test(n,a)){e.push(_i[h].code(r,a)),o=!0;break}if(!o){const h=(n.size===1&&!n.isArray?Pp:Mp)[n.type].replace("location",`ud["${r}"].location`);e.push(`
296
+ cu = ud["${r}"];
339
297
  cv = cu.value;
340
- v = uv["${n}"];
341
- ${b};`)}}return new Function("ud","uv","renderer","syncData",r.join(`
342
- `))}const d0={};let sn=d0;function p0(){if(sn===d0||sn!=null&&sn.isContextLost()){const s=ue.ADAPTER.createCanvas();let t;ue.PREFER_ENV>=ys.WEBGL2&&(t=s.getContext("webgl2",{})),t||(t=s.getContext("webgl",{})||s.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),sn=t}return sn}let Yo;function Vp(){if(!Yo){Yo=ri.MEDIUM;const s=p0();if(s&&s.getShaderPrecisionFormat){const t=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);t&&(Yo=t.precision?ri.HIGH:ri.MEDIUM)}}return Yo}function _0(s,t){const r=s.getShaderSource(t).split(`
343
- `).map((T,C)=>`${C}: ${T}`),i=s.getShaderInfoLog(t),n=i.split(`
344
- `),o={},h=n.map(T=>parseFloat(T.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(T=>T&&!o[T]?(o[T]=!0,!0):!1),c=[""];h.forEach(T=>{r[T-1]=`%c${r[T-1]}%c`,c.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const b=r.join(`
345
- `);c[0]=b,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...c),console.groupEnd()}function Xp(s,t,r,i){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(r,s.COMPILE_STATUS)||_0(s,r),s.getShaderParameter(i,s.COMPILE_STATUS)||_0(s,i),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}const zp={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 g0(s){return zp[s]}let jo=null;const m0={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 y0(s,t){if(!jo){const r=Object.keys(m0);jo={};for(let i=0;i<r.length;++i){const n=r[i];jo[s[n]]=m0[n]}}return jo[t]}function v0(s,t,r){if(s.substring(0,9)!=="precision"){let i=t;return t===ri.HIGH&&r!==ri.HIGH&&(i=ri.MEDIUM),`precision ${i} float;
346
- ${s}`}else if(r!==ri.HIGH&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}let On;function x0(){if(typeof On=="boolean")return On;try{On=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{On=!1}return On}let Wp=0;const qo={},nl=class wn{constructor(t,r,i="pixi-shader",n={}){this.extra={},this.id=Wp++,this.vertexSrc=t||wn.defaultVertexSrc,this.fragmentSrc=r||wn.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=n,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),qo[i]?(qo[i]++,i+=`-${qo[i]}`):qo[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
298
+ v = uv["${r}"];
299
+ ${h};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
300
+ `))}const ql={};let Bi=ql;function Kl(){if(Bi===ql||Bi!=null&&Bi.isContextLost()){const s=q.ADAPTER.createCanvas();let t;q.PREFER_ENV>=Zt.WEBGL2&&(t=s.getContext("webgl2",{})),t||(t=s.getContext("webgl",{})||s.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Bi=t}return Bi}let ms;function Rp(){if(!ms){ms=Xt.MEDIUM;const s=Kl();if(s&&s.getShaderPrecisionFormat){const t=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);t&&(ms=t.precision?Xt.HIGH:Xt.MEDIUM)}}return ms}function Zl(s,t){const e=s.getShaderSource(t).split(`
301
+ `).map((l,u)=>`${u}: ${l}`),i=s.getShaderInfoLog(t),r=i.split(`
302
+ `),n={},a=r.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),o=[""];a.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
303
+ `);o[0]=h,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function Dp(s,t,e,i){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(e,s.COMPILE_STATUS)||Zl(s,e),s.getShaderParameter(i,s.COMPILE_STATUS)||Zl(s,i),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}const Fp={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 Jl(s){return Fp[s]}let gs=null;const Ql={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 tu(s,t){if(!gs){const e=Object.keys(Ql);gs={};for(let i=0;i<e.length;++i){const r=e[i];gs[s[r]]=Ql[r]}}return gs[t]}function eu(s,t,e){if(s.substring(0,9)!=="precision"){let i=t;return t===Xt.HIGH&&e!==Xt.HIGH&&(i=Xt.MEDIUM),`precision ${i} float;
304
+ ${s}`}else if(e!==Xt.HIGH&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}let gr;function iu(){if(typeof gr=="boolean")return gr;try{gr=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{gr=!1}return gr}let Bp=0;const _s={},Ra=class er{constructor(t,e,i="pixi-shader",r={}){this.extra={},this.id=Bp++,this.vertexSrc=t||er.defaultVertexSrc,this.fragmentSrc=e||er.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=r,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),_s[i]?(_s[i]++,i+=`-${_s[i]}`):_s[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
347
305
  ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
348
- ${this.fragmentSrc}`,this.vertexSrc=v0(this.vertexSrc,wn.defaultVertexPrecision,ri.HIGH),this.fragmentSrc=v0(this.fragmentSrc,wn.defaultFragmentPrecision,Vp())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Op}static get defaultFragmentSrc(){return Bp}static from(t,r,i){const n=t+r;let o=Wh[n];return o||(Wh[n]=o=new wn(t,r,i)),o}};nl.defaultVertexPrecision=ri.HIGH,nl.defaultFragmentPrecision=Ci.apple.device?ri.HIGH:ri.MEDIUM;let Hi=nl,Hp=0;class fi{constructor(t,r,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Hp++,this.static=!!r,this.ubo=!!i,t instanceof Ar?(this.buffer=t,this.buffer.type=Ei.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Ar(new Float32Array(1)),this.buffer.type=Ei.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,r,i){if(!this.ubo)this.uniforms[t]=new fi(r,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,r,i){return new fi(t,r,i)}static uboFrom(t,r){return new fi(t,r??!0,!0)}}class Mi{constructor(t,r){this.uniformBindCount=0,this.program=t,r?r instanceof fi?this.uniformGroup=r:this.uniformGroup=new fi(r):this.uniformGroup=new fi({}),this.disposeRunner=new si("disposeShader")}checkUniformExists(t,r){if(r.uniforms[t])return!0;for(const i in r.uniforms){const n=r.uniforms[i];if(n.group===!0&&this.checkUniformExists(t,n))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,r,i){const n=Hi.from(t,r);return new Mi(n,i)}}class b0{constructor(t,r){if(this.vertexSrc=t,this.fragTemplate=r,this.programCache={},this.defaultGroupCache={},!r.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!r.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let o=0;o<t;o++)i[o]=o;this.defaultGroupCache[t]=fi.from({uSamplers:i},!0);let n=this.fragTemplate;n=n.replace(/%count%/gi,`${t}`),n=n.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Hi(this.vertexSrc,n)}const r={tint:new Float32Array([1,1,1,1]),translationMatrix:new nr,default:this.defaultGroupCache[t]};return new Mi(this.programCache[t],r)}generateSampleSrc(t){let r="";r+=`
349
- `,r+=`
350
- `;for(let i=0;i<t;i++)i>0&&(r+=`
351
- else `),i<t-1&&(r+=`if(vTextureId < ${i}.5)`),r+=`
352
- {`,r+=`
353
- color = texture2D(uSamplers[${i}], vTextureCoord);`,r+=`
354
- }`;return r+=`
355
- `,r+=`
356
- `,r}}class Zo{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Yp(){return!Ci.apple.device}function jp(s){let t=!0;const r=ue.ADAPTER.getNavigator();if(Ci.tablet||Ci.phone){if(Ci.apple.device){const i=r.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(Ci.android.device){const i=r.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?s:4}class Nn{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var qp=`varying vec2 vTextureCoord;
306
+ ${this.fragmentSrc}`,this.vertexSrc=eu(this.vertexSrc,er.defaultVertexPrecision,Xt.HIGH),this.fragmentSrc=eu(this.fragmentSrc,er.defaultFragmentPrecision,Rp())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Sp}static get defaultFragmentSrc(){return Ap}static from(t,e,i){const r=t+e;let n=_a[r];return n||(_a[r]=n=new er(t,e,i)),n}};Ra.defaultVertexPrecision=Xt.HIGH,Ra.defaultFragmentPrecision=ce.apple.device?Xt.HIGH:Xt.MEDIUM;let Ae=Ra,Lp=0;class Qt{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Lp++,this.static=!!e,this.ubo=!!i,t instanceof At?(this.buffer=t,this.buffer.type=ue.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new At(new Float32Array(1)),this.buffer.type=ue.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new Qt(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new Qt(t,e,i)}static uboFrom(t,e){return new Qt(t,e??!0,!0)}}class me{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Qt?this.uniformGroup=e:this.uniformGroup=new Qt(e):this.uniformGroup=new Qt({}),this.disposeRunner=new Wt("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const r=e.uniforms[i];if(r.group===!0&&this.checkUniformExists(t,r))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const r=Ae.from(t,e);return new me(r,i)}}class ru{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=Qt.from({uSamplers:i},!0);let r=this.fragTemplate;r=r.replace(/%count%/gi,`${t}`),r=r.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Ae(this.vertexSrc,r)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new vt,default:this.defaultGroupCache[t]};return new me(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
307
+ `,e+=`
308
+ `;for(let i=0;i<t;i++)i>0&&(e+=`
309
+ else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
310
+ {`,e+=`
311
+ color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
312
+ }`;return e+=`
313
+ `,e+=`
314
+ `,e}}class ys{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Op(){return!ce.apple.device}function kp(s){let t=!0;const e=q.ADAPTER.getNavigator();if(ce.tablet||ce.phone){if(ce.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(ce.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?s:4}class _r{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Np=`varying vec2 vTextureCoord;
357
315
  varying vec4 vColor;
358
316
  varying float vTextureId;
359
317
  uniform sampler2D uSamplers[%count%];
@@ -363,7 +321,7 @@ void main(void){
363
321
  %forloop%
364
322
  gl_FragColor = color * vColor;
365
323
  }
366
- `,Zp=`precision highp float;
324
+ `,Up=`precision highp float;
367
325
  attribute vec2 aVertexPosition;
368
326
  attribute vec2 aTextureCoord;
369
327
  attribute vec4 aColor;
@@ -384,14 +342,14 @@ void main(void){
384
342
  vTextureId = aTextureId;
385
343
  vColor = aColor * tint;
386
344
  }
387
- `;const Un=class Ui extends Nn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=el,this.vertexSize=6,this.state=Pi.for2d(),this.size=Ui.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??jp(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Yp(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return Oe("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Zp}static get defaultFragmentTemplate(){return qp}setShaderGenerator({vertex:t=Ui.defaultVertexSrc,fragment:r=Ui.defaultFragmentTemplate}={}){this.shaderGenerator=new b0(t,r)}contextChange(){const t=this.renderer.gl;ue.PREFER_ENV===ys.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Ui.defaultMaxTextures),this.maxTextures=o0(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let r=0;r<this._packedGeometryPoolSize;r++)this._packedGeometries[r]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:r}=Ui,i=this.size/4,n=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new zo);for(;r.length<n;)r.push(new Zo);for(let o=0;o<this.maxTextures;o++)this._tempBoundTextures[o]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:r}=this,i=Ui._textureArrayPool,n=this.renderer.batch,o=this._tempBoundTextures,h=this.renderer.textureGC.count;let c=++Ge._globalBatch,b=0,T=i[0],C=0;n.copyBoundTextures(o,r);for(let x=0;x<this._bufferSize;++x){const $=t[x];t[x]=null,$._batchEnabled!==c&&(T.count>=r&&(n.boundArray(T,o,c,r),this.buildDrawCalls(T,C,x),C=x,T=i[++b],++c),$._batchEnabled=c,$.touched=h,T.elements[T.count++]=$)}T.count>0&&(n.boundArray(T,o,c,r),this.buildDrawCalls(T,C,this._bufferSize),++b,++c);for(let x=0;x<o.length;x++)o[x]=null;Ge._globalBatch=c}buildDrawCalls(t,r,i){const{_bufferedElements:n,_attributeBuffer:o,_indexBuffer:h,vertexSize:c}=this,b=Ui._drawCallPool;let T=this._dcIndex,C=this._aIndex,x=this._iIndex,$=b[T];$.start=this._iIndex,$.texArray=t;for(let I=r;I<i;++I){const B=n[I],U=B._texture.baseTexture,G=Nh[U.alphaMode?1:0][B.blendMode];n[I]=null,r<I&&$.blend!==G&&($.size=x-$.start,r=I,$=b[++T],$.texArray=t,$.start=x),this.packInterleavedGeometry(B,o,h,C,x),C+=B.vertexData.length/2*c,x+=B.indices.length,$.blend=G}r<i&&($.size=x-$.start,++T),this._dcIndex=T,this._aIndex=C,this._iIndex=x}bindAndClearTexArray(t){const r=this.renderer.texture;for(let i=0;i<t.count;i++)r.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:r,_indexBuffer:i}=this;Ui.canUploadSameBuffer?(t[this._flushId]._buffer.update(r.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(r.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:r,state:i}=this.renderer,n=Ui._drawCallPool;let o=null;for(let h=0;h<t;h++){const{texArray:c,type:b,size:T,start:C,blend:x}=n[h];o!==c&&(o=c,this.bindAndClearTexArray(c)),this.state.blendMode=x,i.set(this.state),r.drawElements(b,T,r.UNSIGNED_SHORT,C*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Ui.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const r=Dn(Math.ceil(t/8)),i=Vh(r),n=r*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let o=this._aBuffers[n];return o||(this._aBuffers[n]=o=new Vo(n*this.vertexSize*4)),o}getIndexBuffer(t){const r=Dn(Math.ceil(t/12)),i=Vh(r),n=r*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let o=this._iBuffers[i];return o||(this._iBuffers[i]=o=new Uint16Array(n)),o}packInterleavedGeometry(t,r,i,n,o){const{uint32View:h,float32View:c}=r,b=n/this.vertexSize,T=t.uvs,C=t.indices,x=t.vertexData,$=t._texture.baseTexture._batchLocation,I=Math.min(t.worldAlpha,1),B=rr.shared.setValue(t._tintRGB).toPremultiplied(I,t._texture.baseTexture.alphaMode>0);for(let U=0;U<x.length;U+=2)c[n++]=x[U],c[n++]=x[U+1],c[n++]=T[U],c[n++]=T[U+1],h[n++]=B,c[n++]=$;for(let U=0;U<C.length;U++)i[o++]=b+C[U]}};Un.defaultBatchSize=4096,Un.extension={name:"batch",type:Kt.RendererPlugin},Un._drawCallPool=[],Un._textureArrayPool=[];let bs=Un;be.add(bs);var Qp=`varying vec2 vTextureCoord;
345
+ `;const yr=class xe extends _r{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Sa,this.vertexSize=6,this.state=fe.for2d(),this.size=xe.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??kp(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Op(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return ot("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Up}static get defaultFragmentTemplate(){return Np}setShaderGenerator({vertex:t=xe.defaultVertexSrc,fragment:e=xe.defaultFragmentTemplate}={}){this.shaderGenerator=new ru(t,e)}contextChange(){const t=this.renderer.gl;q.PREFER_ENV===Zt.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),xe.defaultMaxTextures),this.maxTextures=Hl(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=xe,i=this.size/4,r=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new ds);for(;e.length<r;)e.push(new ys);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=xe._textureArrayPool,r=this.renderer.batch,n=this._tempBoundTextures,a=this.renderer.textureGC.count;let o=++lt._globalBatch,h=0,l=i[0],u=0;r.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==o&&(l.count>=e&&(r.boundArray(l,n,o,e),this.buildDrawCalls(l,u,c),u=c,l=i[++h],++o),d._batchEnabled=o,d.touched=a,l.elements[l.count++]=d)}l.count>0&&(r.boundArray(l,n,o,e),this.buildDrawCalls(l,u,this._bufferSize),++h,++o);for(let c=0;c<n.length;c++)n[c]=null;lt._globalBatch=o}buildDrawCalls(t,e,i){const{_bufferedElements:r,_attributeBuffer:n,_indexBuffer:a,vertexSize:o}=this,h=xe._drawCallPool;let l=this._dcIndex,u=this._aIndex,c=this._iIndex,d=h[l];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const p=r[f],g=p._texture.baseTexture,m=ca[g.alphaMode?1:0][p.blendMode];r[f]=null,e<f&&d.blend!==m&&(d.size=c-d.start,e=f,d=h[++l],d.texArray=t,d.start=c),this.packInterleavedGeometry(p,n,a,u,c),u+=p.vertexData.length/2*o,c+=p.indices.length,d.blend=m}e<i&&(d.size=c-d.start,++l),this._dcIndex=l,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;xe.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,r=xe._drawCallPool;let n=null;for(let a=0;a<t;a++){const{texArray:o,type:h,size:l,start:u,blend:c}=r[a];n!==o&&(n=o,this.bindAndClearTexArray(o)),this.state.blendMode=c,i.set(this.state),e.drawElements(h,l,e.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),xe.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=lr(Math.ceil(t/8)),i=pa(e),r=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[r];return n||(this._aBuffers[r]=n=new us(r*this.vertexSize*4)),n}getIndexBuffer(t){const e=lr(Math.ceil(t/12)),i=pa(e),r=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(r)),n}packInterleavedGeometry(t,e,i,r,n){const{uint32View:a,float32View:o}=e,h=r/this.vertexSize,l=t.uvs,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=gt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let g=0;g<c.length;g+=2)o[r++]=c[g],o[r++]=c[g+1],o[r++]=l[g],o[r++]=l[g+1],a[r++]=p,o[r++]=d;for(let g=0;g<u.length;g++)i[n++]=h+u[g]}};yr.defaultBatchSize=4096,yr.extension={name:"batch",type:$.RendererPlugin},yr._drawCallPool=[],yr._textureArrayPool=[];let Ze=yr;Q.add(Ze);var Gp=`varying vec2 vTextureCoord;
388
346
 
389
347
  uniform sampler2D uSampler;
390
348
 
391
349
  void main(void){
392
350
  gl_FragColor = texture2D(uSampler, vTextureCoord);
393
351
  }
394
- `,Kp=`attribute vec2 aVertexPosition;
352
+ `,Vp=`attribute vec2 aVertexPosition;
395
353
 
396
354
  uniform mat3 projectionMatrix;
397
355
 
@@ -417,7 +375,7 @@ void main(void)
417
375
  gl_Position = filterVertexPosition();
418
376
  vTextureCoord = filterTextureCoord();
419
377
  }
420
- `;const ol=class Mo extends Mi{constructor(t,r,i){const n=Hi.from(t||Mo.defaultVertexSrc,r||Mo.defaultFragmentSrc);super(n,i),this.padding=0,this.resolution=Mo.defaultResolution,this.multisample=Mo.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Pi}apply(t,r,i,n,o){t.applyFilter(this,r,i,n)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Kp}static get defaultFragmentSrc(){return Qp}};ol.defaultResolution=1,ol.defaultMultisample=yr.NONE;let Gr=ol;class Gn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new rr(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:r,background:i,backgroundAlpha:n}=t,o=i??r;o!==void 0&&(this.color=o),this.alpha=n}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}Gn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Gn.extension={type:[Kt.RendererSystem,Kt.CanvasRendererSystem],name:"background"},be.add(Gn);class al{constructor(t){this.renderer=t,this.emptyRenderer=new Nn(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,r){const{boundTextures:i}=this.renderer.texture;for(let n=r-1;n>=0;--n)t[n]=i[n]||null,t[n]&&(t[n]._batchLocation=n)}boundArray(t,r,i,n){const{elements:o,ids:h,count:c}=t;let b=0;for(let T=0;T<c;T++){const C=o[T],x=C._batchLocation;if(x>=0&&x<n&&r[x]===C){h[T]=x;continue}for(;b<n;){const $=r[b];if($&&$._batchEnabled===i&&$._batchLocation===b){b++;continue}h[T]=b,C._batchLocation=b,r[b]=C;break}}}destroy(){this.renderer=null}}al.extension={type:Kt.RendererSystem,name:"batch"},be.add(al);let A0=0;class Vn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=A0++}init(t){if(t.context)this.initFromContext(t.context);else{const r=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:r,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=A0++,this.renderer.runners.contextChange.emit(t);const r=this.renderer.view;r.addEventListener!==void 0&&(r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const r=this.createContext(this.renderer.view,t);this.initFromContext(r)}createContext(t,r){let i;if(ue.PREFER_ENV>=ys.WEBGL2&&(i=t.getContext("webgl2",r)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",r)||t.getContext("experimental-webgl",r),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,r={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,r,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,r,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}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 r=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),r&&!r.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=n,n||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Vn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Vn.extension={type:Kt.RendererSystem,name:"context"},be.add(Vn);class Qo{constructor(t,r){if(this.width=Math.round(t),this.height=Math.round(r),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");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 si("disposeFramebuffer"),this.multisample=yr.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,r){return this.colorTextures[t]=r||new Ge(null,{scaleMode:Gi.NEAREST,resolution:1,mipmap:wi.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new Ge(null,{scaleMode:Gi.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:wi.OFF,format:qt.DEPTH_COMPONENT,type:Pe.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,r){if(t=Math.round(t),r=Math.round(r),!t||!r)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&r===this.height)){this.width=t,this.height=r,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const n=this.colorTextures[i],o=n.resolution;n.setSize(t/o,r/o)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,r/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class hl extends Ge{constructor(t={}){if(typeof t=="number"){const r=arguments[0],i=arguments[1],n=arguments[2],o=arguments[3];t={width:r,height:i,scaleMode:n,resolution:o}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=yr.NONE),super(null,t),this.mipmap=wi.OFF,this.valid=!0,this._clear=new rr([0,0,0,0]),this.framebuffer=new Qo(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,r){this.framebuffer.resize(t*this.resolution,r*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Yi extends en{constructor(t){const r=t,i=r.naturalWidth||r.videoWidth||r.displayWidth||r.width,n=r.naturalHeight||r.videoHeight||r.displayHeight||r.height;super(i,n),this.source=t,this.noSubImage=!1}static crossOrigin(t,r,i){i===void 0&&!r.startsWith("data:")?t.crossOrigin=s0(r):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,r,i,n){const o=t.gl,h=r.realWidth,c=r.realHeight;if(n=n||this.source,typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement){if(!n.complete||n.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement&&n.readyState<=1)return!1;return o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Vr.UNPACK),!this.noSubImage&&r.target===o.TEXTURE_2D&&i.width===h&&i.height===c?o.texSubImage2D(o.TEXTURE_2D,0,0,0,r.format,i.type,n):(i.width=h,i.height=c,o.texImage2D(r.target,0,i.internalFormat,r.format,i.type,n)),!0}update(){if(this.destroyed)return;const t=this.source,r=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(r,i),super.update()}dispose(){this.source=null}}class ll extends Yi{constructor(t,r){if(r=r||{},typeof t=="string"){const i=new Image;Yi.crossOrigin(i,t,r.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(r.createBitmap??ue.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof r.alphaMode=="number"?r.alphaMode:null,this.bitmap=null,this._load=null,r.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((r,i)=>{const n=this.source;this.url=n.src;const o=()=>{this.destroyed||(n.onload=null,n.onerror=null,this.update(),this._load=null,this.createBitmap?r(this.process()):r(this))};n.complete&&n.src?o():(n.onload=o,n.onerror=h=>{i(h),this.onError.emit(h)})}),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 r=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(n=>n.blob()).then(n=>r(n,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Vr.UNPACK?"premultiply":"none"})).then(n=>this.destroyed?Promise.reject():(this.bitmap=n,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,r,i){if(typeof this.alphaMode=="number"&&(r.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,r,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,r,i,this.bitmap),!this.preserveBitmap){let n=!0;const o=r._glTextures;for(const h in o){const c=o[h];if(c!==i&&c.dirtyId!==r.dirtyId){n=!1;break}}n&&(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<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Ko{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,r,i){const n=r.width,o=r.height;if(i){const h=t.width/2/n,c=t.height/2/o,b=t.x/n+h,T=t.y/o+c;i=pr.add(i,pr.NW),this.x0=b+h*pr.uX(i),this.y0=T+c*pr.uY(i),i=pr.add(i,2),this.x1=b+h*pr.uX(i),this.y1=T+c*pr.uY(i),i=pr.add(i,2),this.x2=b+h*pr.uX(i),this.y2=T+c*pr.uY(i),i=pr.add(i,2),this.x3=b+h*pr.uX(i),this.y3=T+c*pr.uY(i)}else this.x0=t.x/n,this.y0=t.y/o,this.x1=(t.x+t.width)/n,this.y1=t.y/o,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/o,this.x3=t.x/n,this.y3=(t.y+t.height)/o;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Ko.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const w0=new Ko;function Jo(s){s.destroy=function(){},s.on=function(){},s.once=function(){},s.emit=function(){}}class ne extends Xi{constructor(t,r,i,n,o,h,c){if(super(),this.noFrame=!1,r||(this.noFrame=!0,r=new Ve(0,0,1,1)),t instanceof ne&&(t=t.baseTexture),this.baseTexture=t,this._frame=r,this.trim=n,this.valid=!1,this.destroyed=!1,this._uvs=w0,this.uvMatrix=null,this.orig=i||r,this._rotate=Number(o||0),o===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=h?new He(h.x,h.y):new He(0,0),this.defaultBorders=c,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=r:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:r}=this.baseTexture;r!=null&&r.url&&Xr[r.url]&&ne.removeFromCache(r.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,ne.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var n;const t=this._frame.clone(),r=this._frame===this.orig?t:this.orig.clone(),i=new ne(this.baseTexture,!this.noFrame&&t,r,(n=this.trim)==null?void 0:n.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===w0&&(this._uvs=new Ko),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,r={},i=ue.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let o=null;if(n)o=t;else if(t instanceof Ge){if(!t.cacheId){const c=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t.cacheId=`${c}-${vs()}`,Ge.addToCache(t,t.cacheId)}o=t.cacheId}else{if(!t._pixiId){const c=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t._pixiId=`${c}_${vs()}`}o=t._pixiId}let h=Xr[o];if(n&&i&&!h)throw new Error(`The cacheId "${o}" does not exist in TextureCache.`);return!h&&!(t instanceof Ge)?(r.resolution||(r.resolution=Wi(t)),h=new ne(new Ge(t,r)),h.baseTexture.cacheId=o,Ge.addToCache(h.baseTexture,o),ne.addToCache(h,o)):!h&&t instanceof Ge&&(h=new ne(t),ne.addToCache(h,o)),h}static fromURL(t,r){const i=Object.assign({autoLoad:!1},r==null?void 0:r.resourceOptions),n=ne.from(t,Object.assign({resourceOptions:i},r),!1),o=n.baseTexture.resource;return n.baseTexture.valid?Promise.resolve(n):o.load().then(()=>Promise.resolve(n))}static fromBuffer(t,r,i,n){return new ne(Ge.fromBuffer(t,r,i,n))}static fromLoader(t,r,i,n){const o=new Ge(t,Object.assign({scaleMode:Ge.defaultOptions.scaleMode,resolution:Wi(r)},n)),{resource:h}=o;h instanceof ll&&(h.url=r);const c=new ne(o);return i||(i=r),Ge.addToCache(c.baseTexture,i),ne.addToCache(c,i),i!==r&&(Ge.addToCache(c.baseTexture,r),ne.addToCache(c,r)),c.baseTexture.valid?Promise.resolve(c):new Promise(b=>{c.baseTexture.once("loaded",()=>b(c))})}static addToCache(t,r){r&&(t.textureCacheIds.includes(r)||t.textureCacheIds.push(r),Xr[r]&&Xr[r]!==t&&console.warn(`Texture added to the cache with an id [${r}] that already had an entry`),Xr[r]=t)}static removeFromCache(t){if(typeof t=="string"){const r=Xr[t];if(r){const i=r.textureCacheIds.indexOf(t);return i>-1&&r.textureCacheIds.splice(i,1),delete Xr[t],r}}else if(t!=null&&t.textureCacheIds){for(let r=0;r<t.textureCacheIds.length;++r)Xr[t.textureCacheIds[r]]===t&&delete Xr[t.textureCacheIds[r]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:r,y:i,width:n,height:o}=t,h=r+n>this.baseTexture.width,c=i+o>this.baseTexture.height;if(h||c){const b=h&&c?"and":"or",T=`X: ${r} + ${n} = ${r+n} > ${this.baseTexture.width}`,C=`Y: ${i} + ${o} = ${i+o} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${T} ${b} ${C}`)}this.valid=n&&o&&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 ne._EMPTY||(ne._EMPTY=new ne(new Ge),Jo(ne._EMPTY),Jo(ne._EMPTY.baseTexture)),ne._EMPTY}static get WHITE(){if(!ne._WHITE){const t=ue.ADAPTER.createCanvas(16,16),r=t.getContext("2d");t.width=16,t.height=16,r.fillStyle="white",r.fillRect(0,0,16,16),ne._WHITE=new ne(Ge.from(t)),Jo(ne._WHITE),Jo(ne._WHITE.baseTexture)}return ne._WHITE}}class As extends ne{constructor(t,r){super(t,r),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,r,i=!0){const n=this.baseTexture.resolution,o=Math.round(t*n)/n,h=Math.round(r*n)/n;this.valid=o>0&&h>0,this._frame.width=this.orig.width=o,this._frame.height=this.orig.height=h,i&&this.baseTexture.resize(o,h),this.updateUvs()}setResolution(t){const{baseTexture:r}=this;r.resolution!==t&&(r.setResolution(t),this.resize(r.width,r.height,!1))}static create(t){return new As(new hl(t))}}class ul{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,r,i=yr.NONE){const n=new hl(Object.assign({width:t,height:r,resolution:1,multisample:i},this.textureOptions));return new As(n)}getOptimalTexture(t,r,i=1,n=yr.NONE){let o;t=Math.max(Math.ceil(t*i-1e-6),1),r=Math.max(Math.ceil(r*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||r!==this._pixelsHeight?(t=Dn(t),r=Dn(r),o=((t&65535)<<16|r&65535)>>>0,n>1&&(o+=n*4294967296)):o=n>1?-n:-1,this.texturePool[o]||(this.texturePool[o]=[]);let h=this.texturePool[o].pop();return h||(h=this.createTexture(t,r,n)),h.filterPoolKey=o,h.setResolution(i),h}getFilterTexture(t,r,i){const n=this.getOptimalTexture(t.width,t.height,r||t.resolution,i||yr.NONE);return n.filterFrame=t.filterFrame,n}returnTexture(t){const r=t.filterPoolKey;t.filterFrame=null,this.texturePool[r].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const r in this.texturePool){const i=this.texturePool[r];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const r in this.texturePool){if(!(Number(r)<0))continue;const i=this.texturePool[r];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0);this.texturePool[r]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}ul.SCREEN_KEY=-1;class T0 extends ls{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class cl extends ls{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new Ar(this.vertices),this.uvBuffer=new Ar(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,r){let i=0,n=0;return this.uvs[0]=i,this.uvs[1]=n,this.uvs[2]=i+r.width/t.width,this.uvs[3]=n,this.uvs[4]=i+r.width/t.width,this.uvs[5]=n+r.height/t.height,this.uvs[6]=i,this.uvs[7]=n+r.height/t.height,i=r.x,n=r.y,this.vertices[0]=i,this.vertices[1]=n,this.vertices[2]=i+r.width,this.vertices[3]=n,this.vertices[4]=i+r.width,this.vertices[5]=n+r.height,this.vertices[6]=i,this.vertices[7]=n+r.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class E0{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=yr.NONE,this.sourceFrame=new Ve,this.destinationFrame=new Ve,this.bindingSourceFrame=new Ve,this.bindingDestinationFrame=new Ve,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const ta=[new He,new He,new He,new He],fl=new nr;class dl{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new ul,this.statePool=[],this.quad=new T0,this.quadUv=new cl,this.tempRect=new Ve,this.activeState={},this.globalUniforms=new fi({outputFrame:new Ve,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,r){const i=this.renderer,n=this.defaultFilterStack,o=this.statePool.pop()||new E0,h=i.renderTexture;let c,b;if(h.current){const G=h.current;c=G.resolution,b=G.multisample}else c=i.resolution,b=i.multisample;let T=r[0].resolution||c,C=r[0].multisample??b,x=r[0].padding,$=r[0].autoFit,I=r[0].legacy??!0;for(let G=1;G<r.length;G++){const z=r[G];T=Math.min(T,z.resolution||c),C=Math.min(C,z.multisample??b),x=this.useMaxPadding?Math.max(x,z.padding):x+z.padding,$=$&&z.autoFit,I=I||(z.legacy??!0)}n.length===1&&(this.defaultFilterStack[0].renderTexture=h.current),n.push(o),o.resolution=T,o.multisample=C,o.legacy=I,o.target=t,o.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),o.sourceFrame.pad(x);const B=this.tempRect.copyFrom(h.sourceFrame);i.projection.transform&&this.transformAABB(fl.copyFrom(i.projection.transform).invert(),B),$?(o.sourceFrame.fit(B),(o.sourceFrame.width<=0||o.sourceFrame.height<=0)&&(o.sourceFrame.width=0,o.sourceFrame.height=0)):o.sourceFrame.intersects(B)||(o.sourceFrame.width=0,o.sourceFrame.height=0),this.roundFrame(o.sourceFrame,h.current?h.current.resolution:i.resolution,h.sourceFrame,h.destinationFrame,i.projection.transform),o.renderTexture=this.getOptimalFilterTexture(o.sourceFrame.width,o.sourceFrame.height,T,C),o.filters=r,o.destinationFrame.width=o.renderTexture.width,o.destinationFrame.height=o.renderTexture.height;const U=this.tempRect;U.x=0,U.y=0,U.width=o.sourceFrame.width,U.height=o.sourceFrame.height,o.renderTexture.filterFrame=o.sourceFrame,o.bindingSourceFrame.copyFrom(h.sourceFrame),o.bindingDestinationFrame.copyFrom(h.destinationFrame),o.transform=i.projection.transform,i.projection.transform=null,h.bind(o.renderTexture,o.sourceFrame,U),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,r=t.pop(),i=r.filters;this.activeState=r;const n=this.globalUniforms.uniforms;n.outputFrame=r.sourceFrame,n.resolution=r.resolution;const o=n.inputSize,h=n.inputPixel,c=n.inputClamp;if(o[0]=r.destinationFrame.width,o[1]=r.destinationFrame.height,o[2]=1/o[0],o[3]=1/o[1],h[0]=Math.round(o[0]*r.resolution),h[1]=Math.round(o[1]*r.resolution),h[2]=1/h[0],h[3]=1/h[1],c[0]=.5*h[2],c[1]=.5*h[3],c[2]=r.sourceFrame.width*o[2]-.5*h[2],c[3]=r.sourceFrame.height*o[3]-.5*h[3],r.legacy){const T=n.filterArea;T[0]=r.destinationFrame.width,T[1]=r.destinationFrame.height,T[2]=r.sourceFrame.x,T[3]=r.sourceFrame.y,n.filterClamp=n.inputClamp}this.globalUniforms.update();const b=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,r.renderTexture,b.renderTexture,Ti.BLEND,r),this.returnFilterTexture(r.renderTexture);else{let T=r.renderTexture,C=this.getOptimalFilterTexture(T.width,T.height,r.resolution);C.filterFrame=T.filterFrame;let x=0;for(x=0;x<i.length-1;++x){x===1&&r.multisample>1&&(C=this.getOptimalFilterTexture(T.width,T.height,r.resolution),C.filterFrame=T.filterFrame),i[x].apply(this,T,C,Ti.CLEAR,r);const $=T;T=C,C=$}i[x].apply(this,T,b.renderTexture,Ti.BLEND,r),x>1&&r.multisample>1&&this.returnFilterTexture(r.renderTexture),this.returnFilterTexture(T),this.returnFilterTexture(C)}r.clear(),this.statePool.push(r)}bindAndClear(t,r=Ti.CLEAR){const{renderTexture:i,state:n}=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?void 0:t.filterFrame){const h=this.tempRect;h.x=0,h.y=0,h.width=t.filterFrame.width,h.height=t.filterFrame.height,i.bind(t,t.filterFrame,h)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const o=n.stateId&1||this.forceClear;(r===Ti.CLEAR||r===Ti.BLIT&&o)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,r,i,n){const o=this.renderer;o.state.set(t.state),this.bindAndClear(i,n),t.uniforms.uSampler=r,t.uniforms.filterGlobals=this.globalUniforms,o.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(r._frame,r.filterFrame),o.geometry.bind(this.quadUv),o.geometry.draw(Ai.TRIANGLES)):(o.geometry.bind(this.quad),o.geometry.draw(Ai.TRIANGLE_STRIP))}calculateSpriteMatrix(t,r){const{sourceFrame:i,destinationFrame:n}=this.activeState,{orig:o}=r._texture,h=t.set(n.width,0,0,n.height,i.x,i.y),c=r.worldTransform.copyTo(nr.TEMP_MATRIX);return c.invert(),h.prepend(c),h.scale(1/o.width,1/o.height),h.translate(r.anchor.x,r.anchor.y),h}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,r,i=1,n=yr.NONE){return this.texturePool.getOptimalTexture(t,r,i,n)}getFilterTexture(t,r,i){if(typeof t=="number"){const o=t;t=r,r=o}t=t||this.activeState.renderTexture;const n=this.texturePool.getOptimalTexture(t.width,t.height,r||t.resolution,i||yr.NONE);return n.filterFrame=t.filterFrame,n}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,r){const i=ta[0],n=ta[1],o=ta[2],h=ta[3];i.set(r.left,r.top),n.set(r.left,r.bottom),o.set(r.right,r.top),h.set(r.right,r.bottom),t.apply(i,i),t.apply(n,n),t.apply(o,o),t.apply(h,h);const c=Math.min(i.x,n.x,o.x,h.x),b=Math.min(i.y,n.y,o.y,h.y),T=Math.max(i.x,n.x,o.x,h.x),C=Math.max(i.y,n.y,o.y,h.y);r.x=c,r.y=b,r.width=T-c,r.height=C-b}roundFrame(t,r,i,n,o){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(o){const{a:h,b:c,c:b,d:T}=o;if((Math.abs(c)>1e-4||Math.abs(b)>1e-4)&&(Math.abs(h)>1e-4||Math.abs(T)>1e-4))return}o=o?fl.copyFrom(o):fl.identity(),o.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.transformAABB(o,t),t.ceil(r),this.transformAABB(o.invert(),t)}}}dl.extension={type:Kt.RendererSystem,name:"filter"},be.add(dl);class C0{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=yr.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Jp=new Ve;class pl{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Qo(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Ve,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let r=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;ue.PREFER_ENV===ys.WEBGL_LEGACY&&(r=null,i=null),r?t.drawBuffers=n=>r.drawBuffersWEBGL(n):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,r,i=0){const{gl:n}=this;if(t){const o=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,n.bindFramebuffer(n.FRAMEBUFFER,o.framebuffer)),o.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,o.mipLevel=i),o.dirtyId!==t.dirtyId&&(o.dirtyId=t.dirtyId,o.dirtyFormat!==t.dirtyFormat?(o.dirtyFormat=t.dirtyFormat,o.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):o.dirtySize!==t.dirtySize&&(o.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let h=0;h<t.colorTextures.length;h++){const c=t.colorTextures[h];this.renderer.texture.unbind(c.parentTextureArray||c)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),r){const h=r.width>>i,c=r.height>>i,b=h/r.width;this.setViewport(r.x*b,r.y*b,h,c)}else{const h=t.width>>i,c=t.height>>i;this.setViewport(0,0,h,c)}}else this.current&&(this.current=null,n.bindFramebuffer(n.FRAMEBUFFER,null)),r?this.setViewport(r.x,r.y,r.width,r.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,r,i,n){const o=this.viewport;t=Math.round(t),r=Math.round(r),i=Math.round(i),n=Math.round(n),(o.width!==i||o.height!==n||o.x!==t||o.y!==r)&&(o.x=t,o.y=r,o.width=i,o.height=n,this.gl.viewport(t,r,i,n))}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,r,i,n,o=Lo.COLOR|Lo.DEPTH){const{gl:h}=this;h.clearColor(t,r,i,n),h.clear(o)}initFramebuffer(t){const{gl:r}=this,i=new C0(r.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:r}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){r.bindRenderbuffer(r.RENDERBUFFER,i.stencil);let h;this.renderer.context.webGLVersion===1?h=r.DEPTH_STENCIL:t.depth&&t.stencil?h=r.DEPTH24_STENCIL8:t.depth?h=r.DEPTH_COMPONENT24:h=r.STENCIL_INDEX8,i.msaaBuffer?r.renderbufferStorageMultisample(r.RENDERBUFFER,i.multisample,h,t.width,t.height):r.renderbufferStorage(r.RENDERBUFFER,h,t.width,t.height)}const n=t.colorTextures;let o=n.length;r.drawBuffers||(o=Math.min(o,1));for(let h=0;h<o;h++){const c=n[h],b=c.parentTextureArray||c;this.renderer.texture.bind(b,0),h===0&&i.msaaBuffer&&(r.bindRenderbuffer(r.RENDERBUFFER,i.msaaBuffer),r.renderbufferStorageMultisample(r.RENDERBUFFER,i.multisample,b._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,r){const{gl:i}=this,n=t.glFramebuffers[this.CONTEXT_UID],o=t.colorTextures;let h=o.length;i.drawBuffers||(h=Math.min(h,1)),n.multisample>1&&this.canMultisampleFramebuffer(t)?n.msaaBuffer=n.msaaBuffer||i.createRenderbuffer():n.msaaBuffer&&(i.deleteRenderbuffer(n.msaaBuffer),n.msaaBuffer=null,n.blitFramebuffer&&(n.blitFramebuffer.dispose(),n.blitFramebuffer=null));const c=[];for(let b=0;b<h;b++){const T=o[b],C=T.parentTextureArray||T;this.renderer.texture.bind(C,0),b===0&&n.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,n.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,C._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+b,T.target,C._glTextures[this.CONTEXT_UID].texture,r),c.push(i.COLOR_ATTACHMENT0+b))}if(c.length>1&&i.drawBuffers(c),t.depthTexture&&this.writeDepthTexture){const b=t.depthTexture;this.renderer.texture.bind(b,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,b._glTextures[this.CONTEXT_UID].texture,r)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){n.stencil=n.stencil||i.createRenderbuffer();let b,T;this.renderer.context.webGLVersion===1?(b=i.DEPTH_STENCIL_ATTACHMENT,T=i.DEPTH_STENCIL):t.depth&&t.stencil?(b=i.DEPTH_STENCIL_ATTACHMENT,T=i.DEPTH24_STENCIL8):t.depth?(b=i.DEPTH_ATTACHMENT,T=i.DEPTH_COMPONENT24):(b=i.STENCIL_ATTACHMENT,T=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,n.stencil),n.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,T,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,T,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,b,i.RENDERBUFFER,n.stencil)}else n.stencil&&(i.deleteRenderbuffer(n.stencil),n.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:r}=this;let i=yr.NONE;if(t<=1||r===null)return i;for(let n=0;n<r.length;n++)if(r[n]<=t){i=r[n];break}return i===1&&(i=yr.NONE),i}blit(t,r,i){const{current:n,renderer:o,gl:h,CONTEXT_UID:c}=this;if(o.context.webGLVersion!==2||!n)return;const b=n.glFramebuffers[c];if(!b)return;if(!t){if(!b.msaaBuffer)return;const C=n.colorTextures[0];if(!C)return;b.blitFramebuffer||(b.blitFramebuffer=new Qo(n.width,n.height),b.blitFramebuffer.addColorTexture(0,C)),t=b.blitFramebuffer,t.colorTextures[0]!==C&&(t.colorTextures[0]=C,t.dirtyId++,t.dirtyFormat++),(t.width!==n.width||t.height!==n.height)&&(t.width=n.width,t.height=n.height,t.dirtyId++,t.dirtySize++)}r||(r=Jp,r.width=n.width,r.height=n.height),i||(i=r);const T=r.width===i.width&&r.height===i.height;this.bind(t),h.bindFramebuffer(h.READ_FRAMEBUFFER,b.framebuffer),h.blitFramebuffer(r.left,r.top,r.right,r.bottom,i.left,i.top,i.right,i.bottom,h.COLOR_BUFFER_BIT,T?h.NEAREST:h.LINEAR),h.bindFramebuffer(h.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,r){const i=t.glFramebuffers[this.CONTEXT_UID],n=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const o=this.managedFramebuffers.indexOf(t);o>=0&&this.managedFramebuffers.splice(o,1),t.disposeRunner.remove(this),r||(n.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&n.deleteRenderbuffer(i.msaaBuffer),i.stencil&&n.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,r)}disposeAll(t){const r=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<r.length;i++)this.disposeFramebuffer(r[i],t)}forceStencil(){const t=this.current;if(!t)return;const r=t.glFramebuffers[this.CONTEXT_UID];if(!r||r.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,n=t.height,o=this.gl,h=r.stencil=o.createRenderbuffer();o.bindRenderbuffer(o.RENDERBUFFER,h);let c,b;this.renderer.context.webGLVersion===1?(c=o.DEPTH_STENCIL_ATTACHMENT,b=o.DEPTH_STENCIL):t.depth?(c=o.DEPTH_STENCIL_ATTACHMENT,b=o.DEPTH24_STENCIL8):(c=o.STENCIL_ATTACHMENT,b=o.STENCIL_INDEX8),r.msaaBuffer?o.renderbufferStorageMultisample(o.RENDERBUFFER,r.multisample,b,i,n):o.renderbufferStorage(o.RENDERBUFFER,b,i,n),o.framebufferRenderbuffer(o.FRAMEBUFFER,c,o.RENDERBUFFER,h)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Ve}destroy(){this.renderer=null}}pl.extension={type:Kt.RendererSystem,name:"framebuffer"},be.add(pl);const _l={5126:4,5123:2,5121:1};class gl{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,r=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,r.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;ue.PREFER_ENV===ys.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=n=>i.bindVertexArrayOES(n),t.deleteVertexArray=n=>i.deleteVertexArrayOES(n)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(r.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(n,o)=>i.vertexAttribDivisorANGLE(n,o),t.drawElementsInstanced=(n,o,h,c,b)=>i.drawElementsInstancedANGLE(n,o,h,c,b),t.drawArraysInstanced=(n,o,h,c)=>i.drawArraysInstancedANGLE(n,o,h,c)):this.hasInstance=!1}this.canUseUInt32ElementIndex=r.webGLVersion===2||!!r.extensions.uint32ElementIndex}bind(t,r){r=r||this.renderer.shader.shader;const{gl:i}=this;let n=t.glVertexArrayObjects[this.CONTEXT_UID],o=!1;n||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=n={},o=!0);const h=n[r.program.id]||this.initGeometryVao(t,r,o);this._activeGeometry=t,this._activeVao!==h&&(this._activeVao=h,this.hasVao?i.bindVertexArray(h):this.activateVao(t,r.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,r=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const n=t.buffers[i];r.update(n)}}checkCompatibility(t,r){const i=t.attributes,n=r.attributeData;for(const o in n)if(!i[o])throw new Error(`shader and geometry incompatible, geometry missing the "${o}" attribute`)}getSignature(t,r){const i=t.attributes,n=r.attributeData,o=["g",t.id];for(const h in i)n[h]&&o.push(h,n[h].location);return o.join("-")}initGeometryVao(t,r,i=!0){const n=this.gl,o=this.CONTEXT_UID,h=this.renderer.buffer,c=r.program;c.glPrograms[o]||this.renderer.shader.generateProgram(r),this.checkCompatibility(t,c);const b=this.getSignature(t,c),T=t.glVertexArrayObjects[this.CONTEXT_UID];let C=T[b];if(C)return T[c.id]=C,C;const x=t.buffers,$=t.attributes,I={},B={};for(const U in x)I[U]=0,B[U]=0;for(const U in $)!$[U].size&&c.attributeData[U]?$[U].size=c.attributeData[U].size:$[U].size||console.warn(`PIXI Geometry attribute '${U}' size cannot be determined (likely the bound shader does not have the attribute)`),I[$[U].buffer]+=$[U].size*_l[$[U].type];for(const U in $){const G=$[U],z=G.size;G.stride===void 0&&(I[G.buffer]===z*_l[G.type]?G.stride=0:G.stride=I[G.buffer]),G.start===void 0&&(G.start=B[G.buffer],B[G.buffer]+=z*_l[G.type])}C=n.createVertexArray(),n.bindVertexArray(C);for(let U=0;U<x.length;U++){const G=x[U];h.bind(G),i&&G._glBuffers[o].refCount++}return this.activateVao(t,c),T[c.id]=C,T[b]=C,n.bindVertexArray(null),h.unbind(Ei.ARRAY_BUFFER),C}disposeGeometry(t,r){var c;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],n=this.gl,o=t.buffers,h=(c=this.renderer)==null?void 0:c.buffer;if(t.disposeRunner.remove(this),!!i){if(h)for(let b=0;b<o.length;b++){const T=o[b]._glBuffers[this.CONTEXT_UID];T&&(T.refCount--,T.refCount===0&&!r&&h.dispose(o[b],r))}if(!r){for(const b in i)if(b[0]==="g"){const T=i[b];this._activeVao===T&&this.unbind(),n.deleteVertexArray(T)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const r=Object.keys(this.managedGeometries);for(let i=0;i<r.length;i++)this.disposeGeometry(this.managedGeometries[r[i]],t)}activateVao(t,r){const i=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,h=t.buffers,c=t.attributes;t.indexBuffer&&o.bind(t.indexBuffer);let b=null;for(const T in c){const C=c[T],x=h[C.buffer],$=x._glBuffers[n];if(r.attributeData[T]){b!==$&&(o.bind(x),b=$);const I=r.attributeData[T].location;if(i.enableVertexAttribArray(I),i.vertexAttribPointer(I,C.size,C.type||i.FLOAT,C.normalized,C.stride,C.start),C.instance)if(this.hasInstance)i.vertexAttribDivisor(I,C.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,r,i,n){const{gl:o}=this,h=this._activeGeometry;if(h.indexBuffer){const c=h.indexBuffer.data.BYTES_PER_ELEMENT,b=c===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;c===2||c===4&&this.canUseUInt32ElementIndex?h.instanced?o.drawElementsInstanced(t,r||h.indexBuffer.data.length,b,(i||0)*c,n||1):o.drawElements(t,r||h.indexBuffer.data.length,b,(i||0)*c):console.warn("unsupported index buffer type: uint32")}else h.instanced?o.drawArraysInstanced(t,i,r||h.getSize(),n||1):o.drawArrays(t,i,r||h.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}gl.extension={type:Kt.RendererSystem,name:"geometry"},be.add(gl);const S0=new nr;class ea{constructor(t,r){this._texture=t,this.mapCoord=new nr,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof r>"u"?.5:r,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,r){r===void 0&&(r=t);const i=this.mapCoord;for(let n=0;n<t.length;n+=2){const o=t[n],h=t[n+1];r[n]=o*i.a+h*i.c+i.tx,r[n+1]=o*i.b+h*i.d+i.ty}return r}update(t){const r=this._texture;if(!r||!r.valid||!t&&this._textureID===r._updateID)return!1;this._textureID=r._updateID,this._updateID++;const i=r._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const n=r.orig,o=r.trim;o&&(S0.set(n.width/o.width,0,0,n.height/o.height,-o.x/o.width,-o.y/o.height),this.mapCoord.append(S0));const h=r.baseTexture,c=this.uClampFrame,b=this.clampMargin/h.resolution,T=this.clampOffset;return c[0]=(r._frame.x+b+T)/h.width,c[1]=(r._frame.y+b+T)/h.height,c[2]=(r._frame.x+r._frame.width-b+T)/h.width,c[3]=(r._frame.y+r._frame.height-b+T)/h.height,this.uClampOffset[0]=T/h.realWidth,this.uClampOffset[1]=T/h.realHeight,this.isSimple=r._frame.width===h.width&&r._frame.height===h.height&&r.rotate===0,!0}}var t_=`varying vec2 vMaskCoord;
378
+ `;const Da=class Jr extends me{constructor(t,e,i){const r=Ae.from(t||Jr.defaultVertexSrc,e||Jr.defaultFragmentSrc);super(r,i),this.padding=0,this.resolution=Jr.defaultResolution,this.multisample=Jr.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new fe}apply(t,e,i,r,n){t.applyFilter(this,e,i,r)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Vp}static get defaultFragmentSrc(){return Gp}};Da.defaultResolution=1,Da.defaultMultisample=St.NONE;let kt=Da;class vr{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new gt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:r}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=r}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}vr.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},vr.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"background"},Q.add(vr);class Fa{constructor(t){this.renderer=t,this.emptyRenderer=new _r(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:i}=this.renderer.texture;for(let r=e-1;r>=0;--r)t[r]=i[r]||null,t[r]&&(t[r]._batchLocation=r)}boundArray(t,e,i,r){const{elements:n,ids:a,count:o}=t;let h=0;for(let l=0;l<o;l++){const u=n[l],c=u._batchLocation;if(c>=0&&c<r&&e[c]===u){a[l]=c;continue}for(;h<r;){const d=e[h];if(d&&d._batchEnabled===i&&d._batchLocation===h){h++;continue}a[l]=h,u._batchLocation=h,e[h]=u;break}}}destroy(){this.renderer=null}}Fa.extension={type:$.RendererSystem,name:"batch"},Q.add(Fa);let su=0;class xr{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=su++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=su++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(q.PREFER_ENV>=Zt.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}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(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=i||!!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")}}xr.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},xr.extension={type:$.RendererSystem,name:"context"},Q.add(xr);class vs{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");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 Wt("disposeFramebuffer"),this.multisample=St.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new lt(null,{scaleMode:be.NEAREST,resolution:1,mipmap:he.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new lt(null,{scaleMode:be.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:he.OFF,format:H.DEPTH_COMPONENT,type:it.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||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const r=this.colorTextures[i],n=r.resolution;r.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Ba extends lt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],r=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:r,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=St.NONE),super(null,t),this.mipmap=he.OFF,this.valid=!0,this._clear=new gt([0,0,0,0]),this.framebuffer=new vs(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Se extends Di{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,r=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,r),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=Gl(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,r){const n=t.gl,a=e.realWidth,o=e.realHeight;if(r=r||this.source,typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement){if(!r.complete||r.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement&&r.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Nt.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===a&&i.height===o?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,r):(i.width=a,i.height=o,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,r)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class La extends Se{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Se.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??q.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const r=this.source;this.url=r.src;const n=()=>{this.destroyed||(r.onload=null,r.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};r.complete&&r.src?n():(r.onload=n,r.onerror=a=>{i(a),this.onError.emit(a)})}),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,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(r=>r.blob()).then(r=>e(r,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Nt.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,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let r=!0;const n=e._glTextures;for(const a in n){const o=n[a];if(o!==i&&o.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<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class xs{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const r=e.width,n=e.height;if(i){const a=t.width/2/r,o=t.height/2/n,h=t.x/r+a,l=t.y/n+o;i=wt.add(i,wt.NW),this.x0=h+a*wt.uX(i),this.y0=l+o*wt.uY(i),i=wt.add(i,2),this.x1=h+a*wt.uX(i),this.y1=l+o*wt.uY(i),i=wt.add(i,2),this.x2=h+a*wt.uX(i),this.y2=l+o*wt.uY(i),i=wt.add(i,2),this.x3=h+a*wt.uX(i),this.y3=l+o*wt.uY(i)}else this.x0=t.x/r,this.y0=t.y/n,this.x1=(t.x+t.width)/r,this.y1=t.y/n,this.x2=(t.x+t.width)/r,this.y2=(t.y+t.height)/n,this.x3=t.x/r,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}xs.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const nu=new xs;function bs(s){s.destroy=function(){},s.on=function(){},s.once=function(){},s.emit=function(){}}class j extends Ee{constructor(t,e,i,r,n,a,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new ut(0,0,1,1)),t instanceof j&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this.destroyed=!1,this._uvs=nu,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=a?new ft(a.x,a.y):new ft(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&Ut[e.url]&&j.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,j.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var r;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new j(this.baseTexture,!this.noFrame&&t,e,(r=this.trim)==null?void 0:r.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===nu&&(this._uvs=new xs),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=q.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else if(t instanceof lt){if(!t.cacheId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${o}-${qe()}`,lt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${qe()}`}n=t._pixiId}let a=Ut[n];if(r&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!a&&!(t instanceof lt)?(e.resolution||(e.resolution=Ce(t)),a=new j(new lt(t,e)),a.baseTexture.cacheId=n,lt.addToCache(a.baseTexture,n),j.addToCache(a,n)):!a&&t instanceof lt&&(a=new j(t),j.addToCache(a,n)),a}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),r=j.from(t,Object.assign({resourceOptions:i},e),!1),n=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):n.load().then(()=>Promise.resolve(r))}static fromBuffer(t,e,i,r){return new j(lt.fromBuffer(t,e,i,r))}static fromLoader(t,e,i,r){const n=new lt(t,Object.assign({scaleMode:lt.defaultOptions.scaleMode,resolution:Ce(e)},r)),{resource:a}=n;a instanceof La&&(a.url=e);const o=new j(n);return i||(i=e),lt.addToCache(o.baseTexture,i),j.addToCache(o,i),i!==e&&(lt.addToCache(o.baseTexture,e),j.addToCache(o,e)),o.baseTexture.valid?Promise.resolve(o):new Promise(h=>{o.baseTexture.once("loaded",()=>h(o))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Ut[e]&&Ut[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Ut[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Ut[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Ut[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Ut[t.textureCacheIds[e]]===t&&delete Ut[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:r,height:n}=t,a=e+r>this.baseTexture.width,o=i+n>this.baseTexture.height;if(a||o){const h=a&&o?"and":"or",l=`X: ${e} + ${r} = ${e+r} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${u}`)}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 j._EMPTY||(j._EMPTY=new j(new lt),bs(j._EMPTY),bs(j._EMPTY.baseTexture)),j._EMPTY}static get WHITE(){if(!j._WHITE){const t=q.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),j._WHITE=new j(lt.from(t)),bs(j._WHITE),bs(j._WHITE.baseTexture)}return j._WHITE}}class Je extends j{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,i=!0){const r=this.baseTexture.resolution,n=Math.round(t*r)/r,a=Math.round(e*r)/r;this.valid=n>0&&a>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=a,i&&this.baseTexture.resize(n,a),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 Je(new Ba(t))}}class Oa{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=St.NONE){const r=new Ba(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Je(r)}getOptimalTexture(t,e,i=1,r=St.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=lr(t),e=lr(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 a=this.texturePool[n].pop();return a||(a=this.createTexture(t,e,r)),a.filterPoolKey=n,a.setResolution(i),a}getFilterTexture(t,e,i){const r=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||St.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 i=this.texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Oa.SCREEN_KEY=-1;class au extends Ue{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class ka extends Ue{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new At(this.vertices),this.uvBuffer=new At(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,r=0;return this.uvs[0]=i,this.uvs[1]=r,this.uvs[2]=i+e.width/t.width,this.uvs[3]=r,this.uvs[4]=i+e.width/t.width,this.uvs[5]=r+e.height/t.height,this.uvs[6]=i,this.uvs[7]=r+e.height/t.height,i=e.x,r=e.y,this.vertices[0]=i,this.vertices[1]=r,this.vertices[2]=i+e.width,this.vertices[3]=r,this.vertices[4]=i+e.width,this.vertices[5]=r+e.height,this.vertices[6]=i,this.vertices[7]=r+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class ou{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=St.NONE,this.sourceFrame=new ut,this.destinationFrame=new ut,this.bindingSourceFrame=new ut,this.bindingDestinationFrame=new ut,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Ts=[new ft,new ft,new ft,new ft],Na=new vt;class Ua{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Oa,this.statePool=[],this.quad=new au,this.quadUv=new ka,this.tempRect=new ut,this.activeState={},this.globalUniforms=new Qt({outputFrame:new ut,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,r=this.defaultFilterStack,n=this.statePool.pop()||new ou,a=i.renderTexture;let o,h;if(a.current){const m=a.current;o=m.resolution,h=m.multisample}else o=i.resolution,h=i.multisample;let l=e[0].resolution||o,u=e[0].multisample??h,c=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let m=1;m<e.length;m++){const _=e[m];l=Math.min(l,_.resolution||o),u=Math.min(u,_.multisample??h),c=this.useMaxPadding?Math.max(c,_.padding):c+_.padding,d=d&&_.autoFit,f=f||(_.legacy??!0)}r.length===1&&(this.defaultFilterStack[0].renderTexture=a.current),r.push(n),n.resolution=l,n.multisample=u,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const p=this.tempRect.copyFrom(a.sourceFrame);i.projection.transform&&this.transformAABB(Na.copyFrom(i.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,a.current?a.current.resolution:i.resolution,a.sourceFrame,a.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,l,u),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const g=this.tempRect;g.x=0,g.y=0,g.width=n.sourceFrame.width,g.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(a.sourceFrame),n.bindingDestinationFrame.copyFrom(a.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,a.bind(n.renderTexture,n.sourceFrame,g),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const r=this.globalUniforms.uniforms;r.outputFrame=e.sourceFrame,r.resolution=e.resolution;const n=r.inputSize,a=r.inputPixel,o=r.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],a[0]=Math.round(n[0]*e.resolution),a[1]=Math.round(n[1]*e.resolution),a[2]=1/a[0],a[3]=1/a[1],o[0]=.5*a[2],o[1]=.5*a[3],o[2]=e.sourceFrame.width*n[2]-.5*a[2],o[3]=e.sourceFrame.height*n[3]-.5*a[3],e.legacy){const l=r.filterArea;l[0]=e.destinationFrame.width,l[1]=e.destinationFrame.height,l[2]=e.sourceFrame.x,l[3]=e.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const h=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,h.renderTexture,le.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let l=e.renderTexture,u=this.getOptimalFilterTexture(l.width,l.height,e.resolution);u.filterFrame=l.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(l.width,l.height,e.resolution),u.filterFrame=l.filterFrame),i[c].apply(this,l,u,le.CLEAR,e);const d=l;l=u,u=d}i[c].apply(this,l,h.renderTexture,le.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=le.CLEAR){const{renderTexture:i,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?void 0:t.filterFrame){const a=this.tempRect;a.x=0,a.y=0,a.width=t.filterFrame.width,a.height=t.filterFrame.height,i.bind(t,t.filterFrame,a)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=r.stateId&1||this.forceClear;(e===le.CLEAR||e===le.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,r){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,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(oe.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(oe.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:r}=this.activeState,{orig:n}=e._texture,a=t.set(r.width,0,0,r.height,i.x,i.y),o=e.worldTransform.copyTo(vt.TEMP_MATRIX);return o.invert(),a.prepend(o),a.scale(1/n.width,1/n.height),a.translate(e.anchor.x,e.anchor.y),a}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,r=St.NONE){return this.texturePool.getOptimalTexture(t,e,i,r)}getFilterTexture(t,e,i){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,i||St.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 i=Ts[0],r=Ts[1],n=Ts[2],a=Ts[3];i.set(e.left,e.top),r.set(e.left,e.bottom),n.set(e.right,e.top),a.set(e.right,e.bottom),t.apply(i,i),t.apply(r,r),t.apply(n,n),t.apply(a,a);const o=Math.min(i.x,r.x,n.x,a.x),h=Math.min(i.y,r.y,n.y,a.y),l=Math.max(i.x,r.x,n.x,a.x),u=Math.max(i.y,r.y,n.y,a.y);e.x=o,e.y=h,e.width=l-o,e.height=u-h}roundFrame(t,e,i,r,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a,b:o,c:h,d:l}=n;if((Math.abs(o)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(l)>1e-4))return}n=n?Na.copyFrom(n):Na.identity(),n.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}Ua.extension={type:$.RendererSystem,name:"filter"},Q.add(Ua);class hu{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=St.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Hp=new ut;class Ga{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new vs(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new ut,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;q.PREFER_ENV===Zt.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=r=>e.drawBuffersWEBGL(r):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=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!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let a=0;a<t.colorTextures.length;a++){const o=t.colorTextures[a];this.renderer.texture.unbind(o.parentTextureArray||o)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const a=e.width>>i,o=e.height>>i,h=a/e.width;this.setViewport(e.x*h,e.y*h,a,o)}else{const a=t.width>>i,o=t.height>>i;this.setViewport(0,0,a,o)}}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,i,r){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),r=Math.round(r),(n.width!==i||n.height!==r||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=r,this.gl.viewport(t,e,i,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,i,r,n=rs.COLOR|rs.DEPTH){const{gl:a}=this;a.clearColor(t,e,i,r),a.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new hu(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let a;this.renderer.context.webGLVersion===1?a=e.DEPTH_STENCIL:t.depth&&t.stencil?a=e.DEPTH24_STENCIL8:t.depth?a=e.DEPTH_COMPONENT24:a=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,a,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,a,t.width,t.height)}const r=t.colorTextures;let n=r.length;e.drawBuffers||(n=Math.min(n,1));for(let a=0;a<n;a++){const o=r[a],h=o.parentTextureArray||o;this.renderer.texture.bind(h,0),a===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,h._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,r=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let a=n.length;i.drawBuffers||(a=Math.min(a,1)),r.multisample>1&&this.canMultisampleFramebuffer(t)?r.msaaBuffer=r.msaaBuffer||i.createRenderbuffer():r.msaaBuffer&&(i.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const o=[];for(let h=0;h<a;h++){const l=n[h],u=l.parentTextureArray||l;this.renderer.texture.bind(u,0),h===0&&r.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,r.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+h,l.target,u._glTextures[this.CONTEXT_UID].texture,e),o.push(i.COLOR_ATTACHMENT0+h))}if(o.length>1&&i.drawBuffers(o),t.depthTexture&&this.writeDepthTexture){const h=t.depthTexture;this.renderer.texture.bind(h,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,h._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){r.stencil=r.stencil||i.createRenderbuffer();let h,l;this.renderer.context.webGLVersion===1?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH_STENCIL):t.depth&&t.stencil?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH24_STENCIL8):t.depth?(h=i.DEPTH_ATTACHMENT,l=i.DEPTH_COMPONENT24):(h=i.STENCIL_ATTACHMENT,l=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,r.stencil),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,l,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,l,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,h,i.RENDERBUFFER,r.stencil)}else r.stencil&&(i.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 i=St.NONE;if(t<=1||e===null)return i;for(let r=0;r<e.length;r++)if(e[r]<=t){i=e[r];break}return i===1&&(i=St.NONE),i}blit(t,e,i){const{current:r,renderer:n,gl:a,CONTEXT_UID:o}=this;if(n.context.webGLVersion!==2||!r)return;const h=r.glFramebuffers[o];if(!h)return;if(!t){if(!h.msaaBuffer)return;const u=r.colorTextures[0];if(!u)return;h.blitFramebuffer||(h.blitFramebuffer=new vs(r.width,r.height),h.blitFramebuffer.addColorTexture(0,u)),t=h.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,t.dirtyId++,t.dirtyFormat++),(t.width!==r.width||t.height!==r.height)&&(t.width=r.width,t.height=r.height,t.dirtyId++,t.dirtySize++)}e||(e=Hp,e.width=r.width,e.height=r.height),i||(i=e);const l=e.width===i.width&&e.height===i.height;this.bind(t),a.bindFramebuffer(a.READ_FRAMEBUFFER,h.framebuffer),a.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,a.COLOR_BUFFER_BIT,l?a.NEAREST:a.LINEAR),a.bindFramebuffer(a.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(r.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&r.deleteRenderbuffer(i.msaaBuffer),i.stencil&&r.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,r=t.height,n=this.gl,a=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,a);let o,h;this.renderer.context.webGLVersion===1?(o=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH_STENCIL):t.depth?(o=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH24_STENCIL8):(o=n.STENCIL_ATTACHMENT,h=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,h,i,r):n.renderbufferStorage(n.RENDERBUFFER,h,i,r),n.framebufferRenderbuffer(n.FRAMEBUFFER,o,n.RENDERBUFFER,a)}reset(){this.current=this.unknownFramebuffer,this.viewport=new ut}destroy(){this.renderer=null}}Ga.extension={type:$.RendererSystem,name:"framebuffer"},Q.add(Ga);const Va={5126:4,5123:2,5121:1};class Ha{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;q.PREFER_ENV===Zt.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=r=>i.bindVertexArrayOES(r),t.deleteVertexArray=r=>i.deleteVertexArrayOES(r)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(r,n)=>i.vertexAttribDivisorANGLE(r,n),t.drawElementsInstanced=(r,n,a,o,h)=>i.drawElementsInstancedANGLE(r,n,a,o,h),t.drawArraysInstanced=(r,n,a,o)=>i.drawArraysInstancedANGLE(r,n,a,o)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=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 a=r[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==a&&(this._activeVao=a,this.hasVao?i.bindVertexArray(a):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const r=t.buffers[i];e.update(r)}}checkCompatibility(t,e){const i=t.attributes,r=e.attributeData;for(const n in r)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,r=e.attributeData,n=["g",t.id];for(const a in i)r[a]&&n.push(a,r[a].location);return n.join("-")}initGeometryVao(t,e,i=!0){const r=this.gl,n=this.CONTEXT_UID,a=this.renderer.buffer,o=e.program;o.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,o);const h=this.getSignature(t,o),l=t.glVertexArrayObjects[this.CONTEXT_UID];let u=l[h];if(u)return l[o.id]=u,u;const c=t.buffers,d=t.attributes,f={},p={};for(const g in c)f[g]=0,p[g]=0;for(const g in d)!d[g].size&&o.attributeData[g]?d[g].size=o.attributeData[g].size:d[g].size||console.warn(`PIXI Geometry attribute '${g}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[g].buffer]+=d[g].size*Va[d[g].type];for(const g in d){const m=d[g],_=m.size;m.stride===void 0&&(f[m.buffer]===_*Va[m.type]?m.stride=0:m.stride=f[m.buffer]),m.start===void 0&&(m.start=p[m.buffer],p[m.buffer]+=_*Va[m.type])}u=r.createVertexArray(),r.bindVertexArray(u);for(let g=0;g<c.length;g++){const m=c[g];a.bind(m),i&&m._glBuffers[n].refCount++}return this.activateVao(t,o),l[o.id]=u,l[h]=u,r.bindVertexArray(null),a.unbind(ue.ARRAY_BUFFER),u}disposeGeometry(t,e){var o;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],r=this.gl,n=t.buffers,a=(o=this.renderer)==null?void 0:o.buffer;if(t.disposeRunner.remove(this),!!i){if(a)for(let h=0;h<n.length;h++){const l=n[h]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&a.dispose(n[h],e))}if(!e){for(const h in i)if(h[0]==="g"){const l=i[h];this._activeVao===l&&this.unbind(),r.deleteVertexArray(l)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,r=this.CONTEXT_UID,n=this.renderer.buffer,a=t.buffers,o=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let h=null;for(const l in o){const u=o[l],c=a[u.buffer],d=c._glBuffers[r];if(e.attributeData[l]){h!==d&&(n.bind(c),h=d);const f=e.attributeData[l].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(f,u.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,r){const{gl:n}=this,a=this._activeGeometry;if(a.indexBuffer){const o=a.indexBuffer.data.BYTES_PER_ELEMENT,h=o===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;o===2||o===4&&this.canUseUInt32ElementIndex?a.instanced?n.drawElementsInstanced(t,e||a.indexBuffer.data.length,h,(i||0)*o,r||1):n.drawElements(t,e||a.indexBuffer.data.length,h,(i||0)*o):console.warn("unsupported index buffer type: uint32")}else a.instanced?n.drawArraysInstanced(t,i,e||a.getSize(),r||1):n.drawArrays(t,i,e||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Ha.extension={type:$.RendererSystem,name:"geometry"},Q.add(Ha);const lu=new vt;class Es{constructor(t,e){this._texture=t,this.mapCoord=new vt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],a=t[r+1];e[r]=n*i.a+a*i.c+i.tx,e[r+1]=n*i.b+a*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const r=e.orig,n=e.trim;n&&(lu.set(r.width/n.width,0,0,r.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(lu));const a=e.baseTexture,o=this.uClampFrame,h=this.clampMargin/a.resolution,l=this.clampOffset;return o[0]=(e._frame.x+h+l)/a.width,o[1]=(e._frame.y+h+l)/a.height,o[2]=(e._frame.x+e._frame.width-h+l)/a.width,o[3]=(e._frame.y+e._frame.height-h+l)/a.height,this.uClampOffset[0]=l/a.realWidth,this.uClampOffset[1]=l/a.realHeight,this.isSimple=e._frame.width===a.width&&e._frame.height===a.height&&e.rotate===0,!0}}var Xp=`varying vec2 vMaskCoord;
421
379
  varying vec2 vTextureCoord;
422
380
 
423
381
  uniform sampler2D uSampler;
@@ -442,7 +400,7 @@ void main(void)
442
400
 
443
401
  gl_FragColor = original;
444
402
  }
445
- `,e_=`attribute vec2 aVertexPosition;
403
+ `,zp=`attribute vec2 aVertexPosition;
446
404
  attribute vec2 aTextureCoord;
447
405
 
448
406
  uniform mat3 projectionMatrix;
@@ -458,7 +416,7 @@ void main(void)
458
416
  vTextureCoord = aTextureCoord;
459
417
  vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
460
418
  }
461
- `;class P0 extends Gr{constructor(t,r,i){let n=null;typeof t!="string"&&r===void 0&&i===void 0&&(n=t,t=void 0,r=void 0,i=void 0),super(t||e_,r||t_,i),this.maskSprite=n,this.maskMatrix=new nr}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,r,i,n){const o=this._maskSprite,h=o._texture;h.valid&&(h.uvMatrix||(h.uvMatrix=new ea(h,0)),h.uvMatrix.update(),this.uniforms.npmAlpha=h.baseTexture.alphaMode?0:1,this.uniforms.mask=h,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,o).prepend(h.uvMatrix.mapCoord),this.uniforms.alpha=o.worldAlpha,this.uniforms.maskClamp=h.uvMatrix.uClampFrame,t.applyFilter(this,r,i,n))}}class $0{constructor(t=null){this.type=br.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Gr.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=br.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class ml{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,r){let i=r;if(!i.isMaskData){const o=this.maskDataPool.pop()||new $0;o.pooled=!0,o.maskObject=r,i=o}const n=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(n),i._colorMask=n?n._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==br.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case br.SCISSOR:this.renderer.scissor.push(i);break;case br.STENCIL:this.renderer.stencil.push(i);break;case br.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case br.COLOR:this.pushColorMask(i);break}i.type===br.SPRITE&&this.maskStack.push(i)}pop(t){const r=this.maskStack.pop();if(!(!r||r._target!==t)){if(r.enabled)switch(r.type){case br.SCISSOR:this.renderer.scissor.pop(r);break;case br.STENCIL:this.renderer.stencil.pop(r.maskObject);break;case br.SPRITE:this.popSpriteMask(r);break;case br.COLOR:this.popColorMask(r);break}if(r.reset(),r.pooled&&this.maskDataPool.push(r),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===br.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const r=t.maskObject;r?r.isSprite?t.type=br.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=br.SCISSOR:t.type=br.STENCIL:t.type=br.COLOR}pushSpriteMask(t){const{maskObject:r}=t,i=t._target;let n=t._filters;n||(n=this.alphaMaskPool[this.alphaMaskIndex],n||(n=this.alphaMaskPool[this.alphaMaskIndex]=[new P0])),n[0].resolution=t.resolution,n[0].multisample=t.multisample,n[0].maskSprite=r;const o=i.filterArea;i.filterArea=r.getBounds(!0),this.renderer.filter.push(i,n),i.filterArea=o,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const r=t._colorMask,i=t._colorMask=r&t.colorMask;i!==r&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const r=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==r&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}ml.extension={type:Kt.RendererSystem,name:"mask"},be.add(ml);class M0{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:r}=this.renderer,i=this.getStackLength();this.maskStack=t;const n=this.getStackLength();n!==i&&(n===0?r.disable(this.glConst):(r.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const D0=new nr,R0=[],I0=class Xa extends M0{constructor(t){super(t),this.glConst=ue.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const r=t._scissorRect,{maskObject:i}=t,{renderer:n}=this,o=n.renderTexture,h=i.getBounds(!0,R0.pop()??new Ve);this.roundFrameToPixels(h,o.current?o.current.resolution:n.resolution,o.sourceFrame,o.destinationFrame,n.projection.transform),r&&h.fit(r),t._scissorRectLocal=h}static isMatrixRotated(t){if(!t)return!1;const{a:r,b:i,c:n,d:o}=t;return(Math.abs(i)>1e-4||Math.abs(n)>1e-4)&&(Math.abs(r)>1e-4||Math.abs(o)>1e-4)}testScissor(t){const{maskObject:r}=t;if(!r.isFastRect||!r.isFastRect()||Xa.isMatrixRotated(r.worldTransform)||Xa.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,r,i,n,o){Xa.isMatrixRotated(o)||(o=o?D0.copyFrom(o):D0.identity(),o.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.renderer.filter.transformAABB(o,t),t.fit(n),t.x=Math.round(t.x*r),t.y=Math.round(t.y*r),t.width=Math.round(t.width*r),t.height=Math.round(t.height*r))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:r}=this.renderer;t._scissorRect||r.enable(r.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:r}=this.renderer;t&&R0.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():r.disable(r.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let r;this.renderer.renderTexture.current?r=t.y:r=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,r,t.width,t.height)}};I0.extension={type:Kt.RendererSystem,name:"scissor"};let F0=I0;be.add(F0);class yl extends M0{constructor(t){super(t),this.glConst=ue.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const r=t.maskObject,{gl:i}=this.renderer,n=t._stencilCounter;n===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const o=t._colorMask;o!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,n,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),r.renderable=!0,r.render(this.renderer),this.renderer.batch.flush(),r.renderable=!1,o!==0&&(t._colorMask=o,i.colorMask((o&1)!==0,(o&2)!==0,(o&4)!==0,(o&8)!==0)),this._useCurrent()}pop(t){const r=this.renderer.gl;if(this.getStackLength()===0)r.disable(r.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,n=i?i._colorMask:15;n!==0&&(i._colorMask=0,r.colorMask(!1,!1,!1,!1)),r.stencilOp(r.KEEP,r.KEEP,r.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,n!==0&&(i._colorMask=n,r.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&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)}}yl.extension={type:Kt.RendererSystem,name:"stencil"},be.add(yl);class vl{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const r in t)this.plugins[r]=new t[r](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}vl.extension={type:[Kt.RendererSystem,Kt.CanvasRendererSystem],name:"_plugin"},be.add(vl);class xl{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new nr,this.transform=null}update(t,r,i,n){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=r||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,n),this.transform&&this.projectionMatrix.append(this.transform);const o=this.renderer;o.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,o.globalUniforms.update(),o.shader.shader&&o.shader.syncUniformGroup(o.shader.shader.uniforms.globals)}calculateProjection(t,r,i,n){const o=this.projectionMatrix,h=n?-1:1;o.identity(),o.a=1/r.width*2,o.d=h*(1/r.height*2),o.tx=-1-r.x*o.a,o.ty=-h-r.y*o.d}setTransform(t){}destroy(){this.renderer=null}}xl.extension={type:Kt.RendererSystem,name:"projection"},be.add(xl);const r_=new rn,L0=new Ve;class bl{constructor(t){this.renderer=t,this._tempMatrix=new nr}generateTexture(t,r){const{region:i,...n}=r||{},o=(i==null?void 0:i.copyTo(L0))||t.getLocalBounds(L0,!0),h=n.resolution||this.renderer.resolution;o.width=Math.max(o.width,1/h),o.height=Math.max(o.height,1/h),n.width=o.width,n.height=o.height,n.resolution=h,n.multisample??(n.multisample=this.renderer.multisample);const c=As.create(n);this._tempMatrix.tx=-o.x,this._tempMatrix.ty=-o.y;const b=t.transform;return t.transform=r_,this.renderer.render(t,{renderTexture:c,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=b,c}destroy(){}}bl.extension={type:[Kt.RendererSystem,Kt.CanvasRendererSystem],name:"textureGenerator"},be.add(bl);const Vs=new Ve,Xn=new Ve;class Al{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Ve,this.destinationFrame=new Ve,this.viewportFrame=new Ve}contextChange(){var r;const t=(r=this.renderer)==null?void 0:r.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,r,i){const n=this.renderer;this.current=t;let o,h,c;t?(o=t.baseTexture,c=o.resolution,r||(Vs.width=t.frame.width,Vs.height=t.frame.height,r=Vs),i||(Xn.x=t.frame.x,Xn.y=t.frame.y,Xn.width=r.width,Xn.height=r.height,i=Xn),h=o.framebuffer):(c=n.resolution,r||(Vs.width=n._view.screen.width,Vs.height=n._view.screen.height,r=Vs),i||(i=Vs,i.width=r.width,i.height=r.height));const b=this.viewportFrame;b.x=i.x*c,b.y=i.y*c,b.width=i.width*c,b.height=i.height*c,t||(b.y=n.view.height-(b.y+b.height)),b.ceil(),this.renderer.framebuffer.bind(h,b),this.renderer.projection.update(i,r,c,!h),t?this.renderer.mask.setMaskStack(o.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(r),this.destinationFrame.copyFrom(i)}clear(t,r){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,n=rr.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&n.premultiply(n.alpha);const o=this.destinationFrame,h=this.current?this.current.baseTexture:this.renderer._view.screen,c=o.width!==h.width||o.height!==h.height;if(c){let{x:b,y:T,width:C,height:x}=this.viewportFrame;b=Math.round(b),T=Math.round(T),C=Math.round(C),x=Math.round(x),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(b,T,C,x)}this.renderer.framebuffer.clear(n.red,n.green,n.blue,n.alpha,r),c&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Al.extension={type:Kt.RendererSystem,name:"renderTexture"},be.add(Al);class i_{}class k0{constructor(t,r){this.program=t,this.uniformData=r,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function s_(s,t){const r={},i=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const o=t.getActiveAttrib(s,n);if(o.name.startsWith("gl_"))continue;const h=y0(t,o.type),c={type:h,name:o.name,size:g0(h),location:t.getAttribLocation(s,o.name)};r[o.name]=c}return r}function n_(s,t){const r={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){const o=t.getActiveUniform(s,n),h=o.name.replace(/\[.*?\]$/,""),c=!!o.name.match(/\[.*?\]$/),b=y0(t,o.type);r[h]={name:h,index:n,type:b,size:o.size,isArray:c,value:f0(b,o.size)}}return r}function B0(s,t){var c;const r=c0(s,s.VERTEX_SHADER,t.vertexSrc),i=c0(s,s.FRAGMENT_SHADER,t.fragmentSrc),n=s.createProgram();s.attachShader(n,r),s.attachShader(n,i);const o=(c=t.extra)==null?void 0:c.transformFeedbackVaryings;if(o&&(typeof s.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(n,o.names,o.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(n),s.getProgramParameter(n,s.LINK_STATUS)||Xp(s,n,r,i),t.attributeData=s_(n,s),t.uniformData=n_(n,s),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const b=Object.keys(t.attributeData);b.sort((T,C)=>T>C?1:-1);for(let T=0;T<b.length;T++)t.attributeData[b[T]].location=T,s.bindAttribLocation(n,T,b[T]);s.linkProgram(n)}s.deleteShader(r),s.deleteShader(i);const h={};for(const b in t.uniformData){const T=t.uniformData[b];h[b]={location:s.getUniformLocation(n,b),value:f0(T.type,T.size)}}return new k0(n,h)}function o_(s,t,r,i,n){r.buffer.update(n)}const a_={float:`
419
+ `;class uu extends kt{constructor(t,e,i){let r=null;typeof t!="string"&&e===void 0&&i===void 0&&(r=t,t=void 0,e=void 0,i=void 0),super(t||zp,e||Xp,i),this.maskSprite=r,this.maskMatrix=new vt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,r){const n=this._maskSprite,a=n._texture;a.valid&&(a.uvMatrix||(a.uvMatrix=new Es(a,0)),a.uvMatrix.update(),this.uniforms.npmAlpha=a.baseTexture.alphaMode?0:1,this.uniforms.mask=a,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(a.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=a.uvMatrix.uClampFrame,t.applyFilter(this,e,i,r))}}class cu{constructor(t=null){this.type=It.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=kt.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=It.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Xa{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new cu;n.pooled=!0,n.maskObject=e,i=n}const r=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(r),i._colorMask=r?r._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==It.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case It.SCISSOR:this.renderer.scissor.push(i);break;case It.STENCIL:this.renderer.stencil.push(i);break;case It.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case It.COLOR:this.pushColorMask(i);break}i.type===It.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case It.SCISSOR:this.renderer.scissor.pop(e);break;case It.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case It.SPRITE:this.popSpriteMask(e);break;case It.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===It.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=It.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=It.SCISSOR:t.type=It.STENCIL:t.type=It.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let r=t._filters;r||(r=this.alphaMaskPool[this.alphaMaskIndex],r||(r=this.alphaMaskPool[this.alphaMaskIndex]=[new uu])),r[0].resolution=t.resolution,r[0].multisample=t.multisample,r[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,r),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Xa.extension={type:$.RendererSystem,name:"mask"},Q.add(Xa);class du{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const r=this.getStackLength();r!==i&&(r===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const fu=new vt,pu=[],mu=class mn extends du{constructor(t){super(t),this.glConst=q.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:r}=this,n=r.renderTexture,a=i.getBounds(!0,pu.pop()??new ut);this.roundFrameToPixels(a,n.current?n.current.resolution:r.resolution,n.sourceFrame,n.destinationFrame,r.projection.transform),e&&a.fit(e),t._scissorRectLocal=a}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:r,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||mn.isMatrixRotated(e.worldTransform)||mn.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,r,n){mn.isMatrixRotated(n)||(n=n?fu.copyFrom(n):fu.identity(),n.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.renderer.filter.transformAABB(n,t),t.fit(r),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&pu.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};mu.extension={type:$.RendererSystem,name:"scissor"};let gu=mu;Q.add(gu);class za extends du{constructor(t){super(t),this.glConst=q.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:i}=this.renderer,r=t._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,r,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.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 i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,r=i?i._colorMask:15;r!==0&&(i._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&&(i._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)}}za.extension={type:$.RendererSystem,name:"stencil"},Q.add(za);class Wa{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return ot("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return ot("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return ot("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;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}}Wa.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_plugin"},Q.add(Wa);class $a{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new vt,this.transform=null}update(t,e,i,r){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,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,i,r){const n=this.projectionMatrix,a=r?-1:1;n.identity(),n.a=1/e.width*2,n.d=a*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-a-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}$a.extension={type:$.RendererSystem,name:"projection"},Q.add($a);const Wp=new Fi,_u=new ut;class ja{constructor(t){this.renderer=t,this._tempMatrix=new vt}generateTexture(t,e){const{region:i,...r}=e||{},n=(i==null?void 0:i.copyTo(_u))||t.getLocalBounds(_u,!0),a=r.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/a),n.height=Math.max(n.height,1/a),r.width=n.width,r.height=n.height,r.resolution=a,r.multisample??(r.multisample=this.renderer.multisample);const o=Je.create(r);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const h=t.transform;return t.transform=Wp,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=h,o}destroy(){}}ja.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"textureGenerator"},Q.add(ja);const yi=new ut,br=new ut;class Ya{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new ut,this.destinationFrame=new ut,this.viewportFrame=new ut}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const r=this.renderer;this.current=t;let n,a,o;t?(n=t.baseTexture,o=n.resolution,e||(yi.width=t.frame.width,yi.height=t.frame.height,e=yi),i||(br.x=t.frame.x,br.y=t.frame.y,br.width=e.width,br.height=e.height,i=br),a=n.framebuffer):(o=r.resolution,e||(yi.width=r._view.screen.width,yi.height=r._view.screen.height,e=yi),i||(i=yi,i.width=e.width,i.height=e.height));const h=this.viewportFrame;h.x=i.x*o,h.y=i.y*o,h.width=i.width*o,h.height=i.height*o,t||(h.y=r.view.height-(h.y+h.height)),h.ceil(),this.renderer.framebuffer.bind(a,h),this.renderer.projection.update(i,e,o,!a),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,r=gt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&r.premultiply(r.alpha);const n=this.destinationFrame,a=this.current?this.current.baseTexture:this.renderer._view.screen,o=n.width!==a.width||n.height!==a.height;if(o){let{x:h,y:l,width:u,height:c}=this.viewportFrame;h=Math.round(h),l=Math.round(l),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(h,l,u,c)}this.renderer.framebuffer.clear(r.red,r.green,r.blue,r.alpha,e),o&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Ya.extension={type:$.RendererSystem,name:"renderTexture"},Q.add(Ya);class $p{}class yu{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 jp(s,t){const e={},i=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const n=t.getActiveAttrib(s,r);if(n.name.startsWith("gl_"))continue;const a=tu(t,n.type),o={type:a,name:n.name,size:Jl(a),location:t.getAttribLocation(s,n.name)};e[n.name]=o}return e}function Yp(s,t){const e={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){const n=t.getActiveUniform(s,r),a=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),h=tu(t,n.type);e[a]={name:a,index:r,type:h,size:n.size,isArray:o,value:Yl(h,n.size)}}return e}function vu(s,t){var o;const e=jl(s,s.VERTEX_SHADER,t.vertexSrc),i=jl(s,s.FRAGMENT_SHADER,t.fragmentSrc),r=s.createProgram();s.attachShader(r,e),s.attachShader(r,i);const n=(o=t.extra)==null?void 0:o.transformFeedbackVaryings;if(n&&(typeof s.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(r),s.getProgramParameter(r,s.LINK_STATUS)||Dp(s,r,e,i),t.attributeData=jp(r,s),t.uniformData=Yp(r,s),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const h=Object.keys(t.attributeData);h.sort((l,u)=>l>u?1:-1);for(let l=0;l<h.length;l++)t.attributeData[h[l]].location=l,s.bindAttribLocation(r,l,h[l]);s.linkProgram(r)}s.deleteShader(e),s.deleteShader(i);const a={};for(const h in t.uniformData){const l=t.uniformData[h];a[h]={location:s.getUniformLocation(r,h),value:Yl(l.type,l.size)}}return new yu(r,a)}function qp(s,t,e,i,r){e.buffer.update(r)}const Kp={float:`
462
420
  data[offset] = v;
463
421
  `,vec2:`
464
422
  data[offset] = v[0];
@@ -496,7 +454,7 @@ void main(void)
496
454
  {
497
455
  data[offset + i] = v[i];
498
456
  }
499
- `},O0={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 N0(s){const t=s.map(o=>({data:o,offset:0,dataLen:0,dirty:0}));let r=0,i=0,n=0;for(let o=0;o<t.length;o++){const h=t[o];if(r=O0[h.data.type],h.data.size>1&&(r=Math.max(r,16)*h.data.size),h.dataLen=r,i%r!==0&&i<16){const c=i%r%16;i+=c,n+=c}i+r>16?(n=Math.ceil(n/16)*16,h.offset=n,n+=r,i=r):(h.offset=n,i+=r,n+=r)}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function U0(s,t){const r=[];for(const i in s)t[i]&&r.push(t[i]);return r.sort((i,n)=>i.index-n.index),r}function G0(s,t){if(!s.autoManage)return{size:0,syncFunc:o_};const r=U0(s.uniforms,t),{uboElements:i,size:n}=N0(r),o=[`
457
+ `},xu={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 bu(s){const t=s.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,r=0;for(let n=0;n<t.length;n++){const a=t[n];if(e=xu[a.data.type],a.data.size>1&&(e=Math.max(e,16)*a.data.size),a.dataLen=e,i%e!==0&&i<16){const o=i%e%16;i+=o,r+=o}i+e>16?(r=Math.ceil(r/16)*16,a.offset=r,r+=e,i=e):(a.offset=r,i+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}function Tu(s,t){const e=[];for(const i in s)t[i]&&e.push(t[i]);return e.sort((i,r)=>i.index-r.index),e}function Eu(s,t){if(!s.autoManage)return{size:0,syncFunc:qp};const e=Tu(s.uniforms,t),{uboElements:i,size:r}=bu(e),n=[`
500
458
  var v = null;
501
459
  var v2 = null;
502
460
  var cv = null;
@@ -504,31 +462,31 @@ void main(void)
504
462
  var gl = renderer.gl
505
463
  var index = 0;
506
464
  var data = buffer.data;
507
- `];for(let h=0;h<i.length;h++){const c=i[h],b=s.uniforms[c.data.name],T=c.data.name;let C=!1;for(let x=0;x<Gs.length;x++){const $=Gs[x];if($.codeUbo&&$.test(c.data,b)){o.push(`offset = ${c.offset/4};`,Gs[x].codeUbo(c.data.name,b)),C=!0;break}}if(!C)if(c.data.size>1){const x=g0(c.data.type),$=Math.max(O0[c.data.type]/16,1),I=x/$,B=(4-I%4)%4;o.push(`
508
- cv = ud.${T}.value;
509
- v = uv.${T};
510
- offset = ${c.offset/4};
465
+ `];for(let a=0;a<i.length;a++){const o=i[a],h=s.uniforms[o.data.name],l=o.data.name;let u=!1;for(let c=0;c<_i.length;c++){const d=_i[c];if(d.codeUbo&&d.test(o.data,h)){n.push(`offset = ${o.offset/4};`,_i[c].codeUbo(o.data.name,h)),u=!0;break}}if(!u)if(o.data.size>1){const c=Jl(o.data.type),d=Math.max(xu[o.data.type]/16,1),f=c/d,p=(4-f%4)%4;n.push(`
466
+ cv = ud.${l}.value;
467
+ v = uv.${l};
468
+ offset = ${o.offset/4};
511
469
 
512
470
  t = 0;
513
471
 
514
- for(var i=0; i < ${c.data.size*$}; i++)
472
+ for(var i=0; i < ${o.data.size*d}; i++)
515
473
  {
516
- for(var j = 0; j < ${I}; j++)
474
+ for(var j = 0; j < ${f}; j++)
517
475
  {
518
476
  data[offset++] = v[t++];
519
477
  }
520
- offset += ${B};
478
+ offset += ${p};
521
479
  }
522
480
 
523
- `)}else{const x=a_[c.data.type];o.push(`
524
- cv = ud.${T}.value;
525
- v = uv.${T};
526
- offset = ${c.offset/4};
527
- ${x};
528
- `)}}return o.push(`
481
+ `)}else{const c=Kp[o.data.type];n.push(`
482
+ cv = ud.${l}.value;
483
+ v = uv.${l};
484
+ offset = ${o.offset/4};
485
+ ${c};
486
+ `)}}return n.push(`
529
487
  renderer.buffer.update(buffer);
530
- `),{size:n,syncFunc:new Function("ud","uv","renderer","syncData","buffer",o.join(`
531
- `))}}let h_=0;const ra={textureCount:0,uboCount:0};class wl{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=h_++}systemCheck(){if(!x0())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,r){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,n=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(n.program)),r||(ra.textureCount=0,ra.uboCount=0,this.syncUniformGroup(t.uniformGroup,ra)),n}setUniforms(t){const r=this.shader.program,i=r.glPrograms[this.renderer.CONTEXT_UID];r.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,r){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,r))}syncUniforms(t,r,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(r.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const r=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[r]||(this.cache[r]=Gp(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[r],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,r){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const n=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,r);t.buffer.update(),n(i.uniformData,t.uniforms,this.renderer,ra,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[r])}createSyncBufferGroup(t,r,i){const{gl:n}=this.renderer;this.renderer.buffer.bind(t.buffer);const o=this.gl.getUniformBlockIndex(r.program,i);r.uniformBufferBindings[i]=this.shader.uniformBindCount,n.uniformBlockBinding(r.program,o,this.shader.uniformBindCount),this.shader.uniformBindCount++;const h=this.getSignature(t,this.shader.program.uniformData,"ubo");let c=this._uboCache[h];if(c||(c=this._uboCache[h]=G0(t,this.shader.program.uniformData)),t.autoManage){const b=new Float32Array(c.size/4);t.buffer.update(b)}return r.uniformGroups[t.id]=c.syncFunc,r.uniformGroups[t.id]}getSignature(t,r,i){const n=t.uniforms,o=[`${i}-`];for(const h in n)o.push(h),r[h]&&o.push(r[h].type);return o.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const r=this.gl,i=t.program,n=B0(r,i);return i.glPrograms[this.renderer.CONTEXT_UID]=n,n}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}wl.extension={type:Kt.RendererSystem,name:"shader"},be.add(wl);class zn{constructor(t){this.renderer=t}run(t){const{renderer:r}=this;r.runners.init.emit(r.options),t.hello&&console.log(`PixiJS 7.4.3 - ${r.rendererLogId} - https://pixijs.com`),r.resize(r.screen.width,r.screen.height)}destroy(){}}zn.defaultOptions={hello:!1},zn.extension={type:[Kt.RendererSystem,Kt.CanvasRendererSystem],name:"startup"},be.add(zn);function l_(s,t=[]){return t[De.NORMAL]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.ADD]=[s.ONE,s.ONE],t[De.MULTIPLY]=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.SCREEN]=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.OVERLAY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.DARKEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.LIGHTEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.COLOR_DODGE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.COLOR_BURN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.HARD_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.SOFT_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.DIFFERENCE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.EXCLUSION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.HUE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.SATURATION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.COLOR]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.LUMINOSITY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.NONE]=[0,0],t[De.NORMAL_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.ADD_NPM]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t[De.SCREEN_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[De.SRC_IN]=[s.DST_ALPHA,s.ZERO],t[De.SRC_OUT]=[s.ONE_MINUS_DST_ALPHA,s.ZERO],t[De.SRC_ATOP]=[s.DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[De.DST_OVER]=[s.ONE_MINUS_DST_ALPHA,s.ONE],t[De.DST_IN]=[s.ZERO,s.SRC_ALPHA],t[De.DST_OUT]=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],t[De.DST_ATOP]=[s.ONE_MINUS_DST_ALPHA,s.SRC_ALPHA],t[De.XOR]=[s.ONE_MINUS_DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[De.SUBTRACT]=[s.ONE,s.ONE,s.ONE,s.ONE,s.FUNC_REVERSE_SUBTRACT,s.FUNC_ADD],t}const u_=0,c_=1,f_=2,d_=3,p_=4,__=5,V0=class Mu{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=De.NONE,this._blendEq=!1,this.map=[],this.map[u_]=this.setBlend,this.map[c_]=this.setOffset,this.map[f_]=this.setCullFace,this.map[d_]=this.setDepthTest,this.map[p_]=this.setFrontFace,this.map[__]=this.setDepthMask,this.checks=[],this.defaultState=new Pi,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=l_(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let r=this.stateId^t.data,i=0;for(;r;)r&1&&this.map[i].call(this,!!(t.data&1<<i)),r=r>>1,i++;this.stateId=t.data}for(let r=0;r<this.checks.length;r++)this.checks[r](this,t)}forceState(t){t=t||this.defaultState;for(let r=0;r<this.map.length;r++)this.map[r].call(this,!!(t.data&1<<r));for(let r=0;r<this.checks.length;r++)this.checks[r](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(Mu.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Mu.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const r=this.blendModes[t],i=this.gl;r.length===2?i.blendFunc(r[0],r[1]):i.blendFuncSeparate(r[0],r[1],r[2],r[3]),r.length===6?(this._blendEq=!0,i.blendEquationSeparate(r[4],r[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,r){this.gl.polygonOffset(t,r)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,r){const i=this.checks.indexOf(t);r&&i===-1?this.checks.push(t):!r&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,r){t.setBlendMode(r.blendMode)}static checkPolygonOffset(t,r){t.setPolygonOffset(1,r.polygonOffset)}destroy(){this.gl=null}};V0.extension={type:Kt.RendererSystem,name:"state"};let X0=V0;be.add(X0);class z0 extends Xi{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const r=(t.priority??[]).filter(n=>t.systems[n]),i=[...r,...Object.keys(t.systems).filter(n=>!r.includes(n))];for(const n of i)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(r=>{this.runners[r]=new si(r)})}addSystem(t,r){const i=new t(this);if(this[r])throw new Error(`Whoops! The name "${r}" is already in use`);this[r]=i,this._systemsHash[r]=i;for(const n in this.runners)this.runners[n].add(i);return this}emitWithCustomOptions(t,r){const i=Object.keys(this._systemsHash);t.items.forEach(n=>{const o=i.find(h=>this._systemsHash[h]===n);n[t.name](r[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Wn=class za{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=za.defaultMaxIdle,this.checkCountMax=za.defaultCheckCountMax,this.mode=za.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==ko.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,r=t.managedTextures;let i=!1;for(let n=0;n<r.length;n++){const o=r[n];o.resource&&this.count-o.touched>this.maxIdle&&(t.destroyTexture(o,!0),r[n]=null,i=!0)}if(i){let n=0;for(let o=0;o<r.length;o++)r[o]!==null&&(r[n++]=r[o]);r.length=n}}unload(t){const r=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&r.destroyTexture(i);for(let n=t.children.length-1;n>=0;n--)this.unload(t.children[n])}destroy(){this.renderer=null}};Wn.defaultMode=ko.AUTO,Wn.defaultMaxIdle=60*60,Wn.defaultCheckCountMax=60*10,Wn.extension={type:Kt.RendererSystem,name:"textureGC"};let ws=Wn;be.add(ws);class ia{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=Pe.UNSIGNED_BYTE,this.internalFormat=qt.RGBA,this.samplerType=0}}function g_(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[s.RGB]:le.FLOAT,[s.RGBA]:le.FLOAT,[s.ALPHA]:le.FLOAT,[s.LUMINANCE]:le.FLOAT,[s.LUMINANCE_ALPHA]:le.FLOAT,[s.R8]:le.FLOAT,[s.R8_SNORM]:le.FLOAT,[s.RG8]:le.FLOAT,[s.RG8_SNORM]:le.FLOAT,[s.RGB8]:le.FLOAT,[s.RGB8_SNORM]:le.FLOAT,[s.RGB565]:le.FLOAT,[s.RGBA4]:le.FLOAT,[s.RGB5_A1]:le.FLOAT,[s.RGBA8]:le.FLOAT,[s.RGBA8_SNORM]:le.FLOAT,[s.RGB10_A2]:le.FLOAT,[s.RGB10_A2UI]:le.FLOAT,[s.SRGB8]:le.FLOAT,[s.SRGB8_ALPHA8]:le.FLOAT,[s.R16F]:le.FLOAT,[s.RG16F]:le.FLOAT,[s.RGB16F]:le.FLOAT,[s.RGBA16F]:le.FLOAT,[s.R32F]:le.FLOAT,[s.RG32F]:le.FLOAT,[s.RGB32F]:le.FLOAT,[s.RGBA32F]:le.FLOAT,[s.R11F_G11F_B10F]:le.FLOAT,[s.RGB9_E5]:le.FLOAT,[s.R8I]:le.INT,[s.R8UI]:le.UINT,[s.R16I]:le.INT,[s.R16UI]:le.UINT,[s.R32I]:le.INT,[s.R32UI]:le.UINT,[s.RG8I]:le.INT,[s.RG8UI]:le.UINT,[s.RG16I]:le.INT,[s.RG16UI]:le.UINT,[s.RG32I]:le.INT,[s.RG32UI]:le.UINT,[s.RGB8I]:le.INT,[s.RGB8UI]:le.UINT,[s.RGB16I]:le.INT,[s.RGB16UI]:le.UINT,[s.RGB32I]:le.INT,[s.RGB32UI]:le.UINT,[s.RGBA8I]:le.INT,[s.RGBA8UI]:le.UINT,[s.RGBA16I]:le.INT,[s.RGBA16UI]:le.UINT,[s.RGBA32I]:le.INT,[s.RGBA32UI]:le.UINT,[s.DEPTH_COMPONENT16]:le.FLOAT,[s.DEPTH_COMPONENT24]:le.FLOAT,[s.DEPTH_COMPONENT32F]:le.FLOAT,[s.DEPTH_STENCIL]:le.FLOAT,[s.DEPTH24_STENCIL8]:le.FLOAT,[s.DEPTH32F_STENCIL8]:le.FLOAT}:t={[s.RGB]:le.FLOAT,[s.RGBA]:le.FLOAT,[s.ALPHA]:le.FLOAT,[s.LUMINANCE]:le.FLOAT,[s.LUMINANCE_ALPHA]:le.FLOAT,[s.DEPTH_STENCIL]:le.FLOAT},t}function m_(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[Pe.UNSIGNED_BYTE]:{[qt.RGBA]:s.RGBA8,[qt.RGB]:s.RGB8,[qt.RG]:s.RG8,[qt.RED]:s.R8,[qt.RGBA_INTEGER]:s.RGBA8UI,[qt.RGB_INTEGER]:s.RGB8UI,[qt.RG_INTEGER]:s.RG8UI,[qt.RED_INTEGER]:s.R8UI,[qt.ALPHA]:s.ALPHA,[qt.LUMINANCE]:s.LUMINANCE,[qt.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[Pe.BYTE]:{[qt.RGBA]:s.RGBA8_SNORM,[qt.RGB]:s.RGB8_SNORM,[qt.RG]:s.RG8_SNORM,[qt.RED]:s.R8_SNORM,[qt.RGBA_INTEGER]:s.RGBA8I,[qt.RGB_INTEGER]:s.RGB8I,[qt.RG_INTEGER]:s.RG8I,[qt.RED_INTEGER]:s.R8I},[Pe.UNSIGNED_SHORT]:{[qt.RGBA_INTEGER]:s.RGBA16UI,[qt.RGB_INTEGER]:s.RGB16UI,[qt.RG_INTEGER]:s.RG16UI,[qt.RED_INTEGER]:s.R16UI,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT16},[Pe.SHORT]:{[qt.RGBA_INTEGER]:s.RGBA16I,[qt.RGB_INTEGER]:s.RGB16I,[qt.RG_INTEGER]:s.RG16I,[qt.RED_INTEGER]:s.R16I},[Pe.UNSIGNED_INT]:{[qt.RGBA_INTEGER]:s.RGBA32UI,[qt.RGB_INTEGER]:s.RGB32UI,[qt.RG_INTEGER]:s.RG32UI,[qt.RED_INTEGER]:s.R32UI,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT24},[Pe.INT]:{[qt.RGBA_INTEGER]:s.RGBA32I,[qt.RGB_INTEGER]:s.RGB32I,[qt.RG_INTEGER]:s.RG32I,[qt.RED_INTEGER]:s.R32I},[Pe.FLOAT]:{[qt.RGBA]:s.RGBA32F,[qt.RGB]:s.RGB32F,[qt.RG]:s.RG32F,[qt.RED]:s.R32F,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT32F},[Pe.HALF_FLOAT]:{[qt.RGBA]:s.RGBA16F,[qt.RGB]:s.RGB16F,[qt.RG]:s.RG16F,[qt.RED]:s.R16F},[Pe.UNSIGNED_SHORT_5_6_5]:{[qt.RGB]:s.RGB565},[Pe.UNSIGNED_SHORT_4_4_4_4]:{[qt.RGBA]:s.RGBA4},[Pe.UNSIGNED_SHORT_5_5_5_1]:{[qt.RGBA]:s.RGB5_A1},[Pe.UNSIGNED_INT_2_10_10_10_REV]:{[qt.RGBA]:s.RGB10_A2,[qt.RGBA_INTEGER]:s.RGB10_A2UI},[Pe.UNSIGNED_INT_10F_11F_11F_REV]:{[qt.RGB]:s.R11F_G11F_B10F},[Pe.UNSIGNED_INT_5_9_9_9_REV]:{[qt.RGB]:s.RGB9_E5},[Pe.UNSIGNED_INT_24_8]:{[qt.DEPTH_STENCIL]:s.DEPTH24_STENCIL8},[Pe.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[qt.DEPTH_STENCIL]:s.DEPTH32F_STENCIL8}}:t={[Pe.UNSIGNED_BYTE]:{[qt.RGBA]:s.RGBA,[qt.RGB]:s.RGB,[qt.ALPHA]:s.ALPHA,[qt.LUMINANCE]:s.LUMINANCE,[qt.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[Pe.UNSIGNED_SHORT_5_6_5]:{[qt.RGB]:s.RGB},[Pe.UNSIGNED_SHORT_4_4_4_4]:{[qt.RGBA]:s.RGBA},[Pe.UNSIGNED_SHORT_5_5_5_1]:{[qt.RGBA]:s.RGBA}},t}class Tl{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Ge,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=m_(t),this.samplerTypes=g_(t);const r=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=r;for(let n=0;n<r;n++)this.boundTextures[n]=null;this.emptyTextures={};const i=new ia(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new ia(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let n=0;n<6;n++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let n=0;n<this.boundTextures.length;n++)this.bind(null,n)}bind(t,r=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const n=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[r]!==t&&(this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),i.bindTexture(t.target,n.texture)),n.dirtyId!==t.dirtyId?(this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),this.updateTexture(t)):n.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[r]=t}else this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[r]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:r,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let n=0;n<i.length;n++)i[n]===this.unknownTexture&&this.bind(null,n)}for(let n=0;n<i.length;n++)i[n]===t&&(this.currentLocation!==n&&(r.activeTexture(r.TEXTURE0+n),this.currentLocation=n),r.bindTexture(t.target,this.emptyTextures[t.target].texture),i[n]=null)}ensureSamplerType(t){const{boundTextures:r,hasIntegerTextures:i,CONTEXT_UID:n}=this;if(i)for(let o=t-1;o>=0;--o){const h=r[o];h&&h._glTextures[n].samplerType!==le.FLOAT&&this.renderer.texture.unbind(h)}}initTexture(t){const r=new ia(this.gl.createTexture());return r.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=r,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),r}initTextureType(t,r){var i;r.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,r.samplerType=this.samplerTypes[r.internalFormat]??le.FLOAT,this.webGLVersion===2&&t.type===Pe.HALF_FLOAT?r.type=this.gl.HALF_FLOAT:r.type=t.type}updateTexture(t){var n;const r=t._glTextures[this.CONTEXT_UID];if(!r)return;const i=this.renderer;if(this.initTextureType(t,r),(n=t.resource)==null?void 0:n.upload(i,t,r))r.samplerType!==le.FLOAT&&(this.hasIntegerTextures=!0);else{const o=t.realWidth,h=t.realHeight,c=i.gl;(r.width!==o||r.height!==h||r.dirtyId<0)&&(r.width=o,r.height=h,c.texImage2D(t.target,0,r.internalFormat,o,h,0,t.format,r.type,null))}t.dirtyStyleId!==r.dirtyStyleId&&this.updateTextureStyle(t),r.dirtyId=t.dirtyId}destroyTexture(t,r){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!r)){const n=this.managedTextures.indexOf(t);n!==-1&&ks(this.managedTextures,n,1)}}updateTextureStyle(t){var i;const r=t._glTextures[this.CONTEXT_UID];r&&((t.mipmap===wi.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?r.mipmap=!1:r.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?r.wrapMode=Vi.CLAMP:r.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,r)||this.setStyle(t,r),r.dirtyStyleId=t.dirtyStyleId)}setStyle(t,r){const i=this.gl;if(r.mipmap&&t.mipmap!==wi.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,r.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,r.wrapMode),r.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const n=this.renderer.context.extensions.anisotropicFiltering;if(n&&t.anisotropicLevel>0&&t.scaleMode===Gi.LINEAR){const o=Math.min(t.anisotropicLevel,i.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,n.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Tl.extension={type:Kt.RendererSystem,name:"texture"},be.add(Tl);class El{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,r){const{gl:i,renderer:n}=this;r&&n.shader.bind(r),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:r,renderer:i,CONTEXT_UID:n}=this,o=r.createTransformFeedback();t._glTransformFeedbacks[n]=o,r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,o);for(let h=0;h<t.buffers.length;h++){const c=t.buffers[h];c&&(i.buffer.update(c),c._glBuffers[n].refCount++,r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,h,c._glBuffers[n].buffer||null))}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),o}disposeTransformFeedback(t,r){const i=t._glTransformFeedbacks[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this);const o=this.renderer.buffer;if(o)for(let h=0;h<t.buffers.length;h++){const c=t.buffers[h];if(!c)continue;const b=c._glBuffers[this.CONTEXT_UID];b&&(b.refCount--,b.refCount===0&&!r&&o.dispose(c,r))}i&&(r||n.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}El.extension={type:Kt.RendererSystem,name:"transformFeedback"},be.add(El);class Hn{constructor(t){this.renderer=t}init(t){this.screen=new Ve(0,0,t.width,t.height),this.element=t.view||ue.ADAPTER.createCanvas(),this.resolution=t.resolution||ue.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,r){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(r*this.resolution);const i=this.element.width/this.resolution,n=this.element.height/this.resolution;this.screen.width=i,this.screen.height=n,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${n}px`),this.renderer.emit("resize",i,n),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var r;t&&((r=this.element.parentNode)==null||r.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Hn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Hn.extension={type:[Kt.RendererSystem,Kt.CanvasRendererSystem],name:"_view"},be.add(Hn),ue.PREFER_ENV=ys.WEBGL2,ue.STRICT_TEXTURE_CACHE=!1,ue.RENDER_OPTIONS={...Vn.defaultOptions,...Gn.defaultOptions,...Hn.defaultOptions,...zn.defaultOptions},Object.defineProperties(ue,{WRAP_MODE:{get(){return Ge.defaultOptions.wrapMode},set(s){Oe("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),Ge.defaultOptions.wrapMode=s}},SCALE_MODE:{get(){return Ge.defaultOptions.scaleMode},set(s){Oe("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),Ge.defaultOptions.scaleMode=s}},MIPMAP_TEXTURES:{get(){return Ge.defaultOptions.mipmap},set(s){Oe("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),Ge.defaultOptions.mipmap=s}},ANISOTROPIC_LEVEL:{get(){return Ge.defaultOptions.anisotropicLevel},set(s){Oe("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),Ge.defaultOptions.anisotropicLevel=s}},FILTER_RESOLUTION:{get(){return Oe("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Gr.defaultResolution},set(s){Gr.defaultResolution=s}},FILTER_MULTISAMPLE:{get(){return Oe("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Gr.defaultMultisample},set(s){Gr.defaultMultisample=s}},SPRITE_MAX_TEXTURES:{get(){return bs.defaultMaxTextures},set(s){Oe("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),bs.defaultMaxTextures=s}},SPRITE_BATCH_SIZE:{get(){return bs.defaultBatchSize},set(s){Oe("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),bs.defaultBatchSize=s}},CAN_UPLOAD_SAME_BUFFER:{get(){return bs.canUploadSameBuffer},set(s){Oe("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),bs.canUploadSameBuffer=s}},GC_MODE:{get(){return ws.defaultMode},set(s){Oe("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),ws.defaultMode=s}},GC_MAX_IDLE:{get(){return ws.defaultMaxIdle},set(s){Oe("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),ws.defaultMaxIdle=s}},GC_MAX_CHECK_COUNT:{get(){return ws.defaultCheckCountMax},set(s){Oe("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),ws.defaultCheckCountMax=s}},PRECISION_VERTEX:{get(){return Hi.defaultVertexPrecision},set(s){Oe("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Hi.defaultVertexPrecision=s}},PRECISION_FRAGMENT:{get(){return Hi.defaultFragmentPrecision},set(s){Oe("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Hi.defaultFragmentPrecision=s}}});var ji=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(ji||{});class Cl{constructor(t,r=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=r,this.priority=i,this.once=n}match(t,r=null){return this.fn===t&&this.context===r}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const r=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),r}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 r=this.next;return this.next=t?null:r,this.previous=null,r}}const W0=class ui{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 Cl(null,null,1/0),this.deltaMS=1/ui.targetFPMS,this.elapsedMS=1/ui.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,r,i=ji.NORMAL){return this._addListener(new Cl(t,r,i))}addOnce(t,r,i=ji.NORMAL){return this._addListener(new Cl(t,r,i,!0))}_addListener(t){let r=this._head.next,i=this._head;if(!r)t.connect(i);else{for(;r;){if(t.priority>r.priority){t.connect(i);break}i=r,r=r.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,r){let i=this._head.next;for(;i;)i.match(t,r)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,r=this._head;for(;r=r.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 r;if(t>this.lastTime){if(r=this.elapsedMS=t-this.lastTime,r>this._maxElapsedMS&&(r=this._maxElapsedMS),r*=this.speed,this._minElapsedMS){const o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=r,this.deltaTime=this.deltaMS*ui.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const r=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,r)/1e3,ui.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const r=Math.max(this.minFPS,t);this._minElapsedMS=1/(r/1e3)}}static get shared(){if(!ui._shared){const t=ui._shared=new ui;t.autoStart=!0,t._protected=!0}return ui._shared}static get system(){if(!ui._system){const t=ui._system=new ui;t.autoStart=!0,t._protected=!0}return ui._system}};W0.targetFPMS=.06;let vr=W0;Object.defineProperties(ue,{TARGET_FPMS:{get(){return vr.targetFPMS},set(s){Oe("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),vr.targetFPMS=s}}});class sa{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(r){this._ticker&&this._ticker.remove(this.render,this),this._ticker=r,r&&r.add(this.render,this,ji.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?vr.shared:new vr,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}sa.extension=Kt.Application,be.add(sa);const H0=[];be.handleByList(Kt.Renderer,H0);function Y0(s){for(const t of H0)if(t.test(s))return new t(s);throw new Error("Unable to auto-detect a suitable renderer.")}var y_=`attribute vec2 aVertexPosition;
488
+ `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
489
+ `))}}let Zp=0;const ws={textureCount:0,uboCount:0};class qa{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=Zp++}systemCheck(){if(!iu())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,r=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(r.program)),e||(ws.textureCount=0,ws.uboCount=0,this.syncUniformGroup(t.uniformGroup,ws)),r}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Ip(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const r=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),r(i.uniformData,t.uniforms,this.renderer,ws,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const a=this.getSignature(t,this.shader.program.uniformData,"ubo");let o=this._uboCache[a];if(o||(o=this._uboCache[a]=Eu(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(o.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=o.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const r=t.uniforms,n=[`${i}-`];for(const a in r)n.push(a),e[a]&&n.push(e[a].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,r=vu(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}qa.extension={type:$.RendererSystem,name:"shader"},Q.add(qa);class Tr{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Tr.defaultOptions={hello:!1},Tr.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"},Q.add(Tr);function Jp(s,t=[]){return t[nt.NORMAL]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.ADD]=[s.ONE,s.ONE],t[nt.MULTIPLY]=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.SCREEN]=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.OVERLAY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.DARKEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.LIGHTEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.COLOR_DODGE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.COLOR_BURN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.HARD_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.SOFT_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.DIFFERENCE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.EXCLUSION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.HUE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.SATURATION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.COLOR]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.LUMINOSITY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.NONE]=[0,0],t[nt.NORMAL_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.ADD_NPM]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t[nt.SCREEN_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.SRC_IN]=[s.DST_ALPHA,s.ZERO],t[nt.SRC_OUT]=[s.ONE_MINUS_DST_ALPHA,s.ZERO],t[nt.SRC_ATOP]=[s.DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[nt.DST_OVER]=[s.ONE_MINUS_DST_ALPHA,s.ONE],t[nt.DST_IN]=[s.ZERO,s.SRC_ALPHA],t[nt.DST_OUT]=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],t[nt.DST_ATOP]=[s.ONE_MINUS_DST_ALPHA,s.SRC_ALPHA],t[nt.XOR]=[s.ONE_MINUS_DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[nt.SUBTRACT]=[s.ONE,s.ONE,s.ONE,s.ONE,s.FUNC_REVERSE_SUBTRACT,s.FUNC_ADD],t}const Qp=0,tm=1,em=2,im=3,rm=4,sm=5,wu=class dh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=nt.NONE,this._blendEq=!1,this.map=[],this.map[Qp]=this.setBlend,this.map[tm]=this.setOffset,this.map[em]=this.setCullFace,this.map[im]=this.setDepthTest,this.map[rm]=this.setFrontFace,this.map[sm]=this.setDepthMask,this.checks=[],this.defaultState=new fe,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=Jp(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(dh.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(dh.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};wu.extension={type:$.RendererSystem,name:"state"};let Cu=wu;Q.add(Cu);class Au extends Ee{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(r=>t.systems[r]),i=[...e,...Object.keys(t.systems).filter(r=>!e.includes(r))];for(const r of i)this.addSystem(t.systems[r],r)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Wt(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(r=>{const n=i.find(a=>this._systemsHash[a]===r);r[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Er=class gn{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=gn.defaultMaxIdle,this.checkCountMax=gn.defaultCheckCountMax,this.mode=gn.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==ss.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let r=0;r<e.length;r++){const n=e[r];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,i=!0)}if(i){let r=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[r++]=e[n]);e.length=r}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}};Er.defaultMode=ss.AUTO,Er.defaultMaxIdle=60*60,Er.defaultCheckCountMax=60*10,Er.extension={type:$.RendererSystem,name:"textureGC"};let Qe=Er;Q.add(Qe);class Cs{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=it.UNSIGNED_BYTE,this.internalFormat=H.RGBA,this.samplerType=0}}function nm(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[s.RGB]:Y.FLOAT,[s.RGBA]:Y.FLOAT,[s.ALPHA]:Y.FLOAT,[s.LUMINANCE]:Y.FLOAT,[s.LUMINANCE_ALPHA]:Y.FLOAT,[s.R8]:Y.FLOAT,[s.R8_SNORM]:Y.FLOAT,[s.RG8]:Y.FLOAT,[s.RG8_SNORM]:Y.FLOAT,[s.RGB8]:Y.FLOAT,[s.RGB8_SNORM]:Y.FLOAT,[s.RGB565]:Y.FLOAT,[s.RGBA4]:Y.FLOAT,[s.RGB5_A1]:Y.FLOAT,[s.RGBA8]:Y.FLOAT,[s.RGBA8_SNORM]:Y.FLOAT,[s.RGB10_A2]:Y.FLOAT,[s.RGB10_A2UI]:Y.FLOAT,[s.SRGB8]:Y.FLOAT,[s.SRGB8_ALPHA8]:Y.FLOAT,[s.R16F]:Y.FLOAT,[s.RG16F]:Y.FLOAT,[s.RGB16F]:Y.FLOAT,[s.RGBA16F]:Y.FLOAT,[s.R32F]:Y.FLOAT,[s.RG32F]:Y.FLOAT,[s.RGB32F]:Y.FLOAT,[s.RGBA32F]:Y.FLOAT,[s.R11F_G11F_B10F]:Y.FLOAT,[s.RGB9_E5]:Y.FLOAT,[s.R8I]:Y.INT,[s.R8UI]:Y.UINT,[s.R16I]:Y.INT,[s.R16UI]:Y.UINT,[s.R32I]:Y.INT,[s.R32UI]:Y.UINT,[s.RG8I]:Y.INT,[s.RG8UI]:Y.UINT,[s.RG16I]:Y.INT,[s.RG16UI]:Y.UINT,[s.RG32I]:Y.INT,[s.RG32UI]:Y.UINT,[s.RGB8I]:Y.INT,[s.RGB8UI]:Y.UINT,[s.RGB16I]:Y.INT,[s.RGB16UI]:Y.UINT,[s.RGB32I]:Y.INT,[s.RGB32UI]:Y.UINT,[s.RGBA8I]:Y.INT,[s.RGBA8UI]:Y.UINT,[s.RGBA16I]:Y.INT,[s.RGBA16UI]:Y.UINT,[s.RGBA32I]:Y.INT,[s.RGBA32UI]:Y.UINT,[s.DEPTH_COMPONENT16]:Y.FLOAT,[s.DEPTH_COMPONENT24]:Y.FLOAT,[s.DEPTH_COMPONENT32F]:Y.FLOAT,[s.DEPTH_STENCIL]:Y.FLOAT,[s.DEPTH24_STENCIL8]:Y.FLOAT,[s.DEPTH32F_STENCIL8]:Y.FLOAT}:t={[s.RGB]:Y.FLOAT,[s.RGBA]:Y.FLOAT,[s.ALPHA]:Y.FLOAT,[s.LUMINANCE]:Y.FLOAT,[s.LUMINANCE_ALPHA]:Y.FLOAT,[s.DEPTH_STENCIL]:Y.FLOAT},t}function am(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[it.UNSIGNED_BYTE]:{[H.RGBA]:s.RGBA8,[H.RGB]:s.RGB8,[H.RG]:s.RG8,[H.RED]:s.R8,[H.RGBA_INTEGER]:s.RGBA8UI,[H.RGB_INTEGER]:s.RGB8UI,[H.RG_INTEGER]:s.RG8UI,[H.RED_INTEGER]:s.R8UI,[H.ALPHA]:s.ALPHA,[H.LUMINANCE]:s.LUMINANCE,[H.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[it.BYTE]:{[H.RGBA]:s.RGBA8_SNORM,[H.RGB]:s.RGB8_SNORM,[H.RG]:s.RG8_SNORM,[H.RED]:s.R8_SNORM,[H.RGBA_INTEGER]:s.RGBA8I,[H.RGB_INTEGER]:s.RGB8I,[H.RG_INTEGER]:s.RG8I,[H.RED_INTEGER]:s.R8I},[it.UNSIGNED_SHORT]:{[H.RGBA_INTEGER]:s.RGBA16UI,[H.RGB_INTEGER]:s.RGB16UI,[H.RG_INTEGER]:s.RG16UI,[H.RED_INTEGER]:s.R16UI,[H.DEPTH_COMPONENT]:s.DEPTH_COMPONENT16},[it.SHORT]:{[H.RGBA_INTEGER]:s.RGBA16I,[H.RGB_INTEGER]:s.RGB16I,[H.RG_INTEGER]:s.RG16I,[H.RED_INTEGER]:s.R16I},[it.UNSIGNED_INT]:{[H.RGBA_INTEGER]:s.RGBA32UI,[H.RGB_INTEGER]:s.RGB32UI,[H.RG_INTEGER]:s.RG32UI,[H.RED_INTEGER]:s.R32UI,[H.DEPTH_COMPONENT]:s.DEPTH_COMPONENT24},[it.INT]:{[H.RGBA_INTEGER]:s.RGBA32I,[H.RGB_INTEGER]:s.RGB32I,[H.RG_INTEGER]:s.RG32I,[H.RED_INTEGER]:s.R32I},[it.FLOAT]:{[H.RGBA]:s.RGBA32F,[H.RGB]:s.RGB32F,[H.RG]:s.RG32F,[H.RED]:s.R32F,[H.DEPTH_COMPONENT]:s.DEPTH_COMPONENT32F},[it.HALF_FLOAT]:{[H.RGBA]:s.RGBA16F,[H.RGB]:s.RGB16F,[H.RG]:s.RG16F,[H.RED]:s.R16F},[it.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:s.RGB565},[it.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:s.RGBA4},[it.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:s.RGB5_A1},[it.UNSIGNED_INT_2_10_10_10_REV]:{[H.RGBA]:s.RGB10_A2,[H.RGBA_INTEGER]:s.RGB10_A2UI},[it.UNSIGNED_INT_10F_11F_11F_REV]:{[H.RGB]:s.R11F_G11F_B10F},[it.UNSIGNED_INT_5_9_9_9_REV]:{[H.RGB]:s.RGB9_E5},[it.UNSIGNED_INT_24_8]:{[H.DEPTH_STENCIL]:s.DEPTH24_STENCIL8},[it.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[H.DEPTH_STENCIL]:s.DEPTH32F_STENCIL8}}:t={[it.UNSIGNED_BYTE]:{[H.RGBA]:s.RGBA,[H.RGB]:s.RGB,[H.ALPHA]:s.ALPHA,[H.LUMINANCE]:s.LUMINANCE,[H.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[it.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:s.RGB},[it.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:s.RGBA},[it.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:s.RGBA}},t}class Ka{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new lt,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=am(t),this.samplerTypes=nm(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const i=new Cs(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Cs(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<i.length;r++)i[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<i.length;r++)i[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:r}=this;if(i)for(let n=t-1;n>=0;--n){const a=e[n];a&&a._glTextures[r].samplerType!==Y.FLOAT&&this.renderer.texture.unbind(a)}}initTexture(t){const e=new Cs(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 i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??Y.FLOAT,this.webGLVersion===2&&t.type===it.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 i=this.renderer;if(this.initTextureType(t,e),(r=t.resource)==null?void 0:r.upload(i,t,e))e.samplerType!==Y.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,a=t.realHeight,o=i.gl;(e.width!==n||e.height!==a||e.dirtyId<0)&&(e.width=n,e.height=a,o.texImage2D(t.target,0,e.internalFormat,n,a,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.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&&di(this.managedTextures,r,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===he.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Te.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==he.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===be.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===be.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===be.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===be.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Ka.extension={type:$.RendererSystem,name:"texture"},Q.add(Ka);class Za{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:i}=this,r=t._glTransformFeedbacks[i]||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:i,renderer:r}=this;e&&r.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:r}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[r]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let a=0;a<t.buffers.length;a++){const o=t.buffers[a];o&&(i.buffer.update(o),o._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,a,o._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let a=0;a<t.buffers.length;a++){const o=t.buffers[a];if(!o)continue;const h=o._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(o,e))}i&&(e||r.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Za.extension={type:$.RendererSystem,name:"transformFeedback"},Q.add(Za);class wr{constructor(t){this.renderer=t}init(t){this.screen=new ut(0,0,t.width,t.height),this.element=t.view||q.ADAPTER.createCanvas(),this.resolution=t.resolution||q.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 i=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=i,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",i,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}}wr.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},wr.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"},Q.add(wr),q.PREFER_ENV=Zt.WEBGL2,q.STRICT_TEXTURE_CACHE=!1,q.RENDER_OPTIONS={...xr.defaultOptions,...vr.defaultOptions,...wr.defaultOptions,...Tr.defaultOptions},Object.defineProperties(q,{WRAP_MODE:{get(){return lt.defaultOptions.wrapMode},set(s){ot("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),lt.defaultOptions.wrapMode=s}},SCALE_MODE:{get(){return lt.defaultOptions.scaleMode},set(s){ot("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),lt.defaultOptions.scaleMode=s}},MIPMAP_TEXTURES:{get(){return lt.defaultOptions.mipmap},set(s){ot("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),lt.defaultOptions.mipmap=s}},ANISOTROPIC_LEVEL:{get(){return lt.defaultOptions.anisotropicLevel},set(s){ot("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),lt.defaultOptions.anisotropicLevel=s}},FILTER_RESOLUTION:{get(){return ot("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),kt.defaultResolution},set(s){kt.defaultResolution=s}},FILTER_MULTISAMPLE:{get(){return ot("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),kt.defaultMultisample},set(s){kt.defaultMultisample=s}},SPRITE_MAX_TEXTURES:{get(){return Ze.defaultMaxTextures},set(s){ot("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Ze.defaultMaxTextures=s}},SPRITE_BATCH_SIZE:{get(){return Ze.defaultBatchSize},set(s){ot("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Ze.defaultBatchSize=s}},CAN_UPLOAD_SAME_BUFFER:{get(){return Ze.canUploadSameBuffer},set(s){ot("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Ze.canUploadSameBuffer=s}},GC_MODE:{get(){return Qe.defaultMode},set(s){ot("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Qe.defaultMode=s}},GC_MAX_IDLE:{get(){return Qe.defaultMaxIdle},set(s){ot("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Qe.defaultMaxIdle=s}},GC_MAX_CHECK_COUNT:{get(){return Qe.defaultCheckCountMax},set(s){ot("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Qe.defaultCheckCountMax=s}},PRECISION_VERTEX:{get(){return Ae.defaultVertexPrecision},set(s){ot("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Ae.defaultVertexPrecision=s}},PRECISION_FRAGMENT:{get(){return Ae.defaultFragmentPrecision},set(s){ot("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Ae.defaultFragmentPrecision=s}}});var Pe=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(Pe||{});class Ja{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=r}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Su=class Kt{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 Ja(null,null,1/0),this.deltaMS=1/Kt.targetFPMS,this.elapsedMS=1/Kt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Pe.NORMAL){return this._addListener(new Ja(t,e,i))}addOnce(t,e,i=Pe.NORMAL){return this._addListener(new Ja(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Kt.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Kt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Kt._shared){const t=Kt._shared=new Kt;t.autoStart=!0,t._protected=!0}return Kt._shared}static get system(){if(!Kt._system){const t=Kt._system=new Kt;t.autoStart=!0,t._protected=!0}return Kt._system}};Su.targetFPMS=.06;let Pt=Su;Object.defineProperties(q,{TARGET_FPMS:{get(){return Pt.targetFPMS},set(s){ot("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Pt.targetFPMS=s}}});class As{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Pe.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Pt.shared:new Pt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}As.extension=$.Application,Q.add(As);const Pu=[];Q.handleByList($.Renderer,Pu);function Mu(s){for(const t of Pu)if(t.test(s))return new t(s);throw new Error("Unable to auto-detect a suitable renderer.")}var om=`attribute vec2 aVertexPosition;
532
490
  attribute vec2 aTextureCoord;
533
491
 
534
492
  uniform mat3 projectionMatrix;
@@ -539,7 +497,7 @@ void main(void)
539
497
  {
540
498
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
541
499
  vTextureCoord = aTextureCoord;
542
- }`,v_=`attribute vec2 aVertexPosition;
500
+ }`,hm=`attribute vec2 aVertexPosition;
543
501
 
544
502
  uniform mat3 projectionMatrix;
545
503
 
@@ -565,7 +523,7 @@ void main(void)
565
523
  gl_Position = filterVertexPosition();
566
524
  vTextureCoord = filterTextureCoord();
567
525
  }
568
- `;const j0=y_,Sl=v_;class Pl{constructor(t){this.renderer=t}contextChange(t){let r;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),r=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),r=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}r>=yr.HIGH?this.multisample=yr.HIGH:r>=yr.MEDIUM?this.multisample=yr.MEDIUM:r>=yr.LOW?this.multisample=yr.LOW:this.multisample=yr.NONE}destroy(){}}Pl.extension={type:Kt.RendererSystem,name:"_multisample"},be.add(Pl);class x_{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class $l{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glBuffers[i]||this.createGLBuffer(t);r.bindBuffer(t.type,n.buffer)}unbind(t){const{gl:r}=this;r.bindBuffer(t,null)}bindBufferBase(t,r){const{gl:i,CONTEXT_UID:n}=this;if(this.boundBufferBases[r]!==t){const o=t._glBuffers[n]||this.createGLBuffer(t);this.boundBufferBases[r]=t,i.bindBufferBase(i.UNIFORM_BUFFER,r,o.buffer)}}bindBufferRange(t,r,i){const{gl:n,CONTEXT_UID:o}=this;i=i||0;const h=t._glBuffers[o]||this.createGLBuffer(t);n.bindBufferRange(n.UNIFORM_BUFFER,r||0,h.buffer,i*256,256)}update(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==n.updateID)if(n.updateID=t._updateID,r.bindBuffer(t.type,n.buffer),n.byteLength>=t.data.byteLength)r.bufferSubData(t.type,0,t.data);else{const o=t.static?r.STATIC_DRAW:r.DYNAMIC_DRAW;n.byteLength=t.data.byteLength,r.bufferData(t.type,t.data,o)}}dispose(t,r){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this),i&&(r||n.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const r=Object.keys(this.managedBuffers);for(let i=0;i<r.length;i++)this.dispose(this.managedBuffers[r[i]],t)}createGLBuffer(t){const{CONTEXT_UID:r,gl:i}=this;return t._glBuffers[r]=new x_(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[r]}}$l.extension={type:Kt.RendererSystem,name:"buffer"},be.add($l);class Ml{constructor(t){this.renderer=t}render(t,r){const i=this.renderer;let n,o,h,c;if(r&&(n=r.renderTexture,o=r.clear,h=r.transform,c=r.skipUpdateTransform),this.renderingToScreen=!n,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=h,!i.context.isLost){if(n||(this.lastObjectRendered=t),!c){const b=t.enableTempParent();t.updateTransform(),t.disableTempParent(b)}i.renderTexture.bind(n),i.batch.currentRenderer.start(),(o??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),n&&(r.blit&&i.framebuffer.blit(),n.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Ml.extension={type:Kt.RendererSystem,name:"objectRenderer"},be.add(Ml);const na=class Du extends z0{constructor(t){super(),this.type=qa.WEBGL,t=Object.assign({},ue.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new fi({projectionMatrix:new nr},!0);const r={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Du.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(r),"useContextAlpha"in t&&(Oe("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Du.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Oc()}render(t,r){this.objectRenderer.render(t,r)}resize(t,r){this._view.resizeView(t,r)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return Oe("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return Oe("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return Oe("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return Oe("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){Oe("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return Oe("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){Oe("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return Oe("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,r){return this.textureGenerator.generateTexture(t,r)}};na.extension={type:Kt.Renderer,priority:1},na.__plugins={},na.__systems={};let oa=na;be.handleByMap(Kt.RendererPlugin,oa.__plugins),be.handleByMap(Kt.RendererSystem,oa.__systems),be.add(oa);class Dl extends en{constructor(t,r){const{width:i,height:n}=r||{};super(i,n),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){const h=new Ge;this.items.push(h),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,r){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof en?this.addResourceAt(t[i],i):this.addResourceAt(Jh(t[i],r),i))}dispose(){for(let t=0,r=this.length;t<r;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,r){if(!this.items[r])throw new Error(`Index ${r} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[r].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let r=0;r<this.length;r++)this.items[r].parentTextureArray=t,this.items[r].on("update",t.update,t)}unbind(t){super.unbind(t);for(let r=0;r<this.length;r++)this.items[r].parentTextureArray=null,this.items[r].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(r=>r.resource).filter(r=>r).map(r=>r.load());return this._load=Promise.all(t).then(()=>{const{realWidth:r,realHeight:i}=this.items[0];return this.resize(r,i),this.update(),Promise.resolve(this)}),this._load}}class q0 extends Dl{constructor(t,r){const{width:i,height:n}=r||{};let o,h;Array.isArray(t)?(o=t,h=t.length):h=t,super(h,{width:i,height:n}),o&&this.initFromArray(o,r)}addBaseTextureAt(t,r){if(t.resource)this.addResourceAt(t.resource,r);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=Fs.TEXTURE_2D_ARRAY}upload(t,r,i){const{length:n,itemDirtyIds:o,items:h}=this,{gl:c}=t;i.dirtyId<0&&c.texImage3D(c.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,n,0,r.format,i.type,null);for(let b=0;b<n;b++){const T=h[b];o[b]<T.dirtyId&&(o[b]=T.dirtyId,T.valid&&c.texSubImage3D(c.TEXTURE_2D_ARRAY,0,0,0,b,T.resource.width,T.resource.height,1,r.format,i.type,T.resource.source))}return!0}}class Z0 extends Yi{constructor(t){super(t)}static test(t){const{OffscreenCanvas:r}=globalThis;return r&&t instanceof r?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Q0=class Do extends Dl{constructor(t,r){const{width:i,height:n,autoLoad:o,linkBaseTexture:h}=r||{};if(t&&t.length!==Do.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:n});for(let c=0;c<Do.SIDES;c++)this.items[c].target=Fs.TEXTURE_CUBE_MAP_POSITIVE_X+c;this.linkBaseTexture=h!==!1,t&&this.initFromArray(t,r),o!==!1&&this.load()}bind(t){super.bind(t),t.target=Fs.TEXTURE_CUBE_MAP}addBaseTextureAt(t,r,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[r])throw new Error(`Index ${r} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,r);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=Fs.TEXTURE_CUBE_MAP_POSITIVE_X+r,t.parentTextureArray=this.baseTexture,this.items[r]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[r]=t,this}upload(t,r,i){const n=this.itemDirtyIds;for(let o=0;o<Do.SIDES;o++){const h=this.items[o];(n[o]<h.dirtyId||i.dirtyId<r.dirtyId)&&(h.valid&&h.resource?(h.resource.upload(t,h,i),n[o]=h.dirtyId):n[o]<-1&&(t.gl.texImage2D(h.target,0,i.internalFormat,r.realWidth,r.realHeight,0,r.format,i.type,null),n[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Do.SIDES}};Q0.SIDES=6;let K0=Q0;class Xs extends Yi{constructor(t,r){r=r||{};let i,n,o;typeof t=="string"?(i=Xs.EMPTY,n=t,o=!0):(i=t,n=null,o=!1),super(i),this.url=n,this.crossOrigin=r.crossOrigin??!0,this.alphaMode=typeof r.alphaMode=="number"?r.alphaMode:null,this.ownsImageBitmap=r.ownsImageBitmap??o,this._load=null,r.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,r)=>{if(this.url===null){t(this);return}try{const i=await ue.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const n=await i.blob();if(this.destroyed)return;const o=await createImageBitmap(n,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Vr.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(i){if(this.destroyed)return;r(i),this.onError.emit(i)}}),this._load)}upload(t,r,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(r.alphaMode=this.alphaMode),super.upload(t,r,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Xs._EMPTY=Xs._EMPTY??ue.ADAPTER.createCanvas(0,0),Xs._EMPTY}}const Rl=class Wa extends Yi{constructor(t,r){r=r||{},super(ue.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=r.scale||1,this._overrideWidth=r.width,this._overrideHeight=r.height,this._resolve=null,this._crossorigin=r.crossorigin,this._load=null,r.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},Wa.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 t=new Image;Yi.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=r=>{this._resolve&&(t.onerror=null,this.onError.emit(r))},t.onload=()=>{if(!this._resolve)return;const r=t.width,i=t.height;if(!r||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let n=r*this.scale,o=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(n=this._overrideWidth||this._overrideHeight/i*r,o=this._overrideHeight||this._overrideWidth/r*i),n=Math.round(n),o=Math.round(o);const h=this.source;h.width=n,h.height=o,h._pixiId=`canvas_${vs()}`,h.getContext("2d").drawImage(t,0,0,r,i,0,0,n,o),this._resolve(),this._resolve=null}}static getSize(t){const r=Wa.SVG_SIZE.exec(t),i={};return r&&(i[r[1]]=Math.round(parseFloat(r[3])),i[r[5]]=Math.round(parseFloat(r[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,r){return r==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&Wa.SVG_XML.test(t)}};Rl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Rl.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let aa=Rl;class b_ extends Yi{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Il=class Ru extends Yi{constructor(t,r){if(r=r||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");r.autoLoad!==!1&&i.setAttribute("preload","auto"),r.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),r.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),r.loop===!0&&i.setAttribute("loop",""),r.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const n=t[0].src||t[0];Yi.crossOrigin(i,n,r.crossorigin);for(let o=0;o<t.length;++o){const h=document.createElement("source");let{src:c,mime:b}=t[o];if(c=c||t[o],c.startsWith("data:"))b=c.slice(5,c.indexOf(";"));else if(!c.startsWith("blob:")){const T=c.split("?").shift().toLowerCase(),C=T.slice(T.lastIndexOf(".")+1);b=b||Ru.MIME_TYPES[C]||`video/${C}`}h.src=c,b&&(h.type=b),i.appendChild(h)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=r.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=r.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),r.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const r=vr.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-r)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((r,i)=>{this.valid?r(this):(this._resolve=r,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const r=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!r&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(vr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(vr.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(vr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,r){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Ru.TYPES.includes(r)}};Il.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Il.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Fl=Il;Xo.push(Xs,ll,Z0,Fl,b_,aa,Rn,K0,q0);class A_{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new si("disposeTransformFeedback")}bindBuffer(t,r){this.buffers[t]=r}destroy(){this.disposeRunner.emit(this,!1)}}const w_="7.4.3";class Yn{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?Ve.EMPTY:(t=t||new Ve(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,r){const{a:i,b:n,c:o,d:h,tx:c,ty:b}=t,T=i*r.x+o*r.y+c,C=n*r.x+h*r.y+b;this.minX=Math.min(this.minX,T),this.maxX=Math.max(this.maxX,T),this.minY=Math.min(this.minY,C),this.maxY=Math.max(this.maxY,C)}addQuad(t){let r=this.minX,i=this.minY,n=this.maxX,o=this.maxY,h=t[0],c=t[1];r=h<r?h:r,i=c<i?c:i,n=h>n?h:n,o=c>o?c:o,h=t[2],c=t[3],r=h<r?h:r,i=c<i?c:i,n=h>n?h:n,o=c>o?c:o,h=t[4],c=t[5],r=h<r?h:r,i=c<i?c:i,n=h>n?h:n,o=c>o?c:o,h=t[6],c=t[7],r=h<r?h:r,i=c<i?c:i,n=h>n?h:n,o=c>o?c:o,this.minX=r,this.minY=i,this.maxX=n,this.maxY=o}addFrame(t,r,i,n,o){this.addFrameMatrix(t.worldTransform,r,i,n,o)}addFrameMatrix(t,r,i,n,o){const h=t.a,c=t.b,b=t.c,T=t.d,C=t.tx,x=t.ty;let $=this.minX,I=this.minY,B=this.maxX,U=this.maxY,G=h*r+b*i+C,z=c*r+T*i+x;$=G<$?G:$,I=z<I?z:I,B=G>B?G:B,U=z>U?z:U,G=h*n+b*i+C,z=c*n+T*i+x,$=G<$?G:$,I=z<I?z:I,B=G>B?G:B,U=z>U?z:U,G=h*r+b*o+C,z=c*r+T*o+x,$=G<$?G:$,I=z<I?z:I,B=G>B?G:B,U=z>U?z:U,G=h*n+b*o+C,z=c*n+T*o+x,$=G<$?G:$,I=z<I?z:I,B=G>B?G:B,U=z>U?z:U,this.minX=$,this.minY=I,this.maxX=B,this.maxY=U}addVertexData(t,r,i){let n=this.minX,o=this.minY,h=this.maxX,c=this.maxY;for(let b=r;b<i;b+=2){const T=t[b],C=t[b+1];n=T<n?T:n,o=C<o?C:o,h=T>h?T:h,c=C>c?C:c}this.minX=n,this.minY=o,this.maxX=h,this.maxY=c}addVertices(t,r,i,n){this.addVerticesMatrix(t.worldTransform,r,i,n)}addVerticesMatrix(t,r,i,n,o=0,h=o){const c=t.a,b=t.b,T=t.c,C=t.d,x=t.tx,$=t.ty;let I=this.minX,B=this.minY,U=this.maxX,G=this.maxY;for(let z=i;z<n;z+=2){const J=r[z],Z=r[z+1],it=c*J+T*Z+x,Q=C*Z+b*J+$;I=Math.min(I,it-o),U=Math.max(U,it+o),B=Math.min(B,Q-h),G=Math.max(G,Q+h)}this.minX=I,this.minY=B,this.maxX=U,this.maxY=G}addBounds(t){const r=this.minX,i=this.minY,n=this.maxX,o=this.maxY;this.minX=t.minX<r?t.minX:r,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>n?t.maxX:n,this.maxY=t.maxY>o?t.maxY:o}addBoundsMask(t,r){const i=t.minX>r.minX?t.minX:r.minX,n=t.minY>r.minY?t.minY:r.minY,o=t.maxX<r.maxX?t.maxX:r.maxX,h=t.maxY<r.maxY?t.maxY:r.maxY;if(i<=o&&n<=h){const c=this.minX,b=this.minY,T=this.maxX,C=this.maxY;this.minX=i<c?i:c,this.minY=n<b?n:b,this.maxX=o>T?o:T,this.maxY=h>C?h:C}}addBoundsMatrix(t,r){this.addFrameMatrix(r,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,r){const i=t.minX>r.x?t.minX:r.x,n=t.minY>r.y?t.minY:r.y,o=t.maxX<r.x+r.width?t.maxX:r.x+r.width,h=t.maxY<r.y+r.height?t.maxY:r.y+r.height;if(i<=o&&n<=h){const c=this.minX,b=this.minY,T=this.maxX,C=this.maxY;this.minX=i<c?i:c,this.minY=n<b?n:b,this.maxX=o>T?o:T,this.maxY=h>C?h:C}}pad(t=0,r=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=r,this.maxY+=r)}addFramePad(t,r,i,n,o,h){t-=o,r-=h,i+=o,n+=h,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<r?this.minY:r,this.maxY=this.maxY>n?this.maxY:n}}class fr extends Xi{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new rn,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 Yn,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 r=Object.keys(t);for(let i=0;i<r.length;++i){const n=r[i];Object.defineProperty(fr.prototype,n,Object.getOwnPropertyDescriptor(t,n))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,r){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),r||(this._boundsRect||(this._boundsRect=new Ve),r=this._boundsRect),this._bounds.getRectangle(r)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new Ve),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Yn);const r=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const n=this._bounds,o=this._boundsID;this._bounds=this._localBounds;const h=this.getBounds(!1,t);return this.parent=i,this.transform=r,this._bounds=n,this._bounds.updateID+=this._boundsID-o,h}toGlobal(t,r,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,r)}toLocal(t,r,i,n){return r&&(t=r.toGlobal(t,i,n)),n||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,r=0,i=1,n=1,o=0,h=0,c=0,b=0,T=0){return this.position.x=t,this.position.y=r,this.scale.x=i||1,this.scale.y=n||1,this.rotation=o,this.skew.x=h,this.skew.y=c,this.pivot.x=b,this.pivot.y=T,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new Ll),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*h0}set angle(t){this.transform.rotation=t*l0}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const r=this._mask.isMaskData?this._mask.maskObject:this._mask;r&&(r._maskRefCount--,r._maskRefCount===0&&(r.renderable=!0,r.isMask=!1))}if(this._mask=t,this._mask){const r=this._mask.isMaskData?this._mask.maskObject:this._mask;r&&(r._maskRefCount===0&&(r.renderable=!1,r.isMask=!0),r._maskRefCount++)}}}}class Ll extends fr{constructor(){super(...arguments),this.sortDirty=null}}fr.prototype.displayObjectUpdateTransform=fr.prototype.updateTransform;const T_=new nr;function E_(s,t){return s.zIndex===t.zIndex?s._lastSortedIndex-t._lastSortedIndex:s.zIndex-t.zIndex}const J0=class Iu extends fr{constructor(){super(),this.children=[],this.sortableChildren=Iu.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let r=0;r<t.length;r++)this.addChild(t[r]);else{const r=t[0];r.parent&&r.parent.removeChild(r),r.parent=this,this.sortDirty=!0,r.transform._parentID=-1,this.children.push(r),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",r,this,this.children.length-1),r.emit("added",this)}return t[0]}addChildAt(t,r){if(r<0||r>this.children.length)throw new Error(`${t}addChildAt: The index ${r} 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(r,0,t),this._boundsID++,this.onChildrenChange(r),t.emit("added",this),this.emit("childAdded",t,this,r),t}swapChildren(t,r){if(t===r)return;const i=this.getChildIndex(t),n=this.getChildIndex(r);this.children[i]=r,this.children[n]=t,this.onChildrenChange(i<n?i:n)}getChildIndex(t){const r=this.children.indexOf(t);if(r===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return r}setChildIndex(t,r){if(r<0||r>=this.children.length)throw new Error(`The index ${r} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);ks(this.children,i,1),this.children.splice(r,0,t),this.onChildrenChange(r)}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 r=0;r<t.length;r++)this.removeChild(t[r]);else{const r=t[0],i=this.children.indexOf(r);if(i===-1)return null;r.parent=null,r.transform._parentID=-1,ks(this.children,i,1),this._boundsID++,this.onChildrenChange(i),r.emit("removed",this),this.emit("childRemoved",r,this,i)}return t[0]}removeChildAt(t){const r=this.getChildAt(t);return r.parent=null,r.transform._parentID=-1,ks(this.children,t,1),this._boundsID++,this.onChildrenChange(t),r.emit("removed",this),this.emit("childRemoved",r,this,t),r}removeChildren(t=0,r=this.children.length){const i=t,n=r,o=n-i;let h;if(o>0&&o<=n){h=this.children.splice(i,o);for(let c=0;c<h.length;++c)h[c].parent=null,h[c].transform&&(h[c].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let c=0;c<h.length;++c)h[c].emit("removed",this),this.emit("childRemoved",h[c],this,c);return h}else if(o===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let r=0,i=this.children.length;r<i;++r){const n=this.children[r];n._lastSortedIndex=r,!t&&n.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(E_),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,r=this.children.length;t<r;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const r=this.children[t];if(!(!r.visible||!r.renderable))if(r.calculateBounds(),r._mask){const i=r._mask.isMaskData?r._mask.maskObject:r._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(r._bounds,i._bounds)):this._bounds.addBounds(r._bounds)}else r.filterArea?this._bounds.addBoundsArea(r._bounds,r.filterArea):this._bounds.addBounds(r._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,r=!1){const i=super.getLocalBounds(t);if(!r)for(let n=0,o=this.children.length;n<o;++n){const h=this.children[n];h.visible&&h.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const r=t.renderTexture.sourceFrame;if(!(r.width>0&&r.height>0))return;let i,n;this.cullArea?(i=this.cullArea,n=this.worldTransform):this._render!==Iu.prototype._render&&(i=this.getBounds(!0));const o=t.projection.transform;if(o&&(n?(n=T_.copyFrom(n),n.prepend(o)):n=o),i&&r.intersects(i,n))this._render(t);else if(this.cullArea)return;for(let h=0,c=this.children.length;h<c;++h){const b=this.children[h],T=b.cullable;b.cullable=T||!this.cullArea,b.render(t),b.cullable=T}}render(t){var r;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(r=this.filters)!=null&&r.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,n=this.children.length;i<n;++i)this.children[i].render(t)}}renderAdvanced(t){var o,h,c;const r=this.filters,i=this._mask;if(r){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let b=0;b<r.length;b++)r[b].enabled&&this._enabledFilters.push(r[b])}const n=r&&((o=this._enabledFilters)==null?void 0:o.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==br.NONE));if(n&&t.batch.flush(),r&&((h=this._enabledFilters)!=null&&h.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let b=0,T=this.children.length;b<T;++b)this.children[b].render(t)}n&&t.batch.flush(),i&&t.mask.pop(this),r&&((c=this._enabledFilters)!=null&&c.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const r=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(r)for(let n=0;n<i.length;++n)i[n].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const r=this.getLocalBounds().width;r!==0?this.scale.x=t/r:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const r=this.getLocalBounds().height;r!==0?this.scale.y=t/r:this.scale.y=1,this._height=t}};J0.defaultSortableChildren=!1;let Zr=J0;Zr.prototype.containerUpdateTransform=Zr.prototype.updateTransform,Object.defineProperties(ue,{SORTABLE_CHILDREN:{get(){return Zr.defaultSortableChildren},set(s){Oe("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Zr.defaultSortableChildren=s}}});const jn=new He,C_=new Uint16Array([0,1,2,0,2,3]);class us extends Zr{constructor(t){super(),this._anchor=new $i(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new rr(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=De.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||ne.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=C_,this.pluginName="batch",this.isSprite=!0,this._roundPixels=ue.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=hs(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=hs(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const r=this.transform.worldTransform,i=r.a,n=r.b,o=r.c,h=r.d,c=r.tx,b=r.ty,T=this.vertexData,C=t.trim,x=t.orig,$=this._anchor;let I=0,B=0,U=0,G=0;if(C?(B=C.x-$._x*x.width,I=B+C.width,G=C.y-$._y*x.height,U=G+C.height):(B=-$._x*x.width,I=B+x.width,G=-$._y*x.height,U=G+x.height),T[0]=i*B+o*G+c,T[1]=h*G+n*B+b,T[2]=i*I+o*G+c,T[3]=h*G+n*I+b,T[4]=i*I+o*U+c,T[5]=h*U+n*I+b,T[6]=i*B+o*U+c,T[7]=h*U+n*B+b,this._roundPixels){const z=ue.RESOLUTION;for(let J=0;J<T.length;++J)T[J]=Math.round(T[J]*z)/z}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,r=this.vertexTrimmedData,i=t.orig,n=this._anchor,o=this.transform.worldTransform,h=o.a,c=o.b,b=o.c,T=o.d,C=o.tx,x=o.ty,$=-n._x*i.width,I=$+i.width,B=-n._y*i.height,U=B+i.height;if(r[0]=h*$+b*B+C,r[1]=T*B+c*$+x,r[2]=h*I+b*B+C,r[3]=T*B+c*I+x,r[4]=h*I+b*U+C,r[5]=T*U+c*I+x,r[6]=h*$+b*U+C,r[7]=T*U+c*$+x,this._roundPixels){const G=ue.RESOLUTION;for(let z=0;z<r.length;++z)r[z]=Math.round(r[z]*G)/G}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,r=this._texture.orig;!t||t.width===r.width&&t.height===r.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Yn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new Ve),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,jn);const r=this._texture.orig.width,i=this._texture.orig.height,n=-r*this.anchor.x;let o=0;return jn.x>=n&&jn.x<n+r&&(o=-i*this.anchor.y,jn.y>=o&&jn.y<o+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const r=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!r)}this._texture=null}static from(t,r){const i=t instanceof ne?t:ne.from(t,r);return new us(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const r=hs(this.scale.x)||1;this.scale.x=r*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const r=hs(this.scale.y)||1;this.scale.y=r*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||ne.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const tf=new nr;fr.prototype._cacheAsBitmap=!1,fr.prototype._cacheData=null,fr.prototype._cacheAsBitmapResolution=null,fr.prototype._cacheAsBitmapMultisample=null;class S_{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(fr.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(s){s!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(s){s!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(s){if(this._cacheAsBitmap===s)return;this._cacheAsBitmap=s;let t;s?(this._cacheData||(this._cacheData=new S_),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)}}}),fr.prototype._renderCached=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(s),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(s))},fr.prototype._initCachedDisplayObject=function(s){var $,I;if(($=this._cacheData)!=null&&$.sprite)return;const t=this.alpha;this.alpha=1,s.batch.flush();const r=this.getLocalBounds(new Ve,!0);if((I=this.filters)!=null&&I.length){const B=this.filters[0].padding;r.pad(B)}const i=this.cacheAsBitmapResolution||s.resolution;r.ceil(i),r.width=Math.max(r.width,1/i),r.height=Math.max(r.height,1/i);const n=s.renderTexture.current,o=s.renderTexture.sourceFrame.clone(),h=s.renderTexture.destinationFrame.clone(),c=s.projection.transform,b=As.create({width:r.width,height:r.height,resolution:i,multisample:this.cacheAsBitmapMultisample??s.multisample}),T=`cacheAsBitmap_${vs()}`;this._cacheData.textureCacheId=T,Ge.addToCache(b.baseTexture,T),ne.addToCache(b,T);const C=this.transform.localTransform.copyTo(tf).invert().translate(-r.x,-r.y);this.render=this._cacheData.originalRender,s.render(this,{renderTexture:b,clear:!0,transform:C,skipUpdateTransform:!1}),s.framebuffer.blit(),s.projection.transform=c,s.renderTexture.bind(n,o,h),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const x=new us(b);x.transform.worldTransform=this.transform.worldTransform,x.anchor.x=-(r.x/r.width),x.anchor.y=-(r.y/r.height),x.alpha=t,x._bounds=this._bounds,this._cacheData.sprite=x,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=x.containsPoint.bind(x)},fr.prototype._renderCachedCanvas=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(s),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(s))},fr.prototype._initCachedDisplayObjectCanvas=function(s){var C;if((C=this._cacheData)!=null&&C.sprite)return;const t=this.getLocalBounds(new Ve,!0),r=this.alpha;this.alpha=1;const i=s.canvasContext.activeContext,n=s._projTransform,o=this.cacheAsBitmapResolution||s.resolution;t.ceil(o),t.width=Math.max(t.width,1/o),t.height=Math.max(t.height,1/o);const h=As.create({width:t.width,height:t.height,resolution:o}),c=`cacheAsBitmap_${vs()}`;this._cacheData.textureCacheId=c,Ge.addToCache(h.baseTexture,c),ne.addToCache(h,c);const b=tf;this.transform.localTransform.copyTo(b),b.invert(),b.tx-=t.x,b.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,s.render(this,{renderTexture:h,clear:!0,transform:b,skipUpdateTransform:!1}),s.canvasContext.activeContext=i,s._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=r;const T=new us(h);T.transform.worldTransform=this.transform.worldTransform,T.anchor.x=-(t.x/t.width),T.anchor.y=-(t.y/t.height),T.alpha=r,T._bounds=this._bounds,this._cacheData.sprite=T,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=s._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=T.containsPoint.bind(T)},fr.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},fr.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},fr.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,Ge.removeFromCache(this._cacheData.textureCacheId),ne.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},fr.prototype._cacheAsBitmapDestroy=function(s){this.cacheAsBitmap=!1,this.destroy(s)},fr.prototype.name=null,Zr.prototype.getChildByName=function(s,t){for(let r=0,i=this.children.length;r<i;r++)if(this.children[r].name===s)return this.children[r];if(t)for(let r=0,i=this.children.length;r<i;r++){const n=this.children[r];if(!n.getChildByName)continue;const o=n.getChildByName(s,!0);if(o)return o}return null},fr.prototype.getGlobalPosition=function(s=new He,t=!1){return this.parent?this.parent.toGlobal(this.position,s,t):(s.x=this.position.x,s.y=this.position.y),s};var P_=`varying vec2 vTextureCoord;
526
+ `;const Iu=om,Qa=hm;class to{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=St.HIGH?this.multisample=St.HIGH:e>=St.MEDIUM?this.multisample=St.MEDIUM:e>=St.LOW?this.multisample=St.LOW:this.multisample=St.NONE}destroy(){}}to.extension={type:$.RendererSystem,name:"_multisample"},Q.add(to);class lm{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class eo{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:r,CONTEXT_UID:n}=this;i=i||0;const a=t._glBuffers[n]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,a.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),i&&(e||r.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new lm(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}eo.extension={type:$.RendererSystem,name:"buffer"},Q.add(eo);class io{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let r,n,a,o;if(e&&(r=e.renderTexture,n=e.clear,a=e.transform,o=e.skipUpdateTransform),this.renderingToScreen=!r,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=a,!i.context.isLost){if(r||(this.lastObjectRendered=t),!o){const h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}i.renderTexture.bind(r),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),r&&(e.blit&&i.framebuffer.blit(),r.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}io.extension={type:$.RendererSystem,name:"objectRenderer"},Q.add(io);const Ss=class fh extends Au{constructor(t){super(),this.type=bn.WEBGL,t=Object.assign({},q.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Qt({projectionMatrix:new vt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:fh.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ot("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=fh.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:xl()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ot("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ot("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ot("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ot("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ot("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ot("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ot("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ot("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Ss.extension={type:$.Renderer,priority:1},Ss.__plugins={},Ss.__systems={};let Ps=Ss;Q.handleByMap($.RendererPlugin,Ps.__plugins),Q.handleByMap($.RendererSystem,Ps.__systems),Q.add(Ps);class ro extends Di{constructor(t,e){const{width:i,height:r}=e||{};super(i,r),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const a=new lt;this.items.push(a),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof Di?this.addResourceAt(t[i],i):this.addResourceAt(Ca(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class Ru extends ro{constructor(t,e){const{width:i,height:r}=e||{};let n,a;Array.isArray(t)?(n=t,a=t.length):a=t,super(a,{width:i,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=ui.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:r,itemDirtyIds:n,items:a}=this,{gl:o}=t;i.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,r,0,e.format,i.type,null);for(let h=0;h<r;h++){const l=a[h];n[h]<l.dirtyId&&(n[h]=l.dirtyId,l.valid&&o.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,i.type,l.resource.source))}return!0}}class Du extends Se{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Fu=class Qr extends ro{constructor(t,e){const{width:i,height:r,autoLoad:n,linkBaseTexture:a}=e||{};if(t&&t.length!==Qr.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:r});for(let o=0;o<Qr.SIDES;o++)this.items[o].target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+o;this.linkBaseTexture=a!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=ui.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const r=this.itemDirtyIds;for(let n=0;n<Qr.SIDES;n++){const a=this.items[n];(r[n]<a.dirtyId||i.dirtyId<e.dirtyId)&&(a.valid&&a.resource?(a.resource.upload(t,a,i),r[n]=a.dirtyId):r[n]<-1&&(t.gl.texImage2D(a.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),r[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Qr.SIDES}};Fu.SIDES=6;let Bu=Fu;class vi extends Se{constructor(t,e){e=e||{};let i,r,n;typeof t=="string"?(i=vi.EMPTY,r=t,n=!0):(i=t,r=null,n=!1),super(i),this.url=r,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,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 i=await q.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const r=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(r,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Nt.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return vi._EMPTY=vi._EMPTY??q.ADAPTER.createCanvas(0,0),vi._EMPTY}}const so=class _n extends Se{constructor(t,e){e=e||{},super(q.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},_n.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 t=new Image;Se.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let r=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(r=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),r=Math.round(r),n=Math.round(n);const a=this.source;a.width=r,a.height=n,a._pixiId=`canvas_${qe()}`,a.getContext("2d").drawImage(t,0,0,e,i,0,0,r,n),this._resolve(),this._resolve=null}}static getSize(t){const e=_n.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&_n.SVG_XML.test(t)}};so.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,so.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Ms=so;class um extends Se{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const no=class ph extends Se{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const r=t[0].src||t[0];Se.crossOrigin(i,r,e.crossorigin);for(let n=0;n<t.length;++n){const a=document.createElement("source");let{src:o,mime:h}=t[n];if(o=o||t[n],o.startsWith("data:"))h=o.slice(5,o.indexOf(";"));else if(!o.startsWith("blob:")){const l=o.split("?").shift().toLowerCase(),u=l.slice(l.lastIndexOf(".")+1);h=h||ph.MIME_TYPES[u]||`video/${u}`}a.src=o,h&&(a.type=h),i.appendChild(a)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=Pt.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Pt.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||ph.TYPES.includes(e)}};no.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],no.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ao=no;cs.push(vi,La,Du,ao,um,Ms,ur,Bu,Ru);class cm{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new Wt("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}const dm="7.4.3";class Cr{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?ut.EMPTY:(t=t||new ut(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:i,b:r,c:n,d:a,tx:o,ty:h}=t,l=i*e.x+n*e.y+o,u=r*e.x+a*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(t){let e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,a=t[0],o=t[1];e=a<e?a:e,i=o<i?o:i,r=a>r?a:r,n=o>n?o:n,a=t[2],o=t[3],e=a<e?a:e,i=o<i?o:i,r=a>r?a:r,n=o>n?o:n,a=t[4],o=t[5],e=a<e?a:e,i=o<i?o:i,r=a>r?a:r,n=o>n?o:n,a=t[6],o=t[7],e=a<e?a:e,i=o<i?o:i,r=a>r?a:r,n=o>n?o:n,this.minX=e,this.minY=i,this.maxX=r,this.maxY=n}addFrame(t,e,i,r,n){this.addFrameMatrix(t.worldTransform,e,i,r,n)}addFrameMatrix(t,e,i,r,n){const a=t.a,o=t.b,h=t.c,l=t.d,u=t.tx,c=t.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,m=a*e+h*i+u,_=o*e+l*i+c;d=m<d?m:d,f=_<f?_:f,p=m>p?m:p,g=_>g?_:g,m=a*r+h*i+u,_=o*r+l*i+c,d=m<d?m:d,f=_<f?_:f,p=m>p?m:p,g=_>g?_:g,m=a*e+h*n+u,_=o*e+l*n+c,d=m<d?m:d,f=_<f?_:f,p=m>p?m:p,g=_>g?_:g,m=a*r+h*n+u,_=o*r+l*n+c,d=m<d?m:d,f=_<f?_:f,p=m>p?m:p,g=_>g?_:g,this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addVertexData(t,e,i){let r=this.minX,n=this.minY,a=this.maxX,o=this.maxY;for(let h=e;h<i;h+=2){const l=t[h],u=t[h+1];r=l<r?l:r,n=u<n?u:n,a=l>a?l:a,o=u>o?u:o}this.minX=r,this.minY=n,this.maxX=a,this.maxY=o}addVertices(t,e,i,r){this.addVerticesMatrix(t.worldTransform,e,i,r)}addVerticesMatrix(t,e,i,r,n=0,a=n){const o=t.a,h=t.b,l=t.c,u=t.d,c=t.tx,d=t.ty;let f=this.minX,p=this.minY,g=this.maxX,m=this.maxY;for(let _=i;_<r;_+=2){const b=e[_],y=e[_+1],E=o*b+l*y+c,v=u*y+h*b+d;f=Math.min(f,E-n),g=Math.max(g,E+n),p=Math.min(p,v-a),m=Math.max(m,v+a)}this.minX=f,this.minY=p,this.maxX=g,this.maxY=m}addBounds(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>r?t.maxX:r,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,a=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&r<=a){const o=this.minX,h=this.minY,l=this.maxX,u=this.maxY;this.minX=i<o?i:o,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=a>u?a:u}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,a=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&r<=a){const o=this.minX,h=this.minY,l=this.maxX,u=this.maxY;this.minX=i<o?i:o,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=a>u?a:u}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,r,n,a){t-=n,e-=a,i+=n,r+=a,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>r?this.maxY:r}}class Et extends Ee{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Fi,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 Cr,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 i=0;i<e.length;++i){const r=e[i];Object.defineProperty(Et.prototype,r,Object.getOwnPropertyDescriptor(t,r))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new ut),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new ut),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Cr);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const a=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=r,this._bounds.updateID+=this._boundsID-n,a}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,r){return e&&(t=e.toGlobal(t,i,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,r=1,n=0,a=0,o=0,h=0,l=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=r||1,this.rotation=n,this.skew.x=a,this.skew.y=o,this.pivot.x=h,this.pivot.y=l,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new oo),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*zl}set angle(t){this.transform.rotation=t*Wl}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class oo extends Et{constructor(){super(...arguments),this.sortDirty=null}}Et.prototype.displayObjectUpdateTransform=Et.prototype.updateTransform;const fm=new vt;function pm(s,t){return s.zIndex===t.zIndex?s._lastSortedIndex-t._lastSortedIndex:s.zIndex-t.zIndex}const Lu=class mh extends Et{constructor(){super(),this.children=[],this.sortableChildren=mh.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),r=this.getChildIndex(e);this.children[i]=e,this.children[r]=t,this.onChildrenChange(i<r?i:r)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);di(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,di(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,di(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,r=e,n=r-i;let a;if(n>0&&n<=r){a=this.children.splice(i,n);for(let o=0;o<a.length;++o)a[o].parent=null,a[o].transform&&(a[o].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let o=0;o<a.length;++o)a[o].emit("removed",this),this.emit("childRemoved",a[o],this,o);return a}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const r=this.children[e];r._lastSortedIndex=e,!t&&r.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(pm),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let r=0,n=this.children.length;r<n;++r){const a=this.children[r];a.visible&&a.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,r;this.cullArea?(i=this.cullArea,r=this.worldTransform):this._render!==mh.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(r?(r=fm.copyFrom(r),r.prepend(n)):r=n),i&&e.intersects(i,r))this._render(t);else if(this.cullArea)return;for(let a=0,o=this.children.length;a<o;++a){const h=this.children[a],l=h.cullable;h.cullable=l||!this.cullArea,h.render(t),h.cullable=l}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,r=this.children.length;i<r;++i)this.children[i].render(t)}}renderAdvanced(t){var n,a,o;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let h=0;h<e.length;h++)e[h].enabled&&this._enabledFilters.push(e[h])}const r=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==It.NONE));if(r&&t.batch.flush(),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let h=0,l=this.children.length;h<l;++h)this.children[h].render(t)}r&&t.batch.flush(),i&&t.mask.pop(this),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let r=0;r<i.length;++r)i[r].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};Lu.defaultSortableChildren=!1;let Vt=Lu;Vt.prototype.containerUpdateTransform=Vt.prototype.updateTransform,Object.defineProperties(q,{SORTABLE_CHILDREN:{get(){return Vt.defaultSortableChildren},set(s){ot("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Vt.defaultSortableChildren=s}}});const Ar=new ft,mm=new Uint16Array([0,1,2,0,2,3]);class Ge extends Vt{constructor(t){super(),this._anchor=new pe(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new gt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=nt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||j.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=mm,this.pluginName="batch",this.isSprite=!0,this._roundPixels=q.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Ne(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Ne(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,r=e.b,n=e.c,a=e.d,o=e.tx,h=e.ty,l=this.vertexData,u=t.trim,c=t.orig,d=this._anchor;let f=0,p=0,g=0,m=0;if(u?(p=u.x-d._x*c.width,f=p+u.width,m=u.y-d._y*c.height,g=m+u.height):(p=-d._x*c.width,f=p+c.width,m=-d._y*c.height,g=m+c.height),l[0]=i*p+n*m+o,l[1]=a*m+r*p+h,l[2]=i*f+n*m+o,l[3]=a*m+r*f+h,l[4]=i*f+n*g+o,l[5]=a*g+r*f+h,l[6]=i*p+n*g+o,l[7]=a*g+r*p+h,this._roundPixels){const _=q.RESOLUTION;for(let b=0;b<l.length;++b)l[b]=Math.round(l[b]*_)/_}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,r=this._anchor,n=this.transform.worldTransform,a=n.a,o=n.b,h=n.c,l=n.d,u=n.tx,c=n.ty,d=-r._x*i.width,f=d+i.width,p=-r._y*i.height,g=p+i.height;if(e[0]=a*d+h*p+u,e[1]=l*p+o*d+c,e[2]=a*f+h*p+u,e[3]=l*p+o*f+c,e[4]=a*f+h*g+u,e[5]=l*g+o*f+c,e[6]=a*d+h*g+u,e[7]=l*g+o*d+c,this._roundPixels){const m=q.RESOLUTION;for(let _=0;_<e.length;++_)e[_]=Math.round(e[_]*m)/m}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Cr),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new ut),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Ar);const e=this._texture.orig.width,i=this._texture.orig.height,r=-e*this.anchor.x;let n=0;return Ar.x>=r&&Ar.x<r+e&&(n=-i*this.anchor.y,Ar.y>=n&&Ar.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof j?t:j.from(t,e);return new Ge(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=Ne(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=Ne(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||j.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Ou=new vt;Et.prototype._cacheAsBitmap=!1,Et.prototype._cacheData=null,Et.prototype._cacheAsBitmapResolution=null,Et.prototype._cacheAsBitmapMultisample=null;class gm{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(Et.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(s){s!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(s){s!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(s){if(this._cacheAsBitmap===s)return;this._cacheAsBitmap=s;let t;s?(this._cacheData||(this._cacheData=new gm),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)}}}),Et.prototype._renderCached=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(s),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(s))},Et.prototype._initCachedDisplayObject=function(s){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,s.batch.flush();const e=this.getLocalBounds(new ut,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}const i=this.cacheAsBitmapResolution||s.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const r=s.renderTexture.current,n=s.renderTexture.sourceFrame.clone(),a=s.renderTexture.destinationFrame.clone(),o=s.projection.transform,h=Je.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??s.multisample}),l=`cacheAsBitmap_${qe()}`;this._cacheData.textureCacheId=l,lt.addToCache(h.baseTexture,l),j.addToCache(h,l);const u=this.transform.localTransform.copyTo(Ou).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,s.render(this,{renderTexture:h,clear:!0,transform:u,skipUpdateTransform:!1}),s.framebuffer.blit(),s.projection.transform=o,s.renderTexture.bind(r,n,a),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const c=new Ge(h);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},Et.prototype._renderCachedCanvas=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(s),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(s))},Et.prototype._initCachedDisplayObjectCanvas=function(s){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new ut,!0),e=this.alpha;this.alpha=1;const i=s.canvasContext.activeContext,r=s._projTransform,n=this.cacheAsBitmapResolution||s.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const a=Je.create({width:t.width,height:t.height,resolution:n}),o=`cacheAsBitmap_${qe()}`;this._cacheData.textureCacheId=o,lt.addToCache(a.baseTexture,o),j.addToCache(a,o);const h=Ou;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,s.render(this,{renderTexture:a,clear:!0,transform:h,skipUpdateTransform:!1}),s.canvasContext.activeContext=i,s._projTransform=r,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const l=new Ge(a);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-(t.x/t.width),l.anchor.y=-(t.y/t.height),l.alpha=e,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=s._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)},Et.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Et.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Et.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,lt.removeFromCache(this._cacheData.textureCacheId),j.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Et.prototype._cacheAsBitmapDestroy=function(s){this.cacheAsBitmap=!1,this.destroy(s)},Et.prototype.name=null,Vt.prototype.getChildByName=function(s,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===s)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const r=this.children[e];if(!r.getChildByName)continue;const n=r.getChildByName(s,!0);if(n)return n}return null},Et.prototype.getGlobalPosition=function(s=new ft,t=!1){return this.parent?this.parent.toGlobal(this.position,s,t):(s.x=this.position.x,s.y=this.position.y),s};var _m=`varying vec2 vTextureCoord;
569
527
 
570
528
  uniform sampler2D uSampler;
571
529
  uniform float uAlpha;
@@ -574,9 +532,9 @@ void main(void)
574
532
  {
575
533
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
576
534
  }
577
- `;class ef extends Gr{constructor(t=1){super(j0,P_,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const $_={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},M_=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
578
- `);function D_(s){const t=$_[s],r=t.length;let i=M_,n="";const o="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let h;for(let c=0;c<s;c++){let b=o.replace("%index%",c.toString());h=c,c>=r&&(h=s-c-1),b=b.replace("%value%",t[h].toString()),n+=b,n+=`
579
- `}return i=i.replace("%blur%",n),i=i.replace("%size%",s.toString()),i}const R_=`
535
+ `;class ku extends kt{constructor(t=1){super(Iu,_m,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const ym={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},vm=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
536
+ `);function xm(s){const t=ym[s],e=t.length;let i=vm,r="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let a;for(let o=0;o<s;o++){let h=n.replace("%index%",o.toString());a=o,o>=e&&(a=s-o-1),h=h.replace("%value%",t[a].toString()),r+=h,r+=`
537
+ `}return i=i.replace("%blur%",r),i=i.replace("%size%",s.toString()),i}const bm=`
580
538
  attribute vec2 aVertexPosition;
581
539
 
582
540
  uniform mat3 projectionMatrix;
@@ -606,8 +564,8 @@ void main(void)
606
564
 
607
565
  vec2 textureCoord = filterTextureCoord();
608
566
  %blur%
609
- }`;function I_(s,t){const r=Math.ceil(s/2);let i=R_,n="",o;t?o="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":o="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let h=0;h<s;h++){let c=o.replace("%index%",h.toString());c=c.replace("%sampleIndex%",`${h-(r-1)}.0`),n+=c,n+=`
610
- `}return i=i.replace("%blur%",n),i=i.replace("%size%",s.toString()),i}class ha extends Gr{constructor(t,r=8,i=4,n=Gr.defaultResolution,o=5){const h=I_(o,t),c=D_(o);super(h,c),this.horizontal=t,this.resolution=n,this._quality=0,this.quality=i,this.blur=r}apply(t,r,i,n){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/r.width):this.uniforms.strength=1/i.height*(i.height/r.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/r.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/r.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,r,i,n);else{const o=t.getFilterTexture(),h=t.renderer;let c=r,b=o;this.state.blend=!1,t.applyFilter(this,c,b,Ti.CLEAR);for(let T=1;T<this.passes-1;T++){t.bindAndClear(c,Ti.BLIT),this.uniforms.uSampler=b;const C=b;b=c,c=C,h.shader.bind(this),h.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,b,i,n),t.returnFilterTexture(o)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class rf extends Gr{constructor(t=8,r=4,i=Gr.defaultResolution,n=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new ha(!0,t,r,i,n),this.blurYFilter=new ha(!1,t,r,i,n),this.resolution=i,this.quality=r,this.blur=t,this.repeatEdgePixels=!1}apply(t,r,i,n){const o=Math.abs(this.blurXFilter.strength),h=Math.abs(this.blurYFilter.strength);if(o&&h){const c=t.getFilterTexture();this.blurXFilter.apply(t,r,c,Ti.CLEAR),this.blurYFilter.apply(t,c,i,n),t.returnFilterTexture(c)}else h?this.blurYFilter.apply(t,r,i,n):this.blurXFilter.apply(t,r,i,n)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var F_=`varying vec2 vTextureCoord;
567
+ }`;function Tm(s,t){const e=Math.ceil(s/2);let i=bm,r="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let a=0;a<s;a++){let o=n.replace("%index%",a.toString());o=o.replace("%sampleIndex%",`${a-(e-1)}.0`),r+=o,r+=`
568
+ `}return i=i.replace("%blur%",r),i=i.replace("%size%",s.toString()),i}class Is extends kt{constructor(t,e=8,i=4,r=kt.defaultResolution,n=5){const a=Tm(n,t),o=xm(n);super(a,o),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,this.passes===1)t.applyFilter(this,e,i,r);else{const n=t.getFilterTexture(),a=t.renderer;let o=e,h=n;this.state.blend=!1,t.applyFilter(this,o,h,le.CLEAR);for(let l=1;l<this.passes-1;l++){t.bindAndClear(o,le.BLIT),this.uniforms.uSampler=h;const u=h;h=o,o=u,a.shader.bind(this),a.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,h,i,r),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class Nu extends kt{constructor(t=8,e=4,i=kt.defaultResolution,r=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Is(!0,t,e,i,r),this.blurYFilter=new Is(!1,t,e,i,r),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,r){const n=Math.abs(this.blurXFilter.strength),a=Math.abs(this.blurYFilter.strength);if(n&&a){const o=t.getFilterTexture();this.blurXFilter.apply(t,e,o,le.CLEAR),this.blurYFilter.apply(t,o,i,r),t.returnFilterTexture(o)}else a?this.blurYFilter.apply(t,e,i,r):this.blurXFilter.apply(t,e,i,r)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var Em=`varying vec2 vTextureCoord;
611
569
  uniform sampler2D uSampler;
612
570
  uniform float m[20];
613
571
  uniform float uAlpha;
@@ -659,7 +617,7 @@ void main(void)
659
617
 
660
618
  gl_FragColor = vec4(rgb, result.a);
661
619
  }
662
- `;class la extends Gr{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(Sl,F_,t),this.alpha=1}_loadMatrix(t,r=!1){let i=t;r&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,r,i){return t[0]=r[0]*i[0]+r[1]*i[5]+r[2]*i[10]+r[3]*i[15],t[1]=r[0]*i[1]+r[1]*i[6]+r[2]*i[11]+r[3]*i[16],t[2]=r[0]*i[2]+r[1]*i[7]+r[2]*i[12]+r[3]*i[17],t[3]=r[0]*i[3]+r[1]*i[8]+r[2]*i[13]+r[3]*i[18],t[4]=r[0]*i[4]+r[1]*i[9]+r[2]*i[14]+r[3]*i[19]+r[4],t[5]=r[5]*i[0]+r[6]*i[5]+r[7]*i[10]+r[8]*i[15],t[6]=r[5]*i[1]+r[6]*i[6]+r[7]*i[11]+r[8]*i[16],t[7]=r[5]*i[2]+r[6]*i[7]+r[7]*i[12]+r[8]*i[17],t[8]=r[5]*i[3]+r[6]*i[8]+r[7]*i[13]+r[8]*i[18],t[9]=r[5]*i[4]+r[6]*i[9]+r[7]*i[14]+r[8]*i[19]+r[9],t[10]=r[10]*i[0]+r[11]*i[5]+r[12]*i[10]+r[13]*i[15],t[11]=r[10]*i[1]+r[11]*i[6]+r[12]*i[11]+r[13]*i[16],t[12]=r[10]*i[2]+r[11]*i[7]+r[12]*i[12]+r[13]*i[17],t[13]=r[10]*i[3]+r[11]*i[8]+r[12]*i[13]+r[13]*i[18],t[14]=r[10]*i[4]+r[11]*i[9]+r[12]*i[14]+r[13]*i[19]+r[14],t[15]=r[15]*i[0]+r[16]*i[5]+r[17]*i[10]+r[18]*i[15],t[16]=r[15]*i[1]+r[16]*i[6]+r[17]*i[11]+r[18]*i[16],t[17]=r[15]*i[2]+r[16]*i[7]+r[17]*i[12]+r[18]*i[17],t[18]=r[15]*i[3]+r[16]*i[8]+r[17]*i[13]+r[18]*i[18],t[19]=r[15]*i[4]+r[16]*i[9]+r[17]*i[14]+r[18]*i[19]+r[19],t}_colorMatrix(t){const r=new Float32Array(t);return r[4]/=255,r[9]/=255,r[14]/=255,r[19]/=255,r}brightness(t,r){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,r)}tint(t,r){const[i,n,o]=rr.shared.setValue(t).toArray(),h=[i,0,0,0,0,0,n,0,0,0,0,0,o,0,0,0,0,0,1,0];this._loadMatrix(h,r)}greyscale(t,r){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,r)}blackAndWhite(t){const r=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(r,t)}hue(t,r){t=(t||0)/180*Math.PI;const i=Math.cos(t),n=Math.sin(t),o=Math.sqrt,h=1/3,c=o(h),b=i+(1-i)*h,T=h*(1-i)-c*n,C=h*(1-i)+c*n,x=h*(1-i)+c*n,$=i+h*(1-i),I=h*(1-i)-c*n,B=h*(1-i)-c*n,U=h*(1-i)+c*n,G=i+h*(1-i),z=[b,T,C,0,0,x,$,I,0,0,B,U,G,0,0,0,0,0,1,0];this._loadMatrix(z,r)}contrast(t,r){const i=(t||0)+1,n=-.5*(i-1),o=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(o,r)}saturate(t=0,r){const i=t*2/3+1,n=(i-1)*-.5,o=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(o,r)}desaturate(){this.saturate(-1)}negative(t){const r=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(r,t)}sepia(t){const r=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(r,t)}technicolor(t){const r=[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(r,t)}polaroid(t){const r=[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(r,t)}toBGR(t){const r=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(r,t)}kodachrome(t){const r=[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(r,t)}browni(t){const r=[.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(r,t)}vintage(t){const r=[.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(r,t)}colorTone(t,r,i,n,o){t=t||.2,r=r||.15,i=i||16770432,n=n||3375104;const h=rr.shared,[c,b,T]=h.setValue(i).toArray(),[C,x,$]=h.setValue(n).toArray(),I=[.3,.59,.11,0,0,c,b,T,t,0,C,x,$,r,0,c-C,b-x,T-$,0,0];this._loadMatrix(I,o)}night(t,r){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,r)}predator(t,r){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,r)}lsd(t){const r=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(r,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}}la.prototype.grayscale=la.prototype.greyscale;var L_=`varying vec2 vFilterCoord;
620
+ `;class Rs extends kt{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(Qa,Em,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,n]=gt.shared.setValue(t).toArray(),a=[i,0,0,0,0,0,r,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(a,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){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 i=Math.cos(t),r=Math.sin(t),n=Math.sqrt,a=1/3,o=n(a),h=i+(1-i)*a,l=a*(1-i)-o*r,u=a*(1-i)+o*r,c=a*(1-i)+o*r,d=i+a*(1-i),f=a*(1-i)-o*r,p=a*(1-i)-o*r,g=a*(1-i)+o*r,m=i+a*(1-i),_=[h,l,u,0,0,c,d,f,0,0,p,g,m,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const i=(t||0)+1,r=-.5*(i-1),n=[i,0,0,0,r,0,i,0,0,r,0,0,i,0,r,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,r=(i-1)*-.5,n=[i,r,r,0,0,r,i,r,0,0,r,r,i,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,i,r,n){t=t||.2,e=e||.15,i=i||16770432,r=r||3375104;const a=gt.shared,[o,h,l]=a.setValue(i).toArray(),[u,c,d]=a.setValue(r).toArray(),f=[.3,.59,.11,0,0,o,h,l,t,0,u,c,d,e,0,o-u,h-c,l-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,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){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}}Rs.prototype.grayscale=Rs.prototype.greyscale;var wm=`varying vec2 vFilterCoord;
663
621
  varying vec2 vTextureCoord;
664
622
 
665
623
  uniform vec2 scale;
@@ -679,7 +637,7 @@ void main(void)
679
637
 
680
638
  gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
681
639
  }
682
- `,k_=`attribute vec2 aVertexPosition;
640
+ `,Cm=`attribute vec2 aVertexPosition;
683
641
 
684
642
  uniform mat3 projectionMatrix;
685
643
  uniform mat3 filterMatrix;
@@ -708,7 +666,7 @@ void main(void)
708
666
  vTextureCoord = filterTextureCoord();
709
667
  vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
710
668
  }
711
- `;class sf extends Gr{constructor(t,r){const i=new nr;t.renderable=!1,super(k_,L_,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,r==null&&(r=20),this.scale=new He(r,r)}apply(t,r,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 o=this.maskSprite.worldTransform,h=Math.sqrt(o.a*o.a+o.b*o.b),c=Math.sqrt(o.c*o.c+o.d*o.d);h!==0&&c!==0&&(this.uniforms.rotation[0]=o.a/h,this.uniforms.rotation[1]=o.b/h,this.uniforms.rotation[2]=o.c/c,this.uniforms.rotation[3]=o.d/c),t.applyFilter(this,r,i,n)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var B_=`varying vec2 v_rgbNW;
669
+ `;class Uu extends kt{constructor(t,e){const i=new vt;t.renderable=!1,super(Cm,wm,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new ft(e,e)}apply(t,e,i,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,a=Math.sqrt(n.a*n.a+n.b*n.b),o=Math.sqrt(n.c*n.c+n.d*n.d);a!==0&&o!==0&&(this.uniforms.rotation[0]=n.a/a,this.uniforms.rotation[1]=n.b/a,this.uniforms.rotation[2]=n.c/o,this.uniforms.rotation[3]=n.d/o),t.applyFilter(this,e,i,r)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var Am=`varying vec2 v_rgbNW;
712
670
  varying vec2 v_rgbNE;
713
671
  varying vec2 v_rgbSW;
714
672
  varying vec2 v_rgbSE;
@@ -829,7 +787,7 @@ void main() {
829
787
 
830
788
  gl_FragColor = color;
831
789
  }
832
- `,O_=`
790
+ `,Sm=`
833
791
  attribute vec2 aVertexPosition;
834
792
 
835
793
  uniform mat3 projectionMatrix;
@@ -871,7 +829,7 @@ void main(void) {
871
829
 
872
830
  texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
873
831
  }
874
- `;class nf extends Gr{constructor(){super(O_,B_)}}var N_=`precision highp float;
832
+ `;class Gu extends kt{constructor(){super(Sm,Am)}}var Pm=`precision highp float;
875
833
 
876
834
  varying vec2 vTextureCoord;
877
835
  varying vec4 vColor;
@@ -905,8 +863,8 @@ void main()
905
863
 
906
864
  gl_FragColor = color;
907
865
  }
908
- `;class of extends Gr{constructor(t=.5,r=Math.random()){super(Sl,N_,{uNoise:0,uSeed:0}),this.noise=t,this.seed=r}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 kl={AlphaFilter:ef,BlurFilter:rf,BlurFilterPass:ha,ColorMatrixFilter:la,DisplacementFilter:sf,FXAAFilter:nf,NoiseFilter:of};Object.entries(kl).forEach(([s,t])=>{Object.defineProperty(kl,s,{get(){return Oe("7.1.0",`filters.${s} has moved to ${s}`),t}})});class U_{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||(vr.system.add(this.tickerUpdate,this,ji.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(vr.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const Ts=new U_;class nn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=nn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new He,this.page=new He,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,r,i,n,o){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class qn extends nn{constructor(){super(...arguments),this.client=new He,this.movement=new He,this.offset=new He,this.global=new He,this.screen=new He}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,r,i){return t.worldTransform.applyInverse(i||this.global,r)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,r,i,n,o,h,c,b,T,C,x,$,I,B,U){throw new Error("Method not implemented.")}}class di extends qn{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class zs extends qn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}zs.DOM_DELTA_PIXEL=0,zs.DOM_DELTA_LINE=1,zs.DOM_DELTA_PAGE=2;const G_=2048,V_=new He,Bl=new He;class af{constructor(t){this.dispatch=new Xi,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,r){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:r,priority:0}),this.mappingTable[t].sort((i,n)=>i.priority-n.priority)}dispatchEvent(t,r){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,r),this.dispatch.emit(r||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const r=this.mappingTable[t.type];if(r)for(let i=0,n=r.length;i<n;i++)r[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,r){Ts.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,V_.set(t,r),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,r){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,o=i.length-1;n<o;n++)if(t.currentTarget=i[n],this.notifyTarget(t,r),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,r),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let n=i.length-2;n>=0;n--)if(t.currentTarget=i[n],this.notifyTarget(t,r),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,r,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(r)?r:[r];for(let o=i.length-1;o>=0;o--)n.forEach(h=>{t.currentTarget=i[o],this.notifyTarget(t,h)})}propagationPath(t){const r=[t];for(let i=0;i<G_&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");r.push(t.parent),t=t.parent}return r.reverse(),r}hitTestMoveRecursive(t,r,i,n,o,h=!1){let c=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||r==="dynamic")&&(Ts.pauseUpdate=!1),t.interactiveChildren&&t.children){const C=t.children;for(let x=C.length-1;x>=0;x--){const $=C[x],I=this.hitTestMoveRecursive($,this._isInteractive(r)?r:$.eventMode,i,n,o,h||o(t,i));if(I){if(I.length>0&&!I[I.length-1].parent)continue;const B=t.isInteractive();(I.length>0||B)&&(B&&this._allInteractiveElements.push(t),I.push(t)),this._hitElements.length===0&&(this._hitElements=I),c=!0}}}const b=this._isInteractive(r),T=t.isInteractive();return b&&T&&this._allInteractiveElements.push(t),h||this._hitElements.length>0?null:c?this._hitElements:b&&!o(t,i)&&n(t,i)?T?[t]:[]:null}hitTestRecursive(t,r,i,n,o){if(this._interactivePrune(t)||o(t,i))return null;if((t.eventMode==="dynamic"||r==="dynamic")&&(Ts.pauseUpdate=!1),t.interactiveChildren&&t.children){const b=t.children;for(let T=b.length-1;T>=0;T--){const C=b[T],x=this.hitTestRecursive(C,this._isInteractive(r)?r:C.eventMode,i,n,o);if(x){if(x.length>0&&!x[x.length-1].parent)continue;const $=t.isInteractive();return(x.length>0||$)&&x.push(t),x}}}const h=this._isInteractive(r),c=t.isInteractive();return h&&n(t,i)?c?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,r){var i;if(t.hitArea&&(t.worldTransform.applyInverse(r,Bl),!t.hitArea.contains(Bl.x,Bl.y)))return!0;if(t._mask){const n=t._mask.isMaskData?t._mask.maskObject:t._mask;if(n&&!((i=n.containsPoint)!=null&&i.call(n,r)))return!0}return!1}hitTestFn(t,r){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(r):!1}notifyTarget(t,r){var o,h;r=r??t.type;const i=`on${r}`;(h=(o=t.currentTarget)[i])==null||h.call(o,t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${r}capture`:r;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,r)}mapPointerDown(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.createPointerEvent(t);if(this.dispatchEvent(r,"pointerdown"),r.pointerType==="touch")this.dispatchEvent(r,"touchstart");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const n=r.button===2;this.dispatchEvent(r,n?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=r.composedPath(),this.freeEvent(r)}mapPointerMove(t){var b,T;if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=r.pointerType==="mouse"||r.pointerType==="pen",n=this.trackingData(t.pointerId),o=this.findMountedTarget(n.overTargets);if(((b=n.overTargets)==null?void 0:b.length)>0&&o!==r.target){const C=t.type==="mousemove"?"mouseout":"pointerout",x=this.createPointerEvent(t,C,o);if(this.dispatchEvent(x,"pointerout"),i&&this.dispatchEvent(x,"mouseout"),!r.composedPath().includes(o)){const $=this.createPointerEvent(t,"pointerleave",o);for($.eventPhase=$.AT_TARGET;$.target&&!r.composedPath().includes($.target);)$.currentTarget=$.target,this.notifyTarget($),i&&this.notifyTarget($,"mouseleave"),$.target=$.target.parent;this.freeEvent($)}this.freeEvent(x)}if(o!==r.target){const C=t.type==="mousemove"?"mouseover":"pointerover",x=this.clonePointerEvent(r,C);this.dispatchEvent(x,"pointerover"),i&&this.dispatchEvent(x,"mouseover");let $=o==null?void 0:o.parent;for(;$&&$!==this.rootTarget.parent&&$!==r.target;)$=$.parent;if(!$||$===this.rootTarget.parent){const I=this.clonePointerEvent(r,"pointerenter");for(I.eventPhase=I.AT_TARGET;I.target&&I.target!==o&&I.target!==this.rootTarget.parent;)I.currentTarget=I.target,this.notifyTarget(I),i&&this.notifyTarget(I,"mouseenter"),I.target=I.target.parent;this.freeEvent(I)}this.freeEvent(x)}const h=[],c=this.enableGlobalMoveEvents??!0;this.moveOnAll?h.push("pointermove"):this.dispatchEvent(r,"pointermove"),c&&h.push("globalpointermove"),r.pointerType==="touch"&&(this.moveOnAll?h.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),c&&h.push("globaltouchmove")),i&&(this.moveOnAll?h.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),c&&h.push("globalmousemove"),this.cursor=(T=r.target)==null?void 0:T.cursor),h.length>0&&this.all(r,h),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var h;if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(h=i.target)==null?void 0:h.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId);if(r.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",n=this.findMountedTarget(r.overTargets),o=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(o),i&&this.dispatchEvent(o,"mouseout");const h=this.createPointerEvent(t,"pointerleave",n);for(h.eventPhase=h.AT_TARGET;h.target&&h.target!==this.rootTarget.parent;)h.currentTarget=h.target,this.notifyTarget(h),i&&this.notifyTarget(h,"mouseleave"),h.target=h.target.parent;r.overTargets=null,this.freeEvent(o),this.freeEvent(h)}this.cursor=null}mapPointerUp(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const c=i.button===2;this.dispatchEvent(i,c?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),o=this.findMountedTarget(n.pressTargetsByButton[t.button]);let h=o;if(o&&!i.composedPath().includes(o)){let c=o;for(;c&&!i.composedPath().includes(c);){if(i.currentTarget=c,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const b=i.button===2;this.notifyTarget(i,b?"rightupoutside":"mouseupoutside")}c=c.parent}delete n.pressTargetsByButton[t.button],h=c}if(h){const c=this.clonePointerEvent(i,"click");c.target=h,c.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:c.target,timeStamp:r});const b=n.clicksByButton[t.button];if(b.target===c.target&&r-b.timeStamp<200?++b.clickCount:b.clickCount=1,b.target=c.target,b.timeStamp=r,c.detail=b.clickCount,c.pointerType==="mouse"){const T=c.button===2;this.dispatchEvent(c,T?"rightclick":"click")}else c.pointerType==="touch"&&this.dispatchEvent(c,"tap");this.dispatchEvent(c,"pointertap"),this.freeEvent(c)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.findMountedTarget(r.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let o=i;for(;o;)n.currentTarget=o,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),o=o.parent;delete r.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof zs)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const r=this.createWheelEvent(t);this.dispatchEvent(r),this.freeEvent(r)}findMountedTarget(t){if(!t)return null;let r=t[0];for(let i=1;i<t.length&&t[i].parent===r;i++)r=t[i];return r}createPointerEvent(t,r,i){const n=this.allocateEvent(di);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],typeof r=="string"&&(n.type=r),n}createWheelEvent(t){const r=this.allocateEvent(zs);return this.copyWheelData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=this.hitTest(r.global.x,r.global.y),r}clonePointerEvent(t,r){const i=this.allocateEvent(di);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=r??i.type,i}copyWheelData(t,r){r.deltaMode=t.deltaMode,r.deltaX=t.deltaX,r.deltaY=t.deltaY,r.deltaZ=t.deltaZ}copyPointerData(t,r){t instanceof di&&r instanceof di&&(r.pointerId=t.pointerId,r.width=t.width,r.height=t.height,r.isPrimary=t.isPrimary,r.pointerType=t.pointerType,r.pressure=t.pressure,r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist)}copyMouseData(t,r){t instanceof qn&&r instanceof qn&&(r.altKey=t.altKey,r.button=t.button,r.buttons=t.buttons,r.client.copyFrom(t.client),r.ctrlKey=t.ctrlKey,r.metaKey=t.metaKey,r.movement.copyFrom(t.movement),r.screen.copyFrom(t.screen),r.shiftKey=t.shiftKey,r.global.copyFrom(t.global))}copyData(t,r){r.isTrusted=t.isTrusted,r.srcElement=t.srcElement,r.timeStamp=performance.now(),r.type=t.type,r.detail=t.detail,r.view=t.view,r.which=t.which,r.layer.copyFrom(t.layer),r.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const r=this.eventPool.get(t).pop()||new t(this);return r.eventPhase=r.NONE,r.currentTarget=null,r.path=null,r.target=null,r}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const r=t.constructor;this.eventPool.has(r)||this.eventPool.set(r,[]),this.eventPool.get(r).push(t)}notifyListeners(t,r){const i=t.currentTarget._events[r];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(r,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let n=0,o=i.length;n<o&&!t.propagationImmediatelyStopped;n++)i[n].once&&t.currentTarget.removeListener(r,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,t)}}const X_=1,z_={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ol=class Fu{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new af(null),Ts.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new di(null),this.rootWheelEvent=new zs(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Fu.defaultEventFeatures},{set:(r,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),r[i]=n,!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:r,resolution:i}=this.renderer;this.setTargetElement(r),this.resolution=i,Fu._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 r=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(r=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":r&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":r&&Object.assign(this.domElement.style,i);break}else r&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const r=this.normalizeToPointerData(t);this.autoPreventDefault&&r[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,n=r.length;i<n;i++){const o=r[i],h=this.bootstrapEvent(this.rootPointerEvent,o);this.rootBoundary.mapEvent(h)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Ts.pointerMoved();const r=this.normalizeToPointerData(t);for(let i=0,n=r.length;i<n;i++){const o=this.bootstrapEvent(this.rootPointerEvent,r[i]);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let r=t.target;t.composedPath&&t.composedPath().length>0&&(r=t.composedPath()[0]);const i=r!==this.domElement?"outside":"",n=this.normalizeToPointerData(t);for(let o=0,h=n.length;o<h;o++){const c=this.bootstrapEvent(this.rootPointerEvent,n[o]);c.type+=i,this.rootBoundary.mapEvent(c)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const r=this.normalizeToPointerData(t);for(let i=0,n=r.length;i<n;i++){const o=this.bootstrapEvent(this.rootPointerEvent,r[i]);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const r=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(r)}setTargetElement(t){this.removeEvents(),this.domElement=t,Ts.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Ts.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;Ts.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,r,i){const n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},o=1/this.resolution;t.x=(r-n.left)*(this.domElement.width/n.width)*o,t.y=(i-n.top)*(this.domElement.height/n.height)*o}normalizeToPointerData(t){const r=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,n=t.changedTouches.length;i<n;i++){const o=t.changedTouches[i];typeof o.button>"u"&&(o.button=0),typeof o.buttons>"u"&&(o.buttons=1),typeof o.isPrimary>"u"&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof o.width>"u"&&(o.width=o.radiusX||1),typeof o.height>"u"&&(o.height=o.radiusY||1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="touch"),typeof o.pointerId>"u"&&(o.pointerId=o.identifier||0),typeof o.pressure>"u"&&(o.pressure=o.force||.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),typeof o.layerX>"u"&&(o.layerX=o.offsetX=o.clientX),typeof o.layerY>"u"&&(o.layerY=o.offsetY=o.clientY),o.isNormalized=!0,o.type=t.type,r.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=X_),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,r.push(i)}else r.push(t);return r}normalizeWheelEvent(t){const r=this.rootWheelEvent;return this.transferMouseData(r,t),r.deltaX=t.deltaX,r.deltaY=t.deltaY,r.deltaZ=t.deltaZ,r.deltaMode=t.deltaMode,this.mapPositionToPoint(r.screen,t.clientX,t.clientY),r.global.copyFrom(r.screen),r.offset.copyFrom(r.screen),r.nativeEvent=t,r.type=t.type,r}bootstrapEvent(t,r){return t.originalEvent=null,t.nativeEvent=r,t.pointerId=r.pointerId,t.width=r.width,t.height=r.height,t.isPrimary=r.isPrimary,t.pointerType=r.pointerType,t.pressure=r.pressure,t.tangentialPressure=r.tangentialPressure,t.tiltX=r.tiltX,t.tiltY=r.tiltY,t.twist=r.twist,this.transferMouseData(t,r),this.mapPositionToPoint(t.screen,r.clientX,r.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=r.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=z_[t.type]||t.type),t}transferMouseData(t,r){t.isTrusted=r.isTrusted,t.srcElement=r.srcElement,t.timeStamp=performance.now(),t.type=r.type,t.altKey=r.altKey,t.button=r.button,t.buttons=r.buttons,t.client.x=r.clientX,t.client.y=r.clientY,t.ctrlKey=r.ctrlKey,t.metaKey=r.metaKey,t.movement.x=r.movementX,t.movement.y=r.movementY,t.page.x=r.pageX,t.page.y=r.pageY,t.relatedTarget=null,t.shiftKey=r.shiftKey}};Ol.extension={name:"events",type:[Kt.RendererSystem,Kt.CanvasRendererSystem]},Ol.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let ua=Ol;be.add(ua);function hf(s){return s==="dynamic"||s==="static"}const lf={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??hf(ua.defaultEventMode)},set interactive(s){Oe("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=s,this.eventMode=s?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??ua.defaultEventMode},set eventMode(s){this._internalInteractive=hf(s),this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,r){const i=typeof r=="boolean"&&r||typeof r=="object"&&r.capture,n=typeof r=="object"?r.signal:void 0,o=typeof r=="object"?r.once===!0:!1,h=typeof t=="function"?void 0:t;s=i?`${s}capture`:s;const c=typeof t=="function"?t:t.handleEvent,b=this;n&&n.addEventListener("abort",()=>{b.off(s,c,h)}),o?b.once(s,c,h):b.on(s,c,h)},removeEventListener(s,t,r){const i=typeof r=="boolean"&&r||typeof r=="object"&&r.capture,n=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,n)},dispatchEvent(s){if(!(s instanceof nn))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};fr.mixin(lf);const uf={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};fr.mixin(uf);const W_=9,ca=100,H_=0,Y_=0,cf=2,ff=1,j_=-1e3,q_=-1e3,Z_=2;class Nl{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(Ci.tablet||Ci.phone)&&this.createTouchHook();const r=document.createElement("div");r.style.width=`${ca}px`,r.style.height=`${ca}px`,r.style.position="absolute",r.style.top=`${H_}px`,r.style.left=`${Y_}px`,r.style.zIndex=cf.toString(),this.div=r,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${ff}px`,t.style.height=`${ff}px`,t.style.position="absolute",t.style.top=`${j_}px`,t.style.left=`${q_}px`,t.style.zIndex=Z_.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const r=t.children;if(r)for(let i=0;i<r.length;i++)this.updateAccessibleObjects(r[i])}update(){const t=performance.now();if(Ci.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:r,y:i,width:n,height:o}=this.renderer.view.getBoundingClientRect(),{width:h,height:c,resolution:b}=this.renderer,T=n/h*b,C=o/c*b;let x=this.div;x.style.left=`${r}px`,x.style.top=`${i}px`,x.style.width=`${h}px`,x.style.height=`${c}px`;for(let $=0;$<this.children.length;$++){const I=this.children[$];if(I.renderId!==this.renderId)I._accessibleActive=!1,ks(this.children,$,1),this.div.removeChild(I._accessibleDiv),this.pool.push(I._accessibleDiv),I._accessibleDiv=null,$--;else{x=I._accessibleDiv;let B=I.hitArea;const U=I.worldTransform;I.hitArea?(x.style.left=`${(U.tx+B.x*U.a)*T}px`,x.style.top=`${(U.ty+B.y*U.d)*C}px`,x.style.width=`${B.width*U.a*T}px`,x.style.height=`${B.height*U.d*C}px`):(B=I.getBounds(),this.capHitArea(B),x.style.left=`${B.x*T}px`,x.style.top=`${B.y*C}px`,x.style.width=`${B.width*T}px`,x.style.height=`${B.height*C}px`,x.title!==I.accessibleTitle&&I.accessibleTitle!==null&&(x.title=I.accessibleTitle),x.getAttribute("aria-label")!==I.accessibleHint&&I.accessibleHint!==null&&x.setAttribute("aria-label",I.accessibleHint)),(I.accessibleTitle!==x.title||I.tabIndex!==x.tabIndex)&&(x.title=I.accessibleTitle,x.tabIndex=I.tabIndex,this.debug&&this.updateDebugHTML(x))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:r,height:i}=this.renderer;t.x+t.width>r&&(t.width=r-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let r=this.pool.pop();r||(r=document.createElement("button"),r.style.width=`${ca}px`,r.style.height=`${ca}px`,r.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",r.style.position="absolute",r.style.zIndex=cf.toString(),r.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?r.setAttribute("aria-live","off"):r.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?r.setAttribute("aria-relevant","additions"):r.setAttribute("aria-relevant","text"),r.addEventListener("click",this._onClick.bind(this)),r.addEventListener("focus",this._onFocus.bind(this)),r.addEventListener("focusout",this._onFocusOut.bind(this))),r.style.pointerEvents=t.accessiblePointerEvents,r.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?r.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(r.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&r.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(r),t._accessibleActive=!0,t._accessibleDiv=r,r.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,r){const{displayObject:i}=t.target,n=this.renderer.events.rootBoundary,o=Object.assign(new nn(n),{target:i});n.rootTarget=this.renderer.lastObjectRendered,r.forEach(h=>n.dispatchEvent(o,h))}_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===W_&&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}}Nl.extension={name:"accessibility",type:[Kt.RendererPlugin,Kt.CanvasRendererPlugin]},be.add(Nl);const df=class Lu{constructor(t){this.stage=new Zr,t=Object.assign({forceCanvas:!1},t),this.renderer=Y0(t),Lu._plugins.forEach(r=>{r.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,r){const i=Lu._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(r),this.stage=null,this.renderer.destroy(t),this.renderer=null}};df._plugins=[];let Ul=df;be.handleByList(Kt.Application,Ul._plugins);class Gl{static init(t){Object.defineProperty(this,"resizeTo",{set(r){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=r,r&&(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 r,i;if(this._resizeTo===globalThis.window)r=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:o}=this._resizeTo;r=n,i=o}this.renderer.resize(r,i),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}}Gl.extension=Kt.Application,be.add(Gl);const pf={loader:Kt.LoadParser,resolver:Kt.ResolveParser,cache:Kt.CacheParser,detection:Kt.DetectionParser};be.handle(Kt.Asset,s=>{const t=s.ref;Object.entries(pf).filter(([r])=>!!t[r]).forEach(([r,i])=>be.add(Object.assign(t[r],{extension:t[r].extension??i})))},s=>{const t=s.ref;Object.keys(pf).filter(r=>!!t[r]).forEach(r=>be.remove(t[r]))});class Q_{constructor(t,r=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=r}add(t){t.forEach(r=>{this._assetList.push(r)}),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=[],r=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<r;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Ws(s,t){if(Array.isArray(t)){for(const r of t)if(s.startsWith(`data:${r}`))return!0;return!1}return s.startsWith(`data:${t}`)}function cs(s,t){const r=s.split("?")[0],i=$r.extname(r).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const pi=(s,t,r=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||r?t(i):i):s),fa=(s,t)=>{const r=t.split("?")[1];return r&&(s+=`?${r}`),s};function _f(s,t,r,i,n){const o=t[r];for(let h=0;h<o.length;h++){const c=o[h];r<t.length-1?_f(s.replace(i[r],c),t,r+1,i,n):n.push(s.replace(i[r],c))}}function gf(s){const t=/\{(.*?)\}/g,r=s.match(t),i=[];if(r){const n=[];r.forEach(o=>{const h=o.substring(1,o.length-1).split(",");n.push(h)}),_f(s,n,0,r,i)}else i.push(s);return i}const Zn=s=>!Array.isArray(s);class K_{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 r=this._cache.get(t);return r||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),r}set(t,r){const i=pi(t);let n;for(let c=0;c<this.parsers.length;c++){const b=this.parsers[c];if(b.test(r)){n=b.getCacheableAssets(i,r);break}}n||(n={},i.forEach(c=>{n[c]=r}));const o=Object.keys(n),h={cacheKeys:o,keys:i};if(i.forEach(c=>{this._cacheMap.set(c,h)}),o.forEach(c=>{const b=n?n[c]:r;this._cache.has(c)&&this._cache.get(c)!==b&&console.warn("[Cache] already has key:",c),this._cache.set(c,n[c])}),r instanceof ne){const c=r;i.forEach(b=>{c.baseTexture!==ne.EMPTY.baseTexture&&Ge.addToCache(c.baseTexture,b),ne.addToCache(c,b)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const r=this._cacheMap.get(t);r.cacheKeys.forEach(i=>{this._cache.delete(i)}),r.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Es=new K_;class J_{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,r,i)=>(this._parsersValidated=!1,t[r]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,r){const i={promise:null,parser:null};return i.promise=(async()=>{var h,c;let n=null,o=null;if(r.loadParser&&(o=this._parserHash[r.loadParser],o||console.warn(`[Assets] specified load parser "${r.loadParser}" not found while loading ${t}`)),!o){for(let b=0;b<this.parsers.length;b++){const T=this.parsers[b];if(T.load&&((h=T.test)!=null&&h.call(T,t,r,this))){o=T;break}}if(!o)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}n=await o.load(t,r,this),i.parser=o;for(let b=0;b<this.parsers.length;b++){const T=this.parsers[b];T.parse&&T.parse&&await((c=T.testParse)==null?void 0:c.call(T,n,r,this))&&(n=await T.parse(n,r,this)||n,i.parser=T)}return n})(),i}async load(t,r){this._parsersValidated||this._validateParsers();let i=0;const n={},o=Zn(t),h=pi(t,T=>({alias:[T],src:T})),c=h.length,b=h.map(async T=>{const C=$r.toAbsolute(T.src);if(!n[T.src])try{this.promiseCache[C]||(this.promiseCache[C]=this._getLoadPromiseAndParser(C,T)),n[T.src]=await this.promiseCache[C].promise,r&&r(++i/c)}catch(x){throw delete this.promiseCache[C],delete n[T.src],new Error(`[Loader.load] Failed to load ${C}.
909
- ${x}`)}});return await Promise.all(b),o?n[h[0].src]:n}async unload(t){const r=pi(t,i=>({alias:[i],src:i})).map(async i=>{var h,c;const n=$r.toAbsolute(i.src),o=this.promiseCache[n];if(o){const b=await o.promise;delete this.promiseCache[n],(c=(h=o.parser)==null?void 0:h.unload)==null||c.call(h,b,i,this)}});await Promise.all(r)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,r)=>(t[r.name]&&console.warn(`[Assets] loadParser name conflict "${r.name}"`),{...t,[r.name]:r}),{})}}var _i=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(_i||{});const tg=".json",eg="application/json",mf={extension:{type:Kt.LoadParser,priority:_i.Low},name:"loadJson",test(s){return Ws(s,eg)||cs(s,tg)},async load(s){return await(await ue.ADAPTER.fetch(s)).json()}};be.add(mf);const rg=".txt",ig="text/plain",yf={name:"loadTxt",extension:{type:Kt.LoadParser,priority:_i.Low},test(s){return Ws(s,ig)||cs(s,rg)},async load(s){return await(await ue.ADAPTER.fetch(s)).text()}};be.add(yf);const sg=["normal","bold","100","200","300","400","500","600","700","800","900"],ng=[".ttf",".otf",".woff",".woff2"],og=["font/ttf","font/otf","font/woff","font/woff2"],ag=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function vf(s){const t=$r.extname(s),r=$r.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let i=r.length>0;for(const o of r)if(!o.match(ag)){i=!1;break}let n=r.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const hg=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function lg(s){return hg.test(s)?s:encodeURI(s)}const xf={extension:{type:Kt.LoadParser,priority:_i.Low},name:"loadWebFont",test(s){return Ws(s,og)||cs(s,ng)},async load(s,t){var i,n,o;const r=ue.ADAPTER.getFontFaceSet();if(r){const h=[],c=((i=t.data)==null?void 0:i.family)??vf(s),b=((o=(n=t.data)==null?void 0:n.weights)==null?void 0:o.filter(C=>sg.includes(C)))??["normal"],T=t.data??{};for(let C=0;C<b.length;C++){const x=b[C],$=new FontFace(c,`url(${lg(s)})`,{...T,weight:x});await $.load(),r.add($),h.push($)}return h.length===1?h[0]:h}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>ue.ADAPTER.getFontFaceSet().delete(t))}};be.add(xf);const ug=`(function() {
866
+ `;class Vu extends kt{constructor(t=.5,e=Math.random()){super(Qa,Pm,{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 ho={AlphaFilter:ku,BlurFilter:Nu,BlurFilterPass:Is,ColorMatrixFilter:Rs,DisplacementFilter:Uu,FXAAFilter:Gu,NoiseFilter:Vu};Object.entries(ho).forEach(([s,t])=>{Object.defineProperty(ho,s,{get(){return ot("7.1.0",`filters.${s} has moved to ${s}`),t}})});class Mm{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||(Pt.system.add(this.tickerUpdate,this,Pe.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Pt.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const ti=new Mm;class Li{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Li.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ft,this.page=new ft,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,r,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class Sr extends Li{constructor(){super(...arguments),this.client=new ft,this.movement=new ft,this.offset=new ft,this.global=new ft,this.screen=new ft}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,r,n,a,o,h,l,u,c,d,f,p,g){throw new Error("Method not implemented.")}}class te extends Sr{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class xi extends Sr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}xi.DOM_DELTA_PIXEL=0,xi.DOM_DELTA_LINE=1,xi.DOM_DELTA_PAGE=2;const Im=2048,Rm=new ft,lo=new ft;class Hu{constructor(t){this.dispatch=new Ee,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,r)=>i.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 i=0,r=e.length;i<r;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){ti.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",r=this[i](this.rootTarget,this.rootTarget.eventMode,Rm.set(t,e),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let r=0,n=i.length-1;r<n;r++)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)r.forEach(a=>{t.currentTarget=i[n],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let i=0;i<Im&&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,r,n,a=!1){let o=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ti.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,r,n,a||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),o=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return h&&l&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:h&&!n(t,i)&&r(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,r,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ti.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let l=h.length-1;l>=0;l--){const u=h[l],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,r,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&r(t,i)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,lo),!t.hitArea.contains(lo.x,lo.y)))return!0;if(t._mask){const r=t._mask.isMaskData?t._mask.maskObject:t._mask;if(r&&!((i=r.containsPoint)!=null&&i.call(r,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,a;e=e??t.type;const i=`on${e}`;(a=(n=t.currentTarget)[i])==null||a.call(n,t);const r=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,r),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof te)){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 i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var h,l;if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.overTargets);if(((h=r.overTargets)==null?void 0:h.length)>0&&n!==e.target){const u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),i&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(c)}const a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&a.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&a.push("globaltouchmove")),i&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&a.push("globalmousemove"),this.cursor=(l=e.target)==null?void 0:l.cursor),a.length>0&&this.all(e,a),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var a;if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),r=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),r&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(a=i.target)==null?void 0:a.cursor);const n=this.clonePointerEvent(i,"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=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",r=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(t,"pointerleave",r);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[t.button]);let a=n;if(n&&!i.composedPath().includes(n)){let o=n;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const h=i.button===2;this.notifyTarget(i,h?"rightupoutside":"mouseupoutside")}o=o.parent}delete r.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const h=r.clicksByButton[t.button];if(h.target===o.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=o.target,h.timeStamp=e,o.detail=h.clickCount,o.pointerType==="mouse"){const l=o.button===2;this.dispatchEvent(o,l?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(i){let n=i;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 xi)){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 i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const r=this.allocateEvent(te);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof e=="string"&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(xi);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(te);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof te&&e instanceof te&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof Sr&&e instanceof Sr&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let r=0,n=i.length;r<n&&!t.propagationImmediatelyStopped;r++)i[r].once&&t.currentTarget.removeListener(e,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,t)}}const Dm=1,Fm={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},uo=class gh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Hu(null),ti.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new te(null),this.rootWheelEvent=new xi(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...gh.defaultEventFeatures},{set:(e,i,r)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),e[i]=r,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,gh._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);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,r=e.length;i<r;i++){const n=e[i],a=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ti.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",r=this.normalizeToPointerData(t);for(let n=0,a=r.length;n<a;n++){const o=this.bootstrapEvent(this.rootPointerEvent,r[n]);o.type+=i,this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,ti.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;ti.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;ti.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-r.left)*(this.domElement.width/r.width)*n,t.y=(i-r.top)*(this.domElement.height/r.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,r=t.changedTouches.length;i<r;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=Dm),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=Fm[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};uo.extension={name:"events",type:[$.RendererSystem,$.CanvasRendererSystem]},uo.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ds=uo;Q.add(Ds);function Xu(s){return s==="dynamic"||s==="static"}const zu={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??Xu(Ds.defaultEventMode)},set interactive(s){ot("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=s,this.eventMode=s?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ds.defaultEventMode},set eventMode(s){this._internalInteractive=Xu(s),this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,a=typeof t=="function"?void 0:t;s=i?`${s}capture`:s;const o=typeof t=="function"?t:t.handleEvent,h=this;r&&r.addEventListener("abort",()=>{h.off(s,o,a)}),n?h.once(s,o,a):h.on(s,o,a)},removeEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,r)},dispatchEvent(s){if(!(s instanceof Li))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};Et.mixin(zu);const Wu={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Et.mixin(Wu);const Bm=9,Fs=100,Lm=0,Om=0,$u=2,ju=1,km=-1e3,Nm=-1e3,Um=2;class co{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(ce.tablet||ce.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Fs}px`,e.style.height=`${Fs}px`,e.style.position="absolute",e.style.top=`${Lm}px`,e.style.left=`${Om}px`,e.style.zIndex=$u.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${ju}px`,t.style.height=`${ju}px`,t.style.position="absolute",t.style.top=`${km}px`,t.style.left=`${Nm}px`,t.style.zIndex=Um.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(ce.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:r,height:n}=this.renderer.view.getBoundingClientRect(),{width:a,height:o,resolution:h}=this.renderer,l=r/a*h,u=n/o*h;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${a}px`,c.style.height=`${o}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,di(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{c=f._accessibleDiv;let p=f.hitArea;const g=f.worldTransform;f.hitArea?(c.style.left=`${(g.tx+p.x*g.a)*l}px`,c.style.top=`${(g.ty+p.y*g.d)*u}px`,c.style.width=`${p.width*g.a*l}px`,c.style.height=`${p.height*g.d*u}px`):(p=f.getBounds(),this.capHitArea(p),c.style.left=`${p.x*l}px`,c.style.top=`${p.y*u}px`,c.style.width=`${p.width*l}px`,c.style.height=`${p.height*u}px`,c.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(c.title=f.accessibleTitle),c.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&c.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==c.title||f.tabIndex!==c.tabIndex)&&(c.title=f.accessibleTitle,c.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(c))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height: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=`${Fs}px`,e.style.height=`${Fs}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=$u.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:i}=t.target,r=this.renderer.events.rootBoundary,n=Object.assign(new Li(r),{target:i});r.rootTarget=this.renderer.lastObjectRendered,e.forEach(a=>r.dispatchEvent(n,a))}_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===Bm&&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}}co.extension={name:"accessibility",type:[$.RendererPlugin,$.CanvasRendererPlugin]},Q.add(co);const Yu=class _h{constructor(t){this.stage=new Vt,t=Object.assign({forceCanvas:!1},t),this.renderer=Mu(t),_h._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const i=_h._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Yu._plugins=[];let fo=Yu;Q.handleByList($.Application,fo._plugins);class po{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,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;e=r,i=n}this.renderer.resize(e,i),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}}po.extension=$.Application,Q.add(po);const qu={loader:$.LoadParser,resolver:$.ResolveParser,cache:$.CacheParser,detection:$.DetectionParser};Q.handle($.Asset,s=>{const t=s.ref;Object.entries(qu).filter(([e])=>!!t[e]).forEach(([e,i])=>Q.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(qu).filter(e=>!!t[e]).forEach(e=>Q.remove(t[e]))});class Gm{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 i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function bi(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function Ve(s,t){const e=s.split("?")[0],i=Rt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const ee=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s),Bs=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s};function Ku(s,t,e,i,r){const n=t[e];for(let a=0;a<n.length;a++){const o=n[a];e<t.length-1?Ku(s.replace(i[e],o),t,e+1,i,r):r.push(s.replace(i[e],o))}}function Zu(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const a=n.substring(1,n.length-1).split(",");r.push(a)}),Ku(s,r,0,e,i)}else i.push(s);return i}const Pr=s=>!Array.isArray(s);class Vm{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||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=ee(t);let r;for(let o=0;o<this.parsers.length;o++){const h=this.parsers[o];if(h.test(e)){r=h.getCacheableAssets(i,e);break}}r||(r={},i.forEach(o=>{r[o]=e}));const n=Object.keys(r),a={cacheKeys:n,keys:i};if(i.forEach(o=>{this._cacheMap.set(o,a)}),n.forEach(o=>{const h=r?r[o]:e;this._cache.has(o)&&this._cache.get(o)!==h&&console.warn("[Cache] already has key:",o),this._cache.set(o,r[o])}),e instanceof j){const o=e;i.forEach(h=>{o.baseTexture!==j.EMPTY.baseTexture&&lt.addToCache(o.baseTexture,h),j.addToCache(o,h)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const ei=new Vm;class Hm{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((a=l.test)!=null&&a.call(l,t,e,this))){n=l;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await n.load(t,e,this),i.parser=n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((o=l.testParse)==null?void 0:o.call(l,r,e,this))&&(r=await l.parse(r,e,this)||r,i.parser=l)}return r})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const r={},n=Pr(t),a=ee(t,l=>({alias:[l],src:l})),o=a.length,h=a.map(async l=>{const u=Rt.toAbsolute(l.src);if(!r[l.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,l)),r[l.src]=await this.promiseCache[u].promise,e&&e(++i/o)}catch(c){throw delete this.promiseCache[u],delete r[l.src],new Error(`[Loader.load] Failed to load ${u}.
867
+ ${c}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const e=ee(t,i=>({alias:[i],src:i})).map(async i=>{var a,o;const r=Rt.toAbsolute(i.src),n=this.promiseCache[r];if(n){const h=await n.promise;delete this.promiseCache[r],(o=(a=n.parser)==null?void 0:a.unload)==null||o.call(a,h,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var ie=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(ie||{});const Xm=".json",zm="application/json",Ju={extension:{type:$.LoadParser,priority:ie.Low},name:"loadJson",test(s){return bi(s,zm)||Ve(s,Xm)},async load(s){return await(await q.ADAPTER.fetch(s)).json()}};Q.add(Ju);const Wm=".txt",$m="text/plain",Qu={name:"loadTxt",extension:{type:$.LoadParser,priority:ie.Low},test(s){return bi(s,$m)||Ve(s,Wm)},async load(s){return await(await q.ADAPTER.fetch(s)).text()}};Q.add(Qu);const jm=["normal","bold","100","200","300","400","500","600","700","800","900"],Ym=[".ttf",".otf",".woff",".woff2"],qm=["font/ttf","font/otf","font/woff","font/woff2"],Km=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function tc(s){const t=Rt.extname(s),e=Rt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(Km)){i=!1;break}let r=e.join(" ");return i||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}const Zm=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Jm(s){return Zm.test(s)?s:encodeURI(s)}const ec={extension:{type:$.LoadParser,priority:ie.Low},name:"loadWebFont",test(s){return bi(s,qm)||Ve(s,Ym)},async load(s,t){var i,r,n;const e=q.ADAPTER.getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??tc(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(u=>jm.includes(u)))??["normal"],l=t.data??{};for(let u=0;u<h.length;u++){const c=h[u],d=new FontFace(o,`url(${Jm(s)})`,{...l,weight:c});await d.load(),e.add(d),a.push(d)}return a.length===1?a[0]:a}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>q.ADAPTER.getFontFaceSet().delete(t))}};Q.add(ec);const Qm=`(function() {
910
868
  "use strict";
911
869
  const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
912
870
  async function checkImageBitmap() {
@@ -923,7 +881,7 @@ ${x}`)}});return await Promise.all(b),o?n[h[0].src]:n}async unload(t){const r=pi
923
881
  self.postMessage(result);
924
882
  });
925
883
  })();
926
- `;let on=null,Vl=class{constructor(){on||(on=URL.createObjectURL(new Blob([ug],{type:"application/javascript"}))),this.worker=new Worker(on)}};Vl.revokeObjectURL=function(){on&&(URL.revokeObjectURL(on),on=null)};const cg=`(function() {
884
+ `;let Oi=null,mo=class{constructor(){Oi||(Oi=URL.createObjectURL(new Blob([Qm],{type:"application/javascript"}))),this.worker=new Worker(Oi)}};mo.revokeObjectURL=function(){Oi&&(URL.revokeObjectURL(Oi),Oi=null)};const tg=`(function() {
927
885
  "use strict";
928
886
  async function loadImageBitmap(url) {
929
887
  const response = await fetch(url);
@@ -949,8 +907,8 @@ ${x}`)}});return await Promise.all(b),o?n[h[0].src]:n}async unload(t){const r=pi
949
907
  }
950
908
  };
951
909
  })();
952
- `;let an=null;class bf{constructor(){an||(an=URL.createObjectURL(new Blob([cg],{type:"application/javascript"}))),this.worker=new Worker(an)}}bf.revokeObjectURL=function(){an&&(URL.revokeObjectURL(an),an=null)};let Af=0,Xl;class fg{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:r}=new Vl;r.addEventListener("message",i=>{r.terminate(),Vl.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Xl===void 0&&(Xl=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Xl&&(this._createdWorkers++,t=new bf().worker,t.addEventListener("message",r=>{this.complete(r.data),this.returnWorker(r.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,r){await this._initWorkers();const i=new Promise((n,o)=>{this.queue.push({id:t,arguments:r,resolve:n,reject:o})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const r=this.queue.pop(),i=r.id;this.resolveHash[Af]={resolve:r.resolve,reject:r.reject},t.postMessage({data:r.arguments,uuid:Af++,id:i})}}const wf=new fg;function hn(s,t,r){s.resource.internal=!0;const i=new ne(s),n=()=>{delete t.promiseCache[r],Es.has(r)&&Es.remove(r)};return i.baseTexture.once("destroyed",()=>{r in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),n())}),i.once("destroyed",()=>{s.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),i}const dg=[".jpeg",".jpg",".png",".webp",".avif"],pg=["image/jpeg","image/png","image/webp","image/avif"];async function Tf(s){const t=await ue.ADAPTER.fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const r=await t.blob();return await createImageBitmap(r)}const Qn={name:"loadTextures",extension:{type:Kt.LoadParser,priority:_i.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return Ws(s,pg)||cs(s,dg)},async load(s,t,r){var c;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let n;i?this.config.preferWorkers&&await wf.isImageBitmapSupported()?n=await wf.loadImageBitmap(s):n=await Tf(s):n=await new Promise((b,T)=>{const C=new Image;C.crossOrigin=this.config.crossOrigin,C.src=s,C.complete?b(C):(C.onload=()=>b(C),C.onerror=x=>T(x))});const o={...t.data};o.resolution??(o.resolution=Wi(s)),i&&((c=o.resourceOptions)==null?void 0:c.ownsImageBitmap)===void 0&&(o.resourceOptions={...o.resourceOptions},o.resourceOptions.ownsImageBitmap=!0);const h=new Ge(n,o);return h.resource.src=s,hn(h,r,s)},unload(s){s.destroy(!0)}};be.add(Qn);const _g=".svg",gg="image/svg+xml",Ef={extension:{type:Kt.LoadParser,priority:_i.High},name:"loadSVG",test(s){return Ws(s,gg)||cs(s,_g)},async testParse(s){return aa.test(s)},async parse(s,t,r){var o;const i=new aa(s,(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions);await i.load();const n=new Ge(i,{resolution:Wi(s),...t==null?void 0:t.data});return n.resource.src=t.src,hn(n,r,t.src)},async load(s,t){return(await ue.ADAPTER.fetch(s)).text()},unload:Qn.unload};be.add(Ef);const mg=[".mp4",".m4v",".webm",".ogv"],yg=["video/mp4","video/webm","video/ogg"],Cf={name:"loadVideo",extension:{type:Kt.LoadParser,priority:_i.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(s){return Ws(s,yg)||cs(s,mg)},async load(s,t,r){var h;let i;const n=await(await ue.ADAPTER.fetch(s)).blob(),o=URL.createObjectURL(n);try{const c={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(h=t==null?void 0:t.data)==null?void 0:h.resourceOptions,autoLoad:!0},b=new Fl(o,c);await b.load();const T=new Ge(b,{alphaMode:await Bc(),resolution:Wi(s),...t==null?void 0:t.data});T.resource.src=s,i=hn(T,r,s),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(o)})}catch(c){throw URL.revokeObjectURL(o),c}return i},unload(s){s.destroy(!0)}};be.add(Cf);class vg{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,r)=>`${t}${this._bundleIdConnector}${r}`,extractAssetIdFromBundle:(t,r)=>r.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(r=>{this._preferredOrder.push(r),r.priority||(r.priority=Object.keys(r.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const r=t;this._defaultSearchParams=Object.keys(r).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(r[i])}`).join("&")}}getAlias(t){const{alias:r,name:i,src:n,srcs:o}=t;return pi(r||i||n||o,h=>typeof h=="string"?h:Array.isArray(h)?h.map(c=>(c==null?void 0:c.src)??(c==null?void 0:c.srcs)??c):h!=null&&h.src||h!=null&&h.srcs?h.src??h.srcs:h,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(r=>{this.addBundle(r.name,r.assets)})}addBundle(t,r){const i=[];Array.isArray(r)?r.forEach(n=>{const o=n.src??n.srcs,h=n.alias??n.name;let c;if(typeof h=="string"){const b=this._createBundleAssetId(t,h);i.push(b),c=[h,b]}else{const b=h.map(T=>this._createBundleAssetId(t,T));i.push(...b),c=[...h,...b]}this.add({...n,alias:c,src:o})}):Object.keys(r).forEach(n=>{const o=[n,this._createBundleAssetId(t,n)];if(typeof r[n]=="string")this.add({alias:o,src:r[n]});else if(Array.isArray(r[n]))this.add({alias:o,src:r[n]});else{const h=r[n],c=h.src??h.srcs;this.add({...h,alias:o,src:Array.isArray(c)?c:[c]})}i.push(...o)}),this._bundles[t]=i}add(t,r,i,n,o){const h=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(Oe("7.2.0",`Assets.add now uses an object instead of individual parameters.
953
- Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),h.push({alias:t,src:r,data:i,format:n,loadParser:o})):Array.isArray(t)?h.push(...t):h.push(t);let c;c=b=>{this.hasKey(b)&&console.warn(`[Resolver] already has key: ${b} overwriting`)},pi(h).forEach(b=>{const{src:T,srcs:C}=b;let{data:x,format:$,loadParser:I}=b;const B=pi(T||C).map(z=>typeof z=="string"?gf(z):Array.isArray(z)?z:[z]),U=this.getAlias(b);Array.isArray(U)?U.forEach(c):c(U);const G=[];B.forEach(z=>{z.forEach(J=>{let Z={};if(typeof J!="object"){Z.src=J;for(let it=0;it<this._parsers.length;it++){const Q=this._parsers[it];if(Q.test(J)){Z=Q.parse(J);break}}}else x=J.data??x,$=J.format??$,I=J.loadParser??I,Z={...Z,...J};if(!U)throw new Error(`[Resolver] alias is undefined for this asset: ${Z.src}`);Z=this.buildResolvedAsset(Z,{aliases:U,data:x,format:$,loadParser:I}),G.push(Z)})}),U.forEach(z=>{this._assetMap[z]=G})})}resolveBundle(t){const r=Zn(t);t=pi(t);const i={};return t.forEach(n=>{const o=this._bundles[n];if(o){const h=this.resolve(o),c={};for(const b in h){const T=h[b];c[this._extractAssetIdFromBundle(n,b)]=T}i[n]=c}}),r?i[t[0]]:i}resolveUrl(t){const r=this.resolve(t);if(typeof t!="string"){const i={};for(const n in r)i[n]=r[n].src;return i}return r.src}resolve(t){const r=Zn(t);t=pi(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let o=this._assetMap[n];const h=o[0],c=this._getPreferredOrder(o);c==null||c.priority.forEach(b=>{c.params[b].forEach(T=>{const C=o.filter(x=>x[b]?x[b]===T:!1);C.length&&(o=C)})}),this._resolverHash[n]=o[0]??h}else this._resolverHash[n]=this.buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),r?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let r=0;r<t.length;r++){const i=t[0],n=this._preferredOrder.find(o=>o.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const r=/\?/.test(t)?"&":"?";return`${t}${r}${this._defaultSearchParams}`}buildResolvedAsset(t,r){const{aliases:i,data:n,loadParser:o,format:h}=r;return(this._basePath||this._rootPath)&&(t.src=$r.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=o??t.loadParser,t.format=h??t.format??$r.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class Sf{constructor(){this._detections=[],this._initialized=!1,this.resolver=new vg,this.loader=new J_,this.cache=Es,this._backgroundLoader=new Q_(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var o,h;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let c=t.manifest;typeof c=="string"&&(c=await this.load(c)),this.resolver.addManifest(c)}const r=((o=t.texturePreference)==null?void 0:o.resolution)??1,i=typeof r=="number"?[r]:r,n=await this._detectFormats({preferredFormats:(h=t.texturePreference)==null?void 0:h.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,r,i,n,o){this.resolver.add(t,r,i,n,o)}async load(t,r){this._initialized||await this.init();const i=Zn(t),n=pi(t).map(c=>{if(typeof c!="string"){const b=this.resolver.getAlias(c);return b.some(T=>!this.resolver.hasKey(T))&&this.add(c),Array.isArray(b)?b[0]:b}return this.resolver.hasKey(c)||this.add({alias:c,src:c}),c}),o=this.resolver.resolve(n),h=await this._mapLoadToResolve(o,r);return i?h[n[0]]:h}addBundle(t,r){this.resolver.addBundle(t,r)}async loadBundle(t,r){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),o={},h=Object.keys(n);let c=0,b=0;const T=()=>{r==null||r(++c/b)},C=h.map(x=>{const $=n[x];return b+=Object.keys($).length,this._mapLoadToResolve($,T).then(I=>{o[x]=I})});return await Promise.all(C),i?o[t[0]]:o}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const r=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(r))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const r=this.resolver.resolveBundle(t);Object.values(r).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Es.get(t);const r={};for(let i=0;i<t.length;i++)r[i]=Es.get(t[i]);return r}async _mapLoadToResolve(t,r){const i=Object.values(t),n=Object.keys(t);this._backgroundLoader.active=!1;const o=await this.loader.load(i,r);this._backgroundLoader.active=!0;const h={};return i.forEach((c,b)=>{const T=o[c.src],C=[c.src];c.alias&&C.push(...c.alias),h[n[b]]=T,Es.set(C,T)}),h}async unload(t){this._initialized||await this.init();const r=pi(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(r);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=pi(t);const r=this.resolver.resolveBundle(t),i=Object.keys(r).map(n=>this._unloadFromResolved(r[n]));await Promise.all(i)}async _unloadFromResolved(t){const r=Object.values(t);r.forEach(i=>{Es.remove(i.src)}),await this.loader.unload(r)}async _detectFormats(t){let r=[];t.preferredFormats&&(r=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?r=await i.add(r):t.skipDetections||(r=await i.remove(r));return r=r.filter((i,n)=>r.indexOf(i)===n),r}get detections(){return this._detections}get preferWorkers(){return Qn.config.preferWorkers}set preferWorkers(t){Oe("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(r=>{r.config&&Object.keys(r.config).filter(i=>i in t).forEach(i=>{r.config[i]=t[i]})})}}const Kn=new Sf;be.handleByList(Kt.LoadParser,Kn.loader.parsers).handleByList(Kt.ResolveParser,Kn.resolver.parsers).handleByList(Kt.CacheParser,Kn.cache.parsers).handleByList(Kt.DetectionParser,Kn.detections);const Pf={extension:Kt.CacheParser,test:s=>Array.isArray(s)&&s.every(t=>t instanceof ne),getCacheableAssets:(s,t)=>{const r={};return s.forEach(i=>{t.forEach((n,o)=>{r[i+(o===0?"":o+1)]=n})}),r}};be.add(Pf);async function $f(s){if("Image"in globalThis)return new Promise(t=>{const r=new Image;r.onload=()=>{t(!0)},r.onerror=()=>{t(!1)},r.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Mf={extension:{type:Kt.DetectionParser,priority:1},test:async()=>$f("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")};be.add(Mf);const Df={extension:{type:Kt.DetectionParser,priority:0},test:async()=>$f("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};be.add(Df);const Rf=["png","jpg","jpeg"],If={extension:{type:Kt.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Rf],remove:async s=>s.filter(t=>!Rf.includes(t))};be.add(If);const xg="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function zl(s){return xg?!1:document.createElement("video").canPlayType(s)!==""}const Ff={extension:{type:Kt.DetectionParser,priority:0},test:async()=>zl("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")};be.add(Ff);const Lf={extension:{type:Kt.DetectionParser,priority:0},test:async()=>zl("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")};be.add(Lf);const kf={extension:{type:Kt.DetectionParser,priority:0},test:async()=>zl("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")};be.add(kf);const Bf={extension:Kt.ResolveParser,test:Qn.test,parse:s=>{var t;return{resolution:parseFloat(((t=ue.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:$r.extname(s).slice(1),src:s}}};be.add(Bf);var Fr=(s=>(s[s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",s[s.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",s[s.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",s[s.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",s[s.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",s[s.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",s[s.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",s[s.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",s[s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",s[s.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",s[s.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",s[s.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",s[s.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",s[s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",s[s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",s[s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",s))(Fr||{});const Jn={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,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let qi,ln;function Of(){ln={bptc:qi.getExtension("EXT_texture_compression_bptc"),astc:qi.getExtension("WEBGL_compressed_texture_astc"),etc:qi.getExtension("WEBGL_compressed_texture_etc"),s3tc:qi.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:qi.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:qi.getExtension("WEBGL_compressed_texture_pvrtc")||qi.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:qi.getExtension("WEBGL_compressed_texture_etc1"),atc:qi.getExtension("WEBGL_compressed_texture_atc")}}const Nf={extension:{type:Kt.DetectionParser,priority:2},test:async()=>{const s=ue.ADAPTER.createCanvas().getContext("webgl");return s?(qi=s,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async s=>{ln||Of();const t=[];for(const r in ln)ln[r]&&t.push(r);return[...t,...s]},remove:async s=>(ln||Of(),s.filter(t=>!(t in ln)))};be.add(Nf);class Uf extends Rn{constructor(t,r={width:1,height:1,autoLoad:!0}){let i,n;typeof t=="string"?(i=t,n=new Uint8Array):(i=null,n=t),super(n,r),this.origin=i,this.buffer=n?new Vo(n):null,this._load=null,this.loaded=!1,this.origin!==null&&r.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?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 Vo(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Cs extends Uf{constructor(t,r){super(t,r),this.format=r.format,this.levels=r.levels||1,this._width=r.width,this._height=r.height,this._extension=Cs._formatToExtension(this.format),(r.levelBuffers||this.buffer)&&(this._levelBuffers=r.levelBuffers||Cs._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,r,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;n.pixelStorei(n.UNPACK_ALIGNMENT,4);for(let o=0,h=this.levels;o<h;o++){const{levelID:c,levelWidth:b,levelHeight:T,levelBuffer:C}=this._levelBuffers[o];n.compressedTexImage2D(n.TEXTURE_2D,c,this.format,b,T,0,C)}return!0}onBlobLoaded(){this._levelBuffers=Cs._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,r,i,n,o,h,c){const b=new Array(i);let T=t.byteOffset,C=h,x=c,$=C+n-1&~(n-1),I=x+o-1&~(o-1),B=$*I*Jn[r];for(let U=0;U<i;U++)b[U]={levelID:U,levelWidth:i>1?C:$,levelHeight:i>1?x:I,levelBuffer:new Uint8Array(t.buffer,T,B)},T+=B,C=C>>1||1,x=x>>1||1,$=C+n-1&~(n-1),I=x+o-1&~(o-1),B=$*I*Jn[r];return b}}const Wl=4,da=124,bg=32,Gf=20,Ag=542327876,pa={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},wg={FOURCC:2},_a={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},Tg=1,Eg=2,Cg=4,Sg=64,Pg=512,$g=131072,Mg=827611204,Dg=861165636,Rg=894720068,Ig=808540228,Fg=4,Lg={[Mg]:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Dg]:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Rg]:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT},kg={70:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Fr.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Fr.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Fr.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Fr.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function Vf(s){const t=new Uint32Array(s);if(t[0]!==Ag)throw new Error("Invalid DDS file magic word");const r=new Uint32Array(s,0,da/Uint32Array.BYTES_PER_ELEMENT),i=r[pa.HEIGHT],n=r[pa.WIDTH],o=r[pa.MIPMAP_COUNT],h=new Uint32Array(s,pa.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,bg/Uint32Array.BYTES_PER_ELEMENT),c=h[Tg];if(c&Cg){const b=h[wg.FOURCC];if(b!==Ig){const J=Lg[b],Z=Wl+da,it=new Uint8Array(s,Z);return[new Cs(it,{format:J,width:n,height:i,levels:o})]}const T=Wl+da,C=new Uint32Array(t.buffer,T,Gf/Uint32Array.BYTES_PER_ELEMENT),x=C[_a.DXGI_FORMAT],$=C[_a.RESOURCE_DIMENSION],I=C[_a.MISC_FLAG],B=C[_a.ARRAY_SIZE],U=kg[x];if(U===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${x}`);if(I===Fg)throw new Error("DDSParser does not support cubemap textures");if($===6)throw new Error("DDSParser does not supported 3D texture data");const G=new Array,z=Wl+da+Gf;if(B===1)G.push(new Uint8Array(s,z));else{const J=Jn[U];let Z=0,it=n,Q=i;for(let et=0;et<o;et++){const ft=Math.max(1,it+3&-4),wt=Math.max(1,Q+3&-4),Dt=ft*wt*J;Z+=Dt,it=it>>>1,Q=Q>>>1}let _t=z;for(let et=0;et<B;et++)G.push(new Uint8Array(s,_t,Z)),_t+=Z}return G.map(J=>new Cs(J,{format:U,width:n,height:i,levels:o}))}throw c&Sg?new Error("DDSParser does not support uncompressed texture data."):c&Pg?new Error("DDSParser does not supported YUV uncompressed texture data."):c&$g?new Error("DDSParser does not support single-channel (lumninance) texture data!"):c&Eg?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 Xf=[171,75,84,88,32,49,49,187,13,10,26,10],Bg=67305985,Di={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,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},Hl=64,Yl={[Pe.UNSIGNED_BYTE]:1,[Pe.UNSIGNED_SHORT]:2,[Pe.INT]:4,[Pe.UNSIGNED_INT]:4,[Pe.FLOAT]:4,[Pe.HALF_FLOAT]:8},zf={[qt.RGBA]:4,[qt.RGB]:3,[qt.RG]:2,[qt.RED]:1,[qt.LUMINANCE]:1,[qt.LUMINANCE_ALPHA]:2,[qt.ALPHA]:1},Wf={[Pe.UNSIGNED_SHORT_4_4_4_4]:2,[Pe.UNSIGNED_SHORT_5_5_5_1]:2,[Pe.UNSIGNED_SHORT_5_6_5]:2};function Hf(s,t,r=!1){const i=new DataView(t);if(!Og(s,i))return null;const n=i.getUint32(Di.ENDIANNESS,!0)===Bg,o=i.getUint32(Di.GL_TYPE,n),h=i.getUint32(Di.GL_FORMAT,n),c=i.getUint32(Di.GL_INTERNAL_FORMAT,n),b=i.getUint32(Di.PIXEL_WIDTH,n),T=i.getUint32(Di.PIXEL_HEIGHT,n)||1,C=i.getUint32(Di.PIXEL_DEPTH,n)||1,x=i.getUint32(Di.NUMBER_OF_ARRAY_ELEMENTS,n)||1,$=i.getUint32(Di.NUMBER_OF_FACES,n),I=i.getUint32(Di.NUMBER_OF_MIPMAP_LEVELS,n),B=i.getUint32(Di.BYTES_OF_KEY_VALUE_DATA,n);if(T===0||C!==1)throw new Error("Only 2D textures are supported");if($!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(x!==1)throw new Error("WebGL does not support array textures");const U=4,G=4,z=b+3&-4,J=T+3&-4,Z=new Array(x);let it=b*T;o===0&&(it=z*J);let Q;if(o!==0?Yl[o]?Q=Yl[o]*zf[h]:Q=Wf[o]:Q=Jn[c],Q===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const _t=r?Ug(i,B,n):null;let et=it*Q,ft=b,wt=T,Dt=z,Rt=J,pt=Hl+B;for(let xt=0;xt<I;xt++){const Ct=i.getUint32(pt,n);let Gt=pt+4;for(let st=0;st<x;st++){let nt=Z[st];nt||(nt=Z[st]=new Array(I)),nt[xt]={levelID:xt,levelWidth:I>1||o!==0?ft:Dt,levelHeight:I>1||o!==0?wt:Rt,levelBuffer:new Uint8Array(t,Gt,et)},Gt+=et}pt+=Ct+4,pt=pt%4!==0?pt+4-pt%4:pt,ft=ft>>1||1,wt=wt>>1||1,Dt=ft+U-1&-4,Rt=wt+G-1&-4,et=Dt*Rt*Q}return o!==0?{uncompressed:Z.map(xt=>{let Ct=xt[0].levelBuffer,Gt=!1;return o===Pe.FLOAT?Ct=new Float32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4):o===Pe.UNSIGNED_INT?(Gt=!0,Ct=new Uint32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4)):o===Pe.INT&&(Gt=!0,Ct=new Int32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4)),{resource:new Rn(Ct,{width:xt[0].levelWidth,height:xt[0].levelHeight}),type:o,format:Gt?Ng(h):h}}),kvData:_t}:{compressed:Z.map(xt=>new Cs(null,{format:c,width:b,height:T,levels:I,levelBuffers:xt})),kvData:_t}}function Og(s,t){for(let r=0;r<Xf.length;r++)if(t.getUint8(r)!==Xf[r])return console.error(`${s} is not a valid *.ktx file!`),!1;return!0}function Ng(s){switch(s){case qt.RGBA:return qt.RGBA_INTEGER;case qt.RGB:return qt.RGB_INTEGER;case qt.RG:return qt.RG_INTEGER;case qt.RED:return qt.RED_INTEGER;default:return s}}function Ug(s,t,r){const i=new Map;let n=0;for(;n<t;){const o=s.getUint32(Hl+n,r),h=Hl+n+4,c=3-(o+3)%4;if(o===0||o>t-n){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let b=0;for(;b<o&&s.getUint8(h+b)!==0;b++);if(b===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const T=new TextDecoder().decode(new Uint8Array(s.buffer,h,b)),C=new DataView(s.buffer,h+b+1,o-b-1);i.set(T,C),n+=4+o+c}return i}const Yf={extension:{type:Kt.LoadParser,priority:_i.High},name:"loadDDS",test(s){return cs(s,".dds")},async load(s,t,r){const i=await(await ue.ADAPTER.fetch(s)).arrayBuffer(),n=Vf(i).map(o=>{const h=new Ge(o,{mipmap:wi.OFF,alphaMode:Vr.NO_PREMULTIPLIED_ALPHA,resolution:Wi(s),...t.data});return hn(h,r,s)});return n.length===1?n[0]:n},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};be.add(Yf);const jf={extension:{type:Kt.LoadParser,priority:_i.High},name:"loadKTX",test(s){return cs(s,".ktx")},async load(s,t,r){const i=await(await ue.ADAPTER.fetch(s)).arrayBuffer(),{compressed:n,uncompressed:o,kvData:h}=Hf(s,i),c=n??o,b={mipmap:wi.OFF,alphaMode:Vr.NO_PREMULTIPLIED_ALPHA,resolution:Wi(s),...t.data},T=c.map(C=>{c===o&&Object.assign(b,{type:C.type,format:C.format});const x=C.resource??C,$=new Ge(x,b);return $.ktxKeyValueData=h,hn($,r,s)});return T.length===1?T[0]:T},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};be.add(jf);const Gg=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],qf={extension:Kt.ResolveParser,test:s=>{const t=$r.extname(s).slice(1);return["basis","ktx","dds"].includes(t)},parse:s=>{var i,n;const t=s.split("."),r=t.pop();if(["ktx","dds"].includes(r)){const o=t.pop();if(Gg.includes(o))return{resolution:parseFloat(((i=ue.RETINA_PREFIX.exec(s))==null?void 0:i[1])??"1"),format:o,src:s}}return{resolution:parseFloat(((n=ue.RETINA_PREFIX.exec(s))==null?void 0:n[1])??"1"),format:r,src:s}}};be.add(qf);const ga=new Ve,Vg=4,Zf=class Ro{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var r;const t=(r=this.renderer)==null?void 0:r.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,r,i,n){const o=new Image;return o.src=await this.base64(t,r,i,n),o}async base64(t,r,i,n){const o=this.canvas(t,n);if(o.toBlob!==void 0)return new Promise((h,c)=>{o.toBlob(b=>{if(!b){c(new Error("ICanvas.toBlob failed!"));return}const T=new FileReader;T.onload=()=>h(T.result),T.onerror=c,T.readAsDataURL(b)},r,i)});if(o.toDataURL!==void 0)return o.toDataURL(r,i);if(o.convertToBlob!==void 0){const h=await o.convertToBlob({type:r,quality:i});return new Promise((c,b)=>{const T=new FileReader;T.onload=()=>c(T.result),T.onerror=b,T.readAsDataURL(h)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,r){const{pixels:i,width:n,height:o,flipY:h,premultipliedAlpha:c}=this._rawPixels(t,r);h&&Ro._flipY(i,n,o),c&&Ro._unpremultiplyAlpha(i);const b=new Jc(n,o,1),T=new ImageData(new Uint8ClampedArray(i.buffer),n,o);return b.context.putImageData(T,0,0),b.canvas}pixels(t,r){const{pixels:i,width:n,height:o,flipY:h,premultipliedAlpha:c}=this._rawPixels(t,r);return h&&Ro._flipY(i,n,o),c&&Ro._unpremultiplyAlpha(i),i}_rawPixels(t,r){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let n,o=!1,h=!1,c,b=!1;t&&(t instanceof As?c=t:(c=i.generateTexture(t,{region:r,resolution:i.resolution,multisample:i.multisample}),b=!0,r&&(ga.width=r.width,ga.height=r.height,r=ga)));const T=i.gl;if(c){if(n=c.baseTexture.resolution,r=r??c.frame,o=!1,h=c.baseTexture.alphaMode>0&&c.baseTexture.format===qt.RGBA,!b){i.renderTexture.bind(c);const I=c.framebuffer.glFramebuffers[i.CONTEXT_UID];I.blitFramebuffer&&i.framebuffer.bind(I.blitFramebuffer)}}else n=i.resolution,r||(r=ga,r.width=i.width/n,r.height=i.height/n),o=!0,h=this._rendererPremultipliedAlpha,i.renderTexture.bind();const C=Math.max(Math.round(r.width*n),1),x=Math.max(Math.round(r.height*n),1),$=new Uint8Array(Vg*C*x);return T.readPixels(Math.round(r.x*n),Math.round(r.y*n),C,x,T.RGBA,T.UNSIGNED_BYTE,$),b&&(c==null||c.destroy(!0)),{pixels:$,width:C,height:x,flipY:o,premultipliedAlpha:h}}destroy(){this.renderer=null}static _flipY(t,r,i){const n=r<<2,o=i>>1,h=new Uint8Array(n);for(let c=0;c<o;c++){const b=c*n,T=(i-c-1)*n;h.set(t.subarray(b,b+n)),t.copyWithin(b,T,T+n),t.set(h,T)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const r=t.length;for(let i=0;i<r;i+=4){const n=t[i+3];if(n!==0){const o=255.001/n;t[i]=t[i]*o+.5,t[i+1]=t[i+1]*o+.5,t[i+2]=t[i+2]*o+.5}}}};Zf.extension={name:"extract",type:Kt.RendererSystem};let Qf=Zf;be.add(Qf);const to={build(s){const t=s.points;let r,i,n,o,h,c;if(s.type===Ir.CIRC){const B=s.shape;r=B.x,i=B.y,h=c=B.radius,n=o=0}else if(s.type===Ir.ELIP){const B=s.shape;r=B.x,i=B.y,h=B.width,c=B.height,n=o=0}else{const B=s.shape,U=B.width/2,G=B.height/2;r=B.x+U,i=B.y+G,h=c=Math.max(0,Math.min(B.radius,Math.min(U,G))),n=U-h,o=G-c}if(!(h>=0&&c>=0&&n>=0&&o>=0)){t.length=0;return}const b=Math.ceil(2.3*Math.sqrt(h+c)),T=b*8+(n?4:0)+(o?4:0);if(t.length=T,T===0)return;if(b===0){t.length=8,t[0]=t[6]=r+n,t[1]=t[3]=i+o,t[2]=t[4]=r-n,t[5]=t[7]=i-o;return}let C=0,x=b*4+(n?2:0)+2,$=x,I=T;{const B=n+h,U=o,G=r+B,z=r-B,J=i+U;if(t[C++]=G,t[C++]=J,t[--x]=J,t[--x]=z,o){const Z=i-U;t[$++]=z,t[$++]=Z,t[--I]=Z,t[--I]=G}}for(let B=1;B<b;B++){const U=Math.PI/2*(B/b),G=n+Math.cos(U)*h,z=o+Math.sin(U)*c,J=r+G,Z=r-G,it=i+z,Q=i-z;t[C++]=J,t[C++]=it,t[--x]=it,t[--x]=Z,t[$++]=Z,t[$++]=Q,t[--I]=Q,t[--I]=J}{const B=n,U=o+c,G=r+B,z=r-B,J=i+U,Z=i-U;t[C++]=G,t[C++]=J,t[--I]=Z,t[--I]=G,n&&(t[C++]=z,t[C++]=J,t[--I]=Z,t[--I]=z)}},triangulate(s,t){const r=s.points,i=t.points,n=t.indices;if(r.length===0)return;let o=i.length/2;const h=o;let c,b;if(s.type!==Ir.RREC){const C=s.shape;c=C.x,b=C.y}else{const C=s.shape;c=C.x+C.width/2,b=C.y+C.height/2}const T=s.matrix;i.push(s.matrix?T.a*c+T.c*b+T.tx:c,s.matrix?T.b*c+T.d*b+T.ty:b),o++,i.push(r[0],r[1]);for(let C=2;C<r.length;C+=2)i.push(r[C],r[C+1]),n.push(o++,h,o);n.push(h+1,h,o)}};function Kf(s,t=!1){const r=s.length;if(r<6)return;let i=0;for(let n=0,o=s[r-2],h=s[r-1];n<r;n+=2){const c=s[n],b=s[n+1];i+=(c-o)*(b+h),o=c,h=b}if(!t&&i>0||t&&i<=0){const n=r/2;for(let o=n+n%2;o<r;o+=2){const h=r-o-2,c=r-o-1,b=o,T=o+1;[s[h],s[b]]=[s[b],s[h]],[s[c],s[T]]=[s[T],s[c]]}}}const jl={build(s){s.points=s.shape.points.slice()},triangulate(s,t){let r=s.points;const i=s.holes,n=t.points,o=t.indices;if(r.length>=6){Kf(r,!1);const h=[];for(let T=0;T<i.length;T++){const C=i[T];Kf(C.points,!0),h.push(r.length/2),r=r.concat(C.points)}const c=rc(r,h,2);if(!c)return;const b=n.length/2;for(let T=0;T<c.length;T+=3)o.push(c[T]+b),o.push(c[T+1]+b),o.push(c[T+2]+b);for(let T=0;T<r.length;T++)n.push(r[T])}}},Jf={build(s){const t=s.shape,r=t.x,i=t.y,n=t.width,o=t.height,h=s.points;h.length=0,n>=0&&o>=0&&h.push(r,i,r+n,i,r+n,i+o,r,i+o)},triangulate(s,t){const r=s.points,i=t.points;if(r.length===0)return;const n=i.length/2;i.push(r[0],r[1],r[2],r[3],r[6],r[7],r[4],r[5]),t.indices.push(n,n+1,n+2,n+1,n+2,n+3)}},td={build(s){to.build(s)},triangulate(s,t){to.triangulate(s,t)}};var ni=(s=>(s.MITER="miter",s.BEVEL="bevel",s.ROUND="round",s))(ni||{}),fs=(s=>(s.BUTT="butt",s.ROUND="round",s.SQUARE="square",s))(fs||{});const Ss={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(s,t=20){if(!this.adaptive||!s||isNaN(s))return t;let r=Math.ceil(s/this.maxLength);return r<this.minSegments?r=this.minSegments:r>this.maxSegments&&(r=this.maxSegments),r}},Xg=Ss;class ql{static curveTo(t,r,i,n,o,h){const c=h[h.length-2],b=h[h.length-1]-r,T=c-t,C=n-r,x=i-t,$=Math.abs(b*x-T*C);if($<1e-8||o===0)return(h[h.length-2]!==t||h[h.length-1]!==r)&&h.push(t,r),null;const I=b*b+T*T,B=C*C+x*x,U=b*C+T*x,G=o*Math.sqrt(I)/$,z=o*Math.sqrt(B)/$,J=G*U/I,Z=z*U/B,it=G*x+z*T,Q=G*C+z*b,_t=T*(z+J),et=b*(z+J),ft=x*(G+Z),wt=C*(G+Z),Dt=Math.atan2(et-Q,_t-it),Rt=Math.atan2(wt-Q,ft-it);return{cx:it+t,cy:Q+r,radius:o,startAngle:Dt,endAngle:Rt,anticlockwise:T*C>x*b}}static arc(t,r,i,n,o,h,c,b,T){const C=c-h,x=Ss._segmentsCount(Math.abs(C)*o,Math.ceil(Math.abs(C)/Fn)*40),$=C/(x*2),I=$*2,B=Math.cos($),U=Math.sin($),G=x-1,z=G%1/G;for(let J=0;J<=G;++J){const Z=J+z*J,it=$+h+I*Z,Q=Math.cos(it),_t=-Math.sin(it);T.push((B*Q+U*_t)*o+i,(B*-_t+U*Q)*o+n)}}}class ed{constructor(){this.reset()}begin(t,r,i){this.reset(),this.style=t,this.start=r,this.attribStart=i}end(t,r){this.attribSize=r-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class ma{static curveLength(t,r,i,n,o,h,c,b){let T=0,C=0,x=0,$=0,I=0,B=0,U=0,G=0,z=0,J=0,Z=0,it=t,Q=r;for(let _t=1;_t<=10;++_t)C=_t/10,x=C*C,$=x*C,I=1-C,B=I*I,U=B*I,G=U*t+3*B*C*i+3*I*x*o+$*c,z=U*r+3*B*C*n+3*I*x*h+$*b,J=it-G,Z=Q-z,it=G,Q=z,T+=Math.sqrt(J*J+Z*Z);return T}static curveTo(t,r,i,n,o,h,c){const b=c[c.length-2],T=c[c.length-1];c.length-=2;const C=Ss._segmentsCount(ma.curveLength(b,T,t,r,i,n,o,h));let x=0,$=0,I=0,B=0,U=0;c.push(b,T);for(let G=1,z=0;G<=C;++G)z=G/C,x=1-z,$=x*x,I=$*x,B=z*z,U=B*z,c.push(I*b+3*$*z*t+3*x*B*i+U*o,I*T+3*$*z*r+3*x*B*n+U*h)}}function rd(s,t,r,i,n,o,h,c){const b=s-r*n,T=t-i*n,C=s+r*o,x=t+i*o;let $,I;h?($=i,I=-r):($=-i,I=r);const B=b+$,U=T+I,G=C+$,z=x+I;return c.push(B,U,G,z),2}function Hs(s,t,r,i,n,o,h,c){const b=r-s,T=i-t;let C=Math.atan2(b,T),x=Math.atan2(n-s,o-t);c&&C<x?C+=Math.PI*2:!c&&C>x&&(x+=Math.PI*2);let $=C;const I=x-C,B=Math.abs(I),U=Math.sqrt(b*b+T*T),G=(15*B*Math.sqrt(U)/Math.PI>>0)+1,z=I/G;if($+=z,c){h.push(s,t,r,i);for(let J=1,Z=$;J<G;J++,Z+=z)h.push(s,t,s+Math.sin(Z)*U,t+Math.cos(Z)*U);h.push(s,t,n,o)}else{h.push(r,i,s,t);for(let J=1,Z=$;J<G;J++,Z+=z)h.push(s+Math.sin(Z)*U,t+Math.cos(Z)*U,s,t);h.push(n,o,s,t)}return G*2}function zg(s,t){const r=s.shape;let i=s.points||r.points.slice();const n=t.closePointEps;if(i.length===0)return;const o=s.lineStyle,h=new He(i[0],i[1]),c=new He(i[i.length-2],i[i.length-1]),b=r.type!==Ir.POLY||r.closeStroke,T=Math.abs(h.x-c.x)<n&&Math.abs(h.y-c.y)<n;if(b){i=i.slice(),T&&(i.pop(),i.pop(),c.set(i[i.length-2],i[i.length-1]));const nt=(h.x+c.x)*.5,Y=(c.y+h.y)*.5;i.unshift(nt,Y),i.push(nt,Y)}const C=t.points,x=i.length/2;let $=i.length;const I=C.length/2,B=o.width/2,U=B*B,G=o.miterLimit*o.miterLimit;let z=i[0],J=i[1],Z=i[2],it=i[3],Q=0,_t=0,et=-(J-it),ft=z-Z,wt=0,Dt=0,Rt=Math.sqrt(et*et+ft*ft);et/=Rt,ft/=Rt,et*=B,ft*=B;const pt=o.alignment,xt=(1-pt)*2,Ct=pt*2;b||(o.cap===fs.ROUND?$+=Hs(z-et*(xt-Ct)*.5,J-ft*(xt-Ct)*.5,z-et*xt,J-ft*xt,z+et*Ct,J+ft*Ct,C,!0)+2:o.cap===fs.SQUARE&&($+=rd(z,J,et,ft,xt,Ct,!0,C))),C.push(z-et*xt,J-ft*xt,z+et*Ct,J+ft*Ct);for(let nt=1;nt<x-1;++nt){z=i[(nt-1)*2],J=i[(nt-1)*2+1],Z=i[nt*2],it=i[nt*2+1],Q=i[(nt+1)*2],_t=i[(nt+1)*2+1],et=-(J-it),ft=z-Z,Rt=Math.sqrt(et*et+ft*ft),et/=Rt,ft/=Rt,et*=B,ft*=B,wt=-(it-_t),Dt=Z-Q,Rt=Math.sqrt(wt*wt+Dt*Dt),wt/=Rt,Dt/=Rt,wt*=B,Dt*=B;const Y=Z-z,gt=J-it,ot=Z-Q,ht=_t-it,dt=Y*ot+gt*ht,At=gt*ot-ht*Y,Et=At<0;if(Math.abs(At)<.001*Math.abs(dt)){C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),dt>=0&&(o.join===ni.ROUND?$+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Dt*xt,C,!1)+4:$+=2,C.push(Z-wt*Ct,it-Dt*Ct,Z+wt*xt,it+Dt*xt));continue}const It=(-et+z)*(-ft+it)-(-et+Z)*(-ft+J),oe=(-wt+Q)*(-Dt+it)-(-wt+Z)*(-Dt+_t),Bt=(Y*oe-ot*It)/At,se=(ht*It-gt*oe)/At,Jt=(Bt-Z)*(Bt-Z)+(se-it)*(se-it),zt=Z+(Bt-Z)*xt,_e=it+(se-it)*xt,$e=Z-(Bt-Z)*Ct,te=it-(se-it)*Ct,Ie=Math.min(Y*Y+gt*gt,ot*ot+ht*ht),xe=Et?xt:Ct,ae=Ie+xe*xe*U,Lr=Jt<=ae;let xr=o.join;if(xr===ni.MITER&&Jt/U>G&&(xr=ni.BEVEL),Lr)switch(xr){case ni.MITER:{C.push(zt,_e,$e,te);break}case ni.BEVEL:{Et?C.push(zt,_e,Z+et*Ct,it+ft*Ct,zt,_e,Z+wt*Ct,it+Dt*Ct):C.push(Z-et*xt,it-ft*xt,$e,te,Z-wt*xt,it-Dt*xt,$e,te),$+=2;break}case ni.ROUND:{Et?(C.push(zt,_e,Z+et*Ct,it+ft*Ct),$+=Hs(Z,it,Z+et*Ct,it+ft*Ct,Z+wt*Ct,it+Dt*Ct,C,!0)+4,C.push(zt,_e,Z+wt*Ct,it+Dt*Ct)):(C.push(Z-et*xt,it-ft*xt,$e,te),$+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Dt*xt,C,!1)+4,C.push(Z-wt*xt,it-Dt*xt,$e,te));break}}else{switch(C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),xr){case ni.MITER:{Et?C.push($e,te,$e,te):C.push(zt,_e,zt,_e),$+=2;break}case ni.ROUND:{Et?$+=Hs(Z,it,Z+et*Ct,it+ft*Ct,Z+wt*Ct,it+Dt*Ct,C,!0)+2:$+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Dt*xt,C,!1)+2;break}}C.push(Z-wt*xt,it-Dt*xt,Z+wt*Ct,it+Dt*Ct),$+=2}}z=i[(x-2)*2],J=i[(x-2)*2+1],Z=i[(x-1)*2],it=i[(x-1)*2+1],et=-(J-it),ft=z-Z,Rt=Math.sqrt(et*et+ft*ft),et/=Rt,ft/=Rt,et*=B,ft*=B,C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),b||(o.cap===fs.ROUND?$+=Hs(Z-et*(xt-Ct)*.5,it-ft*(xt-Ct)*.5,Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct,C,!1)+2:o.cap===fs.SQUARE&&($+=rd(Z,it,et,ft,xt,Ct,!1,C)));const Gt=t.indices,st=Ss.epsilon*Ss.epsilon;for(let nt=I;nt<$+I-2;++nt)z=C[nt*2],J=C[nt*2+1],Z=C[(nt+1)*2],it=C[(nt+1)*2+1],Q=C[(nt+2)*2],_t=C[(nt+2)*2+1],!(Math.abs(z*(it-_t)+Z*(_t-J)+Q*(J-it))<st)&&Gt.push(nt,nt+1,nt+2)}function Wg(s,t){let r=0;const i=s.shape,n=s.points||i.points,o=i.type!==Ir.POLY||i.closeStroke;if(n.length===0)return;const h=t.points,c=t.indices,b=n.length/2,T=h.length/2;let C=T;for(h.push(n[0],n[1]),r=1;r<b;r++)h.push(n[r*2],n[r*2+1]),c.push(C,C+1),C++;o&&c.push(C,T)}function Zl(s,t){s.lineStyle.native?Wg(s,t):zg(s,t)}class ya{static curveLength(t,r,i,n,o,h){const c=t-2*i+o,b=r-2*n+h,T=2*i-2*t,C=2*n-2*r,x=4*(c*c+b*b),$=4*(c*T+b*C),I=T*T+C*C,B=2*Math.sqrt(x+$+I),U=Math.sqrt(x),G=2*x*U,z=2*Math.sqrt(I),J=$/U;return(G*B+U*$*(B-z)+(4*I*x-$*$)*Math.log((2*U+J+B)/(J+z)))/(4*G)}static curveTo(t,r,i,n,o){const h=o[o.length-2],c=o[o.length-1],b=Ss._segmentsCount(ya.curveLength(h,c,t,r,i,n));let T=0,C=0;for(let x=1;x<=b;++x){const $=x/b;T=h+(t-h)*$,C=c+(r-c)*$,o.push(T+(t+(i-t)*$-T)*$,C+(r+(n-r)*$-C)*$)}}}const va={[Ir.POLY]:jl,[Ir.CIRC]:to,[Ir.ELIP]:to,[Ir.RECT]:Jf,[Ir.RREC]:td},Ql=[],eo=[];class ro{constructor(t,r=null,i=null,n=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=r,this.matrix=n,this.type=t.type}clone(){return new ro(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 un=new He,sd=class x2 extends el{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 Yn,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 t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),eo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const r=this.batches[t];r.reset(),Ql.push(r)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,r=null,i=null,n=null){const o=new ro(t,r,i,n);return this.graphicsData.push(o),this.dirty++,this}drawHole(t,r=null){if(!this.graphicsData.length)return null;const i=new ro(t,null,null,r),n=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=n.lineStyle,n.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const r=this.graphicsData;for(let i=0;i<r.length;++i){const n=r[i];if(n.fillStyle.visible&&n.shape&&(n.matrix?n.matrix.applyInverse(t,un):un.copyFrom(t),n.shape.contains(un.x,un.y))){let o=!1;if(n.holes){for(let h=0;h<n.holes.length;h++)if(n.holes[h].shape.contains(un.x,un.y)){o=!0;break}}if(!o)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,r=this.graphicsData;let i=null,n=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],n=i.style);for(let b=this.shapeIndex;b<r.length;b++){this.shapeIndex++;const T=r[b],C=T.fillStyle,x=T.lineStyle;va[T.type].build(T),T.matrix&&this.transformPoints(T.points,T.matrix),(C.visible||x.visible)&&this.processHoles(T.holes);for(let $=0;$<2;$++){const I=$===0?C:x;if(!I.visible)continue;const B=I.texture.baseTexture,U=this.indices.length,G=this.points.length/2;B.wrapMode=Vi.REPEAT,$===0?this.processFill(T):this.processLine(T);const z=this.points.length/2-G;z!==0&&(i&&!this._compareStyles(n,I)&&(i.end(U,G),i=null),i||(i=Ql.pop()||new ed,i.begin(I,U,G),this.batches.push(i),n=I),this.addUvs(this.points,t,I.texture,G,z,I.matrix))}}const o=this.indices.length,h=this.points.length/2;if(i&&i.end(o,h),this.batches.length===0){this.batchable=!0;return}const c=h>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&c===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=c?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,r){return!(!t||!r||t.texture.baseTexture!==r.texture.baseTexture||t.color+t.alpha!==r.color+r.alpha||!!t.native!=!!r.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,r=this.graphicsData.length;t<r;t++){const i=this.graphicsData[t],n=i.fillStyle,o=i.lineStyle;if(n&&!n.texture.baseTexture.valid||o&&!o.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let r=0,i=t.length;r<i;r++){const n=t[r];for(let o=0;o<n.size;o++){const h=n.start+o;this.indicesUint16[h]=this.indicesUint16[h]-n.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let r=0;r<t.length;r++)if(t[r].style.native)return!1;return this.points.length<x2.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++Ge._globalBatch;for(let x=0;x<this.drawCalls.length;x++)this.drawCalls[x].texArray.clear(),eo.push(this.drawCalls[x]);this.drawCalls.length=0;const r=this.colors,i=this.textureIds;let n=eo.pop();n||(n=new zo,n.texArray=new Zo),n.texArray.count=0,n.start=0,n.size=0,n.type=Ai.TRIANGLES;let o=0,h=null,c=0,b=!1,T=Ai.TRIANGLES,C=0;this.drawCalls.push(n);for(let x=0;x<this.batches.length;x++){const $=this.batches[x],I=8,B=$.style,U=B.texture.baseTexture;b!==!!B.native&&(b=!!B.native,T=b?Ai.LINES:Ai.TRIANGLES,h=null,o=I,t++),h!==U&&(h=U,U._batchEnabled!==t&&(o===I&&(t++,o=0,n.size>0&&(n=eo.pop(),n||(n=new zo,n.texArray=new Zo),this.drawCalls.push(n)),n.start=C,n.size=0,n.texArray.count=0,n.type=T),U.touched=1,U._batchEnabled=t,U._batchLocation=o,U.wrapMode=Vi.REPEAT,n.texArray.elements[n.texArray.count++]=U,o++)),n.size+=$.size,C+=$.size,c=U._batchLocation,this.addColors(r,B.color,B.alpha,$.attribSize,$.attribStart),this.addTextureIds(i,c,$.attribSize,$.attribStart)}Ge._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,r=this.uvs,i=this.colors,n=this.textureIds,o=new ArrayBuffer(t.length*3*4),h=new Float32Array(o),c=new Uint32Array(o);let b=0;for(let T=0;T<t.length/2;T++)h[b++]=t[T*2],h[b++]=t[T*2+1],h[b++]=r[T*2],h[b++]=r[T*2+1],c[b++]=i[T],h[b++]=n[T];this._buffer.update(o),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?jl.triangulate(t,this):va[t.type].triangulate(t,this)}processLine(t){Zl(t,this);for(let r=0;r<t.holes.length;r++)Zl(t.holes[r],this)}processHoles(t){for(let r=0;r<t.length;r++){const i=t[r];va[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,r){for(let i=0;i<t.length/2;i++){const n=t[i*2],o=t[i*2+1];t[i*2]=r.a*n+r.c*o+r.tx,t[i*2+1]=r.b*n+r.d*o+r.ty}}addColors(t,r,i,n,o=0){const h=rr.shared.setValue(r).toLittleEndianNumber(),c=rr.shared.setValue(h).toPremultiplied(i);t.length=Math.max(t.length,o+n);for(let b=0;b<n;b++)t[o+b]=c}addTextureIds(t,r,i,n=0){t.length=Math.max(t.length,n+i);for(let o=0;o<i;o++)t[n+o]=r}addUvs(t,r,i,n,o,h=null){let c=0;const b=r.length,T=i.frame;for(;c<o;){let x=t[(n+c)*2],$=t[(n+c)*2+1];if(h){const I=h.a*x+h.c*$+h.tx;$=h.b*x+h.d*$+h.ty,x=I}c++,r.push(x/T.width,$/T.height)}const C=i.baseTexture;(T.width<C.width||T.height<C.height)&&this.adjustUvs(r,i,b,o)}adjustUvs(t,r,i,n){const o=r.baseTexture,h=1e-6,c=i+n*2,b=r.frame,T=b.width/o.width,C=b.height/o.height;let x=b.x/b.width,$=b.y/b.height,I=Math.floor(t[i]+h),B=Math.floor(t[i+1]+h);for(let U=i+2;U<c;U+=2)I=Math.min(I,Math.floor(t[U]+h)),B=Math.min(B,Math.floor(t[U+1]+h));x-=I,$-=B;for(let U=i;U<c;U+=2)t[U]=(t[U]+x)*T,t[U+1]=(t[U+1]+$)*C}};sd.BATCHABLE_SIZE=100;let nd=sd;class io{constructor(){this.color=16777215,this.alpha=1,this.texture=ne.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new io;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=ne.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class xa extends io{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=fs.BUTT,this.join=ni.MITER,this.miterLimit=10}clone(){const t=new xa;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=fs.BUTT,this.join=ni.MITER,this.miterLimit=10}}const Kl={},Jl=class Ha extends Zr{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new io,this._lineStyle=new xa,this._matrix=null,this._holeMode=!1,this.state=Pi.for2d(),this._geometry=t||new nd,this._geometry.refCount++,this._transformID=-1,this._tintColor=new rr(16777215),this.blendMode=De.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Ha(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,r=0,i,n=.5,o=!1){return typeof t=="number"&&(t={width:t,color:r,alpha:i,alignment:n,native:o}),this.lineTextureStyle(t)}lineTextureStyle(t){const r={width:0,texture:ne.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:fs.BUTT,join:ni.MITER,miterLimit:10};t=Object.assign(r,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,r=this.currentPath.points.length;r>2&&(this.drawShape(this.currentPath),this.currentPath=new xs,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[r-2],t[r-1]))}else this.currentPath=new xs,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(t,r){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=r,this}lineTo(t,r){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,n=i[i.length-2],o=i[i.length-1];return(n!==t||o!==r)&&i.push(t,r),this}_initCurve(t=0,r=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,r]):this.moveTo(t,r)}quadraticCurveTo(t,r,i,n){this._initCurve();const o=this.currentPath.points;return o.length===0&&this.moveTo(0,0),ya.curveTo(t,r,i,n,o),this}bezierCurveTo(t,r,i,n,o,h){return this._initCurve(),ma.curveTo(t,r,i,n,o,h,this.currentPath.points),this}arcTo(t,r,i,n,o){this._initCurve(t,r);const h=this.currentPath.points,c=ql.curveTo(t,r,i,n,o,h);if(c){const{cx:b,cy:T,radius:C,startAngle:x,endAngle:$,anticlockwise:I}=c;this.arc(b,T,C,x,$,I)}return this}arc(t,r,i,n,o,h=!1){if(n===o)return this;if(!h&&o<=n?o+=Fn:h&&n<=o&&(n+=Fn),o-n===0)return this;const c=t+Math.cos(n)*i,b=r+Math.sin(n)*i,T=this._geometry.closePointEps;let C=this.currentPath?this.currentPath.points:null;if(C){const x=Math.abs(C[C.length-2]-c),$=Math.abs(C[C.length-1]-b);x<T&&$<T||C.push(c,b)}else this.moveTo(c,b),C=this.currentPath.points;return ql.arc(c,b,t,r,i,n,o,h,C),this}beginFill(t=0,r){return this.beginTextureFill({texture:ne.WHITE,color:t,alpha:r})}normalizeColor(t){const r=rr.shared.setValue(t.color??0);t.color=r.toNumber(),t.alpha??(t.alpha=r.alpha)}beginTextureFill(t){const r={texture:ne.WHITE,color:16777215,matrix:null};t=Object.assign(r,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,r,i,n){return this.drawShape(new Ve(t,r,i,n))}drawRoundedRect(t,r,i,n,o){return this.drawShape(new Bn(t,r,i,n,o))}drawCircle(t,r,i){return this.drawShape(new Ln(t,r,i))}drawEllipse(t,r,i,n){return this.drawShape(new kn(t,r,i,n))}drawPolygon(...t){let r,i=!0;const n=t[0];n.points?(i=n.closeStroke,r=n.points):Array.isArray(t[0])?r=t[0]:r=t;const o=new xs(r);return o.closeStroke=i,this.drawShape(o),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,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 t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Ir.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const r=this._geometry;r.updateBatches(),r.batchable?(this.batchDirty!==r.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,r=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let n=0;n<i;n++){const o=t.batches[n],h=o.style.color,c=new Float32Array(this.vertexData.buffer,o.attribStart*4*2,o.attribSize*2),b=new Float32Array(t.uvsFloat32.buffer,o.attribStart*4*2,o.attribSize*2),T=new Uint16Array(t.indicesUint16.buffer,o.start*2,o.size),C={vertexData:c,blendMode:r,indices:T,uvs:b,_batchRGB:rr.shared.setValue(h).toRgbArray(),_tintRGB:h,_texture:o.style.texture,alpha:o.style.alpha,worldAlpha:1};this.batches[n]=C}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let r=0,i=this.batches.length;r<i;r++){const n=this.batches[r];n.worldAlpha=this.worldAlpha*n.alpha,t.plugins[this.pluginName].render(n)}}}_renderDirect(t){const r=this._resolveDirectShader(t),i=this._geometry,n=this.worldAlpha,o=r.uniforms,h=i.drawCalls;o.translationMatrix=this.transform.worldTransform,rr.shared.setValue(this._tintColor).premultiply(n).toArray(o.tint),t.shader.bind(r),t.geometry.bind(i,r),t.state.set(this.state);for(let c=0,b=h.length;c<b;c++)this._renderDrawCallDirect(t,i.drawCalls[c])}_renderDrawCallDirect(t,r){const{texArray:i,type:n,size:o,start:h}=r,c=i.count;for(let b=0;b<c;b++)t.texture.bind(i.elements[b],b);t.geometry.draw(n,o,h)}_resolveDirectShader(t){let r=this.shader;const i=this.pluginName;if(!r){if(!Kl[i]){const{maxTextures:n}=t.plugins[i],o=new Int32Array(n);for(let b=0;b<n;b++)o[b]=b;const h={tint:new Float32Array([1,1,1,1]),translationMatrix:new nr,default:fi.from({uSamplers:o},!0)},c=t.plugins[i]._shader.program;Kl[i]=new Mi(c,h)}r=Kl[i]}return r}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:r,minY:i,maxX:n,maxY:o}=t.bounds;this._bounds.addFrame(this.transform,r,i,n,o)}containsPoint(t){return this.worldTransform.applyInverse(t,Ha._TEMP_POINT),this._geometry.containsPoint(Ha._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const r=this.batches[t];r._tintRGB=rr.shared.setValue(this._tintColor).multiply(r._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const r=this.transform.worldTransform,i=r.a,n=r.b,o=r.c,h=r.d,c=r.tx,b=r.ty,T=this._geometry.points,C=this.vertexData;let x=0;for(let $=0;$<T.length;$+=2){const I=T[$],B=T[$+1];C[x++]=i*I+o*B+c,C[x++]=h*B+n*I+b}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Jl.curves=Ss,Jl._TEMP_POINT=new He;let tu=Jl;const Hg={buildPoly:jl,buildCircle:to,buildRectangle:Jf,buildRoundedRectangle:td,buildLine:Zl,ArcUtils:ql,BezierUtils:ma,QuadraticUtils:ya,BatchPart:ed,FILL_COMMANDS:va,BATCH_POOL:Ql,DRAW_CALL_POOL:eo};class od{constructor(t,r){this.uvBuffer=t,this.uvMatrix=r,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const r=this.uvBuffer.data;(!this.data||this.data.length!==r.length)&&(this.data=new Float32Array(r.length)),this.uvMatrix.multiplyUvs(r,this.data),this._updateID++}}const eu=new He,ad=new xs,hd=class b2 extends Zr{constructor(t,r,i,n=Ai.TRIANGLES){super(),this.geometry=t,this.shader=r,this.state=i||Pi.for2d(),this.drawMode=n,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=ue.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const r=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Ai.TRIANGLES&&r.length<b2.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const r=this.shader;r.alpha=this.worldAlpha,r.update&&r.update(),t.batch.flush(),r.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(r),t.state.set(this.state),t.geometry.bind(this.geometry,r),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const r=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=r.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const n=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[n]),t.plugins[n].render(this)}calculateVertices(){const t=this.geometry.buffers[0],r=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==r.length&&(this.vertexData=new Float32Array(r.length));const n=this.transform.worldTransform,o=n.a,h=n.b,c=n.c,b=n.d,T=n.tx,C=n.ty,x=this.vertexData;for(let $=0;$<x.length/2;$++){const I=r[$*2],B=r[$*2+1];x[$*2]=o*I+c*B+T,x[$*2+1]=h*I+b*B+C}if(this._roundPixels){const $=ue.RESOLUTION;for(let I=0;I<x.length;++I)x[I]=Math.round(x[I]*$)/$}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],r=this.shader;r.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new od(t,r.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,eu);const r=this.geometry.getBuffer("aVertexPosition").data,i=ad.points,n=this.geometry.getIndex().data,o=n.length,h=this.drawMode===4?3:1;for(let c=0;c+2<o;c+=h){const b=n[c]*2,T=n[c+1]*2,C=n[c+2]*2;if(i[0]=r[b],i[1]=r[b+1],i[2]=r[T],i[3]=r[T+1],i[4]=r[C],i[5]=r[C+1],ad.contains(eu.x,eu.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};hd.BATCHABLE_SIZE=100;let cn=hd;class so extends ls{constructor(t,r,i){super();const n=new Ar(t),o=new Ar(r,!0),h=new Ar(i,!0,!0);this.addAttribute("aVertexPosition",n,2,!1,Pe.FLOAT).addAttribute("aTextureCoord",o,2,!1,Pe.FLOAT).addIndex(h),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Yg=`varying vec2 vTextureCoord;
910
+ `;let ki=null;class ic{constructor(){ki||(ki=URL.createObjectURL(new Blob([tg],{type:"application/javascript"}))),this.worker=new Worker(ki)}}ic.revokeObjectURL=function(){ki&&(URL.revokeObjectURL(ki),ki=null)};let rc=0,go;class eg{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new mo;e.addEventListener("message",i=>{e.terminate(),mo.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){go===void 0&&(go=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<go&&(this._createdWorkers++,t=new ic().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((r,n)=>{this.queue.push({id:t,arguments:e,resolve:r,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[rc]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:rc++,id:i})}}const sc=new eg;function Ni(s,t,e){s.resource.internal=!0;const i=new j(s),r=()=>{delete t.promiseCache[e],ei.has(e)&&ei.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),r())}),i.once("destroyed",()=>{s.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const ig=[".jpeg",".jpg",".png",".webp",".avif"],rg=["image/jpeg","image/png","image/webp","image/avif"];async function nc(s){const t=await q.ADAPTER.fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Mr={name:"loadTextures",extension:{type:$.LoadParser,priority:ie.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return bi(s,rg)||Ve(s,ig)},async load(s,t,e){var o;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let r;i?this.config.preferWorkers&&await sc.isImageBitmapSupported()?r=await sc.loadImageBitmap(s):r=await nc(s):r=await new Promise((h,l)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=s,u.complete?h(u):(u.onload=()=>h(u),u.onerror=c=>l(c))});const n={...t.data};n.resolution??(n.resolution=Ce(s)),i&&((o=n.resourceOptions)==null?void 0:o.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const a=new lt(r,n);return a.resource.src=s,Ni(a,e,s)},unload(s){s.destroy(!0)}};Q.add(Mr);const sg=".svg",ng="image/svg+xml",ac={extension:{type:$.LoadParser,priority:ie.High},name:"loadSVG",test(s){return bi(s,ng)||Ve(s,sg)},async testParse(s){return Ms.test(s)},async parse(s,t,e){var n;const i=new Ms(s,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const r=new lt(i,{resolution:Ce(s),...t==null?void 0:t.data});return r.resource.src=t.src,Ni(r,e,t.src)},async load(s,t){return(await q.ADAPTER.fetch(s)).text()},unload:Mr.unload};Q.add(ac);const ag=[".mp4",".m4v",".webm",".ogv"],og=["video/mp4","video/webm","video/ogg"],oc={name:"loadVideo",extension:{type:$.LoadParser,priority:ie.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(s){return bi(s,og)||Ve(s,ag)},async load(s,t,e){var a;let i;const r=await(await q.ADAPTER.fetch(s)).blob(),n=URL.createObjectURL(r);try{const o={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(a=t==null?void 0:t.data)==null?void 0:a.resourceOptions,autoLoad:!0},h=new ao(n,o);await h.load();const l=new lt(h,{alphaMode:await vl(),resolution:Ce(s),...t==null?void 0:t.data});l.resource.src=s,i=Ni(l,e,s),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(o){throw URL.revokeObjectURL(n),o}return i},unload(s){s.destroy(!0)}};Q.add(oc);class hg{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:r,srcs:n}=t;return ee(e||i||r||n,a=>typeof a=="string"?a:Array.isArray(a)?a.map(o=>(o==null?void 0:o.src)??(o==null?void 0:o.srcs)??o):a!=null&&a.src||a!=null&&a.srcs?a.src??a.srcs:a,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(r=>{const n=r.src??r.srcs,a=r.alias??r.name;let o;if(typeof a=="string"){const h=this._createBundleAssetId(t,a);i.push(h),o=[a,h]}else{const h=a.map(l=>this._createBundleAssetId(t,l));i.push(...h),o=[...a,...h]}this.add({...r,alias:o,src:n})}):Object.keys(e).forEach(r=>{const n=[r,this._createBundleAssetId(t,r)];if(typeof e[r]=="string")this.add({alias:n,src:e[r]});else if(Array.isArray(e[r]))this.add({alias:n,src:e[r]});else{const a=e[r],o=a.src??a.srcs;this.add({...a,alias:n,src:Array.isArray(o)?o:[o]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,r,n){const a=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(ot("7.2.0",`Assets.add now uses an object instead of individual parameters.
911
+ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),a.push({alias:t,src:e,data:i,format:r,loadParser:n})):Array.isArray(t)?a.push(...t):a.push(t);let o;o=h=>{this.hasKey(h)&&console.warn(`[Resolver] already has key: ${h} overwriting`)},ee(a).forEach(h=>{const{src:l,srcs:u}=h;let{data:c,format:d,loadParser:f}=h;const p=ee(l||u).map(_=>typeof _=="string"?Zu(_):Array.isArray(_)?_:[_]),g=this.getAlias(h);Array.isArray(g)?g.forEach(o):o(g);const m=[];p.forEach(_=>{_.forEach(b=>{let y={};if(typeof b!="object"){y.src=b;for(let E=0;E<this._parsers.length;E++){const v=this._parsers[E];if(v.test(b)){y=v.parse(b);break}}}else c=b.data??c,d=b.format??d,f=b.loadParser??f,y={...y,...b};if(!g)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this.buildResolvedAsset(y,{aliases:g,data:c,format:d,loadParser:f}),m.push(y)})}),g.forEach(_=>{this._assetMap[_]=m})})}resolveBundle(t){const e=Pr(t);t=ee(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(r,h)]=l}i[r]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=Pr(t);t=ee(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const a=n[0],o=this._getPreferredOrder(n);o==null||o.priority.forEach(h=>{o.params[h].forEach(l=>{const u=n.filter(c=>c[h]?c[h]===l:!1);u.length&&(n=u)})}),this._resolverHash[r]=n[0]??a}else this._resolverHash[r]=this.buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=Rt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??Rt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class hc{constructor(){this._detections=[],this._initialized=!1,this.resolver=new hg,this.loader=new Hm,this.cache=ei,this._backgroundLoader=new Gm(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,r,n){this.resolver.add(t,e,i,r,n)}async load(t,e){this._initialized||await this.init();const i=Pr(t),r=ee(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(l=>!this.resolver.hasKey(l))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return i?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const l=()=>{e==null||e(++o/h)},u=a.map(c=>{const d=r[c];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(f=>{n[c]=f})});return await Promise.all(u),i?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(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return ei.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=ei.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),r=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const a={};return i.forEach((o,h)=>{const l=n[o.src],u=[o.src];o.alias&&u.push(...o.alias),a[r[h]]=l,ei.set(u,l)}),a}async unload(t){this._initialized||await this.init();const e=ee(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=ee(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{ei.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}get preferWorkers(){return Mr.config.preferWorkers}set preferWorkers(t){ot("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Ir=new hc;Q.handleByList($.LoadParser,Ir.loader.parsers).handleByList($.ResolveParser,Ir.resolver.parsers).handleByList($.CacheParser,Ir.cache.parsers).handleByList($.DetectionParser,Ir.detections);const lc={extension:$.CacheParser,test:s=>Array.isArray(s)&&s.every(t=>t instanceof j),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};Q.add(lc);async function uc(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const cc={extension:{type:$.DetectionParser,priority:1},test:async()=>uc("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")};Q.add(cc);const dc={extension:{type:$.DetectionParser,priority:0},test:async()=>uc("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};Q.add(dc);const fc=["png","jpg","jpeg"],pc={extension:{type:$.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...fc],remove:async s=>s.filter(t=>!fc.includes(t))};Q.add(pc);const lg="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function _o(s){return lg?!1:document.createElement("video").canPlayType(s)!==""}const mc={extension:{type:$.DetectionParser,priority:0},test:async()=>_o("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")};Q.add(mc);const gc={extension:{type:$.DetectionParser,priority:0},test:async()=>_o("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")};Q.add(gc);const _c={extension:{type:$.DetectionParser,priority:0},test:async()=>_o("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")};Q.add(_c);const yc={extension:$.ResolveParser,test:Mr.test,parse:s=>{var t;return{resolution:parseFloat(((t=q.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:Rt.extname(s).slice(1),src:s}}};Q.add(yc);var Lt=(s=>(s[s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",s[s.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",s[s.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",s[s.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",s[s.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",s[s.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",s[s.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",s[s.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",s[s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",s[s.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",s[s.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",s[s.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",s[s.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",s[s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",s[s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",s[s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",s))(Lt||{});const Rr={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,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let Me,Ui;function vc(){Ui={bptc:Me.getExtension("EXT_texture_compression_bptc"),astc:Me.getExtension("WEBGL_compressed_texture_astc"),etc:Me.getExtension("WEBGL_compressed_texture_etc"),s3tc:Me.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Me.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Me.getExtension("WEBGL_compressed_texture_pvrtc")||Me.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Me.getExtension("WEBGL_compressed_texture_etc1"),atc:Me.getExtension("WEBGL_compressed_texture_atc")}}const xc={extension:{type:$.DetectionParser,priority:2},test:async()=>{const s=q.ADAPTER.createCanvas().getContext("webgl");return s?(Me=s,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async s=>{Ui||vc();const t=[];for(const e in Ui)Ui[e]&&t.push(e);return[...t,...s]},remove:async s=>(Ui||vc(),s.filter(t=>!(t in Ui)))};Q.add(xc);class bc extends ur{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,r;typeof t=="string"?(i=t,r=new Uint8Array):(i=null,r=t),super(r,e),this.origin=i,this.buffer=r?new us(r):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?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 us(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class ii extends bc{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=ii._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ii._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){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;r.pixelStorei(r.UNPACK_ALIGNMENT,4);for(let n=0,a=this.levels;n<a;n++){const{levelID:o,levelWidth:h,levelHeight:l,levelBuffer:u}=this._levelBuffers[n];r.compressedTexImage2D(r.TEXTURE_2D,o,this.format,h,l,0,u)}return!0}onBlobLoaded(){this._levelBuffers=ii._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,r,n,a,o){const h=new Array(i);let l=t.byteOffset,u=a,c=o,d=u+r-1&~(r-1),f=c+n-1&~(n-1),p=d*f*Rr[e];for(let g=0;g<i;g++)h[g]={levelID:g,levelWidth:i>1?u:d,levelHeight:i>1?c:f,levelBuffer:new Uint8Array(t.buffer,l,p)},l+=p,u=u>>1||1,c=c>>1||1,d=u+r-1&~(r-1),f=c+n-1&~(n-1),p=d*f*Rr[e];return h}}const yo=4,Ls=124,ug=32,Tc=20,cg=542327876,Os={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},dg={FOURCC:2},ks={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},fg=1,pg=2,mg=4,gg=64,_g=512,yg=131072,vg=827611204,xg=861165636,bg=894720068,Tg=808540228,Eg=4,wg={[vg]:Lt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[xg]:Lt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[bg]:Lt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Cg={70:Lt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Lt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Lt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Lt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Lt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Lt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Lt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Lt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Lt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Lt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Lt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Lt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Lt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function Ec(s){const t=new Uint32Array(s);if(t[0]!==cg)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(s,0,Ls/Uint32Array.BYTES_PER_ELEMENT),i=e[Os.HEIGHT],r=e[Os.WIDTH],n=e[Os.MIPMAP_COUNT],a=new Uint32Array(s,Os.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,ug/Uint32Array.BYTES_PER_ELEMENT),o=a[fg];if(o&mg){const h=a[dg.FOURCC];if(h!==Tg){const b=wg[h],y=yo+Ls,E=new Uint8Array(s,y);return[new ii(E,{format:b,width:r,height:i,levels:n})]}const l=yo+Ls,u=new Uint32Array(t.buffer,l,Tc/Uint32Array.BYTES_PER_ELEMENT),c=u[ks.DXGI_FORMAT],d=u[ks.RESOURCE_DIMENSION],f=u[ks.MISC_FLAG],p=u[ks.ARRAY_SIZE],g=Cg[c];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(f===Eg)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const m=new Array,_=yo+Ls+Tc;if(p===1)m.push(new Uint8Array(s,_));else{const b=Rr[g];let y=0,E=r,v=i;for(let T=0;T<n;T++){const P=Math.max(1,E+3&-4),N=Math.max(1,v+3&-4),G=P*N*b;y+=G,E=E>>>1,v=v>>>1}let M=_;for(let T=0;T<p;T++)m.push(new Uint8Array(s,M,y)),M+=y}return m.map(b=>new ii(b,{format:g,width:r,height:i,levels:n}))}throw o&gg?new Error("DDSParser does not support uncompressed texture data."):o&_g?new Error("DDSParser does not supported YUV uncompressed texture data."):o&yg?new Error("DDSParser does not support single-channel (lumninance) texture data!"):o&pg?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 wc=[171,75,84,88,32,49,49,187,13,10,26,10],Ag=67305985,ge={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,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},vo=64,xo={[it.UNSIGNED_BYTE]:1,[it.UNSIGNED_SHORT]:2,[it.INT]:4,[it.UNSIGNED_INT]:4,[it.FLOAT]:4,[it.HALF_FLOAT]:8},Cc={[H.RGBA]:4,[H.RGB]:3,[H.RG]:2,[H.RED]:1,[H.LUMINANCE]:1,[H.LUMINANCE_ALPHA]:2,[H.ALPHA]:1},Ac={[it.UNSIGNED_SHORT_4_4_4_4]:2,[it.UNSIGNED_SHORT_5_5_5_1]:2,[it.UNSIGNED_SHORT_5_6_5]:2};function Sc(s,t,e=!1){const i=new DataView(t);if(!Sg(s,i))return null;const r=i.getUint32(ge.ENDIANNESS,!0)===Ag,n=i.getUint32(ge.GL_TYPE,r),a=i.getUint32(ge.GL_FORMAT,r),o=i.getUint32(ge.GL_INTERNAL_FORMAT,r),h=i.getUint32(ge.PIXEL_WIDTH,r),l=i.getUint32(ge.PIXEL_HEIGHT,r)||1,u=i.getUint32(ge.PIXEL_DEPTH,r)||1,c=i.getUint32(ge.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=i.getUint32(ge.NUMBER_OF_FACES,r),f=i.getUint32(ge.NUMBER_OF_MIPMAP_LEVELS,r),p=i.getUint32(ge.BYTES_OF_KEY_VALUE_DATA,r);if(l===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const g=4,m=4,_=h+3&-4,b=l+3&-4,y=new Array(c);let E=h*l;n===0&&(E=_*b);let v;if(n!==0?xo[n]?v=xo[n]*Cc[a]:v=Ac[n]:v=Rr[o],v===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const M=e?Mg(i,p,r):null;let T=E*v,P=h,N=l,G=_,z=b,D=vo+p;for(let O=0;O<f;O++){const V=i.getUint32(D,r);let W=D+4;for(let w=0;w<c;w++){let C=y[w];C||(C=y[w]=new Array(f)),C[O]={levelID:O,levelWidth:f>1||n!==0?P:G,levelHeight:f>1||n!==0?N:z,levelBuffer:new Uint8Array(t,W,T)},W+=T}D+=V+4,D=D%4!==0?D+4-D%4:D,P=P>>1||1,N=N>>1||1,G=P+g-1&-4,z=N+m-1&-4,T=G*z*v}return n!==0?{uncompressed:y.map(O=>{let V=O[0].levelBuffer,W=!1;return n===it.FLOAT?V=new Float32Array(O[0].levelBuffer.buffer,O[0].levelBuffer.byteOffset,O[0].levelBuffer.byteLength/4):n===it.UNSIGNED_INT?(W=!0,V=new Uint32Array(O[0].levelBuffer.buffer,O[0].levelBuffer.byteOffset,O[0].levelBuffer.byteLength/4)):n===it.INT&&(W=!0,V=new Int32Array(O[0].levelBuffer.buffer,O[0].levelBuffer.byteOffset,O[0].levelBuffer.byteLength/4)),{resource:new ur(V,{width:O[0].levelWidth,height:O[0].levelHeight}),type:n,format:W?Pg(a):a}}),kvData:M}:{compressed:y.map(O=>new ii(null,{format:o,width:h,height:l,levels:f,levelBuffers:O})),kvData:M}}function Sg(s,t){for(let e=0;e<wc.length;e++)if(t.getUint8(e)!==wc[e])return console.error(`${s} is not a valid *.ktx file!`),!1;return!0}function Pg(s){switch(s){case H.RGBA:return H.RGBA_INTEGER;case H.RGB:return H.RGB_INTEGER;case H.RG:return H.RG_INTEGER;case H.RED:return H.RED_INTEGER;default:return s}}function Mg(s,t,e){const i=new Map;let r=0;for(;r<t;){const n=s.getUint32(vo+r,e),a=vo+r+4,o=3-(n+3)%4;if(n===0||n>t-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&s.getUint8(a+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=new TextDecoder().decode(new Uint8Array(s.buffer,a,h)),u=new DataView(s.buffer,a+h+1,n-h-1);i.set(l,u),r+=4+n+o}return i}const Pc={extension:{type:$.LoadParser,priority:ie.High},name:"loadDDS",test(s){return Ve(s,".dds")},async load(s,t,e){const i=await(await q.ADAPTER.fetch(s)).arrayBuffer(),r=Ec(i).map(n=>{const a=new lt(n,{mipmap:he.OFF,alphaMode:Nt.NO_PREMULTIPLIED_ALPHA,resolution:Ce(s),...t.data});return Ni(a,e,s)});return r.length===1?r[0]:r},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};Q.add(Pc);const Mc={extension:{type:$.LoadParser,priority:ie.High},name:"loadKTX",test(s){return Ve(s,".ktx")},async load(s,t,e){const i=await(await q.ADAPTER.fetch(s)).arrayBuffer(),{compressed:r,uncompressed:n,kvData:a}=Sc(s,i),o=r??n,h={mipmap:he.OFF,alphaMode:Nt.NO_PREMULTIPLIED_ALPHA,resolution:Ce(s),...t.data},l=o.map(u=>{o===n&&Object.assign(h,{type:u.type,format:u.format});const c=u.resource??u,d=new lt(c,h);return d.ktxKeyValueData=a,Ni(d,e,s)});return l.length===1?l[0]:l},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};Q.add(Mc);const Ig=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],Ic={extension:$.ResolveParser,test:s=>{const t=Rt.extname(s).slice(1);return["basis","ktx","dds"].includes(t)},parse:s=>{var i,r;const t=s.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(Ig.includes(n))return{resolution:parseFloat(((i=q.RETINA_PREFIX.exec(s))==null?void 0:i[1])??"1"),format:n,src:s}}return{resolution:parseFloat(((r=q.RETINA_PREFIX.exec(s))==null?void 0:r[1])??"1"),format:e,src:s}}};Q.add(Ic);const Ns=new ut,Rg=4,Rc=class ts{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,r){const n=new Image;return n.src=await this.base64(t,e,i,r),n}async base64(t,e,i,r){const n=this.canvas(t,r);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(h=>{if(!h){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>a(l.result),l.onerror=o,l.readAsDataURL(h)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:e,quality:i});return new Promise((o,h)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=h,l.readAsDataURL(a)})}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:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);a&&ts._flipY(i,r,n),o&&ts._unpremultiplyAlpha(i);const h=new Ll(r,n,1),l=new ImageData(new Uint8ClampedArray(i.buffer),r,n);return h.context.putImageData(l,0,0),h.canvas}pixels(t,e){const{pixels:i,width:r,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);return a&&ts._flipY(i,r,n),o&&ts._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let r,n=!1,a=!1,o,h=!1;t&&(t instanceof Je?o=t:(o=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),h=!0,e&&(Ns.width=e.width,Ns.height=e.height,e=Ns)));const l=i.gl;if(o){if(r=o.baseTexture.resolution,e=e??o.frame,n=!1,a=o.baseTexture.alphaMode>0&&o.baseTexture.format===H.RGBA,!h){i.renderTexture.bind(o);const f=o.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else r=i.resolution,e||(e=Ns,e.width=i.width/r,e.height=i.height/r),n=!0,a=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*r),1),c=Math.max(Math.round(e.height*r),1),d=new Uint8Array(Rg*u*c);return l.readPixels(Math.round(e.x*r),Math.round(e.y*r),u,c,l.RGBA,l.UNSIGNED_BYTE,d),h&&(o==null||o.destroy(!0)),{pixels:d,width:u,height:c,flipY:n,premultipliedAlpha:a}}destroy(){this.renderer=null}static _flipY(t,e,i){const r=e<<2,n=i>>1,a=new Uint8Array(r);for(let o=0;o<n;o++){const h=o*r,l=(i-o-1)*r;a.set(t.subarray(h,h+r)),t.copyWithin(h,l,l+r),t.set(a,l)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const r=t[i+3];if(r!==0){const n=255.001/r;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Rc.extension={name:"extract",type:$.RendererSystem};let Dc=Rc;Q.add(Dc);const Dr={build(s){const t=s.points;let e,i,r,n,a,o;if(s.type===Bt.CIRC){const p=s.shape;e=p.x,i=p.y,a=o=p.radius,r=n=0}else if(s.type===Bt.ELIP){const p=s.shape;e=p.x,i=p.y,a=p.width,o=p.height,r=n=0}else{const p=s.shape,g=p.width/2,m=p.height/2;e=p.x+g,i=p.y+m,a=o=Math.max(0,Math.min(p.radius,Math.min(g,m))),r=g-a,n=m-o}if(!(a>=0&&o>=0&&r>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(a+o)),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]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n;return}let u=0,c=h*4+(r?2:0)+2,d=c,f=l;{const p=r+a,g=n,m=e+p,_=e-p,b=i+g;if(t[u++]=m,t[u++]=b,t[--c]=b,t[--c]=_,n){const y=i-g;t[d++]=_,t[d++]=y,t[--f]=y,t[--f]=m}}for(let p=1;p<h;p++){const g=Math.PI/2*(p/h),m=r+Math.cos(g)*a,_=n+Math.sin(g)*o,b=e+m,y=e-m,E=i+_,v=i-_;t[u++]=b,t[u++]=E,t[--c]=E,t[--c]=y,t[d++]=y,t[d++]=v,t[--f]=v,t[--f]=b}{const p=r,g=n+o,m=e+p,_=e-p,b=i+g,y=i-g;t[u++]=m,t[u++]=b,t[--f]=y,t[--f]=m,r&&(t[u++]=_,t[u++]=b,t[--f]=y,t[--f]=_)}},triangulate(s,t){const e=s.points,i=t.points,r=t.indices;if(e.length===0)return;let n=i.length/2;const a=n;let o,h;if(s.type!==Bt.RREC){const u=s.shape;o=u.x,h=u.y}else{const u=s.shape;o=u.x+u.width/2,h=u.y+u.height/2}const l=s.matrix;i.push(s.matrix?l.a*o+l.c*h+l.tx:o,s.matrix?l.b*o+l.d*h+l.ty:h),n++,i.push(e[0],e[1]);for(let u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),r.push(n++,a,n);r.push(a+1,a,n)}};function Fc(s,t=!1){const e=s.length;if(e<6)return;let i=0;for(let r=0,n=s[e-2],a=s[e-1];r<e;r+=2){const o=s[r],h=s[r+1];i+=(o-n)*(h+a),n=o,a=h}if(!t&&i>0||t&&i<=0){const r=e/2;for(let n=r+r%2;n<e;n+=2){const a=e-n-2,o=e-n-1,h=n,l=n+1;[s[a],s[h]]=[s[h],s[a]],[s[o],s[l]]=[s[l],s[o]]}}}const bo={build(s){s.points=s.shape.points.slice()},triangulate(s,t){let e=s.points;const i=s.holes,r=t.points,n=t.indices;if(e.length>=6){Fc(e,!1);const a=[];for(let l=0;l<i.length;l++){const u=i[l];Fc(u.points,!0),a.push(e.length/2),e=e.concat(u.points)}const o=Nh(e,a,2);if(!o)return;const h=r.length/2;for(let l=0;l<o.length;l+=3)n.push(o[l]+h),n.push(o[l+1]+h),n.push(o[l+2]+h);for(let l=0;l<e.length;l++)r.push(e[l])}}},Bc={build(s){const t=s.shape,e=t.x,i=t.y,r=t.width,n=t.height,a=s.points;a.length=0,r>=0&&n>=0&&a.push(e,i,e+r,i,e+r,i+n,e,i+n)},triangulate(s,t){const e=s.points,i=t.points;if(e.length===0)return;const r=i.length/2;i.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)}},Lc={build(s){Dr.build(s)},triangulate(s,t){Dr.triangulate(s,t)}};var $t=(s=>(s.MITER="miter",s.BEVEL="bevel",s.ROUND="round",s))($t||{}),He=(s=>(s.BUTT="butt",s.ROUND="round",s.SQUARE="square",s))(He||{});const ri={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(s,t=20){if(!this.adaptive||!s||isNaN(s))return t;let e=Math.ceil(s/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}},Dg=ri;class To{static curveTo(t,e,i,r,n,a){const o=a[a.length-2],h=a[a.length-1]-e,l=o-t,u=r-e,c=i-t,d=Math.abs(h*c-l*u);if(d<1e-8||n===0)return(a[a.length-2]!==t||a[a.length-1]!==e)&&a.push(t,e),null;const f=h*h+l*l,p=u*u+c*c,g=h*u+l*c,m=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,b=m*g/f,y=_*g/p,E=m*c+_*l,v=m*u+_*h,M=l*(_+b),T=h*(_+b),P=c*(m+y),N=u*(m+y),G=Math.atan2(T-v,M-E),z=Math.atan2(N-v,P-E);return{cx:E+t,cy:v+e,radius:n,startAngle:G,endAngle:z,anticlockwise:l*u>c*h}}static arc(t,e,i,r,n,a,o,h,l){const u=o-a,c=ri._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/dr)*40),d=u/(c*2),f=d*2,p=Math.cos(d),g=Math.sin(d),m=c-1,_=m%1/m;for(let b=0;b<=m;++b){const y=b+_*b,E=d+a+f*y,v=Math.cos(E),M=-Math.sin(E);l.push((p*v+g*M)*n+i,(p*-M+g*v)*n+r)}}}class Oc{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}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}}class Us{static curveLength(t,e,i,r,n,a,o,h){let l=0,u=0,c=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,y=0,E=t,v=e;for(let M=1;M<=10;++M)u=M/10,c=u*u,d=c*u,f=1-u,p=f*f,g=p*f,m=g*t+3*p*u*i+3*f*c*n+d*o,_=g*e+3*p*u*r+3*f*c*a+d*h,b=E-m,y=v-_,E=m,v=_,l+=Math.sqrt(b*b+y*y);return l}static curveTo(t,e,i,r,n,a,o){const h=o[o.length-2],l=o[o.length-1];o.length-=2;const u=ri._segmentsCount(Us.curveLength(h,l,t,e,i,r,n,a));let c=0,d=0,f=0,p=0,g=0;o.push(h,l);for(let m=1,_=0;m<=u;++m)_=m/u,c=1-_,d=c*c,f=d*c,p=_*_,g=p*_,o.push(f*h+3*d*_*t+3*c*p*i+g*n,f*l+3*d*_*e+3*c*p*r+g*a)}}function kc(s,t,e,i,r,n,a,o){const h=s-e*r,l=t-i*r,u=s+e*n,c=t+i*n;let d,f;a?(d=i,f=-e):(d=-i,f=e);const p=h+d,g=l+f,m=u+d,_=c+f;return o.push(p,g,m,_),2}function Ti(s,t,e,i,r,n,a,o){const h=e-s,l=i-t;let u=Math.atan2(h,l),c=Math.atan2(r-s,n-t);o&&u<c?u+=Math.PI*2:!o&&u>c&&(c+=Math.PI*2);let d=u;const f=c-u,p=Math.abs(f),g=Math.sqrt(h*h+l*l),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/m;if(d+=_,o){a.push(s,t,e,i);for(let b=1,y=d;b<m;b++,y+=_)a.push(s,t,s+Math.sin(y)*g,t+Math.cos(y)*g);a.push(s,t,r,n)}else{a.push(e,i,s,t);for(let b=1,y=d;b<m;b++,y+=_)a.push(s+Math.sin(y)*g,t+Math.cos(y)*g,s,t);a.push(r,n,s,t)}return m*2}function Fg(s,t){const e=s.shape;let i=s.points||e.points.slice();const r=t.closePointEps;if(i.length===0)return;const n=s.lineStyle,a=new ft(i[0],i[1]),o=new ft(i[i.length-2],i[i.length-1]),h=e.type!==Bt.POLY||e.closeStroke,l=Math.abs(a.x-o.x)<r&&Math.abs(a.y-o.y)<r;if(h){i=i.slice(),l&&(i.pop(),i.pop(),o.set(i[i.length-2],i[i.length-1]));const C=(a.x+o.x)*.5,x=(o.y+a.y)*.5;i.unshift(C,x),i.push(C,x)}const u=t.points,c=i.length/2;let d=i.length;const f=u.length/2,p=n.width/2,g=p*p,m=n.miterLimit*n.miterLimit;let _=i[0],b=i[1],y=i[2],E=i[3],v=0,M=0,T=-(b-E),P=_-y,N=0,G=0,z=Math.sqrt(T*T+P*P);T/=z,P/=z,T*=p,P*=p;const D=n.alignment,O=(1-D)*2,V=D*2;h||(n.cap===He.ROUND?d+=Ti(_-T*(O-V)*.5,b-P*(O-V)*.5,_-T*O,b-P*O,_+T*V,b+P*V,u,!0)+2:n.cap===He.SQUARE&&(d+=kc(_,b,T,P,O,V,!0,u))),u.push(_-T*O,b-P*O,_+T*V,b+P*V);for(let C=1;C<c-1;++C){_=i[(C-1)*2],b=i[(C-1)*2+1],y=i[C*2],E=i[C*2+1],v=i[(C+1)*2],M=i[(C+1)*2+1],T=-(b-E),P=_-y,z=Math.sqrt(T*T+P*P),T/=z,P/=z,T*=p,P*=p,N=-(E-M),G=y-v,z=Math.sqrt(N*N+G*G),N/=z,G/=z,N*=p,G*=p;const x=y-_,R=b-E,A=y-v,S=M-E,F=x*A+R*S,L=R*A-S*x,U=L<0;if(Math.abs(L)<.001*Math.abs(F)){u.push(y-T*O,E-P*O,y+T*V,E+P*V),F>=0&&(n.join===$t.ROUND?d+=Ti(y,E,y-T*O,E-P*O,y-N*O,E-G*O,u,!1)+4:d+=2,u.push(y-N*V,E-G*V,y+N*O,E+G*O));continue}const X=(-T+_)*(-P+E)-(-T+y)*(-P+b),J=(-N+v)*(-G+E)-(-N+y)*(-G+M),Z=(x*J-A*X)/L,tt=(S*X-R*J)/L,st=(Z-y)*(Z-y)+(tt-E)*(tt-E),K=y+(Z-y)*O,ht=E+(tt-E)*O,dt=y-(Z-y)*V,bt=E-(tt-E)*V,_t=Math.min(x*x+R*R,A*A+S*S),rt=U?O:V,ct=_t+rt*rt*g,Ye=st<=ct;let oi=n.join;if(oi===$t.MITER&&st/g>m&&(oi=$t.BEVEL),Ye)switch(oi){case $t.MITER:{u.push(K,ht,dt,bt);break}case $t.BEVEL:{U?u.push(K,ht,y+T*V,E+P*V,K,ht,y+N*V,E+G*V):u.push(y-T*O,E-P*O,dt,bt,y-N*O,E-G*O,dt,bt),d+=2;break}case $t.ROUND:{U?(u.push(K,ht,y+T*V,E+P*V),d+=Ti(y,E,y+T*V,E+P*V,y+N*V,E+G*V,u,!0)+4,u.push(K,ht,y+N*V,E+G*V)):(u.push(y-T*O,E-P*O,dt,bt),d+=Ti(y,E,y-T*O,E-P*O,y-N*O,E-G*O,u,!1)+4,u.push(y-N*O,E-G*O,dt,bt));break}}else{switch(u.push(y-T*O,E-P*O,y+T*V,E+P*V),oi){case $t.MITER:{U?u.push(dt,bt,dt,bt):u.push(K,ht,K,ht),d+=2;break}case $t.ROUND:{U?d+=Ti(y,E,y+T*V,E+P*V,y+N*V,E+G*V,u,!0)+2:d+=Ti(y,E,y-T*O,E-P*O,y-N*O,E-G*O,u,!1)+2;break}}u.push(y-N*O,E-G*O,y+N*V,E+G*V),d+=2}}_=i[(c-2)*2],b=i[(c-2)*2+1],y=i[(c-1)*2],E=i[(c-1)*2+1],T=-(b-E),P=_-y,z=Math.sqrt(T*T+P*P),T/=z,P/=z,T*=p,P*=p,u.push(y-T*O,E-P*O,y+T*V,E+P*V),h||(n.cap===He.ROUND?d+=Ti(y-T*(O-V)*.5,E-P*(O-V)*.5,y-T*O,E-P*O,y+T*V,E+P*V,u,!1)+2:n.cap===He.SQUARE&&(d+=kc(y,E,T,P,O,V,!1,u)));const W=t.indices,w=ri.epsilon*ri.epsilon;for(let C=f;C<d+f-2;++C)_=u[C*2],b=u[C*2+1],y=u[(C+1)*2],E=u[(C+1)*2+1],v=u[(C+2)*2],M=u[(C+2)*2+1],!(Math.abs(_*(E-M)+y*(M-b)+v*(b-E))<w)&&W.push(C,C+1,C+2)}function Bg(s,t){let e=0;const i=s.shape,r=s.points||i.points,n=i.type!==Bt.POLY||i.closeStroke;if(r.length===0)return;const a=t.points,o=t.indices,h=r.length/2,l=a.length/2;let u=l;for(a.push(r[0],r[1]),e=1;e<h;e++)a.push(r[e*2],r[e*2+1]),o.push(u,u+1),u++;n&&o.push(u,l)}function Eo(s,t){s.lineStyle.native?Bg(s,t):Fg(s,t)}class Gs{static curveLength(t,e,i,r,n,a){const o=t-2*i+n,h=e-2*r+a,l=2*i-2*t,u=2*r-2*e,c=4*(o*o+h*h),d=4*(o*l+h*u),f=l*l+u*u,p=2*Math.sqrt(c+d+f),g=Math.sqrt(c),m=2*c*g,_=2*Math.sqrt(f),b=d/g;return(m*p+g*d*(p-_)+(4*f*c-d*d)*Math.log((2*g+b+p)/(b+_)))/(4*m)}static curveTo(t,e,i,r,n){const a=n[n.length-2],o=n[n.length-1],h=ri._segmentsCount(Gs.curveLength(a,o,t,e,i,r));let l=0,u=0;for(let c=1;c<=h;++c){const d=c/h;l=a+(t-a)*d,u=o+(e-o)*d,n.push(l+(t+(i-t)*d-l)*d,u+(e+(r-e)*d-u)*d)}}}const Vs={[Bt.POLY]:bo,[Bt.CIRC]:Dr,[Bt.ELIP]:Dr,[Bt.RECT]:Bc,[Bt.RREC]:Lc},wo=[],Fr=[];class Br{constructor(t,e=null,i=null,r=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=r,this.type=t.type}clone(){return new Br(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 Gi=new ft,Nc=class lf extends Sa{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 Cr,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 t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),Fr.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),wo.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,r=null){const n=new Br(t,e,i,r);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new Br(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const r=e[i];if(r.fillStyle.visible&&r.shape&&(r.matrix?r.matrix.applyInverse(t,Gi):Gi.copyFrom(t),r.shape.contains(Gi.x,Gi.y))){let n=!1;if(r.holes){for(let a=0;a<r.holes.length;a++)if(r.holes[a].shape.contains(Gi.x,Gi.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,r=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],r=i.style);for(let h=this.shapeIndex;h<e.length;h++){this.shapeIndex++;const l=e[h],u=l.fillStyle,c=l.lineStyle;Vs[l.type].build(l),l.matrix&&this.transformPoints(l.points,l.matrix),(u.visible||c.visible)&&this.processHoles(l.holes);for(let d=0;d<2;d++){const f=d===0?u:c;if(!f.visible)continue;const p=f.texture.baseTexture,g=this.indices.length,m=this.points.length/2;p.wrapMode=Te.REPEAT,d===0?this.processFill(l):this.processLine(l);const _=this.points.length/2-m;_!==0&&(i&&!this._compareStyles(r,f)&&(i.end(g,m),i=null),i||(i=wo.pop()||new Oc,i.begin(f,g,m),this.batches.push(i),r=f),this.addUvs(this.points,t,f.texture,m,_,f.matrix))}}const n=this.indices.length,a=this.points.length/2;if(i&&i.end(n,a),this.batches.length===0){this.batchable=!0;return}const o=a>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],r=i.fillStyle,n=i.lineStyle;if(r&&!r.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const r=t[e];for(let n=0;n<r.size;n++){const a=r.start+n;this.indicesUint16[a]=this.indicesUint16[a]-r.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<lf.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++lt._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Fr.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let r=Fr.pop();r||(r=new ds,r.texArray=new ys),r.texArray.count=0,r.start=0,r.size=0,r.type=oe.TRIANGLES;let n=0,a=null,o=0,h=!1,l=oe.TRIANGLES,u=0;this.drawCalls.push(r);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],f=8,p=d.style,g=p.texture.baseTexture;h!==!!p.native&&(h=!!p.native,l=h?oe.LINES:oe.TRIANGLES,a=null,n=f,t++),a!==g&&(a=g,g._batchEnabled!==t&&(n===f&&(t++,n=0,r.size>0&&(r=Fr.pop(),r||(r=new ds,r.texArray=new ys),this.drawCalls.push(r)),r.start=u,r.size=0,r.texArray.count=0,r.type=l),g.touched=1,g._batchEnabled=t,g._batchLocation=n,g.wrapMode=Te.REPEAT,r.texArray.elements[r.texArray.count++]=g,n++)),r.size+=d.size,u+=d.size,o=g._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,o,d.attribSize,d.attribStart)}lt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,r=this.textureIds,n=new ArrayBuffer(t.length*3*4),a=new Float32Array(n),o=new Uint32Array(n);let h=0;for(let l=0;l<t.length/2;l++)a[h++]=t[l*2],a[h++]=t[l*2+1],a[h++]=e[l*2],a[h++]=e[l*2+1],o[h++]=i[l],a[h++]=r[l];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?bo.triangulate(t,this):Vs[t.type].triangulate(t,this)}processLine(t){Eo(t,this);for(let e=0;e<t.holes.length;e++)Eo(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Vs[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const r=t[i*2],n=t[i*2+1];t[i*2]=e.a*r+e.c*n+e.tx,t[i*2+1]=e.b*r+e.d*n+e.ty}}addColors(t,e,i,r,n=0){const a=gt.shared.setValue(e).toLittleEndianNumber(),o=gt.shared.setValue(a).toPremultiplied(i);t.length=Math.max(t.length,n+r);for(let h=0;h<r;h++)t[n+h]=o}addTextureIds(t,e,i,r=0){t.length=Math.max(t.length,r+i);for(let n=0;n<i;n++)t[r+n]=e}addUvs(t,e,i,r,n,a=null){let o=0;const h=e.length,l=i.frame;for(;o<n;){let c=t[(r+o)*2],d=t[(r+o)*2+1];if(a){const f=a.a*c+a.c*d+a.tx;d=a.b*c+a.d*d+a.ty,c=f}o++,e.push(c/l.width,d/l.height)}const u=i.baseTexture;(l.width<u.width||l.height<u.height)&&this.adjustUvs(e,i,h,n)}adjustUvs(t,e,i,r){const n=e.baseTexture,a=1e-6,o=i+r*2,h=e.frame,l=h.width/n.width,u=h.height/n.height;let c=h.x/h.width,d=h.y/h.height,f=Math.floor(t[i]+a),p=Math.floor(t[i+1]+a);for(let g=i+2;g<o;g+=2)f=Math.min(f,Math.floor(t[g]+a)),p=Math.min(p,Math.floor(t[g+1]+a));c-=f,d-=p;for(let g=i;g<o;g+=2)t[g]=(t[g]+c)*l,t[g+1]=(t[g+1]+d)*u}};Nc.BATCHABLE_SIZE=100;let Uc=Nc;class Lr{constructor(){this.color=16777215,this.alpha=1,this.texture=j.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Lr;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=j.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Hs extends Lr{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=He.BUTT,this.join=$t.MITER,this.miterLimit=10}clone(){const t=new Hs;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=He.BUTT,this.join=$t.MITER,this.miterLimit=10}}const Co={},Ao=class yn extends Vt{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Lr,this._lineStyle=new Hs,this._matrix=null,this._holeMode=!1,this.state=fe.for2d(),this._geometry=t||new Uc,this._geometry.refCount++,this._transformID=-1,this._tintColor=new gt(16777215),this.blendMode=nt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new yn(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,r=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:r,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:j.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:He.BUTT,join:$t.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Ke,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Ke,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(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,r=i[i.length-2],n=i[i.length-1];return(r!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,r){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),Gs.curveTo(t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,a){return this._initCurve(),Us.curveTo(t,e,i,r,n,a,this.currentPath.points),this}arcTo(t,e,i,r,n){this._initCurve(t,e);const a=this.currentPath.points,o=To.curveTo(t,e,i,r,n,a);if(o){const{cx:h,cy:l,radius:u,startAngle:c,endAngle:d,anticlockwise:f}=o;this.arc(h,l,u,c,d,f)}return this}arc(t,e,i,r,n,a=!1){if(r===n)return this;if(!a&&n<=r?n+=dr:a&&r<=n&&(r+=dr),n-r===0)return this;const o=t+Math.cos(r)*i,h=e+Math.sin(r)*i,l=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-o),d=Math.abs(u[u.length-1]-h);c<l&&d<l||u.push(o,h)}else this.moveTo(o,h),u=this.currentPath.points;return To.arc(o,h,t,e,i,r,n,a,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:j.WHITE,color:t,alpha:e})}normalizeColor(t){const e=gt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:j.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,r){return this.drawShape(new ut(t,e,i,r))}drawRoundedRect(t,e,i,r,n){return this.drawShape(new mr(t,e,i,r,n))}drawCircle(t,e,i){return this.drawShape(new fr(t,e,i))}drawEllipse(t,e,i,r){return this.drawShape(new pr(t,e,i,r))}drawPolygon(...t){let e,i=!0;const r=t[0];r.points?(i=r.closeStroke,e=r.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Ke(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,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 t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Bt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let r=0;r<i;r++){const n=t.batches[r],a=n.style.color,o=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),h=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),l=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),u={vertexData:o,blendMode:e,indices:l,uvs:h,_batchRGB:gt.shared.setValue(a).toRgbArray(),_tintRGB:a,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[r]=u}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const r=this.batches[e];r.worldAlpha=this.worldAlpha*r.alpha,t.plugins[this.pluginName].render(r)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,r=this.worldAlpha,n=e.uniforms,a=i.drawCalls;n.translationMatrix=this.transform.worldTransform,gt.shared.setValue(this._tintColor).premultiply(r).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let o=0,h=a.length;o<h;o++)this._renderDrawCallDirect(t,i.drawCalls[o])}_renderDrawCallDirect(t,e){const{texArray:i,type:r,size:n,start:a}=e,o=i.count;for(let h=0;h<o;h++)t.texture.bind(i.elements[h],h);t.geometry.draw(r,n,a)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Co[i]){const{maxTextures:r}=t.plugins[i],n=new Int32Array(r);for(let h=0;h<r;h++)n[h]=h;const a={tint:new Float32Array([1,1,1,1]),translationMatrix:new vt,default:Qt.from({uSamplers:n},!0)},o=t.plugins[i]._shader.program;Co[i]=new me(o,a)}e=Co[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:r,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,r,n)}containsPoint(t){return this.worldTransform.applyInverse(t,yn._TEMP_POINT),this._geometry.containsPoint(yn._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=gt.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,r=e.b,n=e.c,a=e.d,o=e.tx,h=e.ty,l=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<l.length;d+=2){const f=l[d],p=l[d+1];u[c++]=i*f+n*p+o,u[c++]=a*p+r*f+h}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Ao.curves=ri,Ao._TEMP_POINT=new ft;let So=Ao;const Lg={buildPoly:bo,buildCircle:Dr,buildRectangle:Bc,buildRoundedRectangle:Lc,buildLine:Eo,ArcUtils:To,BezierUtils:Us,QuadraticUtils:Gs,BatchPart:Oc,FILL_COMMANDS:Vs,BATCH_POOL:wo,DRAW_CALL_POOL:Fr};class Gc{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const Po=new ft,Vc=new Ke,Hc=class uf extends Vt{constructor(t,e,i,r=oe.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||fe.for2d(),this.drawMode=r,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=q.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===oe.TRIANGLES&&e.length<uf.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const r=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[r]),t.plugins[r].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const r=this.transform.worldTransform,n=r.a,a=r.b,o=r.c,h=r.d,l=r.tx,u=r.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const f=e[d*2],p=e[d*2+1];c[d*2]=n*f+o*p+l,c[d*2+1]=a*f+h*p+u}if(this._roundPixels){const d=q.RESOLUTION;for(let f=0;f<c.length;++f)c[f]=Math.round(c[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new Gc(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,Po);const e=this.geometry.getBuffer("aVertexPosition").data,i=Vc.points,r=this.geometry.getIndex().data,n=r.length,a=this.drawMode===4?3:1;for(let o=0;o+2<n;o+=a){const h=r[o]*2,l=r[o+1]*2,u=r[o+2]*2;if(i[0]=e[h],i[1]=e[h+1],i[2]=e[l],i[3]=e[l+1],i[4]=e[u],i[5]=e[u+1],Vc.contains(Po.x,Po.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};Hc.BATCHABLE_SIZE=100;let Vi=Hc;class Or extends Ue{constructor(t,e,i){super();const r=new At(t),n=new At(e,!0),a=new At(i,!0,!0);this.addAttribute("aVertexPosition",r,2,!1,it.FLOAT).addAttribute("aTextureCoord",n,2,!1,it.FLOAT).addIndex(a),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Og=`varying vec2 vTextureCoord;
954
912
  uniform vec4 uColor;
955
913
 
956
914
  uniform sampler2D uSampler;
@@ -959,7 +917,7 @@ void main(void)
959
917
  {
960
918
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
961
919
  }
962
- `,jg=`attribute vec2 aVertexPosition;
920
+ `,kg=`attribute vec2 aVertexPosition;
963
921
  attribute vec2 aTextureCoord;
964
922
 
965
923
  uniform mat3 projectionMatrix;
@@ -974,7 +932,7 @@ void main(void)
974
932
 
975
933
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
976
934
  }
977
- `;class fn extends Mi{constructor(t,r){const i={uSampler:t,alpha:1,uTextureMatrix:nr.IDENTITY,uColor:new Float32Array([1,1,1,1])};r=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},r),r.uniforms&&Object.assign(i,r.uniforms),super(r.program||Hi.from(jg,Yg),i),this._colorDirty=!1,this.uvMatrix=new ea(t),this.batchable=r.program===void 0,this.pluginName=r.pluginName,this._tintColor=new rr(r.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=r.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;rr.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class ld extends so{constructor(t=100,r=100,i=10,n=10){super(),this.segWidth=i,this.segHeight=n,this.width=t,this.height=r,this.build()}build(){const t=this.segWidth*this.segHeight,r=[],i=[],n=[],o=this.segWidth-1,h=this.segHeight-1,c=this.width/o,b=this.height/h;for(let C=0;C<t;C++){const x=C%this.segWidth,$=C/this.segWidth|0;r.push(x*c,$*b),i.push(x/o,$/h)}const T=o*h;for(let C=0;C<T;C++){const x=C%o,$=C/o|0,I=$*this.segWidth+x,B=$*this.segWidth+x+1,U=($+1)*this.segWidth+x,G=($+1)*this.segWidth+x+1;n.push(I,B,U,B,G,U)}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class ud extends so{constructor(t=200,r,i=0){super(new Float32Array(r.length*4),new Float32Array(r.length*4),new Uint16Array((r.length-1)*6)),this.points=r,this._width=t,this.textureScale=i,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const r=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),n=this.getIndex();if(t.length<1)return;r.data.length/4!==t.length&&(r.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),n.data=new Uint16Array((t.length-1)*6));const o=i.data,h=n.data;o[0]=0,o[1]=0,o[2]=0,o[3]=1;let c=0,b=t[0];const T=this._width*this.textureScale,C=t.length;for(let $=0;$<C;$++){const I=$*4;if(this.textureScale>0){const B=b.x-t[$].x,U=b.y-t[$].y,G=Math.sqrt(B*B+U*U);b=t[$],c+=G/T}else c=$/(C-1);o[I]=c,o[I+1]=0,o[I+2]=c,o[I+3]=1}let x=0;for(let $=0;$<C-1;$++){const I=$*2;h[x++]=I,h[x++]=I+1,h[x++]=I+2,h[x++]=I+2,h[x++]=I+1,h[x++]=I+3}i.update(),n.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let r=t[0],i,n=0,o=0;const h=this.buffers[0].data,c=t.length,b=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let T=0;T<c;T++){const C=t[T],x=T*4;T<t.length-1?i=t[T+1]:i=C,o=-(i.x-r.x),n=i.y-r.y;const $=Math.sqrt(n*n+o*o);$<1e-6?(n=0,o=0):(n/=$,o/=$,n*=b,o*=b),h[x]=C.x+n,h[x+1]=C.y+o,h[x+2]=C.x-n,h[x+3]=C.y-o,r=C}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class cd extends cn{constructor(t,r,i){const n=new ld(t.width,t.height,r,i),o=new fn(ne.WHITE);super(n,o),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:r,height:i}=this.shader.texture;this.autoResize&&(t.width!==r||t.height!==i)&&(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)}}const ba=10;class qg extends cd{constructor(t,r,i,n,o){var h,c,b,T;super(ne.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=r??((h=t.defaultBorders)==null?void 0:h.left)??ba,this._rightWidth=n??((c=t.defaultBorders)==null?void 0:c.right)??ba,this._topHeight=i??((b=t.defaultBorders)==null?void 0:b.top)??ba,this._bottomHeight=o??((T=t.defaultBorders)==null?void 0:T.bottom)??ba,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,r=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*r,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*r,t[25]=t[27]=t[29]=t[31]=this._height}updateVerticalVertices(){const t=this.vertices,r=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*r,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*r,t[6]=t[14]=t[22]=t[30]=this._width}_getMinScale(){const t=this._leftWidth+this._rightWidth,r=this._width>t?1:this._width/t,i=this._topHeight+this._bottomHeight,n=this._height>i?1:this._height/i;return Math.min(r,n)}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,r=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;const i=1/this._origWidth,n=1/this._origHeight;r[0]=r[8]=r[16]=r[24]=0,r[1]=r[3]=r[5]=r[7]=0,r[6]=r[14]=r[22]=r[30]=1,r[25]=r[27]=r[29]=r[31]=1,r[2]=r[10]=r[18]=r[26]=i*this._leftWidth,r[4]=r[12]=r[20]=r[28]=1-i*this._rightWidth,r[9]=r[11]=r[13]=r[15]=n*this._topHeight,r[17]=r[19]=r[21]=r[23]=1-n*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}}class Zg extends cn{constructor(t=ne.EMPTY,r,i,n,o){const h=new so(r,i,n);h.getBuffer("aVertexPosition").static=!1;const c=new fn(t);super(h,c,null,o),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)}}class Qg extends cn{constructor(t,r,i=0){const n=new ud(t.height,r,i),o=new fn(t);i>0&&(t.baseTexture.wrapMode=Vi.REPEAT),super(n,o),this.autoUpdate=!0}_render(t){const r=this.geometry;(this.autoUpdate||r._width!==this.shader.texture.height)&&(r._width=this.shader.texture.height,r.update()),super._render(t)}}class Kg extends Zr{constructor(t=1500,r,i=16384,n=!1){super();const o=16384;i>o&&(i=o),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=i,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=De.NORMAL,this.autoResize=n,this.roundPixels=!0,this.baseTexture=null,this.setProperties(r),this._tintColor=new rr(0),this.tintRgb=new Float32Array(3),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._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintColor.toRgbArray(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 r=Math.floor(t/this._batchSize);for(;this._bufferUpdateIDs.length<r;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[r]=++this._updateID}dispose(){if(this._buffers){for(let t=0;t<this._buffers.length;++t)this._buffers[t].destroy();this._buffers=null}}destroy(t){super.destroy(t),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}class fd{constructor(t,r,i){this.geometry=new ls,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let n=0;n<t.length;++n){let o=t[n];o={attributeName:o.attributeName,size:o.size,uploadFunction:o.uploadFunction,type:o.type||Pe.FLOAT,offset:o.offset},r[n]?this.dynamicProperties.push(o):this.staticProperties.push(o)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let r=0;this.indexBuffer=new Ar(Kc(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let h=0;h<this.dynamicProperties.length;++h){const c=this.dynamicProperties[h];c.offset=r,r+=c.size,this.dynamicStride+=c.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new Ar(this.dynamicData,!1,!1);let n=0;this.staticStride=0;for(let h=0;h<this.staticProperties.length;++h){const c=this.staticProperties[h];c.offset=n,n+=c.size,this.staticStride+=c.size}const o=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(o),this.staticDataUint32=new Uint32Array(o),this.staticBuffer=new Ar(this.staticData,!0,!1);for(let h=0;h<this.dynamicProperties.length;++h){const c=this.dynamicProperties[h];t.addAttribute(c.attributeName,this.dynamicBuffer,0,c.type===Pe.UNSIGNED_BYTE,c.type,this.dynamicStride*4,c.offset*4)}for(let h=0;h<this.staticProperties.length;++h){const c=this.staticProperties[h];t.addAttribute(c.attributeName,this.staticBuffer,0,c.type===Pe.UNSIGNED_BYTE,c.type,this.staticStride*4,c.offset*4)}}uploadDynamic(t,r,i){for(let n=0;n<this.dynamicProperties.length;n++){const o=this.dynamicProperties[n];o.uploadFunction(t,r,i,o.type===Pe.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,o.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,r,i){for(let n=0;n<this.staticProperties.length;n++){const o=this.staticProperties[n];o.uploadFunction(t,r,i,o.type===Pe.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,o.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var Jg=`varying vec2 vTextureCoord;
935
+ `;class Hi extends me{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:vt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||Ae.from(kg,Og),i),this._colorDirty=!1,this.uvMatrix=new Es(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new gt(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;gt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Xc extends Or{constructor(t=100,e=100,i=10,r=10){super(),this.segWidth=i,this.segHeight=r,this.width=t,this.height=e,this.build()}build(){const t=this.segWidth*this.segHeight,e=[],i=[],r=[],n=this.segWidth-1,a=this.segHeight-1,o=this.width/n,h=this.height/a;for(let u=0;u<t;u++){const c=u%this.segWidth,d=u/this.segWidth|0;e.push(c*o,d*h),i.push(c/n,d/a)}const l=n*a;for(let u=0;u<l;u++){const c=u%n,d=u/n|0,f=d*this.segWidth+c,p=d*this.segWidth+c+1,g=(d+1)*this.segWidth+c,m=(d+1)*this.segWidth+c+1;r.push(f,p,g,p,m,g)}this.buffers[0].data=new Float32Array(e),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class zc extends Or{constructor(t=200,e,i=0){super(new Float32Array(e.length*4),new Float32Array(e.length*4),new Uint16Array((e.length-1)*6)),this.points=e,this._width=t,this.textureScale=i,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const e=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const n=i.data,a=r.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let o=0,h=t[0];const l=this._width*this.textureScale,u=t.length;for(let d=0;d<u;d++){const f=d*4;if(this.textureScale>0){const p=h.x-t[d].x,g=h.y-t[d].y,m=Math.sqrt(p*p+g*g);h=t[d],o+=m/l}else o=d/(u-1);n[f]=o,n[f+1]=0,n[f+2]=o,n[f+3]=1}let c=0;for(let d=0;d<u-1;d++){const f=d*2;a[c++]=f,a[c++]=f+1,a[c++]=f+2,a[c++]=f+2,a[c++]=f+1,a[c++]=f+3}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],i,r=0,n=0;const a=this.buffers[0].data,o=t.length,h=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let l=0;l<o;l++){const u=t[l],c=l*4;l<t.length-1?i=t[l+1]:i=u,n=-(i.x-e.x),r=i.y-e.y;const d=Math.sqrt(r*r+n*n);d<1e-6?(r=0,n=0):(r/=d,n/=d,r*=h,n*=h),a[c]=u.x+r,a[c+1]=u.y+n,a[c+2]=u.x-r,a[c+3]=u.y-n,e=u}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class Wc extends Vi{constructor(t,e,i){const r=new Xc(t.width,t.height,e,i),n=new Hi(j.WHITE);super(r,n),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:e,height:i}=this.shader.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(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)}}const Xs=10;class Ng extends Wc{constructor(t,e,i,r,n){var a,o,h,l;super(j.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=e??((a=t.defaultBorders)==null?void 0:a.left)??Xs,this._rightWidth=r??((o=t.defaultBorders)==null?void 0:o.right)??Xs,this._topHeight=i??((h=t.defaultBorders)==null?void 0:h.top)??Xs,this._bottomHeight=n??((l=t.defaultBorders)==null?void 0:l.bottom)??Xs,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,i=this._topHeight+this._bottomHeight,r=this._height>i?1:this._height/i;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 i=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]=i*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-i*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 Ug extends Vi{constructor(t=j.EMPTY,e,i,r,n){const a=new Or(e,i,r);a.getBuffer("aVertexPosition").static=!1;const o=new Hi(t);super(a,o,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)}}class Gg extends Vi{constructor(t,e,i=0){const r=new zc(t.height,e,i),n=new Hi(t);i>0&&(t.baseTexture.wrapMode=Te.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 Vg extends Vt{constructor(t=1500,e,i=16384,r=!1){super();const n=16384;i>n&&(i=n),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=i,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=nt.NORMAL,this.autoResize=r,this.roundPixels=!0,this.baseTexture=null,this.setProperties(e),this._tintColor=new gt(0),this.tintRgb=new Float32Array(3),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._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintColor.toRgbArray(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.length<e;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[e]=++this._updateID}dispose(){if(this._buffers){for(let t=0;t<this._buffers.length;++t)this._buffers[t].destroy();this._buffers=null}}destroy(t){super.destroy(t),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}class $c{constructor(t,e,i){this.geometry=new Ue,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let r=0;r<t.length;++r){let n=t[r];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||it.FLOAT,offset:n.offset},e[r]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new At(Bl(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let a=0;a<this.dynamicProperties.length;++a){const o=this.dynamicProperties[a];o.offset=e,e+=o.size,this.dynamicStride+=o.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new At(this.dynamicData,!1,!1);let r=0;this.staticStride=0;for(let a=0;a<this.staticProperties.length;++a){const o=this.staticProperties[a];o.offset=r,r+=o.size,this.staticStride+=o.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new At(this.staticData,!0,!1);for(let a=0;a<this.dynamicProperties.length;++a){const o=this.dynamicProperties[a];t.addAttribute(o.attributeName,this.dynamicBuffer,0,o.type===it.UNSIGNED_BYTE,o.type,this.dynamicStride*4,o.offset*4)}for(let a=0;a<this.staticProperties.length;++a){const o=this.staticProperties[a];t.addAttribute(o.attributeName,this.staticBuffer,0,o.type===it.UNSIGNED_BYTE,o.type,this.staticStride*4,o.offset*4)}}uploadDynamic(t,e,i){for(let r=0;r<this.dynamicProperties.length;r++){const n=this.dynamicProperties[r];n.uploadFunction(t,e,i,n.type===it.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let r=0;r<this.staticProperties.length;r++){const n=this.staticProperties[r];n.uploadFunction(t,e,i,n.type===it.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var Hg=`varying vec2 vTextureCoord;
978
936
  varying vec4 vColor;
979
937
 
980
938
  uniform sampler2D uSampler;
@@ -982,7 +940,7 @@ uniform sampler2D uSampler;
982
940
  void main(void){
983
941
  vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
984
942
  gl_FragColor = color;
985
- }`,tm=`attribute vec2 aVertexPosition;
943
+ }`,Xg=`attribute vec2 aVertexPosition;
986
944
  attribute vec2 aTextureCoord;
987
945
  attribute vec4 aColor;
988
946
 
@@ -1007,8 +965,8 @@ void main(void){
1007
965
  vTextureCoord = aTextureCoord;
1008
966
  vColor = aColor * uColor;
1009
967
  }
1010
- `;class ru extends Nn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new nr,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:Pe.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Mi.from(tm,Jg,{}),this.state=Pi.for2d()}render(t){const r=t.children,i=t._maxSize,n=t._batchSize,o=this.renderer;let h=r.length;if(h===0)return;h>i&&!t.autoResize&&(h=i);let c=t._buffers;c||(c=t._buffers=this.generateBuffers(t));const b=r[0]._texture.baseTexture,T=b.alphaMode>0;this.state.blendMode=Uh(t.blendMode,T),o.state.set(this.state);const C=o.gl,x=t.worldTransform.copyTo(this.tempMatrix);x.prepend(o.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=x.toArray(!0),this.shader.uniforms.uColor=rr.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,T).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=b,this.renderer.shader.bind(this.shader);let $=!1;for(let I=0,B=0;I<h;I+=n,B+=1){let U=h-I;U>n&&(U=n),B>=c.length&&c.push(this._generateOneMoreBuffer(t));const G=c[B];G.uploadDynamic(r,I,U);const z=t._bufferUpdateIDs[B]||0;$=$||G._updateID<z,$&&(G._updateID=t._updateID,G.uploadStatic(r,I,U)),o.geometry.bind(G.geometry),C.drawElements(C.TRIANGLES,U*6,C.UNSIGNED_SHORT,0)}}generateBuffers(t){const r=[],i=t._maxSize,n=t._batchSize,o=t._properties;for(let h=0;h<i;h+=n)r.push(new fd(this.properties,o,n));return r}_generateOneMoreBuffer(t){const r=t._batchSize,i=t._properties;return new fd(this.properties,i,r)}uploadVertices(t,r,i,n,o,h){let c=0,b=0,T=0,C=0;for(let x=0;x<i;++x){const $=t[r+x],I=$._texture,B=$.scale.x,U=$.scale.y,G=I.trim,z=I.orig;G?(b=G.x-$.anchor.x*z.width,c=b+G.width,C=G.y-$.anchor.y*z.height,T=C+G.height):(c=z.width*(1-$.anchor.x),b=z.width*-$.anchor.x,T=z.height*(1-$.anchor.y),C=z.height*-$.anchor.y),n[h]=b*B,n[h+1]=C*U,n[h+o]=c*B,n[h+o+1]=C*U,n[h+o*2]=c*B,n[h+o*2+1]=T*U,n[h+o*3]=b*B,n[h+o*3+1]=T*U,h+=o*4}}uploadPosition(t,r,i,n,o,h){for(let c=0;c<i;c++){const b=t[r+c].position;n[h]=b.x,n[h+1]=b.y,n[h+o]=b.x,n[h+o+1]=b.y,n[h+o*2]=b.x,n[h+o*2+1]=b.y,n[h+o*3]=b.x,n[h+o*3+1]=b.y,h+=o*4}}uploadRotation(t,r,i,n,o,h){for(let c=0;c<i;c++){const b=t[r+c].rotation;n[h]=b,n[h+o]=b,n[h+o*2]=b,n[h+o*3]=b,h+=o*4}}uploadUvs(t,r,i,n,o,h){for(let c=0;c<i;++c){const b=t[r+c]._texture._uvs;b?(n[h]=b.x0,n[h+1]=b.y0,n[h+o]=b.x1,n[h+o+1]=b.y1,n[h+o*2]=b.x2,n[h+o*2+1]=b.y2,n[h+o*3]=b.x3,n[h+o*3+1]=b.y3,h+=o*4):(n[h]=0,n[h+1]=0,n[h+o]=0,n[h+o+1]=0,n[h+o*2]=0,n[h+o*2+1]=0,n[h+o*3]=0,n[h+o*3+1]=0,h+=o*4)}}uploadTint(t,r,i,n,o,h){for(let c=0;c<i;++c){const b=t[r+c],T=rr.shared.setValue(b._tintRGB).toPremultiplied(b.alpha,b.texture.baseTexture.alphaMode>0);n[h]=T,n[h+o]=T,n[h+o*2]=T,n[h+o*3]=T,h+=o*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}ru.extension={name:"particle",type:Kt.RendererPlugin},be.add(ru);var no=(s=>(s[s.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",s[s.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",s))(no||{});const Aa={willReadFrequently:!0},Zi=class Se{static get experimentalLetterSpacingSupported(){let t=Se._experimentalLetterSpacingSupported;if(t!==void 0){const r=ue.ADAPTER.getCanvasRenderingContext2D().prototype;t=Se._experimentalLetterSpacingSupported="letterSpacing"in r||"textLetterSpacing"in r}return t}constructor(t,r,i,n,o,h,c,b,T){this.text=t,this.style=r,this.width=i,this.height=n,this.lines=o,this.lineWidths=h,this.lineHeight=c,this.maxLineWidth=b,this.fontProperties=T}static measureText(t,r,i,n=Se._canvas){i=i??r.wordWrap;const o=r.toFontString(),h=Se.measureFont(o);h.fontSize===0&&(h.fontSize=r.fontSize,h.ascent=r.fontSize);const c=n.getContext("2d",Aa);c.font=o;const b=(i?Se.wordWrap(t,r,n):t).split(/(?:\r\n|\r|\n)/),T=new Array(b.length);let C=0;for(let B=0;B<b.length;B++){const U=Se._measureText(b[B],r.letterSpacing,c);T[B]=U,C=Math.max(C,U)}let x=C+r.strokeThickness;r.dropShadow&&(x+=r.dropShadowDistance);const $=r.lineHeight||h.fontSize+r.strokeThickness;let I=Math.max($,h.fontSize+r.strokeThickness*2)+r.leading+(b.length-1)*($+r.leading);return r.dropShadow&&(I+=r.dropShadowDistance),new Se(t,r,x,I,b,T,$+r.leading,C,h)}static _measureText(t,r,i){let n=!1;Se.experimentalLetterSpacingSupported&&(Se.experimentalLetterSpacing?(i.letterSpacing=`${r}px`,i.textLetterSpacing=`${r}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let o=i.measureText(t).width;return o>0&&(n?o-=r:o+=(Se.graphemeSegmenter(t).length-1)*r),o}static wordWrap(t,r,i=Se._canvas){const n=i.getContext("2d",Aa);let o=0,h="",c="";const b=Object.create(null),{letterSpacing:T,whiteSpace:C}=r,x=Se.collapseSpaces(C),$=Se.collapseNewlines(C);let I=!x;const B=r.wordWrapWidth+T,U=Se.tokenize(t);for(let G=0;G<U.length;G++){let z=U[G];if(Se.isNewline(z)){if(!$){c+=Se.addLine(h),I=!x,h="",o=0;continue}z=" "}if(x){const Z=Se.isBreakingSpace(z),it=Se.isBreakingSpace(h[h.length-1]);if(Z&&it)continue}const J=Se.getFromCache(z,T,b,n);if(J>B)if(h!==""&&(c+=Se.addLine(h),h="",o=0),Se.canBreakWords(z,r.breakWords)){const Z=Se.wordWrapSplit(z);for(let it=0;it<Z.length;it++){let Q=Z[it],_t=Q,et=1;for(;Z[it+et];){const wt=Z[it+et];if(!Se.canBreakChars(_t,wt,z,it,r.breakWords))Q+=wt;else break;_t=wt,et++}it+=et-1;const ft=Se.getFromCache(Q,T,b,n);ft+o>B&&(c+=Se.addLine(h),I=!1,h="",o=0),h+=Q,o+=ft}}else{h.length>0&&(c+=Se.addLine(h),h="",o=0);const Z=G===U.length-1;c+=Se.addLine(z,!Z),I=!1,h="",o=0}else J+o>B&&(I=!1,c+=Se.addLine(h),h="",o=0),(h.length>0||!Se.isBreakingSpace(z)||I)&&(h+=z,o+=J)}return c+=Se.addLine(h,!1),c}static addLine(t,r=!0){return t=Se.trimRight(t),t=r?`${t}
1011
- `:t,t}static getFromCache(t,r,i,n){let o=i[t];return typeof o!="number"&&(o=Se._measureText(t,r,n)+r,i[t]=o),o}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 r=t.length-1;r>=0;r--){const i=t[r];if(!Se.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:Se._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,r){return typeof t!="string"?!1:Se._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const r=[];let i="";if(typeof t!="string")return r;for(let n=0;n<t.length;n++){const o=t[n],h=t[n+1];if(Se.isBreakingSpace(o,h)||Se.isNewline(o)){i!==""&&(r.push(i),i=""),r.push(o);continue}i+=o}return i!==""&&r.push(i),r}static canBreakWords(t,r){return r}static canBreakChars(t,r,i,n,o){return!0}static wordWrapSplit(t){return Se.graphemeSegmenter(t)}static measureFont(t){if(Se._fonts[t])return Se._fonts[t];const r={ascent:0,descent:0,fontSize:0},i=Se._canvas,n=Se._context;n.font=t;const o=Se.METRICS_STRING+Se.BASELINE_SYMBOL,h=Math.ceil(n.measureText(o).width);let c=Math.ceil(n.measureText(Se.BASELINE_SYMBOL).width);const b=Math.ceil(Se.HEIGHT_MULTIPLIER*c);if(c=c*Se.BASELINE_MULTIPLIER|0,h===0||b===0)return Se._fonts[t]=r,r;i.width=h,i.height=b,n.fillStyle="#f00",n.fillRect(0,0,h,b),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(o,0,c);const T=n.getImageData(0,0,h,b).data,C=T.length,x=h*4;let $=0,I=0,B=!1;for($=0;$<c;++$){for(let U=0;U<x;U+=4)if(T[I+U]!==255){B=!0;break}if(!B)I+=x;else break}for(r.ascent=c-$,I=C-x,B=!1,$=b;$>c;--$){for(let U=0;U<x;U+=4)if(T[I+U]!==255){B=!0;break}if(!B)I-=x;else break}return r.descent=$-c,r.fontSize=r.ascent+r.descent,Se._fonts[t]=r,r}static clearMetrics(t=""){t?delete Se._fonts[t]:Se._fonts={}}static get _canvas(){var t;if(!Se.__canvas){let r;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Aa))!=null&&t.measureText)return Se.__canvas=i,i;r=ue.ADAPTER.createCanvas()}catch{r=ue.ADAPTER.createCanvas()}r.width=r.height=10,Se.__canvas=r}return Se.__canvas}static get _context(){return Se.__context||(Se.__context=Se._canvas.getContext("2d",Aa)),Se.__context}};Zi.METRICS_STRING="|ÉqÅ",Zi.BASELINE_SYMBOL="M",Zi.BASELINE_MULTIPLIER=1.4,Zi.HEIGHT_MULTIPLIER=2,Zi.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(r=>r.segment)}return s=>[...s]})(),Zi.experimentalLetterSpacing=!1,Zi._fonts={},Zi._newlines=[10,13],Zi._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let ds=Zi;const em=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],dd=class Io{constructor(t){this.styleID=0,this.reset(),su(this,t,t)}clone(){const t={};return su(t,this,Io.defaultStyle),new Io(t)}reset(){su(this,Io.defaultStyle,Io.defaultStyle)}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 r=iu(t);this._dropShadowColor!==r&&(this._dropShadowColor=r,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 r=iu(t);this._fill!==r&&(this._fill=r,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){rm(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 r=iu(t);this._stroke!==r&&(this._stroke=r,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 r=this.fontFamily;Array.isArray(this.fontFamily)||(r=this.fontFamily.split(","));for(let i=r.length-1;i>=0;i--){let n=r[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!em.includes(n)&&(n=`"${n}"`),r[i]=n}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${r.join(",")}`}};dd.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:no.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let ps=dd;function iu(s){const t=rr.shared,r=i=>{const n=t.setValue(i);return n.alpha===1?n.toHex():n.toRgbaString()};return Array.isArray(s)?s.map(r):r(s)}function rm(s,t){if(!Array.isArray(s)||!Array.isArray(t)||s.length!==t.length)return!1;for(let r=0;r<s.length;++r)if(s[r]!==t[r])return!1;return!0}function su(s,t,r){for(const i in r)Array.isArray(t[i])?s[i]=t[i].slice():s[i]=t[i]}const im={texture:!0,children:!1,baseTexture:!0},pd=class ku extends us{constructor(t,r,i){let n=!1;i||(i=ue.ADAPTER.createCanvas(),n=!0),i.width=3,i.height=3;const o=ne.from(i);o.orig=new Ve,o.trim=new Ve,super(o),this._ownCanvas=n,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=ku.defaultResolution??ue.RESOLUTION,this._autoResolution=ku.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=r,this.localStyleID=-1}static get experimentalLetterSpacing(){return ds.experimentalLetterSpacing}static set experimentalLetterSpacing(t){Oe("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),ds.experimentalLetterSpacing=t}updateText(t){const r=this._style;if(this.localStyleID!==r.styleID&&(this.dirty=!0,this.localStyleID=r.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,n=ds.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),o=n.width,h=n.height,c=n.lines,b=n.lineHeight,T=n.lineWidths,C=n.maxLineWidth,x=n.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,o)+r.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,h)+r.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=r.strokeThickness,i.textBaseline=r.textBaseline,i.lineJoin=r.lineJoin,i.miterLimit=r.miterLimit;let $,I;const B=r.dropShadow?2:1;for(let U=0;U<B;++U){const G=r.dropShadow&&U===0,z=G?Math.ceil(Math.max(1,h)+r.padding*2):0,J=z*this._resolution;if(G){i.fillStyle="black",i.strokeStyle="black";const it=r.dropShadowColor,Q=r.dropShadowBlur*this._resolution,_t=r.dropShadowDistance*this._resolution;i.shadowColor=rr.shared.setValue(it).setAlpha(r.dropShadowAlpha).toRgbaString(),i.shadowBlur=Q,i.shadowOffsetX=Math.cos(r.dropShadowAngle)*_t,i.shadowOffsetY=Math.sin(r.dropShadowAngle)*_t+J}else i.fillStyle=this._generateFillStyle(r,c,n),i.strokeStyle=r.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let Z=(b-x.fontSize)/2;b-x.fontSize<0&&(Z=0);for(let it=0;it<c.length;it++)$=r.strokeThickness/2,I=r.strokeThickness/2+it*b+x.ascent+Z,r.align==="right"?$+=C-T[it]:r.align==="center"&&($+=(C-T[it])/2),r.stroke&&r.strokeThickness&&this.drawLetterSpacing(c[it],$+r.padding,I+r.padding-z,!0),r.fill&&this.drawLetterSpacing(c[it],$+r.padding,I+r.padding-z)}this.updateTexture()}drawLetterSpacing(t,r,i,n=!1){const o=this._style.letterSpacing;let h=!1;if(ds.experimentalLetterSpacingSupported&&(ds.experimentalLetterSpacing?(this.context.letterSpacing=`${o}px`,this.context.textLetterSpacing=`${o}px`,h=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),o===0||h){n?this.context.strokeText(t,r,i):this.context.fillText(t,r,i);return}let c=r;const b=ds.graphemeSegmenter(t);let T=this.context.measureText(t).width,C=0;for(let x=0;x<b.length;++x){const $=b[x];n?this.context.strokeText($,c,i):this.context.fillText($,c,i);let I="";for(let B=x+1;B<b.length;++B)I+=b[B];C=this.context.measureText(I).width,c+=T-C+o,T=C}}updateTexture(){const t=this.canvas;if(this._style.trim){const h=i0(t);h.data&&(t.width=h.width,t.height=h.height,this.context.putImageData(h.data,0,0))}const r=this._texture,i=this._style,n=i.trim?0:i.padding,o=r.baseTexture;r.trim.width=r._frame.width=t.width/this._resolution,r.trim.height=r._frame.height=t.height/this._resolution,r.trim.x=-n,r.trim.y=-n,r.orig.width=r._frame.width-n*2,r.orig.height=r._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(t.width,t.height,this._resolution),r.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,r){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,r)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,r,i){const n=t.fill;if(Array.isArray(n)){if(n.length===1)return n[0]}else return n;let o;const h=t.dropShadow?t.dropShadowDistance:0,c=t.padding||0,b=this.canvas.width/this._resolution-h-c*2,T=this.canvas.height/this._resolution-h-c*2,C=n.slice(),x=t.fillGradientStops.slice();if(!x.length){const $=C.length+1;for(let I=1;I<$;++I)x.push(I/$)}if(C.unshift(n[0]),x.unshift(0),C.push(n[n.length-1]),x.push(1),t.fillGradientType===no.LINEAR_VERTICAL){o=this.context.createLinearGradient(b/2,c,b/2,T+c);const $=i.fontProperties.fontSize+t.strokeThickness;for(let I=0;I<r.length;I++){const B=i.lineHeight*(I-1)+$,U=i.lineHeight*I;let G=U;I>0&&B>U&&(G=(U+B)/2);const z=U+$,J=i.lineHeight*(I+1);let Z=z;I+1<r.length&&J<z&&(Z=(z+J)/2);const it=(Z-G)/T;for(let Q=0;Q<C.length;Q++){let _t=0;typeof x[Q]=="number"?_t=x[Q]:_t=Q/C.length;let et=Math.min(1,Math.max(0,G/T+_t*it));et=Number(et.toFixed(5)),o.addColorStop(et,C[Q])}}}else{o=this.context.createLinearGradient(c,T/2,b+c,T/2);const $=C.length+1;let I=1;for(let B=0;B<C.length;B++){let U;typeof x[B]=="number"?U=x[B]:U=I/$,o.addColorStop(U,C[B]),I++}}return o}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},im,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const r=hs(this.scale.x)||1;this.scale.x=r*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const r=hs(this.scale.y)||1;this.scale.y=r*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof ps?this._style=t:this._style=new ps(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(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)}};pd.defaultAutoResolution=!0;let nu=pd;class _d{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function sm(s,t){var i;let r=!1;if((i=s==null?void 0:s._textures)!=null&&i.length){for(let n=0;n<s._textures.length;n++)if(s._textures[n]instanceof ne){const o=s._textures[n].baseTexture;t.includes(o)||(t.push(o),r=!0)}}return r}function nm(s,t){if(s.baseTexture instanceof Ge){const r=s.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function om(s,t){if(s._texture&&s._texture instanceof ne){const r=s._texture.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function am(s,t){return t instanceof nu?(t.updateText(!0),!0):!1}function hm(s,t){if(t instanceof ps){const r=t.toFontString();return ds.measureFont(r),!0}return!1}function lm(s,t){if(s instanceof nu){t.includes(s.style)||t.push(s.style),t.includes(s)||t.push(s);const r=s._texture.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function um(s,t){return s instanceof ps?(t.includes(s)||t.push(s),!0):!1}const gd=class A2{constructor(t){this.limiter=new _d(A2.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(lm),this.registerFindHook(um),this.registerFindHook(sm),this.registerFindHook(nm),this.registerFindHook(om),this.registerUploadHook(am),this.registerUploadHook(hm)}upload(t){return new Promise(r=>{t&&this.add(t),this.queue.length?(this.completes.push(r),this.ticking||(this.ticking=!0,vr.system.addOnce(this.tick,this,ji.UTILITY))):r()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let r=!1;if(t&&!t._destroyed){for(let i=0,n=this.uploadHooks.length;i<n;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),r=!0;break}}r||this.queue.shift()}if(this.queue.length)vr.system.addOnce(this.tick,this,ji.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let r=0,i=t.length;r<i;r++)t[r]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let r=0,i=this.addHooks.length;r<i&&!this.addHooks[r](t,this.queue);r++);if(t instanceof Zr)for(let r=t.children.length-1;r>=0;r--)this.add(t.children[r]);return this}destroy(){this.ticking&&vr.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}};gd.uploadsPerFrame=4;let wa=gd;Object.defineProperties(ue,{UPLOADS_PER_FRAME:{get(){return wa.uploadsPerFrame},set(s){Oe("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),wa.uploadsPerFrame=s}}});function md(s,t){return t instanceof Ge?(t._glTextures[s.CONTEXT_UID]||s.texture.bind(t),!0):!1}function cm(s,t){if(!(t instanceof tu))return!1;const{geometry:r}=t;t.finishPoly(),r.updateBatches();const{batches:i}=r;for(let n=0;n<i.length;n++){const{texture:o}=i[n].style;o&&md(s,o.baseTexture)}return r.batchable||s.geometry.bind(r,t._resolveDirectShader(s)),!0}function fm(s,t){return s instanceof tu?(t.push(s),!0):!1}class ou extends wa{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(fm),this.registerUploadHook(md),this.registerUploadHook(cm)}}ou.extension={name:"prepare",type:Kt.RendererSystem},be.add(ou);class dm{constructor(t){this.maxMilliseconds=t,this.frameStart=0}beginFrame(){this.frameStart=Date.now()}allowedToUpload(){return Date.now()-this.frameStart<this.maxMilliseconds}}class Ta extends us{constructor(t,r=!0){super(t[0]instanceof ne?t[0]:t[0].texture),this._textures=null,this._durations=null,this._autoUpdate=r,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&&(vr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(vr.shared.add(this.update,this,ji.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 r=this.animationSpeed*t,i=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=r/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=r;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()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<i||this.animationSpeed<0&&this.currentFrame>i)&&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 r=[];for(let i=0;i<t.length;++i)r.push(ne.from(t[i]));return new Ta(r)}static fromImages(t){const r=[];for(let i=0;i<t.length;++i)r.push(ne.from(t[i]));return new Ta(r)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof ne)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let r=0;r<t.length;r++)this._textures.push(t[r].texture),this._durations.push(t[r].time)}this._previousFrame=null,this.gotoAndStop(0),this.updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const r=this.currentFrame;this._currentTime=t,r!==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?(vr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(vr.shared.add(this.update,this),this._isConnectedToTicker=!0))}}const oo=new He;class au extends us{constructor(t,r=100,i=100){super(t),this.tileTransform=new rn,this._width=r,this._height=i,this.uvMatrix=this.texture.uvMatrix||new ea(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 r=this._texture;!r||!r.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,r=this._height*-this._anchor._y,i=this._width*(1-this._anchor._x),n=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,r,i,n)}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 Ve),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,oo);const r=this._width,i=this._height,n=-r*this.anchor._x;if(oo.x>=n&&oo.x<n+r){const o=-i*this.anchor._y;if(oo.y>=o&&oo.y<o+i)return!0}return!1}destroy(t){super.destroy(t),this.tileTransform=null,this.uvMatrix=null}static from(t,r){const i=t instanceof ne?t:ne.from(t,r);return new au(i,r.width,r.height)}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}}var pm=`#version 300 es
968
+ `;class Mo extends _r{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new vt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:it.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=me.from(Xg,Hg,{}),this.state=fe.for2d()}render(t){const e=t.children,i=t._maxSize,r=t._batchSize,n=this.renderer;let a=e.length;if(a===0)return;a>i&&!t.autoResize&&(a=i);let o=t._buffers;o||(o=t._buffers=this.generateBuffers(t));const h=e[0]._texture.baseTexture,l=h.alphaMode>0;this.state.blendMode=da(t.blendMode,l),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=gt.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,l).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=h,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;f<a;f+=r,p+=1){let g=a-f;g>r&&(g=r),p>=o.length&&o.push(this._generateOneMoreBuffer(t));const m=o[p];m.uploadDynamic(e,f,g);const _=t._bufferUpdateIDs[p]||0;d=d||m._updateID<_,d&&(m._updateID=t._updateID,m.uploadStatic(e,f,g)),n.geometry.bind(m.geometry),u.drawElements(u.TRIANGLES,g*6,u.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,r=t._batchSize,n=t._properties;for(let a=0;a<i;a+=r)e.push(new $c(this.properties,n,r));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new $c(this.properties,i,e)}uploadVertices(t,e,i,r,n,a){let o=0,h=0,l=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],f=d._texture,p=d.scale.x,g=d.scale.y,m=f.trim,_=f.orig;m?(h=m.x-d.anchor.x*_.width,o=h+m.width,u=m.y-d.anchor.y*_.height,l=u+m.height):(o=_.width*(1-d.anchor.x),h=_.width*-d.anchor.x,l=_.height*(1-d.anchor.y),u=_.height*-d.anchor.y),r[a]=h*p,r[a+1]=u*g,r[a+n]=o*p,r[a+n+1]=u*g,r[a+n*2]=o*p,r[a+n*2+1]=l*g,r[a+n*3]=h*p,r[a+n*3+1]=l*g,a+=n*4}}uploadPosition(t,e,i,r,n,a){for(let o=0;o<i;o++){const h=t[e+o].position;r[a]=h.x,r[a+1]=h.y,r[a+n]=h.x,r[a+n+1]=h.y,r[a+n*2]=h.x,r[a+n*2+1]=h.y,r[a+n*3]=h.x,r[a+n*3+1]=h.y,a+=n*4}}uploadRotation(t,e,i,r,n,a){for(let o=0;o<i;o++){const h=t[e+o].rotation;r[a]=h,r[a+n]=h,r[a+n*2]=h,r[a+n*3]=h,a+=n*4}}uploadUvs(t,e,i,r,n,a){for(let o=0;o<i;++o){const h=t[e+o]._texture._uvs;h?(r[a]=h.x0,r[a+1]=h.y0,r[a+n]=h.x1,r[a+n+1]=h.y1,r[a+n*2]=h.x2,r[a+n*2+1]=h.y2,r[a+n*3]=h.x3,r[a+n*3+1]=h.y3,a+=n*4):(r[a]=0,r[a+1]=0,r[a+n]=0,r[a+n+1]=0,r[a+n*2]=0,r[a+n*2+1]=0,r[a+n*3]=0,r[a+n*3+1]=0,a+=n*4)}}uploadTint(t,e,i,r,n,a){for(let o=0;o<i;++o){const h=t[e+o],l=gt.shared.setValue(h._tintRGB).toPremultiplied(h.alpha,h.texture.baseTexture.alphaMode>0);r[a]=l,r[a+n]=l,r[a+n*2]=l,r[a+n*3]=l,a+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Mo.extension={name:"particle",type:$.RendererPlugin},Q.add(Mo);var kr=(s=>(s[s.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",s[s.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",s))(kr||{});const zs={willReadFrequently:!0},Ie=class et{static get experimentalLetterSpacingSupported(){let t=et._experimentalLetterSpacingSupported;if(t!==void 0){const e=q.ADAPTER.getCanvasRenderingContext2D().prototype;t=et._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,a,o,h,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t,e,i,r=et._canvas){i=i??e.wordWrap;const n=e.toFontString(),a=et.measureFont(n);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const o=r.getContext("2d",zs);o.font=n;const h=(i?et.wordWrap(t,e,r):t).split(/(?:\r\n|\r|\n)/),l=new Array(h.length);let u=0;for(let p=0;p<h.length;p++){const g=et._measureText(h[p],e.letterSpacing,o);l[p]=g,u=Math.max(u,g)}let c=u+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);const d=e.lineHeight||a.fontSize+e.strokeThickness;let f=Math.max(d,a.fontSize+e.strokeThickness*2)+e.leading+(h.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new et(t,e,c,f,h,l,d+e.leading,u,a)}static _measureText(t,e,i){let r=!1;et.experimentalLetterSpacingSupported&&(et.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(r?n-=e:n+=(et.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=et._canvas){const r=i.getContext("2d",zs);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:u}=e,c=et.collapseSpaces(u),d=et.collapseNewlines(u);let f=!c;const p=e.wordWrapWidth+l,g=et.tokenize(t);for(let m=0;m<g.length;m++){let _=g[m];if(et.isNewline(_)){if(!d){o+=et.addLine(a),f=!c,a="",n=0;continue}_=" "}if(c){const y=et.isBreakingSpace(_),E=et.isBreakingSpace(a[a.length-1]);if(y&&E)continue}const b=et.getFromCache(_,l,h,r);if(b>p)if(a!==""&&(o+=et.addLine(a),a="",n=0),et.canBreakWords(_,e.breakWords)){const y=et.wordWrapSplit(_);for(let E=0;E<y.length;E++){let v=y[E],M=v,T=1;for(;y[E+T];){const N=y[E+T];if(!et.canBreakChars(M,N,_,E,e.breakWords))v+=N;else break;M=N,T++}E+=T-1;const P=et.getFromCache(v,l,h,r);P+n>p&&(o+=et.addLine(a),f=!1,a="",n=0),a+=v,n+=P}}else{a.length>0&&(o+=et.addLine(a),a="",n=0);const y=m===g.length-1;o+=et.addLine(_,!y),f=!1,a="",n=0}else b+n>p&&(f=!1,o+=et.addLine(a),a="",n=0),(a.length>0||!et.isBreakingSpace(_)||f)&&(a+=_,n+=b)}return o+=et.addLine(a,!1),o}static addLine(t,e=!0){return t=et.trimRight(t),t=e?`${t}
969
+ `:t,t}static getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=et._measureText(t,e,r)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!et.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:et._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:et._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],a=t[r+1];if(et.isBreakingSpace(n,a)||et.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return et.graphemeSegmenter(t)}static measureFont(t){if(et._fonts[t])return et._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=et._canvas,r=et._context;r.font=t;const n=et.METRICS_STRING+et.BASELINE_SYMBOL,a=Math.ceil(r.measureText(n).width);let o=Math.ceil(r.measureText(et.BASELINE_SYMBOL).width);const h=Math.ceil(et.HEIGHT_MULTIPLIER*o);if(o=o*et.BASELINE_MULTIPLIER|0,a===0||h===0)return et._fonts[t]=e,e;i.width=a,i.height=h,r.fillStyle="#f00",r.fillRect(0,0,a,h),r.font=t,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(n,0,o);const l=r.getImageData(0,0,a,h).data,u=l.length,c=a*4;let d=0,f=0,p=!1;for(d=0;d<o;++d){for(let g=0;g<c;g+=4)if(l[f+g]!==255){p=!0;break}if(!p)f+=c;else break}for(e.ascent=o-d,f=u-c,p=!1,d=h;d>o;--d){for(let g=0;g<c;g+=4)if(l[f+g]!==255){p=!0;break}if(!p)f-=c;else break}return e.descent=d-o,e.fontSize=e.ascent+e.descent,et._fonts[t]=e,e}static clearMetrics(t=""){t?delete et._fonts[t]:et._fonts={}}static get _canvas(){var t;if(!et.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",zs))!=null&&t.measureText)return et.__canvas=i,i;e=q.ADAPTER.createCanvas()}catch{e=q.ADAPTER.createCanvas()}e.width=e.height=10,et.__canvas=e}return et.__canvas}static get _context(){return et.__context||(et.__context=et._canvas.getContext("2d",zs)),et.__context}};Ie.METRICS_STRING="|ÉqÅ",Ie.BASELINE_SYMBOL="M",Ie.BASELINE_MULTIPLIER=1.4,Ie.HEIGHT_MULTIPLIER=2,Ie.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})(),Ie.experimentalLetterSpacing=!1,Ie._fonts={},Ie._newlines=[10,13],Ie._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Xe=Ie;const zg=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],jc=class es{constructor(t){this.styleID=0,this.reset(),Ro(this,t,t)}clone(){const t={};return Ro(t,this,es.defaultStyle),new es(t)}reset(){Ro(this,es.defaultStyle,es.defaultStyle)}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=Io(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=Io(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){Wg(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=Io(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 i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!zg.includes(r)&&(r=`"${r}"`),e[i]=r}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};jc.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:kr.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let ze=jc;function Io(s){const t=gt.shared,e=i=>{const r=t.setValue(i);return r.alpha===1?r.toHex():r.toRgbaString()};return Array.isArray(s)?s.map(e):e(s)}function Wg(s,t){if(!Array.isArray(s)||!Array.isArray(t)||s.length!==t.length)return!1;for(let e=0;e<s.length;++e)if(s[e]!==t[e])return!1;return!0}function Ro(s,t,e){for(const i in e)Array.isArray(t[i])?s[i]=t[i].slice():s[i]=t[i]}const $g={texture:!0,children:!1,baseTexture:!0},Yc=class yh extends Ge{constructor(t,e,i){let r=!1;i||(i=q.ADAPTER.createCanvas(),r=!0),i.width=3,i.height=3;const n=j.from(i);n.orig=new ut,n.trim=new ut,super(n),this._ownCanvas=r,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=yh.defaultResolution??q.RESOLUTION,this._autoResolution=yh.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Xe.experimentalLetterSpacing}static set experimentalLetterSpacing(t){ot("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Xe.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,r=Xe.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=r.width,a=r.height,o=r.lines,h=r.lineHeight,l=r.lineWidths,u=r.maxLineWidth,c=r.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,a)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let g=0;g<p;++g){const m=e.dropShadow&&g===0,_=m?Math.ceil(Math.max(1,a)+e.padding*2):0,b=_*this._resolution;if(m){i.fillStyle="black",i.strokeStyle="black";const E=e.dropShadowColor,v=e.dropShadowBlur*this._resolution,M=e.dropShadowDistance*this._resolution;i.shadowColor=gt.shared.setValue(E).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=v,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*M,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*M+b}else i.fillStyle=this._generateFillStyle(e,o,r),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let y=(h-c.fontSize)/2;h-c.fontSize<0&&(y=0);for(let E=0;E<o.length;E++)d=e.strokeThickness/2,f=e.strokeThickness/2+E*h+c.ascent+y,e.align==="right"?d+=u-l[E]:e.align==="center"&&(d+=(u-l[E])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(o[E],d+e.padding,f+e.padding-_,!0),e.fill&&this.drawLetterSpacing(o[E],d+e.padding,f+e.padding-_)}this.updateTexture()}drawLetterSpacing(t,e,i,r=!1){const n=this._style.letterSpacing;let a=!1;if(Xe.experimentalLetterSpacingSupported&&(Xe.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,a=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||a){r?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let o=e;const h=Xe.graphemeSegmenter(t);let l=this.context.measureText(t).width,u=0;for(let c=0;c<h.length;++c){const d=h[c];r?this.context.strokeText(d,o,i):this.context.fillText(d,o,i);let f="";for(let p=c+1;p<h.length;++p)f+=h[p];u=this.context.measureText(f).width,o+=l-u+n,l=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const a=Ul(t);a.data&&(t.width=a.width,t.height=a.height,this.context.putImageData(a.data,0,0))}const e=this._texture,i=this._style,r=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-r,e.trim.y=-r,e.orig.width=e._frame.width-r*2,e.orig.height=e._frame.height-r*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const r=t.fill;if(Array.isArray(r)){if(r.length===1)return r[0]}else return r;let n;const a=t.dropShadow?t.dropShadowDistance:0,o=t.padding||0,h=this.canvas.width/this._resolution-a-o*2,l=this.canvas.height/this._resolution-a-o*2,u=r.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let f=1;f<d;++f)c.push(f/d)}if(u.unshift(r[0]),c.unshift(0),u.push(r[r.length-1]),c.push(1),t.fillGradientType===kr.LINEAR_VERTICAL){n=this.context.createLinearGradient(h/2,o,h/2,l+o);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,g=i.lineHeight*f;let m=g;f>0&&p>g&&(m=(g+p)/2);const _=g+d,b=i.lineHeight*(f+1);let y=_;f+1<e.length&&b<_&&(y=(_+b)/2);const E=(y-m)/l;for(let v=0;v<u.length;v++){let M=0;typeof c[v]=="number"?M=c[v]:M=v/u.length;let T=Math.min(1,Math.max(0,m/l+M*E));T=Number(T.toFixed(5)),n.addColorStop(T,u[v])}}}else{n=this.context.createLinearGradient(o,l/2,h+o,l/2);const d=u.length+1;let f=1;for(let p=0;p<u.length;p++){let g;typeof c[p]=="number"?g=c[p]:g=f/d,n.addColorStop(g,u[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},$g,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=Ne(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=Ne(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof ze?this._style=t:this._style=new ze(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(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)}};Yc.defaultAutoResolution=!0;let Do=Yc;class qc{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function jg(s,t){var i;let e=!1;if((i=s==null?void 0:s._textures)!=null&&i.length){for(let r=0;r<s._textures.length;r++)if(s._textures[r]instanceof j){const n=s._textures[r].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function Yg(s,t){if(s.baseTexture instanceof lt){const e=s.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function qg(s,t){if(s._texture&&s._texture instanceof j){const e=s._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Kg(s,t){return t instanceof Do?(t.updateText(!0),!0):!1}function Zg(s,t){if(t instanceof ze){const e=t.toFontString();return Xe.measureFont(e),!0}return!1}function Jg(s,t){if(s instanceof Do){t.includes(s.style)||t.push(s.style),t.includes(s)||t.push(s);const e=s._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Qg(s,t){return s instanceof ze?(t.includes(s)||t.push(s),!0):!1}const Kc=class cf{constructor(t){this.limiter=new qc(cf.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(Jg),this.registerFindHook(Qg),this.registerFindHook(jg),this.registerFindHook(Yg),this.registerFindHook(qg),this.registerUploadHook(Kg),this.registerUploadHook(Zg)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Pt.system.addOnce(this.tick,this,Pe.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,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)Pt.system.addOnce(this.tick,this,Pe.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof Vt)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Pt.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}};Kc.uploadsPerFrame=4;let Ws=Kc;Object.defineProperties(q,{UPLOADS_PER_FRAME:{get(){return Ws.uploadsPerFrame},set(s){ot("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Ws.uploadsPerFrame=s}}});function Zc(s,t){return t instanceof lt?(t._glTextures[s.CONTEXT_UID]||s.texture.bind(t),!0):!1}function t_(s,t){if(!(t instanceof So))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let r=0;r<i.length;r++){const{texture:n}=i[r].style;n&&Zc(s,n.baseTexture)}return e.batchable||s.geometry.bind(e,t._resolveDirectShader(s)),!0}function e_(s,t){return s instanceof So?(t.push(s),!0):!1}class Fo extends Ws{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(e_),this.registerUploadHook(Zc),this.registerUploadHook(t_)}}Fo.extension={name:"prepare",type:$.RendererSystem},Q.add(Fo);class i_{constructor(t){this.maxMilliseconds=t,this.frameStart=0}beginFrame(){this.frameStart=Date.now()}allowedToUpload(){return Date.now()-this.frameStart<this.maxMilliseconds}}class $s extends Ge{constructor(t,e=!0){super(t[0]instanceof j?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&&(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Pt.shared.add(this.update,this,Pe.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,i=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()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<i||this.animationSpeed<0&&this.currentFrame>i)&&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 i=0;i<t.length;++i)e.push(j.from(t[i]));return new $s(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(j.from(t[i]));return new $s(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof j)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this.updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.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?(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Pt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}const Nr=new ft;class Bo extends Ge{constructor(t,e=100,i=100){super(t),this.tileTransform=new Fi,this._width=e,this._height=i,this.uvMatrix=this.texture.uvMatrix||new Es(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,i=this._width*(1-this._anchor._x),r=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,e,i,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 ut),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Nr);const e=this._width,i=this._height,r=-e*this.anchor._x;if(Nr.x>=r&&Nr.x<r+e){const n=-i*this.anchor._y;if(Nr.y>=n&&Nr.y<n+i)return!0}return!1}destroy(t){super.destroy(t),this.tileTransform=null,this.uvMatrix=null}static from(t,e){const i=t instanceof j?t:j.from(t,e);return new Bo(i,e.width,e.height)}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}}var r_=`#version 300 es
1012
970
  #define SHADER_NAME Tiling-Sprite-100
1013
971
 
1014
972
  precision lowp float;
@@ -1034,7 +992,7 @@ void main(void)
1034
992
 
1035
993
  fragmentColor = texSample * uColor;
1036
994
  }
1037
- `,_m=`#version 300 es
995
+ `,s_=`#version 300 es
1038
996
  #define SHADER_NAME Tiling-Sprite-300
1039
997
 
1040
998
  precision lowp float;
@@ -1054,7 +1012,7 @@ void main(void)
1054
1012
 
1055
1013
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1056
1014
  }
1057
- `,gm=`#version 100
1015
+ `,n_=`#version 100
1058
1016
  #ifdef GL_EXT_shader_texture_lod
1059
1017
  #extension GL_EXT_shader_texture_lod : enable
1060
1018
  #endif
@@ -1087,7 +1045,7 @@ void main(void)
1087
1045
 
1088
1046
  gl_FragColor = texSample * uColor;
1089
1047
  }
1090
- `,yd=`#version 100
1048
+ `,Jc=`#version 100
1091
1049
  #define SHADER_NAME Tiling-Sprite-100
1092
1050
 
1093
1051
  precision lowp float;
@@ -1107,7 +1065,7 @@ void main(void)
1107
1065
 
1108
1066
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1109
1067
  }
1110
- `,mm=`#version 100
1068
+ `,a_=`#version 100
1111
1069
  #define SHADER_NAME Tiling-Sprite-Simple-100
1112
1070
 
1113
1071
  precision lowp float;
@@ -1122,7 +1080,7 @@ void main(void)
1122
1080
  vec4 texSample = texture2D(uSampler, vTextureCoord);
1123
1081
  gl_FragColor = texSample * uColor;
1124
1082
  }
1125
- `;const Ea=new nr;class hu extends Nn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new cl,this.state=Pi.for2d()}contextChange(){const t=this.renderer,r={globals:t.globalUniforms};this.simpleShader=Mi.from(yd,mm,r),this.shader=t.context.webGLVersion>1?Mi.from(_m,pm,r):Mi.from(yd,gm,r)}render(t){const r=this.renderer,i=this.quad;let n=i.vertices;n[0]=n[6]=t._width*-t.anchor.x,n[1]=n[3]=t._height*-t.anchor.y,n[2]=n[4]=t._width*(1-t.anchor.x),n[5]=n[7]=t._height*(1-t.anchor.y);const o=t.uvRespectAnchor?t.anchor.x:0,h=t.uvRespectAnchor?t.anchor.y:0;n=i.uvs,n[0]=n[6]=-o,n[1]=n[3]=-h,n[2]=n[4]=1-o,n[5]=n[7]=1-h,i.invalidate();const c=t._texture,b=c.baseTexture,T=b.alphaMode>0,C=t.tileTransform.localTransform,x=t.uvMatrix;let $=b.isPowerOfTwo&&c.frame.width===b.width&&c.frame.height===b.height;$&&(b._glTextures[r.CONTEXT_UID]?$=b.wrapMode!==Vi.CLAMP:b.wrapMode===Vi.CLAMP&&(b.wrapMode=Vi.REPEAT));const I=$?this.simpleShader:this.shader,B=c.width,U=c.height,G=t._width,z=t._height;Ea.set(C.a*B/G,C.b*B/z,C.c*U/G,C.d*U/z,C.tx/G,C.ty/z),Ea.invert(),$?Ea.prepend(x.mapCoord):(I.uniforms.uMapCoord=x.mapCoord.toArray(!0),I.uniforms.uClampFrame=x.uClampFrame,I.uniforms.uClampOffset=x.uClampOffset),I.uniforms.uTransform=Ea.toArray(!0),I.uniforms.uColor=rr.shared.setValue(t.tint).premultiply(t.worldAlpha,T).toArray(I.uniforms.uColor),I.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),I.uniforms.uSampler=c,r.shader.bind(I),r.geometry.bind(i),this.state.blendMode=Uh(t.blendMode,T),r.state.set(this.state),r.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}hu.extension={name:"tilingSprite",type:Kt.RendererPlugin},be.add(hu);const vd=class Fo{constructor(t,r,i){this.linkedSheets=[],(t instanceof Ge||t instanceof ne)&&(t={texture:t,data:r,resolutionFilename:i});const{texture:n,data:o,resolutionFilename:h=null,cachePrefix:c=""}=t;this.cachePrefix=c,this._texture=n instanceof ne?n:null,this.baseTexture=n instanceof Ge?n:this._texture.baseTexture,this.textures={},this.animations={},this.data=o;const b=this.baseTexture.resource;this.resolution=this._updateResolution(h||(b?b.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:r}=this.data.meta;let i=Wi(t,null);return i===null&&(i=typeof r=="number"?r:parseFloat(r??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Fo.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let r=t;const i=Fo.BATCH_SIZE;for(;r-t<i&&r<this._frameKeys.length;){const n=this._frameKeys[r],o=this._frames[n],h=o.frame;if(h){let c=null,b=null;const T=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,C=new Ve(0,0,Math.floor(T.w)/this.resolution,Math.floor(T.h)/this.resolution);o.rotated?c=new Ve(Math.floor(h.x)/this.resolution,Math.floor(h.y)/this.resolution,Math.floor(h.h)/this.resolution,Math.floor(h.w)/this.resolution):c=new Ve(Math.floor(h.x)/this.resolution,Math.floor(h.y)/this.resolution,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(b=new Ve(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution)),this.textures[n]=new ne(this.baseTexture,c,C,b,o.rotated?2:0,o.anchor,o.borders),ne.addToCache(this.textures[n],this.cachePrefix+n.toString())}r++}}_processAnimations(){const t=this.data.animations||{};for(const r in t){this.animations[r]=[];for(let i=0;i<t[r].length;i++){const n=t[r][i];this.animations[r].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Fo.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Fo.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var r;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((r=this._texture)==null||r.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};vd.BATCH_SIZE=1e3;let lu=vd;const ym=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function xd(s,t,r){const i={};if(s.forEach(n=>{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!r){const n=$r.dirname(s[0]);t.linkedSheets.forEach((o,h)=>{Object.assign(i,xd([`${n}/${t.data.meta.related_multi_packs[h]}`],o,!0))})}return i}const bd={extension:Kt.Asset,cache:{test:s=>s instanceof lu,getCacheableAssets:(s,t)=>xd(s,t,!1)},resolver:{test:s=>{const t=s.split("?")[0].split("."),r=t.pop(),i=t.pop();return r==="json"&&ym.includes(i)},parse:s=>{var r;const t=s.split(".");return{resolution:parseFloat(((r=ue.RETINA_PREFIX.exec(s))==null?void 0:r[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:Kt.LoadParser,priority:_i.Normal},async testParse(s,t){return $r.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,r){var C,x;const{texture:i,imageFilename:n,cachePrefix:o}=(t==null?void 0:t.data)??{};let h=$r.dirname(t.src);h&&h.lastIndexOf("/")!==h.length-1&&(h+="/");let c;if(i&&i.baseTexture)c=i;else{const $=fa(h+(n??s.meta.image),t.src);c=(await r.load([$]))[$]}const b=new lu({texture:c.baseTexture,data:s,resolutionFilename:t.src,cachePrefix:o});await b.parse();const T=(C=s==null?void 0:s.meta)==null?void 0:C.related_multi_packs;if(Array.isArray(T)){const $=[];for(const B of T){if(typeof B!="string")continue;let U=h+B;(x=t.data)!=null&&x.ignoreMultiPack||(U=fa(U,t.src),$.push(r.load({src:U,data:{ignoreMultiPack:!0}})))}const I=await Promise.all($);b.linkedSheets=I,I.forEach(B=>{B.linkedSheets=[b].concat(b.linkedSheets.filter(U=>U!==B))})}return b},unload(s){s.destroy(!0)}}};be.add(bd);class ao{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class ho{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const r=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const o in r){const h=r[o].match(/^[a-z]+/gm)[0],c=r[o].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),b={};for(const T in c){const C=c[T].split("="),x=C[0],$=C[1].replace(/"/gm,""),I=parseFloat($),B=isNaN(I)?$:I;b[x]=B}i[h].push(b)}const n=new ao;return i.info.forEach(o=>n.info.push({face:o.face,size:parseInt(o.size,10)})),i.common.forEach(o=>n.common.push({lineHeight:parseInt(o.lineHeight,10)})),i.page.forEach(o=>n.page.push({id:parseInt(o.id,10),file:o.file})),i.char.forEach(o=>n.char.push({id:parseInt(o.id,10),page:parseInt(o.page,10),x:parseInt(o.x,10),y:parseInt(o.y,10),width:parseInt(o.width,10),height:parseInt(o.height,10),xoffset:parseInt(o.xoffset,10),yoffset:parseInt(o.yoffset,10),xadvance:parseInt(o.xadvance,10)})),i.kerning.forEach(o=>n.kerning.push({first:parseInt(o.first,10),second:parseInt(o.second,10),amount:parseInt(o.amount,10)})),i.distanceField.forEach(o=>n.distanceField.push({distanceRange:parseInt(o.distanceRange,10),fieldType:o.fieldType})),n}}class Ca{static test(t){const r=t;return typeof t!="string"&&"getElementsByTagName"in t&&r.getElementsByTagName("page").length&&r.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const r=new ao,i=t.getElementsByTagName("info"),n=t.getElementsByTagName("common"),o=t.getElementsByTagName("page"),h=t.getElementsByTagName("char"),c=t.getElementsByTagName("kerning"),b=t.getElementsByTagName("distanceField");for(let T=0;T<i.length;T++)r.info.push({face:i[T].getAttribute("face"),size:parseInt(i[T].getAttribute("size"),10)});for(let T=0;T<n.length;T++)r.common.push({lineHeight:parseInt(n[T].getAttribute("lineHeight"),10)});for(let T=0;T<o.length;T++)r.page.push({id:parseInt(o[T].getAttribute("id"),10)||0,file:o[T].getAttribute("file")});for(let T=0;T<h.length;T++){const C=h[T];r.char.push({id:parseInt(C.getAttribute("id"),10),page:parseInt(C.getAttribute("page"),10)||0,x:parseInt(C.getAttribute("x"),10),y:parseInt(C.getAttribute("y"),10),width:parseInt(C.getAttribute("width"),10),height:parseInt(C.getAttribute("height"),10),xoffset:parseInt(C.getAttribute("xoffset"),10),yoffset:parseInt(C.getAttribute("yoffset"),10),xadvance:parseInt(C.getAttribute("xadvance"),10)})}for(let T=0;T<c.length;T++)r.kerning.push({first:parseInt(c[T].getAttribute("first"),10),second:parseInt(c[T].getAttribute("second"),10),amount:parseInt(c[T].getAttribute("amount"),10)});for(let T=0;T<b.length;T++)r.distanceField.push({fieldType:b[T].getAttribute("fieldType"),distanceRange:parseInt(b[T].getAttribute("distanceRange"),10)});return r}}class Sa{static test(t){return typeof t=="string"&&t.includes("<font>")?Ca.test(ue.ADAPTER.parseXML(t)):!1}static parse(t){return Ca.parse(ue.ADAPTER.parseXML(t))}}const uu=[ho,Ca,Sa];function Ad(s){for(let t=0;t<uu.length;t++)if(uu[t].test(s))return uu[t];return null}function vm(s,t,r,i,n,o){const h=r.fill;if(Array.isArray(h)){if(h.length===1)return h[0]}else return h;let c;const b=r.dropShadow?r.dropShadowDistance:0,T=r.padding||0,C=s.width/i-b-T*2,x=s.height/i-b-T*2,$=h.slice(),I=r.fillGradientStops.slice();if(!I.length){const B=$.length+1;for(let U=1;U<B;++U)I.push(U/B)}if($.unshift(h[0]),I.unshift(0),$.push(h[h.length-1]),I.push(1),r.fillGradientType===no.LINEAR_VERTICAL){c=t.createLinearGradient(C/2,T,C/2,x+T);let B=0;const U=(o.fontProperties.fontSize+r.strokeThickness)/x;for(let G=0;G<n.length;G++){const z=o.lineHeight*G;for(let J=0;J<$.length;J++){let Z=0;typeof I[J]=="number"?Z=I[J]:Z=J/$.length;const it=z/x+Z*U;let Q=Math.max(B,it);Q=Math.min(Q,1),c.addColorStop(Q,$[J]),B=Q}}}else{c=t.createLinearGradient(T,x/2,C+T,x/2);const B=$.length+1;let U=1;for(let G=0;G<$.length;G++){let z;typeof I[G]=="number"?z=I[G]:z=U/B,c.addColorStop(z,$[G]),U++}}return c}function xm(s,t,r,i,n,o,h){const c=r.text,b=r.fontProperties;t.translate(i,n),t.scale(o,o);const T=h.strokeThickness/2,C=-(h.strokeThickness/2);if(t.font=h.toFontString(),t.lineWidth=h.strokeThickness,t.textBaseline=h.textBaseline,t.lineJoin=h.lineJoin,t.miterLimit=h.miterLimit,t.fillStyle=vm(s,t,h,o,[c],r),t.strokeStyle=h.stroke,h.dropShadow){const x=h.dropShadowColor,$=h.dropShadowBlur*o,I=h.dropShadowDistance*o;t.shadowColor=rr.shared.setValue(x).setAlpha(h.dropShadowAlpha).toRgbaString(),t.shadowBlur=$,t.shadowOffsetX=Math.cos(h.dropShadowAngle)*I,t.shadowOffsetY=Math.sin(h.dropShadowAngle)*I}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;h.stroke&&h.strokeThickness&&t.strokeText(c,T,C+r.lineHeight-b.descent),h.fill&&t.fillText(c,T,C+r.lineHeight-b.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Pa(s){return s.codePointAt?s.codePointAt(0):s.charCodeAt(0)}function wd(s){return Array.from?Array.from(s):s.split("")}function bm(s){typeof s=="string"&&(s=[s]);const t=[];for(let r=0,i=s.length;r<i;r++){const n=s[r];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);const o=n[0].charCodeAt(0),h=n[1].charCodeAt(0);if(h<o)throw new Error("[BitmapFont]: Invalid character range.");for(let c=o,b=h;c<=b;c++)t.push(String.fromCharCode(c))}else t.push(...wd(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Ps=class ns{constructor(t,r,i){var C;const[n]=t.info,[o]=t.common,[h]=t.page,[c]=t.distanceField,b=Wi(h.file),T={};this._ownsTextures=i,this.font=n.face,this.size=n.size,this.lineHeight=o.lineHeight/b,this.chars={},this.pageTextures=T;for(let x=0;x<t.page.length;x++){const{id:$,file:I}=t.page[x];T[$]=r instanceof Array?r[x]:r[I],c!=null&&c.fieldType&&c.fieldType!=="none"&&(T[$].baseTexture.alphaMode=Vr.NO_PREMULTIPLIED_ALPHA,T[$].baseTexture.mipmap=wi.OFF)}for(let x=0;x<t.char.length;x++){const{id:$,page:I}=t.char[x];let{x:B,y:U,width:G,height:z,xoffset:J,yoffset:Z,xadvance:it}=t.char[x];B/=b,U/=b,G/=b,z/=b,J/=b,Z/=b,it/=b;const Q=new Ve(B+T[I].frame.x/b,U+T[I].frame.y/b,G,z);this.chars[$]={xOffset:J,yOffset:Z,xAdvance:it,kerning:{},texture:new ne(T[I].baseTexture,Q),page:I}}for(let x=0;x<t.kerning.length;x++){let{first:$,second:I,amount:B}=t.kerning[x];$/=b,I/=b,B/=b,this.chars[I]&&(this.chars[I].kerning[$]=B)}this.distanceFieldRange=c==null?void 0:c.distanceRange,this.distanceFieldType=((C=c==null?void 0:c.fieldType)==null?void 0:C.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,r,i){let n;if(t instanceof ao)n=t;else{const h=Ad(t);if(!h)throw new Error("Unrecognized data format for font.");n=h.parse(t)}r instanceof ne&&(r=[r]);const o=new ns(n,r,i);return ns.available[o.font]=o,o}static uninstall(t){const r=ns.available[t];if(!r)throw new Error(`No font found named '${t}'`);r.destroy(),delete ns.available[t]}static from(t,r,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:n,padding:o,resolution:h,textureWidth:c,textureHeight:b,...T}=Object.assign({},ns.defaultOptions,i),C=bm(n),x=r instanceof ps?r:new ps(r),$=c,I=new ao;I.info[0]={face:x.fontFamily,size:x.fontSize},I.common[0]={lineHeight:x.fontSize};let B=0,U=0,G,z,J,Z=0;const it=[];for(let _t=0;_t<C.length;_t++){G||(G=ue.ADAPTER.createCanvas(),G.width=c,G.height=b,z=G.getContext("2d"),J=new Ge(G,{resolution:h,...T}),it.push(new ne(J)),I.page.push({id:it.length-1,file:""}));const et=C[_t],ft=ds.measureText(et,x,!1,G),wt=ft.width,Dt=Math.ceil(ft.height),Rt=Math.ceil((x.fontStyle==="italic"?2:1)*wt);if(U>=b-Dt*h){if(U===0)throw new Error(`[BitmapFont] textureHeight ${b}px is too small (fontFamily: '${x.fontFamily}', fontSize: ${x.fontSize}px, char: '${et}')`);--_t,G=null,z=null,J=null,U=0,B=0,Z=0;continue}if(Z=Math.max(Dt+ft.fontProperties.descent,Z),Rt*h+B>=$){if(B===0)throw new Error(`[BitmapFont] textureWidth ${c}px is too small (fontFamily: '${x.fontFamily}', fontSize: ${x.fontSize}px, char: '${et}')`);--_t,U+=Z*h,U=Math.ceil(U),B=0,Z=0;continue}xm(G,z,ft,B,U,h,x);const pt=Pa(ft.text);I.char.push({id:pt,page:it.length-1,x:B/h,y:U/h,width:Rt,height:Dt,xoffset:0,yoffset:0,xadvance:wt-(x.dropShadow?x.dropShadowDistance:0)-(x.stroke?x.strokeThickness:0)}),B+=(Rt+2*o)*h,B=Math.ceil(B)}if(!(i!=null&&i.skipKerning))for(let _t=0,et=C.length;_t<et;_t++){const ft=C[_t];for(let wt=0;wt<et;wt++){const Dt=C[wt],Rt=z.measureText(ft).width,pt=z.measureText(Dt).width,xt=z.measureText(ft+Dt).width-(Rt+pt);xt&&I.kerning.push({first:Pa(ft),second:Pa(Dt),amount:xt})}}const Q=new ns(I,it,!0);return ns.available[t]!==void 0&&ns.uninstall(t),ns.available[t]=Q,Q}};Ps.ALPHA=[["a","z"],["A","Z"]," "],Ps.NUMERIC=[["0","9"]],Ps.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Ps.ASCII=[[" ","~"]],Ps.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Ps.ALPHANUMERIC},Ps.available={};let _s=Ps;var Am=`// Pixi texture info\r
1083
+ `;const js=new vt;class Lo extends _r{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new ka,this.state=fe.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=me.from(Jc,a_,e),this.shader=t.context.webGLVersion>1?me.from(s_,r_,e):me.from(Jc,n_,e)}render(t){const e=this.renderer,i=this.quad;let r=i.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,a=t.uvRespectAnchor?t.anchor.y:0;r=i.uvs,r[0]=r[6]=-n,r[1]=r[3]=-a,r[2]=r[4]=1-n,r[5]=r[7]=1-a,i.invalidate();const o=t._texture,h=o.baseTexture,l=h.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=h.isPowerOfTwo&&o.frame.width===h.width&&o.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==Te.CLAMP:h.wrapMode===Te.CLAMP&&(h.wrapMode=Te.REPEAT));const f=d?this.simpleShader:this.shader,p=o.width,g=o.height,m=t._width,_=t._height;js.set(u.a*p/m,u.b*p/_,u.c*g/m,u.d*g/_,u.tx/m,u.ty/_),js.invert(),d?js.prepend(c.mapCoord):(f.uniforms.uMapCoord=c.mapCoord.toArray(!0),f.uniforms.uClampFrame=c.uClampFrame,f.uniforms.uClampOffset=c.uClampOffset),f.uniforms.uTransform=js.toArray(!0),f.uniforms.uColor=gt.shared.setValue(t.tint).premultiply(t.worldAlpha,l).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=o,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=da(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Lo.extension={name:"tilingSprite",type:$.RendererPlugin},Q.add(Lo);const Qc=class is{constructor(t,e,i){this.linkedSheets=[],(t instanceof lt||t instanceof j)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:r,data:n,resolutionFilename:a=null,cachePrefix:o=""}=t;this.cachePrefix=o,this._texture=r instanceof j?r:null,this.baseTexture=r instanceof lt?r:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const h=this.baseTexture.resource;this.resolution=this._updateResolution(a||(h?h.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=Ce(t,null);return i===null&&(i=typeof e=="number"?e:parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=is.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=is.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],a=n.frame;if(a){let o=null,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new ut(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?o=new ut(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):o=new ut(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new ut(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[r]=new j(this.baseTexture,o,u,h,n.rotated?2:0,n.anchor,n.borders),j.addToCache(this.textures[r],this.cachePrefix+r.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const r=t[e][i];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*is.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*is.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};Qc.BATCH_SIZE=1e3;let Oo=Qc;const o_=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function td(s,t,e){const i={};if(s.forEach(r=>{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[`${t.cachePrefix}${r}`]=t.textures[r]}),!e){const r=Rt.dirname(s[0]);t.linkedSheets.forEach((n,a)=>{Object.assign(i,td([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0))})}return i}const ed={extension:$.Asset,cache:{test:s=>s instanceof Oo,getCacheableAssets:(s,t)=>td(s,t,!1)},resolver:{test:s=>{const t=s.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&o_.includes(i)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=q.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:$.LoadParser,priority:ie.Normal},async testParse(s,t){return Rt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var u,c;const{texture:i,imageFilename:r,cachePrefix:n}=(t==null?void 0:t.data)??{};let a=Rt.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let o;if(i&&i.baseTexture)o=i;else{const d=Bs(a+(r??s.meta.image),t.src);o=(await e.load([d]))[d]}const h=new Oo({texture:o.baseTexture,data:s,resolutionFilename:t.src,cachePrefix:n});await h.parse();const l=(u=s==null?void 0:s.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(l)){const d=[];for(const p of l){if(typeof p!="string")continue;let g=a+p;(c=t.data)!=null&&c.ignoreMultiPack||(g=Bs(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);h.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[h].concat(h.linkedSheets.filter(g=>g!==p))})}return h},unload(s){s.destroy(!0)}}};Q.add(ed);class Ur{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Gr{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const a=e[n].match(/^[a-z]+/gm)[0],o=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),h={};for(const l in o){const u=o[l].split("="),c=u[0],d=u[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;h[c]=p}i[a].push(h)}const r=new Ur;return i.info.forEach(n=>r.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>r.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>r.page.push({id:parseInt(n.id,10),file:n.file})),i.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)})),i.kerning.forEach(n=>r.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>r.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),r}}class Ys{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Ur,i=t.getElementsByTagName("info"),r=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),a=t.getElementsByTagName("char"),o=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l<i.length;l++)e.info.push({face:i[l].getAttribute("face"),size:parseInt(i[l].getAttribute("size"),10)});for(let l=0;l<r.length;l++)e.common.push({lineHeight:parseInt(r[l].getAttribute("lineHeight"),10)});for(let l=0;l<n.length;l++)e.page.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});for(let l=0;l<a.length;l++){const u=a[l];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let l=0;l<o.length;l++)e.kerning.push({first:parseInt(o[l].getAttribute("first"),10),second:parseInt(o[l].getAttribute("second"),10),amount:parseInt(o[l].getAttribute("amount"),10)});for(let l=0;l<h.length;l++)e.distanceField.push({fieldType:h[l].getAttribute("fieldType"),distanceRange:parseInt(h[l].getAttribute("distanceRange"),10)});return e}}class qs{static test(t){return typeof t=="string"&&t.includes("<font>")?Ys.test(q.ADAPTER.parseXML(t)):!1}static parse(t){return Ys.parse(q.ADAPTER.parseXML(t))}}const ko=[Gr,Ys,qs];function id(s){for(let t=0;t<ko.length;t++)if(ko[t].test(s))return ko[t];return null}function h_(s,t,e,i,r,n){const a=e.fill;if(Array.isArray(a)){if(a.length===1)return a[0]}else return a;let o;const h=e.dropShadow?e.dropShadowDistance:0,l=e.padding||0,u=s.width/i-h-l*2,c=s.height/i-h-l*2,d=a.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let g=1;g<p;++g)f.push(g/p)}if(d.unshift(a[0]),f.unshift(0),d.push(a[a.length-1]),f.push(1),e.fillGradientType===kr.LINEAR_VERTICAL){o=t.createLinearGradient(u/2,l,u/2,c+l);let p=0;const g=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let m=0;m<r.length;m++){const _=n.lineHeight*m;for(let b=0;b<d.length;b++){let y=0;typeof f[b]=="number"?y=f[b]:y=b/d.length;const E=_/c+y*g;let v=Math.max(p,E);v=Math.min(v,1),o.addColorStop(v,d[b]),p=v}}}else{o=t.createLinearGradient(l,c/2,u+l,c/2);const p=d.length+1;let g=1;for(let m=0;m<d.length;m++){let _;typeof f[m]=="number"?_=f[m]:_=g/p,o.addColorStop(_,d[m]),g++}}return o}function l_(s,t,e,i,r,n,a){const o=e.text,h=e.fontProperties;t.translate(i,r),t.scale(n,n);const l=a.strokeThickness/2,u=-(a.strokeThickness/2);if(t.font=a.toFontString(),t.lineWidth=a.strokeThickness,t.textBaseline=a.textBaseline,t.lineJoin=a.lineJoin,t.miterLimit=a.miterLimit,t.fillStyle=h_(s,t,a,n,[o],e),t.strokeStyle=a.stroke,a.dropShadow){const c=a.dropShadowColor,d=a.dropShadowBlur*n,f=a.dropShadowDistance*n;t.shadowColor=gt.shared.setValue(c).setAlpha(a.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(a.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(a.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;a.stroke&&a.strokeThickness&&t.strokeText(o,l,u+e.lineHeight-h.descent),a.fill&&t.fillText(o,l,u+e.lineHeight-h.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Ks(s){return s.codePointAt?s.codePointAt(0):s.charCodeAt(0)}function rd(s){return Array.from?Array.from(s):s.split("")}function u_(s){typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const r=s[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);const n=r[0].charCodeAt(0),a=r[1].charCodeAt(0);if(a<n)throw new Error("[BitmapFont]: Invalid character range.");for(let o=n,h=a;o<=h;o++)t.push(String.fromCharCode(o))}else t.push(...rd(r))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const si=class Le{constructor(t,e,i){var u;const[r]=t.info,[n]=t.common,[a]=t.page,[o]=t.distanceField,h=Ce(a.file),l={};this._ownsTextures=i,this.font=r.face,this.size=r.size,this.lineHeight=n.lineHeight/h,this.chars={},this.pageTextures=l;for(let c=0;c<t.page.length;c++){const{id:d,file:f}=t.page[c];l[d]=e instanceof Array?e[c]:e[f],o!=null&&o.fieldType&&o.fieldType!=="none"&&(l[d].baseTexture.alphaMode=Nt.NO_PREMULTIPLIED_ALPHA,l[d].baseTexture.mipmap=he.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:f}=t.char[c];let{x:p,y:g,width:m,height:_,xoffset:b,yoffset:y,xadvance:E}=t.char[c];p/=h,g/=h,m/=h,_/=h,b/=h,y/=h,E/=h;const v=new ut(p+l[f].frame.x/h,g+l[f].frame.y/h,m,_);this.chars[d]={xOffset:b,yOffset:y,xAdvance:E,kerning:{},texture:new j(l[f].baseTexture,v),page:f}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:f,amount:p}=t.kerning[c];d/=h,f/=h,p/=h,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=o==null?void 0:o.distanceRange,this.distanceFieldType=((u=o==null?void 0:o.fieldType)==null?void 0:u.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let r;if(t instanceof Ur)r=t;else{const a=id(t);if(!a)throw new Error("Unrecognized data format for font.");r=a.parse(t)}e instanceof j&&(e=[e]);const n=new Le(r,e,i);return Le.available[n.font]=n,n}static uninstall(t){const e=Le.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Le.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:r,padding:n,resolution:a,textureWidth:o,textureHeight:h,...l}=Object.assign({},Le.defaultOptions,i),u=u_(r),c=e instanceof ze?e:new ze(e),d=o,f=new Ur;f.info[0]={face:c.fontFamily,size:c.fontSize},f.common[0]={lineHeight:c.fontSize};let p=0,g=0,m,_,b,y=0;const E=[];for(let M=0;M<u.length;M++){m||(m=q.ADAPTER.createCanvas(),m.width=o,m.height=h,_=m.getContext("2d"),b=new lt(m,{resolution:a,...l}),E.push(new j(b)),f.page.push({id:E.length-1,file:""}));const T=u[M],P=Xe.measureText(T,c,!1,m),N=P.width,G=Math.ceil(P.height),z=Math.ceil((c.fontStyle==="italic"?2:1)*N);if(g>=h-G*a){if(g===0)throw new Error(`[BitmapFont] textureHeight ${h}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${T}')`);--M,m=null,_=null,b=null,g=0,p=0,y=0;continue}if(y=Math.max(G+P.fontProperties.descent,y),z*a+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${o}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${T}')`);--M,g+=y*a,g=Math.ceil(g),p=0,y=0;continue}l_(m,_,P,p,g,a,c);const D=Ks(P.text);f.char.push({id:D,page:E.length-1,x:p/a,y:g/a,width:z,height:G,xoffset:0,yoffset:0,xadvance:N-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),p+=(z+2*n)*a,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let M=0,T=u.length;M<T;M++){const P=u[M];for(let N=0;N<T;N++){const G=u[N],z=_.measureText(P).width,D=_.measureText(G).width,O=_.measureText(P+G).width-(z+D);O&&f.kerning.push({first:Ks(P),second:Ks(G),amount:O})}}const v=new Le(f,E,!0);return Le.available[t]!==void 0&&Le.uninstall(t),Le.available[t]=v,v}};si.ALPHA=[["a","z"],["A","Z"]," "],si.NUMERIC=[["0","9"]],si.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],si.ASCII=[[" ","~"]],si.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:si.ALPHANUMERIC},si.available={};let We=si;var c_=`// Pixi texture info\r
1126
1084
  varying vec2 vTextureCoord;\r
1127
1085
  uniform sampler2D uSampler;\r
1128
1086
  \r
@@ -1160,7 +1118,7 @@ void main(void) {\r
1160
1118
  // NPM Textures, NPM outputs\r
1161
1119
  gl_FragColor = vec4(uColor.rgb, coverage);\r
1162
1120
  }\r
1163
- `,wm=`// Mesh material default fragment\r
1121
+ `,d_=`// Mesh material default fragment\r
1164
1122
  attribute vec2 aVertexPosition;\r
1165
1123
  attribute vec2 aTextureCoord;\r
1166
1124
  \r
@@ -1176,33 +1134,32 @@ void main(void)\r
1176
1134
  \r
1177
1135
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1178
1136
  }\r
1179
- `;const Td=[],Ed=[],Cd=[],Sd=class w2 extends Zr{constructor(t,r={}){super();const{align:i,tint:n,maxWidth:o,letterSpacing:h,fontName:c,fontSize:b}=Object.assign({},w2.styleDefaults,r);if(!_s.available[c])throw new Error(`Missing BitmapFont "${c}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new rr(n),this._font=void 0,this._fontName=c,this._fontSize=b,this.text=t,this._maxWidth=o,this._maxLineHeight=0,this._letterSpacing=h,this._anchor=new $i(()=>{this.dirty=!0},this,0,0),this._roundPixels=ue.ROUND_PIXELS,this.dirty=!0,this._resolution=ue.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var Rt;const t=_s.available[this._fontName],r=this.fontSize,i=r/t.size,n=new He,o=[],h=[],c=[],b=this._text.replace(/(?:\r\n|\r)/g,`
1180
- `)||" ",T=wd(b),C=this._maxWidth*t.size/r,x=t.distanceFieldType==="none"?Td:Ed;let $=null,I=0,B=0,U=0,G=-1,z=0,J=0,Z=0,it=0;for(let pt=0;pt<T.length;pt++){const xt=T[pt],Ct=Pa(xt);if(/(?:\s)/.test(xt)&&(G=pt,z=I,it++),xt==="\r"||xt===`
1181
- `){h.push(I),c.push(-1),B=Math.max(B,I),++U,++J,n.x=0,n.y+=t.lineHeight,$=null,it=0;continue}const Gt=t.chars[Ct];if(!Gt)continue;$&&Gt.kerning[$]&&(n.x+=Gt.kerning[$]);const st=Cd.pop()||{texture:ne.EMPTY,line:0,charCode:0,prevSpaces:0,position:new He};st.texture=Gt.texture,st.line=U,st.charCode=Ct,st.position.x=Math.round(n.x+Gt.xOffset+this._letterSpacing/2),st.position.y=Math.round(n.y+Gt.yOffset),st.prevSpaces=it,o.push(st),I=st.position.x+Math.max(Gt.xAdvance-Gt.xOffset,Gt.texture.orig.width),n.x+=Gt.xAdvance+this._letterSpacing,Z=Math.max(Z,Gt.yOffset+Gt.texture.height),$=Ct,G!==-1&&C>0&&n.x>C&&(++J,ks(o,1+G-J,1+pt-G),pt=G,G=-1,h.push(z),c.push(o.length>0?o[o.length-1].prevSpaces:0),B=Math.max(B,z),U++,n.x=0,n.y+=t.lineHeight,$=null,it=0)}const Q=T[T.length-1];Q!=="\r"&&Q!==`
1182
- `&&(/(?:\s)/.test(Q)&&(I=z),h.push(I),B=Math.max(B,I),c.push(-1));const _t=[];for(let pt=0;pt<=U;pt++){let xt=0;this._align==="right"?xt=B-h[pt]:this._align==="center"?xt=(B-h[pt])/2:this._align==="justify"&&(xt=c[pt]<0?0:(B-h[pt])/c[pt]),_t.push(xt)}const et=o.length,ft={},wt=[],Dt=this._activePagesMeshData;x.push(...Dt);for(let pt=0;pt<et;pt++){const xt=o[pt].texture,Ct=xt.baseTexture.uid;if(!ft[Ct]){let Gt=x.pop();if(!Gt){const nt=new so;let Y,gt;t.distanceFieldType==="none"?(Y=new fn(ne.EMPTY),gt=De.NORMAL):(Y=new fn(ne.EMPTY,{program:Hi.from(wm,Am),uniforms:{uFWidth:0}}),gt=De.NORMAL_NPM);const ot=new cn(nt,Y);ot.blendMode=gt,Gt={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:ot,vertices:null,uvs:null,indices:null}}Gt.index=0,Gt.indexCount=0,Gt.vertexCount=0,Gt.uvsCount=0,Gt.total=0;const{_textureCache:st}=this;st[Ct]=st[Ct]||new ne(xt.baseTexture),Gt.mesh.texture=st[Ct],Gt.mesh.tint=this._tintColor.value,wt.push(Gt),ft[Ct]=Gt}ft[Ct].total++}for(let pt=0;pt<Dt.length;pt++)wt.includes(Dt[pt])||this.removeChild(Dt[pt].mesh);for(let pt=0;pt<wt.length;pt++)wt[pt].mesh.parent!==this&&this.addChild(wt[pt].mesh);this._activePagesMeshData=wt;for(const pt in ft){const xt=ft[pt],Ct=xt.total;if(!(((Rt=xt.indices)==null?void 0:Rt.length)>6*Ct)||xt.vertices.length<cn.BATCHABLE_SIZE*2)xt.vertices=new Float32Array(4*2*Ct),xt.uvs=new Float32Array(4*2*Ct),xt.indices=new Uint16Array(6*Ct);else{const Gt=xt.total,st=xt.vertices;for(let nt=Gt*4*2;nt<st.length;nt++)st[nt]=0}xt.mesh.size=6*Ct}for(let pt=0;pt<et;pt++){const xt=o[pt];let Ct=xt.position.x+_t[xt.line]*(this._align==="justify"?xt.prevSpaces:1);this._roundPixels&&(Ct=Math.round(Ct));const Gt=Ct*i,st=xt.position.y*i,nt=xt.texture,Y=ft[nt.baseTexture.uid],gt=nt.frame,ot=nt._uvs,ht=Y.index++;Y.indices[ht*6+0]=0+ht*4,Y.indices[ht*6+1]=1+ht*4,Y.indices[ht*6+2]=2+ht*4,Y.indices[ht*6+3]=0+ht*4,Y.indices[ht*6+4]=2+ht*4,Y.indices[ht*6+5]=3+ht*4,Y.vertices[ht*8+0]=Gt,Y.vertices[ht*8+1]=st,Y.vertices[ht*8+2]=Gt+gt.width*i,Y.vertices[ht*8+3]=st,Y.vertices[ht*8+4]=Gt+gt.width*i,Y.vertices[ht*8+5]=st+gt.height*i,Y.vertices[ht*8+6]=Gt,Y.vertices[ht*8+7]=st+gt.height*i,Y.uvs[ht*8+0]=ot.x0,Y.uvs[ht*8+1]=ot.y0,Y.uvs[ht*8+2]=ot.x1,Y.uvs[ht*8+3]=ot.y1,Y.uvs[ht*8+4]=ot.x2,Y.uvs[ht*8+5]=ot.y2,Y.uvs[ht*8+6]=ot.x3,Y.uvs[ht*8+7]=ot.y3}this._textWidth=B*i,this._textHeight=(n.y+t.lineHeight)*i;for(const pt in ft){const xt=ft[pt];if(this.anchor.x!==0||this.anchor.y!==0){let nt=0;const Y=this._textWidth*this.anchor.x,gt=this._textHeight*this.anchor.y;for(let ot=0;ot<xt.total;ot++)xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt}this._maxLineHeight=Z*i;const Ct=xt.mesh.geometry.getBuffer("aVertexPosition"),Gt=xt.mesh.geometry.getBuffer("aTextureCoord"),st=xt.mesh.geometry.getIndex();Ct.data=xt.vertices,Gt.data=xt.uvs,st.data=xt.indices,Ct.update(),Gt.update(),st.update()}for(let pt=0;pt<o.length;pt++)Cd.push(o[pt]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:r,distanceFieldType:i,size:n}=_s.available[this._fontName];if(i!=="none"){const{a:o,b:h,c,d:b}=this.worldTransform,T=Math.sqrt(o*o+h*h),C=Math.sqrt(c*c+b*b),x=(Math.abs(T)+Math.abs(C))/2,$=this.fontSize/n,I=t._view.resolution;for(const B of this._activePagesMeshData)B.mesh.shader.uniforms.uFWidth=x*r*$*I}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=_s.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let r=0;r<this._activePagesMeshData.length;r++)this._activePagesMeshData[r].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!_s.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??_s.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:r}=this,i=_s.available[this._fontName].distanceFieldType==="none"?Td:Ed;i.push(...this._activePagesMeshData);for(const n of this._activePagesMeshData)this.removeChild(n.mesh);this._activePagesMeshData=[],i.filter(n=>r[n.mesh.texture.baseTexture.uid]).forEach(n=>{n.mesh.texture=ne.EMPTY});for(const n in r)r[n].destroy(),delete r[n];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};Sd.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};let Tm=Sd;const Em=[".xml",".fnt"],Pd={extension:{type:Kt.LoadParser,priority:_i.Normal},name:"loadBitmapFont",test(s){return Em.includes($r.extname(s).toLowerCase())},async testParse(s){return ho.test(s)||Sa.test(s)},async parse(s,t,r){const i=ho.test(s)?ho.parse(s):Sa.parse(s),{src:n}=t,{page:o}=i,h=[];for(let T=0;T<o.length;++T){const C=o[T].file;let x=$r.join($r.dirname(n),C);x=fa(x,n),h.push(x)}const c=await r.load(h),b=h.map(T=>c[T]);return _s.install(i,b,!0)},async load(s,t){return(await ue.ADAPTER.fetch(s)).text()},unload(s){s.destroy()}};be.add(Pd);const cu=class Tn extends ps{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Tn(Object.keys(Tn.defaultOptions).reduce((r,i)=>({...r,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete Tn.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,r={}){const{availableFonts:i}=Tn;if(i[t]){const n=i[t];return this._fonts.push(n),n.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return ue.ADAPTER.fetch(t).then(n=>n.blob()).then(async n=>new Promise((o,h)=>{const c=URL.createObjectURL(n),b=new FileReader;b.onload=()=>o([c,b.result]),b.onerror=h,b.readAsDataURL(n)})).then(async([n,o])=>{const h=Object.assign({family:$r.basename(t,$r.extname(t)),weight:"normal",style:"normal",display:"auto",src:n,dataSrc:o,refs:1,originalUrl:t,fontFace:null},r);i[t]=h,this._fonts.push(h),this.styleID++;const c=new FontFace(h.family,`url(${h.src})`,{weight:h.weight,style:h.style,display:h.display});h.fontFace=c,await c.load(),document.fonts.add(c),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const r=t.filter(i=>!this._overrides.includes(i));r.length>0&&(this._overrides.push(...r),this.styleID++)}removeOverride(...t){const r=t.filter(i=>this._overrides.includes(i));r.length>0&&(this._overrides=this._overrides.filter(i=>!r.includes(i)),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,r)=>`${t}
1137
+ `;const sd=[],nd=[],ad=[],od=class df extends Vt{constructor(t,e={}){super();const{align:i,tint:r,maxWidth:n,letterSpacing:a,fontName:o,fontSize:h}=Object.assign({},df.styleDefaults,e);if(!We.available[o])throw new Error(`Missing BitmapFont "${o}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new gt(r),this._font=void 0,this._fontName=o,this._fontSize=h,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=a,this._anchor=new pe(()=>{this.dirty=!0},this,0,0),this._roundPixels=q.ROUND_PIXELS,this.dirty=!0,this._resolution=q.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var z;const t=We.available[this._fontName],e=this.fontSize,i=e/t.size,r=new ft,n=[],a=[],o=[],h=this._text.replace(/(?:\r\n|\r)/g,`
1138
+ `)||" ",l=rd(h),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?sd:nd;let d=null,f=0,p=0,g=0,m=-1,_=0,b=0,y=0,E=0;for(let D=0;D<l.length;D++){const O=l[D],V=Ks(O);if(/(?:\s)/.test(O)&&(m=D,_=f,E++),O==="\r"||O===`
1139
+ `){a.push(f),o.push(-1),p=Math.max(p,f),++g,++b,r.x=0,r.y+=t.lineHeight,d=null,E=0;continue}const W=t.chars[V];if(!W)continue;d&&W.kerning[d]&&(r.x+=W.kerning[d]);const w=ad.pop()||{texture:j.EMPTY,line:0,charCode:0,prevSpaces:0,position:new ft};w.texture=W.texture,w.line=g,w.charCode=V,w.position.x=Math.round(r.x+W.xOffset+this._letterSpacing/2),w.position.y=Math.round(r.y+W.yOffset),w.prevSpaces=E,n.push(w),f=w.position.x+Math.max(W.xAdvance-W.xOffset,W.texture.orig.width),r.x+=W.xAdvance+this._letterSpacing,y=Math.max(y,W.yOffset+W.texture.height),d=V,m!==-1&&u>0&&r.x>u&&(++b,di(n,1+m-b,1+D-m),D=m,m=-1,a.push(_),o.push(n.length>0?n[n.length-1].prevSpaces:0),p=Math.max(p,_),g++,r.x=0,r.y+=t.lineHeight,d=null,E=0)}const v=l[l.length-1];v!=="\r"&&v!==`
1140
+ `&&(/(?:\s)/.test(v)&&(f=_),a.push(f),p=Math.max(p,f),o.push(-1));const M=[];for(let D=0;D<=g;D++){let O=0;this._align==="right"?O=p-a[D]:this._align==="center"?O=(p-a[D])/2:this._align==="justify"&&(O=o[D]<0?0:(p-a[D])/o[D]),M.push(O)}const T=n.length,P={},N=[],G=this._activePagesMeshData;c.push(...G);for(let D=0;D<T;D++){const O=n[D].texture,V=O.baseTexture.uid;if(!P[V]){let W=c.pop();if(!W){const C=new Or;let x,R;t.distanceFieldType==="none"?(x=new Hi(j.EMPTY),R=nt.NORMAL):(x=new Hi(j.EMPTY,{program:Ae.from(d_,c_),uniforms:{uFWidth:0}}),R=nt.NORMAL_NPM);const A=new Vi(C,x);A.blendMode=R,W={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:A,vertices:null,uvs:null,indices:null}}W.index=0,W.indexCount=0,W.vertexCount=0,W.uvsCount=0,W.total=0;const{_textureCache:w}=this;w[V]=w[V]||new j(O.baseTexture),W.mesh.texture=w[V],W.mesh.tint=this._tintColor.value,N.push(W),P[V]=W}P[V].total++}for(let D=0;D<G.length;D++)N.includes(G[D])||this.removeChild(G[D].mesh);for(let D=0;D<N.length;D++)N[D].mesh.parent!==this&&this.addChild(N[D].mesh);this._activePagesMeshData=N;for(const D in P){const O=P[D],V=O.total;if(!(((z=O.indices)==null?void 0:z.length)>6*V)||O.vertices.length<Vi.BATCHABLE_SIZE*2)O.vertices=new Float32Array(4*2*V),O.uvs=new Float32Array(4*2*V),O.indices=new Uint16Array(6*V);else{const W=O.total,w=O.vertices;for(let C=W*4*2;C<w.length;C++)w[C]=0}O.mesh.size=6*V}for(let D=0;D<T;D++){const O=n[D];let V=O.position.x+M[O.line]*(this._align==="justify"?O.prevSpaces:1);this._roundPixels&&(V=Math.round(V));const W=V*i,w=O.position.y*i,C=O.texture,x=P[C.baseTexture.uid],R=C.frame,A=C._uvs,S=x.index++;x.indices[S*6+0]=0+S*4,x.indices[S*6+1]=1+S*4,x.indices[S*6+2]=2+S*4,x.indices[S*6+3]=0+S*4,x.indices[S*6+4]=2+S*4,x.indices[S*6+5]=3+S*4,x.vertices[S*8+0]=W,x.vertices[S*8+1]=w,x.vertices[S*8+2]=W+R.width*i,x.vertices[S*8+3]=w,x.vertices[S*8+4]=W+R.width*i,x.vertices[S*8+5]=w+R.height*i,x.vertices[S*8+6]=W,x.vertices[S*8+7]=w+R.height*i,x.uvs[S*8+0]=A.x0,x.uvs[S*8+1]=A.y0,x.uvs[S*8+2]=A.x1,x.uvs[S*8+3]=A.y1,x.uvs[S*8+4]=A.x2,x.uvs[S*8+5]=A.y2,x.uvs[S*8+6]=A.x3,x.uvs[S*8+7]=A.y3}this._textWidth=p*i,this._textHeight=(r.y+t.lineHeight)*i;for(const D in P){const O=P[D];if(this.anchor.x!==0||this.anchor.y!==0){let C=0;const x=this._textWidth*this.anchor.x,R=this._textHeight*this.anchor.y;for(let A=0;A<O.total;A++)O.vertices[C++]-=x,O.vertices[C++]-=R,O.vertices[C++]-=x,O.vertices[C++]-=R,O.vertices[C++]-=x,O.vertices[C++]-=R,O.vertices[C++]-=x,O.vertices[C++]-=R}this._maxLineHeight=y*i;const V=O.mesh.geometry.getBuffer("aVertexPosition"),W=O.mesh.geometry.getBuffer("aTextureCoord"),w=O.mesh.geometry.getIndex();V.data=O.vertices,W.data=O.uvs,w.data=O.indices,V.update(),W.update(),w.update()}for(let D=0;D<n.length;D++)ad.push(n[D]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:r}=We.available[this._fontName];if(i!=="none"){const{a:n,b:a,c:o,d:h}=this.worldTransform,l=Math.sqrt(n*n+a*a),u=Math.sqrt(o*o+h*h),c=(Math.abs(l)+Math.abs(u))/2,d=this.fontSize/r,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=c*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=We.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!We.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??We.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=We.available[this._fontName].distanceFieldType==="none"?sd:nd;i.push(...this._activePagesMeshData);for(const r of this._activePagesMeshData)this.removeChild(r.mesh);this._activePagesMeshData=[],i.filter(r=>e[r.mesh.texture.baseTexture.uid]).forEach(r=>{r.mesh.texture=j.EMPTY});for(const r in e)e[r].destroy(),delete e[r];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};od.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};let f_=od;const p_=[".xml",".fnt"],hd={extension:{type:$.LoadParser,priority:ie.Normal},name:"loadBitmapFont",test(s){return p_.includes(Rt.extname(s).toLowerCase())},async testParse(s){return Gr.test(s)||qs.test(s)},async parse(s,t,e){const i=Gr.test(s)?Gr.parse(s):qs.parse(s),{src:r}=t,{page:n}=i,a=[];for(let l=0;l<n.length;++l){const u=n[l].file;let c=Rt.join(Rt.dirname(r),u);c=Bs(c,r),a.push(c)}const o=await e.load(a),h=a.map(l=>o[l]);return We.install(i,h,!0)},async load(s,t){return(await q.ADAPTER.fetch(s)).text()},unload(s){s.destroy()}};Q.add(hd);const No=class ir extends ze{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new ir(Object.keys(ir.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete ir.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=ir;if(i[t]){const r=i[t];return this._fonts.push(r),r.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return q.ADAPTER.fetch(t).then(r=>r.blob()).then(async r=>new Promise((n,a)=>{const o=URL.createObjectURL(r),h=new FileReader;h.onload=()=>n([o,h.result]),h.onerror=a,h.readAsDataURL(r)})).then(async([r,n])=>{const a=Object.assign({family:Rt.basename(t,Rt.extname(t)),weight:"normal",style:"normal",display:"auto",src:r,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=a,this._fonts.push(a),this.styleID++;const o=new FontFace(a.family,`url(${a.src})`,{weight:a.weight,style:a.style,display:a.display});a.fontFace=o,await o.load(),document.fonts.add(o),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),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}
1183
1141
  @font-face {
1184
- font-family: "${r.family}";
1185
- src: url('${r.dataSrc}');
1186
- font-weight: ${r.weight};
1187
- font-style: ${r.style};
1188
- font-display: ${r.display};
1189
- }`,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=Zc(t)),typeof t=="number"?qc(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const r=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&r<1&&(t+=(r*255|0).toString(16).padStart(2,"0"));const o=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${o} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${o} ${t}`}reset(){Object.assign(this,Tn.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(r=>setTimeout(r,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=ue.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}};cu.availableFonts={},cu.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};let $a=cu;const lo=class En extends us{constructor(t="",r={}){super(ne.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,n=ne.from(i,{scaleMode:ue.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new Ve,n.trim=new Ve,this.texture=n;const o="http://www.w3.org/2000/svg",h="http://www.w3.org/1999/xhtml",c=document.createElementNS(o,"svg"),b=document.createElementNS(o,"foreignObject"),T=document.createElementNS(h,"div"),C=document.createElementNS(h,"style");b.setAttribute("width","10000"),b.setAttribute("height","10000"),b.style.overflow="hidden",c.appendChild(b),this.maxWidth=En.defaultMaxWidth,this.maxHeight=En.defaultMaxHeight,this._domElement=T,this._styleElement=C,this._svgRoot=c,this._foreignObject=b,this._foreignObject.appendChild(C),this._foreignObject.appendChild(T),this._image=i,this._loadImage=new Image,this._autoResolution=En.defaultAutoResolution,this._resolution=En.defaultResolution??ue.RESOLUTION,this.text=t,this.style=r}measureText(t){var C,x;const{text:r,style:i,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:r,style:i.toCSS(n)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const o=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:h,height:c}=o;(h>this.maxWidth||c>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const b=Math.min(this.maxWidth,Math.ceil(h)),T=Math.min(this.maxHeight,Math.ceil(c));return this._svgRoot.setAttribute("width",b.toString()),this._svgRoot.setAttribute("height",T.toString()),r!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(C=this._style)==null?void 0:C.toCSS(n)}),this._styleElement.textContent=(x=this._style)==null?void 0:x.toGlobalCSS()),{width:b+i.padding*2,height:T+i.padding*2}}async updateText(t=!0){const{style:r,_image:i,_loadImage:n}=this;if(this.localStyleID!==r.styleID&&(this.dirty=!0,this.localStyleID=r.styleID),!this.dirty&&t)return;const{width:o,height:h}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,o)),i.height=n.height=Math.ceil(Math.max(1,h)),this._updateID++;const c=this._updateID;await new Promise(b=>{n.onload=async()=>{if(c<this._updateID){b();return}await r.onBeforeDraw(),i.src=n.src,n.onload=null,n.src="",this.updateTexture(),b()};const T=new XMLSerializer().serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(T)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:r,_image:i,resolution:n}=this,{padding:o}=t,{baseTexture:h}=r;r.trim.width=r._frame.width=i.width/n,r.trim.height=r._frame.height=i.height/n,r.trim.x=-o,r.trim.y=-o,r.orig.width=r._frame.width-o*2,r.orig.height=r._frame.height-o*2,this._onTextureUpdate(),h.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){var i,n,o,h,c;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},En.defaultDestroyOptions,t),super.destroy(t);const r=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=r,(n=this._svgRoot)==null||n.remove(),this._svgRoot=r,(o=this._domElement)==null||o.remove(),this._domElement=r,(h=this._foreignObject)==null||h.remove(),this._foreignObject=r,(c=this._styleElement)==null||c.remove(),this._styleElement=r,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=r,this._image.src="",this._image=r}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const r=hs(this.scale.x)||1;this.scale.x=r*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 r=hs(this.scale.y)||1;this.scale.y=r*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof $a?(this.ownsStyle=!1,this._style=t):t instanceof ps?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=$a.from(t)):(this.ownsStyle=!0,this._style=new $a(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":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(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};lo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},lo.defaultMaxWidth=2024,lo.defaultMaxHeight=2024,lo.defaultAutoResolution=!0;const Cm=Object.freeze(Object.defineProperty({__proto__:null,ALPHA_MODES:Vr,AbstractMultiResource:Dl,AccessibilityManager:Nl,AlphaFilter:ef,AnimatedSprite:Ta,Application:Ul,ArrayResource:q0,Assets:Kn,AssetsClass:Sf,Attribute:In,BLEND_MODES:De,BUFFER_BITS:Lo,BUFFER_TYPE:Ei,BackgroundSystem:Gn,BaseImageResource:Yi,BasePrepare:wa,BaseRenderTexture:hl,BaseTexture:Ge,BatchDrawCall:zo,BatchGeometry:el,BatchRenderer:bs,BatchShaderGenerator:b0,BatchSystem:al,BatchTextureArray:Zo,BitmapFont:_s,BitmapFontData:ao,BitmapText:Tm,BlobResource:Uf,BlurFilter:rf,BlurFilterPass:ha,Bounds:Yn,BrowserAdapter:Uu,Buffer:Ar,BufferResource:Rn,BufferSystem:$l,CLEAR_MODES:Ti,COLOR_MASK_BITS:Nu,Cache:Es,CanvasResource:Z0,Circle:Ln,Color:rr,ColorMatrixFilter:la,CompressedTextureResource:Cs,Container:Zr,ContextSystem:Vn,CountLimiter:_d,CubeResource:K0,DEG_TO_RAD:l0,DRAW_MODES:Ai,DisplacementFilter:sf,DisplayObject:fr,ENV:ys,Ellipse:kn,EventBoundary:af,EventSystem:ua,ExtensionType:Kt,Extract:Qf,FORMATS:qt,FORMATS_TO_COMPONENTS:zf,FXAAFilter:nf,FederatedDisplayObject:lf,FederatedEvent:nn,FederatedMouseEvent:qn,FederatedPointerEvent:di,FederatedWheelEvent:zs,FillStyle:io,Filter:Gr,FilterState:E0,FilterSystem:dl,Framebuffer:Qo,FramebufferSystem:pl,GC_MODES:ko,GLFramebuffer:C0,GLProgram:k0,GLTexture:ia,GRAPHICS_CURVES:Xg,GenerateTextureSystem:bl,Geometry:ls,GeometrySystem:gl,Graphics:tu,GraphicsData:ro,GraphicsGeometry:nd,HTMLText:lo,HTMLTextStyle:$a,IGLUniformData:i_,INSTALLED:Xo,INTERNAL_FORMATS:Fr,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:Jn,ImageBitmapResource:Xs,ImageResource:ll,LINE_CAP:fs,LINE_JOIN:ni,LineStyle:xa,LoaderParserPriority:_i,MASK_TYPES:br,MIPMAP_MODES:wi,MSAA_QUALITY:yr,MaskData:$0,MaskSystem:ml,Matrix:nr,Mesh:cn,MeshBatchUvs:od,MeshGeometry:so,MeshMaterial:fn,MultisampleSystem:Pl,NineSlicePlane:qg,NoiseFilter:of,ObjectRenderer:Nn,ObjectRendererSystem:Ml,ObservablePoint:$i,PI_2:Fn,PRECISION:ri,ParticleContainer:Kg,ParticleRenderer:ru,PlaneGeometry:ld,PluginSystem:vl,Point:He,Polygon:xs,Prepare:ou,Program:Hi,ProjectionSystem:xl,Quad:T0,QuadUv:cl,RAD_TO_DEG:h0,RENDERER_TYPE:qa,Rectangle:Ve,RenderTexture:As,RenderTexturePool:ul,RenderTextureSystem:Al,Renderer:oa,ResizePlugin:Gl,Resource:en,RopeGeometry:ud,RoundedRectangle:Bn,Runner:si,SAMPLER_TYPES:le,SCALE_MODES:Gi,SHAPES:Ir,SVGResource:aa,ScissorSystem:F0,Shader:Mi,ShaderSystem:wl,SimpleMesh:Zg,SimplePlane:cd,SimpleRope:Qg,Sprite:us,SpriteMaskFilter:P0,Spritesheet:lu,StartupSystem:zn,State:Pi,StateSystem:X0,StencilSystem:yl,SystemManager:z0,TARGETS:Fs,TEXT_GRADIENT:no,TYPES:Pe,TYPES_TO_BYTES_PER_COMPONENT:Yl,TYPES_TO_BYTES_PER_PIXEL:Wf,TemporaryDisplayObject:Ll,Text:nu,TextFormat:ho,TextMetrics:ds,TextStyle:ps,Texture:ne,TextureGCSystem:ws,TextureMatrix:ea,TextureSystem:Tl,TextureUvs:Ko,Ticker:vr,TickerPlugin:sa,TilingSprite:au,TilingSpriteRenderer:hu,TimeLimiter:dm,Transform:rn,TransformFeedback:A_,TransformFeedbackSystem:El,UPDATE_PRIORITY:ji,UniformGroup:fi,VERSION:w_,VideoResource:Fl,ViewSystem:Hn,ViewableBuffer:Vo,WRAP_MODES:Vi,XMLFormat:Ca,XMLStringFormat:Sa,accessibleTarget:uf,autoDetectFormat:Ad,autoDetectRenderer:Y0,autoDetectResource:Jh,cacheTextureArray:Pf,checkDataUrl:Ws,checkExtension:cs,checkMaxIfStatementsInShader:o0,convertToList:pi,copySearchParams:fa,createStringVariations:gf,createTexture:hn,createUBOElements:N0,curves:Ss,defaultFilterVertex:Sl,defaultVertex:j0,detectAvif:Mf,detectCompressedTextures:Nf,detectDefaults:If,detectMp4:Lf,detectOgv:kf,detectWebm:Ff,detectWebp:Df,extensions:be,filters:kl,generateProgram:B0,generateUniformBufferSync:G0,getFontFamilyName:vf,getTestContext:p0,getUBOData:U0,graphicsUtils:Hg,groupD8:pr,isMobile:Ci,isSingleItem:Zn,loadBitmapFont:Pd,loadDDS:Yf,loadImageBitmap:Tf,loadJson:mf,loadKTX:jf,loadSVG:Ef,loadTextures:Qn,loadTxt:yf,loadVideo:Cf,loadWebFont:xf,parseDDS:Vf,parseKTX:Hf,resolveCompressedTextureUrl:qf,resolveTextureUrl:Bf,settings:ue,spritesheetAsset:bd,uniformParsers:Gs,unsafeEvalSupported:x0,utils:Sp},Symbol.toStringTag,{value:"Module"}));var $d=function(){function s(){this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0,this.global=new He,this.target=null,this.originalEvent=null,this.identifier=null,this.isPrimary=!1,this.button=0,this.buttons=0,this.width=0,this.height=0,this.tiltX=0,this.tiltY=0,this.pointerType=null,this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0}return Object.defineProperty(s.prototype,"pointerId",{get:function(){return this.identifier},enumerable:!1,configurable:!0}),s.prototype.getLocalPosition=function(t,r,i){return t.worldTransform.applyInverse(i||this.global,r)},s.prototype.copyEvent=function(t){"isPrimary"in t&&t.isPrimary&&(this.isPrimary=!0),this.button="button"in t&&t.button;var r="buttons"in t&&t.buttons;this.buttons=Number.isInteger(r)?r:"which"in t&&t.which,this.width="width"in t&&t.width,this.height="height"in t&&t.height,this.tiltX="tiltX"in t&&t.tiltX,this.tiltY="tiltY"in t&&t.tiltY,this.pointerType="pointerType"in t&&t.pointerType,this.pressure="pressure"in t&&t.pressure,this.rotationAngle="rotationAngle"in t&&t.rotationAngle,this.twist="twist"in t&&t.twist||0,this.tangentialPressure="tangentialPressure"in t&&t.tangentialPressure||0},s.prototype.reset=function(){this.isPrimary=!1},s}();var fu=function(s,t){return fu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},fu(s,t)};function Sm(s,t){fu(s,t);function r(){this.constructor=s}s.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var Pm=function(){function s(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.target=null,this.currentTarget=null,this.type=null,this.data=null}return s.prototype.stopPropagation=function(){this.stopped=!0,this.stopPropagationHint=!0,this.stopsPropagatingAt=this.currentTarget},s.prototype.reset=function(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.currentTarget=null,this.target=null},s}(),du=function(){function s(t){this._pointerId=t,this._flags=s.FLAGS.NONE}return s.prototype._doSet=function(t,r){r?this._flags=this._flags|t:this._flags=this._flags&~t},Object.defineProperty(s.prototype,"pointerId",{get:function(){return this._pointerId},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"flags",{get:function(){return this._flags},set:function(t){this._flags=t},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"none",{get:function(){return this._flags===s.FLAGS.NONE},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"over",{get:function(){return(this._flags&s.FLAGS.OVER)!==0},set:function(t){this._doSet(s.FLAGS.OVER,t)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"rightDown",{get:function(){return(this._flags&s.FLAGS.RIGHT_DOWN)!==0},set:function(t){this._doSet(s.FLAGS.RIGHT_DOWN,t)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"leftDown",{get:function(){return(this._flags&s.FLAGS.LEFT_DOWN)!==0},set:function(t){this._doSet(s.FLAGS.LEFT_DOWN,t)},enumerable:!1,configurable:!0}),s.FLAGS=Object.freeze({NONE:0,OVER:1,LEFT_DOWN:2,RIGHT_DOWN:4}),s}(),$m=function(){function s(){this._tempPoint=new He}return s.prototype.recursiveFindHit=function(t,r,i,n,o){var h;if(!r||!r.visible)return!1;var c=t.data.global;o=r.interactive||o;var b=!1,T=o,C=!0;if(r.hitArea)n&&(r.worldTransform.applyInverse(c,this._tempPoint),r.hitArea.contains(this._tempPoint.x,this._tempPoint.y)?b=!0:(n=!1,C=!1)),T=!1;else if(r._mask&&n){var x=r._mask.isMaskData?r._mask.maskObject:r._mask;x&&!(!((h=x.containsPoint)===null||h===void 0)&&h.call(x,c))&&(n=!1)}if(C&&r.interactiveChildren&&r.children)for(var $=r.children,I=$.length-1;I>=0;I--){var B=$[I],U=this.recursiveFindHit(t,B,i,n,T);if(U){if(!B.parent)continue;T=!1,U&&(t.target&&(n=!1),b=!0)}}return o&&(n&&!t.target&&!r.hitArea&&r.containsPoint&&r.containsPoint(c)&&(b=!0),r.interactive&&(b&&!t.target&&(t.target=r),i&&i(t,r,!!b))),b},s.prototype.findHit=function(t,r,i,n){this.recursiveFindHit(t,r,i,n,!1)},s}(),Mm={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return this.cursor==="pointer"},set buttonMode(s){s?this.cursor="pointer":this.cursor==="pointer"&&(this.cursor=null)},cursor:null,get trackedPointers(){return this._trackedPointers===void 0&&(this._trackedPointers={}),this._trackedPointers},_trackedPointers:void 0};fr.mixin(Mm);var Ma=1,Da={target:null,data:{global:null}},Dm=function(s){Sm(t,s);function t(r,i){var n=s.call(this)||this;return i=i||{},n.renderer=r,n.autoPreventDefault=i.autoPreventDefault!==void 0?i.autoPreventDefault:!0,n.interactionFrequency=i.interactionFrequency||10,n.mouse=new $d,n.mouse.identifier=Ma,n.mouse.global.set(-999999),n.activeInteractionData={},n.activeInteractionData[Ma]=n.mouse,n.interactionDataPool=[],n.eventData=new Pm,n.interactionDOMElement=null,n.moveWhenInside=!1,n.eventsAdded=!1,n.tickerAdded=!1,n.mouseOverRenderer=!("PointerEvent"in globalThis),n.supportsTouchEvents="ontouchstart"in globalThis,n.supportsPointerEvents=!!globalThis.PointerEvent,n.onPointerUp=n.onPointerUp.bind(n),n.processPointerUp=n.processPointerUp.bind(n),n.onPointerCancel=n.onPointerCancel.bind(n),n.processPointerCancel=n.processPointerCancel.bind(n),n.onPointerDown=n.onPointerDown.bind(n),n.processPointerDown=n.processPointerDown.bind(n),n.onPointerMove=n.onPointerMove.bind(n),n.processPointerMove=n.processPointerMove.bind(n),n.onPointerOut=n.onPointerOut.bind(n),n.processPointerOverOut=n.processPointerOverOut.bind(n),n.onPointerOver=n.onPointerOver.bind(n),n.cursorStyles={default:"inherit",pointer:"pointer"},n.currentCursorMode=null,n.cursor=null,n.resolution=1,n.delayedEvents=[],n.search=new $m,n._tempDisplayObject=new Ll,n._eventListenerOptions={capture:!0,passive:!1},n._useSystemTicker=i.useSystemTicker!==void 0?i.useSystemTicker:!0,n.setTargetElement(n.renderer.view,n.renderer.resolution),n}return Object.defineProperty(t.prototype,"useSystemTicker",{get:function(){return this._useSystemTicker},set:function(r){this._useSystemTicker=r,r?this.addTickerListener():this.removeTickerListener()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastObjectRendered",{get:function(){return this.renderer._lastObjectRendered||this._tempDisplayObject},enumerable:!1,configurable:!0}),t.prototype.hitTest=function(r,i){return Da.target=null,Da.data.global=r,i||(i=this.lastObjectRendered),this.processInteractive(Da,i,null,!0),Da.target},t.prototype.setTargetElement=function(r,i){i===void 0&&(i=1),this.removeTickerListener(),this.removeEvents(),this.interactionDOMElement=r,this.resolution=i,this.addEvents(),this.addTickerListener()},t.prototype.addTickerListener=function(){this.tickerAdded||!this.interactionDOMElement||!this._useSystemTicker||(vr.system.add(this.tickerUpdate,this,ji.INTERACTION),this.tickerAdded=!0)},t.prototype.removeTickerListener=function(){this.tickerAdded&&(vr.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)},t.prototype.addEvents=function(){if(!(this.eventsAdded||!this.interactionDOMElement)){var r=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(r.msContentZooming="none",r.msTouchAction="none"):this.supportsPointerEvents&&(r.touchAction="none"),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerdown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerleave",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerover",this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener("pointercancel",this.onPointerCancel,this._eventListenerOptions),globalThis.addEventListener("pointerup",this.onPointerUp,this._eventListenerOptions)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mousedown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mouseout",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mouseover",this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener("mouseup",this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.addEventListener("touchstart",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchcancel",this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchend",this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchmove",this.onPointerMove,this._eventListenerOptions)),this.eventsAdded=!0}},t.prototype.removeEvents=function(){if(!(!this.eventsAdded||!this.interactionDOMElement)){var r=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(r.msContentZooming="",r.msTouchAction=""):this.supportsPointerEvents&&(r.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerdown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerleave",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerover",this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener("pointercancel",this.onPointerCancel,this._eventListenerOptions),globalThis.removeEventListener("pointerup",this.onPointerUp,this._eventListenerOptions)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mousedown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mouseout",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mouseover",this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener("mouseup",this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.removeEventListener("touchstart",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchcancel",this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchend",this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchmove",this.onPointerMove,this._eventListenerOptions)),this.interactionDOMElement=null,this.eventsAdded=!1}},t.prototype.tickerUpdate=function(r){this._deltaTime+=r,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())},t.prototype.update=function(){if(this.interactionDOMElement){if(this._didMove){this._didMove=!1;return}this.cursor=null;for(var r in this.activeInteractionData)if(this.activeInteractionData.hasOwnProperty(r)){var i=this.activeInteractionData[r];if(i.originalEvent&&i.pointerType!=="touch"){var n=this.configureInteractionEventForDOMEvent(this.eventData,i.originalEvent,i);this.processInteractive(n,this.lastObjectRendered,this.processPointerOverOut,!0)}}this.setCursorMode(this.cursor)}},t.prototype.setCursorMode=function(r){r=r||"default";var i=!0;if(globalThis.OffscreenCanvas&&this.interactionDOMElement instanceof OffscreenCanvas&&(i=!1),this.currentCursorMode!==r){this.currentCursorMode=r;var n=this.cursorStyles[r];if(n)switch(typeof n){case"string":i&&(this.interactionDOMElement.style.cursor=n);break;case"function":n(r);break;case"object":i&&Object.assign(this.interactionDOMElement.style,n);break}else i&&typeof r=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,r)&&(this.interactionDOMElement.style.cursor=r)}},t.prototype.dispatchEvent=function(r,i,n){(!n.stopPropagationHint||r===n.stopsPropagatingAt)&&(n.currentTarget=r,n.type=i,r.emit(i,n),r[i]&&r[i](n))},t.prototype.delayDispatchEvent=function(r,i,n){this.delayedEvents.push({displayObject:r,eventString:i,eventData:n})},t.prototype.mapPositionToPoint=function(r,i,n){var o;this.interactionDOMElement.parentElement?o=this.interactionDOMElement.getBoundingClientRect():o={x:0,y:0,width:this.interactionDOMElement.width,height:this.interactionDOMElement.height,left:0,top:0};var h=1/this.resolution;r.x=(i-o.left)*(this.interactionDOMElement.width/o.width)*h,r.y=(n-o.top)*(this.interactionDOMElement.height/o.height)*h},t.prototype.processInteractive=function(r,i,n,o){var h=this.search.findHit(r,i,n,o),c=this.delayedEvents;if(!c.length)return h;r.stopPropagationHint=!1;var b=c.length;this.delayedEvents=[];for(var T=0;T<b;T++){var C=c[T],x=C.displayObject,$=C.eventString,I=C.eventData;I.stopsPropagatingAt===x&&(I.stopPropagationHint=!0),this.dispatchEvent(x,$,I)}return h},t.prototype.onPointerDown=function(r){if(!(this.supportsTouchEvents&&r.pointerType==="touch")){var i=this.normalizeToPointerData(r);if(this.autoPreventDefault&&i[0].isNormalized){var n=r.cancelable||!("cancelable"in r);n&&r.preventDefault()}for(var o=i.length,h=0;h<o;h++){var c=i[h],b=this.getInteractionDataForPointerId(c),T=this.configureInteractionEventForDOMEvent(this.eventData,c,b);if(T.data.originalEvent=r,this.processInteractive(T,this.lastObjectRendered,this.processPointerDown,!0),this.emit("pointerdown",T),c.pointerType==="touch")this.emit("touchstart",T);else if(c.pointerType==="mouse"||c.pointerType==="pen"){var C=c.button===2;this.emit(C?"rightdown":"mousedown",this.eventData)}}}},t.prototype.processPointerDown=function(r,i,n){var o=r.data,h=r.data.identifier;if(n){if(i.trackedPointers[h]||(i.trackedPointers[h]=new du(h)),this.dispatchEvent(i,"pointerdown",r),o.pointerType==="touch")this.dispatchEvent(i,"touchstart",r);else if(o.pointerType==="mouse"||o.pointerType==="pen"){var c=o.button===2;c?i.trackedPointers[h].rightDown=!0:i.trackedPointers[h].leftDown=!0,this.dispatchEvent(i,c?"rightdown":"mousedown",r)}}},t.prototype.onPointerComplete=function(r,i,n){var o=this.normalizeToPointerData(r),h=o.length,c=r.target;r.composedPath&&r.composedPath().length>0&&(c=r.composedPath()[0]);for(var b=c!==this.interactionDOMElement?"outside":"",T=0;T<h;T++){var C=o[T],x=this.getInteractionDataForPointerId(C),$=this.configureInteractionEventForDOMEvent(this.eventData,C,x);if($.data.originalEvent=r,this.processInteractive($,this.lastObjectRendered,n,i||!b),this.emit(i?"pointercancel":"pointerup"+b,$),C.pointerType==="mouse"||C.pointerType==="pen"){var I=C.button===2;this.emit(I?"rightup"+b:"mouseup"+b,$)}else C.pointerType==="touch"&&(this.emit(i?"touchcancel":"touchend"+b,$),this.releaseInteractionDataForPointerId(C.pointerId))}},t.prototype.onPointerCancel=function(r){this.supportsTouchEvents&&r.pointerType==="touch"||this.onPointerComplete(r,!0,this.processPointerCancel)},t.prototype.processPointerCancel=function(r,i){var n=r.data,o=r.data.identifier;i.trackedPointers[o]!==void 0&&(delete i.trackedPointers[o],this.dispatchEvent(i,"pointercancel",r),n.pointerType==="touch"&&this.dispatchEvent(i,"touchcancel",r))},t.prototype.onPointerUp=function(r){this.supportsTouchEvents&&r.pointerType==="touch"||this.onPointerComplete(r,!1,this.processPointerUp)},t.prototype.processPointerUp=function(r,i,n){var o=r.data,h=r.data.identifier,c=i.trackedPointers[h],b=o.pointerType==="touch",T=o.pointerType==="mouse"||o.pointerType==="pen",C=!1;if(T){var x=o.button===2,$=du.FLAGS,I=x?$.RIGHT_DOWN:$.LEFT_DOWN,B=c!==void 0&&c.flags&I;n?(this.dispatchEvent(i,x?"rightup":"mouseup",r),B&&(this.dispatchEvent(i,x?"rightclick":"click",r),C=!0)):B&&this.dispatchEvent(i,x?"rightupoutside":"mouseupoutside",r),c&&(x?c.rightDown=!1:c.leftDown=!1)}n?(this.dispatchEvent(i,"pointerup",r),b&&this.dispatchEvent(i,"touchend",r),c&&((!T||C)&&this.dispatchEvent(i,"pointertap",r),b&&(this.dispatchEvent(i,"tap",r),c.over=!1))):c&&(this.dispatchEvent(i,"pointerupoutside",r),b&&this.dispatchEvent(i,"touchendoutside",r)),c&&c.none&&delete i.trackedPointers[h]},t.prototype.onPointerMove=function(r){if(!(this.supportsTouchEvents&&r.pointerType==="touch")){var i=this.normalizeToPointerData(r);(i[0].pointerType==="mouse"||i[0].pointerType==="pen")&&(this._didMove=!0,this.cursor=null);for(var n=i.length,o=0;o<n;o++){var h=i[o],c=this.getInteractionDataForPointerId(h),b=this.configureInteractionEventForDOMEvent(this.eventData,h,c);b.data.originalEvent=r,this.processInteractive(b,this.lastObjectRendered,this.processPointerMove,!0),this.emit("pointermove",b),h.pointerType==="touch"&&this.emit("touchmove",b),(h.pointerType==="mouse"||h.pointerType==="pen")&&this.emit("mousemove",b)}i[0].pointerType==="mouse"&&this.setCursorMode(this.cursor)}},t.prototype.processPointerMove=function(r,i,n){var o=r.data,h=o.pointerType==="touch",c=o.pointerType==="mouse"||o.pointerType==="pen";c&&this.processPointerOverOut(r,i,n),(!this.moveWhenInside||n)&&(this.dispatchEvent(i,"pointermove",r),h&&this.dispatchEvent(i,"touchmove",r),c&&this.dispatchEvent(i,"mousemove",r))},t.prototype.onPointerOut=function(r){if(!(this.supportsTouchEvents&&r.pointerType==="touch")){var i=this.normalizeToPointerData(r),n=i[0];n.pointerType==="mouse"&&(this.mouseOverRenderer=!1,this.setCursorMode(null));var o=this.getInteractionDataForPointerId(n),h=this.configureInteractionEventForDOMEvent(this.eventData,n,o);h.data.originalEvent=n,this.processInteractive(h,this.lastObjectRendered,this.processPointerOverOut,!1),this.emit("pointerout",h),n.pointerType==="mouse"||n.pointerType==="pen"?this.emit("mouseout",h):this.releaseInteractionDataForPointerId(o.identifier)}},t.prototype.processPointerOverOut=function(r,i,n){var o=r.data,h=r.data.identifier,c=o.pointerType==="mouse"||o.pointerType==="pen",b=i.trackedPointers[h];n&&!b&&(b=i.trackedPointers[h]=new du(h)),b!==void 0&&(n&&this.mouseOverRenderer?(b.over||(b.over=!0,this.delayDispatchEvent(i,"pointerover",r),c&&this.delayDispatchEvent(i,"mouseover",r)),c&&this.cursor===null&&(this.cursor=i.cursor)):b.over&&(b.over=!1,this.dispatchEvent(i,"pointerout",this.eventData),c&&this.dispatchEvent(i,"mouseout",r),b.none&&delete i.trackedPointers[h]))},t.prototype.onPointerOver=function(r){if(!(this.supportsTouchEvents&&r.pointerType==="touch")){var i=this.normalizeToPointerData(r),n=i[0],o=this.getInteractionDataForPointerId(n),h=this.configureInteractionEventForDOMEvent(this.eventData,n,o);h.data.originalEvent=n,n.pointerType==="mouse"&&(this.mouseOverRenderer=!0),this.emit("pointerover",h),(n.pointerType==="mouse"||n.pointerType==="pen")&&this.emit("mouseover",h)}},t.prototype.getInteractionDataForPointerId=function(r){var i=r.pointerId,n;return i===Ma||r.pointerType==="mouse"?n=this.mouse:this.activeInteractionData[i]?n=this.activeInteractionData[i]:(n=this.interactionDataPool.pop()||new $d,n.identifier=i,this.activeInteractionData[i]=n),n.copyEvent(r),n},t.prototype.releaseInteractionDataForPointerId=function(r){var i=this.activeInteractionData[r];i&&(delete this.activeInteractionData[r],i.reset(),this.interactionDataPool.push(i))},t.prototype.configureInteractionEventForDOMEvent=function(r,i,n){return r.data=n,this.mapPositionToPoint(n.global,i.clientX,i.clientY),i.pointerType==="touch"&&(i.globalX=n.global.x,i.globalY=n.global.y),n.originalEvent=i,r.reset(),r},t.prototype.normalizeToPointerData=function(r){var i=[];if(this.supportsTouchEvents&&r instanceof TouchEvent)for(var n=0,o=r.changedTouches.length;n<o;n++){var h=r.changedTouches[n];typeof h.button>"u"&&(h.button=r.touches.length?1:0),typeof h.buttons>"u"&&(h.buttons=r.touches.length?1:0),typeof h.isPrimary>"u"&&(h.isPrimary=r.touches.length===1&&r.type==="touchstart"),typeof h.width>"u"&&(h.width=h.radiusX||1),typeof h.height>"u"&&(h.height=h.radiusY||1),typeof h.tiltX>"u"&&(h.tiltX=0),typeof h.tiltY>"u"&&(h.tiltY=0),typeof h.pointerType>"u"&&(h.pointerType="touch"),typeof h.pointerId>"u"&&(h.pointerId=h.identifier||0),typeof h.pressure>"u"&&(h.pressure=h.force||.5),typeof h.twist>"u"&&(h.twist=0),typeof h.tangentialPressure>"u"&&(h.tangentialPressure=0),typeof h.layerX>"u"&&(h.layerX=h.offsetX=h.clientX),typeof h.layerY>"u"&&(h.layerY=h.offsetY=h.clientY),h.isNormalized=!0,i.push(h)}else if(!globalThis.MouseEvent||r instanceof MouseEvent&&(!this.supportsPointerEvents||!(r instanceof globalThis.PointerEvent))){var c=r;typeof c.isPrimary>"u"&&(c.isPrimary=!0),typeof c.width>"u"&&(c.width=1),typeof c.height>"u"&&(c.height=1),typeof c.tiltX>"u"&&(c.tiltX=0),typeof c.tiltY>"u"&&(c.tiltY=0),typeof c.pointerType>"u"&&(c.pointerType="mouse"),typeof c.pointerId>"u"&&(c.pointerId=Ma),typeof c.pressure>"u"&&(c.pressure=.5),typeof c.twist>"u"&&(c.twist=0),typeof c.tangentialPressure>"u"&&(c.tangentialPressure=0),c.isNormalized=!0,i.push(c)}else i.push(r);return i},t.prototype.destroy=function(){this.removeEvents(),this.removeTickerListener(),this.removeAllListeners(),this.renderer=null,this.mouse=null,this.eventData=null,this.interactionDOMElement=null,this.onPointerDown=null,this.processPointerDown=null,this.onPointerUp=null,this.processPointerUp=null,this.onPointerCancel=null,this.processPointerCancel=null,this.onPointerMove=null,this.processPointerMove=null,this.onPointerOut=null,this.processPointerOverOut=null,this.onPointerOver=null,this.search=null},t.extension={name:"interaction",type:[Kt.RendererPlugin,Kt.CanvasRendererPlugin]},t}(Xi),Rm=Object.defineProperty,Ys=Math.pow,Im=(s,t,r)=>t in s?Rm(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,bt=(s,t,r)=>(Im(s,typeof t!="symbol"?t+"":t,r),r),_r=(s,t,r)=>new Promise((i,n)=>{var o=b=>{try{c(r.next(b))}catch(T){n(T)}},h=b=>{try{c(r.throw(b))}catch(T){n(T)}},c=b=>b.done?i(b.value):Promise.resolve(b.value).then(o,h);c((r=r.apply(s,t)).next())});const Md=2,Dd=2;var Ra;(s=>{s.supportMoreMaskDivisions=!0,s.setOpacityFromMotion=!1})(Ra||(Ra={}));const dn={motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500},or={log(s,...t){},warn(s,...t){console.warn(`[${s}]`,...t)},error(s,...t){console.error(`[${s}]`,...t)}};function pn(s,t,r){return s<t?t:s>r?r:s}function Fm(s,t){return Math.random()*(t-s)+s}function uo(s,t,r,i,n){const o=t[i];o!==null&&typeof o===s&&(r[n]=o)}function co(s,t,r,i,n){const o=t[i];Array.isArray(o)&&(r[n]=o.filter(h=>h!==null&&typeof h===s))}function Lm(s,t){t.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(s.prototype,i,Object.getOwnPropertyDescriptor(r.prototype,i))})})}function km(s){let t=s.lastIndexOf("/");return t!=-1&&(s=s.slice(0,t)),t=s.lastIndexOf("/"),t!==-1&&(s=s.slice(t+1)),s}function Bm(s,t){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}class pu extends Xi{constructor(t,r){super(),bt(this,"tag"),bt(this,"settings"),bt(this,"expressions",[]),bt(this,"defaultExpression"),bt(this,"currentExpression"),bt(this,"reserveExpressionIndex",-1),bt(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return _r(this,null,function*(){if(!this.definitions[t]){or.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){or.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}if(this.expressions[t])return this.expressions[t];const r=yield this._loadExpression(t);return this.expressions[t]=r,r})}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return _r(this,null,function*(){if(this.definitions.length){const t=[];for(let r=0;r<this.definitions.length;r++)this.expressions[r]!==null&&this.expressions[r]!==this.currentExpression&&r!==this.reserveExpressionIndex&&t.push(r);if(t.length){const r=Math.floor(Math.random()*t.length);return this.setExpression(r)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return _r(this,null,function*(){if(typeof t!="number"&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length)||t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const r=yield this.loadExpression(t);return!r||this.reserveExpressionIndex!==t?!1:(this.reserveExpressionIndex=-1,this.currentExpression=r,this._setExpression(r),!0)})}update(t,r){return this.isFinished()?!1:this.updateParameters(t,r)}destroy(){this.destroyed=!0,this.emit("destroy");const t=this;t.definitions=void 0,t.expressions=void 0}}const Rd=.01,Om=40/7.5,Nm=1/(.15*1e3);class Um{constructor(){bt(this,"targetX",0),bt(this,"targetY",0),bt(this,"x",0),bt(this,"y",0),bt(this,"vx",0),bt(this,"vy",0)}focus(t,r,i=!1){this.targetX=pn(t,-1,1),this.targetY=pn(r,-1,1),i&&(this.x=this.targetX,this.y=this.targetY)}update(t){const r=this.targetX-this.x,i=this.targetY-this.y;if(Math.abs(r)<Rd&&Math.abs(i)<Rd)return;const n=Math.sqrt(Ys(r,2)+Ys(i,2)),o=Om/(1e3/t);let h=o*(r/n)-this.vx,c=o*(i/n)-this.vy;const b=Math.sqrt(Ys(h,2)+Ys(c,2)),T=o*Nm*t;b>T&&(h*=T/b,c*=T/b),this.vx+=h,this.vy+=c;const C=Math.sqrt(Ys(this.vx,2)+Ys(this.vy,2)),x=.5*(Math.sqrt(Ys(T,2)+8*T*n)-T);C>x&&(this.vx*=x/C,this.vy*=x/C),this.x+=this.vx,this.y+=this.vy}}class Ia{constructor(t){bt(this,"json"),bt(this,"name"),bt(this,"url"),bt(this,"pose"),bt(this,"physics"),this.json=t;const r=t.url;if(typeof r!="string")throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=r,this.name=km(this.url)}resolveURL(t){return No.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let r=0;r<this.textures.length;r++)this.textures[r]=t(this.textures[r],`textures[${r}]`)}getDefinedFiles(){const t=[];return this.replaceFiles(r=>(t.push(r),r)),t}validateFiles(t){const r=(o,h)=>{const c=this.resolveURL(o);if(!t.includes(c)){if(h)throw new Error(`File "${o}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(o=>r(o,!0)),this.getDefinedFiles().filter(o=>r(o,!1))}}var Fa=(s=>(s[s.NONE=0]="NONE",s[s.IDLE=1]="IDLE",s[s.NORMAL=2]="NORMAL",s[s.FORCE=3]="FORCE",s))(Fa||{});class Gm{constructor(){bt(this,"tag"),bt(this,"debug",!1),bt(this,"currentPriority",0),bt(this,"reservePriority",0),bt(this,"currentGroup"),bt(this,"currentIndex"),bt(this,"reservedGroup"),bt(this,"reservedIndex"),bt(this,"reservedIdleGroup"),bt(this,"reservedIdleIndex")}reserve(t,r,i){if(i<=0)return or.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&r===this.currentIndex)return or.log(this.tag,"Motion is already playing.",this.dump(t,r)),!1;if(t===this.reservedGroup&&r===this.reservedIndex||t===this.reservedIdleGroup&&r===this.reservedIdleIndex)return or.log(this.tag,"Motion is already reserved.",this.dump(t,r)),!1;if(i===1){if(this.currentPriority!==0)return or.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,r)),!1;if(this.reservedIdleGroup!==void 0)return or.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,r)),!1;this.setReservedIdle(t,r)}else{if(i<3){if(i<=this.currentPriority)return or.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,r)),!1;if(i<=this.reservePriority)return or.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,r)),!1}this.setReserved(t,r,i)}return!0}start(t,r,i,n){if(n===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return or.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(r,i)),!1}else{if(r!==this.reservedGroup||i!==this.reservedIndex)return or.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(r,i)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(r,i,n),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,r,i){this.currentPriority=i,this.currentGroup=t,this.currentIndex=r}setReserved(t,r,i){this.reservePriority=i,this.reservedGroup=t,this.reservedIndex=r}setReservedIdle(t,r){this.reservedIdleGroup=t,this.reservedIdleIndex=r}isActive(t,r){return t===this.currentGroup&&r===this.currentIndex||t===this.reservedGroup&&r===this.reservedIndex||t===this.reservedIdleGroup&&r===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!1}dump(t,r){if(this.debug){const i=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
1190
- <Requested> group = "${t}", index = ${r}
1191
- `+i.map(n=>"["+n+"] "+this[n]).join(`
1192
- `)}return""}}const Vm="SoundManager",_n=.5;class Mr{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(r=>r.volume=this._volume)}static add(t,r,i,n){const o=new Audio(t);return o.volume=this._volume,o.preload="auto",o.crossOrigin=n,o.addEventListener("ended",()=>{this.dispose(o),r==null||r()}),o.addEventListener("error",h=>{this.dispose(o),or.warn(Vm,`Error occurred on "${t}"`,h.error),i==null||i(h.error)}),this.audios.push(o),o}static play(t){return new Promise((r,i)=>{var n;(n=t.play())==null||n.catch(o=>{t.dispatchEvent(new ErrorEvent("error",{error:o})),i(o)}),t.readyState===t.HAVE_ENOUGH_DATA?r():t.addEventListener("canplaythrough",r)})}static addContext(t){const r=new AudioContext;return this.contexts.push(r),r}static addAnalyzer(t,r){const i=r.createMediaElementSource(t),n=r.createAnalyser();return n.fftSize=256,n.minDecibels=-90,n.maxDecibels=-10,n.smoothingTimeConstant=.85,i.connect(n),n.connect(r.destination),this.analysers.push(n),n}static analyze(t){if(t!=null){const r=new Float32Array(t.fftSize);let i=0;t.getFloatTimeDomainData(r);for(const n of r)i+=n*n;return parseFloat(Math.sqrt(i/r.length*20).toFixed(1))}else return parseFloat(Math.random().toFixed(1))}static dispose(t){t.pause(),t.removeAttribute("src"),Bm(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--)this.contexts[t].close();for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}bt(Mr,"audios",[]),bt(Mr,"analysers",[]),bt(Mr,"contexts",[]),bt(Mr,"_volume",_n);class fo extends Xi{constructor(t,r){super(),bt(this,"tag"),bt(this,"settings"),bt(this,"motionGroups",{}),bt(this,"state",new Gm),bt(this,"currentAudio"),bt(this,"currentAnalyzer"),bt(this,"currentContext"),bt(this,"playing",!1),bt(this,"destroyed",!1),this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];let r;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":r=Object.keys(this.definitions);break;case"IDLE":default:r=[this.groups.idle];break}for(const i of r)if(this.definitions[i])for(let n=0;n<this.definitions[i].length;n++)this.loadMotion(i,n).then()}loadMotion(t,r){return _r(this,null,function*(){var i;if(!((i=this.definitions[t])!=null&&i[r])){or.warn(this.tag,`Undefined motion at "${t}"[${r}]`);return}if(this.motionGroups[t][r]===null){or.warn(this.tag,`Cannot start motion at "${t}"[${r}] because it's already failed in loading.`);return}if(this.motionGroups[t][r])return this.motionGroups[t][r];const n=yield this._loadMotion(t,r);if(!this.destroyed)return this.motionGroups[t][r]=n??null,n})}_loadMotion(t,r){throw new Error("Not implemented.")}speak(t){return _r(this,arguments,function*(r,{volume:i=_n,expression:n,resetExpression:o=!0,crossOrigin:h,onFinish:c,onError:b}={}){let T,C,x;if(this.currentAudio&&!this.currentAudio.ended)return!1;let $;const I=r&&r.startsWith("data:");if(console.log(c),r&&!I){const U=document.createElement("a");U.href=r,r=U.href,$=r}else $="data:audio/";const B=r;if(B)try{T=Mr.add(B,(U=this)=>{console.log("Audio finished playing"),c==null||c(),o&&n&&U.expressionManager&&U.expressionManager.resetExpression(),U.currentAudio=void 0},(U,G=this)=>{console.log("Error during audio playback:",U),b==null||b(U),o&&n&&G.expressionManager&&G.expressionManager.resetExpression(),G.currentAudio=void 0},h),this.currentAudio=T,Mr.volume=i,x=Mr.addContext(this.currentAudio),this.currentContext=x,C=Mr.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=C}catch(U){return or.warn(this.tag,"Failed to create audio",$,U),!1}if(T){let U=!0;if(yield Mr.play(T).catch(z=>{or.warn(this.tag,"Failed to play audio",T.src,z),U=!1}),!U)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),n&&this.expressionManager&&this.expressionManager.setExpression(n),this.playing=!0,!0})}startMotion(t,r){return _r(this,arguments,function*(i,n,o=Fa.NORMAL,{sound:h=void 0,volume:c=_n,expression:b=void 0,resetExpression:T=!0,crossOrigin:C,onFinish:x,onError:$}={}){var I;if(!this.state.reserve(i,n,o)||this.currentAudio&&!this.currentAudio.ended&&o!=Fa.FORCE)return!1;const B=(I=this.definitions[i])==null?void 0:I[n];if(!B)return!1;this.currentAudio&&Mr.dispose(this.currentAudio);let U,G,z,J;const Z=h&&h.startsWith("data:");if(h&&!Z){const _t=document.createElement("a");_t.href=h,h=_t.href,J=h}else J=this.getSoundFile(B),J&&(J=this.settings.resolveURL(J));const it=J;if(it)try{U=Mr.add(it,(_t=this)=>{console.log("Audio finished playing"),x==null||x(),console.log(x),T&&b&&_t.expressionManager&&_t.expressionManager.resetExpression(),_t.currentAudio=void 0},(_t,et=this)=>{console.log("Error during audio playback:",_t),$==null||$(_t),T&&b&&et.expressionManager&&et.expressionManager.resetExpression(),et.currentAudio=void 0},C),this.currentAudio=U,Mr.volume=c,z=Mr.addContext(this.currentAudio),this.currentContext=z,G=Mr.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=G}catch(_t){or.warn(this.tag,"Failed to create audio",J,_t)}const Q=yield this.loadMotion(i,n);return U&&(yield Mr.play(U).catch(et=>or.warn(this.tag,"Failed to play audio",U.src,et))),this.state.start(Q,i,n,o)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),or.log(this.tag,"Start motion:",this.getMotionName(B)),this.emit("motionStart",i,n,U),b&&this.expressionManager&&this.state.shouldOverrideExpression()&&this.expressionManager.setExpression(b),this.playing=!0,this._startMotion(Q),!0):(U&&(Mr.dispose(U),this.currentAudio=void 0),!1)})}startRandomMotion(t,r){return _r(this,arguments,function*(i,n,{sound:o,volume:h=_n,expression:c,resetExpression:b=!0,crossOrigin:T,onFinish:C,onError:x}={}){const $=this.definitions[i];if($!=null&&$.length){const I=[];for(let B=0;B<$.length;B++)this.motionGroups[i][B]!==null&&!this.state.isActive(i,B)&&I.push(B);if(I.length){const B=I[Math.floor(Math.random()*I.length)];return this.startMotion(i,B,n,{sound:o,volume:h,expression:c,resetExpression:b,crossOrigin:T,onFinish:C,onError:x})}}return!1})}stopSpeaking(){this.currentAudio&&(Mr.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,r){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((i=this.expressionManager)==null||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,Fa.IDLE)),this.updateParameters(t,r)}mouthSync(){return this.currentAnalyzer?Mr.analyze(this.currentAnalyzer):0}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();const r=this;r.definitions=void 0,r.motionGroups=void 0}}const Xm={x:0,y:0,width:0,height:0};class Id extends Xi{constructor(){super(...arguments),bt(this,"focusController",new Um),bt(this,"pose"),bt(this,"physics"),bt(this,"originalWidth",0),bt(this,"originalHeight",0),bt(this,"width",0),bt(this,"height",0),bt(this,"localTransform",new nr),bt(this,"drawingMatrix",new nr),bt(this,"hitAreas",{}),bt(this,"textureFlipY",!1),bt(this,"viewport",[0,0,0,0]),bt(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,r=this.getSize();t.originalWidth=r[0],t.originalHeight=r[1];const i=Object.assign({width:Md,height:Dd},this.getLayout());this.localTransform.scale(i.width/Md,i.height/Dd),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const n=i.x!==void 0&&i.x-i.width/2||i.centerX!==void 0&&i.centerX||i.left!==void 0&&i.left-i.width/2||i.right!==void 0&&i.right+i.width/2||0,o=i.y!==void 0&&i.y-i.height/2||i.centerY!==void 0&&i.centerY||i.top!==void 0&&i.top-i.height/2||i.bottom!==void 0&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*n,-this.height*o)}setupHitAreas(){const t=this.getHitAreaDefs().filter(r=>r.index>=0);for(const r of t)this.hitAreas[r.name]=r}hitTest(t,r){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,r))}isHit(t,r,i){if(!this.hitAreas[t])return!1;const n=this.hitAreas[t].index,o=this.getDrawableBounds(n,Xm);return o.x<=r&&r<=o.x+o.width&&o.y<=i&&i<=o.y+o.height}getDrawableBounds(t,r){const i=this.getDrawableVertices(t);let n=i[0],o=i[0],h=i[1],c=i[1];for(let b=0;b<i.length;b+=2){const T=i[b],C=i[b+1];n=Math.min(T,n),o=Math.max(T,o),h=Math.min(C,h),c=Math.max(C,c)}return r??(r={}),r.x=n,r.y=h,r.width=o-n,r.height=c-h,r}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,r){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0}}const zm="XHRLoader";class Fd extends Error{constructor(t,r,i,n=!1){super(t),this.url=r,this.status=i,this.aborted=n}}const po=class ei{static createXHR(t,r,i,n,o){const h=new XMLHttpRequest;if(ei.allXhrSet.add(h),t){let c=ei.xhrMap.get(t);c?c.add(h):(c=new Set([h]),ei.xhrMap.set(t,c)),t.listeners("destroy").includes(ei.cancelXHRs)||t.once("destroy",ei.cancelXHRs)}return h.open("GET",r),h.responseType=i,h.onload=()=>{(h.status===200||h.status===0)&&h.response?n(h.response):h.onerror()},h.onerror=()=>{or.warn(zm,`Failed to load resource as ${h.responseType} (Status ${h.status}): ${r}`),o(new Fd("Network error.",r,h.status))},h.onabort=()=>o(new Fd("Aborted.",r,h.status,!0)),h.onloadend=()=>{var c;ei.allXhrSet.delete(h),t&&((c=ei.xhrMap.get(t))==null||c.delete(h))},h}static cancelXHRs(){var t;(t=ei.xhrMap.get(this))==null||t.forEach(r=>{r.abort(),ei.allXhrSet.delete(r)}),ei.xhrMap.delete(this)}static release(){ei.allXhrSet.forEach(t=>t.abort()),ei.allXhrSet.clear(),ei.xhrMap=new WeakMap}};bt(po,"xhrMap",new WeakMap),bt(po,"allXhrSet",new Set),bt(po,"loader",(s,t)=>new Promise((r,i)=>{po.createXHR(s.target,s.settings?s.settings.resolveURL(s.url):s.url,s.type,o=>{s.result=o,r()},i).send()}));let Wm=po;function Ld(s,t){let r=-1;return i(0);function i(n,o){if(o)return Promise.reject(o);if(n<=r)return Promise.reject(new Error("next() called multiple times"));r=n;const h=s[n];if(!h)return Promise.resolve();try{return Promise.resolve(h(t,i.bind(null,n+1)))}catch(c){return Promise.reject(c)}}}class $s{static load(t){return Ld(this.middlewares,t).then(()=>t.result)}}bt($s,"middlewares",[Wm.loader]);function Hm(s,t={}){var r;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(ne.fromURL)return ne.fromURL(s,i).catch(h=>{if(h instanceof Error)throw h;const c=new Error("Texture loading error");throw c.event=h,c});i.resourceOptions.autoLoad=!1;const n=ne.from(s,i);if(n.baseTexture.valid)return Promise.resolve(n);const o=n.baseTexture.resource;return(r=o._live2d_load)!=null||(o._live2d_load=new Promise((h,c)=>{const b=T=>{o.source.removeEventListener("error",b);const C=new Error("Texture loading error");C.event=T,c(C)};o.source.addEventListener("error",b),o.load().then(()=>h(n)).catch(b)})),o._live2d_load}function Ym(){}const kd="Live2DFactory",Bd=(s,t)=>_r(void 0,null,function*(){if(typeof s.source=="string"){const r=yield $s.load({url:s.source,type:"json",target:s.live2dModel});r.url=s.source,s.source=r,s.live2dModel.emit("settingsJSONLoaded",r)}return t()}),Od=(s,t)=>_r(void 0,null,function*(){if(s.source instanceof Ia)return s.settings=s.source,t();if(typeof s.source=="object"){const r=oi.findRuntime(s.source);if(r){const i=r.createModelSettings(s.source);return s.settings=i,s.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),Nd=(s,t)=>{if(s.settings){const r=oi.findRuntime(s.settings);if(r)return r.ready().then(t)}return t()},Ud=(s,t)=>_r(void 0,null,function*(){yield t();const r=s.internalModel;if(r){const i=s.settings,n=oi.findRuntime(i);if(n){const o=[];i.pose&&o.push($s.load({settings:i,url:i.pose,type:"json",target:r}).then(h=>{r.pose=n.createPose(r.coreModel,h),s.live2dModel.emit("poseLoaded",r.pose)}).catch(h=>{s.live2dModel.emit("poseLoadError",h),or.warn(kd,"Failed to load pose.",h)})),i.physics&&o.push($s.load({settings:i,url:i.physics,type:"json",target:r}).then(h=>{r.physics=n.createPhysics(r.coreModel,h),s.live2dModel.emit("physicsLoaded",r.physics)}).catch(h=>{s.live2dModel.emit("physicsLoadError",h),or.warn(kd,"Failed to load physics.",h)})),o.length&&(yield Promise.all(o))}}}),Gd=(s,t)=>_r(void 0,null,function*(){if(s.settings){const r=s.live2dModel,i=Promise.all(s.settings.textures.map(n=>{const o=s.settings.resolveURL(n);return Hm(o,{crossOrigin:s.options.crossOrigin})}));if(i.catch(Ym),yield t(),s.internalModel)r.internalModel=s.internalModel,r.emit("modelLoaded",s.internalModel);else throw new TypeError("Missing internal model.");r.textures=yield i,r.emit("textureLoaded",r.textures)}else throw new TypeError("Missing settings.")}),Vd=(s,t)=>_r(void 0,null,function*(){const r=s.settings;if(r instanceof Ia){const i=oi.findRuntime(r);if(!i)throw new TypeError("Unknown model settings.");const n=yield $s.load({settings:r,url:r.moc,type:"arraybuffer",target:s.live2dModel});if(!i.isValidMoc(n))throw new Error("Invalid moc data");const o=i.createCoreModel(n);return s.internalModel=i.createInternalModel(o,r,s.options),t()}throw new TypeError("Missing settings.")}),zr=class Cn{static unzip(t,r){return _r(this,null,function*(){const i=yield Cn.getFilePaths(t),n=[];for(const h of r.getDefinedFiles()){const c=decodeURI(No.resolve(r.url,h));i.includes(c)&&n.push(c)}const o=yield Cn.getFiles(t,n);for(let h=0;h<o.length;h++){const c=n[h],b=o[h];Object.defineProperty(b,"webkitRelativePath",{value:c})}return o})}static createSettings(t){return _r(this,null,function*(){const i=(yield Cn.getFilePaths(t)).find(c=>c.endsWith("model.json")||c.endsWith("model3.json"));if(!i)throw new Error("Settings file not found");const n=yield Cn.readText(t,i);if(!n)throw new Error("Empty settings file: "+i);const o=JSON.parse(n);o.url=i;const h=Cn.live2dFactory.findRuntime(o);if(!h)throw new Error("Unknown settings JSON");return h.createModelSettings(o)})}static zipReader(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(t){return _r(this,null,function*(){throw new Error("Not implemented")})}static getFiles(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static readText(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(t){}};bt(zr,"live2dFactory"),bt(zr,"ZIP_PROTOCOL","zip://"),bt(zr,"uid",0),bt(zr,"factory",(s,t)=>_r(zr,null,function*(){const r=s.source;let i,n,o;if(typeof r=="string"&&(r.endsWith(".zip")||r.startsWith(zr.ZIP_PROTOCOL))?(r.startsWith(zr.ZIP_PROTOCOL)?i=r.slice(zr.ZIP_PROTOCOL.length):i=r,n=yield $s.load({url:i,type:"blob",target:s.live2dModel})):Array.isArray(r)&&r.length===1&&r[0]instanceof File&&r[0].name.endsWith(".zip")&&(n=r[0],i=URL.createObjectURL(n),o=r.settings),n){if(!n.size)throw new Error("Empty zip file");const h=yield zr.zipReader(n,i);o||(o=yield zr.createSettings(h)),o._objectURL=zr.ZIP_PROTOCOL+zr.uid+"/"+o.url;const c=yield zr.unzip(h,o);c.settings=o,s.source=c,i.startsWith("blob:")&&s.live2dModel.once("modelLoaded",b=>{b.once("destroy",function(){URL.revokeObjectURL(i)})}),zr.releaseReader(h)}return t()}));let Xd=zr;const Ri=class Ya{static resolveURL(t,r){var i;const n=(i=Ya.filesMap[t])==null?void 0:i[r];if(n===void 0)throw new Error("Cannot find this file from uploaded files: "+r);return n}static upload(t,r){return _r(this,null,function*(){const i={};for(const n of r.getDefinedFiles()){const o=decodeURI(No.resolve(r.url,n)),h=t.find(c=>c.webkitRelativePath===o);h&&(i[n]=URL.createObjectURL(h))}Ya.filesMap[r._objectURL]=i})}static createSettings(t){return _r(this,null,function*(){const r=t.find(c=>c.name.endsWith("model.json")||c.name.endsWith("model3.json"));if(!r)throw new TypeError("Settings file not found");const i=yield Ya.readText(r),n=JSON.parse(i);n.url=r.webkitRelativePath;const o=oi.findRuntime(n);if(!o)throw new Error("Unknown settings JSON");const h=o.createModelSettings(n);return h._objectURL=URL.createObjectURL(r),h})}static readText(t){return _r(this,null,function*(){return new Promise((r,i)=>{const n=new FileReader;n.onload=()=>r(n.result),n.onerror=i,n.readAsText(t,"utf8")})})}};bt(Ri,"live2dFactory"),bt(Ri,"filesMap",{}),bt(Ri,"factory",(s,t)=>_r(Ri,null,function*(){if(Array.isArray(s.source)&&s.source[0]instanceof File){const r=s.source;let i=r.settings;if(!i)i=yield Ri.createSettings(r);else if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');i.validateFiles(r.map(n=>encodeURI(n.webkitRelativePath))),yield Ri.upload(r,i),i.resolveURL=function(n){return Ri.resolveURL(this._objectURL,n)},s.source=i,s.live2dModel.once("modelLoaded",n=>{n.once("destroy",function(){const o=this.settings._objectURL;if(URL.revokeObjectURL(o),Ri.filesMap[o])for(const h of Object.values(Ri.filesMap[o]))URL.revokeObjectURL(h);delete Ri.filesMap[o]})})}return t()}));let zd=Ri;const Ii=class Ur{static registerRuntime(t){Ur.runtimes.push(t),Ur.runtimes.sort((r,i)=>i.version-r.version)}static findRuntime(t){for(const r of Ur.runtimes)if(r.test(t))return r}static setupLive2DModel(t,r,i){return _r(this,null,function*(){const n=new Promise(c=>t.once("textureLoaded",c)),o=new Promise(c=>t.once("modelLoaded",c)),h=Promise.all([n,o]).then(()=>t.emit("ready"));yield Ld(Ur.live2DModelMiddlewares,{live2dModel:t,source:r,options:i||{}}),yield h,t.emit("load")})}static loadMotion(t,r,i){var n,o;const h=c=>t.emit("motionLoadError",r,i,c);try{const c=(n=t.definitions[r])==null?void 0:n[i];if(!c)return Promise.resolve(void 0);t.listeners("destroy").includes(Ur.releaseTasks)||t.once("destroy",Ur.releaseTasks);let b=Ur.motionTasksMap.get(t);b||(b={},Ur.motionTasksMap.set(t,b));let T=b[r];T||(T=[],b[r]=T);const C=t.getMotionFile(c);return(o=T[i])!=null||(T[i]=$s.load({url:C,settings:t.settings,type:t.motionDataType,target:t}).then(x=>{var $;const I=($=Ur.motionTasksMap.get(t))==null?void 0:$[r];I&&delete I[i];const B=t.createMotion(x,r,c);return t.emit("motionLoaded",r,i,B),B}).catch(x=>{or.warn(t.tag,`Failed to load motion: ${C}
1193
- `,x),h(x)})),T[i]}catch(c){or.warn(t.tag,`Failed to load motion at "${r}"[${i}]
1194
- `,c),h(c)}return Promise.resolve(void 0)}static loadExpression(t,r){var i;const n=o=>t.emit("expressionLoadError",r,o);try{const o=t.definitions[r];if(!o)return Promise.resolve(void 0);t.listeners("destroy").includes(Ur.releaseTasks)||t.once("destroy",Ur.releaseTasks);let h=Ur.expressionTasksMap.get(t);h||(h=[],Ur.expressionTasksMap.set(t,h));const c=t.getExpressionFile(o);return(i=h[r])!=null||(h[r]=$s.load({url:c,settings:t.settings,type:"json",target:t}).then(b=>{const T=Ur.expressionTasksMap.get(t);T&&delete T[r];const C=t.createExpression(b,o);return t.emit("expressionLoaded",r,C),C}).catch(b=>{or.warn(t.tag,`Failed to load expression: ${c}
1195
- `,b),n(b)})),h[r]}catch(o){or.warn(t.tag,`Failed to load expression at [${r}]
1196
- `,o),n(o)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof fo?Ur.motionTasksMap.delete(this):Ur.expressionTasksMap.delete(this)}};bt(Ii,"runtimes",[]),bt(Ii,"urlToJSON",Bd),bt(Ii,"jsonToSettings",Od),bt(Ii,"waitUntilReady",Nd),bt(Ii,"setupOptionals",Ud),bt(Ii,"setupEssentials",Gd),bt(Ii,"createInternalModel",Vd),bt(Ii,"live2DModelMiddlewares",[Xd.factory,zd.factory,Bd,Od,Nd,Ud,Gd,Vd]),bt(Ii,"motionTasksMap",new WeakMap),bt(Ii,"expressionTasksMap",new WeakMap);let oi=Ii;fo.prototype._loadMotion=function(s,t){return oi.loadMotion(this,s,t)},pu.prototype._loadExpression=function(s){return oi.loadExpression(this,s)},zd.live2dFactory=oi,Xd.live2dFactory=oi;const Wd=class Bu{constructor(t,{autoUpdate:r=!0,autoHitTest:i=!0,autoFocus:n=!0,autoInteract:o,ticker:h}={}){bt(this,"model"),bt(this,"destroyed",!1),bt(this,"_ticker"),bt(this,"_autoUpdate",!1),bt(this,"_autoHitTest",!1),bt(this,"_autoFocus",!1),h||(Bu.defaultTicker?h=Bu.defaultTicker:typeof PIXI<"u"&&(h=PIXI.Ticker.shared)),o!==void 0&&(i=o,n=o,or.warn(t.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=t,this.ticker=h,this.autoUpdate=r,this.autoHitTest=i,this.autoFocus=n,(i||n)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var r;this._ticker&&this._ticker.remove(La,this),this._ticker=t,this._autoUpdate&&((r=this._ticker)==null||r.add(La,this))}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var r;this.destroyed||(t?this._ticker?(this._ticker.add(La,this),this._autoUpdate=!0):or.warn(this.model.tag,"No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI)."):((r=this._ticker)==null||r.remove(La,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",Yd,this):this.model.off("pointertap",Yd,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?this.model.on("globalpointermove",jd,this):this.model.off("globalpointermove",jd,this),this._autoFocus=t)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(t){this.autoHitTest=t,this.autoFocus=t}onTickerUpdate(){const t=this.ticker.deltaMS;this.model.update(t)}onTap(t){this.model.tap(t.global.x,t.global.y)}onPointerMove(t){this.model.focus(t.global.x,t.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};bt(Wd,"defaultTicker");let Hd=Wd;function La(){this.onTickerUpdate()}function Yd(s){this.onTap(s)}function jd(s){this.onPointerMove(s)}class jm extends rn{}const gi=new He,qm=new nr;class _u extends Zr{constructor(t){super(),bt(this,"tag","Live2DModel(uninitialized)"),bt(this,"internalModel"),bt(this,"textures",[]),bt(this,"transform",new jm),bt(this,"anchor",new $i(this.onAnchorChange,this,0,0)),bt(this,"glContextID",-1),bt(this,"elapsedTime",0),bt(this,"deltaTime",0),bt(this,"automator"),this.automator=new Hd(this,t),this.once("modelLoaded",()=>this.init(t))}static from(t,r){const i=new this(r);return oi.setupLive2DModel(i,t,r).then(()=>i)}static fromSync(t,r){const i=new this(r);return oi.setupLive2DModel(i,t,r).then(r==null?void 0:r.onLoad).catch(r==null?void 0:r.onError),i}static registerTicker(t){Hd.defaultTicker=t.shared}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,r,i,{sound:n=void 0,volume:o=_n,expression:h=void 0,resetExpression:c=!0,crossOrigin:b,onFinish:T,onError:C}={}){return r===void 0?this.internalModel.motionManager.startRandomMotion(t,i,{sound:n,volume:o,expression:h,resetExpression:c,crossOrigin:b,onFinish:T,onError:C}):this.internalModel.motionManager.startMotion(t,r,i,{sound:n,volume:o,expression:h,resetExpression:c,crossOrigin:b,onFinish:T,onError:C})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:r=_n,expression:i,resetExpression:n=!0,crossOrigin:o,onFinish:h,onError:c}={}){return this.internalModel.motionManager.speak(t,{volume:r,expression:i,resetExpression:n,crossOrigin:o,onFinish:h,onError:c})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,r,i=!1){gi.x=t,gi.y=r,this.toModelPosition(gi,gi,!0);const n=gi.x/this.internalModel.originalWidth*2-1,o=gi.y/this.internalModel.originalHeight*2-1,h=Math.atan2(o,n);this.internalModel.focusController.focus(Math.cos(h),-Math.sin(h),i)}tap(t,r){const i=this.hitTest(t,r);i.length&&(or.log(this.tag,"Hit",i),this.emit("hit",i))}hitTest(t,r){return gi.x=t,gi.y=r,this.toModelPosition(gi,gi),this.internalModel.hitTest(gi.x,gi.y)}toModelPosition(t,r=t.clone(),i){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,r),this.internalModel.localTransform.applyInverse(r,r),r}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let r=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),r=!0);for(let o=0;o<this.textures.length;o++){const h=this.textures[o];h.valid&&((r||!h.baseTexture._glTextures[this.glContextID])&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(h.baseTexture,0)),this.internalModel.bindTexture(o,h.baseTexture._glTextures[this.glContextID].texture),h.baseTexture.touched=t.textureGC.count)}const i=t.framebuffer.viewport;this.internalModel.viewport=[i.x,i.y,i.width,i.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const n=qm.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(n),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),t!=null&&t.texture&&this.textures.forEach(r=>r.destroy(t.baseTexture)),this.automator.destroy(),this.internalModel.destroy(),super.destroy(t)}}if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const Zm=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(s,t){Zm.call(this,s,t),t.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class Qm extends AMotion{constructor(t){super(),bt(this,"params",[]),this.setFadeIn(t.fade_in>0?t.fade_in:dn.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:dn.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach(r=>{const i=r.calc||"add";if(i==="add"){const n=r.def||0;r.val-=n}else if(i==="mult"){const n=r.def||1;r.val/=n}this.params.push({calc:i,val:r.val,id:r.id})})}updateParamExe(t,r,i,n){this.params.forEach(o=>{t.setParamFloat(o.id,o.val*i)})}}class Km extends pu{constructor(t,r){var i;super(t,r),bt(this,"queueManager",new MotionQueueManager),bt(this,"definitions"),this.definitions=(i=this.settings.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(r=>r.name===t)}getExpressionFile(t){return t.file}createExpression(t,r){return new Qm(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.updateParam(t)}}class Jm extends fo{constructor(t,r){super(t,r),bt(this,"definitions"),bt(this,"groups",{idle:"idle"}),bt(this,"motionDataType","arraybuffer"),bt(this,"queueManager",new MotionQueueManager),bt(this,"lipSyncIds"),bt(this,"expressionManager"),this.definitions=this.settings.motions,this.init(r),this.lipSyncIds=["PARAM_MOUTH_OPEN_Y"]}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Km(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,r,i){const n=Live2DMotion.loadMotion(t),o=r===this.groups.idle?dn.idleMotionFadingDuration:dn.motionFadingDuration;return n.setFadeIn(i.fade_in>0?i.fade_in:o),n.setFadeOut(i.fade_out>0?i.fade_out:o),n}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,r){return t.onFinishHandler=r,this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}}class t1{constructor(t){bt(this,"leftParam"),bt(this,"rightParam"),bt(this,"blinkInterval",4e3),bt(this,"closingDuration",100),bt(this,"closedDuration",50),bt(this,"openingDuration",150),bt(this,"eyeState",0),bt(this,"eyeParamValue",1),bt(this,"closedTimer",0),bt(this,"nextBlinkTimeLeft",this.blinkInterval),this.coreModel=t,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN")}setEyeParams(t){this.eyeParamValue=pn(t,0,1),this.coreModel.setParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.setParamFloat(this.rightParam,this.eyeParamValue)}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.nextBlinkTimeLeft=this.blinkInterval+this.closingDuration+this.closedDuration+this.openingDuration+Fm(0,2e3));break;case 1:this.setEyeParams(this.eyeParamValue+t/this.closingDuration),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0);break;case 2:this.closedTimer+=t,this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.setEyeParams(this.eyeParamValue+t/this.openingDuration),this.eyeParamValue>=1&&(this.eyeState=0)}}}const js=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class e1 extends Id{constructor(t,r,i){super(),bt(this,"settings"),bt(this,"coreModel"),bt(this,"motionManager"),bt(this,"eyeBlink"),bt(this,"eyeballXParamIndex"),bt(this,"eyeballYParamIndex"),bt(this,"angleXParamIndex"),bt(this,"angleYParamIndex"),bt(this,"angleZParamIndex"),bt(this,"bodyAngleXParamIndex"),bt(this,"breathParamIndex"),bt(this,"textureFlipY",!0),bt(this,"lipSync",!0),bt(this,"drawDataCount",0),bt(this,"disableCulling",!1),bt(this,"hasDrawn",!1),this.coreModel=t,this.settings=r,this.motionManager=new Jm(r,i),this.eyeBlink=new t1(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach(({id:o,value:h})=>this.coreModel.setParamFloat(o,h)),this.settings.initOpacities&&this.settings.initOpacities.forEach(({id:o,value:h})=>this.coreModel.setPartsOpacity(o,h)),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;t!=null&&t.length&&(this.drawDataCount=t.length);let r=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:o=>r=o,get:()=>this.disableCulling?!1:r});const i=this.coreModel.getModelContext().clipManager,n=i.setupClip;i.setupClip=(o,h)=>{n.call(i,o,h),h.gl.viewport(...this.viewport)}}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const[r,i]of Object.entries(this.settings.layout)){let n=r;r==="center_x"?n="centerX":r==="center_y"&&(n="centerY"),t[n]=i}return t}updateWebGLContext(t,r){const i=this.coreModel.drawParamWebGL;i.firstDraw=!0,i.setGL(t),i.glno=r;for(const[h,c]of Object.entries(i))c instanceof WebGLBuffer&&(i[h]=null);const n=this.coreModel.getModelContext().clipManager;n.curFrameNo=r;const o=t.getParameter(t.FRAMEBUFFER_BINDING);n.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,o)}bindTexture(t,r){this.coreModel.setTexture(t,r)}getHitAreaDefs(){var t;return((t=this.settings.hitAreas)==null?void 0:t.map(r=>({id:r.id,name:r.name,index:this.coreModel.getDrawDataIndex(r.id)})))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),r=[];for(let i=0;i<this.drawDataCount;i++){const n=t.getDrawData(i);n&&r.push(n.getDrawDataID().id)}return r}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawDataIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}hitTest(t,r){return this.hasDrawn||or.warn("Trying to hit-test a Cubism 2 model that has not been rendered yet. The result will always be empty since the draw data is not ready."),super.hitTest(t,r)}update(t,r){var i,n,o,h;super.update(t,r);const c=this.coreModel;this.emit("beforeMotionUpdate");const b=this.motionManager.update(this.coreModel,r);if(this.emit("afterMotionUpdate"),c.saveParam(),(i=this.motionManager.expressionManager)==null||i.update(c,r),b||(n=this.eyeBlink)==null||n.update(t),this.updateFocus(),this.updateNaturalMovements(t,r),this.lipSync&&this.motionManager.currentAudio){let T=this.motionManager.mouthSync(),C=0;const x=1,$=1.2,I=.7;T>0&&(C=.4),T=Math.pow(T,I),T=pn(T*$,C,x);for(let B=0;B<this.motionManager.lipSyncIds.length;++B)this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[B]),T)}(o=this.physics)==null||o.update(r),(h=this.pose)==null||h.update(t),this.emit("beforeModelUpdate"),c.update(),c.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,this.focusController.x*30),this.coreModel.addToParamFloat(this.angleYParamIndex,this.focusController.y*30),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,this.focusController.x*10)}updateNaturalMovements(t,r){const i=r/1e3*2*Math.PI;this.coreModel.addToParamFloat(this.angleXParamIndex,15*Math.sin(i/6.5345)*.5),this.coreModel.addToParamFloat(this.angleYParamIndex,8*Math.sin(i/3.5345)*.5),this.coreModel.addToParamFloat(this.angleZParamIndex,10*Math.sin(i/5.5345)*.5),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,4*Math.sin(i/15.5345)*.5),this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(i/3.2345))}draw(t){const r=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const i=this.drawingMatrix;js[0]=i.a,js[1]=i.b,js[4]=i.c,js[5]=i.d,js[12]=i.tx,js[13]=i.ty,this.coreModel.setMatrix(js),this.coreModel.draw(),this.hasDrawn=!0,this.disableCulling=r}destroy(){super.destroy(),this.coreModel=void 0}}class _o extends Ia{constructor(t){if(super(t),bt(this,"moc"),bt(this,"textures"),bt(this,"layout"),bt(this,"hitAreas"),bt(this,"initParams"),bt(this,"initOpacities"),bt(this,"expressions"),bt(this,"motions",{}),!_o.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,co("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var r;return!!t&&typeof t.model=="string"&&((r=t.textures)==null?void 0:r.length)>0&&t.textures.every(i=>typeof i=="string")}copy(t){uo("string",t,this,"name","name"),uo("string",t,this,"pose","pose"),uo("string",t,this,"physics","physics"),uo("object",t,this,"layout","layout"),uo("object",t,this,"motions","motions"),co("object",t,this,"hit_areas","hitAreas"),co("object",t,this,"expressions","expressions"),co("object",t,this,"init_params","initParams"),co("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[r,i]of Object.entries(this.motions))for(let n=0;n<i.length;n++)i[n].file=t(i[n].file,`motions.${r}[${n}].file`),i[n].sound!==void 0&&(i[n].sound=t(i[n].sound,`motions.${r}[${n}].sound`));if(this.expressions)for(let r=0;r<this.expressions.length;r++)this.expressions[r].file=t(this.expressions[r].file,`expressions[${r}].file`)}}const r1={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},i1={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class s1{constructor(t,r){bt(this,"physicsHairs",[]),this.coreModel=t,r.physics_hair&&(this.physicsHairs=r.physics_hair.map(i=>{const n=new PhysicsHair;return n.setup(i.setup.length,i.setup.regist,i.setup.mass),i.src.forEach(({id:o,ptype:h,scale:c,weight:b})=>{const T=r1[h];T&&n.addSrcParam(T,o,c,b)}),i.targets.forEach(({id:o,ptype:h,scale:c,weight:b})=>{const T=i1[h];T&&n.addTargetParam(T,o,c,b)}),n}))}update(t){this.physicsHairs.forEach(r=>r.update(this.coreModel,t))}}class qd{constructor(t){bt(this,"paramIndex",-1),bt(this,"partsIndex",-1),bt(this,"link",[]),this.id=t}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class n1{constructor(t,r){bt(this,"opacityAnimDuration",500),bt(this,"partsGroups",[]),this.coreModel=t,r.parts_visible&&(this.partsGroups=r.parts_visible.map(({group:i})=>i.map(({id:n,link:o})=>{const h=new qd(n);return o&&(h.link=o.map(c=>new qd(c))),h})),this.init())}init(){this.partsGroups.forEach(t=>{t.forEach(r=>{if(r.initIndex(this.coreModel),r.paramIndex>=0){const i=this.coreModel.getParamFloat(r.paramIndex)!==0;this.coreModel.setPartsOpacity(r.partsIndex,i?1:0),this.coreModel.setParamFloat(r.paramIndex,i?1:0),r.link.length>0&&r.link.forEach(n=>n.initIndex(this.coreModel))}})})}normalizePartsOpacityGroup(t,r){const i=this.coreModel,n=.5,o=.15;let h=1,c=t.findIndex(({paramIndex:b,partsIndex:T})=>T>=0&&i.getParamFloat(b)!==0);if(c>=0){const b=i.getPartsOpacity(t[c].partsIndex);h=pn(b+r/this.opacityAnimDuration,0,1)}else c=0,h=1;t.forEach(({partsIndex:b},T)=>{if(b>=0)if(c==T)i.setPartsOpacity(b,h);else{let C=i.getPartsOpacity(b),x;h<n?x=h*(n-1)/n+1:x=(1-h)*n/(1-n),(1-x)*(1-h)>o&&(x=1-o/(1-h)),C>x&&(C=x),i.setPartsOpacity(b,C)}})}copyOpacity(t){const r=this.coreModel;t.forEach(({partsIndex:i,link:n})=>{if(i>=0&&n){const o=r.getPartsOpacity(i);n.forEach(({partsIndex:h})=>{h>=0&&r.setPartsOpacity(h,o)})}})}update(t){this.partsGroups.forEach(r=>{this.normalizePartsOpacityGroup(r,t),this.copyOpacity(r)})}}if(oi.registerRuntime({version:2,test(s){return s instanceof _o||_o.isValidJSON(s)},ready(){return Promise.resolve()},isValidMoc(s){if(s.byteLength<3)return!1;const t=new Int8Array(s,0,3);return String.fromCharCode(...t)==="moc"},createModelSettings(s){return new _o(s)},createCoreModel(s){const t=Live2DModelWebGL.loadModel(s),r=Live2D.getError();if(r)throw r;return t},createInternalModel(s,t,r){return new e1(s,t,r)},createPose(s,t){return new n1(s,t)},createPhysics(s,t){return new s1(s,t)}}),!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class Re{constructor(t,r){this.x=t||0,this.y=r||0}add(t){const r=new Re(0,0);return r.x=this.x+t.x,r.y=this.y+t.y,r}substract(t){const r=new Re(0,0);return r.x=this.x-t.x,r.y=this.y-t.y,r}multiply(t){const r=new Re(0,0);return r.x=this.x*t.x,r.y=this.y*t.y,r}multiplyByScaler(t){return this.multiply(new Re(t,t))}division(t){const r=new Re(0,0);return r.x=this.x/t.x,r.y=this.y/t.y,r}divisionByScalar(t){return this.division(new Re(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}const Zd=class ja{static range(t,r,i){return t<r?t=r:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(t===0)return t;let r=t;const i=r<0;i&&(r=-r);let n;return r===1/0?n=1/0:(n=Math.exp(Math.log(r)/3),n=(r/(n*n)+2*n)/3),i?-n:n}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,r){return t>r?t:r}static min(t,r){return t>r?r:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return t*180/Math.PI}static directionToRadian(t,r){const i=Math.atan2(r.y,r.x),n=Math.atan2(t.y,t.x);let o=i-n;for(;o<-Math.PI;)o+=Math.PI*2;for(;o>Math.PI;)o-=Math.PI*2;return o}static directionToDegrees(t,r){const i=this.directionToRadian(t,r);let n=this.radianToDegrees(i);return r.x-t.x>0&&(n=-n),n}static radianToDirection(t){const r=new Re;return r.x=this.sin(t),r.y=this.cos(t),r}static quadraticEquation(t,r,i){return this.abs(t)<ja.Epsilon?this.abs(r)<ja.Epsilon?-i:-i/r:-(r+this.sqrt(r*r-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,r,i,n){if(this.sqrt(t)<ja.Epsilon)return this.range(this.quadraticEquation(r,i,n),0,1);const o=r/t,h=i/t,c=n/t,b=(3*h-o*o)/3,T=b/3,C=(2*o*o*o-9*o*h+27*c)/27,x=C/2,$=x*x+T*T*T,I=.5,B=I+.01;if($<0){const Z=-b/3,it=Z*Z*Z,Q=this.sqrt(it),_t=-C/(2*Q),et=this.range(_t,-1,1),ft=Math.acos(et),Dt=2*this.cbrt(Q),Rt=Dt*this.cos(ft/3)-o/3;if(this.abs(Rt-I)<B)return this.range(Rt,0,1);const pt=Dt*this.cos((ft+2*Math.PI)/3)-o/3;if(this.abs(pt-I)<B)return this.range(pt,0,1);const xt=Dt*this.cos((ft+4*Math.PI)/3)-o/3;return this.range(xt,0,1)}if($==0){let Z;x<0?Z=this.cbrt(-x):Z=-this.cbrt(x);const it=2*Z-o/3;if(this.abs(it-I)<B)return this.range(it,0,1);const Q=-Z-o/3;return this.range(Q,0,1)}const U=this.sqrt($),G=this.cbrt(U-x),z=this.cbrt(U+x),J=G-z-o/3;return this.range(J,0,1)}constructor(){}};Zd.Epsilon=1e-5;let Ke=Zd;class mi{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,r,i){const n=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=4;for(let h=0;h<o;++h)for(let c=0;c<o;++c)for(let b=0;b<o;++b)n[c+h*4]+=t[b+h*4]*r[c+b*4];for(let h=0;h<16;++h)i[h]=n[h]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let r=0;r<16;++r)this._tr[r]=t[r]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,r){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,r,0,1]);mi.multiply(i,this._tr,this._tr)}translate(t,r){this._tr[12]=t,this._tr[13]=r}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,r){const i=new Float32Array([t,0,0,0,0,r,0,0,0,0,1,0,0,0,0,1]);mi.multiply(i,this._tr,this._tr)}scale(t,r){this._tr[0]=t,this._tr[5]=r}multiplyByMatrix(t){mi.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new mi;for(let r=0;r<this._tr.length;r++)t._tr[r]=this._tr[r];return t}}class gu{initialize(t){this._model=t}drawModel(){this.getModel()!=null&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,r,i,n){t<0?t=0:t>1&&(t=1),r<0?r=0:r>1&&(r=1),i<0?i=0:i>1&&(i=1),n<0?n=0:n>1&&(n=1),this._modelColor.R=t,this._modelColor.G=r,this._modelColor.B=i,this._modelColor.A=n}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._modelColor=new ai,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new mi,this._mvpMatrix4x4.loadIdentity()}}var gs=(s=>(s[s.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",s[s.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",s[s.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",s))(gs||{});class ai{constructor(t=1,r=1,i=1,n=1){this.R=t,this.G=r,this.B=i,this.A=n}}let Qi=!1,gn=!1,mn;const mu={vertexOffset:0,vertexStep:2};class go{static startUp(t){if(Qi)return mo("CubismFramework.startUp() is already done."),Qi;if(Live2DCubismCore._isStarted)return Qi=!0,!0;if(Live2DCubismCore._isStarted=!0,mn=t,mn&&Live2DCubismCore.Logging.csmSetLogFunction(mn.logFunction),Qi=!0,Qi){const r=Live2DCubismCore.Version.csmGetVersion(),i=(r&4278190080)>>24,n=(r&16711680)>>16,o=r&65535,h=r;mo("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+n).slice(-2),("0000"+o).slice(-4),h)}return mo("CubismFramework.startUp() is complete."),Qi}static cleanUp(){Qi=!1,gn=!1,mn=void 0}static initialize(t=0){if(!Qi){qs("CubismFramework is not started.");return}if(gn){qs("CubismFramework.initialize() skipped, already initialized.");return}Live2DCubismCore.Memory.initializeAmountOfMemory(t),gn=!0,mo("CubismFramework.initialize() is complete.")}static dispose(){if(!Qi){qs("CubismFramework is not started.");return}if(!gn){qs("CubismFramework.dispose() skipped, not initialized.");return}gu.staticRelease(),gn=!1,mo("CubismFramework.dispose() is complete.")}static isStarted(){return Qi}static isInitialized(){return gn}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return mn!=null?mn.loggingLevel:5}constructor(){}}var yn=(s=>(s[s.LogLevel_Verbose=0]="LogLevel_Verbose",s[s.LogLevel_Debug=1]="LogLevel_Debug",s[s.LogLevel_Info=2]="LogLevel_Info",s[s.LogLevel_Warning=3]="LogLevel_Warning",s[s.LogLevel_Error=4]="LogLevel_Error",s[s.LogLevel_Off=5]="LogLevel_Off",s))(yn||{});const vn=typeof process<"u"&&process.env.NODE_ENV==="production"?()=>{}:s=>console.assert(s);function Qd(s,...t){ka.print(yn.LogLevel_Debug,"[CSM][D]"+s+`
1197
- `,t)}function mo(s,...t){ka.print(yn.LogLevel_Info,"[CSM][I]"+s+`
1198
- `,t)}function qs(s,...t){ka.print(yn.LogLevel_Warning,"[CSM][W]"+s+`
1199
- `,t)}function Ki(s,...t){ka.print(yn.LogLevel_Error,"[CSM][E]"+s+`
1200
- `,t)}class ka{static print(t,r,i){if(t<go.getLoggingLevel())return;const n=go.coreLogFunction;if(!n)return;const o=r.replace(/{(\d+)}/g,(h,c)=>i[c]);n(o)}static dumpBytes(t,r,i){for(let n=0;n<i;n++)n%16==0&&n>0?this.print(t,`
1201
- `):n%8==0&&n>0&&this.print(t," "),this.print(t,"{0} ",[r[n]&255]);this.print(t,`
1202
- `)}constructor(){}}class Kd{constructor(){this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._firedEventValues=[]}release(){this._weight=0}updateParameters(t,r,i){if(!r.isAvailable()||r.isFinished())return;if(!r.isStarted()){r.setIsStarted(!0),r.setStartTime(i-this._offsetSeconds),r.setFadeInStartTime(i);const c=this.getDuration();r.getEndTime()<0&&r.setEndTime(c<=0?-1:r.getStartTime()+c)}let n=this._weight;const o=this._fadeInSeconds==0?1:Ke.getEasingSine((i-r.getFadeInStartTime())/this._fadeInSeconds),h=this._fadeOutSeconds==0||r.getEndTime()<0?1:Ke.getEasingSine((r.getEndTime()-i)/this._fadeOutSeconds);n=n*o*h,r.setState(i,n),vn(0<=n&&n<=1),this.doUpdateParameters(t,i,n,r),r.getEndTime()>0&&r.getEndTime()<i&&r.setIsFinished(!0)}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}getFiredEvent(t,r){return this._firedEventValues}setFinishedMotionHandler(t){this._onFinishedMotion=t}getFinishedMotionHandler(){return this._onFinishedMotion}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){}getModelOpacityValue(){return 1}}const Jd=1;class yu extends Kd{static create(t){const r=new yu;return r.parse(t),r}doUpdateParameters(t,r,i,n){for(let o=0;o<this._parameters.length;++o){const h=this._parameters[o];switch(h.blendType){case 0:{t.addParameterValueById(h.parameterId,h.value,i);break}case 1:{t.multiplyParameterValueById(h.parameterId,h.value,i);break}case 2:{t.setParameterValueById(h.parameterId,h.value,i);break}}}}parse(t){this.setFadeInTime(t.FadeInTime!=null?t.FadeInTime:Jd),this.setFadeOutTime(t.FadeOutTime!=null?t.FadeOutTime:Jd);const r=(t.Parameters||[]).length;for(let i=0;i<r;++i){const n=t.Parameters[i],o=n.Id,h=n.Value;let c;!n.Blend||n.Blend==="Add"?c=0:n.Blend==="Multiply"?c=1:n.Blend==="Overwrite"?c=2:c=0;const b={parameterId:o,blendType:c,value:h};this._parameters.push(b)}}constructor(){super(),this._parameters=[]}}class o1{constructor(){this._autoDelete=!1,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&this._motion.release()}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,r){const i=r+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||i<this._endTimeSeconds)&&(this._endTimeSeconds=i)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,r){this._stateTimeSeconds=t,this._stateWeight=r}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}}class t2{constructor(){this._userTimeSeconds=0,this._eventCustomData=null,this._motions=[]}release(){for(let t=0;t<this._motions.length;++t)this._motions[t]&&this._motions[t].release();this._motions=void 0}startMotion(t,r,i){if(t==null)return a1;let n;for(let o=0;o<this._motions.length;++o)n=this._motions[o],n!=null&&n.setFadeOut(n._motion.getFadeOutTime());return n=new o1,n._autoDelete=r,n._motion=t,this._motions.push(n),n._motionQueueEntryHandle}isFinished(){let t=0;for(;t<this._motions.length;){const r=this._motions[t];if(r==null){this._motions.splice(t,1);continue}if(r._motion==null){r.release(),this._motions.splice(t,1);continue}if(!r.isFinished())return!1;t++}return!0}isFinishedByHandle(t){for(let r=0;r<this._motions.length;r++){const i=this._motions[r];if(i!=null&&i._motionQueueEntryHandle==t&&!i.isFinished())return!1}return!0}stopAllMotions(){for(let t=0;t<this._motions.length;t++){const r=this._motions[t];r!=null&&r.release()}this._motions=[]}getCubismMotionQueueEntry(t){return this._motions.find(r=>r!=null&&r._motionQueueEntryHandle==t)}setEventCallback(t,r=null){this._eventCallBack=t,this._eventCustomData=r}doUpdateMotion(t,r){let i=!1,n=0;for(;n<this._motions.length;){const o=this._motions[n];if(o==null){this._motions.splice(n,1);continue}const h=o._motion;if(h==null){o.release(),this._motions.splice(n,1);continue}h.updateParameters(t,o,r),i=!0;const c=h.getFiredEvent(o.getLastCheckEventSeconds()-o.getStartTime(),r-o.getStartTime());for(let b=0;b<c.length;++b)this._eventCallBack(this,c[b],this._eventCustomData);o.setLastCheckEventSeconds(r),o.isFinished()?(o.release(),this._motions.splice(n,1)):(o.isTriggeredFadeOut()&&o.startFadeOut(o.getFadeOutSeconds(),r),n++)}return i}}const a1=-1;class h1 extends pu{constructor(t,r){var i;super(t,r),bt(this,"queueManager",new t2),bt(this,"definitions"),this.definitions=(i=t.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(r=>r.Name===t)}getExpressionFile(t){return t.File}createExpression(t,r){return yu.create(t)}_setExpression(t){return this.queueManager.startMotion(t,!1,performance.now())}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.doUpdateMotion(t,r)}}var Ji=(s=>(s[s.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",s[s.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",s[s.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",s))(Ji||{}),ts=(s=>(s[s.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",s[s.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",s[s.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",s[s.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",s))(ts||{});class Ms{constructor(t=0,r=0){this.time=t,this.value=r}}class l1{constructor(){this.basePointIndex=0,this.segmentType=0}}class u1{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class c1{constructor(){this.fireTime=0,this.value=""}}class f1{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}}class e2{constructor(t){this._json=t}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(t){return t==0?!!this._json.Meta.AreBeziersRestricted:!1}getMotionCurveCount(){return this._json.Meta.CurveCount}getMotionFps(){return this._json.Meta.Fps}getMotionTotalSegmentCount(){return this._json.Meta.TotalSegmentCount}getMotionTotalPointCount(){return this._json.Meta.TotalPointCount}getMotionFadeInTime(){return this._json.Meta.FadeInTime}getMotionFadeOutTime(){return this._json.Meta.FadeOutTime}getMotionCurveTarget(t){return this._json.Curves[t].Target}getMotionCurveId(t){return this._json.Curves[t].Id}getMotionCurveFadeInTime(t){return this._json.Curves[t].FadeInTime}getMotionCurveFadeOutTime(t){return this._json.Curves[t].FadeOutTime}getMotionCurveSegmentCount(t){return this._json.Curves[t].Segments.length}getMotionCurveSegment(t,r){return this._json.Curves[t].Segments[r]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(t){return this._json.UserData[t].Time}getEventValue(t){return this._json.UserData[t].Value}}var r2=(s=>(s[s.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",s))(r2||{});const d1="EyeBlink",p1="LipSync",_1="Model",g1="Parameter",m1="PartOpacity",Ba="Opacity",y1=!1;function yi(s,t,r){const i=new Ms;return i.time=s.time+(t.time-s.time)*r,i.value=s.value+(t.value-s.value)*r,i}function v1(s,t){let r=(t-s[0].time)/(s[1].time-s[0].time);return r<0&&(r=0),s[0].value+(s[1].value-s[0].value)*r}function x1(s,t){let r=(t-s[0].time)/(s[3].time-s[0].time);r<0&&(r=0);const i=yi(s[0],s[1],r),n=yi(s[1],s[2],r),o=yi(s[2],s[3],r),h=yi(i,n,r),c=yi(n,o,r);return yi(h,c,r).value}function b1(s,t){const r=t,i=s[0].time,n=s[3].time,o=s[1].time,h=s[2].time,c=n-3*h+3*o-i,b=3*h-6*o+3*i,T=3*o-3*i,C=i-r,x=Ke.cardanoAlgorithmForBezier(c,b,T,C),$=yi(s[0],s[1],x),I=yi(s[1],s[2],x),B=yi(s[2],s[3],x),U=yi($,I,x),G=yi(I,B,x);return yi(U,G,x).value}function A1(s,t){return s[0].value}function w1(s,t){return s[1].value}function vu(s,t,r){const i=s.curves[t];let n=-1;const o=i.baseSegmentIndex+i.segmentCount;let h=0;for(let b=i.baseSegmentIndex;b<o;++b)if(h=s.segments[b].basePointIndex+(s.segments[b].segmentType==ts.CubismMotionSegmentType_Bezier?3:1),s.points[h].time>r){n=b;break}if(n==-1)return s.points[h].value;const c=s.segments[n];return c.evaluate(s.points.slice(c.basePointIndex),r)}class xu extends Kd{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._modelOpacity=1}static create(t,r){const i=new xu;return i.parse(t),i._sourceFrameRate=i._motionData.fps,i._loopDurationSeconds=i._motionData.duration,i._onFinishedMotion=r,i}doUpdateParameters(t,r,i,n){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=d1),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=p1),this._modelCurveIdOpacity==null&&(this._modelCurveIdOpacity=Ba);let o=r-n.getStartTime();o<0&&(o=0);let h=Number.MAX_VALUE,c=Number.MAX_VALUE;const b=64;let T=0,C=0;this._eyeBlinkParameterIds.length>b&&Qd("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>b&&Qd("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const x=this._fadeInSeconds<=0?1:Ke.getEasingSine((r-n.getFadeInStartTime())/this._fadeInSeconds),$=this._fadeOutSeconds<=0||n.getEndTime()<0?1:Ke.getEasingSine((n.getEndTime()-r)/this._fadeOutSeconds);let I,B,U,G=o;if(this._isLoop)for(;G>this._motionData.duration;)G-=this._motionData.duration;const z=this._motionData.curves;for(B=0;B<this._motionData.curveCount&&z[B].type==Ji.CubismMotionCurveTarget_Model;++B)I=vu(this._motionData,B,G),z[B].id==this._modelCurveIdEyeBlink?c=I:z[B].id==this._modelCurveIdLipSync?h=I:z[B].id==this._modelCurveIdOpacity&&(this._modelOpacity=I,t.setModelOapcity(this.getModelOpacityValue()));for(;B<this._motionData.curveCount&&z[B].type==Ji.CubismMotionCurveTarget_Parameter;++B){if(U=t.getParameterIndex(z[B].id),U==-1)continue;const J=t.getParameterValueByIndex(U);if(I=vu(this._motionData,B,G),c!=Number.MAX_VALUE){for(let it=0;it<this._eyeBlinkParameterIds.length&&it<b;++it)if(this._eyeBlinkParameterIds[it]==z[B].id){I*=c,C|=1<<it;break}}if(h!=Number.MAX_VALUE){for(let it=0;it<this._lipSyncParameterIds.length&&it<b;++it)if(this._lipSyncParameterIds[it]==z[B].id){I+=h,T|=1<<it;break}}let Z;if(z[B].fadeInTime<0&&z[B].fadeOutTime<0)Z=J+(I-J)*i;else{let it,Q;z[B].fadeInTime<0?it=x:it=z[B].fadeInTime==0?1:Ke.getEasingSine((r-n.getFadeInStartTime())/z[B].fadeInTime),z[B].fadeOutTime<0?Q=$:Q=z[B].fadeOutTime==0||n.getEndTime()<0?1:Ke.getEasingSine((n.getEndTime()-r)/z[B].fadeOutTime);const _t=this._weight*it*Q;Z=J+(I-J)*_t}t.setParameterValueByIndex(U,Z,1)}{if(c!=Number.MAX_VALUE)for(let J=0;J<this._eyeBlinkParameterIds.length&&J<b;++J){const Z=t.getParameterValueById(this._eyeBlinkParameterIds[J]);if(C>>J&1)continue;const it=Z+(c-Z)*i;t.setParameterValueById(this._eyeBlinkParameterIds[J],it)}if(h!=Number.MAX_VALUE)for(let J=0;J<this._lipSyncParameterIds.length&&J<b;++J){const Z=t.getParameterValueById(this._lipSyncParameterIds[J]);if(T>>J&1)continue;const it=Z+(h-Z)*i;t.setParameterValueById(this._lipSyncParameterIds[J],it)}}for(;B<this._motionData.curveCount&&z[B].type==Ji.CubismMotionCurveTarget_PartOpacity;++B)if(I=vu(this._motionData,B,G),Ra.setOpacityFromMotion)t.setPartOpacityById(z[B].id,I);else{if(U=t.getParameterIndex(z[B].id),U==-1)continue;t.setParameterValueByIndex(U,I)}o>=this._motionData.duration&&(this._isLoop?(n.setStartTime(r),this._isLoopFadeIn&&n.setFadeInStartTime(r)):(this._onFinishedMotion&&this._onFinishedMotion(this),n.setIsFinished(!0))),this._lastWeight=i}setIsLoop(t){this._isLoop=t}isLoop(){return this._isLoop}setIsLoopFadeIn(t){this._isLoopFadeIn=t}isLoopFadeIn(){return this._isLoopFadeIn}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,r){const i=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(t==i[n].id){i[n].fadeInTime=r;return}}setParameterFadeOutTime(t,r){const i=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(t==i[n].id){i[n].fadeOutTime=r;return}}getParameterFadeInTime(t){const r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeInTime;return-1}getParameterFadeOutTime(t){const r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeOutTime;return-1}setEffectIds(t,r){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=r}release(){this._motionData=void 0}parse(t){this._motionData=new f1;const r=new e2(t);this._motionData.duration=r.getMotionDuration(),this._motionData.loop=r.isMotionLoop(),this._motionData.curveCount=r.getMotionCurveCount(),this._motionData.fps=r.getMotionFps(),this._motionData.eventCount=r.getEventCount();const i=r.getEvaluationOptionFlag(r2.EvaluationOptionFlag_AreBeziersRistricted),n=r.getMotionFadeInTime(),o=r.getMotionFadeOutTime();n!==void 0?this._fadeInSeconds=n<0?1:n:this._fadeInSeconds=1,o!==void 0?this._fadeOutSeconds=o<0?1:o:this._fadeOutSeconds=1,this._motionData.curves=Array.from({length:this._motionData.curveCount}).map(()=>new u1),this._motionData.segments=Array.from({length:r.getMotionTotalSegmentCount()}).map(()=>new l1),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new c1),this._motionData.points=[];let h=0,c=0;for(let b=0;b<this._motionData.curveCount;++b){const T=this._motionData.curves[b];switch(r.getMotionCurveTarget(b)){case _1:T.type=Ji.CubismMotionCurveTarget_Model;break;case g1:T.type=Ji.CubismMotionCurveTarget_Parameter;break;case m1:T.type=Ji.CubismMotionCurveTarget_PartOpacity;break;default:qs('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!')}T.id=r.getMotionCurveId(b),T.baseSegmentIndex=c;const C=r.getMotionCurveFadeInTime(b),x=r.getMotionCurveFadeOutTime(b);T.fadeInTime=C!==void 0?C:-1,T.fadeOutTime=x!==void 0?x:-1;for(let $=0;$<r.getMotionCurveSegmentCount(b);){switch($==0?(this._motionData.segments[c].basePointIndex=h,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(b,$),r.getMotionCurveSegment(b,$+1)),h+=1,$+=2):this._motionData.segments[c].basePointIndex=h-1,r.getMotionCurveSegment(b,$)){case ts.CubismMotionSegmentType_Linear:{this._motionData.segments[c].segmentType=ts.CubismMotionSegmentType_Linear,this._motionData.segments[c].evaluate=v1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(b,$+1),r.getMotionCurveSegment(b,$+2)),h+=1,$+=3;break}case ts.CubismMotionSegmentType_Bezier:{this._motionData.segments[c].segmentType=ts.CubismMotionSegmentType_Bezier,i||y1?this._motionData.segments[c].evaluate=x1:this._motionData.segments[c].evaluate=b1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(b,$+1),r.getMotionCurveSegment(b,$+2)),this._motionData.points[h+1]=new Ms(r.getMotionCurveSegment(b,$+3),r.getMotionCurveSegment(b,$+4)),this._motionData.points[h+2]=new Ms(r.getMotionCurveSegment(b,$+5),r.getMotionCurveSegment(b,$+6)),h+=3,$+=7;break}case ts.CubismMotionSegmentType_Stepped:{this._motionData.segments[c].segmentType=ts.CubismMotionSegmentType_Stepped,this._motionData.segments[c].evaluate=A1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(b,$+1),r.getMotionCurveSegment(b,$+2)),h+=1,$+=3;break}case ts.CubismMotionSegmentType_InverseStepped:{this._motionData.segments[c].segmentType=ts.CubismMotionSegmentType_InverseStepped,this._motionData.segments[c].evaluate=w1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(b,$+1),r.getMotionCurveSegment(b,$+2)),h+=1,$+=3;break}default:{vn(0);break}}++T.segmentCount,++c}this._motionData.curves.push(T)}for(let b=0;b<r.getEventCount();++b)this._motionData.events[b].fireTime=r.getEventTime(b),this._motionData.events[b].value=r.getEventValue(b);r.release()}getFiredEvent(t,r){this._firedEventValues.length=0;for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events[i].fireTime>t&&this._motionData.events[i].fireTime<=r&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){const r=this._motionData.curves[t];if(r.type==Ji.CubismMotionCurveTarget_Model&&r.id===Ba)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){const r=this._motionData.curves[t];if(r.type==Ji.CubismMotionCurveTarget_Model&&r.id===Ba)return t}return-1}getModelOpacityId(t){if(t!=-1){const r=this._motionData.curves[t];if(r.type==Ji.CubismMotionCurveTarget_Model&&r.id===Ba)return r.id}}getModelOpacityValue(){return this._modelOpacity}}class T1 extends fo{constructor(t,r){var i;super(t,r),bt(this,"definitions"),bt(this,"groups",{idle:"Idle"}),bt(this,"motionDataType","json"),bt(this,"queueManager",new t2),bt(this,"expressionManager"),bt(this,"eyeBlinkIds"),bt(this,"lipSyncIds",["ParamMouthOpenY"]),this.definitions=(i=t.motions)!=null?i:{},this.eyeBlinkIds=t.getEyeBlinkParameters()||[];const n=t.getLipSyncParameters();n!=null&&n.length&&(this.lipSyncIds=n),this.init(r)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new h1(this.settings,t)),this.queueManager.setEventCallback((r,i,n)=>{this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,r){return t.setFinishedMotionHandler(r),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1,performance.now())}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(t,r,i){const n=xu.create(t),o=new e2(t),h=(r===this.groups.idle?dn.idleMotionFadingDuration:dn.motionFadingDuration)/1e3;return o.getMotionFadeInTime()===void 0&&n.setFadeInTime(i.FadeInTime>0?i.FadeInTime:h),o.getMotionFadeOutTime()===void 0&&n.setFadeOutTime(i.FadeOutTime>0?i.FadeOutTime:h),n.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),n}getMotionFile(t){return t.File}getMotionName(t){return t.File}getSoundFile(t){return t.Sound}updateParameters(t,r){return this.queueManager.doUpdateMotion(t,r)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}}const E1="ParamAngleX",C1="ParamAngleY",S1="ParamAngleZ",P1="ParamEyeBallX",$1="ParamEyeBallY",M1="ParamMouthForm",D1="ParamBodyAngleX",R1="ParamBreath";class bu{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new bu}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,r){this._currentTime+=r;const i=this._currentTime*2*3.14159;for(let n=0;n<this._breathParameters.length;++n){const o=this._breathParameters[n];t.addParameterValueById(o.parameterId,o.offset+o.peak*Math.sin(i/o.cycle),o.weight)}}}class yo{constructor(t,r,i,n,o){this.parameterId=t??void 0,this.offset=r??0,this.peak=i??0,this.cycle=n??0,this.weight=o??0}}const i2=class Ou{static create(t){return new Ou(t)}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,r,i){this._closingSeconds=t,this._closedSeconds=r,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,r){this._userTimeSeconds+=r;let i,n=0;switch(this._blinkingState){case 2:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,n>=1&&(n=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-n;break;case 3:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,n>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case 4:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,n>=1&&(n=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=n;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;case 0:default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1;break}Ou.CloseIfZero||(i=-i);for(let o=0;o<this._parameterIds.length;++o)t.setParameterValueById(this._parameterIds[o],i)}constructor(t){var r,i;this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=[],t!=null&&(this._parameterIds=(i=(r=t.getEyeBlinkParameters())==null?void 0:r.slice())!=null?i:this._parameterIds)}determinNextBlinkingTiming(){const t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}};i2.CloseIfZero=!0;let I1=i2;class Au{constructor(t=0,r=0,i=0,n=0){this.x=t,this.y=r,this.width=i,this.height=n}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,r){this.x-=t,this.y-=r,this.width+=t*2,this.height+=r*2}}const Oa=4,F1=36,L1=32,k1=10;let Zs,ms,Na;class s2{getChannelFlagAsColor(t){return this._channelColors[t]}getMaskRenderTexture(){if(this._maskTexture&&this._maskTexture.textures!=null)this._maskTexture.frameNo=this._currentFrameNo;else{this._maskRenderTextures=[],this._maskColorBuffers=[];const t=this._clippingMaskBufferSize;for(let r=0;r<this._renderTextureCount;r++)this._maskColorBuffers.push(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers[r]),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.push(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures[r]),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers[r],0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Na),this._maskTexture=new B1(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,r){let i=Number.MAX_VALUE,n=Number.MAX_VALUE,o=Number.MIN_VALUE,h=Number.MIN_VALUE;const c=r._clippedDrawableIndexList.length;for(let b=0;b<c;b++){const T=r._clippedDrawableIndexList[b],C=t.getDrawableVertexCount(T),x=t.getDrawableVertices(T);let $=Number.MAX_VALUE,I=Number.MAX_VALUE,B=-Number.MAX_VALUE,U=-Number.MAX_VALUE;const G=C*mu.vertexStep;for(let z=mu.vertexOffset;z<G;z+=mu.vertexStep){const J=x[z],Z=x[z+1];J<$&&($=J),J>B&&(B=J),Z<I&&(I=Z),Z>U&&(U=Z)}if($!=Number.MAX_VALUE)if($<i&&(i=$),I<n&&(n=I),B>o&&(o=B),U>h&&(h=U),i==Number.MAX_VALUE)r._allClippedDrawRect.x=0,r._allClippedDrawRect.y=0,r._allClippedDrawRect.width=0,r._allClippedDrawRect.height=0,r._isUsing=!1;else{r._isUsing=!0;const z=o-i,J=h-n;r._allClippedDrawRect.x=i,r._allClippedDrawRect.y=n,r._allClippedDrawRect.width=z,r._allClippedDrawRect.height=J}}}constructor(){this._currentMaskRenderTexture=null,this._currentFrameNo=0,this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new Au,this._tmpMatrix=new mi,this._tmpMatrixForMask=new mi,this._tmpMatrixForDraw=new mi;let t=new ai;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t;const r=this;for(let i=0;i<this._clippingContextListForMask.length;i++)this._clippingContextListForMask[i]&&((t=this._clippingContextListForMask[i])==null||t.release());if(r._clippingContextListForMask=void 0,r._clippingContextListForDraw=void 0,this._maskTexture){for(let i=0;i<this._maskTexture.textures.length;i++)this.gl.deleteFramebuffer(this._maskTexture.textures[i]);this._maskTexture=void 0}if(r._channelColors=void 0,this._maskColorBuffers)for(let i=0;i<this._maskColorBuffers.length;i++)this.gl.deleteTexture(this._maskColorBuffers[i]);this._maskColorBuffers=void 0,this._maskRenderTextures=void 0,this._clearedFrameBufferflags=void 0}initialize(t,r,i,n,o){o%1!=0&&(qs("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),o=~~o),o<1&&qs("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=o<1?1:o,this._clearedFrameBufferflags=[];for(let h=0;h<r;h++){if(n[h]<=0){this._clippingContextListForDraw.push(null);continue}let c=this.findSameClip(i[h],n[h]);c==null&&(c=new O1(this,i[h],n[h]),this._clippingContextListForMask.push(c)),c.addClippedDrawable(h),this._clippingContextListForDraw.push(c)}}setupClippingContext(t,r){this._currentFrameNo++;let i=0;for(let n=0;n<this._clippingContextListForMask.length;n++){const o=this._clippingContextListForMask[n];this.calcClippedDrawTotalBounds(t,o),o._isUsing&&i++}if(i>0){this.setupLayoutBounds(r.isUsingHighPrecisionMask()?0:i),r.isUsingHighPrecisionMask()||(this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture()[0],r.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._clearedFrameBufferflags||(this._clearedFrameBufferflags=[]);for(let n=0;n<this._renderTextureCount;n++)this._clearedFrameBufferflags[n]=!1;for(let n=0;n<this._clippingContextListForMask.length;n++){const o=this._clippingContextListForMask[n],h=o._allClippedDrawRect,c=o._layoutBounds,b=.05;let T=0,C=0;const x=this.getMaskRenderTexture()[o._bufferIndex];if(this._currentMaskRenderTexture!=x&&!r.isUsingHighPrecisionMask()&&(this._currentMaskRenderTexture=x,r.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),r.isUsingHighPrecisionMask()){const $=t.getPixelsPerUnit(),I=o.getClippingManager()._clippingMaskBufferSize,B=c.width*I,U=c.height*I;this._tmpBoundsOnModel.setRect(h),this._tmpBoundsOnModel.width*$>B?(this._tmpBoundsOnModel.expand(h.width*b,0),T=c.width/this._tmpBoundsOnModel.width):T=$/B,this._tmpBoundsOnModel.height*$>U?(this._tmpBoundsOnModel.expand(0,h.height*b),C=c.height/this._tmpBoundsOnModel.height):C=$/U}else this._tmpBoundsOnModel.setRect(h),this._tmpBoundsOnModel.expand(h.width*b,h.height*b),T=c.width/this._tmpBoundsOnModel.width,C=c.height/this._tmpBoundsOnModel.height;if(this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(c.x,c.y),this._tmpMatrix.scaleRelative(T,C),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(c.x,c.y),this._tmpMatrix.scaleRelative(T,C),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),o._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),o._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray()),!r.isUsingHighPrecisionMask()){const $=o._clippingIdCount;for(let I=0;I<$;I++){const B=o._clippingIdList[I];t.getDrawableDynamicFlagVertexPositionsDidChange(B)&&(r.setIsCulling(t.getDrawableCulling(B)!=!1),this._clearedFrameBufferflags[o._bufferIndex]||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferflags[o._bufferIndex]=!0),r.setClippingContextBufferForMask(o),r.drawMesh(t.getDrawableTextureIndex(B),t.getDrawableVertexIndexCount(B),t.getDrawableVertexCount(B),t.getDrawableVertexIndices(B),t.getDrawableVertices(B),t.getDrawableVertexUvs(B),t.getMultiplyColor(B),t.getScreenColor(B),t.getDrawableOpacity(B),gs.CubismBlendMode_Normal,!1))}}}r.isUsingHighPrecisionMask()||(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Na),r.setClippingContextBufferForMask(null),this.gl.viewport(ms[0],ms[1],ms[2],ms[3]))}}findSameClip(t,r){for(let i=0;i<this._clippingContextListForMask.length;i++){const n=this._clippingContextListForMask[i],o=n._clippingIdCount;if(o!=r)continue;let h=0;for(let c=0;c<o;c++){const b=n._clippingIdList[c];for(let T=0;T<o;T++)if(t[T]==b){h++;break}}if(h==o)return n}return null}setupLayoutBounds(t){const r=this._renderTextureCount<=1?F1:L1*this._renderTextureCount;if(t<=0||t>r){t>r&&Ki(`not supported mask count : {0}
1203
- [Details] render texture count : {1}, mask count : {2}`,t-r,this._renderTextureCount,t);for(let T=0;T<this._clippingContextListForMask.length;T++){const C=this._clippingContextListForMask[T];C._layoutChannelNo=0,C._layoutBounds.x=0,C._layoutBounds.y=0,C._layoutBounds.width=1,C._layoutBounds.height=1,C._bufferIndex=0}return}const i=this._renderTextureCount<=1?9:8;let n=t/this._renderTextureCount,o=t%this._renderTextureCount;n=~~n,o=~~o;let h=n/Oa,c=n%Oa;h=~~h,c=~~c;let b=0;for(let T=0;T<this._renderTextureCount;T++)for(let C=0;C<Oa;C++){let x=h+(C<c?1:0);const $=c+1>=Oa?0:c+1;if(x<i&&C==$&&(x+=T<o?1:0),x!=0)if(x==1){const I=this._clippingContextListForMask[b++];I._layoutChannelNo=C,I._layoutBounds.x=0,I._layoutBounds.y=0,I._layoutBounds.width=1,I._layoutBounds.height=1,I._bufferIndex=T}else if(x==2)for(let I=0;I<x;I++){let B=I%2;B=~~B;const U=this._clippingContextListForMask[b++];U._layoutChannelNo=C,U._layoutBounds.x=B*.5,U._layoutBounds.y=0,U._layoutBounds.width=.5,U._layoutBounds.height=1,U._bufferIndex=T}else if(x<=4)for(let I=0;I<x;I++){let B=I%2,U=I/2;B=~~B,U=~~U;const G=this._clippingContextListForMask[b++];G._layoutChannelNo=C,G._layoutBounds.x=B*.5,G._layoutBounds.y=U*.5,G._layoutBounds.width=.5,G._layoutBounds.height=.5,G._bufferIndex=T}else if(x<=i)for(let I=0;I<x;I++){let B=I%3,U=I/3;B=~~B,U=~~U;const G=this._clippingContextListForMask[b++];G._layoutChannelNo=C,G._layoutBounds.x=B/3,G._layoutBounds.y=U/3,G._layoutBounds.width=1/3,G._layoutBounds.height=1/3,G._bufferIndex=T}else if(Ra.supportMoreMaskDivisions&&x<=16)for(let I=0;I<x;I++){let B=I%4,U=I/4;B=~~B,U=~~U;const G=this._clippingContextListForMask[b++];G._layoutChannelNo=C,G._layoutBounds.x=B/4,G._layoutBounds.y=U/4,G._layoutBounds.width=1/4,G._layoutBounds.height=1/4,G._bufferIndex=T}else{Ki(`not supported mask count : {0}
1204
- [Details] render texture count : {1}, mask count : {2}`,t-r,this._renderTextureCount,t);for(let I=0;I<x;I++){const B=this._clippingContextListForMask[b++];B._layoutChannelNo=0,B._layoutBounds.x=0,B._layoutBounds.y=0,B._layoutBounds.width=1,B._layoutBounds.height=1,B._bufferIndex=0}}}}getColorBuffer(){return this._maskColorBuffers}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskCount(){return this._clippingContextListForMask.length}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}}class B1{constructor(t,r){this.frameNo=t,this.textures=r}}class O1{constructor(t,r,i){this._isUsing=!1,this._owner=t,this._clippingIdList=r,this._clippingIdCount=i,this._allClippedDrawRect=new Au,this._layoutBounds=new Au,this._clippedDrawableIndexList=[],this._matrixForMask=new mi,this._matrixForDraw=new mi,this._bufferIndex=0}release(){const t=this;t._layoutBounds=void 0,t._allClippedDrawRect=void 0,t._clippedDrawableIndexList=void 0}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}}class N1{setGlEnable(t,r){r?this.gl.enable(t):this.gl.disable(t)}setGlEnableVertexAttribArray(t,r){r?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)}save(){if(this.gl==null){Ki(`'gl' is null. WebGLRenderingContext is required.
1205
- Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA),this._lastFBO=this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING),this._lastViewport=this.gl.getParameter(this.gl.VIEWPORT)}restore(){if(this.gl==null){Ki(`'gl' is null. WebGLRenderingContext is required.
1206
- Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(t){this.gl=t}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4),this._lastViewport=new Array(4)}}class xn{static getInstance(){return Zs==null&&(Zs=new xn),Zs}static deleteInstance(){Zs&&(Zs.release(),Zs=void 0)}constructor(){this._shaderSets=[]}release(){this.releaseShaderProgram()}setupShaderProgram(t,r,i,n,o,h,c,b,T,C,x,$,I,B,U){I||Ki("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders();let G,z,J,Z;const it=t.getClippingContextBufferForMask();if(it!=null){const Q=this._shaderSets[0];this.gl.useProgram(Q.shaderProgram),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(Q.samplerTexture0Location,0),c.vertex==null&&(c.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,c.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(Q.attributePositionLocation),this.gl.vertexAttribPointer(Q.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),c.uv==null&&(c.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,c.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(Q.attributeTexCoordLocation),this.gl.vertexAttribPointer(Q.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0);const _t=it._layoutChannelNo,et=it.getClippingManager().getChannelFlagAsColor(_t);this.gl.uniform4f(Q.uniformChannelFlagLocation,et.R,et.G,et.B,et.A),this.gl.uniformMatrix4fv(Q.uniformClipMatrixLocation,!1,it._matrixForMask.getArray());const ft=it._layoutBounds;this.gl.uniform4f(Q.uniformBaseColorLocation,ft.x*2-1,ft.y*2-1,ft.getRight()*2-1,ft.getBottom()*2-1),this.gl.uniform4f(Q.uniformMultiplyColorLocation,x.R,x.G,x.B,x.A),this.gl.uniform4f(Q.uniformScreenColorLocation,$.R,$.G,$.B,$.A),G=this.gl.ZERO,z=this.gl.ONE_MINUS_SRC_COLOR,J=this.gl.ZERO,Z=this.gl.ONE_MINUS_SRC_ALPHA}else{const Q=t.getClippingContextBufferForDraw(),et=Q!=null?U?2:1:0;let ft;switch(T){case gs.CubismBlendMode_Normal:default:ft=this._shaderSets[1+et],G=this.gl.ONE,z=this.gl.ONE_MINUS_SRC_ALPHA,J=this.gl.ONE,Z=this.gl.ONE_MINUS_SRC_ALPHA;break;case gs.CubismBlendMode_Additive:ft=this._shaderSets[4+et],G=this.gl.ONE,z=this.gl.ONE,J=this.gl.ZERO,Z=this.gl.ONE;break;case gs.CubismBlendMode_Multiplicative:ft=this._shaderSets[7+et],G=this.gl.DST_COLOR,z=this.gl.ONE_MINUS_SRC_ALPHA,J=this.gl.ZERO,Z=this.gl.ONE;break}if(this.gl.useProgram(ft.shaderProgram),c.vertex==null&&(c.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,c.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(ft.attributePositionLocation),this.gl.vertexAttribPointer(ft.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),c.uv==null&&(c.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,c.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(ft.attributeTexCoordLocation),this.gl.vertexAttribPointer(ft.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),Q!=null){this.gl.activeTexture(this.gl.TEXTURE1);const wt=Q.getClippingManager().getColorBuffer()[t.getClippingContextBufferForDraw()._bufferIndex];this.gl.bindTexture(this.gl.TEXTURE_2D,wt),this.gl.uniform1i(ft.samplerTexture1Location,1),this.gl.uniformMatrix4fv(ft.uniformClipMatrixLocation,!1,Q._matrixForDraw.getArray());const Dt=Q._layoutChannelNo,Rt=Q.getClippingManager().getChannelFlagAsColor(Dt);this.gl.uniform4f(ft.uniformChannelFlagLocation,Rt.R,Rt.G,Rt.B,Rt.A)}this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(ft.samplerTexture0Location,0),this.gl.uniformMatrix4fv(ft.uniformMatrixLocation,!1,B.getArray()),this.gl.uniform4f(ft.uniformBaseColorLocation,C.R,C.G,C.B,C.A),this.gl.uniform4f(ft.uniformMultiplyColorLocation,x.R,x.G,x.B,x.A),this.gl.uniform4f(ft.uniformScreenColorLocation,$.R,$.G,$.B,$.A)}c.index==null&&(c.index=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,c.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,o,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(G,z,J,Z)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.length;t++)this.gl.deleteProgram(this._shaderSets[t].shaderProgram),this._shaderSets[t].shaderProgram=0;this._shaderSets=[]}generateShaders(){for(let t=0;t<k1;t++)this._shaderSets.push({});this._shaderSets[0].shaderProgram=this.loadShaderProgram(U1,G1),this._shaderSets[1].shaderProgram=this.loadShaderProgram(V1,X1),this._shaderSets[2].shaderProgram=this.loadShaderProgram(n2,z1),this._shaderSets[3].shaderProgram=this.loadShaderProgram(n2,W1),this._shaderSets[4].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[5].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[6].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[7].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[8].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[9].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[0].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_position"),this._shaderSets[0].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_texCoord"),this._shaderSets[0].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"s_texture0"),this._shaderSets[0].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_clipMatrix"),this._shaderSets[0].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_channelFlag"),this._shaderSets[0].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_baseColor"),this._shaderSets[0].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_multiplyColor"),this._shaderSets[0].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_screenColor"),this._shaderSets[1].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_position"),this._shaderSets[1].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_texCoord"),this._shaderSets[1].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"s_texture0"),this._shaderSets[1].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_matrix"),this._shaderSets[1].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_baseColor"),this._shaderSets[1].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_multiplyColor"),this._shaderSets[1].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_screenColor"),this._shaderSets[2].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_position"),this._shaderSets[2].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_texCoord"),this._shaderSets[2].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture0"),this._shaderSets[2].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture1"),this._shaderSets[2].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_matrix"),this._shaderSets[2].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_clipMatrix"),this._shaderSets[2].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_channelFlag"),this._shaderSets[2].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_baseColor"),this._shaderSets[2].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_multiplyColor"),this._shaderSets[2].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_screenColor"),this._shaderSets[3].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_position"),this._shaderSets[3].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_texCoord"),this._shaderSets[3].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture0"),this._shaderSets[3].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture1"),this._shaderSets[3].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_matrix"),this._shaderSets[3].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_clipMatrix"),this._shaderSets[3].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_channelFlag"),this._shaderSets[3].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_baseColor"),this._shaderSets[3].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_multiplyColor"),this._shaderSets[3].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_screenColor"),this._shaderSets[4].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_position"),this._shaderSets[4].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_texCoord"),this._shaderSets[4].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"s_texture0"),this._shaderSets[4].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_matrix"),this._shaderSets[4].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_baseColor"),this._shaderSets[4].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_multiplyColor"),this._shaderSets[4].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_screenColor"),this._shaderSets[5].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_position"),this._shaderSets[5].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_texCoord"),this._shaderSets[5].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture0"),this._shaderSets[5].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture1"),this._shaderSets[5].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_matrix"),this._shaderSets[5].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_clipMatrix"),this._shaderSets[5].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_channelFlag"),this._shaderSets[5].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_baseColor"),this._shaderSets[5].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_multiplyColor"),this._shaderSets[5].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_screenColor"),this._shaderSets[6].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_position"),this._shaderSets[6].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_texCoord"),this._shaderSets[6].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture0"),this._shaderSets[6].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture1"),this._shaderSets[6].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_matrix"),this._shaderSets[6].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_clipMatrix"),this._shaderSets[6].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_channelFlag"),this._shaderSets[6].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_baseColor"),this._shaderSets[6].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_multiplyColor"),this._shaderSets[6].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_screenColor"),this._shaderSets[7].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_position"),this._shaderSets[7].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_texCoord"),this._shaderSets[7].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"s_texture0"),this._shaderSets[7].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_matrix"),this._shaderSets[7].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_baseColor"),this._shaderSets[7].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_multiplyColor"),this._shaderSets[7].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_screenColor"),this._shaderSets[8].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_position"),this._shaderSets[8].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_texCoord"),this._shaderSets[8].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture0"),this._shaderSets[8].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture1"),this._shaderSets[8].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_matrix"),this._shaderSets[8].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_clipMatrix"),this._shaderSets[8].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_channelFlag"),this._shaderSets[8].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_baseColor"),this._shaderSets[8].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_multiplyColor"),this._shaderSets[8].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_screenColor"),this._shaderSets[9].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_position"),this._shaderSets[9].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_texCoord"),this._shaderSets[9].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture0"),this._shaderSets[9].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture1"),this._shaderSets[9].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_matrix"),this._shaderSets[9].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_clipMatrix"),this._shaderSets[9].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_channelFlag"),this._shaderSets[9].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_baseColor"),this._shaderSets[9].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_multiplyColor"),this._shaderSets[9].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_screenColor")}loadShaderProgram(t,r){const i=this.gl.createProgram(),n=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!n)return Ki("Vertex shader compile error!"),0;const o=this.compileShaderSource(this.gl.FRAGMENT_SHADER,r);return o?(this.gl.attachShader(i,n),this.gl.attachShader(i,o),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?(this.gl.deleteShader(n),this.gl.deleteShader(o),i):(Ki("Failed to link program: {0}",i),this.gl.deleteShader(n),this.gl.deleteShader(o),i&&this.gl.deleteProgram(i),0)):(Ki("Vertex shader compile error!"),0)}compileShaderSource(t,r){const i=r,n=this.gl.createShader(t);if(this.gl.shaderSource(n,i),this.gl.compileShader(n),!n){const h=this.gl.getShaderInfoLog(n);Ki("Shader compile log: {0} ",h)}return this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(this.gl.deleteShader(n),null)}setGl(t){this.gl=t}}const U1="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",G1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}",V1="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",n2="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",X1="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}",z1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}",W1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * (1.0 - maskVal); gl_FragColor = col_formask;}";class o2 extends gu{initialize(t,r=1){t.isUsingMasking()&&(this._clippingManager=new s2,this._clippingManager.initialize(t,t.getDrawableCount(),t.getDrawableMasks(),t.getDrawableMaskCounts(),r));for(let i=t.getDrawableCount()-1;i>=0;i--)this._sortedDrawableIndexList[i]=0;super.initialize(t)}bindTexture(t,r){this._textures[t]=r}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){if(!this._model.isUsingMasking())return;const r=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=new s2,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts(),r)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new N1,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}release(){var t,r,i;const n=this;this._clippingManager.release(),n._clippingManager=void 0,(t=this.gl)==null||t.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(r=this.gl)==null||r.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(i=this.gl)==null||i.deleteBuffer(this._bufferData.index),this._bufferData.index=null,n._bufferData=void 0,n._textures=void 0}doDrawModel(){if(this.gl==null){Ki(`'gl' is null. WebGLRenderingContext is required.
1207
- Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._clippingManager!=null&&(this.preDraw(),this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();const t=this.getModel().getDrawableCount(),r=this.getModel().getDrawableRenderOrders();for(let i=0;i<t;++i){const n=r[i];this._sortedDrawableIndexList[n]=i}for(let i=0;i<t;++i){const n=this._sortedDrawableIndexList[i];if(!this.getModel().getDrawableDynamicFlagIsVisible(n))continue;const o=this._clippingManager!=null?this._clippingManager.getClippingContextListForDraw()[n]:null;if(o!=null&&this.isUsingHighPrecisionMask()){o._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,o.getClippingManager().getMaskRenderTexture()[o._bufferIndex]),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{const h=o._clippingIdCount;for(let c=0;c<h;c++){const b=o._clippingIdList[c];this._model.getDrawableDynamicFlagVertexPositionsDidChange(b)&&(this.setIsCulling(this._model.getDrawableCulling(b)!=!1),this.setClippingContextBufferForMask(o),this.drawMesh(this.getModel().getDrawableTextureIndex(b),this.getModel().getDrawableVertexIndexCount(b),this.getModel().getDrawableVertexCount(b),this.getModel().getDrawableVertexIndices(b),this.getModel().getDrawableVertices(b),this.getModel().getDrawableVertexUvs(b),this.getModel().getMultiplyColor(b),this.getModel().getScreenColor(b),this.getModel().getDrawableOpacity(b),gs.CubismBlendMode_Normal,!1))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Na),this.setClippingContextBufferForMask(null),this.gl.viewport(ms[0],ms[1],ms[2],ms[3]),this.preDraw()}this.setClippingContextBufferForDraw(o),this.setIsCulling(this.getModel().getDrawableCulling(n)),this.drawMesh(this.getModel().getDrawableTextureIndex(n),this.getModel().getDrawableVertexIndexCount(n),this.getModel().getDrawableVertexCount(n),this.getModel().getDrawableVertexIndices(n),this.getModel().getDrawableVertices(n),this.getModel().getDrawableVertexUvs(n),this.getModel().getMultiplyColor(n),this.getModel().getScreenColor(n),this.getModel().getDrawableOpacity(n),this.getModel().getDrawableBlendMode(n),this.getModel().getDrawableInvertedMaskBit(n))}}drawMesh(t,r,i,n,o,h,c,b,T,C,x){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW);const $=this.getModelColor();this.getClippingContextBufferForMask()==null&&($.A*=T,this.isPremultipliedAlpha()&&($.R*=$.A,$.G*=$.A,$.B*=$.A));let I=null;this._textures[t]!=null&&(I=this._textures[t]),xn.getInstance().setupShaderProgram(this,I,i,o,n,h,this._bufferData,T,C,$,c,b,this.isPremultipliedAlpha(),this.getMvpMatrix(),x),this.gl.drawElements(this.gl.TRIANGLES,r,this.gl.UNSIGNED_SHORT,0),this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){xn.deleteInstance()}setRenderState(t,r){Na=t,ms=r}preDraw(){if(this.firstDraw&&(this.firstDraw=!1),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(const t of Object.entries(this._textures))this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}startUp(t){this.gl=t,this._clippingManager&&this._clippingManager.setGL(t),xn.getInstance().setGl(t),this._rendererProfile.setGl(t),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")}}gu.staticRelease=()=>{o2.doStaticRelease()};const a2=new mi;class H1 extends Id{constructor(t,r,i){super(),bt(this,"settings"),bt(this,"coreModel"),bt(this,"motionManager"),bt(this,"lipSync",!0),bt(this,"breath",bu.create()),bt(this,"eyeBlink"),bt(this,"userData"),bt(this,"renderer",new o2),bt(this,"idParamAngleX",E1),bt(this,"idParamAngleY",C1),bt(this,"idParamAngleZ",S1),bt(this,"idParamEyeBallX",P1),bt(this,"idParamEyeBallY",$1),bt(this,"idParamBodyAngleX",D1),bt(this,"idParamBreath",R1),bt(this,"idParamMouthForm",M1),bt(this,"pixelsPerUnit",1),bt(this,"centeringTransform",new nr),this.coreModel=t,this.settings=r,this.motionManager=new T1(r,i),this.init()}init(){var t;super.init(),(t=this.settings.getEyeBlinkParameters())!=null&&t.length&&(this.eyeBlink=I1.create(this.settings)),this.breath.setParameters([new yo(this.idParamAngleX,0,15,6.5345,.5),new yo(this.idParamAngleY,0,8,3.5345,.5),new yo(this.idParamAngleZ,0,10,5.5345,.5),new yo(this.idParamBodyAngleX,0,4,15.5345,.5),new yo(this.idParamBreath,0,.5,3.2345,.5)]),this.renderer.initialize(this.coreModel),this.renderer.setIsPremultipliedAlpha(!0)}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){const t={};if(this.settings.layout)for(const[r,i]of Object.entries(this.settings.layout)){const n=r.charAt(0).toLowerCase()+r.slice(1);t[n]=i}return t}setupLayout(){super.setupLayout(),this.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit,this.centeringTransform.scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(t,r){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(t),this.renderer._clippingManager._currentFrameNo=r,this.renderer._clippingManager._maskTexture=void 0,xn.getInstance()._shaderSets=[]}bindTexture(t,r){this.renderer.bindTexture(t,r)}getHitAreaDefs(){var t,r;return(r=(t=this.settings.hitAreas)==null?void 0:t.map(i=>({id:i.Id,name:i.Name,index:this.coreModel.getDrawableIndex(i.Id)})))!=null?r:[]}getDrawableIDs(){return this.coreModel.getDrawableIds()}getDrawableIndex(t){return this.coreModel.getDrawableIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawableIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);const r=this.coreModel.getDrawableVertices(t).slice();for(let i=0;i<r.length;i+=2)r[i]=r[i]*this.pixelsPerUnit+this.originalWidth/2,r[i+1]=-r[i+1]*this.pixelsPerUnit+this.originalHeight/2;return r}updateTransform(t){this.drawingMatrix.copyFrom(this.centeringTransform).prepend(this.localTransform).prepend(t)}update(t,r){var i,n,o,h;super.update(t,r),t/=1e3,r/=1e3;const c=this.coreModel;this.emit("beforeMotionUpdate");const b=this.motionManager.update(this.coreModel,r);if(this.emit("afterMotionUpdate"),c.saveParameters(),(i=this.motionManager.expressionManager)==null||i.update(c,r),b||(n=this.eyeBlink)==null||n.updateParameters(c,t),this.updateFocus(),this.updateNaturalMovements(t*1e3,r*1e3),this.lipSync&&this.motionManager.currentAudio){let T=this.motionManager.mouthSync(),C=0;const x=1,$=1.2;T>0&&(C=.4),T=pn(T*$,C,x);for(let I=0;I<this.motionManager.lipSyncIds.length;++I)c.addParameterValueById(this.motionManager.lipSyncIds[I],T,.8)}(o=this.physics)==null||o.evaluate(c,t),(h=this.pose)==null||h.updateParameters(c,t),this.emit("beforeModelUpdate"),c.update(),c.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,this.focusController.x*30),this.coreModel.addParameterValueById(this.idParamAngleY,this.focusController.y*30),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,this.focusController.x*10)}updateFacialEmotion(t){this.coreModel.addParameterValueById(this.idParamMouthForm,t)}updateNaturalMovements(t,r){var i;(i=this.breath)==null||i.updateParameters(this.coreModel,t/1e3)}draw(t){const r=this.drawingMatrix,i=a2.getArray();i[0]=r.a,i[1]=r.b,i[4]=-r.c,i[5]=-r.d,i[12]=r.tx,i[13]=r.ty,this.renderer.setMvpMatrix(a2),this.renderer.setRenderState(t.getParameter(t.FRAMEBUFFER_BINDING),this.viewport),this.renderer.drawModel()}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}}class h2{constructor(t){this.groups=t.Groups,this.hitAreas=t.HitAreas,this.layout=t.Layout,this.moc=t.FileReferences.Moc,this.expressions=t.FileReferences.Expressions,this.motions=t.FileReferences.Motions,this.textures=t.FileReferences.Textures,this.physics=t.FileReferences.Physics,this.pose=t.FileReferences.Pose}getEyeBlinkParameters(){var t,r;return(r=(t=this.groups)==null?void 0:t.find(i=>i.Name==="EyeBlink"))==null?void 0:r.Ids}getLipSyncParameters(){var t,r;return(r=(t=this.groups)==null?void 0:t.find(i=>i.Name==="LipSync"))==null?void 0:r.Ids}}class bn extends Ia{constructor(t){if(super(t),bt(this,"moc"),bt(this,"textures"),!bn.isValidJSON(t))throw new TypeError("Invalid JSON.");Object.assign(this,new h2(t))}static isValidJSON(t){var r;return!!(t!=null&&t.FileReferences)&&typeof t.FileReferences.Moc=="string"&&((r=t.FileReferences.Textures)==null?void 0:r.length)>0&&t.FileReferences.Textures.every(i=>typeof i=="string")}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[r,i]of Object.entries(this.motions))for(let n=0;n<i.length;n++)i[n].File=t(i[n].File,`motions.${r}[${n}].File`),i[n].Sound!==void 0&&(i[n].Sound=t(i[n].Sound,`motions.${r}[${n}].Sound`));if(this.expressions)for(let r=0;r<this.expressions.length;r++)this.expressions[r].File=t(this.expressions[r].File,`expressions[${r}].File`)}}Lm(bn,[h2]);let Ua,l2=20;function Y1(){return go.isStarted()?Promise.resolve():(Ua??(Ua=new Promise((s,t)=>{function r(){try{j1(),s()}catch(i){if(l2--,l2<0){const n=new Error("Failed to start up Cubism 4 framework.");n.cause=i,t(n);return}setTimeout(r,10)}}r()})),Ua)}function j1(s){s=Object.assign({logFunction:console.log,loggingLevel:yn.LogLevel_Verbose},s),go.startUp(s),go.initialize()}const q1=.001,u2=.5;class wu{static create(t){const r=new wu;typeof t.FadeInTime=="number"&&(r._fadeTimeSeconds=t.FadeInTime,r._fadeTimeSeconds<=0&&(r._fadeTimeSeconds=u2));const i=t.Groups,n=i.length;for(let o=0;o<n;++o){const h=i[o],c=h.length;let b=0;for(let T=0;T<c;++T){const C=h[T],x=new Ga;x.partId=C.Id;const $=C.Link;if($){const I=$.length;for(let B=0;B<I;++B){const U=new Ga;U.partId=$[B],x.link.push(U)}}r._partGroups.push(x),++b}r._partGroupCounts.push(b)}return r}updateParameters(t,r){t!=this._lastModel&&this.reset(t),this._lastModel=t,r<0&&(r=0);let i=0;for(let n=0;n<this._partGroupCounts.length;n++){const o=this._partGroupCounts[n];this.doFade(t,r,i,o),i+=o}this.copyPartOpacities(t)}reset(t){let r=0;for(let i=0;i<this._partGroupCounts.length;++i){const n=this._partGroupCounts[i];for(let o=r;o<r+n;++o){this._partGroups[o].initialize(t);const h=this._partGroups[o].partIndex,c=this._partGroups[o].parameterIndex;if(!(h<0)){t.setPartOpacityByIndex(h,o==r?1:0),t.setParameterValueByIndex(c,o==r?1:0);for(let b=0;b<this._partGroups[o].link.length;++b)this._partGroups[o].link[b].initialize(t)}}r+=n}}copyPartOpacities(t){for(let r=0;r<this._partGroups.length;++r){const i=this._partGroups[r];if(i.link.length==0)continue;const n=this._partGroups[r].partIndex,o=t.getPartOpacityByIndex(n);for(let h=0;h<i.link.length;++h){const b=i.link[h].partIndex;b<0||t.setPartOpacityByIndex(b,o)}}}doFade(t,r,i,n){let o=-1,h=1;const c=.5,b=.15;for(let T=i;T<i+n;++T){const C=this._partGroups[T].partIndex,x=this._partGroups[T].parameterIndex;if(t.getParameterValueByIndex(x)>q1){if(o>=0)break;o=T,h=t.getPartOpacityByIndex(C),h+=r/this._fadeTimeSeconds,h>1&&(h=1)}}o<0&&(o=0,h=1);for(let T=i;T<i+n;++T){const C=this._partGroups[T].partIndex;if(o==T)t.setPartOpacityByIndex(C,h);else{let x=t.getPartOpacityByIndex(C),$;h<c?$=h*(c-1)/c+1:$=(1-h)*c/(1-c),(1-$)*(1-h)>b&&($=1-b/(1-h)),x>$&&(x=$),t.setPartOpacityByIndex(C,x)}}}constructor(){this._fadeTimeSeconds=u2,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class Ga{constructor(t){this.parameterIndex=0,this.partIndex=0,this.partId="",this.link=[],t!=null&&this.assignment(t)}assignment(t){return this.partId=t.partId,this.link=t.link.map(r=>r.clone()),this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new Ga;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(r=>r.clone()),t}}class c2{constructor(t=!1,r=new ai){this.isOverwritten=t,this.Color=r}}class f2{constructor(t=!1,r=new ai){this.isOverwritten=t,this.Color=r}}class Z1{constructor(t=!1,r=!1){this.isOverwritten=t,this.isCulling=r}}class Q1{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){const t=this._model.parameters.count,r=this._savedParameters.length;for(let i=0;i<t;++i)i<r?this._savedParameters[i]=this._parameterValues[i]:this._savedParameters.push(this._parameterValues[i])}getMultiplyColor(t){return this.getOverwriteFlagForModelMultiplyColors()||this.getOverwriteFlagForDrawableMultiplyColors(t)?this._userMultiplyColors[t].Color:this.getDrawableMultiplyColor(t)}getScreenColor(t){return this.getOverwriteFlagForModelScreenColors()||this.getOverwriteFlagForDrawableScreenColors(t)?this._userScreenColors[t].Color:this.getDrawableScreenColor(t)}setMultiplyColorByTextureColor(t,r){this.setMultiplyColorByRGBA(t,r.R,r.G,r.B,r.A)}setMultiplyColorByRGBA(t,r,i,n,o=1){this._userMultiplyColors[t].Color.R=r,this._userMultiplyColors[t].Color.G=i,this._userMultiplyColors[t].Color.B=n,this._userMultiplyColors[t].Color.A=o}setScreenColorByTextureColor(t,r){this.setScreenColorByRGBA(t,r.R,r.G,r.B,r.A)}setScreenColorByRGBA(t,r,i,n,o=1){this._userScreenColors[t].Color.R=r,this._userScreenColors[t].Color.G=i,this._userScreenColors[t].Color.B=n,this._userScreenColors[t].Color.A=o}getPartMultiplyColor(t){return this._userPartMultiplyColors[t].Color}getPartScreenColor(t){return this._userPartScreenColors[t].Color}setPartColor(t,r,i,n,o,h,c){if(h[t].Color.R=r,h[t].Color.G=i,h[t].Color.B=n,h[t].Color.A=o,h[t].isOverwritten)for(let b=0;b<this._partChildDrawables[t].length;++b){const T=this._partChildDrawables[t][b];c[T].Color.R=r,c[T].Color.G=i,c[T].Color.B=n,c[T].Color.A=o}}setPartMultiplyColorByTextureColor(t,r){this.setPartMultiplyColorByRGBA(t,r.R,r.G,r.B,r.A)}setPartMultiplyColorByRGBA(t,r,i,n,o){this.setPartColor(t,r,i,n,o,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(t,r){this.setPartScreenColorByRGBA(t,r.R,r.G,r.B,r.A)}setPartScreenColorByRGBA(t,r,i,n,o){this.setPartColor(t,r,i,n,o,this._userPartScreenColors,this._userScreenColors)}getOverwriteFlagForModelMultiplyColors(){return this._isOverwrittenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return this._isOverwrittenModelScreenColors}setOverwriteFlagForModelMultiplyColors(t){this._isOverwrittenModelMultiplyColors=t}setOverwriteFlagForModelScreenColors(t){this._isOverwrittenModelScreenColors=t}getOverwriteFlagForDrawableMultiplyColors(t){return this._userMultiplyColors[t].isOverwritten}getOverwriteFlagForDrawableScreenColors(t){return this._userScreenColors[t].isOverwritten}setOverwriteFlagForDrawableMultiplyColors(t,r){this._userMultiplyColors[t].isOverwritten=r}setOverwriteFlagForDrawableScreenColors(t,r){this._userScreenColors[t].isOverwritten=r}getOverwriteColorForPartMultiplyColors(t){return this._userPartMultiplyColors[t].isOverwritten}getOverwriteColorForPartScreenColors(t){return this._userPartScreenColors[t].isOverwritten}setOverwriteColorForPartColors(t,r,i,n){i[t].isOverwritten=r;for(let o=0;o<this._partChildDrawables[t].length;++o){const h=this._partChildDrawables[t][o];n[h].isOverwritten=r,r&&(n[h].Color.R=i[t].Color.R,n[h].Color.G=i[t].Color.G,n[h].Color.B=i[t].Color.B,n[h].Color.A=i[t].Color.A)}}setOverwriteColorForPartMultiplyColors(t,r){this._userPartMultiplyColors[t].isOverwritten=r,this.setOverwriteColorForPartColors(t,r,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(t,r){this._userPartScreenColors[t].isOverwritten=r,this.setOverwriteColorForPartColors(t,r,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(t){if(this.getOverwriteFlagForModelCullings()||this.getOverwriteFlagForDrawableCullings(t))return this._userCullings[t].isCulling;const r=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(r[t])}setDrawableCulling(t,r){this._userCullings[t].isCulling=r}getOverwriteFlagForModelCullings(){return this._isOverwrittenCullings}setOverwriteFlagForModelCullings(t){this._isOverwrittenCullings=t}getOverwriteFlagForDrawableCullings(t){return this._userCullings[t].isOverwritten}setOverwriteFlagForDrawableCullings(t,r){this._userCullings[t].isOverwritten=r}getModelOapcity(){return this._modelOpacity}setModelOapcity(t){this._modelOpacity=t}getModel(){return this._model}getPartIndex(t){let r;const i=this._model.parts.count;for(r=0;r<i;++r)if(t==this._partIds[r])return r;return t in this._notExistPartId?this._notExistPartId[t]:(r=i+this._notExistPartId.length,this._notExistPartId[t]=r,this._notExistPartOpacities[r]=0,r)}getPartId(t){return this._model.parts.ids[t]}getPartCount(){return this._model.parts.count}setPartOpacityByIndex(t,r){if(t in this._notExistPartOpacities){this._notExistPartOpacities[t]=r;return}vn(0<=t&&t<this.getPartCount()),this._partOpacities[t]=r}setPartOpacityById(t,r){const i=this.getPartIndex(t);i<0||this.setPartOpacityByIndex(i,r)}getPartOpacityByIndex(t){return t in this._notExistPartOpacities?this._notExistPartOpacities[t]:(vn(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){const r=this.getPartIndex(t);return r<0?0:this.getPartOpacityByIndex(r)}getParameterIndex(t){let r;const i=this._model.parameters.count;for(r=0;r<i;++r)if(t==this._parameterIds[r])return r;return t in this._notExistParameterId?this._notExistParameterId[t]:(r=this._model.parameters.count+Object.keys(this._notExistParameterId).length,this._notExistParameterId[t]=r,this._notExistParameterValues[r]=0,r)}getParameterCount(){return this._model.parameters.count}getParameterType(t){return this._model.parameters.types[t]}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterValueByIndex(t){return t in this._notExistParameterValues?this._notExistParameterValues[t]:(vn(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){const r=this.getParameterIndex(t);return this.getParameterValueByIndex(r)}setParameterValueByIndex(t,r,i=1){if(t in this._notExistParameterValues){this._notExistParameterValues[t]=i==1?r:this._notExistParameterValues[t]*(1-i)+r*i;return}vn(0<=t&&t<this.getParameterCount()),this._model.parameters.maximumValues[t]<r&&(r=this._model.parameters.maximumValues[t]),this._model.parameters.minimumValues[t]>r&&(r=this._model.parameters.minimumValues[t]),this._parameterValues[t]=i==1?r:this._parameterValues[t]=this._parameterValues[t]*(1-i)+r*i}setParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.setParameterValueByIndex(n,r,i)}addParameterValueByIndex(t,r,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+r*i)}addParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.addParameterValueByIndex(n,r,i)}multiplyParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.multiplyParameterValueByIndex(n,r,i)}multiplyParameterValueByIndex(t,r,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(r-1)*i))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const r=this._model.drawables.count;for(let i=0;i<r;++i)if(this._drawableIds[i]==t)return i;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){return this._model.drawables.ids[t]}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this.getDrawableTextureIndex(t)}getDrawableTextureIndex(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(r[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableMultiplyColor(t){const r=this._model.drawables.multiplyColors,i=t*4,n=new ai;return n.R=r[i],n.G=r[i+1],n.B=r[i+2],n.A=r[i+3],n}getDrawableScreenColor(t){const r=this._model.drawables.screenColors,i=t*4,n=new ai;return n.R=r[i],n.G=r[i+1],n.B=r[i+2],n.A=r[i+3],n}getDrawableParentPartIndex(t){return this._model.drawables.parentPartIndices[t]}getDrawableBlendMode(t){const r=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(r[t])?gs.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(r[t])?gs.CubismBlendMode_Multiplicative:gs.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){const r=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(r[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(r[t])}getDrawableDynamicFlagVisibilityDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(r[t])}getDrawableDynamicFlagOpacityDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(r[t])}getDrawableDynamicFlagRenderOrderDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(r[t])}getDrawableDynamicFlagBlendColorDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(r[t])}loadParameters(){let t=this._model.parameters.count;const r=this._savedParameters.length;t>r&&(t=r);for(let i=0;i<t;++i)this._parameterValues[i]=this._savedParameters[i]}initialize(){this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{const r=this._model.parameters.ids,i=this._model.parameters.count;for(let n=0;n<i;++n)this._parameterIds.push(r[n])}const t=this._model.parts.count;{const r=this._model.parts.ids;for(let i=0;i<t;++i)this._partIds.push(r[i])}{const r=this._model.drawables.ids,i=this._model.drawables.count,n=new Z1(!1,!1);for(let o=0;o<t;++o){const h=new ai(1,1,1,1),c=new ai(0,0,0,1),b=new f2(!1,h),T=new f2(!1,c);this._userPartMultiplyColors.push(b),this._userPartScreenColors.push(T),this._partChildDrawables.push([])}for(let o=0;o<i;++o){const h=new ai(1,1,1,1),c=new ai(0,0,0,1),b=new c2(!1,h),T=new c2(!1,c);this._drawableIds.push(r[o]),this._userMultiplyColors.push(b),this._userScreenColors.push(T),this._userCullings.push(n);const C=this.getDrawableParentPartIndex(o);C>=0&&this._partChildDrawables[C].push(o)}}}constructor(t){this._model=t,this._savedParameters=[],this._parameterIds=[],this._drawableIds=[],this._partIds=[],this._isOverwrittenModelMultiplyColors=!1,this._isOverwrittenModelScreenColors=!1,this._isOverwrittenCullings=!1,this._modelOpacity=1,this._userMultiplyColors=[],this._userScreenColors=[],this._userCullings=[],this._userPartMultiplyColors=[],this._userPartScreenColors=[],this._partChildDrawables=[],this._notExistPartId={},this._notExistParameterId={},this._notExistParameterValues={},this._notExistPartOpacities={},this.initialize()}release(){this._model.release(),this._model=void 0}}class Tu{static create(t,r){if(r&&!this.hasMocConsistency(t))throw new Error("Inconsistent MOC3.");const i=Live2DCubismCore.Moc.fromArrayBuffer(t);if(i){const n=new Tu(i);return n._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(i,t),n}throw new Error("Failed to CubismMoc.create().")}createModel(){let t;const r=Live2DCubismCore.Model.fromMoc(this._moc);if(r)return t=new Q1(r),++this._modelCount,t;throw new Error("Unknown error")}deleteModel(t){t!=null&&--this._modelCount}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){this._moc._release(),this._moc=void 0}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(t){return Live2DCubismCore.Moc.prototype.hasMocConsistency(t)===1}}var Eu=(s=>(s[s.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",s))(Eu||{}),Qs=(s=>(s[s.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",s[s.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",s[s.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",s))(Qs||{});class K1{constructor(){this.initialPosition=new Re(0,0),this.position=new Re(0,0),this.lastPosition=new Re(0,0),this.lastGravity=new Re(0,0),this.force=new Re(0,0),this.velocity=new Re(0,0)}}class J1{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class ty{constructor(){this.source={}}}class ey{constructor(){this.destination={},this.translationScale=new Re(0,0)}}class ry{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new Re(0,0),this.wind=new Re(0,0),this.fps=0}}class iy{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new Re(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new Re(0,0);return t.x=this._json.Meta.EffectiveForces.Wind.X,t.y=this._json.Meta.EffectiveForces.Wind.Y,t}getFps(){return this._json.Meta.Fps||0}getSubRigCount(){return this._json.Meta.PhysicsSettingCount}getTotalInputCount(){return this._json.Meta.TotalInputCount}getTotalOutputCount(){return this._json.Meta.TotalOutputCount}getVertexCount(){return this._json.Meta.VertexCount}getNormalizationPositionMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Default}getNormalizationAngleMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Default}getInputCount(t){return this._json.PhysicsSettings[t].Input.length}getInputWeight(t,r){return this._json.PhysicsSettings[t].Input[r].Weight}getInputReflect(t,r){return this._json.PhysicsSettings[t].Input[r].Reflect}getInputType(t,r){return this._json.PhysicsSettings[t].Input[r].Type}getInputSourceId(t,r){return this._json.PhysicsSettings[t].Input[r].Source.Id}getOutputCount(t){return this._json.PhysicsSettings[t].Output.length}getOutputVertexIndex(t,r){return this._json.PhysicsSettings[t].Output[r].VertexIndex}getOutputAngleScale(t,r){return this._json.PhysicsSettings[t].Output[r].Scale}getOutputWeight(t,r){return this._json.PhysicsSettings[t].Output[r].Weight}getOutputDestinationId(t,r){return this._json.PhysicsSettings[t].Output[r].Destination.Id}getOutputType(t,r){return this._json.PhysicsSettings[t].Output[r].Type}getOutputReflect(t,r){return this._json.PhysicsSettings[t].Output[r].Reflect}getParticleCount(t){return this._json.PhysicsSettings[t].Vertices.length}getParticleMobility(t,r){return this._json.PhysicsSettings[t].Vertices[r].Mobility}getParticleDelay(t,r){return this._json.PhysicsSettings[t].Vertices[r].Delay}getParticleAcceleration(t,r){return this._json.PhysicsSettings[t].Vertices[r].Acceleration}getParticleRadius(t,r){return this._json.PhysicsSettings[t].Vertices[r].Radius}getParticlePosition(t,r){const i=new Re(0,0);return i.x=this._json.PhysicsSettings[t].Vertices[r].Position.X,i.y=this._json.PhysicsSettings[t].Vertices[r].Position.Y,i}}const d2="X",p2="Y",_2="Angle",sy=5,Cu=100,g2=.001,ny=5;class Su{static create(t){const r=new Su;return r.parse(t),r._physicsRig.gravity.y=0,r}static delete(t){t!=null&&t.release()}parse(t){this._physicsRig=new ry;const r=new iy(t);this._physicsRig.gravity=r.getGravity(),this._physicsRig.wind=r.getWind(),this._physicsRig.subRigCount=r.getSubRigCount(),this._physicsRig.fps=r.getFps(),this._currentRigOutputs=[],this._previousRigOutputs=[];let i=0,n=0,o=0;for(let h=0;h<this._physicsRig.subRigCount;++h){const c=new J1;c.normalizationPosition.minimum=r.getNormalizationPositionMinimumValue(h),c.normalizationPosition.maximum=r.getNormalizationPositionMaximumValue(h),c.normalizationPosition.defalut=r.getNormalizationPositionDefaultValue(h),c.normalizationAngle.minimum=r.getNormalizationAngleMinimumValue(h),c.normalizationAngle.maximum=r.getNormalizationAngleMaximumValue(h),c.normalizationAngle.defalut=r.getNormalizationAngleDefaultValue(h),c.inputCount=r.getInputCount(h),c.baseInputIndex=i,i+=c.inputCount;for(let C=0;C<c.inputCount;++C){const x=new ty;switch(x.sourceParameterIndex=-1,x.weight=r.getInputWeight(h,C),x.reflect=r.getInputReflect(h,C),r.getInputType(h,C)){case d2:x.type=Qs.CubismPhysicsSource_X,x.getNormalizedParameterValue=ay;break;case p2:x.type=Qs.CubismPhysicsSource_Y,x.getNormalizedParameterValue=hy;break;case _2:x.type=Qs.CubismPhysicsSource_Angle,x.getNormalizedParameterValue=ly;break}x.source.targetType=Eu.CubismPhysicsTargetType_Parameter,x.source.id=r.getInputSourceId(h,C),this._physicsRig.inputs.push(x)}c.outputCount=r.getOutputCount(h),c.baseOutputIndex=n;const b=new m2,T=new m2;for(let C=0;C<c.outputCount;++C){b.outputs[C]=0,T.outputs[C]=0;let x=this._physicsRig.outputs[n+C];switch(x||(x=new ey,this._physicsRig.outputs[n+C]=x),x.destinationParameterIndex=-1,x.vertexIndex=r.getOutputVertexIndex(h,C),x.angleScale=r.getOutputAngleScale(h,C),x.weight=r.getOutputWeight(h,C),x.destination.targetType=Eu.CubismPhysicsTargetType_Parameter,x.destination.id=r.getOutputDestinationId(h,C),r.getOutputType(h,C)){case d2:x.type=Qs.CubismPhysicsSource_X,x.getValue=uy,x.getScale=_y;break;case p2:x.type=Qs.CubismPhysicsSource_Y,x.getValue=cy,x.getScale=gy;break;case _2:x.type=Qs.CubismPhysicsSource_Angle,x.getValue=fy,x.getScale=my;break}x.reflect=r.getOutputReflect(h,C)}this._currentRigOutputs.push(b),this._previousRigOutputs.push(T),n+=c.outputCount,c.particleCount=r.getParticleCount(h),c.baseParticleIndex=o,o+=c.particleCount;for(let C=0;C<c.particleCount;++C){const x=new K1;x.mobility=r.getParticleMobility(h,C),x.delay=r.getParticleDelay(h,C),x.acceleration=r.getParticleAcceleration(h,C),x.radius=r.getParticleRadius(h,C),x.position=r.getParticlePosition(h,C),this._physicsRig.particles.push(x)}this._physicsRig.settings.push(c)}this.initialize(),r.release()}stabilization(t){var r,i,n,o;let h,c,b,T;const C=new Re;let x,$,I,B,U,G,z,J;U=t.getModel().parameters.values,G=t.getModel().parameters.maximumValues,z=t.getModel().parameters.minimumValues,J=t.getModel().parameters.defaultValues,((i=(r=this._parameterCaches)==null?void 0:r.length)!=null?i:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((o=(n=this._parameterInputCaches)==null?void 0:n.length)!=null?o:0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let Z=0;Z<t.getParameterCount();++Z)this._parameterCaches[Z]=U[Z],this._parameterInputCaches[Z]=U[Z];for(let Z=0;Z<this._physicsRig.subRigCount;++Z){h={angle:0},C.x=0,C.y=0,x=this._physicsRig.settings[Z],$=this._physicsRig.inputs.slice(x.baseInputIndex),I=this._physicsRig.outputs.slice(x.baseOutputIndex),B=this._physicsRig.particles.slice(x.baseParticleIndex);for(let it=0;it<x.inputCount;++it)c=$[it].weight/Cu,$[it].sourceParameterIndex==-1&&($[it].sourceParameterIndex=t.getParameterIndex($[it].source.id)),$[it].getNormalizedParameterValue(C,h,U[$[it].sourceParameterIndex],z[$[it].sourceParameterIndex],G[$[it].sourceParameterIndex],J[$[it].sourceParameterIndex],x.normalizationPosition,x.normalizationAngle,$[it].reflect,c),this._parameterCaches[$[it].sourceParameterIndex]=U[$[it].sourceParameterIndex];b=Ke.degreesToRadian(-h.angle),C.x=C.x*Ke.cos(b)-C.y*Ke.sin(b),C.y=C.x*Ke.sin(b)+C.y*Ke.cos(b),vy(B,x.particleCount,C,h.angle,this._options.wind,g2*x.normalizationPosition.maximum);for(let it=0;it<x.outputCount;++it){const Q=I[it].vertexIndex;if(I[it].destinationParameterIndex==-1&&(I[it].destinationParameterIndex=t.getParameterIndex(I[it].destination.id)),Q<1||Q>=x.particleCount)continue;let _t=new Re;_t=B[Q].position.substract(B[Q-1].position),T=I[it].getValue(_t,B,Q,I[it].reflect,this._options.gravity),this._currentRigOutputs[Z].outputs[it]=T,this._previousRigOutputs[Z].outputs[it]=T;const et=I[it].destinationParameterIndex,ft=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(U.subarray(et))):U.slice(et);Pu(ft,z[et],G[et],T,I[it]);for(let wt=et,Dt=0;wt<this._parameterCaches.length;wt++,Dt++)U[wt]=this._parameterCaches[wt]=ft[Dt]}}}evaluate(t,r){var i,n,o,h;let c,b,T,C;const x=new Re;let $,I,B,U;if(0>=r)return;let G,z,J,Z,it;if(this._currentRemainTime+=r,this._currentRemainTime>ny&&(this._currentRemainTime=0),G=t.getModel().parameters.values,z=t.getModel().parameters.maximumValues,J=t.getModel().parameters.minimumValues,Z=t.getModel().parameters.defaultValues,((n=(i=this._parameterCaches)==null?void 0:i.length)!=null?n:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((h=(o=this._parameterInputCaches)==null?void 0:o.length)!=null?h:0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let _t=0;_t<t.getParameterCount();++_t)this._parameterInputCaches[_t]=G[_t]}for(this._physicsRig.fps>0?it=1/this._physicsRig.fps:it=r;this._currentRemainTime>=it;){for(let et=0;et<this._physicsRig.subRigCount;++et){$=this._physicsRig.settings[et],B=this._physicsRig.outputs.slice($.baseOutputIndex);for(let ft=0;ft<$.outputCount;++ft)this._previousRigOutputs[et].outputs[ft]=this._currentRigOutputs[et].outputs[ft]}const _t=it/this._currentRemainTime;for(let et=0;et<t.getParameterCount();++et)this._parameterCaches[et]=this._parameterInputCaches[et]*(1-_t)+G[et]*_t,this._parameterInputCaches[et]=this._parameterCaches[et];for(let et=0;et<this._physicsRig.subRigCount;++et){c={angle:0},x.x=0,x.y=0,$=this._physicsRig.settings[et],I=this._physicsRig.inputs.slice($.baseInputIndex),B=this._physicsRig.outputs.slice($.baseOutputIndex),U=this._physicsRig.particles.slice($.baseParticleIndex);for(let ft=0;ft<$.inputCount;++ft)b=I[ft].weight/Cu,I[ft].sourceParameterIndex==-1&&(I[ft].sourceParameterIndex=t.getParameterIndex(I[ft].source.id)),I[ft].getNormalizedParameterValue(x,c,this._parameterCaches[I[ft].sourceParameterIndex],J[I[ft].sourceParameterIndex],z[I[ft].sourceParameterIndex],Z[I[ft].sourceParameterIndex],$.normalizationPosition,$.normalizationAngle,I[ft].reflect,b);T=Ke.degreesToRadian(-c.angle),x.x=x.x*Ke.cos(T)-x.y*Ke.sin(T),x.y=x.x*Ke.sin(T)+x.y*Ke.cos(T),yy(U,$.particleCount,x,c.angle,this._options.wind,g2*$.normalizationPosition.maximum,it,sy);for(let ft=0;ft<$.outputCount;++ft){const wt=B[ft].vertexIndex;if(B[ft].destinationParameterIndex==-1&&(B[ft].destinationParameterIndex=t.getParameterIndex(B[ft].destination.id)),wt<1||wt>=$.particleCount)continue;const Dt=new Re;Dt.x=U[wt].position.x-U[wt-1].position.x,Dt.y=U[wt].position.y-U[wt-1].position.y,C=B[ft].getValue(Dt,U,wt,B[ft].reflect,this._options.gravity),this._currentRigOutputs[et].outputs[ft]=C;const Rt=B[ft].destinationParameterIndex,pt=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(Rt))):this._parameterCaches.slice(Rt);Pu(pt,J[Rt],z[Rt],C,B[ft]);for(let xt=Rt,Ct=0;xt<this._parameterCaches.length;xt++,Ct++)this._parameterCaches[xt]=pt[Ct]}}this._currentRemainTime-=it}const Q=this._currentRemainTime/it;this.interpolate(t,Q)}interpolate(t,r){let i,n,o,h,c;o=t.getModel().parameters.values,h=t.getModel().parameters.maximumValues,c=t.getModel().parameters.minimumValues;for(let b=0;b<this._physicsRig.subRigCount;++b){n=this._physicsRig.settings[b],i=this._physicsRig.outputs.slice(n.baseOutputIndex);for(let T=0;T<n.outputCount;++T){if(i[T].destinationParameterIndex==-1)continue;const C=i[T].destinationParameterIndex,x=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(o.subarray(C))):o.slice(C);Pu(x,c[C],h[C],this._previousRigOutputs[b].outputs[T]*(1-r)+this._currentRigOutputs[b].outputs[T]*r,i[T]);for(let $=C,I=0;$<o.length;$++,I++)o[$]=x[I]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._options=new oy,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=[],this._previousRigOutputs=[],this._currentRemainTime=0}release(){this._physicsRig=void 0}initialize(){let t,r,i;for(let n=0;n<this._physicsRig.subRigCount;++n){r=this._physicsRig.settings[n],t=this._physicsRig.particles.slice(r.baseParticleIndex),t[0].initialPosition=new Re(0,0),t[0].lastPosition=new Re(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new Re(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new Re(0,0),t[0].force=new Re(0,0);for(let o=1;o<r.particleCount;++o)i=new Re(0,0),i.y=t[o].radius,t[o].initialPosition=new Re(t[o-1].initialPosition.x+i.x,t[o-1].initialPosition.y+i.y),t[o].position=new Re(t[o].initialPosition.x,t[o].initialPosition.y),t[o].lastPosition=new Re(t[o].initialPosition.x,t[o].initialPosition.y),t[o].lastGravity=new Re(0,-1),t[o].lastGravity.y*=-1,t[o].velocity=new Re(0,0),t[o].force=new Re(0,0)}}}class oy{constructor(){this.gravity=new Re(0,0),this.wind=new Re(0,0)}}class m2{constructor(){this.outputs=[]}}function ay(s,t,r,i,n,o,h,c,b,T){s.x+=$u(r,i,n,o,h.minimum,h.maximum,h.defalut,b)*T}function hy(s,t,r,i,n,o,h,c,b,T){s.y+=$u(r,i,n,o,h.minimum,h.maximum,h.defalut,b)*T}function ly(s,t,r,i,n,o,h,c,b,T){t.angle+=$u(r,i,n,o,c.minimum,c.maximum,c.defalut,b)*T}function uy(s,t,r,i,n){let o=s.x;return i&&(o*=-1),o}function cy(s,t,r,i,n){let o=s.y;return i&&(o*=-1),o}function fy(s,t,r,i,n){let o;return r>=2?n=t[r-1].position.substract(t[r-2].position):n=n.multiplyByScaler(-1),o=Ke.directionToRadian(n,s),i&&(o*=-1),o}function dy(s,t){return Math.abs(Math.max(s,t)-Math.min(s,t))}function py(s,t){return Math.min(s,t)+dy(s,t)/2}function _y(s,t){return s.x}function gy(s,t){return s.y}function my(s,t){return t}function yy(s,t,r,i,n,o,h,c){let b,T,C,x,$=new Re(0,0),I=new Re(0,0),B=new Re(0,0),U=new Re(0,0);s[0].position=new Re(r.x,r.y),b=Ke.degreesToRadian(i),x=Ke.radianToDirection(b),x.normalize();for(let G=1;G<t;++G)s[G].force=x.multiplyByScaler(s[G].acceleration).add(n),s[G].lastPosition=new Re(s[G].position.x,s[G].position.y),T=s[G].delay*h*30,$=s[G].position.substract(s[G-1].position),C=Ke.directionToRadian(s[G].lastGravity,x)/c,$.x=Ke.cos(C)*$.x-$.y*Ke.sin(C),$.y=Ke.sin(C)*$.x+$.y*Ke.cos(C),s[G].position=s[G-1].position.add($),I=s[G].velocity.multiplyByScaler(T),B=s[G].force.multiplyByScaler(T).multiplyByScaler(T),s[G].position=s[G].position.add(I).add(B),U=s[G].position.substract(s[G-1].position),U.normalize(),s[G].position=s[G-1].position.add(U.multiplyByScaler(s[G].radius)),Ke.abs(s[G].position.x)<o&&(s[G].position.x=0),T!=0&&(s[G].velocity=s[G].position.substract(s[G].lastPosition),s[G].velocity=s[G].velocity.divisionByScalar(T),s[G].velocity=s[G].velocity.multiplyByScaler(s[G].mobility)),s[G].force=new Re(0,0),s[G].lastGravity=new Re(x.x,x.y)}function vy(s,t,r,i,n,o){let h,c,b=new Re(0,0);s[0].position=new Re(r.x,r.y),h=Ke.degreesToRadian(i),c=Ke.radianToDirection(h),c.normalize();for(let T=1;T<t;++T)s[T].force=c.multiplyByScaler(s[T].acceleration).add(n),s[T].lastPosition=new Re(s[T].position.x,s[T].position.y),s[T].velocity=new Re(0,0),b=s[T].force,b.normalize(),b=b.multiplyByScaler(s[T].radius),s[T].position=s[T-1].position.add(b),Ke.abs(s[T].position.x)<o&&(s[T].position.x=0),s[T].force=new Re(0,0),s[T].lastGravity=new Re(c.x,c.y)}function Pu(s,t,r,i,n){let o,h,c;o=n.getScale(n.translationScale,n.angleScale),h=i*o,h<t?(h<n.valueBelowMinimum&&(n.valueBelowMinimum=h),h=t):h>r&&(h>n.valueExceededMaximum&&(n.valueExceededMaximum=h),h=r),c=n.weight/Cu,c>=1||(h=s[0]*(1-c)+h*c),s[0]=h}function $u(s,t,r,i,n,o,h,c){let b=0;const T=Ke.max(r,t);T<s&&(s=T);const C=Ke.min(r,t);C>s&&(s=C);const x=Ke.min(n,o),$=Ke.max(n,o),I=h,B=py(C,T),U=s-B;switch(Math.sign(U)){case 1:{const G=$-I,z=T-B;z!=0&&(b=U*(G/z),b+=I);break}case-1:{const G=x-I,z=C-B;z!=0&&(b=U*(G/z),b+=I);break}case 0:{b=I;break}}return c?b:b*-1}oi.registerRuntime({version:4,ready:Y1,test(s){return s instanceof bn||bn.isValidJSON(s)},isValidMoc(s){if(s.byteLength<4)return!1;const t=new Int8Array(s,0,4);return String.fromCharCode(...t)==="MOC3"},createModelSettings(s){return new bn(s)},createCoreModel(s,t){const r=Tu.create(s,!!(t!=null&&t.checkMocConsistency));try{const i=r.createModel();return i.__moc=r,i}catch(i){try{r.release()}catch{}throw i}},createInternalModel(s,t,r){const i=new H1(s,t,r),n=s;return n.__moc&&(i.__moc=n.__moc,delete n.__moc,i.once("destroy",xy)),i},createPhysics(s,t){return Su.create(t)},createPose(s,t){return wu.create(t)}});function xy(){var s;(s=this.__moc)==null||s.release()}async function by(s){const{models:t,element_id:r,auto_fit:i=!0,auto_motion:n=!0,mouse_tracking:o=!0}=s,h=new Ul({view:document.getElementById(r),width:300,height:300,backgroundAlpha:0,autoDensity:!0,antialias:!0}),c=await _u.from(t[0]);if(h.stage.addChild(c),i){const b=Math.min(300/c.width,300/c.height);c.scale.set(b),c.x=(300-c.width*b)/2,c.y=(300-c.height*b)/2}return o&&Ay(c,h.view),n&&await wy(c),c}function Ay(s,t){document.addEventListener("mousemove",r=>{var b;const i=t.getBoundingClientRect(),n=i.left+i.width/2,o=i.top+i.height/2,h=(r.clientX-n)/i.width,c=(r.clientY-o)/i.height;s.internalModel&&((b=s.internalModel.focusController)==null||b.focus(h,c))})}async function wy(s){var t;try{const r=(t=s.internalModel)==null?void 0:t.motionManager.definitions;if(r)if(r.idle)await s.motion("idle");else if(r.tap_body)await s.motion("tap_body");else{const i=Object.keys(r)[0];i&&await s.motion(i)}}catch(r){console.warn("Failed to start idle animation:",r)}}async function Ty(s,t){_u.registerTicker(vr),be.add(sa),be.add(Dm)}qr.Live2DModel=_u,qr.MotionManager=fo,qr.PIXI=Cm,qr.SoundManager=Mr,qr.createLive2dModel=by,qr.initializeLive2D=Ty,Object.defineProperty(qr,Symbol.toStringTag,{value:"Module"})});
1208
- //# sourceMappingURL=l2d.umd.js.map
1142
+ font-family: "${e.family}";
1143
+ src: url('${e.dataSrc}');
1144
+ font-weight: ${e.weight};
1145
+ font-style: ${e.style};
1146
+ font-display: ${e.display};
1147
+ }`,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=Dl(t)),typeof t=="number"?Rl(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),r=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${r}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,ir.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=q.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}};No.availableFonts={},No.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};let Zs=No;const Vr=class rr extends Ge{constructor(t="",e={}){super(j.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,r=j.from(i,{scaleMode:q.SCALE_MODE,resourceOptions:{autoLoad:!1}});r.orig=new ut,r.trim=new ut,this.texture=r;const n="http://www.w3.org/2000/svg",a="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg"),h=document.createElementNS(n,"foreignObject"),l=document.createElementNS(a,"div"),u=document.createElementNS(a,"style");h.setAttribute("width","10000"),h.setAttribute("height","10000"),h.style.overflow="hidden",o.appendChild(h),this.maxWidth=rr.defaultMaxWidth,this.maxHeight=rr.defaultMaxHeight,this._domElement=l,this._styleElement=u,this._svgRoot=o,this._foreignObject=h,this._foreignObject.appendChild(u),this._foreignObject.appendChild(l),this._image=i,this._loadImage=new Image,this._autoResolution=rr.defaultAutoResolution,this._resolution=rr.defaultResolution??q.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;const{text:e,style:i,resolution:r}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(r)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:a,height:o}=n;(a>this.maxWidth||o>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const h=Math.min(this.maxWidth,Math.ceil(a)),l=Math.min(this.maxHeight,Math.ceil(o));return this._svgRoot.setAttribute("width",h.toString()),this._svgRoot.setAttribute("height",l.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(u=this._style)==null?void 0:u.toCSS(r)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.toGlobalCSS()),{width:h+i.padding*2,height:l+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:r}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:a}=this.measureText();i.width=r.width=Math.ceil(Math.max(1,n)),i.height=r.height=Math.ceil(Math.max(1,a)),this._updateID++;const o=this._updateID;await new Promise(h=>{r.onload=async()=>{if(o<this._updateID){h();return}await e.onBeforeDraw(),i.src=r.src,r.onload=null,r.src="",this.updateTexture(),h()};const l=new XMLSerializer().serializeToString(this._svgRoot);r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(l)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:r}=this,{padding:n}=t,{baseTexture:a}=e;e.trim.width=e._frame.width=i.width/r,e.trim.height=e._frame.height=i.height/r,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),a.setRealSize(i.width,i.height,r),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){var i,r,n,a,o;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},rr.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(r=this._svgRoot)==null||r.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(a=this._foreignObject)==null||a.remove(),this._foreignObject=e,(o=this._styleElement)==null||o.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=Ne(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=Ne(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||{},t instanceof Zs?(this.ownsStyle=!1,this._style=t):t instanceof ze?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Zs.from(t)):(this.ownsStyle=!0,this._style=new Zs(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":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(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};Vr.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Vr.defaultMaxWidth=2024,Vr.defaultMaxHeight=2024,Vr.defaultAutoResolution=!0;const m_=Object.freeze(Object.defineProperty({__proto__:null,ALPHA_MODES:Nt,AbstractMultiResource:ro,AccessibilityManager:co,AlphaFilter:ku,AnimatedSprite:$s,Application:fo,ArrayResource:Ru,Assets:Ir,AssetsClass:hc,Attribute:cr,BLEND_MODES:nt,BUFFER_BITS:rs,BUFFER_TYPE:ue,BackgroundSystem:vr,BaseImageResource:Se,BasePrepare:Ws,BaseRenderTexture:Ba,BaseTexture:lt,BatchDrawCall:ds,BatchGeometry:Sa,BatchRenderer:Ze,BatchShaderGenerator:ru,BatchSystem:Fa,BatchTextureArray:ys,BitmapFont:We,BitmapFontData:Ur,BitmapText:f_,BlobResource:bc,BlurFilter:Nu,BlurFilterPass:Is,Bounds:Cr,BrowserAdapter:Th,Buffer:At,BufferResource:ur,BufferSystem:eo,CLEAR_MODES:le,COLOR_MASK_BITS:bh,Cache:ei,CanvasResource:Du,Circle:fr,Color:gt,ColorMatrixFilter:Rs,CompressedTextureResource:ii,Container:Vt,ContextSystem:xr,CountLimiter:qc,CubeResource:Bu,DEG_TO_RAD:Wl,DRAW_MODES:oe,DisplacementFilter:Uu,DisplayObject:Et,ENV:Zt,Ellipse:pr,EventBoundary:Hu,EventSystem:Ds,ExtensionType:$,Extract:Dc,FORMATS:H,FORMATS_TO_COMPONENTS:Cc,FXAAFilter:Gu,FederatedDisplayObject:zu,FederatedEvent:Li,FederatedMouseEvent:Sr,FederatedPointerEvent:te,FederatedWheelEvent:xi,FillStyle:Lr,Filter:kt,FilterState:ou,FilterSystem:Ua,Framebuffer:vs,FramebufferSystem:Ga,GC_MODES:ss,GLFramebuffer:hu,GLProgram:yu,GLTexture:Cs,GRAPHICS_CURVES:Dg,GenerateTextureSystem:ja,Geometry:Ue,GeometrySystem:Ha,Graphics:So,GraphicsData:Br,GraphicsGeometry:Uc,HTMLText:Vr,HTMLTextStyle:Zs,IGLUniformData:$p,INSTALLED:cs,INTERNAL_FORMATS:Lt,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:Rr,ImageBitmapResource:vi,ImageResource:La,LINE_CAP:He,LINE_JOIN:$t,LineStyle:Hs,LoaderParserPriority:ie,MASK_TYPES:It,MIPMAP_MODES:he,MSAA_QUALITY:St,MaskData:cu,MaskSystem:Xa,Matrix:vt,Mesh:Vi,MeshBatchUvs:Gc,MeshGeometry:Or,MeshMaterial:Hi,MultisampleSystem:to,NineSlicePlane:Ng,NoiseFilter:Vu,ObjectRenderer:_r,ObjectRendererSystem:io,ObservablePoint:pe,PI_2:dr,PRECISION:Xt,ParticleContainer:Vg,ParticleRenderer:Mo,PlaneGeometry:Xc,PluginSystem:Wa,Point:ft,Polygon:Ke,Prepare:Fo,Program:Ae,ProjectionSystem:$a,Quad:au,QuadUv:ka,RAD_TO_DEG:zl,RENDERER_TYPE:bn,Rectangle:ut,RenderTexture:Je,RenderTexturePool:Oa,RenderTextureSystem:Ya,Renderer:Ps,ResizePlugin:po,Resource:Di,RopeGeometry:zc,RoundedRectangle:mr,Runner:Wt,SAMPLER_TYPES:Y,SCALE_MODES:be,SHAPES:Bt,SVGResource:Ms,ScissorSystem:gu,Shader:me,ShaderSystem:qa,SimpleMesh:Ug,SimplePlane:Wc,SimpleRope:Gg,Sprite:Ge,SpriteMaskFilter:uu,Spritesheet:Oo,StartupSystem:Tr,State:fe,StateSystem:Cu,StencilSystem:za,SystemManager:Au,TARGETS:ui,TEXT_GRADIENT:kr,TYPES:it,TYPES_TO_BYTES_PER_COMPONENT:xo,TYPES_TO_BYTES_PER_PIXEL:Ac,TemporaryDisplayObject:oo,Text:Do,TextFormat:Gr,TextMetrics:Xe,TextStyle:ze,Texture:j,TextureGCSystem:Qe,TextureMatrix:Es,TextureSystem:Ka,TextureUvs:xs,Ticker:Pt,TickerPlugin:As,TilingSprite:Bo,TilingSpriteRenderer:Lo,TimeLimiter:i_,Transform:Fi,TransformFeedback:cm,TransformFeedbackSystem:Za,UPDATE_PRIORITY:Pe,UniformGroup:Qt,VERSION:dm,VideoResource:ao,ViewSystem:wr,ViewableBuffer:us,WRAP_MODES:Te,XMLFormat:Ys,XMLStringFormat:qs,accessibleTarget:Wu,autoDetectFormat:id,autoDetectRenderer:Mu,autoDetectResource:Ca,cacheTextureArray:lc,checkDataUrl:bi,checkExtension:Ve,checkMaxIfStatementsInShader:Hl,convertToList:ee,copySearchParams:Bs,createStringVariations:Zu,createTexture:Ni,createUBOElements:bu,curves:ri,defaultFilterVertex:Qa,defaultVertex:Iu,detectAvif:cc,detectCompressedTextures:xc,detectDefaults:pc,detectMp4:gc,detectOgv:_c,detectWebm:mc,detectWebp:dc,extensions:Q,filters:ho,generateProgram:vu,generateUniformBufferSync:Eu,getFontFamilyName:tc,getTestContext:Kl,getUBOData:Tu,graphicsUtils:Lg,groupD8:wt,isMobile:ce,isSingleItem:Pr,loadBitmapFont:hd,loadDDS:Pc,loadImageBitmap:nc,loadJson:Ju,loadKTX:Mc,loadSVG:ac,loadTextures:Mr,loadTxt:Qu,loadVideo:oc,loadWebFont:ec,parseDDS:Ec,parseKTX:Sc,resolveCompressedTextureUrl:Ic,resolveTextureUrl:yc,settings:q,spritesheetAsset:ed,uniformParsers:_i,unsafeEvalSupported:iu,utils:gp},Symbol.toStringTag,{value:"Module"}));var ld=function(){function s(){this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0,this.global=new ft,this.target=null,this.originalEvent=null,this.identifier=null,this.isPrimary=!1,this.button=0,this.buttons=0,this.width=0,this.height=0,this.tiltX=0,this.tiltY=0,this.pointerType=null,this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0}return Object.defineProperty(s.prototype,"pointerId",{get:function(){return this.identifier},enumerable:!1,configurable:!0}),s.prototype.getLocalPosition=function(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)},s.prototype.copyEvent=function(t){"isPrimary"in t&&t.isPrimary&&(this.isPrimary=!0),this.button="button"in t&&t.button;var e="buttons"in t&&t.buttons;this.buttons=Number.isInteger(e)?e:"which"in t&&t.which,this.width="width"in t&&t.width,this.height="height"in t&&t.height,this.tiltX="tiltX"in t&&t.tiltX,this.tiltY="tiltY"in t&&t.tiltY,this.pointerType="pointerType"in t&&t.pointerType,this.pressure="pressure"in t&&t.pressure,this.rotationAngle="rotationAngle"in t&&t.rotationAngle,this.twist="twist"in t&&t.twist||0,this.tangentialPressure="tangentialPressure"in t&&t.tangentialPressure||0},s.prototype.reset=function(){this.isPrimary=!1},s}();var Uo=function(s,t){return Uo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])},Uo(s,t)};function g_(s,t){Uo(s,t);function e(){this.constructor=s}s.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var __=function(){function s(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.target=null,this.currentTarget=null,this.type=null,this.data=null}return s.prototype.stopPropagation=function(){this.stopped=!0,this.stopPropagationHint=!0,this.stopsPropagatingAt=this.currentTarget},s.prototype.reset=function(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.currentTarget=null,this.target=null},s}(),Go=function(){function s(t){this._pointerId=t,this._flags=s.FLAGS.NONE}return s.prototype._doSet=function(t,e){e?this._flags=this._flags|t:this._flags=this._flags&~t},Object.defineProperty(s.prototype,"pointerId",{get:function(){return this._pointerId},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"flags",{get:function(){return this._flags},set:function(t){this._flags=t},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"none",{get:function(){return this._flags===s.FLAGS.NONE},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"over",{get:function(){return(this._flags&s.FLAGS.OVER)!==0},set:function(t){this._doSet(s.FLAGS.OVER,t)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"rightDown",{get:function(){return(this._flags&s.FLAGS.RIGHT_DOWN)!==0},set:function(t){this._doSet(s.FLAGS.RIGHT_DOWN,t)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"leftDown",{get:function(){return(this._flags&s.FLAGS.LEFT_DOWN)!==0},set:function(t){this._doSet(s.FLAGS.LEFT_DOWN,t)},enumerable:!1,configurable:!0}),s.FLAGS=Object.freeze({NONE:0,OVER:1,LEFT_DOWN:2,RIGHT_DOWN:4}),s}(),y_=function(){function s(){this._tempPoint=new ft}return s.prototype.recursiveFindHit=function(t,e,i,r,n){var a;if(!e||!e.visible)return!1;var o=t.data.global;n=e.interactive||n;var h=!1,l=n,u=!0;if(e.hitArea)r&&(e.worldTransform.applyInverse(o,this._tempPoint),e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)?h=!0:(r=!1,u=!1)),l=!1;else if(e._mask&&r){var c=e._mask.isMaskData?e._mask.maskObject:e._mask;c&&!(!((a=c.containsPoint)===null||a===void 0)&&a.call(c,o))&&(r=!1)}if(u&&e.interactiveChildren&&e.children)for(var d=e.children,f=d.length-1;f>=0;f--){var p=d[f],g=this.recursiveFindHit(t,p,i,r,l);if(g){if(!p.parent)continue;l=!1,g&&(t.target&&(r=!1),h=!0)}}return n&&(r&&!t.target&&!e.hitArea&&e.containsPoint&&e.containsPoint(o)&&(h=!0),e.interactive&&(h&&!t.target&&(t.target=e),i&&i(t,e,!!h))),h},s.prototype.findHit=function(t,e,i,r){this.recursiveFindHit(t,e,i,r,!1)},s}(),v_={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return this.cursor==="pointer"},set buttonMode(s){s?this.cursor="pointer":this.cursor==="pointer"&&(this.cursor=null)},cursor:null,get trackedPointers(){return this._trackedPointers===void 0&&(this._trackedPointers={}),this._trackedPointers},_trackedPointers:void 0};Et.mixin(v_);var Js=1,Qs={target:null,data:{global:null}},x_=function(s){g_(t,s);function t(e,i){var r=s.call(this)||this;return i=i||{},r.renderer=e,r.autoPreventDefault=i.autoPreventDefault!==void 0?i.autoPreventDefault:!0,r.interactionFrequency=i.interactionFrequency||10,r.mouse=new ld,r.mouse.identifier=Js,r.mouse.global.set(-999999),r.activeInteractionData={},r.activeInteractionData[Js]=r.mouse,r.interactionDataPool=[],r.eventData=new __,r.interactionDOMElement=null,r.moveWhenInside=!1,r.eventsAdded=!1,r.tickerAdded=!1,r.mouseOverRenderer=!("PointerEvent"in globalThis),r.supportsTouchEvents="ontouchstart"in globalThis,r.supportsPointerEvents=!!globalThis.PointerEvent,r.onPointerUp=r.onPointerUp.bind(r),r.processPointerUp=r.processPointerUp.bind(r),r.onPointerCancel=r.onPointerCancel.bind(r),r.processPointerCancel=r.processPointerCancel.bind(r),r.onPointerDown=r.onPointerDown.bind(r),r.processPointerDown=r.processPointerDown.bind(r),r.onPointerMove=r.onPointerMove.bind(r),r.processPointerMove=r.processPointerMove.bind(r),r.onPointerOut=r.onPointerOut.bind(r),r.processPointerOverOut=r.processPointerOverOut.bind(r),r.onPointerOver=r.onPointerOver.bind(r),r.cursorStyles={default:"inherit",pointer:"pointer"},r.currentCursorMode=null,r.cursor=null,r.resolution=1,r.delayedEvents=[],r.search=new y_,r._tempDisplayObject=new oo,r._eventListenerOptions={capture:!0,passive:!1},r._useSystemTicker=i.useSystemTicker!==void 0?i.useSystemTicker:!0,r.setTargetElement(r.renderer.view,r.renderer.resolution),r}return Object.defineProperty(t.prototype,"useSystemTicker",{get:function(){return this._useSystemTicker},set:function(e){this._useSystemTicker=e,e?this.addTickerListener():this.removeTickerListener()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastObjectRendered",{get:function(){return this.renderer._lastObjectRendered||this._tempDisplayObject},enumerable:!1,configurable:!0}),t.prototype.hitTest=function(e,i){return Qs.target=null,Qs.data.global=e,i||(i=this.lastObjectRendered),this.processInteractive(Qs,i,null,!0),Qs.target},t.prototype.setTargetElement=function(e,i){i===void 0&&(i=1),this.removeTickerListener(),this.removeEvents(),this.interactionDOMElement=e,this.resolution=i,this.addEvents(),this.addTickerListener()},t.prototype.addTickerListener=function(){this.tickerAdded||!this.interactionDOMElement||!this._useSystemTicker||(Pt.system.add(this.tickerUpdate,this,Pe.INTERACTION),this.tickerAdded=!0)},t.prototype.removeTickerListener=function(){this.tickerAdded&&(Pt.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)},t.prototype.addEvents=function(){if(!(this.eventsAdded||!this.interactionDOMElement)){var e=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none"),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerdown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerleave",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerover",this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener("pointercancel",this.onPointerCancel,this._eventListenerOptions),globalThis.addEventListener("pointerup",this.onPointerUp,this._eventListenerOptions)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mousedown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mouseout",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mouseover",this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener("mouseup",this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.addEventListener("touchstart",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchcancel",this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchend",this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchmove",this.onPointerMove,this._eventListenerOptions)),this.eventsAdded=!0}},t.prototype.removeEvents=function(){if(!(!this.eventsAdded||!this.interactionDOMElement)){var e=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerdown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerleave",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerover",this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener("pointercancel",this.onPointerCancel,this._eventListenerOptions),globalThis.removeEventListener("pointerup",this.onPointerUp,this._eventListenerOptions)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mousedown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mouseout",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mouseover",this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener("mouseup",this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.removeEventListener("touchstart",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchcancel",this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchend",this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchmove",this.onPointerMove,this._eventListenerOptions)),this.interactionDOMElement=null,this.eventsAdded=!1}},t.prototype.tickerUpdate=function(e){this._deltaTime+=e,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())},t.prototype.update=function(){if(this.interactionDOMElement){if(this._didMove){this._didMove=!1;return}this.cursor=null;for(var e in this.activeInteractionData)if(this.activeInteractionData.hasOwnProperty(e)){var i=this.activeInteractionData[e];if(i.originalEvent&&i.pointerType!=="touch"){var r=this.configureInteractionEventForDOMEvent(this.eventData,i.originalEvent,i);this.processInteractive(r,this.lastObjectRendered,this.processPointerOverOut,!0)}}this.setCursorMode(this.cursor)}},t.prototype.setCursorMode=function(e){e=e||"default";var i=!0;if(globalThis.OffscreenCanvas&&this.interactionDOMElement instanceof OffscreenCanvas&&(i=!1),this.currentCursorMode!==e){this.currentCursorMode=e;var r=this.cursorStyles[e];if(r)switch(typeof r){case"string":i&&(this.interactionDOMElement.style.cursor=r);break;case"function":r(e);break;case"object":i&&Object.assign(this.interactionDOMElement.style,r);break}else i&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.interactionDOMElement.style.cursor=e)}},t.prototype.dispatchEvent=function(e,i,r){(!r.stopPropagationHint||e===r.stopsPropagatingAt)&&(r.currentTarget=e,r.type=i,e.emit(i,r),e[i]&&e[i](r))},t.prototype.delayDispatchEvent=function(e,i,r){this.delayedEvents.push({displayObject:e,eventString:i,eventData:r})},t.prototype.mapPositionToPoint=function(e,i,r){var n;this.interactionDOMElement.parentElement?n=this.interactionDOMElement.getBoundingClientRect():n={x:0,y:0,width:this.interactionDOMElement.width,height:this.interactionDOMElement.height,left:0,top:0};var a=1/this.resolution;e.x=(i-n.left)*(this.interactionDOMElement.width/n.width)*a,e.y=(r-n.top)*(this.interactionDOMElement.height/n.height)*a},t.prototype.processInteractive=function(e,i,r,n){var a=this.search.findHit(e,i,r,n),o=this.delayedEvents;if(!o.length)return a;e.stopPropagationHint=!1;var h=o.length;this.delayedEvents=[];for(var l=0;l<h;l++){var u=o[l],c=u.displayObject,d=u.eventString,f=u.eventData;f.stopsPropagatingAt===c&&(f.stopPropagationHint=!0),this.dispatchEvent(c,d,f)}return a},t.prototype.onPointerDown=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var i=this.normalizeToPointerData(e);if(this.autoPreventDefault&&i[0].isNormalized){var r=e.cancelable||!("cancelable"in e);r&&e.preventDefault()}for(var n=i.length,a=0;a<n;a++){var o=i[a],h=this.getInteractionDataForPointerId(o),l=this.configureInteractionEventForDOMEvent(this.eventData,o,h);if(l.data.originalEvent=e,this.processInteractive(l,this.lastObjectRendered,this.processPointerDown,!0),this.emit("pointerdown",l),o.pointerType==="touch")this.emit("touchstart",l);else if(o.pointerType==="mouse"||o.pointerType==="pen"){var u=o.button===2;this.emit(u?"rightdown":"mousedown",this.eventData)}}}},t.prototype.processPointerDown=function(e,i,r){var n=e.data,a=e.data.identifier;if(r){if(i.trackedPointers[a]||(i.trackedPointers[a]=new Go(a)),this.dispatchEvent(i,"pointerdown",e),n.pointerType==="touch")this.dispatchEvent(i,"touchstart",e);else if(n.pointerType==="mouse"||n.pointerType==="pen"){var o=n.button===2;o?i.trackedPointers[a].rightDown=!0:i.trackedPointers[a].leftDown=!0,this.dispatchEvent(i,o?"rightdown":"mousedown",e)}}},t.prototype.onPointerComplete=function(e,i,r){var n=this.normalizeToPointerData(e),a=n.length,o=e.target;e.composedPath&&e.composedPath().length>0&&(o=e.composedPath()[0]);for(var h=o!==this.interactionDOMElement?"outside":"",l=0;l<a;l++){var u=n[l],c=this.getInteractionDataForPointerId(u),d=this.configureInteractionEventForDOMEvent(this.eventData,u,c);if(d.data.originalEvent=e,this.processInteractive(d,this.lastObjectRendered,r,i||!h),this.emit(i?"pointercancel":"pointerup"+h,d),u.pointerType==="mouse"||u.pointerType==="pen"){var f=u.button===2;this.emit(f?"rightup"+h:"mouseup"+h,d)}else u.pointerType==="touch"&&(this.emit(i?"touchcancel":"touchend"+h,d),this.releaseInteractionDataForPointerId(u.pointerId))}},t.prototype.onPointerCancel=function(e){this.supportsTouchEvents&&e.pointerType==="touch"||this.onPointerComplete(e,!0,this.processPointerCancel)},t.prototype.processPointerCancel=function(e,i){var r=e.data,n=e.data.identifier;i.trackedPointers[n]!==void 0&&(delete i.trackedPointers[n],this.dispatchEvent(i,"pointercancel",e),r.pointerType==="touch"&&this.dispatchEvent(i,"touchcancel",e))},t.prototype.onPointerUp=function(e){this.supportsTouchEvents&&e.pointerType==="touch"||this.onPointerComplete(e,!1,this.processPointerUp)},t.prototype.processPointerUp=function(e,i,r){var n=e.data,a=e.data.identifier,o=i.trackedPointers[a],h=n.pointerType==="touch",l=n.pointerType==="mouse"||n.pointerType==="pen",u=!1;if(l){var c=n.button===2,d=Go.FLAGS,f=c?d.RIGHT_DOWN:d.LEFT_DOWN,p=o!==void 0&&o.flags&f;r?(this.dispatchEvent(i,c?"rightup":"mouseup",e),p&&(this.dispatchEvent(i,c?"rightclick":"click",e),u=!0)):p&&this.dispatchEvent(i,c?"rightupoutside":"mouseupoutside",e),o&&(c?o.rightDown=!1:o.leftDown=!1)}r?(this.dispatchEvent(i,"pointerup",e),h&&this.dispatchEvent(i,"touchend",e),o&&((!l||u)&&this.dispatchEvent(i,"pointertap",e),h&&(this.dispatchEvent(i,"tap",e),o.over=!1))):o&&(this.dispatchEvent(i,"pointerupoutside",e),h&&this.dispatchEvent(i,"touchendoutside",e)),o&&o.none&&delete i.trackedPointers[a]},t.prototype.onPointerMove=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var i=this.normalizeToPointerData(e);(i[0].pointerType==="mouse"||i[0].pointerType==="pen")&&(this._didMove=!0,this.cursor=null);for(var r=i.length,n=0;n<r;n++){var a=i[n],o=this.getInteractionDataForPointerId(a),h=this.configureInteractionEventForDOMEvent(this.eventData,a,o);h.data.originalEvent=e,this.processInteractive(h,this.lastObjectRendered,this.processPointerMove,!0),this.emit("pointermove",h),a.pointerType==="touch"&&this.emit("touchmove",h),(a.pointerType==="mouse"||a.pointerType==="pen")&&this.emit("mousemove",h)}i[0].pointerType==="mouse"&&this.setCursorMode(this.cursor)}},t.prototype.processPointerMove=function(e,i,r){var n=e.data,a=n.pointerType==="touch",o=n.pointerType==="mouse"||n.pointerType==="pen";o&&this.processPointerOverOut(e,i,r),(!this.moveWhenInside||r)&&(this.dispatchEvent(i,"pointermove",e),a&&this.dispatchEvent(i,"touchmove",e),o&&this.dispatchEvent(i,"mousemove",e))},t.prototype.onPointerOut=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var i=this.normalizeToPointerData(e),r=i[0];r.pointerType==="mouse"&&(this.mouseOverRenderer=!1,this.setCursorMode(null));var n=this.getInteractionDataForPointerId(r),a=this.configureInteractionEventForDOMEvent(this.eventData,r,n);a.data.originalEvent=r,this.processInteractive(a,this.lastObjectRendered,this.processPointerOverOut,!1),this.emit("pointerout",a),r.pointerType==="mouse"||r.pointerType==="pen"?this.emit("mouseout",a):this.releaseInteractionDataForPointerId(n.identifier)}},t.prototype.processPointerOverOut=function(e,i,r){var n=e.data,a=e.data.identifier,o=n.pointerType==="mouse"||n.pointerType==="pen",h=i.trackedPointers[a];r&&!h&&(h=i.trackedPointers[a]=new Go(a)),h!==void 0&&(r&&this.mouseOverRenderer?(h.over||(h.over=!0,this.delayDispatchEvent(i,"pointerover",e),o&&this.delayDispatchEvent(i,"mouseover",e)),o&&this.cursor===null&&(this.cursor=i.cursor)):h.over&&(h.over=!1,this.dispatchEvent(i,"pointerout",this.eventData),o&&this.dispatchEvent(i,"mouseout",e),h.none&&delete i.trackedPointers[a]))},t.prototype.onPointerOver=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var i=this.normalizeToPointerData(e),r=i[0],n=this.getInteractionDataForPointerId(r),a=this.configureInteractionEventForDOMEvent(this.eventData,r,n);a.data.originalEvent=r,r.pointerType==="mouse"&&(this.mouseOverRenderer=!0),this.emit("pointerover",a),(r.pointerType==="mouse"||r.pointerType==="pen")&&this.emit("mouseover",a)}},t.prototype.getInteractionDataForPointerId=function(e){var i=e.pointerId,r;return i===Js||e.pointerType==="mouse"?r=this.mouse:this.activeInteractionData[i]?r=this.activeInteractionData[i]:(r=this.interactionDataPool.pop()||new ld,r.identifier=i,this.activeInteractionData[i]=r),r.copyEvent(e),r},t.prototype.releaseInteractionDataForPointerId=function(e){var i=this.activeInteractionData[e];i&&(delete this.activeInteractionData[e],i.reset(),this.interactionDataPool.push(i))},t.prototype.configureInteractionEventForDOMEvent=function(e,i,r){return e.data=r,this.mapPositionToPoint(r.global,i.clientX,i.clientY),i.pointerType==="touch"&&(i.globalX=r.global.x,i.globalY=r.global.y),r.originalEvent=i,e.reset(),e},t.prototype.normalizeToPointerData=function(e){var i=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(var r=0,n=e.changedTouches.length;r<n;r++){var a=e.changedTouches[r];typeof a.button>"u"&&(a.button=e.touches.length?1:0),typeof a.buttons>"u"&&(a.buttons=e.touches.length?1:0),typeof a.isPrimary>"u"&&(a.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof a.width>"u"&&(a.width=a.radiusX||1),typeof a.height>"u"&&(a.height=a.radiusY||1),typeof a.tiltX>"u"&&(a.tiltX=0),typeof a.tiltY>"u"&&(a.tiltY=0),typeof a.pointerType>"u"&&(a.pointerType="touch"),typeof a.pointerId>"u"&&(a.pointerId=a.identifier||0),typeof a.pressure>"u"&&(a.pressure=a.force||.5),typeof a.twist>"u"&&(a.twist=0),typeof a.tangentialPressure>"u"&&(a.tangentialPressure=0),typeof a.layerX>"u"&&(a.layerX=a.offsetX=a.clientX),typeof a.layerY>"u"&&(a.layerY=a.offsetY=a.clientY),a.isNormalized=!0,i.push(a)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){var o=e;typeof o.isPrimary>"u"&&(o.isPrimary=!0),typeof o.width>"u"&&(o.width=1),typeof o.height>"u"&&(o.height=1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="mouse"),typeof o.pointerId>"u"&&(o.pointerId=Js),typeof o.pressure>"u"&&(o.pressure=.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),o.isNormalized=!0,i.push(o)}else i.push(e);return i},t.prototype.destroy=function(){this.removeEvents(),this.removeTickerListener(),this.removeAllListeners(),this.renderer=null,this.mouse=null,this.eventData=null,this.interactionDOMElement=null,this.onPointerDown=null,this.processPointerDown=null,this.onPointerUp=null,this.processPointerUp=null,this.onPointerCancel=null,this.processPointerCancel=null,this.onPointerMove=null,this.processPointerMove=null,this.onPointerOut=null,this.processPointerOverOut=null,this.onPointerOver=null,this.search=null},t.extension={name:"interaction",type:[$.RendererPlugin,$.CanvasRendererPlugin]},t}(Ee),b_=Object.defineProperty,Ei=Math.pow,T_=(s,t,e)=>t in s?b_(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,I=(s,t,e)=>(T_(s,typeof t!="symbol"?t+"":t,e),e),Ct=(s,t,e)=>new Promise((i,r)=>{var n=h=>{try{o(e.next(h))}catch(l){r(l)}},a=h=>{try{o(e.throw(h))}catch(l){r(l)}},o=h=>h.done?i(h.value):Promise.resolve(h.value).then(n,a);o((e=e.apply(s,t)).next())});const ud=2,cd=2;var tn;(s=>{s.supportMoreMaskDivisions=!0,s.setOpacityFromMotion=!1})(tn||(tn={}));const Xi={motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500},xt={log(s,...t){},warn(s,...t){console.warn(`[${s}]`,...t)},error(s,...t){console.error(`[${s}]`,...t)}};function zi(s,t,e){return s<t?t:s>e?e:s}function E_(s,t){return Math.random()*(t-s)+s}function Hr(s,t,e,i,r){const n=t[i];n!==null&&typeof n===s&&(e[r]=n)}function Xr(s,t,e,i,r){const n=t[i];Array.isArray(n)&&(e[r]=n.filter(a=>a!==null&&typeof a===s))}function w_(s,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(s.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))})})}function C_(s){let t=s.lastIndexOf("/");return t!=-1&&(s=s.slice(0,t)),t=s.lastIndexOf("/"),t!==-1&&(s=s.slice(t+1)),s}function A_(s,t){const e=s.indexOf(t);e!==-1&&s.splice(e,1)}class Vo extends Ee{constructor(t,e){super(),I(this,"tag"),I(this,"settings"),I(this,"expressions",[]),I(this,"defaultExpression"),I(this,"currentExpression"),I(this,"reserveExpressionIndex",-1),I(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return Ct(this,null,function*(){if(!this.definitions[t]){xt.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){xt.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}if(this.expressions[t])return this.expressions[t];const e=yield this._loadExpression(t);return this.expressions[t]=e,e})}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return Ct(this,null,function*(){if(this.definitions.length){const t=[];for(let e=0;e<this.definitions.length;e++)this.expressions[e]!==null&&this.expressions[e]!==this.currentExpression&&e!==this.reserveExpressionIndex&&t.push(e);if(t.length){const e=Math.floor(Math.random()*t.length);return this.setExpression(e)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return Ct(this,null,function*(){if(typeof t!="number"&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length)||t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const e=yield this.loadExpression(t);return!e||this.reserveExpressionIndex!==t?!1:(this.reserveExpressionIndex=-1,this.currentExpression=e,this._setExpression(e),!0)})}update(t,e){return this.isFinished()?!1:this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy");const t=this;t.definitions=void 0,t.expressions=void 0}}const dd=.01,S_=40/7.5,P_=1/(.15*1e3);class M_{constructor(){I(this,"targetX",0),I(this,"targetY",0),I(this,"x",0),I(this,"y",0),I(this,"vx",0),I(this,"vy",0)}focus(t,e,i=!1){this.targetX=zi(t,-1,1),this.targetY=zi(e,-1,1),i&&(this.x=this.targetX,this.y=this.targetY)}update(t){const e=this.targetX-this.x,i=this.targetY-this.y;if(Math.abs(e)<dd&&Math.abs(i)<dd)return;const r=Math.sqrt(Ei(e,2)+Ei(i,2)),n=S_/(1e3/t);let a=n*(e/r)-this.vx,o=n*(i/r)-this.vy;const h=Math.sqrt(Ei(a,2)+Ei(o,2)),l=n*P_*t;h>l&&(a*=l/h,o*=l/h),this.vx+=a,this.vy+=o;const u=Math.sqrt(Ei(this.vx,2)+Ei(this.vy,2)),c=.5*(Math.sqrt(Ei(l,2)+8*l*r)-l);u>c&&(this.vx*=c/u,this.vy*=c/u),this.x+=this.vx,this.y+=this.vy}}class en{constructor(t){I(this,"json"),I(this,"name"),I(this,"url"),I(this,"pose"),I(this,"physics"),this.json=t;const e=t.url;if(typeof e!="string")throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=e,this.name=C_(this.url)}resolveURL(t){return os.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let e=0;e<this.textures.length;e++)this.textures[e]=t(this.textures[e],`textures[${e}]`)}getDefinedFiles(){const t=[];return this.replaceFiles(e=>(t.push(e),e)),t}validateFiles(t){const e=(n,a)=>{const o=this.resolveURL(n);if(!t.includes(o)){if(a)throw new Error(`File "${n}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(n=>e(n,!0)),this.getDefinedFiles().filter(n=>e(n,!1))}}var rn=(s=>(s[s.NONE=0]="NONE",s[s.IDLE=1]="IDLE",s[s.NORMAL=2]="NORMAL",s[s.FORCE=3]="FORCE",s))(rn||{});class I_{constructor(){I(this,"tag"),I(this,"debug",!1),I(this,"currentPriority",0),I(this,"reservePriority",0),I(this,"currentGroup"),I(this,"currentIndex"),I(this,"reservedGroup"),I(this,"reservedIndex"),I(this,"reservedIdleGroup"),I(this,"reservedIdleIndex")}reserve(t,e,i){if(i<=0)return xt.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return xt.log(this.tag,"Motion is already playing.",this.dump(t,e)),!1;if(t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex)return xt.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(i===1){if(this.currentPriority!==0)return xt.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(this.reservedIdleGroup!==void 0)return xt.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(i<3){if(i<=this.currentPriority)return xt.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(i<=this.reservePriority)return xt.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,e)),!1}this.setReserved(t,e,i)}return!0}start(t,e,i,r){if(r===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return xt.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,i)),!1}else{if(e!==this.reservedGroup||i!==this.reservedIndex)return xt.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,i)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(e,i,r),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,i){this.currentPriority=i,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,i){this.reservePriority=i,this.reservedGroup=t,this.reservedIndex=e}setReservedIdle(t,e){this.reservedIdleGroup=t,this.reservedIdleIndex=e}isActive(t,e){return t===this.currentGroup&&e===this.currentIndex||t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!1}dump(t,e){if(this.debug){const i=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
1148
+ <Requested> group = "${t}", index = ${e}
1149
+ `+i.map(r=>"["+r+"] "+this[r]).join(`
1150
+ `)}return""}}const R_="SoundManager",Wi=.5;class Dt{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(t,e,i,r){const n=new Audio(t);return n.volume=this._volume,n.preload="auto",n.crossOrigin=r,n.addEventListener("ended",()=>{this.dispose(n),e==null||e()}),n.addEventListener("error",a=>{this.dispose(n),xt.warn(R_,`Error occurred on "${t}"`,a.error),i==null||i(a.error)}),this.audios.push(n),n}static play(t){return new Promise((e,i)=>{var r;(r=t.play())==null||r.catch(n=>{t.dispatchEvent(new ErrorEvent("error",{error:n})),i(n)}),t.readyState===t.HAVE_ENOUGH_DATA?e():t.addEventListener("canplaythrough",e)})}static addContext(t){const e=new AudioContext;return this.contexts.push(e),e}static addAnalyzer(t,e){const i=e.createMediaElementSource(t),r=e.createAnalyser();return r.fftSize=256,r.minDecibels=-90,r.maxDecibels=-10,r.smoothingTimeConstant=.85,i.connect(r),r.connect(e.destination),this.analysers.push(r),r}static analyze(t){if(t!=null){const e=new Float32Array(t.fftSize);let i=0;t.getFloatTimeDomainData(e);for(const r of e)i+=r*r;return parseFloat(Math.sqrt(i/e.length*20).toFixed(1))}else return parseFloat(Math.random().toFixed(1))}static dispose(t){t.pause(),t.removeAttribute("src"),A_(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--)this.contexts[t].close();for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}I(Dt,"audios",[]),I(Dt,"analysers",[]),I(Dt,"contexts",[]),I(Dt,"_volume",Wi);class zr extends Ee{constructor(t,e){super(),I(this,"tag"),I(this,"settings"),I(this,"motionGroups",{}),I(this,"state",new I_),I(this,"currentAudio"),I(this,"currentAnalyzer"),I(this,"currentContext"),I(this,"playing",!1),I(this,"destroyed",!1),this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];let e;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;case"IDLE":default:e=[this.groups.idle];break}for(const i of e)if(this.definitions[i])for(let r=0;r<this.definitions[i].length;r++)this.loadMotion(i,r).then()}loadMotion(t,e){return Ct(this,null,function*(){var i;if(!((i=this.definitions[t])!=null&&i[e])){xt.warn(this.tag,`Undefined motion at "${t}"[${e}]`);return}if(this.motionGroups[t][e]===null){xt.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);return}if(this.motionGroups[t][e])return this.motionGroups[t][e];const r=yield this._loadMotion(t,e);if(!this.destroyed)return this.motionGroups[t][e]=r??null,r})}_loadMotion(t,e){throw new Error("Not implemented.")}speak(t){return Ct(this,arguments,function*(e,{volume:i=Wi,expression:r,resetExpression:n=!0,crossOrigin:a,onFinish:o,onError:h}={}){let l,u,c;if(this.currentAudio&&!this.currentAudio.ended)return!1;let d;const f=e&&e.startsWith("data:");if(console.log(o),e&&!f){const g=document.createElement("a");g.href=e,e=g.href,d=e}else d="data:audio/";const p=e;if(p)try{l=Dt.add(p,(g=this)=>{console.log("Audio finished playing"),o==null||o(),n&&r&&g.expressionManager&&g.expressionManager.resetExpression(),g.currentAudio=void 0},(g,m=this)=>{console.log("Error during audio playback:",g),h==null||h(g),n&&r&&m.expressionManager&&m.expressionManager.resetExpression(),m.currentAudio=void 0},a),this.currentAudio=l,Dt.volume=i,c=Dt.addContext(this.currentAudio),this.currentContext=c,u=Dt.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=u}catch(g){return xt.warn(this.tag,"Failed to create audio",d,g),!1}if(l){let g=!0;if(yield Dt.play(l).catch(_=>{xt.warn(this.tag,"Failed to play audio",l.src,_),g=!1}),!g)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),r&&this.expressionManager&&this.expressionManager.setExpression(r),this.playing=!0,!0})}startMotion(t,e){return Ct(this,arguments,function*(i,r,n=rn.NORMAL,{sound:a=void 0,volume:o=Wi,expression:h=void 0,resetExpression:l=!0,crossOrigin:u,onFinish:c,onError:d}={}){var f;if(!this.state.reserve(i,r,n)||this.currentAudio&&!this.currentAudio.ended&&n!=rn.FORCE)return!1;const p=(f=this.definitions[i])==null?void 0:f[r];if(!p)return!1;this.currentAudio&&Dt.dispose(this.currentAudio);let g,m,_,b;const y=a&&a.startsWith("data:");if(a&&!y){const M=document.createElement("a");M.href=a,a=M.href,b=a}else b=this.getSoundFile(p),b&&(b=this.settings.resolveURL(b));const E=b;if(E)try{g=Dt.add(E,(M=this)=>{console.log("Audio finished playing"),c==null||c(),console.log(c),l&&h&&M.expressionManager&&M.expressionManager.resetExpression(),M.currentAudio=void 0},(M,T=this)=>{console.log("Error during audio playback:",M),d==null||d(M),l&&h&&T.expressionManager&&T.expressionManager.resetExpression(),T.currentAudio=void 0},u),this.currentAudio=g,Dt.volume=o,_=Dt.addContext(this.currentAudio),this.currentContext=_,m=Dt.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=m}catch(M){xt.warn(this.tag,"Failed to create audio",b,M)}const v=yield this.loadMotion(i,r);return g&&(yield Dt.play(g).catch(T=>xt.warn(this.tag,"Failed to play audio",g.src,T))),this.state.start(v,i,r,n)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),xt.log(this.tag,"Start motion:",this.getMotionName(p)),this.emit("motionStart",i,r,g),h&&this.expressionManager&&this.state.shouldOverrideExpression()&&this.expressionManager.setExpression(h),this.playing=!0,this._startMotion(v),!0):(g&&(Dt.dispose(g),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return Ct(this,arguments,function*(i,r,{sound:n,volume:a=Wi,expression:o,resetExpression:h=!0,crossOrigin:l,onFinish:u,onError:c}={}){const d=this.definitions[i];if(d!=null&&d.length){const f=[];for(let p=0;p<d.length;p++)this.motionGroups[i][p]!==null&&!this.state.isActive(i,p)&&f.push(p);if(f.length){const p=f[Math.floor(Math.random()*f.length)];return this.startMotion(i,p,r,{sound:n,volume:a,expression:o,resetExpression:h,crossOrigin:l,onFinish:u,onError:c})}}return!1})}stopSpeaking(){this.currentAudio&&(Dt.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,e){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((i=this.expressionManager)==null||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,rn.IDLE)),this.updateParameters(t,e)}mouthSync(){return this.currentAnalyzer?Dt.analyze(this.currentAnalyzer):0}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();const e=this;e.definitions=void 0,e.motionGroups=void 0}}const D_={x:0,y:0,width:0,height:0};class fd extends Ee{constructor(){super(...arguments),I(this,"focusController",new M_),I(this,"pose"),I(this,"physics"),I(this,"originalWidth",0),I(this,"originalHeight",0),I(this,"width",0),I(this,"height",0),I(this,"localTransform",new vt),I(this,"drawingMatrix",new vt),I(this,"hitAreas",{}),I(this,"textureFlipY",!1),I(this,"viewport",[0,0,0,0]),I(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const i=Object.assign({width:ud,height:cd},this.getLayout());this.localTransform.scale(i.width/ud,i.height/cd),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const r=i.x!==void 0&&i.x-i.width/2||i.centerX!==void 0&&i.centerX||i.left!==void 0&&i.left-i.width/2||i.right!==void 0&&i.right+i.width/2||0,n=i.y!==void 0&&i.y-i.height/2||i.centerY!==void 0&&i.centerY||i.top!==void 0&&i.top-i.height/2||i.bottom!==void 0&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*r,-this.height*n)}setupHitAreas(){const t=this.getHitAreaDefs().filter(e=>e.index>=0);for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,e))}isHit(t,e,i){if(!this.hitAreas[t])return!1;const r=this.hitAreas[t].index,n=this.getDrawableBounds(r,D_);return n.x<=e&&e<=n.x+n.width&&n.y<=i&&i<=n.y+n.height}getDrawableBounds(t,e){const i=this.getDrawableVertices(t);let r=i[0],n=i[0],a=i[1],o=i[1];for(let h=0;h<i.length;h+=2){const l=i[h],u=i[h+1];r=Math.min(l,r),n=Math.max(l,n),a=Math.min(u,a),o=Math.max(u,o)}return e??(e={}),e.x=r,e.y=a,e.width=n-r,e.height=o-a,e}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,e){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0}}const F_="XHRLoader";class pd extends Error{constructor(t,e,i,r=!1){super(t),this.url=e,this.status=i,this.aborted=r}}const Wr=class Ht{static createXHR(t,e,i,r,n){const a=new XMLHttpRequest;if(Ht.allXhrSet.add(a),t){let o=Ht.xhrMap.get(t);o?o.add(a):(o=new Set([a]),Ht.xhrMap.set(t,o)),t.listeners("destroy").includes(Ht.cancelXHRs)||t.once("destroy",Ht.cancelXHRs)}return a.open("GET",e),a.responseType=i,a.onload=()=>{(a.status===200||a.status===0)&&a.response?r(a.response):a.onerror()},a.onerror=()=>{xt.warn(F_,`Failed to load resource as ${a.responseType} (Status ${a.status}): ${e}`),n(new pd("Network error.",e,a.status))},a.onabort=()=>n(new pd("Aborted.",e,a.status,!0)),a.onloadend=()=>{var o;Ht.allXhrSet.delete(a),t&&((o=Ht.xhrMap.get(t))==null||o.delete(a))},a}static cancelXHRs(){var t;(t=Ht.xhrMap.get(this))==null||t.forEach(e=>{e.abort(),Ht.allXhrSet.delete(e)}),Ht.xhrMap.delete(this)}static release(){Ht.allXhrSet.forEach(t=>t.abort()),Ht.allXhrSet.clear(),Ht.xhrMap=new WeakMap}};I(Wr,"xhrMap",new WeakMap),I(Wr,"allXhrSet",new Set),I(Wr,"loader",(s,t)=>new Promise((e,i)=>{Wr.createXHR(s.target,s.settings?s.settings.resolveURL(s.url):s.url,s.type,n=>{s.result=n,e()},i).send()}));let B_=Wr;function md(s,t){let e=-1;return i(0);function i(r,n){if(n)return Promise.reject(n);if(r<=e)return Promise.reject(new Error("next() called multiple times"));e=r;const a=s[r];if(!a)return Promise.resolve();try{return Promise.resolve(a(t,i.bind(null,r+1)))}catch(o){return Promise.reject(o)}}}class ni{static load(t){return md(this.middlewares,t).then(()=>t.result)}}I(ni,"middlewares",[B_.loader]);function L_(s,t={}){var e;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(j.fromURL)return j.fromURL(s,i).catch(a=>{if(a instanceof Error)throw a;const o=new Error("Texture loading error");throw o.event=a,o});i.resourceOptions.autoLoad=!1;const r=j.from(s,i);if(r.baseTexture.valid)return Promise.resolve(r);const n=r.baseTexture.resource;return(e=n._live2d_load)!=null||(n._live2d_load=new Promise((a,o)=>{const h=l=>{n.source.removeEventListener("error",h);const u=new Error("Texture loading error");u.event=l,o(u)};n.source.addEventListener("error",h),n.load().then(()=>a(r)).catch(h)})),n._live2d_load}function O_(){}const gd="Live2DFactory",_d=(s,t)=>Ct(void 0,null,function*(){if(typeof s.source=="string"){const e=yield ni.load({url:s.source,type:"json",target:s.live2dModel});e.url=s.source,s.source=e,s.live2dModel.emit("settingsJSONLoaded",e)}return t()}),yd=(s,t)=>Ct(void 0,null,function*(){if(s.source instanceof en)return s.settings=s.source,t();if(typeof s.source=="object"){const e=jt.findRuntime(s.source);if(e){const i=e.createModelSettings(s.source);return s.settings=i,s.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),vd=(s,t)=>{if(s.settings){const e=jt.findRuntime(s.settings);if(e)return e.ready().then(t)}return t()},xd=(s,t)=>Ct(void 0,null,function*(){yield t();const e=s.internalModel;if(e){const i=s.settings,r=jt.findRuntime(i);if(r){const n=[];i.pose&&n.push(ni.load({settings:i,url:i.pose,type:"json",target:e}).then(a=>{e.pose=r.createPose(e.coreModel,a),s.live2dModel.emit("poseLoaded",e.pose)}).catch(a=>{s.live2dModel.emit("poseLoadError",a),xt.warn(gd,"Failed to load pose.",a)})),i.physics&&n.push(ni.load({settings:i,url:i.physics,type:"json",target:e}).then(a=>{e.physics=r.createPhysics(e.coreModel,a),s.live2dModel.emit("physicsLoaded",e.physics)}).catch(a=>{s.live2dModel.emit("physicsLoadError",a),xt.warn(gd,"Failed to load physics.",a)})),n.length&&(yield Promise.all(n))}}}),bd=(s,t)=>Ct(void 0,null,function*(){if(s.settings){const e=s.live2dModel,i=Promise.all(s.settings.textures.map(r=>{const n=s.settings.resolveURL(r);return L_(n,{crossOrigin:s.options.crossOrigin})}));if(i.catch(O_),yield t(),s.internalModel)e.internalModel=s.internalModel,e.emit("modelLoaded",s.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield i,e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),Td=(s,t)=>Ct(void 0,null,function*(){const e=s.settings;if(e instanceof en){const i=jt.findRuntime(e);if(!i)throw new TypeError("Unknown model settings.");const r=yield ni.load({settings:e,url:e.moc,type:"arraybuffer",target:s.live2dModel});if(!i.isValidMoc(r))throw new Error("Invalid moc data");const n=i.createCoreModel(r);return s.internalModel=i.createInternalModel(n,e,s.options),t()}throw new TypeError("Missing settings.")}),Gt=class sr{static unzip(t,e){return Ct(this,null,function*(){const i=yield sr.getFilePaths(t),r=[];for(const a of e.getDefinedFiles()){const o=decodeURI(os.resolve(e.url,a));i.includes(o)&&r.push(o)}const n=yield sr.getFiles(t,r);for(let a=0;a<n.length;a++){const o=r[a],h=n[a];Object.defineProperty(h,"webkitRelativePath",{value:o})}return n})}static createSettings(t){return Ct(this,null,function*(){const i=(yield sr.getFilePaths(t)).find(o=>o.endsWith("model.json")||o.endsWith("model3.json"));if(!i)throw new Error("Settings file not found");const r=yield sr.readText(t,i);if(!r)throw new Error("Empty settings file: "+i);const n=JSON.parse(r);n.url=i;const a=sr.live2dFactory.findRuntime(n);if(!a)throw new Error("Unknown settings JSON");return a.createModelSettings(n)})}static zipReader(t,e){return Ct(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(t){return Ct(this,null,function*(){throw new Error("Not implemented")})}static getFiles(t,e){return Ct(this,null,function*(){throw new Error("Not implemented")})}static readText(t,e){return Ct(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(t){}};I(Gt,"live2dFactory"),I(Gt,"ZIP_PROTOCOL","zip://"),I(Gt,"uid",0),I(Gt,"factory",(s,t)=>Ct(Gt,null,function*(){const e=s.source;let i,r,n;if(typeof e=="string"&&(e.endsWith(".zip")||e.startsWith(Gt.ZIP_PROTOCOL))?(e.startsWith(Gt.ZIP_PROTOCOL)?i=e.slice(Gt.ZIP_PROTOCOL.length):i=e,r=yield ni.load({url:i,type:"blob",target:s.live2dModel})):Array.isArray(e)&&e.length===1&&e[0]instanceof File&&e[0].name.endsWith(".zip")&&(r=e[0],i=URL.createObjectURL(r),n=e.settings),r){if(!r.size)throw new Error("Empty zip file");const a=yield Gt.zipReader(r,i);n||(n=yield Gt.createSettings(a)),n._objectURL=Gt.ZIP_PROTOCOL+Gt.uid+"/"+n.url;const o=yield Gt.unzip(a,n);o.settings=n,s.source=o,i.startsWith("blob:")&&s.live2dModel.once("modelLoaded",h=>{h.once("destroy",function(){URL.revokeObjectURL(i)})}),Gt.releaseReader(a)}return t()}));let Ed=Gt;const _e=class vn{static resolveURL(t,e){var i;const r=(i=vn.filesMap[t])==null?void 0:i[e];if(r===void 0)throw new Error("Cannot find this file from uploaded files: "+e);return r}static upload(t,e){return Ct(this,null,function*(){const i={};for(const r of e.getDefinedFiles()){const n=decodeURI(os.resolve(e.url,r)),a=t.find(o=>o.webkitRelativePath===n);a&&(i[r]=URL.createObjectURL(a))}vn.filesMap[e._objectURL]=i})}static createSettings(t){return Ct(this,null,function*(){const e=t.find(o=>o.name.endsWith("model.json")||o.name.endsWith("model3.json"));if(!e)throw new TypeError("Settings file not found");const i=yield vn.readText(e),r=JSON.parse(i);r.url=e.webkitRelativePath;const n=jt.findRuntime(r);if(!n)throw new Error("Unknown settings JSON");const a=n.createModelSettings(r);return a._objectURL=URL.createObjectURL(e),a})}static readText(t){return Ct(this,null,function*(){return new Promise((e,i)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i,r.readAsText(t,"utf8")})})}};I(_e,"live2dFactory"),I(_e,"filesMap",{}),I(_e,"factory",(s,t)=>Ct(_e,null,function*(){if(Array.isArray(s.source)&&s.source[0]instanceof File){const e=s.source;let i=e.settings;if(!i)i=yield _e.createSettings(e);else if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');i.validateFiles(e.map(r=>encodeURI(r.webkitRelativePath))),yield _e.upload(e,i),i.resolveURL=function(r){return _e.resolveURL(this._objectURL,r)},s.source=i,s.live2dModel.once("modelLoaded",r=>{r.once("destroy",function(){const n=this.settings._objectURL;if(URL.revokeObjectURL(n),_e.filesMap[n])for(const a of Object.values(_e.filesMap[n]))URL.revokeObjectURL(a);delete _e.filesMap[n]})})}return t()}));let wd=_e;const ye=class Ot{static registerRuntime(t){Ot.runtimes.push(t),Ot.runtimes.sort((e,i)=>i.version-e.version)}static findRuntime(t){for(const e of Ot.runtimes)if(e.test(t))return e}static setupLive2DModel(t,e,i){return Ct(this,null,function*(){const r=new Promise(o=>t.once("textureLoaded",o)),n=new Promise(o=>t.once("modelLoaded",o)),a=Promise.all([r,n]).then(()=>t.emit("ready"));yield md(Ot.live2DModelMiddlewares,{live2dModel:t,source:e,options:i||{}}),yield a,t.emit("load")})}static loadMotion(t,e,i){var r,n;const a=o=>t.emit("motionLoadError",e,i,o);try{const o=(r=t.definitions[e])==null?void 0:r[i];if(!o)return Promise.resolve(void 0);t.listeners("destroy").includes(Ot.releaseTasks)||t.once("destroy",Ot.releaseTasks);let h=Ot.motionTasksMap.get(t);h||(h={},Ot.motionTasksMap.set(t,h));let l=h[e];l||(l=[],h[e]=l);const u=t.getMotionFile(o);return(n=l[i])!=null||(l[i]=ni.load({url:u,settings:t.settings,type:t.motionDataType,target:t}).then(c=>{var d;const f=(d=Ot.motionTasksMap.get(t))==null?void 0:d[e];f&&delete f[i];const p=t.createMotion(c,e,o);return t.emit("motionLoaded",e,i,p),p}).catch(c=>{xt.warn(t.tag,`Failed to load motion: ${u}
1151
+ `,c),a(c)})),l[i]}catch(o){xt.warn(t.tag,`Failed to load motion at "${e}"[${i}]
1152
+ `,o),a(o)}return Promise.resolve(void 0)}static loadExpression(t,e){var i;const r=n=>t.emit("expressionLoadError",e,n);try{const n=t.definitions[e];if(!n)return Promise.resolve(void 0);t.listeners("destroy").includes(Ot.releaseTasks)||t.once("destroy",Ot.releaseTasks);let a=Ot.expressionTasksMap.get(t);a||(a=[],Ot.expressionTasksMap.set(t,a));const o=t.getExpressionFile(n);return(i=a[e])!=null||(a[e]=ni.load({url:o,settings:t.settings,type:"json",target:t}).then(h=>{const l=Ot.expressionTasksMap.get(t);l&&delete l[e];const u=t.createExpression(h,n);return t.emit("expressionLoaded",e,u),u}).catch(h=>{xt.warn(t.tag,`Failed to load expression: ${o}
1153
+ `,h),r(h)})),a[e]}catch(n){xt.warn(t.tag,`Failed to load expression at [${e}]
1154
+ `,n),r(n)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof zr?Ot.motionTasksMap.delete(this):Ot.expressionTasksMap.delete(this)}};I(ye,"runtimes",[]),I(ye,"urlToJSON",_d),I(ye,"jsonToSettings",yd),I(ye,"waitUntilReady",vd),I(ye,"setupOptionals",xd),I(ye,"setupEssentials",bd),I(ye,"createInternalModel",Td),I(ye,"live2DModelMiddlewares",[Ed.factory,wd.factory,_d,yd,vd,xd,bd,Td]),I(ye,"motionTasksMap",new WeakMap),I(ye,"expressionTasksMap",new WeakMap);let jt=ye;zr.prototype._loadMotion=function(s,t){return jt.loadMotion(this,s,t)},Vo.prototype._loadExpression=function(s){return jt.loadExpression(this,s)},wd.live2dFactory=jt,Ed.live2dFactory=jt;const Cd=class vh{constructor(t,{autoUpdate:e=!0,autoHitTest:i=!0,autoFocus:r=!0,autoInteract:n,ticker:a}={}){I(this,"model"),I(this,"destroyed",!1),I(this,"_ticker"),I(this,"_autoUpdate",!1),I(this,"_autoHitTest",!1),I(this,"_autoFocus",!1),a||(vh.defaultTicker?a=vh.defaultTicker:typeof PIXI<"u"&&(a=PIXI.Ticker.shared)),n!==void 0&&(i=n,r=n,xt.warn(t.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=t,this.ticker=a,this.autoUpdate=e,this.autoHitTest=i,this.autoFocus=r,(i||r)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var e;this._ticker&&this._ticker.remove(sn,this),this._ticker=t,this._autoUpdate&&((e=this._ticker)==null||e.add(sn,this))}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;this.destroyed||(t?this._ticker?(this._ticker.add(sn,this),this._autoUpdate=!0):xt.warn(this.model.tag,"No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI)."):((e=this._ticker)==null||e.remove(sn,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",Sd,this):this.model.off("pointertap",Sd,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?this.model.on("globalpointermove",Pd,this):this.model.off("globalpointermove",Pd,this),this._autoFocus=t)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(t){this.autoHitTest=t,this.autoFocus=t}onTickerUpdate(){const t=this.ticker.deltaMS;this.model.update(t)}onTap(t){this.model.tap(t.global.x,t.global.y)}onPointerMove(t){this.model.focus(t.global.x,t.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};I(Cd,"defaultTicker");let Ad=Cd;function sn(){this.onTickerUpdate()}function Sd(s){this.onTap(s)}function Pd(s){this.onPointerMove(s)}class k_ extends Fi{}const re=new ft,N_=new vt;class Ho extends Vt{constructor(t){super(),I(this,"tag","Live2DModel(uninitialized)"),I(this,"internalModel"),I(this,"textures",[]),I(this,"transform",new k_),I(this,"anchor",new pe(this.onAnchorChange,this,0,0)),I(this,"glContextID",-1),I(this,"elapsedTime",0),I(this,"deltaTime",0),I(this,"automator"),this.automator=new Ad(this,t),this.once("modelLoaded",()=>this.init(t))}static from(t,e){const i=new this(e);return jt.setupLive2DModel(i,t,e).then(()=>i)}static fromSync(t,e){const i=new this(e);return jt.setupLive2DModel(i,t,e).then(e==null?void 0:e.onLoad).catch(e==null?void 0:e.onError),i}static registerTicker(t){Ad.defaultTicker=t.shared}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,i,{sound:r=void 0,volume:n=Wi,expression:a=void 0,resetExpression:o=!0,crossOrigin:h,onFinish:l,onError:u}={}){return e===void 0?this.internalModel.motionManager.startRandomMotion(t,i,{sound:r,volume:n,expression:a,resetExpression:o,crossOrigin:h,onFinish:l,onError:u}):this.internalModel.motionManager.startMotion(t,e,i,{sound:r,volume:n,expression:a,resetExpression:o,crossOrigin:h,onFinish:l,onError:u})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:e=Wi,expression:i,resetExpression:r=!0,crossOrigin:n,onFinish:a,onError:o}={}){return this.internalModel.motionManager.speak(t,{volume:e,expression:i,resetExpression:r,crossOrigin:n,onFinish:a,onError:o})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,e,i=!1){re.x=t,re.y=e,this.toModelPosition(re,re,!0);const r=re.x/this.internalModel.originalWidth*2-1,n=re.y/this.internalModel.originalHeight*2-1,a=Math.atan2(n,r);this.internalModel.focusController.focus(Math.cos(a),-Math.sin(a),i)}tap(t,e){const i=this.hitTest(t,e);i.length&&(xt.log(this.tag,"Hit",i),this.emit("hit",i))}hitTest(t,e){return re.x=t,re.y=e,this.toModelPosition(re,re),this.internalModel.hitTest(re.x,re.y)}toModelPosition(t,e=t.clone(),i){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,e),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let e=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),e=!0);for(let n=0;n<this.textures.length;n++){const a=this.textures[n];a.valid&&((e||!a.baseTexture._glTextures[this.glContextID])&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(a.baseTexture,0)),this.internalModel.bindTexture(n,a.baseTexture._glTextures[this.glContextID].texture),a.baseTexture.touched=t.textureGC.count)}const i=t.framebuffer.viewport;this.internalModel.viewport=[i.x,i.y,i.width,i.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const r=N_.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(r),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),t!=null&&t.texture&&this.textures.forEach(e=>e.destroy(t.baseTexture)),this.automator.destroy(),this.internalModel.destroy(),super.destroy(t)}}if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const U_=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(s,t){U_.call(this,s,t),t.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class G_ extends AMotion{constructor(t){super(),I(this,"params",[]),this.setFadeIn(t.fade_in>0?t.fade_in:Xi.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:Xi.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach(e=>{const i=e.calc||"add";if(i==="add"){const r=e.def||0;e.val-=r}else if(i==="mult"){const r=e.def||1;e.val/=r}this.params.push({calc:i,val:e.val,id:e.id})})}updateParamExe(t,e,i,r){this.params.forEach(n=>{t.setParamFloat(n.id,n.val*i)})}}class V_ extends Vo{constructor(t,e){var i;super(t,e),I(this,"queueManager",new MotionQueueManager),I(this,"definitions"),this.definitions=(i=this.settings.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(e=>e.name===t)}getExpressionFile(t){return t.file}createExpression(t,e){return new G_(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}}class H_ extends zr{constructor(t,e){super(t,e),I(this,"definitions"),I(this,"groups",{idle:"idle"}),I(this,"motionDataType","arraybuffer"),I(this,"queueManager",new MotionQueueManager),I(this,"lipSyncIds"),I(this,"expressionManager"),this.definitions=this.settings.motions,this.init(e),this.lipSyncIds=["PARAM_MOUTH_OPEN_Y"]}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new V_(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,e,i){const r=Live2DMotion.loadMotion(t),n=e===this.groups.idle?Xi.idleMotionFadingDuration:Xi.motionFadingDuration;return r.setFadeIn(i.fade_in>0?i.fade_in:n),r.setFadeOut(i.fade_out>0?i.fade_out:n),r}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,e){return t.onFinishHandler=e,this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}}class X_{constructor(t){I(this,"leftParam"),I(this,"rightParam"),I(this,"blinkInterval",4e3),I(this,"closingDuration",100),I(this,"closedDuration",50),I(this,"openingDuration",150),I(this,"eyeState",0),I(this,"eyeParamValue",1),I(this,"closedTimer",0),I(this,"nextBlinkTimeLeft",this.blinkInterval),this.coreModel=t,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN")}setEyeParams(t){this.eyeParamValue=zi(t,0,1),this.coreModel.setParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.setParamFloat(this.rightParam,this.eyeParamValue)}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.nextBlinkTimeLeft=this.blinkInterval+this.closingDuration+this.closedDuration+this.openingDuration+E_(0,2e3));break;case 1:this.setEyeParams(this.eyeParamValue+t/this.closingDuration),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0);break;case 2:this.closedTimer+=t,this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.setEyeParams(this.eyeParamValue+t/this.openingDuration),this.eyeParamValue>=1&&(this.eyeState=0)}}}const wi=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class z_ extends fd{constructor(t,e,i){super(),I(this,"settings"),I(this,"coreModel"),I(this,"motionManager"),I(this,"eyeBlink"),I(this,"eyeballXParamIndex"),I(this,"eyeballYParamIndex"),I(this,"angleXParamIndex"),I(this,"angleYParamIndex"),I(this,"angleZParamIndex"),I(this,"bodyAngleXParamIndex"),I(this,"breathParamIndex"),I(this,"textureFlipY",!0),I(this,"lipSync",!0),I(this,"drawDataCount",0),I(this,"disableCulling",!1),I(this,"hasDrawn",!1),this.coreModel=t,this.settings=e,this.motionManager=new H_(e,i),this.eyeBlink=new X_(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach(({id:n,value:a})=>this.coreModel.setParamFloat(n,a)),this.settings.initOpacities&&this.settings.initOpacities.forEach(({id:n,value:a})=>this.coreModel.setPartsOpacity(n,a)),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;t!=null&&t.length&&(this.drawDataCount=t.length);let e=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:n=>e=n,get:()=>this.disableCulling?!1:e});const i=this.coreModel.getModelContext().clipManager,r=i.setupClip;i.setupClip=(n,a)=>{r.call(i,n,a),a.gl.viewport(...this.viewport)}}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const[e,i]of Object.entries(this.settings.layout)){let r=e;e==="center_x"?r="centerX":e==="center_y"&&(r="centerY"),t[r]=i}return t}updateWebGLContext(t,e){const i=this.coreModel.drawParamWebGL;i.firstDraw=!0,i.setGL(t),i.glno=e;for(const[a,o]of Object.entries(i))o instanceof WebGLBuffer&&(i[a]=null);const r=this.coreModel.getModelContext().clipManager;r.curFrameNo=e;const n=t.getParameter(t.FRAMEBUFFER_BINDING);r.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,n)}bindTexture(t,e){this.coreModel.setTexture(t,e)}getHitAreaDefs(){var t;return((t=this.settings.hitAreas)==null?void 0:t.map(e=>({id:e.id,name:e.name,index:this.coreModel.getDrawDataIndex(e.id)})))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),e=[];for(let i=0;i<this.drawDataCount;i++){const r=t.getDrawData(i);r&&e.push(r.getDrawDataID().id)}return e}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawDataIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}hitTest(t,e){return this.hasDrawn||xt.warn("Trying to hit-test a Cubism 2 model that has not been rendered yet. The result will always be empty since the draw data is not ready."),super.hitTest(t,e)}update(t,e){var i,r,n,a;super.update(t,e);const o=this.coreModel;this.emit("beforeMotionUpdate");const h=this.motionManager.update(this.coreModel,e);if(this.emit("afterMotionUpdate"),o.saveParam(),(i=this.motionManager.expressionManager)==null||i.update(o,e),h||(r=this.eyeBlink)==null||r.update(t),this.updateFocus(),this.updateNaturalMovements(t,e),this.lipSync&&this.motionManager.currentAudio){let l=this.motionManager.mouthSync(),u=0;const c=1,d=1.2,f=.7;l>0&&(u=.4),l=Math.pow(l,f),l=zi(l*d,u,c);for(let p=0;p<this.motionManager.lipSyncIds.length;++p)this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[p]),l)}(n=this.physics)==null||n.update(e),(a=this.pose)==null||a.update(t),this.emit("beforeModelUpdate"),o.update(),o.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,this.focusController.x*30),this.coreModel.addToParamFloat(this.angleYParamIndex,this.focusController.y*30),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,this.focusController.x*10)}updateNaturalMovements(t,e){const i=e/1e3*2*Math.PI;this.coreModel.addToParamFloat(this.angleXParamIndex,15*Math.sin(i/6.5345)*.5),this.coreModel.addToParamFloat(this.angleYParamIndex,8*Math.sin(i/3.5345)*.5),this.coreModel.addToParamFloat(this.angleZParamIndex,10*Math.sin(i/5.5345)*.5),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,4*Math.sin(i/15.5345)*.5),this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(i/3.2345))}draw(t){const e=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const i=this.drawingMatrix;wi[0]=i.a,wi[1]=i.b,wi[4]=i.c,wi[5]=i.d,wi[12]=i.tx,wi[13]=i.ty,this.coreModel.setMatrix(wi),this.coreModel.draw(),this.hasDrawn=!0,this.disableCulling=e}destroy(){super.destroy(),this.coreModel=void 0}}class $r extends en{constructor(t){if(super(t),I(this,"moc"),I(this,"textures"),I(this,"layout"),I(this,"hitAreas"),I(this,"initParams"),I(this,"initOpacities"),I(this,"expressions"),I(this,"motions",{}),!$r.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,Xr("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var e;return!!t&&typeof t.model=="string"&&((e=t.textures)==null?void 0:e.length)>0&&t.textures.every(i=>typeof i=="string")}copy(t){Hr("string",t,this,"name","name"),Hr("string",t,this,"pose","pose"),Hr("string",t,this,"physics","physics"),Hr("object",t,this,"layout","layout"),Hr("object",t,this,"motions","motions"),Xr("object",t,this,"hit_areas","hitAreas"),Xr("object",t,this,"expressions","expressions"),Xr("object",t,this,"init_params","initParams"),Xr("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[e,i]of Object.entries(this.motions))for(let r=0;r<i.length;r++)i[r].file=t(i[r].file,`motions.${e}[${r}].file`),i[r].sound!==void 0&&(i[r].sound=t(i[r].sound,`motions.${e}[${r}].sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].file=t(this.expressions[e].file,`expressions[${e}].file`)}}const W_={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},$_={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class j_{constructor(t,e){I(this,"physicsHairs",[]),this.coreModel=t,e.physics_hair&&(this.physicsHairs=e.physics_hair.map(i=>{const r=new PhysicsHair;return r.setup(i.setup.length,i.setup.regist,i.setup.mass),i.src.forEach(({id:n,ptype:a,scale:o,weight:h})=>{const l=W_[a];l&&r.addSrcParam(l,n,o,h)}),i.targets.forEach(({id:n,ptype:a,scale:o,weight:h})=>{const l=$_[a];l&&r.addTargetParam(l,n,o,h)}),r}))}update(t){this.physicsHairs.forEach(e=>e.update(this.coreModel,t))}}class Md{constructor(t){I(this,"paramIndex",-1),I(this,"partsIndex",-1),I(this,"link",[]),this.id=t}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class Y_{constructor(t,e){I(this,"opacityAnimDuration",500),I(this,"partsGroups",[]),this.coreModel=t,e.parts_visible&&(this.partsGroups=e.parts_visible.map(({group:i})=>i.map(({id:r,link:n})=>{const a=new Md(r);return n&&(a.link=n.map(o=>new Md(o))),a})),this.init())}init(){this.partsGroups.forEach(t=>{t.forEach(e=>{if(e.initIndex(this.coreModel),e.paramIndex>=0){const i=this.coreModel.getParamFloat(e.paramIndex)!==0;this.coreModel.setPartsOpacity(e.partsIndex,i?1:0),this.coreModel.setParamFloat(e.paramIndex,i?1:0),e.link.length>0&&e.link.forEach(r=>r.initIndex(this.coreModel))}})})}normalizePartsOpacityGroup(t,e){const i=this.coreModel,r=.5,n=.15;let a=1,o=t.findIndex(({paramIndex:h,partsIndex:l})=>l>=0&&i.getParamFloat(h)!==0);if(o>=0){const h=i.getPartsOpacity(t[o].partsIndex);a=zi(h+e/this.opacityAnimDuration,0,1)}else o=0,a=1;t.forEach(({partsIndex:h},l)=>{if(h>=0)if(o==l)i.setPartsOpacity(h,a);else{let u=i.getPartsOpacity(h),c;a<r?c=a*(r-1)/r+1:c=(1-a)*r/(1-r),(1-c)*(1-a)>n&&(c=1-n/(1-a)),u>c&&(u=c),i.setPartsOpacity(h,u)}})}copyOpacity(t){const e=this.coreModel;t.forEach(({partsIndex:i,link:r})=>{if(i>=0&&r){const n=e.getPartsOpacity(i);r.forEach(({partsIndex:a})=>{a>=0&&e.setPartsOpacity(a,n)})}})}update(t){this.partsGroups.forEach(e=>{this.normalizePartsOpacityGroup(e,t),this.copyOpacity(e)})}}if(jt.registerRuntime({version:2,test(s){return s instanceof $r||$r.isValidJSON(s)},ready(){return Promise.resolve()},isValidMoc(s){if(s.byteLength<3)return!1;const t=new Int8Array(s,0,3);return String.fromCharCode(...t)==="moc"},createModelSettings(s){return new $r(s)},createCoreModel(s){const t=Live2DModelWebGL.loadModel(s),e=Live2D.getError();if(e)throw e;return t},createInternalModel(s,t,e){return new z_(s,t,e)},createPose(s,t){return new Y_(s,t)},createPhysics(s,t){return new j_(s,t)}}),!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class at{constructor(t,e){this.x=t||0,this.y=e||0}add(t){const e=new at(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new at(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new at(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new at(t,t))}division(t){const e=new at(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new at(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}const Id=class xn{static range(t,e,i){return t<e?t=e:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(t===0)return t;let e=t;const i=e<0;i&&(e=-e);let r;return e===1/0?r=1/0:(r=Math.exp(Math.log(e)/3),r=(e/(r*r)+2*r)/3),i?-r:r}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,e){return t>e?t:e}static min(t,e){return t>e?e:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return t*180/Math.PI}static directionToRadian(t,e){const i=Math.atan2(e.y,e.x),r=Math.atan2(t.y,t.x);let n=i-r;for(;n<-Math.PI;)n+=Math.PI*2;for(;n>Math.PI;)n-=Math.PI*2;return n}static directionToDegrees(t,e){const i=this.directionToRadian(t,e);let r=this.radianToDegrees(i);return e.x-t.x>0&&(r=-r),r}static radianToDirection(t){const e=new at;return e.x=this.sin(t),e.y=this.cos(t),e}static quadraticEquation(t,e,i){return this.abs(t)<xn.Epsilon?this.abs(e)<xn.Epsilon?-i:-i/e:-(e+this.sqrt(e*e-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,e,i,r){if(this.sqrt(t)<xn.Epsilon)return this.range(this.quadraticEquation(e,i,r),0,1);const n=e/t,a=i/t,o=r/t,h=(3*a-n*n)/3,l=h/3,u=(2*n*n*n-9*n*a+27*o)/27,c=u/2,d=c*c+l*l*l,f=.5,p=f+.01;if(d<0){const y=-h/3,E=y*y*y,v=this.sqrt(E),M=-u/(2*v),T=this.range(M,-1,1),P=Math.acos(T),G=2*this.cbrt(v),z=G*this.cos(P/3)-n/3;if(this.abs(z-f)<p)return this.range(z,0,1);const D=G*this.cos((P+2*Math.PI)/3)-n/3;if(this.abs(D-f)<p)return this.range(D,0,1);const O=G*this.cos((P+4*Math.PI)/3)-n/3;return this.range(O,0,1)}if(d==0){let y;c<0?y=this.cbrt(-c):y=-this.cbrt(c);const E=2*y-n/3;if(this.abs(E-f)<p)return this.range(E,0,1);const v=-y-n/3;return this.range(v,0,1)}const g=this.sqrt(d),m=this.cbrt(g-c),_=this.cbrt(g+c),b=m-_-n/3;return this.range(b,0,1)}constructor(){}};Id.Epsilon=1e-5;let mt=Id;class se{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,i){const r=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),n=4;for(let a=0;a<n;++a)for(let o=0;o<n;++o)for(let h=0;h<n;++h)r[o+a*4]+=t[h+a*4]*e[o+h*4];for(let a=0;a<16;++a)i[a]=r[a]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let e=0;e<16;++e)this._tr[e]=t[e]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,e){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);se.multiply(i,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){const i=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);se.multiply(i,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){se.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new se;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}class Xo{initialize(t){this._model=t}drawModel(){this.getModel()!=null&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,i,r){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),r<0?r=0:r>1&&(r=1),this._modelColor.R=t,this._modelColor.G=e,this._modelColor.B=i,this._modelColor.A=r}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._modelColor=new Yt,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new se,this._mvpMatrix4x4.loadIdentity()}}var $e=(s=>(s[s.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",s[s.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",s[s.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",s))($e||{});class Yt{constructor(t=1,e=1,i=1,r=1){this.R=t,this.G=e,this.B=i,this.A=r}}let Re=!1,$i=!1,ji;const zo={vertexOffset:0,vertexStep:2};class jr{static startUp(t){if(Re)return Yr("CubismFramework.startUp() is already done."),Re;if(Live2DCubismCore._isStarted)return Re=!0,!0;if(Live2DCubismCore._isStarted=!0,ji=t,ji&&Live2DCubismCore.Logging.csmSetLogFunction(ji.logFunction),Re=!0,Re){const e=Live2DCubismCore.Version.csmGetVersion(),i=(e&4278190080)>>24,r=(e&16711680)>>16,n=e&65535,a=e;Yr("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+r).slice(-2),("0000"+n).slice(-4),a)}return Yr("CubismFramework.startUp() is complete."),Re}static cleanUp(){Re=!1,$i=!1,ji=void 0}static initialize(t=0){if(!Re){Ci("CubismFramework is not started.");return}if($i){Ci("CubismFramework.initialize() skipped, already initialized.");return}Live2DCubismCore.Memory.initializeAmountOfMemory(t),$i=!0,Yr("CubismFramework.initialize() is complete.")}static dispose(){if(!Re){Ci("CubismFramework is not started.");return}if(!$i){Ci("CubismFramework.dispose() skipped, not initialized.");return}Xo.staticRelease(),$i=!1,Yr("CubismFramework.dispose() is complete.")}static isStarted(){return Re}static isInitialized(){return $i}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return ji!=null?ji.loggingLevel:5}constructor(){}}var Yi=(s=>(s[s.LogLevel_Verbose=0]="LogLevel_Verbose",s[s.LogLevel_Debug=1]="LogLevel_Debug",s[s.LogLevel_Info=2]="LogLevel_Info",s[s.LogLevel_Warning=3]="LogLevel_Warning",s[s.LogLevel_Error=4]="LogLevel_Error",s[s.LogLevel_Off=5]="LogLevel_Off",s))(Yi||{});const qi=typeof process<"u"&&process.env.NODE_ENV==="production"?()=>{}:s=>console.assert(s);function Rd(s,...t){nn.print(Yi.LogLevel_Debug,"[CSM][D]"+s+`
1155
+ `,t)}function Yr(s,...t){nn.print(Yi.LogLevel_Info,"[CSM][I]"+s+`
1156
+ `,t)}function Ci(s,...t){nn.print(Yi.LogLevel_Warning,"[CSM][W]"+s+`
1157
+ `,t)}function De(s,...t){nn.print(Yi.LogLevel_Error,"[CSM][E]"+s+`
1158
+ `,t)}class nn{static print(t,e,i){if(t<jr.getLoggingLevel())return;const r=jr.coreLogFunction;if(!r)return;const n=e.replace(/{(\d+)}/g,(a,o)=>i[o]);r(n)}static dumpBytes(t,e,i){for(let r=0;r<i;r++)r%16==0&&r>0?this.print(t,`
1159
+ `):r%8==0&&r>0&&this.print(t," "),this.print(t,"{0} ",[e[r]&255]);this.print(t,`
1160
+ `)}constructor(){}}class Dd{constructor(){this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._firedEventValues=[]}release(){this._weight=0}updateParameters(t,e,i){if(!e.isAvailable()||e.isFinished())return;if(!e.isStarted()){e.setIsStarted(!0),e.setStartTime(i-this._offsetSeconds),e.setFadeInStartTime(i);const o=this.getDuration();e.getEndTime()<0&&e.setEndTime(o<=0?-1:e.getStartTime()+o)}let r=this._weight;const n=this._fadeInSeconds==0?1:mt.getEasingSine((i-e.getFadeInStartTime())/this._fadeInSeconds),a=this._fadeOutSeconds==0||e.getEndTime()<0?1:mt.getEasingSine((e.getEndTime()-i)/this._fadeOutSeconds);r=r*n*a,e.setState(i,r),qi(0<=r&&r<=1),this.doUpdateParameters(t,i,r,e),e.getEndTime()>0&&e.getEndTime()<i&&e.setIsFinished(!0)}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}getFiredEvent(t,e){return this._firedEventValues}setFinishedMotionHandler(t){this._onFinishedMotion=t}getFinishedMotionHandler(){return this._onFinishedMotion}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){}getModelOpacityValue(){return 1}}const Fd=1;class Wo extends Dd{static create(t){const e=new Wo;return e.parse(t),e}doUpdateParameters(t,e,i,r){for(let n=0;n<this._parameters.length;++n){const a=this._parameters[n];switch(a.blendType){case 0:{t.addParameterValueById(a.parameterId,a.value,i);break}case 1:{t.multiplyParameterValueById(a.parameterId,a.value,i);break}case 2:{t.setParameterValueById(a.parameterId,a.value,i);break}}}}parse(t){this.setFadeInTime(t.FadeInTime!=null?t.FadeInTime:Fd),this.setFadeOutTime(t.FadeOutTime!=null?t.FadeOutTime:Fd);const e=(t.Parameters||[]).length;for(let i=0;i<e;++i){const r=t.Parameters[i],n=r.Id,a=r.Value;let o;!r.Blend||r.Blend==="Add"?o=0:r.Blend==="Multiply"?o=1:r.Blend==="Overwrite"?o=2:o=0;const h={parameterId:n,blendType:o,value:a};this._parameters.push(h)}}constructor(){super(),this._parameters=[]}}class q_{constructor(){this._autoDelete=!1,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&this._motion.release()}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,e){const i=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||i<this._endTimeSeconds)&&(this._endTimeSeconds=i)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,e){this._stateTimeSeconds=t,this._stateWeight=e}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}}class Bd{constructor(){this._userTimeSeconds=0,this._eventCustomData=null,this._motions=[]}release(){for(let t=0;t<this._motions.length;++t)this._motions[t]&&this._motions[t].release();this._motions=void 0}startMotion(t,e,i){if(t==null)return K_;let r;for(let n=0;n<this._motions.length;++n)r=this._motions[n],r!=null&&r.setFadeOut(r._motion.getFadeOutTime());return r=new q_,r._autoDelete=e,r._motion=t,this._motions.push(r),r._motionQueueEntryHandle}isFinished(){let t=0;for(;t<this._motions.length;){const e=this._motions[t];if(e==null){this._motions.splice(t,1);continue}if(e._motion==null){e.release(),this._motions.splice(t,1);continue}if(!e.isFinished())return!1;t++}return!0}isFinishedByHandle(t){for(let e=0;e<this._motions.length;e++){const i=this._motions[e];if(i!=null&&i._motionQueueEntryHandle==t&&!i.isFinished())return!1}return!0}stopAllMotions(){for(let t=0;t<this._motions.length;t++){const e=this._motions[t];e!=null&&e.release()}this._motions=[]}getCubismMotionQueueEntry(t){return this._motions.find(e=>e!=null&&e._motionQueueEntryHandle==t)}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let i=!1,r=0;for(;r<this._motions.length;){const n=this._motions[r];if(n==null){this._motions.splice(r,1);continue}const a=n._motion;if(a==null){n.release(),this._motions.splice(r,1);continue}a.updateParameters(t,n,e),i=!0;const o=a.getFiredEvent(n.getLastCheckEventSeconds()-n.getStartTime(),e-n.getStartTime());for(let h=0;h<o.length;++h)this._eventCallBack(this,o[h],this._eventCustomData);n.setLastCheckEventSeconds(e),n.isFinished()?(n.release(),this._motions.splice(r,1)):(n.isTriggeredFadeOut()&&n.startFadeOut(n.getFadeOutSeconds(),e),r++)}return i}}const K_=-1;class Z_ extends Vo{constructor(t,e){var i;super(t,e),I(this,"queueManager",new Bd),I(this,"definitions"),this.definitions=(i=t.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(e=>e.Name===t)}getExpressionFile(t){return t.File}createExpression(t,e){return Wo.create(t)}_setExpression(t){return this.queueManager.startMotion(t,!1,performance.now())}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}}var Fe=(s=>(s[s.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",s[s.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",s[s.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",s))(Fe||{}),Be=(s=>(s[s.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",s[s.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",s[s.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",s[s.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",s))(Be||{});class ai{constructor(t=0,e=0){this.time=t,this.value=e}}class J_{constructor(){this.basePointIndex=0,this.segmentType=0}}class Q_{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class ty{constructor(){this.fireTime=0,this.value=""}}class ey{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}}class Ld{constructor(t){this._json=t}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(t){return t==0?!!this._json.Meta.AreBeziersRestricted:!1}getMotionCurveCount(){return this._json.Meta.CurveCount}getMotionFps(){return this._json.Meta.Fps}getMotionTotalSegmentCount(){return this._json.Meta.TotalSegmentCount}getMotionTotalPointCount(){return this._json.Meta.TotalPointCount}getMotionFadeInTime(){return this._json.Meta.FadeInTime}getMotionFadeOutTime(){return this._json.Meta.FadeOutTime}getMotionCurveTarget(t){return this._json.Curves[t].Target}getMotionCurveId(t){return this._json.Curves[t].Id}getMotionCurveFadeInTime(t){return this._json.Curves[t].FadeInTime}getMotionCurveFadeOutTime(t){return this._json.Curves[t].FadeOutTime}getMotionCurveSegmentCount(t){return this._json.Curves[t].Segments.length}getMotionCurveSegment(t,e){return this._json.Curves[t].Segments[e]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(t){return this._json.UserData[t].Time}getEventValue(t){return this._json.UserData[t].Value}}var Od=(s=>(s[s.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",s))(Od||{});const iy="EyeBlink",ry="LipSync",sy="Model",ny="Parameter",ay="PartOpacity",an="Opacity",oy=!1;function ne(s,t,e){const i=new ai;return i.time=s.time+(t.time-s.time)*e,i.value=s.value+(t.value-s.value)*e,i}function hy(s,t){let e=(t-s[0].time)/(s[1].time-s[0].time);return e<0&&(e=0),s[0].value+(s[1].value-s[0].value)*e}function ly(s,t){let e=(t-s[0].time)/(s[3].time-s[0].time);e<0&&(e=0);const i=ne(s[0],s[1],e),r=ne(s[1],s[2],e),n=ne(s[2],s[3],e),a=ne(i,r,e),o=ne(r,n,e);return ne(a,o,e).value}function uy(s,t){const e=t,i=s[0].time,r=s[3].time,n=s[1].time,a=s[2].time,o=r-3*a+3*n-i,h=3*a-6*n+3*i,l=3*n-3*i,u=i-e,c=mt.cardanoAlgorithmForBezier(o,h,l,u),d=ne(s[0],s[1],c),f=ne(s[1],s[2],c),p=ne(s[2],s[3],c),g=ne(d,f,c),m=ne(f,p,c);return ne(g,m,c).value}function cy(s,t){return s[0].value}function dy(s,t){return s[1].value}function $o(s,t,e){const i=s.curves[t];let r=-1;const n=i.baseSegmentIndex+i.segmentCount;let a=0;for(let h=i.baseSegmentIndex;h<n;++h)if(a=s.segments[h].basePointIndex+(s.segments[h].segmentType==Be.CubismMotionSegmentType_Bezier?3:1),s.points[a].time>e){r=h;break}if(r==-1)return s.points[a].value;const o=s.segments[r];return o.evaluate(s.points.slice(o.basePointIndex),e)}class jo extends Dd{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._modelOpacity=1}static create(t,e){const i=new jo;return i.parse(t),i._sourceFrameRate=i._motionData.fps,i._loopDurationSeconds=i._motionData.duration,i._onFinishedMotion=e,i}doUpdateParameters(t,e,i,r){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=iy),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=ry),this._modelCurveIdOpacity==null&&(this._modelCurveIdOpacity=an);let n=e-r.getStartTime();n<0&&(n=0);let a=Number.MAX_VALUE,o=Number.MAX_VALUE;const h=64;let l=0,u=0;this._eyeBlinkParameterIds.length>h&&Rd("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>h&&Rd("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const c=this._fadeInSeconds<=0?1:mt.getEasingSine((e-r.getFadeInStartTime())/this._fadeInSeconds),d=this._fadeOutSeconds<=0||r.getEndTime()<0?1:mt.getEasingSine((r.getEndTime()-e)/this._fadeOutSeconds);let f,p,g,m=n;if(this._isLoop)for(;m>this._motionData.duration;)m-=this._motionData.duration;const _=this._motionData.curves;for(p=0;p<this._motionData.curveCount&&_[p].type==Fe.CubismMotionCurveTarget_Model;++p)f=$o(this._motionData,p,m),_[p].id==this._modelCurveIdEyeBlink?o=f:_[p].id==this._modelCurveIdLipSync?a=f:_[p].id==this._modelCurveIdOpacity&&(this._modelOpacity=f,t.setModelOapcity(this.getModelOpacityValue()));for(;p<this._motionData.curveCount&&_[p].type==Fe.CubismMotionCurveTarget_Parameter;++p){if(g=t.getParameterIndex(_[p].id),g==-1)continue;const b=t.getParameterValueByIndex(g);if(f=$o(this._motionData,p,m),o!=Number.MAX_VALUE){for(let E=0;E<this._eyeBlinkParameterIds.length&&E<h;++E)if(this._eyeBlinkParameterIds[E]==_[p].id){f*=o,u|=1<<E;break}}if(a!=Number.MAX_VALUE){for(let E=0;E<this._lipSyncParameterIds.length&&E<h;++E)if(this._lipSyncParameterIds[E]==_[p].id){f+=a,l|=1<<E;break}}let y;if(_[p].fadeInTime<0&&_[p].fadeOutTime<0)y=b+(f-b)*i;else{let E,v;_[p].fadeInTime<0?E=c:E=_[p].fadeInTime==0?1:mt.getEasingSine((e-r.getFadeInStartTime())/_[p].fadeInTime),_[p].fadeOutTime<0?v=d:v=_[p].fadeOutTime==0||r.getEndTime()<0?1:mt.getEasingSine((r.getEndTime()-e)/_[p].fadeOutTime);const M=this._weight*E*v;y=b+(f-b)*M}t.setParameterValueByIndex(g,y,1)}{if(o!=Number.MAX_VALUE)for(let b=0;b<this._eyeBlinkParameterIds.length&&b<h;++b){const y=t.getParameterValueById(this._eyeBlinkParameterIds[b]);if(u>>b&1)continue;const E=y+(o-y)*i;t.setParameterValueById(this._eyeBlinkParameterIds[b],E)}if(a!=Number.MAX_VALUE)for(let b=0;b<this._lipSyncParameterIds.length&&b<h;++b){const y=t.getParameterValueById(this._lipSyncParameterIds[b]);if(l>>b&1)continue;const E=y+(a-y)*i;t.setParameterValueById(this._lipSyncParameterIds[b],E)}}for(;p<this._motionData.curveCount&&_[p].type==Fe.CubismMotionCurveTarget_PartOpacity;++p)if(f=$o(this._motionData,p,m),tn.setOpacityFromMotion)t.setPartOpacityById(_[p].id,f);else{if(g=t.getParameterIndex(_[p].id),g==-1)continue;t.setParameterValueByIndex(g,f)}n>=this._motionData.duration&&(this._isLoop?(r.setStartTime(e),this._isLoopFadeIn&&r.setFadeInStartTime(e)):(this._onFinishedMotion&&this._onFinishedMotion(this),r.setIsFinished(!0))),this._lastWeight=i}setIsLoop(t){this._isLoop=t}isLoop(){return this._isLoop}setIsLoopFadeIn(t){this._isLoopFadeIn=t}isLoopFadeIn(){return this._isLoopFadeIn}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,e){const i=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(t==i[r].id){i[r].fadeInTime=e;return}}setParameterFadeOutTime(t,e){const i=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(t==i[r].id){i[r].fadeOutTime=e;return}}getParameterFadeInTime(t){const e=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==e[i].id)return e[i].fadeInTime;return-1}getParameterFadeOutTime(t){const e=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==e[i].id)return e[i].fadeOutTime;return-1}setEffectIds(t,e){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=e}release(){this._motionData=void 0}parse(t){this._motionData=new ey;const e=new Ld(t);this._motionData.duration=e.getMotionDuration(),this._motionData.loop=e.isMotionLoop(),this._motionData.curveCount=e.getMotionCurveCount(),this._motionData.fps=e.getMotionFps(),this._motionData.eventCount=e.getEventCount();const i=e.getEvaluationOptionFlag(Od.EvaluationOptionFlag_AreBeziersRistricted),r=e.getMotionFadeInTime(),n=e.getMotionFadeOutTime();r!==void 0?this._fadeInSeconds=r<0?1:r:this._fadeInSeconds=1,n!==void 0?this._fadeOutSeconds=n<0?1:n:this._fadeOutSeconds=1,this._motionData.curves=Array.from({length:this._motionData.curveCount}).map(()=>new Q_),this._motionData.segments=Array.from({length:e.getMotionTotalSegmentCount()}).map(()=>new J_),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new ty),this._motionData.points=[];let a=0,o=0;for(let h=0;h<this._motionData.curveCount;++h){const l=this._motionData.curves[h];switch(e.getMotionCurveTarget(h)){case sy:l.type=Fe.CubismMotionCurveTarget_Model;break;case ny:l.type=Fe.CubismMotionCurveTarget_Parameter;break;case ay:l.type=Fe.CubismMotionCurveTarget_PartOpacity;break;default:Ci('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!')}l.id=e.getMotionCurveId(h),l.baseSegmentIndex=o;const u=e.getMotionCurveFadeInTime(h),c=e.getMotionCurveFadeOutTime(h);l.fadeInTime=u!==void 0?u:-1,l.fadeOutTime=c!==void 0?c:-1;for(let d=0;d<e.getMotionCurveSegmentCount(h);){switch(d==0?(this._motionData.segments[o].basePointIndex=a,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d),e.getMotionCurveSegment(h,d+1)),a+=1,d+=2):this._motionData.segments[o].basePointIndex=a-1,e.getMotionCurveSegment(h,d)){case Be.CubismMotionSegmentType_Linear:{this._motionData.segments[o].segmentType=Be.CubismMotionSegmentType_Linear,this._motionData.segments[o].evaluate=hy,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d+1),e.getMotionCurveSegment(h,d+2)),a+=1,d+=3;break}case Be.CubismMotionSegmentType_Bezier:{this._motionData.segments[o].segmentType=Be.CubismMotionSegmentType_Bezier,i||oy?this._motionData.segments[o].evaluate=ly:this._motionData.segments[o].evaluate=uy,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d+1),e.getMotionCurveSegment(h,d+2)),this._motionData.points[a+1]=new ai(e.getMotionCurveSegment(h,d+3),e.getMotionCurveSegment(h,d+4)),this._motionData.points[a+2]=new ai(e.getMotionCurveSegment(h,d+5),e.getMotionCurveSegment(h,d+6)),a+=3,d+=7;break}case Be.CubismMotionSegmentType_Stepped:{this._motionData.segments[o].segmentType=Be.CubismMotionSegmentType_Stepped,this._motionData.segments[o].evaluate=cy,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d+1),e.getMotionCurveSegment(h,d+2)),a+=1,d+=3;break}case Be.CubismMotionSegmentType_InverseStepped:{this._motionData.segments[o].segmentType=Be.CubismMotionSegmentType_InverseStepped,this._motionData.segments[o].evaluate=dy,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d+1),e.getMotionCurveSegment(h,d+2)),a+=1,d+=3;break}default:{qi(0);break}}++l.segmentCount,++o}this._motionData.curves.push(l)}for(let h=0;h<e.getEventCount();++h)this._motionData.events[h].fireTime=e.getEventTime(h),this._motionData.events[h].value=e.getEventValue(h);e.release()}getFiredEvent(t,e){this._firedEventValues.length=0;for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events[i].fireTime>t&&this._motionData.events[i].fireTime<=e&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){const e=this._motionData.curves[t];if(e.type==Fe.CubismMotionCurveTarget_Model&&e.id===an)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){const e=this._motionData.curves[t];if(e.type==Fe.CubismMotionCurveTarget_Model&&e.id===an)return t}return-1}getModelOpacityId(t){if(t!=-1){const e=this._motionData.curves[t];if(e.type==Fe.CubismMotionCurveTarget_Model&&e.id===an)return e.id}}getModelOpacityValue(){return this._modelOpacity}}class fy extends zr{constructor(t,e){var i;super(t,e),I(this,"definitions"),I(this,"groups",{idle:"Idle"}),I(this,"motionDataType","json"),I(this,"queueManager",new Bd),I(this,"expressionManager"),I(this,"eyeBlinkIds"),I(this,"lipSyncIds",["ParamMouthOpenY"]),this.definitions=(i=t.motions)!=null?i:{},this.eyeBlinkIds=t.getEyeBlinkParameters()||[];const r=t.getLipSyncParameters();r!=null&&r.length&&(this.lipSyncIds=r),this.init(e)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Z_(this.settings,t)),this.queueManager.setEventCallback((e,i,r)=>{this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,e){return t.setFinishedMotionHandler(e),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1,performance.now())}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(t,e,i){const r=jo.create(t),n=new Ld(t),a=(e===this.groups.idle?Xi.idleMotionFadingDuration:Xi.motionFadingDuration)/1e3;return n.getMotionFadeInTime()===void 0&&r.setFadeInTime(i.FadeInTime>0?i.FadeInTime:a),n.getMotionFadeOutTime()===void 0&&r.setFadeOutTime(i.FadeOutTime>0?i.FadeOutTime:a),r.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),r}getMotionFile(t){return t.File}getMotionName(t){return t.File}getSoundFile(t){return t.Sound}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}}const py="ParamAngleX",my="ParamAngleY",gy="ParamAngleZ",_y="ParamEyeBallX",yy="ParamEyeBallY",vy="ParamMouthForm",xy="ParamBodyAngleX",by="ParamBreath";class Yo{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new Yo}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const i=this._currentTime*2*3.14159;for(let r=0;r<this._breathParameters.length;++r){const n=this._breathParameters[r];t.addParameterValueById(n.parameterId,n.offset+n.peak*Math.sin(i/n.cycle),n.weight)}}}class qr{constructor(t,e,i,r,n){this.parameterId=t??void 0,this.offset=e??0,this.peak=i??0,this.cycle=r??0,this.weight=n??0}}const kd=class xh{static create(t){return new xh(t)}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,e,i){this._closingSeconds=t,this._closedSeconds=e,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,e){this._userTimeSeconds+=e;let i,r=0;switch(this._blinkingState){case 2:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,r>=1&&(r=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-r;break;case 3:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,r>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case 4:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,r>=1&&(r=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=r;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;case 0:default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1;break}xh.CloseIfZero||(i=-i);for(let n=0;n<this._parameterIds.length;++n)t.setParameterValueById(this._parameterIds[n],i)}constructor(t){var e,i;this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=[],t!=null&&(this._parameterIds=(i=(e=t.getEyeBlinkParameters())==null?void 0:e.slice())!=null?i:this._parameterIds)}determinNextBlinkingTiming(){const t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}};kd.CloseIfZero=!0;let Ty=kd;class qo{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.width=i,this.height=r}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,e){this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2}}const on=4,Ey=36,wy=32,Cy=10;let Ai,je,hn;class Nd{getChannelFlagAsColor(t){return this._channelColors[t]}getMaskRenderTexture(){if(this._maskTexture&&this._maskTexture.textures!=null)this._maskTexture.frameNo=this._currentFrameNo;else{this._maskRenderTextures=[],this._maskColorBuffers=[];const t=this._clippingMaskBufferSize;for(let e=0;e<this._renderTextureCount;e++)this._maskColorBuffers.push(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers[e]),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.push(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures[e]),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers[e],0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,hn),this._maskTexture=new Ay(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,e){let i=Number.MAX_VALUE,r=Number.MAX_VALUE,n=Number.MIN_VALUE,a=Number.MIN_VALUE;const o=e._clippedDrawableIndexList.length;for(let h=0;h<o;h++){const l=e._clippedDrawableIndexList[h],u=t.getDrawableVertexCount(l),c=t.getDrawableVertices(l);let d=Number.MAX_VALUE,f=Number.MAX_VALUE,p=-Number.MAX_VALUE,g=-Number.MAX_VALUE;const m=u*zo.vertexStep;for(let _=zo.vertexOffset;_<m;_+=zo.vertexStep){const b=c[_],y=c[_+1];b<d&&(d=b),b>p&&(p=b),y<f&&(f=y),y>g&&(g=y)}if(d!=Number.MAX_VALUE)if(d<i&&(i=d),f<r&&(r=f),p>n&&(n=p),g>a&&(a=g),i==Number.MAX_VALUE)e._allClippedDrawRect.x=0,e._allClippedDrawRect.y=0,e._allClippedDrawRect.width=0,e._allClippedDrawRect.height=0,e._isUsing=!1;else{e._isUsing=!0;const _=n-i,b=a-r;e._allClippedDrawRect.x=i,e._allClippedDrawRect.y=r,e._allClippedDrawRect.width=_,e._allClippedDrawRect.height=b}}}constructor(){this._currentMaskRenderTexture=null,this._currentFrameNo=0,this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new qo,this._tmpMatrix=new se,this._tmpMatrixForMask=new se,this._tmpMatrixForDraw=new se;let t=new Yt;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new Yt,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new Yt,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new Yt,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t;const e=this;for(let i=0;i<this._clippingContextListForMask.length;i++)this._clippingContextListForMask[i]&&((t=this._clippingContextListForMask[i])==null||t.release());if(e._clippingContextListForMask=void 0,e._clippingContextListForDraw=void 0,this._maskTexture){for(let i=0;i<this._maskTexture.textures.length;i++)this.gl.deleteFramebuffer(this._maskTexture.textures[i]);this._maskTexture=void 0}if(e._channelColors=void 0,this._maskColorBuffers)for(let i=0;i<this._maskColorBuffers.length;i++)this.gl.deleteTexture(this._maskColorBuffers[i]);this._maskColorBuffers=void 0,this._maskRenderTextures=void 0,this._clearedFrameBufferflags=void 0}initialize(t,e,i,r,n){n%1!=0&&(Ci("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),n=~~n),n<1&&Ci("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=n<1?1:n,this._clearedFrameBufferflags=[];for(let a=0;a<e;a++){if(r[a]<=0){this._clippingContextListForDraw.push(null);continue}let o=this.findSameClip(i[a],r[a]);o==null&&(o=new Sy(this,i[a],r[a]),this._clippingContextListForMask.push(o)),o.addClippedDrawable(a),this._clippingContextListForDraw.push(o)}}setupClippingContext(t,e){this._currentFrameNo++;let i=0;for(let r=0;r<this._clippingContextListForMask.length;r++){const n=this._clippingContextListForMask[r];this.calcClippedDrawTotalBounds(t,n),n._isUsing&&i++}if(i>0){this.setupLayoutBounds(e.isUsingHighPrecisionMask()?0:i),e.isUsingHighPrecisionMask()||(this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture()[0],e.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._clearedFrameBufferflags||(this._clearedFrameBufferflags=[]);for(let r=0;r<this._renderTextureCount;r++)this._clearedFrameBufferflags[r]=!1;for(let r=0;r<this._clippingContextListForMask.length;r++){const n=this._clippingContextListForMask[r],a=n._allClippedDrawRect,o=n._layoutBounds,h=.05;let l=0,u=0;const c=this.getMaskRenderTexture()[n._bufferIndex];if(this._currentMaskRenderTexture!=c&&!e.isUsingHighPrecisionMask()&&(this._currentMaskRenderTexture=c,e.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),e.isUsingHighPrecisionMask()){const d=t.getPixelsPerUnit(),f=n.getClippingManager()._clippingMaskBufferSize,p=o.width*f,g=o.height*f;this._tmpBoundsOnModel.setRect(a),this._tmpBoundsOnModel.width*d>p?(this._tmpBoundsOnModel.expand(a.width*h,0),l=o.width/this._tmpBoundsOnModel.width):l=d/p,this._tmpBoundsOnModel.height*d>g?(this._tmpBoundsOnModel.expand(0,a.height*h),u=o.height/this._tmpBoundsOnModel.height):u=d/g}else this._tmpBoundsOnModel.setRect(a),this._tmpBoundsOnModel.expand(a.width*h,a.height*h),l=o.width/this._tmpBoundsOnModel.width,u=o.height/this._tmpBoundsOnModel.height;if(this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(o.x,o.y),this._tmpMatrix.scaleRelative(l,u),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(o.x,o.y),this._tmpMatrix.scaleRelative(l,u),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),n._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),n._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray()),!e.isUsingHighPrecisionMask()){const d=n._clippingIdCount;for(let f=0;f<d;f++){const p=n._clippingIdList[f];t.getDrawableDynamicFlagVertexPositionsDidChange(p)&&(e.setIsCulling(t.getDrawableCulling(p)!=!1),this._clearedFrameBufferflags[n._bufferIndex]||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferflags[n._bufferIndex]=!0),e.setClippingContextBufferForMask(n),e.drawMesh(t.getDrawableTextureIndex(p),t.getDrawableVertexIndexCount(p),t.getDrawableVertexCount(p),t.getDrawableVertexIndices(p),t.getDrawableVertices(p),t.getDrawableVertexUvs(p),t.getMultiplyColor(p),t.getScreenColor(p),t.getDrawableOpacity(p),$e.CubismBlendMode_Normal,!1))}}}e.isUsingHighPrecisionMask()||(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,hn),e.setClippingContextBufferForMask(null),this.gl.viewport(je[0],je[1],je[2],je[3]))}}findSameClip(t,e){for(let i=0;i<this._clippingContextListForMask.length;i++){const r=this._clippingContextListForMask[i],n=r._clippingIdCount;if(n!=e)continue;let a=0;for(let o=0;o<n;o++){const h=r._clippingIdList[o];for(let l=0;l<n;l++)if(t[l]==h){a++;break}}if(a==n)return r}return null}setupLayoutBounds(t){const e=this._renderTextureCount<=1?Ey:wy*this._renderTextureCount;if(t<=0||t>e){t>e&&De(`not supported mask count : {0}
1161
+ [Details] render texture count : {1}, mask count : {2}`,t-e,this._renderTextureCount,t);for(let l=0;l<this._clippingContextListForMask.length;l++){const u=this._clippingContextListForMask[l];u._layoutChannelNo=0,u._layoutBounds.x=0,u._layoutBounds.y=0,u._layoutBounds.width=1,u._layoutBounds.height=1,u._bufferIndex=0}return}const i=this._renderTextureCount<=1?9:8;let r=t/this._renderTextureCount,n=t%this._renderTextureCount;r=~~r,n=~~n;let a=r/on,o=r%on;a=~~a,o=~~o;let h=0;for(let l=0;l<this._renderTextureCount;l++)for(let u=0;u<on;u++){let c=a+(u<o?1:0);const d=o+1>=on?0:o+1;if(c<i&&u==d&&(c+=l<n?1:0),c!=0)if(c==1){const f=this._clippingContextListForMask[h++];f._layoutChannelNo=u,f._layoutBounds.x=0,f._layoutBounds.y=0,f._layoutBounds.width=1,f._layoutBounds.height=1,f._bufferIndex=l}else if(c==2)for(let f=0;f<c;f++){let p=f%2;p=~~p;const g=this._clippingContextListForMask[h++];g._layoutChannelNo=u,g._layoutBounds.x=p*.5,g._layoutBounds.y=0,g._layoutBounds.width=.5,g._layoutBounds.height=1,g._bufferIndex=l}else if(c<=4)for(let f=0;f<c;f++){let p=f%2,g=f/2;p=~~p,g=~~g;const m=this._clippingContextListForMask[h++];m._layoutChannelNo=u,m._layoutBounds.x=p*.5,m._layoutBounds.y=g*.5,m._layoutBounds.width=.5,m._layoutBounds.height=.5,m._bufferIndex=l}else if(c<=i)for(let f=0;f<c;f++){let p=f%3,g=f/3;p=~~p,g=~~g;const m=this._clippingContextListForMask[h++];m._layoutChannelNo=u,m._layoutBounds.x=p/3,m._layoutBounds.y=g/3,m._layoutBounds.width=1/3,m._layoutBounds.height=1/3,m._bufferIndex=l}else if(tn.supportMoreMaskDivisions&&c<=16)for(let f=0;f<c;f++){let p=f%4,g=f/4;p=~~p,g=~~g;const m=this._clippingContextListForMask[h++];m._layoutChannelNo=u,m._layoutBounds.x=p/4,m._layoutBounds.y=g/4,m._layoutBounds.width=1/4,m._layoutBounds.height=1/4,m._bufferIndex=l}else{De(`not supported mask count : {0}
1162
+ [Details] render texture count : {1}, mask count : {2}`,t-e,this._renderTextureCount,t);for(let f=0;f<c;f++){const p=this._clippingContextListForMask[h++];p._layoutChannelNo=0,p._layoutBounds.x=0,p._layoutBounds.y=0,p._layoutBounds.width=1,p._layoutBounds.height=1,p._bufferIndex=0}}}}getColorBuffer(){return this._maskColorBuffers}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskCount(){return this._clippingContextListForMask.length}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}}class Ay{constructor(t,e){this.frameNo=t,this.textures=e}}class Sy{constructor(t,e,i){this._isUsing=!1,this._owner=t,this._clippingIdList=e,this._clippingIdCount=i,this._allClippedDrawRect=new qo,this._layoutBounds=new qo,this._clippedDrawableIndexList=[],this._matrixForMask=new se,this._matrixForDraw=new se,this._bufferIndex=0}release(){const t=this;t._layoutBounds=void 0,t._allClippedDrawRect=void 0,t._clippedDrawableIndexList=void 0}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}}class Py{setGlEnable(t,e){e?this.gl.enable(t):this.gl.disable(t)}setGlEnableVertexAttribArray(t,e){e?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)}save(){if(this.gl==null){De(`'gl' is null. WebGLRenderingContext is required.
1163
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA),this._lastFBO=this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING),this._lastViewport=this.gl.getParameter(this.gl.VIEWPORT)}restore(){if(this.gl==null){De(`'gl' is null. WebGLRenderingContext is required.
1164
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(t){this.gl=t}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4),this._lastViewport=new Array(4)}}class Ki{static getInstance(){return Ai==null&&(Ai=new Ki),Ai}static deleteInstance(){Ai&&(Ai.release(),Ai=void 0)}constructor(){this._shaderSets=[]}release(){this.releaseShaderProgram()}setupShaderProgram(t,e,i,r,n,a,o,h,l,u,c,d,f,p,g){f||De("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders();let m,_,b,y;const E=t.getClippingContextBufferForMask();if(E!=null){const v=this._shaderSets[0];this.gl.useProgram(v.shaderProgram),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(v.samplerTexture0Location,0),o.vertex==null&&(o.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(v.attributePositionLocation),this.gl.vertexAttribPointer(v.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),o.uv==null&&(o.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,a,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(v.attributeTexCoordLocation),this.gl.vertexAttribPointer(v.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0);const M=E._layoutChannelNo,T=E.getClippingManager().getChannelFlagAsColor(M);this.gl.uniform4f(v.uniformChannelFlagLocation,T.R,T.G,T.B,T.A),this.gl.uniformMatrix4fv(v.uniformClipMatrixLocation,!1,E._matrixForMask.getArray());const P=E._layoutBounds;this.gl.uniform4f(v.uniformBaseColorLocation,P.x*2-1,P.y*2-1,P.getRight()*2-1,P.getBottom()*2-1),this.gl.uniform4f(v.uniformMultiplyColorLocation,c.R,c.G,c.B,c.A),this.gl.uniform4f(v.uniformScreenColorLocation,d.R,d.G,d.B,d.A),m=this.gl.ZERO,_=this.gl.ONE_MINUS_SRC_COLOR,b=this.gl.ZERO,y=this.gl.ONE_MINUS_SRC_ALPHA}else{const v=t.getClippingContextBufferForDraw(),T=v!=null?g?2:1:0;let P;switch(l){case $e.CubismBlendMode_Normal:default:P=this._shaderSets[1+T],m=this.gl.ONE,_=this.gl.ONE_MINUS_SRC_ALPHA,b=this.gl.ONE,y=this.gl.ONE_MINUS_SRC_ALPHA;break;case $e.CubismBlendMode_Additive:P=this._shaderSets[4+T],m=this.gl.ONE,_=this.gl.ONE,b=this.gl.ZERO,y=this.gl.ONE;break;case $e.CubismBlendMode_Multiplicative:P=this._shaderSets[7+T],m=this.gl.DST_COLOR,_=this.gl.ONE_MINUS_SRC_ALPHA,b=this.gl.ZERO,y=this.gl.ONE;break}if(this.gl.useProgram(P.shaderProgram),o.vertex==null&&(o.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(P.attributePositionLocation),this.gl.vertexAttribPointer(P.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),o.uv==null&&(o.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,a,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(P.attributeTexCoordLocation),this.gl.vertexAttribPointer(P.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),v!=null){this.gl.activeTexture(this.gl.TEXTURE1);const N=v.getClippingManager().getColorBuffer()[t.getClippingContextBufferForDraw()._bufferIndex];this.gl.bindTexture(this.gl.TEXTURE_2D,N),this.gl.uniform1i(P.samplerTexture1Location,1),this.gl.uniformMatrix4fv(P.uniformClipMatrixLocation,!1,v._matrixForDraw.getArray());const G=v._layoutChannelNo,z=v.getClippingManager().getChannelFlagAsColor(G);this.gl.uniform4f(P.uniformChannelFlagLocation,z.R,z.G,z.B,z.A)}this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(P.samplerTexture0Location,0),this.gl.uniformMatrix4fv(P.uniformMatrixLocation,!1,p.getArray()),this.gl.uniform4f(P.uniformBaseColorLocation,u.R,u.G,u.B,u.A),this.gl.uniform4f(P.uniformMultiplyColorLocation,c.R,c.G,c.B,c.A),this.gl.uniform4f(P.uniformScreenColorLocation,d.R,d.G,d.B,d.A)}o.index==null&&(o.index=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,o.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(m,_,b,y)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.length;t++)this.gl.deleteProgram(this._shaderSets[t].shaderProgram),this._shaderSets[t].shaderProgram=0;this._shaderSets=[]}generateShaders(){for(let t=0;t<Cy;t++)this._shaderSets.push({});this._shaderSets[0].shaderProgram=this.loadShaderProgram(My,Iy),this._shaderSets[1].shaderProgram=this.loadShaderProgram(Ry,Dy),this._shaderSets[2].shaderProgram=this.loadShaderProgram(Ud,Fy),this._shaderSets[3].shaderProgram=this.loadShaderProgram(Ud,By),this._shaderSets[4].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[5].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[6].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[7].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[8].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[9].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[0].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_position"),this._shaderSets[0].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_texCoord"),this._shaderSets[0].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"s_texture0"),this._shaderSets[0].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_clipMatrix"),this._shaderSets[0].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_channelFlag"),this._shaderSets[0].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_baseColor"),this._shaderSets[0].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_multiplyColor"),this._shaderSets[0].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_screenColor"),this._shaderSets[1].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_position"),this._shaderSets[1].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_texCoord"),this._shaderSets[1].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"s_texture0"),this._shaderSets[1].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_matrix"),this._shaderSets[1].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_baseColor"),this._shaderSets[1].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_multiplyColor"),this._shaderSets[1].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_screenColor"),this._shaderSets[2].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_position"),this._shaderSets[2].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_texCoord"),this._shaderSets[2].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture0"),this._shaderSets[2].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture1"),this._shaderSets[2].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_matrix"),this._shaderSets[2].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_clipMatrix"),this._shaderSets[2].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_channelFlag"),this._shaderSets[2].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_baseColor"),this._shaderSets[2].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_multiplyColor"),this._shaderSets[2].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_screenColor"),this._shaderSets[3].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_position"),this._shaderSets[3].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_texCoord"),this._shaderSets[3].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture0"),this._shaderSets[3].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture1"),this._shaderSets[3].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_matrix"),this._shaderSets[3].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_clipMatrix"),this._shaderSets[3].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_channelFlag"),this._shaderSets[3].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_baseColor"),this._shaderSets[3].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_multiplyColor"),this._shaderSets[3].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_screenColor"),this._shaderSets[4].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_position"),this._shaderSets[4].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_texCoord"),this._shaderSets[4].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"s_texture0"),this._shaderSets[4].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_matrix"),this._shaderSets[4].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_baseColor"),this._shaderSets[4].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_multiplyColor"),this._shaderSets[4].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_screenColor"),this._shaderSets[5].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_position"),this._shaderSets[5].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_texCoord"),this._shaderSets[5].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture0"),this._shaderSets[5].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture1"),this._shaderSets[5].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_matrix"),this._shaderSets[5].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_clipMatrix"),this._shaderSets[5].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_channelFlag"),this._shaderSets[5].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_baseColor"),this._shaderSets[5].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_multiplyColor"),this._shaderSets[5].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_screenColor"),this._shaderSets[6].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_position"),this._shaderSets[6].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_texCoord"),this._shaderSets[6].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture0"),this._shaderSets[6].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture1"),this._shaderSets[6].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_matrix"),this._shaderSets[6].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_clipMatrix"),this._shaderSets[6].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_channelFlag"),this._shaderSets[6].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_baseColor"),this._shaderSets[6].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_multiplyColor"),this._shaderSets[6].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_screenColor"),this._shaderSets[7].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_position"),this._shaderSets[7].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_texCoord"),this._shaderSets[7].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"s_texture0"),this._shaderSets[7].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_matrix"),this._shaderSets[7].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_baseColor"),this._shaderSets[7].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_multiplyColor"),this._shaderSets[7].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_screenColor"),this._shaderSets[8].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_position"),this._shaderSets[8].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_texCoord"),this._shaderSets[8].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture0"),this._shaderSets[8].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture1"),this._shaderSets[8].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_matrix"),this._shaderSets[8].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_clipMatrix"),this._shaderSets[8].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_channelFlag"),this._shaderSets[8].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_baseColor"),this._shaderSets[8].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_multiplyColor"),this._shaderSets[8].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_screenColor"),this._shaderSets[9].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_position"),this._shaderSets[9].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_texCoord"),this._shaderSets[9].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture0"),this._shaderSets[9].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture1"),this._shaderSets[9].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_matrix"),this._shaderSets[9].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_clipMatrix"),this._shaderSets[9].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_channelFlag"),this._shaderSets[9].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_baseColor"),this._shaderSets[9].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_multiplyColor"),this._shaderSets[9].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_screenColor")}loadShaderProgram(t,e){const i=this.gl.createProgram(),r=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!r)return De("Vertex shader compile error!"),0;const n=this.compileShaderSource(this.gl.FRAGMENT_SHADER,e);return n?(this.gl.attachShader(i,r),this.gl.attachShader(i,n),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?(this.gl.deleteShader(r),this.gl.deleteShader(n),i):(De("Failed to link program: {0}",i),this.gl.deleteShader(r),this.gl.deleteShader(n),i&&this.gl.deleteProgram(i),0)):(De("Vertex shader compile error!"),0)}compileShaderSource(t,e){const i=e,r=this.gl.createShader(t);if(this.gl.shaderSource(r,i),this.gl.compileShader(r),!r){const a=this.gl.getShaderInfoLog(r);De("Shader compile log: {0} ",a)}return this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS)?r:(this.gl.deleteShader(r),null)}setGl(t){this.gl=t}}const My="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",Iy="precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}",Ry="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",Ud="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",Dy="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}",Fy="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}",By="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * (1.0 - maskVal); gl_FragColor = col_formask;}";class Gd extends Xo{initialize(t,e=1){t.isUsingMasking()&&(this._clippingManager=new Nd,this._clippingManager.initialize(t,t.getDrawableCount(),t.getDrawableMasks(),t.getDrawableMaskCounts(),e));for(let i=t.getDrawableCount()-1;i>=0;i--)this._sortedDrawableIndexList[i]=0;super.initialize(t)}bindTexture(t,e){this._textures[t]=e}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){if(!this._model.isUsingMasking())return;const e=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=new Nd,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts(),e)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new Py,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}release(){var t,e,i;const r=this;this._clippingManager.release(),r._clippingManager=void 0,(t=this.gl)==null||t.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(e=this.gl)==null||e.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(i=this.gl)==null||i.deleteBuffer(this._bufferData.index),this._bufferData.index=null,r._bufferData=void 0,r._textures=void 0}doDrawModel(){if(this.gl==null){De(`'gl' is null. WebGLRenderingContext is required.
1165
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._clippingManager!=null&&(this.preDraw(),this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();const t=this.getModel().getDrawableCount(),e=this.getModel().getDrawableRenderOrders();for(let i=0;i<t;++i){const r=e[i];this._sortedDrawableIndexList[r]=i}for(let i=0;i<t;++i){const r=this._sortedDrawableIndexList[i];if(!this.getModel().getDrawableDynamicFlagIsVisible(r))continue;const n=this._clippingManager!=null?this._clippingManager.getClippingContextListForDraw()[r]:null;if(n!=null&&this.isUsingHighPrecisionMask()){n._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,n.getClippingManager().getMaskRenderTexture()[n._bufferIndex]),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{const a=n._clippingIdCount;for(let o=0;o<a;o++){const h=n._clippingIdList[o];this._model.getDrawableDynamicFlagVertexPositionsDidChange(h)&&(this.setIsCulling(this._model.getDrawableCulling(h)!=!1),this.setClippingContextBufferForMask(n),this.drawMesh(this.getModel().getDrawableTextureIndex(h),this.getModel().getDrawableVertexIndexCount(h),this.getModel().getDrawableVertexCount(h),this.getModel().getDrawableVertexIndices(h),this.getModel().getDrawableVertices(h),this.getModel().getDrawableVertexUvs(h),this.getModel().getMultiplyColor(h),this.getModel().getScreenColor(h),this.getModel().getDrawableOpacity(h),$e.CubismBlendMode_Normal,!1))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,hn),this.setClippingContextBufferForMask(null),this.gl.viewport(je[0],je[1],je[2],je[3]),this.preDraw()}this.setClippingContextBufferForDraw(n),this.setIsCulling(this.getModel().getDrawableCulling(r)),this.drawMesh(this.getModel().getDrawableTextureIndex(r),this.getModel().getDrawableVertexIndexCount(r),this.getModel().getDrawableVertexCount(r),this.getModel().getDrawableVertexIndices(r),this.getModel().getDrawableVertices(r),this.getModel().getDrawableVertexUvs(r),this.getModel().getMultiplyColor(r),this.getModel().getScreenColor(r),this.getModel().getDrawableOpacity(r),this.getModel().getDrawableBlendMode(r),this.getModel().getDrawableInvertedMaskBit(r))}}drawMesh(t,e,i,r,n,a,o,h,l,u,c){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW);const d=this.getModelColor();this.getClippingContextBufferForMask()==null&&(d.A*=l,this.isPremultipliedAlpha()&&(d.R*=d.A,d.G*=d.A,d.B*=d.A));let f=null;this._textures[t]!=null&&(f=this._textures[t]),Ki.getInstance().setupShaderProgram(this,f,i,n,r,a,this._bufferData,l,u,d,o,h,this.isPremultipliedAlpha(),this.getMvpMatrix(),c),this.gl.drawElements(this.gl.TRIANGLES,e,this.gl.UNSIGNED_SHORT,0),this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){Ki.deleteInstance()}setRenderState(t,e){hn=t,je=e}preDraw(){if(this.firstDraw&&(this.firstDraw=!1),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(const t of Object.entries(this._textures))this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}startUp(t){this.gl=t,this._clippingManager&&this._clippingManager.setGL(t),Ki.getInstance().setGl(t),this._rendererProfile.setGl(t),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")}}Xo.staticRelease=()=>{Gd.doStaticRelease()};const Vd=new se;class Ly extends fd{constructor(t,e,i){super(),I(this,"settings"),I(this,"coreModel"),I(this,"motionManager"),I(this,"lipSync",!0),I(this,"breath",Yo.create()),I(this,"eyeBlink"),I(this,"userData"),I(this,"renderer",new Gd),I(this,"idParamAngleX",py),I(this,"idParamAngleY",my),I(this,"idParamAngleZ",gy),I(this,"idParamEyeBallX",_y),I(this,"idParamEyeBallY",yy),I(this,"idParamBodyAngleX",xy),I(this,"idParamBreath",by),I(this,"idParamMouthForm",vy),I(this,"pixelsPerUnit",1),I(this,"centeringTransform",new vt),this.coreModel=t,this.settings=e,this.motionManager=new fy(e,i),this.init()}init(){var t;super.init(),(t=this.settings.getEyeBlinkParameters())!=null&&t.length&&(this.eyeBlink=Ty.create(this.settings)),this.breath.setParameters([new qr(this.idParamAngleX,0,15,6.5345,.5),new qr(this.idParamAngleY,0,8,3.5345,.5),new qr(this.idParamAngleZ,0,10,5.5345,.5),new qr(this.idParamBodyAngleX,0,4,15.5345,.5),new qr(this.idParamBreath,0,.5,3.2345,.5)]),this.renderer.initialize(this.coreModel),this.renderer.setIsPremultipliedAlpha(!0)}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){const t={};if(this.settings.layout)for(const[e,i]of Object.entries(this.settings.layout)){const r=e.charAt(0).toLowerCase()+e.slice(1);t[r]=i}return t}setupLayout(){super.setupLayout(),this.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit,this.centeringTransform.scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(t,e){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(t),this.renderer._clippingManager._currentFrameNo=e,this.renderer._clippingManager._maskTexture=void 0,Ki.getInstance()._shaderSets=[]}bindTexture(t,e){this.renderer.bindTexture(t,e)}getHitAreaDefs(){var t,e;return(e=(t=this.settings.hitAreas)==null?void 0:t.map(i=>({id:i.Id,name:i.Name,index:this.coreModel.getDrawableIndex(i.Id)})))!=null?e:[]}getDrawableIDs(){return this.coreModel.getDrawableIds()}getDrawableIndex(t){return this.coreModel.getDrawableIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawableIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);const e=this.coreModel.getDrawableVertices(t).slice();for(let i=0;i<e.length;i+=2)e[i]=e[i]*this.pixelsPerUnit+this.originalWidth/2,e[i+1]=-e[i+1]*this.pixelsPerUnit+this.originalHeight/2;return e}updateTransform(t){this.drawingMatrix.copyFrom(this.centeringTransform).prepend(this.localTransform).prepend(t)}update(t,e){var i,r,n,a;super.update(t,e),t/=1e3,e/=1e3;const o=this.coreModel;this.emit("beforeMotionUpdate");const h=this.motionManager.update(this.coreModel,e);if(this.emit("afterMotionUpdate"),o.saveParameters(),(i=this.motionManager.expressionManager)==null||i.update(o,e),h||(r=this.eyeBlink)==null||r.updateParameters(o,t),this.updateFocus(),this.updateNaturalMovements(t*1e3,e*1e3),this.lipSync&&this.motionManager.currentAudio){let l=this.motionManager.mouthSync(),u=0;const c=1,d=1.2;l>0&&(u=.4),l=zi(l*d,u,c);for(let f=0;f<this.motionManager.lipSyncIds.length;++f)o.addParameterValueById(this.motionManager.lipSyncIds[f],l,.8)}(n=this.physics)==null||n.evaluate(o,t),(a=this.pose)==null||a.updateParameters(o,t),this.emit("beforeModelUpdate"),o.update(),o.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,this.focusController.x*30),this.coreModel.addParameterValueById(this.idParamAngleY,this.focusController.y*30),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,this.focusController.x*10)}updateFacialEmotion(t){this.coreModel.addParameterValueById(this.idParamMouthForm,t)}updateNaturalMovements(t,e){var i;(i=this.breath)==null||i.updateParameters(this.coreModel,t/1e3)}draw(t){const e=this.drawingMatrix,i=Vd.getArray();i[0]=e.a,i[1]=e.b,i[4]=-e.c,i[5]=-e.d,i[12]=e.tx,i[13]=e.ty,this.renderer.setMvpMatrix(Vd),this.renderer.setRenderState(t.getParameter(t.FRAMEBUFFER_BINDING),this.viewport),this.renderer.drawModel()}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}}class Hd{constructor(t){this.groups=t.Groups,this.hitAreas=t.HitAreas,this.layout=t.Layout,this.moc=t.FileReferences.Moc,this.expressions=t.FileReferences.Expressions,this.motions=t.FileReferences.Motions,this.textures=t.FileReferences.Textures,this.physics=t.FileReferences.Physics,this.pose=t.FileReferences.Pose}getEyeBlinkParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(i=>i.Name==="EyeBlink"))==null?void 0:e.Ids}getLipSyncParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(i=>i.Name==="LipSync"))==null?void 0:e.Ids}}class Zi extends en{constructor(t){if(super(t),I(this,"moc"),I(this,"textures"),!Zi.isValidJSON(t))throw new TypeError("Invalid JSON.");Object.assign(this,new Hd(t))}static isValidJSON(t){var e;return!!(t!=null&&t.FileReferences)&&typeof t.FileReferences.Moc=="string"&&((e=t.FileReferences.Textures)==null?void 0:e.length)>0&&t.FileReferences.Textures.every(i=>typeof i=="string")}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[e,i]of Object.entries(this.motions))for(let r=0;r<i.length;r++)i[r].File=t(i[r].File,`motions.${e}[${r}].File`),i[r].Sound!==void 0&&(i[r].Sound=t(i[r].Sound,`motions.${e}[${r}].Sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].File=t(this.expressions[e].File,`expressions[${e}].File`)}}w_(Zi,[Hd]);let ln,Xd=20;function Oy(){return jr.isStarted()?Promise.resolve():(ln??(ln=new Promise((s,t)=>{function e(){try{ky(),s()}catch(i){if(Xd--,Xd<0){const r=new Error("Failed to start up Cubism 4 framework.");r.cause=i,t(r);return}setTimeout(e,10)}}e()})),ln)}function ky(s){s=Object.assign({logFunction:console.log,loggingLevel:Yi.LogLevel_Verbose},s),jr.startUp(s),jr.initialize()}const Ny=.001,zd=.5;class Ko{static create(t){const e=new Ko;typeof t.FadeInTime=="number"&&(e._fadeTimeSeconds=t.FadeInTime,e._fadeTimeSeconds<=0&&(e._fadeTimeSeconds=zd));const i=t.Groups,r=i.length;for(let n=0;n<r;++n){const a=i[n],o=a.length;let h=0;for(let l=0;l<o;++l){const u=a[l],c=new un;c.partId=u.Id;const d=u.Link;if(d){const f=d.length;for(let p=0;p<f;++p){const g=new un;g.partId=d[p],c.link.push(g)}}e._partGroups.push(c),++h}e._partGroupCounts.push(h)}return e}updateParameters(t,e){t!=this._lastModel&&this.reset(t),this._lastModel=t,e<0&&(e=0);let i=0;for(let r=0;r<this._partGroupCounts.length;r++){const n=this._partGroupCounts[r];this.doFade(t,e,i,n),i+=n}this.copyPartOpacities(t)}reset(t){let e=0;for(let i=0;i<this._partGroupCounts.length;++i){const r=this._partGroupCounts[i];for(let n=e;n<e+r;++n){this._partGroups[n].initialize(t);const a=this._partGroups[n].partIndex,o=this._partGroups[n].parameterIndex;if(!(a<0)){t.setPartOpacityByIndex(a,n==e?1:0),t.setParameterValueByIndex(o,n==e?1:0);for(let h=0;h<this._partGroups[n].link.length;++h)this._partGroups[n].link[h].initialize(t)}}e+=r}}copyPartOpacities(t){for(let e=0;e<this._partGroups.length;++e){const i=this._partGroups[e];if(i.link.length==0)continue;const r=this._partGroups[e].partIndex,n=t.getPartOpacityByIndex(r);for(let a=0;a<i.link.length;++a){const h=i.link[a].partIndex;h<0||t.setPartOpacityByIndex(h,n)}}}doFade(t,e,i,r){let n=-1,a=1;const o=.5,h=.15;for(let l=i;l<i+r;++l){const u=this._partGroups[l].partIndex,c=this._partGroups[l].parameterIndex;if(t.getParameterValueByIndex(c)>Ny){if(n>=0)break;n=l,a=t.getPartOpacityByIndex(u),a+=e/this._fadeTimeSeconds,a>1&&(a=1)}}n<0&&(n=0,a=1);for(let l=i;l<i+r;++l){const u=this._partGroups[l].partIndex;if(n==l)t.setPartOpacityByIndex(u,a);else{let c=t.getPartOpacityByIndex(u),d;a<o?d=a*(o-1)/o+1:d=(1-a)*o/(1-o),(1-d)*(1-a)>h&&(d=1-h/(1-a)),c>d&&(c=d),t.setPartOpacityByIndex(u,c)}}}constructor(){this._fadeTimeSeconds=zd,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class un{constructor(t){this.parameterIndex=0,this.partIndex=0,this.partId="",this.link=[],t!=null&&this.assignment(t)}assignment(t){return this.partId=t.partId,this.link=t.link.map(e=>e.clone()),this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new un;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(e=>e.clone()),t}}class Wd{constructor(t=!1,e=new Yt){this.isOverwritten=t,this.Color=e}}class $d{constructor(t=!1,e=new Yt){this.isOverwritten=t,this.Color=e}}class Uy{constructor(t=!1,e=!1){this.isOverwritten=t,this.isCulling=e}}class Gy{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){const t=this._model.parameters.count,e=this._savedParameters.length;for(let i=0;i<t;++i)i<e?this._savedParameters[i]=this._parameterValues[i]:this._savedParameters.push(this._parameterValues[i])}getMultiplyColor(t){return this.getOverwriteFlagForModelMultiplyColors()||this.getOverwriteFlagForDrawableMultiplyColors(t)?this._userMultiplyColors[t].Color:this.getDrawableMultiplyColor(t)}getScreenColor(t){return this.getOverwriteFlagForModelScreenColors()||this.getOverwriteFlagForDrawableScreenColors(t)?this._userScreenColors[t].Color:this.getDrawableScreenColor(t)}setMultiplyColorByTextureColor(t,e){this.setMultiplyColorByRGBA(t,e.R,e.G,e.B,e.A)}setMultiplyColorByRGBA(t,e,i,r,n=1){this._userMultiplyColors[t].Color.R=e,this._userMultiplyColors[t].Color.G=i,this._userMultiplyColors[t].Color.B=r,this._userMultiplyColors[t].Color.A=n}setScreenColorByTextureColor(t,e){this.setScreenColorByRGBA(t,e.R,e.G,e.B,e.A)}setScreenColorByRGBA(t,e,i,r,n=1){this._userScreenColors[t].Color.R=e,this._userScreenColors[t].Color.G=i,this._userScreenColors[t].Color.B=r,this._userScreenColors[t].Color.A=n}getPartMultiplyColor(t){return this._userPartMultiplyColors[t].Color}getPartScreenColor(t){return this._userPartScreenColors[t].Color}setPartColor(t,e,i,r,n,a,o){if(a[t].Color.R=e,a[t].Color.G=i,a[t].Color.B=r,a[t].Color.A=n,a[t].isOverwritten)for(let h=0;h<this._partChildDrawables[t].length;++h){const l=this._partChildDrawables[t][h];o[l].Color.R=e,o[l].Color.G=i,o[l].Color.B=r,o[l].Color.A=n}}setPartMultiplyColorByTextureColor(t,e){this.setPartMultiplyColorByRGBA(t,e.R,e.G,e.B,e.A)}setPartMultiplyColorByRGBA(t,e,i,r,n){this.setPartColor(t,e,i,r,n,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(t,e){this.setPartScreenColorByRGBA(t,e.R,e.G,e.B,e.A)}setPartScreenColorByRGBA(t,e,i,r,n){this.setPartColor(t,e,i,r,n,this._userPartScreenColors,this._userScreenColors)}getOverwriteFlagForModelMultiplyColors(){return this._isOverwrittenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return this._isOverwrittenModelScreenColors}setOverwriteFlagForModelMultiplyColors(t){this._isOverwrittenModelMultiplyColors=t}setOverwriteFlagForModelScreenColors(t){this._isOverwrittenModelScreenColors=t}getOverwriteFlagForDrawableMultiplyColors(t){return this._userMultiplyColors[t].isOverwritten}getOverwriteFlagForDrawableScreenColors(t){return this._userScreenColors[t].isOverwritten}setOverwriteFlagForDrawableMultiplyColors(t,e){this._userMultiplyColors[t].isOverwritten=e}setOverwriteFlagForDrawableScreenColors(t,e){this._userScreenColors[t].isOverwritten=e}getOverwriteColorForPartMultiplyColors(t){return this._userPartMultiplyColors[t].isOverwritten}getOverwriteColorForPartScreenColors(t){return this._userPartScreenColors[t].isOverwritten}setOverwriteColorForPartColors(t,e,i,r){i[t].isOverwritten=e;for(let n=0;n<this._partChildDrawables[t].length;++n){const a=this._partChildDrawables[t][n];r[a].isOverwritten=e,e&&(r[a].Color.R=i[t].Color.R,r[a].Color.G=i[t].Color.G,r[a].Color.B=i[t].Color.B,r[a].Color.A=i[t].Color.A)}}setOverwriteColorForPartMultiplyColors(t,e){this._userPartMultiplyColors[t].isOverwritten=e,this.setOverwriteColorForPartColors(t,e,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(t,e){this._userPartScreenColors[t].isOverwritten=e,this.setOverwriteColorForPartColors(t,e,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(t){if(this.getOverwriteFlagForModelCullings()||this.getOverwriteFlagForDrawableCullings(t))return this._userCullings[t].isCulling;const e=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(e[t])}setDrawableCulling(t,e){this._userCullings[t].isCulling=e}getOverwriteFlagForModelCullings(){return this._isOverwrittenCullings}setOverwriteFlagForModelCullings(t){this._isOverwrittenCullings=t}getOverwriteFlagForDrawableCullings(t){return this._userCullings[t].isOverwritten}setOverwriteFlagForDrawableCullings(t,e){this._userCullings[t].isOverwritten=e}getModelOapcity(){return this._modelOpacity}setModelOapcity(t){this._modelOpacity=t}getModel(){return this._model}getPartIndex(t){let e;const i=this._model.parts.count;for(e=0;e<i;++e)if(t==this._partIds[e])return e;return t in this._notExistPartId?this._notExistPartId[t]:(e=i+this._notExistPartId.length,this._notExistPartId[t]=e,this._notExistPartOpacities[e]=0,e)}getPartId(t){return this._model.parts.ids[t]}getPartCount(){return this._model.parts.count}setPartOpacityByIndex(t,e){if(t in this._notExistPartOpacities){this._notExistPartOpacities[t]=e;return}qi(0<=t&&t<this.getPartCount()),this._partOpacities[t]=e}setPartOpacityById(t,e){const i=this.getPartIndex(t);i<0||this.setPartOpacityByIndex(i,e)}getPartOpacityByIndex(t){return t in this._notExistPartOpacities?this._notExistPartOpacities[t]:(qi(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){const e=this.getPartIndex(t);return e<0?0:this.getPartOpacityByIndex(e)}getParameterIndex(t){let e;const i=this._model.parameters.count;for(e=0;e<i;++e)if(t==this._parameterIds[e])return e;return t in this._notExistParameterId?this._notExistParameterId[t]:(e=this._model.parameters.count+Object.keys(this._notExistParameterId).length,this._notExistParameterId[t]=e,this._notExistParameterValues[e]=0,e)}getParameterCount(){return this._model.parameters.count}getParameterType(t){return this._model.parameters.types[t]}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterValueByIndex(t){return t in this._notExistParameterValues?this._notExistParameterValues[t]:(qi(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){const e=this.getParameterIndex(t);return this.getParameterValueByIndex(e)}setParameterValueByIndex(t,e,i=1){if(t in this._notExistParameterValues){this._notExistParameterValues[t]=i==1?e:this._notExistParameterValues[t]*(1-i)+e*i;return}qi(0<=t&&t<this.getParameterCount()),this._model.parameters.maximumValues[t]<e&&(e=this._model.parameters.maximumValues[t]),this._model.parameters.minimumValues[t]>e&&(e=this._model.parameters.minimumValues[t]),this._parameterValues[t]=i==1?e:this._parameterValues[t]=this._parameterValues[t]*(1-i)+e*i}setParameterValueById(t,e,i=1){const r=this.getParameterIndex(t);this.setParameterValueByIndex(r,e,i)}addParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*i)}addParameterValueById(t,e,i=1){const r=this.getParameterIndex(t);this.addParameterValueByIndex(r,e,i)}multiplyParameterValueById(t,e,i=1){const r=this.getParameterIndex(t);this.multiplyParameterValueByIndex(r,e,i)}multiplyParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*i))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const e=this._model.drawables.count;for(let i=0;i<e;++i)if(this._drawableIds[i]==t)return i;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){return this._model.drawables.ids[t]}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this.getDrawableTextureIndex(t)}getDrawableTextureIndex(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(e[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableMultiplyColor(t){const e=this._model.drawables.multiplyColors,i=t*4,r=new Yt;return r.R=e[i],r.G=e[i+1],r.B=e[i+2],r.A=e[i+3],r}getDrawableScreenColor(t){const e=this._model.drawables.screenColors,i=t*4,r=new Yt;return r.R=e[i],r.G=e[i+1],r.B=e[i+2],r.A=e[i+3],r}getDrawableParentPartIndex(t){return this._model.drawables.parentPartIndices[t]}getDrawableBlendMode(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(e[t])?$e.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(e[t])?$e.CubismBlendMode_Multiplicative:$e.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(e[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(e[t])}getDrawableDynamicFlagVisibilityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(e[t])}getDrawableDynamicFlagOpacityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(e[t])}getDrawableDynamicFlagRenderOrderDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(e[t])}getDrawableDynamicFlagBlendColorDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(e[t])}loadParameters(){let t=this._model.parameters.count;const e=this._savedParameters.length;t>e&&(t=e);for(let i=0;i<t;++i)this._parameterValues[i]=this._savedParameters[i]}initialize(){this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{const e=this._model.parameters.ids,i=this._model.parameters.count;for(let r=0;r<i;++r)this._parameterIds.push(e[r])}const t=this._model.parts.count;{const e=this._model.parts.ids;for(let i=0;i<t;++i)this._partIds.push(e[i])}{const e=this._model.drawables.ids,i=this._model.drawables.count,r=new Uy(!1,!1);for(let n=0;n<t;++n){const a=new Yt(1,1,1,1),o=new Yt(0,0,0,1),h=new $d(!1,a),l=new $d(!1,o);this._userPartMultiplyColors.push(h),this._userPartScreenColors.push(l),this._partChildDrawables.push([])}for(let n=0;n<i;++n){const a=new Yt(1,1,1,1),o=new Yt(0,0,0,1),h=new Wd(!1,a),l=new Wd(!1,o);this._drawableIds.push(e[n]),this._userMultiplyColors.push(h),this._userScreenColors.push(l),this._userCullings.push(r);const u=this.getDrawableParentPartIndex(n);u>=0&&this._partChildDrawables[u].push(n)}}}constructor(t){this._model=t,this._savedParameters=[],this._parameterIds=[],this._drawableIds=[],this._partIds=[],this._isOverwrittenModelMultiplyColors=!1,this._isOverwrittenModelScreenColors=!1,this._isOverwrittenCullings=!1,this._modelOpacity=1,this._userMultiplyColors=[],this._userScreenColors=[],this._userCullings=[],this._userPartMultiplyColors=[],this._userPartScreenColors=[],this._partChildDrawables=[],this._notExistPartId={},this._notExistParameterId={},this._notExistParameterValues={},this._notExistPartOpacities={},this.initialize()}release(){this._model.release(),this._model=void 0}}class Zo{static create(t,e){if(e&&!this.hasMocConsistency(t))throw new Error("Inconsistent MOC3.");const i=Live2DCubismCore.Moc.fromArrayBuffer(t);if(i){const r=new Zo(i);return r._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(i,t),r}throw new Error("Failed to CubismMoc.create().")}createModel(){let t;const e=Live2DCubismCore.Model.fromMoc(this._moc);if(e)return t=new Gy(e),++this._modelCount,t;throw new Error("Unknown error")}deleteModel(t){t!=null&&--this._modelCount}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){this._moc._release(),this._moc=void 0}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(t){return Live2DCubismCore.Moc.prototype.hasMocConsistency(t)===1}}var Jo=(s=>(s[s.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",s))(Jo||{}),Si=(s=>(s[s.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",s[s.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",s[s.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",s))(Si||{});class Vy{constructor(){this.initialPosition=new at(0,0),this.position=new at(0,0),this.lastPosition=new at(0,0),this.lastGravity=new at(0,0),this.force=new at(0,0),this.velocity=new at(0,0)}}class Hy{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class Xy{constructor(){this.source={}}}class zy{constructor(){this.destination={},this.translationScale=new at(0,0)}}class Wy{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new at(0,0),this.wind=new at(0,0),this.fps=0}}class $y{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new at(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new at(0,0);return t.x=this._json.Meta.EffectiveForces.Wind.X,t.y=this._json.Meta.EffectiveForces.Wind.Y,t}getFps(){return this._json.Meta.Fps||0}getSubRigCount(){return this._json.Meta.PhysicsSettingCount}getTotalInputCount(){return this._json.Meta.TotalInputCount}getTotalOutputCount(){return this._json.Meta.TotalOutputCount}getVertexCount(){return this._json.Meta.VertexCount}getNormalizationPositionMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Default}getNormalizationAngleMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Default}getInputCount(t){return this._json.PhysicsSettings[t].Input.length}getInputWeight(t,e){return this._json.PhysicsSettings[t].Input[e].Weight}getInputReflect(t,e){return this._json.PhysicsSettings[t].Input[e].Reflect}getInputType(t,e){return this._json.PhysicsSettings[t].Input[e].Type}getInputSourceId(t,e){return this._json.PhysicsSettings[t].Input[e].Source.Id}getOutputCount(t){return this._json.PhysicsSettings[t].Output.length}getOutputVertexIndex(t,e){return this._json.PhysicsSettings[t].Output[e].VertexIndex}getOutputAngleScale(t,e){return this._json.PhysicsSettings[t].Output[e].Scale}getOutputWeight(t,e){return this._json.PhysicsSettings[t].Output[e].Weight}getOutputDestinationId(t,e){return this._json.PhysicsSettings[t].Output[e].Destination.Id}getOutputType(t,e){return this._json.PhysicsSettings[t].Output[e].Type}getOutputReflect(t,e){return this._json.PhysicsSettings[t].Output[e].Reflect}getParticleCount(t){return this._json.PhysicsSettings[t].Vertices.length}getParticleMobility(t,e){return this._json.PhysicsSettings[t].Vertices[e].Mobility}getParticleDelay(t,e){return this._json.PhysicsSettings[t].Vertices[e].Delay}getParticleAcceleration(t,e){return this._json.PhysicsSettings[t].Vertices[e].Acceleration}getParticleRadius(t,e){return this._json.PhysicsSettings[t].Vertices[e].Radius}getParticlePosition(t,e){const i=new at(0,0);return i.x=this._json.PhysicsSettings[t].Vertices[e].Position.X,i.y=this._json.PhysicsSettings[t].Vertices[e].Position.Y,i}}const jd="X",Yd="Y",qd="Angle",jy=5,Qo=100,Kd=.001,Yy=5;class th{static create(t){const e=new th;return e.parse(t),e._physicsRig.gravity.y=0,e}static delete(t){t!=null&&t.release()}parse(t){this._physicsRig=new Wy;const e=new $y(t);this._physicsRig.gravity=e.getGravity(),this._physicsRig.wind=e.getWind(),this._physicsRig.subRigCount=e.getSubRigCount(),this._physicsRig.fps=e.getFps(),this._currentRigOutputs=[],this._previousRigOutputs=[];let i=0,r=0,n=0;for(let a=0;a<this._physicsRig.subRigCount;++a){const o=new Hy;o.normalizationPosition.minimum=e.getNormalizationPositionMinimumValue(a),o.normalizationPosition.maximum=e.getNormalizationPositionMaximumValue(a),o.normalizationPosition.defalut=e.getNormalizationPositionDefaultValue(a),o.normalizationAngle.minimum=e.getNormalizationAngleMinimumValue(a),o.normalizationAngle.maximum=e.getNormalizationAngleMaximumValue(a),o.normalizationAngle.defalut=e.getNormalizationAngleDefaultValue(a),o.inputCount=e.getInputCount(a),o.baseInputIndex=i,i+=o.inputCount;for(let u=0;u<o.inputCount;++u){const c=new Xy;switch(c.sourceParameterIndex=-1,c.weight=e.getInputWeight(a,u),c.reflect=e.getInputReflect(a,u),e.getInputType(a,u)){case jd:c.type=Si.CubismPhysicsSource_X,c.getNormalizedParameterValue=Ky;break;case Yd:c.type=Si.CubismPhysicsSource_Y,c.getNormalizedParameterValue=Zy;break;case qd:c.type=Si.CubismPhysicsSource_Angle,c.getNormalizedParameterValue=Jy;break}c.source.targetType=Jo.CubismPhysicsTargetType_Parameter,c.source.id=e.getInputSourceId(a,u),this._physicsRig.inputs.push(c)}o.outputCount=e.getOutputCount(a),o.baseOutputIndex=r;const h=new Zd,l=new Zd;for(let u=0;u<o.outputCount;++u){h.outputs[u]=0,l.outputs[u]=0;let c=this._physicsRig.outputs[r+u];switch(c||(c=new zy,this._physicsRig.outputs[r+u]=c),c.destinationParameterIndex=-1,c.vertexIndex=e.getOutputVertexIndex(a,u),c.angleScale=e.getOutputAngleScale(a,u),c.weight=e.getOutputWeight(a,u),c.destination.targetType=Jo.CubismPhysicsTargetType_Parameter,c.destination.id=e.getOutputDestinationId(a,u),e.getOutputType(a,u)){case jd:c.type=Si.CubismPhysicsSource_X,c.getValue=Qy,c.getScale=sv;break;case Yd:c.type=Si.CubismPhysicsSource_Y,c.getValue=tv,c.getScale=nv;break;case qd:c.type=Si.CubismPhysicsSource_Angle,c.getValue=ev,c.getScale=av;break}c.reflect=e.getOutputReflect(a,u)}this._currentRigOutputs.push(h),this._previousRigOutputs.push(l),r+=o.outputCount,o.particleCount=e.getParticleCount(a),o.baseParticleIndex=n,n+=o.particleCount;for(let u=0;u<o.particleCount;++u){const c=new Vy;c.mobility=e.getParticleMobility(a,u),c.delay=e.getParticleDelay(a,u),c.acceleration=e.getParticleAcceleration(a,u),c.radius=e.getParticleRadius(a,u),c.position=e.getParticlePosition(a,u),this._physicsRig.particles.push(c)}this._physicsRig.settings.push(o)}this.initialize(),e.release()}stabilization(t){var e,i,r,n;let a,o,h,l;const u=new at;let c,d,f,p,g,m,_,b;g=t.getModel().parameters.values,m=t.getModel().parameters.maximumValues,_=t.getModel().parameters.minimumValues,b=t.getModel().parameters.defaultValues,((i=(e=this._parameterCaches)==null?void 0:e.length)!=null?i:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((n=(r=this._parameterInputCaches)==null?void 0:r.length)!=null?n:0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let y=0;y<t.getParameterCount();++y)this._parameterCaches[y]=g[y],this._parameterInputCaches[y]=g[y];for(let y=0;y<this._physicsRig.subRigCount;++y){a={angle:0},u.x=0,u.y=0,c=this._physicsRig.settings[y],d=this._physicsRig.inputs.slice(c.baseInputIndex),f=this._physicsRig.outputs.slice(c.baseOutputIndex),p=this._physicsRig.particles.slice(c.baseParticleIndex);for(let E=0;E<c.inputCount;++E)o=d[E].weight/Qo,d[E].sourceParameterIndex==-1&&(d[E].sourceParameterIndex=t.getParameterIndex(d[E].source.id)),d[E].getNormalizedParameterValue(u,a,g[d[E].sourceParameterIndex],_[d[E].sourceParameterIndex],m[d[E].sourceParameterIndex],b[d[E].sourceParameterIndex],c.normalizationPosition,c.normalizationAngle,d[E].reflect,o),this._parameterCaches[d[E].sourceParameterIndex]=g[d[E].sourceParameterIndex];h=mt.degreesToRadian(-a.angle),u.x=u.x*mt.cos(h)-u.y*mt.sin(h),u.y=u.x*mt.sin(h)+u.y*mt.cos(h),hv(p,c.particleCount,u,a.angle,this._options.wind,Kd*c.normalizationPosition.maximum);for(let E=0;E<c.outputCount;++E){const v=f[E].vertexIndex;if(f[E].destinationParameterIndex==-1&&(f[E].destinationParameterIndex=t.getParameterIndex(f[E].destination.id)),v<1||v>=c.particleCount)continue;let M=new at;M=p[v].position.substract(p[v-1].position),l=f[E].getValue(M,p,v,f[E].reflect,this._options.gravity),this._currentRigOutputs[y].outputs[E]=l,this._previousRigOutputs[y].outputs[E]=l;const T=f[E].destinationParameterIndex,P=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(g.subarray(T))):g.slice(T);eh(P,_[T],m[T],l,f[E]);for(let N=T,G=0;N<this._parameterCaches.length;N++,G++)g[N]=this._parameterCaches[N]=P[G]}}}evaluate(t,e){var i,r,n,a;let o,h,l,u;const c=new at;let d,f,p,g;if(0>=e)return;let m,_,b,y,E;if(this._currentRemainTime+=e,this._currentRemainTime>Yy&&(this._currentRemainTime=0),m=t.getModel().parameters.values,_=t.getModel().parameters.maximumValues,b=t.getModel().parameters.minimumValues,y=t.getModel().parameters.defaultValues,((r=(i=this._parameterCaches)==null?void 0:i.length)!=null?r:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((a=(n=this._parameterInputCaches)==null?void 0:n.length)!=null?a:0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let M=0;M<t.getParameterCount();++M)this._parameterInputCaches[M]=m[M]}for(this._physicsRig.fps>0?E=1/this._physicsRig.fps:E=e;this._currentRemainTime>=E;){for(let T=0;T<this._physicsRig.subRigCount;++T){d=this._physicsRig.settings[T],p=this._physicsRig.outputs.slice(d.baseOutputIndex);for(let P=0;P<d.outputCount;++P)this._previousRigOutputs[T].outputs[P]=this._currentRigOutputs[T].outputs[P]}const M=E/this._currentRemainTime;for(let T=0;T<t.getParameterCount();++T)this._parameterCaches[T]=this._parameterInputCaches[T]*(1-M)+m[T]*M,this._parameterInputCaches[T]=this._parameterCaches[T];for(let T=0;T<this._physicsRig.subRigCount;++T){o={angle:0},c.x=0,c.y=0,d=this._physicsRig.settings[T],f=this._physicsRig.inputs.slice(d.baseInputIndex),p=this._physicsRig.outputs.slice(d.baseOutputIndex),g=this._physicsRig.particles.slice(d.baseParticleIndex);for(let P=0;P<d.inputCount;++P)h=f[P].weight/Qo,f[P].sourceParameterIndex==-1&&(f[P].sourceParameterIndex=t.getParameterIndex(f[P].source.id)),f[P].getNormalizedParameterValue(c,o,this._parameterCaches[f[P].sourceParameterIndex],b[f[P].sourceParameterIndex],_[f[P].sourceParameterIndex],y[f[P].sourceParameterIndex],d.normalizationPosition,d.normalizationAngle,f[P].reflect,h);l=mt.degreesToRadian(-o.angle),c.x=c.x*mt.cos(l)-c.y*mt.sin(l),c.y=c.x*mt.sin(l)+c.y*mt.cos(l),ov(g,d.particleCount,c,o.angle,this._options.wind,Kd*d.normalizationPosition.maximum,E,jy);for(let P=0;P<d.outputCount;++P){const N=p[P].vertexIndex;if(p[P].destinationParameterIndex==-1&&(p[P].destinationParameterIndex=t.getParameterIndex(p[P].destination.id)),N<1||N>=d.particleCount)continue;const G=new at;G.x=g[N].position.x-g[N-1].position.x,G.y=g[N].position.y-g[N-1].position.y,u=p[P].getValue(G,g,N,p[P].reflect,this._options.gravity),this._currentRigOutputs[T].outputs[P]=u;const z=p[P].destinationParameterIndex,D=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(z))):this._parameterCaches.slice(z);eh(D,b[z],_[z],u,p[P]);for(let O=z,V=0;O<this._parameterCaches.length;O++,V++)this._parameterCaches[O]=D[V]}}this._currentRemainTime-=E}const v=this._currentRemainTime/E;this.interpolate(t,v)}interpolate(t,e){let i,r,n,a,o;n=t.getModel().parameters.values,a=t.getModel().parameters.maximumValues,o=t.getModel().parameters.minimumValues;for(let h=0;h<this._physicsRig.subRigCount;++h){r=this._physicsRig.settings[h],i=this._physicsRig.outputs.slice(r.baseOutputIndex);for(let l=0;l<r.outputCount;++l){if(i[l].destinationParameterIndex==-1)continue;const u=i[l].destinationParameterIndex,c=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(n.subarray(u))):n.slice(u);eh(c,o[u],a[u],this._previousRigOutputs[h].outputs[l]*(1-e)+this._currentRigOutputs[h].outputs[l]*e,i[l]);for(let d=u,f=0;d<n.length;d++,f++)n[d]=c[f]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._options=new qy,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=[],this._previousRigOutputs=[],this._currentRemainTime=0}release(){this._physicsRig=void 0}initialize(){let t,e,i;for(let r=0;r<this._physicsRig.subRigCount;++r){e=this._physicsRig.settings[r],t=this._physicsRig.particles.slice(e.baseParticleIndex),t[0].initialPosition=new at(0,0),t[0].lastPosition=new at(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new at(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new at(0,0),t[0].force=new at(0,0);for(let n=1;n<e.particleCount;++n)i=new at(0,0),i.y=t[n].radius,t[n].initialPosition=new at(t[n-1].initialPosition.x+i.x,t[n-1].initialPosition.y+i.y),t[n].position=new at(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastPosition=new at(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastGravity=new at(0,-1),t[n].lastGravity.y*=-1,t[n].velocity=new at(0,0),t[n].force=new at(0,0)}}}class qy{constructor(){this.gravity=new at(0,0),this.wind=new at(0,0)}}class Zd{constructor(){this.outputs=[]}}function Ky(s,t,e,i,r,n,a,o,h,l){s.x+=ih(e,i,r,n,a.minimum,a.maximum,a.defalut,h)*l}function Zy(s,t,e,i,r,n,a,o,h,l){s.y+=ih(e,i,r,n,a.minimum,a.maximum,a.defalut,h)*l}function Jy(s,t,e,i,r,n,a,o,h,l){t.angle+=ih(e,i,r,n,o.minimum,o.maximum,o.defalut,h)*l}function Qy(s,t,e,i,r){let n=s.x;return i&&(n*=-1),n}function tv(s,t,e,i,r){let n=s.y;return i&&(n*=-1),n}function ev(s,t,e,i,r){let n;return e>=2?r=t[e-1].position.substract(t[e-2].position):r=r.multiplyByScaler(-1),n=mt.directionToRadian(r,s),i&&(n*=-1),n}function iv(s,t){return Math.abs(Math.max(s,t)-Math.min(s,t))}function rv(s,t){return Math.min(s,t)+iv(s,t)/2}function sv(s,t){return s.x}function nv(s,t){return s.y}function av(s,t){return t}function ov(s,t,e,i,r,n,a,o){let h,l,u,c,d=new at(0,0),f=new at(0,0),p=new at(0,0),g=new at(0,0);s[0].position=new at(e.x,e.y),h=mt.degreesToRadian(i),c=mt.radianToDirection(h),c.normalize();for(let m=1;m<t;++m)s[m].force=c.multiplyByScaler(s[m].acceleration).add(r),s[m].lastPosition=new at(s[m].position.x,s[m].position.y),l=s[m].delay*a*30,d=s[m].position.substract(s[m-1].position),u=mt.directionToRadian(s[m].lastGravity,c)/o,d.x=mt.cos(u)*d.x-d.y*mt.sin(u),d.y=mt.sin(u)*d.x+d.y*mt.cos(u),s[m].position=s[m-1].position.add(d),f=s[m].velocity.multiplyByScaler(l),p=s[m].force.multiplyByScaler(l).multiplyByScaler(l),s[m].position=s[m].position.add(f).add(p),g=s[m].position.substract(s[m-1].position),g.normalize(),s[m].position=s[m-1].position.add(g.multiplyByScaler(s[m].radius)),mt.abs(s[m].position.x)<n&&(s[m].position.x=0),l!=0&&(s[m].velocity=s[m].position.substract(s[m].lastPosition),s[m].velocity=s[m].velocity.divisionByScalar(l),s[m].velocity=s[m].velocity.multiplyByScaler(s[m].mobility)),s[m].force=new at(0,0),s[m].lastGravity=new at(c.x,c.y)}function hv(s,t,e,i,r,n){let a,o,h=new at(0,0);s[0].position=new at(e.x,e.y),a=mt.degreesToRadian(i),o=mt.radianToDirection(a),o.normalize();for(let l=1;l<t;++l)s[l].force=o.multiplyByScaler(s[l].acceleration).add(r),s[l].lastPosition=new at(s[l].position.x,s[l].position.y),s[l].velocity=new at(0,0),h=s[l].force,h.normalize(),h=h.multiplyByScaler(s[l].radius),s[l].position=s[l-1].position.add(h),mt.abs(s[l].position.x)<n&&(s[l].position.x=0),s[l].force=new at(0,0),s[l].lastGravity=new at(o.x,o.y)}function eh(s,t,e,i,r){let n,a,o;n=r.getScale(r.translationScale,r.angleScale),a=i*n,a<t?(a<r.valueBelowMinimum&&(r.valueBelowMinimum=a),a=t):a>e&&(a>r.valueExceededMaximum&&(r.valueExceededMaximum=a),a=e),o=r.weight/Qo,o>=1||(a=s[0]*(1-o)+a*o),s[0]=a}function ih(s,t,e,i,r,n,a,o){let h=0;const l=mt.max(e,t);l<s&&(s=l);const u=mt.min(e,t);u>s&&(s=u);const c=mt.min(r,n),d=mt.max(r,n),f=a,p=rv(u,l),g=s-p;switch(Math.sign(g)){case 1:{const m=d-f,_=l-p;_!=0&&(h=g*(m/_),h+=f);break}case-1:{const m=c-f,_=u-p;_!=0&&(h=g*(m/_),h+=f);break}case 0:{h=f;break}}return o?h:h*-1}jt.registerRuntime({version:4,ready:Oy,test(s){return s instanceof Zi||Zi.isValidJSON(s)},isValidMoc(s){if(s.byteLength<4)return!1;const t=new Int8Array(s,0,4);return String.fromCharCode(...t)==="MOC3"},createModelSettings(s){return new Zi(s)},createCoreModel(s,t){const e=Zo.create(s,!!(t!=null&&t.checkMocConsistency));try{const i=e.createModel();return i.__moc=e,i}catch(i){try{e.release()}catch{}throw i}},createInternalModel(s,t,e){const i=new Ly(s,t,e),r=s;return r.__moc&&(i.__moc=r.__moc,delete r.__moc,i.once("destroy",lv)),i},createPhysics(s,t){return th.create(t)},createPose(s,t){return Ko.create(t)}});function lv(){var s;(s=this.__moc)==null||s.release()}async function uv(s){const{models:t,element_id:e,auto_fit:i=!0,auto_motion:r=!0,mouse_tracking:n=!0}=s,a=new fo({view:document.getElementById(e),width:300,height:300,backgroundAlpha:0,autoDensity:!0,antialias:!0}),o=await Ho.from(t[0]);if(a.stage.addChild(o),i){const h=Math.min(300/o.width,300/o.height);o.scale.set(h),o.x=(300-o.width*h)/2,o.y=(300-o.height*h)/2}return n&&cv(o,a.view),r&&await dv(o),o}function cv(s,t){document.addEventListener("mousemove",e=>{var h;const i=t.getBoundingClientRect(),r=i.left+i.width/2,n=i.top+i.height/2,a=(e.clientX-r)/i.width,o=(e.clientY-n)/i.height;s.internalModel&&((h=s.internalModel.focusController)==null||h.focus(a,o))})}async function dv(s){var t;try{const e=(t=s.internalModel)==null?void 0:t.motionManager.definitions;if(e)if(e.idle)await s.motion("idle");else if(e.tap_body)await s.motion("tap_body");else{const i=Object.keys(e)[0];i&&await s.motion(i)}}catch(e){console.warn("Failed to start idle animation:",e)}}async function fv(s,t){Ho.registerTicker(Pt),Q.add(As),Q.add(x_)}ae.Live2DModel=Ho,ae.MotionManager=zr,ae.PIXI=m_,ae.SoundManager=Dt,ae.createLive2dModel=uv,ae.initializeLive2D=fv,Object.defineProperty(ae,Symbol.toStringTag,{value:"Module"})});