=m&&(m=x+1);!(b=v[m])&&++m=0;)(i=r[o])&&(s&&4^i.compareDocumentPosition(s)&&s.parentNode.insertBefore(i,s),s=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=ke);for(var n=this._groups,i=n.length,r=Array(i),o=0;o1?this.each((null==e?Be:"function"==typeof e?Xe:$e)(t,e,null==n?"":n)):Ue(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Ye:"function"==typeof e?Ge:Ve)(t,e)):this.node()[t]},classed:function(t,e){var n=He(t+"");if(arguments.length<2){for(var i=We(this.node()),r=-1,o=n.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),s=o.length;if(!(arguments.length<2)){for(a=e?bn:yn,i=0;i=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!i.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),s=-1,a=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s0)for(var n,i,r=Array(n),o=0;o>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?xi(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?xi(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=ci.exec(t))?new _i(e[1],e[2],e[3],1):(e=ui.exec(t))?new _i(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=li.exec(t))?xi(e[1],e[2],e[3],e[4]):(e=hi.exec(t))?xi(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=fi.exec(t))?ki(e[1],e[2]/100,e[3]/100,1):(e=di.exec(t))?ki(e[1],e[2]/100,e[3]/100,e[4]):pi.hasOwnProperty(t)?bi(pi[t]):"transparent"===t?new _i(NaN,NaN,NaN,0):null}function bi(t){return new _i(t>>16&255,t>>8&255,255&t,1)}function xi(t,e,n,i){return i<=0&&(t=e=n=NaN),new _i(t,e,n,i)}function mi(t,e,n,i){return 1===arguments.length?((r=t)instanceof ri||(r=yi(r)),r?new _i((r=r.rgb()).r,r.g,r.b,r.opacity):new _i):new _i(t,e,n,null==i?1:i);var r}function _i(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function wi(){return"#"+Ei(this.r)+Ei(this.g)+Ei(this.b)}function Ti(){const t=Ai(this.opacity);return(1===t?"rgb(":"rgba(")+Si(this.r)+", "+Si(this.g)+", "+Si(this.b)+(1===t?")":", "+t+")")}function Ai(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Si(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Ei(t){return((t=Si(t))<16?"0":"")+t.toString(16)}function ki(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Mi(t,e,n,i)}function Oi(t){if(t instanceof Mi)return new Mi(t.h,t.s,t.l,t.opacity);if(t instanceof ri||(t=yi(t)),!t)return new Mi;if(t instanceof Mi)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),o=Math.max(e,n,i),s=NaN,a=o-r,c=(o+r)/2;return a?(s=e===o?(n-i)/a+6*(n0&&c<1?0:s,new Mi(s,a,c,t.opacity)}function Mi(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function Ri(t){return(t=(t||0)%360)<0?t+360:t}function Ci(t){return Math.max(0,Math.min(1,t||0))}function Ii(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function Pi(t,e,n,i,r){var o=t*t,s=o*t;return((1-3*t+3*o-s)*e+(4-6*o+3*s)*n+(1+3*t+3*o-3*s)*i+s*r)/6}ni(ri,yi,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:gi,formatHex:gi,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Oi(this).formatHsl()},formatRgb:vi,toString:vi}),ni(_i,mi,ii(ri,{brighter:function(t){return t=null==t?si:Math.pow(si,t),new _i(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?oi:Math.pow(oi,t),new _i(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},clamp:function(){return new _i(Si(this.r),Si(this.g),Si(this.b),Ai(this.opacity))},displayable:function(){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:wi,formatHex:wi,formatHex8:function(){return"#"+Ei(this.r)+Ei(this.g)+Ei(this.b)+Ei(255*(isNaN(this.opacity)?1:this.opacity))},formatRgb:Ti,toString:Ti})),ni(Mi,(function(t,e,n,i){return 1===arguments.length?Oi(t):new Mi(t,e,n,null==i?1:i)}),ii(ri,{brighter:function(t){return t=null==t?si:Math.pow(si,t),new Mi(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?oi:Math.pow(oi,t),new Mi(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new _i(Ii(t>=240?t-240:t+120,r,i),Ii(t,r,i),Ii(t<120?t+240:t-120,r,i),this.opacity)},clamp:function(){return new Mi(Ri(this.h),Ci(this.s),Ci(this.l),Ai(this.opacity))},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){const t=Ai(this.opacity);return(1===t?"hsl(":"hsla(")+Ri(this.h)+", "+100*Ci(this.s)+"%, "+100*Ci(this.l)+"%"+(1===t?")":", "+t+")")}}));var Li=function(t){var e=this;return o(this,undefined),function(){return o(this,e),t}.bind(this)}.bind(void 0);function Di(t,e){return function(n){return t+n*e}}function zi(t){return 1==(t=+t)?Ni:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}(e,n,t):Li(isNaN(e)?n:e)}}function Ni(t,e){var n=e-t;return n?Di(t,n):Li(isNaN(t)?e:t)}var Fi=function t(e){var n=zi(e);function i(t,e){var i=n((t=mi(t)).r,(e=mi(e)).r),r=n(t.g,e.g),o=n(t.b,e.b),s=Ni(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=r(e),t.b=o(e),t.opacity=s(e),t+""}}return i.gamma=t,i}(1);function ji(t){return function(e){var n,i,r=e.length,o=Array(r),s=Array(r),a=Array(r);for(n=0;n=1?(n=1,e-1):Math.floor(n*e),r=t[i],o=t[i+1],s=i>0?t[i-1]:2*r-o,a=io&&(r=e.slice(o,r),a[s]?a[s]+=r:a[++s]=r),(n=n[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,c.push({i:s,x:Yi(n,i)})),o=Hi.lastIndex;return o=0&&e._call.call(void 0,t),e=e._next;--Ji}()}finally{Ji=0,function(){var t,e,n=Zi,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Zi=e);Ki=t,dr(i)}(),ir=0}}function fr(){var t=or.now(),e=t-nr;e>er&&(rr-=e,nr=t)}function dr(t){Ji||(Qi&&(Qi=clearTimeout(Qi)),t-ir>24?(t<1/0&&(Qi=setTimeout(hr,t-or.now()-rr)),tr&&(tr=clearInterval(tr))):(tr||(nr=or.now(),tr=setInterval(fr,er)),Ji=1,sr(hr)))}function pr(t,e,n){var i=this,r=new ur;return e=null==e?0:+e,r.restart(function(n){o(this,i),r.stop(),t(n+e)}.bind(this),e,n),r}ur.prototype=lr.prototype={constructor:ur,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?ar():+n)+(null==e?0:+e),this._next||Ki===this||(Ki?Ki._next=this:Zi=this,Ki=this),this._call=t,this._time=n,dr()},stop:function(){this._call&&(this._call=null,this._time=1/0,dr())}};var gr=qn("start","end","cancel","interrupt"),vr=[],yr=0,br=1,xr=2,mr=3,_r=4,wr=5,Tr=6;function Ar(t,e,n,i,r,o){var s=t.__transition;if(s){if(n in s)return}else t.__transition={};!function(t,e,n){var i,r=t.__transition;function o(c){var u,l,h,f;if(n.state!==br)return a();for(u in r)if((f=r[u]).name===n.name){if(f.state===mr)return pr(o);f.state===_r?(f.state=Tr,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete r[u]):+uyr)throw new Error("too late; already scheduled");return n}function Er(t,e){var n=kr(t,e);if(n.state>mr)throw new Error("too late; already running");return n}function kr(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Or(t,e){var n,i,r,o=t.__transition,s=!0;if(o){for(r in e=null==e?null:e+"",o)(n=o[r]).name===e?(i=n.state>xr&&n.state180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(r(n)+"rotate(",null,i)-2,x:Yi(t,e)})):e&&n.push(r(n)+"rotate("+e+i)}(o.rotate,s.rotate,a,c),function(t,e,n,o){t!==e?o.push({i:n.push(r(n)+"skewX(",null,i)-2,x:Yi(t,e)}):e&&n.push(r(n)+"skewX("+e+i)}(o.skewX,s.skewX,a,c),function(t,e,n,i,o,s){if(t!==n||e!==i){var a=o.push(r(o)+"scale(",null,",",null,")");s.push({i:a-4,x:Yi(t,n)},{i:a-2,x:Yi(e,i)})}else 1===n&&1===i||o.push(r(o)+"scale("+n+","+i+")")}(o.scaleX,o.scaleY,s.scaleX,s.scaleY,a,c),o=s=null,function(t){for(var e,n=-1,i=c.length;++n=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?Sr:Er;return function(){var s=o(this,t),a=s.on;a!==i&&(r=(i=a).copy()).on(e,n),s.on=r}}(n,t,e))},attr:function(t,e){var n=Ie(t),i="transform"===n?Dr:jr;return this.attrTween(t,"function"==typeof e?(n.local?Vr:Yr)(n,i,Fr(this,"attr."+t,e)):null==e?(n.local?$r:Br)(n):(n.local?Ur:Xr)(n,i,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var i=Ie(t);return this.tween(n,(i.local?Gr:Hr)(i,e))},style:function(t,e,n){var i="transform"==(t+="")?Lr:jr;return null==e?this.styleTween(t,function(t,e){var n,i,r;return function(){var o=Ue(this,t),s=(this.style.removeProperty(t),Ue(this,t));return o===s?null:o===n&&s===i?r:r=e(n=o,i=s)}}(t,i)).on("end.style."+t,to(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var i,r,o;return function(){var s=Ue(this,t),a=n(this),c=a+"";return null==a&&(this.style.removeProperty(t),c=a=Ue(this,t)),s===c?null:s===i&&c===r?o:(r=c,o=e(i=s,a))}}(t,i,Fr(this,"style."+t,e))).each(function(t,e){var n,i,r,o,s="style."+e;return function(){var a=Er(this,t),c=a.on,u=null==a.value[s]?o||(o=to(e)):void 0;c===n&&r===u||(i=(n=c).copy()).on("end."+s,r=u),a.on=i}}(this._id,t)):this.styleTween(t,function(t,e,n){var i,r;return function(){var o=Ue(this,t);return o===n+""?null:o===i?r:r=e(i=o,n)}}(t,i,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var i="style."+(t+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==e)return this.tween(i,null);if("function"!=typeof e)throw new Error;return this.tween(i,function(t,e,n){var i,r;function o(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&function(t,e,n){return function(i){this.style.setProperty(t,e.call(this,i),n)}}(t,o,n)),i}return o._value=e,o}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Fr(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function i(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&function(t){return function(e){this.textContent=t.call(this,e)}}(i)),e}return i._value=t,i}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var i,r=kr(this.node(),n).tween,o=0,s=r.length;o=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function fo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n1&&$(n)}else a=k[0][0],u=k[0][1],d=k[1][0],g=k[1][1];c=a,f=u,p=d,v=g;var N=Rn(m).attr("pointer-events","none"),F=N.selectAll(".overlay").attr("cursor",So[_]);if(n.touches)z.moved=B,z.ended=X;else{var j=Rn(n.view).on("mousemove.brush",B,!0).on("mouseup.brush",X,!0);s&&j.on("keydown.brush",(function(t){switch(t.keyCode){case 16:L=T&&A;break;case 18:w===vo&&(T&&(d=p-I*T,a=c+I*T),A&&(g=v-P*A,u=f+P*A),w=yo,$(t));break;case 32:w!==vo&&w!==yo||(T<0?d=p-I:T>0&&(a=c-I),A<0?g=v-P:A>0&&(u=f-P),w=go,F.attr("cursor",So.selection),$(t));break;default:return}lo(t)}),!0).on("keyup.brush",(function(t){switch(t.keyCode){case 16:L&&(b=x=L=!1,$(t));break;case 18:w===yo&&(T<0?d=p:T>0&&(a=c),A<0?g=v:A>0&&(u=f),w=vo,$(t));break;case 32:w===go&&(t.altKey?(T&&(d=p-I*T,a=c+I*T),A&&(g=v-P*A,u=f+P*A),w=yo):(T<0?d=p:T>0&&(a=c),A<0?g=v:A>0&&(u=f),w=vo),F.attr("cursor",So[_]),$(t));break;default:return}lo(t)}),!0),ti(n.view)}l.call(m),z.start(n,w.name)}function B(t){for(var e,n=ho(t.changedTouches||[t]);!(e=n()).done;){const t=e.value;for(var i,r=ho(D);!(i=r()).done;){const e=i.value;e.identifier===t.identifier&&(e.cur=Un(t,m))}}if(L&&!b&&!x&&1===D.length){const t=D[0];bo(t.cur[0]-t[0])>bo(t.cur[1]-t[1])?x=!0:b=!0}for(var o,s=ho(D);!(o=s()).done;){const t=o.value;t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1])}y=!0,lo(t),$(t)}function $(t){const e=D[0],n=e.point0;var i;switch(I=e[0]-n[0],P=e[1]-n[1],w){case go:case po:T&&(I=xo(O-a,mo(R-d,I)),c=a+I,p=d+I),A&&(P=xo(M-u,mo(C-g,P)),f=u+P,v=g+P);break;case vo:D[1]?(T&&(c=xo(O,mo(R,D[0][0])),p=xo(O,mo(R,D[1][0])),T=1),A&&(f=xo(M,mo(C,D[0][1])),v=xo(M,mo(C,D[1][1])),A=1)):(T<0?(I=xo(O-a,mo(R-a,I)),c=a+I,p=d):T>0&&(I=xo(O-d,mo(R-d,I)),c=a,p=d+I),A<0?(P=xo(M-u,mo(C-u,P)),f=u+P,v=g):A>0&&(P=xo(M-g,mo(C-g,P)),f=u,v=g+P));break;case yo:T&&(c=xo(O,mo(R,a-I*T)),p=xo(O,mo(R,d+I*T))),A&&(f=xo(M,mo(C,u-P*A)),v=xo(M,mo(C,g+P*A)))}p2?i-2:0),o=2;o/gi,">"):t}function os(t,e,n,i){var r=this;if(void 0===n&&(n=[-1,1]),void 0===i&&(i=!1),t&&Xo(e))if(-1===e.indexOf("\n"))t.text(e);else{const s=[t.text(),e].map(function(t){return o(this,r),t.replace(/[\s\n]/g,"")}.bind(this));if(s[0]!==s[1]){const s=e.split("\n"),a=i?s.length-1:1;t.html(""),s.forEach(function(e,i){o(this,r),t.append("tspan").attr("x",0).attr("dy",(0===i?n[0]*a:n[1])+"em").text(e)}.bind(this))}}}function ss(t){const e=t.getBBox(),n=e.x,i=e.y,r=e.width,o=e.height;return[{x:n,y:i+o},{x:n,y:i},{x:n+r,y:i},{x:n+r,y:i+o}]}function as(t,e){var n,i=this;const r=t&&(null==(n=t.touches||t.sourceEvent&&t.sourceEvent.touches)?void 0:n[0]);let s=[0,0];try{s=Un(r||t,e)}catch(t){}return s.map(function(t){return o(this,i),isNaN(t)?0:t}.bind(this))}function cs(t){const e=t.event,n=t.$el,i=n.subchart.main||n.main;let r;return e&&"brush"===e.type?r=e.selection:i&&(r=i.select(".bb-brush").node())&&(r=Do(r)),r}function us(t){return!("rect"in t)||"rect"in t&&t.hasAttribute("width")&&t.rect.width!==+t.getAttribute("width")?t.rect=t.getBoundingClientRect():t.rect}function ls(t,e,n){void 0===t&&(t=!0),void 0===e&&(e=0),void 0===n&&(n=1e4);const i=Cn.crypto||Cn.msCrypto,r=i?e+i.getRandomValues(new Uint32Array(1))[0]%(n-e+1):Math.floor(Math.random()*(n-e)+e);return t?r+"":r}function hs(t,e,n,i,r){if(n>i)return-1;const o=Math.floor((n+i)/2);let s=t[o],a=s.x,c=s.w,u=void 0===c?0:c;return r&&(a=t[o].y,u=t[o].h),e>=a&&e<=a+u?o:e1?n-1:0),r=1;r