=x&&(x=m+1);!(b=y[x])&&++x=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=Gt);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?nn:"function"==typeof n?rn:en)(t,n,null==e?"":e)):on(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?an:"function"==typeof n?cn:un)(t,n)):this.node()[t]},classed:function(t,n){var e=fn(t+"");if(arguments.length<2){for(var r=sn(this.node()),i=-1,o=e.length;++i()=>t;function Kn(t,{sourceEvent:n,subject:e,target:r,identifier:i,active:o,x:a,y:u,dx:c,dy:f,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:s}})}function Qn(t){return!t.ctrlKey&&!t.button}function Jn(){return this.parentNode}function te(t,n){return null==n?{x:t.x,y:t.y}:n}function ne(){return navigator.maxTouchPoints||"ontouchstart"in this}function ee(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function re(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function ie(){}Kn.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var oe=.7,ae=1/oe,ue="\\s*([+-]?\\d+)\\s*",ce="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",fe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",se=/^#([0-9a-f]{3,8})$/,le=new RegExp(`^rgb\\(${ue},${ue},${ue}\\)$`),he=new RegExp(`^rgb\\(${fe},${fe},${fe}\\)$`),de=new RegExp(`^rgba\\(${ue},${ue},${ue},${ce}\\)$`),pe=new RegExp(`^rgba\\(${fe},${fe},${fe},${ce}\\)$`),ge=new RegExp(`^hsl\\(${ce},${fe},${fe}\\)$`),ye=new RegExp(`^hsla\\(${ce},${fe},${fe},${ce}\\)$`),ve={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function _e(){return this.rgb().formatHex()}function be(){return this.rgb().formatRgb()}function me(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=se.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?xe(n):3===e?new Te(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?we(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?we(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=le.exec(t))?new Te(n[1],n[2],n[3],1):(n=he.exec(t))?new Te(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=de.exec(t))?we(n[1],n[2],n[3],n[4]):(n=pe.exec(t))?we(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=ge.exec(t))?Pe(n[1],n[2]/100,n[3]/100,1):(n=ye.exec(t))?Pe(n[1],n[2]/100,n[3]/100,n[4]):ve.hasOwnProperty(t)?xe(ve[t]):"transparent"===t?new Te(NaN,NaN,NaN,0):null}function xe(t){return new Te(t>>16&255,t>>8&255,255&t,1)}function we(t,n,e,r){return r<=0&&(t=n=e=NaN),new Te(t,n,e,r)}function Me(t){return t instanceof ie||(t=me(t)),t?new Te((t=t.rgb()).r,t.g,t.b,t.opacity):new Te}function Ae(t,n,e,r){return 1===arguments.length?Me(t):new Te(t,n,e,null==r?1:r)}function Te(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function Se(){return`#${Ce(this.r)}${Ce(this.g)}${Ce(this.b)}`}function Ee(){const t=ke(this.opacity);return`${1===t?"rgb(":"rgba("}${Ne(this.r)}, ${Ne(this.g)}, ${Ne(this.b)}${1===t?")":`, ${t})`}`}function ke(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ne(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Ce(t){return((t=Ne(t))<16?"0":"")+t.toString(16)}function Pe(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new Re(t,n,e,r)}function ze(t){if(t instanceof Re)return new Re(t.h,t.s,t.l,t.opacity);if(t instanceof ie||(t=me(t)),!t)return new Re;if(t instanceof Re)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,c=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e0&&c<1?0:a,new Re(a,u,c,t.opacity)}function De(t,n,e,r){return 1===arguments.length?ze(t):new Re(t,n,e,null==r?1:r)}function Re(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function Fe(t){return(t=(t||0)%360)<0?t+360:t}function qe(t){return Math.max(0,Math.min(1,t||0))}function Oe(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}ee(ie,me,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:_e,formatHex:_e,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ze(this).formatHsl()},formatRgb:be,toString:be}),ee(Te,Ae,re(ie,{brighter(t){return t=null==t?ae:Math.pow(ae,t),new Te(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?oe:Math.pow(oe,t),new Te(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Te(Ne(this.r),Ne(this.g),Ne(this.b),ke(this.opacity))},displayable(){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:Se,formatHex:Se,formatHex8:function(){return`#${Ce(this.r)}${Ce(this.g)}${Ce(this.b)}${Ce(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ee,toString:Ee})),ee(Re,De,re(ie,{brighter(t){return t=null==t?ae:Math.pow(ae,t),new Re(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?oe:Math.pow(oe,t),new Re(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new Te(Oe(t>=240?t-240:t+120,i,r),Oe(t,i,r),Oe(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Re(Fe(this.h),qe(this.s),qe(this.l),ke(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ke(this.opacity);return`${1===t?"hsl(":"hsla("}${Fe(this.h)}, ${100*qe(this.s)}%, ${100*qe(this.l)}%${1===t?")":`, ${t})`}`}}));const Ue=Math.PI/180,Ie=180/Math.PI,Be=.96422,Ye=.82521,Le=4/29,je=6/29,$e=3*je*je;function He(t){if(t instanceof Ge)return new Ge(t.l,t.a,t.b,t.opacity);if(t instanceof tr)return nr(t);t instanceof Te||(t=Me(t));var n,e,r=Ke(t.r),i=Ke(t.g),o=Ke(t.b),a=Ve((.2225045*r+.7168786*i+.0606169*o)/1);return r===i&&i===o?n=e=a:(n=Ve((.4360747*r+.3850649*i+.1430804*o)/Be),e=Ve((.0139322*r+.0971045*i+.7141733*o)/Ye)),new Ge(116*a-16,500*(n-a),200*(a-e),t.opacity)}function Xe(t,n,e,r){return 1===arguments.length?He(t):new Ge(t,n,e,null==r?1:r)}function Ge(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function Ve(t){return t>.008856451679035631?Math.pow(t,1/3):t/$e+Le}function We(t){return t>je?t*t*t:$e*(t-Le)}function Ze(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ke(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Qe(t){if(t instanceof tr)return new tr(t.h,t.c,t.l,t.opacity);if(t instanceof Ge||(t=He(t)),0===t.a&&0===t.b)return new tr(NaN,0=1?(e=1,n-1):Math.floor(e*n),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,u=r()=>t;function vr(t,n){return function(e){return t+e*n}}function _r(t,n){var e=n-t;return e?vr(t,e>180||e<-180?e-360*Math.round(e/360):e):yr(isNaN(t)?n:t)}function br(t){return 1==(t=+t)?mr:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):yr(isNaN(n)?e:n)}}function mr(t,n){var e=n-t;return e?vr(t,e):yr(isNaN(t)?n:t)}var xr=function t(n){var e=br(n);function r(t,n){var r=e((t=Ae(t)).r,(n=Ae(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=mr(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function wr(t){return function(n){var e,r,i=n.length,o=new Array(i),a=new Array(i),u=new Array(i);for(e=0;eo&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,c.push({i:a,x:Nr(e,r)})),o=zr.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Nr(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,c),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Nr(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,c),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:Nr(t,e)},{i:u-2,x:Nr(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,c),o=a=null,function(t){for(var n,e=-1,r=c.length;++e=0&&n._call.call(void 0,t),n=n._next;--ri}function yi(){ui=(ai=fi.now())+ci,ri=ii=0;try{gi()}finally{ri=0,function(){var t,n,e=ni,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:ni=n);ei=t,_i(r)}(),ui=0}}function vi(){var t=fi.now(),n=t-ai;n>1e3&&(ci-=n,ai=t)}function _i(t){ri||(ii&&(ii=clearTimeout(ii)),t-ui>24?(t<1/0&&(ii=setTimeout(yi,t-fi.now()-ci)),oi&&(oi=clearInterval(oi))):(oi||(ai=fi.now(),oi=setInterval(vi,1e3)),ri=1,si(yi)))}function bi(t,n,e){var r=new di;return n=null==n?0:+n,r.restart((e=>{r.stop(),t(e+n)}),n,e),r}di.prototype=pi.prototype={constructor:di,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?li():+e)+(null==n?0:+n),this._next||ei===this||(ei?ei._next=this:ni=this,ei=this),this._call=t,this._time=e,_i()},stop:function(){this._call&&(this._call=null,this._time=1/0,_i())}};var mi=_t("start","end","cancel","interrupt"),xi=[];function wi(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(t){e.state=1,e.timer.restart(a,e.delay,e.time),e.delay<=t&&a(t-e.delay)}function a(o){var f,s,l,h;if(1!==e.state)return c();for(f in i)if((h=i[f]).name===e.name){if(3===h.state)return bi(a);4===h.state?(h.state=6,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[f]):+f0)throw new Error("too late; already scheduled");return e}function Ai(t,n){var e=Ti(t,n);if(e.state>3)throw new Error("too late; already running");return e}function Ti(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Si(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>2&&e.state<5,e.state=6,e.timer.stop(),e.on.call(r?"interrupt":"cancel",t,t.__data__,e.index,e.group),delete o[i]):a=!1;a&&delete t.__transition}}function Ei(t,n){var e,r;return function(){var i=Ai(this,t),o=i.tween;if(o!==e)for(var a=0,u=(r=e=o).length;a=0&&(t=t.slice(0,n)),!t||"start"===t}))}(n)?Mi:Ai;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}var Gi=On.prototype.constructor;function Vi(t){return function(){this.style.removeProperty(t)}}function Wi(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}function Zi(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&Wi(t,o,e)),r}return o._value=n,o}function Ki(t){return function(n){this.textContent=t.call(this,n)}}function Qi(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&Ki(r)),n}return r._value=t,r}var Ji=0;function to(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function no(t){return On().transition(t)}function eo(){return++Ji}var ro=On.prototype;to.prototype=no.prototype={constructor:to,select:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=Ct(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>t;function Po(t,{sourceEvent:n,target:e,selection:r,mode:i,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function zo(t){t.stopImmediatePropagation()}function Do(t){t.preventDefault(),t.stopImmediatePropagation()}var Ro={name:"drag"},Fo={name:"space"},qo={name:"handle"},Oo={name:"center"};const{abs:Uo,max:Io,min:Bo}=Math;function Yo(t){return[+t[0],+t[1]]}function Lo(t){return[Yo(t[0]),Yo(t[1])]}var jo={name:"x",handles:["w","e"].map(Ko),input:function(t,n){return null==t?null:[[+t[0],n[0][1]],[+t[1],n[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},$o={name:"y",handles:["n","s"].map(Ko),input:function(t,n){return null==t?null:[[n[0][0],+t[0]],[n[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},Ho={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(Ko),input:function(t){return null==t?null:Lo(t)},output:function(t){return t}},Xo={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Go={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},Vo={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},Wo={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},Zo={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function Ko(t){return{type:t}}function Qo(t){return!t.ctrlKey&&!t.button}function Jo(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function ta(){return navigator.maxTouchPoints||"ontouchstart"in this}function na(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function ea(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}function ra(t){var n,e=Jo,r=Qo,i=ta,o=!0,a=_t("start","brush","end"),u=6;function c(n){var e=n.property("__brush",g).selectAll(".overlay").data([Ko("overlay")]);e.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Xo.overlay).merge(e).each((function(){var t=na(this).extent;Un(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])})),n.selectAll(".selection").data([Ko("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Xo.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=n.selectAll(".handle").data(t.handles,(function(t){return t.type}));r.exit().remove(),r.enter().append("rect").attr("class",(function(t){return"handle handle--"+t.type})).attr("cursor",(function(t){return Xo[t.type]})),n.each(f).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",h).filter(i).on("touchstart.brush",h).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(){var t=Un(this),n=na(this).selection;n?(t.selectAll(".selection").style("display",null).attr("x",n[0][0]).attr("y",n[0][1]).attr("width",n[1][0]-n[0][0]).attr("height",n[1][1]-n[0][1]),t.selectAll(".handle").style("display",null).attr("x",(function(t){return"e"===t.type[t.type.length-1]?n[1][0]-u/2:n[0][0]-u/2})).attr("y",(function(t){return"s"===t.type[0]?n[1][1]-u/2:n[0][1]-u/2})).attr("width",(function(t){return"n"===t.type||"s"===t.type?n[1][0]-n[0][0]+u:u})).attr("height",(function(t){return"e"===t.type||"w"===t.type?n[1][1]-n[0][1]+u:u}))):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function s(t,n,e){var r=t.__brush.emitter;return!r||e&&r.clean?new l(t,n,e):r}function l(t,n,e){this.that=t,this.args=n,this.state=t.__brush,this.active=0,this.clean=e}function h(e){if((!n||e.touches)&&r.apply(this,arguments)){var i,a,u,c,l,h,d,p,g,y,v,_=this,b=e.target.__data__.type,m="selection"===(o&&e.metaKey?b="overlay":b)?Ro:o&&e.altKey?Oo:qo,x=t===$o?null:Wo[b],w=t===jo?null:Zo[b],M=na(_),A=M.extent,T=M.selection,S=A[0][0],E=A[0][1],k=A[1][0],N=A[1][1],C=0,P=0,z=x&&w&&o&&e.shiftKey,D=Array.from(e.touches||[e],(t=>{const n=t.identifier;return(t=jn(t,_)).point0=t.slice(),t.identifier=n,t}));Si(_);var R=s(_,arguments,!0).beforestart();if("overlay"===b){T&&(g=!0);const n=[D[0],D[1]||D[0]];M.selection=T=[[i=t===$o?S:Bo(n[0][0],n[1][0]),u=t===jo?E:Bo(n[0][1],n[1][1])],[l=t===$o?k:Io(n[0][0],n[1][0]),d=t===jo?N:Io(n[0][1],n[1][1])]],D.length>1&&I(e)}else i=T[0][0],u=T[0][1],l=T[1][0],d=T[1][1];a=i,c=u,h=l,p=d;var F=Un(_).attr("pointer-events","none"),q=F.selectAll(".overlay").attr("cursor",Xo[b]);if(e.touches)R.moved=U,R.ended=B;else{var O=Un(e.view).on("mousemove.brush",U,!0).on("mouseup.brush",B,!0);o&&O.on("keydown.brush",Y,!0).on("keyup.brush",L,!0),Vn(e.view)}f.call(_),R.start(e,m.name)}function U(t){for(const n of t.changedTouches||[t])for(const t of D)t.identifier===n.identifier&&(t.cur=jn(n,_));if(z&&!y&&!v&&1===D.length){const t=D[0];Uo(t.cur[0]-t[0])>Uo(t.cur[1]-t[1])?v=!0:y=!0}for(const t of D)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);g=!0,Do(t),I(t)}function I(t){const n=D[0],e=n.point0;var r;switch(C=n[0]-e[0],P=n[1]-e[1],m){case Fo:case Ro:x&&(C=Io(S-i,Bo(k-l,C)),a=i+C,h=l+C),w&&(P=Io(E-u,Bo(N-d,P)),c=u+P,p=d+P);break;case qo:D[1]?(x&&(a=Io(S,Bo(k,D[0][0])),h=Io(S,Bo(k,D[1][0])),x=1),w&&(c=Io(E,Bo(N,D[0][1])),p=Io(E,Bo(N,D[1][1])),w=1)):(x<0?(C=Io(S-i,Bo(k-i,C)),a=i+C,h=l):x>0&&(C=Io(S-l,Bo(k-l,C)),a=i,h=l+C),w<0?(P=Io(E-u,Bo(N-u,P)),c=u+P,p=d):w>0&&(P=Io(E-d,Bo(N-d,P)),c=u,p=d+P));break;case Oo:x&&(a=Io(S,Bo(k,i-C*x)),h=Io(S,Bo(k,l+C*x))),w&&(c=Io(E,Bo(N,u-P*w)),p=Io(E,Bo(N,d+P*w)))}h0&&(i=a-C),w<0?d=p-P:w>0&&(u=c-P),m=Fo,q.attr("cursor",Xo.selection),I(t));break;default:return}Do(t)}function L(t){switch(t.keyCode){case 16:z&&(y=v=z=!1,I(t));break;case 18:m===Oo&&(x<0?l=h:x>0&&(i=a),w<0?d=p:w>0&&(u=c),m=qo,I(t));break;case 32:m===Fo&&(t.altKey?(x&&(l=h-C*x,i=a+C*x),w&&(d=p-P*w,u=c+P*w),m=Oo):(x<0?l=h:x>0&&(i=a),w<0?d=p:w>0&&(u=c),m=qo),q.attr("cursor",Xo[b]),I(t));break;default:return}Do(t)}}function d(t){s(this,arguments).moved(t)}function p(t){s(this,arguments).ended(t)}function g(){var n=this.__brush||{selection:null};return n.extent=Lo(e.apply(this,arguments)),n.dim=t,n}return c.move=function(n,e,r){n.tween?n.on("start.brush",(function(t){s(this,arguments).beforestart().start(t)})).on("interrupt.brush end.brush",(function(t){s(this,arguments).end(t)})).tween("brush",(function(){var n=this,r=n.__brush,i=s(n,arguments),o=r.selection,a=t.input("function"==typeof e?e.apply(this,arguments):e,r.extent),u=Rr(o,a);function c(t){r.selection=1===t&&null===a?null:u(t),f.call(n),i.brush()}return null!==o&&null!==a?c:c(1)})):n.each((function(){var n=this,i=arguments,o=n.__brush,a=t.input("function"==typeof e?e.apply(n,i):e,o.extent),u=s(n,i).beforestart();Si(n),o.selection=null===a?null:a,f.call(n),u.start(r).brush(r).end(r)}))},c.clear=function(t,n){c.move(t,null,n)},l.prototype={beforestart:function(){return 1==++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,n){return this.starting?(this.starting=!1,this.emit("start",t,n)):this.emit("brush",t),this},brush:function(t,n){return this.emit("brush",t,n),this},end:function(t,n){return 0==--this.active&&(delete this.state.emitter,this.emit("end",t,n)),this},emit:function(n,e,r){var i=Un(this.that).datum();a.call(n,this.that,new Po(n,{sourceEvent:e,target:c,selection:t.output(this.state.selection),mode:r,dispatch:a}),i)}},c.extent=function(t){return arguments.length?(e="function"==typeof t?t:Co(Lo(t)),c):e},c.filter=function(t){return arguments.length?(r="function"==typeof t?t:Co(!!t),c):r},c.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Co(!!t),c):i},c.handleSize=function(t){return arguments.length?(u=+t,c):u},c.keyModifiers=function(t){return arguments.length?(o=!!t,c):o},c.on=function(){var t=a.on.apply(a,arguments);return t===a?c:t},c}var ia=Math.abs,oa=Math.cos,aa=Math.sin,ua=Math.PI,ca=ua/2,fa=2*ua,sa=Math.max,la=1e-12;function ha(t,n){return Array.from({length:n-t},((n,e)=>t+e))}function da(t){return function(n,e){return t(n.source.value+n.target.value,e.source.value+e.target.value)}}function pa(t,n){var e=0,r=null,i=null,o=null;function a(a){var u,c=a.length,f=new Array(c),s=ha(0,c),l=new Array(c*c),h=new Array(c),d=0;a=Float64Array.from({length:c*c},n?(t,n)=>a[n%c][n/c|0]:(t,n)=>a[n/c|0][n%c]);for(let n=0;nr(f[t],f[n])));for(const e of s){const r=n;if(t){const t=ha(1+~c,c).filter((t=>t<0?a[~t*c+e]:a[e*c+t]));i&&t.sort(((t,n)=>i(t<0?-a[~t*c+e]:a[e*c+t],n<0?-a[~n*c+e]:a[e*c+n])));for(const r of t)if(r<0){(l[~r*c+e]||(l[~r*c+e]={source:null,target:null})).target={index:e,startAngle:n,endAngle:n+=a[~r*c+e]*d,value:a[~r*c+e]}}else{(l[e*c+r]||(l[e*c+r]={source:null,target:null})).source={index:e,startAngle:n,endAngle:n+=a[e*c+r]*d,value:a[e*c+r]}}h[e]={index:e,startAngle:r,endAngle:n,value:f[e]}}else{const t=ha(0,c).filter((t=>a[e*c+t]||a[t*c+e]));i&&t.sort(((t,n)=>i(a[e*c+t],a[e*c+n])));for(const r of t){let t;if(eva)if(Math.abs(s*u-c*f)>va&&i){var h=e-o,d=r-a,p=u*u+c*c,g=h*h+d*d,y=Math.sqrt(p),v=Math.sqrt(l),_=i*Math.tan((ga-Math.acos((p+l-g)/(2*y*v)))/2),b=_/v,m=_/y;Math.abs(b-1)>va&&(this._+="L"+(t+b*f)+","+(n+b*s)),this._+="A"+i+","+i+",0,0,"+ +(s*h>f*d)+","+(this._x1=t+m*u)+","+(this._y1=n+m*c)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,r,i,o){t=+t,n=+n,o=!!o;var a=(e=+e)*Math.cos(r),u=e*Math.sin(r),c=t+a,f=n+u,s=1^o,l=o?r-i:i-r;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+c+","+f:(Math.abs(this._x1-c)>va||Math.abs(this._y1-f)>va)&&(this._+="L"+c+","+f),e&&(l<0&&(l=l%ya+ya),l>_a?this._+="A"+e+","+e+",0,1,"+s+","+(t-a)+","+(n-u)+"A"+e+","+e+",0,1,"+s+","+(this._x1=c)+","+(this._y1=f):l>va&&(this._+="A"+e+","+e+",0,"+ +(l>=ga)+","+s+","+(this._x1=t+e*Math.cos(i))+","+(this._y1=n+e*Math.sin(i))))},rect:function(t,n,e,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +r+"h"+-e+"Z"},toString:function(){return this._}};var xa=Array.prototype.slice;function wa(t){return function(){return t}}function Ma(t){return t.source}function Aa(t){return t.target}function Ta(t){return t.radius}function Sa(t){return t.startAngle}function Ea(t){return t.endAngle}function ka(){return 0}function Na(){return 10}function Ca(t){var n=Ma,e=Aa,r=Ta,i=Ta,o=Sa,a=Ea,u=ka,c=null;function f(){var f,s=n.apply(this,arguments),l=e.apply(this,arguments),h=u.apply(this,arguments)/2,d=xa.call(arguments),p=+r.apply(this,(d[0]=s,d)),g=o.apply(this,d)-ca,y=a.apply(this,d)-ca,v=+i.apply(this,(d[0]=l,d)),_=o.apply(this,d)-ca,b=a.apply(this,d)-ca;if(c||(c=f=ma()),h>la&&(ia(y-g)>2*h+la?y>g?(g+=h,y-=h):(g-=h,y+=h):g=y=(g+y)/2,ia(b-_)>2*h+la?b>_?(_+=h,b-=h):(_-=h,b+=h):_=b=(_+b)/2),c.moveTo(p*oa(g),p*aa(g)),c.arc(0,0,p,g,y),g!==_||y!==b)if(t){var m=+t.apply(this,arguments),x=v-m,w=(_+b)/2;c.quadraticCurveTo(0,0,x*oa(_),x*aa(_)),c.lineTo(v*oa(w),v*aa(w)),c.lineTo(x*oa(b),x*aa(b))}else c.quadraticCurveTo(0,0,v*oa(_),v*aa(_)),c.arc(0,0,v,_,b);if(c.quadraticCurveTo(0,0,p*oa(g),p*aa(g)),c.closePath(),f)return c=null,f+""||null}return t&&(f.headRadius=function(n){return arguments.length?(t="function"==typeof n?n:wa(+n),f):t}),f.radius=function(t){return arguments.length?(r=i="function"==typeof t?t:wa(+t),f):r},f.sourceRadius=function(t){return arguments.length?(r="function"==typeof t?t:wa(+t),f):r},f.targetRadius=function(t){return arguments.length?(i="function"==typeof t?t:wa(+t),f):i},f.startAngle=function(t){return arguments.length?(o="function"==typeof t?t:wa(+t),f):o},f.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:wa(+t),f):a},f.padAngle=function(t){return arguments.length?(u="function"==typeof t?t:wa(+t),f):u},f.source=function(t){return arguments.length?(n=t,f):n},f.target=function(t){return arguments.length?(e=t,f):e},f.context=function(t){return arguments.length?(c=null==t?null:t,f):c},f}var Pa=Array.prototype.slice;function za(t,n){return t-n}var Da=t=>()=>t;function Ra(t,n){for(var e,r=-1,i=n.length;++rr!=d>r&&e<(h-f)*(r-s)/(d-s)+f&&(i=-i)}return i}function qa(t,n,e){var r,i,o,a;return function(t,n,e){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])}(t,n,e)&&(i=t[r=+(t[0]===n[0])],o=e[r],a=n[r],i<=o&&o<=a||a<=o&&o<=i)}function Oa(){}var Ua=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Ia(){var t=1,n=1,e=L,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(za);else{const e=g(t),r=B(e[0],e[1],n);n=U(Math.floor(e[0]/r)*r,Math.floor(e[1]/r-1)*r,n)}return n.map((n=>o(t,n)))}function o(e,i){var o=[],u=[];return function(e,r,i){var o,u,c,f,s,l,h=new Array,d=new Array;o=u=-1,f=e[0]>=r,Ua[f<<1].forEach(p);for(;++o=r,Ua[c|f<<1].forEach(p);Ua[f<<0].forEach(p);for(;++u=r,s=e[u*t]>=r,Ua[f<<1|s<<2].forEach(p);++o=r,l=s,s=e[u*t+o+1]>=r,Ua[c|f<<1|s<<2|l<<3].forEach(p);Ua[f|s<<3].forEach(p)}o=-1,s=e[u*t]>=r,Ua[s<<2].forEach(p);for(;++o=r,Ua[s<<2|l<<3].forEach(p);function p(t){var n,e,r=[t[0][0]+o,t[0][1]+u],c=[t[1][0]+o,t[1][1]+u],f=a(r),s=a(c);(n=d[f])?(e=h[s])?(delete d[n.end],delete h[e.start],n===e?(n.ring.push(c),i(n.ring)):h[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete d[n.end],n.ring.push(c),d[n.end=s]=n):(n=h[s])?(e=d[f])?(delete h[n.start],delete d[e.end],n===e?(n.ring.push(c),i(n.ring)):h[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete h[n.start],n.ring.unshift(r),h[n.start=f]=n):h[f]=d[s]={start:f,end:s,ring:[r,c]}}Ua[s<<3].forEach(p)}(e,i,(function(t){r(t,e,i),function(t){for(var n=0,e=t.length,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++n0?o.push([t]):u.push(t)})),u.forEach((function(t){for(var n,e=0,r=o.length;e0&&a0&&u=0&&o>=0))throw new Error("invalid size");return t=r,n=o,i},i.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?Da(Pa.call(t)):Da(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:Oa,i):r===u},i}function Ba(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(c-=t.data[u-o+a*r]),n.data[u-e+a*r]=c/Math.min(u+1,r-1+o-u,o))}function Ya(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(c-=t.data[a+(u-o)*r]),n.data[a+(u-e)*r]=c/Math.min(u+1,i-1+o-u,o))}function La(t){return t[0]}function ja(t){return t[1]}function $a(){return 1}const Ha=134217729;function Xa(t,n,e,r,i){let o,a,u,c,f=n[0],s=r[0],l=0,h=0;s>f==s>-f?(o=f,f=n[++l]):(o=s,s=r[++h]);let d=0;if(lf==s>-f?(a=f+o,u=o-(a-f),f=n[++l]):(a=s+o,u=o-(a-s),s=r[++h]),o=a,0!==u&&(i[d++]=u);lf==s>-f?(a=o+f,c=a-o,u=o-(a-c)+(f-c),f=n[++l]):(a=o+s,c=a-o,u=o-(a-c)+(s-c),s=r[++h]),o=a,0!==u&&(i[d++]=u);for(;l0!=u>0)return c;const f=Math.abs(a+u);return Math.abs(c)>=33306690738754716e-32*f?c:-function(t,n,e,r,i,o,a){let u,c,f,s,l,h,d,p,g,y,v,_,b,m,x,w,M,A;const T=t-i,S=e-i,E=n-o,k=r-o;m=T*k,h=Ha*T,d=h-(h-T),p=T-d,h=Ha*k,g=h-(h-k),y=k-g,x=p*y-(m-d*g-p*g-d*y),w=E*S,h=Ha*E,d=h-(h-E),p=E-d,h=Ha*S,g=h-(h-S),y=S-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,Va[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,Va[1]=b-(v+l)+(l-w),A=_+v,l=A-_,Va[2]=_-(A-l)+(v-l),Va[3]=A;let N=function(t,n){let e=n[0];for(let r=1;r=C||-N>=C)return N;if(l=t-T,u=t-(T+l)+(l-i),l=e-S,f=e-(S+l)+(l-i),l=n-E,c=n-(E+l)+(l-o),l=r-k,s=r-(k+l)+(l-o),0===u&&0===c&&0===f&&0===s)return N;if(C=11093356479670487e-47*a+33306690738754706e-32*Math.abs(N),N+=T*s+k*u-(E*f+S*c),N>=C||-N>=C)return N;m=u*k,h=Ha*u,d=h-(h-u),p=u-d,h=Ha*k,g=h-(h-k),y=k-g,x=p*y-(m-d*g-p*g-d*y),w=c*S,h=Ha*c,d=h-(h-c),p=c-d,h=Ha*S,g=h-(h-S),y=S-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,Qa[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,Qa[1]=b-(v+l)+(l-w),A=_+v,l=A-_,Qa[2]=_-(A-l)+(v-l),Qa[3]=A;const P=Xa(4,Va,4,Qa,Wa);m=T*s,h=Ha*T,d=h-(h-T),p=T-d,h=Ha*s,g=h-(h-s),y=s-g,x=p*y-(m-d*g-p*g-d*y),w=E*f,h=Ha*E,d=h-(h-E),p=E-d,h=Ha*f,g=h-(h-f),y=f-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,Qa[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,Qa[1]=b-(v+l)+(l-w),A=_+v,l=A-_,Qa[2]=_-(A-l)+(v-l),Qa[3]=A;const z=Xa(P,Wa,4,Qa,Za);m=u*s,h=Ha*u,d=h-(h-u),p=u-d,h=Ha*s,g=h-(h-s),y=s-g,x=p*y-(m-d*g-p*g-d*y),w=c*f,h=Ha*c,d=h-(h-c),p=c-d,h=Ha*f,g=h-(h-f),y=f-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,Qa[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,Qa[1]=b-(v+l)+(l-w),A=_+v,l=A-_,Qa[2]=_-(A-l)+(v-l),Qa[3]=A;const D=Xa(z,Za,4,Qa,Ka);return Ka[D-1]}(t,n,e,r,i,o,f)}const tu=Math.pow(2,-52),nu=new Uint32Array(512);class eu{static from(t,n=cu,e=fu){const r=t.length,i=new Float64Array(2*r);for(let o=0;o