/** * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2. * Original file: /npm/d3-quadtree@3.0.1/src/index.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ function t(t,i,r,n){if(isNaN(i)||isNaN(r))return t;var e,h,s,o,a,u,l,_,f,x=t._root,c={data:n},y=t._x0,v=t._y0,d=t._x1,p=t._y1;if(!x)return t._root=c,t;for(;x.length;)if((u=i>=(h=(y+d)/2))?y=h:d=h,(l=r>=(s=(v+p)/2))?v=s:p=s,e=x,!(x=x[_=l<<1|u]))return e[_]=c,t;if(o=+t._x.call(null,x.data),a=+t._y.call(null,x.data),i===o&&r===a)return c.next=x,e?e[_]=c:t._root=c,t;do{e=e?e[_]=new Array(4):t._root=new Array(4),(u=i>=(h=(y+d)/2))?y=h:d=h,(l=r>=(s=(v+p)/2))?v=s:p=s}while((_=l<<1|u)==(f=(a>=s)<<1|o>=h));return e[f]=x,e[_]=c,t}function i(t,i,r,n,e){this.node=t,this.x0=i,this.y0=r,this.x1=n,this.y1=e}function r(t){return t[0]}function n(t){return t[1]}function e(t,i,e){var s=new h(null==i?r:i,null==e?n:e,NaN,NaN,NaN,NaN);return null==t?s:s.addAll(t)}function h(t,i,r,n,e,h){this._x=t,this._y=i,this._x0=r,this._y0=n,this._x1=e,this._y1=h,this._root=void 0}function s(t){for(var i={data:t.data},r=i;t=t.next;)r=r.next={data:t.data};return i}var o=e.prototype=h.prototype;o.copy=function(){var t,i,r=new h(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=s(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var e=0;e<4;++e)(i=n.source[e])&&(i.length?t.push({source:i,target:n.target[e]=new Array(4)}):n.target[e]=s(i));return r},o.add=function(i){const r=+this._x.call(null,i),n=+this._y.call(null,i);return t(this.cover(r,n),r,n,i)},o.addAll=function(i){var r,n,e,h,s=i.length,o=new Array(s),a=new Array(s),u=1/0,l=1/0,_=-1/0,f=-1/0;for(n=0;n_&&(_=e),hf&&(f=h));if(u>_||l>f)return this;for(this.cover(u,l).cover(_,f),n=0;nt||t>=e||n>i||i>=h;)switch(o=(ix||(s=u.y0)>c||(o=u.x1)<_||(a=u.y1)=p)<<1|t>=d)&&(u=y[y.length-1],y[y.length-1]=y[y.length-1-l],y[y.length-1-l]=u)}else{var w=t-+this._x.call(null,v.data),N=r-+this._y.call(null,v.data),g=w*w+N*N;if(g=(o=(c+v)/2))?c=o:v=o,(l=s>=(a=(y+d)/2))?y=a:d=a,i=x,!(x=x[_=l<<1|u]))return this;if(!x.length)break;(i[_+1&3]||i[_+2&3]||i[_+3&3])&&(r=i,f=_)}for(;x.data!==t;)if(n=x,!(x=x.next))return this;return(e=x.next)&&delete x.next,n?(e?n.next=e:delete n.next,this):i?(e?i[_]=e:delete i[_],(x=i[0]||i[1]||i[2]||i[3])&&x===(i[3]||i[2]||i[1]||i[0])&&!x.length&&(r?r[f]=x:this._root=x),this):(this._root=e,this)},o.removeAll=function(t){for(var i=0,r=t.length;i