cc.js 1.3 MB

1
  1. System.register(["./instantiated-443542f0.js"],(function(t){"use strict";var e,i,n,r,s,a,o,h,l,u,c,d,_,f,p,g,m,v,y,T,S,E,A,C,R,b,x,w,M,I,B,P,D,O,F,L,N,k,U,G,V,H,z,X,W,Y,j,K,q,Z,Q,J,$,tt,et,it,nt,rt,st,at,ot,ht,lt,ut,ct,dt,_t,ft,pt,gt,mt,vt,yt,Tt,St,Et,At,Ct,Rt,bt,xt,wt,Mt,It,Bt,Pt,Dt,Ot,Ft,Lt,Nt,kt,Ut,Gt,Vt,Ht,zt,Xt,Wt,Yt,jt,Kt,qt,Zt,Qt,Jt,$t,te,ee,ie,ne,re,se,ae,oe,he,le,ue,ce,de,_e,fe,pe,ge,me,ve,ye,Te,Se,Ee,Ae,Ce,Re,be,xe,we,Me,Ie,Be,Pe,De,Oe,Fe,Le,Ne,ke,Ue,Ge,Ve,He,ze,Xe,We,Ye,je,Ke,qe,Ze,Qe,Je,$e,ti,ei,ii,ni,ri,si,ai,oi,hi,li,ui,ci,di,_i,fi,pi,gi,mi,vi,yi,Ti,Si,Ei,Ai,Ci,Ri,bi,xi,wi,Mi,Ii,Bi,Pi,Di,Oi,Fi,Li,Ni,ki,Ui,Gi,Vi,Hi,zi,Xi,Wi,Yi,ji,Ki,qi,Zi,Qi,Ji,$i,tn,en,nn,rn,sn,an,on,hn,ln,un,cn,dn,_n,fn,pn,gn,mn,vn,yn,Tn,Sn,En,An,Cn,Rn,bn,xn,wn,Mn,In,Bn,Pn,Dn,On,Fn,Ln,Nn,kn,Un,Gn,Vn,Hn,zn,Xn,Wn,Yn,jn,Kn,qn,Zn,Qn,Jn,$n,tr,er,ir,nr,rr,sr,ar,or,hr,lr,ur,cr,dr,_r,fr,pr,gr,mr,vr,yr,Tr,Sr,Er,Ar,Cr,Rr,br,xr,wr,Mr,Ir,Br,Pr,Dr,Or,Fr,Lr,Nr,kr,Ur,Gr,Vr,Hr,zr,Xr,Wr,Yr,jr,Kr,qr,Zr,Qr,Jr,$r,ts,es,is,ns,rs,ss,as,os,hs,ls,us,cs,ds,_s,fs,ps,gs,ms,vs,ys,Ts,Ss,Es,As,Cs,Rs,bs,xs,ws,Ms,Is,Bs,Ps,Ds,Os,Fs,Ls,Ns,ks,Us,Gs,Vs,Hs,zs,Xs,Ws,Ys,js,Ks,qs,Zs,Qs,Js,$s,ta,ea,ia,na,ra,sa,aa,oa,ha,la,ua,ca,da,_a,fa,pa,ga,ma,va,ya,Ta,Sa,Ea,Aa,Ca,Ra,ba,xa,wa,Ma,Ia,Ba,Pa,Da,Oa,Fa,La,Na,ka,Ua,Ga,Va,Ha,za;return{setters:[function(Xa){e=Xa.P,i=Xa.R,n=Xa.C,r=Xa.a,s=Xa.D,a=Xa.B,o=Xa.b,h=Xa.O,l=Xa.S,u=Xa.A,c=Xa.c,d=Xa.F,_=Xa.d,f=Xa.e,p=Xa.T,g=Xa.f,m=Xa.g,v=Xa.M,y=Xa.h,T=Xa.i,S=Xa.j,E=Xa.k,A=Xa.l,C=Xa.m,R=Xa.V,b=Xa.n,x=Xa.o,w=Xa.p,M=Xa.q,I=Xa.r,B=Xa.s,P=Xa.t,D=Xa.u,O=Xa.L,F=Xa.v,L=Xa.w,N=Xa.x,k=Xa.y,U=Xa.z,G=Xa.E,V=Xa.G,H=Xa.H,z=Xa.I,X=Xa.J,W=Xa.K,Y=Xa.Q,j=Xa.N,K=Xa.U,q=Xa.W,Z=Xa.X,Q=Xa.Y,J=Xa.Z,$=Xa._,tt=Xa.$,et=Xa.a0,it=Xa.a1,nt=Xa.a2,rt=Xa.a3,st=Xa.a4,at=Xa.a5,ot=Xa.a6,ht=Xa.a7,lt=Xa.a8,ut=Xa.a9,ct=Xa.aa,dt=Xa.ab,_t=Xa.ac,ft=Xa.ad,pt=Xa.ae,gt=Xa.af,mt=Xa.ag,vt=Xa.ah,yt=Xa.ai,Tt=Xa.aj,St=Xa.ak,Et=Xa.al,At=Xa.am,Ct=Xa.an,Rt=Xa.ao,bt=Xa.ap,xt=Xa.aq,wt=Xa.ar,Mt=Xa.as,It=Xa.at,Bt=Xa.au,Pt=Xa.av,Dt=Xa.aw,Ot=Xa.ax,Ft=Xa.ay,Lt=Xa.az,Nt=Xa.aA,kt=Xa.aB,Ut=Xa.aC,Gt=Xa.aD,Vt=Xa.aE,Ht=Xa.aF,zt=Xa.aG,Xt=Xa.aH,Wt=Xa.aI,Yt=Xa.aJ,jt=Xa.aK,Kt=Xa.aL,qt=Xa.aM,Zt=Xa.aN,Qt=Xa.aO,Jt=Xa.aP,$t=Xa.aQ,te=Xa.aR,ee=Xa.aS,ie=Xa.aT,ne=Xa.aU,re=Xa.aV,se=Xa.aW,ae=Xa.aX,oe=Xa.aY,he=Xa.aZ,le=Xa.a_,ue=Xa.a$,ce=Xa.b0,de=Xa.b1,_e=Xa.b2,fe=Xa.b3,pe=Xa.b4,ge=Xa.b5,me=Xa.b6,ve=Xa.b7,ye=Xa.b8,Te=Xa.b9,Se=Xa.ba,Ee=Xa.bb,Ae=Xa.bc,Ce=Xa.bd,Re=Xa.be,be=Xa.bf,xe=Xa.bg,we=Xa.bh,Me=Xa.bi,Ie=Xa.bj,Be=Xa.bk,Pe=Xa.bl,De=Xa.bm,Oe=Xa.bn,Fe=Xa.bo,Le=Xa.bp,Ne=Xa.bq,ke=Xa.br,Ue=Xa.bs,Ge=Xa.bt,Ve=Xa.bu,He=Xa.bv,ze=Xa.bw,Xe=Xa.bx,We=Xa.by,Ye=Xa.bz,je=Xa.bA,Ke=Xa.bB,qe=Xa.bC,Ze=Xa.bD,Qe=Xa.bE,Je=Xa.bF,$e=Xa.bG,ti=Xa.bH,ei=Xa.bI,ii=Xa.bJ,ni=Xa.bK,ri=Xa.bL,si=Xa.bM,ai=Xa.bN,oi=Xa.bO,hi=Xa.bP,li=Xa.bQ,ui=Xa.bR,ci=Xa.bS,di=Xa.bT,_i=Xa.bU,fi=Xa.bV,pi=Xa.bW,gi=Xa.bX,mi=Xa.bY,vi=Xa.bZ,yi=Xa.b_,Ti=Xa.b$,Si=Xa.c0,Ei=Xa.c1,Ai=Xa.c2,Ci=Xa.c3,Ri=Xa.c4,bi=Xa.c5,xi=Xa.c6,wi=Xa.c7,Mi=Xa.c8,Ii=Xa.c9,Bi=Xa.ca,Pi=Xa.cb,Di=Xa.cc,Oi=Xa.cd,Fi=Xa.ce,Li=Xa.cf,Ni=Xa.cg,ki=Xa.ch,Ui=Xa.ci,Gi=Xa.cj,Vi=Xa.ck,Hi=Xa.cl,zi=Xa.cm,Xi=Xa.cn,Wi=Xa.co,Yi=Xa.cp,ji=Xa.cq,Ki=Xa.cr,qi=Xa.cs,Zi=Xa.ct,Qi=Xa.cu,Ji=Xa.cv,$i=Xa.cw,tn=Xa.cx,en=Xa.cy,nn=Xa.cz,rn=Xa.cA,sn=Xa.cB,an=Xa.cC,on=Xa.cD,hn=Xa.cE,ln=Xa.cF,un=Xa.cG,cn=Xa.cH,dn=Xa.cI,_n=Xa.cJ,fn=Xa.cK,pn=Xa.cL,gn=Xa.cM,mn=Xa.cN,vn=Xa.cO,yn=Xa.cP,Tn=Xa.cQ,Sn=Xa.cR,En=Xa.cS,An=Xa.cT,Cn=Xa.cU,Rn=Xa.cV,bn=Xa.cW,xn=Xa.cX,wn=Xa.cY,Mn=Xa.cZ,In=Xa.c_,Bn=Xa.c$,Pn=Xa.d0,Dn=Xa.d1,On=Xa.d2,Fn=Xa.d3,Ln=Xa.d4,Nn=Xa.d5,kn=Xa.d6,Un=Xa.d7,Gn=Xa.d8,Vn=Xa.d9,Hn=Xa.da,zn=Xa.db,Xn=Xa.dc,Wn=Xa.dd,Yn=Xa.de,jn=Xa.df,Kn=Xa.dg,qn=Xa.dh,Zn=Xa.di,Qn=Xa.dj,Jn=Xa.dk,$n=Xa.dl,tr=Xa.dm,er=Xa.dn,ir=Xa.dp,nr=Xa.dq,rr=Xa.dr,sr=Xa.ds,ar=Xa.dt,or=Xa.du,hr=Xa.dv,lr=Xa.dw,ur=Xa.dx,cr=Xa.dy,dr=Xa.dz,_r=Xa.dA,fr=Xa.dB,pr=Xa.dC,gr=Xa.dD,mr=Xa.dE,vr=Xa.dF,yr=Xa.dG,Tr=Xa.dH,Sr=Xa.dI,Er=Xa.dJ,Ar=Xa.dK,Cr=Xa.dL,Rr=Xa.dM,br=Xa.dN,xr=Xa.dO,wr=Xa.dP,Mr=Xa.dQ,Ir=Xa.dR,Br=Xa.dS,Pr=Xa.dT,Dr=Xa.dU,Or=Xa.dV,Fr=Xa.dW,Lr=Xa.dX,Nr=Xa.dY,kr=Xa.dZ,Ur=Xa.d_,Gr=Xa.d$,Vr=Xa.e0,Hr=Xa.e1,zr=Xa.e2,Xr=Xa.e3,Wr=Xa.e4,Yr=Xa.e5,jr=Xa.e6,Kr=Xa.e7,qr=Xa.e8,Zr=Xa.e9,Qr=Xa.ea,Jr=Xa.eb,$r=Xa.ec,ts=Xa.ed,es=Xa.ee,is=Xa.ef,ns=Xa.eg,rs=Xa.eh,ss=Xa.ei,as=Xa.ej,os=Xa.ek,hs=Xa.el,ls=Xa.em,us=Xa.en,cs=Xa.eo,ds=Xa.ep,_s=Xa.eq,fs=Xa.er,ps=Xa.es,gs=Xa.et,ms=Xa.eu,vs=Xa.ev,ys=Xa.ew,Ts=Xa.ex,Ss=Xa.ey,Es=Xa.ez,As=Xa.eA,Cs=Xa.eB,Rs=Xa.eC,bs=Xa.eD,xs=Xa.eE,ws=Xa.eF,Ms=Xa.eG,Is=Xa.eH,Bs=Xa.eI,Ps=Xa.eJ,Ds=Xa.eK,Os=Xa.eL,Fs=Xa.eM,Ls=Xa.eN,Ns=Xa.eO,ks=Xa.eP,Us=Xa.eQ,Gs=Xa.eR,Vs=Xa.eS,Hs=Xa.eT,zs=Xa.eU,Xs=Xa.eV,Ws=Xa.eW,Ys=Xa.eX,js=Xa.eY,Ks=Xa.eZ,qs=Xa.e_,Zs=Xa.e$,Qs=Xa.f0,Js=Xa.f1,$s=Xa.f2,ta=Xa.f3,ea=Xa.f4,ia=Xa.f5,na=Xa.f6,ra=Xa.f7,sa=Xa.f8,aa=Xa.f9,oa=Xa.fa,ha=Xa.fb,la=Xa.fc,ua=Xa.fd,ca=Xa.fe,da=Xa.ff,_a=Xa.fg,fa=Xa.fh,pa=Xa.fi,ga=Xa.fj,ma=Xa.fk,va=Xa.fl,ya=Xa.fm,Ta=Xa.fn,Sa=Xa.fo,Ea=Xa.fp,Aa=Xa.fq,Ca=Xa.fr,Ra=Xa.fs,ba=Xa.ft,xa=Xa.fu,wa=Xa.fv,Ma=Xa.fw,Ia=Xa.fx,Ba=Xa.fy,Pa=Xa.fz,Da=Xa.fA,Oa=Xa.fB,Fa=Xa.fC,La=Xa.fD,Na=Xa.fE,ka=Xa.fF,Ua=Xa.fG,Ga=Xa.fH,Va=Xa.fI,Ha=Xa.fJ,za=Xa.fK;var Wa={};Wa.Acceleration=Xa.hI,Wa.AffineTransform=Xa.fU,Wa.AmbientInfo=Xa.ha,Wa.Asset=Xa.cw,Wa.AssetLibrary=Xa.hB,Wa.AssetManager=Xa.hx,Wa.AsyncDelegate=Xa.gk,Wa.BITMASK_TAG=Xa.gE,Wa.BaseNode=Xa.dT,Wa.BitMask=Xa.g4,Wa.BloomStage=Xa.gY,Wa.BufferAsset=Xa.ho,Wa.CCBoolean=Xa.eb,Wa.CCClass=Xa.fd,Wa.CCFloat=Xa.ec,Wa.CCInteger=Xa.ea,Wa.CCLoader=Xa.hz,Wa.CCObject=Xa.dU,Wa.CCString=Xa.eg,Wa.CachedArray=Xa.C,Wa.CallbacksInvoker=Xa.gG,Wa.Color=Xa.bu,Wa.CompactValueTypeArray=Xa.gf,Wa.Component=Xa.d0,Wa.DEFAULT_OCTREE_DEPTH=Xa.hg,Wa.DEFAULT_WORLD_MAX_POS=Xa.hf,Wa.DEFAULT_WORLD_MIN_POS=Xa.he,Wa.DebugMode=Xa.gn,Wa.DebugView=Xa.h4,Wa.DeferredPipeline=Xa.gU,Wa.Details=Xa.hn,Wa.Director=Xa.cT,Wa.ENUM_TAG=Xa.gD,Wa.EPSILON=Xa.cZ,Wa.EasingMethod=Xa.eD,Wa.EditorExtendable=Xa.eo,Wa.EffectAsset=Xa.ht,Wa.Enum=Xa.dB,Wa.Event=Xa.fy,Wa.EventAcceleration=Xa.hD,Wa.EventGamepad=Xa.fH,Wa.EventHMD=Xa.hG,Wa.EventHandheld=Xa.hH,Wa.EventHandle=Xa.fI,Wa.EventHandler=Xa.fz,Wa.EventKeyboard=Xa.hE,Wa.EventMouse=Xa.hF,Wa.EventTarget=Xa.ee,Wa.EventTouch=Xa.fF,Wa.Eventify=Xa.dL,Wa.ExtrapolationMode=Xa.gp,Wa.FogInfo=Xa.hc,Wa.ForwardFlow=Xa.gS,Wa.ForwardPipeline=Xa.gR,Wa.ForwardStage=Xa.gT,Wa.GCObject=Xa.gC,Wa.Game=Xa.e9,Wa.GbufferStage=Xa.gW,Wa.HALF_PI=Xa.fY,Wa.ImageAsset=Xa.ci,Wa.Input=Xa.d_,Wa.InstancedBuffer=Xa.h0,Wa.JavaScript=Xa.hv,Wa.JsonAsset=Xa.hr,Wa.KeyCode=Xa.fB,Wa.Layers=Xa.dc,Wa.LightProbeInfo=Xa.hi,Wa.LightingStage=Xa.gX,Wa.MATH_FLOAT_ARRAY=Xa.g2,Wa.MainFlow=Xa.gV,Wa.Mat3=Xa.fb,Wa.Mat4=Xa.bs,Wa.Material=Xa.d1,Wa.MathBase=Xa.g3,Wa.MissingScript=Xa.hl,Wa.MobilityMode=Xa.ed,Wa.Node=Xa.dT,Wa.NodeActivator=Xa.h8,Wa.NodeEventType=Xa.cX,Wa.NodeSpace=Xa.h9,Wa.ObjectCurve=Xa.ex,Wa.OctreeInfo=Xa.hh,Wa.PipelineEventProcessor=Xa.h2,Wa.PipelineEventType=Xa.h3,Wa.PipelineSceneData=Xa.gQ,Wa.PipelineStateManager=Xa.h1,Wa.Pool=Xa.P,Wa.PostProcessStage=Xa.gZ,Wa.Prefab=Xa.dR,Wa.PrivateNode=Xa.hk,Wa.Quat=Xa.cv,Wa.QuatCurve=Xa.ew,Wa.QuatInterpolationMode=Xa.eG,Wa.RealCurve=Xa.et,Wa.RealInterpolationMode=Xa.eE,Wa.Rect=Xa.cG,Wa.RecyclePool=Xa.R,Wa.ReflectionProbeFlow=Xa.h5,Wa.ReflectionProbeStage=Xa.h6,Wa.RenderFlow=Xa.gO,Wa.RenderPipeline=Xa.gN,Wa.RenderStage=Xa.gP,Wa.RenderTexture=Xa.dx,Wa.RenderingSubMesh=Xa.cs,Wa.Root=Xa.fL,Wa.Scene=Xa.fK,Wa.SceneAsset=Xa.hp,Wa.SceneGlobals=Xa.hj,Wa.Scheduler=Xa.go,Wa.Script=Xa.hu,Wa.Settings=Xa.dI,Wa.ShadowFlow=Xa.g_,Wa.ShadowStage=Xa.g$,Wa.ShadowsInfo=Xa.hd,Wa.Size=Xa.cI,Wa.SkyboxInfo=Xa.hb,Wa.System=Xa.cd,Wa.SystemEvent=Xa.hL,Wa.SystemEventType=Xa.fG,Wa.TWO_PI=Xa.fZ,Wa.TangentWeightMode=Xa.eF,Wa.TextAsset=Xa.hq,Wa.Texture2D=Xa.bx,Wa.TextureCube=Xa.hs,Wa.Touch=Xa.hJ,Wa.TransformBit=Xa.dC,Wa.TypeScript=Xa.hw,Wa.VERSION=Xa.fx,Wa.ValueType=Xa.eC,Wa.Vec2=Xa.cH,Wa.Vec3=Xa.cq,Wa.Vec4=Xa.cJ,Wa.WorldNode3DToLocalNodeUI=Xa.gb,Wa.WorldNode3DToWorldNodeUI=Xa.gc,Wa.__checkObsoleteInNamespace__=Xa.ga,Wa.__checkObsolete__=Xa.g9,Wa._decorator=Xa.ge,Wa._resetDebugSetting=Xa.gH,Wa.absMax=Xa.fs,Wa.absMaxComponent=Xa.fv,Wa.approx=Xa.cY,Wa.assert=Xa.eQ,Wa.assertID=Xa.cV,Wa.assertIsNonNullable=Xa.cm,Wa.assertIsTrue=Xa.cg,Wa.assertsArrayIndex=Xa.a,Wa.assetManager=Xa.fq,Wa.bezier=Xa.gq,Wa.bezierByTime=Xa.ez,Wa.binarySearch=Xa.gI,Wa.binarySearchBy=Xa.gJ,Wa.binarySearchEpsilon=Xa.eA,Wa.bits=Xa.fO,Wa.builtinResMgr=Xa.d5,Wa.ccenum=Xa.d3,Wa.cclegacy=Xa.by,Wa.clamp=Xa.bt,Wa.clamp01=Xa.eI,Wa.color=Xa.fX,Wa.convertUtils=Xa.gd,Wa.createDefaultPipeline=Xa.gM,Wa.debug=Xa.d8,Wa.deprecateModuleExportedName=Xa.dA,Wa.deserialize=Xa.hm,Wa.deserializeTag=Xa.gh,Wa.director=Xa.cc,Wa.disallowAnimation=Xa.gA,Wa.displayName=Xa.gv,Wa.displayOrder=Xa.gw,Wa.easing=Xa.ey,Wa.editable=Xa.gs,Wa.editorExtrasTag=Xa.gg,Wa.enumerableProps=Xa.g1,Wa.equals=Xa.fp,Wa.error=Xa.eP,Wa.errorID=Xa.cE,Wa.find=Xa.cC,Wa.flattenCodeArray=Xa.gK,Wa.formerlySerializedAs=Xa.ef,Wa.game=Xa.e8,Wa.garbageCollectionManager=Xa.gB,Wa.geometry=Xa.fN,Wa.getError=Xa.cU,Wa.getPhaseID=Xa.h7,Wa.getSerializationMetadata=Xa.gj,Wa.input=Xa.e0,Wa.inverseLerp=Xa.g0,Wa.isCCClassOrFastDefined=Xa.f7,Wa.isCCObject=Xa.f5,Wa.isDisplayStats=Xa.gl,Wa.isValid=Xa.gF,Wa.js=Xa.g5,Wa.jsbUtils=Xa.gr,Wa.lerp=Xa.eB,Wa.loader=Xa.hA,Wa.log=Xa.eO,Wa.logID=Xa.dZ,Wa.macro=Xa.c8,Wa.markAsWarning=Xa.dM,Wa.mat4=Xa.fT,Wa.math=Xa.fM,Wa.misc=Xa.g6,Wa.murmurhash2_32_gc=Xa.cz,Wa.nextPow2=Xa.ck,Wa.override=Xa.cN,Wa.path=Xa.g7,Wa.pingPong=Xa.fm,Wa.pipeline=Xa.gL,Wa.preTransforms=Xa.fw,Wa.pseudoRandom=Xa.fl,Wa.pseudoRandomRange=Xa.f_,Wa.pseudoRandomRangeInt=Xa.f$,Wa.quat=Xa.fS,Wa.random=Xa.fh,Wa.randomRange=Xa.fi,Wa.randomRangeInt=Xa.fj,Wa.range=Xa.gx,Wa.rangeStep=Xa.gy,Wa.rect=Xa.fW,Wa.removeProperty=Xa.d9,Wa.repeat=Xa.fg,Wa.replaceProperty=Xa.db,Wa.resources=Xa.hy,Wa.screen=Xa.dK,Wa.serializable=Xa.cy,Wa.serializeTag=Xa.gi,Wa.setDefaultLogTimes=Xa.g8,Wa.setDisplayStats=Xa.gm,Wa.settings=Xa.dH,Wa.size=Xa.fV,Wa.slide=Xa.gz,Wa.sys=Xa.cA,Wa.systemEvent=Xa.hK,Wa.toDegree=Xa.fc,Wa.toRadian=Xa.dE,Wa.tooltip=Xa.gt,Wa.url=Xa.hC,Wa.v2=Xa.fP,Wa.v3=Xa.fQ,Wa.v4=Xa.fR,Wa.visible=Xa.gu,Wa.visibleRect=Xa.c$,Wa.warn=Xa.cj,Wa.warnID=Xa.ct,t(Wa)}],execute:function(){t({CacheMode:void 0,EAxisDirection:void 0,ERigidBodyType:void 0,HorizontalTextAlignment:void 0,InstanceMaterialType:void 0,Overflow:void 0,ReflectionProbeType:void 0,VerticalTextAlignment:void 0,applyMixins:function(t,e){e.forEach((function(e){Object.getOwnPropertyNames(e.prototype).forEach((function(i){"constructor"!==i&&Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))}))}))},computeRatioByType:Hb,earcut:Zp,fragmentText:Eh,getBaselineOffset:function(){return 0},getEnglishWordPartAtFirst:Th,getEnglishWordPartAtLast:Sh,getPathFromRoot:function(t,e){for(var i=t,n="";null!==i&&i!==e;)n=i.name+"/"+n,i=i.parent;return n.slice(0,-1)},getWorldTransformUntilRoot:AE,instantiate:rI,isEnglishWordPartAtFirst:function(t){return ph.test(t)},isEnglishWordPartAtLast:function(t){return fh.test(t)},isUnicodeCJK:gh,isUnicodeSpace:mh,safeMeasureText:vh,sampleAnimationCurve:Vb,shift:function(t,e,i){if(r(t,e),r(t,i),e===i)return t;var n=t[e];if(e<i)for(var s=e+1;s<=i;++s)t[s-1]=t[s];else for(var a=e;a!==i;--a)t[a]=t[a-1];return t[i]=n,t},tween:pJ,tweenUtil:gJ}),t("memop",Object.freeze({__proto__:null,Pool:e,RecyclePool:i,CachedArray:n})),t("gfx",Object.freeze({__proto__:null,DescriptorSet:s,Buffer:a,CommandBuffer:o,get ObjectType(){return h},get Status(){return l},get API(){return u},get SurfaceTransform(){return c},get Feature(){return d},get Format(){return _},get FormatType(){return f},get Type(){return p},get BufferUsageBit(){return g},get BufferFlagBit(){return m},get MemoryAccessBit(){return v},get MemoryUsageBit(){return y},get TextureType(){return T},get TextureUsageBit(){return S},get TextureFlagBit(){return E},get FormatFeatureBit(){return A},get SampleCount(){return C},get VsyncMode(){return R},get Filter(){return b},get Address(){return x},get ComparisonFunc(){return w},get StencilOp(){return M},get BlendFactor(){return I},get BlendOp(){return B},get ColorMask(){return P},get ShaderStageFlagBit(){return D},get LoadOp(){return O},get StoreOp(){return F},get AccessFlagBit(){return L},get ResolveMode(){return N},get PipelineBindPoint(){return k},get PrimitiveMode(){return U},get PolygonMode(){return G},get ShadeModel(){return V},get CullMode(){return H},get DynamicStateFlagBit(){return z},get StencilFace(){return X},get DescriptorType(){return W},get QueueType(){return Y},get QueryType(){return j},get CommandBufferType(){return K},get ClearFlagBit(){return q},get BarrierType(){return Z},get PassType(){return Q},Size:J,DeviceCaps:$,DeviceOptions:tt,Offset:et,Rect:it,Extent:nt,TextureSubresLayers:rt,TextureSubresRange:st,TextureCopy:at,TextureBlit:ot,BufferTextureCopy:ht,Viewport:lt,Color:ut,BindingMappingInfo:ct,SwapchainInfo:dt,DeviceInfo:_t,BufferInfo:ft,BufferViewInfo:pt,DrawInfo:gt,DispatchInfo:mt,IndirectBuffer:vt,TextureInfo:yt,TextureViewInfo:Tt,SamplerInfo:St,Uniform:Et,UniformBlock:At,UniformSamplerTexture:Ct,UniformSampler:Rt,UniformTexture:bt,UniformStorageImage:xt,UniformStorageBuffer:wt,UniformInputAttachment:Mt,ShaderStage:It,Attribute:Bt,ShaderInfo:Pt,InputAssemblerInfo:Dt,ColorAttachment:Ot,DepthStencilAttachment:Ft,SubpassInfo:Lt,SubpassDependency:Nt,RenderPassInfo:kt,GeneralBarrierInfo:Ut,TextureBarrierInfo:Gt,BufferBarrierInfo:Vt,FramebufferInfo:Ht,DescriptorSetLayoutBinding:zt,DescriptorSetLayoutInfo:Xt,DescriptorSetInfo:Wt,PipelineLayoutInfo:Yt,InputState:jt,CommandBufferInfo:Kt,QueueInfo:qt,QueryPoolInfo:Zt,FormatInfo:Qt,MemoryStatus:Jt,DynamicStencilStates:$t,DynamicStates:te,GFXObject:ee,get AttributeName(){return ie},FormatInfos:ne,DESCRIPTOR_BUFFER_TYPE:re,DESCRIPTOR_SAMPLER_TYPE:se,DESCRIPTOR_DYNAMIC_TYPE:ae,DRAW_INFO_SIZE:oe,IsPowerOf2:he,FormatSize:le,FormatSurfaceSize:ue,GetTypeSize:ce,getTypedArrayConstructor:de,formatAlignment:_e,alignTo:fe,Device:pe,DefaultResource:ge,Swapchain:me,Framebuffer:ve,InputAssembler:ye,DescriptorSetLayout:Te,PipelineLayout:Se,RasterizerState:Ee,DepthStencilState:Ae,BlendTarget:Ce,BlendState:Re,PipelineStateInfo:be,PipelineState:xe,Queue:we,RenderPass:Me,Sampler:Ie,Shader:Be,Texture:Pe,GeneralBarrier:De,TextureBarrier:Oe,get LegacyRenderMode(){return Fe},get RenderType(){return Le},DeviceManager:Ne,deviceManager:ke}));var Xa=new Ue;function Wa(t,e,i,n){var r=i.chunk,s=i.data,a=r.vb,o=i.vertexCount;t.getWorldMatrix(Xa);for(var h=0,l=0;l<o;l++){var u=s[l],c=u.x,d=u.y,_=Xa.m03*c+Xa.m07*d+Xa.m15;_=_?Math.abs(1/_):1,a[h+0]=(Xa.m00*c+Xa.m04*d+Xa.m12)*_,a[h+1]=(Xa.m01*c+Xa.m05*d+Xa.m13)*_,a[h+2]=(Xa.m02*c+Xa.m06*d+Xa.m14)*_,Ve.toArray(a,n,h+5),h+=9}r.bufferId;for(var f=r.vertexOffset,p=r.meshBuffer,g=r.meshBuffer.iData,m=p.indexOffset,v=0,y=o/4;v<y;v++){var T=f+4*v;g[m++]=T,g[m++]=T+1,g[m++]=T+2,g[m++]=T+1,g[m++]=T+3,g[m++]=T+2}p.indexOffset+=i.indexCount,p.setDirty()}var Ya={},ja=function(){function t(t,e){this._texture=void 0,this._width=void 0,this._height=void 0,this._x=void 0,this._y=void 0,this._nexty=void 0,this._innerTextureInfos={},this._innerSpriteFrames=void 0,this._count=void 0;var i=new Ka;i.initWithSize(t,e),this._texture=i,this._width=t,this._height=e,this._x=2,this._y=2,this._nexty=2,this._innerTextureInfos={},this._innerSpriteFrames=[],this._count=0}var e=t.prototype;return e.insertSpriteFrame=function(t){var e=t.rect,i=t.texture,n=this._innerTextureInfos[i.getId()],r=e.x,s=e.y;if(n)r+=n.x,s+=n.y;else{var a=i.width,o=i.height;if(this._x+a+2>this._width&&(this._x=2,this._y=this._nexty),this._y+o+2>this._nexty&&(this._nexty=this._y+o+2),this._nexty>this._height)return null;We.internal.dynamicAtlasManager.textureBleeding&&((a<=8||o<=8)&&(this._texture.drawTextureAt(i.image,this._x-1,this._y-1),this._texture.drawTextureAt(i.image,this._x-1,this._y+1),this._texture.drawTextureAt(i.image,this._x+1,this._y-1),this._texture.drawTextureAt(i.image,this._x+1,this._y+1)),this._texture.drawTextureAt(i.image,this._x-1,this._y),this._texture.drawTextureAt(i.image,this._x+1,this._y),this._texture.drawTextureAt(i.image,this._x,this._y-1),this._texture.drawTextureAt(i.image,this._x,this._y+1)),this._texture.drawTextureAt(i.image,this._x,this._y),this._innerTextureInfos[i.getId()]={x:this._x,y:this._y,texture:i},this._count++,r+=this._x,s+=this._y,this._x+=a+2}var h={x:r,y:s,texture:this._texture};return this._innerSpriteFrames.push(t),h},e.deleteInnerTexture=function(t){t&&this._innerTextureInfos[t.getId()]&&(delete this._innerTextureInfos[t.getId()],this._count--)},e.isEmpty=function(){return this._count<=0},e.reset=function(){this._x=2,this._y=2,this._nexty=2;for(var t=this._innerSpriteFrames,e=0,i=t.length;e<i;e++){var n=t[e];n.isValid&&n._resetDynamicAtlasFrame()}this._innerSpriteFrames.length=0,this._innerTextureInfos={}},e.destroy=function(){this.reset(),this._texture.destroy()},t}(),Ka=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=ze.RGBA8888),this.reset({width:t,height:e,format:i})},i.drawTextureAt=function(t,e,i){var n=this.getGFXTexture();if(t&&n){var r=this._getGFXDevice();if(r){var s=new ht;s.texOffset.x=e,s.texOffset.y=i,s.texExtent.width=t.width,s.texExtent.height=t.height,r.copyTexImagesToTexture([t.data],n,[s])}else console.warn("Unable to get device")}},e}(Xe),qa=Object.freeze({__proto__:null,get CameraFOVAxis(){return Ye},get CameraProjection(){return je},get CameraAperture(){return Ke},get CameraISO(){return qe},get CameraShutter(){return Ze},get CameraType(){return Qe},get TrackingType(){return Je},get CameraUsage(){return $e},SKYBOX_FLAG:ti,Camera:ei,get ModelType(){return ii},Model:ni,SubModel:ri,Ambient:si,EnvironmentLightingType:ai,Skybox:oi,ShadowSize:hi,ShadowType:li,PCFType:ui,CSMLevel:ci,CSMOptimizationMode:di,Shadows:_i,FogType:fi,Fog:pi,Octree:gi,ColorTemperatureToRGB:mi,get LightType(){return vi},nt2lm:yi,Light:Ti,DirectionalLight:Si,SphereLight:Ei,SpotLight:Ai,get ProbeClearFlag(){return Ci},get ProbeType(){return Ri},ReflectionProbe:bi,LODData:xi,LODGroup:wi}),Za=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._atlases=[],e._atlasIndex=-1,e._maxAtlasCount=5,e._textureSize=2048,e._maxFrameSize=512,e._textureBleeding=!0,e._enabled=!1,e}He(e,t);var i=e.prototype;return i.newAtlas=function(){var t=this._atlases[++this._atlasIndex];return t||(t=new ja(this._textureSize,this._textureSize),this._atlases.push(t)),t},i.beforeSceneLoad=function(){this.reset()},i.init=function(){this.enabled=!Mi.CLEANUP_IMAGE_CACHE},i.insertSpriteFrame=function(t){if(!this._enabled||this._atlasIndex===this._maxAtlasCount||!t||t._original)return null;if(!t.packable)return null;var e=t.texture.getSamplerInfo();if(e.minFilter!==Ii.LINEAR||e.magFilter!==Ii.LINEAR||e.mipFilter!==Ii.NONE)return null;var i=this._atlases[this._atlasIndex];i||(i=this.newAtlas());var n=i.insertSpriteFrame(t);return n||this._atlasIndex===this._maxAtlasCount?n:(i=this.newAtlas()).insertSpriteFrame(t)},i.reset=function(){for(var t=0,e=this._atlases.length;t<e;t++)this._atlases[t].destroy();this._atlases.length=0,this._atlasIndex=-1},i.deleteAtlasSpriteFrame=function(t){if(t._original){for(var e,i=this._atlases.length-1;i>=0;i--)e=this._atlases[i],Bi(e._innerSpriteFrames,t);var n=t._original._texture;this.deleteAtlasTexture(n)}},i.deleteAtlasTexture=function(t){if(t)for(var e=this._atlases.length-1;e>=0;e--)this._atlases[e].deleteInnerTexture(t),this._atlases[e].isEmpty()&&(this._atlases[e].destroy(),this._atlases.splice(e,1),this._atlasIndex--)},i.packToDynamicAtlas=function(t,e){if(this._enabled&&e&&!e._original&&e.packable&&e.texture&&e.texture.width>0&&e.texture.height>0){var i=this.insertSpriteFrame(e);i&&e._setDynamicAtlasFrame(i)}},Pi(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(t?(this.reset(),We.director.on(We.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):(this.reset(),We.director.off(We.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)),this._enabled=t)}},{key:"maxAtlasCount",get:function(){return this._maxAtlasCount},set:function(t){this._maxAtlasCount=t}},{key:"atlasCount",get:function(){return this._atlases.length}},{key:"textureBleeding",get:function(){return this._textureBleeding},set:function(t){this._textureBleeding=t}},{key:"textureSize",get:function(){return this._textureSize},set:function(t){this._textureSize=t}},{key:"maxFrameSize",get:function(){return this._maxFrameSize},set:function(t){this._maxFrameSize=t}}]),e}(Oi);Za.instance=void 0;var Qa,Ja=t("dynamicAtlasManager",Za.instance=new Za);Di.registerSystem("dynamicAtlasManager",Ja,0),We.internal.dynamicAtlasManager=Ja,function(t){t[t.positions=ie.ATTR_POSITION]="positions",t[t.normals=ie.ATTR_NORMAL]="normals",t[t.uvs=ie.ATTR_TEX_COORD]="uvs",t[t.colors=ie.ATTR_COLOR]="colors"}(Qa||(Qa={}));var $a,to,eo,io,no,ro=function(){function t(){this._arrayBufferOrPaddings=[],this._length=0}var e=t.prototype;return e.setNextAlignment=function(t){if(0!==t){var e=this._length%t;if(0!==e){var i=t-e;this._arrayBufferOrPaddings.push(i),this._length+=i}}},e.addBuffer=function(t){var e=this._length;return this._arrayBufferOrPaddings.push(t),this._length+=t.byteLength,e},e.getLength=function(){return this._length},e.getCombined=function(){var t=new Uint8Array(this._length),e=0;return this._arrayBufferOrPaddings.forEach((function(i){"number"==typeof i?e+=i:(t.set(new Uint8Array(i),e),e+=i.byteLength)})),t.buffer},t}(),so=function(){function t(t,e){if(this._mesh=void 0,this._subMeshRenderings=[],this._mesh=t,this._mesh.struct.morph){var i=this._mesh.struct.primitives.length;this._subMeshRenderings=new Array(i).fill(null);for(var n=0;n<i;++n){var r=this._mesh.struct.morph.subMeshMorphs[n];r&&(r.targets.length>ki.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[n]=new oo(this._mesh,n,this._mesh.struct.morph,e):this._subMeshRenderings[n]=new ao(this._mesh,n,this._mesh.struct.morph,e))}}}return t.prototype.createInstance=function(){for(var t=this,e=this._mesh.struct.primitives.length,i=new Array(e),n=0;n<e;++n){var r,s;i[n]=null!==(r=null===(s=this._subMeshRenderings[n])||void 0===s?void 0:s.createInstance())&&void 0!==r?r:null}return{setWeights:function(t,e){var n;null===(n=i[t])||void 0===n||n.setWeights(e)},requiredPatches:function(e){zi(t._mesh.struct.morph);var n=t._mesh.struct.morph.subMeshMorphs[e],r=i[e];if(null===r)return null;var s=[{name:"CC_USE_MORPH",value:!0},{name:"CC_MORPH_TARGET_COUNT",value:n.targets.length}];return n.attributes.includes(ie.ATTR_POSITION)&&s.push({name:"CC_MORPH_TARGET_HAS_POSITION",value:!0}),n.attributes.includes(ie.ATTR_NORMAL)&&s.push({name:"CC_MORPH_TARGET_HAS_NORMAL",value:!0}),n.attributes.includes(ie.ATTR_TANGENT)&&s.push({name:"CC_MORPH_TARGET_HAS_TANGENT",value:!0}),s.push.apply(s,r.requiredPatches()),s},adaptPipelineState:function(t,e){var n;null===(n=i[t])||void 0===n||n.adaptPipelineState(e)},destroy:function(){for(var t,e=Fi(i);!(t=e()).done;){var n=t.value;null==n||n.destroy()}}}},t}(),ao=function(){function t(t,e,i,n){this._gfxDevice=void 0,this._subMeshMorph=void 0,this._textureInfo=void 0,this._attributes=void 0,this._verticesCount=void 0,this._gfxDevice=n;var r=i.subMeshMorphs[e];this._subMeshMorph=r,co(t,e,n);var s=t.struct.vertexBundles[t.struct.primitives[e].vertexBundelIndices[0]].view.count;this._verticesCount=s;var a=r.targets.length,o=uo(n,s*a);this._textureInfo={width:o.width,height:o.height},this._attributes=r.attributes.map((function(e,i){var n=o.create(),a=n.valueView;return r.targets.forEach((function(e,n){for(var r=e.displacements[i],o=new Float32Array(t.data.buffer,t.data.byteOffset+r.offset,r.count),h=s*n*4,l=0;l<s;++l)a[h+4*l+0]=o[3*l+0],a[h+4*l+1]=o[3*l+1],a[h+4*l+2]=o[3*l+2]})),n.updatePixels(),{name:e,morphTexture:n}}))}var e=t.prototype;return e.destroy=function(){for(var t,e=Fi(this._attributes);!(t=e()).done;)t.value.morphTexture.destroy()},e.createInstance=function(){var t=this,e=new lo(this._gfxDevice,this._subMeshMorph.targets.length);return e.setMorphTextureInfo(this._textureInfo.width,this._textureInfo.height),e.setVerticesCount(this._verticesCount),e.commit(),{setWeights:function(t){e.setWeights(t),e.commit()},requiredPatches:function(){return[{name:"CC_MORPH_TARGET_USE_TEXTURE",value:!0}]},adaptPipelineState:function(i){for(var n,r=Fi(t._attributes);!(n=r()).done;){var s=n.value,a=void 0;switch(s.name){case ie.ATTR_POSITION:a=Yi;break;case ie.ATTR_NORMAL:a=Wi;break;case ie.ATTR_TANGENT:a=Xi;break;default:Gi("Unexpected attribute!")}void 0!==a&&(i.bindSampler(a,s.morphTexture.sampler),i.bindTexture(a,s.morphTexture.texture))}i.bindBuffer(ki.BINDING,e.buffer),i.update()},destroy:function(){}}},t}(),oo=function(){function t(t,e,i,n){this._gfxDevice=void 0,this._attributes=[],this._gfxDevice=n;var r=i.subMeshMorphs[e];co(t,e,n),this._attributes=r.attributes.map((function(e,i){return{name:e,targets:r.targets.map((function(e){return{displacements:new Float32Array(t.data.buffer,t.data.byteOffset+e.displacements[i].offset,e.displacements[i].count)}}))}}))}return t.prototype.createInstance=function(){return new ho(this,this._attributes[0].targets[0].displacements.length/3,this._gfxDevice)},Pi(t,[{key:"data",get:function(){return this._attributes}}]),t}(),ho=function(){function t(t,e,i){this._attributes=void 0,this._owner=void 0,this._morphUniforms=void 0,this._owner=t,this._morphUniforms=new lo(i,0);var n=uo(i,e);this._morphUniforms.setMorphTextureInfo(n.width,n.height),this._morphUniforms.commit(),this._attributes=this._owner.data.map((function(t){var e=n.create();return{attributeName:t.name,morphTexture:e}}))}var e=t.prototype;return e.setWeights=function(t){for(var e=0;e<this._attributes.length;++e){var i=this._attributes[e],n=i.morphTexture.valueView,r=this._owner.data[e];Ni(t.length===r.targets.length);for(var s=0;s<r.targets.length;++s){var a=r.targets[s].displacements,o=t[s],h=a.length/3;if(0===s)for(var l=0;l<h;++l)n[4*l+0]=a[3*l+0]*o,n[4*l+1]=a[3*l+1]*o,n[4*l+2]=a[3*l+2]*o;else if(0!==o)for(var u=0;u<h;++u)n[4*u+0]+=a[3*u+0]*o,n[4*u+1]+=a[3*u+1]*o,n[4*u+2]+=a[3*u+2]*o}i.morphTexture.updatePixels()}},e.requiredPatches=function(){return[{name:"CC_MORPH_TARGET_USE_TEXTURE",value:!0},{name:"CC_MORPH_PRECOMPUTED",value:!0}]},e.adaptPipelineState=function(t){for(var e,i=Fi(this._attributes);!(e=i()).done;){var n=e.value,r=void 0;switch(n.attributeName){case ie.ATTR_POSITION:r=Yi;break;case ie.ATTR_NORMAL:r=Wi;break;case ie.ATTR_TANGENT:r=Xi;break;default:Gi("Unexpected attribute!")}void 0!==r&&(t.bindSampler(r,n.morphTexture.sampler),t.bindTexture(r,n.morphTexture.texture))}t.bindBuffer(ki.BINDING,this._morphUniforms.buffer),t.update()},e.destroy=function(){this._morphUniforms.destroy();for(var t=0;t<this._attributes.length;++t)this._attributes[t].morphTexture.destroy()},t}(),lo=function(){function t(t,e){this._targetCount=void 0,this._localBuffer=void 0,this._remoteBuffer=void 0,this._targetCount=e,this._localBuffer=new DataView(new ArrayBuffer(ki.SIZE)),this._remoteBuffer=t.createBuffer(new ft(g.UNIFORM|g.TRANSFER_DST,y.HOST|y.DEVICE,ki.SIZE,ki.SIZE))}var e=t.prototype;return e.destroy=function(){this._remoteBuffer.destroy()},e.setWeights=function(t){Ni(t.length===this._targetCount);for(var e=0;e<t.length;++e)this._localBuffer.setFloat32(ki.OFFSET_OF_WEIGHTS+4*e,t[e],We.sys.isLittleEndian)},e.setMorphTextureInfo=function(t,e){this._localBuffer.setFloat32(ki.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH,t,We.sys.isLittleEndian),this._localBuffer.setFloat32(ki.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT,e,We.sys.isLittleEndian)},e.setVerticesCount=function(t){this._localBuffer.setFloat32(ki.OFFSET_OF_VERTICES_COUNT,t,We.sys.isLittleEndian)},e.commit=function(){this._remoteBuffer.update(this._localBuffer.buffer)},Pi(t,[{key:"buffer",get:function(){return this._remoteBuffer}}]),t}();function uo(t,e){var i,n,r,s;t.getFormatFeatures(_.RGBA32F)&A.SAMPLED_TEXTURE?(i=e,r=16,n=Xe.PixelFormat.RGBA32F,s=Float32Array):(i=4*e,r=4,n=Xe.PixelFormat.RGBA8888,s=Uint8Array);var a=function(t){t<5&&(t=5);var e=Vi(t),i=Hi(e),n=i>>1;return{width:1<<(1&i?n+1:n),height:1<<n}}(i),o=a.width,h=a.height;return{width:o,height:h,create:function(){var e=new ArrayBuffer(o*h*r),i=new Float32Array(e),a=s===Float32Array?i:new s(e),l=new Ui({width:o,height:h,_data:a,_compressed:!1,format:n}),u=new Xe;u.setFilters(Xe.Filter.NEAREST,Xe.Filter.NEAREST),u.setMipFilter(Xe.Filter.NONE),u.setWrapMode(Xe.WrapMode.CLAMP_TO_EDGE,Xe.WrapMode.CLAMP_TO_EDGE,Xe.WrapMode.CLAMP_TO_EDGE),u.image=l,u.getGFXTexture()||Gi("Unexpected: failed to create morph texture?");var c=t.getSampler(u.getSamplerInfo());return{get texture(){return u.getGFXTexture()},get sampler(){return c},get valueView(){return i},destroy:function(){u.destroy()},updatePixels:function(){u.uploadData(a)}}}}}function co(t,e,i){t.renderingSubMeshes[e].enableVertexIdChannel(i)}function _o(t){switch(t){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array;default:return Uint8Array}}var fo=new ji,po=new ji,go=new Uint8Array,mo=t("Mesh",Ki("cc.Mesh")((to=function(t){function e(){var e;return(e=t.call(this)||this).morphRendering=null,e._struct=eo&&eo(),e._hash=io&&io(),e._data=go,e._initialized=!1,e._allowDataAccess=no&&no(),e._isMeshDataUploaded=!1,e._renderingSubMeshes=null,e._boneSpaceBounds=new Map,e._jointBufferIndices=null,e}He(e,t);var i=e.prototype;return i.onLoaded=function(){this.initialize()},i.initialize=function(){var t=this;if(!this._initialized)if(this._initialized=!0,this._struct.dynamic){for(var e=ke.gfxDevice,i=[],n=[],r=0;r<this._struct.vertexBundles.length;r++){var s=this._struct.vertexBundles[r],a=e.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.DEVICE,s.view.length,s.view.stride));i.push(a)}for(var o=0;o<this._struct.primitives.length;o++){var h=this._struct.primitives[o],l=h.indexView,u=null;l&&(u=e.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.DEVICE,l.length,l.stride)));for(var c=[],_=0;_<h.vertexBundelIndices.length;_++){var f=h.vertexBundelIndices[_];c.push(i[f])}for(var p=[],m=0;m<h.vertexBundelIndices.length;m++)for(var v,T=h.vertexBundelIndices[m],S=this._struct.vertexBundles[T],E=Fi(S.attributes);!(v=E()).done;){var A=v.value,C=new Bt;C.copy(A),p.push(C)}var R=new qi(c,p,h.primitiveMode,u);R.drawInfo=new gt,R.mesh=this,R.subMeshIdx=o,n.push(R)}this._renderingSubMeshes=n}else!function(){for(var e=t._data.buffer,i=ke.gfxDevice,n=t._createVertexBuffers(i,e),r=[],s=0;s<t._struct.primitives.length;s++){var a=t._struct.primitives[s];if(0!==a.vertexBundelIndices.length){var o=null,h=null;if(a.indexView){var l=a.indexView,u=l.stride,c=l.length;if(4===u&&!i.hasFeature(d.ELEMENT_INDEX_UINT)){var _=t._struct.vertexBundles[a.vertexBundelIndices[0]].view.count;if(_>=65536){Zi(10001,_,65536);continue}u>>=1,c>>=1}o=i.createBuffer(new ft(g.INDEX,y.DEVICE,c,u)),h=new(_o(l.stride))(e,l.offset,l.count),l.stride!==u&&(h=_o(u).from(h)),o.update(h)}var f=a.vertexBundelIndices.map((function(t){return n[t]})),p=[];if(a.vertexBundelIndices.length>0)for(var m=a.vertexBundelIndices[0],v=t._struct.vertexBundles[m].attributes,T=0;T<v.length;++T){var S=v[T];p[T]=new Bt(S.name,S.format,S.isNormalized,S.stream,S.isInstanced,S.location)}var E=new qi(f,p,a.primitiveMode,o);E.mesh=t,E.subMeshIdx=s,r.push(E)}}t._renderingSubMeshes=r,t._struct.morph&&(t.morphRendering=function(t,e){return new so(t,e)}(t,i)),t._isMeshDataUploaded=!0,t._allowDataAccess||t.releaseData()}()},i.updateSubMesh=function(t,e){if(this._struct.dynamic)if(t>=this._struct.primitives.length)Zi(14201);else{var i=[];if(e.positions.length>0&&i.push(e.positions),e.normals&&e.normals.length>0&&i.push(e.normals),e.uvs&&e.uvs.length>0&&i.push(e.uvs),e.tangents&&e.tangents.length>0&&i.push(e.tangents),e.colors&&e.colors.length>0&&i.push(e.colors),e.customAttributes)for(var n=0;n<e.customAttributes.length;n++)i.push(e.customAttributes[n].values);for(var r=this._struct.dynamic,s=r.info,a=this._struct.primitives[t],o=this._renderingSubMeshes[t],h=o.drawInfo,l=0;l<i.length;l++){var u=i[l],c=this._struct.vertexBundles[a.vertexBundelIndices[l]],d=c.view.stride,_=u.byteLength/d,f=u.byteLength,p=new Uint8Array(this._data.buffer,c.view.offset,f),g=new Uint8Array(u.buffer,u.byteOffset,f),m=o.vertexBuffers[l];Ni(_<=s.maxSubMeshVertices),f>0&&(p.set(g),m.update(g,f)),c.view.count=_,h.vertexCount=_}if(a.indexView){var v=a.indexView,y=v.stride,T=2===y?e.indices16.length:e.indices32.length,S=T*y,E=new Uint8Array(this._data.buffer,v.offset,S),A=2===y?new Uint8Array(e.indices16.buffer,e.indices16.byteOffset,S):new Uint8Array(e.indices32.buffer,e.indices32.byteOffset,S),C=o.indexBuffer;Ni(T<=s.maxSubMeshIndices),S>0&&(E.set(A),C.update(A,S)),v.count=T,h.indexCount=T}if(e.minPos&&e.maxPos){var R=new ji(e.minPos.x,e.minPos.y,e.minPos.z),b=new ji(e.maxPos.x,e.maxPos.y,e.maxPos.z);r.bounds[t]||(r.bounds[t]=new Qi),Qi.fromPoints(r.bounds[t],R,b);for(var x,w=new ji,M=new ji,I=Fi(r.bounds);!(x=I()).done;){var B=x.value;B&&(B.getBoundary(w,M),ji.min(R,w,R),ji.max(b,M,b))}this._struct.minPosition=new ji(R.x,R.y,R.z),this._struct.maxPosition=new ji(b.x,b.y,b.z)}o.invalidateGeometricInfo()}else Zi(14200)},i.destroy=function(){return this.destroyRenderingMesh(),t.prototype.destroy.call(this)},i.destroyRenderingMesh=function(){if(this._renderingSubMeshes){for(var t=0;t<this._renderingSubMeshes.length;t++)this._renderingSubMeshes[t].destroy();this._renderingSubMeshes=null,this._initialized=!1,this._isMeshDataUploaded=!1}},i.assign=function(t,e){this.reset({struct:t,data:e})},i.reset=function(t){this.destroyRenderingMesh(),this._struct=t.struct,this._data=t.data,this._hash=0},i.getBoneSpaceBounds=function(t){if(this._boneSpaceBounds.has(t.hash))return this._boneSpaceBounds.get(t.hash);var e=[];this._boneSpaceBounds.set(t.hash,e);for(var i=[],n=t.bindposes,r=0;r<n.length;r++)e.push(new Qi(1/0,1/0,1/0,-1/0,-1/0,-1/0)),i.push(!1);for(var s=this._struct.primitives,a=0;a<s.length;a++){var o=this.readAttribute(a,ie.ATTR_JOINTS),h=this.readAttribute(a,ie.ATTR_WEIGHTS),l=this.readAttribute(a,ie.ATTR_POSITION);if(o&&h&&l)for(var u=Math.min(o.length/4,h.length/4,l.length/3),c=0;c<u;c++){ji.set(fo,l[3*c+0],l[3*c+1],l[3*c+2]);for(var d=0;d<4;++d){var _=4*c+d,f=o[_];if(!(0===h[_]||f>=n.length)){ji.transformMat4(po,fo,n[f]),i[f]=!0;var p=e[f];ji.min(p.center,p.center,po),ji.max(p.halfExtents,p.halfExtents,po)}}}}for(var g=0;g<n.length;g++){var m=e[g];i[g]?Qi.fromPoints(m,m.center,m.halfExtents):e[g]=null}return e},i.merge=function(t,e,i){if(i&&!this.validateMergingMesh(t))return!1;var n=new ji,r=e&&new Ji,s=e&&new Qi;if(r&&e.getRotation(r),!this._initialized){var a=JSON.parse(JSON.stringify(t._struct)),o=t._data.slice();if(e){a.maxPosition&&a.minPosition&&(ji.add(s.center,a.maxPosition,a.minPosition),ji.multiplyScalar(s.center,s.center,.5),ji.subtract(s.halfExtents,a.maxPosition,a.minPosition),ji.multiplyScalar(s.halfExtents,s.halfExtents,.5),Qi.transform(s,s,e),ji.add(a.maxPosition,s.center,s.halfExtents),ji.subtract(a.minPosition,s.center,s.halfExtents));for(var h=0;h<a.vertexBundles.length;h++)for(var l=a.vertexBundles[h],u=0;u<l.attributes.length;u++)if(l.attributes[u].name===ie.ATTR_POSITION||l.attributes[u].name===ie.ATTR_NORMAL){var c=l.attributes[u].format,d=new DataView(o.buffer,l.view.offset+vo(l.attributes,u)),_=So(d,c),f=Eo(d,c);if(!_||!f)continue;for(var p=l.view.count,g=l.view.stride,m=To(c),v=0;v<p;v++){var y=v*g,T=y+m,S=T+m;switch(n.set(_(y),_(T),_(S)),l.attributes[u].name){case ie.ATTR_POSITION:n.transformMat4(e);break;case ie.ATTR_NORMAL:ji.transformQuat(n,n,r)}f(y,n.x),f(T,n.y),f(S,n.z)}}}return this.reset({struct:a,data:o}),this.initialize(),!0}for(var E,A,C,R,b,x=new ro,w=0,M=0,I=0,B=0,P=0,D=0,O=0,F=0,L=!1,N=new Array(this._struct.vertexBundles.length),k=0;k<this._struct.vertexBundles.length;++k){var U=this._struct.vertexBundles[k],G=t._struct.vertexBundles[k];I=U.view.offset,B=G.view.offset,M=U.view.stride,w=U.view.count+G.view.count,E=new ArrayBuffer(w*M),A=new Uint8Array(E),I+=(C=this._data.subarray(I,I+U.view.length)).length,B+=(R=t._data.subarray(B,B+G.view.length)).length,A.set(C),P=0;for(var V,H=Fi(U.attributes);!(V=H()).done;){var z=V.value;O=0,L=!1;for(var X,W=Fi(G.attributes);!(X=W()).done;){var Y=X.value;if(z.name===Y.name&&z.format===Y.format){L=!0;break}O+=ne[Y.format].size}if(L){F=ne[z.format].size,D=U.view.length+P;for(var j=0;j<G.view.count;++j){if(b=R.subarray(O,O+F),A.set(b,D),(z.name===ie.ATTR_POSITION||z.name===ie.ATTR_NORMAL)&&e){var K=new Float32Array(A.buffer,D,3);switch(n.set(K[0],K[1],K[2]),z.name){case ie.ATTR_POSITION:n.transformMat4(e);break;case ie.ATTR_NORMAL:ji.transformQuat(n,n,r)}K[0]=n.x,K[1]=n.y,K[2]=n.z}D+=U.view.stride,O+=G.view.stride}}P+=ne[z.format].size}N[k]={attributes:U.attributes,view:{offset:x.getLength(),length:E.byteLength,count:w,stride:M}},x.addBuffer(E)}for(var q,Z,Q,J=0,$=2,tt=new Array(this._struct.primitives.length),et=0;et<this._struct.primitives.length;++et){var it=this._struct.primitives[et],nt=t._struct.primitives[et];tt[et]={primitiveMode:it.primitiveMode,vertexBundelIndices:it.vertexBundelIndices};for(var rt,st=0,at=Fi(it.vertexBundelIndices);!(rt=at()).done;){var ot=rt.value;st=Math.max(st,this._struct.vertexBundles[ot].view.count)}if(it.indexView&&nt.indexView){J=it.indexView.count,J+=nt.indexView.count,I=it.indexView.offset,B=nt.indexView.offset,$=J<256?1:J<65536?2:4;var ht=new ArrayBuffer(J*$);if(q=2===$?new Uint16Array(ht):1===$?new Uint8Array(ht):new Uint32Array(ht),Z=2===it.indexView.stride?new Uint16Array(this._data.buffer,I,it.indexView.count):1===it.indexView.stride?new Uint8Array(this._data.buffer,I,it.indexView.count):new Uint32Array(this._data.buffer,I,it.indexView.count),$===it.indexView.stride)q.set(Z);else for(var lt=0;lt<it.indexView.count;++lt)q[lt]=Z[lt];I+=it.indexView.length,Q=2===nt.indexView.stride?new Uint16Array(t._data.buffer,B,nt.indexView.count):1===nt.indexView.stride?new Uint8Array(t._data.buffer,B,nt.indexView.count):new Uint32Array(t._data.buffer,B,nt.indexView.count);for(var ut=0;ut<nt.indexView.count;++ut)q[it.indexView.count+ut]=st+Q[ut];B+=nt.indexView.length,tt[et].indexView={offset:x.getLength(),length:ht.byteLength,count:J,stride:$},x.setNextAlignment($),x.addBuffer(ht)}}var ct={vertexBundles:N,primitives:tt,minPosition:this._struct.minPosition,maxPosition:this._struct.maxPosition};return ct.minPosition&&t._struct.minPosition&&ct.maxPosition&&t._struct.maxPosition&&(e?(ji.add(s.center,t._struct.maxPosition,t._struct.minPosition),ji.multiplyScalar(s.center,s.center,.5),ji.subtract(s.halfExtents,t._struct.maxPosition,t._struct.minPosition),ji.multiplyScalar(s.halfExtents,s.halfExtents,.5),Qi.transform(s,s,e),ji.add(n,s.center,s.halfExtents),ji.max(ct.maxPosition,ct.maxPosition,n),ji.subtract(n,s.center,s.halfExtents),ji.min(ct.minPosition,ct.minPosition,n)):(ji.min(ct.minPosition,ct.minPosition,t._struct.minPosition),ji.max(ct.maxPosition,ct.maxPosition,t._struct.maxPosition))),this.reset({struct:ct,data:new Uint8Array(x.getCombined())}),this.initialize(),!0},i.validateMergingMesh=function(t){if(this._struct.dynamic||t._struct.dynamic)return!1;if(this._struct.vertexBundles.length!==t._struct.vertexBundles.length)return!1;for(var e=0;e<this._struct.vertexBundles.length;++e){var i=this._struct.vertexBundles[e],n=t._struct.vertexBundles[e];if(i.attributes.length!==n.attributes.length)return!1;for(var r=0;r<i.attributes.length;++r)if(i.attributes[r].format!==n.attributes[r].format)return!1}if(this._struct.primitives.length!==t._struct.primitives.length)return!1;for(var s=0;s<this._struct.primitives.length;++s){var a=this._struct.primitives[s],o=t._struct.primitives[s];if(a.vertexBundelIndices.length!==o.vertexBundelIndices.length)return!1;for(var h=0;h<a.vertexBundelIndices.length;++h)if(a.vertexBundelIndices[h]!==o.vertexBundelIndices[h])return!1;if(a.primitiveMode!==o.primitiveMode)return!1;if(a.indexView){if(void 0===o.indexView)return!1}else if(o.indexView)return!1}return!0},i.readAttribute=function(t,e){var i=this,n=null;return this._accessAttribute(t,e,(function(t,e){var r=t.view.count,s=t.attributes[e].format,a=de(ne[s]);if(0!==r){var o=new DataView(i._data.buffer,t.view.offset+vo(t.attributes,e)),h=ne[s],l=So(o,s);if(a&&l){for(var u=h.count,c=new a(r*u),d=t.view.stride,_=0;_<r;++_)for(var f=0;f<u;++f)c[u*_+f]=l(d*_+c.BYTES_PER_ELEMENT*f);n=c}}})),n},i.copyAttribute=function(t,e,i,n,r){var s=this,a=!1;return this._accessAttribute(t,e,(function(t,e){var o=t.view.count;if(0!==o){var h=t.attributes[e].format,l=new DataView(s._data.buffer,t.view.offset+vo(t.attributes,e)),u=new DataView(i,r),c=ne[h],d=So(l,h),_=Eo(u,h);if(d&&_){for(var f=c.count,p=t.view.stride,g=To(h),m=n,v=g,y=0;y<o;++y)for(var T=0;T<f;++T)_(m*y+v*T,d(p*y+g*T));a=!0}}else a=!0})),a},i.readIndices=function(t){if(t>=this._struct.primitives.length)return null;var e=this._struct.primitives[t];if(!e.indexView)return null;var i=e.indexView.stride;return new(1===i?Uint8Array:2===i?Uint16Array:Uint32Array)(this._data.buffer,e.indexView.offset,e.indexView.count)},i.copyIndices=function(t,e){if(t>=this._struct.primitives.length)return!1;var i=this._struct.primitives[t];if(!i.indexView)return!1;for(var n=i.indexView.count,r=1===i.indexView.stride?_.R8UI:2===i.indexView.stride?_.R16UI:_.R32UI,s=So(new DataView(this._data.buffer),r),a=0;a<n;++a)e[a]=s(i.indexView.offset+ne[r].size*a);return!0},i.readAttributeFormat=function(t,e){var i=null;return this._accessAttribute(t,e,(function(t,e){var n=t.attributes[e].format;i=ne[n]})),i},i._accessAttribute=function(t,e,i){if(!(t>=this._struct.primitives.length))for(var n,r=this._struct.primitives[t],s=Fi(r.vertexBundelIndices);!(n=s()).done;){var a=n.value,o=this._struct.vertexBundles[a],h=o.attributes.findIndex((function(t){return t.name===e}));if(!(h<0)){i(o,h);break}}},i._createVertexBuffers=function(t,e){return this._struct.vertexBundles.map((function(i){var n=t.createBuffer(new ft(g.VERTEX,y.DEVICE,i.view.length,i.view.stride)),r=new Uint8Array(e,i.view.offset,i.view.length);return n.update(r),n}))},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.reset({struct:{vertexBundles:[],primitives:[]},data:go})},i.releaseData=function(){this._data=go},Pi(e,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(t){this._data=new Uint8Array(t)}},{key:"subMeshCount",get:function(){var t=this.renderingSubMeshes;return t?t.length:0}},{key:"minPosition",get:function(){return this.struct.minPosition}},{key:"maxPosition",get:function(){return this.struct.maxPosition}},{key:"struct",get:function(){return this._struct}},{key:"data",get:function(){return this._data}},{key:"hash",get:function(){return this._hash||(this._hash=nn(this._data,666)),this._hash}},{key:"jointBufferIndices",get:function(){return this._jointBufferIndices?this._jointBufferIndices:this._jointBufferIndices=this._struct.primitives.map((function(t){return t.jointMapIndex||0}))}},{key:"renderingSubMeshes",get:function(){return this.initialize(),this._renderingSubMeshes}},{key:"allowDataAccess",get:function(){return this._allowDataAccess},set:function(t){this._allowDataAccess=t,this._isMeshDataUploaded&&!this._allowDataAccess&&this.releaseData()}}]),e}($i),eo=tn(to.prototype,"_struct",[en],(function(){return{vertexBundles:[],primitives:[]}})),io=tn(to.prototype,"_hash",[en],(function(){return 0})),no=tn(to.prototype,"_allowDataAccess",[en],(function(){return!0})),$a=to))||$a);function vo(t,e){for(var i=0,n=0;n<e;++n){var r=t[n];i+=ne[r.format].size}return i}We.Mesh=mo;var yo=rn.isLittleEndian;function To(t){var e=ne[t];return e.size/e.count}function So(t,e){var i=ne[e],n=i.size/i.count;switch(i.type){case f.UNORM:switch(n){case 1:return function(e){return t.getUint8(e)};case 2:return function(e){return t.getUint16(e,yo)};case 4:return function(e){return t.getUint32(e,yo)}}break;case f.SNORM:case f.INT:switch(n){case 1:return function(e){return t.getInt8(e)};case 2:return function(e){return t.getInt16(e,yo)};case 4:return function(e){return t.getInt32(e,yo)}}break;case f.UINT:switch(n){case 1:return function(e){return t.getUint8(e)};case 2:return function(e){return t.getUint16(e,yo)};case 4:return function(e){return t.getUint32(e,yo)}}break;case f.FLOAT:return function(e){return t.getFloat32(e,yo)}}return null}function Eo(t,e){var i=ne[e],n=i.size/i.count;switch(i.type){case f.UNORM:switch(n){case 1:return function(e,i){return t.setUint8(e,i)};case 2:return function(e,i){return t.setUint16(e,i,yo)};case 4:return function(e,i){return t.setUint32(e,i,yo)}}break;case f.SNORM:case f.INT:switch(n){case 1:return function(e,i){return t.setInt8(e,i)};case 2:return function(e,i){return t.setInt16(e,i,yo)};case 4:return function(e,i){return t.setInt32(e,i,yo)}}break;case f.UINT:switch(n){case 1:return function(e,i){return t.setUint8(e,i)};case 2:return function(e,i){return t.setUint16(e,i,yo)};case 4:return function(e,i){return t.setUint32(e,i,yo)}}break;case f.FLOAT:return function(e,i){return t.setFloat32(e,i,yo)}}return null}var Ao=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_NORMAL,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RG32F),new Bt(ie.ATTR_TANGENT,_.RGBA32F),new Bt(ie.ATTR_COLOR,_.RGBA32F)],Co=new ji;function Ro(t,e,i){i=i||{};var n,r=[],s=0,a=[],o=0,h=t.positions.slice();if(h.length>0){if(n=null,t.attributes)for(var l,u=Fi(t.attributes);!(l=u()).done;){var c=l.value;if(c.name===ie.ATTR_POSITION){n=c;break}}n||(n=Ao[0]),r.push(n);var d=ne[n.format];o=Math.max(o,Math.floor(h.length/d.count)),a.push({offset:s,data:h,attribute:n}),s+=d.size}if(t.normals&&t.normals.length>0){if(n=null,t.attributes)for(var f,p=Fi(t.attributes);!(f=p()).done;){var g=f.value;if(g.name===ie.ATTR_NORMAL){n=g;break}}n||(n=Ao[1]);var m=ne[n.format];r.push(n),o=Math.max(o,Math.floor(t.normals.length/m.count)),a.push({offset:s,data:t.normals,attribute:n}),s+=m.size}if(t.uvs&&t.uvs.length>0){if(n=null,t.attributes)for(var v,y=Fi(t.attributes);!(v=y()).done;){var T=v.value;if(T.name===ie.ATTR_TEX_COORD){n=T;break}}n||(n=Ao[2]);var S=ne[n.format];r.push(n),o=Math.max(o,Math.floor(t.uvs.length/S.count)),a.push({offset:s,data:t.uvs,attribute:n}),s+=S.size}if(t.tangents&&t.tangents.length>0){if(n=null,t.attributes)for(var E,A=Fi(t.attributes);!(E=A()).done;){var C=E.value;if(C.name===ie.ATTR_TANGENT){n=C;break}}n||(n=Ao[3]);var R=ne[n.format];r.push(n),o=Math.max(o,Math.floor(t.tangents.length/R.count)),a.push({offset:s,data:t.tangents,attribute:n}),s+=R.size}if(t.colors&&t.colors.length>0){if(n=null,t.attributes)for(var b,x=Fi(t.attributes);!(b=x()).done;){var w=b.value;if(w.name===ie.ATTR_COLOR){n=w;break}}n||(n=Ao[4]);var M=ne[n.format];r.push(n),o=Math.max(o,Math.floor(t.colors.length/M.count)),a.push({offset:s,data:t.colors,attribute:n}),s+=M.size}if(t.customAttributes)for(var I=0;I<t.customAttributes.length;I++){var B=t.customAttributes[I],P=ne[B.attr.format];r.push(B.attr),o=Math.max(o,Math.floor(B.values.length/P.count)),a.push({offset:s,data:B.values,attribute:B.attr}),s+=P.size}for(var D=new ro,O=new ArrayBuffer(o*s),F=new DataView(O),L=0,N=a;L<N.length;L++){var k=N[L];sn(F,k.data,k.attribute.format,k.offset,s)}D.setNextAlignment(0);var G={attributes:r,view:{offset:D.getLength(),length:O.byteLength,count:o,stride:s}};D.addBuffer(O);var V=null,H=0;if(t.indices){var z=t.indices;H=z.length,V=new ArrayBuffer(2*H);var X=new DataView(V);sn(X,z,_.R16UI)}var W={primitiveMode:t.primitiveMode||U.TRIANGLE_LIST,vertexBundelIndices:[0]};V&&(D.setNextAlignment(2),W.indexView={offset:D.getLength(),length:V.byteLength,count:H,stride:2},D.addBuffer(V));var Y=t.minPos;if(!Y&&i.calculateBounds){Y=ji.set(new ji,1/0,1/0,1/0);for(var j=0;j<o;++j)ji.set(Co,h[3*j+0],h[3*j+1],h[3*j+2]),ji.min(Y,Y,Co)}var K=t.maxPos;if(!K&&i.calculateBounds){K=ji.set(new ji,-1/0,-1/0,-1/0);for(var q=0;q<o;++q)ji.set(Co,h[3*q+0],h[3*q+1],h[3*q+2]),ji.max(K,K,Co)}var Z={vertexBundles:[G],primitives:[W]};return Y&&(Z.minPosition=new ji(Y.x,Y.y,Y.z)),K&&(Z.maxPosition=new ji(K.x,K.y,K.z)),e||(e=new mo),e.reset({struct:Z,data:new Uint8Array(D.getCombined())}),e}function bo(t,e){if(e>0){var i=t%e;if(0!==i)return e-i}return 0}var xo,wo,Mo,Io=function(){function t(){}return t.createMesh=function(t,e,i){return Ro(t,e,i)},t.createDynamicMesh=function(t,e,i,n){return function(t,e,i,n){n=n||{maxSubMeshes:1,maxSubMeshVertices:1024,maxSubMeshIndices:1024};var r=[],s=0;if(e.positions.length>0&&r.push(new Bt(ie.ATTR_POSITION,_.RGB32F,!1,s++,!1,0)),e.normals&&e.normals.length>0&&r.push(new Bt(ie.ATTR_NORMAL,_.RGB32F,!1,s++,!1,0)),e.uvs&&e.uvs.length>0&&r.push(new Bt(ie.ATTR_TEX_COORD,_.RG32F,!1,s++,!1,0)),e.tangents&&e.tangents.length>0&&r.push(new Bt(ie.ATTR_TANGENT,_.RGBA32F,!1,s++,!1,0)),e.colors&&e.colors.length>0&&r.push(new Bt(ie.ATTR_COLOR,_.RGBA32F,!1,s++,!1,0)),e.customAttributes)for(var a=0;a<e.customAttributes.length;a++){var o=e.customAttributes[a],h=new Bt;h.copy(o.attr),h.stream=s++,r.push(h)}for(var l=[],u=[],c=0,d=0;d<n.maxSubMeshes;d++){for(var f,p={vertexBundelIndices:[],primitiveMode:e.primitiveMode||U.TRIANGLE_LIST},g=Fi(r);!(f=g()).done;){var m=f.value,v=ne[m.format],y=n.maxSubMeshVertices*v.size,T={view:{offset:c,length:y,count:0,stride:v.size},attributes:[m]},S=l.length;p.vertexBundelIndices.push(S),l.push(T),c+=y}var E=0;if(e.indices16&&e.indices16.length>0?E=2:e.indices32&&e.indices32.length>0&&(E=4),E>0){c+=bo(c,E);var A=n.maxSubMeshIndices*E,C={offset:c,length:A,count:0,stride:E};p.indexView=C,c+=A}u.push(p)}var R={info:{maxSubMeshes:n.maxSubMeshes,maxSubMeshVertices:n.maxSubMeshVertices,maxSubMeshIndices:n.maxSubMeshIndices},bounds:[]};R.bounds.length=n.maxSubMeshes;var b={struct:{vertexBundles:l,primitives:u,dynamic:R},data:new Uint8Array(c)};return i||(i=new mo),i.reset(b),i.initialize(),i.updateSubMesh(t,e),i}(t,e,i,n)},t}(),Bo=Object.freeze({__proto__:null,find:an,toPPM:function(t,e,i){return"P3 "+e+" "+i+" 255\n"+t.filter((function(t,e){return e%4<3})).toString()+"\n"},readMesh:function(t,e){void 0===e&&(e=0);for(var i,n={positions:[]},r=new DataView(t.data.buffer,t.data.byteOffset,t.data.byteLength),s=t.struct,a=s.primitives[e],o=Fi(a.vertexBundelIndices);!(i=o()).done;)for(var h,l=i.value,u=s.vertexBundles[l],c=u.view.offset,d=u.view,f=d.length,p=d.stride,g=Fi(u.attributes);!(h=g()).done;){var m=h.value,v=Qa[m.name];v&&(n[v]=(n[v]||[]).concat(Li(r,m.format,c,f,p))),c+=ne[m.format].size}var y=a.indexView;return n.indices=Li(r,_["R"+8*y.stride+"UI"],y.offset,y.length),n},createMesh:Ro,MeshUtils:Io,readBuffer:Li,writeBuffer:sn,mapBuffer:on});t("utils",Bo);var Po,Do=new ji,Oo=new Ue;!function(t){t[t.RECT=0]="RECT",t[t.POLYGON=1]="POLYGON"}(Po||(Po={}));var Fo,Lo,No,ko=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],Uo=t("SpriteFrame",Ki("cc.SpriteFrame")((Mo=wo=function(t){function e(){var e;return(e=t.call(this)||this).vertices=null,e.uv=[],e.unbiasUV=[],e.uvSliced=[],e._rect=new un,e._trimmedBorder=new _n,e._offset=new cn,e._originalSize=new dn,e._rotated=!1,e._capInsets=[0,0,0,0],e._atlasUuid="",e._texture=void 0,e._isFlipUVY=!1,e._isFlipUVX=!1,e._original=null,e._packable=!0,e._pixelsToUnit=100,e._pivot=new cn(.5,.5),e._meshType=Po.RECT,e._extrude=0,e._customOutLine=[],e._minPos=new ji,e._maxPos=new ji,e}He(e,t),e.createWithImage=function(t){var i=t instanceof Ui?t:new Ui(t),n=new Xe;n.image=i;var r=new e;return r.texture=n,r};var i=e.prototype;return i.textureLoaded=function(){return!!this.texture},i.isRotated=function(){return this._rotated},i.setRotated=function(t){this.rotated=t},i.getRect=function(t){return t?(t.set(this._rect),t):this._rect.clone()},i.setRect=function(t){this.rect=t},i.getOriginalSize=function(t){return t?(t.set(this._originalSize),t):this._originalSize.clone()},i.setOriginalSize=function(t){this.originalSize=t},i.getOffset=function(t){return t?(t.set(this._offset),t):this._offset.clone()},i.setOffset=function(t){this.offset=t},i.getGFXTexture=function(){return this._texture.getGFXTexture()},i.getGFXSampler=function(){return this._texture.getGFXSampler()},i.getHash=function(){return this._texture.getHash()},i.getSamplerInfo=function(){return this._texture.getSamplerInfo()},i.reset=function(t,e){void 0===e&&(e=!1);var i=!1;e&&(this._originalSize.set(0,0),this._rect.set(0,0,0,0),this._offset.set(0,0),this._capInsets=[0,0,0,0],this._rotated=!1,i=!0),t&&(t.texture&&(this._rect.x=this._rect.y=0,this._rect.width=t.texture.width,this._rect.height=t.texture.height,this._refreshTexture(t.texture),this.checkRect(this._texture)),t.originalSize&&this._originalSize.set(t.originalSize),t.rect&&this._rect.set(t.rect),t.offset&&this._offset.set(t.offset),void 0!==t.borderTop&&(this._capInsets[1]=t.borderTop),void 0!==t.borderBottom&&(this._capInsets[3]=t.borderBottom),void 0!==t.borderLeft&&(this._capInsets[0]=t.borderLeft),void 0!==t.borderRight&&(this._capInsets[2]=t.borderRight),void 0!==t.isRotate&&(this._rotated=!!t.isRotate),void 0!==t.isFlipUv&&(this._isFlipUVY=!!t.isFlipUv),i=!0),i&&this.texture&&this._calculateUV(),this._calcTrimmedBorder()},i.checkRect=function(t){var e=this._rect,i=e.x,n=e.y;return this._rotated?(i+=e.height,n+=e.width):(i+=e.width,n+=e.height),i>t.width?(hn(3300,this.name+"/"+t.name,i,t.width),!1):!(n>t.height&&(hn(3301,this.name+"/"+t.name,n,t.height),1))},i._calcTrimmedBorder=function(){var t=this._originalSize.width,e=this._originalSize.height,i=.5*(t-this._rect.width),n=.5*(e-this._rect.height);this._trimmedBorder.x=this._offset.x+i,this._trimmedBorder.y=this._offset.x-i,this._trimmedBorder.z=this._offset.y+n,this._trimmedBorder.w=this._offset.y-n},i.ensureMeshData=function(){this._mesh||(this._initVertices(),this._createMesh())},i.destroy=function(){return this._packable&&Ja&&Ja.deleteAtlasSpriteFrame(this),t.prototype.destroy.call(this)},i._calculateSlicedUV=function(){var t=this._rect,i=this.texture,n=i.width,r=i.height,s=this._capInsets[0],a=this._capInsets[2],o=t.width-s-a,h=this._capInsets[1],l=this._capInsets[3],u=t.height-h-l,c=this.uvSliced;if(c.length=0,this._rotated){ko[0].u=t.x/n,ko[1].u=(t.x+l)/n,ko[2].u=(t.x+l+u)/n,ko[3].u=(t.x+t.height)/n,ko[3].v=t.y/r,ko[2].v=(t.y+s)/r,ko[1].v=(t.y+s+o)/r,ko[0].v=(t.y+t.width)/r;for(var d=0;d<4;++d)for(var _=ko[d],f=0;f<4;++f){var p=ko[3-f];c.push({u:_.u,v:p.v})}}else{ko[0].u=t.x/n,ko[1].u=(t.x+s)/n,ko[2].u=(t.x+s+o)/n,ko[3].u=(t.x+t.width)/n,ko[3].v=t.y/r,ko[2].v=(t.y+h)/r,ko[1].v=(t.y+h+u)/r,ko[0].v=(t.y+t.height)/r;for(var g=0;g<4;++g)for(var m=ko[g],v=0;v<4;++v){var y=ko[v];c.push({u:y.u,v:m.v})}}this.emit(e.EVENT_UV_UPDATED,this)},i._calculateUV=function(){var t=this._rect,e=this.uv,i=this.unbiasUV,n=this.texture,r=n.width,s=n.height;if(this._rotated){var a=0===r?0:t.x/r,o=0===r?1:(t.x+t.height)/r,h=0===s?0:t.y/s,l=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=o,e[1]=l,e[2]=o,e[3]=h,e[4]=a,e[5]=l,e[6]=a,e[7]=h):this._isFlipUVX?(e[0]=o,e[1]=h,e[2]=o,e[3]=l,e[4]=a,e[5]=h,e[6]=a,e[7]=l):this._isFlipUVY?(e[0]=a,e[1]=l,e[2]=a,e[3]=h,e[4]=o,e[5]=l,e[6]=o,e[7]=h):(e[0]=a,e[1]=h,e[2]=a,e[3]=l,e[4]=o,e[5]=h,e[6]=o,e[7]=l);var u=0===r?0:t.x/r,c=0===r?1:(t.x+t.height)/r,d=0===s?0:t.y/s,_=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=c,i[1]=_,i[2]=c,i[3]=d,i[4]=u,i[5]=_,i[6]=u,i[7]=d):this._isFlipUVX?(i[0]=c,i[1]=d,i[2]=c,i[3]=_,i[4]=u,i[5]=d,i[6]=u,i[7]=_):this._isFlipUVY?(i[0]=u,i[1]=_,i[2]=u,i[3]=d,i[4]=c,i[5]=_,i[6]=c,i[7]=d):(i[0]=u,i[1]=d,i[2]=u,i[3]=_,i[4]=c,i[5]=d,i[6]=c,i[7]=_)}else{var f=0===r?0:t.x/r,p=0===r?1:(t.x+t.width)/r,g=0===s?1:(t.y+t.height)/s,m=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=p,e[1]=m,e[2]=f,e[3]=m,e[4]=p,e[5]=g,e[6]=f,e[7]=g):this._isFlipUVX?(e[0]=p,e[1]=g,e[2]=f,e[3]=g,e[4]=p,e[5]=m,e[6]=f,e[7]=m):this._isFlipUVY?(e[0]=f,e[1]=m,e[2]=p,e[3]=m,e[4]=f,e[5]=g,e[6]=p,e[7]=g):(e[0]=f,e[1]=g,e[2]=p,e[3]=g,e[4]=f,e[5]=m,e[6]=p,e[7]=m);var v=0===r?0:t.x/r,y=0===r?1:(t.x+t.width)/r,T=0===s?1:(t.y+t.height)/s,S=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=y,i[1]=S,i[2]=v,i[3]=S,i[4]=y,i[5]=T,i[6]=v,i[7]=T):this._isFlipUVX?(i[0]=y,i[1]=T,i[2]=v,i[3]=T,i[4]=y,i[5]=S,i[6]=v,i[7]=S):this._isFlipUVY?(i[0]=v,i[1]=S,i[2]=y,i[3]=S,i[4]=v,i[5]=T,i[6]=y,i[7]=T):(i[0]=v,i[1]=T,i[2]=y,i[3]=T,i[4]=v,i[5]=S,i[6]=y,i[7]=S)}this._calculateSlicedUV()},i._setDynamicAtlasFrame=function(t){t&&(this._original={_texture:this._texture,_x:this._rect.x,_y:this._rect.y},this._texture=t.texture,this._rect.x=t.x,this._rect.y=t.y,this._calculateUV())},i._resetDynamicAtlasFrame=function(){this._original&&(this._rect.x=this._original._x,this._rect.y=this._original._y,this._texture=this._original._texture,this._original=null,this._calculateUV())},i._checkPackable=function(){var t=Ja;if(t){var e=this._texture;if(e instanceof Xe&&!e.isCompressed){var i=this.width,n=this.height;if(!e.image||i>t.maxFrameSize||n>t.maxFrameSize)this._packable=!1;else{var r=ln.HTMLCanvasElement;e.image&&e.image instanceof r&&(this._packable=!0)}}else this._packable=!1}},i._serialize=function(){return null},i._deserialize=function(t){var e=t,i=e.rect;i&&(this._rect=new un(i.x,i.y,i.width,i.height));var n=e.offset;e.offset&&(this._offset=new cn(n.x,n.y));var r=e.originalSize;e.originalSize&&(this._originalSize=new dn(r.width,r.height)),this._rotated=!!e.rotated,this._name=e.name,this._packable=!!e.packable,this._pixelsToUnit=e.pixelsToUnit;var s=e.pivot;s&&(this._pivot=new cn(s.x,s.y)),this._meshType=e.meshType;var a=e.capInsets;a&&(this._capInsets[0]=a[0],this._capInsets[1]=a[1],this._capInsets[2]=a[2],this._capInsets[3]=a[3]);var o=e.vertices;if(o){this.vertices||(this.vertices={rawPosition:[],positions:[],indexes:o.indexes,uv:o.uv,nuv:o.nuv,minPos:new ji(o.minPos.x,o.minPos.y,o.minPos.z),maxPos:new ji(o.maxPos.x,o.maxPos.y,o.maxPos.z)}),this.vertices.rawPosition.length=0;for(var h=o.rawPosition,l=0;l<h.length;l+=3)this.vertices.rawPosition.push(new ji(h[l],h[l+1],h[l+2]));this._updateMeshVertices()}},i.clone=function(){var t,i,n,r,s=new e,a=this.vertices;return s.vertices=a?{rawPosition:a.rawPosition.slice(0),positions:a.positions.slice(0),indexes:a.indexes.slice(0),uv:a.uv.slice(0),nuv:a.nuv.slice(0),minPos:a.minPos.clone(),maxPos:a.minPos.clone()}:null,(t=s.uv).splice.apply(t,[0,s.uv.length].concat(this.uv)),(i=s.unbiasUV).splice.apply(i,[0,s.unbiasUV.length].concat(this.unbiasUV)),(n=s.uvSliced).splice.apply(n,[0,s.uvSliced.length].concat(this.uvSliced)),s._rect.set(this._rect),s._offset.set(this._offset),s._originalSize.set(this._originalSize),s._rotated=this._rotated,(r=s._capInsets).splice.apply(r,[0,s._capInsets.length].concat(this._capInsets)),s._atlasUuid=this._atlasUuid,s._texture=this._texture,s._isFlipUVX=this._isFlipUVX,s._isFlipUVY=this._isFlipUVY,s._pixelsToUnit=this._pixelsToUnit,s._pivot.set(this._pivot),s._meshType=this._meshType,s},i._refreshTexture=function(t){this._texture=t;var e=this._texture,i={},n=!1;0!==this._rect.width&&0!==this._rect.height&&this.checkRect(e)||(i.rect=new un(0,0,e.width,e.height),n=!0),(0===this._originalSize.width||0===this._originalSize.height||n)&&(i.originalSize=new dn(e.width,e.height),n=!0),n&&this.reset(i),this._checkPackable(),this._mesh&&this._updateMesh()},i.onLoaded=function(){this._calcTrimmedBorder()},i.initDefault=function(e){t.prototype.initDefault.call(this,e);var i=new Xe;i.initDefault(),this._refreshTexture(i),this._calculateUV()},i.validate=function(){return this._texture&&this._rect&&0!==this._rect.width&&0!==this._rect.height},i._initVertices=function(){if(this.vertices?(this.vertices.rawPosition.length=0,this.vertices.positions.length=0,this.vertices.indexes.length=0,this.vertices.uv.length=0,this.vertices.nuv.length=0,this.vertices.minPos.set(0,0,0),this.vertices.maxPos.set(0,0,0)):this.vertices={rawPosition:[],positions:[],indexes:[],uv:[],nuv:[],minPos:new ji,maxPos:new ji},this._meshType===Po.POLYGON);else{var t=this.texture,e=t.width,i=t.height,n=this.rect,r=n.width,s=n.height,a=n.x,o=i-n.y-s,h=r/2,l=s/2,u=0===e?0:a/e,c=0===e?1:(a+r)/e,d=0===i?1:(o+s)/i,_=0===i?0:n.y/i;Do.set(-h,-l,0),this.vertices.rawPosition.push(Do.clone()),this.vertices.uv.push(a),this.vertices.uv.push(o+s),this.vertices.nuv.push(u),this.vertices.nuv.push(_),this.vertices.minPos.set(Do),Do.set(h,-l,0),this.vertices.rawPosition.push(Do.clone()),this.vertices.uv.push(a+r),this.vertices.uv.push(o+s),this.vertices.nuv.push(c),this.vertices.nuv.push(_),Do.set(-h,l,0),this.vertices.rawPosition.push(Do.clone()),this.vertices.uv.push(a),this.vertices.uv.push(o),this.vertices.nuv.push(u),this.vertices.nuv.push(d),Do.set(h,l,0),this.vertices.rawPosition.push(Do.clone()),this.vertices.uv.push(a+r),this.vertices.uv.push(o),this.vertices.nuv.push(c),this.vertices.nuv.push(d),this.vertices.maxPos.set(Do),this.vertices.indexes.push(0),this.vertices.indexes.push(1),this.vertices.indexes.push(2),this.vertices.indexes.push(2),this.vertices.indexes.push(1),this.vertices.indexes.push(3)}this._updateMeshVertices()},i._updateMeshVertices=function(){Oo.identity();var t=1/this._pixelsToUnit,e=new ji(t,t,1);Oo.scale(e);var i=-(this._pivot.x-.5)*this.rect.width*t,n=-(this._pivot.y-.5)*this.rect.height*t;e.set(i,n,0),Oo.translate(e);for(var r=this.vertices,s=0;s<r.rawPosition.length;s++){var a=r.rawPosition[s];ji.transformMat4(e,a,Oo),ji.toArray(r.positions,e,3*s)}ji.transformMat4(this._minPos,r.minPos,Oo),ji.transformMat4(this._maxPos,r.maxPos,Oo)},i._createMesh=function(){this._mesh=Ro({primitiveMode:U.TRIANGLE_LIST,positions:this.vertices.positions,uvs:this.vertices.nuv,indices:this.vertices.indexes,minPos:this._minPos,maxPos:this._maxPos,attributes:[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RG32F)]})},i._updateMesh=function(){this._mesh&&this._mesh.destroy(),this._initVertices(),this._createMesh()},Pi(e,[{key:"insetTop",get:function(){return this._capInsets[1]},set:function(t){this._capInsets[1]!==t&&(this._capInsets[1]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetBottom",get:function(){return this._capInsets[3]},set:function(t){this._capInsets[3]!==t&&(this._capInsets[3]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetLeft",get:function(){return this._capInsets[0]},set:function(t){this._capInsets[0]!==t&&(this._capInsets[0]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetRight",get:function(){return this._capInsets[2]},set:function(t){this._capInsets[2]!==t&&(this._capInsets[2]=t,this._texture&&this._calculateSlicedUV())}},{key:"rect",get:function(){return this._rect},set:function(t){this._rect.equals(t)||(this._rect.set(t),this._texture&&this._calculateUV(),this._calcTrimmedBorder())}},{key:"originalSize",get:function(){return this._originalSize},set:function(t){this._originalSize.equals(t)||(this._originalSize.set(t),this._texture&&this._calculateUV(),this._calcTrimmedBorder())}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset.set(t),this._calcTrimmedBorder()}},{key:"rotated",get:function(){return this._rotated},set:function(t){this._rotated!==t&&(this._rotated=t,this._texture&&this._calculateUV())}},{key:"texture",get:function(){return this._texture},set:function(t){t?t!==this._texture&&this.reset({texture:t},!0):Zi(3122,this.name)}},{key:"atlasUuid",get:function(){return this._atlasUuid},set:function(t){this._atlasUuid=t}},{key:"width",get:function(){return this._texture.width}},{key:"height",get:function(){return this._texture.height}},{key:"_textureSource",set:function(t){globalThis.Build?this._texture=t:t&&(this._refreshTexture(t),this._calculateUV())}},{key:"flipUVX",get:function(){return this._isFlipUVX},set:function(t){this._isFlipUVX=t,this._calculateUV()}},{key:"flipUVY",get:function(){return this._isFlipUVY},set:function(t){this._isFlipUVY=t,this._calculateUV()}},{key:"packable",get:function(){return this._packable},set:function(t){this._packable=t}},{key:"original",get:function(){return this._original}},{key:"pixelsToUnit",get:function(){return this._pixelsToUnit}},{key:"pivot",get:function(){return this._pivot}},{key:"mesh",get:function(){return this._mesh}},{key:"trimmedBorder",get:function(){return this._trimmedBorder}}]),e}($i),wo.EVENT_UV_UPDATED="uv_updated",wo.MeshType=Po,xo=Mo))||xo);We.SpriteFrame=Uo;var Go,Vo=t("SpriteAtlas",Ki("cc.SpriteAtlas")((Lo=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).spriteFrames=No&&No(),e}He(e,t);var i=e.prototype;return i.getTexture=function(){var t=Object.keys(this.spriteFrames);if(t.length>0){var e=this.spriteFrames[t[0]];return e&&e.texture}return null},i.getSpriteFrame=function(t){var e=this.spriteFrames[t];return e?(e.name||(e.name=t),e):null},i.getSpriteFrames=function(){for(var t=[],e=this.spriteFrames,i=0,n=Object.keys(e);i<n.length;i++){var r=n[i];t.push(e[r])}return t},i._serialize=function(){},i._deserialize=function(t,e){var i=t;this._name=i.name;var n=i.spriteFrames;this.spriteFrames=fn();for(var r=0;r<n.length;r+=2)e.result.push(this.spriteFrames,n[r],n[r+1],pn(Uo))},e}($i),No=tn(Lo.prototype,"spriteFrames",[en],(function(){return fn()})),Fo=Lo))||Fo);We.SpriteAtlas=Vo;var Ho,zo,Xo,Wo=t("Font",Ki("cc.Font")(Go=function(t){function e(){return t.apply(this,arguments)||this}return He(e,t),e}($i))||Go);We.Font=Wo;var Yo,jo,Ko,qo,Zo,Qo,Jo,$o,th=t("TTFFont",Ki("cc.TTFFont")((zo=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._fontFamily=Xo&&Xo(),e}return He(e,t),e.prototype.initDefault=function(e){this._fontFamily="Arial",t.prototype.initDefault.call(this,e)},Pi(e,[{key:"_nativeAsset",get:function(){return this._fontFamily},set:function(t){this._fontFamily=t||"Arial"}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,__nativeName__:this._native,ext:yn(this._native),__isNative__:!0}}}]),e}(Wo),Xo=tn(zo.prototype,"_fontFamily",[en],(function(){return null})),gn(zo.prototype,"_nativeAsset",[mn,vn],Object.getOwnPropertyDescriptor(zo.prototype,"_nativeAsset"),zo.prototype),gn(zo.prototype,"_nativeDep",[mn],Object.getOwnPropertyDescriptor(zo.prototype,"_nativeDep"),zo.prototype),Ho=zo))||Ho);We.TTFFont=th;var eh,ih=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.offsetX=0,this.offsetY=0,this.textureID=0,this.valid=!1,this.xAdvance=0},nh=function(){function t(t){this.letterDefinitions={},this.texture=t}var e=t.prototype;return e.addLetterDefinitions=function(t,e){this.letterDefinitions[t]=e},e.cloneLetterDefinition=function(){for(var t={},e=0,i=Object.keys(this.letterDefinitions);e<i.length;e++){var n=i[e],r=new ih;Sn(r,this.letterDefinitions[n]),t[n]=r}return t},e.getTexture=function(){return this.texture},e.getLetter=function(t){return this.letterDefinitions[t]},e.getLetterDefinitionForChar=function(t){var e=t.charCodeAt(0);return this.letterDefinitions.hasOwnProperty(e)?this.letterDefinitions[e]:null},e.clear=function(){this.letterDefinitions={}},t}(),rh=t("BitmapFont",(Yo=Ki("cc.BitmapFont"),jo=Tn(Uo),Yo((qo=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).fntDataStr=Zo&&Zo(),e.spriteFrame=Qo&&Qo(),e.fontSize=Jo&&Jo(),e.fntConfig=$o&&$o(),e}return He(e,t),e.prototype.onLoaded=function(){var t=this.spriteFrame;!this.fontDefDictionary&&t&&(this.fontDefDictionary=new nh(t.texture));var e=this.fntConfig;if(e){var i=e.fontDefDictionary;for(var n in i){var r=new ih,s=i[n].rect;r.offsetX=i[n].xOffset,r.offsetY=i[n].yOffset,r.w=s.width,r.h=s.height,r.u=s.x,r.v=s.y,r.textureID=0,r.valid=!0,r.xAdvance=i[n].xAdvance,this.fontDefDictionary.addLetterDefinitions(n,r)}}else Gi("The fnt config is not exists!")},e}(Wo),Zo=tn(qo.prototype,"fntDataStr",[en],(function(){return""})),Qo=tn(qo.prototype,"spriteFrame",[jo],(function(){return null})),Jo=tn(qo.prototype,"fontSize",[en],(function(){return-1})),$o=tn(qo.prototype,"fntConfig",[en],(function(){return null})),Ko=qo))||Ko));We.BitmapFont=rh;var sh=t("LabelAtlas",Ki("cc.LabelAtlas")(eh=function(t){function e(){return t.apply(this,arguments)||this}return He(e,t),e}(rh))||eh);We.LabelAtlas=sh;var ah=t("BASELINE_RATIO",.26),oh=t("MIDDLE_RATIO",(ah+1)/2-ah);var hh=new En(2);hh.get=function(){return this._get()||{key:"",value:0,prev:null,next:null}};var lh,uh=new(function(){function t(t){this.count=0,this.limit=0,this.datas={},this.limit=t}var e=t.prototype;return e.moveToHead=function(t){t.next=this.head,t.prev=null,this.head&&(this.head.prev=t),this.head=t,this.tail||(this.tail=t),this.count++,this.datas[t.key]=t},e.put=function(t,e){var i=hh.get();if(i.key=t,i.value=e,this.count>=this.limit){var n=this.tail;delete this.datas[n.key],this.count--,this.tail=n.prev,this.tail.next=null,n.prev=null,n.next=null,hh.put(n)}this.moveToHead(i)},e.remove=function(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.datas[t.key],this.count--},e.get=function(t){var e=this.datas[t];return e?(this.remove(e),this.moveToHead(e),e.value):null},e.clear=function(){this.count=0,this.datas={},this.head=null,this.tail=null},e.has=function(t){return!!this.datas[t]},e.delete=function(t){var e=this.datas[t];this.remove(e)},t}())(100),ch=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,dh=/^[!,.:;'}\]%\?>、‘“》?。,!]/,_h=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+|\S)$/,fh=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+$/,ph=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]/;function gh(t){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(t)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(t)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(t)}function mh(t){var e=t.charCodeAt(0);return e>=9&&e<=13||32===e||133===e||160===e||5760===e||e>=8192&&e<=8202||8232===e||8233===e||8239===e||8287===e||12288===e}function vh(t,e,i){var n=(i||t.font)+"🎮"+e,r=uh.get(n);if(null!==r)return r;var s=t.measureText(e),a=s&&s.width||0;return uh.put(n,a),a}function yh(t,e,i){var n=e,r=i,s=t[e];if(s>="\udc00"&&s<="\udfff"&&n--,void 0!==i)if(i-1!==e){var a=t[i-1];a>="\ud800"&&a<="\udbff"&&r--}else s>="\ud800"&&s<="\udbff"&&r++;return t.substring(n,r)}function Th(t){return ph.exec(t)}function Sh(t){return fh.exec(t)}function Eh(t,e,i,n){var r=[];if(0===t.length||i<0)return r.push(""),r;for(var s=t;e>i&&s.length>1;){for(var a=s.length*(i/e)|0,o=yh(s,a),h=e-n(o),l=o,u=0,c=0;h>i&&c++<100;)a*=i/h,h=e-n(o=yh(s,a|=0));for(c=0;o&&h<=i&&c++<100;){var d=ch.exec(o);l=o,h=e-n(o=yh(s,a+=u=d?d[0].length:1))}0==(a-=u)?(a=1,l=yh(s,1)):1===a&&s[0]>="\ud800"&&s[0]<="\udbff"&&(a=2,l=yh(s,2));var _=yh(s,0,a),f=void 0;dh.test(l||o)&&(0==(a-=(f=_h.exec(_))?f[0].length:0)&&(a=1),l=yh(s,a),_=yh(s,0,a)),ph.test(l)&&(f=fh.exec(_))&&_!==f[0]&&(l=yh(s,a-=f[0].length),_=yh(s,0,a)),(0===r.length||(_=_.trim()).length>0)&&r.push(_),e=n(s=l||o)}return(0===r.length||(s=s.trim()).length>0)&&r.push(s),r}var Ah,Ch=t("CanvasPool",function(){function t(){this.pool=[]}t.getInstance=function(){return lh||(lh=new t),lh};var e=t.prototype;return e.get=function(){var t=this.pool.pop();if(!t){var e=ln.document.createElement("canvas"),i=e.getContext("2d");t={canvas:e,context:i}}return t},e.put=function(t){this.pool.length>=Mi.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(t)},t}()),Rh=Ve.WHITE.clone(),bh=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.texture=null,this.offsetX=0,this.offsetY=0,this.valid=!1,this.xAdvance=0},xh="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",wh=function(){function t(t,e){this.image=null,this.labelInfo=void 0,this.char=void 0,this.data=null,this.canvas=null,this.context=null,this.width=0,this.height=0,this.offsetY=0,this.hash=void 0,this.char=t,this.labelInfo=e,this.hash=""+t.charCodeAt(0)+e.hash}var e=t.prototype;return e.updateRenderData=function(){this._updateProperties(),this._updateTexture()},e.destroy=function(){this.image=null,Ch.getInstance().put(this.data)},e._updateProperties=function(){if(this.data=Ch.getInstance().get(),this.canvas=this.data.canvas,this.context=this.data.context,this.context){this.context.font=this.labelInfo.fontDesc;var t=vh(this.context,this.char,this.labelInfo.fontDesc),e=2*this.labelInfo.margin+2;this.width=parseFloat(t.toFixed(2))+e,this.height=(1+ah)*this.labelInfo.fontSize+e,this.offsetY=-this.labelInfo.fontSize*ah/2}this.canvas.width!==this.width&&(this.canvas.width=this.width),this.canvas.height!==this.height&&(this.canvas.height=this.height),this.image||(this.image=new Ui),this.image.reset(this.canvas)},e._updateTexture=function(){if(this.context&&this.canvas){var t=this.context,e=this.labelInfo,i=this.canvas.width,n=this.canvas.height;t.textAlign="center",t.textBaseline="alphabetic",t.clearRect(0,0,i,n),t.fillStyle=xh,t.fillRect(0,0,i,n),t.font=e.fontDesc;var r=e.fontSize,s=i/2,a=n/2+r*oh+0*r,o=e.color;if(t.lineJoin="round",t.fillStyle="rgba("+o.r+", "+o.g+", "+o.b+", 1)",e.isOutlined){var h=e.out||Rh;t.strokeStyle="rgba("+h.r+", "+h.g+", "+h.b+", "+h.a/255+")",t.lineWidth=2*e.margin,t.strokeText(this.char,s,a)}t.fillText(this.char,s,a)}},t}(),Mh=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=ze.RGBA8888),this.reset({width:t,height:e,format:i})},i.drawTextureAt=function(t,e,i){var n=this.getGFXTexture();if(t&&n){var r=this._getGFXDevice();if(r){var s=new ht;s.texOffset.x=e,s.texOffset.y=i,s.texExtent.width=t.width,s.texExtent.height=t.height,r.copyTexImagesToTexture([t.data],n,[s])}else console.warn("Unable to get device")}},e}(Xe),Ih=function(){function t(t,e){this._x=0,this._y=0,this._nextY=0,this._width=0,this._height=0,this._halfBleed=0,this._dirty=!1;var i=new Mh;i.initWithSize(t,e),this.fontDefDictionary=new nh(i),this._halfBleed=1,this._width=t,this._height=e,Di.on(An.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}var e=t.prototype;return e.insertLetterTexture=function(t){var e=t.image,i=Di.root.device;if(!e||!this.fontDefDictionary||!i)return null;var n=e.width,r=e.height;if(this._x+n+0>this._width&&(this._x=0,this._y=this._nextY),this._y+r>this._nextY&&(this._nextY=this._y+r+0),this._nextY>this._height)return Zi(12100),null;this.fontDefDictionary.texture.drawTextureAt(e,this._x,this._y),this._dirty=!0;var s=new bh;return s.u=this._x+this._halfBleed,s.v=this._y+this._halfBleed,s.texture=this.fontDefDictionary.texture,s.valid=!0,s.w=t.width-2,s.h=t.height-2,s.xAdvance=s.w,s.offsetY=t.offsetY,this._x+=n+0,this.fontDefDictionary.addLetterDefinitions(t.hash,s),s},e.update=function(){this._dirty&&(this._dirty=!1)},e.reset=function(){this._x=0,this._y=0,this._nextY=0,this.fontDefDictionary.clear()},e.destroy=function(){this.reset(),this.fontDefDictionary&&(this.fontDefDictionary.texture.destroy(),this.fontDefDictionary.texture=null)},e.getTexture=function(){return this.fontDefDictionary.getTexture()},e.beforeSceneLoad=function(){this.clearAllCache()},e.clearAllCache=function(){this.destroy();var t=new Mh;t.initWithSize(this._width,this._height),this.fontDefDictionary.texture=t},e.getLetter=function(t){return this.fontDefDictionary.letterDefinitions[t]},e.getLetterDefinitionForChar=function(t,e){var i=t.charCodeAt(0)+e.hash,n=this.fontDefDictionary.letterDefinitions[i];if(!n){var r=new wh(t,e);r.updateRenderData(),n=this.insertLetterTexture(r),r.destroy()}return n},Pi(t,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),t}(),Bh={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:Ve.WHITE.clone(),isOutlined:!1,out:Ve.WHITE.clone(),margin:0},Ph=[new Bt(ie.ATTR_POSITION,_.RGB32F)],Dh=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_COLOR,_.RGBA32F)],Oh=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RG32F),new Bt(ie.ATTR_COLOR,_.RGBA32F)],Fh=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RG32F),new Bt(ie.ATTR_COLOR,_.RGBA8,!0)],Lh=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RG32F),new Bt(ie.ATTR_COLOR,_.RGBA32F),new Bt(ie.ATTR_COLOR2,_.RGBA32F)],Nh=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RG32F),new Bt(ie.ATTR_COLOR,_.RGBA8,!0),new Bt(ie.ATTR_COLOR2,_.RGBA8,!0)];function kh(t){for(var e=0,i=0;i<t.length;i++){var n=t[i];e+=ne[n.format].count}return e}function Uh(t){for(var e=0,i=0;i<t.length;i++){var n=t[i];e+=ne[n.format].size}return e}We.internal.vfmtPosUvColor=Oh,We.internal.vfmtPosUvTwoColor=Lh,We.internal.vfmtPosUvColor4B=Fh,We.internal.vfmtPosUvTwoColor4B=Nh,t("UIVertexFormat",Object.freeze({__proto__:null,vfmt:Ph,vfmtPosColor:Dh,vfmtPosUvColor:Oh,vfmtPosUvColor4B:Fh,vfmtPosUvTwoColor:Lh,vfmtPosUvTwoColor4B:Nh,getComponentPerVertex:kh,getAttributeStride:Uh})),function(t){t[t.byteOffset=0]="byteOffset",t[t.vertexOffset=1]="vertexOffset",t[t.indexOffset=2]="indexOffset",t[t.dirty=3]="dirty",t[t.count=4]="count"}(Ah||(Ah={}));var Gh,Vh,Hh,zh,Xh=t("MeshBuffer",function(){var t=e.prototype;function e(){this._byteOffset=0,this._vertexOffset=0,this._indexOffset=0,this._dirty=!1,this._floatsPerVertex=0,this._vData=null,this._iData=null,this._vertexFormatBytes=0,this._initVDataCount=0,this._initIDataCount=0,this._attributes=null,this._iaPool=[],this._iaInfo=null,this._nextFreeIAHandle=0,this.initSharedBuffer(),this.syncSharedBufferToNative()}return t.initSharedBuffer=function(){},t.syncSharedBufferToNative=function(){},t.initialize=function(t,e,i,n){this._initVDataCount=i,this._initIDataCount=n,this._attributes=e,this.floatsPerVertex=Uh(e)>>2,Ni(this._initVDataCount/this._floatsPerVertex<65536,Cn(9005)),this.vData&&this.iData||(this.vData=new Float32Array(this._initVDataCount),this.iData=new Uint16Array(this._initIDataCount)),this._iaPool.push(this.createNewIA(t))},t.reset=function(){this._nextFreeIAHandle=0,this.dirty=!1},t.destroy=function(){this.reset(),this._attributes=null,this._iaInfo=null,this.vData=null,this.iData=null;for(var t=0;t<this._iaPool.length;++t){var e=this._iaPool[t];e.vertexBuffers[0]&&e.vertexBuffers[0].destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.ia.destroy()}this._iaPool.length=0},t.setDirty=function(){this.dirty=!0},t.request=function(){return Zi(9002),!1},t.requireFreeIA=function(t){return this._iaPool.length<=this._nextFreeIAHandle&&this._iaPool.push(this.createNewIA(t)),this._iaPool[this._nextFreeIAHandle++].ia},t.recycleIA=function(t){for(var e=this._iaPool,i=0;i<this._nextFreeIAHandle;++i)if(t===e[i].ia){var n=e[i];return e[i]=e[--this._nextFreeIAHandle],void(e[this._nextFreeIAHandle]=n)}},t.checkCapacity=function(t,e){var i=(this.vertexOffset+t)*this._floatsPerVertex,n=this.indexOffset+e;return!(i>this._initVDataCount||n>this._initIDataCount)},t.uploadBuffers=function(){if(0!==this.byteOffset&&this._dirty){for(var t=rn.__isWebIOS14OrIPadOS14Env?this._nextFreeIAHandle:1,e=this.byteOffset,i=this.indexOffset,n=0;n<t;++n){var r=this._iaPool[n],s=new Float32Array(this.vData.buffer,0,e>>2),a=new Uint16Array(this.iData.buffer,0,i),o=r.vertexBuffers[0];e>o.size&&o.resize(e),o.update(s),2*i>r.indexBuffer.size&&r.indexBuffer.resize(2*i),r.indexBuffer.update(a)}this.dirty=!1}},t.createNewIA=function(t){var e,i,n;if(rn.__isWebIOS14OrIPadOS14Env||!this._iaPool[0]){var r=this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT,s=Uint16Array.BYTES_PER_ELEMENT,a=t.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.HOST|y.DEVICE,r,r));n=t.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.HOST|y.DEVICE,s,s)),i=[a],this._iaInfo=new Dt(this._attributes,i,n),e=t.createInputAssembler(this._iaInfo)}else e=t.createInputAssembler(this._iaInfo),i=this._iaInfo.vertexBuffers,n=this._iaInfo.indexBuffer;return{ia:e,vertexBuffers:i,indexBuffer:n}},Pi(e,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}},{key:"byteOffset",get:function(){return this._byteOffset},set:function(t){this._byteOffset=t}},{key:"vertexOffset",get:function(){return this._vertexOffset},set:function(t){this._vertexOffset=t}},{key:"indexOffset",get:function(){return this._indexOffset},set:function(t){this._indexOffset=t}},{key:"dirty",get:function(){return this._dirty},set:function(t){this._dirty=t}},{key:"floatsPerVertex",get:function(){return this._floatsPerVertex},set:function(t){this._floatsPerVertex=t}},{key:"vData",get:function(){return this._vData},set:function(t){this._vData=t}},{key:"iData",get:function(){return this._iData},set:function(t){this._iData=t}},{key:"nativeObj",get:function(){return this._nativeObj}},{key:"sharedBuffer",get:function(){return this._sharedBuffer}}]),e}()),Wh=function(){function t(t,e){this._device=null,this._attributes=null,this._vertexFormatBytes=void 0,this._floatsPerVertex=void 0,this._buffers=[],this._device=t,this._attributes=e,this._floatsPerVertex=Uh(e)>>2,this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT}var e=t.prototype;return e.initialize=function(){},e.reset=function(){},e.request=function(){},e.appendBuffers=function(){},e.uploadBuffers=function(){},e.destroy=function(){this._attributes.length=0},Pi(t,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}},{key:"floatsPerVertex",get:function(){return this._floatsPerVertex}}]),t}(),Yh=new e((function(){return{offset:0,length:0}}),32),jh=function(){function t(t,e,i,n,r,s){this._ib=void 0,this.vertexAccessor=t,this.bufferId=e,this.meshBuffer=i,this.vertexOffset=n,this.vb=r,this.indexCount=s,this._ib=new Uint16Array(s),Ni(i===t.getMeshBuffer(e))}return t.prototype.setIndexBuffer=function(){},Pi(t,[{key:"ib",get:function(){return this._ib}}]),t}(),Kh=function(t){function e(i,n,r,s){var a;return(a=t.call(this,i,n)||this)._freeLists=[],a._vCount=0,a._iCount=0,a._id=0,a._vCount=r||Math.floor(1024*Mi.BATCHER2D_MEM_INCREMENT/a._vertexFormatBytes),a._iCount=s||a._vCount*e.IB_SCALE,a._id=e.generateID(),a._allocateBuffer(),a}He(e,t);var i=e.prototype;return i.destroy=function(){for(var e=0;e<this._buffers.length;++e){this._buffers[e].destroy();for(var i=this._freeLists[e],n=0;n<i.length;++n)Yh.free(i[n])}this._buffers.length=0,this._freeLists.length=0,t.prototype.destroy.call(this)},i.reset=function(){for(var t=0;t<this._buffers.length;++t){var e=this._buffers[t];e.indexOffset=0,e.reset()}},i.getVertexBuffer=function(t){return this._buffers[t].vData},i.getIndexBuffer=function(t){return this._buffers[t].iData},i.getMeshBuffer=function(t){return this._buffers[t]},i.uploadBuffers=function(){for(var t=0;t<this._buffers.length;++t){var e=this._freeLists[t][0],i=this._buffers[t];(!e||e.length<i.vData.byteLength)&&i.uploadBuffers()}},i.appendIndices=function(t,e){var i=this._buffers[t];if(e.length){var n=i.indexOffset+e.length;if(i.iData.length<n){var r=Math.floor(1.25*n),s=new Uint16Array(r);s.set(i.iData),i.iData=s}i.iData.set(e,i.indexOffset),i.indexOffset+=e.length}},i.allocateChunk=function(t,e){for(var i,n=t*this.vertexFormatBytes,r=null,s=0,a=-1,o=null,h=0;h<this._buffers.length;++h){r=this._buffers[h],i=this._freeLists[h];for(var l=0;l<i.length;++l)if(i[l].length>=n){o=i[l],s=h,a=l;break}if(o)break}if(o||(s=this._allocateBuffer(),(r=this._buffers[s])&&r.checkCapacity(t,e)&&(a=0,o=this._freeLists[s][a])),o){var u=o.offset/this.vertexFormatBytes,c=new Float32Array(r.vData.buffer,o.offset,n>>2).fill(0);return this._allocateChunkFromEntry(s,a,o,n),new jh(this,s,r,u,c,e)}return hn(9004,n),null},i.recycleChunk=function(t){var e=this._freeLists[t.bufferId],i=this._buffers[t.bufferId],n=t.vertexOffset*this.vertexFormatBytes,r=t.vb.byteLength;if(0!==r){for(var s=!1,a=0,o=null,h=e[a];h&&h.offset<n;)o=h,h=e[++a];if(o&&0==n-(o.offset+o.length)&&(o.length+=r,n=o.offset,r=o.length,h&&h.offset-(n+r)==0&&(o.length+=h.length,e.splice(a,1),Yh.free(h),h=null),s=!0),!s&&h){if(0==h.offset-(n+r))h.offset=n,h.length+=r;else{var l=Yh.alloc();l.offset=n,l.length=r,e.splice(a,0,l)}s=!0}if(s)n+r===i.byteOffset&&(i.byteOffset=n);else{var u=Yh.alloc();u.offset=n,u.length=r,e.push(u)}}},i._allocateChunkFromEntry=function(t,e,i,n){var r=i.length-n,s=i.offset+n,a=this._buffers[t];a.byteOffset<s&&(a.byteOffset=s),Rn(r>=0,9004,t,i.offset,i.length),0===r?(this._freeLists[t].splice(e,1),Yh.free(i)):(i.offset+=n,i.length=r)},i._allocateBuffer=function(){Rn(this._buffers.length===this._freeLists.length,9003);var t=new Xh,e=this._vCount*this._floatsPerVertex;t.initialize(this._device,this._attributes,e,this._iCount),this._buffers.push(t);var i=Yh.alloc();i.offset=0,i.length=t.vData.byteLength;var n=[i];return this._freeLists.push(n),Di.root.batcher2D.syncMeshBuffersToNative(this.id,this._buffers),this._buffers.length-1},e.generateID=function(){return e.ID_COUNT++},Pi(e,[{key:"id",get:function(){return this._id}}]),e}(Wh);Kh.IB_SCALE=4,Kh.ID_COUNT=0,function(t){t[t.DrawInfoType=0]="DrawInfoType",t[t.VertDirty=1]="VertDirty",t[t.IsMeshBuffer=2]="IsMeshBuffer",t[t.Stride=3]="Stride",t[t.Count=4]="Count"}(Gh||(Gh={})),function(t){t[t.BufferID=0]="BufferID",t[t.AccessorID=1]="AccessorID",t[t.Count=2]="Count"}(Vh||(Vh={})),function(t){t[t.VertexOffset=0]="VertexOffset",t[t.IndexOffset=1]="IndexOffset",t[t.VBCount=2]="VBCount",t[t.IBCount=3]="IBCount",t[t.DataHash=4]="DataHash",t[t.Count=5]="Count"}(Hh||(Hh={})),function(t){t[t.COMP=0]="COMP",t[t.MODEL=1]="MODEL",t[t.MIDDLEWARE=2]="MIDDLEWARE",t[t.SUB_NODE=3]="SUB_NODE"}(zh||(zh={}));var qh,Zh,Qh=function(){function t(t){this._accId=-1,this._bufferId=-1,this._vertexOffset=0,this._indexOffset=0,this._vb=null,this._ib=null,this._vData=null,this._iData=null,this._vertDirty=!1,this._vbCount=0,this._ibCount=0,this._dataHash=0,this._isMeshBuffer=!1,this._material=null,this._texture=null,this._sampler=null,this._stride=0,this._useLocal=!1,this._model=null,this._drawInfoType=zh.COMP,this._subNode=null,this._uint8SharedBuffer=void 0,this._uint16SharedBuffer=void 0,this._uint32SharedBuffer=void 0,this.init(t);var e=this._nativeObj.getAttrSharedBufferForJS(),i=0;this._uint8SharedBuffer=new Uint8Array(e,i,Gh.Count),i+=Gh.Count*Uint8Array.BYTES_PER_ELEMENT,this._uint16SharedBuffer=new Uint16Array(e,i,Vh.Count),i+=Vh.Count*Uint16Array.BYTES_PER_ELEMENT,this._uint32SharedBuffer=new Uint32Array(e,i,Hh.Count)}var e=t.prototype;return e.init=function(){},e.clear=function(){this._bufferId=0,this._vertexOffset=0,this._indexOffset=0,this._vertDirty=!1},e.setAccId=function(t){this._accId=t},e.setBufferId=function(t){this._bufferId=t},e.setAccAndBuffer=function(t,e){this._bufferId=e,this._accId=t},e.setVertexOffset=function(t){this._vertexOffset=t},e.setIndexOffset=function(t){this._indexOffset=t},e.setVB=function(){},e.setIB=function(){},e.setVData=function(){},e.setIData=function(){},e.setVBCount=function(t){this._vbCount=t},e.setIBCount=function(){},e.setVertDirty=function(t){this._vertDirty=t},e.setDataHash=function(t){this._dataHash=t},e.setIsMeshBuffer=function(t){this._isMeshBuffer=t},e.setMaterial=function(t){this._material=t},e.setTexture=function(t){this._texture=t},e.setSampler=function(t){this._sampler=t},e.setModel=function(){},e.setDrawInfoType=function(t){this._drawInfoType=t},e.setSubNode=function(t){this._subNode=t},e.setStride=function(t){this._stride=t},e.initRender2dBuffer=function(){},e.fillRender2dBuffer=function(){},Pi(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"render2dBuffer",get:function(){return this._render2dBuffer}}]),t}();!function(t){t[t.DISABLED=0]="DISABLED",t[t.CLEAR=1]="CLEAR",t[t.ENTER_LEVEL=2]="ENTER_LEVEL",t[t.ENABLED=3]="ENABLED",t[t.EXIT_LEVEL=4]="EXIT_LEVEL",t[t.CLEAR_INVERTED=5]="CLEAR_INVERTED",t[t.ENTER_LEVEL_INVERTED=6]="ENTER_LEVEL_INVERTED"}(qh||(qh={})),function(t){t[t.stencilTest=0]="stencilTest",t[t.func=1]="func",t[t.stencilMask=2]="stencilMask",t[t.writeMask=3]="writeMask",t[t.failOp=4]="failOp",t[t.zFailOp=5]="zFailOp",t[t.passOp=6]="passOp",t[t.ref=7]="ref",t[t.count=8]="count"}(Zh||(Zh={}));var Jh,$h,tl,el,il,nl=t("StencilManager",function(){function t(){this._maskStack=[],this._stencilPattern={stencilTest:!0,func:w.ALWAYS,stencilMask:65535,writeMask:65535,failOp:M.KEEP,zFailOp:M.KEEP,passOp:M.KEEP,ref:1},this._stage=qh.DISABLED,this.stencilStateMap=new Map,this.stencilStateMapWithDepth=new Map}var e=t.prototype;return e.pushMask=function(t){this._maskStack.push(t)},e.clear=function(t){return t.stencilStage!==qh.ENTER_LEVEL?qh.CLEAR_INVERTED:qh.CLEAR},e.enableMask=function(){this.stage=qh.ENABLED},e.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=qh.DISABLED:this.stage=qh.ENABLED)},e.getWriteMask=function(){return 1<<this._maskStack.length-1},e.getExitWriteMask=function(){return 1<<this._maskStack.length},e.getStencilRef=function(){for(var t=0,e=0;e<this._maskStack.length;++e)t+=1<<e;return t},e.getMaskStackSize=function(){return this._maskStack.length},e.reset=function(){this._maskStack.length=0,this.stage=qh.DISABLED},e.destroy=function(){this.stencilStateMap.forEach((function(t){t.destroy()})),this.stencilStateMap.clear()},e.getStencilStage=function(t,e){var i=0,n=!1,r=!1,s=w.LESS,a=this.stencilStateMap;if(e&&e.passes[0]){var o=e.passes[0].depthStencilState,h=0,l=0;o.depthTest&&(h=1),o.depthWrite&&(l=1),i=h|l<<1|o.depthFunc<<2|t<<6|this._maskStack.length<<9,n=o.depthTest,r=o.depthWrite,s=o.depthFunc,a=this.stencilStateMapWithDepth}else i=t<<16|this._maskStack.length;if(a&&a.has(i))return a.get(i);this.setStateFromStage(t);var u=new Ae(n,r,s,this._stencilPattern.stencilTest,this._stencilPattern.func,this._stencilPattern.stencilMask,this._stencilPattern.writeMask,this._stencilPattern.failOp,this._stencilPattern.zFailOp,this._stencilPattern.passOp,this._stencilPattern.ref,this._stencilPattern.stencilTest,this._stencilPattern.func,this._stencilPattern.stencilMask,this._stencilPattern.writeMask,this._stencilPattern.failOp,this._stencilPattern.zFailOp,this._stencilPattern.passOp,this._stencilPattern.ref);return a.set(i,u),u},e.getStencilHash=function(t){return t<<8|this._maskStack.length},e.setStateFromStage=function(t){var e=this._stencilPattern;t===qh.DISABLED?(e.stencilTest=!1,e.func=w.ALWAYS,e.failOp=M.KEEP,e.stencilMask=e.writeMask=65535,e.ref=1):(e.stencilTest=!0,t===qh.ENABLED?(e.func=w.EQUAL,e.failOp=M.KEEP,e.stencilMask=e.ref=this.getStencilRef(),e.writeMask=this.getWriteMask()):t===qh.CLEAR?(e.func=w.NEVER,e.failOp=M.ZERO,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()):t===qh.CLEAR_INVERTED||t===qh.ENTER_LEVEL?(e.func=w.NEVER,e.failOp=M.REPLACE,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()):t===qh.ENTER_LEVEL_INVERTED&&(e.func=w.NEVER,e.failOp=M.ZERO,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()))},Pi(t,[{key:"stage",get:function(){return this._stage},set:function(t){this._stage=t}},{key:"pattern",get:function(){return this._stencilPattern}}]),t}());nl.sharedManager=null,nl.sharedManager=new nl,function(t){t[t.STATIC=0]="STATIC",t[t.DYNAMIC=1]="DYNAMIC",t[t.CROSSED=2]="CROSSED"}(Jh||(Jh={})),function(t){t[t.localOpacity=0]="localOpacity",t[t.count=1]="count"}($h||($h={})),function(t){t[t.colorR=0]="colorR",t[t.colorG=1]="colorG",t[t.colorB=2]="colorB",t[t.colorA=3]="colorA",t[t.maskMode=4]="maskMode",t[t.count=5]="count"}(tl||(tl={})),function(t){t[t.colorDirty=0]="colorDirty",t[t.enabled=1]="enabled",t[t.useLocal=2]="useLocal",t[t.count=3]="count"}(el||(el={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.MASK_INVERTED=2]="MASK_INVERTED",t[t.MASK_NODE=3]="MASK_NODE",t[t.MASK_NODE_INVERTED=4]="MASK_NODE_INVERTED"}(il||(il={}));var rl,sl,al,ol,hl,ll,ul,cl,dl,_l,fl,pl,gl,ml=function(){function t(){this._renderEntityType=Jh.STATIC,this._dynamicDrawInfoArr=[],this._node=null,this._renderTransform=null,this._stencilStage=qh.DISABLED,this._useLocal=!1,this._maskMode=il.NONE,this._color=Ve.WHITE,this._localOpacity=255,this._colorDirty=!0,this._enabled=!1}var e=t.prototype;return e.addDynamicRenderDrawInfo=function(){},e.removeDynamicRenderDrawInfo=function(){},e.clearDynamicRenderDrawInfos=function(){},e.clearStaticRenderDrawInfos=function(){},e.setDynamicRenderDrawInfo=function(){},e.setMaskMode=function(t){this._maskMode=t},e.getStaticRenderDrawInfo=function(){return null},e.setNode=function(t){this._node=t},e.setRenderTransform=function(t){this._renderTransform=t},e.setStencilStage=function(t){this._stencilStage=t},e.setUseLocal=function(t){this._useLocal=t},e.initSharedBuffer=function(){},Pi(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"renderDrawInfoArr",get:function(){return this._dynamicDrawInfoArr}},{key:"renderEntityType",get:function(){return this._renderEntityType}},{key:"color",get:function(){return this._color},set:function(t){this._color=t}},{key:"localOpacity",get:function(){return this._localOpacity},set:function(t){this._localOpacity=t}},{key:"colorDirty",get:function(){return this._colorDirty},set:function(t){this._colorDirty=t}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}}]),t}(),vl=Uh(Oh)>>2,yl=new e((function(){return{x:0,y:0,z:0,u:0,v:0,color:Ve.WHITE.clone()}}),128),Tl=t("BaseRenderData",function(){function t(t){void 0===t&&(t=Oh),this.chunk=null,this._renderDrawInfo=null,this._material=null,this._dataHash=0,this._isMeshBuffer=!1,this._vc=0,this._ic=0,this._floatStride=0,this._vertexFormat=Oh,this._drawInfoType=zh.COMP,this._multiOwner=!1,this._batcher=null,this._floatStride=t===Oh?vl:Uh(t)>>2,this._vertexFormat=t}var e=t.prototype;return e.isValid=function(){return this._ic>0&&this.chunk.vertexAccessor},e.initRenderDrawInfo=function(t,e){void 0===e&&(e=zh.COMP)},e.removeRenderDrawInfo=function(){},e.setRenderDrawInfoAttributes=function(){},Pi(t,[{key:"vertexCount",get:function(){return this._vc}},{key:"indexCount",get:function(){return this._ic}},{key:"stride",get:function(){return this._floatStride<<2}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vertexFormat",get:function(){return this._vertexFormat}},{key:"drawInfoType",get:function(){return this._drawInfoType},set:function(t){this._drawInfoType=t,this._renderDrawInfo&&this._renderDrawInfo.setDrawInfoType(t)}},{key:"renderDrawInfo",get:function(){return this._renderDrawInfo}},{key:"material",get:function(){return this._material},set:function(t){this._material=t,this._renderDrawInfo&&this._renderDrawInfo.setMaterial(t)}},{key:"dataHash",get:function(){return this._dataHash},set:function(t){this._dataHash=t,this._renderDrawInfo&&this._renderDrawInfo.setDataHash(t)}},{key:"multiOwner",get:function(){return this._multiOwner},set:function(t){this._multiOwner=t}},{key:"batcher",get:function(){return this._batcher||(this._batcher=Di.root.batcher2D),this._batcher}}]),t}()),Sl=t("RenderData",function(t){function e(e,i){var n;return void 0===e&&(e=Oh),(n=t.call(this,e)||this)._vertDirty=!0,n._textureHash=0,n.indices=null,n.layer=0,n.nodeDirty=!0,n.passDirty=!0,n.textureDirty=!0,n.hashDirty=!0,n._data=[],n._pivotX=0,n._pivotY=0,n._width=0,n._height=0,n._frame=null,n._accessor=null,n.vertexRow=1,n.vertexCol=1,i||(i=n.batcher.switchBufferAccessor(n._vertexFormat)),n._accessor=i,n}He(e,t),e.add=function(t,i){void 0===t&&(t=Oh);var n=new e(t,i);return i||(i=Di.root.batcher2D.switchBufferAccessor(n._vertexFormat)),n._accessor=i,n},e.remove=function(t){t.clear(),t._accessor=null};var i=e.prototype;return i.resize=function(t,e){t===this._vc&&e===this._ic&&this.chunk||(this._vc=t,this._ic=e,this.chunk&&(this._accessor.recycleChunk(this.chunk),this.chunk=null),this.chunk=this._accessor.allocateChunk(t,e),this.updateHash())},i.setRenderDrawInfoAttributes=function(){},i.fillDrawInfoAttributes=function(){},i.syncRender2dBuffer=function(){},i.resizeAndCopy=function(t,e){if(t!==this._vc||e!==this._ic||!this.chunk){this._vc=t,this._ic=e;var i=this.chunk;this.chunk=this._accessor.allocateChunk(t,e),i&&(this.chunk.vb.set(i.vb),this._accessor.recycleChunk(i)),this.updateHash()}},i.getMeshBuffer=function(){return this.chunk&&this._accessor?this._accessor.getMeshBuffer(this.chunk.bufferId):null},i.updateNode=function(t){this.layer=t.node.layer,this.nodeDirty=!1,this.hashDirty=!0},i.updatePass=function(t){this.material=t.getRenderMaterial(0),this.passDirty=!1,this.hashDirty=!0},i.updateTexture=function(t){this.frame=t,this.textureHash=t.getHash(),this.textureDirty=!1,this.hashDirty=!0},i.updateHash=function(){var t=""+(this.chunk?this.chunk.bufferId:-1)+this.layer+" "+this.textureHash;this.dataHash=nn(t,666),this.hashDirty=!1},i.updateRenderData=function(t,e){if(this.passDirty&&(this.material=t.getRenderMaterial(0),this.passDirty=!1,this.hashDirty=!0,this._renderDrawInfo&&this._renderDrawInfo.setMaterial(this.material)),this.nodeDirty){var i=t.node.scene?t._getRenderScene():null;this.layer=t.node.layer,null!==i&&(this.nodeDirty=!1),this.hashDirty=!0}this.textureDirty&&(this.frame=e,this.textureHash=e.getHash(),this.textureDirty=!1,this.hashDirty=!0,this._renderDrawInfo&&(this._renderDrawInfo.setTexture(this.frame?this.frame.getGFXTexture():null),this._renderDrawInfo.setSampler(this.frame?this.frame.getGFXSampler():null))),this.hashDirty&&(this.updateHash(),this._renderDrawInfo&&this._renderDrawInfo.setDataHash(this.dataHash))},i.updateSizeNPivot=function(t,e,i,n){t===this._width&&e===this._height&&i===this._pivotX&&n===this._pivotY||(this._width=t,this._height=e,this._pivotX=i,this._pivotY=n,this.vertDirty=!0)},i.clear=function(){this.resize(0,0),this._data.length=0,this._pivotX=0,this._pivotY=0,this._width=0,this._height=0,this.indices=null,this.vertDirty=!0,this.material=null,this.nodeDirty=!0,this.passDirty=!0,this.textureDirty=!0,this.hashDirty=!0,this.layer=0,this.frame=null,this.textureHash=0,this.dataHash=0},e.createStaticVBAccessor=function(t,e,i){var n=Di.root.device;return new Kh(n,t,e,i)},Pi(e,[{key:"dataLength",get:function(){return this._data.length},set:function(t){var e=this._data;if(e.length!==t){var i=e.length,n=0;for(n=t;n<i;n++)yl.free(e[n]);for(n=i;n<t;n++)e[n]=yl.alloc();e.length=t}this.syncRender2dBuffer()}},{key:"data",get:function(){return this._data}},{key:"vertDirty",get:function(){return this._vertDirty},set:function(t){this._vertDirty=t,this._renderDrawInfo&&t&&this._renderDrawInfo.setVertDirty(t)}},{key:"textureHash",get:function(){return this._textureHash},set:function(t){this._textureHash=t}},{key:"frame",get:function(){return this._frame},set:function(t){this._frame=t,this._renderDrawInfo&&(this._frame?(this._renderDrawInfo.setTexture(this._frame.getGFXTexture()),this._renderDrawInfo.setSampler(this._frame.getGFXSampler())):(this._renderDrawInfo.setTexture(null),this._renderDrawInfo.setSampler(null)))}},{key:"accessor",get:function(){return this._accessor}}]),e}(Tl)),El=t("MeshRenderData",function(t){function e(e){var i;return void 0===e&&(e=Oh),(i=t.call(this,e)||this)._isMeshBuffer=!0,i.vData=void 0,i.iData=void 0,i.vertexStart=0,i.vertexRange=0,i.indexStart=0,i.indexRange=0,i.lastFilledIndex=0,i.lastFilledVertex=0,i.frame=void 0,i._byteLength=0,i._vertexBuffers=[],i._indexBuffer=null,i._iaPool=null,i._iaInfo=null,i.vData=new Float32Array(256*i.stride),i.iData=new Uint16Array(1536),i}He(e,t),e.add=function(t){void 0===t&&(t=Oh);var i=new e;return i._floatStride=t===Oh?vl:Uh(t)>>2,i._vertexFormat=t,i},e.remove=function(t){t.clear()};var n=e.prototype;return n.request=function(t,e){var i=this._byteLength+t*this.stride;return!!this.reserve(t,e)&&(this._vc+=t,this._ic+=e,this._byteLength=i,this.vertexRange=this._vc,this.indexRange=this._ic,!0)},n.reserve=function(t,e){var i=this._byteLength+t*this.stride,n=this.indexCount+e;if(t+this.vertexCount>65535)return!1;var r=this.vData.byteLength,s=this.iData.length,a=this.vData.length,o=this.iData.length;if(i>r||n>s){for(;r<i||s<n;)r=4*(a*=2),s=o*=2;this._reallocBuffer(a,o)}return!0},n.resize=function(t,e){var i=t*this.stride;Ni(t>=0&&e>=0&&i<=this.vData.byteLength&&e<=this.iData.length),this._vc=t,this._ic=e,this._byteLength=i,this.updateRange(0,t,0,e)},n.updateRange=function(t,e,i,n){Ni(e>=0&&n>=0&&e<=this._vc&&n<=this._ic),this.vertexStart=t,this.indexStart=i,this.vertexRange=e,this.indexRange=n},n.requestIA=function(t){this._initIAInfo(t);var e=this._iaPool.add();return e.firstIndex=this.indexStart,e.indexCount=this.indexRange,e},n.uploadBuffers=function(){if(0!==this._byteLength&&this._vertexBuffers[0]&&this._indexBuffer){var t=this._ic,e=new Float32Array(this.vData.buffer,0,this._byteLength>>2),i=new Uint16Array(this.iData.buffer,0,t),n=this._vertexBuffers[0];this._byteLength>n.size&&n.resize(this._byteLength),n.update(e);var r=t<<1;r>this._indexBuffer.size&&this._indexBuffer.resize(r),this._indexBuffer.update(i)}},n.freeIAPool=function(){this._iaPool&&this._iaPool.reset()},n.reset=function(){this._vc=0,this._ic=0,this._byteLength=0,this.vertexStart=0,this.vertexRange=0,this.indexStart=0,this.indexRange=0,this.lastFilledIndex=0,this.lastFilledVertex=0,this.material=null,this.freeIAPool()},n.clear=function(){this.reset(),this._iaPool&&this._iaPool.destroy(),this._vertexBuffers[0]&&(this._vertexBuffers[0].destroy(),this._vertexBuffers=[]),this._iaInfo=null,this.vData=new Float32Array(256*this.stride),this.iData=new Uint16Array(1536)},n._initIAInfo=function(t){var e=this;if(!this._iaInfo){var n=this.stride,r=this._vertexBuffers;r.length||r.push(t.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.DEVICE,n,n)));var s=Uint16Array.BYTES_PER_ELEMENT;this._indexBuffer||(this._indexBuffer=t.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.DEVICE,s,s))),this._iaInfo=new Dt(this._vertexFormat,r,this._indexBuffer),this._iaPool=new i((function(){return t.createInputAssembler(e._iaInfo)}),1,(function(t){t.destroy()}))}},n._reallocBuffer=function(t,e){var i=this.vData;this.vData=new Float32Array(t),i&&this.vData.set(i,0);var n=this.iData;this.iData=new Uint16Array(e),n&&this.iData.set(n,0)},n.setRenderDrawInfoAttributes=function(){},n.particleInitRenderDrawInfo=function(){},Pi(e,[{key:"formatByte",get:function(){return this.stride},set:function(){}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vDataOffset",get:function(){return this._byteLength>>>2}}]),e}(Tl)),Al=(new i((function(){return new El}),32),new cn),Cl=new cn,Rl=new ji,bl=new Ue,xl=new Ue,wl=new Ue,Ml=new Ue(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),Il=new un,Bl=(ul=Ki("cc.UITransform")(rl=In(110)(rl=bn((ll=hl=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._priority=0,e._contentSize=al&&al(),e._anchorPoint=ol&&ol(),e}He(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiTransformComp=this},i.onLoad=function(){this.node.parent&&e.insertChangeMap(this.node.parent)},i.onEnable=function(){this.node.on(xn.PARENT_CHANGED,this._parentChanged,this),this._markRenderDataDirty()},i.onDisable=function(){this.node.off(xn.PARENT_CHANGED,this._parentChanged,this)},i.onDestroy=function(){this.node._uiProps.uiTransformComp=null},i.setContentSize=function(t,e){var i=this._contentSize;if(void 0===e){if(wn((t=t).width,i.width,Mn)&&wn(t.height,i.height,Mn))return;i.width=t.width,i.height=t.height}else{if(wn(t=t,i.width,Mn)&&wn(e,i.height,Mn))return;i.width=t,i.height=e}this.node.emit(xn.SIZE_CHANGED),this._markRenderDataDirty()},i.setAnchorPoint=function(t,e){var i=this._anchorPoint;if(void 0===e){if((t=t).x===i.x&&t.y===i.y)return;i.x=t.x,i.y=t.y}else{if(t===i.x&&e===i.y)return;i.x=t,i.y=e}this.node.emit(xn.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty()},i.isHit=function(t){for(var e=this._contentSize.width,i=this._contentSize.height,n=Al,r=Cl,s=this._getRenderScene().cameras,a=0;a<s.length;a++){var o=s[a];if(o.visibility&this.node.layer){o.node.getWorldRT(bl);var h=bl.m12,l=bl.m13,u=Bn.center;if(bl.m12=u.x-(bl.m00*h+bl.m04*l),bl.m13=u.y-(bl.m01*h+bl.m05*l),Ue.invert(bl,bl),cn.transformMat4(n,t,bl),this.node.getWorldMatrix(wl),Ue.invert(bl,wl),!Ue.strictEquals(bl,Ml)){cn.transformMat4(r,n,bl),r.x+=this._anchorPoint.x*e,r.y+=this._anchorPoint.y*i;var c=!1;if(r.x>=0&&r.y>=0&&r.x<=e&&r.y<=i&&(c=this._maskTest(n)),c)return!0}}}return!1},i.hitTest=function(t,e){void 0===e&&(e=0);for(var i=this._contentSize.width,n=this._contentSize.height,r=Rl,s=Al,a=Cl,o=this._getRenderScene().cameras,h=0;h<o.length;h++){var l=o[h];if(l.visibility&this.node.layer&&(!l.window||l.window.swapchain)&&l.systemWindowId===e&&(ji.set(r,t.x,t.y,0),l.screenToWorld(r,r),cn.set(s,r.x,r.y),this.node.getWorldMatrix(wl),Ue.invert(bl,wl),!Ue.strictEquals(bl,Ml))){cn.transformMat4(a,s,bl),a.x+=this._anchorPoint.x*i,a.y+=this._anchorPoint.y*n;var u=!1;if(a.x>=0&&a.y>=0&&a.x<=i&&a.y<=n&&(u=this._maskTest(s)),u)return!0}}return!1},i._maskTest=function(t){var e,i,n=null===(e=this.node)||void 0===e||null===(i=e.eventProcessor)||void 0===i?void 0:i.maskList;if(n)for(var r=this.node,s=n.length,a=0,o=0;r&&o<s;++a,r=r.parent){var h=n[o];if(a===h.index){if(r!==h.comp.node){n.length=o;break}var l=h.comp;if(l&&l._enabled&&!l.isHit(t))return!1;o++}else if(a>h.index){n.length=o;break}}return!0},i.convertToNodeSpaceAR=function(t,e){return this.node.getWorldMatrix(wl),Ue.invert(bl,wl),e||(e=new ji),ji.transformMat4(e,t,bl)},i.convertToWorldSpaceAR=function(t,e){return this.node.getWorldMatrix(wl),e||(e=new ji),ji.transformMat4(e,t,wl)},i.getBoundingBox=function(){Ue.fromRTS(xl,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var t=this._contentSize.width,e=this._contentSize.height,i=new un(-this._anchorPoint.x*t,-this._anchorPoint.y*e,t,e);return i.transformMat4(xl),i},i.getBoundingBoxToWorld=function(){if(this.node.parent){var t=this.node.parent.getWorldMatrix();return this.getBoundingBoxTo(t)}return this.getBoundingBox()},i.getBoundingBoxTo=function(t){Ue.fromRTS(xl,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var i=this._contentSize.width,n=this._contentSize.height,r=new un(-this._anchorPoint.x*i,-this._anchorPoint.y*n,i,n);if(Ue.multiply(wl,t,xl),r.transformMat4(wl),!this.node.children||0===this.node.children.length)return r;for(var s,a=this.node.children,o=Fi(a);!(s=o()).done;){var h=s.value;if(h&&h.active){var l=h.getComponent(e);if(l){var u=l.getBoundingBoxTo(t);u&&un.union(r,r,u)}}}return r},i.getComputeAABB=function(t){var e=this._contentSize.width,i=this._contentSize.height;Il.set(-this._anchorPoint.x*e,-this._anchorPoint.y*i,e,i),Il.transformMat4(this.node.worldMatrix);var n=Il.x+.5*Il.width,r=Il.y+.5*Il.height,s=this.node.worldPosition.z,a=Il.width/2,o=Il.height/2;return null!=t?(Qi.set(t,n,r,s,a,o,.001),t):new Qi(n,r,s,a,o,.001)},i._parentChanged=function(){this.node.getComponent("cc.RenderRoot2D")||this.node.parent&&e.insertChangeMap(this.node.parent)},i._markRenderDataDirty=function(){var t=this.node._uiProps.uiComp;t&&t.markForUpdateRenderData()},e.insertChangeMap=function(t){var i=t.uuid;e.priorityChangeNodeMap.has(i)||e.priorityChangeNodeMap.set(i,t)},e._sortChildrenSibling=function(t){var e=t.children;e&&e.sort((function(t,e){var i=t._uiProps.uiTransformComp,n=e._uiProps.uiTransformComp,r=(i?i._priority:0)-(n?n._priority:0);return 0===r?t.getSiblingIndex()-e.getSiblingIndex():r}))},e._sortSiblings=function(){e.priorityChangeNodeMap.forEach((function(t){e._sortChildrenSibling(t),t._updateSiblingIndex(),t.emit("childrenSiblingOrderChanged")})),e.priorityChangeNodeMap.clear()},e._cleanChangeMap=function(){e.priorityChangeNodeMap.clear()},Pi(e,[{key:"contentSize",get:function(){return this._contentSize},set:function(t){this._contentSize.equals(t)||(this._contentSize.set(t),this.node.emit(xn.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"width",get:function(){return this._contentSize.width},set:function(t){this._contentSize.width!==t&&(this._contentSize.width=t,this.node.emit(xn.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"height",get:function(){return this._contentSize.height},set:function(t){this.contentSize.height!==t&&(this._contentSize.height=t,this.node.emit(xn.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"anchorPoint",get:function(){return this._anchorPoint},set:function(t){this._anchorPoint.equals(t)||(this._anchorPoint.set(t),this.node.emit(xn.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"anchorX",get:function(){return this._anchorPoint.x},set:function(t){this._anchorPoint.x!==t&&(this._anchorPoint.x=t,this.node.emit(xn.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"anchorY",get:function(){return this._anchorPoint.y},set:function(t){this._anchorPoint.y!==t&&(this._anchorPoint.y=t,this.node.emit(xn.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority!==t&&(this.node.getComponent("cc.RenderRoot2D")?Zi(6706):(this._priority=t,this.node.parent&&e.insertChangeMap(this.node.parent)))}},{key:"visibility",get:function(){var t=Di.root.batcher2D.getFirstRenderCamera(this.node);return t?t.visibility:0}},{key:"cameraPriority",get:function(){var t=Di.root.batcher2D.getFirstRenderCamera(this.node);return t?t.priority:0}}]),e}(Pn),hl.EventType=xn,hl.priorityChangeNodeMap=new Map,al=tn((sl=ll).prototype,"_contentSize",[en],(function(){return new dn(100,100)})),ol=tn(sl.prototype,"_anchorPoint",[en],(function(){return new cn(.5,.5)})),rl=sl))||rl)||rl)||rl,t({UITransform:ul,UITransformComponent:ul}),ul);Di.on(An.EVENT_AFTER_UPDATE,Bl._sortSiblings),Di.on(An.EVENT_BEFORE_SCENE_LAUNCH,Bl._cleanChangeMap);var Pl,Dl,Ol,Fl,Ll,Nl,kl,Ul,Gl,Vl,Hl,zl,Xl,Wl,Yl={parent:null,owner:null,subModelIdx:0},jl=bn,Kl=Tn,ql=t("Renderer",(cl=Ki("cc.Renderer"),dl=Kl(Dn),_l=Kl([Dn]),cl(fl=jl((pl=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._materials=gl&&gl(),e._materialInstances=[],e}He(e,t);var i=e.prototype;return i.getMaterial=function(t){return t<0||t>=this._materials.length?null:this._materials[t]},i.setMaterial=function(t,e){t&&t instanceof On&&console.error("Can't set a material instance to a sharedMaterial slot"),this._materials[e]=t;var i=this._materialInstances[e];i&&(i.destroy(),this._materialInstances[e]=null),this._onMaterialModified(e,this._materials[e])},i.getMaterialInstance=function(t){if(!this._materials[t])return null;if(!this._materialInstances[t]){Yl.parent=this._materials[t],Yl.owner=this,Yl.subModelIdx=t;var e=new On(Yl);Yl.parent=null,Yl.owner=null,Yl.subModelIdx=0,this.setMaterialInstance(e,t)}return this._materialInstances[t]},i.setMaterialInstance=function(t,e){if("number"==typeof t){Zi(12007);var i=t;t=e,e=i}var n=this._materialInstances[e];t&&t.parent?t!==n&&(this._materialInstances[e]=t,this._onMaterialModified(e,t)):(t!==this._materials[e]||n)&&this.setMaterial(t,e)},i.getRenderMaterial=function(t){return this._materialInstances[t]||this._materials[t]},i._onMaterialModified=function(){},i._onRebuildPSO=function(){},i._clearMaterials=function(){},Pi(e,[{key:"sharedMaterial",get:function(){return this.getMaterial(0)}},{key:"sharedMaterials",get:function(){return this._materials},set:function(t){for(var e=0;e<t.length;e++)t[e]!==this._materials[e]&&this.setMaterial(t[e],e);if(t.length<this._materials.length){for(var i=t.length;i<this._materials.length;i++)this.setMaterial(null,i);this._materials.splice(t.length)}}},{key:"material",get:function(){return this.getMaterialInstance(0)},set:function(t){(1!==this._materials.length||this._materialInstances[0]||this._materials[0]!==t)&&this.setMaterialInstance(t,0)}},{key:"materials",get:function(){for(var t=0;t<this._materials.length;t++)this._materialInstances[t]=this.getMaterialInstance(t);return this._materialInstances},set:function(t){for(var e=t.length,i=this._materials.length,n=e;n<i;n++)this.setMaterialInstance(null,n);this._materials.length=e,this._materialInstances.length=e;for(var r=0;r<e;r++)this._materialInstances[r]!=t[r]&&this.setMaterialInstance(t[r],r)}}]),e}(Pn),gn(pl.prototype,"sharedMaterials",[dl],Object.getOwnPropertyDescriptor(pl.prototype,"sharedMaterials"),pl.prototype),gl=tn(pl.prototype,"_materials",[_l],(function(){return[]})),fl=pl))||fl)||fl));Fn(I),function(t){t[t.ADD_COLOR=0]="ADD_COLOR",t[t.ADD_COLOR_AND_TEXTURE=1]="ADD_COLOR_AND_TEXTURE",t[t.GRAYSCALE=2]="GRAYSCALE",t[t.USE_ALPHA_SEPARATED=3]="USE_ALPHA_SEPARATED",t[t.USE_ALPHA_SEPARATED_AND_GRAY=4]="USE_ALPHA_SEPARATED_AND_GRAY"}(Wl||(Wl=t("InstanceMaterialType",{})));var Zl,Ql,Jl,$l,tu,eu,iu,nu,ru,su,au,ou,hu,lu,uu,cu,du,_u,fu,pu,gu,mu,vu,yu,Tu,Su,Eu,Au,Cu,Ru,bu,xu,wu=function(e){return t({UIRenderer:e,RenderComponent:e,UIRenderable:e,Renderable2D:e}),e}((Pl=Ki("cc.UIRenderer"),Dl=kn(Bl),Ol=Tn(Dn),Fl=Tn(Dn),Pl(Ll=Dl((Xl=zl=function(t){function e(){var e;return(e=t.call(this)||this)._renderData=null,e._materials=kl&&kl(),e._customMaterial=Ul&&Ul(),e._srcBlendFactor=Gl&&Gl(),e._dstBlendFactor=Vl&&Vl(),e._color=Hl&&Hl(),e._stencilStage=qh.DISABLED,e._assembler=null,e._postAssembler=null,e._renderDataFlag=!0,e._renderFlag=!0,e._renderEntity=void 0,e._instanceMaterialType=-1,e._srcBlendFactorCache=I.SRC_ALPHA,e._dstBlendFactorCache=I.ONE_MINUS_SRC_ALPHA,e._dirtyVersion=-1,e._internalId=-1,e._useVertexOpacity=!1,e._lastParent=null,e._renderEntity=e.createRenderEntity(),e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._renderEntity.setNode(this.node)},i.__preload=function(){this.node._uiProps.uiComp=this,this._flushAssembler&&this._flushAssembler()},i.onEnable=function(){this.node.on(xn.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.on(xn.SIZE_CHANGED,this._nodeStateChange,this),this.node.on(xn.PARENT_CHANGED,this._colorDirty,this),this.updateMaterial(),this._colorDirty(),Ln.addRenderer(this),this.markForUpdateRenderData()},i.onRestore=function(){this.updateMaterial(),this.markForUpdateRenderData()},i.onDisable=function(){this.node.off(xn.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.off(xn.SIZE_CHANGED,this._nodeStateChange,this),this.node.off(xn.PARENT_CHANGED,this._colorDirty,this),Ln.removeRenderer(this),this._renderFlag=!1,this._renderEntity.enabled=!1},i.onDestroy=function(){if(this._renderEntity.setNode(null),this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this.destroyRenderData(),this._materialInstances)for(var t=0;t<this._materialInstances.length;t++){var e=this._materialInstances[t];e&&e.destroy()}},i.markForUpdateRenderData=function(t){if(void 0===t&&(t=!0),t){var e=this.renderData;e&&(e.vertDirty=!0),Ln.markDirtyRenderer(this)}},i.requestRenderData=function(t){void 0===t&&(t=zh.COMP);var e=Sl.add();return e.initRenderDrawInfo(this,t),this._renderData=e,e},i.destroyRenderData=function(){this.renderData&&(this.renderData.removeRenderDrawInfo(this),Sl.remove(this.renderData),this._renderData=null)},i.updateRenderer=function(){this._assembler&&this._assembler.updateRenderData(this),this._renderFlag=this._canRender(),this._renderEntity.enabled=this._renderFlag},i.fillBuffers=function(t){this._renderFlag&&this._render(t)},i.postUpdateAssembler=function(t){this._postAssembler&&this._renderFlag&&this._postRender(t)},i._render=function(){},i._postRender=function(){},i._canRender=function(){return null!==this.getMaterial(0)&&this._enabled&&this._color.a>0},i._postCanRender=function(){},i.updateMaterial=function(){if(this._customMaterial)this.getMaterial(0)!==this._customMaterial&&this.setMaterial(this._customMaterial,0);else{var t=this._updateBuiltinMaterial();this.setMaterial(t,0),this.stencilStage!==qh.ENTER_LEVEL&&this.stencilStage!==qh.ENTER_LEVEL_INVERTED||this.getMaterialInstance(0).recompileShaders({USE_ALPHA_TEST:!0}),this._updateBlendFunc()}},i._updateColor=function(){this.node._uiProps.colorDirty=!0,this.setEntityColorDirty(!0),this.setEntityColor(this._color),this.setEntityOpacity(this.node._uiProps.localOpacity),this._assembler&&(this._assembler.updateColor(this),this._renderFlag=this._canRender(),this.setEntityEnabled(this._renderFlag))},e.setEntityColorDirtyRecursively=function(t,i){var n=t._uiProps.uiComp;n&&n.color&&(n._renderEntity.colorDirty=i);for(var r=0;r<t.children.length;r++)e.setEntityColorDirtyRecursively(t.children[r],i)},i.setEntityColorDirty=function(){},i.setEntityColor=function(){},i.setEntityOpacity=function(){},i.setEntityEnabled=function(){},i._updateBlendFunc=function(){var t=this.getRenderMaterial(0).passes[0].blendState.targets[0];if(this._dstBlendFactorCache=t.blendDst,this._srcBlendFactorCache=t.blendSrc,this._dstBlendFactorCache!==this._dstBlendFactor||this._srcBlendFactorCache!==this._srcBlendFactor){(t=this.getMaterialInstance(0).passes[0].blendState.targets[0]).blend=!0,t.blendDstAlpha=I.ONE_MINUS_SRC_ALPHA,t.blendDst=this._dstBlendFactor,t.blendSrc=this._srcBlendFactor;var e=this.getMaterialInstance(0).passes[0];e.blendState.setTarget(0,t),e._updatePassHash(),this._dstBlendFactorCache=this._dstBlendFactor,this._srcBlendFactorCache=this._srcBlendFactor}},i._nodeStateChange=function(){this.renderData&&this.markForUpdateRenderData();for(var t=0;t<this.node.children.length;++t){var i=this.node.children[t].getComponent(e);i&&i.markForUpdateRenderData()}},i._colorDirty=function(){this.node._uiProps.colorDirty=!0,this.setEntityColorDirty(!0)},i._onMaterialModified=function(e,i){this.renderData&&(this.markForUpdateRenderData(),this.renderData.passDirty=!0),t.prototype._onMaterialModified.call(this,e,i)},i._updateBuiltinMaterial=function(){var t;switch(this._instanceMaterialType){case Wl.ADD_COLOR:t=Nn.get("ui-base-material");break;case Wl.GRAYSCALE:t=Nn.get("ui-sprite-gray-material");break;case Wl.USE_ALPHA_SEPARATED:t=Nn.get("ui-sprite-alpha-sep-material");break;case Wl.USE_ALPHA_SEPARATED_AND_GRAY:t=Nn.get("ui-sprite-gray-alpha-sep-material");break;default:t=Nn.get("ui-sprite-material")}return t},i.setNodeDirty=function(){this.renderData&&(this.renderData.nodeDirty=!0)},i.setTextureDirty=function(){this.renderData&&(this.renderData.textureDirty=!0)},i.createRenderEntity=function(){return new ml(Jh.STATIC)},Pi(e,[{key:"sharedMaterials",get:function(){return this._materials},set:function(t){for(var e=0;e<t.length;e++)t[e]!==this._materials[e]&&this.setMaterial(t[e],e);if(t.length<this._materials.length){for(var i=t.length;i<this._materials.length;i++)this.setMaterial(null,i);this._materials.splice(t.length)}}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this.updateMaterial()}},{key:"color",get:function(){return this._color},set:function(t){this._color.equals(t)||(this._color.set(t),this._updateColor())}},{key:"renderData",get:function(){return this._renderData}},{key:"useVertexOpacity",get:function(){return this._useVertexOpacity}},{key:"stencilStage",get:function(){return this._stencilStage},set:function(t){this._stencilStage=t,this._renderEntity.setStencilStage(t)}},{key:"batcher",get:function(){return Di.root.batcher2D}},{key:"renderEntity",get:function(){return this._renderEntity}}]),e}(ql),zl.BlendState=I,zl.Assembler=null,zl.PostAssembler=null,gn((Nl=Xl).prototype,"sharedMaterials",[mn],Object.getOwnPropertyDescriptor(Nl.prototype,"sharedMaterials"),Nl.prototype),gn(Nl.prototype,"customMaterial",[Ol],Object.getOwnPropertyDescriptor(Nl.prototype,"customMaterial"),Nl.prototype),kl=tn(Nl.prototype,"_materials",[mn],(function(){return[]})),Ul=tn(Nl.prototype,"_customMaterial",[Fl],(function(){return null})),Gl=tn(Nl.prototype,"_srcBlendFactor",[en],(function(){return I.SRC_ALPHA})),Vl=tn(Nl.prototype,"_dstBlendFactor",[en],(function(){return I.ONE_MINUS_SRC_ALPHA})),Hl=tn(Nl.prototype,"_color",[en],(function(){return Ve.WHITE.clone()})),Ll=Nl))||Ll)||Ll));We.internal.UIRenderer=wu,Ve.WHITE.clone(),function(t){t[t.LEFT=0]="LEFT",t[t.CENTER=1]="CENTER",t[t.RIGHT=2]="RIGHT"}(Cu||(Cu=t("HorizontalTextAlignment",{}))),Fn(Cu),function(t){t[t.TOP=0]="TOP",t[t.CENTER=1]="CENTER",t[t.BOTTOM=2]="BOTTOM"}(Ru||(Ru=t("VerticalTextAlignment",{}))),Fn(Ru),function(t){t[t.NONE=0]="NONE",t[t.CLAMP=1]="CLAMP",t[t.SHRINK=2]="SHRINK",t[t.RESIZE_HEIGHT=3]="RESIZE_HEIGHT"}(bu||(bu=t("Overflow",{}))),Fn(bu),function(t){t[t.NONE=0]="NONE",t[t.BITMAP=1]="BITMAP",t[t.CHAR=2]="CHAR"}(xu||(xu=t("CacheMode",{}))),Fn(xu);var Mu=function(e){return t({Label:e,LabelComponent:e}),e}((Zl=Ki("cc.Label"),Ql=In(110),Jl=Tn(Cu),$l=Tn(Ru),tu=Tn(bu),eu=Tn(Wo),iu=Tn(xu),Zl(nu=Ql((Au=Eu=function(t){function e(){var e;return(e=t.call(this)||this)._string=su&&su(),e._horizontalAlign=au&&au(),e._verticalAlign=ou&&ou(),e._actualFontSize=hu&&hu(),e._fontSize=lu&&lu(),e._fontFamily=uu&&uu(),e._lineHeight=cu&&cu(),e._overflow=du&&du(),e._enableWrapText=_u&&_u(),e._font=fu&&fu(),e._isSystemFontUsed=pu&&pu(),e._spacingX=gu&&gu(),e._isItalic=mu&&mu(),e._isBold=vu&&vu(),e._isUnderline=yu&&yu(),e._underlineHeight=Tu&&Tu(),e._cacheMode=Su&&Su(),e._N$file=null,e._texture=null,e._ttfSpriteFrame=null,e._userDefinedFont=null,e._assemblerData=null,e._fontAtlas=null,e._letterTexture=null,e._contentWidth=0,e._ttfSpriteFrame=null,e}He(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this._font||this._isSystemFontUsed||(this.useSystemFont=!0),this._isSystemFontUsed&&!this._fontFamily&&(this.fontFamily="Arial"),this._applyFontTexture()},i.onDestroy=function(){if(this._assembler&&this._assembler.resetAssemblerData&&this._assembler.resetAssemblerData(this._assemblerData),this._assemblerData=null,this._ttfSpriteFrame){this._ttfSpriteFrame._resetDynamicAtlasFrame();var e=this._ttfSpriteFrame.texture;if(this._ttfSpriteFrame.destroy(),e){var i=e;i.image&&i.image.destroy(),e.destroy()}this._ttfSpriteFrame=null}this._letterTexture=null,t.prototype.onDestroy.call(this)},i.updateRenderData=function(t){void 0===t&&(t=!1),t&&(this._flushAssembler(),this.renderData&&(this.renderData.vertDirty=!0),this._applyFontTexture()),this._assembler&&this._assembler.updateRenderData(this)},i._render=function(t){t.commitComp(this,this.renderData,this._texture,this._assembler,null)},i._updateColor=function(){t.prototype._updateColor.call(this),this.markForUpdateRenderData()},i.setEntityColor=function(){},i._canRender=function(){if(!t.prototype._canRender.call(this)||!this._string)return!1;var e=this._font;if(e&&e instanceof rh){var i=e.spriteFrame;if(!i||!i.texture)return!1}return!0},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this.destroyRenderData(),this._assembler=t),this.renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this.renderData.material=this.material,this._updateColor())},i._applyFontTexture=function(){this.markForUpdateRenderData();var t=this._font;if(t instanceof rh){var e=t.spriteFrame;e&&e.texture&&(this._texture=e,this.renderData&&(this.renderData.textureDirty=!0),this.changeMaterialForDefine(),this._assembler&&this._assembler.updateRenderData(this))}else{if(this.cacheMode===xu.CHAR)this._letterTexture=this._assembler.getAssemblerData(),this._texture=this._letterTexture;else if(!this._ttfSpriteFrame){this._ttfSpriteFrame=new Uo,this._assemblerData=this._assembler.getAssemblerData();var i=new Ui(this._assemblerData.canvas),n=new Xe;n.image=i,this._ttfSpriteFrame.texture=n}this.cacheMode!==xu.CHAR&&(this._texture=this._ttfSpriteFrame),this.changeMaterialForDefine()}},i.changeMaterialForDefine=function(){if(this._texture){var t=!1;if(this.cacheMode!==xu.CHAR){var e=this._texture.texture;if(e instanceof Un){var i=e.getPixelFormat();t=i===ze.RGBA_ETC1||i===ze.RGB_A_PVRTC_4BPPV1||i===ze.RGB_A_PVRTC_2BPPV1}}this._instanceMaterialType=t?Wl.USE_ALPHA_SEPARATED:Wl.ADD_COLOR_AND_TEXTURE,this.updateMaterial()}},i._updateBlendFunc=function(){t.prototype._updateBlendFunc.call(this)},Pi(e,[{key:"string",get:function(){return this._string},set:function(t){t=null==t?"":t.toString(),this._string!==t&&(this._string=t,this.markForUpdateRenderData())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(t){this._horizontalAlign!==t&&(this._horizontalAlign=t,this.markForUpdateRenderData())}},{key:"verticalAlign",get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!==t&&(this._verticalAlign=t,this.markForUpdateRenderData())}},{key:"actualFontSize",get:function(){return this._actualFontSize},set:function(t){this._actualFontSize=t}},{key:"fontSize",get:function(){return this._fontSize},set:function(t){this._fontSize!==t&&(this._fontSize=t,this.markForUpdateRenderData())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this.markForUpdateRenderData())}},{key:"spacingX",get:function(){return this._spacingX},set:function(t){this._spacingX!==t&&(this._spacingX=t,this.markForUpdateRenderData())}},{key:"overflow",get:function(){return this._overflow},set:function(t){this._overflow!==t&&(this._overflow=t,this.markForUpdateRenderData())}},{key:"enableWrapText",get:function(){return this._enableWrapText},set:function(t){this._enableWrapText!==t&&(this._enableWrapText=t,this.markForUpdateRenderData())}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this.destroyRenderData(),this._isSystemFontUsed=!!t,t&&(this.font=null),this._flushAssembler(),this.markForUpdateRenderData())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this.markForUpdateRenderData())}},{key:"font",get:function(){return this._font},set:function(t){this._font!==t&&(this._isSystemFontUsed=!t,this._font=t,this.destroyRenderData(),this._fontAtlas=null,this.updateRenderData(!0))}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode!==t&&(this._cacheMode!==xu.BITMAP||this._font instanceof rh||!this._ttfSpriteFrame||this._ttfSpriteFrame._resetDynamicAtlasFrame(),this._cacheMode===xu.CHAR&&(this._ttfSpriteFrame=null),this._cacheMode=t,this.updateRenderData(!0))}},{key:"isBold",get:function(){return this._isBold},set:function(t){this._isBold!==t&&(this._isBold=t,this.markForUpdateRenderData())}},{key:"isItalic",get:function(){return this._isItalic},set:function(t){this._isItalic!==t&&(this._isItalic=t,this.markForUpdateRenderData())}},{key:"isUnderline",get:function(){return this._isUnderline},set:function(t){this._isUnderline!==t&&(this._isUnderline=t,this.markForUpdateRenderData())}},{key:"underlineHeight",get:function(){return this._underlineHeight},set:function(t){this._underlineHeight!==t&&(this._underlineHeight=t,this.markForUpdateRenderData())}},{key:"spriteFrame",get:function(){return this._texture}},{key:"ttfSpriteFrame",get:function(){return this._ttfSpriteFrame}},{key:"assemblerData",get:function(){return this._assemblerData}},{key:"fontAtlas",get:function(){return this._fontAtlas},set:function(t){this._fontAtlas=t}},{key:"_bmFontOriginalSize",get:function(){return this._font instanceof rh?this._font.fontSize:-1}},{key:"contentWidth",get:function(){return this._contentWidth},set:function(t){this._contentWidth=t}}]),e}(wu),Eu.HorizontalAlign=Cu,Eu.VerticalAlign=Ru,Eu.Overflow=bu,Eu.CacheMode=xu,Eu._canvasPool=Ch.getInstance(),gn((ru=Au).prototype,"horizontalAlign",[Jl],Object.getOwnPropertyDescriptor(ru.prototype,"horizontalAlign"),ru.prototype),gn(ru.prototype,"verticalAlign",[$l],Object.getOwnPropertyDescriptor(ru.prototype,"verticalAlign"),ru.prototype),gn(ru.prototype,"overflow",[tu],Object.getOwnPropertyDescriptor(ru.prototype,"overflow"),ru.prototype),gn(ru.prototype,"font",[eu],Object.getOwnPropertyDescriptor(ru.prototype,"font"),ru.prototype),gn(ru.prototype,"cacheMode",[iu],Object.getOwnPropertyDescriptor(ru.prototype,"cacheMode"),ru.prototype),su=tn(ru.prototype,"_string",[en],(function(){return"label"})),au=tn(ru.prototype,"_horizontalAlign",[en],(function(){return Cu.CENTER})),ou=tn(ru.prototype,"_verticalAlign",[en],(function(){return Ru.CENTER})),hu=tn(ru.prototype,"_actualFontSize",[en],(function(){return 0})),lu=tn(ru.prototype,"_fontSize",[en],(function(){return 40})),uu=tn(ru.prototype,"_fontFamily",[en],(function(){return"Arial"})),cu=tn(ru.prototype,"_lineHeight",[en],(function(){return 40})),du=tn(ru.prototype,"_overflow",[en],(function(){return bu.NONE})),_u=tn(ru.prototype,"_enableWrapText",[en],(function(){return!0})),fu=tn(ru.prototype,"_font",[en],(function(){return null})),pu=tn(ru.prototype,"_isSystemFontUsed",[en],(function(){return!0})),gu=tn(ru.prototype,"_spacingX",[en],(function(){return 0})),mu=tn(ru.prototype,"_isItalic",[en],(function(){return!1})),vu=tn(ru.prototype,"_isBold",[en],(function(){return!1})),yu=tn(ru.prototype,"_isUnderline",[en],(function(){return!1})),Tu=tn(ru.prototype,"_underlineHeight",[en],(function(){return 2})),Su=tn(ru.prototype,"_cacheMode",[en],(function(){return xu.NONE})),nu=ru))||nu)||nu));We.Label=Mu;var Iu,Bu,Pu=0,Du={};function Ou(t){return--t,t|=t>>16,t|=t>>8,t|=t>>4,t|=t>>2,t|=t>>1,++t}function Fu(t,e){return Math.ceil(t/e)*e}!function(t){t[t.OPAQUE=0]="OPAQUE",t[t.TRANSPARENT=1]="TRANSPARENT",t[t.OVERLAY=2]="OVERLAY"}(Iu||(Iu={})),function(t){t[t.DEFAULT=1]="DEFAULT",t[t.FORWARD=2]="FORWARD",t[t.SHADOWCAST=4]="SHADOWCAST"}(Bu||(Bu={}));var Lu,Nu,ku,Uu,Gu,Vu,Hu,zu,Xu,Wu=function(){function t(t){this._device=void 0,this._format=_.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new ht,this._region1=new ht,this._region2=new ht,this._roundUpFn=null,this._bufferViewCtor=Uint8Array,this._channels=4,this._alignment=1,this._device=t}var e=t.prototype;return e.initialize=function(t){var e=ne[t.format];this._format=t.format,this._formatSize=e.size,this._channels=e.count,this._bufferViewCtor=de(e),this._roundUpFn=t.roundUpFn||null,this._alignment=t.alignment||1,t.inOrderFree&&(this.alloc=this._McDonaldAlloc)},e.destroy=function(){for(var t=0;t<this._chunkCount;++t)this._chunks[t].texture.destroy();this._chunks.length=0,this._handles.length=0},e.alloc=function(t,e){t=Fu(t,this._alignment);var i=-1,n=-1;if(void 0!==e&&(i=e,n=this._findAvailableSpace(t,i)),n<0)for(var r=0;r<this._chunkCount&&(i=r,!((n=this._findAvailableSpace(t,i))>=0));++r);if(n>=0){var s=this._chunks[i];s.start+=t;var a={chunkIdx:i,start:n,end:n+t,texture:s.texture};return this._handles.push(a),a}var o=Math.sqrt(t/this._formatSize),h=this._roundUpFn&&this._roundUpFn(o,this._formatSize)||Math.max(1024,Ou(o)),l=this._chunks[this.createChunk(h)];l.start+=t;var u={chunkIdx:this._chunkCount-1,start:0,end:t,texture:l.texture};return this._handles.push(u),u},e.free=function(t){for(var e=0;e<this._handles.length;++e)if(this._handles[e]===t)return this._chunks[t.chunkIdx].end=t.end,void this._handles.splice(e,1)},e.createChunk=function(t){var e=t*t*this._formatSize;Gn("TextureBufferPool: Allocate chunk "+this._chunkCount+", size: "+e+", format: "+this._format);var i={texture:this._device.createTexture(new yt(T.TEX2D,S.SAMPLED|S.TRANSFER_DST,this._format,t,t)),size:e,start:0,end:e};return this._chunks[this._chunkCount]=i,this._chunkCount++},e.update=function(t,e){var i=[],n=[],r=t.start/this._formatSize,s=e.byteLength/this._formatSize,a=r%t.texture.width,o=Math.floor(r/t.texture.width),h=Math.min(t.texture.width-a,s),l=0;a>0&&(this._region0.texOffset.x=a,this._region0.texOffset.y=o,this._region0.texExtent.width=h,this._region0.texExtent.height=1,i.push(new this._bufferViewCtor(e,l*this._formatSize,h*this._channels)),n.push(this._region0),a=0,o+=1,s-=h,l+=h),s>0&&(this._region1.texOffset.x=a,this._region1.texOffset.y=o,s>t.texture.width?(this._region1.texExtent.width=t.texture.width,this._region1.texExtent.height=Math.floor(s/t.texture.width),h=this._region1.texExtent.width*this._region1.texExtent.height):(h=s,this._region1.texExtent.width=h,this._region1.texExtent.height=1),i.push(new this._bufferViewCtor(e,l*this._formatSize,h*this._channels)),n.push(this._region1),a=0,o+=this._region1.texExtent.height,s-=h,l+=h),s>0&&(this._region2.texOffset.x=a,this._region2.texOffset.y=o,this._region2.texExtent.width=s,this._region2.texExtent.height=1,i.push(new this._bufferViewCtor(e,l*this._formatSize,s*this._channels)),n.push(this._region2)),this._device.copyBuffersToTexture(i,t.texture,n)},e._findAvailableSpace=function(t,e){var i=this._chunks[e],n=!1,r=i.start;if(r+t<=i.size)n=!0;else{r=0;for(var s=this._handles.filter((function(t){return t.chunkIdx===e})).sort((function(t,e){return t.start-e.start})),a=0;a<s.length;a++){var o=s[a];if(r+t<=o.start){n=!0;break}r=o.end}!n&&r+t<=i.size&&(n=!0)}return n?r:-1},e._McDonaldAlloc=function(t){t=Fu(t,this._alignment);for(var e=0;e<this._chunkCount;++e){var i=this._chunks[e],n=!1,r=i.start;if(r+t<=i.end?n=!0:r>i.end?r+t<=i.size?n=!0:t<=i.end&&(i.start=r=0,n=!0):r===i.end&&(i.start=r=0,i.end=i.size,t<=i.end&&(n=!0)),n){i.start+=t;var s={chunkIdx:e,start:r,end:r+t,texture:i.texture};return this._handles.push(s),s}}var a=Math.sqrt(t/this._formatSize),o=this._roundUpFn&&this._roundUpFn(a,this._formatSize)||Math.max(1024,Ou(a)),h=this._chunks[this.createChunk(o)];h.start+=t;var l={chunkIdx:this._chunkCount,start:0,end:t,texture:h.texture};return this._handles.push(l),l},t}(),Yu=function(){function t(t,e,i){this._arrayBuffers=[],this._chunkSize=void 0,this._chunkSize=i*(1<<e)}return t.prototype.allocateNewChunk=function(){return new ArrayBuffer(this._chunkSize)},t}();!function(t){t[t.UINT32=0]="UINT32",t[t.FLOAT32=1]="FLOAT32",t[t.NEVER=2]="NEVER"}(Xu||(Xu={}));var ju,Ku,qu=function(){function t(t,e,i,n,r){void 0===r&&(r=8),this._dataType=void 0,this._dataMembers=void 0,this._elementCount=void 0,this._entryBits=void 0,this._stride=void 0,this._entriesPerChunk=void 0,this._entryMask=void 0,this._chunkMask=void 0,this._poolFlag=void 0,this._arrayBuffers=[],this._freeLists=[],this._uint32BufferViews=[],this._float32BufferViews=[],this._hasUint32=!1,this._hasFloat32=!1,this._nativePool=void 0,this._elementCount=n.COUNT,this._entryBits=r,this._dataType=e,this._dataMembers=i,this._stride=4*this._elementCount,this._entriesPerChunk=1<<r,this._entryMask=this._entriesPerChunk-1,this._poolFlag=1<<30,this._chunkMask=~(this._entryMask|this._poolFlag),this._nativePool=new Yu(t,r,this._stride);var s=Xu.NEVER,a=!1,o=!1;for(var h in e){if(a=this._hasFloat32,(o=this._hasUint32)&&a)break;s=e[h],a||s!==Xu.FLOAT32?o||s!==Xu.UINT32||(this._hasUint32=!0):this._hasFloat32=!0}}var e=t.prototype;return e.alloc=function(){for(var t=0;t<this._freeLists.length;t++){var e=this._freeLists[t];if(e.length){var i=e[e.length-1];return e.length--,(t<<this._entryBits)+i+this._poolFlag}}for(var n=this._nativePool.allocateNewChunk(),r=[],s=[],a=[],o=this._hasFloat32,h=this._hasUint32,l=0;l<this._entriesPerChunk;l++)o&&r.push(new Float32Array(n,this._stride*l,this._elementCount)),h&&s.push(new Uint32Array(n,this._stride*l,this._elementCount)),l&&a.push(l);return h&&this._uint32BufferViews.push(s),o&&this._float32BufferViews.push(r),this._freeLists.push(a),this._arrayBuffers.push(n),(t<<this._entryBits)+this._poolFlag},e.getBuffer=function(t){var e=(this._chunkMask&t)>>this._entryBits,i=this._entryMask&t;return(this._hasFloat32?this._float32BufferViews:this._uint32BufferViews)[e][i]},e.getTypedArray=function(t,e){var i=(this._chunkMask&t)>>this._entryBits,n=this._entryMask&t,r=e,s=(this._dataType[e]===Xu.UINT32?this._uint32BufferViews:this._float32BufferViews)[i][n],a=this._dataMembers[e];return s.subarray(r,r+a)},e.free=function(t){var e=(this._chunkMask&t)>>this._entryBits,i=this._entryMask&t;(this._hasUint32?this._uint32BufferViews:this._float32BufferViews)[e][i].fill(0),this._freeLists[e].push(i)},t}();!function(t){t[t.NODE=0]="NODE",t[t.PASS=1]="PASS",t[t.AABB=2]="AABB",t[t.RENDER2D=3]="RENDER2D"}(ju||(ju={})),function(t){t[t.POSITION=0]="POSITION",t[t.UV=3]="UV",t[t.COLOR=5]="COLOR",t[t.COUNT=9]="COUNT"}(Ku||(Ku={}));var Zu,Qu=((Lu={})[Ku.POSITION]=Xu.FLOAT32,Lu[Ku.UV]=Xu.FLOAT32,Lu[Ku.COLOR]=Xu.UINT32,Lu[Ku.COUNT]=Xu.NEVER,Lu),Ju=((Nu={})[Ku.POSITION]=Ku.UV-Ku.POSITION,Nu[Ku.UV]=Ku.COLOR-Ku.UV,Nu[Ku.COLOR]=Ku.COUNT-Ku.COLOR,Nu[Ku.COUNT]=1,Nu),$u=new qu(ju.RENDER2D,Qu,Ju,Ku);!function(t){t[t.DIRTY_FLAG=0]="DIRTY_FLAG",t[t.LAYER=1]="LAYER",t[t.WORLD_SCALE=2]="WORLD_SCALE",t[t.WORLD_POSITION=5]="WORLD_POSITION",t[t.WORLD_ROTATION=8]="WORLD_ROTATION",t[t.WORLD_MATRIX=12]="WORLD_MATRIX",t[t.LOCAL_SCALE=28]="LOCAL_SCALE",t[t.LOCAL_POSITION=31]="LOCAL_POSITION",t[t.LOCAL_ROTATION=34]="LOCAL_ROTATION",t[t.COUNT=38]="COUNT"}(Zu||(Zu={}));var tc,ec=((ku={})[Zu.DIRTY_FLAG]=Xu.UINT32,ku[Zu.LAYER]=Xu.UINT32,ku[Zu.WORLD_SCALE]=Xu.FLOAT32,ku[Zu.WORLD_POSITION]=Xu.FLOAT32,ku[Zu.WORLD_ROTATION]=Xu.FLOAT32,ku[Zu.WORLD_MATRIX]=Xu.FLOAT32,ku[Zu.LOCAL_SCALE]=Xu.FLOAT32,ku[Zu.LOCAL_POSITION]=Xu.FLOAT32,ku[Zu.LOCAL_ROTATION]=Xu.FLOAT32,ku[Zu.COUNT]=Xu.NEVER,ku),ic=((Uu={})[Zu.DIRTY_FLAG]=Zu.LAYER-Zu.DIRTY_FLAG,Uu[Zu.LAYER]=Zu.WORLD_SCALE-Zu.LAYER,Uu[Zu.WORLD_SCALE]=Zu.WORLD_POSITION-Zu.WORLD_SCALE,Uu[Zu.WORLD_POSITION]=Zu.WORLD_ROTATION-Zu.WORLD_POSITION,Uu[Zu.WORLD_ROTATION]=Zu.WORLD_MATRIX-Zu.WORLD_ROTATION,Uu[Zu.WORLD_MATRIX]=Zu.LOCAL_SCALE-Zu.WORLD_MATRIX,Uu[Zu.LOCAL_SCALE]=Zu.LOCAL_POSITION-Zu.LOCAL_SCALE,Uu[Zu.LOCAL_POSITION]=Zu.LOCAL_ROTATION-Zu.LOCAL_POSITION,Uu[Zu.LOCAL_ROTATION]=Zu.COUNT-Zu.LOCAL_ROTATION,Uu[Zu.COUNT]=1,Uu),nc=new qu(ju.NODE,ec,ic,Zu);!function(t){t[t.PRIORITY=0]="PRIORITY",t[t.STAGE=1]="STAGE",t[t.PHASE=2]="PHASE",t[t.PRIMITIVE=3]="PRIMITIVE",t[t.BATCHING_SCHEME=4]="BATCHING_SCHEME",t[t.DYNAMIC_STATE=5]="DYNAMIC_STATE",t[t.HASH=6]="HASH",t[t.COUNT=7]="COUNT"}(tc||(tc={}));var rc,sc=((Gu={})[tc.PRIORITY]=Xu.UINT32,Gu[tc.STAGE]=Xu.UINT32,Gu[tc.PHASE]=Xu.UINT32,Gu[tc.PRIMITIVE]=Xu.UINT32,Gu[tc.BATCHING_SCHEME]=Xu.UINT32,Gu[tc.DYNAMIC_STATE]=Xu.UINT32,Gu[tc.HASH]=Xu.UINT32,Gu[tc.COUNT]=Xu.NEVER,Gu),ac=((Vu={})[tc.PRIORITY]=tc.STAGE-tc.PRIORITY,Vu[tc.STAGE]=tc.PHASE-tc.STAGE,Vu[tc.PHASE]=tc.PRIMITIVE-tc.PHASE,Vu[tc.PRIMITIVE]=tc.BATCHING_SCHEME-tc.PRIMITIVE,Vu[tc.BATCHING_SCHEME]=tc.DYNAMIC_STATE-tc.BATCHING_SCHEME,Vu[tc.DYNAMIC_STATE]=tc.HASH-tc.DYNAMIC_STATE,Vu[tc.HASH]=tc.COUNT-tc.HASH,Vu[tc.COUNT]=1,Vu),oc=new qu(ju.PASS,sc,ac,tc);!function(t){t[t.CENTER=0]="CENTER",t[t.HALFEXTENTS=3]="HALFEXTENTS",t[t.COUNT=6]="COUNT"}(rc||(rc={}));var hc=((Hu={})[rc.CENTER]=Xu.FLOAT32,Hu[rc.HALFEXTENTS]=Xu.FLOAT32,Hu[rc.COUNT]=Xu.NEVER,Hu),lc=((zu={})[rc.CENTER]=rc.HALFEXTENTS-rc.CENTER,zu[rc.HALFEXTENTS]=rc.COUNT-rc.HALFEXTENTS,zu[rc.COUNT]=1,zu),uc=new qu(ju.AABB,hc,lc,rc);Vn(Hn.prototype,"RenderScene.prototype",[{name:"raycastUI2DNode"},{name:"raycastUINode"}]),Vn(Hn.prototype,"RenderScene.prototype",[{name:"raycastAll",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllModels",suggest:"using intersect.rayModel in geometry"},{name:"raycastSingleModel",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllCanvas",suggest:"using intersect.rayAABB in geometry"},{name:"rayResultCanvas"},{name:"rayResultModels"},{name:"rayResultAll"},{name:"rayResultSingleModel"}]),Vn(ni.prototype,"Model.prototype",[{name:"isInstancingEnabled"},{name:"instancedAttributes"}]);var cc={};Vn(cc,"CameraVisFlags",[{name:"GENERAL"}]),zn(cc,"CameraVisFlags",[{name:"PROFILER",newName:"PROFILER",target:Xn.BitMask,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Xn.BitMask,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Xn.BitMask,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Xn.BitMask,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Xn.BitMask,targetName:"UI_2D"}]),We.CameraVisFlags=cc;var dc={};Vn(dc,"VisibilityFlags",[{name:"GENERAL"}]),zn(dc,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:Xn.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:Xn.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Xn.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Xn.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Xn.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Xn.Enum,targetName:"UI_2D"}]),We.VisibilityFlags=dc,zn(Wn.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),Vn(ei.prototype,"Camera.prototype",[{name:"getSplitFrustum"},{name:"setMatView"},{name:"setMatViewInv"},{name:"setMatProjInv"},{name:"setMatViewProjInv"},{name:"setMatProj"},{name:"setMatViewProj"},{name:"getMatViewInv"}]),Vn(_i.prototype,"Shadows.prototype",[{name:"aspect"},{name:"selfShadow"},{name:"linear"},{name:"packing"},{name:"autoAdapt"},{name:"fixedArea"},{name:"pcf"},{name:"bias"},{name:"normalBias"},{name:"near"},{name:"far"},{name:"shadowDistance"},{name:"invisibleOcclusionRange"},{name:"orthoSize"},{name:"saturation"}]),Vn(Ai.prototype,"SpotLight.prototype",[{name:"aspect"}]),zn(ri.prototype,"SubModel.prototype",[{name:"subMeshData",newName:"subMesh"}]),Vn(ri.prototype,"SubModel.prototype",[{name:"getSubModel",suggest:"Use `subModels[i]` instead"},{name:"subModelNum",suggest:"Use `subModels.length` instead"}]);var _c,fc,pc,gc=function(t){if(void 0===Du[t]){var e=1<<Pu;Du[t]=e,Pu+=1}},mc=Object.freeze({__proto__:null,addStage:gc,scene:qa,createIA:function(t,e){if(!e.positions)return console.error("The data must have positions field"),null;for(var i=[],n=e.positions.length/3,r=0;r<n;++r)i.push(e.positions[3*r],e.positions[3*r+1],e.positions[3*r+2]),e.normals&&i.push(e.normals[3*r],e.normals[3*r+1],e.normals[3*r+2]),e.uvs&&i.push(e.uvs[2*r],e.uvs[2*r+1]),e.colors&&i.push(e.colors[3*r],e.colors[3*r+1],e.colors[3*r+2]);var s=[];s.push(new Bt(ie.ATTR_POSITION,_.RGB32F)),e.normals&&s.push(new Bt(ie.ATTR_NORMAL,_.RGB32F)),e.uvs&&s.push(new Bt(ie.ATTR_TEX_COORD,_.RG32F)),e.colors&&s.push(new Bt(ie.ATTR_COLOR,_.RGB32F));var a=t.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.DEVICE,4*i.length,4*i.length/n));a.update(new Float32Array(i));var o=null;return e.indices&&(o=t.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.DEVICE,2*e.indices.length,2))).update(new Uint16Array(e.indices)),t.createInputAssembler(new Dt(s,[a],o))},get RenderQueue(){return Iu},get PassStage(){return Bu},genHandle:Yn,getTypeFromHandle:jn,getBindingFromHandle:Kn,getCountFromHandle:qn,getOffsetFromHandle:Zn,customizeType:Qn,type2reader:Jn,type2writer:$n,type2validator:tr,getDefaultFromType:er,getStringFromType:ir,overrideMacros:nr,get BatchingSchemes(){return rr},Pass:Wn,flattenShaderLocation:sr,getDeviceShaderVersion:ar,programLib:or,nearestPOT:Ou,TextureBufferPool:Wu,MaterialInstance:On,PassInstance:hr,get PoolType(){return ju},NULL_HANDLE:0,get Render2dView(){return Ku},Render2dPool:$u,get NodeView(){return Zu},NodePool:nc,get PassView(){return tc},PassPool:oc,get AABBView(){return rc},AABBPool:uc,RenderScene:Hn,CameraVisFlags:cc,VisibilityFlags:dc});t("renderer",mc),function(t){t[t.BUTT=0]="BUTT",t[t.ROUND=1]="ROUND",t[t.SQUARE=2]="SQUARE"}(_c||(_c={})),Fn(_c),function(t){t[t.BEVEL=0]="BEVEL",t[t.ROUND=1]="ROUND",t[t.MITER=2]="MITER"}(fc||(fc={})),Fn(fc),function(t){t[t.PT_CORNER=1]="PT_CORNER",t[t.PT_LEFT=2]="PT_LEFT",t[t.PT_BEVEL=4]="PT_BEVEL",t[t.PT_INNERBEVEL=8]="PT_INNERBEVEL"}(pc||(pc={})),Fn(pc);var vc=Math.PI,yc=Math.min,Tc=Math.max,Sc=Math.cos,Ec=Math.sin,Ac=Math.abs,Cc=Math.sign,Rc=.5522847493;function bc(t,e,i,n,r){t.moveTo(e-n,i),t.bezierCurveTo(e-n,i+r*Rc,e-n*Rc,i+r,e,i+r),t.bezierCurveTo(e+n*Rc,i+r,e+n,i+r*Rc,e+n,i),t.bezierCurveTo(e+n,i-r*Rc,e+n*Rc,i-r,e,i-r),t.bezierCurveTo(e-n*Rc,i-r,e-n,i-r*Rc,e-n,i),t.close()}function xc(t,e,i,n,r,s,a,o,h,l,u){var c,d,_,f,p,g,m,v,y,T,S,E,A,C,R,b;l>10||(p=.5*(s+o),g=.5*(a+h),m=.5*((c=.5*(e+n))+(_=.5*(n+s))),v=.5*((d=.5*(i+r))+(f=.5*(r+a))),((R=Ac((n-o)*(C=h-i)-(r-h)*(A=o-e)))+(b=Ac((s-o)*C-(a-h)*A)))*(R+b)<t.tessTol*(A*A+C*C)?t.addPoint(o,h,0===u?u|pc.PT_BEVEL:u):(xc(t,e,i,c,d,m,v,S=.5*(m+(y=.5*(_+p))),E=.5*(v+(T=.5*(f+g))),l+1,0),xc(t,S,E,y,T,p,g,o,h,l+1,u)))}var wc,Mc,Ic,Bc,Pc,Dc,Oc,Fc,Lc,Nc,kc,Uc,Gc,Vc,Hc,zc,Xc,Wc,Yc,jc,Kc,qc,Zc,Qc,Jc,$c,td,ed,id,nd,rd,sd,ad,od,hd,ld,ud,cd,dd,_d=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).dx=0,n.dy=0,n.dmx=0,n.dmy=0,n.flags=0,n.len=0,n.reset(),n}return He(e,t),e.prototype.reset=function(){this.dx=0,this.dy=0,this.dmx=0,this.dmy=0,this.flags=0,this.len=0},e}(cn),fd=function(){function t(){this.closed=!1,this.bevel=0,this.complex=!0,this.points=[],this.reset()}return t.prototype.reset=function(){this.closed=!1,this.bevel=0,this.complex=!0,this.points?this.points.length=0:this.points=[]},t}(),pd=function(){function t(t){this.dataOffset=0,this.updatePathOffset=!1,this.pathLength=0,this.pathOffset=0,this.paths=[],this.tessTol=.25,this.distTol=.01,this.fillColor=Ve.WHITE.clone(),this.lineCap=_c.BUTT,this.strokeColor=Ve.BLACK.clone(),this.lineJoin=fc.MITER,this.lineWidth=0,this.pointsOffset=0,this._commandX=0,this._commandY=0,this._points=[],this._renderDataList=[],this._curPath=null,this._comp=void 0,this._comp=t}var e=t.prototype;return e.moveTo=function(t,e){this.updatePathOffset&&(this.pathOffset=this.pathLength,this.updatePathOffset=!1),this._addPath(),this.addPoint(t,e,pc.PT_CORNER),this._commandX=t,this._commandY=e},e.lineTo=function(t,e){this.addPoint(t,e,pc.PT_CORNER),this._commandX=t,this._commandY=e},e.bezierCurveTo=function(t,e,i,n,r,s){var a=this._curPath,o=a.points[a.points.length-1];o&&(o.x!==t||o.y!==e||i!==r||n!==s?(xc(this,o.x,o.y,t,e,i,n,r,s,0,pc.PT_CORNER),this._commandX=r,this._commandY=s):this.lineTo(r,s))},e.quadraticCurveTo=function(t,e,i,n){var r=this._commandX,s=this._commandY;this.bezierCurveTo(r+2/3*(t-r),s+2/3*(e-s),i+2/3*(t-i),n+2/3*(e-n),i,n)},e.arc=function(t,e,i,n,r,s){!function(t,e,i,n,r,s,a){var o,h,l=0,u=0,c=0,d=0,_=0,f=0,p=0,g=0,m=0,v=0,y=0,T=0,S=0,E=0;if(u=s-r,a=a||!1)if(Ac(u)>=2*vc)u=2*vc;else for(;u<0;)u+=2*vc;else if(Ac(u)>=2*vc)u=2*-vc;else for(;u>0;)u-=2*vc;for(h=0|Tc(1,yc(Ac(u)/(.5*vc)+.5,5)),c=Ac(4/3*(1-Sc(o=u/h/2))/Ec(o)),a||(c=-c),E=0;E<=h;E++)f=e+(d=Sc(l=r+u*(E/h)))*n,p=i+(_=Ec(l))*n,g=-_*n*c,m=d*n*c,0===E?t.moveTo(f,p):t.bezierCurveTo(v+T,y+S,f-g,p-m,f,p),v=f,y=p,T=g,S=m}(this,t,e,i,n,r,s)},e.ellipse=function(t,e,i,n){bc(this,t,e,i,n),this._curPath.complex=!1},e.circle=function(t,e,i){bc(this,t,e,i,i),this._curPath.complex=!1},e.rect=function(t,e,i,n){this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+n),this.lineTo(t,e+n),this.close(),this._curPath.complex=!1},e.roundRect=function(t,e,i,n,r){!function(t,e,i,n,r,s){if(s<.1)t.rect(e,i,n,r);else{var a=yc(s,.5*Ac(n))*Cc(n),o=yc(s,.5*Ac(r))*Cc(r);t.moveTo(e,i+o),t.lineTo(e,i+r-o),t.bezierCurveTo(e,i+r-o*(1-Rc),e+a*(1-Rc),i+r,e+a,i+r),t.lineTo(e+n-a,i+r),t.bezierCurveTo(e+n-a*(1-Rc),i+r,e+n,i+r-o*(1-Rc),e+n,i+r-o),t.lineTo(e+n,i+o),t.bezierCurveTo(e+n,i+o*(1-Rc),e+n-a*(1-Rc),i,e+n-a,i),t.lineTo(e+a,i),t.bezierCurveTo(e+a*(1-Rc),i,e,i+o*(1-Rc),e,i+o),t.close()}}(this,t,e,i,n,r),this._curPath.complex=!1},e.clear=function(){this.pathLength=0,this.pathOffset=0,this.pointsOffset=0,this.dataOffset=0,this._curPath=null,this.paths.length=0,this._points.length=0;for(var t=this._renderDataList,e=0,i=t.length;e<i;e++){var n=t[e];n&&(El.remove(n),n.removeRenderDrawInfo(this._comp))}this._renderDataList.length=0},e.close=function(){this._curPath.closed=!0},e.requestRenderData=function(){var t=El.add();return this._renderDataList.push(t),t},e.getRenderDataList=function(){return 0===this._renderDataList.length&&this.requestRenderData(),this._renderDataList},e.addPoint=function(t,e,i){var n=this._curPath;if(n){var r=this._points,s=n.points,a=r[this.pointsOffset++];a?(a.x=t,a.y=e):(a=new _d(t,e),r.push(a)),a.flags=i,s.push(a)}},e._addPath=function(){var t=this.pathLength,e=this.paths[t];return e?e.reset():(e=new fd,this.paths.push(e)),this.pathLength++,this._curPath=e,e},t}(),gd=Dh.concat([new Bt("a_dist",_.R32F)]),md=kh(gd),vd=Uh(gd),yd=function(e){return t({Graphics:e,GraphicsComponent:e}),e}((wc=Ki("cc.Graphics"),Mc=In(110),Ic=Tn(fc),Bc=Tn(_c),wc(Pc=Mc((Vc=Gc=function(t){function e(){var e;return(e=t.call(this)||this).impl=null,e.model=null,e._lineWidth=Oc&&Oc(),e._strokeColor=Fc&&Fc(),e._lineJoin=Lc&&Lc(),e._lineCap=Nc&&Nc(),e._fillColor=kc&&kc(),e._miterLimit=Uc&&Uc(),e._isDrawing=!1,e._isNeedUploadData=!0,e._graphicsUseSubMeshes=[],e._instanceMaterialType=Wl.ADD_COLOR,e.impl=new pd(lr(e)),e}He(e,t);var i=e.prototype;return i.onRestore=function(){this.impl||this._flushAssembler()},i.onLoad=function(){t.prototype.onLoad.call(this),this.model=Di.root.createModel(ni),this.model.node=this.model.transform=this.node,this._flushAssembler()},i.onEnable=function(){t.prototype.onEnable.call(this),this._updateMtlForGraphics()},i.onDestroy=function(){this._sceneGetter=null,this.model&&(Di.root.destroyModel(this.model),this.model=null);var e=this._graphicsUseSubMeshes.length;if(e>0){for(var i=0;i<e;++i)this._graphicsUseSubMeshes[i].destroy();this._graphicsUseSubMeshes.length=0}this.impl&&(this._isDrawing=!1,this.impl.clear(),this.impl=null),t.prototype.onDestroy.call(this)},i.moveTo=function(t,e){this.impl&&this.impl.moveTo(t,e)},i.lineTo=function(t,e){this.impl&&this.impl.lineTo(t,e)},i.bezierCurveTo=function(t,e,i,n,r,s){this.impl&&this.impl.bezierCurveTo(t,e,i,n,r,s)},i.quadraticCurveTo=function(t,e,i,n){this.impl&&this.impl.quadraticCurveTo(t,e,i,n)},i.arc=function(t,e,i,n,r,s){this.impl&&this.impl.arc(t,e,i,n,r,s)},i.ellipse=function(t,e,i,n){this.impl&&this.impl.ellipse(t,e,i,n)},i.circle=function(t,e,i){this.impl&&this.impl.circle(t,e,i)},i.rect=function(t,e,i,n){this.impl&&this.impl.rect(t,e,i,n)},i.roundRect=function(t,e,i,n,r){this.impl&&this.impl.roundRect(t,e,i,n,r)},i.fillRect=function(t,e,i,n){this.rect(t,e,i,n),this.fill()},i.clear=function(){if(this.impl){if(this.impl.clear(),this._isDrawing=!1,this.model)for(var t=0;t<this.model.subModels.length;t++)this.model.subModels[t].inputAssembler.indexCount=0;this.markForUpdateRenderData()}},i.close=function(){this.impl&&this.impl.close()},i.stroke=function(){this._assembler||this._flushAssembler(),this._isDrawing=!0,this._isNeedUploadData=!0,this._assembler.stroke(this)},i.fill=function(){this._assembler||this._flushAssembler(),this._isDrawing=!0,this._isNeedUploadData=!0,this._assembler.fill(this)},i._updateMtlForGraphics=function(){var t;this._customMaterial?t=this.getMaterialInstance(0):(t=Nn.get("ui-graphics-material"),this.setMaterial(t,0),(t=this.getMaterialInstance(0)).recompileShaders({USE_LOCAL:!0}))},i.activeSubModel=function(t){if(this.model){if(this.model.subModels.length<=t){var e=ke.gfxDevice,i=e.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.DEVICE,65535*vd,vd)),n=e.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.DEVICE,131070*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),r=new qi([i],gd,U.TRIANGLE_LIST,n);r.subMeshIdx=0,this.model.initSubModel(t,r,this.getMaterialInstance(0)),this._graphicsUseSubMeshes.push(r)}}else Zi(4500,this.node.name)},i._uploadData=function(){var t=this.impl;if(t){var e=t&&t.getRenderDataList();if(!(e.length<=0)&&this.model){for(var i=this.model.subModels,n=0;n<e.length;n++){var r=e[n],s=i[n].inputAssembler;if(r.lastFilledVertex!==r.vertexStart){var a=new Float32Array(r.vData.buffer,0,r.vertexStart*md);s.vertexBuffers[0].update(a),s.vertexCount=r.vertexStart;var o=new Uint16Array(r.iData.buffer,0,r.indexStart);s.indexBuffer.update(o),s.indexCount=r.indexStart,r.lastFilledVertex=r.vertexStart,r.lastFilledIndex=r.indexStart}}this._isNeedUploadData=!1}}},i._render=function(t){if(this._isNeedUploadData){if(this.impl){var e=this.impl.getRenderDataList(),i=this.model.subModels.length;if(e.length>i)for(var n=i;n<e.length;n++)this.activeSubModel(n)}this._uploadData()}t.commitModel(this,this.model,this.getMaterialInstance(0))},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t)},i._canRender=function(){return!!t.prototype._canRender.call(this)&&!!this.model&&this._isDrawing},i.updateRenderer=function(){t.prototype.updateRenderer.call(this)},i.createRenderEntity=function(){return new ml(Jh.DYNAMIC)},Pi(e,[{key:"lineWidth",get:function(){return this._lineWidth},set:function(t){this._lineWidth=t,this.impl&&(this.impl.lineWidth=t)}},{key:"lineJoin",get:function(){return this._lineJoin},set:function(t){this._lineJoin=t,this.impl&&(this.impl.lineJoin=t)}},{key:"lineCap",get:function(){return this._lineCap},set:function(t){this._lineCap=t,this.impl&&(this.impl.lineCap=t)}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(t){this.impl&&(this._strokeColor.set(t),this.impl.strokeColor=this._strokeColor)}},{key:"fillColor",get:function(){return this._fillColor},set:function(t){this.impl&&(this._fillColor.set(t),this.impl.fillColor=this._fillColor)}},{key:"miterLimit",get:function(){return this._miterLimit},set:function(t){this._miterLimit=t}},{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&this._color.set(t)}},{key:"srcBlendFactor",get:function(){return this._srcBlendFactor},set:function(){}},{key:"dstBlendFactor",get:function(){return this._dstBlendFactor},set:function(){}},{key:"graphicsNativeProxy",get:function(){return this._graphicsNativeProxy}}]),e}(wu),Gc.LineJoin=fc,Gc.LineCap=_c,gn((Dc=Vc).prototype,"lineJoin",[Ic],Object.getOwnPropertyDescriptor(Dc.prototype,"lineJoin"),Dc.prototype),gn(Dc.prototype,"lineCap",[Bc],Object.getOwnPropertyDescriptor(Dc.prototype,"lineCap"),Dc.prototype),gn(Dc.prototype,"color",[mn],Object.getOwnPropertyDescriptor(Dc.prototype,"color"),Dc.prototype),Oc=tn(Dc.prototype,"_lineWidth",[en],(function(){return 1})),Fc=tn(Dc.prototype,"_strokeColor",[en],(function(){return Ve.BLACK.clone()})),Lc=tn(Dc.prototype,"_lineJoin",[en],(function(){return fc.MITER})),Nc=tn(Dc.prototype,"_lineCap",[en],(function(){return _c.BUTT})),kc=tn(Dc.prototype,"_fillColor",[en],(function(){return Ve.WHITE.clone()})),Uc=tn(Dc.prototype,"_miterLimit",[en],(function(){return 10})),Pc=Dc))||Pc)||Pc));We.Graphics=yd,function(t){t[t.SIMPLE=0]="SIMPLE",t[t.SLICED=1]="SLICED",t[t.TILED=2]="TILED",t[t.FILLED=3]="FILLED"}(ld||(ld={})),Fn(ld),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.RADIAL=2]="RADIAL"}(ud||(ud={})),Fn(ud),function(t){t[t.CUSTOM=0]="CUSTOM",t[t.TRIMMED=1]="TRIMMED",t[t.RAW=2]="RAW"}(cd||(cd={})),Fn(cd),function(t){t.SPRITE_FRAME_CHANGED="spriteframe-changed"}(dd||(dd={}));var Td,Sd,Ed,Ad,Cd,Rd,bd,xd,wd,Md,Id,Bd=function(e){return t({Sprite:e,SpriteComponent:e}),e}((Hc=Ki("cc.Sprite"),zc=In(110),Xc=Tn(Vo),Wc=Tn(Uo),Yc=Tn(ld),jc=Tn(ud),Kc=Tn(cd),Hc(qc=zc((hd=od=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._spriteFrame=Qc&&Qc(),e._type=Jc&&Jc(),e._fillType=$c&&$c(),e._sizeMode=td&&td(),e._fillCenter=ed&&ed(),e._fillStart=id&&id(),e._fillRange=nd&&nd(),e._isTrimmedMode=rd&&rd(),e._useGrayscale=sd&&sd(),e._atlas=ad&&ad(),e}He(e,t);var i=e.prototype;return i.__preload=function(){this.changeMaterialForDefine(),t.prototype.__preload.call(this)},i.onEnable=function(){t.prototype.onEnable.call(this),this._activateMaterial();var e=this._spriteFrame;e&&(this._updateUVs(),this._type===ld.SLICED&&e.on(Uo.EVENT_UV_UPDATED,this._updateUVs,this))},i.onDisable=function(){t.prototype.onDisable.call(this),this._spriteFrame&&this._type===ld.SLICED&&this._spriteFrame.off(Uo.EVENT_UV_UPDATED,this._updateUVs,this)},i.onDestroy=function(){t.prototype.onDestroy.call(this)},i.changeSpriteFrameFromAtlas=function(t){if(this._atlas){var e=this._atlas.getSpriteFrame(t);this.spriteFrame=e}else console.warn("SpriteAtlas is null.")},i.changeMaterialForDefine=function(){var t,e=this._instanceMaterialType;this._spriteFrame&&(t=this._spriteFrame.texture);var i=!1;if(t instanceof Un){var n=t.getPixelFormat();i=n===ze.RGBA_ETC1||n===ze.RGB_A_PVRTC_4BPPV1||n===ze.RGB_A_PVRTC_2BPPV1}i&&this.grayscale?this._instanceMaterialType=Wl.USE_ALPHA_SEPARATED_AND_GRAY:i?this._instanceMaterialType=Wl.USE_ALPHA_SEPARATED:this.grayscale?this._instanceMaterialType=Wl.GRAYSCALE:this._instanceMaterialType=Wl.ADD_COLOR_AND_TEXTURE,e!==this._instanceMaterialType&&this.updateMaterial()},i._updateBuiltinMaterial=function(){var e=t.prototype._updateBuiltinMaterial.call(this);if(this.spriteFrame&&this.spriteFrame.texture instanceof ur){var i=cr({SAMPLE_FROM_RT:!0},e.passes[0].defines),n=new Dn;n.initialize({effectAsset:e.effectAsset,defines:i}),e=n}return e},i._render=function(t){t.commitComp(this,this.renderData,this._spriteFrame,this._assembler,null)},i._canRender=function(){if(!t.prototype._canRender.call(this))return!1;var e=this._spriteFrame;return!(!e||!e.texture)},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this.destroyRenderData(),this._assembler=t),this.renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this.renderData.material=this.getRenderMaterial(0),this.markForUpdateRenderData(),this.spriteFrame&&this._assembler.updateUVs(this),this._updateColor()),this._spriteFrame&&(this._type===ld.SLICED?this._spriteFrame.on(Uo.EVENT_UV_UPDATED,this._updateUVs,this):this._spriteFrame.off(Uo.EVENT_UV_UPDATED,this._updateUVs,this))},i._applySpriteSize=function(){if(this._spriteFrame)if(cd.RAW===this._sizeMode){var t=this._spriteFrame.originalSize;this.node._uiProps.uiTransformComp.setContentSize(t)}else if(cd.TRIMMED===this._sizeMode){var e=this._spriteFrame.rect;this.node._uiProps.uiTransformComp.setContentSize(e.width,e.height)}},i._resized=function(){},i._activateMaterial=function(){var t=this._spriteFrame,e=this.getRenderMaterial(0);t&&e&&this.markForUpdateRenderData(),this.renderData&&(this.renderData.material=e)},i._updateUVs=function(){this._assembler&&this._assembler.updateUVs(this)},i._applySpriteFrame=function(t){var e=this._spriteFrame;t&&this._type===ld.SLICED&&t.off(Uo.EVENT_UV_UPDATED,this._updateUVs,this);var i=!1;e&&(t&&t.texture===e.texture||(i=!0),i&&(this.renderData&&(this.renderData.textureDirty=!0),this.changeMaterialForDefine()),this._applySpriteSize(),this._type===ld.SLICED&&e.on(Uo.EVENT_UV_UPDATED,this._updateUVs,this))},Pi(e,[{key:"spriteAtlas",get:function(){return this._atlas},set:function(t){this._atlas!==t&&(this._atlas=t)}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){if(this._spriteFrame!==t){var e=this._spriteFrame;this._spriteFrame=t,this.markForUpdateRenderData(),this._applySpriteFrame(e)}}},{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this._flushAssembler())}},{key:"fillType",get:function(){return this._fillType},set:function(t){this._fillType!==t&&(t===ud.RADIAL||this._fillType===ud.RADIAL?this.destroyRenderData():this.renderData&&this.markForUpdateRenderData(!0)),this._fillType=t,this._flushAssembler()}},{key:"fillCenter",get:function(){return this._fillCenter},set:function(t){this._fillCenter.x=t.x,this._fillCenter.y=t.y,this._type===ld.FILLED&&this.renderData&&this.markForUpdateRenderData()}},{key:"fillStart",get:function(){return this._fillStart},set:function(t){this._fillStart=Ge(t,0,1),this._type===ld.FILLED&&this.renderData&&(this.markForUpdateRenderData(),this._updateUVs())}},{key:"fillRange",get:function(){return this._fillRange},set:function(t){this._fillRange=Ge(t,-1,1),this._type===ld.FILLED&&this.renderData&&(this.markForUpdateRenderData(),this._updateUVs())}},{key:"trim",get:function(){return this._isTrimmedMode},set:function(t){this._isTrimmedMode!==t&&(this._isTrimmedMode=t,this._type===ld.SIMPLE&&this.renderData&&this.markForUpdateRenderData(!0))}},{key:"grayscale",get:function(){return this._useGrayscale},set:function(t){this._useGrayscale!==t&&(this._useGrayscale=t,this.changeMaterialForDefine(),this.updateMaterial())}},{key:"sizeMode",get:function(){return this._sizeMode},set:function(t){this._sizeMode!==t&&(this._sizeMode=t,t!==cd.CUSTOM&&this._applySpriteSize())}}]),e}(wu),od.FillType=ud,od.Type=ld,od.SizeMode=cd,od.EventType=dd,gn((Zc=hd).prototype,"spriteAtlas",[Xc],Object.getOwnPropertyDescriptor(Zc.prototype,"spriteAtlas"),Zc.prototype),gn(Zc.prototype,"spriteFrame",[Wc],Object.getOwnPropertyDescriptor(Zc.prototype,"spriteFrame"),Zc.prototype),gn(Zc.prototype,"type",[Yc],Object.getOwnPropertyDescriptor(Zc.prototype,"type"),Zc.prototype),gn(Zc.prototype,"fillType",[jc],Object.getOwnPropertyDescriptor(Zc.prototype,"fillType"),Zc.prototype),gn(Zc.prototype,"sizeMode",[Kc],Object.getOwnPropertyDescriptor(Zc.prototype,"sizeMode"),Zc.prototype),Qc=tn(Zc.prototype,"_spriteFrame",[en],(function(){return null})),Jc=tn(Zc.prototype,"_type",[en],(function(){return ld.SIMPLE})),$c=tn(Zc.prototype,"_fillType",[en],(function(){return ud.HORIZONTAL})),td=tn(Zc.prototype,"_sizeMode",[en],(function(){return cd.TRIMMED})),ed=tn(Zc.prototype,"_fillCenter",[en],(function(){return new cn(0,0)})),id=tn(Zc.prototype,"_fillStart",[en],(function(){return 0})),nd=tn(Zc.prototype,"_fillRange",[en],(function(){return 0})),rd=tn(Zc.prototype,"_isTrimmedMode",[en],(function(){return!0})),sd=tn(Zc.prototype,"_useGrayscale",[en],(function(){return!1})),ad=tn(Zc.prototype,"_atlas",[en],(function(){return null})),qc=Zc))||qc)||qc));We.Sprite=Bd;var Pd,Dd=new Ue,Od=new cn,Fd=new Ue,Ld=[];!function(t){t[t.GRAPHICS_RECT=0]="GRAPHICS_RECT",t[t.GRAPHICS_ELLIPSE=1]="GRAPHICS_ELLIPSE",t[t.GRAPHICS_STENCIL=2]="GRAPHICS_STENCIL",t[t.SPRITE_STENCIL=3]="SPRITE_STENCIL"}(Pd||(Pd={})),Fn(Pd);var Nd=function(e){return t({Mask:e,MaskComponent:e}),e}((Td=Ki("cc.Mask"),Sd=In(110),Ed=Tn(Pd),Td(Ad=Sd((Id=Md=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._type=Rd&&Rd(),e._inverted=bd&&bd(),e._segments=xd&&xd(),e._alphaThreshold=wd&&wd(),e._sprite=null,e._graphics=null,e._stencilStage=qh.DISABLED,e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._changeRenderType()},i.onEnable=function(){this._changeRenderType(),this._updateGraphics(),this._enableRender(),this.node.on(xn.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.on(xn.SIZE_CHANGED,this._nodeStateChange,this)},i.onRestore=function(){this._changeRenderType(),this._updateGraphics()},i.onDisable=function(){this._disableRender(),this.node.off(xn.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.off(xn.SIZE_CHANGED,this._nodeStateChange,this)},i.onDestroy=function(){this._removeMaskNode()},i.isHit=function(t){var e=this.node._uiProps.uiTransformComp,i=e.contentSize,n=i.width,r=i.height,s=Od;this.node.getWorldMatrix(Dd),Ue.invert(Fd,Dd),cn.transformMat4(s,t,Fd);var a=e.anchorPoint;s.x+=a.x*n,s.y+=a.y*r;var o=!1;if(this.type===Pd.GRAPHICS_RECT||this.type===Pd.GRAPHICS_STENCIL||this.type===Pd.SPRITE_STENCIL)o=s.x>=0&&s.y>=0&&s.x<=n&&s.y<=r;else if(this.type===Pd.GRAPHICS_ELLIPSE){var h=n/2,l=r/2,u=s.x-.5*n,c=s.y-.5*r;o=u*u/(h*h)+c*c/(l*l)<1}return this._inverted&&(o=!o),o},i._nodeStateChange=function(){this._updateGraphics()},i._changeRenderType=function(){this._type!==Pd.SPRITE_STENCIL?this._createGraphics():this._createSprite()},i._createSprite=function(){if(!this._sprite){var t=this._sprite=this.node.getComponent(Bd);if(!t){var e=this.node;t=this._sprite=e.addComponent(Bd)}t.color=Ve.WHITE.clone(),t.sizeMode=0}this._sprite.stencilStage=this.inverted?qh.ENTER_LEVEL_INVERTED:qh.ENTER_LEVEL,this._sprite.updateMaterial()},i._createGraphics=function(){if(!this._graphics){var t=this._graphics=this.node.getComponent(yd);if(!t){var e=this.node;t=this._graphics=e.addComponent(yd)}t.lineWidth=1;var i=Ve.WHITE.clone();i.a=0,t.fillColor=i}this._graphics.stencilStage=this.inverted?qh.ENTER_LEVEL_INVERTED:qh.ENTER_LEVEL},i._updateGraphics=function(){if(this._graphics&&(this._type===Pd.GRAPHICS_RECT||this._type===Pd.GRAPHICS_ELLIPSE)){var t=this.node._uiProps.uiTransformComp,e=this._graphics;e.clear();var i=t.contentSize,n=i.width,r=i.height,s=t.anchorPoint,a=-n*s.x,o=-r*s.y;if(this._type===Pd.GRAPHICS_RECT)e.rect(a,o,n,r);else if(this._type===Pd.GRAPHICS_ELLIPSE){for(var h=function(t,e,i){Ld.length=0;for(var n=2*Math.PI/i,r=0;r<i;++r)Ld.push(new ji(e.x*Math.cos(n*r)+t.x,e.y*Math.sin(n*r)+t.y,0));return Ld}(new ji(a+n/2,o+r/2,0),new ji(n/2,r/2,0),this._segments),l=0;l<h.length;++l){var u=h[l];0===l?e.moveTo(u.x,u.y):e.lineTo(u.x,u.y)}e.close()}e.fill()}},i._enableRender=function(){this.subComp&&(this.subComp.enabled=!0)},i._disableRender=function(){this.subComp&&(this.subComp.stencilStage=qh.DISABLED,this.subComp.updateMaterial(),this.node.activeInHierarchy&&(this.subComp.enabled=!1))},i._removeMaskNode=function(){this._sprite&&(this._sprite.destroy(),this._sprite=null),this._graphics&&(this._graphics.destroy(),this._graphics=null)},i.markForUpdateRenderData=function(t){void 0===t&&(t=!0),Zi(9007),this.subComp&&this.subComp.markForUpdateRenderData(t)},i.requestRenderData=function(){Zi(9007)},i.destroyRenderData=function(){Zi(9007)},i.updateRenderer=function(){Zi(9007),this.subComp&&this.subComp.updateRenderer()},i.fillBuffers=function(){Zi(9007)},i.postUpdateAssembler=function(){Zi(9007)},i.setNodeDirty=function(){Zi(9007),this.subComp&&this.subComp.setNodeDirty()},i.setTextureDirty=function(){Zi(9007),this.subComp&&this.subComp.setTextureDirty()},i.getMaterial=function(t){return Zi(9007),this.subComp?this.subComp.getMaterial(t):null},i.setMaterial=function(t,e){Zi(9007),this.subComp&&this.subComp.setMaterial(t,e)},i.getMaterialInstance=function(t){return Zi(9007),this.subComp?this.subComp.getMaterialInstance(t):null},i.setMaterialInstance=function(t,e){Zi(9007),this.subComp&&this.subComp.setMaterialInstance(t,e)},i.getRenderMaterial=function(t){return Zi(9007),this.subComp?this.subComp.getRenderMaterial(t):null},Pi(e,[{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this._type!==Pd.SPRITE_STENCIL?(this._sprite&&(this.node.removeComponent(Bd),this._sprite._destroyImmediate(),this._sprite=null),this._changeRenderType(),this._updateGraphics()):(this._graphics&&(this._graphics.clear(),this.node.removeComponent(yd),this._graphics._destroyImmediate(),this._graphics=null),this._changeRenderType()))}},{key:"inverted",get:function(){return this._inverted},set:function(t){this._inverted=t,this.subComp.stencilStage=this.inverted?qh.ENTER_LEVEL_INVERTED:qh.ENTER_LEVEL}},{key:"segments",get:function(){return this._segments},set:function(t){this._segments!==t&&(this._segments=Ge(t,3,1e4),this._updateGraphics())}},{key:"spriteFrame",get:function(){return this._sprite?this._sprite.spriteFrame:null},set:function(t){this._sprite?this._sprite.spriteFrame=t:console.error("please change type to sprite_stencil first")}},{key:"alphaThreshold",get:function(){return this._alphaThreshold},set:function(t){this._alphaThreshold!==t&&(this._alphaThreshold=t,this.type===Pd.SPRITE_STENCIL&&this._sprite&&this._sprite.getMaterialInstance(0).setProperty("alphaThreshold",this._alphaThreshold))}},{key:"subComp",get:function(){return this._graphics||this._sprite}},{key:"customMaterial",get:function(){return Zi(9007),this.subComp?this.subComp.customMaterial:null},set:function(t){Zi(9007),this.subComp&&(this.subComp.customMaterial=t)}},{key:"color",get:function(){return Zi(9007),this.subComp?this.subComp.color:null},set:function(t){Zi(9007),this.subComp&&t&&(this.subComp.color=t)}},{key:"sharedMaterial",get:function(){return Zi(9007),this.subComp?this.subComp.sharedMaterial:null}},{key:"sharedMaterials",get:function(){return Zi(9007),this.subComp?this.subComp.sharedMaterials:null},set:function(t){Zi(9007),this.subComp&&t&&(this.subComp.sharedMaterials=t)}},{key:"material",get:function(){return Zi(9007),this.subComp?this.subComp.material:null},set:function(t){Zi(9007),this.subComp&&(this.subComp.material=t)}},{key:"materials",get:function(){return Zi(9007),this.subComp?this.subComp.materials:[null]},set:function(t){Zi(9007),this.subComp&&(this.subComp.materials=t)}}]),e}(Pn),Md.Type=Pd,gn((Cd=Id).prototype,"type",[Ed],Object.getOwnPropertyDescriptor(Cd.prototype,"type"),Cd.prototype),Rd=tn(Cd.prototype,"_type",[en],(function(){return Pd.GRAPHICS_RECT})),bd=tn(Cd.prototype,"_inverted",[en],(function(){return!1})),xd=tn(Cd.prototype,"_segments",[en],(function(){return 64})),wd=tn(Cd.prototype,"_alphaThreshold",[en],(function(){return.1})),Ad=Cd))||Ad)||Ad));dr._maskComp=Nd,We.Mask=Nd;var kd,Ud,Gd,Vd,Hd,zd,Xd,Wd,Yd,jd,Kd,qd,Zd,Qd,Jd,$d,t_,e_,i_,n_,r_,s_,a_,o_,h_,l_,u_,c_,d_,__,f_,p_,g_,m_,v_,y_,T_,S_=/^(click)(\s)*=|(param)(\s)*=/,E_=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/,A_=t("HtmlTextParser",function(){function t(){this._specialSymbolArray=[],this._stack=[],this._resultObjectArray=[],this._specialSymbolArray.push([/&lt;/g,"<"]),this._specialSymbolArray.push([/&gt;/g,">"]),this._specialSymbolArray.push([/&amp;/g,"&"]),this._specialSymbolArray.push([/&quot;/g,'"']),this._specialSymbolArray.push([/&apos;/g,"'"])}var e=t.prototype;return e.parse=function(t){this._resultObjectArray.length=0,this._stack.length=0;for(var e=0,i=t.length;e<i;){var n=t.indexOf(">",e),r=-1;if(n>=0&&(r=t.lastIndexOf("<",n))<e-1&&(r=t.indexOf("<",n+1),n=t.indexOf(">",r+1)),r<0)this._stack.pop(),this._processResult(t.substring(e)),e=i;else{var s=t.substring(e,r),a=t.substring(r+1,n);""===a&&(s=t.substring(e,n+1)),this._processResult(s),-1===n?n=r:"/"===t.charAt(r+1)?this._stack.pop():this._addToStack(a),e=n+1}}return this._resultObjectArray},e._attributeToObject=function(t){t=t.trim();var e={},i=/^(color|size)(\s)*=/.exec(t),n="",r=0,s="";if(i){if(n=i[0],""===(t=t.substring(n.length).trim()))return e;switch(r=t.indexOf(" "),n[0]){case"c":e.color=r>-1?t.substring(0,r).trim():t;break;case"s":e.size=parseInt(t)}return r>-1&&(s=t.substring(r+1).trim(),e.event=this._processEventHandler(s)),e}if((i=/^(br(\s)*\/)/.exec(t))&&i[0].length>0&&(n=i[0].trim()).startsWith("br")&&"/"===n[n.length-1])return e.isNewLine=!0,this._resultObjectArray.push({text:"",style:{isNewLine:!0}}),e;var a="",o=-1;if((i=/^(img(\s)*src(\s)*=[^>]+\/)/.exec(t))&&i[0].length>0&&(n=i[0].trim()).startsWith("img")&&"/"===n[n.length-1]){var h;i=E_.exec(t);for(var l=!1;i;){var u=(n=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length)).length;if(n=(n=n.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),a=t.substring(u).trim(),o="src"===n?this.getRightQuotationIndex(a):-1,h=(r=a.indexOf(" ",o+1>=a.length?-1:o+1))>-1?a.substr(0,r):a,t=a.substring(r).trim(),h.endsWith("/")&&(h=h.slice(0,-1)),"src"===n){switch(h.charCodeAt(0)){case 34:case 39:l=!0,h=h.slice(1,-1)}e.isImage=!0,e.src=h}else if("height"===n)e.imageHeight=parseInt(h);else if("width"===n)e.imageWidth=parseInt(h);else if("align"===n){switch(h.charCodeAt(0)){case 34:case 39:h=h.slice(1,-1)}e.imageAlign=h.toLowerCase()}else"offset"===n?e.imageOffset=h:"click"===n&&(e.event=this._processEventHandler(n+"="+h));e.event&&"param"===n&&(e.event[n]=h.replace(/^"|"$/g,"")),i=E_.exec(t)}return l&&e.isImage&&this._resultObjectArray.push({text:"",style:e}),{}}if(i=/^(outline(\s)*[^>]*)/.exec(t)){var c={color:"#ffffff",width:1};if(t=i[0].substring("outline".length).trim()){var d,_=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(i=_.exec(t);i;)n=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length),d=(r=(a=t.substring(n.length).trim()).indexOf(" "))>-1?a.substr(0,r):a,n=(n=n.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),t=a.substring(r).trim(),"click"===n?e.event=this._processEventHandler(n+"="+d):"color"===n?c.color=d:"width"===n&&(c.width=parseInt(d)),e.event&&"param"===n&&(e.event[n]=d.replace(/^"|"$/g,"")),i=_.exec(t)}e.outline=c}if((i=/^(on|u|b|i)(\s)*/.exec(t))&&i[0].length>0){switch(n=i[0],t=t.substring(n.length).trim(),n[0]){case"u":e.underline=!0;break;case"i":e.italic=!0;break;case"b":e.bold=!0}if(""===t)return e;e.event=this._processEventHandler(t)}return e},e.getRightQuotationIndex=function(t){var e=-1,i=-1,n=t.indexOf("'"),r=t.indexOf('"'),s=r>-1&&(r<n||-1===n);return n>-1&&(n<r||-1===r)?(e=n,i=t.indexOf("'",e+1>=t.length?-1:e+1)):s&&(e=r,i=t.indexOf('"',e+1>=t.length?-1:e+1)),i},e._processEventHandler=function(t){for(var e={},i=0,n=!1,r=S_.exec(t);r;){var s=r[0],a="";if(n=!1,'"'===(t=t.substring(s.length).trim()).charAt(0))(i=t.indexOf('"',1))>-1&&(a=t.substring(1,i).trim(),n=!0),i++;else if("'"===t.charAt(0))(i=t.indexOf("'",1))>-1&&(a=t.substring(1,i).trim(),n=!0),i++;else{var o=/(\S)+/.exec(t);i=(a=o?o[0]:"").length}n&&(e[s=s.substring(0,s.length-1).trim()]=a),t=t.substring(i).trim(),r=S_.exec(t)}return e},e._addToStack=function(t){var e=this._attributeToObject(t);if(0===this._stack.length)this._stack.push(e);else{if(e.isNewLine||e.isImage)return;var i=this._stack[this._stack.length-1];for(var n in i)e[n]||(e[n]=i[n]);this._stack.push(e)}},e._processResult=function(t){0!==t.length&&(t=this._escapeSpecialSymbol(t),this._stack.length>0?this._resultObjectArray.push({text:t,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:t}))},e._escapeSpecialSymbol=function(t){for(var e,i=Fi(this._specialSymbolArray);!(e=i()).done;){var n=e.value,r=n[0],s=n[1];t=t.replace(r,s)}return t},t}()),C_=function(e){return t({LabelOutline:e,LabelOutlineComponent:e}),e}(Ki("cc.LabelOutline")(kd=In(110)(kd=kn(Mu)((Ud=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._color=Gd&&Gd(),e._width=Vd&&Vd(),e}He(e,t);var i=e.prototype;return i.onEnable=function(){this._updateRenderData()},i.onDisable=function(){this._updateRenderData()},i._updateRenderData=function(){var t=this.node.getComponent(Mu);t&&t.updateRenderData(!0)},Pi(e,[{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&(this._color.set(t),this._updateRenderData())}},{key:"width",get:function(){return this._width},set:function(t){this._width!==t&&(this._width=t,this._updateRenderData())}}]),e}(Pn),Gd=tn(Ud.prototype,"_color",[en],(function(){return new Ve(0,0,0,255)})),Vd=tn(Ud.prototype,"_width",[en],(function(){return 2})),kd=Ud))||kd)||kd)||kd);We.LabelOutline=C_,_r({RenderComponent:{newName:"UIRenderer",since:"1.2.0",removed:!0},UITransformComponent:{newName:"UITransform",since:"1.2.0",removed:!1},CanvasComponent:{newName:"Canvas",since:"1.2.0",removed:!1}}),_r({UIRenderable:{newName:"UIRenderer",since:"3.0.0",removed:!0}}),_r({Renderable2D:{newName:"UIRenderer",since:"3.6.0",removed:!1}});var R_,b_=new ji,x_=fr(je),w_=fr(Ye),M_=fr(Ke),I_=fr(Ze),B_=fr(qe),P_=fr({SKYBOX:ti|q.DEPTH_STENCIL,SOLID_COLOR:q.ALL,DEPTH_ONLY:q.DEPTH_STENCIL,DONT_CLEAR:q.NONE}),D_=function(e){return t({Camera:e,CameraComponent:e}),e}((Hd=Ki("cc.Camera"),zd=Tn(Xn.BitMask),Xd=Tn(P_),Wd=Tn(x_),Yd=Tn(w_),jd=Tn(M_),Kd=Tn(I_),qd=Tn(B_),Zd=Tn(ur),Hd((T_=y_=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._projection=$d&&$d(),e._priority=t_&&t_(),e._fov=e_&&e_(),e._fovAxis=i_&&i_(),e._orthoHeight=n_&&n_(),e._near=r_&&r_(),e._far=s_&&s_(),e._color=a_&&a_(),e._depth=o_&&o_(),e._stencil=h_&&h_(),e._clearFlags=l_&&l_(),e._rect=u_&&u_(),e._aperture=c_&&c_(),e._shutter=d_&&d_(),e._iso=__&&__(),e._screenScale=f_&&f_(),e._visibility=p_&&p_(),e._targetTexture=g_&&g_(),e._camera=null,e._inEditorMode=!1,e._flows=void 0,e._cameraType=m_&&m_(),e._trackingType=v_&&v_(),e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._createCamera()},i.onEnable=function(){this.node.hasChangedFlags|=pr.POSITION,this._camera&&this._attachToScene()},i.onDisable=function(){this._camera&&this._detachFromScene()},i.onDestroy=function(){this._camera&&(this._camera.destroy(),this._camera=null),this._targetTexture&&this._targetTexture.off("resize")},i.screenPointToRay=function(t,e,i){return i||(i=gr.create()),this._camera&&this._camera.screenPointToRay(i,t,e),i},i.worldToScreen=function(t,e){return e||(e=new ji),this._camera&&this._camera.worldToScreen(e,t),e},i.screenToWorld=function(t,e){return e||(e=this.node.getWorldPosition()),this._camera&&this._camera.screenToWorld(e,t),e},i.convertToUINode=function(t,e,i){if(i||(i=new ji),!this._camera)return i;this.worldToScreen(t,b_);var n=e.getComponent("cc.UITransform"),r=We.view.getVisibleSize(),s=b_.x-.5*this._camera.width,a=b_.y-.5*this._camera.height;return b_.x=s/We.view.getScaleX()+.5*r.width,b_.y=a/We.view.getScaleY()+.5*r.height,n&&n.convertToNodeSpaceAR(b_,i),i},i._createCamera=function(){this._camera||(this._camera=We.director.root.createCamera(),this._camera.initialize({name:this.node.name,node:this.node,projection:this._projection,window:this._inEditorMode?We.director.root&&We.director.root.mainWindow:We.director.root&&We.director.root.tempWindow,priority:this._priority,cameraType:this.cameraType,trackingType:this.trackingType}),this._camera.setViewportInOrientedSpace(this._rect),this._camera.fovAxis=this._fovAxis,this._camera.fov=mr(this._fov),this._camera.orthoHeight=this._orthoHeight,this._camera.nearClip=this._near,this._camera.farClip=this._far,this._camera.clearColor=this._color,this._camera.clearDepth=this._depth,this._camera.clearStencil=this._stencil,this._camera.clearFlag=this._clearFlags,this._camera.visibility=this._visibility,this._camera.aperture=this._aperture,this._camera.shutter=this._shutter,this._camera.iso=this._iso),this._updateTargetTexture()},i._attachToScene=function(){this.node.scene&&this._camera&&(this._camera&&this._camera.scene&&this._camera.scene.removeCamera(this._camera),this._getRenderScene().addCamera(this._camera))},i._detachFromScene=function(){this._camera&&this._camera.scene&&this._camera.scene.removeCamera(this._camera)},i._checkTargetTextureEvent=function(t){var e=this;t&&t.off("resize"),this._targetTexture&&this._targetTexture.on("resize",(function(t){e._camera&&e._camera.setFixedSize(t.width,t.height)}),this)},i._updateTargetTexture=function(){if(this._camera&&this._targetTexture){var t=this._targetTexture.window;this._camera.changeTargetWindow(t),this._camera.setFixedSize(t.width,t.height)}},Pi(e,[{key:"camera",get:function(){return this._camera}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t,this._camera&&(this._camera.priority=t)}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t,this._camera&&(this._camera.visibility=t)}},{key:"clearFlags",get:function(){return this._clearFlags},set:function(t){this._clearFlags=t,this._camera&&(this._camera.clearFlag=t)}},{key:"clearColor",get:function(){return this._color},set:function(t){this._color.set(t),this._camera&&(this._camera.clearColor=this._color)}},{key:"clearDepth",get:function(){return this._depth},set:function(t){this._depth=t,this._camera&&(this._camera.clearDepth=t)}},{key:"clearStencil",get:function(){return this._stencil},set:function(t){this._stencil=t,this._camera&&(this._camera.clearStencil=t)}},{key:"projection",get:function(){return this._projection},set:function(t){this._projection=t,this._camera&&(this._camera.projectionType=t)}},{key:"fovAxis",get:function(){return this._fovAxis},set:function(t){t!==this._fovAxis&&(this._fovAxis=t,this._camera&&(this._camera.fovAxis=t,t===Ye.VERTICAL?this.fov=this._fov*this._camera.aspect:this.fov=this._fov/this._camera.aspect))}},{key:"fov",get:function(){return this._fov},set:function(t){this._fov=t,this._camera&&(this._camera.fov=mr(t))}},{key:"orthoHeight",get:function(){return this._orthoHeight},set:function(t){this._orthoHeight=t,this._camera&&(this._camera.orthoHeight=t)}},{key:"near",get:function(){return this._near},set:function(t){this._near=t,this._camera&&(this._camera.nearClip=t)}},{key:"far",get:function(){return this._far},set:function(t){this._far=t,this._camera&&(this._camera.farClip=t)}},{key:"aperture",get:function(){return this._aperture},set:function(t){this._aperture=t,this._camera&&(this._camera.aperture=t)}},{key:"shutter",get:function(){return this._shutter},set:function(t){this._shutter=t,this._camera&&(this._camera.shutter=t)}},{key:"iso",get:function(){return this._iso},set:function(t){this._iso=t,this._camera&&(this._camera.iso=t)}},{key:"rect",get:function(){return this._rect},set:function(t){this._rect=t,this._camera&&this._camera.setViewportInOrientedSpace(t)}},{key:"targetTexture",get:function(){return this._targetTexture},set:function(t){if(this._targetTexture!==t){var i=this._targetTexture;this._targetTexture=t,this._checkTargetTextureEvent(i),this._updateTargetTexture(),!t&&this._camera&&(this._camera.changeTargetWindow(null),this._camera.isWindowSize=!0),this.node.emit(e.TARGET_TEXTURE_CHANGE,this)}}},{key:"screenScale",get:function(){return this._screenScale},set:function(t){this._screenScale=t,this._camera&&(this._camera.screenScale=t)}},{key:"inEditorMode",get:function(){return this._inEditorMode},set:function(t){this._inEditorMode=t,this._camera&&this._camera.changeTargetWindow(t?We.director.root&&We.director.root.mainWindow:We.director.root&&We.director.root.tempWindow)}},{key:"cameraType",get:function(){return this._cameraType},set:function(t){this._cameraType!==t&&(this._cameraType=t,this.camera&&(this.camera.cameraType=t))}},{key:"trackingType",get:function(){return this._trackingType},set:function(t){this._trackingType!==t&&(this._trackingType=t,this.camera&&(this.camera.trackingType=t))}}]),e}(Pn),y_.ProjectionType=x_,y_.FOVAxis=w_,y_.ClearFlag=P_,y_.Aperture=M_,y_.Shutter=I_,y_.ISO=B_,y_.TARGET_TEXTURE_CHANGE="tex-change",$d=tn((Jd=T_).prototype,"_projection",[en],(function(){return x_.PERSPECTIVE})),t_=tn(Jd.prototype,"_priority",[en],(function(){return 0})),e_=tn(Jd.prototype,"_fov",[en],(function(){return 45})),i_=tn(Jd.prototype,"_fovAxis",[en],(function(){return w_.VERTICAL})),n_=tn(Jd.prototype,"_orthoHeight",[en],(function(){return 10})),r_=tn(Jd.prototype,"_near",[en],(function(){return 1})),s_=tn(Jd.prototype,"_far",[en],(function(){return 1e3})),a_=tn(Jd.prototype,"_color",[en],(function(){return new Ve("#333333")})),o_=tn(Jd.prototype,"_depth",[en],(function(){return 1})),h_=tn(Jd.prototype,"_stencil",[en],(function(){return 0})),l_=tn(Jd.prototype,"_clearFlags",[en],(function(){return P_.SOLID_COLOR})),u_=tn(Jd.prototype,"_rect",[en],(function(){return new un(0,0,1,1)})),c_=tn(Jd.prototype,"_aperture",[en],(function(){return M_.F16_0})),d_=tn(Jd.prototype,"_shutter",[en],(function(){return I_.D125})),__=tn(Jd.prototype,"_iso",[en],(function(){return B_.ISO100})),f_=tn(Jd.prototype,"_screenScale",[en],(function(){return 1})),p_=tn(Jd.prototype,"_visibility",[en],(function(){return vr})),g_=tn(Jd.prototype,"_targetTexture",[en],(function(){return null})),m_=tn(Jd.prototype,"_cameraType",[en],(function(){return Qe.DEFAULT})),v_=tn(Jd.prototype,"_trackingType",[en],(function(){return Je.NO_TRACKING})),gn(Jd.prototype,"visibility",[zd],Object.getOwnPropertyDescriptor(Jd.prototype,"visibility"),Jd.prototype),gn(Jd.prototype,"clearFlags",[Xd],Object.getOwnPropertyDescriptor(Jd.prototype,"clearFlags"),Jd.prototype),gn(Jd.prototype,"projection",[Wd],Object.getOwnPropertyDescriptor(Jd.prototype,"projection"),Jd.prototype),gn(Jd.prototype,"fovAxis",[Yd],Object.getOwnPropertyDescriptor(Jd.prototype,"fovAxis"),Jd.prototype),gn(Jd.prototype,"aperture",[jd],Object.getOwnPropertyDescriptor(Jd.prototype,"aperture"),Jd.prototype),gn(Jd.prototype,"shutter",[Kd],Object.getOwnPropertyDescriptor(Jd.prototype,"shutter"),Jd.prototype),gn(Jd.prototype,"iso",[qd],Object.getOwnPropertyDescriptor(Jd.prototype,"iso"),Jd.prototype),gn(Jd.prototype,"targetTexture",[Zd],Object.getOwnPropertyDescriptor(Jd.prototype,"targetTexture"),Jd.prototype),Qd=Jd))||Qd));We.Camera=D_;var O_=new dn,F_=((R_={})[Mi.ORIENTATION_AUTO]=yr.AUTO,R_[Mi.ORIENTATION_LANDSCAPE]=yr.LANDSCAPE,R_[Mi.ORIENTATION_PORTRAIT]=yr.PORTRAIT,R_),L_=t("View",function(t){function e(){var e;(e=t.call(this)||this)._designResolutionSize=void 0,e._scaleX=void 0,e._scaleY=void 0,e._viewportRect=void 0,e._visibleRect=void 0,e._autoFullScreen=void 0,e._retinaEnabled=void 0,e._resizeCallback=void 0,e._resolutionPolicy=void 0,e._rpExactFit=void 0,e._rpShowAll=void 0,e._rpNoBorder=void 0,e._rpFixedHeight=void 0,e._rpFixedWidth=void 0;var i=N_,n=k_;return e._designResolutionSize=new dn(0,0),e._scaleX=1,e._scaleY=1,e._viewportRect=new un(0,0,0,0),e._visibleRect=new un(0,0,0,0),e._autoFullScreen=!1,e._retinaEnabled=!1,e._resizeCallback=null,e._rpExactFit=new U_(i.EQUAL_TO_FRAME,n.EXACT_FIT),e._rpShowAll=new U_(i.EQUAL_TO_FRAME,n.SHOW_ALL),e._rpNoBorder=new U_(i.EQUAL_TO_FRAME,n.NO_BORDER),e._rpFixedHeight=new U_(i.EQUAL_TO_FRAME,n.FIXED_HEIGHT),e._rpFixedWidth=new U_(i.EQUAL_TO_FRAME,n.FIXED_WIDTH),e._resolutionPolicy=e._rpShowAll,e}He(e,t);var i=e.prototype;return i.init=function(){var t=Ar.windowSize,e=t.width,i=t.height;this._designResolutionSize.width=e,this._designResolutionSize.height=i,this._viewportRect.width=e,this._viewportRect.height=i,this._visibleRect.width=e,this._visibleRect.height=i,O_.width=this._visibleRect.width,O_.height=this._visibleRect.height,Bn&&Bn.init(this._visibleRect),this.resizeWithBrowserSize(!0);var n=Tr.querySettings(Sr.Category.SCREEN,"designResolution");n&&this.setDesignResolutionSize(Number(n.width),Number(n.height),n.policy||U_.FIXED_HEIGHT),Er.on("window-resize",this._updateAdaptResult,this),Er.on("orientation-change",this._updateAdaptResult,this),Er.on("fullscreen-change",this._updateAdaptResult,this)},i.resizeWithBrowserSize=function(t){Er.handleResizeEvent=t},i.setResizeCallback=function(t){"function"!=typeof t&&null!=t||(this._resizeCallback=t)},i.setOrientation=function(t){Er.orientation=F_[t]},i.adjustViewportMeta=function(){},i.enableRetina=function(t){this._retinaEnabled=!!t},i.isRetinaEnabled=function(){return this._retinaEnabled},i.enableAutoFullScreen=function(t){t!==this._autoFullScreen&&(this._autoFullScreen=t,t&&Ar.requestFullScreen().catch((function(){})))},i.isAutoFullScreenEnabled=function(){return this._autoFullScreen},i.setCanvasSize=function(t,e){Er.resolutionScale=1;var i=Er.devicePixelRatio,n=new dn(t*i,e*i);Ar.windowSize=n},i.getCanvasSize=function(){return Ar.windowSize},i.getFrameSize=function(){var t=Er.devicePixelRatio,e=Ar.windowSize;return e.width/=t,e.height/=t,e},i.setFrameSize=function(t,e){var i=Er.devicePixelRatio;Ar.windowSize=new dn(t*i,e*i)},i.getVisibleSize=function(){return new dn(this._visibleRect.width,this._visibleRect.height)},i.getVisibleSizeInPixel=function(){return new dn(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},i.getVisibleOrigin=function(){return new cn(this._visibleRect.x,this._visibleRect.y)},i.getVisibleOriginInPixel=function(){return new cn(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},i.getResolutionPolicy=function(){return this._resolutionPolicy},i._updateResolutionPolicy=function(t){if(t instanceof U_)this._resolutionPolicy=t;else{var e=U_;t===e.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit),t===e.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll),t===e.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder),t===e.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight),t===e.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},i.setResolutionPolicy=function(t){this._updateResolutionPolicy(t);var e=V_.getDesignResolutionSize();V_.setDesignResolutionSize(e.width,e.height,t)},i.setDesignResolutionSize=function(t,e,i){if(t>0&&e>0){this._updateResolutionPolicy(i);var n=this._resolutionPolicy;n&&n.preApply(this),this._designResolutionSize.width=t,this._designResolutionSize.height=e;var r=n.apply(this,this._designResolutionSize);if(r.scale&&2===r.scale.length&&(this._scaleX=r.scale[0],this._scaleY=r.scale[1]),r.viewport){var s=this._viewportRect,a=this._visibleRect,o=r.viewport;s.x=o.x,s.y=o.y,s.width=o.width,s.height=o.height,a.x=0,a.y=0,a.width=o.width/this._scaleX,a.height=o.height/this._scaleY}n.postApply(this),O_.width=this._visibleRect.width,O_.height=this._visibleRect.height,Bn&&Bn.init(this._visibleRect),this.emit("design-resolution-changed")}else hn(2200)},i.getDesignResolutionSize=function(){return new dn(this._designResolutionSize.width,this._designResolutionSize.height)},i.setRealPixelResolution=function(t,e,i){document.documentElement.style.width=t+"px",document.body.style.width=t+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(t,e,i)},i.getViewportRect=function(){return this._viewportRect},i.getScaleX=function(){return this._scaleX},i.getScaleY=function(){return this._scaleY},i.getDevicePixelRatio=function(){return Er.devicePixelRatio},i.convertToLocationInView=function(t,e,i,n){void 0===n&&(n=new cn);var r=Er.devicePixelRatio*(t-i.left),s=Er.devicePixelRatio*(i.top+i.height-e);return Er.isFrameRotated?(n.x=Ar.windowSize.width-s,n.y=r):(n.x=r,n.y=s),n},i._convertToUISpace=function(t){var e=this._viewportRect;t.x=(t.x-e.x)/this._scaleX,t.y=(t.y-e.y)/this._scaleY},i._updateAdaptResult=function(t,e,i){var n;We.director.root.resize(t,e,void 0===i?1:i);var r=this._designResolutionSize.width,s=this._designResolutionSize.height;t>0&&this.setDesignResolutionSize(r,s,this._resolutionPolicy),this.emit("canvas-resize"),null===(n=this._resizeCallback)||void 0===n||n.call(this)},e}(Cr(Oi)));L_.instance=void 0;var N_=function(){function t(){this.name="ContainerStrategy"}var e=t.prototype;return e.preApply=function(){},e.apply=function(){},e.postApply=function(){},e._setupCanvas=function(){var t=We.game.canvas;if(t){var e=Ar.windowSize;t.width=e.width,t.height=e.height}},t}();N_.EQUAL_TO_FRAME=void 0,N_.PROPORTION_TO_FRAME=void 0;var k_=function(){function t(){this.name="ContentStrategy",this._result=void 0,this._result={scale:[1,1],viewport:null}}var e=t.prototype;return e.preApply=function(){},e.apply=function(){return{scale:[1,1]}},e.postApply=function(){},e._buildResult=function(t,e,i,n,r,s){Math.abs(t-i)<2&&(i=t),Math.abs(e-n)<2&&(n=e);var a=new un(Math.round((t-i)/2),Math.round((e-n)/2),i,n);return this._result.scale=[r,s],this._result.viewport=a,this._result},t}();k_.EXACT_FIT=void 0,k_.SHOW_ALL=void 0,k_.NO_BORDER=void 0,k_.FIXED_HEIGHT=void 0,k_.FIXED_WIDTH=void 0,function(){var t=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="EqualToFrame",e}return He(e,t),e.prototype.apply=function(){Er.isProportionalToFrame=!1,this._setupCanvas()},e}(N_),e=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="ProportionalToFrame",e}return He(e,t),e.prototype.apply=function(){Er.isProportionalToFrame=!0,this._setupCanvas()},e}(N_);N_.EQUAL_TO_FRAME=new t,N_.PROPORTION_TO_FRAME=new e;var i=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="ExactFit",e}return He(e,t),e.prototype.apply=function(t,e){var i=Ar.windowSize,n=i.width,r=i.height,s=n/e.width,a=r/e.height;return this._buildResult(n,r,n,r,s,a)},e}(k_),n=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="ShowAll",e}return He(e,t),e.prototype.apply=function(t,e){var i,n,r=Ar.windowSize,s=r.width,a=r.height,o=e.width,h=e.height,l=s/o,u=a/h,c=0;return l<u?(i=s,n=h*(c=l)):(i=o*(c=u),n=a),this._buildResult(s,a,i,n,c,c)},e}(k_),r=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="NoBorder",e}return He(e,t),e.prototype.apply=function(t,e){var i,n,r,s=Ar.windowSize,a=s.width,o=s.height,h=e.width,l=e.height,u=a/h,c=o/l;return u<c?(n=h*(i=c),r=o):(n=a,r=l*(i=u)),this._buildResult(a,o,n,r,i,i)},e}(k_),s=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="FixedHeight",e}return He(e,t),e.prototype.apply=function(t,e){var i=Ar.windowSize,n=i.width,r=i.height,s=r/e.height,a=n,o=r;return this._buildResult(n,r,a,o,s,s)},e}(k_),a=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="FixedWidth",e}return He(e,t),e.prototype.apply=function(t,e){var i=Ar.windowSize,n=i.width,r=i.height,s=n/e.width,a=n,o=r;return this._buildResult(n,r,a,o,s,s)},e}(k_);k_.EXACT_FIT=new i,k_.SHOW_ALL=new n,k_.NO_BORDER=new r,k_.FIXED_HEIGHT=new s,k_.FIXED_WIDTH=new a}();var U_=t("ResolutionPolicy",function(){function t(t,e){this.name="ResolutionPolicy",this._containerStrategy=void 0,this._contentStrategy=void 0,this._containerStrategy=null,this._contentStrategy=null,this.setContainerStrategy(t),this.setContentStrategy(e)}var e=t.prototype;return e.preApply=function(t){this._contentStrategy.preApply(t)},e.apply=function(t,e){return this._containerStrategy.apply(t,e),this._contentStrategy.apply(t,e)},e.postApply=function(t){this._contentStrategy.postApply(t)},e.setContainerStrategy=function(t){t instanceof N_&&(this._containerStrategy=t)},e.setContentStrategy=function(t){t instanceof k_&&(this._contentStrategy=t)},Pi(t,[{key:"canvasSize",get:function(){return Ar.windowSize}}]),t}());U_.EXACT_FIT=0,U_.NO_BORDER=1,U_.SHOW_ALL=2,U_.FIXED_HEIGHT=3,U_.FIXED_WIDTH=4,U_.UNKNOWN=5,U_.ContainerStrategy=N_,U_.ContentStrategy=k_,We.ResolutionPolicy=U_;var G_,V_=t("view",L_.instance=We.view=new L_);Di.registerSystem("view",V_,0),We.winSize=O_;var H_,z_,X_,W_,Y_,j_,K_,q_,Z_,Q_=t("RenderRoot2D",Ki("cc.RenderRoot2D")(G_=In(100)(G_=kn(Bl)(G_=bn(G_=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.onEnable=function(){We.director.root.batcher2D.addScreen(this)},i.onDisable=function(){We.director.root.batcher2D.removeScreen(this)},i.onDestroy=function(){We.director.root.batcher2D.removeScreen(this)},e}(Pn))||G_)||G_)||G_)||G_),J_=new ji,$_=fr({OVERLAY:0,INTERSPERSE:1}),tf=function(e){return t({Canvas:e,CanvasComponent:e}),e}((H_=Ki("cc.Canvas"),z_=In(100),X_=Tn(D_),W_=Tn(D_),H_(Y_=z_(Y_=bn((j_=function(t){function e(){var e;return(e=t.call(this)||this)._cameraComponent=K_&&K_(),e._alignCanvasWithScreen=q_&&q_(),e._thisOnCameraResized=void 0,e._fitDesignResolution=void 0,e._pos=new ji,e._renderMode=$_.OVERLAY,e._thisOnCameraResized=e._onResizeCamera.bind(lr(e)),e}He(e,t);var i=e.prototype;return i.__preload=function(){var t=this.getComponent("cc.Widget");t&&t.updateAlignment(),this._cameraComponent&&(this._cameraComponent._createCamera(),this._cameraComponent.node.on(D_.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)),this._onResizeCamera(),this.node.on(xn.TRANSFORM_CHANGED,this._thisOnCameraResized)},i.onEnable=function(){t.prototype.onEnable.call(this),this._cameraComponent&&this._cameraComponent.node.on(D_.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)},i.onDisable=function(){t.prototype.onDisable.call(this),this._cameraComponent&&this._cameraComponent.node.off(D_.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)},i.onDestroy=function(){t.prototype.onDestroy.call(this),this.node.off(xn.TRANSFORM_CHANGED,this._thisOnCameraResized)},i._onResizeCamera=function(){if(this._cameraComponent&&this._alignCanvasWithScreen){if(this._cameraComponent.targetTexture)this._cameraComponent.orthoHeight=Bn.height/2;else{var t=Ar.windowSize;this._cameraComponent.orthoHeight=t.height/V_.getScaleY()/2}this.node.getWorldPosition(J_),this._cameraComponent.node.setWorldPosition(J_.x,J_.y,1e3)}},i._getViewPriority=function(){if(this._cameraComponent){var t,e=null===(t=this.cameraComponent)||void 0===t?void 0:t.priority;return this._renderMode===$_.OVERLAY?e|1<<30:e&~(1<<30)}return 0},Pi(e,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){this._renderMode=t,this._cameraComponent&&(this._cameraComponent.priority=this._getViewPriority())}},{key:"cameraComponent",get:function(){return this._cameraComponent},set:function(t){this._cameraComponent!==t&&(this._cameraComponent=t,this._onResizeCamera())}},{key:"alignCanvasWithScreen",get:function(){return this._alignCanvasWithScreen},set:function(t){this._alignCanvasWithScreen=t,this._onResizeCamera()}}]),e}(Q_),gn(j_.prototype,"cameraComponent",[X_],Object.getOwnPropertyDescriptor(j_.prototype,"cameraComponent"),j_.prototype),K_=tn(j_.prototype,"_cameraComponent",[W_],(function(){return null})),q_=tn(j_.prototype,"_alignCanvasWithScreen",[en],(function(){return!0})),Y_=j_))||Y_)||Y_)||Y_));We.Canvas=tf;var ef=t("UIComponent",Ki("cc.UIComponent")(Z_=kn(Bl)(Z_=In(110)(Z_=bn(Z_=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._lastParent=null,e.stencilStage=qh.DISABLED,e}He(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){},i.onDisable=function(){},i.onDestroy=function(){this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null)},i.postUpdateAssembler=function(){},i.markForUpdateRenderData=function(){},i.setNodeDirty=function(){},i.setTextureDirty=function(){},e}(Pn))||Z_)||Z_)||Z_)||Z_);function nf(t,e,i){var n=t.o,r=t.d,s=1/r.x,a=1/r.y,o=1/r.z,h=(e.x-n.x)*s,l=(i.x-n.x)*s,u=(e.y-n.y)*a,c=(i.y-n.y)*a,d=(e.z-n.z)*o,_=(i.z-n.z)*o,f=Math.max(Math.max(Math.min(h,l),Math.min(u,c)),Math.min(d,_)),p=Math.min(Math.min(Math.max(h,l),Math.max(u,c)),Math.max(d,_));return p<0||f>p?0:f>0?f:p}Vn(ef.prototype,"UIComponent",[{name:"_visibility"},{name:"setVisibility"}]),Vn(wu.prototype,"Renderable2D.prototype",[{name:"srcBlendFactor"},{name:"dstBlendFactor"}]),zn(tf.prototype,"Canvas.prototype",[{name:"camera",newName:"cameraComponent.camera",customGetter:function(){return this._cameraComponent.camera}},{name:"clearFlag",newName:"cameraComponent.clearFlags",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearFlags:0},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.clearFlags=t)}},{name:"color",newName:"cameraComponent.clearColor",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearColor:Ve.BLACK},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.clearColor=t)}},{name:"priority",newName:"cameraComponent.priority",customGetter:function(){return this._cameraComponent?this._cameraComponent.priority:0},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.priority=t)}},{name:"targetTexture",newName:"cameraComponent.targetTexture",customGetter:function(){return this._cameraComponent?this._cameraComponent.targetTexture:null},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.targetTexture=t)}},{name:"visibility",newName:"cameraComponent.visibility",customGetter:function(){return this._cameraComponent?this._cameraComponent.visibility:0}}]),Rr(Bl.prototype,"UITransform.prototype",[{name:"priority",suggest:"Please use setSiblingIndex to change index of the current node in its parent's children array."}]),We.UITransformComponent=Bl,br(Bl,"cc.UITransformComponent"),br(wu,"cc.RenderComponent"),We.CanvasComponent=tf,br(tf,"cc.CanvasComponent"),We.internal.Renderable2D=wu,br(wu,"cc.Renderable2D");var rf,sf,af,of,hf,lf,uf,cf=(rf=xr.create(),sf={distance:1/0,doubleSided:!1,mode:wr.ANY},af=0,of=function(t,e,i,n,r,s){t===wr.CLOSEST?(af>e||0===af)&&(af=e,s&&(0===s.length?s.push({distance:e,vertexIndex0:i/3,vertexIndex1:n/3,vertexIndex2:r/3}):(s[0].distance=e,s[0].vertexIndex0=i/3,s[0].vertexIndex1=n/3,s[0].vertexIndex2=r/3))):(af=e,s&&s.push({distance:e,vertexIndex0:i/3,vertexIndex1:n/3,vertexIndex2:r/3}))},function(t,e,i){if(af=0,0===e.geometricInfo.positions.length)return af;var n=void 0===i?sf:i;if(nf(t,e.geometricInfo.boundingBox.min,e.geometricInfo.boundingBox.max)){var r=e.primitiveMode,s=e.geometricInfo;!function(t,e,i,n,r){if(i===U.TRIANGLE_LIST)for(var s=e.length,a=0;a<s;a+=3){var o=3*e[a],h=3*e[a+1],l=3*e[a+2];ji.set(rf.a,t[o],t[o+1],t[o+2]),ji.set(rf.b,t[h],t[h+1],t[h+2]),ji.set(rf.c,t[l],t[l+1],t[l+2]);var u=Mr.rayTriangle(n,rf,r.doubleSided);if(!(0===u||u>r.distance)&&(of(r.mode,u,o,h,l,r.result),r.mode===wr.ANY))return u}else if(i===U.TRIANGLE_STRIP)for(var c=e.length-2,d=0,_=0;_<c;_+=1){var f=3*e[_-d],p=3*e[_+d+1],g=3*e[_+2];ji.set(rf.a,t[f],t[f+1],t[f+2]),ji.set(rf.b,t[p],t[p+1],t[p+2]),ji.set(rf.c,t[g],t[g+1],t[g+2]),d=~d;var m=Mr.rayTriangle(n,rf,r.doubleSided);if(!(0===m||m>r.distance)&&(of(r.mode,m,f,p,g,r.result),r.mode===wr.ANY))return m}else if(i===U.TRIANGLE_FAN){var v=e.length-1,y=3*e[0];ji.set(rf.a,t[y],t[y+1],t[y+2]);for(var T=1;T<v;T+=1){var S=3*e[T],E=3*e[T+1];ji.set(rf.b,t[S],t[S+1],t[S+2]),ji.set(rf.c,t[E],t[E+1],t[E+2]);var A=Mr.rayTriangle(n,rf,r.doubleSided);if(!(0===A||A>r.distance)&&(of(r.mode,A,y,S,E,r.result),r.mode===wr.ANY))return A}}}(s.positions,s.indices,r,t,n)}return af}),df=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:wr.ANY};return function(i,n,r){t=0;var s=void 0===r?e:r,a=n.renderingSubMeshes.length,o=n.struct.minPosition,h=n.struct.maxPosition;if(o&&h&&!nf(i,o,h))return t;for(var l=0;l<a;l++){var u=n.renderingSubMeshes[l],c=cf(i,u,s);if(c)if(s.mode===wr.CLOSEST)(0===t||t>c)&&(t=c,s.subIndices&&(s.subIndices[0]=l));else if(t=c,s.subIndices&&s.subIndices.push(l),s.mode===wr.ANY)return c}return t&&s.mode===wr.CLOSEST&&(s.result&&(s.result[0].distance=t,s.result.length=1),s.subIndices&&(s.subIndices.length=1)),t}}(),_f=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:wr.ANY},i=new gr,n=new Ue;return function(r,s,a){t=0;var o=void 0===a?e:a,h=s.worldBounds;if(h&&!Mr.rayAABB(r,h))return t;gr.copy(i,r),s.node&&(Ue.invert(n,s.node.getWorldMatrix(n)),ji.transformMat4(i.o,r.o,n),ji.transformMat4Normal(i.d,r.d,n));for(var l=s.subModels,u=0;u<l.length;u++){var c=l[u].subMesh,d=cf(i,c,o);if(d)if(o.mode===wr.CLOSEST)(0===t||t>d)&&(t=d,o.subIndices&&(o.subIndices[0]=u));else if(t=d,o.subIndices&&o.subIndices.push(u),o.mode===wr.ANY)return d}return t&&o.mode===wr.CLOSEST&&(o.result&&(o.result[0].distance=t,o.result.length=1),o.subIndices&&(o.subIndices.length=1)),t}}();Mr.rayModel=_f,Mr.raySubMesh=cf,Mr.rayMesh=df;var ff,pf,gf,mf,vf,yf,Tf,Sf,Ef,Af,Cf,Rf,bf,xf,wf,Mf,If,Bf=function(e){return t({ModelRenderer:e,RenderableComponent:e}),e}(Ki("cc.ModelRenderer")((lf=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._visFlags=uf&&uf(),e._models=[],e._priority=0,e}He(e,t);var i=e.prototype;return i._collectModels=function(){return this._models},i.onEnable=function(){this._updatePriority()},i._attachToScene=function(){},i._detachFromScene=function(){},i._onVisibilityChange=function(){},i._updatePriority=function(){if(this._models.length>0)for(var t=0;t<this._models.length;t++)this._models[t].priority=this._priority},Pi(e,[{key:"visibility",get:function(){return this._visFlags},set:function(t){this._visFlags=t,this._onVisibilityChange(t)}},{key:"priority",get:function(){return this._priority},set:function(t){t!==this._priority&&(this._priority=t,this._updatePriority())}}]),e}(ql),uf=tn(lf.prototype,"_visFlags",[en],(function(){return Xn.Enum.NONE})),hf=lf))||hf),Pf=en,Df=Tn;t("PrefabLink",(ff=Ki("cc.PrefabLink"),pf=Df(Ir),ff((mf=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).prefab=vf&&vf(),e}return He(e,t),e}(Pn),vf=tn(mf.prototype,"prefab",[pf,Pf],(function(){return null})),gf=mf))||gf)),zn(D_,"Camera",[{name:"CameraClearFlag",newName:"ClearFlag"}]),zn(D_.prototype,"Camera.prototype",[{name:"color",newName:"clearColor"},{name:"depth",newName:"clearDepth"},{name:"stencil",newName:"clearStencil"}]),We.CameraComponent=D_,br(D_,"cc.CameraComponent"),We.RenderableComponent=Bf,br(Bf,"cc.RenderableComponent"),function(t){t[t.SIMPLE=0]="SIMPLE",t[t.SLICED=1]="SLICED",t[t.TILED=2]="TILED"}(If||(If={})),t("SpriteRenderer",(yf=Ki("cc.SpriteRenderer"),Tf=In(100),Sf=Tn(Uo),yf(Ef=Tf((Af=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._spriteFrame=Cf&&Cf(),e._mode=Rf&&Rf(),e._color=bf&&bf(),e._flipX=xf&&xf(),e._flipY=wf&&wf(),e._size=Mf&&Mf(),e._model=null,e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._spriteFrame&&(this._spriteFrame.mesh||this._spriteFrame.ensureMeshData(),this._spriteFrame.mesh.initialize()),this._updateModels()},i.onRestore=function(){this._updateModels(),this.enabledInHierarchy&&this._attachToScene()},i.onEnable=function(){this._model||this._updateModels(),this._attachToScene()},i.onDisable=function(){this._model&&this._detachFromScene()},i.onDestroy=function(){this._model&&(We.director.root.destroyModel(this._model),this._model=null,this._models.length=0)},i._updateModels=function(){if(this._spriteFrame){var t=this._model;if(t?(t.destroy(),t.initialize(),t.node=t.transform=this.node):this._createModel(),this._model){var e=this._spriteFrame.mesh;this._model.createBoundingShape(e.struct.minPosition,e.struct.maxPosition),this._updateModelParams(),this._onUpdateLocalDescriptorSet()}}},i._createModel=function(){var t=this._model=We.director.root.createModel(ni);t.visFlags=this.visibility,t.node=t.transform=this.node,this._models.length=0,this._models.push(this._model)},i._updateModelParams=function(){if(this._spriteFrame&&this._model){this._spriteFrame.ensureMeshData();var t=this._spriteFrame.mesh;this.node.hasChangedFlags|=pr.POSITION,this._model.transform.hasChangedFlags|=pr.POSITION;var e=t?t.renderingSubMeshes.length:0,i=t.renderingSubMeshes;if(i)for(var n=0;n<e;++n){var r=this.getRenderMaterial(n);r&&!r.isValid&&(r=null);var s=i[n];s&&this._model.initSubModel(n,s,r||this._getBuiltinMaterial())}this._model.enabled=!0}},i._getBuiltinMaterial=function(){return Nn.get("missing-material")},i._onMaterialModified=function(e,i){t.prototype._onMaterialModified.call(this,e,i),this._spriteFrame&&this._model&&this._model.inited&&this._onRebuildPSO(e,i||this._getBuiltinMaterial())},i._onRebuildPSO=function(t,e){this._model&&this._model.inited&&(this._model.setSubModelMaterial(t,e),this._onUpdateLocalDescriptorSet())},i._onUpdateLocalDescriptorSet=function(){if(this._spriteFrame&&this._model&&this._model.inited)for(var t=this._spriteFrame.getGFXTexture(),e=this._spriteFrame.getGFXSampler(),i=this._model.subModels,n=Br.SAMPLER_SPRITE,r=0;r<i.length;r++){var s=i[r].descriptorSet;s.bindTexture(n,t),s.bindSampler(n,e),s.update()}},i._attachToScene=function(){if(this.node.scene&&this._model){var t=this._getRenderScene();null!==this._model.scene&&this._detachFromScene(),t.addModel(this._model)}},i._detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},Pi(e,[{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._spriteFrame!==t&&(this._spriteFrame,this._spriteFrame=t,this._spriteFrame&&(this._spriteFrame.ensureMeshData(),this._spriteFrame.mesh.initialize()),this._updateModels(),this.enabledInHierarchy&&this._attachToScene())}},{key:"model",get:function(){return this._model}}]),e}(Bf),gn(Af.prototype,"spriteFrame",[Sf],Object.getOwnPropertyDescriptor(Af.prototype,"spriteFrame"),Af.prototype),Cf=tn(Af.prototype,"_spriteFrame",[en],(function(){return null})),Rf=tn(Af.prototype,"_mode",[en],(function(){return If.SIMPLE})),bf=tn(Af.prototype,"_color",[en],(function(){return Ve.WHITE.clone()})),xf=tn(Af.prototype,"_flipX",[en],(function(){return!1})),wf=tn(Af.prototype,"_flipY",[en],(function(){return!1})),Mf=tn(Af.prototype,"_size",[en],(function(){return new cn})),Ef=Af))||Ef)||Ef));var Of,Ff,Lf,Nf,kf,Uf,Gf,Vf,Hf,zf,Xf,Wf,Yf,jf,Kf,qf,Zf,Qf,Jf,$f,tp,ep,ip,np,rp=new A_,sp="RICHTEXT_CHILD",ap="RICHTEXT_Image_CHILD",op=new En((function(t){if(!We.isValid(t.node))return!1;var e=t.node.getComponent(C_);return e&&(e.width=0),!0}),20),hp=new En((function(t){return We.isValid(t.node)}),10);function lp(t){return{node:new Pr(t),comp:null,lineCount:0,styleIndex:0,imageOffset:"",clickParam:"",clickHandler:"",type:t}}function up(t,e){var i;t===sp?i=op._get():t===ap&&(i=hp._get());var n=(i=i||lp(t)).node;return n||(n=new Pr(t)),n.hideFlags|=Dr.Flags.DontSave|Dr.Flags.HideInHierarchy,t===ap?(i.comp=n.getComponent(Bd)||n.addComponent(Bd),i.comp.spriteFrame=e,i.comp.type=Bd.Type.SLICED,i.comp.sizeMode=Bd.SizeMode.CUSTOM):(i.comp=n.getComponent(Mu)||n.addComponent(Mu),i.comp.string=e,i.comp.horizontalAlign=Cu.LEFT,i.comp.verticalAlign=Ru.TOP,i.comp.underlineHeight=2),n.setPosition(0,0,0),n._uiProps.uiTransformComp.setAnchorPoint(.5,.5),i.node=n,i.lineCount=0,i.styleIndex=0,i.imageOffset="",i.clickParam="",i.clickHandler="",i}var cp,dp=function(e){return t({RichText:e,RichTextComponent:e}),e}((Of=Ki("cc.RichText"),Ff=In(110),Lf=Tn(Cu),Nf=Tn(Ru),kf=Tn(Wo),Uf=Tn(xu),Gf=Tn(Vo),Of(Vf=Ff((np=ip=function(t){function e(){var e;return(e=t.call(this)||this)._lineHeight=zf&&zf(),e._string=Xf&&Xf(),e._horizontalAlign=Wf&&Wf(),e._verticalAlign=Yf&&Yf(),e._fontSize=jf&&jf(),e._maxWidth=Kf&&Kf(),e._fontFamily=qf&&qf(),e._font=Zf&&Zf(),e._isSystemFontUsed=Qf&&Qf(),e._userDefinedFont=Jf&&Jf(),e._cacheMode=$f&&$f(),e._imageAtlas=tp&&tp(),e._handleTouchEvent=ep&&ep(),e._textArray=[],e._segments=[],e._labelSegmentsCache=[],e._linesWidth=[],e._lineCount=1,e._labelWidth=0,e._labelHeight=0,e._layoutDirty=!0,e._lineOffsetX=0,e._updateRichTextStatus=void 0,e._labelChildrenNum=0,e._updateRichTextStatus=e._updateRichText,e}He(e,t);var i=e.prototype;return i.onLoad=function(){this.node.on(xn.LAYER_CHANGED,this._applyLayer,this),this.node.on(xn.ANCHOR_CHANGED,this._updateRichTextPosition,this)},i.onEnable=function(){this.handleTouchEvent&&this._addEventListeners(),this._updateRichText(),this._activateChildren(!0)},i.onDisable=function(){this.handleTouchEvent&&this._removeEventListeners(),this._activateChildren(!1)},i.onRestore=function(){},i.onDestroy=function(){for(var t,e=Fi(this._segments);!(t=e()).done;){var i=t.value;i.node.removeFromParent(),i.type===sp?op.put(i):i.type===ap&&hp.put(i)}this.node.off(xn.ANCHOR_CHANGED,this._updateRichTextPosition,this),this.node.off(xn.LAYER_CHANGED,this._applyLayer,this)},i._addEventListeners=function(){this.node.on(xn.TOUCH_END,this._onTouchEnded,this)},i._removeEventListeners=function(){this.node.off(xn.TOUCH_END,this._onTouchEnded,this)},i._updateLabelSegmentTextAttributes=function(){var t=this;this._segments.forEach((function(e){t._applyTextAttribute(e)}))},i._createFontLabel=function(t){return up(sp,t)},i._createImage=function(t){return up(ap,t)},i._onTTFLoaded=function(){this._font,this._layoutDirty=!0,this._updateRichText()},i.splitLongStringApproximatelyIn2048=function(t,e){var i=[];if(t.length*this.fontSize<=1638.4)return i.push(t),i;if(this._calculateSize(e,t).x<2048)i.push(t);else for(var n=t.split("\n"),r=0;r<n.length;r++)if(this._calculateSize(e,n[r]).x<2048)i.push(n[r]);else{var s=this.splitLongStringOver2048(n[r],e);i.push.apply(i,s)}return i},i.splitLongStringOver2048=function(t,e){for(var i=[],n=t,r=0,s=n.length/2,a=n.substring(r,s),o=n.substring(s),h=this._calculateSize(e,a),l=(this._calculateSize(e,o),1*this.maxWidth);h.x>l;){if((s/=2)<1){s*=2;break}a=a.substring(r,s),o=n.substring(s),h=this._calculateSize(e,a)}for(var u=1e3,c=1;u&&r<t.length;){for(;u&&h.x<l;){var d=Th(o);d&&d.length>0&&(c=d[0].length),s+=c,a=n.substring(r,s),o=n.substring(s),h=this._calculateSize(e,a),u--}for(;u&&a.length>=2&&h.x>l;)s-=c,a=n.substring(r,s),h=this._calculateSize(e,a),c=1,u--;if(a.length>=2){var _=Sh(a);_&&_.length>0&&a!==_[0]&&(s-=_[0].length,a=n.substring(r,s))}if(i.push(a),r=s,s+=a.length,a=n.substring(r,s),o=n.substring(s),u--,this._calculateSize(e,o).x<2048){r=t.length,s=t.length,a=o,i.push(a);break}h=this._calculateSize(e,a)}return i},i._measureText=function(t,e){var i=this,n=function(e){return i._calculateSize(t,e).width};return e?n(e):n},i._calculateSize=function(t,e){var i;return 0===this._labelSegmentsCache.length?(i=this._createFontLabel(e),this._labelSegmentsCache.push(i)):(i=this._labelSegmentsCache[0]).node.getComponent(Mu).string=e,i.styleIndex=t,this._applyTextAttribute(i),i.node._uiProps.uiTransformComp.contentSize},i._onTouchEnded=function(t){for(var e,i=this,n=this.node.getComponents(Pn),r=function(){var r=e.value,s=r.clickHandler,a=r.clickParam;s&&i._containsTouchLocation(r,t.touch.getUILocation())&&(n.forEach((function(e){var i=e[s];e.enabledInHierarchy&&i&&i.call(e,t,a)})),t.propagationStopped=!0)},s=Fi(this._segments);!(e=s()).done;)r()},i._containsTouchLocation=function(t,e){var i=t.node.getComponent(Bl);return!!i&&i.getBoundingBoxToWorld().contains(e)},i._resetState=function(){for(var t=this.node.children,e=t.length-1;e>=0;e--){var i=t[e];if(i.name===sp||i.name===ap){i.parent=null;var n=lp(i.name);n.node=i,i.name===sp?(n.comp=i.getComponent(Mu),op.put(n)):(n.comp=i.getComponent(Bd),hp.put(n)),this._labelChildrenNum--}}this._segments.length=0,this._labelSegmentsCache.length=0,this._linesWidth.length=0,this._lineOffsetX=0,this._lineCount=1,this._labelWidth=0,this._labelHeight=0,this._layoutDirty=!0},i._activateChildren=function(t){for(var e=this.node.children.length-1;e>=0;e--){var i=this.node.children[e];i.name!==sp&&i.name!==ap||(i.active=t)}},i._addLabelSegment=function(t,e){var i;if(0===this._labelSegmentsCache.length)i=this._createFontLabel(t);else{var n=(i=this._labelSegmentsCache.pop()).node.getComponent(Mu);n&&(n.string=t)}var r=i.comp;return r.verticalAlign!==this._verticalAlign&&(r.verticalAlign=this._verticalAlign),i.styleIndex=e,i.lineCount=this._lineCount,i.node._uiProps.uiTransformComp.setAnchorPoint(0,0),i.node.layer=this.node.layer,this.node.insertChild(i.node,this._labelChildrenNum++),this._applyTextAttribute(i),this._segments.push(i),i},i._updateRichTextWithMaxWidth=function(t,e,i){var n=e;if(this._lineOffsetX>0&&n+this._lineOffsetX>this._maxWidth)for(var r=0;this._lineOffsetX<=this._maxWidth;){var s=this._getFirstWordLen(t,r,t.length),a=t.substr(r,s),o=this._measureText(i,a);if(!(this._lineOffsetX+o<=this._maxWidth)){if(r>0){var h=t.substr(0,r);this._addLabelSegment(h,i),t=t.substr(r,t.length),n=this._measureText(i,t)}this._updateLineInfo();break}this._lineOffsetX+=o,r+=s}if(n>this._maxWidth)for(var l=Eh(t,n,this._maxWidth,this._measureText(i)),u=0;u<l.length;++u){var c=l[u],d=this._addLabelSegment(c,i).node._uiProps.uiTransformComp.contentSize;this._lineOffsetX+=d.width,l.length>1&&u<l.length-1&&this._updateLineInfo()}else this._lineOffsetX+=n,this._addLabelSegment(t,i)},i._isLastComponentCR=function(t){return t.length-1===t.lastIndexOf("\n")},i._updateLineInfo=function(){this._linesWidth.push(this._lineOffsetX),this._lineOffsetX=0,this._lineCount++},i._needsUpdateTextLayout=function(t){if(this._layoutDirty||!this._textArray||!t)return!0;if(this._textArray.length!==t.length)return!0;for(var e=0;e<this._textArray.length;e++){var i=this._textArray[e],n=t[e];if(i.text!==n.text)return!0;var r=i.style,s=n.style;if(r){if(s){if(!!s.outline!=!!r.outline)return!0;if(r.size!==s.size||r.italic!==s.italic||r.isImage!==s.isImage)return!0;if(r.src!==s.src||r.imageAlign!==s.imageAlign||r.imageHeight!==s.imageHeight||r.imageWidth!==s.imageWidth||r.imageOffset!==s.imageOffset)return!0}else if(r.size||r.italic||r.isImage||r.outline)return!0}else if(s&&(s.size||s.italic||s.isImage||s.outline))return!0}return!1},i._addRichTextImageElement=function(t){if(t.style){var e=t.style,i=e.src,n=this._imageAtlas&&i&&this._imageAtlas.getSpriteFrame(i);if(n){var r=this._createImage(n);switch(r.comp,e.imageAlign){case"top":r.node._uiProps.uiTransformComp.setAnchorPoint(0,1);break;case"center":r.node._uiProps.uiTransformComp.setAnchorPoint(0,.5);break;default:r.node._uiProps.uiTransformComp.setAnchorPoint(0,0)}e.imageOffset&&(r.imageOffset=e.imageOffset),r.node.layer=this.node.layer,this.node.insertChild(r.node,this._labelChildrenNum++),this._segments.push(r);var s=n.rect.clone(),a=1,o=s.width,h=s.height,l=e.imageWidth||0,u=e.imageHeight||0;u>0?(o*=a=u/h,h*=a):(o*=a=this._lineHeight/h,h*=a),l>0&&(o=l),this._maxWidth>0?(this._lineOffsetX+o>this._maxWidth&&this._updateLineInfo(),this._lineOffsetX+=o):(this._lineOffsetX+=o,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),r.node._uiProps.uiTransformComp.setContentSize(o,h),r.lineCount=this._lineCount,r.clickHandler="",r.clickParam="";var c=e.event;c&&(r.clickHandler=c.click,r.clickParam=c.param)}else Zi(4400)}},i._updateRichText=function(){if(this.enabledInHierarchy){var t=rp.parse(this._string);if(!this._needsUpdateTextLayout(t))return this._textArray=t.slice(),void this._updateLabelSegmentTextAttributes();this._textArray=t.slice(),this._resetState();for(var e,i=!1,n=0;n<this._textArray.length;++n){var r=this._textArray[n],s=r.text;if(void 0!==s){if(""===s){if(r.style&&r.style.isNewLine){this._updateLineInfo();continue}if(r.style&&r.style.isImage&&this._imageAtlas){this._addRichTextImageElement(r);continue}}for(var a=(s=this.splitLongStringApproximatelyIn2048(s,n).join("\n")).split("\n"),o=0;o<a.length;++o){var h=a[o];if(""!==h)if(i=!1,this._maxWidth>0){var l=this._measureText(n,h);this._updateRichTextWithMaxWidth(h,l,n),a.length>1&&o<a.length-1&&this._updateLineInfo()}else e=this._addLabelSegment(h,n),this._lineOffsetX+=e.node._uiProps.uiTransformComp.width,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX),a.length>1&&o<a.length-1&&this._updateLineInfo();else{if(this._isLastComponentCR(s)&&o===a.length-1)continue;this._updateLineInfo(),i=!0}}}}i||this._linesWidth.push(this._lineOffsetX),this._maxWidth>0&&(this._labelWidth=this._maxWidth),this._labelHeight=(this._lineCount+ah)*this._lineHeight,this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},i._getFirstWordLen=function(t,e,i){var n=t.charAt(e);if(gh(n)||mh(n))return 1;for(var r=1,s=e+1;s<i&&!mh(n=t.charAt(s))&&!gh(n);++s)r++;return r},i._updateRichTextPosition=function(){for(var t=0,e=1,i=this._lineCount,n=this.node._uiProps.uiTransformComp,r=n.anchorX,s=n.anchorY,a=0;a<this._segments.length;++a){var o=this._segments[a],h=o.lineCount;h>e&&(t=0,e=h);var l=this._labelWidth*(.5*this._horizontalAlign-r);switch(this._horizontalAlign){case Cu.LEFT:break;case Cu.CENTER:l-=this._linesWidth[h-1]/2;break;case Cu.RIGHT:l-=this._linesWidth[h-1]}var u=o.node.position;if(o.node.setPosition(t+l,this._lineHeight*(i-h)-this._labelHeight*s,u.z),h===e&&(t+=o.node._uiProps.uiTransformComp.width),o.node.getComponent(Bd)){var c=o.node.position.clone(),d=this._lineHeight,_=this._lineHeight*(1+ah);switch(o.node._uiProps.uiTransformComp.anchorY){case 1:c.y+=d+(_-d)/2;break;case.5:c.y+=_/2;break;default:c.y+=(_-d)/2}if(o.imageOffset){var f=o.imageOffset.split(",");if(1===f.length&&f[0]){var p=parseFloat(f[0]);Number.isInteger(p)&&(c.y+=p)}else if(2===f.length){var g=parseFloat(f[0]),m=parseFloat(f[1]);Number.isInteger(g)&&(c.x+=g),Number.isInteger(m)&&(c.y+=m)}}o.node.position=c}var v=o.node.getComponent(C_);if(v){var y=o.node.position.clone();y.y-=v.width,o.node.position=y}}},i._convertLiteralColorValue=function(t){var e=t.toUpperCase();return Ve[e]?Ve[e]:(new Ve).fromHEX(t)},i._applyTextAttribute=function(t){var e=t.node.getComponent(Mu);if(e){this._resetLabelState(e);var i,n=t.styleIndex;if(this._textArray[n]&&(i=this._textArray[n].style),i){if(e.color=this._convertLiteralColorValue(i.color||"white"),e.isBold=!!i.bold,e.isItalic=!!i.italic,e.isUnderline=!!i.underline,i.outline){var r=t.node.getComponent(C_);r||(r=t.node.addComponent(C_)),r.color=this._convertLiteralColorValue(i.outline.color),r.width=i.outline.width}e.fontSize=i.size||this._fontSize,t.clickHandler="",t.clickParam="";var s=i.event;s&&(t.clickHandler=s.click||"",t.clickParam=s.param||"")}e.cacheMode=this._cacheMode,this._font instanceof Wo&&!this._isSystemFontUsed?e.font=this._font:e.fontFamily=this._fontFamily,e.useSystemFont=this._isSystemFontUsed,e.lineHeight=this._lineHeight,e.updateRenderData(!0)}},i._applyLayer=function(){for(var t,e=Fi(this._segments);!(t=e()).done;)t.value.node.layer=this.node.layer},i._resetLabelState=function(t){t.fontSize=this._fontSize,t.color=Ve.WHITE,t.isBold=!1,t.isItalic=!1,t.isUnderline=!1},Pi(e,[{key:"string",get:function(){return this._string},set:function(t){this._string!==t&&(this._string=t,this._updateRichTextStatus())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(t){this.horizontalAlign!==t&&(this._horizontalAlign=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"verticalAlign",get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!==t&&(this._verticalAlign=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontSize",get:function(){return this._fontSize},set:function(t){this._fontSize!==t&&(this._fontSize=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"font",get:function(){return this._font},set:function(t){this._font!==t&&(this._font=t,this._layoutDirty=!0,this._font?(this.useSystemFont=!1,this._onTTFLoaded()):this.useSystemFont=!0,this._updateRichTextStatus())}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this._isSystemFontUsed=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode!==t&&(this._cacheMode=t,this._updateRichTextStatus())}},{key:"maxWidth",get:function(){return this._maxWidth},set:function(t){this._maxWidth!==t&&(this._maxWidth=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"imageAtlas",get:function(){return this._imageAtlas},set:function(t){this._imageAtlas!==t&&(this._imageAtlas=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"handleTouchEvent",get:function(){return this._handleTouchEvent},set:function(t){this._handleTouchEvent!==t&&(this._handleTouchEvent=t,this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners()))}}]),e}(Pn),ip.HorizontalAlign=Cu,ip.VerticalAlign=Ru,gn((Hf=np).prototype,"horizontalAlign",[Lf],Object.getOwnPropertyDescriptor(Hf.prototype,"horizontalAlign"),Hf.prototype),gn(Hf.prototype,"verticalAlign",[Nf],Object.getOwnPropertyDescriptor(Hf.prototype,"verticalAlign"),Hf.prototype),gn(Hf.prototype,"font",[kf],Object.getOwnPropertyDescriptor(Hf.prototype,"font"),Hf.prototype),gn(Hf.prototype,"cacheMode",[Uf],Object.getOwnPropertyDescriptor(Hf.prototype,"cacheMode"),Hf.prototype),gn(Hf.prototype,"imageAtlas",[Gf],Object.getOwnPropertyDescriptor(Hf.prototype,"imageAtlas"),Hf.prototype),zf=tn(Hf.prototype,"_lineHeight",[en],(function(){return 40})),Xf=tn(Hf.prototype,"_string",[en],(function(){return"<color=#00ff00>Rich</color><color=#0fffff>Text</color>"})),Wf=tn(Hf.prototype,"_horizontalAlign",[en],(function(){return Cu.LEFT})),Yf=tn(Hf.prototype,"_verticalAlign",[en],(function(){return Ru.TOP})),jf=tn(Hf.prototype,"_fontSize",[en],(function(){return 40})),Kf=tn(Hf.prototype,"_maxWidth",[en],(function(){return 0})),qf=tn(Hf.prototype,"_fontFamily",[en],(function(){return"Arial"})),Zf=tn(Hf.prototype,"_font",[en],(function(){return null})),Qf=tn(Hf.prototype,"_isSystemFontUsed",[en],(function(){return!0})),Jf=tn(Hf.prototype,"_userDefinedFont",[en],(function(){return null})),$f=tn(Hf.prototype,"_cacheMode",[en],(function(){return xu.NONE})),tp=tn(Hf.prototype,"_imageAtlas",[en],(function(){return null})),ep=tn(Hf.prototype,"_handleTouchEvent",[en],(function(){return!0})),Vf=Hf))||Vf)||Vf));We.RichText=dp;var _p=function(e){return t({UIMeshRenderer:e,UIModelComponent:e}),e}(Ki("cc.UIMeshRenderer")(cp=In(110)(cp=function(t){function e(){var e;return(e=t.call(this)||this)._modelComponent=null,e._dirtyVersion=-1,e._internalId=-1,e.stencilStage=qh.DISABLED,e._renderData=null,e._renderEntity=new ml(Jh.DYNAMIC),e}He(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){Ln.addRenderer(this),this.markForUpdateRenderData()},i.onDisable=function(){Ln.removeRenderer(this),this.renderEntity.enabled=this._canRender()},i.onLoad=function(){this.node._uiProps.uiTransformComp||this.node.addComponent("cc.UITransform"),this._modelComponent=this.getComponent("cc.ModelRenderer"),this._modelComponent?this.renderEntity.setNode(this.node):console.warn("node '"+(this.node&&this.node.name)+"' doesn't have any renderable component")},i.onDestroy=function(){this.renderEntity.setNode(null),this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this._modelComponent=this.getComponent("cc.ModelRenderer"),this._modelComponent&&(this._modelComponent._sceneGetter=null)},i._render=function(t){if(this._modelComponent){var e=this._modelComponent._collectModels();this._modelComponent._detachFromScene();for(var i=0;i<e.length;i++)e[i].enabled&&t.commitModel(this,e[i],this._modelComponent.material);return!0}return!1},i.fillBuffers=function(t){this.enabled&&this._render(t)},i.updateRenderer=function(){},i._uploadRenderData=function(){},i.postUpdateAssembler=function(){},i.update=function(){this._fitUIRenderQueue()},i._fitUIRenderQueue=function(){if(this._modelComponent)for(var t=this._modelComponent.sharedMaterials.length,e=0;e<t;e++){var i=this._modelComponent.getMaterialInstance(e);if(null!=i)for(var n=i.passes,r=n.length,s=0;s<r;s++)n[s]._priority=Or.MAX-11,i.recompileShaders({CC_FORCE_FORWARD_SHADING:!0},s)}},i.markForUpdateRenderData=function(){Ln.markDirtyRenderer(this)},i.setNodeDirty=function(){},i.setTextureDirty=function(){},i._canRender=function(){return this.enabled&&null!==this._modelComponent},Pi(e,[{key:"modelComponent",get:function(){return this._modelComponent}},{key:"renderEntity",get:function(){return this._renderEntity}},{key:"renderData",get:function(){return this._renderData}}]),e}(Pn))||cp)||cp);We.UIMeshRenderer=_p;var fp,pp,gp,mp,vp,yp,Tp,Sp,Ep,Ap,Cp=Xn.Enum.NONE|Xn.Enum.UI_3D,Rp=function(){function t(){this.model=null,this.texture=null,this.sampler=null,this.useLocalData=null,this.isStatic=!1,this.textureHash=0,this.samplerHash=0,this._passes=[],this._shaders=[],this._visFlags=Cp,this._inputAssembler=null,this._descriptorSet=null}var e=t.prototype;return e.destroy=function(){this._passes=[]},e.clear=function(){this._inputAssembler=null,this._descriptorSet=null,this.texture=null,this.sampler=null,this.textureHash=0,this.samplerHash=0,this.model=null,this.isStatic=!1,this.useLocalData=null,this.visFlags=Cp},e.fillPasses=function(t,e,i,n){if(t){var r=t.passes;if(!r)return;this._shaders.length=r.length;for(var s=0;s<r.length;s++){this._passes[s]||(this._passes[s]=new Wn(We.director.root));var a=r[s],o=this._passes[s];a.update(),e||(e=a.depthStencilState,i=0),o._initPassFromTarget(a,e,i),this._shaders[s]=o.getShaderVariant(n)}}},Pi(t,[{key:"inputAssembler",get:function(){return this._inputAssembler},set:function(t){this._inputAssembler=t}},{key:"descriptorSet",get:function(){return this._descriptorSet},set:function(t){this._descriptorSet=t}},{key:"visFlags",get:function(){return this._visFlags},set:function(t){this._visFlags=t}},{key:"passes",get:function(){return this._passes}},{key:"shaders",get:function(){return this._shaders}}]),t}(),bp=function(e){return t({UIStaticBatch:e,UIStaticBatchComponent:e}),e}(Ki("cc.UIStaticBatch")(fp=In(110)((pp=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._init=!1,e._bufferAccessor=null,e._dirty=!0,e._uiDrawBatchList=[],e}He(e,t);var i=e.prototype;return i.postUpdateAssembler=function(){},i.markAsDirty=function(){},i._requireDrawBatch=function(){var t=new Rp;return t.isStatic=!0,this._uiDrawBatchList.push(t),t},i._clearData=function(){if(this._bufferAccessor){this._bufferAccessor.reset();for(var t=this._getBatcher(),e=0;e<this._uiDrawBatchList.length;e++)this._uiDrawBatchList[e].destroy(t)}this._uiDrawBatchList.length=0,this._init=!1},i._getBatcher=function(){return Di.root&&Di.root.batcher2D?Di.root.batcher2D:(Zi(9301),null)},Pi(e,[{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&this._color.set(t)}},{key:"drawBatchList",get:function(){return this._uiDrawBatchList}}]),e}(wu),gn(pp.prototype,"color",[mn],Object.getOwnPropertyDescriptor(pp.prototype,"color"),pp.prototype),fp=pp))||fp)||fp),xp=t("LabelShadow",Ki("cc.LabelShadow")(gp=In(110)(gp=kn(Mu)((mp=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._color=vp&&vp(),e._offset=yp&&yp(),e._blur=Tp&&Tp(),e}He(e,t);var i=e.prototype;return i.onEnable=function(){this._updateRenderData()},i.onDisable=function(){this._updateRenderData()},i._updateRenderData=function(){var t=this.node.getComponent(Mu);t&&t.updateRenderData(!0)},Pi(e,[{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&(this._color.set(t),this._updateRenderData())}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset=t,this._updateRenderData()}},{key:"blur",get:function(){return this._blur},set:function(t){this._blur=t,this._updateRenderData()}}]),e}(Pn),vp=tn(mp.prototype,"_color",[en],(function(){return new Ve(0,0,0,255)})),yp=tn(mp.prototype,"_offset",[en],(function(){return new cn(2,2)})),Tp=tn(mp.prototype,"_blur",[en],(function(){return 2})),gp=mp))||gp)||gp)||gp),wp=function(e){return t({UIOpacity:e,UIOpacityComponent:e}),e}(Ki("cc.UIOpacity")(Sp=In(110)(Sp=bn((Ep=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._opacity=Ap&&Ap(),e}He(e,t);var i=e.prototype;return i.setEntityLocalOpacityDirtyRecursively=function(){},e.setEntityLocalOpacityDirtyRecursively=function(t,i,n){if(t.isValid){var r=t._uiProps.uiComp,s=t.getComponent(e),a=n;r&&r.color?(r.renderEntity.colorDirty=i,r.renderEntity.localOpacity=s?a*s.opacity/255:a,a=1):s&&(a=a*s.opacity/255);for(var o=0;o<t.children.length;o++)e.setEntityLocalOpacityDirtyRecursively(t.children[o],i||a<1,a)}},i.onEnable=function(){this.node._uiProps.localOpacity=this._opacity/255,this.setEntityLocalOpacityDirtyRecursively(!0)},i.onDisable=function(){this.node._uiProps.localOpacity=1,this.setEntityLocalOpacityDirtyRecursively(!0)},Pi(e,[{key:"opacity",get:function(){return this._opacity},set:function(t){this._opacity!==t&&(t=Fr(t,0,255),this._opacity=t,this.node._uiProps.localOpacity=t/255,this.setEntityLocalOpacityDirtyRecursively(!0))}}]),e}(Pn),Ap=tn(Ep.prototype,"_opacity",[en],(function(){return 255})),Sp=Ep))||Sp)||Sp)||Sp);We.MaskComponent=Nd,br(Nd,"cc.MaskComponent"),We.LabelComponent=Mu,br(Mu,"cc.LabelComponent"),We.LabelOutlineComponent=C_,br(C_,"cc.LabelOutlineComponent"),We.RichTextComponent=dp,br(dp,"cc.RichTextComponent"),We.SpriteComponent=Bd,br(Bd,"cc.SpriteComponent"),We.UIModelComponent=_p,br(_p,"cc.UIModelComponent"),We.GraphicsComponent=yd,br(yd,"cc.GraphicsComponent"),br(bp,"cc.UIStaticBatchComponent"),br(wp,"cc.UIOpacityComponent"),zn(Nd.prototype,"Mask",[{name:"graphics",newName:"subComp",target:Nd.prototype,targetName:"Mask"}]),zn(Pd,"MaskType",[{name:"RECT",newName:"GRAPHICS_RECT",target:Pd,targetName:"MaskType"},{name:"ELLIPSE",newName:"GRAPHICS_ELLIPSE",target:Pd,targetName:"MaskType"},{name:"IMAGE_STENCIL",newName:"SPRITE_STENCIL",target:Pd,targetName:"MaskType"}]);var Mp=function(t,e,i){this.i=void 0,this.x=void 0,this.y=void 0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=e,this.y=i};function Ip(t,e,i,n,r){var s=0,a=null;if(r===function(t,e,i,n){for(var r=0,s=e,a=i-n;s<i;s+=n)r+=(t[a]-t[s])*(t[s+1]+t[a+1]),a=s;return r}(t,e,i,n)>0)for(s=e;s<i;s+=n)a=Kp(s,t[s],t[s+1],a);else for(s=i-n;s>=e;s-=n)a=Kp(s,t[s],t[s+1],a);return a&&Xp(a,a.next)&&(qp(a),a=a.next),a}function Bp(t,e){if(void 0===e&&(e=null),!t)return t;e||(e=t);var i=t,n=!1;do{if(n=!1,i.steiner||!Xp(i,i.next)&&0!==zp(i.prev,i,i.next))i=i.next;else{if(qp(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function Pp(t,e,i,n,r,s,a){if(void 0===a&&(a=0),t){!a&&s&&function(t,e,i,n){var r=t;do{null===r.z&&(r.z=Up(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e=0,i=null,n=null,r=null,s=null,a=0,o=0,h=0,l=1;do{for(i=t,t=null,s=null,a=0;i;){for(a++,n=i,o=0,e=0;e<l&&(o++,n=n.nextZ);e++);for(h=l;o>0||h>0&&n;)0===o?(r=n,n=n.nextZ,h--):0!==h&&n?i.z<=n.z?(r=i,i=i.nextZ,o--):(r=n,n=n.nextZ,h--):(r=i,i=i.nextZ,o--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,l*=2}while(a>1)}(r)}(t,n,r,s);for(var o=t,h=null,l=null;t.prev!==t.next;)if(h=t.prev,l=t.next,s?Op(t,n,r,s):Dp(t))e.push(h.i/i),e.push(t.i/i),e.push(l.i/i),qp(t),t=l.next,o=l.next;else if((t=l)===o){a?1===a?Pp(t=Fp(t,e,i),e,i,n,r,s,2):2===a&&Lp(t,e,i,n,r,s):Pp(Bp(t),e,i,n,r,s,1);break}}}function Dp(t){var e=t.prev,i=t,n=t.next;if(zp(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(Vp(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&zp(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Op(t,e,i,n){var r=t.prev,s=t,a=t.next;if(zp(r,s,a)>=0)return!1;for(var o=r.x<s.x?r.x<a.x?r.x:a.x:s.x<a.x?s.x:a.x,h=r.y<s.y?r.y<a.y?r.y:a.y:s.y<a.y?s.y:a.y,l=r.x>s.x?r.x>a.x?r.x:a.x:s.x>a.x?s.x:a.x,u=r.y>s.y?r.y>a.y?r.y:a.y:s.y>a.y?s.y:a.y,c=Up(o,h,e,i,n),d=Up(l,u,e,i,n),_=t.nextZ;_&&_.z<=d;){if(_!==t.prev&&_!==t.next&&Vp(r.x,r.y,s.x,s.y,a.x,a.y,_.x,_.y)&&zp(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(_=t.prevZ;_&&_.z>=c;){if(_!==t.prev&&_!==t.next&&Vp(r.x,r.y,s.x,s.y,a.x,a.y,_.x,_.y)&&zp(_.prev,_,_.next)>=0)return!1;_=_.prevZ}return!0}function Fp(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!Xp(r,s)&&Wp(r,n,n.next,s)&&Yp(r,s)&&Yp(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),qp(n),qp(n.next),n=t=s),n=n.next}while(n!==t);return n}function Lp(t,e,i,n,r,s){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Hp(a,o)){var h=jp(a,o);return a=Bp(a,a.next),h=Bp(h,h.next),Pp(a,e,i,n,r,s),void Pp(h,e,i,n,r,s)}o=o.next}a=a.next}while(a!==t)}function Np(t,e){return t.x-e.x}function kp(t,e){if(e=function(t,e){var i=e,n=t.x,r=t.y,s=-1/0,a=null;do{if(r<=i.y&&r>=i.next.y){var o=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=n&&o>s){if(s=o,o===n){if(r===i.y)return i;if(r===i.next.y)return i.next}a=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!a)return null;if(n===s)return a.prev;var h,l=a,u=a.x,c=a.y,d=1/0;for(i=a.next;i!==l;)n>=i.x&&i.x>=u&&Vp(r<c?n:s,r,u,c,r<c?s:n,r,i.x,i.y)&&((h=Math.abs(r-i.y)/(n-i.x))<d||h===d&&i.x>a.x)&&Yp(i,t)&&(a=i,d=h),i=i.next;return a}(t,e)){var i=jp(e,t);Bp(i,i.next)}}function Up(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Gp(t){var e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i}function Vp(t,e,i,n,r,s,a,o){return(r-a)*(e-o)-(t-a)*(s-o)>=0&&(t-a)*(n-o)-(i-a)*(e-o)>=0&&(i-a)*(s-o)-(r-a)*(n-o)>=0}function Hp(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Wp(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&Yp(t,e)&&Yp(e,t)&&function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function zp(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Xp(t,e){return t.x===e.x&&t.y===e.y}function Wp(t,e,i,n){return!!(Xp(t,e)&&Xp(i,n)||Xp(t,n)&&Xp(i,e))||zp(t,e,i)>0!=zp(t,e,n)>0&&zp(i,n,t)>0!=zp(i,n,e)>0}function Yp(t,e){return zp(t.prev,t,t.next)<0?zp(t,e,t.next)>=0&&zp(t,t.prev,e)>=0:zp(t,e,t.prev)<0||zp(t,t.next,e)<0}function jp(t,e){var i=new Mp(t.i,t.x,t.y),n=new Mp(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Kp(t,e,i,n){var r=new Mp(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function qp(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Zp(t,e,i){i=i||3;var n=e?e.length:0,r=n?e[0]*i:t.length,s=Ip(t,0,r,i,!0),a=[];if(!s)return a;var o=0,h=0,l=0,u=0,c=0,d=0,_=0;if(n&&(s=function(t,e,i,n){var r,s=[],a=0,o=null;for(a=0,r=e.length;a<r;a++)(o=Ip(t,e[a]*n,a<r-1?e[a+1]*n:t.length,n,!1))&&(o===o.next&&(o.steiner=!0),s.push(Gp(o)));if(s.sort(Np),!i)return i;for(a=0;a<s.length;a++)kp(s[a],i),i=Bp(i,i.next);return i}(t,e,s,i)),t.length>80*i){o=l=t[0],h=u=t[1];for(var f=i;f<r;f+=i)(c=t[f])<o&&(o=c),(d=t[f+1])<h&&(h=d),c>l&&(l=c),d>u&&(u=d);_=Math.max(l-o,u-h)}return Pp(s,a,i,o,h,_),a}for(var Qp=Math.PI,Jp=Math.min,$p=Math.max,tg=Math.ceil,eg=Math.acos,ig=Math.cos,ng=Math.sin,rg=Math.atan2,sg=null,ag=null,og=new Ve,hg=[],lg=0;lg<4;lg++)hg.push(new ji);function ug(t,e,i){return t<e?e:t>i?i:t}var cg={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(t,e){if(!ag)return null;var i=ag.getRenderDataList(),n=i[ag.dataOffset];if(!n)return null;var r=n,s=r?r.vertexStart+e:0;return(s>65535||3*s>131070)&&(++ag.dataOffset,ag.dataOffset<i.length?n=i[ag.dataOffset]:(n=ag.requestRenderData(),i[ag.dataOffset]=n),r=n),r&&r.vertexCount<s&&r.request(e,3*e),n},stroke:function(t){Ve.copy(og,t.strokeColor),t.impl&&(this._flattenPaths(t.impl),this._expandStroke(t),t.impl.updatePathOffset=!0,this.end(t))},fill:function(t){Ve.copy(og,t.fillColor),this._expandFill(t),t.impl&&(t.impl.updatePathOffset=!0),this.end(t)},end:function(t){t.markForUpdateRenderData()},_expandStroke:function(t){var e=.5*t.lineWidth,i=t.lineCap,n=t.lineJoin,r=t.miterLimit;if(ag=t.impl){var s=function(t,e,i){var n=2*eg(t/(t+i));return $p(2,tg(e/n))}(e,Qp,ag.tessTol);this._calculateJoins(ag,e,n,r);for(var a=ag.paths,o=0,h=ag.pathOffset,l=ag.pathLength;h<l;h++){var u=a[h],c=u.points.length;n===fc.ROUND?o+=2*(c+u.bevel*(s+2)+1):o+=2*(c+5*u.bevel+1),u.closed||(i===_c.ROUND?o+=2*(2*s+2):o+=12)}var d=sg=this.getRenderData(t,o);if(d){for(var _=d.vData,f=d.iData,p=ag.pathOffset,g=ag.pathLength;p<g;p++){var m=a[p],v=m.points,y=v.length,T=d.vertexStart,S=void 0,E=void 0,A=0,C=0,R=m.closed;if(R?(S=v[y-1],E=v[0],A=0,C=y):(S=v[0],E=v[1],A=1,C=y-1),E=E||S,!R){var b=new _d(E.x,E.y);b.subtract(S),b.normalize();var x=b.x,w=b.y;i===_c.BUTT?this._buttCapStart(S,x,w,e,0):i===_c.SQUARE?this._buttCapStart(S,x,w,e,e):i===_c.ROUND&&this._roundCapStart(S,x,w,e,s)}for(var M=A;M<C;++M)n===fc.ROUND?this._roundJoin(S,E,e,e,s):0!=(E.flags&(pc.PT_BEVEL|pc.PT_INNERBEVEL))?this._bevelJoin(S,E,e,e):(this._vSet(E.x+E.dmx*e,E.y+E.dmy*e,1),this._vSet(E.x-E.dmx*e,E.y-E.dmy*e,-1)),S=E,E=v[M+1];if(R){var I=8*T;this._vSet(_[I],_[I+1],1),this._vSet(_[I+8],_[I+8+1],-1)}else{var B=new _d(E.x,E.y);B.subtract(S),B.normalize();var P=B.x,D=B.y;i===_c.BUTT?this._buttCapEnd(E,P,D,e,0):i===_c.SQUARE?this._buttCapEnd(E,P,D,e,e):i===_c.ROUND&&this._roundCapEnd(E,P,D,e,s)}for(var O=d.indexStart,F=T+2,L=d.vertexStart;F<L;F++)f[O++]=F-2,f[O++]=F-1,f[O++]=F;d.indexStart=O}sg=null,ag=null}}},_expandFill:function(t){if(ag=t.impl){for(var e=ag.paths,i=0,n=ag.pathOffset,r=ag.pathLength;n<r;n++)i+=e[n].points.length;var s=sg=this.getRenderData(t,i);if(s){for(var a=s,o=a.vData,h=a.iData,l=ag.pathOffset,u=ag.pathLength;l<u;l++){var c=e[l],d=c.points,_=d.length;if(0!==_){for(var f=s.vertexStart,p=0;p<_;++p)this._vSet(d[p].x,d[p].y);var g=s.indexStart;if(c.complex){for(var m=[],v=f,y=s.vertexStart;v<y;v++){var T=8*v;m.push(o[T++]),m.push(o[T++]),m.push(o[T++])}var S=Zp(m,null,3);if(!S||0===S.length)continue;for(var E=0,A=S.length;E<A;E++)h[g++]=S[E]+f}else for(var C=f,R=f+2,b=a.vertexStart;R<b;R++)h[g++]=C,h[g++]=R-1,h[g++]=R;a.indexStart=g}}sg=null,ag=null}}},_calculateJoins:function(t,e,i,n){var r=0;e>0&&(r=1/e);for(var s=t.paths,a=t.pathOffset,o=t.pathLength;a<o;a++){var h=s[a],l=h.points,u=l.length,c=l[u-1],d=l[0];h.bevel=0;for(var _=0;_<u;_++){var f,p,g=c.dy,m=-c.dx,v=d.dy,y=-d.dx;if(d.dmx=.5*(g+v),d.dmy=.5*(m+y),(f=d.dmx*d.dmx+d.dmy*d.dmy)>1e-6){var T=1/f;T>600&&(T=600),d.dmx*=T,d.dmy*=T}d.dx*c.dy-c.dx*d.dy>0&&(d.flags|=pc.PT_LEFT),f*(p=$p(11,Jp(c.len,d.len)*r))*p<1&&(d.flags|=pc.PT_INNERBEVEL),d.flags&pc.PT_CORNER&&(f*n*n<1||i===fc.BEVEL||i===fc.ROUND)&&(d.flags|=pc.PT_BEVEL),0!=(d.flags&(pc.PT_BEVEL|pc.PT_INNERBEVEL))&&h.bevel++,c=d,d=l[_+1]}}},_flattenPaths:function(t){for(var e=t.paths,i=t.pathOffset,n=t.pathLength;i<n;i++){var r=e[i],s=r.points,a=s[s.length-1],o=s[0];s.length>2&&a.equals(o)&&(r.closed=!0,s.pop(),a=s[s.length-1]);for(var h=0,l=s.length;h<l;h++){var u=new _d(o.x,o.y);u.subtract(a),a.len=u.length(),(u.x||u.y)&&u.normalize(),a.dx=u.x,a.dy=u.y,a=o,o=s[h+1]}}},_chooseBevel:function(t,e,i,n){var r=i.x,s=i.y,a=0,o=0,h=0,l=0;return 0!==t?(a=r+e.dy*n,o=s-e.dx*n,h=r+i.dy*n,l=s-i.dx*n):(a=h=r+i.dmx*n,o=l=s+i.dmy*n),[a,o,h,l]},_buttCapStart:function(t,e,i,n,r){var s=t.x-e*r,a=t.y-i*r,o=i,h=-e;this._vSet(s+o*n,a+h*n,1),this._vSet(s-o*n,a-h*n,-1)},_buttCapEnd:function(t,e,i,n,r){var s=t.x+e*r,a=t.y+i*r,o=i,h=-e;this._vSet(s+o*n,a+h*n,1),this._vSet(s-o*n,a-h*n,-1)},_roundCapStart:function(t,e,i,n,r){for(var s=t.x,a=t.y,o=i,h=-e,l=0;l<r;l++){var u=l/(r-1)*Qp,c=ig(u)*n,d=ng(u)*n;this._vSet(s-o*c-e*d,a-h*c-i*d,1),this._vSet(s,a,0)}this._vSet(s+o*n,a+h*n,1),this._vSet(s-o*n,a-h*n,-1)},_roundCapEnd:function(t,e,i,n,r){var s=t.x,a=t.y,o=i,h=-e;this._vSet(s+o*n,a+h*n,1),this._vSet(s-o*n,a-h*n,-1);for(var l=0;l<r;l++){var u=l/(r-1)*Qp,c=ig(u)*n,d=ng(u)*n;this._vSet(s,a,0),this._vSet(s-o*c+e*d,a-h*c+i*d,1)}},_roundJoin:function(t,e,i,n,r){var s=t.dy,a=-t.dx,o=e.dy,h=-e.dx,l=e.x,u=e.y;if(0!=(e.flags&pc.PT_LEFT)){var c=this._chooseBevel(e.flags&pc.PT_INNERBEVEL,t,e,i),d=c[0],_=c[1],f=c[2],p=c[3],g=rg(-a,-s),m=rg(-h,-o);m>g&&(m-=2*Qp),this._vSet(d,_,1),this._vSet(l-s*n,e.y-a*n,-1);for(var v=ug(tg((g-m)/Qp)*r,2,r),y=0;y<v;y++){var T=g+y/(v-1)*(m-g),S=l+ig(T)*n,E=u+ng(T)*n;this._vSet(l,u,0),this._vSet(S,E,-1)}this._vSet(f,p,1),this._vSet(l-o*n,u-h*n,-1)}else{var A=this._chooseBevel(e.flags&pc.PT_INNERBEVEL,t,e,-n),C=A[0],R=A[1],b=A[2],x=A[3],w=rg(a,s),M=rg(h,o);M<w&&(M+=2*Qp),this._vSet(l+s*n,u+a*n,1),this._vSet(C,R,-1);for(var I=ug(tg((M-w)/Qp)*r,2,r),B=0;B<I;B++){var P=w+B/(I-1)*(M-w),D=l+ig(P)*i,O=u+ng(P)*i;this._vSet(D,O,1),this._vSet(l,u,0)}this._vSet(l+o*n,u+h*n,1),this._vSet(b,x,-1)}},_bevelJoin:function(t,e,i,n){var r=0,s=0,a=0,o=0,h=0,l=0,u=0,c=0,d=t.dy,_=-t.dx,f=e.dy,p=-e.dx;if(e.flags&pc.PT_LEFT){var g=this._chooseBevel(e.flags&pc.PT_INNERBEVEL,t,e,i);h=g[0],l=g[1],u=g[2],c=g[3],this._vSet(h,l,1),this._vSet(e.x-d*n,e.y-_*n,-1),this._vSet(u,c,1),this._vSet(e.x-f*n,e.y-p*n,-1)}else{var m=this._chooseBevel(e.flags&pc.PT_INNERBEVEL,t,e,-n);r=m[0],s=m[1],a=m[2],o=m[3],this._vSet(e.x+d*i,e.y+_*i,1),this._vSet(r,s,-1),this._vSet(e.x+f*i,e.y+p*i,1),this._vSet(a,o,-1)}},_vSet:function(t,e,i){if(void 0===i&&(i=0),sg){var n=sg,r=8*n.vertexStart,s=n.vData;s[r++]=t,s[r++]=e,s[r++]=0,Ve.toArray(s,og,r),r+=4,s[r++]=i,n.vertexStart++}}},dg=t("graphicsAssembler",{getAssembler:function(){return cg}});yd.Assembler=dg;var _g,fg=function(){this.char="",this.valid=!0,this.x=0,this.y=0,this.line=0,this.hash=""},pg=new un,gg=new Ih(64,64),mg=new nh(null),vg=null,yg=null,Tg=[],Sg=[],Eg=[],Ag=[],Cg=new dn,Rg=new dn,bg=new cn,xg=null,wg=0,Mg=0,Ig=0,Bg=0,Pg=0,Dg=1,Og=null,Fg="",Lg=0,Ng=0,kg=0,Ug=0,Gg=0,Vg=0,Hg=0,zg=!1,Xg=0,Wg=0,Yg=0,jg={updateRenderData:function(t){t.renderData&&vg!==t&&(t.renderData.vertDirty&&(yg=(vg=t).node._uiProps.uiTransformComp,this._updateFontFamily(t),this._updateProperties(t),this._updateLabelInfo(t),this._updateContent(),vg.actualFontSize=Lg,yg.setContentSize(Rg),this.updateUVs(t),this.updateColor(t),vg.renderData.vertDirty=!1,vg=null,this._resetProperties()),t.spriteFrame&&t.renderData.updateRenderData(t,t.spriteFrame))},updateUVs:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.vertexCount,r=e.data,s=3,a=0;a<n;a++){var o=r[a];i[s]=o.u,i[s+1]=o.v,s+=9}},updateColor:function(){},_updateFontScale:function(){Dg=Lg/Ng},_updateFontFamily:function(t){var e=t.font;Og=e.spriteFrame,xg=e.fntConfig,Bh.fontAtlas=e.fontDefDictionary,Bh.fontAtlas||(t.cacheMode===xu.CHAR?Bh.fontAtlas=gg:Bh.fontAtlas=mg),Ja.packToDynamicAtlas(t,Og)},_updateLabelInfo:function(){Bh.hash="",Bh.margin=0},_updateProperties:function(t){Fg=t.string.toString(),Lg=t.fontSize,Ng=xg?xg.fontSize:t.fontSize,kg=t.horizontalAlign,Ug=t.verticalAlign,Gg=t.spacingX,Hg=t.overflow,Vg=t._lineHeight;var e=yg.contentSize;Rg.width=e.width,Rg.height=e.height,Hg===bu.NONE?(zg=!1,Rg.width+=2*Bh.margin,Rg.height+=2*Bh.margin):Hg===bu.RESIZE_HEIGHT?(zg=!0,Rg.height+=2*Bh.margin):zg=t.enableWrapText,Bh.lineHeight=Vg,Bh.fontSize=Lg,this._setupBMFontOverflowMetrics()},_resetProperties:function(){xg=null,Og=null,Bh.hash="",Bh.margin=0},_updateContent:function(){this._updateFontScale(),this._computeHorizontalKerningForText(),this._alignText()},_computeHorizontalKerningForText:function(){var t=Fg,e=t.length,i=xg.kerningDict,n=Tg;if(i)for(var r=-1,s=0;s<e;++s){var a=t.charCodeAt(s),o=i[r<<16|65535&a]||0;n[s]=s<e-1?o:0,r=a}},_multilineTextWrap:function(t){for(var e=Fg.length,i=0,n=0,r=0,s=0,a=0,o=0,h=0,l=null,u=0;u<e;){var c=Fg.charAt(u);if("\n"!==c){for(var d=t(Fg,u,e),_=o,f=h,p=a,g=n,m=!1,v=0;v<d;++v){var y=u+v;if("\r"!==(c=Fg.charAt(y)))if(l=Bh.fontAtlas.getLetterDefinitionForChar(c,Bh)){var T=g+l.offsetX*Dg-Bh.margin;if(zg&&Yg>0&&n>0&&T+l.w*Dg>Yg&&!mh(c)){Eg.push(a),a=0,i++,n=0,r-=Vg*this._getFontScale()+0,m=!0;break}bg.x=T,bg.y=r-l.offsetY*Dg,this._recordLetterInfo(bg,c,y,i),y+1<Tg.length&&y<e-1&&(g+=Tg[y+1]),g+=l.xAdvance*Dg+Gg,p=bg.x+l.w*Dg,_<bg.y&&(_=bg.y),f>bg.y-l.h*Dg&&(f=bg.y-l.h*Dg)}else this._recordPlaceholderInfo(y,c),console.log("Can't find letter definition in texture atlas "+xg.atlasName+" for letter:"+c);else this._recordPlaceholderInfo(y,c)}m||(n=g,o<_&&(o=_),h>f&&(h=f),s<(a=p)&&(s=a),u+=d)}else Eg.push(a),a=0,i++,n=0,r-=Vg*this._getFontScale()+0,this._recordPlaceholderInfo(u,c),u++}return Eg.push(a),Mg=(wg=i+1)*Vg*this._getFontScale(),wg>1&&(Mg+=0*(wg-1)),Rg.width=Xg,Rg.height=Wg,Xg<=0&&(Rg.width=parseFloat(s.toFixed(2))+2*Bh.margin),Wg<=0&&(Rg.height=parseFloat(Mg.toFixed(2))+2*Bh.margin),Bg=Rg.height,Pg=0,o>0&&(Bg=Rg.height+o),h<-Mg&&(Pg=Mg+h),!0},_getFirstCharLen:function(){return 1},_getFontScale:function(){return Hg===bu.SHRINK?Dg:1},_getFirstWordLen:function(t,e,i){var n=t.charAt(e);if(gh(n)||"\n"===n||mh(n))return 1;var r=1,s=Bh.fontAtlas.getLetterDefinitionForChar(n,Bh);if(!s)return r;for(var a=s.xAdvance*Dg+Gg,o=e+1;o<i&&(n=t.charAt(o),s=Bh.fontAtlas.getLetterDefinitionForChar(n,Bh));++o){if(a+s.offsetX*Dg+s.w*Dg>Yg&&!mh(n)&&Yg>0)return r;if(a+=s.xAdvance*Dg+Gg,"\n"===n||mh(n)||gh(n))break;r++}return r},_multilineTextWrapByWord:function(){return this._multilineTextWrap(this._getFirstWordLen)},_multilineTextWrapByChar:function(){return this._multilineTextWrap(this._getFirstCharLen)},_recordPlaceholderInfo:function(t,e){if(t>=Sg.length){var i=new fg;Sg.push(i)}Sg[t].char=e,Sg[t].hash=""+e.charCodeAt(0)+Bh.hash,Sg[t].valid=!1},_recordLetterInfo:function(t,e,i,n){if(i>=Sg.length){var r=new fg;Sg.push(r)}var s=""+e.charCodeAt(0)+Bh.hash;Sg[i].line=n,Sg[i].char=e,Sg[i].hash=s,Sg[i].valid=Bh.fontAtlas.getLetter(s).valid,Sg[i].x=t.x,Sg[i].y=t.y},_alignText:function(){Mg=0,Eg.length=0,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),Hg===bu.SHRINK&&Lg>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp),this._updateQuads()||Hg===bu.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp)},_scaleFontSizeDown:function(t){var e=!0;t||(t=.1,e=!1),Lg=t,e&&this._updateContent()},_shrinkLabelToContentSize:function(t){for(var e=0,i=0|Lg,n=0;e<i;){var r=n=e+i+1>>1;if(r<=0)break;Dg=r/Ng,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),t()?i=n-1:e=n}e>=0&&this._scaleFontSizeDown(e)},_isVerticalClamp:function(){return Mg>Rg.height},_isHorizontalClamp:function(){for(var t=!1,e=0,i=Fg.length;e<i;++e){var n=Sg[e];if(n.valid){var r=Bh.fontAtlas.getLetterDefinitionForChar(n.char,Bh);if(!r)continue;var s=n.x+r.w*Dg,a=n.line;if(Xg>0)if(zg){if(Eg[a]>Rg.width&&(s>Rg.width||s<0)){t=!0;break}}else if(s>Rg.width){t=!0;break}}}return t},_isHorizontalClamped:function(t,e){var i=Eg[e],n=t>Rg.width||t<0;return zg?i>Rg.width&&n:n},_updateQuads:function(){if(!vg)return!1;var t=Og?Og.texture:Bh.fontAtlas.getTexture(),e=vg.renderData;e.dataLength=0,e.resize(0,0);for(var i=yg.anchorPoint,n=Rg,r=i.x*n.width,s=i.y*n.height,a=!0,o=0,h=Fg.length;o<h;++o){var l=Sg[o];if(l.valid){var u=Bh.fontAtlas.getLetter(l.hash);if(u){pg.height=u.h,pg.width=u.w,pg.x=u.u,pg.y=u.v;var c=l.y+Ig;if(Wg>0){if(c>Bg){var d=c-Bg;pg.y+=d,pg.height-=d,c-=d}c-pg.height*Dg<Pg&&Hg===bu.CLAMP&&(pg.height=c<Pg?0:(c-Pg)/Dg)}var _=l.line,f=l.x+u.w/2*Dg+Ag[_];if(Xg>0&&this._isHorizontalClamped(f,_))if(Hg===bu.CLAMP)pg.width=0;else if(Hg===bu.SHRINK){if(Rg.width>u.w){a=!1;break}pg.width=0}if(pg.height>0&&pg.width>0){var p=this._determineRect(),g=l.x+Ag[l.line];this.appendQuad(vg,t,pg,p,g-r,c-s,Dg)}}else console.warn("Can't find letter in this bitmap-font")}}var m=e.indexCount;return this.createQuadIndices(m),e.chunk.setIndexBuffer(_g),a},createQuadIndices:function(t){if(t%6==0){var e=t/6;_g=null,_g=new Uint16Array(t);for(var i=0,n=0;n<e;n++)_g[i++]=0+4*n,_g[i++]=1+4*n,_g[i++]=2+4*n,_g[i++]=1+4*n,_g[i++]=3+4*n,_g[i++]=2+4*n}else console.error("illegal index count!")},appendQuad:function(){},_determineRect:function(){var t=Og.isRotated(),e=Og.getOriginalSize(),i=Og.getRect(),n=Og.getOffset(),r=n.x+(e.width-i.width)/2,s=n.y-(e.height-i.height)/2;if(t){var a=pg.x;pg.x=i.x+i.height-pg.y-pg.height-s,pg.y=a+i.y-r,pg.y<0&&(pg.height+=s)}else pg.x+=i.x-r,pg.y+=i.y+s;return t},_computeAlignmentOffset:function(){switch(Ag.length=0,kg){case Cu.LEFT:for(var t=0;t<wg;++t)Ag.push(0);break;case Cu.CENTER:for(var e=0,i=Eg.length;e<i;e++)Ag.push((Rg.width-Eg[e])/2);break;case Cu.RIGHT:for(var n=0,r=Eg.length;n<r;n++)Ag.push(Rg.width-Eg[n])}if(Ig=Rg.height,Ug!==Ru.TOP){var s=Rg.height-Mg+Vg*this._getFontScale()-Ng*Dg;Ug===Ru.BOTTOM?Ig-=s:Ig-=s/2}},_setupBMFontOverflowMetrics:function(){var t=Rg.width,e=Rg.height;Hg===bu.RESIZE_HEIGHT&&(e=0),Hg===bu.NONE&&(t=0,e=0),Xg=t,Wg=e,Cg.width=t,Cg.height=e,Yg=t}},Kg=new Ve(255,255,255,255),qg={createData:function(t){var e=t.requestRenderData();return e.resize(0,0),e},fillBuffers:function(t){var e=t.node;Kg.set(t.color),Kg.a=255*e._uiProps.opacity,Wa(e,0,t.renderData,Kg)},appendQuad:function(t,e,i,n,r,s,a){var o=t.renderData;if(o){var h=o.dataLength;o.dataLength+=4,o.resize(o.dataLength,o.dataLength/2*3);var l=o.data,u=e.width,c=e.height,d=i.width,_=i.height,f=0,p=0,g=0,m=0;n?(f=i.x/u,m=(i.x+_)/u,p=(i.y+d)/c,g=i.y/c,l[h].u=f,l[h].v=g,l[h+1].u=f,l[h+1].v=p,l[h+2].u=m,l[h+2].v=g,l[h+3].u=m,l[h+3].v=p):(f=i.x/u,m=(i.x+d)/u,p=(i.y+_)/c,g=i.y/c,l[h].u=f,l[h].v=p,l[h+1].u=m,l[h+1].v=p,l[h+2].u=f,l[h+2].v=g,l[h+3].u=m,l[h+3].v=g),l[h].x=r,l[h].y=s-_*a,l[h+1].x=r+d*a,l[h+1].y=s-_*a,l[h+2].x=r,l[h+2].y=s,l[h+3].x=r+d*a,l[h+3].y=s}}};Lr(qg,jg);var Zg=null,Qg=Sn(jg,{getAssemblerData:function(){return Zg||(Zg=new Ih(1024,1024)),Zg.getTexture()},_updateFontFamily:function(t){Bh.fontAtlas=Zg,Bh.fontFamily=this._getFontFamily(t);var e=t.getComponent(C_);e&&e.enabled?(Bh.isOutlined=!0,Bh.margin=e.width,Bh.out=e.color.clone(),Bh.out.a=e.color.a*t.color.a/255):(Bh.isOutlined=!1,Bh.margin=0)},_getFontFamily:function(t){var e="Arial";return t.useSystemFont?e=t.fontFamily||"Arial":t.font&&(e=t.font._nativeAsset||"Arial"),e},_updateLabelInfo:function(t){var e,i,n;Bh.fontDesc=this._getFontDesc(),Bh.color=t.color,Bh.hash=(i=(e=Bh).color.toHEX(),n="",e.isOutlined&&e.margin>0&&(n=n+e.margin+e.out.toHEX()),""+e.fontSize+e.fontFamily+i+n)},_getFontDesc:function(){return Bh.fontSize.toString()+"px "+Bh.fontFamily},_computeHorizontalKerningForText:function(){},_determineRect:function(){return!1}}),Jg=new Ve(255,255,255,255),$g={createData:function(t){var e=t.requestRenderData();return e.resize(0,0),e},fillBuffers:function(t){if(t.renderData){var e=t.node;Jg.a=255*e._uiProps.opacity,Wa(e,0,t.renderData,Jg)}},appendQuad:qg.appendQuad};Lr($g,Qg);var tm=Mu.Overflow,em=(1/255).toFixed(3),im=null,nm=null,rm=null,sm="",am="",om=0,hm=0,lm=[],um=new dn,cm=0,dm=0,_m=0,fm=new Ve,pm="",gm=tm.NONE,mm=!1,vm=null,ym=Ve.BLACK.clone(),Tm=null,Sm=Ve.BLACK.clone(),Em=new un,Am=dn.ZERO.clone(),Cm=dn.ZERO.clone(),Rm=cn.ZERO.clone(),bm=cn.ZERO.clone(),xm=0,wm=0,Mm=!1,Im=!1,Bm=!1,Pm=["left","center","right"],Dm={getAssemblerData:function(){var t=Mu._canvasPool.get();return t.canvas.width=t.canvas.height=1,t},resetAssemblerData:function(t){t&&Mu._canvasPool.put(t)},updateRenderData:function(t){if(t.renderData){if(t.renderData.vertDirty){var e=t.node._uiProps.uiTransformComp;this._updateFontFamily(t),this._updateProperties(t,e),this._calculateLabelFont(),this._updateLabelDimensions(),this._updateTexture(t),this._calDynamicAtlas(t),t.actualFontSize=om,e.setContentSize(um),this.updateVertexData(t),this.updateUVs(t),t.renderData.vertDirty=!1,t.contentWidth=Cm.width,im=null,nm=null,rm=null}t.spriteFrame&&t.renderData.updateRenderData(t,t.spriteFrame)}},updateVertexData:function(){},updateUVs:function(){},_updateFontFamily:function(t){pm=t.useSystemFont?t.fontFamily||"Arial":t.font&&t.font._nativeAsset||"Arial"},_updateProperties:function(t,e){var i=t.assemblerData;i&&(im=i.context,nm=i.canvas,rm=t.spriteFrame,am=t.string.toString(),om=t.fontSize,hm=om,gm=t.overflow,Cm.width=um.width=e.width,Cm.height=um.height=e.height,wm=t.underlineHeight,cm=t.lineHeight,dm=t.horizontalAlign,_m=t.verticalAlign,fm=t.color,t.node._uiProps.opacity,Mm=t.isBold,Im=t.isItalic,Bm=t.isUnderline,mm=gm!==tm.NONE&&(gm===tm.RESIZE_HEIGHT||t.enableWrapText),(vm=(vm=C_&&t.getComponent(C_))&&vm.enabled&&vm.width>0?vm:null)&&ym.set(vm.color),(Tm=(Tm=xp&&t.getComponent(xp))&&Tm.enabled?Tm:null)&&Sm.set(Tm.color),this._updatePaddingRect())},_updatePaddingRect:function(){var t=0,e=0,i=0,n=0,r=0;if(Am.width=Am.height=0,vm&&(t=e=i=n=r=vm.width,Am.width=Am.height=2*r),Tm){var s=Tm.blur+r,a=Tm.offset.x,o=Tm.offset.y;i=Math.max(i,-a+s),n=Math.max(n,a+s),t=Math.max(t,o+s),e=Math.max(e,-o+s)}if(Im){var h=hm*Math.tan(.20943951);n+=h,Am.width+=h}Em.x=i,Em.y=t,Em.width=i+n,Em.height=t+e},_calculateFillTextStartPosition:function(){var t=0;dm===Cu.RIGHT?t=um.width-Em.width:dm===Cu.CENTER&&(t=(um.width-Em.width)/2);var e=this._getLineHeight()*(lm.length-1),i=om*(1-ah/2);if(_m!==Ru.TOP){var n=e+Em.height+om-um.height;_m===Ru.BOTTOM?i-=n+=ah/2*om:i-=n/2}i+=0*om,Rm.set(t+Em.x,i+Em.y)},_updateTexture:function(t){if(im&&nm){im.clearRect(0,0,nm.width,nm.height),im.font=sm,this._calculateFillTextStartPosition();var e=this._getLineHeight();im.lineJoin="round",vm?(im.fillStyle="rgba("+ym.r+", "+ym.g+", "+ym.b+", "+em+")",im.fillRect(0,0,nm.width,nm.height)):t._srcBlendFactor===I.SRC_ALPHA&&(im.fillStyle="rgba("+fm.r+", "+fm.g+", "+fm.b+", "+em+")",im.fillRect(0,0,nm.width,nm.height)),im.fillStyle="rgb("+fm.r+", "+fm.g+", "+fm.b+")";var i=Rm.x,n=0;this._drawTextEffect(Rm,e);for(var r=0;r<lm.length;++r)n=Rm.y+r*e,vm&&im.strokeText(lm[r],i,n),im.fillText(lm[r],i,n);Tm&&(im.shadowColor="transparent"),this._uploadTexture(t)}},_uploadTexture:function(t){if(t.cacheMode===Mu.CacheMode.BITMAP){var e=t.ttfSpriteFrame;Ja.deleteAtlasSpriteFrame(e),e._resetDynamicAtlasFrame()}var i;rm&&nm&&(i=rm instanceof Uo?rm.texture:rm,0!==nm.width&&0!==nm.height&&(i.reset({width:nm.width,height:nm.height,mipmapLevel:1}),i.uploadData(nm),i.setWrapMode(Nr.CLAMP_TO_EDGE,Nr.CLAMP_TO_EDGE),rm instanceof Uo&&(rm.rect=new un(0,0,nm.width,nm.height),rm._calculateUV()),t.renderData&&(t.renderData.textureDirty=!0),We.director.root&&We.director.root.batcher2D&&We.director.root.batcher2D._releaseDescriptorSetCache(i.getHash())))},_calDynamicAtlas:function(t){if(!(t.cacheMode!==Mu.CacheMode.BITMAP||!nm||nm.width<=0||nm.height<=0)){var e=t.ttfSpriteFrame;Ja.packToDynamicAtlas(t,e)}},_setupOutline:function(){im.strokeStyle="rgba("+ym.r+", "+ym.g+", "+ym.b+", "+ym.a/255+")",im.lineWidth=2*vm.width},_setupShadow:function(){im.shadowColor="rgba("+Sm.r+", "+Sm.g+", "+Sm.b+", "+Sm.a/255+")",im.shadowBlur=Tm.blur,im.shadowOffsetX=Tm.offset.x,im.shadowOffsetY=-Tm.offset.y},_drawTextEffect:function(t,e){if(Tm||vm||Bm){var i=lm.length>1&&Tm,n=this._measureText(im,sm),r=0,s=0;Tm&&this._setupShadow(),vm&&this._setupOutline();for(var a=0;a<lm.length;++a)r=t.x,s=t.y+a*e,i&&(vm&&im.strokeText(lm[a],r,s),im.fillText(lm[a],r,s)),Bm&&(xm=n(lm[a]),dm===Cu.RIGHT?bm.x=t.x-xm:dm===Cu.CENTER?bm.x=t.x-xm/2:bm.x=t.x,bm.y=s+hm/8,im.fillRect(bm.x,bm.y,xm,wm));i&&(im.shadowColor="transparent")}},_updateLabelDimensions:function(){um.width=Math.min(um.width,2048),um.height=Math.min(um.height,2048);var t=!1;nm.width!==um.width&&(nm.width=um.width,t=!0),nm.height!==um.height&&(nm.height=um.height,t=!0),t&&(im.font=sm),im.textAlign=Pm[dm],im.textBaseline="alphabetic"},_getFontDesc:function(){var t=om.toString()+"px ";return t+=pm,Mm&&(t="bold "+t),Im&&(t="italic "+t),t},_getLineHeight:function(){return 0|(0===cm?om:cm*om/hm)},_calculateParagraphLength:function(t,e){for(var i,n=[],r=Fi(t);!(i=r()).done;){var s=vh(e,i.value,sm);n.push(s)}return n},_measureText:function(t,e){return function(i){return vh(t,i,e)}},_calculateShrinkFont:function(t){if(im){var e=this._calculateParagraphLength(t,im),i=0,n=0,r=0;if(mm){var s=Cm.width,a=Cm.height;if(s<0||a<0)return;n=a+1;for(var o=0,h=0|om+1,l=0;o<h;){if((l=o+h+1>>1)<=0){kr(4003);break}om=l,sm=this._getFontDesc(),im.font=sm;var u=this._getLineHeight();for(n=0,i=0;i<t.length;++i){var c=vh(im,t[i],sm);n+=Eh(t[i],c,s,this._measureText(im,sm)).length*u}n>a?h=l-1:o=l}0===o?kr(4003):(om=o,sm=this._getFontDesc(),im.font=sm)}else{for(n=t.length*this._getLineHeight(),i=0;i<t.length;++i)r<e[i]&&(r=e[i]);var d=(um.width-Em.width)/r,_=um.height/n;om=hm*Math.min(1,d,_)|0,sm=this._getFontDesc(),im.font=sm}}},_calculateWrapText:function(t){if(mm&&im){lm=[];for(var e=Cm.width,i=0;i<t.length;++i){var n=vh(im,t[i],sm),r=Eh(t[i],n,e,this._measureText(im,sm));lm=lm.concat(r)}}},_calculateLabelFont:function(){if(im){var t=am.split("\n");switch(lm=t,sm=this._getFontDesc(),im.font=sm,gm){case tm.NONE:for(var e=0,i=0,n=0;n<t.length;++n){var r=vh(im,t[n],sm);e=e>r?e:r}i=(lm.length+ah)*this._getLineHeight();var s=parseFloat(e.toFixed(2)),a=parseFloat(i.toFixed(2));um.width=s+Em.width,um.height=a+Em.height,Cm.width=s+Am.width,Cm.height=a+Am.height;break;case tm.SHRINK:this._calculateShrinkFont(t),this._calculateWrapText(t);break;case tm.CLAMP:this._calculateWrapText(t);break;case tm.RESIZE_HEIGHT:this._calculateWrapText(t);var o=(lm.length+ah)*this._getLineHeight();um.height=o+Em.height,Cm.height=o+Am.height}}}},Om=Ve.WHITE.clone(),Fm=Uint16Array.from([0,1,2,1,3,2]),Lm={createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6);var i=e.chunk.vb;i[3]=i[21]=i[22]=i[31]=0,i[4]=i[12]=i[13]=i[30]=1;for(var n=5,r=0;r<4;r++)Ve.toArray(i,Om,n),n+=9;return e.vertexRow=2,e.vertexCol=2,e.chunk.setIndexBuffer(Fm),e},fillBuffers:function(t){for(var e=t.renderData,i=e.chunk,n=e.data,r=t.node,s=i.vb,a=r.worldMatrix,o=e.floatStride,h=0,l=n.length,u=0;u<l;u++){var c=n[u],d=c.x,_=c.y,f=a.m03*d+a.m07*_+a.m15;f=f?Math.abs(1/f):1,s[0+(h=u*o)]=(a.m00*d+a.m04*_+a.m12)*f,s[h+1]=(a.m01*d+a.m05*_+a.m13)*f,s[h+2]=(a.m02*d+a.m06*_+a.m14)*f}var p=i.vertexOffset,g=i.meshBuffer,m=i.meshBuffer.iData,v=g.indexOffset;m[v++]=p,m[v++]=p+1,m[v++]=p+2,m[v++]=p+2,m[v++]=p+1,m[v++]=p+3,g.indexOffset+=6},updateVertexData:function(t){var e=t.renderData;if(e){var i=t.node._uiProps.uiTransformComp,n=i.width,r=i.height,s=i.anchorX*n,a=i.anchorY*r,o=e.data;o[0].x=-s,o[0].y=-a,o[1].x=n-s,o[1].y=-a,o[2].x=-s,o[2].y=r-a,o[3].x=n-s,o[3].y=r-a}},updateUVs:function(t){var e=t.renderData;if(e&&t.ttfSpriteFrame){var i=e.chunk.vb,n=t.ttfSpriteFrame.uv;i[3]=n[0],i[4]=n[1],i[12]=n[2],i[13]=n[3],i[21]=n[4],i[22]=n[5],i[30]=n[6],i[31]=n[7]}},updateColor:function(){}};Lr(Lm,Dm);var Nm=t("labelAssembler",{getAssembler:function(t){var e=Lm;return t.font instanceof rh?e=qg:t.cacheMode===Mu.CacheMode.CHAR&&(e=$g),e}});Mu.Assembler=Nm;var km,Um=Bd.FillType,Gm=new Ue,Vm=Uint16Array.from([0,1,2,1,3,2]),Hm={updateRenderData:function(t){var e=t.spriteFrame;Ja.packToDynamicAtlas(t,e);var i=t.renderData;if(i&&e){if(!i.vertDirty)return;var n=t.fillStart,r=t.fillRange;r<0&&(n+=r,r=-r),r=(r=(r=n+r)>1?1:r)<0?0:r;var s=(n=(n=n>1?1:n)<0?0:n)+(r=(r-=n)<0?0:r);s=s>1?1:s,this.updateUVs(t,n,s),this.updateVertexData(t,n,s),i.updateRenderData(t,e)}},updateUVs:function(t,e,i){var n=t.spriteFrame,r=t.renderData.chunk.vb,s=n.width,a=n.height,o=n.rect,h=0,l=0,u=0,c=0,d=0,_=0,f=0,p=0,g=0,m=0;switch(n.isRotated()?(h=o.x/s,l=(o.y+o.width)/a,u=d=h,f=g=(o.x+o.height)/s,_=m=l,c=p=o.y/a):(h=o.x/s,l=(o.y+o.height)/a,u=f=h,d=g=(o.x+o.width)/s,c=_=l,p=m=o.y/a),t.fillType){case Um.HORIZONTAL:r[3]=u+(d-u)*e,r[4]=c+(_-c)*e,r[12]=u+(d-u)*i,r[13]=c+(_-c)*i,r[21]=f+(g-f)*e,r[22]=p+(m-p)*e,r[30]=f+(g-f)*i,r[31]=p+(m-p)*i;break;case Um.VERTICAL:r[3]=u+(f-u)*e,r[4]=c+(p-c)*e,r[12]=d+(g-d)*e,r[13]=_+(m-_)*e,r[21]=u+(f-u)*i,r[22]=c+(p-c)*i,r[30]=d+(g-d)*i,r[31]=_+(m-_)*i;break;default:hn(2626)}},updateVertexData:function(t,e,i){var n=t.renderData.data,r=t.node._uiProps.uiTransformComp,s=r.width,a=r.height,o=r.anchorX*s,h=r.anchorY*a,l=-o,u=-h,c=s-o,d=a-h,_=0;switch(t.fillType){case Um.HORIZONTAL:_=l+(c-l)*i,l+=(c-l)*e,c=_;break;case Um.VERTICAL:_=u+(d-u)*i,u+=(d-u)*e,d=_;break;default:hn(2626)}n[0].x=l,n[0].y=u,n[1].x=c,n[1].y=u,n[2].x=l,n[2].y=d,n[3].x=c,n[3].y=d},createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6),e.vertexRow=2,e.vertexCol=2,e.chunk.setIndexBuffer(Vm);for(var i,n=e.data,r=Fi(n);!(i=r()).done;)i.value.z=0;return e},updateWorldVertexData:function(t,e){t.node.getWorldMatrix(Gm);for(var i=t.renderData.floatStride,n=t.renderData.data,r=e.vb,s=0,a=0;a<4;a++){var o=n[a],h=o.x,l=o.y,u=Gm.m03*h+Gm.m07*l+Gm.m15;u=u?Math.abs(1/u):1,r[s=a*i]=(Gm.m00*h+Gm.m04*l+Gm.m12)*u,r[s+1]=(Gm.m01*h+Gm.m05*l+Gm.m13)*u,r[s+2]=(Gm.m02*h+Gm.m06*l+Gm.m14)*u}},fillBuffers:function(t){var e=t.renderData,i=e.chunk;(t.node.hasChangedFlags||e.vertDirty)&&(this.updateWorldVertexData(t,i),e.vertDirty=!1),i.bufferId;var n=i.vertexOffset,r=i.meshBuffer,s=i.meshBuffer.iData,a=r.indexOffset;s[a++]=n,s[a++]=n+1,s[a++]=n+2,s[a++]=n+2,s[a++]=n+1,s[a++]=n+3,r.indexOffset+=6},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=5,s=t.color,a=s.r/255,o=s.g/255,h=s.b/255,l=t.node._uiProps.opacity,u=0;u<4;u++)i[r]=a,i[r+1]=o,i[r+2]=h,i[r+3]=l,r+=n}},zm=2*Math.PI,Xm=1e-6,Wm=new Ue,Ym=[new cn,new cn,new cn,new cn],jm=new Array(4),Km=new Array(8),qm=[new cn,new cn,new cn,new cn],Zm=[new cn,new cn,new cn,new cn],Qm=new cn,Jm=[new cn,new cn,new cn,new cn];function $m(t,e,i,n,r,s,a){var o=Math.sin(s);o=Math.abs(o)>Xm?o:0;var h=Math.cos(s),l=0,u=0;if(0!==(h=Math.abs(h)>Xm?h:0)){if(l=o/h,(t-r.x)*h>0){var c=r.y+l*(t-r.x);a[0].x=t,a[0].y=c}if((e-r.x)*h>0){var d=r.y+l*(e-r.x);a[2].x=e,a[2].y=d}}if(0!==o){if(u=h/o,(n-r.y)*o>0){var _=r.x+u*(n-r.y);a[3].x=_,a[3].y=n}if((i-r.y)*o>0){var f=r.x+u*(i-r.y);a[1].x=f,a[1].y=i}}}function tv(t,e){var i=e.x-t.x,n=e.y-t.y;if(0===i&&0===n)return 0;if(0===i)return n>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(n/i);return i<0&&(r+=Math.PI),r}function ev(t,e,i,n,r){var s=jm,a=s[0],o=s[1],h=s[2],l=s[3];t[e].x=i.x,t[e].y=i.y,t[e+1].x=n.x,t[e+1].y=n.y,t[e+2].x=r.x,t[e+2].y=r.y,iv((i.x-a)/(h-a),(i.y-o)/(l-o),t,e),iv((n.x-a)/(h-a),(n.y-o)/(l-o),t,e+1),iv((r.x-a)/(h-a),(r.y-o)/(l-o),t,e+2)}function iv(t,e,i,n){var r=Km,s=r[0]+(r[2]-r[0])*t,a=r[4]+(r[6]-r[4])*t,o=r[1]+(r[3]-r[1])*t,h=r[5]+(r[7]-r[5])*t,l=i[n];l.u=s+(a-s)*e,l.v=o+(h-o)*e}for(var nv={useModel:!1,createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.spriteFrame;Ja.packToDynamicAtlas(t,e),this.updateUVs(t);var i,n,r,s,a,o,h,l,u,c=t.renderData;if(c&&e){if(!c.vertDirty)return;var d=c.data,_=t.fillStart,f=t.fillRange;for(f<0&&(_+=f,f=-f);_>=1;)_-=1;for(;_<0;)_+=1;var p=(_*=zm)+(f*=zm);!function(t){var e=t.node._uiProps.uiTransformComp,i=e.width,n=e.height,r=e.anchorX*i,s=e.anchorY*n,a=-r,o=-s,h=i-r,l=n-s,u=jm;u[0]=a,u[1]=o,u[2]=h,u[3]=l;var c=t.fillCenter,d=Qm.x=Math.min(Math.max(0,c.x),1)*(h-a)+a,_=Qm.y=Math.min(Math.max(0,c.y),1)*(l-o)+o;Ym[0].x=Ym[3].x=a,Ym[1].x=Ym[2].x=h,Ym[0].y=Ym[1].y=o,Ym[2].y=Ym[3].y=l;for(var f,p=Fi(Jm);!(f=p()).done;){var g=f.value;cn.set(g,0,0)}d!==u[0]&&cn.set(Jm[0],3,0),d!==u[2]&&cn.set(Jm[2],1,2),_!==u[1]&&cn.set(Jm[1],0,1),_!==u[3]&&cn.set(Jm[3],2,3)}(t),n=(i=e).width,r=i.height,s=i.getRect(),a=0,o=0,h=0,l=0,u=Km,i.isRotated()?(a=s.x/n,o=(s.x+s.height)/n,h=s.y/r,l=(s.y+s.width)/r,u[0]=u[2]=a,u[4]=u[6]=o,u[3]=u[7]=l,u[1]=u[5]=h):(a=s.x/n,o=(s.x+s.width)/n,h=s.y/r,l=(s.y+s.height)/r,u[0]=u[4]=a,u[2]=u[6]=o,u[1]=u[3]=l,u[5]=u[7]=h),$m(jm[0],jm[2],jm[1],jm[3],Qm,_,qm),$m(jm[0],jm[2],jm[1],jm[3],Qm,_+f,Zm);for(var g=0,m=0;m<4;++m){var v=Jm[m];if(v)if(f>=zm)c.dataLength=g+3,ev(d,g,Qm,Ym[v.x],Ym[v.y]),g+=3;else{var y=tv(Qm,Ym[v.x]),T=tv(Qm,Ym[v.y]);T<y&&(T+=zm),y-=zm,T-=zm;for(var S=0;S<3;++S)y>=p||(y>=_?(c.dataLength=g+3,ev(d,g,Qm,Ym[v.x],T>=p?Zm[m]:Ym[v.y]),g+=3):T>_&&(T<=p?(c.dataLength=g+3,ev(d,g,Qm,qm[m],Ym[v.y]),g+=3):(c.dataLength=g+3,ev(d,g,Qm,qm[m],Zm[m]),g+=3))),y+=zm,T+=zm}}0===g&&(c.dataLength=0),c.resize(g,g),c.updateRenderData(t,e)}},createQuadIndices:function(t){km=null,km=new Uint16Array(t);for(var e=0,i=0;i<t;i++)km[e++]=i},fillBuffers:function(t){var e=t.node,i=t.renderData,n=i.chunk;(e.hasChangedFlags||i.vertDirty)&&(this.updateWorldVertexAndUVData(t,n),i.vertDirty=!1),this.updateColorLate(t),n.bufferId;for(var r=n.vertexOffset,s=n.meshBuffer,a=n.meshBuffer.iData,o=s.indexOffset,h=0;h<i.indexCount;h++)a[o+h]=r+h;s.indexOffset+=i.indexCount,s.setDirty()},updateWorldUVData:function(t){for(var e=t.renderData,i=e.floatStride,n=e.data,r=e.chunk.vb,s=0;s<n.length;s++){var a=s*i;r[a+3]=n[s].u,r[a+4]=n[s].v}},updateWorldVertexAndUVData:function(t,e){t.node.getWorldMatrix(Wm);for(var i=t.renderData,n=i.floatStride,r=t.renderData.data,s=e.vb,a=i.vertexCount,o=0,h=0;h<a;h++){var l=r[h],u=l.x,c=l.y,d=Wm.m03*u+Wm.m07*c+Wm.m15;d=d?Math.abs(1/d):1,s[o+0]=(Wm.m00*u+Wm.m04*c+Wm.m12)*d,s[o+1]=(Wm.m01*u+Wm.m05*c+Wm.m13)*d,s[o+2]=(Wm.m02*u+Wm.m06*c+Wm.m14)*d,s[o+3]=l.u,s[o+4]=l.v,o+=n}},updateUVs:function(t){t.renderData.vertDirty=!0,t.markForUpdateRenderData()},updateColorLate:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=e.vertexCount,s=5,a=t.color,o=a.r/255,h=a.g/255,l=a.b/255,u=t.node._uiProps.opacity,c=0;c<r;c++)i[s]=o,i[s+1]=h,i[s+2]=l,i[s+3]=u,s+=n},updateColor:function(){}},rv=Uint16Array.from([0,1,2,1,3,2]),sv={createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.resize(4,6),e.vertexRow=2,e.vertexCol=2,e.chunk.setIndexBuffer(rv),e},updateRenderData:function(t){var e=t.spriteFrame;Ja.packToDynamicAtlas(t,e),this.updateUVs(t);var i=t.renderData;i&&e&&(i.vertDirty&&this.updateVertexData(t),i.updateRenderData(t,e))},updateWorldVerts:function(t,e){for(var i=t.renderData,n=e.vb,r=i.data,s=t.node.worldMatrix,a=i.floatStride,o=0,h=r.length,l=0;l<h;l++){var u=r[l],c=u.x,d=u.y,_=s.m03*c+s.m07*d+s.m15;_=_?Math.abs(1/_):1,n[0+(o=l*a)]=(s.m00*c+s.m04*d+s.m12)*_,n[o+1]=(s.m01*c+s.m05*d+s.m13)*_,n[o+2]=(s.m02*c+s.m06*d+s.m14)*_}},fillBuffers:function(t){if(null!==t){var e=t.renderData,i=e.chunk;(t.node.hasChangedFlags||e.vertDirty)&&(this.updateWorldVerts(t,i),e.vertDirty=!1),i.bufferId;for(var n=i.vertexOffset,r=i.meshBuffer,s=i.meshBuffer.iData,a=r.indexOffset,o=0;o<e.vertexRow-1;o++)for(var h=0;h<e.vertexCol-1;h++){var l=n+o*e.vertexCol+h;s[a++]=l,s[a++]=l+1,s[a++]=l+e.vertexCol,s[a++]=l+1,s[a++]=l+1+e.vertexCol,s[a++]=l+e.vertexCol,r.indexOffset+=6}}},updateVertexData:function(t){var e=t.renderData;if(e){var i=t.node._uiProps.uiTransformComp,n=e.data,r=i.width,s=i.height,a=i.anchorX*r,o=i.anchorY*s,h=0,l=0,u=0,c=0;if(t.trim)h=-a,l=-o,u=r-a,c=s-o;else{var d=t.spriteFrame,_=d.originalSize,f=r/_.width,p=s/_.height,g=d.trimmedBorder;h=g.x*f-a,l=g.z*p-o,u=r+g.y*f-a,c=s+g.w*p-o}n[0].x=h,n[0].y=l,n[1].x=u,n[1].y=l,n[2].x=h,n[2].y=c,n[3].x=u,n[3].y=c,e.vertDirty=!0}},updateUVs:function(t){if(t.spriteFrame){var e=t.renderData.chunk.vb,i=t.spriteFrame.uv;e[3]=i[0],e[4]=i[1],e[12]=i[2],e[13]=i[3],e[21]=i[4],e[22]=i[5],e[30]=i[6],e[31]=i[7]}},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,n=5,r=t.color,s=r.r/255,a=r.g/255,o=r.b/255,h=r.a/255,l=0;l<4;l++,n+=e.floatStride)i[n]=s,i[n+1]=a,i[n+2]=o,i[n+3]=h}},av=new Ue,ov=[],hv=0;hv<4;hv++)ov.push({x:0,y:0,z:0,u:0,v:0,color:new Ve});var lv,uv,cv,dv,_v,fv,pv,gv,mv={createData:function(t){var e=t.requestRenderData();return e.dataLength=16,e.resize(16,54),e.vertexRow=4,e.vertexCol=4,this.QUAD_INDICES=new Uint16Array(54),this.createQuadIndices(4,4),e.chunk.setIndexBuffer(this.QUAD_INDICES),e},createQuadIndices:function(t,e){for(var i=0,n=0;n<t-1;n++)for(var r=0;r<e-1;r++){var s=n*e+r;this.QUAD_INDICES[i++]=s,this.QUAD_INDICES[i++]=s+1,this.QUAD_INDICES[i++]=s+e,this.QUAD_INDICES[i++]=s+1,this.QUAD_INDICES[i++]=s+1+e,this.QUAD_INDICES[i++]=s+e}},updateRenderData:function(t){var e=t.spriteFrame;Ja.packToDynamicAtlas(t,e),this.updateUVs(t);var i=t.renderData;i&&e&&(i.vertDirty&&this.updateVertexData(t),i.updateRenderData(t,e))},updateVertexData:function(t){var e=t.renderData,i=e.data,n=t.node._uiProps.uiTransformComp,r=n.width,s=n.height,a=n.anchorX*r,o=n.anchorY*s,h=t.spriteFrame,l=h.insetLeft,u=h.insetRight,c=h.insetTop,d=h.insetBottom,_=r-l-u,f=s-c-d,p=r/(l+u),g=s/(c+d);p=Number.isNaN(p)||p>1?1:p,g=Number.isNaN(g)||g>1?1:g,_=_<0?0:_,f=f<0?0:f,ov[0].x=-a,ov[0].y=-o,ov[1].x=l*p-a,ov[1].y=d*g-o,ov[2].x=ov[1].x+_,ov[2].y=ov[1].y+f,ov[3].x=r-a,ov[3].y=s-o;for(var m=0;m<e.vertexRow;m++)for(var v=0;v<e.vertexCol;v++){var y=m*e.vertexCol+v;y<e.dataLength&&m<ov.length&&v<ov.length&&(i[y].x=ov[v].x,i[y].y=ov[m].y)}},fillBuffers:function(t){var e=t.renderData,i=e.chunk;(t.node.hasChangedFlags||e.vertDirty)&&(this.updateWorldVertexData(t,i),e.vertDirty=!1),i.bufferId;for(var n=i.vertexOffset,r=i.meshBuffer,s=i.meshBuffer.iData,a=r.indexOffset,o=0;o<3;++o)for(var h=0;h<3;++h){var l=n+4*o+h;s[a++]=l,s[a++]=l+1,s[a++]=l+4,s[a++]=l+1,s[a++]=l+5,s[a++]=l+4}r.indexOffset=a},updateWorldVertexData:function(t,e){t.node.getWorldMatrix(av);for(var i=t.renderData,n=i.floatStride,r=i.data,s=e.vb,a=0,o=0;o<4;++o)for(var h=r[4*o],l=0;l<4;++l){var u=r[l].x,c=h.y,d=av.m03*u+av.m07*c+av.m15;d=d?Math.abs(1/d):1,s[0+(a=(4*o+l)*n)]=(av.m00*u+av.m04*c+av.m12)*d,s[a+1]=(av.m01*u+av.m05*c+av.m13)*d,s[a+2]=(av.m02*u+av.m06*c+av.m14)*d}},updateUVs:function(t){if(t.spriteFrame)for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=t.spriteFrame.uvSliced,s=3,a=0;a<16;a++)i[s]=r[a].u,i[s+1]=r[a].v,s+=n},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=5,s=t.color,a=s.r/255,o=s.g/255,h=s.b/255,l=t.node._uiProps.opacity,u=0;u<16;u++)i[r]=a,i[r+1]=o,i[r+2]=h,i[r+3]=l,r+=n}},vv=new Ue,yv=0,Tv=[];function Sv(t){return t&&(t.insetTop>0||t.insetBottom>0||t.insetLeft>0||t.insetRight>0)?2:0}var Ev={createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.renderData,i=t.spriteFrame;if(i&&e&&e.vertDirty){var n=t.node._uiProps.uiTransformComp,r=Math.abs(n.width),s=Math.abs(n.height),a=i.getRect(),o=i.insetLeft,h=i.insetRight,l=a.width-o-h,u=i.insetTop,c=i.insetBottom,d=a.height-u-c,_=r-o-h,f=s-u-c;_=_>0?_:0,f=f>0?f:0;var p=0===l?_:_/l,g=0===d?f:f/d,m=Sv(i),v=Math.ceil(g+m),y=Math.ceil(p+m);e.dataLength=4*v*y,this.updateVerts(t,_,f,v,y),e.vertexCount!==v*y*4&&(t.renderEntity.colorDirty=!0),e.resize(v*y*4,v*y*6),e.updateRenderData(t,i)}},createQuadIndices:function(t){if(t%6==0){var e=t/6;gv=null,gv=new Uint16Array(t);for(var i=0,n=0;n<e;n++)gv[i++]=0+4*n,gv[i++]=1+4*n,gv[i++]=2+4*n,gv[i++]=1+4*n,gv[i++]=3+4*n,gv[i++]=2+4*n}else console.error("illegal index count!")},updateUVs:function(t){t.renderData.vertDirty=!0,t.markForUpdateRenderData()},fillBuffers:function(t){var e=t.node,i=t.renderData,n=i.chunk;(e.hasChangedFlags||i.vertDirty)&&(this.updateWorldVertexAndUVData(t,n),i.vertDirty=!1),this.updateColorLate(t),n.bufferId;for(var r=n.vertexOffset,s=n.meshBuffer,a=n.meshBuffer.iData,o=s.indexOffset,h=0;h<i.indexCount;h+=6)a[o++]=r,a[o++]=r+1,a[o++]=r+2,a[o++]=r+1,a[o++]=r+3,a[o++]=r+2,r+=4,s.indexOffset+=6;s.setDirty()},updateWorldUVData:function(t){for(var e=t.renderData,i=e.floatStride,n=e.data,r=e.chunk.vb,s=0;s<n.length;s++){var a=s*i;r[a+3]=n[s].u,r[a+4]=n[s].v}},updateWorldVertexAndUVData:function(t,e){t.node.getWorldMatrix(vv);for(var i=t.renderData,n=i.floatStride,r=i.data,s=e.vb,a=r.length,o=0;o<a;o++){var h=r[o].x,l=r[o].y,u=r[o].z,c=vv.m03*h+vv.m07*l+vv.m11*u+vv.m15;c=c?Math.abs(1/c):1;var d=o*n;s[d]=(vv.m00*h+vv.m04*l+vv.m08*u+vv.m12)*c,s[d+1]=(vv.m01*h+vv.m05*l+vv.m09*u+vv.m13)*c,s[d+2]=(vv.m02*h+vv.m06*l+vv.m10*u+vv.m14)*c}this.updateWorldUVData(t)},updateVerts:function(t,e,i,n,r){var s,a,o=t.node._uiProps.uiTransformComp,h=t.renderData.data,l=t.spriteFrame,u=l.rect,c=Math.abs(o.width),d=Math.abs(o.height),_=o.anchorX*c,f=o.anchorY*d,p=l.insetLeft,g=l.insetRight,m=u.width-p-g,v=l.insetTop,y=l.insetBottom,T=u.height-v-y,S=o.width/(p+g)>1?1:o.width/(p+g),E=o.height/(v+y)>1?1:o.height/(v+y);s=m>0?Math.floor(1e3*e)/1e3%m==0?m:e%m:e,a=T>0?Math.floor(1e3*i)/1e3%T==0?T:i%T:i,yv=Math.max(n+1,r+1);for(var A=0;A<yv;A++)Tv.push({x:0,y:0,z:0,u:0,v:0,color:new Ve});var C=Sv(l);if(0===C)for(var R=0;R<yv;R++)Tv[R].x=R>=r?c-_:R*m-_,Tv[R].y=R>=n?d-f:R*T-f;else for(var b=0;b<yv;b++)0===b?Tv[b].x=-_:1===b?Tv[b].x=p*S-_:b>1&&b<r-1?Tv[b].x=m>0?p*S-_+m*(b-1):p+e-_:b===r-1?Tv[b].x=p*S-_+s+m*(b-2):b>=r&&(Tv[b].x=Math.min(p+e+g,c)-_),0===b?Tv[b].y=-f:1===b?Tv[b].y=y*E-f:b>1&&b<n-1?Tv[b].y=T>0?y*E-f+T*(b-1):y+i-f:b===n-1?Tv[b].y=y*E-f+a+T*(b-2):b>=n&&(Tv[b].y=Math.min(y+i+v,d)-f);for(var x=0,w=0,M=0,I=0,B=0;B<n;++B){M=Tv[B].y,I=Tv[B+1].y;for(var P=0;P<r;++P){x=Tv[P].x,w=Tv[P+1].x;var D=4*(B*r+P);h[D].x=x,h[D].y=M,h[D+1].x=w,h[D+1].y=M,h[D+2].x=x,h[D+2].y=I,h[D+3].x=w,h[D+3].y=I}}var O=l.rotated,F=(l.uv,l.uvSliced);lv=F[0],uv=F[1],cv=F[2],dv=F[3],_v=F[4],fv=F[8],pv=F[12];for(var L=0,N=0,k=0===m?e:e/m,U=0===T?i:i/T,G=[],V=[],H=0;H<n;++H){N=i>T?i>=(C>0?H:H+1)*T?1:U%1:U;for(var z=0;z<r;++z){L=e>m?e>=(C>0?z:z+1)*m?1:k%1:k,O?(0===C?(G[0]=_v.u,G[1]=_v.u,G[2]=_v.u+(fv.u-_v.u)*N,V[0]=uv.v,V[1]=uv.v+(cv.v-uv.v)*L,V[2]=uv.v):(0===H?(G[0]=lv.u,G[1]=lv.u,G[2]=_v.u):H<n-1?(G[0]=_v.u,G[1]=_v.u,G[2]=_v.u+(fv.u-_v.u)*N):H===n-1&&(G[0]=fv.u,G[1]=fv.u,G[2]=pv.u),0===z?(V[0]=lv.v,V[1]=uv.v,V[2]=lv.v):z<r-1?(V[0]=uv.v,V[1]=uv.v+(cv.v-uv.v)*L,V[2]=uv.v):z===r-1&&(V[0]=cv.v,V[1]=dv.v,V[2]=cv.v)),G[3]=G[2],V[3]=V[1]):(0===C?(G[0]=uv.u,G[1]=uv.u+(cv.u-uv.u)*L,G[2]=uv.u,V[0]=_v.v,V[1]=_v.v,V[2]=_v.v+(fv.v-_v.v)*N):(0===z?(G[0]=lv.u,G[1]=uv.u,G[2]=lv.u):z<r-1?(G[0]=uv.u,G[1]=uv.u+(cv.u-uv.u)*L,G[2]=uv.u):z===r-1&&(G[0]=cv.u,G[1]=dv.u,G[2]=cv.u),0===H?(V[0]=lv.v,V[1]=lv.v,V[2]=_v.v):H<n-1?(V[0]=_v.v,V[1]=_v.v,V[2]=_v.v+(fv.v-_v.v)*N):H===n-1&&(V[0]=fv.v,V[1]=fv.v,V[2]=pv.v)),G[3]=G[1],V[3]=V[2]);var X=4*(H*r+z);h[X].u=G[0],h[X].v=V[0],h[X+1].u=G[1],h[X+1].v=V[1],h[X+2].u=G[2],h[X+2].v=V[2],h[X+3].u=G[3],h[X+3].v=V[3]}}},updateColorLate:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=e.vertexCount,s=5,a=t.color,o=a.r/255,h=a.g/255,l=a.b/255,u=t.node._uiProps.opacity,c=0;c<r;c++)i[s]=o,i[s+1]=h,i[s+2]=l,i[s+3]=u,s+=n},updateColor:function(){}},Av=Bd.Type,Cv=Bd.FillType,Rv=t("spriteAssembler",{getAssembler:function(t){var e=sv,i=t;switch(i.type){case Av.SLICED:e=mv;break;case Av.TILED:e=Ev;break;case Av.FILLED:e=i.fillType===Cv.RADIAL?nv:Hm}return e}});Bd.Assembler=Rv;var bv=[Ur.EventType.MOUSE_DOWN,Ur.EventType.MOUSE_MOVE,Ur.EventType.MOUSE_UP,Ur.EventType.MOUSE_WHEEL],xv=[Ur.EventType.TOUCH_START,Ur.EventType.TOUCH_MOVE,Ur.EventType.TOUCH_END,Ur.EventType.TOUCH_CANCEL],wv=(new(function(){function t(){this.priority=Gr.UI,this._isListDirty=!1,this._inDispatchCount=0,this._pointerEventProcessorList=[],this._processorListToAdd=[],this._processorListToRemove=[],Vr._registerEventDispatcher(this),dr.callbacksInvoker.on(Hr.ADD_POINTER_EVENT_PROCESSOR,this.addPointerEventProcessor,this),dr.callbacksInvoker.on(Hr.REMOVE_POINTER_EVENT_PROCESSOR,this.removePointerEventProcessor,this),dr.callbacksInvoker.on(Hr.MARK_LIST_DIRTY,this._markListDirty,this)}var e=t.prototype;return e.dispatchEvent=function(t){var e=t.type;return xv.includes(e)?this.dispatchEventTouch(t):!bv.includes(e)||this.dispatchEventMouse(t)},e.addPointerEventProcessor=function(t){0===this._inDispatchCount?this._pointerEventProcessorList.includes(t)||(this._pointerEventProcessorList.push(t),this._isListDirty=!0):this._processorListToAdd.includes(t)||this._processorListToAdd.push(t),zr(this._processorListToRemove,t)},e.removePointerEventProcessor=function(t){0===this._inDispatchCount?(zr(this._pointerEventProcessorList,t),this._isListDirty=!0):this._processorListToRemove.includes(t)||this._processorListToRemove.push(t),zr(this._processorListToAdd,t)},e.dispatchEventMouse=function(t){this._inDispatchCount++,this._sortPointerEventProcessorList();for(var e=this._pointerEventProcessorList,i=e.length,n=!0,r=0;r<i;++r){var s=e[r];if(s.isEnabled&&s.shouldHandleEventMouse&&s._handleEventMouse(t)){if(n=!1,!t.preventSwallow)break;t.preventSwallow=!1}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),n},e.dispatchEventTouch=function(t){this._inDispatchCount++,this._sortPointerEventProcessorList();for(var e=this._pointerEventProcessorList,i=e.length,n=t.touch,r=!0,s=0;s<i;++s){var a=e[s];if(a.isEnabled&&a.shouldHandleEventTouch)if(t.type===Xr.TOUCH_START){if(a._handleEventTouch(t)){if(a.claimedTouchIdList.push(n.getID()),r=!1,!t.preventSwallow)break;t.preventSwallow=!1}}else if(a.claimedTouchIdList.length>0){var o=a.claimedTouchIdList.indexOf(n.getID());if(-1!==o){if(a._handleEventTouch(t),t.type!==Xr.TOUCH_END&&t.type!==Xr.TOUCH_CANCEL||Wr(a.claimedTouchIdList,o),r=!1,!t.preventSwallow)break;t.preventSwallow=!1}}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),r},e._updatePointerEventProcessorList=function(){for(var t=this._processorListToAdd,e=t.length,i=0;i<e;++i)this.addPointerEventProcessor(t[i]);t.length=0;for(var n=this._processorListToRemove,r=n.length,s=0;s<r;++s)this.removePointerEventProcessor(n[s]);n.length=0},e._sortPointerEventProcessorList=function(){if(this._isListDirty){for(var t=this._pointerEventProcessorList,e=t.length,i=0;i<e;++i){var n=t[i],r=n.node;if(r._uiProps){var s=r._uiProps.uiTransformComp;n.cachedCameraPriority=s.cameraPriority}}t.sort(this._sortByPriority),this._isListDirty=!1}},e._sortByPriority=function(t,e){var i=t.node,n=e.node;if(!(e&&n&&n.activeInHierarchy&&n._uiProps.uiTransformComp))return-1;if(!(t&&i&&i.activeInHierarchy&&i._uiProps.uiTransformComp))return 1;if(t.cachedCameraPriority!==e.cachedCameraPriority)return e.cachedCameraPriority-t.cachedCameraPriority;for(var r=i,s=n,a=!1;(null===(o=r.parent)||void 0===o?void 0:o._id)!==(null===(h=s.parent)||void 0===h?void 0:h._id);){var o,h,l,u,c,d;r=null===(null===(l=r)||void 0===l||null===(u=l.parent)||void 0===u?void 0:u.parent)?(a=!0)&&n:r&&r.parent,s=null===(null===(c=s)||void 0===c||null===(d=c.parent)||void 0===d?void 0:d.parent)?(a=!0)&&i:s&&s.parent}if(r._id===s._id){if(r._id===n._id)return-1;if(r._id===i._id)return 1}var _=r?r.getSiblingIndex():0,f=s?s.getSiblingIndex():0;return a?_-f:f-_},e._markListDirty=function(){this._isListDirty=!0},t}()),new Wt(null)),Mv=new Ue,Iv=t("UI",function(){function t(t){var i=this;this.device=void 0,this._screens=[],this._staticVBBuffer=null,this._bufferAccessors=new Map,this._drawBatchPool=void 0,this._batches=void 0,this._currBID=-1,this._indexStart=0,this._emptyMaterial=new Dn,this._currRenderData=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currStaticRoot=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0,this._currDepthStencilStateStage=null,this._currIsStatic=!1,this._currHash=0,this._currIsMiddleware=!1,this._middlewareEnableBatch=!1,this._middlewareBuffer=null,this._middlewareIndexStart=0,this._middlewareIndexCount=0,this._pOpacity=1,this._opacityDirty=0,this._descriptorSetCache=new Pv,this._meshDataArray=[],this._maskClearModel=null,this._maskClearMtl=null,this._maskModelMesh=null,this._root=t,this.device=t.device,this._batches=new n(64),this._drawBatchPool=new e((function(){return new Rp}),128,(function(t){return t.destroy(i)}))}var i=t.prototype;return i.initialize=function(){return!0},i.destroy=function(){for(var t=0;t<this._batches.length;t++)this._batches.array[t]&&this._batches.array[t].destroy(this);this._batches.destroy(),this._bufferAccessors.forEach((function(t){t.destroy()})),this._bufferAccessors.clear(),this._drawBatchPool&&this._drawBatchPool.destroy(),this._descriptorSetCache.destroy(),nl.sharedManager.destroy(),this._maskClearModel&&this._maskModelMesh&&(We.director.root.destroyModel(this._maskClearModel),this._maskModelMesh.destroy()),this._maskClearMtl&&this._maskClearMtl.destroy()},i.syncRootNodesToNative=function(){},i.addScreen=function(t){this._screens.push(t),this._screens.sort(this._screenSort)},i.removeScreen=function(t){var e=this._screens.indexOf(t);-1!==e&&this._screens.splice(e,1)},i.sortScreens=function(){this._screens.sort(this._screenSort)},i.getFirstRenderCamera=function(t){if(t.scene&&t.scene.renderScene)for(var e=t.scene.renderScene.cameras,i=0;i<e.length;i++){var n=e[i];if(n.visibility&t.layer)return n}return null},i.update=function(){for(var t=this._screens,e=0,i=0;i<t.length;++i){var n=t[i],r=n._getRenderScene();if(n.enabledInHierarchy&&r){this._opacityDirty=0,this._pOpacity=1,this.walk(n.node),this.autoMergeBatches(this._currComponent),this.resetRenderStates();var s=0;if(this._batches.length>e)for(;e<this._batches.length;++e){var a=this._batches.array[e];if(a.model)for(var o=a.model.subModels,h=0;h<o.length;h++)o[h].priority=s++;else a.descriptorSet=this._descriptorSetCache.getDescriptorSet(a);r.addBatch(a)}}}},i.uploadBuffers=function(){this._batches.length>0&&(this._meshDataArray.forEach((function(t){t.uploadBuffers()})),this._bufferAccessors.forEach((function(t){t.uploadBuffers(),t.reset()})),this._descriptorSetCache.update())},i.reset=function(){for(var t=0;t<this._batches.length;++t){var e=this._batches.array[t];e.isStatic||(e.clear(),this._drawBatchPool.free(e))}this._bufferAccessors.forEach((function(t){t.reset()})),this._meshDataArray.forEach((function(t){t.freeIAPool()})),this._meshDataArray.length=0,this._staticVBBuffer=null,this._currBID=-1,this._indexStart=0,this._currHash=0,this._currLayer=0,this._currRenderData=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currComponent=null,this._currTransform=null,this._batches.clear(),nl.sharedManager.reset()},i.switchBufferAccessor=function(t){void 0===t&&(t=Oh);var e=t===Oh?36:Uh(t);if(!this._staticVBBuffer||this._staticVBBuffer.vertexFormatBytes!==e){var i=this._bufferAccessors.get(e);i||(i=new Kh(this.device,t),this._bufferAccessors.set(e,i)),this._staticVBBuffer=i,this._currBID=-1}return this._staticVBBuffer},i.registerBufferAccessor=function(t,e){this._bufferAccessors.set(t,e)},i.updateBuffer=function(t,e){var i=this.switchBufferAccessor(t);this._currBID!==e&&(this._currBID=e,this._indexStart=i.getMeshBuffer(e).indexOffset)},i.commitComp=function(t,e,i,n,r){var s,a=0,o=-1;if(e&&e.chunk){if(!e.isValid())return;a=e.dataHash,s=e.material,o=e.chunk.bufferId}t.stencilStage===qh.ENTER_LEVEL||t.stencilStage===qh.ENTER_LEVEL_INVERTED?this._insertMaskBatch(t):t.stencilStage=nl.sharedManager.stage;var h=t.stencilStage;this._currHash===a&&0!==a&&this._currMaterial===s&&this._currDepthStencilStateStage===h||(this.autoMergeBatches(this._currComponent),e&&!e._isMeshBuffer&&this.updateBuffer(e.vertexFormat,o),this._currRenderData=e,this._currHash=e?e.dataHash:0,this._currComponent=t,this._currTransform=r,this._currMaterial=t.getRenderMaterial(0),this._currDepthStencilStateStage=h,this._currLayer=t.node.layer,i?(this._currTexture=i.getGFXTexture(),this._currSampler=i.getGFXSampler(),this._currTextureHash=i.getHash(),this._currSamplerHash=this._currSampler.hash):(this._currTexture=null,this._currSampler=null,this._currTextureHash=0,this._currSamplerHash=0)),n.fillBuffers(t,this)},i.commitIA=function(t,e,i,n,r){var s;this._currMaterial!==this._emptyMaterial&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates());var a=0;t&&(t.stencilStage=nl.sharedManager.stage,s=null!==t.customMaterial?nl.sharedManager.getStencilStage(t.stencilStage,n):nl.sharedManager.getStencilStage(t.stencilStage),a=nl.sharedManager.getStencilHash(t.stencilStage));var o=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();o.visFlags=t.node.layer,o.inputAssembler=e,o.useLocalData=r||null,i&&(o.texture=i.getGFXTexture(),o.sampler=i.getGFXSampler(),o.textureHash=i.getHash(),o.samplerHash=o.sampler.hash),o.fillPasses(n||null,s,a,null),this._batches.push(o)},i.commitMiddleware=function(t,e,i,n,r,s,a){var o=r.getGFXTexture();a&&this._middlewareEnableBatch&&this._middlewareBuffer===e&&this._currTexture===o&&this._currMaterial.hash===s.hash&&this._middlewareIndexStart+this._middlewareIndexCount===i&&this._currLayer===t.node.layer?this._middlewareIndexCount+=n:(this.autoMergeBatches(this._currComponent),this.resetRenderStates(),this._currComponent=t,this._currTexture=o,this._currSampler=r.getGFXSampler(),this._currTextureHash=r.getHash(),this._currLayer=t.node.layer,this._currSamplerHash=this._currSampler.hash,this._currHash=0,this._currTransform=a?null:t.node,this._middlewareEnableBatch=a,this._middlewareBuffer=e,this._currMaterial=s,this._middlewareIndexStart=i,this._middlewareIndexCount=n),this._currIsMiddleware=!0},i.commitModel=function(t,e,i){var n;this._currMaterial!==this._emptyMaterial&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates());var r=0;i&&(t.stencilStage===qh.ENTER_LEVEL||t.stencilStage===qh.ENTER_LEVEL_INVERTED?this._insertMaskBatch(t):t.stencilStage=nl.sharedManager.stage,n=nl.sharedManager.getStencilStage(t.stencilStage,i),r=nl.sharedManager.getStencilHash(t.stencilStage));var s=We.director.getTotalFrames();e&&(e.updateTransform(s),e.updateUBOs(s));for(var a=0;a<e.subModels.length;a++){var o=this._drawBatchPool.alloc(),h=e.subModels[a];o.visFlags=t.node.layer,o.model=e,o.texture=null,o.sampler=null,o.useLocalData=null,n||(n=null),o.fillPasses(i,n,r,h.patches),o.inputAssembler=h.inputAssembler,o.model.visFlags=o.visFlags,o.descriptorSet=h.descriptorSet,this._batches.push(o)}},i.setupStaticBatch=function(t,e){this.finishMergeBatches(),this._staticVBBuffer=e,this.currStaticRoot=t},i.endStaticBatch=function(){this.finishMergeBatches(),this.currStaticRoot=null,this._staticVBBuffer=null,this.switchBufferAccessor()},i.commitStaticBatch=function(t){this._batches.concat(t.drawBatchList),this.finishMergeBatches()},i.autoMergeBatches=function(t){if(this._currIsMiddleware)this.mergeBatchesForMiddleware(t);else{var e=this._currMaterial;if(e){var i,n=this._currRenderData,r=this._staticVBBuffer;if(n&&n._isMeshBuffer)i=n.requestIA(this.device),-1===this._meshDataArray.indexOf(n)&&this._meshDataArray.push(n);else if(r){var s=this._currBID,a=r.getMeshBuffer(s);if(!a)return;var o=a.indexOffset-this._indexStart;if(o<=0)return;Ni(this._indexStart<a.indexOffset),a.setDirty(),(i=a.requireFreeIA(this.device)).firstIndex=this._indexStart,i.indexCount=o,this._indexStart=a.indexOffset}if(this._currBID=-1,i){var h,l=0;t&&(h=null!==t.customMaterial?nl.sharedManager.getStencilStage(t.stencilStage,e):nl.sharedManager.getStencilStage(t.stencilStage),l=nl.sharedManager.getStencilHash(t.stencilStage));var u=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();u.visFlags=this._currLayer,u.texture=this._currTexture,u.sampler=this._currSampler,u.inputAssembler=i,u.useLocalData=this._currTransform,u.textureHash=this._currTextureHash,u.samplerHash=this._currSamplerHash,u.fillPasses(e,h,l,null),this._batches.push(u)}}}},i.mergeBatchesForMiddleware=function(t){var e,i;t.stencilStage=nl.sharedManager.stage,e=null!==t.customMaterial?nl.sharedManager.getStencilStage(t.stencilStage,this._currMaterial):nl.sharedManager.getStencilStage(t.stencilStage),i=nl.sharedManager.getStencilHash(t.stencilStage);var n=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();n.visFlags=t.node.layer;var r=this._middlewareBuffer.requireFreeIA(this.device);r.firstIndex=this._middlewareIndexStart,r.indexCount=this._middlewareIndexCount,n.inputAssembler=r,n.useLocalData=this._currTransform,n.texture=this._currTexture,n.sampler=this._currSampler,n.textureHash=this._currTextureHash,n.samplerHash=this._currSamplerHash,n.fillPasses(this._currMaterial||null,e,i,null),this._batches.push(n),this._currIsMiddleware=!1,this._middlewareBuffer=null},i.forceMergeBatches=function(t,e,i){this._currMaterial=t,e?(this._currTexture=e.getGFXTexture(),this._currSampler=e.getGFXSampler(),this._currTextureHash=e.getHash(),this._currSamplerHash=this._currSampler.hash):(this._currTexture=this._currSampler=null,this._currTextureHash=this._currSamplerHash=0),this._currLayer=i.node.layer,this.autoMergeBatches(i)},i.resetRenderStates=function(){this._currMaterial=this._emptyMaterial,this._currRenderData=null,this._currTexture=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0},i.finishMergeBatches=function(){this.autoMergeBatches(),this.resetRenderStates()},i.flushMaterial=function(t){this._currMaterial=t},i.walk=function(t,e){if(void 0===e&&(e=0),t.activeInHierarchy){var i=t.children,n=t._uiProps,r=n.uiComp,s=this._pOpacity,a=s,o=r&&r.color?r.color.a/255:1;if(this._pOpacity=a*=o*n.localOpacity,n._opacity=a,n.colorDirty&&this._opacityDirty++,r&&r.enabledInHierarchy&&r.fillBuffers(this),this._opacityDirty&&r&&!r.useVertexOpacity&&r.renderData&&r.renderData.vertexCount>0){!function(t,e){for(var i,n,r,s=t.vertexFormat,a=t.chunk.vb,o=0,h=0;h<s.length;++h){if(i=s[h],(n=ne[i.format]).hasAlpha)if(r=t.floatStride,n.size/n.count==1)for(var l=~~Ge(Math.round(255*e),0,255),u=o;u<a.length;u+=r)a[u]=(4294967040&a[u]|l)>>>0;else if(n.size/n.count==4)for(var c=o+3;c<a.length;c+=r)a[c]=e;o+=n.size>>2}}(r.renderData,a);var h=r.renderData.getMeshBuffer();h&&h.setDirty()}if(i.length>0&&!t._static)for(var l=0;l<i.length;++l){var u=i[l];this.walk(u,e)}n.colorDirty&&(this._opacityDirty--,n.colorDirty=!1),this._pOpacity=s,r&&r.enabledInHierarchy&&(r.postUpdateAssembler(this),(r.stencilStage===qh.ENTER_LEVEL||r.stencilStage===qh.ENTER_LEVEL_INVERTED)&&nl.sharedManager.getMaskStackSize()>0&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates(),nl.sharedManager.exitMask())),e+=1}},i._screenSort=function(t,e){return t.node.getSiblingIndex()-e.node.getSiblingIndex()},i._releaseDescriptorSetCache=function(t){this._descriptorSetCache.releaseDescriptorSetCache(t)},i._createClearModel=function(){if(!this._maskClearModel){this._maskClearMtl=Nn.get("default-clear-stencil"),this._maskClearModel=We.director.root.createModel(ni);var t=Uh(Ph),e=ke.gfxDevice,i=e.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.DEVICE,4*t,t)),n=new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0]);i.update(n);var r=e.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.DEVICE,6*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),s=new Uint16Array([0,1,2,2,1,3]);r.update(s),this._maskModelMesh=new qi([i],Ph,U.TRIANGLE_LIST,r),this._maskModelMesh.subMeshIdx=0,this._maskClearModel.initSubModel(0,this._maskModelMesh,this._maskClearMtl)}},i._insertMaskBatch=function(t){this.autoMergeBatches(this._currComponent),this.resetRenderStates(),this._createClearModel(),this._maskClearModel.node=this._maskClearModel.transform=t.node;var e=nl.sharedManager;e.pushMask(1);var i,n=e.clear(t),r=0,s=this._maskClearMtl;s&&(i=e.getStencilStage(n,s),r=e.getStencilHash(n));var a=this._maskClearModel,o=We.director.getTotalFrames();a&&(a.updateTransform(o),a.updateUBOs(o));for(var h=0;h<a.subModels.length;h++){var l=this._drawBatchPool.alloc(),u=a.subModels[h];l.visFlags=t.node.layer,l.model=a,l.texture=null,l.sampler=null,l.useLocalData=null,i||(i=null),l.fillPasses(s,i,r,u.patches),l.inputAssembler=u.inputAssembler,l.model.visFlags=l.visFlags,l.descriptorSet=u.descriptorSet,this._batches.push(l)}e.enableMask()},i.syncMeshBuffersToNative=function(){},Pi(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"currBufferAccessor",get:function(){return this._staticVBBuffer||(this._staticVBBuffer=this.switchBufferAccessor()),this._staticVBBuffer}},{key:"batches",get:function(){return this._batches}},{key:"currStaticRoot",set:function(t){this._currStaticRoot=t}},{key:"currIsStatic",set:function(t){this._currIsStatic=t}}]),t}()),Bv=function(){function t(){this._descriptorSet=null,this._transform=null,this._textureHash=0,this._samplerHash=0,this._localBuffer=null,this._transformUpdate=!0;var t=ke.gfxDevice;this._localData=new Float32Array(Yr.COUNT),this._localBuffer=t.createBuffer(new ft(g.UNIFORM|g.TRANSFER_DST,y.HOST|y.DEVICE,Yr.SIZE,Yr.SIZE))}var e=t.prototype;return e.initialize=function(t){var e=ke.gfxDevice;this._transform=t.useLocalData,this._textureHash=t.textureHash,this._samplerHash=t.samplerHash,wv.layout=t.passes[0].localSetLayout,this._descriptorSet=e.createDescriptorSet(wv),this._descriptorSet.bindBuffer(Yr.BINDING,this._localBuffer);var i=Br.SAMPLER_SPRITE;this._descriptorSet.bindTexture(i,t.texture),this._descriptorSet.bindSampler(i,t.sampler),this._descriptorSet.update(),this._transformUpdate=!0},e.updateTransform=function(t){t!==this._transform&&(this._transform=t,this._transformUpdate=!0,this.uploadLocalData())},e.equals=function(t,e,i){return this._transform===t&&this._textureHash===e&&this._samplerHash===i},e.reset=function(){this._transform=null,this._textureHash=0,this._samplerHash=0},e.destroy=function(){this._localBuffer&&(this._localBuffer.destroy(),this._localBuffer=null),this._descriptorSet&&(this._descriptorSet.destroy(),this._descriptorSet=null),this._localData=null},e.isValid=function(){return this._transform&&this._transform.isValid},e.uploadLocalData=function(){var t=this._transform;if((t.hasChangedFlags||t._dirtyFlags)&&(t.updateWorldTransform(),this._transformUpdate=!0),this._transformUpdate){var e=t.worldMatrix;Ue.toArray(this._localData,e,Yr.MAT_WORLD_OFFSET),Ue.inverseTranspose(Mv,e);var i=Ue.determinant(Mv),n=1/Math.sqrt(i);Ue.multiplyScalar(Mv,Mv,n),Ue.toArray(this._localData,Mv,Yr.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData),this._transformUpdate=!1}},Pi(t,[{key:"descriptorSet",get:function(){return this._descriptorSet}}]),t}(),Pv=function(){function t(){this._descriptorSetCache=new Map,this._dsCacheHashByTexture=new Map,this._localDescriptorSetCache=[],this._localCachePool=void 0,this._localCachePool=new e((function(){return new Bv}),16,(function(t){return t.destroy()}))}var i=t.prototype;return i.getDescriptorSet=function(t){var e;if(We.director.root,t.useLocalData){for(var i=this._localDescriptorSetCache,n=0,r=i.length;n<r;n++){var s=i[n];if(s.equals(t.useLocalData,t.textureHash,t.samplerHash))return s.descriptorSet}var a=this._localCachePool.alloc();return a.initialize(t),this._localDescriptorSetCache.push(a),a.descriptorSet}if(e=t.textureHash^t.samplerHash,this._descriptorSetCache.has(e))return this._descriptorSetCache.get(e);wv.layout=t.passes[0].localSetLayout;var o=ke.gfxDevice.createDescriptorSet(wv),h=Br.SAMPLER_SPRITE;return o.bindTexture(h,t.texture),o.bindSampler(h,t.sampler),o.update(),this._descriptorSetCache.set(e,o),this._dsCacheHashByTexture.set(t.textureHash,e),o},i.update=function(){var t=this._localDescriptorSetCache,e=[];t.forEach((function(i){if(i.isValid())i.uploadLocalData();else{i.reset();var n=t.indexOf(i);e.push(n)}}));for(var i=e.length-1;i>=0;i--)t.splice(e[i],1)},i.reset=function(){var t=this;this._localDescriptorSetCache.forEach((function(e){t._localCachePool.free(e)})),this._localDescriptorSetCache.length=0},i.releaseDescriptorSetCache=function(t){var e=this._dsCacheHashByTexture.get(t);e&&this._descriptorSetCache.has(e)&&(this._descriptorSetCache.get(e).destroy(),this._descriptorSetCache.delete(e),this._dsCacheHashByTexture.delete(t))},i.destroy=function(){this._descriptorSetCache.forEach((function(t){t.destroy()})),this._descriptorSetCache.clear(),this._dsCacheHashByTexture.clear(),this._localDescriptorSetCache.length=0,this._localCachePool.destroy()},t}();We.internal.Batcher2D=Iv,t("UIDrawBatch",function(t){function e(){return t.apply(this,arguments)||this}return He(e,t),e}(Rp)),Rr(Xh.prototype,"MeshBuffer",["byteStart","vertexStart","indicesStart","request"].map((function(t){return{name:t,suggest:"please use meshBuffer.accessor."+t+" instead"}}))),zn(Xh.prototype,"MeshBuffer",[{name:"indicesOffset",newName:"indexOffset"}]),Vn(Xh.prototype,"MeshBuffer",[{name:"vertexBuffers"},{name:"indexBuffer"}]),zn(Iv.prototype,"Batcher2D",[{name:"currBufferBatch",newName:"currBufferAccessor"},{name:"acquireBufferBatch",newName:"switchBufferAccessor"}]),Vn(El.prototype,"MeshRenderData",[{name:"formatByte"},{name:"byteStart"},{name:"byteCount"}]),zn(El.prototype,"MeshRenderData",[{name:"indicesStart",newName:"indexStart"}]),t("QuadRenderData",function(t){function e(e){var i;return i=t.call(this,e)||this,Zi(9006),i}return He(e,t),e}(El));var Dv,Ov=ln.document,Fv=null,Lv=-1,Nv="BES bswy:->@123丁ぁᄁ",kv=Object.create(null),Uv=[],Gv=3e3;function Vv(){for(var t=!0,e=Date.now(),i=Uv.length-1;i>=0;i--){var n=Uv[i],r=n.fontFamilyName;if(e-n.startTime>Gv)Zi(4933,r),n.onComplete(null,r),Uv.splice(i,1);else{var s=n.refWidth,a="40px "+r;Fv.font=a,s!==vh(Fv,Nv,a)?(Uv.splice(i,1),n.onComplete(null,r)):t=!1}}t&&(clearInterval(Lv),Lv=-1)}function Hv(t,e,i){var n=function(t){var e=t.lastIndexOf(".ttf");if(-1===e)return t;var i,n=t.lastIndexOf("/");return-1!==(i=-1===n?t.substring(0,e)+"_LABEL":t.substring(n+1,e)+"_LABEL").indexOf(" ")&&(i='"'+i+'"'),i}(t);if(kv[n])i(null,n);else{if(!Fv){var r=Ov.createElement("canvas");r.width=100,r.height=100,Fv=r.getContext("2d")}var s=vh(Fv,Nv,"40px "+n),a=Ov.createElement("style");a.type="text/css";var o="";Number.isNaN(n)?o+="@font-face { font-family:"+n+"; src:":o+='@font-face { font-family:"'+n+'"; src:',o+='url("'+t+'");',a.textContent=o+"}",Ov.body.appendChild(a);var h,l,u,c,d,_,f=Ov.createElement("div"),p=f.style;if(p.fontFamily=n,f.innerHTML=".",p.position="absolute",p.left="-100px",p.top="-100px",Ov.body.appendChild(f),function(){if(void 0===Dv)if("FontFace"in ln){var t=/Gecko.*Firefox\/(\d+)/.exec(ln.navigator.userAgent),e=/OS X.*Version\/10\..*Safari/.exec(ln.navigator.userAgent)&&/Apple/.exec(ln.navigator.vendor);Dv=t?parseInt(t[1],10)>42:!e}else Dv=!1;return Dv}())h=Date.now(),l=n,u=i,c=new Promise((function(t,e){!function i(){Date.now()-h>=Gv?e():Ov.fonts.load("40px "+l).then((function(e){e.length>=1?t():setTimeout(i,100)}),(function(){e()}))}()})),d=null,_=new Promise((function(t,e){d=setTimeout(e,Gv)})),Promise.race([_,c]).then((function(){d&&(clearTimeout(d),d=null),u(null,l)}),(function(){Zi(4933,l),u(null,l)}));else{var g={fontFamilyName:n,refWidth:s,onComplete:i,startTime:Date.now()};Uv.push(g),-1===Lv&&(Lv=setInterval(Vv,100))}kv[n]=a}}function zv(t,e,i,n){var r=new th;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}jr.register({".font":Hv,".eot":Hv,".ttf":Hv,".woff":Hv,".svg":Hv,".ttc":Hv}),Kr.register({".font":zv,".eot":zv,".ttf":zv,".woff":zv,".svg":zv,".ttc":zv}),We.UI={MeshBuffer:Xh,spriteAssembler:Rv,graphicsAssembler:dg,labelAssembler:Nm,RenderData:Sl,MeshRenderData:El},qr.on(Zr.EVENT_POST_SUBSYSTEM_INIT,(function(){Zv.init()}));var Xv,Wv,Yv,jv,Kv,qv,Zv=t("SortingLayers",function(){function t(){}return t.getSortingPriority=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),(t+32768<<16|e+32768)>>>0},t.getLayerIndex=function(t){void 0===t&&(t=0);var e=0;return this.indexMap.has(t)?e=this.indexMap.get(t):hn(2105),e},t.getLayerIndexByName=function(t){var e=this.getLayerByName(t);return this.getLayerIndex(e)},t.getLayerName=function(t){void 0===t&&(t=0);var e="";return this.nameMap.has(t)?e=this.nameMap.get(t):hn(2105),e},t.getLayerByName=function(t){for(var e=this.nameMap.size,i=this.nameMap.keys(),n=0,r=0;r<e;r++)if(n=i.next().value,this.nameMap.get(n)===t)return n;return hn(2106),0},t.isLayerValid=function(t){return!!this.indexMap.has(t)||(hn(2105),!1)},t.getBuiltinLayers=function(){return[{id:0,name:"default",value:0}]},t.init=function(){var e=Tr.querySettings(Sr.Category.ENGINE,"sortingLayers");e&&0!==e.length||(e=this.getBuiltinLayers()),t.resetState();for(var i=0;i<e.length;i++){var n=e[i];t.setLayer(n.id,n.name,n.value),t.Enum[n.name]=n.id}fr.update(t.Enum),fr.sortList(t.Enum,(function(e,i){return t.getLayerIndex(e.value)-t.getLayerIndex(i.value)}))},t.setLayer=function(t,e,i){this.nameMap.set(t,e),this.indexMap.set(t,i)},t.resetState=function(){for(var e=Object.keys(t.Enum),i=0;i<e.length;i++)delete t.Enum[t.Enum[e[i]]],delete t.Enum[e[i]];t.indexMap.clear(),t.nameMap.clear()},t}());Zv.nameMap=new Map,Zv.indexMap=new Map,Zv.Enum=fr({default:0}),t("Sorting",(Xv=Ki("cc.Sorting"),Wv=Tn(Zv.Enum),Xv(Yv=bn((jv=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._sortingLayer=Kv&&Kv(),e._sortingOrder=qv&&qv(),e._modelRenderer=null,e}He(e,t);var i=e.prototype;return i.__preload=function(){this._modelRenderer=this.getComponent("cc.ModelRenderer"),this._modelRenderer||Zi(16301,this.node.name),this._updateSortingPriority()},i._updateSortingPriority=function(){var t=Zv.getLayerIndex(this._sortingLayer),e=Zv.getSortingPriority(t,this._sortingOrder);this._modelRenderer&&this._modelRenderer.isValid&&(this._modelRenderer.priority=e)},Pi(e,[{key:"sortingLayer",get:function(){return this._sortingLayer},set:function(t){t!==this._sortingLayer&&Zv.isLayerValid(t)&&(this._sortingLayer=t,this._updateSortingPriority())}},{key:"sortingOrder",get:function(){return this._sortingOrder},set:function(t){t!==this._sortingOrder&&(this._sortingOrder=Ge(t,-32768,32767),this._updateSortingPriority())}}]),e}(Pn),gn(jv.prototype,"sortingLayer",[Wv],Object.getOwnPropertyDescriptor(jv.prototype,"sortingLayer"),jv.prototype),Kv=tn(jv.prototype,"_sortingLayer",[en],(function(){return Zv.Enum.default})),qv=tn(jv.prototype,"_sortingOrder",[en],(function(){return 0})),Yv=jv))||Yv)||Yv));var Qv,Jv,$v,ty,ey,iy,ny,ry,sy,ay,oy,hy,ly,uy,cy,dy,_y,fy,py,gy,my,vy,yy,Ty,Sy,Ey,Ay,Cy,Ry,by,xy,wy,My,Iy,By,Py,Dy,Oy,Fy,Ly,Ny,ky=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._morphRenderingInstance=null,e._usedMaterials=new Set,e}He(e,t);var i=e.prototype;return i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);if(this._morphRenderingInstance){var n=this._morphRenderingInstance.requiredPatches(e);if(n)return n.concat(null!=i?i:[])}return i},i.initSubModel=function(e,i,n){return t.prototype.initSubModel.call(this,e,i,this._launderMaterial(n))},i.destroy=function(){t.prototype.destroy.call(this),this._morphRenderingInstance=null},i.setSubModelMaterial=function(e,i){return t.prototype.setSubModelMaterial.call(this,e,this._launderMaterial(i))},i.setMorphRendering=function(t){this._morphRenderingInstance=t},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i),this._morphRenderingInstance&&this._morphRenderingInstance.adaptPipelineState(e,i)},i._launderMaterial=function(t){return t},e}(ni),Uy=Ki,Gy=In,Vy=Tn,Hy=is,zy=en,Xy=fr({OFF:0,ON:1}),Wy=fr({OFF:0,ON:1});!function(t){t[t.NONE=0]="NONE",t[t.BAKED_CUBEMAP=1]="BAKED_CUBEMAP",t[t.PLANAR_REFLECTION=2]="PLANAR_REFLECTION"}(Ny||(Ny=t("ReflectionProbeType",{})));var Yy,jy,Ky,qy,Zy,Qy,Jy,$y,tT=(Qv=Uy("cc.ModelBakeSettings"),Jv=Hy("_recieveShadow"),$v=Vy(Qr),ty=Vy(Jr),ey=Vy(Jr),iy=Vy(fr(Ny)),ny=Vy(Jr),Qv((vy=my=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).texture=ay&&ay(),e.uvParam=oy&&oy(),e._bakeable=hy&&hy(),e._castShadow=ly&&ly(),e._receiveShadow=uy&&uy(),e._lightmapSize=cy&&cy(),e._useLightProbe=dy&&dy(),e._bakeToLightProbe=_y&&_y(),e._reflectionProbeType=fy&&fy(),e._bakeToReflectionProbe=py&&py(),e._probeCubemap=gy&&gy(),e._probePlanarmap=null,e}return He(e,t),Pi(e,[{key:"bakeable",get:function(){return this._bakeable},set:function(t){this._bakeable=t}},{key:"castShadow",get:function(){return this._castShadow},set:function(t){this._castShadow=t}},{key:"receiveShadow",get:function(){return this._receiveShadow},set:function(t){this._receiveShadow=t}},{key:"lightmapSize",get:function(){return this._lightmapSize},set:function(t){this._lightmapSize=t}},{key:"useLightProbe",get:function(){return this._useLightProbe},set:function(t){this._useLightProbe=t,this.emit(e.USE_LIGHT_PROBE_CHANGED)}},{key:"bakeToLightProbe",get:function(){return this._bakeToLightProbe},set:function(t){this._bakeToLightProbe=t}},{key:"reflectionProbe",get:function(){return this._reflectionProbeType},set:function(t){this._reflectionProbeType=t,this.emit(e.REFLECTION_PROBE_CHANGED)}},{key:"bakeToReflectionProbe",get:function(){return this._bakeToReflectionProbe},set:function(t){this._bakeToReflectionProbe=t,this.emit(e.BAKE_TO_REFLECTION_PROBE_CHANGED)}}]),e}(es),my.USE_LIGHT_PROBE_CHANGED="use_light_probe_changed",my.REFLECTION_PROBE_CHANGED="reflection_probe_changed",my.BAKE_TO_REFLECTION_PROBE_CHANGED="bake_to_reflection_probe_changed",ay=tn((sy=vy).prototype,"texture",[zy],(function(){return null})),oy=tn(sy.prototype,"uvParam",[zy],(function(){return new _n})),hy=tn(sy.prototype,"_bakeable",[zy],(function(){return!1})),ly=tn(sy.prototype,"_castShadow",[zy],(function(){return!1})),uy=tn(sy.prototype,"_receiveShadow",[Jv],(function(){return!1})),cy=tn(sy.prototype,"_lightmapSize",[zy],(function(){return 64})),dy=tn(sy.prototype,"_useLightProbe",[zy],(function(){return!1})),_y=tn(sy.prototype,"_bakeToLightProbe",[zy],(function(){return!0})),fy=tn(sy.prototype,"_reflectionProbeType",[zy],(function(){return Ny.NONE})),py=tn(sy.prototype,"_bakeToReflectionProbe",[zy],(function(){return!0})),gy=tn(sy.prototype,"_probeCubemap",[zy],(function(){return null})),gn(sy.prototype,"lightmapSize",[$v],Object.getOwnPropertyDescriptor(sy.prototype,"lightmapSize"),sy.prototype),gn(sy.prototype,"useLightProbe",[ty],Object.getOwnPropertyDescriptor(sy.prototype,"useLightProbe"),sy.prototype),gn(sy.prototype,"bakeToLightProbe",[ey],Object.getOwnPropertyDescriptor(sy.prototype,"bakeToLightProbe"),sy.prototype),gn(sy.prototype,"reflectionProbe",[iy],Object.getOwnPropertyDescriptor(sy.prototype,"reflectionProbe"),sy.prototype),gn(sy.prototype,"bakeToReflectionProbe",[ny],Object.getOwnPropertyDescriptor(sy.prototype,"bakeToReflectionProbe"),sy.prototype),ry=sy))||ry),eT=function(e){return t({MeshRenderer:e,ModelComponent:e}),e}((yy=Uy("cc.MeshRenderer"),Ty=Gy(100),Sy=Vy($r),Ey=Vy($r),Ay=Vy(Xy),Cy=Vy(Wy),Ry=Vy(mo),yy(by=Ty((Ly=Fy=function(t){function e(){var e;return(e=t.call(this)||this).bakeSettings=wy&&wy(),e._mesh=My&&My(),e._shadowCastingMode=Iy&&Iy(),e._shadowReceivingMode=By&&By(),e._shadowBias=Py&&Py(),e._shadowNormalBias=Dy&&Dy(),e._subMeshShapesWeights=[],e._modelType=void 0,e._model=null,e._morphInstance=null,e._enableMorph=Oy&&Oy(),e._modelType=ni,Tr.querySettings(Sr.Category.RENDERING,"highQualityMode")&&(e._shadowCastingMode=Xy.ON,e.bakeSettings.castShadow=!0,e.bakeSettings.receiveShadow=!0),e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._mesh&&this._mesh.initialize(),this._validateShapeWeights()||this._initSubMeshShapesWeights(),this._watchMorphInMesh(),this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias(),this._updateUseLightProbe(),this._updateBakeToReflectionProbe(),this._updateUseReflectionProbe()},i.onRestore=function(){this._updateModels(),this.enabledInHierarchy&&this._attachToScene(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias(),this._updateUseLightProbe(),this._updateBakeToReflectionProbe(),this._updateUseReflectionProbe()},i.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(xn.MOBILITY_CHANGED,this.onMobilityChanged,this),this.bakeSettings.on(tT.USE_LIGHT_PROBE_CHANGED,this.onUseLightProbeChanged,this),this.bakeSettings.on(tT.REFLECTION_PROBE_CHANGED,this.onReflectionProbeChanged,this),this.bakeSettings.on(tT.BAKE_TO_REFLECTION_PROBE_CHANGED,this.onBakeToReflectionProbeChanged,this),this._model||this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias(),this._updateBakeToReflectionProbe(),this._updateUseReflectionProbe(),this._onUpdateLocalShadowBias(),this._updateUseLightProbe(),this._attachToScene()},i.onDisable=function(){this._model&&this._detachFromScene(),this.node.off(xn.MOBILITY_CHANGED,this.onMobilityChanged,this),this.bakeSettings.off(tT.USE_LIGHT_PROBE_CHANGED,this.onUseLightProbeChanged,this),this.bakeSettings.off(tT.REFLECTION_PROBE_CHANGED,this.onReflectionProbeChanged,this),this.bakeSettings.off(tT.BAKE_TO_REFLECTION_PROBE_CHANGED,this.onBakeToReflectionProbeChanged,this)},i.onDestroy=function(){this._model&&(We.director.root.destroyModel(this._model),this._model=null,this._models.length=0),this._morphInstance&&this._morphInstance.destroy()},i.onGeometryChanged=function(){if(this._model&&this._mesh){var t=this._mesh.struct;this._model.createBoundingShape(t.minPosition,t.maxPosition),this._model.updateWorldBound(),this._model.onGeometryChanged()}},i.getWeight=function(t,e){var i=this._subMeshShapesWeights;Ni(t<i.length);var n=this._subMeshShapesWeights[t];return Ni(e<n.length),n[e]},i.setWeights=function(t,e){var i=this._subMeshShapesWeights;e>=i.length||i[e].length===t.length&&(i[e]=t.slice(0),this._uploadSubMeshShapesWeights(e))},i.setWeight=function(t,e,i){var n=this._subMeshShapesWeights;if(!(e>=n.length)){var r=n[e];i>=r.length||(r[i]=t,this._uploadSubMeshShapesWeights(e))}},i.setInstancedAttribute=function(t,e){if(this.model)for(var i=this.model.subModels,n=0;n<i.length;n++)for(var r=i[n].instancedAttributeBlock,s=r.attributes,a=r.views,o=0;o<s.length;o++)if(s[o].name===t){a[o].set(e);break}},i._updateLightmap=function(t,e,i,n,r){this.bakeSettings.texture=t,this.bakeSettings.uvParam.x=e,this.bakeSettings.uvParam.y=i,this.bakeSettings.uvParam.z=n,this.bakeSettings.uvParam.w=r,this._onUpdateLightingmap()},i.updateProbeCubemap=function(t,e){if((!this.bakeSettings._probeCubemap||this.bakeSettings._probeCubemap!==t)&&(this.bakeSettings._probeCubemap=t,null!==this.model)){var i=this.bakeSettings._probeCubemap;i||!this.node.scene||e||(i=this.node.scene._globals.skybox.envmap),this.model.updateReflectionProbeCubemap(i)}},i.updateProbePlanarMap=function(t){this.bakeSettings._probePlanarmap!==t&&(this.bakeSettings._probePlanarmap=t,null!==this.model&&this.model.updateReflectionProbePlanarMap(this.bakeSettings._probePlanarmap))},i._updateReflectionProbeTexture=function(){if(null!==this.model)if(this.bakeSettings.reflectionProbe===Ny.BAKED_CUBEMAP){var t=this.bakeSettings._probeCubemap;!t&&this.node.scene&&(t=this.node.scene._globals.skybox.envmap),this.model.updateReflectionProbeCubemap(t),this.model.updateReflectionProbePlanarMap(null)}else this.bakeSettings.reflectionProbe===Ny.PLANAR_REFLECTION?(this.model.updateReflectionProbePlanarMap(this.bakeSettings._probePlanarmap),this.model.updateReflectionProbeCubemap(null)):(this.model.updateReflectionProbeCubemap(null),this.model.updateReflectionProbePlanarMap(null))},i._updateModels=function(){if(this.enabledInHierarchy){var t=this._model;if(t?(t.destroy(),t.initialize(),t.node=t.transform=this.node):this._createModel(),this._model){if(this._mesh){var e=this._mesh.struct;this._model.createBoundingShape(e.minPosition,e.maxPosition)}this._model.initLightingmap(this.bakeSettings.texture,this.bakeSettings.uvParam),this._updateUseLightProbe(),this._updateModelParams(),this._onUpdateLightingmap(),this._onUpdateLocalShadowBias(),this._updateUseReflectionProbe()}}},i._createModel=function(){var t=this._morphInstance&&this._modelType===ni?ky:this._modelType,e=this._model=We.director.root.createModel(t);e.visFlags=this.visibility,e.node=e.transform=this.node,this._models.length=0,this._models.push(this._model),this._morphInstance&&e instanceof ky&&e.setMorphRendering(this._morphInstance)},i._attachToScene=function(){if(this.node.scene&&this._model){var t=this._getRenderScene();null!==this._model.scene&&this._detachFromScene(),t.addModel(this._model)}},i._detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},i._updateModelParams=function(){if(this._mesh&&this._model){this.node.hasChangedFlags|=pr.POSITION,this._model.transform.hasChangedFlags|=pr.POSITION,this._model.isDynamicBatching=this._isBatchingEnabled();var t=this._mesh?this._mesh.renderingSubMeshes.length:0,e=this._mesh.renderingSubMeshes;if(e)for(var i=0;i<t;++i){var n=this.getRenderMaterial(i);n&&!n.isValid&&(n=null);var r=e[i];r&&this._model.initSubModel(i,r,n||this._getBuiltinMaterial())}this._model.enabled=!0}},i._onUpdateLightingmap=function(){null!==this.model&&this.model.updateLightingmap(this.bakeSettings.texture,this.bakeSettings.uvParam),this.setInstancedAttribute("a_lightingMapUVParam",[this.bakeSettings.uvParam.x,this.bakeSettings.uvParam.y,this.bakeSettings.uvParam.z,this.bakeSettings.uvParam.w])},i._onUpdateLocalShadowBias=function(){null!==this.model&&this.model.updateLocalShadowBias(),this.setInstancedAttribute("a_localShadowBias",[this._shadowBias,this._shadowNormalBias])},i._onMaterialModified=function(t,e){this._model&&this._model.inited&&this._onRebuildPSO(t,e||this._getBuiltinMaterial())},i._onRebuildPSO=function(t,e){this._model&&this._model.inited&&(this._model.isDynamicBatching=this._isBatchingEnabled(),this._model.setSubModelMaterial(t,e),this._onUpdateLightingmap(),this._onUpdateLocalShadowBias(),this._updateReflectionProbeTexture())},i._onMeshChanged=function(){},i._clearMaterials=function(){if(this._model)for(var t=this._model.subModels,e=0;e<t.length;++e)this._onMaterialModified(e,null)},i._getBuiltinMaterial=function(){return Nn.get("missing-material")},i._onVisibilityChange=function(t){this._model&&(this._model.visFlags=t)},i._updateShadowBias=function(){this._model&&(this._model.shadowBias=this._shadowBias)},i._updateShadowNormalBias=function(){this._model&&(this._model.shadowNormalBias=this._shadowNormalBias)},i._updateCastShadow=function(){this._model&&(this._shadowCastingMode===Xy.OFF?this._model.castShadow=!1:(Ni(this._shadowCastingMode===Xy.ON,"ShadowCastingMode "+this._shadowCastingMode+" is not supported."),this._model.castShadow=!0))},i._updateReceiveShadow=function(){this._model&&(this._shadowReceivingMode===Wy.OFF?this._model.receiveShadow=!1:this._model.receiveShadow=!0)},i.onMobilityChanged=function(){this._updateUseLightProbe()},i.onUseLightProbeChanged=function(){this._updateUseLightProbe()},i.onReflectionProbeChanged=function(){this._updateUseReflectionProbe(),this.bakeSettings.reflectionProbe===Ny.BAKED_CUBEMAP?We.internal.reflectionProbeManager.updateUseCubeModels(this._model):this.bakeSettings.reflectionProbe===Ny.PLANAR_REFLECTION&&We.internal.reflectionProbeManager.updateUsePlanarModels(this._model)},i.onBakeToReflectionProbeChanged=function(){this._updateBakeToReflectionProbe()},i._updateUseLightProbe=function(){if(this._model){var t=this.node;this._mesh&&t&&t.mobility===ts.Movable&&this.bakeSettings.useLightProbe?this._model.useLightProbe=!0:this._model.useLightProbe=!1}},i._isBatchingEnabled=function(){for(var t=0;t<this._materials.length;++t){var e=this._materials[t];if(e)for(var i=0;i<e.passes.length;++i)if(e.passes[i].batchingScheme)return!0}return!1},i._updateUseReflectionProbe=function(){this._model&&(this._model.reflectionProbeType=this.bakeSettings.reflectionProbe,this._updateReflectionProbeTexture())},i._updateBakeToReflectionProbe=function(){this._model&&(this._model.bakeToReflectionProbe=this.bakeSettings.bakeToReflectionProbe)},i._watchMorphInMesh=function(){if(this._morphInstance&&(this._morphInstance.destroy(),this._morphInstance=null),this._enableMorph&&this._mesh&&this._mesh.struct.morph&&this._mesh.morphRendering){this._morphInstance=this._mesh.morphRendering.createInstance();for(var t=this._mesh.struct.primitives.length,e=0;e<t;++e)this._uploadSubMeshShapesWeights(e);this._model&&this._model instanceof ky&&this._model.setMorphRendering(this._morphInstance)}},i._initSubMeshShapesWeights=function(){var t=this._mesh;if(this._subMeshShapesWeights.length=0,t){var e=t.struct.morph;if(e){var i=e.weights;this._subMeshShapesWeights=e.subMeshMorphs.map((function(t){return t?t.weights?t.weights.slice(0):i?(Ni(i.length===t.targets.length),i.slice(0)):new Array(t.targets.length).fill(0):[]}))}}},i._validateShapeWeights=function(){var t=this._mesh,e=this._subMeshShapesWeights;if(!t||!t.struct.morph)return 0===e.length;var i=t.struct.morph;return i.subMeshMorphs.length===e.length&&e.every((function(t,e){var n,r,s=t.length;return(null!==(n=null===(r=i.subMeshMorphs[e])||void 0===r?void 0:r.targets.length)&&void 0!==n?n:0)===s}))},i._uploadSubMeshShapesWeights=function(t){var e;null===(e=this._morphInstance)||void 0===e||e.setWeights(t,this._subMeshShapesWeights[t])},Pi(e,[{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._updateShadowBias(),this._onUpdateLocalShadowBias()}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._updateShadowNormalBias(),this._onUpdateLocalShadowBias()}},{key:"shadowCastingMode",get:function(){return this._shadowCastingMode},set:function(t){this._shadowCastingMode=t,this._updateCastShadow()}},{key:"receiveShadow",get:function(){return this._shadowReceivingMode},set:function(t){this._shadowReceivingMode=t,this._updateReceiveShadow()}},{key:"mesh",get:function(){return this._mesh},set:function(t){var e=this._mesh,i=this._mesh=t;null==i||i.initialize(),this._initSubMeshShapesWeights(),this._watchMorphInMesh(),this._onMeshChanged(e),this._updateModels(),this.enabledInHierarchy&&this._attachToScene(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateUseLightProbe(),this._updateUseReflectionProbe()}},{key:"model",get:function(){return this._model}},{key:"enableMorph",get:function(){return this._enableMorph},set:function(t){this._enableMorph=t}}]),e}(Bf),Fy.ShadowCastingMode=Xy,Fy.ShadowReceivingMode=Wy,wy=tn((xy=Ly).prototype,"bakeSettings",[zy],(function(){return new tT(this)})),My=tn(xy.prototype,"_mesh",[zy],(function(){return null})),Iy=tn(xy.prototype,"_shadowCastingMode",[zy],(function(){return Xy.OFF})),By=tn(xy.prototype,"_shadowReceivingMode",[zy],(function(){return Wy.ON})),Py=tn(xy.prototype,"_shadowBias",[zy],(function(){return 0})),Dy=tn(xy.prototype,"_shadowNormalBias",[zy],(function(){return 0})),gn(xy.prototype,"shadowBias",[Sy],Object.getOwnPropertyDescriptor(xy.prototype,"shadowBias"),xy.prototype),gn(xy.prototype,"shadowNormalBias",[Ey],Object.getOwnPropertyDescriptor(xy.prototype,"shadowNormalBias"),xy.prototype),gn(xy.prototype,"shadowCastingMode",[Ay],Object.getOwnPropertyDescriptor(xy.prototype,"shadowCastingMode"),xy.prototype),gn(xy.prototype,"receiveShadow",[Cy],Object.getOwnPropertyDescriptor(xy.prototype,"receiveShadow"),xy.prototype),gn(xy.prototype,"mesh",[Ry],Object.getOwnPropertyDescriptor(xy.prototype,"mesh"),xy.prototype),Oy=tn(xy.prototype,"_enableMorph",[zy],(function(){return!0})),by=xy))||by)||by));function iT(t,e){var i=t.sharedMaterials.length;if(i!==e.sharedMaterials.length)return!1;for(var n=0;n<i;n++)if(t.getRenderMaterial(n)!==e.getRenderMaterial(n))return!1;return!0}t("BatchingUtility",function(){function t(){}return t.batchStaticModel=function(t,e){var i=t.getComponentsInChildren(eT);if(i.length<2)return console.error("the number of static models to batch is less than 2,it needn't batch."),!1;for(var n=1;n<i.length;n++){if(!i[0].mesh.validateMergingMesh(i[n].mesh))return console.error("the meshes of "+i[0].node.name+" and "+i[n].node.name+" can't be merged"),!1;if(!iT(i[0],i[n]))return console.error("the materials of "+i[0].node.name+" and "+i[n].node.name+" can't be merged"),!1}var r=new mo,s=new Ue,a=new Ue;t.getWorldMatrix(a),Ue.invert(a,a);for(var o=0;o<i.length;o++){var h=i[o];h.node.getWorldMatrix(s),Ue.multiply(s,a,s),r.merge(i[o].mesh,s),h.enabled=!1}var l=e.addComponent(eT);return l.mesh=r,l.sharedMaterials=i[0].sharedMaterials,!0},t.unbatchStaticModel=function(t,e){for(var i=t.getComponentsInChildren(eT),n=0;n<i.length;n++)i[n].enabled=!0;var r=e.getComponent(eT);return r&&(r.mesh&&r.mesh.destroyRenderingMesh(),r.destroy()),!0},t}()),zn(mo.prototype,"Mesh.prototype",[{name:"renderingMesh",newName:"renderingSubMeshes"}]),Vn(mo.prototype,"Mesh.prototype",[{name:"hasFlatBuffers"},{name:"destroyFlatBuffers"}]);var nT,rT,sT,aT,oT,hT,lT,uT,cT,dT,_T,fT,pT,gT,mT,vT,yT,TT=t("Skeleton",(Yy=Ki("cc.Skeleton"),jy=Tn([ns]),Ky=Tn([Ue]),Yy((Zy=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._joints=Qy&&Qy(),e._bindposes=Jy&&Jy(),e._hash=$y&&$y(),e._invBindposes=null,e}He(e,t);var i=e.prototype;return i.destroy=function(){var e,i;return null===(e=We.director.root)||void 0===e||null===(i=e.dataPoolManager)||void 0===i||i.releaseSkeleton(this),t.prototype.destroy.call(this)},i.validate=function(){return this.joints.length>0&&this.bindposes.length>0},Pi(e,[{key:"joints",get:function(){return this._joints},set:function(t){this._joints=t}},{key:"bindposes",get:function(){return this._bindposes},set:function(t){this._bindposes=t}},{key:"inverseBindposes",get:function(){if(!this._invBindposes){this._invBindposes=[];for(var t=0;t<this._bindposes.length;t++){var e=new Ue;Ue.invert(e,this._bindposes[t]),this._invBindposes.push(e)}}return this._invBindposes}},{key:"hash",get:function(){if(!this._hash){for(var t="",e=0;e<this._bindposes.length;e++){var i=this._bindposes[e];t+=i.m00.toPrecision(2)+" "+i.m01.toPrecision(2)+" "+i.m02.toPrecision(2)+" "+i.m03.toPrecision(2)+" "+i.m04.toPrecision(2)+" "+i.m05.toPrecision(2)+" "+i.m06.toPrecision(2)+" "+i.m07.toPrecision(2)+" "+i.m08.toPrecision(2)+" "+i.m09.toPrecision(2)+" "+i.m10.toPrecision(2)+" "+i.m11.toPrecision(2)+" "+i.m12.toPrecision(2)+" "+i.m13.toPrecision(2)+" "+i.m14.toPrecision(2)+" "+i.m15.toPrecision(2)+"\n"}this._hash=nn(t,666)}return this._hash}}]),e}($i),Qy=tn(Zy.prototype,"_joints",[jy],(function(){return[]})),Jy=tn(Zy.prototype,"_bindposes",[Ky],(function(){return[]})),$y=tn(Zy.prototype,"_hash",[en],(function(){return 0})),qy=Zy))||qy));We.Skeleton=TT,Vn(eT.prototype,"MeshRenderer.prototype",[{name:"enableDynamicBatching"},{name:"recieveShadows"}]),We.ModelComponent=eT,br(eT,"cc.ModelComponent");var ST,ET,AT,CT,RT,bT,xT,wT,MT,IT,BT,PT,DT,OT,FT,LT,NT,kT,UT,GT,VT,HT,zT,XT,WT,YT,jT,KT,qT,ZT,QT,JT,$T,tS,eS,iS,nS,rS,sS,aS,oS,hS,lS,uS,cS,dS,_S,fS,pS,gS,mS,vS,yS,TS,SS,ES,AS,CS,RS,bS,xS,wS,MS,IS,BS,PS,DS,OS,FS,LS,NS,kS,US,GS,VS,HS,zS,XS,WS,YS,jS,KS,qS,ZS,QS,JS,$S,tE,eE,iE,nE,rE,sE=new ji,aE=fr({LUMINOUS_FLUX:0,LUMINANCE:1}),oE=Ki("cc.StaticLightSettings")((rT=function(){function t(){this._baked=sT&&sT(),this._editorOnly=aT&&aT(),this._castShadow=oT&&oT()}return Pi(t,[{key:"editorOnly",get:function(){return this._editorOnly},set:function(t){this._editorOnly=t}},{key:"baked",get:function(){return this._baked},set:function(t){this._baked=t}},{key:"castShadow",get:function(){return this._castShadow},set:function(t){this._castShadow=t}}]),t}(),sT=tn(rT.prototype,"_baked",[en],(function(){return!1})),aT=tn(rT.prototype,"_editorOnly",[en],(function(){return!1})),oT=tn(rT.prototype,"_castShadow",[en],(function(){return!1})),nT=rT))||nT,hE=function(e){return t({Light:e,LightComponent:e}),e}((hT=Ki("cc.Light"),lT=Tn(oE),uT=Tn(Xn.BitMask),hT((yT=vT=function(t){function e(){var e;return(e=t.call(this)||this)._color=_T&&_T(),e._useColorTemperature=fT&&fT(),e._colorTemperature=pT&&pT(),e._staticSettings=gT&&gT(),e._visibility=mT&&mT(),e._type=vi.UNKNOWN,e._lightType=void 0,e._light=null,e._lightType=Ti,e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._createLight()},i.onEnable=function(){this._attachToScene()},i.onDisable=function(){this._detachFromScene()},i.onDestroy=function(){this._destroyLight()},i._createLight=function(){this._light||(this._light=We.director.root.createLight(this._lightType)),this.color=this._color,this.useColorTemperature=this._useColorTemperature,this.colorTemperature=this._colorTemperature,this._light.node=this.node,this._light.baked=this.baked,this._light.visibility=this.visibility},i._destroyLight=function(){this._light&&(We.director.root.recycleLight(this._light),this._light=null)},i._attachToScene=function(){if(this._detachFromScene(),this._light&&!this._light.scene&&this.node.scene){var t=this._getRenderScene();switch(this._type){case vi.DIRECTIONAL:t.addDirectionalLight(this._light),t.setMainLight(this._light);break;case vi.SPHERE:t.addSphereLight(this._light);break;case vi.SPOT:t.addSpotLight(this._light)}}},i._detachFromScene=function(){if(this._light&&this._light.scene){var t=this._light.scene;switch(this._type){case vi.DIRECTIONAL:t.removeDirectionalLight(this._light),t.unsetMainLight(this._light);break;case vi.SPHERE:t.removeSphereLight(this._light);break;case vi.SPOT:t.removeSpotLight(this._light)}}},Pi(e,[{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._light&&(sE.x=t.r/255,sE.y=t.g/255,sE.z=t.b/255,this._light.color=sE)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(t){this._useColorTemperature=t,this._light&&(this._light.useColorTemperature=t)}},{key:"colorTemperature",get:function(){return this._colorTemperature},set:function(t){this._colorTemperature=t,this._light&&(this._light.colorTemperature=t)}},{key:"staticSettings",get:function(){return this._staticSettings},set:function(t){this._staticSettings=t}},{key:"type",get:function(){return this._type}},{key:"baked",get:function(){return this.staticSettings.baked},set:function(t){this.staticSettings.baked=t,null!==this._light&&(this._light.baked=t)}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t,this._light&&(this._light.visibility=t)}}]),e}(Pn),vT.Type=vi,vT.PhotometricTerm=aE,_T=tn((dT=yT).prototype,"_color",[en],(function(){return Ve.WHITE.clone()})),fT=tn(dT.prototype,"_useColorTemperature",[en],(function(){return!1})),pT=tn(dT.prototype,"_colorTemperature",[en],(function(){return 6550})),gT=tn(dT.prototype,"_staticSettings",[en],(function(){return new oE})),mT=tn(dT.prototype,"_visibility",[en],(function(){return vr})),gn(dT.prototype,"staticSettings",[lT],Object.getOwnPropertyDescriptor(dT.prototype,"staticSettings"),dT.prototype),gn(dT.prototype,"visibility",[uT],Object.getOwnPropertyDescriptor(dT.prototype,"visibility"),dT.prototype),cT=dT))||cT)),lE=rs,uE=en,cE=is,dE=Tn,_E=function(e){return t({DirectionalLight:e,DirectionalLightComponent:e}),e}((ST=Ki("cc.DirectionalLight"),ET=cE("_illuminance"),AT=lE({group:{name:"DynamicShadowSettings",displayOrder:1}}),CT=dE(Jr),RT=lE({group:{name:"DynamicShadowSettings",displayOrder:5}}),bT=dE(ui),xT=lE({group:{name:"DynamicShadowSettings",displayOrder:6}}),wT=dE($r),MT=lE({group:{name:"DynamicShadowSettings",displayOrder:7}}),IT=dE($r),BT=lE({group:{name:"DynamicShadowSettings",displayOrder:8}}),PT=dE($r),DT=lE({group:{name:"DynamicShadowSettings",displayOrder:9}}),OT=dE($r),FT=lE({group:{name:"DynamicShadowSettings",displayOrder:22}}),LT=dE($r),NT=lE({group:{name:"DynamicShadowSettings",displayOrder:10}}),kT=dE(ci),UT=lE({group:{name:"DynamicShadowSettings",displayOrder:11}}),GT=dE(Jr),VT=lE({group:{name:"DynamicShadowSettings",displayOrder:12}}),HT=dE($r),zT=lE({group:{name:"DynamicShadowSettings",displayOrder:13}}),XT=dE(di),WT=lE({group:{name:"DynamicShadowSettings",displayOrder:14}}),YT=dE(Jr),jT=lE({group:{name:"DynamicShadowSettings",displayOrder:15}}),KT=dE($r),qT=lE({group:{name:"DynamicShadowSettings",displayOrder:16}}),ZT=dE($r),QT=lE({group:{name:"DynamicShadowSettings",displayOrder:17}}),JT=dE($r),$T=lE({group:{name:"DynamicShadowSettings",displayOrder:19}}),tS=dE(Jr),eS=lE({group:{name:"DynamicShadowSettings",displayOrder:20}}),iS=dE(Jr),nS=lE({group:{name:"DynamicShadowSettings",displayOrder:21}}),rS=dE($r),ST((aS=function(t){function e(){var e;return(e=t.call(this)||this)._illuminanceHDR=oS&&oS(),e._illuminanceLDR=hS&&hS(),e._shadowEnabled=lS&&lS(),e._shadowPcf=uS&&uS(),e._shadowBias=cS&&cS(),e._shadowNormalBias=dS&&dS(),e._shadowSaturation=_S&&_S(),e._shadowDistance=fS&&fS(),e._shadowInvisibleOcclusionRange=pS&&pS(),e._csmLevel=gS&&gS(),e._csmLayerLambda=mS&&mS(),e._csmOptimizationMode=vS&&vS(),e._csmAdvancedOptions=yS&&yS(),e._csmLayersTransition=TS&&TS(),e._csmTransitionRange=SS&&SS(),e._shadowFixedArea=ES&&ES(),e._shadowNear=AS&&AS(),e._shadowFar=CS&&CS(),e._shadowOrthoSize=RS&&RS(),e._type=vi.DIRECTIONAL,e._light=null,e._lightType=Si,Tr.querySettings(Sr.Category.RENDERING,"highQualityMode")&&(e._shadowPcf=ui.SOFT_2X,e._shadowDistance=50,e.enableCSM=!0,e.staticSettings.castShadow=!0),e}return He(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._light&&(this._light.illuminanceHDR=this._illuminanceHDR,this._light.illuminanceLDR=this._illuminanceLDR,this._light.shadowEnabled=this._shadowEnabled,this._light.shadowPcf=this._shadowPcf,this._light.shadowBias=this._shadowBias,this._light.shadowNormalBias=this._shadowNormalBias,this._light.shadowSaturation=this._shadowSaturation,this._light.shadowDistance=this._shadowDistance,this._light.shadowInvisibleOcclusionRange=this._shadowInvisibleOcclusionRange,this._light.shadowFixedArea=this._shadowFixedArea,this._light.shadowNear=this._shadowNear,this._light.shadowFar=this._shadowFar,this._light.shadowOrthoSize=this._shadowOrthoSize,this._light.csmLevel=this._csmLevel,this._light.csmLayerLambda=this._csmLayerLambda,this._light.csmOptimizationMode=this._csmOptimizationMode,this._light.csmLayersTransition=this._csmLayersTransition,this._light.csmTransitionRange=this._csmTransitionRange)},Pi(e,[{key:"illuminance",get:function(){return We.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){We.director.root.pipeline.pipelineSceneData.isHDR?(this._illuminanceHDR=t,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR)):(this._illuminanceLDR=t,this._light&&(this._light.illuminanceLDR=this._illuminanceLDR))}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this._light&&(this._light.shadowEnabled=this._shadowEnabled)}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this._light&&(this._light.shadowPcf=this._shadowPcf)}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._light&&(this._light.shadowBias=this._shadowBias)}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._light&&(this._light.shadowNormalBias=this._shadowNormalBias)}},{key:"shadowSaturation",get:function(){return this._shadowSaturation},set:function(t){this._shadowSaturation=Ge(t,0,1),this._light&&(this._light.shadowSaturation=this._shadowSaturation)}},{key:"shadowDistance",get:function(){return this._shadowDistance},set:function(t){this._shadowDistance=Math.min(t,_i.MAX_FAR),this._shadowDistance/.1<10&&Zi(15003,this._shadowDistance),this._light&&(this._light.shadowDistance=this._shadowDistance,this._light.csmNeedUpdate=!0)}},{key:"shadowInvisibleOcclusionRange",get:function(){return this._shadowInvisibleOcclusionRange},set:function(t){this._shadowInvisibleOcclusionRange=Math.min(t,_i.MAX_FAR),this._light&&(this._light.shadowInvisibleOcclusionRange=this._shadowInvisibleOcclusionRange)}},{key:"csmLevel",get:function(){return this._csmLevel},set:function(t){this._csmLevel=t,this._light&&(this._light.csmLevel=this._csmLevel,this._light.csmNeedUpdate=!0)}},{key:"enableCSM",get:function(){return this._csmLevel>ci.LEVEL_1},set:function(t){this._csmLevel=t?ci.LEVEL_4:ci.LEVEL_1,this._light&&(this._light.csmLevel=this._csmLevel,this._light.csmNeedUpdate=!0)}},{key:"csmLayerLambda",get:function(){return this._csmLayerLambda},set:function(t){this._csmLayerLambda=t,this._light&&(this._light.csmLayerLambda=this._csmLayerLambda,this._light.csmNeedUpdate=!0)}},{key:"csmOptimizationMode",get:function(){return this._csmOptimizationMode},set:function(t){this._csmOptimizationMode=t,this._light&&(this._light.csmOptimizationMode=this._csmOptimizationMode)}},{key:"shadowFixedArea",get:function(){return this._shadowFixedArea},set:function(t){this._shadowFixedArea=t,this._light&&(this._light.shadowFixedArea=this._shadowFixedArea)}},{key:"shadowNear",get:function(){return this._shadowNear},set:function(t){this._shadowNear=t,this._light&&(this._light.shadowNear=this._shadowNear)}},{key:"shadowFar",get:function(){return this._shadowFar},set:function(t){this._shadowFar=Math.min(t,_i.MAX_FAR),this._light&&(this._light.shadowFar=this._shadowFar)}},{key:"shadowOrthoSize",get:function(){return this._shadowOrthoSize},set:function(t){this._shadowOrthoSize=t,this._light&&(this._light.shadowOrthoSize=this._shadowOrthoSize)}},{key:"csmAdvancedOptions",get:function(){return this._csmAdvancedOptions},set:function(t){this._csmAdvancedOptions=t}},{key:"csmLayersTransition",get:function(){return this._csmLayersTransition},set:function(t){this._csmLayersTransition=t,this._light&&(this._light.csmLayersTransition=t)}},{key:"csmTransitionRange",get:function(){return this._csmTransitionRange},set:function(t){this._csmTransitionRange=t,this._light&&(this._light.csmTransitionRange=t)}}]),e}(hE),oS=tn(aS.prototype,"_illuminanceHDR",[lE,ET],(function(){return 65e3})),hS=tn(aS.prototype,"_illuminanceLDR",[uE],(function(){return 65e3*ei.standardExposureValue})),lS=tn(aS.prototype,"_shadowEnabled",[uE],(function(){return!1})),uS=tn(aS.prototype,"_shadowPcf",[uE],(function(){return ui.HARD})),cS=tn(aS.prototype,"_shadowBias",[uE],(function(){return 1e-5})),dS=tn(aS.prototype,"_shadowNormalBias",[uE],(function(){return 0})),_S=tn(aS.prototype,"_shadowSaturation",[uE],(function(){return 1})),fS=tn(aS.prototype,"_shadowDistance",[uE],(function(){return 50})),pS=tn(aS.prototype,"_shadowInvisibleOcclusionRange",[uE],(function(){return 200})),gS=tn(aS.prototype,"_csmLevel",[uE],(function(){return ci.LEVEL_4})),mS=tn(aS.prototype,"_csmLayerLambda",[uE],(function(){return.75})),vS=tn(aS.prototype,"_csmOptimizationMode",[uE],(function(){return di.RemoveDuplicates})),yS=tn(aS.prototype,"_csmAdvancedOptions",[uE],(function(){return!1})),TS=tn(aS.prototype,"_csmLayersTransition",[uE],(function(){return!1})),SS=tn(aS.prototype,"_csmTransitionRange",[uE],(function(){return.05})),ES=tn(aS.prototype,"_shadowFixedArea",[uE],(function(){return!1})),AS=tn(aS.prototype,"_shadowNear",[uE],(function(){return.1})),CS=tn(aS.prototype,"_shadowFar",[uE],(function(){return 10})),RS=tn(aS.prototype,"_shadowOrthoSize",[uE],(function(){return 5})),gn(aS.prototype,"visibility",[mn],Object.getOwnPropertyDescriptor(aS.prototype,"visibility"),aS.prototype),gn(aS.prototype,"shadowEnabled",[AT,CT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowEnabled"),aS.prototype),gn(aS.prototype,"shadowPcf",[RT,bT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowPcf"),aS.prototype),gn(aS.prototype,"shadowBias",[xT,wT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowBias"),aS.prototype),gn(aS.prototype,"shadowNormalBias",[MT,IT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowNormalBias"),aS.prototype),gn(aS.prototype,"shadowSaturation",[BT,PT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowSaturation"),aS.prototype),gn(aS.prototype,"shadowDistance",[DT,OT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowDistance"),aS.prototype),gn(aS.prototype,"shadowInvisibleOcclusionRange",[FT,LT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowInvisibleOcclusionRange"),aS.prototype),gn(aS.prototype,"csmLevel",[NT,kT],Object.getOwnPropertyDescriptor(aS.prototype,"csmLevel"),aS.prototype),gn(aS.prototype,"enableCSM",[UT,GT],Object.getOwnPropertyDescriptor(aS.prototype,"enableCSM"),aS.prototype),gn(aS.prototype,"csmLayerLambda",[VT,HT],Object.getOwnPropertyDescriptor(aS.prototype,"csmLayerLambda"),aS.prototype),gn(aS.prototype,"csmOptimizationMode",[zT,XT],Object.getOwnPropertyDescriptor(aS.prototype,"csmOptimizationMode"),aS.prototype),gn(aS.prototype,"shadowFixedArea",[WT,YT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowFixedArea"),aS.prototype),gn(aS.prototype,"shadowNear",[jT,KT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowNear"),aS.prototype),gn(aS.prototype,"shadowFar",[qT,ZT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowFar"),aS.prototype),gn(aS.prototype,"shadowOrthoSize",[QT,JT],Object.getOwnPropertyDescriptor(aS.prototype,"shadowOrthoSize"),aS.prototype),gn(aS.prototype,"csmAdvancedOptions",[$T,tS],Object.getOwnPropertyDescriptor(aS.prototype,"csmAdvancedOptions"),aS.prototype),gn(aS.prototype,"csmLayersTransition",[eS,iS],Object.getOwnPropertyDescriptor(aS.prototype,"csmLayersTransition"),aS.prototype),gn(aS.prototype,"csmTransitionRange",[nS,rS],Object.getOwnPropertyDescriptor(aS.prototype,"csmTransitionRange"),aS.prototype),sS=aS))||sS)),fE=function(e){return t({SphereLight:e,SphereLightComponent:e}),e}((bS=Ki("cc.SphereLight"),xS=is("_luminance"),wS=Tn(aE),bS((IS=function(t){function e(){var e;return(e=t.call(this)||this)._size=BS&&BS(),e._luminanceHDR=PS&&PS(),e._luminanceLDR=DS&&DS(),e._term=OS&&OS(),e._range=FS&&FS(),e._type=vi.SPHERE,e._light=null,e._lightType=Ei,e}return He(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this.size=this._size,this.range=this._range,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR)},Pi(e,[{key:"luminousFlux",get:function(){return We.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*yi(this._size):this._luminanceLDR},set:function(t){var e=0;We.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/yi(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return We.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){We.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"size",get:function(){return this._size},set:function(t){this._size=t,this._light&&(this._light.size=t)}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}}]),e}(hE),BS=tn(IS.prototype,"_size",[en],(function(){return.15})),PS=tn(IS.prototype,"_luminanceHDR",[en,xS],(function(){return 1700/yi(.15)})),DS=tn(IS.prototype,"_luminanceLDR",[en],(function(){return 1700/yi(.15)*ei.standardExposureValue*ei.standardLightMeterScale})),OS=tn(IS.prototype,"_term",[en],(function(){return aE.LUMINOUS_FLUX})),FS=tn(IS.prototype,"_range",[en],(function(){return 1})),gn(IS.prototype,"term",[wS],Object.getOwnPropertyDescriptor(IS.prototype,"term"),IS.prototype),MS=IS))||MS)),pE=Tn,gE=en,mE=is,vE=rs,yE=function(e){return t({SpotLight:e,SpotLightComponent:e}),e}((LS=Ki("cc.SpotLight"),NS=mE("_luminance"),kS=pE(aE),US=vE({group:{name:"DynamicShadowSettings",displayOrder:1}}),GS=pE(Jr),VS=vE({group:{name:"DynamicShadowSettings",displayOrder:2}}),HS=pE(ui),zS=vE({group:{name:"DynamicShadowSettings",displayOrder:3}}),XS=pE($r),WS=vE({group:{name:"DynamicShadowSettings",displayOrder:4}}),YS=pE($r),LS((KS=function(t){function e(){var e;return(e=t.call(this)||this)._size=qS&&qS(),e._luminanceHDR=ZS&&ZS(),e._luminanceLDR=QS&&QS(),e._term=JS&&JS(),e._range=$S&&$S(),e._spotAngle=tE&&tE(),e._shadowEnabled=eE&&eE(),e._shadowPcf=iE&&iE(),e._shadowBias=nE&&nE(),e._shadowNormalBias=rE&&rE(),e._type=vi.SPOT,e._light=null,e._lightType=Ai,e}return He(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this.size=this._size,this.range=this._range,this.spotAngle=this._spotAngle,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR,this._light.shadowEnabled=this._shadowEnabled,this._light.shadowPcf=this._shadowPcf,this._light.shadowBias=this._shadowBias,this._light.shadowNormalBias=this._shadowNormalBias)},Pi(e,[{key:"luminousFlux",get:function(){return We.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*yi(this._size):this._luminanceLDR},set:function(t){var e=0;We.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/yi(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return We.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){We.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"size",get:function(){return this._size},set:function(t){this._size=t,this._light&&(this._light.size=t)}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}},{key:"spotAngle",get:function(){return this._spotAngle},set:function(t){this._spotAngle=t,this._light&&(this._light.spotAngle=mr(t))}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this._light&&(this._light.shadowEnabled=t)}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this._light&&(this._light.shadowPcf=t)}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._light&&(this._light.shadowBias=t)}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._light&&(this._light.shadowNormalBias=t)}}]),e}(hE),qS=tn(KS.prototype,"_size",[gE],(function(){return.15})),ZS=tn(KS.prototype,"_luminanceHDR",[gE,NS],(function(){return 1700/yi(.15)})),QS=tn(KS.prototype,"_luminanceLDR",[gE],(function(){return 1700/yi(.15)*ei.standardExposureValue*ei.standardLightMeterScale})),JS=tn(KS.prototype,"_term",[gE],(function(){return aE.LUMINOUS_FLUX})),$S=tn(KS.prototype,"_range",[gE],(function(){return 1})),tE=tn(KS.prototype,"_spotAngle",[gE],(function(){return 60})),eE=tn(KS.prototype,"_shadowEnabled",[gE],(function(){return!1})),iE=tn(KS.prototype,"_shadowPcf",[gE],(function(){return ui.HARD})),nE=tn(KS.prototype,"_shadowBias",[gE],(function(){return 1e-5})),rE=tn(KS.prototype,"_shadowNormalBias",[gE],(function(){return 0})),gn(KS.prototype,"term",[kS],Object.getOwnPropertyDescriptor(KS.prototype,"term"),KS.prototype),gn(KS.prototype,"shadowEnabled",[US,GS],Object.getOwnPropertyDescriptor(KS.prototype,"shadowEnabled"),KS.prototype),gn(KS.prototype,"shadowPcf",[VS,HS],Object.getOwnPropertyDescriptor(KS.prototype,"shadowPcf"),KS.prototype),gn(KS.prototype,"shadowBias",[zS,XS],Object.getOwnPropertyDescriptor(KS.prototype,"shadowBias"),KS.prototype),gn(KS.prototype,"shadowNormalBias",[WS,YS],Object.getOwnPropertyDescriptor(KS.prototype,"shadowNormalBias"),KS.prototype),jS=KS))||jS));We.LightComponent=hE,br(hE,"cc.LightComponent"),We.DirectionalLightComponent=_E,br(_E,"cc.DirectionalLightComponent"),We.SphereLightComponent=fE,br(fE,"cc.SphereLightComponent"),We.SpotLightComponent=yE,br(yE,"cc.SpotLightComponent"),zn(yE.prototype,"SpotLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),zn(fE.prototype,"SphereLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),zn(hE.PhotometricTerm,"Light.PhotometricTerm",[{name:"LUMINOUS_POWER",newName:"LUMINOUS_FLUX"}]);var TE=Symbol("BakeNodeCurves"),SE=function(){function t(){}return t.getOrExtract=function(e){var i=t.pool.get(e);if(!i||i.samples!==e.sample){i&&We.director.root.dataPoolManager.releaseAnimationClip(e);var n=Math.ceil(e.sample*e.duration)+1,r=e.sample;i=e[TE](0,r,n),t.pool.set(e,i)}return i},t.destroy=function(e){t.pool.delete(e)},t}();SE.pool=new Map;var EE=new Ue;function AE(t,e,i){for(Ue.identity(i);t!==e;)Ue.fromRTS(EE,t.rotation,t.position,t.scale),Ue.multiply(i,EE,i),t=t.parent;return i}var CE=new St(b.POINT,b.POINT,b.NONE,x.CLAMP,x.CLAMP,x.CLAMP),RE=function(t,e,i){t[e+0]=i.m00,t[e+1]=i.m01,t[e+2]=i.m02,t[e+3]=i.m12,t[e+4]=i.m04,t[e+5]=i.m05,t[e+6]=i.m06,t[e+7]=i.m13,t[e+8]=i.m08,t[e+9]=i.m09,t[e+10]=i.m10,t[e+11]=i.m14};function bE(t,e){var i=4/Math.sqrt(e);return 12*Math.ceil(Math.max(480*i,t)/12)}new Ji,new Ji,new ji,new Ji,new ji;var xE=new ji,wE=new ji,ME=new ji,IE=new ji,BE=new Ue,PE=new Ue,DE=new Qi,OE=Number.MAX_SAFE_INTEGER,FE=(function(){function t(t){this._device=void 0,this._pool=void 0,this._textureBuffers=new Map,this._formatSize=void 0,this._pixelsPerJoint=void 0,this._customPool=void 0,this._chunkIdxMap=new Map,this._device=t;var e=function(t){return t.getFormatFeatures(_.RGBA32F)&A.SAMPLED_TEXTURE?_.RGBA32F:_.RGBA8}(this._device);this._formatSize=ne[e].size,this._pixelsPerJoint=48/this._formatSize,this._pool=new Wu(t),this._pool.initialize({format:e,roundUpFn:bE}),this._customPool=new Wu(t),this._customPool.initialize({format:e,roundUpFn:bE})}var e=t.prototype;e.clear=function(){this._pool.destroy(),this._textureBuffers.clear()},e.registerCustomTextureLayouts=function(t){for(var e=0;e<t.length;e++)for(var i=t[e],n=this._customPool.createChunk(i.textureLength),r=0;r<i.contents.length;r++){var s=i.contents[r],a=s.skeleton;this._chunkIdxMap.set(a,n);for(var o=0;o<s.clips.length;o++){var h=s.clips[o];this._chunkIdxMap.set(a^h,n)}}},e.getDefaultPoseTexture=function(t,e,i){var n=0^t.hash,r=this._textureBuffers.get(n)||null;if(r&&r.bounds.has(e.hash))return r.refCount++,r;var s=t.joints,a=t.bindposes,o=null,h=!1,l=s.length;if(r)r.refCount++;else{var u=12*l,c=this._chunkIdxMap.get(n),d=void 0!==c?this._customPool.alloc(u*Float32Array.BYTES_PER_ELEMENT,c):this._pool.alloc(u*Float32Array.BYTES_PER_ELEMENT);if(!d)return r;r={pixelOffset:d.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:t.hash,clipHash:0,readyToBeDeleted:!1,handle:d},o=new Float32Array(u),h=!0}ji.set(ME,OE,OE,OE),ji.set(IE,-OE,-OE,-OE);for(var _=e.getBoneSpaceBounds(t),f=0,p=0;f<l;f++,p+=12){var g=i.getChildByPath(s[f]),m=g?AE(g,i,BE):t.inverseBindposes[f],v=_[f];v&&(Qi.transform(DE,v,m),DE.getBoundary(xE,wE),ji.min(ME,ME,xE),ji.max(IE,IE,wE)),h&&(g&&Ue.multiply(m,m,a[f]),RE(o,p,g?m:Ue.IDENTITY))}var y=[new Qi];return r.bounds.set(e.hash,y),Qi.fromPoints(y[0],ME,IE),h&&(this._pool.update(r.handle,o.buffer),this._textureBuffers.set(n,r)),r},e.getSequencePoseTexture=function(t,e,i,n){var r=t.hash^e.hash,s=this._textureBuffers.get(r)||null;if(s&&s.bounds.has(i.hash))return s.refCount++,s;var a=t.joints,o=t.bindposes,h=SE.getOrExtract(e).frames,l=null,u=!1,c=a.length;if(s)s.refCount++;else{var d=12*c*h,_=this._chunkIdxMap.get(r),f=void 0!==_?this._customPool.alloc(d*Float32Array.BYTES_PER_ELEMENT,_):this._pool.alloc(d*Float32Array.BYTES_PER_ELEMENT);if(!f)return null;var p=this._createAnimInfos(t,e,n);s={pixelOffset:f.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:t.hash,clipHash:e.hash,readyToBeDeleted:!1,handle:f,animInfos:p},l=new Float32Array(d),u=!0}var g=i.getBoneSpaceBounds(t),m=[];s.bounds.set(i.hash,m);for(var v=0;v<h;v++)m.push(new Qi(OE,OE,OE,-OE,-OE,-OE));for(var y=0,T=0;y<h;y++){for(var S=m[y],E=0;E<c;E++,T+=12){var A=s.animInfos[E],C=A.curveData,R=A.downstream,b=A.bindposeIdx,x=A.bindposeCorrection,w=void 0,M=!0;C&&R?w=Ue.multiply(BE,C[y],R):C?w=C[y]:R?w=R:(w=t.inverseBindposes[b],M=!1);var I=g[E];if(I){var B=x?Ue.multiply(PE,w,x):w;Qi.transform(DE,I,B),DE.getBoundary(xE,wE),ji.min(S.center,S.center,xE),ji.max(S.halfExtents,S.halfExtents,wE)}u&&(M&&Ue.multiply(BE,w,o[b]),RE(l,T,M?BE:Ue.IDENTITY))}Qi.fromPoints(S,S.center,S.halfExtents)}return u&&(this._pool.update(s.handle,l.buffer),this._textureBuffers.set(r,s)),s},e.releaseHandle=function(t){if(t.refCount>0&&t.refCount--,!t.refCount&&t.readyToBeDeleted){var e=t.skeletonHash^t.clipHash;(void 0!==this._chunkIdxMap.get(e)?this._customPool:this._pool).free(t.handle),this._textureBuffers.get(e)===t&&this._textureBuffers.delete(e)}},e.releaseSkeleton=function(t){for(var e=this._textureBuffers.values(),i=e.next();!i.done;){var n=i.value;n.skeletonHash===t.hash&&(n.readyToBeDeleted=!0,n.refCount?this._textureBuffers.delete(n.skeletonHash^n.clipHash):this.releaseHandle(n)),i=e.next()}},e.releaseAnimationClip=function(t){for(var e=this._textureBuffers.values(),i=e.next();!i.done;){var n=i.value;n.clipHash===t.hash&&(n.readyToBeDeleted=!0,n.refCount?this._textureBuffers.delete(n.skeletonHash^n.clipHash):this.releaseHandle(n)),i=e.next()}},e._createAnimInfos=function(t,e,i){for(var n=[],r=t.joints,s=t.bindposes,a=r.length,o=SE.getOrExtract(e),h=0;h<a;h++){for(var l=r[h],u=o.joints[l],c=i.getChildByPath(l),d=void 0,_=void 0;!u;){var f=l.lastIndexOf("/");if(l=l.substring(0,f),u=o.joints[l],c?(d||(d=new Ue),Ue.fromRTS(BE,c.rotation,c.position,c.scale),Ue.multiply(d,BE,d),c=c.parent):_=l,f<0)break}var p=h,g=void 0;if(void 0!==_&&u){p=h-1;for(var m=0;m<a;m++)if(r[m]===_){p=m,g=new Ue,Ue.multiply(g,s[m],t.inverseBindposes[h]);break}}n.push({curveData:u&&u.transforms,downstream:d,bindposeIdx:p,bindposeCorrection:g})}return n},Pi(t,[{key:"pixelsPerJoint",get:function(){return this._pixelsPerJoint}}])}(),[]),LE=new Map;function NE(t,e){for(var i=0,n=Ue.IDENTITY;t;){if(t.stamp===e||t.stamp+1===e&&!t.node.hasChangedFlags){n=t.world,t.stamp=e;break}t.stamp=e,FE[i++]=t,t=t.parent}for(;i>0;){t=FE[--i],FE[i]=null;var r=t.node;Ue.fromRTS(t.local,r.rotation,r.position,r.scale),n=Ue.multiply(t.world,n,t.local)}return n}function kE(t,e){for(var i,n=null,r=0;t!==e;){var s=t.uuid;if(LE.has(s)){n=LE.get(s);break}n={node:t,local:new Ue,world:new Ue,stamp:-1,parent:null},LE.set(s,n),FE[r++]=n,t=t.parent,n=null}for(;r>0;)i=FE[--r],FE[r]=null,i.parent=n,n=i;return n}function UE(t){for(var e=LE.get(t.uuid)||null;e;)LE.delete(e.node.uuid),e=e.parent}var GE=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!1}],VE=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!0}];function HE(t,e,i,n){for(var r=0;r<i.length;r++){for(var s=i[r],a=-1,o=0;o<s.length;o++)if(s[o]===n){a=o;break}a>=0&&(e.push(r),t.push(a))}}var zE=new ji,XE=new ji,WE=new ji,YE=new ji,jE=new Ue,KE=new Qi,qE=function(){this._format=ze.RGBA32F,this._textures=[],this._buffers=[]};qE.WIDTH=256,qE.HEIGHT=3;var ZE,QE,JE,$E,tA,eA,iA,nA,rA,sA,aA,oA,hA,lA,uA,cA,dA,_A,fA,pA,gA,mA,vA,yA,TA,SA,EA,AA,CA,RA,bA,xA,wA,MA,IA,BA,PA,DA,OA,FA,LA,NA,kA,UA,GA,VA,HA,zA,XA,WA=function(t){function e(){var e;return(e=t.call(this)||this)._buffers=[],e._dataArray=[],e._joints=[],e._bufferIndices=null,e._realTimeJointTexture=new qE,e._realTimeTextureMode=!1,e.type=ii.SKINNING,e}He(e,t);var i=e.prototype;return i.destroy=function(){if(this.bindSkeleton(),this._buffers.length){for(var e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers.length=0}this._dataArray.length=0,this._realTimeJointTexture._textures.forEach((function(t){t.destroy()})),this._realTimeJointTexture._textures.length=0,this._realTimeJointTexture._buffers.length=0,t.prototype.destroy.call(this)},i.uploadAnimation=function(){},i.bindSkeleton=function(t,e,i){void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null);for(var n=0;n<this._joints.length;n++)UE(this._joints[n].target);if(this._bufferIndices=null,this._joints.length=0,t&&e&&i){this._realTimeTextureMode=!1,ss.JOINT_UNIFORM_CAPACITY<t.joints.length&&(this._realTimeTextureMode=!0),this.transform=e;var r=i.getBoneSpaceBounds(t),s=i.struct.jointMaps;this._ensureEnoughBuffers(s&&s.length||1),this._bufferIndices=i.jointBufferIndices,this._initRealTimeJointTexture();for(var a=0;a<t.joints.length;a++){var o=r[a],h=e.getChildByPath(t.joints[a]);if(o&&h){var l=kE(h,e),u=t.bindposes[a],c=[],d=[];s?HE(c,d,s,a):(c.push(a),d.push(0)),this._joints.push({indices:c,buffers:d,bound:o,target:h,bindpose:u,transform:l})}}}},i.updateTransform=function(t){var e=this.transform;(e.hasChangedFlags||e._dirtyFlags)&&(e.updateWorldTransform(),this._localDataUpdated=!0),ji.set(zE,1/0,1/0,1/0),ji.set(XE,-1/0,-1/0,-1/0);for(var i=0;i<this._joints.length;i++){var n=this._joints[i],r=n.bound,s=NE(n.transform,t);Qi.transform(KE,r,s),KE.getBoundary(WE,YE),ji.min(zE,zE,WE),ji.max(XE,XE,YE)}var a=this._worldBounds;this._modelBounds&&a&&(Qi.fromPoints(this._modelBounds,zE,XE),this._modelBounds.transform(e._mat,e._pos,e._rot,e._scale,this._worldBounds))},i.updateUBOs=function(e){t.prototype.updateUBOs.call(this,e);for(var i=0;i<this._joints.length;i++){var n=this._joints[i],r=n.indices,s=n.buffers,a=n.transform,o=n.bindpose;Ue.multiply(jE,a.world,o);for(var h=0;h<s.length;h++)RE(this._dataArray[s[h]],12*r[h],jE)}if(this._realTimeTextureMode)this._updateRealTimeJointTextureBuffer();else for(var l=0;l<this._buffers.length;l++)this._buffers[l].update(this._dataArray[l]);return!0},i.initSubModel=function(e,i,n){var r=i.vertexBuffers,s=i.iaInfo;s.vertexBuffers=i.jointMappedBuffers,t.prototype.initSubModel.call(this,e,i,n),s.vertexBuffers=r},i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e),n=GE;return this._realTimeTextureMode&&(n=VE),i?n.concat(i):n},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i);var n=this._bufferIndices[e];if(this._realTimeTextureMode)this._bindRealTimeJointTexture(n,i);else{var r=this._buffers[n];r&&i.bindBuffer(ss.BINDING,r)}},i._updateInstancedAttributes=function(e,i){i.passes[0].batchingScheme!==rr.NONE&&Zi(3936,this.node.getPathInHierarchy()),t.prototype._updateInstancedAttributes.call(this,e,i)},i._ensureEnoughBuffers=function(t){if(this._buffers.length){for(var e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers.length=0}if(this._dataArray.length&&(this._dataArray.length=0),this._realTimeTextureMode)for(var i=0;i<t;i++){var n=qE.WIDTH;this._dataArray[i]=new Float32Array(12*n)}else for(var r=0;r<t;r++){this._buffers[r]=this._device.createBuffer(new ft(g.UNIFORM|g.TRANSFER_DST,y.HOST|y.DEVICE,ss.SIZE,ss.SIZE));var s=ss.JOINT_UNIFORM_CAPACITY;this._dataArray[r]=new Float32Array(12*s)}},i._initRealTimeJointTexture=function(){if(this._realTimeJointTexture._textures.length&&(this._realTimeJointTexture._textures.forEach((function(t){t.destroy()})),this._realTimeJointTexture._textures.length=0),this._realTimeJointTexture._buffers.length=0,this._realTimeTextureMode){var t=Di.root.device,e=qE.WIDTH,i=qE.HEIGHT;0==(t.getFormatFeatures(_.RGBA32F)&A.SAMPLED_TEXTURE)&&(this._realTimeJointTexture._format=ze.RGBA8888,e=4*qE.WIDTH);for(var n=this._realTimeJointTexture._textures,r=this._realTimeJointTexture._buffers,s=this._realTimeJointTexture._format,a=0;a<this._dataArray.length;a++){r[a]=new Float32Array(4*qE.HEIGHT*qE.WIDTH);var o=r[a],h=s===ze.RGBA32F?o:new Uint8Array(o.buffer),l=new Ui({width:e,height:i,_data:h,_compressed:!1,format:s}),u=new Xe;u.setFilters(Xe.Filter.NEAREST,Xe.Filter.NEAREST),u.setMipFilter(Xe.Filter.NONE),u.setWrapMode(Xe.WrapMode.CLAMP_TO_EDGE,Xe.WrapMode.CLAMP_TO_EDGE,Xe.WrapMode.CLAMP_TO_EDGE),u.image=l,n[a]=u}}},i._bindRealTimeJointTexture=function(t,e){if(this._realTimeTextureMode){var i=this._realTimeJointTexture._textures[t];if(i){var n=i.getGFXTexture(),r=i.getGFXSampler();e.bindTexture(as,n),e.bindSampler(as,r)}}},i._updateRealTimeJointTextureBuffer=function(){if(this._realTimeTextureMode)for(var t=this._realTimeJointTexture._textures,e=this._realTimeJointTexture._buffers,i=0;i<t.length;i++){for(var n=e[i],r=this._dataArray[i],s=r.length/12,a=0,o=0,h=0;h<s;h++)o=4*h,n[o++]=r[a++],n[o++]=r[a++],n[o++]=r[a++],n[o++]=r[a++],o=4*(h+qE.WIDTH),n[o++]=r[a++],n[o++]=r[a++],n[o++]=r[a++],n[o++]=r[a++],o=4*(h+2*qE.WIDTH),n[o++]=r[a++],n[o++]=r[a++],n[o++]=r[a++],n[o++]=r[a++];var l=this._realTimeJointTexture._format===ze.RGBA32F?n:new Uint8Array(n.buffer);t[i].uploadData(l)}},e}(ky),YA=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_BAKED_ANIMATION",value:!0}],jA=function(t){function e(){var e;(e=t.call(this)||this).uploadedAnim=void 0,e._jointsMedium=void 0,e._skeleton=null,e._mesh=null,e._dataPoolManager=void 0,e._instAnimInfoIdx=-1,e.type=ii.BAKED_SKINNING,e._dataPoolManager=We.director.root.dataPoolManager;var i=new Float32Array(4),n=e._dataPoolManager.jointAnimationInfo.getData();return e._jointsMedium={buffer:null,jointTextureInfo:i,animInfo:n,texture:null,boundsInfo:null},e}He(e,t);var i=e.prototype;return i.destroy=function(){this.uploadedAnim=void 0,this._jointsMedium.boundsInfo=null,this._jointsMedium.buffer&&(this._jointsMedium.buffer.destroy(),this._jointsMedium.buffer=null),this._applyJointTexture(),t.prototype.destroy.call(this)},i.bindSkeleton=function(t,e,i){if(void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null),this._skeleton=t,this._mesh=i,t&&e&&i){this.transform=e;var n=this._dataPoolManager;this._jointsMedium.animInfo=n.jointAnimationInfo.getData(e.uuid),this._jointsMedium.buffer||(this._jointsMedium.buffer=this._device.createBuffer(new ft(g.UNIFORM|g.TRANSFER_DST,y.DEVICE,os.SIZE,os.SIZE)))}},i.updateTransform=function(e){if(t.prototype.updateTransform.call(this,e),this.uploadedAnim){var i=this._jointsMedium,n=i.animInfo,r=i.boundsInfo[n.data[0]],s=this._worldBounds;if(s&&r){var a=this.transform;r.transform(a._mat,a._pos,a._rot,a._scale,s)}}},i.updateUBOs=function(e){t.prototype.updateUBOs.call(this,e);for(var i=this._jointsMedium.animInfo,n=!1,r=this._instAnimInfoIdx,s=0;s<this._subModels.length;s++){var a=this._subModels[s];r>=0?a.instancedAttributeBlock.views[r][0]=i.data[0]:n=!0}return n&&i.dirty&&(i.buffer.update(i.data),i.dirty=!1),!0},i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);return i?i.concat(YA):YA},i.uploadAnimation=function(t){if(this._skeleton&&this._mesh&&this.uploadedAnim!==t){this.uploadedAnim=t;var e=this._dataPoolManager,i=null;t?(i=e.jointTexturePool.getSequencePoseTexture(this._skeleton,t,this._mesh,this.transform),this._jointsMedium.boundsInfo=i&&i.bounds.get(this._mesh.hash),this._modelBounds=null):(i=e.jointTexturePool.getDefaultPoseTexture(this._skeleton,this._mesh,this.transform),this._jointsMedium.boundsInfo=null,this._modelBounds=i&&i.bounds.get(this._mesh.hash)[0]),this._applyJointTexture(i)}},i._applyJointTexture=function(t){void 0===t&&(t=null);var e=this._jointsMedium.texture;if(e&&e!==t&&this._dataPoolManager.jointTexturePool.releaseHandle(e),this._jointsMedium.texture=t,t){var i=this._jointsMedium,n=i.buffer,r=i.jointTextureInfo;r[0]=t.handle.texture.width,r[1]=this._skeleton.joints.length,r[2]=t.pixelOffset+.1,r[3]=1/r[0],this.updateInstancedJointTextureInfo(),n&&n.update(r);for(var s=t.handle.texture,a=0;a<this._subModels.length;++a)this._subModels[a].descriptorSet.bindTexture(hs,s)}},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i);var n=this._jointsMedium,r=n.buffer,s=n.texture,a=n.animInfo;if(i.bindBuffer(os.BINDING,r),i.bindBuffer(ls.BINDING,a.buffer),s){var o=this._device.getSampler(CE);i.bindTexture(hs,s.handle.texture),i.bindSampler(hs,o)}},i._updateInstancedAttributes=function(e,i){t.prototype._updateInstancedAttributes.call(this,e,i),this._instAnimInfoIdx=i.getInstancedAttributeIndex(us),this.updateInstancedJointTextureInfo()},i.updateInstancedJointTextureInfo=function(){for(var t=this._jointsMedium,e=t.jointTextureInfo,i=t.animInfo,n=this._instAnimInfoIdx,r=0;r<this._subModels.length;r++){var s=this._subModels[r].instancedAttributeBlock.views;if(n>=0&&s.length>0){var a=s[n];a[0]=i.data[0],a[1]=e[1],a[2]=e[2]}}},e}(ky),KA=function(e){return t({SkinnedMeshRenderer:e,SkinningModelComponent:e}),e}((ZE=Ki("cc.SkinnedMeshRenderer"),QE=In(100),JE=Tn(TT),$E=Tn(Pr),tA=Tn(TT),eA=Tn(Pr),ZE(iA=QE((nA=function(t){function e(){var e;return(e=t.call(this)||this)._skeleton=rA&&rA(),e._skinningRoot=sA&&sA(),e._clip=null,e.associatedAnimation=null,e._modelType=jA,e}He(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this),this._tryBindAnimation()},i.onDestroy=function(){this.associatedAnimation&&(this.associatedAnimation.notifySkinnedMeshRemoved(this),Ni(null===this.associatedAnimation)),t.prototype.onDestroy.call(this)},i.uploadAnimation=function(t){this._clip=t,this.model&&this.model.uploadAnimation&&this.model.uploadAnimation(t)},i.setUseBakedAnimation=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1);var i=t?jA:WA;(e||this._modelType!==i)&&(this._modelType=i,this._model&&(We.director.root.destroyModel(this._model),this._model=null,this._models.length=0,this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateUseLightProbe(),this.enabledInHierarchy&&this._attachToScene()))},i.setMaterial=function(e,i){t.prototype.setMaterial.call(this,e,i),this._modelType===WA&&this.getMaterialInstance(i)},i._updateModelParams=function(){this._update(),t.prototype._updateModelParams.call(this)},i._tryBindAnimation=function(){var t=this._skinningRoot;if(t){for(var e=!1,i=this.node;i;i=i.parent)if(i===t){e=!0;break}if(e){var n=t.getComponent("cc.SkeletalAnimation");n?n.notifySkinnedMeshAdded(this):this.setUseBakedAnimation(!1)}}},i._update=function(){this.model&&(this.model.bindSkeleton(this._skeleton,this._skinningRoot,this._mesh),this.model.uploadAnimation&&this.model.uploadAnimation(this._clip))},Pi(e,[{key:"skeleton",get:function(){return this._skeleton},set:function(t){t!==this._skeleton&&(this._skeleton=t,this._update())}},{key:"skinningRoot",get:function(){return this._skinningRoot},set:function(t){this._skinningRoot=t,this._tryBindAnimation(),t!==this._skinningRoot&&this._update()}},{key:"model",get:function(){return this._model}}]),e}(eT),rA=tn(nA.prototype,"_skeleton",[JE],(function(){return null})),sA=tn(nA.prototype,"_skinningRoot",[$E],(function(){return null})),gn(nA.prototype,"skeleton",[tA],Object.getOwnPropertyDescriptor(nA.prototype,"skeleton"),nA.prototype),gn(nA.prototype,"skinningRoot",[eA],Object.getOwnPropertyDescriptor(nA.prototype,"skinningRoot"),nA.prototype),iA=nA))||iA)||iA)),qA=new Bt(ie.ATTR_BATCH_ID,_.R32F),ZA=new Bt(ie.ATTR_BATCH_UV,_.RG32F),QA=ne[qA.format].size+ne[ZA.format].size,JA=function(e){return t({SkinnedMeshUnit:e,SkinningModelUnit:e}),e}((aA=Ki("cc.SkinnedMeshUnit"),oA=Tn(mo),hA=Tn(TT),lA=Tn(Dn),uA=Tn(KA),aA((dA=function(){function t(){this.mesh=_A&&_A(),this.skeleton=fA&&fA(),this.material=pA&&pA(),this._localTransform=gA&&gA(),this._offset=mA&&mA(),this._size=vA&&vA()}return Pi(t,[{key:"offset",get:function(){return this._offset},set:function(t){cn.copy(this._offset,t)}},{key:"size",get:function(){return this._size},set:function(t){cn.copy(this._size,t)}},{key:"copyFrom",get:function(){return null},set:function(t){t&&(this.mesh=t.mesh,this.skeleton=t.skeleton,this.material=t.getMaterial(0),t.skinningRoot&&AE(t.node,t.skinningRoot,this._localTransform))}}]),t}(),_A=tn(dA.prototype,"mesh",[oA],(function(){return null})),fA=tn(dA.prototype,"skeleton",[hA],(function(){return null})),pA=tn(dA.prototype,"material",[lA],(function(){return null})),gA=tn(dA.prototype,"_localTransform",[en],(function(){return new Ue})),mA=tn(dA.prototype,"_offset",[en],(function(){return new cn(0,0)})),vA=tn(dA.prototype,"_size",[en],(function(){return new cn(1,1)})),gn(dA.prototype,"copyFrom",[uA],Object.getOwnPropertyDescriptor(dA.prototype,"copyFrom"),dA.prototype),cA=dA))||cA)),$A=new Ue,tC=(new Ue,new ji),eC=function(e){return t({SkinnedMeshBatchRenderer:e,BatchedSkinningModelComponent:e}),e}((yA=Ki("cc.SkinnedMeshBatchRenderer"),TA=In(100),SA=Tn([ns]),EA=Tn([JA]),yA(AA=TA((CA=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).atlasSize=RA&&RA(),e.batchableTextureNames=bA&&bA(),e.units=xA&&xA(),e._textures={},e._batchMaterial=null,e}He(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this),this.cook()},i.onDestroy=function(){for(var e in this._textures)this._textures[e].destroy();this._textures={},this._mesh&&(this._mesh.destroy(),this._mesh=null),t.prototype.onDestroy.call(this)},i._onMaterialModified=function(e){this.cookMaterials(),t.prototype._onMaterialModified.call(this,e,this.getMaterialInstance(e))},i.cook=function(){this.cookMaterials(),this.cookSkeletons(),this.cookMeshes()},i.cookMaterials=function(){var t=this;this._batchMaterial||(this._batchMaterial=this.getMaterial(0));var e=this.getMaterialInstance(0);if(e&&this._batchMaterial&&this._batchMaterial.effectAsset){e.copy(this._batchMaterial),this.resizeAtlases();for(var i=e.effectAsset.techniques[e.technique],n=function(n){var r=i.passes[n];if(!r.properties)return"continue";var s=function(i){if(r.properties[i].type>=p.SAMPLER1D){var s=null;t.batchableTextureNames.find((function(t){return t===i}))?((s=t._textures[i])||(s=t.createTexture(i)),t.cookTextures(s,i,n)):t.units.some((function(t){return s=t.material&&t.material.getProperty(i,n)})),s&&e.setProperty(i,s,n)}else{for(var a=[],o=0;o<t.units.length;o++){var h=t.units[o];h.material&&a.push(h.material.getProperty(i.slice(0,-3),n))}e.setProperty(i,a,n)}};for(var a in r.properties)s(a)},r=0;r<i.passes.length;r++)n(r)}else console.warn("incomplete batch material!")},i.cookSkeletons=function(){if(this._skinningRoot){for(var t=[],e=[],i=0;i<this.units.length;i++){var n=this.units[i];if(n&&n.skeleton){var r=n.skeleton;Ue.invert($A,n._localTransform);for(var s=function(i){var n=r.joints[i];if(t.findIndex((function(t){return t===n}))>=0)return"continue";t.push(n),e.push(Ue.multiply(new Ue,r.bindposes[i]||Ue.IDENTITY,$A))},a=0;a<r.joints.length;a++)s(a)}}var o=Array.from(Array(t.length).keys()).sort((function(e,i){return t[e]>t[i]?1:t[e]<t[i]?-1:0})),h=new TT;h.joints=t.map((function(t,e,i){return i[o[e]]})),h.bindposes=e.map((function(t,e,i){return i[o[e]]})),this._skeleton&&this._skeleton.destroy(),this.skeleton=h}else console.warn("no skinning root specified!")},i.cookMeshes=function(){for(var t=this,e=!1,i=0;i<this.units.length;i++)if(this.units[i].mesh){e=!0;break}if(e&&this._skinningRoot){this._mesh?this._mesh.destroyRenderingMesh():this._mesh=new mo;for(var n=0,r=_.UNKNOWN,s=0,a=_.UNKNOWN,o=0,h=_.UNKNOWN,l=0,u=_.UNKNOWN,c=0,d=_.UNKNOWN,f=new Array(this.units.length),p=this.units.length,g=0;g<p;g++){var m=this.units[g];m&&m.skeleton&&(f[g]=m.skeleton.joints.map((function(e){return t._skeleton.joints.findIndex((function(t){return e===t}))})))}for(var v=function(e){var i=t.units[e];if(!i||!i.mesh||!i.mesh.data)return"continue";var p=t._createUnitMesh(e,i.mesh),g=new DataView(p.data.buffer);Ue.inverseTranspose($A,i._localTransform);for(var m=i.offset,v=i.size,y=function(t){var y=p.struct.vertexBundles[t];n=y.view.offset,r=_.UNKNOWN;for(var T=0;T<y.attributes.length;T++){var S=y.attributes[T];if(S.name===ie.ATTR_POSITION){r=S.format;break}n+=ne[S.format].size}if(r){for(var E=Li(g,r,n,y.view.length,y.view.stride),A=0;A<E.length;A+=3)ji.fromArray(tC,E,A),ji.transformMat4(tC,tC,i._localTransform),ji.toArray(E,tC,A);sn(g,E,r,n,y.view.stride)}s=y.view.offset,a=_.UNKNOWN;for(var C=0;C<y.attributes.length;C++){var R=y.attributes[C];if(R.name===ie.ATTR_NORMAL){a=R.format;break}s+=ne[R.format].size}if(a){for(var b=Li(g,a,s,y.view.length,y.view.stride),x=0;x<b.length;x+=3)ji.fromArray(tC,b,x),ji.transformMat4Normal(tC,tC,$A),ji.toArray(b,tC,x);sn(g,b,a,s,y.view.stride)}o=y.view.offset,h=_.UNKNOWN;for(var w=0;w<y.attributes.length;w++){var M=y.attributes[w];if(M.name===ie.ATTR_TANGENT){h=M.format;break}o+=ne[M.format].size}if(h){for(var I=Li(g,h,o,y.view.length,y.view.stride),B=0;B<I.length;B+=3)ji.fromArray(tC,I,B),ji.transformMat4Normal(tC,tC,$A),ji.toArray(I,tC,B);sn(g,I,h,o,y.view.stride)}l=y.view.offset,u=_.UNKNOWN;for(var P=0;P<y.attributes.length;P++){var D=y.attributes[P];if(D.name===ie.ATTR_BATCH_UV){u=D.format;break}l+=ne[D.format].size}u&&on(g,(function(t,e){var i,n=0===e?"x":"y";return(t=(i=t)-Math.floor(i))*v[n]+m[n]}),u,l,y.view.length,y.view.stride,g);var O=f[e];if(!O)return"continue";c=y.view.offset,d=_.UNKNOWN;for(var F=0;F<y.attributes.length;F++){var L=y.attributes[F];if(L.name===ie.ATTR_JOINTS){d=L.format;break}c+=ne[L.format].size}d&&on(g,(function(t){return O[t]}),d,c,y.view.length,y.view.stride,g)},T=0;T<p.struct.vertexBundles.length;T++)y(T);t._mesh.merge(p)},y=0;y<p;y++)v(y);this._onMeshChanged(this._mesh),this._updateModels()}},i.cookTextures=function(t,e,i){for(var n=[],r=[],s=[],a=[],o=0;o<this.units.length;o++){var h=this.units[o];if(h.material){var l=h.material.getProperty(e,i);if(l&&l.image&&l.image.data){var u=new ht;u.texOffset.x=h.offset.x*this.atlasSize,u.texOffset.y=h.offset.y*this.atlasSize,u.texExtent.width=h.size.x*this.atlasSize,u.texExtent.height=h.size.y*this.atlasSize;var c=l.image.data;ArrayBuffer.isView(c)?(s.push(c),a.push(u)):(n.push(c),r.push(u))}}}var d=t.getGFXTexture(),_=We.director.root.device;s.length>0&&_.copyBuffersToTexture(s,d,a),n.length>0&&_.copyTexImagesToTexture(n,d,r)},i.createTexture=function(t){var e=new Xe;return e.setFilters(Ii.LINEAR,Ii.LINEAR),e.setMipFilter(Ii.NEAREST),e.reset({width:this.atlasSize,height:this.atlasSize,format:ze.RGBA8888}),this._textures[t]=e,e},i.resizeAtlases=function(){for(var t in this._textures)this._textures[t].reset({width:this.atlasSize,height:this.atlasSize,format:ze.RGBA8888})},i._createUnitMesh=function(t,e){for(var i=JSON.parse(JSON.stringify(e.struct)),n={},r=0;r<e.struct.primitives.length;r++){for(var s=e.struct.primitives[r],a=0,o=_.UNKNOWN,h=0;h<s.vertexBundelIndices.length;h++){var l=e.struct.vertexBundles[s.vertexBundelIndices[h]];a=l.view.offset,o=_.UNKNOWN;for(var u=0;u<l.attributes.length;u++){var c=l.attributes[u];if(c.name===ie.ATTR_TEX_COORD){o=c.format;break}a+=ne[c.format].size}if(o)break}if(void 0===n[h]){n[h]=[o,a];var d=i.vertexBundles[h];d.attributes.push(qA),d.attributes.push(ZA),d.view.offset=0,d.view.length+=d.view.count*QA,d.view.stride+=QA}}for(var f=0,p=0;p<i.vertexBundles.length;p++)f+=i.vertexBundles[p].view.length;for(var g=0;g<i.primitives.length;g++){var m=i.primitives[g];m.indexView&&(m.indexView.offset=f,f+=m.indexView.length)}var v=new Uint8Array(f),y=e.data,T=new DataView(v.buffer),S=new DataView(y.buffer),E=We.sys.isLittleEndian;for(var A in n)for(var C=i.vertexBundles[A],R=e.struct.vertexBundles[A],b=n[A],x=b[0],w=b[1],M=Li(S,x,w,R.view.length,R.view.stride),I=R.view,B=C.view,P=I.stride,D=B.stride,O=I.offset,F=B.offset,L=0;L<B.count;L++){var N=y.subarray(O,O+P);v.set(N,F),T.setFloat32(F+P,t),T.setFloat32(F+P+4,M[2*L],E),T.setFloat32(F+P+8,M[2*L+1],E),F+=D,O+=P}for(var k=0;k<i.primitives.length;k++){var U=e.struct.primitives[k],G=i.primitives[k];if(U.indexView&&G.indexView)for(var V=U.indexView.stride,H=G.indexView.stride,z=U.indexView.offset,X=G.indexView.offset,W=0;W<G.indexView.count;W++){var Y=y.subarray(z,z+V);v.set(Y,X),X+=H,z+=V}}var j=new mo;return j.reset({struct:i,data:v}),j},Pi(e,[{key:"mesh",get:function(){return t.prototype.mesh},set:function(t){this.mesh=t}},{key:"skeleton",get:function(){return t.prototype.skeleton},set:function(t){this.skeleton=t}}]),e}(KA),RA=tn(CA.prototype,"atlasSize",[en],(function(){return 1024})),bA=tn(CA.prototype,"batchableTextureNames",[SA,en],(function(){return[]})),xA=tn(CA.prototype,"units",[EA,en],(function(){return[]})),gn(CA.prototype,"mesh",[mn],Object.getOwnPropertyDescriptor(CA.prototype,"mesh"),CA.prototype),gn(CA.prototype,"skeleton",[mn],Object.getOwnPropertyDescriptor(CA.prototype,"skeleton"),CA.prototype),AA=CA))||AA)||AA));We.SkinningModelComponent=KA,br(KA,"cc.SkinningModelComponent"),We.SkinningModelUnit=JA,br(JA,"cc.SkinningModelUnit"),We.BatchedSkinningModelComponent=eC,br(eC,"cc.BatchedSkinningModelComponent");var iC,nC,rC,sC,aC,oC,hC,lC,uC,cC,dC,_C,fC,pC,gC,mC,vC,yC,TC,SC,EC,AC,CC=[.25,.125,.01],RC=t("LOD",(wA=Ki("cc.LOD"),MA=Tn([eT]),IA=Tn($r),BA=Tn([eT]),PA=Tn([Qr]),wA((OA=function(){function t(){this._screenUsagePercentage=FA&&FA(),this._renderers=LA&&LA(),this._LODData=new xi,this._modelAddedCallback=void 0,this._LODData.screenUsagePercentage=this._screenUsagePercentage,this._modelAddedCallback=null}var e=t.prototype;return e.insertRenderer=function(t,e){(t<0||t>this._renderers.length)&&(t=this._renderers.length),this._renderers.splice(t,0,e);var i=!1;return e.model&&(i=!0,this._LODData.addModel(e.model)),this._modelAddedCallback&&i&&this._modelAddedCallback(),e},e.deleteRenderer=function(t){var e,i=this._renderers.splice(t,1),n=i.length>0?null===(e=i[0])||void 0===e?void 0:e.model:null;return n&&this._LODData.eraseModel(n),i[0]},e.getRenderer=function(t){return this._renderers[t]||null},e.setRenderer=function(t,e){t<0||t>=this.rendererCount?console.error("setRenderer to LOD error, index out of range"):(this.deleteRenderer(t),this.insertRenderer(t,e))},Pi(t,[{key:"screenUsagePercentage",get:function(){return this._screenUsagePercentage},set:function(t){this._screenUsagePercentage=t,this._LODData.screenUsagePercentage=t}},{key:"renderers",get:function(){return this._renderers},set:function(t){if(t!==this._renderers){var e=!1;this._renderers.length=0,this._LODData.clearModels();for(var i=0;i<t.length;i++){var n;this._renderers[i]=t[i];var r=null===(n=t[i])||void 0===n?void 0:n.model;r&&(e=!0,this._LODData.addModel(r))}this._modelAddedCallback&&e&&this._modelAddedCallback()}}},{key:"triangleCount",get:function(){var t=[];return this._renderers.forEach((function(e){var i=0;if(e&&e.mesh){var n=e.mesh.struct.primitives;null==n||n.forEach((function(t){t&&t.indexView&&(i+=t.indexView.count)}))}t.push(i/3)})),t}},{key:"rendererCount",get:function(){return this._renderers.length}},{key:"lodData",get:function(){return this._LODData}},{key:"modelAddedCallback",set:function(t){this._modelAddedCallback=t}}]),t}(),FA=tn(OA.prototype,"_screenUsagePercentage",[en],(function(){return 1})),LA=tn(OA.prototype,"_renderers",[MA,en],(function(){return[]})),gn(OA.prototype,"screenUsagePercentage",[IA],Object.getOwnPropertyDescriptor(OA.prototype,"screenUsagePercentage"),OA.prototype),gn(OA.prototype,"renderers",[BA],Object.getOwnPropertyDescriptor(OA.prototype,"renderers"),OA.prototype),gn(OA.prototype,"triangleCount",[PA],Object.getOwnPropertyDescriptor(OA.prototype,"triangleCount"),OA.prototype),DA=OA))||DA)),bC=(t("LODGroup",(NA=Ki("cc.LODGroup"),kA=Tn($r),UA=Tn([RC]),NA((VA=function(t){function e(){var e;return(e=t.call(this)||this)._localBoundaryCenter=HA&&HA(),e._objectSize=zA&&zA(),e._LODs=XA&&XA(),e._lodGroup=new wi,e._eventRegistered=!1,e}He(e,t);var i=e.prototype;return i.onLodModelAddedCallback=function(){0===this.objectSize&&this.recalculateBounds()},i.insertLOD=function(t,e,i){if((t<0||t>this.lodCount)&&(t=this.lodCount),i||(i=new RC),i.modelAddedCallback=this.onLodModelAddedCallback.bind(this),!e){var n=this.getLOD(t-1),r=this.getLOD(t);if(n&&r)e=(n.screenUsagePercentage+r.screenUsagePercentage)/2;else if(n&&!r)(e=n.screenUsagePercentage/2)>.01&&(e=.01);else if(r&&!n){e=r.screenUsagePercentage;var s=this.getLOD(t+1);r.screenUsagePercentage=(e+(s?s.screenUsagePercentage:0))/2}else e=CC[0]}return i.screenUsagePercentage=e,this._LODs.splice(t,0,i),this._lodGroup.insertLOD(t,i.lodData),this._updateDataToScene(),this.node&&this._emitChangeNode(this.node),i},i.eraseLOD=function(t){if(t<0||t>=this.lodCount)return console.warn("eraseLOD error, index out of range"),null;var e=this._LODs[t];return e?(this._LODs.splice(t,1),this._lodGroup.eraseLOD(t),this._updateDataToScene(),this._emitChangeNode(this.node),e):(console.warn("eraseLOD error, LOD not exist at specified index."),null)},i.getLOD=function(t){return t<0||t>=this.lodCount?(console.warn("getLOD error, index out of range"),null):this._LODs[t]},i.setLOD=function(t,e){t<0||t>=this.lodCount?console.warn("setLOD error, index out of range"):(this._LODs[t]=e,e.modelAddedCallback=this.onLodModelAddedCallback.bind(this),this.lodGroup.updateLOD(t,e.lodData),this._updateDataToScene())},i.recalculateBounds=function(){for(var t=new ji,e=new ji,i=null,n=new ji,r=0;r<this.lodCount;++r){var s=this.getLOD(r);if(s)for(var a=0;a<s.rendererCount;++a){var o,h,l=s.getRenderer(a);if(l){null===(o=l.model)||void 0===o||o.updateWorldBound();var u=null===(h=l.model)||void 0===h?void 0:h.worldBounds;u&&(u.getBoundary(t,e),i?(ji.min(i,i,t),ji.max(n,n,e)):(i=t.clone(),n=e.clone()))}}}if(i){var c=i,d=new ji(.5*(n.x+c.x),.5*(n.y+c.y),.5*(n.z+c.z)),_=new ji(.5*(n.x-c.x),.5*(n.y-c.y),.5*(n.z-c.z)),f=function(t,e,i){var n,r,s=new Array(new ji(t.x-e.x,t.y-e.y,t.z-e.z),new ji(t.x-e.x,t.y+e.y,t.z-e.z),new ji(t.x+e.x,t.y+e.y,t.z-e.z),new ji(t.x+e.x,t.y-e.y,t.z-e.z),new ji(t.x-e.x,t.y-e.y,t.z+e.z),new ji(t.x-e.x,t.y+e.y,t.z+e.z),new ji(t.x+e.x,t.y+e.y,t.z+e.z),new ji(t.x+e.x,t.y-e.y,t.z+e.z));r=(n=s[0].transformMat4(i)).clone();for(var a=1;a<8;++a){var o=s[a].transformMat4(i);n=ji.min(n,n,o),r=ji.max(r,r,o)}return[n,r]}(d,_,this.node.worldMatrix.clone().invert()),p=f[0],g=f[1];d.set(.5*(g.x+p.x),.5*(g.y+p.y),.5*(g.z+p.z)),_.set(.5*(g.x-p.x),.5*(g.y-p.y),.5*(g.z-p.z)),this.localBoundaryCenter=d,this.objectSize=2*Math.max(_.x,_.y,_.z)}else this.localBoundaryCenter=new ji(0,0,0),this.objectSize=0;this._emitChangeNode(this.node)},i.resetObjectSize=function(){if(1!==this.objectSize){0===this.objectSize&&(this.objectSize=1);var t=1/this.objectSize;this.objectSize=1;for(var e=0;e<this.lodCount;++e){var i=this.getLOD(e);i&&(i.screenUsagePercentage*=t)}this._emitChangeNode(this.node)}},i.forceLOD=function(t){this.lodGroup.lockLODLevels(t<0?[]:[t])},i.onLoad=function(){this._lodGroup.node=this.node,this._lodGroup.objectSize=this._objectSize,this._lodGroup.localBoundaryCenter=this._localBoundaryCenter,this._eventRegistered||(this.node.on(xn.COMPONENT_REMOVED,this._onRemove,this),this._eventRegistered=!0),this._constructLOD()},i._onRemove=function(t){t===this&&this.onDisable()},i._constructLOD=function(){if(this.lodCount<1)for(var t=CC.length,e=0;e<t;e++)this.insertLOD(e,CC[e])},i.onRestore=function(){this._constructLOD(),this.enabledInHierarchy&&this._attachToScene()},i.onEnable=function(){var t=this;this._attachToScene(),0===this.objectSize&&this.recalculateBounds(),this.lodCount>0&&this._lodGroup.lodCount<1&&this._LODs.forEach((function(e,i){e.lodData.screenUsagePercentage=e.screenUsagePercentage;var n=e.renderers;if(null!==n&&n.length>0)for(var r=0;r<n.length;r++){var s=e.lodData,a=n[r];s&&a&&a.model&&s.addModel(a.model)}t._lodGroup.insertLOD(i,e.lodData)}))},i.onDisable=function(){this._detachFromScene()},i._attachToScene=function(){if(this.node&&this.node.scene){var t=this._getRenderScene();this._lodGroup.scene&&this._detachFromScene(),t.addLODGroup(this._lodGroup)}},i._detachFromScene=function(){this._lodGroup.scene&&this._lodGroup.scene.removeLODGroup(this._lodGroup)},i._emitChangeNode=function(){},i._updateDataToScene=function(){this._detachFromScene(),this._attachToScene()},Pi(e,[{key:"localBoundaryCenter",get:function(){return this._localBoundaryCenter.clone()},set:function(t){this._localBoundaryCenter.set(t),this._lodGroup.localBoundaryCenter=t}},{key:"lodCount",get:function(){return this._LODs.length}},{key:"objectSize",get:function(){return this._objectSize},set:function(t){this._objectSize=t,this._lodGroup.objectSize=t}},{key:"LODs",get:function(){return this._LODs},set:function(t){var e=this;t!==this._LODs?(this._LODs.length=0,this.lodGroup.clearLODs(),t.forEach((function(t,i){e.lodGroup.insertLOD(i,t.lodData),e._LODs[i]=t,t.modelAddedCallback=e.onLodModelAddedCallback.bind(e)})),this._updateDataToScene()):this._updateDataToScene()}},{key:"lodGroup",get:function(){return this._lodGroup}}]),e}(Pn),HA=tn(VA.prototype,"_localBoundaryCenter",[en],(function(){return new ji(0,0,0)})),zA=tn(VA.prototype,"_objectSize",[en],(function(){return 0})),XA=tn(VA.prototype,"_LODs",[en],(function(){return[]})),gn(VA.prototype,"objectSize",[kA],Object.getOwnPropertyDescriptor(VA.prototype,"objectSize"),VA.prototype),gn(VA.prototype,"LODs",[UA],Object.getOwnPropertyDescriptor(VA.prototype,"LODs"),VA.prototype),GA=VA))||GA)),Xn.makeMaskExclude([Xn.BitMask.UI_2D,Xn.BitMask.UI_3D,Xn.BitMask.GIZMOS,Xn.BitMask.EDITOR,Xn.BitMask.SCENE_GIZMO,Xn.BitMask.PROFILER,Xn.Enum.IGNORE_RAYCAST])),xC=function(){function t(){this._probes=[],this._useCubeModels=new Map,this._usePlanarModels=new Map,Di.on(An.EVENT_BEFORE_UPDATE,this.onUpdateProbes,this)}var e=t.prototype;return e.onUpdateProbes=function(t){if(void 0===t&&(t=!1),0!==this._probes.length){var e=Di.getScene();if(e&&e.renderScene)for(var i=e.renderScene.models,n=0;n<i.length;n++){var r=i[n];r.node&&r.node.layer&bC&&(r.node.hasChangedFlags||t)&&(r.reflectionProbeType===Ny.BAKED_CUBEMAP?this.updateUseCubeModels(r):r.reflectionProbeType===Ny.PLANAR_REFLECTION&&this.updateUsePlanarModels(r))}}},e.filterModelsForPlanarReflection=function(){if(0!==this._probes.length){var t=Di.getScene();if(t&&t.renderScene)for(var e=t.renderScene.models,i=0;i<e.length;i++){var n=e[i];n.node&&n.node.layer&bC&&n.reflectionProbeType===Ny.PLANAR_REFLECTION&&this.updateUsePlanarModels(n)}}},e.clearPlanarReflectionMap=function(t){for(var e,i=Fi(this._usePlanarModels.entries());!(e=i()).done;){var n=e.value;if(n[1]===t){var r=n[0].node.getComponent(eT);r&&r.updateProbePlanarMap(null)}}},e.register=function(t){-1===this._probes.indexOf(t)&&this._probes.push(t)},e.unregister=function(t){for(var e=0;e<this._probes.length;e++)if(this._probes[e]===t){var i=this._probes.splice(e,1);i[0]&&this._removeDependentModels(i[0]);break}},e.exists=function(t){if(0===this._probes.length)return!1;for(var e=0;e<this._probes.length;e++)if(this._probes[e].getProbeId()===t)return!0;return!1},e.getNewReflectionProbeId=function(){for(var t=0;;){if(!this.exists(t))return t;t++}},e.getProbes=function(){return this._probes},e.clearAll=function(){this._probes=[]},e.getProbeByCamera=function(t){for(var e=0;e<this._probes.length;e++)if(this._probes[e].camera===t)return this._probes[e];return null},e.updateBakedCubemap=function(t){var e=this._getModelsByProbe(t);if(t.cubemap){for(var i=0;i<e.length;i++){var n=e[i].node.getComponent(eT);n&&n.updateProbeCubemap(t.cubemap)}t.needRefresh=!1}},e.updatePlanarMap=function(t,e){if(t.node&&t.node.scene){for(var i=this._getModelsByProbe(t),n=0;n<i.length;n++){var r=i[n].node.getComponent(eT);r&&r.updateProbePlanarMap(e)}if(t.previewPlane){var s=t.previewPlane.getComponent(eT);s&&s.updateProbePlanarMap(e)}}},e.updateUsePlanarModels=function(t){if(t.node&&t.worldBounds&&t.reflectionProbeType===Ny.PLANAR_REFLECTION){for(var e=0;e<this._probes.length;e++){var i=this._probes[e];if(i.probeType===Ri.PLANAR){var n=t.node.getComponent(eT);if(t.node.layer&bC&&n)if(t.updateWorldBound(),Mr.aabbWithAABB(t.worldBounds,i.boundingBox))this._usePlanarModels.set(t,i);else if(this._usePlanarModels.has(t)&&this._usePlanarModels.get(t)===i){this._usePlanarModels.delete(t);var r=t.node.getComponent(eT);r&&r.updateProbePlanarMap(null)}}}for(var s=0;s<this._probes.length;s++)this._probes[s].probeType===Ri.PLANAR&&(this._probes[s].realtimePlanarTexture?this.updatePlanarMap(this._probes[s],this._probes[s].realtimePlanarTexture.getGFXTexture()):this.updatePlanarMap(this._probes[s],null))}},e.updateUseCubeModels=function(t){if(t.node&&t.worldBounds&&t.node.layer&bC){t.updateWorldBound();var e=this._getNearestProbe(t);if(e)this._useCubeModels.has(t)?this._useCubeModels.get(t)!==e&&(this._useCubeModels.set(t,e),e.needRefresh=!0):(this._useCubeModels.set(t,e),e.needRefresh=!0);else{var i=t.node.getComponent(eT);i&&i.updateProbeCubemap(null),this._useCubeModels.delete(t)}}for(var n=0;n<this._probes.length;n++)this._probes[n].needRefresh&&this._probes[n].probeType===Ri.CUBE&&this.updateBakedCubemap(this._probes[n])},e.updatePreviewSphere=function(t){if(t&&t.previewSphere){var e=t.previewSphere.getComponent(eT);e&&e.updateProbeCubemap(t.cubemap,!t.cubemap)}},e.updatePreviewPlane=function(t){t&&t.previewPlane&&t.previewPlane.getComponent(eT)&&t.realtimePlanarTexture&&this.updatePlanarMap(t,t.realtimePlanarTexture.getGFXTexture())},e._getNearestProbe=function(t){if(0===this._probes.length)return null;if(!t.node||!t.worldBounds)return null;for(var e=0,i=-1,n=!1,r=0;r<this._probes.length;r++)if(this._probes[r].probeType===Ri.CUBE&&this._probes[r].validate()&&Mr.aabbWithAABB(t.worldBounds,this._probes[r].boundingBox)){n||(n=!0,e=ji.distance(t.node.worldPosition,this._probes[r].node.worldPosition),i=r);var s=ji.distance(t.node.worldPosition,this._probes[r].node.worldPosition);s<e&&(e=s,i=r)}return n?this._probes[i]:null},e._getModelsByProbe=function(t){var e=[],i=this._useCubeModels;t.probeType===Ri.PLANAR&&(i=this._usePlanarModels);for(var n,r=Fi(i.entries());!(n=r()).done;){var s=n.value;s[1]===t&&e.push(s[0])}return e},e._removeDependentModels=function(t){for(var e,i=Fi(this._useCubeModels.keys());!(e=i()).done;){var n=e.value,r=this._useCubeModels.get(n);if(void 0!==r&&r===t){this._useCubeModels.delete(n);var s=n.node.getComponent(eT);s&&s.updateProbeCubemap(null)}}for(var a,o=Fi(this._usePlanarModels.keys());!(a=o()).done;){var h=a.value,l=this._usePlanarModels.get(h);if(void 0!==l&&l===t){this._usePlanarModels.delete(h);var u=h.node.getComponent(eT);u&&u.updateProbePlanarMap(null)}}},t}();xC.probeManager=void 0,xC.probeManager=new xC,We.internal.reflectionProbeManager=xC.probeManager,function(t){t[t.Low_256x256=256]="Low_256x256",t[t.Medium_512x512=512]="Medium_512x512",t[t.High_768x768=768]="High_768x768"}(AC||(AC={})),t("ReflectionProbe",(iC=Ki("cc.ReflectionProbe"),nC=Tn(ji),rC=Tn(fr(Ri)),sC=Tn(fr(AC)),aC=Tn(fr(Ci)),oC=Tn(Ve),hC=Tn(Xn.BitMask),lC=Tn(D_),iC((EC=SC=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._lastSize=new ji,e._resolution=dC&&dC(),e._clearFlag=_C&&_C(),e._backgroundColor=fC&&fC(),e._visibility=pC&&pC(),e._probeType=gC&&gC(),e._cubemap=mC&&mC(),e._size=vC&&vC(),e._sourceCamera=yC&&yC(),e._probeId=TC&&TC(),e._probe=null,e._previewSphere=null,e._previewPlane=null,e._sourceCameraPos=new ji(0,0,0),e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._createProbe()},i.onEnable=function(){this._probe&&(xC.probeManager.register(this._probe),this._probe.enable())},i.onDisable=function(){this._probe&&(xC.probeManager.unregister(this._probe),this._probe.disable())},i.start=function(){this._sourceCamera&&this.probeType===Ri.PLANAR&&(this.probe.renderPlanarReflection(this.sourceCamera.camera),xC.probeManager.filterModelsForPlanarReflection())},i.onDestroy=function(){this.probe&&this.probe.destroy()},i.update=function(){this.probe&&this.probeType===Ri.PLANAR&&this.sourceCamera&&(this.sourceCamera.node.hasChangedFlags&pr.TRS||!this._sourceCameraPos.equals(this.sourceCamera.node.getWorldPosition()))&&(this._sourceCameraPos=this.sourceCamera.node.getWorldPosition(),this.probe.renderPlanarReflection(this.sourceCamera.camera))},i.clearBakedCubemap=function(){this.cubemap=null,xC.probeManager.updateBakedCubemap(this.probe),xC.probeManager.updatePreviewSphere(this.probe)},i._createProbe=function(){if((-1===this._probeId||xC.probeManager.exists(this._probeId))&&(this._probeId=xC.probeManager.getNewReflectionProbeId()),this._probe=new bi(this._probeId),this._probe){var t=new Pr("ReflectionProbeCamera");t.hideFlags|=Dr.Flags.DontSave|Dr.Flags.HideInHierarchy,this.node.scene.addChild(t),this._probe.initialize(this.node,t),this.enabled&&xC.probeManager.register(this._probe),this._probe.resolution=this._resolution,this._probe.clearFlag=this._clearFlag,this._probe.backgroundColor=this._backgroundColor,this._probe.visibility=this._visibility,this._probe.probeType=this._probeType,this._probe.size=this._size,this._probe.cubemap=this._cubemap}},Pi(e,[{key:"size",get:function(){return this._size},set:function(t){t.x<0&&(t.x=0),t.y<0&&(t.y=0),t.z<0&&(t.z=0),this._size.set(t),this.probe.size=this._size,this.probe&&xC.probeManager.onUpdateProbes(!0)}},{key:"probeType",get:function(){return this._probeType},set:function(t){if(this.probe.probeType=t,t!==this._probeType){var i=this._size.clone(),n=ji.equals(this._lastSize,ji.ZERO);this._probeType=t,this._probeType===Ri.CUBE?(n&&this._size.set(e.DEFAULT_CUBE_SIZE),this.probe.switchProbeType(t,null),xC.probeManager.clearPlanarReflectionMap(this.probe)):(n&&this._size.set(e.DEFAULT_PLANER_SIZE),this._sourceCamera?this.probe.switchProbeType(t,this._sourceCamera.camera):console.warn("the reflection camera is invalid, please set the reflection camera")),n||this._size.set(this._lastSize),this._lastSize.set(i),this.size=this._size}}},{key:"resolution",get:function(){return this._resolution},set:function(t){this._resolution=t,this.probe.resolution=t}},{key:"clearFlag",get:function(){return this._clearFlag},set:function(t){this._clearFlag=t,this.probe.clearFlag=this._clearFlag}},{key:"backgroundColor",get:function(){return this._backgroundColor},set:function(t){this._backgroundColor=t,this.probe.backgroundColor=this._backgroundColor}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t,this.probe.visibility=this._visibility}},{key:"sourceCamera",get:function(){return this._sourceCamera},set:function(t){this._sourceCamera=t,t&&(this.visibility=t.visibility,this.clearFlag=t.clearFlags,this.backgroundColor=t.clearColor,this.probeType===Ri.PLANAR&&this.probe.switchProbeType(this.probeType,t.camera))}},{key:"cubemap",set:function(t){this._cubemap=t,this.probe.cubemap=t,xC.probeManager.onUpdateProbes(!0)}},{key:"probe",get:function(){return this._probe}},{key:"previewSphere",get:function(){return this._previewSphere},set:function(t){this._previewSphere=t,this.probe&&(this.probe.previewSphere=t,this._previewSphere&&xC.probeManager.updatePreviewSphere(this.probe))}},{key:"previewPlane",get:function(){return this._previewPlane},set:function(t){this._previewPlane=t,this.probe&&(this.probe.previewPlane=t,this._previewPlane&&xC.probeManager.updatePreviewPlane(this.probe))}}]),e}(Pn),SC.DEFAULT_CUBE_SIZE=new ji(1,1,1),SC.DEFAULT_PLANER_SIZE=new ji(5,.5,5),dC=tn((cC=EC).prototype,"_resolution",[en],(function(){return 256})),_C=tn(cC.prototype,"_clearFlag",[en],(function(){return Ci.SKYBOX})),fC=tn(cC.prototype,"_backgroundColor",[en],(function(){return new Ve(0,0,0,255)})),pC=tn(cC.prototype,"_visibility",[en],(function(){return vr})),gC=tn(cC.prototype,"_probeType",[en],(function(){return Ri.CUBE})),mC=tn(cC.prototype,"_cubemap",[en],(function(){return null})),vC=tn(cC.prototype,"_size",[en],(function(){return new ji(1,1,1)})),yC=tn(cC.prototype,"_sourceCamera",[en],(function(){return null})),TC=tn(cC.prototype,"_probeId",[en],(function(){return-1})),gn(cC.prototype,"size",[nC],Object.getOwnPropertyDescriptor(cC.prototype,"size"),cC.prototype),gn(cC.prototype,"probeType",[rC],Object.getOwnPropertyDescriptor(cC.prototype,"probeType"),cC.prototype),gn(cC.prototype,"resolution",[sC],Object.getOwnPropertyDescriptor(cC.prototype,"resolution"),cC.prototype),gn(cC.prototype,"clearFlag",[aC],Object.getOwnPropertyDescriptor(cC.prototype,"clearFlag"),cC.prototype),gn(cC.prototype,"backgroundColor",[oC],Object.getOwnPropertyDescriptor(cC.prototype,"backgroundColor"),cC.prototype),gn(cC.prototype,"visibility",[hC],Object.getOwnPropertyDescriptor(cC.prototype,"visibility"),cC.prototype),gn(cC.prototype,"sourceCamera",[lC],Object.getOwnPropertyDescriptor(cC.prototype,"sourceCamera"),cC.prototype),uC=cC))||uC)),We.utils=Bo;var wC,MC,IC,BC,PC,DC,OC=Symbol("CreateEval"),FC=(Ki("cc.animation.EmbeddedPlayer")((wC=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).begin=MC&&MC(),e.end=IC&&IC(),e.reconciledSpeed=BC&&BC(),e.playable=PC&&PC(),e}return He(e,t),e}(cs),MC=tn(wC.prototype,"begin",[en],(function(){return 0})),IC=tn(wC.prototype,"end",[en],(function(){return 0})),BC=tn(wC.prototype,"reconciledSpeed",[en],(function(){return!1})),PC=tn(wC.prototype,"playable",[en],(function(){return null})),wC)),function(){}),LC=function(){function t(t){this._randomAccess=t}return t.prototype.setTime=function(){},Pi(t,[{key:"randomAccess",get:function(){return this._randomAccess}}]),t}(),NC=function(){function t(){this._isPlaying=!1,this._isPaused=!1,this._stepOnce=!1}var e=t.prototype;return e.play=function(){this._isPlaying?this._isPaused?(this._isPaused=!1,this.onResume()):this.onError(Cn(3912)):(this._isPlaying=!0,this.onPlay())},e.stop=function(){this._isPlaying&&(this._isPlaying=!1,this.onStop(),this._isPaused=!1)},e.pause=function(){this._isPlaying&&!this._isPaused&&(this._isPaused=!0,this.onPause())},e.resume=function(){this._isPlaying&&this._isPaused&&(this._isPaused=!1,this.onResume())},e.step=function(){this.pause(),this._stepOnce=!0,this._isPlaying||this.play()},e.update=function(){},e.onPlay=function(){},e.onPause=function(){},e.onResume=function(){},e.onStop=function(){},e.onError=function(){},Pi(t,[{key:"isPlaying",get:function(){return this._isPlaying}},{key:"isPaused",get:function(){return this._isPaused}},{key:"isMotionless",get:function(){return!this.isPlaying||this.isPaused}}]),t}();!function(t){t[t.Default=ds.Default]="Default",t[t.Normal=ds.Normal]="Normal",t[t.Reverse=ds.Reverse]="Reverse",t[t.Loop=ds.Loop]="Loop",t[t.LoopReverse=ds.Loop|ds.Reverse]="LoopReverse",t[t.PingPong=ds.PingPong]="PingPong",t[t.PingPongReverse=ds.PingPong|ds.Reverse]="PingPongReverse"}(DC||(DC={})),Fn(DC);var kC,UC=function(){function t(t){this.ratio=0,this.time=0,this.direction=1,this.stopped=!0,this.iterations=0,this.frameIndex=void 0,t&&this.set(t)}return t.prototype.set=function(t){this.ratio=t.ratio,this.time=t.time,this.direction=t.direction,this.stopped=t.stopped,this.iterations=t.iterations,this.frameIndex=t.frameIndex},t}(),GC=function(){function t(t){this.weight=0,this._pose=void 0,this._blendStateWriters=[],this._pose=t}var e=t.prototype;return e.destroy=function(){for(var t=0;t<this._blendStateWriters.length;++t)this._pose.destroyWriter(this._blendStateWriters[t]);this._blendStateWriters.length=0},e.createPoseWriter=function(t,e,i){var n=this._pose.createWriter(t,e,this,i);return this._blendStateWriters.push(n),n},t}();function VC(){return We.director.getAnimationManager()}!function(t){t.PLAY="play",t.STOP="stop",t.PAUSE="pause",t.RESUME="resume",t.LASTFRAME="lastframe",t.FINISHED="finished"}(kC||(kC={})),Fn(kC);var HC,zC,XC,WC=t("AnimationState",function(t){function e(e,i){var n;return void 0===i&&(i=""),(n=t.call(this)||this).duration=1,n.time=0,n.frameRate=0,n._targetNode=null,n._curveLoaded=!1,n._clip=void 0,n._speed=1,n._useSimpleProcess=!1,n._target=null,n._wrapMode=DC.Normal,n._repeatCount=1,n._delay=0,n._delayTime=0,n._currentFramePlayed=!1,n._name=void 0,n._lastIterations=NaN,n._lastWrapInfo=null,n._wrappedInfo=new UC,n._allowLastFrame=!1,n._blendStateWriterHost={weight:0},n._playbackDuration=0,n._invDuration=1,n._poseOutput=null,n._weight=1,n._clipEval=void 0,n._clipEventEval=void 0,n._clipEmbeddedPlayerEval=void 0,n._doNotCreateEval=!1,n._clip=e,n._name=i||e&&e.name,n._playbackRange={min:0,max:e.duration},n._playbackDuration=e.duration,e.duration||Gn("Clip "+e.name+" has zero duration."),n}He(e,t);var i=e.prototype;return i.initialize=function(t,e,i){if(!this._curveLoaded){this._curveLoaded=!0,this._poseOutput&&(this._poseOutput.destroy(),this._poseOutput=null),this._clipEval&&(this._clipEval=void 0),this._clipEventEval&&(this._clipEventEval=void 0),this._clipEmbeddedPlayerEval&&(this._clipEmbeddedPlayerEval.destroy(),this._clipEmbeddedPlayerEval=void 0),this._targetNode=t;var n=this._clip;if(this.duration=n.duration,this._invDuration=1/this.duration,this._speed=n.speed,this.wrapMode=n.wrapMode,this.frameRate=n.sample,this._playbackRange.min=0,this._playbackRange.max=n.duration,this._playbackDuration=n.duration,(this.wrapMode&ds.Loop)===ds.Loop?this.repeatCount=1/0:this.repeatCount=1,!this._doNotCreateEval){var r,s,a,o=null!==(r=null!=e?e:null===(s=VC())||void 0===s?void 0:s.blendState)&&void 0!==r?r:null;o&&(this._poseOutput=new GC(o)),this._clipEval=n.createEvaluator({target:t,pose:null!==(a=this._poseOutput)&&void 0!==a?a:void 0,mask:i})}n.containsAnyEvent()&&(this._clipEventEval=n.createEventEvaluator(this._targetNode)),n.containsAnyEmbeddedPlayer()&&(this._clipEmbeddedPlayerEval=n.createEmbeddedPlayerEvaluator(this._targetNode),this._clipEmbeddedPlayerEval.notifyHostSpeedChanged(this._speed))}},i.destroy=function(){this.isMotionless||VC().removeAnimation(this),this._poseOutput&&(this._poseOutput.destroy(),this._poseOutput=null),this._clipEval=void 0},i.emit=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];VC().pushDelayEvent(this._emit,this,e)},i.on=function(t,e,i){return this._target&&this._target.isValid?this._target.on(t,e,i):null},i.once=function(t,e,i){return this._target&&this._target.isValid?this._target.once(t,e,i):null},i.off=function(t,e,i){this._target&&this._target.isValid&&this._target.off(t,e,i)},i.allowLastFrameEvent=function(t){this._allowLastFrame=t},i._setEventTarget=function(t){this._target=t},i.setTime=function(t){this._currentFramePlayed=!1,this.time=t||0;var e,i=this.getWrappedInfo(t,this._wrappedInfo);null===(e=this._clipEventEval)||void 0===e||e.ignore(i.ratio,i.direction)},i.update=function(t){this._delayTime>0&&(this._delayTime-=t,this._delayTime>0)||(this._currentFramePlayed?this.time+=t*this._speed:this._currentFramePlayed=!0,this._process())},i.sample=function(){var t=this.getWrappedInfo(this.time,this._wrappedInfo);return this._sampleCurves(t.time),this._sampleEvents(t),this._sampleEmbeddedPlayers(t),t},i.onPlay=function(){var t;this.setTime(this._getPlaybackStart()),this._delayTime=this._delay,this._onReplayOrResume(),this.emit(kC.PLAY,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onStop=function(){var t;this.isPaused||this._onPauseOrStop(),this.emit(kC.STOP,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostStop()},i.onResume=function(){var t;this._onReplayOrResume(),this.emit(kC.RESUME,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onPause=function(){var t;this._onPauseOrStop(),this.emit(kC.PAUSE,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPause(this.current)},i._sampleCurves=function(t){var e=this._poseOutput,i=this._clipEval;e&&(e.weight=this.weight),i&&i.evaluate(t)},i._process=function(){this._useSimpleProcess?this.simpleProcess():this.process()},i.process=function(){var t,e=this.sample();this._allowLastFrame&&(t=this._lastWrapInfo?this._lastWrapInfo:this._lastWrapInfo=new UC(e),this.repeatCount>1&&(0|e.iterations)>(0|t.iterations)&&this.emit(kC.LASTFRAME,this),t.set(e)),e.stopped&&(this.stop(),this.emit(kC.FINISHED,this))},i.simpleProcess=function(){var t=this._playbackRange.min,e=this._playbackDuration,i=0,n=0;if(0!==e&&((i=this.time%e)<0&&(i+=e),n=(t+i)*this._invDuration),this._sampleCurves(t+i),this._clipEventEval||this._clipEmbeddedPlayerEval){var r=this.getWrappedInfo(this.time,this._wrappedInfo);this._sampleEvents(r),this._sampleEmbeddedPlayers(r)}this._allowLastFrame&&(Number.isNaN(this._lastIterations)&&(this._lastIterations=n),(this.time>0&&this._lastIterations>n||this.time<0&&this._lastIterations<n)&&this.emit(kC.LASTFRAME,this),this._lastIterations=n)},i._needReverse=function(t){var e=this.wrapMode,i=!1;return(e&ds.PingPong)===ds.PingPong&&(t-(0|t)==0&&t>0&&(t-=1),1&t&&(i=!i)),(e&ds.Reverse)===ds.Reverse&&(i=!i),i},i.getWrappedInfo=function(t,e){e=e||new UC;var i=this._playbackRange.min,n=this._playbackDuration,r=this.repeatCount;if(0===n)return e.time=0,e.ratio=0,e.direction=1,e.stopped=!!Number.isFinite(r),e.iterations=0,e;var s=!1,a=(t-=i)>0?t/n:-t/n;if(a>=r){a=r,s=!0;var o=r-(0|r);0===o&&(o=1),t=o*n*(t>0?1:-1)}if(t>n){var h=t%n;t=0===h?n:h}else t<0&&0!=(t%=n)&&(t+=n);var l=!1,u=this._wrapMode&ds.ShouldWrap;u&&(l=this._needReverse(a));var c=l?-1:1;return this.speed<0&&(c*=-1),u&&l&&(t=n-t),e.time=i+t,e.ratio=e.time/this.duration,e.direction=c,e.stopped=s,e.iterations=a,e},i._getPlaybackStart=function(){return this._playbackRange.min},i._sampleEvents=function(t){var e;null===(e=this._clipEventEval)||void 0===e||e.sample(t.ratio,t.direction,t.iterations)},i._sampleEmbeddedPlayers=function(t){var e;null===(e=this._clipEmbeddedPlayerEval)||void 0===e||e.evaluate(t.time,Math.trunc(t.iterations))},i._emit=function(t,e){this._target&&this._target.isValid&&this._target.emit(t,t,e)},i._onReplayOrResume=function(){VC().addAnimation(this)},i._onPauseOrStop=function(){VC().removeAnimation(this)},Pi(e,[{key:"clip",get:function(){return this._clip}},{key:"name",get:function(){return this._name}},{key:"length",get:function(){return this.duration}},{key:"wrapMode",get:function(){return this._wrapMode},set:function(t){var e;this._wrapMode=t,this.time=0,t&ds.Loop?this.repeatCount=1/0:this.repeatCount=1,null===(e=this._clipEventEval)||void 0===e||e.setWrapMode(t)}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(t){this._repeatCount=t;var e=this._wrapMode&ds.ShouldWrap,i=(this.wrapMode&ds.Reverse)===ds.Reverse;this._useSimpleProcess=t===1/0&&!e&&!i}},{key:"delay",get:function(){return this._delay},set:function(t){this._delayTime=this._delay=t}},{key:"playbackRange",get:function(){return this._playbackRange},set:function(t){Ni(t.max>=t.min),this._playbackRange.min=Math.max(t.min,0),this._playbackRange.max=Math.min(t.max,this.duration),this._playbackDuration=this._playbackRange.max-this._playbackRange.min,this.setTime(0)}},{key:"speed",get:function(){return this._speed},set:function(t){var e;this._speed=t,null===(e=this._clipEmbeddedPlayerEval)||void 0===e||e.notifyHostSpeedChanged(t)}},{key:"current",get:function(){return this.getWrappedInfo(this.time).time}},{key:"ratio",get:function(){return 0===this.duration?0:this.current/this.duration}},{key:"weight",get:function(){return this._weight},set:function(t){this._weight=t,this._poseOutput&&(this._poseOutput.weight=t)}},{key:"curveLoaded",get:function(){return this._curveLoaded}}]),e}(NC));We.AnimationState=WC,Ki("cc.animation.EmbeddedAnimationClipPlayable")((HC=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).path=zC&&zC(),e.clip=XC&&XC(),e}return He(e,t),e.prototype.instantiate=function(t){var e=this.clip,i=this.path;if(!e)return null;var n=t.getChildByPath(i);if(!n)return hn(3938,i,t.getPathInHierarchy(),e.name),null;var r=new WC(e);return r.initialize(n),new tR(r)},e}(FC),zC=tn(HC.prototype,"path",[en],(function(){return""})),XC=tn(HC.prototype,"clip",[en],(function(){return null})),HC));var YC,jC,KC,qC,ZC,QC,JC,$C,tR=function(t){function e(e){var i;return(i=t.call(this,!0)||this)._animationState=void 0,i._animationState=e,i}He(e,t);var i=e.prototype;return i.destroy=function(){this._animationState.destroy()},i.play=function(){this._animationState.play()},i.pause=function(){this._animationState.pause()},i.stop=function(){this._animationState.stop()},i.setSpeed=function(t){this._animationState.speed=t},i.setTime=function(t){this._animationState.time=t},e}(LC),eR=(Ki("cc.animation.EmbeddedParticleSystemPlayable")((YC=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).path=jC&&jC(),e}return He(e,t),e.prototype.instantiate=function(t){var e=t.getChildByPath(this.path);if(!e)return Gi("Hierarchy path "+this.path+" does not exists."),null;var i=_s("cc.ParticleSystem");if(!i)return Gi("Particle system is required for embedded particle system player."),null;var n=e.getComponent(i);return n?new eR(n):(Gi(this.path+" does not includes a particle system component."),null)},e}(FC),jC=tn(YC.prototype,"path",[en],(function(){return""})),YC)),function(t){function e(e){var i;return(i=t.call(this,!1)||this)._particleSystem=void 0,i._particleSystem=e,i}He(e,t);var i=e.prototype;return i.destroy=function(){},i.play=function(){this._particleSystem.play()},i.pause=function(){this._particleSystem.stopEmitting()},i.stop=function(){this._particleSystem.stopEmitting()},i.setSpeed=function(t){this._particleSystem.simulationSpeed=t},e}(LC));function iR(t){return"string"==typeof t||"number"==typeof t}var nR,rR,sR,aR,oR,hR,lR,uR,cR,dR,_R,fR,pR,gR,mR,vR,yR,TR,SR,ER,AR,CR,RR,bR,xR,wR,MR,IR,BR,PR,DR,OR,FR,LR,NR,kR,UR,GR,VR=Ki("cc.animation.HierarchyPath")((qC=function(){function t(t){this.path=ZC&&ZC(),this.path=t||""}return t.prototype.get=function(t){return t instanceof Pr?t.getChildByPath(this.path)||(Zi(3926,t.name,this.path),null):(Zi(3925),null)},t}(),ZC=tn(qC.prototype,"path",[en],(function(){return""})),KC=qC))||KC,HR=Ki("cc.animation.ComponentPath")((JC=function(){function t(t){this.component=$C&&$C(),this.component=t||""}return t.prototype.get=function(t){return t instanceof Pr?t.getComponent(this.component)||(Zi(3928,t.name,this.component),null):(Zi(3927),null)},t}(),$C=tn(JC.prototype,"component",[en],(function(){return""})),QC=JC))||QC,zR=Symbol("NormalizedFollow"),XR=Symbol("ConvertAsTrsPath"),WR=Symbol("TrackBinding"),YR=Ki("cc.animation.TrackPath")((rR=function(){function t(){this._paths=sR&&sR()}var e=t.prototype;return e.toProperty=function(t){return this._paths.push(t),this},e.toElement=function(t){return this._paths.push(t),this},e.toHierarchy=function(t){return this._paths.push(new VR(t)),this},e.toComponent=function(t){var e=new HR("string"==typeof t?t:fs(t));return this._paths.push(e),this},e.toCustomized=function(t){return this._paths.push(t),this},e.append=function(){for(var t,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];var r=(t=this._paths).concat.apply(t,i.map((function(t){return t._paths})));return this._paths=r,this},e.isPropertyAt=function(t){return"string"==typeof this._paths[t]},e.parsePropertyAt=function(t){return this._paths[t]},e.isElementAt=function(t){return"number"==typeof this._paths[t]},e.parseElementAt=function(t){return this._paths[t]},e.isHierarchyAt=function(t){return this._paths[t]instanceof VR},e.parseHierarchyAt=function(t){return Ni(this.isHierarchyAt(t)),this._paths[t].path},e.isComponentAt=function(t){return this._paths[t]instanceof HR},e.parseComponentAt=function(t){return Ni(this.isComponentAt(t)),this._paths[t].component},e.slice=function(e,i){var n=new t;return n._paths=this._paths.slice(e,i),n},e.trace=function(t,e,i){var n,r;return null!==(n=e)&&void 0!==n||(e=0),null!==(r=i)&&void 0!==r||(i=this._paths.length),this[zR](t,e,i)},e[XR]=function(){for(var t,e=this._paths,i=e.length,n=0,r="";n<i;++n){var s=e[n];if(!(s instanceof VR))break;s.path&&(r?r+="/"+s.path:r=s.path)}if(n===i)return null;if(n!==i-1)return null;switch(e[n]){case"position":case"scale":case"rotation":case"eulerAngles":t=e[n];break;default:return null}return{node:r,property:t}},e[zR]=function(t,e,i){for(var n=this._paths,r=t,s=e;s<i;++s){var a=n[s];if(iR(a)){if(!(a in r))return Zi(3929,a),null;r=r[a]}else r=a.get(r);if(null===r)break}return r},Pi(t,[{key:"length",get:function(){return this._paths.length}}]),t}(),sR=tn(rR.prototype,"_paths",[en],(function(){return[]})),nR=rR))||nR,jR=Ki("cc.animation.TrackBinding")(aR=ps((cR=uR=function(){function t(){this.path=hR&&hR(),this.proxy=lR&&lR()}var e=t.prototype;return e.parseTrsPath=function(){return this.proxy?null:this.path[XR]()},e.createRuntimeBinding=function(e,i,n){var r=this.path,s=this.proxy,a=r.length,o=a-1;if(0===a||!r.isPropertyAt(o)&&!r.isElementAt(o)||s){if(s){var h=r[zR](e,0,a);if(null===h)return null;var l=s.forTarget(h),u={setValue:function(t){l.set(t)}},c=l.get;return c&&(u.getValue=function(){return c.call(l)}),u}return hn(3921),null}var d=r.isPropertyAt(o)?r.parsePropertyAt(o):r.parseElementAt(o),_=r[zR](e,0,a-1);if(null===_)return null;if(i&&_ instanceof Pr&&("position"===(p=d)||"rotation"===p||"scale"===p||"eulerAngles"===p))return i.createPoseWriter(_,d,n);var f=t._animationFunctions.get(_.constructor);f||(f=new Map,t._animationFunctions.set(_.constructor,f));var p,g=f.get(d);return g||(g={setValue:Function("value","this.target."+d+" = value;"),getValue:Function("return this.target."+d+";")},f.set(d,g)),{target:_,setValue:g.setValue,getValue:g.getValue}},e.isMaskedOff=function(t){var e=this.parseTrsPath();if(!e)return!1;for(var i=t.joints[Symbol.iterator](),n=i.next();!n.done;n=i.next()){var r=n.value;if(r.path===e.node)return!r.enabled}return!1},t}(),uR._animationFunctions=new WeakMap,hR=tn((oR=cR).prototype,"path",[en],(function(){return new YR})),lR=tn(oR.prototype,"proxy",[en],null),aR=oR))||aR)||aR,KR=Ki("cc.animation.Track")((_R=function(){function t(){this._binding=fR&&fR()}var e=t.prototype;return e.channels=function(){return[]},e.range=function(){for(var t,e={min:1/0,max:-1/0},i=Fi(this.channels());!(t=i()).done;){var n=t.value;e.min=Math.min(e.min,n.curve.rangeMin),e.max=Math.max(e.max,n.curve.rangeMax)}return e},Pi(t,[{key:"path",get:function(){return this._binding.path},set:function(t){this._binding.path=t}},{key:"proxy",get:function(){return this._binding.proxy},set:function(t){this._binding.proxy=t}},{key:WR,get:function(){return this._binding}}]),t}(),fR=tn(_R.prototype,"_binding",[en],(function(){return new jR})),dR=_R))||dR,qR=Ki("cc.animation.Channel")((gR=function(){function t(t){this.name="",this._curve=mR&&mR(),this._curve=t}return Pi(t,[{key:"curve",get:function(){return this._curve}}]),t}(),mR=tn(gR.prototype,"_curve",[en],null),pR=gR))||pR,ZR=Ki("cc.animation.SingleChannelTrack")((yR=function(t){function e(){var e;return(e=t.call(this)||this)._channel=TR&&TR(),e._channel=new qR(e.createCurve()),e}He(e,t);var i=e.prototype;return i.channels=function(){return[this._channel]},i.createCurve=function(){throw new Error("Not impl")},i[OC]=function(){var t=this._channel.curve;return new QR(t)},Pi(e,[{key:"channel",get:function(){return this._channel}}]),e}(KR),TR=tn(yR.prototype,"_channel",[en],null),vR=yR))||vR,QR=function(){function t(t){this._curve=t}return t.prototype.evaluate=function(t){return this._curve.evaluate(t)},t}(),JR=en,$R=(Ki("cc.animation.RealArrayTrack")((SR=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._channels=ER&&ER(),e}He(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[OC]=function(){return new $R(this._channels.map((function(t){return t.curve})))},Pi(e,[{key:"elementCount",get:function(){return this._channels.length},set:function(t){var e=this._channels.length;if(t<e)this._channels.splice(t);else if(t>e){var i;(i=this._channels).push.apply(i,Array.from({length:t-e},(function(){return new qR(new gs)})))}}}]),e}(KR),ER=tn(SR.prototype,"_channels",[JR],(function(){return[]})),SR)),function(){function t(t){this._curves=t,this._result=new Array(t.length).fill(0)}return t.prototype.evaluate=function(t){for(var e=this._result,i=e.length,n=0;n<i;++n)e[n]=this._curves[n].evaluate(t);return this._result},t}()),tb=Ki("cc.animation.UniformProxyFactory")((CR=function(){function t(t,e){this.passIndex=RR&&RR(),this.uniformName=bR&&bR(),ms(this,"channelIndex",xR,this),this.passIndex=e||0,this.uniformName=t||""}return t.prototype.forTarget=function(t){var e=t.passes[this.passIndex],i=e.getHandle(this.uniformName);if(!i)throw new Error('Material "'+t.name+'" has no uniform "'+this.uniformName+'"');if(Wn.getTypeFromHandle(i)<p.SAMPLER1D){var n=void 0===this.channelIndex?i:e.getHandle(this.uniformName,this.channelIndex,p.FLOAT);if(!n)throw new Error('Uniform "'+this.uniformName+" (in material "+t.name+") has no channel "+this.channelIndex+'"');return function(t,e){for(var i,n=Fi(t.shaderInfo.blocks);!(i=n()).done;)for(var r,s=i.value,a=Fi(s.members);!(r=a()).done;){var o=r.value;if(o.name===e)return o.count>1}return!1}(e,this.uniformName)?{set:function(t){e.setUniformArray(n,t)}}:{set:function(t){e.setUniform(n,t)}}}var r=Wn.getBindingFromHandle(i),s=e.properties[this.uniformName],a=s&&s.value?""+s.value+ir(s.type):er(s.type),o=Nn.get(a);return o||(Gi("Illegal texture default value: "+a+"."),o=Nn.get("default-texture")),{set:function(t){t||(t=o);var i=t.getGFXTexture();i&&i.width&&i.height&&(e.bindTexture(r,i),t instanceof Un&&e.bindSampler(r,ke.gfxDevice.getSampler(t.getSamplerInfo())))}}},t}(),RR=tn(CR.prototype,"passIndex",[en],(function(){return 0})),bR=tn(CR.prototype,"uniformName",[en],(function(){return""})),xR=gn(CR.prototype,"channelIndex",[vs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),AR=CR))||AR,eb=Ki("cc.animation.MorphWeightValueProxy")((MR=function(){function t(){this.subMeshIndex=IR&&IR(),this.shapeIndex=BR&&BR()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeight(i,e.subMeshIndex,e.shapeIndex)}}},t}(),IR=tn(MR.prototype,"subMeshIndex",[en],(function(){return 0})),BR=tn(MR.prototype,"shapeIndex",[en],(function(){return 0})),wR=MR))||wR,ib=Ki("cc.animation.MorphWeightsValueProxy")((DR=function(){function t(){this.subMeshIndex=OR&&OR()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeights(i,e.subMeshIndex)}}},t}(),OR=tn(DR.prototype,"subMeshIndex",[en],(function(){return 0})),PR=DR))||PR,nb=Ki("cc.animation.MorphWeightsAllValueProxy")(FR=function(){function t(){}return t.prototype.forTarget=function(t){return{set:function(e){for(var i,n,r=null!==(i=null===(n=t.mesh)||void 0===n?void 0:n.struct.primitives.length)&&void 0!==i?i:0,s=0;s<r;++s)t.setWeights(e,s)}}},t}())||FR;function rb(t,e,i,n){var r,s,a,o,h,l=new e,u=new e,c=new e,d=Ki(t)((s=function(){function t(t,i,n){this.dataPoint=a&&a(),this.inTangent=o&&o(),this.outTangent=h&&h(),this.dataPoint=t||new e,this.inTangent=i||new e,this.outTangent=n||new e}var r=t.prototype;return r.lerp=function(t,e,r){var s=this.dataPoint,a=t.dataPoint;u=i(u,this.inTangent,r),c=i(c,t.outTangent,r);var o=e*e*e,h=e*e,d=o-2*h+e,_=-2*o+3*h,f=o-h;return l=i(l,s,2*o-3*h+1),l=n(l,l,u,d),l=n(l,l,a,_),l=n(l,l,c,f)},r.getNoLerp=function(){return this.dataPoint},t}(),a=tn(s.prototype,"dataPoint",[en],(function(){return new e})),o=tn(s.prototype,"inTangent",[en],(function(){return new e})),h=tn(s.prototype,"outTangent",[en],(function(){return new e})),r=s))||r;if(e===Ji){var _=d.prototype.lerp;d.prototype.lerp=function(t,e,i){var n=_.call(this,t,e,i);return Ji.normalize(n,n),n}}return d}var sb,ab,ob,hb,lb,ub=rb("cc.CubicSplineVec2Value",cn,cn.multiplyScalar,cn.scaleAndAdd),cb=rb("cc.CubicSplineVec3Value",ji,ji.multiplyScalar,ji.scaleAndAdd),db=rb("cc.CubicSplineVec4Value",_n,_n.multiplyScalar,_n.scaleAndAdd),_b=rb("cc.CubicSplineQuatValue",Ji,Ji.multiplyScalar,Ji.scaleAndAdd),fb=Ki("cc.CubicSplineNumberValue")((NR=function(){function t(t,e,i){this.dataPoint=kR&&kR(),this.inTangent=UR&&UR(),this.outTangent=GR&&GR(),this.dataPoint=t,this.inTangent=e,this.outTangent=i}var e=t.prototype;return e.lerp=function(t,e,i){var n=this.dataPoint,r=t.dataPoint,s=e*e*e,a=e*e;return n*(2*s-3*a+1)+this.outTangent*i*(s-2*a+e)+r*(-2*s+3*a)+t.inTangent*i*(s-a)},e.getNoLerp=function(){return this.dataPoint},t}(),kR=tn(NR.prototype,"dataPoint",[en],(function(){return 0})),UR=tn(NR.prototype,"inTangent",[en],(function(){return 0})),GR=tn(NR.prototype,"outTangent",[en],(function(){return 0})),LR=NR))||LR,pb=Ki("cc.animation.RealTrack")(sb=function(t){function e(){return t.apply(this,arguments)||this}return He(e,t),e.prototype.createCurve=function(){return new gs},e}(ZR))||sb;function gb(t){return 0===t.keyFramesCount?void 0:t}var mb,vb,yb,Tb,Sb,Eb,Ab,Cb,Rb=["X","Y","Z","W"],bb=Ki("cc.animation.VectorTrack")((ob=function(t){function e(){var e;(e=t.call(this)||this)._channels=hb&&hb(),e._nComponents=lb&&lb(),e._channels=new Array(4);for(var i=0;i<e._channels.length;++i){var n=new qR(new gs);n.name=Rb[i],e._channels[i]=n}return e}He(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[OC]=function(){switch(this._nComponents){default:case 2:return new xb(gb(this._channels[0].curve),gb(this._channels[1].curve));case 3:return new wb(gb(this._channels[0].curve),gb(this._channels[1].curve),gb(this._channels[2].curve));case 4:return new Mb(gb(this._channels[0].curve),gb(this._channels[1].curve),gb(this._channels[2].curve),gb(this._channels[3].curve))}},Pi(e,[{key:"componentsCount",get:function(){return this._nComponents},set:function(t){this._nComponents=t}}]),e}(KR),hb=tn(ob.prototype,"_channels",[en],null),lb=tn(ob.prototype,"_nComponents",[en],(function(){return 4})),ab=ob))||ab,xb=function(){function t(t,e){this._result=new cn,this._x=t,this._y=e}return t.prototype.evaluate=function(t,e){return this._x&&this._y||!e.getValue||cn.copy(this._result,e.getValue()),this._x&&(this._result.x=this._x.evaluate(t)),this._y&&(this._result.y=this._y.evaluate(t)),this._result},t}(),wb=function(){function t(t,e,i){this._result=new ji,this._x=t,this._y=e,this._z=i}return t.prototype.evaluate=function(t,e){return this._x&&this._y&&this._z||!e.getValue||ji.copy(this._result,e.getValue()),this._x&&(this._result.x=this._x.evaluate(t)),this._y&&(this._result.y=this._y.evaluate(t)),this._z&&(this._result.z=this._z.evaluate(t)),this._result},t}(),Mb=function(){function t(t,e,i,n){this._result=new _n,this._x=t,this._y=e,this._z=i,this._w=n}return t.prototype.evaluate=function(t,e){return this._x&&this._y&&this._z&&this._w||!e.getValue||_n.copy(this._result,e.getValue()),this._x&&(this._result.x=this._x.evaluate(t)),this._y&&(this._result.y=this._y.evaluate(t)),this._z&&(this._result.z=this._z.evaluate(t)),this._w&&(this._result.w=this._w.evaluate(t)),this._result},t}(),Ib=Ki("cc.animation.QuatTrack")(mb=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.createCurve=function(){return new ys},i[OC]=function(){return new Bb(this.channels()[0].curve)},e}(ZR))||mb,Bb=function(){function t(t){this._result=new Ji,this._curve=t}return t.prototype.evaluate=function(t){return this._curve.evaluate(t,this._result),this._result},t}(),Pb=["Red","Green","Blue","Alpha"],Db=Ki("cc.animation.ColorTrack")((yb=function(t){function e(){var e;(e=t.call(this)||this)._channels=Tb&&Tb(),e._channels=new Array(4);for(var i=0;i<e._channels.length;++i){var n=new qR(new gs);n.name=Pb[i],e._channels[i]=n}return e}He(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[OC]=function(){return new Ob(gb(this._channels[0].curve),gb(this._channels[1].curve),gb(this._channels[2].curve),gb(this._channels[3].curve))},e}(KR),Tb=tn(yb.prototype,"_channels",[en],null),vb=yb))||vb,Ob=function(){function t(t,e,i,n){this._result=new Ve,this._x=t,this._y=e,this._z=i,this._w=n}return t.prototype.evaluate=function(t,e){return this._x&&this._y&&this._z&&this._w||!e.getValue||Ve.copy(this._result,e.getValue()),this._x&&(this._result.r=this._x.evaluate(t)),this._y&&(this._result.g=this._y.evaluate(t)),this._z&&(this._result.b=this._z.evaluate(t)),this._w&&(this._result.a=this._w.evaluate(t)),this._result},t}(),Fb=["Width","Height"],Lb=Ki("cc.animation.SizeTrack")((Eb=function(t){function e(){var e;(e=t.call(this)||this)._channels=Ab&&Ab(),e._channels=new Array(2);for(var i=0;i<e._channels.length;++i){var n=new qR(new gs);n.name=Fb[i],e._channels[i]=n}return e}He(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[OC]=function(){return new Nb(gb(this._channels[0].curve),gb(this._channels[1].curve))},e}(KR),Ab=tn(Eb.prototype,"_channels",[en],null),Sb=Eb))||Sb,Nb=function(){function t(t,e){this._result=new dn,this._width=t,this._height=e}return t.prototype.evaluate=function(t,e){if((!this._width||!this._height)&&e.getValue){var i=e.getValue();this._result.x=i.x,this._result.y=i.y}return this._width&&(this._result.width=this._width.evaluate(t)),this._height&&(this._result.height=this._height.evaluate(t)),this._result},t}(),kb=Ki("cc.animation.ObjectTrack")(Cb=function(t){function e(){return t.apply(this,arguments)||this}return He(e,t),e.prototype.createCurve=function(){return new Ts},e}(ZR))||Cb;t("animation",Object.freeze({__proto__:null,UniformProxyFactory:tb,MorphWeightValueProxy:eb,MorphWeightsValueProxy:ib,MorphWeightsAllValueProxy:nb,Track:KR,TrackPath:YR,RealTrack:pb,VectorTrack:bb,QuatTrack:Ib,ColorTrack:Db,SizeTrack:Lb,ObjectTrack:kb,isPropertyPath:iR,isCustomPath:function(t,e){return t instanceof e},HierarchyPath:VR,ComponentPath:HR,CubicSplineVec2Value:ub,CubicSplineVec3Value:cb,CubicSplineVec4Value:db,CubicSplineQuatValue:_b,CubicSplineNumberValue:fb}));var Ub=t("RatioSampler",function(){function t(t){var e,i;this.ratios=void 0,this._findRatio=void 0,this.ratios=t;for(var n=!0,r=1,s=t.length;r<s;r++)if(e=t[r]-t[r-1],1===r)i=e;else if(Math.abs(e-i)>1e-6){n=!1;break}this._findRatio=n?zb:As}return t.prototype.sample=function(t){return this._findRatio(this.ratios,t)},t}());We.RatioSampler=Ub;var Gb=t("AnimCurve",function(){function t(e,i){this.types=void 0,this.type=null,this._values=[],this._lerp=void 0,this._duration=void 0,this._array=void 0,this._duration=i,this._values=e.values;var n=function(e){return"string"==typeof e?e:Array.isArray(e)?e[0]===e[1]&&e[2]===e[3]?t.Linear:t.Bezier(e):t.Linear};if(void 0!==e.easingMethod)this.type=n(e.easingMethod);else if(Array.isArray(e.easingMethods))this.types=e.easingMethods.map(n);else if(void 0!==e.easingMethods){this.types=new Array(this._values.length).fill(null);for(var r=0,s=Object.keys(e.easingMethods);r<s.length;r++){var a=s[r];this.types[a]=n(e.easingMethods[a])}}else this.type=null;var o=e.values[0];(void 0===e.interpolate||e.interpolate)&&(this._lerp=Zb(o)),void 0!==e._arrayLength&&(this._array=new Array(e._arrayLength))}t.Bezier=function(t){return t};var e=t.prototype;return e.hasLerp=function(){return!!this._lerp},e.valueAt=function(t){if(void 0===this._array){var e=this._values[t];return e&&e.getNoLerp?e.getNoLerp():e}for(var i=0;i<this._array.length;++i)this._array[i]=this._values[this._array.length*t+i];return this._array},e.valueBetween=function(t,e,i,n,r){if(this._lerp){var s=this.types?this.types[e]:this.type,a=r-i,o=(t-i)/a;if(s&&(o=Hb(o,s)),void 0===this._array){var h=this._values[e],l=this._values[n];return this._lerp(h,l,o,a*this._duration)}for(var u=0;u<this._array.length;++u){var c=this._values[this._array.length*e+u],d=this._values[this._array.length*n+u];this._array[u]=this._lerp(c,d,o,a*this._duration)}return this._array}if(void 0===this._array)return this.valueAt(e);for(var _=0;_<this._array.length;++_)this._array[_]=this._values[this._array.length*e+_];return this._array},e.empty=function(){return 0===this._values.length},e.constant=function(){return 1===this._values.length},t}());function Vb(t,e,i){var n=e.sample(i);if(n<0)if((n=~n)<=0)n=0;else{if(!(n>=e.ratios.length))return t.valueBetween(i,n-1,e.ratios[n-1],n,e.ratios[n]);n=e.ratios.length-1}return t.valueAt(n)}function Hb(t,e){if("string"==typeof e){var i=Ss[e];i?t=i(t):hn(3906,e)}else Array.isArray(e)&&(t=Es(e,t));return t}function zb(t,e){var i=t.length-1;if(0===i)return 0;var n=t[0];if(e<n)return 0;var r=t[i];if(e>r)return i;var s=(e=(e-n)/(r-n))/(1/i),a=0|s,o=1e-6;return s-a<o?a:a+1-s<o?a+1:~(a+1)}Gb.Linear=null,We.AnimCurve=Gb,t("EventInfo",function(){function t(){this.events=[]}return t.prototype.add=function(t,e){this.events.push({func:t||"",params:e||[]})},t}()),We.sampleAnimationCurve=Vb;var Xb,Wb,Yb,jb,Kb,qb,Zb=function(){function t(t,e,i,n){return t.lerp(e,i,n)}return function(e){if(null!==e){if("number"==typeof e)return Cs;if("object"==typeof e&&e.constructor){if(e instanceof Ji)return i=new Ji,function(t,e,n){return Ji.slerp(i,t,e,n)};if(e instanceof Rs)return function(t){var e=new t;return function(i,n,r){return t.lerp(e,i,n,r),e}}(e.constructor);if(e.constructor===Number)return Cs;if("function"==typeof e.lerp)return t}var i}}}(),Qb=Ki("cc.animation.UntypedTrackChannel")((Wb=function(t){function e(){var e;return(e=t.call(this,new gs)||this).property=Yb&&Yb(),e}return He(e,t),e}(qR),Yb=tn(Wb.prototype,"property",[en],(function(){return""})),Xb=Wb))||Xb,Jb=Ki("cc.animation.UntypedTrack")((Kb=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._channels=qb&&qb(),e}He(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[OC]=function(t){var e=this;if(!t.getValue)throw new Error(Cn(3930));var i=function(t){var i;return null===(i=e._channels.find((function(e){return e.property===t})))||void 0===i?void 0:i.curve},n=t.getValue();switch(!0){default:throw new Error(Cn(3931));case n instanceof cn:return new xb(i("x"),i("y"));case n instanceof ji:return new wb(i("x"),i("y"),i("z"));case n instanceof _n:return new Mb(i("x"),i("y"),i("z"),i("w"));case n instanceof Ve:return new Ob(i("r"),i("g"),i("b"),i("a"));case n instanceof dn:return new Nb(i("width"),i("height"))}},i.addChannel=function(t){var e=new Qb;return e.property=t,this._channels.push(e),e},i.upgrade=function(t){var e=this,i=function(t,i){var n=e.channels().find((function(e){return e.property===t}));n&&(i.name=n.name,i.curve.assignSorted(Array.from(n.curve.times()),Array.from(n.curve.values())))},n=t(this.path,this.proxy);switch(n){default:break;case"vec2":case"vec3":case"vec4":var r=new bb;r.path=this.path,r.proxy=this.proxy,r.componentsCount="vec2"===n?2:"vec3"===n?3:4;var s=r.channels(),a=s[0],o=s[1],h=s[2],l=s[3];switch(n){case"vec4":i("w",l);case"vec3":i("z",h);default:case"vec2":i("x",a),i("y",o)}return r;case"color":var u=new Db,c=u.channels(),d=c[0],_=c[1],f=c[2],p=c[3];return i("r",d),i("g",_),i("b",f),i("a",p),i("x",d),i("y",_),i("z",f),i("w",p),u;case"size":}return null},e}(KR),qb=tn(Kb.prototype,"_channels",[en],(function(){return[]})),jb=Kb))||jb,$b=function(){function t(t){this._keys=[],this._curves=[],this._commonTargets=[],this._ratioSamplers=[],this._runtimeCurves=void 0,this._data=null,this._duration=void 0,this._duration=t}var e=t.prototype;return e.getPropertyCurves=function(){return this._runtimeCurves||this._createPropertyCurves(),this._runtimeCurves},e.toTracks=function(){for(var t,e=[],i=this.keys,n=this.curves,r=this.commonTargets,s=function(t,e,i){for(var n,r=new YR,s=Fi(e);!(n=s()).done;){var a=n.value;"string"==typeof a?r.toProperty(a):"number"==typeof a?r.toElement(a):a instanceof VR?r.toHierarchy(a.path):a instanceof HR?r.toComponent(a.component):r.toCustomized(a)}t.path=r,t.proxy=i},a=r.map((function(t){var i=new Jb;return s(i,t.modifiers,t.valueAdapter),e.push(i),i})),o=function(){var n,r=t.value,o=r.data,h=o.values;if(0===h.length)return"continue";var l=o.keys<0?[0]:i[o.keys],u=h[0],c=null===(n=o.interpolate)||void 0===n||n;Ni("number"!=typeof o._arrayLength||"number"==typeof u);var d=new ex(o,l.length),_=function(t){s(t,r.modifiers,r.valueAdapter)},f=void 0;if("number"==typeof r.commonTarget){if(!h.every((function(t){return"number"==typeof t})))return Zi(3932),"continue";if(r.valueAdapter||1!==r.modifiers.length||"string"!=typeof r.modifiers[0])return Zi(3933),"continue";var p=r.modifiers[0],g=a[r.commonTarget].addChannel(p).curve;f=g}!function(){if("number"==typeof u){if(!h.every((function(t){return"number"==typeof t})))return void Zi(3934);var t;if(f)t=f;else{var i=new pb;_(i),e.push(i),t=i.channel.curve}var n=c?xs.LINEAR:xs.CONSTANT;return t.assignSorted(l,h.map((function(t){return{value:t,interpolationMode:n}}))),void d.convert(t)}if("object"==typeof u)switch(!0){default:break;case tx(h,cn):case tx(h,ji):case tx(h,_n):var r=u instanceof cn?2:u instanceof ji?3:4,s=new bb;_(s),s.componentsCount=r;var a=s.channels(),o=a[0].curve,p=a[1].curve,g=a[2].curve,m=a[3].curve,v=c?xs.LINEAR:xs.CONSTANT,y=function(t){return{value:t,interpolationMode:v}};switch(r){case 4:m.assignSorted(l,h.map((function(t){return y(t.w)}))),d.convert(m);case 3:g.assignSorted(l,h.map((function(t){return y(t.z)}))),d.convert(g);default:o.assignSorted(l,h.map((function(t){return y(t.x)}))),d.convert(o),p.assignSorted(l,h.map((function(t){return y(t.y)}))),d.convert(p)}return void e.push(s);case tx(h,Ji):var T=new Ib;_(T);var S=c?Ms.SLERP:Ms.CONSTANT;return T.channel.curve.assignSorted(l,h.map((function(t){return{value:Ji.clone(t),interpolationMode:S}}))),d.convertQuatCurve(T.channel.curve),void e.push(T);case tx(h,Ve):var E=new Db;_(E);var A=E.channels(),C=A[0].curve,R=A[1].curve,b=A[2].curve,x=A[3].curve,w=c?xs.LINEAR:xs.CONSTANT,M=function(t){return{value:t,interpolationMode:w}};return C.assignSorted(l,h.map((function(t){return M(t.r)}))),d.convert(C),R.assignSorted(l,h.map((function(t){return M(t.g)}))),d.convert(R),b.assignSorted(l,h.map((function(t){return M(t.b)}))),d.convert(b),x.assignSorted(l,h.map((function(t){return M(t.a)}))),d.convert(x),void e.push(E);case tx(h,dn):var I=new Lb;_(I);var B=I.channels(),P=B[0].curve,D=B[1].curve,O=c?xs.LINEAR:xs.CONSTANT,F=function(t){return{value:t,interpolationMode:O}};return P.assignSorted(l,h.map((function(t){return F(t.width)}))),d.convert(P),D.assignSorted(l,h.map((function(t){return F(t.height)}))),d.convert(D),void e.push(I);case tx(h,fb):var L=new pb;_(L);var N=c?xs.CUBIC:xs.CONSTANT;return L.channel.curve.assignSorted(l,h.map((function(t){return{value:t.dataPoint,leftTangent:t.inTangent,rightTangent:t.outTangent,interpolationMode:N}}))),void e.push(L);case tx(h,ub):case tx(h,cb):case tx(h,db):var k=u instanceof ub?2:u instanceof cb?3:4,U=new bb;_(U),U.componentsCount=k;var G=U.channels(),V=G[0],H=G[1],z=G[2],X=G[3],W=c?xs.LINEAR:xs.CONSTANT,Y=function(t,e,i){return{value:t,leftTangent:e,rightTangent:i,interpolationMode:W}};switch(k){case 4:X.curve.assignSorted(l,h.map((function(t){return Y(t.dataPoint.w,t.inTangent.w,t.outTangent.w)})));case 3:z.curve.assignSorted(l,h.map((function(t){return Y(t.dataPoint.z,t.inTangent.z,t.outTangent.z)})));default:V.curve.assignSorted(l,h.map((function(t){return Y(t.dataPoint.y,t.inTangent.y,t.outTangent.y)}))),H.curve.assignSorted(l,h.map((function(t){return Y(t.dataPoint.x,t.inTangent.x,t.outTangent.x)})))}return void e.push(U);case h.every((function(t){return t instanceof _b})):Zi(3935)}var j=new kb;_(j),j.channel.curve.assignSorted(l,h),e.push(j)}()},h=Fi(n);!(t=h()).done;)o();return e},e._createPropertyCurves=function(){var t=this;this._ratioSamplers=this._keys.map((function(e){return new Ub(e.map((function(e){return e/t._duration})))})),this._runtimeCurves=this._curves.map((function(e){return{curve:new Gb(e.data,t._duration),modifiers:e.modifiers,valueAdapter:e.valueAdapter,sampler:t._ratioSamplers[e.data.keys],commonTarget:e.commonTarget}}))},Pi(t,[{key:"keys",get:function(){return this._keys},set:function(t){this._keys=t}},{key:"curves",get:function(){return this._curves},set:function(t){this._curves=t,delete this._runtimeCurves}},{key:"commonTargets",get:function(){return this._commonTargets},set:function(t){this._commonTargets=t}},{key:"data",get:function(){return this._data}}]),t}();function tx(t,e){return t.every((function(t){return t instanceof e}))}var ex=function(){function t(t,e){this._easingMethods=void 0;var i=t.easingMethods;Array.isArray(i)?0===i.length&&0!==e?this._easingMethods=new Array(e).fill(null):this._easingMethods=i:this._easingMethods=void 0===i?new Array(e).fill(t.easingMethod):Array.from({length:e},(function(t,e){var n;return null!==(n=i[e])&&void 0!==n?n:null}))}var e=t.prototype;return e.convert=function(t){var e,i,n,r,s,a,o,h,l,u,c,d,_,f,p,g,m,v,y,T,S,E,A=this._easingMethods;if(A){var C=t.keyFramesCount;if(!(t.keyFramesCount<2)){Array.isArray(A)&&Ni(C===A.length);for(var R=C-1,b=0;b<R;++b){var x=A[b];x&&(Array.isArray(x)?(e=x,i=t.getKeyframeTime(b),n=t.getKeyframeValue(b),r=t.getKeyframeTime(b+1),s=t.getKeyframeValue(b+1),a=void 0,o=void 0,h=void 0,l=void 0,u=void 0,c=void 0,d=void 0,_=void 0,f=void 0,p=void 0,g=void 0,m=void 0,v=void 0,y=void 0,T=void 0,S=void 0,E=void 0,o=e[0],h=e[1],l=e[2],u=e[3],c=n.value,d=3*(r-i),_=3*(s.value-c),g=(1-l)*d,m=(1-u)*_,v=1/3,y=(p=h*_)/(f=o*d),T=Math.sqrt(f*f+p*p)*v,S=m/g,E=Math.sqrt(g*g+m*m)*v,n.interpolationMode=xs.CUBIC,n.tangentWeightMode=(a=n.tangentWeightMode)===ws.NONE?ws.RIGHT:a===ws.LEFT?ws.BOTH:a,n.rightTangent=y,n.rightTangentWeight=T,s.tangentWeightMode=function(t){return t===ws.NONE?ws.LEFT:t===ws.RIGHT?ws.BOTH:t}(s.tangentWeightMode),s.leftTangent=S,s.leftTangentWeight=E):ix(x,t,b))}}}},e.convertQuatCurve=function(t){var e=this._easingMethods;if(e){var i=t.keyFramesCount;if(!(t.keyFramesCount<2)){Array.isArray(e)&&Ni(i===e.length);for(var n=i-1,r=0;r<n;++r){var s=e[r];s&&(Array.isArray(s)?t.getKeyframeValue(r).easingMethod=s.slice():nx(s,t,r))}}}},Pi(t,[{key:"nil",get:function(){return!this._easingMethods||this._easingMethods.every((function(t){return null==t}))}}]),t}();function ix(t,e,i){Ni(i!==e.keyFramesCount-1);var n=e.getKeyframeValue(i),r=wx[t];r===bs.CONSTANT?n.interpolationMode=xs.CONSTANT:(n.interpolationMode=xs.LINEAR,n.easingMethod=r)}function nx(t,e,i){Ni(i!==e.keyFramesCount-1);var n=e.getKeyframeValue(i),r=wx[t];n.easingMethod=r}var rx,sx,ax,ox,hx,lx,ux,cx,dx,_x,fx,px,gx,mx,vx,yx,Tx,Sx,Ex,Ax,Cx,Rx,bx,xx,wx={constant:bs.CONSTANT,linear:bs.LINEAR,quadIn:bs.QUAD_IN,quadOut:bs.QUAD_OUT,quadInOut:bs.QUAD_IN_OUT,quadOutIn:bs.QUAD_OUT_IN,cubicIn:bs.CUBIC_IN,cubicOut:bs.CUBIC_OUT,cubicInOut:bs.CUBIC_IN_OUT,cubicOutIn:bs.CUBIC_OUT_IN,quartIn:bs.QUART_IN,quartOut:bs.QUART_OUT,quartInOut:bs.QUART_IN_OUT,quartOutIn:bs.QUART_OUT_IN,quintIn:bs.QUINT_IN,quintOut:bs.QUINT_OUT,quintInOut:bs.QUINT_IN_OUT,quintOutIn:bs.QUINT_OUT_IN,sineIn:bs.SINE_IN,sineOut:bs.SINE_OUT,sineInOut:bs.SINE_IN_OUT,sineOutIn:bs.SINE_OUT_IN,expoIn:bs.EXPO_IN,expoOut:bs.EXPO_OUT,expoInOut:bs.EXPO_IN_OUT,expoOutIn:bs.EXPO_OUT_IN,circIn:bs.CIRC_IN,circOut:bs.CIRC_OUT,circInOut:bs.CIRC_IN_OUT,circOutIn:bs.CIRC_OUT_IN,elasticIn:bs.ELASTIC_IN,elasticOut:bs.ELASTIC_OUT,elasticInOut:bs.ELASTIC_IN_OUT,elasticOutIn:bs.ELASTIC_OUT_IN,backIn:bs.BACK_IN,backOut:bs.BACK_OUT,backInOut:bs.BACK_IN_OUT,backOutIn:bs.BACK_OUT_IN,bounceIn:bs.BOUNCE_IN,bounceOut:bs.BOUNCE_OUT,bounceInOut:bs.BOUNCE_IN_OUT,bounceOutIn:bs.BOUNCE_OUT_IN,smooth:bs.SMOOTH,fade:bs.FADE};var Mx=Ki,Ix=en;function Bx(){throw new Error("split() only valid in Editor.")}Mx("cc.animation.ExoticAnimation")((rx=function(){function t(){this._nodeAnimations=sx&&sx()}var e=t.prototype;return e.createEvaluator=function(t){return new Vx(this._nodeAnimations,t)},e.addNodeAnimation=function(t){var e=new Px(t);return this._nodeAnimations.push(e),e},e.collectAnimatedJoints=function(){return Array.from(new Set(this._nodeAnimations.map((function(t){return t.path}))))},e.split=function(){return Bx()},e.toHashString=function(){return this._nodeAnimations.map((function(t){return t.toHashString()})).join("\n")},t}(),sx=tn(rx.prototype,"_nodeAnimations",[Ix],(function(){return[]})),rx));var Px=Mx("cc.animation.ExoticNodeAnimation")((ox=function(){function t(t){this._path=hx&&hx(),this._position=lx&&lx(),this._rotation=ux&&ux(),this._scale=cx&&cx(),this._path=t}var e=t.prototype;return e.createPosition=function(t,e){this._position=new kx(t,new Lx(e))},e.createRotation=function(t,e){this._rotation=new kx(t,new Nx(e))},e.createScale=function(t,e){this._scale=new kx(t,new Lx(e))},e.createEvaluator=function(t){return new Hx(this._path,this._position,this._rotation,this._scale,t)},e.split=function(){return Bx()},e.toHashString=function(){var t,e,i,n,r,s;return this._path+"\n"+(null!==(t=null===(e=this._position)||void 0===e?void 0:e.toHashString())&&void 0!==t?t:"")+(null!==(i=null===(n=this._scale)||void 0===n?void 0:n.toHashString())&&void 0!==i?i:"")+(null!==(r=null===(s=this._rotation)||void 0===s?void 0:s.toHashString())&&void 0!==r?r:"")},Pi(t,[{key:"path",get:function(){return this._path}}]),t}(),hx=tn(ox.prototype,"_path",[Ix],(function(){return""})),lx=tn(ox.prototype,"_position",[Ix],(function(){return null})),ux=tn(ox.prototype,"_rotation",[Ix],(function(){return null})),cx=tn(ox.prototype,"_scale",[Ix],(function(){return null})),ax=ox))||ax;function Dx(t){return t.toPrecision(2)}function Ox(t){return t.map(Dx).join(" ")}var Fx=Mx("cc.animation.ExoticVectorLikeTrackValues")((_x=function(){function t(t){this._values=fx&&fx(),this._isQuantized=px&&px(),this._values=t,this._isQuantized=!1}var e=t.prototype;return e.quantize=function(t){Ni(!this._isQuantized),this._values=function(t,e){var i=Xx[e],n=1<<i.BYTES_PER_ELEMENT,r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;t.forEach((function(t){r=Math.min(t,r),s=Math.max(t,s)}));var a=s-r,o=i.from(t,(function(t){return(t-r)/a*n}));return new aw(Wx(t),o,a,r)}(this._values,t),this._isQuantized=!0},e.toHashString=function(){var t=this._isQuantized,e=this._values;return t+" "+(t?e.toHashString():Ox(e))},Pi(t,[{key:"precision",get:function(){return this._isQuantized?this._values.originalPrecision:Wx(this._values)}}]),t}(),fx=tn(_x.prototype,"_values",[Ix],null),px=tn(_x.prototype,"_isQuantized",[Ix],null),dx=_x))||dx,Lx=Mx("cc.animation.ExoticVec3TrackValues")(gx=function(t){function e(){return t.apply(this,arguments)||this}He(e,t),e.imitate=function(t,i){var n=new e(t);return i._isQuantized&&n.quantize(i._values.quantizationType),n};var i=e.prototype;return i.get=function(t,e){var i=this._values;this._isQuantized?lw(i,t,e):ji.fromArray(e,i,3*t)},i.lerp=function(t,e,i,n,r,s){var a=this._values;this._isQuantized?(lw(a,t,n),lw(a,e,r)):(ji.fromArray(n,a,3*t),ji.fromArray(r,a,3*e)),ji.lerp(s,n,r,i)},e}(Fx))||gx,Nx=Mx("cc.animation.ExoticQuatTrackValues")(mx=function(t){function e(){return t.apply(this,arguments)||this}He(e,t),e.imitate=function(t,i){var n=new e(t);return i._isQuantized&&n.quantize(i._values.quantizationType),n};var i=e.prototype;return i.get=function(t,e){var i=this._values;this._isQuantized?uw(i,t,e):Ji.fromArray(e,i,4*t)},i.lerp=function(t,e,i,n,r,s){var a=this._values;this._isQuantized?(uw(a,t,n),uw(a,e,r)):(Ji.fromArray(n,a,4*t),Ji.fromArray(r,a,4*e)),Ji.slerp(s,n,r,i)},e}(Fx))||mx,kx=Mx("cc.animation.ExoticTrack")((yx=function(){function t(t,e){this.times=Tx&&Tx(),this.values=Sx&&Sx(),this.times=t,this.values=e}return t.prototype.toHashString=function(){var t=this.times,e=this.values;return"times: "+Ox(t)+"; values: "+e.toHashString()},t}(),Tx=tn(yx.prototype,"times",[Ix],null),Sx=tn(yx.prototype,"values",[Ix],null),vx=yx))||vx;function Ux(t,e){t.length,Ni(0!==t.length);var i=0,n=0,r=As(t,e);if(r>=0)i=r;else{var s=~r,a=s-1;i=a;var o=t[s],h=t[a];n=(e-h)/(o-h)}return{index:i,ratio:n}}!function(){function t(){this._reset()}var e=t.prototype;e.transformTime=function(t){return t-this._timeOffset},e.calculate=function(t,e,i){this._reset();var n=t.length;if(n){var r=t[0],s=t[n-1],a=Ge(e,r,s),o=Ge(i,r,s);this._timeOffset=a;var h=function(t,e,i){var n=t.length;Ni(i>=e&&e>=t[0]&&i<=t[n-1]);var r=Ux(t,e),s=r.index,a=r.ratio,o=Ux(t,i);return{fromIndex:s,fromRatio:a,toIndex:o.index,toRatio:o.ratio}}(t,a,o),l=h.fromIndex,u=h.fromRatio,c=h.toIndex,d=h.toRatio,_=!u,f=!d;l!==c||u!==d?(_||(this.preLerpIndex=l,this.preLerpRatio=u),this.directKeyframesBegin=_?l:l+1,this.directKeyframesEnd=c+1,f||(this.postLerpIndex=c,this.postLerpRatio=d)):_?(this.directKeyframesBegin=l,this.directKeyframesEnd=l+1):(this.preLerpIndex=l,this.preLerpRatio=u)}},e._reset=function(){this.preLerpIndex=-1,this.preLerpRatio=0,this.directKeyframesBegin=0,this.directKeyframesEnd=0,this.postLerpIndex=-1,this.postLerpRatio=0,this._timeOffset=0},Pi(t,[{key:"keyframesCount",get:function(){var t=this.preLerpIndex,e=this.directKeyframesBegin;return 0+(t<0?0:1)+(this.directKeyframesEnd-e)+(this.postLerpIndex<0?0:1)}}])}();var Gx,Vx=function(){function t(t,e){this._nodeEvaluations=void 0,this._nodeEvaluations=t.map((function(t){return t.createEvaluator(e)}))}return t.prototype.evaluate=function(t){this._nodeEvaluations.forEach((function(e){e.evaluate(t)}))},t}(),Hx=function(){function t(t,e,i,n,r){this._position=null,this._rotation=null,this._scale=null,e&&(this._position=hw(e.times,e.values,ji,t,"position",r)),i&&(this._rotation=hw(i.times,i.values,Ji,t,"rotation",r)),n&&(this._scale=hw(n.times,n.values,ji,t,"scale",r))}return t.prototype.evaluate=function(t){if(this._position){var e=this._position.evaluator.evaluate(t);this._position.runtimeBinding.setValue(e)}if(this._rotation){var i=this._rotation.evaluator.evaluate(t);this._rotation.runtimeBinding.setValue(i)}if(this._scale){var n=this._scale.evaluator.evaluate(t);this._scale.runtimeBinding.setValue(n)}},t}(),zx=function(){function t(t,e,i){this._times=void 0,this._inputSampleResultCache={just:!1,index:-1,nextIndex:-1,ratio:0},this._values=void 0,this._prevValue=void 0,this._nextValue=void 0,this._resultValue=void 0,this._times=t,this._values=e,this._prevValue=new i,this._nextValue=new i,this._resultValue=new i}return t.prototype.evaluate=function(t){var e=this._times,i=this._values,n=this._resultValue;if(0===e.length)return n;var r=function(t,e,i){var n=t.length,r=t[0],s=t[n-1];if(e<r)i.just=!0,i.index=0;else if(e>s)i.just=!0,i.index=n-1;else{var a=As(t,e);if(a>=0)i.just=!0,i.index=a;else{var o=~a,h=o-1,l=t[h],u=t[o],c=(e-t[h])/(u-l);i.just=!1,i.index=h,i.nextIndex=o,i.ratio=c}}return i}(e,t,this._inputSampleResultCache);return r.just?i.get(r.index,n):i.lerp(r.index,r.nextIndex,r.ratio,this._prevValue,this._nextValue,n),n},t}(),Xx={uint8:Uint8Array,uint16:Uint16Array};function Wx(t){switch(t.BYTES_PER_ELEMENT){default:case 4:return Gx.FLOAT_32;case 8:return Gx.FLOAT_64}}!function(t){t[t.FLOAT_32=0]="FLOAT_32",t[t.FLOAT_64=1]="FLOAT_64"}(Gx||(Gx={}));var Yx,jx,Kx,qx,Zx,Qx,Jx,$x,tw,ew,iw,nw,rw,sw,aw=Mx("cc.animation.QuantizedFloatArray")((Ax=function(){function t(t,e,i,n){void 0===n&&(n=0),this.originalPrecision=Cx&&Cx(),this.min=Rx&&Rx(),this.extent=bx&&bx(),this.values=xx&&xx(),this.originalPrecision=t,this.values=e,this.extent=i,this.min=n}return t.prototype.toHashString=function(){var t=this.originalPrecision,e=this.min,i=this.extent,n=this.values;return t+" "+Dx(e)+" "+Dx(i)+" "+n.join(" ")},Pi(t,[{key:"quantizationType",get:function(){switch(this.values.BYTES_PER_ELEMENT){default:case 1:return"uint8";case 2:return"uint16"}}}]),t}(),Cx=tn(Ax.prototype,"originalPrecision",[Ix],null),Rx=tn(Ax.prototype,"min",[Ix],null),bx=tn(Ax.prototype,"extent",[Ix],null),xx=tn(Ax.prototype,"values",[Ix],null),Ex=Ax))||Ex;function ow(t,e){return t.values[e]/(1<<t.values.BYTES_PER_ELEMENT)*t.extent+t.min}function hw(t,e,i,n,r,s){var a=new jR;a.path=(new YR).toHierarchy(n).toProperty(r);var o=s(a);return o?{runtimeBinding:o,evaluator:new zx(t,e,i)}:null}function lw(t,e,i){ji.set(i,ow(t,3*e+0),ow(t,3*e+1),ow(t,3*e+2))}function uw(t,e,i){Ji.set(i,ow(t,4*e+0),ow(t,4*e+1),ow(t,4*e+2),ow(t,4*e+3))}var cw=Symbol("SearchForRootBonePath"),dw=Symbol("ExoticAnimation"),_w=Symbol("[[EmbeddedPlayerCount]]"),fw=Symbol("[[GetEmbeddedPlayers]]"),pw=Symbol("[[AddEmbeddedPlayer]]"),gw=Symbol("[[RemoveEmbeddedPlayer]]"),mw=Symbol("[[ClearEmbeddedPlayers]]"),vw=t("AnimationClip",Ki("cc.AnimationClip")((sw=rw=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).sample=Kx&&Kx(),e.speed=qx&&qx(),e.wrapMode=Zx&&Zx(),e.enableTrsBlending=Qx&&Qx(),e._duration=Jx&&Jx(),e._hash=$x&&$x(),e.frameRate=0,e._tracks=tw&&tw(),e._exoticAnimation=ew&&ew(),e._legacyData=void 0,e._legacyDataDirty=!1,e._events=iw&&iw(),e._embeddedPlayers=nw&&nw(),e._runtimeEvents={ratios:[],eventGroups:[]},e}He(e,t),e.createWithSpriteFrames=function(t,i){var n=new e;n.sample=i||n.sample,n.duration=t.length/n.sample;var r=1/n.sample,s=new kb;return s.path=(new YR).toComponent("cc.Sprite").toProperty("spriteFrame"),s.channels()[0].curve.assignSorted(t.map((function(t,e){return[r*e,t]}))),n.addTrack(s),n};var i=e.prototype;return i.onLoaded=function(){this.frameRate=this.sample,this.events=this._events},i.range=function(){for(var t={min:1/0,max:-1/0},e=this._tracks,i=e.length,n=0;n<i;++n){var r=e[n].range();t.min=Math.min(t.min,r.min),t.max=Math.max(t.max,r.max)}return t},i.getTrack=function(t){return this._tracks[t]},i.addTrack=function(t){var e=this._tracks.length;return this._tracks.push(t),e},i.removeTrack=function(t){this._tracks.splice(t,1)},i.clearTracks=function(){this._tracks.length=0},i.containsAnyEvent=function(){return 0!==this._events.length},i.createEventEvaluator=function(t){return new xw(t,this._runtimeEvents.ratios,this._runtimeEvents.eventGroups,this.wrapMode)},i.containsAnyEmbeddedPlayer=function(){return 0!==this._embeddedPlayers.length},i.createEmbeddedPlayerEvaluator=function(t){return new yw(this._embeddedPlayers,t)},i.createEvaluator=function(t){var e=this,i=t.target;return this._createEvalWithBinder(i,(function(n){if(!t.mask||!n.isMaskedOff(t.mask)){var r=n.createRuntimeBinding(i,e.enableTrsBlending?t.pose:void 0,!1);return null!=r?r:void 0}}),t.rootMotion)},i.destroy=function(){var e;return null!==(e=We.director.root)&&void 0!==e&&e.dataPoolManager&&We.director.root.dataPoolManager.releaseAnimationClip(this),SE.destroy(this),t.prototype.destroy.call(this)},i[TE]=function(t,e,i){for(var n=1/e,r=this._collectAnimatedJoints(),s=r.length,a={},o=0;o<s;++o)a[r[o]]={transforms:Array.from({length:i},(function(){return new Ue}))};var h=r.reduce((function(t,e){return t[e]=new Ew,t}),{});for(var l in h){var u=h[l],c=l.lastIndexOf("/");if(c>=0){var d=l.substring(0,c),_=h[d];_&&(u.parent=_)}}for(var f=this._createEvalWithBinder(void 0,(function(t){var e=t.parseTrsPath();if(e){var i=h[e.node];if(i)return bw(i,e.property)}}),void 0),p=0;p<i;++p){var g=t+n*p;f.evaluate(g);for(var m=0;m<s;++m){var v=r[m];Ue.copy(a[v].transforms[p],h[v].globalTransform)}for(var y=0;y<s;++y){var T=r[y];h[T].invalidate()}}return{samples:e,frames:i,joints:a}},i.upgradeUntypedTracks=function(t){for(var e=[],i=[],n=this._tracks,r=n.length,s=0;s<r;++s){var a=n[s];if(a instanceof Jb){var o=a.upgrade(t);o&&(e.push(o),i.push(a))}}for(var h=i.length,l=0;l<h;++l)zr(n,i[l]);n.push.apply(n,e)},i[cw]=function(){return this._searchForRootBonePath()},i.getPropertyCurves=function(){return this._getLegacyData().getPropertyCurves()},i.updateEventDatas=function(){this.events=this._events},i.hasEvents=function(){return 0!==this.events.length},i.syncLegacyData=function(){this._legacyData&&(this._fromLegacy(this._legacyData),this._legacyData=void 0)},i[fw]=function(){return this._embeddedPlayers},i[pw]=function(t){this._embeddedPlayers.push(t)},i[gw]=function(t){var e=this._embeddedPlayers.indexOf(t);e>=0&&this._embeddedPlayers.splice(e,1)},i[mw]=function(){this._embeddedPlayers.length=0},i._createEvalWithBinder=function(t,e,i){this._legacyDataDirty&&(this._legacyDataDirty=!1,this.syncLegacyData());var n,r=[];i&&(n=this._createRootMotionEvaluation(t,i,r));for(var s,a=[],o=this._tracks,h=o.length,l=0;l<h;++l){var u=o[l];if(!r.includes(u)&&!Array.from(u.channels()).every((function(t){return 0===t.curve.keyFramesCount}))){var c=e(u[WR]);if(c){var d=u[OC](c);a.push({binding:c,trackEval:d})}}}return this._exoticAnimation&&(s=this._exoticAnimation.createEvaluator(e)),new Tw(a,s,n)},i._createRootMotionEvaluation=function(t,e,i){if(t instanceof Pr){var n=this._searchForRootBonePath();if(n){var r=t.getChildByPath(n);if(r){for(var s=new Sw,a=[],o=this._tracks,h=o.length,l=0;l<h;++l){var u=o[l],c=u[WR].parseTrsPath();if(c&&c.node===n){i.push(u);var d=bw(s,c.property);if(d){var _=u[OC](d);a.push({binding:d,trackEval:_})}}}return new Cw(r,this._duration,s,a)}Zi(3924)}else Zi(3923)}else hn(3920)},i._searchForRootBonePath=function(){var t=this._tracks.map((function(t){var e=t[WR].parseTrsPath();if(e){var i=e.node;return{path:i,rank:i.split("/").length}}return{path:"",rank:0}}));t.sort((function(t,e){return t.rank-e.rank}));var e=t.findIndex((function(t){return 0!==t.rank}));if(e<0)return"";for(var i=t.length,n=t[e],r=!0,s=e+1;s<i;++s){var a=t[s];if(a.rank!==n.rank)break;if(a.path!==n.path){r=!1;break}}return r?n.path:""},i._getLegacyData=function(){return this._legacyData||(this._legacyData=this._toLegacy()),this._legacyData},i._toLegacy=function(){var t=new $b(this._duration);return t.keys=[],t.curves=[],t.commonTargets=[],t},i._fromLegacy=function(t){for(var e=t.toTracks(),i=e.length,n=0;n<i;++n)this.addTrack(e[n])},i._collectAnimatedJoints=function(){for(var t=new Set,e=this._tracks,i=e.length,n=0;n<i;++n){var r=e[n][WR].parseTrsPath();r&&t.add(r.node)}if(this._exoticAnimation)for(var s=this._exoticAnimation.collectAnimatedJoints(),a=s.length,o=0;o<a;++o)t.add(s[o]);return Array.from(t)},Pi(e,[{key:"duration",get:function(){return this._duration},set:function(t){this._duration=t}},{key:"tracksCount",get:function(){return this._tracks.length}},{key:"tracks",get:function(){return this._tracks}},{key:"hash",get:function(){var t,e;if(this._hash)return this._hash;var i="Exotic:"+(null!==(t=null===(e=this._exoticAnimation)||void 0===e?void 0:e.toHashString())&&void 0!==t?t:"");return this._hash=nn(i,666)}},{key:"events",get:function(){return this._events},set:function(t){var e=this;this._events=t;for(var i=[],n=[],r=this.events.sort((function(t,e){return t.frame-e.frame})),s=r.length,a=function(t){var s=r[t],a=s.frame/e._duration,o=i.findIndex((function(t){return t===a}));o<0&&(o=i.length,i.push(a),n.push({events:[]})),n[o].events.push({functionName:s.func,parameters:s.params})},o=0;o<s;++o)a(o);this._runtimeEvents={ratios:i,eventGroups:n}}},{key:dw,get:function(){return this._exoticAnimation}},{key:dw,set:function(t){this._exoticAnimation=t}},{key:"keys",get:function(){return this._getLegacyData().keys}},{key:"keys",set:function(t){this._legacyDataDirty=!0,this._getLegacyData().keys=t}},{key:"curves",get:function(){return this._legacyDataDirty=!0,this._getLegacyData().curves}},{key:"curves",set:function(t){this._getLegacyData().curves=t}},{key:"commonTargets",get:function(){return this._getLegacyData().commonTargets}},{key:"commonTargets",set:function(t){this._legacyDataDirty=!0,this._getLegacyData().commonTargets=t}},{key:"data",get:function(){return this._getLegacyData().data}},{key:"eventGroups",get:function(){return this._runtimeEvents.eventGroups}},{key:_w,get:function(){return this._embeddedPlayers.length}}]),e}($i),rw.WrapMode=DC,Kx=tn((jx=sw).prototype,"sample",[en],(function(){return 60})),qx=tn(jx.prototype,"speed",[en],(function(){return 1})),Zx=tn(jx.prototype,"wrapMode",[en],(function(){return DC.Normal})),Qx=tn(jx.prototype,"enableTrsBlending",[en],(function(){return!1})),Jx=tn(jx.prototype,"_duration",[en],(function(){return 0})),$x=tn(jx.prototype,"_hash",[en],(function(){return 0})),tw=tn(jx.prototype,"_tracks",[en],(function(){return[]})),ew=tn(jx.prototype,"_exoticAnimation",[en],(function(){return null})),iw=tn(jx.prototype,"_events",[en],(function(){return[]})),nw=tn(jx.prototype,"_embeddedPlayers",[en],(function(){return[]})),Yx=jx))||Yx);We.AnimationClip=vw;var yw=function(){function t(t,e){this._embeddedPlayers=t,this._embeddedPlayerEvaluationInfos=t.map((function(t){var i=t.playable;if(!i)return null;var n=i.instantiate(e);return n?{instantiatedPlayer:n,entered:!1,hostPauseTime:0,lastIterations:0}:null}))}var e=t.prototype;return e.destroy=function(){for(var t=this._embeddedPlayerEvaluationInfos,e=t.length,i=0;i<e;++i){var n;null===(n=t[i])||void 0===n||n.instantiatedPlayer.destroy()}this._embeddedPlayerEvaluationInfos.length=0},e.evaluate=function(t,e){for(var i=this._embeddedPlayers,n=this._embeddedPlayerEvaluationInfos,r=i.length,s=0;s<r;++s){var a=n[s];if(a){var o=a.entered,h=a.instantiatedPlayer,l=a.lastIterations,u=i[s],c=u.begin,d=u.end;if(t>=c&&t<=d?o?e!==l&&(h.stop(),h.play(),a.entered=!0):(h.play(),a.entered=!0):o&&(h.stop(),a.entered=!1),a.lastIterations=e,a.entered){var _=t-c;a.instantiatedPlayer.setTime(_)}}}},e.notifyHostSpeedChanged=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r<n;++r){var s=i[r];if(s){var a=s.instantiatedPlayer;e[r].reconciledSpeed&&a.setSpeed(t)}}},e.notifyHostPlay=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r<n;++r){var s=i[r];if(s){var a=e[r],o=a.begin,h=a.end,l=s.instantiatedPlayer;if(s.entered){var u=s.hostPauseTime;if(l.randomAccess||wn(u,t,1e-5)){var c=Ge(t,o,h);l.play(),l.setTime(c-o)}else l.stop()}}}},e.notifyHostPause=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r<n;++r){var s=i[r];if(s){var a=s.instantiatedPlayer;s.entered&&(a.pause(),s.hostPauseTime=t)}}},e.notifyHostStop=function(){for(var t=this._embeddedPlayers,e=this._embeddedPlayerEvaluationInfos,i=t.length,n=0;n<i;++n){var r=e[n];if(r){var s=r.instantiatedPlayer;r.entered&&(r.entered=!1,s.stop())}}},t}(),Tw=function(){function t(t,e,i){this._exoticAnimationEvaluator=void 0,this._trackEvalStatues=[],this._rootMotionEvaluation=void 0,this._trackEvalStatues=t,this._exoticAnimationEvaluator=e,this._rootMotionEvaluation=i}var e=t.prototype;return e.evaluate=function(t){for(var e=this._trackEvalStatues,i=this._exoticAnimationEvaluator,n=e.length,r=0;r<n;++r){var s=e[r],a=s.trackEval,o=s.binding,h=a.evaluate(t,o);o.setValue(h)}i&&i.evaluate(t)},e.evaluateRootMotion=function(t,e){var i=this._rootMotionEvaluation;i&&i.evaluate(t,e)},t}(),Sw=function(){function t(){this.position=new ji,this.scale=new ji(1,1,1),this.rotation=new Ji,this.eulerAngles=new ji}return t.prototype.getTransform=function(t){Ue.fromRTS(t,this.rotation,this.position,this.scale)},t}(),Ew=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).parent=null,e._dirty=!0,e._transform=new Ue,e}return He(e,t),e.prototype.invalidate=function(){this._dirty=!0},Pi(e,[{key:"globalTransform",get:function(){var t=this._transform;return this._dirty&&(this._dirty=!1,Ue.fromRTS(t,this.rotation,this.position,this.scale),this.parent&&Ue.multiply(t,this.parent.globalTransform,t)),this._transform}}]),e}(Sw),Aw=new Ue,Cw=function(){function t(t,e,i,n){this._initialTransformCache=new Ue,this._clipEndTransformCache=new Ue,this._startTransformCache=new Ue,this._endTransformCache=new Ue,this._motionTransformCache=new Ue,this._translationMotionCache=new ji,this._rotationMotionCache=new Ji,this._scaleMotionCache=new ji,this._rootBone=t,this._duration=e,this._boneTransform=i,this._trackEvalStatuses=n}var e=t.prototype;return e.evaluate=function(t,e){var i=this._calcMotionTransform(t,e,this._motionTransformCache),n=this._translationMotionCache,r=this._rotationMotionCache,s=this._scaleMotionCache,a=this._rootBone;Ue.toRTS(i,r,n,s),ji.add(n,n,a.position),a.setPosition(n),Ji.multiply(r,r,a.rotation),a.setRotation(r),ji.multiply(s,s,a.scale),a.setScale(s)},e._calcMotionTransform=function(t,e,i){var n=this._duration,r=n-t,s=this._evaluateAt(t,this._startTransformCache);if(e<r){var a=this._evaluateAt(t+e,this._endTransformCache);Rw(i,s,a)}else{Ue.identity(i);var o=function(t,e){Rw(Aw,t,e),Ue.multiply(i,i,Aw)},h=e-r,l=Math.floor(h/n),u=h-l*n,c=this._evaluateAt(0,this._initialTransformCache),d=this._evaluateAt(n,this._clipEndTransformCache),_=this._evaluateAt(u,this._endTransformCache);o(s,d),Rw(Aw,c,d);for(var f=0;f<l;++f)Ue.multiply(i,i,Aw);o(c,_)}return i},e._evaluateAt=function(t,e){for(var i=this._trackEvalStatuses,n=i.length,r=0;r<n;++r){var s=i[r],a=s.trackEval,o=s.binding,h=a.evaluate(t,o);o.setValue(h)}return this._boneTransform.getTransform(e),e},t}();function Rw(t,e,i){Ue.invert(t,e),Ue.multiply(t,i,t)}function bw(t,e){switch(e){default:return;case"position":return{setValue:function(e){ji.copy(t.position,e)}};case"rotation":return{setValue:function(e){Ji.copy(t.rotation,e)}};case"scale":return{setValue:function(e){ji.copy(t.scale,e)}};case"eulerAngles":return{setValue:function(e){ji.copy(t.eulerAngles,e)}}}}var xw=function(){function t(t,e,i,n){this._lastFrameIndex=-1,this._lastIterations=0,this._lastDirection=0,this._ignoreIndex=-1,this._sampled=!1,this._targetNode=t,this._ratios=e,this._eventGroups=i,this._wrapMode=n}var e=t.prototype;return e.setWrapMode=function(t){this._wrapMode=t},e.ignore=function(t,e){this._ignoreIndex=-1,this._sampled=!1;var i=Mw(t,this._ratios);i<0&&(i=~i-1,e<0&&(i+=1),this._ignoreIndex=i)},e.sample=function(t,e,i){var n=this._eventGroups.length,r=Mw(t,this._ratios);if(r<0&&(r=~r-1,e<0&&(r+=1)),this._ignoreIndex!==r&&(this._ignoreIndex=-1),!this._sampled)return this._sampled=!0,this._doFire(r,!1),this._lastFrameIndex=r,this._lastIterations=i,void(this._lastDirection=e);var s=this._wrapMode,a=ww(i),o=ww(this._lastIterations),h=this._lastFrameIndex,l=this._lastDirection,u=-1!==o&&a!==o;if(h===r&&u&&1===n)this._doFire(0,!1);else if(h!==r||u){e=l;do{if(h!==r){if(-1===e&&0===h&&r>0?((s&ds.PingPong)===ds.PingPong?e*=-1:h=n,o++):1===e&&h===n-1&&r<n-1&&((s&ds.PingPong)===ds.PingPong?e*=-1:h=-1,o++),h===r)break;if(o>a)break}h+=e,this._doFire(h,!0)}while(h!==r&&h>-1&&h<n)}this._lastFrameIndex=r,this._lastIterations=i,this._lastDirection=e},e._doFire=function(t,e){e?VC().pushDelayEvent(this._checkAndFire,this,[t]):this._checkAndFire(t)},e._checkAndFire=function(t){if(this._targetNode&&this._targetNode.isValid){var e=this._eventGroups;if(!(t<0||t>=e.length||this._ignoreIndex===t))for(var i=e[t],n=this._targetNode.components,r=i.events.length,s=0;s<r;++s)for(var a=i.events[s],o=a.functionName,h=n.length,l=0;l<h;++l){var u=n[l],c=u[o];"function"==typeof c&&c.apply(u,a.parameters)}}},t}();function ww(t){return t-(0|t)==0&&(t-=1),0|t}function Mw(t,e){return As(e,t)}var Iw,Bw=function(){function t(){this._nodeBlendStates=new Map}var e=t.prototype;return e.createWriter=function(t,e,i,n){var r=this.ref(t,e);return new Pw(t,e,r,i,n)},e.destroyWriter=function(t){var e=t;this.deRef(e.node,e.property)},e.ref=function(t,e){var i=this._nodeBlendStates.get(t);return i||(i=this.createNodeBlendState(),this._nodeBlendStates.set(t,i)),i.refProperty(t,e)},e.deRef=function(t,e){var i=this._nodeBlendStates.get(t);i&&(i.deRefProperty(e),i.empty&&this._nodeBlendStates.delete(t))},e.apply=function(){this._nodeBlendStates.forEach((function(t,e){t.apply(e)}))},t}(),Pw=function(){function t(t,e,i,n,r){this._node=t,this._property=e,this._propertyBlendState=i,this._host=n,this._constants=r}var e=t.prototype;return e.getValue=function(){return this._node[this._property]},e.setValue=function(t){var e=this._propertyBlendState,i=this._host.weight;e.blend(t,i)},Pi(t,[{key:"node",get:function(){return this._node}},{key:"property",get:function(){return this._property}}]),t}();!function(t){t[t.POSITION=1]="POSITION",t[t.ROTATION=2]="ROTATION",t[t.SCALE=4]="SCALE",t[t.EULER_ANGLES=8]="EULER_ANGLES"}(Iw||(Iw={}));var Dw,Ow,Fw,Lw=Iw.POSITION|Iw.ROTATION|Iw.SCALE|Iw.EULER_ANGLES,Nw=function(){function t(){this.refCount=0,this.accumulatedWeight=0,this.result=new ji}var e=t.prototype;return e.blend=function(t,e){this.accumulatedWeight=Ww(this.result,this.result,this.accumulatedWeight,t,e)},e.reset=function(){this.accumulatedWeight=0,ji.zero(this.result)},t}(),kw=function(){function t(){this.refCount=0,this.accumulatedWeight=0,this.result=new Ji}var e=t.prototype;return e.blend=function(t,e){this.accumulatedWeight=Yw(this.result,this.result,this.accumulatedWeight,t,e)},e.reset=function(){this.accumulatedWeight=0,Ji.identity(this.result)},t}(),Uw=function(){function t(){this._transformApplyFlags=0,this._properties={}}var e=t.prototype;return e.refProperty=function(t,e){var i,n,r,s=this._properties;switch(e){default:case"position":case"scale":case"eulerAngles":r=null!==(i=s[e])&&void 0!==i?i:s[e]=this._createVec3BlendState(t[e]);break;case"rotation":r=null!==(n=s[e])&&void 0!==n?n:s[e]=this._createQuatBlendState(t.rotation)}return++r.refCount,r},e.deRefProperty=function(t){var e=this._properties,i=e[t];i&&(--i.refCount,i.refCount>0||delete e[t])},e.apply=function(t){var e,i,n,r=this._transformApplyFlags,s=this._properties,a=s.position,o=s.scale,h=s.rotation,l=s.eulerAngles;r&&(a&&r&Iw.POSITION&&(e=a.result),o&&r&Iw.SCALE&&(i=o.result),l&&r&Iw.EULER_ANGLES&&(n=l.result),h&&r&Iw.ROTATION&&(n=h.result),(n||e||i)&&t.setRTS(n,e,i),this._transformApplyFlags=0)},Pi(t,[{key:"empty",get:function(){var t=this._properties;return!(t.position||t.rotation||t.eulerAngles||t.scale)}}]),t}(),Gw=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.apply=function(e){var i=this._properties,n=i.position,r=i.scale,s=i.rotation,a=i.eulerAngles;n&&n.accumulatedWeight&&(this._transformApplyFlags|=Iw.POSITION,n.accumulatedWeight<1&&n.blend(e.position,1-n.accumulatedWeight)),r&&r.accumulatedWeight&&(this._transformApplyFlags|=Iw.SCALE,r.accumulatedWeight<1&&r.blend(e.scale,1-r.accumulatedWeight)),a&&a.accumulatedWeight&&(this._transformApplyFlags|=Iw.EULER_ANGLES,a.accumulatedWeight<1&&a.blend(e.eulerAngles,1-a.accumulatedWeight)),s&&s.accumulatedWeight&&(this._transformApplyFlags|=Iw.ROTATION,s.accumulatedWeight<1&&s.blend(e.rotation,1-s.accumulatedWeight)),t.prototype.apply.call(this,e),null==n||n.reset(),null==r||r.reset(),null==s||s.reset(),null==a||a.reset()},i._createVec3BlendState=function(){return new Nw},i._createQuatBlendState=function(){return new kw},e}(Uw),Vw=function(t){function e(){return t.apply(this,arguments)||this}return He(e,t),e.prototype.createNodeBlendState=function(){return new Gw},e}(Bw),Hw=function(){function t(t){this.refCount=0,this.result=new ji,this._defaultValue=new ji,this._clipBlendResult=new ji,this._accumulatedWeight=0,ji.copy(this._defaultValue,t),ji.copy(this.result,t)}var e=t.prototype;return e.blend=function(t,e){this._accumulatedWeight=Ww(this._clipBlendResult,this._clipBlendResult,this._accumulatedWeight,t,e)},e.commitLayerChange=function(t){var e=this.result,i=this._clipBlendResult,n=this._accumulatedWeight;n<1&&this.blend(this._defaultValue,1-n),ji.lerp(e,e,i,t),ji.zero(this._clipBlendResult),this._accumulatedWeight=0},e.reset=function(){ji.copy(this.result,this._defaultValue)},t}(),zw=function(){function t(t){this.refCount=0,this.result=new Ji,this._defaultValue=new Ji,this._clipBlendResult=new Ji,this._accumulatedWeight=0,Ji.copy(this._defaultValue,t),Ji.copy(this.result,t)}var e=t.prototype;return e.blend=function(t,e){this._accumulatedWeight=Yw(this._clipBlendResult,this._clipBlendResult,this._accumulatedWeight,t,e)},e.commitLayerChange=function(t){var e=this.result,i=this._clipBlendResult,n=this._accumulatedWeight;n<1&&this.blend(this._defaultValue,1-n),Ji.slerp(e,e,i,t),Ji.identity(this._clipBlendResult),this._accumulatedWeight=0},e.reset=function(){Ji.copy(this.result,this._defaultValue)},t}(),Xw=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._layerMask=-1>>>0,e}He(e,t);var i=e.prototype;return i.setLayerMask=function(t){this._layerMask&=~(1<<t)},i.commitLayerChanges=function(t,e){if(this._layerMask&1<<t){var i=this._properties,n=i.position,r=i.scale,s=i.rotation,a=i.eulerAngles;n&&n.commitLayerChange(e),r&&r.commitLayerChange(e),s&&s.commitLayerChange(e),a&&a.commitLayerChange(e)}},i.apply=function(e){this._transformApplyFlags=Lw,t.prototype.apply.call(this,e);var i=this._properties,n=i.position,r=i.scale,s=i.rotation,a=i.eulerAngles;null==n||n.reset(),null==r||r.reset(),null==s||s.reset(),null==a||a.reset()},i._createVec3BlendState=function(t){return new Hw(t)},i._createQuatBlendState=function(t){return new zw(t)},e}(Uw);function Ww(t,e,i,n,r){var s=i+r;if(1!==r||i){if(s){var a=r/s;ji.lerp(t,t,n,a)}}else ji.copy(t,n);return s}function Yw(t,e,i,n,r){var s=i+r;if(1!==r||i){if(s){var a=r/s;Ji.slerp(t,e,n,a)}}else Ji.copy(t,n);return s}!function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;i.setMask=function(t,e){this._nodeBlendStates.forEach((function(i,n){e.has(n)&&i.setLayerMask(t)}))},i.commitLayerChanges=function(t,e){this._nodeBlendStates.forEach((function(i){i.commitLayerChanges(t,e)}))},i.createNodeBlendState=function(){return new Xw}}(Bw);var jw=t("AnimationManager",Ki((Fw=Ow=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._anims=new Is([]),e._crossFades=new Is([]),e._delayEvents=[],e._blendStateBuffer=new Vw,e._sockets=[],e}He(e,t);var i=e.prototype;return i.addCrossFade=function(t){-1===this._crossFades.array.indexOf(t)&&this._crossFades.push(t)},i.removeCrossFade=function(t){var e=this._crossFades.array.indexOf(t);e>=0?this._crossFades.fastRemoveAt(e):hn(3907)},i.update=function(t){var e=this._delayEvents,i=this._crossFades,n=this._sockets,r=i.array;for(i.i=0;i.i<r.length;++i.i)r[i.i].update(t);var s=this._anims,a=s.array;for(s.i=0;s.i<a.length;++s.i){var o=a[s.i];o.isMotionless||o.update(t)}this._blendStateBuffer.apply();for(var h=Di.getTotalFrames(),l=0,u=n.length;l<u;l++){var c=n[l],d=c.target,_=c.transform;d.matrix=NE(_,h)}for(var f=0,p=e.length;f<p;f++){var g=e[f];g.fn.apply(g.thisArg,g.args)}e.length=0},i.destruct=function(){},i.addAnimation=function(t){-1===this._anims.array.indexOf(t)&&this._anims.push(t)},i.removeAnimation=function(t){var e=this._anims.array.indexOf(t);e>=0?this._anims.fastRemoveAt(e):hn(3907)},i.pushDelayEvent=function(t,e,i){this._delayEvents.push({fn:t,thisArg:e,args:i})},i.addSockets=function(t,e){for(var i=this,n=function(n){var r=e[n];if(i._sockets.find((function(t){return t.target===r.target})))return"continue";var s=t.getChildByPath(r.path),a=r.target&&s&&kE(s,t);a&&i._sockets.push({target:r.target,transform:a})},r=0;r<e.length;++r)n(r)},i.removeSockets=function(t,e){for(var i=0;i<e.length;++i)for(var n=e[i],r=0;r<this._sockets.length;++r){var s=this._sockets[r];if(s.target===n.target){UE(s.transform.node),this._sockets[r]=this._sockets[this._sockets.length-1],this._sockets.length--;break}}},Pi(e,[{key:"blendState",get:function(){return this._blendStateBuffer}}]),e}(Oi),Ow.ID="animation",Dw=Fw))||Dw);Di.on(An.EVENT_INIT,(function(){var t=new jw;Di.registerSystem(jw.ID,t,Oi.Priority.HIGH)})),We.AnimationManager=jw;var Kw,qw,Zw,Qw,Jw,$w,tM,eM,iM,nM,rM,sM,aM,oM,hM,lM=function(t){function e(e){var i;return(i=t.call(this)||this)._managedStates=[],i._fadings=[],i._scheduled=!1,i._scheduler=null!=e?e:VC(),i}He(e,t);var i=e.prototype;return i.update=function(t){if(!this.isMotionless){var e=this._managedStates,i=this._fadings;if(1===e.length&&1===i.length){var n=e[0].state;n&&(n.weight=1)}else this._calculateWeights(t);1===e.length&&1===i.length&&this._unscheduleThis()}},i.crossFade=function(t,e){var i;0===this._managedStates.length&&(e=0),0===e&&this.clear();var n=this._managedStates.find((function(e){return e.state===t}));n?null!==(i=n.state)&&void 0!==i&&i.isMotionless&&n.state.play():(n={state:t,reference:0},t&&t.play(),this._managedStates.push(n)),++n.reference,this._fadings.unshift({easeDuration:e,easeTime:0,target:n}),this.isMotionless||this._scheduleThis()},i.clear=function(){for(var t=0;t<this._managedStates.length;++t){var e=this._managedStates[t].state;e&&e.stop()}this._managedStates.length=0,this._fadings.length=0},i.onPlay=function(){t.prototype.onPlay.call(this),this._scheduleThis()},i.onPause=function(){t.prototype.onPause.call(this);for(var e=0;e<this._managedStates.length;++e){var i=this._managedStates[e].state;i&&i.pause()}this._unscheduleThis()},i.onResume=function(){t.prototype.onResume.call(this);for(var e=0;e<this._managedStates.length;++e){var i=this._managedStates[e].state;i&&i.resume()}this._scheduleThis()},i.onStop=function(){t.prototype.onStop.call(this),this.clear()},i._calculateWeights=function(t){for(var e=this._managedStates,i=this._fadings,n=0;n<e.length;++n){var r=e[n].state;r&&(r.weight=0)}for(var s=1,a=i.length,o=0;o<i.length;++o){var h=i[o];h.easeTime+=t;var l=0===h.easeDuration?1:Bs(h.easeTime/h.easeDuration),u=l*s;if(s*=1-l,h.target.state&&(h.target.state.weight+=u),h.easeTime>=h.easeDuration){a=o+1,h.easeTime=h.easeDuration;break}}if(a!==i.length){for(var c=a;c<i.length;++c){var d=i[c];--d.target.reference,d.target.reference<=0&&(d.target.state&&d.target.state.stop(),zr(this._managedStates,d.target))}i.splice(a)}},i._scheduleThis=function(){this._scheduled||(this._scheduler.addCrossFade(this),this._scheduled=!0)},i._unscheduleThis=function(){this._scheduled&&(this._scheduler.removeCrossFade(this),this._scheduled=!1)},e}(NC),uM=function(e){return t({Animation:e,AnimationComponent:e}),e}((Kw=Ki("cc.Animation"),qw=In(99),Zw=Tn([vw]),Qw=Tn(vw),Jw=Tn([vw]),Kw($w=qw((sM=rM=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).playOnLoad=eM&&eM(),e._crossFade=new lM,e._nameToState=fn(!0),e._clips=iM&&iM(),e._defaultClip=nM&&nM(),e._hasBeenPlayed=!1,e}He(e,t);var i=e.prototype;return i.onLoad=function(){for(var t in this.clips=this._clips,this._nameToState)this._nameToState[t].initialize(this.node)},i.start=function(){this.playOnLoad&&!this._hasBeenPlayed&&this._defaultClip&&this.crossFade(this._defaultClip.name,0)},i.onEnable=function(){this._crossFade.resume()},i.onDisable=function(){this._crossFade.pause()},i.onDestroy=function(){for(var t in this._crossFade.stop(),this._nameToState)this._nameToState[t].destroy();this._nameToState=fn(!0)},i.play=function(t){if(this._hasBeenPlayed=!0,!t){if(!this._defaultClip)return;t=this._defaultClip.name}this.crossFade(t,0)},i.crossFade=function(t,e){void 0===e&&(e=.3),this._hasBeenPlayed=!0;var i=this._nameToState[t];i&&this.doPlayOrCrossFade(i,e)},i.pause=function(){this._crossFade.pause()},i.resume=function(){this._crossFade.resume()},i.stop=function(){this._crossFade.stop()},i.getState=function(t){var e=this._nameToState[t];return e&&!e.curveLoaded&&e.initialize(this.node),e||null},i.createState=function(t,e){return e=e||t.name,this.removeState(e),this._doCreateState(t,e)},i.removeState=function(t){var e=this._nameToState[t];e&&(e.allowLastFrameEvent(!1),e.stop(),delete this._nameToState[t])},i.addClip=function(t,e){return Ps(this._clips,t)&&this._clips.push(t),this.createState(t,e)},i.removeClip=function(t,e){var i;for(var n in this._nameToState){var r=this._nameToState[n];if(r.clip===t){i=r;break}}if(t===this._defaultClip){if(!e)return void Zi(3902);this._defaultClip=null}if(i&&i.isPlaying){if(!e)return void Zi(3903);i.stop()}this._clips=this._clips.filter((function(e){return e!==t})),i&&delete this._nameToState[i.name]},i.on=function(e,i,n,r){var s=t.prototype.on.call(this,e,i,n,r);return e===kC.LASTFRAME&&this._syncAllowLastFrameEvent(),s},i.once=function(e,i,n){var r=t.prototype.once.call(this,e,i,n);return e===kC.LASTFRAME&&this._syncAllowLastFrameEvent(),r},i.off=function(e,i,n){t.prototype.off.call(this,e,i,n),e===kC.LASTFRAME&&this._syncDisallowLastFrameEvent()},i._createState=function(t,e){return new WC(t,e)},i._doCreateState=function(t,e){var i=this._createState(t,e);return i._setEventTarget(this),i.allowLastFrameEvent(this.hasEventListener(kC.LASTFRAME)),this.node&&i.initialize(this.node),this._nameToState[i.name]=i,i},i.doPlayOrCrossFade=function(t,e){this._crossFade.play(),this._crossFade.crossFade(t,e)},i._removeStateOfAutomaticClip=function(t){for(var e in this._nameToState){var i=this._nameToState[e];cM(t,i.clip)&&(i.stop(),delete this._nameToState[e])}},i._syncAllowLastFrameEvent=function(){if(this.hasEventListener(kC.LASTFRAME))for(var t in this._nameToState)this._nameToState[t].allowLastFrameEvent(!0)},i._syncDisallowLastFrameEvent=function(){if(!this.hasEventListener(kC.LASTFRAME))for(var t in this._nameToState)this._nameToState[t].allowLastFrameEvent(!1)},Pi(e,[{key:"clips",get:function(){return this._clips},set:function(t){var e=this;this._crossFade&&this._crossFade.clear();for(var i,n=Fi(this._clips);!(i=n()).done;){var r=i.value;r&&this._removeStateOfAutomaticClip(r)}for(var s,a=Fi(t);!(s=a()).done;){var o=s.value;o&&this.createState(o)}var h=t.find((function(t){return cM(t,e._defaultClip)}));this._defaultClip=h||null,this._clips=t}},{key:"defaultClip",get:function(){return this._defaultClip},set:function(t){this._defaultClip=t,t&&(this._clips.findIndex((function(e){return cM(e,t)}))>=0||(this._clips.push(t),this.createState(t)))}}]),e}(Cr(Pn)),rM.EventType=kC,gn((tM=sM).prototype,"clips",[Zw],Object.getOwnPropertyDescriptor(tM.prototype,"clips"),tM.prototype),gn(tM.prototype,"defaultClip",[Qw],Object.getOwnPropertyDescriptor(tM.prototype,"defaultClip"),tM.prototype),eM=tn(tM.prototype,"playOnLoad",[en],(function(){return!1})),iM=tn(tM.prototype,"_clips",[Jw],(function(){return[]})),nM=tn(tM.prototype,"_defaultClip",[en],(function(){return null})),$w=tM))||$w)||$w));function cM(t,e){return t===e||!!t&&!!e&&t._uuid===e._uuid&&t._uuid}We.Animation=uM,We.AnimationComponent=uM,br(uM,"cc.AnimationComponent"),function(t){t.PLAYED="play",t.PAUSED="pause",t.STOPPED="stop",t.SEEKED="seeked",t.ENDED="ended",t.INTERRUPTION_BEGIN="interruptionBegin",t.INTERRUPTION_END="interruptionEnd",t.USER_GESTURE="on_gesture"}(aM||(aM={})),function(t){t[t.DOM_AUDIO=0]="DOM_AUDIO",t[t.WEB_AUDIO=1]="WEB_AUDIO",t[t.MINIGAME_AUDIO=2]="MINIGAME_AUDIO",t[t.NATIVE_AUDIO=3]="NATIVE_AUDIO",t[t.UNKNOWN_AUDIO=4]="UNKNOWN_AUDIO"}(oM||(oM={})),function(t){t[t.INIT=0]="INIT",t[t.PLAYING=1]="PLAYING",t[t.PAUSED=2]="PAUSED",t[t.STOPPED=3]="STOPPED",t[t.INTERRUPTED=4]="INTERRUPTED"}(hM||(hM={}));var dM,_M=t("AudioPCMDataView",function(){function t(){if(this._bufferView=void 0,this._normalizeFactor=1,2===arguments.length)this._bufferView=arguments.length<=0?void 0:arguments[0],this._normalizeFactor=arguments.length<=1?void 0:arguments[1];else{var t=arguments.length<=0?void 0:arguments[0],e=arguments.length<=1?void 0:arguments[1],i=arguments.length<=2?void 0:arguments[2];this._bufferView=new e(t),this._normalizeFactor=i}}return t.prototype.getData=function(t){return this._bufferView[t]*this._normalizeFactor},Pi(t,[{key:"length",get:function(){return this._bufferView.length}}]),t}()),fM=0;function pM(t,e){var i;e.invoking||(e.invoking=!0,(i=e.func).call.apply(i,[t].concat(e.args)).then((function(){e.invoking=!1,t._operationQueue.shift(),t._eventTarget.emit(e.id.toString());var i=t._operationQueue[0];i&&pM(t,i)})).catch((function(){})))}function gM(t,e,i){var n=i.value;i.value=function(){for(var t=this,e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];return new Promise((function(e){var r=fM++,s=t;s._operationQueue.push({id:r,func:n,args:i,invoking:!1}),s._eventTarget.once(r.toString(),e),pM(s,s._operationQueue[0])}))}}function mM(t){return new Promise((function(e){var i=t.play();return void 0===i?e():(i.then(e).catch((function(){var i=function i(){t.play().then((function(){null==n||n.removeEventListener("touchend",i,{capture:!0}),null==n||n.removeEventListener("mouseup",i,{capture:!0})})).catch((function(){})),e()},n=document.getElementById("GameCanvas");null==n||n.addEventListener("touchend",i,{capture:!0}),null==n||n.addEventListener("mouseup",i,{capture:!0})})),null)}))}var vM,yM,TM=function(){function t(t,e){this._domAudio=void 0,this._onPlayCb=void 0,this._onEndCb=void 0,this._domAudio=t,t.volume=e}var e=t.prototype;return e.play=function(){var t=this;mM(this._domAudio).then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t)})).catch((function(){}))},e.stop=function(){this._domAudio.pause()},Pi(t,[{key:"onPlay",get:function(){return this._onPlayCb},set:function(t){this._onPlayCb=t}},{key:"onEnd",get:function(){return this._onEndCb},set:function(t){this._onEndCb&&this._domAudio.removeEventListener("ended",this._onEndCb),this._onEndCb=t,t&&this._domAudio.addEventListener("ended",t)}}]),t}(),SM=(dM=function(){function t(t){var e=this;this._domAudio=void 0,this._state=hM.INIT,this._onEnded=void 0,this._eventTarget=new es,this._operationQueue=[],this._domAudio=t,qr.on(Zr.EVENT_PAUSE,this._onInterruptedBegin,this),qr.on(Zr.EVENT_RESUME,this._onInterruptedEnd,this),this._onEnded=function(){e.seek(0).catch((function(){})),e._state=hM.INIT,e._eventTarget.emit(aM.ENDED)},this._domAudio.addEventListener("ended",this._onEnded)}var e=t.prototype;return e.destroy=function(){qr.off(Zr.EVENT_PAUSE,this._onInterruptedBegin,this),qr.off(Zr.EVENT_RESUME,this._onInterruptedEnd,this),this._domAudio.removeEventListener("ended",this._onEnded),this._domAudio=null},t.load=function(e){return new Promise((function(i){t.loadNative(e).then((function(e){i(new t(e))})).catch((function(){}))}))},t.loadNative=function(t){return new Promise((function(e,i){var n=document.createElement("audio"),r="canplaythrough";Ds.os===Os.IOS?r="loadedmetadata":Ds.browserType===Fs.FIREFOX&&(r="canplay");var s=setTimeout((function(){0===n.readyState?h():o()}),8e3),a=function(){clearTimeout(s),n.removeEventListener(r,o,!1),n.removeEventListener("error",h,!1)},o=function(){a(),e(n)},h=function(){a(),i("load audio failure - "+t)};n.addEventListener(r,o,!1),n.addEventListener("error",h,!1),n.src=t}))},t.loadOneShotAudio=function(e,i){return new Promise((function(n,r){t.loadNative(e).then((function(t){var e=new TM(t,i);n(e)})).catch(r)}))},e._onInterruptedBegin=function(){var t=this;this._state===hM.PLAYING&&this.pause().then((function(){t._state=hM.INTERRUPTED,t._eventTarget.emit(aM.INTERRUPTION_BEGIN)})).catch((function(){}))},e._onInterruptedEnd=function(){var t=this;this._state===hM.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit(aM.INTERRUPTION_END)})).catch((function(){}))},e.getPCMData=function(){},e.seek=function(t){return t=Ge(t,0,this.duration),this._domAudio.currentTime=t,Promise.resolve()},e.play=function(){var t=this;return new Promise((function(e){mM(t._domAudio).then((function(){t._state=hM.PLAYING,e()})).catch((function(){}))}))},e.pause=function(){return this._domAudio.pause(),this._state=hM.PAUSED,Promise.resolve()},e.stop=function(){var t=this;return new Promise((function(e){t._domAudio.pause(),t._domAudio.currentTime=0,t._state=hM.STOPPED,e()}))},e.onInterruptionBegin=function(t){this._eventTarget.on(aM.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off(aM.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on(aM.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off(aM.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on(aM.ENDED,t)},e.offEnded=function(t){this._eventTarget.off(aM.ENDED,t)},Pi(t,[{key:"src",get:function(){return this._domAudio?this._domAudio.src:""}},{key:"type",get:function(){return oM.DOM_AUDIO}},{key:"state",get:function(){return this._state}},{key:"loop",get:function(){return this._domAudio.loop},set:function(t){this._domAudio.loop=t}},{key:"volume",get:function(){return this._domAudio.volume},set:function(t){t=Bs(t),this._domAudio.volume=t}},{key:"duration",get:function(){return this._domAudio.duration}},{key:"currentTime",get:function(){return this._domAudio.currentTime}},{key:"sampleRate",get:function(){return 0}}]),t}(),gn(dM.prototype,"seek",[gM],Object.getOwnPropertyDescriptor(dM.prototype,"seek"),dM.prototype),gn(dM.prototype,"play",[gM],Object.getOwnPropertyDescriptor(dM.prototype,"play"),dM.prototype),gn(dM.prototype,"pause",[gM],Object.getOwnPropertyDescriptor(dM.prototype,"pause"),dM.prototype),gn(dM.prototype,"stop",[gM],Object.getOwnPropertyDescriptor(dM.prototype,"stop"),dM.prototype),dM),EM=function(){function t(t){this._nativeAudio=void 0,this._startTime=0,this._startOffset=0,this._isPaused=!0,this._nativeAudio=t}var e=t.prototype;return e.destroy=function(){this._nativeAudio=void 0},e._now=function(){return performance.now()/1e3},e._calculateCurrentTime=function(){var t=this._now()-this._startTime,e=this._startOffset+t;return e>=this.duration&&(this._startTime=this._now(),this._startOffset=0),e%this.duration},e.start=function(){this._isPaused=!1,this._startTime=this._now()},e.pause=function(){this._isPaused||(this._isPaused=!0,this._startOffset=this._calculateCurrentTime())},e.stop=function(){this._isPaused=!0,this._startOffset=0},e.seek=function(t){this._startTime=this._now(),this._startOffset=Ge(t,0,this.duration)},Pi(t,[{key:"duration",get:function(){return this._nativeAudio.duration}},{key:"currentTime",get:function(){return this._isPaused?this._startOffset:this._calculateCurrentTime()}}]),t}(),AM=new(function(){function t(){this._audioBufferDataMap={}}var e=t.prototype;return e.addCache=function(t,e){this._audioBufferDataMap[t]?console.warn("Audio buffer "+t+" has been cached"):this._audioBufferDataMap[t]={usedCount:1,audioBuffer:e}},e.retainCache=function(t){var e=this._audioBufferDataMap[t];e?e.usedCount++:console.warn("Audio buffer cache "+t+" has not been added.")},e.getCache=function(t){var e=this._audioBufferDataMap[t];return null==e?void 0:e.audioBuffer},e.tryReleasingCache=function(t){var e=this._audioBufferDataMap[t];e?--e.usedCount<=0&&delete this._audioBufferDataMap[t]:console.warn("Audio buffer cache "+t+" has not been added.")},t}()),CM=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,RM="on-context-running",bM=function(){function t(){var t=this;this._eventTarget=void 0,this._context=void 0,this._isRunning=!1,this._context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),this._eventTarget=new es,this._context.onstatechange=function(){"running"===t._context.state?(t._isRunning=!0,t._eventTarget.emit(RM)):t._isRunning=!1}}var e=t.prototype;return e.onceRunning=function(t,e){this._eventTarget.once(RM,t,e)},e.offRunning=function(t,e){this._eventTarget.off(RM,t,e)},e.decodeAudioData=function(t){var e=this;return new Promise((function(i){var n=e._context.decodeAudioData(t,(function(t){i(t)}),(function(t){console.error("failed to load Web Audio",t)}));null==n||n.catch((function(){}))}))},e.runContext=function(){var t=this;return new Promise((function(e){if(t.isRunning)e();else{var i=t._context;if(i.resume)if(i.resume().catch((function(){})),"running"!==i.state){var n=document.getElementById("GameCanvas"),r=function t(){i.resume().then((function(){null==n||n.removeEventListener("touchend",t,{capture:!0}),null==n||n.removeEventListener("mouseup",t,{capture:!0}),e()})).catch((function(){}))};null==n||n.addEventListener("touchend",r,{capture:!0}),null==n||n.addEventListener("mouseup",r,{capture:!0})}else e();else e()}}))},e.createBufferSource=function(t,e){var i=this._context.createBufferSource();return void 0!==t&&(i.buffer=t),void 0!==e&&(i.loop=e),i},e.createGain=function(t){void 0===t&&(t=1);var e=this._context.createGain();return this.setGainValue(e,t),e},e.setGainValue=function(t,e){if(t.gain.setTargetAtTime)try{t.gain.setTargetAtTime(e,this._context.currentTime,0)}catch(i){t.gain.setTargetAtTime(e,this._context.currentTime,.01)}else t.gain.value=e},e.connectContext=function(t){this._context&&t.connect(this._context.destination)},Pi(t,[{key:"isRunning",get:function(){return this._isRunning}},{key:"currentTime",get:function(){return this._context.currentTime}}]),t}();bM.support=!!CM,bM.support&&(yM=new bM);var xM,wM,MM,IM,BM,PM=function(){function t(t,e,i){this._duration=void 0,this._bufferSourceNode=void 0,this._onPlayCb=void 0,this._currentTimer=0,this._url=void 0,this._onEndCb=void 0,this._duration=t.duration,this._url=i,this._bufferSourceNode=yM.createBufferSource(t,!1);var n=yM.createGain(e);this._bufferSourceNode.connect(n),yM.connectContext(n)}var e=t.prototype;return e.play=function(){var t=this;this._bufferSourceNode.start(),yM.runContext().then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t),t._currentTimer=window.setTimeout((function(){var e;AM.tryReleasingCache(t._url),null===(e=t.onEnd)||void 0===e||e.call(t)}),1e3*t._duration)})).catch((function(){}))},e.stop=function(){clearTimeout(this._currentTimer),AM.tryReleasingCache(this._url),this._bufferSourceNode.stop(),this._bufferSourceNode.buffer=null},Pi(t,[{key:"onPlay",get:function(){return this._onPlayCb},set:function(t){this._onPlayCb=t}},{key:"onEnd",get:function(){return this._onEndCb},set:function(t){this._onEndCb=t}}]),t}(),DM=(vM=function(){function t(t,e){this._src=void 0,this._audioBuffer=void 0,this._sourceNode=void 0,this._gainNode=void 0,this._currentTimer=0,this._volume=1,this._loop=!1,this._state=hM.INIT,this._audioTimer=void 0,this._eventTarget=new es,this._operationQueue=[],this._audioBuffer=t,this._audioTimer=new EM(t),this._gainNode=yM.createGain(),yM.connectContext(this._gainNode),this._src=e,qr.on(Zr.EVENT_PAUSE,this._onInterruptedBegin,this),qr.on(Zr.EVENT_RESUME,this._onInterruptedEnd,this)}var e=t.prototype;return e.destroy=function(){this._audioTimer.destroy(),this._audioBuffer&&(this._audioBuffer=null),AM.tryReleasingCache(this._src),qr.off(Zr.EVENT_PAUSE,this._onInterruptedBegin,this),qr.off(Zr.EVENT_RESUME,this._onInterruptedEnd,this)},t.load=function(e){return new Promise((function(i){t.loadNative(e).then((function(n){i(new t(n,e))})).catch((function(){}))}))},t.loadNative=function(t){return new Promise((function(e,i){var n=AM.getCache(t);if(n)return AM.retainCache(t),void e(n);var r=new XMLHttpRequest,s="load audio failed: "+t+", status: ";r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=function(){200===r.status||0===r.status?yM.decodeAudioData(r.response).then((function(i){AM.addCache(t,i),e(i)})).catch((function(){})):i(new Error(""+s+r.status+"(no response)"))},r.onerror=function(){i(new Error(""+s+r.status+"(error)"))},r.ontimeout=function(){i(new Error(""+s+r.status+"(time out)"))},r.onabort=function(){i(new Error(""+s+r.status+"(abort)"))},r.send(null)}))},t.loadOneShotAudio=function(e,i){return new Promise((function(n,r){t.loadNative(e).then((function(t){var r=new PM(t,i,e);n(r)})).catch(r)}))},e.getPCMData=function(t){return new _M(this._audioBuffer.getChannelData(t),1)},e._onInterruptedBegin=function(){var t=this;this._state===hM.PLAYING&&this.pause().then((function(){t._state=hM.INTERRUPTED,t._eventTarget.emit(aM.INTERRUPTION_BEGIN)})).catch((function(){}))},e._onInterruptedEnd=function(){var t=this;this._state===hM.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit(aM.INTERRUPTION_END)})).catch((function(){}))},e.seek=function(t){var e=this;return new Promise((function(i){yM.offRunning(),e._audioTimer.seek(t),e._state===hM.PLAYING?e._doPlay().then(i).catch((function(){})):i()}))},e.play=function(){return yM.offRunning(),this._doPlay()},e._doPlay=function(){var t=this;return new Promise((function(e){yM.isRunning?(t._startSourceNode(),e()):(yM.onceRunning((function(){t._startSourceNode(),e()})),yM.runContext().catch((function(){})))}))},e._startSourceNode=function(){var t=this;this._stopSourceNode(),this._sourceNode=yM.createBufferSource(this._audioBuffer,this.loop),this._sourceNode.connect(this._gainNode),this._sourceNode.start(0,this._audioTimer.currentTime),this._state=hM.PLAYING,this._audioTimer.start(),window.clearTimeout(this._currentTimer),this._currentTimer=window.setTimeout((function e(){t.loop?t._currentTimer=window.setTimeout(e,1e3*t._audioBuffer.duration):(t._audioTimer.stop(),t._eventTarget.emit(aM.ENDED),t._state=hM.INIT)}),1e3*(this._audioBuffer.duration-this._audioTimer.currentTime))},e._stopSourceNode=function(){try{this._sourceNode&&(this._sourceNode.stop(),this._sourceNode.buffer=null)}catch(t){}},e.pause=function(){return yM.offRunning(),this._state===hM.PLAYING&&this._sourceNode?(this._audioTimer.pause(),this._state=hM.PAUSED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.stop=function(){return yM.offRunning(),this._sourceNode?(this._audioTimer.stop(),this._state=hM.STOPPED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.onInterruptionBegin=function(t){this._eventTarget.on(aM.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off(aM.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on(aM.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off(aM.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on(aM.ENDED,t)},e.offEnded=function(t){this._eventTarget.off(aM.ENDED,t)},Pi(t,[{key:"sampleRate",get:function(){return this._audioBuffer.sampleRate}},{key:"src",get:function(){return this._src}},{key:"type",get:function(){return oM.WEB_AUDIO}},{key:"state",get:function(){return this._state}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._sourceNode&&(this._sourceNode.loop=t)}},{key:"volume",get:function(){return this._volume},set:function(t){t=Bs(t),this._volume=t,yM.setGainValue(this._gainNode,t)}},{key:"duration",get:function(){return this._audioBuffer.duration}},{key:"currentTime",get:function(){return this._audioTimer.currentTime}}]),t}(),gn(vM.prototype,"seek",[gM],Object.getOwnPropertyDescriptor(vM.prototype,"seek"),vM.prototype),gn(vM.prototype,"play",[gM],Object.getOwnPropertyDescriptor(vM.prototype,"play"),vM.prototype),gn(vM.prototype,"pause",[gM],Object.getOwnPropertyDescriptor(vM.prototype,"pause"),vM.prototype),gn(vM.prototype,"stop",[gM],Object.getOwnPropertyDescriptor(vM.prototype,"stop"),vM.prototype),vM),OM=function(){function t(t){this._audio=void 0,this._audio=t}var e=t.prototype;return e.play=function(){this._audio.play()},e.stop=function(){this._audio.stop()},Pi(t,[{key:"onPlay",get:function(){return this._audio.onPlay},set:function(t){this._audio.onPlay=t}},{key:"onEnd",get:function(){return this._audio.onEnd},set:function(t){this._audio.onEnd=t}}]),t}(),FM=function(){function t(t){this._player=void 0,this._player=t}t.load=function(e,i){return new Promise((function(n){(null==i?void 0:i.audioLoadMode)!==oM.DOM_AUDIO&&bM.support?DM.load(e).then((function(e){n(new t(e))})).catch((function(){})):(bM.support||Zi(5201),SM.load(e).then((function(e){n(new t(e))})).catch((function(){})))}))};var e=t.prototype;return e.destroy=function(){this._player.destroy()},t.loadNative=function(t,e){return(null==e?void 0:e.audioLoadMode)!==oM.DOM_AUDIO&&bM.support?DM.loadNative(t):(bM.support||Zi(5201),SM.loadNative(t))},t.loadOneShotAudio=function(t,e,i){return new Promise((function(n,r){(null==i?void 0:i.audioLoadMode)!==oM.DOM_AUDIO&&bM.support?DM.loadOneShotAudio(t,e).then((function(t){n(new OM(t))})).catch(r):(bM.support||Zi(5201),SM.loadOneShotAudio(t,e).then((function(t){n(new OM(t))})).catch(r))}))},e.getPCMData=function(t){return this._player.getPCMData(t)},e.seek=function(t){return this._player.seek(t)},e.play=function(){return this._player.play()},e.pause=function(){return this._player.pause()},e.stop=function(){return this._player.stop()},e.onInterruptionBegin=function(t){this._player.onInterruptionBegin(t)},e.offInterruptionBegin=function(t){this._player.offInterruptionBegin(t)},e.onInterruptionEnd=function(t){this._player.onInterruptionEnd(t)},e.offInterruptionEnd=function(t){this._player.offInterruptionEnd(t)},e.onEnded=function(t){this._player.onEnded(t)},e.offEnded=function(t){this._player.offEnded(t)},Pi(t,[{key:"src",get:function(){return this._player.src}},{key:"type",get:function(){return this._player.type}},{key:"state",get:function(){return this._player.state}},{key:"loop",get:function(){return this._player.loop},set:function(t){this._player.loop=t}},{key:"volume",get:function(){return this._player.volume},set:function(t){this._player.volume=t}},{key:"duration",get:function(){return this._player.duration}},{key:"currentTime",get:function(){return this._player.currentTime}},{key:"sampleRate",get:function(){return this._player.sampleRate}}]),t}();FM.maxAudioChannel=24;var LM=t("AudioClip",Ki("cc.AudioClip")((BM=IM=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._duration=MM&&MM(),e._loadMode=oM.UNKNOWN_AUDIO,e._meta=null,e._player=null,e}He(e,t);var i=e.prototype;return i.destroy=function(){var e,i=t.prototype.destroy.call(this);return null===(e=this._player)||void 0===e||e.destroy(),this._player=null,this._meta&&(this._meta.player=null),i},i.validate=function(){return!!this._meta},i.getDuration=function(){return this._duration?this._duration:this._meta?this._meta.duration:0},i.getCurrentTime=function(){return this._player?this._player.currentTime:0},i.getVolume=function(){return this._player?this._player.volume:0},i.getLoop=function(){return!!this._player&&this._player.loop},i.setCurrentTime=function(t){var e;null===(e=this._player)||void 0===e||e.seek(t).catch((function(){}))},i.setVolume=function(t){this._player&&(this._player.volume=t)},i.setLoop=function(t){this._player&&(this._player.loop=t)},i.play=function(){var t;null===(t=this._player)||void 0===t||t.play().catch((function(){}))},i.pause=function(){var t;null===(t=this._player)||void 0===t||t.pause().catch((function(){}))},i.stop=function(){var t;null===(t=this._player)||void 0===t||t.stop().catch((function(){}))},i.playOneShot=function(t){void 0===t&&(t=1),this._nativeAsset&&FM.loadOneShotAudio(this._nativeAsset.url,t).then((function(t){t.play()})).catch((function(){}))},Pi(e,[{key:"_nativeAsset",get:function(){return this._meta},set:function(t){this._meta=t,t?(this._loadMode=t.type,this._player=t.player):(this._meta=null,this._loadMode=oM.UNKNOWN_AUDIO,this._duration=0)}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,audioLoadMode:this.loadMode,ext:this._native,__isNative__:!0}}},{key:"loadMode",get:function(){return this._loadMode}},{key:"state",get:function(){return this._player?this._player.state:hM.INIT}}]),e}($i),IM.AudioType=oM,MM=tn((wM=BM).prototype,"_duration",[en],(function(){return 0})),gn(wM.prototype,"_nativeDep",[mn],Object.getOwnPropertyDescriptor(wM.prototype,"_nativeDep"),wM.prototype),xM=wM))||xM);function NM(t,e,i){FM.load(t,{audioLoadMode:e.audioLoadMode}).then((function(e){var n={player:e,url:t,duration:e.duration,type:e.type};i(null,n)})).catch((function(t){i(t)}))}function kM(t,e,i,n){var r=new LM;r._nativeUrl=t,r._nativeAsset=e,r._duration=e.duration,n(null,r)}We.AudioClip=LM,jr.register({".mp3":NM,".ogg":NM,".wav":NM,".m4a":NM}),Kr.register({".mp3":kM,".ogg":kM,".wav":kM,".m4a":kM});var UM,GM,VM,HM,zM,XM,WM,YM,jM,KM,qM,ZM,QM=new(function(){function t(){this._oneShotAudioInfoList=[],this._audioPlayerInfoList=[]}var e=t.prototype;return e._findIndex=function(t,e){return t.findIndex((function(t){return t.audio===e}))},e._tryAddPlaying=function(t,e){var i=this._findIndex(t,e);return i>-1?(t[i].playTime=performance.now(),!1):(t.push({audio:e,playTime:performance.now()}),!0)},e.addPlaying=function(t){t instanceof FM?this._tryAddPlaying(this._audioPlayerInfoList,t):this._tryAddPlaying(this._oneShotAudioInfoList,t)},e._tryRemovePlaying=function(t,e){var i=this._findIndex(t,e);return-1!==i&&(Ls(t,i),!0)},e.removePlaying=function(t){t instanceof FM?this._tryRemovePlaying(this._audioPlayerInfoList,t):this._tryRemovePlaying(this._oneShotAudioInfoList,t)},e.discardOnePlayingIfNeeded=function(){var t;this._audioPlayerInfoList.length+this._oneShotAudioInfoList.length<FM.maxAudioChannel||(this._oneShotAudioInfoList.length>0?this._oneShotAudioInfoList.forEach((function(e){(!t||e.playTime<t.playTime)&&(t=e)})):this._audioPlayerInfoList.forEach((function(e){(!t||e.playTime<t.playTime)&&(t=e)})),t&&(t.audio.stop(),this.removePlaying(t.audio)))},e.pause=function(){this._oneShotAudioInfoList.forEach((function(t){t.audio.stop()})),this._audioPlayerInfoList.forEach((function(t){t.audio.pause().catch((function(){}))}))},e.resume=function(){this._audioPlayerInfoList.forEach((function(t){t.audio.play().catch((function(){}))}))},t}()),JM="audiosource-loaded";!function(t){t.STARTED="started",t.ENDED="ended"}(ZM||(ZM={}));var $M=function(e){return t({AudioSource:e,AudioSourceComponent:e}),e}((UM=Ki("cc.AudioSource"),GM=Tn(LM),VM=Tn(LM),UM((qM=KM=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._clip=XM&&XM(),e._player=null,e._loop=WM&&WM(),e._playOnAwake=YM&&YM(),e._volume=jM&&jM(),e._cachedCurrentTime=0,e._operationsBeforeLoading=[],e._isLoaded=!1,e._lastSetClip=null,e}He(e,t);var i=e.prototype;return i._resetPlayer=function(){this._player&&(QM.removePlaying(this._player),this._player.offEnded(),this._player.offInterruptionBegin(),this._player.offInterruptionEnd(),this._player.destroy(),this._player=null)},i._syncPlayer=function(){var t=this,e=this._clip;if(this._lastSetClip!==e)return e?void(e._nativeAsset?(this._isLoaded=!1,this._lastSetClip=e,this._operationsBeforeLoading.length=0,FM.load(e._nativeAsset.url,{audioLoadMode:e.loadMode}).then((function(i){var n;t._lastSetClip===e?(t._isLoaded=!0,t._resetPlayer(),t._player=i,i.onEnded((function(){var e;QM.removePlaying(i),null===(e=t.node)||void 0===e||e.emit(ZM.ENDED,t)})),i.onInterruptionBegin((function(){QM.removePlaying(i)})),i.onInterruptionEnd((function(){QM.addPlaying(i)})),t._syncStates(),null===(n=t.node)||void 0===n||n.emit(JM)):i.destroy()})).catch((function(){}))):console.error("Invalid audio clip")):(this._lastSetClip=null,void this._resetPlayer())},i.onLoad=function(){this._syncPlayer()},i.onEnable=function(){this._playOnAwake&&!this.playing&&this.play()},i.onDisable=function(){var t=this._getRootNode();null!=t&&t._persistNode||this.pause()},i.onDestroy=function(){var t;this.stop(),null===(t=this._player)||void 0===t||t.destroy(),this._player=null},i.getPCMData=function(t){var e=this;return new Promise((function(i){if(0!==t&&1!==t)return console.warn("Only support channel index 0 or 1 to get buffer"),void i(void 0);var n;e._player?i(e._player.getPCMData(t)):null===(n=e.node)||void 0===n||n.once(JM,(function(){var n;i(null===(n=e._player)||void 0===n?void 0:n.getPCMData(t))}))}))},i.getSampleRate=function(){var t=this;return new Promise((function(e){var i;t._player?e(t._player.sampleRate):null===(i=t.node)||void 0===i||i.once(JM,(function(){e(t._player.sampleRate)}))}))},i._getRootNode=function(){for(var t,e,i=this.node,n=null===(t=i)||void 0===t||null===(e=t.parent)||void 0===e?void 0:e.parent;n;){var r,s,a;n=null===(s=i=null===(r=i)||void 0===r?void 0:r.parent)||void 0===s||null===(a=s.parent)||void 0===a?void 0:a.parent}return i},i.play=function(){var t,e=this;if(this._isLoaded||!this.clip){var i;QM.discardOnePlayingIfNeeded(),this.state===hM.PLAYING&&(null===(i=this._player)||void 0===i||i.stop().catch((function(){})));var n=this._player;null===(t=this._player)||void 0===t||t.play().then((function(){var t;QM.addPlaying(n),null===(t=e.node)||void 0===t||t.emit(ZM.STARTED,e)})).catch((function(){}))}else this._operationsBeforeLoading.push("play")},i.pause=function(){var t;if(this._isLoaded||!this.clip){var e=this._player;null===(t=this._player)||void 0===t||t.pause().then((function(){QM.removePlaying(e)})).catch((function(){}))}else this._operationsBeforeLoading.push("pause")},i.stop=function(){var t;if(this._isLoaded||!this.clip){var e=this._player;null===(t=this._player)||void 0===t||t.stop().then((function(){QM.removePlaying(e)})).catch((function(){}))}else this._operationsBeforeLoading.push("stop")},i.playOneShot=function(t,e){void 0===e&&(e=1),t._nativeAsset?FM.loadOneShotAudio(t._nativeAsset.url,this._volume*e,{audioLoadMode:t.loadMode}).then((function(t){QM.discardOnePlayingIfNeeded(),t.onPlay=function(){QM.addPlaying(t)},t.onEnd=function(){QM.removePlaying(t)},t.play()})).catch((function(){})):console.error("Invalid audio clip")},i._syncStates=function(){var t=this;this._player&&this._player.seek(this._cachedCurrentTime).then((function(){t._player&&(t._player.loop=t._loop,t._player.volume=t._volume,t._operationsBeforeLoading.forEach((function(e){var i;null===(i=t[e])||void 0===i||i.call(t)})),t._operationsBeforeLoading.length=0)})).catch((function(){}))},Pi(e,[{key:"clip",get:function(){return this._clip},set:function(t){t!==this._clip&&(this._clip=t,this._syncPlayer())}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._player&&(this._player.loop=t)}},{key:"playOnAwake",get:function(){return this._playOnAwake},set:function(t){this._playOnAwake=t}},{key:"volume",get:function(){return this._volume},set:function(t){Number.isNaN(t)?console.warn("illegal audio volume!"):(t=Ge(t,0,1),this._player?(this._player.volume=t,this._volume=this._player.volume):this._volume=t)}},{key:"currentTime",get:function(){return this._player?this._player.currentTime:this._cachedCurrentTime},set:function(t){var e;Number.isNaN(t)?console.warn("illegal audio time!"):(t=Ge(t,0,this.duration),this._cachedCurrentTime=t,null===(e=this._player)||void 0===e||e.seek(this._cachedCurrentTime).catch((function(){})))}},{key:"duration",get:function(){var t,e;return null!==(t=null===(e=this._clip)||void 0===e?void 0:e.getDuration())&&void 0!==t?t:this._player?this._player.duration:0}},{key:"state",get:function(){return this._player?this._player.state:hM.INIT}},{key:"playing",get:function(){return this.state===e.AudioState.PLAYING}}],[{key:"maxAudioChannel",get:function(){return FM.maxAudioChannel}}]),e}(Pn),KM.AudioState=hM,KM.EventType=ZM,XM=tn((zM=qM).prototype,"_clip",[GM],(function(){return null})),WM=tn(zM.prototype,"_loop",[en],(function(){return!1})),YM=tn(zM.prototype,"_playOnAwake",[en],(function(){return!0})),jM=tn(zM.prototype,"_volume",[en],(function(){return 1})),gn(zM.prototype,"clip",[VM],Object.getOwnPropertyDescriptor(zM.prototype,"clip"),zM.prototype),HM=zM))||HM));function tI(t){for(var e=t.scene.batches,i=0;i<e.length;i++){var n=e[i];if(t.visibility&n.visFlags)return!0}return!1}zn(LM,"AudioClip",[{name:"PlayingState",newName:"AudioState",target:$M,targetName:"AudioSource"}]),Rr(LM.prototype,"AudioClip.prototype",["state","play","pause","stop","playOneShot","setCurrentTime","setVolume","setLoop","getCurrentTime","getVolume","getLoop"].map((function(t){return{name:t,suggest:"please use AudioSource.prototype."+t+" instead"}}))),We.AudioSourceComponent=$M,br($M,"cc.AudioSourceComponent"),We.log=Ns,We.warn=Gi,We.error=ks,We.assert=Us,We._throw=Gs,We.logID=kr,We.warnID=Zi,We.errorID=hn,We.assertID=Rn,We.debug=Vs,We.path={join:Hs,extname:yn,mainFileName:zs,basename:Xs,dirname:Ws,changeExtname:Ys,changeBasename:js,_normalize:Ks,stripSep:qs,get sep(){return Zs()}},t("ForwardPipelineBuilder",function(){function t(){}return t.prototype.setup=function(t,e){for(var i=0;i<t.length;i++){var n=t[i];null!==n.scene&&Qs(n,e,!1)}},t}()),t("DeferredPipelineBuilder",function(){function t(){}return t.prototype.setup=function(t,e){for(var i=0;i<t.length;++i){var n=t[i];if(n.scene)if(n.cameraUsage===$e.GAME||n.cameraUsage===$e.GAME_VIEW)if(tI(n))ea(n,e);else{var r=Js(n,e),s=$s(n,e,r);ta(n,e,s.rtName)}else Qs(n,e,!1)}},t}());var eI=Dr.Flags.Destroyed,iI=Dr.Flags.PersistentMask,nI=[];function rI(t){var e;if(ia(t)){if(t._instantiate)return We.game._isCloning=!0,e=t._instantiate(null,!0),We.game._isCloning=!1,e;if(t instanceof We.Asset)throw new TypeError(Cn(6903))}return We.game._isCloning=!0,e=sI(t),We.game._isCloning=!1,e}function sI(t,e){var i;aI(t,i=t._iN$t?t._iN$t:t.constructor?new(0,t.constructor):Object.create(null),e);for(var n=0,r=nI.length;n<r;++n)nI[n]._iN$t=null;return nI.length=0,i}function aI(t,e,i){na(t,"_iN$t",e,!0),nI.push(t);var n=t.constructor;if(ra(n))!function(t,e,i,n){for(var r=t.__values__,s=0;s<r.length;s++){var a=r[s],o=e[a];if("object"==typeof o&&o){var h=i[a];h instanceof Rs&&h.constructor===o.constructor?h.set(o):i[a]=o._iN$t||oI(o,n)}else i[a]=o}}(n,t,e,i);else for(var r in t)if(t.hasOwnProperty(r)&&(95!==r.charCodeAt(0)||95!==r.charCodeAt(1)||"__type__"===r||"__prefab"===r)){var s=t[r];if("object"==typeof s&&s){if(s===e)continue;e[r]=s._iN$t||oI(s,i)}else e[r]=s}ia(t)&&(e._objFlags&=iI)}function oI(t,e){if(t instanceof Rs)return t.clone();if(t instanceof We.Asset)return t;var i;if(ArrayBuffer.isView(t)){var n=t.length;i=new t.constructor(n),t._iN$t=i,nI.push(t);for(var r=0;r<n;++r)i[r]=t[r];return i}if(Array.isArray(t)){var s=t.length;i=new Array(s),t._iN$t=i,nI.push(t);for(var a=0;a<s;++a){var o=t[a];i[a]="object"==typeof o&&o?o._iN$t||oI(o,e):o}return i}if(t._objFlags&eI)return null;var h=t.constructor;if(ra(h)){if(e)if(e instanceof We.Component){if(t instanceof We.Node||t instanceof We.Component)return t}else if(e instanceof We.Node)if(t instanceof We.Node){if(!t.isChildOf(e))return t}else if(t instanceof We.Component&&t.node&&!t.node.isChildOf(e))return t;i=new h}else if(h===Object)i={};else{if(h)return t;i=Object.create(null)}return aI(t,i,e),i}rI._clone=sI,We.instantiate=rI;var hI,lI,uI=t("NodePool",function(){function t(t){this.poolHandlerComp=void 0,this._pool=void 0,this.poolHandlerComp=t,this._pool=[]}var e=t.prototype;return e.size=function(){return this._pool.length},e.clear=function(){for(var t=this._pool.length,e=0;e<t;++e)this._pool[e].destroy();this._pool.length=0},e.put=function(t){if(t&&-1===this._pool.indexOf(t)){t.removeFromParent();var e=this.poolHandlerComp?t.getComponent(this.poolHandlerComp):null;e&&e.unuse&&e.unuse(),this._pool.push(t)}},e.get=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=this._pool.length-1;if(n<0)return null;var r=this._pool[n];this._pool.length=n;var s=this.poolHandlerComp?r.getComponent(this.poolHandlerComp):null;return s&&s.reuse&&s.reuse(arguments),r},t}());We.NodePool=uI;var cI=null!==(hI=globalThis.jsb)&&void 0!==hI?hI:{};t("native",{DownloaderHints:cI.DownloaderHints,Downloader:cI.Downloader,zipUtils:cI.zipUtils,fileUtils:cI.fileUtils,DebugRenderer:cI.DebugRenderer,copyTextToClipboard:null===(lI=cI.copyTextToClipboard)||void 0===lI?void 0:lI.bind(cI),garbageCollect:cI.garbageCollect,reflection:cI.reflection,bridge:cI.bridge,jsbBridgeWrapper:cI.jsbBridgeWrapper,AssetsManager:cI.AssetsManager,EventAssetsManager:cI.EventAssetsManager,Manifest:cI.Manifest,saveImageData:cI.saveImageData,process:cI.process}),We.renderer=mc;var dI,_I=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuDescriptorSet=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._layout=t.layout;var e=t.layout.gpuDescriptorSetLayout,i=e.bindings,n=e.descriptorIndices,r=e.descriptorCount;this._buffers=Array(r).fill(null),this._textures=Array(r).fill(null),this._samplers=Array(r).fill(null);var s=[];this._gpuDescriptorSet={gpuDescriptors:s,descriptorIndices:n};for(var a=0;a<i.length;++a)for(var o=i[a],h=0;h<o.count;h++)s.push({type:o.descriptorType,gpuBuffer:null,gpuTexture:null,gpuSampler:null})},i.destroy=function(){this._layout=null,this._gpuDescriptorSet=null},i.update=function(){if(this._isDirty&&this._gpuDescriptorSet){for(var t=this._gpuDescriptorSet.gpuDescriptors,e=0;e<t.length;++e)if(t[e].type&re){var i=this._buffers[e];i&&(t[e].gpuBuffer=i.gpuBuffer||i.gpuBufferView)}else t[e].type&se&&(this._textures[e]&&(t[e].gpuTexture=this._textures[e].gpuTexture),this._samplers[e]&&(t[e].gpuSampler=this._samplers[e].gpuSampler));this._isDirty=!1}},Pi(e,[{key:"gpuDescriptorSet",get:function(){return this._gpuDescriptorSet}}]),e}(s);!function(t){t[t.RGBA16F_EXT=34842]="RGBA16F_EXT",t[t.RGB16F_EXT=34843]="RGB16F_EXT",t[t.RGBA32F_EXT=34836]="RGBA32F_EXT",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",t[t.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",t[t.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",t[t.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",t[t.SRGB_EXT=35904]="SRGB_EXT",t[t.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",t[t.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"}(dI||(dI={}));var fI=function(){function t(){}return t.setInstance=function(e){t._instance=e},Pi(t,null,[{key:"instance",get:function(){return t._instance}}]),t}();function pI(t,e){switch(t){case _.R8:return e.UNSIGNED_BYTE;case _.R8SN:return e.BYTE;case _.R8UI:return e.UNSIGNED_BYTE;case _.R8I:return e.BYTE;case _.R16F:return dI.HALF_FLOAT_OES;case _.R16UI:return e.UNSIGNED_SHORT;case _.R16I:return e.SHORT;case _.R32F:return e.FLOAT;case _.R32UI:return e.UNSIGNED_INT;case _.R32I:return e.INT;case _.RG8:return e.UNSIGNED_BYTE;case _.RG8SN:return e.BYTE;case _.RG8UI:return e.UNSIGNED_BYTE;case _.RG8I:return e.BYTE;case _.RG16F:return dI.HALF_FLOAT_OES;case _.RG16UI:return e.UNSIGNED_SHORT;case _.RG16I:return e.SHORT;case _.RG32F:return e.FLOAT;case _.RG32UI:return e.UNSIGNED_INT;case _.RG32I:return e.INT;case _.RGB8:case _.SRGB8:return e.UNSIGNED_BYTE;case _.RGB8SN:return e.BYTE;case _.RGB8UI:return e.UNSIGNED_BYTE;case _.RGB8I:return e.BYTE;case _.RGB16F:return dI.HALF_FLOAT_OES;case _.RGB16UI:return e.UNSIGNED_SHORT;case _.RGB16I:return e.SHORT;case _.RGB32F:return e.FLOAT;case _.RGB32UI:return e.UNSIGNED_INT;case _.RGB32I:return e.INT;case _.BGRA8:case _.RGBA8:case _.SRGB8_A8:return e.UNSIGNED_BYTE;case _.RGBA8SN:return e.BYTE;case _.RGBA8UI:return e.UNSIGNED_BYTE;case _.RGBA8I:return e.BYTE;case _.RGBA16F:return dI.HALF_FLOAT_OES;case _.RGBA16UI:return e.UNSIGNED_SHORT;case _.RGBA16I:return e.SHORT;case _.RGBA32F:return e.FLOAT;case _.RGBA32UI:return e.UNSIGNED_INT;case _.RGBA32I:return e.INT;case _.R5G6B5:return e.UNSIGNED_SHORT_5_6_5;case _.R11G11B10F:return e.FLOAT;case _.RGB5A1:return e.UNSIGNED_SHORT_5_5_5_1;case _.RGBA4:return e.UNSIGNED_SHORT_4_4_4_4;case _.RGB10A2:return e.UNSIGNED_BYTE;case _.RGB10A2UI:return e.UNSIGNED_INT;case _.RGB9E5:return e.UNSIGNED_BYTE;case _.DEPTH:return e.UNSIGNED_INT;case _.DEPTH_STENCIL:return dI.UNSIGNED_INT_24_8_WEBGL;case _.BC1:case _.BC1_SRGB:case _.BC2:case _.BC2_SRGB:case _.BC3:case _.BC3_SRGB:case _.BC4:return e.UNSIGNED_BYTE;case _.BC4_SNORM:return e.BYTE;case _.BC5:return e.UNSIGNED_BYTE;case _.BC5_SNORM:return e.BYTE;case _.BC6H_SF16:case _.BC6H_UF16:return e.FLOAT;case _.BC7:case _.BC7_SRGB:case _.ETC_RGB8:case _.ETC2_RGB8:case _.ETC2_SRGB8:case _.ETC2_RGB8_A1:case _.ETC2_SRGB8_A1:case _.EAC_R11:return e.UNSIGNED_BYTE;case _.EAC_R11SN:return e.BYTE;case _.EAC_RG11:return e.UNSIGNED_BYTE;case _.EAC_RG11SN:return e.BYTE;case _.PVRTC_RGB2:case _.PVRTC_RGBA2:case _.PVRTC_RGB4:case _.PVRTC_RGBA4:case _.PVRTC2_2BPP:case _.PVRTC2_4BPP:return e.UNSIGNED_BYTE;case _.ASTC_RGBA_4X4:case _.ASTC_RGBA_5X4:case _.ASTC_RGBA_5X5:case _.ASTC_RGBA_6X5:case _.ASTC_RGBA_6X6:case _.ASTC_RGBA_8X5:case _.ASTC_RGBA_8X6:case _.ASTC_RGBA_8X8:case _.ASTC_RGBA_10X5:case _.ASTC_RGBA_10X6:case _.ASTC_RGBA_10X8:case _.ASTC_RGBA_10X10:case _.ASTC_RGBA_12X10:case _.ASTC_RGBA_12X12:case _.ASTC_SRGBA_4X4:case _.ASTC_SRGBA_5X4:case _.ASTC_SRGBA_5X5:case _.ASTC_SRGBA_6X5:case _.ASTC_SRGBA_6X6:case _.ASTC_SRGBA_8X5:case _.ASTC_SRGBA_8X6:case _.ASTC_SRGBA_8X8:case _.ASTC_SRGBA_10X5:case _.ASTC_SRGBA_10X6:case _.ASTC_SRGBA_10X8:case _.ASTC_SRGBA_10X10:case _.ASTC_SRGBA_12X10:case _.ASTC_SRGBA_12X12:default:return e.UNSIGNED_BYTE}}function gI(t,e){switch(t){case p.BOOL:return e.BOOL;case p.BOOL2:return e.BOOL_VEC2;case p.BOOL3:return e.BOOL_VEC3;case p.BOOL4:return e.BOOL_VEC4;case p.INT:return e.INT;case p.INT2:return e.INT_VEC2;case p.INT3:return e.INT_VEC3;case p.INT4:return e.INT_VEC4;case p.UINT:return e.UNSIGNED_INT;case p.FLOAT:return e.FLOAT;case p.FLOAT2:return e.FLOAT_VEC2;case p.FLOAT3:return e.FLOAT_VEC3;case p.FLOAT4:return e.FLOAT_VEC4;case p.MAT2:return e.FLOAT_MAT2;case p.MAT3:return e.FLOAT_MAT3;case p.MAT4:return e.FLOAT_MAT4;case p.SAMPLER2D:return e.SAMPLER_2D;case p.SAMPLER_CUBE:return e.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to GL type failed."),p.UNKNOWN}}function mI(t){switch(t){case p.BOOL:case p.BOOL2:case p.BOOL3:case p.BOOL4:case p.INT:case p.INT2:case p.INT3:case p.INT4:case p.UINT:return Int32Array;case p.FLOAT:case p.FLOAT2:case p.FLOAT3:case p.FLOAT4:case p.MAT2:case p.MAT3:case p.MAT4:return Float32Array;default:return console.error("Unsupported GLType, convert to TypedArrayConstructor failed."),Float32Array}}function vI(t,e){switch(t){case e.BOOL:return p.BOOL;case e.BOOL_VEC2:return p.BOOL2;case e.BOOL_VEC3:return p.BOOL3;case e.BOOL_VEC4:return p.BOOL4;case e.INT:return p.INT;case e.INT_VEC2:return p.INT2;case e.INT_VEC3:return p.INT3;case e.INT_VEC4:return p.INT4;case e.UNSIGNED_INT:return p.UINT;case e.FLOAT:return p.FLOAT;case e.FLOAT_VEC2:return p.FLOAT2;case e.FLOAT_VEC3:return p.FLOAT3;case e.FLOAT_VEC4:return p.FLOAT4;case e.FLOAT_MAT2:return p.MAT2;case e.FLOAT_MAT3:return p.MAT3;case e.FLOAT_MAT4:return p.MAT4;case e.SAMPLER_2D:return p.SAMPLER2D;case e.SAMPLER_CUBE:return p.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to Type failed."),p.UNKNOWN}}function yI(t,e){switch(t){case e.BOOL:return 4;case e.BOOL_VEC2:return 8;case e.BOOL_VEC3:return 12;case e.BOOL_VEC4:return 16;case e.INT:return 4;case e.INT_VEC2:return 8;case e.INT_VEC3:return 12;case e.INT_VEC4:return 16;case e.UNSIGNED_INT:case e.FLOAT:return 4;case e.FLOAT_VEC2:return 8;case e.FLOAT_VEC3:return 12;case e.FLOAT_VEC4:case e.FLOAT_MAT2:return 16;case e.FLOAT_MAT3:return 36;case e.FLOAT_MAT4:return 64;case e.SAMPLER_2D:case e.SAMPLER_CUBE:return 4;default:return console.error("Unsupported GLType, get type failed."),0}}function TI(t,e){switch(t){case e.FLOAT_MAT2:return 2;case e.FLOAT_MAT3:return 3;case e.FLOAT_MAT4:return 4;default:return 1}}fI._instance=null;var SI,EI=[512,513,514,515,516,517,518,519],AI=[0,7680,7681,7682,7683,5386,34055,34056],CI=[32774,32778,32779,32775,32776],RI=[0,1,770,772,771,773,768,774,769,775,776,32769,32770,32771,32772];!function(t){t[t.BEGIN_RENDER_PASS=0]="BEGIN_RENDER_PASS",t[t.END_RENDER_PASS=1]="END_RENDER_PASS",t[t.BIND_STATES=2]="BIND_STATES",t[t.DRAW=3]="DRAW",t[t.UPDATE_BUFFER=4]="UPDATE_BUFFER",t[t.COPY_BUFFER_TO_TEXTURE=5]="COPY_BUFFER_TO_TEXTURE",t[t.BLIT_TEXTURE=6]="BLIT_TEXTURE",t[t.COUNT=7]="COUNT"}(SI||(SI={}));var bI=function(t){this.cmdType=void 0,this.refCount=0,this.cmdType=t},xI=function(t){function e(){var e;return(e=t.call(this,SI.BEGIN_RENDER_PASS)||this).gpuRenderPass=null,e.gpuFramebuffer=null,e.renderArea=new it,e.clearFlag=q.NONE,e.clearColors=[],e.clearDepth=1,e.clearStencil=0,e}return He(e,t),e.prototype.clear=function(){this.gpuFramebuffer=null,this.clearColors.length=0},e}(bI),wI=function(t){function e(){var e;return(e=t.call(this,SI.BIND_STATES)||this).gpuPipelineState=null,e.gpuInputAssembler=null,e.gpuDescriptorSets=[],e.dynamicOffsets=[],e.dynamicStates=new te,e}return He(e,t),e.prototype.clear=function(){this.gpuPipelineState=null,this.gpuDescriptorSets.length=0,this.gpuInputAssembler=null,this.dynamicOffsets.length=0},e}(bI),MI=function(t){function e(){var e;return(e=t.call(this,SI.DRAW)||this).drawInfo=new gt,e}return He(e,t),e.prototype.clear=function(){},e}(bI),II=function(t){function e(){var e;return(e=t.call(this,SI.UPDATE_BUFFER)||this).gpuBuffer=null,e.buffer=null,e.offset=0,e.size=0,e}return He(e,t),e.prototype.clear=function(){this.gpuBuffer=null,this.buffer=null},e}(bI),BI=function(t){function e(){var e;return(e=t.call(this,SI.COPY_BUFFER_TO_TEXTURE)||this).gpuTexture=null,e.buffers=[],e.regions=[],e}return He(e,t),e.prototype.clear=function(){this.gpuTexture=null,this.buffers.length=0,this.regions.length=0},e}(bI),PI=function(t){function e(){var e;return(e=t.call(this,SI.BLIT_TEXTURE)||this).srcTexture=null,e.dstTexture=null,e.regions=[],e.filter=b.LINEAR,e}return He(e,t),e.prototype.clear=function(){this.srcTexture=null,this.dstTexture=null,this.regions.length=0},e}(bI),DI=function(){function t(){this.cmds=new n(1),this.beginRenderPassCmds=new n(1),this.bindStatesCmds=new n(1),this.drawCmds=new n(1),this.updateBufferCmds=new n(1),this.copyBufferToTextureCmds=new n(1),this.blitTextureCmds=new n(1)}return t.prototype.clearCmds=function(t){this.beginRenderPassCmds.length&&(t.beginRenderPassCmdPool.freeCmds(this.beginRenderPassCmds),this.beginRenderPassCmds.clear()),this.bindStatesCmds.length&&(t.bindStatesCmdPool.freeCmds(this.bindStatesCmds),this.bindStatesCmds.clear()),this.drawCmds.length&&(t.drawCmdPool.freeCmds(this.drawCmds),this.drawCmds.clear()),this.updateBufferCmds.length&&(t.updateBufferCmdPool.freeCmds(this.updateBufferCmds),this.updateBufferCmds.clear()),this.copyBufferToTextureCmds.length&&(t.copyBufferToTextureCmdPool.freeCmds(this.copyBufferToTextureCmds),this.copyBufferToTextureCmds.clear()),this.blitTextureCmds.length&&(t.blitTextureCmdPool.freeCmds(this.blitTextureCmds),this.blitTextureCmds.clear()),this.cmds.clear()},t}();function OI(t,e){var i=t.gl,n=t.stateCache,r=e.memUsage&y.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;if(e.usage&g.VERTEX){e.glTarget=i.ARRAY_BUFFER;var s=i.createBuffer();s&&(e.glBuffer=s,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),VI.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer),i.bufferData(i.ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null))}else if(e.usage&g.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;var a=i.createBuffer();a&&(e.glBuffer=a,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),VI.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null))}else e.usage&g.UNIFORM?(e.glTarget=i.NONE,e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer))):(e.usage&g.INDIRECT||e.usage&g.TRANSFER_DST||e.usage&g.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE)}function FI(t,e){var i=t.gl,n=t.stateCache;if(e.glBuffer){switch(e.glTarget){case i.ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),t.stateCache.glVAO=null),VI.gpuInputAssembler=null,i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null;break;case i.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),t.stateCache.glVAO=null),VI.gpuInputAssembler=null,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}function LI(t,e,i,n,r){if(e.usage&g.UNIFORM)ArrayBuffer.isView(i)?e.vf32.set(i,n/Float32Array.BYTES_PER_ELEMENT):e.vf32.set(new Float32Array(i),n/Float32Array.BYTES_PER_ELEMENT);else if(e.usage&g.INDIRECT){e.indirects.clearDraws();for(var s=i.drawInfos,a=0;a<s.length;++a)e.indirects.setDrawInfo(n+a,s[a])}else{var o=i,h=t.gl,l=t.stateCache;switch(e.glTarget){case h.ARRAY_BUFFER:t.extensions.useVAO&&l.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),l.glVAO=null),VI.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&(h.bindBuffer(h.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer);break;case h.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&l.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),l.glVAO=null),VI.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer);break;default:return void console.error("Unsupported BufferType, update buffer failed.")}r===o.byteLength?h.bufferSubData(e.glTarget,n,o):h.bufferSubData(e.glTarget,n,o.slice(0,r))}}function NI(t,e){for(var i=t.gl,n=function(t){var n=e.gpuStages[t],r=0,s="",a=1;switch(n.type){case D.VERTEX:s="VertexShader",r=i.VERTEX_SHADER;break;case D.FRAGMENT:s="FragmentShader",r=i.FRAGMENT_SHADER;break;default:return console.error("Unsupported ShaderType."),{v:void 0}}var o=i.createShader(r);if(o&&(n.glShader=o,i.shaderSource(n.glShader,n.source),i.compileShader(n.glShader),!i.getShaderParameter(n.glShader,i.COMPILE_STATUS))){console.error(s+" in '"+e.name+"' compilation failed."),console.error("Shader source dump:",n.source.replace(/^|\n/g,(function(){return"\n"+a+++" "}))),console.error(i.getShaderInfoLog(n.glShader));for(var h=0;h<e.gpuStages.length;h++){var l=e.gpuStages[t];l.glShader&&(i.deleteShader(l.glShader),l.glShader=null)}return{v:void 0}}},r=0;r<e.gpuStages.length;r++){var s=n(r);if("object"==typeof s)return s.v}var a=i.createProgram();if(a){e.glProgram=a;for(var o=0;o<e.gpuStages.length;o++){var h=e.gpuStages[o];i.attachShader(e.glProgram,h.glShader)}if(i.linkProgram(e.glProgram),t.extensions.destroyShadersImmediately)for(var l=0;l<e.gpuStages.length;l++){var u=e.gpuStages[l];u.glShader&&(i.detachShader(e.glProgram,u.glShader),i.deleteShader(u.glShader),u.glShader=null)}if(!i.getProgramParameter(e.glProgram,i.LINK_STATUS))return console.error("Failed to link shader '"+e.name+"'."),void console.error(i.getProgramInfoLog(e.glProgram));Gn("Shader '"+e.name+"' compilation succeeded.");var c=i.getProgramParameter(e.glProgram,i.ACTIVE_ATTRIBUTES);e.glInputs=new Array(c);for(var d=0;d<c;++d){var _=i.getActiveAttrib(e.glProgram,d);if(_){var f,g=_.name.indexOf("[");f=-1!==g?_.name.substr(0,g):_.name;var m=i.getAttribLocation(e.glProgram,f),v=vI(_.type,i),y=yI(_.type,i);e.glInputs[d]={binding:m,name:f,type:v,stride:y,count:_.size,size:y*_.size,glType:_.type,glLoc:m}}}if(e.blocks.length>0){e.glBlocks=new Array(e.blocks.length);for(var T=0;T<e.blocks.length;++T){var S=e.blocks[T],E={set:S.set,binding:S.binding,name:S.name,size:0,glUniforms:new Array(S.members.length),glActiveUniforms:[]};e.glBlocks[T]=E;for(var A=0;A<S.members.length;++A){var C=S.members[A],R=gI(C.type,i),b=yI(R,i),x=b*C.count;E.glUniforms[A]={binding:-1,name:C.name,type:C.type,stride:b,count:C.count,size:x,offset:0,glType:R,glLoc:null,array:null}}}}for(var w=0;w<e.subpassInputs.length;++w){var M=e.subpassInputs[w];e.samplerTextures.push(new Ct(M.set,M.binding,M.name,p.SAMPLER2D,M.count))}if(e.samplerTextures.length>0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var I=0;I<e.samplerTextures.length;++I){var B=e.samplerTextures[I];e.glSamplerTextures[I]={set:B.set,binding:B.binding,name:B.name,type:B.type,count:B.count,units:[],glUnits:null,glType:gI(B.type,i),glLoc:null}}}for(var P=i.getProgramParameter(e.glProgram,i.ACTIVE_UNIFORMS),O=0;O<P;++O){var F=i.getActiveUniform(e.glProgram,O);if(F&&F.type!==i.SAMPLER_2D&&F.type!==i.SAMPLER_CUBE){var L=i.getUniformLocation(e.glProgram,F.name);if(t.extensions.isLocationActive(L)){var N,k=F.name.indexOf("[");N=-1!==k?F.name.substr(0,k):F.name;for(var U=0;U<e.glBlocks.length;U++)for(var G=e.glBlocks[U],V=0;V<G.glUniforms.length;V++){var H=G.glUniforms[V];if(H.name===N){H.glLoc=L,H.count=F.size,H.size=H.stride*H.count,H.array=new(mI(H.type))(H.size/4),G.glActiveUniforms.push(H);break}}}}}for(var z=0;z<e.glBlocks.length;z++)for(var X=e.glBlocks[z],W=0;W<X.glUniforms.length;W++){var Y=X.glUniforms[W];Y.offset=X.size/4,X.size+=Y.size}var j=[],K=[],q=t.bindingMappings,Z=t.stateCache.texUnitCacheMap;if(We.rendering&&We.rendering.enableEffectImport)for(var Q=0;Q<e.samplerTextures.length;++Q){var J=e.samplerTextures[Q],$=i.getUniformLocation(e.glProgram,J.name);t.extensions.isLocationActive($)&&(j.push(e.glSamplerTextures[Q]),K.push($)),void 0===Z[J.name]&&(Z[J.name]=J.flattened)}else{for(var tt=0,et=0;et<e.blocks.length;++et)e.blocks[et].set===q.flexibleSet&&tt++;for(var it=0,nt=0;nt<e.samplerTextures.length;++nt){var rt=e.samplerTextures[nt],st=i.getUniformLocation(e.glProgram,rt.name);if(t.extensions.isLocationActive(st)&&(j.push(e.glSamplerTextures[nt]),K.push(st)),void 0===Z[rt.name]){var at=rt.binding+q.samplerTextureOffsets[rt.set]+it;rt.set===q.flexibleSet&&(at-=tt),Z[rt.name]=at%t.capabilities.maxTextureUnits,it+=rt.count-1}}}if(j.length){for(var ot=[],ht=0;ht<j.length;++ht){var lt=j[ht],ut=Z[lt.name];if(void 0!==ut){lt.glLoc=K[ht];for(var ct=0;ct<lt.count;++ct){for(;ot[ut];)ut=(ut+1)%t.capabilities.maxTextureUnits;lt.units.push(ut),ot[ut]=!0}}}for(var dt=0,_t=0;_t<j.length;++_t){var ft=j[_t];if(!t.extensions.isLocationActive(ft.glLoc)){ft.glLoc=K[_t];for(var pt=0;pt<ft.count;++pt){for(;ot[dt];)dt=(dt+1)%t.capabilities.maxTextureUnits;void 0===Z[ft.name]&&(Z[ft.name]=dt),ft.units.push(dt),ot[dt]=!0}}}t.stateCache.glProgram!==e.glProgram&&i.useProgram(e.glProgram);for(var gt=0;gt<j.length;gt++){var mt=j[gt];mt.glUnits=new Int32Array(mt.units),i.uniform1iv(mt.glLoc,mt.glUnits)}t.stateCache.glProgram!==e.glProgram&&i.useProgram(t.stateCache.glProgram)}for(var vt=0;vt<e.glBlocks.length;)e.glBlocks[vt].glActiveUniforms.length?vt++:(e.glBlocks[vt]=e.glBlocks[e.glBlocks.length-1],e.glBlocks.length--);e.glSamplerTextures=j}}function kI(t,e){if(e.glProgram){var i=t.gl;if(!t.extensions.destroyShadersImmediately)for(var n=0;n<e.gpuStages.length;n++){var r=e.gpuStages[n];r.glShader&&(i.detachShader(e.glProgram,r.glShader),i.deleteShader(r.glShader),r.glShader=null)}i.deleteProgram(e.glProgram),t.stateCache.glProgram===e.glProgram&&(t.gl.useProgram(null),t.stateCache.glProgram=null),e.glProgram=null}}function UI(t,e){var i=t.gl;e.glAttribs=new Array(e.attributes.length);for(var n=[0,0,0,0,0,0,0,0],r=0;r<e.attributes.length;++r){var s=e.attributes[r],a=void 0!==s.stream?s.stream:0,o=e.gpuVertexBuffers[a],h=pI(s.format,i),l=ne[s.format].size;e.glAttribs[r]={name:s.name,glBuffer:o.glBuffer,glType:h,size:l,count:ne[s.format].count,stride:o.stride,componentCount:TI(h,i),isNormalized:void 0!==s.isNormalized&&s.isNormalized,isInstanced:void 0!==s.isInstanced&&s.isInstanced,offset:n[a]},n[a]+=l}}function GI(t,e){for(var i=e.glVAOs.values(),n=i.next(),r=t.extensions.OES_vertex_array_object,s=t.stateCache.glVAO;!n.done;)r.deleteVertexArrayOES(n.value),s===n.value&&(r.bindVertexArrayOES(null),s=null),n=i.next();t.stateCache.glVAO=s,e.glVAOs.clear()}var VI={gpuPipelineState:null,gpuInputAssembler:null,glPrimitive:0},HI=new it;function zI(t,e,i,n,r,s,a){var o=t.gl,h=t.stateCache,l=0;if(i&&(HI.x=n.x<<i.lodLevel,HI.y=n.y<<i.lodLevel,HI.width=n.width<<i.lodLevel,HI.height=n.height<<i.lodLevel),i&&e){h.glFramebuffer!==i.glFramebuffer&&(o.bindFramebuffer(o.FRAMEBUFFER,i.glFramebuffer),h.glFramebuffer=i.glFramebuffer),h.viewport.left===HI.x&&h.viewport.top===HI.y&&h.viewport.width===HI.width&&h.viewport.height===HI.height||(o.viewport(HI.x,HI.y,HI.width,HI.height),h.viewport.left=HI.x,h.viewport.top=HI.y,h.viewport.width=HI.width,h.viewport.height=HI.height),h.scissorRect.x===HI.x&&h.scissorRect.y===HI.y&&h.scissorRect.width===HI.width&&h.scissorRect.height===HI.height||(o.scissor(HI.x,HI.y,HI.width,HI.height),h.scissorRect.x=HI.x,h.scissorRect.y=HI.y,h.scissorRect.width=HI.width,h.scissorRect.height=HI.height);var u=r.length;t.extensions.WEBGL_draw_buffers||(u=1);for(var c=0;c<u;++c){var d=e.colorAttachments[c];if(d.format!==_.UNKNOWN)switch(d.loadOp){case O.LOAD:break;case O.CLEAR:h.bs.targets[0].blendColorMask!==P.ALL&&o.colorMask(!0,!0,!0,!0);var f=r[0];o.clearColor(f.x,f.y,f.z,f.w),l|=o.COLOR_BUFFER_BIT;break;case O.DISCARD:}}if(e.depthStencilAttachment&&e.depthStencilAttachment.format!==_.UNKNOWN){switch(e.depthStencilAttachment.depthLoadOp){case O.LOAD:break;case O.CLEAR:h.dss.depthWrite||o.depthMask(!0),o.clearDepth(s),l|=o.DEPTH_BUFFER_BIT;break;case O.DISCARD:}if(ne[e.depthStencilAttachment.format].hasStencil)switch(e.depthStencilAttachment.stencilLoadOp){case O.LOAD:break;case O.CLEAR:h.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,65535),h.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,65535),o.clearStencil(a),l|=o.STENCIL_BUFFER_BIT;break;case O.DISCARD:}}if(l&&o.clear(l),l&o.COLOR_BUFFER_BIT){var p=h.bs.targets[0].blendColorMask;if(p!==P.ALL){var g=(p&P.R)!==P.NONE,m=(p&P.G)!==P.NONE,v=(p&P.B)!==P.NONE,y=(p&P.A)!==P.NONE;o.colorMask(g,m,v,y)}}l&o.DEPTH_BUFFER_BIT&&!h.dss.depthWrite&&o.depthMask(!1),l&o.STENCIL_BUFFER_BIT&&(h.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,0),h.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,0))}}function XI(t,e,i,n,r,s){var a,o,h,l=t.gl,u=t.stateCache,c=e&&e.gpuShader,d=!1;if(e&&VI.gpuPipelineState!==e){if(VI.gpuPipelineState=e,VI.glPrimitive=e.glPrimitive,e.gpuShader){var _=e.gpuShader.glProgram;u.glProgram!==_&&(l.useProgram(_),u.glProgram=_,d=!0)}var f=e.rs;if(f){if(u.rs.cullMode!==f.cullMode){switch(f.cullMode){case H.NONE:l.disable(l.CULL_FACE);break;case H.FRONT:l.enable(l.CULL_FACE),l.cullFace(l.FRONT);break;case H.BACK:l.enable(l.CULL_FACE),l.cullFace(l.BACK)}u.rs.cullMode=f.cullMode}var p=f.isFrontFaceCCW;u.rs.isFrontFaceCCW!==p&&(l.frontFace(p?l.CCW:l.CW),u.rs.isFrontFaceCCW=p),u.rs.depthBias===f.depthBias&&u.rs.depthBiasSlop===f.depthBiasSlop||(l.polygonOffset(f.depthBias,f.depthBiasSlop),u.rs.depthBias=f.depthBias,u.rs.depthBiasSlop=f.depthBiasSlop),u.rs.lineWidth!==f.lineWidth&&(l.lineWidth(f.lineWidth),u.rs.lineWidth=f.lineWidth)}var g=e.dss;g&&(u.dss.depthTest!==g.depthTest&&(g.depthTest?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),u.dss.depthTest=g.depthTest),u.dss.depthWrite!==g.depthWrite&&(l.depthMask(g.depthWrite),u.dss.depthWrite=g.depthWrite),u.dss.depthFunc!==g.depthFunc&&(l.depthFunc(EI[g.depthFunc]),u.dss.depthFunc=g.depthFunc),u.dss.stencilTestFront===g.stencilTestFront&&u.dss.stencilTestBack===g.stencilTestBack||(g.stencilTestFront||g.stencilTestBack?l.enable(l.STENCIL_TEST):l.disable(l.STENCIL_TEST),u.dss.stencilTestFront=g.stencilTestFront,u.dss.stencilTestBack=g.stencilTestBack),u.dss.stencilFuncFront===g.stencilFuncFront&&u.dss.stencilRefFront===g.stencilRefFront&&u.dss.stencilReadMaskFront===g.stencilReadMaskFront||(l.stencilFuncSeparate(l.FRONT,EI[g.stencilFuncFront],g.stencilRefFront,g.stencilReadMaskFront),u.dss.stencilFuncFront=g.stencilFuncFront,u.dss.stencilRefFront=g.stencilRefFront,u.dss.stencilReadMaskFront=g.stencilReadMaskFront),u.dss.stencilFailOpFront===g.stencilFailOpFront&&u.dss.stencilZFailOpFront===g.stencilZFailOpFront&&u.dss.stencilPassOpFront===g.stencilPassOpFront||(l.stencilOpSeparate(l.FRONT,AI[g.stencilFailOpFront],AI[g.stencilZFailOpFront],AI[g.stencilPassOpFront]),u.dss.stencilFailOpFront=g.stencilFailOpFront,u.dss.stencilZFailOpFront=g.stencilZFailOpFront,u.dss.stencilPassOpFront=g.stencilPassOpFront),u.dss.stencilWriteMaskFront!==g.stencilWriteMaskFront&&(l.stencilMaskSeparate(l.FRONT,g.stencilWriteMaskFront),u.dss.stencilWriteMaskFront=g.stencilWriteMaskFront),u.dss.stencilFuncBack===g.stencilFuncBack&&u.dss.stencilRefBack===g.stencilRefBack&&u.dss.stencilReadMaskBack===g.stencilReadMaskBack||(l.stencilFuncSeparate(l.BACK,EI[g.stencilFuncBack],g.stencilRefBack,g.stencilReadMaskBack),u.dss.stencilFuncBack=g.stencilFuncBack,u.dss.stencilRefBack=g.stencilRefBack,u.dss.stencilReadMaskBack=g.stencilReadMaskBack),u.dss.stencilFailOpBack===g.stencilFailOpBack&&u.dss.stencilZFailOpBack===g.stencilZFailOpBack&&u.dss.stencilPassOpBack===g.stencilPassOpBack||(l.stencilOpSeparate(l.BACK,AI[g.stencilFailOpBack],AI[g.stencilZFailOpBack],AI[g.stencilPassOpBack]),u.dss.stencilFailOpBack=g.stencilFailOpBack,u.dss.stencilZFailOpBack=g.stencilZFailOpBack,u.dss.stencilPassOpBack=g.stencilPassOpBack),u.dss.stencilWriteMaskBack!==g.stencilWriteMaskBack&&(l.stencilMaskSeparate(l.BACK,g.stencilWriteMaskBack),u.dss.stencilWriteMaskBack=g.stencilWriteMaskBack));var m=e.bs;if(m){u.bs.isA2C!==m.isA2C&&(m.isA2C?l.enable(l.SAMPLE_ALPHA_TO_COVERAGE):l.disable(l.SAMPLE_ALPHA_TO_COVERAGE),u.bs.isA2C=m.isA2C),u.bs.blendColor.x===m.blendColor.x&&u.bs.blendColor.y===m.blendColor.y&&u.bs.blendColor.z===m.blendColor.z&&u.bs.blendColor.w===m.blendColor.w||(l.blendColor(m.blendColor.x,m.blendColor.y,m.blendColor.z,m.blendColor.w),u.bs.blendColor.x=m.blendColor.x,u.bs.blendColor.y=m.blendColor.y,u.bs.blendColor.z=m.blendColor.z,u.bs.blendColor.w=m.blendColor.w);var v=m.targets[0],y=u.bs.targets[0];y.blend!==v.blend&&(v.blend?l.enable(l.BLEND):l.disable(l.BLEND),y.blend=v.blend),y.blendEq===v.blendEq&&y.blendAlphaEq===v.blendAlphaEq||(l.blendEquationSeparate(CI[v.blendEq],CI[v.blendAlphaEq]),y.blendEq=v.blendEq,y.blendAlphaEq=v.blendAlphaEq),y.blendSrc===v.blendSrc&&y.blendDst===v.blendDst&&y.blendSrcAlpha===v.blendSrcAlpha&&y.blendDstAlpha===v.blendDstAlpha||(l.blendFuncSeparate(RI[v.blendSrc],RI[v.blendDst],RI[v.blendSrcAlpha],RI[v.blendDstAlpha]),y.blendSrc=v.blendSrc,y.blendDst=v.blendDst,y.blendSrcAlpha=v.blendSrcAlpha,y.blendDstAlpha=v.blendDstAlpha),y.blendColorMask!==v.blendColorMask&&(l.colorMask((v.blendColorMask&P.R)!==P.NONE,(v.blendColorMask&P.G)!==P.NONE,(v.blendColorMask&P.B)!==P.NONE,(v.blendColorMask&P.A)!==P.NONE),y.blendColorMask=v.blendColorMask)}}if(e&&e.gpuPipelineLayout&&c){for(var T=c.glBlocks.length,S=e.gpuPipelineLayout.dynamicOffsetIndices,E=0;E<T;E++){var A=c.glBlocks[E],C=n[A.set],R=C&&C.descriptorIndices[A.binding],b=R>=0&&C.gpuDescriptors[R],x=null,w=0;if(b&&b.gpuBuffer){var M=b.gpuBuffer,I=S[A.set],B=I&&I[A.binding];B>=0&&(w=r[B]),"vf32"in M?x=M.vf32:(w+=M.offset,x=M.gpuBuffer.vf32),w>>=2}if(x)for(var D=A.glActiveUniforms.length,O=0;O<D;O++){var F=A.glActiveUniforms[O];switch(F.glType){case l.BOOL:case l.INT:for(var L=0;L<F.array.length;++L){var N=F.offset+w+L;if(x[N]!==F.array[L]){for(var k=L,U=N;k<F.array.length;++k,++U)F.array[k]=x[U];l.uniform1iv(F.glLoc,F.array);break}}break;case l.BOOL_VEC2:case l.INT_VEC2:for(var G=0;G<F.array.length;++G){var V=F.offset+w+G;if(x[V]!==F.array[G]){for(var X=G,W=V;X<F.array.length;++X,++W)F.array[X]=x[W];l.uniform2iv(F.glLoc,F.array);break}}break;case l.BOOL_VEC3:case l.INT_VEC3:for(var Y=0;Y<F.array.length;++Y){var j=F.offset+w+Y;if(x[j]!==F.array[Y]){for(var K=Y,q=j;K<F.array.length;++K,++q)F.array[K]=x[q];l.uniform3iv(F.glLoc,F.array);break}}break;case l.BOOL_VEC4:case l.INT_VEC4:for(var Z=0;Z<F.array.length;++Z){var Q=F.offset+w+Z;if(x[Q]!==F.array[Z]){for(var J=Z,$=Q;J<F.array.length;++J,++$)F.array[J]=x[$];l.uniform4iv(F.glLoc,F.array);break}}break;case l.FLOAT:for(var tt=0;tt<F.array.length;++tt){var et=F.offset+w+tt;if(x[et]!==F.array[tt]){for(var it=tt,nt=et;it<F.array.length;++it,++nt)F.array[it]=x[nt];l.uniform1fv(F.glLoc,F.array);break}}break;case l.FLOAT_VEC2:for(var rt=0;rt<F.array.length;++rt){var st=F.offset+w+rt;if(x[st]!==F.array[rt]){for(var at=rt,ot=st;at<F.array.length;++at,++ot)F.array[at]=x[ot];l.uniform2fv(F.glLoc,F.array);break}}break;case l.FLOAT_VEC3:for(var ht=0;ht<F.array.length;++ht){var lt=F.offset+w+ht;if(x[lt]!==F.array[ht]){for(var ut=ht,ct=lt;ut<F.array.length;++ut,++ct)F.array[ut]=x[ct];l.uniform3fv(F.glLoc,F.array);break}}break;case l.FLOAT_VEC4:for(var dt=0;dt<F.array.length;++dt){var _t=F.offset+w+dt;if(x[_t]!==F.array[dt]){for(var ft=dt,pt=_t;ft<F.array.length;++ft,++pt)F.array[ft]=x[pt];l.uniform4fv(F.glLoc,F.array);break}}break;case l.FLOAT_MAT2:for(var gt=0;gt<F.array.length;++gt){var mt=F.offset+w+gt;if(x[mt]!==F.array[gt]){for(var vt=gt,yt=mt;vt<F.array.length;++vt,++yt)F.array[vt]=x[yt];l.uniformMatrix2fv(F.glLoc,!1,F.array);break}}break;case l.FLOAT_MAT3:for(var Tt=0;Tt<F.array.length;++Tt){var St=F.offset+w+Tt;if(x[St]!==F.array[Tt]){for(var Et=Tt,At=St;Et<F.array.length;++Et,++At)F.array[Et]=x[At];l.uniformMatrix3fv(F.glLoc,!1,F.array);break}}break;case l.FLOAT_MAT4:for(var Ct=0;Ct<F.array.length;++Ct){var Rt=F.offset+w+Ct;if(x[Rt]!==F.array[Ct]){for(var bt=Ct,xt=Rt;bt<F.array.length;++bt,++xt)F.array[bt]=x[xt];l.uniformMatrix4fv(F.glLoc,!1,F.array);break}}}}else ks("Buffer binding '"+A.name+"' at set "+A.set+" binding "+A.binding+" is not bounded")}for(var wt=c.glSamplerTextures.length,Mt=0;Mt<wt;Mt++)for(var It=c.glSamplerTextures[Mt],Bt=n[It.set],Pt=Bt&&Bt.descriptorIndices[It.binding],Dt=Pt>=0&&Bt.gpuDescriptors[Pt],Ot=It.units.length,Ft=0;Ft<Ot;Ft++){var Lt=It.units[Ft];if(Dt&&Dt.gpuSampler){if(Dt.gpuTexture&&Dt.gpuTexture.size>0){var Nt=Dt.gpuTexture,kt=u.glTexUnits[Lt];kt.glTexture!==Nt.glTexture&&(u.texUnit!==Lt&&(l.activeTexture(l.TEXTURE0+Lt),u.texUnit=Lt),Nt.glTexture?l.bindTexture(Nt.glTarget,Nt.glTexture):l.bindTexture(Nt.glTarget,t.nullTex2D.gpuTexture.glTexture),kt.glTexture=Nt.glTexture);var Ut=Dt.gpuSampler;Nt.isPowerOf2?(a=Ut.glWrapS,o=Ut.glWrapT):(a=l.CLAMP_TO_EDGE,o=l.CLAMP_TO_EDGE),h=Nt.isPowerOf2?Nt.mipLevel<=1&&(Ut.glMinFilter===l.LINEAR_MIPMAP_NEAREST||Ut.glMinFilter===l.LINEAR_MIPMAP_LINEAR)?l.LINEAR:Ut.glMinFilter:Ut.glMinFilter===l.LINEAR||Ut.glMinFilter===l.LINEAR_MIPMAP_NEAREST||Ut.glMinFilter===l.LINEAR_MIPMAP_LINEAR?l.LINEAR:l.NEAREST,Nt.glWrapS!==a&&(u.texUnit!==Lt&&(l.activeTexture(l.TEXTURE0+Lt),u.texUnit=Lt),l.texParameteri(Nt.glTarget,l.TEXTURE_WRAP_S,a),Nt.glWrapS=a),Nt.glWrapT!==o&&(u.texUnit!==Lt&&(l.activeTexture(l.TEXTURE0+Lt),u.texUnit=Lt),l.texParameteri(Nt.glTarget,l.TEXTURE_WRAP_T,o),Nt.glWrapT=o),Nt.glMinFilter!==h&&(u.texUnit!==Lt&&(l.activeTexture(l.TEXTURE0+Lt),u.texUnit=Lt),l.texParameteri(Nt.glTarget,l.TEXTURE_MIN_FILTER,h),Nt.glMinFilter=h),Nt.glMagFilter!==Ut.glMagFilter&&(u.texUnit!==Lt&&(l.activeTexture(l.TEXTURE0+Lt),u.texUnit=Lt),l.texParameteri(Nt.glTarget,l.TEXTURE_MAG_FILTER,Ut.glMagFilter),Nt.glMagFilter=Ut.glMagFilter)}Dt=Bt.gpuDescriptors[++Pt]}else ks("Sampler binding '"+It.name+"' at set "+It.set+" binding "+It.binding+" index "+Ft+" is not bounded")}}if(i&&c&&(d||VI.gpuInputAssembler!==i)){VI.gpuInputAssembler=i;var Gt=t.extensions.ANGLE_instanced_arrays;if(t.extensions.useVAO){var Vt=t.extensions.OES_vertex_array_object,Ht=i.glVAOs.get(c.glProgram);if(!Ht){var zt;Ht=Vt.createVertexArrayOES(),i.glVAOs.set(c.glProgram,Ht),Vt.bindVertexArrayOES(Ht),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null),u.glArrayBuffer=null,u.glElementArrayBuffer=null;for(var Xt=c.glInputs.length,Wt=0;Wt<Xt;Wt++){var Yt=c.glInputs[Wt];zt=null;for(var jt=i.glAttribs.length,Kt=0;Kt<jt;Kt++){var qt=i.glAttribs[Kt];if(qt.name===Yt.name){zt=qt;break}}if(zt){u.glArrayBuffer!==zt.glBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,zt.glBuffer),u.glArrayBuffer=zt.glBuffer);for(var Zt=0;Zt<zt.componentCount;++Zt){var Qt=Yt.glLoc+Zt,Jt=zt.offset+zt.size*Zt;l.enableVertexAttribArray(Qt),u.glCurrentAttribLocs[Qt]=!0,l.vertexAttribPointer(Qt,zt.count,zt.glType,zt.isNormalized,zt.stride,Jt),Gt&&Gt.vertexAttribDivisorANGLE(Qt,zt.isInstanced?1:0)}}}var $t=i.gpuIndexBuffer;$t&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,$t.glBuffer),Vt.bindVertexArrayOES(null),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null),u.glArrayBuffer=null,u.glElementArrayBuffer=null}u.glVAO!==Ht&&(Vt.bindVertexArrayOES(Ht),u.glVAO=Ht)}else{for(var te=0;te<t.capabilities.maxVertexAttributes;++te)u.glCurrentAttribLocs[te]=!1;for(var ee=c.glInputs.length,ie=0;ie<ee;ie++){for(var ne=c.glInputs[ie],re=null,se=i.glAttribs.length,ae=0;ae<se;ae++){var oe=i.glAttribs[ae];if(oe.name===ne.name){re=oe;break}}if(re){u.glArrayBuffer!==re.glBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,re.glBuffer),u.glArrayBuffer=re.glBuffer);for(var he=0;he<re.componentCount;++he){var le=ne.glLoc+he,ue=re.offset+re.size*he;!u.glEnabledAttribLocs[le]&&le>=0&&(l.enableVertexAttribArray(le),u.glEnabledAttribLocs[le]=!0),u.glCurrentAttribLocs[le]=!0,l.vertexAttribPointer(le,re.count,re.glType,re.isNormalized,re.stride,ue),Gt&&Gt.vertexAttribDivisorANGLE(le,re.isInstanced?1:0)}}}var ce=i.gpuIndexBuffer;ce&&u.glElementArrayBuffer!==ce.glBuffer&&(l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,ce.glBuffer),u.glElementArrayBuffer=ce.glBuffer);for(var de=0;de<t.capabilities.maxVertexAttributes;++de)u.glEnabledAttribLocs[de]!==u.glCurrentAttribLocs[de]&&(l.disableVertexAttribArray(de),u.glEnabledAttribLocs[de]=!1)}}if(e&&e.dynamicStates.length)for(var _e=e.dynamicStates.length,fe=0;fe<_e;fe++)switch(e.dynamicStates[fe]){case z.LINE_WIDTH:u.rs.lineWidth!==s.lineWidth&&(l.lineWidth(s.lineWidth),u.rs.lineWidth=s.lineWidth);break;case z.DEPTH_BIAS:u.rs.depthBias===s.depthBiasConstant&&u.rs.depthBiasSlop===s.depthBiasSlope||(l.polygonOffset(s.depthBiasConstant,s.depthBiasSlope),u.rs.depthBias=s.depthBiasConstant,u.rs.depthBiasSlop=s.depthBiasSlope);break;case z.BLEND_CONSTANTS:var pe=s.blendConstant;u.bs.blendColor.x===pe.x&&u.bs.blendColor.y===pe.y&&u.bs.blendColor.z===pe.z&&u.bs.blendColor.w===pe.w||(l.blendColor(pe.x,pe.y,pe.z,pe.w),u.bs.blendColor.copy(pe));break;case z.STENCIL_WRITE_MASK:var ge=s.stencilStatesFront,me=s.stencilStatesBack;u.dss.stencilWriteMaskFront!==ge.writeMask&&(l.stencilMaskSeparate(l.FRONT,ge.writeMask),u.dss.stencilWriteMaskFront=ge.writeMask),u.dss.stencilWriteMaskBack!==me.writeMask&&(l.stencilMaskSeparate(l.BACK,me.writeMask),u.dss.stencilWriteMaskBack=me.writeMask);break;case z.STENCIL_COMPARE_MASK:var ve=s.stencilStatesFront,ye=s.stencilStatesBack;u.dss.stencilRefFront===ve.reference&&u.dss.stencilReadMaskFront===ve.compareMask||(l.stencilFuncSeparate(l.FRONT,EI[u.dss.stencilFuncFront],ve.reference,ve.compareMask),u.dss.stencilRefFront=ve.reference,u.dss.stencilReadMaskFront=ve.compareMask),u.dss.stencilRefBack===ye.reference&&u.dss.stencilReadMaskBack===ye.compareMask||(l.stencilFuncSeparate(l.BACK,EI[u.dss.stencilFuncBack],ye.reference,ye.compareMask),u.dss.stencilRefBack=ye.reference,u.dss.stencilReadMaskBack=ye.compareMask)}}function WI(t,e){var i=t.gl,n=t.extensions,r=n.ANGLE_instanced_arrays,s=n.WEBGL_multi_draw,a=VI.gpuInputAssembler,o=VI.glPrimitive;if(a){var h=a.gpuIndexBuffer;if(a.gpuIndirectBuffer){var l=a.gpuIndirectBuffer.indirects;if(l.drawByIndex){for(var u=0;u<l.drawCount;u++)l.byteOffsets[u]=l.offsets[u]*h.stride;if(s)l.instancedDraw?s.multiDrawElementsInstancedWEBGL(o,l.counts,0,a.glIndexType,l.byteOffsets,0,l.instances,0,l.drawCount):s.multiDrawElementsWEBGL(o,l.counts,0,a.glIndexType,l.byteOffsets,0,l.drawCount);else for(var c=0;c<l.drawCount;c++)l.instances[c]&&r?r.drawElementsInstancedANGLE(o,l.counts[c],a.glIndexType,l.byteOffsets[c],l.instances[c]):i.drawElements(o,l.counts[c],a.glIndexType,l.byteOffsets[c])}else if(s)l.instancedDraw?s.multiDrawArraysInstancedWEBGL(o,l.offsets,0,l.counts,0,l.instances,0,l.drawCount):s.multiDrawArraysWEBGL(o,l.offsets,0,l.counts,0,l.drawCount);else for(var d=0;d<l.drawCount;d++)l.instances[d]&&r?r.drawArraysInstancedANGLE(o,l.offsets[d],l.counts[d],l.instances[d]):i.drawArrays(o,l.offsets[d],l.counts[d])}else if(e.instanceCount&&r)if(h){if(e.indexCount>0){var _=e.firstIndex*h.stride;r.drawElementsInstancedANGLE(o,e.indexCount,a.glIndexType,_,e.instanceCount)}}else e.vertexCount>0&&r.drawArraysInstancedANGLE(o,e.firstVertex,e.vertexCount,e.instanceCount);else if(h){if(e.indexCount>0){var f=e.firstIndex*h.stride;i.drawElements(o,e.indexCount,a.glIndexType,f)}}else e.vertexCount>0&&i.drawArrays(o,e.firstVertex,e.vertexCount)}}var YI=new Array(SI.COUNT);function jI(t,e){YI.fill(0);for(var i=0;i<e.cmds.length;++i){var n=e.cmds.array[i],r=YI[n]++;switch(n){case SI.BEGIN_RENDER_PASS:var s=e.beginRenderPassCmds.array[r];zI(t,s.gpuRenderPass,s.gpuFramebuffer,s.renderArea,s.clearColors,s.clearDepth,s.clearStencil);break;case SI.BIND_STATES:var a=e.bindStatesCmds.array[r];XI(t,a.gpuPipelineState,a.gpuInputAssembler,a.gpuDescriptorSets,a.dynamicOffsets,a.dynamicStates);break;case SI.DRAW:WI(t,e.drawCmds.array[r].drawInfo);break;case SI.UPDATE_BUFFER:var o=e.updateBufferCmds.array[r];LI(t,o.gpuBuffer,o.buffer,o.offset,o.size);break;case SI.COPY_BUFFER_TO_TEXTURE:var h=e.copyBufferToTextureCmds.array[r];ZI(t,h.buffers,h.gpuTexture,h.regions);break;case SI.BLIT_TEXTURE:var l=e.blitTextureCmds.array[r];QI(t,l.srcTexture,l.dstTexture,l.regions,l.filter)}}}var KI=new Uint8Array(1);function qI(t,e,i,n,r){var s=_e(e).height,a=le(e,r.width,r.height,r.depth),o=le(e,n.width,1,1),h=le(e,n.width,n.height,1),l=le(e,r.width,1,1),u=de(ne[e]);KI.byteLength<a&&(KI=new Uint8Array(a));for(var c=0,d=i,_=0;_<r.depth;_++){d=i+h*_;for(var f=0;f<r.height;f+=s)KI.subarray(c,c+l).set(new Uint8Array(t.buffer,t.byteOffset+d,l)),c+=l,d+=o}return new u(KI.buffer)}function ZI(t,e,i,n){var r=t.gl,s=t.stateCache.glTexUnits[t.stateCache.texUnit];s.glTexture!==i.glTexture&&(r.bindTexture(i.glTarget,i.glTexture),s.glTexture=i.glTexture);var a=0,o=0,h=ne[i.format],l=de(h),u=h.isCompressed,c=_e(i.format),d=new nt,_=new et,f=new nt;switch(i.glTarget){case r.TEXTURE_2D:for(var p=0;p<n.length;p++){var g=n[p],m=g.texSubres.mipLevel;_.x=0===g.texOffset.x?0:fe(g.texOffset.x,c.width),_.y=0===g.texOffset.y?0:fe(g.texOffset.y,c.height),d.width=g.texExtent.width<c.width?g.texExtent.width:fe(g.texExtent.width,c.width),d.height=g.texExtent.height<c.height?g.texExtent.width:fe(g.texExtent.height,c.height),f.width=g.buffStride>0?g.buffStride:d.width,f.height=g.buffTexHeight>0?g.buffTexHeight:d.height;var v,y=g.texExtent.width+_.x===i.width>>m?g.texExtent.width:d.width,T=g.texExtent.height+_.y===i.height>>m?g.texExtent.height:d.height,S=e[a++];v=f.width===d.width&&f.height===d.height?new l(S.buffer,S.byteOffset+g.buffOffset):qI(S,i.format,g.buffOffset,f,d),u?i.glInternalFmt===dI.COMPRESSED_RGB_ETC1_WEBGL||t.extensions.noCompressedTexSubImage2D?r.compressedTexImage2D(r.TEXTURE_2D,m,i.glInternalFmt,y,T,0,v):r.compressedTexSubImage2D(r.TEXTURE_2D,m,_.x,_.y,y,T,i.glFormat,v):r.texSubImage2D(r.TEXTURE_2D,m,_.x,_.y,y,T,i.glFormat,i.glType,v)}break;case r.TEXTURE_CUBE_MAP:for(var A=0;A<n.length;A++){var C=n[A],R=C.texSubres.mipLevel;_.x=0===C.texOffset.x?0:fe(C.texOffset.x,c.width),_.y=0===C.texOffset.y?0:fe(C.texOffset.y,c.height),d.width=C.texExtent.width<c.width?C.texExtent.width:fe(C.texExtent.width,c.width),d.height=C.texExtent.height<c.height?C.texExtent.width:fe(C.texExtent.height,c.height),f.width=C.buffStride>0?C.buffStride:d.width,f.height=C.buffTexHeight>0?C.buffTexHeight:d.height;var b=C.texExtent.width+_.x===i.width>>R?C.texExtent.width:d.width,x=C.texExtent.height+_.y===i.height>>R?C.texExtent.height:d.height,w=C.texSubres.baseArrayLayer+C.texSubres.layerCount;for(o=C.texSubres.baseArrayLayer;o<w;++o){var M,I=e[a++];M=f.width===d.width&&f.height===d.height?new l(I.buffer,I.byteOffset+C.buffOffset):qI(I,i.format,C.buffOffset,f,d),u?i.glInternalFmt===dI.COMPRESSED_RGB_ETC1_WEBGL||t.extensions.noCompressedTexSubImage2D?r.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,R,i.glInternalFmt,b,x,0,M):r.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,R,_.x,_.y,b,x,i.glFormat,M):r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,R,_.x,_.y,b,x,i.glFormat,i.glType,M)}}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&E.GEN_MIPMAP&&r.generateMipmap(i.glTarget)}function QI(t,e,i,n,r){t.blitManager.draw(e,i,n,r)}var JI=function(){function t(){this.counts=void 0,this.offsets=void 0,this.instances=void 0,this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1,this.byteOffsets=void 0,this._capacity=4,this.counts=new Int32Array(this._capacity),this.offsets=new Int32Array(this._capacity),this.instances=new Int32Array(this._capacity),this.byteOffsets=new Int32Array(this._capacity)}var e=t.prototype;return e.clearDraws=function(){this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1},e.setDrawInfo=function(t,e){this._ensureCapacity(t),this.drawByIndex=e.indexCount>0,this.instancedDraw=!!e.instanceCount,this.drawCount=Math.max(t+1,this.drawCount),this.drawByIndex?(this.counts[t]=e.indexCount,this.offsets[t]=e.firstIndex):(this.counts[t]=e.vertexCount,this.offsets[t]=e.firstVertex),this.instances[t]=Math.max(1,e.instanceCount)},e._ensureCapacity=function(t){if(!(this._capacity>t)){this._capacity=Vi(t);var e=new Int32Array(this._capacity),i=new Int32Array(this._capacity),n=new Int32Array(this._capacity);this.byteOffsets=new Int32Array(this._capacity),e.set(this.counts),i.set(this.offsets),n.set(this.instances),this.counts=e,this.offsets=i,this.instances=n}},t}(),$I=function(){function t(){this._gpuShader=null,this._gpuDescriptorSetLayout=null,this._gpuPipelineLayout=null,this._gpuPipelineState=null,this._gpuVertexBuffer=null,this._gpuInputAssembler=null,this._gpuPointSampler=null,this._gpuLinearSampler=null,this._gpuDescriptorSet=null,this._gpuUniformBuffer=null,this._drawInfo=null,this._glFramebuffer=null,this._uniformBuffer=null;var t=fI.instance.gl,e=fI.instance.bindingMappingInfo.maxBlockCounts[0];this._gpuShader={name:"Blit Pass",blocks:[new At(0,0,"BlitParams",[new Et("tilingOffsetSrc",p.FLOAT4,1),new Et("tilingOffsetDst",p.FLOAT4,1)],1)],samplerTextures:[new Ct(0,e,"textureSrc",p.SAMPLER2D,1)],subpassInputs:[],gpuStages:[{type:D.VERTEX,source:"\n precision mediump float;\n\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n \n uniform vec4 tilingOffsetSrc;\n uniform vec4 tilingOffsetDst;\n \n varying vec2 v_texCoord;\n \n void main() {\n v_texCoord = a_texCoord * tilingOffsetSrc.xy + tilingOffsetSrc.zw;\n gl_Position = vec4((a_position + 1.0) * tilingOffsetDst.xy - 1.0 + tilingOffsetDst.zw * 2.0, 0, 1);\n }",glShader:null},{type:D.FRAGMENT,source:"\n precision mediump float;\n uniform sampler2D textureSrc;\n\n varying vec2 v_texCoord;\n \n void main() {\n gl_FragColor = texture2D(textureSrc, v_texCoord);\n }",glShader:null}],glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplerTextures:[]},NI(fI.instance,this._gpuShader),this._gpuDescriptorSetLayout={bindings:[new zt(0,W.UNIFORM_BUFFER,1,D.VERTEX),new zt(e,W.SAMPLER_TEXTURE,1,D.FRAGMENT)],dynamicBindings:[],descriptorIndices:[],descriptorCount:e+1};for(var i=0;i<e;i++)this._gpuDescriptorSetLayout.descriptorIndices[i]=0;this._gpuDescriptorSetLayout.descriptorIndices.push(1),this._gpuPipelineLayout={gpuSetLayouts:[this._gpuDescriptorSetLayout],dynamicOffsetCount:0,dynamicOffsetOffsets:[0],dynamicOffsetIndices:[[]]},this._gpuPipelineState={glPrimitive:t.TRIANGLE_STRIP,gpuShader:this._gpuShader,gpuPipelineLayout:this._gpuPipelineLayout,rs:null,dss:new Ae(!1,!1),bs:null,dynamicStates:[],gpuRenderPass:null},this._gpuVertexBuffer={usage:g.VERTEX,memUsage:y.DEVICE,size:16*Float32Array.BYTES_PER_ELEMENT,stride:4*Float32Array.BYTES_PER_ELEMENT,buffer:null,vf32:null,indirects:new JI,glTarget:0,glBuffer:null},OI(fI.instance,this._gpuVertexBuffer),fI.instance.memoryStatus.bufferSize+=this._gpuVertexBuffer.size;var n=new Float32Array([-1,-1,0,0,1,-1,1,0,-1,1,0,1,1,1,1,1]);LI(fI.instance,this._gpuVertexBuffer,n,0,n.length),this._gpuInputAssembler={attributes:[new Bt("a_position",_.RG32F),new Bt("a_texCoord",_.RG32F)],gpuVertexBuffers:[this._gpuVertexBuffer],gpuIndexBuffer:null,gpuIndirectBuffer:null,glAttribs:[],glIndexType:0,glVAOs:new Map},UI(fI.instance,this._gpuInputAssembler),this._gpuPointSampler={glMinFilter:9728,glMagFilter:9728,glWrapS:10497,glWrapT:10497,glWrapR:10497},this._gpuLinearSampler={glMinFilter:9729,glMagFilter:9729,glWrapS:10497,glWrapT:10497,glWrapR:10497},this._uniformBuffer=new Float32Array(8),this._gpuUniformBuffer={usage:g.UNIFORM,memUsage:y.DEVICE,size:8*Float32Array.BYTES_PER_ELEMENT,stride:8*Float32Array.BYTES_PER_ELEMENT,buffer:this._uniformBuffer,vf32:null,indirects:new JI,glTarget:0,glBuffer:null},OI(fI.instance,this._gpuUniformBuffer),fI.instance.memoryStatus.bufferSize+=this._gpuUniformBuffer.size,this._gpuDescriptorSet={gpuDescriptors:[{type:W.UNIFORM_BUFFER,gpuBuffer:this._gpuUniformBuffer,gpuTexture:null,gpuSampler:null},{type:W.SAMPLER_TEXTURE,gpuBuffer:null,gpuTexture:null,gpuSampler:null}],descriptorIndices:this._gpuDescriptorSetLayout.descriptorIndices},this._drawInfo=new gt(4,0,0,0,0,0,0),this._glFramebuffer=fI.instance.gl.createFramebuffer()}var e=t.prototype;return e.destroy=function(){this._glFramebuffer&&(fI.instance.gl.deleteFramebuffer(this._glFramebuffer),this._glFramebuffer=null),this._gpuVertexBuffer&&(fI.instance.memoryStatus.bufferSize-=this._gpuVertexBuffer.size,FI(fI.instance,this._gpuVertexBuffer)),this._gpuUniformBuffer&&(fI.instance.memoryStatus.bufferSize-=this._gpuUniformBuffer.size,FI(fI.instance,this._gpuUniformBuffer)),this._gpuShader&&kI(fI.instance,this._gpuShader),this._gpuInputAssembler&&GI(fI.instance,this._gpuInputAssembler)},e.draw=function(t,e,i,n){var r=fI.instance,s=r.gl,a=r.stateCache,o=a.glFramebuffer;if(s.viewport(0,0,e.width,e.height),s.scissor(0,0,e.width,e.height),this._uniformBuffer&&this._gpuUniformBuffer&&this._gpuPipelineState&&this._gpuInputAssembler&&this._gpuDescriptorSet&&this._drawInfo){var h=this._gpuDescriptorSet.gpuDescriptors[1];h.gpuTexture=t,h.gpuSampler=n===b.POINT?this._gpuPointSampler:this._gpuLinearSampler;var l=ne[e.format],u=s.COLOR_ATTACHMENT0;l.hasStencil?u=s.DEPTH_STENCIL_ATTACHMENT:l.hasDepth&&(u=s.DEPTH_ATTACHMENT);var c=i.map((function(t,e){return e}));c.sort((function(t,e){return i[t].srcSubres.mipLevel-i[e].srcSubres.mipLevel})),a.glFramebuffer!==this._glFramebuffer&&(r.gl.bindFramebuffer(r.gl.FRAMEBUFFER,this._glFramebuffer),a.glFramebuffer=this._glFramebuffer);var d=i[0].dstSubres.mipLevel;e.glTexture?s.framebufferTexture2D(s.FRAMEBUFFER,u,e.glTarget,e.glTexture,d):s.framebufferRenderbuffer(s.FRAMEBUFFER,u,s.RENDERBUFFER,e.glRenderbuffer);for(var _=0;_<c.length;++_){var f=i[c[_]];t.glTexture&&d!==f.srcSubres.mipLevel&&(d=f.srcSubres.mipLevel,s.framebufferTexture2D(s.FRAMEBUFFER,u,e.glTarget,e.glTexture,d));var p=t.width,g=t.height,m=e.width,v=e.height;this._uniformBuffer[0]=f.srcExtent.width/p,this._uniformBuffer[1]=f.srcExtent.height/g,this._uniformBuffer[2]=f.srcOffset.x/p,this._uniformBuffer[3]=f.srcOffset.y/g,this._uniformBuffer[4]=f.dstExtent.width/m,this._uniformBuffer[5]=f.dstExtent.height/v,this._uniformBuffer[6]=f.dstOffset.x/m,this._uniformBuffer[7]=f.dstOffset.y/v,LI(r,this._gpuUniformBuffer,this._uniformBuffer,0,this._uniformBuffer.length*Float32Array.BYTES_PER_ELEMENT),XI(r,this._gpuPipelineState,this._gpuInputAssembler,[this._gpuDescriptorSet],[],null),WI(r,this._drawInfo)}a.glFramebuffer!==o&&(r.gl.bindFramebuffer(r.gl.FRAMEBUFFER,o),a.glFramebuffer=o);var y=a.viewport;s.viewport(y.left,y.top,y.width,y.height);var T=a.scissorRect;s.scissor(T.x,T.y,T.width,T.height)}},t}(),tB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuBuffer=null,e._gpuBufferView=null,e._uniformBuffer=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){if("buffer"in t){this._isBufferView=!0;var e=t.buffer;this._usage=e.usage,this._memUsage=e.memUsage,this._size=this._stride=t.range,this._count=1,this._flags=e.flags,this._gpuBufferView={gpuBuffer:e.gpuBuffer,offset:t.offset,range:t.range}}else this._usage=t.usage,this._memUsage=t.memUsage,this._size=t.size,this._stride=Math.max(t.stride||this._size,1),this._count=this._size/this._stride,this._flags=t.flags,this._usage&g.UNIFORM&&this._size>0&&(this._uniformBuffer=new Uint8Array(this._size)),this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,vf32:null,indirects:new JI,glTarget:0,glBuffer:null},this._usage&g.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),OI(fI.instance,this._gpuBuffer),fI.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(FI(fI.instance,this._gpuBuffer),fI.instance.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null)},i.resize=function(t){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var e,i,n,r,s,a=this._size;a!==t&&(this._size=t,this._count=this._size/this._stride,this._uniformBuffer&&(this._uniformBuffer=new Uint8Array(t)),this._gpuBuffer&&(this._uniformBuffer&&(this._gpuBuffer.buffer=this._uniformBuffer),this._gpuBuffer.size=t,t>0&&(e=fI.instance,i=this._gpuBuffer,n=e.gl,r=e.stateCache,s=i.memUsage&y.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW,i.usage&g.VERTEX?(e.extensions.useVAO&&r.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),r.glVAO=null),VI.gpuInputAssembler=null,e.stateCache.glArrayBuffer!==i.glBuffer&&n.bindBuffer(n.ARRAY_BUFFER,i.glBuffer),i.buffer?n.bufferData(n.ARRAY_BUFFER,i.buffer,s):n.bufferData(n.ARRAY_BUFFER,i.size,s),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null):i.usage&g.INDEX?(e.extensions.useVAO&&r.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),r.glVAO=null),VI.gpuInputAssembler=null,e.stateCache.glElementArrayBuffer!==i.glBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i.glBuffer),i.buffer?n.bufferData(n.ELEMENT_ARRAY_BUFFER,i.buffer,s):n.bufferData(n.ELEMENT_ARRAY_BUFFER,i.size,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):i.usage&g.UNIFORM?i.buffer&&(i.vf32=new Float32Array(i.buffer.buffer)):(i.usage&g.INDIRECT||i.usage&g.TRANSFER_DST||i.usage&g.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),i.glTarget=n.NONE),fI.instance.memoryStatus.bufferSize-=a,fI.instance.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?console.warn("cannot update through buffer views!"):(i=void 0!==e?e:this._usage&g.INDIRECT?0:t.byteLength,LI(fI.instance,this._gpuBuffer,t,0,i))},Pi(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),e}(a),eB=function(){function t(t,e){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(e),this._freeCmds=new n(e);for(var i=0;i<e;++i)this._frees[i]=new t;this._freeIdx=e-1}var e=t.prototype;return e.alloc=function(t){if(this._freeIdx<0){var e=2*this._frees.length,i=this._frees;this._frees=new Array(e);for(var n=e-i.length,r=0;r<n;++r)this._frees[r]=new t;for(var s=n,a=0;s<e;++s,++a)this._frees[s]=i[a];this._freeIdx+=n}var o=this._frees[this._freeIdx];return this._frees[this._freeIdx--]=null,++o.refCount,o},e.free=function(t){0==--t.refCount&&this._freeCmds.push(t)},e.freeCmds=function(t){for(var e=0;e<t.length;++e)0==--t.array[e].refCount&&this._freeCmds.push(t.array[e])},e.release=function(){for(var t=0;t<this._freeCmds.length;++t){var e=this._freeCmds.array[t];e.clear(),this._frees[++this._freeIdx]=e}this._freeCmds.clear()},t}(),iB=function(){function t(){this.beginRenderPassCmdPool=void 0,this.bindStatesCmdPool=void 0,this.drawCmdPool=void 0,this.updateBufferCmdPool=void 0,this.copyBufferToTextureCmdPool=void 0,this.blitTextureCmdPool=void 0,this.beginRenderPassCmdPool=new eB(xI,1),this.bindStatesCmdPool=new eB(wI,1),this.drawCmdPool=new eB(MI,1),this.updateBufferCmdPool=new eB(II,1),this.copyBufferToTextureCmdPool=new eB(BI,1),this.blitTextureCmdPool=new eB(PI,1)}var e=t.prototype;return e.clearCmds=function(t){t.beginRenderPassCmds.length&&(this.beginRenderPassCmdPool.freeCmds(t.beginRenderPassCmds),t.beginRenderPassCmds.clear()),t.bindStatesCmds.length&&(this.bindStatesCmdPool.freeCmds(t.bindStatesCmds),t.bindStatesCmds.clear()),t.drawCmds.length&&(this.drawCmdPool.freeCmds(t.drawCmds),t.drawCmds.clear()),t.updateBufferCmds.length&&(this.updateBufferCmdPool.freeCmds(t.updateBufferCmds),t.updateBufferCmds.clear()),t.copyBufferToTextureCmds.length&&(this.copyBufferToTextureCmdPool.freeCmds(t.copyBufferToTextureCmds),t.copyBufferToTextureCmds.clear()),t.blitTextureCmds.length&&(this.blitTextureCmdPool.freeCmds(t.blitTextureCmds),t.blitTextureCmds.clear()),t.cmds.clear()},e.releaseCmds=function(){this.beginRenderPassCmdPool.release(),this.bindStatesCmdPool.release(),this.drawCmdPool.release(),this.updateBufferCmdPool.release(),this.copyBufferToTextureCmdPool.release(),this.blitTextureCmdPool.release()},t}(),nB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).cmdPackage=new DI,e._cmdAllocator=new iB,e._isInRenderPass=!1,e._curGPUPipelineState=null,e._curGPUInputAssembler=null,e._curGPUDescriptorSets=[],e._curDynamicOffsets=Array(8).fill(0),e._curDynamicStates=new te,e._isStateInvalied=!1,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type,this._queue=t.queue;for(var e=fI.instance.bindingMappings.blockOffsets.length,i=0;i<e;i++)this._curGPUDescriptorSets.push(null)},i.destroy=function(){this._cmdAllocator.clearCmds(this.cmdPackage)},i.begin=function(){this._cmdAllocator.clearCmds(this.cmdPackage),this._curGPUPipelineState=null,this._curGPUInputAssembler=null,this._curGPUDescriptorSets.length=0,this._numDrawCalls=0,this._numInstances=0,this._numTris=0},i.end=function(){this._isStateInvalied&&this.bindStates(),this._isInRenderPass=!1},i.beginRenderPass=function(t,e,i,n,r,s){var a=this._cmdAllocator.beginRenderPassCmdPool.alloc(xI);a.gpuRenderPass=t.gpuRenderPass,a.gpuFramebuffer=e.gpuFramebuffer,a.renderArea.copy(i),a.clearColors.length=n.length;for(var o=0;o<n.length;++o)a.clearColors[o]=n[o];a.clearDepth=r,a.clearStencil=s,this.cmdPackage.beginRenderPassCmds.push(a),this.cmdPackage.cmds.push(SI.BEGIN_RENDER_PASS),this._isInRenderPass=!0},i.endRenderPass=function(){this._isInRenderPass=!1},i.bindPipelineState=function(t){var e=t.gpuPipelineState;e!==this._curGPUPipelineState&&(this._curGPUPipelineState=e,this._isStateInvalied=!0)},i.bindDescriptorSet=function(t,e,i){var n=e.gpuDescriptorSet;if(n!==this._curGPUDescriptorSets[t]&&(this._curGPUDescriptorSets[t]=n,this._isStateInvalied=!0),i){var r,s=null===(r=this._curGPUPipelineState)||void 0===r?void 0:r.gpuPipelineLayout;if(s){for(var a=this._curDynamicOffsets,o=s.dynamicOffsetOffsets[t],h=0;h<i.length;h++)a[o+h]=i[h];this._isStateInvalied=!0}}},i.bindInputAssembler=function(t){var e=t.gpuInputAssembler;this._curGPUInputAssembler=e,this._isStateInvalied=!0},i.setViewport=function(t){var e=this._curDynamicStates.viewport;e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height&&e.minDepth===t.minDepth&&e.maxDepth===t.maxDepth||(e.left=t.left,e.top=t.top,e.width=t.width,e.height=t.height,e.minDepth=t.minDepth,e.maxDepth=t.maxDepth,this._isStateInvalied=!0)},i.setScissor=function(t){var e=this._curDynamicStates.scissor;e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,this._isStateInvalied=!0)},i.setLineWidth=function(t){this._curDynamicStates.lineWidth!==t&&(this._curDynamicStates.lineWidth=t,this._isStateInvalied=!0)},i.setDepthBias=function(t,e,i){var n=this._curDynamicStates;n.depthBiasConstant===t&&n.depthBiasClamp===e&&n.depthBiasSlope===i||(n.depthBiasConstant=t,n.depthBiasClamp=e,n.depthBiasSlope=i,this._isStateInvalied=!0)},i.setBlendConstants=function(t){var e=this._curDynamicStates.blendConstant;e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w||(e.copy(t),this._isStateInvalied=!0)},i.setDepthBound=function(t,e){var i=this._curDynamicStates;i.depthMinBounds===t&&i.depthMaxBounds===e||(i.depthMinBounds=t,i.depthMaxBounds=e,this._isStateInvalied=!0)},i.setStencilWriteMask=function(t,e){var i=this._curDynamicStates.stencilStatesFront,n=this._curDynamicStates.stencilStatesBack;t&X.FRONT&&i.writeMask!==e&&(i.writeMask=e,this._isStateInvalied=!0),t&X.BACK&&n.writeMask!==e&&(n.writeMask=e,this._isStateInvalied=!0)},i.setStencilCompareMask=function(t,e,i){var n=this._curDynamicStates.stencilStatesFront,r=this._curDynamicStates.stencilStatesBack;t&X.FRONT&&(n.compareMask===i&&n.reference===e||(n.reference=e,n.compareMask=i,this._isStateInvalied=!0)),t&X.BACK&&(r.compareMask===i&&r.reference===e||(r.reference=e,r.compareMask=i,this._isStateInvalied=!0))},i.draw=function(t){if(this._type===K.PRIMARY&&this._isInRenderPass||this._type===K.SECONDARY){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t,i=this._cmdAllocator.drawCmdPool.alloc(MI);i.drawInfo.copy(e),this.cmdPackage.drawCmds.push(i),this.cmdPackage.cmds.push(SI.DRAW),++this._numDrawCalls,this._numInstances+=e.instanceCount;var n=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=n/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(n-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.updateBuffer=function(t,e,i){if(this._type===K.PRIMARY&&!this._isInRenderPass||this._type===K.SECONDARY){var n=t.gpuBuffer;if(n){var r,s=this._cmdAllocator.updateBufferCmdPool.alloc(II),a=0;t.usage&g.INDIRECT||(a=void 0!==i?i:e.byteLength),r=e,s.gpuBuffer=n,s.buffer=r,s.offset=0,s.size=a,this.cmdPackage.updateBufferCmds.push(s),this.cmdPackage.cmds.push(SI.UPDATE_BUFFER)}}else console.error("Command 'updateBuffer' must be recorded outside a render pass.")},i.copyBuffersToTexture=function(t,e,i){if(this._type===K.PRIMARY&&!this._isInRenderPass||this._type===K.SECONDARY){var n=e.gpuTexture;if(n){var r=this._cmdAllocator.copyBufferToTextureCmdPool.alloc(BI);r&&(r.gpuTexture=n,r.regions=i,r.buffers=t,this.cmdPackage.copyBufferToTextureCmds.push(r),this.cmdPackage.cmds.push(SI.COPY_BUFFER_TO_TEXTURE))}}else console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.")},i.execute=function(t,e){for(var i=0;i<e;++i){for(var n=t[i],r=0;r<n.cmdPackage.beginRenderPassCmds.length;++r){var s=n.cmdPackage.beginRenderPassCmds.array[r];++s.refCount,this.cmdPackage.beginRenderPassCmds.push(s)}for(var a=0;a<n.cmdPackage.bindStatesCmds.length;++a){var o=n.cmdPackage.bindStatesCmds.array[a];++o.refCount,this.cmdPackage.bindStatesCmds.push(o)}for(var h=0;h<n.cmdPackage.drawCmds.length;++h){var l=n.cmdPackage.drawCmds.array[h];++l.refCount,this.cmdPackage.drawCmds.push(l)}for(var u=0;u<n.cmdPackage.updateBufferCmds.length;++u){var c=n.cmdPackage.updateBufferCmds.array[u];++c.refCount,this.cmdPackage.updateBufferCmds.push(c)}for(var d=0;d<n.cmdPackage.copyBufferToTextureCmds.length;++d){var _=n.cmdPackage.copyBufferToTextureCmds.array[d];++_.refCount,this.cmdPackage.copyBufferToTextureCmds.push(_)}for(var f=0;f<n.cmdPackage.blitTextureCmds.length;++f){var p=n.cmdPackage.blitTextureCmds.array[f];++p.refCount,this.cmdPackage.blitTextureCmds.push(p)}this.cmdPackage.cmds.concat(n.cmdPackage.cmds.array),this._numDrawCalls+=n._numDrawCalls,this._numInstances+=n._numInstances,this._numTris+=n._numTris}},i.pipelineBarrier=function(){},i.bindStates=function(){var t=this._cmdAllocator.bindStatesCmdPool.alloc(wI);t&&(t.gpuPipelineState=this._curGPUPipelineState,Array.prototype.push.apply(t.gpuDescriptorSets,this._curGPUDescriptorSets),Array.prototype.push.apply(t.dynamicOffsets,this._curDynamicOffsets),t.gpuInputAssembler=this._curGPUInputAssembler,t.dynamicStates.copy(this._curDynamicStates),this.cmdPackage.bindStatesCmds.push(t),this.cmdPackage.cmds.push(SI.BIND_STATES),this._isStateInvalied=!1)},i.blitTexture=function(t,e,i,n){var r=this._cmdAllocator.blitTextureCmdPool.alloc(PI);r.srcTexture=t.gpuTexture,r.dstTexture=e.gpuTexture,r.regions=i,r.filter=n,++this._numDrawCalls,this.cmdPackage.blitTextureCmds.push(r),this.cmdPackage.cmds.push(SI.BLIT_TEXTURE)},e}(o),rB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuFramebuffer=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._renderPass=t.renderPass,this._colorTextures=t.colorTextures||[],this._depthStencilTexture=t.depthStencilTexture||null;for(var e=0,i=[],n=0;n<t.colorTextures.length;++n){var r=t.colorTextures[n];r&&(i.push(r.gpuTexture),e=r.lodLevel)}var s=null;t.depthStencilTexture&&(s=t.depthStencilTexture.gpuTexture,e=t.depthStencilTexture.lodLevel);var a=Number.MAX_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER;this._gpuFramebuffer={gpuRenderPass:t.renderPass.gpuRenderPass,gpuColorTextures:i,gpuDepthStencilTexture:s,glFramebuffer:null,isOffscreen:!0,get width(){return this.isOffscreen?a:this.gpuColorTextures[0].width},set width(t){a=t},get height(){return this.isOffscreen?o:this.gpuColorTextures[0].height},set height(t){o=t},lodLevel:e},function(t,e){for(var i=0;i<e.gpuColorTextures.length;++i)if(e.gpuColorTextures[i].isSwapchainTexture)return void(e.isOffscreen=!1);var n=t.gl,r=[],s=n.createFramebuffer();if(s){e.glFramebuffer=s,t.stateCache.glFramebuffer!==e.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,e.glFramebuffer);for(var a=0;a<e.gpuColorTextures.length;++a){var o=e.gpuColorTextures[a];o&&(o.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,o.glTarget,o.glTexture,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,n.RENDERBUFFER,o.glRenderbuffer),r.push(n.COLOR_ATTACHMENT0+a),e.width=Math.min(e.width,o.width),e.height=Math.min(e.height,o.height))}var h=e.gpuDepthStencilTexture;if(h){var l=ne[h.format].hasStencil?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;h.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,l,h.glTarget,h.glTexture,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,l,n.RENDERBUFFER,h.glRenderbuffer),e.width=Math.min(e.width,h.width),e.height=Math.min(e.height,h.height)}t.extensions.WEBGL_draw_buffers&&t.extensions.WEBGL_draw_buffers.drawBuffersWEBGL(r);var u=n.checkFramebufferStatus(n.FRAMEBUFFER);if(u!==n.FRAMEBUFFER_COMPLETE)switch(u){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case n.FRAMEBUFFER_UNSUPPORTED:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED")}t.stateCache.glFramebuffer!==e.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,t.stateCache.glFramebuffer)}}(fI.instance,this._gpuFramebuffer)},i.destroy=function(){var t,e;this._gpuFramebuffer&&(t=fI.instance,(e=this._gpuFramebuffer).glFramebuffer&&(t.gl.deleteFramebuffer(e.glFramebuffer),t.stateCache.glFramebuffer===e.glFramebuffer&&(t.gl.bindFramebuffer(t.gl.FRAMEBUFFER,null),t.stateCache.glFramebuffer=null),e.glFramebuffer=null),this._gpuFramebuffer=null)},Pi(e,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}}]),e}(ve),sB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuInputAssembler=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){if(0!==t.vertexBuffers.length){if(this._attributes=t.attributes,this._attributesHash=this.computeAttributesHash(),this._vertexBuffers=t.vertexBuffers,t.indexBuffer)this._indexBuffer=t.indexBuffer,this._drawInfo.indexCount=this._indexBuffer.size/this._indexBuffer.stride,this._drawInfo.firstIndex=0;else{var e=this._vertexBuffers[0];this._drawInfo.vertexCount=e.size/e.stride,this._drawInfo.firstVertex=0,this._drawInfo.vertexOffset=0}this._drawInfo.instanceCount=0,this._drawInfo.firstInstance=0,this._indirectBuffer=t.indirectBuffer||null;for(var i=new Array(t.vertexBuffers.length),n=0;n<t.vertexBuffers.length;++n){var r=t.vertexBuffers[n];r.gpuBuffer&&(i[n]=r.gpuBuffer)}var s=null,a=0;if(t.indexBuffer&&(s=t.indexBuffer.gpuBuffer))switch(s.stride){case 1:a=5121;break;case 2:a=5123;break;case 4:a=5125;break;default:console.error("Error index buffer stride.")}var o=null;t.indirectBuffer&&(o=t.indirectBuffer.gpuBuffer),this._gpuInputAssembler={attributes:t.attributes,gpuVertexBuffers:i,gpuIndexBuffer:s,gpuIndirectBuffer:o,glAttribs:[],glIndexType:a,glVAOs:new Map},UI(fI.instance,this._gpuInputAssembler)}else console.error("InputAssemblerInfo.vertexBuffers is null.")},i.destroy=function(){var t=fI.instance;this._gpuInputAssembler&&t.extensions.useVAO&&GI(t,this._gpuInputAssembler),this._gpuInputAssembler=null},Pi(e,[{key:"gpuInputAssembler",get:function(){return this._gpuInputAssembler}}]),e}(ye),aB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuDescriptorSetLayout=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){Array.prototype.push.apply(this._bindings,t.bindings);for(var e=0,i=-1,n=[],r=0;r<this._bindings.length;r++){var s=this._bindings[r];n.push(e),e+=s.count,s.binding>i&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var a=this._descriptorIndices=Array(i+1).fill(-1),o=0;o<this._bindings.length;o++){var h=this._bindings[o];this._bindingIndices[h.binding]=o,a[h.binding]=n[o]}for(var l=[],u=0;u<this._bindings.length;u++){var c=this._bindings[u];if(c.descriptorType&ae)for(var d=0;d<c.count;d++)l.push(c.binding)}this._gpuDescriptorSetLayout={bindings:this._bindings,dynamicBindings:l,descriptorIndices:a,descriptorCount:e}},i.destroy=function(){this._bindings.length=0},Pi(e,[{key:"gpuDescriptorSetLayout",get:function(){return this._gpuDescriptorSetLayout}}]),e}(Te),oB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuPipelineLayout=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){Array.prototype.push.apply(this._setLayouts,t.setLayouts);for(var e=[],i=[],n=0,r=[],s=0;s<this._setLayouts.length;s++){for(var a=this._setLayouts[s],o=a.gpuDescriptorSetLayout.dynamicBindings,h=Array(a.bindingIndices.length).fill(-1),l=0;l<o.length;l++){var u=o[l];h[u]<0&&(h[u]=n+l)}i.push(a.gpuDescriptorSetLayout),e.push(h),r.push(n),n+=o.length}this._gpuPipelineLayout={gpuSetLayouts:i,dynamicOffsetIndices:e,dynamicOffsetCount:n,dynamicOffsetOffsets:r}},i.destroy=function(){this._setLayouts.length=0},Pi(e,[{key:"gpuPipelineLayout",get:function(){return this._gpuPipelineLayout}}]),e}(Se),hB=[0,1,3,2,0,0,0,4,5,6,0,0,0,0],lB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuPipelineState=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._primitive=t.primitive,this._shader=t.shader,this._pipelineLayout=t.pipelineLayout;var e=this._bs;if(t.blendState){var i=t.blendState,n=i.targets;n&&n.forEach((function(t,i){e.setTarget(i,t)})),void 0!==i.isA2C&&(e.isA2C=i.isA2C),void 0!==i.isIndepend&&(e.isIndepend=i.isIndepend),void 0!==i.blendColor&&(e.blendColor=i.blendColor)}Object.assign(this._rs,t.rasterizerState),Object.assign(this._dss,t.depthStencilState),this._is=t.inputState,this._renderPass=t.renderPass,this._dynamicStates=t.dynamicStates;for(var r=[],s=0;s<31;s++)this._dynamicStates&1<<s&&r.push(1<<s);this._gpuPipelineState={glPrimitive:hB[t.primitive],gpuShader:t.shader.gpuShader,gpuPipelineLayout:t.pipelineLayout.gpuPipelineLayout,rs:t.rasterizerState,dss:t.depthStencilState,bs:t.blendState,gpuRenderPass:t.renderPass.gpuRenderPass,dynamicStates:r}},i.destroy=function(){this._gpuPipelineState=null},Pi(e,[{key:"gpuPipelineState",get:function(){return this._gpuPipelineState}}]),e}(xe),uB=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.beginRenderPass=function(t,e,i,n,r,s){zI(fI.instance,t.gpuRenderPass,e.gpuFramebuffer,i,n,r,s),this._isInRenderPass=!0},i.draw=function(t){if(this._isInRenderPass){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t;WI(fI.instance,e),++this._numDrawCalls,this._numInstances+=e.instanceCount;var i=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=i/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(i-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.setViewport=function(t){var e=fI.instance,i=e.stateCache,n=e.gl;i.viewport.left===t.left&&i.viewport.top===t.top&&i.viewport.width===t.width&&i.viewport.height===t.height||(n.viewport(t.left,t.top,t.width,t.height),i.viewport.left=t.left,i.viewport.top=t.top,i.viewport.width=t.width,i.viewport.height=t.height)},i.setScissor=function(t){var e=fI.instance,i=e.stateCache,n=e.gl;i.scissorRect.x===t.x&&i.scissorRect.y===t.y&&i.scissorRect.width===t.width&&i.scissorRect.height===t.height||(n.scissor(t.x,t.y,t.width,t.height),i.scissorRect.x=t.x,i.scissorRect.y=t.y,i.scissorRect.width=t.width,i.scissorRect.height=t.height)},i.updateBuffer=function(t,e,i){if(this._isInRenderPass)console.error("Command 'updateBuffer' must be recorded outside a render pass.");else{var n,r=t.gpuBuffer;r&&(n=void 0!==i?i:t.usage&g.INDIRECT?0:e.byteLength,LI(fI.instance,r,e,0,n))}},i.copyBuffersToTexture=function(t,e,i){if(this._isInRenderPass)console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.");else{var n=e.gpuTexture;n&&ZI(fI.instance,t,n,i)}},i.execute=function(t,e){for(var i=0;i<e;++i){var n=t[i];jI(fI.instance,n.cmdPackage),this._numDrawCalls+=n._numDrawCalls,this._numInstances+=n._numInstances,this._numTris+=n._numTris}},i.bindStates=function(){XI(fI.instance,this._curGPUPipelineState,this._curGPUInputAssembler,this._curGPUDescriptorSets,this._curDynamicOffsets,this._curDynamicStates),this._isStateInvalied=!1},i.blitTexture=function(t,e,i,n){var r=t.gpuTexture,s=e.gpuTexture;QI(fI.instance,r,s,i,n)},e}(nB),cB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).numDrawCalls=0,e.numInstances=0,e.numTris=0,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type},i.destroy=function(){},i.submit=function(t){for(var e=t.length,i=0;i<e;i++){var n=t[i];this.numDrawCalls+=n.numDrawCalls,this.numInstances+=n.numInstances,this.numTris+=n.numTris}},i.clear=function(){this.numDrawCalls=0,this.numInstances=0,this.numTris=0},e}(we),dB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuRenderPass=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._colorInfos=t.colorAttachments,this._depthStencilInfo=t.depthStencilAttachment,this._subpasses=t.subpasses,this._gpuRenderPass={colorAttachments:this._colorInfos,depthStencilAttachment:this._depthStencilInfo},this._hash=this.computeHash()},i.destroy=function(){this._gpuRenderPass=null},Pi(e,[{key:"gpuRenderPass",get:function(){return this._gpuRenderPass}}]),e}(Me),_B=[10497,33648,33071,33071],fB=function(t){function e(e,i){var n;(n=t.call(this,e,i)||this)._gpuSampler=null;var r,s,a=n._info.minFilter,o=n._info.magFilter,h=n._info.mipFilter;r=a===b.LINEAR||a===b.ANISOTROPIC?h===b.LINEAR||h===b.ANISOTROPIC?9987:h===b.POINT?9985:9729:h===b.LINEAR||h===b.ANISOTROPIC?9986:h===b.POINT?9984:9728,s=o===b.LINEAR||o===b.ANISOTROPIC?9729:9728;var l=_B[n._info.addressU],u=_B[n._info.addressV],c=_B[n._info.addressW];return n._gpuSampler={glMinFilter:r,glMagFilter:s,glWrapS:l,glWrapT:u,glWrapR:c},n}return He(e,t),Pi(e,[{key:"gpuSampler",get:function(){return this._gpuSampler}}]),e}(Ie),pB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuShader=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._name=t.name,this._stages=t.stages,this._attributes=t.attributes,this._blocks=t.blocks,this._samplers=t.samplers,this._gpuShader={name:t.name,blocks:t.blocks.slice(),samplerTextures:t.samplerTextures.slice(),subpassInputs:t.subpassInputs.slice(),gpuStages:new Array(t.stages.length),glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplerTextures:[]};for(var e=0;e<t.stages.length;++e){var i=t.stages[e];this._gpuShader.gpuStages[e]={type:i.stage,source:i.source,glShader:null}}},i.destroy=function(){this._gpuShader&&(kI(fI.instance,this._gpuShader),this._gpuShader=null)},Pi(e,[{key:"gpuShader",get:function(){return null===this._gpuShader.glProgram&&NI(fI.instance,this._gpuShader),this._gpuShader}}]),e}(Be),gB=function(){function t(){this.glArrayBuffer=null,this.glElementArrayBuffer=null,this.glVAO=null,this.texUnit=0,this.glTexUnits=[],this.glRenderbuffer=null,this.glFramebuffer=null,this.viewport=new lt,this.scissorRect=new it(0,0,0,0),this.rs=new Ee,this.dss=new Ae,this.bs=new Re,this.glProgram=null,this.glEnabledAttribLocs=[],this.glCurrentAttribLocs=[],this.texUnitCacheMap={}}return t.prototype.initialize=function(t,e){for(var i=0;i<t;++i)this.glTexUnits.push({glTexture:null});this.glEnabledAttribLocs.length=e,this.glEnabledAttribLocs.fill(!1),this.glCurrentAttribLocs.length=e,this.glCurrentAttribLocs.fill(!1)},t}(),mB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuTexture=null,e._lodLevel=0,e}He(e,t);var i=e.prototype;return i.initialize=function(t,e){var i=t,n=t;"texture"in t&&(i=n.texture.info,this._isTextureView=!0),this._info.copy(i),this._isPowerOf2=he(this._info.width)&&he(this._info.height),this._size=ue(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,this._isTextureView?(this._viewInfo.copy(n),this._lodLevel=n.baseLevel,this._gpuTexture=n.texture._gpuTexture):(this._gpuTexture={type:i.type,format:i.format,usage:i.usage,width:i.width,height:i.height,depth:i.depth,size:this._size,arrayLayer:i.layerCount,mipLevel:i.levelCount,samples:i.samples,flags:i.flags,isPowerOf2:this._isPowerOf2,glTarget:0,glInternalFmt:0,glFormat:0,glType:0,glUsage:0,glTexture:null,glRenderbuffer:null,glWrapS:0,glWrapT:0,glMinFilter:0,glMagFilter:0,isSwapchainTexture:e||!1},this._gpuTexture.isSwapchainTexture||(function(t,e){var i=t.gl;e.glFormat=e.glInternalFmt=function(t,e){switch(t){case _.A8:return e.ALPHA;case _.L8:return e.LUMINANCE;case _.LA8:return e.LUMINANCE_ALPHA;case _.RGB8:case _.RGB16F:case _.RGB32F:return e.RGB;case _.BGRA8:case _.RGBA8:case _.SRGB8_A8:case _.RGBA16F:case _.RGBA32F:return e.RGBA;case _.R5G6B5:return e.RGB;case _.RGB5A1:case _.RGBA4:return e.RGBA;case _.DEPTH:return e.DEPTH_COMPONENT;case _.DEPTH_STENCIL:return e.DEPTH_STENCIL;case _.BC1:return dI.COMPRESSED_RGB_S3TC_DXT1_EXT;case _.BC1_ALPHA:return dI.COMPRESSED_RGBA_S3TC_DXT1_EXT;case _.BC1_SRGB:return dI.COMPRESSED_SRGB_S3TC_DXT1_EXT;case _.BC1_SRGB_ALPHA:return dI.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case _.BC2:return dI.COMPRESSED_RGBA_S3TC_DXT3_EXT;case _.BC2_SRGB:return dI.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case _.BC3:return dI.COMPRESSED_RGBA_S3TC_DXT5_EXT;case _.BC3_SRGB:return dI.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case _.ETC_RGB8:return dI.COMPRESSED_RGB_ETC1_WEBGL;case _.ETC2_RGB8:return dI.COMPRESSED_RGB8_ETC2;case _.ETC2_SRGB8:return dI.COMPRESSED_SRGB8_ETC2;case _.ETC2_RGB8_A1:return dI.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_SRGB8_A1:return dI.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_RGBA8:return dI.COMPRESSED_RGBA8_ETC2_EAC;case _.ETC2_SRGB8_A8:return dI.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case _.EAC_R11:return dI.COMPRESSED_R11_EAC;case _.EAC_R11SN:return dI.COMPRESSED_SIGNED_R11_EAC;case _.EAC_RG11:return dI.COMPRESSED_RG11_EAC;case _.EAC_RG11SN:return dI.COMPRESSED_SIGNED_RG11_EAC;case _.PVRTC_RGB2:return dI.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case _.PVRTC_RGBA2:return dI.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case _.PVRTC_RGB4:return dI.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case _.PVRTC_RGBA4:return dI.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case _.ASTC_RGBA_4X4:return dI.COMPRESSED_RGBA_ASTC_4x4_KHR;case _.ASTC_RGBA_5X4:return dI.COMPRESSED_RGBA_ASTC_5x4_KHR;case _.ASTC_RGBA_5X5:return dI.COMPRESSED_RGBA_ASTC_5x5_KHR;case _.ASTC_RGBA_6X5:return dI.COMPRESSED_RGBA_ASTC_6x5_KHR;case _.ASTC_RGBA_6X6:return dI.COMPRESSED_RGBA_ASTC_6x6_KHR;case _.ASTC_RGBA_8X5:return dI.COMPRESSED_RGBA_ASTC_8x5_KHR;case _.ASTC_RGBA_8X6:return dI.COMPRESSED_RGBA_ASTC_8x6_KHR;case _.ASTC_RGBA_8X8:return dI.COMPRESSED_RGBA_ASTC_8x8_KHR;case _.ASTC_RGBA_10X5:return dI.COMPRESSED_RGBA_ASTC_10x5_KHR;case _.ASTC_RGBA_10X6:return dI.COMPRESSED_RGBA_ASTC_10x6_KHR;case _.ASTC_RGBA_10X8:return dI.COMPRESSED_RGBA_ASTC_10x8_KHR;case _.ASTC_RGBA_10X10:return dI.COMPRESSED_RGBA_ASTC_10x10_KHR;case _.ASTC_RGBA_12X10:return dI.COMPRESSED_RGBA_ASTC_12x10_KHR;case _.ASTC_RGBA_12X12:return dI.COMPRESSED_RGBA_ASTC_12x12_KHR;case _.ASTC_SRGBA_4X4:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case _.ASTC_SRGBA_5X4:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case _.ASTC_SRGBA_5X5:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case _.ASTC_SRGBA_6X5:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case _.ASTC_SRGBA_6X6:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case _.ASTC_SRGBA_8X5:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case _.ASTC_SRGBA_8X6:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case _.ASTC_SRGBA_8X8:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case _.ASTC_SRGBA_10X5:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case _.ASTC_SRGBA_10X6:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case _.ASTC_SRGBA_10X8:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case _.ASTC_SRGBA_10X10:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case _.ASTC_SRGBA_12X10:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case _.ASTC_SRGBA_12X12:return dI.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL format failed."),e.RGBA}}(e.format,i),e.glType=pI(e.format,i);var n=e.width,r=e.height;switch(e.type){case T.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(n,r);if(s>t.capabilities.maxTextureSize&&hn(9100,s,t.capabilities.maxTextureSize),t.textureExclusive[e.format]||t.extensions.WEBGL_depth_texture||!ne[e.format].hasDepth){if(e.glTexture=i.createTexture(),e.size>0){var a=t.stateCache.glTexUnits[t.stateCache.texUnit];if(a.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),a.glTexture=e.glTexture),ne[e.format].isCompressed)for(var o=0;o<e.mipLevel;++o){var h=le(e.format,n,r,1),l=new Uint8Array(h);i.compressedTexImage2D(i.TEXTURE_2D,o,e.glInternalFmt,n,r,0,l),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else for(var u=0;u<e.mipLevel;++u)i.texImage2D(i.TEXTURE_2D,u,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null),n=Math.max(1,n>>1),r=Math.max(1,r>>1);e.isPowerOf2?(e.glWrapS=i.REPEAT,e.glWrapT=i.REPEAT):(e.glWrapS=i.CLAMP_TO_EDGE,e.glWrapT=i.CLAMP_TO_EDGE),e.glMinFilter=i.LINEAR,e.glMagFilter=i.LINEAR,i.texParameteri(e.glTarget,i.TEXTURE_WRAP_S,e.glWrapS),i.texParameteri(e.glTarget,i.TEXTURE_WRAP_T,e.glWrapT),i.texParameteri(e.glTarget,i.TEXTURE_MIN_FILTER,e.glMinFilter),i.texParameteri(e.glTarget,i.TEXTURE_MAG_FILTER,e.glMagFilter)}}else e.glInternalFmt=function(t,e){switch(t){case _.R5G6B5:return e.RGB565;case _.RGB5A1:return e.RGB5_A1;case _.RGBA4:return e.RGBA4;case _.RGBA16F:return dI.RGBA16F_EXT;case _.RGBA32F:return dI.RGBA32F_EXT;case _.SRGB8_A8:return dI.SRGB8_ALPHA8_EXT;case _.DEPTH:return e.DEPTH_COMPONENT16;case _.DEPTH_STENCIL:return e.DEPTH_STENCIL;default:return console.error("Unsupported Format, convert to WebGL internal format failed."),e.RGBA}}(e.format,i),e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,n,r));break;case T.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(n,r);if(c>t.capabilities.maxCubeMapTextureSize&&hn(9100,c,t.capabilities.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var d=t.stateCache.glTexUnits[t.stateCache.texUnit];if(d.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),d.glTexture=e.glTexture),ne[e.format].isCompressed)for(var f=0;f<6;++f){n=e.width,r=e.height;for(var p=0;p<e.mipLevel;++p){var g=le(e.format,n,r,1),m=new Uint8Array(g);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+f,p,e.glInternalFmt,n,r,0,m),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}}else for(var v=0;v<6;++v){n=e.width,r=e.height;for(var y=0;y<e.mipLevel;++y)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+v,y,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}e.isPowerOf2?(e.glWrapS=i.REPEAT,e.glWrapT=i.REPEAT):(e.glWrapS=i.CLAMP_TO_EDGE,e.glWrapT=i.CLAMP_TO_EDGE),e.glMinFilter=i.LINEAR,e.glMagFilter=i.LINEAR,i.texParameteri(e.glTarget,i.TEXTURE_WRAP_S,e.glWrapS),i.texParameteri(e.glTarget,i.TEXTURE_WRAP_T,e.glWrapT),i.texParameteri(e.glTarget,i.TEXTURE_MIN_FILTER,e.glMinFilter),i.texParameteri(e.glTarget,i.TEXTURE_MAG_FILTER,e.glMagFilter)}break;default:console.error("Unsupported TextureType, create texture failed."),e.type=T.TEX2D,e.glTarget=i.TEXTURE_2D}}(fI.instance,this._gpuTexture),fI.instance.memoryStatus.textureSize+=this._size),this._viewInfo.texture=this,this._viewInfo.type=t.type,this._viewInfo.format=t.format,this._viewInfo.baseLevel=0,this._viewInfo.levelCount=t.levelCount,this._viewInfo.baseLayer=0,this._viewInfo.layerCount=t.layerCount)},i.destroy=function(){!this._isTextureView&&this._gpuTexture&&(function(t,e){var i=t.gl;if(e.glTexture){var n=t.stateCache.glTexUnits,r=t.stateCache.texUnit;i.deleteTexture(e.glTexture);for(var s=0;s<n.length;s++)n[s].glTexture===e.glTexture&&(i.activeTexture(i.TEXTURE0+s),r=s,i.bindTexture(e.glTarget,null),n[s].glTexture=null);t.stateCache.texUnit=r,e.glTexture=null}if(e.glRenderbuffer){var a=t.stateCache.glRenderbuffer;i.deleteRenderbuffer(e.glRenderbuffer),a===e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,null),a=null),e.glRenderbuffer=null}}(fI.instance,this._gpuTexture),fI.instance.memoryStatus.textureSize-=this._size,this._gpuTexture=null)},i.getGLTextureHandle=function(){var t=this._gpuTexture;return t?t.glTexture?t.glTexture:t.glRenderbuffer?t.glRenderbuffer:0:0},i.resize=function(t,i){if(this._info.width!==t||this._info.height!==i){this._info.levelCount===e.getLevelCount(this._info.width,this._info.height)?this._info.levelCount=e.getLevelCount(t,i):this._info.levelCount>1&&(this._info.levelCount=Math.min(this._info.levelCount,e.getLevelCount(t,i)));var n=this._size;this._info.width=t,this._info.height=i,this._size=ue(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,!this._isTextureView&&this._gpuTexture&&(this._gpuTexture.width=t,this._gpuTexture.height=i,this._gpuTexture.size=this._size,this._gpuTexture.isSwapchainTexture||(function(t,e){if(e.size){var i=t.gl,n=e.width,r=e.height;switch(e.type){case T.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(n,r);if(s>t.capabilities.maxTextureSize&&hn(9100,s,t.capabilities.maxTextureSize),e.glRenderbuffer)t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,n,r);else if(e.glTexture){var a=t.stateCache.glTexUnits[t.stateCache.texUnit];if(a.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),a.glTexture=e.glTexture),ne[e.format].isCompressed)for(var o=0;o<e.mipLevel;++o){var h=le(e.format,n,r,1),l=new Uint8Array(h);i.compressedTexImage2D(i.TEXTURE_2D,o,e.glInternalFmt,n,r,0,l),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else for(var u=0;u<e.mipLevel;++u)i.texImage2D(i.TEXTURE_2D,u,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}break;case T.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(n,r);c>t.capabilities.maxCubeMapTextureSize&&hn(9100,c,t.capabilities.maxTextureSize);var d=t.stateCache.glTexUnits[t.stateCache.texUnit];if(d.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),d.glTexture=e.glTexture),ne[e.format].isCompressed)for(var _=0;_<6;++_){n=e.width,r=e.height;for(var f=0;f<e.mipLevel;++f){var p=le(e.format,n,r,1),g=new Uint8Array(p);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+_,f,e.glInternalFmt,n,r,0,g),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}}else for(var m=0;m<6;++m){n=e.width,r=e.height;for(var v=0;v<e.mipLevel;++v)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+m,v,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}break;default:console.error("Unsupported TextureType, create texture failed."),e.type=T.TEX2D,e.glTarget=i.TEXTURE_2D}}}(fI.instance,this._gpuTexture),fI.instance.memoryStatus.textureSize-=n,fI.instance.memoryStatus.textureSize+=this._size))}},i.initAsSwapchainTexture=function(t){var e=new yt;e.format=t.format,e.usage=ne[t.format].hasDepth?S.DEPTH_STENCIL_ATTACHMENT:S.COLOR_ATTACHMENT,e.width=t.width,e.height=t.height,this.initialize(e,!0)},Pi(e,[{key:"gpuTexture",get:function(){return this._gpuTexture}},{key:"lodLevel",get:function(){return this._lodLevel}}]),e}(Pe),vB="webglcontextlost";function yB(t,e){for(var i=["","WEBKIT_","MOZ_"],n=0;n<i.length;++n){var r=t.getExtension(i[n]+e);if(r)return r}return null}function TB(t){var e={EXT_texture_filter_anisotropic:yB(t,"EXT_texture_filter_anisotropic"),EXT_blend_minmax:yB(t,"EXT_blend_minmax"),EXT_frag_depth:yB(t,"EXT_frag_depth"),EXT_shader_texture_lod:yB(t,"EXT_shader_texture_lod"),EXT_sRGB:yB(t,"EXT_sRGB"),OES_vertex_array_object:yB(t,"OES_vertex_array_object"),EXT_color_buffer_half_float:yB(t,"EXT_color_buffer_half_float"),WEBGL_color_buffer_float:yB(t,"WEBGL_color_buffer_float"),WEBGL_compressed_texture_etc1:yB(t,"WEBGL_compressed_texture_etc1"),WEBGL_compressed_texture_etc:yB(t,"WEBGL_compressed_texture_etc"),WEBGL_compressed_texture_pvrtc:yB(t,"WEBGL_compressed_texture_pvrtc"),WEBGL_compressed_texture_s3tc:yB(t,"WEBGL_compressed_texture_s3tc"),WEBGL_compressed_texture_s3tc_srgb:yB(t,"WEBGL_compressed_texture_s3tc_srgb"),WEBGL_debug_shaders:yB(t,"WEBGL_debug_shaders"),WEBGL_draw_buffers:yB(t,"WEBGL_draw_buffers"),WEBGL_lose_context:yB(t,"WEBGL_lose_context"),WEBGL_depth_texture:yB(t,"WEBGL_depth_texture"),OES_texture_half_float:yB(t,"OES_texture_half_float"),OES_texture_half_float_linear:yB(t,"OES_texture_half_float_linear"),OES_texture_float:yB(t,"OES_texture_float"),OES_texture_float_linear:yB(t,"OES_texture_float_linear"),OES_standard_derivatives:yB(t,"OES_standard_derivatives"),OES_element_index_uint:yB(t,"OES_element_index_uint"),ANGLE_instanced_arrays:yB(t,"ANGLE_instanced_arrays"),WEBGL_debug_renderer_info:yB(t,"WEBGL_debug_renderer_info"),WEBGL_multi_draw:null,WEBGL_compressed_texture_astc:null,destroyShadersImmediately:!0,noCompressedTexSubImage2D:!1,isLocationActive:function(t){return!!t},useVAO:!1};return Ds.os===Os.IOS&&14===Ds.osMainVersion&&Ds.isBrowser||(e.WEBGL_compressed_texture_astc=yB(t,"WEBGL_compressed_texture_astc")),Ds.os!==Os.ANDROID&&Ds.os!==Os.IOS&&(e.WEBGL_multi_draw=yB(t,"WEBGL_multi_draw")),Ds.browserType===Fs.UC&&(e.ANGLE_instanced_arrays=null),(Ds.os===Os.IOS&&Ds.osMainVersion<=10||sa)&&(e.destroyShadersImmediately=!1),e.OES_vertex_array_object&&(e.useVAO=!0),e}var SB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).stateCache=new gB,e.cmdAllocator=new iB,e.nullTex2D=null,e.nullTexCube=null,e._canvas=null,e._webGLContextLostHandler=null,e._extensions=null,e._blitManager=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._canvas=t.windowHandle,this._webGLContextLostHandler=this._onWebGLContextLost.bind(this),this._canvas.addEventListener(vB,this._onWebGLContextLost);var e=fI.instance.gl;this.stateCache.initialize(fI.instance.capabilities.maxTextureUnits,fI.instance.capabilities.maxVertexAttributes),this._extensions=TB(e),function(t){t.activeTexture(t.TEXTURE0),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.bindFramebuffer(t.FRAMEBUFFER,null),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.frontFace(t.CCW),t.disable(t.POLYGON_OFFSET_FILL),t.polygonOffset(0,0),t.enable(t.DEPTH_TEST),t.depthMask(!0),t.depthFunc(t.LESS),t.depthRange(0,1),t.stencilFuncSeparate(t.FRONT,t.ALWAYS,1,65535),t.stencilOpSeparate(t.FRONT,t.KEEP,t.KEEP,t.KEEP),t.stencilMaskSeparate(t.FRONT,65535),t.stencilFuncSeparate(t.BACK,t.ALWAYS,1,65535),t.stencilOpSeparate(t.BACK,t.KEEP,t.KEEP,t.KEEP),t.stencilMaskSeparate(t.BACK,65535),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.disable(t.BLEND),t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.colorMask(!0,!0,!0,!0),t.blendColor(0,0,0,0)}(e);var i=_.RGBA8,n=_.DEPTH_STENCIL,r=e.getParameter(e.DEPTH_BITS),s=e.getParameter(e.STENCIL_BITS);r&&s?n=_.DEPTH_STENCIL:r&&(n=_.DEPTH),this._colorTexture=new mB,this._colorTexture.initAsSwapchainTexture({swapchain:this,format:i,width:t.width,height:t.height}),this._depthStencilTexture=new mB,this._depthStencilTexture.initAsSwapchainTexture({swapchain:this,format:n,width:t.width,height:t.height}),this.nullTex2D=fI.instance.createTexture(new yt(T.TEX2D,S.SAMPLED,_.RGBA8,2,2,E.GEN_MIPMAP)),this.nullTexCube=fI.instance.createTexture(new yt(T.CUBE,S.SAMPLED,_.RGBA8,2,2,E.GEN_MIPMAP,6));var a=new ht;a.texExtent.width=2,a.texExtent.height=2;var o=new Uint8Array(this.nullTex2D.size);o.fill(0),fI.instance.copyBuffersToTexture([o],this.nullTex2D,[a]),a.texSubres.layerCount=6,fI.instance.copyBuffersToTexture([o,o,o,o,o,o],this.nullTexCube,[a]),this._blitManager=new $I},i.destroy=function(){this._canvas&&this._webGLContextLostHandler&&(this._canvas.removeEventListener(vB,this._webGLContextLostHandler),this._webGLContextLostHandler=null),this.nullTex2D&&(this.nullTex2D.destroy(),this.nullTex2D=null),this.nullTexCube&&(this.nullTexCube.destroy(),this.nullTexCube=null),this._blitManager&&(this._blitManager.destroy(),this._blitManager=null),this._extensions=null,this._canvas=null},i.resize=function(t,e){this._colorTexture.width===t&&this._colorTexture.height===e||(Gn("Resizing swapchain: "+t+"x"+e),this._canvas.width=t,this._canvas.height=e,this._colorTexture.resize(t,e),this._depthStencilTexture.resize(t,e))},i._onWebGLContextLost=function(t){Zi(11e3),Gi(t)},Pi(e,[{key:"extensions",get:function(){return this._extensions}},{key:"blitManager",get:function(){return this._blitManager}}]),e}(me),EB=t("WebGLDevice",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._swapchain=null,e._context=null,e._bindingMappings=null,e._textureExclusive=new Array(_.COUNT),e}He(e,t);var i=e.prototype;return i.initialize=function(t){fI.setInstance(this),this._gfxAPI=u.WEBGL;var e=this._bindingMappingInfo=t.bindingMappingInfo,i=[],n=[],r=e.setIndices[0];i[r]=0,n[r]=0;for(var s=1;s<e.setIndices.length;++s){var a=e.setIndices[s],o=e.setIndices[s-1];i[a]=e.maxBlockCounts[o]+i[o],n[a]=e.maxSamplerTextureCounts[o]+n[o]}for(var h=0;h<e.setIndices.length;++h){var l=e.setIndices[h];n[l]-=e.maxBlockCounts[l]}this._bindingMappings={blockOffsets:i,samplerTextureOffsets:n,flexibleSet:e.setIndices[e.setIndices.length-1]};var c=this._context=function(t){var e=null;try{var i={alpha:Mi.ENABLE_TRANSPARENT_CANVAS,antialias:aa||Mi.ENABLE_WEBGL_ANTIALIAS,depth:!0,stencil:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1};e=t.getContext("webgl",i)}catch(t){return null}return e}(pe.canvas);if(!c)return console.error("This device does not support WebGL."),!1;this._queue=this.createQueue(new qt(Y.GRAPHICS)),this._cmdBuff=this.createCommandBuffer(new Kt(this._queue)),this._caps.maxVertexAttributes=c.getParameter(c.MAX_VERTEX_ATTRIBS),this._caps.maxVertexUniformVectors=c.getParameter(c.MAX_VERTEX_UNIFORM_VECTORS),this._caps.maxFragmentUniformVectors=c.getParameter(c.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxTextureUnits=c.getParameter(c.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureUnits=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=c.getParameter(c.MAX_TEXTURE_SIZE),this._caps.maxCubeMapTextureSize=c.getParameter(c.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxArrayTextureLayers=0,this._caps.max3DTextureSize=0,this._caps.maxUniformBufferBindings=16;var f=c.getSupportedExtensions(),p="";if(f)for(var g,m=Fi(f);!(g=m()).done;)p+=g.value+" ";var v=TB(c);v.WEBGL_debug_renderer_info?(this._renderer=c.getParameter(v.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL),this._vendor=c.getParameter(v.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL)):(this._renderer=c.getParameter(c.RENDERER),this._vendor=c.getParameter(c.VENDOR));var y=c.getParameter(c.VERSION);this._features.fill(!1),this.initFormatFeatures(v),v.EXT_blend_minmax&&(this._features[d.BLEND_MINMAX]=!0),v.OES_element_index_uint&&(this._features[d.ELEMENT_INDEX_UINT]=!0),v.ANGLE_instanced_arrays&&(this._features[d.INSTANCED_ARRAYS]=!0),v.WEBGL_draw_buffers&&(this._features[d.MULTIPLE_RENDER_TARGETS]=!0);var T="";return this.getFormatFeatures(_.ETC_RGB8)&&(T+="etc1 "),this.getFormatFeatures(_.ETC2_RGB8)&&(T+="etc2 "),this.getFormatFeatures(_.BC1)&&(T+="dxt "),this.getFormatFeatures(_.PVRTC_RGB2)&&(T+="pvrtc "),this.getFormatFeatures(_.ASTC_RGBA_4X4)&&(T+="astc "),Gn("WebGL device initialized."),Gn("RENDERER: "+this._renderer),Gn("VENDOR: "+this._vendor),Gn("VERSION: "+y),Gn("COMPRESSED_FORMAT: "+T),Gn("EXTENSIONS: "+p),!0},i.destroy=function(){this._queue&&(this._queue.destroy(),this._queue=null),this._cmdBuff&&(this._cmdBuff.destroy(),this._cmdBuff=null),this._swapchain=null},i.flushCommands=function(){},i.acquire=function(){},i.present=function(){var t=this._queue;this._numDrawCalls=t.numDrawCalls,this._numInstances=t.numInstances,this._numTris=t.numTris,t.clear()},i.initFormatFeatures=function(t){this._formatFeatures.fill(A.NONE),this._textureExclusive.fill(!0);var e=A.RENDER_TARGET|A.SAMPLED_TEXTURE|A.LINEAR_FILTER;this._formatFeatures[_.RGB8]=e,this._formatFeatures[_.R5G6B5]=e,this._textureExclusive[_.R5G6B5]=!1,this._formatFeatures[_.RGBA8]=e,this._formatFeatures[_.RGBA4]=e,this._textureExclusive[_.RGBA4]=!1,this._formatFeatures[_.RGB5A1]=e,this._textureExclusive[_.RGB5A1]=!1,this._formatFeatures[_.DEPTH]=A.RENDER_TARGET,this._textureExclusive[_.DEPTH]=!1,this._formatFeatures[_.DEPTH_STENCIL]=A.RENDER_TARGET,this._textureExclusive[_.DEPTH_STENCIL]=!1,this._formatFeatures[_.R8I]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RG8I]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGB8I]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGBA8I]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.R8UI]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RG8UI]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGB8UI]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGBA8UI]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.R8I]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RG8I]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGB8I]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGBA8I]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.R8UI]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RG8UI]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGB8UI]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGBA8UI]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.R32F]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RG32F]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGB32F]|=A.VERTEX_ATTRIBUTE,this._formatFeatures[_.RGBA32F]|=A.VERTEX_ATTRIBUTE,t.EXT_sRGB&&(this._formatFeatures[_.SRGB8]=e,this._formatFeatures[_.SRGB8_A8]=e,this._textureExclusive[_.SRGB8_A8]=!1),t.WEBGL_depth_texture&&(this._formatFeatures[_.DEPTH]|=e,this._formatFeatures[_.DEPTH_STENCIL]|=e),t.WEBGL_color_buffer_float&&(this._formatFeatures[_.RGB32F]|=A.RENDER_TARGET,this._formatFeatures[_.RGBA32F]|=A.RENDER_TARGET,this._textureExclusive[_.RGB32F]=!1,this._textureExclusive[_.RGBA32F]=!1),t.EXT_color_buffer_half_float&&(this._formatFeatures[_.RGB16F]|=A.RENDER_TARGET,this._formatFeatures[_.RGBA16F]|=A.RENDER_TARGET,this._textureExclusive[_.RGB16F]=!1,this._textureExclusive[_.RGBA16F]=!1),t.OES_texture_float&&(this._formatFeatures[_.RGB32F]|=A.RENDER_TARGET|A.SAMPLED_TEXTURE,this._formatFeatures[_.RGBA32F]|=A.RENDER_TARGET|A.SAMPLED_TEXTURE),t.OES_texture_half_float&&(this._formatFeatures[_.RGB16F]|=A.RENDER_TARGET|A.SAMPLED_TEXTURE,this._formatFeatures[_.RGBA16F]|=A.RENDER_TARGET|A.SAMPLED_TEXTURE),t.OES_texture_float_linear&&(this._formatFeatures[_.RGB32F]|=A.LINEAR_FILTER,this._formatFeatures[_.RGBA32F]|=A.LINEAR_FILTER),t.OES_texture_half_float_linear&&(this._formatFeatures[_.RGB16F]|=A.LINEAR_FILTER,this._formatFeatures[_.RGBA16F]|=A.LINEAR_FILTER);var i=A.SAMPLED_TEXTURE|A.LINEAR_FILTER;t.WEBGL_compressed_texture_etc1&&(this._formatFeatures[_.ETC_RGB8]=i),t.WEBGL_compressed_texture_etc&&(this._formatFeatures[_.ETC2_RGB8]=i,this._formatFeatures[_.ETC2_RGBA8]=i,this._formatFeatures[_.ETC2_SRGB8]=i,this._formatFeatures[_.ETC2_SRGB8_A8]=i,this._formatFeatures[_.ETC2_RGB8_A1]=i,this._formatFeatures[_.ETC2_SRGB8_A1]=i),t.WEBGL_compressed_texture_s3tc&&(this._formatFeatures[_.BC1]=i,this._formatFeatures[_.BC1_ALPHA]=i,this._formatFeatures[_.BC1_SRGB]=i,this._formatFeatures[_.BC1_SRGB_ALPHA]=i,this._formatFeatures[_.BC2]=i,this._formatFeatures[_.BC2_SRGB]=i,this._formatFeatures[_.BC3]=i,this._formatFeatures[_.BC3_SRGB]=i),t.WEBGL_compressed_texture_pvrtc&&(this._formatFeatures[_.PVRTC_RGB2]|=i,this._formatFeatures[_.PVRTC_RGBA2]|=i,this._formatFeatures[_.PVRTC_RGB4]|=i,this._formatFeatures[_.PVRTC_RGBA4]|=i),t.WEBGL_compressed_texture_astc&&(this._formatFeatures[_.ASTC_RGBA_4X4]|=i,this._formatFeatures[_.ASTC_RGBA_5X4]|=i,this._formatFeatures[_.ASTC_RGBA_5X5]|=i,this._formatFeatures[_.ASTC_RGBA_6X5]|=i,this._formatFeatures[_.ASTC_RGBA_6X6]|=i,this._formatFeatures[_.ASTC_RGBA_8X5]|=i,this._formatFeatures[_.ASTC_RGBA_8X6]|=i,this._formatFeatures[_.ASTC_RGBA_8X8]|=i,this._formatFeatures[_.ASTC_RGBA_10X5]|=i,this._formatFeatures[_.ASTC_RGBA_10X6]|=i,this._formatFeatures[_.ASTC_RGBA_10X8]|=i,this._formatFeatures[_.ASTC_RGBA_10X10]|=i,this._formatFeatures[_.ASTC_RGBA_12X10]|=i,this._formatFeatures[_.ASTC_RGBA_12X12]|=i,this._formatFeatures[_.ASTC_SRGBA_4X4]|=i,this._formatFeatures[_.ASTC_SRGBA_5X4]|=i,this._formatFeatures[_.ASTC_SRGBA_5X5]|=i,this._formatFeatures[_.ASTC_SRGBA_6X5]|=i,this._formatFeatures[_.ASTC_SRGBA_6X6]|=i,this._formatFeatures[_.ASTC_SRGBA_8X5]|=i,this._formatFeatures[_.ASTC_SRGBA_8X6]|=i,this._formatFeatures[_.ASTC_SRGBA_8X8]|=i,this._formatFeatures[_.ASTC_SRGBA_10X5]|=i,this._formatFeatures[_.ASTC_SRGBA_10X6]|=i,this._formatFeatures[_.ASTC_SRGBA_10X8]|=i,this._formatFeatures[_.ASTC_SRGBA_10X10]|=i,this._formatFeatures[_.ASTC_SRGBA_12X10]|=i,this._formatFeatures[_.ASTC_SRGBA_12X12]|=i)},i.createCommandBuffer=function(t){var e=new(t.type===K.PRIMARY?uB:nB);return e.initialize(t),e},i.createSwapchain=function(t){var e=new SB;return this._swapchain=e,e.initialize(t),e},i.createBuffer=function(t){var e=new tB;return e.initialize(t),e},i.createTexture=function(t){var e=new mB;return e.initialize(t),e},i.createDescriptorSet=function(t){var e=new _I;return e.initialize(t),e},i.createShader=function(t){var e=new pB;return e.initialize(t),e},i.createInputAssembler=function(t){var e=new sB;return e.initialize(t),e},i.createRenderPass=function(t){var e=new dB;return e.initialize(t),e},i.createFramebuffer=function(t){var e=new rB;return e.initialize(t),e},i.createDescriptorSetLayout=function(t){var e=new aB;return e.initialize(t),e},i.createPipelineLayout=function(t){var e=new oB;return e.initialize(t),e},i.createPipelineState=function(t){var e=new lB;return e.initialize(t),e},i.createQueue=function(t){var e=new cB;return e.initialize(t),e},i.getSampler=function(t){var e=Ie.computeHash(t);return this._samplers.has(e)||this._samplers.set(e,new fB(t,e)),this._samplers.get(e)},i.getSwapchains=function(){return[this._swapchain]},i.getGeneralBarrier=function(t){var e=De.computeHash(t);return this._generalBarrierss.has(e)||this._generalBarrierss.set(e,new De(t,e)),this._generalBarrierss.get(e)},i.getTextureBarrier=function(t){var e=Oe.computeHash(t);return this._textureBarriers.has(e)||this._textureBarriers.set(e,new Oe(t,e)),this._textureBarriers.get(e)},i.getBufferBarrier=function(t){var e=oa.computeHash(t);return this._bufferBarriers.has(e)||this._bufferBarriers.set(e,new oa(t,e)),this._bufferBarriers.get(e)},i.copyBuffersToTexture=function(t,e,i){ZI(this,t,e.gpuTexture,i)},i.copyTextureToBuffers=function(t,e,i){!function(t,e,i,n){var r=t.gl,s=t.stateCache,a=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,a);var o=0,h=0,l=1,u=1;switch(e.glTarget){case r.TEXTURE_2D:for(var c=0;c<n.length;c++){var d=n[c];r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,e.glTarget,e.glTexture,d.texSubres.mipLevel),o=d.texOffset.x,h=d.texOffset.y,l=d.texExtent.width,u=d.texExtent.height,r.readPixels(o,h,l,u,e.glFormat,e.glType,i[c])}break;default:console.error("Unsupported GL texture type, copy texture to buffers failed.")}r.bindFramebuffer(r.FRAMEBUFFER,null),s.glFramebuffer=null,r.deleteFramebuffer(a)}(this,t.gpuTexture,e,i)},i.copyTexImagesToTexture=function(t,e,i){!function(t,e,i,n){var r=t.gl,s=t.stateCache.glTexUnits[t.stateCache.texUnit];s.glTexture!==i.glTexture&&(r.bindTexture(i.glTarget,i.glTexture),s.glTexture=i.glTexture);var a=0,o=0;switch(i.glTarget){case r.TEXTURE_2D:for(var h=0;h<n.length;h++){var l=n[h];r.texSubImage2D(r.TEXTURE_2D,l.texSubres.mipLevel,l.texOffset.x,l.texOffset.y,i.glFormat,i.glType,e[a++])}break;case r.TEXTURE_CUBE_MAP:for(var u=0;u<n.length;u++){var c=n[u],d=c.texSubres.baseArrayLayer+c.texSubres.layerCount;for(o=c.texSubres.baseArrayLayer;o<d;++o)r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,c.texSubres.mipLevel,c.texOffset.x,c.texOffset.y,i.glFormat,i.glType,e[a++])}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&E.GEN_MIPMAP&&i.isPowerOf2&&r.generateMipmap(i.glTarget)}(this,t,e.gpuTexture,i)},Pi(e,[{key:"gl",get:function(){return this._context}},{key:"extensions",get:function(){return this._swapchain.extensions}},{key:"stateCache",get:function(){return this._swapchain.stateCache}},{key:"nullTex2D",get:function(){return this._swapchain.nullTex2D}},{key:"nullTexCube",get:function(){return this._swapchain.nullTexCube}},{key:"textureExclusive",get:function(){return this._textureExclusive}},{key:"bindingMappings",get:function(){return this._bindingMappings}},{key:"blitManager",get:function(){return this._swapchain.blitManager}}]),e}(pe));We.WebGLDevice=EB;var AB,CB=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuDescriptorSet=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._layout=t.layout;var e=t.layout.gpuDescriptorSetLayout,i=e.bindings,n=e.descriptorIndices,r=e.descriptorCount;this._buffers=Array(r).fill(null),this._textures=Array(r).fill(null),this._samplers=Array(r).fill(null);var s=[];this._gpuDescriptorSet={gpuDescriptors:s,descriptorIndices:n};for(var a=0;a<i.length;++a)for(var o=i[a],h=0;h<o.count;h++)s.push({type:o.descriptorType,gpuBuffer:null,gpuTextureView:null,gpuSampler:null})},i.destroy=function(){this._layout=null,this._gpuDescriptorSet=null},i.update=function(){if(this._isDirty&&this._gpuDescriptorSet){for(var t=this._gpuDescriptorSet.gpuDescriptors,e=0;e<t.length;++e)t[e].type&re?this._buffers[e]&&(t[e].gpuBuffer=this._buffers[e].gpuBuffer):t[e].type&se&&(this._textures[e]&&(t[e].gpuTextureView=this._textures[e].gpuTextureView),this._samplers[e]&&(t[e].gpuSampler=this._samplers[e].gpuSampler));this._isDirty=!1}},Pi(e,[{key:"gpuDescriptorSet",get:function(){return this._gpuDescriptorSet}}]),e}(s);!function(t){t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"}(AB||(AB={}));var RB=function(){function t(){}return t.setInstance=function(e){t._instance=e},Pi(t,null,[{key:"instance",get:function(){return t._instance}}]),t}();RB._instance=null;var bB=[10497,33648,33071,33071],xB=new Float32Array(4);function wB(t,e){switch(t){case _.R8:return e.UNSIGNED_BYTE;case _.R8SN:return e.BYTE;case _.R8UI:return e.UNSIGNED_BYTE;case _.R8I:return e.BYTE;case _.R16F:return e.HALF_FLOAT;case _.R16UI:return e.UNSIGNED_SHORT;case _.R16I:return e.SHORT;case _.R32F:return e.FLOAT;case _.R32UI:return e.UNSIGNED_INT;case _.R32I:return e.INT;case _.RG8:return e.UNSIGNED_BYTE;case _.RG8SN:return e.BYTE;case _.RG8UI:return e.UNSIGNED_BYTE;case _.RG8I:return e.BYTE;case _.RG16F:return e.HALF_FLOAT;case _.RG16UI:return e.UNSIGNED_SHORT;case _.RG16I:return e.SHORT;case _.RG32F:return e.FLOAT;case _.RG32UI:return e.UNSIGNED_INT;case _.RG32I:return e.INT;case _.RGB8:case _.SRGB8:return e.UNSIGNED_BYTE;case _.RGB8SN:return e.BYTE;case _.RGB8UI:return e.UNSIGNED_BYTE;case _.RGB8I:return e.BYTE;case _.RGB16F:return e.HALF_FLOAT;case _.RGB16UI:return e.UNSIGNED_SHORT;case _.RGB16I:return e.SHORT;case _.RGB32F:return e.FLOAT;case _.RGB32UI:return e.UNSIGNED_INT;case _.RGB32I:return e.INT;case _.BGRA8:case _.RGBA8:case _.SRGB8_A8:return e.UNSIGNED_BYTE;case _.RGBA8SN:return e.BYTE;case _.RGBA8UI:return e.UNSIGNED_BYTE;case _.RGBA8I:return e.BYTE;case _.RGBA16F:return e.HALF_FLOAT;case _.RGBA16UI:return e.UNSIGNED_SHORT;case _.RGBA16I:return e.SHORT;case _.RGBA32F:return e.FLOAT;case _.RGBA32UI:return e.UNSIGNED_INT;case _.RGBA32I:return e.INT;case _.R5G6B5:return e.UNSIGNED_SHORT_5_6_5;case _.R11G11B10F:return e.UNSIGNED_INT_10F_11F_11F_REV;case _.RGB5A1:return e.UNSIGNED_SHORT_5_5_5_1;case _.RGBA4:return e.UNSIGNED_SHORT_4_4_4_4;case _.RGB10A2:case _.RGB10A2UI:return e.UNSIGNED_INT_2_10_10_10_REV;case _.RGB9E5:case _.DEPTH:return e.FLOAT;case _.DEPTH_STENCIL:return e.UNSIGNED_INT_24_8;case _.BC1:case _.BC1_SRGB:case _.BC2:case _.BC2_SRGB:case _.BC3:case _.BC3_SRGB:case _.BC4:return e.UNSIGNED_BYTE;case _.BC4_SNORM:return e.BYTE;case _.BC5:return e.UNSIGNED_BYTE;case _.BC5_SNORM:return e.BYTE;case _.BC6H_SF16:case _.BC6H_UF16:return e.FLOAT;case _.BC7:case _.BC7_SRGB:case _.ETC_RGB8:case _.ETC2_RGB8:case _.ETC2_SRGB8:case _.ETC2_RGB8_A1:case _.ETC2_SRGB8_A1:case _.EAC_R11:return e.UNSIGNED_BYTE;case _.EAC_R11SN:return e.BYTE;case _.EAC_RG11:return e.UNSIGNED_BYTE;case _.EAC_RG11SN:return e.BYTE;case _.PVRTC_RGB2:case _.PVRTC_RGBA2:case _.PVRTC_RGB4:case _.PVRTC_RGBA4:case _.PVRTC2_2BPP:case _.PVRTC2_4BPP:return e.UNSIGNED_BYTE;case _.ASTC_RGBA_4X4:case _.ASTC_RGBA_5X4:case _.ASTC_RGBA_5X5:case _.ASTC_RGBA_6X5:case _.ASTC_RGBA_6X6:case _.ASTC_RGBA_8X5:case _.ASTC_RGBA_8X6:case _.ASTC_RGBA_8X8:case _.ASTC_RGBA_10X5:case _.ASTC_RGBA_10X6:case _.ASTC_RGBA_10X8:case _.ASTC_RGBA_10X10:case _.ASTC_RGBA_12X10:case _.ASTC_RGBA_12X12:case _.ASTC_SRGBA_4X4:case _.ASTC_SRGBA_5X4:case _.ASTC_SRGBA_5X5:case _.ASTC_SRGBA_6X5:case _.ASTC_SRGBA_6X6:case _.ASTC_SRGBA_8X5:case _.ASTC_SRGBA_8X6:case _.ASTC_SRGBA_8X8:case _.ASTC_SRGBA_10X5:case _.ASTC_SRGBA_10X6:case _.ASTC_SRGBA_10X8:case _.ASTC_SRGBA_10X10:case _.ASTC_SRGBA_12X10:case _.ASTC_SRGBA_12X12:default:return e.UNSIGNED_BYTE}}function MB(t,e){switch(t){case p.BOOL:return e.BOOL;case p.BOOL2:return e.BOOL_VEC2;case p.BOOL3:return e.BOOL_VEC3;case p.BOOL4:return e.BOOL_VEC4;case p.INT:return e.INT;case p.INT2:return e.INT_VEC2;case p.INT3:return e.INT_VEC3;case p.INT4:return e.INT_VEC4;case p.UINT:return e.UNSIGNED_INT;case p.FLOAT:return e.FLOAT;case p.FLOAT2:return e.FLOAT_VEC2;case p.FLOAT3:return e.FLOAT_VEC3;case p.FLOAT4:return e.FLOAT_VEC4;case p.MAT2:return e.FLOAT_MAT2;case p.MAT2X3:return e.FLOAT_MAT2x3;case p.MAT2X4:return e.FLOAT_MAT2x4;case p.MAT3X2:return e.FLOAT_MAT3x2;case p.MAT3:return e.FLOAT_MAT3;case p.MAT3X4:return e.FLOAT_MAT3x4;case p.MAT4X2:return e.FLOAT_MAT4x2;case p.MAT4X3:return e.FLOAT_MAT4x3;case p.MAT4:return e.FLOAT_MAT4;case p.SAMPLER2D:return e.SAMPLER_2D;case p.SAMPLER2D_ARRAY:return e.SAMPLER_2D_ARRAY;case p.SAMPLER3D:return e.SAMPLER_3D;case p.SAMPLER_CUBE:return e.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to GL type failed."),p.UNKNOWN}}function IB(t,e){switch(t){case e.BOOL:return p.BOOL;case e.BOOL_VEC2:return p.BOOL2;case e.BOOL_VEC3:return p.BOOL3;case e.BOOL_VEC4:return p.BOOL4;case e.INT:return p.INT;case e.INT_VEC2:return p.INT2;case e.INT_VEC3:return p.INT3;case e.INT_VEC4:return p.INT4;case e.UNSIGNED_INT:return p.UINT;case e.UNSIGNED_INT_VEC2:return p.UINT2;case e.UNSIGNED_INT_VEC3:return p.UINT3;case e.UNSIGNED_INT_VEC4:return p.UINT4;case e.FLOAT:return p.FLOAT;case e.FLOAT_VEC2:return p.FLOAT2;case e.FLOAT_VEC3:return p.FLOAT3;case e.FLOAT_VEC4:return p.FLOAT4;case e.FLOAT_MAT2:return p.MAT2;case e.FLOAT_MAT2x3:return p.MAT2X3;case e.FLOAT_MAT2x4:return p.MAT2X4;case e.FLOAT_MAT3x2:return p.MAT3X2;case e.FLOAT_MAT3:return p.MAT3;case e.FLOAT_MAT3x4:return p.MAT3X4;case e.FLOAT_MAT4x2:return p.MAT4X2;case e.FLOAT_MAT4x3:return p.MAT4X3;case e.FLOAT_MAT4:return p.MAT4;case e.SAMPLER_2D:return p.SAMPLER2D;case e.SAMPLER_2D_ARRAY:return p.SAMPLER2D_ARRAY;case e.SAMPLER_3D:return p.SAMPLER3D;case e.SAMPLER_CUBE:return p.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to Type failed."),p.UNKNOWN}}function BB(t,e){switch(t){case e.BOOL:return 4;case e.BOOL_VEC2:return 8;case e.BOOL_VEC3:return 12;case e.BOOL_VEC4:return 16;case e.INT:return 4;case e.INT_VEC2:return 8;case e.INT_VEC3:return 12;case e.INT_VEC4:return 16;case e.UNSIGNED_INT:return 4;case e.UNSIGNED_INT_VEC2:return 8;case e.UNSIGNED_INT_VEC3:return 12;case e.UNSIGNED_INT_VEC4:return 16;case e.FLOAT:return 4;case e.FLOAT_VEC2:return 8;case e.FLOAT_VEC3:return 12;case e.FLOAT_VEC4:case e.FLOAT_MAT2:return 16;case e.FLOAT_MAT2x3:return 24;case e.FLOAT_MAT2x4:return 32;case e.FLOAT_MAT3x2:return 24;case e.FLOAT_MAT3:return 36;case e.FLOAT_MAT3x4:return 48;case e.FLOAT_MAT4x2:return 32;case e.FLOAT_MAT4x3:return 48;case e.FLOAT_MAT4:return 64;case e.SAMPLER_2D:case e.SAMPLER_2D_ARRAY:case e.SAMPLER_2D_ARRAY_SHADOW:case e.SAMPLER_3D:case e.SAMPLER_CUBE:case e.INT_SAMPLER_2D:case e.INT_SAMPLER_2D_ARRAY:case e.INT_SAMPLER_3D:case e.INT_SAMPLER_CUBE:case e.UNSIGNED_INT_SAMPLER_2D:case e.UNSIGNED_INT_SAMPLER_2D_ARRAY:case e.UNSIGNED_INT_SAMPLER_3D:case e.UNSIGNED_INT_SAMPLER_CUBE:return 4;default:return console.error("Unsupported GLType, get type failed."),0}}function PB(t,e){switch(t){case e.FLOAT_MAT2:case e.FLOAT_MAT2x3:case e.FLOAT_MAT2x4:return 2;case e.FLOAT_MAT3x2:case e.FLOAT_MAT3:case e.FLOAT_MAT3x4:return 3;case e.FLOAT_MAT4x2:case e.FLOAT_MAT4x3:case e.FLOAT_MAT4:return 4;default:return 1}}var DB,OB=[512,513,514,515,516,517,518,519],FB=[0,7680,7681,7682,7683,5386,34055,34056],LB=[32774,32778,32779,32775,32776],NB=[0,1,770,772,771,773,768,774,769,775,776,32769,32770,32771,32772];!function(t){t[t.BEGIN_RENDER_PASS=0]="BEGIN_RENDER_PASS",t[t.END_RENDER_PASS=1]="END_RENDER_PASS",t[t.BIND_STATES=2]="BIND_STATES",t[t.DRAW=3]="DRAW",t[t.UPDATE_BUFFER=4]="UPDATE_BUFFER",t[t.COPY_BUFFER_TO_TEXTURE=5]="COPY_BUFFER_TO_TEXTURE",t[t.BLIT_TEXTURE=6]="BLIT_TEXTURE",t[t.COUNT=7]="COUNT"}(DB||(DB={}));var kB=function(t){this.cmdType=void 0,this.refCount=0,this.cmdType=t},UB=function(t){function e(){var e;return(e=t.call(this,DB.BEGIN_RENDER_PASS)||this).gpuRenderPass=null,e.gpuFramebuffer=null,e.renderArea=new it,e.clearColors=[],e.clearDepth=1,e.clearStencil=0,e}return He(e,t),e.prototype.clear=function(){this.gpuFramebuffer=null,this.clearColors.length=0},e}(kB),GB=function(t){function e(){var e;return(e=t.call(this,DB.BIND_STATES)||this).gpuPipelineState=null,e.gpuInputAssembler=null,e.gpuDescriptorSets=[],e.dynamicOffsets=[],e.dynamicStates=new te,e}return He(e,t),e.prototype.clear=function(){this.gpuPipelineState=null,this.gpuInputAssembler=null,this.gpuDescriptorSets.length=0,this.dynamicOffsets.length=0},e}(kB),VB=function(t){function e(){var e;return(e=t.call(this,DB.DRAW)||this).drawInfo=new gt,e}return He(e,t),e.prototype.clear=function(){},e}(kB),HB=function(t){function e(){var e;return(e=t.call(this,DB.UPDATE_BUFFER)||this).gpuBuffer=null,e.buffer=null,e.offset=0,e.size=0,e}return He(e,t),e.prototype.clear=function(){this.gpuBuffer=null,this.buffer=null},e}(kB),zB=function(t){function e(){var e;return(e=t.call(this,DB.COPY_BUFFER_TO_TEXTURE)||this).gpuTexture=null,e.buffers=[],e.regions=[],e}return He(e,t),e.prototype.clear=function(){this.gpuTexture=null,this.buffers.length=0,this.regions.length=0},e}(kB),XB=function(t){function e(){var e;return(e=t.call(this,DB.BLIT_TEXTURE)||this).srcTexture=null,e.dstTexture=null,e.regions=[],e.filter=b.LINEAR,e}return He(e,t),e.prototype.clear=function(){this.srcTexture=null,this.dstTexture=null,this.regions.length=0},e}(kB),WB=function(){function t(){this.cmds=new n(1),this.beginRenderPassCmds=new n(1),this.bindStatesCmds=new n(1),this.drawCmds=new n(1),this.updateBufferCmds=new n(1),this.copyBufferToTextureCmds=new n(1),this.blitTextureCmds=new n(1)}return t.prototype.clearCmds=function(t){this.beginRenderPassCmds.length&&(t.beginRenderPassCmdPool.freeCmds(this.beginRenderPassCmds),this.beginRenderPassCmds.clear()),this.bindStatesCmds.length&&(t.bindStatesCmdPool.freeCmds(this.bindStatesCmds),this.bindStatesCmds.clear()),this.drawCmds.length&&(t.drawCmdPool.freeCmds(this.drawCmds),this.drawCmds.clear()),this.updateBufferCmds.length&&(t.updateBufferCmdPool.freeCmds(this.updateBufferCmds),this.updateBufferCmds.clear()),this.copyBufferToTextureCmds.length&&(t.copyBufferToTextureCmdPool.freeCmds(this.copyBufferToTextureCmds),this.copyBufferToTextureCmds.clear()),this.blitTextureCmds.length&&(t.blitTextureCmdPool.freeCmds(this.blitTextureCmds),this.blitTextureCmds.clear()),this.cmds.clear()},t}();function YB(t,e,i,n,r){if(e.usage&g.INDIRECT){e.indirects.clearDraws();for(var s=i.drawInfos,a=0;a<s.length;++a)e.indirects.setDrawInfo(n+a,s[a])}else{var o=i,h=t.gl,l=t.stateCache;switch(e.glTarget){case h.ARRAY_BUFFER:t.extensions.useVAO&&l.glVAO&&(h.bindVertexArray(null),l.glVAO=null),qB.gpuInputAssembler=null,l.glArrayBuffer!==e.glBuffer&&(h.bindBuffer(h.ARRAY_BUFFER,e.glBuffer),l.glArrayBuffer=e.glBuffer),r===o.byteLength?h.bufferSubData(e.glTarget,n,o):h.bufferSubData(e.glTarget,n,o.slice(0,r));break;case h.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&l.glVAO&&(h.bindVertexArray(null),l.glVAO=null),qB.gpuInputAssembler=null,l.glElementArrayBuffer!==e.glBuffer&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,e.glBuffer),l.glElementArrayBuffer=e.glBuffer),r===o.byteLength?h.bufferSubData(e.glTarget,n,o):h.bufferSubData(e.glTarget,n,o.slice(0,r));break;case h.UNIFORM_BUFFER:l.glUniformBuffer!==e.glBuffer&&(h.bindBuffer(h.UNIFORM_BUFFER,e.glBuffer),l.glUniformBuffer=e.glBuffer),r===o.byteLength?h.bufferSubData(e.glTarget,n,o):h.bufferSubData(e.glTarget,n,new Float32Array(o,0,r/4));break;default:console.error("Unsupported BufferType, update buffer failed.")}}}function jB(t,e){var i=t.gl;e.glInternalFmt=function(t,e){switch(t){case _.A8:return e.ALPHA;case _.L8:return e.LUMINANCE;case _.LA8:return e.LUMINANCE_ALPHA;case _.R8:return e.R8;case _.R8SN:return e.R8_SNORM;case _.R8UI:return e.R8UI;case _.R8I:return e.R8I;case _.RG8:return e.RG8;case _.RG8SN:return e.RG8_SNORM;case _.RG8UI:return e.RG8UI;case _.RG8I:return e.RG8I;case _.RGB8:return e.RGB8;case _.RGB8SN:return e.RGB8_SNORM;case _.RGB8UI:return e.RGB8UI;case _.RGB8I:return e.RGB8I;case _.BGRA8:case _.RGBA8:return e.RGBA8;case _.RGBA8SN:return e.RGBA8_SNORM;case _.RGBA8UI:return e.RGBA8UI;case _.RGBA8I:return e.RGBA8I;case _.R16I:return e.R16I;case _.R16UI:return e.R16UI;case _.R16F:return e.R16F;case _.RG16I:return e.RG16I;case _.RG16UI:return e.RG16UI;case _.RG16F:return e.RG16F;case _.RGB16I:return e.RGB16I;case _.RGB16UI:return e.RGB16UI;case _.RGB16F:return e.RGB16F;case _.RGBA16I:return e.RGBA16I;case _.RGBA16UI:return e.RGBA16UI;case _.RGBA16F:return e.RGBA16F;case _.R32I:return e.R32I;case _.R32UI:return e.R32UI;case _.R32F:return e.R32F;case _.RG32I:return e.RG32I;case _.RG32UI:return e.RG32UI;case _.RG32F:return e.RG32F;case _.RGB32I:return e.RGB32I;case _.RGB32UI:return e.RGB32UI;case _.RGB32F:return e.RGB32F;case _.RGBA32I:return e.RGBA32I;case _.RGBA32UI:return e.RGBA32UI;case _.RGBA32F:return e.RGBA32F;case _.R5G6B5:return e.RGB565;case _.RGB5A1:return e.RGB5_A1;case _.RGBA4:return e.RGBA4;case _.SRGB8:return e.SRGB8;case _.SRGB8_A8:return e.SRGB8_ALPHA8;case _.RGB10A2:return e.RGB10_A2;case _.RGB10A2UI:return e.RGB10_A2UI;case _.R11G11B10F:return e.R11F_G11F_B10F;case _.DEPTH:return e.DEPTH_COMPONENT32F;case _.DEPTH_STENCIL:return e.DEPTH24_STENCIL8;case _.BC1:return AB.COMPRESSED_RGB_S3TC_DXT1_EXT;case _.BC1_ALPHA:return AB.COMPRESSED_RGBA_S3TC_DXT1_EXT;case _.BC1_SRGB:return AB.COMPRESSED_SRGB_S3TC_DXT1_EXT;case _.BC1_SRGB_ALPHA:return AB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case _.BC2:return AB.COMPRESSED_RGBA_S3TC_DXT3_EXT;case _.BC2_SRGB:return AB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case _.BC3:return AB.COMPRESSED_RGBA_S3TC_DXT5_EXT;case _.BC3_SRGB:return AB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case _.ETC_RGB8:return AB.COMPRESSED_RGB_ETC1_WEBGL;case _.ETC2_RGB8:return AB.COMPRESSED_RGB8_ETC2;case _.ETC2_SRGB8:return AB.COMPRESSED_SRGB8_ETC2;case _.ETC2_RGB8_A1:return AB.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_SRGB8_A1:return AB.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_RGBA8:return AB.COMPRESSED_RGBA8_ETC2_EAC;case _.ETC2_SRGB8_A8:return AB.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case _.EAC_R11:return AB.COMPRESSED_R11_EAC;case _.EAC_R11SN:return AB.COMPRESSED_SIGNED_R11_EAC;case _.EAC_RG11:return AB.COMPRESSED_RG11_EAC;case _.EAC_RG11SN:return AB.COMPRESSED_SIGNED_RG11_EAC;case _.PVRTC_RGB2:return AB.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case _.PVRTC_RGBA2:return AB.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case _.PVRTC_RGB4:return AB.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case _.PVRTC_RGBA4:return AB.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case _.ASTC_RGBA_4X4:return AB.COMPRESSED_RGBA_ASTC_4x4_KHR;case _.ASTC_RGBA_5X4:return AB.COMPRESSED_RGBA_ASTC_5x4_KHR;case _.ASTC_RGBA_5X5:return AB.COMPRESSED_RGBA_ASTC_5x5_KHR;case _.ASTC_RGBA_6X5:return AB.COMPRESSED_RGBA_ASTC_6x5_KHR;case _.ASTC_RGBA_6X6:return AB.COMPRESSED_RGBA_ASTC_6x6_KHR;case _.ASTC_RGBA_8X5:return AB.COMPRESSED_RGBA_ASTC_8x5_KHR;case _.ASTC_RGBA_8X6:return AB.COMPRESSED_RGBA_ASTC_8x6_KHR;case _.ASTC_RGBA_8X8:return AB.COMPRESSED_RGBA_ASTC_8x8_KHR;case _.ASTC_RGBA_10X5:return AB.COMPRESSED_RGBA_ASTC_10x5_KHR;case _.ASTC_RGBA_10X6:return AB.COMPRESSED_RGBA_ASTC_10x6_KHR;case _.ASTC_RGBA_10X8:return AB.COMPRESSED_RGBA_ASTC_10x8_KHR;case _.ASTC_RGBA_10X10:return AB.COMPRESSED_RGBA_ASTC_10x10_KHR;case _.ASTC_RGBA_12X10:return AB.COMPRESSED_RGBA_ASTC_12x10_KHR;case _.ASTC_RGBA_12X12:return AB.COMPRESSED_RGBA_ASTC_12x12_KHR;case _.ASTC_SRGBA_4X4:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case _.ASTC_SRGBA_5X4:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case _.ASTC_SRGBA_5X5:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case _.ASTC_SRGBA_6X5:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case _.ASTC_SRGBA_6X6:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case _.ASTC_SRGBA_8X5:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case _.ASTC_SRGBA_8X6:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case _.ASTC_SRGBA_8X8:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case _.ASTC_SRGBA_10X5:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case _.ASTC_SRGBA_10X6:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case _.ASTC_SRGBA_10X8:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case _.ASTC_SRGBA_10X10:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case _.ASTC_SRGBA_12X10:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case _.ASTC_SRGBA_12X12:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL internal format failed."),e.RGBA}}(e.format,i),e.glFormat=function(t,e){switch(t){case _.A8:return e.ALPHA;case _.L8:return e.LUMINANCE;case _.LA8:return e.LUMINANCE_ALPHA;case _.R8:case _.R8SN:return e.RED;case _.R8UI:case _.R8I:return e.RED;case _.RG8:case _.RG8SN:case _.RG8UI:case _.RG8I:return e.RG;case _.RGB8:case _.RGB8SN:case _.RGB8UI:case _.RGB8I:return e.RGB;case _.BGRA8:case _.RGBA8:case _.RGBA8SN:case _.RGBA8UI:case _.RGBA8I:return e.RGBA;case _.R16UI:case _.R16I:case _.R16F:return e.RED;case _.RG16UI:case _.RG16I:case _.RG16F:return e.RG;case _.RGB16UI:case _.RGB16I:case _.RGB16F:return e.RGB;case _.RGBA16UI:case _.RGBA16I:case _.RGBA16F:return e.RGBA;case _.R32UI:case _.R32I:case _.R32F:return e.RED;case _.RG32UI:case _.RG32I:case _.RG32F:return e.RG;case _.RGB32UI:case _.RGB32I:case _.RGB32F:return e.RGB;case _.RGBA32UI:case _.RGBA32I:case _.RGBA32F:case _.RGB10A2:return e.RGBA;case _.R11G11B10F:case _.R5G6B5:return e.RGB;case _.RGB5A1:case _.RGBA4:return e.RGBA;case _.SRGB8:return e.RGB;case _.SRGB8_A8:return e.RGBA;case _.DEPTH:return e.DEPTH_COMPONENT;case _.DEPTH_STENCIL:return e.DEPTH_STENCIL;case _.BC1:return AB.COMPRESSED_RGB_S3TC_DXT1_EXT;case _.BC1_ALPHA:return AB.COMPRESSED_RGBA_S3TC_DXT1_EXT;case _.BC1_SRGB:return AB.COMPRESSED_SRGB_S3TC_DXT1_EXT;case _.BC1_SRGB_ALPHA:return AB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case _.BC2:return AB.COMPRESSED_RGBA_S3TC_DXT3_EXT;case _.BC2_SRGB:return AB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case _.BC3:return AB.COMPRESSED_RGBA_S3TC_DXT5_EXT;case _.BC3_SRGB:return AB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case _.ETC_RGB8:return AB.COMPRESSED_RGB_ETC1_WEBGL;case _.ETC2_RGB8:return AB.COMPRESSED_RGB8_ETC2;case _.ETC2_SRGB8:return AB.COMPRESSED_SRGB8_ETC2;case _.ETC2_RGB8_A1:return AB.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_SRGB8_A1:return AB.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_RGBA8:return AB.COMPRESSED_RGBA8_ETC2_EAC;case _.ETC2_SRGB8_A8:return AB.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case _.EAC_R11:return AB.COMPRESSED_R11_EAC;case _.EAC_R11SN:return AB.COMPRESSED_SIGNED_R11_EAC;case _.EAC_RG11:return AB.COMPRESSED_RG11_EAC;case _.EAC_RG11SN:return AB.COMPRESSED_SIGNED_RG11_EAC;case _.PVRTC_RGB2:return AB.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case _.PVRTC_RGBA2:return AB.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case _.PVRTC_RGB4:return AB.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case _.PVRTC_RGBA4:return AB.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case _.ASTC_RGBA_4X4:return AB.COMPRESSED_RGBA_ASTC_4x4_KHR;case _.ASTC_RGBA_5X4:return AB.COMPRESSED_RGBA_ASTC_5x4_KHR;case _.ASTC_RGBA_5X5:return AB.COMPRESSED_RGBA_ASTC_5x5_KHR;case _.ASTC_RGBA_6X5:return AB.COMPRESSED_RGBA_ASTC_6x5_KHR;case _.ASTC_RGBA_6X6:return AB.COMPRESSED_RGBA_ASTC_6x6_KHR;case _.ASTC_RGBA_8X5:return AB.COMPRESSED_RGBA_ASTC_8x5_KHR;case _.ASTC_RGBA_8X6:return AB.COMPRESSED_RGBA_ASTC_8x6_KHR;case _.ASTC_RGBA_8X8:return AB.COMPRESSED_RGBA_ASTC_8x8_KHR;case _.ASTC_RGBA_10X5:return AB.COMPRESSED_RGBA_ASTC_10x5_KHR;case _.ASTC_RGBA_10X6:return AB.COMPRESSED_RGBA_ASTC_10x6_KHR;case _.ASTC_RGBA_10X8:return AB.COMPRESSED_RGBA_ASTC_10x8_KHR;case _.ASTC_RGBA_10X10:return AB.COMPRESSED_RGBA_ASTC_10x10_KHR;case _.ASTC_RGBA_12X10:return AB.COMPRESSED_RGBA_ASTC_12x10_KHR;case _.ASTC_RGBA_12X12:return AB.COMPRESSED_RGBA_ASTC_12x12_KHR;case _.ASTC_SRGBA_4X4:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case _.ASTC_SRGBA_5X4:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case _.ASTC_SRGBA_5X5:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case _.ASTC_SRGBA_6X5:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case _.ASTC_SRGBA_6X6:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case _.ASTC_SRGBA_8X5:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case _.ASTC_SRGBA_8X6:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case _.ASTC_SRGBA_8X8:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case _.ASTC_SRGBA_10X5:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case _.ASTC_SRGBA_10X6:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case _.ASTC_SRGBA_10X8:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case _.ASTC_SRGBA_10X10:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case _.ASTC_SRGBA_12X10:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case _.ASTC_SRGBA_12X12:return AB.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL format failed."),e.RGBA}}(e.format,i),e.glType=wB(e.format,i);var n=e.width,r=e.height,s=e.depth,a=e.arrayLayer;switch(e.type){case T.TEX2D:e.glTarget=i.TEXTURE_2D;var o=Math.max(n,r);if(o>t.capabilities.maxTextureSize&&hn(9100,o,t.capabilities.maxTextureSize),e.samples===C.ONE){if(e.glTexture=i.createTexture(),e.size>0){var h=t.stateCache.glTexUnits[t.stateCache.texUnit];if(h.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),h.glTexture=e.glTexture),ne[e.format].isCompressed)for(var l=0;l<e.mipLevel;++l){var u=le(e.format,n,r,1),c=new Uint8Array(u);i.compressedTexImage2D(i.TEXTURE_2D,l,e.glInternalFmt,n,r,0,c),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else i.texStorage2D(i.TEXTURE_2D,e.mipLevel,e.glInternalFmt,n,r)}}else e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,e.samples,e.glInternalFmt,e.width,e.height));break;case T.TEX2D_ARRAY:e.glTarget=i.TEXTURE_2D_ARRAY;var d=Math.max(n,r);if(d>t.capabilities.maxTextureSize&&hn(9100,d,t.capabilities.maxTextureSize),a>t.capabilities.maxArrayTextureLayers&&hn(9100,a,t.capabilities.maxArrayTextureLayers),e.glTexture=i.createTexture(),e.size>0){var f=t.stateCache.glTexUnits[t.stateCache.texUnit];if(f.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D_ARRAY,e.glTexture),f.glTexture=e.glTexture),ne[e.format].isCompressed)for(var p=0;p<e.mipLevel;++p){var g=le(e.format,n,r,a),m=new Uint8Array(g);i.compressedTexImage3D(i.TEXTURE_2D_ARRAY,p,e.glInternalFmt,n,r,a,0,m),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else i.texStorage3D(i.TEXTURE_2D_ARRAY,e.mipLevel,e.glInternalFmt,n,r,a)}break;case T.TEX3D:e.glTarget=i.TEXTURE_3D;var v=Math.max(Math.max(n,r),s);if(v>t.capabilities.max3DTextureSize&&hn(9100,v,t.capabilities.max3DTextureSize),e.glTexture=i.createTexture(),e.size>0){var y=t.stateCache.glTexUnits[t.stateCache.texUnit];if(y.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_3D,e.glTexture),y.glTexture=e.glTexture),ne[e.format].isCompressed)for(var S=0;S<e.mipLevel;++S){var E=le(e.format,n,r,s),A=new Uint8Array(E);i.compressedTexImage3D(i.TEXTURE_3D,S,e.glInternalFmt,n,r,s,0,A),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else i.texStorage3D(i.TEXTURE_3D,e.mipLevel,e.glInternalFmt,n,r,s)}break;case T.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var R=Math.max(n,r);if(R>t.capabilities.maxCubeMapTextureSize&&hn(9100,R,t.capabilities.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var b=t.stateCache.glTexUnits[t.stateCache.texUnit];if(b.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),b.glTexture=e.glTexture),ne[e.format].isCompressed)for(var x=0;x<e.mipLevel;++x){for(var w=le(e.format,n,r,1),M=new Uint8Array(w),I=0;I<6;++I)i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+I,x,e.glInternalFmt,n,r,0,M);n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else i.texStorage2D(i.TEXTURE_CUBE_MAP,e.mipLevel,e.glInternalFmt,n,r)}break;default:console.error("Unsupported TextureType, create texture failed."),e.type=T.TEX2D,e.glTarget=i.TEXTURE_2D}}function KB(t,e){var i=t.gl;if(e.glTexture){var n=t.stateCache.glTexUnits,r=t.stateCache.texUnit;i.deleteTexture(e.glTexture);for(var s=0;s<n.length;++s)n[s].glTexture===e.glTexture&&(i.activeTexture(i.TEXTURE0+s),r=s,i.bindTexture(e.glTarget,null),n[s].glTexture=null);t.stateCache.texUnit=r,e.glTexture=null}if(e.glRenderbuffer){var a=t.stateCache.glRenderbuffer;i.deleteRenderbuffer(e.glRenderbuffer),a===e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,null),a=null),e.glRenderbuffer=null}}var qB={gpuPipelineState:null,gpuInputAssembler:null,glPrimitive:0,invalidateAttachments:[]};function ZB(t,e,i,n,r,s,a){var o=t.gl,h=t.stateCache,l=0;if(i&&e){h.glFramebuffer!==i.glFramebuffer&&(o.bindFramebuffer(o.FRAMEBUFFER,i.glFramebuffer),h.glFramebuffer=i.glFramebuffer),h.viewport.left===n.x&&h.viewport.top===n.y&&h.viewport.width===n.width&&h.viewport.height===n.height||(o.viewport(n.x,n.y,n.width,n.height),h.viewport.left=n.x,h.viewport.top=n.y,h.viewport.width=n.width,h.viewport.height=n.height),h.scissorRect.x===n.x&&h.scissorRect.y===n.y&&h.scissorRect.width===n.width&&h.scissorRect.height===n.height||(o.scissor(n.x,n.y,n.width,n.height),h.scissorRect.x=n.x,h.scissorRect.y=n.y,h.scissorRect.width=n.width,h.scissorRect.height=n.height),qB.invalidateAttachments.length=0;for(var u=0;u<r.length;++u){var c=e.colorAttachments[u];if(c.format!==_.UNKNOWN)switch(c.loadOp){case O.LOAD:break;case O.CLEAR:if(h.bs.targets[0].blendColorMask!==P.ALL&&o.colorMask(!0,!0,!0,!0),i.isOffscreen)xB[0]=r[u].x,xB[1]=r[u].y,xB[2]=r[u].z,xB[3]=r[u].w,o.clearBufferfv(o.COLOR,u,xB);else{var d=r[0];o.clearColor(d.x,d.y,d.z,d.w),l|=o.COLOR_BUFFER_BIT}break;case O.DISCARD:qB.invalidateAttachments.push(o.COLOR_ATTACHMENT0+u)}}if(e.depthStencilAttachment&&e.depthStencilAttachment.format!==_.UNKNOWN){switch(e.depthStencilAttachment.depthLoadOp){case O.LOAD:break;case O.CLEAR:h.dss.depthWrite||o.depthMask(!0),o.clearDepth(s),l|=o.DEPTH_BUFFER_BIT;break;case O.DISCARD:qB.invalidateAttachments.push(o.DEPTH_ATTACHMENT)}if(ne[e.depthStencilAttachment.format].hasStencil)switch(e.depthStencilAttachment.stencilLoadOp){case O.LOAD:break;case O.CLEAR:h.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,65535),h.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,65535),o.clearStencil(a),l|=o.STENCIL_BUFFER_BIT;break;case O.DISCARD:qB.invalidateAttachments.push(o.STENCIL_ATTACHMENT)}}if(i.glFramebuffer&&qB.invalidateAttachments.length&&o.invalidateFramebuffer(o.FRAMEBUFFER,qB.invalidateAttachments),l&&o.clear(l),l&o.COLOR_BUFFER_BIT){var f=h.bs.targets[0].blendColorMask;if(f!==P.ALL){var p=(f&P.R)!==P.NONE,g=(f&P.G)!==P.NONE,m=(f&P.B)!==P.NONE,v=(f&P.A)!==P.NONE;o.colorMask(p,g,m,v)}}l&o.DEPTH_BUFFER_BIT&&!h.dss.depthWrite&&o.depthMask(!1),l&o.STENCIL_BUFFER_BIT&&(h.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,0),h.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,0))}}function QB(t,e,i,n,r,s){var a=t.gl,o=t.stateCache,h=e&&e.gpuShader,l=!1;if(e&&qB.gpuPipelineState!==e){if(qB.gpuPipelineState=e,qB.glPrimitive=e.glPrimitive,h){var u=h.glProgram;o.glProgram!==u&&(a.useProgram(u),o.glProgram=u,l=!0)}var c=e.rs;if(c){if(o.rs.cullMode!==c.cullMode){switch(c.cullMode){case H.NONE:a.disable(a.CULL_FACE);break;case H.FRONT:a.enable(a.CULL_FACE),a.cullFace(a.FRONT);break;case H.BACK:a.enable(a.CULL_FACE),a.cullFace(a.BACK)}t.stateCache.rs.cullMode=c.cullMode}var d=c.isFrontFaceCCW;t.stateCache.rs.isFrontFaceCCW!==d&&(a.frontFace(d?a.CCW:a.CW),t.stateCache.rs.isFrontFaceCCW=d),t.stateCache.rs.depthBias===c.depthBias&&t.stateCache.rs.depthBiasSlop===c.depthBiasSlop||(a.polygonOffset(c.depthBias,c.depthBiasSlop),t.stateCache.rs.depthBias=c.depthBias,t.stateCache.rs.depthBiasSlop=c.depthBiasSlop),t.stateCache.rs.lineWidth!==c.lineWidth&&(a.lineWidth(c.lineWidth),t.stateCache.rs.lineWidth=c.lineWidth)}var _=e.dss;_&&(o.dss.depthTest!==_.depthTest&&(_.depthTest?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST),o.dss.depthTest=_.depthTest),o.dss.depthWrite!==_.depthWrite&&(a.depthMask(_.depthWrite),o.dss.depthWrite=_.depthWrite),o.dss.depthFunc!==_.depthFunc&&(a.depthFunc(OB[_.depthFunc]),o.dss.depthFunc=_.depthFunc),o.dss.stencilTestFront===_.stencilTestFront&&o.dss.stencilTestBack===_.stencilTestBack||(_.stencilTestFront||_.stencilTestBack?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),o.dss.stencilTestFront=_.stencilTestFront,o.dss.stencilTestBack=_.stencilTestBack),o.dss.stencilFuncFront===_.stencilFuncFront&&o.dss.stencilRefFront===_.stencilRefFront&&o.dss.stencilReadMaskFront===_.stencilReadMaskFront||(a.stencilFuncSeparate(a.FRONT,OB[_.stencilFuncFront],_.stencilRefFront,_.stencilReadMaskFront),o.dss.stencilFuncFront=_.stencilFuncFront,o.dss.stencilRefFront=_.stencilRefFront,o.dss.stencilReadMaskFront=_.stencilReadMaskFront),o.dss.stencilFailOpFront===_.stencilFailOpFront&&o.dss.stencilZFailOpFront===_.stencilZFailOpFront&&o.dss.stencilPassOpFront===_.stencilPassOpFront||(a.stencilOpSeparate(a.FRONT,FB[_.stencilFailOpFront],FB[_.stencilZFailOpFront],FB[_.stencilPassOpFront]),o.dss.stencilFailOpFront=_.stencilFailOpFront,o.dss.stencilZFailOpFront=_.stencilZFailOpFront,o.dss.stencilPassOpFront=_.stencilPassOpFront),o.dss.stencilWriteMaskFront!==_.stencilWriteMaskFront&&(a.stencilMaskSeparate(a.FRONT,_.stencilWriteMaskFront),o.dss.stencilWriteMaskFront=_.stencilWriteMaskFront),o.dss.stencilFuncBack===_.stencilFuncBack&&o.dss.stencilRefBack===_.stencilRefBack&&o.dss.stencilReadMaskBack===_.stencilReadMaskBack||(a.stencilFuncSeparate(a.BACK,OB[_.stencilFuncBack],_.stencilRefBack,_.stencilReadMaskBack),o.dss.stencilFuncBack=_.stencilFuncBack,o.dss.stencilRefBack=_.stencilRefBack,o.dss.stencilReadMaskBack=_.stencilReadMaskBack),o.dss.stencilFailOpBack===_.stencilFailOpBack&&o.dss.stencilZFailOpBack===_.stencilZFailOpBack&&o.dss.stencilPassOpBack===_.stencilPassOpBack||(a.stencilOpSeparate(a.BACK,FB[_.stencilFailOpBack],FB[_.stencilZFailOpBack],FB[_.stencilPassOpBack]),o.dss.stencilFailOpBack=_.stencilFailOpBack,o.dss.stencilZFailOpBack=_.stencilZFailOpBack,o.dss.stencilPassOpBack=_.stencilPassOpBack),o.dss.stencilWriteMaskBack!==_.stencilWriteMaskBack&&(a.stencilMaskSeparate(a.BACK,_.stencilWriteMaskBack),o.dss.stencilWriteMaskBack=_.stencilWriteMaskBack));var f=e.bs;if(f){o.bs.isA2C!==f.isA2C&&(f.isA2C?a.enable(a.SAMPLE_ALPHA_TO_COVERAGE):a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),o.bs.isA2C=f.isA2C),o.bs.blendColor.x===f.blendColor.x&&o.bs.blendColor.y===f.blendColor.y&&o.bs.blendColor.z===f.blendColor.z&&o.bs.blendColor.w===f.blendColor.w||(a.blendColor(f.blendColor.x,f.blendColor.y,f.blendColor.z,f.blendColor.w),o.bs.blendColor.x=f.blendColor.x,o.bs.blendColor.y=f.blendColor.y,o.bs.blendColor.z=f.blendColor.z,o.bs.blendColor.w=f.blendColor.w);var p=f.targets[0],g=o.bs.targets[0];g.blend!==p.blend&&(p.blend?a.enable(a.BLEND):a.disable(a.BLEND),g.blend=p.blend),g.blendEq===p.blendEq&&g.blendAlphaEq===p.blendAlphaEq||(a.blendEquationSeparate(LB[p.blendEq],LB[p.blendAlphaEq]),g.blendEq=p.blendEq,g.blendAlphaEq=p.blendAlphaEq),g.blendSrc===p.blendSrc&&g.blendDst===p.blendDst&&g.blendSrcAlpha===p.blendSrcAlpha&&g.blendDstAlpha===p.blendDstAlpha||(a.blendFuncSeparate(NB[p.blendSrc],NB[p.blendDst],NB[p.blendSrcAlpha],NB[p.blendDstAlpha]),g.blendSrc=p.blendSrc,g.blendDst=p.blendDst,g.blendSrcAlpha=p.blendSrcAlpha,g.blendDstAlpha=p.blendDstAlpha),g.blendColorMask!==p.blendColorMask&&(a.colorMask((p.blendColorMask&P.R)!==P.NONE,(p.blendColorMask&P.G)!==P.NONE,(p.blendColorMask&P.B)!==P.NONE,(p.blendColorMask&P.A)!==P.NONE),g.blendColorMask=p.blendColorMask)}}if(e&&e.gpuPipelineLayout&&h){for(var m=h.glBlocks.length,v=e.gpuPipelineLayout.dynamicOffsetIndices,y=0;y<m;y++){var T=h.glBlocks[y],S=n[T.set],E=S&&S.descriptorIndices[T.binding],A=E>=0&&S.gpuDescriptors[E];if(A&&A.gpuBuffer){var C=v[T.set],R=C&&C[T.binding],b=A.gpuBuffer.glOffset;R>=0&&(b+=r[R]),o.glBindUBOs[T.glBinding]===A.gpuBuffer.glBuffer&&o.glBindUBOOffsets[T.glBinding]===b||(b?a.bindBufferRange(a.UNIFORM_BUFFER,T.glBinding,A.gpuBuffer.glBuffer,b,A.gpuBuffer.size):a.bindBufferBase(a.UNIFORM_BUFFER,T.glBinding,A.gpuBuffer.glBuffer),o.glUniformBuffer=o.glBindUBOs[T.glBinding]=A.gpuBuffer.glBuffer,o.glBindUBOOffsets[T.glBinding]=b)}else ks("Buffer binding '"+T.name+"' at set "+T.set+" binding "+T.binding+" is not bounded")}for(var x=h.glSamplerTextures.length,w=0;w<x;w++)for(var M=h.glSamplerTextures[w],I=n[M.set],B=I&&I.descriptorIndices[M.binding],D=B>=0&&I.gpuDescriptors[B],O=0;O<M.units.length;O++){var F=M.units[O],L=o.glTexUnits[F];if(D&&D.gpuTextureView&&D.gpuTextureView.gpuTexture&&D.gpuSampler){var N=D.gpuTextureView,k=N.gpuTexture,U=N.baseLevel,G=U+N.levelCount;if(k.size>0){L.glTexture!==k.glTexture&&(o.texUnit!==F&&(a.activeTexture(a.TEXTURE0+F),o.texUnit=F),k.glTexture?a.bindTexture(k.glTarget,k.glTexture):a.bindTexture(k.glTarget,t.nullTex2D.gpuTexture.glTexture),L.glTexture=k.glTexture);var V=D.gpuSampler.getGLSampler(t,U,G);o.glSamplerUnits[F]!==V&&(a.bindSampler(F,V),o.glSamplerUnits[F]=V)}D=I.gpuDescriptors[++B]}else ks("Sampler binding '"+M.name+"' at set "+M.set+" binding "+M.binding+" index "+O+" is not bounded")}}if(i&&h&&(l||qB.gpuInputAssembler!==i))if(qB.gpuInputAssembler=i,t.extensions.useVAO){var X=i.glVAOs.get(h.glProgram);if(!X){var W;X=a.createVertexArray(),i.glVAOs.set(h.glProgram,X),a.bindVertexArray(X),a.bindBuffer(a.ARRAY_BUFFER,null),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,null),o.glArrayBuffer=null,o.glElementArrayBuffer=null;for(var Y=0;Y<h.glInputs.length;Y++){var j=h.glInputs[Y];W=null;for(var K=0;K<i.glAttribs.length;K++){var q=i.glAttribs[K];if(q.name===j.name){W=q;break}}if(W){o.glArrayBuffer!==W.glBuffer&&(a.bindBuffer(a.ARRAY_BUFFER,W.glBuffer),o.glArrayBuffer=W.glBuffer);for(var Z=0;Z<W.componentCount;++Z){var Q=j.glLoc+Z,J=W.offset+W.size*Z;a.enableVertexAttribArray(Q),o.glCurrentAttribLocs[Q]=!0,a.vertexAttribPointer(Q,W.count,W.glType,W.isNormalized,W.stride,J),a.vertexAttribDivisor(Q,W.isInstanced?1:0)}}}var $=i.gpuIndexBuffer;$&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,$.glBuffer),a.bindVertexArray(null),a.bindBuffer(a.ARRAY_BUFFER,null),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,null),o.glArrayBuffer=null,o.glElementArrayBuffer=null}o.glVAO!==X&&(a.bindVertexArray(X),o.glVAO=X)}else{for(var tt=0;tt<t.capabilities.maxVertexAttributes;++tt)o.glCurrentAttribLocs[tt]=!1;for(var et=0;et<h.glInputs.length;et++){for(var it=h.glInputs[et],nt=null,rt=0;rt<i.glAttribs.length;rt++){var st=i.glAttribs[rt];if(st.name===it.name){nt=st;break}}if(nt){o.glArrayBuffer!==nt.glBuffer&&(a.bindBuffer(a.ARRAY_BUFFER,nt.glBuffer),o.glArrayBuffer=nt.glBuffer);for(var at=0;at<nt.componentCount;++at){var ot=it.glLoc+at,ht=nt.offset+nt.size*at;!o.glEnabledAttribLocs[ot]&&ot>=0&&(a.enableVertexAttribArray(ot),o.glEnabledAttribLocs[ot]=!0),o.glCurrentAttribLocs[ot]=!0,a.vertexAttribPointer(ot,nt.count,nt.glType,nt.isNormalized,nt.stride,ht),a.vertexAttribDivisor(ot,nt.isInstanced?1:0)}}}var lt=i.gpuIndexBuffer;lt&&o.glElementArrayBuffer!==lt.glBuffer&&(a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,lt.glBuffer),o.glElementArrayBuffer=lt.glBuffer);for(var ut=0;ut<t.capabilities.maxVertexAttributes;++ut)o.glEnabledAttribLocs[ut]!==o.glCurrentAttribLocs[ut]&&(a.disableVertexAttribArray(ut),o.glEnabledAttribLocs[ut]=!1)}if(e&&e.dynamicStates.length)for(var ct=e.dynamicStates.length,dt=0;dt<ct;dt++)switch(e.dynamicStates[dt]){case z.LINE_WIDTH:o.rs.lineWidth!==s.lineWidth&&(a.lineWidth(s.lineWidth),o.rs.lineWidth=s.lineWidth);break;case z.DEPTH_BIAS:o.rs.depthBias===s.depthBiasConstant&&o.rs.depthBiasSlop===s.depthBiasSlope||(a.polygonOffset(s.depthBiasConstant,s.depthBiasSlope),o.rs.depthBias=s.depthBiasConstant,o.rs.depthBiasSlop=s.depthBiasSlope);break;case z.BLEND_CONSTANTS:var _t=s.blendConstant;o.bs.blendColor.x===_t.x&&o.bs.blendColor.y===_t.y&&o.bs.blendColor.z===_t.z&&o.bs.blendColor.w===_t.w||(a.blendColor(_t.x,_t.y,_t.z,_t.w),o.bs.blendColor.copy(_t));break;case z.STENCIL_WRITE_MASK:var ft=s.stencilStatesFront,pt=s.stencilStatesBack;o.dss.stencilWriteMaskFront!==ft.writeMask&&(a.stencilMaskSeparate(a.FRONT,ft.writeMask),o.dss.stencilWriteMaskFront=ft.writeMask),o.dss.stencilWriteMaskBack!==pt.writeMask&&(a.stencilMaskSeparate(a.BACK,pt.writeMask),o.dss.stencilWriteMaskBack=pt.writeMask);break;case z.STENCIL_COMPARE_MASK:var gt=s.stencilStatesFront,mt=s.stencilStatesBack;o.dss.stencilRefFront===gt.reference&&o.dss.stencilReadMaskFront===gt.compareMask||(a.stencilFuncSeparate(a.FRONT,OB[o.dss.stencilFuncFront],gt.reference,gt.compareMask),o.dss.stencilRefFront=gt.reference,o.dss.stencilReadMaskFront=gt.compareMask),o.dss.stencilRefBack===mt.reference&&o.dss.stencilReadMaskBack===mt.compareMask||(a.stencilFuncSeparate(a.BACK,OB[o.dss.stencilFuncBack],mt.reference,mt.compareMask),o.dss.stencilRefBack=mt.reference,o.dss.stencilReadMaskBack=mt.compareMask)}}function JB(t,e){var i=t.gl,n=qB.gpuInputAssembler,r=qB.glPrimitive,s=t.extensions.WEBGL_multi_draw;if(n){var a=n.gpuIndexBuffer;if(n.gpuIndirectBuffer){var o=n.gpuIndirectBuffer.indirects;if(o.drawByIndex){for(var h=0;h<o.drawCount;h++)o.byteOffsets[h]=o.offsets[h]*a.stride;if(s)o.instancedDraw?s.multiDrawElementsInstancedWEBGL(r,o.counts,0,n.glIndexType,o.byteOffsets,0,o.instances,0,o.drawCount):s.multiDrawElementsWEBGL(r,o.counts,0,n.glIndexType,o.byteOffsets,0,o.drawCount);else for(var l=0;l<o.drawCount;l++)o.instances[l]?i.drawElementsInstanced(r,o.counts[l],n.glIndexType,o.byteOffsets[l],o.instances[l]):i.drawElements(r,o.counts[l],n.glIndexType,o.byteOffsets[l])}else if(s)o.instancedDraw?s.multiDrawArraysInstancedWEBGL(r,o.offsets,0,o.counts,0,o.instances,0,o.drawCount):s.multiDrawArraysWEBGL(r,o.offsets,0,o.counts,0,o.drawCount);else for(var u=0;u<o.drawCount;u++)o.instances[u]?i.drawArraysInstanced(r,o.offsets[u],o.counts[u],o.instances[u]):i.drawArrays(r,o.offsets[u],o.counts[u])}else if(e.instanceCount)if(a){if(e.indexCount>0){var c=e.firstIndex*a.stride;i.drawElementsInstanced(r,e.indexCount,n.glIndexType,c,e.instanceCount)}}else e.vertexCount>0&&i.drawArraysInstanced(r,e.firstVertex,e.vertexCount,e.instanceCount);else if(a){if(e.indexCount>0){var d=e.firstIndex*a.stride;i.drawElements(r,e.indexCount,n.glIndexType,d)}}else e.vertexCount>0&&i.drawArrays(r,e.firstVertex,e.vertexCount)}}var $B=new Array(DB.COUNT);function tP(t,e){$B.fill(0);for(var i=0;i<e.cmds.length;++i){var n=e.cmds.array[i],r=$B[n]++;switch(n){case DB.BEGIN_RENDER_PASS:var s=e.beginRenderPassCmds.array[r];ZB(t,s.gpuRenderPass,s.gpuFramebuffer,s.renderArea,s.clearColors,s.clearDepth,s.clearStencil);break;case DB.BIND_STATES:var a=e.bindStatesCmds.array[r];QB(t,a.gpuPipelineState,a.gpuInputAssembler,a.gpuDescriptorSets,a.dynamicOffsets,a.dynamicStates);break;case DB.DRAW:JB(t,e.drawCmds.array[r].drawInfo);break;case DB.UPDATE_BUFFER:var o=e.updateBufferCmds.array[r];YB(t,o.gpuBuffer,o.buffer,o.offset,o.size);break;case DB.COPY_BUFFER_TO_TEXTURE:var h=e.copyBufferToTextureCmds.array[r];nP(t,h.buffers,h.gpuTexture,h.regions);break;case DB.BLIT_TEXTURE:var l=e.blitTextureCmds.array[r];rP(t,l.srcTexture,l.dstTexture,l.regions,l.filter)}}}var eP=new Uint8Array(1);function iP(t,e,i,n,r){var s=_e(e).height,a=le(e,r.width,r.height,r.depth),o=le(e,n.width,1,1),h=le(e,n.width,n.height,1),l=le(e,r.width,1,1),u=de(ne[e]);eP.byteLength<a&&(eP=new Uint8Array(a));for(var c=0,d=i,_=0;_<r.depth;_++){d=i+h*_;for(var f=0;f<r.height;f+=s)eP.subarray(c,c+l).set(new Uint8Array(t.buffer,t.byteOffset+d,l)),c+=l,d+=o}return new u(eP.buffer)}function nP(t,e,i,n){var r=t.gl,s=t.stateCache.glTexUnits[t.stateCache.texUnit];s.glTexture!==i.glTexture&&(r.bindTexture(i.glTarget,i.glTexture),s.glTexture=i.glTexture);var a=0,o=0,h=ne[i.format],l=de(h),u=h.isCompressed,c=_e(i.format),d=new nt,_=new et,f=new nt;switch(i.glTarget){case r.TEXTURE_2D:for(var p=0;p<n.length;p++){var g=n[p],m=g.texSubres.mipLevel;_.x=0===g.texOffset.x?0:fe(g.texOffset.x,c.width),_.y=0===g.texOffset.y?0:fe(g.texOffset.y,c.height),d.width=g.texExtent.width<c.width?g.texExtent.width:fe(g.texExtent.width,c.width),d.height=g.texExtent.height<c.height?g.texExtent.width:fe(g.texExtent.height,c.height),f.width=g.buffStride>0?g.buffStride:d.width,f.height=g.buffTexHeight>0?g.buffTexHeight:d.height;var v,y=g.texExtent.width+_.x===i.width>>m?g.texExtent.width:d.width,T=g.texExtent.height+_.y===i.height>>m?g.texExtent.height:d.height,S=e[a++];v=f.width===d.width&&f.height===d.height?new l(S.buffer,S.byteOffset+g.buffOffset):iP(S,i.format,g.buffOffset,f,d),u?i.glInternalFmt!==AB.COMPRESSED_RGB_ETC1_WEBGL?r.compressedTexSubImage2D(r.TEXTURE_2D,m,_.x,_.y,y,T,i.glFormat,v):r.compressedTexImage2D(r.TEXTURE_2D,m,i.glInternalFmt,y,T,0,v):r.texSubImage2D(r.TEXTURE_2D,m,_.x,_.y,y,T,i.glFormat,i.glType,v)}break;case r.TEXTURE_2D_ARRAY:for(var A=0;A<n.length;A++){var C=n[A],R=C.texSubres.mipLevel;_.x=0===C.texOffset.x?0:fe(C.texOffset.x,c.width),_.y=0===C.texOffset.y?0:fe(C.texOffset.y,c.height),d.width=C.texExtent.width<c.width?C.texExtent.width:fe(C.texExtent.width,c.width),d.height=C.texExtent.height<c.height?C.texExtent.width:fe(C.texExtent.height,c.height),d.depth=1,f.width=C.buffStride>0?C.buffStride:d.width,f.height=C.buffTexHeight>0?C.buffTexHeight:d.height;var b=C.texExtent.width+_.x===i.width>>R?C.texExtent.width:d.width,x=C.texExtent.height+_.y===i.height>>R?C.texExtent.height:d.height,w=C.texSubres.baseArrayLayer+C.texSubres.layerCount;for(o=C.texSubres.baseArrayLayer;o<w;++o){_.z=o;var M,I=e[a++];M=f.width===d.width&&f.height===d.height?new l(I.buffer,I.byteOffset+C.buffOffset):iP(I,i.format,C.buffOffset,f,d),u?i.glInternalFmt!==AB.COMPRESSED_RGB_ETC1_WEBGL?r.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,R,_.x,_.y,_.z,b,x,d.depth,i.glFormat,M):r.compressedTexImage3D(r.TEXTURE_2D_ARRAY,R,i.glInternalFmt,b,x,d.depth,0,M):r.texSubImage3D(r.TEXTURE_2D_ARRAY,R,_.x,_.y,_.z,b,x,d.depth,i.glFormat,i.glType,M)}}break;case r.TEXTURE_3D:for(var B=0;B<n.length;B++){var P=n[B],D=P.texSubres.mipLevel;_.x=0===P.texOffset.x?0:fe(P.texOffset.x,c.width),_.y=0===P.texOffset.y?0:fe(P.texOffset.y,c.height),_.z=P.texOffset.z,d.width=P.texExtent.width<c.width?P.texExtent.width:fe(P.texExtent.width,c.width),d.height=P.texExtent.height<c.height?P.texExtent.width:fe(P.texExtent.height,c.height),d.depth=P.texExtent.depth,f.width=P.buffStride>0?P.buffStride:d.width,f.height=P.buffTexHeight>0?P.buffTexHeight:d.height;var O,F=P.texExtent.width+_.x===i.width>>D?P.texExtent.width:d.width,L=P.texExtent.height+_.y===i.height>>D?P.texExtent.height:d.height,N=e[a++];O=f.width===d.width&&f.height===d.height?new l(N.buffer,N.byteOffset+P.buffOffset):iP(N,i.format,P.buffOffset,f,d),u?i.glInternalFmt!==AB.COMPRESSED_RGB_ETC1_WEBGL?r.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,D,_.x,_.y,_.z,F,L,d.depth,i.glFormat,O):r.compressedTexImage3D(r.TEXTURE_2D_ARRAY,D,i.glInternalFmt,F,L,d.depth,0,O):r.texSubImage3D(r.TEXTURE_2D_ARRAY,D,_.x,_.y,_.z,F,L,d.depth,i.glFormat,i.glType,O)}break;case r.TEXTURE_CUBE_MAP:for(var k=0;k<n.length;k++){var U=n[k],G=U.texSubres.mipLevel;_.x=0===U.texOffset.x?0:fe(U.texOffset.x,c.width),_.y=0===U.texOffset.y?0:fe(U.texOffset.y,c.height),d.width=U.texExtent.width<c.width?U.texExtent.width:fe(U.texExtent.width,c.width),d.height=U.texExtent.height<c.height?U.texExtent.width:fe(U.texExtent.height,c.height),f.width=U.buffStride>0?U.buffStride:d.width,f.height=U.buffTexHeight>0?U.buffTexHeight:d.height;var V=U.texExtent.width+_.x===i.width>>G?U.texExtent.width:d.width,H=U.texExtent.height+_.y===i.height>>G?U.texExtent.height:d.height,z=U.texSubres.baseArrayLayer+U.texSubres.layerCount;for(o=U.texSubres.baseArrayLayer;o<z;++o){var X,W=e[a++];X=f.width===d.width&&f.height===d.height?new l(W.buffer,W.byteOffset+U.buffOffset):iP(W,i.format,U.buffOffset,f,d),u?i.glInternalFmt!==AB.COMPRESSED_RGB_ETC1_WEBGL?r.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,G,_.x,_.y,V,H,i.glFormat,X):r.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,G,i.glInternalFmt,V,H,0,X):r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,G,_.x,_.y,V,H,i.glFormat,i.glType,X)}}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&E.GEN_MIPMAP&&r.generateMipmap(i.glTarget)}function rP(t,e,i,n,r){var s=t.gl,a=t.stateCache,o=t.blitManager;if(o){var h=r===b.LINEAR||r===b.ANISOTROPIC?s.LINEAR:s.NEAREST,l=o.srcFramebuffer,u=o.dstFramebuffer,c=a.glReadFramebuffer,d=a.glFramebuffer,_=n[0].srcSubres.mipLevel,f=n[0].dstSubres.mipLevel,p=function(t){var e=0,i=s.COLOR_ATTACHMENT0;return t.hasStencil?i=s.DEPTH_STENCIL_ATTACHMENT:t.hasDepth&&(i=s.DEPTH_ATTACHMENT),t.hasDepth||t.hasStencil?(t.hasDepth&&(e|=s.DEPTH_BUFFER_BIT),t.hasStencil&&(e|=s.STENCIL_BUFFER_BIT)):e|=s.COLOR_BUFFER_BIT,{mask:e,attachment:i}},g=n.map((function(t,e){return e}));g.sort((function(t,e){return n[t].srcSubres.mipLevel-n[e].srcSubres.mipLevel}));var m=p(ne[e.format]),v=m.mask,y=m.attachment,T=p(ne[i.format]).attachment;a.glReadFramebuffer!==l&&(s.bindFramebuffer(s.READ_FRAMEBUFFER,l),a.glReadFramebuffer=l),a.glFramebuffer!==u&&(s.bindFramebuffer(s.DRAW_FRAMEBUFFER,u),a.glFramebuffer=u),e.glTexture?s.framebufferTexture2D(s.READ_FRAMEBUFFER,y,e.glTarget,e.glTexture,_):s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,y,s.RENDERBUFFER,e.glRenderbuffer),i.glTexture?s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,T,i.glTarget,i.glTexture,f):s.framebufferRenderbuffer(s.DRAW_FRAMEBUFFER,T,s.RENDERBUFFER,i.glRenderbuffer);for(var S=0;S<g.length;S++){var E=n[g[S]];e.glTexture&&_!==E.srcSubres.mipLevel&&(_=E.srcSubres.mipLevel,s.framebufferTexture2D(s.READ_FRAMEBUFFER,y,e.glTarget,e.glTexture,_)),i.glTexture&&f!==E.dstSubres.mipLevel&&(f=E.dstSubres.mipLevel,s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,T,i.glTarget,i.glTexture,f)),s.blitFramebuffer(E.srcOffset.x,E.srcOffset.y,E.srcOffset.x+E.srcExtent.width,E.srcOffset.y+E.srcExtent.height,E.dstOffset.x,E.dstOffset.y,E.dstOffset.x+E.dstExtent.width,E.dstOffset.y+E.dstExtent.height,v,h)}a.glReadFramebuffer!==c&&(s.bindFramebuffer(s.READ_FRAMEBUFFER,c),a.glReadFramebuffer=c),a.glFramebuffer!==d&&(s.bindFramebuffer(s.DRAW_FRAMEBUFFER,d),a.glFramebuffer=d)}}var sP=function(){function t(){this.counts=void 0,this.offsets=void 0,this.instances=void 0,this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1,this.byteOffsets=void 0,this._capacity=4,this.counts=new Int32Array(this._capacity),this.offsets=new Int32Array(this._capacity),this.instances=new Int32Array(this._capacity),this.byteOffsets=new Int32Array(this._capacity)}var e=t.prototype;return e.clearDraws=function(){this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1},e.setDrawInfo=function(t,e){this._ensureCapacity(t),this.drawByIndex=e.indexCount>0,this.instancedDraw=!!e.instanceCount,this.drawCount=Math.max(t+1,this.drawCount),this.drawByIndex?(this.counts[t]=e.indexCount,this.offsets[t]=e.firstIndex):(this.counts[t]=e.vertexCount,this.offsets[t]=e.firstVertex),this.instances[t]=Math.max(1,e.instanceCount)},e._ensureCapacity=function(t){if(!(this._capacity>t)){this._capacity=Vi(t);var e=new Int32Array(this._capacity),i=new Int32Array(this._capacity),n=new Int32Array(this._capacity);this.byteOffsets=new Int32Array(this._capacity),e.set(this.counts),i.set(this.offsets),n.set(this.instances),this.counts=e,this.offsets=i,this.instances=n}},t}(),aP=function(){function t(){this._srcFramebuffer=void 0,this._dstFramebuffer=void 0;var t=RB.instance.gl;this._srcFramebuffer=t.createFramebuffer(),this._dstFramebuffer=t.createFramebuffer()}return t.prototype.destroy=function(){var t=RB.instance.gl;t.deleteFramebuffer(this._srcFramebuffer),t.deleteFramebuffer(this._dstFramebuffer)},Pi(t,[{key:"srcFramebuffer",get:function(){return this._srcFramebuffer}},{key:"dstFramebuffer",get:function(){return this._dstFramebuffer}}]),t}(),oP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuBuffer=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){if("buffer"in t){this._isBufferView=!0;var e=t.buffer;this._usage=e.usage,this._memUsage=e.memUsage,this._size=this._stride=t.range,this._count=1,this._flags=e.flags,this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,indirects:e.gpuBuffer.indirects,glTarget:e.gpuBuffer.glTarget,glBuffer:e.gpuBuffer.glBuffer,glOffset:t.offset}}else this._usage=t.usage,this._memUsage=t.memUsage,this._size=t.size,this._stride=Math.max(t.stride||this._size,1),this._count=this._size/this._stride,this._flags=t.flags,this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,indirects:new sP,glTarget:0,glBuffer:null,glOffset:0},function(t,e){var i=t.gl,n=t.stateCache,r=e.memUsage&y.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;if(e.usage&g.VERTEX){e.glTarget=i.ARRAY_BUFFER;var s=i.createBuffer();s&&(e.glBuffer=s,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),qB.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer),i.bufferData(i.ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null))}else if(e.usage&g.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;var a=i.createBuffer();a&&(e.glBuffer=a,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),qB.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null))}else if(e.usage&g.UNIFORM){e.glTarget=i.UNIFORM_BUFFER;var o=i.createBuffer();o&&e.size>0&&(e.glBuffer=o,t.stateCache.glUniformBuffer!==e.glBuffer&&(i.bindBuffer(i.UNIFORM_BUFFER,e.glBuffer),t.stateCache.glUniformBuffer=e.glBuffer),i.bufferData(i.UNIFORM_BUFFER,e.size,r),i.bindBuffer(i.UNIFORM_BUFFER,null),t.stateCache.glUniformBuffer=null)}else e.usage&g.INDIRECT||e.usage&g.TRANSFER_DST||e.usage&g.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE}(RB.instance,this._gpuBuffer),RB.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(this._isBufferView||(function(t,e){var i=t.gl,n=t.stateCache;if(e.glBuffer){switch(e.glTarget){case i.ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),t.stateCache.glVAO=null),qB.gpuInputAssembler=null,i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null;break;case i.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),t.stateCache.glVAO=null),qB.gpuInputAssembler=null,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null;break;case i.UNIFORM_BUFFER:i.bindBuffer(i.UNIFORM_BUFFER,null),t.stateCache.glUniformBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}(RB.instance,this._gpuBuffer),RB.instance.memoryStatus.bufferSize-=this._size),this._gpuBuffer=null)},i.resize=function(t){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var e,i,n,r,s,a=this._size;a!==t&&(this._size=t,this._count=this._size/this._stride,this._gpuBuffer&&(this._gpuBuffer.size=t,t>0&&(e=RB.instance,i=this._gpuBuffer,n=e.gl,r=e.stateCache,s=i.memUsage&y.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW,i.usage&g.VERTEX?(e.extensions.useVAO&&r.glVAO&&(n.bindVertexArray(null),r.glVAO=null),qB.gpuInputAssembler=null,r.glArrayBuffer!==i.glBuffer&&n.bindBuffer(n.ARRAY_BUFFER,i.glBuffer),i.buffer?n.bufferData(n.ARRAY_BUFFER,i.buffer,s):n.bufferData(n.ARRAY_BUFFER,i.size,s),n.bindBuffer(n.ARRAY_BUFFER,null),r.glArrayBuffer=null):i.usage&g.INDEX?(e.extensions.useVAO&&r.glVAO&&(n.bindVertexArray(null),r.glVAO=null),qB.gpuInputAssembler=null,e.stateCache.glElementArrayBuffer!==i.glBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i.glBuffer),i.buffer?n.bufferData(n.ELEMENT_ARRAY_BUFFER,i.buffer,s):n.bufferData(n.ELEMENT_ARRAY_BUFFER,i.size,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):i.usage&g.UNIFORM?(e.stateCache.glUniformBuffer!==i.glBuffer&&n.bindBuffer(n.UNIFORM_BUFFER,i.glBuffer),n.bufferData(n.UNIFORM_BUFFER,i.size,s),n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null):(i.usage&g.INDIRECT||i.usage&g.TRANSFER_DST||i.usage&g.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),i.glTarget=n.NONE),RB.instance.memoryStatus.bufferSize-=a,RB.instance.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?console.warn("cannot update through buffer views!"):(i=void 0!==e?e:this._usage&g.INDIRECT?0:t.byteLength,YB(RB.instance,this._gpuBuffer,t,0,i))},Pi(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}}]),e}(a),hP=function(){function t(t,e){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(e),this._freeCmds=new n(e);for(var i=0;i<e;++i)this._frees[i]=new t;this._freeIdx=e-1}var e=t.prototype;return e.alloc=function(t){if(this._freeIdx<0){var e=2*this._frees.length,i=this._frees;this._frees=new Array(e);for(var n=e-i.length,r=0;r<n;++r)this._frees[r]=new t;for(var s=n,a=0;s<e;++s,++a)this._frees[s]=i[a];this._freeIdx+=n}var o=this._frees[this._freeIdx];return this._frees[this._freeIdx--]=null,++o.refCount,o},e.free=function(t){0==--t.refCount&&this._freeCmds.push(t)},e.freeCmds=function(t){for(var e=0;e<t.length;++e)0==--t.array[e].refCount&&this._freeCmds.push(t.array[e])},e.release=function(){for(var t=0;t<this._freeCmds.length;++t){var e=this._freeCmds.array[t];e.clear(),this._frees[++this._freeIdx]=e}this._freeCmds.clear()},t}(),lP=function(){function t(){this.beginRenderPassCmdPool=void 0,this.bindStatesCmdPool=void 0,this.drawCmdPool=void 0,this.updateBufferCmdPool=void 0,this.copyBufferToTextureCmdPool=void 0,this.blitTextureCmdPool=void 0,this.beginRenderPassCmdPool=new hP(UB,1),this.bindStatesCmdPool=new hP(GB,1),this.drawCmdPool=new hP(VB,1),this.updateBufferCmdPool=new hP(HB,1),this.copyBufferToTextureCmdPool=new hP(zB,1),this.blitTextureCmdPool=new hP(XB,1)}var e=t.prototype;return e.clearCmds=function(t){t.beginRenderPassCmds.length&&(this.beginRenderPassCmdPool.freeCmds(t.beginRenderPassCmds),t.beginRenderPassCmds.clear()),t.bindStatesCmds.length&&(this.bindStatesCmdPool.freeCmds(t.bindStatesCmds),t.bindStatesCmds.clear()),t.drawCmds.length&&(this.drawCmdPool.freeCmds(t.drawCmds),t.drawCmds.clear()),t.updateBufferCmds.length&&(this.updateBufferCmdPool.freeCmds(t.updateBufferCmds),t.updateBufferCmds.clear()),t.copyBufferToTextureCmds.length&&(this.copyBufferToTextureCmdPool.freeCmds(t.copyBufferToTextureCmds),t.copyBufferToTextureCmds.clear()),t.blitTextureCmds.length&&(this.blitTextureCmdPool.freeCmds(t.blitTextureCmds),t.blitTextureCmds.clear()),t.cmds.clear()},e.releaseCmds=function(){this.beginRenderPassCmdPool.release(),this.bindStatesCmdPool.release(),this.drawCmdPool.release(),this.updateBufferCmdPool.release(),this.copyBufferToTextureCmdPool.release(),this.blitTextureCmdPool.release()},t}(),uP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).cmdPackage=new WB,e._cmdAllocator=new lP,e._isInRenderPass=!1,e._curGPUPipelineState=null,e._curGPUDescriptorSets=[],e._curGPUInputAssembler=null,e._curDynamicOffsets=Array(8).fill(0),e._curDynamicStates=new te,e._isStateInvalied=!1,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type,this._queue=t.queue;for(var e=RB.instance.bindingMappings.blockOffsets.length,i=0;i<e;i++)this._curGPUDescriptorSets.push(null)},i.destroy=function(){this._cmdAllocator.clearCmds(this.cmdPackage)},i.begin=function(){this._cmdAllocator.clearCmds(this.cmdPackage),this._curGPUPipelineState=null,this._curGPUInputAssembler=null,this._curGPUDescriptorSets.length=0,this._numDrawCalls=0,this._numInstances=0,this._numTris=0},i.end=function(){this._isStateInvalied&&this.bindStates(),this._isInRenderPass=!1},i.beginRenderPass=function(t,e,i,n,r,s){var a=this._cmdAllocator.beginRenderPassCmdPool.alloc(UB);a.gpuRenderPass=t.gpuRenderPass,a.gpuFramebuffer=e.gpuFramebuffer,a.renderArea.copy(i);for(var o=0;o<n.length;++o)a.clearColors[o]=n[o];a.clearDepth=r,a.clearStencil=s,this.cmdPackage.beginRenderPassCmds.push(a),this.cmdPackage.cmds.push(DB.BEGIN_RENDER_PASS),this._isInRenderPass=!0},i.endRenderPass=function(){this._isInRenderPass=!1},i.bindPipelineState=function(t){var e=t.gpuPipelineState;e!==this._curGPUPipelineState&&(this._curGPUPipelineState=e,this._isStateInvalied=!0)},i.bindDescriptorSet=function(t,e,i){var n=e.gpuDescriptorSet;if(n!==this._curGPUDescriptorSets[t]&&(this._curGPUDescriptorSets[t]=n,this._isStateInvalied=!0),i){var r,s=null===(r=this._curGPUPipelineState)||void 0===r?void 0:r.gpuPipelineLayout;if(s){for(var a=this._curDynamicOffsets,o=s.dynamicOffsetOffsets[t],h=0;h<i.length;h++)a[o+h]=i[h];this._isStateInvalied=!0}}},i.bindInputAssembler=function(t){var e=t.gpuInputAssembler;this._curGPUInputAssembler=e,this._isStateInvalied=!0},i.setViewport=function(t){var e=this._curDynamicStates.viewport;e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height&&e.minDepth===t.minDepth&&e.maxDepth===t.maxDepth||(e.left=t.left,e.top=t.top,e.width=t.width,e.height=t.height,e.minDepth=t.minDepth,e.maxDepth=t.maxDepth,this._isStateInvalied=!0)},i.setScissor=function(t){var e=this._curDynamicStates.scissor;e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,this._isStateInvalied=!0)},i.setLineWidth=function(t){this._curDynamicStates.lineWidth!==t&&(this._curDynamicStates.lineWidth=t,this._isStateInvalied=!0)},i.setDepthBias=function(t,e,i){var n=this._curDynamicStates;n.depthBiasConstant===t&&n.depthBiasClamp===e&&n.depthBiasSlope===i||(n.depthBiasConstant=t,n.depthBiasClamp=e,n.depthBiasSlope=i,this._isStateInvalied=!0)},i.setBlendConstants=function(t){var e=this._curDynamicStates.blendConstant;e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w||(e.copy(t),this._isStateInvalied=!0)},i.setDepthBound=function(t,e){var i=this._curDynamicStates;i.depthMinBounds===t&&i.depthMaxBounds===e||(i.depthMinBounds=t,i.depthMaxBounds=e,this._isStateInvalied=!0)},i.setStencilWriteMask=function(t,e){var i=this._curDynamicStates.stencilStatesFront,n=this._curDynamicStates.stencilStatesBack;t&X.FRONT&&i.writeMask!==e&&(i.writeMask=e,this._isStateInvalied=!0),t&X.BACK&&n.writeMask!==e&&(n.writeMask=e,this._isStateInvalied=!0)},i.setStencilCompareMask=function(t,e,i){var n=this._curDynamicStates.stencilStatesFront,r=this._curDynamicStates.stencilStatesBack;t&X.FRONT&&(n.compareMask===i&&n.reference===e||(n.reference=e,n.compareMask=i,this._isStateInvalied=!0)),t&X.BACK&&(r.compareMask===i&&r.reference===e||(r.reference=e,r.compareMask=i,this._isStateInvalied=!0))},i.draw=function(t){if(this._type===K.PRIMARY&&this._isInRenderPass||this._type===K.SECONDARY){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t,i=this._cmdAllocator.drawCmdPool.alloc(VB);i.drawInfo.copy(e),this.cmdPackage.drawCmds.push(i),this.cmdPackage.cmds.push(DB.DRAW),++this._numDrawCalls,this._numInstances+=e.instanceCount;var n=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=n/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(n-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.updateBuffer=function(t,e,i){if(this._type===K.PRIMARY&&!this._isInRenderPass||this._type===K.SECONDARY){var n=t.gpuBuffer;if(n){var r,s=this._cmdAllocator.updateBufferCmdPool.alloc(HB),a=0;t.usage&g.INDIRECT||(a=void 0!==i?i:e.byteLength),r=e,s.gpuBuffer=n,s.buffer=r,s.offset=0,s.size=a,this.cmdPackage.updateBufferCmds.push(s),this.cmdPackage.cmds.push(DB.UPDATE_BUFFER)}}else console.error("Command 'updateBuffer' must be recorded outside a render pass.")},i.copyBuffersToTexture=function(t,e,i){if(this._type===K.PRIMARY&&!this._isInRenderPass||this._type===K.SECONDARY){var n=e.gpuTexture;if(n){var r=this._cmdAllocator.copyBufferToTextureCmdPool.alloc(zB);r.gpuTexture=n,r.regions=i,r.buffers=t,this.cmdPackage.copyBufferToTextureCmds.push(r),this.cmdPackage.cmds.push(DB.COPY_BUFFER_TO_TEXTURE)}}else console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.")},i.execute=function(t,e){for(var i=0;i<e;++i){for(var n=t[i],r=0;r<n.cmdPackage.beginRenderPassCmds.length;++r){var s=n.cmdPackage.beginRenderPassCmds.array[r];++s.refCount,this.cmdPackage.beginRenderPassCmds.push(s)}for(var a=0;a<n.cmdPackage.bindStatesCmds.length;++a){var o=n.cmdPackage.bindStatesCmds.array[a];++o.refCount,this.cmdPackage.bindStatesCmds.push(o)}for(var h=0;h<n.cmdPackage.drawCmds.length;++h){var l=n.cmdPackage.drawCmds.array[h];++l.refCount,this.cmdPackage.drawCmds.push(l)}for(var u=0;u<n.cmdPackage.updateBufferCmds.length;++u){var c=n.cmdPackage.updateBufferCmds.array[u];++c.refCount,this.cmdPackage.updateBufferCmds.push(c)}for(var d=0;d<n.cmdPackage.copyBufferToTextureCmds.length;++d){var _=n.cmdPackage.copyBufferToTextureCmds.array[d];++_.refCount,this.cmdPackage.copyBufferToTextureCmds.push(_)}for(var f=0;f<n.cmdPackage.blitTextureCmds.length;++f){var p=n.cmdPackage.blitTextureCmds.array[f];++p.refCount,this.cmdPackage.blitTextureCmds.push(p)}this.cmdPackage.cmds.concat(n.cmdPackage.cmds.array),this._numDrawCalls+=n._numDrawCalls,this._numInstances+=n._numInstances,this._numTris+=n._numTris}},i.pipelineBarrier=function(){},i.bindStates=function(){var t=this._cmdAllocator.bindStatesCmdPool.alloc(GB);t.gpuPipelineState=this._curGPUPipelineState,Array.prototype.push.apply(t.gpuDescriptorSets,this._curGPUDescriptorSets),Array.prototype.push.apply(t.dynamicOffsets,this._curDynamicOffsets),t.gpuInputAssembler=this._curGPUInputAssembler,t.dynamicStates=this._curDynamicStates,this.cmdPackage.bindStatesCmds.push(t),this.cmdPackage.cmds.push(DB.BIND_STATES),this._isStateInvalied=!1},i.blitTexture=function(t,e,i,n){var r=this._cmdAllocator.blitTextureCmdPool.alloc(XB);r.srcTexture=t.gpuTexture,r.dstTexture=e.gpuTexture,r.regions=i,r.filter=n,++this._numDrawCalls,this.cmdPackage.blitTextureCmds.push(r),this.cmdPackage.cmds.push(DB.BLIT_TEXTURE)},e}(o),cP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuFramebuffer=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._renderPass=t.renderPass,this._colorTextures=t.colorTextures||[],this._depthStencilTexture=t.depthStencilTexture||null;for(var e=[],i=0;i<t.colorTextures.length;i++){var n=t.colorTextures[i];n&&e.push(n.gpuTextureView)}var r=null;t.depthStencilTexture&&(r=t.depthStencilTexture.gpuTextureView);var s=Number.MAX_SAFE_INTEGER;this._gpuFramebuffer={gpuRenderPass:t.renderPass.gpuRenderPass,gpuColorViews:e,gpuDepthStencilView:r,glFramebuffer:null,isOffscreen:!0,get width(){return this.isOffscreen?s:this.gpuColorViews.length>0?this.gpuColorViews[0].gpuTexture.width:this.gpuDepthStencilView.gpuTexture.width},set width(t){s=t},get height(){return this.isOffscreen?s:this.gpuColorViews.length>0?this.gpuColorViews[0].gpuTexture.height:this.gpuDepthStencilView.gpuTexture.height},set height(t){}},function(t,e){for(var i=0;i<e.gpuColorViews.length;++i)if(e.gpuColorViews[i].gpuTexture.isSwapchainTexture)return void(e.isOffscreen=!1);var n=t.gl,r=[],s=n.createFramebuffer();if(s){e.glFramebuffer=s,t.stateCache.glFramebuffer!==e.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,e.glFramebuffer);for(var a=0;a<e.gpuColorViews.length;++a){var o=e.gpuColorViews[a],h=o.gpuTexture;h&&(h.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,h.glTarget,h.glTexture,o.baseLevel):n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,n.RENDERBUFFER,h.glRenderbuffer),r.push(n.COLOR_ATTACHMENT0+a),e.width=Math.min(e.width,h.width>>o.baseLevel),e.height=Math.min(e.height,h.height>>o.baseLevel))}var l=e.gpuDepthStencilView;if(l){var u=l.gpuTexture,c=ne[u.format].hasStencil?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;u.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,c,u.glTarget,u.glTexture,e.gpuDepthStencilView.baseLevel):n.framebufferRenderbuffer(n.FRAMEBUFFER,c,n.RENDERBUFFER,u.glRenderbuffer),e.width=Math.min(e.width,u.width>>l.baseLevel),e.height=Math.min(e.height,u.height>>l.baseLevel)}n.drawBuffers(r);var d=n.checkFramebufferStatus(n.FRAMEBUFFER);if(d!==n.FRAMEBUFFER_COMPLETE)switch(d){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case n.FRAMEBUFFER_UNSUPPORTED:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED")}t.stateCache.glFramebuffer!==e.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,t.stateCache.glFramebuffer)}}(RB.instance,this._gpuFramebuffer)},i.destroy=function(){var t,e;this._gpuFramebuffer&&(t=RB.instance,(e=this._gpuFramebuffer).glFramebuffer&&(t.gl.deleteFramebuffer(e.glFramebuffer),t.stateCache.glFramebuffer===e.glFramebuffer&&(t.gl.bindFramebuffer(t.gl.FRAMEBUFFER,null),t.stateCache.glFramebuffer=null),e.glFramebuffer=null),this._gpuFramebuffer=null)},Pi(e,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}}]),e}(ve),dP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuInputAssembler=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){if(0!==t.vertexBuffers.length){if(this._attributes=t.attributes,this._attributesHash=this.computeAttributesHash(),this._vertexBuffers=t.vertexBuffers,t.indexBuffer)this._indexBuffer=t.indexBuffer,this._drawInfo.indexCount=this._indexBuffer.size/this._indexBuffer.stride,this._drawInfo.firstIndex=0;else{var e=this._vertexBuffers[0];this._drawInfo.vertexCount=e.size/e.stride,this._drawInfo.firstVertex=0,this._drawInfo.vertexOffset=0}this._drawInfo.instanceCount=0,this._drawInfo.firstInstance=0,this._indirectBuffer=t.indirectBuffer||null;for(var i=new Array(t.vertexBuffers.length),n=0;n<t.vertexBuffers.length;++n){var r=t.vertexBuffers[n];r.gpuBuffer&&(i[n]=r.gpuBuffer)}var s=null,a=0;if(t.indexBuffer&&(s=t.indexBuffer.gpuBuffer))switch(s.stride){case 1:a=5121;break;case 2:a=5123;break;case 4:a=5125;break;default:console.error("Illegal index buffer stride.")}var o=null;t.indirectBuffer&&(o=t.indirectBuffer.gpuBuffer),this._gpuInputAssembler={attributes:t.attributes,gpuVertexBuffers:i,gpuIndexBuffer:s,gpuIndirectBuffer:o,glAttribs:[],glIndexType:a,glVAOs:new Map},function(t,e){var i=t.gl;e.glAttribs=new Array(e.attributes.length);for(var n=[0,0,0,0,0,0,0,0],r=0;r<e.attributes.length;++r){var s=e.attributes[r],a=void 0!==s.stream?s.stream:0,o=e.gpuVertexBuffers[a],h=wB(s.format,i),l=ne[s.format].size;e.glAttribs[r]={name:s.name,glBuffer:o.glBuffer,glType:h,size:l,count:ne[s.format].count,stride:o.stride,componentCount:PB(h,i),isNormalized:void 0!==s.isNormalized&&s.isNormalized,isInstanced:void 0!==s.isInstanced&&s.isInstanced,offset:n[a]},n[a]+=l}}(RB.instance,this._gpuInputAssembler)}else console.error("InputAssemblerInfo.vertexBuffers is null.")},i.destroy=function(){var t=RB.instance;this._gpuInputAssembler&&t.extensions.useVAO&&function(t,e){for(var i=e.glVAOs.values(),n=i.next(),r=t.gl,s=t.stateCache.glVAO;!n.done;)r.deleteVertexArray(n.value),s===n.value&&(r.bindVertexArray(null),s=null),n=i.next();t.stateCache.glVAO=s,e.glVAOs.clear()}(t,this._gpuInputAssembler),this._gpuInputAssembler=null},Pi(e,[{key:"gpuInputAssembler",get:function(){return this._gpuInputAssembler}}]),e}(ye),_P=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuDescriptorSetLayout=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){Array.prototype.push.apply(this._bindings,t.bindings);for(var e=0,i=-1,n=[],r=0;r<this._bindings.length;r++){var s=this._bindings[r];n.push(e),e+=s.count,s.binding>i&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var a=this._descriptorIndices=Array(i+1).fill(-1),o=0;o<this._bindings.length;o++){var h=this._bindings[o];this._bindingIndices[h.binding]=o,a[h.binding]=n[o]}for(var l=[],u=0;u<this._bindings.length;u++){var c=this._bindings[u];if(c.descriptorType&ae)for(var d=0;d<c.count;d++)l.push(c.binding)}this._gpuDescriptorSetLayout={bindings:this._bindings,dynamicBindings:l,descriptorIndices:a,descriptorCount:e}},i.destroy=function(){this._bindings.length=0},Pi(e,[{key:"gpuDescriptorSetLayout",get:function(){return this._gpuDescriptorSetLayout}}]),e}(Te),fP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuPipelineLayout=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){Array.prototype.push.apply(this._setLayouts,t.setLayouts);for(var e=[],i=[],n=0,r=[],s=0;s<this._setLayouts.length;s++){for(var a=this._setLayouts[s],o=a.gpuDescriptorSetLayout.dynamicBindings,h=Array(a.bindingIndices.length).fill(-1),l=0;l<o.length;l++){var u=o[l];h[u]<0&&(h[u]=n+l)}i.push(a.gpuDescriptorSetLayout),e.push(h),r.push(n),n+=o.length}this._gpuPipelineLayout={gpuSetLayouts:i,dynamicOffsetIndices:e,dynamicOffsetCount:n,dynamicOffsetOffsets:r}},i.destroy=function(){this._setLayouts.length=0},Pi(e,[{key:"gpuPipelineLayout",get:function(){return this._gpuPipelineLayout}}]),e}(Se),pP=[0,1,3,2,0,0,0,4,5,6,0,0,0,0],gP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuPipelineState=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._primitive=t.primitive,this._shader=t.shader,this._pipelineLayout=t.pipelineLayout;var e=this._bs;if(t.blendState){var i=t.blendState,n=i.targets;n&&n.forEach((function(t,i){e.setTarget(i,t)})),void 0!==i.isA2C&&(e.isA2C=i.isA2C),void 0!==i.isIndepend&&(e.isIndepend=i.isIndepend),void 0!==i.blendColor&&(e.blendColor=i.blendColor)}Object.assign(this._rs,t.rasterizerState),Object.assign(this._dss,t.depthStencilState),this._is=t.inputState,this._renderPass=t.renderPass,this._dynamicStates=t.dynamicStates;for(var r=[],s=0;s<31;s++)this._dynamicStates&1<<s&&r.push(1<<s);this._gpuPipelineState={glPrimitive:pP[t.primitive],gpuShader:t.shader.gpuShader,gpuPipelineLayout:t.pipelineLayout.gpuPipelineLayout,rs:t.rasterizerState,dss:t.depthStencilState,bs:t.blendState,gpuRenderPass:t.renderPass.gpuRenderPass,dynamicStates:r}},i.destroy=function(){this._gpuPipelineState=null},Pi(e,[{key:"gpuPipelineState",get:function(){return this._gpuPipelineState}}]),e}(xe),mP=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.beginRenderPass=function(t,e,i,n,r,s){ZB(RB.instance,t.gpuRenderPass,e.gpuFramebuffer,i,n,r,s),this._isInRenderPass=!0},i.draw=function(t){if(this._isInRenderPass){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t;JB(RB.instance,e),++this._numDrawCalls,this._numInstances+=e.instanceCount;var i=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=i/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(i-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.setViewport=function(t){var e=RB.instance,i=e.stateCache,n=e.gl;i.viewport.left===t.left&&i.viewport.top===t.top&&i.viewport.width===t.width&&i.viewport.height===t.height||(n.viewport(t.left,t.top,t.width,t.height),i.viewport.left=t.left,i.viewport.top=t.top,i.viewport.width=t.width,i.viewport.height=t.height)},i.setScissor=function(t){var e=RB.instance,i=e.stateCache,n=e.gl;i.scissorRect.x===t.x&&i.scissorRect.y===t.y&&i.scissorRect.width===t.width&&i.scissorRect.height===t.height||(n.scissor(t.x,t.y,t.width,t.height),i.scissorRect.x=t.x,i.scissorRect.y=t.y,i.scissorRect.width=t.width,i.scissorRect.height=t.height)},i.updateBuffer=function(t,e,i){if(this._isInRenderPass)console.error("Command 'updateBuffer' must be recorded outside a render pass.");else{var n,r=t.gpuBuffer;r&&(n=void 0!==i?i:t.usage&g.INDIRECT?0:e.byteLength,YB(RB.instance,r,e,0,n))}},i.copyBuffersToTexture=function(t,e,i){if(this._isInRenderPass)console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.");else{var n=e.gpuTexture;n&&nP(RB.instance,t,n,i)}},i.execute=function(t,e){for(var i=0;i<e;++i){var n=t[i];tP(RB.instance,n.cmdPackage),this._numDrawCalls+=n._numDrawCalls,this._numInstances+=n._numInstances,this._numTris+=n._numTris}},i.bindStates=function(){QB(RB.instance,this._curGPUPipelineState,this._curGPUInputAssembler,this._curGPUDescriptorSets,this._curDynamicOffsets,this._curDynamicStates),this._isStateInvalied=!1},i.blitTexture=function(t,e,i,n){var r=t.gpuTexture,s=e.gpuTexture;rP(RB.instance,r,s,i,n)},e}(uP),vP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).numDrawCalls=0,e.numInstances=0,e.numTris=0,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type},i.destroy=function(){},i.submit=function(t){for(var e=0;e<t.length;e++){var i=t[e];this.numDrawCalls+=i.numDrawCalls,this.numInstances+=i.numInstances,this.numTris+=i.numTris}},i.clear=function(){this.numDrawCalls=0,this.numInstances=0,this.numTris=0},e}(we),yP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuRenderPass=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._colorInfos=t.colorAttachments,this._depthStencilInfo=t.depthStencilAttachment,this._subpasses=t.subpasses,this._gpuRenderPass={colorAttachments:this._colorInfos,depthStencilAttachment:this._depthStencilInfo},this._hash=this.computeHash()},i.destroy=function(){this._gpuRenderPass=null},Pi(e,[{key:"gpuRenderPass",get:function(){return this._gpuRenderPass}}]),e}(Me),TP=function(t){function e(e,i){var n,r,s,a;return(n=t.call(this,e,i)||this)._gpuSampler=null,n._gpuSampler={glSamplers:new Map,minFilter:n._info.minFilter,magFilter:n._info.magFilter,mipFilter:n._info.mipFilter,addressU:n._info.addressU,addressV:n._info.addressV,addressW:n._info.addressW,glMinFilter:0,glMagFilter:0,glWrapS:0,glWrapT:0,glWrapR:0,getGLSampler:function(t,e,i){var n=t.gl,r=e<<16|i;if(!this.glSamplers.has(r)){var s=n.createSampler();s&&(this.glSamplers.set(r,s),n.samplerParameteri(s,n.TEXTURE_MIN_FILTER,this.glMinFilter),n.samplerParameteri(s,n.TEXTURE_MAG_FILTER,this.glMagFilter),n.samplerParameteri(s,n.TEXTURE_WRAP_S,this.glWrapS),n.samplerParameteri(s,n.TEXTURE_WRAP_T,this.glWrapT),n.samplerParameteri(s,n.TEXTURE_WRAP_R,this.glWrapR),n.samplerParameterf(s,n.TEXTURE_MIN_LOD,e),n.samplerParameterf(s,n.TEXTURE_MAX_LOD,i))}return this.glSamplers.get(r)}},r=RB.instance,s=n._gpuSampler,a=r.gl,s.minFilter===b.LINEAR||s.minFilter===b.ANISOTROPIC?s.mipFilter===b.LINEAR||s.mipFilter===b.ANISOTROPIC?s.glMinFilter=a.LINEAR_MIPMAP_LINEAR:s.mipFilter===b.POINT?s.glMinFilter=a.LINEAR_MIPMAP_NEAREST:s.glMinFilter=a.LINEAR:s.mipFilter===b.LINEAR||s.mipFilter===b.ANISOTROPIC?s.glMinFilter=a.NEAREST_MIPMAP_LINEAR:s.mipFilter===b.POINT?s.glMinFilter=a.NEAREST_MIPMAP_NEAREST:s.glMinFilter=a.NEAREST,s.magFilter===b.LINEAR||s.magFilter===b.ANISOTROPIC?s.glMagFilter=a.LINEAR:s.glMagFilter=a.NEAREST,s.glWrapS=bB[s.addressU],s.glWrapT=bB[s.addressV],s.glWrapR=bB[s.addressW],n}return He(e,t),e.prototype.destroy=function(){this._gpuSampler&&(function(t,e){for(var i=t.gl,n=e.glSamplers.values().next();!n.done;){i.deleteSampler(n.value);for(var r=t.stateCache.glSamplerUnits,s=0;s<r.length;++s)r[s]===n.value&&(i.bindSampler(s,null),r[s]=null)}e.glSamplers.clear()}(RB.instance,this._gpuSampler),this._gpuSampler=null)},Pi(e,[{key:"gpuSampler",get:function(){return this._gpuSampler}}]),e}(Ie),SP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuShader=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._name=t.name,this._stages=t.stages,this._attributes=t.attributes,this._blocks=t.blocks,this._samplers=t.samplers,this._gpuShader={name:t.name,blocks:t.blocks.slice(),samplerTextures:t.samplerTextures.slice(),subpassInputs:t.subpassInputs.slice(),gpuStages:new Array(t.stages.length),glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplerTextures:[]};for(var e=0;e<t.stages.length;++e){var i=t.stages[e];this._gpuShader.gpuStages[e]={type:i.stage,source:i.source,glShader:null}}},i.destroy=function(){var t,e;this._gpuShader&&(t=RB.instance,(e=this._gpuShader).glProgram&&(t.gl.deleteProgram(e.glProgram),t.stateCache.glProgram===e.glProgram&&(t.gl.useProgram(null),t.stateCache.glProgram=null),e.glProgram=null),this._gpuShader=null)},Pi(e,[{key:"gpuShader",get:function(){return null===this._gpuShader.glProgram&&function(t,e){for(var i=t.gl,n=function(t){var n=e.gpuStages[t],r=0,s="",a=1;switch(n.type){case D.VERTEX:s="VertexShader",r=i.VERTEX_SHADER;break;case D.FRAGMENT:s="FragmentShader",r=i.FRAGMENT_SHADER;break;default:return console.error("Unsupported ShaderType."),{v:void 0}}var o=i.createShader(r);if(o&&(n.glShader=o,i.shaderSource(n.glShader,"#version 300 es\n"+n.source),i.compileShader(n.glShader),!i.getShaderParameter(n.glShader,i.COMPILE_STATUS))){console.error(s+" in '"+e.name+"' compilation failed."),console.error("Shader source dump:",n.source.replace(/^|\n/g,(function(){return"\n"+a+++" "}))),console.error(i.getShaderInfoLog(n.glShader));for(var h=0;h<e.gpuStages.length;h++){var l=e.gpuStages[t];l.glShader&&(i.deleteShader(l.glShader),l.glShader=null)}return{v:void 0}}},r=0;r<e.gpuStages.length;r++){var s=n(r);if("object"==typeof s)return s.v}var a=i.createProgram();if(a){e.glProgram=a;for(var o=!(!We.rendering||!We.rendering.enableEffectImport),h=0;h<e.gpuStages.length;h++){var l=e.gpuStages[h];i.attachShader(e.glProgram,l.glShader)}i.linkProgram(e.glProgram);for(var u=0;u<e.gpuStages.length;u++){var c=e.gpuStages[u];c.glShader&&(i.detachShader(e.glProgram,c.glShader),i.deleteShader(c.glShader),c.glShader=null)}if(!i.getProgramParameter(e.glProgram,i.LINK_STATUS))return console.error("Failed to link shader '"+e.name+"'."),void console.error(i.getProgramInfoLog(e.glProgram));Gn("Shader '"+e.name+"' compilation succeeded.");var d=i.getProgramParameter(e.glProgram,i.ACTIVE_ATTRIBUTES);e.glInputs=new Array(d);for(var _=0;_<d;++_){var f=i.getActiveAttrib(e.glProgram,_);if(f){var g,m=f.name.indexOf("[");g=-1!==m?f.name.substr(0,m):f.name;var v=i.getAttribLocation(e.glProgram,g),y=IB(f.type,i),T=BB(f.type,i);e.glInputs[_]={name:g,type:y,stride:T,count:f.size,size:T*f.size,glType:f.type,glLoc:v}}}var S,E,A,C,R=i.getProgramParameter(e.glProgram,i.ACTIVE_UNIFORM_BLOCKS);if(R){e.glBlocks=new Array(R);for(var b=0;b<R;++b){var x=(S=i.getActiveUniformBlockName(e.glProgram,b)).indexOf("[");-1!==x&&(S=S.substr(0,x)),C=null;for(var w=0;w<e.blocks.length;w++)if(e.blocks[w].name===S){C=e.blocks[w];break}if(C){E=b,A=i.getActiveUniformBlockParameter(e.glProgram,E,i.UNIFORM_BLOCK_DATA_SIZE);var M=o?C.flattened:C.binding+(t.bindingMappings.blockOffsets[C.set]||0);i.uniformBlockBinding(e.glProgram,E,M),e.glBlocks[b]={set:C.set,binding:C.binding,idx:E,name:S,size:A,glBinding:M}}else ks("Block '"+S+"' does not bound")}}for(var I=0;I<e.subpassInputs.length;++I){var B=e.subpassInputs[I];e.samplerTextures.push(new Ct(B.set,B.binding,B.name,p.SAMPLER2D,B.count))}if(e.samplerTextures.length>0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var P=0;P<e.samplerTextures.length;++P){var O=e.samplerTextures[P];e.glSamplerTextures[P]={set:O.set,binding:O.binding,name:O.name,type:O.type,count:O.count,units:[],glUnits:null,glType:MB(O.type,i),glLoc:null}}}var F=[],L=[],N=t.stateCache.texUnitCacheMap;if(o)for(var k=0;k<e.samplerTextures.length;++k){var U=e.samplerTextures[k],G=i.getUniformLocation(e.glProgram,U.name);G&&-1!==G.id&&(F.push(e.glSamplerTextures[k]),L.push(G)),void 0===N[U.name]&&(N[U.name]=U.flattened%t.capabilities.maxTextureUnits)}else{for(var V=0,H=0;H<e.blocks.length;++H)e.blocks[H].set===t.bindingMappings.flexibleSet&&V++;for(var z=0,X=0;X<e.samplerTextures.length;++X){var W=e.samplerTextures[X],Y=i.getUniformLocation(e.glProgram,W.name);if(Y&&-1!==Y.id&&(F.push(e.glSamplerTextures[X]),L.push(Y)),void 0===N[W.name]){var j=W.binding+t.bindingMappings.samplerTextureOffsets[W.set]+z;W.set===t.bindingMappings.flexibleSet&&(j-=V),N[W.name]=j%t.capabilities.maxTextureUnits,z+=W.count-1}}}if(F.length){for(var K=[],q=0;q<F.length;++q){var Z=F[q],Q=N[Z.name];if(void 0!==Q){Z.glLoc=L[q];for(var J=0;J<Z.count;++J){for(;K[Q];)Q=(Q+1)%t.capabilities.maxTextureUnits;Z.units.push(Q),K[Q]=!0}}}for(var $=0,tt=0;tt<F.length;++tt){var et=F[tt];if(!et.glLoc){for(et.glLoc=L[tt];K[$];)$++;for(var it=0;it<et.count;++it){for(;K[$];)$=($+1)%t.capabilities.maxTextureUnits;void 0===N[et.name]&&(N[et.name]=$),et.units.push($),K[$]=!0}}}t.stateCache.glProgram!==e.glProgram&&i.useProgram(e.glProgram);for(var nt=0;nt<F.length;nt++){var rt=F[nt];rt.glUnits=new Int32Array(rt.units),i.uniform1iv(rt.glLoc,rt.glUnits)}t.stateCache.glProgram!==e.glProgram&&i.useProgram(t.stateCache.glProgram)}e.glSamplerTextures=F}}(RB.instance,this._gpuShader),this._gpuShader}}]),e}(Be),EP=function(){function t(){this.glArrayBuffer=null,this.glElementArrayBuffer=null,this.glUniformBuffer=null,this.glBindUBOs=[],this.glBindUBOOffsets=[],this.glVAO=null,this.texUnit=0,this.glTexUnits=[],this.glSamplerUnits=[],this.glRenderbuffer=null,this.glFramebuffer=null,this.glReadFramebuffer=null,this.viewport=new lt,this.scissorRect=new it(0,0,0,0),this.rs=new Ee,this.dss=new Ae,this.bs=new Re,this.glProgram=null,this.glEnabledAttribLocs=[],this.glCurrentAttribLocs=[],this.texUnitCacheMap={}}return t.prototype.initialize=function(t,e,i){for(var n=0;n<t;++n)this.glTexUnits.push({glTexture:null});this.glSamplerUnits.length=t,this.glSamplerUnits.fill(null),this.glBindUBOs.length=e,this.glBindUBOs.fill(null),this.glBindUBOOffsets.length=e,this.glBindUBOOffsets.fill(0),this.glEnabledAttribLocs.length=i,this.glEnabledAttribLocs.fill(!1),this.glCurrentAttribLocs.length=i,this.glCurrentAttribLocs.fill(!1)},t}(),AP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuTexture=null,e._gpuTextureView=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t,e){var i=t,n=t;if("texture"in t&&(i=n.texture.info,this._isTextureView=!0),this._info.copy(i),this._isPowerOf2=he(this._info.width)&&he(this._info.height),this._size=ue(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,this._isTextureView){var r;if(this._viewInfo.copy(n),this._gpuTexture=n.texture._gpuTexture,(null===(r=this._gpuTexture)||void 0===r?void 0:r.format)!==i.format)return void console.log("GPU memory alias is not supported");this._gpuTextureView={gpuTexture:this._gpuTexture,type:n.type,format:n.format,baseLevel:n.baseLevel,levelCount:n.levelCount}}else this._gpuTexture={type:i.type,format:i.format,usage:i.usage,width:i.width,height:i.height,depth:i.depth,size:this._size,arrayLayer:i.layerCount,mipLevel:i.levelCount,samples:i.samples,flags:i.flags,isPowerOf2:this._isPowerOf2,glTarget:0,glInternalFmt:0,glFormat:0,glType:0,glUsage:0,glTexture:null,glRenderbuffer:null,glWrapS:0,glWrapT:0,glMinFilter:0,glMagFilter:0,isSwapchainTexture:e||!1},!this._gpuTexture.isSwapchainTexture&&this._gpuTexture&&(jB(RB.instance,this._gpuTexture),RB.instance.memoryStatus.textureSize+=this._size),this._viewInfo.texture=this,this._viewInfo.type=t.type,this._viewInfo.format=t.format,this._viewInfo.baseLevel=0,this._viewInfo.levelCount=t.levelCount,this._viewInfo.baseLayer=0,this._viewInfo.layerCount=t.layerCount,this._gpuTextureView={gpuTexture:this._gpuTexture,type:this._viewInfo.type,format:this._viewInfo.format,baseLevel:this._viewInfo.baseLevel,levelCount:this._viewInfo.levelCount}},i.destroy=function(){!this._isTextureView&&this._gpuTexture&&(KB(RB.instance,this._gpuTexture),RB.instance.memoryStatus.textureSize-=this._size,this._gpuTexture=null)},i.getGLTextureHandle=function(){var t=this._gpuTexture;return t?t.glTexture?t.glTexture:t.glRenderbuffer?t.glRenderbuffer:0:0},i.resize=function(t,i){if(this._info.width!==t||this._info.height!==i){this._info.levelCount===e.getLevelCount(this._info.width,this._info.height)?this._info.levelCount=e.getLevelCount(t,i):this._info.levelCount>1&&(this._info.levelCount=Math.min(this._info.levelCount,e.getLevelCount(t,i)));var n=this._size;this._info.width=t,this._info.height=i,this._size=ue(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,!this._isTextureView&&this._gpuTexture&&(this._gpuTexture.width=t,this._gpuTexture.height=i,this._gpuTexture.size=this._size,this._gpuTexture.isSwapchainTexture||(function(t,e){if(e.size){var i=t.gl,n=e.width,r=e.height,s=e.depth,a=e.arrayLayer;switch(e.type){case T.TEX2D:e.glTarget=i.TEXTURE_2D;var o=Math.max(n,r);if(o>t.capabilities.maxTextureSize&&hn(9100,o,t.capabilities.maxTextureSize),e.samples===C.ONE){var h=t.stateCache.glTexUnits[t.stateCache.texUnit];if(h.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),h.glTexture=e.glTexture),ne[e.format].isCompressed)for(var l=0;l<e.mipLevel;++l){var u=le(e.format,n,r,1),c=new Uint8Array(u);i.compressedTexImage2D(i.TEXTURE_2D,l,e.glInternalFmt,n,r,0,c),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else KB(t,e),jB(t,e)}else e.glRenderbuffer&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,e.samples,e.glInternalFmt,e.width,e.height));break;case T.TEX2D_ARRAY:e.glTarget=i.TEXTURE_2D_ARRAY;var d=Math.max(n,r);if(d>t.capabilities.maxTextureSize&&hn(9100,d,t.capabilities.maxTextureSize),a>t.capabilities.maxArrayTextureLayers&&hn(9100,a,t.capabilities.maxArrayTextureLayers),e.glTexture=i.createTexture(),e.size>0){var _=t.stateCache.glTexUnits[t.stateCache.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D_ARRAY,e.glTexture),_.glTexture=e.glTexture),ne[e.format].isCompressed)for(var f=0;f<e.mipLevel;++f){var p=le(e.format,n,r,a),g=new Uint8Array(p);i.compressedTexImage3D(i.TEXTURE_2D_ARRAY,f,e.glInternalFmt,n,r,a,0,g),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else i.texStorage3D(i.TEXTURE_2D_ARRAY,e.mipLevel,e.glInternalFmt,n,r,a)}break;case T.TEX3D:e.glTarget=i.TEXTURE_3D;var m=Math.max(Math.max(n,r),s);if(m>t.capabilities.max3DTextureSize&&hn(9100,m,t.capabilities.max3DTextureSize),e.glTexture=i.createTexture(),e.size>0){var v=t.stateCache.glTexUnits[t.stateCache.texUnit];if(v.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_3D,e.glTexture),v.glTexture=e.glTexture),ne[e.format].isCompressed)for(var y=0;y<e.mipLevel;++y){var S=le(e.format,n,r,s),E=new Uint8Array(S);i.compressedTexImage3D(i.TEXTURE_3D,y,e.glInternalFmt,n,r,s,0,E),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else i.texStorage3D(i.TEXTURE_3D,e.mipLevel,e.glInternalFmt,n,r,s)}break;case T.CUBE:e.type=T.CUBE,e.glTarget=i.TEXTURE_CUBE_MAP;var A=Math.max(n,r);A>t.capabilities.maxCubeMapTextureSize&&hn(9100,A,t.capabilities.maxTextureSize);var R=t.stateCache.glTexUnits[t.stateCache.texUnit];if(R.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),R.glTexture=e.glTexture),ne[e.format].isCompressed)for(var b=0;b<6;++b){n=e.width,r=e.height;for(var x=0;x<e.mipLevel;++x){var w=le(e.format,n,r,1),M=new Uint8Array(w);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+b,x,e.glInternalFmt,n,r,0,M),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}}else KB(t,e),jB(t,e);break;default:console.error("Unsupported TextureType, create texture failed."),e.type=T.TEX2D,e.glTarget=i.TEXTURE_2D}}}(RB.instance,this._gpuTexture),RB.instance.memoryStatus.textureSize-=n,RB.instance.memoryStatus.textureSize+=this._size))}},i.initAsSwapchainTexture=function(t){var e=new yt;e.format=t.format,e.usage=ne[t.format].hasDepth?S.DEPTH_STENCIL_ATTACHMENT:S.COLOR_ATTACHMENT,e.width=t.width,e.height=t.height,this.initialize(e,!0)},Pi(e,[{key:"gpuTexture",get:function(){return this._gpuTexture}},{key:"gpuTextureView",get:function(){return this._gpuTextureView}}]),e}(Pe),CP="webglcontextlost";function RP(t,e){for(var i=["","WEBKIT_","MOZ_"],n=0;n<i.length;++n){var r=t.getExtension(i[n]+e);if(r)return r}return null}function bP(t){var e={EXT_texture_filter_anisotropic:RP(t,"EXT_texture_filter_anisotropic"),EXT_color_buffer_half_float:RP(t,"EXT_color_buffer_half_float"),EXT_color_buffer_float:RP(t,"EXT_color_buffer_float"),WEBGL_compressed_texture_etc1:RP(t,"WEBGL_compressed_texture_etc1"),WEBGL_compressed_texture_etc:RP(t,"WEBGL_compressed_texture_etc"),WEBGL_compressed_texture_pvrtc:RP(t,"WEBGL_compressed_texture_pvrtc"),WEBGL_compressed_texture_astc:RP(t,"WEBGL_compressed_texture_astc"),WEBGL_compressed_texture_s3tc:RP(t,"WEBGL_compressed_texture_s3tc"),WEBGL_compressed_texture_s3tc_srgb:RP(t,"WEBGL_compressed_texture_s3tc_srgb"),WEBGL_debug_shaders:RP(t,"WEBGL_debug_shaders"),WEBGL_lose_context:RP(t,"WEBGL_lose_context"),WEBGL_debug_renderer_info:RP(t,"WEBGL_debug_renderer_info"),OES_texture_half_float_linear:RP(t,"OES_texture_half_float_linear"),OES_texture_float_linear:RP(t,"OES_texture_float_linear"),WEBGL_multi_draw:null,useVAO:!0};return Ds.os!==Os.ANDROID&&Ds.os!==Os.IOS&&(e.WEBGL_multi_draw=RP(t,"WEBGL_multi_draw")),e}var xP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).stateCache=new EP,e.nullTex2D=null,e.nullTexCube=null,e._canvas=null,e._webGL2ContextLostHandler=null,e._extensions=null,e._blitManager=null,e}He(e,t);var i=e.prototype;return i.initialize=function(t){this._canvas=t.windowHandle,this._webGL2ContextLostHandler=this._onWebGLContextLost.bind(this),this._canvas.addEventListener(CP,this._onWebGLContextLost);var e=RB.instance.gl;this.stateCache.initialize(RB.instance.capabilities.maxTextureUnits,RB.instance.capabilities.maxUniformBufferBindings,RB.instance.capabilities.maxVertexAttributes),this._extensions=bP(e),function(t){t.activeTexture(t.TEXTURE0),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.bindFramebuffer(t.FRAMEBUFFER,null),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.enable(t.DEPTH_TEST),t.depthMask(!0),t.depthFunc(t.LESS),t.stencilFuncSeparate(t.FRONT,t.ALWAYS,1,65535),t.stencilOpSeparate(t.FRONT,t.KEEP,t.KEEP,t.KEEP),t.stencilMaskSeparate(t.FRONT,65535),t.stencilFuncSeparate(t.BACK,t.ALWAYS,1,65535),t.stencilOpSeparate(t.BACK,t.KEEP,t.KEEP,t.KEEP),t.stencilMaskSeparate(t.BACK,65535),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.disable(t.BLEND),t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.colorMask(!0,!0,!0,!0),t.blendColor(0,0,0,0)}(e);var i=_.RGBA8,n=_.DEPTH_STENCIL,r=e.getParameter(e.DEPTH_BITS),s=e.getParameter(e.STENCIL_BITS);r&&s?n=_.DEPTH_STENCIL:r&&(n=_.DEPTH),this._colorTexture=new AP,this._colorTexture.initAsSwapchainTexture({swapchain:this,format:i,width:t.width,height:t.height}),this._depthStencilTexture=new AP,this._depthStencilTexture.initAsSwapchainTexture({swapchain:this,format:n,width:t.width,height:t.height}),this.nullTex2D=RB.instance.createTexture(new yt(T.TEX2D,S.SAMPLED,_.RGBA8,2,2,E.NONE)),this.nullTexCube=RB.instance.createTexture(new yt(T.CUBE,S.SAMPLED,_.RGBA8,2,2,E.NONE,6));var a=new ht;a.texExtent.width=2,a.texExtent.height=2;var o=new Uint8Array(this.nullTex2D.size);o.fill(0),RB.instance.copyBuffersToTexture([o],this.nullTex2D,[a]),a.texSubres.layerCount=6,RB.instance.copyBuffersToTexture([o,o,o,o,o,o],this.nullTexCube,[a]),this._blitManager=new aP},i.destroy=function(){this._canvas&&this._webGL2ContextLostHandler&&(this._canvas.removeEventListener(CP,this._webGL2ContextLostHandler),this._webGL2ContextLostHandler=null),this.nullTex2D&&(this.nullTex2D.destroy(),this.nullTex2D=null),this.nullTexCube&&(this.nullTexCube.destroy(),this.nullTexCube=null),this._blitManager&&(this._blitManager.destroy(),this._blitManager=null),this._extensions=null,this._canvas=null},i.resize=function(t,e){this._colorTexture.width===t&&this._colorTexture.height===e||(Gn("Resizing swapchain: "+t+"x"+e),this._canvas.width=t,this._canvas.height=e,this._colorTexture.resize(t,e),this._depthStencilTexture.resize(t,e))},i._onWebGLContextLost=function(t){Zi(11e3),Gi(t)},Pi(e,[{key:"extensions",get:function(){return this._extensions}},{key:"blitManager",get:function(){return this._blitManager}}]),e}(me),wP=t("WebGL2Device",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._swapchain=null,e._context=null,e._bindingMappings=null,e._textureExclusive=new Array(_.COUNT),e}He(e,t);var i=e.prototype;return i.initialize=function(t){RB.setInstance(this),this._gfxAPI=u.WEBGL2;var e=this._bindingMappingInfo=t.bindingMappingInfo,i=[],n=[],r=e.setIndices[0];i[r]=0,n[r]=0;for(var s=1;s<e.setIndices.length;++s){var a=e.setIndices[s],o=e.setIndices[s-1];i[a]=e.maxBlockCounts[o]+i[o],n[a]=e.maxSamplerTextureCounts[o]+n[o]}for(var h=0;h<e.setIndices.length;++h){var l=e.setIndices[h];n[l]-=e.maxBlockCounts[l]}this._bindingMappings={blockOffsets:i,samplerTextureOffsets:n,flexibleSet:e.setIndices[e.setIndices.length-1]};var c=this._context=function(t){var e=null;try{if(globalThis.__globalXR.webxrCompatible){var i={alpha:Mi.ENABLE_TRANSPARENT_CANVAS,antialias:aa||Mi.ENABLE_WEBGL_ANTIALIAS,depth:!0,stencil:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1,xrCompatible:!0};return t.getContext("webgl2",i)}var n={alpha:Mi.ENABLE_TRANSPARENT_CANVAS,antialias:aa||Mi.ENABLE_WEBGL_ANTIALIAS,depth:!0,stencil:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1};e=t.getContext("webgl2",n)}catch(t){return null}return e}(pe.canvas);if(!c)return console.error("This device does not support WebGL."),!1;this._queue=this.createQueue(new qt(Y.GRAPHICS)),this._cmdBuff=this.createCommandBuffer(new Kt(this._queue)),this._caps.maxVertexAttributes=c.getParameter(c.MAX_VERTEX_ATTRIBS),this._caps.maxVertexUniformVectors=c.getParameter(c.MAX_VERTEX_UNIFORM_VECTORS),Ds.os===Os.IOS&&rn.browserType===Fs.WECHAT&&(this._caps.maxVertexUniformVectors=256),this._caps.maxFragmentUniformVectors=c.getParameter(c.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxTextureUnits=c.getParameter(c.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureUnits=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._caps.maxUniformBufferBindings=c.getParameter(c.MAX_UNIFORM_BUFFER_BINDINGS),this._caps.maxUniformBlockSize=c.getParameter(c.MAX_UNIFORM_BLOCK_SIZE),this._caps.maxTextureSize=c.getParameter(c.MAX_TEXTURE_SIZE),this._caps.maxCubeMapTextureSize=c.getParameter(c.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxArrayTextureLayers=c.getParameter(c.MAX_ARRAY_TEXTURE_LAYERS),this._caps.max3DTextureSize=c.getParameter(c.MAX_3D_TEXTURE_SIZE),this._caps.uboOffsetAlignment=c.getParameter(c.UNIFORM_BUFFER_OFFSET_ALIGNMENT);var f=c.getSupportedExtensions(),p="";if(f)for(var g,m=Fi(f);!(g=m()).done;)p+=g.value+" ";var v=bP(c);v.WEBGL_debug_renderer_info?(this._renderer=c.getParameter(v.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL),this._vendor=c.getParameter(v.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL)):(this._renderer=c.getParameter(c.RENDERER),this._vendor=c.getParameter(c.VENDOR));var y=c.getParameter(c.VERSION);this._features.fill(!1),this.initFormatFeatures(v),this._features[d.ELEMENT_INDEX_UINT]=!0,this._features[d.INSTANCED_ARRAYS]=!0,this._features[d.MULTIPLE_RENDER_TARGETS]=!0,this._features[d.BLEND_MINMAX]=!0;var T="";return this.getFormatFeatures(_.ETC_RGB8)&&(T+="etc1 "),this.getFormatFeatures(_.ETC2_RGB8)&&(T+="etc2 "),this.getFormatFeatures(_.BC1)&&(T+="dxt "),this.getFormatFeatures(_.PVRTC_RGB2)&&(T+="pvrtc "),this.getFormatFeatures(_.ASTC_RGBA_4X4)&&(T+="astc "),Gn("WebGL2 device initialized."),Gn("RENDERER: "+this._renderer),Gn("VENDOR: "+this._vendor),Gn("VERSION: "+y),Gn("COMPRESSED_FORMAT: "+T),Gn("EXTENSIONS: "+p),!0},i.destroy=function(){this._queue&&(this._queue.destroy(),this._queue=null),this._cmdBuff&&(this._cmdBuff.destroy(),this._cmdBuff=null);for(var t=this._samplers.values(),e=t.next();!e.done;)e.value.destroy(),e=t.next();this._swapchain=null},i.flushCommands=function(){},i.acquire=function(){},i.present=function(){var t=this._queue;this._numDrawCalls=t.numDrawCalls,this._numInstances=t.numInstances,this._numTris=t.numTris,t.clear()},i.initFormatFeatures=function(t){this._formatFeatures.fill(A.NONE),this._textureExclusive.fill(!0);var e=A.RENDER_TARGET|A.SAMPLED_TEXTURE|A.STORAGE_TEXTURE|A.LINEAR_FILTER|A.VERTEX_ATTRIBUTE;this._formatFeatures[_.R8]=e,this._formatFeatures[_.RG8]=e,this._formatFeatures[_.RGB8]=e,this._formatFeatures[_.RGBA8]=e,e=A.RENDER_TARGET|A.SAMPLED_TEXTURE|A.STORAGE_TEXTURE|A.LINEAR_FILTER,this._formatFeatures[_.R8SN]=e,this._formatFeatures[_.RG8SN]=e,this._formatFeatures[_.RGB8SN]=e,this._formatFeatures[_.RGBA8SN]=e,this._formatFeatures[_.R5G6B5]=e,this._formatFeatures[_.RGBA4]=e,this._formatFeatures[_.RGB5A1]=e,this._formatFeatures[_.RGB10A2]=e,this._formatFeatures[_.SRGB8]=e,this._formatFeatures[_.SRGB8_A8]=e,this._formatFeatures[_.R11G11B10F]=e,this._formatFeatures[_.RGB9E5]=e,this._formatFeatures[_.DEPTH]=e,this._formatFeatures[_.DEPTH_STENCIL]=e,this._formatFeatures[_.RGB10A2UI]=A.RENDER_TARGET|A.STORAGE_TEXTURE|A.SAMPLED_TEXTURE|A.LINEAR_FILTER,e=A.RENDER_TARGET|A.SAMPLED_TEXTURE|A.STORAGE_TEXTURE|A.VERTEX_ATTRIBUTE,this._formatFeatures[_.R16F]=e,this._formatFeatures[_.RG16F]=e,this._formatFeatures[_.RGB16F]=e,this._formatFeatures[_.RGBA16F]=e,e=A.STORAGE_TEXTURE|A.SAMPLED_TEXTURE|A.VERTEX_ATTRIBUTE,this._formatFeatures[_.R32F]=e,this._formatFeatures[_.RG32F]=e,this._formatFeatures[_.RGB32F]=e,this._formatFeatures[_.RGBA32F]=e,this._formatFeatures[_.RGB10A2UI]=A.RENDER_TARGET|A.STORAGE_TEXTURE|A.SAMPLED_TEXTURE|A.LINEAR_FILTER,e=A.RENDER_TARGET|A.STORAGE_TEXTURE|A.SAMPLED_TEXTURE|A.LINEAR_FILTER|A.VERTEX_ATTRIBUTE,this._formatFeatures[_.R8I]=e,this._formatFeatures[_.R8UI]=e,this._formatFeatures[_.R16I]=e,this._formatFeatures[_.R16UI]=e,this._formatFeatures[_.R32I]=e,this._formatFeatures[_.R32UI]=e,this._formatFeatures[_.RG8I]=e,this._formatFeatures[_.RG8UI]=e,this._formatFeatures[_.RG16I]=e,this._formatFeatures[_.RG16UI]=e,this._formatFeatures[_.RG32I]=e,this._formatFeatures[_.RG32UI]=e,this._formatFeatures[_.RGB8I]=e,this._formatFeatures[_.RGB8UI]=e,this._formatFeatures[_.RGB16I]=e,this._formatFeatures[_.RGB16UI]=e,this._formatFeatures[_.RGB32I]=e,this._formatFeatures[_.RGB32UI]=e,this._formatFeatures[_.RGBA8I]=e,this._formatFeatures[_.RGBA8UI]=e,this._formatFeatures[_.RGBA16I]=e,this._formatFeatures[_.RGBA16UI]=e,this._formatFeatures[_.RGBA32I]=e,this._formatFeatures[_.RGBA32UI]=e,this._textureExclusive[_.R8]=!1,this._textureExclusive[_.RG8]=!1,this._textureExclusive[_.RGB8]=!1,this._textureExclusive[_.R5G6B5]=!1,this._textureExclusive[_.RGBA4]=!1,this._textureExclusive[_.RGB5A1]=!1,this._textureExclusive[_.RGBA8]=!1,this._textureExclusive[_.RGB10A2]=!1,this._textureExclusive[_.RGB10A2UI]=!1,this._textureExclusive[_.SRGB8_A8]=!1,this._textureExclusive[_.R8I]=!1,this._textureExclusive[_.R8UI]=!1,this._textureExclusive[_.R16I]=!1,this._textureExclusive[_.R16UI]=!1,this._textureExclusive[_.R32I]=!1,this._textureExclusive[_.R32UI]=!1,this._textureExclusive[_.RG8I]=!1,this._textureExclusive[_.RG8UI]=!1,this._textureExclusive[_.RG16I]=!1,this._textureExclusive[_.RG16UI]=!1,this._textureExclusive[_.RG32I]=!1,this._textureExclusive[_.RG32UI]=!1,this._textureExclusive[_.RGBA8I]=!1,this._textureExclusive[_.RGBA8UI]=!1,this._textureExclusive[_.RGBA16I]=!1,this._textureExclusive[_.RGBA16UI]=!1,this._textureExclusive[_.RGBA32I]=!1,this._textureExclusive[_.RGBA32UI]=!1,this._textureExclusive[_.DEPTH]=!1,this._textureExclusive[_.DEPTH_STENCIL]=!1,t.EXT_color_buffer_float&&(this._formatFeatures[_.R32F]|=A.RENDER_TARGET,this._formatFeatures[_.RG32F]|=A.RENDER_TARGET,this._formatFeatures[_.RGBA32F]|=A.RENDER_TARGET,this._textureExclusive[_.R32F]=!1,this._textureExclusive[_.RG32F]=!1,this._textureExclusive[_.RGBA32F]=!1),t.EXT_color_buffer_half_float&&(this._textureExclusive[_.R16F]=!1,this._textureExclusive[_.RG16F]=!1,this._textureExclusive[_.RGBA16F]=!1),t.OES_texture_float_linear&&(this._formatFeatures[_.RGB32F]|=A.LINEAR_FILTER,this._formatFeatures[_.RGBA32F]|=A.LINEAR_FILTER,this._formatFeatures[_.R32F]|=A.LINEAR_FILTER,this._formatFeatures[_.RG32F]|=A.LINEAR_FILTER),t.OES_texture_half_float_linear&&(this._formatFeatures[_.RGB16F]|=A.LINEAR_FILTER,this._formatFeatures[_.RGBA16F]|=A.LINEAR_FILTER,this._formatFeatures[_.R16F]|=A.LINEAR_FILTER,this._formatFeatures[_.RG16F]|=A.LINEAR_FILTER);var i=A.SAMPLED_TEXTURE|A.LINEAR_FILTER;t.WEBGL_compressed_texture_etc1&&(this._formatFeatures[_.ETC_RGB8]=i),t.WEBGL_compressed_texture_etc&&(this._formatFeatures[_.ETC2_RGB8]=i,this._formatFeatures[_.ETC2_RGBA8]=i,this._formatFeatures[_.ETC2_SRGB8]=i,this._formatFeatures[_.ETC2_SRGB8_A8]=i,this._formatFeatures[_.ETC2_RGB8_A1]=i,this._formatFeatures[_.ETC2_SRGB8_A1]=i),t.WEBGL_compressed_texture_s3tc&&(this._formatFeatures[_.BC1]=i,this._formatFeatures[_.BC1_ALPHA]=i,this._formatFeatures[_.BC1_SRGB]=i,this._formatFeatures[_.BC1_SRGB_ALPHA]=i,this._formatFeatures[_.BC2]=i,this._formatFeatures[_.BC2_SRGB]=i,this._formatFeatures[_.BC3]=i,this._formatFeatures[_.BC3_SRGB]=i),t.WEBGL_compressed_texture_pvrtc&&(this._formatFeatures[_.PVRTC_RGB2]=i,this._formatFeatures[_.PVRTC_RGBA2]=i,this._formatFeatures[_.PVRTC_RGB4]=i,this._formatFeatures[_.PVRTC_RGBA4]=i),t.WEBGL_compressed_texture_astc&&(this._formatFeatures[_.ASTC_RGBA_4X4]=i,this._formatFeatures[_.ASTC_RGBA_5X4]=i,this._formatFeatures[_.ASTC_RGBA_5X5]=i,this._formatFeatures[_.ASTC_RGBA_6X5]=i,this._formatFeatures[_.ASTC_RGBA_6X6]=i,this._formatFeatures[_.ASTC_RGBA_8X5]=i,this._formatFeatures[_.ASTC_RGBA_8X6]=i,this._formatFeatures[_.ASTC_RGBA_8X8]=i,this._formatFeatures[_.ASTC_RGBA_10X5]=i,this._formatFeatures[_.ASTC_RGBA_10X6]=i,this._formatFeatures[_.ASTC_RGBA_10X8]=i,this._formatFeatures[_.ASTC_RGBA_10X10]=i,this._formatFeatures[_.ASTC_RGBA_12X10]=i,this._formatFeatures[_.ASTC_RGBA_12X12]=i,this._formatFeatures[_.ASTC_SRGBA_4X4]=i,this._formatFeatures[_.ASTC_SRGBA_5X4]=i,this._formatFeatures[_.ASTC_SRGBA_5X5]=i,this._formatFeatures[_.ASTC_SRGBA_6X5]=i,this._formatFeatures[_.ASTC_SRGBA_6X6]=i,this._formatFeatures[_.ASTC_SRGBA_8X5]=i,this._formatFeatures[_.ASTC_SRGBA_8X6]=i,this._formatFeatures[_.ASTC_SRGBA_8X8]=i,this._formatFeatures[_.ASTC_SRGBA_10X5]=i,this._formatFeatures[_.ASTC_SRGBA_10X6]=i,this._formatFeatures[_.ASTC_SRGBA_10X8]=i,this._formatFeatures[_.ASTC_SRGBA_10X10]=i,this._formatFeatures[_.ASTC_SRGBA_12X10]=i,this._formatFeatures[_.ASTC_SRGBA_12X12]=i)},i.createCommandBuffer=function(t){var e=new(t.type===K.PRIMARY?mP:uP);return e.initialize(t),e},i.createSwapchain=function(t){var e=new xP;return this._swapchain=e,e.initialize(t),e},i.createBuffer=function(t){var e=new oP;return e.initialize(t),e},i.createTexture=function(t){var e=new AP;return e.initialize(t),e},i.createDescriptorSet=function(t){var e=new CB;return e.initialize(t),e},i.createShader=function(t){var e=new SP;return e.initialize(t),e},i.createInputAssembler=function(t){var e=new dP;return e.initialize(t),e},i.createRenderPass=function(t){var e=new yP;return e.initialize(t),e},i.createFramebuffer=function(t){var e=new cP;return e.initialize(t),e},i.createDescriptorSetLayout=function(t){var e=new _P;return e.initialize(t),e},i.createPipelineLayout=function(t){var e=new fP;return e.initialize(t),e},i.createPipelineState=function(t){var e=new gP;return e.initialize(t),e},i.createQueue=function(t){var e=new vP;return e.initialize(t),e},i.getSampler=function(t){var e=Ie.computeHash(t);return this._samplers.has(e)||this._samplers.set(e,new TP(t,e)),this._samplers.get(e)},i.getSwapchains=function(){return[this._swapchain]},i.getGeneralBarrier=function(t){var e=De.computeHash(t);return this._generalBarrierss.has(e)||this._generalBarrierss.set(e,new De(t,e)),this._generalBarrierss.get(e)},i.getTextureBarrier=function(t){var e=Oe.computeHash(t);return this._textureBarriers.has(e)||this._textureBarriers.set(e,new Oe(t,e)),this._textureBarriers.get(e)},i.getBufferBarrier=function(t){var e=oa.computeHash(t);return this._bufferBarriers.has(e)||this._bufferBarriers.set(e,new oa(t,e)),this._bufferBarriers.get(e)},i.copyBuffersToTexture=function(t,e,i){nP(this,t,e.gpuTexture,i)},i.copyTextureToBuffers=function(t,e,i){!function(t,e,i,n){var r=t.gl,s=t.stateCache,a=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,a);var o=0,h=0,l=1,u=1;switch(e.glTarget){case r.TEXTURE_2D:for(var c=0;c<n.length;c++){var d=n[c];r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,e.glTarget,e.glTexture,d.texSubres.mipLevel),o=d.texOffset.x,h=d.texOffset.y,l=d.texExtent.width,u=d.texExtent.height,r.readPixels(o,h,l,u,e.glFormat,e.glType,i[c])}break;default:console.error("Unsupported GL texture type, copy texture to buffers failed.")}r.bindFramebuffer(r.FRAMEBUFFER,null),s.glFramebuffer=null,r.deleteFramebuffer(a)}(this,t.gpuTexture,e,i)},i.copyTexImagesToTexture=function(t,e,i){!function(t,e,i,n){var r=t.gl,s=t.stateCache.glTexUnits[t.stateCache.texUnit];s.glTexture!==i.glTexture&&(r.bindTexture(i.glTarget,i.glTexture),s.glTexture=i.glTexture);var a=0,o=0;switch(i.glTarget){case r.TEXTURE_2D:for(var h=0;h<n.length;h++){var l=n[h];r.texSubImage2D(r.TEXTURE_2D,l.texSubres.mipLevel,l.texOffset.x,l.texOffset.y,i.glFormat,i.glType,e[a++])}break;case r.TEXTURE_CUBE_MAP:for(var u=0;u<n.length;u++){var c=n[u],d=c.texSubres.baseArrayLayer+c.texSubres.layerCount;for(o=c.texSubres.baseArrayLayer;o<d;++o)r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,c.texSubres.mipLevel,c.texOffset.x,c.texOffset.y,i.glFormat,i.glType,e[a++])}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&E.GEN_MIPMAP&&r.generateMipmap(i.glTarget)}(this,t,e.gpuTexture,i)},Pi(e,[{key:"gl",get:function(){return this._context}},{key:"extensions",get:function(){return this._swapchain.extensions}},{key:"stateCache",get:function(){return this._swapchain.stateCache}},{key:"nullTex2D",get:function(){return this._swapchain.nullTex2D}},{key:"nullTexCube",get:function(){return this._swapchain.nullTexCube}},{key:"textureExclusive",get:function(){return this._textureExclusive}},{key:"bindingMappings",get:function(){return this._bindingMappings}},{key:"blitManager",get:function(){return this._swapchain.blitManager}}]),e}(pe));We.WebGL2Device=wP;var MP,IP,BP,PP,DP,OP,FP,LP,NP,kP,UP,GP,VP,HP,zP,XP,WP,YP,jP,KP,qP,ZP,QP,JP,$P,tD,eD,iD,nD,rD,sD,aD,oD,hD,lD=t("PlaceMethod",fr({UNIFORM:0,ADAPTIVE:1})),uD=t("AutoPlacement",function(){function t(){}return t.generate=function(t){switch(t.method){case lD.UNIFORM:return this.doGenerateUniform(t);case lD.ADAPTIVE:return this.doGenerateAdaptive(t);default:return[]}},t.doGenerateUniform=function(t){if(t.nProbesX<2||t.nProbesY<2||t.nProbesZ<2)return[];for(var e=[],i=new ji(0,0,0),n=new ji((t.maxPos.x-t.minPos.x)/(t.nProbesX-1),(t.maxPos.y-t.minPos.y)/(t.nProbesY-1),(t.maxPos.z-t.minPos.z)/(t.nProbesZ-1)),r=0;r<t.nProbesX;r++){i.x=r*n.x+t.minPos.x;for(var s=0;s<t.nProbesY;s++){i.y=s*n.y+t.minPos.y;for(var a=0;a<t.nProbesZ;a++)i.z=a*n.z+t.minPos.z,e.push(new ji(i))}}return e},t.doGenerateAdaptive=function(t){return this.doGenerateUniform(t)},t}()),cD=Ki,dD=en,_D=new ha,fD=new ji(0,0,0),pD=new ji(0,0,0),gD=new ji(0,0,0),mD=new ji(0,0,0),vD=new ji(0,0,0),yD=new ji(0,0,0),TD=new ji(0,0,0),SD=t("Vertex",cD("cc.Vertex")((IP=function(t){this.position=BP&&BP(),this.normal=PP&&PP(),this.coefficients=DP&&DP(),this.position.set(t)},BP=tn(IP.prototype,"position",[dD],(function(){return new ji(0,0,0)})),PP=tn(IP.prototype,"normal",[dD],(function(){return new ji(0,0,0)})),DP=tn(IP.prototype,"coefficients",[dD],(function(){return[]})),MP=IP))||MP),ED=(OP=function(){function t(t,e,i,n){this.tetrahedron=FP&&FP(),this.index=LP&&LP(),this.vertex0=NP&&NP(),this.vertex1=kP&&kP(),this.tetrahedron=t,this.index=e,i<n?(this.vertex0=i,this.vertex1=n):(this.vertex0=n,this.vertex1=i)}var e=t.prototype;return e.set=function(t,e,i,n){this.tetrahedron=t,this.index=e,i<n?(this.vertex0=i,this.vertex1=n):(this.vertex0=n,this.vertex1=i)},e.isSame=function(t){return this.vertex0===t.vertex0&&this.vertex1===t.vertex1},t}(),FP=tn(OP.prototype,"tetrahedron",[dD],(function(){return-1})),LP=tn(OP.prototype,"index",[dD],(function(){return-1})),NP=tn(OP.prototype,"vertex0",[dD],(function(){return-1})),kP=tn(OP.prototype,"vertex1",[dD],(function(){return-1})),OP),AD=(UP=function(){function t(t,e,i,n,r,s){this.invalid=GP&&GP(),this.isOuterFace=VP&&VP(),this.tetrahedron=HP&&HP(),this.index=zP&&zP(),this.vertex0=XP&&XP(),this.vertex1=WP&&WP(),this.vertex2=YP&&YP(),this.vertex3=jP&&jP(),this.tetrahedron=t,this.index=e,this.vertex3=s,i<n&&i<r?(this.vertex0=i,n<r?(this.vertex1=n,this.vertex2=r):(this.vertex1=r,this.vertex2=n)):n<i&&n<r?(this.vertex0=n,i<r?(this.vertex1=i,this.vertex2=r):(this.vertex1=r,this.vertex2=i)):(this.vertex0=r,i<n?(this.vertex1=i,this.vertex2=n):(this.vertex1=n,this.vertex2=i))}var e=t.prototype;return e.set=function(t,e,i,n,r,s){this.invalid=!1,this.isOuterFace=!0,this.tetrahedron=t,this.index=e,this.vertex3=s,i<n&&i<r?(this.vertex0=i,n<r?(this.vertex1=n,this.vertex2=r):(this.vertex1=r,this.vertex2=n)):n<i&&n<r?(this.vertex0=n,i<r?(this.vertex1=i,this.vertex2=r):(this.vertex1=r,this.vertex2=i)):(this.vertex0=r,i<n?(this.vertex1=i,this.vertex2=n):(this.vertex1=n,this.vertex2=i))},e.isSame=function(t){return this.vertex0===t.vertex0&&this.vertex1===t.vertex1&&this.vertex2===t.vertex2},t}(),GP=tn(UP.prototype,"invalid",[dD],(function(){return!1})),VP=tn(UP.prototype,"isOuterFace",[dD],(function(){return!0})),HP=tn(UP.prototype,"tetrahedron",[dD],(function(){return-1})),zP=tn(UP.prototype,"index",[dD],(function(){return-1})),XP=tn(UP.prototype,"vertex0",[dD],(function(){return-1})),WP=tn(UP.prototype,"vertex1",[dD],(function(){return-1})),YP=tn(UP.prototype,"vertex2",[dD],(function(){return-1})),jP=tn(UP.prototype,"vertex3",[dD],(function(){return-1})),UP),CD=t("CircumSphere",cD("cc.CircumSphere")((qP=function(){function t(){this.center=ZP&&ZP(),this.radiusSquared=QP&&QP()}return t.prototype.init=function(t,e,i,n){_D.set(e.x-t.x,e.y-t.y,e.z-t.z,i.x-t.x,i.y-t.y,i.z-t.z,n.x-t.x,n.y-t.y,n.z-t.z),_D.invert(),_D.transpose(),fD.set(.5*((e.x+t.x)*(e.x-t.x)+(e.y+t.y)*(e.y-t.y)+(e.z+t.z)*(e.z-t.z)),.5*((i.x+t.x)*(i.x-t.x)+(i.y+t.y)*(i.y-t.y)+(i.z+t.z)*(i.z-t.z)),.5*((n.x+t.x)*(n.x-t.x)+(n.y+t.y)*(n.y-t.y)+(n.z+t.z)*(n.z-t.z))),ji.transformMat3(this.center,fD,_D),this.radiusSquared=ji.squaredDistance(t,this.center)},t}(),ZP=tn(qP.prototype,"center",[dD],(function(){return new ji(0,0,0)})),QP=tn(qP.prototype,"radiusSquared",[dD],(function(){return 0})),KP=qP))||KP),RD=t("Tetrahedron",cD("cc.Tetrahedron")(($P=function(){function t(t,e,i,n,r){if(void 0===r&&(r=-1),this.invalid=tD&&tD(),this.vertex0=eD&&eD(),this.vertex1=iD&&iD(),this.vertex2=nD&&nD(),this.vertex3=rD&&rD(),this.neighbours=sD&&sD(),this.matrix=aD&&aD(),this.offset=oD&&oD(),this.sphere=hD&&hD(),this.vertex0=e,this.vertex1=i,this.vertex2=n,this.vertex3=r,r>=0){var s=t._probes,a=s[this.vertex0].position,o=s[this.vertex1].position,h=s[this.vertex2].position,l=s[this.vertex3].position;this.sphere.init(a,o,h,l)}}var e=t.prototype;return e.isInCircumSphere=function(t){return ji.squaredDistance(t,this.sphere.center)<this.sphere.radiusSquared-Mn},e.contain=function(t){return this.vertex0===t||this.vertex1===t||this.vertex2===t||this.vertex3===t},e.isInnerTetrahedron=function(){return this.vertex3>=0},e.isOuterCell=function(){return this.vertex3<0},t}(),tD=tn($P.prototype,"invalid",[dD],(function(){return!1})),eD=tn($P.prototype,"vertex0",[dD],(function(){return-1})),iD=tn($P.prototype,"vertex1",[dD],(function(){return-1})),nD=tn($P.prototype,"vertex2",[dD],(function(){return-1})),rD=tn($P.prototype,"vertex3",[dD],(function(){return-1})),sD=tn($P.prototype,"neighbours",[dD],(function(){return[-1,-1,-1,-1]})),aD=tn($P.prototype,"matrix",[dD],(function(){return new ha})),oD=tn($P.prototype,"offset",[dD],(function(){return new ji(0,0,0)})),hD=tn($P.prototype,"sphere",[dD],(function(){return new CD})),JP=$P))||JP),bD=t("Delaunay",function(){function t(t){this._probes=[],this._tetrahedrons=[],this._triangles=[],this._edges=[],this._probes=t}var e=t.prototype;return e.build=function(){return this.reset(),this.tetrahedralize(),this.computeAdjacency(),this.computeMatrices(),this._tetrahedrons},e.reset=function(){this._tetrahedrons.length=0,this._triangles.length=0,this._edges.length=0},e.tetrahedralize=function(){for(var t=this._probes.length,e=this.initTetrahedron(),i=0;i<t;i++)this.addProbe(i);this._tetrahedrons=this._tetrahedrons.filter((function(e){var i=t;return!(e.contain(i)||e.contain(i+1)||e.contain(i+2)||e.contain(i+3))})),this._probes.length=t,this.reorder(e)},e.initTetrahedron=function(){for(var t=new ji(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),e=new ji(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),i=0;i<this._probes.length;i++){var n=this._probes[i].position;t.x=Math.min(t.x,n.x),e.x=Math.max(e.x,n.x),t.y=Math.min(t.y,n.y),e.y=Math.max(e.y,n.y),t.z=Math.min(t.z,n.z),e.z=Math.max(e.z,n.z)}var r=new ji(0,0,0);ji.add(r,t,e),ji.multiplyScalar(r,r,.5);var s=new ji(0,0,0);ji.subtract(s,e,t);var a=10*Math.max(s.x,s.y,s.z),o=new ji(r.x,r.y+a,r.z),h=new ji(r.x-a,r.y-a,r.z-a),l=new ji(r.x-a,r.y-a,r.z+a),u=new ji(r.x+a,r.y-a,r.z),c=this._probes.length;return this._probes.push(new SD(o)),this._probes.push(new SD(h)),this._probes.push(new SD(l)),this._probes.push(new SD(u)),this._tetrahedrons.push(new RD(this,c,c+1,c+2,c+3)),r},e.addTriangle=function(t,e,i,n,r,s,a){t<this._triangles.length?this._triangles[t].set(e,i,n,r,s,a):this._triangles.push(new AD(e,i,n,r,s,a))},e.addEdge=function(t,e,i,n,r){t<this._edges.length?this._edges[t].set(e,i,n,r):this._edges.push(new ED(e,i,n,r))},e.addProbe=function(t){for(var e=this._probes[t].position,i=0,n=0;n<this._tetrahedrons.length;n++){var r=this._tetrahedrons[n];r.isInCircumSphere(e)&&(r.invalid=!0,this.addTriangle(i,n,0,r.vertex1,r.vertex3,r.vertex2,r.vertex0),this.addTriangle(i+1,n,1,r.vertex0,r.vertex2,r.vertex3,r.vertex1),this.addTriangle(i+2,n,2,r.vertex0,r.vertex3,r.vertex1,r.vertex2),this.addTriangle(i+3,n,3,r.vertex0,r.vertex1,r.vertex2,r.vertex3),i+=4)}for(var s=0;s<i;s++)if(!this._triangles[s].invalid)for(var a=s+1;a<i;a++)if(this._triangles[s].isSame(this._triangles[a])){this._triangles[s].invalid=!0,this._triangles[a].invalid=!0;break}this._tetrahedrons=this._tetrahedrons.filter((function(t){return!t.invalid}));for(var o=0;o<i;o++){var h=this._triangles[o];h.invalid||this._tetrahedrons.push(new RD(this,h.vertex0,h.vertex1,h.vertex2,t))}},e.reorder=function(t){this._tetrahedrons.sort((function(e,i){return ji.squaredDistance(e.sphere.center,t)-ji.squaredDistance(i.sphere.center,t)}))},e.computeAdjacency=function(){for(var t=new ji(0,0,0),e=new ji(0,0,0),i=new ji(0,0,0),n=new ji(0,0,0),r=this._tetrahedrons.length,s=0,a=0;a<this._tetrahedrons.length;a++){var o=this._tetrahedrons[a];this.addTriangle(s,a,0,o.vertex1,o.vertex3,o.vertex2,o.vertex0),this.addTriangle(s+1,a,1,o.vertex0,o.vertex2,o.vertex3,o.vertex1),this.addTriangle(s+2,a,2,o.vertex0,o.vertex3,o.vertex1,o.vertex2),this.addTriangle(s+3,a,3,o.vertex0,o.vertex1,o.vertex2,o.vertex3),s+=4}for(var h=0;h<s;h++)if(this._triangles[h].isOuterFace){for(var l=h+1;l<s;l++)if(this._triangles[h].isSame(this._triangles[l])){this._tetrahedrons[this._triangles[h].tetrahedron].neighbours[this._triangles[h].index]=this._triangles[l].tetrahedron,this._tetrahedrons[this._triangles[l].tetrahedron].neighbours[this._triangles[l].index]=this._triangles[h].tetrahedron,this._triangles[h].isOuterFace=!1,this._triangles[l].isOuterFace=!1;break}if(this._triangles[h].isOuterFace){var u=this._probes[this._triangles[h].vertex0],c=this._probes[this._triangles[h].vertex1],d=this._probes[this._triangles[h].vertex2],_=this._probes[this._triangles[h].vertex3];ji.subtract(e,c.position,u.position),ji.subtract(i,d.position,u.position),ji.cross(t,e,i),ji.subtract(n,_.position,u.position);var f=ji.dot(t,n);f>0&&ji.negate(t,t),ji.add(u.normal,u.normal,t),ji.add(c.normal,c.normal,t),ji.add(d.normal,d.normal,t);var p=this._triangles[h].vertex0,g=f>0?this._triangles[h].vertex2:this._triangles[h].vertex1,m=f>0?this._triangles[h].vertex1:this._triangles[h].vertex2,v=new RD(this,p,g,m);v.neighbours[3]=this._triangles[h].tetrahedron,this._tetrahedrons[this._triangles[h].tetrahedron].neighbours[this._triangles[h].index]=this._tetrahedrons.length,this._tetrahedrons.push(v)}}for(var y=0,T=r;T<this._tetrahedrons.length;T++){var S=this._tetrahedrons[T];this.addEdge(y,T,0,S.vertex1,S.vertex2),this.addEdge(y+1,T,1,S.vertex2,S.vertex0),this.addEdge(y+2,T,2,S.vertex0,S.vertex1),y+=3}for(var E=0;E<y;E++)for(var A=E+1;A<y;A++)this._edges[E].isSame(this._edges[A])&&(this._tetrahedrons[this._edges[E].tetrahedron].neighbours[this._edges[E].index]=this._edges[A].tetrahedron,this._tetrahedrons[this._edges[A].tetrahedron].neighbours[this._edges[A].index]=this._edges[E].tetrahedron);for(var C=0;C<this._probes.length;C++)this._probes[C].normal.normalize()},e.computeMatrices=function(){for(var t=0;t<this._tetrahedrons.length;t++){var e=this._tetrahedrons[t];e.vertex3>=0?this.computeTetrahedronMatrix(e):this.computeOuterCellMatrix(e)}},e.computeTetrahedronMatrix=function(t){var e=this._probes[t.vertex0].position,i=this._probes[t.vertex1].position,n=this._probes[t.vertex2].position,r=this._probes[t.vertex3].position;t.matrix.set(e.x-r.x,i.x-r.x,n.x-r.x,e.y-r.y,i.y-r.y,n.y-r.y,e.z-r.z,i.z-r.z,n.z-r.z),t.matrix.invert(),t.matrix.transpose()},e.computeOuterCellMatrix=function(t){var e=[],i=[];e[0]=this._probes[t.vertex0].normal,e[1]=this._probes[t.vertex1].normal,e[2]=this._probes[t.vertex2].normal,i[0]=this._probes[t.vertex0].position,i[1]=this._probes[t.vertex1].position,i[2]=this._probes[t.vertex2].position,ji.subtract(pD,i[0],i[2]),ji.subtract(gD,e[0],e[2]),ji.subtract(mD,i[1],i[2]),ji.subtract(vD,e[1],e[2]),yD.set(i[2]),ji.negate(TD,e[2]);var n=[];n[0]=gD.y*vD.z-gD.z*vD.y,n[3]=-gD.x*vD.z+gD.z*vD.x,n[6]=gD.x*vD.y-gD.y*vD.x,n[9]=pD.x*vD.y*TD.z-pD.y*vD.x*TD.z+gD.x*mD.y*TD.z-gD.y*mD.x*TD.z+pD.z*vD.x*TD.y-pD.z*vD.y*TD.x+gD.z*mD.x*TD.y-gD.z*mD.y*TD.x-pD.x*vD.z*TD.y+pD.y*vD.z*TD.x-gD.x*mD.z*TD.y+gD.y*mD.z*TD.x,n[9]-=yD.x*n[0]+yD.y*n[3]+yD.z*n[6],n[1]=gD.y*mD.z+pD.y*vD.z-gD.z*mD.y-pD.z*vD.y,n[4]=-pD.x*vD.z-gD.x*mD.z+pD.z*vD.x+gD.z*mD.x,n[7]=pD.x*vD.y-pD.y*vD.x+gD.x*mD.y-gD.y*mD.x,n[10]=pD.x*mD.y*TD.z-pD.y*mD.x*TD.z-pD.x*mD.z*TD.y+pD.y*mD.z*TD.x+pD.z*mD.x*TD.y-pD.z*mD.y*TD.x,n[10]-=yD.x*n[1]+yD.y*n[4]+yD.z*n[7],n[2]=-pD.z*mD.y+pD.y*mD.z,n[5]=-pD.x*mD.z+pD.z*mD.x,n[8]=pD.x*mD.y-pD.y*mD.x,n[11]=0,n[11]-=yD.x*n[2]+yD.y*n[5]+yD.z*n[8];var r=gD.x*vD.y*TD.z-gD.y*vD.x*TD.z+gD.z*vD.x*TD.y-gD.z*vD.y*TD.x+gD.y*vD.z*TD.x-gD.x*vD.z*TD.y;if(Math.abs(r)>Mn)for(var s=0;s<12;s++)n[s]/=r;else t.vertex3=-2;t.matrix.set(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8]),t.offset.set(n[9],n[10],n[11])},t}()),xD=t("LightProbeSampler",function(){function t(){}return t.uniformSampleSphere=function(t,e){var i=1-2*t,n=Math.sqrt(Math.max(0,1-i*i)),r=2*Math.PI*e,s=n*Math.cos(r),a=n*Math.sin(r);return new ji(s,a,i)},t.uniformSampleSphereAll=function(t){for(var e=Math.floor(Math.sqrt(t)),i=e,n=[],r=1/e,s=1/i,a=0;a<e;a++)for(var o=(a+.5)*r,h=0;h<i;h++){var l=(h+.5)*s,u=this.uniformSampleSphere(o,l);n.push(u)}return n},t.uniformSpherePdf=function(){return 1/(4*Math.PI)},t}()),wD=t("SH",function(){function t(){}return t.updateUBOData=function(t,e,i){t[e++]=i[3].x*this.basisOverPI[3],t[e++]=i[1].x*this.basisOverPI[1],t[e++]=i[2].x*this.basisOverPI[2],t[e++]=i[0].x*this.basisOverPI[0]-i[6].x*this.basisOverPI[6]/3,t[e++]=i[3].y*this.basisOverPI[3],t[e++]=i[1].y*this.basisOverPI[1],t[e++]=i[2].y*this.basisOverPI[2],t[e++]=i[0].y*this.basisOverPI[0]-i[6].y*this.basisOverPI[6]/3,t[e++]=i[3].z*this.basisOverPI[3],t[e++]=i[1].z*this.basisOverPI[1],t[e++]=i[2].z*this.basisOverPI[2],t[e++]=i[0].z*this.basisOverPI[0]-i[6].z*this.basisOverPI[6]/3,t[e++]=i[4].x*this.basisOverPI[4],t[e++]=i[5].x*this.basisOverPI[5],t[e++]=i[6].x*this.basisOverPI[6],t[e++]=i[7].x*this.basisOverPI[7],t[e++]=i[4].y*this.basisOverPI[4],t[e++]=i[5].y*this.basisOverPI[5],t[e++]=i[6].y*this.basisOverPI[6],t[e++]=i[7].y*this.basisOverPI[7],t[e++]=i[4].z*this.basisOverPI[4],t[e++]=i[5].z*this.basisOverPI[5],t[e++]=i[6].z*this.basisOverPI[6],t[e++]=i[7].z*this.basisOverPI[7],t[e++]=i[8].x*this.basisOverPI[8],t[e++]=i[8].y*this.basisOverPI[8],t[e++]=i[8].z*this.basisOverPI[8],t[e++]=0},t.shaderEvaluate=function(t,e){var i=new _n(e[3].x*this.basisOverPI[3],e[1].x*this.basisOverPI[1],e[2].x*this.basisOverPI[2],e[0].x*this.basisOverPI[0]-e[6].x*this.basisOverPI[6]/3),n=new _n(e[3].y*this.basisOverPI[3],e[1].y*this.basisOverPI[1],e[2].y*this.basisOverPI[2],e[0].y*this.basisOverPI[0]-e[6].y*this.basisOverPI[6]/3),r=new _n(e[3].z*this.basisOverPI[3],e[1].z*this.basisOverPI[1],e[2].z*this.basisOverPI[2],e[0].z*this.basisOverPI[0]-e[6].z*this.basisOverPI[6]/3),s=new _n(e[4].x*this.basisOverPI[4],e[5].x*this.basisOverPI[5],e[6].x*this.basisOverPI[6],e[7].x*this.basisOverPI[7]),a=new _n(e[4].y*this.basisOverPI[4],e[5].y*this.basisOverPI[5],e[6].y*this.basisOverPI[6],e[7].y*this.basisOverPI[7]),o=new _n(e[4].z*this.basisOverPI[4],e[5].z*this.basisOverPI[5],e[6].z*this.basisOverPI[6],e[7].z*this.basisOverPI[7]),h=new ji(e[8].x*this.basisOverPI[8],e[8].y*this.basisOverPI[8],e[8].z*this.basisOverPI[8]),l=new ji(0,0,0),u=new _n(t.x,t.y,t.z,1);l.x=_n.dot(i,u),l.y=_n.dot(n,u),l.z=_n.dot(r,u);var c=new _n(t.x*t.y,t.y*t.z,t.z*t.z,t.z*t.x),d=t.x*t.x-t.y*t.y;return l.x+=_n.dot(s,c),l.y+=_n.dot(a,c),l.z+=_n.dot(o,c),ji.scaleAndAdd(l,l,h,d),l},t.evaluate=function(t,e){for(var i=new ji(0,0,0),n=e.length,r=0;r<n;r++){var s=e[r];ji.scaleAndAdd(i,i,s,this.evaluateBasis(r,t))}return i},t.project=function(t,e){Ni(t.length>0&&t.length===e.length);for(var i=this.getBasisCount(),n=t.length,r=1/(xD.uniformSpherePdf()*n),s=[],a=0;a<i;a++){for(var o=new ji(0,0,0),h=0;h<n;h++)ji.scaleAndAdd(o,o,e[h],this.evaluateBasis(a,t[h]));ji.multiplyScalar(o,o,r),s.push(o)}return s},t.convolveCosine=function(t){for(var e=[.8862268925,1.0233267546,.495415926],i=[],n=0;n<=this.LMAX;n++)for(var r=-n;r<=n;r++){var s=this.toIndex(n,r),a=new ji(0,0,0);ji.multiplyScalar(a,t[s],this.lambda(n)*e[n]),i.push(a)}return i},t.getBasisCount=function(){return 9},t.evaluateBasis=function(t,e){return Ni(t<this.getBasisCount()),(0,this.basisFunctions[t])(e)},t.reduceRinging=function(t,e){if(0!==e)for(var i=0;i<=this.LMAX;++i)for(var n=1/(1+e*i*i*(i+1)*(i+1)),r=-i;r<=i;++r){var s=this.toIndex(i,r);ji.multiplyScalar(t[s],t[s],n)}},t.lambda=function(t){return Math.sqrt(4*Math.PI/(2*t+1))},t.toIndex=function(t,e){return t*t+t+e},t}());wD.LMAX=2,wD.basisFunctions=[function(){return.282095},function(t){return.488603*t.y},function(t){return.488603*t.z},function(t){return.488603*t.x},function(t){return 1.09255*t.y*t.x},function(t){return 1.09255*t.y*t.z},function(t){return.946175*(t.z*t.z-1/3)},function(t){return 1.09255*t.z*t.x},function(t){return.546274*(t.x*t.x-t.y*t.y)}],wD.basisOverPI=[.0897936,.155527,.155527,.155527,.347769,.347769,.301177,.347769,.173884],We.internal.SH=wD;var MD,ID,BD,PD,DD,OD,FD,LD=function(){function t(){}return t.getQuadraticUniqueRoot=function(t,e,i){return 0!==t?-e/(2*t):0!==e?-i/e:0},t.getCubicUniqueRoot=function(t,e,i){var n=[],r=-t/3,s=e/3-t*t/9,a=i/2+t*t*t/27-t*e/6,o=s*s*s+a*a;if(o>0){var h=Math.sqrt(o);n.push(Math.cbrt(-a+h)+Math.cbrt(-a-h))}else if(o<0){var l=Math.acos(-a*Math.sqrt(-s)/(s*s))/3;n.push(2*Math.sqrt(-s)*Math.cos(l)),n.push(2*Math.sqrt(-s)*Math.cos(l+2*Math.PI/3)),n.push(2*Math.sqrt(-s)*Math.cos(l+4*Math.PI/3))}else if(0===a)n.push(0);else{var u=Math.cbrt(a);n.push(u),n.push(-2*u)}for(var c=0;c<n.length;c++)if(n[c]+r>=0)return n[c]+r;return 0},t}(),ND=new ji(0,0,0),kD=new ji(0,0,0),UD=new ji(0,0,0),GD=new ji(0,0,0),VD=new ji(0,0,0),HD=new ji(0,0,0),zD=new ji(0,0,0),XD=new ji(0,0,0),WD=new ji(0,0,0),YD=new ji(0,0,0),jD=new ji(0,0,0),KD=new ji(0,0,0),qD=new ji(0,0,0),ZD=new ji(0,0,0),QD=new ji(0,0,0),JD=t("LightProbesData",(MD=Ki("cc.LightProbesData"),ID=Tn([SD]),BD=Tn([RD]),MD((DD=function(){function t(){this._probes=OD&&OD(),this._tetrahedrons=FD&&FD()}var e=t.prototype;return e.empty=function(){return 0===this._probes.length||0===this._tetrahedrons.length},e.reset=function(){this._probes.length=0,this._tetrahedrons.length=0},e.updateProbes=function(t){this._probes.length=0;for(var e=t.length,i=0;i<e;i++)this._probes.push(new SD(t[i]))},e.updateTetrahedrons=function(){var t=new bD(this._probes);this._tetrahedrons=t.build()},e.getInterpolationSHCoefficients=function(t,e,i){if(!this.hasCoefficients())return!1;var n=wD.getBasisCount(),r=this._tetrahedrons[t],s=this._probes[r.vertex0].coefficients,a=this._probes[r.vertex1].coefficients,o=this._probes[r.vertex2].coefficients;if(r.vertex3>=0)for(var h=this._probes[r.vertex3].coefficients,l=0;l<n;l++)i[l]=new ji(0,0,0),ji.scaleAndAdd(i[l],i[l],s[l],e.x),ji.scaleAndAdd(i[l],i[l],a[l],e.y),ji.scaleAndAdd(i[l],i[l],o[l],e.z),ji.scaleAndAdd(i[l],i[l],h[l],e.w);else for(var u=0;u<n;u++)i[u]=new ji(0,0,0),ji.scaleAndAdd(i[u],i[u],s[u],e.x),ji.scaleAndAdd(i[u],i[u],a[u],e.y),ji.scaleAndAdd(i[u],i[u],o[u],e.z);return!0},e.getInterpolationWeights=function(t,e,i){var n=this._tetrahedrons.length;(e<0||e>=n)&&(e=0);for(var r=-1,s=-1,a=0;a<n;a++){var o=this._tetrahedrons[e];if(this.getBarycentricCoord(t,o,i),i.x>=0&&i.y>=0&&i.z>=0&&i.w>=0)break;if(r===(s=i.x<i.y&&i.x<i.z&&i.x<i.w?o.neighbours[0]:i.y<i.z&&i.y<i.w?o.neighbours[1]:i.z<i.w?o.neighbours[2]:o.neighbours[3]))break;r=e,e=s}return e},e.hasCoefficients=function(){return!this.empty()&&0!==this._probes[0].coefficients.length},t.getTriangleBarycentricCoord=function(t,e,i,n){if(ji.subtract(ND,e,t),ji.subtract(kD,i,t),ji.cross(UD,ND,kD),UD.lengthSqr()<=Mn)return new ji(0,0,0);var r=UD.clone();r.normalize();var s=1/r.dot(UD);ji.subtract(GD,t,n),ji.subtract(VD,e,n),ji.subtract(HD,i,n),ji.cross(zD,VD,HD);var a=r.dot(zD)*s;ji.cross(XD,HD,GD);var o=r.dot(XD)*s;return new ji(a,o,1-a-o)},e.getBarycentricCoord=function(t,e,i){e.vertex3>=0?this.getTetrahedronBarycentricCoord(t,e,i):this.getOuterCellBarycentricCoord(t,e,i)},e.getTetrahedronBarycentricCoord=function(t,e,i){var n=new ji(0,0,0);ji.subtract(n,t,this._probes[e.vertex3].position),ji.transformMat3(n,n,e.matrix),i.set(n.x,n.y,n.z,1-n.x-n.y-n.z)},e.getOuterCellBarycentricCoord=function(e,i,n){var r=this._probes[i.vertex0].position,s=this._probes[i.vertex1].position,a=this._probes[i.vertex2].position;ji.subtract(YD,s,r),ji.subtract(jD,a,r),ji.cross(WD,YD,jD),ji.subtract(KD,e,r);var o=ji.dot(KD,WD);if(o<0)n.set(0,0,0,-1);else{var h=new ji(0,0,0);ji.transformMat3(h,e,i.matrix),ji.add(h,h,i.offset),o=-1===i.vertex3?LD.getCubicUniqueRoot(h.x,h.y,h.z):LD.getQuadraticUniqueRoot(h.x,h.y,h.z),ji.scaleAndAdd(qD,r,this._probes[i.vertex0].normal,o),ji.scaleAndAdd(ZD,s,this._probes[i.vertex1].normal,o),ji.scaleAndAdd(QD,a,this._probes[i.vertex2].normal,o);var l=t.getTriangleBarycentricCoord(qD,ZD,QD,e);n.set(l.x,l.y,l.z,0)}},Pi(t,[{key:"probes",get:function(){return this._probes}},{key:"tetrahedrons",get:function(){return this._tetrahedrons}}]),t}(),OD=tn(DD.prototype,"_probes",[en,ID],(function(){return[]})),FD=tn(DD.prototype,"_tetrahedrons",[en,BD],(function(){return[]})),PD=DD))||PD));We.internal.LightProbesData=JD;var $D,tO,eO,iO,nO,rO,sO,aO,oO,hO,lO,uO,cO,dO,_O,fO=t("LightProbes",function(){function t(){this._giScale=1,this._giSamples=1024,this._bounces=2,this._reduceRinging=0,this._showProbe=!0,this._showWireframe=!0,this._showConvex=!1,this._data=null}var e=t.prototype;return e.initialize=function(t){this._giScale=t.giScale,this._giSamples=t.giSamples,this._bounces=t.bounces,this._reduceRinging=t.reduceRinging,this._showProbe=t.showProbe,this._showWireframe=t.showWireframe,this._showConvex=t.showConvex,this._data=t.data},e.empty=function(){return!this._data||this._data.empty()},Pi(t,[{key:"giScale",get:function(){return this._giScale},set:function(t){this._giScale=t}},{key:"giSamples",get:function(){return this._giSamples},set:function(t){this._giSamples=t}},{key:"bounces",get:function(){return this._bounces},set:function(t){this._bounces=t}},{key:"reduceRinging",get:function(){return this._reduceRinging},set:function(t){this._reduceRinging=t}},{key:"showProbe",get:function(){return this._showProbe},set:function(t){this._showProbe=t}},{key:"showWireframe",get:function(){return this._showWireframe},set:function(t){this._showWireframe=t}},{key:"showConvex",get:function(){return this._showConvex},set:function(t){this._showConvex=t}},{key:"data",get:function(){return this._data},set:function(t){this._data=t}}]),t}());We.internal.LightProbes=fO,t("LightProbeGroup",($D=Ki("cc.LightProbeGroup"),tO=Tn([ji]),eO=Tn(lD),iO=Tn(Qr),nO=Tn(Qr),rO=Tn(Qr),$D(sO=bn((aO=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._probes=oO&&oO(),e._method=hO&&hO(),e._minPos=lO&&lO(),e._maxPos=uO&&uO(),e._nProbesX=cO&&cO(),e._nProbesY=dO&&dO(),e._nProbesZ=_O&&_O(),e}He(e,t);var i=e.prototype;return i.onLoad=function(){},i.onEnable=function(){},i.onDisable=function(){},i.generateLightProbes=function(){this.node&&(this._probes=uD.generate({method:this._method,nProbesX:this._nProbesX,nProbesY:this._nProbesY,nProbesZ:this._nProbesZ,minPos:this._minPos,maxPos:this._maxPos}),this.onProbeChanged())},i.onProbeChanged=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!0),this.node.scene.globals.lightProbeInfo.syncData(this.node,this.probes),this.node.scene.globals.lightProbeInfo.update(t),e&&this.node.emit(xn.LIGHT_PROBE_CHANGED)},Pi(e,[{key:"probes",get:function(){return this._probes},set:function(t){this._probes=t}},{key:"method",get:function(){return this._method}},{key:"minPos",get:function(){return this._minPos},set:function(t){this._minPos=t}},{key:"maxPos",get:function(){return this._maxPos},set:function(t){this._maxPos=t}},{key:"nProbesX",get:function(){return this._nProbesX},set:function(t){this._nProbesX=t}},{key:"nProbesY",get:function(){return this._nProbesY},set:function(t){this._nProbesY=t}},{key:"nProbesZ",get:function(){return this._nProbesZ},set:function(t){this._nProbesZ=t}}]),e}(Pn),oO=tn(aO.prototype,"_probes",[en],(function(){return[]})),hO=tn(aO.prototype,"_method",[en],(function(){return lD.UNIFORM})),lO=tn(aO.prototype,"_minPos",[en],(function(){return new ji(-5,-5,-5)})),uO=tn(aO.prototype,"_maxPos",[en],(function(){return new ji(5,5,5)})),cO=tn(aO.prototype,"_nProbesX",[en],(function(){return 3})),dO=tn(aO.prototype,"_nProbesY",[en],(function(){return 3})),_O=tn(aO.prototype,"_nProbesZ",[en],(function(){return 3})),gn(aO.prototype,"probes",[tO],Object.getOwnPropertyDescriptor(aO.prototype,"probes"),aO.prototype),gn(aO.prototype,"method",[eO],Object.getOwnPropertyDescriptor(aO.prototype,"method"),aO.prototype),gn(aO.prototype,"nProbesX",[iO],Object.getOwnPropertyDescriptor(aO.prototype,"nProbesX"),aO.prototype),gn(aO.prototype,"nProbesY",[nO],Object.getOwnPropertyDescriptor(aO.prototype,"nProbesY"),aO.prototype),gn(aO.prototype,"nProbesZ",[rO],Object.getOwnPropertyDescriptor(aO.prototype,"nProbesZ"),aO.prototype),sO=aO))||sO)||sO));var pO,gO,mO,vO,yO,TO,SO,EO,AO,CO,RO,bO,xO=function(e){return t({Billboard:e,BillboardComponent:e}),e}((pO=Ki("cc.Billboard"),gO=Tn(Xe),mO=Tn(Xe),pO((yO=function(t){function e(){var e;return(e=t.call(this)||this)._texture=TO&&TO(),e._height=SO&&SO(),e._width=EO&&EO(),e._rotation=AO&&AO(),e._model=null,e._mesh=null,e._material=null,e._uniform=new _n(1,1,0,0),e}He(e,t);var i=e.prototype;return i.onLoad=function(){this.createModel()},i.onEnable=function(){this.attachToScene(),this._model.enabled=!0,this.width=this._width,this.height=this._height,this.rotation=this.rotation,this.texture=this.texture},i.onDisable=function(){this.detachFromScene()},i.attachToScene=function(){this._model&&this.node&&this.node.scene&&(this._model.scene&&this.detachFromScene(),this._getRenderScene().addModel(this._model))},i.detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},i.createModel=function(){this._mesh=Ro({primitiveMode:U.TRIANGLE_LIST,positions:[0,0,0,0,0,0,0,0,0,0,0,0],uvs:[0,0,1,0,0,1,1,1],colors:[Ve.WHITE.r,Ve.WHITE.g,Ve.WHITE.b,Ve.WHITE.a,Ve.WHITE.r,Ve.WHITE.g,Ve.WHITE.b,Ve.WHITE.a,Ve.WHITE.r,Ve.WHITE.g,Ve.WHITE.b,Ve.WHITE.a,Ve.WHITE.r,Ve.WHITE.g,Ve.WHITE.b,Ve.WHITE.a],attributes:[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RG32F),new Bt(ie.ATTR_COLOR,_.RGBA8UI,!0)],indices:[0,1,2,1,2,3]},void 0,{calculateBounds:!1});var t=this._model=We.director.root.createModel(ni,this.node);t.node=t.transform=this.node,null==this._material&&(this._material=new Dn,this._material.copy(Nn.get("default-billboard-material"))),t.initSubModel(0,this._mesh.renderingSubMeshes[0],this._material)},Pi(e,[{key:"texture",get:function(){return this._texture},set:function(t){this._texture=t,this._material&&this._material.setProperty("mainTexture",t)}},{key:"height",get:function(){return this._height},set:function(t){this._height=t,this._material&&(this._uniform.y=t,this._material.setProperty("cc_size_rotation",this._uniform))}},{key:"width",get:function(){return this._width},set:function(t){this._width=t,this._material&&(this._uniform.x=t,this._material.setProperty("cc_size_rotation",this._uniform))}},{key:"rotation",get:function(){return Math.round(100*la(this._rotation))/100},set:function(t){this._rotation=mr(t),this._material&&(this._uniform.z=this._rotation,this._material.setProperty("cc_size_rotation",this._uniform))}}]),e}(Pn),TO=tn(yO.prototype,"_texture",[gO],(function(){return null})),gn(yO.prototype,"texture",[mO],Object.getOwnPropertyDescriptor(yO.prototype,"texture"),yO.prototype),SO=tn(yO.prototype,"_height",[en],(function(){return 0})),EO=tn(yO.prototype,"_width",[en],(function(){return 0})),AO=tn(yO.prototype,"_rotation",[en],(function(){return 0})),vO=yO))||vO)),wO=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RGBA32F),new Bt(ie.ATTR_TEX_COORD1,_.RGB32F),new Bt(ie.ATTR_COLOR,_.RGBA8,!0)],MO=new ji,IO=new ji,BO=function(t){function e(){var e;return(e=t.call(this)||this)._capacity=void 0,e._vertSize=0,e._vBuffer=null,e._vertAttrsFloatCount=0,e._vdataF32=null,e._vdataUint32=null,e._iaInfo=void 0,e._iaInfoBuffer=void 0,e._subMeshData=null,e._vertCount=0,e._indexCount=0,e._material=null,e.type=ii.LINE,e._capacity=100,e._iaInfo=new vt([new gt]),e._iaInfoBuffer=e._device.createBuffer(new ft(g.INDIRECT,y.DEVICE,oe,oe)),e}He(e,t);var i=e.prototype;return i.setCapacity=function(t){this._capacity=t,this.createBuffer()},i.createBuffer=function(){this._vertSize=0;for(var t,e=Fi(wO);!(t=e()).done;){var i=t.value;i.offset=this._vertSize,this._vertSize+=ne[i.format].size}this._vertAttrsFloatCount=this._vertSize/4,this._vBuffer=this.createSubMeshData(),this._vdataF32=new Float32Array(this._vBuffer),this._vdataUint32=new Uint32Array(this._vBuffer)},i.updateMaterial=function(e){this._material=e,t.prototype.setSubModelMaterial.call(this,0,e)},i.createSubMeshData=function(){this._subMeshData&&this.destroySubMeshData(),this._vertCount=2,this._indexCount=6;var t=this._device.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.DEVICE,this._vertSize*this._capacity*this._vertCount,this._vertSize)),e=new ArrayBuffer(this._vertSize*this._capacity*this._vertCount);t.update(e);for(var i=new Uint16Array((this._capacity-1)*this._indexCount),n=0,r=0;r<this._capacity-1;++r){var s=2*r;i[n++]=s,i[n++]=s+1,i[n++]=s+2,i[n++]=s+3,i[n++]=s+2,i[n++]=s+1}var a=this._device.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.DEVICE,(this._capacity-1)*this._indexCount*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));return a.update(i),this._iaInfo.drawInfos[0].vertexCount=this._capacity*this._vertCount,this._iaInfo.drawInfos[0].indexCount=(this._capacity-1)*this._indexCount,this._iaInfoBuffer.update(this._iaInfo),this._subMeshData=new qi([t],wO,U.TRIANGLE_LIST,a,this._iaInfoBuffer),this.initSubModel(0,this._subMeshData,this._material),e},i.addLineVertexData=function(t,e,i){if(t.length>1){var n=0;ji.subtract(MO,t[1],t[0]),this._vdataF32[n++]=t[0].x,this._vdataF32[n++]=t[0].y,this._vdataF32[n++]=t[0].z,this._vdataF32[n++]=0,this._vdataF32[n++]=e.evaluate(0,1),this._vdataF32[n++]=0,this._vdataF32[n++]=0,this._vdataF32[n++]=MO.x,this._vdataF32[n++]=MO.y,this._vdataF32[n++]=MO.z,this._vdataUint32[n++]=i.evaluate(0,1)._val,this._vdataF32[n++]=t[0].x,this._vdataF32[n++]=t[0].y,this._vdataF32[n++]=t[0].z,this._vdataF32[n++]=1,this._vdataF32[n++]=e.evaluate(0,1),this._vdataF32[n++]=0,this._vdataF32[n++]=1,this._vdataF32[n++]=MO.x,this._vdataF32[n++]=MO.y,this._vdataF32[n++]=MO.z,this._vdataUint32[n++]=i.evaluate(0,1)._val;for(var r=1;r<t.length-1;r++){ji.subtract(MO,t[r-1],t[r]),ji.subtract(IO,t[r+1],t[r]),ji.subtract(IO,IO,MO);var s=r/t.length;this._vdataF32[n++]=t[r].x,this._vdataF32[n++]=t[r].y,this._vdataF32[n++]=t[r].z,this._vdataF32[n++]=0,this._vdataF32[n++]=e.evaluate(s,1),this._vdataF32[n++]=s,this._vdataF32[n++]=0,this._vdataF32[n++]=IO.x,this._vdataF32[n++]=IO.y,this._vdataF32[n++]=IO.z,this._vdataUint32[n++]=i.evaluate(s,1)._val,this._vdataF32[n++]=t[r].x,this._vdataF32[n++]=t[r].y,this._vdataF32[n++]=t[r].z,this._vdataF32[n++]=1,this._vdataF32[n++]=e.evaluate(s,1),this._vdataF32[n++]=s,this._vdataF32[n++]=1,this._vdataF32[n++]=IO.x,this._vdataF32[n++]=IO.y,this._vdataF32[n++]=IO.z,this._vdataUint32[n++]=i.evaluate(s,1)._val}ji.subtract(MO,t[t.length-1],t[t.length-2]),this._vdataF32[n++]=t[t.length-1].x,this._vdataF32[n++]=t[t.length-1].y,this._vdataF32[n++]=t[t.length-1].z,this._vdataF32[n++]=0,this._vdataF32[n++]=e.evaluate(1,1),this._vdataF32[n++]=1,this._vdataF32[n++]=0,this._vdataF32[n++]=MO.x,this._vdataF32[n++]=MO.y,this._vdataF32[n++]=MO.z,this._vdataUint32[n++]=i.evaluate(1,1)._val,this._vdataF32[n++]=t[t.length-1].x,this._vdataF32[n++]=t[t.length-1].y,this._vdataF32[n++]=t[t.length-1].z,this._vdataF32[n++]=1,this._vdataF32[n++]=e.evaluate(1,1),this._vdataF32[n++]=1,this._vdataF32[n++]=1,this._vdataF32[n++]=MO.x,this._vdataF32[n++]=MO.y,this._vdataF32[n++]=MO.z,this._vdataUint32[n++]=i.evaluate(1,1)._val}this.updateIA(Math.max(0,t.length-1))},i.updateIA=function(t){this._subModels[0].inputAssembler.vertexBuffers[0].update(this._vdataF32),this._iaInfo.drawInfos[0].firstIndex=0,this._iaInfo.drawInfos[0].indexCount=this._indexCount*t,this._iaInfoBuffer.update(this._iaInfo)},i.destroySubMeshData=function(){this._subMeshData&&(this._subMeshData.destroy(),this._subMeshData=null)},e}(ni),PO=ua.Attr.setClassAttr,DO=[["mode","constant","multiplier"],["mode","spline","multiplier"],["mode","splineMin","splineMax","multiplier"],["mode","constantMin","constantMax","multiplier"]],OO=fr({Constant:0,Curve:1,TwoCurves:2,TwoConstants:3}),FO=t("CurveRange",Ki("cc.CurveRange")((bO=RO=function(){function t(){this.constant=0,this.constantMin=0,this.constantMax=0,this.multiplier=1,this._mode=OO.Constant}var e=t.prototype;return e.evaluate=function(t,e){switch(this.mode){default:case OO.Constant:return this.constant;case OO.Curve:return this.spline.evaluate(t)*this.multiplier;case OO.TwoCurves:return Cs(this.splineMin.evaluate(t),this.splineMax.evaluate(t),e)*this.multiplier;case OO.TwoConstants:return Cs(this.constantMin,this.constantMax,e)}},e.getMax=function(){switch(this.mode){default:case OO.Constant:return this.constant;case OO.Curve:return this.multiplier;case OO.TwoConstants:return this.constantMax;case OO.TwoCurves:return this.multiplier}},e._onBeforeSerialize=function(){return DO[this.mode]},Pi(t,[{key:"mode",get:function(){return this._mode},set:function(t){switch(this._mode=t,t){case OO.Constant:case OO.TwoConstants:break;case OO.Curve:this.spline||(this.spline=ca());break;case OO.TwoCurves:this.splineMax||(this.splineMax=ca()),this.splineMin||(this.splineMin=ca())}}},{key:"curve",get:function(){var t;return null!==(t=this._curve)&&void 0!==t?t:this._curve=new da(this.spline)},set:function(t){this._curve=t,this.spline=t._internalCurve}},{key:"curveMin",get:function(){var t;return null!==(t=this._curveMin)&&void 0!==t?t:this._curveMin=new da(this.splineMin)},set:function(t){this._curveMin=t,this.splineMin=t._internalCurve}},{key:"curveMax",get:function(){var t;return null!==(t=this._curveMax)&&void 0!==t?t:this._curveMax=new da(this.splineMax)},set:function(t){this._curveMax=t,this.splineMax=t._internalCurve}}]),t}(),RO.Mode=OO,CO=bO))||CO);function LO(t,e,i){switch(t.mode){case OO.Constant:return t.constant;case OO.Curve:return t.spline.evaluate(e)*t.multiplier;case OO.TwoCurves:return 0===i?t.splineMin.evaluate(e)*t.multiplier:t.splineMax.evaluate(e)*t.multiplier;case OO.TwoConstants:return 0===i?t.constantMin:t.constantMax;default:return 0}}function NO(t){switch(t.mode){case OO.TwoConstants:case OO.TwoCurves:return 2;default:return 1}}function kO(t,e,i,n){return null===t||i!==t.width||n!==t.height?(t&&t.destroy(),t=function(t,e,i){var n=new Ui({width:e,height:i,_data:t,_compressed:!1,format:ze.RGBA32F}),r=new Xe;return r.setFilters(Ii.NEAREST,Ii.NEAREST),r.setMipFilter(Ii.NONE),r.setWrapMode(Nr.CLAMP_TO_EDGE,Nr.CLAMP_TO_EDGE,Nr.CLAMP_TO_EDGE),r.image=n,r}(e,i,n)):t.uploadData(e),t}function UO(t,e,i,n,r,s,a){var o=Math.max(NO(n),NO(r),NO(s)),h=i*o*4;null!==e&&e.length===h||(e=new Float32Array(i*o*4));for(var l=[n,r,s],u=1/(i-1),c=0;c<o;c++)for(var d=0;d<3;d++)for(var _=l[d],f=0,p=0,g=0;g<i;g++){var m=LO(_,u*g,c);p=a?m:(f+=m)/(g+1),e[4*(c*i+g)+d]=p}return{texture:kO(t,e,i,o),texdata:e}}ua.fastDefine("cc.CurveRange",FO,{multiplier:1,constantMax:0,constantMin:0,constant:0,mode:OO.Constant,splineMax:Object.freeze(ca()),splineMin:Object.freeze(ca()),spline:Object.freeze(ca())}),PO(FO,"multiplier","visible",!0),PO(FO,"constantMax","visible",!0),PO(FO,"constantMin","visible",!0),PO(FO,"constant","visible",!0),PO(FO,"mode","type","Enum"),PO(FO,"mode","enumList",fr.getList(OO)),PO(FO,"mode","visible",!0),PO(FO,"splineMax","type","Object"),PO(FO,"splineMax","ctor",gs),PO(FO,"splineMax","visible",!0),PO(FO,"splineMin","type","Object"),PO(FO,"splineMin","ctor",gs),PO(FO,"splineMin","visible",!0),PO(FO,"spline","type","Object"),PO(FO,"spline","ctor",gs),PO(FO,"spline","visible",!0);var GO=fr({Blend:0,Fixed:1}),VO=t("ColorKey",(function(){this.color=Ve.WHITE.clone(),this.time=0}));ua.fastDefine("cc.ColorKey",VO,{color:Ve.WHITE.clone(),time:0}),ua.Attr.setClassAttr(VO,"color","visible",!0),ua.Attr.setClassAttr(VO,"time","visible",!0);var HO=t("AlphaKey",(function(){this.alpha=1,this.time=0}));ua.fastDefine("cc.AlphaKey",HO,{alpha:1,time:0}),ua.Attr.setClassAttr(HO,"alpha","visible",!0),ua.Attr.setClassAttr(HO,"time","visible",!0);var zO,XO,WO,YO,jO,KO,qO,ZO,QO,JO,$O,tF,eF,iF,nF,rF,sF,aF=t("Gradient",function(){function t(){this.colorKeys=new Array,this.alphaKeys=new Array,this.mode=GO.Blend,this._color=void 0,this._color=Ve.WHITE.clone()}var e=t.prototype;return e.setKeys=function(t,e){this.colorKeys=t,this.alphaKeys=e},e.sortKeys=function(){this.colorKeys.length>1&&this.colorKeys.sort((function(t,e){return t.time-e.time})),this.alphaKeys.length>1&&this.alphaKeys.sort((function(t,e){return t.time-e.time}))},e.evaluate=function(t){return this.getRGB(t),this._color._set_a_unsafe(this.getAlpha(t)),this._color},e.randomColor=function(){var t=this.colorKeys[Math.trunc(Math.random()*this.colorKeys.length)],e=this.alphaKeys[Math.trunc(Math.random()*this.alphaKeys.length)];return this._color.set(t.color),this._color._set_a_unsafe(e.alpha),this._color},e.getRGB=function(t){if(this.colorKeys.length>1){t=_a(t,1);for(var e=1;e<this.colorKeys.length;++e){var i=this.colorKeys[e-1].time,n=this.colorKeys[e].time;if(t>=i&&t<n){if(this.mode===GO.Fixed)return this.colorKeys[e].color;var r=(t-i)/(n-i);return Ve.lerp(this._color,this.colorKeys[e-1].color,this.colorKeys[e].color,r),this._color}}var s=this.colorKeys.length-1;return t<this.colorKeys[0].time?Ve.lerp(this._color,Ve.BLACK,this.colorKeys[0].color,t/this.colorKeys[0].time):t>this.colorKeys[s].time&&Ve.lerp(this._color,this.colorKeys[s].color,Ve.BLACK,(t-this.colorKeys[s].time)/(1-this.colorKeys[s].time)),this._color}return 1===this.colorKeys.length?(this._color.set(this.colorKeys[0].color),this._color):(this._color.set(Ve.WHITE),this._color)},e.getAlpha=function(t){if(this.alphaKeys.length>1){t=_a(t,1);for(var e=1;e<this.alphaKeys.length;++e){var i=this.alphaKeys[e-1].time,n=this.alphaKeys[e].time;if(t>=i&&t<n){if(this.mode===GO.Fixed)return this.alphaKeys[e].alpha;var r=(t-i)/(n-i);return Cs(this.alphaKeys[e-1].alpha,this.alphaKeys[e].alpha,r)}}var s=this.alphaKeys.length-1;return t<this.alphaKeys[0].time?Cs(0,this.alphaKeys[0].alpha,t/this.alphaKeys[0].time):t>this.alphaKeys[s].time?Cs(this.alphaKeys[s].alpha,0,(t-this.alphaKeys[s].time)/(1-this.alphaKeys[s].time)):255}return 1===this.alphaKeys.length?this.alphaKeys[0].alpha:255},t}());aF.Mode=GO,ua.fastDefine("cc.Gradient",aF,{colorKeys:[],alphaKeys:[],mode:GO.Blend}),ua.Attr.setClassAttr(aF,"colorKeys","visible",!0),ua.Attr.setClassAttr(aF,"alphaKeys","visible",!0),ua.Attr.setClassAttr(aF,"mode","visible",!0);var oF,hF,lF,uF,cF,dF,_F,fF,pF,gF,mF,vF,yF,TF,SF,EF,AF,CF,RF,bF,xF,wF,MF=aa,IF=fr({Color:0,Gradient:1,TwoColors:2,TwoGradients:3,RandomColor:4}),BF=t("GradientRange",(zO=Ki("cc.GradientRange"),XO=Tn(IF),WO=Tn(aF),YO=Tn(aF),jO=Tn(aF),KO=Tn(IF),zO((sF=rF=function(){function t(){this.color=QO&&QO(),this.colorMin=JO&&JO(),this.colorMax=$O&&$O(),this.gradient=tF&&tF(),this.gradientMin=eF&&eF(),this.gradientMax=iF&&iF(),this._mode=nF&&nF(),this._color=Ve.WHITE.clone()}var e=t.prototype;return e.evaluate=function(t,e){switch(this._mode){case IF.Color:return this.color;case IF.TwoColors:return Ve.lerp(this._color,this.colorMin,this.colorMax,e),this._color;case IF.RandomColor:return this.gradient.randomColor();case IF.Gradient:return this.gradient.evaluate(t);case IF.TwoGradients:return Ve.lerp(this._color,this.gradientMin.evaluate(t),this.gradientMax.evaluate(t),e),this._color;default:return this.color}},e._onBeforeSerialize=function(){return MF[this._mode]},Pi(t,[{key:"mode",get:function(){return this._mode},set:function(t){this._mode=t}}]),t}(),rF.Mode=IF,gn((ZO=sF).prototype,"mode",[XO],Object.getOwnPropertyDescriptor(ZO.prototype,"mode"),ZO.prototype),QO=tn(ZO.prototype,"color",[en],(function(){return Ve.WHITE.clone()})),JO=tn(ZO.prototype,"colorMin",[en],(function(){return Ve.WHITE.clone()})),$O=tn(ZO.prototype,"colorMax",[en],(function(){return Ve.WHITE.clone()})),tF=tn(ZO.prototype,"gradient",[WO],(function(){return new aF})),eF=tn(ZO.prototype,"gradientMin",[YO],(function(){return new aF})),iF=tn(ZO.prototype,"gradientMax",[jO],(function(){return new aF})),nF=tn(ZO.prototype,"_mode",[KO],(function(){return IF.Color})),qO=ZO))||qO));function PF(t,e,i){switch(t.mode){case IF.Color:return t.color;case IF.TwoColors:return 0===i?t.colorMin:t.colorMax;case IF.RandomColor:return t.gradient.randomColor();case IF.Gradient:return t.gradient.evaluate(e);case IF.TwoGradients:return 0===i?t.gradientMin.evaluate(e):t.gradientMax.evaluate(e);default:return t.color}}var DF={parent:null,owner:null,subModelIdx:0},OF={CC_USE_WORLD_SPACE:!1},FF=function(e){return t({Line:e,LineComponent:e}),e}((oF=Ki("cc.Line"),hF=Tn(Xe),lF=Tn(Xe),uF=Tn(Dn),cF=Tn([ji]),dF=Tn([ji]),_F=Tn(FO),fF=Tn(FO),pF=Tn(cn),gF=Tn(cn),mF=Tn(BF),vF=Tn(BF),oF((TF=function(t){function e(){var e;return(e=t.call(this)||this)._texture=SF&&SF(),e._material=EF&&EF(),e._materialInstance=null,e._worldSpace=AF&&AF(),e._positions=CF&&CF(),e._width=RF&&RF(),e._tile=bF&&bF(),e._offset=xF&&xF(),e._color=wF&&wF(),e._model=null,e._tile_offset=new _n,e}He(e,t);var i=e.prototype;return i.onLoad=function(){var t=this._model=We.director.root.createModel(BO);t.node=t.transform=this.node,null===this._material&&(this._material=new Dn,this._material.copy(Nn.get("default-trail-material"))),this._material&&(OF.CC_USE_WORLD_SPACE=this.worldSpace,DF.parent=this._material,DF.subModelIdx=0,this._materialInstance=new On(DF),DF.parent=null,DF.subModelIdx=0,this._materialInstance.recompileShaders(OF)),t.updateMaterial(this._materialInstance),t.setCapacity(100)},i.onEnable=function(){this._model&&(this._attachToScene(),this.texture=this._texture,this.tile=this._tile,this.offset=this._offset,this._model.addLineVertexData(this._positions,this._width,this._color))},i.onDisable=function(){this._model&&this._detachFromScene()},i._attachToScene=function(){this._model&&this.node&&this.node.scene&&(this._model.scene&&this._detachFromScene(),this._getRenderScene().addModel(this._model))},i._detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},Pi(e,[{key:"texture",get:function(){return this._texture},set:function(t){this._texture=t,this._materialInstance&&this._materialInstance.setProperty("mainTexture",t)}},{key:"material",get:function(){return this._material},set:function(t){this._material=t}},{key:"worldSpace",get:function(){return this._worldSpace},set:function(t){this._worldSpace=t,this._materialInstance&&(OF.CC_USE_WORLD_SPACE=this.worldSpace,this._materialInstance.recompileShaders(OF),this._model&&this._model.setSubModelMaterial(0,this._materialInstance))}},{key:"positions",get:function(){return this._positions},set:function(t){this._positions=t,this._model&&this._model.addLineVertexData(this._positions,this._width,this._color)}},{key:"width",get:function(){return this._width},set:function(t){this._width=t,this._model&&this._model.addLineVertexData(this._positions,this._width,this._color)}},{key:"tile",get:function(){return this._tile},set:function(t){this._tile.set(t),this._materialInstance&&(this._tile_offset.x=this._tile.x,this._tile_offset.y=this._tile.y,this._materialInstance.setProperty("mainTiling_Offset",this._tile_offset))}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset.set(t),this._materialInstance&&(this._tile_offset.z=this._offset.x,this._tile_offset.w=this._offset.y,this._materialInstance.setProperty("mainTiling_Offset",this._tile_offset))}},{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._model&&this._model.addLineVertexData(this._positions,this._width,this._color)}}]),e}(Pn),SF=tn(TF.prototype,"_texture",[hF],(function(){return null})),gn(TF.prototype,"texture",[lF],Object.getOwnPropertyDescriptor(TF.prototype,"texture"),TF.prototype),EF=tn(TF.prototype,"_material",[en],(function(){return null})),gn(TF.prototype,"material",[uF],Object.getOwnPropertyDescriptor(TF.prototype,"material"),TF.prototype),AF=tn(TF.prototype,"_worldSpace",[en],(function(){return!1})),CF=tn(TF.prototype,"_positions",[cF],(function(){return[]})),gn(TF.prototype,"positions",[dF],Object.getOwnPropertyDescriptor(TF.prototype,"positions"),TF.prototype),RF=tn(TF.prototype,"_width",[_F],(function(){return new FO})),gn(TF.prototype,"width",[fF],Object.getOwnPropertyDescriptor(TF.prototype,"width"),TF.prototype),bF=tn(TF.prototype,"_tile",[en],(function(){return new cn(1,1)})),gn(TF.prototype,"tile",[pF],Object.getOwnPropertyDescriptor(TF.prototype,"tile"),TF.prototype),xF=tn(TF.prototype,"_offset",[en],(function(){return new cn(0,0)})),gn(TF.prototype,"offset",[gF],Object.getOwnPropertyDescriptor(TF.prototype,"offset"),TF.prototype),wF=tn(TF.prototype,"_color",[mF],(function(){return new BF})),gn(TF.prototype,"color",[vF],Object.getOwnPropertyDescriptor(TF.prototype,"color"),TF.prototype),yF=TF))||yF)),LF=function(){function t(t){this.particleSystem=void 0,this.position=void 0,this.velocity=void 0,this.animatedVelocity=void 0,this.ultimateVelocity=void 0,this.angularVelocity=void 0,this.axisOfRotation=void 0,this.rotation=void 0,this.startEuler=void 0,this.startRotation=void 0,this.startRotated=void 0,this.deltaQuat=void 0,this.deltaMat=void 0,this.localMat=void 0,this.startSize=void 0,this.size=void 0,this.startColor=void 0,this.color=void 0,this.randomSeed=void 0,this.remainingLifetime=void 0,this.loopCount=void 0,this.lastLoop=void 0,this.trailDelay=void 0,this.startLifetime=void 0,this.emitAccumulator0=void 0,this.emitAccumulator1=void 0,this.frameIndex=void 0,this.startRow=void 0,this.particleSystem=t,this.position=new ji(0,0,0),this.velocity=new ji(0,0,0),this.animatedVelocity=new ji(0,0,0),this.ultimateVelocity=new ji(0,0,0),this.angularVelocity=new ji(0,0,0),this.axisOfRotation=new ji(0,0,0),this.rotation=new ji(0,0,0),this.startEuler=new ji(0,0,0),this.startRotation=new Ji,this.startRotated=!1,this.deltaQuat=new Ji,this.deltaMat=new Ue,this.localMat=new Ue,this.startSize=new ji(0,0,0),this.size=new ji(0,0,0),this.startColor=Ve.WHITE.clone(),this.color=Ve.WHITE.clone(),this.randomSeed=0,this.remainingLifetime=0,this.loopCount=0,this.lastLoop=0,this.trailDelay=0,this.startLifetime=0,this.emitAccumulator0=0,this.emitAccumulator1=0,this.frameIndex=0,this.startRow=0}return t.prototype.reset=function(){this.rotation.set(0,0,0),this.startEuler.set(0,0,0),this.startRotation.set(0,0,0,1),this.startRotated=!1,this.deltaQuat.set(0,0,0,1),this.deltaMat.identity(),this.localMat.identity()},t}();LF.INDENTIFY_NEG_QUAT=10,LF.R2D=180/Math.PI;var NF,kF,UF,GF,VF,HF,zF="colorModule",XF="rotationModule",WF="sizeModule",YF="textureModule",jF="noiseModule",KF=["sizeModule","colorModule","forceModule","velocityModule","limitModule","rotationModule","textureModule","noiseModule"],qF=["_colorOverLifetimeModule","_shapeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule","_noiseModule","_trailModule"],ZF=function(){function t(){this.target=null,this.needUpdate=!1,this.needAnimate=!0,this.name=void 0}var e=t.prototype;return e.bindTarget=function(t){this.target=t},e.update=function(){},t}(),QF=fr({World:0,Local:1,Custom:2}),JF=fr({Pause:0,PauseAndCatchup:1,AlwaysSimulate:2}),$F=fr({World:0,Local:1,View:2}),tL=fr({Billboard:0,StrecthedBillboard:1,HorizontalBillboard:2,VerticalBillboard:3,Mesh:4}),eL=fr({Box:0,Circle:1,Cone:2,Sphere:3,Hemisphere:4}),iL=fr({Base:0,Edge:1,Shell:2,Volume:3}),nL=fr({Random:0,Loop:1,PingPong:2}),rL=fr({Particles:0}),sL=fr({Stretch:0}),aL=new ji(0,0,-1);function oL(t,e,i,n){return e!==t?(t===QF.World||Ue.invert(i,i),Ue.getRotation(n,i),!0):(Ji.set(n,0,0,0,1),!1)}function hL(t,e){cn.set(t,Math.cos(e),Math.sin(e))}function lL(t){var e=pa(-1,1),i=pa(0,2*Math.PI),n=Math.sqrt(1-e*e),r=n*Math.cos(i),s=n*Math.sin(i);ji.set(t,r,s,e)}function uL(t,e,i){lL(t),ji.multiplyScalar(t,t,e+(i-e)*fa())}function cL(t,e,i,n){hL(t,n),t.z=0,ji.multiplyScalar(t,t,e+(i-e)*fa())}function dL(t){for(var e=0;e<t.length;e++){var i=e+ga(0,t.length-e),n=t[i];t[i]=t[e],t[e]=n}}function _L(){var t=pa(-1,1);return 0===t&&t++,ma(t)}function fL(t){var e=FO.Mode;switch(t.mode){case e.TwoCurves:case e.TwoConstants:return!0;default:return!1}}var pL,gL,mL,vL,yL,TL,SL,EL,AL,CL,RL,bL,xL,wL,ML,IL,BL,PL,DL,OL,FL,LL,NL,kL,UL,GL,VL,HL,zL,XL,WL,YL,jL,KL,qL,ZL,QL,JL,$L,tN=(NF=Ki("cc.ColorOvertimeModule"),kF=Tn(BF),NF((GF=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._enable=VF&&VF(),e.color=HF&&HF(),e.name=zF,e}return He(e,t),e.prototype.animate=function(t){t.color.set(t.startColor);var e=function(t){var e=BF.Mode;switch(t.mode){case e.TwoGradients:case e.TwoColors:return!0;default:return!1}}(this.color)?va(t.randomSeed+91041):0;t.color.multiply(this.color.evaluate(1-t.remainingLifetime/t.startLifetime,e))},Pi(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(ZF),VF=tn(GF.prototype,"_enable",[en],(function(){return!1})),HF=tn(GF.prototype,"color",[kF,en],(function(){return new BF})),UF=GF))||UF),eN=212165,iN=new ji,nN=(pL=Ki("cc.ForceOvertimeModule"),gL=Tn(FO),mL=Tn(FO),vL=Tn(FO),yL=Tn(QF),pL((SL=function(t){function e(){var e;return(e=t.call(this)||this)._enable=EL&&EL(),e.x=AL&&AL(),e.y=CL&&CL(),e.z=RL&&RL(),e.space=bL&&bL(),e.randomized=!1,e.rotation=void 0,e.needTransform=void 0,e.name="forceModule",e.rotation=new Ji,e.needTransform=!1,e.needUpdate=!0,e}He(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=oL(t,this.space,e,this.rotation)},i.animate=function(t,e){var i=1-t.remainingLifetime/t.startLifetime,n=fL(this.x)?va(t.randomSeed+eN):0,r=fL(this.y)?va(t.randomSeed+eN):0,s=fL(this.z)?va(t.randomSeed+eN):0,a=ji.set(iN,this.x.evaluate(i,n),this.y.evaluate(i,r),this.z.evaluate(i,s));this.needTransform&&ji.transformQuat(a,a,this.rotation),ji.scaleAndAdd(t.velocity,t.velocity,a,e),ji.copy(t.ultimateVelocity,t.velocity)},Pi(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(ZF),EL=tn(SL.prototype,"_enable",[en],(function(){return!1})),AL=tn(SL.prototype,"x",[gL,en],(function(){return new FO})),CL=tn(SL.prototype,"y",[mL,en],(function(){return new FO})),RL=tn(SL.prototype,"z",[vL,en],(function(){return new FO})),bL=tn(SL.prototype,"space",[yL,en],(function(){return QF.Local})),TL=SL))||TL),rN=23541,sN=new ji,aN=new ji,oN=(xL=Ki("cc.LimitVelocityOvertimeModule"),wL=Tn(FO),ML=Tn(FO),IL=Tn(FO),BL=Tn(FO),PL=Tn(QF),xL((OL=function(t){function e(){var e;return(e=t.call(this)||this)._enable=FL&&FL(),e.limitX=LL&&LL(),e.limitY=NL&&NL(),e.limitZ=kL&&kL(),e.limit=UL&&UL(),e.dampen=GL&&GL(),e.separateAxes=VL&&VL(),e.space=HL&&HL(),e.drag=null,e.multiplyDragByParticleSize=!1,e.multiplyDragByParticleVelocity=!1,e.name="limitModule",e.rotation=void 0,e.needTransform=void 0,e.rotation=new Ji,e.needTransform=!1,e.needUpdate=!0,e}He(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=oL(t,this.space,e,this.rotation)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=sN;if(this.separateAxes){var n=fL(this.limitX)?va(t.randomSeed+rN):0,r=fL(this.limitY)?va(t.randomSeed+rN):0,s=fL(this.limitZ)?va(t.randomSeed+rN):0;ji.set(aN,this.limitX.evaluate(e,n),this.limitY.evaluate(e,r),this.limitZ.evaluate(e,s)),this.needTransform&&ji.transformQuat(aN,aN,this.rotation),ji.set(i,hN(t.ultimateVelocity.x,aN.x,this.dampen),hN(t.ultimateVelocity.y,aN.y,this.dampen),hN(t.ultimateVelocity.z,aN.z,this.dampen))}else{ji.normalize(i,t.ultimateVelocity);var a=fL(this.limit)?va(t.randomSeed+rN):0;ji.multiplyScalar(i,i,hN(t.ultimateVelocity.length(),this.limit.evaluate(e,a),this.dampen))}ji.copy(t.ultimateVelocity,i),ji.copy(t.velocity,t.ultimateVelocity)},Pi(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(ZF),FL=tn(OL.prototype,"_enable",[en],(function(){return!1})),LL=tn(OL.prototype,"limitX",[wL,en],(function(){return new FO})),NL=tn(OL.prototype,"limitY",[ML,en],(function(){return new FO})),kL=tn(OL.prototype,"limitZ",[IL,en],(function(){return new FO})),UL=tn(OL.prototype,"limit",[BL,en],(function(){return new FO})),GL=tn(OL.prototype,"dampen",[en],(function(){return 3})),VL=tn(OL.prototype,"separateAxes",[en],(function(){return!1})),HL=tn(OL.prototype,"space",[PL,en],(function(){return QF.Local})),DL=OL))||DL);function hN(t,e,i){var n=Math.sign(t),r=Math.abs(t);if(r>e){var s=r-r*i;r=s>e?s:e}return r*n}var lN,uN,cN,dN,_N,fN,pN,gN,mN,vN,yN,TN,SN,EN,AN,CN,RN,bN,xN,wN,MN,IN,BN,PN,DN,ON,FN,LN,NN,kN,UN,GN,VN,HN,zN,XN,WN,YN,jN,KN,qN,ZN,QN,JN,$N,tk,ek,ik,nk,rk,sk,ak,ok,hk,lk,uk,ck,dk,_k,fk,pk,gk,mk,vk,yk,Tk,Sk,Ek,Ak,Ck,Rk,bk,xk,wk,Mk,Ik,Bk,Pk,Dk,Ok,Fk,Lk,Nk,kk,Uk,Gk,Vk=125292,Hk=(zL=Ki("cc.RotationOvertimeModule"),XL=Tn(FO),WL=Tn(FO),YL=Tn(FO),zL((KL=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._enable=qL&&qL(),e._separateAxes=ZL&&ZL(),e.x=QL&&QL(),e.y=JL&&JL(),e.z=$L&&$L(),e.name=XF,e._startMat=new Ue,e._matRot=new Ue,e._quatRot=new Ji,e._otherEuler=new ji,e}He(e,t);var i=e.prototype;return i._processRotation=function(t){var e=t.particleSystem.processor.getInfo().renderMode;e!==tL.Mesh&&e===tL.StrecthedBillboard&&this._quatRot.set(0,0,0,1),Ji.normalize(this._quatRot,this._quatRot),this._quatRot.w<0&&(this._quatRot.x+=LF.INDENTIFY_NEG_QUAT)},i.animate=function(t,e){var i=1-t.remainingLifetime/t.startLifetime,n=fL(this.z)?va(t.randomSeed+Vk):0,r=t.particleSystem.processor.getInfo().renderMode;if(this._separateAxes&&r!==tL.VerticalBillboard&&r!==tL.HorizontalBillboard){var s=fL(this.x)?va(t.randomSeed+Vk):0,a=fL(this.y)?va(t.randomSeed+Vk):0;Ji.fromEuler(t.deltaQuat,this.x.evaluate(i,s)*e*LF.R2D,this.y.evaluate(i,a)*e*LF.R2D,this.z.evaluate(i,n)*e*LF.R2D)}else Ji.fromEuler(t.deltaQuat,0,0,this.z.evaluate(i,n)*e*LF.R2D);t.deltaMat=Ue.fromQuat(t.deltaMat,t.deltaQuat),t.localMat=t.localMat.multiply(t.deltaMat),t.startRotated||(r!==tL.Mesh&&(r===tL.StrecthedBillboard?t.startEuler.set(0,0,0):r!==tL.Billboard&&t.startEuler.set(0,0,t.startEuler.z)),Ji.fromEuler(t.startRotation,t.startEuler.x*LF.R2D,t.startEuler.y*LF.R2D,t.startEuler.z*LF.R2D),t.startRotated=!0),this._startMat=Ue.fromQuat(this._startMat,t.startRotation),this._matRot=this._startMat.multiply(t.localMat),Ue.getRotation(this._quatRot,this._matRot),this._processRotation(t,LF.R2D),t.rotation.set(this._quatRot.x,this._quatRot.y,this._quatRot.z)},Pi(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}},{key:"separateAxes",get:function(){return this._separateAxes},set:function(t){this._separateAxes=t}}]),e}(ZF),qL=tn(KL.prototype,"_enable",[en],(function(){return!1})),ZL=tn(KL.prototype,"_separateAxes",[en],(function(){return!1})),QL=tn(KL.prototype,"x",[XL,en],(function(){return new FO})),JL=tn(KL.prototype,"y",[WL,en],(function(){return new FO})),$L=tn(KL.prototype,"z",[YL,en],(function(){return new FO})),jL=KL))||jL),zk=39825,Xk=(lN=Ki("cc.SizeOvertimeModule"),uN=Tn(FO),cN=Tn(FO),dN=Tn(FO),_N=Tn(FO),lN((pN=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._enable=gN&&gN(),e.separateAxes=mN&&mN(),e.size=vN&&vN(),e.x=yN&&yN(),e.y=TN&&TN(),e.z=SN&&SN(),e.name=WF,e}return He(e,t),e.prototype.animate=function(t){if(this.separateAxes){var e=1-t.remainingLifetime/t.startLifetime,i=fL(this.x)?va(t.randomSeed+zk):0,n=fL(this.y)?va(t.randomSeed+zk):0,r=fL(this.z)?va(t.randomSeed+zk):0;t.size.x=t.startSize.x*this.x.evaluate(e,i),t.size.y=t.startSize.y*this.y.evaluate(e,n),t.size.z=t.startSize.z*this.z.evaluate(e,r)}else{var s=fL(this.size)?va(t.randomSeed+zk):0;ji.multiplyScalar(t.size,t.startSize,this.size.evaluate(1-t.remainingLifetime/t.startLifetime,s))}},Pi(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(ZF),gN=tn(pN.prototype,"_enable",[en],(function(){return!1})),mN=tn(pN.prototype,"separateAxes",[en],(function(){return!1})),vN=tn(pN.prototype,"size",[uN,en],(function(){return new FO})),yN=tn(pN.prototype,"x",[cN,en],(function(){return new FO})),TN=tn(pN.prototype,"y",[dN,en],(function(){return new FO})),SN=tn(pN.prototype,"z",[_N,en],(function(){return new FO})),fN=pN))||fN),Wk=fr({Grid:0}),Yk=fr({WholeSheet:0,SingleRow:1}),jk=(EN=Ki("cc.TextureAnimationModule"),AN=is("numTilesX"),CN=is("numTilesY"),RN=Tn(Wk),bN=Tn(Wk),xN=Tn(Yk),wN=Tn(FO),MN=Tn(FO),EN((BN=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._enable=PN&&PN(),e._numTilesX=DN&&DN(),e._numTilesY=ON&&ON(),e._mode=FN&&FN(),e.animation=LN&&LN(),e.frameOverTime=NN&&NN(),e.startFrame=kN&&kN(),e.cycleCount=UN&&UN(),e._flipU=GN&&GN(),e._flipV=VN&&VN(),e._uvChannelMask=HN&&HN(),e.randomRow=zN&&zN(),e.rowIndex=XN&&XN(),e.name=YF,e}He(e,t);var i=e.prototype;return i.init=function(t){t.startRow=Math.floor(Math.random()*this.numTilesY)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=fL(this.startFrame)?va(t.randomSeed+90794):0,n=fL(this.frameOverTime)?va(t.randomSeed+90794):0,r=this.startFrame.evaluate(e,i)/(this.numTilesX*this.numTilesY);if(this.animation===Yk.WholeSheet)t.frameIndex=_a(this.cycleCount*(this.frameOverTime.evaluate(e,n)+r),1);else if(this.animation===Yk.SingleRow){var s=1/this.numTilesY;if(this.randomRow){var a=_a(this.cycleCount*(this.frameOverTime.evaluate(e,n)+r),1),o=t.startRow*s,h=o+s;t.frameIndex=Cs(o,h,a)}else{var l=this.rowIndex*s,u=l+s;t.frameIndex=Cs(l,u,_a(this.cycleCount*(this.frameOverTime.evaluate(e,n)+r),1))}}},Pi(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&(this.target.updateMaterialParams(),this.target.enableModule(this.name,t,this)))}},{key:"mode",get:function(){return this._mode},set:function(t){t!==Wk.Grid&&console.error("particle texture animation's sprites is not supported!")}},{key:"numTilesX",get:function(){return this._numTilesX},set:function(t){this._numTilesX!==t&&(this._numTilesX=t,this.target.updateMaterialParams())}},{key:"numTilesY",get:function(){return this._numTilesY},set:function(t){this._numTilesY!==t&&(this._numTilesY=t,this.target.updateMaterialParams())}},{key:"flipU",get:function(){return this._flipU},set:function(){console.error("particle texture animation's flipU is not supported!")}},{key:"flipV",get:function(){return this._flipV},set:function(){console.error("particle texture animation's flipV is not supported!")}},{key:"uvChannelMask",get:function(){return this._uvChannelMask},set:function(){console.error("particle texture animation's uvChannelMask is not supported!")}}]),e}(ZF),PN=tn(BN.prototype,"_enable",[en],(function(){return!1})),DN=tn(BN.prototype,"_numTilesX",[AN],(function(){return 0})),ON=tn(BN.prototype,"_numTilesY",[CN],(function(){return 0})),FN=tn(BN.prototype,"_mode",[RN],(function(){return Wk.Grid})),gn(BN.prototype,"mode",[bN],Object.getOwnPropertyDescriptor(BN.prototype,"mode"),BN.prototype),LN=tn(BN.prototype,"animation",[xN,en],(function(){return Yk.WholeSheet})),NN=tn(BN.prototype,"frameOverTime",[wN,en],(function(){return new FO})),kN=tn(BN.prototype,"startFrame",[MN,en],(function(){return new FO})),UN=tn(BN.prototype,"cycleCount",[en],(function(){return 0})),GN=tn(BN.prototype,"_flipU",[en],(function(){return 0})),VN=tn(BN.prototype,"_flipV",[en],(function(){return 0})),HN=tn(BN.prototype,"_uvChannelMask",[en],(function(){return-1})),zN=tn(BN.prototype,"randomRow",[en],(function(){return!1})),XN=tn(BN.prototype,"rowIndex",[en],(function(){return 0})),IN=BN))||IN),Kk=197866,qk=new ji,Zk=(WN=Ki("cc.VelocityOvertimeModule"),YN=Tn(FO),jN=Tn(FO),KN=Tn(FO),qN=Tn(FO),ZN=Tn(QF),WN((JN=function(t){function e(){var e;return(e=t.call(this)||this)._enable=$N&&$N(),e.x=tk&&tk(),e.y=ek&&ek(),e.z=ik&&ik(),e.speedModifier=nk&&nk(),e.space=rk&&rk(),e.rotation=void 0,e.needTransform=void 0,e.name="velocityModule",e.rotation=new Ji,e.speedModifier.constant=1,e.needTransform=!1,e.needUpdate=!0,e}He(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=oL(t,this.space,e,this.rotation)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=fL(this.x)?va(t.randomSeed^Kk):0,n=fL(this.y)?va(156497^t.randomSeed):0,r=fL(this.z)?va(984136^t.randomSeed):0,s=fL(this.speedModifier)?va(t.randomSeed+Kk):0,a=ji.set(qk,this.x.evaluate(e,i),this.y.evaluate(e,n),this.z.evaluate(e,r));this.needTransform&&ji.transformQuat(a,a,this.rotation),ji.add(t.animatedVelocity,t.animatedVelocity,a),ji.add(t.ultimateVelocity,t.velocity,t.animatedVelocity),ji.multiplyScalar(t.ultimateVelocity,t.ultimateVelocity,this.speedModifier.evaluate(1-t.remainingLifetime/t.startLifetime,s))},Pi(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(ZF),$N=tn(JN.prototype,"_enable",[en],(function(){return!1})),tk=tn(JN.prototype,"x",[YN,en],(function(){return new FO})),ek=tn(JN.prototype,"y",[jN,en],(function(){return new FO})),ik=tn(JN.prototype,"z",[KN,en],(function(){return new FO})),nk=tn(JN.prototype,"speedModifier",[qN,en],(function(){return new FO})),rk=tn(JN.prototype,"space",[ZN,en],(function(){return QF.Local})),QN=JN))||QN),Qk=t("Burst",(sk=Ki("cc.Burst"),ak=Tn(FO),sk((hk=function(){function t(){this._time=lk&&lk(),this._repeatCount=uk&&uk(),this.repeatInterval=ck&&ck(),this.count=dk&&dk(),this._remainingCount=void 0,this._curTime=void 0,this._remainingCount=0,this._curTime=0}var e=t.prototype;return e.update=function(t,e){if(0===this._remainingCount&&(this._remainingCount=this._repeatCount,this._curTime=this._time),this._remainingCount>0){var i=_a(t._time-t.startDelay.evaluate(0,1),t.duration)-e;i=i>0?i:0;var n=_a(t.time-t.startDelay.evaluate(0,1),t.duration);this._curTime>=i&&this._curTime<n&&(t.emit(this.count.evaluate(this._curTime/t.duration,1),e-(n-this._curTime)),this._curTime+=this.repeatInterval,--this._remainingCount)}},e.reset=function(){this._remainingCount=0,this._curTime=0},e.getMaxCount=function(t){return this.count.getMax()*Math.min(Math.ceil(t.duration/this.repeatInterval),this.repeatCount)},Pi(t,[{key:"time",get:function(){return this._time},set:function(t){this._time=t,this._curTime=t}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(t){this._repeatCount=t,this._remainingCount=t}}]),t}(),lk=tn(hk.prototype,"_time",[en],(function(){return 0})),uk=tn(hk.prototype,"_repeatCount",[en],(function(){return 1})),ck=tn(hk.prototype,"repeatInterval",[en],(function(){return 1})),dk=tn(hk.prototype,"count",[ak,en],(function(){return new FO})),ok=hk))||ok)),Jk=new ji(0,0,0),$k=[],tU=new ji(.5,.5,.5),eU=(_k=Ki("cc.ShapeModule"),fk=Tn(eL),pk=is("shapeType"),gk=Tn(eL),mk=Tn(iL),vk=Tn(nL),yk=Tn(FO),_k((Sk=function(){function t(){this._enable=Ek&&Ek(),this._shapeType=Ak&&Ak(),this.emitFrom=Ck&&Ck(),this.alignToDirection=Rk&&Rk(),this.randomDirectionAmount=bk&&bk(),this.sphericalDirectionAmount=xk&&xk(),this.randomPositionAmount=wk&&wk(),this.radius=Mk&&Mk(),this.radiusThickness=Ik&&Ik(),this.arcMode=Bk&&Bk(),this.arcSpread=Pk&&Pk(),this.arcSpeed=Dk&&Dk(),this.length=Ok&&Ok(),this.boxThickness=Fk&&Fk(),this._position=Lk&&Lk(),this._rotation=Nk&&Nk(),this._scale=kk&&kk(),this._arc=Uk&&Uk(),this._angle=Gk&&Gk(),this.mat=void 0,this.quat=void 0,this.particleSystem=void 0,this.lastTime=void 0,this.totalAngle=void 0,this.mat=new Ue,this.quat=new Ji,this.particleSystem=null,this.lastTime=0,this.totalAngle=0}var e=t.prototype;return e.onInit=function(t){this.particleSystem=t,this.constructMat(),this.lastTime=this.particleSystem._time},e.emit=function(t){switch(this.shapeType){case eL.Box:!function(t,e,i,n){switch(t){case iL.Volume:r=i,s=tU,ji.set(r,pa(-s.x,s.x),pa(-s.y,s.y),pa(-s.z,s.z));break;case iL.Shell:$k.splice(0,$k.length),$k.push(pa(-.5,.5)),$k.push(pa(-.5,.5)),$k.push(.5*_L()),dL($k),iU($k,e),ji.set(i,$k[0],$k[1],$k[2]);break;case iL.Edge:$k.splice(0,$k.length),$k.push(pa(-.5,.5)),$k.push(.5*_L()),$k.push(.5*_L()),dL($k),iU($k,e),ji.set(i,$k[0],$k[1],$k[2]);break;default:console.warn(t+" is not supported for box emitter.")}var r,s;ji.copy(n,aL)}(this.emitFrom,this.boxThickness,t.position,t.velocity);break;case eL.Circle:e=this.radius,i=this.radiusThickness,n=this.generateArcAngle(),r=t.position,s=t.velocity,cL(r,e*(1-i),e,n),ji.normalize(s,r);break;case eL.Cone:!function(t,e,i,n,r,s,a,o){switch(t){case iL.Base:cL(a,e*(1-i),e,n),cn.multiplyScalar(o,a,Math.sin(r)),o.z=-Math.cos(r)*e,ji.normalize(o,o),a.z=0;break;case iL.Shell:hL(a,n),cn.multiplyScalar(o,a,Math.sin(r)),o.z=-Math.cos(r),ji.normalize(o,o),cn.multiplyScalar(a,a,e),a.z=0;break;case iL.Volume:cL(a,e*(1-i),e,n),cn.multiplyScalar(o,a,Math.sin(r)),o.z=-Math.cos(r)*e,ji.normalize(o,o),a.z=0,ji.add(a,a,ji.multiplyScalar(Jk,o,s*fa()/-o.z));break;default:console.warn(t+" is not supported for cone emitter.")}}(this.emitFrom,this.radius,this.radiusThickness,this.generateArcAngle(),this._angle,this.length,t.position,t.velocity);break;case eL.Sphere:!function(t,e,i,n,r){switch(t){case iL.Volume:uL(n,e*(1-i),e),ji.normalize(r,n);break;case iL.Shell:lL(n),ji.multiplyScalar(n,n,e),ji.normalize(r,n);break;default:console.warn(t+" is not supported for sphere emitter.")}}(this.emitFrom,this.radius,this.radiusThickness,t.position,t.velocity);break;case eL.Hemisphere:!function(t,e,i,n,r){switch(t){case iL.Volume:uL(n,e*(1-i),e),n.z>0&&(n.z*=-1),ji.normalize(r,n);break;case iL.Shell:lL(n),ji.multiplyScalar(n,n,e),n.z>0&&(n.z*=-1),ji.normalize(r,n);break;default:console.warn(t+" is not supported for hemisphere emitter.")}}(this.emitFrom,this.radius,this.radiusThickness,t.position,t.velocity);break;default:console.warn(this.shapeType+" shapeType is not supported by ShapeModule.")}var e,i,n,r,s;if(this.randomPositionAmount>0&&(t.position.x+=pa(-this.randomPositionAmount,this.randomPositionAmount),t.position.y+=pa(-this.randomPositionAmount,this.randomPositionAmount),t.position.z+=pa(-this.randomPositionAmount,this.randomPositionAmount)),ji.transformQuat(t.velocity,t.velocity,this.quat),ji.transformMat4(t.position,t.position,this.mat),this.sphericalDirectionAmount>0){var a=ji.normalize(Jk,t.position);ji.lerp(t.velocity,t.velocity,a,this.sphericalDirectionAmount)}this.lastTime=this.particleSystem._time},e.constructMat=function(){Ji.fromEuler(this.quat,this._rotation.x,this._rotation.y,this._rotation.z),Ue.fromRTS(this.mat,this.quat,this._position,this._scale)},e.generateArcAngle=function(){if(this.arcMode===nL.Random)return pa(0,this._arc);var t=this.totalAngle+2*Math.PI*this.arcSpeed.evaluate(this.particleSystem._time,1)*(this.particleSystem._time-this.lastTime);switch(this.totalAngle=t,0!==this.arcSpread&&(t=Math.floor(t/(this._arc*this.arcSpread))*this._arc*this.arcSpread),this.arcMode){case nL.Loop:return _a(t,this._arc);case nL.PingPong:return ya(t,this._arc);default:return _a(t,this._arc)}},Pi(t,[{key:"position",get:function(){return this._position},set:function(t){this._position=t,this.constructMat()}},{key:"rotation",get:function(){return this._rotation},set:function(t){this._rotation=t,this.constructMat()}},{key:"scale",get:function(){return this._scale},set:function(t){this._scale=t,this.constructMat()}},{key:"arc",get:function(){return la(this._arc)},set:function(t){this._arc=mr(t)}},{key:"angle",get:function(){return Math.round(100*la(this._angle))/100},set:function(t){this._angle=mr(t)}},{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"shapeType",get:function(){return this._shapeType},set:function(t){switch(this._shapeType=t,this._shapeType){case eL.Box:this.emitFrom===iL.Base&&(this.emitFrom=iL.Volume);break;case eL.Cone:this.emitFrom===iL.Edge&&(this.emitFrom=iL.Base);break;case eL.Sphere:case eL.Hemisphere:this.emitFrom!==iL.Base&&this.emitFrom!==iL.Edge||(this.emitFrom=iL.Volume)}}}]),t}(),Ek=tn(Sk.prototype,"_enable",[en],(function(){return!1})),Ak=tn(Sk.prototype,"_shapeType",[fk,pk],(function(){return eL.Cone})),gn(Sk.prototype,"shapeType",[gk],Object.getOwnPropertyDescriptor(Sk.prototype,"shapeType"),Sk.prototype),Ck=tn(Sk.prototype,"emitFrom",[mk,en],(function(){return iL.Volume})),Rk=tn(Sk.prototype,"alignToDirection",[en],(function(){return!1})),bk=tn(Sk.prototype,"randomDirectionAmount",[en],(function(){return 0})),xk=tn(Sk.prototype,"sphericalDirectionAmount",[en],(function(){return 0})),wk=tn(Sk.prototype,"randomPositionAmount",[en],(function(){return 0})),Mk=tn(Sk.prototype,"radius",[en],(function(){return 1})),Ik=tn(Sk.prototype,"radiusThickness",[en],(function(){return 1})),Bk=tn(Sk.prototype,"arcMode",[vk,en],(function(){return nL.Random})),Pk=tn(Sk.prototype,"arcSpread",[en],(function(){return 0})),Dk=tn(Sk.prototype,"arcSpeed",[yk,en],(function(){return new FO})),Ok=tn(Sk.prototype,"length",[en],(function(){return 5})),Fk=tn(Sk.prototype,"boxThickness",[en],(function(){return new ji(0,0,0)})),Lk=tn(Sk.prototype,"_position",[en],(function(){return new ji(0,0,0)})),Nk=tn(Sk.prototype,"_rotation",[en],(function(){return new ji(0,0,0)})),kk=tn(Sk.prototype,"_scale",[en],(function(){return new ji(1,1,1)})),Uk=tn(Sk.prototype,"_arc",[en],(function(){return mr(360)})),Gk=tn(Sk.prototype,"_angle",[en],(function(){return mr(25)})),Tk=Sk))||Tk);function iU(t,e){e.x>0&&(t[0]+=.5*pa(-e.x,e.x),t[0]=Ge(t[0],-.5,.5)),e.y>0&&(t[1]+=.5*pa(-e.y,e.y),t[1]=Ge(t[1],-.5,.5)),e.z>0&&(t[2]+=.5*pa(-e.z,e.z),t[2]=Ge(t[2],-.5,.5))}var nU,rU,sU,aU,oU,hU,lU,uU,cU,dU,_U,fU,pU,gU,mU,vU,yU,TU,SU,EU,AU,CU,RU=[0,0,1,0,0,1,1,1],bU=[0,0,0,1,0,0,0,1,0,1,1,0],xU=function(t){function e(){var e;return(e=t.call(this)||this)._capacity=void 0,e._vertAttrs=void 0,e._vertAttribSize=void 0,e._vBuffer=void 0,e._vertAttrsFloatCount=void 0,e._vdataF32=void 0,e._vdataUint32=void 0,e._iaInfo=void 0,e._iaInfoBuffer=void 0,e._subMeshData=void 0,e._mesh=void 0,e._vertCount=0,e._indexCount=0,e._startTimeOffset=0,e._lifeTimeOffset=0,e._material=null,e._vertAttribSizeStatic=void 0,e._vertStaticAttrsFloatCount=void 0,e._insBuffers=void 0,e._insIndices=void 0,e._useInstance=void 0,e.type=ii.PARTICLE_BATCH,e._capacity=0,e._vertAttrs=null,e._vertAttribSize=0,e._vBuffer=null,e._vertAttrsFloatCount=0,e._vdataF32=null,e._vdataUint32=null,e._vertAttribSizeStatic=0,e._vertStaticAttrsFloatCount=0,e._insBuffers=[],e._insIndices=null,ke.gfxDevice.hasFeature(d.INSTANCED_ARRAYS)?e._useInstance=!0:e._useInstance=!1,e._iaInfo=new vt([new gt]),e._iaInfoBuffer=e._device.createBuffer(new ft(g.INDIRECT,y.HOST|y.DEVICE,oe,oe)),e._subMeshData=null,e._mesh=null,e}He(e,t);var i=e.prototype;return i.setCapacity=function(t){var e=this._capacity!==t;this._capacity=t,this._subMeshData&&e&&this.rebuild()},i.setVertexAttributes=function(t,e){if(this._useInstance)this.setVertexAttributesIns(t,e);else{if(this._mesh===t&&this._vertAttrs===e)return;this._mesh=t,this._vertAttrs=e,this._vertAttribSize=0;for(var i,n=Fi(this._vertAttrs);!(i=n()).done;){var r=i.value;r.offset=this._vertAttribSize,this._vertAttribSize+=ne[r.format].size}this._vertAttrsFloatCount=this._vertAttribSize/4,this.rebuild()}},i.setVertexAttributesIns=function(t,e){if(this._mesh!==t||this._vertAttrs!==e){this._mesh=t,this._vertAttrs=e,this._vertAttribSize=0,this._vertAttribSizeStatic=0;for(var i,n=Fi(this._vertAttrs);!(i=n()).done;){var r=i.value;0===r.stream?(r.offset=this._vertAttribSize,this._vertAttribSize+=ne[r.format].size):1===r.stream&&(r.offset=this._vertAttribSizeStatic,this._vertAttribSizeStatic+=ne[r.format].size)}this._vertAttrsFloatCount=this._vertAttribSize/4,this._vertStaticAttrsFloatCount=this._vertAttribSizeStatic/4,this.rebuild()}},i.createSubMeshData=function(){this.destroySubMeshData(),this._vertCount=4,this._indexCount=6,this._mesh&&(this._vertCount=this._mesh.struct.vertexBundles[this._mesh.struct.primitives[0].vertexBundelIndices[0]].view.count,this._indexCount=this._mesh.struct.primitives[0].indexView.count);var t=this._device.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.HOST|y.DEVICE,this._vertAttribSize*this._capacity*this._vertCount,this._vertAttribSize)),e=new ArrayBuffer(this._vertAttribSize*this._capacity*this._vertCount);if(this._mesh&&this._capacity>0){var i=this._vertAttrs[this._vertAttrs.findIndex((function(t){return t.name===ie.ATTR_TEX_COORD}))].offset;this._mesh.copyAttribute(0,ie.ATTR_TEX_COORD,e,this._vertAttribSize,i);var n=this._vertAttrs.findIndex((function(t){return t.name===ie.ATTR_TEX_COORD3}));if(i=this._vertAttrs[n++].offset,this._mesh.copyAttribute(0,ie.ATTR_POSITION,e,this._vertAttribSize,i),i=this._vertAttrs[n++].offset,this._mesh.copyAttribute(0,ie.ATTR_NORMAL,e,this._vertAttribSize,i),i=this._vertAttrs[n++].offset,!this._mesh.copyAttribute(0,ie.ATTR_COLOR,e,this._vertAttribSize,i))for(var r=new Uint32Array(e),s=0;s<this._vertCount;++s)r[s*this._vertAttrsFloatCount+i/4]=Ve.WHITE._val;for(var a=new Float32Array(e),o=1;o<this._capacity;o++)a.copyWithin(o*this._vertAttribSize*this._vertCount/4,0,this._vertAttribSize*this._vertCount/4)}t.update(e);var h=new Uint16Array(this._capacity*this._indexCount);if(this._mesh&&this._capacity>0){this._mesh.copyIndices(0,h);for(var l=1;l<this._capacity;l++)for(var u=0;u<this._indexCount;u++)h[l*this._indexCount+u]=h[u]+l*this._vertCount}else for(var c=0,d=0;d<this._capacity;++d){var _=4*d;h[c++]=_,h[c++]=_+1,h[c++]=_+2,h[c++]=_+3,h[c++]=_+2,h[c++]=_+1}var f=this._device.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.DEVICE,this._capacity*this._indexCount*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));return f.update(h),this._iaInfo.drawInfos[0].vertexCount=this._capacity*this._vertCount,this._iaInfo.drawInfos[0].indexCount=this._capacity*this._indexCount,this._iaInfoBuffer||(this._iaInfoBuffer=this._device.createBuffer(new ft(g.INDIRECT,y.HOST|y.DEVICE,oe,oe))),this._iaInfoBuffer.update(this._iaInfo),this._subMeshData=new qi([t],this._vertAttrs,U.TRIANGLE_LIST,f,this._iaInfoBuffer),this.initSubModel(0,this._subMeshData,this._material),e},i.createSubMeshDataInsDynamic=function(){this._insBuffers.length=0,this.destroySubMeshData();var t=this._device.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.HOST|y.DEVICE,this._vertAttribSize*this._capacity,this._vertAttribSize)),e=new ArrayBuffer(this._vertAttribSize*this._capacity);return t.update(e),this._insBuffers.push(t),e},i.createSubMeshDataInsStatic=function(){this._vertCount=4,this._indexCount=6,this._mesh&&(this._vertCount=this._mesh.struct.vertexBundles[this._mesh.struct.primitives[0].vertexBundelIndices[0]].view.count,this._indexCount=this._mesh.struct.primitives[0].indexView.count);var t=this._device.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.HOST|y.DEVICE,this._vertAttribSizeStatic*this._vertCount,this._vertAttribSizeStatic)),e=new ArrayBuffer(this._vertAttribSizeStatic*this._vertCount);if(this._mesh){var i=this._vertAttrs.findIndex((function(t){return t.name===ie.ATTR_TEX_COORD})),n=this._vertAttrs[i].offset;if(this._mesh.copyAttribute(0,ie.ATTR_TEX_COORD,e,this._vertAttribSizeStatic,n),i=this._vertAttrs.findIndex((function(t){return t.name===ie.ATTR_TEX_COORD3})),n=this._vertAttrs[i++].offset,this._mesh.copyAttribute(0,ie.ATTR_POSITION,e,this._vertAttribSizeStatic,n),n=this._vertAttrs[i++].offset,this._mesh.copyAttribute(0,ie.ATTR_NORMAL,e,this._vertAttribSizeStatic,n),n=this._vertAttrs[i++].offset,!this._mesh.copyAttribute(0,ie.ATTR_COLOR,e,this._vertAttribSizeStatic,n))for(var r=new Uint32Array(e),s=0;s<this._vertCount;++s)r[s*this._vertStaticAttrsFloatCount+n/4]=Ve.WHITE._val}else for(var a=new Float32Array(e),o=0;o<bU.length;++o)a[o]=bU[o];t.update(e);var h=new Uint16Array(this._indexCount);this._mesh?this._mesh.copyIndices(0,h):(h[0]=0,h[1]=1,h[2]=2,h[3]=3,h[4]=2,h[5]=1);var l=this._device.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.DEVICE,this._indexCount*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));l.update(h),this._insIndices=l,this._iaInfo.drawInfos[0].vertexCount=this._vertCount,this._iaInfo.drawInfos[0].indexCount=this._indexCount,this._iaInfoBuffer||(this._iaInfoBuffer=this._device.createBuffer(new ft(g.INDIRECT,y.HOST|y.DEVICE,oe,oe))),this._iaInfoBuffer.update(this._iaInfo),this._insBuffers.push(t)},i.createInsSubmesh=function(){this._subMeshData=new qi(this._insBuffers,this._vertAttrs,U.TRIANGLE_LIST,this._insIndices,this._iaInfoBuffer),this.initSubModel(0,this._subMeshData,this._material)},i.updateMaterial=function(t){this._material=t,this.setSubModelMaterial(0,t)},i.addParticleVertexData=function(t,e){if(this._useInstance)this.addParticleVertexDataIns(t,e);else if(this._mesh)for(var i=0;i<this._vertCount;i++){var n=(t*this._vertCount+i)*this._vertAttrsFloatCount;this._vdataF32[n++]=e[0].x,this._vdataF32[n++]=e[0].y,this._vdataF32[n++]=e[0].z,n+=2,this._vdataF32[n++]=e[1].z,this._vdataF32[n++]=e[2].x,this._vdataF32[n++]=e[2].y,this._vdataF32[n++]=e[2].z,this._vdataF32[n++]=e[3].x,this._vdataF32[n++]=e[3].y,this._vdataF32[n++]=e[3].z,this._vdataUint32[n++]=e[4]}else{var r=t*this._vertAttrsFloatCount;this._vdataF32[r++]=e[0].x,this._vdataF32[r++]=e[0].y,this._vdataF32[r++]=e[0].z,this._vdataF32[r++]=e[1].x,this._vdataF32[r++]=e[1].y,this._vdataF32[r++]=e[1].z,this._vdataF32[r++]=e[2].x,this._vdataF32[r++]=e[2].y,this._vdataF32[r++]=e[2].z,this._vdataF32[r++]=e[3].x,this._vdataF32[r++]=e[3].y,this._vdataF32[r++]=e[3].z,this._vdataUint32[r++]=e[4],e[5]&&(this._vdataF32[r++]=e[5].x,this._vdataF32[r++]=e[5].y,this._vdataF32[r++]=e[5].z)}},i.addParticleVertexDataIns=function(t,e){var i=t*this._vertAttrsFloatCount;this._mesh?(this._vdataF32[i++]=e[0].x,this._vdataF32[i++]=e[0].y,this._vdataF32[i++]=e[0].z,this._vdataF32[i++]=e[1].z,this._vdataF32[i++]=e[2].x,this._vdataF32[i++]=e[2].y,this._vdataF32[i++]=e[2].z,this._vdataF32[i++]=e[3].x,this._vdataF32[i++]=e[3].y,this._vdataF32[i++]=e[3].z,this._vdataUint32[i++]=e[4]):(this._vdataF32[i++]=e[0].x,this._vdataF32[i++]=e[0].y,this._vdataF32[i++]=e[0].z,this._vdataF32[i++]=e[1].z,this._vdataF32[i++]=e[2].x,this._vdataF32[i++]=e[2].y,this._vdataF32[i++]=e[2].z,this._vdataF32[i++]=e[3].x,this._vdataF32[i++]=e[3].y,this._vdataF32[i++]=e[3].z,this._vdataUint32[i++]=e[4],e[5]&&(this._vdataF32[i++]=e[5].x,this._vdataF32[i++]=e[5].y,this._vdataF32[i++]=e[5].z))},i.addGPUParticleVertexData=function(t,e,i){if(this._useInstance)this.addGPUParticleVertexDataIns(t,e,i);else for(var n=e*this._vertAttrsFloatCount*this._vertCount,r=0;r<this._vertCount;r++){var s=n;this._vdataF32[s++]=t.position.x,this._vdataF32[s++]=t.position.y,this._vdataF32[s++]=t.position.z,this._vdataF32[s++]=i,this._vdataF32[s++]=t.startSize.x,this._vdataF32[s++]=t.startSize.y,this._vdataF32[s++]=t.startSize.z,this._vdataF32[s++]=RU[2*r],this._vdataF32[s++]=t.rotation.x,this._vdataF32[s++]=t.rotation.y,this._vdataF32[s++]=t.rotation.z,this._vdataF32[s++]=RU[2*r+1],this._vdataF32[s++]=t.startColor.r/255,this._vdataF32[s++]=t.startColor.g/255,this._vdataF32[s++]=t.startColor.b/255,this._vdataF32[s++]=t.startColor.a/255,this._vdataF32[s++]=t.velocity.x,this._vdataF32[s++]=t.velocity.y,this._vdataF32[s++]=t.velocity.z,this._vdataF32[s++]=t.startLifetime,this._vdataF32[s++]=t.randomSeed,n+=this._vertAttrsFloatCount}},i.addGPUParticleVertexDataIns=function(t,e,i){var n=e*this._vertAttrsFloatCount,r=n;this._vdataF32[r++]=t.position.x,this._vdataF32[r++]=t.position.y,this._vdataF32[r++]=t.position.z,this._vdataF32[r++]=i,this._vdataF32[r++]=t.startSize.x,this._vdataF32[r++]=t.startSize.y,this._vdataF32[r++]=t.startSize.z,this._vdataF32[r++]=t.frameIndex,this._vdataF32[r++]=t.rotation.x,this._vdataF32[r++]=t.rotation.y,this._vdataF32[r++]=t.rotation.z,this._vdataF32[r++]=t.startColor.r/255,this._vdataF32[r++]=t.startColor.g/255,this._vdataF32[r++]=t.startColor.b/255,this._vdataF32[r++]=t.startColor.a/255,this._vdataF32[r++]=t.velocity.x,this._vdataF32[r++]=t.velocity.y,this._vdataF32[r++]=t.velocity.z,this._vdataF32[r++]=t.startLifetime,this._vdataF32[r++]=t.randomSeed,n+=this._vertAttrsFloatCount},i.updateGPUParticles=function(t,e,i){if(this._useInstance)return this.updateGPUParticlesIns(t,e,i);for(var n=this._vertAttrsFloatCount*this._vertCount,r=0,s=0,a=0,o=0;o<t;++o)r=o*n,s=this._vdataF32[r+this._startTimeOffset],this._vdataF32[r+this._lifeTimeOffset]-(e-s)<i&&(a=--t*n,this._vdataF32.copyWithin(r,a,a+n),o--);return t},i.updateGPUParticlesIns=function(t,e,i){for(var n=this._vertAttrsFloatCount,r=0,s=0,a=0,o=0;o<t;++o)r=o*n,s=this._vdataF32[r+this._startTimeOffset],this._vdataF32[r+this._lifeTimeOffset]-(e-s)<i&&(a=--t*n,this._vdataF32.copyWithin(r,a,a+n),o--);return t},i.constructAttributeIndex=function(){if(this._vertAttrs){var t=this._vertAttrs.findIndex((function(t){return"a_position_starttime"===t.name})),e=this._vertAttrs[t].offset;this._startTimeOffset=e/4+3,t=this._vertAttrs.findIndex((function(t){return"a_dir_life"===t.name})),e=this._vertAttrs[t].offset,this._lifeTimeOffset=e/4+3}},i.updateIA=function(t){if(this._useInstance)this.updateIAIns(t);else{if(t<=0)return;this._subModels[0].inputAssembler.vertexBuffers[0].update(this._vdataF32),this._iaInfo.drawInfos[0].firstIndex=0,this._iaInfo.drawInfos[0].indexCount=this._indexCount*t,this._iaInfoBuffer.update(this._iaInfo)}},i.updateIAIns=function(t){if(!(t<=0)){var e=this._subModels[0].inputAssembler;e.vertexBuffers[0].update(this._vdataF32),e.instanceCount=t,this._iaInfo.drawInfos[0].firstIndex=0,this._iaInfo.drawInfos[0].indexCount=this._indexCount,this._iaInfo.drawInfos[0].instanceCount=t,this._iaInfoBuffer.update(this._iaInfo)}},i.clear=function(){this._useInstance?this.clearIns():this._subModels[0].inputAssembler.indexCount=0},i.clearIns=function(){this._subModels[0].inputAssembler.instanceCount=0},i.destroy=function(){t.prototype.destroy.call(this),this.doDestroy()},i.doDestroy=function(){this._vBuffer=null,this._vdataF32=null,this._vdataUint32=null,this._insBuffers=[],this._insIndices=null,this._vertAttrs=null,this._material=null,this._mesh=null,this.destroySubMeshData()},i.rebuild=function(){this._useInstance?this.rebuildIns():(this._vBuffer=this.createSubMeshData(),this._vdataF32=new Float32Array(this._vBuffer),this._vdataUint32=new Uint32Array(this._vBuffer))},i.rebuildIns=function(){this._vBuffer=this.createSubMeshDataInsDynamic(),this._vdataF32=new Float32Array(this._vBuffer),this._vdataUint32=new Uint32Array(this._vBuffer),this.createSubMeshDataInsStatic(),this.createInsSubmesh()},i.destroySubMeshData=function(){this._subMeshData&&(this._subMeshData.destroy(),this._subMeshData=null),this._iaInfoBuffer&&(this._iaInfoBuffer=null)},Pi(e,[{key:"useInstance",get:function(){return this._useInstance},set:function(t){this._useInstance!==t&&(this._useInstance=t)}}]),e}(ni),wU=function(){function t(t){this._particleSystem=null,this._model=null,this._renderInfo=null,this._vertAttrs=[],this._useInstance=void 0,this._renderInfo=t,ke.gfxDevice.hasFeature(d.INSTANCED_ARRAYS)?this._useInstance=!0:this._useInstance=!1}var e=t.prototype;return e.getUseInstance=function(){return this._useInstance},e.getInfo=function(){return this._renderInfo},e.onInit=function(t){this._particleSystem=t},e.onEnable=function(){if(this._particleSystem){this.attachToScene();var t=this._model;t&&(t.node=t.transform=this._particleSystem.node)}},e.onDisable=function(){this.detachFromScene()},e.onDestroy=function(){this._model&&(We.director.root.destroyModel(this._model),this._model=null)},e.attachToScene=function(){this._model&&(this._model.scene&&this.detachFromScene(),this._particleSystem._getRenderScene().addModel(this._model))},e.detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},e.setVertexAttributes=function(){this._model&&(this.updateVertexAttrib(),this._model.setVertexAttributes(this._renderInfo.renderMode===tL.Mesh?this._renderInfo.mesh:null,this._vertAttrs))},e.clear=function(){this._model&&(this._model.enabled=!1)},e.getModel=function(){return this._model},e._initModel=function(){this._model||(this._model=We.director.root.createModel(xU),this._model.setCapacity(this._particleSystem.capacity),this._model.visFlags=this._particleSystem.visibility)},e.updateTrailMaterial=function(){},e.getDefaultTrailMaterial=function(){return null},t}(),MU=function(){function t(t){this.permutation=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],this.accSpeed=new ji,this.noiseSpeed=new ji,this.noiseFrequency=0,this.noiseAbs=new ji,this.noiseAmplitude=new ji,this.octaves=new ji,this.dt=0,this.point=new ji,this.result=new ji,this.mixOut=new cn,t&&(this.permutation=t)}var e=t.prototype;return e.noise=function(t,e,i,n,r){void 0===n&&(n=0),void 0===r&&(r=1);for(var s=new Array(512),a=0;a<256;a++)s[256+a]=s[a]=this.permutation[a];var o=255&Math.floor(t),h=255&Math.floor(e),l=255&Math.floor(i);t-=Math.floor(t),e-=Math.floor(e),i-=Math.floor(i);var u=this.fade(t),c=this.fade(e),d=this.fade(i),_=s[o]+h,f=s[_]+l,p=s[_+1]+l,g=s[o+1]+h,m=s[g]+l,v=s[g+1]+l;return n+this.scale(this.lerp(d,this.lerp(c,this.lerp(u,this.grad(s[f],t,e,i),this.grad(s[m],t-1,e,i)),this.lerp(u,this.grad(s[p],t,e-1,i),this.grad(s[v],t-1,e-1,i))),this.lerp(c,this.lerp(u,this.grad(s[f+1],t,e,i-1),this.grad(s[m+1],t-1,e,i-1)),this.lerp(u,this.grad(s[p+1],t,e-1,i-1),this.grad(s[v+1],t-1,e-1,i-1)))))*(r-n)},e.fade=function(t){return t*t*t*(t*(6*t-15)+10)},e.lerp=function(t,e,i){return e+t*(i-e)},e.grad=function(t,e,i,n){var r=15&t,s=r<8?e:i,a=r<4?i:12===r||14===r?e:n;return(0==(1&r)?s:-s)+(0==(2&r)?a:-a)},e.scale=function(t){return(1+t)/2},e.setSpeed=function(t,e,i){this.noiseSpeed.set(t,e,i)},e.setFrequency=function(t){this.noiseFrequency=t},e.setAbs=function(t,e,i){this.noiseAbs.set(t,e,i)},e.setAmplititude=function(t,e,i){this.noiseAmplitude.set(t,e,i)},e.setOctaves=function(t,e,i){this.octaves.set(t,e,i)},e.setTime=function(t){this.dt=t},e.setSamplePoint=function(t){this.point.set(t)},e.getResult=function(){return this.result},e.getNoise=function(t,e,i,n,r,s,a){var o=s,h=0;if(h+=this.noise(t*o,e*o,i*o,-1,1),1===a.x)return h;for(var l=1,u=1,c=1;c<a.x;++c)l*=a.y,o*=a.z,u+=l,h+=this.noise(t*o,e*o,i*o,-1,1)*l;return h/u},e.getNoiseMix=function(t,e,i,n,r,s){t.x=this.getNoise(e.x,e.y,e.z,i,n,r,s),t.y=this.getNoise(e.y,e.z,e.x,i,n,r,s)},e.getNoiseParticle=function(){this.accSpeed.set(this.noiseSpeed.x*this.dt,this.noiseSpeed.y*this.dt,this.noiseSpeed.z*this.dt);var t=this.getNoise(this.point.z+this.accSpeed.x,this.point.y,this.point.x,this.dt,this.accSpeed,this.noiseFrequency,this.octaves),e=this.getNoise(this.point.x+1e3,this.point.z+this.accSpeed.y,this.point.y,this.dt,this.accSpeed,this.noiseFrequency,this.octaves),i=this.getNoise(this.point.y,this.point.x+1e3,this.point.z+this.accSpeed.z,this.dt,this.accSpeed,this.noiseFrequency,this.octaves);this.result.set(t*this.noiseAmplitude.x,e*this.noiseAmplitude.y,i*this.noiseAmplitude.z)},e.getPreview=function(t,e,i){for(var n=0;n<i;++n)for(var r=0;r<e;++r){var s=(r-.5*e)/e+this.noiseSpeed.x*this.dt,a=(n-.5*i)/i+this.noiseSpeed.y*this.dt,o=this.getNoise(s,a,0,this.dt,this.accSpeed,this.noiseFrequency,this.octaves);t[n*e+r]=.5*(o+1)}},t}(),IU=new ji,BU=new Ue,PU=new Ue,DU=new Ji,OU=(new ji,["_colorOverLifetimeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule","_noiseModule"]),FU=[0,0,1,0,0,1,1,1],LU=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RGB32F),new Bt(ie.ATTR_TEX_COORD1,_.RGB32F),new Bt(ie.ATTR_TEX_COORD2,_.RGB32F),new Bt(ie.ATTR_COLOR,_.RGBA8,!0)],NU=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RGB32F),new Bt(ie.ATTR_TEX_COORD1,_.RGB32F),new Bt(ie.ATTR_TEX_COORD2,_.RGB32F),new Bt(ie.ATTR_COLOR,_.RGBA8,!0),new Bt(ie.ATTR_COLOR1,_.RGB32F)],kU=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RGB32F),new Bt(ie.ATTR_TEX_COORD1,_.RGB32F),new Bt(ie.ATTR_TEX_COORD2,_.RGB32F),new Bt(ie.ATTR_COLOR,_.RGBA8,!0),new Bt(ie.ATTR_TEX_COORD3,_.RGB32F),new Bt(ie.ATTR_NORMAL,_.RGB32F),new Bt(ie.ATTR_COLOR1,_.RGBA8,!0)],UU=[new Bt(ie.ATTR_TEX_COORD4,_.RGBA32F,!1,0,!0),new Bt(ie.ATTR_TEX_COORD1,_.RGB32F,!1,0,!0),new Bt(ie.ATTR_TEX_COORD2,_.RGB32F,!1,0,!0),new Bt(ie.ATTR_COLOR,_.RGBA8,!0,0,!0),new Bt(ie.ATTR_TEX_COORD,_.RGB32F,!1,1)],GU=[new Bt(ie.ATTR_TEX_COORD4,_.RGBA32F,!1,0,!0),new Bt(ie.ATTR_TEX_COORD1,_.RGB32F,!1,0,!0),new Bt(ie.ATTR_TEX_COORD2,_.RGB32F,!1,0,!0),new Bt(ie.ATTR_COLOR,_.RGBA8,!0,0,!0),new Bt(ie.ATTR_COLOR1,_.RGB32F,!1,0,!0),new Bt(ie.ATTR_TEX_COORD,_.RGB32F,!1,1)],VU=[new Bt(ie.ATTR_TEX_COORD4,_.RGBA32F,!1,0,!0),new Bt(ie.ATTR_TEX_COORD1,_.RGB32F,!1,0,!0),new Bt(ie.ATTR_TEX_COORD2,_.RGB32F,!1,0,!0),new Bt(ie.ATTR_COLOR,_.RGBA8,!0,0,!0),new Bt(ie.ATTR_TEX_COORD,_.RGB32F,!1,1),new Bt(ie.ATTR_TEX_COORD3,_.RGB32F,!1,1),new Bt(ie.ATTR_NORMAL,_.RGB32F,!1,1),new Bt(ie.ATTR_COLOR1,_.RGBA8,!0,1)],HU={parent:null,owner:null,subModelIdx:0},zU=function(t){function e(e){var i;return(i=t.call(this,e)||this)._defines=void 0,i._trailDefines=void 0,i._frameTile_velLenScale=void 0,i._tmp_velLenScale=void 0,i._defaultMat=null,i._node_scale=void 0,i._attrs=void 0,i._particles=null,i._defaultTrailMat=null,i._updateList=new Map,i._animateList=new Map,i._runAnimateList=new Array,i._fillDataFunc=null,i._uScaleHandle=0,i._uLenHandle=0,i._uNodeRotHandle=0,i._alignSpace=$F.View,i._inited=!1,i._localMat=new Ue,i._gravity=new _n,i.noise=new MU,i._model=null,i._frameTile_velLenScale=new _n(1,1,0,0),i._tmp_velLenScale=i._frameTile_velLenScale.clone(),i._node_scale=new _n,i._attrs=new Array(7),i._defines={CC_USE_WORLD_SPACE:!0,CC_USE_BILLBOARD:!0,CC_USE_STRETCHED_BILLBOARD:!1,CC_USE_HORIZONTAL_BILLBOARD:!1,CC_USE_VERTICAL_BILLBOARD:!1},i._trailDefines={CC_USE_WORLD_SPACE:!0},i}He(e,t);var n=e.prototype;return n.onInit=function(e){var n=this;t.prototype.onInit.call(this,e),this._particles=new i((function(){return new LF(n)}),16),this._setVertexAttrib(),this._setFillFunc(),this._initModuleList(),this._initModel(),this.updateMaterialParams(),this.updateTrailMaterial(),this.setVertexAttributes(),this._inited=!0},n.clear=function(){t.prototype.clear.call(this),this._particles.reset(),this._particleSystem._trailModule&&this._particleSystem._trailModule.clear(),this.updateRenderData(),this._model.enabled=!1},n.updateRenderMode=function(){this._setVertexAttrib(),this._setFillFunc(),this.updateMaterialParams(),this.setVertexAttributes()},n.onDestroy=function(){var e;null===(e=this._particles)||void 0===e||e.destroy(),t.prototype.onDestroy.call(this)},n.getFreeParticle=function(){return this._particles.length>=this._particleSystem.capacity?null:this._particles.add()},n.getDefaultTrailMaterial=function(){return this._defaultTrailMat},n.setNewParticle=function(){},n._initModuleList=function(){var t=this;OU.forEach((function(e){var i=t._particleSystem[e];i&&i.enable&&(i.needUpdate&&(t._updateList[i.name]=i),i.needAnimate&&(t._animateList[i.name]=i))})),this._runAnimateList.length=0;for(var e=0,i=KF.length;e<i;e++){var n=this._animateList[KF[e]];n&&this._runAnimateList.push(n)}},n.enableModule=function(t,e,i){e?(i.needUpdate&&(this._updateList[i.name]=i),i.needAnimate&&(this._animateList[i.name]=i)):(delete this._animateList[t],delete this._updateList[t]),this._runAnimateList.length=0;for(var n=0,r=KF.length;n<r;n++){var s=this._animateList[KF[n]];s&&this._runAnimateList.push(s)}this.updateMaterialParams()},n.updateAlignSpace=function(t){this._alignSpace=t},n.getDefaultMaterial=function(){return this._defaultMat},n.updateRotation=function(t){t&&this.doUpdateRotation(t)},n.doUpdateRotation=function(t){if(this._renderInfo.renderMode===tL.Mesh||this._alignSpace!==$F.View){if(this._alignSpace===$F.Local)this._particleSystem.node.getRotation(DU);else if(this._alignSpace===$F.World)this._particleSystem.node.getWorldRotation(DU);else if(this._alignSpace===$F.View){var e;DU.set(0,0,0,1);var i=null===(e=this._particleSystem.node.scene.renderScene)||void 0===e?void 0:e.cameras;if(void 0!==i)for(var n=0;n<(null==i?void 0:i.length);++n){var r=i[n];if((r.visibility&this._particleSystem.node.layer)===this._particleSystem.node.layer){Ji.fromViewUp(DU,r.forward);break}}}else DU.set(0,0,0,1);t.setUniform(this._uNodeRotHandle,DU)}},n.updateScale=function(t){t&&this.doUpdateScale(t)},n.doUpdateScale=function(t){switch(this._particleSystem.scaleSpace){case QF.Local:this._particleSystem.node.getScale(this._node_scale);break;case QF.World:this._particleSystem.node.getWorldScale(this._node_scale)}t.setUniform(this._uScaleHandle,this._node_scale)},n.updateParticles=function(t){var e=this,i=this._particleSystem;if(!i)return this._particles.length;i.node.getWorldMatrix(BU);var n=(i.getMaterialInstance(0)||this._defaultMat).passes[0];this.doUpdateScale(n),this.doUpdateRotation(n),this._updateList.forEach((function(t){t.update(i._simulationSpace,BU)}));var r=i._trailModule,s=r&&r.enable;if(s&&r.update(),i.simulationSpace===QF.Local){var a=i.node.getRotation();Ue.fromQuat(this._localMat,a),this._localMat.transpose()}if(i.node.parent){var o=i.node.parent.getWorldRotation();Ue.fromQuat(PU,o),PU.transpose()}for(var h=function(n){var a=e._particles.data[n];if(a.remainingLifetime-=t,ji.set(a.animatedVelocity,0,0,0),a.remainingLifetime<0)return s&&r.removeParticle(a),e._particles.removeAt(n),--n,l=n,"continue";if(i.gravityModifier.mode!==OO.Constant||0!==i.gravityModifier.constant){var o=fL(i.gravityModifier)?va(a.randomSeed):0;if(i.simulationSpace===QF.Local){var h=1-a.remainingLifetime/a.startLifetime,u=9.8*-i.gravityModifier.evaluate(h,o)*t;e._gravity.x=0,e._gravity.y=u,e._gravity.z=0,e._gravity.w=1,wn(u,0,Mn)||(i.node.parent&&(e._gravity=e._gravity.transformMat4(PU)),e._gravity=e._gravity.transformMat4(e._localMat),a.velocity.x+=e._gravity.x,a.velocity.y+=e._gravity.y,a.velocity.z+=e._gravity.z)}else a.velocity.y-=9.8*i.gravityModifier.evaluate(1-a.remainingLifetime/a.startLifetime,o)*t}ji.copy(a.ultimateVelocity,a.velocity),e._runAnimateList.forEach((function(e){e.animate(a,t)})),ji.scaleAndAdd(a.position,a.position,a.ultimateVelocity,t),s&&r.animate(a,t),l=n},l=0;l<this._particles.length;++l)h(l);return this._model.enabled=this._particles.length>0,this._particles.length},n.getNoisePreview=function(t,e,i){var n=this;this._runAnimateList.forEach((function(r){r.name===jF&&r.getNoisePreview(t,n._particleSystem,e,i)}))},n.updateRenderData=function(){for(var t=0,e=0;e<this._particles.length;++e){var i=this._particles.data[e],n=0,r=this._particleSystem._textureAnimationModule;r&&r.enable&&(n=i.frameIndex),t=4*e,this._fillDataFunc(i,t,n)}},n.beforeRender=function(){this._model.updateIA(this._particles.length)},n.getParticleCount=function(){return this._particles.length},n.onMaterialModified=function(t){this._inited&&(0===t?this.updateMaterialParams():this.updateTrailMaterial())},n.onRebuildPSO=function(t,e){this._model&&0===t&&this._model.setSubModelMaterial(0,e);var i=this._particleSystem._trailModule;i&&i._trailModel&&1===t&&i._trailModel.setSubModelMaterial(0,e)},n._setFillFunc=function(){this._renderInfo.renderMode===tL.Mesh?this._fillDataFunc=this._fillMeshData:this._renderInfo.renderMode===tL.StrecthedBillboard?this._fillDataFunc=this._fillStrecthedData:this._fillDataFunc=this._fillNormalData},n._fillMeshData=function(t,e,i){var n=e/4;this._attrs[0]=t.position,IU.z=i,this._attrs[1]=IU,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._model.addParticleVertexData(n,this._attrs)},n._fillStrecthedData=function(t,e,i){if(this._useInstance)this._fillStrecthedDataIns(t,e,i);else for(var n=0;n<4;++n)this._attrs[0]=t.position,IU.x=FU[2*n],IU.y=FU[2*n+1],IU.z=i,this._attrs[1]=IU,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._attrs[5]=t.ultimateVelocity,this._attrs[6]=null,this._model.addParticleVertexData(e++,this._attrs)},n._fillStrecthedDataIns=function(t,e,i){var n=e/4;this._attrs[0]=t.position,IU.z=i,this._attrs[1]=IU,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._attrs[5]=t.ultimateVelocity,this._model.addParticleVertexData(n,this._attrs)},n._fillNormalData=function(t,e,i){if(this._useInstance)this._fillNormalDataIns(t,e,i);else for(var n=0;n<4;++n)this._attrs[0]=t.position,IU.x=FU[2*n],IU.y=FU[2*n+1],IU.z=i,this._attrs[1]=IU,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._attrs[5]=null,this._model.addParticleVertexData(e++,this._attrs)},n._fillNormalDataIns=function(t,e,i){var n=e/4;this._attrs[0]=t.position,IU.z=i,this._attrs[1]=IU,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._attrs[5]=null,this._model.addParticleVertexData(n,this._attrs)},n.updateVertexAttrib=function(){if(this._renderInfo.renderMode===tL.Mesh&&this._renderInfo.mesh){var t=this._renderInfo.mesh.readAttributeFormat(0,ie.ATTR_COLOR);if(t){for(var e=_.RGBA8,i=0;i<ne.length;++i)if(ne[i].name===t.name){e=i;break}this._vertAttrs[7]=new Bt(ie.ATTR_COLOR1,e,!0,this._useInstance?1:0)}else{var n=_.RGBA8;this._vertAttrs[7]=new Bt(ie.ATTR_COLOR1,n,!0,this._useInstance?1:0)}}},n._setVertexAttrib=function(){if(this._useInstance)this._setVertexAttribIns();else switch(this._renderInfo.renderMode){case tL.StrecthedBillboard:this._vertAttrs=NU.slice();break;case tL.Mesh:this._vertAttrs=kU.slice();break;default:this._vertAttrs=LU.slice()}},n._setVertexAttribIns=function(){switch(this._renderInfo.renderMode){case tL.StrecthedBillboard:this._vertAttrs=GU.slice();break;case tL.Mesh:this._vertAttrs=VU.slice();break;default:this._vertAttrs=UU.slice()}},n.updateMaterialParams=function(){if(this._particleSystem){var t=this._particleSystem,e=t.sharedMaterial;null!=e&&(e._effectAsset._name,this._renderInfo.mainTexture=e.getProperty("mainTexture",0)),null==t.sharedMaterial&&null==this._defaultMat&&(HU.parent=Nn.get("default-particle-material"),HU.owner=this._particleSystem,HU.subModelIdx=0,this._defaultMat=new On(HU),HU.parent=null,HU.owner=null,HU.subModelIdx=0,null!==this._renderInfo.mainTexture&&this._defaultMat.setProperty("mainTexture",this._renderInfo.mainTexture));var i=t.getMaterialInstance(0)||this._defaultMat;t._simulationSpace===QF.World?this._defines.CC_USE_WORLD_SPACE=!0:this._defines.CC_USE_WORLD_SPACE=!1;var n=i.passes[0];this._uScaleHandle=n.getHandle("scale"),this._uLenHandle=n.getHandle("frameTile_velLenScale"),this._uNodeRotHandle=n.getHandle("nodeRotation");var r=this._renderInfo.renderMode,s=this._frameTile_velLenScale;r===tL.Billboard?this._defines.CC_RENDER_MODE=0:r===tL.StrecthedBillboard?(this._defines.CC_RENDER_MODE=1,s.z=this._renderInfo.velocityScale,s.w=this._renderInfo.lengthScale):r===tL.HorizontalBillboard?this._defines.CC_RENDER_MODE=2:r===tL.VerticalBillboard?this._defines.CC_RENDER_MODE=3:r===tL.Mesh?this._defines.CC_RENDER_MODE=4:console.warn("particle system renderMode "+r+" not support.");var a=t._textureAnimationModule;a&&a.enable?(_n.copy(this._tmp_velLenScale,s),cn.set(this._tmp_velLenScale,a.numTilesX,a.numTilesY),n.setUniform(this._uLenHandle,this._tmp_velLenScale)):n.setUniform(this._uLenHandle,s);var o,h=this._particleSystem._rotationOvertimeModule;o=!!h&&h.enable,this._defines.ROTATION_OVER_TIME_MODULE_ENABLE=o,this._defines.CC_INSTANCE_PARTICLE=this._useInstance,i.recompileShaders(this._defines),this._model&&this._model.updateMaterial(i)}},n.updateTrailMaterial=function(){if(this._particleSystem){var t=this._particleSystem,e=t._trailModule;if(e&&e.enable){t.simulationSpace===QF.World||e.space===QF.World?this._trailDefines.CC_USE_WORLD_SPACE=!0:this._trailDefines.CC_USE_WORLD_SPACE=!1;var i=t.getMaterialInstance(1);null===i&&null===this._defaultTrailMat&&(HU.parent=Nn.get("default-trail-material"),HU.owner=this._particleSystem,HU.subModelIdx=1,this._defaultTrailMat=new On(HU),HU.parent=null,HU.owner=null,HU.subModelIdx=0),(i=i||this._defaultTrailMat).recompileShaders(this._trailDefines),e.updateMaterial()}}},n.setUseInstance=function(t){this._useInstance!==t&&(this._useInstance=t,this._model&&(this._model.useInstance=t,this._model.doDestroy()),this.updateRenderMode())},e}(wU),XU=new Ue,WU=new _n,YU=new Ji,jU=new Ji,KU=(new ji,32),qU="a_position_starttime",ZU="a_size_uv",QU="a_rotation_uv",JU="a_color",$U="a_dir_life",tG="a_rndSeed",eG="a_size_fid",iG="a_rotation",nG=[new Bt(qU,_.RGBA32F),new Bt(ZU,_.RGBA32F),new Bt(QU,_.RGBA32F),new Bt(JU,_.RGBA32F),new Bt($U,_.RGBA32F),new Bt(tG,_.R32F)],rG=[new Bt(qU,_.RGBA32F),new Bt(ZU,_.RGBA32F),new Bt(QU,_.RGBA32F),new Bt(JU,_.RGBA32F),new Bt($U,_.RGBA32F),new Bt(tG,_.R32F),new Bt(ie.ATTR_TEX_COORD,_.RGB32F),new Bt(ie.ATTR_TEX_COORD3,_.RGB32F),new Bt(ie.ATTR_NORMAL,_.RGB32F),new Bt(ie.ATTR_COLOR1,_.RGBA8,!0)],sG=[new Bt(qU,_.RGBA32F,!1,0,!0),new Bt(eG,_.RGBA32F,!1,0,!0),new Bt(iG,_.RGB32F,!1,0,!0),new Bt(JU,_.RGBA32F,!1,0,!0),new Bt($U,_.RGBA32F,!1,0,!0),new Bt(tG,_.R32F,!1,0,!0),new Bt("a_uv",_.RGB32F,!1,1)],aG=[new Bt(qU,_.RGBA32F,!1,0,!0),new Bt(eG,_.RGBA32F,!1,0,!0),new Bt(iG,_.RGB32F,!1,0,!0),new Bt(JU,_.RGBA32F,!1,0,!0),new Bt($U,_.RGBA32F,!1,0,!0),new Bt(tG,_.R32F,!1,0,!0),new Bt(ie.ATTR_TEX_COORD,_.RGB32F,!1,1),new Bt(ie.ATTR_TEX_COORD3,_.RGB32F,!1,1),new Bt(ie.ATTR_NORMAL,_.RGB32F,!1,1),new Bt(ie.ATTR_COLOR1,_.RGBA8,!0,1)],oG={parent:null,owner:null,subModelIdx:0},hG=function(t){function e(e){var i;return(i=t.call(this,e)||this)._defines=void 0,i._frameTile_velLenScale=void 0,i._unifrom_velLenScale=void 0,i._tmp_velLenScale=void 0,i._node_scale=void 0,i._vertAttrs=[],i._defaultMat=null,i._particleNum=0,i._tempParticle=null,i._colorTexture=null,i._forceTexture=null,i._velocityTexture=null,i._rotationTexture=null,i._sizeTexture=null,i._animTexture=null,i._colorData=null,i._forceData=null,i._velocityData=null,i._rotationData=null,i._sizeData=null,i._animData=null,i._uTimeHandle=0,i._uRotHandle=0,i._uNodeRotHandle=0,i._alignSpace=$F.View,i._inited=!1,i._frameTile_velLenScale=new _n(1,1,0,0),i._unifrom_velLenScale=i._frameTile_velLenScale.clone(),i._tmp_velLenScale=i._frameTile_velLenScale.clone(),i._node_scale=new _n,i._defines={CC_USE_WORLD_SPACE:!0,CC_USE_BILLBOARD:!0,CC_USE_STRETCHED_BILLBOARD:!1,CC_USE_HORIZONTAL_BILLBOARD:!1,CC_USE_VERTICAL_BILLBOARD:!1,COLOR_OVER_TIME_MODULE_ENABLE:!1},i._tempParticle=new LF(null),i._particleNum=0,i}He(e,t);var i=e.prototype;return i.onInit=function(e){t.prototype.onInit.call(this,e),this._setVertexAttrib(),this._initModel(),this.updateMaterialParams(),this.setVertexAttributes(),this._inited=!0},i.updateRenderMode=function(){this._setVertexAttrib(),this.updateMaterialParams(),this.setVertexAttributes()},i.setVertexAttributes=function(){t.prototype.setVertexAttributes.call(this),this._model.constructAttributeIndex()},i.clear=function(){t.prototype.clear.call(this),this._particleNum=0,this.updateRenderData()},i.onDestroy=function(){t.prototype.onDestroy.call(this),this._forceTexture&&this._forceTexture.destroy(),this._velocityTexture&&this._velocityTexture.destroy(),this._colorTexture&&this._colorTexture.destroy(),this._sizeTexture&&this._sizeTexture.destroy(),this._rotationTexture&&this._rotationTexture.destroy(),this._animTexture&&this._animTexture.destroy(),this._forceData=null,this._velocityData=null,this._colorData=null,this._sizeData=null,this._rotationData=null,this._animData=null},i.enableModule=function(){var t=this._particleSystem.getMaterialInstance(0)||this._defaultMat;t&&(this.initShaderUniform(t),t.recompileShaders(this._defines),this._model&&this._model.setSubModelMaterial(0,t))},i.getFreeParticle=function(){return this._particleNum>=this._particleSystem._capacity?null:this._tempParticle},i.setNewParticle=function(t){this._model.addGPUParticleVertexData(t,this._particleNum,this._particleSystem._time),this._particleNum++},i.getDefaultMaterial=function(){return this._defaultMat},i.updateRotation=function(t){t&&this.doUpdateRotation(t)},i.doUpdateRotation=function(t){if(this._renderInfo.renderMode===tL.Mesh||this._alignSpace!==$F.View){if(this._alignSpace===$F.Local)this._particleSystem.node.getRotation(jU);else if(this._alignSpace===$F.World)this._particleSystem.node.getWorldRotation(jU);else if(this._alignSpace===$F.View){var e;jU.set(0,0,0,1);var i=null===(e=this._particleSystem.node.scene.renderScene)||void 0===e?void 0:e.cameras;if(void 0!==i)for(var n=0;n<(null==i?void 0:i.length);++n){var r=i[n];if((r.visibility&this._particleSystem.node.layer)===this._particleSystem.node.layer){Ji.fromViewUp(jU,r.forward);break}}}else jU.set(0,0,0,1);t.setUniform(this._uNodeRotHandle,jU)}},i.updateScale=function(t){t&&this.doUpdateScale(t)},i.doUpdateScale=function(t){switch(this._particleSystem.scaleSpace){case QF.Local:this._particleSystem.node.getScale(this._node_scale);break;case QF.World:this._particleSystem.node.getWorldScale(this._node_scale)}t.setUniform(t.getHandle("scale"),this._node_scale)},i.updateParticles=function(t){return this._particleNum=this._model.updateGPUParticles(this._particleNum,this._particleSystem._time,t),this.updateShaderUniform(t),this._model.enabled=this._particleNum>0,this._particleNum},i.updateRenderData=function(){},i.beforeRender=function(){this._model.updateIA(this._particleNum)},i.updateAlignSpace=function(t){this._alignSpace=t},i.updateShaderUniform=function(t){var e=this._particleSystem.getMaterialInstance(0)||this._defaultMat;if(e){var i=e.passes[0];WU.x=this._particleSystem._time,WU.y=t,i.setUniform(this._uTimeHandle,WU),this._particleSystem.node.getWorldRotation(YU),i.setUniform(this._uRotHandle,YU),this.doUpdateRotation(i)}},i.initShaderUniform=function(t){var e=t.passes[0];this._uTimeHandle=e.getHandle("u_timeDelta"),this._uRotHandle=e.getHandle("u_worldRot"),this._uNodeRotHandle=e.getHandle("nodeRotation"),this.doUpdateScale(e),e.setUniform(e.getHandle("frameTile_velLenScale"),this._unifrom_velLenScale),WU.x=KU,WU.y=.03125,e.setUniform(e.getHandle("u_sampleInfo"),WU);var i=!1,n=this._particleSystem._forceOvertimeModule;if(i=!!n&&n.enable,this._defines.FORCE_OVER_TIME_MODULE_ENABLE=i,i){var r=UO(this._forceTexture,this._forceData,KU,n.x,n.y,n.z);this._forceTexture=r.texture,this._forceData=r.texdata;var s=e.getHandle("force_over_time_tex0"),a=Wn.getBindingFromHandle(s);e.bindSampler(a,this._forceTexture.getGFXSampler()),e.bindTexture(a,this._forceTexture.getGFXTexture());var o=e.getHandle("u_force_space");e.setUniform(o,n.space);var h=e.getHandle("u_force_mode");e.setUniform(h,this._forceTexture.height)}var l=this._particleSystem._velocityOvertimeModule;if(i=!!l&&l.enable,this._defines.VELOCITY_OVER_TIME_MODULE_ENABLE=i,i){var c=function(t,e,i,n,r,s,a){var o=Math.max(NO(n),NO(r),NO(s),NO(a)),h=i*o*4;null!==e&&e.length===h||(e=new Float32Array(i*o*4));for(var l=[n,r,s,a],u=1/(i-1),c=0;c<o;c++)for(var d=0;d<4;d++)for(var _=l[d],f=0,p=0,g=0;g<i;g++){var m=LO(_,u*g,c);p=(f+=m)/(g+1),e[4*(c*i+g)+d]=p}return{texture:kO(t,e,i,o),texdata:e}}(this._velocityTexture,this._velocityData,KU,l.x,l.y,l.z,l.speedModifier);this._velocityTexture=c.texture,this._velocityData=c.texdata;var d=e.getHandle("velocity_over_time_tex0"),_=Wn.getBindingFromHandle(d);e.bindSampler(_,this._velocityTexture.getGFXSampler()),e.bindTexture(_,this._velocityTexture.getGFXTexture());var f=e.getHandle("u_velocity_space");e.setUniform(f,l.space);var p=e.getHandle("u_velocity_mode");e.setUniform(p,this._velocityTexture.height)}var g=this._particleSystem._colorOverLifetimeModule;if(i=!!g&&g.enable,this._defines.COLOR_OVER_TIME_MODULE_ENABLE=i,i){var m=function(t,e,i,n){var r=function(t){switch(t.mode){case IF.TwoColors:case IF.TwoGradients:return 2;default:return 1}}(n),s=i*r*4;null!==e&&e.length===s||(e=new Uint8Array(i*r*4));for(var a=1/i,o=0,h=0;h<r;h++)for(var l=0;l<i;l++){var u=PF(n,a*l,h);e[o]=u.r,e[o+1]=u.g,e[o+2]=u.b,e[o+3]=u.a,o+=4}return null!==t&&i===t.width&&r===t.height||(t&&t.destroy(),(t=new Xe).create(i,r,ze.RGBA8888),t.setFilters(Ii.LINEAR,Ii.LINEAR),t.setWrapMode(Nr.CLAMP_TO_EDGE,Nr.CLAMP_TO_EDGE)),t.uploadData(e),{texture:t,texdata:e}}(this._colorTexture,this._colorData,KU,g.color);this._colorTexture=m.texture,this._colorData=m.texdata;var v=e.getHandle("color_over_time_tex0"),y=Wn.getBindingFromHandle(v);e.bindSampler(y,this._colorTexture.getGFXSampler()),e.bindTexture(y,this._colorTexture.getGFXTexture());var T=e.getHandle("u_color_mode");e.setUniform(T,this._colorTexture.height)}var S,E=this._particleSystem._rotationOvertimeModule;if(i=!!E&&E.enable,this._defines.ROTATION_OVER_TIME_MODULE_ENABLE=i,i&&(S=E.separateAxes?UO(this._rotationTexture,this._rotationData,KU,E.x,E.y,E.z):function(t,e,i,n){var r=NO(n),s=i*r*4;null!==e&&e.length===s||(e=new Float32Array(i*r*4));for(var a=1/(i-1),o=0,h=0;h<r;h++)for(var l=0;l<i;l++){var u=LO(n,a*l,h);e[o+2]=u,o+=4}return{texture:kO(t,e,i,r),texdata:e}}(this._rotationTexture,this._rotationData,KU,E.z),this._rotationTexture=S.texture,this._rotationData=S.texdata,this._rotationTexture)){var A=e.getHandle("rotation_over_time_tex0"),C=Wn.getBindingFromHandle(A);e.bindSampler(C,this._rotationTexture.getGFXSampler()),e.bindTexture(C,this._rotationTexture.getGFXTexture());var R=e.getHandle("u_rotation_mode");e.setUniform(R,this._rotationTexture.height)}var b,x=this._particleSystem._sizeOvertimeModule;if(i=!!x&&x.enable,this._defines.SIZE_OVER_TIME_MODULE_ENABLE=i,i&&(b=x.separateAxes?UO(this._sizeTexture,this._sizeData,KU,x.x,x.y,x.z,!0):function(t,e,i,n){var r=NO(n),s=i*r*4;null!==e&&e.length===s||(e=new Float32Array(i*r*4));for(var a=1/(i-1),o=0,h=0,l=0;l<r;l++){0;for(var u=0;u<i;u++){var c=LO(n,a*u,l);o=c,e[h]=o,e[h+1]=o,e[h+2]=o,h+=4}}return{texture:kO(t,e,i,r),texdata:e}}(this._sizeTexture,this._sizeData,KU,x.size),this._sizeTexture=b.texture,this._sizeData=b.texdata,this._sizeTexture)){var w=e.getHandle("size_over_time_tex0"),M=Wn.getBindingFromHandle(w);e.bindSampler(M,this._sizeTexture.getGFXSampler()),e.bindTexture(M,this._sizeTexture.getGFXTexture());var I=e.getHandle("u_size_mode");e.setUniform(I,this._sizeTexture.height)}var B=this._particleSystem._textureAnimationModule;if(i=!!B&&B.enable,this._defines.TEXTURE_ANIMATION_MODULE_ENABLE=i,i){var P=function(t,e,i,n,r){var s=Math.max(NO(n),NO(r)),a=i*s*4;null!==e&&e.length===a||(e=new Float32Array(i*s*4));for(var o=[n,r],h=1/(i-1),l=0;l<s;l++)for(var u=0;u<2;u++)for(var c=o[u],d=0,_=0;_<i;_++){var f=LO(c,h*_,l);d=f,e[4*(l*i+_)+u]=d}return{texture:kO(t,e,i,s),texdata:e}}(this._animTexture,this._animData,KU,B.startFrame,B.frameOverTime);this._animTexture=P.texture,this._animData=P.texdata;var D=e.getHandle("texture_animation_tex0"),O=Wn.getBindingFromHandle(D);e.bindSampler(O,this._animTexture.getGFXSampler()),e.bindTexture(O,this._animTexture.getGFXTexture());var F=e.getHandle("u_anim_info");WU.x=this._animTexture.height,WU.y=B.numTilesX*B.numTilesY,WU.z=B.cycleCount,e.setUniform(F,WU)}this._defines.USE_VK_SHADER=ke.gfxDevice.gfxAPI===u.VULKAN,this._defines.CC_INSTANCE_PARTICLE=this._useInstance},i.getParticleCount=function(){return this._particleNum},i.onMaterialModified=function(){this._inited&&this.updateMaterialParams()},i.onRebuildPSO=function(t,e){this._model&&0===t&&this._model.setSubModelMaterial(0,e)},i.updateVertexAttrib=function(){if(this._renderInfo.renderMode===tL.Mesh&&this._renderInfo.mesh){var t=this._renderInfo.mesh.readAttributeFormat(0,ie.ATTR_COLOR);if(t){for(var e=_.RGBA8,i=0;i<ne.length;++i)if(ne[i].name===t.name){e=i;break}this._vertAttrs[9]=new Bt(ie.ATTR_COLOR1,e,!0,this._useInstance?1:0)}else{var n=_.RGBA8;this._vertAttrs[9]=new Bt(ie.ATTR_COLOR1,n,!0,this._useInstance?1:0)}}},i._setVertexAttrib=function(){if(this._useInstance)this._setVertexAttribIns();else switch(this._renderInfo.renderMode){case tL.StrecthedBillboard:this._vertAttrs=nG.slice();break;case tL.Mesh:this._vertAttrs=rG.slice();break;default:this._vertAttrs=nG.slice()}},i._setVertexAttribIns=function(){switch(this._renderInfo.renderMode){case tL.StrecthedBillboard:this._vertAttrs=sG.slice();break;case tL.Mesh:this._vertAttrs=aG.slice();break;default:this._vertAttrs=sG.slice()}},i.updateMaterialParams=function(){if(this._particleSystem){var t=this._particleSystem,e=t.sharedMaterial;null!==e&&(e._effectAsset._name,this._renderInfo.mainTexture=e.getProperty("mainTexture",0)),null==t.sharedMaterial&&null==this._defaultMat&&(oG.parent=Nn.get("default-particle-gpu-material"),oG.owner=t,oG.subModelIdx=0,this._defaultMat=new On(oG),oG.parent=null,oG.owner=null,oG.subModelIdx=0,null!==this._renderInfo.mainTexture&&this._defaultMat.setProperty("mainTexture",this._renderInfo.mainTexture));var i=t.getMaterialInstance(0)||this._defaultMat;t.node.getWorldMatrix(XU),t._simulationSpace===QF.World?this._defines.CC_USE_WORLD_SPACE=!0:this._defines.CC_USE_WORLD_SPACE=!1;var n=this._renderInfo.renderMode;n===tL.Billboard?this._defines.CC_RENDER_MODE=0:n===tL.StrecthedBillboard?(this._defines.CC_RENDER_MODE=1,this._frameTile_velLenScale.z=this._renderInfo.velocityScale,this._frameTile_velLenScale.w=this._renderInfo.lengthScale):n===tL.HorizontalBillboard?this._defines.CC_RENDER_MODE=2:n===tL.VerticalBillboard?this._defines.CC_RENDER_MODE=3:n===tL.Mesh?this._defines.CC_RENDER_MODE=4:console.warn("particle system renderMode "+n+" not support.");var r=t._textureAnimationModule;r&&r.enable?(cn.set(this._frameTile_velLenScale,r.numTilesX,r.numTilesY),_n.copy(this._unifrom_velLenScale,this._frameTile_velLenScale)):(this._tmp_velLenScale.z=this._frameTile_velLenScale.z,this._tmp_velLenScale.w=this._frameTile_velLenScale.w,_n.copy(this._unifrom_velLenScale,this._tmp_velLenScale)),this.initShaderUniform(i),i.recompileShaders(this._defines),this._model&&this._model.updateMaterial(i)}},i.setUseInstance=function(t){this._useInstance!==t&&(this._useInstance=t,this._model&&(this._model.useInstance=t,this._model.doDestroy()),this.updateRenderMode())},i.getNoisePreview=function(){},e}(wU);function lG(){var t=Di.root.device;return!!(t.capabilities.maxVertexTextureUnits>=8&&t.getFormatFeatures(_.RGBA32F)&(A.RENDER_TARGET|A.SAMPLED_TEXTURE))||(We.warn("Maybe the device has restrictions on vertex textures or does not support float textures."),!1)}var uG,cG,dG,_G,fG,pG,gG,mG,vG,yG,TG,SG,EG,AG,CG,RG,bG,xG,wG,MG,IG,BG,PG,DG,OG,FG,LG,NG,kG,UG,GG,VG,HG,zG,XG,WG,YG,jG,KG,qG,ZG,QG,JG,$G,tV,eV,iV,nV,rV,sV,aV,oV,hV,lV,uV,cV,dV,_V,fV,pV,gV,mV,vV,yV,TV,SV,EV,AV,CV,RV,bV,xV,wV,MV,IV,BV,PV,DV,OV,FV,LV,NV,kV,UV,GV,VV,HV,zV,XV,WV,YV,jV,KV,qV,ZV,QV,JV,$V,tH,eH,iH,nH,rH,sH,aH,oH,hH,lH,uH,cH,dH,_H,fH,pH,gH,mH,vH,yH,TH,SH,EH,AH,CH,RH,bH,xH,wH,MH,IH,BH,PH,DH,OH,FH,LH,NH,kH,UH,GH,VH,HH,zH,XH,WH,YH,jH,KH,qH,ZH,QH,JH,$H,tz,ez,iz=(nU=Ki("cc.ParticleSystemRenderer"),rU=Tn(tL),sU=Tn(tL),aU=Tn(mo),oU=Tn(Dn),hU=Tn(Dn),lU=Tn(Dn),uU=Tn(Dn),cU=Tn($F),nU((CU=AU=function(){function t(){this._renderMode=fU&&fU(),this._velocityScale=pU&&pU(),this._lengthScale=gU&&gU(),this._mesh=mU&&mU(),this._cpuMaterial=vU&&vU(),this._gpuMaterial=yU&&yU(),this._mainTexture=TU&&TU(),this._useGPU=SU&&SU(),this._alignSpace=EU&&EU(),this._particleSystem=null}var e=t.prototype;return e.create=function(t){null===this._particleSystem?this._particleSystem=t:this._particleSystem!==t&&hn(6033)},e.onInit=function(t){this.create(t);var e=this._useGPU&&lG();this._particleSystem.processor?hn(6034):(this._particleSystem.processor=e?new hG(this):new zU(this),this._particleSystem.processor.updateAlignSpace(this.alignSpace),this._particleSystem.processor.onInit(t)),e?this.gpuMaterial=this.particleMaterial:(this.particleMaterial&&-1!==this.particleMaterial.effectName.indexOf("particle-gpu")&&(this.particleMaterial=null,Zi(6035)),this.cpuMaterial=this.particleMaterial)},e._switchProcessor=function(){if(this._particleSystem){this._particleSystem.processor&&(this._particleSystem.processor.detachFromScene(),this._particleSystem.processor.clear(),this._particleSystem.processor=null);var t=this._useGPU&&lG();!t&&this.cpuMaterial&&(this.particleMaterial=this.cpuMaterial),t&&this.gpuMaterial&&(this.particleMaterial=this.gpuMaterial),this._particleSystem.processor=t?new hG(this):new zU(this),this._particleSystem.processor.updateAlignSpace(this.alignSpace),this._particleSystem.processor.onInit(this._particleSystem),this._particleSystem.processor.onEnable(),this._particleSystem.bindModule()}},Pi(t,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){this._renderMode!==t&&(this._renderMode=t,this._particleSystem&&this._particleSystem.processor.updateRenderMode())}},{key:"velocityScale",get:function(){return this._velocityScale},set:function(t){this._velocityScale=t,this._particleSystem&&this._particleSystem.processor.updateMaterialParams()}},{key:"lengthScale",get:function(){return this._lengthScale},set:function(t){this._lengthScale=t,this._particleSystem&&this._particleSystem.processor.updateMaterialParams()}},{key:"mesh",get:function(){return this._mesh},set:function(t){this._mesh=t,this._particleSystem&&this._particleSystem.processor.setVertexAttributes()}},{key:"particleMaterial",get:function(){return this._particleSystem?this._particleSystem.getMaterial(0):null},set:function(t){this._particleSystem&&this._particleSystem.setMaterial(t,0)}},{key:"cpuMaterial",get:function(){return this._cpuMaterial},set:function(t){if(null!==t){var e=t.effectName;-1!==e.indexOf("particle")&&-1===e.indexOf("particle-gpu")?(this._cpuMaterial=t,this.particleMaterial=this._cpuMaterial):Zi(6035)}}},{key:"gpuMaterial",get:function(){return this._gpuMaterial},set:function(t){null!==t&&(-1!==t.effectName.indexOf("particle-gpu")?(this._gpuMaterial=t,this.particleMaterial=this._gpuMaterial):Zi(6035))}},{key:"trailMaterial",get:function(){return this._particleSystem?this._particleSystem.getMaterial(1):null},set:function(t){this._particleSystem&&this._particleSystem.setMaterial(t,1)}},{key:"mainTexture",get:function(){return this._mainTexture},set:function(t){this._mainTexture=t}},{key:"useGPU",get:function(){return this._useGPU},set:function(t){this._useGPU!==t&&(lG()?this._useGPU=t:this._useGPU=!1,this._switchProcessor())}},{key:"alignSpace",get:function(){return this._alignSpace},set:function(t){this._alignSpace=t,this._particleSystem.processor.updateAlignSpace(this._alignSpace)}}]),t}(),AU.AlignmentSpace=$F,gn((_U=CU).prototype,"renderMode",[rU],Object.getOwnPropertyDescriptor(_U.prototype,"renderMode"),_U.prototype),fU=tn(_U.prototype,"_renderMode",[sU,en],(function(){return tL.Billboard})),pU=tn(_U.prototype,"_velocityScale",[en],(function(){return 1})),gU=tn(_U.prototype,"_lengthScale",[en],(function(){return 1})),mU=tn(_U.prototype,"_mesh",[en],(function(){return null})),gn(_U.prototype,"mesh",[aU],Object.getOwnPropertyDescriptor(_U.prototype,"mesh"),_U.prototype),gn(_U.prototype,"particleMaterial",[oU],Object.getOwnPropertyDescriptor(_U.prototype,"particleMaterial"),_U.prototype),gn(_U.prototype,"cpuMaterial",[hU],Object.getOwnPropertyDescriptor(_U.prototype,"cpuMaterial"),_U.prototype),vU=tn(_U.prototype,"_cpuMaterial",[en],(function(){return null})),gn(_U.prototype,"gpuMaterial",[lU],Object.getOwnPropertyDescriptor(_U.prototype,"gpuMaterial"),_U.prototype),yU=tn(_U.prototype,"_gpuMaterial",[en],(function(){return null})),gn(_U.prototype,"trailMaterial",[uU],Object.getOwnPropertyDescriptor(_U.prototype,"trailMaterial"),_U.prototype),TU=tn(_U.prototype,"_mainTexture",[en],(function(){return null})),SU=tn(_U.prototype,"_useGPU",[en],(function(){return!1})),gn(_U.prototype,"alignSpace",[cU],Object.getOwnPropertyDescriptor(_U.prototype,"alignSpace"),_U.prototype),EU=tn(_U.prototype,"_alignSpace",[en],(function(){return $F.View})),dU=_U))||dU),nz=Math.cos(mr(100)),rz={position:new ji,velocity:new ji},sz=new Ji,az=new Ue,oz=new ji,hz=new ji,lz=new Ve,uz=function(){function t(t){for(this.start=void 0,this.end=void 0,this.trailElements=void 0,this.start=-1,this.end=-1,this.trailElements=[];t--;)this.trailElements.push({position:new ji,lifetime:0,width:0,velocity:new ji,direction:0,color:new Ve})}var e=t.prototype;return e.getElement=function(t){return-1===this.start?null:(t<0&&(t=(t+this.trailElements.length)%this.trailElements.length),t>=this.trailElements.length&&(t%=this.trailElements.length),this.trailElements[t])},e.addElement=function(){if(0===this.trailElements.length)return null;if(-1===this.start)return this.start=0,this.end=1,this.trailElements[0];this.start===this.end&&(this.trailElements.splice(this.end,0,{position:new ji,lifetime:0,width:0,velocity:new ji,direction:0,color:new Ve}),this.start++,this.start%=this.trailElements.length);var t=this.end++;return this.end%=this.trailElements.length,this.trailElements[t]},e.iterateElement=function(t,e,i,n){for(var r=this.start>=this.end?this.end+this.trailElements.length:this.end,s=this.start;s<r;s++)e(t,this.trailElements[s%this.trailElements.length],i,n)&&(this.start++,this.start%=this.trailElements.length);this.start===r&&(this.start=-1,this.end=-1)},e.count=function(){return this.start<this.end?this.end-this.start:this.trailElements.length+this.end-this.start},e.clear=function(){this.start=-1,this.end=-1},t}(),cz=(uG=Ki("cc.TrailModule"),cG=Tn(rL),dG=Tn(FO),_G=Tn(QF),fG=Tn(sL),pG=Tn(FO),gG=Tn(BF),mG=Tn(BF),vG=Tn(QF),uG((TG=function(){var t=i.prototype;function i(){this._enable=SG&&SG(),this.mode=EG&&EG(),this.lifeTime=AG&&AG(),this._minParticleDistance=CG&&CG(),this.existWithParticles=RG&&RG(),this.textureMode=bG&&bG(),this.widthFromParticle=xG&&xG(),this.widthRatio=wG&&wG(),this.colorFromParticle=MG&&MG(),this.colorOverTrail=IG&&IG(),this.colorOvertime=BG&&BG(),this._space=PG&&PG(),this._particleSystem=DG&&DG(),this._minSquaredDistance=0,this._vertSize=void 0,this._trailNum=0,this._trailLifetime=0,this.vbOffset=0,this.ibOffset=0,this._trailSegments=null,this._particleTrail=void 0,this._trailModel=null,this._iaInfo=void 0,this._iaInfoBuffer=null,this._subMeshData=null,this._vertAttrs=void 0,this._vbF32=null,this._vbUint32=null,this._iBuffer=null,this._needTransform=!1,this._material=null,this._inited=void 0,this._iaInfo=new vt([new gt]),this._vertAttrs=[new Bt(ie.ATTR_POSITION,_.RGB32F),new Bt(ie.ATTR_TEX_COORD,_.RGBA32F),new Bt(ie.ATTR_TEX_COORD1,_.RGB32F),new Bt(ie.ATTR_COLOR,_.RGBA8,!0)],this._vertSize=0;for(var t,e=Fi(this._vertAttrs);!(t=e()).done;){var i=t.value;this._vertSize+=ne[i.format].size}this._particleTrail=new Map,this._inited=!1}return t.getModel=function(){return this._trailModel},t.onInit=function(t){this._particleSystem=t,this.minParticleDistance=this._minParticleDistance;for(var i=0,n=t.startLifetime.getMax(),r=t.rateOverTime.getMax(),s=t.duration,a=0,o=t.bursts.length;a<o;a++)i+=t.bursts[a].getMaxCount(t)*Math.ceil(n/s);this.lifeTime.getMax()<1&&Zi(6036),this._trailNum=Math.ceil(n*Math.ceil(this.lifeTime.getMax())*60*(r*s+i)),this._trailSegments=new e((function(){return new uz(10)}),Math.ceil(r*s),(function(t){return t.trailElements.length=0})),this._enable&&(this.enable=this._enable),this._inited=!0},t.onEnable=function(){this._attachToScene()},t.onDisable=function(){this._particleTrail.clear(),this._detachFromScene()},t._attachToScene=function(){this._trailModel&&(this._trailModel.scene&&this._detachFromScene(),this._particleSystem._getRenderScene().addModel(this._trailModel))},t._detachFromScene=function(){this._trailModel&&this._trailModel.scene&&this._trailModel.scene.removeModel(this._trailModel)},t.destroy=function(){this.destroySubMeshData(),this._trailModel&&(Di.root.destroyModel(this._trailModel),this._trailModel=null),this._trailSegments&&(this._trailSegments.destroy(),this._trailSegments=null)},t.play=function(){this._trailModel&&this._enable&&(this._trailModel.enabled=!0)},t.clear=function(){if(this.enable){for(var t=this._particleTrail.values(),e=t.next();!e.done;)e.value.clear(),e=t.next();this._particleTrail.clear(),this.updateRenderData(),this._trailModel&&(this._trailModel.enabled=!1)}},t.updateMaterial=function(){this._particleSystem&&(this._material=this._particleSystem.getMaterialInstance(1)||this._particleSystem.processor._defaultTrailMat,this._trailModel&&this._trailModel.setSubModelMaterial(0,this._material))},t.update=function(){this._trailLifetime=this.lifeTime.evaluate(this._particleSystem._time,1),this.space===QF.World&&this._particleSystem._simulationSpace===QF.Local?(this._needTransform=!0,this._particleSystem.node.getWorldMatrix(az),this._particleSystem.node.getWorldRotation(sz)):this._needTransform=!1},t.animate=function(t,e){if(this._trailSegments)if(t.loopCount>t.lastLoop)t.trailDelay>1?(t.lastLoop=t.loopCount,t.trailDelay=0):t.trailDelay++;else{var i=this._particleTrail.get(t);if(!i)return i=this._trailSegments.alloc(),void this._particleTrail.set(t,i);var n=i.getElement(i.end-1);if(this._needTransform?ji.transformMat4(oz,t.position,az):ji.copy(oz,t.position),!(n&&(i.iterateElement(this,this._updateTrailElement,t,e),ji.squaredDistance(n.position,oz)<this._minSquaredDistance))&&(n=i.addElement())){ji.copy(n.position,oz),n.lifetime=0,this.widthFromParticle?n.width=t.size.x*this.widthRatio.evaluate(0,1):n.width=this.widthRatio.evaluate(0,1);var r=i.count();if(2===r){var s=i.getElement(i.end-2);ji.subtract(s.velocity,n.position,s.position)}else if(r>2){var a=i.getElement(i.end-2),o=i.getElement(i.end-3);ji.subtract(oz,o.position,a.position),ji.subtract(hz,n.position,a.position),ji.subtract(a.velocity,hz,oz),ji.equals(ji.ZERO,a.velocity)&&ji.copy(a.velocity,oz),ji.normalize(a.velocity,a.velocity),this._checkDirectionReverse(a,o)}this.colorFromParticle?n.color.set(t.color):n.color.set(this.colorOvertime.evaluate(0,1))}}},t.removeParticle=function(t){var e=this._particleTrail.get(t);e&&this._trailSegments&&(e.clear(),this._trailSegments.free(e),this._particleTrail.delete(t))},t.updateRenderData=function(){this.vbOffset=0,this.ibOffset=0;for(var t,e=Fi(this._particleTrail.keys());!(t=e()).done;){var i=t.value,n=this._particleTrail.get(i);if(-1!==n.start){var r=4*this.vbOffset/this._vertSize,s=n.start>=n.end?n.end+n.trailElements.length:n.end,a=s-n.start,o=1/a,h=n.trailElements[n.start];this._fillVertexBuffer(h,this.colorOverTrail.evaluate(1,1),r,1,0,4);for(var l=n.start+1;l<s;l++){var u=n.trailElements[l%n.trailElements.length],c=l-n.start;this._fillVertexBuffer(u,this.colorOverTrail.evaluate(1-c/a,1),r,1-c*o,c,5)}this._needTransform?ji.transformMat4(rz.position,i.position,az):ji.copy(rz.position,i.position);var d=this._trailModel;if(d&&d.node.invalidateChildren(pr.POSITION),1===a||2===a){var _=n.getElement(n.end-1);ji.subtract(_.velocity,rz.position,_.position),this._vbF32[this.vbOffset-this._vertSize/4-4]=_.velocity.x,this._vbF32[this.vbOffset-this._vertSize/4-3]=_.velocity.y,this._vbF32[this.vbOffset-this._vertSize/4-2]=_.velocity.z,this._vbF32[this.vbOffset-4]=_.velocity.x,this._vbF32[this.vbOffset-3]=_.velocity.y,this._vbF32[this.vbOffset-2]=_.velocity.z,ji.subtract(rz.velocity,rz.position,_.position),this._checkDirectionReverse(rz,_)}else if(a>2){var f=n.getElement(n.end-1),p=n.getElement(n.end-2);ji.subtract(oz,p.position,f.position),ji.subtract(hz,rz.position,f.position),ji.normalize(oz,oz),ji.normalize(hz,hz),ji.subtract(f.velocity,hz,oz),ji.normalize(f.velocity,f.velocity),this._checkDirectionReverse(f,p),this.vbOffset-=this._vertSize/4*2,this.ibOffset-=6,this._fillVertexBuffer(f,this.colorOverTrail.evaluate(o,1),r,o,a-1,5),ji.subtract(rz.velocity,rz.position,f.position),ji.normalize(rz.velocity,rz.velocity),this._checkDirectionReverse(rz,f)}this.widthFromParticle?rz.width=i.size.x*this.widthRatio.evaluate(0,1):rz.width=this.widthRatio.evaluate(0,1),rz.color=i.color,ji.equals(rz.velocity,ji.ZERO)?this.ibOffset-=3:this._fillVertexBuffer(rz,this.colorOverTrail.evaluate(0,1),r,0,a,1)}}this._trailModel&&(this._trailModel.enabled=this.ibOffset>0)},t.updateIA=function(t){var e=this._trailModel&&this._trailModel.subModels;if(e&&e.length>0){var i=e[0];i.inputAssembler.vertexBuffers[0].update(this._vbF32),i.inputAssembler.indexBuffer.update(this._iBuffer),this._iaInfo.drawInfos[0].firstIndex=0,this._iaInfo.drawInfos[0].indexCount=t,this._iaInfoBuffer.update(this._iaInfo)}},t.beforeRender=function(){this.updateIA(this.ibOffset)},t._createModel=function(){this._trailModel||(this._trailModel=We.director.root.createModel(ni))},t.rebuild=function(){var t=Di.root.device,e=t.createBuffer(new ft(g.VERTEX|g.TRANSFER_DST,y.HOST|y.DEVICE,this._vertSize*(this._trailNum+1)*2,this._vertSize)),i=new ArrayBuffer(this._vertSize*(this._trailNum+1)*2);this._vbF32=new Float32Array(i),this._vbUint32=new Uint32Array(i),e.update(i);var n=t.createBuffer(new ft(g.INDEX|g.TRANSFER_DST,y.HOST|y.DEVICE,6*Math.max(1,this._trailNum)*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));this._iBuffer=new Uint16Array(6*Math.max(1,this._trailNum)),n.update(this._iBuffer),this._iaInfoBuffer=t.createBuffer(new ft(g.INDIRECT,y.HOST|y.DEVICE,oe,oe)),this._iaInfo.drawInfos[0].vertexCount=2*(this._trailNum+1),this._iaInfo.drawInfos[0].indexCount=6*this._trailNum,this._iaInfoBuffer.update(this._iaInfo),this._subMeshData=new qi([e],this._vertAttrs,U.TRIANGLE_LIST,n,this._iaInfoBuffer);var r=this._trailModel;r&&this._material&&(r.node=r.transform=this._particleSystem.node,r.visFlags=this._particleSystem.visibility,r.initSubModel(0,this._subMeshData,this._material),r.enabled=!0)},t._updateTrailElement=function(t,e,i,n){return e.lifetime+=n,t.colorFromParticle?(e.color.set(i.color),e.color.multiply(t.colorOvertime.evaluate(1-i.remainingLifetime/i.startLifetime,1))):e.color.set(t.colorOvertime.evaluate(1-i.remainingLifetime/i.startLifetime,1)),t.widthFromParticle?e.width=i.size.x*t.widthRatio.evaluate(e.lifetime/t._trailLifetime,1):e.width=t.widthRatio.evaluate(e.lifetime/t._trailLifetime,1),e.lifetime>t._trailLifetime},t._fillVertexBuffer=function(t,e,i,n,r,s){this._vbF32[this.vbOffset++]=t.position.x,this._vbF32[this.vbOffset++]=t.position.y,this._vbF32[this.vbOffset++]=t.position.z,this._vbF32[this.vbOffset++]=t.direction,this._vbF32[this.vbOffset++]=t.width,this._vbF32[this.vbOffset++]=n,this._vbF32[this.vbOffset++]=0,this._vbF32[this.vbOffset++]=t.velocity.x,this._vbF32[this.vbOffset++]=t.velocity.y,this._vbF32[this.vbOffset++]=t.velocity.z,lz.set(t.color),lz.multiply(e),this._vbUint32[this.vbOffset++]=lz._val,this._vbF32[this.vbOffset++]=t.position.x,this._vbF32[this.vbOffset++]=t.position.y,this._vbF32[this.vbOffset++]=t.position.z,this._vbF32[this.vbOffset++]=1-t.direction,this._vbF32[this.vbOffset++]=t.width,this._vbF32[this.vbOffset++]=n,this._vbF32[this.vbOffset++]=1,this._vbF32[this.vbOffset++]=t.velocity.x,this._vbF32[this.vbOffset++]=t.velocity.y,this._vbF32[this.vbOffset++]=t.velocity.z,this._vbUint32[this.vbOffset++]=lz._val,1&s&&(this._iBuffer[this.ibOffset++]=i+2*r,this._iBuffer[this.ibOffset++]=i+2*r-1,this._iBuffer[this.ibOffset++]=i+2*r+1),4&s&&(this._iBuffer[this.ibOffset++]=i+2*r,this._iBuffer[this.ibOffset++]=i+2*r+1,this._iBuffer[this.ibOffset++]=i+2*r+2)},t._checkDirectionReverse=function(t,e){ji.dot(t.velocity,e.velocity)<nz?t.direction=1-e.direction:t.direction=e.direction},t.destroySubMeshData=function(){this._subMeshData&&(this._subMeshData.destroy(),this._subMeshData=null)},Pi(i,[{key:"enable",get:function(){return this._enable},set:function(t){t===this._enable&&this._trailModel||(t&&!this._enable&&(this._enable=t,this._particleSystem.processor&&this._particleSystem.processor.updateTrailMaterial()),t&&!this._trailModel&&(this._createModel(),this.rebuild()),this._enable=t,this._trailModel&&(this._trailModel.enabled=t),t?this.onEnable():this.onDisable())}},{key:"minParticleDistance",get:function(){return this._minParticleDistance},set:function(t){this._minParticleDistance=t,this._minSquaredDistance=t*t}},{key:"space",get:function(){return this._space},set:function(t){this._space=t;var e=this._particleSystem;e&&e.processor&&e.processor.updateTrailMaterial()}}]),i}(),SG=tn(TG.prototype,"_enable",[en],(function(){return!1})),EG=tn(TG.prototype,"mode",[cG,en],(function(){return rL.Particles})),AG=tn(TG.prototype,"lifeTime",[dG,en],(function(){return new FO})),CG=tn(TG.prototype,"_minParticleDistance",[en],(function(){return.1})),gn(TG.prototype,"space",[_G],Object.getOwnPropertyDescriptor(TG.prototype,"space"),TG.prototype),RG=tn(TG.prototype,"existWithParticles",[en],(function(){return!0})),bG=tn(TG.prototype,"textureMode",[fG,en],(function(){return sL.Stretch})),xG=tn(TG.prototype,"widthFromParticle",[en],(function(){return!0})),wG=tn(TG.prototype,"widthRatio",[pG,en],(function(){return new FO})),MG=tn(TG.prototype,"colorFromParticle",[en],(function(){return!1})),IG=tn(TG.prototype,"colorOverTrail",[gG,en],(function(){return new BF})),BG=tn(TG.prototype,"colorOvertime",[mG,en],(function(){return new BF})),PG=tn(TG.prototype,"_space",[vG],(function(){return QF.World})),DG=tn(TG.prototype,"_particleSystem",[en],(function(){return null})),yG=TG))||yG),dz=new Ue,_z=new Ue,fz=new Ji,pz=new ji,gz=["_colorOverLifetimeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule"],mz=function(){function t(t){this._particleSystem=void 0,this._processor=void 0,this._node=void 0,this._particlesAll=void 0,this._updateList=new Map,this._animateList=new Map,this._runAnimateList=new Array,this._localMat=new Ue,this._gravity=new _n,this.minPos=new ji,this.maxPos=new ji,this._nodePos=new ji,this._nodeSize=new ji,this._particleSystem=t,this._processor=this._particleSystem.processor,this._node=t.node,this._particlesAll=[],this._initModuleList()}var e=t.prototype;return e._updateBoundingNode=function(){this._nodeSize.set(this.maxPos.x-this.minPos.x,this.maxPos.y-this.minPos.y,this.maxPos.z-this.minPos.z),this._nodePos.set(this.minPos.x+.5*this._nodeSize.x,this.minPos.y+.5*this._nodeSize.y,this.minPos.z+.5*this._nodeSize.z)},e.setBoundingBoxSize=function(t){this.maxPos.x=this._nodePos.x+t.x,this.maxPos.y=this._nodePos.y+t.y,this.maxPos.z=this._nodePos.z+t.z,this.minPos.x=this._nodePos.x-t.x,this.minPos.y=this._nodePos.y-t.y,this.minPos.z=this._nodePos.z-t.z,this._updateBoundingNode()},e.setBoundingBoxCenter=function(t,e,i){this.maxPos.x=t+.5*this._nodeSize.x,this.maxPos.y=e+.5*this._nodeSize.y,this.maxPos.z=i+.5*this._nodeSize.z,this.minPos.x=t-.5*this._nodeSize.x,this.minPos.y=e-.5*this._nodeSize.y,this.minPos.z=i-.5*this._nodeSize.z,this._updateBoundingNode()},e._initModuleList=function(){var t=this;gz.forEach((function(e){var i=t._particleSystem[e];i&&i.enable&&(i.needUpdate&&(t._updateList[i.name]=i),i.needAnimate&&(t._animateList[i.name]=i))})),this._runAnimateList.length=0;for(var e=0,i=KF.length;e<i;e++){var n=this._animateList[KF[e]];n&&this._runAnimateList.push(n)}},e._emit=function(t,e,i){var n=this._particleSystem,r=this._node,s=n.time%n.duration/n.duration;r.invalidateChildren(pr.POSITION),n.simulationSpace===QF.World&&(r.getWorldMatrix(dz),r.getWorldRotation(fz));for(var a=0;a<t;++a){var o=new LF(n);o.particleSystem=n,o.reset();var h=va(ga(0,Ta));n._shapeModule&&n._shapeModule.enable?n._shapeModule.emit(o):(ji.set(o.position,0,0,0),ji.copy(o.velocity,aL)),n._textureAnimationModule&&n._textureAnimationModule.enable&&n._textureAnimationModule.init(o);var l=n.startSpeed.evaluate(s,h);ji.multiplyScalar(o.velocity,o.velocity,l),n.simulationSpace===QF.World&&(ji.transformMat4(o.position,o.position,dz),ji.transformQuat(o.velocity,o.velocity,fz)),ji.copy(o.ultimateVelocity,o.velocity),ji.set(o.rotation,0,0,0),n.startSize3D?ji.set(o.startSize,n.startSizeX.evaluate(s,h),n.startSizeY.evaluate(s,h),n.startSizeZ.evaluate(s,h)):(ji.set(o.startSize,n.startSizeX.evaluate(s,h),1,1),o.startSize.y=o.startSize.x),ji.copy(o.size,o.startSize),o.startLifetime=n.startLifetime.evaluate(s,h)+e,o.remainingLifetime=o.startLifetime,i.push(o)}},e._updateParticles=function(t,e){var i=this,n=this._particleSystem;switch(n.node.getWorldMatrix(dz),n.scaleSpace){case QF.Local:n.node.getScale(pz);break;case QF.World:n.node.getWorldScale(pz)}if(this._updateList.forEach((function(t){t.update(n.simulationSpace,dz)})),n.simulationSpace===QF.Local){var r=n.node.getRotation();Ue.fromQuat(this._localMat,r),this._localMat.transpose()}n.node.parent&&(n.node.parent.getWorldMatrix(_z),_z.invert());for(var s=function(r){var s=e[r];if(s.remainingLifetime-=t,ji.set(s.animatedVelocity,0,0,0),n.gravityModifier.mode!==OO.Constant||0!==n.gravityModifier.constant){var a=fL(n.gravityModifier)?va(s.randomSeed):0;if(n.simulationSpace===QF.Local){var o=9.8*-n.gravityModifier.evaluate(1-s.remainingLifetime/s.startLifetime,a)*t;i._gravity.x=0,i._gravity.y=o,i._gravity.z=0,i._gravity.w=1,wn(o,0,Mn)||(n.node.parent&&(i._gravity=i._gravity.transformMat4(_z)),i._gravity=i._gravity.transformMat4(i._localMat),s.velocity.x+=i._gravity.x,s.velocity.y+=i._gravity.y,s.velocity.z+=i._gravity.z)}else s.velocity.y-=9.8*n.gravityModifier.evaluate(1-s.remainingLifetime/s.startLifetime,a)*t}ji.copy(s.ultimateVelocity,s.velocity),i._runAnimateList.forEach((function(e){e.animate(s,t)})),ji.scaleAndAdd(s.position,s.position,s.ultimateVelocity,t)},a=0;a<e.length;++a)s(a)},e._calculateBounding=function(t){var e=new ji,i=new ji,n=new ji,r=new ji,s=new ji(1,1,1);if(this._processor.getInfo().renderMode===tL.Mesh){var a=this._processor.getInfo().mesh;if(a&&a.struct.minPosition&&a.struct.maxPosition){var o=new Qi;Qi.fromPoints(o,a.struct.minPosition,a.struct.maxPosition);var h=Math.max(o.halfExtents.x,o.halfExtents.y,o.halfExtents.z);s.set(h,h,h)}}for(var l=this._particleSystem.node.worldMatrix,u=0;u<this._particlesAll.length;++u){var c=this._particlesAll[u];ji.multiply(e,pz,c.size),ji.multiply(e,e,s),i.set(c.position),this._particleSystem.simulationSpace!==QF.World&&ji.transformMat4(i,i,l),t&&0===u?(ji.subtract(this.minPos,i,e),ji.add(this.maxPos,i,e)):(ji.subtract(n,i,e),ji.add(r,i,e),ji.min(this.minPos,this.minPos,n),ji.max(this.maxPos,this.maxPos,r))}},e.calculatePositions=function(){this._emit(this._particleSystem.capacity,0,this._particlesAll);var t=fL(this._particleSystem.startLifetime)?va(ga(0,Ta)):0;this._updateParticles(0,this._particlesAll),this._calculateBounding(!0),this._updateParticles(this._particleSystem.startLifetime.evaluate(0,t),this._particlesAll),this._calculateBounding(!1),this._updateBoundingNode()},e.clear=function(){this._particlesAll.length=0},e.destroy=function(){},t}(),vz=en,yz=Tn,Tz=(OG=Ki("cc.NoiseModule"),FG=yz($r),LG=yz($r),NG=yz($r),kG=yz($r),UG=yz($r),GG=yz($r),VG=yz($r),HG=yz($r),zG=yz($r),XG=yz($r),WG=yz(Qr),YG=yz($r),jG=yz($r),OG((qG=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._enable=ZG&&ZG(),e._strengthX=QG&&QG(),e._strengthY=JG&&JG(),e._strengthZ=$G&&$G(),e._noiseSpeedX=tV&&tV(),e._noiseSpeedY=eV&&eV(),e._noiseSpeedZ=iV&&iV(),e._noiseFrequency=nV&&nV(),e._remapX=rV&&rV(),e._remapY=sV&&sV(),e._remapZ=aV&&aV(),e._octaves=oV&&oV(),e._octaveMultiplier=hV&&hV(),e._octaveScale=lV&&lV(),e.name=jF,e.noise=new MU,e.samplePosition=new ji,e}He(e,t);var i=e.prototype;return i.animate=function(t,e){this.noise.setTime(t.particleSystem.time),this.noise.setSpeed(this.noiseSpeedX,this.noiseSpeedY,this.noiseSpeedZ),this.noise.setFrequency(this.noiseFrequency),this.noise.setAbs(this.remapX,this.remapY,this.remapZ),this.noise.setAmplititude(this.strengthX,this.strengthY,this.strengthZ),this.noise.setOctaves(this.octaves,this.octaveMultiplier,this.octaveScale),this.samplePosition.set(t.position),this.samplePosition.add3f(1*Math.random(),1*Math.random(),1*Math.random()),this.noise.setSamplePoint(this.samplePosition),this.noise.getNoiseParticle();var i=this.noise.getResult();i.multiply3f(Math.random(),Math.random(),Math.random()),ji.add(t.position,t.position,i.multiplyScalar(e))},i.getNoisePreview=function(t,e,i,n){this.noise.setTime(e.time),this.noise.setSpeed(this.noiseSpeedX,this.noiseSpeedY,this.noiseSpeedZ),this.noise.setFrequency(this.noiseFrequency),this.noise.setAbs(this.remapX,this.remapY,this.remapZ),this.noise.setAmplititude(this.strengthX,this.strengthY,this.strengthZ),this.noise.setOctaves(this.octaves,this.octaveMultiplier,this.octaveScale),this.noise.getNoiseParticle(),this.noise.getPreview(t,i,n)},Pi(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}},{key:"strengthX",get:function(){return this._strengthX},set:function(t){this._strengthX=t}},{key:"strengthY",get:function(){return this._strengthY},set:function(t){this._strengthY=t}},{key:"strengthZ",get:function(){return this._strengthZ},set:function(t){this._strengthZ=t}},{key:"noiseSpeedX",get:function(){return this._noiseSpeedX},set:function(t){this._noiseSpeedX=t}},{key:"noiseSpeedY",get:function(){return this._noiseSpeedY},set:function(t){this._noiseSpeedY=t}},{key:"noiseSpeedZ",get:function(){return this._noiseSpeedZ},set:function(t){this._noiseSpeedZ=t}},{key:"noiseFrequency",get:function(){return this._noiseFrequency},set:function(t){this._noiseFrequency=t}},{key:"remapX",get:function(){return this._remapX},set:function(t){this._remapX=t}},{key:"remapY",get:function(){return this._remapY},set:function(t){this._remapY=t}},{key:"remapZ",get:function(){return this._remapZ},set:function(t){this._remapZ=t}},{key:"octaves",get:function(){return this._octaves},set:function(t){this._octaves=t}},{key:"octaveMultiplier",get:function(){return this._octaveMultiplier},set:function(t){this._octaveMultiplier=t}},{key:"octaveScale",get:function(){return this._octaveScale},set:function(t){this._octaveScale=t}}]),e}(ZF),ZG=tn(qG.prototype,"_enable",[vz],(function(){return!1})),gn(qG.prototype,"strengthX",[FG],Object.getOwnPropertyDescriptor(qG.prototype,"strengthX"),qG.prototype),QG=tn(qG.prototype,"_strengthX",[vz],(function(){return 10})),gn(qG.prototype,"strengthY",[LG],Object.getOwnPropertyDescriptor(qG.prototype,"strengthY"),qG.prototype),JG=tn(qG.prototype,"_strengthY",[vz],(function(){return 10})),gn(qG.prototype,"strengthZ",[NG],Object.getOwnPropertyDescriptor(qG.prototype,"strengthZ"),qG.prototype),$G=tn(qG.prototype,"_strengthZ",[vz],(function(){return 10})),gn(qG.prototype,"noiseSpeedX",[kG],Object.getOwnPropertyDescriptor(qG.prototype,"noiseSpeedX"),qG.prototype),tV=tn(qG.prototype,"_noiseSpeedX",[vz],(function(){return 0})),gn(qG.prototype,"noiseSpeedY",[UG],Object.getOwnPropertyDescriptor(qG.prototype,"noiseSpeedY"),qG.prototype),eV=tn(qG.prototype,"_noiseSpeedY",[vz],(function(){return 0})),gn(qG.prototype,"noiseSpeedZ",[GG],Object.getOwnPropertyDescriptor(qG.prototype,"noiseSpeedZ"),qG.prototype),iV=tn(qG.prototype,"_noiseSpeedZ",[vz],(function(){return 0})),gn(qG.prototype,"noiseFrequency",[VG],Object.getOwnPropertyDescriptor(qG.prototype,"noiseFrequency"),qG.prototype),nV=tn(qG.prototype,"_noiseFrequency",[vz],(function(){return 1})),gn(qG.prototype,"remapX",[HG],Object.getOwnPropertyDescriptor(qG.prototype,"remapX"),qG.prototype),rV=tn(qG.prototype,"_remapX",[vz],(function(){return 0})),gn(qG.prototype,"remapY",[zG],Object.getOwnPropertyDescriptor(qG.prototype,"remapY"),qG.prototype),sV=tn(qG.prototype,"_remapY",[vz],(function(){return 0})),gn(qG.prototype,"remapZ",[XG],Object.getOwnPropertyDescriptor(qG.prototype,"remapZ"),qG.prototype),aV=tn(qG.prototype,"_remapZ",[vz],(function(){return 0})),gn(qG.prototype,"octaves",[WG],Object.getOwnPropertyDescriptor(qG.prototype,"octaves"),qG.prototype),oV=tn(qG.prototype,"_octaves",[vz],(function(){return 1})),gn(qG.prototype,"octaveMultiplier",[YG],Object.getOwnPropertyDescriptor(qG.prototype,"octaveMultiplier"),qG.prototype),hV=tn(qG.prototype,"_octaveMultiplier",[vz],(function(){return.5})),gn(qG.prototype,"octaveScale",[jG],Object.getOwnPropertyDescriptor(qG.prototype,"octaveScale"),qG.prototype),lV=tn(qG.prototype,"_octaveScale",[vz],(function(){return 2})),KG=qG))||KG),Sz=new Ue,Ez=new Ji,Az=Object.getOwnPropertyDescriptor(ql.prototype,"sharedMaterials"),Cz=function(e){return t({ParticleSystem:e,ParticleSystemComponent:e}),e}((uV=Ki("cc.ParticleSystem"),cV=In(99),dV=Tn(BF),_V=Tn(QF),fV=is("startSize"),pV=Tn(FO),gV=Tn(FO),mV=Tn(FO),vV=Tn(FO),yV=Tn(FO),TV=Tn(FO),SV=Tn(FO),EV=is("startRotation"),AV=Tn(FO),CV=Tn(FO),RV=Tn(QF),bV=Tn(FO),xV=Tn(FO),wV=Tn(FO),MV=Tn([Qk]),IV=Tn(Jr),BV=Tn(JF),PV=Tn($r),DV=Tn($r),OV=Tn($r),FV=is("enableCulling"),LV=Tn(Dn),NV=Tn(tN),kV=Tn(tN),UV=Tn(eU),GV=Tn(eU),VV=Tn(Xk),HV=Tn(Xk),zV=Tn(Zk),XV=Tn(Zk),WV=Tn(nN),YV=Tn(nN),jV=Tn(oN),KV=Tn(oN),qV=Tn(Hk),ZV=Tn(Hk),QV=Tn(jk),JV=Tn(jk),$V=Tn(Tz),tH=Tn(Tz),eH=Tn(cz),iH=Tn(cz),nH=Tn(iz),uV(rH=cV((KH=jH=function(t){function e(){var e;return(e=t.call(this)||this).startColor=aH&&aH(),e.scaleSpace=oH&&oH(),e.startSize3D=hH&&hH(),e.startSizeX=lH&&lH(),e.startSizeY=uH&&uH(),e.startSizeZ=cH&&cH(),e.startSpeed=dH&&dH(),e.startRotation3D=_H&&_H(),e.startRotationX=fH&&fH(),e.startRotationY=pH&&pH(),e.startRotationZ=gH&&gH(),e.startDelay=mH&&mH(),e.startLifetime=vH&&vH(),e.duration=yH&&yH(),e.loop=TH&&TH(),e.simulationSpeed=SH&&SH(),e.playOnAwake=EH&&EH(),e.gravityModifier=AH&&AH(),e.rateOverTime=CH&&CH(),e.rateOverDistance=RH&&RH(),e.bursts=bH&&bH(),e._renderCulling=xH&&xH(),e._cullingMode=wH&&wH(),e._aabbHalfX=MH&&MH(),e._aabbHalfY=IH&&IH(),e._aabbHalfZ=BH&&BH(),e._dataCulling=PH&&PH(),e._colorOverLifetimeModule=DH&&DH(),e._shapeModule=OH&&OH(),e._sizeOvertimeModule=FH&&FH(),e._velocityOvertimeModule=LH&&LH(),e._forceOvertimeModule=NH&&NH(),e._limitVelocityOvertimeModule=kH&&kH(),e._rotationOvertimeModule=UH&&UH(),e._textureAnimationModule=GH&&GH(),e._noiseModule=VH&&VH(),e._trailModule=HH&&HH(),e.renderer=zH&&zH(),e._isPlaying=void 0,e._isPaused=void 0,e._isStopped=void 0,e._isEmitting=void 0,e._needRefresh=void 0,e._time=void 0,e._emitRateTimeCounter=void 0,e._emitRateDistanceCounter=void 0,e._oldWPos=void 0,e._curWPos=void 0,e._boundingBox=void 0,e._culler=void 0,e._oldPos=void 0,e._curPos=void 0,e._isCulled=void 0,e._isSimulating=void 0,e._customData1=void 0,e._customData2=void 0,e._subEmitters=void 0,e._needAttach=void 0,e._prewarm=XH&&XH(),e._capacity=WH&&WH(),e._simulationSpace=YH&&YH(),e.processor=null,e.rateOverTime.constant=10,e.startLifetime.constant=5,e.startSizeX.constant=1,e.startSpeed.constant=5,e._isPlaying=!1,e._isPaused=!1,e._isStopped=!0,e._isEmitting=!1,e._needRefresh=!0,e._needAttach=!1,e._time=0,e._emitRateTimeCounter=0,e._emitRateDistanceCounter=0,e._oldWPos=new ji,e._curWPos=new ji,e._boundingBox=null,e._culler=null,e._oldPos=null,e._curPos=null,e._isCulled=!1,e._isSimulating=!0,e._customData1=new cn,e._customData2=new cn,e._subEmitters=[],e}He(e,t);var i=e.prototype;return i.onFocusInEditor=function(){this.renderer.create(this)},i.onLoad=function(){this.renderer.onInit(this),this._shapeModule&&this._shapeModule.onInit(this),this._trailModule&&!this.renderer.useGPU&&this._trailModule.enable&&this._trailModule.onInit(this),this.bindModule(),this._resetPosition()},i._onMaterialModified=function(t,e){null!==this.processor&&this.processor.onMaterialModified(t,e)},i._onRebuildPSO=function(t,e){this.processor.onRebuildPSO(t,e)},i._collectModels=function(){return this._models.length=0,this._models.push(this.processor._model),this._trailModule&&this._trailModule.enable&&this._trailModule._trailModel&&this._models.push(this._trailModule._trailModel),this._models},i._attachToScene=function(){this.processor.attachToScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._attachToScene()},i._detachFromScene=function(){this.processor.detachFromScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene(),this._boundingBox&&(this._boundingBox=null),this._culler&&(this._culler.clear(),this._culler.destroy(),this._culler=null)},i.bindModule=function(){this._colorOverLifetimeModule&&this._colorOverLifetimeModule.bindTarget(this.processor),this._sizeOvertimeModule&&this._sizeOvertimeModule.bindTarget(this.processor),this._rotationOvertimeModule&&this._rotationOvertimeModule.bindTarget(this.processor),this._forceOvertimeModule&&this._forceOvertimeModule.bindTarget(this.processor),this._limitVelocityOvertimeModule&&this._limitVelocityOvertimeModule.bindTarget(this.processor),this._velocityOvertimeModule&&this._velocityOvertimeModule.bindTarget(this.processor),this._textureAnimationModule&&this._textureAnimationModule.bindTarget(this.processor),this._noiseModule&&this._noiseModule.bindTarget(this.processor)},i.play=function(){if(this._isPaused&&(this._isPaused=!1),this._isStopped&&(this._isStopped=!1),this._isPlaying=!0,this._isEmitting=!0,this._resetPosition(),this._prewarm&&this._prewarmSystem(),this._trailModule&&this._trailModule.play(),this.processor){var t=this.processor.getModel();t&&(t.enabled=this.enabledInHierarchy)}},i.pause=function(){this._isStopped?console.warn("pause(): particle system is already stopped."):(this._isPlaying&&(this._isPlaying=!1),this._isPaused=!0)},i.stopEmitting=function(){this._isEmitting=!1},i.stop=function(){(this._isPlaying||this._isPaused)&&this.clear(),this._isPlaying&&(this._isPlaying=!1),this._isPaused&&(this._isPaused=!1),this._isEmitting&&(this._isEmitting=!1),this._time=0,this._emitRateTimeCounter=0,this._emitRateDistanceCounter=0,this._isStopped=!0,this._needRefresh=!0;for(var t,e=Fi(this.bursts);!(t=e()).done;)t.value.reset()},i.clear=function(){this.enabledInHierarchy&&(this.processor.clear(),this._trailModule&&this._trailModule.clear()),this._calculateBounding(!1)},i.getParticleCount=function(){return this.processor.getParticleCount()},i.setCustomData1=function(t,e){cn.set(this._customData1,t,e)},i.setCustomData2=function(t,e){cn.set(this._customData2,t,e)},i.onDestroy=function(){var t;this.stop(),null!==(t=this.processor.getModel())&&void 0!==t&&t.scene&&(this.processor.detachFromScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene()),We.director.off(We.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.processor.onDestroy(),this._trailModule&&this._trailModule.destroy(),this._culler&&(this._culler.clear(),this._culler.destroy(),this._culler=null)},i.onEnable=function(){t.prototype.onEnable.call(this),We.director.on(We.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.playOnAwake&&!aa&&this.play(),this.processor.onEnable(),this._trailModule&&this._trailModule.onEnable()},i.onDisable=function(){We.director.off(We.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.processor.onDisable(),this._trailModule&&this._trailModule.onDisable(),this._boundingBox&&(this._boundingBox=null),this._culler&&(this._culler.clear(),this._culler.destroy(),this._culler=null)},i._calculateBounding=function(t){this._boundingBox&&(this._culler||(this._culler=new mz(this)),this._culler.calculatePositions(),Qi.fromPoints(this._boundingBox,this._culler.minPos,this._culler.maxPos),t?(this.aabbHalfX=this._boundingBox.halfExtents.x,this.aabbHalfY=this._boundingBox.halfExtents.y,this.aabbHalfZ=this._boundingBox.halfExtents.z):(this.aabbHalfX?this.setBoundingX(this.aabbHalfX):this.aabbHalfX=this._boundingBox.halfExtents.x,this.aabbHalfY?this.setBoundingY(this.aabbHalfY):this.aabbHalfY=this._boundingBox.halfExtents.y,this.aabbHalfZ?this.setBoundingZ(this.aabbHalfZ):this.aabbHalfZ=this._boundingBox.halfExtents.z),this._culler.clear())},i.update=function(t){var e,i,n=t*this.simulationSpeed;if(this.renderCulling){var r;if(this._boundingBox||(this._boundingBox=new Qi,this._calculateBounding(!1)),this._curPos||(this._curPos=new ji),this.node.getWorldPosition(this._curPos),this._oldPos||(this._oldPos=new ji,this._oldPos.set(this._curPos)),!this._curPos.equals(this._oldPos)&&this._boundingBox&&this._culler){var s=this._curPos.x-this._oldPos.x,a=this._curPos.y-this._oldPos.y,o=this._curPos.z-this._oldPos.z,h=this._boundingBox.center;h.x+=s,h.y+=a,h.z+=o,this._culler.setBoundingBoxCenter(h.x,h.y,h.z),this._oldPos.set(this._curPos)}var l=null===(r=this.node.scene.renderScene)||void 0===r?void 0:r.cameras,u=!0;if(void 0!==l&&this._boundingBox)for(var c=0;c<l.length;++c){var d=l[c];if((d.visibility&this.node.layer)===this.node.layer&&Mr.aabbFrustum(this._boundingBox,d.frustum)){u=!1;break}}if(u){if(this._cullingMode!==JF.AlwaysSimulate&&(this._isSimulating=!1),this._isCulled||(this.processor.detachFromScene(),this._isCulled=!0),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene(),this._cullingMode===JF.PauseAndCatchup&&(this._time+=n),this._cullingMode!==JF.AlwaysSimulate)return}else this._isCulled&&(this._attachToScene(),this._isCulled=!1),this._isSimulating||(this._isSimulating=!0);if(!this._isSimulating)return}else this._boundingBox&&(this._boundingBox=null),this._culler&&(this._culler.clear(),this._culler.destroy(),this._culler=null),this._isSimulating=!0;if(this._isPlaying)this._time+=n,this._emit(n),0!==this.processor.updateParticles(n)||this._isEmitting||this.stop();else{var _=(this.getMaterialInstance(0)||this.processor.getDefaultMaterial()).passes[0];this.processor.updateRotation(_),this.processor.updateScale(_)}(this.processor.updateRenderData(),this._trailModule&&this._trailModule.enable&&this._trailModule.updateRenderData(),this._needAttach&&this.getParticleCount()>0&&!this._isCulled)&&(null!==(e=this.processor.getModel())&&void 0!==e&&e.scene||this.processor.attachToScene(),this._trailModule&&this._trailModule.enable&&(null!==(i=this._trailModule.getModel())&&void 0!==i&&i.scene||this._trailModule._attachToScene()),this._needAttach=!1);!this.renderer.useGPU&&this._trailModule&&this._trailModule.enable&&(this._trailModule._inited||(this._trailModule.clear(),this._trailModule.destroy(),this._trailModule.onInit(this),this._trailModule.enable=!1,this._trailModule.enable=!0))},i.beforeRender=function(){var t,e;this.getParticleCount()<=0?null!==(e=this.processor.getModel())&&void 0!==e&&e.scene&&(this.processor.detachFromScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene(),this._needAttach=!1):null!==(t=this.processor.getModel())&&void 0!==t&&t.scene||(this._needAttach=!0),this._isPlaying&&(this.processor.beforeRender(),this._trailModule&&this._trailModule.enable&&this._trailModule.beforeRender())},i._onVisibilityChange=function(t){this.processor._model&&(this.processor._model.visFlags=t)},i.emit=function(t,e){var i=this._time%this.duration/this.duration;this._needRefresh&&(this.node.invalidateChildren(pr.POSITION),this._needRefresh=!1),this._simulationSpace===QF.World&&(this.node.getWorldMatrix(Sz),this.node.getWorldRotation(Ez));for(var n=0;n<t;++n){var r=this.processor.getFreeParticle();if(null===r)return;r.particleSystem=this,r.reset();var s=va(ga(0,Ta));this._shapeModule&&this._shapeModule.enable?this._shapeModule.emit(r):(ji.set(r.position,0,0,0),ji.copy(r.velocity,aL)),this._textureAnimationModule&&this._textureAnimationModule.enable&&this._textureAnimationModule.init(r);var a=this.startSpeed.evaluate(i,s);ji.multiplyScalar(r.velocity,r.velocity,a),this._simulationSpace===QF.World&&(ji.transformMat4(r.position,r.position,Sz),ji.transformQuat(r.velocity,r.velocity,Ez)),ji.copy(r.ultimateVelocity,r.velocity),this.startRotation3D?r.startEuler.set(this.startRotationX.evaluate(i,s),this.startRotationY.evaluate(i,s),this.startRotationZ.evaluate(i,s)):r.startEuler.set(0,0,this.startRotationZ.evaluate(i,s)),r.rotation.set(r.startEuler),this.startSize3D?ji.set(r.startSize,this.startSizeX.evaluate(i,s),this.startSizeY.evaluate(i,s),this.startSizeZ.evaluate(i,s)):(ji.set(r.startSize,this.startSizeX.evaluate(i,s),1,1),r.startSize.y=r.startSize.x),ji.copy(r.size,r.startSize),r.startColor.set(this.startColor.evaluate(i,s)),r.color.set(r.startColor),r.startLifetime=this.startLifetime.evaluate(i,s)+e,r.remainingLifetime=r.startLifetime,r.randomSeed=ga(0,233280),r.loopCount++,this.processor.setNewParticle(r)}},i._prewarmSystem=function(){this.startDelay.mode=OO.Constant,this.startDelay.constant=0;for(var t=this.duration/1,e=0;e<t;++e)this._time+=1,this._emit(1),this.processor.updateParticles(1)},i._emit=function(t){var e=this.startDelay.evaluate(0,1);if(this._time>e){if(this._time>this.duration+e&&(this.loop||(this._isEmitting=!1)),!this._isEmitting)return;if(this._emitRateTimeCounter+=this.rateOverTime.evaluate(this._time/this.duration,1)*t,this._emitRateTimeCounter>1){var i=Math.floor(this._emitRateTimeCounter);this._emitRateTimeCounter-=i,this.emit(i,t)}var n=this.rateOverDistance.evaluate(this._time/this.duration,1);if(n>0){ji.copy(this._oldWPos,this._curWPos),this.node.getWorldPosition(this._curWPos);var r=ji.distance(this._curWPos,this._oldWPos);this._emitRateDistanceCounter+=r*n}if(this._emitRateDistanceCounter>1){var s=Math.floor(this._emitRateDistanceCounter);this._emitRateDistanceCounter-=s,this.emit(s,t)}for(var a,o=Fi(this.bursts);!(a=o()).done;)a.value.update(this,t)}},i._resetPosition=function(){this.node.getWorldPosition(this._oldWPos),ji.copy(this._curWPos,this._oldWPos)},i.addSubEmitter=function(t){this._subEmitters.push(t)},i.removeSubEmitter=function(t){this._subEmitters.splice(this._subEmitters.indexOf(t),1)},i.addBurst=function(t){this.bursts.push(t)},i.removeBurst=function(t){this.bursts.splice(this.bursts.indexOf(t),1)},i.getBoundingX=function(){return this._aabbHalfX},i.getBoundingY=function(){return this._aabbHalfY},i.getBoundingZ=function(){return this._aabbHalfZ},i.setBoundingX=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.x=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfX=t)},i.setBoundingY=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.y=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfY=t)},i.setBoundingZ=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.z=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfZ=t)},i._onBeforeSerialize=function(t){var e=this;return this.dataCulling?t.filter((function(t){return!qF.includes(t)||e[t]&&e[t].enable})):t},i.getNoisePreview=function(t,e){var i=[];return this.processor&&this.processor.getNoisePreview(i,t,e),i},Pi(e,[{key:"capacity",get:function(){return this._capacity},set:function(t){this._capacity=Math.floor(t>0?t:0),this.processor&&this.processor._model&&this.processor._model.setCapacity(this._capacity)}},{key:"prewarm",get:function(){return this._prewarm},set:function(t){!0===t&&this.loop,this._prewarm=t}},{key:"simulationSpace",get:function(){return this._simulationSpace},set:function(t){t!==this._simulationSpace&&(this._simulationSpace=t,this.processor&&(this.processor.updateMaterialParams(),this.processor.updateTrailMaterial()))}},{key:"renderCulling",get:function(){return this._renderCulling},set:function(t){this._renderCulling=t,t&&(this._boundingBox||(this._boundingBox=new Qi,this._calculateBounding(!1)))}},{key:"cullingMode",get:function(){return this._cullingMode},set:function(t){this._cullingMode=t}},{key:"aabbHalfX",get:function(){return this.getBoundingX()||0},set:function(t){this.setBoundingX(t)}},{key:"aabbHalfY",get:function(){return this.getBoundingY()||0},set:function(t){this.setBoundingY(t)}},{key:"aabbHalfZ",get:function(){return this.getBoundingZ()||0},set:function(t){this.setBoundingZ(t)}},{key:"dataCulling",get:function(){return this._dataCulling},set:function(t){this._dataCulling=t}},{key:"sharedMaterials",get:function(){return Az.get.call(this)},set:function(t){Az.set.call(this,t)}},{key:"colorOverLifetimeModule",get:function(){return this._colorOverLifetimeModule},set:function(t){t&&(this._colorOverLifetimeModule=t)}},{key:"shapeModule",get:function(){return this._shapeModule},set:function(t){t&&(this._shapeModule=t)}},{key:"sizeOvertimeModule",get:function(){return this._sizeOvertimeModule},set:function(t){t&&(this._sizeOvertimeModule=t)}},{key:"velocityOvertimeModule",get:function(){return this._velocityOvertimeModule},set:function(t){t&&(this._velocityOvertimeModule=t)}},{key:"forceOvertimeModule",get:function(){return this._forceOvertimeModule},set:function(t){t&&(this._forceOvertimeModule=t)}},{key:"limitVelocityOvertimeModule",get:function(){return this._limitVelocityOvertimeModule},set:function(t){t&&(this._limitVelocityOvertimeModule=t)}},{key:"rotationOvertimeModule",get:function(){return this._rotationOvertimeModule},set:function(t){t&&(this._rotationOvertimeModule=t)}},{key:"textureAnimationModule",get:function(){return this._textureAnimationModule},set:function(t){t&&(this._textureAnimationModule=t)}},{key:"noiseModule",get:function(){return this._noiseModule},set:function(t){t&&(this._noiseModule=t)}},{key:"trailModule",get:function(){return this._trailModule},set:function(t){t&&(this._trailModule=t)}},{key:"isPlaying",get:function(){return this._isPlaying}},{key:"isPaused",get:function(){return this._isPaused}},{key:"isStopped",get:function(){return this._isStopped}},{key:"isEmitting",get:function(){return this._isEmitting}},{key:"time",get:function(){return this._time}}]),e}(Bf),jH.CullingMode=JF,aH=tn((sH=KH).prototype,"startColor",[dV,en],(function(){return new BF})),oH=tn(sH.prototype,"scaleSpace",[_V,en],(function(){return QF.Local})),hH=tn(sH.prototype,"startSize3D",[en],(function(){return!1})),lH=tn(sH.prototype,"startSizeX",[fV,pV],(function(){return new FO})),uH=tn(sH.prototype,"startSizeY",[gV,en],(function(){return new FO})),cH=tn(sH.prototype,"startSizeZ",[mV,en],(function(){return new FO})),dH=tn(sH.prototype,"startSpeed",[vV,en],(function(){return new FO})),_H=tn(sH.prototype,"startRotation3D",[en],(function(){return!1})),fH=tn(sH.prototype,"startRotationX",[yV,en],(function(){return new FO})),pH=tn(sH.prototype,"startRotationY",[TV,en],(function(){return new FO})),gH=tn(sH.prototype,"startRotationZ",[SV,EV],(function(){return new FO})),mH=tn(sH.prototype,"startDelay",[AV,en],(function(){return new FO})),vH=tn(sH.prototype,"startLifetime",[CV,en],(function(){return new FO})),yH=tn(sH.prototype,"duration",[en],(function(){return 5})),TH=tn(sH.prototype,"loop",[en],(function(){return!0})),gn(sH.prototype,"simulationSpace",[RV,en],Object.getOwnPropertyDescriptor(sH.prototype,"simulationSpace"),sH.prototype),SH=tn(sH.prototype,"simulationSpeed",[en],(function(){return 1})),EH=tn(sH.prototype,"playOnAwake",[en],(function(){return!0})),AH=tn(sH.prototype,"gravityModifier",[bV,en],(function(){return new FO})),CH=tn(sH.prototype,"rateOverTime",[xV,en],(function(){return new FO})),RH=tn(sH.prototype,"rateOverDistance",[wV,en],(function(){return new FO})),bH=tn(sH.prototype,"bursts",[MV,en],(function(){return[]})),gn(sH.prototype,"renderCulling",[IV],Object.getOwnPropertyDescriptor(sH.prototype,"renderCulling"),sH.prototype),xH=tn(sH.prototype,"_renderCulling",[en],(function(){return!1})),gn(sH.prototype,"cullingMode",[BV],Object.getOwnPropertyDescriptor(sH.prototype,"cullingMode"),sH.prototype),wH=tn(sH.prototype,"_cullingMode",[en],(function(){return JF.Pause})),gn(sH.prototype,"aabbHalfX",[PV],Object.getOwnPropertyDescriptor(sH.prototype,"aabbHalfX"),sH.prototype),MH=tn(sH.prototype,"_aabbHalfX",[en],(function(){return 0})),gn(sH.prototype,"aabbHalfY",[DV],Object.getOwnPropertyDescriptor(sH.prototype,"aabbHalfY"),sH.prototype),IH=tn(sH.prototype,"_aabbHalfY",[en],(function(){return 0})),gn(sH.prototype,"aabbHalfZ",[OV],Object.getOwnPropertyDescriptor(sH.prototype,"aabbHalfZ"),sH.prototype),BH=tn(sH.prototype,"_aabbHalfZ",[en],(function(){return 0})),PH=tn(sH.prototype,"_dataCulling",[en,FV],(function(){return!1})),gn(sH.prototype,"sharedMaterials",[mn,LV,en],Object.getOwnPropertyDescriptor(sH.prototype,"sharedMaterials"),sH.prototype),DH=tn(sH.prototype,"_colorOverLifetimeModule",[NV],(function(){return null})),gn(sH.prototype,"colorOverLifetimeModule",[kV],Object.getOwnPropertyDescriptor(sH.prototype,"colorOverLifetimeModule"),sH.prototype),OH=tn(sH.prototype,"_shapeModule",[UV],(function(){return null})),gn(sH.prototype,"shapeModule",[GV],Object.getOwnPropertyDescriptor(sH.prototype,"shapeModule"),sH.prototype),FH=tn(sH.prototype,"_sizeOvertimeModule",[VV],(function(){return null})),gn(sH.prototype,"sizeOvertimeModule",[HV],Object.getOwnPropertyDescriptor(sH.prototype,"sizeOvertimeModule"),sH.prototype),LH=tn(sH.prototype,"_velocityOvertimeModule",[zV],(function(){return null})),gn(sH.prototype,"velocityOvertimeModule",[XV],Object.getOwnPropertyDescriptor(sH.prototype,"velocityOvertimeModule"),sH.prototype),NH=tn(sH.prototype,"_forceOvertimeModule",[WV],(function(){return null})),gn(sH.prototype,"forceOvertimeModule",[YV],Object.getOwnPropertyDescriptor(sH.prototype,"forceOvertimeModule"),sH.prototype),kH=tn(sH.prototype,"_limitVelocityOvertimeModule",[jV],(function(){return null})),gn(sH.prototype,"limitVelocityOvertimeModule",[KV],Object.getOwnPropertyDescriptor(sH.prototype,"limitVelocityOvertimeModule"),sH.prototype),UH=tn(sH.prototype,"_rotationOvertimeModule",[qV],(function(){return null})),gn(sH.prototype,"rotationOvertimeModule",[ZV],Object.getOwnPropertyDescriptor(sH.prototype,"rotationOvertimeModule"),sH.prototype),GH=tn(sH.prototype,"_textureAnimationModule",[QV],(function(){return null})),gn(sH.prototype,"textureAnimationModule",[JV],Object.getOwnPropertyDescriptor(sH.prototype,"textureAnimationModule"),sH.prototype),VH=tn(sH.prototype,"_noiseModule",[$V],(function(){return null})),gn(sH.prototype,"noiseModule",[tH],Object.getOwnPropertyDescriptor(sH.prototype,"noiseModule"),sH.prototype),HH=tn(sH.prototype,"_trailModule",[eH],(function(){return null})),gn(sH.prototype,"trailModule",[iH],Object.getOwnPropertyDescriptor(sH.prototype,"trailModule"),sH.prototype),zH=tn(sH.prototype,"renderer",[nH,en],(function(){return new iz})),XH=tn(sH.prototype,"_prewarm",[en],(function(){return!1})),WH=tn(sH.prototype,"_capacity",[en],(function(){return 100})),YH=tn(sH.prototype,"_simulationSpace",[en],(function(){return QF.Local})),rH=sH))||rH)||rH)),Rz=t("ParticleUtils",function(){function t(){}return t.instantiate=function(t){return this.registeredSceneEvent||(Di.on(An.EVENT_BEFORE_SCENE_LAUNCH,this.onSceneUnload,this),this.registeredSceneEvent=!0),this.particleSystemPool.has(t._uuid)||this.particleSystemPool.set(t._uuid,new e((function(){return rI(t)||new Pr}),1,(function(t){return t.destroy()}))),this.particleSystemPool.get(t._uuid).alloc()},t.destroy=function(t){this.particleSystemPool.has(t._prefab.asset._uuid)&&(this.stop(t),this.particleSystemPool.get(t._prefab.asset._uuid).free(t))},t.play=function(t){for(var e,i=Fi(t.getComponentsInChildren(Cz));!(e=i()).done;)e.value.play()},t.stop=function(t){for(var e,i=Fi(t.getComponentsInChildren(Cz));!(e=i()).done;)e.value.stop()},t.onSceneUnload=function(){this.particleSystemPool.forEach((function(t){return t.destroy()})),this.particleSystemPool.clear()},t}());function bz(t){We._global.CC_PHYSICS_BUILTIN="builtin"===t,We._global.CC_PHYSICS_CANNON="cannon.js"===t,We._global.CC_PHYSICS_AMMO="bullet"===t}Rz.particleSystemPool=new Map,Rz.registeredSceneEvent=!1,Vn(Qk.prototype,"Burst.prototype",[{name:"minCount"},{name:"maxCount"}]),zn(Cz.prototype,"ParticleSystem.prototype",[{name:"enableCulling",newName:"dataCulling"}]),We.ParticleSystemComponent=Cz,br(Cz,"cc.ParticleSystemComponent"),We.BillboardComponent=xO,br(xO,"cc.BillboardComponent"),We.LineComponent=FF,br(FF,"cc.LineComponent"),We.ParticleUtils=Rz,function(t){t[t.DYNAMIC=1]="DYNAMIC",t[t.STATIC=2]="STATIC",t[t.KINEMATIC=4]="KINEMATIC"}(qH||(qH=t("ERigidBodyType",{}))),fr(qH),function(t){t[t.X_AXIS=0]="X_AXIS",t[t.Y_AXIS=1]="Y_AXIS",t[t.Z_AXIS=2]="Z_AXIS"}(ZH||(ZH=t("EAxisDirection",{}))),fr(ZH),function(t){t[t.VERTEX=1]="VERTEX",t[t.LINE=2]="LINE",t[t.TRIANGLE=3]="TRIANGLE",t[t.TETRAHEDRON=4]="TETRAHEDRON"}(QH||(QH={})),fr(QH),function(t){t[t.BOX=0]="BOX",t[t.SPHERE=1]="SPHERE",t[t.CAPSULE=2]="CAPSULE",t[t.CYLINDER=3]="CYLINDER",t[t.CONE=4]="CONE",t[t.MESH=5]="MESH",t[t.PLANE=6]="PLANE",t[t.SIMPLEX=7]="SIMPLEX",t[t.TERRAIN=8]="TERRAIN"}(JH||(JH={})),fr(JH),function(t){t[t.POINT_TO_POINT=0]="POINT_TO_POINT",t[t.HINGE=1]="HINGE",t[t.CONE_TWIST=2]="CONE_TWIST",t[t.FIXED=3]="FIXED"}($H||($H={})),fr($H),function(t){t[t.DEFAULT=1]="DEFAULT"}(tz||(tz={})),fr(tz);var xz,wz={id:"",switchTo:function(t){if(wz.runInEditor){var e=wz;if(wz.physicsWorld&&t!==wz.id&&null!=wz.backend[t]?(wz.physicsWorld.destroy(),console.info("[PHYSICS]: switch from "+wz.id+" to "+t+"."),bz(t),e.id=t,e.wrapper=wz.backend[t],e.physicsWorld=Pz()):(console.info("[PHYSICS]: using "+t+"."),e.physicsWorld=Pz()),ez){var i=e.physicsWorld;i.setGravity(ez.gravity),i.setAllowSleep(ez.allowSleep)}}},register:function(t,e){if(console.info("[PHYSICS]: register "+t+"."),wz.backend[t]=e,!wz.physicsWorld||wz.id===t){bz(t);var i=wz;i.id=t,i.wrapper=e}},wrapper:{},backend:{},physicsWorld:null,runInEditor:!aa},Mz=function(){return 0},Iz={impl:null,setGravity:Mz,setAllowSleep:Mz,setDefaultMaterial:Mz,step:Mz,syncAfterEvents:Mz,syncSceneToPhysics:Mz,raycast:Mz,raycastClosest:Mz,emitEvents:Mz,destroy:Mz};function Bz(t,e){return null==t&&(wz.id?Gi(wz.id+" physics does not support "+xz[e]):hn(9600),!0)}function Pz(){return Bz(wz.wrapper.PhysicsWorld,xz.World)?Iz:new wz.wrapper.PhysicsWorld}!function(t){t[t.World=0]="World",t[t.RigidBody=1]="RigidBody",t[t.BoxCollider=2]="BoxCollider",t[t.SphereCollider=3]="SphereCollider",t[t.CapsuleCollider=4]="CapsuleCollider",t[t.MeshCollider=5]="MeshCollider",t[t.CylinderCollider=6]="CylinderCollider",t[t.ConeCollider=7]="ConeCollider",t[t.TerrainCollider=8]="TerrainCollider",t[t.SimplexCollider=9]="SimplexCollider",t[t.PlaneCollider=10]="PlaneCollider",t[t.PointToPointConstraint=11]="PointToPointConstraint",t[t.HingeConstraint=12]="HingeConstraint",t[t.ConeTwistConstraint=13]="ConeTwistConstraint",t[t.FixedConstraint=14]="FixedConstraint"}(xz||(xz={}));var Dz={impl:null,rigidBody:null,isAwake:!1,isSleepy:!1,isSleeping:!1,initialize:Mz,onEnable:Mz,onDisable:Mz,onDestroy:Mz,setType:Mz,setMass:Mz,setLinearDamping:Mz,setAngularDamping:Mz,useGravity:Mz,setLinearFactor:Mz,setAngularFactor:Mz,setAllowSleep:Mz,wakeUp:Mz,sleep:Mz,clearState:Mz,clearForces:Mz,clearVelocity:Mz,setSleepThreshold:Mz,getSleepThreshold:Mz,getLinearVelocity:Mz,setLinearVelocity:Mz,getAngularVelocity:Mz,setAngularVelocity:Mz,applyForce:Mz,applyLocalForce:Mz,applyImpulse:Mz,applyLocalImpulse:Mz,applyTorque:Mz,applyLocalTorque:Mz,setGroup:Mz,getGroup:Mz,addGroup:Mz,removeGroup:Mz,setMask:Mz,getMask:Mz,addMask:Mz,removeMask:Mz,isUsingCCD:Mz,useCCD:Mz},Oz={INITED:!1},Fz={impl:null,collider:null,attachedRigidBody:null,initialize:Mz,onLoad:Mz,onEnable:Mz,onDisable:Mz,onDestroy:Mz,setGroup:Mz,getGroup:Mz,addGroup:Mz,removeGroup:Mz,setMask:Mz,getMask:Mz,addMask:Mz,removeMask:Mz,setMaterial:Mz,setAsTrigger:Mz,setCenter:Mz,getAABB:Mz,getBoundingSphere:Mz,updateSize:Mz,updateRadius:Mz,setRadius:Mz,setCylinderHeight:Mz,setDirection:Mz,setHeight:Mz,setShapeType:Mz,setVertices:Mz,setMesh:Mz,setTerrain:Mz,setNormal:Mz,setConstant:Mz,updateEventListener:Mz};var Lz={INITED:!1},Nz={impl:null,initialize:Mz,onLoad:Mz,onEnable:Mz,onDisable:Mz,onDestroy:Mz,setEnableCollision:Mz,setConnectedBody:Mz,setPivotA:Mz,setPivotB:Mz,setAxis:Mz,setBreakForce:Mz,setBreakTorque:Mz};var kz={type:"onTriggerEnter",selfCollider:null,otherCollider:null,impl:null},Uz={type:"onCollisionEnter",selfCollider:null,otherCollider:null,contacts:[],impl:null},Gz=function(){function t(){this.BT_TRANSFORM_0=Sa.Transform_new(),this.BT_TRANSFORM_1=Sa.Transform_new(),this.BT_V3_0=Sa.Vec3_new(0,0,0),this.BT_V3_1=Sa.Vec3_new(0,0,0),this.BT_V3_2=Sa.Vec3_new(0,0,0),this.BT_QUAT_0=Sa.Quat_new(0,0,0,1)}return t.setWrapper=function(t,e,i){this.ROOT[e]||(this.ROOT[e]={}),this.ROOT[e][t]=i},t.delWrapper=function(t,e){delete this.ROOT[e][t]},t.getWrapper=function(t,e){return this.ROOT[e][t]},t.isNotEmptyShape=function(t){return t!==Sa.EmptyShape_static()},Pi(t,null,[{key:"instance",get:function(){return null==t._instance&&(t._instance=new t),t._instance}}]),t}();Gz._instance=void 0,Gz.ROOT={};var Vz,Hz,zz,Xz,Wz,Yz,jz,Kz,qz=new ji,Zz=new ji,Qz=new Ji,Jz=new Ue;function $z(t,e){return Sa.Vec3_set(t,e.x,e.y,e.z),t}function tX(t,e){return t.x=Sa.Vec3_x(e),t.y=Sa.Vec3_y(e),t.z=Sa.Vec3_z(e),t}function eX(t,e){return Sa.Quat_set(t,e.x,e.y,e.z,e.w),t}function iX(t,e){return t.x=Sa.Quat_x(e),t.y=Sa.Quat_y(e),t.z=Sa.Quat_z(e),t.w=Sa.Quat_w(e),t}function nX(t,e){for(var i=e.renderingSubMeshes.length,n=0;n<i;n++){var r=e.renderingSubMeshes[n],s=r.geometricInfo;if(s){var a=r.primitiveMode,o=s.positions,h=s.indices,l=Gz.instance.BT_V3_0,u=Gz.instance.BT_V3_1,c=Gz.instance.BT_V3_2;if(a===U.TRIANGLE_LIST)for(var d=h.length,_=0;_<d;_+=3){var f=3*h[_],p=3*h[_+1],g=3*h[_+2];Sa.Vec3_set(l,o[f],o[f+1],o[f+2]),Sa.Vec3_set(u,o[p],o[p+1],o[p+2]),Sa.Vec3_set(c,o[g],o[g+1],o[g+2]),Sa.TriangleMesh_addTriangle(t,l,u,c)}else if(a===U.TRIANGLE_STRIP)for(var m=h.length-2,v=0,y=0;y<m;y+=1){var T=3*h[y-v],S=3*h[y+v+1],E=3*h[y+2];v=~v,Sa.Vec3_set(l,o[T],o[T+1],o[T+2]),Sa.Vec3_set(u,o[S],o[S+1],o[S+2]),Sa.Vec3_set(c,o[E],o[E+1],o[E+2]),Sa.TriangleMesh_addTriangle(t,l,u,c)}else if(a===U.TRIANGLE_FAN){var A=h.length-1,C=3*h[0];Sa.Vec3_set(l,o[C],o[C+1],o[C+2]);for(var R=1;R<A;R+=1){var b=3*h[R],x=3*h[R+1];Sa.Vec3_set(u,o[b],o[b+1],o[b+2]),Sa.Vec3_set(c,o[x],o[x+1],o[x+2]),Sa.TriangleMesh_addTriangle(t,l,u,c)}}}}return t}new Ue,Sa.CACHE=Gz;var rX=function(e){return t({PhysicsMaterial:e,PhysicMaterial:e}),e}(Ki("cc.PhysicsMaterial")((Kz=jz=function(t){function e(){var i;return(i=t.call(this)||this).id=void 0,i._friction=zz&&zz(),i._rollingFriction=Xz&&Xz(),i._spinningFriction=Wz&&Wz(),i._restitution=Yz&&Yz(),e.allMaterials.push(lr(i)),i.id=e._idCounter++,i._uuid||(i._uuid="pm_"+i.id),i}He(e,t);var i=e.prototype;return i.clone=function(){var t=new e;return t._friction=this._friction,t._restitution=this._restitution,t._rollingFriction=this._rollingFriction,t._spinningFriction=this._spinningFriction,t},i.destroy=function(){if(t.prototype.destroy.call(this)){var i=e.allMaterials.indexOf(this);return i>=0&&e.allMaterials.splice(i,1),!0}return!1},i.setValues=function(t,i,n,r){var s=this._friction!==t||this._rollingFriction!==i||this._spinningFriction!==n||this._restitution!==r;this._friction=t,this._rollingFriction=i,this._spinningFriction=n,this._restitution=r,s&&this.emit(e.EVENT_UPDATE)},Pi(e,[{key:"friction",get:function(){return this._friction},set:function(t){Ea(this._friction,t)||(this._friction=t,this.emit(e.EVENT_UPDATE))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){Ea(this._rollingFriction,t)||(this._rollingFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"spinningFriction",get:function(){return this._spinningFriction},set:function(t){Ea(this._spinningFriction,t)||(this._spinningFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"restitution",get:function(){return this._restitution},set:function(t){Ea(this._restitution,t)||(this._restitution=t,this.emit(e.EVENT_UPDATE))}}]),e}($i),jz.allMaterials=[],jz.EVENT_UPDATE="event_update",jz._idCounter=0,zz=tn((Hz=Kz).prototype,"_friction",[en],(function(){return.6})),Xz=tn(Hz.prototype,"_rollingFriction",[en],(function(){return 0})),Wz=tn(Hz.prototype,"_spinningFriction",[en],(function(){return 0})),Yz=tn(Hz.prototype,"_restitution",[en],(function(){return 0})),Vz=Hz))||Vz),sX=t("PhysicsRayResult",function(){function t(){this._hitPoint=new ji,this._hitNormal=new ji,this._distance=0,this._collider=null}var e=t.prototype;return e._assign=function(t,e,i,n){ji.copy(this._hitPoint,t),ji.copy(this._hitNormal,n),this._distance=e,this._collider=i},e.clone=function(){var e=new t;return ji.copy(e._hitPoint,this._hitPoint),ji.copy(e._hitNormal,this._hitNormal),e._distance=this._distance,e._collider=this._collider,e},Pi(t,[{key:"hitPoint",get:function(){return this._hitPoint}},{key:"distance",get:function(){return this._distance}},{key:"collider",get:function(){return this._collider}},{key:"hitNormal",get:function(){return this._hitNormal}}]),t}()),aX=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._id=0,e}He(e,t);var i=e.prototype;return i._assign=function(e,i,n,r,s){void 0===s&&(s=0),t.prototype._assign.call(this,e,i,n,r),this._id=s},i.clone=function(){var t=new e;return ji.copy(t._hitPoint,this._hitPoint),ji.copy(t._hitNormal,this._hitNormal),t._distance=this._distance,t._collider=this._collider,t._id=this._id,t},Pi(e,[{key:"id",get:function(){return this._id}}]),e}(sX),oX=function(t){if(1===t){for(var e=this,i=function(t){var i="_"+(1<<t);e[i]=0,e.updateArray=[],Object.defineProperty(e,1<<t,{get:function(){return this[i]},set:function(e){this[i]!==e&&(this[i]=e,this.updateArray.indexOf(t)<0&&this.updateArray.push(t))}})},n=0;n<32;n++)i(n);this._1=tz.DEFAULT}else{for(var r=0;r<32;r++)this[""+(1<<r)]=0;this[1]=tz.DEFAULT}};We.internal.PhysicsGroup=tz;var hX,lX,uX,cX,dX,_X,fX,pX,gX,mX,vX,yX,TX,SX,EX,AX,CX,RX=t("PhysicsSystem",function(t){He(n,t);var e=n.prototype;function n(){var e;return(e=t.call(this)||this).raycastClosestResult=new sX,e.raycastResults=[],e.lineStripCastClosestResult=new aX,e.lineStripCastResults=[],e.collisionMatrix=new oX(1),e.minVolumeSize=1e-5,e.useNodeChains=!1,e._enable=!0,e._allowSleep=!0,e._maxSubSteps=1,e._subStepCount=0,e._fixedTimeStep=1/60,e._autoSimulation=!0,e._accumulator=0,e._sleepThreshold=.1,e._gravity=new ji(0,-10,0),e.raycastOptions={group:-1,mask:-1,queryTrigger:!0,maxDistance:1e7},e.raycastResultPool=new i((function(){return new sX}),1),e}return e.setDefaultPhysicsMaterial=function(t){this._material=t,this.physicsWorld.setDefaultMaterial(this._material),this._material.on(rX.EVENT_UPDATE,this._updateMaterial,this)},e.initDefaultMaterial=function(){var t=this;if(null!=this._material)return Promise.resolve();var e=Nn.get("default-physics-material");if(!e)return console.error("PhysicsSystem initDefaultMaterial() Failed to load builtinMaterial"),Promise.resolve();var i=Tr.querySettings(Sr.Category.PHYSICS,"defaultMaterial");return i?new Promise((function(t,e){Aa.loadAny(i,(function(i,n){return!i&&n instanceof rX?t(n):e(i)}))})).then((function(e){t.setDefaultPhysicsMaterial(e)})).catch((function(n){Gi(n),Gi("Failed to load user customized default physics material: "+i+", will fallback to built-in default physics material"),t.setDefaultPhysicsMaterial(e)})):(this.setDefaultPhysicsMaterial(e),Promise.resolve())},e.postUpdate=function(t){if(this.physicsWorld)if(this._enable){if(this._autoSimulation){for(this._subStepCount=0,this._accumulator+=t,Di.emit(An.EVENT_BEFORE_PHYSICS);this._subStepCount<this._maxSubSteps;){if(!(this._accumulator>=this._fixedTimeStep)){this.physicsWorld.syncSceneToPhysics();break}this.physicsWorld.syncSceneToPhysics(),this.physicsWorld.step(this._fixedTimeStep),this.physicsWorld.emitEvents(),this.physicsWorld.syncAfterEvents(),this._accumulator-=this._fixedTimeStep,this._subStepCount++}Di.emit(An.EVENT_AFTER_PHYSICS)}}else this.physicsWorld.syncSceneToPhysics()},e.resetConfiguration=function(t){var e=t?t.allowSleep:Tr.querySettings(Sr.Category.PHYSICS,"allowSleep");"boolean"==typeof e&&(this._allowSleep=e);var i=t?t.fixedTimeStep:Tr.querySettings(Sr.Category.PHYSICS,"fixedTimeStep");"number"==typeof i&&(this._fixedTimeStep=i);var n=t?t.maxSubSteps:Tr.querySettings(Sr.Category.PHYSICS,"maxSubSteps");"number"==typeof n&&(this._maxSubSteps=n);var r=t?t.sleepThreshold:Tr.querySettings(Sr.Category.PHYSICS,"sleepThreshold");"number"==typeof r&&(this._sleepThreshold=r);var s=t?t.autoSimulation:Tr.querySettings(Sr.Category.PHYSICS,"autoSimulation");"boolean"==typeof s&&(this.autoSimulation=s);var a=t?t.gravity:Tr.querySettings(Sr.Category.PHYSICS,"gravity");a&&ji.copy(this._gravity,a);var o=t?t.collisionMatrix:Tr.querySettings(Sr.Category.PHYSICS,"collisionMatrix");if(o)for(var h in o)this.collisionMatrix[""+(1<<parseInt(h))]=o[h];var l=t?t.collisionGroups:Tr.querySettings(Sr.Category.PHYSICS,"collisionGroups");l&&l instanceof Array&&(l.forEach((function(t){tz[t.name]=1<<t.index})),fr.update(tz)),this.physicsWorld&&(this.physicsWorld.setGravity(this._gravity),this.physicsWorld.setAllowSleep(this._allowSleep))},e.resetAccumulator=function(t){void 0===t&&(t=0),this._accumulator=t},e.step=function(t,e,i){this.physicsWorld&&this.physicsWorld.step(t,e,i)},e.syncSceneToPhysics=function(){this.physicsWorld&&this.physicsWorld.syncSceneToPhysics()},e.emitEvents=function(){this.physicsWorld&&this.physicsWorld.emitEvents()},e.raycast=function(t,e,i,n){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),!!this.physicsWorld&&(this.raycastResultPool.reset(),this.raycastResults.length=0,this.raycastOptions.mask=e>>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=n,this.physicsWorld.raycast(t,this.raycastOptions,this.raycastResultPool,this.raycastResults))},e.raycastClosest=function(t,e,i,n){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),!!this.physicsWorld&&(this.raycastOptions.mask=e>>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=n,this.physicsWorld.raycastClosest(t,this.raycastOptions,this.raycastClosestResult))},e.lineStripCast=function(t,e,i,n){if(void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),t.length<2)return!1;this.lineStripCastResults=[];for(var r=0,s=new gr,a=1;a<t.length&&!(r>i);++a){var o=t[a-1],h=t[a],l=new ji;ji.subtract(l,h,o);var u=ji.len(l);if(r+=u,ji.multiplyScalar(l,l,1/u),s.d=l,s.o=o,this.raycast(s,e,u,n))for(var c=0;c<this.raycastResults.length;c++){var d=this.raycastResults[c];if(0!==c||!ji.equals(o,d.hitPoint)){var _=new aX;_._assign(d.hitPoint,d.distance,d.collider,d.hitNormal,a-1),this.lineStripCastResults.push(_)}}}return this.lineStripCastResults.length>0},e.lineStripCastClosest=function(t,e,i,n){if(void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),t.length<2)return!1;for(var r=0,s=new gr,a=!1,o=1;o<t.length&&!(r>i);++o){var h=t[o-1],l=t[o],u=new ji;ji.subtract(u,l,h);var c=ji.len(u);if(r+=c,ji.multiplyScalar(u,u,1/c),s.d=u,s.o=h,a=this.raycastClosest(s,e,c,n)){var d=this.raycastClosestResult,_=new aX;_._assign(d.hitPoint,d.distance,d.collider,d.hitNormal,o-1),this.lineStripCastClosestResult=_;break}}return a},e._updateMaterial=function(){this.physicsWorld&&this.physicsWorld.setDefaultMaterial(this._material)},n.constructAndRegister=function(){var t;if((null===(t=Tr.querySettings(Sr.Category.PHYSICS,"enabled"))||void 0===t||t)&&!n._instance){var e=new n;e.resetConfiguration(),function(t){if(ez||(ez=t),wz.runInEditor&&!wz.physicsWorld){console.info("[PHYSICS]: using "+wz.id+".");var e=wz.physicsWorld=Pz();e.setGravity(ez.gravity),e.setAllowSleep(ez.allowSleep)}}(e),n._instance=e,Di.registerSystem(n.ID,e,e.priority),qr.onPostProjectInitDelegate.add(e.initDefaultMaterial.bind(e))}},Pi(n,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this.physicsWorld&&this.physicsWorld.setAllowSleep(t)}},{key:"maxSubSteps",get:function(){return this._maxSubSteps},set:function(t){this._maxSubSteps=t}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(t){this._fixedTimeStep=t}},{key:"gravity",get:function(){return this._gravity},set:function(t){this._gravity.set(t),this.physicsWorld&&this.physicsWorld.setGravity(t)}},{key:"sleepThreshold",get:function(){return this._sleepThreshold},set:function(t){this._sleepThreshold=t}},{key:"autoSimulation",get:function(){return this._autoSimulation},set:function(t){this._autoSimulation=t}},{key:"defaultMaterial",get:function(){return this._material}},{key:"physicsWorld",get:function(){return wz.physicsWorld}}],[{key:"PHYSICS_NONE",get:function(){return!wz.id}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===wz.id}},{key:"PHYSICS_CANNON",get:function(){return"cannon.js"===wz.id}},{key:"PHYSICS_BULLET",get:function(){return"bullet"===wz.id}},{key:"PHYSICS_PHYSX",get:function(){return"physx"===wz.id}},{key:"PhysicsGroup",get:function(){return tz}},{key:"instance",get:function(){return n._instance}}]),n}(Oi));RX.ID="PHYSICS",RX._instance=null,Di.once(An.EVENT_INIT,(function(){RX.constructAndRegister()}));var bX,xX,wX,MX,IX,BX,PX,DX,OX,FX,LX,NX,kX=function(e){return t({RigidBody:e,RigidBodyComponent:e}),e}((hX=Ki("cc.RigidBody"),lX=In(-1),uX=Tn(RX.PhysicsGroup),cX=Tn(qH),hX(dX=bn(dX=lX((CX=AX=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._body=null,e._group=fX&&fX(),e._type=pX&&pX(),e._mass=gX&&gX(),e._allowSleep=mX&&mX(),e._linearDamping=vX&&vX(),e._angularDamping=yX&&yX(),e._useGravity=TX&&TX(),e._linearFactor=SX&&SX(),e._angularFactor=EX&&EX(),e}He(e,t);var i=e.prototype;return i.onLoad=function(){wz.runInEditor&&(this._body=Bz(wz.wrapper.RigidBody,xz.RigidBody)?Dz:new wz.wrapper.RigidBody,this._body.initialize(this))},i.onEnable=function(){this._body&&this._body.onEnable()},i.onDisable=function(){this._body&&this._body.onDisable()},i.onDestroy=function(){this._body&&this._body.onDestroy()},i.applyForce=function(t,e){this._isInitialized&&this._body.applyForce(t,e)},i.applyLocalForce=function(t,e){this._isInitialized&&this._body.applyLocalForce(t,e)},i.applyImpulse=function(t,e){this._isInitialized&&this._body.applyImpulse(t,e)},i.applyLocalImpulse=function(t,e){this._isInitialized&&this._body.applyLocalImpulse(t,e)},i.applyTorque=function(t){this._isInitialized&&this._body.applyTorque(t)},i.applyLocalTorque=function(t){this._isInitialized&&this._body.applyLocalTorque(t)},i.wakeUp=function(){this._isInitialized&&this._body.wakeUp()},i.sleep=function(){this._isInitialized&&this._body.sleep()},i.clearState=function(){this._isInitialized&&this._body.clearState()},i.clearForces=function(){this._isInitialized&&this._body.clearForces()},i.clearVelocity=function(){this._isInitialized&&this._body.clearVelocity()},i.getLinearVelocity=function(t){this._isInitialized&&this._body.getLinearVelocity(t)},i.setLinearVelocity=function(t){this._isInitialized&&this._body.setLinearVelocity(t)},i.getAngularVelocity=function(t){this._isInitialized&&this._body.getAngularVelocity(t)},i.setAngularVelocity=function(t){this._isInitialized&&this._body.setAngularVelocity(t)},i.getGroup=function(){return this._isInitialized?this._body.getGroup():0},i.setGroup=function(t){this._isInitialized&&this._body.setGroup(t)},i.addGroup=function(t){this._isInitialized&&this._body.addGroup(t)},i.removeGroup=function(t){this._isInitialized&&this._body.removeGroup(t)},i.getMask=function(){return this._isInitialized?this._body.getMask():0},i.setMask=function(t){this._isInitialized&&this._body.setMask(t)},i.addMask=function(t){this._isInitialized&&this._body.addMask(t)},i.removeMask=function(t){this._isInitialized&&this._body.removeMask(t)},Pi(e,[{key:"group",get:function(){return this._group},set:function(t){this._group=t,this._body&&this._body.getGroup()!==t&&this._body.setGroup(t)}},{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this._body&&this._body.setType(t))}},{key:"mass",get:function(){return this._mass},set:function(t){this._mass!==t&&(t=t<=0?1e-4:t,this._mass=t,this._body&&this._body.setMass(t))}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this._body&&this._body.setAllowSleep(t)}},{key:"linearDamping",get:function(){return this._linearDamping},set:function(t){this._linearDamping=t,this._body&&this._body.setLinearDamping(t)}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(t){this._angularDamping=t,this._body&&this._body.setAngularDamping(t)}},{key:"useGravity",get:function(){return this._useGravity},set:function(t){this._useGravity=t,this._body&&this._body.useGravity(t)}},{key:"linearFactor",get:function(){return this._linearFactor},set:function(t){ji.copy(this._linearFactor,t),this._body&&this._body.setLinearFactor(this._linearFactor)}},{key:"angularFactor",get:function(){return this._angularFactor},set:function(t){ji.copy(this._angularFactor,t),this._body&&this._body.setAngularFactor(this._angularFactor)}},{key:"sleepThreshold",get:function(){return this._isInitialized?this._body.getSleepThreshold():.1},set:function(t){this._isInitialized&&this._body.setSleepThreshold(t)}},{key:"useCCD",get:function(){return!!this._isInitialized&&this._body.isUsingCCD()},set:function(t){this._isInitialized&&this._body.useCCD(t)}},{key:"isAwake",get:function(){return!!this._isInitialized&&this._body.isAwake}},{key:"isSleepy",get:function(){return!!this._isInitialized&&this._body.isSleepy}},{key:"isSleeping",get:function(){return!!this._isInitialized&&this._body.isSleeping}},{key:"isStatic",get:function(){return this._type===qH.STATIC},set:function(t){t&&this.isStatic||!t&&!this.isStatic||(this.type=t?qH.STATIC:qH.DYNAMIC)}},{key:"isDynamic",get:function(){return this._type===qH.DYNAMIC},set:function(t){t&&this.isDynamic||!t&&!this.isDynamic||(this.type=t?qH.DYNAMIC:qH.KINEMATIC)}},{key:"isKinematic",get:function(){return this._type===qH.KINEMATIC},set:function(t){t&&this.isKinematic||!t&&!this.isKinematic||(this.type=t?qH.KINEMATIC:qH.DYNAMIC)}},{key:"body",get:function(){return this._body}},{key:"_isInitialized",get:function(){var t=null===this._body;return t&&ks("[Physics]: This component has not been call onLoad yet, please make sure the node has been added to the scene."),!t}}]),e}(Pn),AX.Type=qH,gn((_X=CX).prototype,"group",[uX],Object.getOwnPropertyDescriptor(_X.prototype,"group"),_X.prototype),gn(_X.prototype,"type",[cX],Object.getOwnPropertyDescriptor(_X.prototype,"type"),_X.prototype),fX=tn(_X.prototype,"_group",[en],(function(){return RX.PhysicsGroup.DEFAULT})),pX=tn(_X.prototype,"_type",[en],(function(){return qH.DYNAMIC})),gX=tn(_X.prototype,"_mass",[en],(function(){return 1})),mX=tn(_X.prototype,"_allowSleep",[en],(function(){return!0})),vX=tn(_X.prototype,"_linearDamping",[en],(function(){return.1})),yX=tn(_X.prototype,"_angularDamping",[en],(function(){return.1})),TX=tn(_X.prototype,"_useGravity",[en],(function(){return!0})),SX=tn(_X.prototype,"_linearFactor",[en],(function(){return new ji(1,1,1)})),EX=tn(_X.prototype,"_angularFactor",[en],(function(){return new ji(1,1,1)})),dX=_X))||dX)||dX)||dX));kX||(kX=function(e){return t({RigidBody:e,RigidBodyComponent:e}),e}({}));var UX=function(e){return t({Collider:e,ColliderComponent:e}),e}((bX=Ki("cc.Collider"),xX=Tn(kX),wX=Tn(rX),MX=Tn(ji),IX=Tn(rX),bX((NX=LX=function(t){function e(e){var i;return(i=t.call(this)||this).type=void 0,i._shape=null,i._aabb=null,i._boundingSphere=null,i._isSharedMaterial=!0,i._needTriggerEvent=!1,i._needCollisionEvent=!1,i._material=DX&&DX(),i._isTrigger=OX&&OX(),i._center=FX&&FX(),i.type=e,i}He(e,t);var i=e.prototype;return i.on=function(e,i,n,r){var s=t.prototype.on.call(this,e,i,n,r);return this._updateNeedEvent(e),s},i.off=function(e,i,n){t.prototype.off.call(this,e,i,n),this._updateNeedEvent()},i.once=function(e,i,n){var r=t.prototype.once.call(this,e,i,n);return this._updateNeedEvent(e),r},i.removeAll=function(e){t.prototype.removeAll.call(this,e),this._updateNeedEvent()},i.getGroup=function(){return this._isInitialized?this._shape.getGroup():0},i.setGroup=function(t){this._isInitialized&&this._shape.setGroup(t)},i.addGroup=function(t){this._isInitialized&&this._shape.addGroup(t)},i.removeGroup=function(t){this._isInitialized&&this._shape.removeGroup(t)},i.getMask=function(){return this._isInitialized?this._shape.getMask():0},i.setMask=function(t){this._isInitialized&&this._shape.setMask(t)},i.addMask=function(t){this._isInitialized&&this._shape.addMask(t)},i.removeMask=function(t){this._isInitialized&&this._shape.removeMask(t)},i.onLoad=function(){wz.runInEditor&&(this.sharedMaterial=this._material,this._shape=function(t){return Oz.INITED||(Oz.INITED=!0,Oz[JH.BOX]=function(){return Bz(wz.wrapper.BoxShape,xz.BoxCollider)?Fz:new wz.wrapper.BoxShape},Oz[JH.SPHERE]=function(){return Bz(wz.wrapper.SphereShape,xz.SphereCollider)?Fz:new wz.wrapper.SphereShape},Oz[JH.CAPSULE]=function(){return Bz(wz.wrapper.CapsuleShape,xz.CapsuleCollider)?Fz:new wz.wrapper.CapsuleShape},Oz[JH.CYLINDER]=function(){return Bz(wz.wrapper.CylinderShape,xz.CylinderCollider)?Fz:new wz.wrapper.CylinderShape},Oz[JH.CONE]=function(){return Bz(wz.wrapper.ConeShape,xz.ConeCollider)?Fz:new wz.wrapper.ConeShape},Oz[JH.MESH]=function(){return Bz(wz.wrapper.TrimeshShape,xz.MeshCollider)?Fz:new wz.wrapper.TrimeshShape},Oz[JH.TERRAIN]=function(){return Bz(wz.wrapper.TerrainShape,xz.TerrainCollider)?Fz:new wz.wrapper.TerrainShape},Oz[JH.SIMPLEX]=function(){return Bz(wz.wrapper.SimplexShape,xz.SimplexCollider)?Fz:new wz.wrapper.SimplexShape},Oz[JH.PLANE]=function(){return Bz(wz.wrapper.PlaneShape,xz.PlaneCollider)?Fz:new wz.wrapper.PlaneShape}),Oz[t]()}(this.type),this._shape.initialize(this),this._shape.onLoad())},i.onEnable=function(){this._shape&&this._shape.onEnable()},i.onDisable=function(){this._shape&&this._shape.onDisable()},i.onDestroy=function(){this._shape&&(this._needTriggerEvent=!1,this._needCollisionEvent=!1,this._shape.updateEventListener(),this._material&&this._material.off(rX.EVENT_UPDATE,this._updateMaterial,this),this._shape.onDestroy()),this._boundingSphere&&this._boundingSphere.destroy()},i._updateMaterial=function(){this._shape&&this._shape.setMaterial(this._material)},i._updateNeedEvent=function(t){this.isValid&&(void 0!==t?("onCollisionEnter"!==t&&"onCollisionStay"!==t&&"onCollisionExit"!==t||(this._needCollisionEvent=!0),"onTriggerEnter"!==t&&"onTriggerStay"!==t&&"onTriggerExit"!==t||(this._needTriggerEvent=!0)):(this.hasEventListener("onTriggerEnter")||this.hasEventListener("onTriggerStay")||this.hasEventListener("onTriggerExit")||(this._needTriggerEvent=!1),this.hasEventListener("onCollisionEnter")||this.hasEventListener("onCollisionStay")||this.hasEventListener("onCollisionExit")||(this._needCollisionEvent=!1)),this._shape&&this._shape.updateEventListener())},Pi(e,[{key:"attachedRigidBody",get:function(){return t=this.node,(e=t.getComponent(kX))&&e.isValid?e:null;var t,e}},{key:"sharedMaterial",get:function(){return this._material},set:function(t){this.material=t}},{key:"material",get:function(){return this._isSharedMaterial&&this._material&&(this._material.off(rX.EVENT_UPDATE,this._updateMaterial,this),this._material=this._material.clone(),this._material.on(rX.EVENT_UPDATE,this._updateMaterial,this),this._isSharedMaterial=!1),this._material},set:function(t){this._shape?(t&&this._material?this._material.id!==t.id&&(this._material.off(rX.EVENT_UPDATE,this._updateMaterial,this),t.on(rX.EVENT_UPDATE,this._updateMaterial,this),this._isSharedMaterial=!1,this._material=t):t&&!this._material?(t.on(rX.EVENT_UPDATE,this._updateMaterial,this),this._material=t):!t&&this._material&&(this._material.off(rX.EVENT_UPDATE,this._updateMaterial,this),this._material=t),this._updateMaterial()):this._material=t}},{key:"isTrigger",get:function(){return this._isTrigger},set:function(t){this._isTrigger=t,this._shape&&this._shape.setAsTrigger(this._isTrigger)}},{key:"center",get:function(){return this._center},set:function(t){ji.copy(this._center,t),this._shape&&this._shape.setCenter(this._center)}},{key:"shape",get:function(){return this._shape}},{key:"worldBounds",get:function(){return null==this._aabb&&(this._aabb=new Qi),this._shape&&this._shape.getAABB(this._aabb),this._aabb}},{key:"boundingSphere",get:function(){return null==this._boundingSphere&&(this._boundingSphere=new Ca),this._shape&&this._shape.getBoundingSphere(this._boundingSphere),this._boundingSphere}},{key:"needTriggerEvent",get:function(){return this._needTriggerEvent}},{key:"needCollisionEvent",get:function(){return this._needCollisionEvent}},{key:"_isInitialized",get:function(){var t=null===this._shape;return t&&ks("[Physics]: This component has not been call onLoad yet, please make sure the node has been added to the scene."),!t}}]),e}(Cr(Pn)),LX.Type=JH,LX.Axis=ZH,gn((PX=NX).prototype,"attachedRigidBody",[xX],Object.getOwnPropertyDescriptor(PX.prototype,"attachedRigidBody"),PX.prototype),gn(PX.prototype,"sharedMaterial",[wX],Object.getOwnPropertyDescriptor(PX.prototype,"sharedMaterial"),PX.prototype),gn(PX.prototype,"center",[MX],Object.getOwnPropertyDescriptor(PX.prototype,"center"),PX.prototype),DX=tn(PX.prototype,"_material",[IX],(function(){return null})),OX=tn(PX.prototype,"_isTrigger",[en],(function(){return!1})),FX=tn(PX.prototype,"_center",[en],(function(){return new ji})),BX=PX))||BX));function GX(t){return void 0===(t=t||{}).includeNormal&&(t.includeNormal=!0),void 0===t.includeUV&&(t.includeUV=!0),t}UX||(UX=function(e){return t({Collider:e,ColliderComponent:e}),e}({}));var VX=new ji,HX=new ji,zX=new ji,XX=new ji,WX=new ji,YX=new ji,jX=new ji,KX=new ji,qX=new ji,ZX=new ji,QX=new ji,JX=new ji,$X=new ji(0,0,0),tW=new ji(0,0,0);function eW(t,e,i,n){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=2),void 0===n&&(n={});var r=.5*i,s=n.radialSegments||32,a=n.heightSegments||1,o=void 0===n.capped||n.capped,h=n.arc||2*Math.PI,l=0;o||(t>0&&l++,e>0&&l++);var u=(s+1)*(a+1);o&&(u+=(s+1)*l+s*l);var c=s*a*6;o&&(c+=s*l*3);var d=new Array(c),_=new Array(3*u),f=new Array(3*u),p=new Array(2*u),g=Math.max(t,e),m=new ji(-g,-r,-g),v=new ji(g,r,g),y=Math.sqrt(g*g+r*r),T=0,S=0;return function(){for(var n=[],o=t-e,l=o*o/i*Math.sign(o),u=0;u<=a;u++){for(var c=[],g=u/a,m=g*o+e,v=0;v<=s;++v){var y=v/s,E=y*h,A=Math.sin(E),C=Math.cos(E);_[3*T]=m*A,_[3*T+1]=g*i-r,_[3*T+2]=m*C,ji.normalize($X,ji.set(tW,A,-l,C)),f[3*T]=$X.x,f[3*T+1]=$X.y,f[3*T+2]=$X.z,p[2*T]=2*(1-y)%1,p[2*T+1]=g,c.push(T),++T}n.push(c)}for(var R=0;R<a;++R)for(var b=0;b<s;++b){var x=n[R][b],w=n[R+1][b],M=n[R+1][b+1],I=n[R][b+1];d[S]=x,++S,d[S]=I,++S,d[S]=w,++S,d[S]=I,++S,d[S]=M,++S,d[S]=w,++S}}(),o&&(e>0&&E(!1),t>0&&E(!0)),{positions:_,normals:f,uvs:p,indices:d,minPos:m,maxPos:v,boundingRadius:y};function E(i){for(var n=i?t:e,a=i?1:-1,o=T,l=1;l<=s;++l)_[3*T]=0,_[3*T+1]=r*a,_[3*T+2]=0,f[3*T]=0,f[3*T+1]=a,f[3*T+2]=0,p[2*T]=.5,p[2*T+1]=.5,++T;for(var u=T,c=0;c<=s;++c){var g=c/s*h,m=Math.cos(g),v=Math.sin(g);_[3*T]=n*v,_[3*T+1]=r*a,_[3*T+2]=n*m,f[3*T]=0,f[3*T+1]=a,f[3*T+2]=0,p[2*T]=.5-.5*v*a,p[2*T+1]=.5+.5*m,++T}for(var y=0;y<s;++y){var E=o+y,A=u+y;i?(d[S]=A+1,++S,d[S]=E,++S,d[S]=A,++S):(d[S]=E,++S,d[S]=A+1,++S,d[S]=A,++S)}}}var iW=new ji(0,0,0),nW=new ji(0,0,0),rW=new ji(0,0,0),sW=new ji(0,0,0),aW=new ji(0,0,0),oW=new ji(0,0,0),hW=new ji(0,0,0),lW=new ji(0,0,0),uW=new ji(0,0,0),cW=Object.freeze({__proto__:null,box:function(t){var e=(t=t||{}).widthSegments||1,i=t.heightSegments||1,n=t.lengthSegments||1,r=(t.width||1)/2,s=(t.height||1)/2,a=(t.length||1)/2,o=[ji.set(WX,-r,-s,a),ji.set(YX,r,-s,a),ji.set(jX,r,s,a),ji.set(KX,-r,s,a),ji.set(qX,r,-s,-a),ji.set(ZX,-r,-s,-a),ji.set(QX,-r,s,-a),ji.set(JX,r,s,-a)],h=[[2,3,1],[4,5,7],[7,6,2],[1,0,4],[1,4,2],[5,0,6]],l=[[0,0,1],[0,0,-1],[0,1,0],[0,-1,0],[1,0,0],[-1,0,0]],u=[[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[0,0,-1,1],[0,0,1,1]],c=[],d=[],_=[],f=[],p=[],g=new ji(-r,-s,-a),m=new ji(r,s,a),v=Math.sqrt(r*r+s*s+a*a);function y(t,e,i){var n,r,s,a,g=c.length/3,m=h[t],v=l[t],y=u[t];for(a=0;a<=i;a++)for(s=0;s<=e;s++)if(n=s/e,r=a/i,ji.lerp(VX,o[m[0]],o[m[1]],n),ji.lerp(HX,o[m[0]],o[m[2]],r),ji.subtract(zX,HX,o[m[0]]),ji.add(XX,VX,zX),c.push(XX.x,XX.y,XX.z),d.push(v[0],v[1],v[2]),_.push(n,r),f.push(y[0],y[1],y[2],y[3]),s<e&&a<i){var T=e+1,S=s+a*T,E=s+(a+1)*T,A=s+1+(a+1)*T,C=s+1+a*T;p.push(g+S,g+C,g+E),p.push(g+E,g+C,g+A)}}return y(0,e,i),y(4,n,i),y(1,e,i),y(5,n,i),y(3,e,n),y(2,e,n),{positions:c,normals:d,uvs:_,tangents:f,indices:p,minPos:g,maxPos:m,boundingRadius:v}},cone:function(t,e,i){return void 0===t&&(t=.5),void 0===e&&(e=1),void 0===i&&(i={}),eW(0,t,e,i)},cylinder:eW,plane:function(t){var e=function(t){return(t=GX(t)).width=t.width||10,t.length=t.length||10,t.widthSegments=t.widthSegments||10,t.lengthSegments=t.lengthSegments||10,t}(t),i=e.width,n=e.length,r=e.widthSegments,s=e.lengthSegments,a=.5*i,o=.5*n,h=[],l=[],u=[],c=new ji(-a,0,-o),d=new ji(a,0,o),_=Math.sqrt(i*i+n*n);ji.set(aW,-a,0,o),ji.set(oW,a,0,o),ji.set(hW,-a,0,-o);for(var f=0;f<=s;f++)for(var p=0;p<=r;p++){var g=p/r,m=f/s;if(ji.lerp(iW,aW,oW,g),ji.lerp(nW,aW,hW,m),ji.subtract(rW,nW,aW),ji.add(sW,iW,rW),h.push(sW.x,sW.y,sW.z),e.includeUV&&l.push(g,m),p<r&&f<s){var v=r+1,y=p+f*v,T=p+(f+1)*v,S=p+1+(f+1)*v,E=p+1+f*v;u.push(y,E,T),u.push(E,S,T)}}var A={positions:h,indices:u,minPos:c,maxPos:d,boundingRadius:_};if(e.includeNormal){var C=(s+1)*(r+1),R=new Array(3*C);A.normals=R;for(var b=0;b<C;++b)R[3*b+0]=0,R[3*b+1]=1,R[3*b+2]=0}return e.includeUV&&(A.uvs=l),A},quad:function(t){var e=GX(t),i={positions:[-.5,-.5,0,-.5,.5,0,.5,.5,0,.5,-.5,0],indices:[0,3,1,3,2,1],minPos:{x:-.5,y:-.5,z:0},maxPos:{x:.5,y:.5,z:0},boundingRadius:Math.sqrt(.5)};return!1!==e.includeNormal&&(i.normals=[0,0,1,0,0,1,0,0,1,0,0,1]),!1!==e.includeUV&&(i.uvs=[0,0,0,1,1,1,1,0]),i},sphere:function(t,e){void 0===t&&(t=.5),void 0===e&&(e={});for(var i=void 0!==e.segments?e.segments:32,n=[],r=[],s=[],a=[],o=new ji(-t,-t,-t),h=new ji(t,t,t),l=t,u=0;u<=i;++u)for(var c=u*Math.PI/i,d=Math.sin(c),_=-Math.cos(c),f=0;f<=i;++f){var p=2*f*Math.PI/i-Math.PI/2,g=Math.sin(p)*d,m=_,v=Math.cos(p)*d,y=f/i,T=u/i;if(n.push(g*t,m*t,v*t),r.push(g,m,v),s.push(y,T),u<i&&f<i){var S=i+1,E=S*u+f,A=S*(u+1)+f,C=S*(u+1)+f+1,R=S*u+f+1;a.push(E,R,A),a.push(R,C,A)}}return{positions:n,indices:a,normals:r,uvs:s,minPos:o,maxPos:h,boundingRadius:l}},torus:function(t,e,i){void 0===t&&(t=.4),void 0===e&&(e=.1),void 0===i&&(i={});for(var n=i.radialSegments||32,r=i.tubularSegments||32,s=i.arc||2*Math.PI,a=[],o=[],h=[],l=[],u=new ji(-t-e,-e,-t-e),c=new ji(t+e,e,t+e),d=t+e,_=0;_<=n;_++)for(var f=0;f<=r;f++){var p=f/r,g=_/n,m=p*s,v=g*Math.PI*2,y=(t+e*Math.cos(v))*Math.sin(m),T=e*Math.sin(v),S=(t+e*Math.cos(v))*Math.cos(m),E=Math.sin(m)*Math.cos(v),A=Math.sin(v),C=Math.cos(m)*Math.cos(v);if(a.push(y,T,S),o.push(E,A,C),h.push(p,g),f<r&&_<n){var R=r+1,b=R*_+f,x=R*(_+1)+f,w=R*(_+1)+f+1,M=R*_+f+1;l.push(b,M,x),l.push(M,w,x)}}return{positions:a,normals:o,uvs:h,indices:l,minPos:u,maxPos:c,boundingRadius:d}},capsule:function(t,e,i,n){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=2),void 0===n&&(n={});var r=i-t-e,s=n.sides||32,a=n.heightSegments||32,o=e/i,h=r/i,l=t/i,u=Math.floor(a*o),c=Math.floor(a*l),d=Math.floor(a*h),_=r+e-i/2,f=e-i/2,p=e-i/2,g=n.arc||2*Math.PI,m=[],v=[],y=[],T=[],S=Math.max(t,e),E=new ji(-S,-i/2,-S),A=new ji(S,i/2,S),C=i/2,R=0,b=[];return function(){for(var t=0;t<=u;++t)for(var i=t*Math.PI/u/2,n=Math.sin(i),r=-Math.cos(i),o=0;o<=s;++o){var h=2*o*Math.PI/s-Math.PI/2,l=Math.sin(h)*n,c=r,d=Math.cos(h)*n,_=o/s,f=t/a;if(m.push(l*e,c*e+p,d*e),v.push(l,c,d),y.push(_,f),t<u&&o<s){var g=s+1,S=g*t+o,E=g*(t+1)+o,A=g*(t+1)+o+1,C=g*t+o+1;T.push(S,C,E),T.push(C,A,E)}++R}}(),function(){for(var i=(t-e)/r,n=0;n<=d;n++){for(var a=[],l=n/d,u=l*(t-e)+e,c=0;c<=s;++c){var _=c/s,p=l*h+o,S=_*g-g/4,E=Math.sin(S),A=Math.cos(S);m.push(u*E),m.push(l*r+f),m.push(u*A),ji.normalize(lW,ji.set(uW,E,-i,A)),v.push(lW.x),v.push(lW.y),v.push(lW.z),y.push(_,p),a.push(R),++R}b.push(a)}for(var C=0;C<d;++C)for(var x=0;x<s;++x){var w=b[C][x],M=b[C+1][x],I=b[C+1][x+1],B=b[C][x+1];T.push(w),T.push(B),T.push(M),T.push(B),T.push(I),T.push(M)}}(),function(){for(var e=0;e<=c;++e)for(var i=e*Math.PI/c/2+Math.PI/2,n=Math.sin(i),r=-Math.cos(i),o=0;o<=s;++o){var h=2*o*Math.PI/s-Math.PI/2,u=Math.sin(h)*n,f=r,p=Math.cos(h)*n,g=o/s,S=e/a+(1-l);if(m.push(u*t,f*t+_,p*t),v.push(u,f,p),y.push(g,S),e<c&&o<s){var E=s+1,A=E*e+o+b[d][s]+1,C=E*(e+1)+o+b[d][s]+1,R=E*(e+1)+o+1+b[d][s]+1,x=E*e+o+1+b[d][s]+1;T.push(A,x,C),T.push(x,R,C)}}}(),{positions:m,normals:v,uvs:y,indices:T,minPos:E,maxPos:A,boundingRadius:C}},circle:function(t){var e=function(t){return(t=GX(t)).segments=64,t}(t).segments,i=new Array(3*(e+1));i[0]=0,i[1]=0,i[2]=0;var n=new Array(1+2*e);n[0]=0;for(var r=2*Math.PI/e,s=0;s<e;++s){var a=r*s,o=Math.cos(a),h=Math.sin(a),l=3*(s+1);i[l+0]=o,i[l+1]=h,i[l+2]=0;var u=2*s;n[1+u]=s+1,n[1+(u+1)]=s+2}return e>0&&(n[n.length-1]=1),{positions:i,indices:n,minPos:{x:1,y:1,z:0},maxPos:{x:-1,y:-1,z:0},boundingRadius:1,primitiveMode:U.TRIANGLE_FAN}},translate:function(t,e){for(var i=e.x||0,n=e.y||0,r=e.z||0,s=Math.floor(t.positions.length/3),a=0;a<s;++a){var o=3*a,h=3*a+1,l=3*a+2;t.positions[o]+=i,t.positions[h]+=n,t.positions[l]+=r}return t.minPos&&(t.minPos.x+=i,t.minPos.y+=n,t.minPos.z+=r),t.maxPos&&(t.maxPos.x+=i,t.maxPos.y+=n,t.maxPos.z+=r),t},scale:function(t,e){for(var i,n,r,s=null!==(i=e.x)&&void 0!==i?i:1,a=null!==(n=e.y)&&void 0!==n?n:1,o=null!==(r=e.z)&&void 0!==r?r:1,h=Math.floor(t.positions.length/3),l=0;l<h;++l){var u=3*l,c=3*l+1,d=3*l+2;t.positions[u]*=s,t.positions[c]*=a,t.positions[d]*=o}var _=t.minPos,f=t.maxPos;if(_&&(_.x*=s,_.y*=a,_.z*=o),f&&(f.x*=s,f.y*=a,f.z*=o),_&&f){if(s<0){var p=_.x;_.x=f.x,f.x=p}if(a<0){var g=_.y;_.y=f.y,f.y=g}if(o<0){var m=_.z;_.z=f.z,f.z=m}}return void 0!==t.boundingRadius&&(t.boundingRadius*=Math.max(Math.max(Math.abs(s),Math.abs(a)),Math.abs(o))),t},wireframed:function(t){var e=t.indices;if(!e)return t;if(t.primitiveMode&&t.primitiveMode!==U.TRIANGLE_LIST)return t;for(var i=[[0,1],[1,2],[2,0]],n=[],r={},s=0;s<e.length;s+=3)for(var a=0;a<3;++a){var o=e[s+i[a][0]],h=e[s+i[a][1]],l=o>h?h<<16|o:o<<16|h;void 0===r[l]&&(r[l]=0,n.push(o,h))}return t.indices=n,t.primitiveMode=U.LINE_LIST,t},wireframe:function(t){for(var e=[[0,1],[1,2],[2,0]],i=[],n={},r=0;r<t.length;r+=3)for(var s=0;s<3;++s){var a=t[r+e[s][0]],o=t[r+e[s][1]],h=a>o?o<<16|a:a<<16|o;void 0===n[h]&&(n[h]=0,i.push(a,o))}return i},invWinding:function(t){for(var e=[],i=0;i<t.length;i+=3)e.push(t[i],t[i+2],t[i+1]);return e},toWavefrontOBJ:function(t,e){if(void 0===e&&(e=1),!t.indices||!t.uvs||!t.normals||void 0!==t.primitiveMode&&t.primitiveMode!==U.TRIANGLE_LIST)return"";for(var i=t.positions,n=t.uvs,r=t.normals,s=t.indices,a=function(t){return s[t]+1+"/"+(s[t]+1)+"/"+(s[t]+1)},o="",h=0;h<i.length;h+=3)o+="v "+i[h]*e+" "+i[h+1]*e+" "+i[h+2]*e+"\n";for(var l=0;l<n.length;l+=2)o+="vt "+n[l]+" "+n[l+1]+"\n";for(var u=0;u<r.length;u+=3)o+="vn "+r[u]+" "+r[u+1]+" "+r[u+2]+"\n";for(var c=0;c<s.length;c+=3)o+="f "+a(c)+" "+a(c+1)+" "+a(c+2)+"\n";return o},normals:function(t,e,i){void 0===i&&(i=1);for(var n=new Array(2*t.length),r=0;r<t.length/3;++r){var s=3*r,a=6*r;n[a+0]=t[s+0],n[a+1]=t[s+1],n[a+2]=t[s+2],n[a+3]=t[s+0]+e[s+0]*i,n[a+4]=t[s+1]+e[s+1]*i,n[a+5]=t[s+2]+e[s+2]*i}return n},applyDefaultGeometryOptions:GX});t("primitives",cW);var dW=new ji;function _W(t){return t.x=Math.abs(t.x),t.y=Math.abs(t.y),t.z=Math.abs(t.z),t}var fW,pW,gW,mW,vW,yW,TW,SW,EW,AW,CW,RW,bW,xW,wW,MW,IW,BW,PW,DW,OW,FW,LW,NW,kW,UW,GW,VW,HW,zW,XW,WW,YW,jW,KW,qW,ZW,QW,JW,$W,tY,eY,iY,nY,rY,sY,aY,oY,hY,lY,uY,cY,dY,_Y,fY,pY,gY,mY,vY,yY,TY,SY,EY,AY,CY,RY,bY,xY,wY,MY,IY,BY=Object.freeze({__proto__:null,setWrap:function(t,e){t.__cc_wrapper__=e},getWrap:function(t){return t.__cc_wrapper__},maxComponent:function(t){return Math.max(t.x,Math.max(t.y,t.z))},VEC3_0:dW,TriggerEventObject:{type:"onTriggerEnter",selfCollider:null,otherCollider:null,impl:null},CollisionEventObject:{type:"onCollisionEnter",selfCollider:null,otherCollider:null,contacts:[],impl:null},shrinkPositions:function(t){var e=[];if(t.length>=3){e[0]=t[0],e[1]=t[1],e[2]=t[2];for(var i=t.length,n=3;n<i;n+=3){for(var r=t[n],s=t[n+1],a=t[n+2],o=e.length,h=!0,l=0;l<o;l+=3)if(Ea(r,e[l])&&Ea(s,e[l+1])&&Ea(a,e[l+2])){h=!1;break}h&&(e.push(r),e.push(s),e.push(a))}}return e},absolute:_W,cylinder:eW}),PY=function(e){return t({BoxCollider:e,BoxColliderComponent:e}),e}((fW=Ki("cc.BoxCollider"),pW=Tn(ji),fW((mW=function(t){function e(){var e;return(e=t.call(this,JH.BOX)||this)._size=vW&&vW(),e}return He(e,t),Pi(e,[{key:"size",get:function(){return this._size},set:function(t){ji.strictEquals(this._size,t)||(ji.copy(this._size,t),_W(this._size),this._shape&&this.shape.updateSize())}},{key:"shape",get:function(){return this._shape}}]),e}(UX),gn(mW.prototype,"size",[pW],Object.getOwnPropertyDescriptor(mW.prototype,"size"),mW.prototype),vW=tn(mW.prototype,"_size",[en],(function(){return new ji(1,1,1)})),gW=mW))||gW)),DY=function(e){return t({SphereCollider:e,SphereColliderComponent:e}),e}(Ki("cc.SphereCollider")((TW=function(t){function e(){var e;return(e=t.call(this,JH.SPHERE)||this)._radius=SW&&SW(),e}return He(e,t),Pi(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.updateRadius())}},{key:"shape",get:function(){return this._shape}}]),e}(UX),SW=tn(TW.prototype,"_radius",[en],(function(){return.5})),yW=TW))||yW),OY=function(e){return t({CapsuleCollider:e,CapsuleColliderComponent:e}),e}((EW=Ki("cc.CapsuleCollider"),AW=Tn(ZH),EW((RW=function(t){function e(){var e;return(e=t.call(this,JH.CAPSULE)||this)._radius=bW&&bW(),e._cylinderHeight=xW&&xW(),e._direction=wW&&wW(),e}He(e,t);var i=e.prototype;return i._getRadiusScale=function(){if(null==this.node)return 1;var t=this.node.worldScale;return this._direction===ZH.Y_AXIS?Math.abs(Ra(t.x,t.z)):this._direction===ZH.X_AXIS?Math.abs(Ra(t.y,t.z)):Math.abs(Ra(t.x,t.y))},i._getHeightScale=function(){if(null==this.node)return 1;var t=this.node.worldScale;return this._direction===ZH.Y_AXIS?Math.abs(t.y):this._direction===ZH.X_AXIS?Math.abs(t.x):Math.abs(t.z)},Pi(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"cylinderHeight",get:function(){return this._cylinderHeight},set:function(t){this._cylinderHeight!==t&&(this._cylinderHeight=Math.abs(t),this._shape&&this.shape.setCylinderHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){(t=Math.floor(t))<ZH.X_AXIS||t>ZH.Z_AXIS||this._direction!==t&&(this._direction=t,this._shape&&this.shape.setDirection(t))}},{key:"height",get:function(){return 2*this._radius+this._cylinderHeight},set:function(t){var e=t-2*this._radius;e<0&&(e=0),this.cylinderHeight=e}},{key:"worldHeight",get:function(){return 2*this._radius*this._getRadiusScale()+this._cylinderHeight*this._getHeightScale()}},{key:"shape",get:function(){return this._shape}}]),e}(UX),gn(RW.prototype,"direction",[AW],Object.getOwnPropertyDescriptor(RW.prototype,"direction"),RW.prototype),bW=tn(RW.prototype,"_radius",[en],(function(){return.5})),xW=tn(RW.prototype,"_cylinderHeight",[en],(function(){return 1})),wW=tn(RW.prototype,"_direction",[en],(function(){return ZH.Y_AXIS})),CW=RW))||CW)),FY=function(e){return t({CylinderCollider:e,CylinderColliderComponent:e}),e}((MW=Ki("cc.CylinderCollider"),IW=Tn(ZH),MW((PW=function(t){function e(){var e;return(e=t.call(this,JH.CYLINDER)||this)._radius=DW&&DW(),e._height=OW&&OW(),e._direction=FW&&FW(),e}return He(e,t),Pi(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(this._height=Math.abs(t),this._shape&&this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<ZH.X_AXIS||t>ZH.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(UX),gn(PW.prototype,"direction",[IW],Object.getOwnPropertyDescriptor(PW.prototype,"direction"),PW.prototype),DW=tn(PW.prototype,"_radius",[en],(function(){return.5})),OW=tn(PW.prototype,"_height",[en],(function(){return 2})),FW=tn(PW.prototype,"_direction",[en],(function(){return ZH.Y_AXIS})),BW=PW))||BW)),LY=t("ConeCollider",(LW=Ki("cc.ConeCollider"),NW=Tn(ZH),LW((UW=function(t){function e(){var e;return(e=t.call(this,JH.CONE)||this)._radius=GW&&GW(),e._height=VW&&VW(),e._direction=HW&&HW(),e}return He(e,t),Pi(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(t<0&&(t=0),this._height=t,this._shape&&this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<ZH.X_AXIS||t>ZH.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(UX),gn(UW.prototype,"direction",[NW],Object.getOwnPropertyDescriptor(UW.prototype,"direction"),UW.prototype),GW=tn(UW.prototype,"_radius",[en],(function(){return.5})),VW=tn(UW.prototype,"_height",[en],(function(){return 1})),HW=tn(UW.prototype,"_direction",[en],(function(){return ZH.Y_AXIS})),kW=UW))||kW)),NY=function(e){return t({MeshCollider:e,MeshColliderComponent:e}),e}((zW=Ki("cc.MeshCollider"),XW=Tn(mo),zW((YW=function(t){function e(){var e;return(e=t.call(this,JH.MESH)||this)._mesh=jW&&jW(),e._convex=KW&&KW(),e}return He(e,t),Pi(e,[{key:"mesh",get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh=t,this._shape&&this.shape.setMesh(this._mesh))}},{key:"convex",get:function(){return this._convex},set:function(t){this._convex!==t&&(this._convex=t,this._shape&&this._mesh&&this.shape.setMesh(this._mesh))}},{key:"shape",get:function(){return this._shape}}]),e}(UX),gn(YW.prototype,"mesh",[XW],Object.getOwnPropertyDescriptor(YW.prototype,"mesh"),YW.prototype),jW=tn(YW.prototype,"_mesh",[en],(function(){return null})),KW=tn(YW.prototype,"_convex",[en],(function(){return!1})),WW=YW))||WW)),kY=t("ConstantForce",Ki("cc.ConstantForce")(qW=kn(kX)(qW=bn((ZW=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._rigidBody=null,e._force=QW&&QW(),e._localForce=JW&&JW(),e._torque=$W&&$W(),e._localTorque=tY&&tY(),e._mask=0,e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._rigidBody=this.node.getComponent(kX),this._maskUpdate(this._force,1),this._maskUpdate(this._localForce,2),this._maskUpdate(this._torque,4),this._maskUpdate(this._localTorque,8)},i.lateUpdate=function(){null!=this._rigidBody&&0!==this._mask&&(1&this._mask&&this._rigidBody.applyForce(this._force),2&this._mask&&this._rigidBody.applyLocalForce(this.localForce),4&this._mask&&this._rigidBody.applyTorque(this._torque),8&this._mask&&this._rigidBody.applyLocalTorque(this._localTorque))},i._maskUpdate=function(t,e){t.strictEquals(ji.ZERO)?this._mask&=~e:this._mask|=e},Pi(e,[{key:"force",get:function(){return this._force},set:function(t){ji.copy(this._force,t),this._maskUpdate(this._force,1)}},{key:"localForce",get:function(){return this._localForce},set:function(t){ji.copy(this._localForce,t),this._maskUpdate(this.localForce,2)}},{key:"torque",get:function(){return this._torque},set:function(t){ji.copy(this._torque,t),this._maskUpdate(this._torque,4)}},{key:"localTorque",get:function(){return this._localTorque},set:function(t){ji.copy(this._localTorque,t),this._maskUpdate(this._localTorque,8)}}]),e}(Pn),QW=tn(ZW.prototype,"_force",[en],(function(){return new ji})),JW=tn(ZW.prototype,"_localForce",[en],(function(){return new ji})),$W=tn(ZW.prototype,"_torque",[en],(function(){return new ji})),tY=tn(ZW.prototype,"_localTorque",[en],(function(){return new ji})),qW=ZW))||qW)||qW)||qW),UY=16842754,GY=16842755,VY=16842756,HY=16842758,zY=16842759,XY=16843025,WY=function(){function t(){this.length=0,this.buffer=new Uint8Array(2048),this._buffView=new DataView(this.buffer.buffer),this._seekPos=0}var e=t.prototype;return e.reserve=function(t){if(!(this.buffer.byteLength>t)){for(var e=this.buffer.byteLength;e<t;)e+=e;for(var i=new Uint8Array(e),n=0;n<this.length;++n)i[n]=this.buffer[n];this.buffer=i,this._buffView=new DataView(this.buffer.buffer)}},e.assign=function(t){this.buffer=t,this.length=t.length,this._seekPos=t.byteOffset,this._buffView=new DataView(t.buffer)},e.writeInt8=function(t){this.reserve(this.length+1),this._buffView.setInt8(this.length,t),this.length+=1},e.writeInt16=function(t){this.reserve(this.length+2),this._buffView.setInt16(this.length,t,!0),this.length+=2},e.writeInt32=function(t){this.reserve(this.length+4),this._buffView.setInt32(this.length,t,!0),this.length+=4},e.writeIntArray=function(t){this.reserve(this.length+4*t.length);for(var e=0;e<t.length;++e)this._buffView.setInt32(this.length+4*e,t[e],!0);this.length+=4*t.length},e.writeFloat=function(t){this.reserve(this.length+4),this._buffView.setFloat32(this.length,t,!0),this.length+=4},e.writeFloatArray=function(t){this.reserve(this.length+4*t.length);for(var e=0;e<t.length;++e)this._buffView.setFloat32(this.length+4*e,t[e],!0);this.length+=4*t.length},e.writeDouble=function(t){this.reserve(this.length+8),this._buffView.setFloat64(this.length,t,!0),this.length+=8},e.writeDoubleArray=function(t){this.reserve(this.length+8*t.length);for(var e=0;e<t.length;++e)this._buffView.setFloat64(this.length+8*e,t[e],!0);this.length+=8*t.length},e.writeString=function(t){this.reserve(this.length+t.length+4),this._buffView.setInt32(this.length,t.length,!0);for(var e=0;e<t.length;++e)this._buffView.setInt8(this.length+4+e,t.charCodeAt(e));this.length+=t.length+4},e.readInt8=function(){var t=this._buffView.getInt8(this._seekPos);return this._seekPos+=1,t},e.readInt16=function(){var t=this._buffView.getInt16(this._seekPos,!0);return this._seekPos+=2,t},e.readInt=function(){var t=this._buffView.getInt32(this._seekPos,!0);return this._seekPos+=4,t},e.readIntArray=function(t){for(var e=0;e<t.length;++e)t[e]=this._buffView.getInt32(this._seekPos+4*e,!0);return this._seekPos+=4*t.length,t},e.readFloat=function(){var t=this._buffView.getFloat32(this._seekPos,!0);return this._seekPos+=4,t},e.readFloatArray=function(t){for(var e=0;e<t.length;++e)t[e]=this._buffView.getFloat32(this._seekPos+4*e,!0);return this._seekPos+=4*t.length,t},e.readDouble=function(){var t=this._buffView.getFloat64(this._seekPos,!0);return this._seekPos+=8,t},e.readDoubleArray=function(t){for(var e=0;e<t.length;++e)t[e]=this._buffView.getFloat64(this._seekPos+4*e,!0);return this._seekPos+=8*t.length,t},e.readString=function(){for(var t=this.readInt(),e="",i=0;i<t;++i)e+=String.fromCharCode(this.readInt8());return e},t}(),YY=(Ki("cc.TerrainLayerInfo")((eY=function(){this.slot=iY&&iY(),this.tileSize=nY&&nY(),this.detailMap=rY&&rY(),this.normalMap=sY&&sY(),this.roughness=aY&&aY(),this.metallic=oY&&oY()},iY=tn(eY.prototype,"slot",[en],(function(){return 0})),nY=tn(eY.prototype,"tileSize",[en],(function(){return 1})),rY=tn(eY.prototype,"detailMap",[en],(function(){return null})),sY=tn(eY.prototype,"normalMap",[en],(function(){return null})),aY=tn(eY.prototype,"roughness",[en],(function(){return 1})),oY=tn(eY.prototype,"metallic",[en],(function(){return 0})),eY)),Ki("cc.TerrainLayerBinaryInfo")(hY=function(){this.slot=0,this.tileSize=1,this.roughness=1,this.metallic=0,this.detailMapId="",this.normalMapId=""})||hY),jY=Ki("cc.TerrainAsset")((uY=function(t){function e(){var e;return(e=t.call(this)||this)._version=0,e._data=null,e._tileSize=1,e._blockCount=[1,1],e._weightMapSize=128,e._lightMapSize=128,e._heights=new Uint16Array,e._normals=new Float32Array,e._weights=new Uint8Array,e._layerBuffer=[-1,-1,-1,-1],e._layerBinaryInfos=[],e._layerInfos=cY&&cY(),e}He(e,t);var i=e.prototype;return i.getLayer=function(t,e,i){var n=4*(e*this.blockCount[0]+t)+i;return t<this.blockCount[0]&&e<this.blockCount[1]&&n<this._layerBuffer.length?this._layerBuffer[n]:-1},i.getHeight=function(t,e){var i=32*this._blockCount[0]+1;return.001953125*(this._heights[e*i+t]-32768)},i.getVertexCountI=function(){return this._blockCount.length<1?0:32*this._blockCount[0]+1},i.getVertexCountJ=function(){return this._blockCount.length<2?0:32*this._blockCount[1]+1},i._setNativeData=function(t){this._data=t},i._loadNativeData=function(t){if(!t||0===t.length)return!1;var e=new WY;if(e.assign(t),this._version=e.readInt(),this._version===XY)return!0;if(16842753!==this._version&&this._version!==UY&&this._version!==GY&&this._version!==VY&&16842757!==this._version&&this._version!==HY&&this._version!==zY)return!1;this._version>=zY?this.tileSize=e.readDouble():this.tileSize=e.readFloat(),this.tileSize=Math.floor(100*this.tileSize)/100,e.readIntArray(this._blockCount),this.weightMapSize=e.readInt16(),this.lightMapSize=e.readInt16();var i=e.readInt();this.heights=new Uint16Array(i);for(var n=0;n<this.heights.length;++n)this.heights[n]=e.readInt16();if(this._version>=HY){var r=e.readInt();this.normals=new Float32Array(r);for(var s=0;s<this.normals.length;++s)this.normals[s]=e.readFloat()}var a=e.readInt();this.weights=new Uint8Array(a);for(var o=0;o<this.weights.length;++o)this.weights[o]=e.readInt8();if(this._version>=UY){var h=e.readInt();this.layerBuffer=new Array(h);for(var l=0;l<this.layerBuffer.length;++l)this.layerBuffer[l]=e.readInt16()}if(this._version>=GY){var u=e.readInt();this._layerBinaryInfos=new Array(u);for(var c=0;c<this._layerBinaryInfos.length;++c)this._layerBinaryInfos[c]=new YY,this._layerBinaryInfos[c].slot=e.readInt(),this._version>=zY?this._layerBinaryInfos[c].tileSize=e.readDouble():this._layerBinaryInfos[c].tileSize=e.readFloat(),this._layerBinaryInfos[c].detailMapId=e.readString(),this._version>=VY&&(this._layerBinaryInfos[c].normalMapId=e.readString(),this._version>=zY?(this._layerBinaryInfos[c].roughness=e.readDouble(),this._layerBinaryInfos[c].metallic=e.readDouble()):(this._layerBinaryInfos[c].roughness=e.readFloat(),this._layerBinaryInfos[c].metallic=e.readFloat()))}return!0},i._exportNativeData=function(){var t=new WY;t.writeInt32(zY),t.writeDouble(this.tileSize),t.writeIntArray(this._blockCount),t.writeInt16(this.weightMapSize),t.writeInt16(this.lightMapSize),t.writeInt32(this.heights.length);for(var e=0;e<this.heights.length;++e)t.writeInt16(this.heights[e]);t.writeInt32(this.normals.length);for(var i=0;i<this.normals.length;++i)t.writeFloat(this.normals[i]);t.writeInt32(this.weights.length);for(var n=0;n<this.weights.length;++n)t.writeInt8(this.weights[n]);t.writeInt32(this.layerBuffer.length);for(var r=0;r<this.layerBuffer.length;++r)t.writeInt16(this.layerBuffer[r]);var s=[];s.length=this.layerInfos.length;for(var a=0;a<s.length;++a){var o=this.layerInfos[a],h=new YY;h.slot=a,h.tileSize=o.tileSize,h.detailMapId=o.detailMap?o.detailMap._uuid:"",h.normalMapId=o.normalMap?o.normalMap._uuid:"",h.metallic=o.metallic,h.roughness=o.roughness,s[a]=h}t.writeInt32(s.length);for(var l=0;l<s.length;++l)t.writeInt32(s[l].slot),t.writeDouble(s[l].tileSize),t.writeString(s[l].detailMapId),t.writeString(s[l].normalMapId),t.writeDouble(s[l].roughness),t.writeDouble(s[l].metallic);return t.buffer},i._exportDefaultNativeData=function(){var t=new WY;return t.writeInt32(XY),t.buffer},Pi(e,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(t){this._data&&this._data.byteLength===t.byteLength?this._data.set(new Uint8Array(t)):this._data=new Uint8Array(t),this._loadNativeData(this._data)}},{key:"version",get:function(){return this._version}},{key:"tileSize",get:function(){return this._tileSize},set:function(t){this._tileSize=t}},{key:"blockCount",get:function(){return this._blockCount},set:function(t){this._blockCount=t}},{key:"lightMapSize",get:function(){return this._lightMapSize},set:function(t){this._lightMapSize=t}},{key:"weightMapSize",get:function(){return this._weightMapSize},set:function(t){this._weightMapSize=t}},{key:"heights",get:function(){return this._heights},set:function(t){this._heights=t}},{key:"normals",get:function(){return this._normals},set:function(t){this._normals=t}},{key:"weights",get:function(){return this._weights},set:function(t){this._weights=t}},{key:"layerBuffer",get:function(){return this._layerBuffer},set:function(t){this._layerBuffer=t}},{key:"layerInfos",get:function(){return this._layerInfos},set:function(t){this._layerInfos=t}},{key:"layerBinaryInfos",get:function(){return this._layerBinaryInfos}}]),e}($i),cY=tn(uY.prototype,"_layerInfos",[en],(function(){return[]})),lY=uY))||lY,KY=t("TerrainCollider",(dY=Ki("cc.TerrainCollider"),_Y=Tn(jY),dY((pY=function(t){function e(){var e;return(e=t.call(this,JH.TERRAIN)||this)._terrain=gY&&gY(),e}return He(e,t),Pi(e,[{key:"terrain",get:function(){return this._terrain},set:function(t){this._terrain=t,this._shape&&this.shape.setTerrain(this._terrain)}},{key:"shape",get:function(){return this._shape}}]),e}(UX),gn(pY.prototype,"terrain",[_Y],Object.getOwnPropertyDescriptor(pY.prototype,"terrain"),pY.prototype),gY=tn(pY.prototype,"_terrain",[en],(function(){return null})),fY=pY))||fY)),qY=t("SimplexCollider",(mY=Ki("cc.SimplexCollider"),vY=Tn(QH),mY((CY=AY=function(t){function e(){var e;return(e=t.call(this,JH.SIMPLEX)||this)._shapeType=SY&&SY(),e._vertices=EY&&EY(),e}return He(e,t),e.prototype.updateVertices=function(){this._shape&&this.shape.setVertices(this._vertices)},Pi(e,[{key:"shapeType",get:function(){return this._shapeType},set:function(t){this._shapeType=t,this._shape&&this.shape.setShapeType(t)}},{key:"vertex0",get:function(){return this._vertices[0]},set:function(t){ji.copy(this._vertices[0],t),this.updateVertices()}},{key:"vertex1",get:function(){return this._vertices[1]},set:function(t){ji.copy(this._vertices[1],t),this.updateVertices()}},{key:"vertex2",get:function(){return this._vertices[2]},set:function(t){ji.copy(this._vertices[2],t),this.updateVertices()}},{key:"vertex3",get:function(){return this._vertices[3]},set:function(t){ji.copy(this._vertices[3],t),this.updateVertices()}},{key:"shape",get:function(){return this._shape}},{key:"vertices",get:function(){return this._vertices}}]),e}(UX),AY.ESimplexType=QH,gn((TY=CY).prototype,"shapeType",[vY],Object.getOwnPropertyDescriptor(TY.prototype,"shapeType"),TY.prototype),SY=tn(TY.prototype,"_shapeType",[en],(function(){return QH.TETRAHEDRON})),EY=tn(TY.prototype,"_vertices",[en],(function(){return[new ji(0,0,0),new ji(0,0,1),new ji(1,0,0),new ji(0,1,0)]})),yY=TY))||yY));qY||(qY=t("SimplexCollider",{}));var ZY,QY,JY,$Y,tj,ej,ij,nj,rj,sj,aj,oj,hj,lj,uj,cj,dj,_j,fj,pj,gj,mj,vj,yj=t("PlaneCollider",(RY=Ki("cc.PlaneCollider"),bY=Tn(ji),RY((wY=function(t){function e(){var e;return(e=t.call(this,JH.PLANE)||this)._normal=MY&&MY(),e._constant=IY&&IY(),e}return He(e,t),Pi(e,[{key:"normal",get:function(){return this._normal},set:function(t){ji.strictEquals(this._normal,t)||(ji.copy(this._normal,t),this._shape&&this.shape.setNormal(this._normal))}},{key:"constant",get:function(){return this._constant},set:function(t){this._constant!==t&&(this._constant=t,this._shape&&this.shape.setConstant(this._constant))}},{key:"shape",get:function(){return this._shape}}]),e}(UX),gn(wY.prototype,"normal",[bY],Object.getOwnPropertyDescriptor(wY.prototype,"normal"),wY.prototype),MY=tn(wY.prototype,"_normal",[en],(function(){return new ji(0,1,0)})),IY=tn(wY.prototype,"_constant",[en],(function(){return 0})),xY=wY))||xY)),Tj=t("Constraint",(ZY=Ki("cc.Constraint"),QY=kn(kX),JY=Tn(kX),$Y=Tn(kX),tj=Tn(kX),ZY(ej=QY((aj=sj=function(t){function e(e){var i;return(i=t.call(this)||this).TYPE=void 0,i._enableCollision=nj&&nj(),i._connectedBody=rj&&rj(),i._constraint=null,i.TYPE=e,i}He(e,t);var i=e.prototype;return i.onLoad=function(){wz.runInEditor&&(this._constraint=function(t){return Lz.INITED||(Lz.INITED=!0,Lz[$H.POINT_TO_POINT]=function(){return Bz(wz.wrapper.PointToPointConstraint,xz.PointToPointConstraint)?Nz:new wz.wrapper.PointToPointConstraint},Lz[$H.HINGE]=function(){return Bz(wz.wrapper.HingeConstraint,xz.HingeConstraint)?Nz:new wz.wrapper.HingeConstraint},Lz[$H.CONE_TWIST]=function(){return Bz(wz.wrapper.ConeTwistConstraint,xz.ConeTwistConstraint)?Nz:new wz.wrapper.ConeTwistConstraint},Lz[$H.FIXED]=function(){return Bz(wz.wrapper.FixedConstraint,xz.FixedConstraint)?Nz:new wz.wrapper.FixedConstraint}),Lz[t]()}(this.TYPE),this._constraint.initialize(this))},i.onEnable=function(){this._constraint&&this._constraint.onEnable()},i.onDisable=function(){this._constraint&&this._constraint.onDisable()},i.onDestroy=function(){this._constraint&&this._constraint.onDestroy()},Pi(e,[{key:"attachedBody",get:function(){return this.getComponent(kX)}},{key:"connectedBody",get:function(){return this._connectedBody},set:function(t){this._connectedBody=t,this._constraint&&this._constraint.setConnectedBody(t)}},{key:"enableCollision",get:function(){return this._enableCollision},set:function(t){this._enableCollision=t,this._constraint&&this._constraint.setEnableCollision(t)}}]),e}(Cr(Pn)),sj.Type=$H,gn((ij=aj).prototype,"attachedBody",[JY],Object.getOwnPropertyDescriptor(ij.prototype,"attachedBody"),ij.prototype),gn(ij.prototype,"connectedBody",[$Y],Object.getOwnPropertyDescriptor(ij.prototype,"connectedBody"),ij.prototype),nj=tn(ij.prototype,"_enableCollision",[en],(function(){return!0})),rj=tn(ij.prototype,"_connectedBody",[tj],(function(){return null})),ej=ij))||ej)||ej));Tj||(Tj=t("Constraint",{}));var Sj,Ej,Aj,Cj,Rj,bj,xj,wj,Mj,Ij,Bj,Pj,Dj,Oj,Fj,Lj,Nj=t("HingeConstraint",(oj=Ki("cc.HingeConstraint"),hj=Tn(ji),lj=Tn(ji),uj=Tn(ji),cj=is("axisA"),dj=is("pivotA"),_j=is("pivotB"),oj((pj=function(t){function e(){var e;return(e=t.call(this,$H.HINGE)||this)._axis=gj&&gj(),e._pivotA=mj&&mj(),e._pivotB=vj&&vj(),e}return He(e,t),Pi(e,[{key:"pivotA",get:function(){return this._pivotA},set:function(t){ji.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){ji.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"axis",get:function(){return this._axis},set:function(t){ji.copy(this._axis,t),this.constraint.setAxis(this._axis)}},{key:"constraint",get:function(){return this._constraint}}]),e}(Tj),gn(pj.prototype,"pivotA",[hj],Object.getOwnPropertyDescriptor(pj.prototype,"pivotA"),pj.prototype),gn(pj.prototype,"pivotB",[lj],Object.getOwnPropertyDescriptor(pj.prototype,"pivotB"),pj.prototype),gn(pj.prototype,"axis",[uj],Object.getOwnPropertyDescriptor(pj.prototype,"axis"),pj.prototype),gj=tn(pj.prototype,"_axis",[en,cj],(function(){return new ji})),mj=tn(pj.prototype,"_pivotA",[en,dj],(function(){return new ji})),vj=tn(pj.prototype,"_pivotB",[en,_j],(function(){return new ji})),fj=pj))||fj)),kj=(Sj=Ki("cc.FixedConstraint"),Ej=Tn($r),Aj=Tn($r),Cj=is("breakForce"),Rj=is("breakTorque"),Sj((xj=function(t){function e(){var e;return(e=t.call(this,$H.FIXED)||this)._breakForce=wj&&wj(),e._breakTorque=Mj&&Mj(),e}return He(e,t),Pi(e,[{key:"breakForce",get:function(){return this._breakForce},set:function(t){this._breakForce=t,this.constraint.setBreakForce(t)}},{key:"breakTorque",get:function(){return this._breakTorque},set:function(t){this._breakTorque=t,this.constraint.setBreakTorque(t)}},{key:"constraint",get:function(){return this._constraint}}]),e}(Tj),gn(xj.prototype,"breakForce",[Ej],Object.getOwnPropertyDescriptor(xj.prototype,"breakForce"),xj.prototype),gn(xj.prototype,"breakTorque",[Aj],Object.getOwnPropertyDescriptor(xj.prototype,"breakTorque"),xj.prototype),wj=tn(xj.prototype,"_breakForce",[en,Cj],(function(){return 1e8})),Mj=tn(xj.prototype,"_breakTorque",[en,Rj],(function(){return 1e8})),bj=xj))||bj),Uj=t("PointToPointConstraint",(Ij=Ki("cc.PointToPointConstraint"),Bj=Tn(ji),Pj=Tn(ji),Ij((Oj=function(t){function e(){var e;return(e=t.call(this,$H.POINT_TO_POINT)||this)._pivotA=Fj&&Fj(),e._pivotB=Lj&&Lj(),e}return He(e,t),Pi(e,[{key:"pivotA",get:function(){return this._pivotA},set:function(t){ji.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){ji.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"constraint",get:function(){return this._constraint}}]),e}(Tj),gn(Oj.prototype,"pivotA",[Bj],Object.getOwnPropertyDescriptor(Oj.prototype,"pivotA"),Oj.prototype),gn(Oj.prototype,"pivotB",[Pj],Object.getOwnPropertyDescriptor(Oj.prototype,"pivotB"),Oj.prototype),Fj=tn(Oj.prototype,"_pivotA",[en],(function(){return new ji})),Lj=tn(Oj.prototype,"_pivotB",[en],(function(){return new ji})),Dj=Oj))||Dj));We.PhysicsSystem=RX,We.PhysicsMaterial=rX,We.PhysicsRayResult=sX,We.ConstantForce=kY;var Gj,Vj,Hj,zj,Xj,Wj=Object.freeze({__proto__:null,PhysicsSystem:RX,PhysicsRayResult:sX,get Collider(){return UX},BoxCollider:PY,SphereCollider:DY,CapsuleCollider:OY,MeshCollider:NY,CylinderCollider:FY,ConeCollider:LY,TerrainCollider:KY,get SimplexCollider(){return qY},PlaneCollider:yj,get Constraint(){return Tj},HingeConstraint:Nj,FixedConstraint:kj,PointToPointConstraint:Uj,get RigidBody(){return kX},PhysicsMaterial:rX,ConstantForce:kY,selector:wz,utils:BY,get ERigidBodyType(){return qH},get EAxisDirection(){return ZH},get ESimplexType(){return QH},get EColliderType(){return JH},get EConstraintType(){return $H},get PhysicsGroup(){return tz}});t("physics",Wj),zn(RX,"PhysicsSystem",[{name:"ins",newName:"instance"},{name:"PHYSICS_AMMO",newName:"PHYSICS_BULLET"}]),zn(RX.prototype,"PhysicsSystem.prototype",[{name:"deltaTime",newName:"fixedTimeStep"},{name:"maxSubStep",newName:"maxSubSteps"}]),Vn(RX.prototype,"PhysicsSystem.prototype",[{name:"useFixedTime"},{name:"useCollisionMatrix"},{name:"updateCollisionMatrix"},{name:"resetCollisionMatrix"},{name:"isCollisionGroup"},{name:"setCollisionGroup"}]),zn(UX.prototype,"Collider.prototype",[{name:"attachedRigidbody",newName:"attachedRigidBody"},{name:"TYPE",newName:"type"}]),zn(UX,"Collider",[{name:"EColliderType",newName:"Type"},{name:"EAxisDirection",newName:"Axis"}]),zn(Tj,"Constraint",[{name:"EConstraintType",newName:"Type"}]),zn(PY.prototype,"BoxCollider.prototype",[{name:"boxShape",newName:"shape"}]),zn(DY.prototype,"SphereCollider.prototype",[{name:"sphereShape",newName:"shape"}]),zn(OY.prototype,"CapsuleCollider.prototype",[{name:"capsuleShape",newName:"shape"}]),zn(kX.prototype,"RigidBody.prototype",[{name:"rigidBody",newName:"body"}]),zn(kX,"RigidBody",[{name:"ERigidBodyType",newName:"Type"}]),Vn(kX.prototype,"RigidBody.prototype",[{name:"fixedRotation"}]),We.RigidBodyComponent=kX,br(kX,"cc.RigidBodyComponent"),We.ColliderComponent=UX,br(UX,"cc.ColliderComponent"),We.BoxColliderComponent=PY,br(PY,"cc.BoxColliderComponent"),We.SphereColliderComponent=DY,br(DY,"cc.SphereColliderComponent"),br(OY,"cc.CapsuleColliderComponent"),br(NY,"cc.MeshColliderComponent"),br(FY,"cc.CylinderColliderComponent"),We.PhysicMaterial=rX,br(rX,"cc.PhysicMaterial"),We.physics=Wj,function(t){t[t.BODY_RE_ADD=1]="BODY_RE_ADD",t[t.GHOST_RE_ADD=2]="GHOST_RE_ADD"}(Gj||(Gj={})),function(t){t[t.CF_STATIC_OBJECT=1]="CF_STATIC_OBJECT",t[t.CF_KINEMATIC_OBJECT=2]="CF_KINEMATIC_OBJECT",t[t.CF_NO_CONTACT_RESPONSE=4]="CF_NO_CONTACT_RESPONSE",t[t.CF_CUSTOM_MATERIAL_CALLBACK=8]="CF_CUSTOM_MATERIAL_CALLBACK",t[t.CF_CHARACTER_OBJECT=16]="CF_CHARACTER_OBJECT",t[t.CF_DISABLE_VISUALIZE_OBJECT=32]="CF_DISABLE_VISUALIZE_OBJECT",t[t.CF_DISABLE_SPU_COLLISION_PROCESSING=64]="CF_DISABLE_SPU_COLLISION_PROCESSING"}(Vj||(Vj={})),function(t){t[t.CO_COLLISION_OBJECT=1]="CO_COLLISION_OBJECT",t[t.CO_RIGID_BODY=2]="CO_RIGID_BODY",t[t.CO_GHOST_OBJECT=4]="CO_GHOST_OBJECT",t[t.CO_SOFT_BODY=8]="CO_SOFT_BODY",t[t.CO_HF_FLUID=16]="CO_HF_FLUID",t[t.CO_USER_TYPE=32]="CO_USER_TYPE",t[t.CO_FEATHERSTONE_LINK=64]="CO_FEATHERSTONE_LINK"}(Hj||(Hj={})),function(t){t[t.ACTIVE_TAG=1]="ACTIVE_TAG",t[t.ISLAND_SLEEPING=2]="ISLAND_SLEEPING",t[t.WANTS_DEACTIVATION=3]="WANTS_DEACTIVATION",t[t.DISABLE_DEACTIVATION=4]="DISABLE_DEACTIVATION",t[t.DISABLE_SIMULATION=5]="DISABLE_SIMULATION"}(zj||(zj={})),function(t){t[t.BT_DISABLE_WORLD_GRAVITY=1]="BT_DISABLE_WORLD_GRAVITY",t[t.BT_ENABLE_GYROPSCOPIC_FORCE=2]="BT_ENABLE_GYROPSCOPIC_FORCE"}(Xj||(Xj={}));var Yj=qz,jj=Zz,Kj=function(){var t=e.prototype;function e(){this.id=void 0,this._isEnabled=!1,this._isUsingCCD=!1,this.id=e.idCounter++}return t.setMass=function(t){this._rigidBody.isDynamic&&(Sa.RigidBody_setMass(this.impl,t),this._wakeUpIfSleep(),this._sharedBody.dirty|=Gj.BODY_RE_ADD)},t.setType=function(t){this._sharedBody.setType(t)},t.setLinearDamping=function(){Sa.RigidBody_setDamping(this.impl,this._rigidBody.linearDamping,this._rigidBody.angularDamping)},t.setAngularDamping=function(){Sa.RigidBody_setDamping(this.impl,this._rigidBody.linearDamping,this._rigidBody.angularDamping)},t.useGravity=function(t){if(this._rigidBody.isDynamic){var e=Sa.RigidBody_getFlags(this.impl);t?e&=~Xj.BT_DISABLE_WORLD_GRAVITY:(Sa.RigidBody_setGravity(this.impl,$z(Gz.instance.BT_V3_0,ji.ZERO)),e|=Xj.BT_DISABLE_WORLD_GRAVITY),Sa.RigidBody_setFlags(this.impl,e),this._wakeUpIfSleep(),this._sharedBody.dirty|=Gj.BODY_RE_ADD}},t.useCCD=function(t){Sa.CollisionObject_setCcdMotionThreshold(this.impl,t?.01:0),Sa.CollisionObject_setCcdSweptSphereRadius(this.impl,t?.1:0),this._isUsingCCD=t},t.isUsingCCD=function(){return this._isUsingCCD},t.setLinearFactor=function(t){Sa.RigidBody_setLinearFactor(this.impl,$z(Gz.instance.BT_V3_0,t)),this._wakeUpIfSleep()},t.setAngularFactor=function(t){Sa.RigidBody_setAngularFactor(this.impl,$z(Gz.instance.BT_V3_0,t)),this._wakeUpIfSleep()},t.setAllowSleep=function(t){this._rigidBody.isDynamic&&(t?Sa.CollisionObject_forceActivationState(this.impl,zj.ACTIVE_TAG):Sa.CollisionObject_forceActivationState(this.impl,zj.DISABLE_DEACTIVATION),this._wakeUpIfSleep())},t.clearState=function(){Sa.RigidBody_clearState(this.impl)},t.clearVelocity=function(){this.setLinearVelocity(ji.ZERO),this.setAngularVelocity(ji.ZERO)},t.clearForces=function(){Sa.RigidBody_clearForces(this.impl)},t.initialize=function(t){this._rigidBody=t,this._sharedBody=RX.instance.physicsWorld.getSharedBody(this._rigidBody.node,this),this._sharedBody.reference=!0},t.onEnable=function(){this._isEnabled=!0,this.setMass(this._rigidBody.mass),this.setAllowSleep(this._rigidBody.allowSleep),this.setLinearDamping(this._rigidBody.linearDamping),this.setAngularDamping(this._rigidBody.angularDamping),this.setLinearFactor(this._rigidBody.linearFactor),this.setAngularFactor(this._rigidBody.angularFactor),this.useGravity(this._rigidBody.useGravity),this._sharedBody.bodyEnabled=!0},t.onDisable=function(){this._isEnabled=!1,this._sharedBody.bodyEnabled=!1},t.onDestroy=function(){this._sharedBody.reference=!1,this._rigidBody=null,this._sharedBody=null},t.wakeUp=function(t){void 0===t&&(t=!0),Sa.CollisionObject_activate(this.impl,t)},t.sleep=function(){var t=Sa.CollisionObject_getActivationState(this.impl);t!==zj.DISABLE_DEACTIVATION&&t!==zj.DISABLE_SIMULATION&&Sa.CollisionObject_forceActivationState(this.impl,zj.ISLAND_SLEEPING)},t.setSleepThreshold=function(t){this._wakeUpIfSleep(),Sa.RigidBody_setSleepingThresholds(this.impl,t,t)},t.getSleepThreshold=function(){return Sa.RigidBody_getLinearSleepingThreshold(this.impl)},t.getLinearVelocity=function(t){return tX(t,Sa.RigidBody_getLinearVelocity(this.impl))},t.setLinearVelocity=function(t){this._wakeUpIfSleep(),$z(Sa.RigidBody_getLinearVelocity(this.impl),t)},t.getAngularVelocity=function(t){return tX(t,Sa.RigidBody_getAngularVelocity(this.impl))},t.setAngularVelocity=function(t){this._wakeUpIfSleep(),$z(Sa.RigidBody_getAngularVelocity(this.impl),t)},t.applyLocalForce=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=this._sharedBody.node.worldRotation,n=ji.transformQuat(Yj,t,i),r=e?ji.transformQuat(jj,e,i):ji.ZERO;Sa.RigidBody_applyForce(this.impl,$z(Gz.instance.BT_V3_0,n),$z(Gz.instance.BT_V3_1,r))},t.applyLocalTorque=function(t){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep(),ji.transformQuat(Yj,t,this._sharedBody.node.worldRotation),Sa.RigidBody_applyTorque(this.impl,$z(Gz.instance.BT_V3_0,Yj))},t.applyLocalImpulse=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=this._sharedBody.node.worldRotation,n=ji.transformQuat(Yj,t,i),r=e?ji.transformQuat(jj,e,i):ji.ZERO;Sa.RigidBody_applyImpulse(this.impl,$z(Gz.instance.BT_V3_0,n),$z(Gz.instance.BT_V3_1,r))},t.applyForce=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=e||ji.ZERO;Sa.RigidBody_applyForce(this.impl,$z(Gz.instance.BT_V3_0,t),$z(Gz.instance.BT_V3_1,i))},t.applyTorque=function(t){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep(),Sa.RigidBody_applyTorque(this.impl,$z(Gz.instance.BT_V3_0,t))},t.applyImpulse=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=e||ji.ZERO;Sa.RigidBody_applyImpulse(this.impl,$z(Gz.instance.BT_V3_0,t),$z(Gz.instance.BT_V3_1,i))},t.getGroup=function(){return this._sharedBody.collisionFilterGroup},t.setGroup=function(t){this._sharedBody.collisionFilterGroup=t},t.addGroup=function(t){this._sharedBody.collisionFilterGroup|=t},t.removeGroup=function(t){this._sharedBody.collisionFilterGroup&=~t},t.getMask=function(){return this._sharedBody.collisionFilterMask},t.setMask=function(t){this._sharedBody.collisionFilterMask=t},t.addMask=function(t){this._sharedBody.collisionFilterMask|=t},t.removeMask=function(t){this._sharedBody.collisionFilterMask&=~t},t._wakeUpIfSleep=function(){this.isAwake||Sa.CollisionObject_activate(this.impl,!0)},Pi(e,[{key:"isAwake",get:function(){var t=Sa.CollisionObject_getActivationState(this.impl);return t===zj.ACTIVE_TAG||t===zj.DISABLE_DEACTIVATION}},{key:"isSleepy",get:function(){return Sa.CollisionObject_getActivationState(this.impl)===zj.WANTS_DEACTIVATION}},{key:"isSleeping",get:function(){return Sa.CollisionObject_getActivationState(this.impl)===zj.ISLAND_SLEEPING}},{key:"impl",get:function(){return this._sharedBody.body}},{key:"rigidBody",get:function(){return this._rigidBody}},{key:"sharedBody",get:function(){return this._sharedBody}},{key:"isEnabled",get:function(){return this._isEnabled}}]),e}();Kj.idCounter=0;var qj=qz,Zj=Qz,Qj=0,Jj=function(){function t(e,i){this.id=void 0,this.node=void 0,this.wrappedWorld=void 0,this.wrappedJoints0=[],this.wrappedJoints1=[],this.dirty=0,this._collisionFilterGroup=RX.PhysicsGroup.DEFAULT,this._collisionFilterMask=-1,this.ref=0,this.bodyIndex=-1,this.ghostIndex=-1,this._wrappedBody=null,this.id=t.idCounter++,this.wrappedWorld=i,this.node=e}t.getSharedBody=function(e,i,n){var r,s=e.uuid;if(t.sharedBodesMap.has(s))r=t.sharedBodesMap.get(s);else{r=new t(e,i);var a=tz.DEFAULT,o=RX.instance.collisionMatrix[a];r._collisionFilterGroup=a,r._collisionFilterMask=o,t.sharedBodesMap.set(e.uuid,r)}if(n){r._wrappedBody=n;var h=n.rigidBody.group,l=RX.instance.collisionMatrix[h];r._collisionFilterGroup=h,r._collisionFilterMask=l}return r};var e=t.prototype;return e._instantiateBodyStruct=function(){if(!this._bodyStruct){var t=0;this._wrappedBody&&this._wrappedBody.rigidBody.enabled&&this._wrappedBody.rigidBody.isDynamic&&(t=this._wrappedBody.rigidBody.mass);var e=Gz.instance.BT_TRANSFORM_0,i=Gz.instance.BT_QUAT_0;$z(Sa.Transform_getOrigin(e),this.node.worldPosition),eX(i,this.node.worldRotation),Sa.Transform_setRotation(e,i);var n=Sa.ccMotionState_new(this.id,e),r=Sa.RigidBody_new(t,n),s=RX.instance.sleepThreshold;Sa.RigidBody_setSleepingThresholds(r,s,s),this._bodyStruct={id:Qj++,body:r,motionState:n,compound:Sa.ccCompoundShape_new(),wrappedShapes:[],useCompound:!1},Gz.setWrapper(this.id,Sa.BODY_CACHE_NAME,this),this._ghostStruct&&Sa.CollisionObject_setIgnoreCollisionCheck(this.ghost,this.body,!0),this._wrappedBody&&this.setBodyType(this._wrappedBody.rigidBody.type)}},e._instantiateGhostStruct=function(){if(!this._ghostStruct){var t=Sa.CollisionObject_new(),e=Sa.ccCompoundShape_new();Sa.CollisionObject_setCollisionShape(t,e),Sa.CollisionObject_setCollisionFlags(t,Vj.CF_STATIC_OBJECT|Vj.CF_NO_CONTACT_RESPONSE),this._ghostStruct={id:Qj++,ghost:t,compound:e,wrappedShapes:[]},this._bodyStruct&&Sa.CollisionObject_setIgnoreCollisionCheck(this.body,this.ghost,!0),this._wrappedBody&&this.setGhostType(this._wrappedBody.rigidBody.type)}},e.setType=function(t){this.setBodyType(t),this.setGhostType(t)},e.setBodyType=function(t){if(this._bodyStruct&&this._wrappedBody){var e=this._bodyStruct.body,i=this._wrappedBody,n=i.rigidBody,r=Sa.CollisionObject_getCollisionFlags(e),s=Gz.instance.BT_V3_0;switch(t){case qH.DYNAMIC:r&=~Vj.CF_KINEMATIC_OBJECT,r&=~Vj.CF_STATIC_OBJECT,Sa.CollisionObject_setCollisionFlags(e,r),i.setMass(n.mass),i.useGravity(n.useGravity),i.setAllowSleep(n.allowSleep);break;case qH.KINEMATIC:Sa.Vec3_set(s,0,0,0),Sa.RigidBody_setMassProps(e,0,s),r|=Vj.CF_KINEMATIC_OBJECT,r&=~Vj.CF_STATIC_OBJECT,Sa.CollisionObject_setCollisionFlags(e,r),Sa.CollisionObject_forceActivationState(e,zj.DISABLE_DEACTIVATION);break;case qH.STATIC:default:Sa.Vec3_set(s,0,0,0),Sa.RigidBody_setMassProps(e,0,s),r|=Vj.CF_STATIC_OBJECT,r&=~Vj.CF_KINEMATIC_OBJECT,Sa.CollisionObject_setCollisionFlags(e,r),Sa.CollisionObject_forceActivationState(e,zj.ISLAND_SLEEPING)}this.dirty|=Gj.BODY_RE_ADD}},e.setGhostType=function(t){if(this._ghostStruct){var e=this._ghostStruct.ghost,i=Sa.CollisionObject_getCollisionFlags(e);switch(t){case qH.DYNAMIC:case qH.KINEMATIC:i&=~Vj.CF_STATIC_OBJECT,i|=Vj.CF_KINEMATIC_OBJECT,Sa.CollisionObject_setCollisionFlags(e,i),Sa.CollisionObject_forceActivationState(e,zj.DISABLE_DEACTIVATION);break;case qH.STATIC:default:i&=~Vj.CF_KINEMATIC_OBJECT,i|=Vj.CF_STATIC_OBJECT,Sa.CollisionObject_setCollisionFlags(e,i),Sa.CollisionObject_forceActivationState(e,zj.ISLAND_SLEEPING)}this.dirty|=Gj.GHOST_RE_ADD}},e.addShape=function(t,e){function i(t,e){Sa.CollisionObject_setCollisionShape(t.body,e),t.dirty|=Gj.BODY_RE_ADD,t._wrappedBody&&t._wrappedBody.isEnabled&&t._wrappedBody.setMass(t._wrappedBody.rigidBody.mass)}if(e)this.ghostStruct.wrappedShapes.indexOf(t)<0&&(this.ghostStruct.wrappedShapes.push(t),t.setCompound(this.ghostCompoundShape),this.ghostEnabled=!0);else if(this.bodyStruct.wrappedShapes.indexOf(t)<0){if(this.bodyStruct.wrappedShapes.push(t),this.bodyStruct.useCompound)t.setCompound(this.bodyCompoundShape);else{var n=this.bodyStruct.wrappedShapes.length;if(1!==n||t.needCompound()){this.bodyStruct.useCompound=!0;for(var r=0;r<n;r++)this.bodyStruct.wrappedShapes[r].setCompound(this.bodyCompoundShape);i(this,this.bodyStruct.compound)}else i(this,t.impl)}this.bodyEnabled=!0}},e.removeShape=function(t,e){if(e){var i=this.ghostStruct.wrappedShapes.indexOf(t);i>=0&&(Ls(this.ghostStruct.wrappedShapes,i),t.setCompound(0),this.ghostEnabled=!1)}else{var n=this.bodyStruct.wrappedShapes.indexOf(t);n>=0&&(this.bodyStruct.useCompound?t.setCompound(0):Sa.CollisionObject_setCollisionShape(this.body,Sa.EmptyShape_static()),Sa.CollisionObject_activate(this.body,!0),this.dirty|=Gj.BODY_RE_ADD,Ls(this.bodyStruct.wrappedShapes,n),this.bodyEnabled=!1)}},e.addJoint=function(t,e){e?this.wrappedJoints1.indexOf(t)<0&&this.wrappedJoints1.push(t):this.wrappedJoints0.indexOf(t)<0&&this.wrappedJoints0.push(t)},e.removeJoint=function(t,e){if(e){var i=this.wrappedJoints1.indexOf(t);i>=0&&Ls(this.wrappedJoints1,i)}else{var n=this.wrappedJoints0.indexOf(t);n>=0&&Ls(this.wrappedJoints0,n)}},e.updateDirty=function(){this.dirty&&(this.bodyIndex>=0&&this.dirty&Gj.BODY_RE_ADD&&this.updateBodyByReAdd(),this.ghostIndex>=0&&this.dirty&Gj.GHOST_RE_ADD&&this.updateGhostByReAdd(),this.dirty=0)},e.syncSceneToPhysics=function(){if(this.node.hasChangedFlags){var t=Gz.instance.BT_QUAT_0,e=Sa.CollisionObject_getWorldTransform(this.body);if(eX(t,this.node.worldRotation),$z(Sa.Transform_getOrigin(e),this.node.worldPosition),Sa.Transform_setRotation(e,t),this.node.hasChangedFlags&pr.SCALE&&this.syncBodyScale(),Sa.CollisionObject_isKinematicObject(this.body)){var i=Sa.RigidBody_getMotionState(this.body);i&&Sa.MotionState_setWorldTransform(i,e)}else this.isBodySleeping()&&Sa.CollisionObject_activate(this.body)}},e.syncPhysicsToScene=function(){Sa.CollisionObject_isStaticOrKinematicObject(this.body)||this.syncPhysicsToGraphics()},e.syncPhysicsToGraphics=function(){if(!this.isBodySleeping()){var t=Gz.instance.BT_QUAT_0,e=Gz.instance.BT_TRANSFORM_0;if(Sa.MotionState_getWorldTransform(Sa.RigidBody_getMotionState(this.body),e),Sa.Transform_getRotation(e,t),this.node.worldRotation=iX(Zj,t),this.node.worldPosition=tX(qj,Sa.Transform_getOrigin(e)),this._ghostStruct){var i=Sa.CollisionObject_getWorldTransform(this.ghost);$z(Sa.Transform_getOrigin(i),this.node.worldPosition),eX(t,this.node.worldRotation),Sa.Transform_setRotation(i,t)}}},e.syncSceneToGhost=function(){if(this.node.hasChangedFlags){var t=Gz.instance.BT_QUAT_0,e=Sa.CollisionObject_getWorldTransform(this.ghost);$z(Sa.Transform_getOrigin(e),this.node.worldPosition),eX(t,this.node.worldRotation),Sa.Transform_setRotation(e,t),this.node.hasChangedFlags&pr.SCALE&&this.syncGhostScale(),Sa.CollisionObject_activate(this.ghost)}},e.syncInitialBody=function(){var t=Gz.instance.BT_QUAT_0,e=Sa.CollisionObject_getWorldTransform(this.body);$z(Sa.Transform_getOrigin(e),this.node.worldPosition),eX(t,this.node.worldRotation),Sa.Transform_setRotation(e,t),this.syncBodyScale(),Sa.CollisionObject_activate(this.body)},e.syncInitialGhost=function(){var t=Gz.instance.BT_QUAT_0,e=Sa.CollisionObject_getWorldTransform(this.ghost);$z(Sa.Transform_getOrigin(e),this.node.worldPosition),eX(t,this.node.worldRotation),Sa.Transform_setRotation(e,t),this.syncGhostScale(),Sa.CollisionObject_activate(this.body)},e.syncBodyScale=function(){for(var t=0;t<this.bodyStruct.wrappedShapes.length;t++)this.bodyStruct.wrappedShapes[t].updateScale();for(var e=0;e<this.wrappedJoints0.length;e++)this.wrappedJoints0[e].updateScale0();for(var i=0;i<this.wrappedJoints1.length;i++)this.wrappedJoints1[i].updateScale1()},e.syncGhostScale=function(){for(var t=0;t<this.ghostStruct.wrappedShapes.length;t++)this.ghostStruct.wrappedShapes[t].updateScale()},e.updateBodyByReAdd=function(){this.bodyIndex>=0&&(this.wrappedWorld.removeSharedBody(this),this.bodyIndex=this.wrappedWorld.bodies.length,this.wrappedWorld.addSharedBody(this))},e.updateGhostByReAdd=function(){this.ghostIndex>=0&&(this.wrappedWorld.removeGhostObject(this),this.ghostIndex=this.wrappedWorld.ghosts.length,this.wrappedWorld.addGhostObject(this))},e.destroy=function(){if(t.sharedBodesMap.delete(this.node.uuid),this.node=null,this.wrappedWorld=null,this._bodyStruct){var e=this._bodyStruct;Gz.delWrapper(e.body,Sa.BODY_CACHE_NAME),Sa._safe_delete(e.motionState,ba.EBulletTypeMotionState),Sa._safe_delete(e.compound,ba.EBulletTypeCollisionShape),Sa._safe_delete(e.body,ba.EBulletTypeCollisionObject),this._bodyStruct=null}if(this._ghostStruct){var i=this._ghostStruct;Sa._safe_delete(i.compound,ba.EBulletTypeCollisionShape),Sa._safe_delete(i.ghost,ba.EBulletTypeCollisionObject),this._ghostStruct=null}},e.isBodySleeping=function(){return Sa.CollisionObject_getActivationState(this.body)===zj.ISLAND_SLEEPING},Pi(t,[{key:"wrappedBody",get:function(){return this._wrappedBody}},{key:"bodyCompoundShape",get:function(){return this.bodyStruct.compound}},{key:"ghostCompoundShape",get:function(){return this.ghostStruct.compound}},{key:"body",get:function(){return this.bodyStruct.body}},{key:"ghost",get:function(){return this.ghostStruct.ghost}},{key:"collisionFilterGroup",get:function(){return this._collisionFilterGroup},set:function(t){t!==this._collisionFilterGroup&&(this._collisionFilterGroup=t,this.dirty|=Gj.BODY_RE_ADD,this.dirty|=Gj.GHOST_RE_ADD)}},{key:"collisionFilterMask",get:function(){return this._collisionFilterMask},set:function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this.dirty|=Gj.BODY_RE_ADD,this.dirty|=Gj.GHOST_RE_ADD)}},{key:"bodyStruct",get:function(){return this._instantiateBodyStruct(),this._bodyStruct}},{key:"ghostStruct",get:function(){return this._instantiateGhostStruct(),this._ghostStruct}},{key:"bodyEnabled",set:function(t){if(t){if(this.bodyIndex<0){if(0===this.bodyStruct.wrappedShapes.length){if(!this.wrappedBody)return;if(!this.wrappedBody.rigidBody.isDynamic)return}this.bodyIndex=this.wrappedWorld.bodies.length,this.wrappedWorld.addSharedBody(this),this.syncInitialBody()}}else this.bodyIndex>=0&&(0===this.bodyStruct.wrappedShapes.length&&null==this.wrappedBody||0===this.bodyStruct.wrappedShapes.length&&null!=this.wrappedBody&&!this.wrappedBody.isEnabled||0===this.bodyStruct.wrappedShapes.length&&null!=this.wrappedBody&&!this.wrappedBody.rigidBody.enabledInHierarchy)&&(Sa.RigidBody_clearState(this.body),this.bodyIndex=-1,this.wrappedWorld.removeSharedBody(this))}},{key:"ghostEnabled",set:function(t){t?this.ghostIndex<0&&this.ghostStruct.wrappedShapes.length>0&&(this.ghostIndex=1,this.wrappedWorld.addGhostObject(this),this.syncInitialGhost()):this.ghostIndex>=0&&0===this.ghostStruct.wrappedShapes.length&&this.ghost&&(this.ghostIndex=-1,this.wrappedWorld.removeGhostObject(this))}},{key:"reference",set:function(t){t?this.ref++:this.ref--,0===this.ref&&this.destroy()}}]),t}();Jj.idCounter=0,Jj.sharedBodesMap=new Map;var $j=qz,tK={},eK=function(){function t(){this.id=t.idCounter++,this._isEnabled=!1,this._isTrigger=!1,this._isInitialized=!1,this._impl=0,this._compound=0,this.quat=Sa.Quat_new(0,0,0,1),this.transform=Sa.Transform_new()}var e=t.prototype;return e.updateEventListener=function(){this._sharedBody.wrappedWorld.updateNeedEmitEvents(this.collider.needCollisionEvent||this.collider.needTriggerEvent)},e.setMaterial=function(t){var e=null==t?RX.instance.defaultMaterial:t;if(!this._isTrigger&&this._isEnabled)if(this._compound){tK[e._uuid]||(tK[e._uuid]=Sa.ccMaterial_new());var i=tK[e._uuid];Sa.ccMaterial_set(i,e.restitution,e.friction,e.rollingFriction,e.spinningFriction),Sa.CollisionShape_setMaterial(this._impl,i)}else Sa.CollisionObject_setMaterial(this._sharedBody.body,e.restitution,e.friction,e.rollingFriction,e.spinningFriction)},e.setCenter=function(t){ji.copy($j,t),$j.multiply(this._collider.node.worldScale),$z(Sa.Transform_getOrigin(this.transform),$j),this.updateCompoundTransform()},e.setAsTrigger=function(t){this._isTrigger!==t&&(this._isEnabled&&(this._sharedBody.removeShape(this,!t),this._sharedBody.addShape(this,t)),this._isTrigger=t)},e.getAABB=function(t){var e=Gz.instance.BT_TRANSFORM_0;Sa.Transform_setIdentity(e),Sa.Transform_setRotation(e,eX(Gz.instance.BT_QUAT_0,this._collider.node.worldRotation));var i=Gz.instance.BT_V3_0,n=Gz.instance.BT_V3_1;Sa.CollisionShape_getAabb(this._impl,e,i,n),t.halfExtents.x=(Sa.Vec3_x(n)-Sa.Vec3_x(i))/2,t.halfExtents.y=(Sa.Vec3_y(n)-Sa.Vec3_y(i))/2,t.halfExtents.z=(Sa.Vec3_z(n)-Sa.Vec3_z(i))/2,ji.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.getBoundingSphere=function(t){t.radius=Sa.CollisionShape_getLocalBoundingSphere(this._impl),ji.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.initialize=function(t){this._collider=t,this._isInitialized=!0,this._sharedBody=RX.instance.physicsWorld.getSharedBody(this._collider.node),this._sharedBody.reference=!0,this.onComponentSet(),this.setWrapper()},e.setWrapper=function(){Gz.isNotEmptyShape(this._impl)&&(Sa.CollisionShape_setUserPointer(this._impl,this._impl),Gz.setWrapper(this._impl,t.TYPE,this))},e.onLoad=function(){this.setCenter(this._collider.center),this.setAsTrigger(this._collider.isTrigger)},e.onEnable=function(){this._isEnabled=!0,this._sharedBody.addShape(this,this._isTrigger),this.setMaterial(this.collider.sharedMaterial)},e.onDisable=function(){this._isEnabled=!1,this._sharedBody.removeShape(this,this._isTrigger)},e.onDestroy=function(){this._sharedBody.reference=!1,this._collider=null,Sa._safe_delete(this.quat,ba.EBulletTypeQuat),Sa._safe_delete(this.transform,ba.EBulletTypeTransform),this._compound&&Sa._safe_delete(this._compound,ba.EBulletTypeCollisionShape),Gz.isNotEmptyShape(this._impl)&&(Sa._safe_delete(this._impl,ba.EBulletTypeCollisionShape),Gz.delWrapper(this._impl,t.TYPE))},e.updateByReAdd=function(){this._isEnabled&&(this._sharedBody.removeShape(this,this._isTrigger),this._sharedBody.addShape(this,this._isTrigger))},e.getGroup=function(){return this._sharedBody.collisionFilterGroup},e.setGroup=function(t){this._sharedBody.collisionFilterGroup=t},e.addGroup=function(t){this._sharedBody.collisionFilterGroup|=t},e.removeGroup=function(t){this._sharedBody.collisionFilterGroup&=~t},e.getMask=function(){return this._sharedBody.collisionFilterMask},e.setMask=function(t){this._sharedBody.collisionFilterMask=t},e.addMask=function(t){this._sharedBody.collisionFilterMask|=t},e.removeMask=function(t){this._sharedBody.collisionFilterMask&=~t},e.setCompound=function(t){this._compound&&Sa.CompoundShape_removeChildShape(this._compound,this._impl),t&&Sa.CompoundShape_addChildShape(t,this.transform,this._impl),this._compound=t},e.updateScale=function(){this.setCenter(this._collider.center)},e.updateCompoundTransform=function(){this._compound?Sa.CompoundShape_updateChildTransform(this._compound,this._impl,this.transform,!0):this._isEnabled&&!this._isTrigger&&this._sharedBody&&!this._sharedBody.bodyStruct.useCompound&&(this._sharedBody.dirty|=Gj.BODY_RE_ADD)},e.needCompound=function(){return this._collider.type===JH.TERRAIN||!this._collider.center.equals(ji.ZERO)},Pi(t,[{key:"attachedRigidBody",get:function(){return this._sharedBody.wrappedBody?this._sharedBody.wrappedBody.rigidBody:null}},{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}},{key:"sharedBody",get:function(){return this._sharedBody}}]),t}();eK.TYPE="shape",eK.idCounter=0;var iK=function(){function t(){this.matrix=[]}var e=t.prototype;return e.get=function(t,e){if(e>t){var i=e;e=t,t=i}return this.matrix[(t*(t+1)>>1)+e-1]},e.set=function(t,e,i){if(e>t){var n=e;e=t,t=n}this.matrix[(t*(t+1)>>1)+e-1]=i?1:0},e.reset=function(){this.matrix.length=0},e.setNumObjects=function(t){this.matrix.length=t*(t-1)>>1},t}(),nK=function(){function t(){this.data=void 0,this.data={keys:[]}}var e=t.prototype;return e.get=function(t,e){if(t>e){var i=e;e=t,t=i}return this.data[t+"-"+e]},e.set=function(t,e,i){if(t>e){var n=e;e=t,t=n}var r=t+"-"+e;if(null==i){var s=this.data.keys.indexOf(r);if(-1!==s)return this.data.keys.splice(s,1),delete this.data[r],i}return this.get(t,e)||this.data.keys.push(r),this.data[r]=i,this.data[r]},e.reset=function(){this.data={keys:[]}},e.getLength=function(){return this.data.keys.length},e.getKeyByIndex=function(t){return this.data.keys[t]},e.getDataByKey=function(t){return this.data[t]},t}(),rK=function(){function t(t){this.impl=0,this.event=void 0,this.event=t}var e=t.prototype;return e.getLocalPointOnA=function(t){this.impl&&tX(t,Sa.ManifoldPoint_get_m_localPointA(this.impl))},e.getLocalPointOnB=function(t){this.impl&&tX(t,Sa.ManifoldPoint_get_m_localPointB(this.impl))},e.getWorldPointOnA=function(t){this.impl&&tX(t,Sa.ManifoldPoint_get_m_positionWorldOnA(this.impl))},e.getWorldPointOnB=function(t){this.impl&&tX(t,Sa.ManifoldPoint_get_m_positionWorldOnB(this.impl))},e.getLocalNormalOnA=function(t){if(this.impl){var e=Gz.instance.BT_QUAT_0,i=Sa.PersistentManifold_getBody0(this.event.impl),n=Sa.CollisionObject_getWorldTransform(i);Sa.Transform_getRotation(n,e);var r=Qz;iX(r,e),Ji.conjugate(r,r),tX(t,Sa.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||ji.negate(t,t),ji.transformQuat(t,t,r)}},e.getLocalNormalOnB=function(t){if(this.impl){var e=Gz.instance.BT_QUAT_0,i=Sa.PersistentManifold_getBody1(this.event.impl),n=Sa.CollisionObject_getWorldTransform(i);Sa.Transform_getRotation(n,e);var r=Qz;iX(r,e),Ji.conjugate(r,r),tX(t,Sa.ManifoldPoint_get_m_normalWorldOnB(this.impl)),ji.transformQuat(t,t,r)}},e.getWorldNormalOnA=function(t){this.impl&&(tX(t,Sa.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||ji.negate(t,t))},e.getWorldNormalOnB=function(t){this.impl&&tX(t,Sa.ManifoldPoint_get_m_normalWorldOnB(this.impl))},Pi(t,[{key:"isBodyA",get:function(){return this.event.selfCollider.shape.sharedBody.body===Sa.PersistentManifold_getBody0(this.event.impl)}}]),t}(),sK=[],aK=qz,oK=Zz,hK=function(){var t=e.prototype;function e(){this._world=void 0,this._broadphase=void 0,this._solver=void 0,this._dispatcher=void 0,this._needEmitEvents=!1,this._needSyncAfterEvents=!1,this.bodies=[],this.ghosts=[],this.constraints=[],this.triggerArrayMat=new iK,this.collisionArrayMat=new iK,this.contactsDic=new nK,this.oldContactsDic=new nK,this._broadphase=Sa.DbvtBroadphase_new(),this._dispatcher=Sa.CollisionDispatcher_new(),this._solver=Sa.SequentialImpulseConstraintSolver_new(),this._world=Sa.ccDiscreteDynamicsWorld_new(this._dispatcher,this._broadphase,this._solver)}return t.setDefaultMaterial=function(){},t.setAllowSleep=function(t){Sa.ccDiscreteDynamicsWorld_setAllowSleep(this._world,t)},t.setGravity=function(t){Sa.DynamicsWorld_setGravity(this._world,$z(Gz.instance.BT_V3_0,t))},t.updateNeedEmitEvents=function(t){if(this.ghosts)if(t)this._needEmitEvents=!0;else{this._needEmitEvents=!1;for(var e=0;e<this.ghosts.length;e++)for(var i=this.ghosts[e].ghostStruct.wrappedShapes,n=0;n<i.length;n++){var r=i[n].collider;if(r.needCollisionEvent||r.needTriggerEvent)return void(this._needEmitEvents=!0)}for(var s=0;s<this.bodies.length;s++)for(var a=this.bodies[s].bodyStruct.wrappedShapes,o=0;o<a.length;o++){var h=a[o].collider;if(h.needCollisionEvent||h.needTriggerEvent)return void(this._needEmitEvents=!0)}}},t.destroy=function(){(this.constraints.length||this.bodies.length)&&ks("You should destroy all physics component first."),Sa._safe_delete(this._world,ba.EBulletTypeCollisionWorld),Sa._safe_delete(this._broadphase,ba.EBulletTypeDbvtBroadPhase),Sa._safe_delete(this._dispatcher,ba.EBulletTypeCollisionDispatcher),Sa._safe_delete(this._solver,ba.EBulletTypeSequentialImpulseConstraintSolver),this.bodies=null,this.ghosts=null,this.constraints=null,this.triggerArrayMat=null,this.collisionArrayMat=null,this.contactsDic=null,this.oldContactsDic=null,sK.length=0},t.step=function(t,e,i){void 0===i&&(i=0),(this.bodies.length||this.ghosts.length)&&(void 0===e&&(e=t),Sa.DynamicsWorld_stepSimulation(this._world,e,i,t))},t.syncSceneToPhysics=function(){for(var t=this.ghosts.length-1;t>=0;t--){var e=this.ghosts[t];e.updateDirty(),e.syncSceneToGhost()}for(var i=this.bodies.length-1;i>=0;i--){var n=this.bodies[i];n.updateDirty(),n.syncSceneToPhysics()}},t.syncAfterEvents=function(){this._needSyncAfterEvents&&this.syncSceneToPhysics()},t.raycast=function(t,e,i,n){t.computeHit(aK,e.maxDistance);var r=$z(Gz.instance.BT_V3_0,aK),s=$z(Gz.instance.BT_V3_1,t.o),a=Sa.ccAllRayCallback_static();if(Sa.ccAllRayCallback_reset(a,s,r,e.mask,e.queryTrigger),Sa.ccAllRayCallback_setFlags(a,xa.UseSubSimplexConvexCastRaytest),Sa.CollisionWorld_rayTest(this._world,s,r,a),Sa.RayCallback_hasHit(a)){for(var o=Sa.ccAllRayCallback_getHitPointWorld(a),h=Sa.ccAllRayCallback_getHitNormalWorld(a),l=Sa.ccAllRayCallback_getCollisionShapePtrs(a),u=0,c=Sa.int_array_size(l);u<c;u++){tX(aK,Sa.Vec3_array_at(o,u)),tX(oK,Sa.Vec3_array_at(h,u));var d=Gz.getWrapper(Sa.int_array_at(l,u),eK.TYPE),_=i.add();n.push(_),_._assign(aK,ji.distance(t.o,aK),d.collider,oK)}return!0}return!1},t.raycastClosest=function(t,e,i){t.computeHit(aK,e.maxDistance);var n=$z(Gz.instance.BT_V3_0,aK),r=$z(Gz.instance.BT_V3_1,t.o),s=Sa.ccClosestRayCallback_static();if(Sa.ccClosestRayCallback_reset(s,r,n,e.mask,e.queryTrigger),Sa.ccClosestRayCallback_setFlags(s,xa.UseSubSimplexConvexCastRaytest),Sa.CollisionWorld_rayTest(this._world,r,n,s),Sa.RayCallback_hasHit(s)){tX(aK,Sa.ccClosestRayCallback_getHitPointWorld(s)),tX(oK,Sa.ccClosestRayCallback_getHitNormalWorld(s));var a=Gz.getWrapper(Sa.ccClosestRayCallback_getCollisionShapePtr(s),eK.TYPE);return i._assign(aK,ji.distance(t.o,aK),a.collider,oK),!0}return!1},t.getSharedBody=function(t,e){return Jj.getSharedBody(t,this,e)},t.addSharedBody=function(t){this.bodies.indexOf(t)<0&&(this.bodies.push(t),Sa.DynamicsWorld_addRigidBody(this._world,t.body,t.collisionFilterGroup,t.collisionFilterMask))},t.removeSharedBody=function(t){var e=this.bodies.indexOf(t);e>=0&&(Ls(this.bodies,e),Sa.DynamicsWorld_removeRigidBody(this._world,t.body))},t.addGhostObject=function(t){this.ghosts.indexOf(t)<0&&(this.ghosts.push(t),Sa.CollisionWorld_addCollisionObject(this._world,t.ghost,t.collisionFilterGroup,t.collisionFilterMask))},t.removeGhostObject=function(t){var e=this.ghosts.indexOf(t);e>=0&&(Ls(this.ghosts,e),Sa.CollisionWorld_removeCollisionObject(this._world,t.ghost))},t.addConstraint=function(t){var e=this.constraints.indexOf(t);e<0&&(this.constraints.push(t),Sa.DynamicsWorld_addConstraint(this.impl,t.impl,!t.constraint.enableCollision),t.index=e)},t.removeConstraint=function(t){var e=this.constraints.indexOf(t);e>=0&&(this.constraints.splice(e,1),Sa.DynamicsWorld_removeConstraint(this.impl,t.impl),t.index=-1)},t.emitEvents=function(){if(this._needSyncAfterEvents=!1,this._needEmitEvents){this.gatherConatactData();for(var t=this.contactsDic.getLength();t--;){sK.push.apply(sK,Uz.contacts),Uz.contacts.length=0;var e=this.contactsDic.getKeyByIndex(t),i=this.contactsDic.getDataByKey(e),n=i.shape0,r=i.shape1;this.oldContactsDic.set(n.id,r.id,i);var s=n.collider,a=r.collider;if(s&&a){if(s.isTrigger||a.isTrigger)this.triggerArrayMat.get(n.id,r.id)?kz.type="onTriggerStay":(kz.type="onTriggerEnter",this.triggerArrayMat.set(n.id,r.id,!0)),kz.impl=i.impl,kz.selfCollider=s,kz.otherCollider=a,s.emit(kz.type,kz),kz.selfCollider=a,kz.otherCollider=s,a.emit(kz.type,kz),this._needSyncAfterEvents=!0;else{var o=s.attachedRigidBody,h=a.attachedRigidBody;if(o&&h){if(o.isSleeping&&h.isSleeping)continue}else if(!o&&h){if(h.isSleeping)continue}else if(!h&&o&&o.isSleeping)continue;this.collisionArrayMat.get(n.id,r.id)?Uz.type="onCollisionStay":(Uz.type="onCollisionEnter",this.collisionArrayMat.set(n.id,r.id,!0));for(var l=0;l<i.contacts.length;l++){var u=i.contacts[l];if(sK.length>0){var c=sK.pop();c.impl=u,Uz.contacts.push(c)}else{var d=new rK(Uz);d.impl=u,Uz.contacts.push(d)}}Uz.impl=i.impl,Uz.selfCollider=s,Uz.otherCollider=a,s.emit(Uz.type,Uz),Uz.selfCollider=a,Uz.otherCollider=s,a.emit(Uz.type,Uz),this._needSyncAfterEvents=!0}null==this.oldContactsDic.get(n.id,r.id)&&this.oldContactsDic.set(n.id,r.id,i)}}for(var _=this.oldContactsDic.getLength();_--;){var f=this.oldContactsDic.getKeyByIndex(_),p=this.oldContactsDic.getDataByKey(f),g=p.shape0,m=p.shape1,v=g.collider,y=m.collider;if(v&&y){var T=v.isTrigger||y.isTrigger;null==this.contactsDic.getDataByKey(f)&&(T?this.triggerArrayMat.get(g.id,m.id)&&(kz.type="onTriggerExit",kz.selfCollider=v,kz.otherCollider=y,v.emit(kz.type,kz),kz.selfCollider=y,kz.otherCollider=v,y.emit(kz.type,kz),this.triggerArrayMat.set(g.id,m.id,!1),this.oldContactsDic.set(g.id,m.id,null),this._needSyncAfterEvents=!0):this.collisionArrayMat.get(g.id,m.id)&&(sK.push.apply(sK,Uz.contacts),Uz.contacts.length=0,Uz.type="onCollisionExit",Uz.selfCollider=v,Uz.otherCollider=y,v.emit(Uz.type,Uz),Uz.selfCollider=y,Uz.otherCollider=v,y.emit(Uz.type,Uz),this.collisionArrayMat.set(g.id,m.id,!1),this.oldContactsDic.set(g.id,m.id,null),this._needSyncAfterEvents=!0))}}this.contactsDic.reset()}},t.gatherConatactData=function(){for(var t=Sa.Dispatcher_getNumManifolds(this._dispatcher),e=0;e<t;e++)for(var i=Sa.Dispatcher_getManifoldByIndexInternal(this._dispatcher,e),n=Sa.PersistentManifold_getNumContacts(i),r=0;r<n;r++){var s=Sa.PersistentManifold_getContactPoint(i,r),a=Sa.ManifoldPoint_getShape0(s),o=Sa.ManifoldPoint_getShape1(s),h=Gz.getWrapper(a,eK.TYPE),l=Gz.getWrapper(o,eK.TYPE);if(h.collider.needTriggerEvent||l.collider.needTriggerEvent||h.collider.needCollisionEvent||l.collider.needCollisionEvent){var u=this.contactsDic.get(h.id,l.id);u||(u=this.contactsDic.set(h.id,l.id,{shape0:h,shape1:l,contacts:[],impl:i})),u.contacts.push(s)}}},Pi(e,[{key:"impl",get:function(){return this._world}}]),e}(),lK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.updateSize=function(){var t=Gz.instance.BT_V3_0;$z(t,this.getMinUnscaledHalfExtents(dW)),Sa.BoxShape_setUnscaledHalfExtents(this.impl,t),this.updateCompoundTransform()},i.onComponentSet=function(){var t=Gz.instance.BT_V3_0;$z(t,this.getMinUnscaledHalfExtents(dW)),this._impl=Sa.BoxShape_new(t),this.updateScale()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=Gz.instance.BT_V3_0;Sa.CollisionShape_setLocalScaling(this._impl,$z(e,this.getMinScale(dW))),this.updateCompoundTransform()},i.getMinUnscaledHalfExtents=function(t){var e=this.collider.size,i=_W(dW.set(this._collider.node.worldScale)),n=RX.instance.minVolumeSize,r=e.x/2,s=e.y/2,a=e.z/2,o=r*i.x<n?n/i.x:r,h=s*i.y<n?n/i.y:s,l=a*i.z<n?n/i.z:a;return t.set(o,h,l),t},i.getMinScale=function(t){var e=this.collider.size,i=_W(dW.set(this._collider.node.worldScale)),n=RX.instance.minVolumeSize,r=e.x/2,s=e.y/2,a=e.z/2,o=r*i.x<n?n/r:i.x,h=s*i.y<n?n/s:i.y,l=a*i.z<n?n/a:i.z;return t.set(o,h,l),t},Pi(e,[{key:"collider",get:function(){return this._collider}}]),e}(eK),uK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.updateRadius=function(){Sa.SphereShape_setUnscaledRadius(this.impl,this.getMinUnscaledRadius()),this.updateCompoundTransform()},i.onComponentSet=function(){this._impl=Sa.SphereShape_new(this.getMinUnscaledRadius()),this.updateScale()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=this.getMinScale();qz.set(e,e,e);var i=Gz.instance.BT_V3_0;Sa.CollisionShape_setLocalScaling(this._impl,$z(i,qz)),this.updateCompoundTransform()},i.getMinUnscaledRadius=function(){var t=this.collider.radius,e=Math.abs(wa(this._collider.node.worldScale)),i=RX.instance.minVolumeSize;return e*t<i?i/e:t},i.getMinScale=function(){var t=this.collider.radius,e=Math.abs(wa(this._collider.node.worldScale)),i=RX.instance.minVolumeSize;return e*t<i?i/t:e},Pi(e,[{key:"collider",get:function(){return this._collider}}]),e}(eK),cK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.setCylinderHeight=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){this._impl=Sa.CapsuleShape_new(.5,1),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,n){var r,s,a=n,o=i;1===o?(r=t*Math.abs(Ra(a.x,a.z)),s=e/2*Math.abs(a.y)):0===o?(r=t*Math.abs(Ra(a.y,a.z)),s=e/2*Math.abs(a.x)):(r=t*Math.abs(Ra(a.x,a.y)),s=e/2*Math.abs(a.z)),Sa.CapsuleShape_updateProp(this._impl,r,s,o),this.updateCompoundTransform()},Pi(e,[{key:"collider",get:function(){return this._collider}}]),e}(eK),dK=function(){function t(t,e){this.key=void 0,this.ref=0,this.bulletBvhTriangleMeshShapePtr=void 0,this.btTriangleMeshPtr=0,this.reference=!0,this.key=t,this.btTriangleMeshPtr=Sa.TriangleMesh_new(),nX(this.btTriangleMeshPtr,e),this.bulletBvhTriangleMeshShapePtr=Sa.BvhTriangleMeshShape_new(this.btTriangleMeshPtr,!0,!0)}return t.getBulletBvhTriangleMeshShape=function(e,i){var n;return t.BulletBvhTriangleMeshShapeMap.has(e)?(n=t.BulletBvhTriangleMeshShapeMap.get(e)).reference=!0:(n=new t(e,i),t.BulletBvhTriangleMeshShapeMap.set(e,n)),n},t.prototype.destroy=function(){this.bulletBvhTriangleMeshShapePtr&&Sa._safe_delete(ba.EBulletTypeCollisionShape,this.bulletBvhTriangleMeshShapePtr),this.btTriangleMeshPtr&&Sa._safe_delete(ba.EBulletTypeTriangleMesh,this.btTriangleMeshPtr),t.BulletBvhTriangleMeshShapeMap.delete(this.key)},Pi(t,[{key:"reference",set:function(t){t?this.ref++:this.ref--,0===this.ref&&this.destroy()}}]),t}();dK.BulletBvhTriangleMeshShapeMap=new Map;var _K,fK,pK,gK,mK,vK,yK,TK,SK,EK=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).btBVHMeshShape=void 0,e.refBtTriangleMesh=0,e}He(e,t);var i=e.prototype;return i.setMesh=function(t){if(this._isInitialized)if(this._impl&&Gz.isNotEmptyShape(this._impl))Zi(9620);else{var e=t;if(e&&e.renderingSubMeshes.length>0){if(this.collider.convex){var i=this._getBtTriangleMesh(e);this._impl=Sa.ConvexTriangleMeshShape_new(i)}else this.btBVHMeshShape=dK.getBulletBvhTriangleMeshShape(e.hash,e),this._impl=Sa.ScaledBvhTriangleMeshShape_new(this.btBVHMeshShape.bulletBvhTriangleMeshShapePtr,1,1,1);var n=Gz.instance.BT_V3_0;$z(n,this._collider.node.worldScale),Sa.CollisionShape_setLocalScaling(this._impl,n),Sa.CollisionShape_setMargin(this._impl,.01),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=Sa.EmptyShape_static()}},i.onComponentSet=function(){this.setMesh(this.collider.mesh)},i.onDestroy=function(){this.collider.convex?this.refBtTriangleMesh&&Sa._safe_delete(this.refBtTriangleMesh,ba.EBulletTypeTriangleMesh):this.btBVHMeshShape&&(this.btBVHMeshShape.reference=!1),t.prototype.onDestroy.call(this)},i.updateScale=function(){t.prototype.updateScale.call(this);var e=Gz.instance.BT_V3_0;$z(e,this._collider.node.worldScale),Sa.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i._getBtTriangleMesh=function(t){return this.refBtTriangleMesh=Sa.TriangleMesh_new(),nX(this.refBtTriangleMesh,t),this.refBtTriangleMesh},Pi(e,[{key:"collider",get:function(){return this._collider}}]),e}(eK),AK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){var t=Gz.instance.BT_V3_0;Sa.Vec3_set(t,.5,1,.5),this._impl=Sa.CylinderShape_new(t),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,n){var r,s,a=n,o=i;1===o?(s=e*Math.abs(a.y),r=t*Math.abs(Ra(a.x,a.z))):0===o?(s=e*Math.abs(a.x),r=t*Math.abs(Ra(a.y,a.z))):(s=e*Math.abs(a.z),r=t*Math.abs(Ra(a.x,a.y))),Sa.CylinderShape_updateProp(this._impl,r,s/2,o),this.updateCompoundTransform()},Pi(e,[{key:"collider",get:function(){return this._collider}}]),e}(eK),CK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){this._impl=Sa.ConeShape_new(.5,1),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,n){var r,s,a=n,o=i;1===o?(s=e*Math.abs(a.y),r=t*Math.abs(Ra(a.x,a.z))):0===o?(s=e*Math.abs(a.x),r=t*Math.abs(Ra(a.y,a.z))):(s=e*Math.abs(a.z),r=t*Math.abs(Ra(a.x,a.y))),Sa.ConeShape_setRadius(this._impl,r),Sa.ConeShape_setHeight(this._impl,s),Sa.ConeShape_setConeUpIndex(this._impl,o);var h=Gz.instance.BT_V3_0;Sa.Vec3_set(h,1,1,1),Sa.CollisionShape_setLocalScaling(this._impl,h),this.updateCompoundTransform()},Pi(e,[{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}}]),e}(eK),RK=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._bufPtr=0,e._tileSize=0,e._localOffset=new ji,e}He(e,t);var i=e.prototype;return i.setTerrain=function(t){if(this._isInitialized)if(this._impl&&Gz.isNotEmptyShape(this._impl))Gi("[Physics][Bullet]: change the terrain asset after initialization is not support.");else{var e=t;if(e){this._tileSize=e.tileSize;var i=e.getVertexCountI(),n=e.getVertexCountJ();this._bufPtr=Sa._malloc(4*i*n);for(var r=0,s=Number.MAX_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER,o=0;o<n;o++)for(var h=0;h<i;h++){var l=e.getHeight(h,o);Sa._write_f32(this._bufPtr+r,l),s>l&&(s=l),l>a&&(a=l),r+=4}a+=.01,s-=.01,this._localOffset.set((i-1)/2*this._tileSize,(a+s)/2,(n-1)/2*this._tileSize),this._impl=Sa.TerrainShape_new(i,n,this._bufPtr,1,s,a);var u=Gz.instance.BT_V3_0;Sa.Vec3_set(u,this._tileSize,1,this._tileSize),Sa.CollisionShape_setLocalScaling(this._impl,u),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=Sa.EmptyShape_static()}},i.onComponentSet=function(){this.setTerrain(this.collider.terrain)},i.onDestroy=function(){this._bufPtr&&Sa._free(this._bufPtr),t.prototype.onDestroy.call(this)},i.setCenter=function(t){ji.copy(qz,t),qz.add(this._localOffset),$z(Sa.Transform_getOrigin(this.transform),qz),this.updateCompoundTransform()},Pi(e,[{key:"collider",get:function(){return this._collider}}]),e}(eK),bK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.setShapeType=function(){},i.setVertices=function(){},i.onComponentSet=function(){this._impl=Sa.SimplexShape_new();for(var t=this.collider.shapeType,e=this.collider.vertices,i=Gz.instance.BT_V3_0,n=0;n<t;n++)Sa.SimplexShape_addVertex(this._impl,$z(i,e[n]));Sa.CollisionShape_setLocalScaling(this._impl,$z(i,this._collider.node.worldScale))},i.onLoad=function(){t.prototype.onLoad.call(this),this.collider.updateVertices()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=Gz.instance.BT_V3_0;Sa.CollisionShape_setLocalScaling(this._impl,$z(e,this._collider.node.worldScale))},Pi(e,[{key:"collider",get:function(){return this._collider}}]),e}(eK),xK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.setNormal=function(t){$z(Sa.StaticPlaneShape_getPlaneNormal(this.impl),t),this.updateCompoundTransform()},i.setConstant=function(t){Sa.StaticPlaneShape_setPlaneConstant(this.impl,t),this.updateCompoundTransform()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=Gz.instance.BT_V3_0;$z(e,this._collider.node.worldScale),Sa.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i.onComponentSet=function(){var t=Gz.instance.BT_V3_0;$z(t,this.collider.normal),this._impl=Sa.StaticPlaneShape_new(t,this.collider.constant),this.updateScale()},Pi(e,[{key:"collider",get:function(){return this._collider}}]),e}(eK),wK=function(){function t(){this.dirty=0,this.index=-1,this._impl=0,this._collided=!1}var e=t.prototype;return e.setConnectedBody=function(){},e.setEnableCollision=function(t){this._collided!==t&&(this._collided=t,this.updateByReAdd())},e.updateByReAdd=function(){if(this._rigidBody&&this.index>=0){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.removeConstraint(this),t.wrappedWorld.addConstraint(this)}},e.initialize=function(t){this._com=t,this._rigidBody=t.attachedBody,this._collided=t.enableCollision,this.onComponentSet()},e.onEnable=function(){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.addConstraint(this),t.addJoint(this,0);var e=this.constraint.connectedBody;e&&e.body.sharedBody.addJoint(this,1)},e.onDisable=function(){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.removeConstraint(this),t.removeJoint(this,0);var e=this.constraint.connectedBody;e&&e.body.sharedBody.removeJoint(this,1)},e.onDestroy=function(){Sa._safe_delete(this._impl,ba.EBulletTypeTypedConstraint),this._com=null,this._rigidBody=null},Pi(t,[{key:"impl",get:function(){return this._impl}},{key:"constraint",get:function(){return this._com}}]),t}(),MK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.setPivotA=function(){var t=this.constraint,e=Gz.instance.BT_V3_0;ji.multiply(qz,t.node.worldScale,t.pivotA),$z(e,qz),Sa.P2PConstraint_setPivotA(this._impl,e),t.connectedBody||this.setPivotB(t.pivotB)},i.setPivotB=function(){var t=this.constraint,e=this._rigidBody.node,i=Gz.instance.BT_V3_0,n=t.connectedBody;n?(ji.multiply(qz,n.node.worldScale,t.pivotB),$z(i,qz)):(ji.multiply(qz,e.worldScale,t.pivotA),ji.add(qz,qz,e.worldPosition),ji.add(qz,qz,t.pivotB),$z(i,qz)),Sa.P2PConstraint_setPivotB(this._impl,i)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:Sa.TypedConstraint_getFixedBody(),n=Gz.instance.BT_V3_0,r=Gz.instance.BT_V3_1;this._impl=Sa.P2PConstraint_new(e,i,n,r),this.setPivotA(this.constraint.pivotA),this.setPivotB(this.constraint.pivotB)},i.updateScale0=function(){this.setPivotA(this.constraint.pivotA)},i.updateScale1=function(){this.setPivotB(this.constraint.pivotB)},Pi(e,[{key:"constraint",get:function(){return this._com}}]),e}(wK),IK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.setBreakForce=function(t){Sa.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.setBreakTorque=function(){},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.sharedBody,i=t?t.body.sharedBody:RX.instance.physicsWorld.getSharedBody(e.node),n=Gz.instance.BT_TRANSFORM_0,r=Gz.instance.BT_TRANSFORM_1;this._impl=Sa.FixedConstraint_new(e.body,i.body,n,r),this.setBreakForce(this.constraint.breakForce),this.setBreakTorque(this.constraint.breakTorque),this.updateFrames()},i.updateFrames=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.sharedBody,i=t?t.body.sharedBody:RX.instance.physicsWorld.getSharedBody(e.node),n=qz,r=Qz,s=Gz.instance.BT_TRANSFORM_0,a=Gz.instance.BT_TRANSFORM_1,o=Gz.instance.BT_QUAT_0,h=Jz;Ue.fromRT(h,e.node.worldRotation,e.node.worldPosition),Ue.invert(h,h),Ue.getRotation(r,h),Ue.getTranslation(n,h),$z(Sa.Transform_getOrigin(s),n),eX(o,r),Sa.Transform_setRotation(s,o),Ue.fromRT(h,i.node.worldRotation,i.node.worldPosition),Ue.invert(h,h),Ue.getRotation(r,h),Ue.getTranslation(n,h),$z(Sa.Transform_getOrigin(a),n),eX(o,r),Sa.Transform_setRotation(a,o),Sa.FixedConstraint_setFrames(this._impl,s,a)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},Pi(e,[{key:"constraint",get:function(){return this._com}}]),e}(wK),BK=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.setPivotA=function(){this.updateFrames()},i.setPivotB=function(){this.updateFrames()},i.setAxis=function(){this.updateFrames()},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:Sa.TypedConstraint_getFixedBody(),n=Gz.instance.BT_TRANSFORM_0,r=Gz.instance.BT_TRANSFORM_1;this._impl=Sa.HingeConstraint_new(e,i,n,r),this.updateFrames()},i.updateFrames=function(){var t=this.constraint,e=t.node,i=qz,n=Qz,r=Gz.instance.BT_TRANSFORM_0;ji.multiply(i,e.worldScale,t.pivotA),$z(Sa.Transform_getOrigin(r),i);var s=Gz.instance.BT_QUAT_0;Ji.rotationTo(n,ji.UNIT_Z,t.axis),eX(s,n),Sa.Transform_setRotation(r,s);var a=Gz.instance.BT_TRANSFORM_1,o=this.constraint.connectedBody;o?ji.multiply(i,o.node.worldScale,t.pivotB):(ji.multiply(i,e.worldScale,t.pivotA),ji.add(i,i,e.worldPosition),ji.add(i,i,t.pivotB),Ji.multiply(n,n,e.worldRotation)),$z(Sa.Transform_getOrigin(a),i),eX(s,n),Sa.Transform_setRotation(a,s),Sa.HingeConstraint_setFrames(this._impl,r,a)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},Pi(e,[{key:"constraint",get:function(){return this._com}}]),e}(wK);qr.once(Zr.EVENT_PRE_SUBSYSTEM_INIT,(function(){wz.register("bullet",{PhysicsWorld:hK,RigidBody:Kj,BoxShape:lK,SphereShape:uK,CapsuleShape:cK,TrimeshShape:EK,CylinderShape:AK,ConeShape:CK,TerrainShape:RK,SimplexShape:bK,PlaneShape:xK,PointToPointConstraint:MK,HingeConstraint:BK,FixedConstraint:IK})})),function(t){t[t.BOX=0]="BOX",t[t.SPHERE=1]="SPHERE",t[t.CYLINDER=2]="CYLINDER",t[t.CONE=3]="CONE",t[t.CAPSULE=4]="CAPSULE",t[t.TORUS=5]="TORUS",t[t.PLANE=6]="PLANE",t[t.QUAD=7]="QUAD"}(SK||(SK={})),Fn(SK);var PK=t("Primitive",(_K=Ki("cc.Primitive"),fK=Tn(SK),_K((TK=yK=function(t){function e(e){var i;return void 0===e&&(e=SK.BOX),(i=t.call(this)||this).type=mK&&mK(),i.info=vK&&vK(),i.type=e,i}return He(e,t),e.prototype.onLoaded=function(){Ro(cW[SK[this.type].toLowerCase()](this.info),this)},e}(mo),yK.PrimitiveType=SK,mK=tn((gK=TK).prototype,"type",[fK],(function(){return SK.BOX})),vK=tn(gK.prototype,"info",[en],(function(){return{}})),pK=gK))||pK));We.Primitive=PK,We.primitives=cW;var DK,OK=function(){function t(t,e,i){this._opts=void 0,this._total=0,this._value=0,this._averageValue=0,this._accumValue=0,this._accumSamples=0,this._id=t,this._opts=e,this._accumStart=i}var e=t.prototype;return e.sample=function(t){this._average(this._value,t)},e.human=function(){var t=this._opts,e=t.average,i=t.isInteger,n=e?this._averageValue:this._value;return i?Math.round(n):Math.round(100*n)/100},e.alarm=function(){return this._opts.below&&this._value<this._opts.below||this._opts.over&&this._value>this._opts.over},e._average=function(t,e){if(void 0===e&&(e=0),this._opts.average){this._accumValue+=t,++this._accumSamples;var i=e;i-this._accumStart>=this._opts.average&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=i,this._accumSamples=0)}},Pi(t,[{key:"value",get:function(){return this._value},set:function(t){this._value=t}}]),t}(),FK=Ki("cc.PerfCounter")(DK=function(t){function e(e,i,n){var r;return(r=t.call(this,e,i,n)||this)._time=n,r}He(e,t);var i=e.prototype;return i.start=function(t){void 0===t&&(t=0),this._time=t},i.end=function(t){void 0===t&&(t=0),this._value=t-this._time,this._average(this._value)},i.tick=function(){this.end(),this.start()},i.frame=function(t){var e=t,i=e-this._time;this._total++,i>(this._opts.average||1e3)&&(this._value=1e3*this._total/i,this._total=0,this._time=e,this._average(this._value))},e}(OK))||DK,LK="0123456789. ",NK=500,kK={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,".":10},UK={fps:{desc:"Framerate (FPS)",below:30,average:NK,isInteger:!0},draws:{desc:"Draw call",isInteger:!0},frame:{desc:"Frame time (ms)",min:0,max:50,average:NK},instances:{desc:"Instance Count",isInteger:!0},tricount:{desc:"Triangle",isInteger:!0},logic:{desc:"Game Logic (ms)",min:0,max:50,average:NK,color:"#080"},physics:{desc:"Physics (ms)",min:0,max:50,average:NK},render:{desc:"Renderer (ms)",min:0,max:50,average:NK,color:"#f90"},present:{desc:"Present (ms)",min:0,max:50,average:NK,color:"#f90"},textureMemory:{desc:"GFX Texture Mem(M)"},bufferMemory:{desc:"GFX Buffer Mem(M)"}},GK=t("Profiler",function(t){function e(){var e;return(e=t.call(this)||this)._stats=null,e._showFPS=!1,e._rootNode=null,e._device=null,e._swapchain=null,e._meshRenderer=null,e._canvas=null,e._ctx=null,e._texture=null,e._region=new ht,e._canvasArr=[],e._regionArr=[e._region],e.digitsData=null,e.offsetData=null,e.pass=null,e._canvasDone=!1,e._statsDone=!1,e._inited=!1,e._lineHeight=280/(Object.keys(UK).length+1),e._wordHeight=0,e._eachNumWidth=0,e._totalLines=0,e.lastTime=0,e._canvas=ln.document.createElement("canvas"),e._ctx=e._canvas.getContext("2d"),e._canvasArr.push(e._canvas),e}He(e,t);var i=e.prototype;return i.init=function(){Tr.querySettings(Sr.Category.PROFILING,"showFPS")?this.showStats():this.hideStats()},i.isShowingStats=function(){return this._showFPS},i.hideStats=function(){this._showFPS&&(this._rootNode&&(this._rootNode.active=!1),We.director.off(We.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),We.director.off(We.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),We.director.off(We.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),We.director.off(We.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),We.director.off(We.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),We.director.off(We.Director.EVENT_AFTER_RENDER,this.afterRender,this),We.director.off(We.Director.EVENT_AFTER_DRAW,this.afterPresent,this),this._showFPS=!1,Di.root.pipeline.profiler=null,We.game.config.showFPS=!1)},i.showStats=function(){if(!this._showFPS){if(!this._device){var t=We.director.root;this._device=ke.gfxDevice,this._swapchain=t.mainWindow.swapchain}this.generateCanvas(),this.generateStats(),We.game.once(We.Game.EVENT_ENGINE_INITED,this.generateNode,this),We.game.on(We.Game.EVENT_RESTART,this.generateNode,this),this._rootNode&&(this._rootNode.active=!0),We.director.on(We.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),We.director.on(We.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),We.director.on(We.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),We.director.on(We.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),We.director.on(We.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),We.director.on(We.Director.EVENT_AFTER_RENDER,this.afterRender,this),We.director.on(We.Director.EVENT_AFTER_DRAW,this.afterPresent,this),this._showFPS=!0,this._canvasDone=!0,this._statsDone=!0,We.game.config.showFPS=!0}},i.generateCanvas=function(){if(!this._canvasDone){this._ctx&&this._canvas&&(this._canvas.width=280,this._canvas.height=280,this._canvas.style.width=""+this._canvas.width,this._canvas.style.height=""+this._canvas.height,this._ctx.font="23px Arial",this._ctx.textBaseline="top",this._ctx.fillStyle="#fff",this._texture=this._device.createTexture(new yt(T.TEX2D,S.SAMPLED|S.TRANSFER_DST,_.RGBA8,280,280)),this._region.texExtent.width=280,this._region.texExtent.height=280)}},i.generateStats=function(){if(!this._statsDone&&this._ctx&&this._canvas){this._stats=null;var t=performance.now();this._ctx.textAlign="left";var e=0;for(var i in UK){var n=UK[i];this._ctx.fillText(n.desc,0,e*this._lineHeight),n.counter=new FK(i,n,t),e++}this._totalLines=e,this._wordHeight=this._totalLines*this._lineHeight/this._canvas.height;for(var r=0;r<LK.length;++r){var s=this._ctx.measureText(LK[r]).width;this._eachNumWidth=Math.max(this._eachNumWidth,s)}for(var a=0;a<LK.length;++a)this._ctx.fillText(LK[a],a*this._eachNumWidth,this._totalLines*this._lineHeight);this._eachNumWidth/=this._canvas.width,this._stats=UK,this._canvasArr[0]=this._canvas,this._device.copyTexImagesToTexture(this._canvasArr,this._texture,this._regionArr)}},i.generateNode=function(){if(!this._rootNode||!this._rootNode.isValid){this._rootNode=new Pr("PROFILER_NODE"),this._rootNode._objFlags=We.Object.Flags.DontSave|We.Object.Flags.HideInHierarchy,We.game.addPersistRootNode(this._rootNode);var t=new Pr("Profiler_Root");t.parent=this._rootNode;for(var e=.4,i=e/this._totalLines,n=e/this._wordHeight,r=i/23,s=this._eachNumWidth*this._canvas.width*r,a=[0,e,0,n,e,0,n,0,0,0,0,0],o=[0,2,1,0,3,2],h=[0,0,-1,0,1,0,-1,0,1,this._wordHeight,-1,0,0,this._wordHeight,-1,0],l=0,u=0;u<this._totalLines;u++)for(var c=0;c<8;c++){a.push(n+c*s,e-u*i,0),a.push(n+(c+1)*s,e-u*i,0),a.push(n+(c+1)*s,e-(u+1)*i,0),a.push(n+c*s,e-(u+1)*i,0),l=4*(8*u+c+1),o.push(0+l,2+l,1+l,0+l,3+l,2+l);var d=8*u+c,_=Math.floor(d/4),f=d-4*_;h.push(0,this._wordHeight,_,f),h.push(this._eachNumWidth,this._wordHeight,_,f),h.push(this._eachNumWidth,1,_,f),h.push(0,1,_,f)}this._meshRenderer=t.addComponent(eT),this._meshRenderer.mesh=Ro({positions:a,indices:o,colors:h});var p=new Dn;p.initialize({effectName:"util/profiler"});var g=this.pass=p.passes[0],m=g.getBinding("mainTexture"),v=g.getBinding("digits"),y=g.getBinding("offset");g.bindTexture(m,this._texture),this.digitsData=g.blocks[v],this.offsetData=g.blocks[y],this.offsetData[3]=-1,this._meshRenderer.material=p,this._meshRenderer.node.layer=Xn.Enum.PROFILER,this._inited=!0}},i.beforeUpdate=function(){if(this._stats){var t=performance.now();this._stats.frame.counter.start(t),this._stats.logic.counter.start(t)}},i.afterUpdate=function(){if(this._stats){var t=performance.now();We.director.isPaused()?this._stats.frame.counter.start(t):this._stats.logic.counter.end(t)}},i.beforePhysics=function(){if(this._stats){var t=performance.now();this._stats.physics.counter.start(t)}},i.afterPhysics=function(){if(this._stats){var t=performance.now();this._stats.physics.counter.end(t)}},i.beforeDraw=function(){if(this._stats&&this._inited){var t=this._swapchain.surfaceTransform,e=this._device.capabilities.clipSpaceSignY;if(t!==this.offsetData[3]){var i=Ma[t],n=-.9,r=-.9*e;rn.isXR&&(n=-.5,r=-.5*e),this.offsetData[0]=n*i[0]+r*i[2],this.offsetData[1]=n*i[1]+r*i[3],this.offsetData[2]=this._eachNumWidth,this.offsetData[3]=t}this.pass._rootBufferDirty=!0,this._meshRenderer.model?Di.root.pipeline.profiler=this._meshRenderer.model:Di.root.pipeline.profiler=null;var s=performance.now();this._stats.render.counter.start(s)}},i.afterRender=function(){if(this._stats&&this._inited){var t=performance.now();this._stats.render.counter.end(t),this._stats.present.counter.start(t)}},i.afterPresent=function(){if(this._stats&&this._inited){var t=performance.now();if(this._stats.frame.counter.end(t),this._stats.fps.counter.frame(t),this._stats.present.counter.end(t),!(t-this.lastTime<NK)){this.lastTime=t;var e=this._device;this._stats.draws.counter.value=e.numDrawCalls,this._stats.instances.counter.value=e.numInstances,this._stats.bufferMemory.counter.value=e.memoryStatus.bufferSize/1048576,this._stats.textureMemory.counter.value=e.memoryStatus.textureSize/1048576,this._stats.tricount.counter.value=e.numTris;var i=0,n=this.digitsData;for(var r in this._stats){var s=this._stats[r];s.counter.sample(t);for(var a=s.counter.human().toString(),o=7;o>=0;o--){var h=8*i+o,l=a[a.length-(8-o)],u=kK[l];void 0===u&&(u=11),n[h]=u}i++}}}},e}(Oi)),VK=t("profiler",new GK);Di.registerSystem("profiler",VK,0),We.profiler=VK;var HK,zK,XK,WK=(HK=function(t,e){return(HK=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}HK(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),YK=void 0!==globalThis.jsb&&void 0!==jsb.window?jsb.window:window;!function(t){var e,i,n,r=function(){function t(t,e,i){if(null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.timelineIds=[];for(var n=0;n<e.length;n++)this.timelineIds[e[n].getPropertyId()]=!0;this.duration=i}return t.prototype.hasTimeline=function(t){return 1==this.timelineIds[t]},t.prototype.apply=function(t,e,i,n,r,s,a,o){if(null==t)throw new Error("skeleton cannot be null.");n&&0!=this.duration&&(i%=this.duration,e>0&&(e%=this.duration));for(var h=this.timelines,l=0,u=h.length;l<u;l++)h[l].apply(t,e,i,r,s,a,o)},t.binarySearch=function(t,e,i){void 0===i&&(i=1);var n=0,r=t.length/i-2;if(0==r)return i;for(var s=r>>>1;;){if(t[(s+1)*i]<=e?n=s+1:r=s,n==r)return(n+1)*i;s=n+r>>>1}},t.linearSearch=function(t,e,i){for(var n=0,r=t.length-i;n<=r;n+=i)if(t[n]>e)return n;return-1},t}();t.Animation=r,function(t){t[t.setup=0]="setup",t[t.first=1]="first",t[t.replace=2]="replace",t[t.add=3]="add"}(e=t.MixBlend||(t.MixBlend={})),function(t){t[t.mixIn=0]="mixIn",t[t.mixOut=1]="mixOut"}(i=t.MixDirection||(t.MixDirection={})),function(t){t[t.rotate=0]="rotate",t[t.translate=1]="translate",t[t.scale=2]="scale",t[t.shear=3]="shear",t[t.attachment=4]="attachment",t[t.color=5]="color",t[t.deform=6]="deform",t[t.event=7]="event",t[t.drawOrder=8]="drawOrder",t[t.ikConstraint=9]="ikConstraint",t[t.transformConstraint=10]="transformConstraint",t[t.pathConstraintPosition=11]="pathConstraintPosition",t[t.pathConstraintSpacing=12]="pathConstraintSpacing",t[t.pathConstraintMix=13]="pathConstraintMix",t[t.twoColor=14]="twoColor"}(n=t.TimelineType||(t.TimelineType={}));var s=function(){function e(i){if(i<=0)throw new Error("frameCount must be > 0: "+i);this.curves=t.Utils.newFloatArray((i-1)*e.BEZIER_SIZE)}return e.prototype.getFrameCount=function(){return this.curves.length/e.BEZIER_SIZE+1},e.prototype.setLinear=function(t){this.curves[t*e.BEZIER_SIZE]=e.LINEAR},e.prototype.setStepped=function(t){this.curves[t*e.BEZIER_SIZE]=e.STEPPED},e.prototype.getCurveType=function(t){var i=t*e.BEZIER_SIZE;if(i==this.curves.length)return e.LINEAR;var n=this.curves[i];return n==e.LINEAR?e.LINEAR:n==e.STEPPED?e.STEPPED:e.BEZIER},e.prototype.setCurve=function(t,i,n,r,s){var a=.03*(2*-i+r),o=.03*(2*-n+s),h=.006*(3*(i-r)+1),l=.006*(3*(n-s)+1),u=2*a+h,c=2*o+l,d=.3*i+a+.16666667*h,_=.3*n+o+.16666667*l,f=t*e.BEZIER_SIZE,p=this.curves;p[f++]=e.BEZIER;for(var g=d,m=_,v=f+e.BEZIER_SIZE-1;f<v;f+=2)p[f]=g,p[f+1]=m,d+=u,_+=c,u+=h,c+=l,g+=d,m+=_},e.prototype.getCurvePercent=function(i,n){n=t.MathUtils.clamp(n,0,1);var r=this.curves,s=i*e.BEZIER_SIZE,a=r[s];if(a==e.LINEAR)return n;if(a==e.STEPPED)return 0;for(var o=0,h=++s,l=s+e.BEZIER_SIZE-1;s<l;s+=2)if((o=r[s])>=n){var u=void 0,c=void 0;return s==h?(u=0,c=0):(u=r[s-2],c=r[s-1]),c+(r[s+1]-c)*(n-u)/(o-u)}var d=r[s-1];return d+(1-d)*(n-o)/(1-o)},e.LINEAR=0,e.STEPPED=1,e.BEZIER=2,e.BEZIER_SIZE=19,e}();t.CurveTimeline=s;var a=function(i){function s(e){var n=i.call(this,e)||this;return n.frames=t.Utils.newFloatArray(e<<1),n}return WK(s,i),s.prototype.getPropertyId=function(){return(n.rotate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i){t<<=1,this.frames[t]=e,this.frames[t+s.ROTATION]=i},s.prototype.apply=function(t,i,n,a,o,h){var l=this.frames,u=t.bones[this.boneIndex];if(u.active)if(n<l[0])switch(h){case e.setup:return void(u.rotation=u.data.rotation);case e.first:var c=u.data.rotation-u.rotation;u.rotation+=(c-360*(16384-(16384.499999999996-c/360|0)))*o}else if(n>=l[l.length-s.ENTRIES]){var d=l[l.length+s.PREV_ROTATION];switch(h){case e.setup:u.rotation=u.data.rotation+d*o;break;case e.first:case e.replace:d+=u.data.rotation-u.rotation,d-=360*(16384-(16384.499999999996-d/360|0));case e.add:u.rotation+=d*o}}else{var _=r.binarySearch(l,n,s.ENTRIES),f=l[_+s.PREV_ROTATION],p=l[_],g=this.getCurvePercent((_>>1)-1,1-(n-p)/(l[_+s.PREV_TIME]-p)),m=l[_+s.ROTATION]-f;switch(m=f+(m-360*(16384-(16384.499999999996-m/360|0)))*g,h){case e.setup:u.rotation=u.data.rotation+(m-360*(16384-(16384.499999999996-m/360|0)))*o;break;case e.first:case e.replace:m+=u.data.rotation-u.rotation;case e.add:u.rotation+=(m-360*(16384-(16384.499999999996-m/360|0)))*o}}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_ROTATION=-1,s.ROTATION=1,s}(s);t.RotateTimeline=a;var o=function(i){function s(e){var n=i.call(this,e)||this;return n.frames=t.Utils.newFloatArray(e*s.ENTRIES),n}return WK(s,i),s.prototype.getPropertyId=function(){return(n.translate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.X]=i,this.frames[t+s.Y]=n},s.prototype.apply=function(t,i,n,a,o,h){var l=this.frames,u=t.bones[this.boneIndex];if(u.active)if(n<l[0])switch(h){case e.setup:return u.x=u.data.x,void(u.y=u.data.y);case e.first:u.x+=(u.data.x-u.x)*o,u.y+=(u.data.y-u.y)*o}else{var c=0,d=0;if(n>=l[l.length-s.ENTRIES])c=l[l.length+s.PREV_X],d=l[l.length+s.PREV_Y];else{var _=r.binarySearch(l,n,s.ENTRIES);c=l[_+s.PREV_X],d=l[_+s.PREV_Y];var f=l[_],p=this.getCurvePercent(_/s.ENTRIES-1,1-(n-f)/(l[_+s.PREV_TIME]-f));c+=(l[_+s.X]-c)*p,d+=(l[_+s.Y]-d)*p}switch(h){case e.setup:u.x=u.data.x+c*o,u.y=u.data.y+d*o;break;case e.first:case e.replace:u.x+=(u.data.x+c-u.x)*o,u.y+=(u.data.y+d-u.y)*o;break;case e.add:u.x+=c*o,u.y+=d*o}}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_X=-2,s.PREV_Y=-1,s.X=1,s.Y=2,s}(s);t.TranslateTimeline=o;var h=function(s){function a(t){return s.call(this,t)||this}return WK(a,s),a.prototype.getPropertyId=function(){return(n.scale<<24)+this.boneIndex},a.prototype.apply=function(n,s,o,h,l,u,c){var d=this.frames,_=n.bones[this.boneIndex];if(_.active)if(o<d[0])switch(u){case e.setup:return _.scaleX=_.data.scaleX,void(_.scaleY=_.data.scaleY);case e.first:_.scaleX+=(_.data.scaleX-_.scaleX)*l,_.scaleY+=(_.data.scaleY-_.scaleY)*l}else{var f=0,p=0;if(o>=d[d.length-a.ENTRIES])f=d[d.length+a.PREV_X]*_.data.scaleX,p=d[d.length+a.PREV_Y]*_.data.scaleY;else{var g=r.binarySearch(d,o,a.ENTRIES);f=d[g+a.PREV_X],p=d[g+a.PREV_Y];var m=d[g],v=this.getCurvePercent(g/a.ENTRIES-1,1-(o-m)/(d[g+a.PREV_TIME]-m));f=(f+(d[g+a.X]-f)*v)*_.data.scaleX,p=(p+(d[g+a.Y]-p)*v)*_.data.scaleY}if(1==l)u==e.add?(_.scaleX+=f-_.data.scaleX,_.scaleY+=p-_.data.scaleY):(_.scaleX=f,_.scaleY=p);else{var y=0,T=0;if(c==i.mixOut)switch(u){case e.setup:y=_.data.scaleX,T=_.data.scaleY,_.scaleX=y+(Math.abs(f)*t.MathUtils.signum(y)-y)*l,_.scaleY=T+(Math.abs(p)*t.MathUtils.signum(T)-T)*l;break;case e.first:case e.replace:y=_.scaleX,T=_.scaleY,_.scaleX=y+(Math.abs(f)*t.MathUtils.signum(y)-y)*l,_.scaleY=T+(Math.abs(p)*t.MathUtils.signum(T)-T)*l;break;case e.add:y=_.scaleX,T=_.scaleY,_.scaleX=y+(Math.abs(f)*t.MathUtils.signum(y)-_.data.scaleX)*l,_.scaleY=T+(Math.abs(p)*t.MathUtils.signum(T)-_.data.scaleY)*l}else switch(u){case e.setup:y=Math.abs(_.data.scaleX)*t.MathUtils.signum(f),T=Math.abs(_.data.scaleY)*t.MathUtils.signum(p),_.scaleX=y+(f-y)*l,_.scaleY=T+(p-T)*l;break;case e.first:case e.replace:y=Math.abs(_.scaleX)*t.MathUtils.signum(f),T=Math.abs(_.scaleY)*t.MathUtils.signum(p),_.scaleX=y+(f-y)*l,_.scaleY=T+(p-T)*l;break;case e.add:y=t.MathUtils.signum(f),T=t.MathUtils.signum(p),_.scaleX=Math.abs(_.scaleX)*y+(f-Math.abs(_.data.scaleX)*y)*l,_.scaleY=Math.abs(_.scaleY)*T+(p-Math.abs(_.data.scaleY)*T)*l}}}},a}(o);t.ScaleTimeline=h;var l=function(t){function i(e){return t.call(this,e)||this}return WK(i,t),i.prototype.getPropertyId=function(){return(n.shear<<24)+this.boneIndex},i.prototype.apply=function(t,n,s,a,o,h){var l=this.frames,u=t.bones[this.boneIndex];if(u.active)if(s<l[0])switch(h){case e.setup:return u.shearX=u.data.shearX,void(u.shearY=u.data.shearY);case e.first:u.shearX+=(u.data.shearX-u.shearX)*o,u.shearY+=(u.data.shearY-u.shearY)*o}else{var c=0,d=0;if(s>=l[l.length-i.ENTRIES])c=l[l.length+i.PREV_X],d=l[l.length+i.PREV_Y];else{var _=r.binarySearch(l,s,i.ENTRIES);c=l[_+i.PREV_X],d=l[_+i.PREV_Y];var f=l[_],p=this.getCurvePercent(_/i.ENTRIES-1,1-(s-f)/(l[_+i.PREV_TIME]-f));c+=(l[_+i.X]-c)*p,d+=(l[_+i.Y]-d)*p}switch(h){case e.setup:u.shearX=u.data.shearX+c*o,u.shearY=u.data.shearY+d*o;break;case e.first:case e.replace:u.shearX+=(u.data.shearX+c-u.shearX)*o,u.shearY+=(u.data.shearY+d-u.shearY)*o;break;case e.add:u.shearX+=c*o,u.shearY+=d*o}}},i}(o);t.ShearTimeline=l;var u=function(i){function s(e){var n=i.call(this,e)||this;return n.frames=t.Utils.newFloatArray(e*s.ENTRIES),n}return WK(s,i),s.prototype.getPropertyId=function(){return(n.color<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i,n,r,a){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.R]=i,this.frames[t+s.G]=n,this.frames[t+s.B]=r,this.frames[t+s.A]=a},s.prototype.apply=function(t,i,n,a,o,h){var l=t.slots[this.slotIndex];if(l.bone.active){var u=this.frames;if(n<u[0])switch(h){case e.setup:return void l.color.setFromColor(l.data.color);case e.first:var c=l.color,d=l.data.color;c.add((d.r-c.r)*o,(d.g-c.g)*o,(d.b-c.b)*o,(d.a-c.a)*o)}else{var _=0,f=0,p=0,g=0;if(n>=u[u.length-s.ENTRIES]){var m=u.length;_=u[m+s.PREV_R],f=u[m+s.PREV_G],p=u[m+s.PREV_B],g=u[m+s.PREV_A]}else{var v=r.binarySearch(u,n,s.ENTRIES);_=u[v+s.PREV_R],f=u[v+s.PREV_G],p=u[v+s.PREV_B],g=u[v+s.PREV_A];var y=u[v],T=this.getCurvePercent(v/s.ENTRIES-1,1-(n-y)/(u[v+s.PREV_TIME]-y));_+=(u[v+s.R]-_)*T,f+=(u[v+s.G]-f)*T,p+=(u[v+s.B]-p)*T,g+=(u[v+s.A]-g)*T}1==o?l.color.set(_,f,p,g):(c=l.color,h==e.setup&&c.setFromColor(l.data.color),c.add((_-c.r)*o,(f-c.g)*o,(p-c.b)*o,(g-c.a)*o))}}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_R=-4,s.PREV_G=-3,s.PREV_B=-2,s.PREV_A=-1,s.R=1,s.G=2,s.B=3,s.A=4,s}(s);t.ColorTimeline=u;var c=function(i){function s(e){var n=i.call(this,e)||this;return n.frames=t.Utils.newFloatArray(e*s.ENTRIES),n}return WK(s,i),s.prototype.getPropertyId=function(){return(n.twoColor<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i,n,r,a,o,h,l){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.R]=i,this.frames[t+s.G]=n,this.frames[t+s.B]=r,this.frames[t+s.A]=a,this.frames[t+s.R2]=o,this.frames[t+s.G2]=h,this.frames[t+s.B2]=l},s.prototype.apply=function(t,i,n,a,o,h){var l=t.slots[this.slotIndex];if(l.bone.active){var u=this.frames;if(n<u[0])switch(h){case e.setup:return l.color.setFromColor(l.data.color),void l.darkColor.setFromColor(l.data.darkColor);case e.first:var c=l.color,d=l.darkColor,_=l.data.color,f=l.data.darkColor;c.add((_.r-c.r)*o,(_.g-c.g)*o,(_.b-c.b)*o,(_.a-c.a)*o),d.add((f.r-d.r)*o,(f.g-d.g)*o,(f.b-d.b)*o,0)}else{var p=0,g=0,m=0,v=0,y=0,T=0,S=0;if(n>=u[u.length-s.ENTRIES]){var E=u.length;p=u[E+s.PREV_R],g=u[E+s.PREV_G],m=u[E+s.PREV_B],v=u[E+s.PREV_A],y=u[E+s.PREV_R2],T=u[E+s.PREV_G2],S=u[E+s.PREV_B2]}else{var A=r.binarySearch(u,n,s.ENTRIES);p=u[A+s.PREV_R],g=u[A+s.PREV_G],m=u[A+s.PREV_B],v=u[A+s.PREV_A],y=u[A+s.PREV_R2],T=u[A+s.PREV_G2],S=u[A+s.PREV_B2];var C=u[A],R=this.getCurvePercent(A/s.ENTRIES-1,1-(n-C)/(u[A+s.PREV_TIME]-C));p+=(u[A+s.R]-p)*R,g+=(u[A+s.G]-g)*R,m+=(u[A+s.B]-m)*R,v+=(u[A+s.A]-v)*R,y+=(u[A+s.R2]-y)*R,T+=(u[A+s.G2]-T)*R,S+=(u[A+s.B2]-S)*R}1==o?(l.color.set(p,g,m,v),l.darkColor.set(y,T,S,1)):(c=l.color,d=l.darkColor,h==e.setup&&(c.setFromColor(l.data.color),d.setFromColor(l.data.darkColor)),c.add((p-c.r)*o,(g-c.g)*o,(m-c.b)*o,(v-c.a)*o),d.add((y-d.r)*o,(T-d.g)*o,(S-d.b)*o,0))}}},s.ENTRIES=8,s.PREV_TIME=-8,s.PREV_R=-7,s.PREV_G=-6,s.PREV_B=-5,s.PREV_A=-4,s.PREV_R2=-3,s.PREV_G2=-2,s.PREV_B2=-1,s.R=1,s.G=2,s.B=3,s.A=4,s.R2=5,s.G2=6,s.B2=7,s}(s);t.TwoColorTimeline=c;var d=function(){function s(e){this.frames=t.Utils.newFloatArray(e),this.attachmentNames=new Array(e)}return s.prototype.getPropertyId=function(){return(n.attachment<<24)+this.slotIndex},s.prototype.getFrameCount=function(){return this.frames.length},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.attachmentNames[t]=i},s.prototype.apply=function(t,n,s,a,o,h,l){var u=t.slots[this.slotIndex];if(u.bone.active)if(l!=i.mixOut||h!=e.setup){var c=this.frames;if(s<c[0]){if(h==e.setup||h==e.first){var d=u.data.attachmentName;u.setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}}else{var _;_=s>=c[c.length-1]?c.length-1:r.binarySearch(c,s,1)-1;var f=this.attachmentNames[_];t.slots[this.slotIndex].setAttachment(null==f?null:t.getAttachment(this.slotIndex,f))}}else{var p=u.data.attachmentName;u.setAttachment(null==p?null:t.getAttachment(this.slotIndex,p))}},s}();t.AttachmentTimeline=d;var _=null,f=function(i){function s(e){var n=i.call(this,e)||this;return n.frames=t.Utils.newFloatArray(e),n.frameVertices=new Array(e),null==_&&(_=t.Utils.newFloatArray(64)),n}return WK(s,i),s.prototype.getPropertyId=function(){return(n.deform<<27)+ +this.attachment.id+this.slotIndex},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.frameVertices[t]=i},s.prototype.apply=function(i,n,s,a,o,h){var l=i.slots[this.slotIndex];if(l.bone.active){var u=l.getAttachment();if(u instanceof t.VertexAttachment&&u.deformAttachment==this.attachment){var c=l.deform;0==c.length&&(h=e.setup);var d=this.frameVertices,_=d[0].length,f=this.frames;if(s<f[0]){var p=u;switch(h){case e.setup:return void(c.length=0);case e.first:if(1==o){c.length=0;break}var g=t.Utils.setArraySize(c,_);if(null==p.bones)for(var m=p.vertices,v=0;v<_;v++)g[v]+=(m[v]-g[v])*o;else for(o=1-o,v=0;v<_;v++)g[v]*=o}}else{var y=t.Utils.setArraySize(c,_);if(s>=f[f.length-1]){var T=d[f.length-1];if(1==o)if(h==e.add)if(null==(p=u).bones){m=p.vertices;for(var S=0;S<_;S++)y[S]+=T[S]-m[S]}else for(var E=0;E<_;E++)y[E]+=T[E];else t.Utils.arrayCopy(T,0,y,0,_);else switch(h){case e.setup:var A=u;if(null==A.bones){m=A.vertices;for(var C=0;C<_;C++){var R=m[C];y[C]=R+(T[C]-R)*o}}else for(var b=0;b<_;b++)y[b]=T[b]*o;break;case e.first:case e.replace:for(var x=0;x<_;x++)y[x]+=(T[x]-y[x])*o;case e.add:if(null==(p=u).bones){m=p.vertices;for(var w=0;w<_;w++)y[w]+=(T[w]-m[w])*o}else for(var M=0;M<_;M++)y[M]+=T[M]*o}}else{var I=r.binarySearch(f,s),B=d[I-1],P=d[I],D=f[I],O=this.getCurvePercent(I-1,1-(s-D)/(f[I-1]-D));if(1==o)if(h==e.add)if(null==(p=u).bones){m=p.vertices;for(var F=0;F<_;F++){var L=B[F];y[F]+=L+(P[F]-L)*O-m[F]}}else for(var N=0;N<_;N++)L=B[N],y[N]+=L+(P[N]-L)*O;else for(var k=0;k<_;k++)L=B[k],y[k]=L+(P[k]-L)*O;else switch(h){case e.setup:var U=u;if(null==U.bones){m=U.vertices;for(var G=0;G<_;G++)L=B[G],R=m[G],y[G]=R+(L+(P[G]-L)*O-R)*o}else for(var V=0;V<_;V++)L=B[V],y[V]=(L+(P[V]-L)*O)*o;break;case e.first:case e.replace:for(var H=0;H<_;H++)L=B[H],y[H]+=(L+(P[H]-L)*O-y[H])*o;break;case e.add:if(null==(p=u).bones){m=p.vertices;for(var z=0;z<_;z++)L=B[z],y[z]+=(L+(P[z]-L)*O-m[z])*o}else for(var X=0;X<_;X++)L=B[X],y[X]+=(L+(P[X]-L)*O)*o}}}}}},s}(s);t.DeformTimeline=f;var p=function(){function e(e){this.frames=t.Utils.newFloatArray(e),this.events=new Array(e)}return e.prototype.getPropertyId=function(){return n.event<<24},e.prototype.getFrameCount=function(){return this.frames.length},e.prototype.setFrame=function(t,e){this.frames[t]=e.time,this.events[t]=e},e.prototype.apply=function(t,e,i,n,s,a,o){if(null!=n){var h=this.frames,l=this.frames.length;if(e>i)this.apply(t,e,Number.MAX_VALUE,n,s,a,o),e=-1;else if(e>=h[l-1])return;if(!(i<h[0])){var u=0;if(e<h[0])u=0;else for(var c=h[u=r.binarySearch(h,e)];u>0&&h[u-1]==c;)u--;for(;u<l&&i>=h[u];u++)n.push(this.events[u])}}},e}();t.EventTimeline=p;var g=function(){function s(e){this.frames=t.Utils.newFloatArray(e),this.drawOrders=new Array(e)}return s.prototype.getPropertyId=function(){return n.drawOrder<<24},s.prototype.getFrameCount=function(){return this.frames.length},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.drawOrders[t]=i},s.prototype.apply=function(n,s,a,o,h,l,u){var c=n.drawOrder,d=n.slots;if(u!=i.mixOut||l!=e.setup){var _=this.frames;if(a<_[0])l!=e.setup&&l!=e.first||t.Utils.arrayCopy(n.slots,0,n.drawOrder,0,n.slots.length);else{var f;f=a>=_[_.length-1]?_.length-1:r.binarySearch(_,a)-1;var p=this.drawOrders[f];if(null==p)t.Utils.arrayCopy(d,0,c,0,d.length);else for(var g=0,m=p.length;g<m;g++)c[g]=d[p[g]]}}else t.Utils.arrayCopy(n.slots,0,n.drawOrder,0,n.slots.length)},s}();t.DrawOrderTimeline=g;var m=function(s){function a(e){var i=s.call(this,e)||this;return i.frames=t.Utils.newFloatArray(e*a.ENTRIES),i}return WK(a,s),a.prototype.getPropertyId=function(){return(n.ikConstraint<<24)+this.ikConstraintIndex},a.prototype.setFrame=function(t,e,i,n,r,s,o){t*=a.ENTRIES,this.frames[t]=e,this.frames[t+a.MIX]=i,this.frames[t+a.SOFTNESS]=n,this.frames[t+a.BEND_DIRECTION]=r,this.frames[t+a.COMPRESS]=s?1:0,this.frames[t+a.STRETCH]=o?1:0},a.prototype.apply=function(t,n,s,o,h,l,u){var c=this.frames,d=t.ikConstraints[this.ikConstraintIndex];if(d.active)if(s<c[0])switch(l){case e.setup:return d.mix=d.data.mix,d.softness=d.data.softness,d.bendDirection=d.data.bendDirection,d.compress=d.data.compress,void(d.stretch=d.data.stretch);case e.first:d.mix+=(d.data.mix-d.mix)*h,d.softness+=(d.data.softness-d.softness)*h,d.bendDirection=d.data.bendDirection,d.compress=d.data.compress,d.stretch=d.data.stretch}else if(s>=c[c.length-a.ENTRIES])l==e.setup?(d.mix=d.data.mix+(c[c.length+a.PREV_MIX]-d.data.mix)*h,d.softness=d.data.softness+(c[c.length+a.PREV_SOFTNESS]-d.data.softness)*h,u==i.mixOut?(d.bendDirection=d.data.bendDirection,d.compress=d.data.compress,d.stretch=d.data.stretch):(d.bendDirection=c[c.length+a.PREV_BEND_DIRECTION],d.compress=0!=c[c.length+a.PREV_COMPRESS],d.stretch=0!=c[c.length+a.PREV_STRETCH])):(d.mix+=(c[c.length+a.PREV_MIX]-d.mix)*h,d.softness+=(c[c.length+a.PREV_SOFTNESS]-d.softness)*h,u==i.mixIn&&(d.bendDirection=c[c.length+a.PREV_BEND_DIRECTION],d.compress=0!=c[c.length+a.PREV_COMPRESS],d.stretch=0!=c[c.length+a.PREV_STRETCH]));else{var _=r.binarySearch(c,s,a.ENTRIES),f=c[_+a.PREV_MIX],p=c[_+a.PREV_SOFTNESS],g=c[_],m=this.getCurvePercent(_/a.ENTRIES-1,1-(s-g)/(c[_+a.PREV_TIME]-g));l==e.setup?(d.mix=d.data.mix+(f+(c[_+a.MIX]-f)*m-d.data.mix)*h,d.softness=d.data.softness+(p+(c[_+a.SOFTNESS]-p)*m-d.data.softness)*h,u==i.mixOut?(d.bendDirection=d.data.bendDirection,d.compress=d.data.compress,d.stretch=d.data.stretch):(d.bendDirection=c[_+a.PREV_BEND_DIRECTION],d.compress=0!=c[_+a.PREV_COMPRESS],d.stretch=0!=c[_+a.PREV_STRETCH])):(d.mix+=(f+(c[_+a.MIX]-f)*m-d.mix)*h,d.softness+=(p+(c[_+a.SOFTNESS]-p)*m-d.softness)*h,u==i.mixIn&&(d.bendDirection=c[_+a.PREV_BEND_DIRECTION],d.compress=0!=c[_+a.PREV_COMPRESS],d.stretch=0!=c[_+a.PREV_STRETCH]))}},a.ENTRIES=6,a.PREV_TIME=-6,a.PREV_MIX=-5,a.PREV_SOFTNESS=-4,a.PREV_BEND_DIRECTION=-3,a.PREV_COMPRESS=-2,a.PREV_STRETCH=-1,a.MIX=1,a.SOFTNESS=2,a.BEND_DIRECTION=3,a.COMPRESS=4,a.STRETCH=5,a}(s);t.IkConstraintTimeline=m;var v=function(i){function s(e){var n=i.call(this,e)||this;return n.frames=t.Utils.newFloatArray(e*s.ENTRIES),n}return WK(s,i),s.prototype.getPropertyId=function(){return(n.transformConstraint<<24)+this.transformConstraintIndex},s.prototype.setFrame=function(t,e,i,n,r,a){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=n,this.frames[t+s.SCALE]=r,this.frames[t+s.SHEAR]=a},s.prototype.apply=function(t,i,n,a,o,h){var l=this.frames,u=t.transformConstraints[this.transformConstraintIndex];if(u.active)if(n<l[0]){var c=u.data;switch(h){case e.setup:return u.rotateMix=c.rotateMix,u.translateMix=c.translateMix,u.scaleMix=c.scaleMix,void(u.shearMix=c.shearMix);case e.first:u.rotateMix+=(c.rotateMix-u.rotateMix)*o,u.translateMix+=(c.translateMix-u.translateMix)*o,u.scaleMix+=(c.scaleMix-u.scaleMix)*o,u.shearMix+=(c.shearMix-u.shearMix)*o}}else{var d=0,_=0,f=0,p=0;if(n>=l[l.length-s.ENTRIES]){var g=l.length;d=l[g+s.PREV_ROTATE],_=l[g+s.PREV_TRANSLATE],f=l[g+s.PREV_SCALE],p=l[g+s.PREV_SHEAR]}else{var m=r.binarySearch(l,n,s.ENTRIES);d=l[m+s.PREV_ROTATE],_=l[m+s.PREV_TRANSLATE],f=l[m+s.PREV_SCALE],p=l[m+s.PREV_SHEAR];var v=l[m],y=this.getCurvePercent(m/s.ENTRIES-1,1-(n-v)/(l[m+s.PREV_TIME]-v));d+=(l[m+s.ROTATE]-d)*y,_+=(l[m+s.TRANSLATE]-_)*y,f+=(l[m+s.SCALE]-f)*y,p+=(l[m+s.SHEAR]-p)*y}h==e.setup?(c=u.data,u.rotateMix=c.rotateMix+(d-c.rotateMix)*o,u.translateMix=c.translateMix+(_-c.translateMix)*o,u.scaleMix=c.scaleMix+(f-c.scaleMix)*o,u.shearMix=c.shearMix+(p-c.shearMix)*o):(u.rotateMix+=(d-u.rotateMix)*o,u.translateMix+=(_-u.translateMix)*o,u.scaleMix+=(f-u.scaleMix)*o,u.shearMix+=(p-u.shearMix)*o)}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_ROTATE=-4,s.PREV_TRANSLATE=-3,s.PREV_SCALE=-2,s.PREV_SHEAR=-1,s.ROTATE=1,s.TRANSLATE=2,s.SCALE=3,s.SHEAR=4,s}(s);t.TransformConstraintTimeline=v;var y=function(i){function s(e){var n=i.call(this,e)||this;return n.frames=t.Utils.newFloatArray(e*s.ENTRIES),n}return WK(s,i),s.prototype.getPropertyId=function(){return(n.pathConstraintPosition<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.VALUE]=i},s.prototype.apply=function(t,i,n,a,o,h){var l=this.frames,u=t.pathConstraints[this.pathConstraintIndex];if(u.active)if(n<l[0])switch(h){case e.setup:return void(u.position=u.data.position);case e.first:u.position+=(u.data.position-u.position)*o}else{var c=0;if(n>=l[l.length-s.ENTRIES])c=l[l.length+s.PREV_VALUE];else{var d=r.binarySearch(l,n,s.ENTRIES);c=l[d+s.PREV_VALUE];var _=l[d],f=this.getCurvePercent(d/s.ENTRIES-1,1-(n-_)/(l[d+s.PREV_TIME]-_));c+=(l[d+s.VALUE]-c)*f}h==e.setup?u.position=u.data.position+(c-u.data.position)*o:u.position+=(c-u.position)*o}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_VALUE=-1,s.VALUE=1,s}(s);t.PathConstraintPositionTimeline=y;var T=function(t){function i(e){return t.call(this,e)||this}return WK(i,t),i.prototype.getPropertyId=function(){return(n.pathConstraintSpacing<<24)+this.pathConstraintIndex},i.prototype.apply=function(t,n,s,a,o,h){var l=this.frames,u=t.pathConstraints[this.pathConstraintIndex];if(u.active)if(s<l[0])switch(h){case e.setup:return void(u.spacing=u.data.spacing);case e.first:u.spacing+=(u.data.spacing-u.spacing)*o}else{var c=0;if(s>=l[l.length-i.ENTRIES])c=l[l.length+i.PREV_VALUE];else{var d=r.binarySearch(l,s,i.ENTRIES);c=l[d+i.PREV_VALUE];var _=l[d],f=this.getCurvePercent(d/i.ENTRIES-1,1-(s-_)/(l[d+i.PREV_TIME]-_));c+=(l[d+i.VALUE]-c)*f}h==e.setup?u.spacing=u.data.spacing+(c-u.data.spacing)*o:u.spacing+=(c-u.spacing)*o}},i}(y);t.PathConstraintSpacingTimeline=T;var S=function(i){function s(e){var n=i.call(this,e)||this;return n.frames=t.Utils.newFloatArray(e*s.ENTRIES),n}return WK(s,i),s.prototype.getPropertyId=function(){return(n.pathConstraintMix<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=n},s.prototype.apply=function(t,i,n,a,o,h){var l=this.frames,u=t.pathConstraints[this.pathConstraintIndex];if(u.active)if(n<l[0])switch(h){case e.setup:return u.rotateMix=u.data.rotateMix,void(u.translateMix=u.data.translateMix);case e.first:u.rotateMix+=(u.data.rotateMix-u.rotateMix)*o,u.translateMix+=(u.data.translateMix-u.translateMix)*o}else{var c=0,d=0;if(n>=l[l.length-s.ENTRIES])c=l[l.length+s.PREV_ROTATE],d=l[l.length+s.PREV_TRANSLATE];else{var _=r.binarySearch(l,n,s.ENTRIES);c=l[_+s.PREV_ROTATE],d=l[_+s.PREV_TRANSLATE];var f=l[_],p=this.getCurvePercent(_/s.ENTRIES-1,1-(n-f)/(l[_+s.PREV_TIME]-f));c+=(l[_+s.ROTATE]-c)*p,d+=(l[_+s.TRANSLATE]-d)*p}h==e.setup?(u.rotateMix=u.data.rotateMix+(c-u.data.rotateMix)*o,u.translateMix=u.data.translateMix+(d-u.data.translateMix)*o):(u.rotateMix+=(c-u.rotateMix)*o,u.translateMix+=(d-u.translateMix)*o)}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_ROTATE=-2,s.PREV_TRANSLATE=-1,s.ROTATE=1,s.TRANSLATE=2,s}(s);t.PathConstraintMixTimeline=S}(XK||(XK={})),function(t){var e=function(){function e(e){this.tracks=new Array,this.timeScale=1,this.events=new Array,this.listeners=new Array,this.queue=new r(this),this.propertyIDs=new t.IntSet,this.animationsChanged=!1,this.trackEntryPool=new t.Pool((function(){return new i})),this.data=e}return e.prototype.update=function(t){t*=this.timeScale;for(var e=this.tracks,i=0,n=e.length;i<n;i++){var r=e[i];if(null!=r){r.animationLast=r.nextAnimationLast,r.trackLast=r.nextTrackLast;var s=t*r.timeScale;if(r.delay>0){if(r.delay-=s,r.delay>0)continue;s=-r.delay,r.delay=0}var a=r.next;if(null!=a){var o=r.trackLast-a.delay;if(o>=0){for(a.delay=0,a.trackTime+=0==r.timeScale?0:(o/r.timeScale+t)*a.timeScale,r.trackTime+=s,this.setCurrent(i,a,!0);null!=a.mixingFrom;)a.mixTime+=t,a=a.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&null==r.mixingFrom){e[i]=null,this.queue.end(r),this.disposeNext(r);continue}if(null!=r.mixingFrom&&this.updateMixingFrom(r,t)){var h=r.mixingFrom;for(r.mixingFrom=null,null!=h&&(h.mixingTo=null);null!=h;)this.queue.end(h),h=h.mixingFrom}r.trackTime+=s}}this.queue.drain()},e.prototype.updateMixingFrom=function(t,e){var i=t.mixingFrom;if(null==i)return!0;var n=this.updateMixingFrom(i,e);return i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast,t.mixTime>0&&t.mixTime>=t.mixDuration?(0!=i.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=i.mixingFrom,null!=i.mixingFrom&&(i.mixingFrom.mixingTo=t),t.interruptAlpha=i.interruptAlpha,this.queue.end(i)),n):(i.trackTime+=e*i.timeScale,t.mixTime+=e,!1)},e.prototype.apply=function(i){if(null==i)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();for(var n=this.events,r=this.tracks,s=!1,a=0,o=r.length;a<o;a++){var h=r[a];if(!(null==h||h.delay>0)){s=!0;var l=0==a?t.MixBlend.first:h.mixBlend,u=h.alpha;null!=h.mixingFrom?u*=this.applyMixingFrom(h,i,l):h.trackTime>=h.trackEnd&&null==h.next&&(u=0);var c=h.animationLast,d=h.getAnimationTime(),_=h.animation.timelines.length,f=h.animation.timelines;if(0==a&&1==u||l==t.MixBlend.add)for(var p=0;p<_;p++)t.Utils.webkit602BugfixHelper(u,l),f[p].apply(i,c,d,n,u,l,t.MixDirection.mixIn);else{var g=h.timelineMode,m=0==h.timelinesRotation.length;m&&t.Utils.setArraySize(h.timelinesRotation,_<<1,null);var v=h.timelinesRotation;for(p=0;p<_;p++){var y=f[p],T=(g[p]&e.NOT_LAST-1)==e.SUBSEQUENT?l:t.MixBlend.setup;y instanceof t.RotateTimeline?this.applyRotateTimeline(y,i,d,u,T,v,p<<1,m):(t.Utils.webkit602BugfixHelper(u,l),y.apply(i,c,d,n,u,T,t.MixDirection.mixIn))}}this.queueEvents(h,d),n.length=0,h.nextAnimationLast=d,h.nextTrackLast=h.trackTime}}return this.queue.drain(),s},e.prototype.applyMixingFrom=function(i,n,r){var s=i.mixingFrom;null!=s.mixingFrom&&this.applyMixingFrom(s,n,r);var a=0;0==i.mixDuration?(a=1,r==t.MixBlend.first&&(r=t.MixBlend.setup)):((a=i.mixTime/i.mixDuration)>1&&(a=1),r!=t.MixBlend.first&&(r=s.mixBlend));var o=a<s.eventThreshold?this.events:null,h=a<s.attachmentThreshold,l=a<s.drawOrderThreshold,u=s.animationLast,c=s.getAnimationTime(),d=s.animation.timelines.length,_=s.animation.timelines,f=s.alpha*i.interruptAlpha,p=f*(1-a);if(r==t.MixBlend.add)for(var g=0;g<d;g++)_[g].apply(n,u,c,o,p,r,t.MixDirection.mixOut);else{var m=s.timelineMode,v=s.timelineHoldMix,y=0==s.timelinesRotation.length;y&&t.Utils.setArraySize(s.timelinesRotation,d<<1,null);var T=s.timelinesRotation;for(s.totalAlpha=0,g=0;g<d;g++){var S=_[g],E=t.MixDirection.mixOut,A=void 0,C=0;switch(m[g]&e.NOT_LAST-1){case e.SUBSEQUENT:if(A=r,!h&&S instanceof t.AttachmentTimeline){if((m[g]&e.NOT_LAST)==e.NOT_LAST)continue;A=t.MixBlend.setup}if(!l&&S instanceof t.DrawOrderTimeline)continue;C=p;break;case e.FIRST:A=t.MixBlend.setup,C=p;break;case e.HOLD:A=t.MixBlend.setup,C=f;break;default:A=t.MixBlend.setup;var R=v[g];C=f*Math.max(0,1-R.mixTime/R.mixDuration)}s.totalAlpha+=C,S instanceof t.RotateTimeline?this.applyRotateTimeline(S,n,c,C,A,T,g<<1,y):(t.Utils.webkit602BugfixHelper(C,r),A==t.MixBlend.setup&&(S instanceof t.AttachmentTimeline?(h||(m[g]&e.NOT_LAST)==e.NOT_LAST)&&(E=t.MixDirection.mixIn):S instanceof t.DrawOrderTimeline&&l&&(E=t.MixDirection.mixIn)),S.apply(n,u,c,o,C,A,E))}}return i.mixDuration>0&&this.queueEvents(s,c),this.events.length=0,s.nextAnimationLast=c,s.nextTrackLast=s.trackTime,a},e.prototype.applyRotateTimeline=function(e,i,n,r,s,a,o,h){if(h&&(a[o]=0),1!=r){var l=e,u=l.frames,c=i.bones[l.boneIndex];if(c.active){var d=0,_=0;if(n<u[0])switch(s){case t.MixBlend.setup:c.rotation=c.data.rotation;default:return;case t.MixBlend.first:d=c.rotation,_=c.data.rotation}else if(d=s==t.MixBlend.setup?c.data.rotation:c.rotation,n>=u[u.length-t.RotateTimeline.ENTRIES])_=c.data.rotation+u[u.length+t.RotateTimeline.PREV_ROTATION];else{var f=t.Animation.binarySearch(u,n,t.RotateTimeline.ENTRIES),p=u[f+t.RotateTimeline.PREV_ROTATION],g=u[f],m=l.getCurvePercent((f>>1)-1,1-(n-g)/(u[f+t.RotateTimeline.PREV_TIME]-g));_=u[f+t.RotateTimeline.ROTATION]-p,_=p+(_-=360*(16384-(16384.499999999996-_/360|0)))*m+c.data.rotation,_-=360*(16384-(16384.499999999996-_/360|0))}var v=0,y=_-d;if(0==(y-=360*(16384-(16384.499999999996-y/360|0))))v=a[o];else{var T=0,S=0;h?(T=0,S=y):(T=a[o],S=a[o+1]);var E=y>0,A=T>=0;t.MathUtils.signum(S)!=t.MathUtils.signum(y)&&Math.abs(S)<=90&&(Math.abs(T)>180&&(T+=360*t.MathUtils.signum(T)),A=E),v=y+T-T%360,A!=E&&(v+=360*t.MathUtils.signum(T)),a[o]=v}a[o+1]=y,d+=v*r,c.rotation=d-360*(16384-(16384.499999999996-d/360|0))}}else e.apply(i,0,n,null,1,s,t.MixDirection.mixIn)},e.prototype.queueEvents=function(t,e){for(var i=t.animationStart,n=t.animationEnd,r=n-i,s=t.trackLast%r,a=this.events,o=0,h=a.length;o<h;o++){var l=a[o];if(l.time<s)break;l.time>n||this.queue.event(t,l)}for((t.loop?0==r||s>t.trackTime%r:e>=n&&t.animationLast<n)&&this.queue.complete(t);o<h;o++)a[o].time<i||this.queue.event(t,a[o])},e.prototype.clearTracks=function(){var t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(var e=0,i=this.tracks.length;e<i;e++)this.clearTrack(e);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()},e.prototype.clearTrack=function(t){if(!(t>=this.tracks.length)){var e=this.tracks[t];if(null!=e){this.queue.end(e),this.disposeNext(e);for(var i=e;;){var n=i.mixingFrom;if(null==n)break;this.queue.end(n),i.mixingFrom=null,i.mixingTo=null,i=n}this.tracks[e.trackIndex]=null,this.queue.drain()}}},e.prototype.setCurrent=function(t,e,i){var n=this.expandToIndex(t);this.tracks[t]=e,null!=n&&(i&&this.queue.interrupt(n),e.mixingFrom=n,n.mixingTo=e,e.mixTime=0,null!=n.mixingFrom&&n.mixDuration>0&&(e.interruptAlpha*=Math.min(1,n.mixTime/n.mixDuration)),n.timelinesRotation.length=0),this.queue.start(e)},e.prototype.setAnimation=function(t,e,i){var n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,n,i)},e.prototype.setAnimationWith=function(t,e,i){if(null==e)throw new Error("animation cannot be null.");var n=!0,r=this.expandToIndex(t);null!=r&&(-1==r.nextTrackLast?(this.tracks[t]=r.mixingFrom,this.queue.interrupt(r),this.queue.end(r),this.disposeNext(r),r=r.mixingFrom,n=!1):this.disposeNext(r));var s=this.trackEntry(t,e,i,r);return this.setCurrent(t,s,n),this.queue.drain(),s},e.prototype.addAnimation=function(t,e,i,n){var r=this.data.skeletonData.findAnimation(e);if(null==r)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,r,i,n)},e.prototype.addAnimationWith=function(t,e,i,n){if(null==e)throw new Error("animation cannot be null.");var r=this.expandToIndex(t);if(null!=r)for(;null!=r.next;)r=r.next;var s=this.trackEntry(t,e,i,r);if(null==r)this.setCurrent(t,s,!0),this.queue.drain();else if(r.next=s,n<=0){var a=r.animationEnd-r.animationStart;0!=a?(r.loop?n+=a*(1+(r.trackTime/a|0)):n+=Math.max(a,r.trackTime),n-=this.data.getMix(r.animation,e)):n=r.trackTime}return s.delay=n,s},e.prototype.setEmptyAnimation=function(t,i){var n=this.setAnimationWith(t,e.emptyAnimation,!1);return n.mixDuration=i,n.trackEnd=i,n},e.prototype.addEmptyAnimation=function(t,i,n){n<=0&&(n-=i);var r=this.addAnimationWith(t,e.emptyAnimation,!1,n);return r.mixDuration=i,r.trackEnd=i,r},e.prototype.setEmptyAnimations=function(t){var e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(var i=0,n=this.tracks.length;i<n;i++){var r=this.tracks[i];null!=r&&this.setEmptyAnimation(r.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()},e.prototype.expandToIndex=function(e){return e<this.tracks.length?this.tracks[e]:(t.Utils.ensureArrayCapacity(this.tracks,e+1,null),this.tracks.length=e+1,null)},e.prototype.trackEntry=function(t,e,i,n){var r=this.trackEntryPool.obtain();return r.trackIndex=t,r.animation=e,r.loop=i,r.holdPrevious=!1,r.eventThreshold=0,r.attachmentThreshold=0,r.drawOrderThreshold=0,r.animationStart=0,r.animationEnd=e.duration,r.animationLast=-1,r.nextAnimationLast=-1,r.delay=0,r.trackTime=0,r.trackLast=-1,r.nextTrackLast=-1,r.trackEnd=Number.MAX_VALUE,r.timeScale=1,r.alpha=1,r.interruptAlpha=1,r.mixTime=0,r.mixDuration=null==n?0:this.data.getMix(n.animation,e),r},e.prototype.disposeNext=function(t){for(var e=t.next;null!=e;)this.queue.dispose(e),e=e.next;t.next=null},e.prototype._animationsChanged=function(){this.animationsChanged=!1,this.propertyIDs.clear();for(var e=0,i=this.tracks.length;e<i;e++)if(null!=(n=this.tracks[e])){for(;null!=n.mixingFrom;)n=n.mixingFrom;do{null!=n.mixingFrom&&n.mixBlend==t.MixBlend.add||this.computeHold(n),n=n.mixingTo}while(null!=n)}for(this.propertyIDs.clear(),e=this.tracks.length-1;e>=0;e--)for(var n=this.tracks[e];null!=n;)this.computeNotLast(n),n=n.mixingFrom},e.prototype.computeHold=function(i){var n=i.mixingTo,r=i.animation.timelines,s=i.animation.timelines.length,a=t.Utils.setArraySize(i.timelineMode,s);i.timelineHoldMix.length=0;var o=t.Utils.setArraySize(i.timelineHoldMix,s),h=this.propertyIDs;if(null!=n&&n.holdPrevious)for(var l=0;l<s;l++)h.add(r[l].getPropertyId()),a[l]=e.HOLD;else t:for(l=0;l<s;l++){var u=r[l],c=u.getPropertyId();if(h.add(c))if(null==n||u instanceof t.AttachmentTimeline||u instanceof t.DrawOrderTimeline||u instanceof t.EventTimeline||!n.animation.hasTimeline(c))a[l]=e.FIRST;else{for(var d=n.mixingTo;null!=d;d=d.mixingTo)if(!d.animation.hasTimeline(c)){if(i.mixDuration>0){a[l]=e.HOLD_MIX,o[l]=d;continue t}break}a[l]=e.HOLD}else a[l]=e.SUBSEQUENT}},e.prototype.computeNotLast=function(i){for(var n=i.animation.timelines,r=i.animation.timelines.length,s=i.timelineMode,a=this.propertyIDs,o=0;o<r;o++)if(n[o]instanceof t.AttachmentTimeline){var h=n[o];a.add(h.slotIndex)||(s[o]|=e.NOT_LAST)}},e.prototype.getCurrent=function(t){return t>=this.tracks.length?null:this.tracks[t]},e.prototype.addListener=function(t){if(null==t)throw new Error("listener cannot be null.");this.listeners.push(t)},e.prototype.removeListener=function(t){var e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)},e.prototype.clearListeners=function(){this.listeners.length=0},e.prototype.clearListenerNotifications=function(){this.queue.clear()},e.emptyAnimation=new t.Animation("<empty>",[],0),e.SUBSEQUENT=0,e.FIRST=1,e.HOLD=2,e.HOLD_MIX=3,e.NOT_LAST=4,e}();t.AnimationState=e;var i=function(){function e(){this.mixBlend=t.MixBlend.replace,this.timelineMode=new Array,this.timelineHoldMix=new Array,this.timelinesRotation=new Array}return e.prototype.reset=function(){this.next=null,this.mixingFrom=null,this.mixingTo=null,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0},e.prototype.getAnimationTime=function(){if(this.loop){var t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)},e.prototype.setAnimationLast=function(t){this.animationLast=t,this.nextAnimationLast=t},e.prototype.isComplete=function(){return this.trackTime>=this.animationEnd-this.animationStart},e.prototype.resetRotationDirections=function(){this.timelinesRotation.length=0},e}();t.TrackEntry=i;var n,r=function(){function t(t){this.objects=[],this.drainDisabled=!1,this.animState=t}return t.prototype.start=function(t){this.objects.push(n.start),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.interrupt=function(t){this.objects.push(n.interrupt),this.objects.push(t)},t.prototype.end=function(t){this.objects.push(n.end),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.dispose=function(t){this.objects.push(n.dispose),this.objects.push(t)},t.prototype.complete=function(t){this.objects.push(n.complete),this.objects.push(t)},t.prototype.event=function(t,e){this.objects.push(n.event),this.objects.push(t),this.objects.push(e)},t.prototype.drain=function(){if(!this.drainDisabled){this.drainDisabled=!0;for(var t=this.objects,e=this.animState.listeners,i=0;i<t.length;i+=2){var r=t[i],s=t[i+1];switch(r){case n.start:null!=s.listener&&s.listener.start&&s.listener.start(s);for(var a=0;a<e.length;a++)e[a].start&&e[a].start(s);break;case n.interrupt:for(null!=s.listener&&s.listener.interrupt&&s.listener.interrupt(s),a=0;a<e.length;a++)e[a].interrupt&&e[a].interrupt(s);break;case n.end:for(null!=s.listener&&s.listener.end&&s.listener.end(s),a=0;a<e.length;a++)e[a].end&&e[a].end(s);case n.dispose:for(null!=s.listener&&s.listener.dispose&&s.listener.dispose(s),a=0;a<e.length;a++)e[a].dispose&&e[a].dispose(s);this.animState.trackEntryPool.free(s);break;case n.complete:for(null!=s.listener&&s.listener.complete&&s.listener.complete(s),a=0;a<e.length;a++)e[a].complete&&e[a].complete(s);break;case n.event:var o=t[2+i++];for(null!=s.listener&&s.listener.event&&s.listener.event(s,o),a=0;a<e.length;a++)e[a].event&&e[a].event(s,o)}}this.clear(),this.drainDisabled=!1}},t.prototype.clear=function(){this.objects.length=0},t}();t.EventQueue=r,function(t){t[t.start=0]="start",t[t.interrupt=1]="interrupt",t[t.end=2]="end",t[t.dispose=3]="dispose",t[t.complete=4]="complete",t[t.event=5]="event"}(n=t.EventType||(t.EventType={}));var s=function(){function t(){}return t.prototype.start=function(){},t.prototype.interrupt=function(){},t.prototype.end=function(){},t.prototype.dispose=function(){},t.prototype.complete=function(){},t.prototype.event=function(){},t}();t.AnimationStateAdapter=s}(XK||(XK={})),function(t){var e=function(){function t(t){if(this.animationToMixTime={},this.defaultMix=0,null==t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}return t.prototype.setMix=function(t,e,i){var n=this.skeletonData.findAnimation(t);if(null==n)throw new Error("Animation not found: "+t);var r=this.skeletonData.findAnimation(e);if(null==r)throw new Error("Animation not found: "+e);this.setMixWith(n,r,i)},t.prototype.setMixWith=function(t,e,i){if(null==t)throw new Error("from cannot be null.");if(null==e)throw new Error("to cannot be null.");var n=t.name+"."+e.name;this.animationToMixTime[n]=i},t.prototype.getMix=function(t,e){var i=t.name+"."+e.name,n=this.animationToMixTime[i];return void 0===n?this.defaultMix:n},t}();t.AnimationStateData=e}(XK||(XK={})),function(t){var e=function(){function e(t,e){void 0===e&&(e=""),this.assets={},this.errors={},this.toLoad=0,this.loaded=0,this.textureLoader=t,this.pathPrefix=e}return e.downloadText=function(t,e,i){var n=new XMLHttpRequest;n.open("GET",t,!0),n.onload=function(){200==n.status?e(n.responseText):i(n.status,n.responseText)},n.onerror=function(){i(n.status,n.responseText)},n.send()},e.downloadBinary=function(t,e,i){var n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status?e(new Uint8Array(n.response)):i(n.status,n.responseText)},n.onerror=function(){i(n.status,n.responseText)},n.send()},e.prototype.loadBinary=function(t,i,n){var r=this;void 0===i&&(i=null),void 0===n&&(n=null),t=this.pathPrefix+t,this.toLoad++,e.downloadBinary(t,(function(e){r.assets[t]=e,i&&i(t,e),r.toLoad--,r.loaded++}),(function(e,i){r.errors[t]="Couldn't load binary "+t+": status "+status+", "+i,n&&n(t,"Couldn't load binary "+t+": status "+status+", "+i),r.toLoad--,r.loaded++}))},e.prototype.loadText=function(t,i,n){var r=this;void 0===i&&(i=null),void 0===n&&(n=null),t=this.pathPrefix+t,this.toLoad++,e.downloadText(t,(function(e){r.assets[t]=e,i&&i(t,e),r.toLoad--,r.loaded++}),(function(e,i){r.errors[t]="Couldn't load text "+t+": status "+status+", "+i,n&&n(t,"Couldn't load text "+t+": status "+status+", "+i),r.toLoad--,r.loaded++}))},e.prototype.loadTexture=function(t,e,i){var n=this;void 0===e&&(e=null),void 0===i&&(i=null),t=this.pathPrefix+t,this.toLoad++;var r=new YK.Image;r.crossOrigin="anonymous",r.onload=function(){var i=n.textureLoader(r);n.assets[t]=i,n.toLoad--,n.loaded++,e&&e(t,r)},r.onerror=function(){n.errors[t]="Couldn't load image "+t,n.toLoad--,n.loaded++,i&&i(t,"Couldn't load image "+t)},r.src=t},e.prototype.loadTextureData=function(t,e,i,n){var r=this;void 0===i&&(i=null),void 0===n&&(n=null),t=this.pathPrefix+t,this.toLoad++;var s=new YK.Image;s.onload=function(){var e=r.textureLoader(s);r.assets[t]=e,r.toLoad--,r.loaded++,i&&i(t,s)},s.onerror=function(){r.errors[t]="Couldn't load image "+t,r.toLoad--,r.loaded++,n&&n(t,"Couldn't load image "+t)},s.src=e},e.prototype.loadTextureAtlas=function(i,n,r){var s=this;void 0===n&&(n=null),void 0===r&&(r=null);var a=i.lastIndexOf("/")>=0?i.substring(0,i.lastIndexOf("/")):"";i=this.pathPrefix+i,this.toLoad++,e.downloadText(i,(function(e){var o={count:0},h=new Array;try{new t.TextureAtlas(e,(function(e){h.push(a+"/"+e);var i=new YK.Image;return i.width=16,i.height=16,new t.FakeTexture(i)}))}catch(t){var l=t;return s.errors[i]="Couldn't load texture atlas "+i+": "+l.message,r&&r(i,"Couldn't load texture atlas "+i+": "+l.message),s.toLoad--,void s.loaded++}for(var u=function(l){var u=!1;s.loadTexture(l,(function(l){if(o.count++,o.count==h.length)if(u)s.errors[i]="Couldn't load texture atlas page "+l+"} of atlas "+i,r&&r(i,"Couldn't load texture atlas page "+l+" of atlas "+i),s.toLoad--,s.loaded++;else try{var c=new t.TextureAtlas(e,(function(t){return s.get(a+"/"+t)}));s.assets[i]=c,n&&n(i,c),s.toLoad--,s.loaded++}catch(t){var d=t;s.errors[i]="Couldn't load texture atlas "+i+": "+d.message,r&&r(i,"Couldn't load texture atlas "+i+": "+d.message),s.toLoad--,s.loaded++}}),(function(t){u=!0,o.count++,o.count==h.length&&(s.errors[i]="Couldn't load texture atlas page "+t+"} of atlas "+i,r&&r(i,"Couldn't load texture atlas page "+t+" of atlas "+i),s.toLoad--,s.loaded++)}))},c=0,d=h;c<d.length;c++)u(d[c])}),(function(t,e){s.errors[i]="Couldn't load texture atlas "+i+": status "+status+", "+e,r&&r(i,"Couldn't load texture atlas "+i+": status "+status+", "+e),s.toLoad--,s.loaded++}))},e.prototype.get=function(t){return t=this.pathPrefix+t,this.assets[t]},e.prototype.remove=function(t){t=this.pathPrefix+t;var e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null},e.prototype.removeAll=function(){for(var t in this.assets){var e=this.assets[t];e.dispose&&e.dispose()}this.assets={}},e.prototype.isLoadingComplete=function(){return 0==this.toLoad},e.prototype.getToLoad=function(){return this.toLoad},e.prototype.getLoaded=function(){return this.loaded},e.prototype.dispose=function(){this.removeAll()},e.prototype.hasErrors=function(){return Object.keys(this.errors).length>0},e.prototype.getErrors=function(){return this.errors},e}();t.AssetManager=e}(XK||(XK={})),function(t){var e=function(){function e(t){this.atlas=t}return e.prototype.newRegionAttachment=function(e,i,n){var r=this.atlas.findRegion(n);if(null==r)return null;r.renderObject=r;var s=new t.RegionAttachment(i);return s.setRegion(r),s},e.prototype.newMeshAttachment=function(e,i,n){var r=this.atlas.findRegion(n);if(null==r)return null;r.renderObject=r;var s=new t.MeshAttachment(i);return s.region=r,s},e.prototype.newBoundingBoxAttachment=function(e,i){return new t.BoundingBoxAttachment(i)},e.prototype.newPathAttachment=function(e,i){return new t.PathAttachment(i)},e.prototype.newPointAttachment=function(e,i){return new t.PointAttachment(i)},e.prototype.newClippingAttachment=function(e,i){return new t.ClippingAttachment(i)},e}();t.AtlasAttachmentLoader=e}(XK||(XK={})),function(t){var e;(e=t.BlendMode||(t.BlendMode={}))[e.Normal=0]="Normal",e[e.Additive=1]="Additive",e[e.Multiply=2]="Multiply",e[e.Screen=3]="Screen"}(XK||(XK={})),function(t){var e=function(){function e(t,e,i){if(this.children=new Array,this.x=0,this.y=0,this.rotation=0,this.scaleX=0,this.scaleY=0,this.shearX=0,this.shearY=0,this.ax=0,this.ay=0,this.arotation=0,this.ascaleX=0,this.ascaleY=0,this.ashearX=0,this.ashearY=0,this.appliedValid=!1,this.a=0,this.b=0,this.c=0,this.d=0,this.worldY=0,this.worldX=0,this.sorted=!1,this.active=!1,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=i,this.setToSetupPose()}return e.prototype.isActive=function(){return this.active},e.prototype.update=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)},e.prototype.updateWorldTransform=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)},e.prototype.updateWorldTransformWith=function(e,i,n,r,s,a,o){this.ax=e,this.ay=i,this.arotation=n,this.ascaleX=r,this.ascaleY=s,this.ashearX=a,this.ashearY=o,this.appliedValid=!0;var h=this.parent;if(null==h){var l=this.skeleton,u=n+90+o,c=l.scaleX,d=l.scaleY;return this.a=t.MathUtils.cosDeg(n+a)*r*c,this.b=t.MathUtils.cosDeg(u)*s*c,this.c=t.MathUtils.sinDeg(n+a)*r*d,this.d=t.MathUtils.sinDeg(u)*s*d,this.worldX=e*c+l.x,void(this.worldY=i*d+l.y)}var _=h.a,f=h.b,p=h.c,g=h.d;switch(this.worldX=_*e+f*i+h.worldX,this.worldY=p*e+g*i+h.worldY,this.data.transformMode){case t.TransformMode.Normal:u=n+90+o;var m=t.MathUtils.cosDeg(n+a)*r,v=t.MathUtils.cosDeg(u)*s,y=t.MathUtils.sinDeg(n+a)*r,T=t.MathUtils.sinDeg(u)*s;return this.a=_*m+f*y,this.b=_*v+f*T,this.c=p*m+g*y,void(this.d=p*v+g*T);case t.TransformMode.OnlyTranslation:u=n+90+o,this.a=t.MathUtils.cosDeg(n+a)*r,this.b=t.MathUtils.cosDeg(u)*s,this.c=t.MathUtils.sinDeg(n+a)*r,this.d=t.MathUtils.sinDeg(u)*s;break;case t.TransformMode.NoRotationOrReflection:var S=0;(C=_*_+p*p)>1e-4?(f=p*(C=Math.abs(_*g-f*p)/C),g=_*C,S=Math.atan2(p,_)*t.MathUtils.radDeg):(_=0,p=0,S=90-Math.atan2(g,f)*t.MathUtils.radDeg);var E=n+a-S,A=n+o-S+90;m=t.MathUtils.cosDeg(E)*r,v=t.MathUtils.cosDeg(A)*s,y=t.MathUtils.sinDeg(E)*r,T=t.MathUtils.sinDeg(A)*s,this.a=_*m-f*y,this.b=_*v-f*T,this.c=p*m+g*y,this.d=p*v+g*T;break;case t.TransformMode.NoScale:case t.TransformMode.NoScaleOrReflection:var C,R=t.MathUtils.cosDeg(n),b=t.MathUtils.sinDeg(n),x=(_*R+f*b)/this.skeleton.scaleX,w=(p*R+g*b)/this.skeleton.scaleY;(C=Math.sqrt(x*x+w*w))>1e-5&&(C=1/C),x*=C,w*=C,C=Math.sqrt(x*x+w*w),this.data.transformMode==t.TransformMode.NoScale&&_*g-f*p<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(C=-C);var M=Math.PI/2+Math.atan2(w,x),I=Math.cos(M)*C,B=Math.sin(M)*C;m=t.MathUtils.cosDeg(a)*r,v=t.MathUtils.cosDeg(90+o)*s,y=t.MathUtils.sinDeg(a)*r,T=t.MathUtils.sinDeg(90+o)*s,this.a=x*m+I*y,this.b=x*v+I*T,this.c=w*m+B*y,this.d=w*v+B*T}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY},e.prototype.setToSetupPose=function(){var t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY},e.prototype.getWorldRotationX=function(){return Math.atan2(this.c,this.a)*t.MathUtils.radDeg},e.prototype.getWorldRotationY=function(){return Math.atan2(this.d,this.b)*t.MathUtils.radDeg},e.prototype.getWorldScaleX=function(){return Math.sqrt(this.a*this.a+this.c*this.c)},e.prototype.getWorldScaleY=function(){return Math.sqrt(this.b*this.b+this.d*this.d)},e.prototype.updateAppliedTransform=function(){this.appliedValid=!0;var e=this.parent;if(null==e)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*t.MathUtils.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*t.MathUtils.radDeg);var i=e.a,n=e.b,r=e.c,s=e.d,a=1/(i*s-n*r),o=this.worldX-e.worldX,h=this.worldY-e.worldY;this.ax=o*s*a-h*n*a,this.ay=h*i*a-o*r*a;var l=a*s,u=a*i,c=a*n,d=a*r,_=l*this.a-c*this.c,f=l*this.b-c*this.d,p=u*this.c-d*this.a,g=u*this.d-d*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(_*_+p*p),this.ascaleX>1e-4){var m=_*g-f*p;this.ascaleY=m/this.ascaleX,this.ashearY=Math.atan2(_*f+p*g,m)*t.MathUtils.radDeg,this.arotation=Math.atan2(p,_)*t.MathUtils.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(f*f+g*g),this.ashearY=0,this.arotation=90-Math.atan2(g,f)*t.MathUtils.radDeg},e.prototype.worldToLocal=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=1/(e*r-i*n),a=t.x-this.worldX,o=t.y-this.worldY;return t.x=a*r*s-o*i*s,t.y=o*e*s-a*n*s,t},e.prototype.localToWorld=function(t){var e=t.x,i=t.y;return t.x=e*this.a+i*this.b+this.worldX,t.y=e*this.c+i*this.d+this.worldY,t},e.prototype.worldToLocalRotation=function(e){var i=t.MathUtils.sinDeg(e),n=t.MathUtils.cosDeg(e);return Math.atan2(this.a*i-this.c*n,this.d*n-this.b*i)*t.MathUtils.radDeg+this.rotation-this.shearX},e.prototype.localToWorldRotation=function(e){e-=this.rotation-this.shearX;var i=t.MathUtils.sinDeg(e),n=t.MathUtils.cosDeg(e);return Math.atan2(n*this.c+i*this.d,n*this.a+i*this.b)*t.MathUtils.radDeg},e.prototype.rotateWorld=function(e){var i=this.a,n=this.b,r=this.c,s=this.d,a=t.MathUtils.cosDeg(e),o=t.MathUtils.sinDeg(e);this.a=a*i-o*r,this.b=a*n-o*s,this.c=o*i+a*r,this.d=o*n+a*s,this.appliedValid=!1},e}();t.Bone=e}(XK||(XK={})),function(t){var e;t.BoneData=function(i,n,r){if(this.x=0,this.y=0,this.rotation=0,this.scaleX=1,this.scaleY=1,this.shearX=0,this.shearY=0,this.transformMode=e.Normal,this.skinRequired=!1,this.color=new t.Color,i<0)throw new Error("index must be >= 0.");if(null==n)throw new Error("name cannot be null.");this.index=i,this.name=n,this.parent=r},function(t){t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection"}(e=t.TransformMode||(t.TransformMode={}))}(XK||(XK={})),function(t){t.ConstraintData=function(t,e,i){this.name=t,this.order=e,this.skinRequired=i}}(XK||(XK={})),function(t){t.Event=function(t,e){if(null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}}(XK||(XK={})),function(t){t.EventData=function(t){this.name=t}}(XK||(XK={})),function(t){var e=function(){function e(t,e){if(this.bendDirection=0,this.compress=!1,this.stretch=!1,this.mix=1,this.softness=0,this.active=!1,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch,this.bones=new Array;for(var i=0;i<t.bones.length;i++)this.bones.push(e.findBone(t.bones[i].name));this.target=e.findBone(t.target.name)}return e.prototype.isActive=function(){return this.active},e.prototype.apply=function(){this.update()},e.prototype.update=function(){var t=this.target,e=this.bones;switch(e.length){case 1:this.apply1(e[0],t.worldX,t.worldY,this.compress,this.stretch,this.data.uniform,this.mix);break;case 2:this.apply2(e[0],e[1],t.worldX,t.worldY,this.bendDirection,this.stretch,this.softness,this.mix)}},e.prototype.apply1=function(e,i,n,r,s,a,o){e.appliedValid||e.updateAppliedTransform();var h=e.parent,l=1/(h.a*h.d-h.b*h.c),u=i-h.worldX,c=n-h.worldY,d=(u*h.d-c*h.b)*l-e.ax,_=(c*h.a-u*h.c)*l-e.ay,f=Math.atan2(_,d)*t.MathUtils.radDeg-e.ashearX-e.arotation;e.ascaleX<0&&(f+=180),f>180?f-=360:f<-180&&(f+=360);var p=e.ascaleX,g=e.ascaleY;if(r||s){var m=e.data.length*p,v=Math.sqrt(d*d+_*_);if(r&&v<m||s&&v>m&&m>1e-4){var y=(v/m-1)*o+1;p*=y,a&&(g*=y)}}e.updateWorldTransformWith(e.ax,e.ay,e.arotation+f*o,p,g,e.ashearX,e.ashearY)},e.prototype.apply2=function(e,i,n,r,s,a,o,h){if(0!=h){e.appliedValid||e.updateAppliedTransform(),i.appliedValid||i.updateAppliedTransform();var l=e.ax,u=e.ay,c=e.ascaleX,d=c,_=e.ascaleY,f=i.ascaleX,p=0,g=0,m=0;c<0?(c=-c,p=180,m=-1):(p=0,m=1),_<0&&(_=-_,m=-m),f<0?(f=-f,g=180):g=0;var v=i.ax,y=0,T=0,S=0,E=e.a,A=e.b,C=e.c,R=e.d,b=Math.abs(c-_)<=1e-4;b?(T=E*v+A*(y=i.ay)+e.worldX,S=C*v+R*y+e.worldY):(y=0,T=E*v+e.worldX,S=C*v+e.worldY);var x=e.parent;E=x.a,A=x.b,C=x.c;var w,M,I=1/(E*(R=x.d)-A*C),B=T-x.worldX,P=S-x.worldY,D=(B*R-P*A)*I-l,O=(P*E-B*C)*I-u,F=Math.sqrt(D*D+O*O),L=i.data.length*f;if(F<1e-4)return this.apply1(e,n,r,!1,a,!1,h),void i.updateWorldTransformWith(v,y,0,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY);var N=((B=n-x.worldX)*R-(P=r-x.worldY)*A)*I-l,k=(P*E-B*C)*I-u,U=N*N+k*k;if(0!=o){o*=c*(f+1)/2;var G=Math.sqrt(U),V=G-F-L*c+o;if(V>0){var H=Math.min(1,V/(2*o))-1;U=(N-=(H=(V-o*(1-H*H))/G)*N)*N+(k-=H*k)*k}}t:if(b){var z=(U-F*F-(L*=c)*L)/(2*F*L);z<-1?z=-1:z>1&&(z=1,a&&(d*=(Math.sqrt(U)/(F+L)-1)*h+1)),M=Math.acos(z)*s,E=F+L*z,A=L*Math.sin(M),w=Math.atan2(k*E-N*A,N*E+k*A)}else{var X=(E=c*L)*E,W=(A=_*L)*A,Y=Math.atan2(k,N),j=-2*W*F,K=W-X;if((R=j*j-4*K*(C=W*F*F+X*U-X*W))>=0){var q=Math.sqrt(R);j<0&&(q=-q);var Z=(q=-(j+q)/2)/K,Q=C/q,J=Math.abs(Z)<Math.abs(Q)?Z:Q;if(J*J<=U){P=Math.sqrt(U-J*J)*s,w=Y-Math.atan2(P,J),M=Math.atan2(P/_,(J-F)/c);break t}}var $=t.MathUtils.PI,tt=F-E,et=tt*tt,it=0,nt=0,rt=F+E,st=rt*rt,at=0;(C=-E*F/(X-W))>=-1&&C<=1&&(C=Math.acos(C),(R=(B=E*Math.cos(C)+F)*B+(P=A*Math.sin(C))*P)<et&&($=C,et=R,tt=B,it=P),R>st&&(nt=C,st=R,rt=B,at=P)),U<=(et+st)/2?(w=Y-Math.atan2(it*s,tt),M=$*s):(w=Y-Math.atan2(at*s,rt),M=nt*s)}var ot=Math.atan2(y,v)*m,ht=e.arotation;(w=(w-ot)*t.MathUtils.radDeg+p-ht)>180?w-=360:w<-180&&(w+=360),e.updateWorldTransformWith(l,u,ht+w*h,d,e.ascaleY,0,0),ht=i.arotation,(M=((M+ot)*t.MathUtils.radDeg-i.ashearX)*m+g-ht)>180?M-=360:M<-180&&(M+=360),i.updateWorldTransformWith(v,y,ht+M*h,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY)}else i.updateWorldTransform()},e}();t.IkConstraint=e}(XK||(XK={})),function(t){var e=function(t){function e(e){var i=t.call(this,e,0,!1)||this;return i.bones=new Array,i.bendDirection=1,i.compress=!1,i.stretch=!1,i.uniform=!1,i.mix=1,i.softness=0,i}return WK(e,t),e}(t.ConstraintData);t.IkConstraintData=e}(XK||(XK={})),function(t){var e=function(){function e(t,e){if(this.position=0,this.spacing=0,this.rotateMix=0,this.translateMix=0,this.spaces=new Array,this.positions=new Array,this.world=new Array,this.curves=new Array,this.lengths=new Array,this.segments=new Array,this.active=!1,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(var i=0,n=t.bones.length;i<n;i++)this.bones.push(e.findBone(t.bones[i].name));this.target=e.findSlot(t.target.name),this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix}return e.prototype.isActive=function(){return this.active},e.prototype.apply=function(){this.update()},e.prototype.update=function(){var i=this.target.getAttachment();if(i instanceof t.PathAttachment){var n=this.rotateMix,r=this.translateMix,s=n>0;if(r>0||s){var a=this.data,o=a.spacingMode==t.SpacingMode.Percent,h=a.rotateMode,l=h==t.RotateMode.Tangent,u=h==t.RotateMode.ChainScale,c=this.bones.length,d=l?c:c+1,_=this.bones,f=t.Utils.setArraySize(this.spaces,d),p=null,g=this.spacing;if(u||!o){u&&(p=t.Utils.setArraySize(this.lengths,c));for(var m=a.spacingMode==t.SpacingMode.Length,v=0,y=d-1;v<y;){var T=(B=_[v]).data.length;if(T<e.epsilon)u&&(p[v]=0),f[++v]=0;else if(o){if(u){var S=T*B.a,E=T*B.c,A=Math.sqrt(S*S+E*E);p[v]=A}f[++v]=g}else{S=T*B.a,E=T*B.c;var C=Math.sqrt(S*S+E*E);u&&(p[v]=C),f[++v]=(m?T+g:g)*C/T}}}else for(v=1;v<d;v++)f[v]=g;var R=this.computeWorldPositions(i,d,l,a.positionMode==t.PositionMode.Percent,o),b=R[0],x=R[1],w=a.offsetRotation,M=!1;0==w?M=h==t.RotateMode.Chain:(M=!1,w*=(I=this.target.bone).a*I.d-I.b*I.c>0?t.MathUtils.degRad:-t.MathUtils.degRad),v=0;for(var I=3;v<c;v++,I+=3){var B;(B=_[v]).worldX+=(b-B.worldX)*r,B.worldY+=(x-B.worldY)*r;var P=(S=R[I])-b,D=(E=R[I+1])-x;if(u){var O=p[v];if(0!=O){var F=(Math.sqrt(P*P+D*D)/O-1)*n+1;B.a*=F,B.c*=F}}if(b=S,x=E,s){var L=B.a,N=B.b,k=B.c,U=B.d,G=0,V=0,H=0;if(G=l?R[I-1]:0==f[v+1]?R[I+2]:Math.atan2(D,P),G-=Math.atan2(k,L),M){V=Math.cos(G),H=Math.sin(G);var z=B.data.length;b+=(z*(V*L-H*k)-P)*n,x+=(z*(H*L+V*k)-D)*n}else G+=w;G>t.MathUtils.PI?G-=t.MathUtils.PI2:G<-t.MathUtils.PI&&(G+=t.MathUtils.PI2),G*=n,V=Math.cos(G),H=Math.sin(G),B.a=V*L-H*k,B.b=V*N-H*U,B.c=H*L+V*k,B.d=H*N+V*U}B.appliedValid=!1}}}},e.prototype.computeWorldPositions=function(i,n,r,s,a){var o=this.target,h=this.position,l=this.spaces,u=t.Utils.setArraySize(this.positions,3*n+2),c=null,d=i.closed,_=i.worldVerticesLength,f=_/6,p=e.NONE;if(!i.constantSpeed){var g=i.lengths,m=g[f-=d?1:2];if(s&&(h*=m),a)for(var v=1;v<n;v++)l[v]*=m;c=t.Utils.setArraySize(this.world,8),v=0;for(var y=0,T=0;v<n;v++,y+=3){var S=h+=W=l[v];if(d)(S%=m)<0&&(S+=m),T=0;else{if(S<0){p!=e.BEFORE&&(p=e.BEFORE,i.computeWorldVertices(o,2,4,c,0,2)),this.addBeforePosition(S,c,0,u,y);continue}if(S>m){p!=e.AFTER&&(p=e.AFTER,i.computeWorldVertices(o,_-6,4,c,0,2)),this.addAfterPosition(S-m,c,0,u,y);continue}}for(;;T++){var E=g[T];if(!(S>E)){0==T?S/=E:S=(S-(q=g[T-1]))/(E-q);break}}T!=p&&(p=T,d&&T==f?(i.computeWorldVertices(o,_-4,4,c,0,2),i.computeWorldVertices(o,0,4,c,4,2)):i.computeWorldVertices(o,6*T+2,8,c,0,2)),this.addCurvePosition(S,c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],u,y,r||v>0&&0==W)}return u}d?(_+=2,c=t.Utils.setArraySize(this.world,_),i.computeWorldVertices(o,2,_-4,c,0,2),i.computeWorldVertices(o,0,2,c,_-4,2),c[_-2]=c[0],c[_-1]=c[1]):(f--,_-=4,c=t.Utils.setArraySize(this.world,_),i.computeWorldVertices(o,2,_,c,0,2));for(var A=t.Utils.setArraySize(this.curves,f),C=0,R=c[0],b=c[1],x=0,w=0,M=0,I=0,B=0,P=0,D=0,O=0,F=0,L=0,N=0,k=0,U=0,G=0,V=(v=0,2);v<f;v++,V+=6)x=c[V],w=c[V+1],M=c[V+2],I=c[V+3],N=2*(D=.1875*(R-2*x+M))+(F=.09375*(3*(x-M)-R+(B=c[V+4]))),k=2*(O=.1875*(b-2*w+I))+(L=.09375*(3*(w-I)-b+(P=c[V+5]))),U=.75*(x-R)+D+.16666667*F,G=.75*(w-b)+O+.16666667*L,C+=Math.sqrt(U*U+G*G),U+=N,G+=k,N+=F,k+=L,C+=Math.sqrt(U*U+G*G),U+=N,G+=k,C+=Math.sqrt(U*U+G*G),U+=N+F,G+=k+L,C+=Math.sqrt(U*U+G*G),A[v]=C,R=B,b=P;if(h*=s?C:C/i.lengths[f-1],a)for(v=1;v<n;v++)l[v]*=C;for(var H=this.segments,z=0,X=(v=0,y=0,T=0,0);v<n;v++,y+=3){var W;if(S=h+=W=l[v],d)(S%=C)<0&&(S+=C),T=0;else{if(S<0){this.addBeforePosition(S,c,0,u,y);continue}if(S>C){this.addAfterPosition(S-C,c,_-4,u,y);continue}}for(;;T++){var Y=A[T];if(!(S>Y)){0==T?S/=Y:S=(S-(q=A[T-1]))/(Y-q);break}}if(T!=p){p=T;var j=6*T;for(R=c[j],b=c[j+1],x=c[j+2],w=c[j+3],M=c[j+4],I=c[j+5],N=2*(D=.03*(R-2*x+M))+(F=.006*(3*(x-M)-R+(B=c[j+6]))),k=2*(O=.03*(b-2*w+I))+(L=.006*(3*(w-I)-b+(P=c[j+7]))),U=.3*(x-R)+D+.16666667*F,G=.3*(w-b)+O+.16666667*L,z=Math.sqrt(U*U+G*G),H[0]=z,j=1;j<8;j++)U+=N,G+=k,N+=F,k+=L,z+=Math.sqrt(U*U+G*G),H[j]=z;U+=N,G+=k,z+=Math.sqrt(U*U+G*G),H[8]=z,U+=N+F,G+=k+L,z+=Math.sqrt(U*U+G*G),H[9]=z,X=0}for(S*=z;;X++){var K=H[X];if(!(S>K)){var q;0==X?S/=K:S=X+(S-(q=H[X-1]))/(K-q);break}}this.addCurvePosition(.1*S,R,b,x,w,M,I,B,P,u,y,r||v>0&&0==W)}return u},e.prototype.addBeforePosition=function(t,e,i,n,r){var s=e[i],a=e[i+1],o=e[i+2]-s,h=e[i+3]-a,l=Math.atan2(h,o);n[r]=s+t*Math.cos(l),n[r+1]=a+t*Math.sin(l),n[r+2]=l},e.prototype.addAfterPosition=function(t,e,i,n,r){var s=e[i+2],a=e[i+3],o=s-e[i],h=a-e[i+1],l=Math.atan2(h,o);n[r]=s+t*Math.cos(l),n[r+1]=a+t*Math.sin(l),n[r+2]=l},e.prototype.addCurvePosition=function(t,e,i,n,r,s,a,o,h,l,u,c){if(0==t||isNaN(t))return l[u]=e,l[u+1]=i,void(l[u+2]=Math.atan2(r-i,n-e));var d=t*t,_=d*t,f=1-t,p=f*f,g=p*f,m=f*t,v=3*m,y=f*v,T=v*t,S=e*g+n*y+s*T+o*_,E=i*g+r*y+a*T+h*_;l[u]=S,l[u+1]=E,c&&(l[u+2]=t<.001?Math.atan2(r-i,n-e):Math.atan2(E-(i*p+r*m*2+a*d),S-(e*p+n*m*2+s*d)))},e.NONE=-1,e.BEFORE=-2,e.AFTER=-3,e.epsilon=1e-5,e}();t.PathConstraint=e}(XK||(XK={})),function(t){var e,i,n,r=function(t){function e(e){var i=t.call(this,e,0,!1)||this;return i.bones=new Array,i}return WK(e,t),e}(t.ConstraintData);t.PathConstraintData=r,(n=t.PositionMode||(t.PositionMode={}))[n.Fixed=0]="Fixed",n[n.Percent=1]="Percent",(i=t.SpacingMode||(t.SpacingMode={}))[i.Length=0]="Length",i[i.Fixed=1]="Fixed",i[i.Percent=2]="Percent",(e=t.RotateMode||(t.RotateMode={}))[e.Tangent=0]="Tangent",e[e.Chain=1]="Chain",e[e.ChainScale=2]="ChainScale"}(XK||(XK={})),function(t){var e=function(){function t(t){this.toLoad=new Array,this.assets={},this.clientId=t}return t.prototype.loaded=function(){var t=0;for(var e in this.assets)t++;return t},t}(),i=function(){function t(t){void 0===t&&(t=""),this.clientAssets={},this.queuedAssets={},this.rawAssets={},this.errors={},this.pathPrefix=t}return t.prototype.queueAsset=function(t,i,n){var r=this.clientAssets[t];return null==r&&(r=new e(t),this.clientAssets[t]=r),null!==i&&(r.textureLoader=i),r.toLoad.push(n),this.queuedAssets[n]!==n&&(this.queuedAssets[n]=n,!0)},t.prototype.loadText=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&(n.status>=200&&n.status<300?i.rawAssets[e]=n.responseText:i.errors[e]="Couldn't load text "+e+": status "+n.status+", "+n.responseText)},n.open("GET",e,!0),n.send()}},t.prototype.loadJson=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&(n.status>=200&&n.status<300?i.rawAssets[e]=JSON.parse(n.responseText):i.errors[e]="Couldn't load text "+e+": status "+n.status+", "+n.responseText)},n.open("GET",e,!0),n.send()}},t.prototype.loadTexture=function(t,e,i){var n=this;if(i=this.pathPrefix+i,this.queueAsset(t,e,i)){var r=new YK.Image;r.src=i,r.crossOrigin="anonymous",r.onload=function(){n.rawAssets[i]=r},r.onerror=function(){n.errors[i]="Couldn't load image "+i}}},t.prototype.get=function(t,e){e=this.pathPrefix+e;var i=this.clientAssets[t];return null==i||i.assets[e]},t.prototype.updateClientAssets=function(t){for(var e=0;e<t.toLoad.length;e++){var i=t.toLoad[e];if(null==t.assets[i]){var n=this.rawAssets[i];if(null==n)continue;n instanceof HTMLImageElement?t.assets[i]=t.textureLoader(n):t.assets[i]=n}}},t.prototype.isLoadingComplete=function(t){var e=this.clientAssets[t];return null==e||(this.updateClientAssets(e),e.toLoad.length==e.loaded())},t.prototype.dispose=function(){},t.prototype.hasErrors=function(){return Object.keys(this.errors).length>0},t.prototype.getErrors=function(){return this.errors},t}();t.SharedAssetManager=i}(XK||(XK={})),function(t){var e=function(){function e(e){if(this._updateCache=new Array,this.updateCacheReset=new Array,this.time=0,this.scaleX=1,this.scaleY=1,this.x=0,this.y=0,null==e)throw new Error("data cannot be null.");this.data=e,this.bones=new Array;for(var i=0;i<e.bones.length;i++){var n=e.bones[i],r=void 0;if(null==n.parent)r=new t.Bone(n,this,null);else{var s=this.bones[n.parent.index];r=new t.Bone(n,this,s),s.children.push(r)}this.bones.push(r)}for(this.slots=new Array,this.drawOrder=new Array,i=0;i<e.slots.length;i++){var a=e.slots[i],o=(r=this.bones[a.boneData.index],new t.Slot(a,r));this.slots.push(o),this.drawOrder.push(o)}for(this.ikConstraints=new Array,i=0;i<e.ikConstraints.length;i++){var h=e.ikConstraints[i];this.ikConstraints.push(new t.IkConstraint(h,this))}for(this.transformConstraints=new Array,i=0;i<e.transformConstraints.length;i++){var l=e.transformConstraints[i];this.transformConstraints.push(new t.TransformConstraint(l,this))}for(this.pathConstraints=new Array,i=0;i<e.pathConstraints.length;i++){var u=e.pathConstraints[i];this.pathConstraints.push(new t.PathConstraint(u,this))}this.color=new t.Color(1,1,1,1),this.updateCache()}return e.prototype.updateCache=function(){this._updateCache.length=0,this.updateCacheReset.length=0;for(var t=this.bones,e=0,i=t.length;e<i;e++)(r=t[e]).sorted=r.data.skinRequired,r.active=!r.sorted;if(null!=this.skin){var n=this.skin.bones;for(e=0,i=this.skin.bones.length;e<i;e++){var r=this.bones[n[e].index];do{r.sorted=!1,r.active=!0,r=r.parent}while(null!=r)}}var s=this.ikConstraints,a=this.transformConstraints,o=this.pathConstraints,h=s.length,l=a.length,u=o.length,c=h+l+u;t:for(e=0;e<c;e++){for(var d=0;d<h;d++)if((_=s[d]).data.order==e){this.sortIkConstraint(_);continue t}for(d=0;d<l;d++)if((_=a[d]).data.order==e){this.sortTransformConstraint(_);continue t}for(d=0;d<u;d++){var _;if((_=o[d]).data.order==e){this.sortPathConstraint(_);continue t}}}for(e=0,i=t.length;e<i;e++)this.sortBone(t[e])},e.prototype.sortIkConstraint=function(e){if(e.active=e.target.isActive()&&(!e.data.skinRequired||null!=this.skin&&t.Utils.contains(this.skin.constraints,e.data,!0)),e.active){var i=e.target;this.sortBone(i);var n=e.bones,r=n[0];if(this.sortBone(r),n.length>1){var s=n[n.length-1];this._updateCache.indexOf(s)>-1||this.updateCacheReset.push(s)}this._updateCache.push(e),this.sortReset(r.children),n[n.length-1].sorted=!0}},e.prototype.sortPathConstraint=function(e){if(e.active=e.target.bone.isActive()&&(!e.data.skinRequired||null!=this.skin&&t.Utils.contains(this.skin.constraints,e.data,!0)),e.active){var i=e.target,n=i.data.index,r=i.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,n,r),null!=this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,n,r);for(var s=0,a=this.data.skins.length;s<a;s++)this.sortPathConstraintAttachment(this.data.skins[s],n,r);var o=i.getAttachment();o instanceof t.PathAttachment&&this.sortPathConstraintAttachmentWith(o,r);var h=e.bones,l=h.length;for(s=0;s<l;s++)this.sortBone(h[s]);for(this._updateCache.push(e),s=0;s<l;s++)this.sortReset(h[s].children);for(s=0;s<l;s++)h[s].sorted=!0}},e.prototype.sortTransformConstraint=function(e){if(e.active=e.target.isActive()&&(!e.data.skinRequired||null!=this.skin&&t.Utils.contains(this.skin.constraints,e.data,!0)),e.active){this.sortBone(e.target);var i=e.bones,n=i.length;if(e.data.local)for(var r=0;r<n;r++){var s=i[r];this.sortBone(s.parent),this._updateCache.indexOf(s)>-1||this.updateCacheReset.push(s)}else for(r=0;r<n;r++)this.sortBone(i[r]);this._updateCache.push(e);for(var a=0;a<n;a++)this.sortReset(i[a].children);for(a=0;a<n;a++)i[a].sorted=!0}},e.prototype.sortPathConstraintAttachment=function(t,e,i){var n=t.attachments[e];if(n)for(var r in n)this.sortPathConstraintAttachmentWith(n[r],i)},e.prototype.sortPathConstraintAttachmentWith=function(e,i){if(e instanceof t.PathAttachment){var n=e.bones;if(null==n)this.sortBone(i);else for(var r=this.bones,s=0;s<n.length;)for(var a=n[s++],o=s+a;s<o;s++){var h=n[s];this.sortBone(r[h])}}},e.prototype.sortBone=function(t){if(!t.sorted){var e=t.parent;null!=e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}},e.prototype.sortReset=function(t){for(var e=0,i=t.length;e<i;e++){var n=t[e];n.active&&(n.sorted&&this.sortReset(n.children),n.sorted=!1)}},e.prototype.updateWorldTransform=function(){for(var t=this.updateCacheReset,e=0,i=t.length;e<i;e++){var n=t[e];n.ax=n.x,n.ay=n.y,n.arotation=n.rotation,n.ascaleX=n.scaleX,n.ascaleY=n.scaleY,n.ashearX=n.shearX,n.ashearY=n.shearY,n.appliedValid=!0}var r=this._updateCache;for(e=0,i=r.length;e<i;e++)r[e].update()},e.prototype.setToSetupPose=function(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()},e.prototype.setBonesToSetupPose=function(){for(var t=this.bones,e=0,i=t.length;e<i;e++)t[e].setToSetupPose();var n=this.ikConstraints;for(e=0,i=n.length;e<i;e++)(o=n[e]).mix=o.data.mix,o.softness=o.data.softness,o.bendDirection=o.data.bendDirection,o.compress=o.data.compress,o.stretch=o.data.stretch;var r=this.transformConstraints;for(e=0,i=r.length;e<i;e++){var s=(o=r[e]).data;o.rotateMix=s.rotateMix,o.translateMix=s.translateMix,o.scaleMix=s.scaleMix,o.shearMix=s.shearMix}var a=this.pathConstraints;for(e=0,i=a.length;e<i;e++){var o;s=(o=a[e]).data,o.position=s.position,o.spacing=s.spacing,o.rotateMix=s.rotateMix,o.translateMix=s.translateMix}},e.prototype.setSlotsToSetupPose=function(){var e=this.slots;t.Utils.arrayCopy(e,0,this.drawOrder,0,e.length);for(var i=0,n=e.length;i<n;i++)e[i].setToSetupPose()},e.prototype.getRootBone=function(){return 0==this.bones.length?null:this.bones[0]},e.prototype.findBone=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.findBoneIndex=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i<n;i++)if(e[i].data.name==t)return i;return-1},e.prototype.findSlot=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.findSlotIndex=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,n=e.length;i<n;i++)if(e[i].data.name==t)return i;return-1},e.prototype.setSkinByName=function(t){var e=this.data.findSkin(t);if(null==e)throw new Error("Skin not found: "+t);this.setSkin(e)},e.prototype.setSkin=function(t){if(t!=this.skin){if(null!=t)if(null!=this.skin)t.attachAll(this,this.skin);else for(var e=this.slots,i=0,n=e.length;i<n;i++){var r=e[i],s=r.data.attachmentName;if(null!=s){var a=t.getAttachment(i,s);null!=a&&r.setAttachment(a)}}this.skin=t,this.updateCache()}},e.prototype.getAttachmentByName=function(t,e){return this.getAttachment(this.data.findSlotIndex(t),e)},e.prototype.getAttachment=function(t,e){if(null==e)throw new Error("attachmentName cannot be null.");if(null!=this.skin){var i=this.skin.getAttachment(t,e);if(null!=i)return i}return null!=this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null},e.prototype.setAttachment=function(t,e){if(null==t)throw new Error("slotName cannot be null.");for(var i=this.slots,n=0,r=i.length;n<r;n++){var s=i[n];if(s.data.name==t){var a=null;if(null!=e&&null==(a=this.getAttachment(n,e)))throw new Error("Attachment not found: "+e+", for slot: "+t);return void s.setAttachment(a)}}throw new Error("Slot not found: "+t)},e.prototype.findIkConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.ikConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.findTransformConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.transformConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.findPathConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.pathConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.getBounds=function(e,i,n){if(void 0===n&&(n=new Array(2)),null==e)throw new Error("offset cannot be null.");if(null==i)throw new Error("size cannot be null.");for(var r=this.drawOrder,s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY,l=0,u=r.length;l<u;l++){var c=r[l];if(c.bone.active){var d=0,_=null,f=c.getAttachment();if(f instanceof t.RegionAttachment)d=8,_=t.Utils.setArraySize(n,d,0),f.computeWorldVertices(c.bone,_,0,2);else if(f instanceof t.MeshAttachment){var p=f;d=p.worldVerticesLength,_=t.Utils.setArraySize(n,d,0),p.computeWorldVertices(c,0,d,_,0,2)}if(null!=_)for(var g=0,m=_.length;g<m;g+=2){var v=_[g],y=_[g+1];s=Math.min(s,v),a=Math.min(a,y),o=Math.max(o,v),h=Math.max(h,y)}}}e.set(s,a),i.set(o-s,h-a)},e.prototype.update=function(t){this.time+=t},e}();t.Skeleton=e}(XK||(XK={})),function(t){var e=function(){function e(t){this.scale=1,this.linkedMeshes=new Array,this.attachmentLoader=t}return e.prototype.readSkeletonData=function(n){var r=this.scale,s=new t.SkeletonData;s.name="";var a=new i(n);s.hash=a.readString(),s.version=a.readString(),s.x=a.readFloat(),s.y=a.readFloat(),s.width=a.readFloat(),s.height=a.readFloat();var o=a.readBoolean();o&&(s.fps=a.readFloat(),s.imagesPath=a.readString(),s.audioPath=a.readString());var h=0;h=a.readInt(!0);for(var l=0;l<h;l++)a.strings.push(a.readString());for(h=a.readInt(!0),l=0;l<h;l++){var u=a.readString(),c=0==l?null:s.bones[a.readInt(!0)];(f=new t.BoneData(l,u,c)).rotation=a.readFloat(),f.x=a.readFloat()*r,f.y=a.readFloat()*r,f.scaleX=a.readFloat(),f.scaleY=a.readFloat(),f.shearX=a.readFloat(),f.shearY=a.readFloat(),f.length=a.readFloat()*r,f.transformMode=e.TransformModeValues[a.readInt(!0)],f.skinRequired=a.readBoolean(),o&&t.Color.rgba8888ToColor(f.color,a.readInt32()),s.bones.push(f)}for(h=a.readInt(!0),l=0;l<h;l++){var d=a.readString(),_=s.bones[a.readInt(!0)],f=new t.SlotData(l,d,_);t.Color.rgba8888ToColor(f.color,a.readInt32());var p=a.readInt32();-1!=p&&t.Color.rgb888ToColor(f.darkColor=new t.Color,p),f.attachmentName=a.readStringRef(),f.blendMode=e.BlendModeValues[a.readInt(!0)],s.slots.push(f)}h=a.readInt(!0),l=0;for(var g=void 0;l<h;l++){(f=new t.IkConstraintData(a.readString())).order=a.readInt(!0),f.skinRequired=a.readBoolean(),g=a.readInt(!0);for(var m=0;m<g;m++)f.bones.push(s.bones[a.readInt(!0)]);f.target=s.bones[a.readInt(!0)],f.mix=a.readFloat(),f.softness=a.readFloat()*r,f.bendDirection=a.readByte(),f.compress=a.readBoolean(),f.stretch=a.readBoolean(),f.uniform=a.readBoolean(),s.ikConstraints.push(f)}for(h=a.readInt(!0),l=0,g=void 0;l<h;l++){for((f=new t.TransformConstraintData(a.readString())).order=a.readInt(!0),f.skinRequired=a.readBoolean(),g=a.readInt(!0),m=0;m<g;m++)f.bones.push(s.bones[a.readInt(!0)]);f.target=s.bones[a.readInt(!0)],f.local=a.readBoolean(),f.relative=a.readBoolean(),f.offsetRotation=a.readFloat(),f.offsetX=a.readFloat()*r,f.offsetY=a.readFloat()*r,f.offsetScaleX=a.readFloat(),f.offsetScaleY=a.readFloat(),f.offsetShearY=a.readFloat(),f.rotateMix=a.readFloat(),f.translateMix=a.readFloat(),f.scaleMix=a.readFloat(),f.shearMix=a.readFloat(),s.transformConstraints.push(f)}for(h=a.readInt(!0),l=0,g=void 0;l<h;l++){for((f=new t.PathConstraintData(a.readString())).order=a.readInt(!0),f.skinRequired=a.readBoolean(),g=a.readInt(!0),m=0;m<g;m++)f.bones.push(s.bones[a.readInt(!0)]);f.target=s.slots[a.readInt(!0)],f.positionMode=e.PositionModeValues[a.readInt(!0)],f.spacingMode=e.SpacingModeValues[a.readInt(!0)],f.rotateMode=e.RotateModeValues[a.readInt(!0)],f.offsetRotation=a.readFloat(),f.position=a.readFloat(),f.positionMode==t.PositionMode.Fixed&&(f.position*=r),f.spacing=a.readFloat(),f.spacingMode!=t.SpacingMode.Length&&f.spacingMode!=t.SpacingMode.Fixed||(f.spacing*=r),f.rotateMix=a.readFloat(),f.translateMix=a.readFloat(),s.pathConstraints.push(f)}var v=this.readSkin(a,s,!0,o);for(null!=v&&(s.defaultSkin=v,s.skins.push(v)),l=s.skins.length,t.Utils.setArraySize(s.skins,h=l+a.readInt(!0));l<h;l++)s.skins[l]=this.readSkin(a,s,!1,o);for(h=this.linkedMeshes.length,l=0;l<h;l++){var y=this.linkedMeshes[l],T=null==y.skin?s.defaultSkin:s.findSkin(y.skin);if(null==T)throw new Error("Skin not found: "+y.skin);var S=T.getAttachment(y.slotIndex,y.parent);if(null==S)throw new Error("Parent mesh not found: "+y.parent);y.mesh.deformAttachment=y.inheritDeform?S:y.mesh,y.mesh.setParentMesh(S),y.mesh.updateUVs()}for(this.linkedMeshes.length=0,h=a.readInt(!0),l=0;l<h;l++)(f=new t.EventData(a.readStringRef())).intValue=a.readInt(!1),f.floatValue=a.readFloat(),f.stringValue=a.readString(),f.audioPath=a.readString(),null!=f.audioPath&&(f.volume=a.readFloat(),f.balance=a.readFloat()),s.events.push(f);for(h=a.readInt(!0),l=0;l<h;l++)s.animations.push(this.readAnimation(a,a.readString(),s));return s},e.prototype.readSkin=function(e,i,n,r){var s=null,a=0;if(n){if(0==(a=e.readInt(!0)))return null;s=new t.Skin("default")}else{(s=new t.Skin(e.readStringRef())).bones.length=e.readInt(!0);for(var o=0,h=s.bones.length;o<h;o++)s.bones[o]=i.bones[e.readInt(!0)];for(o=0,h=e.readInt(!0);o<h;o++)s.constraints.push(i.ikConstraints[e.readInt(!0)]);for(o=0,h=e.readInt(!0);o<h;o++)s.constraints.push(i.transformConstraints[e.readInt(!0)]);for(o=0,h=e.readInt(!0);o<h;o++)s.constraints.push(i.pathConstraints[e.readInt(!0)]);a=e.readInt(!0)}for(o=0;o<a;o++)for(var l=e.readInt(!0),u=0,c=e.readInt(!0);u<c;u++){var d=e.readStringRef(),_=this.readAttachment(e,i,s,l,d,r);null!=_&&s.setAttachment(l,d,_)}return s},e.prototype.readAttachment=function(i,r,s,a,o,h){var l=this.scale,u=i.readStringRef();null==u&&(u=o);var c=i.readByte();switch(e.AttachmentTypeValues[c]){case t.AttachmentType.Region:var d=i.readStringRef(),_=i.readFloat(),f=i.readFloat(),p=i.readFloat(),g=i.readFloat(),m=i.readFloat(),v=i.readFloat(),y=i.readFloat(),T=i.readInt32();null==d&&(d=u);var S=this.attachmentLoader.newRegionAttachment(s,u,d);return null==S?null:(S.path=d,S.x=f*l,S.y=p*l,S.scaleX=g,S.scaleY=m,S.rotation=_,S.width=v*l,S.height=y*l,t.Color.rgba8888ToColor(S.color,T),S.updateOffset(),S);case t.AttachmentType.BoundingBox:var E=i.readInt(!0),A=this.readVertices(i,E),C=(T=h?i.readInt32():0,this.attachmentLoader.newBoundingBoxAttachment(s,u));return null==C?null:(C.worldVerticesLength=E<<1,C.vertices=A.vertices,C.bones=A.bones,h&&t.Color.rgba8888ToColor(C.color,T),C);case t.AttachmentType.Mesh:d=i.readStringRef(),T=i.readInt32(),E=i.readInt(!0);var R=this.readFloatArray(i,E<<1,1),b=this.readShortArray(i),x=(A=this.readVertices(i,E),i.readInt(!0)),w=null;return v=0,y=0,h&&(w=this.readShortArray(i),v=i.readFloat(),y=i.readFloat()),null==d&&(d=u),null==(M=this.attachmentLoader.newMeshAttachment(s,u,d))?null:(M.path=d,t.Color.rgba8888ToColor(M.color,T),M.bones=A.bones,M.vertices=A.vertices,M.worldVerticesLength=E<<1,M.triangles=b,M.regionUVs=R,M.updateUVs(),M.hullLength=x<<1,h&&(M.edges=w,M.width=v*l,M.height=y*l),M);case t.AttachmentType.LinkedMesh:d=i.readStringRef(),T=i.readInt32();var M,I=i.readStringRef(),B=i.readStringRef(),P=i.readBoolean();return v=0,y=0,h&&(v=i.readFloat(),y=i.readFloat()),null==d&&(d=u),null==(M=this.attachmentLoader.newMeshAttachment(s,u,d))?null:(M.path=d,t.Color.rgba8888ToColor(M.color,T),h&&(M.width=v*l,M.height=y*l),this.linkedMeshes.push(new n(M,I,a,B,P)),M);case t.AttachmentType.Path:for(var D=i.readBoolean(),O=i.readBoolean(),F=(E=i.readInt(!0),A=this.readVertices(i,E),t.Utils.newArray(E/3,0)),L=0,N=F.length;L<N;L++)F[L]=i.readFloat()*l;return T=h?i.readInt32():0,null==(d=this.attachmentLoader.newPathAttachment(s,u))?null:(d.closed=D,d.constantSpeed=O,d.worldVerticesLength=E<<1,d.vertices=A.vertices,d.bones=A.bones,d.lengths=F,h&&t.Color.rgba8888ToColor(d.color,T),d);case t.AttachmentType.Point:_=i.readFloat(),f=i.readFloat(),p=i.readFloat(),T=h?i.readInt32():0;var k=this.attachmentLoader.newPointAttachment(s,u);return null==k?null:(k.x=f*l,k.y=p*l,k.rotation=_,h&&t.Color.rgba8888ToColor(k.color,T),k);case t.AttachmentType.Clipping:var U=i.readInt(!0),G=(E=i.readInt(!0),A=this.readVertices(i,E),T=h?i.readInt32():0,this.attachmentLoader.newClippingAttachment(s,u));return null==G?null:(G.endSlot=r.slots[U],G.worldVerticesLength=E<<1,G.vertices=A.vertices,G.bones=A.bones,h&&t.Color.rgba8888ToColor(G.color,T),G)}return null},e.prototype.readVertices=function(e,i){var n=i<<1,s=new r,a=this.scale;if(!e.readBoolean())return s.vertices=this.readFloatArray(e,n,a),s;for(var o=new Array,h=new Array,l=0;l<i;l++){var u=e.readInt(!0);h.push(u);for(var c=0;c<u;c++)h.push(e.readInt(!0)),o.push(e.readFloat()*a),o.push(e.readFloat()*a),o.push(e.readFloat())}return s.vertices=t.Utils.toFloatArray(o),s.bones=h,s},e.prototype.readFloatArray=function(t,e,i){var n=new Array(e);if(1==i)for(var r=0;r<e;r++)n[r]=t.readFloat();else for(r=0;r<e;r++)n[r]=t.readFloat()*i;return n},e.prototype.readShortArray=function(t){for(var e=t.readInt(!0),i=new Array(e),n=0;n<e;n++)i[n]=t.readShort();return i},e.prototype.readAnimation=function(i,n,r){for(var s=new Array,a=this.scale,o=0,h=new t.Color,l=new t.Color,u=0,c=i.readInt(!0);u<c;u++)for(var d=i.readInt(!0),_=0,f=i.readInt(!0);_<f;_++){var p=i.readByte(),g=i.readInt(!0);switch(p){case e.SLOT_ATTACHMENT:(T=new t.AttachmentTimeline(g)).slotIndex=d;for(var m=0;m<g;m++)T.setFrame(m,i.readFloat(),i.readStringRef());s.push(T),o=Math.max(o,T.frames[g-1]);break;case e.SLOT_COLOR:for((T=new t.ColorTimeline(g)).slotIndex=d,m=0;m<g;m++){var v=i.readFloat();t.Color.rgba8888ToColor(h,i.readInt32()),T.setFrame(m,v,h.r,h.g,h.b,h.a),m<g-1&&this.readCurve(i,m,T)}s.push(T),o=Math.max(o,T.frames[(g-1)*t.ColorTimeline.ENTRIES]);break;case e.SLOT_TWO_COLOR:for((T=new t.TwoColorTimeline(g)).slotIndex=d,m=0;m<g;m++)v=i.readFloat(),t.Color.rgba8888ToColor(h,i.readInt32()),t.Color.rgb888ToColor(l,i.readInt32()),T.setFrame(m,v,h.r,h.g,h.b,h.a,l.r,l.g,l.b),m<g-1&&this.readCurve(i,m,T);s.push(T),o=Math.max(o,T.frames[(g-1)*t.TwoColorTimeline.ENTRIES])}}for(u=0,c=i.readInt(!0);u<c;u++){var y=i.readInt(!0);for(_=0,f=i.readInt(!0);_<f;_++)switch(p=i.readByte(),g=i.readInt(!0),p){case e.BONE_ROTATE:for((T=new t.RotateTimeline(g)).boneIndex=y,m=0;m<g;m++)T.setFrame(m,i.readFloat(),i.readFloat()),m<g-1&&this.readCurve(i,m,T);s.push(T),o=Math.max(o,T.frames[(g-1)*t.RotateTimeline.ENTRIES]);break;case e.BONE_TRANSLATE:case e.BONE_SCALE:case e.BONE_SHEAR:var T=void 0,S=1;for(p==e.BONE_SCALE?T=new t.ScaleTimeline(g):p==e.BONE_SHEAR?T=new t.ShearTimeline(g):(T=new t.TranslateTimeline(g),S=a),T.boneIndex=y,m=0;m<g;m++)T.setFrame(m,i.readFloat(),i.readFloat()*S,i.readFloat()*S),m<g-1&&this.readCurve(i,m,T);s.push(T),o=Math.max(o,T.frames[(g-1)*t.TranslateTimeline.ENTRIES])}}for(u=0,c=i.readInt(!0);u<c;u++){var E=i.readInt(!0);for(g=i.readInt(!0),(T=new t.IkConstraintTimeline(g)).ikConstraintIndex=E,m=0;m<g;m++)T.setFrame(m,i.readFloat(),i.readFloat(),i.readFloat()*a,i.readByte(),i.readBoolean(),i.readBoolean()),m<g-1&&this.readCurve(i,m,T);s.push(T),o=Math.max(o,T.frames[(g-1)*t.IkConstraintTimeline.ENTRIES])}for(u=0,c=i.readInt(!0);u<c;u++){for(E=i.readInt(!0),g=i.readInt(!0),(T=new t.TransformConstraintTimeline(g)).transformConstraintIndex=E,m=0;m<g;m++)T.setFrame(m,i.readFloat(),i.readFloat(),i.readFloat(),i.readFloat(),i.readFloat()),m<g-1&&this.readCurve(i,m,T);s.push(T),o=Math.max(o,T.frames[(g-1)*t.TransformConstraintTimeline.ENTRIES])}for(u=0,c=i.readInt(!0);u<c;u++){E=i.readInt(!0);var A=r.pathConstraints[E];for(_=0,f=i.readInt(!0);_<f;_++)switch(p=i.readByte(),g=i.readInt(!0),p){case e.PATH_POSITION:case e.PATH_SPACING:for(T=void 0,S=1,p==e.PATH_SPACING?(T=new t.PathConstraintSpacingTimeline(g),A.spacingMode!=t.SpacingMode.Length&&A.spacingMode!=t.SpacingMode.Fixed||(S=a)):(T=new t.PathConstraintPositionTimeline(g),A.positionMode==t.PositionMode.Fixed&&(S=a)),T.pathConstraintIndex=E,m=0;m<g;m++)T.setFrame(m,i.readFloat(),i.readFloat()*S),m<g-1&&this.readCurve(i,m,T);s.push(T),o=Math.max(o,T.frames[(g-1)*t.PathConstraintPositionTimeline.ENTRIES]);break;case e.PATH_MIX:for((T=new t.PathConstraintMixTimeline(g)).pathConstraintIndex=E,m=0;m<g;m++)T.setFrame(m,i.readFloat(),i.readFloat(),i.readFloat()),m<g-1&&this.readCurve(i,m,T);s.push(T),o=Math.max(o,T.frames[(g-1)*t.PathConstraintMixTimeline.ENTRIES])}}for(u=0,c=i.readInt(!0);u<c;u++){var C=r.skins[i.readInt(!0)];for(_=0,f=i.readInt(!0);_<f;_++){d=i.readInt(!0);for(var R=0,b=i.readInt(!0);R<b;R++){var x=C.getAttachment(d,i.readStringRef()),w=null!=x.bones,M=x.vertices,I=w?M.length/3*2:M.length;for(g=i.readInt(!0),(T=new t.DeformTimeline(g)).slotIndex=d,T.attachment=x,m=0;m<g;m++){v=i.readFloat();var B=void 0,P=i.readInt(!0);if(0==P)B=w?t.Utils.newFloatArray(I):M;else{B=t.Utils.newFloatArray(I);var D=i.readInt(!0);if(P+=D,1==a)for(var O=D;O<P;O++)B[O]=i.readFloat();else for(O=D;O<P;O++)B[O]=i.readFloat()*a;if(!w){O=0;for(var F=B.length;O<F;O++)B[O]+=M[O]}}T.setFrame(m,v,B),m<g-1&&this.readCurve(i,m,T)}s.push(T),o=Math.max(o,T.frames[g-1])}}}var L=i.readInt(!0);if(L>0){T=new t.DrawOrderTimeline(L);var N=r.slots.length;for(u=0;u<L;u++){v=i.readFloat();var k=i.readInt(!0),U=t.Utils.newArray(N,0);for(_=N-1;_>=0;_--)U[_]=-1;var G=t.Utils.newArray(N-k,0),V=0,H=0;for(_=0;_<k;_++){for(d=i.readInt(!0);V!=d;)G[H++]=V++;U[V+i.readInt(!0)]=V++}for(;V<N;)G[H++]=V++;for(_=N-1;_>=0;_--)-1==U[_]&&(U[_]=G[--H]);T.setFrame(u,v,U)}s.push(T),o=Math.max(o,T.frames[L-1])}var z=i.readInt(!0);if(z>0){for(T=new t.EventTimeline(z),u=0;u<z;u++){v=i.readFloat();var X=r.events[i.readInt(!0)],W=new t.Event(v,X);W.intValue=i.readInt(!1),W.floatValue=i.readFloat(),W.stringValue=i.readBoolean()?i.readString():X.stringValue,null!=W.data.audioPath&&(W.volume=i.readFloat(),W.balance=i.readFloat()),T.setFrame(u,W)}s.push(T),o=Math.max(o,T.frames[z-1])}return new t.Animation(n,s,o)},e.prototype.readCurve=function(t,i,n){switch(t.readByte()){case e.CURVE_STEPPED:n.setStepped(i);break;case e.CURVE_BEZIER:this.setCurve(n,i,t.readFloat(),t.readFloat(),t.readFloat(),t.readFloat())}},e.prototype.setCurve=function(t,e,i,n,r,s){t.setCurve(e,i,n,r,s)},e.AttachmentTypeValues=[0,1,2,3,4,5,6],e.TransformModeValues=[t.TransformMode.Normal,t.TransformMode.OnlyTranslation,t.TransformMode.NoRotationOrReflection,t.TransformMode.NoScale,t.TransformMode.NoScaleOrReflection],e.PositionModeValues=[t.PositionMode.Fixed,t.PositionMode.Percent],e.SpacingModeValues=[t.SpacingMode.Length,t.SpacingMode.Fixed,t.SpacingMode.Percent],e.RotateModeValues=[t.RotateMode.Tangent,t.RotateMode.Chain,t.RotateMode.ChainScale],e.BlendModeValues=[t.BlendMode.Normal,t.BlendMode.Additive,t.BlendMode.Multiply,t.BlendMode.Screen],e.BONE_ROTATE=0,e.BONE_TRANSLATE=1,e.BONE_SCALE=2,e.BONE_SHEAR=3,e.SLOT_ATTACHMENT=0,e.SLOT_COLOR=1,e.SLOT_TWO_COLOR=2,e.PATH_POSITION=0,e.PATH_SPACING=1,e.PATH_MIX=2,e.CURVE_LINEAR=0,e.CURVE_STEPPED=1,e.CURVE_BEZIER=2,e}();t.SkeletonBinary=e;var i=function(){function t(t,e,i,n){void 0===e&&(e=new Array),void 0===i&&(i=0),void 0===n&&(n=new DataView(t.buffer)),this.strings=e,this.index=i,this.buffer=n}return t.prototype.readByte=function(){return this.buffer.getInt8(this.index++)},t.prototype.readShort=function(){var t=this.buffer.getInt16(this.index);return this.index+=2,t},t.prototype.readInt32=function(){var t=this.buffer.getInt32(this.index);return this.index+=4,t},t.prototype.readInt=function(t){var e=this.readByte(),i=127&e;return 0!=(128&e)&&(i|=(127&(e=this.readByte()))<<7,0!=(128&e)&&(i|=(127&(e=this.readByte()))<<14,0!=(128&e)&&(i|=(127&(e=this.readByte()))<<21,0!=(128&e)&&(i|=(127&(e=this.readByte()))<<28)))),t?i:i>>>1^-(1&i)},t.prototype.readStringRef=function(){var t=this.readInt(!0);return 0==t?null:this.strings[t-1]},t.prototype.readString=function(){var t=this.readInt(!0);switch(t){case 0:return null;case 1:return""}t--;for(var e="",i=0;i<t;){var n=this.readByte();switch(n>>4){case 12:case 13:e+=String.fromCharCode((31&n)<<6|63&this.readByte()),i+=2;break;case 14:e+=String.fromCharCode((15&n)<<12|(63&this.readByte())<<6|63&this.readByte()),i+=3;break;default:e+=String.fromCharCode(n),i++}}return e},t.prototype.readFloat=function(){var t=this.buffer.getFloat32(this.index);return this.index+=4,t},t.prototype.readBoolean=function(){return 0!=this.readByte()},t}(),n=function(t,e,i,n,r){this.mesh=t,this.skin=e,this.slotIndex=i,this.parent=n,this.inheritDeform=r},r=function(t,e){void 0===t&&(t=null),void 0===e&&(e=null),this.bones=t,this.vertices=e}}(XK||(XK={})),function(t){var e=function(){function e(){this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.boundingBoxes=new Array,this.polygons=new Array,this.polygonPool=new t.Pool((function(){return t.Utils.newFloatArray(16)}))}return e.prototype.update=function(e,i){if(null==e)throw new Error("skeleton cannot be null.");var n=this.boundingBoxes,r=this.polygons,s=this.polygonPool,a=e.slots,o=a.length;n.length=0,s.freeAll(r),r.length=0;for(var h=0;h<o;h++){var l=a[h];if(l.bone.active){var u=l.getAttachment();if(u instanceof t.BoundingBoxAttachment){var c=u;n.push(c);var d=s.obtain();d.length!=c.worldVerticesLength&&(d=t.Utils.newFloatArray(c.worldVerticesLength)),r.push(d),c.computeWorldVertices(l,0,c.worldVerticesLength,d,0,2)}}}i?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)},e.prototype.aabbCompute=function(){for(var t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,r=this.polygons,s=0,a=r.length;s<a;s++)for(var o=r[s],h=o,l=0,u=o.length;l<u;l+=2){var c=h[l],d=h[l+1];t=Math.min(t,c),e=Math.min(e,d),i=Math.max(i,c),n=Math.max(n,d)}this.minX=t,this.minY=e,this.maxX=i,this.maxY=n},e.prototype.aabbContainsPoint=function(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY},e.prototype.aabbIntersectsSegment=function(t,e,i,n){var r=this.minX,s=this.minY,a=this.maxX,o=this.maxY;if(t<=r&&i<=r||e<=s&&n<=s||t>=a&&i>=a||e>=o&&n>=o)return!1;var h=(n-e)/(i-t),l=h*(r-t)+e;if(l>s&&l<o)return!0;if((l=h*(a-t)+e)>s&&l<o)return!0;var u=(s-e)/h+t;return u>r&&u<a||(u=(o-e)/h+t)>r&&u<a},e.prototype.aabbIntersectsSkeleton=function(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY},e.prototype.containsPoint=function(t,e){for(var i=this.polygons,n=0,r=i.length;n<r;n++)if(this.containsPointPolygon(i[n],t,e))return this.boundingBoxes[n];return null},e.prototype.containsPointPolygon=function(t,e,i){for(var n=t,r=t.length,s=r-2,a=!1,o=0;o<r;o+=2){var h=n[o+1],l=n[s+1];if(h<i&&l>=i||l<i&&h>=i){var u=n[o];u+(i-h)/(l-h)*(n[s]-u)<e&&(a=!a)}s=o}return a},e.prototype.intersectsSegment=function(t,e,i,n){for(var r=this.polygons,s=0,a=r.length;s<a;s++)if(this.intersectsSegmentPolygon(r[s],t,e,i,n))return this.boundingBoxes[s];return null},e.prototype.intersectsSegmentPolygon=function(t,e,i,n,r){for(var s=t,a=t.length,o=e-n,h=i-r,l=e*r-i*n,u=s[a-2],c=s[a-1],d=0;d<a;d+=2){var _=s[d],f=s[d+1],p=u*f-c*_,g=u-_,m=c-f,v=o*m-h*g,y=(l*g-o*p)/v;if((y>=u&&y<=_||y>=_&&y<=u)&&(y>=e&&y<=n||y>=n&&y<=e)){var T=(l*m-h*p)/v;if((T>=c&&T<=f||T>=f&&T<=c)&&(T>=i&&T<=r||T>=r&&T<=i))return!0}u=_,c=f}return!1},e.prototype.getPolygon=function(t){if(null==t)throw new Error("boundingBox cannot be null.");var e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]},e.prototype.getWidth=function(){return this.maxX-this.minX},e.prototype.getHeight=function(){return this.maxY-this.minY},e}();t.SkeletonBounds=e}(XK||(XK={})),function(t){var e=function(){function e(){this.triangulator=new t.Triangulator,this.clippingPolygon=new Array,this.clipOutput=new Array,this.clippedVertices=new Array,this.clippedTriangles=new Array,this.scratch=new Array}return e.prototype.clipStart=function(i,n){if(null!=this.clipAttachment)return 0;this.clipAttachment=n;var r=n.worldVerticesLength,s=t.Utils.setArraySize(this.clippingPolygon,r);n.computeWorldVertices(i,0,r,s,0,2);var a=this.clippingPolygon;e.makeClockwise(a);for(var o=this.clippingPolygons=this.triangulator.decompose(a,this.triangulator.triangulate(a)),h=0,l=o.length;h<l;h++){var u=o[h];e.makeClockwise(u),u.push(u[0]),u.push(u[1])}return o.length},e.prototype.clipEndWithSlot=function(t){null!=this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()},e.prototype.clipEnd=function(){null!=this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)},e.prototype.isClipping=function(){return null!=this.clipAttachment},e.prototype.clipTriangles=function(e,i,n,r,s,a,o,h,l,u,c){void 0===l&&(l=2),void 0===u&&(u=0),void 0===c&&(c=0);var d=this.clipOutput,_=this.clippedVertices,f=this.clippedTriangles,p=this.clippingPolygons,g=this.clippingPolygons.length,m=h?12:8,v=0;_.length=0,f.length=0;t:for(var y=0;y<r;y+=3)for(var T=n[y]*l,S=e[T+u],E=e[T+u+1],A=s[T+c],C=s[T+c+1],R=e[(T=n[y+1]*l)+u],b=e[T+u+1],x=s[T+c],w=s[T+c+1],M=e[(T=n[y+2]*l)+u],I=e[T+u+1],B=s[T+c],P=s[T+c+1],D=0;D<g;D++){var O=_.length;if(!this.clip(S,E,R,b,M,I,p[D],d)){(z=t.Utils.setArraySize(_,O+3*m))[O]=S,z[O+1]=E,z[O+2]=a.r,z[O+3]=a.g,z[O+4]=a.b,z[O+5]=a.a,h?(z[O+6]=A,z[O+7]=C,z[O+8]=o.r,z[O+9]=o.g,z[O+10]=o.b,z[O+11]=o.a,z[O+12]=R,z[O+13]=b,z[O+14]=a.r,z[O+15]=a.g,z[O+16]=a.b,z[O+17]=a.a,z[O+18]=x,z[O+19]=w,z[O+20]=o.r,z[O+21]=o.g,z[O+22]=o.b,z[O+23]=o.a,z[O+24]=M,z[O+25]=I,z[O+26]=a.r,z[O+27]=a.g,z[O+28]=a.b,z[O+29]=a.a,z[O+30]=B,z[O+31]=P,z[O+32]=o.r,z[O+33]=o.g,z[O+34]=o.b,z[O+35]=o.a):(z[O+6]=A,z[O+7]=C,z[O+8]=R,z[O+9]=b,z[O+10]=a.r,z[O+11]=a.g,z[O+12]=a.b,z[O+13]=a.a,z[O+14]=x,z[O+15]=w,z[O+16]=M,z[O+17]=I,z[O+18]=a.r,z[O+19]=a.g,z[O+20]=a.b,z[O+21]=a.a,z[O+22]=B,z[O+23]=P),O=f.length,(J=t.Utils.setArraySize(f,O+3))[O]=v,J[O+1]=v+1,J[O+2]=v+2,v+=3;continue t}var F=d.length;if(0!=F){for(var L=b-I,N=M-R,k=S-M,U=I-E,G=1/(L*k+N*(E-I)),V=F>>1,H=this.clipOutput,z=t.Utils.setArraySize(_,O+V*m),X=0;X<F;X+=2){var W=H[X],Y=H[X+1];z[O]=W,z[O+1]=Y,z[O+2]=a.r,z[O+3]=a.g,z[O+4]=a.b,z[O+5]=a.a;var j=W-M,K=Y-I,q=(L*j+N*K)*G,Z=(U*j+k*K)*G,Q=1-q-Z;z[O+6]=A*q+x*Z+B*Q,z[O+7]=C*q+w*Z+P*Q,h&&(z[O+8]=o.r,z[O+9]=o.g,z[O+10]=o.b,z[O+11]=o.a),O+=m}O=f.length;var J=t.Utils.setArraySize(f,O+3*(V-2));for(V--,X=1;X<V;X++)J[O]=v,J[O+1]=v+X,J[O+2]=v+X+1,O+=3;v+=V+1}}},e.prototype.clip=function(t,e,i,n,r,s,a,o){var h=o,l=!1,u=null;a.length%4>=2?(u=o,o=this.scratch):u=this.scratch,u.length=0,u.push(t),u.push(e),u.push(i),u.push(n),u.push(r),u.push(s),u.push(t),u.push(e),o.length=0;for(var c=a,d=a.length-4,_=0;;_+=2){for(var f=c[_],p=c[_+1],g=c[_+2],m=c[_+3],v=f-g,y=p-m,T=u,S=u.length-2,E=o.length,A=0;A<S;A+=2){var C=T[A],R=T[A+1],b=T[A+2],x=T[A+3],w=v*(x-m)-y*(b-g)>0;if(v*(R-m)-y*(C-g)>0){if(w){o.push(b),o.push(x);continue}var M=(B=x-R)*(g-f)-(P=b-C)*(m-p);if(Math.abs(M)>1e-6){var I=(P*(p-R)-B*(f-C))/M;o.push(f+(g-f)*I),o.push(p+(m-p)*I)}else o.push(f),o.push(p)}else if(w){var B,P;M=(B=x-R)*(g-f)-(P=b-C)*(m-p),Math.abs(M)>1e-6?(I=(P*(p-R)-B*(f-C))/M,o.push(f+(g-f)*I),o.push(p+(m-p)*I)):(o.push(f),o.push(p)),o.push(b),o.push(x)}l=!0}if(E==o.length)return h.length=0,!0;if(o.push(o[0]),o.push(o[1]),_==d)break;var D=o;(o=u).length=0,u=D}if(h!=o){h.length=0,_=0;for(var O=o.length-2;_<O;_++)h[_]=o[_]}else h.length=h.length-2;return l},e.makeClockwise=function(t){for(var e=t,i=t.length,n=e[i-2]*e[1]-e[0]*e[i-1],r=0,s=0,a=0,o=0,h=i-3;o<h;o+=2)r=e[o],s=e[o+1],a=e[o+2],n+=r*e[o+3]-a*s;if(!(n<0)){o=0;var l=i-2;for(h=i>>1;o<h;o+=2){var u=e[o],c=e[o+1],d=l-o;e[o]=e[d],e[o+1]=e[d+1],e[d]=u,e[d+1]=c}}},e}();t.SkeletonClipping=e}(XK||(XK={})),function(t){var e=function(){function t(){this.bones=new Array,this.slots=new Array,this.skins=new Array,this.events=new Array,this.animations=new Array,this.ikConstraints=new Array,this.transformConstraints=new Array,this.pathConstraints=new Array,this.fps=0}return t.prototype.findBone=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findBoneIndex=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i<n;i++)if(e[i].name==t)return i;return-1},t.prototype.findSlot=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findSlotIndex=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,n=e.length;i<n;i++)if(e[i].name==t)return i;return-1},t.prototype.findSkin=function(t){if(null==t)throw new Error("skinName cannot be null.");for(var e=this.skins,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findEvent=function(t){if(null==t)throw new Error("eventDataName cannot be null.");for(var e=this.events,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findAnimation=function(t){if(null==t)throw new Error("animationName cannot be null.");for(var e=this.animations,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findIkConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.ikConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findTransformConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.transformConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findPathConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.pathConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findPathConstraintIndex=function(t){if(null==t)throw new Error("pathConstraintName cannot be null.");for(var e=this.pathConstraints,i=0,n=e.length;i<n;i++)if(e[i].name==t)return i;return-1},t}();t.SkeletonData=e}(XK||(XK={})),function(t){var e=function(){function e(t){this.scale=1,this.linkedMeshes=new Array,this.attachmentLoader=t}return e.prototype.readSkeletonData=function(i){var n=this.scale,r=new t.SkeletonData,s="string"==typeof i?JSON.parse(i):i,a=s.skeleton;if(null!=a&&(r.hash=a.hash,r.version=a.spine,r.x=a.x,r.y=a.y,r.width=a.width,r.height=a.height,r.fps=a.fps,r.imagesPath=a.images),s.bones)for(var o=0;o<s.bones.length;o++){var h=s.bones[o],l=null,u=this.getValue(h,"parent",null);if(null!=u&&null==(l=r.findBone(u)))throw new Error("Parent bone not found: "+u);(f=new t.BoneData(r.bones.length,h.name,l)).length=this.getValue(h,"length",0)*n,f.x=this.getValue(h,"x",0)*n,f.y=this.getValue(h,"y",0)*n,f.rotation=this.getValue(h,"rotation",0),f.scaleX=this.getValue(h,"scaleX",1),f.scaleY=this.getValue(h,"scaleY",1),f.shearX=this.getValue(h,"shearX",0),f.shearY=this.getValue(h,"shearY",0),f.transformMode=e.transformModeFromString(this.getValue(h,"transform","normal")),f.skinRequired=this.getValue(h,"skin",!1),r.bones.push(f)}if(s.slots)for(o=0;o<s.slots.length;o++){var c=(M=s.slots[o]).name,d=M.bone,_=r.findBone(d);if(null==_)throw new Error("Slot bone not found: "+d);var f=new t.SlotData(r.slots.length,c,_),p=this.getValue(M,"color",null);null!=p&&f.color.setFromString(p);var g=this.getValue(M,"dark",null);null!=g&&(f.darkColor=new t.Color(1,1,1,1),f.darkColor.setFromString(g)),f.attachmentName=this.getValue(M,"attachment",null),f.blendMode=e.blendModeFromString(this.getValue(M,"blend","normal")),r.slots.push(f)}if(s.ik)for(o=0;o<s.ik.length;o++){var m=s.ik[o];(f=new t.IkConstraintData(m.name)).order=this.getValue(m,"order",0),f.skinRequired=this.getValue(m,"skin",!1);for(var v=0;v<m.bones.length;v++){if(d=m.bones[v],null==(b=r.findBone(d)))throw new Error("IK bone not found: "+d);f.bones.push(b)}var y=m.target;if(f.target=r.findBone(y),null==f.target)throw new Error("IK target bone not found: "+y);f.mix=this.getValue(m,"mix",1),f.softness=this.getValue(m,"softness",0)*n,f.bendDirection=this.getValue(m,"bendPositive",!0)?1:-1,f.compress=this.getValue(m,"compress",!1),f.stretch=this.getValue(m,"stretch",!1),f.uniform=this.getValue(m,"uniform",!1),r.ikConstraints.push(f)}if(s.transform)for(o=0;o<s.transform.length;o++){for(m=s.transform[o],(f=new t.TransformConstraintData(m.name)).order=this.getValue(m,"order",0),f.skinRequired=this.getValue(m,"skin",!1),v=0;v<m.bones.length;v++){if(d=m.bones[v],null==(b=r.findBone(d)))throw new Error("Transform constraint bone not found: "+d);f.bones.push(b)}if(y=m.target,f.target=r.findBone(y),null==f.target)throw new Error("Transform constraint target bone not found: "+y);f.local=this.getValue(m,"local",!1),f.relative=this.getValue(m,"relative",!1),f.offsetRotation=this.getValue(m,"rotation",0),f.offsetX=this.getValue(m,"x",0)*n,f.offsetY=this.getValue(m,"y",0)*n,f.offsetScaleX=this.getValue(m,"scaleX",0),f.offsetScaleY=this.getValue(m,"scaleY",0),f.offsetShearY=this.getValue(m,"shearY",0),f.rotateMix=this.getValue(m,"rotateMix",1),f.translateMix=this.getValue(m,"translateMix",1),f.scaleMix=this.getValue(m,"scaleMix",1),f.shearMix=this.getValue(m,"shearMix",1),r.transformConstraints.push(f)}if(s.path)for(o=0;o<s.path.length;o++){for(m=s.path[o],(f=new t.PathConstraintData(m.name)).order=this.getValue(m,"order",0),f.skinRequired=this.getValue(m,"skin",!1),v=0;v<m.bones.length;v++){if(d=m.bones[v],null==(b=r.findBone(d)))throw new Error("Transform constraint bone not found: "+d);f.bones.push(b)}if(y=m.target,f.target=r.findSlot(y),null==f.target)throw new Error("Path target slot not found: "+y);f.positionMode=e.positionModeFromString(this.getValue(m,"positionMode","percent")),f.spacingMode=e.spacingModeFromString(this.getValue(m,"spacingMode","length")),f.rotateMode=e.rotateModeFromString(this.getValue(m,"rotateMode","tangent")),f.offsetRotation=this.getValue(m,"rotation",0),f.position=this.getValue(m,"position",0),f.positionMode==t.PositionMode.Fixed&&(f.position*=n),f.spacing=this.getValue(m,"spacing",0),f.spacingMode!=t.SpacingMode.Length&&f.spacingMode!=t.SpacingMode.Fixed||(f.spacing*=n),f.rotateMix=this.getValue(m,"rotateMix",1),f.translateMix=this.getValue(m,"translateMix",1),r.pathConstraints.push(f)}if(s.skins){var T=s.skins;if(!(T instanceof Array)){var S=[];for(var E in T)S.push({name:E,attachments:T[E]});T=S}for(o=0;o<T.length;o++){var A=T[o],C=new t.Skin(A.name);if(A.bones)for(var R=0;R<A.bones.length;R++){var b;if(null==(b=r.findBone(A.bones[R])))throw new Error("Skin bone not found: "+A.bones[R]);C.bones.push(b)}if(A.ik)for(R=0;R<A.ik.length;R++){if(null==(x=r.findIkConstraint(A.ik[R])))throw new Error("Skin IK constraint not found: "+A.ik[R]);C.constraints.push(x)}if(A.transform)for(R=0;R<A.transform.length;R++){if(null==(x=r.findTransformConstraint(A.transform[R])))throw new Error("Skin transform constraint not found: "+A.transform[R]);C.constraints.push(x)}if(A.path)for(R=0;R<A.path.length;R++){var x;if(null==(x=r.findPathConstraint(A.path[R])))throw new Error("Skin path constraint not found: "+A.path[R]);C.constraints.push(x)}for(var c in A.attachments){var w=r.findSlot(c);if(null==w)throw new Error("Slot not found: "+c);var M=A.attachments[c];for(var I in M){var B=this.readAttachment(M[I],C,w.index,I,r);null!=B&&C.setAttachment(w.index,I,B)}}r.skins.push(C),"default"==C.name&&(r.defaultSkin=C)}}o=0;for(var P=this.linkedMeshes.length;o<P;o++){var D=this.linkedMeshes[o];if(null==(C=null==D.skin?r.defaultSkin:r.findSkin(D.skin)))throw new Error("Skin not found: "+D.skin);var O=C.getAttachment(D.slotIndex,D.parent);if(null==O)throw new Error("Parent mesh not found: "+D.parent);D.mesh.deformAttachment=D.inheritDeform?O:D.mesh,D.mesh.setParentMesh(O),D.mesh.updateUVs()}if(this.linkedMeshes.length=0,s.events)for(var F in s.events){var L=s.events[F];(f=new t.EventData(F)).intValue=this.getValue(L,"int",0),f.floatValue=this.getValue(L,"float",0),f.stringValue=this.getValue(L,"string",""),f.audioPath=this.getValue(L,"audio",null),null!=f.audioPath&&(f.volume=this.getValue(L,"volume",1),f.balance=this.getValue(L,"balance",0)),r.events.push(f)}if(s.animations)for(var N in s.animations){var k=s.animations[N];this.readAnimation(k,N,r)}return r},e.prototype.readAttachment=function(e,n,r,s,a){var o=this.scale;switch(s=this.getValue(e,"name",s),this.getValue(e,"type","region")){case"region":var h=this.getValue(e,"path",s),l=this.attachmentLoader.newRegionAttachment(n,s,h);return null==l?null:(l.path=h,l.x=this.getValue(e,"x",0)*o,l.y=this.getValue(e,"y",0)*o,l.scaleX=this.getValue(e,"scaleX",1),l.scaleY=this.getValue(e,"scaleY",1),l.rotation=this.getValue(e,"rotation",0),l.width=e.width*o,l.height=e.height*o,null!=(y=this.getValue(e,"color",null))&&l.color.setFromString(y),l.updateOffset(),l);case"boundingbox":var u=this.attachmentLoader.newBoundingBoxAttachment(n,s);return null==u?null:(this.readVertices(e,u,e.vertexCount<<1),null!=(y=this.getValue(e,"color",null))&&u.color.setFromString(y),u);case"mesh":case"linkedmesh":h=this.getValue(e,"path",s);var c=this.attachmentLoader.newMeshAttachment(n,s,h);if(null==c)return null;c.path=h,null!=(y=this.getValue(e,"color",null))&&c.color.setFromString(y),c.width=this.getValue(e,"width",0)*o,c.height=this.getValue(e,"height",0)*o;var d=this.getValue(e,"parent",null);if(null!=d)return this.linkedMeshes.push(new i(c,this.getValue(e,"skin",null),r,d,this.getValue(e,"deform",!0))),c;var _=e.uvs;return this.readVertices(e,c,_.length),c.triangles=e.triangles,c.regionUVs=_,c.updateUVs(),c.edges=this.getValue(e,"edges",null),c.hullLength=2*this.getValue(e,"hull",0),c;case"path":if(null==(h=this.attachmentLoader.newPathAttachment(n,s)))return null;h.closed=this.getValue(e,"closed",!1),h.constantSpeed=this.getValue(e,"constantSpeed",!0);var f=e.vertexCount;this.readVertices(e,h,f<<1);for(var p=t.Utils.newArray(f/3,0),g=0;g<e.lengths.length;g++)p[g]=e.lengths[g]*o;return h.lengths=p,null!=(y=this.getValue(e,"color",null))&&h.color.setFromString(y),h;case"point":var m=this.attachmentLoader.newPointAttachment(n,s);return null==m?null:(m.x=this.getValue(e,"x",0)*o,m.y=this.getValue(e,"y",0)*o,m.rotation=this.getValue(e,"rotation",0),null!=(y=this.getValue(e,"color",null))&&m.color.setFromString(y),m);case"clipping":var v=this.attachmentLoader.newClippingAttachment(n,s);if(null==v)return null;var y,T=this.getValue(e,"end",null);if(null!=T){var S=a.findSlot(T);if(null==S)throw new Error("Clipping end slot not found: "+T);v.endSlot=S}return f=e.vertexCount,this.readVertices(e,v,f<<1),null!=(y=this.getValue(e,"color",null))&&v.color.setFromString(y),v}return null},e.prototype.readVertices=function(e,i,n){var r=this.scale;i.worldVerticesLength=n;var s=e.vertices;if(n!=s.length){var a=new Array,o=new Array;for(c=0,d=s.length;c<d;){var h=s[c++];o.push(h);for(var l=c+4*h;c<l;c+=4)o.push(s[c]),a.push(s[c+1]*r),a.push(s[c+2]*r),a.push(s[c+3])}i.bones=o,i.vertices=t.Utils.toFloatArray(a)}else{var u=t.Utils.toFloatArray(s);if(1!=r)for(var c=0,d=s.length;c<d;c++)u[c]*=r;i.vertices=u}},e.prototype.readAnimation=function(e,i,n){var r=this.scale,s=new Array,a=0;if(e.slots)for(var o in e.slots){var h=e.slots[o];if(-1==(Q=n.findSlotIndex(o)))throw new Error("Slot not found: "+o);for(var l in h){var u=h[l];if("attachment"==l){(T=new t.AttachmentTimeline(u.length)).slotIndex=Q;for(var c=0,d=0;d<u.length;d++){var _=u[d];T.setFrame(c++,this.getValue(_,"time",0),_.name)}s.push(T),a=Math.max(a,T.frames[T.getFrameCount()-1])}else if("color"==l){for((T=new t.ColorTimeline(u.length)).slotIndex=Q,c=0,d=0;d<u.length;d++){_=u[d];var f=new t.Color;f.setFromString(_.color),T.setFrame(c,this.getValue(_,"time",0),f.r,f.g,f.b,f.a),this.readCurve(_,T,c),c++}s.push(T),a=Math.max(a,T.frames[(T.getFrameCount()-1)*t.ColorTimeline.ENTRIES])}else{if("twoColor"!=l)throw new Error("Invalid timeline type for a slot: "+l+" ("+o+")");for((T=new t.TwoColorTimeline(u.length)).slotIndex=Q,c=0,d=0;d<u.length;d++){_=u[d];var p=new t.Color,g=new t.Color;p.setFromString(_.light),g.setFromString(_.dark),T.setFrame(c,this.getValue(_,"time",0),p.r,p.g,p.b,p.a,g.r,g.g,g.b),this.readCurve(_,T,c),c++}s.push(T),a=Math.max(a,T.frames[(T.getFrameCount()-1)*t.TwoColorTimeline.ENTRIES])}}}if(e.bones)for(var m in e.bones){var v=e.bones[m],y=n.findBoneIndex(m);if(-1==y)throw new Error("Bone not found: "+m);for(var l in v)if(u=v[l],"rotate"===l){for((T=new t.RotateTimeline(u.length)).boneIndex=y,c=0,d=0;d<u.length;d++)_=u[d],T.setFrame(c,this.getValue(_,"time",0),this.getValue(_,"angle",0)),this.readCurve(_,T,c),c++;s.push(T),a=Math.max(a,T.frames[(T.getFrameCount()-1)*t.RotateTimeline.ENTRIES])}else{if("translate"!==l&&"scale"!==l&&"shear"!==l)throw new Error("Invalid timeline type for a bone: "+l+" ("+m+")");var T=null,S=1,E=0;for("scale"===l?(T=new t.ScaleTimeline(u.length),E=1):"shear"===l?T=new t.ShearTimeline(u.length):(T=new t.TranslateTimeline(u.length),S=r),T.boneIndex=y,c=0,d=0;d<u.length;d++){_=u[d];var A=this.getValue(_,"x",E),C=this.getValue(_,"y",E);T.setFrame(c,this.getValue(_,"time",0),A*S,C*S),this.readCurve(_,T,c),c++}s.push(T),a=Math.max(a,T.frames[(T.getFrameCount()-1)*t.TranslateTimeline.ENTRIES])}}if(e.ik)for(var R in e.ik){var b=e.ik[R],x=n.findIkConstraint(R);for((T=new t.IkConstraintTimeline(b.length)).ikConstraintIndex=n.ikConstraints.indexOf(x),c=0,d=0;d<b.length;d++)_=b[d],T.setFrame(c,this.getValue(_,"time",0),this.getValue(_,"mix",1),this.getValue(_,"softness",0)*r,this.getValue(_,"bendPositive",!0)?1:-1,this.getValue(_,"compress",!1),this.getValue(_,"stretch",!1)),this.readCurve(_,T,c),c++;s.push(T),a=Math.max(a,T.frames[(T.getFrameCount()-1)*t.IkConstraintTimeline.ENTRIES])}if(e.transform)for(var R in e.transform){for(b=e.transform[R],x=n.findTransformConstraint(R),(T=new t.TransformConstraintTimeline(b.length)).transformConstraintIndex=n.transformConstraints.indexOf(x),c=0,d=0;d<b.length;d++)_=b[d],T.setFrame(c,this.getValue(_,"time",0),this.getValue(_,"rotateMix",1),this.getValue(_,"translateMix",1),this.getValue(_,"scaleMix",1),this.getValue(_,"shearMix",1)),this.readCurve(_,T,c),c++;s.push(T),a=Math.max(a,T.frames[(T.getFrameCount()-1)*t.TransformConstraintTimeline.ENTRIES])}var w=e.path||e.paths;if(w)for(var R in w){b=w[R];var M=n.findPathConstraintIndex(R);if(-1==M)throw new Error("Path constraint not found: "+R);var I=n.pathConstraints[M];for(var l in b)if(u=b[l],"position"===l||"spacing"===l){for(T=null,S=1,"spacing"===l?(T=new t.PathConstraintSpacingTimeline(u.length),I.spacingMode!=t.SpacingMode.Length&&I.spacingMode!=t.SpacingMode.Fixed||(S=r)):(T=new t.PathConstraintPositionTimeline(u.length),I.positionMode==t.PositionMode.Fixed&&(S=r)),T.pathConstraintIndex=M,c=0,d=0;d<u.length;d++)_=u[d],T.setFrame(c,this.getValue(_,"time",0),this.getValue(_,l,0)*S),this.readCurve(_,T,c),c++;s.push(T),a=Math.max(a,T.frames[(T.getFrameCount()-1)*t.PathConstraintPositionTimeline.ENTRIES])}else if("mix"===l){for((T=new t.PathConstraintMixTimeline(u.length)).pathConstraintIndex=M,c=0,d=0;d<u.length;d++)_=u[d],T.setFrame(c,this.getValue(_,"time",0),this.getValue(_,"rotateMix",1),this.getValue(_,"translateMix",1)),this.readCurve(_,T,c),c++;s.push(T),a=Math.max(a,T.frames[(T.getFrameCount()-1)*t.PathConstraintMixTimeline.ENTRIES])}}if(e.deform)for(var B in e.deform){var P=e.deform[B],D=n.findSkin(B);if(null==D)throw new Error("Skin not found: "+B);for(var o in P){if(h=P[o],-1==(Q=n.findSlotIndex(o)))throw new Error("Slot not found: "+h.name);for(var l in h){u=h[l];var O=D.getAttachment(Q,l);if(null!=O){var F=null!=O.bones,L=O.vertices,N=F?L.length/3*2:L.length;(T=new t.DeformTimeline(u.length)).slotIndex=Q,T.attachment=O,c=0;for(var k=0;k<u.length;k++){_=u[k];var U=void 0,G=this.getValue(_,"vertices",null);if(null==G)U=F?t.Utils.newFloatArray(N):L;else{U=t.Utils.newFloatArray(N);var V=this.getValue(_,"offset",0);if(t.Utils.arrayCopy(G,0,U,V,G.length),1!=r)for(var H=(d=V)+G.length;d<H;d++)U[d]*=r;if(!F)for(d=0;d<N;d++)U[d]+=L[d]}T.setFrame(c,this.getValue(_,"time",0),U),this.readCurve(_,T,c),c++}s.push(T),a=Math.max(a,T.frames[T.getFrameCount()-1])}}}}var z=e.drawOrder;if(null==z&&(z=e.draworder),null!=z){T=new t.DrawOrderTimeline(z.length);var X=n.slots.length;for(c=0,k=0;k<z.length;k++){var W=z[k],Y=null,j=this.getValue(W,"offsets",null);if(null!=j){Y=t.Utils.newArray(X,-1);var K=t.Utils.newArray(X-j.length,0),q=0,Z=0;for(d=0;d<j.length;d++){var Q,J=j[d];if(-1==(Q=n.findSlotIndex(J.slot)))throw new Error("Slot not found: "+J.slot);for(;q!=Q;)K[Z++]=q++;Y[q+J.offset]=q++}for(;q<X;)K[Z++]=q++;for(d=X-1;d>=0;d--)-1==Y[d]&&(Y[d]=K[--Z])}T.setFrame(c++,this.getValue(W,"time",0),Y)}s.push(T),a=Math.max(a,T.frames[T.getFrameCount()-1])}if(e.events){for(T=new t.EventTimeline(e.events.length),c=0,d=0;d<e.events.length;d++){var $=e.events[d],tt=n.findEvent($.name);if(null==tt)throw new Error("Event not found: "+$.name);var et=new t.Event(t.Utils.toSinglePrecision(this.getValue($,"time",0)),tt);et.intValue=this.getValue($,"int",tt.intValue),et.floatValue=this.getValue($,"float",tt.floatValue),et.stringValue=this.getValue($,"string",tt.stringValue),null!=et.data.audioPath&&(et.volume=this.getValue($,"volume",1),et.balance=this.getValue($,"balance",0)),T.setFrame(c++,et)}s.push(T),a=Math.max(a,T.frames[T.getFrameCount()-1])}if(isNaN(a))throw new Error("Error while parsing animation, duration is NaN");n.animations.push(new t.Animation(i,s,a))},e.prototype.readCurve=function(t,e,i){var n=t.curve;n&&("stepped"==n?e.setStepped(i):"[object Array]"===Object.prototype.toString.call(n)?e.setCurve(i,n[0],n[1],n[2],n[3]):e.setCurve(i,n,this.getValue(t,"c2",0),this.getValue(t,"c3",1),this.getValue(t,"c4",1)))},e.prototype.getValue=function(t,e,i){return void 0!==t[e]?t[e]:i},e.blendModeFromString=function(e){if("normal"==(e=e.toLowerCase()))return t.BlendMode.Normal;if("additive"==e)return t.BlendMode.Additive;if("multiply"==e)return t.BlendMode.Multiply;if("screen"==e)return t.BlendMode.Screen;throw new Error("Unknown blend mode: "+e)},e.positionModeFromString=function(e){if("fixed"==(e=e.toLowerCase()))return t.PositionMode.Fixed;if("percent"==e)return t.PositionMode.Percent;throw new Error("Unknown position mode: "+e)},e.spacingModeFromString=function(e){if("length"==(e=e.toLowerCase()))return t.SpacingMode.Length;if("fixed"==e)return t.SpacingMode.Fixed;if("percent"==e)return t.SpacingMode.Percent;throw new Error("Unknown position mode: "+e)},e.rotateModeFromString=function(e){if("tangent"==(e=e.toLowerCase()))return t.RotateMode.Tangent;if("chain"==e)return t.RotateMode.Chain;if("chainscale"==e)return t.RotateMode.ChainScale;throw new Error("Unknown rotate mode: "+e)},e.transformModeFromString=function(e){if("normal"==(e=e.toLowerCase()))return t.TransformMode.Normal;if("onlytranslation"==e)return t.TransformMode.OnlyTranslation;if("norotationorreflection"==e)return t.TransformMode.NoRotationOrReflection;if("noscale"==e)return t.TransformMode.NoScale;if("noscaleorreflection"==e)return t.TransformMode.NoScaleOrReflection;throw new Error("Unknown transform mode: "+e)},e}();t.SkeletonJson=e;var i=function(t,e,i,n,r){this.mesh=t,this.skin=e,this.slotIndex=i,this.parent=n,this.inheritDeform=r}}(XK||(XK={})),function(t){var e=function(t,e,i){this.slotIndex=t,this.name=e,this.attachment=i};t.SkinEntry=e;var i=function(){function i(t){if(this.attachments=new Array,this.bones=Array(),this.constraints=new Array,null==t)throw new Error("name cannot be null.");this.name=t}return i.prototype.setAttachment=function(t,e,i){if(null==i)throw new Error("attachment cannot be null.");var n=this.attachments;t>=n.length&&(n.length=t+1),n[t]||(n[t]={}),n[t][e]=i},i.prototype.addSkin=function(t){for(var e=0;e<t.bones.length;e++){for(var i=t.bones[e],n=!1,r=0;r<this.bones.length;r++)if(this.bones[r]==i){n=!0;break}n||this.bones.push(i)}for(e=0;e<t.constraints.length;e++){var s=t.constraints[e];for(n=!1,r=0;r<this.constraints.length;r++)if(this.constraints[r]==s){n=!0;break}n||this.constraints.push(s)}var a=t.getAttachments();for(e=0;e<a.length;e++){var o=a[e];this.setAttachment(o.slotIndex,o.name,o.attachment)}},i.prototype.copySkin=function(e){for(var i=0;i<e.bones.length;i++){for(var n=e.bones[i],r=!1,s=0;s<this.bones.length;s++)if(this.bones[s]==n){r=!0;break}r||this.bones.push(n)}for(i=0;i<e.constraints.length;i++){var a=e.constraints[i];for(r=!1,s=0;s<this.constraints.length;s++)if(this.constraints[s]==a){r=!0;break}r||this.constraints.push(a)}var o=e.getAttachments();for(i=0;i<o.length;i++){var h=o[i];null!=h.attachment&&(h.attachment instanceof t.MeshAttachment?(h.attachment=h.attachment.newLinkedMesh(),this.setAttachment(h.slotIndex,h.name,h.attachment)):(h.attachment=h.attachment.copy(),this.setAttachment(h.slotIndex,h.name,h.attachment)))}},i.prototype.getAttachment=function(t,e){var i=this.attachments[t];return i?i[e]:null},i.prototype.removeAttachment=function(t,e){var i=this.attachments[t];i&&(i[e]=null)},i.prototype.getAttachments=function(){for(var t=new Array,i=0;i<this.attachments.length;i++){var n=this.attachments[i];if(n)for(var r in n){var s=n[r];s&&t.push(new e(i,r,s))}}return t},i.prototype.getAttachmentsForSlot=function(t,i){var n=this.attachments[t];if(n)for(var r in n){var s=n[r];s&&i.push(new e(t,r,s))}},i.prototype.clear=function(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0},i.prototype.attachAll=function(t,e){for(var i=0,n=0;n<t.slots.length;n++){var r=t.slots[n],s=r.getAttachment();if(s&&i<e.attachments.length){var a=e.attachments[i];for(var o in a)if(s==a[o]){var h=this.getAttachment(i,o);null!=h&&r.setAttachment(h);break}}i++}},i}();t.Skin=i}(XK||(XK={})),function(t){var e=function(){function e(e,i){if(this.deform=new Array,null==e)throw new Error("data cannot be null.");if(null==i)throw new Error("bone cannot be null.");this.data=e,this.bone=i,this.color=new t.Color,this.darkColor=null==e.darkColor?null:new t.Color,this.setToSetupPose()}return e.prototype.getSkeleton=function(){return this.bone.skeleton},e.prototype.getAttachment=function(){return this.attachment},e.prototype.setAttachment=function(t){this.attachment!=t&&(this.attachment=t,this.attachmentTime=this.bone.skeleton.time,this.deform.length=0)},e.prototype.setAttachmentTime=function(t){this.attachmentTime=this.bone.skeleton.time-t},e.prototype.getAttachmentTime=function(){return this.bone.skeleton.time-this.attachmentTime},e.prototype.setToSetupPose=function(){this.color.setFromColor(this.data.color),null!=this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),null==this.data.attachmentName?this.attachment=null:(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName)))},e}();t.Slot=e}(XK||(XK={})),function(t){t.SlotData=function(e,i,n){if(this.color=new t.Color(1,1,1,1),e<0)throw new Error("index must be >= 0.");if(null==i)throw new Error("name cannot be null.");if(null==n)throw new Error("boneData cannot be null.");this.index=e,this.name=i,this.boneData=n}}(XK||(XK={})),function(t){var e,i,n=function(){function t(t){this._image=t}return t.prototype.getImage=function(){return this._image},t.filterFromString=function(t){switch(t.toLowerCase()){case"nearest":return e.Nearest;case"linear":return e.Linear;case"mipmap":return e.MipMap;case"mipmapnearestnearest":return e.MipMapNearestNearest;case"mipmaplinearnearest":return e.MipMapLinearNearest;case"mipmapnearestlinear":return e.MipMapNearestLinear;case"mipmaplinearlinear":return e.MipMapLinearLinear;default:throw new Error("Unknown texture filter "+t)}},t.wrapFromString=function(t){switch(t.toLowerCase()){case"mirroredtepeat":return i.MirroredRepeat;case"clamptoedge":return i.ClampToEdge;case"repeat":return i.Repeat;default:throw new Error("Unknown texture wrap "+t)}},t}();t.Texture=n,function(t){t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear"}(e=t.TextureFilter||(t.TextureFilter={})),function(t){t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat"}(i=t.TextureWrap||(t.TextureWrap={}));t.TextureRegion=function(){this.u=0,this.v=0,this.u2=0,this.v2=0,this.width=0,this.height=0,this.rotate=!1,this.offsetX=0,this.offsetY=0,this.originalWidth=0,this.originalHeight=0};var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return WK(e,t),e.prototype.setFilters=function(){},e.prototype.setWraps=function(){},e.prototype.dispose=function(){},e}(n);t.FakeTexture=r}(XK||(XK={})),function(t){var e=function(){function e(t,e){this.pages=new Array,this.regions=new Array,this.load(t,e)}return e.prototype.load=function(e,s){if(null==s)throw new Error("textureLoader cannot be null.");for(var a=new i(e),o=new Array(4),h=null;;){var l=a.readLine();if(null==l)break;if(0==(l=l.trim()).length)h=null;else if(h){var u=new r;u.name=l,u.page=h;var c=a.readValue();"true"==c.toLocaleLowerCase()?u.degrees=90:"false"==c.toLocaleLowerCase()?u.degrees=0:u.degrees=parseFloat(c),u.rotate=90==u.degrees,a.readTuple(o);var d=parseInt(o[0]),_=parseInt(o[1]);a.readTuple(o);var f=parseInt(o[0]),p=parseInt(o[1]);u.u=d/h.width,u.v=_/h.height,u.rotate?(u.u2=(d+p)/h.width,u.v2=(_+f)/h.height):(u.u2=(d+f)/h.width,u.v2=(_+p)/h.height),u.x=d,u.y=_,u.width=Math.abs(f),u.height=Math.abs(p),4==a.readTuple(o)&&4==a.readTuple(o)&&a.readTuple(o),u.originalWidth=parseInt(o[0]),u.originalHeight=parseInt(o[1]),a.readTuple(o),u.offsetX=parseInt(o[0]),u.offsetY=parseInt(o[1]),u.index=parseInt(a.readValue()),u.texture=h.texture,this.regions.push(u)}else{(h=new n).name=l,2==a.readTuple(o)&&(h.width=parseInt(o[0]),h.height=parseInt(o[1]),a.readTuple(o)),a.readTuple(o),h.minFilter=t.Texture.filterFromString(o[0]),h.magFilter=t.Texture.filterFromString(o[1]);var g=a.readValue();h.uWrap=t.TextureWrap.ClampToEdge,h.vWrap=t.TextureWrap.ClampToEdge,"x"==g?h.uWrap=t.TextureWrap.Repeat:"y"==g?h.vWrap=t.TextureWrap.Repeat:"xy"==g&&(h.uWrap=h.vWrap=t.TextureWrap.Repeat),h.texture=s(l),h.texture.setFilters(h.minFilter,h.magFilter),h.texture.setWraps(h.uWrap,h.vWrap),h.width=h.texture.getImage().width,h.height=h.texture.getImage().height,this.pages.push(h)}}},e.prototype.findRegion=function(t){for(var e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null},e.prototype.dispose=function(){for(var t=0;t<this.pages.length;t++)this.pages[t].texture.dispose()},e}();t.TextureAtlas=e;var i=function(){function t(t){this.index=0,this.lines=t.split(/\r\n|\r|\n/)}return t.prototype.readLine=function(){return this.index>=this.lines.length?null:this.lines[this.index++]},t.prototype.readValue=function(){var t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()},t.prototype.readTuple=function(t){var e=this.readLine(),i=e.indexOf(":");if(-1==i)throw new Error("Invalid line: "+e);for(var n=0,r=i+1;n<3;n++){var s=e.indexOf(",",r);if(-1==s)break;t[n]=e.substr(r,s-r).trim(),r=s+1}return t[n]=e.substring(r).trim(),n+1},t}(),n=function(){};t.TextureAtlasPage=n;var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return WK(e,t),e}(t.TextureRegion);t.TextureAtlasRegion=r}(XK||(XK={})),function(t){var e=function(){function e(e,i){if(this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.temp=new t.Vector2,this.active=!1,null==e)throw new Error("data cannot be null.");if(null==i)throw new Error("skeleton cannot be null.");this.data=e,this.rotateMix=e.rotateMix,this.translateMix=e.translateMix,this.scaleMix=e.scaleMix,this.shearMix=e.shearMix,this.bones=new Array;for(var n=0;n<e.bones.length;n++)this.bones.push(i.findBone(e.bones[n].name));this.target=i.findBone(e.target.name)}return e.prototype.isActive=function(){return this.active},e.prototype.apply=function(){this.update()},e.prototype.update=function(){this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld()},e.prototype.applyAbsoluteWorld=function(){for(var e=this.rotateMix,i=this.translateMix,n=this.scaleMix,r=this.shearMix,s=this.target,a=s.a,o=s.b,h=s.c,l=s.d,u=a*l-o*h>0?t.MathUtils.degRad:-t.MathUtils.degRad,c=this.data.offsetRotation*u,d=this.data.offsetShearY*u,_=this.bones,f=0,p=_.length;f<p;f++){var g=_[f],m=!1;if(0!=e){var v=g.a,y=g.b,T=g.c,S=g.d;(x=Math.atan2(h,a)-Math.atan2(T,v)+c)>t.MathUtils.PI?x-=t.MathUtils.PI2:x<-t.MathUtils.PI&&(x+=t.MathUtils.PI2),x*=e;var E=Math.cos(x),A=Math.sin(x);g.a=E*v-A*T,g.b=E*y-A*S,g.c=A*v+E*T,g.d=A*y+E*S,m=!0}if(0!=i){var C=this.temp;s.localToWorld(C.set(this.data.offsetX,this.data.offsetY)),g.worldX+=(C.x-g.worldX)*i,g.worldY+=(C.y-g.worldY)*i,m=!0}if(n>0){var R=Math.sqrt(g.a*g.a+g.c*g.c),b=Math.sqrt(a*a+h*h);R>1e-5&&(R=(R+(b-R+this.data.offsetScaleX)*n)/R),g.a*=R,g.c*=R,R=Math.sqrt(g.b*g.b+g.d*g.d),b=Math.sqrt(o*o+l*l),R>1e-5&&(R=(R+(b-R+this.data.offsetScaleY)*n)/R),g.b*=R,g.d*=R,m=!0}if(r>0){y=g.b,S=g.d;var x,w=Math.atan2(S,y);(x=Math.atan2(l,o)-Math.atan2(h,a)-(w-Math.atan2(g.c,g.a)))>t.MathUtils.PI?x-=t.MathUtils.PI2:x<-t.MathUtils.PI&&(x+=t.MathUtils.PI2),x=w+(x+d)*r,R=Math.sqrt(y*y+S*S),g.b=Math.cos(x)*R,g.d=Math.sin(x)*R,m=!0}m&&(g.appliedValid=!1)}},e.prototype.applyRelativeWorld=function(){for(var e=this.rotateMix,i=this.translateMix,n=this.scaleMix,r=this.shearMix,s=this.target,a=s.a,o=s.b,h=s.c,l=s.d,u=a*l-o*h>0?t.MathUtils.degRad:-t.MathUtils.degRad,c=this.data.offsetRotation*u,d=this.data.offsetShearY*u,_=this.bones,f=0,p=_.length;f<p;f++){var g,m=_[f],v=!1;if(0!=e){var y=m.a,T=m.b,S=m.c,E=m.d;(g=Math.atan2(h,a)+c)>t.MathUtils.PI?g-=t.MathUtils.PI2:g<-t.MathUtils.PI&&(g+=t.MathUtils.PI2),g*=e;var A=Math.cos(g),C=Math.sin(g);m.a=A*y-C*S,m.b=A*T-C*E,m.c=C*y+A*S,m.d=C*T+A*E,v=!0}if(0!=i){var R=this.temp;s.localToWorld(R.set(this.data.offsetX,this.data.offsetY)),m.worldX+=R.x*i,m.worldY+=R.y*i,v=!0}if(n>0){var b=(Math.sqrt(a*a+h*h)-1+this.data.offsetScaleX)*n+1;m.a*=b,m.c*=b,b=(Math.sqrt(o*o+l*l)-1+this.data.offsetScaleY)*n+1,m.b*=b,m.d*=b,v=!0}if(r>0)(g=Math.atan2(l,o)-Math.atan2(h,a))>t.MathUtils.PI?g-=t.MathUtils.PI2:g<-t.MathUtils.PI&&(g+=t.MathUtils.PI2),T=m.b,E=m.d,g=Math.atan2(E,T)+(g-t.MathUtils.PI/2+d)*r,b=Math.sqrt(T*T+E*E),m.b=Math.cos(g)*b,m.d=Math.sin(g)*b,v=!0;v&&(m.appliedValid=!1)}},e.prototype.applyAbsoluteLocal=function(){var t=this.rotateMix,e=this.translateMix,i=this.scaleMix,n=this.shearMix,r=this.target;r.appliedValid||r.updateAppliedTransform();for(var s=this.bones,a=0,o=s.length;a<o;a++){var h=s[a];h.appliedValid||h.updateAppliedTransform();var l=h.arotation;if(0!=t){var u=r.arotation-l+this.data.offsetRotation;l+=(u-=360*(16384-(16384.499999999996-u/360|0)))*t}var c=h.ax,d=h.ay;0!=e&&(c+=(r.ax-c+this.data.offsetX)*e,d+=(r.ay-d+this.data.offsetY)*e);var _=h.ascaleX,f=h.ascaleY;0!=i&&(_>1e-5&&(_=(_+(r.ascaleX-_+this.data.offsetScaleX)*i)/_),f>1e-5&&(f=(f+(r.ascaleY-f+this.data.offsetScaleY)*i)/f));var p=h.ashearY;0!=n&&(u=r.ashearY-p+this.data.offsetShearY,u-=360*(16384-(16384.499999999996-u/360|0)),h.shearY+=u*n),h.updateWorldTransformWith(c,d,l,_,f,h.ashearX,p)}},e.prototype.applyRelativeLocal=function(){var t=this.rotateMix,e=this.translateMix,i=this.scaleMix,n=this.shearMix,r=this.target;r.appliedValid||r.updateAppliedTransform();for(var s=this.bones,a=0,o=s.length;a<o;a++){var h=s[a];h.appliedValid||h.updateAppliedTransform();var l=h.arotation;0!=t&&(l+=(r.arotation+this.data.offsetRotation)*t);var u=h.ax,c=h.ay;0!=e&&(u+=(r.ax+this.data.offsetX)*e,c+=(r.ay+this.data.offsetY)*e);var d=h.ascaleX,_=h.ascaleY;0!=i&&(d>1e-5&&(d*=(r.ascaleX-1+this.data.offsetScaleX)*i+1),_>1e-5&&(_*=(r.ascaleY-1+this.data.offsetScaleY)*i+1));var f=h.ashearY;0!=n&&(f+=(r.ashearY+this.data.offsetShearY)*n),h.updateWorldTransformWith(u,c,l,d,_,h.ashearX,f)}},e}();t.TransformConstraint=e}(XK||(XK={})),function(t){var e=function(t){function e(e){var i=t.call(this,e,0,!1)||this;return i.bones=new Array,i.rotateMix=0,i.translateMix=0,i.scaleMix=0,i.shearMix=0,i.offsetRotation=0,i.offsetX=0,i.offsetY=0,i.offsetScaleX=0,i.offsetScaleY=0,i.offsetShearY=0,i.relative=!1,i.local=!1,i}return WK(e,t),e}(t.ConstraintData);t.TransformConstraintData=e}(XK||(XK={})),function(t){var e=function(){function e(){this.convexPolygons=new Array,this.convexPolygonsIndices=new Array,this.indicesArray=new Array,this.isConcaveArray=new Array,this.triangles=new Array,this.polygonPool=new t.Pool((function(){return new Array})),this.polygonIndicesPool=new t.Pool((function(){return new Array}))}return e.prototype.triangulate=function(t){var i=t,n=t.length>>1,r=this.indicesArray;r.length=0;for(var s=0;s<n;s++)r[s]=s;var a=this.isConcaveArray;a.length=0,s=0;for(var o=n;s<o;++s)a[s]=e.isConcave(s,n,i,r);var h=this.triangles;for(h.length=0;n>3;){for(var l=n-1,u=(s=0,1);;){t:if(!a[s]){for(var c=r[l]<<1,d=r[s]<<1,_=r[u]<<1,f=i[c],p=i[c+1],g=i[d],m=i[d+1],v=i[_],y=i[_+1],T=(u+1)%n;T!=l;T=(T+1)%n)if(a[T]){var S=r[T]<<1,E=i[S],A=i[S+1];if(e.positiveArea(v,y,f,p,E,A)&&e.positiveArea(f,p,g,m,E,A)&&e.positiveArea(g,m,v,y,E,A))break t}break}if(0==u){do{if(!a[s])break;s--}while(s>0);break}l=s,s=u,u=(u+1)%n}h.push(r[(n+s-1)%n]),h.push(r[s]),h.push(r[(s+1)%n]),r.splice(s,1),a.splice(s,1);var C=(--n+s-1)%n,R=s==n?0:s;a[C]=e.isConcave(C,n,i,r),a[R]=e.isConcave(R,n,i,r)}return 3==n&&(h.push(r[2]),h.push(r[0]),h.push(r[1])),h},e.prototype.decompose=function(t,i){var n=t,r=this.convexPolygons;this.polygonPool.freeAll(r),r.length=0;var s=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(s),s.length=0;var a=this.polygonIndicesPool.obtain();a.length=0;var o=this.polygonPool.obtain();o.length=0;for(var h=-1,l=0,u=0,c=i.length;u<c;u+=3){var d=i[u]<<1,_=i[u+1]<<1,f=i[u+2]<<1,p=n[d],g=n[d+1],m=n[_],v=n[_+1],y=n[f],T=n[f+1],S=!1;if(h==d){var E=o.length-4,A=e.winding(o[E],o[E+1],o[E+2],o[E+3],y,T),C=e.winding(y,T,o[0],o[1],o[2],o[3]);A==l&&C==l&&(o.push(y),o.push(T),a.push(f),S=!0)}S||(o.length>0?(r.push(o),s.push(a)):(this.polygonPool.free(o),this.polygonIndicesPool.free(a)),(o=this.polygonPool.obtain()).length=0,o.push(p),o.push(g),o.push(m),o.push(v),o.push(y),o.push(T),(a=this.polygonIndicesPool.obtain()).length=0,a.push(d),a.push(_),a.push(f),l=e.winding(p,g,m,v,y,T),h=d)}for(o.length>0&&(r.push(o),s.push(a)),u=0,c=r.length;u<c;u++)if(0!=(a=s[u]).length)for(var R=a[0],b=a[a.length-1],x=(o=r[u])[E=o.length-4],w=o[E+1],M=o[E+2],I=o[E+3],B=o[0],P=o[1],D=o[2],O=o[3],F=e.winding(x,w,M,I,B,P),L=0;L<c;L++)if(L!=u){var N=s[L];if(3==N.length){var k=N[0],U=N[1],G=N[2],V=r[L];y=V[V.length-2],T=V[V.length-1],k==R&&U==b&&(A=e.winding(x,w,M,I,y,T),C=e.winding(y,T,B,P,D,O),A==F&&C==F&&(V.length=0,N.length=0,o.push(y),o.push(T),a.push(G),x=M,w=I,M=y,I=T,L=0))}}for(u=r.length-1;u>=0;u--)0==(o=r[u]).length&&(r.splice(u,1),this.polygonPool.free(o),a=s[u],s.splice(u,1),this.polygonIndicesPool.free(a));return r},e.isConcave=function(t,e,i,n){var r=n[(e+t-1)%e]<<1,s=n[t]<<1,a=n[(t+1)%e]<<1;return!this.positiveArea(i[r],i[r+1],i[s],i[s+1],i[a],i[a+1])},e.positiveArea=function(t,e,i,n,r,s){return t*(s-n)+i*(e-s)+r*(n-e)>=0},e.winding=function(t,e,i,n,r,s){var a=i-t,o=n-e;return r*o-s*a+a*e-t*o>=0?1:-1},e}();t.Triangulator=e}(XK||(XK={})),function(t){var e=function(){function t(){this.array=new Array}return t.prototype.add=function(t){var e=this.contains(t);return this.array[0|t]=0|t,!e},t.prototype.contains=function(t){return null!=this.array[0|t]},t.prototype.remove=function(t){this.array[0|t]=void 0},t.prototype.clear=function(){this.array.length=0},t}();t.IntSet=e;var i=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.r=t,this.g=e,this.b=i,this.a=n}return t.prototype.set=function(t,e,i,n){return this.r=t,this.g=e,this.b=i,this.a=n,this.clamp(),this},t.prototype.setFromColor=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.setFromString=function(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=(8!=t.length?255:parseInt(t.substr(6,2),16))/255,this},t.prototype.add=function(t,e,i,n){return this.r+=t,this.g+=e,this.b+=i,this.a+=n,this.clamp(),this},t.prototype.clamp=function(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this},t.rgba8888ToColor=function(t,e){t.r=((4278190080&e)>>>24)/255,t.g=((16711680&e)>>>16)/255,t.b=((65280&e)>>>8)/255,t.a=(255&e)/255},t.rgb888ToColor=function(t,e){t.r=((16711680&e)>>>16)/255,t.g=((65280&e)>>>8)/255,t.b=(255&e)/255},t.WHITE=new t(1,1,1,1),t.RED=new t(1,0,0,1),t.GREEN=new t(0,1,0,1),t.BLUE=new t(0,0,1,1),t.MAGENTA=new t(1,0,1,1),t}();t.Color=i;var n=function(){function t(){}return t.clamp=function(t,e,i){return t<e?e:t>i?i:t},t.cosDeg=function(e){return Math.cos(e*t.degRad)},t.sinDeg=function(e){return Math.sin(e*t.degRad)},t.signum=function(t){return t>0?1:t<0?-1:0},t.toInt=function(t){return t>0?Math.floor(t):Math.ceil(t)},t.cbrt=function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},t.randomTriangular=function(e,i){return t.randomTriangularWith(e,i,.5*(e+i))},t.randomTriangularWith=function(t,e,i){var n=Math.random(),r=e-t;return n<=(i-t)/r?t+Math.sqrt(n*r*(i-t)):e-Math.sqrt((1-n)*r*(e-i))},t.PI=3.1415927,t.PI2=2*t.PI,t.radiansToDegrees=180/t.PI,t.radDeg=t.radiansToDegrees,t.degreesToRadians=t.PI/180,t.degRad=t.degreesToRadians,t}();t.MathUtils=n;var r=function(){function t(){}return t.prototype.apply=function(t,e,i){return t+(e-t)*this.applyInternal(i)},t}();t.Interpolation=r;var s=function(t){function e(e){var i=t.call(this)||this;return i.power=2,i.power=e,i}return WK(e,t),e.prototype.applyInternal=function(t){return t<=.5?Math.pow(2*t,this.power)/2:Math.pow(2*(t-1),this.power)/(this.power%2==0?-2:2)+1},e}(r);t.Pow=s;var a=function(t){function e(e){return t.call(this,e)||this}return WK(e,t),e.prototype.applyInternal=function(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1},e}(s);t.PowOut=a;var o=function(){function t(){}return t.arrayCopy=function(t,e,i,n,r){for(var s=e,a=n;s<e+r;s++,a++)i[a]=t[s]},t.setArraySize=function(t,e,i){void 0===i&&(i=0);var n=t.length;if(n==e)return t;if(t.length=e,n<e)for(var r=n;r<e;r++)t[r]=i;return t},t.ensureArrayCapacity=function(e,i,n){return void 0===n&&(n=0),e.length>=i?e:t.setArraySize(e,i,n)},t.newArray=function(t,e){for(var i=new Array(t),n=0;n<t;n++)i[n]=e;return i},t.newFloatArray=function(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);for(var i=new Array(e),n=0;n<i.length;n++)i[n]=0;return i},t.newShortArray=function(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Int16Array(e);for(var i=new Array(e),n=0;n<i.length;n++)i[n]=0;return i},t.toFloatArray=function(e){return t.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e},t.toSinglePrecision=function(e){return t.SUPPORTS_TYPED_ARRAYS?Math.fround(e):e},t.webkit602BugfixHelper=function(){},t.contains=function(t,e){for(var i=0;i<t.length;i++)if(t[i]==e)return!0;return!1},t.SUPPORTS_TYPED_ARRAYS="undefined"!=typeof Float32Array,t}();t.Utils=o;var h=function(){function t(){}return t.logBones=function(t){for(var e=0;e<t.bones.length;e++){var i=t.bones[e];console.log(i.data.name+", "+i.a+", "+i.b+", "+i.c+", "+i.d+", "+i.worldX+", "+i.worldY)}},t}();t.DebugUtils=h;var l=function(){function t(t){this.items=new Array,this.instantiator=t}return t.prototype.obtain=function(){return this.items.length>0?this.items.pop():this.instantiator()},t.prototype.free=function(t){t.reset&&t.reset(),this.items.push(t)},t.prototype.freeAll=function(t){for(var e=0;e<t.length;e++)t[e].reset&&t[e].reset(),this.items[e]=t[e]},t.prototype.clear=function(){this.items.length=0},t}();t.Pool=l;var u=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.set=function(t,e){return this.x=t,this.y=e,this},t.prototype.length=function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},t.prototype.normalize=function(){var t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this},t}();t.Vector2=u;var c=function(){function t(){this.maxDelta=.064,this.framesPerSecond=0,this.delta=0,this.totalTime=0,this.lastTime=Date.now()/1e3,this.frameCount=0,this.frameTime=0}return t.prototype.update=function(){var t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)},t}();t.TimeKeeper=c;var d=function(){function t(t){void 0===t&&(t=32),this.addedValues=0,this.lastValue=0,this.mean=0,this.dirty=!0,this.values=new Array(t)}return t.prototype.hasEnoughData=function(){return this.addedValues>=this.values.length},t.prototype.addValue=function(t){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=t,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0},t.prototype.getMean=function(){if(this.hasEnoughData()){if(this.dirty){for(var t=0,e=0;e<this.values.length;e++)t+=this.values[e];this.mean=t/this.values.length,this.dirty=!1}return this.mean}return 0},t}();t.WindowedMean=d}(XK||(XK={})),Math.fround||(Math.fround=(zK=new Float32Array(1),function(t){return zK[0]=t,zK[0]})),function(t){var e=function(t){if(null==t)throw new Error("name cannot be null.");this.name=t};t.Attachment=e;var i=function(e){function i(t){var n=e.call(this,t)||this;return n.id=(65535&i.nextID++)<<11,n.worldVerticesLength=0,n.deformAttachment=n,n}return WK(i,e),i.prototype.computeWorldVertices=function(t,e,i,n,r,s){i=r+(i>>1)*s;var a=t.bone.skeleton,o=t.deform,h=this.vertices,l=this.bones;if(null!=l){for(var u=0,c=0,d=0;d<e;d+=2)u+=(g=l[u])+1,c+=g;var _=a.bones;if(0==o.length)for(w=r,C=3*c;w<i;w+=s){var f=0,p=0,g=l[u++];for(g+=u;u<g;u++,C+=3){T=_[l[u]],M=h[C],I=h[C+1];var m=h[C+2];f+=(M*T.a+I*T.b+T.worldX)*m,p+=(M*T.c+I*T.d+T.worldY)*m}n[w]=f,n[w+1]=p}else for(var v=o,y=(w=r,C=3*c,c<<1);w<i;w+=s){for(f=0,p=0,g=l[u++],g+=u;u<g;u++,C+=3,y+=2)T=_[l[u]],M=h[C]+v[y],I=h[C+1]+v[y+1],m=h[C+2],f+=(M*T.a+I*T.b+T.worldX)*m,p+=(M*T.c+I*T.d+T.worldY)*m;n[w]=f,n[w+1]=p}}else{o.length>0&&(h=o);for(var T,S=(T=t.bone).worldX,E=T.worldY,A=T.a,C=T.b,R=T.c,b=T.d,x=e,w=r;w<i;x+=2,w+=s){var M=h[x],I=h[x+1];n[w]=M*A+I*C+S,n[w+1]=M*R+I*b+E}}},i.prototype.copyTo=function(e){null!=this.bones?(e.bones=new Array(this.bones.length),t.Utils.arrayCopy(this.bones,0,e.bones,0,this.bones.length)):e.bones=null,null!=this.vertices?(e.vertices=t.Utils.newFloatArray(this.vertices.length),t.Utils.arrayCopy(this.vertices,0,e.vertices,0,this.vertices.length)):e.vertices=null,e.worldVerticesLength=this.worldVerticesLength,e.deformAttachment=this.deformAttachment},i.nextID=0,i}(e);t.VertexAttachment=i}(XK||(XK={})),function(t){var e;(e=t.AttachmentType||(t.AttachmentType={}))[e.Region=0]="Region",e[e.BoundingBox=1]="BoundingBox",e[e.Mesh=2]="Mesh",e[e.LinkedMesh=3]="LinkedMesh",e[e.Path=4]="Path",e[e.Point=5]="Point",e[e.Clipping=6]="Clipping"}(XK||(XK={})),function(t){var e=function(e){function i(i){var n=e.call(this,i)||this;return n.color=new t.Color(1,1,1,1),n}return WK(i,e),i.prototype.copy=function(){var t=new i(this.name);return this.copyTo(t),t.color.setFromColor(this.color),t},i}(t.VertexAttachment);t.BoundingBoxAttachment=e}(XK||(XK={})),function(t){var e=function(e){function i(i){var n=e.call(this,i)||this;return n.color=new t.Color(.2275,.2275,.8078,1),n}return WK(i,e),i.prototype.copy=function(){var t=new i(this.name);return this.copyTo(t),t.endSlot=this.endSlot,t.color.setFromColor(this.color),t},i}(t.VertexAttachment);t.ClippingAttachment=e}(XK||(XK={})),function(t){var e=function(e){function i(i){var n=e.call(this,i)||this;return n.color=new t.Color(1,1,1,1),n.tempColor=new t.Color(0,0,0,0),n}return WK(i,e),i.prototype.updateUVs=function(){var e=this.regionUVs;null!=this.uvs&&this.uvs.length==e.length||(this.uvs=t.Utils.newFloatArray(e.length));var i=this.uvs,n=this.uvs.length,r=this.region.u,s=this.region.v,a=0,o=0;if(this.region instanceof t.TextureAtlasRegion){var h=this.region,l=h.texture.getImage().width,u=h.texture.getImage().height;switch(h.degrees){case 90:r-=(h.originalHeight-h.offsetY-h.height)/l,s-=(h.originalWidth-h.offsetX-h.width)/u,a=h.originalHeight/l,o=h.originalWidth/u;for(var c=0;c<n;c+=2)i[c]=r+e[c+1]*a,i[c+1]=s+(1-e[c])*o;return;case 180:for(r-=(h.originalWidth-h.offsetX-h.width)/l,s-=h.offsetY/u,a=h.originalWidth/l,o=h.originalHeight/u,c=0;c<n;c+=2)i[c]=r+(1-e[c])*a,i[c+1]=s+(1-e[c+1])*o;return;case 270:for(r-=h.offsetY/l,s-=h.offsetX/u,a=h.originalHeight/l,o=h.originalWidth/u,c=0;c<n;c+=2)i[c]=r+(1-e[c+1])*a,i[c+1]=s+e[c]*o;return}r-=h.offsetX/l,s-=(h.originalHeight-h.offsetY-h.height)/u,a=h.originalWidth/l,o=h.originalHeight/u}else null==this.region?(r=s=0,a=o=1):(a=this.region.u2-r,o=this.region.v2-s);for(c=0;c<n;c+=2)i[c]=r+e[c]*a,i[c+1]=s+e[c+1]*o},i.prototype.getParentMesh=function(){return this.parentMesh},i.prototype.setParentMesh=function(t){this.parentMesh=t,null!=t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)},i.prototype.copy=function(){if(null!=this.parentMesh)return this.newLinkedMesh();var e=new i(this.name);return e.region=this.region,e.path=this.path,e.color.setFromColor(this.color),this.copyTo(e),e.regionUVs=new Array(this.regionUVs.length),t.Utils.arrayCopy(this.regionUVs,0,e.regionUVs,0,this.regionUVs.length),e.uvs=new Array(this.uvs.length),t.Utils.arrayCopy(this.uvs,0,e.uvs,0,this.uvs.length),e.triangles=new Array(this.triangles.length),t.Utils.arrayCopy(this.triangles,0,e.triangles,0,this.triangles.length),e.hullLength=this.hullLength,null!=this.edges&&(e.edges=new Array(this.edges.length),t.Utils.arrayCopy(this.edges,0,e.edges,0,this.edges.length)),e.width=this.width,e.height=this.height,e},i.prototype.newLinkedMesh=function(){var t=new i(this.name);return t.region=this.region,t.path=this.path,t.color.setFromColor(this.color),t.deformAttachment=this.deformAttachment,t.setParentMesh(null!=this.parentMesh?this.parentMesh:this),t.updateUVs(),t},i}(t.VertexAttachment);t.MeshAttachment=e}(XK||(XK={})),function(t){var e=function(e){function i(i){var n=e.call(this,i)||this;return n.closed=!1,n.constantSpeed=!1,n.color=new t.Color(1,1,1,1),n}return WK(i,e),i.prototype.copy=function(){var e=new i(this.name);return this.copyTo(e),e.lengths=new Array(this.lengths.length),t.Utils.arrayCopy(this.lengths,0,e.lengths,0,this.lengths.length),e.closed=closed,e.constantSpeed=this.constantSpeed,e.color.setFromColor(this.color),e},i}(t.VertexAttachment);t.PathAttachment=e}(XK||(XK={})),function(t){var e=function(e){function i(i){var n=e.call(this,i)||this;return n.color=new t.Color(.38,.94,0,1),n}return WK(i,e),i.prototype.computeWorldPosition=function(t,e){return e.x=this.x*t.a+this.y*t.b+t.worldX,e.y=this.x*t.c+this.y*t.d+t.worldY,e},i.prototype.computeWorldRotation=function(e){var i=t.MathUtils.cosDeg(this.rotation),n=t.MathUtils.sinDeg(this.rotation),r=i*e.a+n*e.b,s=i*e.c+n*e.d;return Math.atan2(s,r)*t.MathUtils.radDeg},i.prototype.copy=function(){var t=new i(this.name);return t.x=this.x,t.y=this.y,t.rotation=this.rotation,t.color.setFromColor(this.color),t},i}(t.VertexAttachment);t.PointAttachment=e}(XK||(XK={})),function(t){var e=function(e){function i(i){var n=e.call(this,i)||this;return n.x=0,n.y=0,n.scaleX=1,n.scaleY=1,n.rotation=0,n.width=0,n.height=0,n.color=new t.Color(1,1,1,1),n.offset=t.Utils.newFloatArray(8),n.uvs=t.Utils.newFloatArray(8),n.tempColor=new t.Color(1,1,1,1),n}return WK(i,e),i.prototype.updateOffset=function(){var t=this.width/this.region.originalWidth*this.scaleX,e=this.height/this.region.originalHeight*this.scaleY,n=-this.width/2*this.scaleX+this.region.offsetX*t,r=-this.height/2*this.scaleY+this.region.offsetY*e,s=n+this.region.width*t,a=r+this.region.height*e,o=this.rotation*Math.PI/180,h=Math.cos(o),l=Math.sin(o),u=n*h+this.x,c=n*l,d=r*h+this.y,_=r*l,f=s*h+this.x,p=s*l,g=a*h+this.y,m=a*l,v=this.offset;v[i.OX1]=u-_,v[i.OY1]=d+c,v[i.OX2]=u-m,v[i.OY2]=g+c,v[i.OX3]=f-m,v[i.OY3]=g+p,v[i.OX4]=f-_,v[i.OY4]=d+p},i.prototype.setRegion=function(t){this.region=t;var e=this.uvs;t.rotate?(e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v,e[0]=t.u2,e[1]=t.v2):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)},i.prototype.computeWorldVertices=function(t,e,n,r){var s=this.offset,a=t.worldX,o=t.worldY,h=t.a,l=t.b,u=t.c,c=t.d,d=0,_=0;d=s[i.OX1],_=s[i.OY1],e[n]=d*h+_*l+a,e[n+1]=d*u+_*c+o,n+=r,d=s[i.OX2],_=s[i.OY2],e[n]=d*h+_*l+a,e[n+1]=d*u+_*c+o,n+=r,d=s[i.OX3],_=s[i.OY3],e[n]=d*h+_*l+a,e[n+1]=d*u+_*c+o,n+=r,d=s[i.OX4],_=s[i.OY4],e[n]=d*h+_*l+a,e[n+1]=d*u+_*c+o},i.prototype.copy=function(){var e=new i(this.name);return e.region=this.region,e.rendererObject=this.rendererObject,e.path=this.path,e.x=this.x,e.y=this.y,e.scaleX=this.scaleX,e.scaleY=this.scaleY,e.rotation=this.rotation,e.width=this.width,e.height=this.height,t.Utils.arrayCopy(this.uvs,0,e.uvs,0,8),t.Utils.arrayCopy(this.offset,0,e.offset,0,8),e.color.setFromColor(this.color),e},i.OX1=0,i.OY1=1,i.OX2=2,i.OY2=3,i.OX3=4,i.OY3=5,i.OX4=6,i.OY4=7,i.X1=0,i.Y1=1,i.C1R=2,i.C1G=3,i.C1B=4,i.C1A=5,i.U1=6,i.V1=7,i.X2=8,i.Y2=9,i.C2R=10,i.C2G=11,i.C2B=12,i.C2A=13,i.U2=14,i.V2=15,i.X3=16,i.Y3=17,i.C3R=18,i.C3G=19,i.C3B=20,i.C3A=21,i.U3=22,i.V3=23,i.X4=24,i.Y4=25,i.C4R=26,i.C4G=27,i.C4B=28,i.C4A=29,i.U4=30,i.V4=31,i}(t.Attachment);t.RegionAttachment=e}(XK||(XK={})),function(t){var e=function(){function e(t,e){this.jitterX=0,this.jitterY=0,this.jitterX=t,this.jitterY=e}return e.prototype.begin=function(){},e.prototype.transform=function(e){e.x+=t.MathUtils.randomTriangular(-this.jitterX,this.jitterY),e.y+=t.MathUtils.randomTriangular(-this.jitterX,this.jitterY)},e.prototype.end=function(){},e}();t.JitterEffect=e}(XK||(XK={})),function(t){var e=function(){function e(t,e){this.centerX=0,this.centerY=0,this.radius=0,this.angle=0,this.worldX=0,this.worldY=0,this.radius=t,this.interpolation=e}return e.prototype.begin=function(t){this.worldX=t.x+this.centerX,this.worldY=t.y+this.centerY},e.prototype.transform=function(e){var i=this.angle*t.MathUtils.degreesToRadians,n=e.x-this.worldX,r=e.y-this.worldY,s=Math.sqrt(n*n+r*r);if(s<this.radius){var a=this.interpolation.apply(0,i,(this.radius-s)/this.radius),o=Math.cos(a),h=Math.sin(a);e.x=o*n-h*r+this.worldX,e.y=h*n+o*r+this.worldY}},e.prototype.end=function(){},e.interpolation=new t.PowOut(2),e}();t.SwirlEffect=e}(XK||(XK={}));var jK,KK,qK,ZK,QK,JK,$K=XK,tq=function(){function t(){this.start=void 0,this.interrupt=void 0,this.end=void 0,this.dispose=void 0,this.complete=void 0,this.event=void 0}return t.getListeners=function(e){return e.listener||(e.listener=new t),e.listener},t}(),eq=1/60,iq=[],nq=[],rq=0,sq=0,aq=0,oq=null,hq=null,lq=0,uq=0,cq=0,dq=0,_q=null,fq=null,pq=0,gq=0,mq=new $K.Color(1,1,1,1),vq=new $K.Color(1,1,1,1),yq=[0,1,2,2,3,0],Tq=function(){function t(){this.frames=[],this.totalTime=0,this.isCompleted=!1,this.maxVertexCount=0,this.maxIndexCount=0,this._privateMode=!1,this._inited=!1,this._invalid=!0,this._enableCacheAttachedInfo=!1,this._frameIdx=-1,this._skeletonInfo=null,this._animationName=null,this._tempSegments=null,this._tempColors=null,this._tempBoneInfos=null,this._privateMode=!1,this._inited=!1,this._invalid=!0,this._enableCacheAttachedInfo=!1,this.frames=[],this.totalTime=0,this._frameIdx=-1,this.isCompleted=!1,this._skeletonInfo=null,this._animationName=null,this._tempSegments=null,this._tempColors=null,this._tempBoneInfos=null}var e=t.prototype;return e.init=function(t,e){this._inited=!0,this._animationName=e,this._skeletonInfo=t},e.clear=function(){this._inited=!1;for(var t=0,e=this.frames.length;t<e;t++)this.frames[t].segments.length=0;this.invalidAllFrame()},e.bind=function(t){var e=this;t.complete=function(t){t&&t.animation.name===e._animationName&&(e.isCompleted=!0)}},e.unbind=function(t){t.complete=null},e.begin=function(){if(this._invalid){var t=this._skeletonInfo,e=null==t?void 0:t.curAnimationCache;e&&e!==this&&(this._privateMode?e.invalidAllFrame():e.updateToFrame());var i=null==t?void 0:t.skeleton,n=null==t?void 0:t.listener,r=null==t?void 0:t.state,s=null==i?void 0:i.data.findAnimation(this._animationName);null==r||r.setAnimationWith(0,s,!1),this.bind(n),t.curAnimationCache=this,this._frameIdx=-1,this.isCompleted=!1,this.totalTime=0,this._invalid=!1}},e.end=function(){this.needToUpdate()||(this._skeletonInfo.curAnimationCache=null,this.frames.length=this._frameIdx+1,this.isCompleted=!0,this.unbind(this._skeletonInfo.listener))},e.updateToFrame=function(t){if(this._inited&&(this.begin(),this.needToUpdate(t))){var e=this._skeletonInfo,i=null==e?void 0:e.skeleton,n=null==e?void 0:e.clipper,r=null==e?void 0:e.state;do{null==i||i.update(eq),null==r||r.update(eq),null==r||r.apply(i),null==i||i.updateWorldTransform(),this._frameIdx++,this.updateFrame(i,n,this._frameIdx),this.totalTime+=eq}while(this.needToUpdate(t));this.end()}},e.isInited=function(){return this._inited},e.isInvalid=function(){return this._invalid},e.invalidAllFrame=function(){this.isCompleted=!1,this._invalid=!0},e.updateAllFrame=function(){this.invalidAllFrame(),this.updateToFrame()},e.enableCacheAttachedInfo=function(){this._enableCacheAttachedInfo||(this._enableCacheAttachedInfo=!0,this.invalidAllFrame())},e.fillVertices=function(t,e,i,n,r){if(ZK=i.a*e.a*t.a*255,jK=e.r*t.r*255,KK=e.g*t.g*255,qK=e.b*t.b*255,mq.r=jK*i.r,mq.g=KK*i.g,mq.b=qK*i.b,mq.a=ZK,null==r.darkColor?vq.set(0,0,0,0):(vq.r=r.darkColor.r*jK,vq.g=r.darkColor.g*KK,vq.b=r.darkColor.b*qK,vq.a=0),QK=(mq.a<<24>>>0)+(mq.b<<16)+(mq.g<<8)+mq.r,JK=(vq.a<<24>>>0)+(vq.b<<16)+(vq.g<<8)+vq.r,_q!==QK||fq!==JK){var s=this._tempColors;_q=QK,fq=JK,dq>0&&(s[dq-1].vfOffset=aq),s[dq++]={fr:mq.r,fg:mq.g,fb:mq.b,fa:mq.a,dr:vq.r,dg:vq.g,db:vq.b,da:vq.a,vfOffset:0}}if(n.isClipping()){var a=nq.slice(sq,nq.length);n.clipTriangles(iq,pq,a,gq,iq,mq,vq,!0,6,aq,aq+2);var o=n.clippedVertices,h=n.clippedTriangles;gq=h.length,pq=o.length/12*6;for(var l=0,u=sq,c=h.length;l<c;)nq[u++]=h[l++];for(var d=0,_=o.length,f=aq;d<_;d+=12,f+=6)iq[f]=o[d],iq[f+1]=o[d+1],iq[f+2]=o[d+6],iq[f+3]=o[d+7],iq[f+4]=QK,iq[f+5]=JK}else for(var p=aq,g=aq+pq;p<g;p+=6)iq[p+4]=QK,iq[p+5]=JK},e.updateFrame=function(t,e,i){aq=0,rq=0,sq=0,oq=null,hq=null,lq=0,uq=0,cq=0,dq=0,_q=null,fq=null,this.frames[i]=this.frames[i]||{segments:[],colors:[],boneInfos:[],vertices:null,uintVert:null,indices:null};var n=this.frames[i],r=this._tempSegments=n.segments,s=this._tempColors=n.colors,a=this._tempBoneInfos=n.boneInfos;this.traverseSkeleton(t,e),dq>0&&(s[dq-1].vfOffset=aq),s.length=dq,a.length=rq;var o=cq-1;if(o>=0)if(uq>0){var h=r[o];h.indexCount=uq,h.vfCount=7*lq,h.vertexCount=lq,r.length=cq}else r.length=cq-1;if(0!==r.length){var l=n.vertices,u=aq/6,c=7*u;(!l||l.length<c)&&(l=n.vertices=new Float32Array(c));for(var d=new Uint32Array(l.buffer),_=0,f=0;_<c;)l[_]=iq[f++],l[_+1]=iq[f++],l[_+3]=iq[f++],l[_+4]=iq[f++],d[_+5]=iq[f++],d[_+6]=iq[f++],_+=7;var p=n.indices;(!p||p.length<sq)&&(p=n.indices=new Uint16Array(sq));for(var g=0;g<sq;g++)p[g]=nq[g];n.vertices=l,n.indices=p,this.maxVertexCount=u>this.maxVertexCount?u:this.maxVertexCount,this.maxIndexCount=p.length>this.maxIndexCount?p.length:this.maxIndexCount}},e.needToUpdate=function(t){return!this.isCompleted&&this.totalTime<30&&(void 0===t||this._frameIdx<t)},e.traverseSkeleton=function(t,e){var i,n,r,s,a,o,h,l,u,c,d,_,f=this._tempSegments,p=this._tempBoneInfos,g=t.color,m=t.bones;if(this._enableCacheAttachedInfo)for(var v=0,y=m.length;v<y;v++,rq++){var T=m[v],S=p[rq];S||(S=p[rq]={}),S.a=T.a,S.b=T.b,S.c=T.c,S.d=T.d,S.worldX=T.worldX,S.worldY=T.worldY}for(var E=0,A=t.drawOrder.length;E<A;E++)if((_=t.drawOrder[E]).bone.active)if(pq=0,gq=0,i=_.getAttachment())if(o=i instanceof $K.RegionAttachment,h=i instanceof $K.MeshAttachment,i instanceof $K.ClippingAttachment)e.clipStart(_,i);else if(o||h)if(l=i.region.texture.getRealTexture()){if(d=_.data.blendMode,oq===l.getId()&&hq===d||(oq=l.getId(),hq=d,(u=cq-1)>=0&&(uq>0?((c=f[u]).indexCount=uq,c.vertexCount=lq,c.vfCount=7*lq):cq--),f[cq]={tex:l,blendMode:d,indexCount:0,vertexCount:0,vfCount:0},cq++,uq=0,lq=0),o)a=yq,pq=24,gq=6,i.computeWorldVertices(_.bone,iq,aq,6);else if(h){var C=i;a=C.triangles,pq=6*(C.worldVerticesLength>>1),gq=a.length,C.computeWorldVertices(_,0,C.worldVerticesLength,iq,aq,6)}if(0!==pq&&0!==gq){for(var R=0,b=sq,x=a.length;R<x;)nq[b++]=a[R++];s=i.uvs;for(var w=aq,M=aq+pq,I=0;w<M;w+=6,I+=2)iq[w+2]=s[I],iq[w+3]=s[I+1];if(n=i.color,r=_.color,this.fillVertices(g,n,r,e,_),gq>0){for(var B=sq,P=sq+gq;B<P;B++)nq[B]+=lq;sq+=gq,aq+=pq,uq+=gq,lq+=pq/6}e.clipEndWithSlot(_)}else e.clipEndWithSlot(_)}else e.clipEndWithSlot(_);else e.clipEndWithSlot(_);else e.clipEndWithSlot(_);e.clipEnd()},t}(),Sq=function(){function t(){this._privateMode=void 0,this._skeletonCache=void 0,this._animationPool=void 0,this._privateMode=!1,this._animationPool={},this._skeletonCache={}}var e=t.prototype;return e.enablePrivateMode=function(){this._privateMode=!0},e.clear=function(){this._animationPool={},this._skeletonCache={}},e.removeSkeleton=function(t){var e=this._skeletonCache[t];if(e){var i=e.animationsCache;for(var n in i){var r=i[n];r&&(this._animationPool[t+"#"+n]=r,r.clear())}delete this._skeletonCache[t]}},e.getSkeletonCache=function(t,e){var i=this._skeletonCache[t];if(!i){var n=new $K.Skeleton(e),r=new $K.SkeletonClipping,s=new $K.AnimationStateData(n.data),a=new $K.AnimationState(s),o=new tq;a.addListener(o),this._skeletonCache[t]=i={skeleton:n,clipper:r,state:a,listener:o,animationsCache:{},curAnimationCache:null}}return i},e.getAnimationCache=function(t,e){var i=this._skeletonCache[t];return i?i.animationsCache[e]:null},e.invalidAnimationCache=function(t){var e=this._skeletonCache[t];if(e&&e.skeleton){var i=e.animationsCache;for(var n in i)i[n].invalidAllFrame()}},e.initAnimationCache=function(t,e){if(!e)return null;var i=this._skeletonCache[t],n=i&&i.skeleton;if(!n)return null;if(!n.data.findAnimation(e))return null;var r=i.animationsCache,s=r[e];if(!s){var a=t+"#"+e;(s=this._animationPool[a])?delete this._animationPool[a]:(s=new Tq)._privateMode=this._privateMode,s.init(i,e),r[e]=s}return s},e.updateAnimationCache=function(t,e){if(e){var i=this.initAnimationCache(t,e);if(!i)return;i.updateAllFrame()}else{var n=this._skeletonCache[t];if(!n||!n.skeleton)return;var r=n.animationsCache;for(var s in r)r[s].updateAllFrame()}},t}();Sq.FrameTime=eq,Sq.sharedCache=new Sq;var Eq,Aq,Cq,Rq,bq,xq,wq,Mq,Iq,Bq,Pq=new Ue,Dq=function(){function t(){this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null,this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null}var e=t.prototype;return e.init=function(t){this._inited=!0,this._skeleton=t._skeleton,this._skeletonNode=t.node,this._skeletonComp=t},e.reset=function(){this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null},e._syncAttachedNode=function(){if(this._inited){var t=this._skeletonComp.socketNodes;if(0!==t.size){var e;if(e=this._skeletonComp.isAnimationCached()?this._skeletonComp._curFrame&&this._skeletonComp._curFrame.boneInfos:this._skeleton.bones)for(var i,n=function(t,e){var i=Pq;i.m00=e.a,i.m01=e.c,i.m04=e.b,i.m05=e.d,i.m12=e.worldX,i.m13=e.worldY,t.matrix=Pq},r=Fi(t.keys());!(i=r()).done;){var s=i.value,a=t.get(s);if(a&&a.isValid){var o=e[s];o?n(a,o):(a.removeFromParent(),a.destroy(),t.delete(s))}else t.delete(s)}}}},t}(),Oq=function(t){function e(e){var i;return(i=t.call(this,e)||this).name="sp.SkeletonTexture",i._texture=null,i._material=null,i}He(e,t);var i=e.prototype;return i.setRealTexture=function(t){this._texture=t},i.getRealTexture=function(){return this._texture},i.setFilters=function(t,e){this._texture&&this.getRealTexture().setFilters(Fq(t),Fq(e))},i.setWraps=function(t,e){this._texture&&this.getRealTexture().setWrapMode(Lq(t),Lq(e))},i.dispose=function(){},e}($K.Texture);function Fq(t){switch(t){case $K.TextureFilter.Nearest:case $K.TextureFilter.MipMapNearestNearest:case $K.TextureFilter.MipMapLinearNearest:return Ii.NEAREST;case $K.TextureFilter.MipMap:case $K.TextureFilter.MipMapNearestLinear:case $K.TextureFilter.MipMapLinearLinear:case $K.TextureFilter.Linear:default:return Ii.LINEAR}}function Lq(t){switch(t){case $K.TextureWrap.MirroredRepeat:return Nr.MIRRORED_REPEAT;case $K.TextureWrap.ClampToEdge:return Nr.CLAMP_TO_EDGE;case $K.TextureWrap.Repeat:default:return Nr.REPEAT}}var Nq=(Eq=Ki("sp.SkeletonData"),Aq=Tn([Xe]),Cq=Tn([ns]),Eq((bq=function(t){function e(){var e;return(e=t.call(this)||this)._skeletonJson=xq&&xq(),e.textures=wq&&wq(),e.textureNames=Mq&&Mq(),e.scale=Iq&&Iq(),e._atlasText=Bq&&Bq(),e._buffer=void 0,e._skeletonCache=null,e._atlasCache=null,e._skinsEnum=null,e._animsEnum=null,e.reset(),e}He(e,t);var i=e.prototype;return i.createNode=function(t){var e=new Pr(this.name);return e.addComponent("cc.Skeleton").skeletonData=this,t(null,e)},i.reset=function(){this._skeletonCache=null,this._atlasCache=null},i.resetEnums=function(){},i.getRuntimeData=function(t){if(this._skeletonCache)return this._skeletonCache;if(!(this.textures&&this.textures.length>0)&&this.textureNames&&this.textureNames.length>0)return t||console.error(this.name+" no textures found!"),null;var e=this._getAtlas(t);if(!e)return null;var i=new $K.AtlasAttachmentLoader(e),n=null,r=null;return this.skeletonJson?(r=new $K.SkeletonJson(i),n=this.skeletonJson):(r=new $K.SkeletonBinary(i),n=new Uint8Array(this._nativeAsset)),r.scale=this.scale,this._skeletonCache=r.readSkeletonData(n),e.dispose(),this._skeletonCache},i.getSkinsEnum=function(){if(this._skinsEnum)return this._skinsEnum;var t=this.getRuntimeData(!0);if(t){for(var e=t.skins,i={},n=0;n<e.length;n++)i[e[n].name]=n;return this._skinsEnum=fr(i)}return null},i.getAnimsEnum=function(){if(this._animsEnum&&Object.keys(this._animsEnum).length>1)return this._animsEnum;var t=this.getRuntimeData(!0);if(t){for(var e={"<None>":0},i=t.animations,n=0;n<i.length;n++)e[i[n].name]=n+1;return this._animsEnum=fr(e)}return null},i.destroy=function(){return Sq.sharedCache.removeSkeleton(this._uuid),t.prototype.destroy.call(this)},i._getTexture=function(t){for(var e=this.textureNames,i=0;i<e.length;i++)if(e[i]===t){var n=this.textures[i],r=new Oq({width:n.width,height:n.height});return r.setRealTexture(n),r}return console.error(this.name+" no textures found!"),null},i._getAtlas=function(t){return this._atlasCache?this._atlasCache:this.atlasText?this._atlasCache=new $K.TextureAtlas(this.atlasText,this._getTexture.bind(this)):(t||console.error(this.name+" no atlas found!"),null)},Pi(e,[{key:"skeletonJsonStr",get:function(){return this._skeletonJson?JSON.stringify(this._skeletonJson):""}},{key:"skeletonJson",get:function(){return this._skeletonJson},set:function(t){this.reset(),this._skeletonJson="string"==typeof t?JSON.parse(t):t,!this._uuid&&t.skeleton&&(this._uuid=t.skeleton.hash)}},{key:"atlasText",get:function(){return this._atlasText},set:function(t){this._atlasText=t,this.reset()}},{key:"_nativeAsset",get:function(){return this._buffer},set:function(t){this._buffer=t,this.reset()}}]),e}($i),xq=tn(bq.prototype,"_skeletonJson",[en],(function(){return null})),wq=tn(bq.prototype,"textures",[en,Aq],(function(){return[]})),Mq=tn(bq.prototype,"textureNames",[en,Cq],(function(){return[]})),Iq=tn(bq.prototype,"scale",[en],(function(){return 1})),Bq=tn(bq.prototype,"_atlasText",[en],(function(){return""})),Rq=bq))||Rq);We.internal.SpineSkeletonData=Nq;var kq,Uq,Gq,Vq,Hq,zq,Xq,Wq,Yq,jq,Kq,qq,Zq,Qq,Jq,$q,tZ,eZ,iZ,nZ,rZ,sZ,aZ,oZ,hZ,lZ,uZ,cZ,dZ,_Z,fZ,pZ,gZ,mZ,vZ,yZ,TZ=function(t){function e(){var e;return(e=t.call(this)||this)._skeletons=new Set,e}He(e,t),e.getInstance=function(){return e._instance||(e._instance=new e,Di.registerSystem(e.ID,e._instance,Oi.Priority.HIGH)),e._instance};var i=e.prototype;return i.add=function(t){t&&(this._skeletons.has(t)||this._skeletons.add(t))},i.remove=function(t){t&&this._skeletons.has(t)&&this._skeletons.delete(t)},i.postUpdate=function(t){this._skeletons&&this._skeletons.forEach((function(e){e.updateAnimation(t)}))},i.prepareRenderData=function(){this._skeletons&&this._skeletons.forEach((function(t){t.markForUpdateRenderData()}))},e}(Oi);function SZ(t,e,i){ua.Attr.setClassAttr(t,e,"type","Enum"),ua.Attr.setClassAttr(t,e,"enumList",fr.getList(i))}TZ.ID="SKELETON",TZ._instance=void 0,We.internal.SpineSkeletonSystem=TZ,function(t){t[t.default=0]="default"}(gZ||(gZ={})),Fn(gZ),function(t){t[t["<None>"]=0]="<None>"}(mZ||(mZ={})),Fn(mZ),function(t){t[t.REALTIME=0]="REALTIME",t[t.SHARED_CACHE=1]="SHARED_CACHE",t[t.PRIVATE_CACHE=2]="PRIVATE_CACHE"}(vZ||(vZ={})),Fn(vZ),function(t){t[t.COLORED_TEXTURED=0]="COLORED_TEXTURED",t[t.TWO_COLORED=1]="TWO_COLORED"}(yZ||(yZ={}));var EZ=(kq=Ki("sp.Skeleton.SpineSocket"),Uq=Tn(Pr),kq((Vq=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),this.path=Hq&&Hq(),this.target=zq&&zq(),this.path=t,this.target=e},Hq=tn(Vq.prototype,"path",[en],(function(){return""})),zq=tn(Vq.prototype,"target",[Uq,en],(function(){return null})),Gq=Vq))||Gq);br(EZ,"sp.Skeleton.SpineSocket");var AZ=(Xq=Ki("sp.Skeleton"),Wq=Tn(Dn),Yq=Tn(Nq),jq=Tn(gZ),Kq=Tn(mZ),qq=Tn(vZ),Zq=Tn([EZ]),Xq((pZ=fZ=function(t){He(n,t);var e=n.prototype;function n(){var e;return(e=t.call(this)||this).loop=$q&&$q(),e._frameCache=null,e._curFrame=null,e._effectDelegate=null,e._skeleton=void 0,e._clipper=void 0,e._debugRenderer=void 0,e._startSlotIndex=void 0,e._endSlotIndex=void 0,e._startEntry=void 0,e._endEntry=void 0,e.attachUtil=void 0,e.maxVertexCount=0,e.maxIndexCount=0,e._materialCache={},e._enumSkins=fr({}),e._enumAnimations=fr({}),e._playTimes=0,e._timeScale=tZ&&tZ(),e._paused=!1,e._accTime=0,e._playCount=0,e._skeletonCache=null,e._animationName="",e._animationQueue=[],e._headAniInfo=null,e._isAniComplete=!0,e._needUpdateSkeltonData=!0,e._useTint=eZ&&eZ(),e._preCacheMode=iZ&&iZ(),e._cacheMode=nZ&&nZ(),e._defaultCacheMode=rZ&&rZ(),e._debugBones=sZ&&sZ(),e._debugSlots=aZ&&aZ(),e._skeletonData=oZ&&oZ(),e._premultipliedAlpha=hZ&&hZ(),e.defaultSkin=lZ&&lZ(),e.defaultAnimation=uZ&&uZ(),e._enableBatch=cZ&&cZ(),e._sockets=dZ&&dZ(),e._drawIdx=0,e._drawList=new i((function(){return{material:null,texture:null,indexOffset:0,indexCount:0}}),1),e._debugMesh=_Z&&_Z(),e._rootBone=void 0,e._state=void 0,e._listener=void 0,e._socketNodes=new Map,e._cachedSockets=new Map,e._drawInfoList=[],e._effectDelegate=null,e._skeleton=null,e._rootBone=null,e._listener=null,e._debugRenderer=null,e._startSlotIndex=-1,e._endSlotIndex=-1,e._startEntry={animation:{name:""},trackIndex:0},e._endEntry={animation:{name:""},trackIndex:0},e.attachUtil=new Dq,SZ(lr(e),"_defaultSkinIndex",e._enumSkins),SZ(lr(e),"_animationIndex",e._enumAnimations),e._useVertexOpacity=!0,e}return e._updateBuiltinMaterial=function(){return Nn.get("default-spine-material")},e.updateMaterial=function(){var t;t=this._customMaterial?this._customMaterial:this._updateBuiltinMaterial(),this.setMaterial(t,0),this._cleanMaterialCache()},e.requestDrawInfo=function(t){return this._drawInfoList[t]||(this._drawInfoList[t]=new Qh),this._drawInfoList[t]},e.setSkeletonData=function(t){var e=this.node._uiProps.uiTransformComp;if(null!=t.width&&null!=t.height&&e.setContentSize(t.width,t.height),this._cacheMode===vZ.SHARED_CACHE?this._skeletonCache=Sq.sharedCache:this._cacheMode===vZ.PRIVATE_CACHE&&(this._skeletonCache=new Sq,this._skeletonCache.enablePrivateMode()),this.isAnimationCached()){(this.debugBones||this.debugSlots)&&Gi("Debug bones or slots is invalid in cached mode");var i=this._skeletonCache.getSkeletonCache(this.skeletonData._uuid,t);this._skeleton=i.skeleton,this._clipper=i.clipper,this._rootBone=this._skeleton.getRootBone()}else this._skeleton=new $K.Skeleton(t),this._clipper=new $K.SkeletonClipping,this._rootBone=this._skeleton.getRootBone();this._flushAssembler()},e.setSlotsRange=function(t,e){this.isAnimationCached()?Gi("Slots visible range can not be modified in cached mode."):(this._startSlotIndex=t,this._endSlotIndex=e)},e.setAnimationStateData=function(t){if(this.isAnimationCached())Gi("'setAnimationStateData' interface can not be invoked in cached mode.");else{var e=new $K.AnimationState(t);this._listener&&(this._state&&this._state.removeListener(this._listener),e.addListener(this._listener)),this._state=e}},e.__preload=function(){t.prototype.__preload.call(this);for(var e=this.node.children,i=0,n=e.length;i<n;i++){var r=e[i];r&&"DEBUG_DRAW_NODE"===r.name&&r.destroy()}this._updateSkeletonData(),this._updateDebugDraw(),this._indexBoneSockets(),this._updateSocketBindings()},e.setAnimationCacheMode=function(t){this._preCacheMode!==t&&(this._cacheMode=t,this._needUpdateSkeltonData=!0,this._updateSkeletonData(),this._updateUseTint(),this._updateSocketBindings(),this.markForUpdateRenderData())},e.isAnimationCached=function(){return this._cacheMode!==vZ.REALTIME},e.updateAnimation=function(t){if(this.markForUpdateRenderData(),!this.paused)if(t*=1*this._timeScale,this.isAnimationCached()){if(this._isAniComplete){if(0===this._animationQueue.length&&!this._headAniInfo){var e=this._frameCache;if(e&&e.isInvalid()){e.updateToFrame();var i=e.frames;this._curFrame=i[i.length-1]}return}if(this._headAniInfo||(this._headAniInfo=this._animationQueue.shift()),this._accTime+=t,this._accTime>this._headAniInfo.delay){var n=this._headAniInfo;this._headAniInfo=null,this.setAnimation(0,n.animationName,n.loop)}return}this._updateCache(t)}else this._updateRealtime(t)},e.setVertexEffectDelegate=function(t){this._effectDelegate=t},e.setToSetupPose=function(){this._skeleton&&this._skeleton.setToSetupPose()},e.setBonesToSetupPose=function(){this._skeleton&&this._skeleton.setBonesToSetupPose()},e.setSlotsToSetupPose=function(){this._skeleton&&this._skeleton.setSlotsToSetupPose()},e.updateAnimationCache=function(t){if(this.isAnimationCached()){var e=this._skeletonData._uuid;this._skeletonCache&&this._skeletonCache.updateAnimationCache(e,t)}},e.invalidAnimationCache=function(){this.isAnimationCached()&&this._skeletonCache&&this._skeletonCache.invalidAnimationCache(this._skeletonData._uuid)},e.findBone=function(t){return this._skeleton?this._skeleton.findBone(t):null},e.findSlot=function(t){return this._skeleton?this._skeleton.findSlot(t):null},e.setSkin=function(t){this._skeleton&&(this._skeleton.setSkinByName(t),this._skeleton.setSlotsToSetupPose()),this.invalidAnimationCache()},e.getAttachment=function(t,e){return this._skeleton?this._skeleton.getAttachmentByName(t,e):null},e.setAttachment=function(t,e){this._skeleton&&this._skeleton.setAttachment(t,e),this.invalidAnimationCache()},e.getTextureAtlas=function(t){return t.region},e.setMix=function(t,e,i){this._state&&this._state.data.setMix(t,e,i)},e.setAnimation=function(t,e,i){if(this._playTimes=i?0:1,this._animationName=e,this.isAnimationCached()){if(0!==t&&Gi("Track index can not greater than 0 in cached mode."),!this._skeletonCache)return null;var n=this._skeletonCache.getAnimationCache(this._skeletonData._uuid,e);n||(n=this._skeletonCache.initAnimationCache(this._skeletonData._uuid,e)),n&&(this._isAniComplete=!1,this._accTime=0,this._playCount=0,this._frameCache=n,this._socketNodes.size>0&&this._frameCache.enableCacheAttachedInfo(),this._frameCache.updateToFrame(0),this._curFrame=this._frameCache.frames[0])}else if(this._skeleton){var r=this._skeleton.data.findAnimation(e);if(!r)return kr(7509,e),null;var s=this._state.setAnimationWith(t,r,i);return this._state.apply(this._skeleton),s}return null},e.addAnimation=function(t,e,i,n){if(n=n||0,this.isAnimationCached())0!==t&&Gi("Track index can not greater than 0 in cached mode."),this._animationQueue.push({animationName:e,loop:i,delay:n});else if(this._skeleton){var r,s=this._skeleton.data.findAnimation(e);return s?null===(r=this._state)||void 0===r?void 0:r.addAnimationWith(t,s,i,n):(kr(7510,e),null)}return null},e.findAnimation=function(t){return this._skeleton?this._skeleton.data.findAnimation(t):null},e.getCurrent=function(t){if(this.isAnimationCached())Gi("'getCurrent' interface can not be invoked in cached mode.");else if(this._state)return this._state.getCurrent(t);return null},e.clearTracks=function(){this.isAnimationCached()?Gi("'clearTracks' interface can not be invoked in cached mode."):this._state&&(this._state.clearTracks(),this.setToSetupPose())},e.clearTrack=function(t){this.isAnimationCached()?Gi("'clearTrack' interface can not be invoked in cached mode."):this._state&&this._state.clearTrack(t)},e.setStartListener=function(t){this._ensureListener(),this._listener.start=t},e.setInterruptListener=function(t){this._ensureListener(),this._listener.interrupt=t},e.setEndListener=function(t){this._ensureListener(),this._listener.end=t},e.setDisposeListener=function(t){this._ensureListener(),this._listener.dispose=t},e.setCompleteListener=function(t){this._ensureListener(),this._listener.complete=t},e.setEventListener=function(t){this._ensureListener(),this._listener.event=t},e.setTrackStartListener=function(t,e){tq.getListeners(t).start=e},e.setTrackInterruptListener=function(t,e){tq.getListeners(t).interrupt=e},e.setTrackEndListener=function(t,e){tq.getListeners(t).end=e},e.setTrackDisposeListener=function(t,e){tq.getListeners(t).dispose=e},e.setTrackCompleteListener=function(t,e){tq.getListeners(t).complete=function(t){var i=Math.floor(t.trackTime/t.animationEnd);e(t,i)}},e.setTrackEventListener=function(t,e){tq.getListeners(t).event=e},e.getState=function(){return this._state},e.onEnable=function(){t.prototype.onEnable.call(this),this._flushAssembler(),TZ.getInstance().add(this)},e.onDisable=function(){t.prototype.onDisable.call(this),TZ.getInstance().remove(this)},e.onDestroy=function(){this._cleanMaterialCache(),this._drawList.destroy(),t.prototype.onDestroy.call(this)},e.destroyRenderData=function(){this._drawList.reset(),t.prototype.destroyRenderData.call(this)},e.getMaterialTemplate=function(){return null!==this.customMaterial?this.customMaterial:(this.material||this.updateMaterial(),this.material)},e.getMaterialForBlendAndTint=function(t,e,i){var n=i+"/"+t+"/"+e,r=this._materialCache[n];if(r)return r;var s=this.getMaterialTemplate();r=new On({parent:s,subModelIdx:0,owner:this}),this._materialCache[n]=r,r.overridePipelineStates({blendState:{blendColor:Ve.WHITE,targets:[{blendEq:B.ADD,blendAlphaEq:B.ADD,blendSrc:t,blendDst:e,blendSrcAlpha:t,blendDstAlpha:e}]}});var a=!1;i===yZ.TWO_COLORED&&(a=!0);var o=!this._enableBatch;return r.recompileShaders({TWO_COLORED:a,USE_LOCAL:o}),r},e.onRestore=function(){this.updateMaterial(),this.markForUpdateRenderData()},e.querySockets=function(){return this._skeleton?(0===this._cachedSockets.size&&this._indexBoneSockets(),this._cachedSockets.size>0?Array.from(this._cachedSockets.keys()).sort():[]):[]},e._requestDrawData=function(t,e,i,n){var r=this._drawList.add();return r.material=t,r.texture=e,r.indexOffset=i,r.indexCount=n,r},e._render=function(t){var e=0;if(this.renderData&&this._drawList){for(var i=this.renderData,n=i.chunk,r=n.vertexAccessor,s=i.getMeshBuffer(),a=s.indexOffset,o=0;o<this._drawList.length;o++){this._drawIdx=o;var h=this._drawList.data[o];h.texture&&t.commitMiddleware(this,s,a+h.indexOffset,h.indexCount,h.texture,h.material,this._enableBatch),e+=h.indexCount}var l=i.indices.subarray(0,e);r.appendIndices(n.bufferId,l)}},e.updateWorldTransform=function(){this.isAnimationCached()&&this._skeleton&&this._skeleton.updateWorldTransform()},e._emitCacheCompleteEvent=function(){this._listener&&(this._endEntry.animation.name=this._animationName,this._listener.complete&&this._listener.complete(this._endEntry),this._listener.end&&this._listener.end(this._endEntry))},e._updateCache=function(t){var e=this._frameCache;if(e.isInited()){var i=e.frames,n=Sq.FrameTime;0===this._accTime&&0===this._playCount&&(this._startEntry.animation.name=this._animationName,this._listener&&this._listener.start&&this._listener.start(this._startEntry)),this._accTime+=t;var r=Math.floor(this._accTime/n);if(e.isCompleted||(e.updateToFrame(r),this.renderData&&(this.renderData.vertexCount<e.maxVertexCount||this.renderData.indexCount<e.maxIndexCount)&&(this.maxVertexCount=e.maxVertexCount>this.maxVertexCount?e.maxVertexCount:this.maxVertexCount,this.maxIndexCount=e.maxIndexCount>this.maxIndexCount?e.maxIndexCount:this.maxIndexCount,this.renderData.resize(this.maxVertexCount,this.maxIndexCount),(!this.renderData.indices||this.maxIndexCount>this.renderData.indices.length)&&(this.renderData.indices=new Uint16Array(this.maxIndexCount)))),e.isCompleted&&r>=i.length){if(this._playCount++,this._playTimes>0&&this._playCount>=this._playTimes)return this._curFrame=i[i.length-1],this._accTime=0,this._playCount=0,this._isAniComplete=!0,void this._emitCacheCompleteEvent();this._accTime=0,r=0,this._emitCacheCompleteEvent()}this._curFrame=i[r]}},e._updateRealtime=function(t){var e=this._skeleton,i=this._state;e&&(e.update(t),i&&(i.update(t),i.apply(e)))},e._indexBoneSockets=function(){if(this._skeleton){this._cachedSockets.clear();for(var t=this._skeleton.bones,e=function e(i){return null==i.parent?i.data.name||"<Unamed>":e(t[i.parent.data.index])+"/"+i.data.name},i=0,n=t.length;i<n;i++){var r=t[i].data,s=e(t[i]);this._cachedSockets.set(s,r.index)}}},e._updateUseTint=function(){this._cleanMaterialCache(),this.destroyRenderData(),this._assembler&&this._skeleton&&(this._renderData=this._assembler.createData(this),this.markForUpdateRenderData())},e._updateBatch=function(){this._cleanMaterialCache(),this.markForUpdateRenderData()},e._updateAnimEnum=function(){var t;t=this.skeletonData?this.skeletonData.getAnimsEnum():mZ,this._enumAnimations=fr({}),Object.assign(this._enumAnimations,t),fr.update(this._enumAnimations),SZ(this,"_animationIndex",this._enumAnimations)},e._updateSkinEnum=function(){var t;t=this.skeletonData?this.skeletonData.getSkinsEnum():gZ,this._enumSkins=fr({}),Object.assign(this._enumSkins,t),fr.update(this._enumSkins),SZ(this,"_defaultSkinIndex",this._enumSkins)},e._ensureListener=function(){this._listener||(this._listener=new tq,this._state&&this._state.addListener(this._listener))},e._updateSkeletonData=function(){if(this.skeletonData&&!1!==this._needUpdateSkeltonData){this._needUpdateSkeltonData=!1;var t=this.skeletonData.getRuntimeData();if(t){try{this.setSkeletonData(t),this.isAnimationCached()||this.setAnimationStateData(new $K.AnimationStateData(this._skeleton.data)),this.defaultSkin&&this.setSkin(this.defaultSkin)}catch(t){Gi(t)}this._indexBoneSockets(),this.attachUtil.init(this),this._preCacheMode=this._cacheMode,this.animation=this.defaultAnimation}}},e._refreshInspector=function(){this._updateAnimEnum(),this._updateSkinEnum()},e._updateDebugDraw=function(){if(this.debugBones||this.debugSlots||this.debugMesh){if(!this._debugRenderer){var t=new Pr("DEBUG_DRAW_NODE");t.hideFlags|=Dr.Flags.DontSave|Dr.Flags.HideInHierarchy;var e=t.addComponent(yd);e.lineWidth=1,e.strokeColor=new Ve(255,0,0,255),this._debugRenderer=e,t.parent=this.node}this.isAnimationCached()&&Gi("Debug bones or slots is invalid in cached mode")}else this._debugRenderer&&(this._debugRenderer.node.destroy(),this._debugRenderer=null)},e._flushAssembler=function(){var t=n.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._skeleton&&this._assembler&&(this._renderData=this._assembler.createData(this),this.markForUpdateRenderData(),this._updateColor())},e._updateSocketBindings=function(){if(this._skeleton){this._socketNodes.clear();for(var t=0,e=this._sockets.length;t<e;t++){var i=this._sockets[t];if(i.path&&i.target){var n=this._cachedSockets.get(i.path);if(!n){console.error("Skeleton data does not contain path "+i.path);continue}this._socketNodes.set(n,i.target)}}}},e._verifySockets=function(t){for(var e=0,i=t.length;e<i;e++){var n=t[e].target;!n||n.parent&&n.parent===this.node||console.error("Target node "+n.name+" is expected to be a direct child of "+this.node.name)}var r=new Map;t.forEach((function(t){t.target&&(r.get(t.target)?console.error("Target node "+t.target.name+" has existed."):r.set(t.target,!0))}))},e._cleanMaterialCache=function(){for(var t in this._materialCache)this._materialCache[t].destroy();this._materialCache={}},e.createRenderEntity=function(){var t=new ml(Jh.DYNAMIC);return t.setUseLocal(!0),t},e.markForUpdateRenderData=function(e){void 0===e&&(e=!0),t.prototype.markForUpdateRenderData.call(this,e),this._debugRenderer&&this._debugRenderer.markForUpdateRenderData(e)},Pi(n,[{key:"drawList",get:function(){return this._drawList}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this.updateMaterial(),this.markForUpdateRenderData()}},{key:"paused",get:function(){return this._paused},set:function(t){this._paused=t}},{key:"skeletonData",get:function(){return this._skeletonData},set:function(t){t&&t.resetEnums(),this._skeletonData!==t&&(this.destroyRenderData(),this._skeletonData=t,this._needUpdateSkeltonData=!0,this.defaultSkin="",this.defaultAnimation="",this._updateSkeletonData())}},{key:"animation",get:function(){if(this.isAnimationCached())return this._animationName;var t=this.getCurrent(0);return t&&t.animation.name||""},set:function(t){t?(this.setAnimation(0,t,this.loop),this.markForUpdateRenderData()):this.isAnimationCached()||(this.clearTrack(0),this.setToSetupPose())}},{key:"_defaultSkinIndex",get:function(){if(this.skeletonData){var t=this.skeletonData.getSkinsEnum();if(t)if(""===this.defaultSkin){if(t.hasOwnProperty(0))return this._defaultSkinIndex=0,0}else{var e=t[this.defaultSkin];if(void 0!==e)return e}}return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getSkinsEnum()),e){var i=e[t];void 0!==i?(this.defaultSkin=i,this.setSkin(this.defaultSkin)):console.error(this.name+" skin enums are invalid")}else console.error(this.name+" skin enums are invalid")}},{key:"_animationIndex",get:function(){var t=this.animation;if(this.skeletonData)if(t){var e=this.skeletonData.getAnimsEnum();if(e){var i=e[t];if(void 0!==i)return i}}else this._refreshInspector();return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getAnimsEnum()),e){var i=e[t];void 0!==i?(this.animation=i,this.animation=i):console.error(this.name+" animation enums are invalid")}else console.error(this.name+" animation enums are invalid")}},{key:"defaultCacheMode",get:function(){return this._defaultCacheMode},set:function(t){this._defaultCacheMode=t,this.setAnimationCacheMode(this._defaultCacheMode)}},{key:"premultipliedAlpha",get:function(){return this._premultipliedAlpha},set:function(t){t!==this._premultipliedAlpha&&(this._premultipliedAlpha=t,this.markForUpdateRenderData())}},{key:"timeScale",get:function(){return this._timeScale},set:function(t){t!==this._timeScale&&(this._timeScale=t)}},{key:"debugSlots",get:function(){return this._debugSlots},set:function(t){t!==this._debugSlots&&(this._debugSlots=t,this._updateDebugDraw(),this.markForUpdateRenderData())}},{key:"debugBones",get:function(){return this._debugBones},set:function(t){t!==this._debugBones&&(this._debugBones=t,this._updateDebugDraw(),this.markForUpdateRenderData())}},{key:"debugMesh",get:function(){return this._debugMesh},set:function(t){t!==this._debugMesh&&(this._debugMesh=t,this._updateDebugDraw(),this.markForUpdateRenderData())}},{key:"useTint",get:function(){return this._useTint},set:function(t){t!==this._useTint&&(this._useTint=t,this._updateUseTint())}},{key:"enableBatch",get:function(){return this._enableBatch},set:function(t){t!==this._enableBatch&&(this._enableBatch=t,this._updateBatch())}},{key:"sockets",get:function(){return this._sockets},set:function(t){this._sockets=t,this._updateSocketBindings(),this.attachUtil._syncAttachedNode()}},{key:"socketNodes",get:function(){return this._socketNodes}}]),n}(wu),fZ.SpineSocket=EZ,fZ.AnimationCacheMode=vZ,gn((Jq=pZ).prototype,"customMaterial",[mn,Wq],Object.getOwnPropertyDescriptor(Jq.prototype,"customMaterial"),Jq.prototype),gn(Jq.prototype,"skeletonData",[Yq],Object.getOwnPropertyDescriptor(Jq.prototype,"skeletonData"),Jq.prototype),gn(Jq.prototype,"_defaultSkinIndex",[jq],Object.getOwnPropertyDescriptor(Jq.prototype,"_defaultSkinIndex"),Jq.prototype),gn(Jq.prototype,"_animationIndex",[Kq],Object.getOwnPropertyDescriptor(Jq.prototype,"_animationIndex"),Jq.prototype),gn(Jq.prototype,"defaultCacheMode",[qq],Object.getOwnPropertyDescriptor(Jq.prototype,"defaultCacheMode"),Jq.prototype),$q=tn(Jq.prototype,"loop",[en],(function(){return!0})),gn(Jq.prototype,"sockets",[Zq],Object.getOwnPropertyDescriptor(Jq.prototype,"sockets"),Jq.prototype),tZ=tn(Jq.prototype,"_timeScale",[en],(function(){return 1})),eZ=tn(Jq.prototype,"_useTint",[en],(function(){return!1})),iZ=tn(Jq.prototype,"_preCacheMode",[en],(function(){return-1})),nZ=tn(Jq.prototype,"_cacheMode",[en],(function(){return vZ.REALTIME})),rZ=tn(Jq.prototype,"_defaultCacheMode",[en],(function(){return vZ.REALTIME})),sZ=tn(Jq.prototype,"_debugBones",[en],(function(){return!1})),aZ=tn(Jq.prototype,"_debugSlots",[en],(function(){return!1})),oZ=tn(Jq.prototype,"_skeletonData",[en],(function(){return null})),hZ=tn(Jq.prototype,"_premultipliedAlpha",[en],(function(){return!0})),lZ=tn(Jq.prototype,"defaultSkin",[en],(function(){return""})),uZ=tn(Jq.prototype,"defaultAnimation",[en],(function(){return""})),cZ=tn(Jq.prototype,"_enableBatch",[en],(function(){return!1})),dZ=tn(Jq.prototype,"_sockets",[en],(function(){return[]})),_Z=tn(Jq.prototype,"_debugMesh",[en],(function(){return!1})),Qq=Jq))||Qq);We.internal.SpineSkeleton=AZ;var CZ,RZ,bZ,xZ,wZ,MZ,IZ,BZ,PZ,DZ,OZ,FZ,LZ,NZ,kZ,UZ,GZ,VZ,HZ,zZ,XZ,WZ,YZ,jZ,KZ,qZ,ZZ,QZ,JZ,$Z,tQ,eQ,iQ,nQ,rQ,sQ,aQ,oQ=function(){function t(){this.name="sp.VertexEffectDelegate",this._vertexEffect=null,this._interpolation=null,this._effectType=void 0,this._vertexEffect=null,this._interpolation=null,this._effectType="none"}var e=t.prototype;return e.clear=function(){this._vertexEffect=null,this._interpolation=null,this._effectType="none"},e.initJitter=function(t,e){return this._effectType="jitter",this._vertexEffect=new $K.JitterEffect(t,e),this._vertexEffect},e.initSwirlWithPow=function(t,e){return this._interpolation=new $K.Pow(e),this._vertexEffect=new $K.SwirlEffect(t,this._interpolation),this._vertexEffect},e.initSwirlWithPowOut=function(t,e){return this._interpolation=new $K.PowOut(e),this._vertexEffect=new $K.SwirlEffect(t,this._interpolation),this._vertexEffect},e.getJitterVertexEffect=function(){return this._vertexEffect},e.getSwirlVertexEffect=function(){return this._vertexEffect},e.getVertexEffect=function(){return this._vertexEffect},e.getEffectType=function(){return this._effectType},t}(),hQ=[0,1,2,2,3,0],lQ=new Ve(0,0,255,255),uQ=new Ve(255,0,0,255),cQ=new Ve(0,255,0,255),dQ=new Ve(255,255,0,255),_Q=new $K.Color(1,1,1,1),fQ=new $K.Color(1,1,1,1),pQ=new $K.Vector2,gQ=new $K.Vector2,mQ=0,vQ=0,yQ=0,TQ=0,SQ=0,EQ=0,AQ=0,CQ=0,RQ=new ji(0,0,0),bQ=null,xQ=null,wQ=null;function MQ(t){var e,i;switch(t){case $K.BlendMode.Additive:e=CZ?I.ONE:I.SRC_ALPHA,i=I.ONE;break;case $K.BlendMode.Multiply:e=I.DST_COLOR,i=I.ONE_MINUS_SRC_ALPHA;break;case $K.BlendMode.Screen:e=I.ONE,i=I.ONE_MINUS_SRC_COLOR;break;case $K.BlendMode.Normal:default:e=CZ?I.ONE:I.SRC_ALPHA,i=I.ONE_MINUS_SRC_ALPHA}return eQ.getMaterialForBlendAndTint(e,i,wZ?yZ.TWO_COLORED:yZ.COLORED_TEXTURED)}function IQ(t){QZ=t.fa*FZ,WZ=PZ*(RZ=CZ?QZ/255:1),YZ=DZ*RZ,jZ=OZ*RZ,KZ=t.fr*WZ,qZ=t.fg*YZ,ZZ=t.fb*jZ,LZ=(QZ<<24>>>0)+(ZZ<<16)+(qZ<<8)+KZ,JZ=t.dr*WZ,$Z=t.dg*YZ,tQ=t.db*jZ,NZ=((CZ?255:0)<<24>>>0)+(tQ<<16)+($Z<<8)+JZ}function BQ(t){return(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r}function PQ(t,e,i,n){return(n<<24>>>0)+(i<<16)+(e<<8)+t}var DQ=null,OQ=null,FQ={vCount:32767,ensureAccessor:function(t){var e=t?OQ:DQ;if(!e){var i=Di.root.device,n=Di.root.batcher2D,r=t?Nh:Fh;t?(e=OQ=new Kh(i,r,this.vCount),n.registerBufferAccessor(Number.parseInt("SPINETINT",36),OQ)):(e=DQ=new Kh(i,r,this.vCount),n.registerBufferAccessor(Number.parseInt("SPINE",36),DQ))}return e},createData:function(t){var e=t.renderData;if(!e){for(var i=t.useTint||t.isAnimationCached(),n=this.ensureAccessor(i),r=t._skeleton.data.skins,s=0,a=0,o=0;o<r.length;++o)for(var h=r[o].attachments,l=0;l<h.length;l++){var u=h[l];for(var c in u){var d=u[c];d instanceof $K.RegionAttachment?(s+=4,a+=6):d instanceof $K.MeshAttachment&&(s+=d.worldVerticesLength>>1,a+=d.triangles.length)}}(e=Sl.add(i?Nh:Fh,n)).resize(s,a),e.indices&&a===e.indices.length||(e.indices=new Uint16Array(a)),t.maxVertexCount=s,t.maxIndexCount=a}return e},updateRenderData:function(t){eQ=t;var e=t._skeleton;!t.isAnimationCached()&&e&&e.updateWorldTransform(),e&&function(t){if(t._skeleton){var e=t.color;PZ=e.r/255,DZ=e.g/255,OZ=e.b/255,FZ=t.node._uiProps.opacity,wZ=t.useTint||t.isAnimationCached(),kZ=Uh(wZ?Nh:Fh)>>2,t.drawList.reset(),eQ=t,iQ=t.renderData,xQ=null,XZ=!0,CZ=t.premultipliedAlpha,RZ=1,aQ=!1,bQ=t._effectDelegate&&t._effectDelegate._vertexEffect,(4294967295!==e._val||CZ)&&(aQ=!0);var i=null;t.enableBatch&&(i=t.node.worldMatrix),t.isAnimationCached()?function(t){var e=eQ._curFrame;if(e){var i=e.segments;if(0!==i.length){UZ=12,TQ=0,SQ=0,yQ=0,EQ=0;var n=null,r=e.vertices,s=e.indices,a=0,o=0,h=0,l=0,u=e.colors,c=0,d=u[c++],_=d.vfOffset;IQ(d);var f=0,p=iQ,g=p.chunk.vb;sQ=new Uint32Array(g.buffer,g.byteOffset,g.length);for(var m=p.indices,v=0,y=i.length;v<y;v++){var T=i[v];if(n=MQ(T.blendMode)){if(xQ||(xQ=n),XZ||n.hash!==xQ.hash||T.tex&&T.tex!==wQ){XZ=!1;var S=EQ-f;S>0&&(eQ._requestDrawData(xQ,wQ,f,S),f=EQ),xQ=n,wQ=T.tex}vQ=T.vertexCount,SQ=T.indexCount,a=p.chunk.vertexOffset;for(var E=EQ,A=EQ+SQ;E<A;E++)m[E]=a+yQ+s[h++];if(l=T.vfCount,g.set(r.subarray(o,o+l),o),t)for(var C=o,R=o+l;C<R;C+=kZ)RQ.x=g[C],RQ.y=g[C+1],RQ.z=0,RQ.transformMat4(t),g[C]=RQ.x,g[C+1]=RQ.y,g[C+2]=RQ.z;if(aQ)for(var b=o/7*6,x=o,w=o+l;x<w;x+=kZ,b+=6)b>=_&&(IQ(d=u[c++]),_=d.vfOffset),sQ[x+5]=LZ,sQ[x+6]=NZ;o+=l,yQ+=vQ,EQ+=SQ,vQ=0,SQ=0}}var M=EQ-f;wQ&&M>0&&eQ._requestDrawData(xQ,wQ,f,M)}}}(i):(bQ&&bQ.begin(t._skeleton),function(t){var e=iQ;rQ=e.chunk.vb,sQ=new Uint32Array(rQ.buffer,rQ.byteOffset,rQ.length),nQ=e.indices,AQ=eQ.maxVertexCount,CQ=eQ.maxIndexCount;var i,n,r,s,a,o,h=eQ._skeleton,l=h.color,u=eQ._debugRenderer,c=eQ._clipper,d=null;bZ=eQ._startSlotIndex,xZ=eQ._endSlotIndex,zZ=!1,-1===bZ&&(zZ=!0),MZ=eQ.debugSlots,IZ=eQ.debugBones,BZ=eQ.debugMesh,u&&(IZ||MZ||BZ)&&(u.clear(),u.lineWidth=5),UZ=12,mQ=0,yQ=0,TQ=0,SQ=0,EQ=0;for(var _=0,f=0,p=h.drawOrder.length;f<p;f++)if(void 0!==(o=h.drawOrder[f])&&o.bone.active)if(bZ>=0&&bZ===o.data.index&&(zZ=!0),zZ)if(xZ>=0&&xZ===o.data.index&&(zZ=!1),mQ=0,SQ=0,i=o.getAttachment())if(s=i instanceof $K.RegionAttachment,a=i instanceof $K.MeshAttachment,i instanceof $K.ClippingAttachment)c.clipStart(o,i);else if(s||a){var g=i.region.texture.getRealTexture();if(d=MQ(o.data.blendMode)){if(xQ||(xQ=d),XZ||d.hash!==xQ.hash||g&&wQ!==g){XZ=!1;var m=EQ-_;m>0&&(eQ._requestDrawData(xQ,wQ,_,m),_=EQ),wQ=g,xQ=d}if(s){if(r=hQ,mQ=(vQ=4)*kZ,SQ=6,i.computeWorldVertices(o.bone,rQ,TQ,kZ),u&&MZ){u.strokeColor=lQ,u.moveTo(rQ[TQ],rQ[TQ+1]);for(var v=TQ+kZ,y=TQ+mQ;v<y;v+=kZ)u.lineTo(rQ[v],rQ[v+1]);u.close(),u.stroke()}}else if(a){var T=i;if(r=T.triangles,vQ=T.worldVerticesLength>>1,mQ=vQ*kZ,SQ=r.length,T.computeWorldVertices(o,0,T.worldVerticesLength,rQ,TQ,kZ),u&&BZ){u.strokeColor=dQ;for(var S=0,E=r.length;S<E;S+=3){var A=r[S]*kZ+TQ,C=r[S+1]*kZ+TQ,R=r[S+2]*kZ+TQ;u.moveTo(rQ[A],rQ[A+1]),u.lineTo(rQ[C],rQ[C+1]),u.lineTo(rQ[R],rQ[R+1]),u.close(),u.stroke()}}}if(0!==mQ&&0!==SQ){var b=i;(nQ=e.indices).set(r,EQ),n=b.uvs;for(var x=TQ,w=TQ+mQ,M=0;x<w;x+=kZ,M+=2)rQ[x+3]=n[M],rQ[x+4]=n[M+1];if(NQ(l,b.color,o.color,c,o),SQ>0){for(var I=e.chunk.vertexOffset,B=EQ,P=EQ+SQ;B<P;B++)nQ[B]+=yQ+I;if(t)for(var D=TQ,O=TQ+mQ;D<O;D+=kZ)RQ.x=rQ[D],RQ.y=rQ[D+1],RQ.z=0,RQ.transformMat4(t),rQ[D]=RQ.x,rQ[D+1]=RQ.y,rQ[D+2]=RQ.z}TQ+=mQ,yQ+=vQ,EQ+=SQ,vQ=0,SQ=0,c.clipEndWithSlot(o)}else c.clipEndWithSlot(o)}else c.clipEndWithSlot(o)}else c.clipEndWithSlot(o);else c.clipEndWithSlot(o);else c.clipEndWithSlot(o);var F=EQ-_;if(wQ&&F>0&&eQ._requestDrawData(xQ,wQ,_,F),c.clipEnd(),u&&IZ){var L;u.strokeColor=uQ,u.fillColor=lQ;for(var N=0,k=h.bones.length;N<k;N++){var U=(L=h.bones[N]).data.length*L.a+L.worldX,G=L.data.length*L.c+L.worldY;u.moveTo(L.worldX,L.worldY),u.lineTo(U,G),u.stroke(),u.circle(L.worldX,L.worldY,1.5*Math.PI),u.fill(),0===N&&(u.fillColor=cQ)}}}(i),bQ&&bQ.end()),(wZ?OQ:DQ).getMeshBuffer(iQ.chunk.bufferId).setDirty(),t.attachUtil._syncAttachedNode(),eQ=void 0,bQ=null}}(t)},updateColor:function(t){t&&(eQ=t).markForUpdateRenderData()},fillBuffers:function(){}};function LQ(t,e){var i=vQ,n=SQ,r=iQ;SQ=e.length,vQ=t.length/UZ,mQ=vQ*kZ,AQ+=vQ-i,CQ+=SQ-n;var s=nQ,a=r.chunk.vertexOffset,o=!1;if(AQ>r.vertexCount&&(r.resizeAndCopy(AQ,CQ>r.indexCount?CQ:r.indexCount),rQ=r.chunk.vb,sQ=new Uint32Array(rQ.buffer,rQ.byteOffset,rQ.length),o=!0),CQ>nQ.length&&(nQ=r.indices=new Uint16Array(CQ),o=!0),o)for(var h=r.chunk.vertexOffset-a,l=0;l<EQ;++l)nQ[l]=s[l]+h}function NQ(t,e,i,n,r){if(_Q.a=i.a*e.a*t.a*FZ*255,RZ=CZ?_Q.a:255,GZ=PZ*e.r*t.r*RZ,VZ=DZ*e.g*t.g*RZ,HZ=OZ*e.b*t.b*RZ,_Q.r=GZ*i.r,_Q.g=VZ*i.g,_Q.b=HZ*i.b,null==r.darkColor?fQ.set(0,0,0,1):(fQ.r=r.darkColor.r*GZ,fQ.g=r.darkColor.g*VZ,fQ.b=r.darkColor.b*HZ),fQ.a=CZ?255:0,wZ)if(n.isClipping()){UZ=wZ?12:8;var s=rQ.subarray(TQ),a=rQ.subarray(TQ+3);n.clipTriangles(s,mQ,nQ.subarray(EQ),SQ,a,_Q,fQ,wZ,kZ);var o=n.clippedVertices,h=n.clippedTriangles;if(LQ(o,h),h.length>0&&nQ.set(h,EQ),bQ)for(var l=0,u=o.length,c=TQ;l<u;l+=UZ,c+=kZ)pQ.x=o[l],pQ.y=o[l+1],gQ.x=o[l+6],gQ.y=o[l+7],bQ.transform(pQ,gQ,_Q,fQ),rQ[c]=pQ.x,rQ[c+1]=pQ.y,rQ[c+3]=gQ.x,rQ[c+4]=gQ.y,sQ[c+5]=PQ(o[l+2],o[l+3],o[l+4],o[l+5]),sQ[c+6]=PQ(o[l+8],o[l+9],o[l+10],o[l+11]);else for(var d=0,_=o.length,f=TQ;d<_;d+=UZ,f+=kZ)rQ[f]=o[d],rQ[f+1]=o[d+1],rQ[f+3]=o[d+6],rQ[f+4]=o[d+7],sQ[f+5]=PQ(o[d+2],o[d+3],o[d+4],o[d+5]),sQ[f+6]=PQ(o[d+8],o[d+9],o[d+10],o[d+11])}else if(LZ=BQ(_Q),NZ=BQ(fQ),bQ)for(var p=TQ,g=TQ+mQ;p<g;p+=kZ)pQ.x=rQ[p],pQ.y=rQ[p+1],gQ.x=rQ[p+3],gQ.y=rQ[p+4],bQ.transform(pQ,gQ,_Q,fQ),rQ[p]=pQ.x,rQ[p+1]=pQ.y,rQ[p+3]=gQ.x,rQ[p+4]=gQ.y,sQ[p+5]=LZ,sQ[p+6]=NZ;else for(var m=TQ,v=TQ+mQ;m<v;m+=kZ)sQ[m+5]=LZ,sQ[m+6]=NZ;else if(n.isClipping()){UZ=wZ?12:8;var y=rQ.subarray(TQ),T=rQ.subarray(TQ+3);n.clipTriangles(y,mQ,nQ.subarray(EQ),SQ,T,_Q,fQ,wZ,kZ);var S=n.clippedVertices,E=n.clippedTriangles;if(LQ(S,E),E.length>0&&nQ.set(E,EQ),bQ)for(var A=0,C=S.length,R=TQ;A<C;A+=UZ,R+=kZ)pQ.x=S[A],pQ.y=S[A+1],gQ.x=S[A+6],gQ.y=S[A+7],bQ.transform(pQ,gQ,_Q,fQ),rQ[R]=pQ.x,rQ[R+1]=pQ.y,rQ[R+3]=gQ.x,rQ[R+4]=gQ.y,sQ[R+5]=PQ(S[A+2],S[A+3],S[A+4],S[A+5]);else for(var b=0,x=S.length,w=TQ;b<x;b+=UZ,w+=kZ)rQ[w]=S[b],rQ[w+1]=S[b+1],rQ[w+3]=S[b+6],rQ[w+4]=S[b+7],sQ[w+5]=PQ(S[b+2],S[b+3],S[b+4],S[b+5])}else if(LZ=BQ(_Q),bQ)for(var M=TQ,I=TQ+mQ;M<I;M+=kZ)pQ.x=rQ[M],pQ.y=rQ[M+1],gQ.x=rQ[M+3],gQ.y=rQ[M+4],bQ.transform(pQ,gQ,_Q,fQ),rQ[M]=pQ.x,rQ[M+1]=pQ.y,rQ[M+3]=gQ.x,rQ[M+4]=gQ.y,sQ[M+5]=LZ;else for(var B=TQ,P=TQ+mQ;B<P;B+=kZ)sQ[B+5]=LZ}We.internal.SpineAssembler=FQ;var kQ,UQ,GQ={getAssembler:function(){return FQ}};AZ.Assembler=GQ,function(t){t[t.REGION=0]="REGION",t[t.BOUNDING_BOX=1]="BOUNDING_BOX",t[t.MESH=2]="MESH",t[t.SKINNED_MESH=3]="SKINNED_MESH"}(kQ||(kQ={})),Fn(kQ),function(t){t[t.START=0]="START",t[t.INTERRUPT=1]="INTERRUPT",t[t.END=2]="END",t[t.DISPOSE=3]="DISPOSE",t[t.COMPLETE=4]="COMPLETE",t[t.EVENT=5]="EVENT"}(UQ||(UQ={})),Fn(UQ),t("sp",Object.freeze({__proto__:null,spine:$K,get ATTACHMENT_TYPE(){return kQ},get AnimationEventType(){return UQ},timeScale:1,get DefaultSkinsEnum(){return gZ},get DefaultAnimsEnum(){return mZ},get AnimationCacheMode(){return vZ},get SpineMaterialType(){return yZ},SpineSocket:EZ,Skeleton:AZ,SkeletonData:Nq,SkeletonTexture:Oq,convertFilter:Fq,convertWraps:Lq,VertexEffectDelegate:oQ,simpleSpineAssembler:GQ}));var VQ=function(){function t(){this.originalTarget=null,this.target=null,this.tag=t.TAG_INVALID}var e=t.prototype;return e.clone=function(){var e=new t;return e.originalTarget=null,e.target=null,e.tag=this.tag,e},e.isDone=function(){return!0},e.startWithTarget=function(t){this.originalTarget=t,this.target=t},e.stop=function(){this.target=null},e.step=function(){kr(1006)},e.update=function(){kr(1007)},e.getTarget=function(){return this.target},e.setTarget=function(t){this.target=t},e.getOriginalTarget=function(){return this.originalTarget},e.setOriginalTarget=function(t){this.originalTarget=t},e.getTag=function(){return this.tag},e.setTag=function(t){this.tag=t},e.reverse=function(){return kr(1008),null},e.retain=function(){},e.release=function(){},t}();VQ.TAG_INVALID=-1;var HQ=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._duration=0,e._timesForRepeat=1,e}He(e,t);var i=e.prototype;return i.getDuration=function(){return this._duration*(this._timesForRepeat||1)},i.setDuration=function(t){this._duration=t},i.clone=function(){return new e},e}(VQ),zQ=(function(t){function e(e,i){var n;return void 0===i&&(i=1),(n=t.call(this)||this)._speed=0,n._innerAction=null,e&&n.initWithAction(e,i),n}He(e,t);var i=e.prototype;i.getSpeed=function(){return this._speed},i.setSpeed=function(t){this._speed=t},i.initWithAction=function(t,e){return t?(this._innerAction=t,this._speed=e,!0):(hn(1021),!1)},i.clone=function(){var t=new e;return t.initWithAction(this._innerAction.clone(),this._speed),t},i.startWithTarget=function(t){VQ.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),VQ.prototype.stop.call(this)},i.step=function(t){this._innerAction.step(t*this._speed)},i.isDone=function(){return this._innerAction.isDone()},i.reverse=function(){return new e(this._innerAction.reverse(),this._speed)},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction}}(VQ),0),XQ=function(){this.actions=[],this.target=null,this.actionIndex=0,this.currentAction=null,this.paused=!1,this.lock=!1},WQ=function(){function t(){this._hashTargets=new Map,this._arrayTargets=[],this._elementPool=[]}var e=t.prototype;return e._searchElementByTarget=function(t,e){for(var i=0;i<t.length;i++)if(e===t[i].target)return t[i];return null},e._getElement=function(t,e){var i=this._elementPool.pop();return i||(i=new XQ),i.target=t,i.paused=!!e,i},e._putElement=function(t){t.actions.length=0,t.actionIndex=0,t.currentAction=null,t.paused=!1,t.target=null,t.lock=!1,this._elementPool.push(t)},e.addAction=function(t,e,i){if(t&&e){null==e.uuid&&(e.uuid="_TWEEN_UUID_"+zQ++);var n=this._hashTargets.get(e);n?n.actions||(n.actions=[]):(n=this._getElement(e,i),this._hashTargets.set(e,n),this._arrayTargets.push(n)),n.target=e,n.actions.push(t),t.startWithTarget(e)}else hn(1e3)},e.removeAllActions=function(){for(var t=this._arrayTargets,e=0;e<t.length;e++){var i=t[e];i&&this._putElement(i)}this._arrayTargets.length=0,this._hashTargets=new Map},e.removeAllActionsFromTarget=function(t){if(null!=t){var e=this._hashTargets.get(t);e&&(e.actions.length=0,this._deleteHashElement(e))}},e.removeAction=function(t){if(null!=t){var e=t.getOriginalTarget(),i=this._hashTargets.get(e);if(i)for(var n=0;n<i.actions.length;n++)if(i.actions[n]===t){i.actions.splice(n,1),i.actionIndex>=n&&i.actionIndex--;break}}},e._removeActionByTag=function(t,e,i){for(var n=0,r=e.actions.length;n<r;++n){var s=e.actions[n];if(s&&s.getTag()===t){if(i&&s.getOriginalTarget()!==i)continue;this._removeActionAtIndex(n,e);break}}},e._removeAllActionsByTag=function(t,e,i){for(var n=e.actions.length-1;n>=0;--n){var r=e.actions[n];if(r&&r.getTag()===t){if(i&&r.getOriginalTarget()!==i)continue;this._removeActionAtIndex(n,e)}}},e.removeActionByTag=function(t,e){var i=this;t===VQ.TAG_INVALID&&kr(1002);var n=this._hashTargets;if(e){var r=n.get(e);r&&this._removeActionByTag(t,r,e)}else n.forEach((function(e){i._removeActionByTag(t,e)}))},e.removeAllActionsByTag=function(t,e){var i=this;t===VQ.TAG_INVALID&&kr(1002);var n=this._hashTargets;if(e){var r=n.get(e);r&&this._removeAllActionsByTag(t,r,e)}else n.forEach((function(e){i._removeAllActionsByTag(t,e)}))},e.getActionByTag=function(t,e){t===VQ.TAG_INVALID&&kr(1004);var i=this._hashTargets.get(e);if(i){if(null!=i.actions)for(var n=0;n<i.actions.length;++n){var r=i.actions[n];if(r&&r.getTag()===t)return r}kr(1005,t)}return null},e.getNumberOfRunningActionsInTarget=function(t){var e=this._hashTargets.get(t);return e&&e.actions?e.actions.length:0},e.pauseTarget=function(t){var e=this._hashTargets.get(t);e&&(e.paused=!0)},e.resumeTarget=function(t){var e=this._hashTargets.get(t);e&&(e.paused=!1)},e.pauseAllRunningActions=function(){for(var t=[],e=this._arrayTargets,i=0;i<e.length;i++){var n=e[i];n&&!n.paused&&(n.paused=!0,t.push(n.target))}return t},e.resumeTargets=function(t){if(t)for(var e=0;e<t.length;e++)t[e]&&this.resumeTarget(t[e])},e.pauseTargets=function(t){if(t)for(var e=0;e<t.length;e++)t[e]&&this.pauseTarget(t[e])},e.purgeSharedManager=function(){We.director.getScheduler().unscheduleUpdate(this)},e._removeActionAtIndex=function(t,e){e.actions[t],e.actions.splice(t,1),e.actionIndex>=t&&e.actionIndex--,0===e.actions.length&&this._deleteHashElement(e)},e._deleteHashElement=function(t){var e=!1;if(t&&!t.lock&&this._hashTargets.get(t.target)){this._hashTargets.delete(t.target);for(var i=this._arrayTargets,n=0,r=i.length;n<r;n++)if(i[n]===t){i.splice(n,1);break}this._putElement(t),e=!0}return e},e.update=function(t){for(var e,i=this._arrayTargets,n=0;n<i.length;n++){this._currentTarget=i[n];var r=(e=this._currentTarget).target;if(!ia(r)||r.isValid){if(!e.paused&&e.actions){for(e.lock=!0,e.actionIndex=0;e.actionIndex<e.actions.length;e.actionIndex++)if(e.currentAction=e.actions[e.actionIndex],e.currentAction){if(e.currentAction.step(t*(e.currentAction._speedMethod?e.currentAction._speed:1)),e.currentAction&&e.currentAction.isDone()){e.currentAction.stop();var s=e.currentAction;e.currentAction=null,this.removeAction(s)}e.currentAction=null}e.lock=!1}0===e.actions.length&&this._deleteHashElement(e)&&n--}else this.removeAllActionsFromTarget(r),n--}},t}(),YQ=t("TweenSystem",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).actionMgr=new WQ,e}return He(e,t),e.prototype.update=function(t){this.actionMgr.update(t)},Pi(e,[{key:"ActionManager",get:function(){return this.actionMgr}}]),e}(Oi));YQ.ID="TWEEN",YQ.instance=void 0,Di.on(An.EVENT_INIT,(function(){var t=new YQ;YQ.instance=t,Di.registerSystem(YQ.ID,t,Oi.Priority.MEDIUM)}));var jQ=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.isDone=function(){return!0},i.step=function(){this.update(1)},i.update=function(){},i.reverse=function(){return this.clone()},i.clone=function(){return new e},e}(HQ),KQ=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.update=function(){for(var t=this.target.getComponentsInChildren(ql),e=0;e<t.length;++e)t[e].enabled=!0},i.reverse=function(){return new qQ},i.clone=function(){return new e},e}(jQ),qQ=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.update=function(){for(var t=this.target.getComponentsInChildren(ql),e=0;e<t.length;++e)t[e].enabled=!1},i.reverse=function(){return new KQ},i.clone=function(){return new e},e}(jQ);!function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;i.update=function(){for(var t=this.target.getComponentsInChildren(ql),e=0;e<t.length;++e){var i=t[e];i.enabled=!i.enabled}},i.reverse=function(){return new e},i.clone=function(){return new e}}(jQ);var ZQ=function(t){function e(e){var i;return(i=t.call(this)||this)._isNeedCleanUp=!0,void 0!==e&&i.init(e),i}He(e,t);var i=e.prototype;return i.update=function(){this.target.removeFromParent(),this._isNeedCleanUp&&this.target.destroy()},i.init=function(t){return this._isNeedCleanUp=t,!0},i.reverse=function(){return new e(this._isNeedCleanUp)},i.clone=function(){return new e(this._isNeedCleanUp)},e}(jQ),QQ=function(t){function e(e,i,n){var r;return(r=t.call(this)||this)._selectorTarget=null,r._function=null,r._data=null,r.initWithFunction(e,i,n),r}He(e,t);var i=e.prototype;return i.initWithFunction=function(t,e,i){return t&&(this._function=t),e&&(this._selectorTarget=e),void 0!==i&&(this._data=i),!0},i.execute=function(){this._function&&this._function.call(this._selectorTarget,this.target,this._data)},i.update=function(){this.execute()},i.getTargetCallback=function(){return this._selectorTarget},i.setTargetCallback=function(t){t!==this._selectorTarget&&(this._selectorTarget&&(this._selectorTarget=null),this._selectorTarget=t)},i.clone=function(){var t=new e;return t.initWithFunction(this._function,this._selectorTarget,this._data),t},e}(jQ),JQ=function(t){function e(e){var i;return(i=t.call(this)||this).MAX_VALUE=2,i._elapsed=0,i._firstTick=!1,i._easeList=[],i._speed=1,i._repeatForever=!1,i._repeatMethod=!1,i._speedMethod=!1,void 0===e||isNaN(e)||i.initWithDuration(e),i}He(e,t);var i=e.prototype;return i.getElapsed=function(){return this._elapsed},i.initWithDuration=function(t){return this._duration=0===t?Mi.FLT_EPSILON:t,this._elapsed=0,this._firstTick=!0,!0},i.isDone=function(){return this._elapsed>=this._duration},i._cloneDecoration=function(t){t._repeatForever=this._repeatForever,t._speed=this._speed,t._timesForRepeat=this._timesForRepeat,t._easeList=this._easeList,t._speedMethod=this._speedMethod,t._repeatMethod=this._repeatMethod},i._reverseEaseList=function(t){if(this._easeList){t._easeList=[];for(var e=0;e<this._easeList.length;e++)t._easeList.push(this._easeList[e])}},i.clone=function(){var t=new e(this._duration);return this._cloneDecoration(t),t},i.easing=function(t){this._easeList?this._easeList.length=0:this._easeList=[];for(var e=0;e<arguments.length;e++)this._easeList.push(arguments[e]);return this},i._computeEaseTime=function(t){return t},i.step=function(t){this._firstTick?(this._firstTick=!1,this._elapsed=0):this._elapsed+=t;var e=this._elapsed/(this._duration>1.192092896e-7?this._duration:1.192092896e-7);e=e<1?e:1,this.update(e>0?e:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},i.startWithTarget=function(t){VQ.prototype.startWithTarget.call(this,t),this._elapsed=0,this._firstTick=!0},i.reverse=function(){return kr(1010),this},i.setAmplitudeRate=function(){kr(1011)},i.getAmplitudeRate=function(){return kr(1012),0},i.speed=function(t){return t<=0?(kr(1013),this):(this._speedMethod=!0,this._speed*=t,this)},i.getSpeed=function(){return this._speed},i.setSpeed=function(t){return this._speed=t,this},i.repeat=function(t){return t=Math.round(t),isNaN(t)||t<1?(kr(1014),this):(this._repeatMethod=!0,this._timesForRepeat*=t,this)},i.repeatForever=function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this},e}(HQ),$Q=function(t){function e(i){var n;(n=t.call(this)||this)._actions=[],n._split=0,n._last=0,n._reversed=!1;var r=i instanceof Array?i:arguments;if(1===r.length)return hn(1019),lr(n);var s=r.length-1;if(s>=0&&null==r[s]&&kr(1015),s>=0){for(var a,o=r[0],h=1;h<s;h++)r[h]&&(a=o,o=e._actionOneTwo(a,r[h]));n.initWithTwoActions(o,r[s])}return n}He(e,t);var i=e.prototype;return i.initWithTwoActions=function(t,e){if(!t||!e)return hn(1025),!1;var i=t._duration,n=e._duration,r=(i*=t._repeatMethod?t._timesForRepeat:1)+(n*=e._repeatMethod?e._timesForRepeat:1);return this.initWithDuration(r),this._actions[0]=t,this._actions[1]=e,!0},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithTwoActions(this._actions[0].clone(),this._actions[1].clone()),t},i.startWithTarget=function(t){JQ.prototype.startWithTarget.call(this,t),this._split=this._actions[0]._duration/this._duration,this._split*=this._actions[0]._repeatMethod?this._actions[0]._timesForRepeat:1,this._last=-1},i.stop=function(){-1!==this._last&&this._actions[this._last].stop(),VQ.prototype.stop.call(this)},i.update=function(t){var e,i,n=0,r=this._split,s=this._actions,a=this._last;(t=this._computeEaseTime(t))<r?(e=0!==r?t/r:1,0===n&&1===a&&this._reversed&&(s[1].update(0),s[1].stop())):(n=1,e=1===r?1:(t-r)/(1-r),-1===a&&(s[0].startWithTarget(this.target),s[0].update(1),s[0].stop()),0===a&&(s[0].update(1),s[0].stop())),i=s[n],a===n&&i.isDone()||(a!==n&&i.startWithTarget(this.target),e*=i._timesForRepeat,i.update(e>1?e%1:e),this._last=n)},i.reverse=function(){var t=e._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t._reversed=!0,t},e}(JQ);function tJ(t){var e=t instanceof Array?t:arguments;if(1===e.length)return hn(1019),null;var i=e.length-1;i>=0&&null==e[i]&&kr(1015);var n=null;if(i>=0){n=e[0];for(var r=1;r<=i;r++)e[r]&&(n=$Q._actionOneTwo(n,e[r]))}return n}$Q._actionOneTwo=function(t,e){var i=new $Q;return i.initWithTwoActions(t,e),i};var eJ=function(t){function e(e,i){var n;return(n=t.call(this)||this)._times=0,n._total=0,n._nextDt=0,n._actionInstant=!1,n._innerAction=null,void 0!==i&&n.initWithAction(e,i),n}He(e,t);var i=e.prototype;return i.initWithAction=function(t,e){var i=t._duration*e;return!!this.initWithDuration(i)&&(this._times=e,this._innerAction=t,t instanceof jQ&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone(),this._times),t},i.startWithTarget=function(t){this._total=0,this._nextDt=this._innerAction._duration/this._duration,JQ.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),VQ.prototype.stop.call(this)},i.update=function(t){t=this._computeEaseTime(t);var e=this._innerAction,i=this._duration,n=this._times,r=this._nextDt;if(t>=r){for(;t>r&&this._total<n;)e.update(1),this._total++,e.stop(),e.startWithTarget(this.target),r+=e._duration/i,this._nextDt=r>1?1:r;t>=1&&this._total<n&&(e.update(1),this._total++),this._actionInstant||(this._total===n?e.stop():e.update(t-(r-e._duration/i)))}else e.update(t*n%1)},i.isDone=function(){return this._total===this._times},i.reverse=function(){var t=new e(this._innerAction.reverse(),this._times);return this._cloneDecoration(t),this._reverseEaseList(t),t},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction},e}(JQ),iJ=function(t){function e(e){var i;return(i=t.call(this)||this)._innerAction=null,e&&i.initWithAction(e),i}He(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?(this._innerAction=t,!0):(hn(1026),!1)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone()),t},i.startWithTarget=function(t){JQ.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.step=function(t){var e=this._innerAction;e.step(t),e.isDone()&&(e.startWithTarget(this.target),e.step(e.getElapsed()-e._duration))},i.isDone=function(){return!1},i.reverse=function(){var t=new e(this._innerAction.reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction},e}(JQ),nJ=function(t){function e(i){var n;(n=t.call(this)||this)._one=null,n._two=null;var r=i instanceof Array?i:arguments;if(1===r.length)return hn(1020),lr(n);var s=r.length-1;if(s>=0&&null==r[s]&&kr(1015),s>=0){for(var a,o=r[0],h=1;h<s;h++)r[h]&&(a=o,o=e._actionOneTwo(a,r[h]));n.initWithTwoActions(o,r[s])}return n}He(e,t);var i=e.prototype;return i.initWithTwoActions=function(t,e){if(!t||!e)return hn(1027),!1;var i=!1,n=t._duration,r=e._duration;return this.initWithDuration(Math.max(n,r))&&(this._one=t,this._two=e,n>r?this._two=$Q._actionOneTwo(e,aJ(n-r)):n<r&&(this._one=$Q._actionOneTwo(t,aJ(r-n))),i=!0),i},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithTwoActions(this._one.clone(),this._two.clone()),t},i.startWithTarget=function(t){JQ.prototype.startWithTarget.call(this,t),this._one.startWithTarget(t),this._two.startWithTarget(t)},i.stop=function(){this._one.stop(),this._two.stop(),VQ.prototype.stop.call(this)},i.update=function(t){t=this._computeEaseTime(t),this._one&&this._one.update(t),this._two&&this._two.update(t)},i.reverse=function(){var t=e._actionOneTwo(this._one.reverse(),this._two.reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t},e}(JQ);function rJ(t){var e=t instanceof Array?t:arguments;if(1===e.length)return hn(1020),null;e.length>0&&null==e[e.length-1]&&kr(1015);for(var i=e[0],n=1;n<e.length;n++)null!=e[n]&&(i=nJ._actionOneTwo(i,e[n]));return i}nJ._actionOneTwo=function(t,e){var i=new nJ;return i.initWithTwoActions(t,e),i};var sJ=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.update=function(){},i.reverse=function(){var t=new e(this._duration);return this._cloneDecoration(t),this._reverseEaseList(t),t},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithDuration(this._duration),t},e}(JQ);function aJ(t){return new sJ(t)}var oJ,hJ,lJ,uJ,cJ=function(t){function e(e){var i;return(i=t.call(this)||this)._other=null,e&&i.initWithAction(e),i}He(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?t===this._other?(hn(1029),!1):!!JQ.prototype.initWithDuration.call(this,t._duration)&&(this._other=t,!0):(hn(1028),!1)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._other.clone()),t},i.startWithTarget=function(t){JQ.prototype.startWithTarget.call(this,t),this._other.startWithTarget(t)},i.update=function(t){t=this._computeEaseTime(t),this._other&&this._other.update(1-t)},i.reverse=function(){return this._other.clone()},i.stop=function(){this._other.stop(),VQ.prototype.stop.call(this)},e}(JQ),dJ=t("TweenAction",function(t){function e(e,i,n){var r;if((r=t.call(this)||this)._opts=void 0,r._props=void 0,r._originProps=void 0,null==n)n=Object.create(null);else if(function(t){var e=" [Tween:] ",i=" option is not support in v + "+Ia,n=t;n.delay&&Gi(e+"delay"+i),n.repeat&&Gi(e+"repeat"+i),n.repeatDelay&&Gi(e+"repeatDelay"+i),n.interpolation&&Gi(e+"interpolation"+i),n.onStop&&Gi(e+"onStop"+i)}(n),n.easing&&"string"==typeof n.easing&&(n.easing=function(t){var e=t.charAt(0);if(/[A-Z]/.test(e)){var i=(t=t.replace(e,e.toLowerCase())).split("-");if(2===i.length){var n=i[0];if("linear"===n)t="linear";else{var r=i[1];switch(n){case"quadratic":t="quad"+r;break;case"quartic":t="quart"+r;break;case"quintic":t="quint"+r;break;case"sinusoidal":t="sine"+r;break;case"exponential":t="expo"+r;break;case"circular":t="circ"+r;break;default:t=n+r}}}}return t}(n.easing)),n.progress||(n.progress=r.progress),n.easing&&"string"==typeof n.easing){var s=n.easing;n.easing=Ss[s],n.easing||Zi(1031,s)}for(var a in r._opts=n,r._props=Object.create(null),i)if(i.hasOwnProperty(a)){var o=i[a];if("function"==typeof o&&(o=o()),null!=o&&"string"!=typeof o){var h=void 0,l=void 0;void 0!==o.value&&(o.easing||o.progress)&&("string"==typeof o.easing?(h=Ss[o.easing])||Zi(1031,o.easing):h=o.easing,l=o.progress,o=o.value);var u=Object.create(null);u.value=o,u.easing=h,u.progress=l,r._props[a]=u}}return r._originProps=i,r.initWithDuration(e),r}He(e,t);var i=e.prototype;return i.clone=function(){var t=new e(this._duration,this._originProps,this._opts);return this._cloneDecoration(t),t},i.startWithTarget=function(t){JQ.prototype.startWithTarget.call(this,t);var e=!!this._opts.relative,i=this._props;for(var n in i){var r=t[n];if(void 0!==r){var s=i[n],a=s.value;if("number"==typeof r)s.start=r,s.current=r,s.end=e?r+a:a;else if("object"==typeof r)for(var o in null==s.start&&(s.start={},s.current={},s.end={}),a)isNaN(r[o])||(s.start[o]=r[o],s.current[o]=r[o],s.end[o]=e?r[o]+a[o]:a[o])}}this._opts.onStart&&this._opts.onStart(this.target)},i.update=function(t){var e=this.target;if(e){var i=this._props,n=this._opts,r=t;n.easing&&(r=n.easing(t));var s=n.progress;for(var a in i){var o=i[a],h=o.easing?o.easing(t):r,l=o.progress?o.progress:s,u=o.start,c=o.end;if("number"==typeof u)o.current=l(u,c,o.current,h);else if("object"==typeof u)for(var d in u)o.current[d]=l(u[d],c[d],o.current[d],h);e[a]=o.current}n.onUpdate&&n.onUpdate(this.target,t),1===t&&n.onComplete&&n.onComplete(this.target)}},i.progress=function(t,e,i,n){return t+(e-t)*n},e}(JQ)),_J=function(t){function e(e){var i;return(i=t.call(this)||this)._props=void 0,i._props={},void 0!==e&&i.init(e),i}He(e,t);var i=e.prototype;return i.init=function(t){for(var e in t)this._props[e]=t[e];return!0},i.update=function(){var t=this._props,e=this.target;for(var i in t)e[i]=t[i]},i.clone=function(){var t=new e;return t.init(this._props),t},e}(jQ),fJ=t("Tween",function(){function t(t){this._actions=[],this._finalAction=null,this._target=null,this._tag=VQ.TAG_INVALID,this._target=void 0===t?null:t}var e=t.prototype;return e.tag=function(t){return this._tag=t,this},e.then=function(t){return t instanceof VQ?this._actions.push(t.clone()):this._actions.push(t._union()),this},e.target=function(t){return this._target=t,this},e.start=function(){return this._target?(this._finalAction&&YQ.instance.ActionManager.removeAction(this._finalAction),this._finalAction=this._union(),this._finalAction.setTag(this._tag),YQ.instance.ActionManager.addAction(this._finalAction,this._target,!1),this):(Gi("Please set target to tween first"),this)},e.stop=function(){return this._finalAction&&YQ.instance.ActionManager.removeAction(this._finalAction),this},e.clone=function(t){var e=this._union();return pJ(t).then(e.clone())},e.union=function(){var t=this._union();return this._actions.length=0,this._actions.push(t),this},e.to=function(t,e,i){(i=i||Object.create(null)).relative=!1;var n=new dJ(t,e,i);return this._actions.push(n),this},e.by=function(t,e,i){(i=i||Object.create(null)).relative=!0;var n=new dJ(t,e,i);return this._actions.push(n),this},e.set=function(t){var e=new _J(t);return this._actions.push(e),this},e.delay=function(t){var e=aJ(t);return this._actions.push(e),this},e.call=function(t){var e=function(t){return new QQ(t,void 0,void 0)}(t);return this._actions.push(e),this},e.sequence=function(){var e=t._wrappedSequence.apply(t,arguments);return this._actions.push(e),this},e.parallel=function(){var e=t._wrappedParallel.apply(t,arguments);return this._actions.push(e),this},e.repeat=function(e,i){if(e===1/0)return this.repeatForever(i);var n,r=this._actions;return n=i instanceof t?i._union():r.pop(),r.push(function(t,e){return new eJ(t,e)}(n,e)),this},e.repeatForever=function(e){var i,n=this._actions;return i=e instanceof t?e._union():n.pop(),n.push(function(t){return new iJ(t)}(i)),this},e.reverseTime=function(e){var i,n=this._actions;return i=e instanceof t?e._union():n.pop(),n.push(function(t){return new cJ(t)}(i)),this},e.hide=function(){var t=new qQ;return this._actions.push(t),this},e.show=function(){var t=new KQ;return this._actions.push(t),this},e.removeSelf=function(){var t=new ZQ(!1);return this._actions.push(t),this},t.stopAll=function(){YQ.instance.ActionManager.removeAllActions()},t.stopAllByTag=function(t,e){YQ.instance.ActionManager.removeAllActionsByTag(t,e)},t.stopAllByTarget=function(t){YQ.instance.ActionManager.removeAllActionsFromTarget(t)},e._union=function(){var t=this._actions;return 1===t.length?t[0]:tJ(t)},e._destroy=function(){this.stop()},t._wrappedSequence=function(){var e=t._tmp_args;e.length=0;for(var i=arguments.length,n=0;n<i;n++){var r=e[n]=n<0||arguments.length<=n?void 0:arguments[n];r instanceof t&&(e[n]=r._union())}return tJ.apply(tJ,e)},t._wrappedParallel=function(){var e=t._tmp_args;e.length=0;for(var i=arguments.length,n=0;n<i;n++){var r=e[n]=n<0||arguments.length<=n?void 0:arguments[n];r instanceof t&&(e[n]=r._union())}return rJ.apply(rJ,e)},t}());function pJ(t){return new fJ(t)}function gJ(t){return Gi("tweenUtil' is deprecated, please use 'tween' instead "),new fJ(t)}fJ._tmp_args=[],We.Tween=fJ,We.tween=pJ,We.tweenUtil=gJ,function(t){t[t.Other=0]="Other",t[t.Left=1]="Left",t[t.Right=2]="Right"}(oJ||(oJ={})),function(t){t.XRUI_HOVER_ENTERED="xrui-hover-entered",t.XRUI_HOVER_EXITED="xrui-hover-exited",t.XRUI_HOVER_STAY="xrui-hover-stay",t.XRUI_CLICK="xrui-click",t.XRUI_UNCLICK="xrui-unclick"}(hJ||(hJ={})),function(t){t.XR_CAPS_LOCK="xr-caps-lock",t.XR_KEYBOARD_INIT="xr-keyboard-init",t.XR_KEYBOARD_INPUT="xr-keyboard-input",t.TO_LATIN="to-latin",t.TO_SYMBOL="to-symbol",t.TO_MATH_SYMBOL="to-math-symbol"}(lJ||(lJ={})),He((function(){for(var t,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return(t=uJ.call.apply(uJ,[this].concat(i))||this).deviceType=oJ.Other,t.hitPoint=new ji,t}),uJ=Ba);var mJ,vJ,yJ,TJ,SJ,EJ,AJ,CJ,RJ,bJ,xJ,wJ,MJ,IJ,BJ,PJ,DJ,OJ,FJ,LJ,NJ,kJ,UJ,GJ,VJ,HJ,zJ,XJ,WJ,YJ,jJ,KJ=new Ve;!function(t){t[t.NONE=0]="NONE",t[t.COLOR=1]="COLOR",t[t.SPRITE=2]="SPRITE",t[t.SCALE=3]="SCALE"}(WJ||(WJ={})),Fn(WJ),function(t){t.NORMAL="normal",t.HOVER="hover",t.PRESSED="pressed",t.DISABLED="disabled"}(YJ||(YJ={})),function(t){t.CLICK="click"}(jJ||(jJ={}));var qJ=function(e){return t({Button:e,ButtonComponent:e}),e}((mJ=Ki("cc.Button"),vJ=In(110),yJ=kn(Bl),TJ=Tn(Pr),SJ=Tn(WJ),EJ=Tn(Uo),AJ=Tn(Uo),CJ=Tn(Uo),RJ=Tn(Uo),bJ=Tn([Pa]),mJ(xJ=vJ(xJ=yJ((XJ=zJ=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).clickEvents=MJ&&MJ(),e._interactable=IJ&&IJ(),e._transition=BJ&&BJ(),e._normalColor=PJ&&PJ(),e._hoverColor=DJ&&DJ(),e._pressedColor=OJ&&OJ(),e._disabledColor=FJ&&FJ(),e._normalSprite=LJ&&LJ(),e._hoverSprite=NJ&&NJ(),e._pressedSprite=kJ&&kJ(),e._disabledSprite=UJ&&UJ(),e._duration=GJ&&GJ(),e._zoomScale=VJ&&VJ(),e._target=HJ&&HJ(),e._pressed=!1,e._hovered=!1,e._fromColor=new Ve,e._toColor=new Ve,e._time=0,e._transitionFinished=!0,e._fromScale=new ji,e._toScale=new ji,e._originalScale=null,e._sprite=null,e._targetScale=new ji,e}He(e,t);var i=e.prototype;return i.__preload=function(){this.target||(this.target=this.node);var t=this.node.getComponent(Bd);t&&(this._normalSprite=t.spriteFrame),this._applyTarget(),this._resetState()},i.onEnable=function(){this._registerNodeEvent()},i.onDisable=function(){this._resetState(),this._unregisterNodeEvent()},i.onDestroy=function(){this.target.isValid&&this._unregisterTargetEvent(this.target)},i.update=function(t){var e=this.target;if(!this._transitionFinished&&e&&(this._transition===WJ.COLOR||this._transition===WJ.SCALE)){this._time+=t;var i=1;if(this._duration>0&&(i=this._time/this._duration),i>=1&&(i=1),this._transition===WJ.COLOR){var n=e._uiProps.uiComp;Ve.lerp(KJ,this._fromColor,this._toColor,i),n&&(n.color=KJ)}else this.transition===WJ.SCALE&&(e.getScale(this._targetScale),this._targetScale.x=Cs(this._fromScale.x,this._toScale.x,i),this._targetScale.y=Cs(this._fromScale.y,this._toScale.y,i),e.setScale(this._targetScale));1===i&&(this._transitionFinished=!0)}},i._resizeNodeToTargetNode=function(){this.target&&this.target._uiProps.uiTransformComp},i._resetState=function(){this._pressed=!1,this._hovered=!1;var t=this.target;if(t){var e=this._transition;if(e===WJ.COLOR&&this._interactable){var i=t.getComponent(wu);i&&(i.color=this._normalColor)}else e===WJ.SCALE&&this._originalScale&&t.setScale(this._originalScale);this._transitionFinished=!0}},i._registerNodeEvent=function(){this.node.on(xn.TOUCH_START,this._onTouchBegan,this),this.node.on(xn.TOUCH_MOVE,this._onTouchMove,this),this.node.on(xn.TOUCH_END,this._onTouchEnded,this),this.node.on(xn.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(xn.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(xn.MOUSE_LEAVE,this._onMouseMoveOut,this),this.node.on(hJ.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.on(hJ.XRUI_HOVER_EXITED,this._xrHoverExit,this),this.node.on(hJ.XRUI_CLICK,this._xrClick,this),this.node.on(hJ.XRUI_UNCLICK,this._xrUnClick,this)},i._registerTargetEvent=function(t){t.on(xn.TRANSFORM_CHANGED,this._onTargetTransformChanged,this)},i._unregisterNodeEvent=function(){this.node.off(xn.TOUCH_START,this._onTouchBegan,this),this.node.off(xn.TOUCH_MOVE,this._onTouchMove,this),this.node.off(xn.TOUCH_END,this._onTouchEnded,this),this.node.off(xn.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(xn.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(xn.MOUSE_LEAVE,this._onMouseMoveOut,this),this.node.off(hJ.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.off(hJ.XRUI_HOVER_EXITED,this._xrHoverExit,this),this.node.off(hJ.XRUI_CLICK,this._xrClick,this),this.node.off(hJ.XRUI_UNCLICK,this._xrUnClick,this)},i._unregisterTargetEvent=function(t){t.off(xn.TRANSFORM_CHANGED)},i._getTargetSprite=function(t){var e=null;return t&&(e=t.getComponent(Bd)),e},i._applyTarget=function(){this.target&&(this._sprite=this._getTargetSprite(this.target),this._originalScale||(this._originalScale=new ji),ji.copy(this._originalScale,this.target.getScale()),this._registerTargetEvent(this.target))},i._onTargetSpriteFrameChanged=function(t){this._transition===WJ.SPRITE&&this._setCurrentStateSpriteFrame(t.spriteFrame)},i._setCurrentStateSpriteFrame=function(t){if(t)switch(this._getButtonState()){case YJ.NORMAL:this._normalSprite=t;break;case YJ.HOVER:this._hoverSprite=t;break;case YJ.PRESSED:this._pressedSprite=t;break;case YJ.DISABLED:this._disabledSprite=t}},i._onTargetColorChanged=function(t){this._transition===WJ.COLOR&&this._setCurrentStateColor(t)},i._setCurrentStateColor=function(t){switch(this._getButtonState()){case YJ.NORMAL:this._normalColor=t;break;case YJ.HOVER:this._hoverColor=t;break;case YJ.PRESSED:this._pressedColor=t;break;case YJ.DISABLED:this._disabledColor=t}},i._onTargetTransformChanged=function(t){t&pr.SCALE&&this._originalScale&&this._transition===WJ.SCALE&&this._transitionFinished&&ji.copy(this._originalScale,this.target.getScale())},i._onTouchBegan=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState(),t&&(t.propagationStopped=!0))},i._onTouchMove=function(t){if(this._interactable&&this.enabledInHierarchy&&this._pressed&&t){var e=t.touch;if(e){var i,n=this.node._uiProps.uiTransformComp.hitTest(e.getLocation());this._transition===WJ.SCALE&&this.target&&this._originalScale?n?(ji.copy(this._fromScale,this._originalScale),ji.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._transitionFinished=!1):(this._time=0,this._transitionFinished=!0,this.target.setScale(this._originalScale)):(i=n?YJ.PRESSED:YJ.NORMAL,this._applyTransition(i)),t&&(t.propagationStopped=!0)}}},i._onTouchEnded=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(Pa.emitEvents(this.clickEvents,t),this.node.emit(jJ.CLICK,this)),this._pressed=!1,this._updateState(),t&&(t.propagationStopped=!0))},i._onTouchCancel=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed=!1,this._updateState())},i._onMouseMoveIn=function(){!this._pressed&&this.interactable&&this.enabledInHierarchy&&(this._transition!==WJ.SPRITE||this._hoverSprite)&&(this._hovered||(this._hovered=!0,this._updateState()))},i._onMouseMoveOut=function(){this._hovered&&(this._hovered=!1,this._updateState())},i._updateState=function(){var t=this._getButtonState();this._applyTransition(t)},i._getButtonState=function(){var t=YJ.NORMAL;return this._interactable?this._pressed?t=YJ.PRESSED:this._hovered&&(t=YJ.HOVER):t=YJ.DISABLED,t.toString()},i._updateColorTransition=function(t){var e,i=this[t+"Color"],n=null===(e=this.target)||void 0===e?void 0:e.getComponent(wu);n&&(t===YJ.DISABLED?n.color=i:(this._fromColor=n.color.clone(),this._toColor=i,this._time=0,this._transitionFinished=!1))},i._updateSpriteTransition=function(t){var e=this[t+"Sprite"];this._sprite&&e&&(this._sprite.spriteFrame=e)},i._updateScaleTransition=function(t){this._interactable&&(t===YJ.PRESSED?this._zoomUp():this._zoomBack())},i._zoomUp=function(){this._originalScale&&(ji.copy(this._fromScale,this._originalScale),ji.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._time=0,this._transitionFinished=!1)},i._zoomBack=function(){this.target&&this._originalScale&&(ji.copy(this._fromScale,this.target.getScale()),ji.copy(this._toScale,this._originalScale),this._time=0,this._transitionFinished=!1)},i._applyTransition=function(t){var e=this._transition;e===WJ.COLOR?this._updateColorTransition(t):e===WJ.SPRITE?this._updateSpriteTransition(t):e===WJ.SCALE&&this._updateScaleTransition(t)},i._xrHoverEnter=function(){this._onMouseMoveIn(),this._updateState()},i._xrHoverExit=function(){this._onMouseMoveOut(),this._pressed&&(this._pressed=!1,this._updateState())},i._xrClick=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState())},i._xrUnClick=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(Pa.emitEvents(this.clickEvents,this),this.node.emit(jJ.CLICK,this)),this._pressed=!1,this._updateState())},Pi(e,[{key:"target",get:function(){return this._target||this.node},set:function(t){this._target!==t&&(this._target&&this._unregisterTargetEvent(this._target),this._target=t,this._applyTarget())}},{key:"interactable",get:function(){return this._interactable},set:function(t){this._interactable!==t&&(this._interactable=t,this._updateState(),this._interactable||this._resetState())}},{key:"_resizeToTarget",set:function(t){t&&this._resizeNodeToTargetNode()}},{key:"transition",get:function(){return this._transition},set:function(t){this._transition!==t&&(this._transition===WJ.COLOR?this._updateColorTransition(YJ.NORMAL):this._transition===WJ.SPRITE&&this._updateSpriteTransition(YJ.NORMAL),this._transition=t,this._updateState())}},{key:"normalColor",get:function(){return this._normalColor},set:function(t){this._normalColor!==t&&(this._normalColor.set(t),this._updateState())}},{key:"pressedColor",get:function(){return this._pressedColor},set:function(t){this._pressedColor!==t&&this._pressedColor.set(t)}},{key:"hoverColor",get:function(){return this._hoverColor},set:function(t){this._hoverColor!==t&&this._hoverColor.set(t)}},{key:"disabledColor",get:function(){return this._disabledColor},set:function(t){this._disabledColor!==t&&(this._disabledColor.set(t),this._updateState())}},{key:"duration",get:function(){return this._duration},set:function(t){this._duration!==t&&(this._duration=t)}},{key:"zoomScale",get:function(){return this._zoomScale},set:function(t){this._zoomScale!==t&&(this._zoomScale=t)}},{key:"normalSprite",get:function(){return this._normalSprite},set:function(t){if(this._normalSprite!==t){this._normalSprite=t;var e=this.node.getComponent(Bd);e&&(e.spriteFrame=t),this._updateState()}}},{key:"pressedSprite",get:function(){return this._pressedSprite},set:function(t){this._pressedSprite!==t&&(this._pressedSprite=t,this._updateState())}},{key:"hoverSprite",get:function(){return this._hoverSprite},set:function(t){this._hoverSprite!==t&&(this._hoverSprite=t,this._updateState())}},{key:"disabledSprite",get:function(){return this._disabledSprite},set:function(t){this._disabledSprite!==t&&(this._disabledSprite=t,this._updateState())}}]),e}(Pn),zJ.Transition=WJ,zJ.EventType=jJ,gn((wJ=XJ).prototype,"target",[TJ],Object.getOwnPropertyDescriptor(wJ.prototype,"target"),wJ.prototype),gn(wJ.prototype,"transition",[SJ],Object.getOwnPropertyDescriptor(wJ.prototype,"transition"),wJ.prototype),gn(wJ.prototype,"normalSprite",[EJ],Object.getOwnPropertyDescriptor(wJ.prototype,"normalSprite"),wJ.prototype),gn(wJ.prototype,"pressedSprite",[AJ],Object.getOwnPropertyDescriptor(wJ.prototype,"pressedSprite"),wJ.prototype),gn(wJ.prototype,"hoverSprite",[CJ],Object.getOwnPropertyDescriptor(wJ.prototype,"hoverSprite"),wJ.prototype),gn(wJ.prototype,"disabledSprite",[RJ],Object.getOwnPropertyDescriptor(wJ.prototype,"disabledSprite"),wJ.prototype),MJ=tn(wJ.prototype,"clickEvents",[bJ,en],(function(){return[]})),IJ=tn(wJ.prototype,"_interactable",[en],(function(){return!0})),BJ=tn(wJ.prototype,"_transition",[en],(function(){return WJ.NONE})),PJ=tn(wJ.prototype,"_normalColor",[en],(function(){return Ve.WHITE.clone()})),DJ=tn(wJ.prototype,"_hoverColor",[en],(function(){return new Ve(211,211,211,255)})),OJ=tn(wJ.prototype,"_pressedColor",[en],(function(){return Ve.WHITE.clone()})),FJ=tn(wJ.prototype,"_disabledColor",[en],(function(){return new Ve(124,124,124,255)})),LJ=tn(wJ.prototype,"_normalSprite",[en],(function(){return null})),NJ=tn(wJ.prototype,"_hoverSprite",[en],(function(){return null})),kJ=tn(wJ.prototype,"_pressedSprite",[en],(function(){return null})),UJ=tn(wJ.prototype,"_disabledSprite",[en],(function(){return null})),GJ=tn(wJ.prototype,"_duration",[en],(function(){return.1})),VJ=tn(wJ.prototype,"_zoomScale",[en],(function(){return 1.2})),HJ=tn(wJ.prototype,"_target",[en],(function(){return null})),xJ=wJ))||xJ)||xJ)||xJ));We.Button=qJ;var ZJ,QJ,JJ,$J=function(){function t(){}return t.add=function(t){var e=this._tabIndexList;-1===e.indexOf(t)&&e.push(t)},t.remove=function(t){var e=this._tabIndexList,i=e.indexOf(t);-1!==i&&e.splice(i,1)},t.resort=function(){this._tabIndexList.sort((function(t,e){return t._delegate.tabIndex-e._delegate.tabIndex}))},t.next=function(t){var e=this._tabIndexList,i=e.indexOf(t);if(t.setFocus(!1),-1!==i){var n=e[i+1];n&&n._delegate.tabIndex>=0&&n.setFocus(!0)}},t}();$J._tabIndexList=[],function(t){t[t.DEFAULT=0]="DEFAULT",t[t.DONE=1]="DONE",t[t.SEND=2]="SEND",t[t.SEARCH=3]="SEARCH",t[t.GO=4]="GO",t[t.NEXT=5]="NEXT"}(ZJ||(ZJ={})),fr(ZJ),function(t){t[t.ANY=0]="ANY",t[t.EMAIL_ADDR=1]="EMAIL_ADDR",t[t.NUMERIC=2]="NUMERIC",t[t.PHONE_NUMBER=3]="PHONE_NUMBER",t[t.URL=4]="URL",t[t.DECIMAL=5]="DECIMAL",t[t.SINGLE_LINE=6]="SINGLE_LINE"}(QJ||(QJ={})),fr(QJ),function(t){t[t.PASSWORD=0]="PASSWORD",t[t.SENSITIVE=1]="SENSITIVE",t[t.INITIAL_CAPS_WORD=2]="INITIAL_CAPS_WORD",t[t.INITIAL_CAPS_SENTENCE=3]="INITIAL_CAPS_SENTENCE",t[t.INITIAL_CAPS_ALL_CHARACTERS=4]="INITIAL_CAPS_ALL_CHARACTERS",t[t.DEFAULT=5]="DEFAULT"}(JJ||(JJ={})),fr(JJ);var t$,e$,i$,n$,r$,s$,a$,o$,h$,l$,u$,c$,d$,_$,f$,p$,g$,m$,v$,y$,T$,S$,E$,A$,C$,R$,b$,x$,w$,M$,I$,B$=function(){function t(){this._editing=!1,this._delegate=null}var e=t.prototype;return e.init=function(){},e.onEnable=function(){},e.update=function(){},e.onDisable=function(){this._editing&&this.endEditing()},e.clear=function(){this._delegate=null},e.setTabIndex=function(){},e.setSize=function(){},e.setFocus=function(t){t?this.beginEditing():this.endEditing()},e.isFocused=function(){return this._editing},e.beginEditing=function(){},e.endEditing=function(){},t}(),P$=ln.document,D$=new Ue,O$=new Ue,F$=new ji,L$=null,N$=0,k$=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._delegate=null,e._inputMode=-1,e._inputFlag=-1,e._returnType=-1,e.__eventListeners={},e.__autoResize=!1,e.__orientationChanged=void 0,e._edTxt=null,e._isTextArea=!1,e._textLabelFont=null,e._textLabelFontSize=null,e._textLabelFontColor=null,e._textLabelAlign=null,e._placeholderLabelFont=null,e._placeholderLabelFontSize=null,e._placeholderLabelFontColor=null,e._placeholderLabelAlign=null,e._placeholderLineHeight=null,e._placeholderStyleSheet=null,e._domId="EditBoxId_"+ ++N$,e}He(e,t);var i=e.prototype;return i.init=function(t){t&&(this._delegate=t,t.inputMode===QJ.ANY?this._createTextArea():this._createInput(),$J.add(this),this.setTabIndex(t.tabIndex),this._initStyleSheet(),this._registerEventListeners(),this._addDomToGameContainer())},i.clear=function(){this._removeEventListeners(),this._removeDomFromGameContainer(),$J.remove(this),L$===this&&(L$=null),this._delegate=null},i.update=function(){this._updateMatrix()},i.setTabIndex=function(t){this._edTxt.tabIndex=t,$J.resort()},i.setSize=function(t,e){var i=this._edTxt;i&&(i.style.width=t+"px",i.style.height=e+"px")},i.beginEditing=function(){L$&&L$!==this&&L$.setFocus(!1),this._editing=!0,L$=this,this._delegate._editBoxEditingDidBegan(),this._showDom(),this._edTxt.focus()},i.endEditing=function(){this._edTxt.blur()},i._createInput=function(){this._isTextArea=!1,this._edTxt=P$.createElement("input")},i._createTextArea=function(){this._isTextArea=!0,this._edTxt=P$.createElement("textarea")},i._addDomToGameContainer=function(){qr.container&&this._edTxt&&(qr.container.appendChild(this._edTxt),P$.head.appendChild(this._placeholderStyleSheet))},i._removeDomFromGameContainer=function(){Da(qr.container,this._edTxt)&&this._edTxt&&qr.container.removeChild(this._edTxt),Da(P$.head,this._placeholderStyleSheet)&&P$.head.removeChild(this._placeholderStyleSheet),this._edTxt=null,this._placeholderStyleSheet=null},i._showDom=function(){this._updateMaxLength(),this._updateInputType(),this._updateStyleSheet(),this._edTxt&&this._delegate&&(this._edTxt.style.display="",this._delegate._hideLabels()),rn.isMobile&&this._showDomOnMobile()},i._hideDom=function(){var t=this._edTxt;t&&this._delegate&&(t.style.display="none",this._delegate._showLabels()),rn.isMobile&&this._hideDomOnMobile()},i._showDomOnMobile=function(){rn.os!==Os.ANDROID&&rn.os!==Os.OHOS||(Er.handleResizeEvent=!1,this._adjustWindowScroll())},i._hideDomOnMobile=function(){rn.os!==Os.ANDROID&&rn.os!==Os.OHOS||(Er.handleResizeEvent=!0),this._scrollBackWindow()},i._adjustWindowScroll=function(){var t=this;setTimeout((function(){ln.scrollY<40&&t._edTxt.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}),400)},i._scrollBackWindow=function(){setTimeout((function(){rn.browserType!==Fs.WECHAT||rn.os!==Os.IOS?ln.scrollTo(0,0):ln.top&&ln.top.scrollTo(0,0)}),400)},i._updateMatrix=function(){if(this._edTxt){var t=this._delegate.node,e=V_.getScaleX(),i=V_.getScaleY(),n=V_.getViewportRect(),r=Er.devicePixelRatio;t.getWorldMatrix(D$);var s=t._uiProps.uiTransformComp;if(s&&ji.set(F$,-s.anchorX*s.width,-s.anchorY*s.height,F$.z),Ue.transform(D$,D$,F$),t._uiProps.uiTransformComp){var a=Di.root.batcher2D.getFirstRenderCamera(t);if(a){a.node.getWorldRT(O$);var o=O$.m12,h=O$.m13,l=Bn.center;O$.m12=l.x-(O$.m00*o+O$.m04*h),O$.m13=l.y-(O$.m01*o+O$.m05*h),Ue.multiply(O$,O$,D$),e/=r,i/=r;var u=qr.container,c=O$.m00*e,d=D$.m01,_=D$.m04,f=O$.m05*i,p=parseInt(u&&u.style.paddingLeft||"0");p+=n.x/r;var g=parseInt(u&&u.style.paddingBottom||"0");g+=n.y/r;var m="matrix("+c+","+-d+","+-_+","+f+","+(O$.m12*e+p)+","+-(O$.m13*i+g)+")";this._edTxt.style.transform=m,this._edTxt.style["-webkit-transform"]=m,this._edTxt.style["transform-origin"]="0px 100% 0px",this._edTxt.style["-webkit-transform-origin"]="0px 100% 0px"}}}},i._updateInputType=function(){var t=this._delegate,e=t.inputMode,i=t.inputFlag,n=t.returnType,r=this._edTxt;if(this._inputMode!==e||this._inputFlag!==i||this._returnType!==n){if(this._inputMode=e,this._inputFlag=i,this._returnType=n,this._isTextArea){var s="none";return i===JJ.INITIAL_CAPS_ALL_CHARACTERS?s="uppercase":i===JJ.INITIAL_CAPS_WORD&&(s="capitalize"),void(r.style.textTransform=s)}if(r=r,i===JJ.PASSWORD)return r.type="password",void(r.style.textTransform="none");var a=r.type;e===QJ.EMAIL_ADDR?a="email":e===QJ.NUMERIC||e===QJ.DECIMAL?a="number":e===QJ.PHONE_NUMBER?(a="number",r.pattern="[0-9]*",r.addEventListener("wheel",(function(){return!1}))):e===QJ.URL?a="url":(a="text",n===ZJ.SEARCH&&(a="search")),r.type=a;var o="none";i===JJ.INITIAL_CAPS_ALL_CHARACTERS?o="uppercase":i===JJ.INITIAL_CAPS_WORD&&(o="capitalize"),r.style.textTransform=o}},i._updateMaxLength=function(){var t=this._delegate.maxLength;t<0&&(t=65535),this._edTxt.maxLength=t},i._initStyleSheet=function(){if(this._edTxt){var t=this._edTxt;t.style.color="#000000",t.style.border="0px",t.style.background="transparent",t.style.width="100%",t.style.height="100%",t.style.outline="medium",t.style.padding="0",t.style.textTransform="none",t.style.display="none",t.style.position="absolute",t.style.bottom="0px",t.style.left="2px",t.className="cocosEditBox",t.style.fontFamily="Arial",t.id=this._domId,this._isTextArea?(t.style.resize="none",t.style.overflowY="scroll"):((t=t).type="text",t.style["-moz-appearance"]="textfield"),this._placeholderStyleSheet=P$.createElement("style")}},i._updateStyleSheet=function(){var t=this._delegate,e=this._edTxt;e&&t&&(e.value=t.string,this._updateTextLabel(t.textLabel))},i._updateTextLabel=function(t){if(t){var e=t.font;e=!e||e instanceof rh?t.fontFamily:e._fontFamily;var i=t.fontSize*t.node.scale.y;if((this._textLabelFont!==e||this._textLabelFontSize!==i||this._textLabelFontColor!==t.fontColor||this._textLabelAlign!==t.horizontalAlign)&&(this._textLabelFont=e,this._textLabelFontSize=i,this._textLabelFontColor=t.fontColor,this._textLabelAlign=t.horizontalAlign,this._edTxt)){var n=this._edTxt;switch(n.style.fontSize=i+"px",n.style.color=t.color.toCSS(),n.style.fontFamily=e,t.horizontalAlign){case Mu.HorizontalAlign.LEFT:n.style.textAlign="left";break;case Mu.HorizontalAlign.CENTER:n.style.textAlign="center";break;case Mu.HorizontalAlign.RIGHT:n.style.textAlign="right"}}}},i._updatePlaceholderLabel=function(t){if(t){var e=t.font;e=!e||e instanceof rh?t.fontFamily:t.font._fontFamily;var i=t.fontSize*t.node.scale.y;if(this._placeholderLabelFont!==e||this._placeholderLabelFontSize!==i||this._placeholderLabelFontColor!==t.fontColor||this._placeholderLabelAlign!==t.horizontalAlign||this._placeholderLineHeight!==t.fontSize){this._placeholderLabelFont=e,this._placeholderLabelFontSize=i,this._placeholderLabelFontColor=t.fontColor,this._placeholderLabelAlign=t.horizontalAlign,this._placeholderLineHeight=t.fontSize;var n=this._placeholderStyleSheet,r=t.color.toCSS(),s=t.fontSize,a="";switch(t.horizontalAlign){case Mu.HorizontalAlign.LEFT:a="left";break;case Mu.HorizontalAlign.CENTER:a="center";break;case Mu.HorizontalAlign.RIGHT:a="right"}n.innerHTML="#"+this._domId+"::-webkit-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+a+";}#"+this._domId+"::-moz-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+a+";}#"+this._domId+"::-ms-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+a+";}",rn.browserType===Fs.EDGE&&(n.innerHTML+="#"+this._domId+"::-ms-clear{display: none;}")}}},i._registerEventListeners=function(){var t=this;if(this._edTxt){var e=this._edTxt,i=!1,n=this.__eventListeners;n.compositionStart=function(){i=!0},n.compositionEnd=function(){i=!1,t._delegate._editBoxTextChanged(e.value)},n.onInput=function(){if(!i){var n=t._delegate,r=n.maxLength;r>=0&&(e.value=e.value.slice(0,r)),n._editBoxTextChanged(e.value)}},n.onClick=function(){t._editing&&rn.isMobile&&t._adjustWindowScroll()},n.onKeydown=function(i){i.keyCode===Oa.ENTER?(i.propagationStopped=!0,t._delegate._editBoxEditingReturn(),t._isTextArea||e.blur()):i.keyCode===Oa.TAB&&(i.propagationStopped=!0,i.preventDefault(),$J.next(t))},n.onBlur=function(){rn.isMobile&&i&&n.compositionEnd(),t._editing=!1,L$=null,t._hideDom(),t._delegate._editBoxEditingDidEnded()},e.addEventListener("compositionstart",n.compositionStart),e.addEventListener("compositionend",n.compositionEnd),e.addEventListener("input",n.onInput),e.addEventListener("keydown",n.onKeydown),e.addEventListener("blur",n.onBlur),e.addEventListener("touchstart",n.onClick)}},i._removeEventListeners=function(){if(this._edTxt){var t=this._edTxt,e=this.__eventListeners;t.removeEventListener("compositionstart",e.compositionStart),t.removeEventListener("compositionend",e.compositionEnd),t.removeEventListener("input",e.onInput),t.removeEventListener("keydown",e.onKeydown),t.removeEventListener("blur",e.onBlur),t.removeEventListener("touchstart",e.onClick),e.compositionStart=null,e.compositionEnd=null,e.onInput=null,e.onKeydown=null,e.onBlur=null,e.onClick=null}},e}(B$);!function(t){t.EDITING_DID_BEGAN="editing-did-began",t.EDITING_DID_ENDED="editing-did-ended",t.TEXT_CHANGED="text-changed",t.EDITING_RETURN="editing-return",t.XR_EDITING_DID_BEGAN="xr-editing-did-began",t.XR_EDITING_DID_ENDED="xr-editing-did-ended"}(I$||(I$={}));var U$,G$,V$,H$,z$,X$,W$,Y$,j$,K$,q$,Z$,Q$,J$,$$,t0,e0,i0,n0,r0,s0,a0,o0,h0,l0,u0,c0,d0,_0,f0,p0,g0,m0,v0,y0,T0=function(e){return t({EditBox:e,EditBoxComponent:e}),e}((t$=Ki("cc.EditBox"),e$=In(110),i$=kn(Bl),n$=Tn(Mu),r$=Tn(Mu),s$=Tn(Uo),a$=Tn(JJ),o$=Tn(QJ),h$=Tn(ZJ),l$=Tn([Pa]),u$=Tn([Pa]),c$=Tn([Pa]),d$=Tn([Pa]),t$(_$=e$(_$=i$((M$=w$=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).editingDidBegan=p$&&p$(),e.textChanged=g$&&g$(),e.editingDidEnded=m$&&m$(),e.editingReturn=v$&&v$(),e._impl=null,e._background=null,e._textLabel=y$&&y$(),e._placeholderLabel=T$&&T$(),e._returnType=S$&&S$(),e._string=E$&&E$(),e._tabIndex=A$&&A$(),e._backgroundImage=C$&&C$(),e._inputFlag=R$&&R$(),e._inputMode=b$&&b$(),e._maxLength=x$&&x$(),e._isLabelVisible=!1,e}He(e,t);var i=e.prototype;return i.__preload=function(){this._init()},i.onEnable=function(){this._registerEvent(),this._ensureBackgroundSprite(),this._impl&&this._impl.onEnable()},i.update=function(){this._impl&&this._impl.update()},i.onDisable=function(){this._unregisterEvent(),this._unregisterBackgroundEvent(),this._impl&&this._impl.onDisable()},i.onDestroy=function(){this._impl&&this._impl.clear()},i.setFocus=function(){this._impl&&this._impl.setFocus(!0)},i.focus=function(){this._impl&&this._impl.setFocus(!0)},i.blur=function(){this._impl&&this._impl.setFocus(!1)},i.isFocused=function(){return!!this._impl&&this._impl.isFocused()},i._editBoxEditingDidBegan=function(){Pa.emitEvents(this.editingDidBegan,this),this.node.emit(I$.EDITING_DID_BEGAN,this)},i._editBoxEditingDidEnded=function(t){Pa.emitEvents(this.editingDidEnded,this),this.node.emit(I$.EDITING_DID_ENDED,this,t)},i._editBoxTextChanged=function(t){t=this._updateLabelStringStyle(t,!0),this.string=t,Pa.emitEvents(this.textChanged,t,this),this.node.emit(I$.TEXT_CHANGED,this)},i._editBoxEditingReturn=function(t){Pa.emitEvents(this.editingReturn,this),this.node.emit(I$.EDITING_RETURN,this,t)},i._showLabels=function(){this._isLabelVisible=!0,this._updateLabels()},i._hideLabels=function(){this._isLabelVisible=!1,this._textLabel&&(this._textLabel.node.active=!1),this._placeholderLabel&&(this._placeholderLabel.node.active=!1)},i._onTouchBegan=function(t){t.propagationStopped=!0},i._onTouchCancel=function(t){t.propagationStopped=!0},i._onTouchEnded=function(t){this._impl&&this._impl.beginEditing(),t.propagationStopped=!0},i._init=function(){this._updatePlaceholderLabel(),this._updateTextLabel(),this._isLabelVisible=!0,this.node.on(xn.SIZE_CHANGED,this._resizeChildNodes,this),(this._impl=new e._EditBoxImpl).init(this),this._updateString(this._string),this._syncSize()},i._ensureBackgroundSprite=function(){if(!this._background){var t=this.node.getComponent(Bd);t||(t=this.node.addComponent(Bd)),t!==this._background&&(t.type=Bd.Type.SLICED,t.spriteFrame=this._backgroundImage,this._background=t,this._registerBackgroundEvent())}},i._updateTextLabel=function(){var t=this._textLabel;if(!t){var e=this.node.getChildByName("TEXT_LABEL");e||((e=new Pr("TEXT_LABEL")).layer=this.node.layer),(t=e.getComponent(Mu))||(t=e.addComponent(Mu)),e.parent=this.node,this._textLabel=t}this._textLabel.node._uiProps.uiTransformComp.setAnchorPoint(0,1),t.overflow=Mu.Overflow.CLAMP,this._inputMode===QJ.ANY?(t.verticalAlign=Ru.TOP,t.enableWrapText=!0):t.enableWrapText=!1,t.string=this._updateLabelStringStyle(this._string)},i._updatePlaceholderLabel=function(){var t=this._placeholderLabel;if(!t){var e=this.node.getChildByName("PLACEHOLDER_LABEL");e||((e=new Pr("PLACEHOLDER_LABEL")).layer=this.node.layer),(t=e.getComponent(Mu))||(t=e.addComponent(Mu)),e.parent=this.node,this._placeholderLabel=t}this._placeholderLabel.node._uiProps.uiTransformComp.setAnchorPoint(0,1),this._inputMode===QJ.ANY?t.enableWrapText=!0:t.enableWrapText=!1,t.string=this.placeholder},i._syncSize=function(){var t=this.node._uiProps.uiTransformComp,e=t.contentSize;if(this._background){var i=this._background.node._uiProps.uiTransformComp;i.anchorPoint=t.anchorPoint,i.setContentSize(e)}this._updateLabelPosition(e),this._impl&&this._impl.setSize(e.width,e.height)},i._updateLabels=function(){if(this._isLabelVisible){var t=this._string;this._textLabel&&(this._textLabel.node.active=""!==t),this._placeholderLabel&&(this._placeholderLabel.node.active=""===t)}},i._updateString=function(t){var e=this._textLabel;if(e){var i=t;i&&(i=this._updateLabelStringStyle(i)),e.string=i,this._updateLabels()}},i._updateLabelStringStyle=function(t,e){void 0===e&&(e=!1);var i,n=this._inputFlag;if(e||n!==JJ.PASSWORD)n===JJ.INITIAL_CAPS_ALL_CHARACTERS?t=t.toUpperCase():n===JJ.INITIAL_CAPS_WORD?t=t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()})):n===JJ.INITIAL_CAPS_SENTENCE&&(t=(i=t).charAt(0).toUpperCase()+i.slice(1));else{for(var r="",s=t.length,a=0;a<s;++a)r+="●";t=r}return t},i._registerEvent=function(){this.node.on(xn.TOUCH_START,this._onTouchBegan,this),this.node.on(xn.TOUCH_END,this._onTouchEnded,this),this.node.on(hJ.XRUI_UNCLICK,this._xrUnClick,this),this.node.on(lJ.XR_KEYBOARD_INPUT,this._xrKeyBoardInput,this)},i._unregisterEvent=function(){this.node.off(xn.TOUCH_START,this._onTouchBegan,this),this.node.off(xn.TOUCH_END,this._onTouchEnded,this),this.node.off(hJ.XRUI_UNCLICK,this._xrUnClick,this),this.node.off(lJ.XR_KEYBOARD_INPUT,this._xrKeyBoardInput,this)},i._onBackgroundSpriteFrameChanged=function(){this._background&&(this.backgroundImage=this._background.spriteFrame)},i._registerBackgroundEvent=function(){var t=this._background&&this._background.node;null==t||t.on(Bd.EventType.SPRITE_FRAME_CHANGED,this._onBackgroundSpriteFrameChanged,this)},i._unregisterBackgroundEvent=function(){var t=this._background&&this._background.node;null==t||t.off(Bd.EventType.SPRITE_FRAME_CHANGED,this._onBackgroundSpriteFrameChanged,this)},i._updateLabelPosition=function(t){var e=this.node._uiProps.uiTransformComp,i=-e.anchorX*e.width,n=-e.anchorY*e.height,r=this._placeholderLabel,s=this._textLabel;s&&(s.node._uiProps.uiTransformComp.setContentSize(t.width-2,t.height),s.node.setPosition(i+2,n+t.height,s.node.position.z),this._inputMode===QJ.ANY&&(s.verticalAlign=Ru.TOP),s.enableWrapText=this._inputMode===QJ.ANY),r&&(r.node._uiProps.uiTransformComp.setContentSize(t.width-2,t.height),r.lineHeight=t.height,r.node.setPosition(i+2,n+t.height,r.node.position.z),r.enableWrapText=this._inputMode===QJ.ANY)},i._resizeChildNodes=function(){var t=this.node._uiProps.uiTransformComp,e=this._textLabel&&this._textLabel.node;e&&(e.setPosition(-t.width/2,t.height/2,e.position.z),e._uiProps.uiTransformComp.setContentSize(t.contentSize));var i=this._placeholderLabel&&this._placeholderLabel.node;i&&(i.setPosition(-t.width/2,t.height/2,i.position.z),i._uiProps.uiTransformComp.setContentSize(t.contentSize));var n=this._background&&this._background.node;n&&n._uiProps.uiTransformComp.setContentSize(t.contentSize),this._syncSize()},i._xrUnClick=function(){this.node.emit(I$.XR_EDITING_DID_BEGAN,this._maxLength,this.string)},i._xrKeyBoardInput=function(t){this.string=t},Pi(e,[{key:"string",get:function(){return this._string},set:function(t){this._maxLength>=0&&t.length>=this._maxLength&&(t=t.slice(0,this._maxLength)),this._string!==t&&(this._string=t,this._updateString(t))}},{key:"placeholder",get:function(){return this._placeholderLabel?this._placeholderLabel.string:""},set:function(t){this._placeholderLabel&&(this._placeholderLabel.string=t)}},{key:"textLabel",get:function(){return this._textLabel},set:function(t){this._textLabel!==t&&(this._textLabel=t,this._textLabel&&(this._updateTextLabel(),this._updateLabels()))}},{key:"placeholderLabel",get:function(){return this._placeholderLabel},set:function(t){this._placeholderLabel!==t&&(this._placeholderLabel=t,this._placeholderLabel&&(this._updatePlaceholderLabel(),this._updateLabels()))}},{key:"backgroundImage",get:function(){return this._backgroundImage},set:function(t){this._backgroundImage!==t&&(this._backgroundImage=t,this._ensureBackgroundSprite(),this._background.spriteFrame=t)}},{key:"inputFlag",get:function(){return this._inputFlag},set:function(t){this._inputFlag!==t&&(this._inputFlag=t,this._updateString(this._string))}},{key:"inputMode",get:function(){return this._inputMode},set:function(t){this._inputMode!==t&&(this._inputMode=t,this._updateTextLabel(),this._updatePlaceholderLabel())}},{key:"returnType",get:function(){return this._returnType},set:function(t){this._returnType=t}},{key:"maxLength",get:function(){return this._maxLength},set:function(t){this._maxLength=t}},{key:"tabIndex",get:function(){return this._tabIndex},set:function(t){this._tabIndex!==t&&(this._tabIndex=t,this._impl&&this._impl.setTabIndex(t))}}]),e}(Pn),w$._EditBoxImpl=B$,w$.KeyboardReturnType=ZJ,w$.InputFlag=JJ,w$.InputMode=QJ,w$.EventType=I$,gn((f$=M$).prototype,"textLabel",[n$],Object.getOwnPropertyDescriptor(f$.prototype,"textLabel"),f$.prototype),gn(f$.prototype,"placeholderLabel",[r$],Object.getOwnPropertyDescriptor(f$.prototype,"placeholderLabel"),f$.prototype),gn(f$.prototype,"backgroundImage",[s$],Object.getOwnPropertyDescriptor(f$.prototype,"backgroundImage"),f$.prototype),gn(f$.prototype,"inputFlag",[a$],Object.getOwnPropertyDescriptor(f$.prototype,"inputFlag"),f$.prototype),gn(f$.prototype,"inputMode",[o$],Object.getOwnPropertyDescriptor(f$.prototype,"inputMode"),f$.prototype),gn(f$.prototype,"returnType",[h$],Object.getOwnPropertyDescriptor(f$.prototype,"returnType"),f$.prototype),p$=tn(f$.prototype,"editingDidBegan",[l$,en],(function(){return[]})),g$=tn(f$.prototype,"textChanged",[u$,en],(function(){return[]})),m$=tn(f$.prototype,"editingDidEnded",[c$,en],(function(){return[]})),v$=tn(f$.prototype,"editingReturn",[d$,en],(function(){return[]})),y$=tn(f$.prototype,"_textLabel",[en],(function(){return null})),T$=tn(f$.prototype,"_placeholderLabel",[en],(function(){return null})),S$=tn(f$.prototype,"_returnType",[en],(function(){return ZJ.DEFAULT})),E$=tn(f$.prototype,"_string",[en],(function(){return""})),A$=tn(f$.prototype,"_tabIndex",[en],(function(){return 0})),C$=tn(f$.prototype,"_backgroundImage",[en],(function(){return null})),R$=tn(f$.prototype,"_inputFlag",[en],(function(){return JJ.DEFAULT})),b$=tn(f$.prototype,"_inputMode",[en],(function(){return QJ.ANY})),x$=tn(f$.prototype,"_maxLength",[en],(function(){return 20})),_$=f$))||_$)||_$)||_$));"object"!=typeof window||"object"!=typeof document||Fa||La||Na||(T0._EditBoxImpl=k$),We.internal.EditBox=T0,function(t){t[t.NONE=0]="NONE",t[t.HORIZONTAL=1]="HORIZONTAL",t[t.VERTICAL=2]="VERTICAL",t[t.GRID=3]="GRID"}(f0||(f0={})),Fn(f0),function(t){t[t.NONE=0]="NONE",t[t.CONTAINER=1]="CONTAINER",t[t.CHILDREN=2]="CHILDREN"}(p0||(p0={})),Fn(p0),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(g0||(g0={})),Fn(g0),function(t){t[t.BOTTOM_TO_TOP=0]="BOTTOM_TO_TOP",t[t.TOP_TO_BOTTOM=1]="TOP_TO_BOTTOM"}(m0||(m0={})),Fn(m0),function(t){t[t.LEFT_TO_RIGHT=0]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=1]="RIGHT_TO_LEFT"}(v0||(v0={})),Fn(v0),function(t){t[t.NONE=0]="NONE",t[t.FIXED_ROW=1]="FIXED_ROW",t[t.FIXED_COL=2]="FIXED_COL"}(y0||(y0={})),Fn(y0);var S0,E0,A0,C0,R0,b0,x0,w0,M0,I0,B0,P0,D0,O0,F0,L0=new ji,N0=function(e){return t({Layout:e,LayoutComponent:e}),e}((U$=Ki("cc.Layout"),G$=In(110),V$=kn(Bl),H$=Tn(f0),z$=Tn(p0),X$=Tn(g0),W$=Tn(m0),Y$=Tn(v0),j$=Tn(y0),U$(K$=G$(K$=V$((_0=d0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._resizeMode=Z$&&Z$(),e._layoutType=Q$&&Q$(),e._cellSize=J$&&J$(),e._startAxis=$$&&$$(),e._paddingLeft=t0&&t0(),e._paddingRight=e0&&e0(),e._paddingTop=i0&&i0(),e._paddingBottom=n0&&n0(),e._spacingX=r0&&r0(),e._spacingY=s0&&s0(),e._verticalDirection=a0&&a0(),e._horizontalDirection=o0&&o0(),e._constraint=h0&&h0(),e._constraintNum=l0&&l0(),e._affectedByScale=u0&&u0(),e._isAlign=c0&&c0(),e._layoutSize=new dn(300,200),e._layoutDirty=!0,e._childrenDirty=!1,e._usefulLayoutObj=[],e._init=!1,e}He(e,t);var i=e.prototype;return i.updateLayout=function(t){void 0===t&&(t=!1),(this._layoutDirty||t)&&(this._doLayout(),this._layoutDirty=!1)},i.onEnable=function(){this._addEventListeners();var t=this.node._uiProps.uiTransformComp;t.contentSize.equals(dn.ZERO)&&t.setContentSize(this._layoutSize),this._childrenChanged()},i.onDisable=function(){this._usefulLayoutObj.length=0,this._removeEventListeners()},i._checkUsefulObj=function(){this._usefulLayoutObj.length=0;for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e],n=i._uiProps.uiTransformComp;i.activeInHierarchy&&n&&this._usefulLayoutObj.push(n)}},i._addEventListeners=function(){Di.on(An.EVENT_AFTER_UPDATE,this.updateLayout,this),this.node.on(xn.SIZE_CHANGED,this._resized,this),this.node.on(xn.ANCHOR_CHANGED,this._doLayoutDirty,this),this.node.on(xn.CHILD_ADDED,this._childAdded,this),this.node.on(xn.CHILD_REMOVED,this._childRemoved,this),this.node.on(xn.SIBLING_ORDER_CHANGED,this._childrenChanged,this),this.node.on("childrenSiblingOrderChanged",this.updateLayout,this),this._addChildrenEventListeners()},i._removeEventListeners=function(){Di.off(An.EVENT_AFTER_UPDATE,this.updateLayout,this),this.node.off(xn.SIZE_CHANGED,this._resized,this),this.node.off(xn.ANCHOR_CHANGED,this._doLayoutDirty,this),this.node.off(xn.CHILD_ADDED,this._childAdded,this),this.node.off(xn.CHILD_REMOVED,this._childRemoved,this),this.node.off(xn.SIBLING_ORDER_CHANGED,this._childrenChanged,this),this.node.off("childrenSiblingOrderChanged",this.updateLayout,this),this._removeChildrenEventListeners()},i._addChildrenEventListeners=function(){for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e];i.on(xn.SIZE_CHANGED,this._doLayoutDirty,this),i.on(xn.TRANSFORM_CHANGED,this._transformDirty,this),i.on(xn.ANCHOR_CHANGED,this._doLayoutDirty,this),i.on(xn.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this)}},i._removeChildrenEventListeners=function(){for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e];i.off(xn.SIZE_CHANGED,this._doLayoutDirty,this),i.off(xn.TRANSFORM_CHANGED,this._transformDirty,this),i.off(xn.ANCHOR_CHANGED,this._doLayoutDirty,this),i.off(xn.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this)}},i._childAdded=function(t){t.on(xn.SIZE_CHANGED,this._doLayoutDirty,this),t.on(xn.TRANSFORM_CHANGED,this._transformDirty,this),t.on(xn.ANCHOR_CHANGED,this._doLayoutDirty,this),t.on(xn.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this),this._childrenChanged()},i._childRemoved=function(t){t.off(xn.SIZE_CHANGED,this._doLayoutDirty,this),t.off(xn.TRANSFORM_CHANGED,this._transformDirty,this),t.off(xn.ANCHOR_CHANGED,this._doLayoutDirty,this),t.off(xn.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this),this._childrenChanged()},i._resized=function(){this._layoutSize.set(this.node._uiProps.uiTransformComp.contentSize),this._doLayoutDirty()},i._doLayoutHorizontally=function(t,e,i,n){var r=this.node._uiProps.uiTransformComp.anchorPoint,s=this._getFixedBreakingNum(),a=1,o=this._paddingLeft;this._horizontalDirection===v0.RIGHT_TO_LEFT&&(a=-1,o=this._paddingRight);var h=(this._horizontalDirection-r.x)*t+a*o,l=h-a*this._spacingX,u=0,c=0,d=0,_=0,f=!1,p=this._usefulLayoutObj.length,g=this._cellSize.width,m=this._getPaddingH();this._layoutType!==f0.GRID&&this._resizeMode===p0.CHILDREN&&(g=(t-m-(p-1)*this._spacingX)/p);for(var v=this._usefulLayoutObj,y=0;y<v.length;++y){var T=v[y],S=T.node,E=S.scale,A=this._getUsedScaleValue(E.x),C=this._getUsedScaleValue(E.y);this._resizeMode===p0.CHILDREN&&(T.width=g/A,this._layoutType===f0.GRID&&(T.height=this._cellSize.height/C));var R=Math.abs(this._horizontalDirection-T.anchorX),b=T.width*A,x=T.height*C;x>d&&(_=Math.max(d,_),c=d||x,d=x),l+=a*(R*b+this._spacingX);var w=a*(1-R)*b;if(e){if(s>0)(f=y/s>0&&y%s==0)&&(c=d>x?d:c);else if(b>t-m)l>h+a*R*b&&(f=!0);else{var M=(1-this._horizontalDirection-r.x)*t,I=l+w+a*(a>0?this._paddingRight:this._paddingLeft);f=Math.abs(I)>Math.abs(M)}f&&(l=h+a*R*b,x!==d&&(c=d),u+=c+this._spacingY,c=d=x)}var B=i(S,T,u);n&&S.setPosition(l,B),l+=w}return c=Math.max(c,d),Math.max(_,u+c)+this._getPaddingV()},i._doLayoutVertically=function(t,e,i,n){var r=this.node._uiProps.uiTransformComp.anchorPoint,s=this._getFixedBreakingNum(),a=1,o=this._paddingBottom;this._verticalDirection===m0.TOP_TO_BOTTOM&&(a=-1,o=this._paddingTop);var h=(this._verticalDirection-r.y)*t+a*o,l=h-a*this._spacingY,u=0,c=0,d=0,_=0,f=!1,p=this._usefulLayoutObj.length,g=this._cellSize.height,m=this._getPaddingV();this._layoutType!==f0.GRID&&this._resizeMode===p0.CHILDREN&&(g=(t-m-(p-1)*this._spacingY)/p);for(var v=this._usefulLayoutObj,y=0;y<v.length;++y){var T=v[y],S=T.node,E=S.scale,A=this._getUsedScaleValue(E.x),C=this._getUsedScaleValue(E.y);this._resizeMode===p0.CHILDREN&&(T.height=g/C,this._layoutType===f0.GRID&&(T.width=this._cellSize.width/A));var R=Math.abs(this._verticalDirection-T.anchorY),b=T.width*A,x=T.height*C;b>u&&(c=Math.max(u,c),d=u||b,u=b),l+=a*(R*x+this._spacingY);var w=a*(1-R)*x;if(e){if(s>0)(f=y/s>0&&y%s==0)&&(d=u>x?u:d);else if(x>t-m)l>h+a*R*x&&(f=!0);else{var M=(1-this._verticalDirection-r.y)*t,I=l+w+a*(a>0?this._paddingTop:this._paddingBottom);f=Math.abs(I)>Math.abs(M)}f&&(l=h+a*R*x,b!==u&&(d=u),_+=d+this._spacingX,d=u=b)}var B=i(S,T,_);n&&(S.getPosition(L0),S.setPosition(B,l,L0.z)),l+=w}return d=Math.max(d,u),Math.max(c,_+d)+this._getPaddingH()},i._doLayoutGridAxisHorizontal=function(t,e){var i=this,n=e.width,r=1,s=-t.y*e.height,a=this._paddingBottom;this._verticalDirection===m0.TOP_TO_BOTTOM&&(r=-1,s=(1-t.y)*e.height,a=this._paddingTop);var o=function(t,e,n){return s+r*(n+(1-e.anchorY)*e.height*i._getUsedScaleValue(t.scale.y)+a)},h=0;this._resizeMode===p0.CONTAINER&&(h=this._doLayoutHorizontally(n,!0,o,!1),s=-t.y*h,this._verticalDirection===m0.TOP_TO_BOTTOM&&(r=-1,s=(1-t.y)*h)),this._doLayoutHorizontally(n,!0,o,!0),this._resizeMode===p0.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(n,h)},i._doLayoutGridAxisVertical=function(t,e){var i=this,n=e.height,r=1,s=-t.x*e.width,a=this._paddingLeft;this._horizontalDirection===v0.RIGHT_TO_LEFT&&(r=-1,s=(1-t.x)*e.width,a=this._paddingRight);var o=function(t,e,n){return s+r*(n+(1-e.anchorX)*e.width*i._getUsedScaleValue(t.scale.x)+a)},h=0;this._resizeMode===p0.CONTAINER&&(h=this._doLayoutVertically(n,!0,o,!1),s=-t.x*h,this._horizontalDirection===v0.RIGHT_TO_LEFT&&(r=-1,s=(1-t.x)*h)),this._doLayoutVertically(n,!0,o,!0),this._resizeMode===p0.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(h,n)},i._doLayoutGrid=function(){var t=this.node._uiProps.uiTransformComp,e=t.anchorPoint,i=t.contentSize;this.startAxis===g0.HORIZONTAL?this._doLayoutGridAxisHorizontal(e,i):this.startAxis===g0.VERTICAL&&this._doLayoutGridAxisVertical(e,i)},i._getHorizontalBaseWidth=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===p0.CONTAINER){for(var n=0;n<t.length;++n){var r=t[n],s=r.node.scale;e+=r.width*this._getUsedScaleValue(s.x)}e+=(i-1)*this._spacingX+this._getPaddingH()}else e=this.node._uiProps.uiTransformComp.width;return e},i._getVerticalBaseHeight=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===p0.CONTAINER){for(var n=0;n<t.length;++n){var r=t[n],s=r.node.scale;e+=r.height*this._getUsedScaleValue(s.y)}e+=(i-1)*this._spacingY+this._getPaddingV()}else e=this.node._uiProps.uiTransformComp.height;return e},i._doLayout=function(){var t=this;if(this._init&&!this._childrenDirty||(this._checkUsefulObj(),this._init=!0,this._childrenDirty=!1),this._layoutType===f0.HORIZONTAL){var e=this._getHorizontalBaseWidth();this._doLayoutHorizontally(e,!1,(function(e){return(t._isAlign?ji.ZERO:e.position).y}),!0),this.node._uiProps.uiTransformComp.width=e}else if(this._layoutType===f0.VERTICAL){var i=this._getVerticalBaseHeight();this._doLayoutVertically(i,!1,(function(e){return(t._isAlign?ji.ZERO:e.position).x}),!0),this.node._uiProps.uiTransformComp.height=i}else this._layoutType===f0.GRID&&this._doLayoutGrid()},i._getUsedScaleValue=function(t){return this._affectedByScale?Math.abs(t):1},i._transformDirty=function(t){t&pr.SCALE&&t&pr.POSITION&&this._affectedByScale&&this._doLayoutDirty()},i._doLayoutDirty=function(){this._layoutDirty=!0},i._childrenChanged=function(){this._childrenDirty=!0,this._doLayoutDirty()},i._getPaddingH=function(){return this._paddingLeft+this._paddingRight},i._getPaddingV=function(){return this._paddingTop+this._paddingBottom},i._getFixedBreakingNum=function(){if(this._layoutType!==f0.GRID||this._constraint===y0.NONE||this._constraintNum<=0)return 0;var t=this._constraint===y0.FIXED_ROW?Math.ceil(this._usefulLayoutObj.length/this._constraintNum):this._constraintNum;return this._startAxis===g0.VERTICAL&&(t=this._constraint===y0.FIXED_COL?Math.ceil(this._usefulLayoutObj.length/this._constraintNum):this._constraintNum),t},Pi(e,[{key:"alignHorizontal",get:function(){return this._isAlign},set:function(t){this._layoutType===f0.HORIZONTAL&&(this._isAlign=t,this._doLayoutDirty())}},{key:"alignVertical",get:function(){return this._isAlign},set:function(t){this._layoutType===f0.VERTICAL&&(this._isAlign=t,this._doLayoutDirty())}},{key:"type",get:function(){return this._layoutType},set:function(t){this._layoutType=t,this._doLayoutDirty()}},{key:"resizeMode",get:function(){return this._resizeMode},set:function(t){this._layoutType!==f0.NONE&&(this._resizeMode=t,this._doLayoutDirty())}},{key:"cellSize",get:function(){return this._cellSize},set:function(t){this._cellSize!==t&&(this._cellSize.set(t),this._doLayoutDirty())}},{key:"startAxis",get:function(){return this._startAxis},set:function(t){this._startAxis!==t&&(this._startAxis=t,this._doLayoutDirty())}},{key:"paddingLeft",get:function(){return this._paddingLeft},set:function(t){this._paddingLeft!==t&&(this._paddingLeft=t,this._doLayoutDirty())}},{key:"paddingRight",get:function(){return this._paddingRight},set:function(t){this._paddingRight!==t&&(this._paddingRight=t,this._doLayoutDirty())}},{key:"paddingTop",get:function(){return this._paddingTop},set:function(t){this._paddingTop!==t&&(this._paddingTop=t,this._doLayoutDirty())}},{key:"paddingBottom",get:function(){return this._paddingBottom},set:function(t){this._paddingBottom!==t&&(this._paddingBottom=t,this._doLayoutDirty())}},{key:"spacingX",get:function(){return this._spacingX},set:function(t){this._spacingX!==t&&(this._spacingX=t,this._doLayoutDirty())}},{key:"spacingY",get:function(){return this._spacingY},set:function(t){this._spacingY!==t&&(this._spacingY=t,this._doLayoutDirty())}},{key:"verticalDirection",get:function(){return this._verticalDirection},set:function(t){this._verticalDirection!==t&&(this._verticalDirection=t,this._doLayoutDirty())}},{key:"horizontalDirection",get:function(){return this._horizontalDirection},set:function(t){this._horizontalDirection!==t&&(this._horizontalDirection=t,this._doLayoutDirty())}},{key:"padding",get:function(){return this._paddingLeft},set:function(t){this.paddingLeft===t&&this._paddingRight===t&&this._paddingTop===t&&this._paddingBottom===t||(this._paddingLeft=this._paddingRight=this._paddingTop=this._paddingBottom=t,this._doLayoutDirty())}},{key:"constraint",get:function(){return this._constraint},set:function(t){this._layoutType!==f0.NONE&&this._constraint!==t&&(this._constraint=t,this._doLayoutDirty())}},{key:"constraintNum",get:function(){return this._constraintNum},set:function(t){this._constraint!==y0.NONE&&this._constraintNum!==t&&(t<=0&&Gi("Limit values to be greater than 0"),this._constraintNum=t,this._doLayoutDirty())}},{key:"affectedByScale",get:function(){return this._affectedByScale},set:function(t){this._affectedByScale=t,this._doLayoutDirty()}}]),e}(Pn),d0.Type=f0,d0.VerticalDirection=m0,d0.HorizontalDirection=v0,d0.ResizeMode=p0,d0.AxisDirection=g0,d0.Constraint=y0,gn((q$=_0).prototype,"type",[H$],Object.getOwnPropertyDescriptor(q$.prototype,"type"),q$.prototype),gn(q$.prototype,"resizeMode",[z$],Object.getOwnPropertyDescriptor(q$.prototype,"resizeMode"),q$.prototype),gn(q$.prototype,"startAxis",[X$],Object.getOwnPropertyDescriptor(q$.prototype,"startAxis"),q$.prototype),gn(q$.prototype,"verticalDirection",[W$],Object.getOwnPropertyDescriptor(q$.prototype,"verticalDirection"),q$.prototype),gn(q$.prototype,"horizontalDirection",[Y$],Object.getOwnPropertyDescriptor(q$.prototype,"horizontalDirection"),q$.prototype),gn(q$.prototype,"constraint",[j$],Object.getOwnPropertyDescriptor(q$.prototype,"constraint"),q$.prototype),Z$=tn(q$.prototype,"_resizeMode",[en],(function(){return p0.NONE})),Q$=tn(q$.prototype,"_layoutType",[en],(function(){return f0.NONE})),J$=tn(q$.prototype,"_cellSize",[en],(function(){return new dn(40,40)})),$$=tn(q$.prototype,"_startAxis",[en],(function(){return g0.HORIZONTAL})),t0=tn(q$.prototype,"_paddingLeft",[en],(function(){return 0})),e0=tn(q$.prototype,"_paddingRight",[en],(function(){return 0})),i0=tn(q$.prototype,"_paddingTop",[en],(function(){return 0})),n0=tn(q$.prototype,"_paddingBottom",[en],(function(){return 0})),r0=tn(q$.prototype,"_spacingX",[en],(function(){return 0})),s0=tn(q$.prototype,"_spacingY",[en],(function(){return 0})),a0=tn(q$.prototype,"_verticalDirection",[en],(function(){return m0.TOP_TO_BOTTOM})),o0=tn(q$.prototype,"_horizontalDirection",[en],(function(){return v0.LEFT_TO_RIGHT})),h0=tn(q$.prototype,"_constraint",[en],(function(){return y0.NONE})),l0=tn(q$.prototype,"_constraintNum",[en],(function(){return 2})),u0=tn(q$.prototype,"_affectedByScale",[en],(function(){return!1})),c0=tn(q$.prototype,"_isAlign",[en],(function(){return!1})),K$=q$))||K$)||K$)||K$));We.Layout=N0,function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.FILLED=2]="FILLED"}(F0||(F0={})),fr(F0);var k0,U0,G0,V0,H0,z0,X0,W0,Y0,j0,K0,q0,Z0,Q0,J0=function(e){return t({ProgressBar:e,ProgressBarComponent:e}),e}((S0=Ki("cc.ProgressBar"),E0=In(110),A0=kn(Bl),C0=Tn(Bd),R0=Tn(F0),S0(b0=E0(b0=A0((O0=D0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._barSprite=w0&&w0(),e._mode=M0&&M0(),e._totalLength=I0&&I0(),e._progress=B0&&B0(),e._reverse=P0&&P0(),e}He(e,t);var i=e.prototype;return i._initBarSprite=function(){if(this._barSprite){var t=this._barSprite.node;if(!t)return;var e=this.node._uiProps.uiTransformComp,i=e.contentSize,n=e.anchorPoint,r=t._uiProps.uiTransformComp.contentSize;if(this._barSprite.fillType===Bd.FillType.RADIAL&&(this._mode=F0.FILLED),this._mode===F0.HORIZONTAL?this.totalLength=r.width:this._mode===F0.VERTICAL?this.totalLength=r.height:this.totalLength=this._barSprite.fillRange,t.parent===this.node){var s=-i.width*n.x;t.setPosition(s,0,0)}}},i._updateBarStatus=function(){if(this._barSprite){var t=this._barSprite.node;if(!t)return;var e=t._uiProps.uiTransformComp,i=e.anchorPoint,n=e.contentSize,r=t.getPosition(),s=new cn(0,.5),a=Bs(this._progress),o=this._totalLength*a,h=n,l=0,u=0;switch(this._mode){case F0.HORIZONTAL:this._reverse&&(s=new cn(1,.5)),h=new dn(o,n.height),l=this._totalLength,u=n.height;break;case F0.VERTICAL:s=this._reverse?new cn(.5,1):new cn(.5,0),h=new dn(n.width,o),l=n.width,u=this._totalLength}if(this._mode===F0.FILLED)this._barSprite.type!==Bd.Type.FILLED?Gi("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"):(this._reverse&&(o*=-1),this._barSprite.fillRange=o);else if(this._barSprite.type!==Bd.Type.FILLED){var c=s.x-i.x,d=s.y-i.y,_=new ji(l*c,u*d,0);t.setPosition(r.x+_.x,r.y+_.y,r.z),e.setAnchorPoint(s),e.setContentSize(h)}else Gi("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!")}},Pi(e,[{key:"barSprite",get:function(){return this._barSprite},set:function(t){this._barSprite!==t&&(this._barSprite=t,this._initBarSprite())}},{key:"mode",get:function(){return this._mode},set:function(t){if(this._mode!==t&&(this._mode=t,this._barSprite)){var e=this._barSprite.node;if(!e)return;var i=e._uiProps.uiTransformComp.contentSize;this._mode===F0.HORIZONTAL?this.totalLength=i.width:this._mode===F0.VERTICAL?this.totalLength=i.height:this._mode===F0.FILLED&&(this.totalLength=this._barSprite.fillRange)}}},{key:"totalLength",get:function(){return this._totalLength},set:function(t){this._mode===F0.FILLED&&(t=Bs(t)),this._totalLength!==t&&(this._totalLength=t,this._updateBarStatus())}},{key:"progress",get:function(){return this._progress},set:function(t){this._progress!==t&&(this._progress=t,this._updateBarStatus())}},{key:"reverse",get:function(){return this._reverse},set:function(t){this._reverse!==t&&(this._reverse=t,this._barSprite&&(this._barSprite.fillStart=1-this._barSprite.fillStart),this._updateBarStatus())}}]),e}(Pn),D0.Mode=F0,gn((x0=O0).prototype,"barSprite",[C0],Object.getOwnPropertyDescriptor(x0.prototype,"barSprite"),x0.prototype),gn(x0.prototype,"mode",[R0],Object.getOwnPropertyDescriptor(x0.prototype,"mode"),x0.prototype),w0=tn(x0.prototype,"_barSprite",[en],(function(){return null})),M0=tn(x0.prototype,"_mode",[en],(function(){return F0.HORIZONTAL})),I0=tn(x0.prototype,"_totalLength",[en],(function(){return 1})),B0=tn(x0.prototype,"_progress",[en],(function(){return.1})),P0=tn(x0.prototype,"_reverse",[en],(function(){return!1})),b0=x0))||b0)||b0)||b0));We.ProgressBar=J0;var $0,t1=new ji,e1=new ji,i1=new ji,n1=new cn,r1=new Ve,s1=new cn;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}($0||($0={})),Fn($0);var a1,o1=function(e){return t({ScrollBar:e,ScrollBarComponent:e}),e}((k0=Ki("cc.ScrollBar"),U0=In(110),G0=kn(Bl),V0=Tn(Bd),H0=Tn($0),k0(z0=U0(z0=G0((Q0=Z0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._scrollView=W0&&W0(),e._handle=Y0&&Y0(),e._direction=j0&&j0(),e._enableAutoHide=K0&&K0(),e._autoHideTime=q0&&q0(),e._touching=!1,e._opacity=255,e._autoHideRemainingTime=0,e}He(e,t);var i=e.prototype;return i.hide=function(){this._autoHideRemainingTime=0,this._setOpacity(0)},i.show=function(){this._autoHideRemainingTime=this._autoHideTime,this._opacity=255,this._setOpacity(this._opacity)},i.onScroll=function(t){if(this._scrollView){var e=this._scrollView.content;if(e){var i=e._uiProps.uiTransformComp.contentSize,n=this._scrollView.node._uiProps.uiTransformComp.contentSize,r=this.node._uiProps.uiTransformComp.contentSize;if(!this._conditionalDisableScrollBar(i,n)){this._enableAutoHide&&(this._autoHideRemainingTime=this._autoHideTime,this._setOpacity(this._opacity));var s=0,a=0,o=0,h=0,l=0,u=s1;u.set(0,0),this._direction===$0.HORIZONTAL?(s=i.width,a=n.width,l=r.width,o=t.x,this._convertToScrollViewSpace(u,e),h=-u.x):this._direction===$0.VERTICAL&&(s=i.height,a=n.height,l=r.height,o=t.y,this._convertToScrollViewSpace(u,e),h=-u.y);var c=this._calculateLength(s,a,l,o),d=s1;this._calculatePosition(d,s,a,l,h,o,c),this._updateLength(c),this._updateHandlerPosition(d)}}}},i.setScrollView=function(t){this._scrollView=t},i.onTouchBegan=function(){this._enableAutoHide&&(this._touching=!0)},i.onTouchEnded=function(){if(this._enableAutoHide&&(this._touching=!1,!(this._autoHideTime<=0))){if(this._scrollView){var t=this._scrollView.content;if(t){var e=t._uiProps.uiTransformComp.contentSize,i=this._scrollView.node._uiProps.uiTransformComp.contentSize;if(this._conditionalDisableScrollBar(e,i))return}}this._autoHideRemainingTime=this._autoHideTime}},i.onEnable=function(){var t=this.node.getComponent(Bd);t&&(this._opacity=t.color.a)},i.start=function(){this._enableAutoHide&&this._setOpacity(0)},i.update=function(t){this._processAutoHide(t)},i._convertToScrollViewSpace=function(t,e){var i=this._scrollView&&this._scrollView.node._uiProps.uiTransformComp,n=e._uiProps.uiTransformComp;if(i&&n){t1.set(-n.anchorX*n.width,-n.anchorY*n.height,0),n.convertToWorldSpaceAR(t1,e1);var r=i.convertToNodeSpaceAR(e1);r.x+=i.anchorX*i.width,r.y+=i.anchorY*i.height,t.set(r.x,r.y)}else t.set(cn.ZERO)},i._setOpacity=function(t){if(this._handle){var e=this.node.getComponent(Bd);e&&(r1.set(e.color),r1.a=t,e.color=r1),(e=this._handle.getComponent(Bd))&&(r1.set(e.color),r1.a=t,e.color=r1)}},i._updateHandlerPosition=function(t){if(this._handle){var e=i1;this._fixupHandlerPosition(e),this._handle.node.setPosition(t.x+e.x,t.y+e.y,e.z)}},i._fixupHandlerPosition=function(t){var e=this.node._uiProps.uiTransformComp,i=e.contentSize,n=e.anchorPoint,r=this.handle.node._uiProps.uiTransformComp.contentSize,s=this.handle.node.parent;ji.set(t1,-i.width*n.x,-i.height*n.y,0);var a=this.node._uiProps.uiTransformComp.convertToWorldSpaceAR(t1,e1),o=t;o.set(0,0,0),s._uiProps.uiTransformComp.convertToNodeSpaceAR(a,o),this.direction===$0.HORIZONTAL?o.set(o.x,o.y+(i.height-r.height)/2,o.z):this.direction===$0.VERTICAL&&o.set(o.x+(i.width-r.width)/2,o.y,o.z),this.handle.node.setPosition(o)},i._conditionalDisableScrollBar=function(t,e){return t.width<=e.width&&this._direction===$0.HORIZONTAL||t.height<=e.height&&this._direction===$0.VERTICAL},i._calculateLength=function(t,e,i,n){var r=t;return n&&(r+=20*(n>0?n:-n)),i*(e/r)},i._calculatePosition=function(t,e,i,n,r,s,a){var o=e-i;s&&(o+=Math.abs(s));var h=0;o&&(h=Bs(h=r/o));var l=(n-a)*h;this._direction===$0.VERTICAL?t.set(0,l):t.set(l,0)},i._updateLength=function(t){if(this._handle){var e=this._handle.node._uiProps.uiTransformComp,i=e.contentSize,n=e.anchorPoint;n.x===n1.x&&n.y===n1.y||e.setAnchorPoint(n1),this._direction===$0.HORIZONTAL?e.setContentSize(t,i.height):e.setContentSize(i.width,t)}},i._processAutoHide=function(t){if(this._enableAutoHide&&!(this._autoHideRemainingTime<=0)&&!this._touching&&(this._autoHideRemainingTime-=t,this._autoHideRemainingTime<=this._autoHideTime)){this._autoHideRemainingTime=Math.max(0,this._autoHideRemainingTime);var e=this._opacity*(this._autoHideRemainingTime/this._autoHideTime);this._setOpacity(e)}},Pi(e,[{key:"handle",get:function(){return this._handle},set:function(t){this._handle!==t&&(this._handle=t,this.onScroll(cn.ZERO))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this.onScroll(cn.ZERO))}},{key:"enableAutoHide",get:function(){return this._enableAutoHide},set:function(t){this._enableAutoHide!==t&&(this._enableAutoHide=t,this._enableAutoHide&&this._setOpacity(0))}},{key:"autoHideTime",get:function(){return this._autoHideTime},set:function(t){this._autoHideTime!==t&&(this._autoHideTime=t)}}]),e}(Pn),Z0.Direction=$0,gn((X0=Q0).prototype,"handle",[V0],Object.getOwnPropertyDescriptor(X0.prototype,"handle"),X0.prototype),gn(X0.prototype,"direction",[H0],Object.getOwnPropertyDescriptor(X0.prototype,"direction"),X0.prototype),W0=tn(X0.prototype,"_scrollView",[en],(function(){return null})),Y0=tn(X0.prototype,"_handle",[en],(function(){return null})),j0=tn(X0.prototype,"_direction",[en],(function(){return $0.HORIZONTAL})),K0=tn(X0.prototype,"_enableAutoHide",[en],(function(){return!1})),q0=tn(X0.prototype,"_autoHideTime",[en],(function(){return 1})),z0=X0))||z0)||z0)||z0));We.ScrollBar=o1;var h1,l1,u1,c1,d1,_1,f1,p1,g1,m1,v1,y1,T1,S1,E1,A1,C1,R1,b1,x1,w1,M1,I1=t("ViewGroup",Ki("cc.ViewGroup")(a1=In(110)(a1=function(t){function e(){return t.apply(this,arguments)||this}return He(e,t),e}(Pn))||a1)||a1);We.ViewGroup=I1;var B1,P1,D1=1e-4,O1=new ji,F1=new ji,L1=new cn,N1=new cn,k1=function(){return(new Date).getMilliseconds()},U1={"scroll-to-top":0,"scroll-to-bottom":1,"scroll-to-left":2,"scroll-to-right":3,scrolling:4,"bounce-bottom":6,"bounce-left":7,"bounce-right":8,"bounce-top":5,"scroll-ended":9,"touch-up":10,"scroll-ended-with-threshold":11,"scroll-began":12};!function(t){t.SCROLL_TO_TOP="scroll-to-top",t.SCROLL_TO_BOTTOM="scroll-to-bottom",t.SCROLL_TO_LEFT="scroll-to-left",t.SCROLL_TO_RIGHT="scroll-to-right",t.SCROLL_BEGAN="scroll-began",t.SCROLL_ENDED="scroll-ended",t.BOUNCE_TOP="bounce-top",t.BOUNCE_BOTTOM="bounce-bottom",t.BOUNCE_LEFT="bounce-left",t.BOUNCE_RIGHT="bounce-right",t.SCROLLING="scrolling",t.SCROLL_ENG_WITH_THRESHOLD="scroll-ended-with-threshold",t.TOUCH_UP="touch-up"}(B1||(B1={})),function(t){t[t.NONE=0]="NONE",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT"}(P1||(P1={}));var G1,V1,H1,z1,X1,W1,Y1,j1,K1,q1,Z1,Q1,J1,$1,t2=function(e){return t({ScrollView:e,ScrollViewComponent:e}),e}((h1=Ki("cc.ScrollView"),l1=In(110),u1=kn(Bl),c1=Tn(Pr),d1=Tn(o1),_1=Tn(o1),f1=Tn([Pa]),h1(p1=l1(p1=u1((M1=w1=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).bounceDuration=m1&&m1(),e.brake=v1&&v1(),e.elastic=y1&&y1(),e.inertia=T1&&T1(),e.horizontal=S1&&S1(),e.vertical=E1&&E1(),e.cancelInnerEvents=A1&&A1(),e.scrollEvents=C1&&C1(),e._autoScrolling=!1,e._scrolling=!1,e._content=R1&&R1(),e._horizontalScrollBar=b1&&b1(),e._verticalScrollBar=x1&&x1(),e._topBoundary=0,e._bottomBoundary=0,e._leftBoundary=0,e._rightBoundary=0,e._touchMoveDisplacements=[],e._touchMoveTimeDeltas=[],e._touchMovePreviousTimestamp=0,e._touchMoved=!1,e._autoScrollAttenuate=!1,e._autoScrollStartPosition=new ji,e._autoScrollTargetDelta=new ji,e._autoScrollTotalTime=0,e._autoScrollAccumulatedTime=0,e._autoScrollCurrentlyOutOfBoundary=!1,e._autoScrollBraking=!1,e._autoScrollBrakingStartPosition=new ji,e._outOfBoundaryAmount=new ji,e._outOfBoundaryAmountDirty=!0,e._stopMouseWheel=!1,e._mouseWheelEventElapsedTime=0,e._isScrollEndedWithThresholdEventFired=!1,e._scrollEventEmitMask=0,e._isBouncing=!1,e._contentPos=new ji,e._deltaPos=new ji,e._hoverIn=P1.NONE,e}He(e,t);var i=e.prototype;return i.scrollToBottom=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new cn(0,0),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i,!0)},i.scrollToTop=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new cn(0,1),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new cn(0,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new cn(1,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToTopLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new cn(0,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToTopRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new cn(1,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToBottomLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new cn(0,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToBottomRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new cn(1,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToOffset=function(t,e,i){void 0===i&&(i=!0);var n=this.getMaxScrollOffset(),r=new cn(0,0);0===n.x?r.x=0:r.x=t.x/n.x,0===n.y?r.y=1:r.y=(n.y-t.y)/n.y,this.scrollTo(r,e,i)},i.getScrollOffset=function(){var t=this._getContentTopBoundary()-this._topBoundary,e=this._getContentLeftBoundary()-this._leftBoundary;return new cn(e,t)},i.getMaxScrollOffset=function(){if(!this._content||!this.view)return cn.ZERO;var t=this._content._uiProps.uiTransformComp.contentSize,e=t.width-this.view.width,i=t.height-this.view.height;return new cn(e=e>=0?e:0,i=i>=0?i:0)},i.scrollToPercentHorizontal=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new cn(t,0),applyToHorizontal:!0,applyToVertical:!1});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},i.scrollTo=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new cn(t),applyToHorizontal:!0,applyToVertical:!0});e?this._startAutoScroll(n,e,i):this._moveContent(n)},i.scrollToPercentVertical=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new cn(0,t),applyToHorizontal:!1,applyToVertical:!0});e?this._startAutoScroll(n,e,i):this._moveContent(n)},i.stopAutoScroll=function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},i.setContentPosition=function(t){this._setContentPosition(t)},i._setContentPosition=function(t){if(this._content){var e=this._getContentPosition();Math.abs(t.x-e.x)<D1&&Math.abs(t.y-e.y)<D1||(this._content.setPosition(t),this._outOfBoundaryAmountDirty=!0)}},i.getContentPosition=function(){return this._getContentPosition()},i._getContentPosition=function(){return this._content?(this._contentPos.set(this._content.position),this._contentPos):ji.ZERO.clone()},i.isScrolling=function(){return this._scrolling},i.isAutoScrolling=function(){return this._autoScrolling},i.getScrollEndedEventTiming=function(){return D1},i.start=function(){this._calculateBoundary(),this._content&&Di.once(An.EVENT_BEFORE_DRAW,this._adjustContentOutOfBoundary,this)},i.onEnable=function(){this._registerEvent(),this._content&&(this._content.on(xn.SIZE_CHANGED,this._calculateBoundary,this),this._content.on(xn.TRANSFORM_CHANGED,this._scaleChanged,this),this.view&&(this.view.node.on(xn.TRANSFORM_CHANGED,this._scaleChanged,this),this.view.node.on(xn.SIZE_CHANGED,this._calculateBoundary,this))),this._calculateBoundary(),this._updateScrollBarState()},i.update=function(t){this._autoScrolling&&this._processAutoScrolling(t)},i.onDisable=function(){this._unregisterEvent(),this._content&&(this._content.off(xn.SIZE_CHANGED,this._calculateBoundary,this),this._content.off(xn.TRANSFORM_CHANGED,this._scaleChanged,this),this.view&&(this.view.node.off(xn.TRANSFORM_CHANGED,this._scaleChanged,this),this.view.node.off(xn.SIZE_CHANGED,this._calculateBoundary,this))),this._hideScrollBar(),this.stopAutoScroll()},i._registerEvent=function(){this.node.on(xn.TOUCH_START,this._onTouchBegan,this,!0),this.node.on(xn.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.on(xn.TOUCH_END,this._onTouchEnded,this,!0),this.node.on(xn.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.on(xn.MOUSE_WHEEL,this._onMouseWheel,this,!0),this.node.on(hJ.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.on(hJ.XRUI_HOVER_EXITED,this._xrHoverExit,this),Vr.on(Ur.EventType.HANDLE_INPUT,this._dispatchEventHandleInput,this),Vr.on(Ur.EventType.GAMEPAD_INPUT,this._dispatchEventHandleInput,this)},i._unregisterEvent=function(){this.node.off(xn.TOUCH_START,this._onTouchBegan,this,!0),this.node.off(xn.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.off(xn.TOUCH_END,this._onTouchEnded,this,!0),this.node.off(xn.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.off(xn.MOUSE_WHEEL,this._onMouseWheel,this,!0),this.node.off(hJ.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.off(hJ.XRUI_HOVER_EXITED,this._xrHoverExit,this),Vr.off(Ur.EventType.HANDLE_INPUT,this._dispatchEventHandleInput,this),Vr.off(Ur.EventType.GAMEPAD_INPUT,this._dispatchEventHandleInput,this)},i._onMouseWheel=function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=new ji,n=t.getScrollY();this.vertical?i.set(0,-.1*n,0):this.horizontal&&i.set(-.1*n,0,0),this._mouseWheelEventElapsedTime=0,this._processDeltaMove(i),this._stopMouseWheel||(this._handlePressLogic(),this.schedule(this._checkMouseWheel,1/60,NaN,0),this._stopMouseWheel=!0),this._stopPropagationIfTargetIsMe(t)}},i._onTouchBegan=function(t,e){this.enabledInHierarchy&&this._content&&(this._hasNestedViewGroup(t,e)||(this._handlePressLogic(),this._touchMoved=!1,this._stopPropagationIfTargetIsMe(t)))},i._onTouchMoved=function(t,e){if(this.enabledInHierarchy&&this._content&&!this._hasNestedViewGroup(t,e)){var i=t.touch;if(this._handleMoveLogic(i),this.cancelInnerEvents){var n=i.getUILocation(L1);if(n.subtract(i.getUIStartLocation(N1)),n.length()>7&&!this._touchMoved&&t.target!==this.node){var r=new ka(t.getTouches(),t.bubbles,Ua.TOUCH_CANCEL);r.touch=t.touch,r.simulate=!0,t.target.dispatchEvent(r),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(t)}}},i._onTouchEnded=function(t,e){if(this.enabledInHierarchy&&this._content&&t&&!this._hasNestedViewGroup(t,e)){this._dispatchEvent(B1.TOUCH_UP);var i=t.touch;this._handleReleaseLogic(i),this._touchMoved?t.propagationStopped=!0:this._stopPropagationIfTargetIsMe(t)}},i._onTouchCancelled=function(t,e){if(this.enabledInHierarchy&&this._content&&!this._hasNestedViewGroup(t,e)){if(t&&!t.simulate){var i=t.touch;this._handleReleaseLogic(i)}this._stopPropagationIfTargetIsMe(t)}},i._calculateBoundary=function(){if(this._content&&this.view){var t=this._content.getComponent(N0);t&&t.enabledInHierarchy&&t.updateLayout();var e=this.view,i=e.width*e.anchorX,n=e.height*e.anchorY;this._leftBoundary=-i,this._bottomBoundary=-n,this._rightBoundary=this._leftBoundary+e.width,this._topBoundary=this._bottomBoundary+e.height,this._moveContentToTopLeft(e.contentSize)}},i._hasNestedViewGroup=function(t,e){if(!t||t.eventPhase!==Ba.CAPTURING_PHASE)return!1;if(e)for(var i,n=Fi(e);!(i=n()).done;){var r=i.value;if(this.node===r)return!(!t.target||!t.target.getComponent(I1));if(r.getComponent(I1))return!0}return!1},i._startInertiaScroll=function(t){var e=new ji(t);e.multiplyScalar(.7),this._startAttenuatingAutoScroll(e,t)},i._calculateAttenuatedFactor=function(t){return this.brake<=0?1-this.brake:(1-this.brake)*(1/(1+14e-6*t+t*t*8e-9))},i._startAttenuatingAutoScroll=function(t,e){var i=t.clone();if(i.normalize(),this._content&&this.view){var n=this._content._uiProps.uiTransformComp.contentSize,r=this.view.contentSize,s=n.width-r.width,a=n.height-r.height,o=this._calculateAttenuatedFactor(s),h=this._calculateAttenuatedFactor(a);i.x=i.x*s*(1-this.brake)*o,i.y=i.y*a*h*(1-this.brake),i.z=0}var l=t.length(),u=i.length()/l;if(i.add(t),this.brake>0&&u>7){u=Math.sqrt(u);var c=t.clone();c.multiplyScalar(u),i.set(c),i.add(t)}var d=this._calculateAutoScrollTimeByInitialSpeed(e.length());this.brake>0&&u>3&&(d*=u=3),0===this.brake&&u>1&&(d*=u),this._startAutoScroll(i,d,!0)},i._calculateAutoScrollTimeByInitialSpeed=function(t){return Math.sqrt(Math.sqrt(t/5))},i._startAutoScroll=function(t,e,i){void 0===i&&(i=!1);var n=this._flattenVectorByDirection(t);this._autoScrolling=!0,this._autoScrollTargetDelta=n,this._autoScrollAttenuate=i,ji.copy(this._autoScrollStartPosition,this._getContentPosition()),this._autoScrollTotalTime=e,this._autoScrollAccumulatedTime=0,this._autoScrollBraking=!1,this._isScrollEndedWithThresholdEventFired=!1,this._autoScrollBrakingStartPosition.set(0,0,0),this._getHowMuchOutOfBoundary().equals(ji.ZERO,D1)||(this._autoScrollCurrentlyOutOfBoundary=!0)},i._calculateTouchMoveVelocity=function(){var t=new ji,e=0;if((e=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),e))<=0||e>=.5)t.set(ji.ZERO);else{var i=new ji;i=this._touchMoveDisplacements.reduce((function(t,e){return t.add(e),t}),i),t.set(i.x*(1-this.brake)/e,i.y*(1-this.brake)/e,i.z)}return t},i._flattenVectorByDirection=function(t){var e=t;return e.x=this.horizontal?e.x:0,e.y=this.vertical?e.y:0,e},i._moveContent=function(t,e){var i=this._flattenVectorByDirection(t);O1.set(this._getContentPosition()),O1.add(i),O1.set(Math.round(1e4*O1.x)*D1,Math.round(1e4*O1.y)*D1,O1.z),this._setContentPosition(O1);var n=this._getHowMuchOutOfBoundary();L1.set(n.x,n.y),this._updateScrollBar(L1),this.elastic&&e&&this._startBounceBackIfNeeded()},i._getContentLeftBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.x-e.anchorX*e.width},i._getContentRightBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentLeftBoundary()+t.width},i._getContentTopBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentBottomBoundary()+t.height},i._getContentBottomBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.y-e.anchorY*e.height},i._getHowMuchOutOfBoundary=function(t){if((t=t||new ji).equals(ji.ZERO,D1)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=new ji,i=this._getContentLeftBoundary(),n=this._getContentRightBoundary();i+t.x>this._leftBoundary?e.x=this._leftBoundary-(i+t.x):n+t.x<this._rightBoundary&&(e.x=this._rightBoundary-(n+t.x));var r=this._getContentTopBoundary(),s=this._getContentBottomBoundary();return r+t.y<this._topBoundary?e.y=this._topBoundary-(r+t.y):s+t.y>this._bottomBoundary&&(e.y=this._bottomBoundary-(s+t.y)),t.equals(ji.ZERO,D1)&&(this._outOfBoundaryAmount=e,this._outOfBoundaryAmountDirty=!1),this._clampDelta(e),e},i._updateScrollBar=function(t){this._horizontalScrollBar&&this._horizontalScrollBar.onScroll(t),this.verticalScrollBar&&this.verticalScrollBar.onScroll(t)},i._onScrollBarTouchBegan=function(){this._horizontalScrollBar&&this._horizontalScrollBar.onTouchBegan(),this.verticalScrollBar&&this.verticalScrollBar.onTouchBegan()},i._onScrollBarTouchEnded=function(){this._horizontalScrollBar&&this._horizontalScrollBar.onTouchEnded(),this.verticalScrollBar&&this.verticalScrollBar.onTouchEnded()},i._dispatchEvent=function(t){if(t===B1.SCROLL_ENDED)this._scrollEventEmitMask=0;else if(t===B1.SCROLL_TO_TOP||t===B1.SCROLL_TO_BOTTOM||t===B1.SCROLL_TO_LEFT||t===B1.SCROLL_TO_RIGHT){var e=1<<U1[t];if(this._scrollEventEmitMask&e)return;this._scrollEventEmitMask|=e}Pa.emitEvents(this.scrollEvents,this,U1[t]),this.node.emit(t,this)},i._adjustContentOutOfBoundary=function(){if(this._content&&(this._outOfBoundaryAmountDirty=!0,this._isOutOfBoundary())){var t=this._getHowMuchOutOfBoundary();O1.set(this._getContentPosition()),O1.add(t),this._setContentPosition(O1),this._updateScrollBar(cn.ZERO)}},i._hideScrollBar=function(){this._horizontalScrollBar&&this._horizontalScrollBar.hide(),this._verticalScrollBar&&this._verticalScrollBar.hide()},i._updateScrollBarState=function(){if(this._content&&this.view){var t=this.view,e=this._content._uiProps.uiTransformComp;this.verticalScrollBar&&(e.height<t.height?this.verticalScrollBar.hide():this.verticalScrollBar.show()),this.horizontalScrollBar&&(e.width<t.width?this.horizontalScrollBar.hide():this.horizontalScrollBar.show())}},i._stopPropagationIfTargetIsMe=function(t){t.eventPhase===Ba.AT_TARGET&&t.target===this.node&&(t.propagationStopped=!0)},i._processDeltaMove=function(t){this._scrollChildren(t),this._gatherTouchMove(t)},i._handleMoveLogic=function(t){this._getLocalAxisAlignDelta(this._deltaPos,t),this._processDeltaMove(this._deltaPos)},i._handleReleaseLogic=function(t){this._getLocalAxisAlignDelta(this._deltaPos,t),this._gatherTouchMove(this._deltaPos),this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(B1.SCROLL_ENDED))},i._getLocalAxisAlignDelta=function(t,e){var i=this.node._uiProps.uiTransformComp,n=new ji;i&&(e.getUILocation(L1),e.getUIPreviousLocation(N1),O1.set(L1.x,L1.y,0),F1.set(N1.x,N1.y,0),i.convertToNodeSpaceAR(O1,O1),i.convertToNodeSpaceAR(F1,F1),ji.subtract(n,O1,F1)),t.set(n)},i._scrollChildren=function(t){this._clampDelta(t);var e,i=t;this.elastic&&(e=this._getHowMuchOutOfBoundary(),i.x*=0===e.x?1:.5,i.y*=0===e.y?1:.5),this.elastic||(e=this._getHowMuchOutOfBoundary(i),i.add(e));var n="",r="";if(this._content){var s=this._content._uiProps.uiTransformComp,a=s.anchorX,o=s.anchorY,h=s.width,l=s.height,u=this._content.position||ji.ZERO;this.vertical&&(i.y>0?u.y-o*l+i.y>=this._bottomBoundary&&(n=B1.SCROLL_TO_BOTTOM):i.y<0&&u.y-o*l+l+i.y<=this._topBoundary&&(n=B1.SCROLL_TO_TOP)),this.horizontal&&(i.x<0?u.x-a*h+h+i.x<=this._rightBoundary&&(r=B1.SCROLL_TO_RIGHT):i.x>0&&u.x-a*h+i.x>=this._leftBoundary&&(r=B1.SCROLL_TO_LEFT))}this._moveContent(i,!1),(this.horizontal&&0!==i.x||this.vertical&&0!==i.y)&&(this._scrolling||(this._scrolling=!0,this._dispatchEvent(B1.SCROLL_BEGAN)),this._dispatchEvent(B1.SCROLLING)),""!==n&&this._dispatchEvent(n),""!==r&&this._dispatchEvent(r)},i._handlePressLogic=function(){this._autoScrolling&&this._dispatchEvent(B1.SCROLL_ENDED),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=k1(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},i._clampDelta=function(t){if(this._content&&this.view){var e=this.view.contentSize,i=this._content._uiProps.uiTransformComp;i.width<e.width&&(t.x=0),i.height<e.height&&(t.y=0)}},i._gatherTouchMove=function(t){var e=t.clone();for(this._clampDelta(e);this._touchMoveDisplacements.length>=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(e);var i=k1();this._touchMoveTimeDeltas.push((i-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=i},i._startBounceBackIfNeeded=function(){if(!this.elastic)return!1;var t=this._getHowMuchOutOfBoundary();if(this._clampDelta(t),t.equals(ji.ZERO,D1))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent(B1.BOUNCE_TOP),t.y<0&&this._dispatchEvent(B1.BOUNCE_BOTTOM),t.x>0&&this._dispatchEvent(B1.BOUNCE_RIGHT),t.x<0&&this._dispatchEvent(B1.BOUNCE_LEFT),this._isBouncing=!0),!0},i._processInertiaScroll=function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!t.equals(O1,D1)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},i._isOutOfBoundary=function(){return!this._getHowMuchOutOfBoundary().equals(ji.ZERO,D1)},i._isNecessaryAutoScrollBrake=function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,ji.copy(this._autoScrollBrakingStartPosition,this._getContentPosition()),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},i._processAutoScrolling=function(t){var e=this._isNecessaryAutoScrollBrake(),i=e?.05:1;this._autoScrollAccumulatedTime+=t*(1/i);var n,r=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(n=r,r=(n-=1)*n*n*n*n+1);var s=this._autoScrollTargetDelta.clone();s.multiplyScalar(r);var a=this._autoScrollStartPosition.clone();a.add(s);var o=Math.abs(r-1)<=D1;if(Math.abs(r-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent(B1.SCROLL_ENG_WITH_THRESHOLD),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var h=a.clone();h.subtract(this._autoScrollBrakingStartPosition),e&&h.multiplyScalar(i),a.set(this._autoScrollBrakingStartPosition),a.add(h)}else{var l=a.clone();l.subtract(this.getContentPosition());var u=this._getHowMuchOutOfBoundary(l);u.equals(ji.ZERO,D1)||(a.add(u),o=!0)}o&&(this._autoScrolling=!1);var c=a.clone();c.subtract(this._getContentPosition()),this._clampDelta(c),this._moveContent(c,o),this._dispatchEvent(B1.SCROLLING),this._autoScrolling||(this._isBouncing=!1,this._scrolling=!1,this._dispatchEvent(B1.SCROLL_ENDED))},i._checkMouseWheel=function(t){if(!this._getHowMuchOutOfBoundary().equals(ji.ZERO,D1))return this._processInertiaScroll(),this.unschedule(this._checkMouseWheel),this._dispatchEvent(B1.SCROLL_ENDED),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this.unschedule(this._checkMouseWheel),this._dispatchEvent(B1.SCROLL_ENDED),this._stopMouseWheel=!1)},i._calculateMovePercentDelta=function(t){var e=t.anchor,i=t.applyToHorizontal,n=t.applyToVertical;this._calculateBoundary(),e.clampf(cn.ZERO,cn.ONE);var r=this._getContentBottomBoundary()-this._bottomBoundary;r=-r;var s=this._getContentLeftBoundary()-this._leftBoundary;s=-s;var a=new ji;if(this._content&&this.view){var o=0,h=this._content._uiProps.uiTransformComp.contentSize,l=this.view.contentSize;i&&(o=h.width-l.width,a.x=s-o*e.x),n&&(o=h.height-l.height,a.y=r-o*e.y)}return a},i._moveContentToTopLeft=function(t){var e=this._getContentBottomBoundary()-this._bottomBoundary;e=-e;var i=new ji,n=0,r=this._getContentLeftBoundary()-this._leftBoundary;if(r=-r,this._content){var s=this._content._uiProps.uiTransformComp.contentSize;s.height<t.height&&(n=s.height-t.height,i.y=e-n),s.width<t.width&&(n=s.width-t.width,i.x=r)}this._updateScrollBarState(),this._moveContent(i),this._adjustContentOutOfBoundary()},i._scaleChanged=function(t){t===pr.SCALE&&this._calculateBoundary()},i._xrHoverEnter=function(t){t.deviceType===oJ.Left?this._hoverIn=P1.LEFT:t.deviceType===oJ.Right&&(this._hoverIn=P1.RIGHT)},i._xrHoverExit=function(){this._hoverIn=P1.NONE},i._dispatchEventHandleInput=function(t){var e,i;t instanceof Ga?e=t.gamepad:t instanceof Va&&(e=t.handleInputDevice),this.enabledInHierarchy&&this._hoverIn!==P1.NONE&&(this._hoverIn===P1.LEFT?(i=e.leftStick.getValue()).equals(cn.ZERO)||this._xrThumbStickMove(i):this._hoverIn===P1.RIGHT&&((i=e.rightStick.getValue()).equals(cn.ZERO)||this._xrThumbStickMove(i)))},i._xrThumbStickMove=function(t){if(this.enabledInHierarchy){var e=new ji,i=t.y;this.vertical?e.set(0,-62.5*i,0):this.horizontal&&e.set(-62.5*i,0,0),this._mouseWheelEventElapsedTime=0,this._processDeltaMove(e),this._stopMouseWheel||(this._handlePressLogic(),this.schedule(this._checkMouseWheel,1/60,NaN,0),this._stopMouseWheel=!0)}},Pi(e,[{key:"content",get:function(){return this._content},set:function(t){if(this._content!==t){var e=t&&t.parent&&t.parent._uiProps.uiTransformComp;!t||t&&e?(this._content=t,this._calculateBoundary()):kr(4302)}}},{key:"horizontalScrollBar",get:function(){return this._horizontalScrollBar},set:function(t){this._horizontalScrollBar!==t&&(this._horizontalScrollBar=t,this._horizontalScrollBar&&(this._horizontalScrollBar.setScrollView(this),this._updateScrollBar(cn.ZERO)))}},{key:"verticalScrollBar",get:function(){return this._verticalScrollBar},set:function(t){this._verticalScrollBar!==t&&(this._verticalScrollBar=t,this._verticalScrollBar&&(this._verticalScrollBar.setScrollView(this),this._updateScrollBar(cn.ZERO)))}},{key:"view",get:function(){var t=this._content&&this._content.parent;return t?t._uiProps.uiTransformComp:null}}]),e}(I1),w1.EventType=B1,m1=tn((g1=M1).prototype,"bounceDuration",[en],(function(){return 1})),v1=tn(g1.prototype,"brake",[en],(function(){return.5})),y1=tn(g1.prototype,"elastic",[en],(function(){return!0})),T1=tn(g1.prototype,"inertia",[en],(function(){return!0})),gn(g1.prototype,"content",[c1],Object.getOwnPropertyDescriptor(g1.prototype,"content"),g1.prototype),S1=tn(g1.prototype,"horizontal",[en],(function(){return!0})),gn(g1.prototype,"horizontalScrollBar",[d1],Object.getOwnPropertyDescriptor(g1.prototype,"horizontalScrollBar"),g1.prototype),E1=tn(g1.prototype,"vertical",[en],(function(){return!0})),gn(g1.prototype,"verticalScrollBar",[_1],Object.getOwnPropertyDescriptor(g1.prototype,"verticalScrollBar"),g1.prototype),A1=tn(g1.prototype,"cancelInnerEvents",[en],(function(){return!0})),C1=tn(g1.prototype,"scrollEvents",[f1,en],(function(){return[]})),R1=tn(g1.prototype,"_content",[en],(function(){return null})),b1=tn(g1.prototype,"_horizontalScrollBar",[en],(function(){return null})),x1=tn(g1.prototype,"_verticalScrollBar",[en],(function(){return null})),p1=g1))||p1)||p1)||p1));We.ScrollView=t2;var e2,i2=new ji;!function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(e2||(e2={})),Fn(e2);var n2,r2,s2,a2,o2,h2,l2,u2,c2,d2,_2,f2,p2,g2=function(e){return t({Slider:e,SliderComponent:e}),e}((G1=Ki("cc.Slider"),V1=In(110),H1=kn(Bl),z1=Tn(Bd),X1=Tn(e2),W1=Tn([Pa]),G1(Y1=V1(Y1=H1(($1=J1=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).slideEvents=K1&&K1(),e._handle=q1&&q1(),e._direction=Z1&&Z1(),e._progress=Q1&&Q1(),e._offset=new ji,e._dragging=!1,e._touchHandle=!1,e._handleLocalPos=new ji,e._touchPos=new ji,e}He(e,t);var i=e.prototype;return i.__preload=function(){this._updateHandlePosition()},i.onEnable=function(){this._updateHandlePosition(),this.node.on(xn.TOUCH_START,this._onTouchBegan,this),this.node.on(xn.TOUCH_MOVE,this._onTouchMoved,this),this.node.on(xn.TOUCH_END,this._onTouchEnded,this),this.node.on(xn.TOUCH_CANCEL,this._onTouchCancelled,this),this.node.on(hJ.XRUI_HOVER_STAY,this._xrHoverStay,this),this.node.on(hJ.XRUI_CLICK,this._xrClick,this),this.node.on(hJ.XRUI_UNCLICK,this._xrUnClick,this),this._handle&&this._handle.isValid&&(this._handle.node.on(xn.TOUCH_START,this._onHandleDragStart,this),this._handle.node.on(xn.TOUCH_MOVE,this._onTouchMoved,this),this._handle.node.on(xn.TOUCH_END,this._onTouchEnded,this))},i.onDisable=function(){this.node.off(xn.TOUCH_START,this._onTouchBegan,this),this.node.off(xn.TOUCH_MOVE,this._onTouchMoved,this),this.node.off(xn.TOUCH_END,this._onTouchEnded,this),this.node.off(xn.TOUCH_CANCEL,this._onTouchCancelled,this),this.node.off(hJ.XRUI_HOVER_STAY,this._xrHoverStay,this),this.node.off(hJ.XRUI_CLICK,this._xrClick,this),this.node.off(hJ.XRUI_UNCLICK,this._xrUnClick,this),this._handle&&this._handle.isValid&&(this._handle.node.off(xn.TOUCH_START,this._onHandleDragStart,this),this._handle.node.off(xn.TOUCH_MOVE,this._onTouchMoved,this),this._handle.node.off(xn.TOUCH_END,this._onTouchEnded,this))},i._onHandleDragStart=function(t){if(t&&this._handle&&this._handle.node._uiProps.uiTransformComp){this._dragging=!0,this._touchHandle=!0;var e=t.touch.getUILocation();ji.set(this._touchPos,e.x,e.y,0),this._handle.node._uiProps.uiTransformComp.convertToNodeSpaceAR(this._touchPos,this._offset),t.propagationStopped=!0}},i._onTouchBegan=function(t){this._handle&&t&&(this._dragging=!0,this._touchHandle||this._handleSliderLogic(t.touch),t.propagationStopped=!0)},i._onTouchMoved=function(t){this._dragging&&t&&(this._handleSliderLogic(t.touch),t.propagationStopped=!0)},i._onTouchEnded=function(t){this._dragging=!1,this._touchHandle=!1,this._offset=new ji,t&&(t.propagationStopped=!0)},i._onTouchCancelled=function(t){this._dragging=!1,t&&(t.propagationStopped=!0)},i._handleSliderLogic=function(t){this._updateProgress(t),this._emitSlideEvent()},i._emitSlideEvent=function(){Pa.emitEvents(this.slideEvents,this),this.node.emit("slide",this)},i._updateProgress=function(t){if(this._handle&&t){var e=t.getUILocation();ji.set(this._touchPos,e.x,e.y,0);var i=this.node._uiProps.uiTransformComp,n=i.convertToNodeSpaceAR(this._touchPos,i2);this.direction===e2.Horizontal?this.progress=Bs(.5+(n.x-this._offset.x)/i.width):this.progress=Bs(.5+(n.y-this._offset.y)/i.height)}},i._updateHandlePosition=function(){if(this._handle){this._handleLocalPos.set(this._handle.node.getPosition());var t=this.node._uiProps.uiTransformComp;this._direction===e2.Horizontal?this._handleLocalPos.x=-t.width*t.anchorX+this.progress*t.width:this._handleLocalPos.y=-t.height*t.anchorY+this.progress*t.height,this._handle.node.setPosition(this._handleLocalPos)}},i._changeLayout=function(){var t=this.node._uiProps.uiTransformComp,e=t.contentSize;if(t.setContentSize(e.height,e.width),this._handle){var i=this._handle.node.position;this._direction===e2.Horizontal?this._handle.node.setPosition(i.x,0,i.z):this._handle.node.setPosition(0,i.y,i.z),this._updateHandlePosition()}},i._xrHandleProgress=function(t){if(!this._touchHandle){var e=this.node._uiProps.uiTransformComp;e.convertToNodeSpaceAR(t,i2),this.direction===e2.Horizontal?this.progress=Bs(.5+(i2.x-this.node.position.x)/e.width):this.progress=Bs(.5+(i2.y-this.node.position.y)/e.height)}},i._xrClick=function(t){this._handle&&(this._dragging=!0,this._xrHandleProgress(t.hitPoint),this._emitSlideEvent())},i._xrUnClick=function(){this._dragging=!1,this._touchHandle=!1},i._xrHoverStay=function(t){this._dragging&&(this._xrHandleProgress(t.hitPoint),this._emitSlideEvent())},Pi(e,[{key:"handle",get:function(){return this._handle},set:function(t){this._handle!==t&&(this._handle=t)}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this._changeLayout())}},{key:"progress",get:function(){return this._progress},set:function(t){this._progress!==t&&(this._progress=t,this._updateHandlePosition())}}]),e}(Pn),J1.Direction=e2,gn((j1=$1).prototype,"handle",[z1],Object.getOwnPropertyDescriptor(j1.prototype,"handle"),j1.prototype),gn(j1.prototype,"direction",[X1],Object.getOwnPropertyDescriptor(j1.prototype,"direction"),j1.prototype),K1=tn(j1.prototype,"slideEvents",[W1,en],(function(){return[]})),q1=tn(j1.prototype,"_handle",[en],(function(){return null})),Z1=tn(j1.prototype,"_direction",[en],(function(){return e2.Horizontal})),Q1=tn(j1.prototype,"_progress",[en],(function(){return.1})),Y1=j1))||Y1)||Y1)||Y1));function m2(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return Object.assign.apply(Object,[{}].concat(e))}We.Slider=g2,function(t){t.TOGGLE="toggle"}(p2||(p2={}));var v2,y2,T2,S2,E2,A2,C2,R2=function(e){return t({Toggle:e,ToggleComponent:e}),e}((n2=Ki("cc.Toggle"),r2=In(110),s2=kn(Bl),a2=Tn(Bd),o2=Tn([Pa]),n2(h2=r2(h2=s2((f2=_2=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).checkEvents=u2&&u2(),e._isChecked=c2&&c2(),e._checkMark=d2&&d2(),e}He(e,t);var i=e.prototype;return i._internalToggle=function(){this.isChecked=!this.isChecked},i._set=function(t,e){if(void 0===e&&(e=!0),this._isChecked!=t){this._isChecked=t;var i=this._toggleContainer;i&&i.enabled&&this.enabled&&(t||!i.anyTogglesChecked()&&!i.allowSwitchOff)&&(this._isChecked=!0,i.notifyToggleCheck(this,e)),this.playEffect(),e&&this._emitToggleEvents()}},i.playEffect=function(){this._checkMark&&(this._checkMark.node.active=this._isChecked)},i.setIsCheckedWithoutNotify=function(t){this._set(t,!1)},i.onEnable=function(){t.prototype.onEnable.call(this),this.playEffect(),this.node.on(e.EventType.CLICK,this._internalToggle,this)},i.onDisable=function(){t.prototype.onDisable.call(this),this.node.off(e.EventType.CLICK,this._internalToggle,this)},i._emitToggleEvents=function(){this.node.emit(e.EventType.TOGGLE,this),this.checkEvents&&Pa.emitEvents(this.checkEvents,this)},Pi(e,[{key:"isChecked",get:function(){return this._isChecked},set:function(t){this._set(t)}},{key:"checkMark",get:function(){return this._checkMark},set:function(t){this._checkMark!==t&&(this._checkMark=t)}},{key:"_resizeToTarget",set:function(t){t&&this._resizeNodeToTargetNode()}},{key:"_toggleContainer",get:function(){var t=this.node.parent;return We.Node.isNode(t)?t.getComponent("cc.ToggleContainer"):null}}]),e}(qJ),_2.EventType=m2(p2,jJ),gn((l2=f2).prototype,"checkMark",[a2],Object.getOwnPropertyDescriptor(l2.prototype,"checkMark"),l2.prototype),u2=tn(l2.prototype,"checkEvents",[o2,en],(function(){return[]})),c2=tn(l2.prototype,"_isChecked",[en],(function(){return!0})),d2=tn(l2.prototype,"_checkMark",[en],(function(){return null})),h2=l2))||h2)||h2)||h2));We.Toggle=R2;var b2,x2,w2,M2,I2,B2,P2,D2,O2,F2,L2,N2,k2,U2,G2,V2,H2,z2,X2,W2,Y2,j2,K2,q2,Z2,Q2,J2,$2=function(e){return t({ToggleContainer:e,ToggleContainerComponent:e}),e}((v2=Ki("cc.ToggleContainer"),y2=In(110),T2=Tn([Pa]),v2(S2=y2((E2=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._allowSwitchOff=A2&&A2(),e.checkEvents=C2&&C2(),e}He(e,t);var i=e.prototype;return i.onEnable=function(){this.ensureValidState(),this.node.on(xn.CHILD_ADDED,this.ensureValidState,this),this.node.on(xn.CHILD_REMOVED,this.ensureValidState,this)},i.onDisable=function(){this.node.off(xn.CHILD_ADDED,this.ensureValidState,this),this.node.off(xn.CHILD_REMOVED,this.ensureValidState,this)},i.activeToggles=function(){return this.toggleItems.filter((function(t){return t.isChecked}))},i.anyTogglesChecked=function(){return!!this.toggleItems.find((function(t){return t.isChecked}))},i.notifyToggleCheck=function(t,e){if(void 0===e&&(e=!0),this.enabledInHierarchy){for(var i=0;i<this.toggleItems.length;i++){var n=this.toggleItems[i];n!==t&&(e?n.isChecked=!1:n.setIsCheckedWithoutNotify(!1))}this.checkEvents&&We.Component.EventHandler.emitEvents(this.checkEvents,t)}},i.ensureValidState=function(){var t=this.toggleItems;if(!this._allowSwitchOff&&!this.anyTogglesChecked()&&0!==t.length){var e=t[0];e.isChecked=!0,this.notifyToggleCheck(e)}var i=this.activeToggles();if(i.length>1)for(var n=i[0],r=0;r<i.length;++r){var s=i[r];s!==n&&(s.isChecked=!1)}},Pi(e,[{key:"allowSwitchOff",get:function(){return this._allowSwitchOff},set:function(t){this._allowSwitchOff=t}},{key:"toggleItems",get:function(){return this.node.children.map((function(t){var e=t.getComponent("cc.Toggle");return e&&e.enabled?e:null})).filter(Boolean)}}]),e}(Pn),A2=tn(E2.prototype,"_allowSwitchOff",[en],(function(){return!1})),C2=tn(E2.prototype,"checkEvents",[T2,en],(function(){return[]})),S2=E2))||S2)||S2));We.ToggleContainer=$2;var t3,e3,i3=new cn;function n3(t){return t instanceof za?Bn:t._uiProps.uiTransformComp?t._uiProps.uiTransformComp.contentSize:dn.ZERO}function r3(t,e,i,n){t.parent?i3.set(t.parent.getScale().x,t.parent.getScale().y):i3.set(0,0);for(var r=i3.x,s=i3.y,a=0,o=0,h=t.parent;;){if(!h)return i.x=i.y=0,void(n.x=n.y=1);var l=h.getPosition();if(a+=l.x,o+=l.y,(h=h.parent)===e)break;h?i3.set(h.getScale().x,h.getScale().y):i3.set(0,0);var u=i3.x,c=i3.y;a*=u,o*=c,r*=u,s*=c}n.x=0!==r?1/r:1,n.y=0!==s?1/s:1,i.x=-a,i.y=-o}!function(t){t[t.ONCE=0]="ONCE",t[t.ALWAYS=1]="ALWAYS",t[t.ON_WINDOW_RESIZE=2]="ON_WINDOW_RESIZE"}(t3||(t3={})),Fn(t3),function(t){t[t.TOP=1]="TOP",t[t.MID=2]="MID",t[t.BOT=4]="BOT",t[t.LEFT=8]="LEFT",t[t.CENTER=16]="CENTER",t[t.RIGHT=32]="RIGHT",t[t.HORIZONTAL=56]="HORIZONTAL",t[t.VERTICAL=7]="VERTICAL"}(e3||(e3={}));var s3,a3,o3,h3,l3,u3,c3,d3,_3,f3,p3,g3,m3,v3=e3.TOP|e3.BOT,y3=e3.LEFT|e3.RIGHT,T3=function(e){return t({Widget:e,WidgetComponent:e}),e}((b2=Ki("cc.Widget"),x2=In(110),w2=kn(Bl),M2=Tn(Pr),I2=Tn(t3),b2(B2=x2(B2=w2((J2=Q2=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._lastPos=new ji,e._lastSize=new dn,e._dirty=!0,e._hadAlignOnce=!1,e._alignFlags=D2&&D2(),e._target=O2&&O2(),e._left=F2&&F2(),e._right=L2&&L2(),e._top=N2&&N2(),e._bottom=k2&&k2(),e._horizontalCenter=U2&&U2(),e._verticalCenter=G2&&G2(),e._isAbsLeft=V2&&V2(),e._isAbsRight=H2&&H2(),e._isAbsTop=z2&&z2(),e._isAbsBottom=X2&&X2(),e._isAbsHorizontalCenter=W2&&W2(),e._isAbsVerticalCenter=Y2&&Y2(),e._originalWidth=j2&&j2(),e._originalHeight=K2&&K2(),e._alignMode=q2&&q2(),e._lockFlags=Z2&&Z2(),e}He(e,t);var i=e.prototype;return i.updateAlignment=function(){We._widgetManager.updateAlignment(this.node)},i._validateTargetInDEV=function(){},i.setDirty=function(){this._recursiveDirty()},i.onEnable=function(){this.node.getPosition(this._lastPos),this._lastSize.set(this.node._uiProps.uiTransformComp.contentSize),We._widgetManager.add(this),this._hadAlignOnce=!1,this._registerEvent(),this._registerTargetEvents()},i.onDisable=function(){We._widgetManager.remove(this),this._unregisterEvent(),this._unregisterTargetEvents()},i.onDestroy=function(){this._removeParentEvent()},i._adjustWidgetToAllowMovingInEditor=function(){},i._adjustWidgetToAllowResizingInEditor=function(){},i._adjustWidgetToAnchorChanged=function(){this.setDirty()},i._adjustTargetToParentChanged=function(t){t&&this._unregisterOldParentEvents(t),this.node.getParent()&&this._registerTargetEvents(),this._setDirtyByMode()},i._registerEvent=function(){this.node.on(xn.TRANSFORM_CHANGED,this._setDirtyByMode,this),this.node.on(xn.SIZE_CHANGED,this._setDirtyByMode,this),this.node.on(xn.ANCHOR_CHANGED,this._adjustWidgetToAnchorChanged,this),this.node.on(xn.PARENT_CHANGED,this._adjustTargetToParentChanged,this)},i._unregisterEvent=function(){this.node.off(xn.TRANSFORM_CHANGED,this._setDirtyByMode,this),this.node.off(xn.SIZE_CHANGED,this._setDirtyByMode,this),this.node.off(xn.ANCHOR_CHANGED,this._adjustWidgetToAnchorChanged,this)},i._removeParentEvent=function(){this.node.off(xn.PARENT_CHANGED,this._adjustTargetToParentChanged,this)},i._autoChangedValue=function(t,e){if((this._alignFlags&t)>0){var i=this.node.parent&&this.node.parent._uiProps,n=i&&i.uiTransformComp,r=n?n.contentSize:Bn;this.isAlignLeft&&t===e3.LEFT?this._left=e?this._left*r.width:this._left/r.width:this.isAlignRight&&t===e3.RIGHT?this._right=e?this._right*r.width:this._right/r.width:this.isAlignHorizontalCenter&&t===e3.CENTER?this._horizontalCenter=e?this._horizontalCenter*r.width:this._horizontalCenter/r.width:this.isAlignTop&&t===e3.TOP?this._top=e?this._top*r.height:this._top/r.height:this.isAlignBottom&&t===e3.BOT?this._bottom=e?this._bottom*r.height:this._bottom/r.height:this.isAbsoluteVerticalCenter&&t===e3.MID&&(this._verticalCenter=this._verticalCenter/r.height),this._recursiveDirty()}},i._registerTargetEvents=function(){var t=this._target||this.node.parent;t&&t.getComponent(Bl)&&(t.on(xn.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.on(xn.SIZE_CHANGED,this._setDirtyByMode,this),t.on(xn.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterTargetEvents=function(){var t=this._target||this.node.parent;t&&(t.off(xn.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.off(xn.SIZE_CHANGED,this._setDirtyByMode,this),t.off(xn.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterOldParentEvents=function(t){var e=this._target||t;e&&(e.off(xn.TRANSFORM_CHANGED,this._setDirtyByMode,this),e.off(xn.SIZE_CHANGED,this._setDirtyByMode,this))},i._setDirtyByMode=function(){(this.alignMode===t3.ALWAYS||aa)&&this._recursiveDirty()},i._setAlign=function(t,e){if(e!==(this._alignFlags&t)>0){var i=(t&y3)>0,n=this.node._uiProps.uiTransformComp;e?(this._alignFlags|=t,i?(this.isAlignHorizontalCenter=!1,this.isStretchWidth&&(this._originalWidth=n.width)):(this.isAlignVerticalCenter=!1,this.isStretchHeight&&(this._originalHeight=n.height))):(i?this.isStretchWidth&&(n.width=this._originalWidth):this.isStretchHeight&&(n.height=this._originalHeight),this._alignFlags&=~t)}},i._recursiveDirty=function(){this._dirty||(this._dirty=!0)},Pi(e,[{key:"target",get:function(){return this._target},set:function(t){this._target!==t&&(this._unregisterTargetEvents(),this._target=t,this._registerTargetEvents(),this._validateTargetInDEV(),this._recursiveDirty())}},{key:"isAlignTop",get:function(){return(this._alignFlags&e3.TOP)>0},set:function(t){this._setAlign(e3.TOP,t),this._recursiveDirty()}},{key:"isAlignBottom",get:function(){return(this._alignFlags&e3.BOT)>0},set:function(t){this._setAlign(e3.BOT,t),this._recursiveDirty()}},{key:"isAlignLeft",get:function(){return(this._alignFlags&e3.LEFT)>0},set:function(t){this._setAlign(e3.LEFT,t),this._recursiveDirty()}},{key:"isAlignRight",get:function(){return(this._alignFlags&e3.RIGHT)>0},set:function(t){this._setAlign(e3.RIGHT,t),this._recursiveDirty()}},{key:"isAlignVerticalCenter",get:function(){return(this._alignFlags&e3.MID)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=e3.MID):this._alignFlags&=~e3.MID,this._recursiveDirty()}},{key:"isAlignHorizontalCenter",get:function(){return(this._alignFlags&e3.CENTER)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=e3.CENTER):this._alignFlags&=~e3.CENTER,this._recursiveDirty()}},{key:"isStretchWidth",get:function(){return(this._alignFlags&y3)===y3}},{key:"isStretchHeight",get:function(){return(this._alignFlags&v3)===v3}},{key:"top",get:function(){return this._top},set:function(t){this._top=t,this._recursiveDirty()}},{key:"editorTop",get:function(){return this._isAbsTop?this._top:100*this._top},set:function(t){this._top=this._isAbsTop?t:t/100,this._recursiveDirty()}},{key:"bottom",get:function(){return this._bottom},set:function(t){this._bottom=t,this._recursiveDirty()}},{key:"editorBottom",get:function(){return this._isAbsBottom?this._bottom:100*this._bottom},set:function(t){this._bottom=this._isAbsBottom?t:t/100,this._recursiveDirty()}},{key:"left",get:function(){return this._left},set:function(t){this._left=t,this._recursiveDirty()}},{key:"editorLeft",get:function(){return this._isAbsLeft?this._left:100*this._left},set:function(t){this._left=this._isAbsLeft?t:t/100,this._recursiveDirty()}},{key:"right",get:function(){return this._right},set:function(t){this._right=t,this._recursiveDirty()}},{key:"editorRight",get:function(){return this._isAbsRight?this._right:100*this._right},set:function(t){this._right=this._isAbsRight?t:t/100,this._recursiveDirty()}},{key:"horizontalCenter",get:function(){return this._horizontalCenter},set:function(t){this._horizontalCenter=t,this._recursiveDirty()}},{key:"editorHorizontalCenter",get:function(){return this._isAbsHorizontalCenter?this._horizontalCenter:100*this._horizontalCenter},set:function(t){this._horizontalCenter=this._isAbsHorizontalCenter?t:t/100,this._recursiveDirty()}},{key:"verticalCenter",get:function(){return this._verticalCenter},set:function(t){this._verticalCenter=t,this._recursiveDirty()}},{key:"editorVerticalCenter",get:function(){return this._isAbsVerticalCenter?this._verticalCenter:100*this._verticalCenter},set:function(t){this._verticalCenter=this._isAbsVerticalCenter?t:t/100,this._recursiveDirty()}},{key:"isAbsoluteTop",get:function(){return this._isAbsTop},set:function(t){this._isAbsTop!==t&&(this._isAbsTop=t,this._autoChangedValue(e3.TOP,this._isAbsTop))}},{key:"isAbsoluteBottom",get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom!==t&&(this._isAbsBottom=t,this._autoChangedValue(e3.BOT,this._isAbsBottom))}},{key:"isAbsoluteLeft",get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft!==t&&(this._isAbsLeft=t,this._autoChangedValue(e3.LEFT,this._isAbsLeft))}},{key:"isAbsoluteRight",get:function(){return this._isAbsRight},set:function(t){this._isAbsRight!==t&&(this._isAbsRight=t,this._autoChangedValue(e3.RIGHT,this._isAbsRight))}},{key:"isAbsoluteHorizontalCenter",get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter!==t&&(this._isAbsHorizontalCenter=t,this._autoChangedValue(e3.CENTER,this._isAbsHorizontalCenter))}},{key:"isAbsoluteVerticalCenter",get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter!==t&&(this._isAbsVerticalCenter=t,this._autoChangedValue(e3.MID,this._isAbsVerticalCenter))}},{key:"alignMode",get:function(){return this._alignMode},set:function(t){this._alignMode=t,this._recursiveDirty()}},{key:"alignFlags",get:function(){return this._alignFlags},set:function(t){this._alignFlags!==t&&(this._alignFlags=t,this._recursiveDirty())}}]),e}(Pn),Q2.AlignMode=t3,gn((P2=J2).prototype,"target",[M2],Object.getOwnPropertyDescriptor(P2.prototype,"target"),P2.prototype),gn(P2.prototype,"alignMode",[I2],Object.getOwnPropertyDescriptor(P2.prototype,"alignMode"),P2.prototype),D2=tn(P2.prototype,"_alignFlags",[en],(function(){return 0})),O2=tn(P2.prototype,"_target",[en],(function(){return null})),F2=tn(P2.prototype,"_left",[en],(function(){return 0})),L2=tn(P2.prototype,"_right",[en],(function(){return 0})),N2=tn(P2.prototype,"_top",[en],(function(){return 0})),k2=tn(P2.prototype,"_bottom",[en],(function(){return 0})),U2=tn(P2.prototype,"_horizontalCenter",[en],(function(){return 0})),G2=tn(P2.prototype,"_verticalCenter",[en],(function(){return 0})),V2=tn(P2.prototype,"_isAbsLeft",[en],(function(){return!0})),H2=tn(P2.prototype,"_isAbsRight",[en],(function(){return!0})),z2=tn(P2.prototype,"_isAbsTop",[en],(function(){return!0})),X2=tn(P2.prototype,"_isAbsBottom",[en],(function(){return!0})),W2=tn(P2.prototype,"_isAbsHorizontalCenter",[en],(function(){return!0})),Y2=tn(P2.prototype,"_isAbsVerticalCenter",[en],(function(){return!0})),j2=tn(P2.prototype,"_originalWidth",[en],(function(){return 0})),K2=tn(P2.prototype,"_originalHeight",[en],(function(){return 0})),q2=tn(P2.prototype,"_alignMode",[en],(function(){return t3.ON_WINDOW_RESIZE})),Z2=tn(P2.prototype,"_lockFlags",[en,Ha],(function(){return 0})),B2=P2))||B2)||B2)||B2));We.internal.computeInverseTransForTarget=r3,We.internal.getReadonlyNodeSize=n3,We.Widget=T3;var S3,E3=new Ve;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(S3||(S3={})),Fn(S3);var A3,C3,R3,b3,x3,w3,M3,I3,B3,P3,D3,O3,F3,L3,N3,k3,U3,G3,V3,H3,z3,X3,W3,Y3,j3,K3=function(e){return t({PageViewIndicator:e,PageViewIndicatorComponent:e}),e}((s3=Ki("cc.PageViewIndicator"),a3=In(110),o3=Tn(Uo),h3=Tn(S3),l3=Tn(dn),s3(u3=a3((m3=g3=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).spacing=d3&&d3(),e._spriteFrame=_3&&_3(),e._direction=f3&&f3(),e._cellSize=p3&&p3(),e._layout=null,e._pageView=null,e._indicators=[],e}He(e,t);var i=e.prototype;return i.onLoad=function(){this._updateLayout()},i.setPageView=function(t){this._pageView=t,this._refresh()},i._updateLayout=function(){this._layout=this.getComponent(N0),this._layout||(this._layout=this.addComponent(N0));var t=this._layout;this.direction===S3.HORIZONTAL?(t.type=N0.Type.HORIZONTAL,t.spacingX=this.spacing):this.direction===S3.VERTICAL&&(t.type=N0.Type.VERTICAL,t.spacingY=this.spacing),t.resizeMode=N0.ResizeMode.CONTAINER},i._createIndicator=function(){var t=new Pr;t.layer=this.node.layer;var e=t.addComponent(Bd);return e.spriteFrame=this.spriteFrame,e.sizeMode=Bd.SizeMode.CUSTOM,t.parent=this.node,t._uiProps.uiTransformComp.setContentSize(this._cellSize),t},i._changedState=function(){var t=this._indicators;if(0!==t.length&&this._pageView){var e=this._pageView.curPageIdx;if(!(e>=t.length)){for(var i=0;i<t.length;++i){var n=t[i];if(n._uiProps.uiComp){var r=n._uiProps.uiComp;E3.set(r.color),E3.a=127.5,r.color=E3}}if(t[e]._uiProps.uiComp){var s=t[e]._uiProps.uiComp;E3.set(s.color),E3.a=255,s.color=E3}}}},i._refresh=function(){if(this._pageView){var t=this._indicators,e=this._pageView.getPages();if(e.length!==t.length){var i=0;if(e.length>t.length)for(i=0;i<e.length;++i)t[i]||(t[i]=this._createIndicator());else for(i=t.length-e.length;i>0;--i){var n=t[i-1];this.node.removeChild(n),t.splice(i-1,1)}this._layout&&this._layout.enabledInHierarchy&&this._layout.updateLayout(),this._changedState()}}},Pi(e,[{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._spriteFrame!==t&&(this._spriteFrame=t)}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t)}},{key:"cellSize",get:function(){return this._cellSize},set:function(t){this._cellSize!==t&&(this._cellSize=t)}}]),e}(Pn),g3.Direction=S3,gn((c3=m3).prototype,"spriteFrame",[o3],Object.getOwnPropertyDescriptor(c3.prototype,"spriteFrame"),c3.prototype),gn(c3.prototype,"direction",[h3],Object.getOwnPropertyDescriptor(c3.prototype,"direction"),c3.prototype),gn(c3.prototype,"cellSize",[l3],Object.getOwnPropertyDescriptor(c3.prototype,"cellSize"),c3.prototype),d3=tn(c3.prototype,"spacing",[en],(function(){return 0})),_3=tn(c3.prototype,"_spriteFrame",[en],(function(){return null})),f3=tn(c3.prototype,"_direction",[en],(function(){return S3.HORIZONTAL})),p3=tn(c3.prototype,"_cellSize",[en],(function(){return new dn(20,20)})),u3=c3))||u3)||u3));We.PageViewIndicator=K3;var q3,Z3,Q3,J3=new cn;!function(t){t[t.Unified=0]="Unified",t[t.Free=1]="Free"}(q3||(q3={})),Fn(q3),function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(Z3||(Z3={})),Fn(Z3),function(t){t.PAGE_TURNING="page-turning"}(Q3||(Q3={}));var $3=function(e){return t({PageView:e,PageViewComponent:e}),e}((A3=Ki("cc.PageView"),C3=In(110),R3=Tn(q3),b3=Tn(Z3),x3=Tn(K3),w3=Tn(o1),M3=Tn(o1),I3=Tn([Pa]),B3=Tn([Pa]),A3(P3=C3((j3=Y3=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).autoPageTurningThreshold=O3&&O3(),e.horizontal=F3&&F3(),e.vertical=L3&&L3(),e.cancelInnerEvents=N3&&N3(),e.scrollEvents=k3&&k3(),e.pageTurningSpeed=U3&&U3(),e.pageEvents=G3&&G3(),e._sizeMode=V3&&V3(),e._direction=H3&&H3(),e._scrollThreshold=z3&&z3(),e._pageTurningEventTiming=X3&&X3(),e._indicator=W3&&W3(),e._curPageIdx=0,e._lastPageIdx=0,e._pages=[],e._initContentPos=new ji,e._scrollCenterOffsetX=[],e._scrollCenterOffsetY=[],e._touchBeganPosition=new cn,e._touchEndPosition=new cn,e}He(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(xn.SIZE_CHANGED,this._updateAllPagesSize,this),this.node.on(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},i.onDisable=function(){t.prototype.onDisable.call(this),this.node.off(xn.SIZE_CHANGED,this._updateAllPagesSize,this),this.node.off(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},i.onLoad=function(){this._initPages(),this.indicator&&this.indicator.setPageView(this)},i.getCurrentPageIndex=function(){return this._curPageIdx},i.setCurrentPageIndex=function(t){this.scrollToPage(t,1)},i.getPages=function(){return this._pages},i.addPage=function(t){t&&-1===this._pages.indexOf(t)&&this.content&&(t._uiProps.uiTransformComp?(this.content.addChild(t),this._pages.push(t),this._updatePageView()):kr(4301))},i.insertPage=function(t,e){if(!(e<0)&&t&&-1===this._pages.indexOf(t)&&this.content)if(e>=this._pages.length)this.addPage(t);else{if(!t._uiProps.uiTransformComp)return void kr(4301);this._pages.splice(e,0,t),this.content.insertChild(t,e),this._updatePageView()}},i.removePage=function(t){if(t&&this.content){var e=this._pages.indexOf(t);-1!==e?this.removePageAtIndex(e):Zi(4300,t.name)}},i.removePageAtIndex=function(t){var e=this._pages;if(!(t<0||t>=e.length)){var i=e[t];i&&this.content&&(this.content.removeChild(i),e.splice(t,1),this._updatePageView())}},i.removeAllPages=function(){if(this.content){for(var t=this._pages,e=0,i=t.length;e<i;e++)this.content.removeChild(t[e]);this._pages.length=0,this._updatePageView()}},i.scrollToPage=function(t,e){void 0===e&&(e=.3),t<0||t>=this._pages.length||(this._curPageIdx=t,this.scrollToOffset(this._moveOffsetValue(t),e,!0),this.indicator&&this.indicator._changedState())},i.getScrollEndedEventTiming=function(){return this.pageTurningEventTiming},i._updatePageView=function(){if(this.content){var t=this.content.getComponent(N0);t&&t.enabled&&t.updateLayout();var e=this._pages.length;this._curPageIdx>=e&&(this._curPageIdx=0===e?0:e-1,this._lastPageIdx=this._curPageIdx);for(var i=this._initContentPos,n=0;n<e;++n){var r=this._pages[n].position;this.direction===Z3.Horizontal?this._scrollCenterOffsetX[n]=Math.abs(i.x+r.x):this._scrollCenterOffsetY[n]=Math.abs(i.y+r.y)}this.indicator&&this.indicator._refresh()}},i._updateAllPagesSize=function(){var t=this.view;if(this.content&&t&&this._sizeMode===q3.Unified)for(var e=this._pages,i=t.contentSize,n=0,r=e.length;n<r;n++)e[n]._uiProps.uiTransformComp.setContentSize(i)},i._handleReleaseLogic=function(){this._autoScrollToPage(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(e.EventType.SCROLL_ENDED))},i._onTouchBegan=function(e,i){e.touch.getUILocation(J3),cn.set(this._touchBeganPosition,J3.x,J3.y),t.prototype._onTouchBegan.call(this,e,i)},i._onTouchMoved=function(e,i){t.prototype._onTouchMoved.call(this,e,i)},i._onTouchEnded=function(e,i){e.touch.getUILocation(J3),cn.set(this._touchEndPosition,J3.x,J3.y),t.prototype._onTouchEnded.call(this,e,i)},i._onTouchCancelled=function(e,i){e.touch.getUILocation(J3),cn.set(this._touchEndPosition,J3.x,J3.y),t.prototype._onTouchCancelled.call(this,e,i)},i._onMouseWheel=function(){},i._syncScrollDirection=function(){this.horizontal=this.direction===Z3.Horizontal,this.vertical=this.direction===Z3.Vertical},i._syncSizeMode=function(){var t=this.view;if(this.content&&t){var e=this.content.getComponent(N0);if(e){if(this._sizeMode===q3.Free&&this._pages.length>0){var i=this._pages[0]._uiProps.uiTransformComp,n=this._pages[this._pages.length-1]._uiProps.uiTransformComp;this.direction===Z3.Horizontal?(e.paddingLeft=(t.width-i.width)/2,e.paddingRight=(t.width-n.width)/2):this.direction===Z3.Vertical&&(e.paddingTop=(t.height-i.height)/2,e.paddingBottom=(t.height-n.height)/2)}e.updateLayout()}}},i._initPages=function(){if(this.content){this._initContentPos=this.content.position;for(var t=this.content.children,e=0;e<t.length;++e){var i=t[e];this._pages.indexOf(i)>=0||this._pages.push(i)}this._syncScrollDirection(),this._syncSizeMode(),this._updatePageView()}},i._dispatchPageTurningEvent=function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,Pa.emitEvents(this.pageEvents,this,Q3.PAGE_TURNING),this.node.emit(Q3.PAGE_TURNING,this))},i._isQuicklyScrollable=function(t){if(this.direction===Z3.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===Z3.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},i._moveOffsetValue=function(t){var e=new cn;if(this._sizeMode===q3.Free)this.direction===Z3.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===Z3.Vertical&&(e.y=this._scrollCenterOffsetY[t]);else{var i=this.view;if(!i)return e;this.direction===Z3.Horizontal?e.x=t*i.width:this.direction===Z3.Vertical&&(e.y=t*i.height)}return e},i._getDragDirection=function(t){return this._direction===Z3.Horizontal?0===t.x?0:t.x>0?1:-1:0===t.y?0:t.y<0?1:-1},i._isScrollable=function(t,e,i){if(this._sizeMode===q3.Free){var n=0,r=0;if(this.direction===Z3.Horizontal)return n=this._scrollCenterOffsetX[e],r=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(n-r)*this.scrollThreshold;if(this.direction===Z3.Vertical)return n=this._scrollCenterOffsetY[e],r=this._scrollCenterOffsetY[i],Math.abs(t.y)>=Math.abs(n-r)*this.scrollThreshold}else{var s=this.view;if(!s)return!1;if(this.direction===Z3.Horizontal)return Math.abs(t.x)>=s.width*this.scrollThreshold;if(this.direction===Z3.Vertical)return Math.abs(t.y)>=s.height*this.scrollThreshold}return!1},i._autoScrollToPage=function(){if(this._startBounceBackIfNeeded()){var t=this._getHowMuchOutOfBoundary();this._clampDelta(t),(t.x>0||t.y<0)&&(this._curPageIdx=0===this._pages.length?0:this._pages.length-1),(t.x<0||t.y>0)&&(this._curPageIdx=0),this.indicator&&this.indicator._changedState()}else{var e=new cn;cn.subtract(e,this._touchBeganPosition,this._touchEndPosition);var i=this._curPageIdx,n=i+this._getDragDirection(e),r=this.pageTurningSpeed*Math.abs(i-n);if(n<this._pages.length){if(this._isScrollable(e,i,n))return void this.scrollToPage(n,r);var s=this._calculateTouchMoveVelocity();if(this._isQuicklyScrollable(s))return void this.scrollToPage(n,r)}this.scrollToPage(i,r)}},Pi(e,[{key:"sizeMode",get:function(){return this._sizeMode},set:function(t){this._sizeMode!==t&&(this._sizeMode=t,this._syncSizeMode())}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this._syncScrollDirection())}},{key:"scrollThreshold",get:function(){return this._scrollThreshold},set:function(t){this._scrollThreshold!==t&&(this._scrollThreshold=t)}},{key:"pageTurningEventTiming",get:function(){return this._pageTurningEventTiming},set:function(t){this._pageTurningEventTiming!==t&&(this._pageTurningEventTiming=t)}},{key:"indicator",get:function(){return this._indicator},set:function(t){this._indicator!==t&&(this._indicator=t,this.indicator&&this.indicator.setPageView(this))}},{key:"curPageIdx",get:function(){return this._curPageIdx}},{key:"verticalScrollBar",get:function(){return t.prototype.verticalScrollBar},set:function(t){this.verticalScrollBar=t}},{key:"horizontalScrollBar",get:function(){return t.prototype.horizontalScrollBar},set:function(t){this.horizontalScrollBar=t}}]),e}(t2),Y3.SizeMode=q3,Y3.Direction=Z3,Y3.EventType=m2(Q3,B1),gn((D3=j3).prototype,"sizeMode",[R3],Object.getOwnPropertyDescriptor(D3.prototype,"sizeMode"),D3.prototype),gn(D3.prototype,"direction",[b3],Object.getOwnPropertyDescriptor(D3.prototype,"direction"),D3.prototype),gn(D3.prototype,"indicator",[x3],Object.getOwnPropertyDescriptor(D3.prototype,"indicator"),D3.prototype),O3=tn(D3.prototype,"autoPageTurningThreshold",[en],(function(){return 100})),gn(D3.prototype,"verticalScrollBar",[w3,mn],Object.getOwnPropertyDescriptor(D3.prototype,"verticalScrollBar"),D3.prototype),gn(D3.prototype,"horizontalScrollBar",[M3,mn],Object.getOwnPropertyDescriptor(D3.prototype,"horizontalScrollBar"),D3.prototype),F3=tn(D3.prototype,"horizontal",[mn,en],(function(){return!0})),L3=tn(D3.prototype,"vertical",[mn,en],(function(){return!0})),N3=tn(D3.prototype,"cancelInnerEvents",[mn,en],(function(){return!0})),k3=tn(D3.prototype,"scrollEvents",[I3,en,mn],(function(){return[]})),U3=tn(D3.prototype,"pageTurningSpeed",[en],(function(){return.3})),G3=tn(D3.prototype,"pageEvents",[B3,en],(function(){return[]})),V3=tn(D3.prototype,"_sizeMode",[en],(function(){return q3.Unified})),H3=tn(D3.prototype,"_direction",[en],(function(){return Z3.Horizontal})),z3=tn(D3.prototype,"_scrollThreshold",[en],(function(){return.5})),X3=tn(D3.prototype,"_pageTurningEventTiming",[en],(function(){return.1})),W3=tn(D3.prototype,"_indicator",[en],(function(){return null})),P3=D3))||P3)||P3));We.PageView=$3;var t8=new ji,e8=new cn,i8=new cn,n8=new cn(1,1),r8=new cn,s8=new cn;function a8(t,e){if(!e._hadAlignOnce){e.alignMode===t3.ONCE&&(e._hadAlignOnce=!0);var i,n=e.target,r=i8,s=n8;n?r3(t,i=n,r,s):i=t.parent;var a=n3(i),o=i instanceof za||!i.getComponent(Bl),h=o?e8:i.getComponent(Bl).anchorPoint,l=o;t.getPosition(t8);var u=t._uiProps.uiTransformComp,c=t8.x,d=t8.y,_=u.anchorPoint,f=t.getScale();if(e.alignFlags&e3.HORIZONTAL){var p=0,g=0,m=a.width;l?(p=Bn.left.x,g=Bn.right.x):g=(p=-h.x*m)+m,p+=e.isAbsoluteLeft?e.left:e.left*m,g-=e.isAbsoluteRight?e.right:e.right*m,n&&(p+=r.x,p*=s.x,g+=r.x,g*=s.x);var v=0,y=_.x,T=f.x;if(T<0&&(y=1-y,T=-T),e.isStretchWidth)v=g-p,0!==T&&(u.width=v/T),c=p+y*v;else if(v=u.width*T,e.isAlignHorizontalCenter){var S=e.isAbsoluteHorizontalCenter?e.horizontalCenter:e.horizontalCenter*m,E=(.5-h.x)*a.width;n&&(S*=s.x,E+=r.x,E*=s.x),c=E+(y-.5)*v+S}else c=e.isAlignLeft?p+y*v:g+(y-1)*v;e._lastSize.width=v}if(e.alignFlags&e3.VERTICAL){var A=0,C=0,R=a.height;l?(C=Bn.bottom.y,A=Bn.top.y):A=(C=-h.y*R)+R,C+=e.isAbsoluteBottom?e.bottom:e.bottom*R,A-=e.isAbsoluteTop?e.top:e.top*R,n&&(C+=r.y,C*=s.y,A+=r.y,A*=s.y);var b=0,x=_.y,w=f.y;if(w<0&&(x=1-x,w=-w),e.isStretchHeight)b=A-C,0!==w&&(u.height=b/w),d=C+x*b;else if(b=u.height*w,e.isAlignVerticalCenter){var M=e.isAbsoluteVerticalCenter?e.verticalCenter:e.verticalCenter*R,I=(.5-h.y)*a.height;n&&(M*=s.y,I+=r.y,I*=s.y),d=I+(x-.5)*b+M}else d=e.isAlignBottom?C+x*b:A+(x-1)*b;e._lastSize.height=b}t.setPosition(c,d,t8.z),ji.set(e._lastPos,c,d,t8.z)}}function o8(t){var e=t.getComponent(T3);if(e&&e.enabled){if(!We.isValid(t,!0))return;u8.push(e)}for(var i,n=t.children,r=Fi(n);!(i=r()).done;){var s=i.value;s.active&&o8(s)}}function h8(){var t=Di.getScene();if(t){c8.isAligning=!0,c8._nodesOrderDirty&&(u8.length=0,o8(t),c8._nodesOrderDirty=!1);var e=null,i=c8._activeWidgetsIterator;for(i.i=0;i.i<u8.length;++i.i)(e=u8[i.i])._dirty&&(a8(e.node,e),e._dirty=!1);c8.isAligning=!1}}var l8,u8=[],c8=t("widgetManager",We._widgetManager={isAligning:!1,_nodesOrderDirty:!1,_activeWidgetsIterator:new Is(u8),animationState:null,init:function(){Di.on(An.EVENT_AFTER_SCENE_LAUNCH,h8),Di.on(An.EVENT_AFTER_UPDATE,h8),L_.instance.on("design-resolution-changed",this.onResized,this);var t=this.onResized.bind(this);L_.instance.on("canvas-resize",t),Er.on("window-resize",t)},add:function(){this._nodesOrderDirty=!0},remove:function(t){this._activeWidgetsIterator.remove(t)},onResized:function(){var t=Di.getScene();t&&this.refreshWidgetOnResized(t)},refreshWidgetOnResized:function(t){var e=Pr.isNode(t)&&t.getComponent(T3);e&&e.enabled&&(e.alignMode===t3.ON_WINDOW_RESIZE||e.alignMode===t3.ALWAYS)&&e.setDirty();for(var i,n=t.children,r=Fi(n);!(i=r()).done;){var s=i.value;this.refreshWidgetOnResized(s)}},updateOffsetsToStayPut:function(t,e){function i(t,e){return Math.abs(t-e)>1e-10?e:t}var n=t.node,r=n.parent;if(r){var s=r8;s.set(0,0);var a=s8;if(a.set(1,1),t.target&&r3(n,r=t.target,s,a),!e)return;var o=r._uiProps&&r._uiProps.uiTransformComp,h=o?o.anchorPoint:e8,l=n._uiProps.uiTransformComp,u=n3(r),c=l.anchorPoint,d=n.getPosition(),_=e3,f=n.getScale(),p=0;if(e&_.LEFT){var g=-h.x*u.width;g+=s.x,g*=a.x,p=d.x-c.x*l.width*Math.abs(f.x)-g,t.isAbsoluteLeft||(p/=u.width),p/=a.x,t.left=i(t.left,p)}if(e&_.RIGHT){var m=(1-h.x)*u.width;m+=s.x,p=(m*=a.x)-(d.x+(1-c.x)*l.width*Math.abs(f.x)),t.isAbsoluteRight||(p/=u.width),p/=a.x,t.right=i(t.right,p)}if(e&_.TOP){var v=(1-h.y)*u.height;v+=s.y,p=(v*=a.y)-(d.y+(1-c.y)*l.height*Math.abs(f.y)),t.isAbsoluteTop||(p/=u.height),p/=a.y,t.top=i(t.top,p)}if(e&_.BOT){var y=-h.y*u.height;y+=s.y,y*=a.y,p=d.y-c.y*l.height*Math.abs(f.y)-y,t.isAbsoluteBottom||(p/=u.height),p/=a.y,t.bottom=i(t.bottom,p)}}},updateAlignment:function t(e){var i=e.parent;i&&Pr.isNode(i)&&t(i);var n=e.getComponent(T3);n&&i&&a8(e,n)},AlignMode:t3,AlignFlags:e3});Di.on(An.EVENT_INIT,(function(){c8.init()}));var d8,_8,f8,p8,g8,m8,v8,y8,T8,S8,E8,A8,C8=function(e){return t({SafeArea:e,SafeAreaComponent:e}),e}(Ki("cc.SafeArea")(l8=In(110)(l8=kn(T3)(l8=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.onEnable=function(){this.updateArea(),Er.on("window-resize",this.updateArea,this),Er.on("orientation-change",this.updateArea,this)},i.onDisable=function(){Er.off("window-resize",this.updateArea,this),Er.off("orientation-change",this.updateArea,this)},i.updateArea=function(){var t=this.node.getComponent(T3),e=this.node.getComponent(Bl);if(t&&e){t.updateAlignment();var i=this.node.position.clone(),n=e.anchorPoint.clone();t.isAlignTop=t.isAlignBottom=t.isAlignLeft=t.isAlignRight=!0;var r=V_.getVisibleSize(),s=r.width,a=r.height,o=rn.getSafeAreaRect();t.top=a-o.y-o.height,t.bottom=o.y,t.left=o.x,t.right=s-o.x-o.width,t.updateAlignment();var h=this.node.position.clone(),l=n.x-(h.x-i.x)/e.width,u=n.y-(h.y-i.y)/e.height;e.setAnchorPoint(l,u),c8.add(t)}},e}(Pn))||l8)||l8)||l8);We.SafeArea=C8;var R8,b8=function(e){return t({UICoordinateTracker:e,UICoordinateTrackerComponent:e}),e}((d8=Ki("cc.UICoordinateTracker"),_8=In(110),f8=Tn(Pr),p8=Tn(D_),g8=Tn([Pa]),d8(m8=_8((v8=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).syncEvents=y8&&y8(),e._target=T8&&T8(),e._camera=S8&&S8(),e._useScale=E8&&E8(),e._distance=A8&&A8(),e._transformPos=new ji,e._viewPos=new ji,e._canMove=!0,e._lastWPos=new ji,e._lastCameraPos=new ji,e}He(e,t);var i=e.prototype;return i.onEnable=function(){this._checkCanMove()},i.update=function(){var t=this.node.worldPosition,e=this._camera;if(this._canMove&&e&&e.camera&&(!this._lastWPos.equals(t)||!this._lastCameraPos.equals(e.node.worldPosition))&&(this._lastWPos.set(t),this._lastCameraPos.set(e.node.worldPosition),e.camera.update(),e.convertToUINode(t,this._target,this._transformPos),this._useScale&&ji.transformMat4(this._viewPos,this.node.worldPosition,e.camera.matView),this.syncEvents.length>0)){var i=this._distance/Math.abs(this._viewPos.z);Pa.emitEvents(this.syncEvents,this._transformPos,i)}},i._checkCanMove=function(){this._canMove=!(!this._camera||!this._target)},Pi(e,[{key:"target",get:function(){return this._target},set:function(t){this._target!==t&&(this._target=t,this._checkCanMove())}},{key:"camera",get:function(){return this._camera},set:function(t){this._camera!==t&&(this._camera=t,this._checkCanMove())}},{key:"useScale",get:function(){return this._useScale},set:function(t){this._useScale!==t&&(this._useScale=t)}},{key:"distance",get:function(){return this._distance},set:function(t){this._distance!==t&&(this._distance=t)}}]),e}(Pn),gn(v8.prototype,"target",[f8],Object.getOwnPropertyDescriptor(v8.prototype,"target"),v8.prototype),gn(v8.prototype,"camera",[p8],Object.getOwnPropertyDescriptor(v8.prototype,"camera"),v8.prototype),y8=tn(v8.prototype,"syncEvents",[g8,en],(function(){return[]})),T8=tn(v8.prototype,"_target",[en],(function(){return null})),S8=tn(v8.prototype,"_camera",[en],(function(){return null})),E8=tn(v8.prototype,"_useScale",[en],(function(){return!0})),A8=tn(v8.prototype,"_distance",[en],(function(){return 1})),m8=v8))||m8)||m8)),x8=[xn.TOUCH_START,xn.TOUCH_END,xn.TOUCH_MOVE,xn.MOUSE_DOWN,xn.MOUSE_MOVE,xn.MOUSE_UP,xn.MOUSE_ENTER,xn.MOUSE_LEAVE,xn.MOUSE_WHEEL];function w8(t){t.propagationStopped=!0}var M8,I8,B8,P8,D8,O8=function(e){return t({BlockInputEvents:e,BlockInputEventsComponent:e}),e}(Ki("cc.BlockInputEvents")(R8=function(t){function e(){return t.apply(this,arguments)||this}He(e,t);var i=e.prototype;return i.onEnable=function(){for(var t=0;t<x8.length;t++)this.node.on(x8[t],w8,this)},i.onDisable=function(){for(var t=0;t<x8.length;t++)this.node.off(x8[t],w8,this)},e}(Pn))||R8),F8=t("SubContextView",Ki("cc.SubContextView")(M8=In(110)(M8=kn(Bl)((I8=function(t){function e(){var e;return(e=t.call(this)||this)._fps=B8&&B8(),e._sprite=void 0,e._imageAsset=void 0,e._texture=void 0,e._updatedTime=0,e._updateInterval=0,e._openDataContext=void 0,e._content=void 0,e._designResolutionSize=P8&&P8(),e._content=new Pr("content"),e._content.hideFlags|=Dr.Flags.DontSave|Dr.Flags.HideInHierarchy,e._sprite=null,e._imageAsset=new Ui,e._openDataContext=null,e._updatedTime=performance.now(),e._texture=new Xe,e}He(e,t);var i=e.prototype;return i.onLoad=function(){Ya.getOpenDataContext?(this._updateInterval=1e3/this._fps,this._openDataContext=Ya.getOpenDataContext(),this._initSharedCanvas(),this._initContentNode(),this._updateSubContextView(),this._updateContentLayer()):this.enabled=!1},i.onEnable=function(){this._registerNodeEvent()},i.onDisable=function(){this._unregisterNodeEvent()},i._initSharedCanvas=function(){if(this._openDataContext){var t=this._openDataContext.canvas,e=this._designResolutionSize.width,i=this._designResolutionSize.height;t.width=e,t.height=i}},i._initContentNode=function(){if(this._openDataContext){var t=this._openDataContext.canvas,e=this._imageAsset;if(e.reset(t),this._texture.image=e,this._texture.create(t.width,t.height),this._sprite=this._content.getComponent(Bd),this._sprite||(this._sprite=this._content.addComponent(Bd)),this._sprite.spriteFrame)this._sprite.spriteFrame.texture=this._texture;else{var i=new Uo;i.texture=this._texture,this._sprite.spriteFrame=i}this._content.parent=this.node}},i._updateSubContextView=function(){if(this._openDataContext){var t=this.node.getComponent(Bl),e=this._content.getComponent(Bl),i=t.width/e.width,n=t.height/e.height,r=i>n?n:i;e.width*=r,e.height*=r;var s=V_.getViewportRect(),a=e.getBoundingBoxToWorld(),o=V_.getVisibleSize(),h=Er.devicePixelRatio,l=(s.width*(a.x/o.width)+s.x)/h,u=(s.height*(a.y/o.height)+s.y)/h,c=s.width*(a.width/o.width)/h,d=s.height*(a.height/o.height)/h;this._openDataContext.postMessage({fromEngine:!0,type:"engine",event:"viewport",x:l,y:u,width:c,height:d})}},i._updateSubContextTexture=function(){var t=this._imageAsset;if(t&&this._openDataContext&&!(t.width<=0||t.height<=0)){var e=this._openDataContext.canvas;t.reset(e),(e.width>t.width||e.height>t.height)&&this._texture.create(e.width,e.height),this._texture.uploadData(e)}},i._registerNodeEvent=function(){this.node.on(xn.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.on(xn.SIZE_CHANGED,this._updateSubContextView,this),this.node.on(xn.LAYER_CHANGED,this._updateContentLayer,this)},i._unregisterNodeEvent=function(){this.node.off(xn.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.off(xn.SIZE_CHANGED,this._updateSubContextView,this),this.node.off(xn.LAYER_CHANGED,this._updateContentLayer,this)},i._updateContentLayer=function(){this._content.layer=this.node.layer},i.update=function(t){void 0===t?this._updateSubContextTexture():performance.now()-this._updatedTime>=this._updateInterval&&(this._updatedTime+=this._updateInterval,this._updateSubContextTexture())},i.onDestroy=function(){this._content.destroy(),this._texture.destroy(),this._sprite&&this._sprite.destroy(),this._imageAsset.destroy(),this._openDataContext=null},Pi(e,[{key:"designResolutionSize",get:function(){return this._designResolutionSize},set:function(){}},{key:"fps",get:function(){return this._fps},set:function(t){this._fps!==t&&(this._fps=t,this._updateInterval=1e3/t)}}]),e}(Pn),B8=tn(I8.prototype,"_fps",[en],(function(){return 60})),P8=tn(I8.prototype,"_designResolutionSize",[en],(function(){return new dn(640,960)})),M8=I8))||M8)||M8)||M8);We.SubContextView=F8,_r({ButtonComponent:{newName:"Button",since:"1.2.0",removed:!1},EditBoxComponent:{newName:"EditBox",since:"1.2.0",removed:!1},LayoutComponent:{newName:"Layout",since:"1.2.0",removed:!1},ProgressBarComponent:{newName:"ProgressBar",since:"1.2.0",removed:!1},ScrollViewComponent:{newName:"ScrollView",since:"1.2.0",removed:!1},ScrollBarComponent:{newName:"ScrollBar",since:"1.2.0",removed:!1},SliderComponent:{newName:"Slider",since:"1.2.0",removed:!1},ToggleComponent:{newName:"Toggle",since:"1.2.0",removed:!1},ToggleContainerComponent:{newName:"ToggleContainer",since:"1.2.0",removed:!1},WidgetComponent:{newName:"Widget",since:"1.2.0",removed:!1},PageViewComponent:{newName:"PageView",since:"1.2.0",removed:!1},PageViewIndicatorComponent:{newName:"PageViewIndicator",since:"1.2.0",removed:!1},SafeAreaComponent:{newName:"SafeArea",since:"1.2.0",removed:!1},UICoordinateTrackerComponent:{newName:"UICoordinateTracker",since:"1.2.0",removed:!1},BlockInputEventsComponent:{newName:"BlockInputEvents",since:"1.2.0",removed:!1}});var L8=t("UIReorderComponent",Ki("cc.UIReorderComponent")(D8=function(){Zi(1408,"UIReorderComponent")})||D8);We.UIReorderComponent=L8,We.ButtonComponent=qJ,br(qJ,"cc.ButtonComponent"),We.EditBoxComponent=T0,br(T0,"cc.EditBoxComponent"),We.LayoutComponent=N0,br(N0,"cc.LayoutComponent"),We.ProgressBarComponent=J0,br(J0,"cc.ProgressBarComponent"),We.ScrollViewComponent=t2,br(t2,"cc.ScrollViewComponent"),We.ScrollBarComponent=o1,br(o1,"cc.ScrollBarComponent"),We.SliderComponent=g2,br(g2,"cc.SliderComponent"),We.ToggleComponent=R2,br(R2,"cc.ToggleComponent"),We.ToggleContainerComponent=$2,br($2,"cc.ToggleContainerComponent"),We.WidgetComponent=T3,br(T3,"cc.WidgetComponent"),We.PageViewComponent=$3,br($3,"cc.PageViewComponent"),We.PageViewIndicatorComponent=K3,br(K3,"cc.PageViewIndicatorComponent"),We.SafeAreaComponent=C8,br(C8,"cc.SafeAreaComponent"),br(b8,"cc.UICoordinateTrackerComponent"),We.BlockInputEventsComponent=O8,br(O8,"cc.BlockInputEventsComponent"),Vn(L_.prototype,"View.prototype",[{name:"isAntiAliasEnabled",suggest:"The API of Texture2d have been largely modified, no alternative"},{name:"enableAntiAlias",suggest:"The API of Texture2d have been largely modified, no alternative"}]),Rr(L_.prototype,"View.prototype",[{name:"adjustViewportMeta"},{name:"enableAutoFullScreen",suggest:"use screen.requestFullScreen() instead."},{name:"isAutoFullScreenEnabled"},{name:"setCanvasSize",suggest:"setting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"getCanvasSize",suggest:"please use screen.windowSize instead."},{name:"getFrameSize",suggest:"getting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"setFrameSize",suggest:"setting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"getDevicePixelRatio",suggest:"use screen.devicePixelRatio instead."},{name:"convertToLocationInView"},{name:"enableRetina"},{name:"isRetinaEnabled"},{name:"setRealPixelResolution"}])}}}));