// https://github.com/vasturiano/d3-binarytree v1.0.2 !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";function r(t,r,e){if(isNaN(r))return t;var n,i,o,s,h,a,u=t._root,f={data:e},l=t._x0,x=t._x1;if(!u)return t._root=f,t;for(;u.length;)if((s=r>=(i=(l+x)/2))?l=i:x=i,n=u,!(u=u[h=+s]))return n[h]=f,t;if(r===(o=+t._x.call(null,u.data)))return f.next=u,n?n[h]=f:t._root=f,t;do{n=n?n[h]=new Array(2):t._root=new Array(2),(s=r>=(i=(l+x)/2))?l=i:x=i}while((h=+s)==(a=+(o>=i)));return n[a]=u,n[h]=f,t}function e(t,r,e){this.node=t,this.x0=r,this.x1=e}function n(t){return t[0]}function i(t,r){var e=new o(null==r?n:r,NaN,NaN);return null==t?e:e.addAll(t)}function o(t,r,e){this._x=t,this._x0=r,this._x1=e,this._root=void 0}function s(t){for(var r={data:t.data},e=r;t=t.next;)e=e.next={data:t.data};return r}var h=i.prototype=o.prototype;h.copy=function(){var t,r,e=new o(this._x,this._x0,this._x1),n=this._root;if(!n)return e;if(!n.length)return e._root=s(n),e;for(t=[{source:n,target:e._root=new Array(2)}];n=t.pop();)for(var i=0;i<2;++i)(r=n.source[i])&&(r.length?t.push({source:r,target:n.target[i]=new Array(2)}):n.target[i]=s(r));return e},h.add=function(t){const e=+this._x.call(null,t);return r(this.cover(e),e,t)},h.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e);let i=1/0,o=-1/0;for(let r,s=0;so&&(o=r));if(i>o)return this;this.cover(i).cover(o);for(let i=0;it||t>=e;)switch(i=+(tu||(o=s.x1)=x))&&(s=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=s)}else{var _=Math.abs(t-+this._x.call(null,l.data));_=(s=(l+x)/2))?l=s:x=s,r=f,!(f=f[a=+h]))return this;if(!f.length)break;r[a+1&1]&&(e=r,u=a)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,n?(i?n.next=i:delete n.next,this):r?(i?r[a]=i:delete r[a],(f=r[0]||r[1])&&f===(r[1]||r[0])&&!f.length&&(e?e[u]=f:this._root=f),this):(this._root=i,this)},h.removeAll=function(t){for(var r=0,e=t.length;r