@cosmos.gl/graph 2.0.0 → 2.1.0

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
@@ -1,11 +1,11 @@
1
- (function(Pt,Tn){typeof exports=="object"&&typeof module<"u"?Tn(exports):typeof define=="function"&&define.amd?define(["exports"],Tn):(Pt=typeof globalThis<"u"?globalThis:Pt||self,Tn(Pt.Cosmos={}))})(this,function(Pt){"use strict";var Tn="http://www.w3.org/1999/xhtml";const Ia={svg:"http://www.w3.org/2000/svg",xhtml:Tn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vr(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Ia.hasOwnProperty(e)?{space:Ia[e],local:t}:t}function gc(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Tn&&e.documentElement.namespaceURI===Tn?e.createElement(t):e.createElementNS(n,t)}}function yc(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ra(t){var e=Vr(t);return(e.local?yc:gc)(e)}function xc(){}function eo(t){return t==null?xc:function(){return this.querySelector(t)}}function bc(t){typeof t!="function"&&(t=eo(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],f=o.length,s=r[i]=new Array(f),u,c,v=0;v<f;++v)(u=o[v])&&(c=t.call(u,u.__data__,v,o))&&("__data__"in u&&(c.__data__=u.__data__),s[v]=c);return new zt(r,this._parents)}function _c(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Sc(){return[]}function Da(t){return t==null?Sc:function(){return this.querySelectorAll(t)}}function wc(t){return function(){return _c(t.apply(this,arguments))}}function Tc(t){typeof t=="function"?t=wc(t):t=Da(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var f=e[o],s=f.length,u,c=0;c<s;++c)(u=f[c])&&(r.push(t.call(u,u.__data__,c,f)),i.push(u));return new zt(r,i)}function Ma(t){return function(){return this.matches(t)}}function Oa(t){return function(e){return e.matches(t)}}var Ac=Array.prototype.find;function Ec(t){return function(){return Ac.call(this.children,t)}}function Cc(){return this.firstElementChild}function Pc(t){return this.select(t==null?Cc:Ec(typeof t=="function"?t:Oa(t)))}var kc=Array.prototype.filter;function Fc(){return Array.from(this.children)}function Lc(t){return function(){return kc.call(this.children,t)}}function zc(t){return this.selectAll(t==null?Fc:Lc(typeof t=="function"?t:Oa(t)))}function Ic(t){typeof t!="function"&&(t=Ma(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],f=o.length,s=r[i]=[],u,c=0;c<f;++c)(u=o[c])&&t.call(u,u.__data__,c,o)&&s.push(u);return new zt(r,this._parents)}function Ga(t){return new Array(t.length)}function Rc(){return new zt(this._enter||this._groups.map(Ga),this._parents)}function $r(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}$r.prototype={constructor:$r,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Dc(t){return function(){return t}}function Mc(t,e,n,r,i,o){for(var f=0,s,u=e.length,c=o.length;f<c;++f)(s=e[f])?(s.__data__=o[f],r[f]=s):n[f]=new $r(t,o[f]);for(;f<u;++f)(s=e[f])&&(i[f]=s)}function Oc(t,e,n,r,i,o,f){var s,u,c=new Map,v=e.length,b=o.length,S=new Array(v),D;for(s=0;s<v;++s)(u=e[s])&&(S[s]=D=f.call(u,u.__data__,s,e)+"",c.has(D)?i[s]=u:c.set(D,u));for(s=0;s<b;++s)D=f.call(t,o[s],s,o)+"",(u=c.get(D))?(r[s]=u,u.__data__=o[s],c.delete(D)):n[s]=new $r(t,o[s]);for(s=0;s<v;++s)(u=e[s])&&c.get(S[s])===u&&(i[s]=u)}function Gc(t){return t.__data__}function Nc(t,e){if(!arguments.length)return Array.from(this,Gc);var n=e?Oc:Mc,r=this._parents,i=this._groups;typeof t!="function"&&(t=Dc(t));for(var o=i.length,f=new Array(o),s=new Array(o),u=new Array(o),c=0;c<o;++c){var v=r[c],b=i[c],S=b.length,D=Bc(t.call(v,v&&v.__data__,c,r)),Z=D.length,we=s[c]=new Array(Z),Se=f[c]=new Array(Z),ae=u[c]=new Array(S);n(v,b,we,Se,ae,D,e);for(var Ne=0,je=0,q,le;Ne<Z;++Ne)if(q=we[Ne]){for(Ne>=je&&(je=Ne+1);!(le=Se[je])&&++je<Z;);q._next=le||null}}return f=new zt(f,r),f._enter=s,f._exit=u,f}function Bc(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Vc(){return new zt(this._exit||this._groups.map(Ga),this._parents)}function $c(t,e,n){var r=this.enter(),i=this,o=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function Uc(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,f=Math.min(i,o),s=new Array(i),u=0;u<f;++u)for(var c=n[u],v=r[u],b=c.length,S=s[u]=new Array(b),D,Z=0;Z<b;++Z)(D=c[Z]||v[Z])&&(S[Z]=D);for(;u<i;++u)s[u]=n[u];return new zt(s,this._parents)}function jc(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],i=r.length-1,o=r[i],f;--i>=0;)(f=r[i])&&(o&&f.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(f,o),o=f);return this}function Xc(t){t||(t=Hc);function e(b,S){return b&&S?t(b.__data__,S.__data__):!b-!S}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var f=n[o],s=f.length,u=i[o]=new Array(s),c,v=0;v<s;++v)(c=f[v])&&(u[v]=c);u.sort(e)}return new zt(i,this._parents).order()}function Hc(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Wc(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function qc(){return Array.from(this)}function Yc(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length;i<o;++i){var f=r[i];if(f)return f}return null}function Zc(){let t=0;for(const e of this)++t;return t}function Qc(){return!this.node()}function Kc(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],o=0,f=i.length,s;o<f;++o)(s=i[o])&&t.call(s,s.__data__,o,i);return this}function Jc(t){return function(){this.removeAttribute(t)}}function el(t){return function(){this.removeAttributeNS(t.space,t.local)}}function tl(t,e){return function(){this.setAttribute(t,e)}}function nl(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function rl(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function il(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function ol(t,e){var n=Vr(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?el:Jc:typeof e=="function"?n.local?il:rl:n.local?nl:tl)(n,e))}function Na(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function al(t){return function(){this.style.removeProperty(t)}}function sl(t,e,n){return function(){this.style.setProperty(t,e,n)}}function fl(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ul(t,e,n){return arguments.length>1?this.each((e==null?al:typeof e=="function"?fl:sl)(t,e,n??"")):Xn(this.node(),t)}function Xn(t,e){return t.style.getPropertyValue(e)||Na(t).getComputedStyle(t,null).getPropertyValue(e)}function cl(t){return function(){delete this[t]}}function ll(t,e){return function(){this[t]=e}}function hl(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function dl(t,e){return arguments.length>1?this.each((e==null?cl:typeof e=="function"?hl:ll)(t,e)):this.node()[t]}function Ba(t){return t.trim().split(/^|\s+/)}function to(t){return t.classList||new Va(t)}function Va(t){this._node=t,this._names=Ba(t.getAttribute("class")||"")}Va.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function $a(t,e){for(var n=to(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function Ua(t,e){for(var n=to(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function ml(t){return function(){$a(this,t)}}function pl(t){return function(){Ua(this,t)}}function vl(t,e){return function(){(e.apply(this,arguments)?$a:Ua)(this,t)}}function gl(t,e){var n=Ba(t+"");if(arguments.length<2){for(var r=to(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof e=="function"?vl:e?ml:pl)(n,e))}function yl(){this.textContent=""}function xl(t){return function(){this.textContent=t}}function bl(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function _l(t){return arguments.length?this.each(t==null?yl:(typeof t=="function"?bl:xl)(t)):this.node().textContent}function Sl(){this.innerHTML=""}function wl(t){return function(){this.innerHTML=t}}function Tl(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Al(t){return arguments.length?this.each(t==null?Sl:(typeof t=="function"?Tl:wl)(t)):this.node().innerHTML}function El(){this.nextSibling&&this.parentNode.appendChild(this)}function Cl(){return this.each(El)}function Pl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function kl(){return this.each(Pl)}function Fl(t){var e=typeof t=="function"?t:Ra(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Ll(){return null}function zl(t,e){var n=typeof t=="function"?t:Ra(t),r=e==null?Ll:typeof e=="function"?e:eo(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Il(){var t=this.parentNode;t&&t.removeChild(this)}function Rl(){return this.each(Il)}function Dl(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ml(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ol(t){return this.select(t?Ml:Dl)}function Gl(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Nl(t){return function(e){t.call(this,e,this.__data__)}}function Bl(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Vl(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,o;n<i;++n)o=e[n],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++r]=o;++r?e.length=r:delete this.__on}}}function $l(t,e,n){return function(){var r=this.__on,i,o=Nl(e);if(r){for(var f=0,s=r.length;f<s;++f)if((i=r[f]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=e;return}}this.addEventListener(t.type,o,n),i={type:t.type,name:t.name,value:e,listener:o,options:n},r?r.push(i):this.__on=[i]}}function Ul(t,e,n){var r=Bl(t+""),i,o=r.length,f;if(arguments.length<2){var s=this.node().__on;if(s){for(var u=0,c=s.length,v;u<c;++u)for(i=0,v=s[u];i<o;++i)if((f=r[i]).type===v.type&&f.name===v.name)return v.value}return}for(s=e?$l:Vl,i=0;i<o;++i)this.each(s(r[i],e,n));return this}function ja(t,e,n){var r=Na(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function jl(t,e){return function(){return ja(this,t,e)}}function Xl(t,e){return function(){return ja(this,t,e.apply(this,arguments))}}function Hl(t,e){return this.each((typeof e=="function"?Xl:jl)(t,e))}function*Wl(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length,f;i<o;++i)(f=r[i])&&(yield f)}var Xa=[null];function zt(t,e){this._groups=t,this._parents=e}function lr(){return new zt([[document.documentElement]],Xa)}function ql(){return this}zt.prototype=lr.prototype={constructor:zt,select:bc,selectAll:Tc,selectChild:Pc,selectChildren:zc,filter:Ic,data:Nc,enter:Rc,exit:Vc,join:$c,merge:Uc,selection:ql,order:jc,sort:Xc,call:Wc,nodes:qc,node:Yc,size:Zc,empty:Qc,each:Kc,attr:ol,style:ul,property:dl,classed:gl,text:_l,html:Al,raise:Cl,lower:kl,append:Fl,insert:zl,remove:Rl,clone:Ol,datum:Gl,on:Ul,dispatch:Hl,[Symbol.iterator]:Wl};function wt(t){return typeof t=="string"?new zt([[document.querySelector(t)]],[document.documentElement]):new zt([[t]],Xa)}function Yl(t){let e;for(;e=t.sourceEvent;)t=e;return t}function an(t,e){if(t=Yl(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}var Zl={value:()=>{}};function Ur(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new jr(n)}function jr(t){this._=t}function Ql(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}jr.prototype=Ur.prototype={constructor:jr,on:function(t,e){var n=this._,r=Ql(t+"",n),i,o=-1,f=r.length;if(arguments.length<2){for(;++o<f;)if((i=(t=r[o]).type)&&(i=Kl(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<f;)if(i=(t=r[o]).type)n[i]=Ha(n[i],t.name,e);else if(e==null)for(i in n)n[i]=Ha(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new jr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function Kl(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function Ha(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Zl,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Hn=0,hr=0,dr=0,Wa=1e3,Xr,mr,Hr=0,An=0,Wr=0,pr=typeof performance=="object"&&performance.now?performance:Date,qa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function no(){return An||(qa(Jl),An=pr.now()+Wr)}function Jl(){An=0}function qr(){this._call=this._time=this._next=null}qr.prototype=Ya.prototype={constructor:qr,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?no():+n)+(e==null?0:+e),!this._next&&mr!==this&&(mr?mr._next=this:Xr=this,mr=this),this._call=t,this._time=n,ro()},stop:function(){this._call&&(this._call=null,this._time=1/0,ro())}};function Ya(t,e,n){var r=new qr;return r.restart(t,e,n),r}function eh(){no(),++Hn;for(var t=Xr,e;t;)(e=An-t._time)>=0&&t._call.call(null,e),t=t._next;--Hn}function Za(){An=(Hr=pr.now())+Wr,Hn=hr=0;try{eh()}finally{Hn=0,nh(),An=0}}function th(){var t=pr.now(),e=t-Hr;e>Wa&&(Wr-=e,Hr=t)}function nh(){for(var t,e=Xr,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Xr=n);mr=t,ro(r)}function ro(t){if(!Hn){hr&&(hr=clearTimeout(hr));var e=t-An;e>24?(t<1/0&&(hr=setTimeout(Za,t-pr.now()-Wr)),dr&&(dr=clearInterval(dr))):(dr||(Hr=pr.now(),dr=setInterval(th,Wa)),Hn=1,qa(Za))}}function Qa(t,e,n){var r=new qr;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var rh=Ur("start","end","cancel","interrupt"),ih=[],Ka=0,Ja=1,io=2,Yr=3,es=4,oo=5,Zr=6;function Qr(t,e,n,r,i,o){var f=t.__transition;if(!f)t.__transition={};else if(n in f)return;oh(t,n,{name:e,index:r,group:i,on:rh,tween:ih,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Ka})}function ao(t,e){var n=Ut(t,e);if(n.state>Ka)throw new Error("too late; already scheduled");return n}function Kt(t,e){var n=Ut(t,e);if(n.state>Yr)throw new Error("too late; already running");return n}function Ut(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function oh(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=Ya(o,0,n.time);function o(c){n.state=Ja,n.timer.restart(f,n.delay,n.time),n.delay<=c&&f(c-n.delay)}function f(c){var v,b,S,D;if(n.state!==Ja)return u();for(v in r)if(D=r[v],D.name===n.name){if(D.state===Yr)return Qa(f);D.state===es?(D.state=Zr,D.timer.stop(),D.on.call("interrupt",t,t.__data__,D.index,D.group),delete r[v]):+v<e&&(D.state=Zr,D.timer.stop(),D.on.call("cancel",t,t.__data__,D.index,D.group),delete r[v])}if(Qa(function(){n.state===Yr&&(n.state=es,n.timer.restart(s,n.delay,n.time),s(c))}),n.state=io,n.on.call("start",t,t.__data__,n.index,n.group),n.state===io){for(n.state=Yr,i=new Array(S=n.tween.length),v=0,b=-1;v<S;++v)(D=n.tween[v].value.call(t,t.__data__,n.index,n.group))&&(i[++b]=D);i.length=b+1}}function s(c){for(var v=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(u),n.state=oo,1),b=-1,S=i.length;++b<S;)i[b].call(t,v);n.state===oo&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){n.state=Zr,n.timer.stop(),delete r[e];for(var c in r)return;delete t.__transition}}function Kr(t,e){var n=t.__transition,r,i,o=!0,f;if(n){e=e==null?null:e+"";for(f in n){if((r=n[f]).name!==e){o=!1;continue}i=r.state>io&&r.state<oo,r.state=Zr,r.timer.stop(),r.on.call(i?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[f]}o&&delete t.__transition}}function ah(t){return this.each(function(){Kr(this,t)})}function so(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function ts(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function vr(){}var gr=.7,Jr=1/gr,Wn="\\s*([+-]?\\d+)\\s*",yr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sh=/^#([0-9a-f]{3,8})$/,fh=new RegExp(`^rgb\\(${Wn},${Wn},${Wn}\\)$`),uh=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),ch=new RegExp(`^rgba\\(${Wn},${Wn},${Wn},${yr}\\)$`),lh=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${yr}\\)$`),hh=new RegExp(`^hsl\\(${yr},${Jt},${Jt}\\)$`),dh=new RegExp(`^hsla\\(${yr},${Jt},${Jt},${yr}\\)$`),ns={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};so(vr,pn,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:rs,formatHex:rs,formatHex8:mh,formatHsl:ph,formatRgb:is,toString:is});function rs(){return this.rgb().formatHex()}function mh(){return this.rgb().formatHex8()}function ph(){return us(this).formatHsl()}function is(){return this.rgb().formatRgb()}function pn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=sh.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?os(e):n===3?new kt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?ei(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?ei(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=fh.exec(t))?new kt(e[1],e[2],e[3],1):(e=uh.exec(t))?new kt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ch.exec(t))?ei(e[1],e[2],e[3],e[4]):(e=lh.exec(t))?ei(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=hh.exec(t))?fs(e[1],e[2]/100,e[3]/100,1):(e=dh.exec(t))?fs(e[1],e[2]/100,e[3]/100,e[4]):ns.hasOwnProperty(t)?os(ns[t]):t==="transparent"?new kt(NaN,NaN,NaN,0):null}function os(t){return new kt(t>>16&255,t>>8&255,t&255,1)}function ei(t,e,n,r){return r<=0&&(t=e=n=NaN),new kt(t,e,n,r)}function vh(t){return t instanceof vr||(t=pn(t)),t?(t=t.rgb(),new kt(t.r,t.g,t.b,t.opacity)):new kt}function fo(t,e,n,r){return arguments.length===1?vh(t):new kt(t,e,n,r??1)}function kt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}so(kt,fo,ts(vr,{brighter(t){return t=t==null?Jr:Math.pow(Jr,t),new kt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?gr:Math.pow(gr,t),new kt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new kt(En(this.r),En(this.g),En(this.b),ti(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:as,formatHex:as,formatHex8:gh,formatRgb:ss,toString:ss}));function as(){return`#${Cn(this.r)}${Cn(this.g)}${Cn(this.b)}`}function gh(){return`#${Cn(this.r)}${Cn(this.g)}${Cn(this.b)}${Cn((isNaN(this.opacity)?1:this.opacity)*255)}`}function ss(){const t=ti(this.opacity);return`${t===1?"rgb(":"rgba("}${En(this.r)}, ${En(this.g)}, ${En(this.b)}${t===1?")":`, ${t})`}`}function ti(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function En(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Cn(t){return t=En(t),(t<16?"0":"")+t.toString(16)}function fs(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new jt(t,e,n,r)}function us(t){if(t instanceof jt)return new jt(t.h,t.s,t.l,t.opacity);if(t instanceof vr||(t=pn(t)),!t)return new jt;if(t instanceof jt)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),f=NaN,s=o-i,u=(o+i)/2;return s?(e===o?f=(n-r)/s+(n<r)*6:n===o?f=(r-e)/s+2:f=(e-n)/s+4,s/=u<.5?o+i:2-o-i,f*=60):s=u>0&&u<1?0:f,new jt(f,s,u,t.opacity)}function yh(t,e,n,r){return arguments.length===1?us(t):new jt(t,e,n,r??1)}function jt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}so(jt,yh,ts(vr,{brighter(t){return t=t==null?Jr:Math.pow(Jr,t),new jt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?gr:Math.pow(gr,t),new jt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new kt(uo(t>=240?t-240:t+120,i,r),uo(t,i,r),uo(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new jt(cs(this.h),ni(this.s),ni(this.l),ti(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ti(this.opacity);return`${t===1?"hsl(":"hsla("}${cs(this.h)}, ${ni(this.s)*100}%, ${ni(this.l)*100}%${t===1?")":`, ${t})`}`}}));function cs(t){return t=(t||0)%360,t<0?t+360:t}function ni(t){return Math.max(0,Math.min(1,t||0))}function uo(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const co=t=>()=>t;function xh(t,e){return function(n){return t+n*e}}function bh(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function _h(t){return(t=+t)==1?ls:function(e,n){return n-e?bh(e,n,t):co(isNaN(e)?n:e)}}function ls(t,e){var n=e-t;return n?xh(t,n):co(isNaN(t)?e:t)}const ri=function t(e){var n=_h(e);function r(i,o){var f=n((i=fo(i)).r,(o=fo(o)).r),s=n(i.g,o.g),u=n(i.b,o.b),c=ls(i.opacity,o.opacity);return function(v){return i.r=f(v),i.g=s(v),i.b=u(v),i.opacity=c(v),i+""}}return r.gamma=t,r}(1);function Sh(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(o){for(i=0;i<n;++i)r[i]=t[i]*(1-o)+e[i]*o;return r}}function wh(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Th(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),o=new Array(n),f;for(f=0;f<r;++f)i[f]=mo(t[f],e[f]);for(;f<n;++f)o[f]=e[f];return function(s){for(f=0;f<r;++f)o[f]=i[f](s);return o}}function Ah(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Xt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Eh(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=mo(t[i],e[i]):r[i]=e[i];return function(o){for(i in n)r[i]=n[i](o);return r}}var lo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ho=new RegExp(lo.source,"g");function Ch(t){return function(){return t}}function Ph(t){return function(e){return t(e)+""}}function hs(t,e){var n=lo.lastIndex=ho.lastIndex=0,r,i,o,f=-1,s=[],u=[];for(t=t+"",e=e+"";(r=lo.exec(t))&&(i=ho.exec(e));)(o=i.index)>n&&(o=e.slice(n,o),s[f]?s[f]+=o:s[++f]=o),(r=r[0])===(i=i[0])?s[f]?s[f]+=i:s[++f]=i:(s[++f]=null,u.push({i:f,x:Xt(r,i)})),n=ho.lastIndex;return n<e.length&&(o=e.slice(n),s[f]?s[f]+=o:s[++f]=o),s.length<2?u[0]?Ph(u[0].x):Ch(e):(e=u.length,function(c){for(var v=0,b;v<e;++v)s[(b=u[v]).i]=b.x(c);return s.join("")})}function mo(t,e){var n=typeof e,r;return e==null||n==="boolean"?co(e):(n==="number"?Xt:n==="string"?(r=pn(e))?(e=r,ri):hs:e instanceof pn?ri:e instanceof Date?Ah:wh(e)?Sh:Array.isArray(e)?Th:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Eh:Xt)(t,e)}function kh(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var ds=180/Math.PI,po={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ms(t,e,n,r,i,o){var f,s,u;return(f=Math.sqrt(t*t+e*e))&&(t/=f,e/=f),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),t*r<e*n&&(t=-t,e=-e,u=-u,f=-f),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*ds,skewX:Math.atan(u)*ds,scaleX:f,scaleY:s}}var ii;function Fh(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?po:ms(e.a,e.b,e.c,e.d,e.e,e.f)}function Lh(t){return t==null||(ii||(ii=document.createElementNS("http://www.w3.org/2000/svg","g")),ii.setAttribute("transform",t),!(t=ii.transform.baseVal.consolidate()))?po:(t=t.matrix,ms(t.a,t.b,t.c,t.d,t.e,t.f))}function ps(t,e,n,r){function i(c){return c.length?c.pop()+" ":""}function o(c,v,b,S,D,Z){if(c!==b||v!==S){var we=D.push("translate(",null,e,null,n);Z.push({i:we-4,x:Xt(c,b)},{i:we-2,x:Xt(v,S)})}else(b||S)&&D.push("translate("+b+e+S+n)}function f(c,v,b,S){c!==v?(c-v>180?v+=360:v-c>180&&(c+=360),S.push({i:b.push(i(b)+"rotate(",null,r)-2,x:Xt(c,v)})):v&&b.push(i(b)+"rotate("+v+r)}function s(c,v,b,S){c!==v?S.push({i:b.push(i(b)+"skewX(",null,r)-2,x:Xt(c,v)}):v&&b.push(i(b)+"skewX("+v+r)}function u(c,v,b,S,D,Z){if(c!==b||v!==S){var we=D.push(i(D)+"scale(",null,",",null,")");Z.push({i:we-4,x:Xt(c,b)},{i:we-2,x:Xt(v,S)})}else(b!==1||S!==1)&&D.push(i(D)+"scale("+b+","+S+")")}return function(c,v){var b=[],S=[];return c=t(c),v=t(v),o(c.translateX,c.translateY,v.translateX,v.translateY,b,S),f(c.rotate,v.rotate,b,S),s(c.skewX,v.skewX,b,S),u(c.scaleX,c.scaleY,v.scaleX,v.scaleY,b,S),c=v=null,function(D){for(var Z=-1,we=S.length,Se;++Z<we;)b[(Se=S[Z]).i]=Se.x(D);return b.join("")}}}var zh=ps(Fh,"px, ","px)","deg)"),Ih=ps(Lh,", ",")",")"),Rh=1e-12;function vs(t){return((t=Math.exp(t))+1/t)/2}function Dh(t){return((t=Math.exp(t))-1/t)/2}function Mh(t){return((t=Math.exp(2*t))-1)/(t+1)}const Oh=function t(e,n,r){function i(o,f){var s=o[0],u=o[1],c=o[2],v=f[0],b=f[1],S=f[2],D=v-s,Z=b-u,we=D*D+Z*Z,Se,ae;if(we<Rh)ae=Math.log(S/c)/e,Se=function(Me){return[s+Me*D,u+Me*Z,c*Math.exp(e*Me*ae)]};else{var Ne=Math.sqrt(we),je=(S*S-c*c+r*we)/(2*c*n*Ne),q=(S*S-c*c-r*we)/(2*S*n*Ne),le=Math.log(Math.sqrt(je*je+1)-je),Le=Math.log(Math.sqrt(q*q+1)-q);ae=(Le-le)/e,Se=function(Me){var Xe=Me*ae,et=vs(le),nt=c/(n*Ne)*(et*Mh(e*Xe+le)-Dh(le));return[s+nt*D,u+nt*Z,c*et/vs(e*Xe+le)]}}return Se.duration=ae*1e3*e/Math.SQRT2,Se}return i.rho=function(o){var f=Math.max(.001,+o),s=f*f,u=s*s;return t(f,s,u)},i}(Math.SQRT2,2,4);function Gh(t,e){var n,r;return function(){var i=Kt(this,t),o=i.tween;if(o!==n){r=n=o;for(var f=0,s=r.length;f<s;++f)if(r[f].name===e){r=r.slice(),r.splice(f,1);break}}i.tween=r}}function Nh(t,e,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Kt(this,t),f=o.tween;if(f!==r){i=(r=f).slice();for(var s={name:e,value:n},u=0,c=i.length;u<c;++u)if(i[u].name===e){i[u]=s;break}u===c&&i.push(s)}o.tween=i}}function Bh(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=Ut(this.node(),n).tween,i=0,o=r.length,f;i<o;++i)if((f=r[i]).name===t)return f.value;return null}return this.each((e==null?Gh:Nh)(n,t,e))}function vo(t,e,n){var r=t._id;return t.each(function(){var i=Kt(this,r);(i.value||(i.value={}))[e]=n.apply(this,arguments)}),function(i){return Ut(i,r).value[e]}}function gs(t,e){var n;return(typeof e=="number"?Xt:e instanceof pn?ri:(n=pn(e))?(e=n,ri):hs)(t,e)}function Vh(t){return function(){this.removeAttribute(t)}}function $h(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Uh(t,e,n){var r,i=n+"",o;return function(){var f=this.getAttribute(t);return f===i?null:f===r?o:o=e(r=f,n)}}function jh(t,e,n){var r,i=n+"",o;return function(){var f=this.getAttributeNS(t.space,t.local);return f===i?null:f===r?o:o=e(r=f,n)}}function Xh(t,e,n){var r,i,o;return function(){var f,s=n(this),u;return s==null?void this.removeAttribute(t):(f=this.getAttribute(t),u=s+"",f===u?null:f===r&&u===i?o:(i=u,o=e(r=f,s)))}}function Hh(t,e,n){var r,i,o;return function(){var f,s=n(this),u;return s==null?void this.removeAttributeNS(t.space,t.local):(f=this.getAttributeNS(t.space,t.local),u=s+"",f===u?null:f===r&&u===i?o:(i=u,o=e(r=f,s)))}}function Wh(t,e){var n=Vr(t),r=n==="transform"?Ih:gs;return this.attrTween(t,typeof e=="function"?(n.local?Hh:Xh)(n,r,vo(this,"attr."+t,e)):e==null?(n.local?$h:Vh)(n):(n.local?jh:Uh)(n,r,e))}function qh(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Yh(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function Zh(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&Yh(t,o)),n}return i._value=e,i}function Qh(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&qh(t,o)),n}return i._value=e,i}function Kh(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Vr(t);return this.tween(n,(r.local?Zh:Qh)(r,e))}function Jh(t,e){return function(){ao(this,t).delay=+e.apply(this,arguments)}}function ed(t,e){return e=+e,function(){ao(this,t).delay=e}}function td(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Jh:ed)(e,t)):Ut(this.node(),e).delay}function nd(t,e){return function(){Kt(this,t).duration=+e.apply(this,arguments)}}function rd(t,e){return e=+e,function(){Kt(this,t).duration=e}}function id(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?nd:rd)(e,t)):Ut(this.node(),e).duration}function od(t,e){if(typeof e!="function")throw new Error;return function(){Kt(this,t).ease=e}}function ad(t){var e=this._id;return arguments.length?this.each(od(e,t)):Ut(this.node(),e).ease}function sd(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Kt(this,t).ease=n}}function fd(t){if(typeof t!="function")throw new Error;return this.each(sd(this._id,t))}function ud(t){typeof t!="function"&&(t=Ma(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],f=o.length,s=r[i]=[],u,c=0;c<f;++c)(u=o[c])&&t.call(u,u.__data__,c,o)&&s.push(u);return new sn(r,this._parents,this._name,this._id)}function cd(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),f=new Array(r),s=0;s<o;++s)for(var u=e[s],c=n[s],v=u.length,b=f[s]=new Array(v),S,D=0;D<v;++D)(S=u[D]||c[D])&&(b[D]=S);for(;s<r;++s)f[s]=e[s];return new sn(f,this._parents,this._name,this._id)}function ld(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function hd(t,e,n){var r,i,o=ld(e)?ao:Kt;return function(){var f=o(this,t),s=f.on;s!==r&&(i=(r=s).copy()).on(e,n),f.on=i}}function dd(t,e){var n=this._id;return arguments.length<2?Ut(this.node(),n).on.on(t):this.each(hd(n,t,e))}function md(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function pd(){return this.on("end.remove",md(this._id))}function vd(t){var e=this._name,n=this._id;typeof t!="function"&&(t=eo(t));for(var r=this._groups,i=r.length,o=new Array(i),f=0;f<i;++f)for(var s=r[f],u=s.length,c=o[f]=new Array(u),v,b,S=0;S<u;++S)(v=s[S])&&(b=t.call(v,v.__data__,S,s))&&("__data__"in v&&(b.__data__=v.__data__),c[S]=b,Qr(c[S],e,n,S,c,Ut(v,n)));return new sn(o,this._parents,e,n)}function gd(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Da(t));for(var r=this._groups,i=r.length,o=[],f=[],s=0;s<i;++s)for(var u=r[s],c=u.length,v,b=0;b<c;++b)if(v=u[b]){for(var S=t.call(v,v.__data__,b,u),D,Z=Ut(v,n),we=0,Se=S.length;we<Se;++we)(D=S[we])&&Qr(D,e,n,we,S,Z);o.push(S),f.push(v)}return new sn(o,f,e,n)}var yd=lr.prototype.constructor;function xd(){return new yd(this._groups,this._parents)}function bd(t,e){var n,r,i;return function(){var o=Xn(this,t),f=(this.style.removeProperty(t),Xn(this,t));return o===f?null:o===n&&f===r?i:i=e(n=o,r=f)}}function ys(t){return function(){this.style.removeProperty(t)}}function _d(t,e,n){var r,i=n+"",o;return function(){var f=Xn(this,t);return f===i?null:f===r?o:o=e(r=f,n)}}function Sd(t,e,n){var r,i,o;return function(){var f=Xn(this,t),s=n(this),u=s+"";return s==null&&(u=s=(this.style.removeProperty(t),Xn(this,t))),f===u?null:f===r&&u===i?o:(i=u,o=e(r=f,s))}}function wd(t,e){var n,r,i,o="style."+e,f="end."+o,s;return function(){var u=Kt(this,t),c=u.on,v=u.value[o]==null?s||(s=ys(e)):void 0;(c!==n||i!==v)&&(r=(n=c).copy()).on(f,i=v),u.on=r}}function Td(t,e,n){var r=(t+="")=="transform"?zh:gs;return e==null?this.styleTween(t,bd(t,r)).on("end.style."+t,ys(t)):typeof e=="function"?this.styleTween(t,Sd(t,r,vo(this,"style."+t,e))).each(wd(this._id,t)):this.styleTween(t,_d(t,r,e),n).on("end.style."+t,null)}function Ad(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Ed(t,e,n){var r,i;function o(){var f=e.apply(this,arguments);return f!==i&&(r=(i=f)&&Ad(t,f,n)),r}return o._value=e,o}function Cd(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,Ed(t,e,n??""))}function Pd(t){return function(){this.textContent=t}}function kd(t){return function(){var e=t(this);this.textContent=e??""}}function Fd(t){return this.tween("text",typeof t=="function"?kd(vo(this,"text",t)):Pd(t==null?"":t+""))}function Ld(t){return function(e){this.textContent=t.call(this,e)}}function zd(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&Ld(i)),e}return r._value=t,r}function Id(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,zd(t))}function Rd(){for(var t=this._name,e=this._id,n=xs(),r=this._groups,i=r.length,o=0;o<i;++o)for(var f=r[o],s=f.length,u,c=0;c<s;++c)if(u=f[c]){var v=Ut(u,e);Qr(u,t,n,c,f,{time:v.time+v.delay+v.duration,delay:0,duration:v.duration,ease:v.ease})}return new sn(r,this._parents,t,n)}function Dd(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,f){var s={value:f},u={value:function(){--i===0&&o()}};n.each(function(){var c=Kt(this,r),v=c.on;v!==t&&(e=(t=v).copy(),e._.cancel.push(s),e._.interrupt.push(s),e._.end.push(u)),c.on=e}),i===0&&o()})}var Md=0;function sn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function xs(){return++Md}var fn=lr.prototype;sn.prototype={constructor:sn,select:vd,selectAll:gd,selectChild:fn.selectChild,selectChildren:fn.selectChildren,filter:ud,merge:cd,selection:xd,transition:Rd,call:fn.call,nodes:fn.nodes,node:fn.node,size:fn.size,empty:fn.empty,each:fn.each,on:dd,attr:Wh,attrTween:Kh,style:Td,styleTween:Cd,text:Fd,textTween:Id,remove:pd,tween:Bh,delay:td,duration:id,ease:ad,easeVarying:fd,end:Dd,[Symbol.iterator]:fn[Symbol.iterator]};function Od(t){return t*t}function Gd(t){return t*(2-t)}function Nd(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function Bd(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Vd={time:null,delay:0,duration:250,ease:Bd};function $d(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function Ud(t){var e,n;t instanceof sn?(e=t._id,t=t._name):(e=xs(),(n=Vd).time=no(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var f=r[o],s=f.length,u,c=0;c<s;++c)(u=f[c])&&Qr(u,t,e,c,f,n||$d(u,e));return new sn(r,this._parents,t,e)}lr.prototype.interrupt=ah,lr.prototype.transition=Ud;function go(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function jd(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var oi={exports:{}},Xd=oi.exports,bs;function Hd(){return bs||(bs=1,function(t,e){(function(n,r){t.exports=r()})(Xd,function(){var n=function(a){return a instanceof Uint8Array||a instanceof Uint16Array||a instanceof Uint32Array||a instanceof Int8Array||a instanceof Int16Array||a instanceof Int32Array||a instanceof Float32Array||a instanceof Float64Array||a instanceof Uint8ClampedArray},r=function(a,h){for(var _=Object.keys(h),R=0;R<_.length;++R)a[_[R]]=h[_[R]];return a},i=`
2
- `;function o(a){return typeof atob<"u"?atob(a):"base64:"+a}function f(a){var h=new Error("(regl) "+a);throw console.error(h),h}function s(a,h){a||f(h)}function u(a){return a?": "+a:""}function c(a,h,_){a in h||f("unknown parameter ("+a+")"+u(_)+". possible values: "+Object.keys(h).join())}function v(a,h){n(a)||f("invalid parameter type"+u(h)+". must be a typed array")}function b(a,h){switch(h){case"number":return typeof a=="number";case"object":return typeof a=="object";case"string":return typeof a=="string";case"boolean":return typeof a=="boolean";case"function":return typeof a=="function";case"undefined":return typeof a>"u";case"symbol":return typeof a=="symbol"}}function S(a,h,_){b(a,h)||f("invalid parameter type"+u(_)+". expected "+h+", got "+typeof a)}function D(a,h){a>=0&&(a|0)===a||f("invalid parameter type, ("+a+")"+u(h)+". must be a nonnegative integer")}function Z(a,h,_){h.indexOf(a)<0&&f("invalid value"+u(_)+". must be one of: "+h)}var we=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function Se(a){Object.keys(a).forEach(function(h){we.indexOf(h)<0&&f('invalid regl constructor argument "'+h+'". must be one of '+we)})}function ae(a,h){for(a=a+"";a.length<h;)a=" "+a;return a}function Ne(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function je(a,h){this.number=a,this.line=h,this.errors=[]}function q(a,h,_){this.file=a,this.line=h,this.message=_}function le(){var a=new Error,h=(a.stack||a).toString(),_=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(h);if(_)return _[1];var R=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(h);return R?R[1]:"unknown"}function Le(){var a=new Error,h=(a.stack||a).toString(),_=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(h);if(_)return _[1];var R=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(h);return R?R[1]:"unknown"}function Me(a,h){var _=a.split(`
3
- `),R=1,U=0,I={unknown:new Ne,0:new Ne};I.unknown.name=I[0].name=h||le(),I.unknown.lines.push(new je(0,""));for(var N=0;N<_.length;++N){var Q=_[N],Y=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(Q);if(Y)switch(Y[1]){case"line":var ne=/(\d+)(\s+\d+)?/.exec(Y[2]);ne&&(R=ne[1]|0,ne[2]&&(U=ne[2]|0,U in I||(I[U]=new Ne)));break;case"define":var ie=/SHADER_NAME(_B64)?\s+(.*)$/.exec(Y[2]);ie&&(I[U].name=ie[1]?o(ie[2]):ie[2]);break}I[U].lines.push(new je(R++,Q))}return Object.keys(I).forEach(function(re){var fe=I[re];fe.lines.forEach(function(K){fe.index[K.number]=K})}),I}function Xe(a){var h=[];return a.split(`
4
- `).forEach(function(_){if(!(_.length<5)){var R=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(_);R?h.push(new q(R[1]|0,R[2]|0,R[3].trim())):_.length>0&&h.push(new q("unknown",0,_))}}),h}function et(a,h){h.forEach(function(_){var R=a[_.file];if(R){var U=R.index[_.line];if(U){U.errors.push(_),R.hasErrors=!0;return}}a.unknown.hasErrors=!0,a.unknown.lines[0].errors.push(_)})}function nt(a,h,_,R,U){if(!a.getShaderParameter(h,a.COMPILE_STATUS)){var I=a.getShaderInfoLog(h),N=R===a.FRAGMENT_SHADER?"fragment":"vertex";Ce(_,"string",N+" shader source must be a string",U);var Q=Me(_,U),Y=Xe(I);et(Q,Y),Object.keys(Q).forEach(function(ne){var ie=Q[ne];if(!ie.hasErrors)return;var re=[""],fe=[""];function K(te,P){re.push(te),fe.push(P||"")}K("file number "+ne+": "+ie.name+`
5
- `,"color:red;text-decoration:underline;font-weight:bold"),ie.lines.forEach(function(te){if(te.errors.length>0){K(ae(te.number,4)+"| ","background-color:yellow; font-weight:bold"),K(te.line+i,"color:red; background-color:yellow; font-weight:bold");var P=0;te.errors.forEach(function(O){var ee=O.message,ge=/^\s*'(.*)'\s*:\s*(.*)$/.exec(ee);if(ge){var W=ge[1];switch(ee=ge[2],W){case"assign":W="=";break}P=Math.max(te.line.indexOf(W,P),0)}else P=0;K(ae("| ",6)),K(ae("^^^",P+3)+i,"font-weight:bold"),K(ae("| ",6)),K(ee+i,"font-weight:bold")}),K(ae("| ",6)+i)}else K(ae(te.number,4)+"| "),K(te.line+i,"color:red")}),typeof document<"u"&&!window.chrome?(fe[0]=re.join("%c"),console.log.apply(console,fe)):console.log(re.join(""))}),s.raise("Error compiling "+N+" shader, "+Q[0].name)}}function ke(a,h,_,R,U){if(!a.getProgramParameter(h,a.LINK_STATUS)){var I=a.getProgramInfoLog(h),N=Me(_,U),Q=Me(R,U),Y='Error linking program with vertex shader, "'+Q[0].name+'", and fragment shader "'+N[0].name+'"';typeof document<"u"?console.log("%c"+Y+i+"%c"+I,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(Y+i+I),s.raise(Y)}}function it(a){a._commandRef=le()}function tt(a,h,_,R){it(a);function U(Y){return Y?R.id(Y):0}a._fragId=U(a.static.frag),a._vertId=U(a.static.vert);function I(Y,ne){Object.keys(ne).forEach(function(ie){Y[R.id(ie)]=!0})}var N=a._uniformSet={};I(N,h.static),I(N,h.dynamic);var Q=a._attributeSet={};I(Q,_.static),I(Q,_.dynamic),a._hasCount="count"in a.static||"count"in a.dynamic||"elements"in a.static||"elements"in a.dynamic}function G(a,h){var _=Le();f(a+" in command "+(h||le())+(_==="unknown"?"":" called from "+_))}function Ae(a,h,_){a||G(h,_||le())}function oe(a,h,_,R){a in h||G("unknown parameter ("+a+")"+u(_)+". possible values: "+Object.keys(h).join(),R||le())}function Ce(a,h,_,R){b(a,h)||G("invalid parameter type"+u(_)+". expected "+h+", got "+typeof a,R||le())}function Ue(a){a()}function Be(a,h,_){a.texture?Z(a.texture._texture.internalformat,h,"unsupported texture format for attachment"):Z(a.renderbuffer._renderbuffer.format,_,"unsupported renderbuffer format for attachment")}var Ye=33071,rt=9728,ut=9984,Bt=9985,_t=9986,It=9987,qt=5120,Rt=5121,Yt=5122,Sr=5123,C0=5124,P0=5125,df=5126,mf=32819,pf=32820,vf=33635,gf=34042,k0=36193,Dt={};Dt[qt]=Dt[Rt]=1,Dt[Yt]=Dt[Sr]=Dt[k0]=Dt[vf]=Dt[mf]=Dt[pf]=2,Dt[C0]=Dt[P0]=Dt[df]=Dt[gf]=4;function yf(a,h){return a===pf||a===mf||a===vf?2:a===gf?4:Dt[a]*h}function _i(a){return!(a&a-1)&&!!a}function F0(a,h,_){var R,U=h.width,I=h.height,N=h.channels;s(U>0&&U<=_.maxTextureSize&&I>0&&I<=_.maxTextureSize,"invalid texture shape"),(a.wrapS!==Ye||a.wrapT!==Ye)&&s(_i(U)&&_i(I),"incompatible wrap mode for texture, both width and height must be power of 2"),h.mipmask===1?U!==1&&I!==1&&s(a.minFilter!==ut&&a.minFilter!==_t&&a.minFilter!==Bt&&a.minFilter!==It,"min filter requires mipmap"):(s(_i(U)&&_i(I),"texture must be a square power of 2 to support mipmapping"),s(h.mipmask===(U<<1)-1,"missing or incomplete mipmap data")),h.type===df&&(_.extensions.indexOf("oes_texture_float_linear")<0&&s(a.minFilter===rt&&a.magFilter===rt,"filter not supported, must enable oes_texture_float_linear"),s(!a.genMipmaps,"mipmap generation not supported with float textures"));var Q=h.images;for(R=0;R<16;++R)if(Q[R]){var Y=U>>R,ne=I>>R;s(h.mipmask&1<<R,"missing mipmap data");var ie=Q[R];if(s(ie.width===Y&&ie.height===ne,"invalid shape for mip images"),s(ie.format===h.format&&ie.internalformat===h.internalformat&&ie.type===h.type,"incompatible type for mip image"),!ie.compressed)if(ie.data){var re=Math.ceil(yf(ie.type,N)*Y/ie.unpackAlignment)*ie.unpackAlignment;s(ie.data.byteLength===re*ne,"invalid data for image, buffer size is inconsistent with image format")}else ie.element||ie.copy}else a.genMipmaps||s((h.mipmask&1<<R)===0,"extra mipmap data");h.compressed&&s(!a.genMipmaps,"mipmap generation for compressed images not supported")}function L0(a,h,_,R){var U=a.width,I=a.height,N=a.channels;s(U>0&&U<=R.maxTextureSize&&I>0&&I<=R.maxTextureSize,"invalid texture shape"),s(U===I,"cube map must be square"),s(h.wrapS===Ye&&h.wrapT===Ye,"wrap mode not supported by cube map");for(var Q=0;Q<_.length;++Q){var Y=_[Q];s(Y.width===U&&Y.height===I,"inconsistent cube map face shape"),h.genMipmaps&&(s(!Y.compressed,"can not generate mipmap for compressed textures"),s(Y.mipmask===1,"can not specify mipmaps and generate mipmaps"));for(var ne=Y.images,ie=0;ie<16;++ie){var re=ne[ie];if(re){var fe=U>>ie,K=I>>ie;s(Y.mipmask&1<<ie,"missing mipmap data"),s(re.width===fe&&re.height===K,"invalid shape for mip images"),s(re.format===a.format&&re.internalformat===a.internalformat&&re.type===a.type,"incompatible type for mip image"),re.compressed||(re.data?s(re.data.byteLength===fe*K*Math.max(yf(re.type,N),re.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):re.element||re.copy)}}}}var d=r(s,{optional:Ue,raise:f,commandRaise:G,command:Ae,parameter:c,commandParameter:oe,constructor:Se,type:S,commandType:Ce,isTypedArray:v,nni:D,oneOf:Z,shaderError:nt,linkError:ke,callSite:Le,saveCommandRef:it,saveDrawInfo:tt,framebufferFormat:Be,guessCommand:le,texture2D:F0,textureCube:L0}),z0=0,I0=0,R0=5,D0=6;function Fn(a,h){this.id=z0++,this.type=a,this.data=h}function xf(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function wr(a){if(a.length===0)return[];var h=a.charAt(0),_=a.charAt(a.length-1);if(a.length>1&&h===_&&(h==='"'||h==="'"))return['"'+xf(a.substr(1,a.length-2))+'"'];var R=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(a);if(R)return wr(a.substr(0,R.index)).concat(wr(R[1])).concat(wr(a.substr(R.index+R[0].length)));var U=a.split(".");if(U.length===1)return['"'+xf(a)+'"'];for(var I=[],N=0;N<U.length;++N)I=I.concat(wr(U[N]));return I}function bf(a){return"["+wr(a).join("][")+"]"}function M0(a,h){return new Fn(a,bf(h+""))}function O0(a){return typeof a=="function"&&!a._reglType||a instanceof Fn}function _f(a,h){if(typeof a=="function")return new Fn(I0,a);if(typeof a=="number"||typeof a=="boolean")return new Fn(R0,a);if(Array.isArray(a))return new Fn(D0,a.map(function(_,R){return _f(_,h+"["+R+"]")}));if(a instanceof Fn)return a;d(!1,"invalid option type in uniform "+h)}var Mt={DynamicVariable:Fn,define:M0,isDynamic:O0,unbox:_f,accessor:bf},Mo={next:typeof requestAnimationFrame=="function"?function(a){return requestAnimationFrame(a)}:function(a){return setTimeout(a,16)},cancel:typeof cancelAnimationFrame=="function"?function(a){return cancelAnimationFrame(a)}:clearTimeout},Sf=typeof performance<"u"&&performance.now?function(){return performance.now()}:function(){return+new Date};function G0(){var a={"":0},h=[""];return{id:function(_){var R=a[_];return R||(R=a[_]=h.length,h.push(_),R)},str:function(_){return h[_]}}}function N0(a,h,_){var R=document.createElement("canvas");r(R.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),a.appendChild(R),a===document.body&&(R.style.position="absolute",r(a.style,{margin:0,padding:0}));function U(){var Q=window.innerWidth,Y=window.innerHeight;if(a!==document.body){var ne=R.getBoundingClientRect();Q=ne.right-ne.left,Y=ne.bottom-ne.top}R.width=_*Q,R.height=_*Y}var I;a!==document.body&&typeof ResizeObserver=="function"?(I=new ResizeObserver(function(){setTimeout(U)}),I.observe(a)):window.addEventListener("resize",U,!1);function N(){I?I.disconnect():window.removeEventListener("resize",U),a.removeChild(R)}return U(),{canvas:R,onDestroy:N}}function B0(a,h){function _(R){try{return a.getContext(R,h)}catch{return null}}return _("webgl")||_("experimental-webgl")||_("webgl-experimental")}function V0(a){return typeof a.nodeName=="string"&&typeof a.appendChild=="function"&&typeof a.getBoundingClientRect=="function"}function $0(a){return typeof a.drawArrays=="function"||typeof a.drawElements=="function"}function wf(a){return typeof a=="string"?a.split():(d(Array.isArray(a),"invalid extension array"),a)}function Tf(a){return typeof a=="string"?(d(typeof document<"u","not supported outside of DOM"),document.querySelector(a)):a}function U0(a){var h=a||{},_,R,U,I,N={},Q=[],Y=[],ne=typeof window>"u"?1:window.devicePixelRatio,ie=!1,re=function(te){te&&d.raise(te)},fe=function(){};if(typeof h=="string"?(d(typeof document<"u","selector queries only supported in DOM enviroments"),_=document.querySelector(h),d(_,"invalid query string for element")):typeof h=="object"?V0(h)?_=h:$0(h)?(I=h,U=I.canvas):(d.constructor(h),"gl"in h?I=h.gl:"canvas"in h?U=Tf(h.canvas):"container"in h&&(R=Tf(h.container)),"attributes"in h&&(N=h.attributes,d.type(N,"object","invalid context attributes")),"extensions"in h&&(Q=wf(h.extensions)),"optionalExtensions"in h&&(Y=wf(h.optionalExtensions)),"onDone"in h&&(d.type(h.onDone,"function","invalid or missing onDone callback"),re=h.onDone),"profile"in h&&(ie=!!h.profile),"pixelRatio"in h&&(ne=+h.pixelRatio,d(ne>0,"invalid pixel ratio"))):d.raise("invalid arguments to regl"),_&&(_.nodeName.toLowerCase()==="canvas"?U=_:R=_),!I){if(!U){d(typeof document<"u","must manually specify webgl context outside of DOM environments");var K=N0(R||document.body,re,ne);if(!K)return null;U=K.canvas,fe=K.onDestroy}N.premultipliedAlpha===void 0&&(N.premultipliedAlpha=!0),I=B0(U,N)}return I?{gl:I,canvas:U,container:R,extensions:Q,optionalExtensions:Y,pixelRatio:ne,profile:ie,onDone:re,onDestroy:fe}:(fe(),re("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function j0(a,h){var _={};function R(N){d.type(N,"string","extension name must be string");var Q=N.toLowerCase(),Y;try{Y=_[Q]=a.getExtension(Q)}catch{}return!!Y}for(var U=0;U<h.extensions.length;++U){var I=h.extensions[U];if(!R(I))return h.onDestroy(),h.onDone('"'+I+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return h.optionalExtensions.forEach(R),{extensions:_,restore:function(){Object.keys(_).forEach(function(N){if(_[N]&&!R(N))throw new Error("(regl): error restoring extension "+N)})}}}function Ot(a,h){for(var _=Array(a),R=0;R<a;++R)_[R]=h(R);return _}var X0=5120,H0=5121,W0=5122,q0=5123,Y0=5124,Z0=5125,Q0=5126;function K0(a){for(var h=16;h<=1<<28;h*=16)if(a<=h)return h;return 0}function Af(a){var h,_;return h=(a>65535)<<4,a>>>=h,_=(a>255)<<3,a>>>=_,h|=_,_=(a>15)<<2,a>>>=_,h|=_,_=(a>3)<<1,a>>>=_,h|=_,h|a>>1}function Ef(){var a=Ot(8,function(){return[]});function h(I){var N=K0(I),Q=a[Af(N)>>2];return Q.length>0?Q.pop():new ArrayBuffer(N)}function _(I){a[Af(I.byteLength)>>2].push(I)}function R(I,N){var Q=null;switch(I){case X0:Q=new Int8Array(h(N),0,N);break;case H0:Q=new Uint8Array(h(N),0,N);break;case W0:Q=new Int16Array(h(2*N),0,N);break;case q0:Q=new Uint16Array(h(2*N),0,N);break;case Y0:Q=new Int32Array(h(4*N),0,N);break;case Z0:Q=new Uint32Array(h(4*N),0,N);break;case Q0:Q=new Float32Array(h(4*N),0,N);break;default:return null}return Q.length!==N?Q.subarray(0,N):Q}function U(I){_(I.buffer)}return{alloc:h,free:_,allocType:R,freeType:U}}var ht=Ef();ht.zero=Ef();var J0=3408,ev=3410,tv=3411,nv=3412,rv=3413,iv=3414,ov=3415,av=33901,sv=33902,fv=3379,uv=3386,cv=34921,lv=36347,hv=36348,dv=35661,mv=35660,pv=34930,vv=36349,gv=34076,yv=34024,xv=7936,bv=7937,_v=7938,Sv=35724,wv=34047,Tv=36063,Av=34852,Si=3553,Cf=34067,Ev=34069,Cv=33984,Tr=6408,Oo=5126,Pf=5121,Go=36160,Pv=36053,kv=36064,Fv=16384,Lv=function(a,h){var _=1;h.ext_texture_filter_anisotropic&&(_=a.getParameter(wv));var R=1,U=1;h.webgl_draw_buffers&&(R=a.getParameter(Av),U=a.getParameter(Tv));var I=!!h.oes_texture_float;if(I){var N=a.createTexture();a.bindTexture(Si,N),a.texImage2D(Si,0,Tr,1,1,0,Tr,Oo,null);var Q=a.createFramebuffer();if(a.bindFramebuffer(Go,Q),a.framebufferTexture2D(Go,kv,Si,N,0),a.bindTexture(Si,null),a.checkFramebufferStatus(Go)!==Pv)I=!1;else{a.viewport(0,0,1,1),a.clearColor(1,0,0,1),a.clear(Fv);var Y=ht.allocType(Oo,4);a.readPixels(0,0,1,1,Tr,Oo,Y),a.getError()?I=!1:(a.deleteFramebuffer(Q),a.deleteTexture(N),I=Y[0]===1),ht.freeType(Y)}}var ne=typeof navigator<"u"&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent)),ie=!0;if(!ne){var re=a.createTexture(),fe=ht.allocType(Pf,36);a.activeTexture(Cv),a.bindTexture(Cf,re),a.texImage2D(Ev,0,Tr,3,3,0,Tr,Pf,fe),ht.freeType(fe),a.bindTexture(Cf,null),a.deleteTexture(re),ie=!a.getError()}return{colorBits:[a.getParameter(ev),a.getParameter(tv),a.getParameter(nv),a.getParameter(rv)],depthBits:a.getParameter(iv),stencilBits:a.getParameter(ov),subpixelBits:a.getParameter(J0),extensions:Object.keys(h).filter(function(K){return!!h[K]}),maxAnisotropic:_,maxDrawbuffers:R,maxColorAttachments:U,pointSizeDims:a.getParameter(av),lineWidthDims:a.getParameter(sv),maxViewportDims:a.getParameter(uv),maxCombinedTextureUnits:a.getParameter(dv),maxCubeMapSize:a.getParameter(gv),maxRenderbufferSize:a.getParameter(yv),maxTextureUnits:a.getParameter(pv),maxTextureSize:a.getParameter(fv),maxAttributes:a.getParameter(cv),maxVertexUniforms:a.getParameter(lv),maxVertexTextureUnits:a.getParameter(mv),maxVaryingVectors:a.getParameter(hv),maxFragmentUniforms:a.getParameter(vv),glsl:a.getParameter(Sv),renderer:a.getParameter(bv),vendor:a.getParameter(xv),version:a.getParameter(_v),readFloat:I,npotTextureCube:ie}};function Zt(a){return!!a&&typeof a=="object"&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&typeof a.offset=="number"&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||n(a.data))}var Gt=function(a){return Object.keys(a).map(function(h){return a[h]})},wi={shape:Dv,flatten:Rv};function zv(a,h,_){for(var R=0;R<h;++R)_[R]=a[R]}function Iv(a,h,_,R){for(var U=0,I=0;I<h;++I)for(var N=a[I],Q=0;Q<_;++Q)R[U++]=N[Q]}function kf(a,h,_,R,U,I){for(var N=I,Q=0;Q<h;++Q)for(var Y=a[Q],ne=0;ne<_;++ne)for(var ie=Y[ne],re=0;re<R;++re)U[N++]=ie[re]}function Ff(a,h,_,R,U){for(var I=1,N=_+1;N<h.length;++N)I*=h[N];var Q=h[_];if(h.length-_===4){var Y=h[_+1],ne=h[_+2],ie=h[_+3];for(N=0;N<Q;++N)kf(a[N],Y,ne,ie,R,U),U+=I}else for(N=0;N<Q;++N)Ff(a[N],h,_+1,R,U),U+=I}function Rv(a,h,_,R){var U=1;if(h.length)for(var I=0;I<h.length;++I)U*=h[I];else U=0;var N=R||ht.allocType(_,U);switch(h.length){case 0:break;case 1:zv(a,h[0],N);break;case 2:Iv(a,h[0],h[1],N);break;case 3:kf(a,h[0],h[1],h[2],N,0);break;default:Ff(a,h,0,N,0)}return N}function Dv(a){for(var h=[],_=a;_.length;_=_[0])h.push(_.length);return h}var No={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Mv=5120,Ov=5122,Gv=5124,Nv=5121,Bv=5123,Vv=5125,$v=5126,Uv=5126,Ln={int8:Mv,int16:Ov,int32:Gv,uint8:Nv,uint16:Bv,uint32:Vv,float:$v,float32:Uv},jv=35048,Xv=35040,Ti={dynamic:jv,stream:Xv,static:35044},Bo=wi.flatten,Lf=wi.shape,zf=35044,Hv=35040,Vo=5121,$o=5126,gn=[];gn[5120]=1,gn[5122]=2,gn[5124]=4,gn[5121]=1,gn[5123]=2,gn[5125]=4,gn[5126]=4;function Ai(a){return No[Object.prototype.toString.call(a)]|0}function If(a,h){for(var _=0;_<h.length;++_)a[_]=h[_]}function Rf(a,h,_,R,U,I,N){for(var Q=0,Y=0;Y<_;++Y)for(var ne=0;ne<R;++ne)a[Q++]=h[U*Y+I*ne+N]}function Wv(a,h,_,R){var U=0,I={};function N(P){this.id=U++,this.buffer=a.createBuffer(),this.type=P,this.usage=zf,this.byteLength=0,this.dimension=1,this.dtype=Vo,this.persistentData=null,_.profile&&(this.stats={size:0})}N.prototype.bind=function(){a.bindBuffer(this.type,this.buffer)},N.prototype.destroy=function(){fe(this)};var Q=[];function Y(P,O){var ee=Q.pop();return ee||(ee=new N(P)),ee.bind(),re(ee,O,Hv,0,1,!1),ee}function ne(P){Q.push(P)}function ie(P,O,ee){P.byteLength=O.byteLength,a.bufferData(P.type,O,ee)}function re(P,O,ee,ge,W,pe){var de;if(P.usage=ee,Array.isArray(O)){if(P.dtype=ge||$o,O.length>0){var Pe;if(Array.isArray(O[0])){de=Lf(O);for(var j=1,$=1;$<de.length;++$)j*=de[$];P.dimension=j,Pe=Bo(O,de,P.dtype),ie(P,Pe,ee),pe?P.persistentData=Pe:ht.freeType(Pe)}else if(typeof O[0]=="number"){P.dimension=W;var be=ht.allocType(P.dtype,O.length);If(be,O),ie(P,be,ee),pe?P.persistentData=be:ht.freeType(be)}else n(O[0])?(P.dimension=O[0].length,P.dtype=ge||Ai(O[0])||$o,Pe=Bo(O,[O.length,O[0].length],P.dtype),ie(P,Pe,ee),pe?P.persistentData=Pe:ht.freeType(Pe)):d.raise("invalid buffer data")}}else if(n(O))P.dtype=ge||Ai(O),P.dimension=W,ie(P,O,ee),pe&&(P.persistentData=new Uint8Array(new Uint8Array(O.buffer)));else if(Zt(O)){de=O.shape;var ue=O.stride,J=O.offset,ce=0,he=0,Oe=0,De=0;de.length===1?(ce=de[0],he=1,Oe=ue[0],De=0):de.length===2?(ce=de[0],he=de[1],Oe=ue[0],De=ue[1]):d.raise("invalid shape"),P.dtype=ge||Ai(O.data)||$o,P.dimension=he;var me=ht.allocType(P.dtype,ce*he);Rf(me,O.data,ce,he,Oe,De,J),ie(P,me,ee),pe?P.persistentData=me:ht.freeType(me)}else O instanceof ArrayBuffer?(P.dtype=Vo,P.dimension=W,ie(P,O,ee),pe&&(P.persistentData=new Uint8Array(new Uint8Array(O)))):d.raise("invalid buffer data")}function fe(P){h.bufferCount--,R(P);var O=P.buffer;d(O,"buffer must not be deleted already"),a.deleteBuffer(O),P.buffer=null,delete I[P.id]}function K(P,O,ee,ge){h.bufferCount++;var W=new N(O);I[W.id]=W;function pe(j){var $=zf,be=null,ue=0,J=0,ce=1;return Array.isArray(j)||n(j)||Zt(j)||j instanceof ArrayBuffer?be=j:typeof j=="number"?ue=j|0:j&&(d.type(j,"object","buffer arguments must be an object, a number or an array"),"data"in j&&(d(be===null||Array.isArray(be)||n(be)||Zt(be),"invalid data for buffer"),be=j.data),"usage"in j&&(d.parameter(j.usage,Ti,"invalid buffer usage"),$=Ti[j.usage]),"type"in j&&(d.parameter(j.type,Ln,"invalid buffer type"),J=Ln[j.type]),"dimension"in j&&(d.type(j.dimension,"number","invalid dimension"),ce=j.dimension|0),"length"in j&&(d.nni(ue,"buffer length must be a nonnegative integer"),ue=j.length|0)),W.bind(),be?re(W,be,$,J,ce,ge):(ue&&a.bufferData(W.type,ue,$),W.dtype=J||Vo,W.usage=$,W.dimension=ce,W.byteLength=ue),_.profile&&(W.stats.size=W.byteLength*gn[W.dtype]),pe}function de(j,$){d($+j.byteLength<=W.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+j.byteLength+" starting from offset "+$+" to a buffer of size "+W.byteLength),a.bufferSubData(W.type,$,j)}function Pe(j,$){var be=($||0)|0,ue;if(W.bind(),n(j)||j instanceof ArrayBuffer)de(j,be);else if(Array.isArray(j)){if(j.length>0)if(typeof j[0]=="number"){var J=ht.allocType(W.dtype,j.length);If(J,j),de(J,be),ht.freeType(J)}else if(Array.isArray(j[0])||n(j[0])){ue=Lf(j);var ce=Bo(j,ue,W.dtype);de(ce,be),ht.freeType(ce)}else d.raise("invalid buffer data")}else if(Zt(j)){ue=j.shape;var he=j.stride,Oe=0,De=0,me=0,ve=0;ue.length===1?(Oe=ue[0],De=1,me=he[0],ve=0):ue.length===2?(Oe=ue[0],De=ue[1],me=he[0],ve=he[1]):d.raise("invalid shape");var ze=Array.isArray(j.data)?W.dtype:Ai(j.data),Ge=ht.allocType(ze,Oe*De);Rf(Ge,j.data,Oe,De,me,ve,j.offset),de(Ge,be),ht.freeType(Ge)}else d.raise("invalid data for buffer subdata");return pe}return ee||pe(P),pe._reglType="buffer",pe._buffer=W,pe.subdata=Pe,_.profile&&(pe.stats=W.stats),pe.destroy=function(){fe(W)},pe}function te(){Gt(I).forEach(function(P){P.buffer=a.createBuffer(),a.bindBuffer(P.type,P.buffer),a.bufferData(P.type,P.persistentData||P.byteLength,P.usage)})}return _.profile&&(h.getTotalBufferSize=function(){var P=0;return Object.keys(I).forEach(function(O){P+=I[O].stats.size}),P}),{create:K,createStream:Y,destroyStream:ne,clear:function(){Gt(I).forEach(fe),Q.forEach(fe)},getBuffer:function(P){return P&&P._buffer instanceof N?P._buffer:null},restore:te,_initBuffer:re}}var qv=0,Yv=0,Zv=1,Qv=1,Kv=4,Jv=4,yn={points:qv,point:Yv,lines:Zv,line:Qv,triangles:Kv,triangle:Jv,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},eg=0,tg=1,Ar=4,ng=5120,Zn=5121,Df=5122,Qn=5123,Mf=5124,zn=5125,Uo=34963,rg=35040,ig=35044;function og(a,h,_,R){var U={},I=0,N={uint8:Zn,uint16:Qn};h.oes_element_index_uint&&(N.uint32=zn);function Q(te){this.id=I++,U[this.id]=this,this.buffer=te,this.primType=Ar,this.vertCount=0,this.type=0}Q.prototype.bind=function(){this.buffer.bind()};var Y=[];function ne(te){var P=Y.pop();return P||(P=new Q(_.create(null,Uo,!0,!1)._buffer)),re(P,te,rg,-1,-1,0,0),P}function ie(te){Y.push(te)}function re(te,P,O,ee,ge,W,pe){te.buffer.bind();var de;if(P){var Pe=pe;!pe&&(!n(P)||Zt(P)&&!n(P.data))&&(Pe=h.oes_element_index_uint?zn:Qn),_._initBuffer(te.buffer,P,O,Pe,3)}else a.bufferData(Uo,W,O),te.buffer.dtype=de||Zn,te.buffer.usage=O,te.buffer.dimension=3,te.buffer.byteLength=W;if(de=pe,!pe){switch(te.buffer.dtype){case Zn:case ng:de=Zn;break;case Qn:case Df:de=Qn;break;case zn:case Mf:de=zn;break;default:d.raise("unsupported type for element array")}te.buffer.dtype=de}te.type=de,d(de!==zn||!!h.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var j=ge;j<0&&(j=te.buffer.byteLength,de===Qn?j>>=1:de===zn&&(j>>=2)),te.vertCount=j;var $=ee;if(ee<0){$=Ar;var be=te.buffer.dimension;be===1&&($=eg),be===2&&($=tg),be===3&&($=Ar)}te.primType=$}function fe(te){R.elementsCount--,d(te.buffer!==null,"must not double destroy elements"),delete U[te.id],te.buffer.destroy(),te.buffer=null}function K(te,P){var O=_.create(null,Uo,!0),ee=new Q(O._buffer);R.elementsCount++;function ge(W){if(!W)O(),ee.primType=Ar,ee.vertCount=0,ee.type=Zn;else if(typeof W=="number")O(W),ee.primType=Ar,ee.vertCount=W|0,ee.type=Zn;else{var pe=null,de=ig,Pe=-1,j=-1,$=0,be=0;Array.isArray(W)||n(W)||Zt(W)?pe=W:(d.type(W,"object","invalid arguments for elements"),"data"in W&&(pe=W.data,d(Array.isArray(pe)||n(pe)||Zt(pe),"invalid data for element buffer")),"usage"in W&&(d.parameter(W.usage,Ti,"invalid element buffer usage"),de=Ti[W.usage]),"primitive"in W&&(d.parameter(W.primitive,yn,"invalid element buffer primitive"),Pe=yn[W.primitive]),"count"in W&&(d(typeof W.count=="number"&&W.count>=0,"invalid vertex count for elements"),j=W.count|0),"type"in W&&(d.parameter(W.type,N,"invalid buffer type"),be=N[W.type]),"length"in W?$=W.length|0:($=j,be===Qn||be===Df?$*=2:(be===zn||be===Mf)&&($*=4))),re(ee,pe,de,Pe,j,$,be)}return ge}return ge(te),ge._reglType="elements",ge._elements=ee,ge.subdata=function(W,pe){return O.subdata(W,pe),ge},ge.destroy=function(){fe(ee)},ge}return{create:K,createStream:ne,destroyStream:ie,getElements:function(te){return typeof te=="function"&&te._elements instanceof Q?te._elements:null},clear:function(){Gt(U).forEach(fe)}}}var Of=new Float32Array(1),ag=new Uint32Array(Of.buffer),sg=5123;function Gf(a){for(var h=ht.allocType(sg,a.length),_=0;_<a.length;++_)if(isNaN(a[_]))h[_]=65535;else if(a[_]===1/0)h[_]=31744;else if(a[_]===-1/0)h[_]=64512;else{Of[0]=a[_];var R=ag[0],U=R>>>31<<15,I=(R<<1>>>24)-127,N=R>>13&1023;if(I<-24)h[_]=U;else if(I<-14){var Q=-14-I;h[_]=U+(N+1024>>Q)}else I>15?h[_]=U+31744:h[_]=U+(I+15<<10)+N}return h}function at(a){return Array.isArray(a)||n(a)}var Nf=function(a){return!(a&a-1)&&!!a},fg=34467,tn=3553,jo=34067,Ei=34069,In=6408,Xo=6406,Ci=6407,Er=6409,Pi=6410,Bf=32854,Ho=32855,Vf=36194,ug=32819,cg=32820,lg=33635,hg=34042,Wo=6402,ki=34041,qo=35904,Yo=35906,Kn=36193,Zo=33776,Qo=33777,Ko=33778,Jo=33779,$f=35986,Uf=35987,jf=34798,Xf=35840,Hf=35841,Wf=35842,qf=35843,Yf=36196,Jn=5121,ea=5123,ta=5125,Cr=5126,dg=10242,mg=10243,pg=10497,na=33071,vg=33648,gg=10240,yg=10241,ra=9728,xg=9729,ia=9984,Zf=9985,Qf=9986,oa=9987,bg=33170,Fi=4352,_g=4353,Sg=4354,wg=34046,Tg=3317,Ag=37440,Eg=37441,Cg=37443,Kf=37444,Pr=33984,Pg=[ia,Qf,Zf,oa],Li=[0,Er,Pi,Ci,In],Vt={};Vt[Er]=Vt[Xo]=Vt[Wo]=1,Vt[ki]=Vt[Pi]=2,Vt[Ci]=Vt[qo]=3,Vt[In]=Vt[Yo]=4;function er(a){return"[object "+a+"]"}var Jf=er("HTMLCanvasElement"),eu=er("OffscreenCanvas"),tu=er("CanvasRenderingContext2D"),nu=er("ImageBitmap"),ru=er("HTMLImageElement"),iu=er("HTMLVideoElement"),kg=Object.keys(No).concat([Jf,eu,tu,nu,ru,iu]),tr=[];tr[Jn]=1,tr[Cr]=4,tr[Kn]=2,tr[ea]=2,tr[ta]=4;var Tt=[];Tt[Bf]=2,Tt[Ho]=2,Tt[Vf]=2,Tt[ki]=4,Tt[Zo]=.5,Tt[Qo]=.5,Tt[Ko]=1,Tt[Jo]=1,Tt[$f]=.5,Tt[Uf]=1,Tt[jf]=1,Tt[Xf]=.5,Tt[Hf]=.25,Tt[Wf]=.5,Tt[qf]=.25,Tt[Yf]=.5;function ou(a){return Array.isArray(a)&&(a.length===0||typeof a[0]=="number")}function au(a){if(!Array.isArray(a))return!1;var h=a.length;return!(h===0||!at(a[0]))}function Rn(a){return Object.prototype.toString.call(a)}function su(a){return Rn(a)===Jf}function fu(a){return Rn(a)===eu}function Fg(a){return Rn(a)===tu}function Lg(a){return Rn(a)===nu}function zg(a){return Rn(a)===ru}function Ig(a){return Rn(a)===iu}function aa(a){if(!a)return!1;var h=Rn(a);return kg.indexOf(h)>=0?!0:ou(a)||au(a)||Zt(a)}function uu(a){return No[Object.prototype.toString.call(a)]|0}function Rg(a,h){var _=h.length;switch(a.type){case Jn:case ea:case ta:case Cr:var R=ht.allocType(a.type,_);R.set(h),a.data=R;break;case Kn:a.data=Gf(h);break;default:d.raise("unsupported texture type, must specify a typed array")}}function cu(a,h){return ht.allocType(a.type===Kn?Cr:a.type,h)}function lu(a,h){a.type===Kn?(a.data=Gf(h),ht.freeType(h)):a.data=h}function Dg(a,h,_,R,U,I){for(var N=a.width,Q=a.height,Y=a.channels,ne=N*Q*Y,ie=cu(a,ne),re=0,fe=0;fe<Q;++fe)for(var K=0;K<N;++K)for(var te=0;te<Y;++te)ie[re++]=h[_*K+R*fe+U*te+I];lu(a,ie)}function zi(a,h,_,R,U,I){var N;if(typeof Tt[a]<"u"?N=Tt[a]:N=Vt[a]*tr[h],I&&(N*=6),U){for(var Q=0,Y=_;Y>=1;)Q+=N*Y*Y,Y/=2;return Q}else return N*_*R}function Mg(a,h,_,R,U,I,N){var Q={"don't care":Fi,"dont care":Fi,nice:Sg,fast:_g},Y={repeat:pg,clamp:na,mirror:vg},ne={nearest:ra,linear:xg},ie=r({mipmap:oa,"nearest mipmap nearest":ia,"linear mipmap nearest":Zf,"nearest mipmap linear":Qf,"linear mipmap linear":oa},ne),re={none:0,browser:Kf},fe={uint8:Jn,rgba4:ug,rgb565:lg,"rgb5 a1":cg},K={alpha:Xo,luminance:Er,"luminance alpha":Pi,rgb:Ci,rgba:In,rgba4:Bf,"rgb5 a1":Ho,rgb565:Vf},te={};h.ext_srgb&&(K.srgb=qo,K.srgba=Yo),h.oes_texture_float&&(fe.float32=fe.float=Cr),h.oes_texture_half_float&&(fe.float16=fe["half float"]=Kn),h.webgl_depth_texture&&(r(K,{depth:Wo,"depth stencil":ki}),r(fe,{uint16:ea,uint32:ta,"depth stencil":hg})),h.webgl_compressed_texture_s3tc&&r(te,{"rgb s3tc dxt1":Zo,"rgba s3tc dxt1":Qo,"rgba s3tc dxt3":Ko,"rgba s3tc dxt5":Jo}),h.webgl_compressed_texture_atc&&r(te,{"rgb atc":$f,"rgba atc explicit alpha":Uf,"rgba atc interpolated alpha":jf}),h.webgl_compressed_texture_pvrtc&&r(te,{"rgb pvrtc 4bppv1":Xf,"rgb pvrtc 2bppv1":Hf,"rgba pvrtc 4bppv1":Wf,"rgba pvrtc 2bppv1":qf}),h.webgl_compressed_texture_etc1&&(te["rgb etc1"]=Yf);var P=Array.prototype.slice.call(a.getParameter(fg));Object.keys(te).forEach(function(y){var M=te[y];P.indexOf(M)>=0&&(K[y]=M)});var O=Object.keys(K);_.textureFormats=O;var ee=[];Object.keys(K).forEach(function(y){var M=K[y];ee[M]=y});var ge=[];Object.keys(fe).forEach(function(y){var M=fe[y];ge[M]=y});var W=[];Object.keys(ne).forEach(function(y){var M=ne[y];W[M]=y});var pe=[];Object.keys(ie).forEach(function(y){var M=ie[y];pe[M]=y});var de=[];Object.keys(Y).forEach(function(y){var M=Y[y];de[M]=y});var Pe=O.reduce(function(y,M){var z=K[M];return z===Er||z===Xo||z===Er||z===Pi||z===Wo||z===ki||h.ext_srgb&&(z===qo||z===Yo)?y[z]=z:z===Ho||M.indexOf("rgba")>=0?y[z]=In:y[z]=Ci,y},{});function j(){this.internalformat=In,this.format=In,this.type=Jn,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=Kf,this.width=0,this.height=0,this.channels=0}function $(y,M){y.internalformat=M.internalformat,y.format=M.format,y.type=M.type,y.compressed=M.compressed,y.premultiplyAlpha=M.premultiplyAlpha,y.flipY=M.flipY,y.unpackAlignment=M.unpackAlignment,y.colorSpace=M.colorSpace,y.width=M.width,y.height=M.height,y.channels=M.channels}function be(y,M){if(!(typeof M!="object"||!M)){if("premultiplyAlpha"in M&&(d.type(M.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),y.premultiplyAlpha=M.premultiplyAlpha),"flipY"in M&&(d.type(M.flipY,"boolean","invalid texture flip"),y.flipY=M.flipY),"alignment"in M&&(d.oneOf(M.alignment,[1,2,4,8],"invalid texture unpack alignment"),y.unpackAlignment=M.alignment),"colorSpace"in M&&(d.parameter(M.colorSpace,re,"invalid colorSpace"),y.colorSpace=re[M.colorSpace]),"type"in M){var z=M.type;d(h.oes_texture_float||!(z==="float"||z==="float32"),"you must enable the OES_texture_float extension in order to use floating point textures."),d(h.oes_texture_half_float||!(z==="half float"||z==="float16"),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),d(h.webgl_depth_texture||!(z==="uint16"||z==="uint32"||z==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),d.parameter(z,fe,"invalid texture type"),y.type=fe[z]}var xe=y.width,He=y.height,m=y.channels,l=!1;"shape"in M?(d(Array.isArray(M.shape)&&M.shape.length>=2,"shape must be an array"),xe=M.shape[0],He=M.shape[1],M.shape.length===3&&(m=M.shape[2],d(m>0&&m<=4,"invalid number of channels"),l=!0),d(xe>=0&&xe<=_.maxTextureSize,"invalid width"),d(He>=0&&He<=_.maxTextureSize,"invalid height")):("radius"in M&&(xe=He=M.radius,d(xe>=0&&xe<=_.maxTextureSize,"invalid radius")),"width"in M&&(xe=M.width,d(xe>=0&&xe<=_.maxTextureSize,"invalid width")),"height"in M&&(He=M.height,d(He>=0&&He<=_.maxTextureSize,"invalid height")),"channels"in M&&(m=M.channels,d(m>0&&m<=4,"invalid number of channels"),l=!0)),y.width=xe|0,y.height=He|0,y.channels=m|0;var w=!1;if("format"in M){var C=M.format;d(h.webgl_depth_texture||!(C==="depth"||C==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),d.parameter(C,K,"invalid texture format");var k=y.internalformat=K[C];y.format=Pe[k],C in fe&&("type"in M||(y.type=fe[C])),C in te&&(y.compressed=!0),w=!0}!l&&w?y.channels=Vt[y.format]:l&&!w?y.channels!==Li[y.format]&&(y.format=y.internalformat=Li[y.channels]):w&&l&&d(y.channels===Vt[y.format],"number of channels inconsistent with specified format")}}function ue(y){a.pixelStorei(Ag,y.flipY),a.pixelStorei(Eg,y.premultiplyAlpha),a.pixelStorei(Cg,y.colorSpace),a.pixelStorei(Tg,y.unpackAlignment)}function J(){j.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function ce(y,M){var z=null;if(aa(M)?z=M:M&&(d.type(M,"object","invalid pixel data type"),be(y,M),"x"in M&&(y.xOffset=M.x|0),"y"in M&&(y.yOffset=M.y|0),aa(M.data)&&(z=M.data)),d(!y.compressed||z instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),M.copy){d(!z,"can not specify copy and data field for the same texture");var xe=U.viewportWidth,He=U.viewportHeight;y.width=y.width||xe-y.xOffset,y.height=y.height||He-y.yOffset,y.needsCopy=!0,d(y.xOffset>=0&&y.xOffset<xe&&y.yOffset>=0&&y.yOffset<He&&y.width>0&&y.width<=xe&&y.height>0&&y.height<=He,"copy texture read out of bounds")}else if(!z)y.width=y.width||1,y.height=y.height||1,y.channels=y.channels||4;else if(n(z))y.channels=y.channels||4,y.data=z,!("type"in M)&&y.type===Jn&&(y.type=uu(z));else if(ou(z))y.channels=y.channels||4,Rg(y,z),y.alignment=1,y.needsFree=!0;else if(Zt(z)){var m=z.data;!Array.isArray(m)&&y.type===Jn&&(y.type=uu(m));var l=z.shape,w=z.stride,C,k,A,T,E,p;l.length===3?(A=l[2],p=w[2]):(d(l.length===2,"invalid ndarray pixel data, must be 2 or 3D"),A=1,p=1),C=l[0],k=l[1],T=w[0],E=w[1],y.alignment=1,y.width=C,y.height=k,y.channels=A,y.format=y.internalformat=Li[A],y.needsFree=!0,Dg(y,m,T,E,p,z.offset)}else if(su(z)||fu(z)||Fg(z))su(z)||fu(z)?y.element=z:y.element=z.canvas,y.width=y.element.width,y.height=y.element.height,y.channels=4;else if(Lg(z))y.element=z,y.width=z.width,y.height=z.height,y.channels=4;else if(zg(z))y.element=z,y.width=z.naturalWidth,y.height=z.naturalHeight,y.channels=4;else if(Ig(z))y.element=z,y.width=z.videoWidth,y.height=z.videoHeight,y.channels=4;else if(au(z)){var x=y.width||z[0].length,g=y.height||z.length,L=y.channels;at(z[0][0])?L=L||z[0][0].length:L=L||1;for(var F=wi.shape(z),V=1,X=0;X<F.length;++X)V*=F[X];var se=cu(y,V);wi.flatten(z,F,"",se),lu(y,se),y.alignment=1,y.width=x,y.height=g,y.channels=L,y.format=y.internalformat=Li[L],y.needsFree=!0}y.type===Cr?d(_.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):y.type===Kn&&d(_.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function he(y,M,z){var xe=y.element,He=y.data,m=y.internalformat,l=y.format,w=y.type,C=y.width,k=y.height;ue(y),xe?a.texImage2D(M,z,l,l,w,xe):y.compressed?a.compressedTexImage2D(M,z,m,C,k,0,He):y.needsCopy?(R(),a.copyTexImage2D(M,z,l,y.xOffset,y.yOffset,C,k,0)):a.texImage2D(M,z,l,C,k,0,l,w,He||null)}function Oe(y,M,z,xe,He){var m=y.element,l=y.data,w=y.internalformat,C=y.format,k=y.type,A=y.width,T=y.height;ue(y),m?a.texSubImage2D(M,He,z,xe,C,k,m):y.compressed?a.compressedTexSubImage2D(M,He,z,xe,w,A,T,l):y.needsCopy?(R(),a.copyTexSubImage2D(M,He,z,xe,y.xOffset,y.yOffset,A,T)):a.texSubImage2D(M,He,z,xe,A,T,C,k,l)}var De=[];function me(){return De.pop()||new J}function ve(y){y.needsFree&&ht.freeType(y.data),J.call(y),De.push(y)}function ze(){j.call(this),this.genMipmaps=!1,this.mipmapHint=Fi,this.mipmask=0,this.images=Array(16)}function Ge(y,M,z){var xe=y.images[0]=me();y.mipmask=1,xe.width=y.width=M,xe.height=y.height=z,xe.channels=y.channels=4}function We(y,M){var z=null;if(aa(M))z=y.images[0]=me(),$(z,y),ce(z,M),y.mipmask=1;else if(be(y,M),Array.isArray(M.mipmap))for(var xe=M.mipmap,He=0;He<xe.length;++He)z=y.images[He]=me(),$(z,y),z.width>>=He,z.height>>=He,ce(z,xe[He]),y.mipmask|=1<<He;else z=y.images[0]=me(),$(z,y),ce(z,M),y.mipmask=1;$(y,y.images[0]),y.compressed&&(y.internalformat===Zo||y.internalformat===Qo||y.internalformat===Ko||y.internalformat===Jo)&&d(y.width%4===0&&y.height%4===0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function st(y,M){for(var z=y.images,xe=0;xe<z.length;++xe){if(!z[xe])return;he(z[xe],M,xe)}}var ft=[];function Ze(){var y=ft.pop()||new ze;j.call(y),y.mipmask=0;for(var M=0;M<16;++M)y.images[M]=null;return y}function pt(y){for(var M=y.images,z=0;z<M.length;++z)M[z]&&ve(M[z]),M[z]=null;ft.push(y)}function ot(){this.minFilter=ra,this.magFilter=ra,this.wrapS=na,this.wrapT=na,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=Fi}function mt(y,M){if("min"in M){var z=M.min;d.parameter(z,ie),y.minFilter=ie[z],Pg.indexOf(y.minFilter)>=0&&!("faces"in M)&&(y.genMipmaps=!0)}if("mag"in M){var xe=M.mag;d.parameter(xe,ne),y.magFilter=ne[xe]}var He=y.wrapS,m=y.wrapT;if("wrap"in M){var l=M.wrap;typeof l=="string"?(d.parameter(l,Y),He=m=Y[l]):Array.isArray(l)&&(d.parameter(l[0],Y),d.parameter(l[1],Y),He=Y[l[0]],m=Y[l[1]])}else{if("wrapS"in M){var w=M.wrapS;d.parameter(w,Y),He=Y[w]}if("wrapT"in M){var C=M.wrapT;d.parameter(C,Y),m=Y[C]}}if(y.wrapS=He,y.wrapT=m,"anisotropic"in M){var k=M.anisotropic;d(typeof k=="number"&&k>=1&&k<=_.maxAnisotropic,"aniso samples must be between 1 and "),y.anisotropic=M.anisotropic}if("mipmap"in M){var A=!1;switch(typeof M.mipmap){case"string":d.parameter(M.mipmap,Q,"invalid mipmap hint"),y.mipmapHint=Q[M.mipmap],y.genMipmaps=!0,A=!0;break;case"boolean":A=y.genMipmaps=M.mipmap;break;case"object":d(Array.isArray(M.mipmap),"invalid mipmap type"),y.genMipmaps=!1,A=!0;break;default:d.raise("invalid mipmap type")}A&&!("min"in M)&&(y.minFilter=ia)}}function vt(y,M){a.texParameteri(M,yg,y.minFilter),a.texParameteri(M,gg,y.magFilter),a.texParameteri(M,dg,y.wrapS),a.texParameteri(M,mg,y.wrapT),h.ext_texture_filter_anisotropic&&a.texParameteri(M,wg,y.anisotropic),y.genMipmaps&&(a.hint(bg,y.mipmapHint),a.generateMipmap(M))}var gt=0,St={},At=_.maxTextureUnits,ct=Array(At).map(function(){return null});function Ve(y){j.call(this),this.mipmask=0,this.internalformat=In,this.id=gt++,this.refCount=1,this.target=y,this.texture=a.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new ot,N.profile&&(this.stats={size:0})}function Et(y){a.activeTexture(Pr),a.bindTexture(y.target,y.texture)}function Ke(){var y=ct[0];y?a.bindTexture(y.target,y.texture):a.bindTexture(tn,null)}function Fe(y){var M=y.texture;d(M,"must not double destroy texture");var z=y.unit,xe=y.target;z>=0&&(a.activeTexture(Pr+z),a.bindTexture(xe,null),ct[z]=null),a.deleteTexture(M),y.texture=null,y.params=null,y.pixels=null,y.refCount=0,delete St[y.id],I.textureCount--}r(Ve.prototype,{bind:function(){var y=this;y.bindCount+=1;var M=y.unit;if(M<0){for(var z=0;z<At;++z){var xe=ct[z];if(xe){if(xe.bindCount>0)continue;xe.unit=-1}ct[z]=y,M=z;break}M>=At&&d.raise("insufficient number of texture units"),N.profile&&I.maxTextureUnits<M+1&&(I.maxTextureUnits=M+1),y.unit=M,a.activeTexture(Pr+M),a.bindTexture(y.target,y.texture)}return M},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&Fe(this)}});function qe(y,M){var z=new Ve(tn);St[z.id]=z,I.textureCount++;function xe(l,w){var C=z.texInfo;ot.call(C);var k=Ze();return typeof l=="number"?typeof w=="number"?Ge(k,l|0,w|0):Ge(k,l|0,l|0):l?(d.type(l,"object","invalid arguments to regl.texture"),mt(C,l),We(k,l)):Ge(k,1,1),C.genMipmaps&&(k.mipmask=(k.width<<1)-1),z.mipmask=k.mipmask,$(z,k),d.texture2D(C,k,_),z.internalformat=k.internalformat,xe.width=k.width,xe.height=k.height,Et(z),st(k,tn),vt(C,tn),Ke(),pt(k),N.profile&&(z.stats.size=zi(z.internalformat,z.type,k.width,k.height,C.genMipmaps,!1)),xe.format=ee[z.internalformat],xe.type=ge[z.type],xe.mag=W[C.magFilter],xe.min=pe[C.minFilter],xe.wrapS=de[C.wrapS],xe.wrapT=de[C.wrapT],xe}function He(l,w,C,k){d(!!l,"must specify image data");var A=w|0,T=C|0,E=k|0,p=me();return $(p,z),p.width=0,p.height=0,ce(p,l),p.width=p.width||(z.width>>E)-A,p.height=p.height||(z.height>>E)-T,d(z.type===p.type&&z.format===p.format&&z.internalformat===p.internalformat,"incompatible format for texture.subimage"),d(A>=0&&T>=0&&A+p.width<=z.width&&T+p.height<=z.height,"texture.subimage write out of bounds"),d(z.mipmask&1<<E,"missing mipmap data"),d(p.data||p.element||p.needsCopy,"missing image data"),Et(z),Oe(p,tn,A,T,E),Ke(),ve(p),xe}function m(l,w){var C=l|0,k=w|0||C;if(C===z.width&&k===z.height)return xe;xe.width=z.width=C,xe.height=z.height=k,Et(z);for(var A=0;z.mipmask>>A;++A){var T=C>>A,E=k>>A;if(!T||!E)break;a.texImage2D(tn,A,z.format,T,E,0,z.format,z.type,null)}return Ke(),N.profile&&(z.stats.size=zi(z.internalformat,z.type,C,k,!1,!1)),xe}return xe(y,M),xe.subimage=He,xe.resize=m,xe._reglType="texture2d",xe._texture=z,N.profile&&(xe.stats=z.stats),xe.destroy=function(){z.decRef()},xe}function Qe(y,M,z,xe,He,m){var l=new Ve(jo);St[l.id]=l,I.cubeCount++;var w=new Array(6);function C(T,E,p,x,g,L){var F,V=l.texInfo;for(ot.call(V),F=0;F<6;++F)w[F]=Ze();if(typeof T=="number"||!T){var X=T|0||1;for(F=0;F<6;++F)Ge(w[F],X,X)}else if(typeof T=="object")if(E)We(w[0],T),We(w[1],E),We(w[2],p),We(w[3],x),We(w[4],g),We(w[5],L);else if(mt(V,T),be(l,T),"faces"in T){var se=T.faces;for(d(Array.isArray(se)&&se.length===6,"cube faces must be a length 6 array"),F=0;F<6;++F)d(typeof se[F]=="object"&&!!se[F],"invalid input for cube map face"),$(w[F],l),We(w[F],se[F])}else for(F=0;F<6;++F)We(w[F],T);else d.raise("invalid arguments to cube map");for($(l,w[0]),d.optional(function(){_.npotTextureCube||d(Nf(l.width)&&Nf(l.height),"your browser does not support non power or two texture dimensions")}),V.genMipmaps?l.mipmask=(w[0].width<<1)-1:l.mipmask=w[0].mipmask,d.textureCube(l,V,w,_),l.internalformat=w[0].internalformat,C.width=w[0].width,C.height=w[0].height,Et(l),F=0;F<6;++F)st(w[F],Ei+F);for(vt(V,jo),Ke(),N.profile&&(l.stats.size=zi(l.internalformat,l.type,C.width,C.height,V.genMipmaps,!0)),C.format=ee[l.internalformat],C.type=ge[l.type],C.mag=W[V.magFilter],C.min=pe[V.minFilter],C.wrapS=de[V.wrapS],C.wrapT=de[V.wrapT],F=0;F<6;++F)pt(w[F]);return C}function k(T,E,p,x,g){d(!!E,"must specify image data"),d(typeof T=="number"&&T===(T|0)&&T>=0&&T<6,"invalid face");var L=p|0,F=x|0,V=g|0,X=me();return $(X,l),X.width=0,X.height=0,ce(X,E),X.width=X.width||(l.width>>V)-L,X.height=X.height||(l.height>>V)-F,d(l.type===X.type&&l.format===X.format&&l.internalformat===X.internalformat,"incompatible format for texture.subimage"),d(L>=0&&F>=0&&L+X.width<=l.width&&F+X.height<=l.height,"texture.subimage write out of bounds"),d(l.mipmask&1<<V,"missing mipmap data"),d(X.data||X.element||X.needsCopy,"missing image data"),Et(l),Oe(X,Ei+T,L,F,V),Ke(),ve(X),C}function A(T){var E=T|0;if(E!==l.width){C.width=l.width=E,C.height=l.height=E,Et(l);for(var p=0;p<6;++p)for(var x=0;l.mipmask>>x;++x)a.texImage2D(Ei+p,x,l.format,E>>x,E>>x,0,l.format,l.type,null);return Ke(),N.profile&&(l.stats.size=zi(l.internalformat,l.type,C.width,C.height,!1,!0)),C}}return C(y,M,z,xe,He,m),C.subimage=k,C.resize=A,C._reglType="textureCube",C._texture=l,N.profile&&(C.stats=l.stats),C.destroy=function(){l.decRef()},C}function lt(){for(var y=0;y<At;++y)a.activeTexture(Pr+y),a.bindTexture(tn,null),ct[y]=null;Gt(St).forEach(Fe),I.cubeCount=0,I.textureCount=0}N.profile&&(I.getTotalTextureSize=function(){var y=0;return Object.keys(St).forEach(function(M){y+=St[M].stats.size}),y});function rn(){for(var y=0;y<At;++y){var M=ct[y];M&&(M.bindCount=0,M.unit=-1,ct[y]=null)}Gt(St).forEach(function(z){z.texture=a.createTexture(),a.bindTexture(z.target,z.texture);for(var xe=0;xe<32;++xe)if((z.mipmask&1<<xe)!==0)if(z.target===tn)a.texImage2D(tn,xe,z.internalformat,z.width>>xe,z.height>>xe,0,z.internalformat,z.type,null);else for(var He=0;He<6;++He)a.texImage2D(Ei+He,xe,z.internalformat,z.width>>xe,z.height>>xe,0,z.internalformat,z.type,null);vt(z.texInfo,z.target)})}function Vn(){for(var y=0;y<At;++y){var M=ct[y];M&&(M.bindCount=0,M.unit=-1,ct[y]=null),a.activeTexture(Pr+y),a.bindTexture(tn,null),a.bindTexture(jo,null)}}return{create2D:qe,createCube:Qe,clear:lt,getTexture:function(y){return null},restore:rn,refresh:Vn}}var xn=36161,Ii=32854,hu=32855,du=36194,mu=33189,pu=36168,vu=34041,gu=35907,yu=34836,xu=34842,bu=34843,Qt=[];Qt[Ii]=2,Qt[hu]=2,Qt[du]=2,Qt[mu]=2,Qt[pu]=1,Qt[vu]=4,Qt[gu]=4,Qt[yu]=16,Qt[xu]=8,Qt[bu]=6;function _u(a,h,_){return Qt[a]*h*_}var Og=function(a,h,_,R,U){var I={rgba4:Ii,rgb565:du,"rgb5 a1":hu,depth:mu,stencil:pu,"depth stencil":vu};h.ext_srgb&&(I.srgba=gu),h.ext_color_buffer_half_float&&(I.rgba16f=xu,I.rgb16f=bu),h.webgl_color_buffer_float&&(I.rgba32f=yu);var N=[];Object.keys(I).forEach(function(K){var te=I[K];N[te]=K});var Q=0,Y={};function ne(K){this.id=Q++,this.refCount=1,this.renderbuffer=K,this.format=Ii,this.width=0,this.height=0,U.profile&&(this.stats={size:0})}ne.prototype.decRef=function(){--this.refCount<=0&&ie(this)};function ie(K){var te=K.renderbuffer;d(te,"must not double destroy renderbuffer"),a.bindRenderbuffer(xn,null),a.deleteRenderbuffer(te),K.renderbuffer=null,K.refCount=0,delete Y[K.id],R.renderbufferCount--}function re(K,te){var P=new ne(a.createRenderbuffer());Y[P.id]=P,R.renderbufferCount++;function O(ge,W){var pe=0,de=0,Pe=Ii;if(typeof ge=="object"&&ge){var j=ge;if("shape"in j){var $=j.shape;d(Array.isArray($)&&$.length>=2,"invalid renderbuffer shape"),pe=$[0]|0,de=$[1]|0}else"radius"in j&&(pe=de=j.radius|0),"width"in j&&(pe=j.width|0),"height"in j&&(de=j.height|0);"format"in j&&(d.parameter(j.format,I,"invalid renderbuffer format"),Pe=I[j.format])}else typeof ge=="number"?(pe=ge|0,typeof W=="number"?de=W|0:de=pe):ge?d.raise("invalid arguments to renderbuffer constructor"):pe=de=1;if(d(pe>0&&de>0&&pe<=_.maxRenderbufferSize&&de<=_.maxRenderbufferSize,"invalid renderbuffer size"),!(pe===P.width&&de===P.height&&Pe===P.format))return O.width=P.width=pe,O.height=P.height=de,P.format=Pe,a.bindRenderbuffer(xn,P.renderbuffer),a.renderbufferStorage(xn,Pe,pe,de),d(a.getError()===0,"invalid render buffer format"),U.profile&&(P.stats.size=_u(P.format,P.width,P.height)),O.format=N[P.format],O}function ee(ge,W){var pe=ge|0,de=W|0||pe;return pe===P.width&&de===P.height||(d(pe>0&&de>0&&pe<=_.maxRenderbufferSize&&de<=_.maxRenderbufferSize,"invalid renderbuffer size"),O.width=P.width=pe,O.height=P.height=de,a.bindRenderbuffer(xn,P.renderbuffer),a.renderbufferStorage(xn,P.format,pe,de),d(a.getError()===0,"invalid render buffer format"),U.profile&&(P.stats.size=_u(P.format,P.width,P.height))),O}return O(K,te),O.resize=ee,O._reglType="renderbuffer",O._renderbuffer=P,U.profile&&(O.stats=P.stats),O.destroy=function(){P.decRef()},O}U.profile&&(R.getTotalRenderbufferSize=function(){var K=0;return Object.keys(Y).forEach(function(te){K+=Y[te].stats.size}),K});function fe(){Gt(Y).forEach(function(K){K.renderbuffer=a.createRenderbuffer(),a.bindRenderbuffer(xn,K.renderbuffer),a.renderbufferStorage(xn,K.format,K.width,K.height)}),a.bindRenderbuffer(xn,null)}return{create:re,clear:function(){Gt(Y).forEach(ie)},restore:fe}},hn=36160,sa=36161,Dn=3553,Ri=34069,Su=36064,wu=36096,Tu=36128,Au=33306,Eu=36053,Gg=36054,Ng=36055,Bg=36057,Vg=36061,$g=36193,Ug=5121,jg=5126,Cu=6407,Pu=6408,Xg=6402,Hg=[Cu,Pu],fa=[];fa[Pu]=4,fa[Cu]=3;var Di=[];Di[Ug]=1,Di[jg]=4,Di[$g]=2;var Wg=32854,qg=32855,Yg=36194,Zg=33189,Qg=36168,ku=34041,Kg=35907,Jg=34836,ey=34842,ty=34843,ny=[Wg,qg,Yg,Kg,ey,ty,Jg],nr={};nr[Eu]="complete",nr[Gg]="incomplete attachment",nr[Bg]="incomplete dimensions",nr[Ng]="incomplete, missing attachment",nr[Vg]="unsupported";function ry(a,h,_,R,U,I){var N={cur:null,next:null,dirty:!1,setFBO:null},Q=["rgba"],Y=["rgba4","rgb565","rgb5 a1"];h.ext_srgb&&Y.push("srgba"),h.ext_color_buffer_half_float&&Y.push("rgba16f","rgb16f"),h.webgl_color_buffer_float&&Y.push("rgba32f");var ne=["uint8"];h.oes_texture_half_float&&ne.push("half float","float16"),h.oes_texture_float&&ne.push("float","float32");function ie(J,ce,he){this.target=J,this.texture=ce,this.renderbuffer=he;var Oe=0,De=0;ce?(Oe=ce.width,De=ce.height):he&&(Oe=he.width,De=he.height),this.width=Oe,this.height=De}function re(J){J&&(J.texture&&J.texture._texture.decRef(),J.renderbuffer&&J.renderbuffer._renderbuffer.decRef())}function fe(J,ce,he){if(J)if(J.texture){var Oe=J.texture._texture,De=Math.max(1,Oe.width),me=Math.max(1,Oe.height);d(De===ce&&me===he,"inconsistent width/height for supplied texture"),Oe.refCount+=1}else{var ve=J.renderbuffer._renderbuffer;d(ve.width===ce&&ve.height===he,"inconsistent width/height for renderbuffer"),ve.refCount+=1}}function K(J,ce){ce&&(ce.texture?a.framebufferTexture2D(hn,J,ce.target,ce.texture._texture.texture,0):a.framebufferRenderbuffer(hn,J,sa,ce.renderbuffer._renderbuffer.renderbuffer))}function te(J){var ce=Dn,he=null,Oe=null,De=J;typeof J=="object"&&(De=J.data,"target"in J&&(ce=J.target|0)),d.type(De,"function","invalid attachment data");var me=De._reglType;return me==="texture2d"?(he=De,d(ce===Dn)):me==="textureCube"?(he=De,d(ce>=Ri&&ce<Ri+6,"invalid cube map target")):me==="renderbuffer"?(Oe=De,ce=sa):d.raise("invalid regl object for attachment"),new ie(ce,he,Oe)}function P(J,ce,he,Oe,De){if(he){var me=R.create2D({width:J,height:ce,format:Oe,type:De});return me._texture.refCount=0,new ie(Dn,me,null)}else{var ve=U.create({width:J,height:ce,format:Oe});return ve._renderbuffer.refCount=0,new ie(sa,null,ve)}}function O(J){return J&&(J.texture||J.renderbuffer)}function ee(J,ce,he){J&&(J.texture?J.texture.resize(ce,he):J.renderbuffer&&J.renderbuffer.resize(ce,he),J.width=ce,J.height=he)}var ge=0,W={};function pe(){this.id=ge++,W[this.id]=this,this.framebuffer=a.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function de(J){J.colorAttachments.forEach(re),re(J.depthAttachment),re(J.stencilAttachment),re(J.depthStencilAttachment)}function Pe(J){var ce=J.framebuffer;d(ce,"must not double destroy framebuffer"),a.deleteFramebuffer(ce),J.framebuffer=null,I.framebufferCount--,delete W[J.id]}function j(J){var ce;a.bindFramebuffer(hn,J.framebuffer);var he=J.colorAttachments;for(ce=0;ce<he.length;++ce)K(Su+ce,he[ce]);for(ce=he.length;ce<_.maxColorAttachments;++ce)a.framebufferTexture2D(hn,Su+ce,Dn,null,0);a.framebufferTexture2D(hn,Au,Dn,null,0),a.framebufferTexture2D(hn,wu,Dn,null,0),a.framebufferTexture2D(hn,Tu,Dn,null,0),K(wu,J.depthAttachment),K(Tu,J.stencilAttachment),K(Au,J.depthStencilAttachment);var Oe=a.checkFramebufferStatus(hn);!a.isContextLost()&&Oe!==Eu&&d.raise("framebuffer configuration not supported, status = "+nr[Oe]),a.bindFramebuffer(hn,N.next?N.next.framebuffer:null),N.cur=N.next,a.getError()}function $(J,ce){var he=new pe;I.framebufferCount++;function Oe(me,ve){var ze;d(N.next!==he,"can not update framebuffer which is currently in use");var Ge=0,We=0,st=!0,ft=!0,Ze=null,pt=!0,ot="rgba",mt="uint8",vt=1,gt=null,St=null,At=null,ct=!1;if(typeof me=="number")Ge=me|0,We=ve|0||Ge;else if(!me)Ge=We=1;else{d.type(me,"object","invalid arguments for framebuffer");var Ve=me;if("shape"in Ve){var Et=Ve.shape;d(Array.isArray(Et)&&Et.length>=2,"invalid shape for framebuffer"),Ge=Et[0],We=Et[1]}else"radius"in Ve&&(Ge=We=Ve.radius),"width"in Ve&&(Ge=Ve.width),"height"in Ve&&(We=Ve.height);("color"in Ve||"colors"in Ve)&&(Ze=Ve.color||Ve.colors,Array.isArray(Ze)&&d(Ze.length===1||h.webgl_draw_buffers,"multiple render targets not supported")),Ze||("colorCount"in Ve&&(vt=Ve.colorCount|0,d(vt>0,"invalid color buffer count")),"colorTexture"in Ve&&(pt=!!Ve.colorTexture,ot="rgba4"),"colorType"in Ve&&(mt=Ve.colorType,pt?(d(h.oes_texture_float||!(mt==="float"||mt==="float32"),"you must enable OES_texture_float in order to use floating point framebuffer objects"),d(h.oes_texture_half_float||!(mt==="half float"||mt==="float16"),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):mt==="half float"||mt==="float16"?(d(h.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),ot="rgba16f"):(mt==="float"||mt==="float32")&&(d(h.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),ot="rgba32f"),d.oneOf(mt,ne,"invalid color type")),"colorFormat"in Ve&&(ot=Ve.colorFormat,Q.indexOf(ot)>=0?pt=!0:Y.indexOf(ot)>=0?pt=!1:d.optional(function(){pt?d.oneOf(Ve.colorFormat,Q,"invalid color format for texture"):d.oneOf(Ve.colorFormat,Y,"invalid color format for renderbuffer")}))),("depthTexture"in Ve||"depthStencilTexture"in Ve)&&(ct=!!(Ve.depthTexture||Ve.depthStencilTexture),d(!ct||h.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in Ve&&(typeof Ve.depth=="boolean"?st=Ve.depth:(gt=Ve.depth,ft=!1)),"stencil"in Ve&&(typeof Ve.stencil=="boolean"?ft=Ve.stencil:(St=Ve.stencil,st=!1)),"depthStencil"in Ve&&(typeof Ve.depthStencil=="boolean"?st=ft=Ve.depthStencil:(At=Ve.depthStencil,st=!1,ft=!1))}var Ke=null,Fe=null,qe=null,Qe=null;if(Array.isArray(Ze))Ke=Ze.map(te);else if(Ze)Ke=[te(Ze)];else for(Ke=new Array(vt),ze=0;ze<vt;++ze)Ke[ze]=P(Ge,We,pt,ot,mt);d(h.webgl_draw_buffers||Ke.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),d(Ke.length<=_.maxColorAttachments,"too many color attachments, not supported"),Ge=Ge||Ke[0].width,We=We||Ke[0].height,gt?Fe=te(gt):st&&!ft&&(Fe=P(Ge,We,ct,"depth","uint32")),St?qe=te(St):ft&&!st&&(qe=P(Ge,We,!1,"stencil","uint8")),At?Qe=te(At):!gt&&!St&&ft&&st&&(Qe=P(Ge,We,ct,"depth stencil","depth stencil")),d(!!gt+!!St+!!At<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var lt=null;for(ze=0;ze<Ke.length;++ze)if(fe(Ke[ze],Ge,We),d(!Ke[ze]||Ke[ze].texture&&Hg.indexOf(Ke[ze].texture._texture.format)>=0||Ke[ze].renderbuffer&&ny.indexOf(Ke[ze].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+ze+" is invalid"),Ke[ze]&&Ke[ze].texture){var rn=fa[Ke[ze].texture._texture.format]*Di[Ke[ze].texture._texture.type];lt===null?lt=rn:d(lt===rn,"all color attachments much have the same number of bits per pixel.")}return fe(Fe,Ge,We),d(!Fe||Fe.texture&&Fe.texture._texture.format===Xg||Fe.renderbuffer&&Fe.renderbuffer._renderbuffer.format===Zg,"invalid depth attachment for framebuffer object"),fe(qe,Ge,We),d(!qe||qe.renderbuffer&&qe.renderbuffer._renderbuffer.format===Qg,"invalid stencil attachment for framebuffer object"),fe(Qe,Ge,We),d(!Qe||Qe.texture&&Qe.texture._texture.format===ku||Qe.renderbuffer&&Qe.renderbuffer._renderbuffer.format===ku,"invalid depth-stencil attachment for framebuffer object"),de(he),he.width=Ge,he.height=We,he.colorAttachments=Ke,he.depthAttachment=Fe,he.stencilAttachment=qe,he.depthStencilAttachment=Qe,Oe.color=Ke.map(O),Oe.depth=O(Fe),Oe.stencil=O(qe),Oe.depthStencil=O(Qe),Oe.width=he.width,Oe.height=he.height,j(he),Oe}function De(me,ve){d(N.next!==he,"can not resize a framebuffer which is currently in use");var ze=Math.max(me|0,1),Ge=Math.max(ve|0||ze,1);if(ze===he.width&&Ge===he.height)return Oe;for(var We=he.colorAttachments,st=0;st<We.length;++st)ee(We[st],ze,Ge);return ee(he.depthAttachment,ze,Ge),ee(he.stencilAttachment,ze,Ge),ee(he.depthStencilAttachment,ze,Ge),he.width=Oe.width=ze,he.height=Oe.height=Ge,j(he),Oe}return Oe(J,ce),r(Oe,{resize:De,_reglType:"framebuffer",_framebuffer:he,destroy:function(){Pe(he),de(he)},use:function(me){N.setFBO({framebuffer:Oe},me)}})}function be(J){var ce=Array(6);function he(De){var me;d(ce.indexOf(N.next)<0,"can not update framebuffer which is currently in use");var ve={color:null},ze=0,Ge=null,We="rgba",st="uint8",ft=1;if(typeof De=="number")ze=De|0;else if(!De)ze=1;else{d.type(De,"object","invalid arguments for framebuffer");var Ze=De;if("shape"in Ze){var pt=Ze.shape;d(Array.isArray(pt)&&pt.length>=2,"invalid shape for framebuffer"),d(pt[0]===pt[1],"cube framebuffer must be square"),ze=pt[0]}else"radius"in Ze&&(ze=Ze.radius|0),"width"in Ze?(ze=Ze.width|0,"height"in Ze&&d(Ze.height===ze,"must be square")):"height"in Ze&&(ze=Ze.height|0);("color"in Ze||"colors"in Ze)&&(Ge=Ze.color||Ze.colors,Array.isArray(Ge)&&d(Ge.length===1||h.webgl_draw_buffers,"multiple render targets not supported")),Ge||("colorCount"in Ze&&(ft=Ze.colorCount|0,d(ft>0,"invalid color buffer count")),"colorType"in Ze&&(d.oneOf(Ze.colorType,ne,"invalid color type"),st=Ze.colorType),"colorFormat"in Ze&&(We=Ze.colorFormat,d.oneOf(Ze.colorFormat,Q,"invalid color format for texture"))),"depth"in Ze&&(ve.depth=Ze.depth),"stencil"in Ze&&(ve.stencil=Ze.stencil),"depthStencil"in Ze&&(ve.depthStencil=Ze.depthStencil)}var ot;if(Ge)if(Array.isArray(Ge))for(ot=[],me=0;me<Ge.length;++me)ot[me]=Ge[me];else ot=[Ge];else{ot=Array(ft);var mt={radius:ze,format:We,type:st};for(me=0;me<ft;++me)ot[me]=R.createCube(mt)}for(ve.color=Array(ot.length),me=0;me<ot.length;++me){var vt=ot[me];d(typeof vt=="function"&&vt._reglType==="textureCube","invalid cube map"),ze=ze||vt.width,d(vt.width===ze&&vt.height===ze,"invalid cube map shape"),ve.color[me]={target:Ri,data:ot[me]}}for(me=0;me<6;++me){for(var gt=0;gt<ot.length;++gt)ve.color[gt].target=Ri+me;me>0&&(ve.depth=ce[0].depth,ve.stencil=ce[0].stencil,ve.depthStencil=ce[0].depthStencil),ce[me]?ce[me](ve):ce[me]=$(ve)}return r(he,{width:ze,height:ze,color:ot})}function Oe(De){var me,ve=De|0;if(d(ve>0&&ve<=_.maxCubeMapSize,"invalid radius for cube fbo"),ve===he.width)return he;var ze=he.color;for(me=0;me<ze.length;++me)ze[me].resize(ve);for(me=0;me<6;++me)ce[me].resize(ve);return he.width=he.height=ve,he}return he(J),r(he,{faces:ce,resize:Oe,_reglType:"framebufferCube",destroy:function(){ce.forEach(function(De){De.destroy()})}})}function ue(){N.cur=null,N.next=null,N.dirty=!0,Gt(W).forEach(function(J){J.framebuffer=a.createFramebuffer(),j(J)})}return r(N,{getFramebuffer:function(J){if(typeof J=="function"&&J._reglType==="framebuffer"){var ce=J._framebuffer;if(ce instanceof pe)return ce}return null},create:$,createCube:be,clear:function(){Gt(W).forEach(Pe)},restore:ue})}var iy=5126,Fu=34962,Mi=34963,Lu=["attributes","elements","offset","count","primitive","instances"];function ua(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=iy,this.offset=0,this.stride=0,this.divisor=0}function oy(a,h,_,R,U,I,N){for(var Q=_.maxAttributes,Y=new Array(Q),ne=0;ne<Q;++ne)Y[ne]=new ua;var ie=0,re={},fe={Record:ua,scope:{},state:Y,currentVAO:null,targetVAO:null,restore:te()?de:function(){},createVAO:Pe,getVAO:O,destroyBuffer:K,setVAO:te()?ee:ge,clear:te()?W:function(){}};function K(j){for(var $=0;$<Y.length;++$){var be=Y[$];be.buffer===j&&(a.disableVertexAttribArray($),be.buffer=null)}}function te(){return h.oes_vertex_array_object}function P(){return h.angle_instanced_arrays}function O(j){return typeof j=="function"&&j._vao?j._vao:null}function ee(j){if(j!==fe.currentVAO){var $=te();j?$.bindVertexArrayOES(j.vao):$.bindVertexArrayOES(null),fe.currentVAO=j}}function ge(j){if(j!==fe.currentVAO){if(j)j.bindAttrs();else{for(var $=P(),be=0;be<Y.length;++be){var ue=Y[be];ue.buffer?(a.enableVertexAttribArray(be),ue.buffer.bind(),a.vertexAttribPointer(be,ue.size,ue.type,ue.normalized,ue.stride,ue.offfset),$&&ue.divisor&&$.vertexAttribDivisorANGLE(be,ue.divisor)):(a.disableVertexAttribArray(be),a.vertexAttrib4f(be,ue.x,ue.y,ue.z,ue.w))}N.elements?a.bindBuffer(Mi,N.elements.buffer.buffer):a.bindBuffer(Mi,null)}fe.currentVAO=j}}function W(){Gt(re).forEach(function(j){j.destroy()})}function pe(){this.id=++ie,this.attributes=[],this.elements=null,this.ownsElements=!1,this.count=0,this.offset=0,this.instances=-1,this.primitive=4;var j=te();j?this.vao=j.createVertexArrayOES():this.vao=null,re[this.id]=this,this.buffers=[]}pe.prototype.bindAttrs=function(){for(var j=P(),$=this.attributes,be=0;be<$.length;++be){var ue=$[be];ue.buffer?(a.enableVertexAttribArray(be),a.bindBuffer(Fu,ue.buffer.buffer),a.vertexAttribPointer(be,ue.size,ue.type,ue.normalized,ue.stride,ue.offset),j&&ue.divisor&&j.vertexAttribDivisorANGLE(be,ue.divisor)):(a.disableVertexAttribArray(be),a.vertexAttrib4f(be,ue.x,ue.y,ue.z,ue.w))}for(var J=$.length;J<Q;++J)a.disableVertexAttribArray(J);var ce=I.getElements(this.elements);ce?a.bindBuffer(Mi,ce.buffer.buffer):a.bindBuffer(Mi,null)},pe.prototype.refresh=function(){var j=te();j&&(j.bindVertexArrayOES(this.vao),this.bindAttrs(),fe.currentVAO=null,j.bindVertexArrayOES(null))},pe.prototype.destroy=function(){if(this.vao){var j=te();this===fe.currentVAO&&(fe.currentVAO=null,j.bindVertexArrayOES(null)),j.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),re[this.id]&&(delete re[this.id],R.vaoCount-=1)};function de(){var j=te();j&&Gt(re).forEach(function($){$.refresh()})}function Pe(j){var $=new pe;R.vaoCount+=1;function be(ue){var J;if(Array.isArray(ue))J=ue,$.elements&&$.ownsElements&&$.elements.destroy(),$.elements=null,$.ownsElements=!1,$.offset=0,$.count=0,$.instances=-1,$.primitive=4;else{if(d(typeof ue=="object","invalid arguments for create vao"),d("attributes"in ue,"must specify attributes for vao"),ue.elements){var ce=ue.elements;$.ownsElements?typeof ce=="function"&&ce._reglType==="elements"?($.elements.destroy(),$.ownsElements=!1):($.elements(ce),$.ownsElements=!1):I.getElements(ue.elements)?($.elements=ue.elements,$.ownsElements=!1):($.elements=I.create(ue.elements),$.ownsElements=!0)}else $.elements=null,$.ownsElements=!1;J=ue.attributes,$.offset=0,$.count=-1,$.instances=-1,$.primitive=4,$.elements&&($.count=$.elements._elements.vertCount,$.primitive=$.elements._elements.primType),"offset"in ue&&($.offset=ue.offset|0),"count"in ue&&($.count=ue.count|0),"instances"in ue&&($.instances=ue.instances|0),"primitive"in ue&&(d(ue.primitive in yn,"bad primitive type: "+ue.primitive),$.primitive=yn[ue.primitive]),d.optional(()=>{for(var st=Object.keys(ue),ft=0;ft<st.length;++ft)d(Lu.indexOf(st[ft])>=0,'invalid option for vao: "'+st[ft]+'" valid options are '+Lu)}),d(Array.isArray(J),"attributes must be an array")}d(J.length<Q,"too many attributes"),d(J.length>0,"must specify at least one attribute");var he={},Oe=$.attributes;Oe.length=J.length;for(var De=0;De<J.length;++De){var me=J[De],ve=Oe[De]=new ua,ze=me.data||me;if(Array.isArray(ze)||n(ze)||Zt(ze)){var Ge;$.buffers[De]&&(Ge=$.buffers[De],n(ze)&&Ge._buffer.byteLength>=ze.byteLength?Ge.subdata(ze):(Ge.destroy(),$.buffers[De]=null)),$.buffers[De]||(Ge=$.buffers[De]=U.create(me,Fu,!1,!0)),ve.buffer=U.getBuffer(Ge),ve.size=ve.buffer.dimension|0,ve.normalized=!1,ve.type=ve.buffer.dtype,ve.offset=0,ve.stride=0,ve.divisor=0,ve.state=1,he[De]=1}else U.getBuffer(me)?(ve.buffer=U.getBuffer(me),ve.size=ve.buffer.dimension|0,ve.normalized=!1,ve.type=ve.buffer.dtype,ve.offset=0,ve.stride=0,ve.divisor=0,ve.state=1):U.getBuffer(me.buffer)?(ve.buffer=U.getBuffer(me.buffer),ve.size=(+me.size||ve.buffer.dimension)|0,ve.normalized=!!me.normalized||!1,"type"in me?(d.parameter(me.type,Ln,"invalid buffer type"),ve.type=Ln[me.type]):ve.type=ve.buffer.dtype,ve.offset=(me.offset||0)|0,ve.stride=(me.stride||0)|0,ve.divisor=(me.divisor||0)|0,ve.state=1,d(ve.size>=1&&ve.size<=4,"size must be between 1 and 4"),d(ve.offset>=0,"invalid offset"),d(ve.stride>=0&&ve.stride<=255,"stride must be between 0 and 255"),d(ve.divisor>=0,"divisor must be positive"),d(!ve.divisor||!!h.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in me?(d(De>0,"first attribute must not be a constant"),ve.x=+me.x||0,ve.y=+me.y||0,ve.z=+me.z||0,ve.w=+me.w||0,ve.state=2):d(!1,"invalid attribute spec for location "+De)}for(var We=0;We<$.buffers.length;++We)!he[We]&&$.buffers[We]&&($.buffers[We].destroy(),$.buffers[We]=null);return $.refresh(),be}return be.destroy=function(){for(var ue=0;ue<$.buffers.length;++ue)$.buffers[ue]&&$.buffers[ue].destroy();$.buffers.length=0,$.ownsElements&&($.elements.destroy(),$.elements=null,$.ownsElements=!1),$.destroy()},be._vao=$,be._reglType="vao",be(j)}return fe}var zu=35632,ay=35633,sy=35718,fy=35721;function uy(a,h,_,R){var U={},I={};function N(P,O,ee,ge){this.name=P,this.id=O,this.location=ee,this.info=ge}function Q(P,O){for(var ee=0;ee<P.length;++ee)if(P[ee].id===O.id){P[ee].location=O.location;return}P.push(O)}function Y(P,O,ee){var ge=P===zu?U:I,W=ge[O];if(!W){var pe=h.str(O);W=a.createShader(P),a.shaderSource(W,pe),a.compileShader(W),d.shaderError(a,W,pe,P,ee),ge[O]=W}return W}var ne={},ie=[],re=0;function fe(P,O){this.id=re++,this.fragId=P,this.vertId=O,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,R.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function K(P,O,ee){var ge,W,pe=Y(zu,P.fragId),de=Y(ay,P.vertId),Pe=P.program=a.createProgram();if(a.attachShader(Pe,pe),a.attachShader(Pe,de),ee)for(ge=0;ge<ee.length;++ge){var j=ee[ge];a.bindAttribLocation(Pe,j[0],j[1])}a.linkProgram(Pe),d.linkError(a,Pe,h.str(P.fragId),h.str(P.vertId),O);var $=a.getProgramParameter(Pe,sy);R.profile&&(P.stats.uniformsCount=$);var be=P.uniforms;for(ge=0;ge<$;++ge)if(W=a.getActiveUniform(Pe,ge),W){if(W.size>1)for(var ue=0;ue<W.size;++ue){var J=W.name.replace("[0]","["+ue+"]");Q(be,new N(J,h.id(J),a.getUniformLocation(Pe,J),W))}var ce=W.name;W.size>1&&(ce=ce.replace("[0]","")),Q(be,new N(ce,h.id(ce),a.getUniformLocation(Pe,ce),W))}var he=a.getProgramParameter(Pe,fy);R.profile&&(P.stats.attributesCount=he);var Oe=P.attributes;for(ge=0;ge<he;++ge)W=a.getActiveAttrib(Pe,ge),W&&Q(Oe,new N(W.name,h.id(W.name),a.getAttribLocation(Pe,W.name),W))}R.profile&&(_.getMaxUniformsCount=function(){var P=0;return ie.forEach(function(O){O.stats.uniformsCount>P&&(P=O.stats.uniformsCount)}),P},_.getMaxAttributesCount=function(){var P=0;return ie.forEach(function(O){O.stats.attributesCount>P&&(P=O.stats.attributesCount)}),P});function te(){U={},I={};for(var P=0;P<ie.length;++P)K(ie[P],null,ie[P].attributes.map(function(O){return[O.location,O.name]}))}return{clear:function(){var P=a.deleteShader.bind(a);Gt(U).forEach(P),U={},Gt(I).forEach(P),I={},ie.forEach(function(O){a.deleteProgram(O.program)}),ie.length=0,ne={},_.shaderCount=0},program:function(P,O,ee,ge){d.command(P>=0,"missing vertex shader",ee),d.command(O>=0,"missing fragment shader",ee);var W=ne[O];W||(W=ne[O]={});var pe=W[P];if(pe&&(pe.refCount++,!ge))return pe;var de=new fe(O,P);return _.shaderCount++,K(de,ee,ge),pe||(W[P]=de),ie.push(de),r(de,{destroy:function(){if(de.refCount--,de.refCount<=0){a.deleteProgram(de.program);var Pe=ie.indexOf(de);ie.splice(Pe,1),_.shaderCount--}W[de.vertId].refCount<=0&&(a.deleteShader(I[de.vertId]),delete I[de.vertId],delete ne[de.fragId][de.vertId]),Object.keys(ne[de.fragId]).length||(a.deleteShader(U[de.fragId]),delete U[de.fragId],delete ne[de.fragId])}})},restore:te,shader:Y,frag:-1,vert:-1}}var cy=6408,kr=5121,ly=3333,Oi=5126;function hy(a,h,_,R,U,I,N){function Q(ie){var re;h.next===null?(d(U.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),re=kr):(d(h.next.colorAttachments[0].texture!==null,"You cannot read from a renderbuffer"),re=h.next.colorAttachments[0].texture._texture.type,d.optional(function(){I.oes_texture_float?(d(re===kr||re===Oi,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),re===Oi&&d(N.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):d(re===kr,"Reading from a framebuffer is only allowed for the type 'uint8'")}));var fe=0,K=0,te=R.framebufferWidth,P=R.framebufferHeight,O=null;n(ie)?O=ie:ie&&(d.type(ie,"object","invalid arguments to regl.read()"),fe=ie.x|0,K=ie.y|0,d(fe>=0&&fe<R.framebufferWidth,"invalid x offset for regl.read"),d(K>=0&&K<R.framebufferHeight,"invalid y offset for regl.read"),te=(ie.width||R.framebufferWidth-fe)|0,P=(ie.height||R.framebufferHeight-K)|0,O=ie.data||null),O&&(re===kr?d(O instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):re===Oi&&d(O instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),d(te>0&&te+fe<=R.framebufferWidth,"invalid width for read pixels"),d(P>0&&P+K<=R.framebufferHeight,"invalid height for read pixels"),_();var ee=te*P*4;return O||(re===kr?O=new Uint8Array(ee):re===Oi&&(O=O||new Float32Array(ee))),d.isTypedArray(O,"data buffer for regl.read() must be a typedarray"),d(O.byteLength>=ee,"data buffer for regl.read() too small"),a.pixelStorei(ly,4),a.readPixels(fe,K,te,P,cy,re,O),O}function Y(ie){var re;return h.setFBO({framebuffer:ie.framebuffer},function(){re=Q(ie)}),re}function ne(ie){return!ie||!("framebuffer"in ie)?Q(ie):Y(ie)}return ne}function rr(a){return Array.prototype.slice.call(a)}function ir(a){return rr(a).join("")}function dy(){var a=0,h=[],_=[];function R(re){for(var fe=0;fe<_.length;++fe)if(_[fe]===re)return h[fe];var K="g"+a++;return h.push(K),_.push(re),K}function U(){var re=[];function fe(){re.push.apply(re,rr(arguments))}var K=[];function te(){var P="v"+a++;return K.push(P),arguments.length>0&&(re.push(P,"="),re.push.apply(re,rr(arguments)),re.push(";")),P}return r(fe,{def:te,toString:function(){return ir([K.length>0?"var "+K.join(",")+";":"",ir(re)])}})}function I(){var re=U(),fe=U(),K=re.toString,te=fe.toString;function P(O,ee){fe(O,ee,"=",re.def(O,ee),";")}return r(function(){re.apply(re,rr(arguments))},{def:re.def,entry:re,exit:fe,save:P,set:function(O,ee,ge){P(O,ee),re(O,ee,"=",ge,";")},toString:function(){return K()+te()}})}function N(){var re=ir(arguments),fe=I(),K=I(),te=fe.toString,P=K.toString;return r(fe,{then:function(){return fe.apply(fe,rr(arguments)),this},else:function(){return K.apply(K,rr(arguments)),this},toString:function(){var O=P();return O&&(O="else{"+O+"}"),ir(["if(",re,"){",te(),"}",O])}})}var Q=U(),Y={};function ne(re,fe){var K=[];function te(){var W="a"+K.length;return K.push(W),W}fe=fe||0;for(var P=0;P<fe;++P)te();var O=I(),ee=O.toString,ge=Y[re]=r(O,{arg:te,toString:function(){return ir(["function(",K.join(),"){",ee(),"}"])}});return ge}function ie(){var re=['"use strict";',Q,"return {"];Object.keys(Y).forEach(function(te){re.push('"',te,'":',Y[te].toString(),",")}),re.push("}");var fe=ir(re).replace(/;/g,`;
1
+ (function(Pt,Tn){typeof exports=="object"&&typeof module<"u"?Tn(exports):typeof define=="function"&&define.amd?define(["exports"],Tn):(Pt=typeof globalThis<"u"?globalThis:Pt||self,Tn(Pt.Cosmos={}))})(this,function(Pt){"use strict";var Tn="http://www.w3.org/1999/xhtml";const Ia={svg:"http://www.w3.org/2000/svg",xhtml:Tn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vr(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Ia.hasOwnProperty(e)?{space:Ia[e],local:t}:t}function gc(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Tn&&e.documentElement.namespaceURI===Tn?e.createElement(t):e.createElementNS(n,t)}}function yc(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ra(t){var e=Vr(t);return(e.local?yc:gc)(e)}function xc(){}function eo(t){return t==null?xc:function(){return this.querySelector(t)}}function bc(t){typeof t!="function"&&(t=eo(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],f=o.length,s=r[i]=new Array(f),u,c,v=0;v<f;++v)(u=o[v])&&(c=t.call(u,u.__data__,v,o))&&("__data__"in u&&(c.__data__=u.__data__),s[v]=c);return new zt(r,this._parents)}function _c(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Sc(){return[]}function Da(t){return t==null?Sc:function(){return this.querySelectorAll(t)}}function wc(t){return function(){return _c(t.apply(this,arguments))}}function Tc(t){typeof t=="function"?t=wc(t):t=Da(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var f=e[o],s=f.length,u,c=0;c<s;++c)(u=f[c])&&(r.push(t.call(u,u.__data__,c,f)),i.push(u));return new zt(r,i)}function Ma(t){return function(){return this.matches(t)}}function Oa(t){return function(e){return e.matches(t)}}var Ac=Array.prototype.find;function Ec(t){return function(){return Ac.call(this.children,t)}}function Cc(){return this.firstElementChild}function Pc(t){return this.select(t==null?Cc:Ec(typeof t=="function"?t:Oa(t)))}var kc=Array.prototype.filter;function Fc(){return Array.from(this.children)}function Lc(t){return function(){return kc.call(this.children,t)}}function zc(t){return this.selectAll(t==null?Fc:Lc(typeof t=="function"?t:Oa(t)))}function Ic(t){typeof t!="function"&&(t=Ma(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],f=o.length,s=r[i]=[],u,c=0;c<f;++c)(u=o[c])&&t.call(u,u.__data__,c,o)&&s.push(u);return new zt(r,this._parents)}function Na(t){return new Array(t.length)}function Rc(){return new zt(this._enter||this._groups.map(Na),this._parents)}function $r(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}$r.prototype={constructor:$r,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Dc(t){return function(){return t}}function Mc(t,e,n,r,i,o){for(var f=0,s,u=e.length,c=o.length;f<c;++f)(s=e[f])?(s.__data__=o[f],r[f]=s):n[f]=new $r(t,o[f]);for(;f<u;++f)(s=e[f])&&(i[f]=s)}function Oc(t,e,n,r,i,o,f){var s,u,c=new Map,v=e.length,b=o.length,S=new Array(v),D;for(s=0;s<v;++s)(u=e[s])&&(S[s]=D=f.call(u,u.__data__,s,e)+"",c.has(D)?i[s]=u:c.set(D,u));for(s=0;s<b;++s)D=f.call(t,o[s],s,o)+"",(u=c.get(D))?(r[s]=u,u.__data__=o[s],c.delete(D)):n[s]=new $r(t,o[s]);for(s=0;s<v;++s)(u=e[s])&&c.get(S[s])===u&&(i[s]=u)}function Nc(t){return t.__data__}function Gc(t,e){if(!arguments.length)return Array.from(this,Nc);var n=e?Oc:Mc,r=this._parents,i=this._groups;typeof t!="function"&&(t=Dc(t));for(var o=i.length,f=new Array(o),s=new Array(o),u=new Array(o),c=0;c<o;++c){var v=r[c],b=i[c],S=b.length,D=Bc(t.call(v,v&&v.__data__,c,r)),Z=D.length,we=s[c]=new Array(Z),Se=f[c]=new Array(Z),ae=u[c]=new Array(S);n(v,b,we,Se,ae,D,e);for(var Ge=0,je=0,W,le;Ge<Z;++Ge)if(W=we[Ge]){for(Ge>=je&&(je=Ge+1);!(le=Se[je])&&++je<Z;);W._next=le||null}}return f=new zt(f,r),f._enter=s,f._exit=u,f}function Bc(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Vc(){return new zt(this._exit||this._groups.map(Na),this._parents)}function $c(t,e,n){var r=this.enter(),i=this,o=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function Uc(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,f=Math.min(i,o),s=new Array(i),u=0;u<f;++u)for(var c=n[u],v=r[u],b=c.length,S=s[u]=new Array(b),D,Z=0;Z<b;++Z)(D=c[Z]||v[Z])&&(S[Z]=D);for(;u<i;++u)s[u]=n[u];return new zt(s,this._parents)}function jc(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],i=r.length-1,o=r[i],f;--i>=0;)(f=r[i])&&(o&&f.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(f,o),o=f);return this}function Xc(t){t||(t=Hc);function e(b,S){return b&&S?t(b.__data__,S.__data__):!b-!S}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var f=n[o],s=f.length,u=i[o]=new Array(s),c,v=0;v<s;++v)(c=f[v])&&(u[v]=c);u.sort(e)}return new zt(i,this._parents).order()}function Hc(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function qc(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Wc(){return Array.from(this)}function Yc(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length;i<o;++i){var f=r[i];if(f)return f}return null}function Zc(){let t=0;for(const e of this)++t;return t}function Qc(){return!this.node()}function Kc(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],o=0,f=i.length,s;o<f;++o)(s=i[o])&&t.call(s,s.__data__,o,i);return this}function Jc(t){return function(){this.removeAttribute(t)}}function el(t){return function(){this.removeAttributeNS(t.space,t.local)}}function tl(t,e){return function(){this.setAttribute(t,e)}}function nl(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function rl(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function il(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function ol(t,e){var n=Vr(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?el:Jc:typeof e=="function"?n.local?il:rl:n.local?nl:tl)(n,e))}function Ga(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function al(t){return function(){this.style.removeProperty(t)}}function sl(t,e,n){return function(){this.style.setProperty(t,e,n)}}function fl(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ul(t,e,n){return arguments.length>1?this.each((e==null?al:typeof e=="function"?fl:sl)(t,e,n??"")):Xn(this.node(),t)}function Xn(t,e){return t.style.getPropertyValue(e)||Ga(t).getComputedStyle(t,null).getPropertyValue(e)}function cl(t){return function(){delete this[t]}}function ll(t,e){return function(){this[t]=e}}function hl(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function dl(t,e){return arguments.length>1?this.each((e==null?cl:typeof e=="function"?hl:ll)(t,e)):this.node()[t]}function Ba(t){return t.trim().split(/^|\s+/)}function to(t){return t.classList||new Va(t)}function Va(t){this._node=t,this._names=Ba(t.getAttribute("class")||"")}Va.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function $a(t,e){for(var n=to(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function Ua(t,e){for(var n=to(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function ml(t){return function(){$a(this,t)}}function pl(t){return function(){Ua(this,t)}}function vl(t,e){return function(){(e.apply(this,arguments)?$a:Ua)(this,t)}}function gl(t,e){var n=Ba(t+"");if(arguments.length<2){for(var r=to(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof e=="function"?vl:e?ml:pl)(n,e))}function yl(){this.textContent=""}function xl(t){return function(){this.textContent=t}}function bl(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function _l(t){return arguments.length?this.each(t==null?yl:(typeof t=="function"?bl:xl)(t)):this.node().textContent}function Sl(){this.innerHTML=""}function wl(t){return function(){this.innerHTML=t}}function Tl(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Al(t){return arguments.length?this.each(t==null?Sl:(typeof t=="function"?Tl:wl)(t)):this.node().innerHTML}function El(){this.nextSibling&&this.parentNode.appendChild(this)}function Cl(){return this.each(El)}function Pl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function kl(){return this.each(Pl)}function Fl(t){var e=typeof t=="function"?t:Ra(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Ll(){return null}function zl(t,e){var n=typeof t=="function"?t:Ra(t),r=e==null?Ll:typeof e=="function"?e:eo(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Il(){var t=this.parentNode;t&&t.removeChild(this)}function Rl(){return this.each(Il)}function Dl(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ml(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ol(t){return this.select(t?Ml:Dl)}function Nl(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Gl(t){return function(e){t.call(this,e,this.__data__)}}function Bl(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Vl(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,o;n<i;++n)o=e[n],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++r]=o;++r?e.length=r:delete this.__on}}}function $l(t,e,n){return function(){var r=this.__on,i,o=Gl(e);if(r){for(var f=0,s=r.length;f<s;++f)if((i=r[f]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=e;return}}this.addEventListener(t.type,o,n),i={type:t.type,name:t.name,value:e,listener:o,options:n},r?r.push(i):this.__on=[i]}}function Ul(t,e,n){var r=Bl(t+""),i,o=r.length,f;if(arguments.length<2){var s=this.node().__on;if(s){for(var u=0,c=s.length,v;u<c;++u)for(i=0,v=s[u];i<o;++i)if((f=r[i]).type===v.type&&f.name===v.name)return v.value}return}for(s=e?$l:Vl,i=0;i<o;++i)this.each(s(r[i],e,n));return this}function ja(t,e,n){var r=Ga(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function jl(t,e){return function(){return ja(this,t,e)}}function Xl(t,e){return function(){return ja(this,t,e.apply(this,arguments))}}function Hl(t,e){return this.each((typeof e=="function"?Xl:jl)(t,e))}function*ql(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length,f;i<o;++i)(f=r[i])&&(yield f)}var Xa=[null];function zt(t,e){this._groups=t,this._parents=e}function lr(){return new zt([[document.documentElement]],Xa)}function Wl(){return this}zt.prototype=lr.prototype={constructor:zt,select:bc,selectAll:Tc,selectChild:Pc,selectChildren:zc,filter:Ic,data:Gc,enter:Rc,exit:Vc,join:$c,merge:Uc,selection:Wl,order:jc,sort:Xc,call:qc,nodes:Wc,node:Yc,size:Zc,empty:Qc,each:Kc,attr:ol,style:ul,property:dl,classed:gl,text:_l,html:Al,raise:Cl,lower:kl,append:Fl,insert:zl,remove:Rl,clone:Ol,datum:Nl,on:Ul,dispatch:Hl,[Symbol.iterator]:ql};function wt(t){return typeof t=="string"?new zt([[document.querySelector(t)]],[document.documentElement]):new zt([[t]],Xa)}function Yl(t){let e;for(;e=t.sourceEvent;)t=e;return t}function an(t,e){if(t=Yl(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}var Zl={value:()=>{}};function Ur(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new jr(n)}function jr(t){this._=t}function Ql(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}jr.prototype=Ur.prototype={constructor:jr,on:function(t,e){var n=this._,r=Ql(t+"",n),i,o=-1,f=r.length;if(arguments.length<2){for(;++o<f;)if((i=(t=r[o]).type)&&(i=Kl(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<f;)if(i=(t=r[o]).type)n[i]=Ha(n[i],t.name,e);else if(e==null)for(i in n)n[i]=Ha(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new jr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function Kl(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function Ha(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Zl,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Hn=0,hr=0,dr=0,qa=1e3,Xr,mr,Hr=0,An=0,qr=0,pr=typeof performance=="object"&&performance.now?performance:Date,Wa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function no(){return An||(Wa(Jl),An=pr.now()+qr)}function Jl(){An=0}function Wr(){this._call=this._time=this._next=null}Wr.prototype=Ya.prototype={constructor:Wr,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?no():+n)+(e==null?0:+e),!this._next&&mr!==this&&(mr?mr._next=this:Xr=this,mr=this),this._call=t,this._time=n,ro()},stop:function(){this._call&&(this._call=null,this._time=1/0,ro())}};function Ya(t,e,n){var r=new Wr;return r.restart(t,e,n),r}function eh(){no(),++Hn;for(var t=Xr,e;t;)(e=An-t._time)>=0&&t._call.call(null,e),t=t._next;--Hn}function Za(){An=(Hr=pr.now())+qr,Hn=hr=0;try{eh()}finally{Hn=0,nh(),An=0}}function th(){var t=pr.now(),e=t-Hr;e>qa&&(qr-=e,Hr=t)}function nh(){for(var t,e=Xr,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Xr=n);mr=t,ro(r)}function ro(t){if(!Hn){hr&&(hr=clearTimeout(hr));var e=t-An;e>24?(t<1/0&&(hr=setTimeout(Za,t-pr.now()-qr)),dr&&(dr=clearInterval(dr))):(dr||(Hr=pr.now(),dr=setInterval(th,qa)),Hn=1,Wa(Za))}}function Qa(t,e,n){var r=new Wr;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var rh=Ur("start","end","cancel","interrupt"),ih=[],Ka=0,Ja=1,io=2,Yr=3,es=4,oo=5,Zr=6;function Qr(t,e,n,r,i,o){var f=t.__transition;if(!f)t.__transition={};else if(n in f)return;oh(t,n,{name:e,index:r,group:i,on:rh,tween:ih,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Ka})}function ao(t,e){var n=Ut(t,e);if(n.state>Ka)throw new Error("too late; already scheduled");return n}function Kt(t,e){var n=Ut(t,e);if(n.state>Yr)throw new Error("too late; already running");return n}function Ut(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function oh(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=Ya(o,0,n.time);function o(c){n.state=Ja,n.timer.restart(f,n.delay,n.time),n.delay<=c&&f(c-n.delay)}function f(c){var v,b,S,D;if(n.state!==Ja)return u();for(v in r)if(D=r[v],D.name===n.name){if(D.state===Yr)return Qa(f);D.state===es?(D.state=Zr,D.timer.stop(),D.on.call("interrupt",t,t.__data__,D.index,D.group),delete r[v]):+v<e&&(D.state=Zr,D.timer.stop(),D.on.call("cancel",t,t.__data__,D.index,D.group),delete r[v])}if(Qa(function(){n.state===Yr&&(n.state=es,n.timer.restart(s,n.delay,n.time),s(c))}),n.state=io,n.on.call("start",t,t.__data__,n.index,n.group),n.state===io){for(n.state=Yr,i=new Array(S=n.tween.length),v=0,b=-1;v<S;++v)(D=n.tween[v].value.call(t,t.__data__,n.index,n.group))&&(i[++b]=D);i.length=b+1}}function s(c){for(var v=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(u),n.state=oo,1),b=-1,S=i.length;++b<S;)i[b].call(t,v);n.state===oo&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){n.state=Zr,n.timer.stop(),delete r[e];for(var c in r)return;delete t.__transition}}function Kr(t,e){var n=t.__transition,r,i,o=!0,f;if(n){e=e==null?null:e+"";for(f in n){if((r=n[f]).name!==e){o=!1;continue}i=r.state>io&&r.state<oo,r.state=Zr,r.timer.stop(),r.on.call(i?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[f]}o&&delete t.__transition}}function ah(t){return this.each(function(){Kr(this,t)})}function so(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function ts(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function vr(){}var gr=.7,Jr=1/gr,qn="\\s*([+-]?\\d+)\\s*",yr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sh=/^#([0-9a-f]{3,8})$/,fh=new RegExp(`^rgb\\(${qn},${qn},${qn}\\)$`),uh=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),ch=new RegExp(`^rgba\\(${qn},${qn},${qn},${yr}\\)$`),lh=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${yr}\\)$`),hh=new RegExp(`^hsl\\(${yr},${Jt},${Jt}\\)$`),dh=new RegExp(`^hsla\\(${yr},${Jt},${Jt},${yr}\\)$`),ns={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};so(vr,pn,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:rs,formatHex:rs,formatHex8:mh,formatHsl:ph,formatRgb:is,toString:is});function rs(){return this.rgb().formatHex()}function mh(){return this.rgb().formatHex8()}function ph(){return us(this).formatHsl()}function is(){return this.rgb().formatRgb()}function pn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=sh.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?os(e):n===3?new kt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?ei(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?ei(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=fh.exec(t))?new kt(e[1],e[2],e[3],1):(e=uh.exec(t))?new kt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ch.exec(t))?ei(e[1],e[2],e[3],e[4]):(e=lh.exec(t))?ei(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=hh.exec(t))?fs(e[1],e[2]/100,e[3]/100,1):(e=dh.exec(t))?fs(e[1],e[2]/100,e[3]/100,e[4]):ns.hasOwnProperty(t)?os(ns[t]):t==="transparent"?new kt(NaN,NaN,NaN,0):null}function os(t){return new kt(t>>16&255,t>>8&255,t&255,1)}function ei(t,e,n,r){return r<=0&&(t=e=n=NaN),new kt(t,e,n,r)}function vh(t){return t instanceof vr||(t=pn(t)),t?(t=t.rgb(),new kt(t.r,t.g,t.b,t.opacity)):new kt}function fo(t,e,n,r){return arguments.length===1?vh(t):new kt(t,e,n,r??1)}function kt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}so(kt,fo,ts(vr,{brighter(t){return t=t==null?Jr:Math.pow(Jr,t),new kt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?gr:Math.pow(gr,t),new kt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new kt(En(this.r),En(this.g),En(this.b),ti(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:as,formatHex:as,formatHex8:gh,formatRgb:ss,toString:ss}));function as(){return`#${Cn(this.r)}${Cn(this.g)}${Cn(this.b)}`}function gh(){return`#${Cn(this.r)}${Cn(this.g)}${Cn(this.b)}${Cn((isNaN(this.opacity)?1:this.opacity)*255)}`}function ss(){const t=ti(this.opacity);return`${t===1?"rgb(":"rgba("}${En(this.r)}, ${En(this.g)}, ${En(this.b)}${t===1?")":`, ${t})`}`}function ti(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function En(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Cn(t){return t=En(t),(t<16?"0":"")+t.toString(16)}function fs(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new jt(t,e,n,r)}function us(t){if(t instanceof jt)return new jt(t.h,t.s,t.l,t.opacity);if(t instanceof vr||(t=pn(t)),!t)return new jt;if(t instanceof jt)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),f=NaN,s=o-i,u=(o+i)/2;return s?(e===o?f=(n-r)/s+(n<r)*6:n===o?f=(r-e)/s+2:f=(e-n)/s+4,s/=u<.5?o+i:2-o-i,f*=60):s=u>0&&u<1?0:f,new jt(f,s,u,t.opacity)}function yh(t,e,n,r){return arguments.length===1?us(t):new jt(t,e,n,r??1)}function jt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}so(jt,yh,ts(vr,{brighter(t){return t=t==null?Jr:Math.pow(Jr,t),new jt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?gr:Math.pow(gr,t),new jt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new kt(uo(t>=240?t-240:t+120,i,r),uo(t,i,r),uo(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new jt(cs(this.h),ni(this.s),ni(this.l),ti(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ti(this.opacity);return`${t===1?"hsl(":"hsla("}${cs(this.h)}, ${ni(this.s)*100}%, ${ni(this.l)*100}%${t===1?")":`, ${t})`}`}}));function cs(t){return t=(t||0)%360,t<0?t+360:t}function ni(t){return Math.max(0,Math.min(1,t||0))}function uo(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const co=t=>()=>t;function xh(t,e){return function(n){return t+n*e}}function bh(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function _h(t){return(t=+t)==1?ls:function(e,n){return n-e?bh(e,n,t):co(isNaN(e)?n:e)}}function ls(t,e){var n=e-t;return n?xh(t,n):co(isNaN(t)?e:t)}const ri=function t(e){var n=_h(e);function r(i,o){var f=n((i=fo(i)).r,(o=fo(o)).r),s=n(i.g,o.g),u=n(i.b,o.b),c=ls(i.opacity,o.opacity);return function(v){return i.r=f(v),i.g=s(v),i.b=u(v),i.opacity=c(v),i+""}}return r.gamma=t,r}(1);function Sh(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(o){for(i=0;i<n;++i)r[i]=t[i]*(1-o)+e[i]*o;return r}}function wh(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Th(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),o=new Array(n),f;for(f=0;f<r;++f)i[f]=mo(t[f],e[f]);for(;f<n;++f)o[f]=e[f];return function(s){for(f=0;f<r;++f)o[f]=i[f](s);return o}}function Ah(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Xt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Eh(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=mo(t[i],e[i]):r[i]=e[i];return function(o){for(i in n)r[i]=n[i](o);return r}}var lo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ho=new RegExp(lo.source,"g");function Ch(t){return function(){return t}}function Ph(t){return function(e){return t(e)+""}}function hs(t,e){var n=lo.lastIndex=ho.lastIndex=0,r,i,o,f=-1,s=[],u=[];for(t=t+"",e=e+"";(r=lo.exec(t))&&(i=ho.exec(e));)(o=i.index)>n&&(o=e.slice(n,o),s[f]?s[f]+=o:s[++f]=o),(r=r[0])===(i=i[0])?s[f]?s[f]+=i:s[++f]=i:(s[++f]=null,u.push({i:f,x:Xt(r,i)})),n=ho.lastIndex;return n<e.length&&(o=e.slice(n),s[f]?s[f]+=o:s[++f]=o),s.length<2?u[0]?Ph(u[0].x):Ch(e):(e=u.length,function(c){for(var v=0,b;v<e;++v)s[(b=u[v]).i]=b.x(c);return s.join("")})}function mo(t,e){var n=typeof e,r;return e==null||n==="boolean"?co(e):(n==="number"?Xt:n==="string"?(r=pn(e))?(e=r,ri):hs:e instanceof pn?ri:e instanceof Date?Ah:wh(e)?Sh:Array.isArray(e)?Th:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Eh:Xt)(t,e)}function kh(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var ds=180/Math.PI,po={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ms(t,e,n,r,i,o){var f,s,u;return(f=Math.sqrt(t*t+e*e))&&(t/=f,e/=f),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),t*r<e*n&&(t=-t,e=-e,u=-u,f=-f),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*ds,skewX:Math.atan(u)*ds,scaleX:f,scaleY:s}}var ii;function Fh(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?po:ms(e.a,e.b,e.c,e.d,e.e,e.f)}function Lh(t){return t==null||(ii||(ii=document.createElementNS("http://www.w3.org/2000/svg","g")),ii.setAttribute("transform",t),!(t=ii.transform.baseVal.consolidate()))?po:(t=t.matrix,ms(t.a,t.b,t.c,t.d,t.e,t.f))}function ps(t,e,n,r){function i(c){return c.length?c.pop()+" ":""}function o(c,v,b,S,D,Z){if(c!==b||v!==S){var we=D.push("translate(",null,e,null,n);Z.push({i:we-4,x:Xt(c,b)},{i:we-2,x:Xt(v,S)})}else(b||S)&&D.push("translate("+b+e+S+n)}function f(c,v,b,S){c!==v?(c-v>180?v+=360:v-c>180&&(c+=360),S.push({i:b.push(i(b)+"rotate(",null,r)-2,x:Xt(c,v)})):v&&b.push(i(b)+"rotate("+v+r)}function s(c,v,b,S){c!==v?S.push({i:b.push(i(b)+"skewX(",null,r)-2,x:Xt(c,v)}):v&&b.push(i(b)+"skewX("+v+r)}function u(c,v,b,S,D,Z){if(c!==b||v!==S){var we=D.push(i(D)+"scale(",null,",",null,")");Z.push({i:we-4,x:Xt(c,b)},{i:we-2,x:Xt(v,S)})}else(b!==1||S!==1)&&D.push(i(D)+"scale("+b+","+S+")")}return function(c,v){var b=[],S=[];return c=t(c),v=t(v),o(c.translateX,c.translateY,v.translateX,v.translateY,b,S),f(c.rotate,v.rotate,b,S),s(c.skewX,v.skewX,b,S),u(c.scaleX,c.scaleY,v.scaleX,v.scaleY,b,S),c=v=null,function(D){for(var Z=-1,we=S.length,Se;++Z<we;)b[(Se=S[Z]).i]=Se.x(D);return b.join("")}}}var zh=ps(Fh,"px, ","px)","deg)"),Ih=ps(Lh,", ",")",")"),Rh=1e-12;function vs(t){return((t=Math.exp(t))+1/t)/2}function Dh(t){return((t=Math.exp(t))-1/t)/2}function Mh(t){return((t=Math.exp(2*t))-1)/(t+1)}const Oh=function t(e,n,r){function i(o,f){var s=o[0],u=o[1],c=o[2],v=f[0],b=f[1],S=f[2],D=v-s,Z=b-u,we=D*D+Z*Z,Se,ae;if(we<Rh)ae=Math.log(S/c)/e,Se=function(Me){return[s+Me*D,u+Me*Z,c*Math.exp(e*Me*ae)]};else{var Ge=Math.sqrt(we),je=(S*S-c*c+r*we)/(2*c*n*Ge),W=(S*S-c*c-r*we)/(2*S*n*Ge),le=Math.log(Math.sqrt(je*je+1)-je),Le=Math.log(Math.sqrt(W*W+1)-W);ae=(Le-le)/e,Se=function(Me){var Xe=Me*ae,et=vs(le),nt=c/(n*Ge)*(et*Mh(e*Xe+le)-Dh(le));return[s+nt*D,u+nt*Z,c*et/vs(e*Xe+le)]}}return Se.duration=ae*1e3*e/Math.SQRT2,Se}return i.rho=function(o){var f=Math.max(.001,+o),s=f*f,u=s*s;return t(f,s,u)},i}(Math.SQRT2,2,4);function Nh(t,e){var n,r;return function(){var i=Kt(this,t),o=i.tween;if(o!==n){r=n=o;for(var f=0,s=r.length;f<s;++f)if(r[f].name===e){r=r.slice(),r.splice(f,1);break}}i.tween=r}}function Gh(t,e,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Kt(this,t),f=o.tween;if(f!==r){i=(r=f).slice();for(var s={name:e,value:n},u=0,c=i.length;u<c;++u)if(i[u].name===e){i[u]=s;break}u===c&&i.push(s)}o.tween=i}}function Bh(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=Ut(this.node(),n).tween,i=0,o=r.length,f;i<o;++i)if((f=r[i]).name===t)return f.value;return null}return this.each((e==null?Nh:Gh)(n,t,e))}function vo(t,e,n){var r=t._id;return t.each(function(){var i=Kt(this,r);(i.value||(i.value={}))[e]=n.apply(this,arguments)}),function(i){return Ut(i,r).value[e]}}function gs(t,e){var n;return(typeof e=="number"?Xt:e instanceof pn?ri:(n=pn(e))?(e=n,ri):hs)(t,e)}function Vh(t){return function(){this.removeAttribute(t)}}function $h(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Uh(t,e,n){var r,i=n+"",o;return function(){var f=this.getAttribute(t);return f===i?null:f===r?o:o=e(r=f,n)}}function jh(t,e,n){var r,i=n+"",o;return function(){var f=this.getAttributeNS(t.space,t.local);return f===i?null:f===r?o:o=e(r=f,n)}}function Xh(t,e,n){var r,i,o;return function(){var f,s=n(this),u;return s==null?void this.removeAttribute(t):(f=this.getAttribute(t),u=s+"",f===u?null:f===r&&u===i?o:(i=u,o=e(r=f,s)))}}function Hh(t,e,n){var r,i,o;return function(){var f,s=n(this),u;return s==null?void this.removeAttributeNS(t.space,t.local):(f=this.getAttributeNS(t.space,t.local),u=s+"",f===u?null:f===r&&u===i?o:(i=u,o=e(r=f,s)))}}function qh(t,e){var n=Vr(t),r=n==="transform"?Ih:gs;return this.attrTween(t,typeof e=="function"?(n.local?Hh:Xh)(n,r,vo(this,"attr."+t,e)):e==null?(n.local?$h:Vh)(n):(n.local?jh:Uh)(n,r,e))}function Wh(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Yh(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function Zh(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&Yh(t,o)),n}return i._value=e,i}function Qh(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&Wh(t,o)),n}return i._value=e,i}function Kh(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Vr(t);return this.tween(n,(r.local?Zh:Qh)(r,e))}function Jh(t,e){return function(){ao(this,t).delay=+e.apply(this,arguments)}}function ed(t,e){return e=+e,function(){ao(this,t).delay=e}}function td(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Jh:ed)(e,t)):Ut(this.node(),e).delay}function nd(t,e){return function(){Kt(this,t).duration=+e.apply(this,arguments)}}function rd(t,e){return e=+e,function(){Kt(this,t).duration=e}}function id(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?nd:rd)(e,t)):Ut(this.node(),e).duration}function od(t,e){if(typeof e!="function")throw new Error;return function(){Kt(this,t).ease=e}}function ad(t){var e=this._id;return arguments.length?this.each(od(e,t)):Ut(this.node(),e).ease}function sd(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Kt(this,t).ease=n}}function fd(t){if(typeof t!="function")throw new Error;return this.each(sd(this._id,t))}function ud(t){typeof t!="function"&&(t=Ma(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],f=o.length,s=r[i]=[],u,c=0;c<f;++c)(u=o[c])&&t.call(u,u.__data__,c,o)&&s.push(u);return new sn(r,this._parents,this._name,this._id)}function cd(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),f=new Array(r),s=0;s<o;++s)for(var u=e[s],c=n[s],v=u.length,b=f[s]=new Array(v),S,D=0;D<v;++D)(S=u[D]||c[D])&&(b[D]=S);for(;s<r;++s)f[s]=e[s];return new sn(f,this._parents,this._name,this._id)}function ld(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function hd(t,e,n){var r,i,o=ld(e)?ao:Kt;return function(){var f=o(this,t),s=f.on;s!==r&&(i=(r=s).copy()).on(e,n),f.on=i}}function dd(t,e){var n=this._id;return arguments.length<2?Ut(this.node(),n).on.on(t):this.each(hd(n,t,e))}function md(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function pd(){return this.on("end.remove",md(this._id))}function vd(t){var e=this._name,n=this._id;typeof t!="function"&&(t=eo(t));for(var r=this._groups,i=r.length,o=new Array(i),f=0;f<i;++f)for(var s=r[f],u=s.length,c=o[f]=new Array(u),v,b,S=0;S<u;++S)(v=s[S])&&(b=t.call(v,v.__data__,S,s))&&("__data__"in v&&(b.__data__=v.__data__),c[S]=b,Qr(c[S],e,n,S,c,Ut(v,n)));return new sn(o,this._parents,e,n)}function gd(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Da(t));for(var r=this._groups,i=r.length,o=[],f=[],s=0;s<i;++s)for(var u=r[s],c=u.length,v,b=0;b<c;++b)if(v=u[b]){for(var S=t.call(v,v.__data__,b,u),D,Z=Ut(v,n),we=0,Se=S.length;we<Se;++we)(D=S[we])&&Qr(D,e,n,we,S,Z);o.push(S),f.push(v)}return new sn(o,f,e,n)}var yd=lr.prototype.constructor;function xd(){return new yd(this._groups,this._parents)}function bd(t,e){var n,r,i;return function(){var o=Xn(this,t),f=(this.style.removeProperty(t),Xn(this,t));return o===f?null:o===n&&f===r?i:i=e(n=o,r=f)}}function ys(t){return function(){this.style.removeProperty(t)}}function _d(t,e,n){var r,i=n+"",o;return function(){var f=Xn(this,t);return f===i?null:f===r?o:o=e(r=f,n)}}function Sd(t,e,n){var r,i,o;return function(){var f=Xn(this,t),s=n(this),u=s+"";return s==null&&(u=s=(this.style.removeProperty(t),Xn(this,t))),f===u?null:f===r&&u===i?o:(i=u,o=e(r=f,s))}}function wd(t,e){var n,r,i,o="style."+e,f="end."+o,s;return function(){var u=Kt(this,t),c=u.on,v=u.value[o]==null?s||(s=ys(e)):void 0;(c!==n||i!==v)&&(r=(n=c).copy()).on(f,i=v),u.on=r}}function Td(t,e,n){var r=(t+="")=="transform"?zh:gs;return e==null?this.styleTween(t,bd(t,r)).on("end.style."+t,ys(t)):typeof e=="function"?this.styleTween(t,Sd(t,r,vo(this,"style."+t,e))).each(wd(this._id,t)):this.styleTween(t,_d(t,r,e),n).on("end.style."+t,null)}function Ad(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Ed(t,e,n){var r,i;function o(){var f=e.apply(this,arguments);return f!==i&&(r=(i=f)&&Ad(t,f,n)),r}return o._value=e,o}function Cd(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,Ed(t,e,n??""))}function Pd(t){return function(){this.textContent=t}}function kd(t){return function(){var e=t(this);this.textContent=e??""}}function Fd(t){return this.tween("text",typeof t=="function"?kd(vo(this,"text",t)):Pd(t==null?"":t+""))}function Ld(t){return function(e){this.textContent=t.call(this,e)}}function zd(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&Ld(i)),e}return r._value=t,r}function Id(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,zd(t))}function Rd(){for(var t=this._name,e=this._id,n=xs(),r=this._groups,i=r.length,o=0;o<i;++o)for(var f=r[o],s=f.length,u,c=0;c<s;++c)if(u=f[c]){var v=Ut(u,e);Qr(u,t,n,c,f,{time:v.time+v.delay+v.duration,delay:0,duration:v.duration,ease:v.ease})}return new sn(r,this._parents,t,n)}function Dd(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,f){var s={value:f},u={value:function(){--i===0&&o()}};n.each(function(){var c=Kt(this,r),v=c.on;v!==t&&(e=(t=v).copy(),e._.cancel.push(s),e._.interrupt.push(s),e._.end.push(u)),c.on=e}),i===0&&o()})}var Md=0;function sn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function xs(){return++Md}var fn=lr.prototype;sn.prototype={constructor:sn,select:vd,selectAll:gd,selectChild:fn.selectChild,selectChildren:fn.selectChildren,filter:ud,merge:cd,selection:xd,transition:Rd,call:fn.call,nodes:fn.nodes,node:fn.node,size:fn.size,empty:fn.empty,each:fn.each,on:dd,attr:qh,attrTween:Kh,style:Td,styleTween:Cd,text:Fd,textTween:Id,remove:pd,tween:Bh,delay:td,duration:id,ease:ad,easeVarying:fd,end:Dd,[Symbol.iterator]:fn[Symbol.iterator]};function Od(t){return t*t}function Nd(t){return t*(2-t)}function Gd(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function Bd(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Vd={time:null,delay:0,duration:250,ease:Bd};function $d(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function Ud(t){var e,n;t instanceof sn?(e=t._id,t=t._name):(e=xs(),(n=Vd).time=no(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var f=r[o],s=f.length,u,c=0;c<s;++c)(u=f[c])&&Qr(u,t,e,c,f,n||$d(u,e));return new sn(r,this._parents,t,e)}lr.prototype.interrupt=ah,lr.prototype.transition=Ud;function go(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function jd(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var oi={exports:{}},Xd=oi.exports,bs;function Hd(){return bs||(bs=1,function(t,e){(function(n,r){t.exports=r()})(Xd,function(){var n=function(a){return a instanceof Uint8Array||a instanceof Uint16Array||a instanceof Uint32Array||a instanceof Int8Array||a instanceof Int16Array||a instanceof Int32Array||a instanceof Float32Array||a instanceof Float64Array||a instanceof Uint8ClampedArray},r=function(a,h){for(var _=Object.keys(h),R=0;R<_.length;++R)a[_[R]]=h[_[R]];return a},i=`
2
+ `;function o(a){return typeof atob<"u"?atob(a):"base64:"+a}function f(a){var h=new Error("(regl) "+a);throw console.error(h),h}function s(a,h){a||f(h)}function u(a){return a?": "+a:""}function c(a,h,_){a in h||f("unknown parameter ("+a+")"+u(_)+". possible values: "+Object.keys(h).join())}function v(a,h){n(a)||f("invalid parameter type"+u(h)+". must be a typed array")}function b(a,h){switch(h){case"number":return typeof a=="number";case"object":return typeof a=="object";case"string":return typeof a=="string";case"boolean":return typeof a=="boolean";case"function":return typeof a=="function";case"undefined":return typeof a>"u";case"symbol":return typeof a=="symbol"}}function S(a,h,_){b(a,h)||f("invalid parameter type"+u(_)+". expected "+h+", got "+typeof a)}function D(a,h){a>=0&&(a|0)===a||f("invalid parameter type, ("+a+")"+u(h)+". must be a nonnegative integer")}function Z(a,h,_){h.indexOf(a)<0&&f("invalid value"+u(_)+". must be one of: "+h)}var we=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function Se(a){Object.keys(a).forEach(function(h){we.indexOf(h)<0&&f('invalid regl constructor argument "'+h+'". must be one of '+we)})}function ae(a,h){for(a=a+"";a.length<h;)a=" "+a;return a}function Ge(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function je(a,h){this.number=a,this.line=h,this.errors=[]}function W(a,h,_){this.file=a,this.line=h,this.message=_}function le(){var a=new Error,h=(a.stack||a).toString(),_=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(h);if(_)return _[1];var R=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(h);return R?R[1]:"unknown"}function Le(){var a=new Error,h=(a.stack||a).toString(),_=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(h);if(_)return _[1];var R=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(h);return R?R[1]:"unknown"}function Me(a,h){var _=a.split(`
3
+ `),R=1,U=0,I={unknown:new Ge,0:new Ge};I.unknown.name=I[0].name=h||le(),I.unknown.lines.push(new je(0,""));for(var G=0;G<_.length;++G){var Q=_[G],Y=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(Q);if(Y)switch(Y[1]){case"line":var ne=/(\d+)(\s+\d+)?/.exec(Y[2]);ne&&(R=ne[1]|0,ne[2]&&(U=ne[2]|0,U in I||(I[U]=new Ge)));break;case"define":var ie=/SHADER_NAME(_B64)?\s+(.*)$/.exec(Y[2]);ie&&(I[U].name=ie[1]?o(ie[2]):ie[2]);break}I[U].lines.push(new je(R++,Q))}return Object.keys(I).forEach(function(re){var fe=I[re];fe.lines.forEach(function(K){fe.index[K.number]=K})}),I}function Xe(a){var h=[];return a.split(`
4
+ `).forEach(function(_){if(!(_.length<5)){var R=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(_);R?h.push(new W(R[1]|0,R[2]|0,R[3].trim())):_.length>0&&h.push(new W("unknown",0,_))}}),h}function et(a,h){h.forEach(function(_){var R=a[_.file];if(R){var U=R.index[_.line];if(U){U.errors.push(_),R.hasErrors=!0;return}}a.unknown.hasErrors=!0,a.unknown.lines[0].errors.push(_)})}function nt(a,h,_,R,U){if(!a.getShaderParameter(h,a.COMPILE_STATUS)){var I=a.getShaderInfoLog(h),G=R===a.FRAGMENT_SHADER?"fragment":"vertex";Ce(_,"string",G+" shader source must be a string",U);var Q=Me(_,U),Y=Xe(I);et(Q,Y),Object.keys(Q).forEach(function(ne){var ie=Q[ne];if(!ie.hasErrors)return;var re=[""],fe=[""];function K(te,P){re.push(te),fe.push(P||"")}K("file number "+ne+": "+ie.name+`
5
+ `,"color:red;text-decoration:underline;font-weight:bold"),ie.lines.forEach(function(te){if(te.errors.length>0){K(ae(te.number,4)+"| ","background-color:yellow; font-weight:bold"),K(te.line+i,"color:red; background-color:yellow; font-weight:bold");var P=0;te.errors.forEach(function(O){var ee=O.message,ge=/^\s*'(.*)'\s*:\s*(.*)$/.exec(ee);if(ge){var q=ge[1];switch(ee=ge[2],q){case"assign":q="=";break}P=Math.max(te.line.indexOf(q,P),0)}else P=0;K(ae("| ",6)),K(ae("^^^",P+3)+i,"font-weight:bold"),K(ae("| ",6)),K(ee+i,"font-weight:bold")}),K(ae("| ",6)+i)}else K(ae(te.number,4)+"| "),K(te.line+i,"color:red")}),typeof document<"u"&&!window.chrome?(fe[0]=re.join("%c"),console.log.apply(console,fe)):console.log(re.join(""))}),s.raise("Error compiling "+G+" shader, "+Q[0].name)}}function ke(a,h,_,R,U){if(!a.getProgramParameter(h,a.LINK_STATUS)){var I=a.getProgramInfoLog(h),G=Me(_,U),Q=Me(R,U),Y='Error linking program with vertex shader, "'+Q[0].name+'", and fragment shader "'+G[0].name+'"';typeof document<"u"?console.log("%c"+Y+i+"%c"+I,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(Y+i+I),s.raise(Y)}}function it(a){a._commandRef=le()}function tt(a,h,_,R){it(a);function U(Y){return Y?R.id(Y):0}a._fragId=U(a.static.frag),a._vertId=U(a.static.vert);function I(Y,ne){Object.keys(ne).forEach(function(ie){Y[R.id(ie)]=!0})}var G=a._uniformSet={};I(G,h.static),I(G,h.dynamic);var Q=a._attributeSet={};I(Q,_.static),I(Q,_.dynamic),a._hasCount="count"in a.static||"count"in a.dynamic||"elements"in a.static||"elements"in a.dynamic}function N(a,h){var _=Le();f(a+" in command "+(h||le())+(_==="unknown"?"":" called from "+_))}function Ae(a,h,_){a||N(h,_||le())}function oe(a,h,_,R){a in h||N("unknown parameter ("+a+")"+u(_)+". possible values: "+Object.keys(h).join(),R||le())}function Ce(a,h,_,R){b(a,h)||N("invalid parameter type"+u(_)+". expected "+h+", got "+typeof a,R||le())}function Ue(a){a()}function Ve(a,h,_){a.texture?Z(a.texture._texture.internalformat,h,"unsupported texture format for attachment"):Z(a.renderbuffer._renderbuffer.format,_,"unsupported renderbuffer format for attachment")}var Ye=33071,rt=9728,ut=9984,Bt=9985,_t=9986,It=9987,Wt=5120,Rt=5121,Yt=5122,Sr=5123,C0=5124,P0=5125,df=5126,mf=32819,pf=32820,vf=33635,gf=34042,k0=36193,Dt={};Dt[Wt]=Dt[Rt]=1,Dt[Yt]=Dt[Sr]=Dt[k0]=Dt[vf]=Dt[mf]=Dt[pf]=2,Dt[C0]=Dt[P0]=Dt[df]=Dt[gf]=4;function yf(a,h){return a===pf||a===mf||a===vf?2:a===gf?4:Dt[a]*h}function _i(a){return!(a&a-1)&&!!a}function F0(a,h,_){var R,U=h.width,I=h.height,G=h.channels;s(U>0&&U<=_.maxTextureSize&&I>0&&I<=_.maxTextureSize,"invalid texture shape"),(a.wrapS!==Ye||a.wrapT!==Ye)&&s(_i(U)&&_i(I),"incompatible wrap mode for texture, both width and height must be power of 2"),h.mipmask===1?U!==1&&I!==1&&s(a.minFilter!==ut&&a.minFilter!==_t&&a.minFilter!==Bt&&a.minFilter!==It,"min filter requires mipmap"):(s(_i(U)&&_i(I),"texture must be a square power of 2 to support mipmapping"),s(h.mipmask===(U<<1)-1,"missing or incomplete mipmap data")),h.type===df&&(_.extensions.indexOf("oes_texture_float_linear")<0&&s(a.minFilter===rt&&a.magFilter===rt,"filter not supported, must enable oes_texture_float_linear"),s(!a.genMipmaps,"mipmap generation not supported with float textures"));var Q=h.images;for(R=0;R<16;++R)if(Q[R]){var Y=U>>R,ne=I>>R;s(h.mipmask&1<<R,"missing mipmap data");var ie=Q[R];if(s(ie.width===Y&&ie.height===ne,"invalid shape for mip images"),s(ie.format===h.format&&ie.internalformat===h.internalformat&&ie.type===h.type,"incompatible type for mip image"),!ie.compressed)if(ie.data){var re=Math.ceil(yf(ie.type,G)*Y/ie.unpackAlignment)*ie.unpackAlignment;s(ie.data.byteLength===re*ne,"invalid data for image, buffer size is inconsistent with image format")}else ie.element||ie.copy}else a.genMipmaps||s((h.mipmask&1<<R)===0,"extra mipmap data");h.compressed&&s(!a.genMipmaps,"mipmap generation for compressed images not supported")}function L0(a,h,_,R){var U=a.width,I=a.height,G=a.channels;s(U>0&&U<=R.maxTextureSize&&I>0&&I<=R.maxTextureSize,"invalid texture shape"),s(U===I,"cube map must be square"),s(h.wrapS===Ye&&h.wrapT===Ye,"wrap mode not supported by cube map");for(var Q=0;Q<_.length;++Q){var Y=_[Q];s(Y.width===U&&Y.height===I,"inconsistent cube map face shape"),h.genMipmaps&&(s(!Y.compressed,"can not generate mipmap for compressed textures"),s(Y.mipmask===1,"can not specify mipmaps and generate mipmaps"));for(var ne=Y.images,ie=0;ie<16;++ie){var re=ne[ie];if(re){var fe=U>>ie,K=I>>ie;s(Y.mipmask&1<<ie,"missing mipmap data"),s(re.width===fe&&re.height===K,"invalid shape for mip images"),s(re.format===a.format&&re.internalformat===a.internalformat&&re.type===a.type,"incompatible type for mip image"),re.compressed||(re.data?s(re.data.byteLength===fe*K*Math.max(yf(re.type,G),re.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):re.element||re.copy)}}}}var d=r(s,{optional:Ue,raise:f,commandRaise:N,command:Ae,parameter:c,commandParameter:oe,constructor:Se,type:S,commandType:Ce,isTypedArray:v,nni:D,oneOf:Z,shaderError:nt,linkError:ke,callSite:Le,saveCommandRef:it,saveDrawInfo:tt,framebufferFormat:Ve,guessCommand:le,texture2D:F0,textureCube:L0}),z0=0,I0=0,R0=5,D0=6;function Fn(a,h){this.id=z0++,this.type=a,this.data=h}function xf(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function wr(a){if(a.length===0)return[];var h=a.charAt(0),_=a.charAt(a.length-1);if(a.length>1&&h===_&&(h==='"'||h==="'"))return['"'+xf(a.substr(1,a.length-2))+'"'];var R=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(a);if(R)return wr(a.substr(0,R.index)).concat(wr(R[1])).concat(wr(a.substr(R.index+R[0].length)));var U=a.split(".");if(U.length===1)return['"'+xf(a)+'"'];for(var I=[],G=0;G<U.length;++G)I=I.concat(wr(U[G]));return I}function bf(a){return"["+wr(a).join("][")+"]"}function M0(a,h){return new Fn(a,bf(h+""))}function O0(a){return typeof a=="function"&&!a._reglType||a instanceof Fn}function _f(a,h){if(typeof a=="function")return new Fn(I0,a);if(typeof a=="number"||typeof a=="boolean")return new Fn(R0,a);if(Array.isArray(a))return new Fn(D0,a.map(function(_,R){return _f(_,h+"["+R+"]")}));if(a instanceof Fn)return a;d(!1,"invalid option type in uniform "+h)}var Mt={DynamicVariable:Fn,define:M0,isDynamic:O0,unbox:_f,accessor:bf},Mo={next:typeof requestAnimationFrame=="function"?function(a){return requestAnimationFrame(a)}:function(a){return setTimeout(a,16)},cancel:typeof cancelAnimationFrame=="function"?function(a){return cancelAnimationFrame(a)}:clearTimeout},Sf=typeof performance<"u"&&performance.now?function(){return performance.now()}:function(){return+new Date};function N0(){var a={"":0},h=[""];return{id:function(_){var R=a[_];return R||(R=a[_]=h.length,h.push(_),R)},str:function(_){return h[_]}}}function G0(a,h,_){var R=document.createElement("canvas");r(R.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),a.appendChild(R),a===document.body&&(R.style.position="absolute",r(a.style,{margin:0,padding:0}));function U(){var Q=window.innerWidth,Y=window.innerHeight;if(a!==document.body){var ne=R.getBoundingClientRect();Q=ne.right-ne.left,Y=ne.bottom-ne.top}R.width=_*Q,R.height=_*Y}var I;a!==document.body&&typeof ResizeObserver=="function"?(I=new ResizeObserver(function(){setTimeout(U)}),I.observe(a)):window.addEventListener("resize",U,!1);function G(){I?I.disconnect():window.removeEventListener("resize",U),a.removeChild(R)}return U(),{canvas:R,onDestroy:G}}function B0(a,h){function _(R){try{return a.getContext(R,h)}catch{return null}}return _("webgl")||_("experimental-webgl")||_("webgl-experimental")}function V0(a){return typeof a.nodeName=="string"&&typeof a.appendChild=="function"&&typeof a.getBoundingClientRect=="function"}function $0(a){return typeof a.drawArrays=="function"||typeof a.drawElements=="function"}function wf(a){return typeof a=="string"?a.split():(d(Array.isArray(a),"invalid extension array"),a)}function Tf(a){return typeof a=="string"?(d(typeof document<"u","not supported outside of DOM"),document.querySelector(a)):a}function U0(a){var h=a||{},_,R,U,I,G={},Q=[],Y=[],ne=typeof window>"u"?1:window.devicePixelRatio,ie=!1,re=function(te){te&&d.raise(te)},fe=function(){};if(typeof h=="string"?(d(typeof document<"u","selector queries only supported in DOM enviroments"),_=document.querySelector(h),d(_,"invalid query string for element")):typeof h=="object"?V0(h)?_=h:$0(h)?(I=h,U=I.canvas):(d.constructor(h),"gl"in h?I=h.gl:"canvas"in h?U=Tf(h.canvas):"container"in h&&(R=Tf(h.container)),"attributes"in h&&(G=h.attributes,d.type(G,"object","invalid context attributes")),"extensions"in h&&(Q=wf(h.extensions)),"optionalExtensions"in h&&(Y=wf(h.optionalExtensions)),"onDone"in h&&(d.type(h.onDone,"function","invalid or missing onDone callback"),re=h.onDone),"profile"in h&&(ie=!!h.profile),"pixelRatio"in h&&(ne=+h.pixelRatio,d(ne>0,"invalid pixel ratio"))):d.raise("invalid arguments to regl"),_&&(_.nodeName.toLowerCase()==="canvas"?U=_:R=_),!I){if(!U){d(typeof document<"u","must manually specify webgl context outside of DOM environments");var K=G0(R||document.body,re,ne);if(!K)return null;U=K.canvas,fe=K.onDestroy}G.premultipliedAlpha===void 0&&(G.premultipliedAlpha=!0),I=B0(U,G)}return I?{gl:I,canvas:U,container:R,extensions:Q,optionalExtensions:Y,pixelRatio:ne,profile:ie,onDone:re,onDestroy:fe}:(fe(),re("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function j0(a,h){var _={};function R(G){d.type(G,"string","extension name must be string");var Q=G.toLowerCase(),Y;try{Y=_[Q]=a.getExtension(Q)}catch{}return!!Y}for(var U=0;U<h.extensions.length;++U){var I=h.extensions[U];if(!R(I))return h.onDestroy(),h.onDone('"'+I+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return h.optionalExtensions.forEach(R),{extensions:_,restore:function(){Object.keys(_).forEach(function(G){if(_[G]&&!R(G))throw new Error("(regl): error restoring extension "+G)})}}}function Ot(a,h){for(var _=Array(a),R=0;R<a;++R)_[R]=h(R);return _}var X0=5120,H0=5121,q0=5122,W0=5123,Y0=5124,Z0=5125,Q0=5126;function K0(a){for(var h=16;h<=1<<28;h*=16)if(a<=h)return h;return 0}function Af(a){var h,_;return h=(a>65535)<<4,a>>>=h,_=(a>255)<<3,a>>>=_,h|=_,_=(a>15)<<2,a>>>=_,h|=_,_=(a>3)<<1,a>>>=_,h|=_,h|a>>1}function Ef(){var a=Ot(8,function(){return[]});function h(I){var G=K0(I),Q=a[Af(G)>>2];return Q.length>0?Q.pop():new ArrayBuffer(G)}function _(I){a[Af(I.byteLength)>>2].push(I)}function R(I,G){var Q=null;switch(I){case X0:Q=new Int8Array(h(G),0,G);break;case H0:Q=new Uint8Array(h(G),0,G);break;case q0:Q=new Int16Array(h(2*G),0,G);break;case W0:Q=new Uint16Array(h(2*G),0,G);break;case Y0:Q=new Int32Array(h(4*G),0,G);break;case Z0:Q=new Uint32Array(h(4*G),0,G);break;case Q0:Q=new Float32Array(h(4*G),0,G);break;default:return null}return Q.length!==G?Q.subarray(0,G):Q}function U(I){_(I.buffer)}return{alloc:h,free:_,allocType:R,freeType:U}}var ht=Ef();ht.zero=Ef();var J0=3408,ev=3410,tv=3411,nv=3412,rv=3413,iv=3414,ov=3415,av=33901,sv=33902,fv=3379,uv=3386,cv=34921,lv=36347,hv=36348,dv=35661,mv=35660,pv=34930,vv=36349,gv=34076,yv=34024,xv=7936,bv=7937,_v=7938,Sv=35724,wv=34047,Tv=36063,Av=34852,Si=3553,Cf=34067,Ev=34069,Cv=33984,Tr=6408,Oo=5126,Pf=5121,No=36160,Pv=36053,kv=36064,Fv=16384,Lv=function(a,h){var _=1;h.ext_texture_filter_anisotropic&&(_=a.getParameter(wv));var R=1,U=1;h.webgl_draw_buffers&&(R=a.getParameter(Av),U=a.getParameter(Tv));var I=!!h.oes_texture_float;if(I){var G=a.createTexture();a.bindTexture(Si,G),a.texImage2D(Si,0,Tr,1,1,0,Tr,Oo,null);var Q=a.createFramebuffer();if(a.bindFramebuffer(No,Q),a.framebufferTexture2D(No,kv,Si,G,0),a.bindTexture(Si,null),a.checkFramebufferStatus(No)!==Pv)I=!1;else{a.viewport(0,0,1,1),a.clearColor(1,0,0,1),a.clear(Fv);var Y=ht.allocType(Oo,4);a.readPixels(0,0,1,1,Tr,Oo,Y),a.getError()?I=!1:(a.deleteFramebuffer(Q),a.deleteTexture(G),I=Y[0]===1),ht.freeType(Y)}}var ne=typeof navigator<"u"&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent)),ie=!0;if(!ne){var re=a.createTexture(),fe=ht.allocType(Pf,36);a.activeTexture(Cv),a.bindTexture(Cf,re),a.texImage2D(Ev,0,Tr,3,3,0,Tr,Pf,fe),ht.freeType(fe),a.bindTexture(Cf,null),a.deleteTexture(re),ie=!a.getError()}return{colorBits:[a.getParameter(ev),a.getParameter(tv),a.getParameter(nv),a.getParameter(rv)],depthBits:a.getParameter(iv),stencilBits:a.getParameter(ov),subpixelBits:a.getParameter(J0),extensions:Object.keys(h).filter(function(K){return!!h[K]}),maxAnisotropic:_,maxDrawbuffers:R,maxColorAttachments:U,pointSizeDims:a.getParameter(av),lineWidthDims:a.getParameter(sv),maxViewportDims:a.getParameter(uv),maxCombinedTextureUnits:a.getParameter(dv),maxCubeMapSize:a.getParameter(gv),maxRenderbufferSize:a.getParameter(yv),maxTextureUnits:a.getParameter(pv),maxTextureSize:a.getParameter(fv),maxAttributes:a.getParameter(cv),maxVertexUniforms:a.getParameter(lv),maxVertexTextureUnits:a.getParameter(mv),maxVaryingVectors:a.getParameter(hv),maxFragmentUniforms:a.getParameter(vv),glsl:a.getParameter(Sv),renderer:a.getParameter(bv),vendor:a.getParameter(xv),version:a.getParameter(_v),readFloat:I,npotTextureCube:ie}};function Zt(a){return!!a&&typeof a=="object"&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&typeof a.offset=="number"&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||n(a.data))}var Nt=function(a){return Object.keys(a).map(function(h){return a[h]})},wi={shape:Dv,flatten:Rv};function zv(a,h,_){for(var R=0;R<h;++R)_[R]=a[R]}function Iv(a,h,_,R){for(var U=0,I=0;I<h;++I)for(var G=a[I],Q=0;Q<_;++Q)R[U++]=G[Q]}function kf(a,h,_,R,U,I){for(var G=I,Q=0;Q<h;++Q)for(var Y=a[Q],ne=0;ne<_;++ne)for(var ie=Y[ne],re=0;re<R;++re)U[G++]=ie[re]}function Ff(a,h,_,R,U){for(var I=1,G=_+1;G<h.length;++G)I*=h[G];var Q=h[_];if(h.length-_===4){var Y=h[_+1],ne=h[_+2],ie=h[_+3];for(G=0;G<Q;++G)kf(a[G],Y,ne,ie,R,U),U+=I}else for(G=0;G<Q;++G)Ff(a[G],h,_+1,R,U),U+=I}function Rv(a,h,_,R){var U=1;if(h.length)for(var I=0;I<h.length;++I)U*=h[I];else U=0;var G=R||ht.allocType(_,U);switch(h.length){case 0:break;case 1:zv(a,h[0],G);break;case 2:Iv(a,h[0],h[1],G);break;case 3:kf(a,h[0],h[1],h[2],G,0);break;default:Ff(a,h,0,G,0)}return G}function Dv(a){for(var h=[],_=a;_.length;_=_[0])h.push(_.length);return h}var Go={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Mv=5120,Ov=5122,Nv=5124,Gv=5121,Bv=5123,Vv=5125,$v=5126,Uv=5126,Ln={int8:Mv,int16:Ov,int32:Nv,uint8:Gv,uint16:Bv,uint32:Vv,float:$v,float32:Uv},jv=35048,Xv=35040,Ti={dynamic:jv,stream:Xv,static:35044},Bo=wi.flatten,Lf=wi.shape,zf=35044,Hv=35040,Vo=5121,$o=5126,gn=[];gn[5120]=1,gn[5122]=2,gn[5124]=4,gn[5121]=1,gn[5123]=2,gn[5125]=4,gn[5126]=4;function Ai(a){return Go[Object.prototype.toString.call(a)]|0}function If(a,h){for(var _=0;_<h.length;++_)a[_]=h[_]}function Rf(a,h,_,R,U,I,G){for(var Q=0,Y=0;Y<_;++Y)for(var ne=0;ne<R;++ne)a[Q++]=h[U*Y+I*ne+G]}function qv(a,h,_,R){var U=0,I={};function G(P){this.id=U++,this.buffer=a.createBuffer(),this.type=P,this.usage=zf,this.byteLength=0,this.dimension=1,this.dtype=Vo,this.persistentData=null,_.profile&&(this.stats={size:0})}G.prototype.bind=function(){a.bindBuffer(this.type,this.buffer)},G.prototype.destroy=function(){fe(this)};var Q=[];function Y(P,O){var ee=Q.pop();return ee||(ee=new G(P)),ee.bind(),re(ee,O,Hv,0,1,!1),ee}function ne(P){Q.push(P)}function ie(P,O,ee){P.byteLength=O.byteLength,a.bufferData(P.type,O,ee)}function re(P,O,ee,ge,q,pe){var de;if(P.usage=ee,Array.isArray(O)){if(P.dtype=ge||$o,O.length>0){var Pe;if(Array.isArray(O[0])){de=Lf(O);for(var j=1,$=1;$<de.length;++$)j*=de[$];P.dimension=j,Pe=Bo(O,de,P.dtype),ie(P,Pe,ee),pe?P.persistentData=Pe:ht.freeType(Pe)}else if(typeof O[0]=="number"){P.dimension=q;var be=ht.allocType(P.dtype,O.length);If(be,O),ie(P,be,ee),pe?P.persistentData=be:ht.freeType(be)}else n(O[0])?(P.dimension=O[0].length,P.dtype=ge||Ai(O[0])||$o,Pe=Bo(O,[O.length,O[0].length],P.dtype),ie(P,Pe,ee),pe?P.persistentData=Pe:ht.freeType(Pe)):d.raise("invalid buffer data")}}else if(n(O))P.dtype=ge||Ai(O),P.dimension=q,ie(P,O,ee),pe&&(P.persistentData=new Uint8Array(new Uint8Array(O.buffer)));else if(Zt(O)){de=O.shape;var ue=O.stride,J=O.offset,ce=0,he=0,Oe=0,De=0;de.length===1?(ce=de[0],he=1,Oe=ue[0],De=0):de.length===2?(ce=de[0],he=de[1],Oe=ue[0],De=ue[1]):d.raise("invalid shape"),P.dtype=ge||Ai(O.data)||$o,P.dimension=he;var me=ht.allocType(P.dtype,ce*he);Rf(me,O.data,ce,he,Oe,De,J),ie(P,me,ee),pe?P.persistentData=me:ht.freeType(me)}else O instanceof ArrayBuffer?(P.dtype=Vo,P.dimension=q,ie(P,O,ee),pe&&(P.persistentData=new Uint8Array(new Uint8Array(O)))):d.raise("invalid buffer data")}function fe(P){h.bufferCount--,R(P);var O=P.buffer;d(O,"buffer must not be deleted already"),a.deleteBuffer(O),P.buffer=null,delete I[P.id]}function K(P,O,ee,ge){h.bufferCount++;var q=new G(O);I[q.id]=q;function pe(j){var $=zf,be=null,ue=0,J=0,ce=1;return Array.isArray(j)||n(j)||Zt(j)||j instanceof ArrayBuffer?be=j:typeof j=="number"?ue=j|0:j&&(d.type(j,"object","buffer arguments must be an object, a number or an array"),"data"in j&&(d(be===null||Array.isArray(be)||n(be)||Zt(be),"invalid data for buffer"),be=j.data),"usage"in j&&(d.parameter(j.usage,Ti,"invalid buffer usage"),$=Ti[j.usage]),"type"in j&&(d.parameter(j.type,Ln,"invalid buffer type"),J=Ln[j.type]),"dimension"in j&&(d.type(j.dimension,"number","invalid dimension"),ce=j.dimension|0),"length"in j&&(d.nni(ue,"buffer length must be a nonnegative integer"),ue=j.length|0)),q.bind(),be?re(q,be,$,J,ce,ge):(ue&&a.bufferData(q.type,ue,$),q.dtype=J||Vo,q.usage=$,q.dimension=ce,q.byteLength=ue),_.profile&&(q.stats.size=q.byteLength*gn[q.dtype]),pe}function de(j,$){d($+j.byteLength<=q.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+j.byteLength+" starting from offset "+$+" to a buffer of size "+q.byteLength),a.bufferSubData(q.type,$,j)}function Pe(j,$){var be=($||0)|0,ue;if(q.bind(),n(j)||j instanceof ArrayBuffer)de(j,be);else if(Array.isArray(j)){if(j.length>0)if(typeof j[0]=="number"){var J=ht.allocType(q.dtype,j.length);If(J,j),de(J,be),ht.freeType(J)}else if(Array.isArray(j[0])||n(j[0])){ue=Lf(j);var ce=Bo(j,ue,q.dtype);de(ce,be),ht.freeType(ce)}else d.raise("invalid buffer data")}else if(Zt(j)){ue=j.shape;var he=j.stride,Oe=0,De=0,me=0,ve=0;ue.length===1?(Oe=ue[0],De=1,me=he[0],ve=0):ue.length===2?(Oe=ue[0],De=ue[1],me=he[0],ve=he[1]):d.raise("invalid shape");var ze=Array.isArray(j.data)?q.dtype:Ai(j.data),Ne=ht.allocType(ze,Oe*De);Rf(Ne,j.data,Oe,De,me,ve,j.offset),de(Ne,be),ht.freeType(Ne)}else d.raise("invalid data for buffer subdata");return pe}return ee||pe(P),pe._reglType="buffer",pe._buffer=q,pe.subdata=Pe,_.profile&&(pe.stats=q.stats),pe.destroy=function(){fe(q)},pe}function te(){Nt(I).forEach(function(P){P.buffer=a.createBuffer(),a.bindBuffer(P.type,P.buffer),a.bufferData(P.type,P.persistentData||P.byteLength,P.usage)})}return _.profile&&(h.getTotalBufferSize=function(){var P=0;return Object.keys(I).forEach(function(O){P+=I[O].stats.size}),P}),{create:K,createStream:Y,destroyStream:ne,clear:function(){Nt(I).forEach(fe),Q.forEach(fe)},getBuffer:function(P){return P&&P._buffer instanceof G?P._buffer:null},restore:te,_initBuffer:re}}var Wv=0,Yv=0,Zv=1,Qv=1,Kv=4,Jv=4,yn={points:Wv,point:Yv,lines:Zv,line:Qv,triangles:Kv,triangle:Jv,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},eg=0,tg=1,Ar=4,ng=5120,Zn=5121,Df=5122,Qn=5123,Mf=5124,zn=5125,Uo=34963,rg=35040,ig=35044;function og(a,h,_,R){var U={},I=0,G={uint8:Zn,uint16:Qn};h.oes_element_index_uint&&(G.uint32=zn);function Q(te){this.id=I++,U[this.id]=this,this.buffer=te,this.primType=Ar,this.vertCount=0,this.type=0}Q.prototype.bind=function(){this.buffer.bind()};var Y=[];function ne(te){var P=Y.pop();return P||(P=new Q(_.create(null,Uo,!0,!1)._buffer)),re(P,te,rg,-1,-1,0,0),P}function ie(te){Y.push(te)}function re(te,P,O,ee,ge,q,pe){te.buffer.bind();var de;if(P){var Pe=pe;!pe&&(!n(P)||Zt(P)&&!n(P.data))&&(Pe=h.oes_element_index_uint?zn:Qn),_._initBuffer(te.buffer,P,O,Pe,3)}else a.bufferData(Uo,q,O),te.buffer.dtype=de||Zn,te.buffer.usage=O,te.buffer.dimension=3,te.buffer.byteLength=q;if(de=pe,!pe){switch(te.buffer.dtype){case Zn:case ng:de=Zn;break;case Qn:case Df:de=Qn;break;case zn:case Mf:de=zn;break;default:d.raise("unsupported type for element array")}te.buffer.dtype=de}te.type=de,d(de!==zn||!!h.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var j=ge;j<0&&(j=te.buffer.byteLength,de===Qn?j>>=1:de===zn&&(j>>=2)),te.vertCount=j;var $=ee;if(ee<0){$=Ar;var be=te.buffer.dimension;be===1&&($=eg),be===2&&($=tg),be===3&&($=Ar)}te.primType=$}function fe(te){R.elementsCount--,d(te.buffer!==null,"must not double destroy elements"),delete U[te.id],te.buffer.destroy(),te.buffer=null}function K(te,P){var O=_.create(null,Uo,!0),ee=new Q(O._buffer);R.elementsCount++;function ge(q){if(!q)O(),ee.primType=Ar,ee.vertCount=0,ee.type=Zn;else if(typeof q=="number")O(q),ee.primType=Ar,ee.vertCount=q|0,ee.type=Zn;else{var pe=null,de=ig,Pe=-1,j=-1,$=0,be=0;Array.isArray(q)||n(q)||Zt(q)?pe=q:(d.type(q,"object","invalid arguments for elements"),"data"in q&&(pe=q.data,d(Array.isArray(pe)||n(pe)||Zt(pe),"invalid data for element buffer")),"usage"in q&&(d.parameter(q.usage,Ti,"invalid element buffer usage"),de=Ti[q.usage]),"primitive"in q&&(d.parameter(q.primitive,yn,"invalid element buffer primitive"),Pe=yn[q.primitive]),"count"in q&&(d(typeof q.count=="number"&&q.count>=0,"invalid vertex count for elements"),j=q.count|0),"type"in q&&(d.parameter(q.type,G,"invalid buffer type"),be=G[q.type]),"length"in q?$=q.length|0:($=j,be===Qn||be===Df?$*=2:(be===zn||be===Mf)&&($*=4))),re(ee,pe,de,Pe,j,$,be)}return ge}return ge(te),ge._reglType="elements",ge._elements=ee,ge.subdata=function(q,pe){return O.subdata(q,pe),ge},ge.destroy=function(){fe(ee)},ge}return{create:K,createStream:ne,destroyStream:ie,getElements:function(te){return typeof te=="function"&&te._elements instanceof Q?te._elements:null},clear:function(){Nt(U).forEach(fe)}}}var Of=new Float32Array(1),ag=new Uint32Array(Of.buffer),sg=5123;function Nf(a){for(var h=ht.allocType(sg,a.length),_=0;_<a.length;++_)if(isNaN(a[_]))h[_]=65535;else if(a[_]===1/0)h[_]=31744;else if(a[_]===-1/0)h[_]=64512;else{Of[0]=a[_];var R=ag[0],U=R>>>31<<15,I=(R<<1>>>24)-127,G=R>>13&1023;if(I<-24)h[_]=U;else if(I<-14){var Q=-14-I;h[_]=U+(G+1024>>Q)}else I>15?h[_]=U+31744:h[_]=U+(I+15<<10)+G}return h}function at(a){return Array.isArray(a)||n(a)}var Gf=function(a){return!(a&a-1)&&!!a},fg=34467,tn=3553,jo=34067,Ei=34069,In=6408,Xo=6406,Ci=6407,Er=6409,Pi=6410,Bf=32854,Ho=32855,Vf=36194,ug=32819,cg=32820,lg=33635,hg=34042,qo=6402,ki=34041,Wo=35904,Yo=35906,Kn=36193,Zo=33776,Qo=33777,Ko=33778,Jo=33779,$f=35986,Uf=35987,jf=34798,Xf=35840,Hf=35841,qf=35842,Wf=35843,Yf=36196,Jn=5121,ea=5123,ta=5125,Cr=5126,dg=10242,mg=10243,pg=10497,na=33071,vg=33648,gg=10240,yg=10241,ra=9728,xg=9729,ia=9984,Zf=9985,Qf=9986,oa=9987,bg=33170,Fi=4352,_g=4353,Sg=4354,wg=34046,Tg=3317,Ag=37440,Eg=37441,Cg=37443,Kf=37444,Pr=33984,Pg=[ia,Qf,Zf,oa],Li=[0,Er,Pi,Ci,In],Vt={};Vt[Er]=Vt[Xo]=Vt[qo]=1,Vt[ki]=Vt[Pi]=2,Vt[Ci]=Vt[Wo]=3,Vt[In]=Vt[Yo]=4;function er(a){return"[object "+a+"]"}var Jf=er("HTMLCanvasElement"),eu=er("OffscreenCanvas"),tu=er("CanvasRenderingContext2D"),nu=er("ImageBitmap"),ru=er("HTMLImageElement"),iu=er("HTMLVideoElement"),kg=Object.keys(Go).concat([Jf,eu,tu,nu,ru,iu]),tr=[];tr[Jn]=1,tr[Cr]=4,tr[Kn]=2,tr[ea]=2,tr[ta]=4;var Tt=[];Tt[Bf]=2,Tt[Ho]=2,Tt[Vf]=2,Tt[ki]=4,Tt[Zo]=.5,Tt[Qo]=.5,Tt[Ko]=1,Tt[Jo]=1,Tt[$f]=.5,Tt[Uf]=1,Tt[jf]=1,Tt[Xf]=.5,Tt[Hf]=.25,Tt[qf]=.5,Tt[Wf]=.25,Tt[Yf]=.5;function ou(a){return Array.isArray(a)&&(a.length===0||typeof a[0]=="number")}function au(a){if(!Array.isArray(a))return!1;var h=a.length;return!(h===0||!at(a[0]))}function Rn(a){return Object.prototype.toString.call(a)}function su(a){return Rn(a)===Jf}function fu(a){return Rn(a)===eu}function Fg(a){return Rn(a)===tu}function Lg(a){return Rn(a)===nu}function zg(a){return Rn(a)===ru}function Ig(a){return Rn(a)===iu}function aa(a){if(!a)return!1;var h=Rn(a);return kg.indexOf(h)>=0?!0:ou(a)||au(a)||Zt(a)}function uu(a){return Go[Object.prototype.toString.call(a)]|0}function Rg(a,h){var _=h.length;switch(a.type){case Jn:case ea:case ta:case Cr:var R=ht.allocType(a.type,_);R.set(h),a.data=R;break;case Kn:a.data=Nf(h);break;default:d.raise("unsupported texture type, must specify a typed array")}}function cu(a,h){return ht.allocType(a.type===Kn?Cr:a.type,h)}function lu(a,h){a.type===Kn?(a.data=Nf(h),ht.freeType(h)):a.data=h}function Dg(a,h,_,R,U,I){for(var G=a.width,Q=a.height,Y=a.channels,ne=G*Q*Y,ie=cu(a,ne),re=0,fe=0;fe<Q;++fe)for(var K=0;K<G;++K)for(var te=0;te<Y;++te)ie[re++]=h[_*K+R*fe+U*te+I];lu(a,ie)}function zi(a,h,_,R,U,I){var G;if(typeof Tt[a]<"u"?G=Tt[a]:G=Vt[a]*tr[h],I&&(G*=6),U){for(var Q=0,Y=_;Y>=1;)Q+=G*Y*Y,Y/=2;return Q}else return G*_*R}function Mg(a,h,_,R,U,I,G){var Q={"don't care":Fi,"dont care":Fi,nice:Sg,fast:_g},Y={repeat:pg,clamp:na,mirror:vg},ne={nearest:ra,linear:xg},ie=r({mipmap:oa,"nearest mipmap nearest":ia,"linear mipmap nearest":Zf,"nearest mipmap linear":Qf,"linear mipmap linear":oa},ne),re={none:0,browser:Kf},fe={uint8:Jn,rgba4:ug,rgb565:lg,"rgb5 a1":cg},K={alpha:Xo,luminance:Er,"luminance alpha":Pi,rgb:Ci,rgba:In,rgba4:Bf,"rgb5 a1":Ho,rgb565:Vf},te={};h.ext_srgb&&(K.srgb=Wo,K.srgba=Yo),h.oes_texture_float&&(fe.float32=fe.float=Cr),h.oes_texture_half_float&&(fe.float16=fe["half float"]=Kn),h.webgl_depth_texture&&(r(K,{depth:qo,"depth stencil":ki}),r(fe,{uint16:ea,uint32:ta,"depth stencil":hg})),h.webgl_compressed_texture_s3tc&&r(te,{"rgb s3tc dxt1":Zo,"rgba s3tc dxt1":Qo,"rgba s3tc dxt3":Ko,"rgba s3tc dxt5":Jo}),h.webgl_compressed_texture_atc&&r(te,{"rgb atc":$f,"rgba atc explicit alpha":Uf,"rgba atc interpolated alpha":jf}),h.webgl_compressed_texture_pvrtc&&r(te,{"rgb pvrtc 4bppv1":Xf,"rgb pvrtc 2bppv1":Hf,"rgba pvrtc 4bppv1":qf,"rgba pvrtc 2bppv1":Wf}),h.webgl_compressed_texture_etc1&&(te["rgb etc1"]=Yf);var P=Array.prototype.slice.call(a.getParameter(fg));Object.keys(te).forEach(function(y){var M=te[y];P.indexOf(M)>=0&&(K[y]=M)});var O=Object.keys(K);_.textureFormats=O;var ee=[];Object.keys(K).forEach(function(y){var M=K[y];ee[M]=y});var ge=[];Object.keys(fe).forEach(function(y){var M=fe[y];ge[M]=y});var q=[];Object.keys(ne).forEach(function(y){var M=ne[y];q[M]=y});var pe=[];Object.keys(ie).forEach(function(y){var M=ie[y];pe[M]=y});var de=[];Object.keys(Y).forEach(function(y){var M=Y[y];de[M]=y});var Pe=O.reduce(function(y,M){var z=K[M];return z===Er||z===Xo||z===Er||z===Pi||z===qo||z===ki||h.ext_srgb&&(z===Wo||z===Yo)?y[z]=z:z===Ho||M.indexOf("rgba")>=0?y[z]=In:y[z]=Ci,y},{});function j(){this.internalformat=In,this.format=In,this.type=Jn,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=Kf,this.width=0,this.height=0,this.channels=0}function $(y,M){y.internalformat=M.internalformat,y.format=M.format,y.type=M.type,y.compressed=M.compressed,y.premultiplyAlpha=M.premultiplyAlpha,y.flipY=M.flipY,y.unpackAlignment=M.unpackAlignment,y.colorSpace=M.colorSpace,y.width=M.width,y.height=M.height,y.channels=M.channels}function be(y,M){if(!(typeof M!="object"||!M)){if("premultiplyAlpha"in M&&(d.type(M.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),y.premultiplyAlpha=M.premultiplyAlpha),"flipY"in M&&(d.type(M.flipY,"boolean","invalid texture flip"),y.flipY=M.flipY),"alignment"in M&&(d.oneOf(M.alignment,[1,2,4,8],"invalid texture unpack alignment"),y.unpackAlignment=M.alignment),"colorSpace"in M&&(d.parameter(M.colorSpace,re,"invalid colorSpace"),y.colorSpace=re[M.colorSpace]),"type"in M){var z=M.type;d(h.oes_texture_float||!(z==="float"||z==="float32"),"you must enable the OES_texture_float extension in order to use floating point textures."),d(h.oes_texture_half_float||!(z==="half float"||z==="float16"),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),d(h.webgl_depth_texture||!(z==="uint16"||z==="uint32"||z==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),d.parameter(z,fe,"invalid texture type"),y.type=fe[z]}var xe=y.width,He=y.height,m=y.channels,l=!1;"shape"in M?(d(Array.isArray(M.shape)&&M.shape.length>=2,"shape must be an array"),xe=M.shape[0],He=M.shape[1],M.shape.length===3&&(m=M.shape[2],d(m>0&&m<=4,"invalid number of channels"),l=!0),d(xe>=0&&xe<=_.maxTextureSize,"invalid width"),d(He>=0&&He<=_.maxTextureSize,"invalid height")):("radius"in M&&(xe=He=M.radius,d(xe>=0&&xe<=_.maxTextureSize,"invalid radius")),"width"in M&&(xe=M.width,d(xe>=0&&xe<=_.maxTextureSize,"invalid width")),"height"in M&&(He=M.height,d(He>=0&&He<=_.maxTextureSize,"invalid height")),"channels"in M&&(m=M.channels,d(m>0&&m<=4,"invalid number of channels"),l=!0)),y.width=xe|0,y.height=He|0,y.channels=m|0;var w=!1;if("format"in M){var C=M.format;d(h.webgl_depth_texture||!(C==="depth"||C==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),d.parameter(C,K,"invalid texture format");var k=y.internalformat=K[C];y.format=Pe[k],C in fe&&("type"in M||(y.type=fe[C])),C in te&&(y.compressed=!0),w=!0}!l&&w?y.channels=Vt[y.format]:l&&!w?y.channels!==Li[y.format]&&(y.format=y.internalformat=Li[y.channels]):w&&l&&d(y.channels===Vt[y.format],"number of channels inconsistent with specified format")}}function ue(y){a.pixelStorei(Ag,y.flipY),a.pixelStorei(Eg,y.premultiplyAlpha),a.pixelStorei(Cg,y.colorSpace),a.pixelStorei(Tg,y.unpackAlignment)}function J(){j.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function ce(y,M){var z=null;if(aa(M)?z=M:M&&(d.type(M,"object","invalid pixel data type"),be(y,M),"x"in M&&(y.xOffset=M.x|0),"y"in M&&(y.yOffset=M.y|0),aa(M.data)&&(z=M.data)),d(!y.compressed||z instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),M.copy){d(!z,"can not specify copy and data field for the same texture");var xe=U.viewportWidth,He=U.viewportHeight;y.width=y.width||xe-y.xOffset,y.height=y.height||He-y.yOffset,y.needsCopy=!0,d(y.xOffset>=0&&y.xOffset<xe&&y.yOffset>=0&&y.yOffset<He&&y.width>0&&y.width<=xe&&y.height>0&&y.height<=He,"copy texture read out of bounds")}else if(!z)y.width=y.width||1,y.height=y.height||1,y.channels=y.channels||4;else if(n(z))y.channels=y.channels||4,y.data=z,!("type"in M)&&y.type===Jn&&(y.type=uu(z));else if(ou(z))y.channels=y.channels||4,Rg(y,z),y.alignment=1,y.needsFree=!0;else if(Zt(z)){var m=z.data;!Array.isArray(m)&&y.type===Jn&&(y.type=uu(m));var l=z.shape,w=z.stride,C,k,A,T,E,p;l.length===3?(A=l[2],p=w[2]):(d(l.length===2,"invalid ndarray pixel data, must be 2 or 3D"),A=1,p=1),C=l[0],k=l[1],T=w[0],E=w[1],y.alignment=1,y.width=C,y.height=k,y.channels=A,y.format=y.internalformat=Li[A],y.needsFree=!0,Dg(y,m,T,E,p,z.offset)}else if(su(z)||fu(z)||Fg(z))su(z)||fu(z)?y.element=z:y.element=z.canvas,y.width=y.element.width,y.height=y.element.height,y.channels=4;else if(Lg(z))y.element=z,y.width=z.width,y.height=z.height,y.channels=4;else if(zg(z))y.element=z,y.width=z.naturalWidth,y.height=z.naturalHeight,y.channels=4;else if(Ig(z))y.element=z,y.width=z.videoWidth,y.height=z.videoHeight,y.channels=4;else if(au(z)){var x=y.width||z[0].length,g=y.height||z.length,L=y.channels;at(z[0][0])?L=L||z[0][0].length:L=L||1;for(var F=wi.shape(z),V=1,X=0;X<F.length;++X)V*=F[X];var se=cu(y,V);wi.flatten(z,F,"",se),lu(y,se),y.alignment=1,y.width=x,y.height=g,y.channels=L,y.format=y.internalformat=Li[L],y.needsFree=!0}y.type===Cr?d(_.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):y.type===Kn&&d(_.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function he(y,M,z){var xe=y.element,He=y.data,m=y.internalformat,l=y.format,w=y.type,C=y.width,k=y.height;ue(y),xe?a.texImage2D(M,z,l,l,w,xe):y.compressed?a.compressedTexImage2D(M,z,m,C,k,0,He):y.needsCopy?(R(),a.copyTexImage2D(M,z,l,y.xOffset,y.yOffset,C,k,0)):a.texImage2D(M,z,l,C,k,0,l,w,He||null)}function Oe(y,M,z,xe,He){var m=y.element,l=y.data,w=y.internalformat,C=y.format,k=y.type,A=y.width,T=y.height;ue(y),m?a.texSubImage2D(M,He,z,xe,C,k,m):y.compressed?a.compressedTexSubImage2D(M,He,z,xe,w,A,T,l):y.needsCopy?(R(),a.copyTexSubImage2D(M,He,z,xe,y.xOffset,y.yOffset,A,T)):a.texSubImage2D(M,He,z,xe,A,T,C,k,l)}var De=[];function me(){return De.pop()||new J}function ve(y){y.needsFree&&ht.freeType(y.data),J.call(y),De.push(y)}function ze(){j.call(this),this.genMipmaps=!1,this.mipmapHint=Fi,this.mipmask=0,this.images=Array(16)}function Ne(y,M,z){var xe=y.images[0]=me();y.mipmask=1,xe.width=y.width=M,xe.height=y.height=z,xe.channels=y.channels=4}function qe(y,M){var z=null;if(aa(M))z=y.images[0]=me(),$(z,y),ce(z,M),y.mipmask=1;else if(be(y,M),Array.isArray(M.mipmap))for(var xe=M.mipmap,He=0;He<xe.length;++He)z=y.images[He]=me(),$(z,y),z.width>>=He,z.height>>=He,ce(z,xe[He]),y.mipmask|=1<<He;else z=y.images[0]=me(),$(z,y),ce(z,M),y.mipmask=1;$(y,y.images[0]),y.compressed&&(y.internalformat===Zo||y.internalformat===Qo||y.internalformat===Ko||y.internalformat===Jo)&&d(y.width%4===0&&y.height%4===0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function st(y,M){for(var z=y.images,xe=0;xe<z.length;++xe){if(!z[xe])return;he(z[xe],M,xe)}}var ft=[];function Ze(){var y=ft.pop()||new ze;j.call(y),y.mipmask=0;for(var M=0;M<16;++M)y.images[M]=null;return y}function pt(y){for(var M=y.images,z=0;z<M.length;++z)M[z]&&ve(M[z]),M[z]=null;ft.push(y)}function ot(){this.minFilter=ra,this.magFilter=ra,this.wrapS=na,this.wrapT=na,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=Fi}function mt(y,M){if("min"in M){var z=M.min;d.parameter(z,ie),y.minFilter=ie[z],Pg.indexOf(y.minFilter)>=0&&!("faces"in M)&&(y.genMipmaps=!0)}if("mag"in M){var xe=M.mag;d.parameter(xe,ne),y.magFilter=ne[xe]}var He=y.wrapS,m=y.wrapT;if("wrap"in M){var l=M.wrap;typeof l=="string"?(d.parameter(l,Y),He=m=Y[l]):Array.isArray(l)&&(d.parameter(l[0],Y),d.parameter(l[1],Y),He=Y[l[0]],m=Y[l[1]])}else{if("wrapS"in M){var w=M.wrapS;d.parameter(w,Y),He=Y[w]}if("wrapT"in M){var C=M.wrapT;d.parameter(C,Y),m=Y[C]}}if(y.wrapS=He,y.wrapT=m,"anisotropic"in M){var k=M.anisotropic;d(typeof k=="number"&&k>=1&&k<=_.maxAnisotropic,"aniso samples must be between 1 and "),y.anisotropic=M.anisotropic}if("mipmap"in M){var A=!1;switch(typeof M.mipmap){case"string":d.parameter(M.mipmap,Q,"invalid mipmap hint"),y.mipmapHint=Q[M.mipmap],y.genMipmaps=!0,A=!0;break;case"boolean":A=y.genMipmaps=M.mipmap;break;case"object":d(Array.isArray(M.mipmap),"invalid mipmap type"),y.genMipmaps=!1,A=!0;break;default:d.raise("invalid mipmap type")}A&&!("min"in M)&&(y.minFilter=ia)}}function vt(y,M){a.texParameteri(M,yg,y.minFilter),a.texParameteri(M,gg,y.magFilter),a.texParameteri(M,dg,y.wrapS),a.texParameteri(M,mg,y.wrapT),h.ext_texture_filter_anisotropic&&a.texParameteri(M,wg,y.anisotropic),y.genMipmaps&&(a.hint(bg,y.mipmapHint),a.generateMipmap(M))}var gt=0,St={},At=_.maxTextureUnits,ct=Array(At).map(function(){return null});function $e(y){j.call(this),this.mipmask=0,this.internalformat=In,this.id=gt++,this.refCount=1,this.target=y,this.texture=a.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new ot,G.profile&&(this.stats={size:0})}function Et(y){a.activeTexture(Pr),a.bindTexture(y.target,y.texture)}function Ke(){var y=ct[0];y?a.bindTexture(y.target,y.texture):a.bindTexture(tn,null)}function Fe(y){var M=y.texture;d(M,"must not double destroy texture");var z=y.unit,xe=y.target;z>=0&&(a.activeTexture(Pr+z),a.bindTexture(xe,null),ct[z]=null),a.deleteTexture(M),y.texture=null,y.params=null,y.pixels=null,y.refCount=0,delete St[y.id],I.textureCount--}r($e.prototype,{bind:function(){var y=this;y.bindCount+=1;var M=y.unit;if(M<0){for(var z=0;z<At;++z){var xe=ct[z];if(xe){if(xe.bindCount>0)continue;xe.unit=-1}ct[z]=y,M=z;break}M>=At&&d.raise("insufficient number of texture units"),G.profile&&I.maxTextureUnits<M+1&&(I.maxTextureUnits=M+1),y.unit=M,a.activeTexture(Pr+M),a.bindTexture(y.target,y.texture)}return M},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&Fe(this)}});function We(y,M){var z=new $e(tn);St[z.id]=z,I.textureCount++;function xe(l,w){var C=z.texInfo;ot.call(C);var k=Ze();return typeof l=="number"?typeof w=="number"?Ne(k,l|0,w|0):Ne(k,l|0,l|0):l?(d.type(l,"object","invalid arguments to regl.texture"),mt(C,l),qe(k,l)):Ne(k,1,1),C.genMipmaps&&(k.mipmask=(k.width<<1)-1),z.mipmask=k.mipmask,$(z,k),d.texture2D(C,k,_),z.internalformat=k.internalformat,xe.width=k.width,xe.height=k.height,Et(z),st(k,tn),vt(C,tn),Ke(),pt(k),G.profile&&(z.stats.size=zi(z.internalformat,z.type,k.width,k.height,C.genMipmaps,!1)),xe.format=ee[z.internalformat],xe.type=ge[z.type],xe.mag=q[C.magFilter],xe.min=pe[C.minFilter],xe.wrapS=de[C.wrapS],xe.wrapT=de[C.wrapT],xe}function He(l,w,C,k){d(!!l,"must specify image data");var A=w|0,T=C|0,E=k|0,p=me();return $(p,z),p.width=0,p.height=0,ce(p,l),p.width=p.width||(z.width>>E)-A,p.height=p.height||(z.height>>E)-T,d(z.type===p.type&&z.format===p.format&&z.internalformat===p.internalformat,"incompatible format for texture.subimage"),d(A>=0&&T>=0&&A+p.width<=z.width&&T+p.height<=z.height,"texture.subimage write out of bounds"),d(z.mipmask&1<<E,"missing mipmap data"),d(p.data||p.element||p.needsCopy,"missing image data"),Et(z),Oe(p,tn,A,T,E),Ke(),ve(p),xe}function m(l,w){var C=l|0,k=w|0||C;if(C===z.width&&k===z.height)return xe;xe.width=z.width=C,xe.height=z.height=k,Et(z);for(var A=0;z.mipmask>>A;++A){var T=C>>A,E=k>>A;if(!T||!E)break;a.texImage2D(tn,A,z.format,T,E,0,z.format,z.type,null)}return Ke(),G.profile&&(z.stats.size=zi(z.internalformat,z.type,C,k,!1,!1)),xe}return xe(y,M),xe.subimage=He,xe.resize=m,xe._reglType="texture2d",xe._texture=z,G.profile&&(xe.stats=z.stats),xe.destroy=function(){z.decRef()},xe}function Qe(y,M,z,xe,He,m){var l=new $e(jo);St[l.id]=l,I.cubeCount++;var w=new Array(6);function C(T,E,p,x,g,L){var F,V=l.texInfo;for(ot.call(V),F=0;F<6;++F)w[F]=Ze();if(typeof T=="number"||!T){var X=T|0||1;for(F=0;F<6;++F)Ne(w[F],X,X)}else if(typeof T=="object")if(E)qe(w[0],T),qe(w[1],E),qe(w[2],p),qe(w[3],x),qe(w[4],g),qe(w[5],L);else if(mt(V,T),be(l,T),"faces"in T){var se=T.faces;for(d(Array.isArray(se)&&se.length===6,"cube faces must be a length 6 array"),F=0;F<6;++F)d(typeof se[F]=="object"&&!!se[F],"invalid input for cube map face"),$(w[F],l),qe(w[F],se[F])}else for(F=0;F<6;++F)qe(w[F],T);else d.raise("invalid arguments to cube map");for($(l,w[0]),d.optional(function(){_.npotTextureCube||d(Gf(l.width)&&Gf(l.height),"your browser does not support non power or two texture dimensions")}),V.genMipmaps?l.mipmask=(w[0].width<<1)-1:l.mipmask=w[0].mipmask,d.textureCube(l,V,w,_),l.internalformat=w[0].internalformat,C.width=w[0].width,C.height=w[0].height,Et(l),F=0;F<6;++F)st(w[F],Ei+F);for(vt(V,jo),Ke(),G.profile&&(l.stats.size=zi(l.internalformat,l.type,C.width,C.height,V.genMipmaps,!0)),C.format=ee[l.internalformat],C.type=ge[l.type],C.mag=q[V.magFilter],C.min=pe[V.minFilter],C.wrapS=de[V.wrapS],C.wrapT=de[V.wrapT],F=0;F<6;++F)pt(w[F]);return C}function k(T,E,p,x,g){d(!!E,"must specify image data"),d(typeof T=="number"&&T===(T|0)&&T>=0&&T<6,"invalid face");var L=p|0,F=x|0,V=g|0,X=me();return $(X,l),X.width=0,X.height=0,ce(X,E),X.width=X.width||(l.width>>V)-L,X.height=X.height||(l.height>>V)-F,d(l.type===X.type&&l.format===X.format&&l.internalformat===X.internalformat,"incompatible format for texture.subimage"),d(L>=0&&F>=0&&L+X.width<=l.width&&F+X.height<=l.height,"texture.subimage write out of bounds"),d(l.mipmask&1<<V,"missing mipmap data"),d(X.data||X.element||X.needsCopy,"missing image data"),Et(l),Oe(X,Ei+T,L,F,V),Ke(),ve(X),C}function A(T){var E=T|0;if(E!==l.width){C.width=l.width=E,C.height=l.height=E,Et(l);for(var p=0;p<6;++p)for(var x=0;l.mipmask>>x;++x)a.texImage2D(Ei+p,x,l.format,E>>x,E>>x,0,l.format,l.type,null);return Ke(),G.profile&&(l.stats.size=zi(l.internalformat,l.type,C.width,C.height,!1,!0)),C}}return C(y,M,z,xe,He,m),C.subimage=k,C.resize=A,C._reglType="textureCube",C._texture=l,G.profile&&(C.stats=l.stats),C.destroy=function(){l.decRef()},C}function lt(){for(var y=0;y<At;++y)a.activeTexture(Pr+y),a.bindTexture(tn,null),ct[y]=null;Nt(St).forEach(Fe),I.cubeCount=0,I.textureCount=0}G.profile&&(I.getTotalTextureSize=function(){var y=0;return Object.keys(St).forEach(function(M){y+=St[M].stats.size}),y});function rn(){for(var y=0;y<At;++y){var M=ct[y];M&&(M.bindCount=0,M.unit=-1,ct[y]=null)}Nt(St).forEach(function(z){z.texture=a.createTexture(),a.bindTexture(z.target,z.texture);for(var xe=0;xe<32;++xe)if((z.mipmask&1<<xe)!==0)if(z.target===tn)a.texImage2D(tn,xe,z.internalformat,z.width>>xe,z.height>>xe,0,z.internalformat,z.type,null);else for(var He=0;He<6;++He)a.texImage2D(Ei+He,xe,z.internalformat,z.width>>xe,z.height>>xe,0,z.internalformat,z.type,null);vt(z.texInfo,z.target)})}function Vn(){for(var y=0;y<At;++y){var M=ct[y];M&&(M.bindCount=0,M.unit=-1,ct[y]=null),a.activeTexture(Pr+y),a.bindTexture(tn,null),a.bindTexture(jo,null)}}return{create2D:We,createCube:Qe,clear:lt,getTexture:function(y){return null},restore:rn,refresh:Vn}}var xn=36161,Ii=32854,hu=32855,du=36194,mu=33189,pu=36168,vu=34041,gu=35907,yu=34836,xu=34842,bu=34843,Qt=[];Qt[Ii]=2,Qt[hu]=2,Qt[du]=2,Qt[mu]=2,Qt[pu]=1,Qt[vu]=4,Qt[gu]=4,Qt[yu]=16,Qt[xu]=8,Qt[bu]=6;function _u(a,h,_){return Qt[a]*h*_}var Og=function(a,h,_,R,U){var I={rgba4:Ii,rgb565:du,"rgb5 a1":hu,depth:mu,stencil:pu,"depth stencil":vu};h.ext_srgb&&(I.srgba=gu),h.ext_color_buffer_half_float&&(I.rgba16f=xu,I.rgb16f=bu),h.webgl_color_buffer_float&&(I.rgba32f=yu);var G=[];Object.keys(I).forEach(function(K){var te=I[K];G[te]=K});var Q=0,Y={};function ne(K){this.id=Q++,this.refCount=1,this.renderbuffer=K,this.format=Ii,this.width=0,this.height=0,U.profile&&(this.stats={size:0})}ne.prototype.decRef=function(){--this.refCount<=0&&ie(this)};function ie(K){var te=K.renderbuffer;d(te,"must not double destroy renderbuffer"),a.bindRenderbuffer(xn,null),a.deleteRenderbuffer(te),K.renderbuffer=null,K.refCount=0,delete Y[K.id],R.renderbufferCount--}function re(K,te){var P=new ne(a.createRenderbuffer());Y[P.id]=P,R.renderbufferCount++;function O(ge,q){var pe=0,de=0,Pe=Ii;if(typeof ge=="object"&&ge){var j=ge;if("shape"in j){var $=j.shape;d(Array.isArray($)&&$.length>=2,"invalid renderbuffer shape"),pe=$[0]|0,de=$[1]|0}else"radius"in j&&(pe=de=j.radius|0),"width"in j&&(pe=j.width|0),"height"in j&&(de=j.height|0);"format"in j&&(d.parameter(j.format,I,"invalid renderbuffer format"),Pe=I[j.format])}else typeof ge=="number"?(pe=ge|0,typeof q=="number"?de=q|0:de=pe):ge?d.raise("invalid arguments to renderbuffer constructor"):pe=de=1;if(d(pe>0&&de>0&&pe<=_.maxRenderbufferSize&&de<=_.maxRenderbufferSize,"invalid renderbuffer size"),!(pe===P.width&&de===P.height&&Pe===P.format))return O.width=P.width=pe,O.height=P.height=de,P.format=Pe,a.bindRenderbuffer(xn,P.renderbuffer),a.renderbufferStorage(xn,Pe,pe,de),d(a.getError()===0,"invalid render buffer format"),U.profile&&(P.stats.size=_u(P.format,P.width,P.height)),O.format=G[P.format],O}function ee(ge,q){var pe=ge|0,de=q|0||pe;return pe===P.width&&de===P.height||(d(pe>0&&de>0&&pe<=_.maxRenderbufferSize&&de<=_.maxRenderbufferSize,"invalid renderbuffer size"),O.width=P.width=pe,O.height=P.height=de,a.bindRenderbuffer(xn,P.renderbuffer),a.renderbufferStorage(xn,P.format,pe,de),d(a.getError()===0,"invalid render buffer format"),U.profile&&(P.stats.size=_u(P.format,P.width,P.height))),O}return O(K,te),O.resize=ee,O._reglType="renderbuffer",O._renderbuffer=P,U.profile&&(O.stats=P.stats),O.destroy=function(){P.decRef()},O}U.profile&&(R.getTotalRenderbufferSize=function(){var K=0;return Object.keys(Y).forEach(function(te){K+=Y[te].stats.size}),K});function fe(){Nt(Y).forEach(function(K){K.renderbuffer=a.createRenderbuffer(),a.bindRenderbuffer(xn,K.renderbuffer),a.renderbufferStorage(xn,K.format,K.width,K.height)}),a.bindRenderbuffer(xn,null)}return{create:re,clear:function(){Nt(Y).forEach(ie)},restore:fe}},hn=36160,sa=36161,Dn=3553,Ri=34069,Su=36064,wu=36096,Tu=36128,Au=33306,Eu=36053,Ng=36054,Gg=36055,Bg=36057,Vg=36061,$g=36193,Ug=5121,jg=5126,Cu=6407,Pu=6408,Xg=6402,Hg=[Cu,Pu],fa=[];fa[Pu]=4,fa[Cu]=3;var Di=[];Di[Ug]=1,Di[jg]=4,Di[$g]=2;var qg=32854,Wg=32855,Yg=36194,Zg=33189,Qg=36168,ku=34041,Kg=35907,Jg=34836,ey=34842,ty=34843,ny=[qg,Wg,Yg,Kg,ey,ty,Jg],nr={};nr[Eu]="complete",nr[Ng]="incomplete attachment",nr[Bg]="incomplete dimensions",nr[Gg]="incomplete, missing attachment",nr[Vg]="unsupported";function ry(a,h,_,R,U,I){var G={cur:null,next:null,dirty:!1,setFBO:null},Q=["rgba"],Y=["rgba4","rgb565","rgb5 a1"];h.ext_srgb&&Y.push("srgba"),h.ext_color_buffer_half_float&&Y.push("rgba16f","rgb16f"),h.webgl_color_buffer_float&&Y.push("rgba32f");var ne=["uint8"];h.oes_texture_half_float&&ne.push("half float","float16"),h.oes_texture_float&&ne.push("float","float32");function ie(J,ce,he){this.target=J,this.texture=ce,this.renderbuffer=he;var Oe=0,De=0;ce?(Oe=ce.width,De=ce.height):he&&(Oe=he.width,De=he.height),this.width=Oe,this.height=De}function re(J){J&&(J.texture&&J.texture._texture.decRef(),J.renderbuffer&&J.renderbuffer._renderbuffer.decRef())}function fe(J,ce,he){if(J)if(J.texture){var Oe=J.texture._texture,De=Math.max(1,Oe.width),me=Math.max(1,Oe.height);d(De===ce&&me===he,"inconsistent width/height for supplied texture"),Oe.refCount+=1}else{var ve=J.renderbuffer._renderbuffer;d(ve.width===ce&&ve.height===he,"inconsistent width/height for renderbuffer"),ve.refCount+=1}}function K(J,ce){ce&&(ce.texture?a.framebufferTexture2D(hn,J,ce.target,ce.texture._texture.texture,0):a.framebufferRenderbuffer(hn,J,sa,ce.renderbuffer._renderbuffer.renderbuffer))}function te(J){var ce=Dn,he=null,Oe=null,De=J;typeof J=="object"&&(De=J.data,"target"in J&&(ce=J.target|0)),d.type(De,"function","invalid attachment data");var me=De._reglType;return me==="texture2d"?(he=De,d(ce===Dn)):me==="textureCube"?(he=De,d(ce>=Ri&&ce<Ri+6,"invalid cube map target")):me==="renderbuffer"?(Oe=De,ce=sa):d.raise("invalid regl object for attachment"),new ie(ce,he,Oe)}function P(J,ce,he,Oe,De){if(he){var me=R.create2D({width:J,height:ce,format:Oe,type:De});return me._texture.refCount=0,new ie(Dn,me,null)}else{var ve=U.create({width:J,height:ce,format:Oe});return ve._renderbuffer.refCount=0,new ie(sa,null,ve)}}function O(J){return J&&(J.texture||J.renderbuffer)}function ee(J,ce,he){J&&(J.texture?J.texture.resize(ce,he):J.renderbuffer&&J.renderbuffer.resize(ce,he),J.width=ce,J.height=he)}var ge=0,q={};function pe(){this.id=ge++,q[this.id]=this,this.framebuffer=a.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function de(J){J.colorAttachments.forEach(re),re(J.depthAttachment),re(J.stencilAttachment),re(J.depthStencilAttachment)}function Pe(J){var ce=J.framebuffer;d(ce,"must not double destroy framebuffer"),a.deleteFramebuffer(ce),J.framebuffer=null,I.framebufferCount--,delete q[J.id]}function j(J){var ce;a.bindFramebuffer(hn,J.framebuffer);var he=J.colorAttachments;for(ce=0;ce<he.length;++ce)K(Su+ce,he[ce]);for(ce=he.length;ce<_.maxColorAttachments;++ce)a.framebufferTexture2D(hn,Su+ce,Dn,null,0);a.framebufferTexture2D(hn,Au,Dn,null,0),a.framebufferTexture2D(hn,wu,Dn,null,0),a.framebufferTexture2D(hn,Tu,Dn,null,0),K(wu,J.depthAttachment),K(Tu,J.stencilAttachment),K(Au,J.depthStencilAttachment);var Oe=a.checkFramebufferStatus(hn);!a.isContextLost()&&Oe!==Eu&&d.raise("framebuffer configuration not supported, status = "+nr[Oe]),a.bindFramebuffer(hn,G.next?G.next.framebuffer:null),G.cur=G.next,a.getError()}function $(J,ce){var he=new pe;I.framebufferCount++;function Oe(me,ve){var ze;d(G.next!==he,"can not update framebuffer which is currently in use");var Ne=0,qe=0,st=!0,ft=!0,Ze=null,pt=!0,ot="rgba",mt="uint8",vt=1,gt=null,St=null,At=null,ct=!1;if(typeof me=="number")Ne=me|0,qe=ve|0||Ne;else if(!me)Ne=qe=1;else{d.type(me,"object","invalid arguments for framebuffer");var $e=me;if("shape"in $e){var Et=$e.shape;d(Array.isArray(Et)&&Et.length>=2,"invalid shape for framebuffer"),Ne=Et[0],qe=Et[1]}else"radius"in $e&&(Ne=qe=$e.radius),"width"in $e&&(Ne=$e.width),"height"in $e&&(qe=$e.height);("color"in $e||"colors"in $e)&&(Ze=$e.color||$e.colors,Array.isArray(Ze)&&d(Ze.length===1||h.webgl_draw_buffers,"multiple render targets not supported")),Ze||("colorCount"in $e&&(vt=$e.colorCount|0,d(vt>0,"invalid color buffer count")),"colorTexture"in $e&&(pt=!!$e.colorTexture,ot="rgba4"),"colorType"in $e&&(mt=$e.colorType,pt?(d(h.oes_texture_float||!(mt==="float"||mt==="float32"),"you must enable OES_texture_float in order to use floating point framebuffer objects"),d(h.oes_texture_half_float||!(mt==="half float"||mt==="float16"),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):mt==="half float"||mt==="float16"?(d(h.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),ot="rgba16f"):(mt==="float"||mt==="float32")&&(d(h.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),ot="rgba32f"),d.oneOf(mt,ne,"invalid color type")),"colorFormat"in $e&&(ot=$e.colorFormat,Q.indexOf(ot)>=0?pt=!0:Y.indexOf(ot)>=0?pt=!1:d.optional(function(){pt?d.oneOf($e.colorFormat,Q,"invalid color format for texture"):d.oneOf($e.colorFormat,Y,"invalid color format for renderbuffer")}))),("depthTexture"in $e||"depthStencilTexture"in $e)&&(ct=!!($e.depthTexture||$e.depthStencilTexture),d(!ct||h.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in $e&&(typeof $e.depth=="boolean"?st=$e.depth:(gt=$e.depth,ft=!1)),"stencil"in $e&&(typeof $e.stencil=="boolean"?ft=$e.stencil:(St=$e.stencil,st=!1)),"depthStencil"in $e&&(typeof $e.depthStencil=="boolean"?st=ft=$e.depthStencil:(At=$e.depthStencil,st=!1,ft=!1))}var Ke=null,Fe=null,We=null,Qe=null;if(Array.isArray(Ze))Ke=Ze.map(te);else if(Ze)Ke=[te(Ze)];else for(Ke=new Array(vt),ze=0;ze<vt;++ze)Ke[ze]=P(Ne,qe,pt,ot,mt);d(h.webgl_draw_buffers||Ke.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),d(Ke.length<=_.maxColorAttachments,"too many color attachments, not supported"),Ne=Ne||Ke[0].width,qe=qe||Ke[0].height,gt?Fe=te(gt):st&&!ft&&(Fe=P(Ne,qe,ct,"depth","uint32")),St?We=te(St):ft&&!st&&(We=P(Ne,qe,!1,"stencil","uint8")),At?Qe=te(At):!gt&&!St&&ft&&st&&(Qe=P(Ne,qe,ct,"depth stencil","depth stencil")),d(!!gt+!!St+!!At<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var lt=null;for(ze=0;ze<Ke.length;++ze)if(fe(Ke[ze],Ne,qe),d(!Ke[ze]||Ke[ze].texture&&Hg.indexOf(Ke[ze].texture._texture.format)>=0||Ke[ze].renderbuffer&&ny.indexOf(Ke[ze].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+ze+" is invalid"),Ke[ze]&&Ke[ze].texture){var rn=fa[Ke[ze].texture._texture.format]*Di[Ke[ze].texture._texture.type];lt===null?lt=rn:d(lt===rn,"all color attachments much have the same number of bits per pixel.")}return fe(Fe,Ne,qe),d(!Fe||Fe.texture&&Fe.texture._texture.format===Xg||Fe.renderbuffer&&Fe.renderbuffer._renderbuffer.format===Zg,"invalid depth attachment for framebuffer object"),fe(We,Ne,qe),d(!We||We.renderbuffer&&We.renderbuffer._renderbuffer.format===Qg,"invalid stencil attachment for framebuffer object"),fe(Qe,Ne,qe),d(!Qe||Qe.texture&&Qe.texture._texture.format===ku||Qe.renderbuffer&&Qe.renderbuffer._renderbuffer.format===ku,"invalid depth-stencil attachment for framebuffer object"),de(he),he.width=Ne,he.height=qe,he.colorAttachments=Ke,he.depthAttachment=Fe,he.stencilAttachment=We,he.depthStencilAttachment=Qe,Oe.color=Ke.map(O),Oe.depth=O(Fe),Oe.stencil=O(We),Oe.depthStencil=O(Qe),Oe.width=he.width,Oe.height=he.height,j(he),Oe}function De(me,ve){d(G.next!==he,"can not resize a framebuffer which is currently in use");var ze=Math.max(me|0,1),Ne=Math.max(ve|0||ze,1);if(ze===he.width&&Ne===he.height)return Oe;for(var qe=he.colorAttachments,st=0;st<qe.length;++st)ee(qe[st],ze,Ne);return ee(he.depthAttachment,ze,Ne),ee(he.stencilAttachment,ze,Ne),ee(he.depthStencilAttachment,ze,Ne),he.width=Oe.width=ze,he.height=Oe.height=Ne,j(he),Oe}return Oe(J,ce),r(Oe,{resize:De,_reglType:"framebuffer",_framebuffer:he,destroy:function(){Pe(he),de(he)},use:function(me){G.setFBO({framebuffer:Oe},me)}})}function be(J){var ce=Array(6);function he(De){var me;d(ce.indexOf(G.next)<0,"can not update framebuffer which is currently in use");var ve={color:null},ze=0,Ne=null,qe="rgba",st="uint8",ft=1;if(typeof De=="number")ze=De|0;else if(!De)ze=1;else{d.type(De,"object","invalid arguments for framebuffer");var Ze=De;if("shape"in Ze){var pt=Ze.shape;d(Array.isArray(pt)&&pt.length>=2,"invalid shape for framebuffer"),d(pt[0]===pt[1],"cube framebuffer must be square"),ze=pt[0]}else"radius"in Ze&&(ze=Ze.radius|0),"width"in Ze?(ze=Ze.width|0,"height"in Ze&&d(Ze.height===ze,"must be square")):"height"in Ze&&(ze=Ze.height|0);("color"in Ze||"colors"in Ze)&&(Ne=Ze.color||Ze.colors,Array.isArray(Ne)&&d(Ne.length===1||h.webgl_draw_buffers,"multiple render targets not supported")),Ne||("colorCount"in Ze&&(ft=Ze.colorCount|0,d(ft>0,"invalid color buffer count")),"colorType"in Ze&&(d.oneOf(Ze.colorType,ne,"invalid color type"),st=Ze.colorType),"colorFormat"in Ze&&(qe=Ze.colorFormat,d.oneOf(Ze.colorFormat,Q,"invalid color format for texture"))),"depth"in Ze&&(ve.depth=Ze.depth),"stencil"in Ze&&(ve.stencil=Ze.stencil),"depthStencil"in Ze&&(ve.depthStencil=Ze.depthStencil)}var ot;if(Ne)if(Array.isArray(Ne))for(ot=[],me=0;me<Ne.length;++me)ot[me]=Ne[me];else ot=[Ne];else{ot=Array(ft);var mt={radius:ze,format:qe,type:st};for(me=0;me<ft;++me)ot[me]=R.createCube(mt)}for(ve.color=Array(ot.length),me=0;me<ot.length;++me){var vt=ot[me];d(typeof vt=="function"&&vt._reglType==="textureCube","invalid cube map"),ze=ze||vt.width,d(vt.width===ze&&vt.height===ze,"invalid cube map shape"),ve.color[me]={target:Ri,data:ot[me]}}for(me=0;me<6;++me){for(var gt=0;gt<ot.length;++gt)ve.color[gt].target=Ri+me;me>0&&(ve.depth=ce[0].depth,ve.stencil=ce[0].stencil,ve.depthStencil=ce[0].depthStencil),ce[me]?ce[me](ve):ce[me]=$(ve)}return r(he,{width:ze,height:ze,color:ot})}function Oe(De){var me,ve=De|0;if(d(ve>0&&ve<=_.maxCubeMapSize,"invalid radius for cube fbo"),ve===he.width)return he;var ze=he.color;for(me=0;me<ze.length;++me)ze[me].resize(ve);for(me=0;me<6;++me)ce[me].resize(ve);return he.width=he.height=ve,he}return he(J),r(he,{faces:ce,resize:Oe,_reglType:"framebufferCube",destroy:function(){ce.forEach(function(De){De.destroy()})}})}function ue(){G.cur=null,G.next=null,G.dirty=!0,Nt(q).forEach(function(J){J.framebuffer=a.createFramebuffer(),j(J)})}return r(G,{getFramebuffer:function(J){if(typeof J=="function"&&J._reglType==="framebuffer"){var ce=J._framebuffer;if(ce instanceof pe)return ce}return null},create:$,createCube:be,clear:function(){Nt(q).forEach(Pe)},restore:ue})}var iy=5126,Fu=34962,Mi=34963,Lu=["attributes","elements","offset","count","primitive","instances"];function ua(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=iy,this.offset=0,this.stride=0,this.divisor=0}function oy(a,h,_,R,U,I,G){for(var Q=_.maxAttributes,Y=new Array(Q),ne=0;ne<Q;++ne)Y[ne]=new ua;var ie=0,re={},fe={Record:ua,scope:{},state:Y,currentVAO:null,targetVAO:null,restore:te()?de:function(){},createVAO:Pe,getVAO:O,destroyBuffer:K,setVAO:te()?ee:ge,clear:te()?q:function(){}};function K(j){for(var $=0;$<Y.length;++$){var be=Y[$];be.buffer===j&&(a.disableVertexAttribArray($),be.buffer=null)}}function te(){return h.oes_vertex_array_object}function P(){return h.angle_instanced_arrays}function O(j){return typeof j=="function"&&j._vao?j._vao:null}function ee(j){if(j!==fe.currentVAO){var $=te();j?$.bindVertexArrayOES(j.vao):$.bindVertexArrayOES(null),fe.currentVAO=j}}function ge(j){if(j!==fe.currentVAO){if(j)j.bindAttrs();else{for(var $=P(),be=0;be<Y.length;++be){var ue=Y[be];ue.buffer?(a.enableVertexAttribArray(be),ue.buffer.bind(),a.vertexAttribPointer(be,ue.size,ue.type,ue.normalized,ue.stride,ue.offfset),$&&ue.divisor&&$.vertexAttribDivisorANGLE(be,ue.divisor)):(a.disableVertexAttribArray(be),a.vertexAttrib4f(be,ue.x,ue.y,ue.z,ue.w))}G.elements?a.bindBuffer(Mi,G.elements.buffer.buffer):a.bindBuffer(Mi,null)}fe.currentVAO=j}}function q(){Nt(re).forEach(function(j){j.destroy()})}function pe(){this.id=++ie,this.attributes=[],this.elements=null,this.ownsElements=!1,this.count=0,this.offset=0,this.instances=-1,this.primitive=4;var j=te();j?this.vao=j.createVertexArrayOES():this.vao=null,re[this.id]=this,this.buffers=[]}pe.prototype.bindAttrs=function(){for(var j=P(),$=this.attributes,be=0;be<$.length;++be){var ue=$[be];ue.buffer?(a.enableVertexAttribArray(be),a.bindBuffer(Fu,ue.buffer.buffer),a.vertexAttribPointer(be,ue.size,ue.type,ue.normalized,ue.stride,ue.offset),j&&ue.divisor&&j.vertexAttribDivisorANGLE(be,ue.divisor)):(a.disableVertexAttribArray(be),a.vertexAttrib4f(be,ue.x,ue.y,ue.z,ue.w))}for(var J=$.length;J<Q;++J)a.disableVertexAttribArray(J);var ce=I.getElements(this.elements);ce?a.bindBuffer(Mi,ce.buffer.buffer):a.bindBuffer(Mi,null)},pe.prototype.refresh=function(){var j=te();j&&(j.bindVertexArrayOES(this.vao),this.bindAttrs(),fe.currentVAO=null,j.bindVertexArrayOES(null))},pe.prototype.destroy=function(){if(this.vao){var j=te();this===fe.currentVAO&&(fe.currentVAO=null,j.bindVertexArrayOES(null)),j.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),re[this.id]&&(delete re[this.id],R.vaoCount-=1)};function de(){var j=te();j&&Nt(re).forEach(function($){$.refresh()})}function Pe(j){var $=new pe;R.vaoCount+=1;function be(ue){var J;if(Array.isArray(ue))J=ue,$.elements&&$.ownsElements&&$.elements.destroy(),$.elements=null,$.ownsElements=!1,$.offset=0,$.count=0,$.instances=-1,$.primitive=4;else{if(d(typeof ue=="object","invalid arguments for create vao"),d("attributes"in ue,"must specify attributes for vao"),ue.elements){var ce=ue.elements;$.ownsElements?typeof ce=="function"&&ce._reglType==="elements"?($.elements.destroy(),$.ownsElements=!1):($.elements(ce),$.ownsElements=!1):I.getElements(ue.elements)?($.elements=ue.elements,$.ownsElements=!1):($.elements=I.create(ue.elements),$.ownsElements=!0)}else $.elements=null,$.ownsElements=!1;J=ue.attributes,$.offset=0,$.count=-1,$.instances=-1,$.primitive=4,$.elements&&($.count=$.elements._elements.vertCount,$.primitive=$.elements._elements.primType),"offset"in ue&&($.offset=ue.offset|0),"count"in ue&&($.count=ue.count|0),"instances"in ue&&($.instances=ue.instances|0),"primitive"in ue&&(d(ue.primitive in yn,"bad primitive type: "+ue.primitive),$.primitive=yn[ue.primitive]),d.optional(()=>{for(var st=Object.keys(ue),ft=0;ft<st.length;++ft)d(Lu.indexOf(st[ft])>=0,'invalid option for vao: "'+st[ft]+'" valid options are '+Lu)}),d(Array.isArray(J),"attributes must be an array")}d(J.length<Q,"too many attributes"),d(J.length>0,"must specify at least one attribute");var he={},Oe=$.attributes;Oe.length=J.length;for(var De=0;De<J.length;++De){var me=J[De],ve=Oe[De]=new ua,ze=me.data||me;if(Array.isArray(ze)||n(ze)||Zt(ze)){var Ne;$.buffers[De]&&(Ne=$.buffers[De],n(ze)&&Ne._buffer.byteLength>=ze.byteLength?Ne.subdata(ze):(Ne.destroy(),$.buffers[De]=null)),$.buffers[De]||(Ne=$.buffers[De]=U.create(me,Fu,!1,!0)),ve.buffer=U.getBuffer(Ne),ve.size=ve.buffer.dimension|0,ve.normalized=!1,ve.type=ve.buffer.dtype,ve.offset=0,ve.stride=0,ve.divisor=0,ve.state=1,he[De]=1}else U.getBuffer(me)?(ve.buffer=U.getBuffer(me),ve.size=ve.buffer.dimension|0,ve.normalized=!1,ve.type=ve.buffer.dtype,ve.offset=0,ve.stride=0,ve.divisor=0,ve.state=1):U.getBuffer(me.buffer)?(ve.buffer=U.getBuffer(me.buffer),ve.size=(+me.size||ve.buffer.dimension)|0,ve.normalized=!!me.normalized||!1,"type"in me?(d.parameter(me.type,Ln,"invalid buffer type"),ve.type=Ln[me.type]):ve.type=ve.buffer.dtype,ve.offset=(me.offset||0)|0,ve.stride=(me.stride||0)|0,ve.divisor=(me.divisor||0)|0,ve.state=1,d(ve.size>=1&&ve.size<=4,"size must be between 1 and 4"),d(ve.offset>=0,"invalid offset"),d(ve.stride>=0&&ve.stride<=255,"stride must be between 0 and 255"),d(ve.divisor>=0,"divisor must be positive"),d(!ve.divisor||!!h.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in me?(d(De>0,"first attribute must not be a constant"),ve.x=+me.x||0,ve.y=+me.y||0,ve.z=+me.z||0,ve.w=+me.w||0,ve.state=2):d(!1,"invalid attribute spec for location "+De)}for(var qe=0;qe<$.buffers.length;++qe)!he[qe]&&$.buffers[qe]&&($.buffers[qe].destroy(),$.buffers[qe]=null);return $.refresh(),be}return be.destroy=function(){for(var ue=0;ue<$.buffers.length;++ue)$.buffers[ue]&&$.buffers[ue].destroy();$.buffers.length=0,$.ownsElements&&($.elements.destroy(),$.elements=null,$.ownsElements=!1),$.destroy()},be._vao=$,be._reglType="vao",be(j)}return fe}var zu=35632,ay=35633,sy=35718,fy=35721;function uy(a,h,_,R){var U={},I={};function G(P,O,ee,ge){this.name=P,this.id=O,this.location=ee,this.info=ge}function Q(P,O){for(var ee=0;ee<P.length;++ee)if(P[ee].id===O.id){P[ee].location=O.location;return}P.push(O)}function Y(P,O,ee){var ge=P===zu?U:I,q=ge[O];if(!q){var pe=h.str(O);q=a.createShader(P),a.shaderSource(q,pe),a.compileShader(q),d.shaderError(a,q,pe,P,ee),ge[O]=q}return q}var ne={},ie=[],re=0;function fe(P,O){this.id=re++,this.fragId=P,this.vertId=O,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,R.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function K(P,O,ee){var ge,q,pe=Y(zu,P.fragId),de=Y(ay,P.vertId),Pe=P.program=a.createProgram();if(a.attachShader(Pe,pe),a.attachShader(Pe,de),ee)for(ge=0;ge<ee.length;++ge){var j=ee[ge];a.bindAttribLocation(Pe,j[0],j[1])}a.linkProgram(Pe),d.linkError(a,Pe,h.str(P.fragId),h.str(P.vertId),O);var $=a.getProgramParameter(Pe,sy);R.profile&&(P.stats.uniformsCount=$);var be=P.uniforms;for(ge=0;ge<$;++ge)if(q=a.getActiveUniform(Pe,ge),q){if(q.size>1)for(var ue=0;ue<q.size;++ue){var J=q.name.replace("[0]","["+ue+"]");Q(be,new G(J,h.id(J),a.getUniformLocation(Pe,J),q))}var ce=q.name;q.size>1&&(ce=ce.replace("[0]","")),Q(be,new G(ce,h.id(ce),a.getUniformLocation(Pe,ce),q))}var he=a.getProgramParameter(Pe,fy);R.profile&&(P.stats.attributesCount=he);var Oe=P.attributes;for(ge=0;ge<he;++ge)q=a.getActiveAttrib(Pe,ge),q&&Q(Oe,new G(q.name,h.id(q.name),a.getAttribLocation(Pe,q.name),q))}R.profile&&(_.getMaxUniformsCount=function(){var P=0;return ie.forEach(function(O){O.stats.uniformsCount>P&&(P=O.stats.uniformsCount)}),P},_.getMaxAttributesCount=function(){var P=0;return ie.forEach(function(O){O.stats.attributesCount>P&&(P=O.stats.attributesCount)}),P});function te(){U={},I={};for(var P=0;P<ie.length;++P)K(ie[P],null,ie[P].attributes.map(function(O){return[O.location,O.name]}))}return{clear:function(){var P=a.deleteShader.bind(a);Nt(U).forEach(P),U={},Nt(I).forEach(P),I={},ie.forEach(function(O){a.deleteProgram(O.program)}),ie.length=0,ne={},_.shaderCount=0},program:function(P,O,ee,ge){d.command(P>=0,"missing vertex shader",ee),d.command(O>=0,"missing fragment shader",ee);var q=ne[O];q||(q=ne[O]={});var pe=q[P];if(pe&&(pe.refCount++,!ge))return pe;var de=new fe(O,P);return _.shaderCount++,K(de,ee,ge),pe||(q[P]=de),ie.push(de),r(de,{destroy:function(){if(de.refCount--,de.refCount<=0){a.deleteProgram(de.program);var Pe=ie.indexOf(de);ie.splice(Pe,1),_.shaderCount--}q[de.vertId].refCount<=0&&(a.deleteShader(I[de.vertId]),delete I[de.vertId],delete ne[de.fragId][de.vertId]),Object.keys(ne[de.fragId]).length||(a.deleteShader(U[de.fragId]),delete U[de.fragId],delete ne[de.fragId])}})},restore:te,shader:Y,frag:-1,vert:-1}}var cy=6408,kr=5121,ly=3333,Oi=5126;function hy(a,h,_,R,U,I,G){function Q(ie){var re;h.next===null?(d(U.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),re=kr):(d(h.next.colorAttachments[0].texture!==null,"You cannot read from a renderbuffer"),re=h.next.colorAttachments[0].texture._texture.type,d.optional(function(){I.oes_texture_float?(d(re===kr||re===Oi,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),re===Oi&&d(G.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):d(re===kr,"Reading from a framebuffer is only allowed for the type 'uint8'")}));var fe=0,K=0,te=R.framebufferWidth,P=R.framebufferHeight,O=null;n(ie)?O=ie:ie&&(d.type(ie,"object","invalid arguments to regl.read()"),fe=ie.x|0,K=ie.y|0,d(fe>=0&&fe<R.framebufferWidth,"invalid x offset for regl.read"),d(K>=0&&K<R.framebufferHeight,"invalid y offset for regl.read"),te=(ie.width||R.framebufferWidth-fe)|0,P=(ie.height||R.framebufferHeight-K)|0,O=ie.data||null),O&&(re===kr?d(O instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):re===Oi&&d(O instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),d(te>0&&te+fe<=R.framebufferWidth,"invalid width for read pixels"),d(P>0&&P+K<=R.framebufferHeight,"invalid height for read pixels"),_();var ee=te*P*4;return O||(re===kr?O=new Uint8Array(ee):re===Oi&&(O=O||new Float32Array(ee))),d.isTypedArray(O,"data buffer for regl.read() must be a typedarray"),d(O.byteLength>=ee,"data buffer for regl.read() too small"),a.pixelStorei(ly,4),a.readPixels(fe,K,te,P,cy,re,O),O}function Y(ie){var re;return h.setFBO({framebuffer:ie.framebuffer},function(){re=Q(ie)}),re}function ne(ie){return!ie||!("framebuffer"in ie)?Q(ie):Y(ie)}return ne}function rr(a){return Array.prototype.slice.call(a)}function ir(a){return rr(a).join("")}function dy(){var a=0,h=[],_=[];function R(re){for(var fe=0;fe<_.length;++fe)if(_[fe]===re)return h[fe];var K="g"+a++;return h.push(K),_.push(re),K}function U(){var re=[];function fe(){re.push.apply(re,rr(arguments))}var K=[];function te(){var P="v"+a++;return K.push(P),arguments.length>0&&(re.push(P,"="),re.push.apply(re,rr(arguments)),re.push(";")),P}return r(fe,{def:te,toString:function(){return ir([K.length>0?"var "+K.join(",")+";":"",ir(re)])}})}function I(){var re=U(),fe=U(),K=re.toString,te=fe.toString;function P(O,ee){fe(O,ee,"=",re.def(O,ee),";")}return r(function(){re.apply(re,rr(arguments))},{def:re.def,entry:re,exit:fe,save:P,set:function(O,ee,ge){P(O,ee),re(O,ee,"=",ge,";")},toString:function(){return K()+te()}})}function G(){var re=ir(arguments),fe=I(),K=I(),te=fe.toString,P=K.toString;return r(fe,{then:function(){return fe.apply(fe,rr(arguments)),this},else:function(){return K.apply(K,rr(arguments)),this},toString:function(){var O=P();return O&&(O="else{"+O+"}"),ir(["if(",re,"){",te(),"}",O])}})}var Q=U(),Y={};function ne(re,fe){var K=[];function te(){var q="a"+K.length;return K.push(q),q}fe=fe||0;for(var P=0;P<fe;++P)te();var O=I(),ee=O.toString,ge=Y[re]=r(O,{arg:te,toString:function(){return ir(["function(",K.join(),"){",ee(),"}"])}});return ge}function ie(){var re=['"use strict";',Q,"return {"];Object.keys(Y).forEach(function(te){re.push('"',te,'":',Y[te].toString(),",")}),re.push("}");var fe=ir(re).replace(/;/g,`;
6
6
  `).replace(/}/g,`}
7
7
  `).replace(/{/g,`{
8
- `),K=Function.apply(null,h.concat(fe));return K.apply(null,_)}return{global:Q,link:R,block:U,proc:ne,scope:I,cond:N,compile:ie}}var or="xyzw".split(""),Iu=5121,ar=1,ca=2,la=0,ha=1,da=2,ma=3,Gi=4,Ru=5,Du=6,Mu="dither",Ou="blend.enable",Gu="blend.color",pa="blend.equation",va="blend.func",Nu="depth.enable",Bu="depth.func",Vu="depth.range",$u="depth.mask",ga="colorMask",Uu="cull.enable",ju="cull.face",ya="frontFace",xa="lineWidth",Xu="polygonOffset.enable",ba="polygonOffset.offset",Hu="sample.alpha",Wu="sample.enable",_a="sample.coverage",qu="stencil.enable",Yu="stencil.mask",Sa="stencil.func",wa="stencil.opFront",Fr="stencil.opBack",Zu="scissor.enable",Ni="scissor.box",dn="viewport",Lr="profile",Mn="framebuffer",zr="vert",Ir="frag",On="elements",Gn="primitive",Nn="count",Bi="offset",Vi="instances",Rr="vao",Ta="Width",Aa="Height",sr=Mn+Ta,fr=Mn+Aa,my=dn+Ta,py=dn+Aa,Qu="drawingBuffer",Ku=Qu+Ta,Ju=Qu+Aa,vy=[va,pa,Sa,wa,Fr,_a,dn,Ni,ba],ur=34962,Ea=34963,gy=35632,yy=35633,ec=3553,xy=34067,by=2884,_y=3042,Sy=3024,wy=2960,Ty=2929,Ay=3089,Ey=32823,Cy=32926,Py=32928,Ca=5126,$i=35664,Ui=35665,ji=35666,Pa=5124,Xi=35667,Hi=35668,Wi=35669,ka=35670,qi=35671,Yi=35672,Zi=35673,Dr=35674,Mr=35675,Or=35676,Gr=35678,Nr=35680,Fa=4,Br=1028,Bn=1029,tc=2304,La=2305,ky=32775,Fy=32776,Ly=519,bn=7680,nc=0,rc=1,ic=32774,zy=513,oc=36160,Iy=36064,nn={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},ac=["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"],cr={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},_n={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},sc={frag:gy,vert:yy},za={cw:tc,ccw:La};function Qi(a){return Array.isArray(a)||n(a)||Zt(a)}function fc(a){return a.sort(function(h,_){return h===dn?-1:_===dn?1:h<_?-1:1})}function xt(a,h,_,R){this.thisDep=a,this.contextDep=h,this.propDep=_,this.append=R}function Sn(a){return a&&!(a.thisDep||a.contextDep||a.propDep)}function dt(a){return new xt(!1,!1,!1,a)}function Ft(a,h){var _=a.type;if(_===la){var R=a.data.length;return new xt(!0,R>=1,R>=2,h)}else if(_===Gi){var U=a.data;return new xt(U.thisDep,U.contextDep,U.propDep,h)}else{if(_===Ru)return new xt(!1,!1,!1,h);if(_===Du){for(var I=!1,N=!1,Q=!1,Y=0;Y<a.data.length;++Y){var ne=a.data[Y];if(ne.type===ha)Q=!0;else if(ne.type===da)N=!0;else if(ne.type===ma)I=!0;else if(ne.type===la){I=!0;var ie=ne.data;ie>=1&&(N=!0),ie>=2&&(Q=!0)}else ne.type===Gi&&(I=I||ne.data.thisDep,N=N||ne.data.contextDep,Q=Q||ne.data.propDep)}return new xt(I,N,Q,h)}else return new xt(_===ma,_===da,_===ha,h)}}var uc=new xt(!1,!1,!1,function(){});function Ry(a,h,_,R,U,I,N,Q,Y,ne,ie,re,fe,K,te){var P=ne.Record,O={add:32774,subtract:32778,"reverse subtract":32779};_.ext_blend_minmax&&(O.min=ky,O.max=Fy);var ee=_.angle_instanced_arrays,ge=_.webgl_draw_buffers,W=_.oes_vertex_array_object,pe={dirty:!0,profile:te.profile},de={},Pe=[],j={},$={};function be(m){return m.replace(".","_")}function ue(m,l,w){var C=be(m);Pe.push(m),de[C]=pe[C]=!!w,j[C]=l}function J(m,l,w){var C=be(m);Pe.push(m),Array.isArray(w)?(pe[C]=w.slice(),de[C]=w.slice()):pe[C]=de[C]=w,$[C]=l}ue(Mu,Sy),ue(Ou,_y),J(Gu,"blendColor",[0,0,0,0]),J(pa,"blendEquationSeparate",[ic,ic]),J(va,"blendFuncSeparate",[rc,nc,rc,nc]),ue(Nu,Ty,!0),J(Bu,"depthFunc",zy),J(Vu,"depthRange",[0,1]),J($u,"depthMask",!0),J(ga,ga,[!0,!0,!0,!0]),ue(Uu,by),J(ju,"cullFace",Bn),J(ya,ya,La),J(xa,xa,1),ue(Xu,Ey),J(ba,"polygonOffset",[0,0]),ue(Hu,Cy),ue(Wu,Py),J(_a,"sampleCoverage",[1,!1]),ue(qu,wy),J(Yu,"stencilMask",-1),J(Sa,"stencilFunc",[Ly,0,-1]),J(wa,"stencilOpSeparate",[Br,bn,bn,bn]),J(Fr,"stencilOpSeparate",[Bn,bn,bn,bn]),ue(Zu,Ay),J(Ni,"scissor",[0,0,a.drawingBufferWidth,a.drawingBufferHeight]),J(dn,dn,[0,0,a.drawingBufferWidth,a.drawingBufferHeight]);var ce={gl:a,context:fe,strings:h,next:de,current:pe,draw:re,elements:I,buffer:U,shader:ie,attributes:ne.state,vao:ne,uniforms:Y,framebuffer:Q,extensions:_,timer:K,isBufferArgs:Qi},he={primTypes:yn,compareFuncs:cr,blendFuncs:nn,blendEquations:O,stencilOps:_n,glTypes:Ln,orientationType:za};d.optional(function(){ce.isArrayLike=at}),ge&&(he.backBuffer=[Bn],he.drawBuffer=Ot(R.maxDrawbuffers,function(m){return m===0?[0]:Ot(m,function(l){return Iy+l})}));var Oe=0;function De(){var m=dy(),l=m.link,w=m.global;m.id=Oe++,m.batchId="0";var C=l(ce),k=m.shared={props:"a0"};Object.keys(ce).forEach(function(x){k[x]=w.def(C,".",x)}),d.optional(function(){m.CHECK=l(d),m.commandStr=d.guessCommand(),m.command=l(m.commandStr),m.assert=function(x,g,L){x("if(!(",g,"))",this.CHECK,".commandRaise(",l(L),",",this.command,");")},he.invalidBlendCombinations=ac});var A=m.next={},T=m.current={};Object.keys($).forEach(function(x){Array.isArray(pe[x])&&(A[x]=w.def(k.next,".",x),T[x]=w.def(k.current,".",x))});var E=m.constants={};Object.keys(he).forEach(function(x){E[x]=w.def(JSON.stringify(he[x]))}),m.invoke=function(x,g){switch(g.type){case la:var L=["this",k.context,k.props,m.batchId];return x.def(l(g.data),".call(",L.slice(0,Math.max(g.data.length+1,4)),")");case ha:return x.def(k.props,g.data);case da:return x.def(k.context,g.data);case ma:return x.def("this",g.data);case Gi:return g.data.append(m,x),g.data.ref;case Ru:return g.data.toString();case Du:return g.data.map(function(F){return m.invoke(x,F)})}},m.attribCache={};var p={};return m.scopeAttrib=function(x){var g=h.id(x);if(g in p)return p[g];var L=ne.scope[g];L||(L=ne.scope[g]=new P);var F=p[g]=l(L);return F},m}function me(m){var l=m.static,w=m.dynamic,C;if(Lr in l){var k=!!l[Lr];C=dt(function(T,E){return k}),C.enable=k}else if(Lr in w){var A=w[Lr];C=Ft(A,function(T,E){return T.invoke(E,A)})}return C}function ve(m,l){var w=m.static,C=m.dynamic;if(Mn in w){var k=w[Mn];return k?(k=Q.getFramebuffer(k),d.command(k,"invalid framebuffer object"),dt(function(T,E){var p=T.link(k),x=T.shared;E.set(x.framebuffer,".next",p);var g=x.context;return E.set(g,"."+sr,p+".width"),E.set(g,"."+fr,p+".height"),p})):dt(function(T,E){var p=T.shared;E.set(p.framebuffer,".next","null");var x=p.context;return E.set(x,"."+sr,x+"."+Ku),E.set(x,"."+fr,x+"."+Ju),"null"})}else if(Mn in C){var A=C[Mn];return Ft(A,function(T,E){var p=T.invoke(E,A),x=T.shared,g=x.framebuffer,L=E.def(g,".getFramebuffer(",p,")");d.optional(function(){T.assert(E,"!"+p+"||"+L,"invalid framebuffer object")}),E.set(g,".next",L);var F=x.context;return E.set(F,"."+sr,L+"?"+L+".width:"+F+"."+Ku),E.set(F,"."+fr,L+"?"+L+".height:"+F+"."+Ju),L})}else return null}function ze(m,l,w){var C=m.static,k=m.dynamic;function A(p){if(p in C){var x=C[p];d.commandType(x,"object","invalid "+p,w.commandStr);var g=!0,L=x.x|0,F=x.y|0,V,X;return"width"in x?(V=x.width|0,d.command(V>=0,"invalid "+p,w.commandStr)):g=!1,"height"in x?(X=x.height|0,d.command(X>=0,"invalid "+p,w.commandStr)):g=!1,new xt(!g&&l&&l.thisDep,!g&&l&&l.contextDep,!g&&l&&l.propDep,function(Ee,ye){var H=Ee.shared.context,B=V;"width"in x||(B=ye.def(H,".",sr,"-",L));var Te=X;return"height"in x||(Te=ye.def(H,".",fr,"-",F)),[L,F,B,Te]})}else if(p in k){var se=k[p],Re=Ft(se,function(Ee,ye){var H=Ee.invoke(ye,se);d.optional(function(){Ee.assert(ye,H+"&&typeof "+H+'==="object"',"invalid "+p)});var B=Ee.shared.context,Te=ye.def(H,".x|0"),_e=ye.def(H,".y|0"),Ie=ye.def('"width" in ',H,"?",H,".width|0:","(",B,".",sr,"-",Te,")"),Je=ye.def('"height" in ',H,"?",H,".height|0:","(",B,".",fr,"-",_e,")");return d.optional(function(){Ee.assert(ye,Ie+">=0&&"+Je+">=0","invalid "+p)}),[Te,_e,Ie,Je]});return l&&(Re.thisDep=Re.thisDep||l.thisDep,Re.contextDep=Re.contextDep||l.contextDep,Re.propDep=Re.propDep||l.propDep),Re}else return l?new xt(l.thisDep,l.contextDep,l.propDep,function(Ee,ye){var H=Ee.shared.context;return[0,0,ye.def(H,".",sr),ye.def(H,".",fr)]}):null}var T=A(dn);if(T){var E=T;T=new xt(T.thisDep,T.contextDep,T.propDep,function(p,x){var g=E.append(p,x),L=p.shared.context;return x.set(L,"."+my,g[2]),x.set(L,"."+py,g[3]),g})}return{viewport:T,scissor_box:A(Ni)}}function Ge(m,l){var w=m.static,C=typeof w[Ir]=="string"&&typeof w[zr]=="string";if(C){if(Object.keys(l.dynamic).length>0)return null;var k=l.static,A=Object.keys(k);if(A.length>0&&typeof k[A[0]]=="number"){for(var T=[],E=0;E<A.length;++E)d(typeof k[A[E]]=="number","must specify all vertex attribute locations when using vaos"),T.push([k[A[E]]|0,A[E]]);return T}}return null}function We(m,l,w){var C=m.static,k=m.dynamic;function A(g){if(g in C){var L=h.id(C[g]);d.optional(function(){ie.shader(sc[g],L,d.guessCommand())});var F=dt(function(){return L});return F.id=L,F}else if(g in k){var V=k[g];return Ft(V,function(X,se){var Re=X.invoke(se,V),Ee=se.def(X.shared.strings,".id(",Re,")");return d.optional(function(){se(X.shared.shader,".shader(",sc[g],",",Ee,",",X.command,");")}),Ee})}return null}var T=A(Ir),E=A(zr),p=null,x;return Sn(T)&&Sn(E)?(p=ie.program(E.id,T.id,null,w),x=dt(function(g,L){return g.link(p)})):x=new xt(T&&T.thisDep||E&&E.thisDep,T&&T.contextDep||E&&E.contextDep,T&&T.propDep||E&&E.propDep,function(g,L){var F=g.shared.shader,V;T?V=T.append(g,L):V=L.def(F,".",Ir);var X;E?X=E.append(g,L):X=L.def(F,".",zr);var se=F+".program("+X+","+V;return d.optional(function(){se+=","+g.command}),L.def(se+")")}),{frag:T,vert:E,progVar:x,program:p}}function st(m,l){var w=m.static,C=m.dynamic,k={},A=!1;function T(){if(Rr in w){var ye=w[Rr];return ye!==null&&ne.getVAO(ye)===null&&(ye=ne.createVAO(ye)),A=!0,k.vao=ye,dt(function(B){var Te=ne.getVAO(ye);return Te?B.link(Te):"null"})}else if(Rr in C){A=!0;var H=C[Rr];return Ft(H,function(B,Te){var _e=B.invoke(Te,H);return Te.def(B.shared.vao+".getVAO("+_e+")")})}return null}var E=T(),p=!1;function x(){if(On in w){var ye=w[On];if(k.elements=ye,Qi(ye)){var H=k.elements=I.create(ye,!0);ye=I.getElements(H),p=!0}else ye&&(ye=I.getElements(ye),p=!0,d.command(ye,"invalid elements",l.commandStr));var B=dt(function(_e,Ie){if(ye){var Je=_e.link(ye);return _e.ELEMENTS=Je,Je}return _e.ELEMENTS=null,null});return B.value=ye,B}else if(On in C){p=!0;var Te=C[On];return Ft(Te,function(_e,Ie){var Je=_e.shared,Ct=Je.isBufferArgs,$n=Je.elements,mn=_e.invoke(Ie,Te),on=Ie.def("null"),wn=Ie.def(Ct,"(",mn,")"),Un=_e.cond(wn).then(on,"=",$n,".createStream(",mn,");").else(on,"=",$n,".getElements(",mn,");");return d.optional(function(){_e.assert(Un.else,"!"+mn+"||"+on,"invalid elements")}),Ie.entry(Un),Ie.exit(_e.cond(wn).then($n,".destroyStream(",on,");")),_e.ELEMENTS=on,on})}else if(A)return new xt(E.thisDep,E.contextDep,E.propDep,function(_e,Ie){return Ie.def(_e.shared.vao+".currentVAO?"+_e.shared.elements+".getElements("+_e.shared.vao+".currentVAO.elements):null")});return null}var g=x();function L(){if(Gn in w){var ye=w[Gn];return k.primitive=ye,d.commandParameter(ye,yn,"invalid primitve",l.commandStr),dt(function(B,Te){return yn[ye]})}else if(Gn in C){var H=C[Gn];return Ft(H,function(B,Te){var _e=B.constants.primTypes,Ie=B.invoke(Te,H);return d.optional(function(){B.assert(Te,Ie+" in "+_e,"invalid primitive, must be one of "+Object.keys(yn))}),Te.def(_e,"[",Ie,"]")})}else{if(p)return Sn(g)?g.value?dt(function(B,Te){return Te.def(B.ELEMENTS,".primType")}):dt(function(){return Fa}):new xt(g.thisDep,g.contextDep,g.propDep,function(B,Te){var _e=B.ELEMENTS;return Te.def(_e,"?",_e,".primType:",Fa)});if(A)return new xt(E.thisDep,E.contextDep,E.propDep,function(B,Te){return Te.def(B.shared.vao+".currentVAO?"+B.shared.vao+".currentVAO.primitive:"+Fa)})}return null}function F(ye,H){if(ye in w){var B=w[ye]|0;return H?k.offset=B:k.instances=B,d.command(!H||B>=0,"invalid "+ye,l.commandStr),dt(function(_e,Ie){return H&&(_e.OFFSET=B),B})}else if(ye in C){var Te=C[ye];return Ft(Te,function(_e,Ie){var Je=_e.invoke(Ie,Te);return H&&(_e.OFFSET=Je,d.optional(function(){_e.assert(Ie,Je+">=0","invalid "+ye)})),Je})}else if(H){if(p)return dt(function(_e,Ie){return _e.OFFSET=0,0});if(A)return new xt(E.thisDep,E.contextDep,E.propDep,function(_e,Ie){return Ie.def(_e.shared.vao+".currentVAO?"+_e.shared.vao+".currentVAO.offset:0")})}else if(A)return new xt(E.thisDep,E.contextDep,E.propDep,function(_e,Ie){return Ie.def(_e.shared.vao+".currentVAO?"+_e.shared.vao+".currentVAO.instances:-1")});return null}var V=F(Bi,!0);function X(){if(Nn in w){var ye=w[Nn]|0;return k.count=ye,d.command(typeof ye=="number"&&ye>=0,"invalid vertex count",l.commandStr),dt(function(){return ye})}else if(Nn in C){var H=C[Nn];return Ft(H,function(Ie,Je){var Ct=Ie.invoke(Je,H);return d.optional(function(){Ie.assert(Je,"typeof "+Ct+'==="number"&&'+Ct+">=0&&"+Ct+"===("+Ct+"|0)","invalid vertex count")}),Ct})}else if(p)if(Sn(g)){if(g)return V?new xt(V.thisDep,V.contextDep,V.propDep,function(Ie,Je){var Ct=Je.def(Ie.ELEMENTS,".vertCount-",Ie.OFFSET);return d.optional(function(){Ie.assert(Je,Ct+">=0","invalid vertex offset/element buffer too small")}),Ct}):dt(function(Ie,Je){return Je.def(Ie.ELEMENTS,".vertCount")});var B=dt(function(){return-1});return d.optional(function(){B.MISSING=!0}),B}else{var Te=new xt(g.thisDep||V.thisDep,g.contextDep||V.contextDep,g.propDep||V.propDep,function(Ie,Je){var Ct=Ie.ELEMENTS;return Ie.OFFSET?Je.def(Ct,"?",Ct,".vertCount-",Ie.OFFSET,":-1"):Je.def(Ct,"?",Ct,".vertCount:-1")});return d.optional(function(){Te.DYNAMIC=!0}),Te}else if(A){var _e=new xt(E.thisDep,E.contextDep,E.propDep,function(Ie,Je){return Je.def(Ie.shared.vao,".currentVAO?",Ie.shared.vao,".currentVAO.count:-1")});return _e}return null}var se=L(),Re=X(),Ee=F(Vi,!1);return{elements:g,primitive:se,count:Re,instances:Ee,offset:V,vao:E,vaoActive:A,elementsActive:p,static:k}}function ft(m,l){var w=m.static,C=m.dynamic,k={};return Pe.forEach(function(A){var T=be(A);function E(p,x){if(A in w){var g=p(w[A]);k[T]=dt(function(){return g})}else if(A in C){var L=C[A];k[T]=Ft(L,function(F,V){return x(F,V,F.invoke(V,L))})}}switch(A){case Uu:case Ou:case Mu:case qu:case Nu:case Zu:case Xu:case Hu:case Wu:case $u:return E(function(p){return d.commandType(p,"boolean",A,l.commandStr),p},function(p,x,g){return d.optional(function(){p.assert(x,"typeof "+g+'==="boolean"',"invalid flag "+A,p.commandStr)}),g});case Bu:return E(function(p){return d.commandParameter(p,cr,"invalid "+A,l.commandStr),cr[p]},function(p,x,g){var L=p.constants.compareFuncs;return d.optional(function(){p.assert(x,g+" in "+L,"invalid "+A+", must be one of "+Object.keys(cr))}),x.def(L,"[",g,"]")});case Vu:return E(function(p){return d.command(at(p)&&p.length===2&&typeof p[0]=="number"&&typeof p[1]=="number"&&p[0]<=p[1],"depth range is 2d array",l.commandStr),p},function(p,x,g){d.optional(function(){p.assert(x,p.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 L=x.def("+",g,"[0]"),F=x.def("+",g,"[1]");return[L,F]});case va:return E(function(p){d.commandType(p,"object","blend.func",l.commandStr);var x="srcRGB"in p?p.srcRGB:p.src,g="srcAlpha"in p?p.srcAlpha:p.src,L="dstRGB"in p?p.dstRGB:p.dst,F="dstAlpha"in p?p.dstAlpha:p.dst;return d.commandParameter(x,nn,T+".srcRGB",l.commandStr),d.commandParameter(g,nn,T+".srcAlpha",l.commandStr),d.commandParameter(L,nn,T+".dstRGB",l.commandStr),d.commandParameter(F,nn,T+".dstAlpha",l.commandStr),d.command(ac.indexOf(x+", "+L)===-1,"unallowed blending combination (srcRGB, dstRGB) = ("+x+", "+L+")",l.commandStr),[nn[x],nn[L],nn[g],nn[F]]},function(p,x,g){var L=p.constants.blendFuncs;d.optional(function(){p.assert(x,g+"&&typeof "+g+'==="object"',"invalid blend func, must be an object")});function F(H,B){var Te=x.def('"',H,B,'" in ',g,"?",g,".",H,B,":",g,".",H);return d.optional(function(){p.assert(x,Te+" in "+L,"invalid "+A+"."+H+B+", must be one of "+Object.keys(nn))}),Te}var V=F("src","RGB"),X=F("dst","RGB");d.optional(function(){var H=p.constants.invalidBlendCombinations;p.assert(x,H+".indexOf("+V+'+", "+'+X+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var se=x.def(L,"[",V,"]"),Re=x.def(L,"[",F("src","Alpha"),"]"),Ee=x.def(L,"[",X,"]"),ye=x.def(L,"[",F("dst","Alpha"),"]");return[se,Ee,Re,ye]});case pa:return E(function(p){if(typeof p=="string")return d.commandParameter(p,O,"invalid "+A,l.commandStr),[O[p],O[p]];if(typeof p=="object")return d.commandParameter(p.rgb,O,A+".rgb",l.commandStr),d.commandParameter(p.alpha,O,A+".alpha",l.commandStr),[O[p.rgb],O[p.alpha]];d.commandRaise("invalid blend.equation",l.commandStr)},function(p,x,g){var L=p.constants.blendEquations,F=x.def(),V=x.def(),X=p.cond("typeof ",g,'==="string"');return d.optional(function(){function se(Re,Ee,ye){p.assert(Re,ye+" in "+L,"invalid "+Ee+", must be one of "+Object.keys(O))}se(X.then,A,g),p.assert(X.else,g+"&&typeof "+g+'==="object"',"invalid "+A),se(X.else,A+".rgb",g+".rgb"),se(X.else,A+".alpha",g+".alpha")}),X.then(F,"=",V,"=",L,"[",g,"];"),X.else(F,"=",L,"[",g,".rgb];",V,"=",L,"[",g,".alpha];"),x(X),[F,V]});case Gu:return E(function(p){return d.command(at(p)&&p.length===4,"blend.color must be a 4d array",l.commandStr),Ot(4,function(x){return+p[x]})},function(p,x,g){return d.optional(function(){p.assert(x,p.shared.isArrayLike+"("+g+")&&"+g+".length===4","blend.color must be a 4d array")}),Ot(4,function(L){return x.def("+",g,"[",L,"]")})});case Yu:return E(function(p){return d.commandType(p,"number",T,l.commandStr),p|0},function(p,x,g){return d.optional(function(){p.assert(x,"typeof "+g+'==="number"',"invalid stencil.mask")}),x.def(g,"|0")});case Sa:return E(function(p){d.commandType(p,"object",T,l.commandStr);var x=p.cmp||"keep",g=p.ref||0,L="mask"in p?p.mask:-1;return d.commandParameter(x,cr,A+".cmp",l.commandStr),d.commandType(g,"number",A+".ref",l.commandStr),d.commandType(L,"number",A+".mask",l.commandStr),[cr[x],g,L]},function(p,x,g){var L=p.constants.compareFuncs;d.optional(function(){function se(){p.assert(x,Array.prototype.join.call(arguments,""),"invalid stencil.func")}se(g+"&&typeof ",g,'==="object"'),se('!("cmp" in ',g,")||(",g,".cmp in ",L,")")});var F=x.def('"cmp" in ',g,"?",L,"[",g,".cmp]",":",bn),V=x.def(g,".ref|0"),X=x.def('"mask" in ',g,"?",g,".mask|0:-1");return[F,V,X]});case wa:case Fr:return E(function(p){d.commandType(p,"object",T,l.commandStr);var x=p.fail||"keep",g=p.zfail||"keep",L=p.zpass||"keep";return d.commandParameter(x,_n,A+".fail",l.commandStr),d.commandParameter(g,_n,A+".zfail",l.commandStr),d.commandParameter(L,_n,A+".zpass",l.commandStr),[A===Fr?Bn:Br,_n[x],_n[g],_n[L]]},function(p,x,g){var L=p.constants.stencilOps;d.optional(function(){p.assert(x,g+"&&typeof "+g+'==="object"',"invalid "+A)});function F(V){return d.optional(function(){p.assert(x,'!("'+V+'" in '+g+")||("+g+"."+V+" in "+L+")","invalid "+A+"."+V+", must be one of "+Object.keys(_n))}),x.def('"',V,'" in ',g,"?",L,"[",g,".",V,"]:",bn)}return[A===Fr?Bn:Br,F("fail"),F("zfail"),F("zpass")]});case ba:return E(function(p){d.commandType(p,"object",T,l.commandStr);var x=p.factor|0,g=p.units|0;return d.commandType(x,"number",T+".factor",l.commandStr),d.commandType(g,"number",T+".units",l.commandStr),[x,g]},function(p,x,g){d.optional(function(){p.assert(x,g+"&&typeof "+g+'==="object"',"invalid "+A)});var L=x.def(g,".factor|0"),F=x.def(g,".units|0");return[L,F]});case ju:return E(function(p){var x=0;return p==="front"?x=Br:p==="back"&&(x=Bn),d.command(!!x,T,l.commandStr),x},function(p,x,g){return d.optional(function(){p.assert(x,g+'==="front"||'+g+'==="back"',"invalid cull.face")}),x.def(g,'==="front"?',Br,":",Bn)});case xa:return E(function(p){return d.command(typeof p=="number"&&p>=R.lineWidthDims[0]&&p<=R.lineWidthDims[1],"invalid line width, must be a positive number between "+R.lineWidthDims[0]+" and "+R.lineWidthDims[1],l.commandStr),p},function(p,x,g){return d.optional(function(){p.assert(x,"typeof "+g+'==="number"&&'+g+">="+R.lineWidthDims[0]+"&&"+g+"<="+R.lineWidthDims[1],"invalid line width")}),g});case ya:return E(function(p){return d.commandParameter(p,za,T,l.commandStr),za[p]},function(p,x,g){return d.optional(function(){p.assert(x,g+'==="cw"||'+g+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),x.def(g+'==="cw"?'+tc+":"+La)});case ga:return E(function(p){return d.command(at(p)&&p.length===4,"color.mask must be length 4 array",l.commandStr),p.map(function(x){return!!x})},function(p,x,g){return d.optional(function(){p.assert(x,p.shared.isArrayLike+"("+g+")&&"+g+".length===4","invalid color.mask")}),Ot(4,function(L){return"!!"+g+"["+L+"]"})});case _a:return E(function(p){d.command(typeof p=="object"&&p,T,l.commandStr);var x="value"in p?p.value:1,g=!!p.invert;return d.command(typeof x=="number"&&x>=0&&x<=1,"sample.coverage.value must be a number between 0 and 1",l.commandStr),[x,g]},function(p,x,g){d.optional(function(){p.assert(x,g+"&&typeof "+g+'==="object"',"invalid sample.coverage")});var L=x.def('"value" in ',g,"?+",g,".value:1"),F=x.def("!!",g,".invert");return[L,F]})}}),k}function Ze(m,l){var w=m.static,C=m.dynamic,k={};return Object.keys(w).forEach(function(A){var T=w[A],E;if(typeof T=="number"||typeof T=="boolean")E=dt(function(){return T});else if(typeof T=="function"){var p=T._reglType;p==="texture2d"||p==="textureCube"?E=dt(function(x){return x.link(T)}):p==="framebuffer"||p==="framebufferCube"?(d.command(T.color.length>0,'missing color attachment for framebuffer sent to uniform "'+A+'"',l.commandStr),E=dt(function(x){return x.link(T.color[0])})):d.commandRaise('invalid data for uniform "'+A+'"',l.commandStr)}else at(T)?E=dt(function(x){var g=x.global.def("[",Ot(T.length,function(L){return d.command(typeof T[L]=="number"||typeof T[L]=="boolean","invalid uniform "+A,x.commandStr),T[L]}),"]");return g}):d.commandRaise('invalid or missing data for uniform "'+A+'"',l.commandStr);E.value=T,k[A]=E}),Object.keys(C).forEach(function(A){var T=C[A];k[A]=Ft(T,function(E,p){return E.invoke(p,T)})}),k}function pt(m,l){var w=m.static,C=m.dynamic,k={};return Object.keys(w).forEach(function(A){var T=w[A],E=h.id(A),p=new P;if(Qi(T))p.state=ar,p.buffer=U.getBuffer(U.create(T,ur,!1,!0)),p.type=0;else{var x=U.getBuffer(T);if(x)p.state=ar,p.buffer=x,p.type=0;else if(d.command(typeof T=="object"&&T,"invalid data for attribute "+A,l.commandStr),"constant"in T){var g=T.constant;p.buffer="null",p.state=ca,typeof g=="number"?p.x=g:(d.command(at(g)&&g.length>0&&g.length<=4,"invalid constant for attribute "+A,l.commandStr),or.forEach(function(Ee,ye){ye<g.length&&(p[Ee]=g[ye])}))}else{Qi(T.buffer)?x=U.getBuffer(U.create(T.buffer,ur,!1,!0)):x=U.getBuffer(T.buffer),d.command(!!x,'missing buffer for attribute "'+A+'"',l.commandStr);var L=T.offset|0;d.command(L>=0,'invalid offset for attribute "'+A+'"',l.commandStr);var F=T.stride|0;d.command(F>=0&&F<256,'invalid stride for attribute "'+A+'", must be integer betweeen [0, 255]',l.commandStr);var V=T.size|0;d.command(!("size"in T)||V>0&&V<=4,'invalid size for attribute "'+A+'", must be 1,2,3,4',l.commandStr);var X=!!T.normalized,se=0;"type"in T&&(d.commandParameter(T.type,Ln,"invalid type for attribute "+A,l.commandStr),se=Ln[T.type]);var Re=T.divisor|0;d.optional(function(){"divisor"in T&&(d.command(Re===0||ee,'cannot specify divisor for attribute "'+A+'", instancing not supported',l.commandStr),d.command(Re>=0,'invalid divisor for attribute "'+A+'"',l.commandStr));var Ee=l.commandStr,ye=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(T).forEach(function(H){d.command(ye.indexOf(H)>=0,'unknown parameter "'+H+'" for attribute pointer "'+A+'" (valid parameters are '+ye+")",Ee)})}),p.buffer=x,p.state=ar,p.size=V,p.normalized=X,p.type=se||x.dtype,p.offset=L,p.stride=F,p.divisor=Re}}k[A]=dt(function(Ee,ye){var H=Ee.attribCache;if(E in H)return H[E];var B={isStream:!1};return Object.keys(p).forEach(function(Te){B[Te]=p[Te]}),p.buffer&&(B.buffer=Ee.link(p.buffer),B.type=B.type||B.buffer+".dtype"),H[E]=B,B})}),Object.keys(C).forEach(function(A){var T=C[A];function E(p,x){var g=p.invoke(x,T),L=p.shared,F=p.constants,V=L.isBufferArgs,X=L.buffer;d.optional(function(){p.assert(x,g+"&&(typeof "+g+'==="object"||typeof '+g+'==="function")&&('+V+"("+g+")||"+X+".getBuffer("+g+")||"+X+".getBuffer("+g+".buffer)||"+V+"("+g+'.buffer)||("constant" in '+g+"&&(typeof "+g+'.constant==="number"||'+L.isArrayLike+"("+g+".constant))))",'invalid dynamic attribute "'+A+'"')});var se={isStream:x.def(!1)},Re=new P;Re.state=ar,Object.keys(Re).forEach(function(B){se[B]=x.def(""+Re[B])});var Ee=se.buffer,ye=se.type;x("if(",V,"(",g,")){",se.isStream,"=true;",Ee,"=",X,".createStream(",ur,",",g,");",ye,"=",Ee,".dtype;","}else{",Ee,"=",X,".getBuffer(",g,");","if(",Ee,"){",ye,"=",Ee,".dtype;",'}else if("constant" in ',g,"){",se.state,"=",ca,";","if(typeof "+g+'.constant === "number"){',se[or[0]],"=",g,".constant;",or.slice(1).map(function(B){return se[B]}).join("="),"=0;","}else{",or.map(function(B,Te){return se[B]+"="+g+".constant.length>"+Te+"?"+g+".constant["+Te+"]:0;"}).join(""),"}}else{","if(",V,"(",g,".buffer)){",Ee,"=",X,".createStream(",ur,",",g,".buffer);","}else{",Ee,"=",X,".getBuffer(",g,".buffer);","}",ye,'="type" in ',g,"?",F.glTypes,"[",g,".type]:",Ee,".dtype;",se.normalized,"=!!",g,".normalized;");function H(B){x(se[B],"=",g,".",B,"|0;")}return H("size"),H("offset"),H("stride"),H("divisor"),x("}}"),x.exit("if(",se.isStream,"){",X,".destroyStream(",Ee,");","}"),se}k[A]=Ft(T,E)}),k}function ot(m){var l=m.static,w=m.dynamic,C={};return Object.keys(l).forEach(function(k){var A=l[k];C[k]=dt(function(T,E){return typeof A=="number"||typeof A=="boolean"?""+A:T.link(A)})}),Object.keys(w).forEach(function(k){var A=w[k];C[k]=Ft(A,function(T,E){return T.invoke(E,A)})}),C}function mt(m,l,w,C,k){var A=m.static,T=m.dynamic;d.optional(function(){var H=[Mn,zr,Ir,On,Gn,Bi,Nn,Vi,Lr,Rr].concat(Pe);function B(Te){Object.keys(Te).forEach(function(_e){d.command(H.indexOf(_e)>=0,'unknown parameter "'+_e+'"',k.commandStr)})}B(A),B(T)});var E=Ge(m,l),p=ve(m),x=ze(m,p,k),g=st(m,k),L=ft(m,k),F=We(m,k,E);function V(H){var B=x[H];B&&(L[H]=B)}V(dn),V(be(Ni));var X=Object.keys(L).length>0,se={framebuffer:p,draw:g,shader:F,state:L,dirty:X,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(se.profile=me(m),se.uniforms=Ze(w,k),se.drawVAO=se.scopeVAO=g.vao,!se.drawVAO&&F.program&&!E&&_.angle_instanced_arrays&&g.static.elements){var Re=!0,Ee=F.program.attributes.map(function(H){var B=l.static[H];return Re=Re&&!!B,B});if(Re&&Ee.length>0){var ye=ne.getVAO(ne.createVAO({attributes:Ee,elements:g.static.elements}));se.drawVAO=new xt(null,null,null,function(H,B){return H.link(ye)}),se.useVAO=!0}}return E?se.useVAO=!0:se.attributes=pt(l,k),se.context=ot(C),se}function vt(m,l,w){var C=m.shared,k=C.context,A=m.scope();Object.keys(w).forEach(function(T){l.save(k,"."+T);var E=w[T],p=E.append(m,l);Array.isArray(p)?A(k,".",T,"=[",p.join(),"];"):A(k,".",T,"=",p,";")}),l(A)}function gt(m,l,w,C){var k=m.shared,A=k.gl,T=k.framebuffer,E;ge&&(E=l.def(k.extensions,".webgl_draw_buffers"));var p=m.constants,x=p.drawBuffer,g=p.backBuffer,L;w?L=w.append(m,l):L=l.def(T,".next"),C||l("if(",L,"!==",T,".cur){"),l("if(",L,"){",A,".bindFramebuffer(",oc,",",L,".framebuffer);"),ge&&l(E,".drawBuffersWEBGL(",x,"[",L,".colorAttachments.length]);"),l("}else{",A,".bindFramebuffer(",oc,",null);"),ge&&l(E,".drawBuffersWEBGL(",g,");"),l("}",T,".cur=",L,";"),C||l("}")}function St(m,l,w){var C=m.shared,k=C.gl,A=m.current,T=m.next,E=C.current,p=C.next,x=m.cond(E,".dirty");Pe.forEach(function(g){var L=be(g);if(!(L in w.state)){var F,V;if(L in T){F=T[L],V=A[L];var X=Ot(pe[L].length,function(Re){return x.def(F,"[",Re,"]")});x(m.cond(X.map(function(Re,Ee){return Re+"!=="+V+"["+Ee+"]"}).join("||")).then(k,".",$[L],"(",X,");",X.map(function(Re,Ee){return V+"["+Ee+"]="+Re}).join(";"),";"))}else{F=x.def(p,".",L);var se=m.cond(F,"!==",E,".",L);x(se),L in j?se(m.cond(F).then(k,".enable(",j[L],");").else(k,".disable(",j[L],");"),E,".",L,"=",F,";"):se(k,".",$[L],"(",F,");",E,".",L,"=",F,";")}}}),Object.keys(w.state).length===0&&x(E,".dirty=false;"),l(x)}function At(m,l,w,C){var k=m.shared,A=m.current,T=k.current,E=k.gl;fc(Object.keys(w)).forEach(function(p){var x=w[p];if(!(C&&!C(x))){var g=x.append(m,l);if(j[p]){var L=j[p];Sn(x)?g?l(E,".enable(",L,");"):l(E,".disable(",L,");"):l(m.cond(g).then(E,".enable(",L,");").else(E,".disable(",L,");")),l(T,".",p,"=",g,";")}else if(at(g)){var F=A[p];l(E,".",$[p],"(",g,");",g.map(function(V,X){return F+"["+X+"]="+V}).join(";"),";")}else l(E,".",$[p],"(",g,");",T,".",p,"=",g,";")}})}function ct(m,l){ee&&(m.instancing=l.def(m.shared.extensions,".angle_instanced_arrays"))}function Ve(m,l,w,C,k){var A=m.shared,T=m.stats,E=A.current,p=A.timer,x=w.profile;function g(){return typeof performance>"u"?"Date.now()":"performance.now()"}var L,F;function V(H){L=l.def(),H(L,"=",g(),";"),typeof k=="string"?H(T,".count+=",k,";"):H(T,".count++;"),K&&(C?(F=l.def(),H(F,"=",p,".getNumPendingQueries();")):H(p,".beginQuery(",T,");"))}function X(H){H(T,".cpuTime+=",g(),"-",L,";"),K&&(C?H(p,".pushScopeStats(",F,",",p,".getNumPendingQueries(),",T,");"):H(p,".endQuery();"))}function se(H){var B=l.def(E,".profile");l(E,".profile=",H,";"),l.exit(E,".profile=",B,";")}var Re;if(x){if(Sn(x)){x.enable?(V(l),X(l.exit),se("true")):se("false");return}Re=x.append(m,l),se(Re)}else Re=l.def(E,".profile");var Ee=m.block();V(Ee),l("if(",Re,"){",Ee,"}");var ye=m.block();X(ye),l.exit("if(",Re,"){",ye,"}")}function Et(m,l,w,C,k){var A=m.shared;function T(p){switch(p){case $i:case Xi:case qi:return 2;case Ui:case Hi:case Yi:return 3;case ji:case Wi:case Zi:return 4;default:return 1}}function E(p,x,g){var L=A.gl,F=l.def(p,".location"),V=l.def(A.attributes,"[",F,"]"),X=g.state,se=g.buffer,Re=[g.x,g.y,g.z,g.w],Ee=["buffer","normalized","offset","stride"];function ye(){l("if(!",V,".buffer){",L,".enableVertexAttribArray(",F,");}");var B=g.type,Te;if(g.size?Te=l.def(g.size,"||",x):Te=x,l("if(",V,".type!==",B,"||",V,".size!==",Te,"||",Ee.map(function(Ie){return V+"."+Ie+"!=="+g[Ie]}).join("||"),"){",L,".bindBuffer(",ur,",",se,".buffer);",L,".vertexAttribPointer(",[F,Te,B,g.normalized,g.stride,g.offset],");",V,".type=",B,";",V,".size=",Te,";",Ee.map(function(Ie){return V+"."+Ie+"="+g[Ie]+";"}).join(""),"}"),ee){var _e=g.divisor;l("if(",V,".divisor!==",_e,"){",m.instancing,".vertexAttribDivisorANGLE(",[F,_e],");",V,".divisor=",_e,";}")}}function H(){l("if(",V,".buffer){",L,".disableVertexAttribArray(",F,");",V,".buffer=null;","}if(",or.map(function(B,Te){return V+"."+B+"!=="+Re[Te]}).join("||"),"){",L,".vertexAttrib4f(",F,",",Re,");",or.map(function(B,Te){return V+"."+B+"="+Re[Te]+";"}).join(""),"}")}X===ar?ye():X===ca?H():(l("if(",X,"===",ar,"){"),ye(),l("}else{"),H(),l("}"))}C.forEach(function(p){var x=p.name,g=w.attributes[x],L;if(g){if(!k(g))return;L=g.append(m,l)}else{if(!k(uc))return;var F=m.scopeAttrib(x);d.optional(function(){m.assert(l,F+".state","missing attribute "+x)}),L={},Object.keys(new P).forEach(function(V){L[V]=l.def(F,".",V)})}E(m.link(p),T(p.info.type),L)})}function Ke(m,l,w,C,k,A){for(var T=m.shared,E=T.gl,p={},x,g=0;g<C.length;++g){var L=C[g],F=L.name,V=L.info.type,X=L.info.size,se=w.uniforms[F];if(X>1){if(!se)continue;var Re=F.replace("[0]","");if(p[Re])continue;p[Re]=1}var Ee=m.link(L),ye=Ee+".location",H;if(se){if(!k(se))continue;if(Sn(se)){var B=se.value;if(d.command(B!==null&&typeof B<"u",'missing uniform "'+F+'"',m.commandStr),V===Gr||V===Nr){d.command(typeof B=="function"&&(V===Gr&&(B._reglType==="texture2d"||B._reglType==="framebuffer")||V===Nr&&(B._reglType==="textureCube"||B._reglType==="framebufferCube")),"invalid texture for uniform "+F,m.commandStr);var Te=m.link(B._texture||B.color[0]._texture);l(E,".uniform1i(",ye,",",Te+".bind());"),l.exit(Te,".unbind();")}else if(V===Dr||V===Mr||V===Or){d.optional(function(){d.command(at(B),"invalid matrix for uniform "+F,m.commandStr),d.command(V===Dr&&B.length===4||V===Mr&&B.length===9||V===Or&&B.length===16,"invalid length for matrix uniform "+F,m.commandStr)});var _e=m.global.def("new Float32Array(["+Array.prototype.slice.call(B)+"])"),Ie=2;V===Mr?Ie=3:V===Or&&(Ie=4),l(E,".uniformMatrix",Ie,"fv(",ye,",false,",_e,");")}else{switch(V){case Ca:X===1?d.commandType(B,"number","uniform "+F,m.commandStr):d.command(at(B)&&B.length===X,"uniform "+F,m.commandStr),x="1f";break;case $i:d.command(at(B)&&B.length&&B.length%2===0&&B.length<=X*2,"uniform "+F,m.commandStr),x="2f";break;case Ui:d.command(at(B)&&B.length&&B.length%3===0&&B.length<=X*3,"uniform "+F,m.commandStr),x="3f";break;case ji:d.command(at(B)&&B.length&&B.length%4===0&&B.length<=X*4,"uniform "+F,m.commandStr),x="4f";break;case ka:X===1?d.commandType(B,"boolean","uniform "+F,m.commandStr):d.command(at(B)&&B.length===X,"uniform "+F,m.commandStr),x="1i";break;case Pa:X===1?d.commandType(B,"number","uniform "+F,m.commandStr):d.command(at(B)&&B.length===X,"uniform "+F,m.commandStr),x="1i";break;case qi:d.command(at(B)&&B.length&&B.length%2===0&&B.length<=X*2,"uniform "+F,m.commandStr),x="2i";break;case Xi:d.command(at(B)&&B.length&&B.length%2===0&&B.length<=X*2,"uniform "+F,m.commandStr),x="2i";break;case Yi:d.command(at(B)&&B.length&&B.length%3===0&&B.length<=X*3,"uniform "+F,m.commandStr),x="3i";break;case Hi:d.command(at(B)&&B.length&&B.length%3===0&&B.length<=X*3,"uniform "+F,m.commandStr),x="3i";break;case Zi:d.command(at(B)&&B.length&&B.length%4===0&&B.length<=X*4,"uniform "+F,m.commandStr),x="4i";break;case Wi:d.command(at(B)&&B.length&&B.length%4===0&&B.length<=X*4,"uniform "+F,m.commandStr),x="4i";break}X>1?(x+="v",B=m.global.def("["+Array.prototype.slice.call(B)+"]")):B=at(B)?Array.prototype.slice.call(B):B,l(E,".uniform",x,"(",ye,",",B,");")}continue}else H=se.append(m,l)}else{if(!k(uc))continue;H=l.def(T.uniforms,"[",h.id(F),"]")}V===Gr?(d(!Array.isArray(H),"must specify a scalar prop for textures"),l("if(",H,"&&",H,'._reglType==="framebuffer"){',H,"=",H,".color[0];","}")):V===Nr&&(d(!Array.isArray(H),"must specify a scalar prop for cube maps"),l("if(",H,"&&",H,'._reglType==="framebufferCube"){',H,"=",H,".color[0];","}")),d.optional(function(){function Nt(Lt,Ki){m.assert(l,Lt,'bad data or missing for uniform "'+F+'". '+Ki)}function jn(Lt,Ki){Ki===1&&d(!Array.isArray(H),"must not specify an array type for uniform"),Nt("Array.isArray("+H+") && typeof "+H+'[0]===" '+Lt+'" || typeof '+H+'==="'+Lt+'"',"invalid type, expected "+Lt)}function $t(Lt,Ki,Ji){Array.isArray(H)?d(H.length&&H.length%Lt===0&&H.length<=Lt*Ji,"must have length of "+(Ji===1?"":"n * ")+Lt):Nt(T.isArrayLike+"("+H+")&&"+H+".length && "+H+".length % "+Lt+" === 0 && "+H+".length<="+Lt*Ji,"invalid vector, should have length of "+(Ji===1?"":"n * ")+Lt,m.commandStr)}function vc(Lt){d(!Array.isArray(H),"must not specify a value type"),Nt("typeof "+H+'==="function"&&'+H+'._reglType==="texture'+(Lt===ec?"2d":"Cube")+'"',"invalid texture type",m.commandStr)}switch(V){case Pa:jn("number",X);break;case Xi:$t(2,"number",X);break;case Hi:$t(3,"number",X);break;case Wi:$t(4,"number",X);break;case Ca:jn("number",X);break;case $i:$t(2,"number",X);break;case Ui:$t(3,"number",X);break;case ji:$t(4,"number",X);break;case ka:jn("boolean",X);break;case qi:$t(2,"boolean",X);break;case Yi:$t(3,"boolean",X);break;case Zi:$t(4,"boolean",X);break;case Dr:$t(4,"number",X);break;case Mr:$t(9,"number",X);break;case Or:$t(16,"number",X);break;case Gr:vc(ec);break;case Nr:vc(xy);break}});var Je=1;switch(V){case Gr:case Nr:var Ct=l.def(H,"._texture");l(E,".uniform1i(",ye,",",Ct,".bind());"),l.exit(Ct,".unbind();");continue;case Pa:case ka:x="1i";break;case Xi:case qi:x="2i",Je=2;break;case Hi:case Yi:x="3i",Je=3;break;case Wi:case Zi:x="4i",Je=4;break;case Ca:x="1f";break;case $i:x="2f",Je=2;break;case Ui:x="3f",Je=3;break;case ji:x="4f",Je=4;break;case Dr:x="Matrix2fv";break;case Mr:x="Matrix3fv";break;case Or:x="Matrix4fv";break}if(x.indexOf("Matrix")===-1&&X>1&&(x+="v",Je=1),x.charAt(0)==="M"){l(E,".uniform",x,"(",ye,",");var $n=Math.pow(V-Dr+2,2),mn=m.global.def("new Float32Array(",$n,")");Array.isArray(H)?l("false,(",Ot($n,function(Nt){return mn+"["+Nt+"]="+H[Nt]}),",",mn,")"):l("false,(Array.isArray(",H,")||",H," instanceof Float32Array)?",H,":(",Ot($n,function(Nt){return mn+"["+Nt+"]="+H+"["+Nt+"]"}),",",mn,")"),l(");")}else if(Je>1){for(var on=[],wn=[],Un=0;Un<Je;++Un)Array.isArray(H)?wn.push(H[Un]):wn.push(l.def(H+"["+Un+"]")),A&&on.push(l.def());A&&l("if(!",m.batchId,"||",on.map(function(Nt,jn){return Nt+"!=="+wn[jn]}).join("||"),"){",on.map(function(Nt,jn){return Nt+"="+wn[jn]+";"}).join("")),l(E,".uniform",x,"(",ye,",",wn.join(","),");"),A&&l("}")}else{if(d(!Array.isArray(H),"uniform value must not be an array"),A){var pc=l.def();l("if(!",m.batchId,"||",pc,"!==",H,"){",pc,"=",H,";")}l(E,".uniform",x,"(",ye,",",H,");"),A&&l("}")}}}function Fe(m,l,w,C){var k=m.shared,A=k.gl,T=k.draw,E=C.draw;function p(){var Te=E.elements,_e,Ie=l;return Te?((Te.contextDep&&C.contextDynamic||Te.propDep)&&(Ie=w),_e=Te.append(m,Ie),E.elementsActive&&Ie("if("+_e+")"+A+".bindBuffer("+Ea+","+_e+".buffer.buffer);")):(_e=Ie.def(),Ie(_e,"=",T,".",On,";","if(",_e,"){",A,".bindBuffer(",Ea,",",_e,".buffer.buffer);}","else if(",k.vao,".currentVAO){",_e,"=",m.shared.elements+".getElements("+k.vao,".currentVAO.elements);",W?"":"if("+_e+")"+A+".bindBuffer("+Ea+","+_e+".buffer.buffer);","}")),_e}function x(){var Te=E.count,_e,Ie=l;return Te?((Te.contextDep&&C.contextDynamic||Te.propDep)&&(Ie=w),_e=Te.append(m,Ie),d.optional(function(){Te.MISSING&&m.assert(l,"false","missing vertex count"),Te.DYNAMIC&&m.assert(Ie,_e+">=0","missing vertex count")})):(_e=Ie.def(T,".",Nn),d.optional(function(){m.assert(Ie,_e+">=0","missing vertex count")})),_e}var g=p();function L(Te){var _e=E[Te];return _e?_e.contextDep&&C.contextDynamic||_e.propDep?_e.append(m,w):_e.append(m,l):l.def(T,".",Te)}var F=L(Gn),V=L(Bi),X=x();if(typeof X=="number"){if(X===0)return}else w("if(",X,"){"),w.exit("}");var se,Re;ee&&(se=L(Vi),Re=m.instancing);var Ee=g+".type",ye=E.elements&&Sn(E.elements)&&!E.vaoActive;function H(){function Te(){w(Re,".drawElementsInstancedANGLE(",[F,X,Ee,V+"<<(("+Ee+"-"+Iu+")>>1)",se],");")}function _e(){w(Re,".drawArraysInstancedANGLE(",[F,V,X,se],");")}g&&g!=="null"?ye?Te():(w("if(",g,"){"),Te(),w("}else{"),_e(),w("}")):_e()}function B(){function Te(){w(A+".drawElements("+[F,X,Ee,V+"<<(("+Ee+"-"+Iu+")>>1)"]+");")}function _e(){w(A+".drawArrays("+[F,V,X]+");")}g&&g!=="null"?ye?Te():(w("if(",g,"){"),Te(),w("}else{"),_e(),w("}")):_e()}ee&&(typeof se!="number"||se>=0)?typeof se=="string"?(w("if(",se,">0){"),H(),w("}else if(",se,"<0){"),B(),w("}")):H():B()}function qe(m,l,w,C,k){var A=De(),T=A.proc("body",k);return d.optional(function(){A.commandStr=l.commandStr,A.command=A.link(l.commandStr)}),ee&&(A.instancing=T.def(A.shared.extensions,".angle_instanced_arrays")),m(A,T,w,C),A.compile().body}function Qe(m,l,w,C){ct(m,l),w.useVAO?w.drawVAO?l(m.shared.vao,".setVAO(",w.drawVAO.append(m,l),");"):l(m.shared.vao,".setVAO(",m.shared.vao,".targetVAO);"):(l(m.shared.vao,".setVAO(null);"),Et(m,l,w,C.attributes,function(){return!0})),Ke(m,l,w,C.uniforms,function(){return!0},!1),Fe(m,l,l,w)}function lt(m,l){var w=m.proc("draw",1);ct(m,w),vt(m,w,l.context),gt(m,w,l.framebuffer),St(m,w,l),At(m,w,l.state),Ve(m,w,l,!1,!0);var C=l.shader.progVar.append(m,w);if(w(m.shared.gl,".useProgram(",C,".program);"),l.shader.program)Qe(m,w,l,l.shader.program);else{w(m.shared.vao,".setVAO(null);");var k=m.global.def("{}"),A=w.def(C,".id"),T=w.def(k,"[",A,"]");w(m.cond(T).then(T,".call(this,a0);").else(T,"=",k,"[",A,"]=",m.link(function(E){return qe(Qe,m,l,E,1)}),"(",C,");",T,".call(this,a0);"))}Object.keys(l.state).length>0&&w(m.shared.current,".dirty=true;"),m.shared.vao&&w(m.shared.vao,".setVAO(null);")}function rn(m,l,w,C){m.batchId="a1",ct(m,l);function k(){return!0}Et(m,l,w,C.attributes,k),Ke(m,l,w,C.uniforms,k,!1),Fe(m,l,l,w)}function Vn(m,l,w,C){ct(m,l);var k=w.contextDep,A=l.def(),T="a0",E="a1",p=l.def();m.shared.props=p,m.batchId=A;var x=m.scope(),g=m.scope();l(x.entry,"for(",A,"=0;",A,"<",E,";++",A,"){",p,"=",T,"[",A,"];",g,"}",x.exit);function L(Ee){return Ee.contextDep&&k||Ee.propDep}function F(Ee){return!L(Ee)}if(w.needsContext&&vt(m,g,w.context),w.needsFramebuffer&&gt(m,g,w.framebuffer),At(m,g,w.state,L),w.profile&&L(w.profile)&&Ve(m,g,w,!1,!0),C)w.useVAO?w.drawVAO?L(w.drawVAO)?g(m.shared.vao,".setVAO(",w.drawVAO.append(m,g),");"):x(m.shared.vao,".setVAO(",w.drawVAO.append(m,x),");"):x(m.shared.vao,".setVAO(",m.shared.vao,".targetVAO);"):(x(m.shared.vao,".setVAO(null);"),Et(m,x,w,C.attributes,F),Et(m,g,w,C.attributes,L)),Ke(m,x,w,C.uniforms,F,!1),Ke(m,g,w,C.uniforms,L,!0),Fe(m,x,g,w);else{var V=m.global.def("{}"),X=w.shader.progVar.append(m,g),se=g.def(X,".id"),Re=g.def(V,"[",se,"]");g(m.shared.gl,".useProgram(",X,".program);","if(!",Re,"){",Re,"=",V,"[",se,"]=",m.link(function(Ee){return qe(rn,m,w,Ee,2)}),"(",X,");}",Re,".call(this,a0[",A,"],",A,");")}}function y(m,l){var w=m.proc("batch",2);m.batchId="0",ct(m,w);var C=!1,k=!0;Object.keys(l.context).forEach(function(V){C=C||l.context[V].propDep}),C||(vt(m,w,l.context),k=!1);var A=l.framebuffer,T=!1;A?(A.propDep?C=T=!0:A.contextDep&&C&&(T=!0),T||gt(m,w,A)):gt(m,w,null),l.state.viewport&&l.state.viewport.propDep&&(C=!0);function E(V){return V.contextDep&&C||V.propDep}St(m,w,l),At(m,w,l.state,function(V){return!E(V)}),(!l.profile||!E(l.profile))&&Ve(m,w,l,!1,"a1"),l.contextDep=C,l.needsContext=k,l.needsFramebuffer=T;var p=l.shader.progVar;if(p.contextDep&&C||p.propDep)Vn(m,w,l,null);else{var x=p.append(m,w);if(w(m.shared.gl,".useProgram(",x,".program);"),l.shader.program)Vn(m,w,l,l.shader.program);else{w(m.shared.vao,".setVAO(null);");var g=m.global.def("{}"),L=w.def(x,".id"),F=w.def(g,"[",L,"]");w(m.cond(F).then(F,".call(this,a0,a1);").else(F,"=",g,"[",L,"]=",m.link(function(V){return qe(Vn,m,l,V,2)}),"(",x,");",F,".call(this,a0,a1);"))}}Object.keys(l.state).length>0&&w(m.shared.current,".dirty=true;"),m.shared.vao&&w(m.shared.vao,".setVAO(null);")}function M(m,l){var w=m.proc("scope",3);m.batchId="a2";var C=m.shared,k=C.current;vt(m,w,l.context),l.framebuffer&&l.framebuffer.append(m,w),fc(Object.keys(l.state)).forEach(function(T){var E=l.state[T],p=E.append(m,w);at(p)?p.forEach(function(x,g){w.set(m.next[T],"["+g+"]",x)}):w.set(C.next,"."+T,p)}),Ve(m,w,l,!0,!0),[On,Bi,Nn,Vi,Gn].forEach(function(T){var E=l.draw[T];E&&w.set(C.draw,"."+T,""+E.append(m,w))}),Object.keys(l.uniforms).forEach(function(T){var E=l.uniforms[T].append(m,w);Array.isArray(E)&&(E="["+E.join()+"]"),w.set(C.uniforms,"["+h.id(T)+"]",E)}),Object.keys(l.attributes).forEach(function(T){var E=l.attributes[T].append(m,w),p=m.scopeAttrib(T);Object.keys(new P).forEach(function(x){w.set(p,"."+x,E[x])})}),l.scopeVAO&&w.set(C.vao,".targetVAO",l.scopeVAO.append(m,w));function A(T){var E=l.shader[T];E&&w.set(C.shader,"."+T,E.append(m,w))}A(zr),A(Ir),Object.keys(l.state).length>0&&(w(k,".dirty=true;"),w.exit(k,".dirty=true;")),w("a1(",m.shared.context,",a0,",m.batchId,");")}function z(m){if(!(typeof m!="object"||at(m))){for(var l=Object.keys(m),w=0;w<l.length;++w)if(Mt.isDynamic(m[l[w]]))return!0;return!1}}function xe(m,l,w){var C=l.static[w];if(!C||!z(C))return;var k=m.global,A=Object.keys(C),T=!1,E=!1,p=!1,x=m.global.def("{}");A.forEach(function(L){var F=C[L];if(Mt.isDynamic(F)){typeof F=="function"&&(F=C[L]=Mt.unbox(F));var V=Ft(F,null);T=T||V.thisDep,p=p||V.propDep,E=E||V.contextDep}else{switch(k(x,".",L,"="),typeof F){case"number":k(F);break;case"string":k('"',F,'"');break;case"object":Array.isArray(F)&&k("[",F.join(),"]");break;default:k(m.link(F));break}k(";")}});function g(L,F){A.forEach(function(V){var X=C[V];if(Mt.isDynamic(X)){var se=L.invoke(F,X);F(x,".",V,"=",se,";")}})}l.dynamic[w]=new Mt.DynamicVariable(Gi,{thisDep:T,contextDep:E,propDep:p,ref:x,append:g}),delete l.static[w]}function He(m,l,w,C,k){var A=De();A.stats=A.link(k),Object.keys(l.static).forEach(function(E){xe(A,l,E)}),vy.forEach(function(E){xe(A,m,E)});var T=mt(m,l,w,C,A);return lt(A,T),M(A,T),y(A,T),r(A.compile(),{destroy:function(){T.shader.program.destroy()}})}return{next:de,current:pe,procs:function(){var m=De(),l=m.proc("poll"),w=m.proc("refresh"),C=m.block();l(C),w(C);var k=m.shared,A=k.gl,T=k.next,E=k.current;C(E,".dirty=false;"),gt(m,l),gt(m,w,null,!0);var p;ee&&(p=m.link(ee)),_.oes_vertex_array_object&&w(m.link(_.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var x=0;x<R.maxAttributes;++x){var g=w.def(k.attributes,"[",x,"]"),L=m.cond(g,".buffer");L.then(A,".enableVertexAttribArray(",x,");",A,".bindBuffer(",ur,",",g,".buffer.buffer);",A,".vertexAttribPointer(",x,",",g,".size,",g,".type,",g,".normalized,",g,".stride,",g,".offset);").else(A,".disableVertexAttribArray(",x,");",A,".vertexAttrib4f(",x,",",g,".x,",g,".y,",g,".z,",g,".w);",g,".buffer=null;"),w(L),ee&&w(p,".vertexAttribDivisorANGLE(",x,",",g,".divisor);")}return w(m.shared.vao,".currentVAO=null;",m.shared.vao,".setVAO(",m.shared.vao,".targetVAO);"),Object.keys(j).forEach(function(F){var V=j[F],X=C.def(T,".",F),se=m.block();se("if(",X,"){",A,".enable(",V,")}else{",A,".disable(",V,")}",E,".",F,"=",X,";"),w(se),l("if(",X,"!==",E,".",F,"){",se,"}")}),Object.keys($).forEach(function(F){var V=$[F],X=pe[F],se,Re,Ee=m.block();if(Ee(A,".",V,"("),at(X)){var ye=X.length;se=m.global.def(T,".",F),Re=m.global.def(E,".",F),Ee(Ot(ye,function(H){return se+"["+H+"]"}),");",Ot(ye,function(H){return Re+"["+H+"]="+se+"["+H+"];"}).join("")),l("if(",Ot(ye,function(H){return se+"["+H+"]!=="+Re+"["+H+"]"}).join("||"),"){",Ee,"}")}else se=C.def(T,".",F),Re=C.def(E,".",F),Ee(se,");",E,".",F,"=",se,";"),l("if(",se,"!==",Re,"){",Ee,"}");w(Ee)}),m.compile()}(),compile:He}}function Dy(){return{vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}var My=34918,Oy=34919,cc=35007,Gy=function(a,h){if(!h.ext_disjoint_timer_query)return null;var _=[];function R(){return _.pop()||h.ext_disjoint_timer_query.createQueryEXT()}function U(ee){_.push(ee)}var I=[];function N(ee){var ge=R();h.ext_disjoint_timer_query.beginQueryEXT(cc,ge),I.push(ge),K(I.length-1,I.length,ee)}function Q(){h.ext_disjoint_timer_query.endQueryEXT(cc)}function Y(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var ne=[];function ie(){return ne.pop()||new Y}function re(ee){ne.push(ee)}var fe=[];function K(ee,ge,W){var pe=ie();pe.startQueryIndex=ee,pe.endQueryIndex=ge,pe.sum=0,pe.stats=W,fe.push(pe)}var te=[],P=[];function O(){var ee,ge,W=I.length;if(W!==0){P.length=Math.max(P.length,W+1),te.length=Math.max(te.length,W+1),te[0]=0,P[0]=0;var pe=0;for(ee=0,ge=0;ge<I.length;++ge){var de=I[ge];h.ext_disjoint_timer_query.getQueryObjectEXT(de,Oy)?(pe+=h.ext_disjoint_timer_query.getQueryObjectEXT(de,My),U(de)):I[ee++]=de,te[ge+1]=pe,P[ge+1]=ee}for(I.length=ee,ee=0,ge=0;ge<fe.length;++ge){var Pe=fe[ge],j=Pe.startQueryIndex,$=Pe.endQueryIndex;Pe.sum+=te[$]-te[j];var be=P[j],ue=P[$];ue===be?(Pe.stats.gpuTime+=Pe.sum/1e6,re(Pe)):(Pe.startQueryIndex=be,Pe.endQueryIndex=ue,fe[ee++]=Pe)}fe.length=ee}}return{beginQuery:N,endQuery:Q,pushScopeStats:K,update:O,getNumPendingQueries:function(){return I.length},clear:function(){_.push.apply(_,I);for(var ee=0;ee<_.length;ee++)h.ext_disjoint_timer_query.deleteQueryEXT(_[ee]);I.length=0,_.length=0},restore:function(){I.length=0,_.length=0}}},Ny=16384,By=256,Vy=1024,$y=34962,lc="webglcontextlost",hc="webglcontextrestored",dc=1,Uy=2,jy=3;function mc(a,h){for(var _=0;_<a.length;++_)if(a[_]===h)return _;return-1}function Xy(a){var h=U0(a);if(!h)return null;var _=h.gl,R=_.getContextAttributes(),U=_.isContextLost(),I=j0(_,h);if(!I)return null;var N=G0(),Q=Dy(),Y=I.extensions,ne=Gy(_,Y),ie=Sf(),re=_.drawingBufferWidth,fe=_.drawingBufferHeight,K={tick:0,time:0,viewportWidth:re,viewportHeight:fe,framebufferWidth:re,framebufferHeight:fe,drawingBufferWidth:re,drawingBufferHeight:fe,pixelRatio:h.pixelRatio},te={},P={elements:null,primitive:4,count:-1,offset:0,instances:-1},O=Lv(_,Y),ee=Wv(_,Q,h,pe),ge=og(_,Y,ee,Q),W=oy(_,Y,O,Q,ee,ge,P);function pe(Fe){return W.destroyBuffer(Fe)}var de=uy(_,N,Q,h),Pe=Mg(_,Y,O,function(){be.procs.poll()},K,Q,h),j=Og(_,Y,O,Q,h),$=ry(_,Y,O,Pe,j,Q),be=Ry(_,N,Y,O,ee,ge,Pe,$,te,W,de,P,K,ne,h),ue=hy(_,$,be.procs.poll,K,R,Y,O),J=be.next,ce=_.canvas,he=[],Oe=[],De=[],me=[h.onDestroy],ve=null;function ze(){if(he.length===0){ne&&ne.update(),ve=null;return}ve=Mo.next(ze),At();for(var Fe=he.length-1;Fe>=0;--Fe){var qe=he[Fe];qe&&qe(K,null,0)}_.flush(),ne&&ne.update()}function Ge(){!ve&&he.length>0&&(ve=Mo.next(ze))}function We(){ve&&(Mo.cancel(ze),ve=null)}function st(Fe){Fe.preventDefault(),U=!0,We(),Oe.forEach(function(qe){qe()})}function ft(Fe){_.getError(),U=!1,I.restore(),de.restore(),ee.restore(),Pe.restore(),j.restore(),$.restore(),W.restore(),ne&&ne.restore(),be.procs.refresh(),Ge(),De.forEach(function(qe){qe()})}ce&&(ce.addEventListener(lc,st,!1),ce.addEventListener(hc,ft,!1));function Ze(){he.length=0,We(),ce&&(ce.removeEventListener(lc,st),ce.removeEventListener(hc,ft)),de.clear(),$.clear(),j.clear(),W.clear(),Pe.clear(),ge.clear(),ee.clear(),ne&&ne.clear(),me.forEach(function(Fe){Fe()})}function pt(Fe){d(!!Fe,"invalid args to regl({...})"),d.type(Fe,"object","invalid args to regl({...})");function qe(k){var A=r({},k);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 T(E){if(E in A){var p=A[E];delete A[E],Object.keys(p).forEach(function(x){A[E+"."+x]=p[x]})}}return T("blend"),T("depth"),T("cull"),T("stencil"),T("polygonOffset"),T("scissor"),T("sample"),"vao"in k&&(A.vao=k.vao),A}function Qe(k,A){var T={},E={};return Object.keys(k).forEach(function(p){var x=k[p];if(Mt.isDynamic(x)){E[p]=Mt.unbox(x,p);return}else if(A&&Array.isArray(x)){for(var g=0;g<x.length;++g)if(Mt.isDynamic(x[g])){E[p]=Mt.unbox(x,p);return}}T[p]=x}),{dynamic:E,static:T}}var lt=Qe(Fe.context||{},!0),rn=Qe(Fe.uniforms||{},!0),Vn=Qe(Fe.attributes||{},!1),y=Qe(qe(Fe),!1),M={gpuTime:0,cpuTime:0,count:0},z=be.compile(y,Vn,rn,lt,M),xe=z.draw,He=z.batch,m=z.scope,l=[];function w(k){for(;l.length<k;)l.push(null);return l}function C(k,A){var T;if(U&&d.raise("context lost"),typeof k=="function")return m.call(this,null,k,0);if(typeof A=="function")if(typeof k=="number")for(T=0;T<k;++T)m.call(this,null,A,T);else if(Array.isArray(k))for(T=0;T<k.length;++T)m.call(this,k[T],A,T);else return m.call(this,k,A,0);else if(typeof k=="number"){if(k>0)return He.call(this,w(k|0),k|0)}else if(Array.isArray(k)){if(k.length)return He.call(this,k,k.length)}else return xe.call(this,k)}return r(C,{stats:M,destroy:function(){z.destroy()}})}var ot=$.setFBO=pt({framebuffer:Mt.define.call(null,dc,"framebuffer")});function mt(Fe,qe){var Qe=0;be.procs.poll();var lt=qe.color;lt&&(_.clearColor(+lt[0]||0,+lt[1]||0,+lt[2]||0,+lt[3]||0),Qe|=Ny),"depth"in qe&&(_.clearDepth(+qe.depth),Qe|=By),"stencil"in qe&&(_.clearStencil(qe.stencil|0),Qe|=Vy),d(!!Qe,"called regl.clear with no buffer specified"),_.clear(Qe)}function vt(Fe){if(d(typeof Fe=="object"&&Fe,"regl.clear() takes an object as input"),"framebuffer"in Fe)if(Fe.framebuffer&&Fe.framebuffer_reglType==="framebufferCube")for(var qe=0;qe<6;++qe)ot(r({framebuffer:Fe.framebuffer.faces[qe]},Fe),mt);else ot(Fe,mt);else mt(null,Fe)}function gt(Fe){d.type(Fe,"function","regl.frame() callback must be a function"),he.push(Fe);function qe(){var Qe=mc(he,Fe);d(Qe>=0,"cannot cancel a frame twice");function lt(){var rn=mc(he,lt);he[rn]=he[he.length-1],he.length-=1,he.length<=0&&We()}he[Qe]=lt}return Ge(),{cancel:qe}}function St(){var Fe=J.viewport,qe=J.scissor_box;Fe[0]=Fe[1]=qe[0]=qe[1]=0,K.viewportWidth=K.framebufferWidth=K.drawingBufferWidth=Fe[2]=qe[2]=_.drawingBufferWidth,K.viewportHeight=K.framebufferHeight=K.drawingBufferHeight=Fe[3]=qe[3]=_.drawingBufferHeight}function At(){K.tick+=1,K.time=Ve(),St(),be.procs.poll()}function ct(){Pe.refresh(),St(),be.procs.refresh(),ne&&ne.update()}function Ve(){return(Sf()-ie)/1e3}ct();function Et(Fe,qe){d.type(qe,"function","listener callback must be a function");var Qe;switch(Fe){case"frame":return gt(qe);case"lost":Qe=Oe;break;case"restore":Qe=De;break;case"destroy":Qe=me;break;default:d.raise("invalid event, must be one of frame,lost,restore,destroy")}return Qe.push(qe),{cancel:function(){for(var lt=0;lt<Qe.length;++lt)if(Qe[lt]===qe){Qe[lt]=Qe[Qe.length-1],Qe.pop();return}}}}var Ke=r(pt,{clear:vt,prop:Mt.define.bind(null,dc),context:Mt.define.bind(null,Uy),this:Mt.define.bind(null,jy),draw:pt({}),buffer:function(Fe){return ee.create(Fe,$y,!1,!1)},elements:function(Fe){return ge.create(Fe,!1)},texture:Pe.create2D,cube:Pe.createCube,renderbuffer:j.create,framebuffer:$.create,framebufferCube:$.createCube,vao:W.createVAO,attributes:R,frame:gt,on:Et,limits:O,hasExtension:function(Fe){return O.extensions.indexOf(Fe.toLowerCase())>=0},read:ue,destroy:Ze,_gl:_,_refresh:ct,poll:function(){At(),ne&&ne.update()},now:Ve,stats:Q});return h.onDone(null,Ke),Ke}return Xy})}(oi)),oi.exports}var Wd=Hd();const qd=go(Wd),Yd="#b3b3b3",Zd=void 0,Qd=void 0,Kd=4,Jd="#666666",em=.1,tm=1,nm="#222222",$e={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,arrowSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,arrowLinks:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",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:!0,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0},rm=.7,im=.95,om=3,_s=t=>typeof t=="function",yo=t=>Array.isArray(t),Ss=t=>t instanceof Object,ws=t=>t instanceof Object?t.constructor.name!=="Function"&&t.constructor.name!=="Object":!1,xo=t=>Ss(t)&&!yo(t)&&!_s(t)&&!ws(t);function vn(t){let e;if(yo(t))e=t;else{const n=pn(t),r=n==null?void 0:n.rgb();e=[(r==null?void 0:r.r)||0,(r==null?void 0:r.g)||0,(r==null?void 0:r.b)||0,(n==null?void 0:n.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function Ts(t,e,n){return .2126*t+.7152*e+.0722*n}function un(t,e){let n=new Float32Array;return t({framebuffer:e})(()=>{n=t.read()}),n}function As(t,e,n){return Math.min(Math.max(t,e),n)}function Ht(t){return t!=null&&!Number.isNaN(t)}class am{constructor(){this.enableSimulation=$e.enableSimulation,this.backgroundColor=nm,this.spaceSize=$e.spaceSize,this.pointColor=Yd,this.pointGreyoutOpacity=Zd,this.pointGreyoutColor=Qd,this.pointSize=Kd,this.pointSizeScale=$e.pointSizeScale,this.hoveredPointCursor=$e.hoveredPointCursor,this.renderHoveredPointRing=$e.renderHoveredPointRing,this.hoveredPointRingColor=$e.hoveredPointRingColor,this.focusedPointRingColor=$e.focusedPointRingColor,this.focusedPointIndex=$e.focusedPointIndex,this.linkColor=Jd,this.linkGreyoutOpacity=em,this.linkWidth=tm,this.linkWidthScale=$e.linkWidthScale,this.renderLinks=$e.renderLinks,this.curvedLinks=$e.curvedLinks,this.curvedLinkSegments=$e.curvedLinkSegments,this.curvedLinkWeight=$e.curvedLinkWeight,this.curvedLinkControlPointDistance=$e.curvedLinkControlPointDistance,this.linkArrows=$e.arrowLinks,this.linkArrowsSizeScale=$e.arrowSizeScale,this.linkVisibilityDistanceRange=$e.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=$e.linkVisibilityMinTransparency,this.useClassicQuadtree=$e.useClassicQuadtree,this.simulationDecay=$e.simulation.decay,this.simulationGravity=$e.simulation.gravity,this.simulationCenter=$e.simulation.center,this.simulationRepulsion=$e.simulation.repulsion,this.simulationRepulsionTheta=$e.simulation.repulsionTheta,this.simulationRepulsionQuadtreeLevels=$e.simulation.repulsionQuadtreeLevels,this.simulationLinkSpring=$e.simulation.linkSpring,this.simulationLinkDistance=$e.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=$e.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=$e.simulation.repulsionFromMouse,this.simulationFriction=$e.simulation.friction,this.simulationCluster=$e.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=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=$e.showFPSMonitor,this.pixelRatio=$e.pixelRatio,this.scalePointsOnZoom=$e.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=$e.enableZoom,this.enableSimulationDuringZoom=$e.enableSimulationDuringZoom,this.enableDrag=$e.enableDrag,this.fitViewOnInit=$e.fitViewOnInit,this.fitViewDelay=$e.fitViewDelay,this.fitViewPadding=$e.fitViewPadding,this.fitViewDuration=$e.fitViewDuration,this.fitViewByPointsInRect=void 0,this.randomSeed=void 0,this.pointSamplingDistance=$e.pointSamplingDistance,this.attribution=$e.attribution,this.rescalePositions=$e.rescalePositions}init(e){Object.keys(e).forEach(n=>{this.deepMergeConfig(this.getConfig(),e,n)})}deepMergeConfig(e,n,r){xo(e[r])&&xo(n[r])?Object.keys(n[r]).forEach(i=>{this.deepMergeConfig(e[r],n[r],i)}):e[r]=n[r]}getConfig(){return this}}class cn{constructor(e,n,r,i,o){this.reglInstance=e,this.config=n,this.store=r,this.data=i,o&&(this.points=o)}}var sm=`#ifdef GL_ES
8
+ `),K=Function.apply(null,h.concat(fe));return K.apply(null,_)}return{global:Q,link:R,block:U,proc:ne,scope:I,cond:G,compile:ie}}var or="xyzw".split(""),Iu=5121,ar=1,ca=2,la=0,ha=1,da=2,ma=3,Ni=4,Ru=5,Du=6,Mu="dither",Ou="blend.enable",Nu="blend.color",pa="blend.equation",va="blend.func",Gu="depth.enable",Bu="depth.func",Vu="depth.range",$u="depth.mask",ga="colorMask",Uu="cull.enable",ju="cull.face",ya="frontFace",xa="lineWidth",Xu="polygonOffset.enable",ba="polygonOffset.offset",Hu="sample.alpha",qu="sample.enable",_a="sample.coverage",Wu="stencil.enable",Yu="stencil.mask",Sa="stencil.func",wa="stencil.opFront",Fr="stencil.opBack",Zu="scissor.enable",Gi="scissor.box",dn="viewport",Lr="profile",Mn="framebuffer",zr="vert",Ir="frag",On="elements",Nn="primitive",Gn="count",Bi="offset",Vi="instances",Rr="vao",Ta="Width",Aa="Height",sr=Mn+Ta,fr=Mn+Aa,my=dn+Ta,py=dn+Aa,Qu="drawingBuffer",Ku=Qu+Ta,Ju=Qu+Aa,vy=[va,pa,Sa,wa,Fr,_a,dn,Gi,ba],ur=34962,Ea=34963,gy=35632,yy=35633,ec=3553,xy=34067,by=2884,_y=3042,Sy=3024,wy=2960,Ty=2929,Ay=3089,Ey=32823,Cy=32926,Py=32928,Ca=5126,$i=35664,Ui=35665,ji=35666,Pa=5124,Xi=35667,Hi=35668,qi=35669,ka=35670,Wi=35671,Yi=35672,Zi=35673,Dr=35674,Mr=35675,Or=35676,Nr=35678,Gr=35680,Fa=4,Br=1028,Bn=1029,tc=2304,La=2305,ky=32775,Fy=32776,Ly=519,bn=7680,nc=0,rc=1,ic=32774,zy=513,oc=36160,Iy=36064,nn={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},ac=["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"],cr={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},_n={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},sc={frag:gy,vert:yy},za={cw:tc,ccw:La};function Qi(a){return Array.isArray(a)||n(a)||Zt(a)}function fc(a){return a.sort(function(h,_){return h===dn?-1:_===dn?1:h<_?-1:1})}function xt(a,h,_,R){this.thisDep=a,this.contextDep=h,this.propDep=_,this.append=R}function Sn(a){return a&&!(a.thisDep||a.contextDep||a.propDep)}function dt(a){return new xt(!1,!1,!1,a)}function Ft(a,h){var _=a.type;if(_===la){var R=a.data.length;return new xt(!0,R>=1,R>=2,h)}else if(_===Ni){var U=a.data;return new xt(U.thisDep,U.contextDep,U.propDep,h)}else{if(_===Ru)return new xt(!1,!1,!1,h);if(_===Du){for(var I=!1,G=!1,Q=!1,Y=0;Y<a.data.length;++Y){var ne=a.data[Y];if(ne.type===ha)Q=!0;else if(ne.type===da)G=!0;else if(ne.type===ma)I=!0;else if(ne.type===la){I=!0;var ie=ne.data;ie>=1&&(G=!0),ie>=2&&(Q=!0)}else ne.type===Ni&&(I=I||ne.data.thisDep,G=G||ne.data.contextDep,Q=Q||ne.data.propDep)}return new xt(I,G,Q,h)}else return new xt(_===ma,_===da,_===ha,h)}}var uc=new xt(!1,!1,!1,function(){});function Ry(a,h,_,R,U,I,G,Q,Y,ne,ie,re,fe,K,te){var P=ne.Record,O={add:32774,subtract:32778,"reverse subtract":32779};_.ext_blend_minmax&&(O.min=ky,O.max=Fy);var ee=_.angle_instanced_arrays,ge=_.webgl_draw_buffers,q=_.oes_vertex_array_object,pe={dirty:!0,profile:te.profile},de={},Pe=[],j={},$={};function be(m){return m.replace(".","_")}function ue(m,l,w){var C=be(m);Pe.push(m),de[C]=pe[C]=!!w,j[C]=l}function J(m,l,w){var C=be(m);Pe.push(m),Array.isArray(w)?(pe[C]=w.slice(),de[C]=w.slice()):pe[C]=de[C]=w,$[C]=l}ue(Mu,Sy),ue(Ou,_y),J(Nu,"blendColor",[0,0,0,0]),J(pa,"blendEquationSeparate",[ic,ic]),J(va,"blendFuncSeparate",[rc,nc,rc,nc]),ue(Gu,Ty,!0),J(Bu,"depthFunc",zy),J(Vu,"depthRange",[0,1]),J($u,"depthMask",!0),J(ga,ga,[!0,!0,!0,!0]),ue(Uu,by),J(ju,"cullFace",Bn),J(ya,ya,La),J(xa,xa,1),ue(Xu,Ey),J(ba,"polygonOffset",[0,0]),ue(Hu,Cy),ue(qu,Py),J(_a,"sampleCoverage",[1,!1]),ue(Wu,wy),J(Yu,"stencilMask",-1),J(Sa,"stencilFunc",[Ly,0,-1]),J(wa,"stencilOpSeparate",[Br,bn,bn,bn]),J(Fr,"stencilOpSeparate",[Bn,bn,bn,bn]),ue(Zu,Ay),J(Gi,"scissor",[0,0,a.drawingBufferWidth,a.drawingBufferHeight]),J(dn,dn,[0,0,a.drawingBufferWidth,a.drawingBufferHeight]);var ce={gl:a,context:fe,strings:h,next:de,current:pe,draw:re,elements:I,buffer:U,shader:ie,attributes:ne.state,vao:ne,uniforms:Y,framebuffer:Q,extensions:_,timer:K,isBufferArgs:Qi},he={primTypes:yn,compareFuncs:cr,blendFuncs:nn,blendEquations:O,stencilOps:_n,glTypes:Ln,orientationType:za};d.optional(function(){ce.isArrayLike=at}),ge&&(he.backBuffer=[Bn],he.drawBuffer=Ot(R.maxDrawbuffers,function(m){return m===0?[0]:Ot(m,function(l){return Iy+l})}));var Oe=0;function De(){var m=dy(),l=m.link,w=m.global;m.id=Oe++,m.batchId="0";var C=l(ce),k=m.shared={props:"a0"};Object.keys(ce).forEach(function(x){k[x]=w.def(C,".",x)}),d.optional(function(){m.CHECK=l(d),m.commandStr=d.guessCommand(),m.command=l(m.commandStr),m.assert=function(x,g,L){x("if(!(",g,"))",this.CHECK,".commandRaise(",l(L),",",this.command,");")},he.invalidBlendCombinations=ac});var A=m.next={},T=m.current={};Object.keys($).forEach(function(x){Array.isArray(pe[x])&&(A[x]=w.def(k.next,".",x),T[x]=w.def(k.current,".",x))});var E=m.constants={};Object.keys(he).forEach(function(x){E[x]=w.def(JSON.stringify(he[x]))}),m.invoke=function(x,g){switch(g.type){case la:var L=["this",k.context,k.props,m.batchId];return x.def(l(g.data),".call(",L.slice(0,Math.max(g.data.length+1,4)),")");case ha:return x.def(k.props,g.data);case da:return x.def(k.context,g.data);case ma:return x.def("this",g.data);case Ni:return g.data.append(m,x),g.data.ref;case Ru:return g.data.toString();case Du:return g.data.map(function(F){return m.invoke(x,F)})}},m.attribCache={};var p={};return m.scopeAttrib=function(x){var g=h.id(x);if(g in p)return p[g];var L=ne.scope[g];L||(L=ne.scope[g]=new P);var F=p[g]=l(L);return F},m}function me(m){var l=m.static,w=m.dynamic,C;if(Lr in l){var k=!!l[Lr];C=dt(function(T,E){return k}),C.enable=k}else if(Lr in w){var A=w[Lr];C=Ft(A,function(T,E){return T.invoke(E,A)})}return C}function ve(m,l){var w=m.static,C=m.dynamic;if(Mn in w){var k=w[Mn];return k?(k=Q.getFramebuffer(k),d.command(k,"invalid framebuffer object"),dt(function(T,E){var p=T.link(k),x=T.shared;E.set(x.framebuffer,".next",p);var g=x.context;return E.set(g,"."+sr,p+".width"),E.set(g,"."+fr,p+".height"),p})):dt(function(T,E){var p=T.shared;E.set(p.framebuffer,".next","null");var x=p.context;return E.set(x,"."+sr,x+"."+Ku),E.set(x,"."+fr,x+"."+Ju),"null"})}else if(Mn in C){var A=C[Mn];return Ft(A,function(T,E){var p=T.invoke(E,A),x=T.shared,g=x.framebuffer,L=E.def(g,".getFramebuffer(",p,")");d.optional(function(){T.assert(E,"!"+p+"||"+L,"invalid framebuffer object")}),E.set(g,".next",L);var F=x.context;return E.set(F,"."+sr,L+"?"+L+".width:"+F+"."+Ku),E.set(F,"."+fr,L+"?"+L+".height:"+F+"."+Ju),L})}else return null}function ze(m,l,w){var C=m.static,k=m.dynamic;function A(p){if(p in C){var x=C[p];d.commandType(x,"object","invalid "+p,w.commandStr);var g=!0,L=x.x|0,F=x.y|0,V,X;return"width"in x?(V=x.width|0,d.command(V>=0,"invalid "+p,w.commandStr)):g=!1,"height"in x?(X=x.height|0,d.command(X>=0,"invalid "+p,w.commandStr)):g=!1,new xt(!g&&l&&l.thisDep,!g&&l&&l.contextDep,!g&&l&&l.propDep,function(Ee,ye){var H=Ee.shared.context,B=V;"width"in x||(B=ye.def(H,".",sr,"-",L));var Te=X;return"height"in x||(Te=ye.def(H,".",fr,"-",F)),[L,F,B,Te]})}else if(p in k){var se=k[p],Re=Ft(se,function(Ee,ye){var H=Ee.invoke(ye,se);d.optional(function(){Ee.assert(ye,H+"&&typeof "+H+'==="object"',"invalid "+p)});var B=Ee.shared.context,Te=ye.def(H,".x|0"),_e=ye.def(H,".y|0"),Ie=ye.def('"width" in ',H,"?",H,".width|0:","(",B,".",sr,"-",Te,")"),Je=ye.def('"height" in ',H,"?",H,".height|0:","(",B,".",fr,"-",_e,")");return d.optional(function(){Ee.assert(ye,Ie+">=0&&"+Je+">=0","invalid "+p)}),[Te,_e,Ie,Je]});return l&&(Re.thisDep=Re.thisDep||l.thisDep,Re.contextDep=Re.contextDep||l.contextDep,Re.propDep=Re.propDep||l.propDep),Re}else return l?new xt(l.thisDep,l.contextDep,l.propDep,function(Ee,ye){var H=Ee.shared.context;return[0,0,ye.def(H,".",sr),ye.def(H,".",fr)]}):null}var T=A(dn);if(T){var E=T;T=new xt(T.thisDep,T.contextDep,T.propDep,function(p,x){var g=E.append(p,x),L=p.shared.context;return x.set(L,"."+my,g[2]),x.set(L,"."+py,g[3]),g})}return{viewport:T,scissor_box:A(Gi)}}function Ne(m,l){var w=m.static,C=typeof w[Ir]=="string"&&typeof w[zr]=="string";if(C){if(Object.keys(l.dynamic).length>0)return null;var k=l.static,A=Object.keys(k);if(A.length>0&&typeof k[A[0]]=="number"){for(var T=[],E=0;E<A.length;++E)d(typeof k[A[E]]=="number","must specify all vertex attribute locations when using vaos"),T.push([k[A[E]]|0,A[E]]);return T}}return null}function qe(m,l,w){var C=m.static,k=m.dynamic;function A(g){if(g in C){var L=h.id(C[g]);d.optional(function(){ie.shader(sc[g],L,d.guessCommand())});var F=dt(function(){return L});return F.id=L,F}else if(g in k){var V=k[g];return Ft(V,function(X,se){var Re=X.invoke(se,V),Ee=se.def(X.shared.strings,".id(",Re,")");return d.optional(function(){se(X.shared.shader,".shader(",sc[g],",",Ee,",",X.command,");")}),Ee})}return null}var T=A(Ir),E=A(zr),p=null,x;return Sn(T)&&Sn(E)?(p=ie.program(E.id,T.id,null,w),x=dt(function(g,L){return g.link(p)})):x=new xt(T&&T.thisDep||E&&E.thisDep,T&&T.contextDep||E&&E.contextDep,T&&T.propDep||E&&E.propDep,function(g,L){var F=g.shared.shader,V;T?V=T.append(g,L):V=L.def(F,".",Ir);var X;E?X=E.append(g,L):X=L.def(F,".",zr);var se=F+".program("+X+","+V;return d.optional(function(){se+=","+g.command}),L.def(se+")")}),{frag:T,vert:E,progVar:x,program:p}}function st(m,l){var w=m.static,C=m.dynamic,k={},A=!1;function T(){if(Rr in w){var ye=w[Rr];return ye!==null&&ne.getVAO(ye)===null&&(ye=ne.createVAO(ye)),A=!0,k.vao=ye,dt(function(B){var Te=ne.getVAO(ye);return Te?B.link(Te):"null"})}else if(Rr in C){A=!0;var H=C[Rr];return Ft(H,function(B,Te){var _e=B.invoke(Te,H);return Te.def(B.shared.vao+".getVAO("+_e+")")})}return null}var E=T(),p=!1;function x(){if(On in w){var ye=w[On];if(k.elements=ye,Qi(ye)){var H=k.elements=I.create(ye,!0);ye=I.getElements(H),p=!0}else ye&&(ye=I.getElements(ye),p=!0,d.command(ye,"invalid elements",l.commandStr));var B=dt(function(_e,Ie){if(ye){var Je=_e.link(ye);return _e.ELEMENTS=Je,Je}return _e.ELEMENTS=null,null});return B.value=ye,B}else if(On in C){p=!0;var Te=C[On];return Ft(Te,function(_e,Ie){var Je=_e.shared,Ct=Je.isBufferArgs,$n=Je.elements,mn=_e.invoke(Ie,Te),on=Ie.def("null"),wn=Ie.def(Ct,"(",mn,")"),Un=_e.cond(wn).then(on,"=",$n,".createStream(",mn,");").else(on,"=",$n,".getElements(",mn,");");return d.optional(function(){_e.assert(Un.else,"!"+mn+"||"+on,"invalid elements")}),Ie.entry(Un),Ie.exit(_e.cond(wn).then($n,".destroyStream(",on,");")),_e.ELEMENTS=on,on})}else if(A)return new xt(E.thisDep,E.contextDep,E.propDep,function(_e,Ie){return Ie.def(_e.shared.vao+".currentVAO?"+_e.shared.elements+".getElements("+_e.shared.vao+".currentVAO.elements):null")});return null}var g=x();function L(){if(Nn in w){var ye=w[Nn];return k.primitive=ye,d.commandParameter(ye,yn,"invalid primitve",l.commandStr),dt(function(B,Te){return yn[ye]})}else if(Nn in C){var H=C[Nn];return Ft(H,function(B,Te){var _e=B.constants.primTypes,Ie=B.invoke(Te,H);return d.optional(function(){B.assert(Te,Ie+" in "+_e,"invalid primitive, must be one of "+Object.keys(yn))}),Te.def(_e,"[",Ie,"]")})}else{if(p)return Sn(g)?g.value?dt(function(B,Te){return Te.def(B.ELEMENTS,".primType")}):dt(function(){return Fa}):new xt(g.thisDep,g.contextDep,g.propDep,function(B,Te){var _e=B.ELEMENTS;return Te.def(_e,"?",_e,".primType:",Fa)});if(A)return new xt(E.thisDep,E.contextDep,E.propDep,function(B,Te){return Te.def(B.shared.vao+".currentVAO?"+B.shared.vao+".currentVAO.primitive:"+Fa)})}return null}function F(ye,H){if(ye in w){var B=w[ye]|0;return H?k.offset=B:k.instances=B,d.command(!H||B>=0,"invalid "+ye,l.commandStr),dt(function(_e,Ie){return H&&(_e.OFFSET=B),B})}else if(ye in C){var Te=C[ye];return Ft(Te,function(_e,Ie){var Je=_e.invoke(Ie,Te);return H&&(_e.OFFSET=Je,d.optional(function(){_e.assert(Ie,Je+">=0","invalid "+ye)})),Je})}else if(H){if(p)return dt(function(_e,Ie){return _e.OFFSET=0,0});if(A)return new xt(E.thisDep,E.contextDep,E.propDep,function(_e,Ie){return Ie.def(_e.shared.vao+".currentVAO?"+_e.shared.vao+".currentVAO.offset:0")})}else if(A)return new xt(E.thisDep,E.contextDep,E.propDep,function(_e,Ie){return Ie.def(_e.shared.vao+".currentVAO?"+_e.shared.vao+".currentVAO.instances:-1")});return null}var V=F(Bi,!0);function X(){if(Gn in w){var ye=w[Gn]|0;return k.count=ye,d.command(typeof ye=="number"&&ye>=0,"invalid vertex count",l.commandStr),dt(function(){return ye})}else if(Gn in C){var H=C[Gn];return Ft(H,function(Ie,Je){var Ct=Ie.invoke(Je,H);return d.optional(function(){Ie.assert(Je,"typeof "+Ct+'==="number"&&'+Ct+">=0&&"+Ct+"===("+Ct+"|0)","invalid vertex count")}),Ct})}else if(p)if(Sn(g)){if(g)return V?new xt(V.thisDep,V.contextDep,V.propDep,function(Ie,Je){var Ct=Je.def(Ie.ELEMENTS,".vertCount-",Ie.OFFSET);return d.optional(function(){Ie.assert(Je,Ct+">=0","invalid vertex offset/element buffer too small")}),Ct}):dt(function(Ie,Je){return Je.def(Ie.ELEMENTS,".vertCount")});var B=dt(function(){return-1});return d.optional(function(){B.MISSING=!0}),B}else{var Te=new xt(g.thisDep||V.thisDep,g.contextDep||V.contextDep,g.propDep||V.propDep,function(Ie,Je){var Ct=Ie.ELEMENTS;return Ie.OFFSET?Je.def(Ct,"?",Ct,".vertCount-",Ie.OFFSET,":-1"):Je.def(Ct,"?",Ct,".vertCount:-1")});return d.optional(function(){Te.DYNAMIC=!0}),Te}else if(A){var _e=new xt(E.thisDep,E.contextDep,E.propDep,function(Ie,Je){return Je.def(Ie.shared.vao,".currentVAO?",Ie.shared.vao,".currentVAO.count:-1")});return _e}return null}var se=L(),Re=X(),Ee=F(Vi,!1);return{elements:g,primitive:se,count:Re,instances:Ee,offset:V,vao:E,vaoActive:A,elementsActive:p,static:k}}function ft(m,l){var w=m.static,C=m.dynamic,k={};return Pe.forEach(function(A){var T=be(A);function E(p,x){if(A in w){var g=p(w[A]);k[T]=dt(function(){return g})}else if(A in C){var L=C[A];k[T]=Ft(L,function(F,V){return x(F,V,F.invoke(V,L))})}}switch(A){case Uu:case Ou:case Mu:case Wu:case Gu:case Zu:case Xu:case Hu:case qu:case $u:return E(function(p){return d.commandType(p,"boolean",A,l.commandStr),p},function(p,x,g){return d.optional(function(){p.assert(x,"typeof "+g+'==="boolean"',"invalid flag "+A,p.commandStr)}),g});case Bu:return E(function(p){return d.commandParameter(p,cr,"invalid "+A,l.commandStr),cr[p]},function(p,x,g){var L=p.constants.compareFuncs;return d.optional(function(){p.assert(x,g+" in "+L,"invalid "+A+", must be one of "+Object.keys(cr))}),x.def(L,"[",g,"]")});case Vu:return E(function(p){return d.command(at(p)&&p.length===2&&typeof p[0]=="number"&&typeof p[1]=="number"&&p[0]<=p[1],"depth range is 2d array",l.commandStr),p},function(p,x,g){d.optional(function(){p.assert(x,p.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 L=x.def("+",g,"[0]"),F=x.def("+",g,"[1]");return[L,F]});case va:return E(function(p){d.commandType(p,"object","blend.func",l.commandStr);var x="srcRGB"in p?p.srcRGB:p.src,g="srcAlpha"in p?p.srcAlpha:p.src,L="dstRGB"in p?p.dstRGB:p.dst,F="dstAlpha"in p?p.dstAlpha:p.dst;return d.commandParameter(x,nn,T+".srcRGB",l.commandStr),d.commandParameter(g,nn,T+".srcAlpha",l.commandStr),d.commandParameter(L,nn,T+".dstRGB",l.commandStr),d.commandParameter(F,nn,T+".dstAlpha",l.commandStr),d.command(ac.indexOf(x+", "+L)===-1,"unallowed blending combination (srcRGB, dstRGB) = ("+x+", "+L+")",l.commandStr),[nn[x],nn[L],nn[g],nn[F]]},function(p,x,g){var L=p.constants.blendFuncs;d.optional(function(){p.assert(x,g+"&&typeof "+g+'==="object"',"invalid blend func, must be an object")});function F(H,B){var Te=x.def('"',H,B,'" in ',g,"?",g,".",H,B,":",g,".",H);return d.optional(function(){p.assert(x,Te+" in "+L,"invalid "+A+"."+H+B+", must be one of "+Object.keys(nn))}),Te}var V=F("src","RGB"),X=F("dst","RGB");d.optional(function(){var H=p.constants.invalidBlendCombinations;p.assert(x,H+".indexOf("+V+'+", "+'+X+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var se=x.def(L,"[",V,"]"),Re=x.def(L,"[",F("src","Alpha"),"]"),Ee=x.def(L,"[",X,"]"),ye=x.def(L,"[",F("dst","Alpha"),"]");return[se,Ee,Re,ye]});case pa:return E(function(p){if(typeof p=="string")return d.commandParameter(p,O,"invalid "+A,l.commandStr),[O[p],O[p]];if(typeof p=="object")return d.commandParameter(p.rgb,O,A+".rgb",l.commandStr),d.commandParameter(p.alpha,O,A+".alpha",l.commandStr),[O[p.rgb],O[p.alpha]];d.commandRaise("invalid blend.equation",l.commandStr)},function(p,x,g){var L=p.constants.blendEquations,F=x.def(),V=x.def(),X=p.cond("typeof ",g,'==="string"');return d.optional(function(){function se(Re,Ee,ye){p.assert(Re,ye+" in "+L,"invalid "+Ee+", must be one of "+Object.keys(O))}se(X.then,A,g),p.assert(X.else,g+"&&typeof "+g+'==="object"',"invalid "+A),se(X.else,A+".rgb",g+".rgb"),se(X.else,A+".alpha",g+".alpha")}),X.then(F,"=",V,"=",L,"[",g,"];"),X.else(F,"=",L,"[",g,".rgb];",V,"=",L,"[",g,".alpha];"),x(X),[F,V]});case Nu:return E(function(p){return d.command(at(p)&&p.length===4,"blend.color must be a 4d array",l.commandStr),Ot(4,function(x){return+p[x]})},function(p,x,g){return d.optional(function(){p.assert(x,p.shared.isArrayLike+"("+g+")&&"+g+".length===4","blend.color must be a 4d array")}),Ot(4,function(L){return x.def("+",g,"[",L,"]")})});case Yu:return E(function(p){return d.commandType(p,"number",T,l.commandStr),p|0},function(p,x,g){return d.optional(function(){p.assert(x,"typeof "+g+'==="number"',"invalid stencil.mask")}),x.def(g,"|0")});case Sa:return E(function(p){d.commandType(p,"object",T,l.commandStr);var x=p.cmp||"keep",g=p.ref||0,L="mask"in p?p.mask:-1;return d.commandParameter(x,cr,A+".cmp",l.commandStr),d.commandType(g,"number",A+".ref",l.commandStr),d.commandType(L,"number",A+".mask",l.commandStr),[cr[x],g,L]},function(p,x,g){var L=p.constants.compareFuncs;d.optional(function(){function se(){p.assert(x,Array.prototype.join.call(arguments,""),"invalid stencil.func")}se(g+"&&typeof ",g,'==="object"'),se('!("cmp" in ',g,")||(",g,".cmp in ",L,")")});var F=x.def('"cmp" in ',g,"?",L,"[",g,".cmp]",":",bn),V=x.def(g,".ref|0"),X=x.def('"mask" in ',g,"?",g,".mask|0:-1");return[F,V,X]});case wa:case Fr:return E(function(p){d.commandType(p,"object",T,l.commandStr);var x=p.fail||"keep",g=p.zfail||"keep",L=p.zpass||"keep";return d.commandParameter(x,_n,A+".fail",l.commandStr),d.commandParameter(g,_n,A+".zfail",l.commandStr),d.commandParameter(L,_n,A+".zpass",l.commandStr),[A===Fr?Bn:Br,_n[x],_n[g],_n[L]]},function(p,x,g){var L=p.constants.stencilOps;d.optional(function(){p.assert(x,g+"&&typeof "+g+'==="object"',"invalid "+A)});function F(V){return d.optional(function(){p.assert(x,'!("'+V+'" in '+g+")||("+g+"."+V+" in "+L+")","invalid "+A+"."+V+", must be one of "+Object.keys(_n))}),x.def('"',V,'" in ',g,"?",L,"[",g,".",V,"]:",bn)}return[A===Fr?Bn:Br,F("fail"),F("zfail"),F("zpass")]});case ba:return E(function(p){d.commandType(p,"object",T,l.commandStr);var x=p.factor|0,g=p.units|0;return d.commandType(x,"number",T+".factor",l.commandStr),d.commandType(g,"number",T+".units",l.commandStr),[x,g]},function(p,x,g){d.optional(function(){p.assert(x,g+"&&typeof "+g+'==="object"',"invalid "+A)});var L=x.def(g,".factor|0"),F=x.def(g,".units|0");return[L,F]});case ju:return E(function(p){var x=0;return p==="front"?x=Br:p==="back"&&(x=Bn),d.command(!!x,T,l.commandStr),x},function(p,x,g){return d.optional(function(){p.assert(x,g+'==="front"||'+g+'==="back"',"invalid cull.face")}),x.def(g,'==="front"?',Br,":",Bn)});case xa:return E(function(p){return d.command(typeof p=="number"&&p>=R.lineWidthDims[0]&&p<=R.lineWidthDims[1],"invalid line width, must be a positive number between "+R.lineWidthDims[0]+" and "+R.lineWidthDims[1],l.commandStr),p},function(p,x,g){return d.optional(function(){p.assert(x,"typeof "+g+'==="number"&&'+g+">="+R.lineWidthDims[0]+"&&"+g+"<="+R.lineWidthDims[1],"invalid line width")}),g});case ya:return E(function(p){return d.commandParameter(p,za,T,l.commandStr),za[p]},function(p,x,g){return d.optional(function(){p.assert(x,g+'==="cw"||'+g+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),x.def(g+'==="cw"?'+tc+":"+La)});case ga:return E(function(p){return d.command(at(p)&&p.length===4,"color.mask must be length 4 array",l.commandStr),p.map(function(x){return!!x})},function(p,x,g){return d.optional(function(){p.assert(x,p.shared.isArrayLike+"("+g+")&&"+g+".length===4","invalid color.mask")}),Ot(4,function(L){return"!!"+g+"["+L+"]"})});case _a:return E(function(p){d.command(typeof p=="object"&&p,T,l.commandStr);var x="value"in p?p.value:1,g=!!p.invert;return d.command(typeof x=="number"&&x>=0&&x<=1,"sample.coverage.value must be a number between 0 and 1",l.commandStr),[x,g]},function(p,x,g){d.optional(function(){p.assert(x,g+"&&typeof "+g+'==="object"',"invalid sample.coverage")});var L=x.def('"value" in ',g,"?+",g,".value:1"),F=x.def("!!",g,".invert");return[L,F]})}}),k}function Ze(m,l){var w=m.static,C=m.dynamic,k={};return Object.keys(w).forEach(function(A){var T=w[A],E;if(typeof T=="number"||typeof T=="boolean")E=dt(function(){return T});else if(typeof T=="function"){var p=T._reglType;p==="texture2d"||p==="textureCube"?E=dt(function(x){return x.link(T)}):p==="framebuffer"||p==="framebufferCube"?(d.command(T.color.length>0,'missing color attachment for framebuffer sent to uniform "'+A+'"',l.commandStr),E=dt(function(x){return x.link(T.color[0])})):d.commandRaise('invalid data for uniform "'+A+'"',l.commandStr)}else at(T)?E=dt(function(x){var g=x.global.def("[",Ot(T.length,function(L){return d.command(typeof T[L]=="number"||typeof T[L]=="boolean","invalid uniform "+A,x.commandStr),T[L]}),"]");return g}):d.commandRaise('invalid or missing data for uniform "'+A+'"',l.commandStr);E.value=T,k[A]=E}),Object.keys(C).forEach(function(A){var T=C[A];k[A]=Ft(T,function(E,p){return E.invoke(p,T)})}),k}function pt(m,l){var w=m.static,C=m.dynamic,k={};return Object.keys(w).forEach(function(A){var T=w[A],E=h.id(A),p=new P;if(Qi(T))p.state=ar,p.buffer=U.getBuffer(U.create(T,ur,!1,!0)),p.type=0;else{var x=U.getBuffer(T);if(x)p.state=ar,p.buffer=x,p.type=0;else if(d.command(typeof T=="object"&&T,"invalid data for attribute "+A,l.commandStr),"constant"in T){var g=T.constant;p.buffer="null",p.state=ca,typeof g=="number"?p.x=g:(d.command(at(g)&&g.length>0&&g.length<=4,"invalid constant for attribute "+A,l.commandStr),or.forEach(function(Ee,ye){ye<g.length&&(p[Ee]=g[ye])}))}else{Qi(T.buffer)?x=U.getBuffer(U.create(T.buffer,ur,!1,!0)):x=U.getBuffer(T.buffer),d.command(!!x,'missing buffer for attribute "'+A+'"',l.commandStr);var L=T.offset|0;d.command(L>=0,'invalid offset for attribute "'+A+'"',l.commandStr);var F=T.stride|0;d.command(F>=0&&F<256,'invalid stride for attribute "'+A+'", must be integer betweeen [0, 255]',l.commandStr);var V=T.size|0;d.command(!("size"in T)||V>0&&V<=4,'invalid size for attribute "'+A+'", must be 1,2,3,4',l.commandStr);var X=!!T.normalized,se=0;"type"in T&&(d.commandParameter(T.type,Ln,"invalid type for attribute "+A,l.commandStr),se=Ln[T.type]);var Re=T.divisor|0;d.optional(function(){"divisor"in T&&(d.command(Re===0||ee,'cannot specify divisor for attribute "'+A+'", instancing not supported',l.commandStr),d.command(Re>=0,'invalid divisor for attribute "'+A+'"',l.commandStr));var Ee=l.commandStr,ye=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(T).forEach(function(H){d.command(ye.indexOf(H)>=0,'unknown parameter "'+H+'" for attribute pointer "'+A+'" (valid parameters are '+ye+")",Ee)})}),p.buffer=x,p.state=ar,p.size=V,p.normalized=X,p.type=se||x.dtype,p.offset=L,p.stride=F,p.divisor=Re}}k[A]=dt(function(Ee,ye){var H=Ee.attribCache;if(E in H)return H[E];var B={isStream:!1};return Object.keys(p).forEach(function(Te){B[Te]=p[Te]}),p.buffer&&(B.buffer=Ee.link(p.buffer),B.type=B.type||B.buffer+".dtype"),H[E]=B,B})}),Object.keys(C).forEach(function(A){var T=C[A];function E(p,x){var g=p.invoke(x,T),L=p.shared,F=p.constants,V=L.isBufferArgs,X=L.buffer;d.optional(function(){p.assert(x,g+"&&(typeof "+g+'==="object"||typeof '+g+'==="function")&&('+V+"("+g+")||"+X+".getBuffer("+g+")||"+X+".getBuffer("+g+".buffer)||"+V+"("+g+'.buffer)||("constant" in '+g+"&&(typeof "+g+'.constant==="number"||'+L.isArrayLike+"("+g+".constant))))",'invalid dynamic attribute "'+A+'"')});var se={isStream:x.def(!1)},Re=new P;Re.state=ar,Object.keys(Re).forEach(function(B){se[B]=x.def(""+Re[B])});var Ee=se.buffer,ye=se.type;x("if(",V,"(",g,")){",se.isStream,"=true;",Ee,"=",X,".createStream(",ur,",",g,");",ye,"=",Ee,".dtype;","}else{",Ee,"=",X,".getBuffer(",g,");","if(",Ee,"){",ye,"=",Ee,".dtype;",'}else if("constant" in ',g,"){",se.state,"=",ca,";","if(typeof "+g+'.constant === "number"){',se[or[0]],"=",g,".constant;",or.slice(1).map(function(B){return se[B]}).join("="),"=0;","}else{",or.map(function(B,Te){return se[B]+"="+g+".constant.length>"+Te+"?"+g+".constant["+Te+"]:0;"}).join(""),"}}else{","if(",V,"(",g,".buffer)){",Ee,"=",X,".createStream(",ur,",",g,".buffer);","}else{",Ee,"=",X,".getBuffer(",g,".buffer);","}",ye,'="type" in ',g,"?",F.glTypes,"[",g,".type]:",Ee,".dtype;",se.normalized,"=!!",g,".normalized;");function H(B){x(se[B],"=",g,".",B,"|0;")}return H("size"),H("offset"),H("stride"),H("divisor"),x("}}"),x.exit("if(",se.isStream,"){",X,".destroyStream(",Ee,");","}"),se}k[A]=Ft(T,E)}),k}function ot(m){var l=m.static,w=m.dynamic,C={};return Object.keys(l).forEach(function(k){var A=l[k];C[k]=dt(function(T,E){return typeof A=="number"||typeof A=="boolean"?""+A:T.link(A)})}),Object.keys(w).forEach(function(k){var A=w[k];C[k]=Ft(A,function(T,E){return T.invoke(E,A)})}),C}function mt(m,l,w,C,k){var A=m.static,T=m.dynamic;d.optional(function(){var H=[Mn,zr,Ir,On,Nn,Bi,Gn,Vi,Lr,Rr].concat(Pe);function B(Te){Object.keys(Te).forEach(function(_e){d.command(H.indexOf(_e)>=0,'unknown parameter "'+_e+'"',k.commandStr)})}B(A),B(T)});var E=Ne(m,l),p=ve(m),x=ze(m,p,k),g=st(m,k),L=ft(m,k),F=qe(m,k,E);function V(H){var B=x[H];B&&(L[H]=B)}V(dn),V(be(Gi));var X=Object.keys(L).length>0,se={framebuffer:p,draw:g,shader:F,state:L,dirty:X,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(se.profile=me(m),se.uniforms=Ze(w,k),se.drawVAO=se.scopeVAO=g.vao,!se.drawVAO&&F.program&&!E&&_.angle_instanced_arrays&&g.static.elements){var Re=!0,Ee=F.program.attributes.map(function(H){var B=l.static[H];return Re=Re&&!!B,B});if(Re&&Ee.length>0){var ye=ne.getVAO(ne.createVAO({attributes:Ee,elements:g.static.elements}));se.drawVAO=new xt(null,null,null,function(H,B){return H.link(ye)}),se.useVAO=!0}}return E?se.useVAO=!0:se.attributes=pt(l,k),se.context=ot(C),se}function vt(m,l,w){var C=m.shared,k=C.context,A=m.scope();Object.keys(w).forEach(function(T){l.save(k,"."+T);var E=w[T],p=E.append(m,l);Array.isArray(p)?A(k,".",T,"=[",p.join(),"];"):A(k,".",T,"=",p,";")}),l(A)}function gt(m,l,w,C){var k=m.shared,A=k.gl,T=k.framebuffer,E;ge&&(E=l.def(k.extensions,".webgl_draw_buffers"));var p=m.constants,x=p.drawBuffer,g=p.backBuffer,L;w?L=w.append(m,l):L=l.def(T,".next"),C||l("if(",L,"!==",T,".cur){"),l("if(",L,"){",A,".bindFramebuffer(",oc,",",L,".framebuffer);"),ge&&l(E,".drawBuffersWEBGL(",x,"[",L,".colorAttachments.length]);"),l("}else{",A,".bindFramebuffer(",oc,",null);"),ge&&l(E,".drawBuffersWEBGL(",g,");"),l("}",T,".cur=",L,";"),C||l("}")}function St(m,l,w){var C=m.shared,k=C.gl,A=m.current,T=m.next,E=C.current,p=C.next,x=m.cond(E,".dirty");Pe.forEach(function(g){var L=be(g);if(!(L in w.state)){var F,V;if(L in T){F=T[L],V=A[L];var X=Ot(pe[L].length,function(Re){return x.def(F,"[",Re,"]")});x(m.cond(X.map(function(Re,Ee){return Re+"!=="+V+"["+Ee+"]"}).join("||")).then(k,".",$[L],"(",X,");",X.map(function(Re,Ee){return V+"["+Ee+"]="+Re}).join(";"),";"))}else{F=x.def(p,".",L);var se=m.cond(F,"!==",E,".",L);x(se),L in j?se(m.cond(F).then(k,".enable(",j[L],");").else(k,".disable(",j[L],");"),E,".",L,"=",F,";"):se(k,".",$[L],"(",F,");",E,".",L,"=",F,";")}}}),Object.keys(w.state).length===0&&x(E,".dirty=false;"),l(x)}function At(m,l,w,C){var k=m.shared,A=m.current,T=k.current,E=k.gl;fc(Object.keys(w)).forEach(function(p){var x=w[p];if(!(C&&!C(x))){var g=x.append(m,l);if(j[p]){var L=j[p];Sn(x)?g?l(E,".enable(",L,");"):l(E,".disable(",L,");"):l(m.cond(g).then(E,".enable(",L,");").else(E,".disable(",L,");")),l(T,".",p,"=",g,";")}else if(at(g)){var F=A[p];l(E,".",$[p],"(",g,");",g.map(function(V,X){return F+"["+X+"]="+V}).join(";"),";")}else l(E,".",$[p],"(",g,");",T,".",p,"=",g,";")}})}function ct(m,l){ee&&(m.instancing=l.def(m.shared.extensions,".angle_instanced_arrays"))}function $e(m,l,w,C,k){var A=m.shared,T=m.stats,E=A.current,p=A.timer,x=w.profile;function g(){return typeof performance>"u"?"Date.now()":"performance.now()"}var L,F;function V(H){L=l.def(),H(L,"=",g(),";"),typeof k=="string"?H(T,".count+=",k,";"):H(T,".count++;"),K&&(C?(F=l.def(),H(F,"=",p,".getNumPendingQueries();")):H(p,".beginQuery(",T,");"))}function X(H){H(T,".cpuTime+=",g(),"-",L,";"),K&&(C?H(p,".pushScopeStats(",F,",",p,".getNumPendingQueries(),",T,");"):H(p,".endQuery();"))}function se(H){var B=l.def(E,".profile");l(E,".profile=",H,";"),l.exit(E,".profile=",B,";")}var Re;if(x){if(Sn(x)){x.enable?(V(l),X(l.exit),se("true")):se("false");return}Re=x.append(m,l),se(Re)}else Re=l.def(E,".profile");var Ee=m.block();V(Ee),l("if(",Re,"){",Ee,"}");var ye=m.block();X(ye),l.exit("if(",Re,"){",ye,"}")}function Et(m,l,w,C,k){var A=m.shared;function T(p){switch(p){case $i:case Xi:case Wi:return 2;case Ui:case Hi:case Yi:return 3;case ji:case qi:case Zi:return 4;default:return 1}}function E(p,x,g){var L=A.gl,F=l.def(p,".location"),V=l.def(A.attributes,"[",F,"]"),X=g.state,se=g.buffer,Re=[g.x,g.y,g.z,g.w],Ee=["buffer","normalized","offset","stride"];function ye(){l("if(!",V,".buffer){",L,".enableVertexAttribArray(",F,");}");var B=g.type,Te;if(g.size?Te=l.def(g.size,"||",x):Te=x,l("if(",V,".type!==",B,"||",V,".size!==",Te,"||",Ee.map(function(Ie){return V+"."+Ie+"!=="+g[Ie]}).join("||"),"){",L,".bindBuffer(",ur,",",se,".buffer);",L,".vertexAttribPointer(",[F,Te,B,g.normalized,g.stride,g.offset],");",V,".type=",B,";",V,".size=",Te,";",Ee.map(function(Ie){return V+"."+Ie+"="+g[Ie]+";"}).join(""),"}"),ee){var _e=g.divisor;l("if(",V,".divisor!==",_e,"){",m.instancing,".vertexAttribDivisorANGLE(",[F,_e],");",V,".divisor=",_e,";}")}}function H(){l("if(",V,".buffer){",L,".disableVertexAttribArray(",F,");",V,".buffer=null;","}if(",or.map(function(B,Te){return V+"."+B+"!=="+Re[Te]}).join("||"),"){",L,".vertexAttrib4f(",F,",",Re,");",or.map(function(B,Te){return V+"."+B+"="+Re[Te]+";"}).join(""),"}")}X===ar?ye():X===ca?H():(l("if(",X,"===",ar,"){"),ye(),l("}else{"),H(),l("}"))}C.forEach(function(p){var x=p.name,g=w.attributes[x],L;if(g){if(!k(g))return;L=g.append(m,l)}else{if(!k(uc))return;var F=m.scopeAttrib(x);d.optional(function(){m.assert(l,F+".state","missing attribute "+x)}),L={},Object.keys(new P).forEach(function(V){L[V]=l.def(F,".",V)})}E(m.link(p),T(p.info.type),L)})}function Ke(m,l,w,C,k,A){for(var T=m.shared,E=T.gl,p={},x,g=0;g<C.length;++g){var L=C[g],F=L.name,V=L.info.type,X=L.info.size,se=w.uniforms[F];if(X>1){if(!se)continue;var Re=F.replace("[0]","");if(p[Re])continue;p[Re]=1}var Ee=m.link(L),ye=Ee+".location",H;if(se){if(!k(se))continue;if(Sn(se)){var B=se.value;if(d.command(B!==null&&typeof B<"u",'missing uniform "'+F+'"',m.commandStr),V===Nr||V===Gr){d.command(typeof B=="function"&&(V===Nr&&(B._reglType==="texture2d"||B._reglType==="framebuffer")||V===Gr&&(B._reglType==="textureCube"||B._reglType==="framebufferCube")),"invalid texture for uniform "+F,m.commandStr);var Te=m.link(B._texture||B.color[0]._texture);l(E,".uniform1i(",ye,",",Te+".bind());"),l.exit(Te,".unbind();")}else if(V===Dr||V===Mr||V===Or){d.optional(function(){d.command(at(B),"invalid matrix for uniform "+F,m.commandStr),d.command(V===Dr&&B.length===4||V===Mr&&B.length===9||V===Or&&B.length===16,"invalid length for matrix uniform "+F,m.commandStr)});var _e=m.global.def("new Float32Array(["+Array.prototype.slice.call(B)+"])"),Ie=2;V===Mr?Ie=3:V===Or&&(Ie=4),l(E,".uniformMatrix",Ie,"fv(",ye,",false,",_e,");")}else{switch(V){case Ca:X===1?d.commandType(B,"number","uniform "+F,m.commandStr):d.command(at(B)&&B.length===X,"uniform "+F,m.commandStr),x="1f";break;case $i:d.command(at(B)&&B.length&&B.length%2===0&&B.length<=X*2,"uniform "+F,m.commandStr),x="2f";break;case Ui:d.command(at(B)&&B.length&&B.length%3===0&&B.length<=X*3,"uniform "+F,m.commandStr),x="3f";break;case ji:d.command(at(B)&&B.length&&B.length%4===0&&B.length<=X*4,"uniform "+F,m.commandStr),x="4f";break;case ka:X===1?d.commandType(B,"boolean","uniform "+F,m.commandStr):d.command(at(B)&&B.length===X,"uniform "+F,m.commandStr),x="1i";break;case Pa:X===1?d.commandType(B,"number","uniform "+F,m.commandStr):d.command(at(B)&&B.length===X,"uniform "+F,m.commandStr),x="1i";break;case Wi:d.command(at(B)&&B.length&&B.length%2===0&&B.length<=X*2,"uniform "+F,m.commandStr),x="2i";break;case Xi:d.command(at(B)&&B.length&&B.length%2===0&&B.length<=X*2,"uniform "+F,m.commandStr),x="2i";break;case Yi:d.command(at(B)&&B.length&&B.length%3===0&&B.length<=X*3,"uniform "+F,m.commandStr),x="3i";break;case Hi:d.command(at(B)&&B.length&&B.length%3===0&&B.length<=X*3,"uniform "+F,m.commandStr),x="3i";break;case Zi:d.command(at(B)&&B.length&&B.length%4===0&&B.length<=X*4,"uniform "+F,m.commandStr),x="4i";break;case qi:d.command(at(B)&&B.length&&B.length%4===0&&B.length<=X*4,"uniform "+F,m.commandStr),x="4i";break}X>1?(x+="v",B=m.global.def("["+Array.prototype.slice.call(B)+"]")):B=at(B)?Array.prototype.slice.call(B):B,l(E,".uniform",x,"(",ye,",",B,");")}continue}else H=se.append(m,l)}else{if(!k(uc))continue;H=l.def(T.uniforms,"[",h.id(F),"]")}V===Nr?(d(!Array.isArray(H),"must specify a scalar prop for textures"),l("if(",H,"&&",H,'._reglType==="framebuffer"){',H,"=",H,".color[0];","}")):V===Gr&&(d(!Array.isArray(H),"must specify a scalar prop for cube maps"),l("if(",H,"&&",H,'._reglType==="framebufferCube"){',H,"=",H,".color[0];","}")),d.optional(function(){function Gt(Lt,Ki){m.assert(l,Lt,'bad data or missing for uniform "'+F+'". '+Ki)}function jn(Lt,Ki){Ki===1&&d(!Array.isArray(H),"must not specify an array type for uniform"),Gt("Array.isArray("+H+") && typeof "+H+'[0]===" '+Lt+'" || typeof '+H+'==="'+Lt+'"',"invalid type, expected "+Lt)}function $t(Lt,Ki,Ji){Array.isArray(H)?d(H.length&&H.length%Lt===0&&H.length<=Lt*Ji,"must have length of "+(Ji===1?"":"n * ")+Lt):Gt(T.isArrayLike+"("+H+")&&"+H+".length && "+H+".length % "+Lt+" === 0 && "+H+".length<="+Lt*Ji,"invalid vector, should have length of "+(Ji===1?"":"n * ")+Lt,m.commandStr)}function vc(Lt){d(!Array.isArray(H),"must not specify a value type"),Gt("typeof "+H+'==="function"&&'+H+'._reglType==="texture'+(Lt===ec?"2d":"Cube")+'"',"invalid texture type",m.commandStr)}switch(V){case Pa:jn("number",X);break;case Xi:$t(2,"number",X);break;case Hi:$t(3,"number",X);break;case qi:$t(4,"number",X);break;case Ca:jn("number",X);break;case $i:$t(2,"number",X);break;case Ui:$t(3,"number",X);break;case ji:$t(4,"number",X);break;case ka:jn("boolean",X);break;case Wi:$t(2,"boolean",X);break;case Yi:$t(3,"boolean",X);break;case Zi:$t(4,"boolean",X);break;case Dr:$t(4,"number",X);break;case Mr:$t(9,"number",X);break;case Or:$t(16,"number",X);break;case Nr:vc(ec);break;case Gr:vc(xy);break}});var Je=1;switch(V){case Nr:case Gr:var Ct=l.def(H,"._texture");l(E,".uniform1i(",ye,",",Ct,".bind());"),l.exit(Ct,".unbind();");continue;case Pa:case ka:x="1i";break;case Xi:case Wi:x="2i",Je=2;break;case Hi:case Yi:x="3i",Je=3;break;case qi:case Zi:x="4i",Je=4;break;case Ca:x="1f";break;case $i:x="2f",Je=2;break;case Ui:x="3f",Je=3;break;case ji:x="4f",Je=4;break;case Dr:x="Matrix2fv";break;case Mr:x="Matrix3fv";break;case Or:x="Matrix4fv";break}if(x.indexOf("Matrix")===-1&&X>1&&(x+="v",Je=1),x.charAt(0)==="M"){l(E,".uniform",x,"(",ye,",");var $n=Math.pow(V-Dr+2,2),mn=m.global.def("new Float32Array(",$n,")");Array.isArray(H)?l("false,(",Ot($n,function(Gt){return mn+"["+Gt+"]="+H[Gt]}),",",mn,")"):l("false,(Array.isArray(",H,")||",H," instanceof Float32Array)?",H,":(",Ot($n,function(Gt){return mn+"["+Gt+"]="+H+"["+Gt+"]"}),",",mn,")"),l(");")}else if(Je>1){for(var on=[],wn=[],Un=0;Un<Je;++Un)Array.isArray(H)?wn.push(H[Un]):wn.push(l.def(H+"["+Un+"]")),A&&on.push(l.def());A&&l("if(!",m.batchId,"||",on.map(function(Gt,jn){return Gt+"!=="+wn[jn]}).join("||"),"){",on.map(function(Gt,jn){return Gt+"="+wn[jn]+";"}).join("")),l(E,".uniform",x,"(",ye,",",wn.join(","),");"),A&&l("}")}else{if(d(!Array.isArray(H),"uniform value must not be an array"),A){var pc=l.def();l("if(!",m.batchId,"||",pc,"!==",H,"){",pc,"=",H,";")}l(E,".uniform",x,"(",ye,",",H,");"),A&&l("}")}}}function Fe(m,l,w,C){var k=m.shared,A=k.gl,T=k.draw,E=C.draw;function p(){var Te=E.elements,_e,Ie=l;return Te?((Te.contextDep&&C.contextDynamic||Te.propDep)&&(Ie=w),_e=Te.append(m,Ie),E.elementsActive&&Ie("if("+_e+")"+A+".bindBuffer("+Ea+","+_e+".buffer.buffer);")):(_e=Ie.def(),Ie(_e,"=",T,".",On,";","if(",_e,"){",A,".bindBuffer(",Ea,",",_e,".buffer.buffer);}","else if(",k.vao,".currentVAO){",_e,"=",m.shared.elements+".getElements("+k.vao,".currentVAO.elements);",q?"":"if("+_e+")"+A+".bindBuffer("+Ea+","+_e+".buffer.buffer);","}")),_e}function x(){var Te=E.count,_e,Ie=l;return Te?((Te.contextDep&&C.contextDynamic||Te.propDep)&&(Ie=w),_e=Te.append(m,Ie),d.optional(function(){Te.MISSING&&m.assert(l,"false","missing vertex count"),Te.DYNAMIC&&m.assert(Ie,_e+">=0","missing vertex count")})):(_e=Ie.def(T,".",Gn),d.optional(function(){m.assert(Ie,_e+">=0","missing vertex count")})),_e}var g=p();function L(Te){var _e=E[Te];return _e?_e.contextDep&&C.contextDynamic||_e.propDep?_e.append(m,w):_e.append(m,l):l.def(T,".",Te)}var F=L(Nn),V=L(Bi),X=x();if(typeof X=="number"){if(X===0)return}else w("if(",X,"){"),w.exit("}");var se,Re;ee&&(se=L(Vi),Re=m.instancing);var Ee=g+".type",ye=E.elements&&Sn(E.elements)&&!E.vaoActive;function H(){function Te(){w(Re,".drawElementsInstancedANGLE(",[F,X,Ee,V+"<<(("+Ee+"-"+Iu+")>>1)",se],");")}function _e(){w(Re,".drawArraysInstancedANGLE(",[F,V,X,se],");")}g&&g!=="null"?ye?Te():(w("if(",g,"){"),Te(),w("}else{"),_e(),w("}")):_e()}function B(){function Te(){w(A+".drawElements("+[F,X,Ee,V+"<<(("+Ee+"-"+Iu+")>>1)"]+");")}function _e(){w(A+".drawArrays("+[F,V,X]+");")}g&&g!=="null"?ye?Te():(w("if(",g,"){"),Te(),w("}else{"),_e(),w("}")):_e()}ee&&(typeof se!="number"||se>=0)?typeof se=="string"?(w("if(",se,">0){"),H(),w("}else if(",se,"<0){"),B(),w("}")):H():B()}function We(m,l,w,C,k){var A=De(),T=A.proc("body",k);return d.optional(function(){A.commandStr=l.commandStr,A.command=A.link(l.commandStr)}),ee&&(A.instancing=T.def(A.shared.extensions,".angle_instanced_arrays")),m(A,T,w,C),A.compile().body}function Qe(m,l,w,C){ct(m,l),w.useVAO?w.drawVAO?l(m.shared.vao,".setVAO(",w.drawVAO.append(m,l),");"):l(m.shared.vao,".setVAO(",m.shared.vao,".targetVAO);"):(l(m.shared.vao,".setVAO(null);"),Et(m,l,w,C.attributes,function(){return!0})),Ke(m,l,w,C.uniforms,function(){return!0},!1),Fe(m,l,l,w)}function lt(m,l){var w=m.proc("draw",1);ct(m,w),vt(m,w,l.context),gt(m,w,l.framebuffer),St(m,w,l),At(m,w,l.state),$e(m,w,l,!1,!0);var C=l.shader.progVar.append(m,w);if(w(m.shared.gl,".useProgram(",C,".program);"),l.shader.program)Qe(m,w,l,l.shader.program);else{w(m.shared.vao,".setVAO(null);");var k=m.global.def("{}"),A=w.def(C,".id"),T=w.def(k,"[",A,"]");w(m.cond(T).then(T,".call(this,a0);").else(T,"=",k,"[",A,"]=",m.link(function(E){return We(Qe,m,l,E,1)}),"(",C,");",T,".call(this,a0);"))}Object.keys(l.state).length>0&&w(m.shared.current,".dirty=true;"),m.shared.vao&&w(m.shared.vao,".setVAO(null);")}function rn(m,l,w,C){m.batchId="a1",ct(m,l);function k(){return!0}Et(m,l,w,C.attributes,k),Ke(m,l,w,C.uniforms,k,!1),Fe(m,l,l,w)}function Vn(m,l,w,C){ct(m,l);var k=w.contextDep,A=l.def(),T="a0",E="a1",p=l.def();m.shared.props=p,m.batchId=A;var x=m.scope(),g=m.scope();l(x.entry,"for(",A,"=0;",A,"<",E,";++",A,"){",p,"=",T,"[",A,"];",g,"}",x.exit);function L(Ee){return Ee.contextDep&&k||Ee.propDep}function F(Ee){return!L(Ee)}if(w.needsContext&&vt(m,g,w.context),w.needsFramebuffer&&gt(m,g,w.framebuffer),At(m,g,w.state,L),w.profile&&L(w.profile)&&$e(m,g,w,!1,!0),C)w.useVAO?w.drawVAO?L(w.drawVAO)?g(m.shared.vao,".setVAO(",w.drawVAO.append(m,g),");"):x(m.shared.vao,".setVAO(",w.drawVAO.append(m,x),");"):x(m.shared.vao,".setVAO(",m.shared.vao,".targetVAO);"):(x(m.shared.vao,".setVAO(null);"),Et(m,x,w,C.attributes,F),Et(m,g,w,C.attributes,L)),Ke(m,x,w,C.uniforms,F,!1),Ke(m,g,w,C.uniforms,L,!0),Fe(m,x,g,w);else{var V=m.global.def("{}"),X=w.shader.progVar.append(m,g),se=g.def(X,".id"),Re=g.def(V,"[",se,"]");g(m.shared.gl,".useProgram(",X,".program);","if(!",Re,"){",Re,"=",V,"[",se,"]=",m.link(function(Ee){return We(rn,m,w,Ee,2)}),"(",X,");}",Re,".call(this,a0[",A,"],",A,");")}}function y(m,l){var w=m.proc("batch",2);m.batchId="0",ct(m,w);var C=!1,k=!0;Object.keys(l.context).forEach(function(V){C=C||l.context[V].propDep}),C||(vt(m,w,l.context),k=!1);var A=l.framebuffer,T=!1;A?(A.propDep?C=T=!0:A.contextDep&&C&&(T=!0),T||gt(m,w,A)):gt(m,w,null),l.state.viewport&&l.state.viewport.propDep&&(C=!0);function E(V){return V.contextDep&&C||V.propDep}St(m,w,l),At(m,w,l.state,function(V){return!E(V)}),(!l.profile||!E(l.profile))&&$e(m,w,l,!1,"a1"),l.contextDep=C,l.needsContext=k,l.needsFramebuffer=T;var p=l.shader.progVar;if(p.contextDep&&C||p.propDep)Vn(m,w,l,null);else{var x=p.append(m,w);if(w(m.shared.gl,".useProgram(",x,".program);"),l.shader.program)Vn(m,w,l,l.shader.program);else{w(m.shared.vao,".setVAO(null);");var g=m.global.def("{}"),L=w.def(x,".id"),F=w.def(g,"[",L,"]");w(m.cond(F).then(F,".call(this,a0,a1);").else(F,"=",g,"[",L,"]=",m.link(function(V){return We(Vn,m,l,V,2)}),"(",x,");",F,".call(this,a0,a1);"))}}Object.keys(l.state).length>0&&w(m.shared.current,".dirty=true;"),m.shared.vao&&w(m.shared.vao,".setVAO(null);")}function M(m,l){var w=m.proc("scope",3);m.batchId="a2";var C=m.shared,k=C.current;vt(m,w,l.context),l.framebuffer&&l.framebuffer.append(m,w),fc(Object.keys(l.state)).forEach(function(T){var E=l.state[T],p=E.append(m,w);at(p)?p.forEach(function(x,g){w.set(m.next[T],"["+g+"]",x)}):w.set(C.next,"."+T,p)}),$e(m,w,l,!0,!0),[On,Bi,Gn,Vi,Nn].forEach(function(T){var E=l.draw[T];E&&w.set(C.draw,"."+T,""+E.append(m,w))}),Object.keys(l.uniforms).forEach(function(T){var E=l.uniforms[T].append(m,w);Array.isArray(E)&&(E="["+E.join()+"]"),w.set(C.uniforms,"["+h.id(T)+"]",E)}),Object.keys(l.attributes).forEach(function(T){var E=l.attributes[T].append(m,w),p=m.scopeAttrib(T);Object.keys(new P).forEach(function(x){w.set(p,"."+x,E[x])})}),l.scopeVAO&&w.set(C.vao,".targetVAO",l.scopeVAO.append(m,w));function A(T){var E=l.shader[T];E&&w.set(C.shader,"."+T,E.append(m,w))}A(zr),A(Ir),Object.keys(l.state).length>0&&(w(k,".dirty=true;"),w.exit(k,".dirty=true;")),w("a1(",m.shared.context,",a0,",m.batchId,");")}function z(m){if(!(typeof m!="object"||at(m))){for(var l=Object.keys(m),w=0;w<l.length;++w)if(Mt.isDynamic(m[l[w]]))return!0;return!1}}function xe(m,l,w){var C=l.static[w];if(!C||!z(C))return;var k=m.global,A=Object.keys(C),T=!1,E=!1,p=!1,x=m.global.def("{}");A.forEach(function(L){var F=C[L];if(Mt.isDynamic(F)){typeof F=="function"&&(F=C[L]=Mt.unbox(F));var V=Ft(F,null);T=T||V.thisDep,p=p||V.propDep,E=E||V.contextDep}else{switch(k(x,".",L,"="),typeof F){case"number":k(F);break;case"string":k('"',F,'"');break;case"object":Array.isArray(F)&&k("[",F.join(),"]");break;default:k(m.link(F));break}k(";")}});function g(L,F){A.forEach(function(V){var X=C[V];if(Mt.isDynamic(X)){var se=L.invoke(F,X);F(x,".",V,"=",se,";")}})}l.dynamic[w]=new Mt.DynamicVariable(Ni,{thisDep:T,contextDep:E,propDep:p,ref:x,append:g}),delete l.static[w]}function He(m,l,w,C,k){var A=De();A.stats=A.link(k),Object.keys(l.static).forEach(function(E){xe(A,l,E)}),vy.forEach(function(E){xe(A,m,E)});var T=mt(m,l,w,C,A);return lt(A,T),M(A,T),y(A,T),r(A.compile(),{destroy:function(){T.shader.program.destroy()}})}return{next:de,current:pe,procs:function(){var m=De(),l=m.proc("poll"),w=m.proc("refresh"),C=m.block();l(C),w(C);var k=m.shared,A=k.gl,T=k.next,E=k.current;C(E,".dirty=false;"),gt(m,l),gt(m,w,null,!0);var p;ee&&(p=m.link(ee)),_.oes_vertex_array_object&&w(m.link(_.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var x=0;x<R.maxAttributes;++x){var g=w.def(k.attributes,"[",x,"]"),L=m.cond(g,".buffer");L.then(A,".enableVertexAttribArray(",x,");",A,".bindBuffer(",ur,",",g,".buffer.buffer);",A,".vertexAttribPointer(",x,",",g,".size,",g,".type,",g,".normalized,",g,".stride,",g,".offset);").else(A,".disableVertexAttribArray(",x,");",A,".vertexAttrib4f(",x,",",g,".x,",g,".y,",g,".z,",g,".w);",g,".buffer=null;"),w(L),ee&&w(p,".vertexAttribDivisorANGLE(",x,",",g,".divisor);")}return w(m.shared.vao,".currentVAO=null;",m.shared.vao,".setVAO(",m.shared.vao,".targetVAO);"),Object.keys(j).forEach(function(F){var V=j[F],X=C.def(T,".",F),se=m.block();se("if(",X,"){",A,".enable(",V,")}else{",A,".disable(",V,")}",E,".",F,"=",X,";"),w(se),l("if(",X,"!==",E,".",F,"){",se,"}")}),Object.keys($).forEach(function(F){var V=$[F],X=pe[F],se,Re,Ee=m.block();if(Ee(A,".",V,"("),at(X)){var ye=X.length;se=m.global.def(T,".",F),Re=m.global.def(E,".",F),Ee(Ot(ye,function(H){return se+"["+H+"]"}),");",Ot(ye,function(H){return Re+"["+H+"]="+se+"["+H+"];"}).join("")),l("if(",Ot(ye,function(H){return se+"["+H+"]!=="+Re+"["+H+"]"}).join("||"),"){",Ee,"}")}else se=C.def(T,".",F),Re=C.def(E,".",F),Ee(se,");",E,".",F,"=",se,";"),l("if(",se,"!==",Re,"){",Ee,"}");w(Ee)}),m.compile()}(),compile:He}}function Dy(){return{vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}var My=34918,Oy=34919,cc=35007,Ny=function(a,h){if(!h.ext_disjoint_timer_query)return null;var _=[];function R(){return _.pop()||h.ext_disjoint_timer_query.createQueryEXT()}function U(ee){_.push(ee)}var I=[];function G(ee){var ge=R();h.ext_disjoint_timer_query.beginQueryEXT(cc,ge),I.push(ge),K(I.length-1,I.length,ee)}function Q(){h.ext_disjoint_timer_query.endQueryEXT(cc)}function Y(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var ne=[];function ie(){return ne.pop()||new Y}function re(ee){ne.push(ee)}var fe=[];function K(ee,ge,q){var pe=ie();pe.startQueryIndex=ee,pe.endQueryIndex=ge,pe.sum=0,pe.stats=q,fe.push(pe)}var te=[],P=[];function O(){var ee,ge,q=I.length;if(q!==0){P.length=Math.max(P.length,q+1),te.length=Math.max(te.length,q+1),te[0]=0,P[0]=0;var pe=0;for(ee=0,ge=0;ge<I.length;++ge){var de=I[ge];h.ext_disjoint_timer_query.getQueryObjectEXT(de,Oy)?(pe+=h.ext_disjoint_timer_query.getQueryObjectEXT(de,My),U(de)):I[ee++]=de,te[ge+1]=pe,P[ge+1]=ee}for(I.length=ee,ee=0,ge=0;ge<fe.length;++ge){var Pe=fe[ge],j=Pe.startQueryIndex,$=Pe.endQueryIndex;Pe.sum+=te[$]-te[j];var be=P[j],ue=P[$];ue===be?(Pe.stats.gpuTime+=Pe.sum/1e6,re(Pe)):(Pe.startQueryIndex=be,Pe.endQueryIndex=ue,fe[ee++]=Pe)}fe.length=ee}}return{beginQuery:G,endQuery:Q,pushScopeStats:K,update:O,getNumPendingQueries:function(){return I.length},clear:function(){_.push.apply(_,I);for(var ee=0;ee<_.length;ee++)h.ext_disjoint_timer_query.deleteQueryEXT(_[ee]);I.length=0,_.length=0},restore:function(){I.length=0,_.length=0}}},Gy=16384,By=256,Vy=1024,$y=34962,lc="webglcontextlost",hc="webglcontextrestored",dc=1,Uy=2,jy=3;function mc(a,h){for(var _=0;_<a.length;++_)if(a[_]===h)return _;return-1}function Xy(a){var h=U0(a);if(!h)return null;var _=h.gl,R=_.getContextAttributes(),U=_.isContextLost(),I=j0(_,h);if(!I)return null;var G=N0(),Q=Dy(),Y=I.extensions,ne=Ny(_,Y),ie=Sf(),re=_.drawingBufferWidth,fe=_.drawingBufferHeight,K={tick:0,time:0,viewportWidth:re,viewportHeight:fe,framebufferWidth:re,framebufferHeight:fe,drawingBufferWidth:re,drawingBufferHeight:fe,pixelRatio:h.pixelRatio},te={},P={elements:null,primitive:4,count:-1,offset:0,instances:-1},O=Lv(_,Y),ee=qv(_,Q,h,pe),ge=og(_,Y,ee,Q),q=oy(_,Y,O,Q,ee,ge,P);function pe(Fe){return q.destroyBuffer(Fe)}var de=uy(_,G,Q,h),Pe=Mg(_,Y,O,function(){be.procs.poll()},K,Q,h),j=Og(_,Y,O,Q,h),$=ry(_,Y,O,Pe,j,Q),be=Ry(_,G,Y,O,ee,ge,Pe,$,te,q,de,P,K,ne,h),ue=hy(_,$,be.procs.poll,K,R,Y,O),J=be.next,ce=_.canvas,he=[],Oe=[],De=[],me=[h.onDestroy],ve=null;function ze(){if(he.length===0){ne&&ne.update(),ve=null;return}ve=Mo.next(ze),At();for(var Fe=he.length-1;Fe>=0;--Fe){var We=he[Fe];We&&We(K,null,0)}_.flush(),ne&&ne.update()}function Ne(){!ve&&he.length>0&&(ve=Mo.next(ze))}function qe(){ve&&(Mo.cancel(ze),ve=null)}function st(Fe){Fe.preventDefault(),U=!0,qe(),Oe.forEach(function(We){We()})}function ft(Fe){_.getError(),U=!1,I.restore(),de.restore(),ee.restore(),Pe.restore(),j.restore(),$.restore(),q.restore(),ne&&ne.restore(),be.procs.refresh(),Ne(),De.forEach(function(We){We()})}ce&&(ce.addEventListener(lc,st,!1),ce.addEventListener(hc,ft,!1));function Ze(){he.length=0,qe(),ce&&(ce.removeEventListener(lc,st),ce.removeEventListener(hc,ft)),de.clear(),$.clear(),j.clear(),q.clear(),Pe.clear(),ge.clear(),ee.clear(),ne&&ne.clear(),me.forEach(function(Fe){Fe()})}function pt(Fe){d(!!Fe,"invalid args to regl({...})"),d.type(Fe,"object","invalid args to regl({...})");function We(k){var A=r({},k);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 T(E){if(E in A){var p=A[E];delete A[E],Object.keys(p).forEach(function(x){A[E+"."+x]=p[x]})}}return T("blend"),T("depth"),T("cull"),T("stencil"),T("polygonOffset"),T("scissor"),T("sample"),"vao"in k&&(A.vao=k.vao),A}function Qe(k,A){var T={},E={};return Object.keys(k).forEach(function(p){var x=k[p];if(Mt.isDynamic(x)){E[p]=Mt.unbox(x,p);return}else if(A&&Array.isArray(x)){for(var g=0;g<x.length;++g)if(Mt.isDynamic(x[g])){E[p]=Mt.unbox(x,p);return}}T[p]=x}),{dynamic:E,static:T}}var lt=Qe(Fe.context||{},!0),rn=Qe(Fe.uniforms||{},!0),Vn=Qe(Fe.attributes||{},!1),y=Qe(We(Fe),!1),M={gpuTime:0,cpuTime:0,count:0},z=be.compile(y,Vn,rn,lt,M),xe=z.draw,He=z.batch,m=z.scope,l=[];function w(k){for(;l.length<k;)l.push(null);return l}function C(k,A){var T;if(U&&d.raise("context lost"),typeof k=="function")return m.call(this,null,k,0);if(typeof A=="function")if(typeof k=="number")for(T=0;T<k;++T)m.call(this,null,A,T);else if(Array.isArray(k))for(T=0;T<k.length;++T)m.call(this,k[T],A,T);else return m.call(this,k,A,0);else if(typeof k=="number"){if(k>0)return He.call(this,w(k|0),k|0)}else if(Array.isArray(k)){if(k.length)return He.call(this,k,k.length)}else return xe.call(this,k)}return r(C,{stats:M,destroy:function(){z.destroy()}})}var ot=$.setFBO=pt({framebuffer:Mt.define.call(null,dc,"framebuffer")});function mt(Fe,We){var Qe=0;be.procs.poll();var lt=We.color;lt&&(_.clearColor(+lt[0]||0,+lt[1]||0,+lt[2]||0,+lt[3]||0),Qe|=Gy),"depth"in We&&(_.clearDepth(+We.depth),Qe|=By),"stencil"in We&&(_.clearStencil(We.stencil|0),Qe|=Vy),d(!!Qe,"called regl.clear with no buffer specified"),_.clear(Qe)}function vt(Fe){if(d(typeof Fe=="object"&&Fe,"regl.clear() takes an object as input"),"framebuffer"in Fe)if(Fe.framebuffer&&Fe.framebuffer_reglType==="framebufferCube")for(var We=0;We<6;++We)ot(r({framebuffer:Fe.framebuffer.faces[We]},Fe),mt);else ot(Fe,mt);else mt(null,Fe)}function gt(Fe){d.type(Fe,"function","regl.frame() callback must be a function"),he.push(Fe);function We(){var Qe=mc(he,Fe);d(Qe>=0,"cannot cancel a frame twice");function lt(){var rn=mc(he,lt);he[rn]=he[he.length-1],he.length-=1,he.length<=0&&qe()}he[Qe]=lt}return Ne(),{cancel:We}}function St(){var Fe=J.viewport,We=J.scissor_box;Fe[0]=Fe[1]=We[0]=We[1]=0,K.viewportWidth=K.framebufferWidth=K.drawingBufferWidth=Fe[2]=We[2]=_.drawingBufferWidth,K.viewportHeight=K.framebufferHeight=K.drawingBufferHeight=Fe[3]=We[3]=_.drawingBufferHeight}function At(){K.tick+=1,K.time=$e(),St(),be.procs.poll()}function ct(){Pe.refresh(),St(),be.procs.refresh(),ne&&ne.update()}function $e(){return(Sf()-ie)/1e3}ct();function Et(Fe,We){d.type(We,"function","listener callback must be a function");var Qe;switch(Fe){case"frame":return gt(We);case"lost":Qe=Oe;break;case"restore":Qe=De;break;case"destroy":Qe=me;break;default:d.raise("invalid event, must be one of frame,lost,restore,destroy")}return Qe.push(We),{cancel:function(){for(var lt=0;lt<Qe.length;++lt)if(Qe[lt]===We){Qe[lt]=Qe[Qe.length-1],Qe.pop();return}}}}var Ke=r(pt,{clear:vt,prop:Mt.define.bind(null,dc),context:Mt.define.bind(null,Uy),this:Mt.define.bind(null,jy),draw:pt({}),buffer:function(Fe){return ee.create(Fe,$y,!1,!1)},elements:function(Fe){return ge.create(Fe,!1)},texture:Pe.create2D,cube:Pe.createCube,renderbuffer:j.create,framebuffer:$.create,framebufferCube:$.createCube,vao:q.createVAO,attributes:R,frame:gt,on:Et,limits:O,hasExtension:function(Fe){return O.extensions.indexOf(Fe.toLowerCase())>=0},read:ue,destroy:Ze,_gl:_,_refresh:ct,poll:function(){At(),ne&&ne.update()},now:$e,stats:Q});return h.onDone(null,Ke),Ke}return Xy})}(oi)),oi.exports}var qd=Hd();const Wd=go(qd),Yd="#b3b3b3",Zd=void 0,Qd=void 0,Kd=4,Jd="#666666",em=.1,tm=1,nm="#222222",Be={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,arrowSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,arrowLinks:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",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},rm=.7,im=.95,om=3,_s=t=>typeof t=="function",yo=t=>Array.isArray(t),Ss=t=>t instanceof Object,ws=t=>t instanceof Object?t.constructor.name!=="Function"&&t.constructor.name!=="Object":!1,xo=t=>Ss(t)&&!yo(t)&&!_s(t)&&!ws(t);function vn(t){let e;if(yo(t))e=t;else{const n=pn(t),r=n==null?void 0:n.rgb();e=[(r==null?void 0:r.r)||0,(r==null?void 0:r.g)||0,(r==null?void 0:r.b)||0,(n==null?void 0:n.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function Ts(t,e,n){return .2126*t+.7152*e+.0722*n}function un(t,e){let n=new Float32Array;return t({framebuffer:e})(()=>{n=t.read()}),n}function As(t,e,n){return Math.min(Math.max(t,e),n)}function Ht(t){return t!=null&&!Number.isNaN(t)}class am{constructor(){this.enableSimulation=Be.enableSimulation,this.backgroundColor=nm,this.spaceSize=Be.spaceSize,this.pointColor=Yd,this.pointGreyoutOpacity=Zd,this.pointGreyoutColor=Qd,this.pointSize=Kd,this.pointSizeScale=Be.pointSizeScale,this.hoveredPointCursor=Be.hoveredPointCursor,this.renderHoveredPointRing=Be.renderHoveredPointRing,this.hoveredPointRingColor=Be.hoveredPointRingColor,this.focusedPointRingColor=Be.focusedPointRingColor,this.focusedPointIndex=Be.focusedPointIndex,this.linkColor=Jd,this.linkGreyoutOpacity=em,this.linkWidth=tm,this.linkWidthScale=Be.linkWidthScale,this.renderLinks=Be.renderLinks,this.curvedLinks=Be.curvedLinks,this.curvedLinkSegments=Be.curvedLinkSegments,this.curvedLinkWeight=Be.curvedLinkWeight,this.curvedLinkControlPointDistance=Be.curvedLinkControlPointDistance,this.linkArrows=Be.arrowLinks,this.linkArrowsSizeScale=Be.arrowSizeScale,this.scaleLinksOnZoom=Be.scaleLinksOnZoom,this.linkVisibilityDistanceRange=Be.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=Be.linkVisibilityMinTransparency,this.useClassicQuadtree=Be.useClassicQuadtree,this.simulationDecay=Be.simulation.decay,this.simulationGravity=Be.simulation.gravity,this.simulationCenter=Be.simulation.center,this.simulationRepulsion=Be.simulation.repulsion,this.simulationRepulsionTheta=Be.simulation.repulsionTheta,this.simulationRepulsionQuadtreeLevels=Be.simulation.repulsionQuadtreeLevels,this.simulationLinkSpring=Be.simulation.linkSpring,this.simulationLinkDistance=Be.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=Be.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=Be.simulation.repulsionFromMouse,this.enableRightClickRepulsion=Be.enableRightClickRepulsion,this.simulationFriction=Be.simulation.friction,this.simulationCluster=Be.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=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=Be.showFPSMonitor,this.pixelRatio=Be.pixelRatio,this.scalePointsOnZoom=Be.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=Be.enableZoom,this.enableSimulationDuringZoom=Be.enableSimulationDuringZoom,this.enableDrag=Be.enableDrag,this.fitViewOnInit=Be.fitViewOnInit,this.fitViewDelay=Be.fitViewDelay,this.fitViewPadding=Be.fitViewPadding,this.fitViewDuration=Be.fitViewDuration,this.fitViewByPointsInRect=void 0,this.randomSeed=void 0,this.pointSamplingDistance=Be.pointSamplingDistance,this.attribution=Be.attribution,this.rescalePositions=Be.rescalePositions}init(e){Object.keys(e).forEach(n=>{this.deepMergeConfig(this.getConfig(),e,n)})}deepMergeConfig(e,n,r){xo(e[r])&&xo(n[r])?Object.keys(n[r]).forEach(i=>{this.deepMergeConfig(e[r],n[r],i)}):e[r]=n[r]}getConfig(){return this}}class cn{constructor(e,n,r,i,o){this.reglInstance=e,this.config=n,this.store=r,this.data=i,o&&(this.points=o)}}var sm=`#ifdef GL_ES
9
9
  precision highp float;
10
10
  #endif
11
11
 
@@ -168,7 +168,7 @@ void main() {
168
168
 
169
169
  gl_FragColor = vec4(velocity.rg, 0.0, 0.0);
170
170
  }
171
- `}var bo=(t=>(t.OUTGOING="outgoing",t.INCOMING="incoming",t))(bo||{});class Es extends cn{constructor(){super(...arguments),this.linkFirstIndicesAndAmount=new Float32Array,this.indices=new Float32Array,this.maxPointDegree=0}create(e){const{reglInstance:n,store:{pointsTextureSize:r,linksTextureSize:i},data:o}=this;if(!r||!i)return;this.linkFirstIndicesAndAmount=new Float32Array(r*r*4),this.indices=new Float32Array(i*i*4);const f=new Float32Array(i*i*4),s=new Float32Array(i*i*4),u=e==="incoming"?o.sourceIndexToTargetIndices:o.targetIndexToSourceIndices;this.maxPointDegree=0;let c=0;u==null||u.forEach((v,b)=>{v&&(this.linkFirstIndicesAndAmount[b*4+0]=c%i,this.linkFirstIndicesAndAmount[b*4+1]=Math.floor(c/i),this.linkFirstIndicesAndAmount[b*4+2]=v.length??0,v.forEach(([S,D])=>{var q,le,Le;this.indices[c*4+0]=S%r,this.indices[c*4+1]=Math.floor(S/r);const Z=((q=o.degree)==null?void 0:q[S])??0,we=((le=o.degree)==null?void 0:le[b])??0,Se=Z+we,ae=Se!==0?Z/Se:.5,Ne=Math.min(Z,we);let je=((Le=o.linkStrength)==null?void 0:Le[D])??1/Math.max(Ne,1);je=Math.sqrt(je),f[c*4+0]=ae,f[c*4+1]=je,s[c*4]=this.store.getRandomFloat(0,1),c+=1}),this.maxPointDegree=Math.max(this.maxPointDegree,v.length??0))}),this.linkFirstIndicesAndAmountTexture||(this.linkFirstIndicesAndAmountTexture=n.texture()),this.linkFirstIndicesAndAmountTexture({data:this.linkFirstIndicesAndAmount,shape:[r,r,4],type:"float"}),this.linkFirstIndicesAndAmountFbo||(this.linkFirstIndicesAndAmountFbo=n.framebuffer()),this.linkFirstIndicesAndAmountFbo({color:this.linkFirstIndicesAndAmountTexture,depth:!1,stencil:!1}),this.indicesTexture||(this.indicesTexture=n.texture()),this.indicesTexture({data:this.indices,shape:[i,i,4],type:"float"}),this.indicesFbo||(this.indicesFbo=n.framebuffer()),this.indicesFbo({color:this.indicesTexture,depth:!1,stencil:!1}),this.biasAndStrengthTexture||(this.biasAndStrengthTexture=n.texture()),this.biasAndStrengthTexture({data:f,shape:[i,i,4],type:"float"}),this.biasAndStrengthFbo||(this.biasAndStrengthFbo=n.framebuffer()),this.biasAndStrengthFbo({color:this.biasAndStrengthTexture,depth:!1,stencil:!1}),this.randomDistanceTexture||(this.randomDistanceTexture=n.texture()),this.randomDistanceTexture({data:s,shape:[i,i,4],type:"float"}),this.randomDistanceFbo||(this.randomDistanceFbo=n.framebuffer()),this.randomDistanceFbo({color:this.randomDistanceTexture,depth:!1,stencil:!1})}initPrograms(){const{reglInstance:e,config:n,store:r,points:i}=this;this.runCommand||(this.runCommand=e({frag:()=>dm(this.maxPointDegree),vert:bt,framebuffer:()=>i==null?void 0:i.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>i==null?void 0:i.previousPositionFbo,linkSpring:()=>n.simulationLinkSpring,linkDistance:()=>n.simulationLinkDistance,linkDistRandomVariationRange:()=>n.simulationLinkDistRandomVariationRange,linkInfoTexture:()=>this.linkFirstIndicesAndAmountFbo,linkIndicesTexture:()=>this.indicesFbo,linkPropertiesTexture:()=>this.biasAndStrengthFbo,linkRandomDistanceTexture:()=>this.randomDistanceFbo,pointsTextureSize:()=>r.pointsTextureSize,linksTextureSize:()=>r.linksTextureSize,alpha:()=>r.alpha}}))}run(){var e;(e=this.runCommand)==null||e.call(this)}}var Cs=`#ifdef GL_ES
171
+ `}var bo=(t=>(t.OUTGOING="outgoing",t.INCOMING="incoming",t))(bo||{});class Es extends cn{constructor(){super(...arguments),this.linkFirstIndicesAndAmount=new Float32Array,this.indices=new Float32Array,this.maxPointDegree=0}create(e){const{reglInstance:n,store:{pointsTextureSize:r,linksTextureSize:i},data:o}=this;if(!r||!i)return;this.linkFirstIndicesAndAmount=new Float32Array(r*r*4),this.indices=new Float32Array(i*i*4);const f=new Float32Array(i*i*4),s=new Float32Array(i*i*4),u=e==="incoming"?o.sourceIndexToTargetIndices:o.targetIndexToSourceIndices;this.maxPointDegree=0;let c=0;u==null||u.forEach((v,b)=>{v&&(this.linkFirstIndicesAndAmount[b*4+0]=c%i,this.linkFirstIndicesAndAmount[b*4+1]=Math.floor(c/i),this.linkFirstIndicesAndAmount[b*4+2]=v.length??0,v.forEach(([S,D])=>{var W,le,Le;this.indices[c*4+0]=S%r,this.indices[c*4+1]=Math.floor(S/r);const Z=((W=o.degree)==null?void 0:W[S])??0,we=((le=o.degree)==null?void 0:le[b])??0,Se=Z+we,ae=Se!==0?Z/Se:.5,Ge=Math.min(Z,we);let je=((Le=o.linkStrength)==null?void 0:Le[D])??1/Math.max(Ge,1);je=Math.sqrt(je),f[c*4+0]=ae,f[c*4+1]=je,s[c*4]=this.store.getRandomFloat(0,1),c+=1}),this.maxPointDegree=Math.max(this.maxPointDegree,v.length??0))}),this.linkFirstIndicesAndAmountTexture||(this.linkFirstIndicesAndAmountTexture=n.texture()),this.linkFirstIndicesAndAmountTexture({data:this.linkFirstIndicesAndAmount,shape:[r,r,4],type:"float"}),this.linkFirstIndicesAndAmountFbo||(this.linkFirstIndicesAndAmountFbo=n.framebuffer()),this.linkFirstIndicesAndAmountFbo({color:this.linkFirstIndicesAndAmountTexture,depth:!1,stencil:!1}),this.indicesTexture||(this.indicesTexture=n.texture()),this.indicesTexture({data:this.indices,shape:[i,i,4],type:"float"}),this.indicesFbo||(this.indicesFbo=n.framebuffer()),this.indicesFbo({color:this.indicesTexture,depth:!1,stencil:!1}),this.biasAndStrengthTexture||(this.biasAndStrengthTexture=n.texture()),this.biasAndStrengthTexture({data:f,shape:[i,i,4],type:"float"}),this.biasAndStrengthFbo||(this.biasAndStrengthFbo=n.framebuffer()),this.biasAndStrengthFbo({color:this.biasAndStrengthTexture,depth:!1,stencil:!1}),this.randomDistanceTexture||(this.randomDistanceTexture=n.texture()),this.randomDistanceTexture({data:s,shape:[i,i,4],type:"float"}),this.randomDistanceFbo||(this.randomDistanceFbo=n.framebuffer()),this.randomDistanceFbo({color:this.randomDistanceTexture,depth:!1,stencil:!1})}initPrograms(){const{reglInstance:e,config:n,store:r,points:i}=this;this.runCommand||(this.runCommand=e({frag:()=>dm(this.maxPointDegree),vert:bt,framebuffer:()=>i==null?void 0:i.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>i==null?void 0:i.previousPositionFbo,linkSpring:()=>n.simulationLinkSpring,linkDistance:()=>n.simulationLinkDistance,linkDistRandomVariationRange:()=>n.simulationLinkDistRandomVariationRange,linkInfoTexture:()=>this.linkFirstIndicesAndAmountFbo,linkIndicesTexture:()=>this.indicesFbo,linkPropertiesTexture:()=>this.biasAndStrengthFbo,linkRandomDistanceTexture:()=>this.randomDistanceFbo,pointsTextureSize:()=>r.pointsTextureSize,linksTextureSize:()=>r.linksTextureSize,alpha:()=>r.alpha}}))}run(){var e;(e=this.runCommand)==null||e.call(this)}}var Cs=`#ifdef GL_ES
172
172
  precision highp float;
173
173
  #endif
174
174
 
@@ -606,7 +606,7 @@ void main() {
606
606
  #gl-bench .opacity {
607
607
  stroke: #448844;
608
608
  }
609
- `;class i{constructor(f,s={}){this.css=r,this.svg=n,this.paramLogger=()=>{},this.chartLogger=()=>{},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuAccums=[],this.activeAccums=[],this.chart=new Array(this.chartLen),this.now=()=>performance&&performance.now?performance.now():Date.now(),this.updateUI=()=>{[].forEach.call(this.nodes["gl-gpu-svg"],S=>{S.style.display=this.trackGPU?"inline":"none"})},Object.assign(this,s),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let u,c=0,v,b=S=>{++c<20?u=requestAnimationFrame(b):(this.detected=Math.ceil(1e3*c/(S-v)/70),cancelAnimationFrame(u)),v||(v=S)};if(requestAnimationFrame(b),f){const S=async(Z,we)=>Promise.resolve(setTimeout(()=>{f.getError();const Se=this.now()-Z;we.forEach((ae,Ne)=>{ae&&(this.gpuAccums[Ne]+=Se)})},0)),D=(Z,we,Se)=>function(){const ae=we.now();Z.apply(Se,arguments),we.trackGPU&&we.finished.push(S(ae,we.activeAccums.slice(0)))};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach(Z=>{f[Z]&&(f[Z]=D(f[Z],this,f))}),f.getExtension=((Z,we)=>function(){let Se=Z.apply(f,arguments);return Se&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach(ae=>{Se[ae]&&(Se[ae]=D(Se[ae],we,Se))}),Se})(f.getExtension,this)}if(!this.withoutUI){this.dom||(this.dom=document.body);let S=document.createElement("div");S.id="gl-bench",this.dom.appendChild(S),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=S,this.dom.addEventListener("click",()=>{this.trackGPU=!this.trackGPU,this.updateUI()}),this.paramLogger=((D,Z,we)=>{const Se=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],ae=Object.assign({},Se);return Se.forEach(Ne=>ae[Ne]=Z.getElementsByClassName(Ne)),this.nodes=ae,(Ne,je,q,le,Le,Me,Xe)=>{ae["gl-cpu"][Ne].style.strokeDasharray=(je*.27).toFixed(0)+" 100",ae["gl-gpu"][Ne].style.strokeDasharray=(q*.27).toFixed(0)+" 100",ae["gl-mem"][Ne].innerHTML=we[Ne]?we[Ne]:le?"mem: "+le.toFixed(0)+"mb":"",ae["gl-fps"][Ne].innerHTML=Le.toFixed(0)+" FPS",D(we[Ne],je,q,le,Le,Me,Xe)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((D,Z)=>{let we={"gl-chart":Z.getElementsByClassName("gl-chart")};return(Se,ae,Ne)=>{let je="",q=ae.length;for(let le=0;le<q;le++){let Le=(Ne+le+1)%q;ae[Le]!=null&&(je=je+" "+(55*le/(q-1)).toFixed(1)+","+(45-ae[Le]*22/60/this.detected).toFixed(1))}we["gl-chart"][Se].setAttribute("points",je),D(this.names[Se],ae,Ne)}})(this.chartLogger,this.dom)}}addUI(f){this.names.indexOf(f)==-1&&(this.names.push(f),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(f){this.frameId++;const s=f||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=s;else{let u=s-this.paramTime;if(u>=1e3){const c=this.frameId-this.paramFrame,v=c/u*1e3;for(let b=0;b<this.names.length;b++){const S=this.cpuAccums[b]/u*100,D=this.gpuAccums[b]/u*100,Z=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(b,S,D,Z,v,u,c),this.cpuAccums[b]=0,Promise.all(this.finished).then(()=>{this.gpuAccums[b]=0,this.finished=[]})}this.paramFrame=this.frameId,this.paramTime=s}}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=s,this.circularId=0;else{let u=s-this.chartTime,c=this.chartHz*u/1e3;for(;--c>0&&this.detected;){const b=(this.frameId-this.chartFrame)/u*1e3;this.chart[this.circularId%this.chartLen]=b;for(let S=0;S<this.names.length;S++)this.chartLogger(S,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=s}}}begin(f){this.updateAccums(f)}end(f){this.updateAccums(f)}updateAccums(f){let s=this.names.indexOf(f);s==-1&&(s=this.names.length,this.addUI(f));const u=this.now(),c=u-this.t0;for(let v=0;v<s+1;v++)this.activeAccums[v]&&(this.cpuAccums[v]+=c);this.activeAccums[s]=!this.activeAccums[s],this.t0=u}}return i})}(ai)),ai.exports}var Cm=Em();const Pm=go(Cm),km=`
609
+ `;class i{constructor(f,s={}){this.css=r,this.svg=n,this.paramLogger=()=>{},this.chartLogger=()=>{},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuAccums=[],this.activeAccums=[],this.chart=new Array(this.chartLen),this.now=()=>performance&&performance.now?performance.now():Date.now(),this.updateUI=()=>{[].forEach.call(this.nodes["gl-gpu-svg"],S=>{S.style.display=this.trackGPU?"inline":"none"})},Object.assign(this,s),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let u,c=0,v,b=S=>{++c<20?u=requestAnimationFrame(b):(this.detected=Math.ceil(1e3*c/(S-v)/70),cancelAnimationFrame(u)),v||(v=S)};if(requestAnimationFrame(b),f){const S=async(Z,we)=>Promise.resolve(setTimeout(()=>{f.getError();const Se=this.now()-Z;we.forEach((ae,Ge)=>{ae&&(this.gpuAccums[Ge]+=Se)})},0)),D=(Z,we,Se)=>function(){const ae=we.now();Z.apply(Se,arguments),we.trackGPU&&we.finished.push(S(ae,we.activeAccums.slice(0)))};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach(Z=>{f[Z]&&(f[Z]=D(f[Z],this,f))}),f.getExtension=((Z,we)=>function(){let Se=Z.apply(f,arguments);return Se&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach(ae=>{Se[ae]&&(Se[ae]=D(Se[ae],we,Se))}),Se})(f.getExtension,this)}if(!this.withoutUI){this.dom||(this.dom=document.body);let S=document.createElement("div");S.id="gl-bench",this.dom.appendChild(S),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=S,this.dom.addEventListener("click",()=>{this.trackGPU=!this.trackGPU,this.updateUI()}),this.paramLogger=((D,Z,we)=>{const Se=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],ae=Object.assign({},Se);return Se.forEach(Ge=>ae[Ge]=Z.getElementsByClassName(Ge)),this.nodes=ae,(Ge,je,W,le,Le,Me,Xe)=>{ae["gl-cpu"][Ge].style.strokeDasharray=(je*.27).toFixed(0)+" 100",ae["gl-gpu"][Ge].style.strokeDasharray=(W*.27).toFixed(0)+" 100",ae["gl-mem"][Ge].innerHTML=we[Ge]?we[Ge]:le?"mem: "+le.toFixed(0)+"mb":"",ae["gl-fps"][Ge].innerHTML=Le.toFixed(0)+" FPS",D(we[Ge],je,W,le,Le,Me,Xe)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((D,Z)=>{let we={"gl-chart":Z.getElementsByClassName("gl-chart")};return(Se,ae,Ge)=>{let je="",W=ae.length;for(let le=0;le<W;le++){let Le=(Ge+le+1)%W;ae[Le]!=null&&(je=je+" "+(55*le/(W-1)).toFixed(1)+","+(45-ae[Le]*22/60/this.detected).toFixed(1))}we["gl-chart"][Se].setAttribute("points",je),D(this.names[Se],ae,Ge)}})(this.chartLogger,this.dom)}}addUI(f){this.names.indexOf(f)==-1&&(this.names.push(f),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(f){this.frameId++;const s=f||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=s;else{let u=s-this.paramTime;if(u>=1e3){const c=this.frameId-this.paramFrame,v=c/u*1e3;for(let b=0;b<this.names.length;b++){const S=this.cpuAccums[b]/u*100,D=this.gpuAccums[b]/u*100,Z=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(b,S,D,Z,v,u,c),this.cpuAccums[b]=0,Promise.all(this.finished).then(()=>{this.gpuAccums[b]=0,this.finished=[]})}this.paramFrame=this.frameId,this.paramTime=s}}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=s,this.circularId=0;else{let u=s-this.chartTime,c=this.chartHz*u/1e3;for(;--c>0&&this.detected;){const b=(this.frameId-this.chartFrame)/u*1e3;this.chart[this.circularId%this.chartLen]=b;for(let S=0;S<this.names.length;S++)this.chartLogger(S,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=s}}}begin(f){this.updateAccums(f)}end(f){this.updateAccums(f)}updateAccums(f){let s=this.names.indexOf(f);s==-1&&(s=this.names.length,this.addUI(f));const u=this.now(),c=u-this.t0;for(let v=0;v<s+1;v++)this.activeAccums[v]&&(this.cpuAccums[v]+=c);this.activeAccums[s]=!this.activeAccums[s],this.t0=u}}return i})}(ai)),ai.exports}var Cm=Em();const Pm=go(Cm),km=`
610
610
  #gl-bench {
611
611
  position:absolute;
612
612
  right:0;
@@ -663,9 +663,8 @@ void main() {
663
663
  varying vec4 rgbaColor;
664
664
  varying vec2 pos;
665
665
  varying float arrowLength;
666
- varying float linkWidthArrowWidthRatio;
667
- varying float smoothWidthRatio;
668
666
  varying float useArrow;
667
+ varying float smoothing;
669
668
 
670
669
  float map(float value, float min1, float max1, float min2, float max2) {
671
670
  return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
@@ -674,29 +673,31 @@ float map(float value, float min1, float max1, float min2, float max2) {
674
673
  void main() {
675
674
  float opacity = 1.0;
676
675
  vec3 color = rgbaColor.rgb;
677
- float smoothDelta = smoothWidthRatio / 2.0;
676
+
678
677
  if (useArrow > 0.5) {
679
678
  float end_arrow = 0.5 + arrowLength / 2.0;
680
679
  float start_arrow = end_arrow - arrowLength;
681
- float arrowWidthDelta = linkWidthArrowWidthRatio / 2.0;
682
- float linkOpacity = rgbaColor.a * smoothstep(0.5 - arrowWidthDelta, 0.5 - arrowWidthDelta - smoothDelta, abs(pos.y));
680
+ float arrowWidthDelta = 0.25;
681
+ float linkOpacity = rgbaColor.a * smoothstep(0.5 - arrowWidthDelta, 0.5 - arrowWidthDelta - smoothing / 2.0, abs(pos.y));
683
682
  float arrowOpacity = 1.0;
684
683
  if (pos.x > start_arrow && pos.x < start_arrow + arrowLength) {
685
684
  float xmapped = map(pos.x, start_arrow, end_arrow, 0.0, 1.0);
686
- arrowOpacity = rgbaColor.a * smoothstep(xmapped - smoothDelta, xmapped, map(abs(pos.y), 0.5, 0.0, 0.0, 1.0));
685
+ arrowOpacity = rgbaColor.a * smoothstep(xmapped - smoothing, xmapped, map(abs(pos.y), 0.5, 0.0, 0.0, 1.0));
687
686
  if (linkOpacity != arrowOpacity) {
688
- linkOpacity += arrowOpacity;
687
+ linkOpacity = max(linkOpacity, arrowOpacity);
689
688
  }
690
689
  }
691
690
  opacity = linkOpacity;
692
- } else opacity = rgbaColor.a * smoothstep(0.5, 0.5 - smoothDelta, abs(pos.y));
691
+ } else opacity = rgbaColor.a * smoothstep(0.5, 0.5 - smoothing, abs(pos.y));
693
692
 
694
693
  gl_FragColor = vec4(color, opacity);
695
694
  }`,zm=`precision highp float;
695
+
696
696
  attribute vec2 position, pointA, pointB;
697
697
  attribute vec4 color;
698
698
  attribute float width;
699
699
  attribute float arrow;
700
+
700
701
  uniform sampler2D positionsTexture;
701
702
  uniform sampler2D pointGreyoutStatus;
702
703
  uniform mat3 transformationMatrix;
@@ -705,20 +706,20 @@ uniform float widthScale;
705
706
  uniform float arrowSizeScale;
706
707
  uniform float spaceSize;
707
708
  uniform vec2 screenSize;
708
- uniform float ratio;
709
709
  uniform vec2 linkVisibilityDistanceRange;
710
710
  uniform float linkVisibilityMinTransparency;
711
711
  uniform float greyoutOpacity;
712
712
  uniform float curvedWeight;
713
713
  uniform float curvedLinkControlPointDistance;
714
714
  uniform float curvedLinkSegments;
715
+ uniform bool scaleLinksOnZoom;
716
+ uniform float maxPointSize;
715
717
 
716
718
  varying vec4 rgbaColor;
717
719
  varying vec2 pos;
718
720
  varying float arrowLength;
719
- varying float linkWidthArrowWidthRatio;
720
- varying float smoothWidthRatio;
721
721
  varying float useArrow;
722
+ varying float smoothing;
722
723
 
723
724
  float map(float value, float min1, float max1, float min2, float max2) {
724
725
  return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
@@ -730,6 +731,33 @@ vec2 conicParametricCurve(vec2 A, vec2 B, vec2 ControlPoint, float t, float w) {
730
731
  return divident / divisor;
731
732
  }
732
733
 
734
+ float calculateLinkWidth(float width) {
735
+ float linkWidth;
736
+ if (scaleLinksOnZoom) {
737
+
738
+ linkWidth = width;
739
+ } else {
740
+
741
+ linkWidth = width / transformationMatrix[0][0];
742
+
743
+ linkWidth *= min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
744
+ }
745
+
746
+ if (useArrow > 0.5) {
747
+ return min(linkWidth, (maxPointSize * 2.0) / transformationMatrix[0][0]);
748
+ } else {
749
+ return min(linkWidth, maxPointSize / transformationMatrix[0][0]);
750
+ }
751
+ }
752
+
753
+ float calculateArrowWidth(float arrowWidth) {
754
+ if (scaleLinksOnZoom) {
755
+ return arrowWidth;
756
+ } else {
757
+ return arrowWidth / transformationMatrix[0][0];
758
+ }
759
+ }
760
+
733
761
  void main() {
734
762
  pos = position;
735
763
 
@@ -743,6 +771,8 @@ void main() {
743
771
  vec4 pointPositionB = texture2D(positionsTexture, pointTexturePosB);
744
772
  vec2 a = pointPositionA.xy;
745
773
  vec2 b = pointPositionB.xy;
774
+
775
+
746
776
  vec2 xBasis = b - a;
747
777
  vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
748
778
 
@@ -751,53 +781,72 @@ void main() {
751
781
  float h = curvedLinkControlPointDistance;
752
782
  vec2 controlPoint = (a + b) / 2.0 + yBasis * linkDist * h;
753
783
 
784
+
754
785
  float linkDistPx = linkDist * transformationMatrix[0][0];
755
786
 
787
+
756
788
  float linkWidth = width * widthScale;
757
789
  float k = 2.0;
790
+
758
791
  float arrowWidth = max(5.0, linkWidth * k);
759
792
  arrowWidth *= arrowSizeScale;
760
793
 
761
- float arrowWidthPx = arrowWidth / transformationMatrix[0][0];
794
+
795
+ float arrowWidthPx = calculateArrowWidth(arrowWidth);
796
+
797
+
798
+
799
+
762
800
  arrowLength = min(0.3, (0.866 * arrowWidthPx * 2.0) / linkDist);
763
801
 
764
- float smoothWidth = 2.0;
765
- float arrowExtraWidth = arrowWidth - linkWidth;
766
- linkWidth += smoothWidth / 2.0;
767
802
  useArrow = arrow;
768
803
  if (useArrow > 0.5) {
769
- linkWidth += arrowExtraWidth;
804
+ linkWidth *= 2.0;
770
805
  }
771
- smoothWidthRatio = smoothWidth / linkWidth;
772
- linkWidthArrowWidthRatio = arrowExtraWidth / linkWidth;
773
806
 
774
- float linkWidthPx = linkWidth / transformationMatrix[0][0];
807
+
808
+ float linkWidthPx = calculateLinkWidth(linkWidth);
809
+ float smoothingPx = 0.5 / transformationMatrix[0][0];
810
+ smoothing = smoothingPx / linkWidthPx;
811
+ linkWidthPx += smoothingPx;
775
812
 
776
813
 
777
814
  vec3 rgbColor = color.rgb;
815
+
778
816
  float opacity = color.a * max(linkVisibilityMinTransparency, map(linkDistPx, linkVisibilityDistanceRange.g, linkVisibilityDistanceRange.r, 0.0, 1.0));
779
817
 
818
+
780
819
  if (greyoutStatusA.r > 0.0 || greyoutStatusB.r > 0.0) {
781
820
  opacity *= greyoutOpacity;
782
821
  }
783
822
 
823
+
784
824
  rgbaColor = vec4(rgbColor, opacity);
785
825
 
826
+
786
827
  float t = position.x;
787
828
  float w = curvedWeight;
829
+
788
830
  float tPrev = t - 1.0 / curvedLinkSegments;
789
831
  float tNext = t + 1.0 / curvedLinkSegments;
832
+
790
833
  vec2 pointCurr = conicParametricCurve(a, b, controlPoint, t, w);
834
+
791
835
  vec2 pointPrev = conicParametricCurve(a, b, controlPoint, max(0.0, tPrev), w);
792
836
  vec2 pointNext = conicParametricCurve(a, b, controlPoint, min(tNext, 1.0), w);
837
+
793
838
  vec2 xBasisCurved = pointNext - pointPrev;
794
839
  vec2 yBasisCurved = normalize(vec2(-xBasisCurved.y, xBasisCurved.x));
840
+
795
841
  pointCurr += yBasisCurved * linkWidthPx * position.y;
842
+
843
+
796
844
  vec2 p = 2.0 * pointCurr / spaceSize - 1.0;
797
845
  p *= spaceSize / screenSize;
798
- vec3 final = transformationMatrix * vec3(p, 1);
846
+ vec3 final = transformationMatrix * vec3(p, 1);
847
+
799
848
  gl_Position = vec4(final.rg, 0, 1);
800
- }`;function si(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Im(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Ls(t){let e,n,r;t.length!==2?(e=si,n=(s,u)=>si(t(s),u),r=(s,u)=>t(s)-u):(e=t===si||t===Im?t:Rm,n=t,r=t);function i(s,u,c=0,v=s.length){if(c<v){if(e(u,u)!==0)return v;do{const b=c+v>>>1;n(s[b],u)<0?c=b+1:v=b}while(c<v)}return c}function o(s,u,c=0,v=s.length){if(c<v){if(e(u,u)!==0)return v;do{const b=c+v>>>1;n(s[b],u)<=0?c=b+1:v=b}while(c<v)}return c}function f(s,u,c=0,v=s.length){const b=i(s,u,c,v-1);return b>c&&r(s[b-1],u)>-r(s[b],u)?b-1:b}return{left:i,center:f,right:o}}function Rm(){return 0}function Dm(t){return t===null?NaN:+t}const Mm=Ls(si).right;Ls(Dm).center;function zs(t,e){let n,r;for(const i of t)i!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)));return[n,r]}var _o=Math.sqrt(50),So=Math.sqrt(10),wo=Math.sqrt(2);function Om(t,e,n){var r,i=-1,o,f,s;if(e=+e,t=+t,n=+n,t===e&&n>0)return[t];if((r=e<t)&&(o=t,t=e,e=o),(s=Is(t,e,n))===0||!isFinite(s))return[];if(s>0){let u=Math.round(t/s),c=Math.round(e/s);for(u*s<t&&++u,c*s>e&&--c,f=new Array(o=c-u+1);++i<o;)f[i]=(u+i)*s}else{s=-s;let u=Math.round(t*s),c=Math.round(e*s);for(u/s<t&&++u,c/s>e&&--c,f=new Array(o=c-u+1);++i<o;)f[i]=(u+i)/s}return r&&f.reverse(),f}function Is(t,e,n){var r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),o=r/Math.pow(10,i);return i>=0?(o>=_o?10:o>=So?5:o>=wo?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=_o?10:o>=So?5:o>=wo?2:1)}function Gm(t,e,n){var r=Math.abs(e-t)/Math.max(0,n),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=_o?i*=10:o>=So?i*=5:o>=wo&&(i*=2),e<t?-i:i}function Nm(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,o=new Array(i);++r<i;)o[r]=t+r*n;return o}function Rs(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Bm(t){return function(){return t}}function Vm(t){return+t}var Ds=[0,1];function en(t){return t}function To(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Bm(isNaN(e)?NaN:.5)}function $m(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Um(t,e,n){var r=t[0],i=t[1],o=e[0],f=e[1];return i<r?(r=To(i,r),o=n(f,o)):(r=To(r,i),o=n(o,f)),function(s){return o(r(s))}}function jm(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),f=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++f<r;)i[f]=To(t[f],t[f+1]),o[f]=n(e[f],e[f+1]);return function(s){var u=Mm(t,s,1,r)-1;return o[u](i[u](s))}}function Ms(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Os(){var t=Ds,e=Ds,n=mo,r,i,o,f=en,s,u,c;function v(){var S=Math.min(t.length,e.length);return f!==en&&(f=$m(t[0],t[S-1])),s=S>2?jm:Um,u=c=null,b}function b(S){return S==null||isNaN(S=+S)?o:(u||(u=s(t.map(r),e,n)))(r(f(S)))}return b.invert=function(S){return f(i((c||(c=s(e,t.map(r),Xt)))(S)))},b.domain=function(S){return arguments.length?(t=Array.from(S,Vm),v()):t.slice()},b.range=function(S){return arguments.length?(e=Array.from(S),v()):e.slice()},b.rangeRound=function(S){return e=Array.from(S),n=kh,v()},b.clamp=function(S){return arguments.length?(f=S?!0:en,v()):f!==en},b.interpolate=function(S){return arguments.length?(n=S,v()):n},b.unknown=function(S){return arguments.length?(o=S,b):o},function(S,D){return r=S,i=D,v()}}function Xm(){return Os()(en,en)}function Hm(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function fi(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function qn(t){return t=fi(Math.abs(t)),t?t[1]:NaN}function Wm(t,e){return function(n,r){for(var i=n.length,o=[],f=0,s=t[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),o.push(n.substring(i-=s,i+s)),!((u+=s+1)>r));)s=t[f=(f+1)%t.length];return o.reverse().join(e)}}function qm(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Ym=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ui(t){if(!(e=Ym.exec(t)))throw new Error("invalid format: "+t);var e;return new Ao({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}ui.prototype=Ao.prototype;function Ao(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Ao.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Zm(t){e:for(var e=t.length,n=1,r=-1,i;n<e;++n)switch(t[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+t[n])break e;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var Gs;function Qm(t,e){var n=fi(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(Gs=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,f=r.length;return o===f?r:o>f?r+new Array(o-f+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+fi(t,Math.max(0,e+o-1))[0]}function Ns(t,e){var n=fi(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const Bs={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Hm,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Ns(t*100,e),r:Ns,s:Qm,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Vs(t){return t}var $s=Array.prototype.map,Us=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Km(t){var e=t.grouping===void 0||t.thousands===void 0?Vs:Wm($s.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?Vs:qm($s.call(t.numerals,String)),f=t.percent===void 0?"%":t.percent+"",s=t.minus===void 0?"−":t.minus+"",u=t.nan===void 0?"NaN":t.nan+"";function c(b){b=ui(b);var S=b.fill,D=b.align,Z=b.sign,we=b.symbol,Se=b.zero,ae=b.width,Ne=b.comma,je=b.precision,q=b.trim,le=b.type;le==="n"?(Ne=!0,le="g"):Bs[le]||(je===void 0&&(je=12),q=!0,le="g"),(Se||S==="0"&&D==="=")&&(Se=!0,S="0",D="=");var Le=we==="$"?n:we==="#"&&/[boxX]/.test(le)?"0"+le.toLowerCase():"",Me=we==="$"?r:/[%p]/.test(le)?f:"",Xe=Bs[le],et=/[defgprs%]/.test(le);je=je===void 0?6:/[gprs]/.test(le)?Math.max(1,Math.min(21,je)):Math.max(0,Math.min(20,je));function nt(ke){var it=Le,tt=Me,G,Ae,oe;if(le==="c")tt=Xe(ke)+tt,ke="";else{ke=+ke;var Ce=ke<0||1/ke<0;if(ke=isNaN(ke)?u:Xe(Math.abs(ke),je),q&&(ke=Zm(ke)),Ce&&+ke==0&&Z!=="+"&&(Ce=!1),it=(Ce?Z==="("?Z:s:Z==="-"||Z==="("?"":Z)+it,tt=(le==="s"?Us[8+Gs/3]:"")+tt+(Ce&&Z==="("?")":""),et){for(G=-1,Ae=ke.length;++G<Ae;)if(oe=ke.charCodeAt(G),48>oe||oe>57){tt=(oe===46?i+ke.slice(G+1):ke.slice(G))+tt,ke=ke.slice(0,G);break}}}Ne&&!Se&&(ke=e(ke,1/0));var Ue=it.length+ke.length+tt.length,Be=Ue<ae?new Array(ae-Ue+1).join(S):"";switch(Ne&&Se&&(ke=e(Be+ke,Be.length?ae-tt.length:1/0),Be=""),D){case"<":ke=it+ke+tt+Be;break;case"=":ke=it+Be+ke+tt;break;case"^":ke=Be.slice(0,Ue=Be.length>>1)+it+ke+tt+Be.slice(Ue);break;default:ke=Be+it+ke+tt;break}return o(ke)}return nt.toString=function(){return b+""},nt}function v(b,S){var D=c((b=ui(b),b.type="f",b)),Z=Math.max(-8,Math.min(8,Math.floor(qn(S)/3)))*3,we=Math.pow(10,-Z),Se=Us[8+Z/3];return function(ae){return D(we*ae)+Se}}return{format:c,formatPrefix:v}}var ci,js,Xs;Jm({thousands:",",grouping:[3],currency:["$",""]});function Jm(t){return ci=Km(t),js=ci.format,Xs=ci.formatPrefix,ci}function ep(t){return Math.max(0,-qn(Math.abs(t)))}function tp(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(qn(e)/3)))*3-qn(Math.abs(t)))}function np(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,qn(e)-qn(t))+1}function rp(t,e,n,r){var i=Gm(t,e,n),o;switch(r=ui(r??",f"),r.type){case"s":{var f=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(o=tp(i,f))&&(r.precision=o),Xs(r,f)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=np(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=ep(i))&&(r.precision=o-(r.type==="%")*2);break}}return js(r)}function Hs(t){var e=t.domain;return t.ticks=function(n){var r=e();return Om(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return rp(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,o=r.length-1,f=r[i],s=r[o],u,c,v=10;for(s<f&&(c=f,f=s,s=c,c=i,i=o,o=c);v-- >0;){if(c=Is(f,s,n),c===u)return r[i]=f,r[o]=s,e(r);if(c>0)f=Math.floor(f/c)*c,s=Math.ceil(s/c)*c;else if(c<0)f=Math.ceil(f*c)/c,s=Math.floor(s*c)/c;else break;u=c}return t},t}function Eo(){var t=Xm();return t.copy=function(){return Ms(t,Eo())},Rs.apply(t,arguments),Hs(t)}function Ws(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function ip(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function op(t){return t<0?-t*t:t*t}function ap(t){var e=t(en,en),n=1;function r(){return n===1?t(en,en):n===.5?t(ip,op):t(Ws(n),Ws(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Hs(e)}function qs(){var t=ap(Os());return t.copy=function(){return Ms(t,qs()).exponent(t.exponent())},Rs.apply(t,arguments),t}const sp=t=>{const e=qs().exponent(2).range([0,1]).domain([-1,1]),n=Nm(0,t).map(i=>-.5+i/t);n.push(.5);const r=new Array(n.length*2);return n.forEach((i,o)=>{r[o*2]=[e(i*2),.5],r[o*2+1]=[e(i*2),-.5]}),r};class fp extends cn{initPrograms(){const{reglInstance:e,config:n,store:r}=this;this.drawCurveCommand||(this.drawCurveCommand=e({vert:zm,frag:Lm,attributes:{position:{buffer:()=>this.curveLineBuffer,divisor:0},pointA:{buffer:()=>this.pointsBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*4},pointB:{buffer:()=>this.pointsBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*2,stride:Float32Array.BYTES_PER_ELEMENT*4},color:{buffer:()=>this.colorBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*4},width:{buffer:()=>this.widthBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*1},arrow:{buffer:()=>this.arrowBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*1}},uniforms:{positionsTexture:()=>{var i;return(i=this.points)==null?void 0:i.currentPositionFbo},pointGreyoutStatus:()=>{var i;return(i=this.points)==null?void 0:i.greyoutStatusFbo},transformationMatrix:()=>r.transform,pointsTextureSize:()=>r.pointsTextureSize,pointSizeScale:()=>n.pointSizeScale,widthScale:()=>n.linkWidthScale,arrowSizeScale:()=>n.linkArrowsSizeScale,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,ratio:()=>n.pixelRatio,linkVisibilityDistanceRange:()=>n.linkVisibilityDistanceRange,linkVisibilityMinTransparency:()=>n.linkVisibilityMinTransparency,greyoutOpacity:()=>n.linkGreyoutOpacity,scalePointsOnZoom:()=>n.scalePointsOnZoom,curvedWeight:()=>n.curvedLinkWeight,curvedLinkControlPointDistance:()=>n.curvedLinkControlPointDistance,curvedLinkSegments:()=>n.curvedLinks?n.curvedLinkSegments??$e.curvedLinkSegments:1},cull:{enable:!0,face:"back"},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},count:()=>{var i;return((i=this.curveLineGeometry)==null?void 0:i.length)??0},instances:()=>this.data.linksNumber??0,primitive:"triangle strip"}))}draw(){var e;this.pointsBuffer&&(this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),(e=this.drawCurveCommand)==null||e.call(this))}updatePointsBuffer(){const{reglInstance:e,data:n,store:r}=this;if(n.linksNumber===void 0||n.links===void 0)return;const i=new Float32Array(n.linksNumber*4);for(let o=0;o<n.linksNumber;o++){const f=n.links[o*2],s=n.links[o*2+1],u=f%r.pointsTextureSize,c=Math.floor(f/r.pointsTextureSize),v=s%r.pointsTextureSize,b=Math.floor(s/r.pointsTextureSize),S=o*4;i[S]=u,i[S+1]=c,i[S+2]=v,i[S+3]=b}this.pointsBuffer||(this.pointsBuffer=e.buffer(0)),this.pointsBuffer(i)}updateColor(){const{reglInstance:e,data:n}=this;this.colorBuffer||(this.colorBuffer=e.buffer(0)),this.colorBuffer(n.linkColors??new Float32Array)}updateWidth(){const{reglInstance:e,data:n}=this;this.widthBuffer||(this.widthBuffer=e.buffer(0)),this.widthBuffer(n.linkWidths??new Float32Array)}updateArrow(){const{reglInstance:e,data:n}=this;this.arrowBuffer||(this.arrowBuffer=e.buffer(0)),this.arrowBuffer(n.linkArrows??new Float32Array)}updateCurveLineGeometry(){const{reglInstance:e,config:{curvedLinks:n,curvedLinkSegments:r}}=this;this.curveLineGeometry=sp(n?r??$e.curvedLinkSegments:1),this.curveLineBuffer||(this.curveLineBuffer=e.buffer(0)),this.curveLineBuffer(this.curveLineGeometry)}}var up=`#ifdef GL_ES
849
+ }`;function si(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Im(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Ls(t){let e,n,r;t.length!==2?(e=si,n=(s,u)=>si(t(s),u),r=(s,u)=>t(s)-u):(e=t===si||t===Im?t:Rm,n=t,r=t);function i(s,u,c=0,v=s.length){if(c<v){if(e(u,u)!==0)return v;do{const b=c+v>>>1;n(s[b],u)<0?c=b+1:v=b}while(c<v)}return c}function o(s,u,c=0,v=s.length){if(c<v){if(e(u,u)!==0)return v;do{const b=c+v>>>1;n(s[b],u)<=0?c=b+1:v=b}while(c<v)}return c}function f(s,u,c=0,v=s.length){const b=i(s,u,c,v-1);return b>c&&r(s[b-1],u)>-r(s[b],u)?b-1:b}return{left:i,center:f,right:o}}function Rm(){return 0}function Dm(t){return t===null?NaN:+t}const Mm=Ls(si).right;Ls(Dm).center;function zs(t,e){let n,r;for(const i of t)i!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)));return[n,r]}var _o=Math.sqrt(50),So=Math.sqrt(10),wo=Math.sqrt(2);function Om(t,e,n){var r,i=-1,o,f,s;if(e=+e,t=+t,n=+n,t===e&&n>0)return[t];if((r=e<t)&&(o=t,t=e,e=o),(s=Is(t,e,n))===0||!isFinite(s))return[];if(s>0){let u=Math.round(t/s),c=Math.round(e/s);for(u*s<t&&++u,c*s>e&&--c,f=new Array(o=c-u+1);++i<o;)f[i]=(u+i)*s}else{s=-s;let u=Math.round(t*s),c=Math.round(e*s);for(u/s<t&&++u,c/s>e&&--c,f=new Array(o=c-u+1);++i<o;)f[i]=(u+i)/s}return r&&f.reverse(),f}function Is(t,e,n){var r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),o=r/Math.pow(10,i);return i>=0?(o>=_o?10:o>=So?5:o>=wo?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=_o?10:o>=So?5:o>=wo?2:1)}function Nm(t,e,n){var r=Math.abs(e-t)/Math.max(0,n),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=_o?i*=10:o>=So?i*=5:o>=wo&&(i*=2),e<t?-i:i}function Gm(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,o=new Array(i);++r<i;)o[r]=t+r*n;return o}function Rs(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Bm(t){return function(){return t}}function Vm(t){return+t}var Ds=[0,1];function en(t){return t}function To(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Bm(isNaN(e)?NaN:.5)}function $m(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Um(t,e,n){var r=t[0],i=t[1],o=e[0],f=e[1];return i<r?(r=To(i,r),o=n(f,o)):(r=To(r,i),o=n(o,f)),function(s){return o(r(s))}}function jm(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),f=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++f<r;)i[f]=To(t[f],t[f+1]),o[f]=n(e[f],e[f+1]);return function(s){var u=Mm(t,s,1,r)-1;return o[u](i[u](s))}}function Ms(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Os(){var t=Ds,e=Ds,n=mo,r,i,o,f=en,s,u,c;function v(){var S=Math.min(t.length,e.length);return f!==en&&(f=$m(t[0],t[S-1])),s=S>2?jm:Um,u=c=null,b}function b(S){return S==null||isNaN(S=+S)?o:(u||(u=s(t.map(r),e,n)))(r(f(S)))}return b.invert=function(S){return f(i((c||(c=s(e,t.map(r),Xt)))(S)))},b.domain=function(S){return arguments.length?(t=Array.from(S,Vm),v()):t.slice()},b.range=function(S){return arguments.length?(e=Array.from(S),v()):e.slice()},b.rangeRound=function(S){return e=Array.from(S),n=kh,v()},b.clamp=function(S){return arguments.length?(f=S?!0:en,v()):f!==en},b.interpolate=function(S){return arguments.length?(n=S,v()):n},b.unknown=function(S){return arguments.length?(o=S,b):o},function(S,D){return r=S,i=D,v()}}function Xm(){return Os()(en,en)}function Hm(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function fi(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Wn(t){return t=fi(Math.abs(t)),t?t[1]:NaN}function qm(t,e){return function(n,r){for(var i=n.length,o=[],f=0,s=t[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),o.push(n.substring(i-=s,i+s)),!((u+=s+1)>r));)s=t[f=(f+1)%t.length];return o.reverse().join(e)}}function Wm(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Ym=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ui(t){if(!(e=Ym.exec(t)))throw new Error("invalid format: "+t);var e;return new Ao({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}ui.prototype=Ao.prototype;function Ao(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Ao.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Zm(t){e:for(var e=t.length,n=1,r=-1,i;n<e;++n)switch(t[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+t[n])break e;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var Ns;function Qm(t,e){var n=fi(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(Ns=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,f=r.length;return o===f?r:o>f?r+new Array(o-f+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+fi(t,Math.max(0,e+o-1))[0]}function Gs(t,e){var n=fi(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const Bs={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Hm,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Gs(t*100,e),r:Gs,s:Qm,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Vs(t){return t}var $s=Array.prototype.map,Us=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Km(t){var e=t.grouping===void 0||t.thousands===void 0?Vs:qm($s.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?Vs:Wm($s.call(t.numerals,String)),f=t.percent===void 0?"%":t.percent+"",s=t.minus===void 0?"−":t.minus+"",u=t.nan===void 0?"NaN":t.nan+"";function c(b){b=ui(b);var S=b.fill,D=b.align,Z=b.sign,we=b.symbol,Se=b.zero,ae=b.width,Ge=b.comma,je=b.precision,W=b.trim,le=b.type;le==="n"?(Ge=!0,le="g"):Bs[le]||(je===void 0&&(je=12),W=!0,le="g"),(Se||S==="0"&&D==="=")&&(Se=!0,S="0",D="=");var Le=we==="$"?n:we==="#"&&/[boxX]/.test(le)?"0"+le.toLowerCase():"",Me=we==="$"?r:/[%p]/.test(le)?f:"",Xe=Bs[le],et=/[defgprs%]/.test(le);je=je===void 0?6:/[gprs]/.test(le)?Math.max(1,Math.min(21,je)):Math.max(0,Math.min(20,je));function nt(ke){var it=Le,tt=Me,N,Ae,oe;if(le==="c")tt=Xe(ke)+tt,ke="";else{ke=+ke;var Ce=ke<0||1/ke<0;if(ke=isNaN(ke)?u:Xe(Math.abs(ke),je),W&&(ke=Zm(ke)),Ce&&+ke==0&&Z!=="+"&&(Ce=!1),it=(Ce?Z==="("?Z:s:Z==="-"||Z==="("?"":Z)+it,tt=(le==="s"?Us[8+Ns/3]:"")+tt+(Ce&&Z==="("?")":""),et){for(N=-1,Ae=ke.length;++N<Ae;)if(oe=ke.charCodeAt(N),48>oe||oe>57){tt=(oe===46?i+ke.slice(N+1):ke.slice(N))+tt,ke=ke.slice(0,N);break}}}Ge&&!Se&&(ke=e(ke,1/0));var Ue=it.length+ke.length+tt.length,Ve=Ue<ae?new Array(ae-Ue+1).join(S):"";switch(Ge&&Se&&(ke=e(Ve+ke,Ve.length?ae-tt.length:1/0),Ve=""),D){case"<":ke=it+ke+tt+Ve;break;case"=":ke=it+Ve+ke+tt;break;case"^":ke=Ve.slice(0,Ue=Ve.length>>1)+it+ke+tt+Ve.slice(Ue);break;default:ke=Ve+it+ke+tt;break}return o(ke)}return nt.toString=function(){return b+""},nt}function v(b,S){var D=c((b=ui(b),b.type="f",b)),Z=Math.max(-8,Math.min(8,Math.floor(Wn(S)/3)))*3,we=Math.pow(10,-Z),Se=Us[8+Z/3];return function(ae){return D(we*ae)+Se}}return{format:c,formatPrefix:v}}var ci,js,Xs;Jm({thousands:",",grouping:[3],currency:["$",""]});function Jm(t){return ci=Km(t),js=ci.format,Xs=ci.formatPrefix,ci}function ep(t){return Math.max(0,-Wn(Math.abs(t)))}function tp(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Wn(e)/3)))*3-Wn(Math.abs(t)))}function np(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Wn(e)-Wn(t))+1}function rp(t,e,n,r){var i=Nm(t,e,n),o;switch(r=ui(r??",f"),r.type){case"s":{var f=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(o=tp(i,f))&&(r.precision=o),Xs(r,f)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=np(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=ep(i))&&(r.precision=o-(r.type==="%")*2);break}}return js(r)}function Hs(t){var e=t.domain;return t.ticks=function(n){var r=e();return Om(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return rp(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,o=r.length-1,f=r[i],s=r[o],u,c,v=10;for(s<f&&(c=f,f=s,s=c,c=i,i=o,o=c);v-- >0;){if(c=Is(f,s,n),c===u)return r[i]=f,r[o]=s,e(r);if(c>0)f=Math.floor(f/c)*c,s=Math.ceil(s/c)*c;else if(c<0)f=Math.ceil(f*c)/c,s=Math.floor(s*c)/c;else break;u=c}return t},t}function Eo(){var t=Xm();return t.copy=function(){return Ms(t,Eo())},Rs.apply(t,arguments),Hs(t)}function qs(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function ip(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function op(t){return t<0?-t*t:t*t}function ap(t){var e=t(en,en),n=1;function r(){return n===1?t(en,en):n===.5?t(ip,op):t(qs(n),qs(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Hs(e)}function Ws(){var t=ap(Os());return t.copy=function(){return Ms(t,Ws()).exponent(t.exponent())},Rs.apply(t,arguments),t}const sp=t=>{const e=Ws().exponent(2).range([0,1]).domain([-1,1]),n=Gm(0,t).map(i=>-.5+i/t);n.push(.5);const r=new Array(n.length*2);return n.forEach((i,o)=>{r[o*2]=[e(i*2),.5],r[o*2+1]=[e(i*2),-.5]}),r};class fp extends cn{initPrograms(){const{reglInstance:e,config:n,store:r}=this;this.drawCurveCommand||(this.drawCurveCommand=e({vert:zm,frag:Lm,attributes:{position:{buffer:()=>this.curveLineBuffer,divisor:0},pointA:{buffer:()=>this.pointsBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*4},pointB:{buffer:()=>this.pointsBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*2,stride:Float32Array.BYTES_PER_ELEMENT*4},color:{buffer:()=>this.colorBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*4},width:{buffer:()=>this.widthBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*1},arrow:{buffer:()=>this.arrowBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*1}},uniforms:{positionsTexture:()=>{var i;return(i=this.points)==null?void 0:i.currentPositionFbo},pointGreyoutStatus:()=>{var i;return(i=this.points)==null?void 0:i.greyoutStatusFbo},transformationMatrix:()=>r.transform,pointsTextureSize:()=>r.pointsTextureSize,widthScale:()=>n.linkWidthScale,arrowSizeScale:()=>n.linkArrowsSizeScale,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,linkVisibilityDistanceRange:()=>n.linkVisibilityDistanceRange,linkVisibilityMinTransparency:()=>n.linkVisibilityMinTransparency,greyoutOpacity:()=>n.linkGreyoutOpacity,scaleLinksOnZoom:()=>n.scaleLinksOnZoom,maxPointSize:()=>r.maxPointSize,curvedWeight:()=>n.curvedLinkWeight,curvedLinkControlPointDistance:()=>n.curvedLinkControlPointDistance,curvedLinkSegments:()=>n.curvedLinks?n.curvedLinkSegments??Be.curvedLinkSegments:1},cull:{enable:!0,face:"back"},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},count:()=>{var i;return((i=this.curveLineGeometry)==null?void 0:i.length)??0},instances:()=>this.data.linksNumber??0,primitive:"triangle strip"}))}draw(){var e;this.pointsBuffer&&(this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),(e=this.drawCurveCommand)==null||e.call(this))}updatePointsBuffer(){const{reglInstance:e,data:n,store:r}=this;if(n.linksNumber===void 0||n.links===void 0)return;const i=new Float32Array(n.linksNumber*4);for(let o=0;o<n.linksNumber;o++){const f=n.links[o*2],s=n.links[o*2+1],u=f%r.pointsTextureSize,c=Math.floor(f/r.pointsTextureSize),v=s%r.pointsTextureSize,b=Math.floor(s/r.pointsTextureSize),S=o*4;i[S]=u,i[S+1]=c,i[S+2]=v,i[S+3]=b}this.pointsBuffer||(this.pointsBuffer=e.buffer(0)),this.pointsBuffer(i)}updateColor(){const{reglInstance:e,data:n}=this;this.colorBuffer||(this.colorBuffer=e.buffer(0)),this.colorBuffer(n.linkColors??new Float32Array)}updateWidth(){const{reglInstance:e,data:n}=this;this.widthBuffer||(this.widthBuffer=e.buffer(0)),this.widthBuffer(n.linkWidths??new Float32Array)}updateArrow(){const{reglInstance:e,data:n}=this;this.arrowBuffer||(this.arrowBuffer=e.buffer(0)),this.arrowBuffer(n.linkArrows??new Float32Array)}updateCurveLineGeometry(){const{reglInstance:e,config:{curvedLinks:n,curvedLinkSegments:r}}=this;this.curveLineGeometry=sp(n?r??Be.curvedLinkSegments:1),this.curveLineBuffer||(this.curveLineBuffer=e.buffer(0)),this.curveLineBuffer(this.curveLineGeometry)}}var up=`#ifdef GL_ES
801
850
  precision highp float;
802
851
  #endif
803
852
 
@@ -1199,7 +1248,7 @@ void main() {
1199
1248
  }
1200
1249
 
1201
1250
  gl_FragColor = pointPosition;
1202
- }`;class _p extends cn{updatePositions(){const{reglInstance:e,store:n,data:r,config:{rescalePositions:i,enableSimulation:o}}=this,{pointsTextureSize:f}=n;if(!f||!r.pointPositions||r.pointsNumber===void 0)return;const s=new Float32Array(f*f*4);let u=i;i===void 0&&!o&&(u=!0),this.dontRescale&&(u=!1),u?this.rescaleInitialNodePositions():this.dontRescale||(this.scaleX=void 0,this.scaleY=void 0),this.dontRescale=void 0;for(let c=0;c<r.pointsNumber;++c)s[c*4+0]=r.pointPositions[c*2+0],s[c*4+1]=r.pointPositions[c*2+1],s[c*4+2]=c;this.currentPositionFbo||(this.currentPositionFbo=e.framebuffer()),this.currentPositionFbo({color:e.texture({data:s,shape:[f,f,4],type:"float"}),depth:!1,stencil:!1}),this.previousPositionFbo||(this.previousPositionFbo=e.framebuffer()),this.previousPositionFbo({color:e.texture({data:s,shape:[f,f,4],type:"float"}),depth:!1,stencil:!1}),this.config.enableSimulation&&(this.velocityFbo||(this.velocityFbo=e.framebuffer()),this.velocityFbo({color:e.texture({data:new Float32Array(f*f*4).fill(0),shape:[f,f,4],type:"float"}),depth:!1,stencil:!1})),this.selectedTexture||(this.selectedTexture=e.texture()),this.selectedTexture({data:s,shape:[f,f,4],type:"float"}),this.selectedFbo||(this.selectedFbo=e.framebuffer()),this.selectedFbo({color:this.selectedTexture,depth:!1,stencil:!1}),this.hoveredFbo||(this.hoveredFbo=e.framebuffer()),this.hoveredFbo({shape:[2,2],colorType:"float",depth:!1,stencil:!1}),this.drawPointIndices||(this.drawPointIndices=e.buffer(0)),this.drawPointIndices(Pn(n.pointsTextureSize)),this.hoveredPointIndices||(this.hoveredPointIndices=e.buffer(0)),this.hoveredPointIndices(Pn(n.pointsTextureSize)),this.sampledPointIndices||(this.sampledPointIndices=e.buffer(0)),this.sampledPointIndices(Pn(n.pointsTextureSize)),this.updateGreyoutStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){const{reglInstance:e,config:n,store:r,data:i}=this;n.enableSimulation&&(this.updatePositionCommand||(this.updatePositionCommand=e({frag:yp,vert:bt,framebuffer:()=>this.currentPositionFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>this.previousPositionFbo,velocity:()=>this.velocityFbo,friction:()=>n.simulationFriction,spaceSize:()=>r.adjustedSpaceSize}}))),this.dragPointCommand||(this.dragPointCommand=e({frag:bp,vert:bt,framebuffer:()=>this.currentPositionFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>this.previousPositionFbo,mousePos:()=>r.mousePosition,index:()=>{var o;return((o=r.hoveredPoint)==null?void 0:o.index)??-1}}})),this.drawCommand||(this.drawCommand=e({frag:up,vert:cp,primitive:"points",count:()=>i.pointsNumber??0,attributes:{pointIndices:{buffer:this.drawPointIndices,size:2},size:{buffer:()=>this.sizeBuffer,size:1},color:{buffer:()=>this.colorBuffer,size:4}},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointGreyoutStatus:()=>this.greyoutStatusFbo,ratio:()=>n.pixelRatio,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>r.pointsTextureSize,transformationMatrix:()=>r.transform,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,greyoutOpacity:()=>n.pointGreyoutOpacity??-1,greyoutColor:()=>r.greyoutPointColor,backgroundColor:()=>r.backgroundColor,darkenGreyout:()=>r.darkenGreyout,scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>r.maxPointSize},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}})),this.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionCommand=e({frag:lp,vert:bt,framebuffer:()=>this.selectedFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointSize:()=>this.sizeFbo,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,sizeScale:()=>n.pointSizeScale,transformationMatrix:()=>r.transform,ratio:()=>n.pixelRatio,"selection[0]":()=>r.selectedArea[0],"selection[1]":()=>r.selectedArea[1],scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>r.maxPointSize}})),this.clearHoveredFboCommand||(this.clearHoveredFboCommand=e({frag:kn,vert:bt,framebuffer:this.hoveredFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)}})),this.findHoveredPointCommand||(this.findHoveredPointCommand=e({frag:mp,vert:pp,primitive:"points",count:()=>i.pointsNumber??0,framebuffer:()=>this.hoveredFbo,attributes:{pointIndices:{buffer:this.hoveredPointIndices,size:2},size:{buffer:()=>this.sizeBuffer,size:1}},uniforms:{positionsTexture:()=>this.currentPositionFbo,ratio:()=>n.pixelRatio,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>r.pointsTextureSize,transformationMatrix:()=>r.transform,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,scalePointsOnZoom:()=>n.scalePointsOnZoom,mousePosition:()=>r.screenMousePosition,maxPointSize:()=>r.maxPointSize},depth:{enable:!1,mask:!1}})),this.clearSampledPointsFboCommand||(this.clearSampledPointsFboCommand=e({frag:kn,vert:bt,framebuffer:()=>this.sampledPointsFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)}})),this.fillSampledPointsFboCommand||(this.fillSampledPointsFboCommand=e({frag:vp,vert:gp,primitive:"points",count:()=>i.pointsNumber??0,framebuffer:()=>this.sampledPointsFbo,attributes:{pointIndices:{buffer:this.sampledPointIndices,size:2}},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointsTextureSize:()=>r.pointsTextureSize,transformationMatrix:()=>r.transform,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize},depth:{enable:!1,mask:!1}})),this.drawHighlightedCommand||(this.drawHighlightedCommand=e({frag:hp,vert:dp,attributes:{vertexCoord:yt(e)},primitive:"triangle strip",count:4,uniforms:{color:e.prop("color"),width:e.prop("width"),pointIndex:e.prop("pointIndex"),size:e.prop("size"),positionsTexture:()=>this.currentPositionFbo,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>r.pointsTextureSize,transformationMatrix:()=>r.transform,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>r.maxPointSize,pointGreyoutStatusTexture:()=>this.greyoutStatusFbo,greyoutOpacity:()=>n.pointGreyoutOpacity??-1,darkenGreyout:()=>r.darkenGreyout,backgroundColor:()=>r.backgroundColor,greyoutColor:()=>r.greyoutPointColor},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}})),this.trackPointsCommand||(this.trackPointsCommand=e({frag:xp,vert:bt,framebuffer:()=>this.trackedPositionsFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,trackedIndices:()=>this.trackedIndicesFbo,pointsTextureSize:()=>r.pointsTextureSize}}))}updateColor(){const{reglInstance:e,store:{pointsTextureSize:n},data:r}=this;n&&(this.colorBuffer||(this.colorBuffer=e.buffer(0)),this.colorBuffer(r.pointColors))}updateGreyoutStatus(){const{reglInstance:e,store:{selectedIndices:n,pointsTextureSize:r}}=this;if(!r)return;const i=new Float32Array(r*r*4).fill(n?1:0);if(n)for(const o of n)i[o*4]=0;this.greyoutStatusTexture||(this.greyoutStatusTexture=e.texture()),this.greyoutStatusTexture({data:i,width:r,height:r,type:"float"}),this.greyoutStatusFbo||(this.greyoutStatusFbo=e.framebuffer()),this.greyoutStatusFbo({color:this.greyoutStatusTexture,depth:!1,stencil:!1})}updateSize(){const{reglInstance:e,store:{pointsTextureSize:n},data:r}=this;if(!n||r.pointsNumber===void 0||r.pointSizes===void 0)return;this.sizeBuffer||(this.sizeBuffer=e.buffer(0)),this.sizeBuffer(r.pointSizes);const i=new Float32Array(n*n*4);for(let o=0;o<r.pointsNumber;o++)i[o*4]=r.pointSizes[o];this.sizeTexture||(this.sizeTexture=e.texture()),this.sizeTexture({data:i,width:n,height:n,type:"float"}),this.sizeFbo||(this.sizeFbo=e.framebuffer()),this.sizeFbo({color:this.sizeTexture,depth:!1,stencil:!1})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:n},reglInstance:r}=this;let i=n??Math.min(...e)/2;i===0&&(i=$e.pointSamplingDistance);const o=Math.ceil(e[0]/i),f=Math.ceil(e[1]/i);this.sampledPointsFbo||(this.sampledPointsFbo=r.framebuffer()),this.sampledPointsFbo({shape:[o,f],depth:!1,stencil:!1,colorType:"float"})}trackPoints(){var e,n;(e=this.trackedIndices)!=null&&e.length&&((n=this.trackPointsCommand)==null||n.call(this))}draw(){var o,f,s,u,c;const{config:{renderHoveredPointRing:e,pointSize:n},store:r,data:i}=this;this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),(o=this.drawCommand)==null||o.call(this),e&&r.hoveredPoint&&((s=this.drawHighlightedCommand)==null||s.call(this,{width:.85,color:r.hoveredPointRingColor,pointIndex:r.hoveredPoint.index,size:((f=i.pointSizes)==null?void 0:f[r.hoveredPoint.index])??n})),r.focusedPoint&&((c=this.drawHighlightedCommand)==null||c.call(this,{width:.75,color:r.focusedPointRingColor,pointIndex:r.focusedPoint.index,size:((u=i.pointSizes)==null?void 0:u[r.focusedPoint.index])??n}))}updatePosition(){var e;(e=this.updatePositionCommand)==null||e.call(this),this.swapFbo()}drag(){var e;(e=this.dragPointCommand)==null||e.call(this),this.swapFbo()}findPointsOnAreaSelection(){var e;(e=this.findPointsOnAreaSelectionCommand)==null||e.call(this)}findHoveredPoint(){var e,n;(e=this.clearHoveredFboCommand)==null||e.call(this),(n=this.findHoveredPointCommand)==null||n.call(this)}trackPointsByIndices(e){const{store:{pointsTextureSize:n},reglInstance:r}=this;if(this.trackedIndices=e,!(e!=null&&e.length))return;const i=Math.ceil(Math.sqrt(e.length)),o=new Float32Array(i*i*4).fill(-1);for(const[f,s]of e.entries())s!==void 0&&(o[f*4]=s%n,o[f*4+1]=Math.floor(s/n),o[f*4+2]=0,o[f*4+3]=0);this.trackedIndicesTexture||(this.trackedIndicesTexture=r.texture()),this.trackedIndicesTexture({data:o,width:i,height:i,type:"float"}),this.trackedIndicesFbo||(this.trackedIndicesFbo=r.framebuffer()),this.trackedIndicesFbo({color:this.trackedIndicesTexture,depth:!1,stencil:!1}),this.trackedPositionsFbo||(this.trackedPositionsFbo=r.framebuffer()),this.trackedPositionsFbo({shape:[i,i],depth:!1,stencil:!1,colorType:"float"}),this.trackPoints()}getTrackedPositionsMap(){const e=new Map;if(!this.trackedIndices)return e;const n=un(this.reglInstance,this.trackedPositionsFbo);for(let r=0;r<n.length/4;r+=1){const i=n[r*4],o=n[r*4+1],f=this.trackedIndices[r];i!==void 0&&o!==void 0&&f!==void 0&&e.set(f,[i,o])}return e}getSampledPointPositionsMap(){var r,i;const e=new Map;if(!this.sampledPointsFbo)return e;(r=this.clearSampledPointsFboCommand)==null||r.call(this),(i=this.fillSampledPointsFboCommand)==null||i.call(this);const n=un(this.reglInstance,this.sampledPointsFbo);for(let o=0;o<n.length/4;o++){const f=n[o*4],s=!!n[o*4+1],u=n[o*4+2],c=n[o*4+3];s&&f!==void 0&&u!==void 0&&c!==void 0&&e.set(f,[u,c])}return e}swapFbo(){const e=this.previousPositionFbo;this.previousPositionFbo=this.currentPositionFbo,this.currentPositionFbo=e}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const n=this.data.pointPositions,r=n.length/2;let i=1/0,o=-1/0,f=1/0,s=-1/0;for(let Se=0;Se<n.length;Se+=2){const ae=n[Se],Ne=n[Se+1];i=Math.min(i,ae),o=Math.max(o,ae),f=Math.min(f,Ne),s=Math.max(s,Ne)}const u=o-i,c=s-f,v=Math.max(u,c);if(v>e){this.scaleX=void 0,this.scaleY=void 0;return}const b=e*e*.001,D=(r>b?e*Math.max(1.2,Math.sqrt(r)/e):e*.1)/v,Z=(v-u)/2*D,we=(v-c)/2*D;this.scaleX=Se=>(Se-i)*D+Z,this.scaleY=Se=>(Se-f)*D+we;for(let Se=0;Se<r;Se++)this.data.pointPositions[Se*2]=this.scaleX(n[Se*2]),this.data.pointPositions[Se*2+1]=this.scaleY(n[Se*2+1])}}var Ys=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});function Sp(){var t=new Ys(9);return Ys!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function Zs(t,e,n){var r=e[0],i=e[1],o=e[2],f=e[3],s=e[4],u=e[5],c=e[6],v=e[7],b=e[8],S=n[0],D=n[1];return t[0]=r,t[1]=i,t[2]=o,t[3]=f,t[4]=s,t[5]=u,t[6]=S*r+D*f+c,t[7]=S*i+D*s+v,t[8]=S*o+D*u+b,t}function Co(t,e,n){var r=n[0],i=n[1];return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function wp(t,e,n){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/n,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}var li={exports:{}},Tp=li.exports,Qs;function Ap(){return Qs||(Qs=1,function(t){(function(e,n,r){function i(u){var c=this,v=s();c.next=function(){var b=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=b-(c.c=b|0)},c.c=1,c.s0=v(" "),c.s1=v(" "),c.s2=v(" "),c.s0-=v(u),c.s0<0&&(c.s0+=1),c.s1-=v(u),c.s1<0&&(c.s1+=1),c.s2-=v(u),c.s2<0&&(c.s2+=1),v=null}function o(u,c){return c.c=u.c,c.s0=u.s0,c.s1=u.s1,c.s2=u.s2,c}function f(u,c){var v=new i(u),b=c&&c.state,S=v.next;return S.int32=function(){return v.next()*4294967296|0},S.double=function(){return S()+(S()*2097152|0)*11102230246251565e-32},S.quick=S,b&&(typeof b=="object"&&o(b,v),S.state=function(){return o(v,{})}),S}function s(){var u=4022871197,c=function(v){v=String(v);for(var b=0;b<v.length;b++){u+=v.charCodeAt(b);var S=.02519603282416938*u;u=S>>>0,S-=u,S*=u,u=S>>>0,S-=u,u+=S*4294967296}return(u>>>0)*23283064365386963e-26};return c}n&&n.exports?n.exports=f:this.alea=f})(Tp,t)}(li)),li.exports}var hi={exports:{}},Ep=hi.exports,Ks;function Cp(){return Ks||(Ks=1,function(t){(function(e,n,r){function i(s){var u=this,c="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var b=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^b^b>>>8},s===(s|0)?u.x=s:c+=s;for(var v=0;v<c.length+64;v++)u.x^=c.charCodeAt(v)|0,u.next()}function o(s,u){return u.x=s.x,u.y=s.y,u.z=s.z,u.w=s.w,u}function f(s,u){var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(typeof v=="object"&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.xor128=f})(Ep,t)}(hi)),hi.exports}var di={exports:{}},Pp=di.exports,Js;function kp(){return Js||(Js=1,function(t){(function(e,n,r){function i(s){var u=this,c="";u.next=function(){var b=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(b^b<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,s===(s|0)?u.x=s:c+=s;for(var v=0;v<c.length+64;v++)u.x^=c.charCodeAt(v)|0,v==c.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function o(s,u){return u.x=s.x,u.y=s.y,u.z=s.z,u.w=s.w,u.v=s.v,u.d=s.d,u}function f(s,u){var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(typeof v=="object"&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.xorwow=f})(Pp,t)}(di)),di.exports}var mi={exports:{}},Fp=mi.exports,ef;function Lp(){return ef||(ef=1,function(t){(function(e,n,r){function i(s){var u=this;u.next=function(){var v=u.x,b=u.i,S,D;return S=v[b],S^=S>>>7,D=S^S<<24,S=v[b+1&7],D^=S^S>>>10,S=v[b+3&7],D^=S^S>>>3,S=v[b+4&7],D^=S^S<<7,S=v[b+7&7],S=S^S<<13,D^=S^S<<9,v[b]=D,u.i=b+1&7,D};function c(v,b){var S,D=[];if(b===(b|0))D[0]=b;else for(b=""+b,S=0;S<b.length;++S)D[S&7]=D[S&7]<<15^b.charCodeAt(S)+D[S+1&7]<<13;for(;D.length<8;)D.push(0);for(S=0;S<8&&D[S]===0;++S);for(S==8?D[7]=-1:D[S],v.x=D,v.i=0,S=256;S>0;--S)v.next()}c(u,s)}function o(s,u){return u.x=s.x.slice(),u.i=s.i,u}function f(s,u){s==null&&(s=+new Date);var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(v.x&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.xorshift7=f})(Fp,t)}(mi)),mi.exports}var pi={exports:{}},zp=pi.exports,tf;function Ip(){return tf||(tf=1,function(t){(function(e,n,r){function i(s){var u=this;u.next=function(){var v=u.w,b=u.X,S=u.i,D,Z;return u.w=v=v+1640531527|0,Z=b[S+34&127],D=b[S=S+1&127],Z^=Z<<13,D^=D<<17,Z^=Z>>>15,D^=D>>>12,Z=b[S]=Z^D,u.i=S,Z+(v^v>>>16)|0};function c(v,b){var S,D,Z,we,Se,ae=[],Ne=128;for(b===(b|0)?(D=b,b=null):(b=b+"\0",D=0,Ne=Math.max(Ne,b.length)),Z=0,we=-32;we<Ne;++we)b&&(D^=b.charCodeAt((we+32)%b.length)),we===0&&(Se=D),D^=D<<10,D^=D>>>15,D^=D<<4,D^=D>>>13,we>=0&&(Se=Se+1640531527|0,S=ae[we&127]^=D+Se,Z=S==0?Z+1:0);for(Z>=128&&(ae[(b&&b.length||0)&127]=-1),Z=127,we=4*128;we>0;--we)D=ae[Z+34&127],S=ae[Z=Z+1&127],D^=D<<13,S^=S<<17,D^=D>>>15,S^=S>>>12,ae[Z]=D^S;v.w=Se,v.X=ae,v.i=Z}c(u,s)}function o(s,u){return u.i=s.i,u.w=s.w,u.X=s.X.slice(),u}function f(s,u){s==null&&(s=+new Date);var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(v.X&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.xor4096=f})(zp,t)}(pi)),pi.exports}var vi={exports:{}},Rp=vi.exports,nf;function Dp(){return nf||(nf=1,function(t){(function(e,n,r){function i(s){var u=this,c="";u.next=function(){var b=u.b,S=u.c,D=u.d,Z=u.a;return b=b<<25^b>>>7^S,S=S-D|0,D=D<<24^D>>>8^Z,Z=Z-b|0,u.b=b=b<<20^b>>>12^S,u.c=S=S-D|0,u.d=D<<16^S>>>16^Z,u.a=Z-b|0},u.a=0,u.b=0,u.c=-1640531527,u.d=1367130551,s===Math.floor(s)?(u.a=s/4294967296|0,u.b=s|0):c+=s;for(var v=0;v<c.length+20;v++)u.b^=c.charCodeAt(v)|0,u.next()}function o(s,u){return u.a=s.a,u.b=s.b,u.c=s.c,u.d=s.d,u}function f(s,u){var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(typeof v=="object"&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.tychei=f})(Rp,t)}(vi)),vi.exports}var gi={exports:{}};const Mp=jd(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Op=gi.exports,rf;function Gp(){return rf||(rf=1,function(t){(function(e,n,r){var i=256,o=6,f=52,s="random",u=r.pow(i,o),c=r.pow(2,f),v=c*2,b=i-1,S;function D(q,le,Le){var Me=[];le=le==!0?{entropy:!0}:le||{};var Xe=ae(Se(le.entropy?[q,je(n)]:q??Ne(),3),Me),et=new Z(Me),nt=function(){for(var ke=et.g(o),it=u,tt=0;ke<c;)ke=(ke+tt)*i,it*=i,tt=et.g(1);for(;ke>=v;)ke/=2,it/=2,tt>>>=1;return(ke+tt)/it};return nt.int32=function(){return et.g(4)|0},nt.quick=function(){return et.g(4)/4294967296},nt.double=nt,ae(je(et.S),n),(le.pass||Le||function(ke,it,tt,G){return G&&(G.S&&we(G,et),ke.state=function(){return we(et,{})}),tt?(r[s]=ke,it):ke})(nt,Xe,"global"in le?le.global:this==r,le.state)}function Z(q){var le,Le=q.length,Me=this,Xe=0,et=Me.i=Me.j=0,nt=Me.S=[];for(Le||(q=[Le++]);Xe<i;)nt[Xe]=Xe++;for(Xe=0;Xe<i;Xe++)nt[Xe]=nt[et=b&et+q[Xe%Le]+(le=nt[Xe])],nt[et]=le;(Me.g=function(ke){for(var it,tt=0,G=Me.i,Ae=Me.j,oe=Me.S;ke--;)it=oe[G=b&G+1],tt=tt*i+oe[b&(oe[G]=oe[Ae=b&Ae+it])+(oe[Ae]=it)];return Me.i=G,Me.j=Ae,tt})(i)}function we(q,le){return le.i=q.i,le.j=q.j,le.S=q.S.slice(),le}function Se(q,le){var Le=[],Me=typeof q,Xe;if(le&&Me=="object")for(Xe in q)try{Le.push(Se(q[Xe],le-1))}catch{}return Le.length?Le:Me=="string"?q:q+"\0"}function ae(q,le){for(var Le=q+"",Me,Xe=0;Xe<Le.length;)le[b&Xe]=b&(Me^=le[b&Xe]*19)+Le.charCodeAt(Xe++);return je(le)}function Ne(){try{var q;return S&&(q=S.randomBytes)?q=q(i):(q=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(q)),je(q)}catch{var le=e.navigator,Le=le&&le.plugins;return[+new Date,e,Le,e.screen,je(n)]}}function je(q){return String.fromCharCode.apply(0,q)}if(ae(r.random(),n),t.exports){t.exports=D;try{S=Mp}catch{}}else r["seed"+s]=D})(typeof self<"u"?self:Op,[],Math)}(gi)),gi.exports}var Po,of;function Np(){if(of)return Po;of=1;var t=Ap(),e=Cp(),n=kp(),r=Lp(),i=Ip(),o=Dp(),f=Gp();return f.alea=t,f.xor128=e,f.xorwow=n,f.xorshift7=r,f.xor4096=i,f.tychei=o,Po=f,Po}var Bp=Np();const Vp=go(Bp);function $p(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,jp(r.key),r)}}function ko(t,e,n){return e&&$p(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function af(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,Fo(t,e)}function Fo(t,e){return Fo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Fo(t,e)}function Up(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function jp(t){var e=Up(t,"string");return typeof e=="symbol"?e:String(e)}var yi=function(){function t(){}var e=t.prototype;return e._seed=function(r,i){if(r===(r||0))return r;for(var o=""+r,f=0,s=0;s<o.length;++s)f^=o.charCodeAt(s)|0;return f},t}(),sf=function(t){af(e,t);function e(r,i){var o;return o=t.call(this)||this,o._rng=void 0,o.seed(r,i),o}var n=e.prototype;return n.next=function(){return this._rng()},n.seed=function(i,o){this._rng=i},n.clone=function(i,o){return new e(this._rng,o)},ko(e,[{key:"name",get:function(){return"function"}}]),e}(yi),ff=function(){var t=[].slice.call(arguments),e=t,n=e[0],r=n===void 0?"default":n;switch(typeof r){case"object":if(r instanceof yi)return r;break;case"function":return new sf(r);case"number":case"string":default:return new sf(Vp.apply(void 0,t))}throw new Error('invalid RNG "'+r+'"')},Xp=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),function(){return t.next()*(n-e)+e}};function Wt(t){return new Hp(t)}var Hp=function(e){var n=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(n.n))return n;throw new Error("Expected number to be an integer, got "+n.n)},this.isPositive=function(){if(n.n>0)return n;throw new Error("Expected number to be positive, got "+n.n)},this.lessThan=function(r){if(n.n<r)return n;throw new Error("Expected number to be less than "+r+", got "+n.n)},this.greaterThanOrEqual=function(r){if(n.n>=r)return n;throw new Error("Expected number to be greater than or equal to "+r+", got "+n.n)},this.greaterThan=function(r){if(n.n>r)return n;throw new Error("Expected number to be greater than "+r+", got "+n.n)},this.n=e},Wp=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),n===void 0&&(n=e===void 0?1:e,e=0),Wt(e).isInt(),Wt(n).isInt(),function(){return Math.floor(t.next()*(n-e+1)+e)}},qp=function(t){return function(){return t.next()>=.5}},Yp=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),function(){var r,i,o;do r=t.next()*2-1,i=t.next()*2-1,o=r*r+i*i;while(!o||o>1);return e+n*i*Math.sqrt(-2*Math.log(o)/o)}},Zp=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=1);var r=t.normal(e,n);return function(){return Math.exp(r())}},Qp=function(t,e){return e===void 0&&(e=.5),Wt(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(t.next()+e)}},Kp=function(t,e,n){return e===void 0&&(e=1),n===void 0&&(n=.5),Wt(e).isInt().isPositive(),Wt(n).greaterThanOrEqual(0).lessThan(1),function(){for(var r=0,i=0;r++<e;)t.next()<n&&i++;return i}},Jp=function(t,e){e===void 0&&(e=.5),Wt(e).greaterThan(0).lessThan(1);var n=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(t.next())*n)}},e0=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],t0=function(e){return e0[e]},n0=.9189385332046727,r0=function(t,e){if(e===void 0&&(e=1),Wt(e).isPositive(),e<10){var n=Math.exp(-e);return function(){for(var u=n,c=0,v=t.next();v>u;)v=v-u,u=e*u/++c;return c}}else{var r=Math.sqrt(e),i=.931+2.53*r,o=-.059+.02483*i,f=1.1239+1.1328/(i-3.4),s=.9277-3.6224/(i-2);return function(){for(;;){var u=void 0,c=t.next();if(c<=.86*s)return u=c/s-.43,Math.floor((2*o/(.5-Math.abs(u))+i)*u+e+.445);c>=s?u=t.next()-.5:(u=c/s-.93,u=(u<0?-.5:.5)-u,c=t.next()*s);var v=.5-Math.abs(u);if(!(v<.013&&c>v)){var b=Math.floor((2*o/v+i)*u+e+.445);if(c=c*f/(o/(v*v)+i),b>=10){var S=(b+.5)*Math.log(e/b)-e-n0+b-(.08333333333333333-(.002777777777777778-1/(1260*b*b))/(b*b))/b;if(Math.log(c*r)<=S)return b}else if(b>=0){var D,Z=(D=t0(b))!=null?D:0;if(Math.log(c)<=b*Math.log(e)-e-Z)return b}}}}}},i0=function(t,e){return e===void 0&&(e=1),Wt(e).isPositive(),function(){return-Math.log(1-t.next())/e}},o0=function(t,e){return e===void 0&&(e=1),Wt(e).isInt().greaterThanOrEqual(0),function(){for(var n=0,r=0;r<e;++r)n+=t.next();return n}},a0=function(t,e){e===void 0&&(e=1),Wt(e).isInt().isPositive();var n=t.irwinHall(e);return function(){return n()/e}},s0=function(t,e){e===void 0&&(e=1),Wt(e).greaterThanOrEqual(0);var n=1/e;return function(){return 1/Math.pow(1-t.next(),n)}},f0=function(t){af(e,t);function e(){return t.apply(this,arguments)||this}var n=e.prototype;return n.next=function(){return Math.random()},n.seed=function(i,o){},n.clone=function(){return new e},ko(e,[{key:"name",get:function(){return"default"}}]),e}(yi),uf=function(){function t(n){var r=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return r._rng.next()},this.float=function(i,o){return r.uniform(i,o)()},this.int=function(i,o){return r.uniformInt(i,o)()},this.integer=function(i,o){return r.uniformInt(i,o)()},this.bool=function(){return r.uniformBoolean()()},this.boolean=function(){return r.uniformBoolean()()},this.uniform=function(i,o){return r._memoize("uniform",Xp,i,o)},this.uniformInt=function(i,o){return r._memoize("uniformInt",Wp,i,o)},this.uniformBoolean=function(){return r._memoize("uniformBoolean",qp)},this.normal=function(i,o){return Yp(r,i,o)},this.logNormal=function(i,o){return Zp(r,i,o)},this.bernoulli=function(i){return Qp(r,i)},this.binomial=function(i,o){return Kp(r,i,o)},this.geometric=function(i){return Jp(r,i)},this.poisson=function(i){return r0(r,i)},this.exponential=function(i){return i0(r,i)},this.irwinHall=function(i){return o0(r,i)},this.bates=function(i){return a0(r,i)},this.pareto=function(i){return s0(r,i)},n&&n instanceof yi?this.use(n):this.use(new f0),this._cache={}}var e=t.prototype;return e.clone=function(){var r=[].slice.call(arguments);return r.length?new t(ff.apply(void 0,r)):new t(this.rng.clone())},e.use=function(){this._rng=ff.apply(void 0,[].slice.call(arguments))},e.patch=function(){if(this._patch)throw new Error("Math.random already patched");this._patch=Math.random,Math.random=this.uniform()},e.unpatch=function(){this._patch&&(Math.random=this._patch,delete this._patch)},e.choice=function(r){if(!Array.isArray(r))throw new Error("Random.choice expected input to be an array, got "+typeof r);var i=r==null?void 0:r.length;if(i>0){var o=this.uniformInt(0,i-1)();return r[o]}else return},e._memoize=function(r,i){var o=[].slice.call(arguments,2),f=""+o.join(";"),s=this._cache[r];return(s===void 0||s.key!==f)&&(s={key:f,distribution:i.apply(void 0,[this].concat(o))},this._cache[r]=s),s.distribution},ko(t,[{key:"rng",get:function(){return this._rng}}]),t}();new uf;const Lo=.001,zo=64;class u0{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=Sp(),this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.selectedArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.selectedIndices=null,this.maxPointSize=zo,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.adjustedSpaceSize=$e.spaceSize,this.isSpaceKeyPressed=!1,this.hoveredPointRingColor=[1,1,1,rm],this.focusedPointRingColor=[1,1,1,im],this.greyoutPointColor=[-1,-1,-1,-1],this.darkenGreyout=!1,this.alphaTarget=0,this.scalePointX=Eo(),this.scalePointY=Eo(),this.random=new uf,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(Lo,1/e)}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e;const n=Ts(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",n>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",n>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.darkenGreyout=n<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,n){return this.random.float(e,n)}adjustSpaceSize(e,n){e>=n?(this.adjustedSpaceSize=n/2,console.warn(`The \`spaceSize\` has been reduced to ${this.adjustedSpaceSize} due to WebGL limits`)):this.adjustedSpaceSize=e}updateScreenSize(e,n){const{adjustedSpaceSize:r}=this;this.screenSize=[e,n],this.scalePointX.domain([0,r]).range([(e-r)/2,(e+r)/2]),this.scalePointY.domain([r,0]).range([(n-r)/2,(n+r)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const n=vn(e);this.hoveredPointRingColor[0]=n[0],this.hoveredPointRingColor[1]=n[1],this.hoveredPointRingColor[2]=n[2]}setFocusedPointRingColor(e){const n=vn(e);this.focusedPointRingColor[0]=n[0],this.focusedPointRingColor[1]=n[1],this.focusedPointRingColor[2]=n[2]}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const n=vn(e);this.greyoutPointColor[0]=n[0],this.greyoutPointColor[1]=n[1],this.greyoutPointColor[2]=n[2],this.greyoutPointColor[3]=n[3]}setFocusedPoint(e){e!==void 0?this.focusedPoint={index:e}:this.focusedPoint=void 0}addAlpha(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}const c0={passive:!1},xr={capture:!0,passive:!1};function Io(t){t.stopImmediatePropagation()}function Yn(t){t.preventDefault(),t.stopImmediatePropagation()}function cf(t){var e=t.document.documentElement,n=wt(t).on("dragstart.drag",Yn,xr);"onselectstart"in e?n.on("selectstart.drag",Yn,xr):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function lf(t,e){var n=t.document.documentElement,r=wt(t).on("dragstart.drag",null);e&&(r.on("click.drag",Yn,xr),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const xi=t=>()=>t;function Ro(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:o,x:f,y:s,dx:u,dy:c,dispatch:v}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:f,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:v}})}Ro.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function l0(t){return!t.ctrlKey&&!t.button}function h0(){return this.parentNode}function d0(t,e){return e??{x:t.x,y:t.y}}function m0(){return navigator.maxTouchPoints||"ontouchstart"in this}function p0(){var t=l0,e=h0,n=d0,r=m0,i={},o=Ur("start","drag","end"),f=0,s,u,c,v,b=0;function S(q){q.on("mousedown.drag",D).filter(r).on("touchstart.drag",Se).on("touchmove.drag",ae,c0).on("touchend.drag touchcancel.drag",Ne).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function D(q,le){if(!(v||!t.call(this,q,le))){var Le=je(this,e.call(this,q,le),q,le,"mouse");Le&&(wt(q.view).on("mousemove.drag",Z,xr).on("mouseup.drag",we,xr),cf(q.view),Io(q),c=!1,s=q.clientX,u=q.clientY,Le("start",q))}}function Z(q){if(Yn(q),!c){var le=q.clientX-s,Le=q.clientY-u;c=le*le+Le*Le>b}i.mouse("drag",q)}function we(q){wt(q.view).on("mousemove.drag mouseup.drag",null),lf(q.view,c),Yn(q),i.mouse("end",q)}function Se(q,le){if(t.call(this,q,le)){var Le=q.changedTouches,Me=e.call(this,q,le),Xe=Le.length,et,nt;for(et=0;et<Xe;++et)(nt=je(this,Me,q,le,Le[et].identifier,Le[et]))&&(Io(q),nt("start",q,Le[et]))}}function ae(q){var le=q.changedTouches,Le=le.length,Me,Xe;for(Me=0;Me<Le;++Me)(Xe=i[le[Me].identifier])&&(Yn(q),Xe("drag",q,le[Me]))}function Ne(q){var le=q.changedTouches,Le=le.length,Me,Xe;for(v&&clearTimeout(v),v=setTimeout(function(){v=null},500),Me=0;Me<Le;++Me)(Xe=i[le[Me].identifier])&&(Io(q),Xe("end",q,le[Me]))}function je(q,le,Le,Me,Xe,et){var nt=o.copy(),ke=an(et||Le,le),it,tt,G;if((G=n.call(q,new Ro("beforestart",{sourceEvent:Le,target:S,identifier:Xe,active:f,x:ke[0],y:ke[1],dx:0,dy:0,dispatch:nt}),Me))!=null)return it=G.x-ke[0]||0,tt=G.y-ke[1]||0,function Ae(oe,Ce,Ue){var Be=ke,Ye;switch(oe){case"start":i[Xe]=Ae,Ye=f++;break;case"end":delete i[Xe],--f;case"drag":ke=an(Ue||Ce,le),Ye=f;break}nt.call(oe,q,new Ro(oe,{sourceEvent:Ce,subject:G,target:S,identifier:Xe,active:Ye,x:ke[0]+it,y:ke[1]+tt,dx:ke[0]-Be[0],dy:ke[1]-Be[1],dispatch:nt}),Me)}}return S.filter=function(q){return arguments.length?(t=typeof q=="function"?q:xi(!!q),S):t},S.container=function(q){return arguments.length?(e=typeof q=="function"?q:xi(q),S):e},S.subject=function(q){return arguments.length?(n=typeof q=="function"?q:xi(q),S):n},S.touchable=function(q){return arguments.length?(r=typeof q=="function"?q:xi(!!q),S):r},S.on=function(){var q=o.on.apply(o,arguments);return q===o?S:q},S.clickDistance=function(q){return arguments.length?(b=(q=+q)*q,S):Math.sqrt(b)},S}const bi=t=>()=>t;function v0(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function ln(t,e,n){this.k=t,this.x=e,this.y=n}ln.prototype={constructor:ln,scale:function(t){return t===1?this:new ln(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new ln(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var br=new ln(1,0,0);ln.prototype;function Do(t){t.stopImmediatePropagation()}function _r(t){t.preventDefault(),t.stopImmediatePropagation()}function g0(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function y0(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function hf(){return this.__zoom||br}function x0(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function b0(){return navigator.maxTouchPoints||"ontouchstart"in this}function _0(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],f=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),f>o?(o+f)/2:Math.min(0,o)||Math.max(0,f))}function S0(){var t=g0,e=y0,n=_0,r=x0,i=b0,o=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],s=250,u=Oh,c=Ur("start","zoom","end"),v,b,S,D=500,Z=150,we=0,Se=10;function ae(G){G.property("__zoom",hf).on("wheel.zoom",Xe,{passive:!1}).on("mousedown.zoom",et).on("dblclick.zoom",nt).filter(i).on("touchstart.zoom",ke).on("touchmove.zoom",it).on("touchend.zoom touchcancel.zoom",tt).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}ae.transform=function(G,Ae,oe,Ce){var Ue=G.selection?G.selection():G;Ue.property("__zoom",hf),G!==Ue?le(G,Ae,oe,Ce):Ue.interrupt().each(function(){Le(this,arguments).event(Ce).start().zoom(null,typeof Ae=="function"?Ae.apply(this,arguments):Ae).end()})},ae.scaleBy=function(G,Ae,oe,Ce){ae.scaleTo(G,function(){var Ue=this.__zoom.k,Be=typeof Ae=="function"?Ae.apply(this,arguments):Ae;return Ue*Be},oe,Ce)},ae.scaleTo=function(G,Ae,oe,Ce){ae.transform(G,function(){var Ue=e.apply(this,arguments),Be=this.__zoom,Ye=oe==null?q(Ue):typeof oe=="function"?oe.apply(this,arguments):oe,rt=Be.invert(Ye),ut=typeof Ae=="function"?Ae.apply(this,arguments):Ae;return n(je(Ne(Be,ut),Ye,rt),Ue,f)},oe,Ce)},ae.translateBy=function(G,Ae,oe,Ce){ae.transform(G,function(){return n(this.__zoom.translate(typeof Ae=="function"?Ae.apply(this,arguments):Ae,typeof oe=="function"?oe.apply(this,arguments):oe),e.apply(this,arguments),f)},null,Ce)},ae.translateTo=function(G,Ae,oe,Ce,Ue){ae.transform(G,function(){var Be=e.apply(this,arguments),Ye=this.__zoom,rt=Ce==null?q(Be):typeof Ce=="function"?Ce.apply(this,arguments):Ce;return n(br.translate(rt[0],rt[1]).scale(Ye.k).translate(typeof Ae=="function"?-Ae.apply(this,arguments):-Ae,typeof oe=="function"?-oe.apply(this,arguments):-oe),Be,f)},Ce,Ue)};function Ne(G,Ae){return Ae=Math.max(o[0],Math.min(o[1],Ae)),Ae===G.k?G:new ln(Ae,G.x,G.y)}function je(G,Ae,oe){var Ce=Ae[0]-oe[0]*G.k,Ue=Ae[1]-oe[1]*G.k;return Ce===G.x&&Ue===G.y?G:new ln(G.k,Ce,Ue)}function q(G){return[(+G[0][0]+ +G[1][0])/2,(+G[0][1]+ +G[1][1])/2]}function le(G,Ae,oe,Ce){G.on("start.zoom",function(){Le(this,arguments).event(Ce).start()}).on("interrupt.zoom end.zoom",function(){Le(this,arguments).event(Ce).end()}).tween("zoom",function(){var Ue=this,Be=arguments,Ye=Le(Ue,Be).event(Ce),rt=e.apply(Ue,Be),ut=oe==null?q(rt):typeof oe=="function"?oe.apply(Ue,Be):oe,Bt=Math.max(rt[1][0]-rt[0][0],rt[1][1]-rt[0][1]),_t=Ue.__zoom,It=typeof Ae=="function"?Ae.apply(Ue,Be):Ae,qt=u(_t.invert(ut).concat(Bt/_t.k),It.invert(ut).concat(Bt/It.k));return function(Rt){if(Rt===1)Rt=It;else{var Yt=qt(Rt),Sr=Bt/Yt[2];Rt=new ln(Sr,ut[0]-Yt[0]*Sr,ut[1]-Yt[1]*Sr)}Ye.zoom(null,Rt)}})}function Le(G,Ae,oe){return!oe&&G.__zooming||new Me(G,Ae)}function Me(G,Ae){this.that=G,this.args=Ae,this.active=0,this.sourceEvent=null,this.extent=e.apply(G,Ae),this.taps=0}Me.prototype={event:function(G){return G&&(this.sourceEvent=G),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(G,Ae){return this.mouse&&G!=="mouse"&&(this.mouse[1]=Ae.invert(this.mouse[0])),this.touch0&&G!=="touch"&&(this.touch0[1]=Ae.invert(this.touch0[0])),this.touch1&&G!=="touch"&&(this.touch1[1]=Ae.invert(this.touch1[0])),this.that.__zoom=Ae,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(G){var Ae=wt(this.that).datum();c.call(G,this.that,new v0(G,{sourceEvent:this.sourceEvent,target:ae,transform:this.that.__zoom,dispatch:c}),Ae)}};function Xe(G,...Ae){if(!t.apply(this,arguments))return;var oe=Le(this,Ae).event(G),Ce=this.__zoom,Ue=Math.max(o[0],Math.min(o[1],Ce.k*Math.pow(2,r.apply(this,arguments)))),Be=an(G);if(oe.wheel)(oe.mouse[0][0]!==Be[0]||oe.mouse[0][1]!==Be[1])&&(oe.mouse[1]=Ce.invert(oe.mouse[0]=Be)),clearTimeout(oe.wheel);else{if(Ce.k===Ue)return;oe.mouse=[Be,Ce.invert(Be)],Kr(this),oe.start()}_r(G),oe.wheel=setTimeout(Ye,Z),oe.zoom("mouse",n(je(Ne(Ce,Ue),oe.mouse[0],oe.mouse[1]),oe.extent,f));function Ye(){oe.wheel=null,oe.end()}}function et(G,...Ae){if(S||!t.apply(this,arguments))return;var oe=G.currentTarget,Ce=Le(this,Ae,!0).event(G),Ue=wt(G.view).on("mousemove.zoom",ut,!0).on("mouseup.zoom",Bt,!0),Be=an(G,oe),Ye=G.clientX,rt=G.clientY;cf(G.view),Do(G),Ce.mouse=[Be,this.__zoom.invert(Be)],Kr(this),Ce.start();function ut(_t){if(_r(_t),!Ce.moved){var It=_t.clientX-Ye,qt=_t.clientY-rt;Ce.moved=It*It+qt*qt>we}Ce.event(_t).zoom("mouse",n(je(Ce.that.__zoom,Ce.mouse[0]=an(_t,oe),Ce.mouse[1]),Ce.extent,f))}function Bt(_t){Ue.on("mousemove.zoom mouseup.zoom",null),lf(_t.view,Ce.moved),_r(_t),Ce.event(_t).end()}}function nt(G,...Ae){if(t.apply(this,arguments)){var oe=this.__zoom,Ce=an(G.changedTouches?G.changedTouches[0]:G,this),Ue=oe.invert(Ce),Be=oe.k*(G.shiftKey?.5:2),Ye=n(je(Ne(oe,Be),Ce,Ue),e.apply(this,Ae),f);_r(G),s>0?wt(this).transition().duration(s).call(le,Ye,Ce,G):wt(this).call(ae.transform,Ye,Ce,G)}}function ke(G,...Ae){if(t.apply(this,arguments)){var oe=G.touches,Ce=oe.length,Ue=Le(this,Ae,G.changedTouches.length===Ce).event(G),Be,Ye,rt,ut;for(Do(G),Ye=0;Ye<Ce;++Ye)rt=oe[Ye],ut=an(rt,this),ut=[ut,this.__zoom.invert(ut),rt.identifier],Ue.touch0?!Ue.touch1&&Ue.touch0[2]!==ut[2]&&(Ue.touch1=ut,Ue.taps=0):(Ue.touch0=ut,Be=!0,Ue.taps=1+!!v);v&&(v=clearTimeout(v)),Be&&(Ue.taps<2&&(b=ut[0],v=setTimeout(function(){v=null},D)),Kr(this),Ue.start())}}function it(G,...Ae){if(this.__zooming){var oe=Le(this,Ae).event(G),Ce=G.changedTouches,Ue=Ce.length,Be,Ye,rt,ut;for(_r(G),Be=0;Be<Ue;++Be)Ye=Ce[Be],rt=an(Ye,this),oe.touch0&&oe.touch0[2]===Ye.identifier?oe.touch0[0]=rt:oe.touch1&&oe.touch1[2]===Ye.identifier&&(oe.touch1[0]=rt);if(Ye=oe.that.__zoom,oe.touch1){var Bt=oe.touch0[0],_t=oe.touch0[1],It=oe.touch1[0],qt=oe.touch1[1],Rt=(Rt=It[0]-Bt[0])*Rt+(Rt=It[1]-Bt[1])*Rt,Yt=(Yt=qt[0]-_t[0])*Yt+(Yt=qt[1]-_t[1])*Yt;Ye=Ne(Ye,Math.sqrt(Rt/Yt)),rt=[(Bt[0]+It[0])/2,(Bt[1]+It[1])/2],ut=[(_t[0]+qt[0])/2,(_t[1]+qt[1])/2]}else if(oe.touch0)rt=oe.touch0[0],ut=oe.touch0[1];else return;oe.zoom("touch",n(je(Ye,rt,ut),oe.extent,f))}}function tt(G,...Ae){if(this.__zooming){var oe=Le(this,Ae).event(G),Ce=G.changedTouches,Ue=Ce.length,Be,Ye;for(Do(G),S&&clearTimeout(S),S=setTimeout(function(){S=null},D),Be=0;Be<Ue;++Be)Ye=Ce[Be],oe.touch0&&oe.touch0[2]===Ye.identifier?delete oe.touch0:oe.touch1&&oe.touch1[2]===Ye.identifier&&delete oe.touch1;if(oe.touch1&&!oe.touch0&&(oe.touch0=oe.touch1,delete oe.touch1),oe.touch0)oe.touch0[1]=this.__zoom.invert(oe.touch0[0]);else if(oe.end(),oe.taps===2&&(Ye=an(Ye,this),Math.hypot(b[0]-Ye[0],b[1]-Ye[1])<Se)){var rt=wt(this).on("dblclick.zoom");rt&&rt.apply(this,arguments)}}}return ae.wheelDelta=function(G){return arguments.length?(r=typeof G=="function"?G:bi(+G),ae):r},ae.filter=function(G){return arguments.length?(t=typeof G=="function"?G:bi(!!G),ae):t},ae.touchable=function(G){return arguments.length?(i=typeof G=="function"?G:bi(!!G),ae):i},ae.extent=function(G){return arguments.length?(e=typeof G=="function"?G:bi([[+G[0][0],+G[0][1]],[+G[1][0],+G[1][1]]]),ae):e},ae.scaleExtent=function(G){return arguments.length?(o[0]=+G[0],o[1]=+G[1],ae):[o[0],o[1]]},ae.translateExtent=function(G){return arguments.length?(f[0][0]=+G[0][0],f[1][0]=+G[1][0],f[0][1]=+G[0][1],f[1][1]=+G[1][1],ae):[[f[0][0],f[0][1]],[f[1][0],f[1][1]]]},ae.constrain=function(G){return arguments.length?(n=G,ae):n},ae.duration=function(G){return arguments.length?(s=+G,ae):s},ae.interpolate=function(G){return arguments.length?(u=G,ae):u},ae.on=function(){var G=c.on.apply(c,arguments);return G===c?ae:G},ae.clickDistance=function(G){return arguments.length?(we=(G=+G)*G,ae):Math.sqrt(we)},ae.tapDistance=function(G){return arguments.length?(Se=+G,ae):Se},ae}class w0{constructor(e,n){this.eventTransform=br,this.behavior=S0().scaleExtent([.001,1/0]).on("start",r=>{var o,f;this.isRunning=!0;const i=!!r.sourceEvent;(f=(o=this.config)==null?void 0:o.onZoomStart)==null||f.call(o,r,i)}).on("zoom",r=>{var S,D;this.eventTransform=r.transform;const{eventTransform:{x:i,y:o,k:f},store:{transform:s,screenSize:u}}=this,c=u[0],v=u[1];if(!c||!v)return;wp(s,c,v),Zs(s,s,[i,o]),Co(s,s,[f,f]),Zs(s,s,[c/2,v/2]),Co(s,s,[c/2,v/2]),Co(s,s,[1,-1]);const b=!!r.sourceEvent;(D=(S=this.config)==null?void 0:S.onZoom)==null||D.call(S,r,b)}).on("end",r=>{var o,f;this.isRunning=!1;const i=!!r.sourceEvent;(f=(o=this.config)==null?void 0:o.onZoomEnd)==null||f.call(o,r,i)}),this.isRunning=!1,this.store=e,this.config=n}getTransform(e,n,r=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:i}}=this,o=i[0],f=i[1],s=zs(e.map(ae=>ae[0])),u=zs(e.map(ae=>ae[1]));s[0]=this.store.scaleX(s[0]),s[1]=this.store.scaleX(s[1]),u[0]=this.store.scaleY(u[0]),u[1]=this.store.scaleY(u[1]),s[0]===s[1]&&(s[0]-=.5,s[1]+=.5),u[0]===u[1]&&(u[0]+=.5,u[1]-=.5);const c=o*(1-r*2)/(s[1]-s[0]),v=f*(1-r*2)/(u[0]-u[1]),b=As(n??Math.min(c,v),...this.behavior.scaleExtent()),S=(s[1]+s[0])/2,D=(u[1]+u[0])/2,Z=o/2-S*b,we=f/2-D*b;return br.translate(Z,we).scale(b)}getDistanceToPoint(e){const{x:n,y:r,k:i}=this.eventTransform,o=this.getTransform([e],i),f=n-o.x,s=r-o.y;return Math.sqrt(f*f+s*s)}getMiddlePointTransform(e){const{store:{screenSize:n},eventTransform:{x:r,y:i,k:o}}=this,f=n[0],s=n[1],u=(f/2-r)/o,c=(s/2-i)/o,v=this.store.scaleX(e[0]),b=this.store.scaleY(e[1]),S=(u+v)/2,D=(c+b)/2,Z=1,we=f/2-S*Z,Se=s/2-D*Z;return br.translate(we,Se).scale(Z)}convertScreenToSpacePosition(e){const{eventTransform:{x:n,y:r,k:i},store:{screenSize:o}}=this,f=o[0],s=o[1],u=(e[0]-n)/i,c=(e[1]-r)/i,v=[u,s-c];return v[0]-=(f-this.store.adjustedSpaceSize)/2,v[1]-=(s-this.store.adjustedSpaceSize)/2,v}convertSpaceToScreenPosition(e){const n=this.eventTransform.applyX(this.store.scaleX(e[0])),r=this.eventTransform.applyY(this.store.scaleY(e[1]));return[n,r]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:n},store:{maxPointSize:r},eventTransform:{k:i}}=this;let o=e*2;return n?o*=i:o*=Math.min(5,Math.max(1,i*.01)),Math.min(o,r)/2}}class T0{constructor(e,n){this.isActive=!1,this.behavior=p0().subject(r=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:r.x,y:r.y}:void 0).on("start",r=>{var i,o;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(o=(i=this.config)==null?void 0:i.onDragStart)==null||o.call(i,r))}).on("drag",r=>{var i,o;(o=(i=this.config)==null?void 0:i.onDrag)==null||o.call(i,r)}).on("end",r=>{var i,o;this.isActive=!1,this.store.draggingPointIndex=void 0,(o=(i=this.config)==null?void 0:i.onDragEnd)==null||o.call(i,r)}),this.store=e,this.config=n}}function A0(t){const e=document.createElement("div");return e.style.cssText=`
1251
+ }`;class _p extends cn{updatePositions(){const{reglInstance:e,store:n,data:r,config:{rescalePositions:i,enableSimulation:o}}=this,{pointsTextureSize:f}=n;if(!f||!r.pointPositions||r.pointsNumber===void 0)return;const s=new Float32Array(f*f*4);let u=i;i===void 0&&!o&&(u=!0),this.dontRescale&&(u=!1),u?this.rescaleInitialNodePositions():this.dontRescale||(this.scaleX=void 0,this.scaleY=void 0),this.dontRescale=void 0;for(let c=0;c<r.pointsNumber;++c)s[c*4+0]=r.pointPositions[c*2+0],s[c*4+1]=r.pointPositions[c*2+1],s[c*4+2]=c;this.currentPositionFbo||(this.currentPositionFbo=e.framebuffer()),this.currentPositionFbo({color:e.texture({data:s,shape:[f,f,4],type:"float"}),depth:!1,stencil:!1}),this.previousPositionFbo||(this.previousPositionFbo=e.framebuffer()),this.previousPositionFbo({color:e.texture({data:s,shape:[f,f,4],type:"float"}),depth:!1,stencil:!1}),this.config.enableSimulation&&(this.velocityFbo||(this.velocityFbo=e.framebuffer()),this.velocityFbo({color:e.texture({data:new Float32Array(f*f*4).fill(0),shape:[f,f,4],type:"float"}),depth:!1,stencil:!1})),this.selectedTexture||(this.selectedTexture=e.texture()),this.selectedTexture({data:s,shape:[f,f,4],type:"float"}),this.selectedFbo||(this.selectedFbo=e.framebuffer()),this.selectedFbo({color:this.selectedTexture,depth:!1,stencil:!1}),this.hoveredFbo||(this.hoveredFbo=e.framebuffer()),this.hoveredFbo({shape:[2,2],colorType:"float",depth:!1,stencil:!1}),this.drawPointIndices||(this.drawPointIndices=e.buffer(0)),this.drawPointIndices(Pn(n.pointsTextureSize)),this.hoveredPointIndices||(this.hoveredPointIndices=e.buffer(0)),this.hoveredPointIndices(Pn(n.pointsTextureSize)),this.sampledPointIndices||(this.sampledPointIndices=e.buffer(0)),this.sampledPointIndices(Pn(n.pointsTextureSize)),this.updateGreyoutStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){const{reglInstance:e,config:n,store:r,data:i}=this;n.enableSimulation&&(this.updatePositionCommand||(this.updatePositionCommand=e({frag:yp,vert:bt,framebuffer:()=>this.currentPositionFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>this.previousPositionFbo,velocity:()=>this.velocityFbo,friction:()=>n.simulationFriction,spaceSize:()=>r.adjustedSpaceSize}}))),this.dragPointCommand||(this.dragPointCommand=e({frag:bp,vert:bt,framebuffer:()=>this.currentPositionFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>this.previousPositionFbo,mousePos:()=>r.mousePosition,index:()=>{var o;return((o=r.hoveredPoint)==null?void 0:o.index)??-1}}})),this.drawCommand||(this.drawCommand=e({frag:up,vert:cp,primitive:"points",count:()=>i.pointsNumber??0,attributes:{pointIndices:{buffer:this.drawPointIndices,size:2},size:{buffer:()=>this.sizeBuffer,size:1},color:{buffer:()=>this.colorBuffer,size:4}},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointGreyoutStatus:()=>this.greyoutStatusFbo,ratio:()=>n.pixelRatio,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>r.pointsTextureSize,transformationMatrix:()=>r.transform,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,greyoutOpacity:()=>n.pointGreyoutOpacity??-1,greyoutColor:()=>r.greyoutPointColor,backgroundColor:()=>r.backgroundColor,darkenGreyout:()=>r.darkenGreyout,scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>r.maxPointSize},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}})),this.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionCommand=e({frag:lp,vert:bt,framebuffer:()=>this.selectedFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointSize:()=>this.sizeFbo,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,sizeScale:()=>n.pointSizeScale,transformationMatrix:()=>r.transform,ratio:()=>n.pixelRatio,"selection[0]":()=>r.selectedArea[0],"selection[1]":()=>r.selectedArea[1],scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>r.maxPointSize}})),this.clearHoveredFboCommand||(this.clearHoveredFboCommand=e({frag:kn,vert:bt,framebuffer:this.hoveredFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)}})),this.findHoveredPointCommand||(this.findHoveredPointCommand=e({frag:mp,vert:pp,primitive:"points",count:()=>i.pointsNumber??0,framebuffer:()=>this.hoveredFbo,attributes:{pointIndices:{buffer:this.hoveredPointIndices,size:2},size:{buffer:()=>this.sizeBuffer,size:1}},uniforms:{positionsTexture:()=>this.currentPositionFbo,ratio:()=>n.pixelRatio,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>r.pointsTextureSize,transformationMatrix:()=>r.transform,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,scalePointsOnZoom:()=>n.scalePointsOnZoom,mousePosition:()=>r.screenMousePosition,maxPointSize:()=>r.maxPointSize},depth:{enable:!1,mask:!1}})),this.clearSampledPointsFboCommand||(this.clearSampledPointsFboCommand=e({frag:kn,vert:bt,framebuffer:()=>this.sampledPointsFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)}})),this.fillSampledPointsFboCommand||(this.fillSampledPointsFboCommand=e({frag:vp,vert:gp,primitive:"points",count:()=>i.pointsNumber??0,framebuffer:()=>this.sampledPointsFbo,attributes:{pointIndices:{buffer:this.sampledPointIndices,size:2}},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointsTextureSize:()=>r.pointsTextureSize,transformationMatrix:()=>r.transform,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize},depth:{enable:!1,mask:!1}})),this.drawHighlightedCommand||(this.drawHighlightedCommand=e({frag:hp,vert:dp,attributes:{vertexCoord:yt(e)},primitive:"triangle strip",count:4,uniforms:{color:e.prop("color"),width:e.prop("width"),pointIndex:e.prop("pointIndex"),size:e.prop("size"),positionsTexture:()=>this.currentPositionFbo,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>r.pointsTextureSize,transformationMatrix:()=>r.transform,spaceSize:()=>r.adjustedSpaceSize,screenSize:()=>r.screenSize,scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>r.maxPointSize,pointGreyoutStatusTexture:()=>this.greyoutStatusFbo,greyoutOpacity:()=>n.pointGreyoutOpacity??-1,darkenGreyout:()=>r.darkenGreyout,backgroundColor:()=>r.backgroundColor,greyoutColor:()=>r.greyoutPointColor},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}})),this.trackPointsCommand||(this.trackPointsCommand=e({frag:xp,vert:bt,framebuffer:()=>this.trackedPositionsFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:yt(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,trackedIndices:()=>this.trackedIndicesFbo,pointsTextureSize:()=>r.pointsTextureSize}}))}updateColor(){const{reglInstance:e,store:{pointsTextureSize:n},data:r}=this;n&&(this.colorBuffer||(this.colorBuffer=e.buffer(0)),this.colorBuffer(r.pointColors))}updateGreyoutStatus(){const{reglInstance:e,store:{selectedIndices:n,pointsTextureSize:r}}=this;if(!r)return;const i=new Float32Array(r*r*4).fill(n?1:0);if(n)for(const o of n)i[o*4]=0;this.greyoutStatusTexture||(this.greyoutStatusTexture=e.texture()),this.greyoutStatusTexture({data:i,width:r,height:r,type:"float"}),this.greyoutStatusFbo||(this.greyoutStatusFbo=e.framebuffer()),this.greyoutStatusFbo({color:this.greyoutStatusTexture,depth:!1,stencil:!1})}updateSize(){const{reglInstance:e,store:{pointsTextureSize:n},data:r}=this;if(!n||r.pointsNumber===void 0||r.pointSizes===void 0)return;this.sizeBuffer||(this.sizeBuffer=e.buffer(0)),this.sizeBuffer(r.pointSizes);const i=new Float32Array(n*n*4);for(let o=0;o<r.pointsNumber;o++)i[o*4]=r.pointSizes[o];this.sizeTexture||(this.sizeTexture=e.texture()),this.sizeTexture({data:i,width:n,height:n,type:"float"}),this.sizeFbo||(this.sizeFbo=e.framebuffer()),this.sizeFbo({color:this.sizeTexture,depth:!1,stencil:!1})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:n},reglInstance:r}=this;let i=n??Math.min(...e)/2;i===0&&(i=Be.pointSamplingDistance);const o=Math.ceil(e[0]/i),f=Math.ceil(e[1]/i);this.sampledPointsFbo||(this.sampledPointsFbo=r.framebuffer()),this.sampledPointsFbo({shape:[o,f],depth:!1,stencil:!1,colorType:"float"})}trackPoints(){var e,n;(e=this.trackedIndices)!=null&&e.length&&((n=this.trackPointsCommand)==null||n.call(this))}draw(){var o,f,s,u,c;const{config:{renderHoveredPointRing:e,pointSize:n},store:r,data:i}=this;this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),(o=this.drawCommand)==null||o.call(this),e&&r.hoveredPoint&&((s=this.drawHighlightedCommand)==null||s.call(this,{width:.85,color:r.hoveredPointRingColor,pointIndex:r.hoveredPoint.index,size:((f=i.pointSizes)==null?void 0:f[r.hoveredPoint.index])??n})),r.focusedPoint&&((c=this.drawHighlightedCommand)==null||c.call(this,{width:.75,color:r.focusedPointRingColor,pointIndex:r.focusedPoint.index,size:((u=i.pointSizes)==null?void 0:u[r.focusedPoint.index])??n}))}updatePosition(){var e;(e=this.updatePositionCommand)==null||e.call(this),this.swapFbo()}drag(){var e;(e=this.dragPointCommand)==null||e.call(this),this.swapFbo()}findPointsOnAreaSelection(){var e;(e=this.findPointsOnAreaSelectionCommand)==null||e.call(this)}findHoveredPoint(){var e,n;(e=this.clearHoveredFboCommand)==null||e.call(this),(n=this.findHoveredPointCommand)==null||n.call(this)}trackPointsByIndices(e){const{store:{pointsTextureSize:n},reglInstance:r}=this;if(this.trackedIndices=e,!(e!=null&&e.length))return;const i=Math.ceil(Math.sqrt(e.length)),o=new Float32Array(i*i*4).fill(-1);for(const[f,s]of e.entries())s!==void 0&&(o[f*4]=s%n,o[f*4+1]=Math.floor(s/n),o[f*4+2]=0,o[f*4+3]=0);this.trackedIndicesTexture||(this.trackedIndicesTexture=r.texture()),this.trackedIndicesTexture({data:o,width:i,height:i,type:"float"}),this.trackedIndicesFbo||(this.trackedIndicesFbo=r.framebuffer()),this.trackedIndicesFbo({color:this.trackedIndicesTexture,depth:!1,stencil:!1}),this.trackedPositionsFbo||(this.trackedPositionsFbo=r.framebuffer()),this.trackedPositionsFbo({shape:[i,i],depth:!1,stencil:!1,colorType:"float"}),this.trackPoints()}getTrackedPositionsMap(){const e=new Map;if(!this.trackedIndices)return e;const n=un(this.reglInstance,this.trackedPositionsFbo);for(let r=0;r<n.length/4;r+=1){const i=n[r*4],o=n[r*4+1],f=this.trackedIndices[r];i!==void 0&&o!==void 0&&f!==void 0&&e.set(f,[i,o])}return e}getSampledPointPositionsMap(){var r,i;const e=new Map;if(!this.sampledPointsFbo)return e;(r=this.clearSampledPointsFboCommand)==null||r.call(this),(i=this.fillSampledPointsFboCommand)==null||i.call(this);const n=un(this.reglInstance,this.sampledPointsFbo);for(let o=0;o<n.length/4;o++){const f=n[o*4],s=!!n[o*4+1],u=n[o*4+2],c=n[o*4+3];s&&f!==void 0&&u!==void 0&&c!==void 0&&e.set(f,[u,c])}return e}swapFbo(){const e=this.previousPositionFbo;this.previousPositionFbo=this.currentPositionFbo,this.currentPositionFbo=e}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const n=this.data.pointPositions,r=n.length/2;let i=1/0,o=-1/0,f=1/0,s=-1/0;for(let Se=0;Se<n.length;Se+=2){const ae=n[Se],Ge=n[Se+1];i=Math.min(i,ae),o=Math.max(o,ae),f=Math.min(f,Ge),s=Math.max(s,Ge)}const u=o-i,c=s-f,v=Math.max(u,c);if(v>e){this.scaleX=void 0,this.scaleY=void 0;return}const b=e*e*.001,D=(r>b?e*Math.max(1.2,Math.sqrt(r)/e):e*.1)/v,Z=(v-u)/2*D,we=(v-c)/2*D;this.scaleX=Se=>(Se-i)*D+Z,this.scaleY=Se=>(Se-f)*D+we;for(let Se=0;Se<r;Se++)this.data.pointPositions[Se*2]=this.scaleX(n[Se*2]),this.data.pointPositions[Se*2+1]=this.scaleY(n[Se*2+1])}}var Ys=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});function Sp(){var t=new Ys(9);return Ys!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function Zs(t,e,n){var r=e[0],i=e[1],o=e[2],f=e[3],s=e[4],u=e[5],c=e[6],v=e[7],b=e[8],S=n[0],D=n[1];return t[0]=r,t[1]=i,t[2]=o,t[3]=f,t[4]=s,t[5]=u,t[6]=S*r+D*f+c,t[7]=S*i+D*s+v,t[8]=S*o+D*u+b,t}function Co(t,e,n){var r=n[0],i=n[1];return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function wp(t,e,n){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/n,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}var li={exports:{}},Tp=li.exports,Qs;function Ap(){return Qs||(Qs=1,function(t){(function(e,n,r){function i(u){var c=this,v=s();c.next=function(){var b=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=b-(c.c=b|0)},c.c=1,c.s0=v(" "),c.s1=v(" "),c.s2=v(" "),c.s0-=v(u),c.s0<0&&(c.s0+=1),c.s1-=v(u),c.s1<0&&(c.s1+=1),c.s2-=v(u),c.s2<0&&(c.s2+=1),v=null}function o(u,c){return c.c=u.c,c.s0=u.s0,c.s1=u.s1,c.s2=u.s2,c}function f(u,c){var v=new i(u),b=c&&c.state,S=v.next;return S.int32=function(){return v.next()*4294967296|0},S.double=function(){return S()+(S()*2097152|0)*11102230246251565e-32},S.quick=S,b&&(typeof b=="object"&&o(b,v),S.state=function(){return o(v,{})}),S}function s(){var u=4022871197,c=function(v){v=String(v);for(var b=0;b<v.length;b++){u+=v.charCodeAt(b);var S=.02519603282416938*u;u=S>>>0,S-=u,S*=u,u=S>>>0,S-=u,u+=S*4294967296}return(u>>>0)*23283064365386963e-26};return c}n&&n.exports?n.exports=f:this.alea=f})(Tp,t)}(li)),li.exports}var hi={exports:{}},Ep=hi.exports,Ks;function Cp(){return Ks||(Ks=1,function(t){(function(e,n,r){function i(s){var u=this,c="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var b=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^b^b>>>8},s===(s|0)?u.x=s:c+=s;for(var v=0;v<c.length+64;v++)u.x^=c.charCodeAt(v)|0,u.next()}function o(s,u){return u.x=s.x,u.y=s.y,u.z=s.z,u.w=s.w,u}function f(s,u){var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(typeof v=="object"&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.xor128=f})(Ep,t)}(hi)),hi.exports}var di={exports:{}},Pp=di.exports,Js;function kp(){return Js||(Js=1,function(t){(function(e,n,r){function i(s){var u=this,c="";u.next=function(){var b=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(b^b<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,s===(s|0)?u.x=s:c+=s;for(var v=0;v<c.length+64;v++)u.x^=c.charCodeAt(v)|0,v==c.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function o(s,u){return u.x=s.x,u.y=s.y,u.z=s.z,u.w=s.w,u.v=s.v,u.d=s.d,u}function f(s,u){var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(typeof v=="object"&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.xorwow=f})(Pp,t)}(di)),di.exports}var mi={exports:{}},Fp=mi.exports,ef;function Lp(){return ef||(ef=1,function(t){(function(e,n,r){function i(s){var u=this;u.next=function(){var v=u.x,b=u.i,S,D;return S=v[b],S^=S>>>7,D=S^S<<24,S=v[b+1&7],D^=S^S>>>10,S=v[b+3&7],D^=S^S>>>3,S=v[b+4&7],D^=S^S<<7,S=v[b+7&7],S=S^S<<13,D^=S^S<<9,v[b]=D,u.i=b+1&7,D};function c(v,b){var S,D=[];if(b===(b|0))D[0]=b;else for(b=""+b,S=0;S<b.length;++S)D[S&7]=D[S&7]<<15^b.charCodeAt(S)+D[S+1&7]<<13;for(;D.length<8;)D.push(0);for(S=0;S<8&&D[S]===0;++S);for(S==8?D[7]=-1:D[S],v.x=D,v.i=0,S=256;S>0;--S)v.next()}c(u,s)}function o(s,u){return u.x=s.x.slice(),u.i=s.i,u}function f(s,u){s==null&&(s=+new Date);var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(v.x&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.xorshift7=f})(Fp,t)}(mi)),mi.exports}var pi={exports:{}},zp=pi.exports,tf;function Ip(){return tf||(tf=1,function(t){(function(e,n,r){function i(s){var u=this;u.next=function(){var v=u.w,b=u.X,S=u.i,D,Z;return u.w=v=v+1640531527|0,Z=b[S+34&127],D=b[S=S+1&127],Z^=Z<<13,D^=D<<17,Z^=Z>>>15,D^=D>>>12,Z=b[S]=Z^D,u.i=S,Z+(v^v>>>16)|0};function c(v,b){var S,D,Z,we,Se,ae=[],Ge=128;for(b===(b|0)?(D=b,b=null):(b=b+"\0",D=0,Ge=Math.max(Ge,b.length)),Z=0,we=-32;we<Ge;++we)b&&(D^=b.charCodeAt((we+32)%b.length)),we===0&&(Se=D),D^=D<<10,D^=D>>>15,D^=D<<4,D^=D>>>13,we>=0&&(Se=Se+1640531527|0,S=ae[we&127]^=D+Se,Z=S==0?Z+1:0);for(Z>=128&&(ae[(b&&b.length||0)&127]=-1),Z=127,we=4*128;we>0;--we)D=ae[Z+34&127],S=ae[Z=Z+1&127],D^=D<<13,S^=S<<17,D^=D>>>15,S^=S>>>12,ae[Z]=D^S;v.w=Se,v.X=ae,v.i=Z}c(u,s)}function o(s,u){return u.i=s.i,u.w=s.w,u.X=s.X.slice(),u}function f(s,u){s==null&&(s=+new Date);var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(v.X&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.xor4096=f})(zp,t)}(pi)),pi.exports}var vi={exports:{}},Rp=vi.exports,nf;function Dp(){return nf||(nf=1,function(t){(function(e,n,r){function i(s){var u=this,c="";u.next=function(){var b=u.b,S=u.c,D=u.d,Z=u.a;return b=b<<25^b>>>7^S,S=S-D|0,D=D<<24^D>>>8^Z,Z=Z-b|0,u.b=b=b<<20^b>>>12^S,u.c=S=S-D|0,u.d=D<<16^S>>>16^Z,u.a=Z-b|0},u.a=0,u.b=0,u.c=-1640531527,u.d=1367130551,s===Math.floor(s)?(u.a=s/4294967296|0,u.b=s|0):c+=s;for(var v=0;v<c.length+20;v++)u.b^=c.charCodeAt(v)|0,u.next()}function o(s,u){return u.a=s.a,u.b=s.b,u.c=s.c,u.d=s.d,u}function f(s,u){var c=new i(s),v=u&&u.state,b=function(){return(c.next()>>>0)/4294967296};return b.double=function(){do var S=c.next()>>>11,D=(c.next()>>>0)/4294967296,Z=(S+D)/(1<<21);while(Z===0);return Z},b.int32=c.next,b.quick=b,v&&(typeof v=="object"&&o(v,c),b.state=function(){return o(c,{})}),b}n&&n.exports?n.exports=f:this.tychei=f})(Rp,t)}(vi)),vi.exports}var gi={exports:{}};const Mp=jd(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Op=gi.exports,rf;function Np(){return rf||(rf=1,function(t){(function(e,n,r){var i=256,o=6,f=52,s="random",u=r.pow(i,o),c=r.pow(2,f),v=c*2,b=i-1,S;function D(W,le,Le){var Me=[];le=le==!0?{entropy:!0}:le||{};var Xe=ae(Se(le.entropy?[W,je(n)]:W??Ge(),3),Me),et=new Z(Me),nt=function(){for(var ke=et.g(o),it=u,tt=0;ke<c;)ke=(ke+tt)*i,it*=i,tt=et.g(1);for(;ke>=v;)ke/=2,it/=2,tt>>>=1;return(ke+tt)/it};return nt.int32=function(){return et.g(4)|0},nt.quick=function(){return et.g(4)/4294967296},nt.double=nt,ae(je(et.S),n),(le.pass||Le||function(ke,it,tt,N){return N&&(N.S&&we(N,et),ke.state=function(){return we(et,{})}),tt?(r[s]=ke,it):ke})(nt,Xe,"global"in le?le.global:this==r,le.state)}function Z(W){var le,Le=W.length,Me=this,Xe=0,et=Me.i=Me.j=0,nt=Me.S=[];for(Le||(W=[Le++]);Xe<i;)nt[Xe]=Xe++;for(Xe=0;Xe<i;Xe++)nt[Xe]=nt[et=b&et+W[Xe%Le]+(le=nt[Xe])],nt[et]=le;(Me.g=function(ke){for(var it,tt=0,N=Me.i,Ae=Me.j,oe=Me.S;ke--;)it=oe[N=b&N+1],tt=tt*i+oe[b&(oe[N]=oe[Ae=b&Ae+it])+(oe[Ae]=it)];return Me.i=N,Me.j=Ae,tt})(i)}function we(W,le){return le.i=W.i,le.j=W.j,le.S=W.S.slice(),le}function Se(W,le){var Le=[],Me=typeof W,Xe;if(le&&Me=="object")for(Xe in W)try{Le.push(Se(W[Xe],le-1))}catch{}return Le.length?Le:Me=="string"?W:W+"\0"}function ae(W,le){for(var Le=W+"",Me,Xe=0;Xe<Le.length;)le[b&Xe]=b&(Me^=le[b&Xe]*19)+Le.charCodeAt(Xe++);return je(le)}function Ge(){try{var W;return S&&(W=S.randomBytes)?W=W(i):(W=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(W)),je(W)}catch{var le=e.navigator,Le=le&&le.plugins;return[+new Date,e,Le,e.screen,je(n)]}}function je(W){return String.fromCharCode.apply(0,W)}if(ae(r.random(),n),t.exports){t.exports=D;try{S=Mp}catch{}}else r["seed"+s]=D})(typeof self<"u"?self:Op,[],Math)}(gi)),gi.exports}var Po,of;function Gp(){if(of)return Po;of=1;var t=Ap(),e=Cp(),n=kp(),r=Lp(),i=Ip(),o=Dp(),f=Np();return f.alea=t,f.xor128=e,f.xorwow=n,f.xorshift7=r,f.xor4096=i,f.tychei=o,Po=f,Po}var Bp=Gp();const Vp=go(Bp);function $p(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,jp(r.key),r)}}function ko(t,e,n){return e&&$p(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function af(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,Fo(t,e)}function Fo(t,e){return Fo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Fo(t,e)}function Up(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function jp(t){var e=Up(t,"string");return typeof e=="symbol"?e:String(e)}var yi=function(){function t(){}var e=t.prototype;return e._seed=function(r,i){if(r===(r||0))return r;for(var o=""+r,f=0,s=0;s<o.length;++s)f^=o.charCodeAt(s)|0;return f},t}(),sf=function(t){af(e,t);function e(r,i){var o;return o=t.call(this)||this,o._rng=void 0,o.seed(r,i),o}var n=e.prototype;return n.next=function(){return this._rng()},n.seed=function(i,o){this._rng=i},n.clone=function(i,o){return new e(this._rng,o)},ko(e,[{key:"name",get:function(){return"function"}}]),e}(yi),ff=function(){var t=[].slice.call(arguments),e=t,n=e[0],r=n===void 0?"default":n;switch(typeof r){case"object":if(r instanceof yi)return r;break;case"function":return new sf(r);case"number":case"string":default:return new sf(Vp.apply(void 0,t))}throw new Error('invalid RNG "'+r+'"')},Xp=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),function(){return t.next()*(n-e)+e}};function qt(t){return new Hp(t)}var Hp=function(e){var n=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(n.n))return n;throw new Error("Expected number to be an integer, got "+n.n)},this.isPositive=function(){if(n.n>0)return n;throw new Error("Expected number to be positive, got "+n.n)},this.lessThan=function(r){if(n.n<r)return n;throw new Error("Expected number to be less than "+r+", got "+n.n)},this.greaterThanOrEqual=function(r){if(n.n>=r)return n;throw new Error("Expected number to be greater than or equal to "+r+", got "+n.n)},this.greaterThan=function(r){if(n.n>r)return n;throw new Error("Expected number to be greater than "+r+", got "+n.n)},this.n=e},qp=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),n===void 0&&(n=e===void 0?1:e,e=0),qt(e).isInt(),qt(n).isInt(),function(){return Math.floor(t.next()*(n-e+1)+e)}},Wp=function(t){return function(){return t.next()>=.5}},Yp=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),function(){var r,i,o;do r=t.next()*2-1,i=t.next()*2-1,o=r*r+i*i;while(!o||o>1);return e+n*i*Math.sqrt(-2*Math.log(o)/o)}},Zp=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=1);var r=t.normal(e,n);return function(){return Math.exp(r())}},Qp=function(t,e){return e===void 0&&(e=.5),qt(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(t.next()+e)}},Kp=function(t,e,n){return e===void 0&&(e=1),n===void 0&&(n=.5),qt(e).isInt().isPositive(),qt(n).greaterThanOrEqual(0).lessThan(1),function(){for(var r=0,i=0;r++<e;)t.next()<n&&i++;return i}},Jp=function(t,e){e===void 0&&(e=.5),qt(e).greaterThan(0).lessThan(1);var n=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(t.next())*n)}},e0=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],t0=function(e){return e0[e]},n0=.9189385332046727,r0=function(t,e){if(e===void 0&&(e=1),qt(e).isPositive(),e<10){var n=Math.exp(-e);return function(){for(var u=n,c=0,v=t.next();v>u;)v=v-u,u=e*u/++c;return c}}else{var r=Math.sqrt(e),i=.931+2.53*r,o=-.059+.02483*i,f=1.1239+1.1328/(i-3.4),s=.9277-3.6224/(i-2);return function(){for(;;){var u=void 0,c=t.next();if(c<=.86*s)return u=c/s-.43,Math.floor((2*o/(.5-Math.abs(u))+i)*u+e+.445);c>=s?u=t.next()-.5:(u=c/s-.93,u=(u<0?-.5:.5)-u,c=t.next()*s);var v=.5-Math.abs(u);if(!(v<.013&&c>v)){var b=Math.floor((2*o/v+i)*u+e+.445);if(c=c*f/(o/(v*v)+i),b>=10){var S=(b+.5)*Math.log(e/b)-e-n0+b-(.08333333333333333-(.002777777777777778-1/(1260*b*b))/(b*b))/b;if(Math.log(c*r)<=S)return b}else if(b>=0){var D,Z=(D=t0(b))!=null?D:0;if(Math.log(c)<=b*Math.log(e)-e-Z)return b}}}}}},i0=function(t,e){return e===void 0&&(e=1),qt(e).isPositive(),function(){return-Math.log(1-t.next())/e}},o0=function(t,e){return e===void 0&&(e=1),qt(e).isInt().greaterThanOrEqual(0),function(){for(var n=0,r=0;r<e;++r)n+=t.next();return n}},a0=function(t,e){e===void 0&&(e=1),qt(e).isInt().isPositive();var n=t.irwinHall(e);return function(){return n()/e}},s0=function(t,e){e===void 0&&(e=1),qt(e).greaterThanOrEqual(0);var n=1/e;return function(){return 1/Math.pow(1-t.next(),n)}},f0=function(t){af(e,t);function e(){return t.apply(this,arguments)||this}var n=e.prototype;return n.next=function(){return Math.random()},n.seed=function(i,o){},n.clone=function(){return new e},ko(e,[{key:"name",get:function(){return"default"}}]),e}(yi),uf=function(){function t(n){var r=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return r._rng.next()},this.float=function(i,o){return r.uniform(i,o)()},this.int=function(i,o){return r.uniformInt(i,o)()},this.integer=function(i,o){return r.uniformInt(i,o)()},this.bool=function(){return r.uniformBoolean()()},this.boolean=function(){return r.uniformBoolean()()},this.uniform=function(i,o){return r._memoize("uniform",Xp,i,o)},this.uniformInt=function(i,o){return r._memoize("uniformInt",qp,i,o)},this.uniformBoolean=function(){return r._memoize("uniformBoolean",Wp)},this.normal=function(i,o){return Yp(r,i,o)},this.logNormal=function(i,o){return Zp(r,i,o)},this.bernoulli=function(i){return Qp(r,i)},this.binomial=function(i,o){return Kp(r,i,o)},this.geometric=function(i){return Jp(r,i)},this.poisson=function(i){return r0(r,i)},this.exponential=function(i){return i0(r,i)},this.irwinHall=function(i){return o0(r,i)},this.bates=function(i){return a0(r,i)},this.pareto=function(i){return s0(r,i)},n&&n instanceof yi?this.use(n):this.use(new f0),this._cache={}}var e=t.prototype;return e.clone=function(){var r=[].slice.call(arguments);return r.length?new t(ff.apply(void 0,r)):new t(this.rng.clone())},e.use=function(){this._rng=ff.apply(void 0,[].slice.call(arguments))},e.patch=function(){if(this._patch)throw new Error("Math.random already patched");this._patch=Math.random,Math.random=this.uniform()},e.unpatch=function(){this._patch&&(Math.random=this._patch,delete this._patch)},e.choice=function(r){if(!Array.isArray(r))throw new Error("Random.choice expected input to be an array, got "+typeof r);var i=r==null?void 0:r.length;if(i>0){var o=this.uniformInt(0,i-1)();return r[o]}else return},e._memoize=function(r,i){var o=[].slice.call(arguments,2),f=""+o.join(";"),s=this._cache[r];return(s===void 0||s.key!==f)&&(s={key:f,distribution:i.apply(void 0,[this].concat(o))},this._cache[r]=s),s.distribution},ko(t,[{key:"rng",get:function(){return this._rng}}]),t}();new uf;const Lo=.001,zo=64;class u0{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=Sp(),this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.selectedArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.selectedIndices=null,this.maxPointSize=zo,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.adjustedSpaceSize=Be.spaceSize,this.isSpaceKeyPressed=!1,this.hoveredPointRingColor=[1,1,1,rm],this.focusedPointRingColor=[1,1,1,im],this.greyoutPointColor=[-1,-1,-1,-1],this.darkenGreyout=!1,this.alphaTarget=0,this.scalePointX=Eo(),this.scalePointY=Eo(),this.random=new uf,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(Lo,1/e)}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e;const n=Ts(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",n>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",n>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.darkenGreyout=n<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,n){return this.random.float(e,n)}adjustSpaceSize(e,n){e>=n?(this.adjustedSpaceSize=n/2,console.warn(`The \`spaceSize\` has been reduced to ${this.adjustedSpaceSize} due to WebGL limits`)):this.adjustedSpaceSize=e}updateScreenSize(e,n){const{adjustedSpaceSize:r}=this;this.screenSize=[e,n],this.scalePointX.domain([0,r]).range([(e-r)/2,(e+r)/2]),this.scalePointY.domain([r,0]).range([(n-r)/2,(n+r)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const n=vn(e);this.hoveredPointRingColor[0]=n[0],this.hoveredPointRingColor[1]=n[1],this.hoveredPointRingColor[2]=n[2]}setFocusedPointRingColor(e){const n=vn(e);this.focusedPointRingColor[0]=n[0],this.focusedPointRingColor[1]=n[1],this.focusedPointRingColor[2]=n[2]}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const n=vn(e);this.greyoutPointColor[0]=n[0],this.greyoutPointColor[1]=n[1],this.greyoutPointColor[2]=n[2],this.greyoutPointColor[3]=n[3]}setFocusedPoint(e){e!==void 0?this.focusedPoint={index:e}:this.focusedPoint=void 0}addAlpha(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}const c0={passive:!1},xr={capture:!0,passive:!1};function Io(t){t.stopImmediatePropagation()}function Yn(t){t.preventDefault(),t.stopImmediatePropagation()}function cf(t){var e=t.document.documentElement,n=wt(t).on("dragstart.drag",Yn,xr);"onselectstart"in e?n.on("selectstart.drag",Yn,xr):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function lf(t,e){var n=t.document.documentElement,r=wt(t).on("dragstart.drag",null);e&&(r.on("click.drag",Yn,xr),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const xi=t=>()=>t;function Ro(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:o,x:f,y:s,dx:u,dy:c,dispatch:v}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:f,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:v}})}Ro.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function l0(t){return!t.ctrlKey&&!t.button}function h0(){return this.parentNode}function d0(t,e){return e??{x:t.x,y:t.y}}function m0(){return navigator.maxTouchPoints||"ontouchstart"in this}function p0(){var t=l0,e=h0,n=d0,r=m0,i={},o=Ur("start","drag","end"),f=0,s,u,c,v,b=0;function S(W){W.on("mousedown.drag",D).filter(r).on("touchstart.drag",Se).on("touchmove.drag",ae,c0).on("touchend.drag touchcancel.drag",Ge).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function D(W,le){if(!(v||!t.call(this,W,le))){var Le=je(this,e.call(this,W,le),W,le,"mouse");Le&&(wt(W.view).on("mousemove.drag",Z,xr).on("mouseup.drag",we,xr),cf(W.view),Io(W),c=!1,s=W.clientX,u=W.clientY,Le("start",W))}}function Z(W){if(Yn(W),!c){var le=W.clientX-s,Le=W.clientY-u;c=le*le+Le*Le>b}i.mouse("drag",W)}function we(W){wt(W.view).on("mousemove.drag mouseup.drag",null),lf(W.view,c),Yn(W),i.mouse("end",W)}function Se(W,le){if(t.call(this,W,le)){var Le=W.changedTouches,Me=e.call(this,W,le),Xe=Le.length,et,nt;for(et=0;et<Xe;++et)(nt=je(this,Me,W,le,Le[et].identifier,Le[et]))&&(Io(W),nt("start",W,Le[et]))}}function ae(W){var le=W.changedTouches,Le=le.length,Me,Xe;for(Me=0;Me<Le;++Me)(Xe=i[le[Me].identifier])&&(Yn(W),Xe("drag",W,le[Me]))}function Ge(W){var le=W.changedTouches,Le=le.length,Me,Xe;for(v&&clearTimeout(v),v=setTimeout(function(){v=null},500),Me=0;Me<Le;++Me)(Xe=i[le[Me].identifier])&&(Io(W),Xe("end",W,le[Me]))}function je(W,le,Le,Me,Xe,et){var nt=o.copy(),ke=an(et||Le,le),it,tt,N;if((N=n.call(W,new Ro("beforestart",{sourceEvent:Le,target:S,identifier:Xe,active:f,x:ke[0],y:ke[1],dx:0,dy:0,dispatch:nt}),Me))!=null)return it=N.x-ke[0]||0,tt=N.y-ke[1]||0,function Ae(oe,Ce,Ue){var Ve=ke,Ye;switch(oe){case"start":i[Xe]=Ae,Ye=f++;break;case"end":delete i[Xe],--f;case"drag":ke=an(Ue||Ce,le),Ye=f;break}nt.call(oe,W,new Ro(oe,{sourceEvent:Ce,subject:N,target:S,identifier:Xe,active:Ye,x:ke[0]+it,y:ke[1]+tt,dx:ke[0]-Ve[0],dy:ke[1]-Ve[1],dispatch:nt}),Me)}}return S.filter=function(W){return arguments.length?(t=typeof W=="function"?W:xi(!!W),S):t},S.container=function(W){return arguments.length?(e=typeof W=="function"?W:xi(W),S):e},S.subject=function(W){return arguments.length?(n=typeof W=="function"?W:xi(W),S):n},S.touchable=function(W){return arguments.length?(r=typeof W=="function"?W:xi(!!W),S):r},S.on=function(){var W=o.on.apply(o,arguments);return W===o?S:W},S.clickDistance=function(W){return arguments.length?(b=(W=+W)*W,S):Math.sqrt(b)},S}const bi=t=>()=>t;function v0(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function ln(t,e,n){this.k=t,this.x=e,this.y=n}ln.prototype={constructor:ln,scale:function(t){return t===1?this:new ln(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new ln(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var br=new ln(1,0,0);ln.prototype;function Do(t){t.stopImmediatePropagation()}function _r(t){t.preventDefault(),t.stopImmediatePropagation()}function g0(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function y0(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function hf(){return this.__zoom||br}function x0(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function b0(){return navigator.maxTouchPoints||"ontouchstart"in this}function _0(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],f=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),f>o?(o+f)/2:Math.min(0,o)||Math.max(0,f))}function S0(){var t=g0,e=y0,n=_0,r=x0,i=b0,o=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],s=250,u=Oh,c=Ur("start","zoom","end"),v,b,S,D=500,Z=150,we=0,Se=10;function ae(N){N.property("__zoom",hf).on("wheel.zoom",Xe,{passive:!1}).on("mousedown.zoom",et).on("dblclick.zoom",nt).filter(i).on("touchstart.zoom",ke).on("touchmove.zoom",it).on("touchend.zoom touchcancel.zoom",tt).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}ae.transform=function(N,Ae,oe,Ce){var Ue=N.selection?N.selection():N;Ue.property("__zoom",hf),N!==Ue?le(N,Ae,oe,Ce):Ue.interrupt().each(function(){Le(this,arguments).event(Ce).start().zoom(null,typeof Ae=="function"?Ae.apply(this,arguments):Ae).end()})},ae.scaleBy=function(N,Ae,oe,Ce){ae.scaleTo(N,function(){var Ue=this.__zoom.k,Ve=typeof Ae=="function"?Ae.apply(this,arguments):Ae;return Ue*Ve},oe,Ce)},ae.scaleTo=function(N,Ae,oe,Ce){ae.transform(N,function(){var Ue=e.apply(this,arguments),Ve=this.__zoom,Ye=oe==null?W(Ue):typeof oe=="function"?oe.apply(this,arguments):oe,rt=Ve.invert(Ye),ut=typeof Ae=="function"?Ae.apply(this,arguments):Ae;return n(je(Ge(Ve,ut),Ye,rt),Ue,f)},oe,Ce)},ae.translateBy=function(N,Ae,oe,Ce){ae.transform(N,function(){return n(this.__zoom.translate(typeof Ae=="function"?Ae.apply(this,arguments):Ae,typeof oe=="function"?oe.apply(this,arguments):oe),e.apply(this,arguments),f)},null,Ce)},ae.translateTo=function(N,Ae,oe,Ce,Ue){ae.transform(N,function(){var Ve=e.apply(this,arguments),Ye=this.__zoom,rt=Ce==null?W(Ve):typeof Ce=="function"?Ce.apply(this,arguments):Ce;return n(br.translate(rt[0],rt[1]).scale(Ye.k).translate(typeof Ae=="function"?-Ae.apply(this,arguments):-Ae,typeof oe=="function"?-oe.apply(this,arguments):-oe),Ve,f)},Ce,Ue)};function Ge(N,Ae){return Ae=Math.max(o[0],Math.min(o[1],Ae)),Ae===N.k?N:new ln(Ae,N.x,N.y)}function je(N,Ae,oe){var Ce=Ae[0]-oe[0]*N.k,Ue=Ae[1]-oe[1]*N.k;return Ce===N.x&&Ue===N.y?N:new ln(N.k,Ce,Ue)}function W(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function le(N,Ae,oe,Ce){N.on("start.zoom",function(){Le(this,arguments).event(Ce).start()}).on("interrupt.zoom end.zoom",function(){Le(this,arguments).event(Ce).end()}).tween("zoom",function(){var Ue=this,Ve=arguments,Ye=Le(Ue,Ve).event(Ce),rt=e.apply(Ue,Ve),ut=oe==null?W(rt):typeof oe=="function"?oe.apply(Ue,Ve):oe,Bt=Math.max(rt[1][0]-rt[0][0],rt[1][1]-rt[0][1]),_t=Ue.__zoom,It=typeof Ae=="function"?Ae.apply(Ue,Ve):Ae,Wt=u(_t.invert(ut).concat(Bt/_t.k),It.invert(ut).concat(Bt/It.k));return function(Rt){if(Rt===1)Rt=It;else{var Yt=Wt(Rt),Sr=Bt/Yt[2];Rt=new ln(Sr,ut[0]-Yt[0]*Sr,ut[1]-Yt[1]*Sr)}Ye.zoom(null,Rt)}})}function Le(N,Ae,oe){return!oe&&N.__zooming||new Me(N,Ae)}function Me(N,Ae){this.that=N,this.args=Ae,this.active=0,this.sourceEvent=null,this.extent=e.apply(N,Ae),this.taps=0}Me.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,Ae){return this.mouse&&N!=="mouse"&&(this.mouse[1]=Ae.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=Ae.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=Ae.invert(this.touch1[0])),this.that.__zoom=Ae,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var Ae=wt(this.that).datum();c.call(N,this.that,new v0(N,{sourceEvent:this.sourceEvent,target:ae,transform:this.that.__zoom,dispatch:c}),Ae)}};function Xe(N,...Ae){if(!t.apply(this,arguments))return;var oe=Le(this,Ae).event(N),Ce=this.__zoom,Ue=Math.max(o[0],Math.min(o[1],Ce.k*Math.pow(2,r.apply(this,arguments)))),Ve=an(N);if(oe.wheel)(oe.mouse[0][0]!==Ve[0]||oe.mouse[0][1]!==Ve[1])&&(oe.mouse[1]=Ce.invert(oe.mouse[0]=Ve)),clearTimeout(oe.wheel);else{if(Ce.k===Ue)return;oe.mouse=[Ve,Ce.invert(Ve)],Kr(this),oe.start()}_r(N),oe.wheel=setTimeout(Ye,Z),oe.zoom("mouse",n(je(Ge(Ce,Ue),oe.mouse[0],oe.mouse[1]),oe.extent,f));function Ye(){oe.wheel=null,oe.end()}}function et(N,...Ae){if(S||!t.apply(this,arguments))return;var oe=N.currentTarget,Ce=Le(this,Ae,!0).event(N),Ue=wt(N.view).on("mousemove.zoom",ut,!0).on("mouseup.zoom",Bt,!0),Ve=an(N,oe),Ye=N.clientX,rt=N.clientY;cf(N.view),Do(N),Ce.mouse=[Ve,this.__zoom.invert(Ve)],Kr(this),Ce.start();function ut(_t){if(_r(_t),!Ce.moved){var It=_t.clientX-Ye,Wt=_t.clientY-rt;Ce.moved=It*It+Wt*Wt>we}Ce.event(_t).zoom("mouse",n(je(Ce.that.__zoom,Ce.mouse[0]=an(_t,oe),Ce.mouse[1]),Ce.extent,f))}function Bt(_t){Ue.on("mousemove.zoom mouseup.zoom",null),lf(_t.view,Ce.moved),_r(_t),Ce.event(_t).end()}}function nt(N,...Ae){if(t.apply(this,arguments)){var oe=this.__zoom,Ce=an(N.changedTouches?N.changedTouches[0]:N,this),Ue=oe.invert(Ce),Ve=oe.k*(N.shiftKey?.5:2),Ye=n(je(Ge(oe,Ve),Ce,Ue),e.apply(this,Ae),f);_r(N),s>0?wt(this).transition().duration(s).call(le,Ye,Ce,N):wt(this).call(ae.transform,Ye,Ce,N)}}function ke(N,...Ae){if(t.apply(this,arguments)){var oe=N.touches,Ce=oe.length,Ue=Le(this,Ae,N.changedTouches.length===Ce).event(N),Ve,Ye,rt,ut;for(Do(N),Ye=0;Ye<Ce;++Ye)rt=oe[Ye],ut=an(rt,this),ut=[ut,this.__zoom.invert(ut),rt.identifier],Ue.touch0?!Ue.touch1&&Ue.touch0[2]!==ut[2]&&(Ue.touch1=ut,Ue.taps=0):(Ue.touch0=ut,Ve=!0,Ue.taps=1+!!v);v&&(v=clearTimeout(v)),Ve&&(Ue.taps<2&&(b=ut[0],v=setTimeout(function(){v=null},D)),Kr(this),Ue.start())}}function it(N,...Ae){if(this.__zooming){var oe=Le(this,Ae).event(N),Ce=N.changedTouches,Ue=Ce.length,Ve,Ye,rt,ut;for(_r(N),Ve=0;Ve<Ue;++Ve)Ye=Ce[Ve],rt=an(Ye,this),oe.touch0&&oe.touch0[2]===Ye.identifier?oe.touch0[0]=rt:oe.touch1&&oe.touch1[2]===Ye.identifier&&(oe.touch1[0]=rt);if(Ye=oe.that.__zoom,oe.touch1){var Bt=oe.touch0[0],_t=oe.touch0[1],It=oe.touch1[0],Wt=oe.touch1[1],Rt=(Rt=It[0]-Bt[0])*Rt+(Rt=It[1]-Bt[1])*Rt,Yt=(Yt=Wt[0]-_t[0])*Yt+(Yt=Wt[1]-_t[1])*Yt;Ye=Ge(Ye,Math.sqrt(Rt/Yt)),rt=[(Bt[0]+It[0])/2,(Bt[1]+It[1])/2],ut=[(_t[0]+Wt[0])/2,(_t[1]+Wt[1])/2]}else if(oe.touch0)rt=oe.touch0[0],ut=oe.touch0[1];else return;oe.zoom("touch",n(je(Ye,rt,ut),oe.extent,f))}}function tt(N,...Ae){if(this.__zooming){var oe=Le(this,Ae).event(N),Ce=N.changedTouches,Ue=Ce.length,Ve,Ye;for(Do(N),S&&clearTimeout(S),S=setTimeout(function(){S=null},D),Ve=0;Ve<Ue;++Ve)Ye=Ce[Ve],oe.touch0&&oe.touch0[2]===Ye.identifier?delete oe.touch0:oe.touch1&&oe.touch1[2]===Ye.identifier&&delete oe.touch1;if(oe.touch1&&!oe.touch0&&(oe.touch0=oe.touch1,delete oe.touch1),oe.touch0)oe.touch0[1]=this.__zoom.invert(oe.touch0[0]);else if(oe.end(),oe.taps===2&&(Ye=an(Ye,this),Math.hypot(b[0]-Ye[0],b[1]-Ye[1])<Se)){var rt=wt(this).on("dblclick.zoom");rt&&rt.apply(this,arguments)}}}return ae.wheelDelta=function(N){return arguments.length?(r=typeof N=="function"?N:bi(+N),ae):r},ae.filter=function(N){return arguments.length?(t=typeof N=="function"?N:bi(!!N),ae):t},ae.touchable=function(N){return arguments.length?(i=typeof N=="function"?N:bi(!!N),ae):i},ae.extent=function(N){return arguments.length?(e=typeof N=="function"?N:bi([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),ae):e},ae.scaleExtent=function(N){return arguments.length?(o[0]=+N[0],o[1]=+N[1],ae):[o[0],o[1]]},ae.translateExtent=function(N){return arguments.length?(f[0][0]=+N[0][0],f[1][0]=+N[1][0],f[0][1]=+N[0][1],f[1][1]=+N[1][1],ae):[[f[0][0],f[0][1]],[f[1][0],f[1][1]]]},ae.constrain=function(N){return arguments.length?(n=N,ae):n},ae.duration=function(N){return arguments.length?(s=+N,ae):s},ae.interpolate=function(N){return arguments.length?(u=N,ae):u},ae.on=function(){var N=c.on.apply(c,arguments);return N===c?ae:N},ae.clickDistance=function(N){return arguments.length?(we=(N=+N)*N,ae):Math.sqrt(we)},ae.tapDistance=function(N){return arguments.length?(Se=+N,ae):Se},ae}class w0{constructor(e,n){this.eventTransform=br,this.behavior=S0().scaleExtent([.001,1/0]).on("start",r=>{var o,f;this.isRunning=!0;const i=!!r.sourceEvent;(f=(o=this.config)==null?void 0:o.onZoomStart)==null||f.call(o,r,i)}).on("zoom",r=>{var S,D;this.eventTransform=r.transform;const{eventTransform:{x:i,y:o,k:f},store:{transform:s,screenSize:u}}=this,c=u[0],v=u[1];if(!c||!v)return;wp(s,c,v),Zs(s,s,[i,o]),Co(s,s,[f,f]),Zs(s,s,[c/2,v/2]),Co(s,s,[c/2,v/2]),Co(s,s,[1,-1]);const b=!!r.sourceEvent;(D=(S=this.config)==null?void 0:S.onZoom)==null||D.call(S,r,b)}).on("end",r=>{var o,f;this.isRunning=!1;const i=!!r.sourceEvent;(f=(o=this.config)==null?void 0:o.onZoomEnd)==null||f.call(o,r,i)}),this.isRunning=!1,this.store=e,this.config=n}getTransform(e,n,r=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:i}}=this,o=i[0],f=i[1],s=zs(e.map(ae=>ae[0])),u=zs(e.map(ae=>ae[1]));s[0]=this.store.scaleX(s[0]),s[1]=this.store.scaleX(s[1]),u[0]=this.store.scaleY(u[0]),u[1]=this.store.scaleY(u[1]),s[0]===s[1]&&(s[0]-=.5,s[1]+=.5),u[0]===u[1]&&(u[0]+=.5,u[1]-=.5);const c=o*(1-r*2)/(s[1]-s[0]),v=f*(1-r*2)/(u[0]-u[1]),b=As(n??Math.min(c,v),...this.behavior.scaleExtent()),S=(s[1]+s[0])/2,D=(u[1]+u[0])/2,Z=o/2-S*b,we=f/2-D*b;return br.translate(Z,we).scale(b)}getDistanceToPoint(e){const{x:n,y:r,k:i}=this.eventTransform,o=this.getTransform([e],i),f=n-o.x,s=r-o.y;return Math.sqrt(f*f+s*s)}getMiddlePointTransform(e){const{store:{screenSize:n},eventTransform:{x:r,y:i,k:o}}=this,f=n[0],s=n[1],u=(f/2-r)/o,c=(s/2-i)/o,v=this.store.scaleX(e[0]),b=this.store.scaleY(e[1]),S=(u+v)/2,D=(c+b)/2,Z=1,we=f/2-S*Z,Se=s/2-D*Z;return br.translate(we,Se).scale(Z)}convertScreenToSpacePosition(e){const{eventTransform:{x:n,y:r,k:i},store:{screenSize:o}}=this,f=o[0],s=o[1],u=(e[0]-n)/i,c=(e[1]-r)/i,v=[u,s-c];return v[0]-=(f-this.store.adjustedSpaceSize)/2,v[1]-=(s-this.store.adjustedSpaceSize)/2,v}convertSpaceToScreenPosition(e){const n=this.eventTransform.applyX(this.store.scaleX(e[0])),r=this.eventTransform.applyY(this.store.scaleY(e[1]));return[n,r]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:n},store:{maxPointSize:r},eventTransform:{k:i}}=this;let o=e*2;return n?o*=i:o*=Math.min(5,Math.max(1,i*.01)),Math.min(o,r)/2}}class T0{constructor(e,n){this.isActive=!1,this.behavior=p0().subject(r=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:r.x,y:r.y}:void 0).on("start",r=>{var i,o;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(o=(i=this.config)==null?void 0:i.onDragStart)==null||o.call(i,r))}).on("drag",r=>{var i,o;(o=(i=this.config)==null?void 0:i.onDrag)==null||o.call(i,r)}).on("end",r=>{var i,o;this.isActive=!1,this.store.draggingPointIndex=void 0,(o=(i=this.config)==null?void 0:i.onDragEnd)==null||o.call(i,r)}),this.store=e,this.config=n}}function A0(t){const e=document.createElement("div");return e.style.cssText=`
1203
1252
  color: var(--cosmosgl-error-message-color);
1204
1253
  padding: 0em 2em;
1205
1254
  position: absolute;
@@ -1210,7 +1259,7 @@ void main() {
1210
1259
  font-size: 1rem;
1211
1260
  text-align: center;
1212
1261
  user-select: none;
1213
- `,e.textContent="Sorry, your device or browser does not support the required WebGL features for this visualization",t.appendChild(e),e}class E0{constructor(e,n){this.config=new am,this.graph=new Fm(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new u0,this.zoomInstance=new w0(this.store,this.config),this.dragInstance=new T0(this.store,this.config),this._findHoveredPointExecutionCount=0,this._isMouseOnCanvas=!1,this._isFirstRenderAfterInit=!0,this._needsPointPositionsUpdate=!1,this._needsPointColorUpdate=!1,this._needsPointSizeUpdate=!1,this._needsLinksUpdate=!1,this._needsLinkColorUpdate=!1,this._needsLinkWidthUpdate=!1,this._needsLinkArrowUpdate=!1,this._needsPointClusterUpdate=!1,this._needsForceManyBodyUpdate=!1,this._needsForceLinkUpdate=!1,this._needsForceCenterUpdate=!1,this._isDestroyed=!1,n&&this.config.init(n),this.store.div=e;const r=document.createElement("canvas");r.style.width="100%",r.style.height="100%",this.store.div.appendChild(r),this.addAttribution();const i=r.clientWidth,o=r.clientHeight;r.width=i*this.config.pixelRatio,r.height=o*this.config.pixelRatio,this.canvas=r;let f;try{f=qd({canvas:this.canvas,attributes:{antialias:!1,preserveDrawingBuffer:!0},extensions:["OES_texture_float","ANGLE_instanced_arrays"]})}catch{A0(this.store.div),this._isDestroyed=!0;return}this.reglInstance=f,this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.store.updateScreenSize(i,o),this.canvasD3Selection=wt(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mousemove.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mouseleave.cosmos",()=>{this._isMouseOnCanvas=!1}),wt(document).on("keydown.cosmos",s=>{s.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",s=>{s.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",s=>{this.currentEvent=s}).on("zoom.detect",s=>{!!s.sourceEvent&&this.updateMousePosition(s.sourceEvent),this.currentEvent=s}).on("end.detect",s=>{this.currentEvent=s}),this.dragInstance.behavior.on("start.detect",s=>{this.currentEvent=s,this.updateCanvasCursor()}).on("drag.detect",s=>{this.dragInstance.isActive&&this.updateMousePosition(s),this.currentEvent=s}).on("end.detect",s=>{this.currentEvent=s,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]??zo)/this.config.pixelRatio,this.points=new _p(this.reglInstance,this.config,this.store,this.graph),this.lines=new fp(this.reglInstance,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new hm(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceCenter=new cm(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceManyBody=this.config.useClassicQuadtree?new ym(this.reglInstance,this.config,this.store,this.graph,this.points):new vm(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new Es(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new Es(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceMouse=new bm(this.reglInstance,this.config,this.store,this.graph,this.points)),this.clusters=new Tm(this.reglInstance,this.config,this.store,this.graph,this.points),this.store.backgroundColor=vn(this.config.backgroundColor),this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor),this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor),this.config.showFPSMonitor&&(this.fpsMonitor=new Fs(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 r;if(this._isDestroyed||!this.reglInstance||!this.points||!this.lines||!this.clusters)return;const n={...this.config};this.config.init(e),n.pointColor!==this.config.pointColor&&(this.graph.updatePointColor(),this.points.updateColor()),n.pointSize!==this.config.pointSize&&(this.graph.updatePointSize(),this.points.updateSize()),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=vn(this.config.backgroundColor)),n.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor),n.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor),n.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor),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 Fs(this.canvas):((r=this.fpsMonitor)==null||r.destroy(),this.fpsMonitor=void 0)),n.pixelRatio!==this.config.pixelRatio&&(this.store.maxPointSize=(this.reglInstance.limits.pointSizeDims[1]??zo)/this.config.pixelRatio),(n.enableZoom!==this.config.enableZoom||n.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors()}setPointPositions(e,n){this._isDestroyed||!this.points||(this.graph.inputPointPositions=e,this.points.dontRescale=n,this._needsPointPositionsUpdate=!0,this._needsLinksUpdate=!0,this._needsPointColorUpdate=!0,this._needsPointSizeUpdate=!0,this._needsPointClusterUpdate=!0,this._needsForceManyBodyUpdate=!0,this._needsForceLinkUpdate=!0,this._needsForceCenterUpdate=!0)}setPointColors(e){this._isDestroyed||(this.graph.inputPointColors=e,this._needsPointColorUpdate=!0)}setPointSizes(e){this._isDestroyed||(this.graph.inputPointSizes=e,this._needsPointSizeUpdate=!0)}setLinks(e){this._isDestroyed||(this.graph.inputLinks=e,this._needsLinksUpdate=!0,this._needsLinkColorUpdate=!0,this._needsLinkWidthUpdate=!0,this._needsLinkArrowUpdate=!0,this._needsForceLinkUpdate=!0)}setLinkColors(e){this._isDestroyed||(this.graph.inputLinkColors=e,this._needsLinkColorUpdate=!0)}setLinkWidths(e){this._isDestroyed||(this.graph.inputLinkWidths=e,this._needsLinkWidthUpdate=!0)}setLinkArrows(e){this._isDestroyed||(this.graph.linkArrowsBoolean=e,this._needsLinkArrowUpdate=!0)}setLinkStrength(e){this._isDestroyed||(this.graph.inputLinkStrength=e,this._needsForceLinkUpdate=!0)}setPointClusters(e){this._isDestroyed||(this.graph.inputPointClusters=e,this._needsPointClusterUpdate=!0)}setClusterPositions(e){this._isDestroyed||(this.graph.inputClusterPositions=e,this._needsPointClusterUpdate=!0)}setPointClusterStrength(e){this._isDestroyed||(this.graph.inputClusterStrength=e,this._needsPointClusterUpdate=!0)}render(e){if(this._isDestroyed||!this.reglInstance)return;this.graph.update();const{fitViewOnInit:n,fitViewDelay:r,fitViewPadding:i,fitViewDuration:o,fitViewByPointsInRect:f,initialZoomLevel:s}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),wt(this.canvas).style("cursor",null),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0});return}this._isFirstRenderAfterInit&&n&&s===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{f?this.setZoomTransformByPointPositions(f,o,void 0,i):this.fitView(o,i)},r)),this._isFirstRenderAfterInit=!1,this.update(e)}zoomToPointByIndex(e,n=700,r=om,i=!0){if(this._isDestroyed||!this.reglInstance||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:o}}=this,f=un(this.reglInstance,this.points.currentPositionFbo);if(e===void 0)return;const s=f[e*4+0],u=f[e*4+1];if(s===void 0||u===void 0)return;const c=this.zoomInstance.getDistanceToPoint([s,u]),v=i?r:Math.max(this.getZoomLevel(),r);if(c<Math.min(o[0],o[1]))this.setZoomTransformByPointPositions([s,u],n,v);else{const b=this.zoomInstance.getTransform([[s,u]],v),S=this.zoomInstance.getMiddlePointTransform([s,u]);this.canvasD3Selection.transition().ease(Od).duration(n/2).call(this.zoomInstance.behavior.transform,S).transition().ease(Gd).duration(n/2).call(this.zoomInstance.behavior.transform,b)}}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=un(this.reglInstance,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let r=0;r<this.graph.pointsNumber;r+=1){const i=n[r*4+0],o=n[r*4+1];i!==void 0&&o!==void 0&&(e[r*2]=i,e[r*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=un(this.reglInstance,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let r=0;r<e.length/2;r+=1){const i=n[r*4+0],o=n[r*4+1],f=n[r*4+2];i!==void 0&&o!==void 0&&f!==void 0&&(e[r*2]=i/f,e[r*2+1]=o/f)}return e}fitView(e=250,n=.1){this._isDestroyed||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,n)}fitViewByPointIndices(e,n=250,r=.1){if(this._isDestroyed)return;const i=this.getPointPositions(),o=new Array(e.length*2);for(const[f,s]of e.entries())o[f*2]=i[s*2],o[f*2+1]=i[s*2+1];this.setZoomTransformByPointPositions(o,n,void 0,r)}fitViewByPointPositions(e,n=250,r=.1){this._isDestroyed||this.setZoomTransformByPointPositions(e,n,void 0,r)}getPointsInRange(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(),un(this.reglInstance,this.points.selectedFbo).map((i,o)=>o%4===0&&i!==0?o/4:-1).filter(i=>i!==-1)}selectPointsInRange(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 r=un(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=r.map((i,o)=>o%4===0&&i!==0?o/4:-1).filter(i=>i!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,n=!1){if(!this._isDestroyed)if(n){const r=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...r])}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()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}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,r;this._isDestroyed||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.alpha=e,this.store.simulationProgress=0,(r=(n=this.config).onSimulationStart)==null||r.call(n),this.stopFrames(),this.frame())}pause(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!1,(n=(e=this.config).onSimulationPause)==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.store.isSimulationRunning=!1,this.stopFrames(),this.frame())}destroy(){var e,n;this._isDestroyed||!this.reglInstance||(window.clearTimeout(this._fitViewOnInitTimeoutID),this.stopFrames(),this.reglInstance.destroy(),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0}),wt(this.canvas).style("cursor",null),(e=this.fpsMonitor)==null||e.destroy(),(n=document.getElementById("gl-bench-style"))==null||n.remove(),this._isDestroyed=!0)}create(){var e,n,r,i,o;this._isDestroyed||!this.points||!this.lines||(this._needsPointPositionsUpdate&&this.points.updatePositions(),this._needsPointColorUpdate&&this.points.updateColor(),this._needsPointSizeUpdate&&this.points.updateSize(),this._needsLinksUpdate&&this.lines.updatePointsBuffer(),this._needsLinkColorUpdate&&this.lines.updateColor(),this._needsLinkWidthUpdate&&this.lines.updateWidth(),this._needsLinkArrowUpdate&&this.lines.updateArrow(),this._needsForceManyBodyUpdate&&((e=this.forceManyBody)==null||e.create()),this._needsForceLinkUpdate&&((n=this.forceLinkIncoming)==null||n.create(bo.INCOMING),(r=this.forceLinkOutgoing)==null||r.create(bo.OUTGOING)),this._needsForceCenterUpdate&&((i=this.forceCenter)==null||i.create()),this._needsPointClusterUpdate&&((o=this.clusters)==null||o.create()),this._needsPointPositionsUpdate=!1,this._needsPointColorUpdate=!1,this._needsPointSizeUpdate=!1,this._needsLinksUpdate=!1,this._needsLinkColorUpdate=!1,this._needsLinkWidthUpdate=!1,this._needsLinkArrowUpdate=!1,this._needsPointClusterUpdate=!1,this._needsForceManyBodyUpdate=!1,this._needsForceLinkUpdate=!1,this._needsForceCenterUpdate=!1)}flatten(e){return e.flat()}pair(e){const n=new Array(e.length/2);for(let r=0;r<e.length/2;r++)n[r]=[e[r*2],e[r*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.start(e)}initPrograms(){var e,n,r,i,o,f;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(),(r=this.forceLinkOutgoing)==null||r.initPrograms(),(i=this.forceMouse)==null||i.initPrograms(),(o=this.forceManyBody)==null||o.initPrograms(),(f=this.forceCenter)==null||f.initPrograms(),this.clusters.initPrograms())}frame(){const{config:{simulationGravity:e,simulationCenter:n,renderLinks:r,enableSimulation:i},store:{alpha:o,isSimulationRunning:f}}=this;o<Lo&&f&&this.end(),this.store.pointsTextureSize&&(this.requestAnimationFrameId=window.requestAnimationFrame(s=>{var u,c,v,b,S,D,Z,we,Se,ae,Ne,je,q,le,Le,Me,Xe,et,nt,ke,it,tt,G,Ae,oe,Ce;(u=this.fpsMonitor)==null||u.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredPoint(),i&&(this.isRightClickMouse&&(f||this.start(.1),(c=this.forceMouse)==null||c.run(),(v=this.points)==null||v.updatePosition()),f&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom)&&(e&&((b=this.forceGravity)==null||b.run(),(S=this.points)==null||S.updatePosition()),n&&((D=this.forceCenter)==null||D.run(),(Z=this.points)==null||Z.updatePosition()),(we=this.forceManyBody)==null||we.run(),(Se=this.points)==null||Se.updatePosition(),this.store.linksTextureSize&&((ae=this.forceLinkIncoming)==null||ae.run(),(Ne=this.points)==null||Ne.updatePosition(),(je=this.forceLinkOutgoing)==null||je.run(),(q=this.points)==null||q.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((le=this.clusters)==null||le.run(),(Le=this.points)==null||Le.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??$e.simulation.decay),this.isRightClickMouse&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,Lo/this.store.alpha)),(nt=(et=this.config).onSimulationTick)==null||nt.call(et,this.store.alpha,(Me=this.store.hoveredPoint)==null?void 0:Me.index,(Xe=this.store.hoveredPoint)==null?void 0:Xe.position)),(ke=this.points)==null||ke.trackPoints()),(it=this.reglInstance)==null||it.clear({color:this.store.backgroundColor,depth:1,stencil:0}),r&&this.store.linksTextureSize&&((tt=this.lines)==null||tt.draw()),(G=this.points)==null||G.draw(),this.dragInstance.isActive&&((Ae=this.points)==null||Ae.drag(),(oe=this.points)==null||oe.drag()),(Ce=this.fpsMonitor)==null||Ce.end(s),this.currentEvent=void 0,this.frame()}))}stopFrames(){this.requestAnimationFrameId&&window.cancelAnimationFrame(this.requestAnimationFrameId)}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,r,i,o;(o=(i=this.config).onClick)==null||o.call(i,(n=this.store.hoveredPoint)==null?void 0:n.index,(r=this.store.hoveredPoint)==null?void 0:r.position,e)}updateMousePosition(e){if(!e)return;const n=e.offsetX??e.x,r=e.offsetY??e.y;n===void 0||r===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([n,r]),this.store.screenMousePosition=[n,this.store.screenSize[1]-r])}onMouseMove(e){var n,r,i,o;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(o=(i=this.config).onMouseMove)==null||o.call(i,(n=this.store.hoveredPoint)==null?void 0:n.index,(r=this.store.hoveredPoint)==null?void 0:r.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var f,s,u;const n=this.canvas.width,r=this.canvas.height,i=this.canvas.clientWidth,o=this.canvas.clientHeight;if(e||n!==i*this.config.pixelRatio||r!==o*this.config.pixelRatio){const[c,v]=this.store.screenSize,{k:b}=this.zoomInstance.eventTransform,S=this.zoomInstance.convertScreenToSpacePosition([c/2,v/2]);this.store.updateScreenSize(i,o),this.canvas.width=i*this.config.pixelRatio,this.canvas.height=o*this.config.pixelRatio,(f=this.reglInstance)==null||f.poll(),(s=this.canvasD3Selection)==null||s.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([S],b)),(u=this.points)==null||u.updateSampledPointsGrid()}}setZoomTransformByPointPositions(e,n=250,r,i){var f;this.resizeCanvas();const o=this.zoomInstance.getTransform(this.pair(e),r,i);(f=this.canvasD3Selection)==null||f.transition().ease(Nd).duration(n).call(this.zoomInstance.behavior.transform,o)}updateZoomDragBehaviors(){var e,n,r,i;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?(r=this.canvasD3Selection)==null||r.call(this.zoomInstance.behavior):(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredPoint(){var o,f,s,u,c;if(!this._isMouseOnCanvas||!this.reglInstance||!this.points)return;if(this._findHoveredPointExecutionCount<2){this._findHoveredPointExecutionCount+=1;return}this._findHoveredPointExecutionCount=0,this.points.findHoveredPoint();let e=!1,n=!1;const r=un(this.reglInstance,this.points.hoveredFbo);if(r[1]){const v=r[0];((o=this.store.hoveredPoint)==null?void 0:o.index)!==v&&(e=!0);const b=r[2],S=r[3];this.store.hoveredPoint={index:v,position:[b,S]}}else this.store.hoveredPoint&&(n=!0),this.store.hoveredPoint=void 0;e&&this.store.hoveredPoint&&((s=(f=this.config).onPointMouseOver)==null||s.call(f,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),n&&((c=(u=this.config).onPointMouseOut)==null||c.call(u,this.currentEvent)),this.updateCanvasCursor()}updateCanvasCursor(){const{hoveredPointCursor:e}=this.config;this.dragInstance.isActive?wt(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?wt(this.canvas).style("cursor",e):wt(this.canvas).style("cursor","grab"):wt(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
1262
+ `,e.textContent="Sorry, your device or browser does not support the required WebGL features for this visualization",t.appendChild(e),e}class E0{constructor(e,n){this.config=new am,this.graph=new Fm(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new u0,this.zoomInstance=new w0(this.store,this.config),this.dragInstance=new T0(this.store,this.config),this._findHoveredPointExecutionCount=0,this._isMouseOnCanvas=!1,this._isFirstRenderAfterInit=!0,this._needsPointPositionsUpdate=!1,this._needsPointColorUpdate=!1,this._needsPointSizeUpdate=!1,this._needsLinksUpdate=!1,this._needsLinkColorUpdate=!1,this._needsLinkWidthUpdate=!1,this._needsLinkArrowUpdate=!1,this._needsPointClusterUpdate=!1,this._needsForceManyBodyUpdate=!1,this._needsForceLinkUpdate=!1,this._needsForceCenterUpdate=!1,this._isDestroyed=!1,n&&this.config.init(n),this.store.div=e;const r=document.createElement("canvas");r.style.width="100%",r.style.height="100%",this.store.div.appendChild(r),this.addAttribution();const i=r.clientWidth,o=r.clientHeight;r.width=i*this.config.pixelRatio,r.height=o*this.config.pixelRatio,this.canvas=r;let f;try{f=Wd({canvas:this.canvas,attributes:{antialias:!1,preserveDrawingBuffer:!0},extensions:["OES_texture_float","ANGLE_instanced_arrays"]})}catch{A0(this.store.div),this._isDestroyed=!0;return}this.reglInstance=f,this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.store.updateScreenSize(i,o),this.canvasD3Selection=wt(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mousemove.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mouseleave.cosmos",()=>{this._isMouseOnCanvas=!1}),wt(document).on("keydown.cosmos",s=>{s.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",s=>{s.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",s=>{this.currentEvent=s}).on("zoom.detect",s=>{!!s.sourceEvent&&this.updateMousePosition(s.sourceEvent),this.currentEvent=s}).on("end.detect",s=>{this.currentEvent=s}),this.dragInstance.behavior.on("start.detect",s=>{this.currentEvent=s,this.updateCanvasCursor()}).on("drag.detect",s=>{this.dragInstance.isActive&&this.updateMousePosition(s),this.currentEvent=s}).on("end.detect",s=>{this.currentEvent=s,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]??zo)/this.config.pixelRatio,this.points=new _p(this.reglInstance,this.config,this.store,this.graph),this.lines=new fp(this.reglInstance,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new hm(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceCenter=new cm(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceManyBody=this.config.useClassicQuadtree?new ym(this.reglInstance,this.config,this.store,this.graph,this.points):new vm(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new Es(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new Es(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceMouse=new bm(this.reglInstance,this.config,this.store,this.graph,this.points)),this.clusters=new Tm(this.reglInstance,this.config,this.store,this.graph,this.points),this.store.backgroundColor=vn(this.config.backgroundColor),this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor),this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor),this.config.showFPSMonitor&&(this.fpsMonitor=new Fs(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 r;if(this._isDestroyed||!this.reglInstance||!this.points||!this.lines||!this.clusters)return;const n={...this.config};this.config.init(e),n.pointColor!==this.config.pointColor&&(this.graph.updatePointColor(),this.points.updateColor()),n.pointSize!==this.config.pointSize&&(this.graph.updatePointSize(),this.points.updateSize()),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=vn(this.config.backgroundColor)),n.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor),n.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor),n.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor),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 Fs(this.canvas):((r=this.fpsMonitor)==null||r.destroy(),this.fpsMonitor=void 0)),n.pixelRatio!==this.config.pixelRatio&&(this.store.maxPointSize=(this.reglInstance.limits.pointSizeDims[1]??zo)/this.config.pixelRatio),(n.enableZoom!==this.config.enableZoom||n.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors()}setPointPositions(e,n){this._isDestroyed||!this.points||(this.graph.inputPointPositions=e,this.points.dontRescale=n,this._needsPointPositionsUpdate=!0,this._needsLinksUpdate=!0,this._needsPointColorUpdate=!0,this._needsPointSizeUpdate=!0,this._needsPointClusterUpdate=!0,this._needsForceManyBodyUpdate=!0,this._needsForceLinkUpdate=!0,this._needsForceCenterUpdate=!0)}setPointColors(e){this._isDestroyed||(this.graph.inputPointColors=e,this._needsPointColorUpdate=!0)}setPointSizes(e){this._isDestroyed||(this.graph.inputPointSizes=e,this._needsPointSizeUpdate=!0)}setLinks(e){this._isDestroyed||(this.graph.inputLinks=e,this._needsLinksUpdate=!0,this._needsLinkColorUpdate=!0,this._needsLinkWidthUpdate=!0,this._needsLinkArrowUpdate=!0,this._needsForceLinkUpdate=!0)}setLinkColors(e){this._isDestroyed||(this.graph.inputLinkColors=e,this._needsLinkColorUpdate=!0)}setLinkWidths(e){this._isDestroyed||(this.graph.inputLinkWidths=e,this._needsLinkWidthUpdate=!0)}setLinkArrows(e){this._isDestroyed||(this.graph.linkArrowsBoolean=e,this._needsLinkArrowUpdate=!0)}setLinkStrength(e){this._isDestroyed||(this.graph.inputLinkStrength=e,this._needsForceLinkUpdate=!0)}setPointClusters(e){this._isDestroyed||(this.graph.inputPointClusters=e,this._needsPointClusterUpdate=!0)}setClusterPositions(e){this._isDestroyed||(this.graph.inputClusterPositions=e,this._needsPointClusterUpdate=!0)}setPointClusterStrength(e){this._isDestroyed||(this.graph.inputClusterStrength=e,this._needsPointClusterUpdate=!0)}render(e){if(this._isDestroyed||!this.reglInstance)return;this.graph.update();const{fitViewOnInit:n,fitViewDelay:r,fitViewPadding:i,fitViewDuration:o,fitViewByPointsInRect:f,initialZoomLevel:s}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),wt(this.canvas).style("cursor",null),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0});return}this._isFirstRenderAfterInit&&n&&s===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{f?this.setZoomTransformByPointPositions(f,o,void 0,i):this.fitView(o,i)},r)),this._isFirstRenderAfterInit=!1,this.update(e)}zoomToPointByIndex(e,n=700,r=om,i=!0){if(this._isDestroyed||!this.reglInstance||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:o}}=this,f=un(this.reglInstance,this.points.currentPositionFbo);if(e===void 0)return;const s=f[e*4+0],u=f[e*4+1];if(s===void 0||u===void 0)return;const c=this.zoomInstance.getDistanceToPoint([s,u]),v=i?r:Math.max(this.getZoomLevel(),r);if(c<Math.min(o[0],o[1]))this.setZoomTransformByPointPositions([s,u],n,v);else{const b=this.zoomInstance.getTransform([[s,u]],v),S=this.zoomInstance.getMiddlePointTransform([s,u]);this.canvasD3Selection.transition().ease(Od).duration(n/2).call(this.zoomInstance.behavior.transform,S).transition().ease(Nd).duration(n/2).call(this.zoomInstance.behavior.transform,b)}}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=un(this.reglInstance,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let r=0;r<this.graph.pointsNumber;r+=1){const i=n[r*4+0],o=n[r*4+1];i!==void 0&&o!==void 0&&(e[r*2]=i,e[r*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=un(this.reglInstance,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let r=0;r<e.length/2;r+=1){const i=n[r*4+0],o=n[r*4+1],f=n[r*4+2];i!==void 0&&o!==void 0&&f!==void 0&&(e[r*2]=i/f,e[r*2+1]=o/f)}return e}fitView(e=250,n=.1){this._isDestroyed||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,n)}fitViewByPointIndices(e,n=250,r=.1){if(this._isDestroyed)return;const i=this.getPointPositions(),o=new Array(e.length*2);for(const[f,s]of e.entries())o[f*2]=i[s*2],o[f*2+1]=i[s*2+1];this.setZoomTransformByPointPositions(o,n,void 0,r)}fitViewByPointPositions(e,n=250,r=.1){this._isDestroyed||this.setZoomTransformByPointPositions(e,n,void 0,r)}getPointsInRange(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(),un(this.reglInstance,this.points.selectedFbo).map((i,o)=>o%4===0&&i!==0?o/4:-1).filter(i=>i!==-1)}selectPointsInRange(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 r=un(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=r.map((i,o)=>o%4===0&&i!==0?o/4:-1).filter(i=>i!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,n=!1){if(!this._isDestroyed)if(n){const r=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...r])}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()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}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,r;this._isDestroyed||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.alpha=e,this.store.simulationProgress=0,(r=(n=this.config).onSimulationStart)==null||r.call(n),this.stopFrames(),this.frame())}pause(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!1,(n=(e=this.config).onSimulationPause)==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.store.isSimulationRunning=!1,this.stopFrames(),this.frame())}destroy(){var e,n,r,i;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),wt(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),(r=this.fpsMonitor)==null||r.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),(i=document.getElementById("gl-bench-style"))==null||i.remove(),this.canvasD3Selection=void 0,this.reglInstance=void 0,this.attributionDivElement=void 0,this._isDestroyed=!0)}create(){var e,n,r,i,o;this._isDestroyed||!this.points||!this.lines||(this._needsPointPositionsUpdate&&this.points.updatePositions(),this._needsPointColorUpdate&&this.points.updateColor(),this._needsPointSizeUpdate&&this.points.updateSize(),this._needsLinksUpdate&&this.lines.updatePointsBuffer(),this._needsLinkColorUpdate&&this.lines.updateColor(),this._needsLinkWidthUpdate&&this.lines.updateWidth(),this._needsLinkArrowUpdate&&this.lines.updateArrow(),this._needsForceManyBodyUpdate&&((e=this.forceManyBody)==null||e.create()),this._needsForceLinkUpdate&&((n=this.forceLinkIncoming)==null||n.create(bo.INCOMING),(r=this.forceLinkOutgoing)==null||r.create(bo.OUTGOING)),this._needsForceCenterUpdate&&((i=this.forceCenter)==null||i.create()),this._needsPointClusterUpdate&&((o=this.clusters)==null||o.create()),this._needsPointPositionsUpdate=!1,this._needsPointColorUpdate=!1,this._needsPointSizeUpdate=!1,this._needsLinksUpdate=!1,this._needsLinkColorUpdate=!1,this._needsLinkWidthUpdate=!1,this._needsLinkArrowUpdate=!1,this._needsPointClusterUpdate=!1,this._needsForceManyBodyUpdate=!1,this._needsForceLinkUpdate=!1,this._needsForceCenterUpdate=!1)}flatten(e){return e.flat()}pair(e){const n=new Array(e.length/2);for(let r=0;r<e.length/2;r++)n[r]=[e[r*2],e[r*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.start(e)}initPrograms(){var e,n,r,i,o,f;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(),(r=this.forceLinkOutgoing)==null||r.initPrograms(),(i=this.forceMouse)==null||i.initPrograms(),(o=this.forceManyBody)==null||o.initPrograms(),(f=this.forceCenter)==null||f.initPrograms(),this.clusters.initPrograms())}frame(){const{config:{simulationGravity:e,simulationCenter:n,renderLinks:r,enableSimulation:i},store:{alpha:o,isSimulationRunning:f}}=this;o<Lo&&f&&this.end(),this.store.pointsTextureSize&&(this.requestAnimationFrameId=window.requestAnimationFrame(s=>{var u,c,v,b,S,D,Z,we,Se,ae,Ge,je,W,le,Le,Me,Xe,et,nt,ke,it,tt,N,Ae,oe,Ce;(u=this.fpsMonitor)==null||u.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredPoint(),i&&(this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((c=this.forceMouse)==null||c.run(),(v=this.points)==null||v.updatePosition()),f&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom)&&(e&&((b=this.forceGravity)==null||b.run(),(S=this.points)==null||S.updatePosition()),n&&((D=this.forceCenter)==null||D.run(),(Z=this.points)==null||Z.updatePosition()),(we=this.forceManyBody)==null||we.run(),(Se=this.points)==null||Se.updatePosition(),this.store.linksTextureSize&&((ae=this.forceLinkIncoming)==null||ae.run(),(Ge=this.points)==null||Ge.updatePosition(),(je=this.forceLinkOutgoing)==null||je.run(),(W=this.points)==null||W.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((le=this.clusters)==null||le.run(),(Le=this.points)==null||Le.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??Be.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,Lo/this.store.alpha)),(nt=(et=this.config).onSimulationTick)==null||nt.call(et,this.store.alpha,(Me=this.store.hoveredPoint)==null?void 0:Me.index,(Xe=this.store.hoveredPoint)==null?void 0:Xe.position)),(ke=this.points)==null||ke.trackPoints()),(it=this.reglInstance)==null||it.clear({color:this.store.backgroundColor,depth:1,stencil:0}),r&&this.store.linksTextureSize&&((tt=this.lines)==null||tt.draw()),(N=this.points)==null||N.draw(),this.dragInstance.isActive&&((Ae=this.points)==null||Ae.drag(),(oe=this.points)==null||oe.drag()),(Ce=this.fpsMonitor)==null||Ce.end(s),this.currentEvent=void 0,this.frame()}))}stopFrames(){this.requestAnimationFrameId&&window.cancelAnimationFrame(this.requestAnimationFrameId)}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,r,i,o;(o=(i=this.config).onClick)==null||o.call(i,(n=this.store.hoveredPoint)==null?void 0:n.index,(r=this.store.hoveredPoint)==null?void 0:r.position,e)}updateMousePosition(e){if(!e)return;const n=e.offsetX??e.x,r=e.offsetY??e.y;n===void 0||r===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([n,r]),this.store.screenMousePosition=[n,this.store.screenSize[1]-r])}onMouseMove(e){var n,r,i,o;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(o=(i=this.config).onMouseMove)==null||o.call(i,(n=this.store.hoveredPoint)==null?void 0:n.index,(r=this.store.hoveredPoint)==null?void 0:r.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var f,s,u;const n=this.canvas.width,r=this.canvas.height,i=this.canvas.clientWidth,o=this.canvas.clientHeight;if(e||n!==i*this.config.pixelRatio||r!==o*this.config.pixelRatio){const[c,v]=this.store.screenSize,{k:b}=this.zoomInstance.eventTransform,S=this.zoomInstance.convertScreenToSpacePosition([c/2,v/2]);this.store.updateScreenSize(i,o),this.canvas.width=i*this.config.pixelRatio,this.canvas.height=o*this.config.pixelRatio,(f=this.reglInstance)==null||f.poll(),(s=this.canvasD3Selection)==null||s.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([S],b)),(u=this.points)==null||u.updateSampledPointsGrid()}}setZoomTransformByPointPositions(e,n=250,r,i){var f;this.resizeCanvas();const o=this.zoomInstance.getTransform(this.pair(e),r,i);(f=this.canvasD3Selection)==null||f.transition().ease(Gd).duration(n).call(this.zoomInstance.behavior.transform,o)}updateZoomDragBehaviors(){var e,n,r,i;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?(r=this.canvasD3Selection)==null||r.call(this.zoomInstance.behavior):(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredPoint(){var o,f,s,u,c;if(!this._isMouseOnCanvas||!this.reglInstance||!this.points)return;if(this._findHoveredPointExecutionCount<2){this._findHoveredPointExecutionCount+=1;return}this._findHoveredPointExecutionCount=0,this.points.findHoveredPoint();let e=!1,n=!1;const r=un(this.reglInstance,this.points.hoveredFbo);if(r[1]){const v=r[0];((o=this.store.hoveredPoint)==null?void 0:o.index)!==v&&(e=!0);const b=r[2],S=r[3];this.store.hoveredPoint={index:v,position:[b,S]}}else this.store.hoveredPoint&&(n=!0),this.store.hoveredPoint=void 0;e&&this.store.hoveredPoint&&((s=(f=this.config).onPointMouseOver)==null||s.call(f,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),n&&((c=(u=this.config).onPointMouseOut)==null||c.call(u,this.currentEvent)),this.updateCanvasCursor()}updateCanvasCursor(){const{hoveredPointCursor:e}=this.config;this.dragInstance.isActive?wt(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?wt(this.canvas).style("cursor",e):wt(this.canvas).style("cursor","grab"):wt(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
1214
1263
  user-select: none;
1215
1264
  position: absolute;
1216
1265
  bottom: 0;