@cosmos.gl/graph 2.6.2-rc.0 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -6,7 +6,7 @@
6
6
  `).replace(/}/g,`}
7
7
  `).replace(/{/g,`{
8
8
  `),J=Function.apply(null,h.concat(ue));return J.apply(null,_)}return{global:K,link:M,block:W,proc:ie,scope:R,cond:B,compile:oe}}var Zi="xyzw".split(""),cc=5121,Qi=1,Gs=2,Bs=0,Us=1,Vs=2,$s=3,na=4,hc=5,dc=6,mc="dither",pc="blend.enable",vc="blend.color",Hs="blend.equation",Ws="blend.func",gc="depth.enable",yc="depth.func",xc="depth.range",bc="depth.mask",Xs="colorMask",_c="cull.enable",Sc="cull.face",js="frontFace",qs="lineWidth",Tc="polygonOffset.enable",Ys="polygonOffset.offset",wc="sample.alpha",Ac="sample.enable",Zs="sample.coverage",Ec="stencil.enable",Cc="stencil.mask",Qs="stencil.func",Ks="stencil.opFront",kr="stencil.opBack",Pc="scissor.enable",ia="scissor.box",Bn="viewport",Ir="profile",xi="framebuffer",Lr="vert",Dr="frag",bi="elements",_i="primitive",Si="count",ra="offset",oa="instances",Fr="vao",Js="Width",ef="Height",Ki=xi+Js,Ji=xi+ef,Cx=Bn+Js,Px=Bn+ef,kc="drawingBuffer",Ic=kc+Js,Lc=kc+ef,kx=[Ws,Hs,Qs,Ks,kr,Zs,Bn,ia,Ys],er=34962,tf=34963,Ix=35632,Lx=35633,Dc=3553,Dx=34067,Fx=2884,zx=3042,Rx=3024,Mx=2960,Ox=2929,Nx=3089,Gx=32823,Bx=32926,Ux=32928,nf=5126,aa=35664,sa=35665,fa=35666,rf=5124,la=35667,ua=35668,ca=35669,of=35670,ha=35671,da=35672,ma=35673,zr=35674,Rr=35675,Mr=35676,Or=35678,Nr=35680,af=4,Gr=1028,Ti=1029,Fc=2304,sf=2305,Vx=32775,$x=32776,Hx=519,Qn=7680,zc=0,Rc=1,Mc=32774,Wx=513,Oc=36160,Xx=36064,En={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Nc=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],tr={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Kn={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Gc={frag:Ix,vert:Lx},ff={cw:Fc,ccw:sf};function pa(a){return Array.isArray(a)||n(a)||yn(a)}function Bc(a){return a.sort(function(h,_){return h===Bn?-1:_===Bn?1:h<_?-1:1})}function Dt(a,h,_,M){this.thisDep=a,this.contextDep=h,this.propDep=_,this.append=M}function Jn(a){return a&&!(a.thisDep||a.contextDep||a.propDep)}function St(a){return new Dt(!1,!1,!1,a)}function Jt(a,h){var _=a.type;if(_===Bs){var M=a.data.length;return new Dt(!0,M>=1,M>=2,h)}else if(_===na){var W=a.data;return new Dt(W.thisDep,W.contextDep,W.propDep,h)}else{if(_===hc)return new Dt(!1,!1,!1,h);if(_===dc){for(var R=!1,B=!1,K=!1,Q=0;Q<a.data.length;++Q){var ie=a.data[Q];if(ie.type===Us)K=!0;else if(ie.type===Vs)B=!0;else if(ie.type===$s)R=!0;else if(ie.type===Bs){R=!0;var oe=ie.data;oe>=1&&(B=!0),oe>=2&&(K=!0)}else ie.type===na&&(R=R||ie.data.thisDep,B=B||ie.data.contextDep,K=K||ie.data.propDep)}return new Dt(R,B,K,h)}else return new Dt(_===$s,_===Vs,_===Us,h)}}var Uc=new Dt(!1,!1,!1,function(){});function jx(a,h,_,M,W,R,B,K,Q,ie,oe,re,ue,J,ne){var k=ie.Record,N={add:32774,subtract:32778,"reverse subtract":32779};_.ext_blend_minmax&&(N.min=Vx,N.max=$x);var te=_.angle_instanced_arrays,xe=_.webgl_draw_buffers,Z=_.oes_vertex_array_object,ge={dirty:!0,profile:ne.profile},me={},Le=[],X={},H={};function Se(p){return p.replace(".","_")}function ce(p,c,T){var C=Se(p);Le.push(p),me[C]=ge[C]=!!T,X[C]=c}function ee(p,c,T){var C=Se(p);Le.push(p),Array.isArray(T)?(ge[C]=T.slice(),me[C]=T.slice()):ge[C]=me[C]=T,H[C]=c}ce(mc,Rx),ce(pc,zx),ee(vc,"blendColor",[0,0,0,0]),ee(Hs,"blendEquationSeparate",[Mc,Mc]),ee(Ws,"blendFuncSeparate",[Rc,zc,Rc,zc]),ce(gc,Ox,!0),ee(yc,"depthFunc",Wx),ee(xc,"depthRange",[0,1]),ee(bc,"depthMask",!0),ee(Xs,Xs,[!0,!0,!0,!0]),ce(_c,Fx),ee(Sc,"cullFace",Ti),ee(js,js,sf),ee(qs,qs,1),ce(Tc,Gx),ee(Ys,"polygonOffset",[0,0]),ce(wc,Bx),ce(Ac,Ux),ee(Zs,"sampleCoverage",[1,!1]),ce(Ec,Mx),ee(Cc,"stencilMask",-1),ee(Qs,"stencilFunc",[Hx,0,-1]),ee(Ks,"stencilOpSeparate",[Gr,Qn,Qn,Qn]),ee(kr,"stencilOpSeparate",[Ti,Qn,Qn,Qn]),ce(Pc,Nx),ee(ia,"scissor",[0,0,a.drawingBufferWidth,a.drawingBufferHeight]),ee(Bn,Bn,[0,0,a.drawingBufferWidth,a.drawingBufferHeight]);var he={gl:a,context:ue,strings:h,next:me,current:ge,draw:re,elements:R,buffer:W,shader:oe,attributes:ie.state,vao:ie,uniforms:Q,framebuffer:K,extensions:_,timer:J,isBufferArgs:pa},de={primTypes:Yn,compareFuncs:tr,blendFuncs:En,blendEquations:N,stencilOps:Kn,glTypes:mi,orientationType:ff};m.optional(function(){he.isArrayLike=pt}),xe&&(de.backBuffer=[Ti],de.drawBuffer=Yt(M.maxDrawbuffers,function(p){return p===0?[0]:Yt(p,function(c){return Xx+c})}));var He=0;function Ue(){var p=Ex(),c=p.link,T=p.global;p.id=He++,p.batchId="0";var C=c(he),I=p.shared={props:"a0"};Object.keys(he).forEach(function(b){I[b]=T.def(C,".",b)}),m.optional(function(){p.CHECK=c(m),p.commandStr=m.guessCommand(),p.command=c(p.commandStr),p.assert=function(b,g,F){b("if(!(",g,"))",this.CHECK,".commandRaise(",c(F),",",this.command,");")},de.invalidBlendCombinations=Nc});var A=p.next={},w=p.current={};Object.keys(H).forEach(function(b){Array.isArray(ge[b])&&(A[b]=T.def(I.next,".",b),w[b]=T.def(I.current,".",b))});var E=p.constants={};Object.keys(de).forEach(function(b){E[b]=T.def(JSON.stringify(de[b]))}),p.invoke=function(b,g){switch(g.type){case Bs:var F=["this",I.context,I.props,p.batchId];return b.def(c(g.data),".call(",F.slice(0,Math.max(g.data.length+1,4)),")");case Us:return b.def(I.props,g.data);case Vs:return b.def(I.context,g.data);case $s:return b.def("this",g.data);case na:return g.data.append(p,b),g.data.ref;case hc:return g.data.toString();case dc:return g.data.map(function(L){return p.invoke(b,L)})}},p.attribCache={};var v={};return p.scopeAttrib=function(b){var g=h.id(b);if(g in v)return v[g];var F=ie.scope[g];F||(F=ie.scope[g]=new k);var L=v[g]=c(F);return L},p}function pe(p){var c=p.static,T=p.dynamic,C;if(Ir in c){var I=!!c[Ir];C=St(function(w,E){return I}),C.enable=I}else if(Ir in T){var A=T[Ir];C=Jt(A,function(w,E){return w.invoke(E,A)})}return C}function ye(p,c){var T=p.static,C=p.dynamic;if(xi in T){var I=T[xi];return I?(I=K.getFramebuffer(I),m.command(I,"invalid framebuffer object"),St(function(w,E){var v=w.link(I),b=w.shared;E.set(b.framebuffer,".next",v);var g=b.context;return E.set(g,"."+Ki,v+".width"),E.set(g,"."+Ji,v+".height"),v})):St(function(w,E){var v=w.shared;E.set(v.framebuffer,".next","null");var b=v.context;return E.set(b,"."+Ki,b+"."+Ic),E.set(b,"."+Ji,b+"."+Lc),"null"})}else if(xi in C){var A=C[xi];return Jt(A,function(w,E){var v=w.invoke(E,A),b=w.shared,g=b.framebuffer,F=E.def(g,".getFramebuffer(",v,")");m.optional(function(){w.assert(E,"!"+v+"||"+F,"invalid framebuffer object")}),E.set(g,".next",F);var L=b.context;return E.set(L,"."+Ki,F+"?"+F+".width:"+L+"."+Ic),E.set(L,"."+Ji,F+"?"+F+".height:"+L+"."+Lc),F})}else return null}function Re(p,c,T){var C=p.static,I=p.dynamic;function A(v){if(v in C){var b=C[v];m.commandType(b,"object","invalid "+v,T.commandStr);var g=!0,F=b.x|0,L=b.y|0,$,j;return"width"in b?($=b.width|0,m.command($>=0,"invalid "+v,T.commandStr)):g=!1,"height"in b?(j=b.height|0,m.command(j>=0,"invalid "+v,T.commandStr)):g=!1,new Dt(!g&&c&&c.thisDep,!g&&c&&c.contextDep,!g&&c&&c.propDep,function(ke,be){var Y=ke.shared.context,U=$;"width"in b||(U=be.def(Y,".",Ki,"-",F));var Ce=j;return"height"in b||(Ce=be.def(Y,".",Ji,"-",L)),[F,L,U,Ce]})}else if(v in I){var le=I[v],Ge=Jt(le,function(ke,be){var Y=ke.invoke(be,le);m.optional(function(){ke.assert(be,Y+"&&typeof "+Y+'==="object"',"invalid "+v)});var U=ke.shared.context,Ce=be.def(Y,".x|0"),Ae=be.def(Y,".y|0"),Me=be.def('"width" in ',Y,"?",Y,".width|0:","(",U,".",Ki,"-",Ce,")"),st=be.def('"height" in ',Y,"?",Y,".height|0:","(",U,".",Ji,"-",Ae,")");return m.optional(function(){ke.assert(be,Me+">=0&&"+st+">=0","invalid "+v)}),[Ce,Ae,Me,st]});return c&&(Ge.thisDep=Ge.thisDep||c.thisDep,Ge.contextDep=Ge.contextDep||c.contextDep,Ge.propDep=Ge.propDep||c.propDep),Ge}else return c?new Dt(c.thisDep,c.contextDep,c.propDep,function(ke,be){var Y=ke.shared.context;return[0,0,be.def(Y,".",Ki),be.def(Y,".",Ji)]}):null}var w=A(Bn);if(w){var E=w;w=new Dt(w.thisDep,w.contextDep,w.propDep,function(v,b){var g=E.append(v,b),F=v.shared.context;return b.set(F,"."+Cx,g[2]),b.set(F,"."+Px,g[3]),g})}return{viewport:w,scissor_box:A(ia)}}function We(p,c){var T=p.static,C=typeof T[Dr]=="string"&&typeof T[Lr]=="string";if(C){if(Object.keys(c.dynamic).length>0)return null;var I=c.static,A=Object.keys(I);if(A.length>0&&typeof I[A[0]]=="number"){for(var w=[],E=0;E<A.length;++E)m(typeof I[A[E]]=="number","must specify all vertex attribute locations when using vaos"),w.push([I[A[E]]|0,A[E]]);return w}}return null}function Je(p,c,T){var C=p.static,I=p.dynamic;function A(g){if(g in C){var F=h.id(C[g]);m.optional(function(){oe.shader(Gc[g],F,m.guessCommand())});var L=St(function(){return F});return L.id=F,L}else if(g in I){var $=I[g];return Jt($,function(j,le){var Ge=j.invoke(le,$),ke=le.def(j.shared.strings,".id(",Ge,")");return m.optional(function(){le(j.shared.shader,".shader(",Gc[g],",",ke,",",j.command,");")}),ke})}return null}var w=A(Dr),E=A(Lr),v=null,b;return Jn(w)&&Jn(E)?(v=oe.program(E.id,w.id,null,T),b=St(function(g,F){return g.link(v)})):b=new Dt(w&&w.thisDep||E&&E.thisDep,w&&w.contextDep||E&&E.contextDep,w&&w.propDep||E&&E.propDep,function(g,F){var L=g.shared.shader,$;w?$=w.append(g,F):$=F.def(L,".",Dr);var j;E?j=E.append(g,F):j=F.def(L,".",Lr);var le=L+".program("+j+","+$;return m.optional(function(){le+=","+g.command}),F.def(le+")")}),{frag:w,vert:E,progVar:b,program:v}}function vt(p,c){var T=p.static,C=p.dynamic,I={},A=!1;function w(){if(Fr in T){var be=T[Fr];return be!==null&&ie.getVAO(be)===null&&(be=ie.createVAO(be)),A=!0,I.vao=be,St(function(U){var Ce=ie.getVAO(be);return Ce?U.link(Ce):"null"})}else if(Fr in C){A=!0;var Y=C[Fr];return Jt(Y,function(U,Ce){var Ae=U.invoke(Ce,Y);return Ce.def(U.shared.vao+".getVAO("+Ae+")")})}return null}var E=w(),v=!1;function b(){if(bi in T){var be=T[bi];if(I.elements=be,pa(be)){var Y=I.elements=R.create(be,!0);be=R.getElements(Y),v=!0}else be&&(be=R.getElements(be),v=!0,m.command(be,"invalid elements",c.commandStr));var U=St(function(Ae,Me){if(be){var st=Ae.link(be);return Ae.ELEMENTS=st,st}return Ae.ELEMENTS=null,null});return U.value=be,U}else if(bi in C){v=!0;var Ce=C[bi];return Jt(Ce,function(Ae,Me){var st=Ae.shared,Vt=st.isBufferArgs,Ai=st.elements,Un=Ae.invoke(Me,Ce),Pn=Me.def("null"),ei=Me.def(Vt,"(",Un,")"),Ei=Ae.cond(ei).then(Pn,"=",Ai,".createStream(",Un,");").else(Pn,"=",Ai,".getElements(",Un,");");return m.optional(function(){Ae.assert(Ei.else,"!"+Un+"||"+Pn,"invalid elements")}),Me.entry(Ei),Me.exit(Ae.cond(ei).then(Ai,".destroyStream(",Pn,");")),Ae.ELEMENTS=Pn,Pn})}else if(A)return new Dt(E.thisDep,E.contextDep,E.propDep,function(Ae,Me){return Me.def(Ae.shared.vao+".currentVAO?"+Ae.shared.elements+".getElements("+Ae.shared.vao+".currentVAO.elements):null")});return null}var g=b();function F(){if(_i in T){var be=T[_i];return I.primitive=be,m.commandParameter(be,Yn,"invalid primitve",c.commandStr),St(function(U,Ce){return Yn[be]})}else if(_i in C){var Y=C[_i];return Jt(Y,function(U,Ce){var Ae=U.constants.primTypes,Me=U.invoke(Ce,Y);return m.optional(function(){U.assert(Ce,Me+" in "+Ae,"invalid primitive, must be one of "+Object.keys(Yn))}),Ce.def(Ae,"[",Me,"]")})}else{if(v)return Jn(g)?g.value?St(function(U,Ce){return Ce.def(U.ELEMENTS,".primType")}):St(function(){return af}):new Dt(g.thisDep,g.contextDep,g.propDep,function(U,Ce){var Ae=U.ELEMENTS;return Ce.def(Ae,"?",Ae,".primType:",af)});if(A)return new Dt(E.thisDep,E.contextDep,E.propDep,function(U,Ce){return Ce.def(U.shared.vao+".currentVAO?"+U.shared.vao+".currentVAO.primitive:"+af)})}return null}function L(be,Y){if(be in T){var U=T[be]|0;return Y?I.offset=U:I.instances=U,m.command(!Y||U>=0,"invalid "+be,c.commandStr),St(function(Ae,Me){return Y&&(Ae.OFFSET=U),U})}else if(be in C){var Ce=C[be];return Jt(Ce,function(Ae,Me){var st=Ae.invoke(Me,Ce);return Y&&(Ae.OFFSET=st,m.optional(function(){Ae.assert(Me,st+">=0","invalid "+be)})),st})}else if(Y){if(v)return St(function(Ae,Me){return Ae.OFFSET=0,0});if(A)return new Dt(E.thisDep,E.contextDep,E.propDep,function(Ae,Me){return Me.def(Ae.shared.vao+".currentVAO?"+Ae.shared.vao+".currentVAO.offset:0")})}else if(A)return new Dt(E.thisDep,E.contextDep,E.propDep,function(Ae,Me){return Me.def(Ae.shared.vao+".currentVAO?"+Ae.shared.vao+".currentVAO.instances:-1")});return null}var $=L(ra,!0);function j(){if(Si in T){var be=T[Si]|0;return I.count=be,m.command(typeof be=="number"&&be>=0,"invalid vertex count",c.commandStr),St(function(){return be})}else if(Si in C){var Y=C[Si];return Jt(Y,function(Me,st){var Vt=Me.invoke(st,Y);return m.optional(function(){Me.assert(st,"typeof "+Vt+'==="number"&&'+Vt+">=0&&"+Vt+"===("+Vt+"|0)","invalid vertex count")}),Vt})}else if(v)if(Jn(g)){if(g)return $?new Dt($.thisDep,$.contextDep,$.propDep,function(Me,st){var Vt=st.def(Me.ELEMENTS,".vertCount-",Me.OFFSET);return m.optional(function(){Me.assert(st,Vt+">=0","invalid vertex offset/element buffer too small")}),Vt}):St(function(Me,st){return st.def(Me.ELEMENTS,".vertCount")});var U=St(function(){return-1});return m.optional(function(){U.MISSING=!0}),U}else{var Ce=new Dt(g.thisDep||$.thisDep,g.contextDep||$.contextDep,g.propDep||$.propDep,function(Me,st){var Vt=Me.ELEMENTS;return Me.OFFSET?st.def(Vt,"?",Vt,".vertCount-",Me.OFFSET,":-1"):st.def(Vt,"?",Vt,".vertCount:-1")});return m.optional(function(){Ce.DYNAMIC=!0}),Ce}else if(A){var Ae=new Dt(E.thisDep,E.contextDep,E.propDep,function(Me,st){return st.def(Me.shared.vao,".currentVAO?",Me.shared.vao,".currentVAO.count:-1")});return Ae}return null}var le=F(),Ge=j(),ke=L(oa,!1);return{elements:g,primitive:le,count:Ge,instances:ke,offset:$,vao:E,vaoActive:A,elementsActive:v,static:I}}function yt(p,c){var T=p.static,C=p.dynamic,I={};return Le.forEach(function(A){var w=Se(A);function E(v,b){if(A in T){var g=v(T[A]);I[w]=St(function(){return g})}else if(A in C){var F=C[A];I[w]=Jt(F,function(L,$){return b(L,$,L.invoke($,F))})}}switch(A){case _c:case pc:case mc:case Ec:case gc:case Pc:case Tc:case wc:case Ac:case bc:return E(function(v){return m.commandType(v,"boolean",A,c.commandStr),v},function(v,b,g){return m.optional(function(){v.assert(b,"typeof "+g+'==="boolean"',"invalid flag "+A,v.commandStr)}),g});case yc:return E(function(v){return m.commandParameter(v,tr,"invalid "+A,c.commandStr),tr[v]},function(v,b,g){var F=v.constants.compareFuncs;return m.optional(function(){v.assert(b,g+" in "+F,"invalid "+A+", must be one of "+Object.keys(tr))}),b.def(F,"[",g,"]")});case xc:return E(function(v){return m.command(pt(v)&&v.length===2&&typeof v[0]=="number"&&typeof v[1]=="number"&&v[0]<=v[1],"depth range is 2d array",c.commandStr),v},function(v,b,g){m.optional(function(){v.assert(b,v.shared.isArrayLike+"("+g+")&&"+g+".length===2&&typeof "+g+'[0]==="number"&&typeof '+g+'[1]==="number"&&'+g+"[0]<="+g+"[1]","depth range must be a 2d array")});var F=b.def("+",g,"[0]"),L=b.def("+",g,"[1]");return[F,L]});case Ws:return E(function(v){m.commandType(v,"object","blend.func",c.commandStr);var b="srcRGB"in v?v.srcRGB:v.src,g="srcAlpha"in v?v.srcAlpha:v.src,F="dstRGB"in v?v.dstRGB:v.dst,L="dstAlpha"in v?v.dstAlpha:v.dst;return m.commandParameter(b,En,w+".srcRGB",c.commandStr),m.commandParameter(g,En,w+".srcAlpha",c.commandStr),m.commandParameter(F,En,w+".dstRGB",c.commandStr),m.commandParameter(L,En,w+".dstAlpha",c.commandStr),m.command(Nc.indexOf(b+", "+F)===-1,"unallowed blending combination (srcRGB, dstRGB) = ("+b+", "+F+")",c.commandStr),[En[b],En[F],En[g],En[L]]},function(v,b,g){var F=v.constants.blendFuncs;m.optional(function(){v.assert(b,g+"&&typeof "+g+'==="object"',"invalid blend func, must be an object")});function L(Y,U){var Ce=b.def('"',Y,U,'" in ',g,"?",g,".",Y,U,":",g,".",Y);return m.optional(function(){v.assert(b,Ce+" in "+F,"invalid "+A+"."+Y+U+", must be one of "+Object.keys(En))}),Ce}var $=L("src","RGB"),j=L("dst","RGB");m.optional(function(){var Y=v.constants.invalidBlendCombinations;v.assert(b,Y+".indexOf("+$+'+", "+'+j+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var le=b.def(F,"[",$,"]"),Ge=b.def(F,"[",L("src","Alpha"),"]"),ke=b.def(F,"[",j,"]"),be=b.def(F,"[",L("dst","Alpha"),"]");return[le,ke,Ge,be]});case Hs:return E(function(v){if(typeof v=="string")return m.commandParameter(v,N,"invalid "+A,c.commandStr),[N[v],N[v]];if(typeof v=="object")return m.commandParameter(v.rgb,N,A+".rgb",c.commandStr),m.commandParameter(v.alpha,N,A+".alpha",c.commandStr),[N[v.rgb],N[v.alpha]];m.commandRaise("invalid blend.equation",c.commandStr)},function(v,b,g){var F=v.constants.blendEquations,L=b.def(),$=b.def(),j=v.cond("typeof ",g,'==="string"');return m.optional(function(){function le(Ge,ke,be){v.assert(Ge,be+" in "+F,"invalid "+ke+", must be one of "+Object.keys(N))}le(j.then,A,g),v.assert(j.else,g+"&&typeof "+g+'==="object"',"invalid "+A),le(j.else,A+".rgb",g+".rgb"),le(j.else,A+".alpha",g+".alpha")}),j.then(L,"=",$,"=",F,"[",g,"];"),j.else(L,"=",F,"[",g,".rgb];",$,"=",F,"[",g,".alpha];"),b(j),[L,$]});case vc:return E(function(v){return m.command(pt(v)&&v.length===4,"blend.color must be a 4d array",c.commandStr),Yt(4,function(b){return+v[b]})},function(v,b,g){return m.optional(function(){v.assert(b,v.shared.isArrayLike+"("+g+")&&"+g+".length===4","blend.color must be a 4d array")}),Yt(4,function(F){return b.def("+",g,"[",F,"]")})});case Cc:return E(function(v){return m.commandType(v,"number",w,c.commandStr),v|0},function(v,b,g){return m.optional(function(){v.assert(b,"typeof "+g+'==="number"',"invalid stencil.mask")}),b.def(g,"|0")});case Qs:return E(function(v){m.commandType(v,"object",w,c.commandStr);var b=v.cmp||"keep",g=v.ref||0,F="mask"in v?v.mask:-1;return m.commandParameter(b,tr,A+".cmp",c.commandStr),m.commandType(g,"number",A+".ref",c.commandStr),m.commandType(F,"number",A+".mask",c.commandStr),[tr[b],g,F]},function(v,b,g){var F=v.constants.compareFuncs;m.optional(function(){function le(){v.assert(b,Array.prototype.join.call(arguments,""),"invalid stencil.func")}le(g+"&&typeof ",g,'==="object"'),le('!("cmp" in ',g,")||(",g,".cmp in ",F,")")});var L=b.def('"cmp" in ',g,"?",F,"[",g,".cmp]",":",Qn),$=b.def(g,".ref|0"),j=b.def('"mask" in ',g,"?",g,".mask|0:-1");return[L,$,j]});case Ks:case kr:return E(function(v){m.commandType(v,"object",w,c.commandStr);var b=v.fail||"keep",g=v.zfail||"keep",F=v.zpass||"keep";return m.commandParameter(b,Kn,A+".fail",c.commandStr),m.commandParameter(g,Kn,A+".zfail",c.commandStr),m.commandParameter(F,Kn,A+".zpass",c.commandStr),[A===kr?Ti:Gr,Kn[b],Kn[g],Kn[F]]},function(v,b,g){var F=v.constants.stencilOps;m.optional(function(){v.assert(b,g+"&&typeof "+g+'==="object"',"invalid "+A)});function L($){return m.optional(function(){v.assert(b,'!("'+$+'" in '+g+")||("+g+"."+$+" in "+F+")","invalid "+A+"."+$+", must be one of "+Object.keys(Kn))}),b.def('"',$,'" in ',g,"?",F,"[",g,".",$,"]:",Qn)}return[A===kr?Ti:Gr,L("fail"),L("zfail"),L("zpass")]});case Ys:return E(function(v){m.commandType(v,"object",w,c.commandStr);var b=v.factor|0,g=v.units|0;return m.commandType(b,"number",w+".factor",c.commandStr),m.commandType(g,"number",w+".units",c.commandStr),[b,g]},function(v,b,g){m.optional(function(){v.assert(b,g+"&&typeof "+g+'==="object"',"invalid "+A)});var F=b.def(g,".factor|0"),L=b.def(g,".units|0");return[F,L]});case Sc:return E(function(v){var b=0;return v==="front"?b=Gr:v==="back"&&(b=Ti),m.command(!!b,w,c.commandStr),b},function(v,b,g){return m.optional(function(){v.assert(b,g+'==="front"||'+g+'==="back"',"invalid cull.face")}),b.def(g,'==="front"?',Gr,":",Ti)});case qs:return E(function(v){return m.command(typeof v=="number"&&v>=M.lineWidthDims[0]&&v<=M.lineWidthDims[1],"invalid line width, must be a positive number between "+M.lineWidthDims[0]+" and "+M.lineWidthDims[1],c.commandStr),v},function(v,b,g){return m.optional(function(){v.assert(b,"typeof "+g+'==="number"&&'+g+">="+M.lineWidthDims[0]+"&&"+g+"<="+M.lineWidthDims[1],"invalid line width")}),g});case js:return E(function(v){return m.commandParameter(v,ff,w,c.commandStr),ff[v]},function(v,b,g){return m.optional(function(){v.assert(b,g+'==="cw"||'+g+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),b.def(g+'==="cw"?'+Fc+":"+sf)});case Xs:return E(function(v){return m.command(pt(v)&&v.length===4,"color.mask must be length 4 array",c.commandStr),v.map(function(b){return!!b})},function(v,b,g){return m.optional(function(){v.assert(b,v.shared.isArrayLike+"("+g+")&&"+g+".length===4","invalid color.mask")}),Yt(4,function(F){return"!!"+g+"["+F+"]"})});case Zs:return E(function(v){m.command(typeof v=="object"&&v,w,c.commandStr);var b="value"in v?v.value:1,g=!!v.invert;return m.command(typeof b=="number"&&b>=0&&b<=1,"sample.coverage.value must be a number between 0 and 1",c.commandStr),[b,g]},function(v,b,g){m.optional(function(){v.assert(b,g+"&&typeof "+g+'==="object"',"invalid sample.coverage")});var F=b.def('"value" in ',g,"?+",g,".value:1"),L=b.def("!!",g,".invert");return[F,L]})}}),I}function tt(p,c){var T=p.static,C=p.dynamic,I={};return Object.keys(T).forEach(function(A){var w=T[A],E;if(typeof w=="number"||typeof w=="boolean")E=St(function(){return w});else if(typeof w=="function"){var v=w._reglType;v==="texture2d"||v==="textureCube"?E=St(function(b){return b.link(w)}):v==="framebuffer"||v==="framebufferCube"?(m.command(w.color.length>0,'missing color attachment for framebuffer sent to uniform "'+A+'"',c.commandStr),E=St(function(b){return b.link(w.color[0])})):m.commandRaise('invalid data for uniform "'+A+'"',c.commandStr)}else pt(w)?E=St(function(b){var g=b.global.def("[",Yt(w.length,function(F){return m.command(typeof w[F]=="number"||typeof w[F]=="boolean","invalid uniform "+A,b.commandStr),w[F]}),"]");return g}):m.commandRaise('invalid or missing data for uniform "'+A+'"',c.commandStr);E.value=w,I[A]=E}),Object.keys(C).forEach(function(A){var w=C[A];I[A]=Jt(w,function(E,v){return E.invoke(v,w)})}),I}function Et(p,c){var T=p.static,C=p.dynamic,I={};return Object.keys(T).forEach(function(A){var w=T[A],E=h.id(A),v=new k;if(pa(w))v.state=Qi,v.buffer=W.getBuffer(W.create(w,er,!1,!0)),v.type=0;else{var b=W.getBuffer(w);if(b)v.state=Qi,v.buffer=b,v.type=0;else if(m.command(typeof w=="object"&&w,"invalid data for attribute "+A,c.commandStr),"constant"in w){var g=w.constant;v.buffer="null",v.state=Gs,typeof g=="number"?v.x=g:(m.command(pt(g)&&g.length>0&&g.length<=4,"invalid constant for attribute "+A,c.commandStr),Zi.forEach(function(ke,be){be<g.length&&(v[ke]=g[be])}))}else{pa(w.buffer)?b=W.getBuffer(W.create(w.buffer,er,!1,!0)):b=W.getBuffer(w.buffer),m.command(!!b,'missing buffer for attribute "'+A+'"',c.commandStr);var F=w.offset|0;m.command(F>=0,'invalid offset for attribute "'+A+'"',c.commandStr);var L=w.stride|0;m.command(L>=0&&L<256,'invalid stride for attribute "'+A+'", must be integer betweeen [0, 255]',c.commandStr);var $=w.size|0;m.command(!("size"in w)||$>0&&$<=4,'invalid size for attribute "'+A+'", must be 1,2,3,4',c.commandStr);var j=!!w.normalized,le=0;"type"in w&&(m.commandParameter(w.type,mi,"invalid type for attribute "+A,c.commandStr),le=mi[w.type]);var Ge=w.divisor|0;m.optional(function(){"divisor"in w&&(m.command(Ge===0||te,'cannot specify divisor for attribute "'+A+'", instancing not supported',c.commandStr),m.command(Ge>=0,'invalid divisor for attribute "'+A+'"',c.commandStr));var ke=c.commandStr,be=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(w).forEach(function(Y){m.command(be.indexOf(Y)>=0,'unknown parameter "'+Y+'" for attribute pointer "'+A+'" (valid parameters are '+be+")",ke)})}),v.buffer=b,v.state=Qi,v.size=$,v.normalized=j,v.type=le||b.dtype,v.offset=F,v.stride=L,v.divisor=Ge}}I[A]=St(function(ke,be){var Y=ke.attribCache;if(E in Y)return Y[E];var U={isStream:!1};return Object.keys(v).forEach(function(Ce){U[Ce]=v[Ce]}),v.buffer&&(U.buffer=ke.link(v.buffer),U.type=U.type||U.buffer+".dtype"),Y[E]=U,U})}),Object.keys(C).forEach(function(A){var w=C[A];function E(v,b){var g=v.invoke(b,w),F=v.shared,L=v.constants,$=F.isBufferArgs,j=F.buffer;m.optional(function(){v.assert(b,g+"&&(typeof "+g+'==="object"||typeof '+g+'==="function")&&('+$+"("+g+")||"+j+".getBuffer("+g+")||"+j+".getBuffer("+g+".buffer)||"+$+"("+g+'.buffer)||("constant" in '+g+"&&(typeof "+g+'.constant==="number"||'+F.isArrayLike+"("+g+".constant))))",'invalid dynamic attribute "'+A+'"')});var le={isStream:b.def(!1)},Ge=new k;Ge.state=Qi,Object.keys(Ge).forEach(function(U){le[U]=b.def(""+Ge[U])});var ke=le.buffer,be=le.type;b("if(",$,"(",g,")){",le.isStream,"=true;",ke,"=",j,".createStream(",er,",",g,");",be,"=",ke,".dtype;","}else{",ke,"=",j,".getBuffer(",g,");","if(",ke,"){",be,"=",ke,".dtype;",'}else if("constant" in ',g,"){",le.state,"=",Gs,";","if(typeof "+g+'.constant === "number"){',le[Zi[0]],"=",g,".constant;",Zi.slice(1).map(function(U){return le[U]}).join("="),"=0;","}else{",Zi.map(function(U,Ce){return le[U]+"="+g+".constant.length>"+Ce+"?"+g+".constant["+Ce+"]:0;"}).join(""),"}}else{","if(",$,"(",g,".buffer)){",ke,"=",j,".createStream(",er,",",g,".buffer);","}else{",ke,"=",j,".getBuffer(",g,".buffer);","}",be,'="type" in ',g,"?",L.glTypes,"[",g,".type]:",ke,".dtype;",le.normalized,"=!!",g,".normalized;");function Y(U){b(le[U],"=",g,".",U,"|0;")}return Y("size"),Y("offset"),Y("stride"),Y("divisor"),b("}}"),b.exit("if(",le.isStream,"){",j,".destroyStream(",ke,");","}"),le}I[A]=Jt(w,E)}),I}function ht(p){var c=p.static,T=p.dynamic,C={};return Object.keys(c).forEach(function(I){var A=c[I];C[I]=St(function(w,E){return typeof A=="number"||typeof A=="boolean"?""+A:w.link(A)})}),Object.keys(T).forEach(function(I){var A=T[I];C[I]=Jt(A,function(w,E){return w.invoke(E,A)})}),C}function Tt(p,c,T,C,I){var A=p.static,w=p.dynamic;m.optional(function(){var Y=[xi,Lr,Dr,bi,_i,ra,Si,oa,Ir,Fr].concat(Le);function U(Ce){Object.keys(Ce).forEach(function(Ae){m.command(Y.indexOf(Ae)>=0,'unknown parameter "'+Ae+'"',I.commandStr)})}U(A),U(w)});var E=We(p,c),v=ye(p),b=Re(p,v,I),g=vt(p,I),F=yt(p,I),L=Je(p,I,E);function $(Y){var U=b[Y];U&&(F[Y]=U)}$(Bn),$(Se(ia));var j=Object.keys(F).length>0,le={framebuffer:v,draw:g,shader:L,state:F,dirty:j,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(le.profile=pe(p),le.uniforms=tt(T,I),le.drawVAO=le.scopeVAO=g.vao,!le.drawVAO&&L.program&&!E&&_.angle_instanced_arrays&&g.static.elements){var Ge=!0,ke=L.program.attributes.map(function(Y){var U=c.static[Y];return Ge=Ge&&!!U,U});if(Ge&&ke.length>0){var be=ie.getVAO(ie.createVAO({attributes:ke,elements:g.static.elements}));le.drawVAO=new Dt(null,null,null,function(Y,U){return Y.link(be)}),le.useVAO=!0}}return E?le.useVAO=!0:le.attributes=Et(c,I),le.context=ht(C),le}function Ct(p,c,T){var C=p.shared,I=C.context,A=p.scope();Object.keys(T).forEach(function(w){c.save(I,"."+w);var E=T[w],v=E.append(p,c);Array.isArray(v)?A(I,".",w,"=[",v.join(),"];"):A(I,".",w,"=",v,";")}),c(A)}function Pt(p,c,T,C){var I=p.shared,A=I.gl,w=I.framebuffer,E;xe&&(E=c.def(I.extensions,".webgl_draw_buffers"));var v=p.constants,b=v.drawBuffer,g=v.backBuffer,F;T?F=T.append(p,c):F=c.def(w,".next"),C||c("if(",F,"!==",w,".cur){"),c("if(",F,"){",A,".bindFramebuffer(",Oc,",",F,".framebuffer);"),xe&&c(E,".drawBuffersWEBGL(",b,"[",F,".colorAttachments.length]);"),c("}else{",A,".bindFramebuffer(",Oc,",null);"),xe&&c(E,".drawBuffersWEBGL(",g,");"),c("}",w,".cur=",F,";"),C||c("}")}function zt(p,c,T){var C=p.shared,I=C.gl,A=p.current,w=p.next,E=C.current,v=C.next,b=p.cond(E,".dirty");Le.forEach(function(g){var F=Se(g);if(!(F in T.state)){var L,$;if(F in w){L=w[F],$=A[F];var j=Yt(ge[F].length,function(Ge){return b.def(L,"[",Ge,"]")});b(p.cond(j.map(function(Ge,ke){return Ge+"!=="+$+"["+ke+"]"}).join("||")).then(I,".",H[F],"(",j,");",j.map(function(Ge,ke){return $+"["+ke+"]="+Ge}).join(";"),";"))}else{L=b.def(v,".",F);var le=p.cond(L,"!==",E,".",F);b(le),F in X?le(p.cond(L).then(I,".enable(",X[F],");").else(I,".disable(",X[F],");"),E,".",F,"=",L,";"):le(I,".",H[F],"(",L,");",E,".",F,"=",L,";")}}}),Object.keys(T.state).length===0&&b(E,".dirty=false;"),c(b)}function Bt(p,c,T,C){var I=p.shared,A=p.current,w=I.current,E=I.gl;Bc(Object.keys(T)).forEach(function(v){var b=T[v];if(!(C&&!C(b))){var g=b.append(p,c);if(X[v]){var F=X[v];Jn(b)?g?c(E,".enable(",F,");"):c(E,".disable(",F,");"):c(p.cond(g).then(E,".enable(",F,");").else(E,".disable(",F,");")),c(w,".",v,"=",g,";")}else if(pt(g)){var L=A[v];c(E,".",H[v],"(",g,");",g.map(function($,j){return L+"["+j+"]="+$}).join(";"),";")}else c(E,".",H[v],"(",g,");",w,".",v,"=",g,";")}})}function xt(p,c){te&&(p.instancing=c.def(p.shared.extensions,".angle_instanced_arrays"))}function Ye(p,c,T,C,I){var A=p.shared,w=p.stats,E=A.current,v=A.timer,b=T.profile;function g(){return typeof performance>"u"?"Date.now()":"performance.now()"}var F,L;function $(Y){F=c.def(),Y(F,"=",g(),";"),typeof I=="string"?Y(w,".count+=",I,";"):Y(w,".count++;"),J&&(C?(L=c.def(),Y(L,"=",v,".getNumPendingQueries();")):Y(v,".beginQuery(",w,");"))}function j(Y){Y(w,".cpuTime+=",g(),"-",F,";"),J&&(C?Y(v,".pushScopeStats(",L,",",v,".getNumPendingQueries(),",w,");"):Y(v,".endQuery();"))}function le(Y){var U=c.def(E,".profile");c(E,".profile=",Y,";"),c.exit(E,".profile=",U,";")}var Ge;if(b){if(Jn(b)){b.enable?($(c),j(c.exit),le("true")):le("false");return}Ge=b.append(p,c),le(Ge)}else Ge=c.def(E,".profile");var ke=p.block();$(ke),c("if(",Ge,"){",ke,"}");var be=p.block();j(be),c.exit("if(",Ge,"){",be,"}")}function Ut(p,c,T,C,I){var A=p.shared;function w(v){switch(v){case aa:case la:case ha:return 2;case sa:case ua:case da:return 3;case fa:case ca:case ma:return 4;default:return 1}}function E(v,b,g){var F=A.gl,L=c.def(v,".location"),$=c.def(A.attributes,"[",L,"]"),j=g.state,le=g.buffer,Ge=[g.x,g.y,g.z,g.w],ke=["buffer","normalized","offset","stride"];function be(){c("if(!",$,".buffer){",F,".enableVertexAttribArray(",L,");}");var U=g.type,Ce;if(g.size?Ce=c.def(g.size,"||",b):Ce=b,c("if(",$,".type!==",U,"||",$,".size!==",Ce,"||",ke.map(function(Me){return $+"."+Me+"!=="+g[Me]}).join("||"),"){",F,".bindBuffer(",er,",",le,".buffer);",F,".vertexAttribPointer(",[L,Ce,U,g.normalized,g.stride,g.offset],");",$,".type=",U,";",$,".size=",Ce,";",ke.map(function(Me){return $+"."+Me+"="+g[Me]+";"}).join(""),"}"),te){var Ae=g.divisor;c("if(",$,".divisor!==",Ae,"){",p.instancing,".vertexAttribDivisorANGLE(",[L,Ae],");",$,".divisor=",Ae,";}")}}function Y(){c("if(",$,".buffer){",F,".disableVertexAttribArray(",L,");",$,".buffer=null;","}if(",Zi.map(function(U,Ce){return $+"."+U+"!=="+Ge[Ce]}).join("||"),"){",F,".vertexAttrib4f(",L,",",Ge,");",Zi.map(function(U,Ce){return $+"."+U+"="+Ge[Ce]+";"}).join(""),"}")}j===Qi?be():j===Gs?Y():(c("if(",j,"===",Qi,"){"),be(),c("}else{"),Y(),c("}"))}C.forEach(function(v){var b=v.name,g=T.attributes[b],F;if(g){if(!I(g))return;F=g.append(p,c)}else{if(!I(Uc))return;var L=p.scopeAttrib(b);m.optional(function(){p.assert(c,L+".state","missing attribute "+b)}),F={},Object.keys(new k).forEach(function($){F[$]=c.def(L,".",$)})}E(p.link(v),w(v.info.type),F)})}function ot(p,c,T,C,I,A){for(var w=p.shared,E=w.gl,v={},b,g=0;g<C.length;++g){var F=C[g],L=F.name,$=F.info.type,j=F.info.size,le=T.uniforms[L];if(j>1){if(!le)continue;var Ge=L.replace("[0]","");if(v[Ge])continue;v[Ge]=1}var ke=p.link(F),be=ke+".location",Y;if(le){if(!I(le))continue;if(Jn(le)){var U=le.value;if(m.command(U!==null&&typeof U<"u",'missing uniform "'+L+'"',p.commandStr),$===Or||$===Nr){m.command(typeof U=="function"&&($===Or&&(U._reglType==="texture2d"||U._reglType==="framebuffer")||$===Nr&&(U._reglType==="textureCube"||U._reglType==="framebufferCube")),"invalid texture for uniform "+L,p.commandStr);var Ce=p.link(U._texture||U.color[0]._texture);c(E,".uniform1i(",be,",",Ce+".bind());"),c.exit(Ce,".unbind();")}else if($===zr||$===Rr||$===Mr){m.optional(function(){m.command(pt(U),"invalid matrix for uniform "+L,p.commandStr),m.command($===zr&&U.length===4||$===Rr&&U.length===9||$===Mr&&U.length===16,"invalid length for matrix uniform "+L,p.commandStr)});var Ae=p.global.def("new Float32Array(["+Array.prototype.slice.call(U)+"])"),Me=2;$===Rr?Me=3:$===Mr&&(Me=4),c(E,".uniformMatrix",Me,"fv(",be,",false,",Ae,");")}else{switch($){case nf:j===1?m.commandType(U,"number","uniform "+L,p.commandStr):m.command(pt(U)&&U.length===j,"uniform "+L,p.commandStr),b="1f";break;case aa:m.command(pt(U)&&U.length&&U.length%2===0&&U.length<=j*2,"uniform "+L,p.commandStr),b="2f";break;case sa:m.command(pt(U)&&U.length&&U.length%3===0&&U.length<=j*3,"uniform "+L,p.commandStr),b="3f";break;case fa:m.command(pt(U)&&U.length&&U.length%4===0&&U.length<=j*4,"uniform "+L,p.commandStr),b="4f";break;case of:j===1?m.commandType(U,"boolean","uniform "+L,p.commandStr):m.command(pt(U)&&U.length===j,"uniform "+L,p.commandStr),b="1i";break;case rf:j===1?m.commandType(U,"number","uniform "+L,p.commandStr):m.command(pt(U)&&U.length===j,"uniform "+L,p.commandStr),b="1i";break;case ha:m.command(pt(U)&&U.length&&U.length%2===0&&U.length<=j*2,"uniform "+L,p.commandStr),b="2i";break;case la:m.command(pt(U)&&U.length&&U.length%2===0&&U.length<=j*2,"uniform "+L,p.commandStr),b="2i";break;case da:m.command(pt(U)&&U.length&&U.length%3===0&&U.length<=j*3,"uniform "+L,p.commandStr),b="3i";break;case ua:m.command(pt(U)&&U.length&&U.length%3===0&&U.length<=j*3,"uniform "+L,p.commandStr),b="3i";break;case ma:m.command(pt(U)&&U.length&&U.length%4===0&&U.length<=j*4,"uniform "+L,p.commandStr),b="4i";break;case ca:m.command(pt(U)&&U.length&&U.length%4===0&&U.length<=j*4,"uniform "+L,p.commandStr),b="4i";break}j>1?(b+="v",U=p.global.def("["+Array.prototype.slice.call(U)+"]")):U=pt(U)?Array.prototype.slice.call(U):U,c(E,".uniform",b,"(",be,",",U,");")}continue}else Y=le.append(p,c)}else{if(!I(Uc))continue;Y=c.def(w.uniforms,"[",h.id(L),"]")}$===Or?(m(!Array.isArray(Y),"must specify a scalar prop for textures"),c("if(",Y,"&&",Y,'._reglType==="framebuffer"){',Y,"=",Y,".color[0];","}")):$===Nr&&(m(!Array.isArray(Y),"must specify a scalar prop for cube maps"),c("if(",Y,"&&",Y,'._reglType==="framebufferCube"){',Y,"=",Y,".color[0];","}")),m.optional(function(){function on(en,va){p.assert(c,en,'bad data or missing for uniform "'+L+'". '+va)}function Ci(en,va){va===1&&m(!Array.isArray(Y),"must not specify an array type for uniform"),on("Array.isArray("+Y+") && typeof "+Y+'[0]===" '+en+'" || typeof '+Y+'==="'+en+'"',"invalid type, expected "+en)}function un(en,va,ga){Array.isArray(Y)?m(Y.length&&Y.length%en===0&&Y.length<=en*ga,"must have length of "+(ga===1?"":"n * ")+en):on(w.isArrayLike+"("+Y+")&&"+Y+".length && "+Y+".length % "+en+" === 0 && "+Y+".length<="+en*ga,"invalid vector, should have length of "+(ga===1?"":"n * ")+en,p.commandStr)}function qc(en){m(!Array.isArray(Y),"must not specify a value type"),on("typeof "+Y+'==="function"&&'+Y+'._reglType==="texture'+(en===Dc?"2d":"Cube")+'"',"invalid texture type",p.commandStr)}switch($){case rf:Ci("number",j);break;case la:un(2,"number",j);break;case ua:un(3,"number",j);break;case ca:un(4,"number",j);break;case nf:Ci("number",j);break;case aa:un(2,"number",j);break;case sa:un(3,"number",j);break;case fa:un(4,"number",j);break;case of:Ci("boolean",j);break;case ha:un(2,"boolean",j);break;case da:un(3,"boolean",j);break;case ma:un(4,"boolean",j);break;case zr:un(4,"number",j);break;case Rr:un(9,"number",j);break;case Mr:un(16,"number",j);break;case Or:qc(Dc);break;case Nr:qc(Dx);break}});var st=1;switch($){case Or:case Nr:var Vt=c.def(Y,"._texture");c(E,".uniform1i(",be,",",Vt,".bind());"),c.exit(Vt,".unbind();");continue;case rf:case of:b="1i";break;case la:case ha:b="2i",st=2;break;case ua:case da:b="3i",st=3;break;case ca:case ma:b="4i",st=4;break;case nf:b="1f";break;case aa:b="2f",st=2;break;case sa:b="3f",st=3;break;case fa:b="4f",st=4;break;case zr:b="Matrix2fv";break;case Rr:b="Matrix3fv";break;case Mr:b="Matrix4fv";break}if(b.indexOf("Matrix")===-1&&j>1&&(b+="v",st=1),b.charAt(0)==="M"){c(E,".uniform",b,"(",be,",");var Ai=Math.pow($-zr+2,2),Un=p.global.def("new Float32Array(",Ai,")");Array.isArray(Y)?c("false,(",Yt(Ai,function(on){return Un+"["+on+"]="+Y[on]}),",",Un,")"):c("false,(Array.isArray(",Y,")||",Y," instanceof Float32Array)?",Y,":(",Yt(Ai,function(on){return Un+"["+on+"]="+Y+"["+on+"]"}),",",Un,")"),c(");")}else if(st>1){for(var Pn=[],ei=[],Ei=0;Ei<st;++Ei)Array.isArray(Y)?ei.push(Y[Ei]):ei.push(c.def(Y+"["+Ei+"]")),A&&Pn.push(c.def());A&&c("if(!",p.batchId,"||",Pn.map(function(on,Ci){return on+"!=="+ei[Ci]}).join("||"),"){",Pn.map(function(on,Ci){return on+"="+ei[Ci]+";"}).join("")),c(E,".uniform",b,"(",be,",",ei.join(","),");"),A&&c("}")}else{if(m(!Array.isArray(Y),"uniform value must not be an array"),A){var jc=c.def();c("if(!",p.batchId,"||",jc,"!==",Y,"){",jc,"=",Y,";")}c(E,".uniform",b,"(",be,",",Y,");"),A&&c("}")}}}function Fe(p,c,T,C){var I=p.shared,A=I.gl,w=I.draw,E=C.draw;function v(){var Ce=E.elements,Ae,Me=c;return Ce?((Ce.contextDep&&C.contextDynamic||Ce.propDep)&&(Me=T),Ae=Ce.append(p,Me),E.elementsActive&&Me("if("+Ae+")"+A+".bindBuffer("+tf+","+Ae+".buffer.buffer);")):(Ae=Me.def(),Me(Ae,"=",w,".",bi,";","if(",Ae,"){",A,".bindBuffer(",tf,",",Ae,".buffer.buffer);}","else if(",I.vao,".currentVAO){",Ae,"=",p.shared.elements+".getElements("+I.vao,".currentVAO.elements);",Z?"":"if("+Ae+")"+A+".bindBuffer("+tf+","+Ae+".buffer.buffer);","}")),Ae}function b(){var Ce=E.count,Ae,Me=c;return Ce?((Ce.contextDep&&C.contextDynamic||Ce.propDep)&&(Me=T),Ae=Ce.append(p,Me),m.optional(function(){Ce.MISSING&&p.assert(c,"false","missing vertex count"),Ce.DYNAMIC&&p.assert(Me,Ae+">=0","missing vertex count")})):(Ae=Me.def(w,".",Si),m.optional(function(){p.assert(Me,Ae+">=0","missing vertex count")})),Ae}var g=v();function F(Ce){var Ae=E[Ce];return Ae?Ae.contextDep&&C.contextDynamic||Ae.propDep?Ae.append(p,T):Ae.append(p,c):c.def(w,".",Ce)}var L=F(_i),$=F(ra),j=b();if(typeof j=="number"){if(j===0)return}else T("if(",j,"){"),T.exit("}");var le,Ge;te&&(le=F(oa),Ge=p.instancing);var ke=g+".type",be=E.elements&&Jn(E.elements)&&!E.vaoActive;function Y(){function Ce(){T(Ge,".drawElementsInstancedANGLE(",[L,j,ke,$+"<<(("+ke+"-"+cc+")>>1)",le],");")}function Ae(){T(Ge,".drawArraysInstancedANGLE(",[L,$,j,le],");")}g&&g!=="null"?be?Ce():(T("if(",g,"){"),Ce(),T("}else{"),Ae(),T("}")):Ae()}function U(){function Ce(){T(A+".drawElements("+[L,j,ke,$+"<<(("+ke+"-"+cc+")>>1)"]+");")}function Ae(){T(A+".drawArrays("+[L,$,j]+");")}g&&g!=="null"?be?Ce():(T("if(",g,"){"),Ce(),T("}else{"),Ae(),T("}")):Ae()}te&&(typeof le!="number"||le>=0)?typeof le=="string"?(T("if(",le,">0){"),Y(),T("}else if(",le,"<0){"),U(),T("}")):Y():U()}function et(p,c,T,C,I){var A=Ue(),w=A.proc("body",I);return m.optional(function(){A.commandStr=c.commandStr,A.command=A.link(c.commandStr)}),te&&(A.instancing=w.def(A.shared.extensions,".angle_instanced_arrays")),p(A,w,T,C),A.compile().body}function it(p,c,T,C){xt(p,c),T.useVAO?T.drawVAO?c(p.shared.vao,".setVAO(",T.drawVAO.append(p,c),");"):c(p.shared.vao,".setVAO(",p.shared.vao,".targetVAO);"):(c(p.shared.vao,".setVAO(null);"),Ut(p,c,T,C.attributes,function(){return!0})),ot(p,c,T,C.uniforms,function(){return!0},!1),Fe(p,c,c,T)}function bt(p,c){var T=p.proc("draw",1);xt(p,T),Ct(p,T,c.context),Pt(p,T,c.framebuffer),zt(p,T,c),Bt(p,T,c.state),Ye(p,T,c,!1,!0);var C=c.shader.progVar.append(p,T);if(T(p.shared.gl,".useProgram(",C,".program);"),c.shader.program)it(p,T,c,c.shader.program);else{T(p.shared.vao,".setVAO(null);");var I=p.global.def("{}"),A=T.def(C,".id"),w=T.def(I,"[",A,"]");T(p.cond(w).then(w,".call(this,a0);").else(w,"=",I,"[",A,"]=",p.link(function(E){return et(it,p,c,E,1)}),"(",C,");",w,".call(this,a0);"))}Object.keys(c.state).length>0&&T(p.shared.current,".dirty=true;"),p.shared.vao&&T(p.shared.vao,".setVAO(null);")}function Cn(p,c,T,C){p.batchId="a1",xt(p,c);function I(){return!0}Ut(p,c,T,C.attributes,I),ot(p,c,T,C.uniforms,I,!1),Fe(p,c,c,T)}function wi(p,c,T,C){xt(p,c);var I=T.contextDep,A=c.def(),w="a0",E="a1",v=c.def();p.shared.props=v,p.batchId=A;var b=p.scope(),g=p.scope();c(b.entry,"for(",A,"=0;",A,"<",E,";++",A,"){",v,"=",w,"[",A,"];",g,"}",b.exit);function F(ke){return ke.contextDep&&I||ke.propDep}function L(ke){return!F(ke)}if(T.needsContext&&Ct(p,g,T.context),T.needsFramebuffer&&Pt(p,g,T.framebuffer),Bt(p,g,T.state,F),T.profile&&F(T.profile)&&Ye(p,g,T,!1,!0),C)T.useVAO?T.drawVAO?F(T.drawVAO)?g(p.shared.vao,".setVAO(",T.drawVAO.append(p,g),");"):b(p.shared.vao,".setVAO(",T.drawVAO.append(p,b),");"):b(p.shared.vao,".setVAO(",p.shared.vao,".targetVAO);"):(b(p.shared.vao,".setVAO(null);"),Ut(p,b,T,C.attributes,L),Ut(p,g,T,C.attributes,F)),ot(p,b,T,C.uniforms,L,!1),ot(p,g,T,C.uniforms,F,!0),Fe(p,b,g,T);else{var $=p.global.def("{}"),j=T.shader.progVar.append(p,g),le=g.def(j,".id"),Ge=g.def($,"[",le,"]");g(p.shared.gl,".useProgram(",j,".program);","if(!",Ge,"){",Ge,"=",$,"[",le,"]=",p.link(function(ke){return et(Cn,p,T,ke,2)}),"(",j,");}",Ge,".call(this,a0[",A,"],",A,");")}}function x(p,c){var T=p.proc("batch",2);p.batchId="0",xt(p,T);var C=!1,I=!0;Object.keys(c.context).forEach(function($){C=C||c.context[$].propDep}),C||(Ct(p,T,c.context),I=!1);var A=c.framebuffer,w=!1;A?(A.propDep?C=w=!0:A.contextDep&&C&&(w=!0),w||Pt(p,T,A)):Pt(p,T,null),c.state.viewport&&c.state.viewport.propDep&&(C=!0);function E($){return $.contextDep&&C||$.propDep}zt(p,T,c),Bt(p,T,c.state,function($){return!E($)}),(!c.profile||!E(c.profile))&&Ye(p,T,c,!1,"a1"),c.contextDep=C,c.needsContext=I,c.needsFramebuffer=w;var v=c.shader.progVar;if(v.contextDep&&C||v.propDep)wi(p,T,c,null);else{var b=v.append(p,T);if(T(p.shared.gl,".useProgram(",b,".program);"),c.shader.program)wi(p,T,c,c.shader.program);else{T(p.shared.vao,".setVAO(null);");var g=p.global.def("{}"),F=T.def(b,".id"),L=T.def(g,"[",F,"]");T(p.cond(L).then(L,".call(this,a0,a1);").else(L,"=",g,"[",F,"]=",p.link(function($){return et(wi,p,c,$,2)}),"(",b,");",L,".call(this,a0,a1);"))}}Object.keys(c.state).length>0&&T(p.shared.current,".dirty=true;"),p.shared.vao&&T(p.shared.vao,".setVAO(null);")}function O(p,c){var T=p.proc("scope",3);p.batchId="a2";var C=p.shared,I=C.current;Ct(p,T,c.context),c.framebuffer&&c.framebuffer.append(p,T),Bc(Object.keys(c.state)).forEach(function(w){var E=c.state[w],v=E.append(p,T);pt(v)?v.forEach(function(b,g){T.set(p.next[w],"["+g+"]",b)}):T.set(C.next,"."+w,v)}),Ye(p,T,c,!0,!0),[bi,ra,Si,oa,_i].forEach(function(w){var E=c.draw[w];E&&T.set(C.draw,"."+w,""+E.append(p,T))}),Object.keys(c.uniforms).forEach(function(w){var E=c.uniforms[w].append(p,T);Array.isArray(E)&&(E="["+E.join()+"]"),T.set(C.uniforms,"["+h.id(w)+"]",E)}),Object.keys(c.attributes).forEach(function(w){var E=c.attributes[w].append(p,T),v=p.scopeAttrib(w);Object.keys(new k).forEach(function(b){T.set(v,"."+b,E[b])})}),c.scopeVAO&&T.set(C.vao,".targetVAO",c.scopeVAO.append(p,T));function A(w){var E=c.shader[w];E&&T.set(C.shader,"."+w,E.append(p,T))}A(Lr),A(Dr),Object.keys(c.state).length>0&&(T(I,".dirty=true;"),T.exit(I,".dirty=true;")),T("a1(",p.shared.context,",a0,",p.batchId,");")}function z(p){if(!(typeof p!="object"||pt(p))){for(var c=Object.keys(p),T=0;T<c.length;++T)if(It.isDynamic(p[c[T]]))return!0;return!1}}function _e(p,c,T){var C=c.static[T];if(!C||!z(C))return;var I=p.global,A=Object.keys(C),w=!1,E=!1,v=!1,b=p.global.def("{}");A.forEach(function(F){var L=C[F];if(It.isDynamic(L)){typeof L=="function"&&(L=C[F]=It.unbox(L));var $=Jt(L,null);w=w||$.thisDep,v=v||$.propDep,E=E||$.contextDep}else{switch(I(b,".",F,"="),typeof L){case"number":I(L);break;case"string":I('"',L,'"');break;case"object":Array.isArray(L)&&I("[",L.join(),"]");break;default:I(p.link(L));break}I(";")}});function g(F,L){A.forEach(function($){var j=C[$];if(It.isDynamic(j)){var le=F.invoke(L,j);L(b,".",$,"=",le,";")}})}c.dynamic[T]=new It.DynamicVariable(na,{thisDep:w,contextDep:E,propDep:v,ref:b,append:g}),delete c.static[T]}function Ke(p,c,T,C,I){var A=Ue();A.stats=A.link(I),Object.keys(c.static).forEach(function(E){_e(A,c,E)}),kx.forEach(function(E){_e(A,p,E)});var w=Tt(p,c,T,C,A);return bt(A,w),O(A,w),x(A,w),i(A.compile(),{destroy:function(){w.shader.program.destroy()}})}return{next:me,current:ge,procs:function(){var p=Ue(),c=p.proc("poll"),T=p.proc("refresh"),C=p.block();c(C),T(C);var I=p.shared,A=I.gl,w=I.next,E=I.current;C(E,".dirty=false;"),Pt(p,c),Pt(p,T,null,!0);var v;te&&(v=p.link(te)),_.oes_vertex_array_object&&T(p.link(_.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var b=0;b<M.maxAttributes;++b){var g=T.def(I.attributes,"[",b,"]"),F=p.cond(g,".buffer");F.then(A,".enableVertexAttribArray(",b,");",A,".bindBuffer(",er,",",g,".buffer.buffer);",A,".vertexAttribPointer(",b,",",g,".size,",g,".type,",g,".normalized,",g,".stride,",g,".offset);").else(A,".disableVertexAttribArray(",b,");",A,".vertexAttrib4f(",b,",",g,".x,",g,".y,",g,".z,",g,".w);",g,".buffer=null;"),T(F),te&&T(v,".vertexAttribDivisorANGLE(",b,",",g,".divisor);")}return T(p.shared.vao,".currentVAO=null;",p.shared.vao,".setVAO(",p.shared.vao,".targetVAO);"),Object.keys(X).forEach(function(L){var $=X[L],j=C.def(w,".",L),le=p.block();le("if(",j,"){",A,".enable(",$,")}else{",A,".disable(",$,")}",E,".",L,"=",j,";"),T(le),c("if(",j,"!==",E,".",L,"){",le,"}")}),Object.keys(H).forEach(function(L){var $=H[L],j=ge[L],le,Ge,ke=p.block();if(ke(A,".",$,"("),pt(j)){var be=j.length;le=p.global.def(w,".",L),Ge=p.global.def(E,".",L),ke(Yt(be,function(Y){return le+"["+Y+"]"}),");",Yt(be,function(Y){return Ge+"["+Y+"]="+le+"["+Y+"];"}).join("")),c("if(",Yt(be,function(Y){return le+"["+Y+"]!=="+Ge+"["+Y+"]"}).join("||"),"){",ke,"}")}else le=C.def(w,".",L),Ge=C.def(E,".",L),ke(le,");",E,".",L,"=",le,";"),c("if(",le,"!==",Ge,"){",ke,"}");T(ke)}),p.compile()}(),compile:Ke}}function qx(){return{vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}var Yx=34918,Zx=34919,Vc=35007,Qx=function(a,h){if(!h.ext_disjoint_timer_query)return null;var _=[];function M(){return _.pop()||h.ext_disjoint_timer_query.createQueryEXT()}function W(te){_.push(te)}var R=[];function B(te){var xe=M();h.ext_disjoint_timer_query.beginQueryEXT(Vc,xe),R.push(xe),J(R.length-1,R.length,te)}function K(){h.ext_disjoint_timer_query.endQueryEXT(Vc)}function Q(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var ie=[];function oe(){return ie.pop()||new Q}function re(te){ie.push(te)}var ue=[];function J(te,xe,Z){var ge=oe();ge.startQueryIndex=te,ge.endQueryIndex=xe,ge.sum=0,ge.stats=Z,ue.push(ge)}var ne=[],k=[];function N(){var te,xe,Z=R.length;if(Z!==0){k.length=Math.max(k.length,Z+1),ne.length=Math.max(ne.length,Z+1),ne[0]=0,k[0]=0;var ge=0;for(te=0,xe=0;xe<R.length;++xe){var me=R[xe];h.ext_disjoint_timer_query.getQueryObjectEXT(me,Zx)?(ge+=h.ext_disjoint_timer_query.getQueryObjectEXT(me,Yx),W(me)):R[te++]=me,ne[xe+1]=ge,k[xe+1]=te}for(R.length=te,te=0,xe=0;xe<ue.length;++xe){var Le=ue[xe],X=Le.startQueryIndex,H=Le.endQueryIndex;Le.sum+=ne[H]-ne[X];var Se=k[X],ce=k[H];ce===Se?(Le.stats.gpuTime+=Le.sum/1e6,re(Le)):(Le.startQueryIndex=Se,Le.endQueryIndex=ce,ue[te++]=Le)}ue.length=te}}return{beginQuery:B,endQuery:K,pushScopeStats:J,update:N,getNumPendingQueries:function(){return R.length},clear:function(){_.push.apply(_,R);for(var te=0;te<_.length;te++)h.ext_disjoint_timer_query.deleteQueryEXT(_[te]);R.length=0,_.length=0},restore:function(){R.length=0,_.length=0}}},Kx=16384,Jx=256,eb=1024,tb=34962,$c="webglcontextlost",Hc="webglcontextrestored",Wc=1,nb=2,ib=3;function Xc(a,h){for(var _=0;_<a.length;++_)if(a[_]===h)return _;return-1}function rb(a){var h=Lt(a);if(!h)return null;var _=h.gl,M=_.getContextAttributes(),W=_.isContextLost(),R=Xn(_,h);if(!R)return null;var B=fs(),K=qx(),Q=R.extensions,ie=Qx(_,Q),oe=Oi(),re=_.drawingBufferWidth,ue=_.drawingBufferHeight,J={tick:0,time:0,viewportWidth:re,viewportHeight:ue,framebufferWidth:re,framebufferHeight:ue,drawingBufferWidth:re,drawingBufferHeight:ue,pixelRatio:h.pixelRatio},ne={},k={elements:null,primitive:4,count:-1,offset:0,instances:-1},N=Hg(_,Q),te=ay(_,K,h,ge),xe=yy(_,Q,te,K),Z=yx(_,Q,N,K,te,xe,k);function ge(Fe){return Z.destroyBuffer(Fe)}var me=Sx(_,B,K,h),Le=Yy(_,Q,N,function(){Se.procs.poll()},J,K,h),X=Zy(_,Q,N,K,h),H=vx(_,Q,N,Le,X,K),Se=jx(_,B,Q,N,te,xe,Le,H,ne,Z,me,k,J,ie,h),ce=Ax(_,H,Se.procs.poll,J,M,Q,N),ee=Se.next,he=_.canvas,de=[],He=[],Ue=[],pe=[h.onDestroy],ye=null;function Re(){if(de.length===0){ie&&ie.update(),ye=null;return}ye=ci.next(Re),Bt();for(var Fe=de.length-1;Fe>=0;--Fe){var et=de[Fe];et&&et(J,null,0)}_.flush(),ie&&ie.update()}function We(){!ye&&de.length>0&&(ye=ci.next(Re))}function Je(){ye&&(ci.cancel(Re),ye=null)}function vt(Fe){Fe.preventDefault(),W=!0,Je(),He.forEach(function(et){et()})}function yt(Fe){_.getError(),W=!1,R.restore(),me.restore(),te.restore(),Le.restore(),X.restore(),H.restore(),Z.restore(),ie&&ie.restore(),Se.procs.refresh(),We(),Ue.forEach(function(et){et()})}he&&(he.addEventListener($c,vt,!1),he.addEventListener(Hc,yt,!1));function tt(){de.length=0,Je(),he&&(he.removeEventListener($c,vt),he.removeEventListener(Hc,yt)),me.clear(),H.clear(),X.clear(),Z.clear(),Le.clear(),xe.clear(),te.clear(),ie&&ie.clear(),pe.forEach(function(Fe){Fe()})}function Et(Fe){m(!!Fe,"invalid args to regl({...})"),m.type(Fe,"object","invalid args to regl({...})");function et(I){var A=i({},I);delete A.uniforms,delete A.attributes,delete A.context,delete A.vao,"stencil"in A&&A.stencil.op&&(A.stencil.opBack=A.stencil.opFront=A.stencil.op,delete A.stencil.op);function w(E){if(E in A){var v=A[E];delete A[E],Object.keys(v).forEach(function(b){A[E+"."+b]=v[b]})}}return w("blend"),w("depth"),w("cull"),w("stencil"),w("polygonOffset"),w("scissor"),w("sample"),"vao"in I&&(A.vao=I.vao),A}function it(I,A){var w={},E={};return Object.keys(I).forEach(function(v){var b=I[v];if(It.isDynamic(b)){E[v]=It.unbox(b,v);return}else if(A&&Array.isArray(b)){for(var g=0;g<b.length;++g)if(It.isDynamic(b[g])){E[v]=It.unbox(b,v);return}}w[v]=b}),{dynamic:E,static:w}}var bt=it(Fe.context||{},!0),Cn=it(Fe.uniforms||{},!0),wi=it(Fe.attributes||{},!1),x=it(et(Fe),!1),O={gpuTime:0,cpuTime:0,count:0},z=Se.compile(x,wi,Cn,bt,O),_e=z.draw,Ke=z.batch,p=z.scope,c=[];function T(I){for(;c.length<I;)c.push(null);return c}function C(I,A){var w;if(W&&m.raise("context lost"),typeof I=="function")return p.call(this,null,I,0);if(typeof A=="function")if(typeof I=="number")for(w=0;w<I;++w)p.call(this,null,A,w);else if(Array.isArray(I))for(w=0;w<I.length;++w)p.call(this,I[w],A,w);else return p.call(this,I,A,0);else if(typeof I=="number"){if(I>0)return Ke.call(this,T(I|0),I|0)}else if(Array.isArray(I)){if(I.length)return Ke.call(this,I,I.length)}else return _e.call(this,I)}return i(C,{stats:O,destroy:function(){z.destroy()}})}var ht=H.setFBO=Et({framebuffer:It.define.call(null,Wc,"framebuffer")});function Tt(Fe,et){var it=0;Se.procs.poll();var bt=et.color;bt&&(_.clearColor(+bt[0]||0,+bt[1]||0,+bt[2]||0,+bt[3]||0),it|=Kx),"depth"in et&&(_.clearDepth(+et.depth),it|=Jx),"stencil"in et&&(_.clearStencil(et.stencil|0),it|=eb),m(!!it,"called regl.clear with no buffer specified"),_.clear(it)}function Ct(Fe){if(m(typeof Fe=="object"&&Fe,"regl.clear() takes an object as input"),"framebuffer"in Fe)if(Fe.framebuffer&&Fe.framebuffer_reglType==="framebufferCube")for(var et=0;et<6;++et)ht(i({framebuffer:Fe.framebuffer.faces[et]},Fe),Tt);else ht(Fe,Tt);else Tt(null,Fe)}function Pt(Fe){m.type(Fe,"function","regl.frame() callback must be a function"),de.push(Fe);function et(){var it=Xc(de,Fe);m(it>=0,"cannot cancel a frame twice");function bt(){var Cn=Xc(de,bt);de[Cn]=de[de.length-1],de.length-=1,de.length<=0&&Je()}de[it]=bt}return We(),{cancel:et}}function zt(){var Fe=ee.viewport,et=ee.scissor_box;Fe[0]=Fe[1]=et[0]=et[1]=0,J.viewportWidth=J.framebufferWidth=J.drawingBufferWidth=Fe[2]=et[2]=_.drawingBufferWidth,J.viewportHeight=J.framebufferHeight=J.drawingBufferHeight=Fe[3]=et[3]=_.drawingBufferHeight}function Bt(){J.tick+=1,J.time=Ye(),zt(),Se.procs.poll()}function xt(){Le.refresh(),zt(),Se.procs.refresh(),ie&&ie.update()}function Ye(){return(Oi()-oe)/1e3}xt();function Ut(Fe,et){m.type(et,"function","listener callback must be a function");var it;switch(Fe){case"frame":return Pt(et);case"lost":it=He;break;case"restore":it=Ue;break;case"destroy":it=pe;break;default:m.raise("invalid event, must be one of frame,lost,restore,destroy")}return it.push(et),{cancel:function(){for(var bt=0;bt<it.length;++bt)if(it[bt]===et){it[bt]=it[it.length-1],it.pop();return}}}}var ot=i(Et,{clear:Ct,prop:It.define.bind(null,Wc),context:It.define.bind(null,nb),this:It.define.bind(null,ib),draw:Et({}),buffer:function(Fe){return te.create(Fe,tb,!1,!1)},elements:function(Fe){return xe.create(Fe,!1)},texture:Le.create2D,cube:Le.createCube,renderbuffer:X.create,framebuffer:H.create,framebufferCube:H.createCube,vao:Z.createVAO,attributes:M,frame:Pt,on:Ut,limits:N,hasExtension:function(Fe){return N.extensions.indexOf(Fe.toLowerCase())>=0},read:ce,destroy:tt,_gl:_,_refresh:xt,poll:function(){Bt(),ie&&ie.update()},now:Ye,stats:K});return h.onDone(null,ot),ot}return rb})}(ro)),ro.exports}var Ap=wp();const Ep=za(Ap),Cp="#b3b3b3",Pp=void 0,Ra=void 0,kp=1,Ip=4,Lp="#666666",Dp=.1,Fp=1,zp=1,Qf="#222222",Oe={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,useClassicQuadtree:!1,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,repulsionQuadtreeLevels:12,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},Rp=.7,Mp=.95,Op=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:Kf,setPrototypeOf:Jf,isFrozen:Np,getPrototypeOf:Gp,getOwnPropertyDescriptor:Bp}=Object;let{freeze:Xt,seal:an,create:el}=Object,{apply:Ma,construct:Oa}=typeof Reflect<"u"&&Reflect;Xt||(Xt=function(e){return e}),an||(an=function(e){return e}),Ma||(Ma=function(e,n,i){return e.apply(n,i)}),Oa||(Oa=function(e,n){return new e(...n)});const oo=qt(Array.prototype.forEach),Up=qt(Array.prototype.lastIndexOf),tl=qt(Array.prototype.pop),ur=qt(Array.prototype.push),Vp=qt(Array.prototype.splice),ao=qt(String.prototype.toLowerCase),Na=qt(String.prototype.toString),nl=qt(String.prototype.match),cr=qt(String.prototype.replace),$p=qt(String.prototype.indexOf),Hp=qt(String.prototype.trim),mn=qt(Object.prototype.hasOwnProperty),jt=qt(RegExp.prototype.test),hr=Wp(TypeError);function qt(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return Ma(t,e,i)}}function Wp(t){return function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return Oa(t,n)}}function rt(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ao;Jf&&Jf(t,null);let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){const o=n(r);o!==r&&(Np(e)||(e[i]=o),r=o)}t[r]=!0}return t}function Xp(t){for(let e=0;e<t.length;e++)mn(t,e)||(t[e]=null);return t}function Dn(t){const e=el(null);for(const[n,i]of Kf(t))mn(t,n)&&(Array.isArray(i)?e[n]=Xp(i):i&&typeof i=="object"&&i.constructor===Object?e[n]=Dn(i):e[n]=i);return e}function dr(t,e){for(;t!==null;){const i=Bp(t,e);if(i){if(i.get)return qt(i.get);if(typeof i.value=="function")return qt(i.value)}t=Gp(t)}function n(){return null}return n}const il=Xt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ga=Xt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ba=Xt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),jp=Xt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ua=Xt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),qp=Xt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),rl=Xt(["#text"]),ol=Xt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Va=Xt(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),al=Xt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),so=Xt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Yp=an(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Zp=an(/<%[\w\W]*|[\w\W]*%>/gm),Qp=an(/\$\{[\w\W]*/gm),Kp=an(/^data-[\-\w.\u00B7-\uFFFF]+$/),Jp=an(/^aria-[\-\w]+$/),sl=an(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),e0=an(/^(?:\w+script|data):/i),t0=an(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),fl=an(/^html$/i),n0=an(/^[a-z][.\w]*(-[.\w]+)+$/i);var ll=Object.freeze({__proto__:null,ARIA_ATTR:Jp,ATTR_WHITESPACE:t0,CUSTOM_ELEMENT:n0,DATA_ATTR:Kp,DOCTYPE_NAME:fl,ERB_EXPR:Zp,IS_ALLOWED_URI:sl,IS_SCRIPT_OR_DATA:e0,MUSTACHE_EXPR:Yp,TMPLIT_EXPR:Qp});const mr={element:1,text:3,progressingInstruction:7,comment:8,document:9},i0=function(){return typeof window>"u"?null:window},r0=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));const o="dompurify"+(i?"#"+i:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},ul=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function cl(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:i0();const e=$e=>cl($e);if(e.version="3.2.6",e.removed=[],!t||!t.document||t.document.nodeType!==mr.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const i=n,r=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:s,Node:f,Element:l,NodeFilter:u,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:y,DOMParser:S,trustedTypes:D}=t,q=l.prototype,Te=dr(q,"cloneNode"),we=dr(q,"remove"),fe=dr(q,"nextSibling"),Ne=dr(q,"childNodes"),Ve=dr(q,"parentNode");if(typeof s=="function"){const $e=n.createElement("template");$e.content&&$e.content.ownerDocument&&(n=$e.content.ownerDocument)}let V,ae="";const{implementation:Ie,createNodeIterator:Be,createDocumentFragment:Xe,getElementsByTagName:nt}=n,{importNode:lt}=i;let Ee=ul();e.isSupported=typeof Kf=="function"&&typeof Ve=="function"&&Ie&&Ie.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ct,ERB_EXPR:ft,TMPLIT_EXPR:G,DATA_ATTR:Pe,ARIA_ATTR:se,IS_SCRIPT_OR_DATA:De,ATTR_WHITESPACE:qe,CUSTOM_ELEMENT:je}=ll;let{IS_ALLOWED_URI:Qe}=ll,Ze=null;const dt=rt({},[...il,...Ga,...Ba,...Ua,...rl]);let ut=null;const _t=rt({},[...ol,...Va,...al,...so]);let at=Object.seal(el(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),$t=null,Ht=null,Kt=!0,Mn=!0,wo=!1,Ao=!0,On=!1,si=!0,Tn=!1,Fi=!1,zi=!1,$n=!1,Mt=!1,fi=!1,li=!0,Eo=!1;const ss="user-content-";let m=!0,ui=!1,Hn={},Wn=null;const Co=rt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let wn=null;const yr=rt({},["audio","video","img","source","image","track"]);let Nn=null;const xr=rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ri="http://www.w3.org/1998/Math/MathML",Mi="http://www.w3.org/2000/svg",sn="http://www.w3.org/1999/xhtml";let It=sn,ci=!1,Oi=null;const fs=rt({},[Ri,Mi,sn],Na);let Ni=rt({},["mi","mo","mn","ms","mtext"]),Gi=rt({},["annotation-xml"]);const ls=rt({},["title","style","font","a","script"]);let hi=null;const Po=["application/xhtml+xml","text/html"],ko="text/html";let Lt=null,Xn=null;const Yt=n.createElement("form"),Io=function(P){return P instanceof RegExp||P instanceof Function},br=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Xn&&Xn===P)){if((!P||typeof P!="object")&&(P={}),P=Dn(P),hi=Po.indexOf(P.PARSER_MEDIA_TYPE)===-1?ko:P.PARSER_MEDIA_TYPE,Lt=hi==="application/xhtml+xml"?Na:ao,Ze=mn(P,"ALLOWED_TAGS")?rt({},P.ALLOWED_TAGS,Lt):dt,ut=mn(P,"ALLOWED_ATTR")?rt({},P.ALLOWED_ATTR,Lt):_t,Oi=mn(P,"ALLOWED_NAMESPACES")?rt({},P.ALLOWED_NAMESPACES,Na):fs,Nn=mn(P,"ADD_URI_SAFE_ATTR")?rt(Dn(xr),P.ADD_URI_SAFE_ATTR,Lt):xr,wn=mn(P,"ADD_DATA_URI_TAGS")?rt(Dn(yr),P.ADD_DATA_URI_TAGS,Lt):yr,Wn=mn(P,"FORBID_CONTENTS")?rt({},P.FORBID_CONTENTS,Lt):Co,$t=mn(P,"FORBID_TAGS")?rt({},P.FORBID_TAGS,Lt):Dn({}),Ht=mn(P,"FORBID_ATTR")?rt({},P.FORBID_ATTR,Lt):Dn({}),Hn=mn(P,"USE_PROFILES")?P.USE_PROFILES:!1,Kt=P.ALLOW_ARIA_ATTR!==!1,Mn=P.ALLOW_DATA_ATTR!==!1,wo=P.ALLOW_UNKNOWN_PROTOCOLS||!1,Ao=P.ALLOW_SELF_CLOSE_IN_ATTR!==!1,On=P.SAFE_FOR_TEMPLATES||!1,si=P.SAFE_FOR_XML!==!1,Tn=P.WHOLE_DOCUMENT||!1,$n=P.RETURN_DOM||!1,Mt=P.RETURN_DOM_FRAGMENT||!1,fi=P.RETURN_TRUSTED_TYPE||!1,zi=P.FORCE_BODY||!1,li=P.SANITIZE_DOM!==!1,Eo=P.SANITIZE_NAMED_PROPS||!1,m=P.KEEP_CONTENT!==!1,ui=P.IN_PLACE||!1,Qe=P.ALLOWED_URI_REGEXP||sl,It=P.NAMESPACE||sn,Ni=P.MATHML_TEXT_INTEGRATION_POINTS||Ni,Gi=P.HTML_INTEGRATION_POINTS||Gi,at=P.CUSTOM_ELEMENT_HANDLING||{},P.CUSTOM_ELEMENT_HANDLING&&Io(P.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(at.tagNameCheck=P.CUSTOM_ELEMENT_HANDLING.tagNameCheck),P.CUSTOM_ELEMENT_HANDLING&&Io(P.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(at.attributeNameCheck=P.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),P.CUSTOM_ELEMENT_HANDLING&&typeof P.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(at.allowCustomizedBuiltInElements=P.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),On&&(Mn=!1),Mt&&($n=!0),Hn&&(Ze=rt({},rl),ut=[],Hn.html===!0&&(rt(Ze,il),rt(ut,ol)),Hn.svg===!0&&(rt(Ze,Ga),rt(ut,Va),rt(ut,so)),Hn.svgFilters===!0&&(rt(Ze,Ba),rt(ut,Va),rt(ut,so)),Hn.mathMl===!0&&(rt(Ze,Ua),rt(ut,al),rt(ut,so))),P.ADD_TAGS&&(Ze===dt&&(Ze=Dn(Ze)),rt(Ze,P.ADD_TAGS,Lt)),P.ADD_ATTR&&(ut===_t&&(ut=Dn(ut)),rt(ut,P.ADD_ATTR,Lt)),P.ADD_URI_SAFE_ATTR&&rt(Nn,P.ADD_URI_SAFE_ATTR,Lt),P.FORBID_CONTENTS&&(Wn===Co&&(Wn=Dn(Wn)),rt(Wn,P.FORBID_CONTENTS,Lt)),m&&(Ze["#text"]=!0),Tn&&rt(Ze,["html","head","body"]),Ze.table&&(rt(Ze,["tbody"]),delete $t.tbody),P.TRUSTED_TYPES_POLICY){if(typeof P.TRUSTED_TYPES_POLICY.createHTML!="function")throw hr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof P.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');V=P.TRUSTED_TYPES_POLICY,ae=V.createHTML("")}else V===void 0&&(V=r0(D,r)),V!==null&&typeof ae=="string"&&(ae=V.createHTML(""));Xt&&Xt(P),Xn=P}},Lo=rt({},[...Ga,...Ba,...jp]),Do=rt({},[...Ua,...qp]),us=function(P){let ve=Ve(P);(!ve||!ve.tagName)&&(ve={namespaceURI:It,tagName:"template"});const ze=ao(P.tagName),mt=ao(ve.tagName);return Oi[P.namespaceURI]?P.namespaceURI===Mi?ve.namespaceURI===sn?ze==="svg":ve.namespaceURI===Ri?ze==="svg"&&(mt==="annotation-xml"||Ni[mt]):!!Lo[ze]:P.namespaceURI===Ri?ve.namespaceURI===sn?ze==="math":ve.namespaceURI===Mi?ze==="math"&&Gi[mt]:!!Do[ze]:P.namespaceURI===sn?ve.namespaceURI===Mi&&!Gi[mt]||ve.namespaceURI===Ri&&!Ni[mt]?!1:!Do[ze]&&(ls[ze]||!Lo[ze]):!!(hi==="application/xhtml+xml"&&Oi[P.namespaceURI]):!1},fn=function(P){ur(e.removed,{element:P});try{Ve(P).removeChild(P)}catch{we(P)}},jn=function(P,ve){try{ur(e.removed,{attribute:ve.getAttributeNode(P),from:ve})}catch{ur(e.removed,{attribute:null,from:ve})}if(ve.removeAttribute(P),P==="is")if($n||Mt)try{fn(ve)}catch{}else try{ve.setAttribute(P,"")}catch{}},Fo=function(P){let ve=null,ze=null;if(zi)P="<remove></remove>"+P;else{const At=nl(P,/^[\r\n\t ]+/);ze=At&&At[0]}hi==="application/xhtml+xml"&&It===sn&&(P='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+P+"</body></html>");const mt=V?V.createHTML(P):P;if(It===sn)try{ve=new S().parseFromString(mt,hi)}catch{}if(!ve||!ve.documentElement){ve=Ie.createDocument(It,"template",null);try{ve.documentElement.innerHTML=ci?ae:mt}catch{}}const Ot=ve.body||ve.documentElement;return P&&ze&&Ot.insertBefore(n.createTextNode(ze),Ot.childNodes[0]||null),It===sn?nt.call(ve,Tn?"html":"body")[0]:Tn?ve.documentElement:Ot},_r=function(P){return Be.call(P.ownerDocument||P,P,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Bi=function(P){return P instanceof y&&(typeof P.nodeName!="string"||typeof P.textContent!="string"||typeof P.removeChild!="function"||!(P.attributes instanceof d)||typeof P.removeAttribute!="function"||typeof P.setAttribute!="function"||typeof P.namespaceURI!="string"||typeof P.insertBefore!="function"||typeof P.hasChildNodes!="function")},gt=function(P){return typeof f=="function"&&P instanceof f};function vn($e,P,ve){oo($e,ze=>{ze.call(e,P,ve,Xn)})}const zo=function(P){let ve=null;if(vn(Ee.beforeSanitizeElements,P,null),Bi(P))return fn(P),!0;const ze=Lt(P.nodeName);if(vn(Ee.uponSanitizeElement,P,{tagName:ze,allowedTags:Ze}),si&&P.hasChildNodes()&&!gt(P.firstElementChild)&&jt(/<[/\w!]/g,P.innerHTML)&&jt(/<[/\w!]/g,P.textContent)||P.nodeType===mr.progressingInstruction||si&&P.nodeType===mr.comment&&jt(/<[/\w]/g,P.data))return fn(P),!0;if(!Ze[ze]||$t[ze]){if(!$t[ze]&&Mo(ze)&&(at.tagNameCheck instanceof RegExp&&jt(at.tagNameCheck,ze)||at.tagNameCheck instanceof Function&&at.tagNameCheck(ze)))return!1;if(m&&!Wn[ze]){const mt=Ve(P)||P.parentNode,Ot=Ne(P)||P.childNodes;if(Ot&&mt){const At=Ot.length;for(let Wt=At-1;Wt>=0;--Wt){const gn=Te(Ot[Wt],!0);gn.__removalCount=(P.__removalCount||0)+1,mt.insertBefore(gn,fe(P))}}}return fn(P),!0}return P instanceof l&&!us(P)||(ze==="noscript"||ze==="noembed"||ze==="noframes")&&jt(/<\/no(script|embed|frames)/i,P.innerHTML)?(fn(P),!0):(On&&P.nodeType===mr.text&&(ve=P.textContent,oo([ct,ft,G],mt=>{ve=cr(ve,mt," ")}),P.textContent!==ve&&(ur(e.removed,{element:P.cloneNode()}),P.textContent=ve)),vn(Ee.afterSanitizeElements,P,null),!1)},Ro=function(P,ve,ze){if(li&&(ve==="id"||ve==="name")&&(ze in n||ze in Yt))return!1;if(!(Mn&&!Ht[ve]&&jt(Pe,ve))){if(!(Kt&&jt(se,ve))){if(!ut[ve]||Ht[ve]){if(!(Mo(P)&&(at.tagNameCheck instanceof RegExp&&jt(at.tagNameCheck,P)||at.tagNameCheck instanceof Function&&at.tagNameCheck(P))&&(at.attributeNameCheck instanceof RegExp&&jt(at.attributeNameCheck,ve)||at.attributeNameCheck instanceof Function&&at.attributeNameCheck(ve))||ve==="is"&&at.allowCustomizedBuiltInElements&&(at.tagNameCheck instanceof RegExp&&jt(at.tagNameCheck,ze)||at.tagNameCheck instanceof Function&&at.tagNameCheck(ze))))return!1}else if(!Nn[ve]){if(!jt(Qe,cr(ze,qe,""))){if(!((ve==="src"||ve==="xlink:href"||ve==="href")&&P!=="script"&&$p(ze,"data:")===0&&wn[P])){if(!(wo&&!jt(De,cr(ze,qe,"")))){if(ze)return!1}}}}}}return!0},Mo=function(P){return P!=="annotation-xml"&&nl(P,je)},Oo=function(P){vn(Ee.beforeSanitizeAttributes,P,null);const{attributes:ve}=P;if(!ve||Bi(P))return;const ze={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ut,forceKeepAttr:void 0};let mt=ve.length;for(;mt--;){const Ot=ve[mt],{name:At,namespaceURI:Wt,value:gn}=Ot,di=Lt(At),Sr=gn;let Nt=At==="value"?Sr:Hp(Sr);if(ze.attrName=di,ze.attrValue=Nt,ze.keepAttr=!0,ze.forceKeepAttr=void 0,vn(Ee.uponSanitizeAttribute,P,ze),Nt=ze.attrValue,Eo&&(di==="id"||di==="name")&&(jn(At,P),Nt=ss+Nt),si&&jt(/((--!?|])>)|<\/(style|title)/i,Nt)){jn(At,P);continue}if(ze.forceKeepAttr)continue;if(!ze.keepAttr){jn(At,P);continue}if(!Ao&&jt(/\/>/i,Nt)){jn(At,P);continue}On&&oo([ct,ft,G],Go=>{Nt=cr(Nt,Go," ")});const No=Lt(P.nodeName);if(!Ro(No,di,Nt)){jn(At,P);continue}if(V&&typeof D=="object"&&typeof D.getAttributeType=="function"&&!Wt)switch(D.getAttributeType(No,di)){case"TrustedHTML":{Nt=V.createHTML(Nt);break}case"TrustedScriptURL":{Nt=V.createScriptURL(Nt);break}}if(Nt!==Sr)try{Wt?P.setAttributeNS(Wt,At,Nt):P.setAttribute(At,Nt),Bi(P)?fn(P):tl(e.removed)}catch{jn(At,P)}}vn(Ee.afterSanitizeAttributes,P,null)},cs=function $e(P){let ve=null;const ze=_r(P);for(vn(Ee.beforeSanitizeShadowDOM,P,null);ve=ze.nextNode();)vn(Ee.uponSanitizeShadowNode,ve,null),zo(ve),Oo(ve),ve.content instanceof o&&$e(ve.content);vn(Ee.afterSanitizeShadowDOM,P,null)};return e.sanitize=function($e){let P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ve=null,ze=null,mt=null,Ot=null;if(ci=!$e,ci&&($e="<!-->"),typeof $e!="string"&&!gt($e))if(typeof $e.toString=="function"){if($e=$e.toString(),typeof $e!="string")throw hr("dirty is not a string, aborting")}else throw hr("toString is not a function");if(!e.isSupported)return $e;if(Fi||br(P),e.removed=[],typeof $e=="string"&&(ui=!1),ui){if($e.nodeName){const gn=Lt($e.nodeName);if(!Ze[gn]||$t[gn])throw hr("root node is forbidden and cannot be sanitized in-place")}}else if($e instanceof f)ve=Fo("<!---->"),ze=ve.ownerDocument.importNode($e,!0),ze.nodeType===mr.element&&ze.nodeName==="BODY"||ze.nodeName==="HTML"?ve=ze:ve.appendChild(ze);else{if(!$n&&!On&&!Tn&&$e.indexOf("<")===-1)return V&&fi?V.createHTML($e):$e;if(ve=Fo($e),!ve)return $n?null:fi?ae:""}ve&&zi&&fn(ve.firstChild);const At=_r(ui?$e:ve);for(;mt=At.nextNode();)zo(mt),Oo(mt),mt.content instanceof o&&cs(mt.content);if(ui)return $e;if($n){if(Mt)for(Ot=Xe.call(ve.ownerDocument);ve.firstChild;)Ot.appendChild(ve.firstChild);else Ot=ve;return(ut.shadowroot||ut.shadowrootmode)&&(Ot=lt.call(i,Ot,!0)),Ot}let Wt=Tn?ve.outerHTML:ve.innerHTML;return Tn&&Ze["!doctype"]&&ve.ownerDocument&&ve.ownerDocument.doctype&&ve.ownerDocument.doctype.name&&jt(fl,ve.ownerDocument.doctype.name)&&(Wt="<!DOCTYPE "+ve.ownerDocument.doctype.name+`>
9
- `+Wt),On&&oo([ct,ft,G],gn=>{Wt=cr(Wt,gn," ")}),V&&fi?V.createHTML(Wt):Wt},e.setConfig=function(){let $e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};br($e),Fi=!0},e.clearConfig=function(){Xn=null,Fi=!1},e.isValidAttribute=function($e,P,ve){Xn||br({});const ze=Lt($e),mt=Lt(P);return Ro(ze,mt,ve)},e.addHook=function($e,P){typeof P=="function"&&ur(Ee[$e],P)},e.removeHook=function($e,P){if(P!==void 0){const ve=Up(Ee[$e],P);return ve===-1?void 0:Vp(Ee[$e],ve,1)[0]}return tl(Ee[$e])},e.removeHooks=function($e){Ee[$e]=[]},e.removeAllHooks=function(){Ee=ul()},e}var o0=cl();const hl=t=>typeof t=="function",$a=t=>Array.isArray(t),dl=t=>t instanceof Object,ml=t=>t instanceof Object?t.constructor.name!=="Function"&&t.constructor.name!=="Object":!1,Ha=t=>dl(t)&&!$a(t)&&!hl(t)&&!ml(t);function Fn(t){let e;if($a(t))e=t;else{const n=Vn(t),i=n==null?void 0:n.rgb();e=[(i==null?void 0:i.r)||0,(i==null?void 0:i.g)||0,(i==null?void 0:i.b)||0,(n==null?void 0:n.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function pl(t,e,n){return .2126*t+.7152*e+.0722*n}function Qt(t,e){let n=new Float32Array;return t({framebuffer:e})(()=>{n=t.read()}),n}function vl(t,e,n){return Math.min(Math.max(t,e),n)}function nn(t){return t!=null&&!Number.isNaN(t)}function gl(t,e){return o0.sanitize(t,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class a0{constructor(){this.enableSimulation=Oe.enableSimulation,this.backgroundColor=Qf,this.spaceSize=Oe.spaceSize,this.pointColor=Cp,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=Pp,this.pointGreyoutColor=Ra,this.pointSize=Ip,this.pointOpacity=kp,this.pointSizeScale=Oe.pointSizeScale,this.hoveredPointCursor=Oe.hoveredPointCursor,this.hoveredLinkCursor=Oe.hoveredLinkCursor,this.renderHoveredPointRing=Oe.renderHoveredPointRing,this.hoveredPointRingColor=Oe.hoveredPointRingColor,this.focusedPointRingColor=Oe.focusedPointRingColor,this.focusedPointIndex=Oe.focusedPointIndex,this.linkColor=Lp,this.linkDefaultColor=void 0,this.linkOpacity=Fp,this.linkGreyoutOpacity=Dp,this.linkWidth=zp,this.linkWidthScale=Oe.linkWidthScale,this.hoveredLinkColor=Oe.hoveredLinkColor,this.hoveredLinkWidthIncrease=Oe.hoveredLinkWidthIncrease,this.renderLinks=Oe.renderLinks,this.curvedLinks=Oe.curvedLinks,this.curvedLinkSegments=Oe.curvedLinkSegments,this.curvedLinkWeight=Oe.curvedLinkWeight,this.curvedLinkControlPointDistance=Oe.curvedLinkControlPointDistance,this.linkArrows=Oe.linkArrows,this.linkArrowsSizeScale=Oe.linkArrowsSizeScale,this.scaleLinksOnZoom=Oe.scaleLinksOnZoom,this.linkVisibilityDistanceRange=Oe.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=Oe.linkVisibilityMinTransparency,this.useClassicQuadtree=Oe.useClassicQuadtree,this.simulationDecay=Oe.simulation.decay,this.simulationGravity=Oe.simulation.gravity,this.simulationCenter=Oe.simulation.center,this.simulationRepulsion=Oe.simulation.repulsion,this.simulationRepulsionTheta=Oe.simulation.repulsionTheta,this.simulationRepulsionQuadtreeLevels=Oe.simulation.repulsionQuadtreeLevels,this.simulationLinkSpring=Oe.simulation.linkSpring,this.simulationLinkDistance=Oe.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=Oe.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=Oe.simulation.repulsionFromMouse,this.enableRightClickRepulsion=Oe.enableRightClickRepulsion,this.simulationFriction=Oe.simulation.friction,this.simulationCluster=Oe.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=Oe.showFPSMonitor,this.pixelRatio=Oe.pixelRatio,this.scalePointsOnZoom=Oe.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=Oe.enableZoom,this.enableSimulationDuringZoom=Oe.enableSimulationDuringZoom,this.enableDrag=Oe.enableDrag,this.fitViewOnInit=Oe.fitViewOnInit,this.fitViewDelay=Oe.fitViewDelay,this.fitViewPadding=Oe.fitViewPadding,this.fitViewDuration=Oe.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=Oe.pointSamplingDistance,this.attribution=Oe.attribution,this.rescalePositions=Oe.rescalePositions}init(e){Object.keys(e).forEach(n=>{this.deepMergeConfig(this.getConfig(),e,n)})}deepMergeConfig(e,n,i){Ha(e[i])&&Ha(n[i])?Object.keys(n[i]).forEach(r=>{this.deepMergeConfig(e[i],n[i],r)}):e[i]=n[i]}getConfig(){return this}}class zn{constructor(e,n,i,r,o){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.reglInstance=e,this.config=n,this.store=i,this.data=r,o&&(this.points=o)}}var s0=`#ifdef GL_ES
9
+ `+Wt),On&&oo([ct,ft,G],gn=>{Wt=cr(Wt,gn," ")}),V&&fi?V.createHTML(Wt):Wt},e.setConfig=function(){let $e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};br($e),Fi=!0},e.clearConfig=function(){Xn=null,Fi=!1},e.isValidAttribute=function($e,P,ve){Xn||br({});const ze=Lt($e),mt=Lt(P);return Ro(ze,mt,ve)},e.addHook=function($e,P){typeof P=="function"&&ur(Ee[$e],P)},e.removeHook=function($e,P){if(P!==void 0){const ve=Up(Ee[$e],P);return ve===-1?void 0:Vp(Ee[$e],ve,1)[0]}return tl(Ee[$e])},e.removeHooks=function($e){Ee[$e]=[]},e.removeAllHooks=function(){Ee=ul()},e}var o0=cl();const hl=t=>typeof t=="function",$a=t=>Array.isArray(t),dl=t=>t instanceof Object,ml=t=>t instanceof Object?t.constructor.name!=="Function"&&t.constructor.name!=="Object":!1,Ha=t=>dl(t)&&!$a(t)&&!hl(t)&&!ml(t);function Fn(t){let e;if($a(t))e=t;else{const n=Vn(t),i=n==null?void 0:n.rgb();e=[(i==null?void 0:i.r)||0,(i==null?void 0:i.g)||0,(i==null?void 0:i.b)||0,(n==null?void 0:n.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function pl(t,e,n){return .2126*t+.7152*e+.0722*n}function Qt(t,e){let n=new Float32Array;return t({framebuffer:e})(()=>{n=t.read()}),n}function vl(t,e,n){return Math.min(Math.max(t,e),n)}function nn(t){return t!=null&&!Number.isNaN(t)}function gl(t,e){return o0.sanitize(t,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class a0{constructor(){this.enableSimulation=Oe.enableSimulation,this.backgroundColor=Qf,this.spaceSize=Oe.spaceSize,this.pointColor=Cp,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=Pp,this.pointGreyoutColor=Ra,this.pointSize=Ip,this.pointDefaultSize=void 0,this.pointOpacity=kp,this.pointSizeScale=Oe.pointSizeScale,this.hoveredPointCursor=Oe.hoveredPointCursor,this.hoveredLinkCursor=Oe.hoveredLinkCursor,this.renderHoveredPointRing=Oe.renderHoveredPointRing,this.hoveredPointRingColor=Oe.hoveredPointRingColor,this.focusedPointRingColor=Oe.focusedPointRingColor,this.focusedPointIndex=Oe.focusedPointIndex,this.linkColor=Lp,this.linkDefaultColor=void 0,this.linkOpacity=Fp,this.linkGreyoutOpacity=Dp,this.linkWidth=zp,this.linkDefaultWidth=void 0,this.linkWidthScale=Oe.linkWidthScale,this.hoveredLinkColor=Oe.hoveredLinkColor,this.hoveredLinkWidthIncrease=Oe.hoveredLinkWidthIncrease,this.renderLinks=Oe.renderLinks,this.curvedLinks=Oe.curvedLinks,this.curvedLinkSegments=Oe.curvedLinkSegments,this.curvedLinkWeight=Oe.curvedLinkWeight,this.curvedLinkControlPointDistance=Oe.curvedLinkControlPointDistance,this.linkArrows=Oe.linkArrows,this.linkDefaultArrows=void 0,this.linkArrowsSizeScale=Oe.linkArrowsSizeScale,this.scaleLinksOnZoom=Oe.scaleLinksOnZoom,this.linkVisibilityDistanceRange=Oe.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=Oe.linkVisibilityMinTransparency,this.useClassicQuadtree=Oe.useClassicQuadtree,this.simulationDecay=Oe.simulation.decay,this.simulationGravity=Oe.simulation.gravity,this.simulationCenter=Oe.simulation.center,this.simulationRepulsion=Oe.simulation.repulsion,this.simulationRepulsionTheta=Oe.simulation.repulsionTheta,this.simulationRepulsionQuadtreeLevels=Oe.simulation.repulsionQuadtreeLevels,this.simulationLinkSpring=Oe.simulation.linkSpring,this.simulationLinkDistance=Oe.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=Oe.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=Oe.simulation.repulsionFromMouse,this.enableRightClickRepulsion=Oe.enableRightClickRepulsion,this.simulationFriction=Oe.simulation.friction,this.simulationCluster=Oe.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=Oe.showFPSMonitor,this.pixelRatio=Oe.pixelRatio,this.scalePointsOnZoom=Oe.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=Oe.enableZoom,this.enableSimulationDuringZoom=Oe.enableSimulationDuringZoom,this.enableDrag=Oe.enableDrag,this.fitViewOnInit=Oe.fitViewOnInit,this.fitViewDelay=Oe.fitViewDelay,this.fitViewPadding=Oe.fitViewPadding,this.fitViewDuration=Oe.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=Oe.pointSamplingDistance,this.attribution=Oe.attribution,this.rescalePositions=Oe.rescalePositions}init(e){Object.keys(e).forEach(n=>{this.deepMergeConfig(this.getConfig(),e,n)})}deepMergeConfig(e,n,i){Ha(e[i])&&Ha(n[i])?Object.keys(n[i]).forEach(r=>{this.deepMergeConfig(e[i],n[i],r)}):e[i]=n[i]}getConfig(){return this}}class zn{constructor(e,n,i,r,o){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.reglInstance=e,this.config=n,this.store=i,this.data=r,o&&(this.points=o)}}var s0=`#ifdef GL_ES
10
10
  precision highp float;
11
11
  #endif
12
12
 
@@ -659,7 +659,7 @@ void main() {
659
659
  #gl-bench .opacity {
660
660
  stroke: #8288e4;
661
661
  }
662
- `;class Sl{constructor(e){this.destroy();const n=e.getContext("webgl")||e.getContext("experimental-webgl");this.bench=new P0(n,{css:k0})}begin(){var e;(e=this.bench)==null||e.begin("frame")}end(e){var n,i;(n=this.bench)==null||n.end("frame"),(i=this.bench)==null||i.nextFrame(e)}destroy(){this.bench=void 0,Ft("#gl-bench").remove()}}var Tl=(t=>(t[t.Circle=0]="Circle",t[t.Square=1]="Square",t[t.Triangle=2]="Triangle",t[t.Diamond=3]="Diamond",t[t.Pentagon=4]="Pentagon",t[t.Hexagon=5]="Hexagon",t[t.Star=6]="Star",t[t.Cross=7]="Cross",t[t.None=8]="None",t))(Tl||{});class I0{constructor(e){this._config=e}get pointsNumber(){return this.pointPositions&&this.pointPositions.length/2}get linksNumber(){return this.links&&this.links.length/2}updatePoints(){this.pointPositions=this.inputPointPositions}updatePointColor(){if(this.pointsNumber===void 0){this.pointColors=void 0;return}const e=Fn(this._config.pointDefaultColor??this._config.pointColor);if(this.inputPointColors===void 0||this.inputPointColors.length/4!==this.pointsNumber){this.pointColors=new Float32Array(this.pointsNumber*4);for(let n=0;n<this.pointColors.length/4;n++)this.pointColors[n*4]=e[0],this.pointColors[n*4+1]=e[1],this.pointColors[n*4+2]=e[2],this.pointColors[n*4+3]=e[3]}else{this.pointColors=this.inputPointColors;for(let n=0;n<this.pointColors.length/4;n++)nn(this.pointColors[n*4])||(this.pointColors[n*4]=e[0]),nn(this.pointColors[n*4+1])||(this.pointColors[n*4+1]=e[1]),nn(this.pointColors[n*4+2])||(this.pointColors[n*4+2]=e[2]),nn(this.pointColors[n*4+3])||(this.pointColors[n*4+3]=e[3])}}updatePointSize(){if(this.pointsNumber===void 0){this.pointSizes=void 0;return}if(this.inputPointSizes===void 0||this.inputPointSizes.length!==this.pointsNumber)this.pointSizes=new Float32Array(this.pointsNumber).fill(this._config.pointSize);else{this.pointSizes=this.inputPointSizes;for(let e=0;e<this.pointSizes.length;e++)nn(this.pointSizes[e])||(this.pointSizes[e]=this._config.pointSize)}}updatePointShape(){if(this.pointsNumber===void 0){this.pointShapes=void 0;return}const e=0;if(this.inputPointShapes===void 0||this.inputPointShapes.length!==this.pointsNumber)this.pointShapes=new Float32Array(this.pointsNumber).fill(e);else{this.pointShapes=new Float32Array(this.inputPointShapes);const n=this.pointShapes;for(let i=0;i<n.length;i++){const r=n[i];(r==null||!nn(r)||r<0||r>8)&&(n[i]=e)}}}updatePointImageIndices(){if(this.pointsNumber===void 0){this.pointImageIndices=void 0;return}if(this.inputPointImageIndices===void 0||this.inputPointImageIndices.length!==this.pointsNumber)this.pointImageIndices=new Float32Array(this.pointsNumber).fill(-1);else{const e=new Float32Array(this.inputPointImageIndices);for(let n=0;n<e.length;n++){const i=e[n],r=i===void 0?NaN:i;!Number.isFinite(r)||r<0?e[n]=-1:e[n]=Math.trunc(r)}this.pointImageIndices=e}}updatePointImageSizes(){var e;if(this.pointsNumber===void 0){this.pointImageSizes=void 0;return}if(this.inputPointImageSizes===void 0||this.inputPointImageSizes.length!==this.pointsNumber)this.pointImageSizes=this.pointSizes?new Float32Array(this.pointSizes):new Float32Array(this.pointsNumber).fill(this._config.pointSize);else{this.pointImageSizes=new Float32Array(this.inputPointImageSizes);for(let n=0;n<this.pointImageSizes.length;n++)nn(this.pointImageSizes[n])||(this.pointImageSizes[n]=((e=this.pointSizes)==null?void 0:e[n])??this._config.pointSize)}}updateLinks(){this.links=this.inputLinks}updateLinkColor(){if(this.linksNumber===void 0){this.linkColors=void 0;return}const e=Fn(this._config.linkDefaultColor??this._config.linkColor);if(this.inputLinkColors===void 0||this.inputLinkColors.length/4!==this.linksNumber){this.linkColors=new Float32Array(this.linksNumber*4);for(let n=0;n<this.linkColors.length/4;n++)this.linkColors[n*4]=e[0],this.linkColors[n*4+1]=e[1],this.linkColors[n*4+2]=e[2],this.linkColors[n*4+3]=e[3]}else{this.linkColors=this.inputLinkColors;for(let n=0;n<this.linkColors.length/4;n++)nn(this.linkColors[n*4])||(this.linkColors[n*4]=e[0]),nn(this.linkColors[n*4+1])||(this.linkColors[n*4+1]=e[1]),nn(this.linkColors[n*4+2])||(this.linkColors[n*4+2]=e[2]),nn(this.linkColors[n*4+3])||(this.linkColors[n*4+3]=e[3])}}updateLinkWidth(){if(this.linksNumber===void 0){this.linkWidths=void 0;return}if(this.inputLinkWidths===void 0||this.inputLinkWidths.length!==this.linksNumber)this.linkWidths=new Float32Array(this.linksNumber).fill(this._config.linkWidth);else{this.linkWidths=this.inputLinkWidths;for(let e=0;e<this.linkWidths.length;e++)nn(this.linkWidths[e])||(this.linkWidths[e]=this._config.linkWidth)}}updateArrows(){if(this.linksNumber===void 0){this.linkArrows=void 0;return}this.linkArrowsBoolean===void 0||this.linkArrowsBoolean.length!==this.linksNumber?this.linkArrows=new Array(this.linksNumber).fill(+this._config.linkArrows):this.linkArrows=this.linkArrowsBoolean.map(e=>+e)}updateLinkStrength(){this.linksNumber===void 0&&(this.linkStrength=void 0),this.inputLinkStrength===void 0||this.inputLinkStrength.length!==this.linksNumber?this.linkStrength=void 0:this.linkStrength=this.inputLinkStrength}updateClusters(){if(this.pointsNumber===void 0){this.pointClusters=void 0,this.clusterPositions=void 0;return}this.inputPointClusters===void 0||this.inputPointClusters.length!==this.pointsNumber?this.pointClusters=void 0:this.pointClusters=this.inputPointClusters,this.inputClusterPositions===void 0?this.clusterPositions=void 0:this.clusterPositions=this.inputClusterPositions,this.inputClusterStrength===void 0||this.inputClusterStrength.length!==this.pointsNumber?this.clusterStrength=void 0:this.clusterStrength=this.inputClusterStrength}update(){this.updatePoints(),this.updatePointColor(),this.updatePointSize(),this.updatePointShape(),this.updatePointImageIndices(),this.updatePointImageSizes(),this.updateLinks(),this.updateLinkColor(),this.updateLinkWidth(),this.updateArrows(),this.updateLinkStrength(),this.updateClusters(),this._createAdjacencyLists(),this._calculateDegrees()}getAdjacentIndices(e){var n,i,r,o;return[...((i=(n=this.sourceIndexToTargetIndices)==null?void 0:n[e])==null?void 0:i.map(s=>s[0]))||[],...((o=(r=this.targetIndexToSourceIndices)==null?void 0:r[e])==null?void 0:o.map(s=>s[0]))||[]]}_createAdjacencyLists(){var e,n;if(this.linksNumber===void 0||this.links===void 0){this.sourceIndexToTargetIndices=void 0,this.targetIndexToSourceIndices=void 0;return}this.sourceIndexToTargetIndices=new Array(this.pointsNumber).fill(void 0),this.targetIndexToSourceIndices=new Array(this.pointsNumber).fill(void 0);for(let i=0;i<this.linksNumber;i++){const r=this.links[i*2],o=this.links[i*2+1];r!==void 0&&o!==void 0&&(this.sourceIndexToTargetIndices[r]===void 0&&(this.sourceIndexToTargetIndices[r]=[]),(e=this.sourceIndexToTargetIndices[r])==null||e.push([o,i]),this.targetIndexToSourceIndices[o]===void 0&&(this.targetIndexToSourceIndices[o]=[]),(n=this.targetIndexToSourceIndices[o])==null||n.push([r,i]))}}_calculateDegrees(){var e,n,i,r;if(this.pointsNumber===void 0){this.degree=void 0,this.inDegree=void 0,this.outDegree=void 0;return}this.degree=new Array(this.pointsNumber).fill(0),this.inDegree=new Array(this.pointsNumber).fill(0),this.outDegree=new Array(this.pointsNumber).fill(0);for(let o=0;o<this.pointsNumber;o++)this.inDegree[o]=((n=(e=this.targetIndexToSourceIndices)==null?void 0:e[o])==null?void 0:n.length)??0,this.outDegree[o]=((r=(i=this.sourceIndexToTargetIndices)==null?void 0:i[o])==null?void 0:r.length)??0,this.degree[o]=(this.inDegree[o]??0)+(this.outDegree[o]??0)}}var L0=`precision highp float;
662
+ `;class Sl{constructor(e){this.destroy();const n=e.getContext("webgl")||e.getContext("experimental-webgl");this.bench=new P0(n,{css:k0})}begin(){var e;(e=this.bench)==null||e.begin("frame")}end(e){var n,i;(n=this.bench)==null||n.end("frame"),(i=this.bench)==null||i.nextFrame(e)}destroy(){this.bench=void 0,Ft("#gl-bench").remove()}}var Tl=(t=>(t[t.Circle=0]="Circle",t[t.Square=1]="Square",t[t.Triangle=2]="Triangle",t[t.Diamond=3]="Diamond",t[t.Pentagon=4]="Pentagon",t[t.Hexagon=5]="Hexagon",t[t.Star=6]="Star",t[t.Cross=7]="Cross",t[t.None=8]="None",t))(Tl||{});class I0{constructor(e){this._config=e}get pointsNumber(){return this.pointPositions&&this.pointPositions.length/2}get linksNumber(){return this.links&&this.links.length/2}updatePoints(){this.pointPositions=this.inputPointPositions}updatePointColor(){if(this.pointsNumber===void 0){this.pointColors=void 0;return}const e=Fn(this._config.pointDefaultColor??this._config.pointColor);if(this.inputPointColors===void 0||this.inputPointColors.length/4!==this.pointsNumber){this.pointColors=new Float32Array(this.pointsNumber*4);for(let n=0;n<this.pointColors.length/4;n++)this.pointColors[n*4]=e[0],this.pointColors[n*4+1]=e[1],this.pointColors[n*4+2]=e[2],this.pointColors[n*4+3]=e[3]}else{this.pointColors=this.inputPointColors;for(let n=0;n<this.pointColors.length/4;n++)nn(this.pointColors[n*4])||(this.pointColors[n*4]=e[0]),nn(this.pointColors[n*4+1])||(this.pointColors[n*4+1]=e[1]),nn(this.pointColors[n*4+2])||(this.pointColors[n*4+2]=e[2]),nn(this.pointColors[n*4+3])||(this.pointColors[n*4+3]=e[3])}}updatePointSize(){if(this.pointsNumber===void 0){this.pointSizes=void 0;return}const e=this._config.pointDefaultSize??this._config.pointSize;if(this.inputPointSizes===void 0||this.inputPointSizes.length!==this.pointsNumber)this.pointSizes=new Float32Array(this.pointsNumber).fill(e);else{this.pointSizes=this.inputPointSizes;for(let n=0;n<this.pointSizes.length;n++)nn(this.pointSizes[n])||(this.pointSizes[n]=e)}}updatePointShape(){if(this.pointsNumber===void 0){this.pointShapes=void 0;return}const e=0;if(this.inputPointShapes===void 0||this.inputPointShapes.length!==this.pointsNumber)this.pointShapes=new Float32Array(this.pointsNumber).fill(e);else{this.pointShapes=new Float32Array(this.inputPointShapes);const n=this.pointShapes;for(let i=0;i<n.length;i++){const r=n[i];(r==null||!nn(r)||r<0||r>8)&&(n[i]=e)}}}updatePointImageIndices(){if(this.pointsNumber===void 0){this.pointImageIndices=void 0;return}if(this.inputPointImageIndices===void 0||this.inputPointImageIndices.length!==this.pointsNumber)this.pointImageIndices=new Float32Array(this.pointsNumber).fill(-1);else{const e=new Float32Array(this.inputPointImageIndices);for(let n=0;n<e.length;n++){const i=e[n],r=i===void 0?NaN:i;!Number.isFinite(r)||r<0?e[n]=-1:e[n]=Math.trunc(r)}this.pointImageIndices=e}}updatePointImageSizes(){var n;if(this.pointsNumber===void 0){this.pointImageSizes=void 0;return}const e=this._config.pointDefaultSize??this._config.pointSize;if(this.inputPointImageSizes===void 0||this.inputPointImageSizes.length!==this.pointsNumber)this.pointImageSizes=this.pointSizes?new Float32Array(this.pointSizes):new Float32Array(this.pointsNumber).fill(e);else{this.pointImageSizes=new Float32Array(this.inputPointImageSizes);for(let i=0;i<this.pointImageSizes.length;i++)nn(this.pointImageSizes[i])||(this.pointImageSizes[i]=((n=this.pointSizes)==null?void 0:n[i])??e)}}updateLinks(){this.links=this.inputLinks}updateLinkColor(){if(this.linksNumber===void 0){this.linkColors=void 0;return}const e=Fn(this._config.linkDefaultColor??this._config.linkColor);if(this.inputLinkColors===void 0||this.inputLinkColors.length/4!==this.linksNumber){this.linkColors=new Float32Array(this.linksNumber*4);for(let n=0;n<this.linkColors.length/4;n++)this.linkColors[n*4]=e[0],this.linkColors[n*4+1]=e[1],this.linkColors[n*4+2]=e[2],this.linkColors[n*4+3]=e[3]}else{this.linkColors=this.inputLinkColors;for(let n=0;n<this.linkColors.length/4;n++)nn(this.linkColors[n*4])||(this.linkColors[n*4]=e[0]),nn(this.linkColors[n*4+1])||(this.linkColors[n*4+1]=e[1]),nn(this.linkColors[n*4+2])||(this.linkColors[n*4+2]=e[2]),nn(this.linkColors[n*4+3])||(this.linkColors[n*4+3]=e[3])}}updateLinkWidth(){if(this.linksNumber===void 0){this.linkWidths=void 0;return}const e=this._config.linkDefaultWidth??this._config.linkWidth;if(this.inputLinkWidths===void 0||this.inputLinkWidths.length!==this.linksNumber)this.linkWidths=new Float32Array(this.linksNumber).fill(e);else{this.linkWidths=this.inputLinkWidths;for(let n=0;n<this.linkWidths.length;n++)nn(this.linkWidths[n])||(this.linkWidths[n]=e)}}updateArrows(){if(this.linksNumber===void 0){this.linkArrows=void 0;return}const e=this._config.linkDefaultArrows??this._config.linkArrows;this.linkArrowsBoolean===void 0||this.linkArrowsBoolean.length!==this.linksNumber?this.linkArrows=new Array(this.linksNumber).fill(+e):this.linkArrows=this.linkArrowsBoolean.map(n=>+n)}updateLinkStrength(){this.linksNumber===void 0&&(this.linkStrength=void 0),this.inputLinkStrength===void 0||this.inputLinkStrength.length!==this.linksNumber?this.linkStrength=void 0:this.linkStrength=this.inputLinkStrength}updateClusters(){if(this.pointsNumber===void 0){this.pointClusters=void 0,this.clusterPositions=void 0;return}this.inputPointClusters===void 0||this.inputPointClusters.length!==this.pointsNumber?this.pointClusters=void 0:this.pointClusters=this.inputPointClusters,this.inputClusterPositions===void 0?this.clusterPositions=void 0:this.clusterPositions=this.inputClusterPositions,this.inputClusterStrength===void 0||this.inputClusterStrength.length!==this.pointsNumber?this.clusterStrength=void 0:this.clusterStrength=this.inputClusterStrength}update(){this.updatePoints(),this.updatePointColor(),this.updatePointSize(),this.updatePointShape(),this.updatePointImageIndices(),this.updatePointImageSizes(),this.updateLinks(),this.updateLinkColor(),this.updateLinkWidth(),this.updateArrows(),this.updateLinkStrength(),this.updateClusters(),this._createAdjacencyLists(),this._calculateDegrees()}getAdjacentIndices(e){var n,i,r,o;return[...((i=(n=this.sourceIndexToTargetIndices)==null?void 0:n[e])==null?void 0:i.map(s=>s[0]))||[],...((o=(r=this.targetIndexToSourceIndices)==null?void 0:r[e])==null?void 0:o.map(s=>s[0]))||[]]}_createAdjacencyLists(){var e,n;if(this.linksNumber===void 0||this.links===void 0){this.sourceIndexToTargetIndices=void 0,this.targetIndexToSourceIndices=void 0;return}this.sourceIndexToTargetIndices=new Array(this.pointsNumber).fill(void 0),this.targetIndexToSourceIndices=new Array(this.pointsNumber).fill(void 0);for(let i=0;i<this.linksNumber;i++){const r=this.links[i*2],o=this.links[i*2+1];r!==void 0&&o!==void 0&&(this.sourceIndexToTargetIndices[r]===void 0&&(this.sourceIndexToTargetIndices[r]=[]),(e=this.sourceIndexToTargetIndices[r])==null||e.push([o,i]),this.targetIndexToSourceIndices[o]===void 0&&(this.targetIndexToSourceIndices[o]=[]),(n=this.targetIndexToSourceIndices[o])==null||n.push([r,i]))}}_calculateDegrees(){var e,n,i,r;if(this.pointsNumber===void 0){this.degree=void 0,this.inDegree=void 0,this.outDegree=void 0;return}this.degree=new Array(this.pointsNumber).fill(0),this.inDegree=new Array(this.pointsNumber).fill(0),this.outDegree=new Array(this.pointsNumber).fill(0);for(let o=0;o<this.pointsNumber;o++)this.inDegree[o]=((n=(e=this.targetIndexToSourceIndices)==null?void 0:e[o])==null?void 0:n.length)??0,this.outDegree[o]=((r=(i=this.sourceIndexToTargetIndices)==null?void 0:i[o])==null?void 0:r.length)??0,this.degree[o]=(this.inDegree[o]??0)+(this.outDegree[o]??0)}}var L0=`precision highp float;
663
663
 
664
664
  varying vec4 rgbaColor;
665
665
  varying vec2 pos;
@@ -1678,7 +1678,7 @@ void main() {
1678
1678
  font-size: 1rem;
1679
1679
  text-align: center;
1680
1680
  user-select: none;
1681
- `,e.textContent="Sorry, your device or browser does not support the required WebGL features for this visualization",t.appendChild(e),e}class Lg{constructor(e,n){this.config=new a0,this.graph=new I0(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new mg,this.zoomInstance=new Pg(this.store,this.config),this.dragInstance=new kg(this.store,this.config),this._findHoveredItemExecutionCount=0,this._isMouseOnCanvas=!1,this._isFirstRenderAfterInit=!0,this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this._isDestroyed=!1,n&&this.config.init(n),this.store.div=e;const i=document.createElement("canvas");i.style.width="100%",i.style.height="100%",this.store.div.appendChild(i),this.addAttribution();const r=i.clientWidth,o=i.clientHeight;i.width=r*this.config.pixelRatio,i.height=o*this.config.pixelRatio,this.canvas=i;let s;try{s=Ep({canvas:this.canvas,attributes:{antialias:!1,preserveDrawingBuffer:!0},extensions:["OES_texture_float","ANGLE_instanced_arrays"]})}catch{Ig(this.store.div),this._isDestroyed=!0;return}this.reglInstance=s,this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.store.setWebGLMaxTextureSize(this.reglInstance.limits.maxTextureSize),this.store.updateScreenSize(r,o),this.canvasD3Selection=Ft(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mousemove.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mouseleave.cosmos",f=>{this._isMouseOnCanvas=!1,this.currentEvent=f,this.store.hoveredPoint!==void 0&&this.config.onPointMouseOut&&this.config.onPointMouseOut(f),this.store.hoveredLinkIndex!==void 0&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(f),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()}),Ft(document).on("keydown.cosmos",f=>{f.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",f=>{f.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",f=>{this.currentEvent=f}).on("zoom.detect",f=>{!!f.sourceEvent&&this.updateMousePosition(f.sourceEvent),this.currentEvent=f}).on("end.detect",f=>{this.currentEvent=f}),this.dragInstance.behavior.on("start.detect",f=>{this.currentEvent=f,this.updateCanvasCursor()}).on("drag.detect",f=>{this.dragInstance.isActive&&this.updateMousePosition(f),this.currentEvent=f}).on("end.detect",f=>{this.currentEvent=f,this.updateCanvasCursor()}),this.canvasD3Selection.call(this.dragInstance.behavior).call(this.zoomInstance.behavior).on("click",this.onClick.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("contextmenu",this.onRightClickMouse.bind(this)),(!this.config.enableZoom||!this.config.enableDrag)&&this.updateZoomDragBehaviors(),this.setZoomLevel(this.config.initialZoomLevel??1),this.store.maxPointSize=(this.reglInstance.limits.pointSizeDims[1]??is)/this.config.pixelRatio,this.store.isSimulationRunning=this.config.enableSimulation,this.points=new Av(this.reglInstance,this.config,this.store,this.graph),this.lines=new uv(this.reglInstance,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new h0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceCenter=new u0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceManyBody=this.config.useClassicQuadtree?new y0(this.reglInstance,this.config,this.store,this.graph,this.points):new v0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new yl(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new yl(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceMouse=new b0(this.reglInstance,this.config,this.store,this.graph,this.points)),this.clusters=new w0(this.reglInstance,this.config,this.store,this.graph,this.points),this.store.backgroundColor=Fn(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??Oe.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??Oe.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ra),this.store.setHoveredLinkColor(this.config.hoveredLinkColor??Oe.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Sl(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed)}get progress(){return this._isDestroyed?0:this.store.simulationProgress}get isSimulationRunning(){return this._isDestroyed?!1:this.store.isSimulationRunning}get maxPointSize(){return this._isDestroyed?0:this.store.maxPointSize}setConfig(e){var i;if(this._isDestroyed||!this.reglInstance||!this.points||!this.lines||!this.clusters)return;const n={...this.config};this.config.init(e),(n.pointDefaultColor!==this.config.pointDefaultColor||n.pointColor!==this.config.pointColor)&&(this.graph.updatePointColor(),this.points.updateColor()),n.pointSize!==this.config.pointSize&&(this.graph.updatePointSize(),this.points.updateSize()),(n.linkDefaultColor!==this.config.linkDefaultColor||n.linkColor!==this.config.linkColor)&&(this.graph.updateLinkColor(),this.lines.updateColor()),n.linkWidth!==this.config.linkWidth&&(this.graph.updateLinkWidth(),this.lines.updateWidth()),n.linkArrows!==this.config.linkArrows&&(this.graph.updateArrows(),this.lines.updateArrow()),(n.curvedLinkSegments!==this.config.curvedLinkSegments||n.curvedLinks!==this.config.curvedLinks)&&this.lines.updateCurveLineGeometry(),n.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=Fn(this.config.backgroundColor??Qf)),n.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??Oe.hoveredPointRingColor),n.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??Oe.focusedPointRingColor),n.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ra),n.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor??Oe.hoveredLinkColor),n.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),(n.spaceSize!==this.config.spaceSize||n.simulationRepulsionQuadtreeLevels!==this.config.simulationRepulsionQuadtreeLevels)&&(this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),n.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Sl(this.canvas):((i=this.fpsMonitor)==null||i.destroy(),this.fpsMonitor=void 0)),n.pixelRatio!==this.config.pixelRatio&&(this.store.maxPointSize=(this.reglInstance.limits.pointSizeDims[1]??is)/this.config.pixelRatio),(n.enableZoom!==this.config.enableZoom||n.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(n.onLinkClick!==this.config.onLinkClick||n.onLinkMouseOver!==this.config.onLinkMouseOver||n.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,n){this._isDestroyed||!this.points||(this.graph.inputPointPositions=e,this.points.shouldSkipRescale=n,this.isPointPositionsUpdateNeeded=!0,this.isLinksUpdateNeeded=!0,this.isPointColorUpdateNeeded=!0,this.isPointSizeUpdateNeeded=!0,this.isPointShapeUpdateNeeded=!0,this.isPointImageIndicesUpdateNeeded=!0,this.isPointImageSizesUpdateNeeded=!0,this.isPointClusterUpdateNeeded=!0,this.isForceManyBodyUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0,this.isForceCenterUpdateNeeded=!0)}setPointColors(e){this._isDestroyed||(this.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){return this._isDestroyed?new Float32Array:this.graph.pointColors??new Float32Array}setPointSizes(e){this._isDestroyed||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){this._isDestroyed||!this.points||(this.graph.inputImageData=e,this.points.createAtlas())}setPointImageIndices(e){this._isDestroyed||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){return this._isDestroyed?new Float32Array:this.graph.pointSizes??new Float32Array}setLinks(e){this._isDestroyed||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){return this._isDestroyed?new Float32Array:this.graph.linkColors??new Float32Array}setLinkWidths(e){this._isDestroyed||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){return this._isDestroyed?new Float32Array:this.graph.linkWidths??new Float32Array}setLinkArrows(e){this._isDestroyed||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}setPinnedPoints(e){this._isDestroyed||!this.points||(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,this.points.updatePinnedStatus())}render(e){if(this._isDestroyed||!this.reglInstance)return;this.graph.update();const{fitViewOnInit:n,fitViewDelay:i,fitViewPadding:r,fitViewDuration:o,fitViewByPointsInRect:s,fitViewByPointIndices:f,initialZoomLevel:l}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),Ft(this.canvas).style("cursor",null),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0});return}this._isFirstRenderAfterInit&&n&&l===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{f?this.fitViewByPointIndices(f,o,r):s?this.setZoomTransformByPointPositions(s,o,void 0,r):this.fitView(o,r)},i)),this.update(e),this.startFrames(),this._isFirstRenderAfterInit=!1}zoomToPointByIndex(e,n=700,i=Op,r=!0){if(this._isDestroyed||!this.reglInstance||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:o}}=this,s=Qt(this.reglInstance,this.points.currentPositionFbo);if(e===void 0)return;const f=s[e*4+0],l=s[e*4+1];if(f===void 0||l===void 0)return;const u=this.zoomInstance.getDistanceToPoint([f,l]),d=r?i:Math.max(this.getZoomLevel(),i);if(u<Math.min(o[0],o[1]))this.setZoomTransformByPointPositions([f,l],n,d);else{const y=this.zoomInstance.getTransform([[f,l]],d),S=this.zoomInstance.getMiddlePointTransform([f,l]);this.canvasD3Selection.transition().ease(pp).duration(n/2).call(this.zoomInstance.behavior.transform,S).transition().ease(vp).duration(n/2).call(this.zoomInstance.behavior.transform,y)}}zoom(e,n=0){this._isDestroyed||this.setZoomLevel(e,n)}setZoomLevel(e,n=0){this._isDestroyed||!this.canvasD3Selection||(n===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(n).call(this.zoomInstance.behavior.scaleTo,e))}getZoomLevel(){return this._isDestroyed?0:this.zoomInstance.eventTransform.k}getPointPositions(){if(this._isDestroyed||!this.reglInstance||!this.points)return[];if(this.graph.pointsNumber===void 0)return[];const e=[],n=Qt(this.reglInstance,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let i=0;i<this.graph.pointsNumber;i+=1){const r=n[i*4+0],o=n[i*4+1];r!==void 0&&o!==void 0&&(e[i*2]=r,e[i*2+1]=o)}return e}getClusterPositions(){if(this._isDestroyed||!this.reglInstance||!this.clusters)return[];if(this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0)return[];this.clusters.calculateCentermass();const e=[],n=Qt(this.reglInstance,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let i=0;i<e.length/2;i+=1){const r=n[i*4+0],o=n[i*4+1],s=n[i*4+2];r!==void 0&&o!==void 0&&s!==void 0&&(e[i*2]=r/s,e[i*2+1]=o/s)}return e}fitView(e=250,n=.1){this._isDestroyed||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,n)}fitViewByPointIndices(e,n=250,i=.1){if(this._isDestroyed)return;const r=this.getPointPositions(),o=new Array(e.length*2);for(const[s,f]of e.entries())o[s*2]=r[f*2],o[s*2+1]=r[f*2+1];this.setZoomTransformByPointPositions(o,n,void 0,i)}fitViewByPointPositions(e,n=250,i=.1){this._isDestroyed||this.setZoomTransformByPointPositions(e,n,void 0,i)}getPointsInRect(e){if(this._isDestroyed||!this.reglInstance||!this.points)return new Float32Array;const n=this.store.screenSize[1];return this.store.selectedArea=[[e[0][0],n-e[1][1]],[e[1][0],n-e[0][1]]],this.points.findPointsOnAreaSelection(),Qt(this.reglInstance,this.points.selectedFbo).map((r,o)=>o%4===0&&r!==0?o/4:-1).filter(r=>r!==-1)}getPointsInRange(e){return this.getPointsInRect(e)}getPointsInPolygon(e){if(this._isDestroyed||!this.reglInstance||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const n=this.store.screenSize[1],i=e.map(([o,s])=>[o,n-s]);return this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection(),Qt(this.reglInstance,this.points.selectedFbo).map((o,s)=>s%4===0&&o!==0?s/4:-1).filter(o=>o!==-1)}selectPointsInRect(e){if(!(this._isDestroyed||!this.reglInstance||!this.points)){if(e){const n=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],n-e[1][1]],[e[1][0],n-e[0][1]]],this.points.findPointsOnAreaSelection();const i=Qt(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=i.map((r,o)=>o%4===0&&r!==0?o/4:-1).filter(r=>r!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointsInRange(e){return this.selectPointsInRect(e)}selectPointsInPolygon(e){if(!(this._isDestroyed||!this.reglInstance||!this.points)){if(e){if(e.length<3){console.warn("Polygon path requires at least 3 points to form a polygon.");return}const n=this.store.screenSize[1],i=e.map(([o,s])=>[o,n-s]);this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection();const r=Qt(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=r.map((o,s)=>s%4===0&&o!==0?s/4:-1).filter(o=>o!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,n=!1){if(!this._isDestroyed)if(n){const i=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...i])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){this._isDestroyed||!this.points||(e?e.length===0?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter(n=>n!==void 0)):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){this._isDestroyed||!this.points||(this.store.selectedIndices=null,this.points.updateGreyoutStatus())}getSelectedIndices(){if(this._isDestroyed)return null;const{selectedIndices:e}=this.store;return e?Array.from(e):null}getAdjacentIndices(e){if(!this._isDestroyed)return this.graph.getAdjacentIndices(e)}spaceToScreenPosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertSpaceToScreenPosition(e)}screenToSpacePosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertScreenToSpacePosition(e)}spaceToScreenRadius(e){return this._isDestroyed?0:this.zoomInstance.convertSpaceToScreenRadius(e)}getPointRadiusByIndex(e){var n;if(!this._isDestroyed)return(n=this.graph.pointSizes)==null?void 0:n[e]}trackPointPositionsByIndices(e){this._isDestroyed||!this.points||this.points.trackPointsByIndices(e)}getTrackedPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getTrackedPositionsMap()}getTrackedPointPositionsArray(){return this._isDestroyed||!this.points?[]:this.points.getTrackedPositionsArray()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}getSampledPoints(){return this._isDestroyed||!this.points?{indices:[],positions:[]}:this.points.getSampledPoints()}getScaleX(){if(!(this._isDestroyed||!this.points))return this.points.scaleX}getScaleY(){if(!(this._isDestroyed||!this.points))return this.points.scaleY}start(e=1){var n,i;this._isDestroyed||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,this.store.alpha=e,(i=(n=this.config).onSimulationStart)==null||i.call(n))}stop(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!1,this.store.simulationProgress=0,this.store.alpha=0,(n=(e=this.config).onSimulationEnd)==null||n.call(e))}pause(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!1,(n=(e=this.config).onSimulationPause)==null||n.call(e))}unpause(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!0,(n=(e=this.config).onSimulationUnpause)==null||n.call(e))}restart(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!0,(n=(e=this.config).onSimulationRestart)==null||n.call(e))}step(){this._isDestroyed||this.config.enableSimulation&&this.store.pointsTextureSize&&this.runSimulationStep(!0)}destroy(){var e,n,i,r;this._isDestroyed||!this.reglInstance||(window.clearTimeout(this._fitViewOnInitTimeoutID),this.stopFrames(),this.canvasD3Selection&&this.canvasD3Selection.on("mouseenter.cosmos",null).on("mousemove.cosmos",null).on("mouseleave.cosmos",null).on("click",null).on("mousemove",null).on("contextmenu",null).on(".drag",null).on(".zoom",null),Ft(document).on("keydown.cosmos",null).on("keyup.cosmos",null),(e=this.zoomInstance)!=null&&e.behavior&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(n=this.dragInstance)!=null&&n.behavior&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),(i=this.fpsMonitor)==null||i.destroy(),this.reglInstance.destroy(),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0}),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),(r=document.getElementById("gl-bench-style"))==null||r.remove(),this.canvasD3Selection=void 0,this.reglInstance=void 0,this.attributionDivElement=void 0,this._isDestroyed=!0)}create(){var e,n,i,r,o;this._isDestroyed||!this.points||!this.lines||(this.isPointPositionsUpdateNeeded&&this.points.updatePositions(),this.isPointColorUpdateNeeded&&this.points.updateColor(),this.isPointSizeUpdateNeeded&&this.points.updateSize(),this.isPointShapeUpdateNeeded&&this.points.updateShape(),this.isPointImageIndicesUpdateNeeded&&this.points.updateImageIndices(),this.isPointImageSizesUpdateNeeded&&this.points.updateImageSizes(),this.isLinksUpdateNeeded&&this.lines.updatePointsBuffer(),this.isLinkColorUpdateNeeded&&this.lines.updateColor(),this.isLinkWidthUpdateNeeded&&this.lines.updateWidth(),this.isLinkArrowUpdateNeeded&&this.lines.updateArrow(),this.isForceManyBodyUpdateNeeded&&((e=this.forceManyBody)==null||e.create()),this.isForceLinkUpdateNeeded&&((n=this.forceLinkIncoming)==null||n.create(Wa.INCOMING),(i=this.forceLinkOutgoing)==null||i.create(Wa.OUTGOING)),this.isForceCenterUpdateNeeded&&((r=this.forceCenter)==null||r.create()),this.isPointClusterUpdateNeeded&&((o=this.clusters)==null||o.create()),this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1)}flatten(e){return e.flat()}pair(e){const n=new Array(e.length/2);for(let i=0;i<e.length/2;i++)n[i]=[e[i*2],e[i*2+1]];return n}update(e=this.store.alpha){const{graph:n}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(n.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((n.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.store.alpha=e}runSimulationStep(e=!1){var f,l,u,d,y,S,D,q,Te,we,fe,Ne,Ve,V,ae,Ie,Be,Xe,nt;const{config:{simulationGravity:n,simulationCenter:i,enableSimulation:r},store:{isSimulationRunning:o}}=this;if(!r)return;this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((f=this.forceMouse)==null||f.run(),(l=this.points)==null||l.updatePosition()),(e||o&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom))&&(n&&((u=this.forceGravity)==null||u.run(),(d=this.points)==null||d.updatePosition()),i&&((y=this.forceCenter)==null||y.run(),(S=this.points)==null||S.updatePosition()),(D=this.forceManyBody)==null||D.run(),(q=this.points)==null||q.updatePosition(),this.store.linksTextureSize&&((Te=this.forceLinkIncoming)==null||Te.run(),(we=this.points)==null||we.updatePosition(),(fe=this.forceLinkOutgoing)==null||fe.run(),(Ne=this.points)==null||Ne.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((Ve=this.clusters)==null||Ve.run(),(V=this.points)==null||V.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??Oe.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,ns/this.store.alpha)),(Xe=(Be=this.config).onSimulationTick)==null||Xe.call(Be,this.store.alpha,(ae=this.store.hoveredPoint)==null?void 0:ae.index,(Ie=this.store.hoveredPoint)==null?void 0:Ie.position)),(nt=this.points)==null||nt.trackPoints()}initPrograms(){var e,n,i,r,o,s;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(n=this.forceLinkIncoming)==null||n.initPrograms(),(i=this.forceLinkOutgoing)==null||i.initPrograms(),(r=this.forceMouse)==null||r.initPrograms(),(o=this.forceManyBody)==null||o.initPrograms(),(s=this.forceCenter)==null||s.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{store:{alpha:e,isSimulationRunning:n}}=this;e<ns&&n&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame(i=>{this.renderFrame(i),this._isDestroyed||this.frame()})}renderFrame(e){var i,r,o,s,f,l,u,d;if(this._isDestroyed||!this.store.pointsTextureSize)return;(i=this.fpsMonitor)==null||i.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),this.runSimulationStep(!1),(r=this.reglInstance)==null||r.clear({color:this.store.backgroundColor,depth:1,stencil:0});const{config:{renderLinks:n}}=this;n&&this.store.linksTextureSize&&((o=this.lines)==null||o.draw()),(s=this.points)==null||s.draw(),this.dragInstance.isActive&&((f=this.points)==null||f.drag(),(l=this.points)==null||l.drag(),(u=this.points)==null||u.trackPoints()),(d=this.fpsMonitor)==null||d.end(e??performance.now()),this.currentEvent=void 0}stopFrames(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=0)}startFrames(){this._isDestroyed||(this.stopFrames(),this.frame())}end(){var e,n;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(n=(e=this.config).onSimulationEnd)==null||n.call(e)}onClick(e){var n,i,r,o,s,f,l,u,d,y;(o=(r=this.config).onClick)==null||o.call(r,(n=this.store.hoveredPoint)==null?void 0:n.index,(i=this.store.hoveredPoint)==null?void 0:i.position,e),this.store.hoveredPoint?(f=(s=this.config).onPointClick)==null||f.call(s,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(u=(l=this.config).onLinkClick)==null||u.call(l,this.store.hoveredLinkIndex,e):(y=(d=this.config).onBackgroundClick)==null||y.call(d,e)}updateMousePosition(e){if(!e)return;const n=e.offsetX??e.x,i=e.offsetY??e.y;n===void 0||i===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([n,i]),this.store.screenMousePosition=[n,this.store.screenSize[1]-i])}onMouseMove(e){var n,i,r,o;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(o=(r=this.config).onMouseMove)==null||o.call(r,(n=this.store.hoveredPoint)==null?void 0:n.index,(i=this.store.hoveredPoint)==null?void 0:i.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var s,f,l,u;if(this._isDestroyed)return;const n=this.canvas.width,i=this.canvas.height,r=this.canvas.clientWidth,o=this.canvas.clientHeight;if(e||n!==r*this.config.pixelRatio||i!==o*this.config.pixelRatio){const[d,y]=this.store.screenSize,{k:S}=this.zoomInstance.eventTransform,D=this.zoomInstance.convertScreenToSpacePosition([d/2,y/2]);this.store.updateScreenSize(r,o),this.canvas.width=r*this.config.pixelRatio,this.canvas.height=o*this.config.pixelRatio,(s=this.reglInstance)==null||s.poll(),(f=this.canvasD3Selection)==null||f.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([D],S)),(l=this.points)==null||l.updateSampledPointsGrid(),this.store.isLinkHoveringEnabled&&((u=this.lines)==null||u.updateLinkIndexFbo())}}setZoomTransformByPointPositions(e,n=250,i,r){var s;this.resizeCanvas();const o=this.zoomInstance.getTransform(this.pair(e),i,r);(s=this.canvasD3Selection)==null||s.transition().ease(gp).duration(n).call(this.zoomInstance.behavior.transform,o)}updateZoomDragBehaviors(){var e,n,i,r;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(n=this.canvasD3Selection)==null||n.call(this.dragInstance.behavior).on(".drag",null),this.config.enableZoom?(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior):(r=this.canvasD3Selection)==null||r.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredItem(){if(!(this._isDestroyed||!this._isMouseOnCanvas||!this.reglInstance)){if(this._findHoveredItemExecutionCount<dg){this._findHoveredItemExecutionCount+=1;return}if(this._findHoveredItemExecutionCount=0,this.findHoveredPoint(),this.graph.linksNumber&&this.store.isLinkHoveringEnabled)this.findHoveredLine();else if(this.store.hoveredLinkIndex!==void 0){const e=this.store.hoveredLinkIndex!==void 0;this.store.hoveredLinkIndex=void 0,e&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(this.currentEvent)}this.updateCanvasCursor()}}findHoveredPoint(){var o,s,f,l,u;if(this._isDestroyed||!this.reglInstance||!this.points)return;this.points.findHoveredPoint();let e=!1,n=!1;const i=Qt(this.reglInstance,this.points.hoveredFbo);if(i[1]){const d=i[0];((o=this.store.hoveredPoint)==null?void 0:o.index)!==d&&(e=!0);const y=i[2],S=i[3];this.store.hoveredPoint={index:d,position:[y,S]}}else this.store.hoveredPoint&&(n=!0),this.store.hoveredPoint=void 0;e&&this.store.hoveredPoint&&((f=(s=this.config).onPointMouseOver)==null||f.call(s,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),n&&((u=(l=this.config).onPointMouseOut)==null||u.call(l,this.currentEvent))}findHoveredLine(){var o,s,f,l,u,d;if(this._isDestroyed||!this.reglInstance||!this.lines)return;if(this.store.hoveredPoint){this.store.hoveredLinkIndex!==void 0&&(this.store.hoveredLinkIndex=void 0,(s=(o=this.config).onLinkMouseOut)==null||s.call(o,this.currentEvent));return}this.lines.findHoveredLine();let e=!1,n=!1;const r=Qt(this.reglInstance,this.lines.hoveredLineIndexFbo)[0];r>=0?(this.store.hoveredLinkIndex!==r&&(e=!0),this.store.hoveredLinkIndex=r):(this.store.hoveredLinkIndex!==void 0&&(n=!0),this.store.hoveredLinkIndex=void 0),e&&this.store.hoveredLinkIndex!==void 0&&((l=(f=this.config).onLinkMouseOver)==null||l.call(f,this.store.hoveredLinkIndex)),n&&((d=(u=this.config).onLinkMouseOut)==null||d.call(u,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:n}=this.config;this.dragInstance.isActive?Ft(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?Ft(this.canvas).style("cursor",e):Ft(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?Ft(this.canvas).style("cursor",n):Ft(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
1681
+ `,e.textContent="Sorry, your device or browser does not support the required WebGL features for this visualization",t.appendChild(e),e}class Lg{constructor(e,n){this.config=new a0,this.graph=new I0(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new mg,this.zoomInstance=new Pg(this.store,this.config),this.dragInstance=new kg(this.store,this.config),this._findHoveredItemExecutionCount=0,this._isMouseOnCanvas=!1,this._isFirstRenderAfterInit=!0,this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this._isDestroyed=!1,n&&this.config.init(n),this.store.div=e;const i=document.createElement("canvas");i.style.width="100%",i.style.height="100%",this.store.div.appendChild(i),this.addAttribution();const r=i.clientWidth,o=i.clientHeight;i.width=r*this.config.pixelRatio,i.height=o*this.config.pixelRatio,this.canvas=i;let s;try{s=Ep({canvas:this.canvas,attributes:{antialias:!1,preserveDrawingBuffer:!0},extensions:["OES_texture_float","ANGLE_instanced_arrays"]})}catch{Ig(this.store.div),this._isDestroyed=!0;return}this.reglInstance=s,this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.store.setWebGLMaxTextureSize(this.reglInstance.limits.maxTextureSize),this.store.updateScreenSize(r,o),this.canvasD3Selection=Ft(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mousemove.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mouseleave.cosmos",f=>{this._isMouseOnCanvas=!1,this.currentEvent=f,this.store.hoveredPoint!==void 0&&this.config.onPointMouseOut&&this.config.onPointMouseOut(f),this.store.hoveredLinkIndex!==void 0&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(f),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()}),Ft(document).on("keydown.cosmos",f=>{f.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",f=>{f.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",f=>{this.currentEvent=f}).on("zoom.detect",f=>{!!f.sourceEvent&&this.updateMousePosition(f.sourceEvent),this.currentEvent=f}).on("end.detect",f=>{this.currentEvent=f}),this.dragInstance.behavior.on("start.detect",f=>{this.currentEvent=f,this.updateCanvasCursor()}).on("drag.detect",f=>{this.dragInstance.isActive&&this.updateMousePosition(f),this.currentEvent=f}).on("end.detect",f=>{this.currentEvent=f,this.updateCanvasCursor()}),this.canvasD3Selection.call(this.dragInstance.behavior).call(this.zoomInstance.behavior).on("click",this.onClick.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("contextmenu",this.onRightClickMouse.bind(this)),(!this.config.enableZoom||!this.config.enableDrag)&&this.updateZoomDragBehaviors(),this.setZoomLevel(this.config.initialZoomLevel??1),this.store.maxPointSize=(this.reglInstance.limits.pointSizeDims[1]??is)/this.config.pixelRatio,this.store.isSimulationRunning=this.config.enableSimulation,this.points=new Av(this.reglInstance,this.config,this.store,this.graph),this.lines=new uv(this.reglInstance,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new h0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceCenter=new u0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceManyBody=this.config.useClassicQuadtree?new y0(this.reglInstance,this.config,this.store,this.graph,this.points):new v0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new yl(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new yl(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceMouse=new b0(this.reglInstance,this.config,this.store,this.graph,this.points)),this.clusters=new w0(this.reglInstance,this.config,this.store,this.graph,this.points),this.store.backgroundColor=Fn(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??Oe.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??Oe.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ra),this.store.setHoveredLinkColor(this.config.hoveredLinkColor??Oe.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Sl(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed)}get progress(){return this._isDestroyed?0:this.store.simulationProgress}get isSimulationRunning(){return this._isDestroyed?!1:this.store.isSimulationRunning}get maxPointSize(){return this._isDestroyed?0:this.store.maxPointSize}setConfig(e){var i;if(this._isDestroyed||!this.reglInstance||!this.points||!this.lines||!this.clusters)return;const n={...this.config};this.config.init(e),(n.pointDefaultColor!==this.config.pointDefaultColor||n.pointColor!==this.config.pointColor)&&(this.graph.updatePointColor(),this.points.updateColor()),(n.pointDefaultSize!==this.config.pointDefaultSize||n.pointSize!==this.config.pointSize)&&(this.graph.updatePointSize(),this.points.updateSize()),(n.linkDefaultColor!==this.config.linkDefaultColor||n.linkColor!==this.config.linkColor)&&(this.graph.updateLinkColor(),this.lines.updateColor()),(n.linkDefaultWidth!==this.config.linkDefaultWidth||n.linkWidth!==this.config.linkWidth)&&(this.graph.updateLinkWidth(),this.lines.updateWidth()),(n.linkDefaultArrows!==this.config.linkDefaultArrows||n.linkArrows!==this.config.linkArrows)&&(this.graph.updateArrows(),this.lines.updateArrow()),(n.curvedLinkSegments!==this.config.curvedLinkSegments||n.curvedLinks!==this.config.curvedLinks)&&this.lines.updateCurveLineGeometry(),n.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=Fn(this.config.backgroundColor??Qf)),n.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??Oe.hoveredPointRingColor),n.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??Oe.focusedPointRingColor),n.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ra),n.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor??Oe.hoveredLinkColor),n.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),(n.spaceSize!==this.config.spaceSize||n.simulationRepulsionQuadtreeLevels!==this.config.simulationRepulsionQuadtreeLevels)&&(this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),n.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Sl(this.canvas):((i=this.fpsMonitor)==null||i.destroy(),this.fpsMonitor=void 0)),n.pixelRatio!==this.config.pixelRatio&&(this.store.maxPointSize=(this.reglInstance.limits.pointSizeDims[1]??is)/this.config.pixelRatio),(n.enableZoom!==this.config.enableZoom||n.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(n.onLinkClick!==this.config.onLinkClick||n.onLinkMouseOver!==this.config.onLinkMouseOver||n.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,n){this._isDestroyed||!this.points||(this.graph.inputPointPositions=e,this.points.shouldSkipRescale=n,this.isPointPositionsUpdateNeeded=!0,this.isLinksUpdateNeeded=!0,this.isPointColorUpdateNeeded=!0,this.isPointSizeUpdateNeeded=!0,this.isPointShapeUpdateNeeded=!0,this.isPointImageIndicesUpdateNeeded=!0,this.isPointImageSizesUpdateNeeded=!0,this.isPointClusterUpdateNeeded=!0,this.isForceManyBodyUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0,this.isForceCenterUpdateNeeded=!0)}setPointColors(e){this._isDestroyed||(this.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){return this._isDestroyed?new Float32Array:this.graph.pointColors??new Float32Array}setPointSizes(e){this._isDestroyed||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){this._isDestroyed||!this.points||(this.graph.inputImageData=e,this.points.createAtlas())}setPointImageIndices(e){this._isDestroyed||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){return this._isDestroyed?new Float32Array:this.graph.pointSizes??new Float32Array}setLinks(e){this._isDestroyed||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){return this._isDestroyed?new Float32Array:this.graph.linkColors??new Float32Array}setLinkWidths(e){this._isDestroyed||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){return this._isDestroyed?new Float32Array:this.graph.linkWidths??new Float32Array}setLinkArrows(e){this._isDestroyed||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}setPinnedPoints(e){this._isDestroyed||!this.points||(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,this.points.updatePinnedStatus())}render(e){if(this._isDestroyed||!this.reglInstance)return;this.graph.update();const{fitViewOnInit:n,fitViewDelay:i,fitViewPadding:r,fitViewDuration:o,fitViewByPointsInRect:s,fitViewByPointIndices:f,initialZoomLevel:l}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),Ft(this.canvas).style("cursor",null),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0});return}this._isFirstRenderAfterInit&&n&&l===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{f?this.fitViewByPointIndices(f,o,r):s?this.setZoomTransformByPointPositions(s,o,void 0,r):this.fitView(o,r)},i)),this.update(e),this.startFrames(),this._isFirstRenderAfterInit=!1}zoomToPointByIndex(e,n=700,i=Op,r=!0){if(this._isDestroyed||!this.reglInstance||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:o}}=this,s=Qt(this.reglInstance,this.points.currentPositionFbo);if(e===void 0)return;const f=s[e*4+0],l=s[e*4+1];if(f===void 0||l===void 0)return;const u=this.zoomInstance.getDistanceToPoint([f,l]),d=r?i:Math.max(this.getZoomLevel(),i);if(u<Math.min(o[0],o[1]))this.setZoomTransformByPointPositions([f,l],n,d);else{const y=this.zoomInstance.getTransform([[f,l]],d),S=this.zoomInstance.getMiddlePointTransform([f,l]);this.canvasD3Selection.transition().ease(pp).duration(n/2).call(this.zoomInstance.behavior.transform,S).transition().ease(vp).duration(n/2).call(this.zoomInstance.behavior.transform,y)}}zoom(e,n=0){this._isDestroyed||this.setZoomLevel(e,n)}setZoomLevel(e,n=0){this._isDestroyed||!this.canvasD3Selection||(n===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(n).call(this.zoomInstance.behavior.scaleTo,e))}getZoomLevel(){return this._isDestroyed?0:this.zoomInstance.eventTransform.k}getPointPositions(){if(this._isDestroyed||!this.reglInstance||!this.points)return[];if(this.graph.pointsNumber===void 0)return[];const e=[],n=Qt(this.reglInstance,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let i=0;i<this.graph.pointsNumber;i+=1){const r=n[i*4+0],o=n[i*4+1];r!==void 0&&o!==void 0&&(e[i*2]=r,e[i*2+1]=o)}return e}getClusterPositions(){if(this._isDestroyed||!this.reglInstance||!this.clusters)return[];if(this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0)return[];this.clusters.calculateCentermass();const e=[],n=Qt(this.reglInstance,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let i=0;i<e.length/2;i+=1){const r=n[i*4+0],o=n[i*4+1],s=n[i*4+2];r!==void 0&&o!==void 0&&s!==void 0&&(e[i*2]=r/s,e[i*2+1]=o/s)}return e}fitView(e=250,n=.1){this._isDestroyed||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,n)}fitViewByPointIndices(e,n=250,i=.1){if(this._isDestroyed)return;const r=this.getPointPositions(),o=new Array(e.length*2);for(const[s,f]of e.entries())o[s*2]=r[f*2],o[s*2+1]=r[f*2+1];this.setZoomTransformByPointPositions(o,n,void 0,i)}fitViewByPointPositions(e,n=250,i=.1){this._isDestroyed||this.setZoomTransformByPointPositions(e,n,void 0,i)}getPointsInRect(e){if(this._isDestroyed||!this.reglInstance||!this.points)return new Float32Array;const n=this.store.screenSize[1];return this.store.selectedArea=[[e[0][0],n-e[1][1]],[e[1][0],n-e[0][1]]],this.points.findPointsOnAreaSelection(),Qt(this.reglInstance,this.points.selectedFbo).map((r,o)=>o%4===0&&r!==0?o/4:-1).filter(r=>r!==-1)}getPointsInRange(e){return this.getPointsInRect(e)}getPointsInPolygon(e){if(this._isDestroyed||!this.reglInstance||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const n=this.store.screenSize[1],i=e.map(([o,s])=>[o,n-s]);return this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection(),Qt(this.reglInstance,this.points.selectedFbo).map((o,s)=>s%4===0&&o!==0?s/4:-1).filter(o=>o!==-1)}selectPointsInRect(e){if(!(this._isDestroyed||!this.reglInstance||!this.points)){if(e){const n=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],n-e[1][1]],[e[1][0],n-e[0][1]]],this.points.findPointsOnAreaSelection();const i=Qt(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=i.map((r,o)=>o%4===0&&r!==0?o/4:-1).filter(r=>r!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointsInRange(e){return this.selectPointsInRect(e)}selectPointsInPolygon(e){if(!(this._isDestroyed||!this.reglInstance||!this.points)){if(e){if(e.length<3){console.warn("Polygon path requires at least 3 points to form a polygon.");return}const n=this.store.screenSize[1],i=e.map(([o,s])=>[o,n-s]);this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection();const r=Qt(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=r.map((o,s)=>s%4===0&&o!==0?s/4:-1).filter(o=>o!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,n=!1){if(!this._isDestroyed)if(n){const i=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...i])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){this._isDestroyed||!this.points||(e?e.length===0?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter(n=>n!==void 0)):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){this._isDestroyed||!this.points||(this.store.selectedIndices=null,this.points.updateGreyoutStatus())}getSelectedIndices(){if(this._isDestroyed)return null;const{selectedIndices:e}=this.store;return e?Array.from(e):null}getAdjacentIndices(e){if(!this._isDestroyed)return this.graph.getAdjacentIndices(e)}spaceToScreenPosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertSpaceToScreenPosition(e)}screenToSpacePosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertScreenToSpacePosition(e)}spaceToScreenRadius(e){return this._isDestroyed?0:this.zoomInstance.convertSpaceToScreenRadius(e)}getPointRadiusByIndex(e){var n;if(!this._isDestroyed)return(n=this.graph.pointSizes)==null?void 0:n[e]}trackPointPositionsByIndices(e){this._isDestroyed||!this.points||this.points.trackPointsByIndices(e)}getTrackedPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getTrackedPositionsMap()}getTrackedPointPositionsArray(){return this._isDestroyed||!this.points?[]:this.points.getTrackedPositionsArray()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}getSampledPoints(){return this._isDestroyed||!this.points?{indices:[],positions:[]}:this.points.getSampledPoints()}getScaleX(){if(!(this._isDestroyed||!this.points))return this.points.scaleX}getScaleY(){if(!(this._isDestroyed||!this.points))return this.points.scaleY}start(e=1){var n,i;this._isDestroyed||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,this.store.alpha=e,(i=(n=this.config).onSimulationStart)==null||i.call(n))}stop(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!1,this.store.simulationProgress=0,this.store.alpha=0,(n=(e=this.config).onSimulationEnd)==null||n.call(e))}pause(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!1,(n=(e=this.config).onSimulationPause)==null||n.call(e))}unpause(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!0,(n=(e=this.config).onSimulationUnpause)==null||n.call(e))}restart(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!0,(n=(e=this.config).onSimulationRestart)==null||n.call(e))}step(){this._isDestroyed||this.config.enableSimulation&&this.store.pointsTextureSize&&this.runSimulationStep(!0)}destroy(){var e,n,i,r;this._isDestroyed||!this.reglInstance||(window.clearTimeout(this._fitViewOnInitTimeoutID),this.stopFrames(),this.canvasD3Selection&&this.canvasD3Selection.on("mouseenter.cosmos",null).on("mousemove.cosmos",null).on("mouseleave.cosmos",null).on("click",null).on("mousemove",null).on("contextmenu",null).on(".drag",null).on(".zoom",null),Ft(document).on("keydown.cosmos",null).on("keyup.cosmos",null),(e=this.zoomInstance)!=null&&e.behavior&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(n=this.dragInstance)!=null&&n.behavior&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),(i=this.fpsMonitor)==null||i.destroy(),this.reglInstance.destroy(),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0}),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),(r=document.getElementById("gl-bench-style"))==null||r.remove(),this.canvasD3Selection=void 0,this.reglInstance=void 0,this.attributionDivElement=void 0,this._isDestroyed=!0)}create(){var e,n,i,r,o;this._isDestroyed||!this.points||!this.lines||(this.isPointPositionsUpdateNeeded&&this.points.updatePositions(),this.isPointColorUpdateNeeded&&this.points.updateColor(),this.isPointSizeUpdateNeeded&&this.points.updateSize(),this.isPointShapeUpdateNeeded&&this.points.updateShape(),this.isPointImageIndicesUpdateNeeded&&this.points.updateImageIndices(),this.isPointImageSizesUpdateNeeded&&this.points.updateImageSizes(),this.isLinksUpdateNeeded&&this.lines.updatePointsBuffer(),this.isLinkColorUpdateNeeded&&this.lines.updateColor(),this.isLinkWidthUpdateNeeded&&this.lines.updateWidth(),this.isLinkArrowUpdateNeeded&&this.lines.updateArrow(),this.isForceManyBodyUpdateNeeded&&((e=this.forceManyBody)==null||e.create()),this.isForceLinkUpdateNeeded&&((n=this.forceLinkIncoming)==null||n.create(Wa.INCOMING),(i=this.forceLinkOutgoing)==null||i.create(Wa.OUTGOING)),this.isForceCenterUpdateNeeded&&((r=this.forceCenter)==null||r.create()),this.isPointClusterUpdateNeeded&&((o=this.clusters)==null||o.create()),this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1)}flatten(e){return e.flat()}pair(e){const n=new Array(e.length/2);for(let i=0;i<e.length/2;i++)n[i]=[e[i*2],e[i*2+1]];return n}update(e=this.store.alpha){const{graph:n}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(n.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((n.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.store.alpha=e}runSimulationStep(e=!1){var f,l,u,d,y,S,D,q,Te,we,fe,Ne,Ve,V,ae,Ie,Be,Xe,nt;const{config:{simulationGravity:n,simulationCenter:i,enableSimulation:r},store:{isSimulationRunning:o}}=this;if(!r)return;this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((f=this.forceMouse)==null||f.run(),(l=this.points)==null||l.updatePosition()),(e||o&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom))&&(n&&((u=this.forceGravity)==null||u.run(),(d=this.points)==null||d.updatePosition()),i&&((y=this.forceCenter)==null||y.run(),(S=this.points)==null||S.updatePosition()),(D=this.forceManyBody)==null||D.run(),(q=this.points)==null||q.updatePosition(),this.store.linksTextureSize&&((Te=this.forceLinkIncoming)==null||Te.run(),(we=this.points)==null||we.updatePosition(),(fe=this.forceLinkOutgoing)==null||fe.run(),(Ne=this.points)==null||Ne.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((Ve=this.clusters)==null||Ve.run(),(V=this.points)==null||V.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??Oe.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,ns/this.store.alpha)),(Xe=(Be=this.config).onSimulationTick)==null||Xe.call(Be,this.store.alpha,(ae=this.store.hoveredPoint)==null?void 0:ae.index,(Ie=this.store.hoveredPoint)==null?void 0:Ie.position)),(nt=this.points)==null||nt.trackPoints()}initPrograms(){var e,n,i,r,o,s;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(n=this.forceLinkIncoming)==null||n.initPrograms(),(i=this.forceLinkOutgoing)==null||i.initPrograms(),(r=this.forceMouse)==null||r.initPrograms(),(o=this.forceManyBody)==null||o.initPrograms(),(s=this.forceCenter)==null||s.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{store:{alpha:e,isSimulationRunning:n}}=this;e<ns&&n&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame(i=>{this.renderFrame(i),this._isDestroyed||this.frame()})}renderFrame(e){var i,r,o,s,f,l,u,d;if(this._isDestroyed||!this.store.pointsTextureSize)return;(i=this.fpsMonitor)==null||i.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),this.runSimulationStep(!1),(r=this.reglInstance)==null||r.clear({color:this.store.backgroundColor,depth:1,stencil:0});const{config:{renderLinks:n}}=this;n&&this.store.linksTextureSize&&((o=this.lines)==null||o.draw()),(s=this.points)==null||s.draw(),this.dragInstance.isActive&&((f=this.points)==null||f.drag(),(l=this.points)==null||l.drag(),(u=this.points)==null||u.trackPoints()),(d=this.fpsMonitor)==null||d.end(e??performance.now()),this.currentEvent=void 0}stopFrames(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=0)}startFrames(){this._isDestroyed||(this.stopFrames(),this.frame())}end(){var e,n;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(n=(e=this.config).onSimulationEnd)==null||n.call(e)}onClick(e){var n,i,r,o,s,f,l,u,d,y;(o=(r=this.config).onClick)==null||o.call(r,(n=this.store.hoveredPoint)==null?void 0:n.index,(i=this.store.hoveredPoint)==null?void 0:i.position,e),this.store.hoveredPoint?(f=(s=this.config).onPointClick)==null||f.call(s,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(u=(l=this.config).onLinkClick)==null||u.call(l,this.store.hoveredLinkIndex,e):(y=(d=this.config).onBackgroundClick)==null||y.call(d,e)}updateMousePosition(e){if(!e)return;const n=e.offsetX??e.x,i=e.offsetY??e.y;n===void 0||i===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([n,i]),this.store.screenMousePosition=[n,this.store.screenSize[1]-i])}onMouseMove(e){var n,i,r,o;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(o=(r=this.config).onMouseMove)==null||o.call(r,(n=this.store.hoveredPoint)==null?void 0:n.index,(i=this.store.hoveredPoint)==null?void 0:i.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var s,f,l,u;if(this._isDestroyed)return;const n=this.canvas.width,i=this.canvas.height,r=this.canvas.clientWidth,o=this.canvas.clientHeight;if(e||n!==r*this.config.pixelRatio||i!==o*this.config.pixelRatio){const[d,y]=this.store.screenSize,{k:S}=this.zoomInstance.eventTransform,D=this.zoomInstance.convertScreenToSpacePosition([d/2,y/2]);this.store.updateScreenSize(r,o),this.canvas.width=r*this.config.pixelRatio,this.canvas.height=o*this.config.pixelRatio,(s=this.reglInstance)==null||s.poll(),(f=this.canvasD3Selection)==null||f.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([D],S)),(l=this.points)==null||l.updateSampledPointsGrid(),this.store.isLinkHoveringEnabled&&((u=this.lines)==null||u.updateLinkIndexFbo())}}setZoomTransformByPointPositions(e,n=250,i,r){var s;this.resizeCanvas();const o=this.zoomInstance.getTransform(this.pair(e),i,r);(s=this.canvasD3Selection)==null||s.transition().ease(gp).duration(n).call(this.zoomInstance.behavior.transform,o)}updateZoomDragBehaviors(){var e,n,i,r;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(n=this.canvasD3Selection)==null||n.call(this.dragInstance.behavior).on(".drag",null),this.config.enableZoom?(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior):(r=this.canvasD3Selection)==null||r.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredItem(){if(!(this._isDestroyed||!this._isMouseOnCanvas||!this.reglInstance)){if(this._findHoveredItemExecutionCount<dg){this._findHoveredItemExecutionCount+=1;return}if(this._findHoveredItemExecutionCount=0,this.findHoveredPoint(),this.graph.linksNumber&&this.store.isLinkHoveringEnabled)this.findHoveredLine();else if(this.store.hoveredLinkIndex!==void 0){const e=this.store.hoveredLinkIndex!==void 0;this.store.hoveredLinkIndex=void 0,e&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(this.currentEvent)}this.updateCanvasCursor()}}findHoveredPoint(){var o,s,f,l,u;if(this._isDestroyed||!this.reglInstance||!this.points)return;this.points.findHoveredPoint();let e=!1,n=!1;const i=Qt(this.reglInstance,this.points.hoveredFbo);if(i[1]){const d=i[0];((o=this.store.hoveredPoint)==null?void 0:o.index)!==d&&(e=!0);const y=i[2],S=i[3];this.store.hoveredPoint={index:d,position:[y,S]}}else this.store.hoveredPoint&&(n=!0),this.store.hoveredPoint=void 0;e&&this.store.hoveredPoint&&((f=(s=this.config).onPointMouseOver)==null||f.call(s,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),n&&((u=(l=this.config).onPointMouseOut)==null||u.call(l,this.currentEvent))}findHoveredLine(){var o,s,f,l,u,d;if(this._isDestroyed||!this.reglInstance||!this.lines)return;if(this.store.hoveredPoint){this.store.hoveredLinkIndex!==void 0&&(this.store.hoveredLinkIndex=void 0,(s=(o=this.config).onLinkMouseOut)==null||s.call(o,this.currentEvent));return}this.lines.findHoveredLine();let e=!1,n=!1;const r=Qt(this.reglInstance,this.lines.hoveredLineIndexFbo)[0];r>=0?(this.store.hoveredLinkIndex!==r&&(e=!0),this.store.hoveredLinkIndex=r):(this.store.hoveredLinkIndex!==void 0&&(n=!0),this.store.hoveredLinkIndex=void 0),e&&this.store.hoveredLinkIndex!==void 0&&((l=(f=this.config).onLinkMouseOver)==null||l.call(f,this.store.hoveredLinkIndex)),n&&((d=(u=this.config).onLinkMouseOut)==null||d.call(u,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:n}=this.config;this.dragInstance.isActive?Ft(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?Ft(this.canvas).style("cursor",e):Ft(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?Ft(this.canvas).style("cursor",n):Ft(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
1682
1682
  user-select: none;
1683
1683
  position: absolute;
1684
1684
  bottom: 0;