@fnndsc/argus 0.16.4 → 0.16.5

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.
@@ -1 +0,0 @@
1
- function st(t,n,i){var e,r=1;t==null&&(t=0),n==null&&(n=0),i==null&&(i=0);function o(){var f,s=e.length,a,c=0,u=0,h=0;for(f=0;f<s;++f)a=e[f],c+=a.x||0,u+=a.y||0,h+=a.z||0;for(c=(c/s-t)*r,u=(u/s-n)*r,h=(h/s-i)*r,f=0;f<s;++f)a=e[f],c&&(a.x-=c),u&&(a.y-=u),h&&(a.z-=h)}return o.initialize=function(f){e=f},o.x=function(f){return arguments.length?(t=+f,o):t},o.y=function(f){return arguments.length?(n=+f,o):n},o.z=function(f){return arguments.length?(i=+f,o):i},o.strength=function(f){return arguments.length?(r=+f,o):r},o}function Zt(t){const n=+this._x.call(null,t);return Rt(this.cover(n),n,t)}function Rt(t,n,i){if(isNaN(n))return t;var e,r=t._root,o={data:i},f=t._x0,s=t._x1,a,c,u,h,_;if(!r)return t._root=o,t;for(;r.length;)if((u=n>=(a=(f+s)/2))?f=a:s=a,e=r,!(r=r[h=+u]))return e[h]=o,t;if(c=+t._x.call(null,r.data),n===c)return o.next=r,e?e[h]=o:t._root=o,t;do e=e?e[h]=new Array(2):t._root=new Array(2),(u=n>=(a=(f+s)/2))?f=a:s=a;while((h=+u)==(_=+(c>=a)));return e[_]=r,e[h]=o,t}function Jt(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,i=new Float64Array(n);let e=1/0,r=-1/0;for(let o=0,f;o<n;++o)isNaN(f=+this._x.call(null,t[o]))||(i[o]=f,f<e&&(e=f),f>r&&(r=f));if(e>r)return this;this.cover(e).cover(r);for(let o=0;o<n;++o)Rt(this,i[o],t[o]);return this}function Vt(t){if(isNaN(t=+t))return this;var n=this._x0,i=this._x1;if(isNaN(n))i=(n=Math.floor(t))+1;else{for(var e=i-n||1,r=this._root,o,f;n>t||t>=i;)switch(f=+(t<n),o=new Array(2),o[f]=r,r=o,e*=2,f){case 0:i=n+e;break;case 1:n=i-e;break}this._root&&this._root.length&&(this._root=r)}return this._x0=n,this._x1=i,this}function tn(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function nn(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function J(t,n,i){this.node=t,this.x0=n,this.x1=i}function en(t,n){var i,e=this._x0,r,o,f=this._x1,s=[],a=this._root,c,u;for(a&&s.push(new J(a,e,f)),n==null?n=1/0:(e=t-n,f=t+n);c=s.pop();)if(!(!(a=c.node)||(r=c.x0)>f||(o=c.x1)<e))if(a.length){var h=(r+o)/2;s.push(new J(a[1],h,o),new J(a[0],r,h)),(u=+(t>=h))&&(c=s[s.length-1],s[s.length-1]=s[s.length-1-u],s[s.length-1-u]=c)}else{var _=Math.abs(t-+this._x.call(null,a.data));_<n&&(n=_,e=t-_,f=t+_,i=a.data)}return i}function rn(t){if(isNaN(a=+this._x.call(null,t)))return this;var n,i=this._root,e,r,o,f=this._x0,s=this._x1,a,c,u,h,_;if(!i)return this;if(i.length)for(;;){if((u=a>=(c=(f+s)/2))?f=c:s=c,n=i,!(i=i[h=+u]))return this;if(!i.length)break;n[h+1&1]&&(e=n,_=h)}for(;i.data!==t;)if(r=i,!(i=i.next))return this;return(o=i.next)&&delete i.next,r?(o?r.next=o:delete r.next,this):n?(o?n[h]=o:delete n[h],(i=n[0]||n[1])&&i===(n[1]||n[0])&&!i.length&&(e?e[_]=i:this._root=i),this):(this._root=o,this)}function on(t){for(var n=0,i=t.length;n<i;++n)this.remove(t[n]);return this}function sn(){return this._root}function fn(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function an(t){var n=[],i,e=this._root,r,o,f;for(e&&n.push(new J(e,this._x0,this._x1));i=n.pop();)if(!t(e=i.node,o=i.x0,f=i.x1)&&e.length){var s=(o+f)/2;(r=e[1])&&n.push(new J(r,s,f)),(r=e[0])&&n.push(new J(r,o,s))}return this}function hn(t){var n=[],i=[],e;for(this._root&&n.push(new J(this._root,this._x0,this._x1));e=n.pop();){var r=e.node;if(r.length){var o,f=e.x0,s=e.x1,a=(f+s)/2;(o=r[0])&&n.push(new J(o,f,a)),(o=r[1])&&n.push(new J(o,a,s))}i.push(e)}for(;e=i.pop();)t(e.node,e.x0,e.x1);return this}function un(t){return t[0]}function cn(t){return arguments.length?(this._x=t,this):this._x}function zt(t,n){var i=new Mt(n??un,NaN,NaN);return t==null?i:i.addAll(t)}function Mt(t,n,i){this._x=t,this._x0=n,this._x1=i,this._root=void 0}function It(t){for(var n={data:t.data},i=n;t=t.next;)i=i.next={data:t.data};return n}var K=zt.prototype=Mt.prototype;K.copy=function(){var t=new Mt(this._x,this._x0,this._x1),n=this._root,i,e;if(!n)return t;if(!n.length)return t._root=It(n),t;for(i=[{source:n,target:t._root=new Array(2)}];n=i.pop();)for(var r=0;r<2;++r)(e=n.source[r])&&(e.length?i.push({source:e,target:n.target[r]=new Array(2)}):n.target[r]=It(e));return t};K.add=Zt;K.addAll=Jt;K.cover=Vt;K.data=tn;K.extent=nn;K.find=en;K.remove=rn;K.removeAll=on;K.root=sn;K.size=fn;K.visit=an;K.visitAfter=hn;K.x=cn;function ln(t){const n=+this._x.call(null,t),i=+this._y.call(null,t);return Ct(this.cover(n,i),n,i,t)}function Ct(t,n,i,e){if(isNaN(n)||isNaN(i))return t;var r,o=t._root,f={data:e},s=t._x0,a=t._y0,c=t._x1,u=t._y1,h,_,g,p,w,y,l,N;if(!o)return t._root=f,t;for(;o.length;)if((w=n>=(h=(s+c)/2))?s=h:c=h,(y=i>=(_=(a+u)/2))?a=_:u=_,r=o,!(o=o[l=y<<1|w]))return r[l]=f,t;if(g=+t._x.call(null,o.data),p=+t._y.call(null,o.data),n===g&&i===p)return f.next=o,r?r[l]=f:t._root=f,t;do r=r?r[l]=new Array(4):t._root=new Array(4),(w=n>=(h=(s+c)/2))?s=h:c=h,(y=i>=(_=(a+u)/2))?a=_:u=_;while((l=y<<1|w)===(N=(p>=_)<<1|g>=h));return r[N]=o,r[l]=f,t}function gn(t){var n,i,e=t.length,r,o,f=new Array(e),s=new Array(e),a=1/0,c=1/0,u=-1/0,h=-1/0;for(i=0;i<e;++i)isNaN(r=+this._x.call(null,n=t[i]))||isNaN(o=+this._y.call(null,n))||(f[i]=r,s[i]=o,r<a&&(a=r),r>u&&(u=r),o<c&&(c=o),o>h&&(h=o));if(a>u||c>h)return this;for(this.cover(a,c).cover(u,h),i=0;i<e;++i)Ct(this,f[i],s[i],t[i]);return this}function _n(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var i=this._x0,e=this._y0,r=this._x1,o=this._y1;if(isNaN(i))r=(i=Math.floor(t))+1,o=(e=Math.floor(n))+1;else{for(var f=r-i||1,s=this._root,a,c;i>t||t>=r||e>n||n>=o;)switch(c=(n<e)<<1|t<i,a=new Array(4),a[c]=s,s=a,f*=2,c){case 0:r=i+f,o=e+f;break;case 1:i=r-f,o=e+f;break;case 2:r=i+f,e=o-f;break;case 3:i=r-f,e=o-f;break}this._root&&this._root.length&&(this._root=s)}return this._x0=i,this._y0=e,this._x1=r,this._y1=o,this}function pn(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function vn(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function U(t,n,i,e,r){this.node=t,this.x0=n,this.y0=i,this.x1=e,this.y1=r}function xn(t,n,i){var e,r=this._x0,o=this._y0,f,s,a,c,u=this._x1,h=this._y1,_=[],g=this._root,p,w;for(g&&_.push(new U(g,r,o,u,h)),i==null?i=1/0:(r=t-i,o=n-i,u=t+i,h=n+i,i*=i);p=_.pop();)if(!(!(g=p.node)||(f=p.x0)>u||(s=p.y0)>h||(a=p.x1)<r||(c=p.y1)<o))if(g.length){var y=(f+a)/2,l=(s+c)/2;_.push(new U(g[3],y,l,a,c),new U(g[2],f,l,y,c),new U(g[1],y,s,a,l),new U(g[0],f,s,y,l)),(w=(n>=l)<<1|t>=y)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-w],_[_.length-1-w]=p)}else{var N=t-+this._x.call(null,g.data),M=n-+this._y.call(null,g.data),z=N*N+M*M;if(z<i){var x=Math.sqrt(i=z);r=t-x,o=n-x,u=t+x,h=n+x,e=g.data}}return e}function yn(t){if(isNaN(u=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var n,i=this._root,e,r,o,f=this._x0,s=this._y0,a=this._x1,c=this._y1,u,h,_,g,p,w,y,l;if(!i)return this;if(i.length)for(;;){if((p=u>=(_=(f+a)/2))?f=_:a=_,(w=h>=(g=(s+c)/2))?s=g:c=g,n=i,!(i=i[y=w<<1|p]))return this;if(!i.length)break;(n[y+1&3]||n[y+2&3]||n[y+3&3])&&(e=n,l=y)}for(;i.data!==t;)if(r=i,!(i=i.next))return this;return(o=i.next)&&delete i.next,r?(o?r.next=o:delete r.next,this):n?(o?n[y]=o:delete n[y],(i=n[0]||n[1]||n[2]||n[3])&&i===(n[3]||n[2]||n[1]||n[0])&&!i.length&&(e?e[l]=i:this._root=i),this):(this._root=o,this)}function dn(t){for(var n=0,i=t.length;n<i;++n)this.remove(t[n]);return this}function wn(){return this._root}function zn(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function Mn(t){var n=[],i,e=this._root,r,o,f,s,a;for(e&&n.push(new U(e,this._x0,this._y0,this._x1,this._y1));i=n.pop();)if(!t(e=i.node,o=i.x0,f=i.y0,s=i.x1,a=i.y1)&&e.length){var c=(o+s)/2,u=(f+a)/2;(r=e[3])&&n.push(new U(r,c,u,s,a)),(r=e[2])&&n.push(new U(r,o,u,c,a)),(r=e[1])&&n.push(new U(r,c,f,s,u)),(r=e[0])&&n.push(new U(r,o,f,c,u))}return this}function Nn(t){var n=[],i=[],e;for(this._root&&n.push(new U(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var r=e.node;if(r.length){var o,f=e.x0,s=e.y0,a=e.x1,c=e.y1,u=(f+a)/2,h=(s+c)/2;(o=r[0])&&n.push(new U(o,f,s,u,h)),(o=r[1])&&n.push(new U(o,u,s,a,h)),(o=r[2])&&n.push(new U(o,f,h,u,c)),(o=r[3])&&n.push(new U(o,u,h,a,c))}i.push(e)}for(;e=i.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this}function An(t){return t[0]}function mn(t){return arguments.length?(this._x=t,this):this._x}function $n(t){return t[1]}function In(t){return arguments.length?(this._y=t,this):this._y}function Nt(t,n,i){var e=new At(n??An,i??$n,NaN,NaN,NaN,NaN);return t==null?e:e.addAll(t)}function At(t,n,i,e,r,o){this._x=t,this._y=n,this._x0=i,this._y0=e,this._x1=r,this._y1=o,this._root=void 0}function kt(t){for(var n={data:t.data},i=n;t=t.next;)i=i.next={data:t.data};return n}var H=Nt.prototype=At.prototype;H.copy=function(){var t=new At(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,i,e;if(!n)return t;if(!n.length)return t._root=kt(n),t;for(i=[{source:n,target:t._root=new Array(4)}];n=i.pop();)for(var r=0;r<4;++r)(e=n.source[r])&&(e.length?i.push({source:e,target:n.target[r]=new Array(4)}):n.target[r]=kt(e));return t};H.add=ln;H.addAll=gn;H.cover=_n;H.data=pn;H.extent=vn;H.find=xn;H.remove=yn;H.removeAll=dn;H.root=wn;H.size=zn;H.visit=Mn;H.visitAfter=Nn;H.x=mn;H.y=In;function kn(t){const n=+this._x.call(null,t),i=+this._y.call(null,t),e=+this._z.call(null,t);return Pt(this.cover(n,i,e),n,i,e,t)}function Pt(t,n,i,e,r){if(isNaN(n)||isNaN(i)||isNaN(e))return t;var o,f=t._root,s={data:r},a=t._x0,c=t._y0,u=t._z0,h=t._x1,_=t._y1,g=t._z1,p,w,y,l,N,M,z,x,$,I,q;if(!f)return t._root=s,t;for(;f.length;)if((z=n>=(p=(a+h)/2))?a=p:h=p,(x=i>=(w=(c+_)/2))?c=w:_=w,($=e>=(y=(u+g)/2))?u=y:g=y,o=f,!(f=f[I=$<<2|x<<1|z]))return o[I]=s,t;if(l=+t._x.call(null,f.data),N=+t._y.call(null,f.data),M=+t._z.call(null,f.data),n===l&&i===N&&e===M)return s.next=f,o?o[I]=s:t._root=s,t;do o=o?o[I]=new Array(8):t._root=new Array(8),(z=n>=(p=(a+h)/2))?a=p:h=p,(x=i>=(w=(c+_)/2))?c=w:_=w,($=e>=(y=(u+g)/2))?u=y:g=y;while((I=$<<2|x<<1|z)===(q=(M>=y)<<2|(N>=w)<<1|l>=p));return o[q]=f,o[I]=s,t}function bn(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,i=new Float64Array(n),e=new Float64Array(n),r=new Float64Array(n);let o=1/0,f=1/0,s=1/0,a=-1/0,c=-1/0,u=-1/0;for(let h=0,_,g,p,w;h<n;++h)isNaN(g=+this._x.call(null,_=t[h]))||isNaN(p=+this._y.call(null,_))||isNaN(w=+this._z.call(null,_))||(i[h]=g,e[h]=p,r[h]=w,g<o&&(o=g),g>a&&(a=g),p<f&&(f=p),p>c&&(c=p),w<s&&(s=w),w>u&&(u=w));if(o>a||f>c||s>u)return this;this.cover(o,f,s).cover(a,c,u);for(let h=0;h<n;++h)Pt(this,i[h],e[h],r[h],t[h]);return this}function qn(t,n,i){if(isNaN(t=+t)||isNaN(n=+n)||isNaN(i=+i))return this;var e=this._x0,r=this._y0,o=this._z0,f=this._x1,s=this._y1,a=this._z1;if(isNaN(e))f=(e=Math.floor(t))+1,s=(r=Math.floor(n))+1,a=(o=Math.floor(i))+1;else{for(var c=f-e||1,u=this._root,h,_;e>t||t>=f||r>n||n>=s||o>i||i>=a;)switch(_=(i<o)<<2|(n<r)<<1|t<e,h=new Array(8),h[_]=u,u=h,c*=2,_){case 0:f=e+c,s=r+c,a=o+c;break;case 1:e=f-c,s=r+c,a=o+c;break;case 2:f=e+c,r=s-c,a=o+c;break;case 3:e=f-c,r=s-c,a=o+c;break;case 4:f=e+c,s=r+c,o=a-c;break;case 5:e=f-c,s=r+c,o=a-c;break;case 6:f=e+c,r=s-c,o=a-c;break;case 7:e=f-c,r=s-c,o=a-c;break}this._root&&this._root.length&&(this._root=u)}return this._x0=e,this._y0=r,this._z0=o,this._x1=f,this._y1=s,this._z1=a,this}function Sn(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function En(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function F(t,n,i,e,r,o,f){this.node=t,this.x0=n,this.y0=i,this.z0=e,this.x1=r,this.y1=o,this.z1=f}function On(t,n,i,e){var r,o=this._x0,f=this._y0,s=this._z0,a,c,u,h,_,g,p=this._x1,w=this._y1,y=this._z1,l=[],N=this._root,M,z;for(N&&l.push(new F(N,o,f,s,p,w,y)),e==null?e=1/0:(o=t-e,f=n-e,s=i-e,p=t+e,w=n+e,y=i+e,e*=e);M=l.pop();)if(!(!(N=M.node)||(a=M.x0)>p||(c=M.y0)>w||(u=M.z0)>y||(h=M.x1)<o||(_=M.y1)<f||(g=M.z1)<s))if(N.length){var x=(a+h)/2,$=(c+_)/2,I=(u+g)/2;l.push(new F(N[7],x,$,I,h,_,g),new F(N[6],a,$,I,x,_,g),new F(N[5],x,c,I,h,$,g),new F(N[4],a,c,I,x,$,g),new F(N[3],x,$,u,h,_,I),new F(N[2],a,$,u,x,_,I),new F(N[1],x,c,u,h,$,I),new F(N[0],a,c,u,x,$,I)),(z=(i>=I)<<2|(n>=$)<<1|t>=x)&&(M=l[l.length-1],l[l.length-1]=l[l.length-1-z],l[l.length-1-z]=M)}else{var q=t-+this._x.call(null,N.data),Y=n-+this._y.call(null,N.data),W=i-+this._z.call(null,N.data),R=q*q+Y*Y+W*W;if(R<e){var v=Math.sqrt(e=R);o=t-v,f=n-v,s=i-v,p=t+v,w=n+v,y=i+v,r=N.data}}return r}const Dn=(t,n,i,e,r,o)=>Math.sqrt((t-e)**2+(n-r)**2+(i-o)**2);function Fn(t,n,i,e){const r=[],o=t-e,f=n-e,s=i-e,a=t+e,c=n+e,u=i+e;return this.visit((h,_,g,p,w,y,l)=>{if(!h.length)do{const N=h.data;Dn(t,n,i,this._x(N),this._y(N),this._z(N))<=e&&r.push(N)}while(h=h.next);return _>a||g>c||p>u||w<o||y<f||l<s}),r}function jn(t){if(isNaN(_=+this._x.call(null,t))||isNaN(g=+this._y.call(null,t))||isNaN(p=+this._z.call(null,t)))return this;var n,i=this._root,e,r,o,f=this._x0,s=this._y0,a=this._z0,c=this._x1,u=this._y1,h=this._z1,_,g,p,w,y,l,N,M,z,x,$;if(!i)return this;if(i.length)for(;;){if((N=_>=(w=(f+c)/2))?f=w:c=w,(M=g>=(y=(s+u)/2))?s=y:u=y,(z=p>=(l=(a+h)/2))?a=l:h=l,n=i,!(i=i[x=z<<2|M<<1|N]))return this;if(!i.length)break;(n[x+1&7]||n[x+2&7]||n[x+3&7]||n[x+4&7]||n[x+5&7]||n[x+6&7]||n[x+7&7])&&(e=n,$=x)}for(;i.data!==t;)if(r=i,!(i=i.next))return this;return(o=i.next)&&delete i.next,r?(o?r.next=o:delete r.next,this):n?(o?n[x]=o:delete n[x],(i=n[0]||n[1]||n[2]||n[3]||n[4]||n[5]||n[6]||n[7])&&i===(n[7]||n[6]||n[5]||n[4]||n[3]||n[2]||n[1]||n[0])&&!i.length&&(e?e[$]=i:this._root=i),this):(this._root=o,this)}function Tn(t){for(var n=0,i=t.length;n<i;++n)this.remove(t[n]);return this}function Wn(){return this._root}function Rn(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function Cn(t){var n=[],i,e=this._root,r,o,f,s,a,c,u;for(e&&n.push(new F(e,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));i=n.pop();)if(!t(e=i.node,o=i.x0,f=i.y0,s=i.z0,a=i.x1,c=i.y1,u=i.z1)&&e.length){var h=(o+a)/2,_=(f+c)/2,g=(s+u)/2;(r=e[7])&&n.push(new F(r,h,_,g,a,c,u)),(r=e[6])&&n.push(new F(r,o,_,g,h,c,u)),(r=e[5])&&n.push(new F(r,h,f,g,a,_,u)),(r=e[4])&&n.push(new F(r,o,f,g,h,_,u)),(r=e[3])&&n.push(new F(r,h,_,s,a,c,g)),(r=e[2])&&n.push(new F(r,o,_,s,h,c,g)),(r=e[1])&&n.push(new F(r,h,f,s,a,_,g)),(r=e[0])&&n.push(new F(r,o,f,s,h,_,g))}return this}function Pn(t){var n=[],i=[],e;for(this._root&&n.push(new F(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var r=e.node;if(r.length){var o,f=e.x0,s=e.y0,a=e.z0,c=e.x1,u=e.y1,h=e.z1,_=(f+c)/2,g=(s+u)/2,p=(a+h)/2;(o=r[0])&&n.push(new F(o,f,s,a,_,g,p)),(o=r[1])&&n.push(new F(o,_,s,a,c,g,p)),(o=r[2])&&n.push(new F(o,f,g,a,_,u,p)),(o=r[3])&&n.push(new F(o,_,g,a,c,u,p)),(o=r[4])&&n.push(new F(o,f,s,p,_,g,h)),(o=r[5])&&n.push(new F(o,_,s,p,c,g,h)),(o=r[6])&&n.push(new F(o,f,g,p,_,u,h)),(o=r[7])&&n.push(new F(o,_,g,p,c,u,h))}i.push(e)}for(;e=i.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this}function Gn(t){return t[0]}function Xn(t){return arguments.length?(this._x=t,this):this._x}function Yn(t){return t[1]}function Bn(t){return arguments.length?(this._y=t,this):this._y}function Un(t){return t[2]}function Hn(t){return arguments.length?(this._z=t,this):this._z}function mt(t,n,i,e){var r=new $t(n??Gn,i??Yn,e??Un,NaN,NaN,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function $t(t,n,i,e,r,o,f,s,a){this._x=t,this._y=n,this._z=i,this._x0=e,this._y0=r,this._z0=o,this._x1=f,this._y1=s,this._z1=a,this._root=void 0}function bt(t){for(var n={data:t.data},i=n;t=t.next;)i=i.next={data:t.data};return n}var X=mt.prototype=$t.prototype;X.copy=function(){var t=new $t(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root,i,e;if(!n)return t;if(!n.length)return t._root=bt(n),t;for(i=[{source:n,target:t._root=new Array(8)}];n=i.pop();)for(var r=0;r<8;++r)(e=n.source[r])&&(e.length?i.push({source:e,target:n.target[r]=new Array(8)}):n.target[r]=bt(e));return t};X.add=kn;X.addAll=bn;X.cover=qn;X.data=Sn;X.extent=En;X.find=On;X.findAllWithinRadius=Fn;X.remove=jn;X.removeAll=Tn;X.root=Wn;X.size=Rn;X.visit=Cn;X.visitAfter=Pn;X.x=Xn;X.y=Bn;X.z=Hn;function P(t){return function(){return t}}function Q(t){return(t()-.5)*1e-6}function _t(t){return t.x+t.vx}function qt(t){return t.y+t.vy}function Kn(t){return t.z+t.vz}function ft(t){var n,i,e,r,o=1,f=1;typeof t!="function"&&(t=P(t==null?1:+t));function s(){for(var u,h=n.length,_,g,p,w,y,l,N,M=0;M<f;++M)for(_=(i===1?zt(n,_t):i===2?Nt(n,_t,qt):i===3?mt(n,_t,qt,Kn):null).visitAfter(a),u=0;u<h;++u)g=n[u],l=e[g.index],N=l*l,p=g.x+g.vx,i>1&&(w=g.y+g.vy),i>2&&(y=g.z+g.vz),_.visit(z);function z(x,$,I,q,Y,W,R){var v=[$,I,q,Y,W,R],m=v[0],A=v[1],d=v[2],k=v[i],O=v[i+1],G=v[i+2],D=x.data,b=x.r,E=l+b;if(D){if(D.index>g.index){var C=p-D.x-D.vx,j=i>1?w-D.y-D.vy:0,B=i>2?y-D.z-D.vz:0,T=C*C+j*j+B*B;T<E*E&&(C===0&&(C=Q(r),T+=C*C),i>1&&j===0&&(j=Q(r),T+=j*j),i>2&&B===0&&(B=Q(r),T+=B*B),T=(E-(T=Math.sqrt(T)))/T*o,g.vx+=(C*=T)*(E=(b*=b)/(N+b)),i>1&&(g.vy+=(j*=T)*E),i>2&&(g.vz+=(B*=T)*E),D.vx-=C*(E=1-E),i>1&&(D.vy-=j*E),i>2&&(D.vz-=B*E))}return}return m>p+E||k<p-E||i>1&&(A>w+E||O<w-E)||i>2&&(d>y+E||G<y-E)}}function a(u){if(u.data)return u.r=e[u.data.index];for(var h=u.r=0;h<Math.pow(2,i);++h)u[h]&&u[h].r>u.r&&(u.r=u[h].r)}function c(){if(n){var u,h=n.length,_;for(e=new Array(h),u=0;u<h;++u)_=n[u],e[_.index]=+t(_,u,n)}}return s.initialize=function(u,...h){n=u,r=h.find(_=>typeof _=="function")||Math.random,i=h.find(_=>[1,2,3].includes(_))||2,c()},s.iterations=function(u){return arguments.length?(f=+u,s):f},s.strength=function(u){return arguments.length?(o=+u,s):o},s.radius=function(u){return arguments.length?(t=typeof u=="function"?u:P(+u),c(),s):t},s}function Ln(t){return t.index}function St(t,n){var i=t.get(n);if(!i)throw new Error("node not found: "+n);return i}function yt(t){var n=Ln,i=_,e,r=P(30),o,f,s,a,c,u,h=1;t==null&&(t=[]);function _(l){return 1/Math.min(a[l.source.index],a[l.target.index])}function g(l){for(var N=0,M=t.length;N<h;++N)for(var z=0,x,$,I,q=0,Y=0,W=0,R,v;z<M;++z)x=t[z],$=x.source,I=x.target,q=I.x+I.vx-$.x-$.vx||Q(u),s>1&&(Y=I.y+I.vy-$.y-$.vy||Q(u)),s>2&&(W=I.z+I.vz-$.z-$.vz||Q(u)),R=Math.sqrt(q*q+Y*Y+W*W),R=(R-o[z])/R*l*e[z],q*=R,Y*=R,W*=R,I.vx-=q*(v=c[z]),s>1&&(I.vy-=Y*v),s>2&&(I.vz-=W*v),$.vx+=q*(v=1-v),s>1&&($.vy+=Y*v),s>2&&($.vz+=W*v)}function p(){if(f){var l,N=f.length,M=t.length,z=new Map(f.map(($,I)=>[n($,I,f),$])),x;for(l=0,a=new Array(N);l<M;++l)x=t[l],x.index=l,typeof x.source!="object"&&(x.source=St(z,x.source)),typeof x.target!="object"&&(x.target=St(z,x.target)),a[x.source.index]=(a[x.source.index]||0)+1,a[x.target.index]=(a[x.target.index]||0)+1;for(l=0,c=new Array(M);l<M;++l)x=t[l],c[l]=a[x.source.index]/(a[x.source.index]+a[x.target.index]);e=new Array(M),w(),o=new Array(M),y()}}function w(){if(f)for(var l=0,N=t.length;l<N;++l)e[l]=+i(t[l],l,t)}function y(){if(f)for(var l=0,N=t.length;l<N;++l)o[l]=+r(t[l],l,t)}return g.initialize=function(l,...N){f=l,u=N.find(M=>typeof M=="function")||Math.random,s=N.find(M=>[1,2,3].includes(M))||2,p()},g.links=function(l){return arguments.length?(t=l,p(),g):t},g.id=function(l){return arguments.length?(n=l,g):n},g.iterations=function(l){return arguments.length?(h=+l,g):h},g.strength=function(l){return arguments.length?(i=typeof l=="function"?l:P(+l),w(),g):i},g.distance=function(l){return arguments.length?(r=typeof l=="function"?l:P(+l),y(),g):r},g}var Qn={value:()=>{}};function Gt(){for(var t=0,n=arguments.length,i={},e;t<n;++t){if(!(e=arguments[t]+"")||e in i||/[\s.]/.test(e))throw new Error("illegal type: "+e);i[e]=[]}return new at(i)}function at(t){this._=t}function Zn(t,n){return t.trim().split(/^|\s+/).map(function(i){var e="",r=i.indexOf(".");if(r>=0&&(e=i.slice(r+1),i=i.slice(0,r)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:e}})}at.prototype=Gt.prototype={constructor:at,on:function(t,n){var i=this._,e=Zn(t+"",i),r,o=-1,f=e.length;if(arguments.length<2){for(;++o<f;)if((r=(t=e[o]).type)&&(r=Jn(i[r],t.name)))return r;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++o<f;)if(r=(t=e[o]).type)i[r]=Et(i[r],t.name,n);else if(n==null)for(r in i)i[r]=Et(i[r],t.name,null);return this},copy:function(){var t={},n=this._;for(var i in n)t[i]=n[i].slice();return new at(t)},call:function(t,n){if((r=arguments.length-2)>0)for(var i=new Array(r),e=0,r,o;e<r;++e)i[e]=arguments[e+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],e=0,r=o.length;e<r;++e)o[e].value.apply(n,i)},apply:function(t,n,i){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var e=this._[t],r=0,o=e.length;r<o;++r)e[r].value.apply(n,i)}};function Jn(t,n){for(var i=0,e=t.length,r;i<e;++i)if((r=t[i]).name===n)return r.value}function Et(t,n,i){for(var e=0,r=t.length;e<r;++e)if(t[e].name===n){t[e]=Qn,t=t.slice(0,e).concat(t.slice(e+1));break}return i!=null&&t.push({name:n,value:i}),t}var tt=0,it=0,nt=0,Xt=1e3,ct,et,lt=0,V=0,gt=0,rt=typeof performance=="object"&&performance.now?performance:Date,Yt=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Bt(){return V||(Yt(Vn),V=rt.now()+gt)}function Vn(){V=0}function dt(){this._call=this._time=this._next=null}dt.prototype=Ut.prototype={constructor:dt,restart:function(t,n,i){if(typeof t!="function")throw new TypeError("callback is not a function");i=(i==null?Bt():+i)+(n==null?0:+n),!this._next&&et!==this&&(et?et._next=this:ct=this,et=this),this._call=t,this._time=i,wt()},stop:function(){this._call&&(this._call=null,this._time=1/0,wt())}};function Ut(t,n,i){var e=new dt;return e.restart(t,n,i),e}function ti(){Bt(),++tt;for(var t=ct,n;t;)(n=V-t._time)>=0&&t._call.call(void 0,n),t=t._next;--tt}function Ot(){V=(lt=rt.now())+gt,tt=it=0;try{ti()}finally{tt=0,ii(),V=0}}function ni(){var t=rt.now(),n=t-lt;n>Xt&&(gt-=n,lt=t)}function ii(){for(var t,n=ct,i,e=1/0;n;)n._call?(e>n._time&&(e=n._time),t=n,n=n._next):(i=n._next,n._next=null,n=t?t._next=i:ct=i);et=t,wt(e)}function wt(t){if(!tt){it&&(it=clearTimeout(it));var n=t-V;n>24?(t<1/0&&(it=setTimeout(Ot,t-rt.now()-gt)),nt&&(nt=clearInterval(nt))):(nt||(lt=rt.now(),nt=setInterval(ni,Xt)),tt=1,Yt(Ot))}}const ei=1664525,ri=1013904223,Dt=4294967296;function oi(){let t=1;return()=>(t=(ei*t+ri)%Dt)/Dt}var Ft=3;function pt(t){return t.x}function jt(t){return t.y}function si(t){return t.z}var fi=10,ai=Math.PI*(3-Math.sqrt(5)),hi=Math.PI*20/(9+Math.sqrt(221));function ht(t,n){n=n||2;var i=Math.min(Ft,Math.max(1,Math.round(n))),e,r=1,o=.001,f=1-Math.pow(o,1/300),s=0,a=.6,c=new Map,u=Ut(g),h=Gt("tick","end"),_=oi();t==null&&(t=[]);function g(){p(),h.call("tick",e),r<o&&(u.stop(),h.call("end",e))}function p(l){var N,M=t.length,z;l===void 0&&(l=1);for(var x=0;x<l;++x)for(r+=(s-r)*f,c.forEach(function($){$(r)}),N=0;N<M;++N)z=t[N],z.fx==null?z.x+=z.vx*=a:(z.x=z.fx,z.vx=0),i>1&&(z.fy==null?z.y+=z.vy*=a:(z.y=z.fy,z.vy=0)),i>2&&(z.fz==null?z.z+=z.vz*=a:(z.z=z.fz,z.vz=0));return e}function w(){for(var l=0,N=t.length,M;l<N;++l){if(M=t[l],M.index=l,M.fx!=null&&(M.x=M.fx),M.fy!=null&&(M.y=M.fy),M.fz!=null&&(M.z=M.fz),isNaN(M.x)||i>1&&isNaN(M.y)||i>2&&isNaN(M.z)){var z=fi*(i>2?Math.cbrt(.5+l):i>1?Math.sqrt(.5+l):l),x=l*ai,$=l*hi;i===1?M.x=z:i===2?(M.x=z*Math.cos(x),M.y=z*Math.sin(x)):(M.x=z*Math.sin(x)*Math.cos($),M.y=z*Math.cos(x),M.z=z*Math.sin(x)*Math.sin($))}(isNaN(M.vx)||i>1&&isNaN(M.vy)||i>2&&isNaN(M.vz))&&(M.vx=0,i>1&&(M.vy=0),i>2&&(M.vz=0))}}function y(l){return l.initialize&&l.initialize(t,_,i),l}return w(),e={tick:p,restart:function(){return u.restart(g),e},stop:function(){return u.stop(),e},numDimensions:function(l){return arguments.length?(i=Math.min(Ft,Math.max(1,Math.round(l))),c.forEach(y),e):i},nodes:function(l){return arguments.length?(t=l,w(),c.forEach(y),e):t},alpha:function(l){return arguments.length?(r=+l,e):r},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(f=+l,e):+f},alphaTarget:function(l){return arguments.length?(s=+l,e):s},velocityDecay:function(l){return arguments.length?(a=1-l,e):1-a},randomSource:function(l){return arguments.length?(_=l,c.forEach(y),e):_},force:function(l,N){return arguments.length>1?(N==null?c.delete(l):c.set(l,y(N)),e):c.get(l)},find:function(){var l=Array.prototype.slice.call(arguments),N=l.shift()||0,M=(i>1?l.shift():null)||0,z=(i>2?l.shift():null)||0,x=l.shift()||1/0,$=0,I=t.length,q,Y,W,R,v,m;for(x*=x,$=0;$<I;++$)v=t[$],q=N-v.x,Y=M-(v.y||0),W=z-(v.z||0),R=q*q+Y*Y+W*W,R<x&&(m=v,x=R);return m},on:function(l,N){return arguments.length>1?(h.on(l,N),e):h.on(l)}}}function ut(){var t,n,i,e,r,o=P(-30),f,s=1,a=1/0,c=.81;function u(p){var w,y=t.length,l=(n===1?zt(t,pt):n===2?Nt(t,pt,jt):n===3?mt(t,pt,jt,si):null).visitAfter(_);for(r=p,w=0;w<y;++w)i=t[w],l.visit(g)}function h(){if(t){var p,w=t.length,y;for(f=new Array(w),p=0;p<w;++p)y=t[p],f[y.index]=+o(y,p,t)}}function _(p){var w=0,y,l,N=0,M,z,x,$,I=p.length;if(I){for(M=z=x=$=0;$<I;++$)(y=p[$])&&(l=Math.abs(y.value))&&(w+=y.value,N+=l,M+=l*(y.x||0),z+=l*(y.y||0),x+=l*(y.z||0));w*=Math.sqrt(4/I),p.x=M/N,n>1&&(p.y=z/N),n>2&&(p.z=x/N)}else{y=p,y.x=y.data.x,n>1&&(y.y=y.data.y),n>2&&(y.z=y.data.z);do w+=f[y.data.index];while(y=y.next)}p.value=w}function g(p,w,y,l,N){if(!p.value)return!0;var M=[y,l,N][n-1],z=p.x-i.x,x=n>1?p.y-i.y:0,$=n>2?p.z-i.z:0,I=M-w,q=z*z+x*x+$*$;if(I*I/c<q)return q<a&&(z===0&&(z=Q(e),q+=z*z),n>1&&x===0&&(x=Q(e),q+=x*x),n>2&&$===0&&($=Q(e),q+=$*$),q<s&&(q=Math.sqrt(s*q)),i.vx+=z*p.value*r/q,n>1&&(i.vy+=x*p.value*r/q),n>2&&(i.vz+=$*p.value*r/q)),!0;if(p.length||q>=a)return;(p.data!==i||p.next)&&(z===0&&(z=Q(e),q+=z*z),n>1&&x===0&&(x=Q(e),q+=x*x),n>2&&$===0&&($=Q(e),q+=$*$),q<s&&(q=Math.sqrt(s*q)));do p.data!==i&&(I=f[p.data.index]*r/q,i.vx+=z*I,n>1&&(i.vy+=x*I),n>2&&(i.vz+=$*I));while(p=p.next)}return u.initialize=function(p,...w){t=p,e=w.find(y=>typeof y=="function")||Math.random,n=w.find(y=>[1,2,3].includes(y))||2,h()},u.strength=function(p){return arguments.length?(o=typeof p=="function"?p:P(+p),h(),u):o},u.distanceMin=function(p){return arguments.length?(s=p*p,u):Math.sqrt(s)},u.distanceMax=function(p){return arguments.length?(a=p*p,u):Math.sqrt(a)},u.theta=function(p){return arguments.length?(c=p*p,u):Math.sqrt(c)},u}function Ht(t){var n=P(.1),i,e,r;typeof t!="function"&&(t=P(t==null?0:+t));function o(s){for(var a=0,c=i.length,u;a<c;++a)u=i[a],u.vx+=(r[a]-u.x)*e[a]*s}function f(){if(i){var s,a=i.length;for(e=new Array(a),r=new Array(a),s=0;s<a;++s)e[s]=isNaN(r[s]=+t(i[s],s,i))?0:+n(i[s],s,i)}}return o.initialize=function(s){i=s,f()},o.strength=function(s){return arguments.length?(n=typeof s=="function"?s:P(+s),f(),o):n},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:P(+s),f(),o):t},o}function Kt(t){var n=P(.1),i,e,r;typeof t!="function"&&(t=P(t==null?0:+t));function o(s){for(var a=0,c=i.length,u;a<c;++a)u=i[a],u.vy+=(r[a]-u.y)*e[a]*s}function f(){if(i){var s,a=i.length;for(e=new Array(a),r=new Array(a),s=0;s<a;++s)e[s]=isNaN(r[s]=+t(i[s],s,i))?0:+n(i[s],s,i)}}return o.initialize=function(s){i=s,f()},o.strength=function(s){return arguments.length?(n=typeof s=="function"?s:P(+s),f(),o):n},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:P(+s),f(),o):t},o}function Lt(t){var n=P(.1),i,e,r;typeof t!="function"&&(t=P(t==null?0:+t));function o(s){for(var a=0,c=i.length,u;a<c;++a)u=i[a],u.vz+=(r[a]-u.z)*e[a]*s}function f(){if(i){var s,a=i.length;for(e=new Array(a),r=new Array(a),s=0;s<a;++s)e[s]=isNaN(r[s]=+t(i[s],s,i))?0:+n(i[s],s,i)}}return o.initialize=function(s){i=s,f()},o.strength=function(s){return arguments.length?(n=typeof s=="function"?s:P(+s),f(),o):n},o.z=function(s){return arguments.length?(t=typeof s=="function"?s:P(+s),f(),o):t},o}const Z=.55,ui=12,ci=60,vt=60;function li(t){const n=new Map(t.map((i,e)=>[i.id,e]));return t.map(i=>`${i.parents.map(r=>n.get(r)??-1).join(".")}:${i.radius.toFixed(2)}`).join("|")}function gi(t,n,i){const[e,r,o]=t,f=e*Math.cos(n)+o*Math.sin(n),s=-e*Math.sin(n)+o*Math.cos(n),a=r*Math.cos(i)-s*Math.sin(i),c=r*Math.sin(i)+s*Math.cos(i);return[f,a,c]}function _i(t,n,i){const e=p=>Math.hypot(p[0],p[1],p[2]),r=e(n),o=e(i);if(r<1e-9||o<1e-9)return t;const f=[n[0]/r,n[1]/r,n[2]/r],s=[i[0]/o,i[1]/o,i[2]/o],a=[f[1]*s[2]-f[2]*s[1],f[2]*s[0]-f[0]*s[2],f[0]*s[1]-f[1]*s[0]],c=e(a),u=f[0]*s[0]+f[1]*s[1]+f[2]*s[2];if(c<1e-9)return u>0?t:[-t[0],-t[1],-t[2]];const h=[a[0]/c,a[1]/c,a[2]/c],_=h[0]*t[0]+h[1]*t[1]+h[2]*t[2],g=[h[1]*t[2]-h[2]*t[1],h[2]*t[0]-h[0]*t[2],h[0]*t[1]-h[1]*t[0]];return[t[0]*u+g[0]*c+h[0]*_*(1-u),t[1]*u+g[1]*c+h[1]*_*(1-u),t[2]*u+g[2]*c+h[2]*_*(1-u)]}function Tt(t,n,i){if(n.length===0)return t;let e=0;for(const r of n)e+=i.get(r.id.slice(6))??Z;return e/=n.length,Math.max(t+2,Math.sqrt(n.length)*e*1.6)}function xt(t,n,i){const e=n<=1?0:1-2*(t+.5)/n,r=Math.sqrt(Math.max(0,1-e*e)),o=t*Math.PI*(3-Math.sqrt(5));return[Math.cos(o)*r*i,e*i,Math.sin(o)*r*i]}function Qt(t,n,i=()=>{},e="clumps"){const r=new Map(t.map(v=>[v.id,v])),o=new Map,f=[];for(const v of t)v.group===null?f.push(v):o.set(v.group,[...o.get(v.group)??[],v]);const s=new Map,a=new Map,c=new Map,u=new Set;let h=0;const _=Math.max(1,o.size),g=new Map;for(const[v,m]of o){const A=m.filter(b=>b.seed!==void 0),d=[0,0,0];for(const b of A)d[0]+=b.seed[0],d[1]+=b.seed[1],d[2]+=b.seed[2];A.length>0&&(d[0]/=A.length,d[1]/=A.length,d[2]/=A.length,c.set(v,d)),m.every(b=>b.frozen===!0&&b.seed!==void 0)&&u.add(v);const k=new Map,O=A.length===0?li(m):null,G=O===null?void 0:g.get(O);if(A.length===m.length)for(const b of m)k.set(b.id,[b.seed[0]-d[0],b.seed[1]-d[1],b.seed[2]-d[2]]);else if(G!==void 0){const b=Math.random()*Math.PI*2,E=(Math.random()-.5)*Math.PI;m.forEach((C,j)=>{k.set(C.id,gi(G[j]??[0,0,0],b,E))})}else{const b=m.map(S=>{const L={id:S.id,r:S.radius};return S.seed!==void 0&&(L.x=S.seed[0]-d[0],L.y=S.seed[1]-d[1],L.z=S.seed[2]-d[2],S.frozen===!0&&(L.fx=L.x,L.fy=L.y,L.fz=L.z)),L}),E=new Set(m.map(S=>S.id)),C=[];for(const S of m)for(const L of S.parents)E.has(L)&&C.push({source:L,target:S.id});const j=new Map(m.map(S=>[S.id,S.radius])),B=ht(b,3).force("link",yt(C).id(S=>S.id).distance(n.link?S=>(j.get(S.source.id)??Z)+(j.get(S.target.id)??Z)+1.4:2.2)).force("charge",ut().strength(S=>n.charge?-6*(S.r/Z)**2:-6).distanceMax(ui)).force("center",st(0,0,0)).stop();n.collide&&B.force("collide",ft().radius(S=>S.r*1.2));for(let S=0;S<ci;S++)B.tick();const T=[0,0,0];for(const S of b)T[0]+=S.x??0,T[1]+=S.y??0,T[2]+=S.z??0;T[0]/=b.length,T[1]/=b.length,T[2]/=b.length;for(const S of b)k.set(S.id,[(S.x??0)-T[0],(S.y??0)-T[1],(S.z??0)-T[2]]);O!==null&&g.set(O,m.map(S=>k.get(S.id)??[0,0,0]))}let D=Z;for(const b of m){const E=k.get(b.id)??[0,0,0];s.set(b.id,E),D=Math.max(D,Math.hypot(E[0],E[1],E[2])+b.radius)}a.set(v,D),h+=1,h%50===0&&i(.3*(h/_))}i(.3);const p=v=>{const m=r.get(v);return m!==void 0&&m.group!==null?`group:${m.group}`:v},w=[],y=new Map;let l=!1;for(const[v]of o){const m=`group:${v}`,A=a.get(v)??Z,d={id:m,r:A},k=c.get(v);k!==void 0&&(d.x=k[0],d.y=k[1],d.z=k[2],u.has(v)&&(d.fx=k[0],d.fy=k[1],d.fz=k[2],l=!0)),y.set(m,A),w.push(d)}for(const v of f){const m={id:v.id,r:v.radius};v.seed!==void 0&&(m.x=v.seed[0],m.y=v.seed[1],m.z=v.seed[2],v.frozen===!0&&(m.fx=v.seed[0],m.fy=v.seed[1],m.fz=v.seed[2],l=!0)),y.set(v.id,v.radius),w.push(m)}const N=new Set,M=[];for(const v of t)for(const m of v.parents){if(!r.has(m))continue;const A=p(m),d=p(v.id);if(A===d)continue;const k=`${A}\0${d}`;N.has(k)||(N.add(k),M.push({source:A,target:d}))}const z=new Map;for(const v of M)if(v.source.startsWith("group:")!==v.target.startsWith("group:")){const m=v.source.startsWith("group:")?v.source:v.target,A=v.source.startsWith("group:")?v.target:v.source;z.has(m)||z.set(m,A)}const x=new Map;for(const v of w){const m=z.get(v.id);m!==void 0&&x.set(m,[...x.get(m)??[],v])}const $=w.reduce((v,m)=>v+m.r*m.r,0),I=w.filter(v=>!v.id.startsWith("group:"));I.forEach((v,m)=>{if(v.x!==void 0)return;const[A,d,k]=xt(m,I.length,Math.sqrt($)*1.2+10);v.x=A,v.y=d,v.z=k});for(const[v,m]of x){const A=w.find(k=>k.id===v),d=Math.sqrt(m.reduce((k,O)=>k+O.r*O.r,0))*1.4+2;m.forEach((k,O)=>{if(k.x!==void 0)return;const[G,D,b]=xt(O,m.length,d);k.x=(A?.x??0)+G,k.y=(A?.y??0)+D,k.z=(A?.z??0)+b})}const q=new Set;if(e==="spokes"){const v=A=>{const d=o.get(A)??[],k=new Set(d.map(G=>G.id)),O=d.find(G=>G.parents.some(D=>!k.has(D)))??d[0];return O===void 0?[0,0,0]:s.get(O.id)??[0,0,0]},m=[];for(const A of w){if(A.id.startsWith("group:")&&z.has(A.id)){q.add(A.id);continue}if(A.id.startsWith("group:"))m.push(A);else{const d=x.get(A.id)??[];let k=A.r;const O=Tt(A.r,d,a);for(const G of d){const D=G.id.slice(6),b=v(D);k=Math.max(k,O+Math.hypot(b[0],b[1],b[2])+2*(a.get(D)??Z))}m.push({id:A.id,r:k,x:A.x,y:A.y,z:A.z,...A.fx!==void 0?{fx:A.fx,fy:A.fy,fz:A.fz}:{}})}}if(!m.every(A=>A.fx!==void 0)){const A=ht(m,3).force("charge",ut().strength(d=>-1.5*d.r)).force("collide",ft().radius(d=>d.r*.9)).stop();l||A.force("center",st(0,0,0));for(let d=0;d<vt;d++)A.tick(),d%5===0&&i(.3+.7*(d/vt))}for(const A of m){const d=w.find(k=>k.id===A.id);d!==void 0&&d!==A&&(d.x=A.x,d.y=A.y,d.z=A.z)}for(const A of w){if(A.id.startsWith("group:")||!x.has(A.id))continue;const d=x.get(A.id)??[],k=Tt(A.r,d,a);d.forEach((O,G)=>{if(O.fx!==void 0||c.has(O.id.slice(6)))return;const D=v(O.id.slice(6)),b=xt(G,d.length,1),E=.35+.65*(G*.6180339887%1),C=A.r+1.4+k*E+Math.hypot(D[0],D[1],D[2]);O.x=(A.x??0)+b[0]*C,O.y=(A.y??0)+b[1]*C,O.z=(A.z??0)+b[2]*C})}}if(!w.every(v=>v.fx!==void 0)&&e!=="spokes"){const v=ht(w,3).force("link",yt(M).id(d=>d.id).distance(n.link?d=>(y.get(d.source.id)??Z)+(y.get(d.target.id)??Z)+1.4:2.2)).stop(),m=ut().strength(d=>n.charge?-6*(d.r/Z)**2:-6);if(n.reach!==void 0&&m.distanceMax(n.reach),v.force("charge",m),l||v.force("center",st(0,0,0)),n.collide&&v.force("collide",ft().radius(d=>d.r*1.05)),n.gravity){const d=k=>Math.min(1,(k.r/Z)**2*.08);v.force("gx",Ht(0).strength(d)).force("gy",Kt(0).strength(d)).force("gz",Lt(0).strength(d))}const A=vt;for(let d=0;d<A;d++)v.tick(),d%5===0&&i(.3+.7*(d/A))}const W=new Map(w.map(v=>[v.id,v]));if(e==="spokes")for(const[v,m]of o){if(m.some(j=>j.seed!==void 0))continue;const A=`group:${v}`,d=W.get(A),k=z.get(A),O=k===void 0?void 0:W.get(k);if(d===void 0||O===void 0)continue;const G=[(d.x??0)-(O.x??0),(d.y??0)-(O.y??0),(d.z??0)-(O.z??0)],D=new Set(m.map(j=>j.id)),b=m.find(j=>j.parents.some(B=>!D.has(B)))??m[0],E=s.get(b.id)??[0,0,0],C=[-E[0],-E[1],-E[2]];for(const j of m){const B=s.get(j.id)??[0,0,0];s.set(j.id,_i(B,C,G))}}const R={};for(const v of t){const m=W.get(p(v.id)),A=[m?.x??0,m?.y??0,m?.z??0],d=v.group===null?[0,0,0]:s.get(v.id)??[0,0,0];R[v.id]=[A[0]+d[0],A[1]+d[1],A[2]+d[2]]}return i(1),R}const ot=.55,Wt=80;function pi(t,n,i=()=>{}){const e=t.some(h=>h.seed===void 0),r=e?Qt(t,n,h=>i(.05*h),"spokes"):{};i(.05);const o=t.map(h=>{const _=h.seed??r[h.id],g={id:h.id,r:h.radius};return _!==void 0&&(g.x=_[0],g.y=_[1],g.z=_[2],h.frozen===!0&&h.seed!==void 0&&(g.fx=_[0],g.fy=_[1],g.fz=_[2])),g}),f=new Set(t.map(h=>h.id)),s=[];for(const h of t)for(const _ of h.parents)f.has(_)&&s.push({source:_,target:h.id});const a=new Map(t.map(h=>[h.id,h.radius])),c=o.some(h=>h.fx!==void 0);if(!o.every(h=>h.fx!==void 0)){const h=ht(o,3).force("link",yt(s).id(g=>g.id).distance(n.link?g=>(a.get(g.source.id)??ot)+(a.get(g.target.id)??ot)+1.4:2.2)).stop(),_=ut().strength(g=>n.charge?-6*(g.r/ot)**2:-6);if(n.reach!==void 0&&_.distanceMax(n.reach),h.force("charge",_),c||h.force("center",st(0,0,0)),n.collide&&h.force("collide",ft().radius(g=>g.r*1.2)),n.gravity){const g=p=>(p.r/ot)**2*.08;h.force("gx",Ht(0).strength(g)).force("gy",Kt(0).strength(g)).force("gz",Lt(0).strength(g))}e&&h.alpha(.6);for(let g=0;g<Wt;g++)h.tick(),g%2===0&&i(.05+.95*(g/Wt))}const u={};for(const h of o)u[h.id]=[h.x??0,h.y??0,h.z??0];return i(1),u}self.onmessage=t=>{const{generation:n,nodes:i,physics:e,arrangement:r}=t.data;let o=-1;const f=a=>{const c=Math.floor(a*100);c!==o&&(o=c,self.postMessage({generation:n,type:"progress",fraction:a}))},s=r==="galaxy"?pi(i,e,f):Qt(i,e,f,r);self.postMessage({generation:n,type:"done",positions:s})};