UNPKG

proportions-chart

Version:

A one-dimensional proportional chart web component for visualizing categorical data

2 lines 90.2 kB
// Version 1.5.5 proportions-chart - https://github.com/vasturiano/proportions-chart !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).ProportionsChart=n()}(this,(function(){"use strict";!function(t,n){void 0===n&&(n={});var e=n.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===e&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}(".proportions-viz rect {\n transition-property: transform, opacity;\n transition-duration: .5s;\n}\n\n.proportions-viz rect:hover {\n transform: scaleY(1.2); /* set HOVER_REL_MARGIN to 0.18 */\n opacity: 0.85;\n transition-duration: .25s;\n transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275); /* EaseOutBack */\n}\n\n.proportions-viz .rect {\n stroke: white;\n stroke-width: 1px;\n /*transition: opacity .4s;*/\n}\n\n.proportions-viz .rect:hover {\n opacity: 0.9;\n transition: opacity .05s;\n}\n\n.proportions-viz text {\n font-family: sans-serif;\n font-size: 12px;\n dominant-baseline: middle;\n text-anchor: middle;\n pointer-events: none;\n fill: #404041;\n}\n\n.proportions-viz text.sub-label {\n font-size: 10px;\n opacity: 0.7;\n}\n\n.proportions-viz .light text {\n fill: #F7F7F7;\n}\n\n.proportions-viz {\n position: relative;\n}\n\n.proportions-viz .tooltip-title {\n font-weight: bold;\n text-align: center;\n margin-bottom: 5px;\n}\n");var t="http://www.w3.org/1999/xhtml",n={svg:"http://www.w3.org/2000/svg",xhtml:t,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function e(t){var e=t+="",r=e.indexOf(":");return r>=0&&"xmlns"!==(e=t.slice(0,r))&&(t=t.slice(r+1)),n.hasOwnProperty(e)?{space:n[e],local:t}:t}function r(n){return function(){var e=this.ownerDocument,r=this.namespaceURI;return r===t&&e.documentElement.namespaceURI===t?e.createElement(n):e.createElementNS(r,n)}}function i(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function o(t){var n=e(t);return(n.local?i:r)(n)}function a(){}function u(t){return null==t?a:function(){return this.querySelector(t)}}function l(){return[]}function s(t){return null==t?l:function(){return this.querySelectorAll(t)}}function c(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function f(t){return function(){return this.matches(t)}}function h(t){return function(n){return n.matches(t)}}var p=Array.prototype.find;function d(){return this.firstElementChild}var _=Array.prototype.filter;function g(){return Array.from(this.children)}function v(t){return new Array(t.length)}function y(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function m(t,n,e,r,i,o){for(var a,u=0,l=n.length,s=o.length;u<s;++u)(a=n[u])?(a.__data__=o[u],r[u]=a):e[u]=new y(t,o[u]);for(;u<l;++u)(a=n[u])&&(i[u]=a)}function b(t,n,e,r,i,o,a){var u,l,s,c=new Map,f=n.length,h=o.length,p=new Array(f);for(u=0;u<f;++u)(l=n[u])&&(p[u]=s=a.call(l,l.__data__,u,n)+"",c.has(s)?i[u]=l:c.set(s,l));for(u=0;u<h;++u)s=a.call(t,o[u],u,o)+"",(l=c.get(s))?(r[u]=l,l.__data__=o[u],c.delete(s)):e[u]=new y(t,o[u]);for(u=0;u<f;++u)(l=n[u])&&c.get(p[u])===l&&(i[u]=l)}function w(t){return t.__data__}function x(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function M(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function A(t){return function(){this.removeAttribute(t)}}function k(t){return function(){this.removeAttributeNS(t.space,t.local)}}function S(t,n){return function(){this.setAttribute(t,n)}}function N(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function E(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function C(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function P(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function j(t){return function(){this.style.removeProperty(t)}}function O(t,n,e){return function(){this.style.setProperty(t,n,e)}}function $(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function T(t,n){return t.style.getPropertyValue(n)||P(t).getComputedStyle(t,null).getPropertyValue(n)}function R(t){return function(){delete this[t]}}function H(t,n){return function(){this[t]=n}}function I(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function D(t){return t.trim().split(/^|\s+/)}function F(t){return t.classList||new L(t)}function L(t){this._node=t,this._names=D(t.getAttribute("class")||"")}function z(t,n){for(var e=F(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function q(t,n){for(var e=F(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function U(t){return function(){z(this,t)}}function X(t){return function(){q(this,t)}}function B(t,n){return function(){(n.apply(this,arguments)?z:q)(this,t)}}function Y(){this.textContent=""}function V(t){return function(){this.textContent=t}}function W(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function G(){this.innerHTML=""}function K(t){return function(){this.innerHTML=t}}function Z(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function J(){this.nextSibling&&this.parentNode.appendChild(this)}function Q(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function tt(){return null}function nt(){var t=this.parentNode;t&&t.removeChild(this)}function et(){var t=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function rt(){var t=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function it(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;r<o;++r)e=n[r],t.type&&e.type!==t.type||e.name!==t.name?n[++i]=e:this.removeEventListener(e.type,e.listener,e.options);++i?n.length=i:delete this.__on}}}function ot(t,n,e){return function(){var r,i=this.__on,o=function(t){return function(n){t.call(this,n,this.__data__)}}(n);if(i)for(var a=0,u=i.length;a<u;++a)if((r=i[a]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=e),void(r.value=n);this.addEventListener(t.type,o,e),r={type:t.type,name:t.name,value:n,listener:o,options:e},i?i.push(r):this.__on=[r]}}function at(t,n,e){var r=P(t),i=r.CustomEvent;"function"==typeof i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function ut(t,n){return function(){return at(this,t,n)}}function lt(t,n){return function(){return at(this,t,n.apply(this,arguments))}}y.prototype={constructor:y,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},L.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var st=[null];function ct(t,n){this._groups=t,this._parents=n}function ft(){return new ct([[document.documentElement]],st)}function ht(t){return"string"==typeof t?new ct([[document.querySelector(t)]],[document.documentElement]):new ct([[t]],st)}function pt(t,n){return null==t||null==n?NaN:t<n?-1:t>n?1:t>=n?0:NaN}function dt(t,n){return null==t||null==n?NaN:n<t?-1:n>t?1:n>=t?0:NaN}function _t(t){let n,e,r;function i(t,r,i=0,o=t.length){if(i<o){if(0!==n(r,r))return o;do{const n=i+o>>>1;e(t[n],r)<0?i=n+1:o=n}while(i<o)}return i}return 2!==t.length?(n=pt,e=(n,e)=>pt(t(n),e),r=(n,e)=>t(n)-e):(n=t===pt||t===dt?t:gt,e=t,r=t),{left:i,center:function(t,n,e=0,o=t.length){const a=i(t,n,e,o-1);return a>e&&r(t[a-1],n)>-r(t[a],n)?a-1:a},right:function(t,r,i=0,o=t.length){if(i<o){if(0!==n(r,r))return o;do{const n=i+o>>>1;e(t[n],r)<=0?i=n+1:o=n}while(i<o)}return i}}}function gt(){return 0}ct.prototype=ft.prototype={constructor:ct,select:function(t){"function"!=typeof t&&(t=u(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a,l=n[i],s=l.length,c=r[i]=new Array(s),f=0;f<s;++f)(o=l[f])&&(a=t.call(o,o.__data__,f,l))&&("__data__"in o&&(a.__data__=o.__data__),c[f]=a);return new ct(r,this._parents)},selectAll:function(t){t="function"==typeof t?c(t):s(t);for(var n=this._groups,e=n.length,r=[],i=[],o=0;o<e;++o)for(var a,u=n[o],l=u.length,f=0;f<l;++f)(a=u[f])&&(r.push(t.call(a,a.__data__,f,u)),i.push(a));return new ct(r,i)},selectChild:function(t){return this.select(null==t?d:function(t){return function(){return p.call(this.children,t)}}("function"==typeof t?t:h(t)))},selectChildren:function(t){return this.selectAll(null==t?g:function(t){return function(){return _.call(this.children,t)}}("function"==typeof t?t:h(t)))},filter:function(t){"function"!=typeof t&&(t=f(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a=n[i],u=a.length,l=r[i]=[],s=0;s<u;++s)(o=a[s])&&t.call(o,o.__data__,s,a)&&l.push(o);return new ct(r,this._parents)},data:function(t,n){if(!arguments.length)return Array.from(this,w);var e=n?b:m,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var o=i.length,a=new Array(o),u=new Array(o),l=new Array(o),s=0;s<o;++s){var c=r[s],f=i[s],h=f.length,p=x(t.call(c,c&&c.__data__,s,r)),d=p.length,_=u[s]=new Array(d),g=a[s]=new Array(d);e(c,f,_,g,l[s]=new Array(h),p,n);for(var v,y,M=0,A=0;M<d;++M)if(v=_[M]){for(M>=A&&(A=M+1);!(y=g[A])&&++A<d;);v._next=y||null}}return(a=new ct(a,r))._enter=u,a._exit=l,a},enter:function(){return new ct(this._enter||this._groups.map(v),this._parents)},exit:function(){return new ct(this._exit||this._groups.map(v),this._parents)},join:function(t,n,e){var r=this.enter(),i=this,o=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=n&&(i=n(i))&&(i=i.selection()),null==e?o.remove():e(o),r&&i?r.merge(i).order():i},merge:function(t){for(var n=t.selection?t.selection():t,e=this._groups,r=n._groups,i=e.length,o=r.length,a=Math.min(i,o),u=new Array(i),l=0;l<a;++l)for(var s,c=e[l],f=r[l],h=c.length,p=u[l]=new Array(h),d=0;d<h;++d)(s=c[d]||f[d])&&(p[d]=s);for(;l<i;++l)u[l]=e[l];return new ct(u,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,a=i[o];--o>=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=M);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o<r;++o){for(var a,u=e[o],l=u.length,s=i[o]=new Array(l),c=0;c<l;++c)(a=u[c])&&(s[c]=a);s.sort(n)}return new ct(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,n=0,e=t.length;n<e;++n)for(var r=t[n],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null},size:function(){let t=0;for(const n of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var n=this._groups,e=0,r=n.length;e<r;++e)for(var i,o=n[e],a=0,u=o.length;a<u;++a)(i=o[a])&&t.call(i,i.__data__,a,o);return this},attr:function(t,n){var r=e(t);if(arguments.length<2){var i=this.node();return r.local?i.getAttributeNS(r.space,r.local):i.getAttribute(r)}return this.each((null==n?r.local?k:A:"function"==typeof n?r.local?C:E:r.local?N:S)(r,n))},style:function(t,n,e){return arguments.length>1?this.each((null==n?j:"function"==typeof n?$:O)(t,n,null==e?"":e)):T(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?R:"function"==typeof n?I:H)(t,n)):this.node()[t]},classed:function(t,n){var e=D(t+"");if(arguments.length<2){for(var r=F(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?B:n?U:X)(e,n))},text:function(t){return arguments.length?this.each(null==t?Y:("function"==typeof t?W:V)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?G:("function"==typeof t?Z:K)(t)):this.node().innerHTML},raise:function(){return this.each(J)},lower:function(){return this.each(Q)},append:function(t){var n="function"==typeof t?t:o(t);return this.select((function(){return this.appendChild(n.apply(this,arguments))}))},insert:function(t,n){var e="function"==typeof t?t:o(t),r=null==n?tt:"function"==typeof n?n:u(n);return this.select((function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(nt)},clone:function(t){return this.select(t?rt:et)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,n,e){var r,i,o=function(t){return t.trim().split(/^|\s+/).map((function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}}))}(t+""),a=o.length;if(!(arguments.length<2)){for(u=n?ot:it,r=0;r<a;++r)this.each(u(o[r],n,e));return this}var u=this.node().__on;if(u)for(var l,s=0,c=u.length;s<c;++s)for(r=0,l=u[s];r<a;++r)if((i=o[r]).type===l.type&&i.name===l.name)return l.value},dispatch:function(t,n){return this.each(("function"==typeof n?lt:ut)(t,n))},[Symbol.iterator]:function*(){for(var t=this._groups,n=0,e=t.length;n<e;++n)for(var r,i=t[n],o=0,a=i.length;o<a;++o)(r=i[o])&&(yield r)}};const vt=_t(pt).right;_t((function(t){return null===t?NaN:+t})).center;const yt=Math.sqrt(50),mt=Math.sqrt(10),bt=Math.sqrt(2);function wt(t,n,e){const r=(n-t)/Math.max(0,e),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),a=o>=yt?10:o>=mt?5:o>=bt?2:1;let u,l,s;return i<0?(s=Math.pow(10,-i)/a,u=Math.round(t*s),l=Math.round(n*s),u/s<t&&++u,l/s>n&&--l,s=-s):(s=Math.pow(10,i)*a,u=Math.round(t/s),l=Math.round(n/s),u*s<t&&++u,l*s>n&&--l),l<u&&.5<=e&&e<2?wt(t,n,2*e):[u,l,s]}function xt(t,n,e){return wt(t=+t,n=+n,e=+e)[2]}function Mt(t,n){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(n).domain(t)}return this}function At(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function kt(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function St(){}var Nt=.7,Et=1/Nt,Ct="\\s*([+-]?\\d+)\\s*",Pt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ot=/^#([0-9a-f]{3,8})$/,$t=new RegExp(`^rgb\\(${Ct},${Ct},${Ct}\\)$`),Tt=new RegExp(`^rgb\\(${jt},${jt},${jt}\\)$`),Rt=new RegExp(`^rgba\\(${Ct},${Ct},${Ct},${Pt}\\)$`),Ht=new RegExp(`^rgba\\(${jt},${jt},${jt},${Pt}\\)$`),It=new RegExp(`^hsl\\(${Pt},${jt},${jt}\\)$`),Dt=new RegExp(`^hsla\\(${Pt},${jt},${jt},${Pt}\\)$`),Ft={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 Lt(){return this.rgb().formatHex()}function zt(){return this.rgb().formatRgb()}function qt(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=Ot.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?Ut(n):3===e?new Yt(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?Xt(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?Xt(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=$t.exec(t))?new Yt(n[1],n[2],n[3],1):(n=Tt.exec(t))?new Yt(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=Rt.exec(t))?Xt(n[1],n[2],n[3],n[4]):(n=Ht.exec(t))?Xt(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=It.exec(t))?Jt(n[1],n[2]/100,n[3]/100,1):(n=Dt.exec(t))?Jt(n[1],n[2]/100,n[3]/100,n[4]):Ft.hasOwnProperty(t)?Ut(Ft[t]):"transparent"===t?new Yt(NaN,NaN,NaN,0):null}function Ut(t){return new Yt(t>>16&255,t>>8&255,255&t,1)}function Xt(t,n,e,r){return r<=0&&(t=n=e=NaN),new Yt(t,n,e,r)}function Bt(t,n,e,r){return 1===arguments.length?function(t){return t instanceof St||(t=qt(t)),t?new Yt((t=t.rgb()).r,t.g,t.b,t.opacity):new Yt}(t):new Yt(t,n,e,null==r?1:r)}function Yt(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function Vt(){return`#${Zt(this.r)}${Zt(this.g)}${Zt(this.b)}`}function Wt(){const t=Gt(this.opacity);return`${1===t?"rgb(":"rgba("}${Kt(this.r)}, ${Kt(this.g)}, ${Kt(this.b)}${1===t?")":`, ${t})`}`}function Gt(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Kt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Zt(t){return((t=Kt(t))<16?"0":"")+t.toString(16)}function Jt(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new tn(t,n,e,r)}function Qt(t){if(t instanceof tn)return new tn(t.h,t.s,t.l,t.opacity);if(t instanceof St||(t=qt(t)),!t)return new tn;if(t instanceof tn)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,l=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e<r):e===o?(r-n)/u+2:(n-e)/u+4,u/=l<.5?o+i:2-o-i,a*=60):u=l>0&&l<1?0:a,new tn(a,u,l,t.opacity)}function tn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function nn(t){return(t=(t||0)%360)<0?t+360:t}function en(t){return Math.max(0,Math.min(1,t||0))}function rn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}At(St,qt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Lt,formatHex:Lt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Qt(this).formatHsl()},formatRgb:zt,toString:zt}),At(Yt,Bt,kt(St,{brighter(t){return t=null==t?Et:Math.pow(Et,t),new Yt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Nt:Math.pow(Nt,t),new Yt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Yt(Kt(this.r),Kt(this.g),Kt(this.b),Gt(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:Vt,formatHex:Vt,formatHex8:function(){return`#${Zt(this.r)}${Zt(this.g)}${Zt(this.b)}${Zt(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Wt,toString:Wt})),At(tn,(function(t,n,e,r){return 1===arguments.length?Qt(t):new tn(t,n,e,null==r?1:r)}),kt(St,{brighter(t){return t=null==t?Et:Math.pow(Et,t),new tn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Nt:Math.pow(Nt,t),new tn(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 Yt(rn(t>=240?t-240:t+120,i,r),rn(t,i,r),rn(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new tn(nn(this.h),en(this.s),en(this.l),Gt(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=Gt(this.opacity);return`${1===t?"hsl(":"hsla("}${nn(this.h)}, ${100*en(this.s)}%, ${100*en(this.l)}%${1===t?")":`, ${t})`}`}}));var on=t=>()=>t;function an(t){return 1==(t=+t)?un: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):on(isNaN(n)?e:n)}}function un(t,n){var e=n-t;return e?function(t,n){return function(e){return t+e*n}}(t,e):on(isNaN(t)?n:t)}var ln=function t(n){var e=an(n);function r(t,n){var r=e((t=Bt(t)).r,(n=Bt(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=un(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 sn(t,n){n||(n=[]);var e,r=t?Math.min(n.length,t.length):0,i=n.slice();return function(o){for(e=0;e<r;++e)i[e]=t[e]*(1-o)+n[e]*o;return i}}function cn(t,n){var e,r=n?n.length:0,i=t?Math.min(r,t.length):0,o=new Array(i),a=new Array(r);for(e=0;e<i;++e)o[e]=vn(t[e],n[e]);for(;e<r;++e)a[e]=n[e];return function(t){for(e=0;e<i;++e)a[e]=o[e](t);return a}}function fn(t,n){var e=new Date;return t=+t,n=+n,function(r){return e.setTime(t*(1-r)+n*r),e}}function hn(t,n){return t=+t,n=+n,function(e){return t*(1-e)+n*e}}function pn(t,n){var e,r={},i={};for(e in null!==t&&"object"==typeof t||(t={}),null!==n&&"object"==typeof n||(n={}),n)e in t?r[e]=vn(t[e],n[e]):i[e]=n[e];return function(t){for(e in r)i[e]=r[e](t);return i}}var dn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,_n=new RegExp(dn.source,"g");function gn(t,n){var e,r,i,o=dn.lastIndex=_n.lastIndex=0,a=-1,u=[],l=[];for(t+="",n+="";(e=dn.exec(t))&&(r=_n.exec(n));)(i=r.index)>o&&(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,l.push({i:a,x:hn(e,r)})),o=_n.lastIndex;return o<n.length&&(i=n.slice(o),u[a]?u[a]+=i:u[++a]=i),u.length<2?l[0]?function(t){return function(n){return t(n)+""}}(l[0].x):function(t){return function(){return t}}(n):(n=l.length,function(t){for(var e,r=0;r<n;++r)u[(e=l[r]).i]=e.x(t);return u.join("")})}function vn(t,n){var e,r=typeof n;return null==n||"boolean"===r?on(n):("number"===r?hn:"string"===r?(e=qt(n))?(n=e,ln):gn:n instanceof qt?ln:n instanceof Date?fn:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(n)?sn:Array.isArray(n)?cn:"function"!=typeof n.valueOf&&"function"!=typeof n.toString||isNaN(n)?pn:hn)(t,n)}function yn(t,n){return t=+t,n=+n,function(e){return Math.round(t*(1-e)+n*e)}}var mn,bn=180/Math.PI,wn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xn(t,n,e,r,i,o){var a,u,l;return(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a),(l=t*e+n*r)&&(e-=t*l,r-=n*l),(u=Math.sqrt(e*e+r*r))&&(e/=u,r/=u,l/=u),t*r<n*e&&(t=-t,n=-n,l=-l,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(n,t)*bn,skewX:Math.atan(l)*bn,scaleX:a,scaleY:u}}function Mn(t,n,e,r){function i(t){return t.length?t.pop()+" ":""}return function(o,a){var u=[],l=[];return o=t(o),a=t(a),function(t,r,i,o,a,u){if(t!==i||r!==o){var l=a.push("translate(",null,n,null,e);u.push({i:l-4,x:hn(t,i)},{i:l-2,x:hn(r,o)})}else(i||o)&&a.push("translate("+i+n+o+e)}(o.translateX,o.translateY,a.translateX,a.translateY,u,l),function(t,n,e,o){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:hn(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,l),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:hn(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,l),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:hn(t,e)},{i:u-2,x:hn(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,l),o=a=null,function(t){for(var n,e=-1,r=l.length;++e<r;)u[(n=l[e]).i]=n.x(t);return u.join("")}}}var An=Mn((function(t){const n=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return n.isIdentity?wn:xn(n.a,n.b,n.c,n.d,n.e,n.f)}),"px, ","px)","deg)"),kn=Mn((function(t){return null==t?wn:(mn||(mn=document.createElementNS("http://www.w3.org/2000/svg","g")),mn.setAttribute("transform",t),(t=mn.transform.baseVal.consolidate())?xn((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):wn)}),", ",")",")");function Sn(t){return+t}var Nn=[0,1];function En(t){return t}function Cn(t,n){return(n-=t=+t)?function(e){return(e-t)/n}:function(t){return function(){return t}}(isNaN(n)?NaN:.5)}function Pn(t,n,e){var r=t[0],i=t[1],o=n[0],a=n[1];return i<r?(r=Cn(i,r),o=e(a,o)):(r=Cn(r,i),o=e(o,a)),function(t){return o(r(t))}}function jn(t,n,e){var r=Math.min(t.length,n.length)-1,i=new Array(r),o=new Array(r),a=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),n=n.slice().reverse());++a<r;)i[a]=Cn(t[a],t[a+1]),o[a]=e(n[a],n[a+1]);return function(n){var e=vt(t,n,1,r)-1;return o[e](i[e](n))}}function On(){var t,n,e,r,i,o,a=Nn,u=Nn,l=vn,s=En;function c(){var t=Math.min(a.length,u.length);return s!==En&&(s=function(t,n){var e;return t>n&&(e=t,t=n,n=e),function(e){return Math.max(t,Math.min(n,e))}}(a[0],a[t-1])),r=t>2?jn:Pn,i=o=null,f}function f(n){return null==n||isNaN(n=+n)?e:(i||(i=r(a.map(t),u,l)))(t(s(n)))}return f.invert=function(e){return s(n((o||(o=r(u,a.map(t),hn)))(e)))},f.domain=function(t){return arguments.length?(a=Array.from(t,Sn),c()):a.slice()},f.range=function(t){return arguments.length?(u=Array.from(t),c()):u.slice()},f.rangeRound=function(t){return u=Array.from(t),l=yn,c()},f.clamp=function(t){return arguments.length?(s=!!t||En,c()):s!==En},f.interpolate=function(t){return arguments.length?(l=t,c()):l},f.unknown=function(t){return arguments.length?(e=t,f):e},function(e,r){return t=e,n=r,c()}}function $n(t,n){if((e=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var e,r=t.slice(0,e);return[r.length>1?r[0]+r.slice(2):r,+t.slice(e+1)]}function Tn(t){return(t=$n(Math.abs(t)))?t[1]:NaN}var Rn,Hn=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function In(t){if(!(n=Hn.exec(t)))throw new Error("invalid format: "+t);var n;return new Dn({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function Dn(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Fn(t,n){var e=$n(t,n);if(!e)return t+"";var r=e[0],i=e[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}In.prototype=Dn.prototype,Dn.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Ln={"%":(t,n)=>(100*t).toFixed(n),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,n)=>t.toExponential(n),f:(t,n)=>t.toFixed(n),g:(t,n)=>t.toPrecision(n),o:t=>Math.round(t).toString(8),p:(t,n)=>Fn(100*t,n),r:Fn,s:function(t,n){var e=$n(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(Rn=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+$n(t,Math.max(0,n+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function zn(t){return t}var qn,Un,Xn,Bn=Array.prototype.map,Yn=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Vn(t){var n,e,r=void 0===t.grouping||void 0===t.thousands?zn:(n=Bn.call(t.grouping,Number),e=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,u=n[0],l=0;i>0&&u>0&&(l+u+1>r&&(u=Math.max(1,r-l)),o.push(t.substring(i-=u,i+u)),!((l+=u+1)>r));)u=n[a=(a+1)%n.length];return o.reverse().join(e)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",u=void 0===t.numerals?zn:function(t){return function(n){return n.replace(/[0-9]/g,(function(n){return t[+n]}))}}(Bn.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",s=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function f(t){var n=(t=In(t)).fill,e=t.align,f=t.sign,h=t.symbol,p=t.zero,d=t.width,_=t.comma,g=t.precision,v=t.trim,y=t.type;"n"===y?(_=!0,y="g"):Ln[y]||(void 0===g&&(g=12),v=!0,y="g"),(p||"0"===n&&"="===e)&&(p=!0,n="0",e="=");var m="$"===h?i:"#"===h&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",b="$"===h?o:/[%p]/.test(y)?l:"",w=Ln[y],x=/[defgprs%]/.test(y);function M(t){var i,o,l,h=m,M=b;if("c"===y)M=w(t)+M,t="";else{var A=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:w(Math.abs(t),g),v&&(t=function(t){t:for(var n,e=t.length,r=1,i=-1;r<e;++r)switch(t[r]){case".":i=n=r;break;case"0":0===i&&(i=r),n=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(n+1):t}(t)),A&&0==+t&&"+"!==f&&(A=!1),h=(A?"("===f?f:s:"-"===f||"("===f?"":f)+h,M=("s"===y?Yn[8+Rn/3]:"")+M+(A&&"("===f?")":""),x)for(i=-1,o=t.length;++i<o;)if(48>(l=t.charCodeAt(i))||l>57){M=(46===l?a+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}_&&!p&&(t=r(t,1/0));var k=h.length+t.length+M.length,S=k<d?new Array(d-k+1).join(n):"";switch(_&&p&&(t=r(S+t,S.length?d-M.length:1/0),S=""),e){case"<":t=h+t+M+S;break;case"=":t=h+S+t+M;break;case"^":t=S.slice(0,k=S.length>>1)+h+t+M+S.slice(k);break;default:t=S+h+t+M}return u(t)}return g=void 0===g?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:f,formatPrefix:function(t,n){var e=f(((t=In(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Tn(n)/3))),i=Math.pow(10,-r),o=Yn[8+r/3];return function(t){return e(i*t)+o}}}}function Wn(t,n,e,r){var i,o=function(t,n,e){e=+e;const r=(n=+n)<(t=+t),i=r?xt(n,t,e):xt(t,n,e);return(r?-1:1)*(i<0?1/-i:i)}(t,n,e);switch((r=In(null==r?",f":r)).type){case"s":var a=Math.max(Math.abs(t),Math.abs(n));return null!=r.precision||isNaN(i=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Tn(n)/3)))-Tn(Math.abs(t)))}(o,a))||(r.precision=i),Xn(r,a);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Tn(n)-Tn(t))+1}(o,Math.max(Math.abs(t),Math.abs(n))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-Tn(Math.abs(t)))}(o))||(r.precision=i-2*("%"===r.type))}return Un(r)}function Gn(t){var n=t.domain;return t.ticks=function(t){var e=n();return function(t,n,e){if(!((e=+e)>0))return[];if((t=+t)==(n=+n))return[t];const r=n<t,[i,o,a]=r?wt(n,t,e):wt(t,n,e);if(!(o>=i))return[];const u=o-i+1,l=new Array(u);if(r)if(a<0)for(let t=0;t<u;++t)l[t]=(o-t)/-a;else for(let t=0;t<u;++t)l[t]=(o-t)*a;else if(a<0)for(let t=0;t<u;++t)l[t]=(i+t)/-a;else for(let t=0;t<u;++t)l[t]=(i+t)*a;return l}(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){var r=n();return Wn(r[0],r[r.length-1],null==t?10:t,e)},t.nice=function(e){null==e&&(e=10);var r,i,o=n(),a=0,u=o.length-1,l=o[a],s=o[u],c=10;for(s<l&&(i=l,l=s,s=i,i=a,a=u,u=i);c-- >0;){if((i=xt(l,s,e))===r)return o[a]=l,o[u]=s,n(o);if(i>0)l=Math.floor(l/i)*i,s=Math.ceil(s/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,s=Math.floor(s*i)/i}r=i}return t},t}function Kn(){var t=On()(En,En);return t.copy=function(){return n=t,Kn().domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown());var n},Mt.apply(t,arguments),Gn(t)}function Zn(t){return function(){return t}}qn=Vn({thousands:",",grouping:[3],currency:["$",""]}),Un=qn.format,Xn=qn.formatPrefix;const Jn=2*Math.PI;function Qn(t,n){return n<t?-1:n>t?1:n>=t?0:NaN}function te(t){return t}function ne(){var t=te,n=Qn,e=null,r=Zn(0),i=Zn(Jn),o=Zn(0);function a(a){var u,l,s,c,f,h=(a=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(a)).length,p=0,d=new Array(h),_=new Array(h),g=+r.apply(this,arguments),v=Math.min(Jn,Math.max(-Jn,i.apply(this,arguments)-g)),y=Math.min(Math.abs(v)/h,o.apply(this,arguments)),m=y*(v<0?-1:1);for(u=0;u<h;++u)(f=_[d[u]=u]=+t(a[u],u,a))>0&&(p+=f);for(null!=n?d.sort((function(t,e){return n(_[t],_[e])})):null!=e&&d.sort((function(t,n){return e(a[t],a[n])})),u=0,s=p?(v-h*m)/p:0;u<h;++u,g=c)l=d[u],c=g+((f=_[l])>0?f*s:0)+m,_[l]={data:a[l],index:u,value:f,startAngle:g,endAngle:c,padAngle:y};return _}return a.value=function(n){return arguments.length?(t="function"==typeof n?n:Zn(+n),a):t},a.sortValues=function(t){return arguments.length?(n=t,e=null,a):n},a.sort=function(t){return arguments.length?(e=t,n=null,a):e},a.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:Zn(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:Zn(+t),a):i},a.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:Zn(+t),a):o},a}var ee={value:()=>{}};function re(){for(var t,n=0,e=arguments.length,r={};n<e;++n){if(!(t=arguments[n]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new ie(r)}function ie(t){this._=t}function oe(t,n){for(var e,r=0,i=t.length;r<i;++r)if((e=t[r]).name===n)return e.value}function ae(t,n,e){for(var r=0,i=t.length;r<i;++r)if(t[r].name===n){t[r]=ee,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=e&&t.push({name:n,value:e}),t}ie.prototype=re.prototype={constructor:ie,on:function(t,n){var e,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var n="",e=t.indexOf(".");if(e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))),a=-1,u=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++a<u;)if(e=(t=o[a]).type)i[e]=ae(i[e],t.name,n);else if(null==n)for(e in i)i[e]=ae(i[e],t.name,null);return this}for(;++a<u;)if((e=(t=o[a]).type)&&(e=oe(i[e],t.name)))return e},copy:function(){var t={},n=this._;for(var e in n)t[e]=n[e].slice();return new ie(t)},call:function(t,n){if((e=arguments.length-2)>0)for(var e,r,i=new Array(e),o=0;o<e;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,e=(r=this._[t]).length;o<e;++o)r[o].value.apply(n,i)},apply:function(t,n,e){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(n,e)}};var ue,le,se=0,ce=0,fe=0,he=0,pe=0,de=0,_e="object"==typeof performance&&performance.now?performance:Date,ge="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ve(){return pe||(ge(ye),pe=_e.now()+de)}function ye(){pe=0}function me(){this._call=this._time=this._next=null}function be(t,n,e){var r=new me;return r.restart(t,n,e),r}function we(){pe=(he=_e.now())+de,se=ce=0;try{!function(){ve(),++se;for(var t,n=ue;n;)(t=pe-n._time)>=0&&n._call.call(void 0,t),n=n._next;--se}()}finally{se=0,function(){var t,n,e=ue,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:ue=n);le=t,Me(r)}(),pe=0}}function xe(){var t=_e.now(),n=t-he;n>1e3&&(de-=n,he=t)}function Me(t){se||(ce&&(ce=clearTimeout(ce)),t-pe>24?(t<1/0&&(ce=setTimeout(we,t-_e.now()-de)),fe&&(fe=clearInterval(fe))):(fe||(he=_e.now(),fe=setInterval(xe,1e3)),se=1,ge(we)))}function Ae(t,n,e){var r=new me;return n=null==n?0:+n,r.restart((e=>{r.stop(),t(e+n)}),n,e),r}me.prototype=be.prototype={constructor:me,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?ve():+e)+(null==n?0:+n),this._next||le===this||(le?le._next=this:ue=this,le=this),this._call=t,this._time=e,Me()},stop:function(){this._call&&(this._call=null,this._time=1/0,Me())}};var ke=re("start","end","cancel","interrupt"),Se=[];function Ne(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 s,c,f,h;if(1!==e.state)return l();for(s in i)if((h=i[s]).name===e.name){if(3===h.state)return Ae(a);4===h.state?(h.state=6,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[s]):+s<n&&(h.state=6,h.timer.stop(),h.on.call("cancel",t,t.__data__,h.index,h.group),delete i[s])}if(Ae((function(){3===e.state&&(e.state=4,e.timer.restart(u,e.delay,e.time),u(o))})),e.state=2,e.on.call("start",t,t.__data__,e.index,e.group),2===e.state){for(e.state=3,r=new Array(f=e.tween.length),s=0,c=-1;s<f;++s)(h=e.tween[s].value.call(t,t.__data__,e.index,e.group))&&(r[++c]=h);r.length=c+1}}function u(n){for(var i=n<e.duration?e.ease.call(null,n/e.duration):(e.timer.restart(l),e.state=5,1),o=-1,a=r.length;++o<a;)r[o].call(t,i);5===e.state&&(e.on.call("end",t,t.__data__,e.index,e.group),l())}function l(){for(var r in e.state=6,e.timer.stop(),delete i[n],i)return;delete t.__transition}i[n]=e,e.timer=be(o,0,e.time)}(t,e,{name:n,index:r,group:i,on:ke,tween:Se,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function Ee(t,n){var e=Pe(t,n);if(e.state>0)throw new Error("too late; already scheduled");return e}function Ce(t,n){var e=Pe(t,n);if(e.state>3)throw new Error("too late; already running");return e}function Pe(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function je(t,n){var e,r;return function(){var i=Ce(this,t),o=i.tween;if(o!==e)for(var a=0,u=(r=e=o).length;a<u;++a)if(r[a].name===n){(r=r.slice()).splice(a,1);break}i.tween=r}}function Oe(t,n,e){var r,i;if("function"!=typeof e)throw new Error;return function(){var o=Ce(this,t),a=o.tween;if(a!==r){i=(r=a).slice();for(var u={name:n,value:e},l=0,s=i.length;l<s;++l)if(i[l].name===n){i[l]=u;break}l===s&&i.push(u)}o.tween=i}}function $e(t,n,e){var r=t._id;return t.each((function(){var t=Ce(this,r);(t.value||(t.value={}))[n]=e.apply(this,arguments)})),function(t){return Pe(t,r).value[n]}}function Te(t,n){var e;return("number"==typeof n?hn:n instanceof qt?ln:(e=qt(n))?(n=e,ln):gn)(t,n)}function Re(t){return function(){this.removeAttribute(t)}}function He(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Ie(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttribute(t);return a===o?null:a===r?i:i=n(r=a,e)}}function De(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===r?i:i=n(r=a,e)}}function Fe(t,n,e){var r,i,o;return function(){var a,u,l=e(this);if(null!=l)return(a=this.getAttribute(t))===(u=l+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,l));this.removeAttribute(t)}}function Le(t,n,e){var r,i,o;return function(){var a,u,l=e(this);if(null!=l)return(a=this.getAttributeNS(t.space,t.local))===(u=l+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,l));this.removeAttributeNS(t.space,t.local)}}function ze(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttributeNS(t.space,t.local,n.call(this,e))}}(t,i)),e}return i._value=n,i}function qe(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttribute(t,n.call(this,e))}}(t,i)),e}return i._value=n,i}function Ue(t,n){return function(){Ee(this,t).delay=+n.apply(this,arguments)}}function Xe(t,n){return n=+n,function(){Ee(this,t).delay=n}}function Be(t,n){return function(){Ce(this,t).duration=+n.apply(this,arguments)}}function Ye(t,n){return n=+n,function(){Ce(this,t).duration=n}}var Ve=ft.prototype.constructor;function We(t){return function(){this.style.removeProperty(t)}}var Ge=0;function Ke(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function Ze(t){return ft().transition(t)}function Je(){return++Ge}var Qe=ft.prototype;Ke.prototype=Ze.prototype={constructor:Ke,select:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=u(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a<i;++a)for(var l,s,c=r[a],f=c.length,h=o[a]=new Array(f),p=0;p<f;++p)(l=c[p])&&(s=t.call(l,l.__data__,p,c))&&("__data__"in l&&(s.__data__=l.__data__),h[p]=s,Ne(h[p],n,e,p,h,Pe(l,e)));return new Ke(o,this._parents,n,e)},selectAll:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=s(t));for(var r=this._groups,i=r.length,o=[],a=[],u=0;u<i;++u)for(var l,c=r[u],f=c.length,h=0;h<f;++h)if(l=c[h]){for(var p,d=t.call(l,l.__data__,h,c),_=Pe(l,e),g=0,v=d.length;g<v;++g)(p=d[g])&&Ne(p,n,e,g,d,_);o.push(d),a.push(l)}return new Ke(o,a,n,e)},selectChild:Qe.selectChild,selectChildren:Qe.selectChildren,filter:function(t){"function"!=typeof t&&(t=f(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a=n[i],u=a.length,l=r[i]=[],s=0;s<u;++s)(o=a[s])&&t.call(o,o.__data__,s,a)&&l.push(o);return new Ke(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),a=new Array(r),u=0;u<o;++u)for(var l,s=n[u],c=e[u],f=s.length,h=a[u]=new Array(f),p=0;p<f;++p)(l=s[p]||c[p])&&(h[p]=l);for(;u<r;++u)a[u]=n[u];return new Ke(a,this._parents,this._name,this._id)},selection:function(){return new Ve(this._groups,this._parents)},transition:function(){for(var t=this._name,n=this._id,e=Je(),r=this._groups,i=r.length,o=0;o<i;++o)for(var a,u=r[o],l=u.length,s=0;s<l;++s)if(a=u[s]){var c=Pe(a,n);Ne(a,t,e,s,u,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Ke(r,this._parents,t,e)},call:Qe.call,nodes:Qe.nodes,node:Qe.node,size:Qe.size,empty:Qe.empty,each:Qe.each,on:function(t,n){var e=this._id;return arguments.length<2?Pe(this.node(),e).on.on(t):this.each(function(t,n,e){var r,i,o=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||"start"===t}))}(n)?Ee:Ce;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var r=e(t),i="transform"===r?kn:Te;return this.attrTween(t,"function"==typeof n?(r.local?Le:Fe)(r,i,$e(this,"attr."+t,n)):null==n?(r.local?He:Re)(r):(r.local?De:Ie)(r,i,n))},attrTween:function(t,n){var r="attr."+t;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;var i=e(t);return this.tween(r,(i.local?ze:qe)(i,n))},style:function(t,n,e){var r="transform"==(t+="")?An:Te;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=T(this,t),a=(this.style.removeProperty(t),T(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,We(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=T(this,t),u=e(this),l=u+"";return null==u&&(this.style.removeProperty(t),l=u=T(this,t)),a===l?null:a===r&&l===i?o:(i=l,o=n(r=a,u))}}(t,r,$e(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var l=Ce(this,t),s=l.on,c=null==l.value[a]?o||(o=We(n)):void 0;s===e&&i===c||(r=(e=s).copy()).on(u,i=c),l.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=T(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}($e(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=Pe(this.node(),e).tween,o=0,a=i.length;o<a;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==n?je:Oe)(e,t,n))},delay:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?Ue:Xe)(n,t)):Pe(this.node(),n).delay},duration:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?Be:Ye)(n,t)):Pe(this.node(),n).duration},ease:function(t){var n=this._id;return arguments.length?this.each(function(t,n){if("function"!=typeof n)throw new Error;return function(){Ce(this,t).ease=n}}(n,t)):Pe(this.node(),n).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,n){return function(){var e=n.apply(this,arguments);if("function"!=typeof e)throw new Error;Ce(this,t).ease=e}}(this._id,t))},end:function(){var t,n,e=this,r=e._id,i=e.size();return new Promise((function(o,a){var u={value:a},l={value:function(){0==--i&&o()}};e.each((function(){var e=Ce(this,r),i=e.on;i!==t&&((n=(t=i).copy())._.cancel.push(u),n._.interrupt.push(u),n._.end.push(l)),e.on=n})),0===i&&o()}))},[Symbol.iterator]:Qe[Symbol.iterator]};var tr={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function nr(t,n){for(var e;!(e=t.__transition)||!(e=e[n]);)if(!(t=t.parentNode))throw new Error(`transition ${n} not found`);return e}function er(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}ft.prototype.interrupt=function(t){return this.each((function(){!function(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}}(this,t)}))},ft.prototype.transition=function(t){var n,e;t instanceof Ke?(n=t._id,t=t._name):(n=Je(),(e=tr).time=ve(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a,u=r[o],l=u.length,s=0;s<l;++s)(a=u[s])&&Ne(a,t,n,s,u,e||nr(a,n));return new Ke(r,this._parents,t,n)};var rr="object"==typeof global&&global&&global.Object===Object&&global,ir="object"==typeof self&&self&&self.Object===Object&&self,or=rr||ir||Function("return this")(),ar=function(){return or.Date.now()},ur=/\s/;var lr=/^\s+/;function sr(t){return t?t.slice(0,function(t){for(var n=t.length;n--&&ur.test(t.charAt(n)););return n}(t)+1).replace(lr,""):t}var cr=or.Symbol,fr=Object.prototype,hr=fr.hasOwnProperty,pr=fr.toString,dr=cr?cr.toStringTag:void 0;var _r=Object.prototype.toString;var gr=cr?cr.toStringTag:void 0;function vr(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":gr&&gr in Object(t)?function(t){var n=hr.call(t,dr),e=t[dr];try{t[dr]=void 0;var r=!0}catch(t){}var i=pr.call(t);return r&&(n?t[dr]=e:delete t[dr]),i}(t):function(t){return _r.call(t)}(t)}var yr=/^[-+]0x[0-9a-f]+$/i,mr=/^0b[01]+$/i,br=/^0o[0-7]+$/i,wr=parseInt;function xr(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return null!=t&&"object"==typeof t}(t)&&"[object Symbol]"==vr(t)}(t))return NaN;if(er(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=er(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=sr(t);var e=mr.test(t);return e||br.test(t)?wr(t.slice(2),e?2:8):yr.test(t)?NaN:+t}var Mr=Math.max,Ar=Math.min;functi