// https://d3js.org/d3-quadtree/ v1.0.5 Copyright 2018 Mike Bostock !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.d3=t.d3||{})}(this,function(t){"use strict";function i(t,i,e,r){if(isNaN(i)||isNaN(e))return t;var n,h,s,o,a,u,l,_,f,y=t._root,x={data:r},c=t._x0,d=t._y0,v=t._x1,p=t._y1;if(!y)return t._root=x,t;for(;y.length;)if((u=i>=(h=(c+v)/2))?c=h:v=h,(l=e>=(s=(d+p)/2))?d=s:p=s,n=y,!(y=y[_=l<<1|u]))return n[_]=x,t;if(o=+t._x.call(null,y.data),a=+t._y.call(null,y.data),i===o&&e===a)return x.next=y,n?n[_]=x:t._root=x,t;do{n=n?n[_]=new Array(4):t._root=new Array(4),(u=i>=(h=(c+v)/2))?c=h:v=h,(l=e>=(s=(d+p)/2))?d=s:p=s}while((_=l<<1|u)==(f=(a>=s)<<1|o>=h));return n[f]=y,n[_]=x,t}function e(t,i,e,r,n){this.node=t,this.x0=i,this.y0=e,this.x1=r,this.y1=n}function r(t){return t[0]}function n(t){return t[1]}function h(t,i,e){var h=new s(null==i?r:i,null==e?n:e,NaN,NaN,NaN,NaN);return null==t?h:h.addAll(t)}function s(t,i,e,r,n,h){this._x=t,this._y=i,this._x0=e,this._y0=r,this._x1=n,this._y1=h,this._root=void 0}function o(t){for(var i={data:t.data},e=i;t=t.next;)e=e.next={data:t.data};return i}var a=h.prototype=s.prototype;a.copy=function(){var t,i,e=new s(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=o(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var n=0;n<4;++n)(i=r.source[n])&&(i.length?t.push({source:i,target:r.target[n]=new Array(4)}):r.target[n]=o(i));return e},a.add=function(t){var e=+this._x.call(null,t),r=+this._y.call(null,t);return i(this.cover(e,r),e,r,t)},a.addAll=function(t){var e,r,n,h,s=t.length,o=new Array(s),a=new Array(s),u=1/0,l=1/0,_=-1/0,f=-1/0;for(r=0;r_&&(_=n),hf&&(f=h));for(_t||t>n||r>i||i>h))return this;var s,o,a=n-e,u=this._root;switch(o=(i<(r+h)/2)<<1|t<(e+n)/2){case 0:do{(s=new Array(4))[o]=u,u=s}while(h=r+(a*=2),t>(n=e+a)||i>h);break;case 1:do{(s=new Array(4))[o]=u,u=s}while(h=r+(a*=2),(e=n-a)>t||i>h);break;case 2:do{(s=new Array(4))[o]=u,u=s}while(r=h-(a*=2),t>(n=e+a)||r>i);break;case 3:do{(s=new Array(4))[o]=u,u=s}while(r=h-(a*=2),(e=n-a)>t||r>i)}this._root&&this._root.length&&(this._root=u)}return this._x0=e,this._y0=r,this._x1=n,this._y1=h,this},a.data=function(){var t=[];return this.visit(function(i){if(!i.length)do{t.push(i.data)}while(i=i.next)}),t},a.extent=function(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]]},a.find=function(t,i,r){var n,h,s,o,a,u,l,_=this._x0,f=this._y0,y=this._x1,x=this._y1,c=[],d=this._root;for(d&&c.push(new e(d,_,f,y,x)),null==r?r=1/0:(_=t-r,f=i-r,y=t+r,x=i+r,r*=r);u=c.pop();)if(!(!(d=u.node)||(h=u.x0)>y||(s=u.y0)>x||(o=u.x1)<_||(a=u.y1)=p)<<1|t>=v)&&(u=c[c.length-1],c[c.length-1]=c[c.length-1-l],c[c.length-1-l]=u)}else{var w=t-+this._x.call(null,d.data),N=i-+this._y.call(null,d.data),g=w*w+N*N;if(g=(o=(x+d)/2))?x=o:d=o,(l=s>=(a=(c+v)/2))?c=a:v=a,i=y,!(y=y[_=l<<1|u]))return this;if(!y.length)break;(i[_+1&3]||i[_+2&3]||i[_+3&3])&&(e=i,f=_)}for(;y.data!==t;)if(r=y,!(y=y.next))return this;return(n=y.next)&&delete y.next,r?(n?r.next=n:delete r.next,this):i?(n?i[_]=n:delete i[_],(y=i[0]||i[1]||i[2]||i[3])&&y===(i[3]||i[2]||i[1]||i[0])&&!y.length&&(e?e[f]=y:this._root=y),this):(this._root=n,this)},a.removeAll=function(t){for(var i=0,e=t.length;i