chartformers 1.0.58 → 1.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chartformers.es.js +485 -485
- package/dist/chartformers.umd.js +29 -29
- package/package.json +1 -1
package/dist/chartformers.umd.js
CHANGED
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,pt,ot,O,ot),et[ot+pt]=!0)}if(ot=null,wt!==void 0&&(n(wt),ot=""+wt),s(dt)&&(n(dt.key),ot=""+dt.key),"key"in dt){wt={};for(var Q in dt)Q!=="key"&&(wt[Q]=dt[Q])}else wt=dt;return ot&&o(wt,typeof $=="function"?$.displayName||$.name||"Unknown":$),c($,ot,wt,a(),_t,G)}function h($){f($)?$._store&&($._store.validated=1):typeof $=="object"&&$!==null&&$.$$typeof===E&&($._payload.status==="fulfilled"?f($._payload.value)&&$._payload.value._store&&($._payload.value._store.validated=1):$._store&&($._store.validated=1))}function f($){return typeof $=="object"&&$!==null&&$.$$typeof===v}var g=bt,v=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),y=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),z=Symbol.for("react.view_transition"),I=Symbol.for("react.client.reference"),N=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,M=Array.isArray,Y=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function($){return $()}};var C,F={},H=g.react_stack_bottom_frame.bind(g,i)(),V=Y(r(i)),et={};Mr.Fragment=d,Mr.jsx=function($,dt,wt){var pt=1e4>N.recentlyCreatedOwnerStacks++;if(pt){var _t=Error.stackTraceLimit;Error.stackTraceLimit=10;var G=Error("react-stack-top-frame");Error.stackTraceLimit=_t}else G=H;return u($,dt,wt,!1,G,pt?Y(r($)):V)},Mr.jsxs=function($,dt,wt){var pt=1e4>N.recentlyCreatedOwnerStacks++;if(pt){var _t=Error.stackTraceLimit;Error.stackTraceLimit=10;var G=Error("react-stack-top-frame");Error.stackTraceLimit=_t}else G=H;return u($,dt,wt,!0,G,pt?Y(r($)):V)}})()),Mr}var ro;function Hu(){return ro||(ro=1,process.env.NODE_ENV==="production"?ua.exports=Iu():ua.exports=Fu()),ua.exports}var m=Hu();function Ln(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ao(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Nr(t){let e,n,r;t.length!==2?(e=Ln,n=(o,l)=>Ln(t(o),l),r=(o,l)=>t(o)-l):(e=t===Ln||t===ao?t:Wu,n=t,r=t);function a(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const h=c+u>>>1;n(o[h],l)<0?c=h+1:u=h}while(c<u)}return c}function i(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const h=c+u>>>1;n(o[h],l)<=0?c=h+1:u=h}while(c<u)}return c}function s(o,l,c=0,u=o.length){const h=a(o,l,c,u-1);return h>c&&r(o[h-1],l)>-r(o[h],l)?h-1:h}return{left:a,center:s,right:i}}function Wu(){return 0}function Ou(t){return t===null?NaN:+t}function*Bu(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const io=Nr(Ln).right;Nr(Ou).center;function ki(t,e){let n=0;for(let r of t)r!=null&&(r=+r)>=r&&++n;return n}function Yu(t,e){let n=0,r,a=0,i=0;for(let s of t)s!=null&&(s=+s)>=s&&(r=s-a,a+=r/++n,i+=r*(s-a));if(n>1)return i/(n-1)}function Uu(t,e){const n=Yu(t);return n&&Math.sqrt(n)}function fa(t,e){let n,r;if(e===void 0)for(const a of t)a!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)));else{let a=-1;for(let i of t)(i=e(i,++a,t))!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)))}return[n,r]}class Ai extends Map{constructor(e,n=Ku){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,a]of e)this.set(r,a)}get(e){return super.get(so(this,e))}has(e){return super.has(so(this,e))}set(e,n){return super.set(Vu(this,e),n)}delete(e){return super.delete(Xu(this,e))}}function so({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Vu({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Xu({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Ku(t){return t!==null&&typeof t=="object"?t.valueOf():t}function ha(t){return t}function oo(t,...e){return lo(t,ha,ha,e)}function Gu(t,e,...n){return lo(t,ha,e,n)}function lo(t,e,n,r){return(function a(i,s){if(s>=r.length)return n(i);const o=new Ai,l=r[s++];let c=-1;for(const u of i){const h=l(u,++c,i),f=o.get(h);f?f.push(u):o.set(h,[u])}for(const[u,h]of o)o.set(u,a(h,s));return e(o)})(t,0)}function Zu(t=Ln){if(t===Ln)return co;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,n)=>{const r=t(e,n);return r||r===0?r:(t(n,n)===0)-(t(e,e)===0)}}function co(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}var Ju=Array.prototype,Qu=Ju.slice;function Si(t){return()=>t}const qu=Math.sqrt(50),tf=Math.sqrt(10),ef=Math.sqrt(2);function da(t,e,n){const r=(e-t)/Math.max(0,n),a=Math.floor(Math.log10(r)),i=r/Math.pow(10,a),s=i>=qu?10:i>=tf?5:i>=ef?2:1;let o,l,c;return a<0?(c=Math.pow(10,-a)/s,o=Math.round(t*c),l=Math.round(e*c),o/c<t&&++o,l/c>e&&--l,c=-c):(c=Math.pow(10,a)*s,o=Math.round(t/c),l=Math.round(e/c),o*c<t&&++o,l*c>e&&--l),l<o&&.5<=n&&n<2?da(t,e,n*2):[o,l,c]}function uo(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[a,i,s]=r?da(e,t,n):da(t,e,n);if(!(i>=a))return[];const o=i-a+1,l=new Array(o);if(r)if(s<0)for(let c=0;c<o;++c)l[c]=(i-c)/-s;else for(let c=0;c<o;++c)l[c]=(i-c)*s;else if(s<0)for(let c=0;c<o;++c)l[c]=(a+c)/-s;else for(let c=0;c<o;++c)l[c]=(a+c)*s;return l}function Qn(t,e,n){return e=+e,t=+t,n=+n,da(t,e,n)[2]}function pa(t,e,n){e=+e,t=+t,n=+n;const r=e<t,a=r?Qn(e,t,n):Qn(t,e,n);return(r?-1:1)*(a<0?1/-a:a)}function nf(t,e,n){let r;for(;;){const a=Qn(t,e,n);if(a===r||a===0||!isFinite(a))return[t,e];a>0?(t=Math.floor(t/a)*a,e=Math.ceil(e/a)*a):a<0&&(t=Math.ceil(t*a)/a,e=Math.floor(e*a)/a),r=a}}function fo(t){return Math.max(1,Math.ceil(Math.log(ki(t))/Math.LN2)+1)}function rf(){var t=ha,e=fa,n=fo;function r(a){Array.isArray(a)||(a=Array.from(a));var i,s=a.length,o,l,c=new Array(s);for(i=0;i<s;++i)c[i]=t(a[i],i,a);var u=e(c),h=u[0],f=u[1],g=n(c,h,f);if(!Array.isArray(g)){const w=f,y=+g;if(e===fa&&([h,f]=nf(h,f,y)),g=uo(h,f,y),g[0]<=h&&(l=Qn(h,f,y)),g[g.length-1]>=f)if(w>=f&&e===fa){const T=Qn(h,f,y);isFinite(T)&&(T>0?f=(Math.floor(f/T)+1)*T:T<0&&(f=(Math.ceil(f*-T)+1)/-T))}else g.pop()}for(var v=g.length,b=0,d=v;g[b]<=h;)++b;for(;g[d-1]>f;)--d;(b||d<v)&&(g=g.slice(b,d),v=d-b);var x=new Array(v+1),S;for(i=0;i<=v;++i)S=x[i]=[],S.x0=i>0?g[i-1]:h,S.x1=i<v?g[i]:f;if(isFinite(l)){if(l>0)for(i=0;i<s;++i)(o=c[i])!=null&&h<=o&&o<=f&&x[Math.min(v,Math.floor((o-h)/l))].push(a[i]);else if(l<0){for(i=0;i<s;++i)if((o=c[i])!=null&&h<=o&&o<=f){const w=Math.floor((h-o)*l);x[Math.min(v,w+(g[w]<=o))].push(a[i])}}}else for(i=0;i<s;++i)(o=c[i])!=null&&h<=o&&o<=f&&x[io(g,o,0,v)].push(a[i]);return x}return r.value=function(a){return arguments.length?(t=typeof a=="function"?a:Si(a),r):t},r.domain=function(a){return arguments.length?(e=typeof a=="function"?a:Si([a[0],a[1]]),r):e},r.thresholds=function(a){return arguments.length?(n=typeof a=="function"?a:Si(Array.isArray(a)?Qu.call(a):a),r):n},r}function Gt(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let a of t)(a=e(a,++r,t))!=null&&(n<a||n===void 0&&a>=a)&&(n=a)}return n}function oe(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let a of t)(a=e(a,++r,t))!=null&&(n>a||n===void 0&&a>=a)&&(n=a)}return n}function ho(t,e,n=0,r=1/0,a){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(t.length-1,r)),!(n<=e&&e<=r))return t;for(a=a===void 0?co:Zu(a);r>n;){if(r-n>600){const l=r-n+1,c=e-n+1,u=Math.log(l),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1),g=Math.max(n,Math.floor(e-c*h/l+f)),v=Math.min(r,Math.floor(e+(l-c)*h/l+f));ho(t,e,g,v,a)}const i=t[e];let s=n,o=r;for(Tr(t,n,e),a(t[r],i)>0&&Tr(t,n,r);s<o;){for(Tr(t,s,o),++s,--o;a(t[s],i)<0;)++s;for(;a(t[o],i)>0;)--o}a(t[n],i)===0?Tr(t,n,o):(++o,Tr(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function Tr(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function po(t,e,n){if(t=Float64Array.from(Bu(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return oe(t);if(e>=1)return Gt(t);var r,a=(r-1)*e,i=Math.floor(a),s=Gt(ho(t,i).subarray(0,i+1)),o=oe(t.subarray(i+1));return s+(o-s)*(a-i)}}function af(t,e,n){const r=ki(t),a=po(t,.75)-po(t,.25);return r&&a?Math.ceil((n-e)/(2*a*Math.pow(r,-1/3))):1}function sf(t,e,n){const r=ki(t),a=Uu(t);return r&&a?Math.ceil((n-e)*Math.cbrt(r)/(3.49*a)):1}function ga(t,e,n){t=+t,e=+e,n=(a=arguments.length)<2?(e=t,t=0,1):a<3?1:+n;for(var r=-1,a=Math.max(0,Math.ceil((e-t)/n))|0,i=new Array(a);++r<a;)i[r]=t+r*n;return i}const of=lf(Math.random);function lf(t){return function(n,r=0,a=n.length){let i=a-(r=+r);for(;i;){const s=t()*i--|0,o=n[i+r];n[i+r]=n[s+r],n[s+r]=o}return n}}function Dr(t,e){let n=0;if(e===void 0)for(let r of t)(r=+r)&&(n+=r);else{let r=-1;for(let a of t)(a=+e(a,++r,t))&&(n+=a)}return n}function cf(t){return t}var ya=1,xa=2,Mi=3,$r=4,go=1e-6;function uf(t){return"translate("+t+",0)"}function ff(t){return"translate(0,"+t+")"}function hf(t){return e=>+t(e)}function df(t,e){return e=Math.max(0,t.bandwidth()-e*2)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function pf(){return!this.__axis}function ma(t,e){var n=[],r=null,a=null,i=6,s=6,o=3,l=typeof window<"u"&&window.devicePixelRatio>1?0:.5,c=t===ya||t===$r?-1:1,u=t===$r||t===xa?"x":"y",h=t===ya||t===Mi?uf:ff;function f(g){var v=r??(e.ticks?e.ticks.apply(e,n):e.domain()),b=a??(e.tickFormat?e.tickFormat.apply(e,n):cf),d=Math.max(i,0)+o,x=e.range(),S=+x[0]+l,w=+x[x.length-1]+l,y=(e.bandwidth?df:hf)(e.copy(),l),T=g.selection?g.selection():g,p=T.selectAll(".domain").data([null]),k=T.selectAll(".tick").data(v,e).order(),_=k.exit(),E=k.enter().append("g").attr("class","tick"),R=k.select("line"),z=k.select("text");p=p.merge(p.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),k=k.merge(E),R=R.merge(E.append("line").attr("stroke","currentColor").attr(u+"2",c*i)),z=z.merge(E.append("text").attr("fill","currentColor").attr(u,c*d).attr("dy",t===ya?"0em":t===Mi?"0.71em":"0.32em")),g!==T&&(p=p.transition(g),k=k.transition(g),R=R.transition(g),z=z.transition(g),_=_.transition(g).attr("opacity",go).attr("transform",function(I){return isFinite(I=y(I))?h(I+l):this.getAttribute("transform")}),E.attr("opacity",go).attr("transform",function(I){var N=this.parentNode.__axis;return h((N&&isFinite(N=N(I))?N:y(I))+l)})),_.remove(),p.attr("d",t===$r||t===xa?s?"M"+c*s+","+S+"H"+l+"V"+w+"H"+c*s:"M"+l+","+S+"V"+w:s?"M"+S+","+c*s+"V"+l+"H"+w+"V"+c*s:"M"+S+","+l+"H"+w),k.attr("opacity",1).attr("transform",function(I){return h(y(I)+l)}),R.attr(u+"2",c*i),z.attr(u,c*d).text(b),T.filter(pf).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===xa?"start":t===$r?"end":"middle"),T.each(function(){this.__axis=y})}return f.scale=function(g){return arguments.length?(e=g,f):e},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(g){return arguments.length?(n=g==null?[]:Array.from(g),f):n.slice()},f.tickValues=function(g){return arguments.length?(r=g==null?null:Array.from(g),f):r&&r.slice()},f.tickFormat=function(g){return arguments.length?(a=g,f):a},f.tickSize=function(g){return arguments.length?(i=s=+g,f):i},f.tickSizeInner=function(g){return arguments.length?(i=+g,f):i},f.tickSizeOuter=function(g){return arguments.length?(s=+g,f):s},f.tickPadding=function(g){return arguments.length?(o=+g,f):o},f.offset=function(g){return arguments.length?(l=+g,f):l},f}function va(t){return ma(ya,t)}function Ni(t){return ma(xa,t)}function he(t){return ma(Mi,t)}function be(t){return ma($r,t)}var gf={value:()=>{}};function Cr(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new ba(n)}function ba(t){this._=t}function yf(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",a=n.indexOf(".");if(a>=0&&(r=n.slice(a+1),n=n.slice(0,a)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ba.prototype=Cr.prototype={constructor:ba,on:function(t,e){var n=this._,r=yf(t+"",n),a,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((a=(t=r[i]).type)&&(a=xf(n[a],t.name)))return a;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<s;)if(a=(t=r[i]).type)n[a]=yo(n[a],t.name,e);else if(e==null)for(a in n)n[a]=yo(n[a],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new ba(t)},call:function(t,e){if((a=arguments.length-2)>0)for(var n=new Array(a),r=0,a,i;r<a;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=this._[t],r=0,a=i.length;r<a;++r)i[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],a=0,i=r.length;a<i;++a)r[a].value.apply(e,n)}};function xf(t,e){for(var n=0,r=t.length,a;n<r;++n)if((a=t[n]).name===e)return a.value}function yo(t,e,n){for(var r=0,a=t.length;r<a;++r)if(t[r].name===e){t[r]=gf,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Ti="http://www.w3.org/1999/xhtml";const xo={svg:"http://www.w3.org/2000/svg",xhtml:Ti,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function wa(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),xo.hasOwnProperty(e)?{space:xo[e],local:t}:t}function mf(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Ti&&e.documentElement.namespaceURI===Ti?e.createElement(t):e.createElementNS(n,t)}}function vf(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function mo(t){var e=wa(t);return(e.local?vf:mf)(e)}function bf(){}function Di(t){return t==null?bf:function(){return this.querySelector(t)}}function wf(t){typeof t!="function"&&(t=Di(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],s=i.length,o=r[a]=new Array(s),l,c,u=0;u<s;++u)(l=i[u])&&(c=t.call(l,l.__data__,u,i))&&("__data__"in l&&(c.__data__=l.__data__),o[u]=c);return new Ue(r,this._parents)}function _f(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function kf(){return[]}function vo(t){return t==null?kf:function(){return this.querySelectorAll(t)}}function Af(t){return function(){return _f(t.apply(this,arguments))}}function Sf(t){typeof t=="function"?t=Af(t):t=vo(t);for(var e=this._groups,n=e.length,r=[],a=[],i=0;i<n;++i)for(var s=e[i],o=s.length,l,c=0;c<o;++c)(l=s[c])&&(r.push(t.call(l,l.__data__,c,s)),a.push(l));return new Ue(r,a)}function bo(t){return function(){return this.matches(t)}}function wo(t){return function(e){return e.matches(t)}}var Mf=Array.prototype.find;function Nf(t){return function(){return Mf.call(this.children,t)}}function Tf(){return this.firstElementChild}function Df(t){return this.select(t==null?Tf:Nf(typeof t=="function"?t:wo(t)))}var $f=Array.prototype.filter;function Cf(){return Array.from(this.children)}function Lf(t){return function(){return $f.call(this.children,t)}}function jf(t){return this.selectAll(t==null?Cf:Lf(typeof t=="function"?t:wo(t)))}function Pf(t){typeof t!="function"&&(t=bo(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],s=i.length,o=r[a]=[],l,c=0;c<s;++c)(l=i[c])&&t.call(l,l.__data__,c,i)&&o.push(l);return new Ue(r,this._parents)}function _o(t){return new Array(t.length)}function Ef(){return new Ue(this._enter||this._groups.map(_o),this._parents)}function _a(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}_a.prototype={constructor:_a,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Rf(t){return function(){return t}}function zf(t,e,n,r,a,i){for(var s=0,o,l=e.length,c=i.length;s<c;++s)(o=e[s])?(o.__data__=i[s],r[s]=o):n[s]=new _a(t,i[s]);for(;s<l;++s)(o=e[s])&&(a[s]=o)}function If(t,e,n,r,a,i,s){var o,l,c=new Map,u=e.length,h=i.length,f=new Array(u),g;for(o=0;o<u;++o)(l=e[o])&&(f[o]=g=s.call(l,l.__data__,o,e)+"",c.has(g)?a[o]=l:c.set(g,l));for(o=0;o<h;++o)g=s.call(t,i[o],o,i)+"",(l=c.get(g))?(r[o]=l,l.__data__=i[o],c.delete(g)):n[o]=new _a(t,i[o]);for(o=0;o<u;++o)(l=e[o])&&c.get(f[o])===l&&(a[o]=l)}function Ff(t){return t.__data__}function Hf(t,e){if(!arguments.length)return Array.from(this,Ff);var n=e?If:zf,r=this._parents,a=this._groups;typeof t!="function"&&(t=Rf(t));for(var i=a.length,s=new Array(i),o=new Array(i),l=new Array(i),c=0;c<i;++c){var u=r[c],h=a[c],f=h.length,g=Wf(t.call(u,u&&u.__data__,c,r)),v=g.length,b=o[c]=new Array(v),d=s[c]=new Array(v),x=l[c]=new Array(f);n(u,h,b,d,x,g,e);for(var S=0,w=0,y,T;S<v;++S)if(y=b[S]){for(S>=w&&(w=S+1);!(T=d[w])&&++w<v;);y._next=T||null}}return s=new Ue(s,r),s._enter=o,s._exit=l,s}function Wf(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Of(){return new Ue(this._exit||this._groups.map(_o),this._parents)}function Bf(t,e,n){var r=this.enter(),a=this,i=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(a=e(a),a&&(a=a.selection())),n==null?i.remove():n(i),r&&a?r.merge(a).order():a}function Yf(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,a=n.length,i=r.length,s=Math.min(a,i),o=new Array(a),l=0;l<s;++l)for(var c=n[l],u=r[l],h=c.length,f=o[l]=new Array(h),g,v=0;v<h;++v)(g=c[v]||u[v])&&(f[v]=g);for(;l<a;++l)o[l]=n[l];return new Ue(o,this._parents)}function Uf(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],a=r.length-1,i=r[a],s;--a>=0;)(s=r[a])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Vf(t){t||(t=Xf);function e(h,f){return h&&f?t(h.__data__,f.__data__):!h-!f}for(var n=this._groups,r=n.length,a=new Array(r),i=0;i<r;++i){for(var s=n[i],o=s.length,l=a[i]=new Array(o),c,u=0;u<o;++u)(c=s[u])&&(l[u]=c);l.sort(e)}return new Ue(a,this._parents).order()}function Xf(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Kf(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Gf(){return Array.from(this)}function Zf(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],a=0,i=r.length;a<i;++a){var s=r[a];if(s)return s}return null}function Jf(){let t=0;for(const e of this)++t;return t}function Qf(){return!this.node()}function qf(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var a=e[n],i=0,s=a.length,o;i<s;++i)(o=a[i])&&t.call(o,o.__data__,i,a);return this}function th(t){return function(){this.removeAttribute(t)}}function eh(t){return function(){this.removeAttributeNS(t.space,t.local)}}function nh(t,e){return function(){this.setAttribute(t,e)}}function rh(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ah(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function ih(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function sh(t,e){var n=wa(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?eh:th:typeof e=="function"?n.local?ih:ah:n.local?rh:nh)(n,e))}function ko(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function oh(t){return function(){this.style.removeProperty(t)}}function lh(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ch(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function uh(t,e,n){return arguments.length>1?this.each((e==null?oh:typeof e=="function"?ch:lh)(t,e,n??"")):qn(this.node(),t)}function qn(t,e){return t.style.getPropertyValue(e)||ko(t).getComputedStyle(t,null).getPropertyValue(e)}function fh(t){return function(){delete this[t]}}function hh(t,e){return function(){this[t]=e}}function dh(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function ph(t,e){return arguments.length>1?this.each((e==null?fh:typeof e=="function"?dh:hh)(t,e)):this.node()[t]}function Ao(t){return t.trim().split(/^|\s+/)}function $i(t){return t.classList||new So(t)}function So(t){this._node=t,this._names=Ao(t.getAttribute("class")||"")}So.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Mo(t,e){for(var n=$i(t),r=-1,a=e.length;++r<a;)n.add(e[r])}function No(t,e){for(var n=$i(t),r=-1,a=e.length;++r<a;)n.remove(e[r])}function gh(t){return function(){Mo(this,t)}}function yh(t){return function(){No(this,t)}}function xh(t,e){return function(){(e.apply(this,arguments)?Mo:No)(this,t)}}function mh(t,e){var n=Ao(t+"");if(arguments.length<2){for(var r=$i(this.node()),a=-1,i=n.length;++a<i;)if(!r.contains(n[a]))return!1;return!0}return this.each((typeof e=="function"?xh:e?gh:yh)(n,e))}function vh(){this.textContent=""}function bh(t){return function(){this.textContent=t}}function wh(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function _h(t){return arguments.length?this.each(t==null?vh:(typeof t=="function"?wh:bh)(t)):this.node().textContent}function kh(){this.innerHTML=""}function Ah(t){return function(){this.innerHTML=t}}function Sh(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Mh(t){return arguments.length?this.each(t==null?kh:(typeof t=="function"?Sh:Ah)(t)):this.node().innerHTML}function Nh(){this.nextSibling&&this.parentNode.appendChild(this)}function Th(){return this.each(Nh)}function Dh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function $h(){return this.each(Dh)}function Ch(t){var e=typeof t=="function"?t:mo(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Lh(){return null}function jh(t,e){var n=typeof t=="function"?t:mo(t),r=e==null?Lh:typeof e=="function"?e:Di(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Ph(){var t=this.parentNode;t&&t.removeChild(this)}function Eh(){return this.each(Ph)}function Rh(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function zh(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ih(t){return this.select(t?zh:Rh)}function Fh(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Hh(t){return function(e){t.call(this,e,this.__data__)}}function Wh(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Oh(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,a=e.length,i;n<a;++n)i=e[n],(!t.type||i.type===t.type)&&i.name===t.name?this.removeEventListener(i.type,i.listener,i.options):e[++r]=i;++r?e.length=r:delete this.__on}}}function Bh(t,e,n){return function(){var r=this.__on,a,i=Hh(e);if(r){for(var s=0,o=r.length;s<o;++s)if((a=r[s]).type===t.type&&a.name===t.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=i,a.options=n),a.value=e;return}}this.addEventListener(t.type,i,n),a={type:t.type,name:t.name,value:e,listener:i,options:n},r?r.push(a):this.__on=[a]}}function Yh(t,e,n){var r=Wh(t+""),a,i=r.length,s;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,c=o.length,u;l<c;++l)for(a=0,u=o[l];a<i;++a)if((s=r[a]).type===u.type&&s.name===u.name)return u.value}return}for(o=e?Bh:Oh,a=0;a<i;++a)this.each(o(r[a],e,n));return this}function To(t,e,n){var r=ko(t),a=r.CustomEvent;typeof a=="function"?a=new a(e,n):(a=r.document.createEvent("Event"),n?(a.initEvent(e,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(e,!1,!1)),t.dispatchEvent(a)}function Uh(t,e){return function(){return To(this,t,e)}}function Vh(t,e){return function(){return To(this,t,e.apply(this,arguments))}}function Xh(t,e){return this.each((typeof e=="function"?Vh:Uh)(t,e))}function*Kh(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],a=0,i=r.length,s;a<i;++a)(s=r[a])&&(yield s)}var Do=[null];function Ue(t,e){this._groups=t,this._parents=e}function Lr(){return new Ue([[document.documentElement]],Do)}function Gh(){return this}Ue.prototype=Lr.prototype={constructor:Ue,select:wf,selectAll:Sf,selectChild:Df,selectChildren:jf,filter:Pf,data:Hf,enter:Ef,exit:Of,join:Bf,merge:Yf,selection:Gh,order:Uf,sort:Vf,call:Kf,nodes:Gf,node:Zf,size:Jf,empty:Qf,each:qf,attr:sh,style:uh,property:ph,classed:mh,text:_h,html:Mh,raise:Th,lower:$h,append:Ch,insert:jh,remove:Eh,clone:Ih,datum:Fh,on:Yh,dispatch:Xh,[Symbol.iterator]:Kh};function qt(t){return typeof t=="string"?new Ue([[document.querySelector(t)]],[document.documentElement]):new Ue([[t]],Do)}function Zh(t){let e;for(;e=t.sourceEvent;)t=e;return t}function tr(t,e){if(t=Zh(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var a=e.getBoundingClientRect();return[t.clientX-a.left-e.clientLeft,t.clientY-a.top-e.clientTop]}}return[t.pageX,t.pageY]}const Jh={passive:!1},jr={capture:!0,passive:!1};function Ci(t){t.stopImmediatePropagation()}function er(t){t.preventDefault(),t.stopImmediatePropagation()}function $o(t){var e=t.document.documentElement,n=qt(t).on("dragstart.drag",er,jr);"onselectstart"in e?n.on("selectstart.drag",er,jr):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Co(t,e){var n=t.document.documentElement,r=qt(t).on("dragstart.drag",null);e&&(r.on("click.drag",er,jr),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const ka=t=>()=>t;function Li(t,{sourceEvent:e,subject:n,target:r,identifier:a,active:i,x:s,y:o,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Li.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Qh(t){return!t.ctrlKey&&!t.button}function qh(){return this.parentNode}function td(t,e){return e??{x:t.x,y:t.y}}function ed(){return navigator.maxTouchPoints||"ontouchstart"in this}function nd(){var t=Qh,e=qh,n=td,r=ed,a={},i=Cr("start","drag","end"),s=0,o,l,c,u,h=0;function f(y){y.on("mousedown.drag",g).filter(r).on("touchstart.drag",d).on("touchmove.drag",x,Jh).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(y,T){if(!(u||!t.call(this,y,T))){var p=w(this,e.call(this,y,T),y,T,"mouse");p&&(qt(y.view).on("mousemove.drag",v,jr).on("mouseup.drag",b,jr),$o(y.view),Ci(y),c=!1,o=y.clientX,l=y.clientY,p("start",y))}}function v(y){if(er(y),!c){var T=y.clientX-o,p=y.clientY-l;c=T*T+p*p>h}a.mouse("drag",y)}function b(y){qt(y.view).on("mousemove.drag mouseup.drag",null),Co(y.view,c),er(y),a.mouse("end",y)}function d(y,T){if(t.call(this,y,T)){var p=y.changedTouches,k=e.call(this,y,T),_=p.length,E,R;for(E=0;E<_;++E)(R=w(this,k,y,T,p[E].identifier,p[E]))&&(Ci(y),R("start",y,p[E]))}}function x(y){var T=y.changedTouches,p=T.length,k,_;for(k=0;k<p;++k)(_=a[T[k].identifier])&&(er(y),_("drag",y,T[k]))}function S(y){var T=y.changedTouches,p=T.length,k,_;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),k=0;k<p;++k)(_=a[T[k].identifier])&&(Ci(y),_("end",y,T[k]))}function w(y,T,p,k,_,E){var R=i.copy(),z=tr(E||p,T),I,N,U;if((U=n.call(y,new Li("beforestart",{sourceEvent:p,target:f,identifier:_,active:s,x:z[0],y:z[1],dx:0,dy:0,dispatch:R}),k))!=null)return I=U.x-z[0]||0,N=U.y-z[1]||0,function M(Y,C,F){var H=z,V;switch(Y){case"start":a[_]=M,V=s++;break;case"end":delete a[_],--s;case"drag":z=tr(F||C,T),V=s;break}R.call(Y,y,new Li(Y,{sourceEvent:C,subject:U,target:f,identifier:_,active:V,x:z[0]+I,y:z[1]+N,dx:z[0]-H[0],dy:z[1]-H[1],dispatch:R}),k)}}return f.filter=function(y){return arguments.length?(t=typeof y=="function"?y:ka(!!y),f):t},f.container=function(y){return arguments.length?(e=typeof y=="function"?y:ka(y),f):e},f.subject=function(y){return arguments.length?(n=typeof y=="function"?y:ka(y),f):n},f.touchable=function(y){return arguments.length?(r=typeof y=="function"?y:ka(!!y),f):r},f.on=function(){var y=i.on.apply(i,arguments);return y===i?f:y},f.clickDistance=function(y){return arguments.length?(h=(y=+y)*y,f):Math.sqrt(h)},f}function nr(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Pr(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function An(){}var jn=.7,rr=1/jn,ar="\\s*([+-]?\\d+)\\s*",Er="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",sn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",rd=/^#([0-9a-f]{3,8})$/,ad=new RegExp(`^rgb\\(${ar},${ar},${ar}\\)$`),id=new RegExp(`^rgb\\(${sn},${sn},${sn}\\)$`),sd=new RegExp(`^rgba\\(${ar},${ar},${ar},${Er}\\)$`),od=new RegExp(`^rgba\\(${sn},${sn},${sn},${Er}\\)$`),ld=new RegExp(`^hsl\\(${Er},${sn},${sn}\\)$`),cd=new RegExp(`^hsla\\(${Er},${sn},${sn},${Er}\\)$`),Lo={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};nr(An,Ve,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:jo,formatHex:jo,formatHex8:ud,formatHsl:fd,formatRgb:Po,toString:Po});function jo(){return this.rgb().formatHex()}function ud(){return this.rgb().formatHex8()}function fd(){return Fo(this).formatHsl()}function Po(){return this.rgb().formatRgb()}function Ve(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=rd.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Eo(e):n===3?new Te(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Aa(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Aa(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=ad.exec(t))?new Te(e[1],e[2],e[3],1):(e=id.exec(t))?new Te(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=sd.exec(t))?Aa(e[1],e[2],e[3],e[4]):(e=od.exec(t))?Aa(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=ld.exec(t))?Io(e[1],e[2]/100,e[3]/100,1):(e=cd.exec(t))?Io(e[1],e[2]/100,e[3]/100,e[4]):Lo.hasOwnProperty(t)?Eo(Lo[t]):t==="transparent"?new Te(NaN,NaN,NaN,0):null}function Eo(t){return new Te(t>>16&255,t>>8&255,t&255,1)}function Aa(t,e,n,r){return r<=0&&(t=e=n=NaN),new Te(t,e,n,r)}function ji(t){return t instanceof An||(t=Ve(t)),t?(t=t.rgb(),new Te(t.r,t.g,t.b,t.opacity)):new Te}function Sa(t,e,n,r){return arguments.length===1?ji(t):new Te(t,e,n,r??1)}function Te(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}nr(Te,Sa,Pr(An,{brighter(t){return t=t==null?rr:Math.pow(rr,t),new Te(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?jn:Math.pow(jn,t),new Te(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Te(Pn(this.r),Pn(this.g),Pn(this.b),Ma(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:Ro,formatHex:Ro,formatHex8:hd,formatRgb:zo,toString:zo}));function Ro(){return`#${En(this.r)}${En(this.g)}${En(this.b)}`}function hd(){return`#${En(this.r)}${En(this.g)}${En(this.b)}${En((isNaN(this.opacity)?1:this.opacity)*255)}`}function zo(){const t=Ma(this.opacity);return`${t===1?"rgb(":"rgba("}${Pn(this.r)}, ${Pn(this.g)}, ${Pn(this.b)}${t===1?")":`, ${t})`}`}function Ma(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Pn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function En(t){return t=Pn(t),(t<16?"0":"")+t.toString(16)}function Io(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new tn(t,e,n,r)}function Fo(t){if(t instanceof tn)return new tn(t.h,t.s,t.l,t.opacity);if(t instanceof An||(t=Ve(t)),!t)return new tn;if(t instanceof tn)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,a=Math.min(e,n,r),i=Math.max(e,n,r),s=NaN,o=i-a,l=(i+a)/2;return o?(e===i?s=(n-r)/o+(n<r)*6:n===i?s=(r-e)/o+2:s=(e-n)/o+4,o/=l<.5?i+a:2-i-a,s*=60):o=l>0&&l<1?0:s,new tn(s,o,l,t.opacity)}function dd(t,e,n,r){return arguments.length===1?Fo(t):new tn(t,e,n,r??1)}function tn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}nr(tn,dd,Pr(An,{brighter(t){return t=t==null?rr:Math.pow(rr,t),new tn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?jn:Math.pow(jn,t),new tn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,a=2*n-r;return new Te(Pi(t>=240?t-240:t+120,a,r),Pi(t,a,r),Pi(t<120?t+240:t-120,a,r),this.opacity)},clamp(){return new tn(Ho(this.h),Na(this.s),Na(this.l),Ma(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=Ma(this.opacity);return`${t===1?"hsl(":"hsla("}${Ho(this.h)}, ${Na(this.s)*100}%, ${Na(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Ho(t){return t=(t||0)%360,t<0?t+360:t}function Na(t){return Math.max(0,Math.min(1,t||0))}function Pi(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Wo=Math.PI/180,Oo=180/Math.PI,Ta=18,Bo=.96422,Yo=1,Uo=.82521,Vo=4/29,ir=6/29,Xo=3*ir*ir,pd=ir*ir*ir;function Ko(t){if(t instanceof on)return new on(t.l,t.a,t.b,t.opacity);if(t instanceof gn)return Go(t);t instanceof Te||(t=ji(t));var e=Ii(t.r),n=Ii(t.g),r=Ii(t.b),a=Ei((.2225045*e+.7168786*n+.0606169*r)/Yo),i,s;return e===n&&n===r?i=s=a:(i=Ei((.4360747*e+.3850649*n+.1430804*r)/Bo),s=Ei((.0139322*e+.0971045*n+.7141733*r)/Uo)),new on(116*a-16,500*(i-a),200*(a-s),t.opacity)}function gd(t,e,n,r){return arguments.length===1?Ko(t):new on(t,e,n,r??1)}function on(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}nr(on,gd,Pr(An,{brighter(t){return new on(this.l+Ta*(t??1),this.a,this.b,this.opacity)},darker(t){return new on(this.l-Ta*(t??1),this.a,this.b,this.opacity)},rgb(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return e=Bo*Ri(e),t=Yo*Ri(t),n=Uo*Ri(n),new Te(zi(3.1338561*e-1.6168667*t-.4906146*n),zi(-.9787684*e+1.9161415*t+.033454*n),zi(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}}));function Ei(t){return t>pd?Math.pow(t,1/3):t/Xo+Vo}function Ri(t){return t>ir?t*t*t:Xo*(t-Vo)}function zi(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ii(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function yd(t){if(t instanceof gn)return new gn(t.h,t.c,t.l,t.opacity);if(t instanceof on||(t=Ko(t)),t.a===0&&t.b===0)return new gn(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*Oo;return new gn(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function Fi(t,e,n,r){return arguments.length===1?yd(t):new gn(t,e,n,r??1)}function gn(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function Go(t){if(isNaN(t.h))return new on(t.l,0,0,t.opacity);var e=t.h*Wo;return new on(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}nr(gn,Fi,Pr(An,{brighter(t){return new gn(this.h,this.c,this.l+Ta*(t??1),this.opacity)},darker(t){return new gn(this.h,this.c,this.l-Ta*(t??1),this.opacity)},rgb(){return Go(this).rgb()}}));var Zo=-.14861,Hi=1.78277,Wi=-.29227,Da=-.90649,Rr=1.97294,Jo=Rr*Da,Qo=Rr*Hi,qo=Hi*Wi-Da*Zo;function xd(t){if(t instanceof Rn)return new Rn(t.h,t.s,t.l,t.opacity);t instanceof Te||(t=ji(t));var e=t.r/255,n=t.g/255,r=t.b/255,a=(qo*r+Jo*e-Qo*n)/(qo+Jo-Qo),i=r-a,s=(Rr*(n-a)-Wi*i)/Da,o=Math.sqrt(s*s+i*i)/(Rr*a*(1-a)),l=o?Math.atan2(s,i)*Oo-120:NaN;return new Rn(l<0?l+360:l,o,a,t.opacity)}function Sn(t,e,n,r){return arguments.length===1?xd(t):new Rn(t,e,n,r??1)}function Rn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}nr(Rn,Sn,Pr(An,{brighter(t){return t=t==null?rr:Math.pow(rr,t),new Rn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?jn:Math.pow(jn,t),new Rn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*Wo,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),a=Math.sin(t);return new Te(255*(e+n*(Zo*r+Hi*a)),255*(e+n*(Wi*r+Da*a)),255*(e+n*(Rr*r)),this.opacity)}}));const $a=t=>()=>t;function tl(t,e){return function(n){return t+n*e}}function md(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function el(t,e){var n=e-t;return n?tl(t,n>180||n<-180?n-360*Math.round(n/360):n):$a(isNaN(t)?e:t)}function vd(t){return(t=+t)==1?yn:function(e,n){return n-e?md(e,n,t):$a(isNaN(e)?n:e)}}function yn(t,e){var n=e-t;return n?tl(t,n):$a(isNaN(t)?e:t)}const Ca=(function t(e){var n=vd(e);function r(a,i){var s=n((a=Sa(a)).r,(i=Sa(i)).r),o=n(a.g,i.g),l=n(a.b,i.b),c=yn(a.opacity,i.opacity);return function(u){return a.r=s(u),a.g=o(u),a.b=l(u),a.opacity=c(u),a+""}}return r.gamma=t,r})(1);function bd(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),a;return function(i){for(a=0;a<n;++a)r[a]=t[a]*(1-i)+e[a]*i;return r}}function wd(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function _d(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,a=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)a[s]=Ae(t[s],e[s]);for(;s<n;++s)i[s]=e[s];return function(o){for(s=0;s<r;++s)i[s]=a[s](o);return i}}function kd(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function en(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Ad(t,e){var n={},r={},a;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(a in e)a in t?n[a]=Ae(t[a],e[a]):r[a]=e[a];return function(i){for(a in n)r[a]=n[a](i);return r}}var Oi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Bi=new RegExp(Oi.source,"g");function Sd(t){return function(){return t}}function Md(t){return function(e){return t(e)+""}}function nl(t,e){var n=Oi.lastIndex=Bi.lastIndex=0,r,a,i,s=-1,o=[],l=[];for(t=t+"",e=e+"";(r=Oi.exec(t))&&(a=Bi.exec(e));)(i=a.index)>n&&(i=e.slice(n,i),o[s]?o[s]+=i:o[++s]=i),(r=r[0])===(a=a[0])?o[s]?o[s]+=a:o[++s]=a:(o[++s]=null,l.push({i:s,x:en(r,a)})),n=Bi.lastIndex;return n<e.length&&(i=e.slice(n),o[s]?o[s]+=i:o[++s]=i),o.length<2?l[0]?Md(l[0].x):Sd(e):(e=l.length,function(c){for(var u=0,h;u<e;++u)o[(h=l[u]).i]=h.x(c);return o.join("")})}function Ae(t,e){var n=typeof e,r;return e==null||n==="boolean"?$a(e):(n==="number"?en:n==="string"?(r=Ve(e))?(e=r,Ca):nl:e instanceof Ve?Ca:e instanceof Date?kd:wd(e)?bd:Array.isArray(e)?_d:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Ad:en)(t,e)}function Nd(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var rl=180/Math.PI,Yi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function al(t,e,n,r,a,i){var s,o,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),t*r<e*n&&(t=-t,e=-e,l=-l,s=-s),{translateX:a,translateY:i,rotate:Math.atan2(e,t)*rl,skewX:Math.atan(l)*rl,scaleX:s,scaleY:o}}var La;function Td(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Yi:al(e.a,e.b,e.c,e.d,e.e,e.f)}function Dd(t){return t==null||(La||(La=document.createElementNS("http://www.w3.org/2000/svg","g")),La.setAttribute("transform",t),!(t=La.transform.baseVal.consolidate()))?Yi:(t=t.matrix,al(t.a,t.b,t.c,t.d,t.e,t.f))}function il(t,e,n,r){function a(c){return c.length?c.pop()+" ":""}function i(c,u,h,f,g,v){if(c!==h||u!==f){var b=g.push("translate(",null,e,null,n);v.push({i:b-4,x:en(c,h)},{i:b-2,x:en(u,f)})}else(h||f)&&g.push("translate("+h+e+f+n)}function s(c,u,h,f){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),f.push({i:h.push(a(h)+"rotate(",null,r)-2,x:en(c,u)})):u&&h.push(a(h)+"rotate("+u+r)}function o(c,u,h,f){c!==u?f.push({i:h.push(a(h)+"skewX(",null,r)-2,x:en(c,u)}):u&&h.push(a(h)+"skewX("+u+r)}function l(c,u,h,f,g,v){if(c!==h||u!==f){var b=g.push(a(g)+"scale(",null,",",null,")");v.push({i:b-4,x:en(c,h)},{i:b-2,x:en(u,f)})}else(h!==1||f!==1)&&g.push(a(g)+"scale("+h+","+f+")")}return function(c,u){var h=[],f=[];return c=t(c),u=t(u),i(c.translateX,c.translateY,u.translateX,u.translateY,h,f),s(c.rotate,u.rotate,h,f),o(c.skewX,u.skewX,h,f),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,h,f),c=u=null,function(g){for(var v=-1,b=f.length,d;++v<b;)h[(d=f[v]).i]=d.x(g);return h.join("")}}}var $d=il(Td,"px, ","px)","deg)"),Cd=il(Dd,", ",")",")");function Ld(t){return function(e,n){var r=t((e=Fi(e)).h,(n=Fi(n)).h),a=yn(e.c,n.c),i=yn(e.l,n.l),s=yn(e.opacity,n.opacity);return function(o){return e.h=r(o),e.c=a(o),e.l=i(o),e.opacity=s(o),e+""}}}const jd=Ld(el);function sl(t){return(function e(n){n=+n;function r(a,i){var s=t((a=Sn(a)).h,(i=Sn(i)).h),o=yn(a.s,i.s),l=yn(a.l,i.l),c=yn(a.opacity,i.opacity);return function(u){return a.h=s(u),a.s=o(u),a.l=l(Math.pow(u,n)),a.opacity=c(u),a+""}}return r.gamma=e,r})(1)}sl(el);var ol=sl(yn);function ll(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t(r/(e-1));return n}var sr=0,zr=0,Ir=0,cl=1e3,ja,Fr,Pa=0,zn=0,Ea=0,Hr=typeof performance=="object"&&performance.now?performance:Date,ul=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Ui(){return zn||(ul(Pd),zn=Hr.now()+Ea)}function Pd(){zn=0}function Ra(){this._call=this._time=this._next=null}Ra.prototype=Vi.prototype={constructor:Ra,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Ui():+n)+(e==null?0:+e),!this._next&&Fr!==this&&(Fr?Fr._next=this:ja=this,Fr=this),this._call=t,this._time=n,Xi()},stop:function(){this._call&&(this._call=null,this._time=1/0,Xi())}};function Vi(t,e,n){var r=new Ra;return r.restart(t,e,n),r}function Ed(){Ui(),++sr;for(var t=ja,e;t;)(e=zn-t._time)>=0&&t._call.call(void 0,e),t=t._next;--sr}function fl(){zn=(Pa=Hr.now())+Ea,sr=zr=0;try{Ed()}finally{sr=0,zd(),zn=0}}function Rd(){var t=Hr.now(),e=t-Pa;e>cl&&(Ea-=e,Pa=t)}function zd(){for(var t,e=ja,n,r=1/0;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:ja=n);Fr=t,Xi(r)}function Xi(t){if(!sr){zr&&(zr=clearTimeout(zr));var e=t-zn;e>24?(t<1/0&&(zr=setTimeout(fl,t-Hr.now()-Ea)),Ir&&(Ir=clearInterval(Ir))):(Ir||(Pa=Hr.now(),Ir=setInterval(Rd,cl)),sr=1,ul(fl))}}function hl(t,e,n){var r=new Ra;return e=e==null?0:+e,r.restart(a=>{r.stop(),t(a+e)},e,n),r}var Id=Cr("start","end","cancel","interrupt"),Fd=[],dl=0,pl=1,Ki=2,za=3,gl=4,Gi=5,Ia=6;function Fa(t,e,n,r,a,i){var s=t.__transition;if(!s)t.__transition={};else if(n in s)return;Hd(t,n,{name:e,index:r,group:a,on:Id,tween:Fd,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:dl})}function Zi(t,e){var n=nn(t,e);if(n.state>dl)throw new Error("too late; already scheduled");return n}function ln(t,e){var n=nn(t,e);if(n.state>za)throw new Error("too late; already running");return n}function nn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Hd(t,e,n){var r=t.__transition,a;r[e]=n,n.timer=Vi(i,0,n.time);function i(c){n.state=pl,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,h,f,g;if(n.state!==pl)return l();for(u in r)if(g=r[u],g.name===n.name){if(g.state===za)return hl(s);g.state===gl?(g.state=Ia,g.timer.stop(),g.on.call("interrupt",t,t.__data__,g.index,g.group),delete r[u]):+u<e&&(g.state=Ia,g.timer.stop(),g.on.call("cancel",t,t.__data__,g.index,g.group),delete r[u])}if(hl(function(){n.state===za&&(n.state=gl,n.timer.restart(o,n.delay,n.time),o(c))}),n.state=Ki,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Ki){for(n.state=za,a=new Array(f=n.tween.length),u=0,h=-1;u<f;++u)(g=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(a[++h]=g);a.length=h+1}}function o(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Gi,1),h=-1,f=a.length;++h<f;)a[h].call(t,u);n.state===Gi&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=Ia,n.timer.stop(),delete r[e];for(var c in r)return;delete t.__transition}}function Ji(t,e){var n=t.__transition,r,a,i=!0,s;if(n){e=e==null?null:e+"";for(s in n){if((r=n[s]).name!==e){i=!1;continue}a=r.state>Ki&&r.state<Gi,r.state=Ia,r.timer.stop(),r.on.call(a?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[s]}i&&delete t.__transition}}function Wd(t){return this.each(function(){Ji(this,t)})}function Od(t,e){var n,r;return function(){var a=ln(this,t),i=a.tween;if(i!==n){r=n=i;for(var s=0,o=r.length;s<o;++s)if(r[s].name===e){r=r.slice(),r.splice(s,1);break}}a.tween=r}}function Bd(t,e,n){var r,a;if(typeof n!="function")throw new Error;return function(){var i=ln(this,t),s=i.tween;if(s!==r){a=(r=s).slice();for(var o={name:e,value:n},l=0,c=a.length;l<c;++l)if(a[l].name===e){a[l]=o;break}l===c&&a.push(o)}i.tween=a}}function Yd(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=nn(this.node(),n).tween,a=0,i=r.length,s;a<i;++a)if((s=r[a]).name===t)return s.value;return null}return this.each((e==null?Od:Bd)(n,t,e))}function Qi(t,e,n){var r=t._id;return t.each(function(){var a=ln(this,r);(a.value||(a.value={}))[e]=n.apply(this,arguments)}),function(a){return nn(a,r).value[e]}}function yl(t,e){var n;return(typeof e=="number"?en:e instanceof Ve?Ca:(n=Ve(e))?(e=n,Ca):nl)(t,e)}function Ud(t){return function(){this.removeAttribute(t)}}function Vd(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Xd(t,e,n){var r,a=n+"",i;return function(){var s=this.getAttribute(t);return s===a?null:s===r?i:i=e(r=s,n)}}function Kd(t,e,n){var r,a=n+"",i;return function(){var s=this.getAttributeNS(t.space,t.local);return s===a?null:s===r?i:i=e(r=s,n)}}function Gd(t,e,n){var r,a,i;return function(){var s,o=n(this),l;return o==null?void this.removeAttribute(t):(s=this.getAttribute(t),l=o+"",s===l?null:s===r&&l===a?i:(a=l,i=e(r=s,o)))}}function Zd(t,e,n){var r,a,i;return function(){var s,o=n(this),l;return o==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),l=o+"",s===l?null:s===r&&l===a?i:(a=l,i=e(r=s,o)))}}function Jd(t,e){var n=wa(t),r=n==="transform"?Cd:yl;return this.attrTween(t,typeof e=="function"?(n.local?Zd:Gd)(n,r,Qi(this,"attr."+t,e)):e==null?(n.local?Vd:Ud)(n):(n.local?Kd:Xd)(n,r,e))}function Qd(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function qd(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function tp(t,e){var n,r;function a(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&qd(t,i)),n}return a._value=e,a}function ep(t,e){var n,r;function a(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Qd(t,i)),n}return a._value=e,a}function np(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=wa(t);return this.tween(n,(r.local?tp:ep)(r,e))}function rp(t,e){return function(){Zi(this,t).delay=+e.apply(this,arguments)}}function ap(t,e){return e=+e,function(){Zi(this,t).delay=e}}function ip(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?rp:ap)(e,t)):nn(this.node(),e).delay}function sp(t,e){return function(){ln(this,t).duration=+e.apply(this,arguments)}}function op(t,e){return e=+e,function(){ln(this,t).duration=e}}function lp(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?sp:op)(e,t)):nn(this.node(),e).duration}function cp(t,e){if(typeof e!="function")throw new Error;return function(){ln(this,t).ease=e}}function up(t){var e=this._id;return arguments.length?this.each(cp(e,t)):nn(this.node(),e).ease}function fp(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;ln(this,t).ease=n}}function hp(t){if(typeof t!="function")throw new Error;return this.each(fp(this._id,t))}function dp(t){typeof t!="function"&&(t=bo(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],s=i.length,o=r[a]=[],l,c=0;c<s;++c)(l=i[c])&&t.call(l,l.__data__,c,i)&&o.push(l);return new xn(r,this._parents,this._name,this._id)}function pp(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,a=n.length,i=Math.min(r,a),s=new Array(r),o=0;o<i;++o)for(var l=e[o],c=n[o],u=l.length,h=s[o]=new Array(u),f,g=0;g<u;++g)(f=l[g]||c[g])&&(h[g]=f);for(;o<r;++o)s[o]=e[o];return new xn(s,this._parents,this._name,this._id)}function gp(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function yp(t,e,n){var r,a,i=gp(e)?Zi:ln;return function(){var s=i(this,t),o=s.on;o!==r&&(a=(r=o).copy()).on(e,n),s.on=a}}function xp(t,e){var n=this._id;return arguments.length<2?nn(this.node(),n).on.on(t):this.each(yp(n,t,e))}function mp(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function vp(){return this.on("end.remove",mp(this._id))}function bp(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Di(t));for(var r=this._groups,a=r.length,i=new Array(a),s=0;s<a;++s)for(var o=r[s],l=o.length,c=i[s]=new Array(l),u,h,f=0;f<l;++f)(u=o[f])&&(h=t.call(u,u.__data__,f,o))&&("__data__"in u&&(h.__data__=u.__data__),c[f]=h,Fa(c[f],e,n,f,c,nn(u,n)));return new xn(i,this._parents,e,n)}function wp(t){var e=this._name,n=this._id;typeof t!="function"&&(t=vo(t));for(var r=this._groups,a=r.length,i=[],s=[],o=0;o<a;++o)for(var l=r[o],c=l.length,u,h=0;h<c;++h)if(u=l[h]){for(var f=t.call(u,u.__data__,h,l),g,v=nn(u,n),b=0,d=f.length;b<d;++b)(g=f[b])&&Fa(g,e,n,b,f,v);i.push(f),s.push(u)}return new xn(i,s,e,n)}var _p=Lr.prototype.constructor;function kp(){return new _p(this._groups,this._parents)}function Ap(t,e){var n,r,a;return function(){var i=qn(this,t),s=(this.style.removeProperty(t),qn(this,t));return i===s?null:i===n&&s===r?a:a=e(n=i,r=s)}}function xl(t){return function(){this.style.removeProperty(t)}}function Sp(t,e,n){var r,a=n+"",i;return function(){var s=qn(this,t);return s===a?null:s===r?i:i=e(r=s,n)}}function Mp(t,e,n){var r,a,i;return function(){var s=qn(this,t),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(t),qn(this,t))),s===l?null:s===r&&l===a?i:(a=l,i=e(r=s,o))}}function Np(t,e){var n,r,a,i="style."+e,s="end."+i,o;return function(){var l=ln(this,t),c=l.on,u=l.value[i]==null?o||(o=xl(e)):void 0;(c!==n||a!==u)&&(r=(n=c).copy()).on(s,a=u),l.on=r}}function Tp(t,e,n){var r=(t+="")=="transform"?$d:yl;return e==null?this.styleTween(t,Ap(t,r)).on("end.style."+t,xl(t)):typeof e=="function"?this.styleTween(t,Mp(t,r,Qi(this,"style."+t,e))).each(Np(this._id,t)):this.styleTween(t,Sp(t,r,e),n).on("end.style."+t,null)}function Dp(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function $p(t,e,n){var r,a;function i(){var s=e.apply(this,arguments);return s!==a&&(r=(a=s)&&Dp(t,s,n)),r}return i._value=e,i}function Cp(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,$p(t,e,n??""))}function Lp(t){return function(){this.textContent=t}}function jp(t){return function(){var e=t(this);this.textContent=e??""}}function Pp(t){return this.tween("text",typeof t=="function"?jp(Qi(this,"text",t)):Lp(t==null?"":t+""))}function Ep(t){return function(e){this.textContent=t.call(this,e)}}function Rp(t){var e,n;function r(){var a=t.apply(this,arguments);return a!==n&&(e=(n=a)&&Ep(a)),e}return r._value=t,r}function zp(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,Rp(t))}function Ip(){for(var t=this._name,e=this._id,n=ml(),r=this._groups,a=r.length,i=0;i<a;++i)for(var s=r[i],o=s.length,l,c=0;c<o;++c)if(l=s[c]){var u=nn(l,e);Fa(l,t,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new xn(r,this._parents,t,n)}function Fp(){var t,e,n=this,r=n._id,a=n.size();return new Promise(function(i,s){var o={value:s},l={value:function(){--a===0&&i()}};n.each(function(){var c=ln(this,r),u=c.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(o),e._.interrupt.push(o),e._.end.push(l)),c.on=e}),a===0&&i()})}var Hp=0;function xn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function ml(){return++Hp}var mn=Lr.prototype;xn.prototype={constructor:xn,select:bp,selectAll:wp,selectChild:mn.selectChild,selectChildren:mn.selectChildren,filter:dp,merge:pp,selection:kp,transition:Ip,call:mn.call,nodes:mn.nodes,node:mn.node,size:mn.size,empty:mn.empty,each:mn.each,on:xp,attr:Jd,attrTween:np,style:Tp,styleTween:Cp,text:Pp,textTween:zp,remove:vp,tween:Yd,delay:ip,duration:lp,ease:up,easeVarying:hp,end:Fp,[Symbol.iterator]:mn[Symbol.iterator]};function Wp(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Op={time:null,delay:0,duration:250,ease:Wp};function Bp(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function Yp(t){var e,n;t instanceof xn?(e=t._id,t=t._name):(e=ml(),(n=Op).time=Ui(),t=t==null?null:t+"");for(var r=this._groups,a=r.length,i=0;i<a;++i)for(var s=r[i],o=s.length,l,c=0;c<o;++c)(l=s[c])&&Fa(l,t,e,c,s,n||Bp(l,e));return new xn(r,this._parents,t,e)}Lr.prototype.interrupt=Wd,Lr.prototype.transition=Yp;const qi=t=>()=>t;function Up(t,{sourceEvent:e,target:n,selection:r,mode:a,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:a,enumerable:!0,configurable:!0},_:{value:i}})}function Vp(t){t.stopImmediatePropagation()}function ts(t){t.preventDefault(),t.stopImmediatePropagation()}var vl={name:"drag"},es={name:"space"},or={name:"handle"},lr={name:"center"};const{abs:bl,max:$e,min:Ce}=Math;function wl(t){return[+t[0],+t[1]]}function _l(t){return[wl(t[0]),wl(t[1])]}var Ha={name:"x",handles:["w","e"].map(rs),input:function(t,e){return t==null?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},ns={},vn={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"},kl={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},Al={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},Xp={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},Kp={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function rs(t){return{type:t}}function Gp(t){return!t.ctrlKey&&!t.button}function Zp(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function Jp(){return navigator.maxTouchPoints||"ontouchstart"in this}function as(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function Qp(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}function Sl(){return qp(Ha)}function qp(t){var e=Zp,n=Gp,r=Jp,a=!0,i=Cr("start","brush","end"),s=6,o;function l(d){var x=d.property("__brush",b).selectAll(".overlay").data([rs("overlay")]);x.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",vn.overlay).merge(x).each(function(){var w=as(this).extent;qt(this).attr("x",w[0][0]).attr("y",w[0][1]).attr("width",w[1][0]-w[0][0]).attr("height",w[1][1]-w[0][1])}),d.selectAll(".selection").data([rs("selection")]).enter().append("rect").attr("class","selection").attr("cursor",vn.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var S=d.selectAll(".handle").data(t.handles,function(w){return w.type});S.exit().remove(),S.enter().append("rect").attr("class",function(w){return"handle handle--"+w.type}).attr("cursor",function(w){return vn[w.type]}),d.each(c).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",f).filter(r).on("touchstart.brush",f).on("touchmove.brush",g).on("touchend.brush touchcancel.brush",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}l.move=function(d,x,S){d.tween?d.on("start.brush",function(w){u(this,arguments).beforestart().start(w)}).on("interrupt.brush end.brush",function(w){u(this,arguments).end(w)}).tween("brush",function(){var w=this,y=w.__brush,T=u(w,arguments),p=y.selection,k=t.input(typeof x=="function"?x.apply(this,arguments):x,y.extent),_=Ae(p,k);function E(R){y.selection=R===1&&k===null?null:_(R),c.call(w),T.brush()}return p!==null&&k!==null?E:E(1)}):d.each(function(){var w=this,y=arguments,T=w.__brush,p=t.input(typeof x=="function"?x.apply(w,y):x,T.extent),k=u(w,y).beforestart();Ji(w),T.selection=p===null?null:p,c.call(w),k.start(S).brush(S).end(S)})},l.clear=function(d,x){l.move(d,null,x)};function c(){var d=qt(this),x=as(this).selection;x?(d.selectAll(".selection").style("display",null).attr("x",x[0][0]).attr("y",x[0][1]).attr("width",x[1][0]-x[0][0]).attr("height",x[1][1]-x[0][1]),d.selectAll(".handle").style("display",null).attr("x",function(S){return S.type[S.type.length-1]==="e"?x[1][0]-s/2:x[0][0]-s/2}).attr("y",function(S){return S.type[0]==="s"?x[1][1]-s/2:x[0][1]-s/2}).attr("width",function(S){return S.type==="n"||S.type==="s"?x[1][0]-x[0][0]+s:s}).attr("height",function(S){return S.type==="e"||S.type==="w"?x[1][1]-x[0][1]+s:s})):d.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(d,x,S){var w=d.__brush.emitter;return w&&(!S||!w.clean)?w:new h(d,x,S)}function h(d,x,S){this.that=d,this.args=x,this.state=d.__brush,this.active=0,this.clean=S}h.prototype={beforestart:function(){return++this.active===1&&(this.state.emitter=this,this.starting=!0),this},start:function(d,x){return this.starting?(this.starting=!1,this.emit("start",d,x)):this.emit("brush",d),this},brush:function(d,x){return this.emit("brush",d,x),this},end:function(d,x){return--this.active===0&&(delete this.state.emitter,this.emit("end",d,x)),this},emit:function(d,x,S){var w=qt(this.that).datum();i.call(d,this.that,new Up(d,{sourceEvent:x,target:l,selection:t.output(this.state.selection),mode:S,dispatch:i}),w)}};function f(d){if(o&&!d.touches||!n.apply(this,arguments))return;var x=this,S=d.target.__data__.type,w=(a&&d.metaKey?S="overlay":S)==="selection"?vl:a&&d.altKey?lr:or,y=t===ns?null:Xp[S],T=t===Ha?null:Kp[S],p=as(x),k=p.extent,_=p.selection,E=k[0][0],R,z,I=k[0][1],N,U,M=k[1][0],Y,C,F=k[1][1],H,V,et=0,$=0,dt,wt=y&&T&&a&&d.shiftKey,pt,_t,G=Array.from(d.touches||[d],st=>{const it=st.identifier;return st=tr(st,x),st.point0=st.slice(),st.identifier=it,st});Ji(x);var ot=u(x,arguments,!0).beforestart();if(S==="overlay"){_&&(dt=!0);const st=[G[0],G[1]||G[0]];p.selection=_=[[R=t===ns?E:Ce(st[0][0],st[1][0]),N=t===Ha?I:Ce(st[0][1],st[1][1])],[Y=t===ns?M:$e(st[0][0],st[1][0]),H=t===Ha?F:$e(st[0][1],st[1][1])]],G.length>1&&tt(d)}else R=_[0][0],N=_[0][1],Y=_[1][0],H=_[1][1];z=R,U=N,C=Y,V=H;var O=qt(x).attr("pointer-events","none"),Q=O.selectAll(".overlay").attr("cursor",vn[S]);if(d.touches)ot.moved=D,ot.ended=L;else{var X=qt(d.view).on("mousemove.brush",D,!0).on("mouseup.brush",L,!0);a&&X.on("keydown.brush",Z,!0).on("keyup.brush",ft,!0),$o(d.view)}c.call(x),ot.start(d,w.name);function D(st){for(const it of st.changedTouches||[st])for(const A of G)A.identifier===it.identifier&&(A.cur=tr(it,x));if(wt&&!pt&&!_t&&G.length===1){const it=G[0];bl(it.cur[0]-it[0])>bl(it.cur[1]-it[1])?_t=!0:pt=!0}for(const it of G)it.cur&&(it[0]=it.cur[0],it[1]=it.cur[1]);dt=!0,ts(st),tt(st)}function tt(st){const it=G[0],A=it.point0;var j;switch(et=it[0]-A[0],$=it[1]-A[1],w){case es:case vl:{y&&(et=$e(E-R,Ce(M-Y,et)),z=R+et,C=Y+et),T&&($=$e(I-N,Ce(F-H,$)),U=N+$,V=H+$);break}case or:{G[1]?(y&&(z=$e(E,Ce(M,G[0][0])),C=$e(E,Ce(M,G[1][0])),y=1),T&&(U=$e(I,Ce(F,G[0][1])),V=$e(I,Ce(F,G[1][1])),T=1)):(y<0?(et=$e(E-R,Ce(M-R,et)),z=R+et,C=Y):y>0&&(et=$e(E-Y,Ce(M-Y,et)),z=R,C=Y+et),T<0?($=$e(I-N,Ce(F-N,$)),U=N+$,V=H):T>0&&($=$e(I-H,Ce(F-H,$)),U=N,V=H+$));break}case lr:{y&&(z=$e(E,Ce(M,R-et*y)),C=$e(E,Ce(M,Y+et*y))),T&&(U=$e(I,Ce(F,N-$*T)),V=$e(I,Ce(F,H+$*T)));break}}C<z&&(y*=-1,j=R,R=Y,Y=j,j=z,z=C,C=j,S in kl&&Q.attr("cursor",vn[S=kl[S]])),V<U&&(T*=-1,j=N,N=H,H=j,j=U,U=V,V=j,S in Al&&Q.attr("cursor",vn[S=Al[S]])),p.selection&&(_=p.selection),pt&&(z=_[0][0],C=_[1][0]),_t&&(U=_[0][1],V=_[1][1]),(_[0][0]!==z||_[0][1]!==U||_[1][0]!==C||_[1][1]!==V)&&(p.selection=[[z,U],[C,V]],c.call(x),ot.brush(st,w.name))}function L(st){if(Vp(st),st.touches){if(st.touches.length)return;o&&clearTimeout(o),o=setTimeout(function(){o=null},500)}else Co(st.view,dt),X.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);O.attr("pointer-events","all"),Q.attr("cursor",vn.overlay),p.selection&&(_=p.selection),Qp(_)&&(p.selection=null,c.call(x)),ot.end(st,w.name)}function Z(st){switch(st.keyCode){case 16:{wt=y&&T;break}case 18:{w===or&&(y&&(Y=C-et*y,R=z+et*y),T&&(H=V-$*T,N=U+$*T),w=lr,tt(st));break}case 32:{(w===or||w===lr)&&(y<0?Y=C-et:y>0&&(R=z-et),T<0?H=V-$:T>0&&(N=U-$),w=es,Q.attr("cursor",vn.selection),tt(st));break}default:return}ts(st)}function ft(st){switch(st.keyCode){case 16:{wt&&(pt=_t=wt=!1,tt(st));break}case 18:{w===lr&&(y<0?Y=C:y>0&&(R=z),T<0?H=V:T>0&&(N=U),w=or,tt(st));break}case 32:{w===es&&(st.altKey?(y&&(Y=C-et*y,R=z+et*y),T&&(H=V-$*T,N=U+$*T),w=lr):(y<0?Y=C:y>0&&(R=z),T<0?H=V:T>0&&(N=U),w=or),Q.attr("cursor",vn[S]),tt(st));break}default:return}ts(st)}}function g(d){u(this,arguments).moved(d)}function v(d){u(this,arguments).ended(d)}function b(){var d=this.__brush||{selection:null};return d.extent=_l(e.apply(this,arguments)),d.dim=t,d}return l.extent=function(d){return arguments.length?(e=typeof d=="function"?d:qi(_l(d)),l):e},l.filter=function(d){return arguments.length?(n=typeof d=="function"?d:qi(!!d),l):n},l.touchable=function(d){return arguments.length?(r=typeof d=="function"?d:qi(!!d),l):r},l.handleSize=function(d){return arguments.length?(s=+d,l):s},l.keyModifiers=function(d){return arguments.length?(a=!!d,l):a},l.on=function(){var d=i.on.apply(i,arguments);return d===i?l:d},l}var Ml=Math.abs,is=Math.cos,ss=Math.sin,Nl=Math.PI,Wa=Nl/2,Tl=Nl*2,Dl=Math.max,os=1e-12;function $l(t,e){return Array.from({length:e-t},(n,r)=>t+r)}function t0(t){return function(e,n){return t(e.source.value+e.target.value,n.source.value+n.target.value)}}function e0(){return n0(!1)}function n0(t,e){var n=0,r=null,a=null,i=null;function s(o){var l=o.length,c=new Array(l),u=$l(0,l),h=new Array(l*l),f=new Array(l),g=0,v;o=Float64Array.from({length:l*l},(b,d)=>o[d/l|0][d%l]);for(let b=0;b<l;++b){let d=0;for(let x=0;x<l;++x)d+=o[b*l+x]+t*o[x*l+b];g+=c[b]=d}g=Dl(0,Tl-n*l)/g,v=g?n:Tl/l;{let b=0;r&&u.sort((d,x)=>r(c[d],c[x]));for(const d of u){const x=b;{const S=$l(0,l).filter(w=>o[d*l+w]||o[w*l+d]);a&&S.sort((w,y)=>a(o[d*l+w],o[d*l+y]));for(const w of S){let y;if(d<w?(y=h[d*l+w]||(h[d*l+w]={source:null,target:null}),y.source={index:d,startAngle:b,endAngle:b+=o[d*l+w]*g,value:o[d*l+w]}):(y=h[w*l+d]||(h[w*l+d]={source:null,target:null}),y.target={index:d,startAngle:b,endAngle:b+=o[d*l+w]*g,value:o[d*l+w]},d===w&&(y.source=y.target)),y.source&&y.target&&y.source.value<y.target.value){const T=y.source;y.source=y.target,y.target=T}}f[d]={index:d,startAngle:x,endAngle:b,value:c[d]}}b+=v}}return h=Object.values(h),h.groups=f,i?h.sort(i):h}return s.padAngle=function(o){return arguments.length?(n=Dl(0,o),s):n},s.sortGroups=function(o){return arguments.length?(r=o,s):r},s.sortSubgroups=function(o){return arguments.length?(a=o,s):a},s.sortChords=function(o){return arguments.length?(o==null?i=null:(i=t0(o))._=o,s):i&&i._},s}const ls=Math.PI,cs=2*ls,In=1e-6,r0=cs-In;function Cl(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function a0(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Cl;const n=10**e;return function(r){this._+=r[0];for(let a=1,i=r.length;a<i;++a)this._+=Math.round(arguments[a]*n)/n+r[a]}}let us=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?Cl:a0(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,a){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+a}`}bezierCurveTo(e,n,r,a,i,s){this._append`C${+e},${+n},${+r},${+a},${this._x1=+i},${this._y1=+s}`}arcTo(e,n,r,a,i){if(e=+e,n=+n,r=+r,a=+a,i=+i,i<0)throw new Error(`negative radius: ${i}`);let s=this._x1,o=this._y1,l=r-e,c=a-n,u=s-e,h=o-n,f=u*u+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(f>In)if(!(Math.abs(h*l-c*u)>In)||!i)this._append`L${this._x1=e},${this._y1=n}`;else{let g=r-s,v=a-o,b=l*l+c*c,d=g*g+v*v,x=Math.sqrt(b),S=Math.sqrt(f),w=i*Math.tan((ls-Math.acos((b+f-d)/(2*x*S)))/2),y=w/S,T=w/x;Math.abs(y-1)>In&&this._append`L${e+y*u},${n+y*h}`,this._append`A${i},${i},0,0,${+(h*g>u*v)},${this._x1=e+T*l},${this._y1=n+T*c}`}}arc(e,n,r,a,i,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(a),l=r*Math.sin(a),c=e+o,u=n+l,h=1^s,f=s?a-i:i-a;this._x1===null?this._append`M${c},${u}`:(Math.abs(this._x1-c)>In||Math.abs(this._y1-u)>In)&&this._append`L${c},${u}`,r&&(f<0&&(f=f%cs+cs),f>r0?this._append`A${r},${r},0,1,${h},${e-o},${n-l}A${r},${r},0,1,${h},${this._x1=c},${this._y1=u}`:f>In&&this._append`A${r},${r},0,${+(f>=ls)},${h},${this._x1=e+r*Math.cos(i)},${this._y1=n+r*Math.sin(i)}`)}rect(e,n,r,a){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+a}h${-r}Z`}toString(){return this._}};function Ll(){return new us}Ll.prototype=us.prototype;var i0=Array.prototype.slice;function cr(t){return function(){return t}}function s0(t){return t.source}function o0(t){return t.target}function jl(t){return t.radius}function l0(t){return t.startAngle}function c0(t){return t.endAngle}function u0(){return 0}function f0(t){var e=s0,n=o0,r=jl,a=jl,i=l0,s=c0,o=u0,l=null;function c(){var u,h=e.apply(this,arguments),f=n.apply(this,arguments),g=o.apply(this,arguments)/2,v=i0.call(arguments),b=+r.apply(this,(v[0]=h,v)),d=i.apply(this,v)-Wa,x=s.apply(this,v)-Wa,S=+a.apply(this,(v[0]=f,v)),w=i.apply(this,v)-Wa,y=s.apply(this,v)-Wa;if(l||(l=u=Ll()),g>os&&(Ml(x-d)>g*2+os?x>d?(d+=g,x-=g):(d-=g,x+=g):d=x=(d+x)/2,Ml(y-w)>g*2+os?y>w?(w+=g,y-=g):(w-=g,y+=g):w=y=(w+y)/2),l.moveTo(b*is(d),b*ss(d)),l.arc(0,0,b,d,x),(d!==w||x!==y)&&(l.quadraticCurveTo(0,0,S*is(w),S*ss(w)),l.arc(0,0,S,w,y)),l.quadraticCurveTo(0,0,b*is(d),b*ss(d)),l.closePath(),u)return l=null,u+""||null}return c.radius=function(u){return arguments.length?(r=a=typeof u=="function"?u:cr(+u),c):r},c.sourceRadius=function(u){return arguments.length?(r=typeof u=="function"?u:cr(+u),c):r},c.targetRadius=function(u){return arguments.length?(a=typeof u=="function"?u:cr(+u),c):a},c.startAngle=function(u){return arguments.length?(i=typeof u=="function"?u:cr(+u),c):i},c.endAngle=function(u){return arguments.length?(s=typeof u=="function"?u:cr(+u),c):s},c.padAngle=function(u){return arguments.length?(o=typeof u=="function"?u:cr(+u),c):o},c.source=function(u){return arguments.length?(e=u,c):e},c.target=function(u){return arguments.length?(n=u,c):n},c.context=function(u){return arguments.length?(l=u??null,c):l},c}function h0(){return f0()}function fs(t,e){var n,r=1;t==null&&(t=0),e==null&&(e=0);function a(){var i,s=n.length,o,l=0,c=0;for(i=0;i<s;++i)o=n[i],l+=o.x,c+=o.y;for(l=(l/s-t)*r,c=(c/s-e)*r,i=0;i<s;++i)o=n[i],o.x-=l,o.y-=c}return a.initialize=function(i){n=i},a.x=function(i){return arguments.length?(t=+i,a):t},a.y=function(i){return arguments.length?(e=+i,a):e},a.strength=function(i){return arguments.length?(r=+i,a):r},a}function d0(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Pl(this.cover(e,n),e,n,t)}function Pl(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var a,i=t._root,s={data:r},o=t._x0,l=t._y0,c=t._x1,u=t._y1,h,f,g,v,b,d,x,S;if(!i)return t._root=s,t;for(;i.length;)if((b=e>=(h=(o+c)/2))?o=h:c=h,(d=n>=(f=(l+u)/2))?l=f:u=f,a=i,!(i=i[x=d<<1|b]))return a[x]=s,t;if(g=+t._x.call(null,i.data),v=+t._y.call(null,i.data),e===g&&n===v)return s.next=i,a?a[x]=s:t._root=s,t;do a=a?a[x]=new Array(4):t._root=new Array(4),(b=e>=(h=(o+c)/2))?o=h:c=h,(d=n>=(f=(l+u)/2))?l=f:u=f;while((x=d<<1|b)===(S=(v>=f)<<1|g>=h));return a[S]=i,a[x]=s,t}function p0(t){var e,n,r=t.length,a,i,s=new Array(r),o=new Array(r),l=1/0,c=1/0,u=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(a=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(s[n]=a,o[n]=i,a<l&&(l=a),a>u&&(u=a),i<c&&(c=i),i>h&&(h=i));if(l>u||c>h)return this;for(this.cover(l,c).cover(u,h),n=0;n<r;++n)Pl(this,s[n],o[n],t[n]);return this}function g0(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,a=this._x1,i=this._y1;if(isNaN(n))a=(n=Math.floor(t))+1,i=(r=Math.floor(e))+1;else{for(var s=a-n||1,o=this._root,l,c;n>t||t>=a||r>e||e>=i;)switch(c=(e<r)<<1|t<n,l=new Array(4),l[c]=o,o=l,s*=2,c){case 0:a=n+s,i=r+s;break;case 1:n=a-s,i=r+s;break;case 2:a=n+s,r=i-s;break;case 3:n=a-s,r=i-s;break}this._root&&this._root.length&&(this._root=o)}return this._x0=n,this._y0=r,this._x1=a,this._y1=i,this}function y0(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function x0(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function ze(t,e,n,r,a){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=a}function m0(t,e,n){var r,a=this._x0,i=this._y0,s,o,l,c,u=this._x1,h=this._y1,f=[],g=this._root,v,b;for(g&&f.push(new ze(g,a,i,u,h)),n==null?n=1/0:(a=t-n,i=e-n,u=t+n,h=e+n,n*=n);v=f.pop();)if(!(!(g=v.node)||(s=v.x0)>u||(o=v.y0)>h||(l=v.x1)<a||(c=v.y1)<i))if(g.length){var d=(s+l)/2,x=(o+c)/2;f.push(new ze(g[3],d,x,l,c),new ze(g[2],s,x,d,c),new ze(g[1],d,o,l,x),new ze(g[0],s,o,d,x)),(b=(e>=x)<<1|t>=d)&&(v=f[f.length-1],f[f.length-1]=f[f.length-1-b],f[f.length-1-b]=v)}else{var S=t-+this._x.call(null,g.data),w=e-+this._y.call(null,g.data),y=S*S+w*w;if(y<n){var T=Math.sqrt(n=y);a=t-T,i=e-T,u=t+T,h=e+T,r=g.data}}return r}function v0(t){if(isNaN(u=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,n=this._root,r,a,i,s=this._x0,o=this._y0,l=this._x1,c=this._y1,u,h,f,g,v,b,d,x;if(!n)return this;if(n.length)for(;;){if((v=u>=(f=(s+l)/2))?s=f:l=f,(b=h>=(g=(o+c)/2))?o=g:c=g,e=n,!(n=n[d=b<<1|v]))return this;if(!n.length)break;(e[d+1&3]||e[d+2&3]||e[d+3&3])&&(r=e,x=d)}for(;n.data!==t;)if(a=n,!(n=n.next))return this;return(i=n.next)&&delete n.next,a?(i?a.next=i:delete a.next,this):e?(i?e[d]=i:delete e[d],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[x]=n:this._root=n),this):(this._root=i,this)}function b0(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function w0(){return this._root}function _0(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function k0(t){var e=[],n,r=this._root,a,i,s,o,l;for(r&&e.push(new ze(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,i=n.x0,s=n.y0,o=n.x1,l=n.y1)&&r.length){var c=(i+o)/2,u=(s+l)/2;(a=r[3])&&e.push(new ze(a,c,u,o,l)),(a=r[2])&&e.push(new ze(a,i,u,c,l)),(a=r[1])&&e.push(new ze(a,c,s,o,u)),(a=r[0])&&e.push(new ze(a,i,s,c,u))}return this}function A0(t){var e=[],n=[],r;for(this._root&&e.push(new ze(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var a=r.node;if(a.length){var i,s=r.x0,o=r.y0,l=r.x1,c=r.y1,u=(s+l)/2,h=(o+c)/2;(i=a[0])&&e.push(new ze(i,s,o,u,h)),(i=a[1])&&e.push(new ze(i,u,o,l,h)),(i=a[2])&&e.push(new ze(i,s,h,u,c)),(i=a[3])&&e.push(new ze(i,u,h,l,c))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function S0(t){return t[0]}function M0(t){return arguments.length?(this._x=t,this):this._x}function N0(t){return t[1]}function T0(t){return arguments.length?(this._y=t,this):this._y}function Oa(t,e,n){var r=new hs(e??S0,n??N0,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function hs(t,e,n,r,a,i){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=a,this._y1=i,this._root=void 0}function El(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Ie=Oa.prototype=hs.prototype;Ie.copy=function(){var t=new hs(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=El(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var a=0;a<4;++a)(r=e.source[a])&&(r.length?n.push({source:r,target:e.target[a]=new Array(4)}):e.target[a]=El(r));return t},Ie.add=d0,Ie.addAll=p0,Ie.cover=g0,Ie.data=y0,Ie.extent=x0,Ie.find=m0,Ie.remove=v0,Ie.removeAll=b0,Ie.root=w0,Ie.size=_0,Ie.visit=k0,Ie.visitAfter=A0,Ie.x=M0,Ie.y=T0;function Fe(t){return function(){return t}}function Mn(t){return(t()-.5)*1e-6}function D0(t){return t.x+t.vx}function $0(t){return t.y+t.vy}function Wr(t){var e,n,r,a=1,i=1;typeof t!="function"&&(t=Fe(t==null?1:+t));function s(){for(var c,u=e.length,h,f,g,v,b,d,x=0;x<i;++x)for(h=Oa(e,D0,$0).visitAfter(o),c=0;c<u;++c)f=e[c],b=n[f.index],d=b*b,g=f.x+f.vx,v=f.y+f.vy,h.visit(S);function S(w,y,T,p,k){var _=w.data,E=w.r,R=b+E;if(_){if(_.index>f.index){var z=g-_.x-_.vx,I=v-_.y-_.vy,N=z*z+I*I;N<R*R&&(z===0&&(z=Mn(r),N+=z*z),I===0&&(I=Mn(r),N+=I*I),N=(R-(N=Math.sqrt(N)))/N*a,f.vx+=(z*=N)*(R=(E*=E)/(d+E)),f.vy+=(I*=N)*R,_.vx-=z*(R=1-R),_.vy-=I*R)}return}return y>g+R||p<g-R||T>v+R||k<v-R}}function o(c){if(c.data)return c.r=n[c.data.index];for(var u=c.r=0;u<4;++u)c[u]&&c[u].r>c.r&&(c.r=c[u].r)}function l(){if(e){var c,u=e.length,h;for(n=new Array(u),c=0;c<u;++c)h=e[c],n[h.index]=+t(h,c,e)}}return s.initialize=function(c,u){e=c,r=u,l()},s.iterations=function(c){return arguments.length?(i=+c,s):i},s.strength=function(c){return arguments.length?(a=+c,s):a},s.radius=function(c){return arguments.length?(t=typeof c=="function"?c:Fe(+c),l(),s):t},s}function C0(t){return t.index}function Rl(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function ds(t){var e=C0,n=h,r,a=Fe(30),i,s,o,l,c,u=1;t==null&&(t=[]);function h(d){return 1/Math.min(o[d.source.index],o[d.target.index])}function f(d){for(var x=0,S=t.length;x<u;++x)for(var w=0,y,T,p,k,_,E,R;w<S;++w)y=t[w],T=y.source,p=y.target,k=p.x+p.vx-T.x-T.vx||Mn(c),_=p.y+p.vy-T.y-T.vy||Mn(c),E=Math.sqrt(k*k+_*_),E=(E-i[w])/E*d*r[w],k*=E,_*=E,p.vx-=k*(R=l[w]),p.vy-=_*R,T.vx+=k*(R=1-R),T.vy+=_*R}function g(){if(s){var d,x=s.length,S=t.length,w=new Map(s.map((T,p)=>[e(T,p,s),T])),y;for(d=0,o=new Array(x);d<S;++d)y=t[d],y.index=d,typeof y.source!="object"&&(y.source=Rl(w,y.source)),typeof y.target!="object"&&(y.target=Rl(w,y.target)),o[y.source.index]=(o[y.source.index]||0)+1,o[y.target.index]=(o[y.target.index]||0)+1;for(d=0,l=new Array(S);d<S;++d)y=t[d],l[d]=o[y.source.index]/(o[y.source.index]+o[y.target.index]);r=new Array(S),v(),i=new Array(S),b()}}function v(){if(s)for(var d=0,x=t.length;d<x;++d)r[d]=+n(t[d],d,t)}function b(){if(s)for(var d=0,x=t.length;d<x;++d)i[d]=+a(t[d],d,t)}return f.initialize=function(d,x){s=d,c=x,g()},f.links=function(d){return arguments.length?(t=d,g(),f):t},f.id=function(d){return arguments.length?(e=d,f):e},f.iterations=function(d){return arguments.length?(u=+d,f):u},f.strength=function(d){return arguments.length?(n=typeof d=="function"?d:Fe(+d),v(),f):n},f.distance=function(d){return arguments.length?(a=typeof d=="function"?d:Fe(+d),b(),f):a},f}const L0=1664525,j0=1013904223,zl=4294967296;function P0(){let t=1;return()=>(t=(L0*t+j0)%zl)/zl}function E0(t){return t.x}function R0(t){return t.y}var z0=10,I0=Math.PI*(3-Math.sqrt(5));function F0(t){var e,n=1,r=.001,a=1-Math.pow(r,1/300),i=0,s=.6,o=new Map,l=Vi(h),c=Cr("tick","end"),u=P0();t==null&&(t=[]);function h(){f(),c.call("tick",e),n<r&&(l.stop(),c.call("end",e))}function f(b){var d,x=t.length,S;b===void 0&&(b=1);for(var w=0;w<b;++w)for(n+=(i-n)*a,o.forEach(function(y){y(n)}),d=0;d<x;++d)S=t[d],S.fx==null?S.x+=S.vx*=s:(S.x=S.fx,S.vx=0),S.fy==null?S.y+=S.vy*=s:(S.y=S.fy,S.vy=0);return e}function g(){for(var b=0,d=t.length,x;b<d;++b){if(x=t[b],x.index=b,x.fx!=null&&(x.x=x.fx),x.fy!=null&&(x.y=x.fy),isNaN(x.x)||isNaN(x.y)){var S=z0*Math.sqrt(.5+b),w=b*I0;x.x=S*Math.cos(w),x.y=S*Math.sin(w)}(isNaN(x.vx)||isNaN(x.vy))&&(x.vx=x.vy=0)}}function v(b){return b.initialize&&b.initialize(t,u),b}return g(),e={tick:f,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(b){return arguments.length?(t=b,g(),o.forEach(v),e):t},alpha:function(b){return arguments.length?(n=+b,e):n},alphaMin:function(b){return arguments.length?(r=+b,e):r},alphaDecay:function(b){return arguments.length?(a=+b,e):+a},alphaTarget:function(b){return arguments.length?(i=+b,e):i},velocityDecay:function(b){return arguments.length?(s=1-b,e):1-s},randomSource:function(b){return arguments.length?(u=b,o.forEach(v),e):u},force:function(b,d){return arguments.length>1?(d==null?o.delete(b):o.set(b,v(d)),e):o.get(b)},find:function(b,d,x){var S=0,w=t.length,y,T,p,k,_;for(x==null?x=1/0:x*=x,S=0;S<w;++S)k=t[S],y=b-k.x,T=d-k.y,p=y*y+T*T,p<x&&(_=k,x=p);return _},on:function(b,d){return arguments.length>1?(c.on(b,d),e):c.on(b)}}}function Or(){var t,e,n,r,a=Fe(-30),i,s=1,o=1/0,l=.81;function c(g){var v,b=t.length,d=Oa(t,E0,R0).visitAfter(h);for(r=g,v=0;v<b;++v)e=t[v],d.visit(f)}function u(){if(t){var g,v=t.length,b;for(i=new Array(v),g=0;g<v;++g)b=t[g],i[b.index]=+a(b,g,t)}}function h(g){var v=0,b,d,x=0,S,w,y;if(g.length){for(S=w=y=0;y<4;++y)(b=g[y])&&(d=Math.abs(b.value))&&(v+=b.value,x+=d,S+=d*b.x,w+=d*b.y);g.x=S/x,g.y=w/x}else{b=g,b.x=b.data.x,b.y=b.data.y;do v+=i[b.data.index];while(b=b.next)}g.value=v}function f(g,v,b,d){if(!g.value)return!0;var x=g.x-e.x,S=g.y-e.y,w=d-v,y=x*x+S*S;if(w*w/l<y)return y<o&&(x===0&&(x=Mn(n),y+=x*x),S===0&&(S=Mn(n),y+=S*S),y<s&&(y=Math.sqrt(s*y)),e.vx+=x*g.value*r/y,e.vy+=S*g.value*r/y),!0;if(g.length||y>=o)return;(g.data!==e||g.next)&&(x===0&&(x=Mn(n),y+=x*x),S===0&&(S=Mn(n),y+=S*S),y<s&&(y=Math.sqrt(s*y)));do g.data!==e&&(w=i[g.data.index]*r/y,e.vx+=x*w,e.vy+=S*w);while(g=g.next)}return c.initialize=function(g,v){t=g,n=v,u()},c.strength=function(g){return arguments.length?(a=typeof g=="function"?g:Fe(+g),u(),c):a},c.distanceMin=function(g){return arguments.length?(s=g*g,c):Math.sqrt(s)},c.distanceMax=function(g){return arguments.length?(o=g*g,c):Math.sqrt(o)},c.theta=function(g){return arguments.length?(l=g*g,c):Math.sqrt(l)},c}function Nn(t){var e=Fe(.1),n,r,a;typeof t!="function"&&(t=Fe(t==null?0:+t));function i(o){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vx+=(a[l]-u.x)*r[l]*o}function s(){if(n){var o,l=n.length;for(r=new Array(l),a=new Array(l),o=0;o<l;++o)r[o]=isNaN(a[o]=+t(n[o],o,n))?0:+e(n[o],o,n)}}return i.initialize=function(o){n=o,s()},i.strength=function(o){return arguments.length?(e=typeof o=="function"?o:Fe(+o),s(),i):e},i.x=function(o){return arguments.length?(t=typeof o=="function"?o:Fe(+o),s(),i):t},i}function Tn(t){var e=Fe(.1),n,r,a;typeof t!="function"&&(t=Fe(t==null?0:+t));function i(o){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vy+=(a[l]-u.y)*r[l]*o}function s(){if(n){var o,l=n.length;for(r=new Array(l),a=new Array(l),o=0;o<l;++o)r[o]=isNaN(a[o]=+t(n[o],o,n))?0:+e(n[o],o,n)}}return i.initialize=function(o){n=o,s()},i.strength=function(o){return arguments.length?(e=typeof o=="function"?o:Fe(+o),s(),i):e},i.y=function(o){return arguments.length?(t=typeof o=="function"?o:Fe(+o),s(),i):t},i}function H0(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Ba(t,e){if(!isFinite(t)||t===0)return null;var n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function ur(t){return t=Ba(Math.abs(t)),t?t[1]:NaN}function W0(t,e){return function(n,r){for(var a=n.length,i=[],s=0,o=t[0],l=0;a>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),i.push(n.substring(a-=o,a+o)),!((l+=o+1)>r));)o=t[s=(s+1)%t.length];return i.reverse().join(e)}}function O0(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var B0=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Ya(t){if(!(e=B0.exec(t)))throw new Error("invalid format: "+t);var e;return new ps({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Ya.prototype=ps.prototype;function ps(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}ps.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Y0(t){t:for(var e=t.length,n=1,r=-1,a;n<e;++n)switch(t[n]){case".":r=a=n;break;case"0":r===0&&(r=n),a=n;break;default:if(!+t[n])break t;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(a+1):t}var Ua;function U0(t,e){var n=Ba(t,e);if(!n)return Ua=void 0,t.toPrecision(e);var r=n[0],a=n[1],i=a-(Ua=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,s=r.length;return i===s?r:i>s?r+new Array(i-s+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+Ba(t,Math.max(0,e+i-1))[0]}function Il(t,e){var n=Ba(t,e);if(!n)return t+"";var r=n[0],a=n[1];return a<0?"0."+new Array(-a).join("0")+r:r.length>a+1?r.slice(0,a+1)+"."+r.slice(a+1):r+new Array(a-r.length+2).join("0")}const Fl={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:H0,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Il(t*100,e),r:Il,s:U0,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Hl(t){return t}var Wl=Array.prototype.map,Ol=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function V0(t){var e=t.grouping===void 0||t.thousands===void 0?Hl:W0(Wl.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",a=t.decimal===void 0?".":t.decimal+"",i=t.numerals===void 0?Hl:O0(Wl.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function c(h,f){h=Ya(h);var g=h.fill,v=h.align,b=h.sign,d=h.symbol,x=h.zero,S=h.width,w=h.comma,y=h.precision,T=h.trim,p=h.type;p==="n"?(w=!0,p="g"):Fl[p]||(y===void 0&&(y=12),T=!0,p="g"),(x||g==="0"&&v==="=")&&(x=!0,g="0",v="=");var k=(f&&f.prefix!==void 0?f.prefix:"")+(d==="$"?n:d==="#"&&/[boxX]/.test(p)?"0"+p.toLowerCase():""),_=(d==="$"?r:/[%p]/.test(p)?s:"")+(f&&f.suffix!==void 0?f.suffix:""),E=Fl[p],R=/[defgprs%]/.test(p);y=y===void 0?6:/[gprs]/.test(p)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y));function z(I){var N=k,U=_,M,Y,C;if(p==="c")U=E(I)+U,I="";else{I=+I;var F=I<0||1/I<0;if(I=isNaN(I)?l:E(Math.abs(I),y),T&&(I=Y0(I)),F&&+I==0&&b!=="+"&&(F=!1),N=(F?b==="("?b:o:b==="-"||b==="("?"":b)+N,U=(p==="s"&&!isNaN(I)&&Ua!==void 0?Ol[8+Ua/3]:"")+U+(F&&b==="("?")":""),R){for(M=-1,Y=I.length;++M<Y;)if(C=I.charCodeAt(M),48>C||C>57){U=(C===46?a+I.slice(M+1):I.slice(M))+U,I=I.slice(0,M);break}}}w&&!x&&(I=e(I,1/0));var H=N.length+I.length+U.length,V=H<S?new Array(S-H+1).join(g):"";switch(w&&x&&(I=e(V+I,V.length?S-U.length:1/0),V=""),v){case"<":I=N+I+U+V;break;case"=":I=N+V+I+U;break;case"^":I=V.slice(0,H=V.length>>1)+N+I+U+V.slice(H);break;default:I=V+N+I+U;break}return i(I)}return z.toString=function(){return h+""},z}function u(h,f){var g=Math.max(-8,Math.min(8,Math.floor(ur(f)/3)))*3,v=Math.pow(10,-g),b=c((h=Ya(h),h.type="f",h),{suffix:Ol[8+g/3]});return function(d){return b(v*d)}}return{format:c,formatPrefix:u}}var Va,pe,Bl;X0({thousands:",",grouping:[3],currency:["$",""]});function X0(t){return Va=V0(t),pe=Va.format,Bl=Va.formatPrefix,Va}function K0(t){return Math.max(0,-ur(Math.abs(t)))}function G0(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ur(e)/3)))*3-ur(Math.abs(t)))}function Z0(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,ur(e)-ur(t))+1}function J0(t){var e=0,n=t.children,r=n&&n.length;if(!r)e=1;else for(;--r>=0;)e+=n[r].value;t.value=e}function Q0(){return this.eachAfter(J0)}function q0(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this}function tg(t,e){for(var n=this,r=[n],a,i,s=-1;n=r.pop();)if(t.call(e,n,++s,this),a=n.children)for(i=a.length-1;i>=0;--i)r.push(a[i]);return this}function eg(t,e){for(var n=this,r=[n],a=[],i,s,o,l=-1;n=r.pop();)if(a.push(n),i=n.children)for(s=0,o=i.length;s<o;++s)r.push(i[s]);for(;n=a.pop();)t.call(e,n,++l,this);return this}function ng(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r}function rg(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,a=r&&r.length;--a>=0;)n+=r[a].value;e.value=n})}function ag(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function ig(t){for(var e=this,n=sg(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var a=r.length;t!==n;)r.splice(a,0,t),t=t.parent;return r}function sg(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),a=null;for(t=n.pop(),e=r.pop();t===e;)a=t,t=n.pop(),e=r.pop();return a}function og(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function lg(){return Array.from(this)}function cg(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function ug(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function*fg(){var t=this,e,n=[t],r,a,i;do for(e=n.reverse(),n=[];t=e.pop();)if(yield t,r=t.children)for(a=0,i=r.length;a<i;++a)n.push(r[a]);while(n.length)}function fr(t,e){t instanceof Map?(t=[void 0,t],e===void 0&&(e=pg)):e===void 0&&(e=dg);for(var n=new Br(t),r,a=[n],i,s,o,l;r=a.pop();)if((s=e(r.data))&&(l=(s=Array.from(s)).length))for(r.children=s,o=l-1;o>=0;--o)a.push(i=s[o]=new Br(s[o])),i.parent=r,i.depth=r.depth+1;return n.eachBefore(yg)}function hg(){return fr(this).eachBefore(gg)}function dg(t){return t.children}function pg(t){return Array.isArray(t)?t[1]:null}function gg(t){t.data.value!==void 0&&(t.value=t.data.value),t.data=t.data.data}function yg(t){var e=0;do t.height=e;while((t=t.parent)&&t.height<++e)}function Br(t){this.data=t,this.depth=this.height=0,this.parent=null}Br.prototype=fr.prototype={constructor:Br,count:Q0,each:q0,eachAfter:eg,eachBefore:tg,find:ng,sum:rg,sort:ag,path:ig,ancestors:og,descendants:lg,leaves:cg,links:ug,copy:hg,[Symbol.iterator]:fg};function xg(t){return t==null?null:mg(t)}function mg(t){if(typeof t!="function")throw new Error;return t}function Yl(){return 0}function vg(t){return function(){return t}}const bg=1664525,wg=1013904223,Ul=4294967296;function _g(){let t=1;return()=>(t=(bg*t+wg)%Ul)/Ul}function kg(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Ag(t,e){let n=t.length,r,a;for(;n;)a=e()*n--|0,r=t[n],t[n]=t[a],t[a]=r;return t}function Sg(t,e){for(var n=0,r=(t=Ag(Array.from(t),e)).length,a=[],i,s;n<r;)i=t[n],s&&Vl(s,i)?++n:(s=Ng(a=Mg(a,i)),n=0);return s}function Mg(t,e){var n,r;if(gs(e,t))return[e];for(n=0;n<t.length;++n)if(Xa(e,t[n])&&gs(Yr(t[n],e),t))return[t[n],e];for(n=0;n<t.length-1;++n)for(r=n+1;r<t.length;++r)if(Xa(Yr(t[n],t[r]),e)&&Xa(Yr(t[n],e),t[r])&&Xa(Yr(t[r],e),t[n])&&gs(Xl(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function Xa(t,e){var n=t.r-e.r,r=e.x-t.x,a=e.y-t.y;return n<0||n*n<r*r+a*a}function Vl(t,e){var n=t.r-e.r+Math.max(t.r,e.r,1)*1e-9,r=e.x-t.x,a=e.y-t.y;return n>0&&n*n>r*r+a*a}function gs(t,e){for(var n=0;n<e.length;++n)if(!Vl(t,e[n]))return!1;return!0}function Ng(t){switch(t.length){case 1:return Tg(t[0]);case 2:return Yr(t[0],t[1]);case 3:return Xl(t[0],t[1],t[2])}}function Tg(t){return{x:t.x,y:t.y,r:t.r}}function Yr(t,e){var n=t.x,r=t.y,a=t.r,i=e.x,s=e.y,o=e.r,l=i-n,c=s-r,u=o-a,h=Math.sqrt(l*l+c*c);return{x:(n+i+l/h*u)/2,y:(r+s+c/h*u)/2,r:(h+a+o)/2}}function Xl(t,e,n){var r=t.x,a=t.y,i=t.r,s=e.x,o=e.y,l=e.r,c=n.x,u=n.y,h=n.r,f=r-s,g=r-c,v=a-o,b=a-u,d=l-i,x=h-i,S=r*r+a*a-i*i,w=S-s*s-o*o+l*l,y=S-c*c-u*u+h*h,T=g*v-f*b,p=(v*y-b*w)/(T*2)-r,k=(b*d-v*x)/T,_=(g*w-f*y)/(T*2)-a,E=(f*x-g*d)/T,R=k*k+E*E-1,z=2*(i+p*k+_*E),I=p*p+_*_-i*i,N=-(Math.abs(R)>1e-6?(z+Math.sqrt(z*z-4*R*I))/(2*R):I/z);return{x:r+p+k*N,y:a+_+E*N,r:N}}function Kl(t,e,n){var r=t.x-e.x,a,i,s=t.y-e.y,o,l,c=r*r+s*s;c?(i=e.r+n.r,i*=i,l=t.r+n.r,l*=l,i>l?(a=(c+l-i)/(2*c),o=Math.sqrt(Math.max(0,l/c-a*a)),n.x=t.x-a*r-o*s,n.y=t.y-a*s+o*r):(a=(c+i-l)/(2*c),o=Math.sqrt(Math.max(0,i/c-a*a)),n.x=e.x+a*r-o*s,n.y=e.y+a*s+o*r)):(n.x=e.x+n.r,n.y=e.y)}function Gl(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,a=e.y-t.y;return n>0&&n*n>r*r+a*a}function Zl(t){var e=t._,n=t.next._,r=e.r+n.r,a=(e.x*n.r+n.x*e.r)/r,i=(e.y*n.r+n.y*e.r)/r;return a*a+i*i}function Ka(t){this._=t,this.next=null,this.previous=null}function Dg(t,e){if(!(i=(t=kg(t)).length))return 0;var n,r,a,i,s,o,l,c,u,h,f;if(n=t[0],n.x=0,n.y=0,!(i>1))return n.r;if(r=t[1],n.x=-r.r,r.x=n.r,r.y=0,!(i>2))return n.r+r.r;Kl(r,n,a=t[2]),n=new Ka(n),r=new Ka(r),a=new Ka(a),n.next=a.previous=r,r.next=n.previous=a,a.next=r.previous=n;t:for(l=3;l<i;++l){Kl(n._,r._,a=t[l]),a=new Ka(a),c=r.next,u=n.previous,h=r._.r,f=n._.r;do if(h<=f){if(Gl(c._,a._)){r=c,n.next=r,r.previous=n,--l;continue t}h+=c._.r,c=c.next}else{if(Gl(u._,a._)){n=u,n.next=r,r.previous=n,--l;continue t}f+=u._.r,u=u.previous}while(c!==u.next);for(a.previous=n,a.next=r,n.next=r.previous=r=a,s=Zl(n);(a=a.next)!==r;)(o=Zl(a))<s&&(n=a,s=o);r=n.next}for(n=[r._],a=r;(a=a.next)!==r;)n.push(a._);for(a=Sg(n,e),l=0;l<i;++l)n=t[l],n.x-=a.x,n.y-=a.y;return a.r}function $g(t){return Math.sqrt(t.value)}function Jl(){var t=null,e=1,n=1,r=Yl;function a(i){const s=_g();return i.x=e/2,i.y=n/2,t?i.eachBefore(Ql(t)).eachAfter(ys(r,.5,s)).eachBefore(ql(1)):i.eachBefore(Ql($g)).eachAfter(ys(Yl,1,s)).eachAfter(ys(r,i.r/Math.min(e,n),s)).eachBefore(ql(Math.min(e,n)/(2*i.r))),i}return a.radius=function(i){return arguments.length?(t=xg(i),a):t},a.size=function(i){return arguments.length?(e=+i[0],n=+i[1],a):[e,n]},a.padding=function(i){return arguments.length?(r=typeof i=="function"?i:vg(+i),a):r},a}function Ql(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function ys(t,e,n){return function(r){if(a=r.children){var a,i,s=a.length,o=t(r)*e||0,l;if(o)for(i=0;i<s;++i)a[i].r+=o;if(l=Dg(a,n),o)for(i=0;i<s;++i)a[i].r-=o;r.r=l+o}}}function ql(t){return function(e){var n=e.parent;e.r*=t,n&&(e.x=n.x+t*e.x,e.y=n.y+t*e.y)}}function Cg(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function Lg(t,e,n,r,a){for(var i=t.children,s,o=-1,l=i.length,c=t.value&&(r-e)/t.value;++o<l;)s=i[o],s.y0=n,s.y1=a,s.x0=e,s.x1=e+=s.value*c}function jg(){var t=1,e=1,n=0,r=!1;function a(s){var o=s.height+1;return s.x0=s.y0=n,s.x1=t,s.y1=e/o,s.eachBefore(i(e,o)),r&&s.eachBefore(Cg),s}function i(s,o){return function(l){l.children&&Lg(l,l.x0,s*(l.depth+1)/o,l.x1,s*(l.depth+2)/o);var c=l.x0,u=l.y0,h=l.x1-n,f=l.y1-n;h<c&&(c=h=(c+h)/2),f<u&&(u=f=(u+f)/2),l.x0=c,l.y0=u,l.x1=h,l.y1=f}}return a.round=function(s){return arguments.length?(r=!!s,a):r},a.size=function(s){return arguments.length?(t=+s[0],e=+s[1],a):[t,e]},a.padding=function(s){return arguments.length?(n=+s,a):n},a}function Pg(t,e){return t.parent===e.parent?1:2}function xs(t){var e=t.children;return e?e[0]:t.t}function ms(t){var e=t.children;return e?e[e.length-1]:t.t}function Eg(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n}function Rg(t){for(var e=0,n=0,r=t.children,a=r.length,i;--a>=0;)i=r[a],i.z+=e,i.m+=e,e+=i.s+(n+=i.c)}function zg(t,e,n){return t.a.parent===e.parent?t.a:n}function Ga(t,e){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}Ga.prototype=Object.create(Br.prototype);function Ig(t){for(var e=new Ga(t,0),n,r=[e],a,i,s,o;n=r.pop();)if(i=n._.children)for(n.children=new Array(o=i.length),s=o-1;s>=0;--s)r.push(a=n.children[s]=new Ga(i[s],s)),a.parent=n;return(e.parent=new Ga(null,0)).children=[e],e}function tc(){var t=Pg,e=1,n=1,r=null;function a(c){var u=Ig(c);if(u.eachAfter(i),u.parent.m=-u.z,u.eachBefore(s),r)c.eachBefore(l);else{var h=c,f=c,g=c;c.eachBefore(function(S){S.x<h.x&&(h=S),S.x>f.x&&(f=S),S.depth>g.depth&&(g=S)});var v=h===f?1:t(h,f)/2,b=v-h.x,d=e/(f.x+v+b),x=n/(g.depth||1);c.eachBefore(function(S){S.x=(S.x+b)*d,S.y=S.depth*x})}return c}function i(c){var u=c.children,h=c.parent.children,f=c.i?h[c.i-1]:null;if(u){Rg(c);var g=(u[0].z+u[u.length-1].z)/2;f?(c.z=f.z+t(c._,f._),c.m=c.z-g):c.z=g}else f&&(c.z=f.z+t(c._,f._));c.parent.A=o(c,f,c.parent.A||h[0])}function s(c){c._.x=c.z+c.parent.m,c.m+=c.parent.m}function o(c,u,h){if(u){for(var f=c,g=c,v=u,b=f.parent.children[0],d=f.m,x=g.m,S=v.m,w=b.m,y;v=ms(v),f=xs(f),v&&f;)b=xs(b),g=ms(g),g.a=c,y=v.z+S-f.z-d+t(v._,f._),y>0&&(Eg(zg(v,c,h),c,y),d+=y,x+=y),S+=v.m,d+=f.m,w+=b.m,x+=g.m;v&&!ms(g)&&(g.t=v,g.m+=S-x),f&&!xs(b)&&(b.t=f,b.m+=d-w,h=c)}return h}function l(c){c.x*=e,c.y=c.depth*n}return a.separation=function(c){return arguments.length?(t=c,a):t},a.size=function(c){return arguments.length?(r=!1,e=+c[0],n=+c[1],a):r?null:[e,n]},a.nodeSize=function(c){return arguments.length?(r=!0,e=+c[0],n=+c[1],a):r?[e,n]:null},a}function Ur(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}const ec=Symbol("implicit");function hr(){var t=new Ai,e=[],n=[],r=ec;function a(i){let s=t.get(i);if(s===void 0){if(r!==ec)return r;t.set(i,s=e.push(i)-1)}return n[s%n.length]}return a.domain=function(i){if(!arguments.length)return e.slice();e=[],t=new Ai;for(const s of i)t.has(s)||t.set(s,e.push(s)-1);return a},a.range=function(i){return arguments.length?(n=Array.from(i),a):n.slice()},a.unknown=function(i){return arguments.length?(r=i,a):r},a.copy=function(){return hr(e,n).unknown(r)},Ur.apply(a,arguments),a}function Xe(){var t=hr().unknown(void 0),e=t.domain,n=t.range,r=0,a=1,i,s,o=!1,l=0,c=0,u=.5;delete t.unknown;function h(){var f=e().length,g=a<r,v=g?a:r,b=g?r:a;i=(b-v)/Math.max(1,f-l+c*2),o&&(i=Math.floor(i)),v+=(b-v-i*(f-l))*u,s=i*(1-l),o&&(v=Math.round(v),s=Math.round(s));var d=ga(f).map(function(x){return v+i*x});return n(g?d.reverse():d)}return t.domain=function(f){return arguments.length?(e(f),h()):e()},t.range=function(f){return arguments.length?([r,a]=f,r=+r,a=+a,h()):[r,a]},t.rangeRound=function(f){return[r,a]=f,r=+r,a=+a,o=!0,h()},t.bandwidth=function(){return s},t.step=function(){return i},t.round=function(f){return arguments.length?(o=!!f,h()):o},t.padding=function(f){return arguments.length?(l=Math.min(1,c=+f),h()):l},t.paddingInner=function(f){return arguments.length?(l=Math.min(1,f),h()):l},t.paddingOuter=function(f){return arguments.length?(c=+f,h()):c},t.align=function(f){return arguments.length?(u=Math.max(0,Math.min(1,f)),h()):u},t.copy=function(){return Xe(e(),[r,a]).round(o).paddingInner(l).paddingOuter(c).align(u)},Ur.apply(h(),arguments)}function Fg(t){return function(){return t}}function Hg(t){return+t}var nc=[0,1];function cn(t){return t}function vs(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Fg(isNaN(e)?NaN:.5)}function Wg(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Og(t,e,n){var r=t[0],a=t[1],i=e[0],s=e[1];return a<r?(r=vs(a,r),i=n(s,i)):(r=vs(r,a),i=n(i,s)),function(o){return i(r(o))}}function Bg(t,e,n){var r=Math.min(t.length,e.length)-1,a=new Array(r),i=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)a[s]=vs(t[s],t[s+1]),i[s]=n(e[s],e[s+1]);return function(o){var l=io(t,o,1,r)-1;return i[l](a[l](o))}}function bs(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function rc(){var t=nc,e=nc,n=Ae,r,a,i,s=cn,o,l,c;function u(){var f=Math.min(t.length,e.length);return s!==cn&&(s=Wg(t[0],t[f-1])),o=f>2?Bg:Og,l=c=null,h}function h(f){return f==null||isNaN(f=+f)?i:(l||(l=o(t.map(r),e,n)))(r(s(f)))}return h.invert=function(f){return s(a((c||(c=o(e,t.map(r),en)))(f)))},h.domain=function(f){return arguments.length?(t=Array.from(f,Hg),u()):t.slice()},h.range=function(f){return arguments.length?(e=Array.from(f),u()):e.slice()},h.rangeRound=function(f){return e=Array.from(f),n=Nd,u()},h.clamp=function(f){return arguments.length?(s=f?!0:cn,u()):s!==cn},h.interpolate=function(f){return arguments.length?(n=f,u()):n},h.unknown=function(f){return arguments.length?(i=f,h):i},function(f,g){return r=f,a=g,u()}}function ac(){return rc()(cn,cn)}function Yg(t,e,n,r){var a=pa(t,e,n),i;switch(r=Ya(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(i=G0(a,s))&&(r.precision=i),Bl(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(i=Z0(a,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=i-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(i=K0(a))&&(r.precision=i-(r.type==="%")*2);break}}return pe(r)}function ic(t){var e=t.domain;return t.ticks=function(n){var r=e();return uo(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var a=e();return Yg(a[0],a[a.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),a=0,i=r.length-1,s=r[a],o=r[i],l,c,u=10;for(o<s&&(c=s,s=o,o=c,c=a,a=i,i=c);u-- >0;){if(c=Qn(s,o,n),c===l)return r[a]=s,r[i]=o,e(r);if(c>0)s=Math.floor(s/c)*c,o=Math.ceil(o/c)*c;else if(c<0)s=Math.ceil(s*c)/c,o=Math.floor(o*c)/c;else break;l=c}return t},t}function ye(){var t=ac();return t.copy=function(){return bs(t,ye())},Ur.apply(t,arguments),ic(t)}function Ug(t,e){t=t.slice();var n=0,r=t.length-1,a=t[n],i=t[r],s;return i<a&&(s=n,n=r,r=s,s=a,a=i,i=s),t[n]=e.floor(a),t[r]=e.ceil(i),t}function sc(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Vg(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Xg(t){return t<0?-t*t:t*t}function Kg(t){var e=t(cn,cn),n=1;function r(){return n===1?t(cn,cn):n===.5?t(Vg,Xg):t(sc(n),sc(1/n))}return e.exponent=function(a){return arguments.length?(n=+a,r()):n},ic(e)}function oc(){var t=Kg(rc());return t.copy=function(){return bs(t,oc()).exponent(t.exponent())},Ur.apply(t,arguments),t}const ws=new Date,_s=new Date;function Me(t,e,n,r){function a(i){return t(i=arguments.length===0?new Date:new Date(+i)),i}return a.floor=i=>(t(i=new Date(+i)),i),a.ceil=i=>(t(i=new Date(i-1)),e(i,1),t(i),i),a.round=i=>{const s=a(i),o=a.ceil(i);return i-s<o-i?s:o},a.offset=(i,s)=>(e(i=new Date(+i),s==null?1:Math.floor(s)),i),a.range=(i,s,o)=>{const l=[];if(i=a.ceil(i),o=o==null?1:Math.floor(o),!(i<s)||!(o>0))return l;let c;do l.push(c=new Date(+i)),e(i,o),t(i);while(c<i&&i<s);return l},a.filter=i=>Me(s=>{if(s>=s)for(;t(s),!i(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;e(s,-1),!i(s););else for(;--o>=0;)for(;e(s,1),!i(s););}),n&&(a.count=(i,s)=>(ws.setTime(+i),_s.setTime(+s),t(ws),t(_s),Math.floor(n(ws,_s))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(r?s=>r(s)%i===0:s=>a.count(0,s)%i===0):a)),a}const Za=Me(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Za.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Me(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Za),Za.range;const bn=1e3,Je=bn*60,wn=Je*60,_n=wn*24,ks=_n*7,lc=_n*30,As=_n*365,dr=Me(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*bn)},(t,e)=>(e-t)/bn,t=>t.getUTCSeconds());dr.range;const Ss=Me(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*bn)},(t,e)=>{t.setTime(+t+e*Je)},(t,e)=>(e-t)/Je,t=>t.getMinutes());Ss.range,Me(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Je)},(t,e)=>(e-t)/Je,t=>t.getUTCMinutes()).range;const Ms=Me(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*bn-t.getMinutes()*Je)},(t,e)=>{t.setTime(+t+e*wn)},(t,e)=>(e-t)/wn,t=>t.getHours());Ms.range,Me(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*wn)},(t,e)=>(e-t)/wn,t=>t.getUTCHours()).range;const Vr=Me(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Je)/_n,t=>t.getDate()-1);Vr.range;const Ns=Me(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/_n,t=>t.getUTCDate()-1);Ns.range,Me(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/_n,t=>Math.floor(t/_n)).range;function Fn(t){return Me(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*Je)/ks)}const Xr=Fn(0),Ja=Fn(1),Gg=Fn(2),Zg=Fn(3),pr=Fn(4),Jg=Fn(5),Qg=Fn(6);Xr.range,Ja.range,Gg.range,Zg.range,pr.range,Jg.range,Qg.range;function Hn(t){return Me(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/ks)}const cc=Hn(0),Qa=Hn(1),qg=Hn(2),ty=Hn(3),gr=Hn(4),ey=Hn(5),ny=Hn(6);cc.range,Qa.range,qg.range,ty.range,gr.range,ey.range,ny.range;const qa=Me(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());qa.range,Me(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth()).range;const kn=Me(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());kn.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Me(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)}),kn.range;const Wn=Me(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());Wn.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Me(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)}),Wn.range;function ry(t,e,n,r,a,i){const s=[[dr,1,bn],[dr,5,5*bn],[dr,15,15*bn],[dr,30,30*bn],[i,1,Je],[i,5,5*Je],[i,15,15*Je],[i,30,30*Je],[a,1,wn],[a,3,3*wn],[a,6,6*wn],[a,12,12*wn],[r,1,_n],[r,2,2*_n],[n,1,ks],[e,1,lc],[e,3,3*lc],[t,1,As]];function o(c,u,h){const f=u<c;f&&([c,u]=[u,c]);const g=h&&typeof h.range=="function"?h:l(c,u,h),v=g?g.range(c,+u+1):[];return f?v.reverse():v}function l(c,u,h){const f=Math.abs(u-c)/h,g=Nr(([,,d])=>d).right(s,f);if(g===s.length)return t.every(pa(c/As,u/As,h));if(g===0)return Za.every(Math.max(pa(c,u,h),1));const[v,b]=s[f/s[g-1][2]<s[g][2]/f?g-1:g];return v.every(b)}return[o,l]}const[ay,iy]=ry(kn,qa,Xr,Vr,Ms,Ss);function Ts(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Ds(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Kr(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function sy(t){var e=t.dateTime,n=t.date,r=t.time,a=t.periods,i=t.days,s=t.shortDays,o=t.months,l=t.shortMonths,c=Gr(a),u=Zr(a),h=Gr(i),f=Zr(i),g=Gr(s),v=Zr(s),b=Gr(o),d=Zr(o),x=Gr(l),S=Zr(l),w={a:C,A:F,b:H,B:V,c:null,d:gc,e:gc,f:Dy,g:Fy,G:Wy,H:My,I:Ny,j:Ty,L:yc,m:$y,M:Cy,p:et,q:$,Q:_c,s:kc,S:Ly,u:jy,U:Py,V:Ey,w:Ry,W:zy,x:null,X:null,y:Iy,Y:Hy,Z:Oy,"%":wc},y={a:dt,A:wt,b:pt,B:_t,c:null,d:mc,e:mc,f:Vy,g:nx,G:ax,H:By,I:Yy,j:Uy,L:vc,m:Xy,M:Ky,p:G,q:ot,Q:_c,s:kc,S:Gy,u:Zy,U:Jy,V:Qy,w:qy,W:tx,x:null,X:null,y:ex,Y:rx,Z:ix,"%":wc},T={a:R,A:z,b:I,B:N,c:U,d:dc,e:dc,f:_y,g:hc,G:fc,H:pc,I:pc,j:my,L:wy,m:xy,M:vy,p:E,q:yy,Q:Ay,s:Sy,S:by,u:fy,U:hy,V:dy,w:uy,W:py,x:M,X:Y,y:hc,Y:fc,Z:gy,"%":ky};w.x=p(n,w),w.X=p(r,w),w.c=p(e,w),y.x=p(n,y),y.X=p(r,y),y.c=p(e,y);function p(O,Q){return function(X){var D=[],tt=-1,L=0,Z=O.length,ft,st,it;for(X instanceof Date||(X=new Date(+X));++tt<Z;)O.charCodeAt(tt)===37&&(D.push(O.slice(L,tt)),(st=uc[ft=O.charAt(++tt)])!=null?ft=O.charAt(++tt):st=ft==="e"?" ":"0",(it=Q[ft])&&(ft=it(X,st)),D.push(ft),L=tt+1);return D.push(O.slice(L,tt)),D.join("")}}function k(O,Q){return function(X){var D=Kr(1900,void 0,1),tt=_(D,O,X+="",0),L,Z;if(tt!=X.length)return null;if("Q"in D)return new Date(D.Q);if("s"in D)return new Date(D.s*1e3+("L"in D?D.L:0));if(Q&&!("Z"in D)&&(D.Z=0),"p"in D&&(D.H=D.H%12+D.p*12),D.m===void 0&&(D.m="q"in D?D.q:0),"V"in D){if(D.V<1||D.V>53)return null;"w"in D||(D.w=1),"Z"in D?(L=Ds(Kr(D.y,0,1)),Z=L.getUTCDay(),L=Z>4||Z===0?Qa.ceil(L):Qa(L),L=Ns.offset(L,(D.V-1)*7),D.y=L.getUTCFullYear(),D.m=L.getUTCMonth(),D.d=L.getUTCDate()+(D.w+6)%7):(L=Ts(Kr(D.y,0,1)),Z=L.getDay(),L=Z>4||Z===0?Ja.ceil(L):Ja(L),L=Vr.offset(L,(D.V-1)*7),D.y=L.getFullYear(),D.m=L.getMonth(),D.d=L.getDate()+(D.w+6)%7)}else("W"in D||"U"in D)&&("w"in D||(D.w="u"in D?D.u%7:"W"in D?1:0),Z="Z"in D?Ds(Kr(D.y,0,1)).getUTCDay():Ts(Kr(D.y,0,1)).getDay(),D.m=0,D.d="W"in D?(D.w+6)%7+D.W*7-(Z+5)%7:D.w+D.U*7-(Z+6)%7);return"Z"in D?(D.H+=D.Z/100|0,D.M+=D.Z%100,Ds(D)):Ts(D)}}function _(O,Q,X,D){for(var tt=0,L=Q.length,Z=X.length,ft,st;tt<L;){if(D>=Z)return-1;if(ft=Q.charCodeAt(tt++),ft===37){if(ft=Q.charAt(tt++),st=T[ft in uc?Q.charAt(tt++):ft],!st||(D=st(O,X,D))<0)return-1}else if(ft!=X.charCodeAt(D++))return-1}return D}function E(O,Q,X){var D=c.exec(Q.slice(X));return D?(O.p=u.get(D[0].toLowerCase()),X+D[0].length):-1}function R(O,Q,X){var D=g.exec(Q.slice(X));return D?(O.w=v.get(D[0].toLowerCase()),X+D[0].length):-1}function z(O,Q,X){var D=h.exec(Q.slice(X));return D?(O.w=f.get(D[0].toLowerCase()),X+D[0].length):-1}function I(O,Q,X){var D=x.exec(Q.slice(X));return D?(O.m=S.get(D[0].toLowerCase()),X+D[0].length):-1}function N(O,Q,X){var D=b.exec(Q.slice(X));return D?(O.m=d.get(D[0].toLowerCase()),X+D[0].length):-1}function U(O,Q,X){return _(O,e,Q,X)}function M(O,Q,X){return _(O,n,Q,X)}function Y(O,Q,X){return _(O,r,Q,X)}function C(O){return s[O.getDay()]}function F(O){return i[O.getDay()]}function H(O){return l[O.getMonth()]}function V(O){return o[O.getMonth()]}function et(O){return a[+(O.getHours()>=12)]}function $(O){return 1+~~(O.getMonth()/3)}function dt(O){return s[O.getUTCDay()]}function wt(O){return i[O.getUTCDay()]}function pt(O){return l[O.getUTCMonth()]}function _t(O){return o[O.getUTCMonth()]}function G(O){return a[+(O.getUTCHours()>=12)]}function ot(O){return 1+~~(O.getUTCMonth()/3)}return{format:function(O){var Q=p(O+="",w);return Q.toString=function(){return O},Q},parse:function(O){var Q=k(O+="",!1);return Q.toString=function(){return O},Q},utcFormat:function(O){var Q=p(O+="",y);return Q.toString=function(){return O},Q},utcParse:function(O){var Q=k(O+="",!0);return Q.toString=function(){return O},Q}}}var uc={"-":"",_:" ",0:"0"},De=/^\s*\d+/,oy=/^%/,ly=/[\\^$*+?|[\]().{}]/g;function ne(t,e,n){var r=t<0?"-":"",a=(r?-t:t)+"",i=a.length;return r+(i<n?new Array(n-i+1).join(e)+a:a)}function cy(t){return t.replace(ly,"\\$&")}function Gr(t){return new RegExp("^(?:"+t.map(cy).join("|")+")","i")}function Zr(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function uy(t,e,n){var r=De.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function fy(t,e,n){var r=De.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function hy(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function dy(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function py(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function fc(t,e,n){var r=De.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function hc(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function gy(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function yy(t,e,n){var r=De.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function xy(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function dc(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function my(t,e,n){var r=De.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function pc(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function vy(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function by(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function wy(t,e,n){var r=De.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function _y(t,e,n){var r=De.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ky(t,e,n){var r=oy.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Ay(t,e,n){var r=De.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Sy(t,e,n){var r=De.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function gc(t,e){return ne(t.getDate(),e,2)}function My(t,e){return ne(t.getHours(),e,2)}function Ny(t,e){return ne(t.getHours()%12||12,e,2)}function Ty(t,e){return ne(1+Vr.count(kn(t),t),e,3)}function yc(t,e){return ne(t.getMilliseconds(),e,3)}function Dy(t,e){return yc(t,e)+"000"}function $y(t,e){return ne(t.getMonth()+1,e,2)}function Cy(t,e){return ne(t.getMinutes(),e,2)}function Ly(t,e){return ne(t.getSeconds(),e,2)}function jy(t){var e=t.getDay();return e===0?7:e}function Py(t,e){return ne(Xr.count(kn(t)-1,t),e,2)}function xc(t){var e=t.getDay();return e>=4||e===0?pr(t):pr.ceil(t)}function Ey(t,e){return t=xc(t),ne(pr.count(kn(t),t)+(kn(t).getDay()===4),e,2)}function Ry(t){return t.getDay()}function zy(t,e){return ne(Ja.count(kn(t)-1,t),e,2)}function Iy(t,e){return ne(t.getFullYear()%100,e,2)}function Fy(t,e){return t=xc(t),ne(t.getFullYear()%100,e,2)}function Hy(t,e){return ne(t.getFullYear()%1e4,e,4)}function Wy(t,e){var n=t.getDay();return t=n>=4||n===0?pr(t):pr.ceil(t),ne(t.getFullYear()%1e4,e,4)}function Oy(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+ne(e/60|0,"0",2)+ne(e%60,"0",2)}function mc(t,e){return ne(t.getUTCDate(),e,2)}function By(t,e){return ne(t.getUTCHours(),e,2)}function Yy(t,e){return ne(t.getUTCHours()%12||12,e,2)}function Uy(t,e){return ne(1+Ns.count(Wn(t),t),e,3)}function vc(t,e){return ne(t.getUTCMilliseconds(),e,3)}function Vy(t,e){return vc(t,e)+"000"}function Xy(t,e){return ne(t.getUTCMonth()+1,e,2)}function Ky(t,e){return ne(t.getUTCMinutes(),e,2)}function Gy(t,e){return ne(t.getUTCSeconds(),e,2)}function Zy(t){var e=t.getUTCDay();return e===0?7:e}function Jy(t,e){return ne(cc.count(Wn(t)-1,t),e,2)}function bc(t){var e=t.getUTCDay();return e>=4||e===0?gr(t):gr.ceil(t)}function Qy(t,e){return t=bc(t),ne(gr.count(Wn(t),t)+(Wn(t).getUTCDay()===4),e,2)}function qy(t){return t.getUTCDay()}function tx(t,e){return ne(Qa.count(Wn(t)-1,t),e,2)}function ex(t,e){return ne(t.getUTCFullYear()%100,e,2)}function nx(t,e){return t=bc(t),ne(t.getUTCFullYear()%100,e,2)}function rx(t,e){return ne(t.getUTCFullYear()%1e4,e,4)}function ax(t,e){var n=t.getUTCDay();return t=n>=4||n===0?gr(t):gr.ceil(t),ne(t.getUTCFullYear()%1e4,e,4)}function ix(){return"+0000"}function wc(){return"%"}function _c(t){return+t}function kc(t){return Math.floor(+t/1e3)}var yr,Jr,Ac;sx({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function sx(t){return yr=sy(t),Jr=yr.format,Ac=yr.parse,yr.utcFormat,yr.utcParse,yr}function ox(t){return new Date(t)}function lx(t){return t instanceof Date?+t:+new Date(+t)}function Sc(t,e,n,r,a,i,s,o,l,c){var u=ac(),h=u.invert,f=u.domain,g=c(".%L"),v=c(":%S"),b=c("%I:%M"),d=c("%I %p"),x=c("%a %d"),S=c("%b %d"),w=c("%B"),y=c("%Y");function T(p){return(l(p)<p?g:o(p)<p?v:s(p)<p?b:i(p)<p?d:r(p)<p?a(p)<p?x:S:n(p)<p?w:y)(p)}return u.invert=function(p){return new Date(h(p))},u.domain=function(p){return arguments.length?f(Array.from(p,lx)):f().map(ox)},u.ticks=function(p){var k=f();return t(k[0],k[k.length-1],p??10)},u.tickFormat=function(p,k){return k==null?T:c(k)},u.nice=function(p){var k=f();return(!p||typeof p.range!="function")&&(p=e(k[0],k[k.length-1],p??10)),p?f(Ug(k,p)):u},u.copy=function(){return bs(u,Sc(t,e,n,r,a,i,s,o,l,c))},u}function ti(){return Ur.apply(Sc(ay,iy,kn,qa,Xr,Vr,Ms,Ss,dr,Jr).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Qr(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(r*6,++r*6);return n}const qr=Qr("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),Mc=Qr("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"),Nc=Qr("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"),Tc=Qr("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"),Dc=Qr("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");ol(Sn(-100,.75,.35),Sn(80,1.5,.8)),ol(Sn(260,.75,.35),Sn(80,1.5,.8));var ei=Sn();function $c(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return ei.h=360*t-100,ei.s=1.5-1.5*e,ei.l=.8-.9*e,ei+""}function Vt(t){return function(){return t}}const Cc=Math.abs,Le=Math.atan2,On=Math.cos,cx=Math.max,$s=Math.min,un=Math.sin,xr=Math.sqrt,je=1e-12,ta=Math.PI,ni=ta/2,ri=2*ta;function ux(t){return t>1?0:t<-1?ta:Math.acos(t)}function Lc(t){return t>=1?ni:t<=-1?-ni:Math.asin(t)}function ai(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new us(e)}function fx(t){return t.innerRadius}function hx(t){return t.outerRadius}function dx(t){return t.startAngle}function px(t){return t.endAngle}function gx(t){return t&&t.padAngle}function yx(t,e,n,r,a,i,s,o){var l=n-t,c=r-e,u=s-a,h=o-i,f=h*l-u*c;if(!(f*f<je))return f=(u*(e-i)-h*(t-a))/f,[t+f*l,e+f*c]}function ii(t,e,n,r,a,i,s){var o=t-n,l=e-r,c=(s?i:-i)/xr(o*o+l*l),u=c*l,h=-c*o,f=t+u,g=e+h,v=n+u,b=r+h,d=(f+v)/2,x=(g+b)/2,S=v-f,w=b-g,y=S*S+w*w,T=a-i,p=f*b-v*g,k=(w<0?-1:1)*xr(cx(0,T*T*y-p*p)),_=(p*w-S*k)/y,E=(-p*S-w*k)/y,R=(p*w+S*k)/y,z=(-p*S+w*k)/y,I=_-d,N=E-x,U=R-d,M=z-x;return I*I+N*N>U*U+M*M&&(_=R,E=z),{cx:_,cy:E,x01:-u,y01:-h,x11:_*(a/T-1),y11:E*(a/T-1)}}function si(){var t=fx,e=hx,n=Vt(0),r=null,a=dx,i=px,s=gx,o=null,l=ai(c);function c(){var u,h,f=+t.apply(this,arguments),g=+e.apply(this,arguments),v=a.apply(this,arguments)-ni,b=i.apply(this,arguments)-ni,d=Cc(b-v),x=b>v;if(o||(o=u=l()),g<f&&(h=g,g=f,f=h),!(g>je))o.moveTo(0,0);else if(d>ri-je)o.moveTo(g*On(v),g*un(v)),o.arc(0,0,g,v,b,!x),f>je&&(o.moveTo(f*On(b),f*un(b)),o.arc(0,0,f,b,v,x));else{var S=v,w=b,y=v,T=b,p=d,k=d,_=s.apply(this,arguments)/2,E=_>je&&(r?+r.apply(this,arguments):xr(f*f+g*g)),R=$s(Cc(g-f)/2,+n.apply(this,arguments)),z=R,I=R,N,U;if(E>je){var M=Lc(E/f*un(_)),Y=Lc(E/g*un(_));(p-=M*2)>je?(M*=x?1:-1,y+=M,T-=M):(p=0,y=T=(v+b)/2),(k-=Y*2)>je?(Y*=x?1:-1,S+=Y,w-=Y):(k=0,S=w=(v+b)/2)}var C=g*On(S),F=g*un(S),H=f*On(T),V=f*un(T);if(R>je){var et=g*On(w),$=g*un(w),dt=f*On(y),wt=f*un(y),pt;if(d<ta)if(pt=yx(C,F,dt,wt,et,$,H,V)){var _t=C-pt[0],G=F-pt[1],ot=et-pt[0],O=$-pt[1],Q=1/un(ux((_t*ot+G*O)/(xr(_t*_t+G*G)*xr(ot*ot+O*O)))/2),X=xr(pt[0]*pt[0]+pt[1]*pt[1]);z=$s(R,(f-X)/(Q-1)),I=$s(R,(g-X)/(Q+1))}else z=I=0}k>je?I>je?(N=ii(dt,wt,C,F,g,I,x),U=ii(et,$,H,V,g,I,x),o.moveTo(N.cx+N.x01,N.cy+N.y01),I<R?o.arc(N.cx,N.cy,I,Le(N.y01,N.x01),Le(U.y01,U.x01),!x):(o.arc(N.cx,N.cy,I,Le(N.y01,N.x01),Le(N.y11,N.x11),!x),o.arc(0,0,g,Le(N.cy+N.y11,N.cx+N.x11),Le(U.cy+U.y11,U.cx+U.x11),!x),o.arc(U.cx,U.cy,I,Le(U.y11,U.x11),Le(U.y01,U.x01),!x))):(o.moveTo(C,F),o.arc(0,0,g,S,w,!x)):o.moveTo(C,F),!(f>je)||!(p>je)?o.lineTo(H,V):z>je?(N=ii(H,V,et,$,f,-z,x),U=ii(C,F,dt,wt,f,-z,x),o.lineTo(N.cx+N.x01,N.cy+N.y01),z<R?o.arc(N.cx,N.cy,z,Le(N.y01,N.x01),Le(U.y01,U.x01),!x):(o.arc(N.cx,N.cy,z,Le(N.y01,N.x01),Le(N.y11,N.x11),!x),o.arc(0,0,f,Le(N.cy+N.y11,N.cx+N.x11),Le(U.cy+U.y11,U.cx+U.x11),x),o.arc(U.cx,U.cy,z,Le(U.y11,U.x11),Le(U.y01,U.x01),!x))):o.arc(0,0,f,T,y,x)}if(o.closePath(),u)return o=null,u+""||null}return c.centroid=function(){var u=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,h=(+a.apply(this,arguments)+ +i.apply(this,arguments))/2-ta/2;return[On(h)*u,un(h)*u]},c.innerRadius=function(u){return arguments.length?(t=typeof u=="function"?u:Vt(+u),c):t},c.outerRadius=function(u){return arguments.length?(e=typeof u=="function"?u:Vt(+u),c):e},c.cornerRadius=function(u){return arguments.length?(n=typeof u=="function"?u:Vt(+u),c):n},c.padRadius=function(u){return arguments.length?(r=u==null?null:typeof u=="function"?u:Vt(+u),c):r},c.startAngle=function(u){return arguments.length?(a=typeof u=="function"?u:Vt(+u),c):a},c.endAngle=function(u){return arguments.length?(i=typeof u=="function"?u:Vt(+u),c):i},c.padAngle=function(u){return arguments.length?(s=typeof u=="function"?u:Vt(+u),c):s},c.context=function(u){return arguments.length?(o=u??null,c):o},c}var xx=Array.prototype.slice;function oi(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function jc(t){this._context=t}jc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);break}}};function li(t){return new jc(t)}function Cs(t){return t[0]}function Ls(t){return t[1]}function Bn(t,e){var n=Vt(!0),r=null,a=li,i=null,s=ai(o);t=typeof t=="function"?t:t===void 0?Cs:Vt(t),e=typeof e=="function"?e:e===void 0?Ls:Vt(e);function o(l){var c,u=(l=oi(l)).length,h,f=!1,g;for(r==null&&(i=a(g=s())),c=0;c<=u;++c)!(c<u&&n(h=l[c],c,l))===f&&((f=!f)?i.lineStart():i.lineEnd()),f&&i.point(+t(h,c,l),+e(h,c,l));if(g)return i=null,g+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Vt(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:Vt(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Vt(!!l),o):n},o.curve=function(l){return arguments.length?(a=l,r!=null&&(i=a(r)),o):a},o.context=function(l){return arguments.length?(l==null?r=i=null:i=a(r=l),o):r},o}function js(t,e,n){var r=null,a=Vt(!0),i=null,s=li,o=null,l=ai(c);t=typeof t=="function"?t:t===void 0?Cs:Vt(+t),e=typeof e=="function"?e:Vt(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?Ls:Vt(+n);function c(h){var f,g,v,b=(h=oi(h)).length,d,x=!1,S,w=new Array(b),y=new Array(b);for(i==null&&(o=s(S=l())),f=0;f<=b;++f){if(!(f<b&&a(d=h[f],f,h))===x)if(x=!x)g=f,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),v=f-1;v>=g;--v)o.point(w[v],y[v]);o.lineEnd(),o.areaEnd()}x&&(w[f]=+t(d,f,h),y[f]=+e(d,f,h),o.point(r?+r(d,f,h):w[f],n?+n(d,f,h):y[f]))}if(S)return o=null,S+""||null}function u(){return Bn().defined(a).curve(s).context(i)}return c.x=function(h){return arguments.length?(t=typeof h=="function"?h:Vt(+h),r=null,c):t},c.x0=function(h){return arguments.length?(t=typeof h=="function"?h:Vt(+h),c):t},c.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:Vt(+h),c):r},c.y=function(h){return arguments.length?(e=typeof h=="function"?h:Vt(+h),n=null,c):e},c.y0=function(h){return arguments.length?(e=typeof h=="function"?h:Vt(+h),c):e},c.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:Vt(+h),c):n},c.lineX0=c.lineY0=function(){return u().x(t).y(e)},c.lineY1=function(){return u().x(t).y(n)},c.lineX1=function(){return u().x(r).y(e)},c.defined=function(h){return arguments.length?(a=typeof h=="function"?h:Vt(!!h),c):a},c.curve=function(h){return arguments.length?(s=h,i!=null&&(o=s(i)),c):s},c.context=function(h){return arguments.length?(h==null?i=o=null:o=s(i=h),c):i},c}function mx(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function vx(t){return t}function bx(){var t=vx,e=mx,n=null,r=Vt(0),a=Vt(ri),i=Vt(0);function s(o){var l,c=(o=oi(o)).length,u,h,f=0,g=new Array(c),v=new Array(c),b=+r.apply(this,arguments),d=Math.min(ri,Math.max(-ri,a.apply(this,arguments)-b)),x,S=Math.min(Math.abs(d)/c,i.apply(this,arguments)),w=S*(d<0?-1:1),y;for(l=0;l<c;++l)(y=v[g[l]=l]=+t(o[l],l,o))>0&&(f+=y);for(e!=null?g.sort(function(T,p){return e(v[T],v[p])}):n!=null&&g.sort(function(T,p){return n(o[T],o[p])}),l=0,h=f?(d-c*w)/f:0;l<c;++l,b=x)u=g[l],y=v[u],x=b+(y>0?y*h:0)+w,v[u]={data:o[u],index:l,value:y,startAngle:b,endAngle:x,padAngle:S};return v}return s.value=function(o){return arguments.length?(t=typeof o=="function"?o:Vt(+o),s):t},s.sortValues=function(o){return arguments.length?(e=o,n=null,s):e},s.sort=function(o){return arguments.length?(n=o,e=null,s):n},s.startAngle=function(o){return arguments.length?(r=typeof o=="function"?o:Vt(+o),s):r},s.endAngle=function(o){return arguments.length?(a=typeof o=="function"?o:Vt(+o),s):a},s.padAngle=function(o){return arguments.length?(i=typeof o=="function"?o:Vt(+o),s):i},s}function ci(t,e){return[(e=+e)*Math.cos(t-=Math.PI/2),e*Math.sin(t)]}class wx{constructor(e){this._context=e}lineStart(){this._point=0}lineEnd(){}point(e,n){if(e=+e,n=+n,this._point===0)this._point=1;else{const r=ci(this._x0,this._y0),a=ci(this._x0,this._y0=(this._y0+n)/2),i=ci(e,this._y0),s=ci(e,n);this._context.moveTo(...r),this._context.bezierCurveTo(...a,...i,...s)}this._x0=e,this._y0=n}}function _x(t){return new wx(t)}function kx(t){return t.source}function Ax(t){return t.target}function Sx(t){let e=kx,n=Ax,r=Cs,a=Ls,i=null,s=null,o=ai(l);function l(){let c;const u=xx.call(arguments),h=e.apply(this,u),f=n.apply(this,u);if(i==null&&(s=t(c=o())),s.lineStart(),u[0]=h,s.point(+r.apply(this,u),+a.apply(this,u)),u[0]=f,s.point(+r.apply(this,u),+a.apply(this,u)),s.lineEnd(),c)return s=null,c+""||null}return l.source=function(c){return arguments.length?(e=c,l):e},l.target=function(c){return arguments.length?(n=c,l):n},l.x=function(c){return arguments.length?(r=typeof c=="function"?c:Vt(+c),l):r},l.y=function(c){return arguments.length?(a=typeof c=="function"?c:Vt(+c),l):a},l.context=function(c){return arguments.length?(c==null?i=s=null:s=t(i=c),l):i},l}function Mx(){const t=Sx(_x);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t}function Pc(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function Ec(t){this._context=t}Ec.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Pc(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Pc(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Rc(t){return new Ec(t)}function zc(t,e,n){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-e),t._y2+t._k*(t._y1-n),t._x2,t._y2)}function Ps(t,e){this._context=t,this._k=(1-e)/6}Ps.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:zc(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2,this._x1=t,this._y1=e;break;case 2:this._point=3;default:zc(this,t,e);break}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};const Ic=(function t(e){function n(r){return new Ps(r,e)}return n.tension=function(r){return t(+r)},n})(0);function Nx(t,e,n){var r=t._x1,a=t._y1,i=t._x2,s=t._y2;if(t._l01_a>je){var o=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,l=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*o-t._x0*t._l12_2a+t._x2*t._l01_2a)/l,a=(a*o-t._y0*t._l12_2a+t._y2*t._l01_2a)/l}if(t._l23_a>je){var c=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,u=3*t._l23_a*(t._l23_a+t._l12_a);i=(i*c+t._x1*t._l23_2a-e*t._l12_2a)/u,s=(s*c+t._y1*t._l23_2a-n*t._l12_2a)/u}t._context.bezierCurveTo(r,a,i,s,t._x2,t._y2)}function Fc(t,e){this._context=t,this._alpha=e}Fc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3;default:Nx(this,t,e);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};const Hc=(function t(e){function n(r){return e?new Fc(r,e):new Ps(r,0)}return n.alpha=function(r){return t(+r)},n})(.5);function Wc(t){this._context=t}Wc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=Oc(t),a=Oc(e),i=0,s=1;s<n;++i,++s)this._context.bezierCurveTo(r[0][i],a[0][i],r[1][i],a[1][i],t[s],e[s]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function Oc(t){var e,n=t.length-1,r,a=new Array(n),i=new Array(n),s=new Array(n);for(a[0]=0,i[0]=2,s[0]=t[0]+2*t[1],e=1;e<n-1;++e)a[e]=1,i[e]=4,s[e]=4*t[e]+2*t[e+1];for(a[n-1]=2,i[n-1]=7,s[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=a[e]/i[e-1],i[e]-=r,s[e]-=r*s[e-1];for(a[n-1]=s[n-1]/i[n-1],e=n-2;e>=0;--e)a[e]=(s[e]-a[e+1])/i[e];for(i[n-1]=(t[n]+a[n-1])/2,e=0;e<n-1;++e)i[e]=2*t[e+1]-a[e+1];return[a,i]}function Bc(t){return new Wc(t)}function ea(t,e){if((s=t.length)>1)for(var n=1,r,a,i=t[e[0]],s,o=i.length;n<s;++n)for(a=i,i=t[e[n]],r=0;r<o;++r)i[r][1]+=i[r][0]=isNaN(a[r][1])?a[r][0]:a[r][1]}function ui(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Tx(t,e){return t[e]}function Dx(t){const e=[];return e.key=t,e}function na(){var t=Vt([]),e=ui,n=ea,r=Tx;function a(i){var s=Array.from(t.apply(this,arguments),Dx),o,l=s.length,c=-1,u;for(const h of i)for(o=0,++c;o<l;++o)(s[o][c]=[0,+r(h,s[o].key,c,i)]).data=h;for(o=0,u=oi(e(s));o<l;++o)s[u[o]].index=o;return n(s,u),s}return a.keys=function(i){return arguments.length?(t=typeof i=="function"?i:Vt(Array.from(i)),a):t},a.value=function(i){return arguments.length?(r=typeof i=="function"?i:Vt(+i),a):r},a.order=function(i){return arguments.length?(e=i==null?ui:typeof i=="function"?i:Vt(Array.from(i)),a):e},a.offset=function(i){return arguments.length?(n=i??ea,a):n},a}function Yc(t,e){if((r=t.length)>0){for(var n,r,a=0,i=t[0].length,s;a<i;++a){for(s=n=0;n<r;++n)s+=t[n][a][1]||0;if(s)for(n=0;n<r;++n)t[n][a][1]/=s}ea(t,e)}}function Es(t,e){if((l=t.length)>0)for(var n,r=0,a,i,s,o,l,c=t[e[0]].length;r<c;++r)for(s=o=0,n=0;n<l;++n)(i=(a=t[e[n]][r])[1]-a[0])>0?(a[0]=s,a[1]=s+=i):i<0?(a[1]=o,a[0]=o+=i):(a[0]=0,a[1]=i)}function ra(t,e,n){this.k=t,this.x=e,this.y=n}ra.prototype={constructor:ra,scale:function(t){return t===1?this:new ra(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new ra(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}},ra.prototype;const Se=(t,e)=>{const n=bt.useRef(null);return bt.useEffect(()=>{e!==void 0&&n.current&&t(qt(n.current))},e===null?void 0:e),n};function Ne(){const t=bt.useRef(null),[e,n]=bt.useState({width:0,height:0});return bt.useEffect(()=>{const r=t.current;if(!r||!r.parentElement)return;const a=r.parentElement,i=()=>{const o=a.getBoundingClientRect();n({width:o.width,height:o.height})};i();const s=new ResizeObserver(()=>i());return s.observe(a),()=>s.disconnect()},[]),[t,e]}function fi(){const[t,e]=bt.useState(null);return bt.useEffect(()=>{const n=typeof document<"u"?document.getElementById("UI-controls"):null;e(n)},[]),t}const Oe={tooltip:"_tooltip_cqxcs_3","tooltip--arrow-up":"_tooltip--arrow-up_cqxcs_71","tooltip--arrow-down":"_tooltip--arrow-down_cqxcs_99",title:"_title_cqxcs_165","text-small":"_text-small_cqxcs_197","right-label":"_right-label_cqxcs_225"},Qe=({pCount:t,children:e})=>m.jsxs("div",{id:"tooltip",className:`${Oe.tooltip}`,style:{opacity:0},children:[e,!t&&!e&&m.jsx("p",{className:`top-label ${Oe["text-small"]}`}),t===2&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:`top-label ${Oe["text-small"]}`}),m.jsx("p",{className:`bottom-label ${Oe["text-small"]}`})]}),(t===3||t===4)&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:`title ${Oe.title}`}),m.jsx("p",{className:`top-label ${Oe["right-label"]}`}),m.jsx("p",{className:`bottom-label ${Oe["right-label"]}`})]}),t===4&&m.jsx("p",{className:`small-text ${Oe["right-label"]} ${Oe["small-text"]}`})]}),hi=(t,e="tooltip")=>t.select(`#${e}`).style("opacity",0);function $x(t,e,n){const{top:r,height:a}=e.getBoundingClientRect(),i=t.clientY-r;return{pixelY:i,dataY:n?.invert(i)??0,svgHeight:a}}function le(t,e){const{e:n,svg:r,yScale:a}=e,{pixelY:i,svgHeight:s}=$x(n,r,a),l=(t.node()?.getBoundingClientRect()).height??100,u=((d=.5)=>i+l-s>l*d)(),h=i<l?u?"top":"bottom":"top",{offsetWidth:f,offsetHeight:g}=t.node()||{};typeof document<"u"&&document.documentElement.clientWidth;const v=n.x-f/2,b=h==="top"?Oe["tooltip--arrow-down"]:Oe["tooltip--arrow-up"];t.attr("class",`${Oe.tooltip} ${b}`).style("left",v+"px").style("top",h==="top"?n.y-(g+20)+"px":n.y+30+"px")}function Dn(t,e){const{offsetWidth:n,offsetHeight:r}=e.node()||{},a=document.documentElement.clientWidth,i=t.x-n/2;let s=0;if(i<0)s=0;else if(i+n>a){const o=i+n-a;s=i-o}else s=i;e.style("left",s+"px").attr("class",`${Oe.tooltip} ${Oe["tooltip--arrow-down"]}`).style("top",t.y-(r+10)+"px")}const we=t=>{try{return JSON.parse(JSON.stringify(t))}catch{return console.log("error when cloning object : "),Array.isArray(t)?[]:null}},mr=["#34D399","#6ee7b7","#10b981","#059669","#bef264","#a3e635","#84cc16","#86efac","#4ade80","#16a34a","#5eead4","#2dd4bf","#14b8a6","#67e8f9","#22d3ee","#06b6d4","#7dd3fc","#38bdf8","#0ea5e9","#93c5fd","#60a5fa","#3b82f6","#a5b4fc","#818cf8","#6366f1","#a78bfa","#8b5cf6","#7c3aed","#d8b4fe","#c084fc","#a855f7","#f9a8d4","#f472b6","#ec4899","#fb7185","#f43f5e","#db2777","#fca5a5","#f87171","#ef4444","#fdba74","#fb923c","#f97316","#fcd34d","#fbbf24","#f59e0b","#fde047","#facc15","#eab308"],Cx=of([...Nc,...Mc,...Tc,...Dc,...qr]),Uc=[...Nc,...Mc,...Tc,...Dc,...qr],de=(t,e=!0,n=!1)=>{const r=n?Cx:e?[...mr,...Uc]:[...Uc,...mr];return t<r.length?r[t]:r[t%r.length]},vr=t=>t<mr.length?mr[t]:mr[t%mr.length],Pe=(t,{formatType:e="long",prefix:n="",suffix:r=""}={})=>n+pe(e==="long"?",":"~s")(t)+r,Yn=(t,e="long")=>t<0?t.toFixed(4):e==="long"?pe(",")(t):pe("~s")(t),_e=(t,e)=>{const{formatType:n,prefix:r,suffix:a}=e,i=t<0?"-":"",s=Yn(Math.abs(t),n);return`${r}${i}${s}${a}`};function Lx(t){return t instanceof Date?!0:/^\d{4}-\d{2}-\d{2}$/.test(t)&&!Number.isNaN(new Date(t).getTime())}const di=(t,e)=>t<640&&e.length>3||t<768&&e.length>4||t<1024&&e.length>7||t<1280&&e.length>9,Rs=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function aa(t,e,n,r,a,i="vertical",s={showLine:!1,showDots:!0,curve:"linear"}){const{data:o,idExtension:l}=r,c=Bn().x(_=>i==="vertical"?(e.scale(_.label)??0)+e.offset:n(_.value)).y(_=>i==="horizontal"?(e.scale(_.label)??0)+e.offset:n(_.value)),{curve:u,showLine:h,showDots:f,lineStroke:g,dotFill:v}=s;u==="linear"?c.curve(li):u==="basis"?c.curve(Rc):u==="cardinal"?c.curve(Ic):u==="catmullrom"?c.curve(Hc):u==="natural"&&c.curve(Bc);const d=a>576?3:2,x=g??"#594c5b",S=500,w=h?[o]:[],y=t.selectAll(l?`path.chartline${l}`:"path.chartline").data(w).join(_=>_.append("path").attr("class",l?`chartline${l}`:"chartline").attr("fill","none").attr("stroke",x).attr("stroke-width",2).style("stroke-opacity",.75).style("pointer-events","none"),void 0,_=>_.remove());y.transition().duration(S).attr("d",_=>c(_)).attr("stroke",x),y.raise();const T=_=>i==="vertical"?(e.scale(_.label)??0)+e.offset:n(_.value),p=_=>i==="vertical"?n(_.value):(e.scale(_.label)??0)+e.offset,k=h&&f?o:[];t.selectAll(l?`.dot${l}`:".dot").data(k,_=>l?String(_.label)+l:String(_.label)).join(_=>_.append("circle").attr("class",l?`dot${l}`:"dot").attr("cx",function(E){return i==="horizontal"?n(0):(e.scale(E.label)??0)+e.offset}).attr("cy",function(E){return i==="vertical"?n(0):(e.scale(E.label)??0)+e.offset}).attr("fill",x).attr("r",0).style("pointer-events","none").transition().duration(S).attr("cx",T).attr("cy",p).attr("r",d),void 0,_=>_.transition().duration(S).style("opacity",0).remove()).transition().duration(S).attr("cx",T).attr("cy",p).attr("r",d).attr("fill",x)}const Un=t=>Number.isFinite(t),Ee="#d1d5db",J={"controls-container":"_controls-container_1nadu_1","controls-container-sm":"_controls-container-sm_1nadu_1","fill-container":"_fill-container_1nadu_39","controls-label":"_controls-label_1nadu_55",disabled:"_disabled_1nadu_99","controls-checkbox":"_controls-checkbox_1nadu_109",button:"_button_1nadu_139","chart-svg":"_chart-svg_1nadu_167","value-axis":"_value-axis_1nadu_177","legends-container":"_legends-container_1nadu_199","legend-container":"_legend-container_1nadu_259","legend-container-active":"_legend-container-active_1nadu_259","legend-container-inactive":"_legend-container-inactive_1nadu_259","legend-container-sm":"_legend-container-sm_1nadu_261","legend-container-active-sm":"_legend-container-active-sm_1nadu_261","legend-container-inactive-sm":"_legend-container-inactive-sm_1nadu_261","legend-rect":"_legend-rect_1nadu_323","legend-label":"_legend-label_1nadu_363",rotatedTopAxisText:"_rotatedTopAxisText_1nadu_481",rotatedAxisText:"_rotatedAxisText_1nadu_491",axisText:"_axisText_1nadu_501",bar:"_bar_1nadu_511",shadowed_text:"_shadowed_text_1nadu_531"},Vc={rotatedAxisText:"_rotatedAxisText_1tba7_1",axisText:"_axisText_1tba7_11"},rn=t=>{const e=bt.useRef([]);return bt.useEffect(()=>{const n=e.current;if(t.length===0){e.current=[];return}const r=t.some(i=>n.includes(i)),a=t.filter(i=>!n.includes(i));if(!r){e.current=[...t];return}if(a.length>0){e.current=[...n,...a];return}},[t]),e};function jx({data:t,color:{idx:e=0,type:n="fixed"}={idx:0,type:"fixed"},orientation:r="vertical",tooltipFormat:{prefix:a="",suffix:i="",formatType:s="long"}={prefix:"",suffix:"",formatType:"long"},lineProps:{showLine:o=!1,showDots:l=!0,curve:c="linear"}={showLine:!1,showDots:!0,curve:"linear"}}){const[u,h]=Ne(),{width:f,height:g}=h,[v,b]=bt.useState(!1),d=rn(t.map(k=>String(k.label))),x=fi(),S=f>576,w=m.jsx("div",{id:"controls",className:`${J[S?"controls-container":"controls-container-sm"]} ${x?J["fill-container"]:""}`,children:m.jsxs("label",{className:J["controls-label"],children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:v,onChange:k=>b(k.target.checked)}),"Sort"]})}),y={idx:e,type:n},T=750,p=Se(k=>{if(f===0||g===0)return;const _={top:20,right:30,bottom:r==="vertical"?50:30,left:r==="vertical"?25:50},E=v?we(t).sort((O,Q)=>Q.value-O.value):we(t),R=k.select("svg"),z=R.node(),I=R.select(".plot-area").attr("transform","translate("+_.left+","+_.top+")"),N=k.select("#tooltip").style("opacity",0),U=S?Vc.axisText:Vc.rotatedAxisText,M=f-_.left-_.right,Y=g-_.top-_.bottom,C=Xe().domain(E.map(O=>String(O.label))).rangeRound(r==="vertical"?[0,M]:[Y,0]).paddingInner(S?.4:.25).paddingOuter(.1),F=oe(E,O=>O.value)??0,H=Math.min(0,F),V=Gt(E,O=>O.value)??0,et=Math.max(0,V),$=ye().domain([H,et]).rangeRound(r==="vertical"?[Y,0]:[0,M]).nice(),dt=r==="vertical"?he(C).tickValues(C.domain()).scale(C).tickSizeOuter(0):he($).ticks(5,"s").tickSizeOuter(0).tickSize(-Y);I.select(".x-axis").attr("transform",`translate(0, ${Y})`).transition().duration(T).call(dt).selectAll("text").attr("class",U);const wt=r==="vertical"?be($).ticks(5,"s").tickSize(-M):be(C).tickSizeOuter(0);I.select(".y-axis").attr("transform","translate(0, 0)").transition().duration(T).call(wt);const pt=O=>{const{idx:Q,type:X}=y,D=d.current.findIndex(tt=>tt===String(O.label));return vr(X==="fixed"?Q:Q+D)},_t=O=>r==="vertical"?O>=0?$(O):$(0):O>=0?$(0):$(O),G=O=>{const Q=Math.abs($(O)-$(0));return isNaN(Q)||Q<0?0:Q},ot={prefix:a,suffix:i,formatType:s};I.selectAll(".bar").data(E,O=>String(O.label)).join(O=>O.append("rect").attr("class",`bar ${J.bar}`).attr("x",function(Q){return r==="vertical"?C(String(Q.label))??0:$(0)}).attr("width",function(Q){return r==="vertical"&&C.bandwidth()>0?C.bandwidth():0}).attr("y",function(Q){return r==="vertical"?$(0):C(String(Q.label))??0}).attr("height",function(){return r==="vertical"?0:Math.max(C.bandwidth(),0)}).attr("fill",pt).transition().duration(T).attr("y",function(Q){return r==="vertical"?_t(Q.value):C(String(Q.label))??0}).attr("width",function(Q){return r==="vertical"?Math.max(C.bandwidth(),0):G(Q.value)}).attr("height",function(Q){return r==="vertical"?G(Q.value):C.bandwidth()>0?0:C.bandwidth()}),void 0,O=>O.transition().duration(T).attr("fill",Ee).attr("height",0).attr("y",g).style("opacity",0).remove()).on("pointerenter",(O,Q)=>{N.style("opacity",1),N.select("p.label span.chev").style("background",pt(Q)),N.select("p.label span.value").text(String(Q.label)+""),N.select("p.value").text(_e(Q.value,ot)),le(N,{e:O,svg:z,yScale:$}),(r==="vertical"?k.select(".x-axis"):k.select(".y-axis")).selectAll("text").filter(D=>D===String(Q.label)).style("font-weight","bold")}).on("pointermove",(O,Q)=>{le(N,{e:O,svg:z,yScale:$})}).on("pointerleave",(O,Q)=>{N.style("opacity",0),(r==="vertical"?k.select(".x-axis"):k.select(".y-axis")).selectAll("text").filter(D=>D===String(Q.label)).style("font-weight","normal")}).transition().duration(T).attr("fill",pt).attr("x",function(O){return r==="vertical"?C(String(O.label))??0:_t(O.value)}).attr("width",function(O){return r==="vertical"?C.bandwidth():G(O.value)}).attr("y",function(O){return r==="vertical"?_t(O.value):C(String(O.label))??0}).attr("height",function(O){return r==="vertical"?G(O.value):C.bandwidth()}),aa(I,{scale:C,offset:C.bandwidth()/2},$,{data:E},f,r,{showLine:o,showDots:l,curve:c})},[t,y,f,g,v,r,{prefix:a,suffix:i,formatType:s},{showLine:o,showDots:l,curve:c}]);return m.jsxs("div",{ref:u,style:{width:f,height:g,display:"flex",flexDirection:"column"},children:[x&&Ru.createPortal(w,x),m.jsxs("div",{ref:p,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${f} ${g}`,children:m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`${r==="vertical"?J["value-axis"]:""} y-axis`}),m.jsx("g",{className:`${r==="horizontal"?J["value-axis"]:""} x-axis`})]})}),!x&&m.jsxs("label",{className:J["controls-label"],style:{position:"absolute",right:"12px",top:"6px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:v,onChange:k=>b(k.target.checked)}),"Sort"]}),m.jsxs(Qe,{children:[m.jsxs("p",{className:"label",style:{fontWeight:600,margin:"3px",fontSize:"12px",color:"wheat",display:"flex",justifyContent:"center",alignItems:"center",gap:2},children:[m.jsx("span",{className:"chev",style:{width:10,height:10,borderRadius:2}}),m.jsx("span",{className:"value"})]}),m.jsx("p",{className:"value",style:{fontWeight:700,margin:"3px",fontSize:"13px",color:"wheat",textAlign:"center"}})]})]})]})}const an={rotatedAxisText:"_rotatedAxisText_y6xfd_1",axisText:"_axisText_y6xfd_11","value-axis":"_value-axis_y6xfd_21","time-axis":"_time-axis_y6xfd_41"};function Px({data:t,type:e="line",xKey:n,yValue:r,withBrush:a=!1,colorIdx:i=0,tooltipFormat:s={prefix:"",suffix:""}}){const[o,l]=Ne(),{width:c,height:u}=l,h=750,f=[t,e,n,r,a,i,c,u,s],g={top:10,right:30,bottom:25,left:60},v=c>576,b=t.map(S=>S.title),d=rn(b),x=Se(S=>{if(c===0||u===0)return;const w=40,y=w+g.bottom,T=c-g.left-g.right,p=u-g.top-g.bottom,k=p-(a?y:0),_=S.select("svg");_.node();const E=_.select(".plot-area").attr("transform","translate("+g.left+","+g.top+")"),R=E.select("line.tooltipLine").attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",k).attr("stroke","#5b4f4b").attr("stroke-width",1).attr("fill","none").style("stroke-dasharray","3 3").style("opacity",0),z=_.select("defs");z.select("clipPath").select("rect").attr("width",T<0?0:T).attr("height",p);const N=t[0].datum[0][n],U=Lx(N),M=oe(t,function(A){return oe(A.datum,function(j){return U?new Date(j[n]):typeof j[n]=="number"?j[n]:Number(j[n])})}),Y=Gt(t,function(A){return Gt(A.datum,function(j){return U?new Date(j[n]):typeof j[n]=="number"?j[n]:Number(j[n])})}),C=[M,Y],F=U?ti().domain(C):ye().domain(C);F.range([0,T]);const H=di(T,U?[M,Y]:[]),V=U?v?an.axisText:an.rotatedAxisText:H,{prefix:et,suffix:$}=s;E.select(".x-axis").attr("transform","translate(0,"+k+")").transition().duration(h).call(he(F)).selectAll("text").attr("class",V);const dt=oe(t,A=>oe(A.datum,function(j){const nt=j[r];return typeof nt=="number"?nt:void 0}))??0,wt=Gt(t,A=>Gt(A.datum,function(j){const nt=j[r];return typeof nt=="number"?nt:void 0}))??0,pt=ye().domain([dt,wt]).rangeRound([k,0]).nice(),_t=be(pt).tickSize(-T);E.select(".y-axis").transition().duration(h).call(_t),E.selectAll("path.chartline").remove(),E.selectAll("path.chartarea").remove();const G=Bn().x(A=>F(U?new Date(A[n]):A[n])).y(A=>pt(Number(A[r]))),ot=A=>{const j=d.current.findIndex(nt=>nt===t[A].title)+i;return de(j,!1,!0)},O=E.selectAll("g.lineGroup").data(t,A=>A.title).join(A=>A.append("g").attr("class","lineGroup"),A=>A,A=>A.remove());z.selectAll("linearGradient").remove();const Q=js().x(A=>F(U?new Date(A[n]):A[n])).y0(k).y1(A=>pt(Number(A[r])));e==="area"&&(t.map(j=>j.title).forEach((j,nt)=>{const $t=Rs(j),W=z.append("linearGradient").attr("id",$t).attr("x1","0%").attr("y1","0%").attr("x2","0%").attr("y2","100%"),K=de(nt,!1,!0);W.append("stop").attr("offset","0%").attr("stop-color",K).attr("stop-opacity",.7),W.append("stop").attr("offset","100%").attr("stop-color",K).attr("stop-opacity",0)}),O.selectAll("path.chartarea").data(function(j){return[j.datum]}).join(j=>j.append("path").attr("class","chartarea").attr("stroke","none").attr("fill",function(){const nt=qt(this.parentNode).datum(),{title:$t}=nt;return`url(#${Rs($t)})`}).attr("d",nt=>G(nt)).attr("clip-path","url(#clip)").style("pointer-events","none"),void 0,j=>j.remove()).attr("d",j=>Q(j))),O.selectAll("path.chartline").data(function(A){return[A.datum]}).join(A=>A.append("path").attr("class","chartline").attr("fill","none").attr("stroke",function(){const j=qt(this.parentNode).datum(),nt=d.current.findIndex($t=>$t===j.title)+i;return de(nt,!1,!0)}).attr("stroke-width",2).attr("d",j=>G(j)).attr("clip-path","url(#clip)").style("pointer-events","none"),void 0,A=>A.remove()).attr("d",A=>G(A));const X=3,D=O.selectAll("circle.tooltipCircle").data(function(A){return[A.datum]}).join(A=>A.append("circle").attr("class","tooltipCircle").attr("cx",20).attr("cy",30).attr("r",X).attr("fill",function(){const j=qt(this.parentNode).datum(),nt=d.current.findIndex($t=>$t===j.title)+i;return de(nt,!1,!0)}).style("opacity",0),void 0,A=>A).attr("cx",20).attr("cy",30).attr("r",X).attr("fill",function(){const A=qt(this.parentNode).datum(),j=d.current.findIndex(nt=>nt===A.title)+i;return de(j,!1,!0)}),tt=E.select("g.tooltip").style("pointer-events","none");tt.raise(),E.select("rect.overlay").attr("width",T<0?0:T).attr("height",k).style("fill","red").style("opacity",0).on("pointerenter pointermove",L).on("pointerleave",Z).on("touchstart",A=>A.preventDefault());function L(A){const j=Nr(ut=>U?new Date(ut[n]):ut[n]).center,nt=j(t[0].datum,F.invert(tr(A)[0])),$t=t[0].datum[nt],W=oe(t,function(ut){return Number(ut.datum[nt][r])}),K=[];for(let ut=0;ut<t.length;ut++){const{title:vt}=t[ut],At=t[ut].datum[nt],jt=String(At[n]),Xt=Number(At[r]);D.filter(function(){return qt(this.parentNode).datum().title===vt}).attr("cx",F(U?new Date(At[n]):At[n])).attr("cy",pt(Xt)).style("opacity",1),K.push({title:vt,label:jt,value:Xt})}const Ct=F(U?new Date(t[0].datum[nt][n]):t[0].datum[nt][n]);R.style("opacity",1).attr("x1",Ct).attr("x2",Ct),ft(K);const Rt=5,q=F(U?new Date($t[n]):$t[n]),Tt=pt(W??0)+X+Rt;tt.transition().duration(100).style("display",null).attr("transform",`translate(${q},${Tt})`)}function Z(A){tt.transition().duration(250).style("display","none"),D.style("opacity",0),R.style("opacity",0),a&&it.transition().duration(h/4).style("opacity",1)}function ft(A){const j=tt.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),nt=A.reduce((W,K)=>{const Ct=K.title,Rt=K.label+": "+(et??"")+K.value+($??"");return W.push(Ct),W.push(Rt),W},[]),$t=tt.selectAll("text").data([null]).join("text").call(W=>W.selectAll("tspan").data(nt).join("tspan").attr("x",0).attr("y",(K,Ct)=>`${Ct*1.1}em`).style("align","right").text(K=>K));st($t,j),a&&it.transition().duration(h/4).style("opacity",0)}function st(A,j){const{x:nt,y:$t,width:W,height:K}=A.node().getBBox();A.attr("transform",`translate(${-W/2},${15-$t})`),j.attr("d",`M${-W/2-10},5H-5l5,-5l5,5H${W/2+10}v${K+20}h-${W+20}z`)}const it=_.select(".brush-area").attr("transform","translate("+g.left+","+(k+g.top+g.bottom)+")");if(it.selectAll("path.line").remove(),it.selectAll("path.area").remove(),it.selectAll("g.brush").remove(),a){let A=function(Ct){const Rt=Ct.selection;if(Rt)F.domain([j.invert(Rt[0]),j.invert(Rt[1])]);else if(!Rt||Rt===null){const q=C;F.domain(q)}K()};const j=U?ti().domain(C):ye().domain(C);j.range([0,T]);const nt=ye().domain([dt,wt]).range([w,0]),$t=Bn().x(Ct=>F(U?new Date(Ct[n]):Ct[n])).y(Ct=>nt(Number(Ct[r])));for(let Ct=0;Ct<t.length;Ct++){if(e==="area"){const Rt=js().x(q=>F(U?new Date(q[n]):q[n])).y0(w).y1(q=>nt(Number(q[r])));it.append("path").datum(t[Ct].datum).attr("class","area").attr("fill",function(){const q=t[Ct].title;return`url(#${Rs(q)})`}).attr("stroke","none").attr("d",Rt).attr("clip-path","url(#clip)")}it.append("path").datum(t[Ct].datum).attr("class","line").attr("fill","none").attr("stroke",ot(Ct)).attr("stroke-width",2).attr("d",$t).attr("clip-path","url(#clip)")}it.select(".x-axis").attr("transform","translate(0,"+w+")").call(he(j)).selectAll("text").attr("class",V);const W=Sl().extent([[0,0],[c,w]]).on("brush",A);it.append("g").attr("class","brush").call(W),_.on("dblclick",function(){F.domain(C),it.select(".brush").call(W.move,null),K()});const K=()=>{E.select(".x-axis").call(he(F)).selectAll("text").attr("class",V),e==="area"&&E.selectAll("path.chartarea").attr("d",Q),E.selectAll("path.chartline").attr("d",G)}}},[...f,s]);return m.jsx("div",{ref:o,style:{width:c,height:u,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:x,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsx("div",{className:`${J[v?"controls-container":"controls-container-sm"]}`,style:{gap:2,height:24}}),m.jsxs("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${c} ${u}`,children:[m.jsx("defs",{children:m.jsx("clipPath",{id:"clip",children:m.jsx("rect",{})})}),c>0&&m.jsxs(m.Fragment,{children:[m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`x-axis ${an["time-axis"]}`}),m.jsx("g",{className:`y-axis ${an["value-axis"]}`}),m.jsx("line",{className:"tooltipLine"}),m.jsx("rect",{className:"overlay"}),m.jsx("g",{className:"tooltip"})]}),m.jsx("g",{className:"brush-area",children:m.jsx("g",{className:`x-axis ${an["time-axis"]}`})})]})]})]})})}function He(){const t=bt.useRef(null),[e,n]=bt.useState({width:0,height:0});return bt.useEffect(()=>{const r=t.current;if(!r)return;const a=new ResizeObserver(([i])=>{i?.contentRect&&n({width:i.contentRect.width,height:i.contentRect.height})});return a.observe(r,{box:"border-box"}),n({width:r.offsetWidth,height:r.offsetHeight}),()=>{a.disconnect()}},[]),[t,e]}const fn={legend:"_legend_7ftsg_1","legend-active":"_legend-active_7ftsg_1","legend-rect":"_legend-rect_7ftsg_21","legend-label":"_legend-label_7ftsg_35",pieSlice:"_pieSlice_7ftsg_77",pieSliceNotHovered:"_pieSliceNotHovered_7ftsg_87",animateNotHovered:"_animateNotHovered_7ftsg_1",pieSliceExit:"_pieSliceExit_7ftsg_111",animateHide:"_animateHide_7ftsg_1",pieLabelEnter:"_pieLabelEnter_7ftsg_129",showText:"_showText_7ftsg_1",pieLabelUnhover:"_pieLabelUnhover_7ftsg_153",pieLabelUpdate:"_pieLabelUpdate_7ftsg_183",pieLabelExit:"_pieLabelExit_7ftsg_197"};function Ex({data:t,innerRadius:e=0,sortWithLegends:n=!1,colorIdx:r=0}){const[a,i]=Ne(),{width:s,height:o}=i,[l,c]=He(),{width:u,height:h}=c,f=rn(t.map(k=>k.label)),[g,v]=bt.useState([]),[b,d]=bt.useState(!1),[x,S]=bt.useState(""),w=750,y=Se(k=>{const E=(n&&b?we(t).sort((z,I)=>z.value-I.value):t).map(z=>z.label);k.selectAll(".legend-item").data([...E],z=>z).join(z=>{const I=z.append("div").attr("class",function(N){return`${fn[N===x?"legend-active":"legend"]} legend-item`}).style("left","-10px").style("top",function(N,U){return`${U*20+10}px`}).style("opacity",0);return I.append("div").attr("class",`rect ${fn["legend-rect"]}`).style("background-color",N=>vr(f.current.findIndex(U=>U===N)+r)),I.append("span").attr("class",fn["legend-label"]).style("color",N=>"#333").text(N=>N),I.transition().duration(w).style("left","6px").style("opacity",1),I},z=>(z.attr("class",I=>`
|
|
7
|
-
${fn[I===x?"legend-active":"legend"]} legend-item`).transition().duration(w).style("top",function(I,N){return`${N*20+10}px`}).style("left","6px").style("opacity",1).select("div.rect").attr("class",`rect ${fn["legend-rect"]}`).style("background-color",I=>vr(f.current.findIndex(N=>N===I)+r)),z.select("span").style("color",I=>"#333").text(I=>I),z),z=>z.transition().duration(w).style("opacity",0).style("left","30px").remove()).on("mouseover",(z,I)=>{S(I)}).on("mouseout",()=>{S("")})},[t,r,u,h,x,b,n]),T=Se(k=>{if(u===0||h===0)return;const _={x:u/2,y:h/2},E={top:10,right:20,bottom:10,left:20},R=t,z=u-(E.left+E.right),I=h-(E.top+E.bottom),N=Math.min(z,I)/2,U=R.reduce((X,D)=>X+D.value,0),M=k.select(".plot-area").attr("transform","translate("+_.x+","+_.y+")"),Y=bx().value(function(X){return X.value}).sort(function(X,D){return b?Ln(X.value,D.value):0}),C=we(R),F=Y(C),H=we(C);v(Y(H));let V=H.length>C.length;const et=g.map(X=>X.data.label),$=F.map(X=>X.data.label);et.every(X=>V?!1:$.includes(X)?!0:(V=!0,!1));const dt=g.length===0,pt=si().innerRadius(e*N).outerRadius(N-12),_t=si().innerRadius(e*N).outerRadius(N),G=(X,D)=>{const tt=Ae(D==="exit"?X.endAngle:X.startAngle,D==="exit"?X.startAngle:X.endAngle),L=X.data.label===x;return function(Z){return X.endAngle=tt(Z),L?_t(X)||"":pt(X)||""}};M.selectAll("path").data(F,function(X){return X.data.label}).join(X=>{const D=X.append("path").attr("class",fn.pieSlice).attr("fill",function(tt){const L=f.current.findIndex(Z=>Z===tt.data.label)+r;return vr(L)});return D.transition().duration(w).delay(dt?0:w).attr("d",pt).attrTween("d",function(tt){if(!dt)return G(tt,"not exit");const L=Ae(0,tt.startAngle),Z=Ae(0,tt.endAngle),ft=tt.data.label===x;return function(st){return tt.startAngle=L(st),tt.endAngle=Z(st),ft?_t(tt):pt(tt)}}),D},X=>{const D=X;return X.transition().duration(w).attr("fill",function(tt,L){const Z=f.current.findIndex(ft=>ft===tt.data.label)+r;return vr(Z)}).attrTween("d",function(tt){const L=g.find(j=>j.data.label===tt.data.label),Z=L&&L.startAngle?L.startAngle:0,ft=Ae(Z,tt.startAngle),st=L&&L.endAngle?L.endAngle:0,it=Ae(st,tt.endAngle),A=tt.data.label===x;return function(j){return tt.startAngle=ft(j),tt.endAngle=it(j),A?_t(tt)||"":pt(tt)||""}}),D},X=>X.attr("class",fn.pieSliceExit).transition().duration(w).attr("fill",Ee).attrTween("d",function(D){return G(D,"exit")}).remove()).on("mouseover",function(X,D){S(D.data.label)}).on("mouseout",()=>{S("")});const O=X=>R.length===1?"translate(0, 0)":`translate(${pt.centroid(X)})`,Q=X=>{const D=X.value/U;return pe(".1%")(D)};M.selectAll("text").data(F,function(X){return X.data.label}).join(X=>{const D=X.append("text").text(Q).attr("class",fn.pieLabelEnter);return D.merge(D).transition().duration(w).delay(w).attr("transform",O),D},X=>{const D=X.text(Q);return X.merge(D).attr("class",fn.pieLabelUpdate).transition().duration(x!==""?250:w).style("opacity",function(tt){const L=x===tt.data.label;return x===""||L?1:0}).attr("transform",O),D},X=>X.transition().duration(w/2).attr("class",fn.pieLabelExit).remove())},[t,r,e,u,h,b,x]),p=s>o;return m.jsxs("div",{ref:a,style:{width:s,height:o,position:"relative",display:"flex",flexDirection:p?"row":"column",overflow:"hidden"},children:[m.jsx("div",{ref:l,style:{flex:1,position:"relative",display:"flex"},children:m.jsx("svg",{ref:T,className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${u} ${h}`,children:m.jsx("g",{className:"plot-area"})})}),m.jsx("div",{style:{width:p?s>480?"180px":"100px":"100%",height:p?"100%":o>400?"180px":"100px",flexShrink:0,overflowY:"auto",background:"rgba(255, 255, 255)",borderLeft:p?"1px solid #ddd":"none",borderTop:p?"none":"1px solid #ddd",padding:"0px"},children:m.jsx("div",{ref:y,className:"legends-content",style:{display:"flex",flexDirection:"column",gap:"6px",padding:"8px 8px 16px 8px",boxSizing:"border-box",position:"relative"}})}),m.jsxs("label",{className:J["controls-label"],style:{position:"absolute",left:"12px",top:"6px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:b,onChange:k=>d(k.target.checked)}),"Sort"]})]})}const pi=({totalLabel:t="of total"})=>m.jsxs(Qe,{children:[m.jsx("p",{className:"label",style:{fontWeight:700,margin:"3px",fontSize:"14px",color:"wheat",textAlign:"center",borderBottom:"1px solid wheat"}}),m.jsxs("p",{className:"layer",style:{fontWeight:700,margin:"3px",marginTop:0,fontSize:"13px",color:"wheat",display:"flex",justifyContent:"flex-end",alignItems:"center",gap:2},children:[m.jsxs("span",{className:"label",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:1.5},children:[m.jsx("span",{className:"chev",style:{width:10,height:10,borderRadius:2}}),m.jsx("span",{className:"label"})]}),m.jsx("span",{className:"value",style:{textAlign:"right"}})]}),m.jsxs("p",{className:"total",style:{fontWeight:600,margin:"3px",marginTop:0,fontSize:"13px",color:"wheat",display:"flex",justifyContent:"flex-end",alignItems:"center",gap:2},children:[t,m.jsx("span",{className:"value",style:{fontWeight:700}})]})]}),It={"legends-container":"_legends-container_7rrtc_1","legend-container":"_legend-container_7rrtc_61","legend-container-active":"_legend-container-active_7rrtc_61","legend-container-inactive":"_legend-container-inactive_7rrtc_61","legend-container-sm":"_legend-container-sm_7rrtc_63","legend-container-active-sm":"_legend-container-active-sm_7rrtc_63","legend-container-inactive-sm":"_legend-container-inactive-sm_7rrtc_63","legend-rect":"_legend-rect_7rrtc_125","legend-label":"_legend-label_7rrtc_159",rect:"_rect_7rrtc_277",rectCard:"_rectCard_7rrtc_277",rectLegendNotHovered:"_rectLegendNotHovered_7rrtc_297",legend:"_legend_7rrtc_1",rectHoveredLegend:"_rectHoveredLegend_7rrtc_333",rectCardLegendHovered:"_rectCardLegendHovered_7rrtc_343",rectLegendHovered:"_rectLegendHovered_7rrtc_355",groupedRectNotHovered:"_groupedRectNotHovered_7rrtc_377",rotatedAxisText:"_rotatedAxisText_7rrtc_385",axisText:"_axisText_7rrtc_395",hoveredAxisText:"_hoveredAxisText_7rrtc_405",yAxisLabel:"_yAxisLabel_7rrtc_419","label-axis":"_label-axis_7rrtc_437",tick:"_tick_7rrtc_429",domain:"_domain_7rrtc_429","value-axis":"_value-axis_7rrtc_445"};function Rx({data:t,focusOnPlot:e=!1,colorIdx:n=0,orientation:r="vertical",tooltipFormat:{prefix:a="",suffix:i="",formatType:s="long"}={prefix:"",suffix:"",formatType:"long"}}){const[o,l]=Ne(),{width:c,height:u}=l,[h,f]=He(),{height:g}=f,[v,b]=He(),{width:d,height:x}=b,[S,w]=bt.useState(null),[y,T]=bt.useState(!1),[p,k]=bt.useState(["all"]),[_,E]=bt.useState(!1),[R,z]=bt.useState(!1);fi();const I=t;bt.useEffect(()=>{k(["all"]),T(!0)},[I]),bt.useEffect(()=>{k(["all"])},[e]);const N=750;bt.useEffect(()=>{let V;return y&&(V=setTimeout(()=>{T(!1)},N+500)),()=>{clearTimeout(V)}},[y]);const U=[d,x,p,n,e],M=we(I),Y=M.length===0?[]:Object.keys(M[0]).filter(V=>V!=="label"&&V!=="total"),C=rn(Y),F=d>576,H=Se(V=>{if(d===0||x===0)return;const et={top:20,right:30,bottom:30,left:30},$=M.length===0?[]:Object.keys(M[0]).filter(B=>B!=="label"&&B!=="total"),dt=e?$:$.filter(B=>!p.includes(B));M.forEach((B,mt)=>{const
|
|
8
|
-
${p.includes(B)?e?
|
|
6
|
+
<%s key={someKey} {...props} />`,pt,ot,O,ot),et[ot+pt]=!0)}if(ot=null,wt!==void 0&&(n(wt),ot=""+wt),s(dt)&&(n(dt.key),ot=""+dt.key),"key"in dt){wt={};for(var Q in dt)Q!=="key"&&(wt[Q]=dt[Q])}else wt=dt;return ot&&o(wt,typeof $=="function"?$.displayName||$.name||"Unknown":$),c($,ot,wt,a(),_t,G)}function h($){f($)?$._store&&($._store.validated=1):typeof $=="object"&&$!==null&&$.$$typeof===E&&($._payload.status==="fulfilled"?f($._payload.value)&&$._payload.value._store&&($._payload.value._store.validated=1):$._store&&($._store.validated=1))}function f($){return typeof $=="object"&&$!==null&&$.$$typeof===v}var g=bt,v=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),y=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),z=Symbol.for("react.view_transition"),I=Symbol.for("react.client.reference"),N=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,M=Array.isArray,Y=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function($){return $()}};var C,F={},H=g.react_stack_bottom_frame.bind(g,i)(),V=Y(r(i)),et={};Mr.Fragment=d,Mr.jsx=function($,dt,wt){var pt=1e4>N.recentlyCreatedOwnerStacks++;if(pt){var _t=Error.stackTraceLimit;Error.stackTraceLimit=10;var G=Error("react-stack-top-frame");Error.stackTraceLimit=_t}else G=H;return u($,dt,wt,!1,G,pt?Y(r($)):V)},Mr.jsxs=function($,dt,wt){var pt=1e4>N.recentlyCreatedOwnerStacks++;if(pt){var _t=Error.stackTraceLimit;Error.stackTraceLimit=10;var G=Error("react-stack-top-frame");Error.stackTraceLimit=_t}else G=H;return u($,dt,wt,!0,G,pt?Y(r($)):V)}})()),Mr}var ro;function Hu(){return ro||(ro=1,process.env.NODE_ENV==="production"?ua.exports=Iu():ua.exports=Fu()),ua.exports}var m=Hu();function Ln(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ao(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Nr(t){let e,n,r;t.length!==2?(e=Ln,n=(o,l)=>Ln(t(o),l),r=(o,l)=>t(o)-l):(e=t===Ln||t===ao?t:Wu,n=t,r=t);function a(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const h=c+u>>>1;n(o[h],l)<0?c=h+1:u=h}while(c<u)}return c}function i(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const h=c+u>>>1;n(o[h],l)<=0?c=h+1:u=h}while(c<u)}return c}function s(o,l,c=0,u=o.length){const h=a(o,l,c,u-1);return h>c&&r(o[h-1],l)>-r(o[h],l)?h-1:h}return{left:a,center:s,right:i}}function Wu(){return 0}function Ou(t){return t===null?NaN:+t}function*Bu(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const io=Nr(Ln).right;Nr(Ou).center;function ki(t,e){let n=0;for(let r of t)r!=null&&(r=+r)>=r&&++n;return n}function Yu(t,e){let n=0,r,a=0,i=0;for(let s of t)s!=null&&(s=+s)>=s&&(r=s-a,a+=r/++n,i+=r*(s-a));if(n>1)return i/(n-1)}function Uu(t,e){const n=Yu(t);return n&&Math.sqrt(n)}function fa(t,e){let n,r;if(e===void 0)for(const a of t)a!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)));else{let a=-1;for(let i of t)(i=e(i,++a,t))!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)))}return[n,r]}class Ai extends Map{constructor(e,n=Ku){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,a]of e)this.set(r,a)}get(e){return super.get(so(this,e))}has(e){return super.has(so(this,e))}set(e,n){return super.set(Vu(this,e),n)}delete(e){return super.delete(Xu(this,e))}}function so({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Vu({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Xu({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Ku(t){return t!==null&&typeof t=="object"?t.valueOf():t}function ha(t){return t}function oo(t,...e){return lo(t,ha,ha,e)}function Gu(t,e,...n){return lo(t,ha,e,n)}function lo(t,e,n,r){return(function a(i,s){if(s>=r.length)return n(i);const o=new Ai,l=r[s++];let c=-1;for(const u of i){const h=l(u,++c,i),f=o.get(h);f?f.push(u):o.set(h,[u])}for(const[u,h]of o)o.set(u,a(h,s));return e(o)})(t,0)}function Zu(t=Ln){if(t===Ln)return co;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,n)=>{const r=t(e,n);return r||r===0?r:(t(n,n)===0)-(t(e,e)===0)}}function co(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}var Ju=Array.prototype,Qu=Ju.slice;function Si(t){return()=>t}const qu=Math.sqrt(50),tf=Math.sqrt(10),ef=Math.sqrt(2);function da(t,e,n){const r=(e-t)/Math.max(0,n),a=Math.floor(Math.log10(r)),i=r/Math.pow(10,a),s=i>=qu?10:i>=tf?5:i>=ef?2:1;let o,l,c;return a<0?(c=Math.pow(10,-a)/s,o=Math.round(t*c),l=Math.round(e*c),o/c<t&&++o,l/c>e&&--l,c=-c):(c=Math.pow(10,a)*s,o=Math.round(t/c),l=Math.round(e/c),o*c<t&&++o,l*c>e&&--l),l<o&&.5<=n&&n<2?da(t,e,n*2):[o,l,c]}function uo(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[a,i,s]=r?da(e,t,n):da(t,e,n);if(!(i>=a))return[];const o=i-a+1,l=new Array(o);if(r)if(s<0)for(let c=0;c<o;++c)l[c]=(i-c)/-s;else for(let c=0;c<o;++c)l[c]=(i-c)*s;else if(s<0)for(let c=0;c<o;++c)l[c]=(a+c)/-s;else for(let c=0;c<o;++c)l[c]=(a+c)*s;return l}function Qn(t,e,n){return e=+e,t=+t,n=+n,da(t,e,n)[2]}function pa(t,e,n){e=+e,t=+t,n=+n;const r=e<t,a=r?Qn(e,t,n):Qn(t,e,n);return(r?-1:1)*(a<0?1/-a:a)}function nf(t,e,n){let r;for(;;){const a=Qn(t,e,n);if(a===r||a===0||!isFinite(a))return[t,e];a>0?(t=Math.floor(t/a)*a,e=Math.ceil(e/a)*a):a<0&&(t=Math.ceil(t*a)/a,e=Math.floor(e*a)/a),r=a}}function fo(t){return Math.max(1,Math.ceil(Math.log(ki(t))/Math.LN2)+1)}function rf(){var t=ha,e=fa,n=fo;function r(a){Array.isArray(a)||(a=Array.from(a));var i,s=a.length,o,l,c=new Array(s);for(i=0;i<s;++i)c[i]=t(a[i],i,a);var u=e(c),h=u[0],f=u[1],g=n(c,h,f);if(!Array.isArray(g)){const w=f,y=+g;if(e===fa&&([h,f]=nf(h,f,y)),g=uo(h,f,y),g[0]<=h&&(l=Qn(h,f,y)),g[g.length-1]>=f)if(w>=f&&e===fa){const T=Qn(h,f,y);isFinite(T)&&(T>0?f=(Math.floor(f/T)+1)*T:T<0&&(f=(Math.ceil(f*-T)+1)/-T))}else g.pop()}for(var v=g.length,b=0,d=v;g[b]<=h;)++b;for(;g[d-1]>f;)--d;(b||d<v)&&(g=g.slice(b,d),v=d-b);var x=new Array(v+1),S;for(i=0;i<=v;++i)S=x[i]=[],S.x0=i>0?g[i-1]:h,S.x1=i<v?g[i]:f;if(isFinite(l)){if(l>0)for(i=0;i<s;++i)(o=c[i])!=null&&h<=o&&o<=f&&x[Math.min(v,Math.floor((o-h)/l))].push(a[i]);else if(l<0){for(i=0;i<s;++i)if((o=c[i])!=null&&h<=o&&o<=f){const w=Math.floor((h-o)*l);x[Math.min(v,w+(g[w]<=o))].push(a[i])}}}else for(i=0;i<s;++i)(o=c[i])!=null&&h<=o&&o<=f&&x[io(g,o,0,v)].push(a[i]);return x}return r.value=function(a){return arguments.length?(t=typeof a=="function"?a:Si(a),r):t},r.domain=function(a){return arguments.length?(e=typeof a=="function"?a:Si([a[0],a[1]]),r):e},r.thresholds=function(a){return arguments.length?(n=typeof a=="function"?a:Si(Array.isArray(a)?Qu.call(a):a),r):n},r}function Gt(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let a of t)(a=e(a,++r,t))!=null&&(n<a||n===void 0&&a>=a)&&(n=a)}return n}function oe(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let a of t)(a=e(a,++r,t))!=null&&(n>a||n===void 0&&a>=a)&&(n=a)}return n}function ho(t,e,n=0,r=1/0,a){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(t.length-1,r)),!(n<=e&&e<=r))return t;for(a=a===void 0?co:Zu(a);r>n;){if(r-n>600){const l=r-n+1,c=e-n+1,u=Math.log(l),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1),g=Math.max(n,Math.floor(e-c*h/l+f)),v=Math.min(r,Math.floor(e+(l-c)*h/l+f));ho(t,e,g,v,a)}const i=t[e];let s=n,o=r;for(Tr(t,n,e),a(t[r],i)>0&&Tr(t,n,r);s<o;){for(Tr(t,s,o),++s,--o;a(t[s],i)<0;)++s;for(;a(t[o],i)>0;)--o}a(t[n],i)===0?Tr(t,n,o):(++o,Tr(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function Tr(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function po(t,e,n){if(t=Float64Array.from(Bu(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return oe(t);if(e>=1)return Gt(t);var r,a=(r-1)*e,i=Math.floor(a),s=Gt(ho(t,i).subarray(0,i+1)),o=oe(t.subarray(i+1));return s+(o-s)*(a-i)}}function af(t,e,n){const r=ki(t),a=po(t,.75)-po(t,.25);return r&&a?Math.ceil((n-e)/(2*a*Math.pow(r,-1/3))):1}function sf(t,e,n){const r=ki(t),a=Uu(t);return r&&a?Math.ceil((n-e)*Math.cbrt(r)/(3.49*a)):1}function ga(t,e,n){t=+t,e=+e,n=(a=arguments.length)<2?(e=t,t=0,1):a<3?1:+n;for(var r=-1,a=Math.max(0,Math.ceil((e-t)/n))|0,i=new Array(a);++r<a;)i[r]=t+r*n;return i}const of=lf(Math.random);function lf(t){return function(n,r=0,a=n.length){let i=a-(r=+r);for(;i;){const s=t()*i--|0,o=n[i+r];n[i+r]=n[s+r],n[s+r]=o}return n}}function Dr(t,e){let n=0;if(e===void 0)for(let r of t)(r=+r)&&(n+=r);else{let r=-1;for(let a of t)(a=+e(a,++r,t))&&(n+=a)}return n}function cf(t){return t}var ya=1,xa=2,Mi=3,$r=4,go=1e-6;function uf(t){return"translate("+t+",0)"}function ff(t){return"translate(0,"+t+")"}function hf(t){return e=>+t(e)}function df(t,e){return e=Math.max(0,t.bandwidth()-e*2)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function pf(){return!this.__axis}function ma(t,e){var n=[],r=null,a=null,i=6,s=6,o=3,l=typeof window<"u"&&window.devicePixelRatio>1?0:.5,c=t===ya||t===$r?-1:1,u=t===$r||t===xa?"x":"y",h=t===ya||t===Mi?uf:ff;function f(g){var v=r??(e.ticks?e.ticks.apply(e,n):e.domain()),b=a??(e.tickFormat?e.tickFormat.apply(e,n):cf),d=Math.max(i,0)+o,x=e.range(),S=+x[0]+l,w=+x[x.length-1]+l,y=(e.bandwidth?df:hf)(e.copy(),l),T=g.selection?g.selection():g,p=T.selectAll(".domain").data([null]),k=T.selectAll(".tick").data(v,e).order(),_=k.exit(),E=k.enter().append("g").attr("class","tick"),R=k.select("line"),z=k.select("text");p=p.merge(p.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),k=k.merge(E),R=R.merge(E.append("line").attr("stroke","currentColor").attr(u+"2",c*i)),z=z.merge(E.append("text").attr("fill","currentColor").attr(u,c*d).attr("dy",t===ya?"0em":t===Mi?"0.71em":"0.32em")),g!==T&&(p=p.transition(g),k=k.transition(g),R=R.transition(g),z=z.transition(g),_=_.transition(g).attr("opacity",go).attr("transform",function(I){return isFinite(I=y(I))?h(I+l):this.getAttribute("transform")}),E.attr("opacity",go).attr("transform",function(I){var N=this.parentNode.__axis;return h((N&&isFinite(N=N(I))?N:y(I))+l)})),_.remove(),p.attr("d",t===$r||t===xa?s?"M"+c*s+","+S+"H"+l+"V"+w+"H"+c*s:"M"+l+","+S+"V"+w:s?"M"+S+","+c*s+"V"+l+"H"+w+"V"+c*s:"M"+S+","+l+"H"+w),k.attr("opacity",1).attr("transform",function(I){return h(y(I)+l)}),R.attr(u+"2",c*i),z.attr(u,c*d).text(b),T.filter(pf).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===xa?"start":t===$r?"end":"middle"),T.each(function(){this.__axis=y})}return f.scale=function(g){return arguments.length?(e=g,f):e},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(g){return arguments.length?(n=g==null?[]:Array.from(g),f):n.slice()},f.tickValues=function(g){return arguments.length?(r=g==null?null:Array.from(g),f):r&&r.slice()},f.tickFormat=function(g){return arguments.length?(a=g,f):a},f.tickSize=function(g){return arguments.length?(i=s=+g,f):i},f.tickSizeInner=function(g){return arguments.length?(i=+g,f):i},f.tickSizeOuter=function(g){return arguments.length?(s=+g,f):s},f.tickPadding=function(g){return arguments.length?(o=+g,f):o},f.offset=function(g){return arguments.length?(l=+g,f):l},f}function va(t){return ma(ya,t)}function Ni(t){return ma(xa,t)}function he(t){return ma(Mi,t)}function be(t){return ma($r,t)}var gf={value:()=>{}};function Cr(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new ba(n)}function ba(t){this._=t}function yf(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",a=n.indexOf(".");if(a>=0&&(r=n.slice(a+1),n=n.slice(0,a)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ba.prototype=Cr.prototype={constructor:ba,on:function(t,e){var n=this._,r=yf(t+"",n),a,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((a=(t=r[i]).type)&&(a=xf(n[a],t.name)))return a;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<s;)if(a=(t=r[i]).type)n[a]=yo(n[a],t.name,e);else if(e==null)for(a in n)n[a]=yo(n[a],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new ba(t)},call:function(t,e){if((a=arguments.length-2)>0)for(var n=new Array(a),r=0,a,i;r<a;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=this._[t],r=0,a=i.length;r<a;++r)i[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],a=0,i=r.length;a<i;++a)r[a].value.apply(e,n)}};function xf(t,e){for(var n=0,r=t.length,a;n<r;++n)if((a=t[n]).name===e)return a.value}function yo(t,e,n){for(var r=0,a=t.length;r<a;++r)if(t[r].name===e){t[r]=gf,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Ti="http://www.w3.org/1999/xhtml";const xo={svg:"http://www.w3.org/2000/svg",xhtml:Ti,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function wa(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),xo.hasOwnProperty(e)?{space:xo[e],local:t}:t}function mf(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Ti&&e.documentElement.namespaceURI===Ti?e.createElement(t):e.createElementNS(n,t)}}function vf(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function mo(t){var e=wa(t);return(e.local?vf:mf)(e)}function bf(){}function Di(t){return t==null?bf:function(){return this.querySelector(t)}}function wf(t){typeof t!="function"&&(t=Di(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],s=i.length,o=r[a]=new Array(s),l,c,u=0;u<s;++u)(l=i[u])&&(c=t.call(l,l.__data__,u,i))&&("__data__"in l&&(c.__data__=l.__data__),o[u]=c);return new Ue(r,this._parents)}function _f(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function kf(){return[]}function vo(t){return t==null?kf:function(){return this.querySelectorAll(t)}}function Af(t){return function(){return _f(t.apply(this,arguments))}}function Sf(t){typeof t=="function"?t=Af(t):t=vo(t);for(var e=this._groups,n=e.length,r=[],a=[],i=0;i<n;++i)for(var s=e[i],o=s.length,l,c=0;c<o;++c)(l=s[c])&&(r.push(t.call(l,l.__data__,c,s)),a.push(l));return new Ue(r,a)}function bo(t){return function(){return this.matches(t)}}function wo(t){return function(e){return e.matches(t)}}var Mf=Array.prototype.find;function Nf(t){return function(){return Mf.call(this.children,t)}}function Tf(){return this.firstElementChild}function Df(t){return this.select(t==null?Tf:Nf(typeof t=="function"?t:wo(t)))}var $f=Array.prototype.filter;function Cf(){return Array.from(this.children)}function Lf(t){return function(){return $f.call(this.children,t)}}function jf(t){return this.selectAll(t==null?Cf:Lf(typeof t=="function"?t:wo(t)))}function Pf(t){typeof t!="function"&&(t=bo(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],s=i.length,o=r[a]=[],l,c=0;c<s;++c)(l=i[c])&&t.call(l,l.__data__,c,i)&&o.push(l);return new Ue(r,this._parents)}function _o(t){return new Array(t.length)}function Ef(){return new Ue(this._enter||this._groups.map(_o),this._parents)}function _a(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}_a.prototype={constructor:_a,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Rf(t){return function(){return t}}function zf(t,e,n,r,a,i){for(var s=0,o,l=e.length,c=i.length;s<c;++s)(o=e[s])?(o.__data__=i[s],r[s]=o):n[s]=new _a(t,i[s]);for(;s<l;++s)(o=e[s])&&(a[s]=o)}function If(t,e,n,r,a,i,s){var o,l,c=new Map,u=e.length,h=i.length,f=new Array(u),g;for(o=0;o<u;++o)(l=e[o])&&(f[o]=g=s.call(l,l.__data__,o,e)+"",c.has(g)?a[o]=l:c.set(g,l));for(o=0;o<h;++o)g=s.call(t,i[o],o,i)+"",(l=c.get(g))?(r[o]=l,l.__data__=i[o],c.delete(g)):n[o]=new _a(t,i[o]);for(o=0;o<u;++o)(l=e[o])&&c.get(f[o])===l&&(a[o]=l)}function Ff(t){return t.__data__}function Hf(t,e){if(!arguments.length)return Array.from(this,Ff);var n=e?If:zf,r=this._parents,a=this._groups;typeof t!="function"&&(t=Rf(t));for(var i=a.length,s=new Array(i),o=new Array(i),l=new Array(i),c=0;c<i;++c){var u=r[c],h=a[c],f=h.length,g=Wf(t.call(u,u&&u.__data__,c,r)),v=g.length,b=o[c]=new Array(v),d=s[c]=new Array(v),x=l[c]=new Array(f);n(u,h,b,d,x,g,e);for(var S=0,w=0,y,T;S<v;++S)if(y=b[S]){for(S>=w&&(w=S+1);!(T=d[w])&&++w<v;);y._next=T||null}}return s=new Ue(s,r),s._enter=o,s._exit=l,s}function Wf(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Of(){return new Ue(this._exit||this._groups.map(_o),this._parents)}function Bf(t,e,n){var r=this.enter(),a=this,i=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(a=e(a),a&&(a=a.selection())),n==null?i.remove():n(i),r&&a?r.merge(a).order():a}function Yf(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,a=n.length,i=r.length,s=Math.min(a,i),o=new Array(a),l=0;l<s;++l)for(var c=n[l],u=r[l],h=c.length,f=o[l]=new Array(h),g,v=0;v<h;++v)(g=c[v]||u[v])&&(f[v]=g);for(;l<a;++l)o[l]=n[l];return new Ue(o,this._parents)}function Uf(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],a=r.length-1,i=r[a],s;--a>=0;)(s=r[a])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Vf(t){t||(t=Xf);function e(h,f){return h&&f?t(h.__data__,f.__data__):!h-!f}for(var n=this._groups,r=n.length,a=new Array(r),i=0;i<r;++i){for(var s=n[i],o=s.length,l=a[i]=new Array(o),c,u=0;u<o;++u)(c=s[u])&&(l[u]=c);l.sort(e)}return new Ue(a,this._parents).order()}function Xf(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Kf(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Gf(){return Array.from(this)}function Zf(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],a=0,i=r.length;a<i;++a){var s=r[a];if(s)return s}return null}function Jf(){let t=0;for(const e of this)++t;return t}function Qf(){return!this.node()}function qf(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var a=e[n],i=0,s=a.length,o;i<s;++i)(o=a[i])&&t.call(o,o.__data__,i,a);return this}function th(t){return function(){this.removeAttribute(t)}}function eh(t){return function(){this.removeAttributeNS(t.space,t.local)}}function nh(t,e){return function(){this.setAttribute(t,e)}}function rh(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ah(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function ih(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function sh(t,e){var n=wa(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?eh:th:typeof e=="function"?n.local?ih:ah:n.local?rh:nh)(n,e))}function ko(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function oh(t){return function(){this.style.removeProperty(t)}}function lh(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ch(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function uh(t,e,n){return arguments.length>1?this.each((e==null?oh:typeof e=="function"?ch:lh)(t,e,n??"")):qn(this.node(),t)}function qn(t,e){return t.style.getPropertyValue(e)||ko(t).getComputedStyle(t,null).getPropertyValue(e)}function fh(t){return function(){delete this[t]}}function hh(t,e){return function(){this[t]=e}}function dh(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function ph(t,e){return arguments.length>1?this.each((e==null?fh:typeof e=="function"?dh:hh)(t,e)):this.node()[t]}function Ao(t){return t.trim().split(/^|\s+/)}function $i(t){return t.classList||new So(t)}function So(t){this._node=t,this._names=Ao(t.getAttribute("class")||"")}So.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Mo(t,e){for(var n=$i(t),r=-1,a=e.length;++r<a;)n.add(e[r])}function No(t,e){for(var n=$i(t),r=-1,a=e.length;++r<a;)n.remove(e[r])}function gh(t){return function(){Mo(this,t)}}function yh(t){return function(){No(this,t)}}function xh(t,e){return function(){(e.apply(this,arguments)?Mo:No)(this,t)}}function mh(t,e){var n=Ao(t+"");if(arguments.length<2){for(var r=$i(this.node()),a=-1,i=n.length;++a<i;)if(!r.contains(n[a]))return!1;return!0}return this.each((typeof e=="function"?xh:e?gh:yh)(n,e))}function vh(){this.textContent=""}function bh(t){return function(){this.textContent=t}}function wh(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function _h(t){return arguments.length?this.each(t==null?vh:(typeof t=="function"?wh:bh)(t)):this.node().textContent}function kh(){this.innerHTML=""}function Ah(t){return function(){this.innerHTML=t}}function Sh(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Mh(t){return arguments.length?this.each(t==null?kh:(typeof t=="function"?Sh:Ah)(t)):this.node().innerHTML}function Nh(){this.nextSibling&&this.parentNode.appendChild(this)}function Th(){return this.each(Nh)}function Dh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function $h(){return this.each(Dh)}function Ch(t){var e=typeof t=="function"?t:mo(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Lh(){return null}function jh(t,e){var n=typeof t=="function"?t:mo(t),r=e==null?Lh:typeof e=="function"?e:Di(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Ph(){var t=this.parentNode;t&&t.removeChild(this)}function Eh(){return this.each(Ph)}function Rh(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function zh(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ih(t){return this.select(t?zh:Rh)}function Fh(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Hh(t){return function(e){t.call(this,e,this.__data__)}}function Wh(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Oh(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,a=e.length,i;n<a;++n)i=e[n],(!t.type||i.type===t.type)&&i.name===t.name?this.removeEventListener(i.type,i.listener,i.options):e[++r]=i;++r?e.length=r:delete this.__on}}}function Bh(t,e,n){return function(){var r=this.__on,a,i=Hh(e);if(r){for(var s=0,o=r.length;s<o;++s)if((a=r[s]).type===t.type&&a.name===t.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=i,a.options=n),a.value=e;return}}this.addEventListener(t.type,i,n),a={type:t.type,name:t.name,value:e,listener:i,options:n},r?r.push(a):this.__on=[a]}}function Yh(t,e,n){var r=Wh(t+""),a,i=r.length,s;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,c=o.length,u;l<c;++l)for(a=0,u=o[l];a<i;++a)if((s=r[a]).type===u.type&&s.name===u.name)return u.value}return}for(o=e?Bh:Oh,a=0;a<i;++a)this.each(o(r[a],e,n));return this}function To(t,e,n){var r=ko(t),a=r.CustomEvent;typeof a=="function"?a=new a(e,n):(a=r.document.createEvent("Event"),n?(a.initEvent(e,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(e,!1,!1)),t.dispatchEvent(a)}function Uh(t,e){return function(){return To(this,t,e)}}function Vh(t,e){return function(){return To(this,t,e.apply(this,arguments))}}function Xh(t,e){return this.each((typeof e=="function"?Vh:Uh)(t,e))}function*Kh(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],a=0,i=r.length,s;a<i;++a)(s=r[a])&&(yield s)}var Do=[null];function Ue(t,e){this._groups=t,this._parents=e}function Lr(){return new Ue([[document.documentElement]],Do)}function Gh(){return this}Ue.prototype=Lr.prototype={constructor:Ue,select:wf,selectAll:Sf,selectChild:Df,selectChildren:jf,filter:Pf,data:Hf,enter:Ef,exit:Of,join:Bf,merge:Yf,selection:Gh,order:Uf,sort:Vf,call:Kf,nodes:Gf,node:Zf,size:Jf,empty:Qf,each:qf,attr:sh,style:uh,property:ph,classed:mh,text:_h,html:Mh,raise:Th,lower:$h,append:Ch,insert:jh,remove:Eh,clone:Ih,datum:Fh,on:Yh,dispatch:Xh,[Symbol.iterator]:Kh};function qt(t){return typeof t=="string"?new Ue([[document.querySelector(t)]],[document.documentElement]):new Ue([[t]],Do)}function Zh(t){let e;for(;e=t.sourceEvent;)t=e;return t}function tr(t,e){if(t=Zh(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var a=e.getBoundingClientRect();return[t.clientX-a.left-e.clientLeft,t.clientY-a.top-e.clientTop]}}return[t.pageX,t.pageY]}const Jh={passive:!1},jr={capture:!0,passive:!1};function Ci(t){t.stopImmediatePropagation()}function er(t){t.preventDefault(),t.stopImmediatePropagation()}function $o(t){var e=t.document.documentElement,n=qt(t).on("dragstart.drag",er,jr);"onselectstart"in e?n.on("selectstart.drag",er,jr):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Co(t,e){var n=t.document.documentElement,r=qt(t).on("dragstart.drag",null);e&&(r.on("click.drag",er,jr),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const ka=t=>()=>t;function Li(t,{sourceEvent:e,subject:n,target:r,identifier:a,active:i,x:s,y:o,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Li.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Qh(t){return!t.ctrlKey&&!t.button}function qh(){return this.parentNode}function td(t,e){return e??{x:t.x,y:t.y}}function ed(){return navigator.maxTouchPoints||"ontouchstart"in this}function nd(){var t=Qh,e=qh,n=td,r=ed,a={},i=Cr("start","drag","end"),s=0,o,l,c,u,h=0;function f(y){y.on("mousedown.drag",g).filter(r).on("touchstart.drag",d).on("touchmove.drag",x,Jh).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(y,T){if(!(u||!t.call(this,y,T))){var p=w(this,e.call(this,y,T),y,T,"mouse");p&&(qt(y.view).on("mousemove.drag",v,jr).on("mouseup.drag",b,jr),$o(y.view),Ci(y),c=!1,o=y.clientX,l=y.clientY,p("start",y))}}function v(y){if(er(y),!c){var T=y.clientX-o,p=y.clientY-l;c=T*T+p*p>h}a.mouse("drag",y)}function b(y){qt(y.view).on("mousemove.drag mouseup.drag",null),Co(y.view,c),er(y),a.mouse("end",y)}function d(y,T){if(t.call(this,y,T)){var p=y.changedTouches,k=e.call(this,y,T),_=p.length,E,R;for(E=0;E<_;++E)(R=w(this,k,y,T,p[E].identifier,p[E]))&&(Ci(y),R("start",y,p[E]))}}function x(y){var T=y.changedTouches,p=T.length,k,_;for(k=0;k<p;++k)(_=a[T[k].identifier])&&(er(y),_("drag",y,T[k]))}function S(y){var T=y.changedTouches,p=T.length,k,_;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),k=0;k<p;++k)(_=a[T[k].identifier])&&(Ci(y),_("end",y,T[k]))}function w(y,T,p,k,_,E){var R=i.copy(),z=tr(E||p,T),I,N,U;if((U=n.call(y,new Li("beforestart",{sourceEvent:p,target:f,identifier:_,active:s,x:z[0],y:z[1],dx:0,dy:0,dispatch:R}),k))!=null)return I=U.x-z[0]||0,N=U.y-z[1]||0,function M(Y,C,F){var H=z,V;switch(Y){case"start":a[_]=M,V=s++;break;case"end":delete a[_],--s;case"drag":z=tr(F||C,T),V=s;break}R.call(Y,y,new Li(Y,{sourceEvent:C,subject:U,target:f,identifier:_,active:V,x:z[0]+I,y:z[1]+N,dx:z[0]-H[0],dy:z[1]-H[1],dispatch:R}),k)}}return f.filter=function(y){return arguments.length?(t=typeof y=="function"?y:ka(!!y),f):t},f.container=function(y){return arguments.length?(e=typeof y=="function"?y:ka(y),f):e},f.subject=function(y){return arguments.length?(n=typeof y=="function"?y:ka(y),f):n},f.touchable=function(y){return arguments.length?(r=typeof y=="function"?y:ka(!!y),f):r},f.on=function(){var y=i.on.apply(i,arguments);return y===i?f:y},f.clickDistance=function(y){return arguments.length?(h=(y=+y)*y,f):Math.sqrt(h)},f}function nr(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Pr(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function An(){}var jn=.7,rr=1/jn,ar="\\s*([+-]?\\d+)\\s*",Er="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",sn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",rd=/^#([0-9a-f]{3,8})$/,ad=new RegExp(`^rgb\\(${ar},${ar},${ar}\\)$`),id=new RegExp(`^rgb\\(${sn},${sn},${sn}\\)$`),sd=new RegExp(`^rgba\\(${ar},${ar},${ar},${Er}\\)$`),od=new RegExp(`^rgba\\(${sn},${sn},${sn},${Er}\\)$`),ld=new RegExp(`^hsl\\(${Er},${sn},${sn}\\)$`),cd=new RegExp(`^hsla\\(${Er},${sn},${sn},${Er}\\)$`),Lo={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};nr(An,Ve,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:jo,formatHex:jo,formatHex8:ud,formatHsl:fd,formatRgb:Po,toString:Po});function jo(){return this.rgb().formatHex()}function ud(){return this.rgb().formatHex8()}function fd(){return Fo(this).formatHsl()}function Po(){return this.rgb().formatRgb()}function Ve(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=rd.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Eo(e):n===3?new Te(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Aa(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Aa(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=ad.exec(t))?new Te(e[1],e[2],e[3],1):(e=id.exec(t))?new Te(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=sd.exec(t))?Aa(e[1],e[2],e[3],e[4]):(e=od.exec(t))?Aa(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=ld.exec(t))?Io(e[1],e[2]/100,e[3]/100,1):(e=cd.exec(t))?Io(e[1],e[2]/100,e[3]/100,e[4]):Lo.hasOwnProperty(t)?Eo(Lo[t]):t==="transparent"?new Te(NaN,NaN,NaN,0):null}function Eo(t){return new Te(t>>16&255,t>>8&255,t&255,1)}function Aa(t,e,n,r){return r<=0&&(t=e=n=NaN),new Te(t,e,n,r)}function ji(t){return t instanceof An||(t=Ve(t)),t?(t=t.rgb(),new Te(t.r,t.g,t.b,t.opacity)):new Te}function Sa(t,e,n,r){return arguments.length===1?ji(t):new Te(t,e,n,r??1)}function Te(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}nr(Te,Sa,Pr(An,{brighter(t){return t=t==null?rr:Math.pow(rr,t),new Te(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?jn:Math.pow(jn,t),new Te(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Te(Pn(this.r),Pn(this.g),Pn(this.b),Ma(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:Ro,formatHex:Ro,formatHex8:hd,formatRgb:zo,toString:zo}));function Ro(){return`#${En(this.r)}${En(this.g)}${En(this.b)}`}function hd(){return`#${En(this.r)}${En(this.g)}${En(this.b)}${En((isNaN(this.opacity)?1:this.opacity)*255)}`}function zo(){const t=Ma(this.opacity);return`${t===1?"rgb(":"rgba("}${Pn(this.r)}, ${Pn(this.g)}, ${Pn(this.b)}${t===1?")":`, ${t})`}`}function Ma(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Pn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function En(t){return t=Pn(t),(t<16?"0":"")+t.toString(16)}function Io(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new tn(t,e,n,r)}function Fo(t){if(t instanceof tn)return new tn(t.h,t.s,t.l,t.opacity);if(t instanceof An||(t=Ve(t)),!t)return new tn;if(t instanceof tn)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,a=Math.min(e,n,r),i=Math.max(e,n,r),s=NaN,o=i-a,l=(i+a)/2;return o?(e===i?s=(n-r)/o+(n<r)*6:n===i?s=(r-e)/o+2:s=(e-n)/o+4,o/=l<.5?i+a:2-i-a,s*=60):o=l>0&&l<1?0:s,new tn(s,o,l,t.opacity)}function dd(t,e,n,r){return arguments.length===1?Fo(t):new tn(t,e,n,r??1)}function tn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}nr(tn,dd,Pr(An,{brighter(t){return t=t==null?rr:Math.pow(rr,t),new tn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?jn:Math.pow(jn,t),new tn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,a=2*n-r;return new Te(Pi(t>=240?t-240:t+120,a,r),Pi(t,a,r),Pi(t<120?t+240:t-120,a,r),this.opacity)},clamp(){return new tn(Ho(this.h),Na(this.s),Na(this.l),Ma(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=Ma(this.opacity);return`${t===1?"hsl(":"hsla("}${Ho(this.h)}, ${Na(this.s)*100}%, ${Na(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Ho(t){return t=(t||0)%360,t<0?t+360:t}function Na(t){return Math.max(0,Math.min(1,t||0))}function Pi(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Wo=Math.PI/180,Oo=180/Math.PI,Ta=18,Bo=.96422,Yo=1,Uo=.82521,Vo=4/29,ir=6/29,Xo=3*ir*ir,pd=ir*ir*ir;function Ko(t){if(t instanceof on)return new on(t.l,t.a,t.b,t.opacity);if(t instanceof gn)return Go(t);t instanceof Te||(t=ji(t));var e=Ii(t.r),n=Ii(t.g),r=Ii(t.b),a=Ei((.2225045*e+.7168786*n+.0606169*r)/Yo),i,s;return e===n&&n===r?i=s=a:(i=Ei((.4360747*e+.3850649*n+.1430804*r)/Bo),s=Ei((.0139322*e+.0971045*n+.7141733*r)/Uo)),new on(116*a-16,500*(i-a),200*(a-s),t.opacity)}function gd(t,e,n,r){return arguments.length===1?Ko(t):new on(t,e,n,r??1)}function on(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}nr(on,gd,Pr(An,{brighter(t){return new on(this.l+Ta*(t??1),this.a,this.b,this.opacity)},darker(t){return new on(this.l-Ta*(t??1),this.a,this.b,this.opacity)},rgb(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return e=Bo*Ri(e),t=Yo*Ri(t),n=Uo*Ri(n),new Te(zi(3.1338561*e-1.6168667*t-.4906146*n),zi(-.9787684*e+1.9161415*t+.033454*n),zi(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}}));function Ei(t){return t>pd?Math.pow(t,1/3):t/Xo+Vo}function Ri(t){return t>ir?t*t*t:Xo*(t-Vo)}function zi(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ii(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function yd(t){if(t instanceof gn)return new gn(t.h,t.c,t.l,t.opacity);if(t instanceof on||(t=Ko(t)),t.a===0&&t.b===0)return new gn(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*Oo;return new gn(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function Fi(t,e,n,r){return arguments.length===1?yd(t):new gn(t,e,n,r??1)}function gn(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function Go(t){if(isNaN(t.h))return new on(t.l,0,0,t.opacity);var e=t.h*Wo;return new on(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}nr(gn,Fi,Pr(An,{brighter(t){return new gn(this.h,this.c,this.l+Ta*(t??1),this.opacity)},darker(t){return new gn(this.h,this.c,this.l-Ta*(t??1),this.opacity)},rgb(){return Go(this).rgb()}}));var Zo=-.14861,Hi=1.78277,Wi=-.29227,Da=-.90649,Rr=1.97294,Jo=Rr*Da,Qo=Rr*Hi,qo=Hi*Wi-Da*Zo;function xd(t){if(t instanceof Rn)return new Rn(t.h,t.s,t.l,t.opacity);t instanceof Te||(t=ji(t));var e=t.r/255,n=t.g/255,r=t.b/255,a=(qo*r+Jo*e-Qo*n)/(qo+Jo-Qo),i=r-a,s=(Rr*(n-a)-Wi*i)/Da,o=Math.sqrt(s*s+i*i)/(Rr*a*(1-a)),l=o?Math.atan2(s,i)*Oo-120:NaN;return new Rn(l<0?l+360:l,o,a,t.opacity)}function Sn(t,e,n,r){return arguments.length===1?xd(t):new Rn(t,e,n,r??1)}function Rn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}nr(Rn,Sn,Pr(An,{brighter(t){return t=t==null?rr:Math.pow(rr,t),new Rn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?jn:Math.pow(jn,t),new Rn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*Wo,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),a=Math.sin(t);return new Te(255*(e+n*(Zo*r+Hi*a)),255*(e+n*(Wi*r+Da*a)),255*(e+n*(Rr*r)),this.opacity)}}));const $a=t=>()=>t;function tl(t,e){return function(n){return t+n*e}}function md(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function el(t,e){var n=e-t;return n?tl(t,n>180||n<-180?n-360*Math.round(n/360):n):$a(isNaN(t)?e:t)}function vd(t){return(t=+t)==1?yn:function(e,n){return n-e?md(e,n,t):$a(isNaN(e)?n:e)}}function yn(t,e){var n=e-t;return n?tl(t,n):$a(isNaN(t)?e:t)}const Ca=(function t(e){var n=vd(e);function r(a,i){var s=n((a=Sa(a)).r,(i=Sa(i)).r),o=n(a.g,i.g),l=n(a.b,i.b),c=yn(a.opacity,i.opacity);return function(u){return a.r=s(u),a.g=o(u),a.b=l(u),a.opacity=c(u),a+""}}return r.gamma=t,r})(1);function bd(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),a;return function(i){for(a=0;a<n;++a)r[a]=t[a]*(1-i)+e[a]*i;return r}}function wd(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function _d(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,a=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)a[s]=Ae(t[s],e[s]);for(;s<n;++s)i[s]=e[s];return function(o){for(s=0;s<r;++s)i[s]=a[s](o);return i}}function kd(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function en(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Ad(t,e){var n={},r={},a;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(a in e)a in t?n[a]=Ae(t[a],e[a]):r[a]=e[a];return function(i){for(a in n)r[a]=n[a](i);return r}}var Oi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Bi=new RegExp(Oi.source,"g");function Sd(t){return function(){return t}}function Md(t){return function(e){return t(e)+""}}function nl(t,e){var n=Oi.lastIndex=Bi.lastIndex=0,r,a,i,s=-1,o=[],l=[];for(t=t+"",e=e+"";(r=Oi.exec(t))&&(a=Bi.exec(e));)(i=a.index)>n&&(i=e.slice(n,i),o[s]?o[s]+=i:o[++s]=i),(r=r[0])===(a=a[0])?o[s]?o[s]+=a:o[++s]=a:(o[++s]=null,l.push({i:s,x:en(r,a)})),n=Bi.lastIndex;return n<e.length&&(i=e.slice(n),o[s]?o[s]+=i:o[++s]=i),o.length<2?l[0]?Md(l[0].x):Sd(e):(e=l.length,function(c){for(var u=0,h;u<e;++u)o[(h=l[u]).i]=h.x(c);return o.join("")})}function Ae(t,e){var n=typeof e,r;return e==null||n==="boolean"?$a(e):(n==="number"?en:n==="string"?(r=Ve(e))?(e=r,Ca):nl:e instanceof Ve?Ca:e instanceof Date?kd:wd(e)?bd:Array.isArray(e)?_d:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Ad:en)(t,e)}function Nd(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var rl=180/Math.PI,Yi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function al(t,e,n,r,a,i){var s,o,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),t*r<e*n&&(t=-t,e=-e,l=-l,s=-s),{translateX:a,translateY:i,rotate:Math.atan2(e,t)*rl,skewX:Math.atan(l)*rl,scaleX:s,scaleY:o}}var La;function Td(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Yi:al(e.a,e.b,e.c,e.d,e.e,e.f)}function Dd(t){return t==null||(La||(La=document.createElementNS("http://www.w3.org/2000/svg","g")),La.setAttribute("transform",t),!(t=La.transform.baseVal.consolidate()))?Yi:(t=t.matrix,al(t.a,t.b,t.c,t.d,t.e,t.f))}function il(t,e,n,r){function a(c){return c.length?c.pop()+" ":""}function i(c,u,h,f,g,v){if(c!==h||u!==f){var b=g.push("translate(",null,e,null,n);v.push({i:b-4,x:en(c,h)},{i:b-2,x:en(u,f)})}else(h||f)&&g.push("translate("+h+e+f+n)}function s(c,u,h,f){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),f.push({i:h.push(a(h)+"rotate(",null,r)-2,x:en(c,u)})):u&&h.push(a(h)+"rotate("+u+r)}function o(c,u,h,f){c!==u?f.push({i:h.push(a(h)+"skewX(",null,r)-2,x:en(c,u)}):u&&h.push(a(h)+"skewX("+u+r)}function l(c,u,h,f,g,v){if(c!==h||u!==f){var b=g.push(a(g)+"scale(",null,",",null,")");v.push({i:b-4,x:en(c,h)},{i:b-2,x:en(u,f)})}else(h!==1||f!==1)&&g.push(a(g)+"scale("+h+","+f+")")}return function(c,u){var h=[],f=[];return c=t(c),u=t(u),i(c.translateX,c.translateY,u.translateX,u.translateY,h,f),s(c.rotate,u.rotate,h,f),o(c.skewX,u.skewX,h,f),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,h,f),c=u=null,function(g){for(var v=-1,b=f.length,d;++v<b;)h[(d=f[v]).i]=d.x(g);return h.join("")}}}var $d=il(Td,"px, ","px)","deg)"),Cd=il(Dd,", ",")",")");function Ld(t){return function(e,n){var r=t((e=Fi(e)).h,(n=Fi(n)).h),a=yn(e.c,n.c),i=yn(e.l,n.l),s=yn(e.opacity,n.opacity);return function(o){return e.h=r(o),e.c=a(o),e.l=i(o),e.opacity=s(o),e+""}}}const jd=Ld(el);function sl(t){return(function e(n){n=+n;function r(a,i){var s=t((a=Sn(a)).h,(i=Sn(i)).h),o=yn(a.s,i.s),l=yn(a.l,i.l),c=yn(a.opacity,i.opacity);return function(u){return a.h=s(u),a.s=o(u),a.l=l(Math.pow(u,n)),a.opacity=c(u),a+""}}return r.gamma=e,r})(1)}sl(el);var ol=sl(yn);function ll(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t(r/(e-1));return n}var sr=0,zr=0,Ir=0,cl=1e3,ja,Fr,Pa=0,zn=0,Ea=0,Hr=typeof performance=="object"&&performance.now?performance:Date,ul=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Ui(){return zn||(ul(Pd),zn=Hr.now()+Ea)}function Pd(){zn=0}function Ra(){this._call=this._time=this._next=null}Ra.prototype=Vi.prototype={constructor:Ra,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Ui():+n)+(e==null?0:+e),!this._next&&Fr!==this&&(Fr?Fr._next=this:ja=this,Fr=this),this._call=t,this._time=n,Xi()},stop:function(){this._call&&(this._call=null,this._time=1/0,Xi())}};function Vi(t,e,n){var r=new Ra;return r.restart(t,e,n),r}function Ed(){Ui(),++sr;for(var t=ja,e;t;)(e=zn-t._time)>=0&&t._call.call(void 0,e),t=t._next;--sr}function fl(){zn=(Pa=Hr.now())+Ea,sr=zr=0;try{Ed()}finally{sr=0,zd(),zn=0}}function Rd(){var t=Hr.now(),e=t-Pa;e>cl&&(Ea-=e,Pa=t)}function zd(){for(var t,e=ja,n,r=1/0;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:ja=n);Fr=t,Xi(r)}function Xi(t){if(!sr){zr&&(zr=clearTimeout(zr));var e=t-zn;e>24?(t<1/0&&(zr=setTimeout(fl,t-Hr.now()-Ea)),Ir&&(Ir=clearInterval(Ir))):(Ir||(Pa=Hr.now(),Ir=setInterval(Rd,cl)),sr=1,ul(fl))}}function hl(t,e,n){var r=new Ra;return e=e==null?0:+e,r.restart(a=>{r.stop(),t(a+e)},e,n),r}var Id=Cr("start","end","cancel","interrupt"),Fd=[],dl=0,pl=1,Ki=2,za=3,gl=4,Gi=5,Ia=6;function Fa(t,e,n,r,a,i){var s=t.__transition;if(!s)t.__transition={};else if(n in s)return;Hd(t,n,{name:e,index:r,group:a,on:Id,tween:Fd,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:dl})}function Zi(t,e){var n=nn(t,e);if(n.state>dl)throw new Error("too late; already scheduled");return n}function ln(t,e){var n=nn(t,e);if(n.state>za)throw new Error("too late; already running");return n}function nn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Hd(t,e,n){var r=t.__transition,a;r[e]=n,n.timer=Vi(i,0,n.time);function i(c){n.state=pl,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,h,f,g;if(n.state!==pl)return l();for(u in r)if(g=r[u],g.name===n.name){if(g.state===za)return hl(s);g.state===gl?(g.state=Ia,g.timer.stop(),g.on.call("interrupt",t,t.__data__,g.index,g.group),delete r[u]):+u<e&&(g.state=Ia,g.timer.stop(),g.on.call("cancel",t,t.__data__,g.index,g.group),delete r[u])}if(hl(function(){n.state===za&&(n.state=gl,n.timer.restart(o,n.delay,n.time),o(c))}),n.state=Ki,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Ki){for(n.state=za,a=new Array(f=n.tween.length),u=0,h=-1;u<f;++u)(g=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(a[++h]=g);a.length=h+1}}function o(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Gi,1),h=-1,f=a.length;++h<f;)a[h].call(t,u);n.state===Gi&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=Ia,n.timer.stop(),delete r[e];for(var c in r)return;delete t.__transition}}function Ji(t,e){var n=t.__transition,r,a,i=!0,s;if(n){e=e==null?null:e+"";for(s in n){if((r=n[s]).name!==e){i=!1;continue}a=r.state>Ki&&r.state<Gi,r.state=Ia,r.timer.stop(),r.on.call(a?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[s]}i&&delete t.__transition}}function Wd(t){return this.each(function(){Ji(this,t)})}function Od(t,e){var n,r;return function(){var a=ln(this,t),i=a.tween;if(i!==n){r=n=i;for(var s=0,o=r.length;s<o;++s)if(r[s].name===e){r=r.slice(),r.splice(s,1);break}}a.tween=r}}function Bd(t,e,n){var r,a;if(typeof n!="function")throw new Error;return function(){var i=ln(this,t),s=i.tween;if(s!==r){a=(r=s).slice();for(var o={name:e,value:n},l=0,c=a.length;l<c;++l)if(a[l].name===e){a[l]=o;break}l===c&&a.push(o)}i.tween=a}}function Yd(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=nn(this.node(),n).tween,a=0,i=r.length,s;a<i;++a)if((s=r[a]).name===t)return s.value;return null}return this.each((e==null?Od:Bd)(n,t,e))}function Qi(t,e,n){var r=t._id;return t.each(function(){var a=ln(this,r);(a.value||(a.value={}))[e]=n.apply(this,arguments)}),function(a){return nn(a,r).value[e]}}function yl(t,e){var n;return(typeof e=="number"?en:e instanceof Ve?Ca:(n=Ve(e))?(e=n,Ca):nl)(t,e)}function Ud(t){return function(){this.removeAttribute(t)}}function Vd(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Xd(t,e,n){var r,a=n+"",i;return function(){var s=this.getAttribute(t);return s===a?null:s===r?i:i=e(r=s,n)}}function Kd(t,e,n){var r,a=n+"",i;return function(){var s=this.getAttributeNS(t.space,t.local);return s===a?null:s===r?i:i=e(r=s,n)}}function Gd(t,e,n){var r,a,i;return function(){var s,o=n(this),l;return o==null?void this.removeAttribute(t):(s=this.getAttribute(t),l=o+"",s===l?null:s===r&&l===a?i:(a=l,i=e(r=s,o)))}}function Zd(t,e,n){var r,a,i;return function(){var s,o=n(this),l;return o==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),l=o+"",s===l?null:s===r&&l===a?i:(a=l,i=e(r=s,o)))}}function Jd(t,e){var n=wa(t),r=n==="transform"?Cd:yl;return this.attrTween(t,typeof e=="function"?(n.local?Zd:Gd)(n,r,Qi(this,"attr."+t,e)):e==null?(n.local?Vd:Ud)(n):(n.local?Kd:Xd)(n,r,e))}function Qd(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function qd(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function tp(t,e){var n,r;function a(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&qd(t,i)),n}return a._value=e,a}function ep(t,e){var n,r;function a(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Qd(t,i)),n}return a._value=e,a}function np(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=wa(t);return this.tween(n,(r.local?tp:ep)(r,e))}function rp(t,e){return function(){Zi(this,t).delay=+e.apply(this,arguments)}}function ap(t,e){return e=+e,function(){Zi(this,t).delay=e}}function ip(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?rp:ap)(e,t)):nn(this.node(),e).delay}function sp(t,e){return function(){ln(this,t).duration=+e.apply(this,arguments)}}function op(t,e){return e=+e,function(){ln(this,t).duration=e}}function lp(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?sp:op)(e,t)):nn(this.node(),e).duration}function cp(t,e){if(typeof e!="function")throw new Error;return function(){ln(this,t).ease=e}}function up(t){var e=this._id;return arguments.length?this.each(cp(e,t)):nn(this.node(),e).ease}function fp(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;ln(this,t).ease=n}}function hp(t){if(typeof t!="function")throw new Error;return this.each(fp(this._id,t))}function dp(t){typeof t!="function"&&(t=bo(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],s=i.length,o=r[a]=[],l,c=0;c<s;++c)(l=i[c])&&t.call(l,l.__data__,c,i)&&o.push(l);return new xn(r,this._parents,this._name,this._id)}function pp(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,a=n.length,i=Math.min(r,a),s=new Array(r),o=0;o<i;++o)for(var l=e[o],c=n[o],u=l.length,h=s[o]=new Array(u),f,g=0;g<u;++g)(f=l[g]||c[g])&&(h[g]=f);for(;o<r;++o)s[o]=e[o];return new xn(s,this._parents,this._name,this._id)}function gp(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function yp(t,e,n){var r,a,i=gp(e)?Zi:ln;return function(){var s=i(this,t),o=s.on;o!==r&&(a=(r=o).copy()).on(e,n),s.on=a}}function xp(t,e){var n=this._id;return arguments.length<2?nn(this.node(),n).on.on(t):this.each(yp(n,t,e))}function mp(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function vp(){return this.on("end.remove",mp(this._id))}function bp(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Di(t));for(var r=this._groups,a=r.length,i=new Array(a),s=0;s<a;++s)for(var o=r[s],l=o.length,c=i[s]=new Array(l),u,h,f=0;f<l;++f)(u=o[f])&&(h=t.call(u,u.__data__,f,o))&&("__data__"in u&&(h.__data__=u.__data__),c[f]=h,Fa(c[f],e,n,f,c,nn(u,n)));return new xn(i,this._parents,e,n)}function wp(t){var e=this._name,n=this._id;typeof t!="function"&&(t=vo(t));for(var r=this._groups,a=r.length,i=[],s=[],o=0;o<a;++o)for(var l=r[o],c=l.length,u,h=0;h<c;++h)if(u=l[h]){for(var f=t.call(u,u.__data__,h,l),g,v=nn(u,n),b=0,d=f.length;b<d;++b)(g=f[b])&&Fa(g,e,n,b,f,v);i.push(f),s.push(u)}return new xn(i,s,e,n)}var _p=Lr.prototype.constructor;function kp(){return new _p(this._groups,this._parents)}function Ap(t,e){var n,r,a;return function(){var i=qn(this,t),s=(this.style.removeProperty(t),qn(this,t));return i===s?null:i===n&&s===r?a:a=e(n=i,r=s)}}function xl(t){return function(){this.style.removeProperty(t)}}function Sp(t,e,n){var r,a=n+"",i;return function(){var s=qn(this,t);return s===a?null:s===r?i:i=e(r=s,n)}}function Mp(t,e,n){var r,a,i;return function(){var s=qn(this,t),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(t),qn(this,t))),s===l?null:s===r&&l===a?i:(a=l,i=e(r=s,o))}}function Np(t,e){var n,r,a,i="style."+e,s="end."+i,o;return function(){var l=ln(this,t),c=l.on,u=l.value[i]==null?o||(o=xl(e)):void 0;(c!==n||a!==u)&&(r=(n=c).copy()).on(s,a=u),l.on=r}}function Tp(t,e,n){var r=(t+="")=="transform"?$d:yl;return e==null?this.styleTween(t,Ap(t,r)).on("end.style."+t,xl(t)):typeof e=="function"?this.styleTween(t,Mp(t,r,Qi(this,"style."+t,e))).each(Np(this._id,t)):this.styleTween(t,Sp(t,r,e),n).on("end.style."+t,null)}function Dp(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function $p(t,e,n){var r,a;function i(){var s=e.apply(this,arguments);return s!==a&&(r=(a=s)&&Dp(t,s,n)),r}return i._value=e,i}function Cp(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,$p(t,e,n??""))}function Lp(t){return function(){this.textContent=t}}function jp(t){return function(){var e=t(this);this.textContent=e??""}}function Pp(t){return this.tween("text",typeof t=="function"?jp(Qi(this,"text",t)):Lp(t==null?"":t+""))}function Ep(t){return function(e){this.textContent=t.call(this,e)}}function Rp(t){var e,n;function r(){var a=t.apply(this,arguments);return a!==n&&(e=(n=a)&&Ep(a)),e}return r._value=t,r}function zp(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,Rp(t))}function Ip(){for(var t=this._name,e=this._id,n=ml(),r=this._groups,a=r.length,i=0;i<a;++i)for(var s=r[i],o=s.length,l,c=0;c<o;++c)if(l=s[c]){var u=nn(l,e);Fa(l,t,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new xn(r,this._parents,t,n)}function Fp(){var t,e,n=this,r=n._id,a=n.size();return new Promise(function(i,s){var o={value:s},l={value:function(){--a===0&&i()}};n.each(function(){var c=ln(this,r),u=c.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(o),e._.interrupt.push(o),e._.end.push(l)),c.on=e}),a===0&&i()})}var Hp=0;function xn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function ml(){return++Hp}var mn=Lr.prototype;xn.prototype={constructor:xn,select:bp,selectAll:wp,selectChild:mn.selectChild,selectChildren:mn.selectChildren,filter:dp,merge:pp,selection:kp,transition:Ip,call:mn.call,nodes:mn.nodes,node:mn.node,size:mn.size,empty:mn.empty,each:mn.each,on:xp,attr:Jd,attrTween:np,style:Tp,styleTween:Cp,text:Pp,textTween:zp,remove:vp,tween:Yd,delay:ip,duration:lp,ease:up,easeVarying:hp,end:Fp,[Symbol.iterator]:mn[Symbol.iterator]};function Wp(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Op={time:null,delay:0,duration:250,ease:Wp};function Bp(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function Yp(t){var e,n;t instanceof xn?(e=t._id,t=t._name):(e=ml(),(n=Op).time=Ui(),t=t==null?null:t+"");for(var r=this._groups,a=r.length,i=0;i<a;++i)for(var s=r[i],o=s.length,l,c=0;c<o;++c)(l=s[c])&&Fa(l,t,e,c,s,n||Bp(l,e));return new xn(r,this._parents,t,e)}Lr.prototype.interrupt=Wd,Lr.prototype.transition=Yp;const qi=t=>()=>t;function Up(t,{sourceEvent:e,target:n,selection:r,mode:a,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:a,enumerable:!0,configurable:!0},_:{value:i}})}function Vp(t){t.stopImmediatePropagation()}function ts(t){t.preventDefault(),t.stopImmediatePropagation()}var vl={name:"drag"},es={name:"space"},or={name:"handle"},lr={name:"center"};const{abs:bl,max:$e,min:Ce}=Math;function wl(t){return[+t[0],+t[1]]}function _l(t){return[wl(t[0]),wl(t[1])]}var Ha={name:"x",handles:["w","e"].map(rs),input:function(t,e){return t==null?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},ns={},vn={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"},kl={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},Al={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},Xp={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},Kp={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function rs(t){return{type:t}}function Gp(t){return!t.ctrlKey&&!t.button}function Zp(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function Jp(){return navigator.maxTouchPoints||"ontouchstart"in this}function as(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function Qp(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}function Sl(){return qp(Ha)}function qp(t){var e=Zp,n=Gp,r=Jp,a=!0,i=Cr("start","brush","end"),s=6,o;function l(d){var x=d.property("__brush",b).selectAll(".overlay").data([rs("overlay")]);x.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",vn.overlay).merge(x).each(function(){var w=as(this).extent;qt(this).attr("x",w[0][0]).attr("y",w[0][1]).attr("width",w[1][0]-w[0][0]).attr("height",w[1][1]-w[0][1])}),d.selectAll(".selection").data([rs("selection")]).enter().append("rect").attr("class","selection").attr("cursor",vn.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var S=d.selectAll(".handle").data(t.handles,function(w){return w.type});S.exit().remove(),S.enter().append("rect").attr("class",function(w){return"handle handle--"+w.type}).attr("cursor",function(w){return vn[w.type]}),d.each(c).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",f).filter(r).on("touchstart.brush",f).on("touchmove.brush",g).on("touchend.brush touchcancel.brush",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}l.move=function(d,x,S){d.tween?d.on("start.brush",function(w){u(this,arguments).beforestart().start(w)}).on("interrupt.brush end.brush",function(w){u(this,arguments).end(w)}).tween("brush",function(){var w=this,y=w.__brush,T=u(w,arguments),p=y.selection,k=t.input(typeof x=="function"?x.apply(this,arguments):x,y.extent),_=Ae(p,k);function E(R){y.selection=R===1&&k===null?null:_(R),c.call(w),T.brush()}return p!==null&&k!==null?E:E(1)}):d.each(function(){var w=this,y=arguments,T=w.__brush,p=t.input(typeof x=="function"?x.apply(w,y):x,T.extent),k=u(w,y).beforestart();Ji(w),T.selection=p===null?null:p,c.call(w),k.start(S).brush(S).end(S)})},l.clear=function(d,x){l.move(d,null,x)};function c(){var d=qt(this),x=as(this).selection;x?(d.selectAll(".selection").style("display",null).attr("x",x[0][0]).attr("y",x[0][1]).attr("width",x[1][0]-x[0][0]).attr("height",x[1][1]-x[0][1]),d.selectAll(".handle").style("display",null).attr("x",function(S){return S.type[S.type.length-1]==="e"?x[1][0]-s/2:x[0][0]-s/2}).attr("y",function(S){return S.type[0]==="s"?x[1][1]-s/2:x[0][1]-s/2}).attr("width",function(S){return S.type==="n"||S.type==="s"?x[1][0]-x[0][0]+s:s}).attr("height",function(S){return S.type==="e"||S.type==="w"?x[1][1]-x[0][1]+s:s})):d.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(d,x,S){var w=d.__brush.emitter;return w&&(!S||!w.clean)?w:new h(d,x,S)}function h(d,x,S){this.that=d,this.args=x,this.state=d.__brush,this.active=0,this.clean=S}h.prototype={beforestart:function(){return++this.active===1&&(this.state.emitter=this,this.starting=!0),this},start:function(d,x){return this.starting?(this.starting=!1,this.emit("start",d,x)):this.emit("brush",d),this},brush:function(d,x){return this.emit("brush",d,x),this},end:function(d,x){return--this.active===0&&(delete this.state.emitter,this.emit("end",d,x)),this},emit:function(d,x,S){var w=qt(this.that).datum();i.call(d,this.that,new Up(d,{sourceEvent:x,target:l,selection:t.output(this.state.selection),mode:S,dispatch:i}),w)}};function f(d){if(o&&!d.touches||!n.apply(this,arguments))return;var x=this,S=d.target.__data__.type,w=(a&&d.metaKey?S="overlay":S)==="selection"?vl:a&&d.altKey?lr:or,y=t===ns?null:Xp[S],T=t===Ha?null:Kp[S],p=as(x),k=p.extent,_=p.selection,E=k[0][0],R,z,I=k[0][1],N,U,M=k[1][0],Y,C,F=k[1][1],H,V,et=0,$=0,dt,wt=y&&T&&a&&d.shiftKey,pt,_t,G=Array.from(d.touches||[d],st=>{const it=st.identifier;return st=tr(st,x),st.point0=st.slice(),st.identifier=it,st});Ji(x);var ot=u(x,arguments,!0).beforestart();if(S==="overlay"){_&&(dt=!0);const st=[G[0],G[1]||G[0]];p.selection=_=[[R=t===ns?E:Ce(st[0][0],st[1][0]),N=t===Ha?I:Ce(st[0][1],st[1][1])],[Y=t===ns?M:$e(st[0][0],st[1][0]),H=t===Ha?F:$e(st[0][1],st[1][1])]],G.length>1&&tt(d)}else R=_[0][0],N=_[0][1],Y=_[1][0],H=_[1][1];z=R,U=N,C=Y,V=H;var O=qt(x).attr("pointer-events","none"),Q=O.selectAll(".overlay").attr("cursor",vn[S]);if(d.touches)ot.moved=D,ot.ended=L;else{var X=qt(d.view).on("mousemove.brush",D,!0).on("mouseup.brush",L,!0);a&&X.on("keydown.brush",Z,!0).on("keyup.brush",ft,!0),$o(d.view)}c.call(x),ot.start(d,w.name);function D(st){for(const it of st.changedTouches||[st])for(const A of G)A.identifier===it.identifier&&(A.cur=tr(it,x));if(wt&&!pt&&!_t&&G.length===1){const it=G[0];bl(it.cur[0]-it[0])>bl(it.cur[1]-it[1])?_t=!0:pt=!0}for(const it of G)it.cur&&(it[0]=it.cur[0],it[1]=it.cur[1]);dt=!0,ts(st),tt(st)}function tt(st){const it=G[0],A=it.point0;var j;switch(et=it[0]-A[0],$=it[1]-A[1],w){case es:case vl:{y&&(et=$e(E-R,Ce(M-Y,et)),z=R+et,C=Y+et),T&&($=$e(I-N,Ce(F-H,$)),U=N+$,V=H+$);break}case or:{G[1]?(y&&(z=$e(E,Ce(M,G[0][0])),C=$e(E,Ce(M,G[1][0])),y=1),T&&(U=$e(I,Ce(F,G[0][1])),V=$e(I,Ce(F,G[1][1])),T=1)):(y<0?(et=$e(E-R,Ce(M-R,et)),z=R+et,C=Y):y>0&&(et=$e(E-Y,Ce(M-Y,et)),z=R,C=Y+et),T<0?($=$e(I-N,Ce(F-N,$)),U=N+$,V=H):T>0&&($=$e(I-H,Ce(F-H,$)),U=N,V=H+$));break}case lr:{y&&(z=$e(E,Ce(M,R-et*y)),C=$e(E,Ce(M,Y+et*y))),T&&(U=$e(I,Ce(F,N-$*T)),V=$e(I,Ce(F,H+$*T)));break}}C<z&&(y*=-1,j=R,R=Y,Y=j,j=z,z=C,C=j,S in kl&&Q.attr("cursor",vn[S=kl[S]])),V<U&&(T*=-1,j=N,N=H,H=j,j=U,U=V,V=j,S in Al&&Q.attr("cursor",vn[S=Al[S]])),p.selection&&(_=p.selection),pt&&(z=_[0][0],C=_[1][0]),_t&&(U=_[0][1],V=_[1][1]),(_[0][0]!==z||_[0][1]!==U||_[1][0]!==C||_[1][1]!==V)&&(p.selection=[[z,U],[C,V]],c.call(x),ot.brush(st,w.name))}function L(st){if(Vp(st),st.touches){if(st.touches.length)return;o&&clearTimeout(o),o=setTimeout(function(){o=null},500)}else Co(st.view,dt),X.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);O.attr("pointer-events","all"),Q.attr("cursor",vn.overlay),p.selection&&(_=p.selection),Qp(_)&&(p.selection=null,c.call(x)),ot.end(st,w.name)}function Z(st){switch(st.keyCode){case 16:{wt=y&&T;break}case 18:{w===or&&(y&&(Y=C-et*y,R=z+et*y),T&&(H=V-$*T,N=U+$*T),w=lr,tt(st));break}case 32:{(w===or||w===lr)&&(y<0?Y=C-et:y>0&&(R=z-et),T<0?H=V-$:T>0&&(N=U-$),w=es,Q.attr("cursor",vn.selection),tt(st));break}default:return}ts(st)}function ft(st){switch(st.keyCode){case 16:{wt&&(pt=_t=wt=!1,tt(st));break}case 18:{w===lr&&(y<0?Y=C:y>0&&(R=z),T<0?H=V:T>0&&(N=U),w=or,tt(st));break}case 32:{w===es&&(st.altKey?(y&&(Y=C-et*y,R=z+et*y),T&&(H=V-$*T,N=U+$*T),w=lr):(y<0?Y=C:y>0&&(R=z),T<0?H=V:T>0&&(N=U),w=or),Q.attr("cursor",vn[S]),tt(st));break}default:return}ts(st)}}function g(d){u(this,arguments).moved(d)}function v(d){u(this,arguments).ended(d)}function b(){var d=this.__brush||{selection:null};return d.extent=_l(e.apply(this,arguments)),d.dim=t,d}return l.extent=function(d){return arguments.length?(e=typeof d=="function"?d:qi(_l(d)),l):e},l.filter=function(d){return arguments.length?(n=typeof d=="function"?d:qi(!!d),l):n},l.touchable=function(d){return arguments.length?(r=typeof d=="function"?d:qi(!!d),l):r},l.handleSize=function(d){return arguments.length?(s=+d,l):s},l.keyModifiers=function(d){return arguments.length?(a=!!d,l):a},l.on=function(){var d=i.on.apply(i,arguments);return d===i?l:d},l}var Ml=Math.abs,is=Math.cos,ss=Math.sin,Nl=Math.PI,Wa=Nl/2,Tl=Nl*2,Dl=Math.max,os=1e-12;function $l(t,e){return Array.from({length:e-t},(n,r)=>t+r)}function t0(t){return function(e,n){return t(e.source.value+e.target.value,n.source.value+n.target.value)}}function e0(){return n0(!1)}function n0(t,e){var n=0,r=null,a=null,i=null;function s(o){var l=o.length,c=new Array(l),u=$l(0,l),h=new Array(l*l),f=new Array(l),g=0,v;o=Float64Array.from({length:l*l},(b,d)=>o[d/l|0][d%l]);for(let b=0;b<l;++b){let d=0;for(let x=0;x<l;++x)d+=o[b*l+x]+t*o[x*l+b];g+=c[b]=d}g=Dl(0,Tl-n*l)/g,v=g?n:Tl/l;{let b=0;r&&u.sort((d,x)=>r(c[d],c[x]));for(const d of u){const x=b;{const S=$l(0,l).filter(w=>o[d*l+w]||o[w*l+d]);a&&S.sort((w,y)=>a(o[d*l+w],o[d*l+y]));for(const w of S){let y;if(d<w?(y=h[d*l+w]||(h[d*l+w]={source:null,target:null}),y.source={index:d,startAngle:b,endAngle:b+=o[d*l+w]*g,value:o[d*l+w]}):(y=h[w*l+d]||(h[w*l+d]={source:null,target:null}),y.target={index:d,startAngle:b,endAngle:b+=o[d*l+w]*g,value:o[d*l+w]},d===w&&(y.source=y.target)),y.source&&y.target&&y.source.value<y.target.value){const T=y.source;y.source=y.target,y.target=T}}f[d]={index:d,startAngle:x,endAngle:b,value:c[d]}}b+=v}}return h=Object.values(h),h.groups=f,i?h.sort(i):h}return s.padAngle=function(o){return arguments.length?(n=Dl(0,o),s):n},s.sortGroups=function(o){return arguments.length?(r=o,s):r},s.sortSubgroups=function(o){return arguments.length?(a=o,s):a},s.sortChords=function(o){return arguments.length?(o==null?i=null:(i=t0(o))._=o,s):i&&i._},s}const ls=Math.PI,cs=2*ls,In=1e-6,r0=cs-In;function Cl(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function a0(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Cl;const n=10**e;return function(r){this._+=r[0];for(let a=1,i=r.length;a<i;++a)this._+=Math.round(arguments[a]*n)/n+r[a]}}let us=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?Cl:a0(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,a){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+a}`}bezierCurveTo(e,n,r,a,i,s){this._append`C${+e},${+n},${+r},${+a},${this._x1=+i},${this._y1=+s}`}arcTo(e,n,r,a,i){if(e=+e,n=+n,r=+r,a=+a,i=+i,i<0)throw new Error(`negative radius: ${i}`);let s=this._x1,o=this._y1,l=r-e,c=a-n,u=s-e,h=o-n,f=u*u+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(f>In)if(!(Math.abs(h*l-c*u)>In)||!i)this._append`L${this._x1=e},${this._y1=n}`;else{let g=r-s,v=a-o,b=l*l+c*c,d=g*g+v*v,x=Math.sqrt(b),S=Math.sqrt(f),w=i*Math.tan((ls-Math.acos((b+f-d)/(2*x*S)))/2),y=w/S,T=w/x;Math.abs(y-1)>In&&this._append`L${e+y*u},${n+y*h}`,this._append`A${i},${i},0,0,${+(h*g>u*v)},${this._x1=e+T*l},${this._y1=n+T*c}`}}arc(e,n,r,a,i,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(a),l=r*Math.sin(a),c=e+o,u=n+l,h=1^s,f=s?a-i:i-a;this._x1===null?this._append`M${c},${u}`:(Math.abs(this._x1-c)>In||Math.abs(this._y1-u)>In)&&this._append`L${c},${u}`,r&&(f<0&&(f=f%cs+cs),f>r0?this._append`A${r},${r},0,1,${h},${e-o},${n-l}A${r},${r},0,1,${h},${this._x1=c},${this._y1=u}`:f>In&&this._append`A${r},${r},0,${+(f>=ls)},${h},${this._x1=e+r*Math.cos(i)},${this._y1=n+r*Math.sin(i)}`)}rect(e,n,r,a){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+a}h${-r}Z`}toString(){return this._}};function Ll(){return new us}Ll.prototype=us.prototype;var i0=Array.prototype.slice;function cr(t){return function(){return t}}function s0(t){return t.source}function o0(t){return t.target}function jl(t){return t.radius}function l0(t){return t.startAngle}function c0(t){return t.endAngle}function u0(){return 0}function f0(t){var e=s0,n=o0,r=jl,a=jl,i=l0,s=c0,o=u0,l=null;function c(){var u,h=e.apply(this,arguments),f=n.apply(this,arguments),g=o.apply(this,arguments)/2,v=i0.call(arguments),b=+r.apply(this,(v[0]=h,v)),d=i.apply(this,v)-Wa,x=s.apply(this,v)-Wa,S=+a.apply(this,(v[0]=f,v)),w=i.apply(this,v)-Wa,y=s.apply(this,v)-Wa;if(l||(l=u=Ll()),g>os&&(Ml(x-d)>g*2+os?x>d?(d+=g,x-=g):(d-=g,x+=g):d=x=(d+x)/2,Ml(y-w)>g*2+os?y>w?(w+=g,y-=g):(w-=g,y+=g):w=y=(w+y)/2),l.moveTo(b*is(d),b*ss(d)),l.arc(0,0,b,d,x),(d!==w||x!==y)&&(l.quadraticCurveTo(0,0,S*is(w),S*ss(w)),l.arc(0,0,S,w,y)),l.quadraticCurveTo(0,0,b*is(d),b*ss(d)),l.closePath(),u)return l=null,u+""||null}return c.radius=function(u){return arguments.length?(r=a=typeof u=="function"?u:cr(+u),c):r},c.sourceRadius=function(u){return arguments.length?(r=typeof u=="function"?u:cr(+u),c):r},c.targetRadius=function(u){return arguments.length?(a=typeof u=="function"?u:cr(+u),c):a},c.startAngle=function(u){return arguments.length?(i=typeof u=="function"?u:cr(+u),c):i},c.endAngle=function(u){return arguments.length?(s=typeof u=="function"?u:cr(+u),c):s},c.padAngle=function(u){return arguments.length?(o=typeof u=="function"?u:cr(+u),c):o},c.source=function(u){return arguments.length?(e=u,c):e},c.target=function(u){return arguments.length?(n=u,c):n},c.context=function(u){return arguments.length?(l=u??null,c):l},c}function h0(){return f0()}function fs(t,e){var n,r=1;t==null&&(t=0),e==null&&(e=0);function a(){var i,s=n.length,o,l=0,c=0;for(i=0;i<s;++i)o=n[i],l+=o.x,c+=o.y;for(l=(l/s-t)*r,c=(c/s-e)*r,i=0;i<s;++i)o=n[i],o.x-=l,o.y-=c}return a.initialize=function(i){n=i},a.x=function(i){return arguments.length?(t=+i,a):t},a.y=function(i){return arguments.length?(e=+i,a):e},a.strength=function(i){return arguments.length?(r=+i,a):r},a}function d0(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Pl(this.cover(e,n),e,n,t)}function Pl(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var a,i=t._root,s={data:r},o=t._x0,l=t._y0,c=t._x1,u=t._y1,h,f,g,v,b,d,x,S;if(!i)return t._root=s,t;for(;i.length;)if((b=e>=(h=(o+c)/2))?o=h:c=h,(d=n>=(f=(l+u)/2))?l=f:u=f,a=i,!(i=i[x=d<<1|b]))return a[x]=s,t;if(g=+t._x.call(null,i.data),v=+t._y.call(null,i.data),e===g&&n===v)return s.next=i,a?a[x]=s:t._root=s,t;do a=a?a[x]=new Array(4):t._root=new Array(4),(b=e>=(h=(o+c)/2))?o=h:c=h,(d=n>=(f=(l+u)/2))?l=f:u=f;while((x=d<<1|b)===(S=(v>=f)<<1|g>=h));return a[S]=i,a[x]=s,t}function p0(t){var e,n,r=t.length,a,i,s=new Array(r),o=new Array(r),l=1/0,c=1/0,u=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(a=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(s[n]=a,o[n]=i,a<l&&(l=a),a>u&&(u=a),i<c&&(c=i),i>h&&(h=i));if(l>u||c>h)return this;for(this.cover(l,c).cover(u,h),n=0;n<r;++n)Pl(this,s[n],o[n],t[n]);return this}function g0(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,a=this._x1,i=this._y1;if(isNaN(n))a=(n=Math.floor(t))+1,i=(r=Math.floor(e))+1;else{for(var s=a-n||1,o=this._root,l,c;n>t||t>=a||r>e||e>=i;)switch(c=(e<r)<<1|t<n,l=new Array(4),l[c]=o,o=l,s*=2,c){case 0:a=n+s,i=r+s;break;case 1:n=a-s,i=r+s;break;case 2:a=n+s,r=i-s;break;case 3:n=a-s,r=i-s;break}this._root&&this._root.length&&(this._root=o)}return this._x0=n,this._y0=r,this._x1=a,this._y1=i,this}function y0(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function x0(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function ze(t,e,n,r,a){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=a}function m0(t,e,n){var r,a=this._x0,i=this._y0,s,o,l,c,u=this._x1,h=this._y1,f=[],g=this._root,v,b;for(g&&f.push(new ze(g,a,i,u,h)),n==null?n=1/0:(a=t-n,i=e-n,u=t+n,h=e+n,n*=n);v=f.pop();)if(!(!(g=v.node)||(s=v.x0)>u||(o=v.y0)>h||(l=v.x1)<a||(c=v.y1)<i))if(g.length){var d=(s+l)/2,x=(o+c)/2;f.push(new ze(g[3],d,x,l,c),new ze(g[2],s,x,d,c),new ze(g[1],d,o,l,x),new ze(g[0],s,o,d,x)),(b=(e>=x)<<1|t>=d)&&(v=f[f.length-1],f[f.length-1]=f[f.length-1-b],f[f.length-1-b]=v)}else{var S=t-+this._x.call(null,g.data),w=e-+this._y.call(null,g.data),y=S*S+w*w;if(y<n){var T=Math.sqrt(n=y);a=t-T,i=e-T,u=t+T,h=e+T,r=g.data}}return r}function v0(t){if(isNaN(u=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,n=this._root,r,a,i,s=this._x0,o=this._y0,l=this._x1,c=this._y1,u,h,f,g,v,b,d,x;if(!n)return this;if(n.length)for(;;){if((v=u>=(f=(s+l)/2))?s=f:l=f,(b=h>=(g=(o+c)/2))?o=g:c=g,e=n,!(n=n[d=b<<1|v]))return this;if(!n.length)break;(e[d+1&3]||e[d+2&3]||e[d+3&3])&&(r=e,x=d)}for(;n.data!==t;)if(a=n,!(n=n.next))return this;return(i=n.next)&&delete n.next,a?(i?a.next=i:delete a.next,this):e?(i?e[d]=i:delete e[d],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[x]=n:this._root=n),this):(this._root=i,this)}function b0(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function w0(){return this._root}function _0(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function k0(t){var e=[],n,r=this._root,a,i,s,o,l;for(r&&e.push(new ze(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,i=n.x0,s=n.y0,o=n.x1,l=n.y1)&&r.length){var c=(i+o)/2,u=(s+l)/2;(a=r[3])&&e.push(new ze(a,c,u,o,l)),(a=r[2])&&e.push(new ze(a,i,u,c,l)),(a=r[1])&&e.push(new ze(a,c,s,o,u)),(a=r[0])&&e.push(new ze(a,i,s,c,u))}return this}function A0(t){var e=[],n=[],r;for(this._root&&e.push(new ze(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var a=r.node;if(a.length){var i,s=r.x0,o=r.y0,l=r.x1,c=r.y1,u=(s+l)/2,h=(o+c)/2;(i=a[0])&&e.push(new ze(i,s,o,u,h)),(i=a[1])&&e.push(new ze(i,u,o,l,h)),(i=a[2])&&e.push(new ze(i,s,h,u,c)),(i=a[3])&&e.push(new ze(i,u,h,l,c))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function S0(t){return t[0]}function M0(t){return arguments.length?(this._x=t,this):this._x}function N0(t){return t[1]}function T0(t){return arguments.length?(this._y=t,this):this._y}function Oa(t,e,n){var r=new hs(e??S0,n??N0,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function hs(t,e,n,r,a,i){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=a,this._y1=i,this._root=void 0}function El(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Ie=Oa.prototype=hs.prototype;Ie.copy=function(){var t=new hs(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=El(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var a=0;a<4;++a)(r=e.source[a])&&(r.length?n.push({source:r,target:e.target[a]=new Array(4)}):e.target[a]=El(r));return t},Ie.add=d0,Ie.addAll=p0,Ie.cover=g0,Ie.data=y0,Ie.extent=x0,Ie.find=m0,Ie.remove=v0,Ie.removeAll=b0,Ie.root=w0,Ie.size=_0,Ie.visit=k0,Ie.visitAfter=A0,Ie.x=M0,Ie.y=T0;function Fe(t){return function(){return t}}function Mn(t){return(t()-.5)*1e-6}function D0(t){return t.x+t.vx}function $0(t){return t.y+t.vy}function Wr(t){var e,n,r,a=1,i=1;typeof t!="function"&&(t=Fe(t==null?1:+t));function s(){for(var c,u=e.length,h,f,g,v,b,d,x=0;x<i;++x)for(h=Oa(e,D0,$0).visitAfter(o),c=0;c<u;++c)f=e[c],b=n[f.index],d=b*b,g=f.x+f.vx,v=f.y+f.vy,h.visit(S);function S(w,y,T,p,k){var _=w.data,E=w.r,R=b+E;if(_){if(_.index>f.index){var z=g-_.x-_.vx,I=v-_.y-_.vy,N=z*z+I*I;N<R*R&&(z===0&&(z=Mn(r),N+=z*z),I===0&&(I=Mn(r),N+=I*I),N=(R-(N=Math.sqrt(N)))/N*a,f.vx+=(z*=N)*(R=(E*=E)/(d+E)),f.vy+=(I*=N)*R,_.vx-=z*(R=1-R),_.vy-=I*R)}return}return y>g+R||p<g-R||T>v+R||k<v-R}}function o(c){if(c.data)return c.r=n[c.data.index];for(var u=c.r=0;u<4;++u)c[u]&&c[u].r>c.r&&(c.r=c[u].r)}function l(){if(e){var c,u=e.length,h;for(n=new Array(u),c=0;c<u;++c)h=e[c],n[h.index]=+t(h,c,e)}}return s.initialize=function(c,u){e=c,r=u,l()},s.iterations=function(c){return arguments.length?(i=+c,s):i},s.strength=function(c){return arguments.length?(a=+c,s):a},s.radius=function(c){return arguments.length?(t=typeof c=="function"?c:Fe(+c),l(),s):t},s}function C0(t){return t.index}function Rl(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function ds(t){var e=C0,n=h,r,a=Fe(30),i,s,o,l,c,u=1;t==null&&(t=[]);function h(d){return 1/Math.min(o[d.source.index],o[d.target.index])}function f(d){for(var x=0,S=t.length;x<u;++x)for(var w=0,y,T,p,k,_,E,R;w<S;++w)y=t[w],T=y.source,p=y.target,k=p.x+p.vx-T.x-T.vx||Mn(c),_=p.y+p.vy-T.y-T.vy||Mn(c),E=Math.sqrt(k*k+_*_),E=(E-i[w])/E*d*r[w],k*=E,_*=E,p.vx-=k*(R=l[w]),p.vy-=_*R,T.vx+=k*(R=1-R),T.vy+=_*R}function g(){if(s){var d,x=s.length,S=t.length,w=new Map(s.map((T,p)=>[e(T,p,s),T])),y;for(d=0,o=new Array(x);d<S;++d)y=t[d],y.index=d,typeof y.source!="object"&&(y.source=Rl(w,y.source)),typeof y.target!="object"&&(y.target=Rl(w,y.target)),o[y.source.index]=(o[y.source.index]||0)+1,o[y.target.index]=(o[y.target.index]||0)+1;for(d=0,l=new Array(S);d<S;++d)y=t[d],l[d]=o[y.source.index]/(o[y.source.index]+o[y.target.index]);r=new Array(S),v(),i=new Array(S),b()}}function v(){if(s)for(var d=0,x=t.length;d<x;++d)r[d]=+n(t[d],d,t)}function b(){if(s)for(var d=0,x=t.length;d<x;++d)i[d]=+a(t[d],d,t)}return f.initialize=function(d,x){s=d,c=x,g()},f.links=function(d){return arguments.length?(t=d,g(),f):t},f.id=function(d){return arguments.length?(e=d,f):e},f.iterations=function(d){return arguments.length?(u=+d,f):u},f.strength=function(d){return arguments.length?(n=typeof d=="function"?d:Fe(+d),v(),f):n},f.distance=function(d){return arguments.length?(a=typeof d=="function"?d:Fe(+d),b(),f):a},f}const L0=1664525,j0=1013904223,zl=4294967296;function P0(){let t=1;return()=>(t=(L0*t+j0)%zl)/zl}function E0(t){return t.x}function R0(t){return t.y}var z0=10,I0=Math.PI*(3-Math.sqrt(5));function F0(t){var e,n=1,r=.001,a=1-Math.pow(r,1/300),i=0,s=.6,o=new Map,l=Vi(h),c=Cr("tick","end"),u=P0();t==null&&(t=[]);function h(){f(),c.call("tick",e),n<r&&(l.stop(),c.call("end",e))}function f(b){var d,x=t.length,S;b===void 0&&(b=1);for(var w=0;w<b;++w)for(n+=(i-n)*a,o.forEach(function(y){y(n)}),d=0;d<x;++d)S=t[d],S.fx==null?S.x+=S.vx*=s:(S.x=S.fx,S.vx=0),S.fy==null?S.y+=S.vy*=s:(S.y=S.fy,S.vy=0);return e}function g(){for(var b=0,d=t.length,x;b<d;++b){if(x=t[b],x.index=b,x.fx!=null&&(x.x=x.fx),x.fy!=null&&(x.y=x.fy),isNaN(x.x)||isNaN(x.y)){var S=z0*Math.sqrt(.5+b),w=b*I0;x.x=S*Math.cos(w),x.y=S*Math.sin(w)}(isNaN(x.vx)||isNaN(x.vy))&&(x.vx=x.vy=0)}}function v(b){return b.initialize&&b.initialize(t,u),b}return g(),e={tick:f,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(b){return arguments.length?(t=b,g(),o.forEach(v),e):t},alpha:function(b){return arguments.length?(n=+b,e):n},alphaMin:function(b){return arguments.length?(r=+b,e):r},alphaDecay:function(b){return arguments.length?(a=+b,e):+a},alphaTarget:function(b){return arguments.length?(i=+b,e):i},velocityDecay:function(b){return arguments.length?(s=1-b,e):1-s},randomSource:function(b){return arguments.length?(u=b,o.forEach(v),e):u},force:function(b,d){return arguments.length>1?(d==null?o.delete(b):o.set(b,v(d)),e):o.get(b)},find:function(b,d,x){var S=0,w=t.length,y,T,p,k,_;for(x==null?x=1/0:x*=x,S=0;S<w;++S)k=t[S],y=b-k.x,T=d-k.y,p=y*y+T*T,p<x&&(_=k,x=p);return _},on:function(b,d){return arguments.length>1?(c.on(b,d),e):c.on(b)}}}function Or(){var t,e,n,r,a=Fe(-30),i,s=1,o=1/0,l=.81;function c(g){var v,b=t.length,d=Oa(t,E0,R0).visitAfter(h);for(r=g,v=0;v<b;++v)e=t[v],d.visit(f)}function u(){if(t){var g,v=t.length,b;for(i=new Array(v),g=0;g<v;++g)b=t[g],i[b.index]=+a(b,g,t)}}function h(g){var v=0,b,d,x=0,S,w,y;if(g.length){for(S=w=y=0;y<4;++y)(b=g[y])&&(d=Math.abs(b.value))&&(v+=b.value,x+=d,S+=d*b.x,w+=d*b.y);g.x=S/x,g.y=w/x}else{b=g,b.x=b.data.x,b.y=b.data.y;do v+=i[b.data.index];while(b=b.next)}g.value=v}function f(g,v,b,d){if(!g.value)return!0;var x=g.x-e.x,S=g.y-e.y,w=d-v,y=x*x+S*S;if(w*w/l<y)return y<o&&(x===0&&(x=Mn(n),y+=x*x),S===0&&(S=Mn(n),y+=S*S),y<s&&(y=Math.sqrt(s*y)),e.vx+=x*g.value*r/y,e.vy+=S*g.value*r/y),!0;if(g.length||y>=o)return;(g.data!==e||g.next)&&(x===0&&(x=Mn(n),y+=x*x),S===0&&(S=Mn(n),y+=S*S),y<s&&(y=Math.sqrt(s*y)));do g.data!==e&&(w=i[g.data.index]*r/y,e.vx+=x*w,e.vy+=S*w);while(g=g.next)}return c.initialize=function(g,v){t=g,n=v,u()},c.strength=function(g){return arguments.length?(a=typeof g=="function"?g:Fe(+g),u(),c):a},c.distanceMin=function(g){return arguments.length?(s=g*g,c):Math.sqrt(s)},c.distanceMax=function(g){return arguments.length?(o=g*g,c):Math.sqrt(o)},c.theta=function(g){return arguments.length?(l=g*g,c):Math.sqrt(l)},c}function Nn(t){var e=Fe(.1),n,r,a;typeof t!="function"&&(t=Fe(t==null?0:+t));function i(o){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vx+=(a[l]-u.x)*r[l]*o}function s(){if(n){var o,l=n.length;for(r=new Array(l),a=new Array(l),o=0;o<l;++o)r[o]=isNaN(a[o]=+t(n[o],o,n))?0:+e(n[o],o,n)}}return i.initialize=function(o){n=o,s()},i.strength=function(o){return arguments.length?(e=typeof o=="function"?o:Fe(+o),s(),i):e},i.x=function(o){return arguments.length?(t=typeof o=="function"?o:Fe(+o),s(),i):t},i}function Tn(t){var e=Fe(.1),n,r,a;typeof t!="function"&&(t=Fe(t==null?0:+t));function i(o){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vy+=(a[l]-u.y)*r[l]*o}function s(){if(n){var o,l=n.length;for(r=new Array(l),a=new Array(l),o=0;o<l;++o)r[o]=isNaN(a[o]=+t(n[o],o,n))?0:+e(n[o],o,n)}}return i.initialize=function(o){n=o,s()},i.strength=function(o){return arguments.length?(e=typeof o=="function"?o:Fe(+o),s(),i):e},i.y=function(o){return arguments.length?(t=typeof o=="function"?o:Fe(+o),s(),i):t},i}function H0(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Ba(t,e){if(!isFinite(t)||t===0)return null;var n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function ur(t){return t=Ba(Math.abs(t)),t?t[1]:NaN}function W0(t,e){return function(n,r){for(var a=n.length,i=[],s=0,o=t[0],l=0;a>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),i.push(n.substring(a-=o,a+o)),!((l+=o+1)>r));)o=t[s=(s+1)%t.length];return i.reverse().join(e)}}function O0(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var B0=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Ya(t){if(!(e=B0.exec(t)))throw new Error("invalid format: "+t);var e;return new ps({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Ya.prototype=ps.prototype;function ps(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}ps.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Y0(t){t:for(var e=t.length,n=1,r=-1,a;n<e;++n)switch(t[n]){case".":r=a=n;break;case"0":r===0&&(r=n),a=n;break;default:if(!+t[n])break t;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(a+1):t}var Ua;function U0(t,e){var n=Ba(t,e);if(!n)return Ua=void 0,t.toPrecision(e);var r=n[0],a=n[1],i=a-(Ua=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,s=r.length;return i===s?r:i>s?r+new Array(i-s+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+Ba(t,Math.max(0,e+i-1))[0]}function Il(t,e){var n=Ba(t,e);if(!n)return t+"";var r=n[0],a=n[1];return a<0?"0."+new Array(-a).join("0")+r:r.length>a+1?r.slice(0,a+1)+"."+r.slice(a+1):r+new Array(a-r.length+2).join("0")}const Fl={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:H0,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Il(t*100,e),r:Il,s:U0,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Hl(t){return t}var Wl=Array.prototype.map,Ol=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function V0(t){var e=t.grouping===void 0||t.thousands===void 0?Hl:W0(Wl.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",a=t.decimal===void 0?".":t.decimal+"",i=t.numerals===void 0?Hl:O0(Wl.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function c(h,f){h=Ya(h);var g=h.fill,v=h.align,b=h.sign,d=h.symbol,x=h.zero,S=h.width,w=h.comma,y=h.precision,T=h.trim,p=h.type;p==="n"?(w=!0,p="g"):Fl[p]||(y===void 0&&(y=12),T=!0,p="g"),(x||g==="0"&&v==="=")&&(x=!0,g="0",v="=");var k=(f&&f.prefix!==void 0?f.prefix:"")+(d==="$"?n:d==="#"&&/[boxX]/.test(p)?"0"+p.toLowerCase():""),_=(d==="$"?r:/[%p]/.test(p)?s:"")+(f&&f.suffix!==void 0?f.suffix:""),E=Fl[p],R=/[defgprs%]/.test(p);y=y===void 0?6:/[gprs]/.test(p)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y));function z(I){var N=k,U=_,M,Y,C;if(p==="c")U=E(I)+U,I="";else{I=+I;var F=I<0||1/I<0;if(I=isNaN(I)?l:E(Math.abs(I),y),T&&(I=Y0(I)),F&&+I==0&&b!=="+"&&(F=!1),N=(F?b==="("?b:o:b==="-"||b==="("?"":b)+N,U=(p==="s"&&!isNaN(I)&&Ua!==void 0?Ol[8+Ua/3]:"")+U+(F&&b==="("?")":""),R){for(M=-1,Y=I.length;++M<Y;)if(C=I.charCodeAt(M),48>C||C>57){U=(C===46?a+I.slice(M+1):I.slice(M))+U,I=I.slice(0,M);break}}}w&&!x&&(I=e(I,1/0));var H=N.length+I.length+U.length,V=H<S?new Array(S-H+1).join(g):"";switch(w&&x&&(I=e(V+I,V.length?S-U.length:1/0),V=""),v){case"<":I=N+I+U+V;break;case"=":I=N+V+I+U;break;case"^":I=V.slice(0,H=V.length>>1)+N+I+U+V.slice(H);break;default:I=V+N+I+U;break}return i(I)}return z.toString=function(){return h+""},z}function u(h,f){var g=Math.max(-8,Math.min(8,Math.floor(ur(f)/3)))*3,v=Math.pow(10,-g),b=c((h=Ya(h),h.type="f",h),{suffix:Ol[8+g/3]});return function(d){return b(v*d)}}return{format:c,formatPrefix:u}}var Va,pe,Bl;X0({thousands:",",grouping:[3],currency:["$",""]});function X0(t){return Va=V0(t),pe=Va.format,Bl=Va.formatPrefix,Va}function K0(t){return Math.max(0,-ur(Math.abs(t)))}function G0(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ur(e)/3)))*3-ur(Math.abs(t)))}function Z0(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,ur(e)-ur(t))+1}function J0(t){var e=0,n=t.children,r=n&&n.length;if(!r)e=1;else for(;--r>=0;)e+=n[r].value;t.value=e}function Q0(){return this.eachAfter(J0)}function q0(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this}function tg(t,e){for(var n=this,r=[n],a,i,s=-1;n=r.pop();)if(t.call(e,n,++s,this),a=n.children)for(i=a.length-1;i>=0;--i)r.push(a[i]);return this}function eg(t,e){for(var n=this,r=[n],a=[],i,s,o,l=-1;n=r.pop();)if(a.push(n),i=n.children)for(s=0,o=i.length;s<o;++s)r.push(i[s]);for(;n=a.pop();)t.call(e,n,++l,this);return this}function ng(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r}function rg(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,a=r&&r.length;--a>=0;)n+=r[a].value;e.value=n})}function ag(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function ig(t){for(var e=this,n=sg(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var a=r.length;t!==n;)r.splice(a,0,t),t=t.parent;return r}function sg(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),a=null;for(t=n.pop(),e=r.pop();t===e;)a=t,t=n.pop(),e=r.pop();return a}function og(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function lg(){return Array.from(this)}function cg(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function ug(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function*fg(){var t=this,e,n=[t],r,a,i;do for(e=n.reverse(),n=[];t=e.pop();)if(yield t,r=t.children)for(a=0,i=r.length;a<i;++a)n.push(r[a]);while(n.length)}function fr(t,e){t instanceof Map?(t=[void 0,t],e===void 0&&(e=pg)):e===void 0&&(e=dg);for(var n=new Br(t),r,a=[n],i,s,o,l;r=a.pop();)if((s=e(r.data))&&(l=(s=Array.from(s)).length))for(r.children=s,o=l-1;o>=0;--o)a.push(i=s[o]=new Br(s[o])),i.parent=r,i.depth=r.depth+1;return n.eachBefore(yg)}function hg(){return fr(this).eachBefore(gg)}function dg(t){return t.children}function pg(t){return Array.isArray(t)?t[1]:null}function gg(t){t.data.value!==void 0&&(t.value=t.data.value),t.data=t.data.data}function yg(t){var e=0;do t.height=e;while((t=t.parent)&&t.height<++e)}function Br(t){this.data=t,this.depth=this.height=0,this.parent=null}Br.prototype=fr.prototype={constructor:Br,count:Q0,each:q0,eachAfter:eg,eachBefore:tg,find:ng,sum:rg,sort:ag,path:ig,ancestors:og,descendants:lg,leaves:cg,links:ug,copy:hg,[Symbol.iterator]:fg};function xg(t){return t==null?null:mg(t)}function mg(t){if(typeof t!="function")throw new Error;return t}function Yl(){return 0}function vg(t){return function(){return t}}const bg=1664525,wg=1013904223,Ul=4294967296;function _g(){let t=1;return()=>(t=(bg*t+wg)%Ul)/Ul}function kg(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Ag(t,e){let n=t.length,r,a;for(;n;)a=e()*n--|0,r=t[n],t[n]=t[a],t[a]=r;return t}function Sg(t,e){for(var n=0,r=(t=Ag(Array.from(t),e)).length,a=[],i,s;n<r;)i=t[n],s&&Vl(s,i)?++n:(s=Ng(a=Mg(a,i)),n=0);return s}function Mg(t,e){var n,r;if(gs(e,t))return[e];for(n=0;n<t.length;++n)if(Xa(e,t[n])&&gs(Yr(t[n],e),t))return[t[n],e];for(n=0;n<t.length-1;++n)for(r=n+1;r<t.length;++r)if(Xa(Yr(t[n],t[r]),e)&&Xa(Yr(t[n],e),t[r])&&Xa(Yr(t[r],e),t[n])&&gs(Xl(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function Xa(t,e){var n=t.r-e.r,r=e.x-t.x,a=e.y-t.y;return n<0||n*n<r*r+a*a}function Vl(t,e){var n=t.r-e.r+Math.max(t.r,e.r,1)*1e-9,r=e.x-t.x,a=e.y-t.y;return n>0&&n*n>r*r+a*a}function gs(t,e){for(var n=0;n<e.length;++n)if(!Vl(t,e[n]))return!1;return!0}function Ng(t){switch(t.length){case 1:return Tg(t[0]);case 2:return Yr(t[0],t[1]);case 3:return Xl(t[0],t[1],t[2])}}function Tg(t){return{x:t.x,y:t.y,r:t.r}}function Yr(t,e){var n=t.x,r=t.y,a=t.r,i=e.x,s=e.y,o=e.r,l=i-n,c=s-r,u=o-a,h=Math.sqrt(l*l+c*c);return{x:(n+i+l/h*u)/2,y:(r+s+c/h*u)/2,r:(h+a+o)/2}}function Xl(t,e,n){var r=t.x,a=t.y,i=t.r,s=e.x,o=e.y,l=e.r,c=n.x,u=n.y,h=n.r,f=r-s,g=r-c,v=a-o,b=a-u,d=l-i,x=h-i,S=r*r+a*a-i*i,w=S-s*s-o*o+l*l,y=S-c*c-u*u+h*h,T=g*v-f*b,p=(v*y-b*w)/(T*2)-r,k=(b*d-v*x)/T,_=(g*w-f*y)/(T*2)-a,E=(f*x-g*d)/T,R=k*k+E*E-1,z=2*(i+p*k+_*E),I=p*p+_*_-i*i,N=-(Math.abs(R)>1e-6?(z+Math.sqrt(z*z-4*R*I))/(2*R):I/z);return{x:r+p+k*N,y:a+_+E*N,r:N}}function Kl(t,e,n){var r=t.x-e.x,a,i,s=t.y-e.y,o,l,c=r*r+s*s;c?(i=e.r+n.r,i*=i,l=t.r+n.r,l*=l,i>l?(a=(c+l-i)/(2*c),o=Math.sqrt(Math.max(0,l/c-a*a)),n.x=t.x-a*r-o*s,n.y=t.y-a*s+o*r):(a=(c+i-l)/(2*c),o=Math.sqrt(Math.max(0,i/c-a*a)),n.x=e.x+a*r-o*s,n.y=e.y+a*s+o*r)):(n.x=e.x+n.r,n.y=e.y)}function Gl(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,a=e.y-t.y;return n>0&&n*n>r*r+a*a}function Zl(t){var e=t._,n=t.next._,r=e.r+n.r,a=(e.x*n.r+n.x*e.r)/r,i=(e.y*n.r+n.y*e.r)/r;return a*a+i*i}function Ka(t){this._=t,this.next=null,this.previous=null}function Dg(t,e){if(!(i=(t=kg(t)).length))return 0;var n,r,a,i,s,o,l,c,u,h,f;if(n=t[0],n.x=0,n.y=0,!(i>1))return n.r;if(r=t[1],n.x=-r.r,r.x=n.r,r.y=0,!(i>2))return n.r+r.r;Kl(r,n,a=t[2]),n=new Ka(n),r=new Ka(r),a=new Ka(a),n.next=a.previous=r,r.next=n.previous=a,a.next=r.previous=n;t:for(l=3;l<i;++l){Kl(n._,r._,a=t[l]),a=new Ka(a),c=r.next,u=n.previous,h=r._.r,f=n._.r;do if(h<=f){if(Gl(c._,a._)){r=c,n.next=r,r.previous=n,--l;continue t}h+=c._.r,c=c.next}else{if(Gl(u._,a._)){n=u,n.next=r,r.previous=n,--l;continue t}f+=u._.r,u=u.previous}while(c!==u.next);for(a.previous=n,a.next=r,n.next=r.previous=r=a,s=Zl(n);(a=a.next)!==r;)(o=Zl(a))<s&&(n=a,s=o);r=n.next}for(n=[r._],a=r;(a=a.next)!==r;)n.push(a._);for(a=Sg(n,e),l=0;l<i;++l)n=t[l],n.x-=a.x,n.y-=a.y;return a.r}function $g(t){return Math.sqrt(t.value)}function Jl(){var t=null,e=1,n=1,r=Yl;function a(i){const s=_g();return i.x=e/2,i.y=n/2,t?i.eachBefore(Ql(t)).eachAfter(ys(r,.5,s)).eachBefore(ql(1)):i.eachBefore(Ql($g)).eachAfter(ys(Yl,1,s)).eachAfter(ys(r,i.r/Math.min(e,n),s)).eachBefore(ql(Math.min(e,n)/(2*i.r))),i}return a.radius=function(i){return arguments.length?(t=xg(i),a):t},a.size=function(i){return arguments.length?(e=+i[0],n=+i[1],a):[e,n]},a.padding=function(i){return arguments.length?(r=typeof i=="function"?i:vg(+i),a):r},a}function Ql(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function ys(t,e,n){return function(r){if(a=r.children){var a,i,s=a.length,o=t(r)*e||0,l;if(o)for(i=0;i<s;++i)a[i].r+=o;if(l=Dg(a,n),o)for(i=0;i<s;++i)a[i].r-=o;r.r=l+o}}}function ql(t){return function(e){var n=e.parent;e.r*=t,n&&(e.x=n.x+t*e.x,e.y=n.y+t*e.y)}}function Cg(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function Lg(t,e,n,r,a){for(var i=t.children,s,o=-1,l=i.length,c=t.value&&(r-e)/t.value;++o<l;)s=i[o],s.y0=n,s.y1=a,s.x0=e,s.x1=e+=s.value*c}function jg(){var t=1,e=1,n=0,r=!1;function a(s){var o=s.height+1;return s.x0=s.y0=n,s.x1=t,s.y1=e/o,s.eachBefore(i(e,o)),r&&s.eachBefore(Cg),s}function i(s,o){return function(l){l.children&&Lg(l,l.x0,s*(l.depth+1)/o,l.x1,s*(l.depth+2)/o);var c=l.x0,u=l.y0,h=l.x1-n,f=l.y1-n;h<c&&(c=h=(c+h)/2),f<u&&(u=f=(u+f)/2),l.x0=c,l.y0=u,l.x1=h,l.y1=f}}return a.round=function(s){return arguments.length?(r=!!s,a):r},a.size=function(s){return arguments.length?(t=+s[0],e=+s[1],a):[t,e]},a.padding=function(s){return arguments.length?(n=+s,a):n},a}function Pg(t,e){return t.parent===e.parent?1:2}function xs(t){var e=t.children;return e?e[0]:t.t}function ms(t){var e=t.children;return e?e[e.length-1]:t.t}function Eg(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n}function Rg(t){for(var e=0,n=0,r=t.children,a=r.length,i;--a>=0;)i=r[a],i.z+=e,i.m+=e,e+=i.s+(n+=i.c)}function zg(t,e,n){return t.a.parent===e.parent?t.a:n}function Ga(t,e){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}Ga.prototype=Object.create(Br.prototype);function Ig(t){for(var e=new Ga(t,0),n,r=[e],a,i,s,o;n=r.pop();)if(i=n._.children)for(n.children=new Array(o=i.length),s=o-1;s>=0;--s)r.push(a=n.children[s]=new Ga(i[s],s)),a.parent=n;return(e.parent=new Ga(null,0)).children=[e],e}function tc(){var t=Pg,e=1,n=1,r=null;function a(c){var u=Ig(c);if(u.eachAfter(i),u.parent.m=-u.z,u.eachBefore(s),r)c.eachBefore(l);else{var h=c,f=c,g=c;c.eachBefore(function(S){S.x<h.x&&(h=S),S.x>f.x&&(f=S),S.depth>g.depth&&(g=S)});var v=h===f?1:t(h,f)/2,b=v-h.x,d=e/(f.x+v+b),x=n/(g.depth||1);c.eachBefore(function(S){S.x=(S.x+b)*d,S.y=S.depth*x})}return c}function i(c){var u=c.children,h=c.parent.children,f=c.i?h[c.i-1]:null;if(u){Rg(c);var g=(u[0].z+u[u.length-1].z)/2;f?(c.z=f.z+t(c._,f._),c.m=c.z-g):c.z=g}else f&&(c.z=f.z+t(c._,f._));c.parent.A=o(c,f,c.parent.A||h[0])}function s(c){c._.x=c.z+c.parent.m,c.m+=c.parent.m}function o(c,u,h){if(u){for(var f=c,g=c,v=u,b=f.parent.children[0],d=f.m,x=g.m,S=v.m,w=b.m,y;v=ms(v),f=xs(f),v&&f;)b=xs(b),g=ms(g),g.a=c,y=v.z+S-f.z-d+t(v._,f._),y>0&&(Eg(zg(v,c,h),c,y),d+=y,x+=y),S+=v.m,d+=f.m,w+=b.m,x+=g.m;v&&!ms(g)&&(g.t=v,g.m+=S-x),f&&!xs(b)&&(b.t=f,b.m+=d-w,h=c)}return h}function l(c){c.x*=e,c.y=c.depth*n}return a.separation=function(c){return arguments.length?(t=c,a):t},a.size=function(c){return arguments.length?(r=!1,e=+c[0],n=+c[1],a):r?null:[e,n]},a.nodeSize=function(c){return arguments.length?(r=!0,e=+c[0],n=+c[1],a):r?[e,n]:null},a}function Ur(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}const ec=Symbol("implicit");function hr(){var t=new Ai,e=[],n=[],r=ec;function a(i){let s=t.get(i);if(s===void 0){if(r!==ec)return r;t.set(i,s=e.push(i)-1)}return n[s%n.length]}return a.domain=function(i){if(!arguments.length)return e.slice();e=[],t=new Ai;for(const s of i)t.has(s)||t.set(s,e.push(s)-1);return a},a.range=function(i){return arguments.length?(n=Array.from(i),a):n.slice()},a.unknown=function(i){return arguments.length?(r=i,a):r},a.copy=function(){return hr(e,n).unknown(r)},Ur.apply(a,arguments),a}function Xe(){var t=hr().unknown(void 0),e=t.domain,n=t.range,r=0,a=1,i,s,o=!1,l=0,c=0,u=.5;delete t.unknown;function h(){var f=e().length,g=a<r,v=g?a:r,b=g?r:a;i=(b-v)/Math.max(1,f-l+c*2),o&&(i=Math.floor(i)),v+=(b-v-i*(f-l))*u,s=i*(1-l),o&&(v=Math.round(v),s=Math.round(s));var d=ga(f).map(function(x){return v+i*x});return n(g?d.reverse():d)}return t.domain=function(f){return arguments.length?(e(f),h()):e()},t.range=function(f){return arguments.length?([r,a]=f,r=+r,a=+a,h()):[r,a]},t.rangeRound=function(f){return[r,a]=f,r=+r,a=+a,o=!0,h()},t.bandwidth=function(){return s},t.step=function(){return i},t.round=function(f){return arguments.length?(o=!!f,h()):o},t.padding=function(f){return arguments.length?(l=Math.min(1,c=+f),h()):l},t.paddingInner=function(f){return arguments.length?(l=Math.min(1,f),h()):l},t.paddingOuter=function(f){return arguments.length?(c=+f,h()):c},t.align=function(f){return arguments.length?(u=Math.max(0,Math.min(1,f)),h()):u},t.copy=function(){return Xe(e(),[r,a]).round(o).paddingInner(l).paddingOuter(c).align(u)},Ur.apply(h(),arguments)}function Fg(t){return function(){return t}}function Hg(t){return+t}var nc=[0,1];function cn(t){return t}function vs(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Fg(isNaN(e)?NaN:.5)}function Wg(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Og(t,e,n){var r=t[0],a=t[1],i=e[0],s=e[1];return a<r?(r=vs(a,r),i=n(s,i)):(r=vs(r,a),i=n(i,s)),function(o){return i(r(o))}}function Bg(t,e,n){var r=Math.min(t.length,e.length)-1,a=new Array(r),i=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)a[s]=vs(t[s],t[s+1]),i[s]=n(e[s],e[s+1]);return function(o){var l=io(t,o,1,r)-1;return i[l](a[l](o))}}function bs(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function rc(){var t=nc,e=nc,n=Ae,r,a,i,s=cn,o,l,c;function u(){var f=Math.min(t.length,e.length);return s!==cn&&(s=Wg(t[0],t[f-1])),o=f>2?Bg:Og,l=c=null,h}function h(f){return f==null||isNaN(f=+f)?i:(l||(l=o(t.map(r),e,n)))(r(s(f)))}return h.invert=function(f){return s(a((c||(c=o(e,t.map(r),en)))(f)))},h.domain=function(f){return arguments.length?(t=Array.from(f,Hg),u()):t.slice()},h.range=function(f){return arguments.length?(e=Array.from(f),u()):e.slice()},h.rangeRound=function(f){return e=Array.from(f),n=Nd,u()},h.clamp=function(f){return arguments.length?(s=f?!0:cn,u()):s!==cn},h.interpolate=function(f){return arguments.length?(n=f,u()):n},h.unknown=function(f){return arguments.length?(i=f,h):i},function(f,g){return r=f,a=g,u()}}function ac(){return rc()(cn,cn)}function Yg(t,e,n,r){var a=pa(t,e,n),i;switch(r=Ya(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(i=G0(a,s))&&(r.precision=i),Bl(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(i=Z0(a,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=i-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(i=K0(a))&&(r.precision=i-(r.type==="%")*2);break}}return pe(r)}function ic(t){var e=t.domain;return t.ticks=function(n){var r=e();return uo(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var a=e();return Yg(a[0],a[a.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),a=0,i=r.length-1,s=r[a],o=r[i],l,c,u=10;for(o<s&&(c=s,s=o,o=c,c=a,a=i,i=c);u-- >0;){if(c=Qn(s,o,n),c===l)return r[a]=s,r[i]=o,e(r);if(c>0)s=Math.floor(s/c)*c,o=Math.ceil(o/c)*c;else if(c<0)s=Math.ceil(s*c)/c,o=Math.floor(o*c)/c;else break;l=c}return t},t}function ye(){var t=ac();return t.copy=function(){return bs(t,ye())},Ur.apply(t,arguments),ic(t)}function Ug(t,e){t=t.slice();var n=0,r=t.length-1,a=t[n],i=t[r],s;return i<a&&(s=n,n=r,r=s,s=a,a=i,i=s),t[n]=e.floor(a),t[r]=e.ceil(i),t}function sc(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Vg(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Xg(t){return t<0?-t*t:t*t}function Kg(t){var e=t(cn,cn),n=1;function r(){return n===1?t(cn,cn):n===.5?t(Vg,Xg):t(sc(n),sc(1/n))}return e.exponent=function(a){return arguments.length?(n=+a,r()):n},ic(e)}function oc(){var t=Kg(rc());return t.copy=function(){return bs(t,oc()).exponent(t.exponent())},Ur.apply(t,arguments),t}const ws=new Date,_s=new Date;function Me(t,e,n,r){function a(i){return t(i=arguments.length===0?new Date:new Date(+i)),i}return a.floor=i=>(t(i=new Date(+i)),i),a.ceil=i=>(t(i=new Date(i-1)),e(i,1),t(i),i),a.round=i=>{const s=a(i),o=a.ceil(i);return i-s<o-i?s:o},a.offset=(i,s)=>(e(i=new Date(+i),s==null?1:Math.floor(s)),i),a.range=(i,s,o)=>{const l=[];if(i=a.ceil(i),o=o==null?1:Math.floor(o),!(i<s)||!(o>0))return l;let c;do l.push(c=new Date(+i)),e(i,o),t(i);while(c<i&&i<s);return l},a.filter=i=>Me(s=>{if(s>=s)for(;t(s),!i(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;e(s,-1),!i(s););else for(;--o>=0;)for(;e(s,1),!i(s););}),n&&(a.count=(i,s)=>(ws.setTime(+i),_s.setTime(+s),t(ws),t(_s),Math.floor(n(ws,_s))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(r?s=>r(s)%i===0:s=>a.count(0,s)%i===0):a)),a}const Za=Me(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Za.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Me(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Za),Za.range;const bn=1e3,Je=bn*60,wn=Je*60,_n=wn*24,ks=_n*7,lc=_n*30,As=_n*365,dr=Me(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*bn)},(t,e)=>(e-t)/bn,t=>t.getUTCSeconds());dr.range;const Ss=Me(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*bn)},(t,e)=>{t.setTime(+t+e*Je)},(t,e)=>(e-t)/Je,t=>t.getMinutes());Ss.range,Me(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Je)},(t,e)=>(e-t)/Je,t=>t.getUTCMinutes()).range;const Ms=Me(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*bn-t.getMinutes()*Je)},(t,e)=>{t.setTime(+t+e*wn)},(t,e)=>(e-t)/wn,t=>t.getHours());Ms.range,Me(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*wn)},(t,e)=>(e-t)/wn,t=>t.getUTCHours()).range;const Vr=Me(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Je)/_n,t=>t.getDate()-1);Vr.range;const Ns=Me(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/_n,t=>t.getUTCDate()-1);Ns.range,Me(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/_n,t=>Math.floor(t/_n)).range;function Fn(t){return Me(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*Je)/ks)}const Xr=Fn(0),Ja=Fn(1),Gg=Fn(2),Zg=Fn(3),pr=Fn(4),Jg=Fn(5),Qg=Fn(6);Xr.range,Ja.range,Gg.range,Zg.range,pr.range,Jg.range,Qg.range;function Hn(t){return Me(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/ks)}const cc=Hn(0),Qa=Hn(1),qg=Hn(2),ty=Hn(3),gr=Hn(4),ey=Hn(5),ny=Hn(6);cc.range,Qa.range,qg.range,ty.range,gr.range,ey.range,ny.range;const qa=Me(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());qa.range,Me(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth()).range;const kn=Me(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());kn.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Me(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)}),kn.range;const Wn=Me(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());Wn.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Me(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)}),Wn.range;function ry(t,e,n,r,a,i){const s=[[dr,1,bn],[dr,5,5*bn],[dr,15,15*bn],[dr,30,30*bn],[i,1,Je],[i,5,5*Je],[i,15,15*Je],[i,30,30*Je],[a,1,wn],[a,3,3*wn],[a,6,6*wn],[a,12,12*wn],[r,1,_n],[r,2,2*_n],[n,1,ks],[e,1,lc],[e,3,3*lc],[t,1,As]];function o(c,u,h){const f=u<c;f&&([c,u]=[u,c]);const g=h&&typeof h.range=="function"?h:l(c,u,h),v=g?g.range(c,+u+1):[];return f?v.reverse():v}function l(c,u,h){const f=Math.abs(u-c)/h,g=Nr(([,,d])=>d).right(s,f);if(g===s.length)return t.every(pa(c/As,u/As,h));if(g===0)return Za.every(Math.max(pa(c,u,h),1));const[v,b]=s[f/s[g-1][2]<s[g][2]/f?g-1:g];return v.every(b)}return[o,l]}const[ay,iy]=ry(kn,qa,Xr,Vr,Ms,Ss);function Ts(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Ds(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Kr(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function sy(t){var e=t.dateTime,n=t.date,r=t.time,a=t.periods,i=t.days,s=t.shortDays,o=t.months,l=t.shortMonths,c=Gr(a),u=Zr(a),h=Gr(i),f=Zr(i),g=Gr(s),v=Zr(s),b=Gr(o),d=Zr(o),x=Gr(l),S=Zr(l),w={a:C,A:F,b:H,B:V,c:null,d:gc,e:gc,f:Dy,g:Fy,G:Wy,H:My,I:Ny,j:Ty,L:yc,m:$y,M:Cy,p:et,q:$,Q:_c,s:kc,S:Ly,u:jy,U:Py,V:Ey,w:Ry,W:zy,x:null,X:null,y:Iy,Y:Hy,Z:Oy,"%":wc},y={a:dt,A:wt,b:pt,B:_t,c:null,d:mc,e:mc,f:Vy,g:nx,G:ax,H:By,I:Yy,j:Uy,L:vc,m:Xy,M:Ky,p:G,q:ot,Q:_c,s:kc,S:Gy,u:Zy,U:Jy,V:Qy,w:qy,W:tx,x:null,X:null,y:ex,Y:rx,Z:ix,"%":wc},T={a:R,A:z,b:I,B:N,c:U,d:dc,e:dc,f:_y,g:hc,G:fc,H:pc,I:pc,j:my,L:wy,m:xy,M:vy,p:E,q:yy,Q:Ay,s:Sy,S:by,u:fy,U:hy,V:dy,w:uy,W:py,x:M,X:Y,y:hc,Y:fc,Z:gy,"%":ky};w.x=p(n,w),w.X=p(r,w),w.c=p(e,w),y.x=p(n,y),y.X=p(r,y),y.c=p(e,y);function p(O,Q){return function(X){var D=[],tt=-1,L=0,Z=O.length,ft,st,it;for(X instanceof Date||(X=new Date(+X));++tt<Z;)O.charCodeAt(tt)===37&&(D.push(O.slice(L,tt)),(st=uc[ft=O.charAt(++tt)])!=null?ft=O.charAt(++tt):st=ft==="e"?" ":"0",(it=Q[ft])&&(ft=it(X,st)),D.push(ft),L=tt+1);return D.push(O.slice(L,tt)),D.join("")}}function k(O,Q){return function(X){var D=Kr(1900,void 0,1),tt=_(D,O,X+="",0),L,Z;if(tt!=X.length)return null;if("Q"in D)return new Date(D.Q);if("s"in D)return new Date(D.s*1e3+("L"in D?D.L:0));if(Q&&!("Z"in D)&&(D.Z=0),"p"in D&&(D.H=D.H%12+D.p*12),D.m===void 0&&(D.m="q"in D?D.q:0),"V"in D){if(D.V<1||D.V>53)return null;"w"in D||(D.w=1),"Z"in D?(L=Ds(Kr(D.y,0,1)),Z=L.getUTCDay(),L=Z>4||Z===0?Qa.ceil(L):Qa(L),L=Ns.offset(L,(D.V-1)*7),D.y=L.getUTCFullYear(),D.m=L.getUTCMonth(),D.d=L.getUTCDate()+(D.w+6)%7):(L=Ts(Kr(D.y,0,1)),Z=L.getDay(),L=Z>4||Z===0?Ja.ceil(L):Ja(L),L=Vr.offset(L,(D.V-1)*7),D.y=L.getFullYear(),D.m=L.getMonth(),D.d=L.getDate()+(D.w+6)%7)}else("W"in D||"U"in D)&&("w"in D||(D.w="u"in D?D.u%7:"W"in D?1:0),Z="Z"in D?Ds(Kr(D.y,0,1)).getUTCDay():Ts(Kr(D.y,0,1)).getDay(),D.m=0,D.d="W"in D?(D.w+6)%7+D.W*7-(Z+5)%7:D.w+D.U*7-(Z+6)%7);return"Z"in D?(D.H+=D.Z/100|0,D.M+=D.Z%100,Ds(D)):Ts(D)}}function _(O,Q,X,D){for(var tt=0,L=Q.length,Z=X.length,ft,st;tt<L;){if(D>=Z)return-1;if(ft=Q.charCodeAt(tt++),ft===37){if(ft=Q.charAt(tt++),st=T[ft in uc?Q.charAt(tt++):ft],!st||(D=st(O,X,D))<0)return-1}else if(ft!=X.charCodeAt(D++))return-1}return D}function E(O,Q,X){var D=c.exec(Q.slice(X));return D?(O.p=u.get(D[0].toLowerCase()),X+D[0].length):-1}function R(O,Q,X){var D=g.exec(Q.slice(X));return D?(O.w=v.get(D[0].toLowerCase()),X+D[0].length):-1}function z(O,Q,X){var D=h.exec(Q.slice(X));return D?(O.w=f.get(D[0].toLowerCase()),X+D[0].length):-1}function I(O,Q,X){var D=x.exec(Q.slice(X));return D?(O.m=S.get(D[0].toLowerCase()),X+D[0].length):-1}function N(O,Q,X){var D=b.exec(Q.slice(X));return D?(O.m=d.get(D[0].toLowerCase()),X+D[0].length):-1}function U(O,Q,X){return _(O,e,Q,X)}function M(O,Q,X){return _(O,n,Q,X)}function Y(O,Q,X){return _(O,r,Q,X)}function C(O){return s[O.getDay()]}function F(O){return i[O.getDay()]}function H(O){return l[O.getMonth()]}function V(O){return o[O.getMonth()]}function et(O){return a[+(O.getHours()>=12)]}function $(O){return 1+~~(O.getMonth()/3)}function dt(O){return s[O.getUTCDay()]}function wt(O){return i[O.getUTCDay()]}function pt(O){return l[O.getUTCMonth()]}function _t(O){return o[O.getUTCMonth()]}function G(O){return a[+(O.getUTCHours()>=12)]}function ot(O){return 1+~~(O.getUTCMonth()/3)}return{format:function(O){var Q=p(O+="",w);return Q.toString=function(){return O},Q},parse:function(O){var Q=k(O+="",!1);return Q.toString=function(){return O},Q},utcFormat:function(O){var Q=p(O+="",y);return Q.toString=function(){return O},Q},utcParse:function(O){var Q=k(O+="",!0);return Q.toString=function(){return O},Q}}}var uc={"-":"",_:" ",0:"0"},De=/^\s*\d+/,oy=/^%/,ly=/[\\^$*+?|[\]().{}]/g;function ne(t,e,n){var r=t<0?"-":"",a=(r?-t:t)+"",i=a.length;return r+(i<n?new Array(n-i+1).join(e)+a:a)}function cy(t){return t.replace(ly,"\\$&")}function Gr(t){return new RegExp("^(?:"+t.map(cy).join("|")+")","i")}function Zr(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function uy(t,e,n){var r=De.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function fy(t,e,n){var r=De.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function hy(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function dy(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function py(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function fc(t,e,n){var r=De.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function hc(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function gy(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function yy(t,e,n){var r=De.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function xy(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function dc(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function my(t,e,n){var r=De.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function pc(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function vy(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function by(t,e,n){var r=De.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function wy(t,e,n){var r=De.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function _y(t,e,n){var r=De.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ky(t,e,n){var r=oy.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Ay(t,e,n){var r=De.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Sy(t,e,n){var r=De.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function gc(t,e){return ne(t.getDate(),e,2)}function My(t,e){return ne(t.getHours(),e,2)}function Ny(t,e){return ne(t.getHours()%12||12,e,2)}function Ty(t,e){return ne(1+Vr.count(kn(t),t),e,3)}function yc(t,e){return ne(t.getMilliseconds(),e,3)}function Dy(t,e){return yc(t,e)+"000"}function $y(t,e){return ne(t.getMonth()+1,e,2)}function Cy(t,e){return ne(t.getMinutes(),e,2)}function Ly(t,e){return ne(t.getSeconds(),e,2)}function jy(t){var e=t.getDay();return e===0?7:e}function Py(t,e){return ne(Xr.count(kn(t)-1,t),e,2)}function xc(t){var e=t.getDay();return e>=4||e===0?pr(t):pr.ceil(t)}function Ey(t,e){return t=xc(t),ne(pr.count(kn(t),t)+(kn(t).getDay()===4),e,2)}function Ry(t){return t.getDay()}function zy(t,e){return ne(Ja.count(kn(t)-1,t),e,2)}function Iy(t,e){return ne(t.getFullYear()%100,e,2)}function Fy(t,e){return t=xc(t),ne(t.getFullYear()%100,e,2)}function Hy(t,e){return ne(t.getFullYear()%1e4,e,4)}function Wy(t,e){var n=t.getDay();return t=n>=4||n===0?pr(t):pr.ceil(t),ne(t.getFullYear()%1e4,e,4)}function Oy(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+ne(e/60|0,"0",2)+ne(e%60,"0",2)}function mc(t,e){return ne(t.getUTCDate(),e,2)}function By(t,e){return ne(t.getUTCHours(),e,2)}function Yy(t,e){return ne(t.getUTCHours()%12||12,e,2)}function Uy(t,e){return ne(1+Ns.count(Wn(t),t),e,3)}function vc(t,e){return ne(t.getUTCMilliseconds(),e,3)}function Vy(t,e){return vc(t,e)+"000"}function Xy(t,e){return ne(t.getUTCMonth()+1,e,2)}function Ky(t,e){return ne(t.getUTCMinutes(),e,2)}function Gy(t,e){return ne(t.getUTCSeconds(),e,2)}function Zy(t){var e=t.getUTCDay();return e===0?7:e}function Jy(t,e){return ne(cc.count(Wn(t)-1,t),e,2)}function bc(t){var e=t.getUTCDay();return e>=4||e===0?gr(t):gr.ceil(t)}function Qy(t,e){return t=bc(t),ne(gr.count(Wn(t),t)+(Wn(t).getUTCDay()===4),e,2)}function qy(t){return t.getUTCDay()}function tx(t,e){return ne(Qa.count(Wn(t)-1,t),e,2)}function ex(t,e){return ne(t.getUTCFullYear()%100,e,2)}function nx(t,e){return t=bc(t),ne(t.getUTCFullYear()%100,e,2)}function rx(t,e){return ne(t.getUTCFullYear()%1e4,e,4)}function ax(t,e){var n=t.getUTCDay();return t=n>=4||n===0?gr(t):gr.ceil(t),ne(t.getUTCFullYear()%1e4,e,4)}function ix(){return"+0000"}function wc(){return"%"}function _c(t){return+t}function kc(t){return Math.floor(+t/1e3)}var yr,Jr,Ac;sx({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function sx(t){return yr=sy(t),Jr=yr.format,Ac=yr.parse,yr.utcFormat,yr.utcParse,yr}function ox(t){return new Date(t)}function lx(t){return t instanceof Date?+t:+new Date(+t)}function Sc(t,e,n,r,a,i,s,o,l,c){var u=ac(),h=u.invert,f=u.domain,g=c(".%L"),v=c(":%S"),b=c("%I:%M"),d=c("%I %p"),x=c("%a %d"),S=c("%b %d"),w=c("%B"),y=c("%Y");function T(p){return(l(p)<p?g:o(p)<p?v:s(p)<p?b:i(p)<p?d:r(p)<p?a(p)<p?x:S:n(p)<p?w:y)(p)}return u.invert=function(p){return new Date(h(p))},u.domain=function(p){return arguments.length?f(Array.from(p,lx)):f().map(ox)},u.ticks=function(p){var k=f();return t(k[0],k[k.length-1],p??10)},u.tickFormat=function(p,k){return k==null?T:c(k)},u.nice=function(p){var k=f();return(!p||typeof p.range!="function")&&(p=e(k[0],k[k.length-1],p??10)),p?f(Ug(k,p)):u},u.copy=function(){return bs(u,Sc(t,e,n,r,a,i,s,o,l,c))},u}function ti(){return Ur.apply(Sc(ay,iy,kn,qa,Xr,Vr,Ms,Ss,dr,Jr).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Qr(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(r*6,++r*6);return n}const qr=Qr("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),Mc=Qr("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"),Nc=Qr("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"),Tc=Qr("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"),Dc=Qr("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");ol(Sn(-100,.75,.35),Sn(80,1.5,.8)),ol(Sn(260,.75,.35),Sn(80,1.5,.8));var ei=Sn();function $c(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return ei.h=360*t-100,ei.s=1.5-1.5*e,ei.l=.8-.9*e,ei+""}function Vt(t){return function(){return t}}const Cc=Math.abs,Le=Math.atan2,On=Math.cos,cx=Math.max,$s=Math.min,un=Math.sin,xr=Math.sqrt,je=1e-12,ta=Math.PI,ni=ta/2,ri=2*ta;function ux(t){return t>1?0:t<-1?ta:Math.acos(t)}function Lc(t){return t>=1?ni:t<=-1?-ni:Math.asin(t)}function ai(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new us(e)}function fx(t){return t.innerRadius}function hx(t){return t.outerRadius}function dx(t){return t.startAngle}function px(t){return t.endAngle}function gx(t){return t&&t.padAngle}function yx(t,e,n,r,a,i,s,o){var l=n-t,c=r-e,u=s-a,h=o-i,f=h*l-u*c;if(!(f*f<je))return f=(u*(e-i)-h*(t-a))/f,[t+f*l,e+f*c]}function ii(t,e,n,r,a,i,s){var o=t-n,l=e-r,c=(s?i:-i)/xr(o*o+l*l),u=c*l,h=-c*o,f=t+u,g=e+h,v=n+u,b=r+h,d=(f+v)/2,x=(g+b)/2,S=v-f,w=b-g,y=S*S+w*w,T=a-i,p=f*b-v*g,k=(w<0?-1:1)*xr(cx(0,T*T*y-p*p)),_=(p*w-S*k)/y,E=(-p*S-w*k)/y,R=(p*w+S*k)/y,z=(-p*S+w*k)/y,I=_-d,N=E-x,U=R-d,M=z-x;return I*I+N*N>U*U+M*M&&(_=R,E=z),{cx:_,cy:E,x01:-u,y01:-h,x11:_*(a/T-1),y11:E*(a/T-1)}}function si(){var t=fx,e=hx,n=Vt(0),r=null,a=dx,i=px,s=gx,o=null,l=ai(c);function c(){var u,h,f=+t.apply(this,arguments),g=+e.apply(this,arguments),v=a.apply(this,arguments)-ni,b=i.apply(this,arguments)-ni,d=Cc(b-v),x=b>v;if(o||(o=u=l()),g<f&&(h=g,g=f,f=h),!(g>je))o.moveTo(0,0);else if(d>ri-je)o.moveTo(g*On(v),g*un(v)),o.arc(0,0,g,v,b,!x),f>je&&(o.moveTo(f*On(b),f*un(b)),o.arc(0,0,f,b,v,x));else{var S=v,w=b,y=v,T=b,p=d,k=d,_=s.apply(this,arguments)/2,E=_>je&&(r?+r.apply(this,arguments):xr(f*f+g*g)),R=$s(Cc(g-f)/2,+n.apply(this,arguments)),z=R,I=R,N,U;if(E>je){var M=Lc(E/f*un(_)),Y=Lc(E/g*un(_));(p-=M*2)>je?(M*=x?1:-1,y+=M,T-=M):(p=0,y=T=(v+b)/2),(k-=Y*2)>je?(Y*=x?1:-1,S+=Y,w-=Y):(k=0,S=w=(v+b)/2)}var C=g*On(S),F=g*un(S),H=f*On(T),V=f*un(T);if(R>je){var et=g*On(w),$=g*un(w),dt=f*On(y),wt=f*un(y),pt;if(d<ta)if(pt=yx(C,F,dt,wt,et,$,H,V)){var _t=C-pt[0],G=F-pt[1],ot=et-pt[0],O=$-pt[1],Q=1/un(ux((_t*ot+G*O)/(xr(_t*_t+G*G)*xr(ot*ot+O*O)))/2),X=xr(pt[0]*pt[0]+pt[1]*pt[1]);z=$s(R,(f-X)/(Q-1)),I=$s(R,(g-X)/(Q+1))}else z=I=0}k>je?I>je?(N=ii(dt,wt,C,F,g,I,x),U=ii(et,$,H,V,g,I,x),o.moveTo(N.cx+N.x01,N.cy+N.y01),I<R?o.arc(N.cx,N.cy,I,Le(N.y01,N.x01),Le(U.y01,U.x01),!x):(o.arc(N.cx,N.cy,I,Le(N.y01,N.x01),Le(N.y11,N.x11),!x),o.arc(0,0,g,Le(N.cy+N.y11,N.cx+N.x11),Le(U.cy+U.y11,U.cx+U.x11),!x),o.arc(U.cx,U.cy,I,Le(U.y11,U.x11),Le(U.y01,U.x01),!x))):(o.moveTo(C,F),o.arc(0,0,g,S,w,!x)):o.moveTo(C,F),!(f>je)||!(p>je)?o.lineTo(H,V):z>je?(N=ii(H,V,et,$,f,-z,x),U=ii(C,F,dt,wt,f,-z,x),o.lineTo(N.cx+N.x01,N.cy+N.y01),z<R?o.arc(N.cx,N.cy,z,Le(N.y01,N.x01),Le(U.y01,U.x01),!x):(o.arc(N.cx,N.cy,z,Le(N.y01,N.x01),Le(N.y11,N.x11),!x),o.arc(0,0,f,Le(N.cy+N.y11,N.cx+N.x11),Le(U.cy+U.y11,U.cx+U.x11),x),o.arc(U.cx,U.cy,z,Le(U.y11,U.x11),Le(U.y01,U.x01),!x))):o.arc(0,0,f,T,y,x)}if(o.closePath(),u)return o=null,u+""||null}return c.centroid=function(){var u=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,h=(+a.apply(this,arguments)+ +i.apply(this,arguments))/2-ta/2;return[On(h)*u,un(h)*u]},c.innerRadius=function(u){return arguments.length?(t=typeof u=="function"?u:Vt(+u),c):t},c.outerRadius=function(u){return arguments.length?(e=typeof u=="function"?u:Vt(+u),c):e},c.cornerRadius=function(u){return arguments.length?(n=typeof u=="function"?u:Vt(+u),c):n},c.padRadius=function(u){return arguments.length?(r=u==null?null:typeof u=="function"?u:Vt(+u),c):r},c.startAngle=function(u){return arguments.length?(a=typeof u=="function"?u:Vt(+u),c):a},c.endAngle=function(u){return arguments.length?(i=typeof u=="function"?u:Vt(+u),c):i},c.padAngle=function(u){return arguments.length?(s=typeof u=="function"?u:Vt(+u),c):s},c.context=function(u){return arguments.length?(o=u??null,c):o},c}var xx=Array.prototype.slice;function oi(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function jc(t){this._context=t}jc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);break}}};function li(t){return new jc(t)}function Cs(t){return t[0]}function Ls(t){return t[1]}function Bn(t,e){var n=Vt(!0),r=null,a=li,i=null,s=ai(o);t=typeof t=="function"?t:t===void 0?Cs:Vt(t),e=typeof e=="function"?e:e===void 0?Ls:Vt(e);function o(l){var c,u=(l=oi(l)).length,h,f=!1,g;for(r==null&&(i=a(g=s())),c=0;c<=u;++c)!(c<u&&n(h=l[c],c,l))===f&&((f=!f)?i.lineStart():i.lineEnd()),f&&i.point(+t(h,c,l),+e(h,c,l));if(g)return i=null,g+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Vt(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:Vt(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Vt(!!l),o):n},o.curve=function(l){return arguments.length?(a=l,r!=null&&(i=a(r)),o):a},o.context=function(l){return arguments.length?(l==null?r=i=null:i=a(r=l),o):r},o}function js(t,e,n){var r=null,a=Vt(!0),i=null,s=li,o=null,l=ai(c);t=typeof t=="function"?t:t===void 0?Cs:Vt(+t),e=typeof e=="function"?e:Vt(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?Ls:Vt(+n);function c(h){var f,g,v,b=(h=oi(h)).length,d,x=!1,S,w=new Array(b),y=new Array(b);for(i==null&&(o=s(S=l())),f=0;f<=b;++f){if(!(f<b&&a(d=h[f],f,h))===x)if(x=!x)g=f,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),v=f-1;v>=g;--v)o.point(w[v],y[v]);o.lineEnd(),o.areaEnd()}x&&(w[f]=+t(d,f,h),y[f]=+e(d,f,h),o.point(r?+r(d,f,h):w[f],n?+n(d,f,h):y[f]))}if(S)return o=null,S+""||null}function u(){return Bn().defined(a).curve(s).context(i)}return c.x=function(h){return arguments.length?(t=typeof h=="function"?h:Vt(+h),r=null,c):t},c.x0=function(h){return arguments.length?(t=typeof h=="function"?h:Vt(+h),c):t},c.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:Vt(+h),c):r},c.y=function(h){return arguments.length?(e=typeof h=="function"?h:Vt(+h),n=null,c):e},c.y0=function(h){return arguments.length?(e=typeof h=="function"?h:Vt(+h),c):e},c.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:Vt(+h),c):n},c.lineX0=c.lineY0=function(){return u().x(t).y(e)},c.lineY1=function(){return u().x(t).y(n)},c.lineX1=function(){return u().x(r).y(e)},c.defined=function(h){return arguments.length?(a=typeof h=="function"?h:Vt(!!h),c):a},c.curve=function(h){return arguments.length?(s=h,i!=null&&(o=s(i)),c):s},c.context=function(h){return arguments.length?(h==null?i=o=null:o=s(i=h),c):i},c}function mx(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function vx(t){return t}function bx(){var t=vx,e=mx,n=null,r=Vt(0),a=Vt(ri),i=Vt(0);function s(o){var l,c=(o=oi(o)).length,u,h,f=0,g=new Array(c),v=new Array(c),b=+r.apply(this,arguments),d=Math.min(ri,Math.max(-ri,a.apply(this,arguments)-b)),x,S=Math.min(Math.abs(d)/c,i.apply(this,arguments)),w=S*(d<0?-1:1),y;for(l=0;l<c;++l)(y=v[g[l]=l]=+t(o[l],l,o))>0&&(f+=y);for(e!=null?g.sort(function(T,p){return e(v[T],v[p])}):n!=null&&g.sort(function(T,p){return n(o[T],o[p])}),l=0,h=f?(d-c*w)/f:0;l<c;++l,b=x)u=g[l],y=v[u],x=b+(y>0?y*h:0)+w,v[u]={data:o[u],index:l,value:y,startAngle:b,endAngle:x,padAngle:S};return v}return s.value=function(o){return arguments.length?(t=typeof o=="function"?o:Vt(+o),s):t},s.sortValues=function(o){return arguments.length?(e=o,n=null,s):e},s.sort=function(o){return arguments.length?(n=o,e=null,s):n},s.startAngle=function(o){return arguments.length?(r=typeof o=="function"?o:Vt(+o),s):r},s.endAngle=function(o){return arguments.length?(a=typeof o=="function"?o:Vt(+o),s):a},s.padAngle=function(o){return arguments.length?(i=typeof o=="function"?o:Vt(+o),s):i},s}function ci(t,e){return[(e=+e)*Math.cos(t-=Math.PI/2),e*Math.sin(t)]}class wx{constructor(e){this._context=e}lineStart(){this._point=0}lineEnd(){}point(e,n){if(e=+e,n=+n,this._point===0)this._point=1;else{const r=ci(this._x0,this._y0),a=ci(this._x0,this._y0=(this._y0+n)/2),i=ci(e,this._y0),s=ci(e,n);this._context.moveTo(...r),this._context.bezierCurveTo(...a,...i,...s)}this._x0=e,this._y0=n}}function _x(t){return new wx(t)}function kx(t){return t.source}function Ax(t){return t.target}function Sx(t){let e=kx,n=Ax,r=Cs,a=Ls,i=null,s=null,o=ai(l);function l(){let c;const u=xx.call(arguments),h=e.apply(this,u),f=n.apply(this,u);if(i==null&&(s=t(c=o())),s.lineStart(),u[0]=h,s.point(+r.apply(this,u),+a.apply(this,u)),u[0]=f,s.point(+r.apply(this,u),+a.apply(this,u)),s.lineEnd(),c)return s=null,c+""||null}return l.source=function(c){return arguments.length?(e=c,l):e},l.target=function(c){return arguments.length?(n=c,l):n},l.x=function(c){return arguments.length?(r=typeof c=="function"?c:Vt(+c),l):r},l.y=function(c){return arguments.length?(a=typeof c=="function"?c:Vt(+c),l):a},l.context=function(c){return arguments.length?(c==null?i=s=null:s=t(i=c),l):i},l}function Mx(){const t=Sx(_x);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t}function Pc(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function Ec(t){this._context=t}Ec.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Pc(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Pc(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Rc(t){return new Ec(t)}function zc(t,e,n){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-e),t._y2+t._k*(t._y1-n),t._x2,t._y2)}function Ps(t,e){this._context=t,this._k=(1-e)/6}Ps.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:zc(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2,this._x1=t,this._y1=e;break;case 2:this._point=3;default:zc(this,t,e);break}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};const Ic=(function t(e){function n(r){return new Ps(r,e)}return n.tension=function(r){return t(+r)},n})(0);function Nx(t,e,n){var r=t._x1,a=t._y1,i=t._x2,s=t._y2;if(t._l01_a>je){var o=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,l=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*o-t._x0*t._l12_2a+t._x2*t._l01_2a)/l,a=(a*o-t._y0*t._l12_2a+t._y2*t._l01_2a)/l}if(t._l23_a>je){var c=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,u=3*t._l23_a*(t._l23_a+t._l12_a);i=(i*c+t._x1*t._l23_2a-e*t._l12_2a)/u,s=(s*c+t._y1*t._l23_2a-n*t._l12_2a)/u}t._context.bezierCurveTo(r,a,i,s,t._x2,t._y2)}function Fc(t,e){this._context=t,this._alpha=e}Fc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3;default:Nx(this,t,e);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};const Hc=(function t(e){function n(r){return e?new Fc(r,e):new Ps(r,0)}return n.alpha=function(r){return t(+r)},n})(.5);function Wc(t){this._context=t}Wc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=Oc(t),a=Oc(e),i=0,s=1;s<n;++i,++s)this._context.bezierCurveTo(r[0][i],a[0][i],r[1][i],a[1][i],t[s],e[s]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function Oc(t){var e,n=t.length-1,r,a=new Array(n),i=new Array(n),s=new Array(n);for(a[0]=0,i[0]=2,s[0]=t[0]+2*t[1],e=1;e<n-1;++e)a[e]=1,i[e]=4,s[e]=4*t[e]+2*t[e+1];for(a[n-1]=2,i[n-1]=7,s[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=a[e]/i[e-1],i[e]-=r,s[e]-=r*s[e-1];for(a[n-1]=s[n-1]/i[n-1],e=n-2;e>=0;--e)a[e]=(s[e]-a[e+1])/i[e];for(i[n-1]=(t[n]+a[n-1])/2,e=0;e<n-1;++e)i[e]=2*t[e+1]-a[e+1];return[a,i]}function Bc(t){return new Wc(t)}function ea(t,e){if((s=t.length)>1)for(var n=1,r,a,i=t[e[0]],s,o=i.length;n<s;++n)for(a=i,i=t[e[n]],r=0;r<o;++r)i[r][1]+=i[r][0]=isNaN(a[r][1])?a[r][0]:a[r][1]}function ui(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Tx(t,e){return t[e]}function Dx(t){const e=[];return e.key=t,e}function na(){var t=Vt([]),e=ui,n=ea,r=Tx;function a(i){var s=Array.from(t.apply(this,arguments),Dx),o,l=s.length,c=-1,u;for(const h of i)for(o=0,++c;o<l;++o)(s[o][c]=[0,+r(h,s[o].key,c,i)]).data=h;for(o=0,u=oi(e(s));o<l;++o)s[u[o]].index=o;return n(s,u),s}return a.keys=function(i){return arguments.length?(t=typeof i=="function"?i:Vt(Array.from(i)),a):t},a.value=function(i){return arguments.length?(r=typeof i=="function"?i:Vt(+i),a):r},a.order=function(i){return arguments.length?(e=i==null?ui:typeof i=="function"?i:Vt(Array.from(i)),a):e},a.offset=function(i){return arguments.length?(n=i??ea,a):n},a}function Yc(t,e){if((r=t.length)>0){for(var n,r,a=0,i=t[0].length,s;a<i;++a){for(s=n=0;n<r;++n)s+=t[n][a][1]||0;if(s)for(n=0;n<r;++n)t[n][a][1]/=s}ea(t,e)}}function Es(t,e){if((l=t.length)>0)for(var n,r=0,a,i,s,o,l,c=t[e[0]].length;r<c;++r)for(s=o=0,n=0;n<l;++n)(i=(a=t[e[n]][r])[1]-a[0])>0?(a[0]=s,a[1]=s+=i):i<0?(a[1]=o,a[0]=o+=i):(a[0]=0,a[1]=i)}function ra(t,e,n){this.k=t,this.x=e,this.y=n}ra.prototype={constructor:ra,scale:function(t){return t===1?this:new ra(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new ra(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}},ra.prototype;const Se=(t,e)=>{const n=bt.useRef(null);return bt.useEffect(()=>{e!==void 0&&n.current&&t(qt(n.current))},e===null?void 0:e),n};function Ne(){const t=bt.useRef(null),[e,n]=bt.useState({width:0,height:0});return bt.useEffect(()=>{const r=t.current;if(!r||!r.parentElement)return;const a=r.parentElement,i=()=>{const o=a.getBoundingClientRect();n({width:o.width,height:o.height})};i();const s=new ResizeObserver(()=>i());return s.observe(a),()=>s.disconnect()},[]),[t,e]}function fi(){const[t,e]=bt.useState(null);return bt.useEffect(()=>{const n=typeof document<"u"?document.getElementById("UI-controls"):null;e(n)},[]),t}const Oe={tooltip:"_tooltip_cqxcs_3","tooltip--arrow-up":"_tooltip--arrow-up_cqxcs_71","tooltip--arrow-down":"_tooltip--arrow-down_cqxcs_99",title:"_title_cqxcs_165","text-small":"_text-small_cqxcs_197","right-label":"_right-label_cqxcs_225"},Qe=({pCount:t,children:e})=>m.jsxs("div",{id:"tooltip",className:`${Oe.tooltip}`,style:{opacity:0},children:[e,!t&&!e&&m.jsx("p",{className:`top-label ${Oe["text-small"]}`}),t===2&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:`top-label ${Oe["text-small"]}`}),m.jsx("p",{className:`bottom-label ${Oe["text-small"]}`})]}),(t===3||t===4)&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:`title ${Oe.title}`}),m.jsx("p",{className:`top-label ${Oe["right-label"]}`}),m.jsx("p",{className:`bottom-label ${Oe["right-label"]}`})]}),t===4&&m.jsx("p",{className:`small-text ${Oe["right-label"]} ${Oe["small-text"]}`})]}),hi=(t,e="tooltip")=>t.select(`#${e}`).style("opacity",0);function $x(t,e,n){const{top:r,height:a}=e.getBoundingClientRect(),i=t.clientY-r;return{pixelY:i,dataY:n?.invert(i)??0,svgHeight:a}}function le(t,e){const{e:n,svg:r,yScale:a}=e,{pixelY:i,svgHeight:s}=$x(n,r,a),l=(t.node()?.getBoundingClientRect()).height??100,u=((d=.5)=>i+l-s>l*d)(),h=i<l?u?"top":"bottom":"top",{offsetWidth:f,offsetHeight:g}=t.node()||{};typeof document<"u"&&document.documentElement.clientWidth;const v=n.x-f/2,b=h==="top"?Oe["tooltip--arrow-down"]:Oe["tooltip--arrow-up"];t.attr("class",`${Oe.tooltip} ${b}`).style("left",v+"px").style("top",h==="top"?n.y-(g+20)+"px":n.y+30+"px")}function Dn(t,e){const{offsetWidth:n,offsetHeight:r}=e.node()||{},a=document.documentElement.clientWidth,i=t.x-n/2;let s=0;if(i<0)s=0;else if(i+n>a){const o=i+n-a;s=i-o}else s=i;e.style("left",s+"px").attr("class",`${Oe.tooltip} ${Oe["tooltip--arrow-down"]}`).style("top",t.y-(r+10)+"px")}const we=t=>{try{return JSON.parse(JSON.stringify(t))}catch{return console.log("error when cloning object : "),Array.isArray(t)?[]:null}},mr=["#34D399","#6ee7b7","#10b981","#059669","#bef264","#a3e635","#84cc16","#86efac","#4ade80","#16a34a","#5eead4","#2dd4bf","#14b8a6","#67e8f9","#22d3ee","#06b6d4","#7dd3fc","#38bdf8","#0ea5e9","#93c5fd","#60a5fa","#3b82f6","#a5b4fc","#818cf8","#6366f1","#a78bfa","#8b5cf6","#7c3aed","#d8b4fe","#c084fc","#a855f7","#f9a8d4","#f472b6","#ec4899","#fb7185","#f43f5e","#db2777","#fca5a5","#f87171","#ef4444","#fdba74","#fb923c","#f97316","#fcd34d","#fbbf24","#f59e0b","#fde047","#facc15","#eab308"],Cx=of([...Nc,...Mc,...Tc,...Dc,...qr]),Uc=[...Nc,...Mc,...Tc,...Dc,...qr],de=(t,e=!0,n=!1)=>{const r=n?Cx:e?[...mr,...Uc]:[...Uc,...mr];return t<r.length?r[t]:r[t%r.length]},vr=t=>t<mr.length?mr[t]:mr[t%mr.length],Pe=(t,{formatType:e="long",prefix:n="",suffix:r=""}={})=>n+pe(e==="long"?",":"~s")(t)+r,Yn=(t,e="long")=>t<0?t.toFixed(4):e==="long"?pe(",")(t):pe("~s")(t),_e=(t,e)=>{const{formatType:n,prefix:r,suffix:a}=e,i=t<0?"-":"",s=Yn(Math.abs(t),n);return`${r}${i}${s}${a}`};function Lx(t){return t instanceof Date?!0:/^\d{4}-\d{2}-\d{2}$/.test(t)&&!Number.isNaN(new Date(t).getTime())}const di=(t,e)=>t<640&&e.length>3||t<768&&e.length>4||t<1024&&e.length>7||t<1280&&e.length>9,Rs=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function aa(t,e,n,r,a,i="vertical",s={showLine:!1,showDots:!0,curve:"linear"}){const{data:o,idExtension:l}=r,c=Bn().x(_=>i==="vertical"?(e.scale(_.label)??0)+e.offset:n(_.value)).y(_=>i==="horizontal"?(e.scale(_.label)??0)+e.offset:n(_.value)),{curve:u,showLine:h,showDots:f,lineStroke:g,dotFill:v}=s;u==="linear"?c.curve(li):u==="basis"?c.curve(Rc):u==="cardinal"?c.curve(Ic):u==="catmullrom"?c.curve(Hc):u==="natural"&&c.curve(Bc);const d=a>576?3:2,x=g??"#594c5b",S=500,w=h?[o]:[],y=t.selectAll(l?`path.chartline${l}`:"path.chartline").data(w).join(_=>_.append("path").attr("class",l?`chartline${l}`:"chartline").attr("fill","none").attr("stroke",x).attr("stroke-width",2).style("stroke-opacity",.75).style("pointer-events","none"),void 0,_=>_.remove());y.transition().duration(S).attr("d",_=>c(_)).attr("stroke",x),y.raise();const T=_=>i==="vertical"?(e.scale(_.label)??0)+e.offset:n(_.value),p=_=>i==="vertical"?n(_.value):(e.scale(_.label)??0)+e.offset,k=h&&f?o:[];t.selectAll(l?`.dot${l}`:".dot").data(k,_=>l?String(_.label)+l:String(_.label)).join(_=>_.append("circle").attr("class",l?`dot${l}`:"dot").attr("cx",function(E){return i==="horizontal"?n(0):(e.scale(E.label)??0)+e.offset}).attr("cy",function(E){return i==="vertical"?n(0):(e.scale(E.label)??0)+e.offset}).attr("fill",x).attr("r",0).style("pointer-events","none").transition().duration(S).attr("cx",T).attr("cy",p).attr("r",d),void 0,_=>_.transition().duration(S).style("opacity",0).remove()).transition().duration(S).attr("cx",T).attr("cy",p).attr("r",d).attr("fill",x)}const Un=t=>Number.isFinite(t),Ee="#d1d5db",J={"controls-container":"_controls-container_1nadu_1","controls-container-sm":"_controls-container-sm_1nadu_1","fill-container":"_fill-container_1nadu_39","controls-label":"_controls-label_1nadu_55",disabled:"_disabled_1nadu_99","controls-checkbox":"_controls-checkbox_1nadu_109",button:"_button_1nadu_139","chart-svg":"_chart-svg_1nadu_167","value-axis":"_value-axis_1nadu_177","legends-container":"_legends-container_1nadu_199","legend-container":"_legend-container_1nadu_259","legend-container-active":"_legend-container-active_1nadu_259","legend-container-inactive":"_legend-container-inactive_1nadu_259","legend-container-sm":"_legend-container-sm_1nadu_261","legend-container-active-sm":"_legend-container-active-sm_1nadu_261","legend-container-inactive-sm":"_legend-container-inactive-sm_1nadu_261","legend-rect":"_legend-rect_1nadu_323","legend-label":"_legend-label_1nadu_363",rotatedTopAxisText:"_rotatedTopAxisText_1nadu_481",rotatedAxisText:"_rotatedAxisText_1nadu_491",axisText:"_axisText_1nadu_501",bar:"_bar_1nadu_511",shadowed_text:"_shadowed_text_1nadu_531"},Vc={rotatedAxisText:"_rotatedAxisText_1tba7_1",axisText:"_axisText_1tba7_11"},rn=t=>{const e=bt.useRef([]);return bt.useEffect(()=>{const n=e.current;if(t.length===0){e.current=[];return}const r=t.some(i=>n.includes(i)),a=t.filter(i=>!n.includes(i));if(!r){e.current=[...t];return}if(a.length>0){e.current=[...n,...a];return}},[t]),e};function jx({data:t,color:{idx:e=0,type:n="fixed"}={idx:0,type:"fixed"},orientation:r="vertical",tooltipFormat:{prefix:a="",suffix:i="",formatType:s="long"}={prefix:"",suffix:"",formatType:"long"},lineProps:{showLine:o=!1,showDots:l=!0,curve:c="linear"}={showLine:!1,showDots:!0,curve:"linear"}}){const[u,h]=Ne(),{width:f,height:g}=h,[v,b]=bt.useState(!1),d=rn(t.map(k=>String(k.label))),x=fi(),S=f>576,w=m.jsx("div",{id:"controls",className:`${J[S?"controls-container":"controls-container-sm"]} ${x?J["fill-container"]:""}`,children:m.jsxs("label",{className:J["controls-label"],children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:v,onChange:k=>b(k.target.checked)}),"Sort"]})}),y={idx:e,type:n},T=750,p=Se(k=>{if(f===0||g===0)return;const _={top:20,right:30,bottom:r==="vertical"?50:30,left:r==="vertical"?25:50},E=v?we(t).sort((O,Q)=>Q.value-O.value):we(t),R=k.select("svg"),z=R.node(),I=R.select(".plot-area").attr("transform","translate("+_.left+","+_.top+")"),N=k.select("#tooltip").style("opacity",0),U=S?Vc.axisText:Vc.rotatedAxisText,M=f-_.left-_.right,Y=g-_.top-_.bottom,C=Xe().domain(E.map(O=>String(O.label))).rangeRound(r==="vertical"?[0,M]:[Y,0]).paddingInner(S?.4:.25).paddingOuter(.1),F=oe(E,O=>O.value)??0,H=Math.min(0,F),V=Gt(E,O=>O.value)??0,et=Math.max(0,V),$=ye().domain([H,et]).rangeRound(r==="vertical"?[Y,0]:[0,M]).nice(),dt=r==="vertical"?he(C).tickValues(C.domain()).scale(C).tickSizeOuter(0):he($).ticks(5,"s").tickSizeOuter(0).tickSize(-Y);I.select(".x-axis").attr("transform",`translate(0, ${Y})`).transition().duration(T).call(dt).selectAll("text").attr("class",U);const wt=r==="vertical"?be($).ticks(5,"s").tickSize(-M):be(C).tickSizeOuter(0);I.select(".y-axis").attr("transform","translate(0, 0)").transition().duration(T).call(wt);const pt=O=>{const{idx:Q,type:X}=y,D=d.current.findIndex(tt=>tt===String(O.label));return vr(X==="fixed"?Q:Q+D)},_t=O=>r==="vertical"?O>=0?$(O):$(0):O>=0?$(0):$(O),G=O=>{const Q=Math.abs($(O)-$(0));return isNaN(Q)||Q<0?0:Q},ot={prefix:a,suffix:i,formatType:s};I.selectAll(".bar").data(E,O=>String(O.label)).join(O=>O.append("rect").attr("class",`bar ${J.bar}`).attr("x",function(Q){return r==="vertical"?C(String(Q.label))??0:$(0)}).attr("width",function(Q){return r==="vertical"&&C.bandwidth()>0?C.bandwidth():0}).attr("y",function(Q){return r==="vertical"?$(0):C(String(Q.label))??0}).attr("height",function(){return r==="vertical"?0:Math.max(C.bandwidth(),0)}).attr("fill",pt).transition().duration(T).attr("y",function(Q){return r==="vertical"?_t(Q.value):C(String(Q.label))??0}).attr("width",function(Q){return r==="vertical"?Math.max(C.bandwidth(),0):G(Q.value)}).attr("height",function(Q){return r==="vertical"?G(Q.value):C.bandwidth()>0?0:C.bandwidth()}),void 0,O=>O.transition().duration(T).attr("fill",Ee).attr("height",0).attr("y",g).style("opacity",0).remove()).on("pointerenter",(O,Q)=>{N.style("opacity",1),N.select("p.label span.chev").style("background",pt(Q)),N.select("p.label span.value").text(String(Q.label)+""),N.select("p.value").text(_e(Q.value,ot)),le(N,{e:O,svg:z,yScale:$}),(r==="vertical"?k.select(".x-axis"):k.select(".y-axis")).selectAll("text").filter(D=>D===String(Q.label)).style("font-weight","bold")}).on("pointermove",(O,Q)=>{le(N,{e:O,svg:z,yScale:$})}).on("pointerleave",(O,Q)=>{N.style("opacity",0),(r==="vertical"?k.select(".x-axis"):k.select(".y-axis")).selectAll("text").filter(D=>D===String(Q.label)).style("font-weight","normal")}).transition().duration(T).attr("fill",pt).attr("x",function(O){return r==="vertical"?C(String(O.label))??0:_t(O.value)}).attr("width",function(O){return r==="vertical"?C.bandwidth():G(O.value)}).attr("y",function(O){return r==="vertical"?_t(O.value):C(String(O.label))??0}).attr("height",function(O){return r==="vertical"?G(O.value):C.bandwidth()}),aa(I,{scale:C,offset:C.bandwidth()/2},$,{data:E},f,r,{showLine:o,showDots:l,curve:c})},[t,y,f,g,v,r,{prefix:a,suffix:i,formatType:s},{showLine:o,showDots:l,curve:c}]);return m.jsxs("div",{ref:u,style:{width:f,height:g,display:"flex",flexDirection:"column"},children:[x&&Ru.createPortal(w,x),m.jsxs("div",{ref:p,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${f} ${g}`,children:m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`${r==="vertical"?J["value-axis"]:""} y-axis`}),m.jsx("g",{className:`${r==="horizontal"?J["value-axis"]:""} x-axis`})]})}),!x&&m.jsxs("label",{className:J["controls-label"],style:{position:"absolute",right:"12px",top:"6px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:v,onChange:k=>b(k.target.checked)}),"Sort"]}),m.jsxs(Qe,{children:[m.jsxs("p",{className:"label",style:{fontWeight:600,margin:"3px",fontSize:"12px",color:"wheat",display:"flex",justifyContent:"center",alignItems:"center",gap:2},children:[m.jsx("span",{className:"chev",style:{width:10,height:10,borderRadius:2}}),m.jsx("span",{className:"value"})]}),m.jsx("p",{className:"value",style:{fontWeight:700,margin:"3px",fontSize:"13px",color:"wheat",textAlign:"center"}})]})]})]})}const an={rotatedAxisText:"_rotatedAxisText_y6xfd_1",axisText:"_axisText_y6xfd_11","value-axis":"_value-axis_y6xfd_21","time-axis":"_time-axis_y6xfd_41"};function Px({data:t,type:e="line",xKey:n,yValue:r,withBrush:a=!1,colorIdx:i=0,tooltipFormat:s={prefix:"",suffix:""}}){const[o,l]=Ne(),{width:c,height:u}=l,h=750,f=[t,e,n,r,a,i,c,u,s],g={top:10,right:30,bottom:25,left:60},v=c>576,b=t.map(S=>S.title),d=rn(b),x=Se(S=>{if(c===0||u===0)return;const w=40,y=w+g.bottom,T=c-g.left-g.right,p=u-g.top-g.bottom,k=p-(a?y:0),_=S.select("svg");_.node();const E=_.select(".plot-area").attr("transform","translate("+g.left+","+g.top+")"),R=E.select("line.tooltipLine").attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",k).attr("stroke","#5b4f4b").attr("stroke-width",1).attr("fill","none").style("stroke-dasharray","3 3").style("opacity",0),z=_.select("defs");z.select("clipPath").select("rect").attr("width",T<0?0:T).attr("height",p);const N=t[0].datum[0][n],U=Lx(N),M=oe(t,function(A){return oe(A.datum,function(j){return U?new Date(j[n]):typeof j[n]=="number"?j[n]:Number(j[n])})}),Y=Gt(t,function(A){return Gt(A.datum,function(j){return U?new Date(j[n]):typeof j[n]=="number"?j[n]:Number(j[n])})}),C=[M,Y],F=U?ti().domain(C):ye().domain(C);F.range([0,T]);const H=di(T,U?[M,Y]:[]),V=U?v?an.axisText:an.rotatedAxisText:H,{prefix:et,suffix:$}=s;E.select(".x-axis").attr("transform","translate(0,"+k+")").transition().duration(h).call(he(F)).selectAll("text").attr("class",V);const dt=oe(t,A=>oe(A.datum,function(j){const nt=j[r];return typeof nt=="number"?nt:void 0}))??0,wt=Gt(t,A=>Gt(A.datum,function(j){const nt=j[r];return typeof nt=="number"?nt:void 0}))??0,pt=ye().domain([dt,wt]).rangeRound([k,0]).nice(),_t=be(pt).tickSize(-T);E.select(".y-axis").transition().duration(h).call(_t),E.selectAll("path.chartline").remove(),E.selectAll("path.chartarea").remove();const G=Bn().x(A=>F(U?new Date(A[n]):A[n])).y(A=>pt(Number(A[r]))),ot=A=>{const j=d.current.findIndex(nt=>nt===t[A].title)+i;return de(j,!1,!0)},O=E.selectAll("g.lineGroup").data(t,A=>A.title).join(A=>A.append("g").attr("class","lineGroup"),A=>A,A=>A.remove());z.selectAll("linearGradient").remove();const Q=js().x(A=>F(U?new Date(A[n]):A[n])).y0(k).y1(A=>pt(Number(A[r])));e==="area"&&(t.map(j=>j.title).forEach((j,nt)=>{const Dt=Rs(j),W=z.append("linearGradient").attr("id",Dt).attr("x1","0%").attr("y1","0%").attr("x2","0%").attr("y2","100%"),K=de(nt,!1,!0);W.append("stop").attr("offset","0%").attr("stop-color",K).attr("stop-opacity",.7),W.append("stop").attr("offset","100%").attr("stop-color",K).attr("stop-opacity",0)}),O.selectAll("path.chartarea").data(function(j){return[j.datum]}).join(j=>j.append("path").attr("class","chartarea").attr("stroke","none").attr("fill",function(){const nt=qt(this.parentNode).datum(),{title:Dt}=nt;return`url(#${Rs(Dt)})`}).attr("d",nt=>G(nt)).attr("clip-path","url(#clip)").style("pointer-events","none"),void 0,j=>j.remove()).attr("d",j=>Q(j))),O.selectAll("path.chartline").data(function(A){return[A.datum]}).join(A=>A.append("path").attr("class","chartline").attr("fill","none").attr("stroke",function(){const j=qt(this.parentNode).datum(),nt=d.current.findIndex(Dt=>Dt===j.title)+i;return de(nt,!1,!0)}).attr("stroke-width",2).attr("d",j=>G(j)).attr("clip-path","url(#clip)").style("pointer-events","none"),void 0,A=>A.remove()).attr("d",A=>G(A));const X=3,D=O.selectAll("circle.tooltipCircle").data(function(A){return[A.datum]}).join(A=>A.append("circle").attr("class","tooltipCircle").attr("cx",20).attr("cy",30).attr("r",X).attr("fill",function(){const j=qt(this.parentNode).datum(),nt=d.current.findIndex(Dt=>Dt===j.title)+i;return de(nt,!1,!0)}).style("opacity",0),void 0,A=>A).attr("cx",20).attr("cy",30).attr("r",X).attr("fill",function(){const A=qt(this.parentNode).datum(),j=d.current.findIndex(nt=>nt===A.title)+i;return de(j,!1,!0)}),tt=E.select("g.tooltip").style("pointer-events","none");tt.raise(),E.select("rect.overlay").attr("width",T<0?0:T).attr("height",k).style("fill","red").style("opacity",0).on("pointerenter pointermove",L).on("pointerleave",Z).on("touchstart",A=>A.preventDefault());function L(A){const j=Nr(ut=>U?new Date(ut[n]):ut[n]).center,nt=j(t[0].datum,F.invert(tr(A)[0])),Dt=t[0].datum[nt],W=oe(t,function(ut){return Number(ut.datum[nt][r])}),K=[];for(let ut=0;ut<t.length;ut++){const{title:vt}=t[ut],At=t[ut].datum[nt],jt=String(At[n]),Xt=Number(At[r]);D.filter(function(){return qt(this.parentNode).datum().title===vt}).attr("cx",F(U?new Date(At[n]):At[n])).attr("cy",pt(Xt)).style("opacity",1),K.push({title:vt,label:jt,value:Xt})}const Ct=F(U?new Date(t[0].datum[nt][n]):t[0].datum[nt][n]);R.style("opacity",1).attr("x1",Ct).attr("x2",Ct),ft(K);const Rt=5,q=F(U?new Date(Dt[n]):Dt[n]),Tt=pt(W??0)+X+Rt;tt.transition().duration(100).style("display",null).attr("transform",`translate(${q},${Tt})`)}function Z(A){tt.transition().duration(250).style("display","none"),D.style("opacity",0),R.style("opacity",0),a&&it.transition().duration(h/4).style("opacity",1)}function ft(A){const j=tt.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),nt=A.reduce((W,K)=>{const Ct=K.title,Rt=K.label+": "+(et??"")+K.value+($??"");return W.push(Ct),W.push(Rt),W},[]),Dt=tt.selectAll("text").data([null]).join("text").call(W=>W.selectAll("tspan").data(nt).join("tspan").attr("x",0).attr("y",(K,Ct)=>`${Ct*1.1}em`).style("align","right").text(K=>K));st(Dt,j),a&&it.transition().duration(h/4).style("opacity",0)}function st(A,j){const{x:nt,y:Dt,width:W,height:K}=A.node().getBBox();A.attr("transform",`translate(${-W/2},${15-Dt})`),j.attr("d",`M${-W/2-10},5H-5l5,-5l5,5H${W/2+10}v${K+20}h-${W+20}z`)}const it=_.select(".brush-area").attr("transform","translate("+g.left+","+(k+g.top+g.bottom)+")");if(it.selectAll("path.line").remove(),it.selectAll("path.area").remove(),it.selectAll("g.brush").remove(),a){let A=function(Ct){const Rt=Ct.selection;if(Rt)F.domain([j.invert(Rt[0]),j.invert(Rt[1])]);else if(!Rt||Rt===null){const q=C;F.domain(q)}K()};const j=U?ti().domain(C):ye().domain(C);j.range([0,T]);const nt=ye().domain([dt,wt]).range([w,0]),Dt=Bn().x(Ct=>F(U?new Date(Ct[n]):Ct[n])).y(Ct=>nt(Number(Ct[r])));for(let Ct=0;Ct<t.length;Ct++){if(e==="area"){const Rt=js().x(q=>F(U?new Date(q[n]):q[n])).y0(w).y1(q=>nt(Number(q[r])));it.append("path").datum(t[Ct].datum).attr("class","area").attr("fill",function(){const q=t[Ct].title;return`url(#${Rs(q)})`}).attr("stroke","none").attr("d",Rt).attr("clip-path","url(#clip)")}it.append("path").datum(t[Ct].datum).attr("class","line").attr("fill","none").attr("stroke",ot(Ct)).attr("stroke-width",2).attr("d",Dt).attr("clip-path","url(#clip)")}it.select(".x-axis").attr("transform","translate(0,"+w+")").call(he(j)).selectAll("text").attr("class",V);const W=Sl().extent([[0,0],[c,w]]).on("brush",A);it.append("g").attr("class","brush").call(W),_.on("dblclick",function(){F.domain(C),it.select(".brush").call(W.move,null),K()});const K=()=>{E.select(".x-axis").call(he(F)).selectAll("text").attr("class",V),e==="area"&&E.selectAll("path.chartarea").attr("d",Q),E.selectAll("path.chartline").attr("d",G)}}},[...f,s]);return m.jsx("div",{ref:o,style:{width:c,height:u,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:x,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsx("div",{className:`${J[v?"controls-container":"controls-container-sm"]}`,style:{gap:2,height:24}}),m.jsxs("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${c} ${u}`,children:[m.jsx("defs",{children:m.jsx("clipPath",{id:"clip",children:m.jsx("rect",{})})}),c>0&&m.jsxs(m.Fragment,{children:[m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`x-axis ${an["time-axis"]}`}),m.jsx("g",{className:`y-axis ${an["value-axis"]}`}),m.jsx("line",{className:"tooltipLine"}),m.jsx("rect",{className:"overlay"}),m.jsx("g",{className:"tooltip"})]}),m.jsx("g",{className:"brush-area",children:m.jsx("g",{className:`x-axis ${an["time-axis"]}`})})]})]})]})})}function He(){const t=bt.useRef(null),[e,n]=bt.useState({width:0,height:0});return bt.useEffect(()=>{const r=t.current;if(!r)return;const a=new ResizeObserver(([i])=>{i?.contentRect&&n({width:i.contentRect.width,height:i.contentRect.height})});return a.observe(r,{box:"border-box"}),n({width:r.offsetWidth,height:r.offsetHeight}),()=>{a.disconnect()}},[]),[t,e]}const fn={legend:"_legend_7ftsg_1","legend-active":"_legend-active_7ftsg_1","legend-rect":"_legend-rect_7ftsg_21","legend-label":"_legend-label_7ftsg_35",pieSlice:"_pieSlice_7ftsg_77",pieSliceNotHovered:"_pieSliceNotHovered_7ftsg_87",animateNotHovered:"_animateNotHovered_7ftsg_1",pieSliceExit:"_pieSliceExit_7ftsg_111",animateHide:"_animateHide_7ftsg_1",pieLabelEnter:"_pieLabelEnter_7ftsg_129",showText:"_showText_7ftsg_1",pieLabelUnhover:"_pieLabelUnhover_7ftsg_153",pieLabelUpdate:"_pieLabelUpdate_7ftsg_183",pieLabelExit:"_pieLabelExit_7ftsg_197"};function Ex({data:t,innerRadius:e=0,sortWithLegends:n=!1,colorIdx:r=0}){const[a,i]=Ne(),{width:s,height:o}=i,[l,c]=He(),{width:u,height:h}=c,f=rn(t.map(k=>k.label)),[g,v]=bt.useState([]),[b,d]=bt.useState(!1),[x,S]=bt.useState(""),w=750,y=Se(k=>{const E=(n&&b?we(t).sort((z,I)=>z.value-I.value):t).map(z=>z.label);k.selectAll(".legend-item").data([...E],z=>z).join(z=>{const I=z.append("div").attr("class",function(N){return`${fn[N===x?"legend-active":"legend"]} legend-item`}).style("left","-10px").style("top",function(N,U){return`${U*20+10}px`}).style("opacity",0);return I.append("div").attr("class",`rect ${fn["legend-rect"]}`).style("background-color",N=>vr(f.current.findIndex(U=>U===N)+r)),I.append("span").attr("class",fn["legend-label"]).style("color",N=>"#333").text(N=>N),I.transition().duration(w).style("left","6px").style("opacity",1),I},z=>(z.attr("class",I=>`
|
|
7
|
+
${fn[I===x?"legend-active":"legend"]} legend-item`).transition().duration(w).style("top",function(I,N){return`${N*20+10}px`}).style("left","6px").style("opacity",1).select("div.rect").attr("class",`rect ${fn["legend-rect"]}`).style("background-color",I=>vr(f.current.findIndex(N=>N===I)+r)),z.select("span").style("color",I=>"#333").text(I=>I),z),z=>z.transition().duration(w).style("opacity",0).style("left","30px").remove()).on("mouseover",(z,I)=>{S(I)}).on("mouseout",()=>{S("")})},[t,r,u,h,x,b,n]),T=Se(k=>{if(u===0||h===0)return;const _={x:u/2,y:h/2},E={top:10,right:20,bottom:10,left:20},R=t,z=u-(E.left+E.right),I=h-(E.top+E.bottom),N=Math.min(z,I)/2,U=R.reduce((X,D)=>X+D.value,0),M=k.select(".plot-area").attr("transform","translate("+_.x+","+_.y+")"),Y=bx().value(function(X){return X.value}).sort(function(X,D){return b?Ln(X.value,D.value):0}),C=we(R),F=Y(C),H=we(C);v(Y(H));let V=H.length>C.length;const et=g.map(X=>X.data.label),$=F.map(X=>X.data.label);et.every(X=>V?!1:$.includes(X)?!0:(V=!0,!1));const dt=g.length===0,pt=si().innerRadius(e*N).outerRadius(N-12),_t=si().innerRadius(e*N).outerRadius(N),G=(X,D)=>{const tt=Ae(D==="exit"?X.endAngle:X.startAngle,D==="exit"?X.startAngle:X.endAngle),L=X.data.label===x;return function(Z){return X.endAngle=tt(Z),L?_t(X)||"":pt(X)||""}};M.selectAll("path").data(F,function(X){return X.data.label}).join(X=>{const D=X.append("path").attr("class",fn.pieSlice).attr("fill",function(tt){const L=f.current.findIndex(Z=>Z===tt.data.label)+r;return vr(L)});return D.transition().duration(w).delay(dt?0:w).attr("d",pt).attrTween("d",function(tt){if(!dt)return G(tt,"not exit");const L=Ae(0,tt.startAngle),Z=Ae(0,tt.endAngle),ft=tt.data.label===x;return function(st){return tt.startAngle=L(st),tt.endAngle=Z(st),ft?_t(tt):pt(tt)}}),D},X=>{const D=X;return X.transition().duration(w).attr("fill",function(tt,L){const Z=f.current.findIndex(ft=>ft===tt.data.label)+r;return vr(Z)}).attrTween("d",function(tt){const L=g.find(j=>j.data.label===tt.data.label),Z=L&&L.startAngle?L.startAngle:0,ft=Ae(Z,tt.startAngle),st=L&&L.endAngle?L.endAngle:0,it=Ae(st,tt.endAngle),A=tt.data.label===x;return function(j){return tt.startAngle=ft(j),tt.endAngle=it(j),A?_t(tt)||"":pt(tt)||""}}),D},X=>X.attr("class",fn.pieSliceExit).transition().duration(w).attr("fill",Ee).attrTween("d",function(D){return G(D,"exit")}).remove()).on("mouseover",function(X,D){S(D.data.label)}).on("mouseout",()=>{S("")});const O=X=>R.length===1?"translate(0, 0)":`translate(${pt.centroid(X)})`,Q=X=>{const D=X.value/U;return pe(".1%")(D)};M.selectAll("text").data(F,function(X){return X.data.label}).join(X=>{const D=X.append("text").text(Q).attr("class",fn.pieLabelEnter);return D.merge(D).transition().duration(w).delay(w).attr("transform",O),D},X=>{const D=X.text(Q);return X.merge(D).attr("class",fn.pieLabelUpdate).transition().duration(x!==""?250:w).style("opacity",function(tt){const L=x===tt.data.label;return x===""||L?1:0}).attr("transform",O),D},X=>X.transition().duration(w/2).attr("class",fn.pieLabelExit).remove())},[t,r,e,u,h,b,x]),p=s>o;return m.jsxs("div",{ref:a,style:{width:s,height:o,position:"relative",display:"flex",flexDirection:p?"row":"column",overflow:"hidden"},children:[m.jsx("div",{ref:l,style:{flex:1,position:"relative",display:"flex"},children:m.jsx("svg",{ref:T,className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${u} ${h}`,children:m.jsx("g",{className:"plot-area"})})}),m.jsx("div",{style:{width:p?s>480?"180px":"100px":"100%",height:p?"100%":o>400?"180px":"100px",flexShrink:0,overflowY:"auto",background:"rgba(255, 255, 255)",borderLeft:p?"1px solid #ddd":"none",borderTop:p?"none":"1px solid #ddd",padding:"0px"},children:m.jsx("div",{ref:y,className:"legends-content",style:{display:"flex",flexDirection:"column",gap:"6px",padding:"8px 8px 16px 8px",boxSizing:"border-box",position:"relative"}})}),m.jsxs("label",{className:J["controls-label"],style:{position:"absolute",left:"12px",top:"6px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:b,onChange:k=>d(k.target.checked)}),"Sort"]})]})}const pi=({totalLabel:t="of total"})=>m.jsxs(Qe,{children:[m.jsx("p",{className:"label",style:{fontWeight:700,margin:"3px",fontSize:"14px",color:"wheat",textAlign:"center",borderBottom:"1px solid wheat"}}),m.jsxs("p",{className:"layer",style:{fontWeight:700,margin:"3px",marginTop:0,fontSize:"13px",color:"wheat",display:"flex",justifyContent:"flex-end",alignItems:"center",gap:2},children:[m.jsxs("span",{className:"label",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:1.5},children:[m.jsx("span",{className:"chev",style:{width:10,height:10,borderRadius:2}}),m.jsx("span",{className:"label"})]}),m.jsx("span",{className:"value",style:{textAlign:"right"}})]}),m.jsxs("p",{className:"total",style:{fontWeight:600,margin:"3px",marginTop:0,fontSize:"13px",color:"wheat",display:"flex",justifyContent:"flex-end",alignItems:"center",gap:2},children:[t,m.jsx("span",{className:"value",style:{fontWeight:700}})]})]}),It={"legends-container":"_legends-container_7rrtc_1","legend-container":"_legend-container_7rrtc_61","legend-container-active":"_legend-container-active_7rrtc_61","legend-container-inactive":"_legend-container-inactive_7rrtc_61","legend-container-sm":"_legend-container-sm_7rrtc_63","legend-container-active-sm":"_legend-container-active-sm_7rrtc_63","legend-container-inactive-sm":"_legend-container-inactive-sm_7rrtc_63","legend-rect":"_legend-rect_7rrtc_125","legend-label":"_legend-label_7rrtc_159",rect:"_rect_7rrtc_277",rectCard:"_rectCard_7rrtc_277",rectLegendNotHovered:"_rectLegendNotHovered_7rrtc_297",legend:"_legend_7rrtc_1",rectHoveredLegend:"_rectHoveredLegend_7rrtc_333",rectCardLegendHovered:"_rectCardLegendHovered_7rrtc_343",rectLegendHovered:"_rectLegendHovered_7rrtc_355",groupedRectNotHovered:"_groupedRectNotHovered_7rrtc_377",rotatedAxisText:"_rotatedAxisText_7rrtc_385",axisText:"_axisText_7rrtc_395",hoveredAxisText:"_hoveredAxisText_7rrtc_405",yAxisLabel:"_yAxisLabel_7rrtc_419","label-axis":"_label-axis_7rrtc_437",tick:"_tick_7rrtc_429",domain:"_domain_7rrtc_429","value-axis":"_value-axis_7rrtc_445"};function Rx({data:t,focusOnPlot:e=!1,colorIdx:n=0,orientation:r="vertical",tooltipFormat:{prefix:a="",suffix:i="",formatType:s="long"}={prefix:"",suffix:"",formatType:"long"}}){const[o,l]=Ne(),{width:c,height:u}=l,[h,f]=He(),{height:g}=f,[v,b]=He(),{width:d,height:x}=b,[S,w]=bt.useState(null),[y,T]=bt.useState(!1),[p,k]=bt.useState(["all"]),[_,E]=bt.useState(!1),[R,z]=bt.useState(!1);fi();const I=t;bt.useEffect(()=>{k(["all"]),T(!0)},[I]),bt.useEffect(()=>{k(["all"])},[e]);const N=750;bt.useEffect(()=>{let V;return y&&(V=setTimeout(()=>{T(!1)},N+500)),()=>{clearTimeout(V)}},[y]);const U=[d,x,p,n,e],M=we(I),Y=M.length===0?[]:Object.keys(M[0]).filter(V=>V!=="label"&&V!=="total"),C=rn(Y),F=d>576,H=Se(V=>{if(d===0||x===0)return;const et={top:20,right:30,bottom:30,left:30},$=M.length===0?[]:Object.keys(M[0]).filter(B=>B!=="label"&&B!=="total"),dt=e?$:$.filter(B=>!p.includes(B));M.forEach((B,mt)=>{const Mt=dt.reduce((Pt,ee)=>{ee in B||(B[ee]=0);const re=B[ee],lt=typeof re=="number"?re:0,yt=Pt.total+lt,St=Pt.totalPos+(lt>=0?lt:0),Ft=Pt.totalMin+(lt<0?lt:0);return{total:yt,totalPos:St,totalMin:Ft}},{total:0,totalPos:0,totalMin:0});B.total=Mt.total,B.totalPos=Mt.totalPos,B.totalMin=Mt.totalMin});const wt=M,pt=R?we(wt).sort(function(B,mt){return e?p[0]==="all"?B.total-mt.total:Number(B[p[0]])-Number(mt[p[0]]):B.total-mt.total}):wt,_t=d-et.left-et.right,G=x-et.top-et.bottom,ot=V.select("svg"),O=ot.node(),Q=ot.select(".plot-area").attr("transform","translate("+et.left+","+et.top+")"),D=V.select(".controls").select(".legends-container"),tt=F?80:50,L=function(B){const mt=It[F?"legend-container":"legend-container-sm"],Mt=It[F?"legend-container-active":"legend-container-active-sm"],Pt=It[F?"legend-container-inactive":"legend-container-inactive-sm"];return`
|
|
8
|
+
${p.includes(B)?e?Mt:Pt:mt}
|
|
9
9
|
legend-item
|
|
10
|
-
`},Z=B=>{const mt=C.current.findIndex(Pt=>Pt===B)+n;return de(mt)};function ft(B){return Z(B.key)}D.selectAll(".legend-item").data([...$],B=>B).join(B=>{const mt=B.append("div").attr("class",L).style("left",(
|
|
10
|
+
`},Z=B=>{const mt=C.current.findIndex(Pt=>Pt===B)+n;return de(mt)};function ft(B){return Z(B.key)}D.selectAll(".legend-item").data([...$],B=>B).join(B=>{const mt=B.append("div").attr("class",L).style("left",(Mt,Pt)=>`${Pt*tt}px`).style("top","-53px").style("opacity",0);return mt.append("div").attr("class",It["legend-rect"]).style("background",Mt=>{if(!e&&p.includes(Mt))return Ee;const Pt=C.current.findIndex(ee=>ee===Mt)+n;return de(Pt)}),mt.append("span").attr("class",It["legend-label"]).style("color",Mt=>!e&&p.includes(Mt)?"#d1d5db":"#333").text(Mt=>Mt),mt.transition().duration(N).style("top","0px").style("opacity",1),mt},B=>(B.attr("class",L).transition().duration(N).style("top","0px").style("left",(mt,Mt)=>`${Mt*tt}px`).style("opacity",1).select(`.${It["legend-rect"]}`).style("background",mt=>{if(!e&&p.includes(mt))return Ee;const Mt=C.current.findIndex(Pt=>Pt===mt)+n;return de(Mt)}),B.select(`.${It["legend-label"]}`).style("color",mt=>!e&&p.includes(mt)?Ee:"#333").text(mt=>mt),B),B=>B.style("color",Ee).transition().duration(N).style("opacity",0).style("top","53px").remove()).on("pointerenter",function(B,mt){if(p[0]==="all"){const Mt=Q.selectAll(".serie");e?(Mt.attr("fill",ft).filter(Pt=>Pt.key!==mt).style("opacity",.25),Mt.selectAll("rect").filter(Pt=>Pt.barKey===mt).attr("stroke-dasharray","none")):Mt.attr("fill",ft).filter(Pt=>Pt.key===mt).style("opacity",.25)}}).on("pointerleave",function(B,mt){const Mt=Q.selectAll(".serie");p[0]==="all"&&Mt.attr("fill",ft).style("opacity",1),Mt.selectAll("rect").attr("stroke-dasharray",kt),_&&E(!1)}).on("click",(B,mt)=>{k(Mt=>{let Pt=[];return e?Mt[0]===mt?Pt=["all"]:Pt=[mt]:Mt.includes(mt)?Pt=Mt.filter(ee=>ee!==mt):Pt=[...Mt,mt],Pt}),E(!0)});const st=V.select("div#tooltip").style("opacity",0);S===null&&w(we(M));const it=pt.map(function(B){return B.label}),A=Xe().domain(it).rangeRound(r==="vertical"?[0,_t]:[G,0]).paddingInner(F?.4:.25).paddingOuter(.2).align(.2),j=e?p[0]==="all"?Gt(M,B=>B.totalPos):Gt(M,B=>B[p[0]]):Gt(M,B=>B.totalPos),nt=Math.max(0,j??0),Dt=e?p[0]==="all"?oe(M,B=>B.totalMin):oe(M,B=>B[p[0]]):oe(M,B=>B.totalMin),W=Math.min(0,Dt??0),K=ye().domain([W,nt]).range(r==="vertical"?[G,0]:[0,_t]).nice(),Ct=!F&&r==="vertical"?It.rotatedAxisText:It.axisText,Rt=r==="vertical"?he(A).tickValues(A.domain()).tickSizeOuter(0):he(K).ticks(10,"s").tickSizeOuter(0).tickSize(-G);Q.select(".x-axis").attr("transform",`translate(0,${G})`).transition().duration(N).call(Rt).selectAll("text").style("cursor","pointer").attr("dy",F?"1em":".20em").attr("dx",F?"0em":"-.8em").attr("class",Ct).selectAll(".tick").filter(B=>B===0).select("line").remove(),Q.select(".x-axis").selectAll("path").style("display","none");const q=r==="vertical"?be(K).ticks(10,"s").tickSize(-_t):be(A).tickSizeOuter(0);Q.select(".y-axis").attr("transform","translate(0,0)").transition().duration(N).call(q).selectAll(".tick").filter(B=>B===0).select("line").remove(),Q.select(".y-axis").selectAll("path").style("display","none"),Q.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",r==="vertical"?_t:0).attr("y2",r==="vertical"?0:G).attr("transform",r==="vertical"?`translate(0, ${K(0)||0})`:`translate(${K(0)||0}, 0)`);const ut=na().keys(dt).offset(Es)(we(pt)).map(B=>{const mt=B.key,Mt=B.map(Pt=>{const ee=Pt.data.label;return{...Pt,key:`${mt} - ${ee}`,barKey:mt}});return Mt.key=mt,Mt}),vt=Q.selectAll(".serie").data(ut,B=>B.key).join(B=>B.append("g").attr("class","serie").attr("fill",ft).style("opacity",Mt=>e?p[0]==="all"||Mt.key===p[0]?1:0:1).style("pointer-events",Mt=>e?p[0]==="all"||Mt.key===p[0]?"auto":"none":"auto"),B=>B.transition().duration(N).attr("fill",Mt=>{const Pt=C.current.findIndex(re=>re===Mt.key)+n;return de(Pt)}).style("opacity",Mt=>e?p[0]==="all"||Mt.key===p[0]?1:0:1).style("pointer-events",Mt=>e?p[0]==="all"||Mt.key===p[0]?"auto":"none":"auto"),B=>B.transition().duration(N).attr("fill",Ee).style("opacity",0).selectAll("rect").attr("y",G).attr("height",0).remove()),At=B=>A(B.data.label+"")??0,jt=A.bandwidth(),Xt=e&&p[0]!=="all"||dt.length===1,ae=B=>{if(Xt){const mt=Number(B.data[B.barKey]);return r==="vertical"?mt>=0?K(mt):K(0):mt>=0?K(0):K(mt)}else{const mt=r==="vertical"?G:_t;return p[0]==="all"?K(r==="vertical"?B[1]:B[0]):e&&r!=="vertical"?K(0):mt-(K(B[0])-K(B[1]))}},Zt=B=>{if(Xt){const mt=Number(B.data[B.barKey]),Mt=Math.abs(K(mt)-K(0));return isNaN(Mt)||Mt<0?0:Mt}else{const mt=r==="vertical"?K(B[0])-K(B[1]):K(B[1])-K(B[0]);return isNaN(mt)||mt<0?0:mt}},Ht=B=>r==="vertical"?At(B):ae(B),te=B=>r==="vertical"?jt:Zt(B),ie=B=>r==="vertical"?ae(B):At(B),rt=B=>r==="vertical"?Zt(B):jt,gt=pt.map((B,mt)=>{const Mt=ut.map(re=>({key:re.key,start:re[mt][0],end:re[mt][1],value:B[re.key]})),Pt=Mt.filter(re=>re.value??!1).sort((re,lt)=>lt.end-re.end),ee=Mt.filter(re=>re.value??!1).sort((re,lt)=>re.start-lt.start);return{label:B.label,top:Pt.length>0?Pt[0]?.key:ee[ee.length-1]?.key,bottom:ee.length>0?ee[0]?.key:Pt[Pt.length-1]?.key}}),kt=(B,mt)=>{const Mt=te(B),Pt=rt(B),ee=gt.find(St=>St.label===B.data.label),re=B.data[B.barKey],lt=ee?.top===B.barKey&&Number(re)>=0,yt=ee?.bottom===B.barKey&&Number(re)<0;return lt?r==="vertical"?`${Mt+Pt} ${Mt} ${Pt}`:`${Mt+Pt+Mt}`:yt?r==="vertical"?`${Pt+Mt+Pt} ${Mt}`:`${Mt} ${Pt} ${Mt+Pt}`:r==="vertical"?`${Pt} ${Mt}`:`${Mt} ${Pt}`},Wt=B=>{const mt=te(B),Mt=gt.find(lt=>lt.label===B.data.label),Pt=B.data[B.barKey],ee=Mt?.top===B.barKey&&Number(Pt)>=0;return Mt?.bottom===B.barKey&&Number(Pt)<0?r==="vertical"?mt*-1:0:r==="vertical"?ee?0:mt*-1:0},xt=B=>`rect ${It.rect}`;vt.selectAll("rect").data(B=>B,B=>B.data.label).join(B=>{const mt=B.append("rect").attr("class",`rect ${J.rect}`).attr("x",function(Mt){return r==="vertical"?Ht(Mt):K(0)}).attr("width",function(Mt){return r==="vertical"?te(Mt):0}).attr("y",Mt=>r==="vertical"?K(0):ie(Mt)).attr("height",function(Mt){return r==="vertical"?0:rt(Mt)}).attr("stroke-dasharray",kt).attr("stroke-dashoffset",Wt);return mt.transition().duration(N).attr("x",Ht).attr("width",te).attr("height",rt).attr("y",ie),mt},void 0,B=>B.transition().duration(N).attr("opacity",0).attr("y",G).attr("height",0).remove()).attr("class",xt).attr("stroke-dasharray",kt).attr("stroke-dashoffset",Wt).transition().duration(N).attr("x",Ht).attr("width",te).attr("height",rt).attr("y",ie);const Nt={prefix:a,suffix:i,formatType:s};vt.selectAll("rect").on("pointerenter",function(B,mt){Q.select(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(ee=>ee===mt.data.label).attr("class",(r==="vertical"?Ct:"")+" "+It.hoveredAxisText),st.style("opacity",1);const Mt=mt.data[mt.barKey],{total:Pt}=mt.data;st.select("p.label").text(mt.data.label),st.select("p.layer span.label span.chev").style("background",Z(mt.barKey)),st.select("p.layer span.label span.label").text(mt.barKey),st.select("p.layer span.value").text(_e(Mt,Nt)),st.select("p.total span.value").text(_e(Pt??0,Nt)),le(st,{e:B,svg:O,yScale:K})}).on("touch",function(B,mt){qt(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(Mt=>Mt===mt.data.label)}).on("pointermove",(B,mt)=>{le(st,{e:B,svg:O,yScale:K})}).on("pointerleave",function(B,mt){Q.select(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(Mt=>Mt===mt.data.label).attr("class",r==="vertical"?Ct:""),st.style("opacity",0)})},[...U,R,M,Y,_,y,r,{prefix:a,suffix:i,formatType:s}]);return m.jsx("div",{ref:o,style:{width:`${c}px`,height:`${u}px`,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:H,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{ref:h,className:`controls ${J[F?"controls-container":"controls-container-sm"]}`,children:[m.jsxs("label",{className:J["controls-label"],style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:R,onChange:V=>z(V.target.checked)}),"Sort"]}),m.jsx("div",{className:`legends-container ${It["legends-container"]}`})]}),m.jsxs("div",{ref:v,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${d} ${x}`,children:d>0&&m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:"plot-rects"}),m.jsx("g",{className:`${r==="vertical"?It["value-axis"]:It["label-axis"]}
|
|
11
11
|
y-axis`}),m.jsx("g",{className:`${r==="horizontal"?It["value-axis"]:It["label-axis"]}
|
|
12
|
-
x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})}),m.jsx(pi,{})]})]})})}function zx({data:t,colorIdx:e=0,orientation:n="vertical",focusOnPlot:r=!0,tooltipFormat:{prefix:a="",suffix:i="",formatType:s="long"}={prefix:"",suffix:"",formatType:"long"}}){const[o,l]=Ne(),{width:c,height:u}=l,[h,f]=He(),{height:g}=f,[v,b]=He(),{width:d,height:x}=b,[S,w]=bt.useState(null),[y,T]=bt.useState(!1),[p,k]=bt.useState(["all"]),[_,E]=bt.useState(!1),[R,z]=bt.useState(!1);fi();const I=t;bt.useEffect(()=>{k(["all"]),T(!0),z(!1)},[I]);const N=750;bt.useEffect(()=>{let et;return y&&(et=setTimeout(()=>{T(!1)},N+500)),()=>{clearTimeout(et)}},[y]);const U=[d,x,p,e],M=we(I),Y=M.length===0?[]:Object.keys(M[0]).filter(et=>et!=="label"&&et!=="total"),C=rn(Y),F=d>576,H={prefix:a,suffix:i,formatType:s},V=Se(et=>{if(d===0||x===0)return;const $={top:20,right:30,bottom:30,left:30},dt=M.length===0?[]:Object.keys(M[0]).filter(
|
|
13
|
-
${p.includes(
|
|
12
|
+
x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})}),m.jsx(pi,{})]})]})})}function zx({data:t,colorIdx:e=0,orientation:n="vertical",focusOnPlot:r=!0,tooltipFormat:{prefix:a="",suffix:i="",formatType:s="long"}={prefix:"",suffix:"",formatType:"long"}}){const[o,l]=Ne(),{width:c,height:u}=l,[h,f]=He(),{height:g}=f,[v,b]=He(),{width:d,height:x}=b,[S,w]=bt.useState(null),[y,T]=bt.useState(!1),[p,k]=bt.useState(["all"]),[_,E]=bt.useState(!1),[R,z]=bt.useState(!1);fi();const I=t;bt.useEffect(()=>{k(["all"]),T(!0),z(!1)},[I]);const N=750;bt.useEffect(()=>{let et;return y&&(et=setTimeout(()=>{T(!1)},N+500)),()=>{clearTimeout(et)}},[y]);const U=[d,x,p,e],M=we(I),Y=M.length===0?[]:Object.keys(M[0]).filter(et=>et!=="label"&&et!=="total"),C=rn(Y),F=d>576,H={prefix:a,suffix:i,formatType:s},V=Se(et=>{if(d===0||x===0)return;const $={top:20,right:30,bottom:30,left:30},dt=M.length===0?[]:Object.keys(M[0]).filter(xt=>xt!=="label"&&xt!=="total"),wt=r?dt:dt.filter(xt=>!p.includes(xt));M.forEach(function(xt){xt.total=wt.reduce((Nt,B)=>{B in xt||(xt[B]=0);const mt=xt[B];return Nt+(typeof mt=="number"?mt:Number(mt))},0)});const pt=M,_t=R&&(r&&p[0]!=="all"||!r&&wt.length===1)?we(pt).sort(function(xt,Nt){return r?p[0]==="all"?xt.total-Nt.total:Number(xt[p[0]])-Number(Nt[p[0]]):xt.total-Nt.total}):pt,G=d-$.left-$.right,ot=x-$.top-$.bottom,O=et.select("svg"),Q=O.node(),X=O.select(".plot-area").attr("transform","translate("+$.left+","+$.top+")"),tt=et.select(".controls").select(".legends-container"),L=F?80:50,Z=function(xt){const Nt=It[F?"legend-container":"legend-container-sm"],B=It[F?"legend-container-active":"legend-container-active-sm"],mt=It[F?"legend-container-inactive":"legend-container-inactive-sm"];return`
|
|
13
|
+
${p.includes(xt)?r?B:mt:Nt}
|
|
14
14
|
legend-item
|
|
15
|
-
`},ft=
|
|
16
|
-
${T.includes(rt)?kt:
|
|
15
|
+
`},ft=xt=>{const Nt=C.current.findIndex(mt=>mt===xt)+e;return de(Nt)};function st(xt){return ft(xt.key)}tt.selectAll(".legend-item").data([...dt],xt=>xt).join(xt=>{const Nt=xt.append("div").attr("class",Z).style("left",(B,mt)=>`${mt*L}px`).style("top","-53px").style("opacity",0);return Nt.append("div").attr("class",It["legend-rect"]).style("background",B=>{if(!r&&p.includes(B))return Ee;const mt=C.current.findIndex(Mt=>Mt===B)+e;return de(mt)}),Nt.append("span").attr("class",It["legend-label"]).text(B=>B),Nt.transition().duration(N).style("top","0px").style("opacity",1),Nt},xt=>(xt.attr("class",Z).transition().duration(N).style("top","0px").style("left",(Nt,B)=>`${B*L}px`).style("opacity",1).select(`.${It["legend-rect"]}`).style("background",Nt=>{if(!r&&p.includes(Nt))return Ee;const B=C.current.findIndex(mt=>mt===Nt)+e;return de(B)}),xt.select(`.${It["legend-label"]}`).text(Nt=>Nt),xt),xt=>xt.transition().duration(N).style("opacity",0).style("top","53px").remove().remove()).on("click",(xt,Nt)=>{k(B=>{let mt=[];return r?B[0]===Nt?mt=["all"]:mt=[Nt]:B.includes(Nt)?mt=B.filter(Mt=>Mt!==Nt):mt=[...B,Nt],mt}),E(!0)}).on("pointerenter",(xt,Nt)=>{const B=X.selectAll(".serie");p[0]==="all"&&(r?B.attr("fill",st).filter(mt=>mt.key!==Nt).transition().duration(250).style("opacity",.25):B.attr("fill",st).filter(mt=>mt.key===Nt).transition().duration(250).style("opacity",.25))}).on("pointerleave",(xt,Nt)=>{X.selectAll(".serie"),p[0]==="all"&&X.selectAll(".serie").attr("fill",st).transition().duration(250).style("opacity",1)});const A=et.select("div#tooltip").style("opacity",0);S===null&&w(we(M));const j=p[0]==="all",nt=_t.map(function(xt){return xt.label}),W=di(d,nt)&&n==="vertical"?It.rotatedAxisText:It.axisText,K=Xe().domain(nt).rangeRound(n==="vertical"?[0,G]:[ot,0]).paddingInner(j?.15:F?.4:.25).paddingOuter(.2).align(.2),Ct=p[0]==="all"?Gt(M,xt=>Gt(Object.entries(xt).filter(([Nt])=>Nt!=="total"&&Nt!=="label").map(([,Nt])=>Nt))):Gt(M,xt=>xt[p[0]]),Rt=p[0]==="all"?oe(M,xt=>oe(Object.entries(xt).filter(([Nt])=>Nt!=="total"&&Nt!=="label").map(([,Nt])=>Nt))):oe(M,xt=>xt[p[0]]),q=Math.min(0,Rt??0),Tt=ye().domain([q,Ct??0]).range(n==="vertical"?[ot,0]:[0,G]),ut=n==="vertical"?he(K).tickValues(K.domain()).tickSizeOuter(0).tickSize(0):he(Tt).ticks(4,"s").tickSizeOuter(0).tickSize(-ot);X.select(".x-axis").attr("transform",`translate(0,${ot})`).transition().duration(N).call(ut).selectAll("text").attr("dy",F?"1em":".20em").attr("dx",F?"0em":"-.8em").attr("class",W).selectAll(".tick").filter(xt=>xt===0).select("line").remove(),X.select(".x-axis").selectAll("path").style("display","none");const vt=n==="vertical"?be(Tt).ticks(4,"s").tickSize(-G):be(K).tickSizeOuter(0).tickSize(0);X.select(".y-axis").attr("transform","translate(0,0)").transition().duration(N).call(vt).selectAll(".tick").filter(xt=>xt===0).select("path").remove(),X.select(".y-axis").selectAll("path").style("display","none"),X.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",n==="vertical"?G:0).attr("y2",n==="vertical"?0:ot).attr("transform",n==="vertical"?`translate(0, ${Tt(0)||0})`:`translate(${Tt(0)||0}, 0)`);const jt=na().keys(wt).offset(Es)(_t).map(xt=>{const Nt=xt.key,B=xt.map(mt=>{const Mt=Object.keys(mt.data).filter(Pt=>Pt!=="label"&&Pt!=="total"&&(r?!0:!p.includes(Pt))).map(Pt=>({label:Pt,value:mt.data[Pt]})).sort((Pt,ee)=>Number(Pt.value)-Number(ee.value));return{...mt,key:`${Nt} - ${mt.data.label}`,barKey:Nt,data:{...mt.data,sortedLayers:Mt.map(Pt=>Pt.label)}}});return B.key=Nt,B}),Xt=xt=>`rect ${It.rect}`;let ae=X.selectAll(".serie").data(jt,function(xt){return xt.key}).join(xt=>xt.append("g").attr("class","serie").attr("fill",st).style("opacity",B=>p[0]==="all"||B.key===p[0]?1:0).style("pointer-events",B=>p[0]==="all"||B.key===p[0]?"auto":"none"),xt=>xt.transition().duration(N).attr("fill",st).style("opacity",B=>p[0]==="all"||B.key===p[0]?1:0).style("pointer-events",B=>p[0]==="all"||B.key===p[0]?"auto":"none"),xt=>xt.transition().duration(N).style("opacity",0).attr("fill","grey").selectAll("rect").attr("y",ot).attr("height",0).remove());const Zt=xt=>{const Nt=K(xt.data.label)??0;if(!r||r&&p[0]==="all"){const B=R?xt.data.sortedLayers:wt,mt=Array.isArray(B)&&B.indexOf(xt.barKey)||0;return Nt+mt*(K.bandwidth()/wt.length)}return Nt},Ht=()=>!r||r&&p[0]==="all"?K.bandwidth()/wt.length:K.bandwidth(),te=xt=>{const Nt=Number(xt.data[xt.barKey]);return n==="vertical"?Nt>=0?Tt(Nt):Tt(0):Nt>=0?Tt(0):Tt(Nt)},ie=xt=>{const Nt=Number(xt.data[xt.barKey]),B=Math.abs(Tt(Nt)-Tt(0));return isNaN(B)||B<0?0:B},rt=xt=>n==="vertical"?Zt(xt):te(xt),gt=xt=>n==="vertical"?Ht():ie(xt),kt=xt=>n==="vertical"?te(xt):Zt(xt),Wt=xt=>n==="vertical"?ie(xt):Ht();ae.selectAll("rect").data(xt=>xt,xt=>xt.data.label).join(xt=>{let Nt;return Nt=xt.append("rect").attr("class",Xt).attr("x",function(B){return n==="vertical"?rt(B):0}).attr("width",function(B){return n==="vertical"?p[0]==="all"?K.bandwidth()/wt.length:K.bandwidth():0}).attr("y",function(B){return n==="vertical"?ot:kt(B)}).attr("height",function(B){return n==="vertical"?0:p[0]==="all"?K.bandwidth()/wt.length:K.bandwidth()}).transition().duration(N).style("opacity",1).attr("x",rt).attr("width",gt).attr("height",Wt).attr("y",kt),Nt},void 0,xt=>xt.attr("fill",Ee).transition().duration(N).attr("opacity",0).attr("height",0).attr("y",ot+$.bottom).remove()).attr("class",Xt).transition().duration(N).style("opacity",1).attr("x",rt).attr("width",gt).attr("height",Wt).attr("y",kt),ae.selectAll("rect").on("pointerenter",function(xt,Nt){R&&ae.selectAll("rect").filter(Pt=>Pt.barKey!==Nt.barKey).style("opacity",.25),X.select(n==="vertical"?".x-axis":".y-axis").selectAll("text").filter(Pt=>Pt===Nt.data.label).attr("class",(n==="vertical"?W:"")+" "+It.hoveredAxisText),A.style("opacity",1);const B=Nt.data[Nt.barKey],{total:mt}=Nt.data,Mt=B/mt*100;pe(".1f")(Mt)+"",A.select("p.label").text(Nt.data.label),A.select("p.layer span.label span.chev").style("background",ft(Nt.barKey)),A.select("p.layer span.label span.label").text(Nt.barKey),A.select("p.layer span.value").text(_e(B,H)),A.select("p.total span.value").text(_e(mt??0,H)),le(A,{e:xt,svg:Q,yScale:Tt})}).on("touch",function(xt,Nt){qt(".x-axis").selectAll("text").filter(B=>B===Nt.data.label).attr("class",W)}).on("pointermove",(xt,Nt)=>{le(A,{e:xt,svg:Q,yScale:Tt})}).on("pointerleave",function(xt,Nt){R&&ae.selectAll("rect").filter(B=>B.barKey!==Nt.barKey).style("opacity",1),X.select(n==="vertical"?".x-axis":".y-axis").selectAll("text").filter(B=>B===Nt.data.label).attr("class",n==="vertical"?W:""),A.style("opacity",0)})},[...U,R,M,_,n,y,H]);return m.jsx("div",{ref:o,style:{width:c,height:u,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:V,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{ref:h,className:`controls ${J[F?"controls-container":"controls-container-sm"]}`,children:[m.jsxs("label",{className:J["controls-label"],style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:R,onChange:et=>z(et.target.checked)}),"Sort"]}),m.jsx("div",{className:`legends-container ${It["legends-container"]}`})]}),m.jsxs("div",{ref:v,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${d} ${x}`,children:d>0&&m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:"plot-rects"}),m.jsx("g",{className:`${n==="vertical"?It["value-axis"]:It["label-axis"]} y-axis`}),m.jsx("g",{className:`${n==="horizontal"?It["value-axis"]:It["label-axis"]} x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})}),m.jsx(pi,{})]})]})})}function Ix({data:t,colorIdx:e=0,orientation:n="vertical",tooltipFormat:{prefix:r="",suffix:a="",formatType:i="long"}={prefix:"",suffix:"",formatType:"long"}}){const[s,o]=Ne(),{width:l,height:c}=o,[u,h]=He(),{height:f}=h,[g,v]=He(),{width:b,height:d}=v,[x,S]=bt.useState(!0),[w,y]=bt.useState(!1),[T,p]=bt.useState(["all"]);fi();const k=t;bt.useEffect(()=>{p(["all"]),S(!0),y(!0)},[k]);const _=750;bt.useEffect(()=>{let Y;return w&&(Y=setTimeout(()=>{y(!1)},_+500)),()=>{clearTimeout(Y)}},[w]);const E=[b,d,T,e],R=we(k),z=R.length===0?[]:Object.keys(R[0]).filter(Y=>Y!=="label"&&Y!=="total"),I=rn(z),N=b>576,U={prefix:r,suffix:a,formatType:i},M=Se(Y=>{if(b===0||d===0)return;const C={top:20,right:30,bottom:30,left:30},F=R.length===0?[]:Object.keys(R[0]).filter(rt=>rt!=="label"&&rt!=="total"),H=F.filter(rt=>!T.includes(rt));R.forEach(function(rt){rt.total=H.reduce((gt,kt)=>{kt in rt||(rt[kt]=0);const Wt=rt[kt];return gt+(typeof Wt=="number"?Wt:Number(Wt))},0)});const et=R.filter(rt=>rt?.total&&rt.total>0),$=b-C.left-C.right,dt=d-C.top-C.bottom,wt=Y.select("svg"),pt=wt.node(),_t=wt.select(".plot-area").attr("transform","translate("+C.left+","+C.top+")"),ot=Y.select(".controls").select(".legends-container"),O=N?80:50,Q=rt=>{const gt=I.current.findIndex(kt=>kt===rt)+e;return de(gt)};function X(rt){return Q(rt.key)}const D=function(rt){const gt=It[N?"legend-container":"legend-container-sm"],kt=It[N?"legend-container-inactive":"legend-container-inactive-sm"];return`
|
|
16
|
+
${T.includes(rt)?kt:gt}
|
|
17
17
|
legend-item
|
|
18
|
-
`};ot.selectAll(".legend-item").data([...F],rt=>rt).join(rt=>{const
|
|
19
|
-
${y.includes(lt)?a?St:
|
|
18
|
+
`};ot.selectAll(".legend-item").data([...F],rt=>rt).join(rt=>{const gt=rt.append("div").attr("class",D).style("left",(kt,Wt)=>`${Wt*O}px`).style("top","-53px").style("opacity",0);return gt.append("div").attr("class",It["legend-rect"]).style("background",kt=>{if(T.includes(kt))return Ee;const Wt=I.current.findIndex(xt=>xt===kt)+e;return de(Wt)}),gt.append("span").attr("class",It["legend-label"]).text(kt=>kt),gt.transition().duration(_).style("top","0px").style("opacity",1),gt},rt=>(rt.attr("class",D).transition().duration(_).style("top","0px").style("left",(gt,kt)=>`${kt*O}px`).style("opacity",1).select(`.${It["legend-rect"]}`).style("background",gt=>{if(T.includes(gt))return Ee;const kt=I.current.findIndex(Wt=>Wt===gt)+e;return de(kt)}),rt.select(`.${It["legend-label"]}`).text(gt=>gt),rt),rt=>rt.transition().duration(_).style("opacity",0).style("top","53px").remove().remove().remove()).on("pointerenter",(rt,gt)=>{_t.selectAll(".serie").attr("fill",X).filter(kt=>kt.key===gt).style("opacity",.25)}).on("pointerleave",function(rt,gt){_t.selectAll(".serie").attr("fill",X).filter(kt=>kt.key===gt).style("opacity",1)}).on("click",function(rt,gt){p(kt=>{let Wt=[];return kt.includes(gt)?Wt=kt.filter(xt=>xt!==gt):Wt=[...kt,gt],Wt})});const L=Y.select("div#tooltip").style("opacity",0),Z=!N&&n==="vertical"?It.rotatedAxisText:It.axisText,ft=et.map(function(rt){return rt.label}),st=Xe().domain(ft).rangeRound(n==="vertical"?[0,$]:[dt,0]).paddingInner(N?.4:.25).paddingOuter(.2).align(.2),it=Gt(R,rt=>rt.total),A=ye().domain([0,x?1:it||0]).nice().range(n==="vertical"?[dt,0]:[0,$]),j=[],nt=n==="vertical"?he(st).tickValues(st.domain()).tickSizeOuter(0):he(A).ticks(10,x?".0%":"s").tickSizeOuter(0).tickSize(-dt);_t.select(".x-axis").attr("transform",`translate(0,${dt})`).transition().duration(_).call(nt).selectAll("text").style("cursor","pointer").attr("dy",N?"1em":".20em").attr("dx",N?"0em":"-.8em").attr("class",Z).selectAll(".tick").filter(rt=>rt===0).select("line").remove();const Dt=Gt(R,rt=>rt.total),W=ye().domain([0,x?1:Dt||0]).nice().range([dt,0]),K=n==="vertical"?be(A).ticks(10,x?".0%":"s").tickSize(-$):be(st).tickSizeOuter(0);_t.select(".y-axis").attr("transform","translate(0,0)").transition().duration(_).call(K).selectAll(".tick").filter(rt=>rt===0).select("line").remove();const Rt=na().keys(H).order(ui).offset(x?Yc:ea)(et).map(rt=>{const gt=rt.key,kt=rt.map(Wt=>{const xt=Wt.data.label;return{...Wt,key:`${gt} - ${xt}`,barKey:gt}});return kt.key=gt,kt});let q=_t.selectAll(".serie").data(Rt,function(rt){return rt.key}).join(rt=>rt.append("g").attr("class","serie").attr("fill",X).style("opacity",1).style("pointer-events","auto"),rt=>rt.transition().duration(_).attr("fill",X).style("opacity",1).style("pointer-events","auto"),rt=>rt.transition().duration(_).style("opacity",0).attr("fill",Ee).selectAll("rect").attr("y",dt).attr("height",0).remove());const Tt=rt=>st(rt.data.label+"")??0,ut=st.bandwidth(),vt=rt=>A(n==="vertical"?rt[1]:rt[0]),At=rt=>{const gt=n==="vertical"?A(rt[0])-A(rt[1]):A(rt[1])-A(rt[0]);return isNaN(gt)||gt<0?0:gt},jt=rt=>n==="vertical"?Tt(rt):vt(rt),Xt=rt=>n==="vertical"?ut:At(rt),ae=rt=>n==="vertical"?vt(rt):Tt(rt),Zt=rt=>n==="vertical"?At(rt):ut;function Ht(rt){const gt=Xt(rt),kt=Zt(rt);return H.indexOf(rt.barKey)===H.length-1||rt.barKey===T[0]?n==="vertical"?`${gt+kt} ${gt} ${kt}`:`${gt+kt+gt}`:n==="vertical"?`${kt} ${gt}`:`${gt} ${kt}`}function te(rt){const gt=Xt(rt),kt=H.indexOf(rt.barKey)===H.length-1;return n==="vertical"?kt?0:gt*-1:0}const ie=rt=>`rect ${It.rect}`;q.selectAll("rect").data(rt=>rt,rt=>rt.data.label).join(rt=>{let gt;return gt=rt.append("rect").attr("class",ie).attr("x",function(kt){return n==="vertical"?st(kt.data.label)??0:A(0)}).attr("width",function(kt){return n==="vertical"?st.bandwidth():0}).attr("y",function(kt){if(n==="vertical"){if(!j.includes(kt.data.label+""))return dt;const Wt=A(kt[1]),xt=A(kt[0])-A(kt[1]),Nt=isNaN(xt)||xt<0?0:xt;return Wt+Nt}else return ae(kt)}).attr("height",function(kt){return n==="vertical"?0:Zt(kt)}).attr("stroke-dasharray",Ht).attr("stroke-dashoffset",te).transition().duration(_).attr("x",jt).attr("width",Xt).attr("height",Zt).attr("y",ae),gt},void 0,rt=>rt.transition().duration(_).attr("opacity",0).attr("height",0).attr("y",dt).remove()).attr("class",ie).attr("stroke-dasharray",Ht).attr("stroke-dashoffset",te).transition().duration(_).attr("x",jt).attr("width",Xt).attr("height",Zt).attr("y",ae),q.selectAll("rect").on("pointerenter",function(rt,gt){_t.select(".x-axis").selectAll("text").filter(B=>B===gt.data.name).attr("class",Z+" "+J.hoveredAxisText),L.style("opacity",1);const kt=gt.data[gt.barKey]||0,Wt=gt.data.total||0,xt=kt/Wt*100,Nt=pe(".1f")(xt)+"%";L.select("p.label").text(gt.data.label),L.select("p.layer span.label span.chev").style("background",Q(gt.barKey)),L.select("p.layer span.label span.label").text(gt.barKey),L.select("p.layer span.value").text(Nt),L.select("p.total span.value").text(`(${Pe(kt,U)} of ${Pe(Wt,U)})`),le(L,{e:rt,svg:pt,yScale:W})}).on("touch",function(rt,gt){qt(".x-axis").selectAll("text").filter(kt=>kt===gt.data.label).attr("class",Z)}).on("pointermove",(rt,gt)=>{le(L,{e:rt,svg:pt,yScale:W})}).on("pointerleave",function(rt,gt){_t.select(".x-axis").selectAll("text").filter(kt=>kt===gt.data.name).attr("class",Z),L.style("opacity",0)})},[...E,R,x,n,w,U]);return m.jsx("div",{ref:s,style:{width:l,height:c,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:M,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{ref:u,className:`controls ${J["controls-container"]}`,children:[m.jsxs("label",{className:J["controls-label"],style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:x,onChange:Y=>S(Y.target.checked)}),"Percentage"]}),m.jsx("div",{className:`legends-container ${It["legends-container"]}`})]}),m.jsxs("div",{ref:g,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${b} ${d}`,children:m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:"plot-rects"}),m.jsx("g",{className:`${n==="vertical"?It["value-axis"]:""} y-axis`}),m.jsx("g",{className:`${n==="horizontal"?It["value-axis"]:""} x-axis`})]})}),m.jsx(pi,{totalLabel:""})]})]})})}function Fx({data:t,colorIdx:e=0,mode:n="stacked",orientation:r="vertical",focusOnPlot:a=!1,tooltipFormat:{prefix:i="",suffix:s="",formatType:o="long"}={prefix:"",suffix:"",formatType:"long"}}){const[l,c]=Ne(),u=bt.useRef(n),h=bt.useDeferredValue(n),{width:f,height:g}=c,[v,b]=He(),{width:d,height:x}=b,[S,w]=bt.useState(null),[y,T]=bt.useState(["all"]),[p,k]=bt.useState(!1),[_,E]=bt.useState(!1),R=t;bt.useEffect(()=>{T(["all"])},[R]),bt.useEffect(()=>{u.current!==n&&(u.current=n),n!=="stacked"&&E(!1)},[R,n]),bt.useEffect(()=>{E(!1)},[n]),bt.useEffect(()=>{a&&T(["all"])},[n,a]),bt.useEffect(()=>{_&&u.current!==n&&(u.current=n)},[_]);const z=750;bt.useEffect(()=>{h!==n&&(u.current=h)},[h,n]);const I=[d,x,y,e],N=we(R),U={prefix:i,suffix:s,formatType:o},M=N.length===0?[]:Object.keys(N[0]).filter(H=>H!=="label"&&H!=="total"),Y=rn(M),C=d>576,F=Se(H=>{if(d===0||x===0)return;const V={top:20,right:30,bottom:30,left:30},et=u.current,$=N.length===0?[]:Object.keys(N[0]).filter(lt=>lt!=="label"&<!=="total"),dt=a?$:$.filter(lt=>!y.includes(lt));N.forEach(function(lt){const yt=dt.reduce((St,Ft)=>{Ft in lt||(lt[Ft]=0);const ue=lt[Ft],Ut=typeof ue=="number"?ue:Number(ue)??0,ke=St.totalPos+(Ut>=0?Ut:0),hn=St.totalMin+(Ut<0?Ut:0);return St.total+=Ut,St.totalPos=ke,St.totalMin=hn,St},{total:0,totalPos:0,totalMin:0});lt.total=yt.total,lt.totalPos=yt.totalPos,lt.totalMin=yt.totalMin});const wt=N,pt=_&&(n==="stacked"||n==="grouped"&&(a&&y[0]!=="all"||!a&&dt.length===1))?we(wt).sort(function(lt,yt){return a?y[0]==="all"?lt.total-yt.total:Number(lt[y[0]])-Number(yt[y[0]]):lt.total-yt.total}):wt,_t=d-V.left-V.right,G=x-V.top-V.bottom,ot=H.select("svg"),O=ot.node(),Q=ot.select(".plot-area").attr("transform","translate("+V.left+","+V.top+")"),D=H.select(".controls").select(".legends-container"),tt=function(lt){const yt=It[C?"legend-container":"legend-container-sm"],St=It[C?"legend-container-active":"legend-container-active-sm"],Ft=It[C?"legend-container-inactive":"legend-container-inactive-sm"];return`
|
|
19
|
+
${y.includes(lt)?a?St:Ft:yt}
|
|
20
20
|
legend-item
|
|
21
|
-
`},L=lt=>{const xt=Y.current.findIndex(Ht=>Ht===lt)+e;return de(xt)};function Z(lt){return L(lt.key)}const ft=C?80:50;D.selectAll(".legend-item").data([...$],lt=>lt).join(lt=>{const xt=lt.append("div").attr("class",tt).style("left",(St,Ht)=>`${Ht*ft}px`).style("top","-53px").style("opacity",0);return xt.append("div").attr("class",It["legend-rect"]).style("background",St=>{if(!a&&y.includes(St))return Ee;const Ht=Y.current.findIndex(ue=>ue===St)+e;return de(Ht)}),xt.append("span").attr("class",It["legend-label"]).text(St=>St),xt.transition().duration(z).style("top","0px").style("opacity",1),xt},lt=>(lt.attr("class",tt).transition().duration(z).style("top","0px").style("left",(xt,St)=>`${St*ft}px`).style("opacity",1).select(`.${It["legend-rect"]}`).style("background",xt=>{if(!a&&y.includes(xt))return Ee;const St=Y.current.findIndex(Ht=>Ht===xt)+e;return de(St)}),lt.select(`.${It["legend-label"]}`).text(xt=>xt),lt),lt=>lt.transition().duration(z).style("opacity",0).style("top","53px").remove().remove()).on("pointerenter",function(lt,xt){if(n==="percentage"&&a)return;const St=Q.selectAll(".serie");y[0]==="all"&&(a?(St.attr("fill",Z).filter(Ht=>Ht.key!==xt).transition().duration(250).style("opacity",.25),St.selectAll("rect").filter(Ht=>Ht.barKey===xt).attr("stroke-dasharray","none")):St.attr("fill",Z).filter(Ht=>Ht.key===xt).transition().duration(250).style("opacity",.25))}).on("pointerleave",function(lt,xt){if(n==="percentage"&&a)return;const St=Q.selectAll(".serie");y[0]==="all"&&Q.selectAll(".serie").attr("fill",Z).transition().duration(250).style("opacity",1),St.selectAll("rect").attr("stroke-dasharray",mt)}).on("click",(lt,xt)=>{n==="percentage"&&a||(T(St=>{let Ht=[];return a?St[0]===xt?Ht=["all"]:Ht=[xt]:St.includes(xt)?Ht=St.filter(ue=>ue!==xt):Ht=[...St,xt],Ht}),k(!0))});const st=pt.map(function(lt){return lt.label}),it=S?.map(lt=>lt.name)??[];let A=!1;S===null&&(A=!0,w(we(N)));const j=Xe().rangeRound(r==="vertical"?[0,_t]:[G,0]).domain(st).paddingInner(n!=="grouped"||n==="grouped"&&(a&&y[0]!=="all"||!a&&dt.length===1)?C?.4:.25:.1).paddingOuter(.2).align(.2),nt=a&&y[0]!=="all"||dt.length===1,$t=n==="stacked"||n==="percentage",W=n==="stacked"?a?y[0]==="all"?Gt(N,lt=>lt.totalPos):Gt(N,lt=>lt[y[0]]):Gt(N,lt=>lt.totalPos):n==="grouped"?y[0]==="all"?Gt(N,lt=>Gt(Object.entries(lt).filter(([xt])=>xt!=="total"&&xt!=="label"&&xt!=="totalPos"&&xt!=="totalMin").map(([,xt])=>xt))):Gt(N,lt=>lt[y[0]]):1,K=Math.max(0,W??0),Ct=n==="stacked"?a?y[0]==="all"?oe(N,lt=>lt.totalMin):oe(N,lt=>lt[y[0]]):oe(N,lt=>lt.totalMin):n==="grouped"?y[0]==="all"?oe(N,lt=>oe(Object.entries(lt).filter(([xt])=>xt!=="total"&&xt!=="label"&&xt!=="totalPos"&&xt!=="totalMin").map(([,xt])=>xt))):oe(N,lt=>lt[y[0]]):1,Rt=Math.min(0,Ct??0),q=ye().domain([Rt,K]).range(r==="vertical"?[G,0]:[0,_t]).nice(),Tt=!C&&r==="vertical"?It.rotatedAxisText:It.axisText,ut=r==="vertical"?he(j).tickValues(j.domain()).tickSizeOuter(0):he(q).ticks(4,n==="percentage"?".0%":"s").tickSizeOuter(0).tickSize(-G);Q.select(".x-axis").attr("transform",`translate(0,${G})`).transition().duration(z).call(ut).selectAll("text").style("cursor","pointer").attr("dy",C?"1em":".20em").attr("dx",C?"0em":"-.8em").attr("class",Tt).selectAll(".tick").filter(lt=>lt===0).select("line").remove(),Q.select(".x-axis").selectAll("path").style("display","none");const vt=r==="vertical"?be(q).ticks(4,n==="percentage"?".0%":"s").tickSize(-_t):be(j).tickSizeOuter(0);Q.select(".y-axis").attr("transform","translate(0,0)").transition().duration(A?0:z).call(vt).selectAll(".tick").filter(lt=>lt===0).select("line").remove(),Q.select(".y-axis").selectAll("path").style("display","none"),Q.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",r==="vertical"?_t:0).attr("y2",r==="vertical"?0:G).attr("transform",r==="vertical"?`translate(0, ${q(0)||0})`:`translate(${q(0)||0}, 0)`);const At=H.select("div#tooltip").style("opacity",0),Xt=na().keys(dt).offset(n!=="percentage"?Es:Yc)(pt).map(lt=>{const xt=lt.key,St=lt.map(Ht=>{const ue=Object.keys(Ht.data).filter(Ut=>Ut!=="label"&&Ut!=="total"&&Ut!=="totalPos"&&Ut!=="totalMin"&&(a?!0:!y.includes(Ut))).map(Ut=>({label:Ut,value:Ht.data[Ut]})).sort((Ut,ke)=>Number(Ut.value)-Number(ke.value));return{...Ht,key:`${xt} - ${Ht.data.label}`,barKey:xt,data:{...Ht.data,sortedLayers:ue.map(Ut=>Ut.label)}}});return St.key=xt,St}),ae=Q.selectAll(".serie").data(Xt,function(lt){return lt.key}).join(lt=>lt.append("g").attr("class","serie").attr("fill",Z).style("opacity",St=>y[0]==="all"||St.key===y[0]?1:0).style("pointer-events",St=>y[0]==="all"||St.key===y[0]?"auto":"none"),lt=>lt.transition().duration(z).attr("fill",Z).style("opacity",St=>y[0]==="all"||St.key===y[0]?1:0).style("pointer-events",St=>y[0]==="all"||St.key===y[0]?"auto":"none"),lt=>lt.transition().duration(z).style("opacity",0).attr("fill","grey").selectAll("rect").attr("y",0).attr("height",0).remove()),Zt=lt=>`rect ${It.rect}`,Wt=pt.map((lt,xt)=>{const St=Xt.map(Ut=>({key:Ut.key,start:Ut[xt][0],end:Ut[xt][1],value:lt[Ut.key]})),Ht=St.filter(Ut=>Ut.value??!1).sort((Ut,ke)=>ke.end-Ut.end),ue=St.filter(Ut=>Ut.value??!1).sort((Ut,ke)=>Ut.start-ke.start);return{label:lt.label,top:Ht.length>0?Ht[0]?.key:ue[ue.length-1]?.key,bottom:ue.length>0?ue[0]?.key:Ht[Ht.length-1]?.key}});function te(lt){const xt=j(lt.data.label)??0;if(n==="grouped"&&(!a||a&&y[0]==="all")){const Ht=(_?lt.data.sortedLayers:dt).indexOf(lt.barKey);return xt+Ht*(j.bandwidth()/dt.length)}return xt}function ie(lt){return n==="grouped"&&(!a||a&&y[0]==="all")?j.bandwidth()/dt.length:j.bandwidth()}function rt(lt){if($t)if(nt){const xt=Number(lt.data[lt.barKey]);return r==="vertical"?xt>=0?q(xt):q(0):xt>=0?q(0):q(xt)}else{const xt=r==="vertical"?G:_t;return y[0]==="all"?q(r==="vertical"?lt[1]:lt[0]):a&&r!=="vertical"?q(0):xt-(q(lt[0])-q(lt[1]))}else{const xt=Number(lt.data[lt.barKey]);return r==="vertical"?xt>=0?q(xt):q(0):xt>=0?q(0):q(xt)}}function yt(lt){if($t)if(nt){const xt=Number(lt.data[lt.barKey]),St=Math.abs(q(xt)-q(0));return isNaN(St)||St<0?0:St}else{const xt=r==="vertical"?q(lt[0])-q(lt[1]):q(lt[1])-q(lt[0]);return isNaN(xt)||xt<0?0:xt}else{const xt=Number(lt.data[lt.barKey]),St=Math.abs(q(xt)-q(0));return isNaN(St)||St<0?0:St}}const kt=et==="stacked"||et==="percentage",Ft=lt=>r==="vertical"?te(lt):rt(lt),gt=lt=>r==="vertical"?ie():yt(lt),Mt=lt=>r==="vertical"?rt(lt):te(lt),B=lt=>r==="vertical"?yt(lt):ie();function mt(lt){if(n==="grouped"||nt)return"none";const xt=gt(lt),St=B(lt),Ht=Wt.find(hn=>hn.label===lt.data.label),ue=lt.data[lt.barKey],Ut=Ht?.top===lt.barKey&&Number(ue)>=0,ke=Ht?.bottom===lt.barKey&&Number(ue)<0;return Ut?r==="vertical"?`${xt+St} ${xt} ${St}`:`${xt+St+xt}`:ke?r==="vertical"?`${St+xt+St} ${xt}`:`${xt} ${St} ${xt+St}`:r==="vertical"?`${St} ${xt}`:`${xt} ${St}`}function Nt(lt){const xt=gt(lt),St=Wt.find(ke=>ke.label===lt.data.label),Ht=lt.data[lt.barKey],ue=St?.top===lt.barKey&&Number(Ht)>=0;return St?.bottom===lt.barKey&&Number(Ht)<0?r==="vertical"?xt*-1:0:r==="vertical"?ue?0:xt*-1:0}ae.selectAll("rect").data(lt=>lt,lt=>lt.data.label).join(lt=>kt&&!$t?lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:q(0)}).attr("width",r==="vertical"?j.bandwidth():0).attr("y",function(St){return r==="vertical"?q(0):j(St.data.label)??0}).attr("height",r==="vertical"?0:j.bandwidth()).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Nt).transition().duration(z).attr("x",Ft).attr("width",gt).attr("height",B).transition().duration(z).attr("y",Mt):!kt&&$t?lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:q(0)}).attr("width",r==="vertical"?j.bandwidth():0).attr("y",function(St){return r==="vertical"?G:j(St.data.label)??0}).attr("height",r==="vertical"?0:j.bandwidth()).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Nt).transition().duration(z).attr("y",Mt).transition().duration(z).attr("x",Ft).attr("width",gt).attr("height",B):lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:it.includes(St.data.label)?rt(St)+yt(St):q(0)}).attr("width",r==="vertical"?j.bandwidth():0).attr("y",function(St){return r==="vertical"?it.includes(St.data.label)?rt(St)+yt(St):q(0):j(St.data.label)??0}).attr("height",r==="vertical"?0:j.bandwidth()).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Nt).transition().duration(z).attr("x",Ft).attr("width",gt).attr("height",B).attr("y",Mt),void 0,lt=>lt.attr("opacity",0).style("fill","grey").remove()).on("pointerenter",function(lt,xt){n==="grouped"&&_&&ae.selectAll("rect").filter(ke=>ke.barKey!==xt.barKey).style("opacity",.25),Q.select(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(ke=>ke===xt.data.label).attr("class",(r==="vertical"?Tt:"")+" "+It.hoveredAxisText),At.style("opacity",1);const St=xt.data[xt.barKey],Ht=xt.data.total??0,ue=St/Ht*100,Ut=pe(".1f")(ue)+"%";At.select("p.label").text(xt.data.label),At.select("p.layer span.label span.chev").style("background",L(xt.barKey)),At.select("p.layer span.label span.label").text(xt.barKey),At.select("p.layer span.value").text(n==="percentage"?Ut:_e(St,U)),At.select("p.total span.value").text(n==="percentage"?`(${Pe(St,U)} of ${Pe(Ht,U)})`:_e(Ht,U)),le(At,{e:lt,svg:O,yScale:q})}).on("pointermove",(lt,xt)=>{le(At,{e:lt,svg:O,yScale:q})}).on("pointerleave",function(lt,xt){n==="grouped"&&_&&ae.selectAll("rect").filter(St=>St.barKey!==xt.barKey).style("opacity",1),Q.select(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(St=>St===xt.data.label).attr("class",r==="vertical"?Tt:""),At.style("opacity",0)});function Pt(){ae.selectAll("rect").attr("class",Zt).transition().duration(z).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Nt).attr("x",Ft).attr("width",gt).attr("height",B).attr("y",Mt)}function ee(){ae.selectAll("rect").attr("class",Zt).transition().duration(z).attr("x",Ft).attr("width",gt).transition().duration(z).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Nt).attr("height",B).attr("y",Mt)}function re(){ae.selectAll("rect").attr("class",Zt).transition().duration(z).attr("y",Mt).attr("height",B).transition().duration(z).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Nt).attr("x",Ft).attr("width",gt)}n===et?Pt():$t?kt?Pt():r==="vertical"?re():ee():kt?r==="vertical"?ee():re():Pt()},[...I,_,N,n,r,U]);return m.jsx("div",{ref:l,style:{width:f,height:g,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:F,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{className:`controls ${J[C?"controls-container":"controls-container-sm"]}`,children:[m.jsxs("label",{className:`${J["controls-label"]} ${n==="percentage"?J.disabled:""}`,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:_,onChange:H=>E(H.target.checked),disabled:n==="percentage"}),"Sort"]}),m.jsx("div",{className:`legends-container ${It["legends-container"]}`})]}),m.jsxs("div",{ref:v,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",border:"1px solid green"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${d} ${x}`,children:d>0&&m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:"plot-rects"}),m.jsx("g",{className:`${r==="vertical"?It["value-axis"]:It["label-axis"]}
|
|
21
|
+
`},L=lt=>{const yt=Y.current.findIndex(Ft=>Ft===lt)+e;return de(yt)};function Z(lt){return L(lt.key)}const ft=C?80:50;D.selectAll(".legend-item").data([...$],lt=>lt).join(lt=>{const yt=lt.append("div").attr("class",tt).style("left",(St,Ft)=>`${Ft*ft}px`).style("top","-53px").style("opacity",0);return yt.append("div").attr("class",It["legend-rect"]).style("background",St=>{if(!a&&y.includes(St))return Ee;const Ft=Y.current.findIndex(ue=>ue===St)+e;return de(Ft)}),yt.append("span").attr("class",It["legend-label"]).text(St=>St),yt.transition().duration(z).style("top","0px").style("opacity",1),yt},lt=>(lt.attr("class",tt).transition().duration(z).style("top","0px").style("left",(yt,St)=>`${St*ft}px`).style("opacity",1).select(`.${It["legend-rect"]}`).style("background",yt=>{if(!a&&y.includes(yt))return Ee;const St=Y.current.findIndex(Ft=>Ft===yt)+e;return de(St)}),lt.select(`.${It["legend-label"]}`).text(yt=>yt),lt),lt=>lt.transition().duration(z).style("opacity",0).style("top","53px").remove().remove()).on("pointerenter",function(lt,yt){if(n==="percentage"&&a)return;const St=Q.selectAll(".serie");y[0]==="all"&&(a?(St.attr("fill",Z).filter(Ft=>Ft.key!==yt).transition().duration(250).style("opacity",.25),St.selectAll("rect").filter(Ft=>Ft.barKey===yt).attr("stroke-dasharray","none")):St.attr("fill",Z).filter(Ft=>Ft.key===yt).transition().duration(250).style("opacity",.25))}).on("pointerleave",function(lt,yt){if(n==="percentage"&&a)return;const St=Q.selectAll(".serie");y[0]==="all"&&Q.selectAll(".serie").attr("fill",Z).transition().duration(250).style("opacity",1),St.selectAll("rect").attr("stroke-dasharray",mt)}).on("click",(lt,yt)=>{n==="percentage"&&a||(T(St=>{let Ft=[];return a?St[0]===yt?Ft=["all"]:Ft=[yt]:St.includes(yt)?Ft=St.filter(ue=>ue!==yt):Ft=[...St,yt],Ft}),k(!0))});const st=pt.map(function(lt){return lt.label}),it=S?.map(lt=>lt.name)??[];let A=!1;S===null&&(A=!0,w(we(N)));const j=Xe().rangeRound(r==="vertical"?[0,_t]:[G,0]).domain(st).paddingInner(n!=="grouped"||n==="grouped"&&(a&&y[0]!=="all"||!a&&dt.length===1)?C?.4:.25:.1).paddingOuter(.2).align(.2),nt=a&&y[0]!=="all"||dt.length===1,Dt=n==="stacked"||n==="percentage",W=n==="stacked"?a?y[0]==="all"?Gt(N,lt=>lt.totalPos):Gt(N,lt=>lt[y[0]]):Gt(N,lt=>lt.totalPos):n==="grouped"?y[0]==="all"?Gt(N,lt=>Gt(Object.entries(lt).filter(([yt])=>yt!=="total"&&yt!=="label"&&yt!=="totalPos"&&yt!=="totalMin").map(([,yt])=>yt))):Gt(N,lt=>lt[y[0]]):1,K=Math.max(0,W??0),Ct=n==="stacked"?a?y[0]==="all"?oe(N,lt=>lt.totalMin):oe(N,lt=>lt[y[0]]):oe(N,lt=>lt.totalMin):n==="grouped"?y[0]==="all"?oe(N,lt=>oe(Object.entries(lt).filter(([yt])=>yt!=="total"&&yt!=="label"&&yt!=="totalPos"&&yt!=="totalMin").map(([,yt])=>yt))):oe(N,lt=>lt[y[0]]):1,Rt=Math.min(0,Ct??0),q=ye().domain([Rt,K]).range(r==="vertical"?[G,0]:[0,_t]).nice(),Tt=!C&&r==="vertical"?It.rotatedAxisText:It.axisText,ut=r==="vertical"?he(j).tickValues(j.domain()).tickSizeOuter(0):he(q).ticks(4,n==="percentage"?".0%":"s").tickSizeOuter(0).tickSize(-G);Q.select(".x-axis").attr("transform",`translate(0,${G})`).transition().duration(z).call(ut).selectAll("text").style("cursor","pointer").attr("dy",C?"1em":".20em").attr("dx",C?"0em":"-.8em").attr("class",Tt).selectAll(".tick").filter(lt=>lt===0).select("line").remove(),Q.select(".x-axis").selectAll("path").style("display","none");const vt=r==="vertical"?be(q).ticks(4,n==="percentage"?".0%":"s").tickSize(-_t):be(j).tickSizeOuter(0);Q.select(".y-axis").attr("transform","translate(0,0)").transition().duration(A?0:z).call(vt).selectAll(".tick").filter(lt=>lt===0).select("line").remove(),Q.select(".y-axis").selectAll("path").style("display","none"),Q.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",r==="vertical"?_t:0).attr("y2",r==="vertical"?0:G).attr("transform",r==="vertical"?`translate(0, ${q(0)||0})`:`translate(${q(0)||0}, 0)`);const At=H.select("div#tooltip").style("opacity",0),Xt=na().keys(dt).offset(n!=="percentage"?Es:Yc)(pt).map(lt=>{const yt=lt.key,St=lt.map(Ft=>{const ue=Object.keys(Ft.data).filter(Ut=>Ut!=="label"&&Ut!=="total"&&Ut!=="totalPos"&&Ut!=="totalMin"&&(a?!0:!y.includes(Ut))).map(Ut=>({label:Ut,value:Ft.data[Ut]})).sort((Ut,ke)=>Number(Ut.value)-Number(ke.value));return{...Ft,key:`${yt} - ${Ft.data.label}`,barKey:yt,data:{...Ft.data,sortedLayers:ue.map(Ut=>Ut.label)}}});return St.key=yt,St}),ae=Q.selectAll(".serie").data(Xt,function(lt){return lt.key}).join(lt=>lt.append("g").attr("class","serie").attr("fill",Z).style("opacity",St=>y[0]==="all"||St.key===y[0]?1:0).style("pointer-events",St=>y[0]==="all"||St.key===y[0]?"auto":"none"),lt=>lt.transition().duration(z).attr("fill",Z).style("opacity",St=>y[0]==="all"||St.key===y[0]?1:0).style("pointer-events",St=>y[0]==="all"||St.key===y[0]?"auto":"none"),lt=>lt.transition().duration(z).style("opacity",0).attr("fill","grey").selectAll("rect").attr("y",0).attr("height",0).remove()),Zt=lt=>`rect ${It.rect}`,Ht=pt.map((lt,yt)=>{const St=Xt.map(Ut=>({key:Ut.key,start:Ut[yt][0],end:Ut[yt][1],value:lt[Ut.key]})),Ft=St.filter(Ut=>Ut.value??!1).sort((Ut,ke)=>ke.end-Ut.end),ue=St.filter(Ut=>Ut.value??!1).sort((Ut,ke)=>Ut.start-ke.start);return{label:lt.label,top:Ft.length>0?Ft[0]?.key:ue[ue.length-1]?.key,bottom:ue.length>0?ue[0]?.key:Ft[Ft.length-1]?.key}});function te(lt){const yt=j(lt.data.label)??0;if(n==="grouped"&&(!a||a&&y[0]==="all")){const Ft=(_?lt.data.sortedLayers:dt).indexOf(lt.barKey);return yt+Ft*(j.bandwidth()/dt.length)}return yt}function ie(lt){return n==="grouped"&&(!a||a&&y[0]==="all")?j.bandwidth()/dt.length:j.bandwidth()}function rt(lt){if(Dt)if(nt){const yt=Number(lt.data[lt.barKey]);return r==="vertical"?yt>=0?q(yt):q(0):yt>=0?q(0):q(yt)}else{const yt=r==="vertical"?G:_t;return y[0]==="all"?q(r==="vertical"?lt[1]:lt[0]):a&&r!=="vertical"?q(0):yt-(q(lt[0])-q(lt[1]))}else{const yt=Number(lt.data[lt.barKey]);return r==="vertical"?yt>=0?q(yt):q(0):yt>=0?q(0):q(yt)}}function gt(lt){if(Dt)if(nt){const yt=Number(lt.data[lt.barKey]),St=Math.abs(q(yt)-q(0));return isNaN(St)||St<0?0:St}else{const yt=r==="vertical"?q(lt[0])-q(lt[1]):q(lt[1])-q(lt[0]);return isNaN(yt)||yt<0?0:yt}else{const yt=Number(lt.data[lt.barKey]),St=Math.abs(q(yt)-q(0));return isNaN(St)||St<0?0:St}}const kt=et==="stacked"||et==="percentage",Wt=lt=>r==="vertical"?te(lt):rt(lt),xt=lt=>r==="vertical"?ie():gt(lt),Nt=lt=>r==="vertical"?rt(lt):te(lt),B=lt=>r==="vertical"?gt(lt):ie();function mt(lt){if(n==="grouped"||nt)return"none";const yt=xt(lt),St=B(lt),Ft=Ht.find(hn=>hn.label===lt.data.label),ue=lt.data[lt.barKey],Ut=Ft?.top===lt.barKey&&Number(ue)>=0,ke=Ft?.bottom===lt.barKey&&Number(ue)<0;return Ut?r==="vertical"?`${yt+St} ${yt} ${St}`:`${yt+St+yt}`:ke?r==="vertical"?`${St+yt+St} ${yt}`:`${yt} ${St} ${yt+St}`:r==="vertical"?`${St} ${yt}`:`${yt} ${St}`}function Mt(lt){const yt=xt(lt),St=Ht.find(ke=>ke.label===lt.data.label),Ft=lt.data[lt.barKey],ue=St?.top===lt.barKey&&Number(Ft)>=0;return St?.bottom===lt.barKey&&Number(Ft)<0?r==="vertical"?yt*-1:0:r==="vertical"?ue?0:yt*-1:0}console.log("width: ",d),console.log("height: ",x),console.log("isStacked: ",Dt),console.log("prevIsStacked: ",kt),ae.selectAll("rect").data(lt=>lt,lt=>lt.data.label).join(lt=>kt&&!Dt?lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:q(0)}).attr("width",r==="vertical"?j.bandwidth():0).attr("y",function(St){return r==="vertical"?q(0):j(St.data.label)??0}).attr("height",r==="vertical"?0:j.bandwidth()).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Mt):!kt&&Dt?lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:q(0)}).attr("width",r==="vertical"?j.bandwidth():0).attr("y",function(St){return r==="vertical"?G:j(St.data.label)??0}).attr("height",r==="vertical"?0:j.bandwidth()).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Mt):lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:it.includes(St.data.label)?rt(St)+gt(St):q(0)}).attr("width",r==="vertical"?j.bandwidth():0).attr("y",function(St){return r==="vertical"?it.includes(St.data.label)?rt(St)+gt(St):q(0):j(St.data.label)??0}).attr("height",r==="vertical"?0:j.bandwidth()).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Mt),void 0,lt=>lt.attr("opacity",0).style("fill","grey").remove()).on("pointerenter",function(lt,yt){n==="grouped"&&_&&ae.selectAll("rect").filter(ke=>ke.barKey!==yt.barKey).style("opacity",.25),Q.select(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(ke=>ke===yt.data.label).attr("class",(r==="vertical"?Tt:"")+" "+It.hoveredAxisText),At.style("opacity",1);const St=yt.data[yt.barKey],Ft=yt.data.total??0,ue=St/Ft*100,Ut=pe(".1f")(ue)+"%";At.select("p.label").text(yt.data.label),At.select("p.layer span.label span.chev").style("background",L(yt.barKey)),At.select("p.layer span.label span.label").text(yt.barKey),At.select("p.layer span.value").text(n==="percentage"?Ut:_e(St,U)),At.select("p.total span.value").text(n==="percentage"?`(${Pe(St,U)} of ${Pe(Ft,U)})`:_e(Ft,U)),le(At,{e:lt,svg:O,yScale:q})}).on("pointermove",(lt,yt)=>{le(At,{e:lt,svg:O,yScale:q})}).on("pointerleave",function(lt,yt){n==="grouped"&&_&&ae.selectAll("rect").filter(St=>St.barKey!==yt.barKey).style("opacity",1),Q.select(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(St=>St===yt.data.label).attr("class",r==="vertical"?Tt:""),At.style("opacity",0)});function Pt(){ae.selectAll("rect").attr("class",Zt).transition().duration(z).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Mt).attr("x",Wt).attr("width",xt).attr("height",B).attr("y",Nt)}function ee(){ae.selectAll("rect").attr("class",Zt).transition().duration(z).attr("x",Wt).attr("width",xt).transition().duration(z).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Mt).attr("height",B).attr("y",Nt)}function re(){ae.selectAll("rect").attr("class",Zt).transition().duration(z).attr("y",Nt).attr("height",B).transition().duration(z).attr("stroke-dasharray",mt).attr("stroke-dashoffset",Mt).attr("x",Wt).attr("width",xt)}n===et?Pt():Dt?kt?Pt():r==="vertical"?re():ee():kt?r==="vertical"?ee():re():Pt()},[...I,_,N,n,r,U]);return m.jsx("div",{ref:l,style:{width:f,height:g,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:F,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{className:`controls ${J[C?"controls-container":"controls-container-sm"]}`,children:[m.jsxs("label",{className:`${J["controls-label"]} ${n==="percentage"?J.disabled:""}`,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:_,onChange:H=>E(H.target.checked),disabled:n==="percentage"}),"Sort"]}),m.jsx("div",{className:`legends-container ${It["legends-container"]}`})]}),m.jsxs("div",{ref:v,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",border:"1px solid green"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${d} ${x}`,children:d>0&&m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:"plot-rects"}),m.jsx("g",{className:`${r==="vertical"?It["value-axis"]:It["label-axis"]}
|
|
22
22
|
y-axis`}),m.jsx("g",{className:`${r==="horizontal"?It["value-axis"]:It["label-axis"]}
|
|
23
|
-
x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})}),m.jsx(pi,{totalLabel:n==="percentage"?"":"of total"})]})]})})}function Xc(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let a of t)(a=e(a,++r,t))!=null&&(n<a||n===void 0&&a>=a)&&(n=a)}return n}function Kc(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let a of t)(a=e(a,++r,t))!=null&&(n>a||n===void 0&&a>=a)&&(n=a)}return n}function zs(t,e){let n=0;if(e===void 0)for(let r of t)(r=+r)&&(n+=r);else{let r=-1;for(let a of t)(a=+e(a,++r,t))&&(n+=a)}return n}function Hx(t){return t.target.depth}function Wx(t,e){return t.sourceLinks.length?t.depth:e-1}function Ox(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Kc(t.sourceLinks,Hx)-1:0}function gi(t){return function(){return t}}function Gc(t,e){return yi(t.source,e.source)||t.index-e.index}function Zc(t,e){return yi(t.target,e.target)||t.index-e.index}function yi(t,e){return t.y0-e.y0}function Is(t){return t.value}function Bx(t){return t.index}function Yx(t){return t.nodes}function Ux(t){return t.links}function Jc(t,e){const n=t.get(e);if(!n)throw new Error("missing: "+e);return n}function Qc({nodes:t}){for(const e of t){let n=e.y0,r=n;for(const a of e.sourceLinks)a.y0=n+a.width/2,n+=a.width;for(const a of e.targetLinks)a.y1=r+a.width/2,r+=a.width}}function Vx(){let t=0,e=0,n=1,r=1,a=24,i=8,s,o=Bx,l=Wx,c,u,h=Yx,f=Ux,g=6;function v(){const M={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return b(M),d(M),x(M),S(M),T(M),Qc(M),M}v.update=function(M){return Qc(M),M},v.nodeId=function(M){return arguments.length?(o=typeof M=="function"?M:gi(M),v):o},v.nodeAlign=function(M){return arguments.length?(l=typeof M=="function"?M:gi(M),v):l},v.nodeSort=function(M){return arguments.length?(c=M,v):c},v.nodeWidth=function(M){return arguments.length?(a=+M,v):a},v.nodePadding=function(M){return arguments.length?(i=s=+M,v):i},v.nodes=function(M){return arguments.length?(h=typeof M=="function"?M:gi(M),v):h},v.links=function(M){return arguments.length?(f=typeof M=="function"?M:gi(M),v):f},v.linkSort=function(M){return arguments.length?(u=M,v):u},v.size=function(M){return arguments.length?(t=e=0,n=+M[0],r=+M[1],v):[n-t,r-e]},v.extent=function(M){return arguments.length?(t=+M[0][0],n=+M[1][0],e=+M[0][1],r=+M[1][1],v):[[t,e],[n,r]]},v.iterations=function(M){return arguments.length?(g=+M,v):g};function b({nodes:M,links:Y}){for(const[F,H]of M.entries())H.index=F,H.sourceLinks=[],H.targetLinks=[];const C=new Map(M.map((F,H)=>[o(F,H,M),F]));for(const[F,H]of Y.entries()){H.index=F;let{source:V,target:et}=H;typeof V!="object"&&(V=H.source=Jc(C,V)),typeof et!="object"&&(et=H.target=Jc(C,et)),V.sourceLinks.push(H),et.targetLinks.push(H)}if(u!=null)for(const{sourceLinks:F,targetLinks:H}of M)F.sort(u),H.sort(u)}function d({nodes:M}){for(const Y of M)Y.value=Y.fixedValue===void 0?Math.max(zs(Y.sourceLinks,Is),zs(Y.targetLinks,Is)):Y.fixedValue}function x({nodes:M}){const Y=M.length;let C=new Set(M),F=new Set,H=0;for(;C.size;){for(const V of C){V.depth=H;for(const{target:et}of V.sourceLinks)F.add(et)}if(++H>Y)throw new Error("circular link");C=F,F=new Set}}function S({nodes:M}){const Y=M.length;let C=new Set(M),F=new Set,H=0;for(;C.size;){for(const V of C){V.height=H;for(const{source:et}of V.targetLinks)F.add(et)}if(++H>Y)throw new Error("circular link");C=F,F=new Set}}function w({nodes:M}){const Y=Xc(M,H=>H.depth)+1,C=(n-t-a)/(Y-1),F=new Array(Y);for(const H of M){const V=Math.max(0,Math.min(Y-1,Math.floor(l.call(null,H,Y))));H.layer=V,H.x0=t+V*C,H.x1=H.x0+a,F[V]?F[V].push(H):F[V]=[H]}if(c)for(const H of F)H.sort(c);return F}function y(M){const Y=Kc(M,C=>(r-e-(C.length-1)*s)/zs(C,Is));for(const C of M){let F=e;for(const H of C){H.y0=F,H.y1=F+H.value*Y,F=H.y1+s;for(const V of H.sourceLinks)V.width=V.value*Y}F=(r-F+s)/(C.length+1);for(let H=0;H<C.length;++H){const V=C[H];V.y0+=F*(H+1),V.y1+=F*(H+1)}I(C)}}function T(M){const Y=w(M);s=Math.min(i,(r-e)/(Xc(Y,C=>C.length)-1)),y(Y);for(let C=0;C<g;++C){const F=Math.pow(.99,C),H=Math.max(1-F,(C+1)/g);k(Y,F,H),p(Y,F,H)}}function p(M,Y,C){for(let F=1,H=M.length;F<H;++F){const V=M[F];for(const et of V){let $=0,dt=0;for(const{source:pt,value:_t}of et.targetLinks){let G=_t*(et.layer-pt.layer);$+=N(pt,et)*G,dt+=G}if(!(dt>0))continue;let wt=($/dt-et.y0)*Y;et.y0+=wt,et.y1+=wt,z(et)}c===void 0&&V.sort(yi),_(V,C)}}function k(M,Y,C){for(let F=M.length,H=F-2;H>=0;--H){const V=M[H];for(const et of V){let $=0,dt=0;for(const{target:pt,value:_t}of et.sourceLinks){let G=_t*(pt.layer-et.layer);$+=U(et,pt)*G,dt+=G}if(!(dt>0))continue;let wt=($/dt-et.y0)*Y;et.y0+=wt,et.y1+=wt,z(et)}c===void 0&&V.sort(yi),_(V,C)}}function _(M,Y){const C=M.length>>1,F=M[C];R(M,F.y0-s,C-1,Y),E(M,F.y1+s,C+1,Y),R(M,r,M.length-1,Y),E(M,e,0,Y)}function E(M,Y,C,F){for(;C<M.length;++C){const H=M[C],V=(Y-H.y0)*F;V>1e-6&&(H.y0+=V,H.y1+=V),Y=H.y1+s}}function R(M,Y,C,F){for(;C>=0;--C){const H=M[C],V=(H.y1-Y)*F;V>1e-6&&(H.y0-=V,H.y1-=V),Y=H.y0-s}}function z({sourceLinks:M,targetLinks:Y}){if(u===void 0){for(const{source:{sourceLinks:C}}of Y)C.sort(Zc);for(const{target:{targetLinks:C}}of M)C.sort(Gc)}}function I(M){if(u===void 0)for(const{sourceLinks:Y,targetLinks:C}of M)Y.sort(Zc),C.sort(Gc)}function N(M,Y){let C=M.y0-(M.sourceLinks.length-1)*s/2;for(const{target:F,width:H}of M.sourceLinks){if(F===Y)break;C+=H+s}for(const{source:F,width:H}of Y.targetLinks){if(F===M)break;C-=H}return C}function U(M,Y){let C=Y.y0-(Y.targetLinks.length-1)*s/2;for(const{source:F,width:H}of Y.targetLinks){if(F===M)break;C+=H+s}for(const{target:F,width:H}of M.sourceLinks){if(F===Y)break;C-=H}return C}return v}var Fs=Math.PI,Hs=2*Fs,Vn=1e-6,Xx=Hs-Vn;function Ws(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function qc(){return new Ws}Ws.prototype=qc.prototype={constructor:Ws,moveTo:function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},quadraticCurveTo:function(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r)},bezierCurveTo:function(t,e,n,r,a,i){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+a)+","+(this._y1=+i)},arcTo:function(t,e,n,r,a){t=+t,e=+e,n=+n,r=+r,a=+a;var i=this._x1,s=this._y1,o=n-t,l=r-e,c=i-t,u=s-e,h=c*c+u*u;if(a<0)throw new Error("negative radius: "+a);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(h>Vn)if(!(Math.abs(u*o-l*c)>Vn)||!a)this._+="L"+(this._x1=t)+","+(this._y1=e);else{var f=n-i,g=r-s,v=o*o+l*l,b=f*f+g*g,d=Math.sqrt(v),x=Math.sqrt(h),S=a*Math.tan((Fs-Math.acos((v+h-b)/(2*d*x)))/2),w=S/x,y=S/d;Math.abs(w-1)>Vn&&(this._+="L"+(t+w*c)+","+(e+w*u)),this._+="A"+a+","+a+",0,0,"+ +(u*f>c*g)+","+(this._x1=t+y*o)+","+(this._y1=e+y*l)}},arc:function(t,e,n,r,a,i){t=+t,e=+e,n=+n,i=!!i;var s=n*Math.cos(r),o=n*Math.sin(r),l=t+s,c=e+o,u=1^i,h=i?r-a:a-r;if(n<0)throw new Error("negative radius: "+n);this._x1===null?this._+="M"+l+","+c:(Math.abs(this._x1-l)>Vn||Math.abs(this._y1-c)>Vn)&&(this._+="L"+l+","+c),n&&(h<0&&(h=h%Hs+Hs),h>Xx?this._+="A"+n+","+n+",0,1,"+u+","+(t-s)+","+(e-o)+"A"+n+","+n+",0,1,"+u+","+(this._x1=l)+","+(this._y1=c):h>Vn&&(this._+="A"+n+","+n+",0,"+ +(h>=Fs)+","+u+","+(this._x1=t+n*Math.cos(a))+","+(this._y1=e+n*Math.sin(a))))},rect:function(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};function tu(t){return function(){return t}}function Kx(t){return t[0]}function Gx(t){return t[1]}var Zx=Array.prototype.slice;function Jx(t){return t.source}function Qx(t){return t.target}function qx(t){var e=Jx,n=Qx,r=Kx,a=Gx,i=null;function s(){var o,l=Zx.call(arguments),c=e.apply(this,l),u=n.apply(this,l);if(i||(i=o=qc()),t(i,+r.apply(this,(l[0]=c,l)),+a.apply(this,l),+r.apply(this,(l[0]=u,l)),+a.apply(this,l)),o)return i=null,o+""||null}return s.source=function(o){return arguments.length?(e=o,s):e},s.target=function(o){return arguments.length?(n=o,s):n},s.x=function(o){return arguments.length?(r=typeof o=="function"?o:tu(+o),s):r},s.y=function(o){return arguments.length?(a=typeof o=="function"?o:tu(+o),s):a},s.context=function(o){return arguments.length?(i=o??null,s):i},s}function tm(t,e,n,r,a){t.moveTo(e,n),t.bezierCurveTo(e=(e+r)/2,n,e,a,r,a)}function eu(){return qx(tm)}function em(t){return[t.source.x1,t.y0]}function nm(t){return[t.target.x0,t.y1]}function nu(){return eu().source(em).target(nm)}function Os(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function rm(t){return t.length===1&&(t=am(t)),{left:function(e,n,r,a){for(r==null&&(r=0),a==null&&(a=e.length);r<a;){var i=r+a>>>1;t(e[i],n)<0?r=i+1:a=i}return r},right:function(e,n,r,a){for(r==null&&(r=0),a==null&&(a=e.length);r<a;){var i=r+a>>>1;t(e[i],n)>0?a=i:r=i+1}return r}}}function am(t){return function(e,n){return Os(t(e),n)}}rm(Os);function ru(t){return t===null?NaN:+t}function Bs(t,e){var n=t.length,r=-1,a,i;if(e==null){for(;++r<n;)if((a=t[r])!=null&&a>=a)for(i=a;++r<n;)(a=t[r])!=null&&a>i&&(i=a)}else for(;++r<n;)if((a=e(t[r],r,t))!=null&&a>=a)for(i=a;++r<n;)(a=e(t[r],r,t))!=null&&a>i&&(i=a);return i}function au(t,e){var n=t.length,r=n,a=-1,i,s=0;if(e==null)for(;++a<n;)isNaN(i=ru(t[a]))?--r:s+=i;else for(;++a<n;)isNaN(i=ru(e(t[a],a,t)))?--r:s+=i;if(r)return s/r}function Ys(t,e){var n=t.length,r=-1,a,i;if(e==null){for(;++r<n;)if((a=t[r])!=null&&a>=a)for(i=a;++r<n;)(a=t[r])!=null&&i>a&&(i=a)}else for(;++r<n;)if((a=e(t[r],r,t))!=null&&a>=a)for(i=a;++r<n;)(a=e(t[r],r,t))!=null&&i>a&&(i=a);return i}function Us(t,e){var n=t.length,r=-1,a,i=0;if(e==null)for(;++r<n;)(a=+t[r])&&(i+=a);else for(;++r<n;)(a=+e(t[r],r,t))&&(i+=a);return i}var qe="$";function xi(){}xi.prototype=ia.prototype={constructor:xi,has:function(t){return qe+t in this},get:function(t){return this[qe+t]},set:function(t,e){return this[qe+t]=e,this},remove:function(t){var e=qe+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===qe&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===qe&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===qe&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===qe&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===qe&&++t;return t},empty:function(){for(var t in this)if(t[0]===qe)return!1;return!0},each:function(t){for(var e in this)e[0]===qe&&t(this[e],e.slice(1),this)}};function ia(t,e){var n=new xi;if(t instanceof xi)t.each(function(o,l){n.set(l,o)});else if(Array.isArray(t)){var r=-1,a=t.length,i;if(e==null)for(;++r<a;)n.set(r,t[r]);else for(;++r<a;)n.set(e(i=t[r],r,t),i)}else if(t)for(var s in t)n.set(s,t[s]);return n}function im(){var t=[],e=[],n,r,a;function i(o,l,c,u){if(l>=t.length)return n!=null&&o.sort(n),r!=null?r(o):o;for(var h=-1,f=o.length,g=t[l++],v,b,d=ia(),x,S=c();++h<f;)(x=d.get(v=g(b=o[h])+""))?x.push(b):d.set(v,[b]);return d.each(function(w,y){u(S,y,i(w,l,c,u))}),S}function s(o,l){if(++l>t.length)return o;var c,u=e[l-1];return r!=null&&l>=t.length?c=o.entries():(c=[],o.each(function(h,f){c.push({key:f,values:s(h,l)})})),u!=null?c.sort(function(h,f){return u(h.key,f.key)}):c}return a={object:function(o){return i(o,0,sm,om)},map:function(o){return i(o,0,iu,su)},entries:function(o){return s(i(o,0,iu,su),0)},key:function(o){return t.push(o),a},sortKeys:function(o){return e[t.length-1]=o,a},sortValues:function(o){return n=o,a},rollup:function(o){return r=o,a}}}function sm(){return{}}function om(t,e,n){t[e]=n}function iu(){return ia()}function su(t,e,n){t.set(e,n)}function ou(){}var Xn=ia.prototype;ou.prototype={constructor:ou,has:Xn.has,add:function(t){return t+="",this[qe+t]=t,this},remove:Xn.remove,clear:Xn.clear,values:Xn.keys,size:Xn.size,empty:Xn.empty,each:Xn.each};var Vs,lu;function lm(){if(lu)return Vs;lu=1,Vs=t;function t(e){for(var n=e.length,r=new Array(n),a=new Array(n),i=new Array(n),s=new Array(n),o=new Array(n),l=new Array(n),c=0;c<n;++c)r[c]=-1,a[c]=0,i[c]=!1,s[c]=0,o[c]=-1,l[c]=[];var u=0,h=[],f=[];function g(x){var S=[x],w=[x];for(r[x]=a[x]=u,i[x]=!0,u+=1;w.length>0;){x=w[w.length-1];var y=e[x];if(s[x]<y.length){for(var T=s[x];T<y.length;++T){var p=y[T];if(r[p]<0){r[p]=a[p]=u,i[p]=!0,u+=1,S.push(p),w.push(p);break}else i[p]&&(a[x]=Math.min(a[x],a[p])|0);o[p]>=0&&l[x].push(o[p])}s[x]=T}else{if(a[x]===r[x]){for(var k=[],_=[],E=0,T=S.length-1;T>=0;--T){var R=S[T];if(i[R]=!1,k.push(R),_.push(l[R]),E+=l[R].length,o[R]=h.length,R===x){S.length=T;break}}h.push(k);for(var z=new Array(E),T=0;T<_.length;T++)for(var I=0;I<_[T].length;I++)z[--E]=_[T][I];f.push(z)}w.pop()}}}for(var c=0;c<n;++c)r[c]<0&&g(c);for(var v,c=0;c<f.length;c++){var b=f[c];if(b.length!==0){b.sort(function(S,w){return S-w}),v=[b[0]];for(var d=1;d<b.length;d++)b[d]!==b[d-1]&&v.push(b[d]);f[c]=v}}return{components:h,adjacencyList:f}}return Vs}var Xs,cu;function cm(){if(cu)return Xs;cu=1;var t=lm();return Xs=function(n,r){var a=[],i=[],s=[],o={},l=[],c;function u(y){s[y]=!1,o.hasOwnProperty(y)&&Object.keys(o[y]).forEach(function(T){delete o[y][T],s[T]&&u(T)})}function h(y){var T=!1;i.push(y),s[y]=!0;var p,k;for(p=0;p<l[y].length;p++)k=l[y][p],k===c?(f(c,i),T=!0):s[k]||(T=h(k));if(T)u(y);else for(p=0;p<l[y].length;p++){k=l[y][p];var _=o[k];_||(_={},o[k]=_),_[k]=!0}return i.pop(),T}function f(y,T){var p=[].concat(T).concat(y);r?r(p):a.push(p)}function g(y){for(var T=0;T<n.length;T++)(T<y||!n[T])&&(n[T]=[]),n[T]=n[T].filter(function(p){return p>=y})}function v(y){g(y);for(var T=n,p=t(T),k=p.components.filter(function(U){return U.length>1}),_=1/0,E,R=0;R<k.length;R++)for(var z=0;z<k[R].length;z++)k[R][z]<_&&(_=k[R][z],E=R);var I=k[E];if(!I)return!1;var N=n.map(function(U,M){return I.indexOf(M)===-1?[]:U.filter(function(Y){return I.indexOf(Y)!==-1})});return{leastVertex:_,adjList:N}}c=0;for(var b=n.length;c<b;){var d=v(c);if(c=d.leastVertex,l=d.adjList,l){for(var x=0;x<l.length;x++)for(var S=0;S<l[x].length;S++){var w=l[x][S];s[+w]=!1,o[w]={}}h(c),c=c+1}else c=b}if(!r)return a},Xs}var um=cm();const fm=zu(um);function hm(t,e){return t.sourceLinks.length?t.depth:e-1}function mi(t){return function(){return t}}var uu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function dm(t,e){return Ks(t.source,e.source)||t.index-e.index}function pm(t,e){return Ks(t.target,e.target)||t.index-e.index}function Ks(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:t.circularLinkType==="top"||e.circularLinkType==="bottom"?-1:1}function Gs(t){return t.value}function Zs(t){return(t.y0+t.y1)/2}function gm(t){return Zs(t.source)}function ym(t){return Zs(t.target)}function xm(t){return t.index}function mm(t){return t.nodes}function vm(t){return t.links}function fu(t,e){var n=t.get(e);if(!n)throw new Error("missing: "+e);return n}function Re(t,e){return e(t)}var $n=25,Ke=10,bm=.3;function wm(){var t=0,e=0,n=1,r=1,a=24,i,s=xm,o=hm,l=mm,c=vm,u=32,h=2,f,g=null;function v(){var p={nodes:l.apply(null,arguments),links:c.apply(null,arguments)};b(p),_m(p,s,g),d(p),w(p),hu(p,s),y(p,u,s),T(p);for(var k=4,_=0;_<k;_++)Js(p,r,s),Qs(p,r,s),Tm(p,e,r,s),Js(p,r,s),Qs(p,r,s);return $m(p,e,r),xu(p,h,r,s),p}v.nodeId=function(p){return arguments.length?(s=typeof p=="function"?p:mi(p),v):s},v.nodeAlign=function(p){return arguments.length?(o=typeof p=="function"?p:mi(p),v):o},v.nodeWidth=function(p){return arguments.length?(a=+p,v):a},v.nodePadding=function(p){return arguments.length?(i=+p,v):i},v.nodes=function(p){return arguments.length?(l=typeof p=="function"?p:mi(p),v):l},v.links=function(p){return arguments.length?(c=typeof p=="function"?p:mi(p),v):c},v.size=function(p){return arguments.length?(t=e=0,n=+p[0],r=+p[1],v):[n-t,r-e]},v.extent=function(p){return arguments.length?(t=+p[0][0],n=+p[1][0],e=+p[0][1],r=+p[1][1],v):[[t,e],[n,r]]},v.iterations=function(p){return arguments.length?(u=+p,v):u},v.circularLinkGap=function(p){return arguments.length?(h=+p,v):h},v.nodePaddingRatio=function(p){return arguments.length?(f=+p,v):f},v.sortNodes=function(p){return arguments.length?(g=p,v):g},v.update=function(p){return hu(p,s),T(p),p.links.forEach(function(k){k.circular&&(k.circularLinkType=k.y0+k.y1<r?"top":"bottom",k.source.circularLinkType=k.circularLinkType,k.target.circularLinkType=k.circularLinkType)}),Js(p,r,s,!1),Qs(p,r,s),xu(p,h,r,s),p};function b(p){p.nodes.forEach(function(_,E){_.index=E,_.sourceLinks=[],_.targetLinks=[]});var k=ia(p.nodes,s);return p.links.forEach(function(_,E){_.index=E;var R=_.source,z=_.target;(typeof R>"u"?"undefined":uu(R))!=="object"&&(R=_.source=fu(k,R)),(typeof z>"u"?"undefined":uu(z))!=="object"&&(z=_.target=fu(k,z)),R.sourceLinks.push(_),z.targetLinks.push(_)}),p}function d(p){p.nodes.forEach(function(k){k.partOfCycle=!1,k.value=Math.max(Us(k.sourceLinks,Gs),Us(k.targetLinks,Gs)),k.sourceLinks.forEach(function(_){_.circular&&(k.partOfCycle=!0,k.circularLinkType=_.circularLinkType)}),k.targetLinks.forEach(function(_){_.circular&&(k.partOfCycle=!0,k.circularLinkType=_.circularLinkType)})})}function x(p){var k=0,_=0,E=0,R=0,z=Bs(p.nodes,function(I){return I.column});return p.links.forEach(function(I){I.circular&&(I.circularLinkType=="top"?k=k+I.width:_=_+I.width,I.target.column==0&&(R=R+I.width),I.source.column==z&&(E=E+I.width))}),k=k>0?k+$n+Ke:k,_=_>0?_+$n+Ke:_,E=E>0?E+$n+Ke:E,R=R>0?R+$n+Ke:R,{top:k,bottom:_,left:R,right:E}}function S(p,k){var _=Bs(p.nodes,function(M){return M.column}),E=n-t,R=r-e,z=E+k.right+k.left,I=R+k.top+k.bottom,N=E/z,U=R/I;return t=t*N+k.left,n=k.right==0?n:n*N,e=e*U+k.top,r=r*U,p.nodes.forEach(function(M){M.x0=t+M.column*((n-t-a)/_),M.x1=M.x0+a}),U}function w(p){var k,_,E;for(k=p.nodes,_=[],E=0;k.length;++E,k=_,_=[])k.forEach(function(R){R.depth=E,R.sourceLinks.forEach(function(z){_.indexOf(z.target)<0&&!z.circular&&_.push(z.target)})});for(k=p.nodes,_=[],E=0;k.length;++E,k=_,_=[])k.forEach(function(R){R.height=E,R.targetLinks.forEach(function(z){_.indexOf(z.source)<0&&!z.circular&&_.push(z.source)})});p.nodes.forEach(function(R){R.column=Math.floor(o.call(null,R,E))})}function y(p,k,_){var E=im().key(function(M){return M.column}).sortKeys(Os).entries(p.nodes).map(function(M){return M.values});I(_),U();for(var R=1,z=k;z>0;--z)N(R*=.99,_),U();function I(M){if(f){var Y=1/0;E.forEach(function(V){var et=r*f/(V.length+1);Y=et<Y?et:Y}),i=Y}var C=Ys(E,function(V){return(r-e-(V.length-1)*i)/Us(V,Gs)});C=C*bm,p.links.forEach(function(V){V.width=V.value*C});var F=x(p),H=S(p,F);C=C*H,p.links.forEach(function(V){V.width=V.value*C}),E.forEach(function(V){var et=V.length;V.forEach(function($,dt){$.depth==E.length-1&&et==1||$.depth==0&&et==1?($.y0=r/2-$.value*C,$.y1=$.y0+$.value*C):$.partOfCycle?pu($,M)==0?($.y0=r/2+dt,$.y1=$.y0+$.value*C):$.circularLinkType=="top"?($.y0=e+dt,$.y1=$.y0+$.value*C):($.y0=r-$.value*C-dt,$.y1=$.y0+$.value*C):F.top==0||F.bottom==0?($.y0=(r-e)/et*dt,$.y1=$.y0+$.value*C):($.y0=(r-e)/2-et/2+dt,$.y1=$.y0+$.value*C)})})}function N(M,Y){var C=E.length;E.forEach(function(F){var H=F.length,V=F[0].depth;F.forEach(function(et){var $;if((et.sourceLinks.length||et.targetLinks.length)&&!(et.partOfCycle&&pu(et,Y)>0))if(V==0&&H==1)$=et.y1-et.y0,et.y0=r/2-$/2,et.y1=r/2+$/2;else if(V==C-1&&H==1)$=et.y1-et.y0,et.y0=r/2-$/2,et.y1=r/2+$/2;else{var dt=0,wt=au(et.sourceLinks,ym),pt=au(et.targetLinks,gm);wt&&pt?dt=(wt+pt)/2:dt=wt||pt;var _t=(dt-Zs(et))*M;et.y0+=_t,et.y1+=_t}})})}function U(){E.forEach(function(M){var Y,C,F=e,H=M.length,V;for(M.sort(Ks),V=0;V<H;++V)Y=M[V],C=F-Y.y0,C>0&&(Y.y0+=C,Y.y1+=C),F=Y.y1+i;if(C=F-i-r,C>0)for(F=Y.y0-=C,Y.y1-=C,V=H-2;V>=0;--V)Y=M[V],C=Y.y1+i-F,C>0&&(Y.y0-=C,Y.y1-=C),F=Y.y0})}}function T(p){p.nodes.forEach(function(k){k.sourceLinks.sort(pm),k.targetLinks.sort(dm)}),p.nodes.forEach(function(k){var _=k.y0,E=_,R=k.y1,z=R;k.sourceLinks.forEach(function(I){I.circular?(I.y0=R-I.width/2,R=R-I.width):(I.y0=_+I.width/2,_+=I.width)}),k.targetLinks.forEach(function(I){I.circular?(I.y1=z-I.width/2,z=z-I.width):(I.y1=E+I.width/2,E+=I.width)})})}return v}function _m(t,e,n){var r=0;if(n===null){for(var a=[],i=0;i<t.links.length;i++){var s=t.links[i],o=s.source.index,l=s.target.index;a[o]||(a[o]=[]),a[l]||(a[l]=[]),a[o].indexOf(l)===-1&&a[o].push(l)}var c=fm(a);c.sort(function(g,v){return g.length-v.length});var u={};for(i=0;i<c.length;i++){var h=c[i],f=h.slice(-2);u[f[0]]||(u[f[0]]={}),u[f[0]][f[1]]=!0}t.links.forEach(function(g){var v=g.target.index,b=g.source.index;v===b||u[b]&&u[b][v]?(g.circular=!0,g.circularLinkID=r,r=r+1):g.circular=!1})}else t.links.forEach(function(g){g.source[n]<g.target[n]?g.circular=!1:(g.circular=!0,g.circularLinkID=r,r=r+1)})}function hu(t,e){var n=0,r=0;t.links.forEach(function(a){a.circular&&(a.source.circularLinkType||a.target.circularLinkType?a.circularLinkType=a.source.circularLinkType?a.source.circularLinkType:a.target.circularLinkType:a.circularLinkType=n<r?"top":"bottom",a.circularLinkType=="top"?n=n+1:r=r+1,t.nodes.forEach(function(i){(Re(i,e)==Re(a.source,e)||Re(i,e)==Re(a.target,e))&&(i.circularLinkType=a.circularLinkType)}))}),t.links.forEach(function(a){a.circular&&(a.source.circularLinkType==a.target.circularLinkType&&(a.circularLinkType=a.source.circularLinkType),sa(a,e)&&(a.circularLinkType=a.source.circularLinkType))})}function du(t){var e=Math.abs(t.y1-t.y0),n=Math.abs(t.target.x0-t.source.x1);return Math.atan(n/e)}function km(t,e){return t.source.column<e.target.column?!1:!(t.target.column>e.source.column)}function pu(t,e){var n=0;t.sourceLinks.forEach(function(a){n=a.circular&&!sa(a,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(a){r=a.circular&&!sa(a,e)?r+1:r}),n+r}function gu(t){var e=t.source.sourceLinks,n=0;e.forEach(function(i){n=i.circular?n+1:n});var r=t.target.targetLinks,a=0;return r.forEach(function(i){a=i.circular?a+1:a}),!(n>1||a>1)}function yu(t,e,n){return t.sort(Sm),t.forEach(function(r,a){var i=0;if(sa(r,n)&&gu(r))r.circularPathData.verticalBuffer=i+r.width/2;else{var s=0;for(s;s<a;s++)if(km(t[a],t[s])){var o=t[s].circularPathData.verticalBuffer+t[s].width/2+e;i=o>i?o:i}r.circularPathData.verticalBuffer=i+r.width/2}}),t}function xu(t,e,n,r){var a=5,i=Ys(t.links,function(l){return l.source.y0});t.links.forEach(function(l){l.circular&&(l.circularPathData={})});var s=t.links.filter(function(l){return l.circularLinkType=="top"});yu(s,e,r);var o=t.links.filter(function(l){return l.circularLinkType=="bottom"});yu(o,e,r),t.links.forEach(function(l){if(l.circular){if(l.circularPathData.arcRadius=l.width+Ke,l.circularPathData.leftNodeBuffer=a,l.circularPathData.rightNodeBuffer=a,l.circularPathData.sourceWidth=l.source.x1-l.source.x0,l.circularPathData.sourceX=l.source.x0+l.circularPathData.sourceWidth,l.circularPathData.targetX=l.target.x0,l.circularPathData.sourceY=l.y0,l.circularPathData.targetY=l.y1,sa(l,r)&&gu(l))l.circularPathData.leftSmallArcRadius=Ke+l.width/2,l.circularPathData.leftLargeArcRadius=Ke+l.width/2,l.circularPathData.rightSmallArcRadius=Ke+l.width/2,l.circularPathData.rightLargeArcRadius=Ke+l.width/2,l.circularLinkType=="bottom"?(l.circularPathData.verticalFullExtent=l.source.y1+$n+l.circularPathData.verticalBuffer,l.circularPathData.verticalLeftInnerExtent=l.circularPathData.verticalFullExtent-l.circularPathData.leftLargeArcRadius,l.circularPathData.verticalRightInnerExtent=l.circularPathData.verticalFullExtent-l.circularPathData.rightLargeArcRadius):(l.circularPathData.verticalFullExtent=l.source.y0-$n-l.circularPathData.verticalBuffer,l.circularPathData.verticalLeftInnerExtent=l.circularPathData.verticalFullExtent+l.circularPathData.leftLargeArcRadius,l.circularPathData.verticalRightInnerExtent=l.circularPathData.verticalFullExtent+l.circularPathData.rightLargeArcRadius);else{var c=l.source.column,u=l.circularLinkType,h=t.links.filter(function(v){return v.source.column==c&&v.circularLinkType==u});l.circularLinkType=="bottom"?h.sort(vu):h.sort(mu);var f=0;h.forEach(function(v,b){v.circularLinkID==l.circularLinkID&&(l.circularPathData.leftSmallArcRadius=Ke+l.width/2+f,l.circularPathData.leftLargeArcRadius=Ke+l.width/2+b*e+f),f=f+v.width}),c=l.target.column,h=t.links.filter(function(v){return v.target.column==c&&v.circularLinkType==u}),l.circularLinkType=="bottom"?h.sort(Nm):h.sort(Mm),f=0,h.forEach(function(v,b){v.circularLinkID==l.circularLinkID&&(l.circularPathData.rightSmallArcRadius=Ke+l.width/2+f,l.circularPathData.rightLargeArcRadius=Ke+l.width/2+b*e+f),f=f+v.width}),l.circularLinkType=="bottom"?(l.circularPathData.verticalFullExtent=Math.max(n,l.source.y1,l.target.y1)+$n+l.circularPathData.verticalBuffer,l.circularPathData.verticalLeftInnerExtent=l.circularPathData.verticalFullExtent-l.circularPathData.leftLargeArcRadius,l.circularPathData.verticalRightInnerExtent=l.circularPathData.verticalFullExtent-l.circularPathData.rightLargeArcRadius):(l.circularPathData.verticalFullExtent=i-$n-l.circularPathData.verticalBuffer,l.circularPathData.verticalLeftInnerExtent=l.circularPathData.verticalFullExtent+l.circularPathData.leftLargeArcRadius,l.circularPathData.verticalRightInnerExtent=l.circularPathData.verticalFullExtent+l.circularPathData.rightLargeArcRadius)}l.circularPathData.leftInnerExtent=l.circularPathData.sourceX+l.circularPathData.leftNodeBuffer,l.circularPathData.rightInnerExtent=l.circularPathData.targetX-l.circularPathData.rightNodeBuffer,l.circularPathData.leftFullExtent=l.circularPathData.sourceX+l.circularPathData.leftLargeArcRadius+l.circularPathData.leftNodeBuffer,l.circularPathData.rightFullExtent=l.circularPathData.targetX-l.circularPathData.rightLargeArcRadius-l.circularPathData.rightNodeBuffer}if(l.circular)l.path=Am(l);else{var g=eu().source(function(v){var b=v.source.x0+(v.source.x1-v.source.x0),d=v.y0;return[b,d]}).target(function(v){var b=v.target.x0,d=v.y1;return[b,d]});l.path=g(l)}})}function Am(t){var e="";return t.circularLinkType=="top"?e="M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.leftSmallArcRadius)+" L"+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" L"+t.circularPathData.rightFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.rightSmallArcRadius)+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:e="M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.leftSmallArcRadius)+" L"+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" L"+t.circularPathData.rightFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.rightSmallArcRadius)+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY,e}function Sm(t,e){return vi(t)==vi(e)?t.circularLinkType=="bottom"?vu(t,e):mu(t,e):vi(e)-vi(t)}function mu(t,e){return t.y0-e.y0}function vu(t,e){return e.y0-t.y0}function Mm(t,e){return t.y1-e.y1}function Nm(t,e){return e.y1-t.y1}function vi(t){return t.target.column-t.source.column}function bu(t){return t.target.x0-t.source.x1}function wu(t,e){var n=du(t),r=bu(e)/Math.tan(n),a=bi(t)=="up"?t.y1+r:t.y1-r;return a}function _u(t,e){var n=du(t),r=bu(e)/Math.tan(n),a=bi(t)=="up"?t.y1-r:t.y1+r;return a}function Tm(t,e,n,r){t.links.forEach(function(a){if(!a.circular&&a.target.column-a.source.column>1){var i=a.source.column+1,s=a.target.column-1,o=1,l=s-i+1;for(o=1;i<=s;i++,o++)t.nodes.forEach(function(c){if(c.column==i){var u=o/(l+1),h=Math.pow(1-u,3),f=3*u*Math.pow(1-u,2),g=3*Math.pow(u,2)*(1-u),v=Math.pow(u,3),b=h*a.y0+f*a.y0+g*a.y1+v*a.y1,d=b-a.width/2,x=b+a.width/2,S;d>c.y0&&d<c.y1?(S=c.y1-d+10,S=c.circularLinkType=="bottom"?S:-S,c=br(c,S,e,n),t.nodes.forEach(function(w){Re(w,r)==Re(c,r)||w.column!=c.column||Dm(c,w)&&br(w,S,e,n)})):x>c.y0&&x<c.y1?(S=x-c.y0+10,c=br(c,S,e,n),t.nodes.forEach(function(w){Re(w,r)==Re(c,r)||w.column!=c.column||w.y0<c.y1&&w.y1>c.y1&&br(w,S,e,n)})):d<c.y0&&x>c.y1&&(S=x-c.y0+10,c=br(c,S,e,n),t.nodes.forEach(function(w){Re(w,r)==Re(c,r)||w.column!=c.column||w.y0<c.y1&&w.y1>c.y1&&br(w,S,e,n)}))}})}})}function Dm(t,e){return t.y0>e.y0&&t.y0<e.y1||t.y1>e.y0&&t.y1<e.y1?!0:t.y0<e.y0&&t.y1>e.y1}function br(t,e,n,r){return t.y0+e>=n&&t.y1+e<=r&&(t.y0=t.y0+e,t.y1=t.y1+e,t.targetLinks.forEach(function(a){a.y1=a.y1+e}),t.sourceLinks.forEach(function(a){a.y0=a.y0+e})),t}function Js(t,e,n,r){t.nodes.forEach(function(a){r&&a.y+(a.y1-a.y0)>e&&(a.y=a.y-(a.y+(a.y1-a.y0)-e));var i=t.links.filter(function(l){return Re(l.source,n)==Re(a,n)}),s=i.length;s>1&&i.sort(function(l,c){if(!l.circular&&!c.circular){if(l.target.column==c.target.column)return l.y1-c.y1;if(ku(l,c)){if(l.target.column>c.target.column){var u=_u(c,l);return l.y1-u}if(c.target.column>l.target.column){var h=_u(l,c);return h-c.y1}}else return l.y1-c.y1}if(l.circular&&!c.circular)return l.circularLinkType=="top"?-1:1;if(c.circular&&!l.circular)return c.circularLinkType=="top"?1:-1;if(l.circular&&c.circular)return l.circularLinkType===c.circularLinkType&&l.circularLinkType=="top"?l.target.column===c.target.column?l.target.y1-c.target.y1:c.target.column-l.target.column:l.circularLinkType===c.circularLinkType&&l.circularLinkType=="bottom"?l.target.column===c.target.column?c.target.y1-l.target.y1:l.target.column-c.target.column:l.circularLinkType=="top"?-1:1});var o=a.y0;i.forEach(function(l){l.y0=o+l.width/2,o=o+l.width}),i.forEach(function(l,c){if(l.circularLinkType=="bottom"){var u=c+1,h=0;for(u;u<s;u++)h=h+i[u].width;l.y0=a.y1-h-l.width/2}})})}function Qs(t,e,n){t.nodes.forEach(function(r){var a=t.links.filter(function(o){return Re(o.target,n)==Re(r,n)}),i=a.length;i>1&&a.sort(function(o,l){if(!o.circular&&!l.circular){if(o.source.column==l.source.column)return o.y0-l.y0;if(ku(o,l)){if(l.source.column<o.source.column){var c=wu(l,o);return o.y0-c}if(o.source.column<l.source.column){var u=wu(o,l);return u-l.y0}}else return o.y0-l.y0}if(o.circular&&!l.circular)return o.circularLinkType=="top"?-1:1;if(l.circular&&!o.circular)return l.circularLinkType=="top"?1:-1;if(o.circular&&l.circular)return o.circularLinkType===l.circularLinkType&&o.circularLinkType=="top"?o.source.column===l.source.column?o.source.y1-l.source.y1:o.source.column-l.source.column:o.circularLinkType===l.circularLinkType&&o.circularLinkType=="bottom"?o.source.column===l.source.column?o.source.y1-l.source.y1:l.source.column-o.source.column:o.circularLinkType=="top"?-1:1});var s=r.y0;a.forEach(function(o){o.y1=s+o.width/2,s=s+o.width}),a.forEach(function(o,l){if(o.circularLinkType=="bottom"){var c=l+1,u=0;for(c;c<i;c++)u=u+a[c].width;o.y1=r.y1-u-o.width/2}})})}function ku(t,e){return bi(t)==bi(e)}function bi(t){return t.y0-t.y1>0?"up":"down"}function sa(t,e){return Re(t.source,e)==Re(t.target,e)}function $m(t,e,n){var r=t.nodes,a=t.links,i=!1,s=!1;if(a.forEach(function(f){f.circularLinkType=="top"?i=!0:f.circularLinkType=="bottom"&&(s=!0)}),i==!1||s==!1){var o=Ys(r,function(f){return f.y0}),l=Bs(r,function(f){return f.y1}),c=l-o,u=n-e,h=u/c;r.forEach(function(f){var g=(f.y1-f.y0)*h;f.y0=(f.y0-o)*h,f.y1=f.y0+g}),a.forEach(function(f){f.y0=(f.y0-o)*h,f.y1=(f.y1-o)*h,f.width=f.width*h})}}function Au(t){const e=new Map;for(const{source:s,target:o}of t)e.has(s)||e.set(s,[]),e.has(o)||e.set(o,[]),e.get(s).push(o);const n=new Set,r=new Set,a=[];function i(s){n.add(s),r.add(s),a.push(s);const o=e.get(s)||[];for(const l of o)if(n.has(l)){if(r.has(l))return a.push(l),!0}else if(i(l))return!0;return r.delete(s),a.pop(),!1}for(const s of e.keys())if(!n.has(s)&&i(s)){const o=a[a.length-1],l=a.indexOf(o);return{hasCircularConnection:!0,cyclePath:a.slice(l)}}return{hasCircularConnection:!1}}const Su={sankeyEnergyLink:"_sankeyEnergyLink_10fud_285",sankeyLabel:"_sankeyLabel_10fud_323"};function Cm({data:t,tooltipFormat:e}){const[n,r]=bt.useState(null),[a,i]=bt.useState(!1),[s,o]=bt.useState(!1),l=bt.useRef(!0),c=bt.useRef(!0),u=bt.useRef("data"),[h,f]=Ne(),{width:g,height:v}=f,b=rn(n?n.nodes.map(k=>k.name):[]);function d(k){const _=new Map,E=[],R=[],z=I=>(_.has(I)||(_.set(I,E.length),E.push({name:I})),_.get(I));for(const{source:I,target:N,value:U}of k)R.push({source:z(I),target:z(N),value:U});return{nodes:E,links:R}}bt.useEffect(()=>{r(k=>{const _=d(t),E=k===null?[]:k.nodes.map(z=>z.name),R=_.nodes.map(z=>z.name);return l.current=R.every(z=>!E.includes(z)),k!==null&&(c.current=!1),u.current="data",_}),s&&o(!1),a&&i(!1)},[t]),bt.useEffect(()=>{g!==0&&v!==0&&(u.current="dimension")},[g,v]);const x=Au(t),S=bt.useDeferredValue(t),w=bt.useRef(void 0);bt.useEffect(()=>{if(S!==t){const k=Au(S);w.current=k.hasCircularConnection}},[t,S]);const y=g<=768,T=1e3,p=Se(k=>{if(!n)return;const _=g,E=v;if(_===0||E===0)return;const R={top:30,right:20,bottom:20,left:20},z=E-(R.top+R.bottom),I=_-(R.left+R.right),N=z,U=I,M=n.links.map(L=>({...L})),Y=n.nodes.map(L=>({...L}));M.forEach(function(L){const Z=n.nodes[L.source].name,ft=n.nodes[L.target].name,st=Z+" → "+ft;L.sourceName=Z,L.targetName=ft,L.id=st});const C=k.select("svg");C.node();const F=C.select(".plot-area").attr("transform","translate("+R.left+","+R.top+")"),H=hi(k).style("opacity",0),V=L=>{const Z=L.targetLinks?.reduce((st,it)=>st+it.value,0)??0,ft=L.sourceLinks?.reduce((st,it)=>st+it.value,0)??0;return{enteringValue:Z,exitingValue:ft}},et=wm(),$=Vx().nodeAlign(Ox).nodeSort(s?(L,Z)=>{const{enteringValue:ft,exitingValue:st}=V(L),{enteringValue:it,exitingValue:A}=V(Z);return Math.max(ft,st)-Math.max(it,A)}:null).linkSort(a?(L,Z)=>L.value-Z.value:null),dt=x.hasCircularConnection||w.current?et:$;dt.nodeWidth(U<=540?8:U>540&&U<=768?12:15).nodePadding(U<=540?5:8).extent([[0,0],[U,N]]);const wt=dt({nodes:Y.map(L=>Object.assign({},L)),links:M.map(L=>Object.assign({},L))}),{nodes:pt,links:_t}=wt;F.selectAll("linearGradient").remove();const G=F.selectAll("linearGradient").data(_t).join("linearGradient").attr("id",(L,Z)=>Z.toString()).attr("gradientUnits","userSpaceOnUse").attr("x1",L=>L.source.x0).attr("x2",L=>L.target.x0);G.append("stop").attr("offset","0%").attr("stop-color",L=>{const Z=b.current.findIndex(ft=>ft===L.sourceName);return de(Z,!1)}),G.append("stop").attr("offset","100%").attr("stop-color",L=>{const Z=b.current.findIndex(ft=>ft===L.targetName);return de(Z,!1)});const ot=L=>{const Z=L.source,ft=L.target,st=Math.abs(ft.depth-Z.depth);return U*1.5*st},O=L=>ot(L)+" "+ot(L),Q=L=>x.hasCircularConnection||!l.current||u.current==="sort node"||u.current==="sort link"||u.current!=="data"&&!c.current?0:L.target.depth*T;F.selectAll(".link").data(_t,L=>L.id).join(L=>L.append("path").attr("class",`link ${Su.sankeyEnergyLink}`).attr("d",nu()).style("stroke",function(Z){return`url(#${G.filter(it=>it.sourceName===Z.sourceName&&it.targetName===Z.targetName).node()?.id})`}).attr("stroke-dasharray",O).attr("stroke-dashoffset",ot).attr("stroke-width",Z=>Math.max(1,Z.width)).transition().duration(T).delay(function(Z){return x.hasCircularConnection?0:l.current?Q(Z):T}).attr("stroke-dashoffset",0).on("end",function(){qt(this).attr("stroke-dasharray","none")}),L=>(L.attr("stroke-width",Z=>Math.max(1,Z.width||0)).transition().duration(T).delay(Q).attr("d",nu()).attr("stroke-dashoffset",0).on("end",function(){qt(this).attr("stroke-dasharray","none")}),L),L=>l.current?L.remove():L.transition().duration(T/4).style("opacity",0).remove()).on("pointerenter",(L,Z)=>{F.selectAll("path.link").filter(ft=>ft.id!==Z.id).style("stroke","#1f2937").style("stroke-opacity",.05),F.selectAll("text.label").filter(ft=>{const st=ft;return st.name!==Z.sourceName&&st.name!==Z.targetName}).style("opacity",0),H.style("opacity",1),H.select("p.title").text(Z.id+Pe(Z.value,e)),H.select("p.top-label").style("display","none"),H.select("p.bottom-label").style("display","none"),Dn(L,H)}).on("pointermove",(L,Z)=>{Dn(L,H)}).on("pointerleave",(L,Z)=>{H.style("opacity",0),F.selectAll("path.link").style("stroke",function(ft){const st=ft;return`url(#${G.filter(j=>j.sourceName===st.sourceName&&j.targetName===st.targetName).node()?.id})`}).style("stroke-opacity",.5).style("fill","none").attr("class",`link ${J.sankeyEnergyLink}`),F.selectAll("text.label").style("opacity",1)});const X=L=>x.hasCircularConnection||!l.current||L.depth===0||u.current==="sort node"||u.current==="sort link"||u.current!=="data"&&!c.current?0:L.depth*T+T/4,D=L=>{const{enteringValue:Z,exitingValue:ft}=V(L);return{nodeState:L.sourceLinks?.length===0&&L.targetLinks?.length===0?"stray node":L.sourceLinks?.length===0?"leaf node":L.targetLinks?.length===0?"source node":Z>ft?"surplus":Z<ft?"minus":"balanced",enteringValue:Z,exitingValue:ft}},tt=L=>{const{nodeState:Z,enteringValue:ft,exitingValue:st}=D(L);return{enteringValue:ft,exitingValue:st,nodeState:Z,stateColor:Z==="surplus"?"#4ade80":Z==="minus"?"#f87171":"#e7e7e7"}};F.selectAll("rect.node").data(pt,(L=>L.name)).join(L=>L.append("rect").attr("class",`node ${J.baseNode}`).attr("x",Z=>Z.x0).attr("y",Z=>Z.y0).attr("height",Z=>l.current?Math.abs(Z.y1-Z.y0):0).attr("width",Z=>l.current?0:Z.x1-Z.x0).attr("opacity",0).attr("stroke-width",2.5).transition().duration(T).delay(X).attr("fill",Z=>{const ft=b.current.findIndex(st=>st===Z.name);return de(ft,!1)}).attr("opacity",1).attr("width",function(Z){return Z.x1-Z.x0}),void 0,L=>l.current?L.remove():L.transition().duration(T/4).style("opacity",0).remove()).on("pointerenter",(L,Z)=>{F.selectAll("path.link").filter(W=>{const K=W;return!(K.sourceName===Z.name||K.targetName===Z.name)}).style("stroke","#1f2937").style("stroke-opacity",.05);const ft=Z.sourceLinks?.map(W=>W.targetName)??[],it=[...Z.targetLinks?.map(W=>W.sourceName)??[],...ft,Z.name];F.selectAll("text.label").filter(W=>!it.includes(W.name)).style("opacity",.0625);const{enteringValue:A,exitingValue:j,nodeState:nt,stateColor:$t}=tt(Z);H.style("opacity",1),H.select("p.title").text(Z.name+" :"),H.select("p.top-label").style("display","block").text("in "+Pe(A,e)),H.select("p.bottom-label").style("display","block").text("out "+Pe(j,e)),H.select("p.small-text").style("display","block").text(`${nt}`).style("color",`${$t}`),Dn(L,H)}).on("pointermove",(L,Z)=>{Dn(L,H)}).on("pointerleave",(L,Z)=>{H.style("opacity",0),H.select("p.small-text").style("display","none"),F.selectAll("path.link").style("stroke",function(A){const j=A;return`url(#${G.filter(W=>W.sourceName===j.sourceName&&W.targetName===j.targetName).node()?.id})`}).style("stroke-opacity",.5).style("fill","none").attr("class",`link ${J.sankeyEnergyLink}`);const ft=Z.sourceLinks?.map(A=>A.targetName)??[],it=[...Z.targetLinks?.map(A=>A.sourceName)??[],...ft,Z.name];F.selectAll("text.label").filter(A=>!it.includes(A.name)).style("opacity",1)}).transition().duration(T).delay(X).attr("stroke-width",y?2:2.5).style("stroke",function(L){const{stateColor:Z,nodeState:ft}=tt(L);return ft==="surplus"||ft==="minus"?Z:"#52525b"}).attr("opacity",1).attr("x",L=>L.x0).attr("y",L=>L.y0).attr("height",L=>Math.abs(L.y1-L.y0)).attr("width",L=>L.x1-L.x0).attr("fill",L=>{const Z=b.current.findIndex(ft=>ft===L.name);return de(Z,!1)}),F.selectAll("text.label").data(pt,L=>L.name).join(L=>L.append("text").attr("class",`label ${Su.sankeyLabel}`).attr("x",Z=>Z.x0<U/2?Z.x1+6:Z.x0-6).attr("y",Z=>(Z.y1+Z.y0)/2).attr("dy","0.35em").attr("text-anchor",Z=>Z.x0<U/2?"start":"end").style("font-size",U<648?"12px":"16px").style("font-weight",U<648?"normal":"bold").style("stroke-width",U<648?"0px":"0.25px").style("stroke","#eff1f4").text(Z=>Z.name).attr("opacity",0),void 0,L=>L.remove()).style("font-size",U<648?"12px":"16px").style("font-weight",U<648?"normal":"bold").style("stroke-width",U<648?"0px":"0.25px").transition().duration(T).delay(X).attr("x",L=>L.x0<U/2?L.x1+6:L.x0-6).attr("y",L=>(L.y1+L.y0)/2).attr("dy","0.35em").attr("text-anchor",L=>L.x0<U/2?"start":"end").attr("opacity",1)},[n,a,s,g,v,e]);return m.jsx("div",{ref:h,style:{width:g,height:v,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:p,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${g} ${v}`,children:m.jsx("g",{className:"plot-area"})}),m.jsxs("div",{style:{position:"absolute",right:"12px",top:"6px",display:x.hasCircularConnection?"none":"flex",alignItems:"center",pointerEvents:x.hasCircularConnection?"none":"auto"},children:[m.jsxs("label",{className:J["controls-label"],children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:a,onChange:k=>{const _=k.target.checked;_&&(u.current="sort link"),i(_)}}),"Sort link"]}),m.jsxs("label",{className:J["controls-label"],children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:s,onChange:k=>{const _=k.target.checked;_&&(u.current="sort node"),o(_)}}),"Sort node"]})]}),m.jsx(Qe,{pCount:4})]})})}function Lm(t,e){return e.value-t.value}function jm(t){return t.children}function Pm(t){return t.value}function Em(t,e){return t.value-e.value}function wr(t,e){if(!t)return;const n=[t],r=[];let a;for(;a=n.pop();){r.push(a);const i=a.children;if(i&&i.length)for(let s=0;s<i.length;s++)n.push(i[s])}for(;a=r.pop();)e(a)}const Rm=t=>{let e=0;for(let a=0;a<t.length;a++)e+=t[a].length;const n=new Array(e);let r=t.length;for(;--r>=0;){const a=t[r];let i=a.length;for(;--i>=0;)n[--e]=a[i]}return n};function zm(t){return Rm(t.map(e=>(e.children||[]).map(n=>({source:e,target:n}))))}function Im(t,e,n){return function(...r){const a=n.apply(e,r);return a===e?t:a}}function Fm(t,e,...n){for(let r=0;r<n.length;r++){const a=n[r];t[a]=Im(t,e,e[a])}return t}function Hm(t,e){return Fm(t,e,"sort","children","value"),t.nodes=t,t.links=zm,t}function Wm(){let t=Lm,e=jm,n=Pm;function r(a){const i=[a],s=[];let o;for(a.depth=0;o=i.pop();){s.push(o);const l=e.call(r,o,o.depth);if(l&&l.length){for(let c=l.length-1;c>=0;c--){const u=l[c];i.push(u),u.parent=o,u.depth=(o.depth||0)+1}n&&(o.value=0),o.children=l}else n&&(o.value=+n.call(r,o,o.depth||0)||0),delete o.children}return wr(a,l=>{t&&l.children&&l.children.sort(t),n&&l.parent&&(l.parent.value+=l.value)}),s}return r.sort=function(a){return arguments.length?(t=a,r):t},r.children=function(a){return arguments.length?(e=a,r):e},r.value=function(a){return arguments.length?(n=a,r):n},r}function Om(t){delete t._pack_next,delete t._pack_prev}function Bm(t){t._pack_next=t._pack_prev=t}function Mu(t,e,n){let r=t.r+n.r,a=e.x-t.x,i=e.y-t.y;if(r&&(a||i)){let s=e.r+n.r,o=a*a+i*i;s*=s,r*=r;const l=.5+(r-s)/(2*o),c=Math.sqrt(Math.max(0,2*s*(r+o)-(r-=o)*r-s*s))/(2*o);n.x=t.x+l*a+c*i,n.y=t.y+l*i-c*a}else n.x=t.x+r,n.y=t.y}function Nu(t,e,n,r){const a=t.children;if(t.x=e+r*t.x,t.y=n+r*t.y,t.r*=r,a)for(let i=0;i<a.length;i++)Nu(a[i],t.x,t.y,r)}function qs(t,e){const n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Tu(t,e){const n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return .999*a*a>n*n+r*r}function Du(t,e){t._pack_next=e,e._pack_prev=t}function $u(t){const e=t.children;if(e&&e.length){let n=1/0,r=-1/0,a=1/0,i=-1/0;const s=h=>{n=Math.min(h.x-h.r,n),r=Math.max(h.x+h.r,r),a=Math.min(h.y-h.r,a),i=Math.max(h.y+h.r,i)};e.forEach(Bm);let o=e[0];if(o.x=-o.r,o.y=0,s(o),e.length>1){let h=e[1];if(h.x=h.r,h.y=0,s(h),e.length>2){let f=e[2];Mu(o,h,f),s(f),qs(o,f),o._pack_prev=f,qs(f,h),h=o._pack_next;for(let g=3;g<e.length;g++){Mu(o,h,f=e[g]);let v=0,b=1,d=1;for(let x=h._pack_next;x!==h;x=x._pack_next,b++)if(Tu(x,f)){v=1;break}if(v===1)for(let x=o._pack_prev;x!==e[g-1]._pack_prev&&!Tu(x,f);x=x._pack_prev,d++);v?(d>b||b===d&&h.r<o.r?Du(o,h=h._pack_next):Du(o=o._pack_prev,h),g--):(qs(o,f),h=f,s(f))}}}const l=(n+r)/2,c=(a+i)/2;let u=0;for(let h=0;h<e.length;h++){const f=e[h];f.x-=l,f.y-=c,u=Math.max(u,f.r+Math.sqrt(f.x*f.x+f.y*f.y))}t.r=u,e.forEach(Om)}}function Cu(){let t,e=Wm().sort(Em),n=0,r=[1,1];function a(i,s){const o=e(i,s),l=o[0],c=r[0],u=r[1],h=t==null?Math.sqrt:typeof t=="function"?t:()=>t;if(l.x=l.y=0,wr(l,f=>{f.r=+h(f.value)}),wr(l,$u),n){const f=n*(t?1:Math.max(2*l.r/c,2*l.r/u))/2;wr(l,g=>{g.r+=f}),wr(l,$u),wr(l,g=>{g.r-=f})}return Nu(l,c/2,u/2,t?1:1/Math.max(2*l.r/c,2*l.r/u)),o}return a.size=function(i){return arguments.length?(r=i,a):r},a.radius=function(i){return arguments.length?(t=i==null||typeof i=="function"?i:+i,a):t},a.padding=function(i){return arguments.length?(n=+i,a):n},Hm(a,e)}const Kn={node:"_node_1x526_1","node--leaf":"_node--leaf_1x526_19",circle_pack_label:"_circle_pack_label_1x526_27","node--root":"_node--root_1x526_73"};function Ym(t){const e=new Map;for(const n of t)e.set(n.name,n);return e}function Lu(t,e){const n=e.get(t.data.name);if(n&&(t.sortedX=n.x,t.sortedY=n.y,t.sortedR=n.r),t.children)for(const r of t.children)Lu(r,e)}function Um({data:t,tooltipFormat:e,colorScheme:n="monochrome"}){const[r,a]=bt.useState(null),[i,s]=bt.useState(!1),o=bt.useRef(!0),[l,c]=Ne(),{width:u,height:h}=c;bt.useEffect(()=>{a(x=>(x!==null&&(o.current=!1),t))},[t]);const f=rn(t.children?.map(x=>x.name)),g=ll($c,12),v=bt.useRef(hr().domain(f.current).range(g)),b=1e3,d=Se(x=>{if(!r)return;const S=u,w=h,y=12,T=1.5;if(S===0||w===0)return;const p=25,k=w-p*2,_=S-p*2,E=k,R=_,z={name:"branches",children:r.children},I=Math.min(R,E),N=fr(we(z)).sum(function(A){return A.value}).sort(function(A,j){return A.value-j.value}),U=Jl().size([I-p,I-p]).padding(2),Y=Cu().padding(2).size([I-p,I-p]).value(function(A){return A.value}).nodes(we(z));let C=N,F=1,H=1;const V=U(N),et=V.descendants(),$=[V.x,V.y,V.r*2+p],dt=Ym(Y);Lu(et[0],dt);const wt=x.select("#tooltip").style("opacity",0),pt=x.select("svg"),_t=pt.node(),G=pt.select(".plot-area"),ot=ye().domain([-1,2]).range(["#34d399","#6b21a8"]).interpolate(jd),O=A=>{let j=A;for(;j.depth>1;)j=j.parent;const nt=j.data.name,$t=v.current(nt),W=Ve($t);if(!W)return $t;const K=A.depth,Ct=.5;return K===1?W.formatHex():W.darker(K*Ct).formatHex()},Q=A=>n==="monochrome"?A.children?ot(A.depth):"#f0fdfa":O(A);function X(A){const j=I/$[2];return(i?A.sortedR??0:A.r)*j}function D(A){const j=I/$[2];return((i?A.sortedX??0:A.x)-$[0])*j}function tt(A){const j=I/$[2];return((i?A.sortedY??0:A.y)-$[1])*j}const L=G.selectAll("circle").data(et,A=>A.data.name).join(A=>A.append("circle").attr("class",function(j){return j.parent?j.children?Kn.node:`${Kn.node} ${Kn["node--leaf"]}`:`${Kn.node} ${Kn["node--root"]}`}).style("fill",Q).style("cursor","pointer").transition().duration(b).attr("r",X).attr("cx",D).attr("cy",tt).style("stroke","#737373").style("stroke-width",T*H).style("fill",Q),A=>A.transition().duration(b).attr("cx",D).attr("cy",tt).attr("r",X).style("stroke",function(j){return"#737373"}).style("stroke-width",T*H).style("fill",Q),A=>A.transition().duration(b).style("opacity",0).remove()).on("mouseover",function(A,j){C.parent===j?ft.filter(function(W){return W.parent===C||this.style.display==="inline"}).style("font-size",y*H).style("fill-opacity",function(W){return W.parent===C?1:0}).style("display",function(W){return W.parent===C?"inline":"none"}):j===C?ft.filter(function(W){return W.parent===C||this.style.display==="inline"}).style("font-size",y*H).style("fill-opacity",function(W){return W.parent===C?1:0}).style("display",function(W){return W.parent===C?"inline":"none"}):(ft.filter(function(W){if(i){const K=j;return W.name!==K.name}return W.data.name!=j.data.name}).style("fill-opacity",0).style("display","none"),ft.filter(function(W){if(i){const K=j;return W.name!==K.name}return W.data.name===j.data.name}).style("fill-opacity",1).style("display","inline")),j!=N&&qt(this).style("stroke-width",T*H*2.5).style("stroke","#e4e4e7");const nt=j.data.name==="branches"?"Total":j.data.name;wt.select("p.name").text(nt);const $t=j.value??0;wt.select("p.value").text(Pe($t,e).toLocaleString()),wt.transition().duration(250).style("opacity",1),le(wt,{e:A,svg:_t})}).on("mousemove",(A,j)=>{le(wt,{e:A,svg:_t})}).on("mouseout",function(A,j){ft.filter(function(nt){return nt.parent===C||this.style.display==="inline"}).style("fill-opacity",function(nt){return nt.parent===C?1:0}).style("display",function(nt){return nt.parent===C?"inline":"none"}),qt(this).style("stroke-width",T*H).style("stroke",function(nt){return"#737373"}),wt.transition().duration(250).style("opacity",0)}).on("click",function(A,j){if(j===N){it();return}C!=j?st(j):it(),L.style("stroke-width",T*H),A.stopPropagation()});function Z(A){const j=I/$[2],nt=i?A.sortedX??0:A.x,$t=i?A.sortedY??0:A.y;return"translate("+(nt-$[0])*j+","+($t-$[1])*j+")"}const ft=G.selectAll("text").data(et,A=>A.data.name).join(A=>A.append("text").attr("class",Kn.circle_pack_label).text(j=>j.data.name).style("font-size",y).style("text-anchor","middle").style("fill-opacity",0).style("stroke-opacity",0).style("display","none").style("pointer-events","none").style("text-shadow","0 1px 0 lightblue, 1px 0 0 lightblue, -1px 0 0 lightblue, 0 -1px 0 lightblue").transition().duration(b).attr("transform",Z).style("fill-opacity",function(j){return j.parent===N?1:0}).style("display",function(j){return j.parent===N?"inline":"none"}),A=>A.attr("class",Kn.circle_pack_label).transition().duration(b).attr("transform",Z).style("fill-opacity",function(j){return j.parent===N?1:0}).style("display",function(j){return j.parent===N?"inline":"none"}),A=>A.transition().duration(b).style("opacity",0).remove());ft.raise();function st(A){C=A;const j=I/2-p,nt=S/2,$t=w/2,W=I/$[2],K=A.r*W;H=K/j,F=j/K;const Rt=((i?A.sortedX??0:A.x)-$[0])*W,q=nt-Rt*F,ut=((i?A.sortedY??0:A.y)-$[0])*W,vt=$t-ut*F;G.transition().duration(1e3).attr("transform","translate("+q+","+vt+")scale("+F+")"),ft.style("font-size",y*H+"px").filter(function(At){return At.parent===C||this.style.display==="inline"}).style("fill-opacity",function(At){return At.parent===C?1:0}).style("display",function(At){return At.parent===C?"inline":"none"})}function it(){G.transition().duration(b).attr("transform","translate("+S/2+", "+w/2+")scale(1)"),C=N,F=1,H=1,ft.style("font-size",y*H+"px").filter(function(A){return A.parent===C||this.style.display==="inline"}).style("fill-opacity",function(A){return A.parent===C?1:0}).style("display",function(A){return A.parent===C?"inline":"none"})}it()},[r,n,u,h,i]);return m.jsx("div",{ref:l,style:{width:u,height:h,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:d,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${u} ${h}`,children:m.jsx("g",{className:"plot-area"})}),m.jsxs("label",{className:J["controls-label"],style:{position:"absolute",right:"12px",top:"6px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:i,onChange:x=>s(x.target.checked)}),"Sort"]}),m.jsxs(Qe,{children:[m.jsx("p",{className:"name",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat"},children:"Tooltip"}),m.jsx("p",{className:"value",style:{fontWeight:"400px",margin:"3px",fontSize:"13px",color:"wheat",textAlign:"right"},children:"Tooltip"})]})]})})}const Vm=({size:t=24,color:e="#0099ff",...n})=>m.jsx("svg",{viewBox:"0 0 64 64",width:t,height:t,xmlns:"http://www.w3.org/2000/svg",...n,children:m.jsxs("g",{fill:e,children:[m.jsx("path",{d:`M62.242,47.758l0.014-0.014c-5.847-4.753-12.84-8.137-20.491-9.722C44.374,35.479,46,31.932,46,28\r
|
|
23
|
+
x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})}),m.jsx(pi,{totalLabel:n==="percentage"?"":"of total"})]})]})})}function Xc(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let a of t)(a=e(a,++r,t))!=null&&(n<a||n===void 0&&a>=a)&&(n=a)}return n}function Kc(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let a of t)(a=e(a,++r,t))!=null&&(n>a||n===void 0&&a>=a)&&(n=a)}return n}function zs(t,e){let n=0;if(e===void 0)for(let r of t)(r=+r)&&(n+=r);else{let r=-1;for(let a of t)(a=+e(a,++r,t))&&(n+=a)}return n}function Hx(t){return t.target.depth}function Wx(t,e){return t.sourceLinks.length?t.depth:e-1}function Ox(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Kc(t.sourceLinks,Hx)-1:0}function gi(t){return function(){return t}}function Gc(t,e){return yi(t.source,e.source)||t.index-e.index}function Zc(t,e){return yi(t.target,e.target)||t.index-e.index}function yi(t,e){return t.y0-e.y0}function Is(t){return t.value}function Bx(t){return t.index}function Yx(t){return t.nodes}function Ux(t){return t.links}function Jc(t,e){const n=t.get(e);if(!n)throw new Error("missing: "+e);return n}function Qc({nodes:t}){for(const e of t){let n=e.y0,r=n;for(const a of e.sourceLinks)a.y0=n+a.width/2,n+=a.width;for(const a of e.targetLinks)a.y1=r+a.width/2,r+=a.width}}function Vx(){let t=0,e=0,n=1,r=1,a=24,i=8,s,o=Bx,l=Wx,c,u,h=Yx,f=Ux,g=6;function v(){const M={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return b(M),d(M),x(M),S(M),T(M),Qc(M),M}v.update=function(M){return Qc(M),M},v.nodeId=function(M){return arguments.length?(o=typeof M=="function"?M:gi(M),v):o},v.nodeAlign=function(M){return arguments.length?(l=typeof M=="function"?M:gi(M),v):l},v.nodeSort=function(M){return arguments.length?(c=M,v):c},v.nodeWidth=function(M){return arguments.length?(a=+M,v):a},v.nodePadding=function(M){return arguments.length?(i=s=+M,v):i},v.nodes=function(M){return arguments.length?(h=typeof M=="function"?M:gi(M),v):h},v.links=function(M){return arguments.length?(f=typeof M=="function"?M:gi(M),v):f},v.linkSort=function(M){return arguments.length?(u=M,v):u},v.size=function(M){return arguments.length?(t=e=0,n=+M[0],r=+M[1],v):[n-t,r-e]},v.extent=function(M){return arguments.length?(t=+M[0][0],n=+M[1][0],e=+M[0][1],r=+M[1][1],v):[[t,e],[n,r]]},v.iterations=function(M){return arguments.length?(g=+M,v):g};function b({nodes:M,links:Y}){for(const[F,H]of M.entries())H.index=F,H.sourceLinks=[],H.targetLinks=[];const C=new Map(M.map((F,H)=>[o(F,H,M),F]));for(const[F,H]of Y.entries()){H.index=F;let{source:V,target:et}=H;typeof V!="object"&&(V=H.source=Jc(C,V)),typeof et!="object"&&(et=H.target=Jc(C,et)),V.sourceLinks.push(H),et.targetLinks.push(H)}if(u!=null)for(const{sourceLinks:F,targetLinks:H}of M)F.sort(u),H.sort(u)}function d({nodes:M}){for(const Y of M)Y.value=Y.fixedValue===void 0?Math.max(zs(Y.sourceLinks,Is),zs(Y.targetLinks,Is)):Y.fixedValue}function x({nodes:M}){const Y=M.length;let C=new Set(M),F=new Set,H=0;for(;C.size;){for(const V of C){V.depth=H;for(const{target:et}of V.sourceLinks)F.add(et)}if(++H>Y)throw new Error("circular link");C=F,F=new Set}}function S({nodes:M}){const Y=M.length;let C=new Set(M),F=new Set,H=0;for(;C.size;){for(const V of C){V.height=H;for(const{source:et}of V.targetLinks)F.add(et)}if(++H>Y)throw new Error("circular link");C=F,F=new Set}}function w({nodes:M}){const Y=Xc(M,H=>H.depth)+1,C=(n-t-a)/(Y-1),F=new Array(Y);for(const H of M){const V=Math.max(0,Math.min(Y-1,Math.floor(l.call(null,H,Y))));H.layer=V,H.x0=t+V*C,H.x1=H.x0+a,F[V]?F[V].push(H):F[V]=[H]}if(c)for(const H of F)H.sort(c);return F}function y(M){const Y=Kc(M,C=>(r-e-(C.length-1)*s)/zs(C,Is));for(const C of M){let F=e;for(const H of C){H.y0=F,H.y1=F+H.value*Y,F=H.y1+s;for(const V of H.sourceLinks)V.width=V.value*Y}F=(r-F+s)/(C.length+1);for(let H=0;H<C.length;++H){const V=C[H];V.y0+=F*(H+1),V.y1+=F*(H+1)}I(C)}}function T(M){const Y=w(M);s=Math.min(i,(r-e)/(Xc(Y,C=>C.length)-1)),y(Y);for(let C=0;C<g;++C){const F=Math.pow(.99,C),H=Math.max(1-F,(C+1)/g);k(Y,F,H),p(Y,F,H)}}function p(M,Y,C){for(let F=1,H=M.length;F<H;++F){const V=M[F];for(const et of V){let $=0,dt=0;for(const{source:pt,value:_t}of et.targetLinks){let G=_t*(et.layer-pt.layer);$+=N(pt,et)*G,dt+=G}if(!(dt>0))continue;let wt=($/dt-et.y0)*Y;et.y0+=wt,et.y1+=wt,z(et)}c===void 0&&V.sort(yi),_(V,C)}}function k(M,Y,C){for(let F=M.length,H=F-2;H>=0;--H){const V=M[H];for(const et of V){let $=0,dt=0;for(const{target:pt,value:_t}of et.sourceLinks){let G=_t*(pt.layer-et.layer);$+=U(et,pt)*G,dt+=G}if(!(dt>0))continue;let wt=($/dt-et.y0)*Y;et.y0+=wt,et.y1+=wt,z(et)}c===void 0&&V.sort(yi),_(V,C)}}function _(M,Y){const C=M.length>>1,F=M[C];R(M,F.y0-s,C-1,Y),E(M,F.y1+s,C+1,Y),R(M,r,M.length-1,Y),E(M,e,0,Y)}function E(M,Y,C,F){for(;C<M.length;++C){const H=M[C],V=(Y-H.y0)*F;V>1e-6&&(H.y0+=V,H.y1+=V),Y=H.y1+s}}function R(M,Y,C,F){for(;C>=0;--C){const H=M[C],V=(H.y1-Y)*F;V>1e-6&&(H.y0-=V,H.y1-=V),Y=H.y0-s}}function z({sourceLinks:M,targetLinks:Y}){if(u===void 0){for(const{source:{sourceLinks:C}}of Y)C.sort(Zc);for(const{target:{targetLinks:C}}of M)C.sort(Gc)}}function I(M){if(u===void 0)for(const{sourceLinks:Y,targetLinks:C}of M)Y.sort(Zc),C.sort(Gc)}function N(M,Y){let C=M.y0-(M.sourceLinks.length-1)*s/2;for(const{target:F,width:H}of M.sourceLinks){if(F===Y)break;C+=H+s}for(const{source:F,width:H}of Y.targetLinks){if(F===M)break;C-=H}return C}function U(M,Y){let C=Y.y0-(Y.targetLinks.length-1)*s/2;for(const{source:F,width:H}of Y.targetLinks){if(F===M)break;C+=H+s}for(const{target:F,width:H}of M.sourceLinks){if(F===Y)break;C-=H}return C}return v}var Fs=Math.PI,Hs=2*Fs,Vn=1e-6,Xx=Hs-Vn;function Ws(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function qc(){return new Ws}Ws.prototype=qc.prototype={constructor:Ws,moveTo:function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},quadraticCurveTo:function(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r)},bezierCurveTo:function(t,e,n,r,a,i){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+a)+","+(this._y1=+i)},arcTo:function(t,e,n,r,a){t=+t,e=+e,n=+n,r=+r,a=+a;var i=this._x1,s=this._y1,o=n-t,l=r-e,c=i-t,u=s-e,h=c*c+u*u;if(a<0)throw new Error("negative radius: "+a);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(h>Vn)if(!(Math.abs(u*o-l*c)>Vn)||!a)this._+="L"+(this._x1=t)+","+(this._y1=e);else{var f=n-i,g=r-s,v=o*o+l*l,b=f*f+g*g,d=Math.sqrt(v),x=Math.sqrt(h),S=a*Math.tan((Fs-Math.acos((v+h-b)/(2*d*x)))/2),w=S/x,y=S/d;Math.abs(w-1)>Vn&&(this._+="L"+(t+w*c)+","+(e+w*u)),this._+="A"+a+","+a+",0,0,"+ +(u*f>c*g)+","+(this._x1=t+y*o)+","+(this._y1=e+y*l)}},arc:function(t,e,n,r,a,i){t=+t,e=+e,n=+n,i=!!i;var s=n*Math.cos(r),o=n*Math.sin(r),l=t+s,c=e+o,u=1^i,h=i?r-a:a-r;if(n<0)throw new Error("negative radius: "+n);this._x1===null?this._+="M"+l+","+c:(Math.abs(this._x1-l)>Vn||Math.abs(this._y1-c)>Vn)&&(this._+="L"+l+","+c),n&&(h<0&&(h=h%Hs+Hs),h>Xx?this._+="A"+n+","+n+",0,1,"+u+","+(t-s)+","+(e-o)+"A"+n+","+n+",0,1,"+u+","+(this._x1=l)+","+(this._y1=c):h>Vn&&(this._+="A"+n+","+n+",0,"+ +(h>=Fs)+","+u+","+(this._x1=t+n*Math.cos(a))+","+(this._y1=e+n*Math.sin(a))))},rect:function(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};function tu(t){return function(){return t}}function Kx(t){return t[0]}function Gx(t){return t[1]}var Zx=Array.prototype.slice;function Jx(t){return t.source}function Qx(t){return t.target}function qx(t){var e=Jx,n=Qx,r=Kx,a=Gx,i=null;function s(){var o,l=Zx.call(arguments),c=e.apply(this,l),u=n.apply(this,l);if(i||(i=o=qc()),t(i,+r.apply(this,(l[0]=c,l)),+a.apply(this,l),+r.apply(this,(l[0]=u,l)),+a.apply(this,l)),o)return i=null,o+""||null}return s.source=function(o){return arguments.length?(e=o,s):e},s.target=function(o){return arguments.length?(n=o,s):n},s.x=function(o){return arguments.length?(r=typeof o=="function"?o:tu(+o),s):r},s.y=function(o){return arguments.length?(a=typeof o=="function"?o:tu(+o),s):a},s.context=function(o){return arguments.length?(i=o??null,s):i},s}function tm(t,e,n,r,a){t.moveTo(e,n),t.bezierCurveTo(e=(e+r)/2,n,e,a,r,a)}function eu(){return qx(tm)}function em(t){return[t.source.x1,t.y0]}function nm(t){return[t.target.x0,t.y1]}function nu(){return eu().source(em).target(nm)}function Os(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function rm(t){return t.length===1&&(t=am(t)),{left:function(e,n,r,a){for(r==null&&(r=0),a==null&&(a=e.length);r<a;){var i=r+a>>>1;t(e[i],n)<0?r=i+1:a=i}return r},right:function(e,n,r,a){for(r==null&&(r=0),a==null&&(a=e.length);r<a;){var i=r+a>>>1;t(e[i],n)>0?a=i:r=i+1}return r}}}function am(t){return function(e,n){return Os(t(e),n)}}rm(Os);function ru(t){return t===null?NaN:+t}function Bs(t,e){var n=t.length,r=-1,a,i;if(e==null){for(;++r<n;)if((a=t[r])!=null&&a>=a)for(i=a;++r<n;)(a=t[r])!=null&&a>i&&(i=a)}else for(;++r<n;)if((a=e(t[r],r,t))!=null&&a>=a)for(i=a;++r<n;)(a=e(t[r],r,t))!=null&&a>i&&(i=a);return i}function au(t,e){var n=t.length,r=n,a=-1,i,s=0;if(e==null)for(;++a<n;)isNaN(i=ru(t[a]))?--r:s+=i;else for(;++a<n;)isNaN(i=ru(e(t[a],a,t)))?--r:s+=i;if(r)return s/r}function Ys(t,e){var n=t.length,r=-1,a,i;if(e==null){for(;++r<n;)if((a=t[r])!=null&&a>=a)for(i=a;++r<n;)(a=t[r])!=null&&i>a&&(i=a)}else for(;++r<n;)if((a=e(t[r],r,t))!=null&&a>=a)for(i=a;++r<n;)(a=e(t[r],r,t))!=null&&i>a&&(i=a);return i}function Us(t,e){var n=t.length,r=-1,a,i=0;if(e==null)for(;++r<n;)(a=+t[r])&&(i+=a);else for(;++r<n;)(a=+e(t[r],r,t))&&(i+=a);return i}var qe="$";function xi(){}xi.prototype=ia.prototype={constructor:xi,has:function(t){return qe+t in this},get:function(t){return this[qe+t]},set:function(t,e){return this[qe+t]=e,this},remove:function(t){var e=qe+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===qe&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===qe&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===qe&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===qe&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===qe&&++t;return t},empty:function(){for(var t in this)if(t[0]===qe)return!1;return!0},each:function(t){for(var e in this)e[0]===qe&&t(this[e],e.slice(1),this)}};function ia(t,e){var n=new xi;if(t instanceof xi)t.each(function(o,l){n.set(l,o)});else if(Array.isArray(t)){var r=-1,a=t.length,i;if(e==null)for(;++r<a;)n.set(r,t[r]);else for(;++r<a;)n.set(e(i=t[r],r,t),i)}else if(t)for(var s in t)n.set(s,t[s]);return n}function im(){var t=[],e=[],n,r,a;function i(o,l,c,u){if(l>=t.length)return n!=null&&o.sort(n),r!=null?r(o):o;for(var h=-1,f=o.length,g=t[l++],v,b,d=ia(),x,S=c();++h<f;)(x=d.get(v=g(b=o[h])+""))?x.push(b):d.set(v,[b]);return d.each(function(w,y){u(S,y,i(w,l,c,u))}),S}function s(o,l){if(++l>t.length)return o;var c,u=e[l-1];return r!=null&&l>=t.length?c=o.entries():(c=[],o.each(function(h,f){c.push({key:f,values:s(h,l)})})),u!=null?c.sort(function(h,f){return u(h.key,f.key)}):c}return a={object:function(o){return i(o,0,sm,om)},map:function(o){return i(o,0,iu,su)},entries:function(o){return s(i(o,0,iu,su),0)},key:function(o){return t.push(o),a},sortKeys:function(o){return e[t.length-1]=o,a},sortValues:function(o){return n=o,a},rollup:function(o){return r=o,a}}}function sm(){return{}}function om(t,e,n){t[e]=n}function iu(){return ia()}function su(t,e,n){t.set(e,n)}function ou(){}var Xn=ia.prototype;ou.prototype={constructor:ou,has:Xn.has,add:function(t){return t+="",this[qe+t]=t,this},remove:Xn.remove,clear:Xn.clear,values:Xn.keys,size:Xn.size,empty:Xn.empty,each:Xn.each};var Vs,lu;function lm(){if(lu)return Vs;lu=1,Vs=t;function t(e){for(var n=e.length,r=new Array(n),a=new Array(n),i=new Array(n),s=new Array(n),o=new Array(n),l=new Array(n),c=0;c<n;++c)r[c]=-1,a[c]=0,i[c]=!1,s[c]=0,o[c]=-1,l[c]=[];var u=0,h=[],f=[];function g(x){var S=[x],w=[x];for(r[x]=a[x]=u,i[x]=!0,u+=1;w.length>0;){x=w[w.length-1];var y=e[x];if(s[x]<y.length){for(var T=s[x];T<y.length;++T){var p=y[T];if(r[p]<0){r[p]=a[p]=u,i[p]=!0,u+=1,S.push(p),w.push(p);break}else i[p]&&(a[x]=Math.min(a[x],a[p])|0);o[p]>=0&&l[x].push(o[p])}s[x]=T}else{if(a[x]===r[x]){for(var k=[],_=[],E=0,T=S.length-1;T>=0;--T){var R=S[T];if(i[R]=!1,k.push(R),_.push(l[R]),E+=l[R].length,o[R]=h.length,R===x){S.length=T;break}}h.push(k);for(var z=new Array(E),T=0;T<_.length;T++)for(var I=0;I<_[T].length;I++)z[--E]=_[T][I];f.push(z)}w.pop()}}}for(var c=0;c<n;++c)r[c]<0&&g(c);for(var v,c=0;c<f.length;c++){var b=f[c];if(b.length!==0){b.sort(function(S,w){return S-w}),v=[b[0]];for(var d=1;d<b.length;d++)b[d]!==b[d-1]&&v.push(b[d]);f[c]=v}}return{components:h,adjacencyList:f}}return Vs}var Xs,cu;function cm(){if(cu)return Xs;cu=1;var t=lm();return Xs=function(n,r){var a=[],i=[],s=[],o={},l=[],c;function u(y){s[y]=!1,o.hasOwnProperty(y)&&Object.keys(o[y]).forEach(function(T){delete o[y][T],s[T]&&u(T)})}function h(y){var T=!1;i.push(y),s[y]=!0;var p,k;for(p=0;p<l[y].length;p++)k=l[y][p],k===c?(f(c,i),T=!0):s[k]||(T=h(k));if(T)u(y);else for(p=0;p<l[y].length;p++){k=l[y][p];var _=o[k];_||(_={},o[k]=_),_[k]=!0}return i.pop(),T}function f(y,T){var p=[].concat(T).concat(y);r?r(p):a.push(p)}function g(y){for(var T=0;T<n.length;T++)(T<y||!n[T])&&(n[T]=[]),n[T]=n[T].filter(function(p){return p>=y})}function v(y){g(y);for(var T=n,p=t(T),k=p.components.filter(function(U){return U.length>1}),_=1/0,E,R=0;R<k.length;R++)for(var z=0;z<k[R].length;z++)k[R][z]<_&&(_=k[R][z],E=R);var I=k[E];if(!I)return!1;var N=n.map(function(U,M){return I.indexOf(M)===-1?[]:U.filter(function(Y){return I.indexOf(Y)!==-1})});return{leastVertex:_,adjList:N}}c=0;for(var b=n.length;c<b;){var d=v(c);if(c=d.leastVertex,l=d.adjList,l){for(var x=0;x<l.length;x++)for(var S=0;S<l[x].length;S++){var w=l[x][S];s[+w]=!1,o[w]={}}h(c),c=c+1}else c=b}if(!r)return a},Xs}var um=cm();const fm=zu(um);function hm(t,e){return t.sourceLinks.length?t.depth:e-1}function mi(t){return function(){return t}}var uu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function dm(t,e){return Ks(t.source,e.source)||t.index-e.index}function pm(t,e){return Ks(t.target,e.target)||t.index-e.index}function Ks(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:t.circularLinkType==="top"||e.circularLinkType==="bottom"?-1:1}function Gs(t){return t.value}function Zs(t){return(t.y0+t.y1)/2}function gm(t){return Zs(t.source)}function ym(t){return Zs(t.target)}function xm(t){return t.index}function mm(t){return t.nodes}function vm(t){return t.links}function fu(t,e){var n=t.get(e);if(!n)throw new Error("missing: "+e);return n}function Re(t,e){return e(t)}var $n=25,Ke=10,bm=.3;function wm(){var t=0,e=0,n=1,r=1,a=24,i,s=xm,o=hm,l=mm,c=vm,u=32,h=2,f,g=null;function v(){var p={nodes:l.apply(null,arguments),links:c.apply(null,arguments)};b(p),_m(p,s,g),d(p),w(p),hu(p,s),y(p,u,s),T(p);for(var k=4,_=0;_<k;_++)Js(p,r,s),Qs(p,r,s),Tm(p,e,r,s),Js(p,r,s),Qs(p,r,s);return $m(p,e,r),xu(p,h,r,s),p}v.nodeId=function(p){return arguments.length?(s=typeof p=="function"?p:mi(p),v):s},v.nodeAlign=function(p){return arguments.length?(o=typeof p=="function"?p:mi(p),v):o},v.nodeWidth=function(p){return arguments.length?(a=+p,v):a},v.nodePadding=function(p){return arguments.length?(i=+p,v):i},v.nodes=function(p){return arguments.length?(l=typeof p=="function"?p:mi(p),v):l},v.links=function(p){return arguments.length?(c=typeof p=="function"?p:mi(p),v):c},v.size=function(p){return arguments.length?(t=e=0,n=+p[0],r=+p[1],v):[n-t,r-e]},v.extent=function(p){return arguments.length?(t=+p[0][0],n=+p[1][0],e=+p[0][1],r=+p[1][1],v):[[t,e],[n,r]]},v.iterations=function(p){return arguments.length?(u=+p,v):u},v.circularLinkGap=function(p){return arguments.length?(h=+p,v):h},v.nodePaddingRatio=function(p){return arguments.length?(f=+p,v):f},v.sortNodes=function(p){return arguments.length?(g=p,v):g},v.update=function(p){return hu(p,s),T(p),p.links.forEach(function(k){k.circular&&(k.circularLinkType=k.y0+k.y1<r?"top":"bottom",k.source.circularLinkType=k.circularLinkType,k.target.circularLinkType=k.circularLinkType)}),Js(p,r,s,!1),Qs(p,r,s),xu(p,h,r,s),p};function b(p){p.nodes.forEach(function(_,E){_.index=E,_.sourceLinks=[],_.targetLinks=[]});var k=ia(p.nodes,s);return p.links.forEach(function(_,E){_.index=E;var R=_.source,z=_.target;(typeof R>"u"?"undefined":uu(R))!=="object"&&(R=_.source=fu(k,R)),(typeof z>"u"?"undefined":uu(z))!=="object"&&(z=_.target=fu(k,z)),R.sourceLinks.push(_),z.targetLinks.push(_)}),p}function d(p){p.nodes.forEach(function(k){k.partOfCycle=!1,k.value=Math.max(Us(k.sourceLinks,Gs),Us(k.targetLinks,Gs)),k.sourceLinks.forEach(function(_){_.circular&&(k.partOfCycle=!0,k.circularLinkType=_.circularLinkType)}),k.targetLinks.forEach(function(_){_.circular&&(k.partOfCycle=!0,k.circularLinkType=_.circularLinkType)})})}function x(p){var k=0,_=0,E=0,R=0,z=Bs(p.nodes,function(I){return I.column});return p.links.forEach(function(I){I.circular&&(I.circularLinkType=="top"?k=k+I.width:_=_+I.width,I.target.column==0&&(R=R+I.width),I.source.column==z&&(E=E+I.width))}),k=k>0?k+$n+Ke:k,_=_>0?_+$n+Ke:_,E=E>0?E+$n+Ke:E,R=R>0?R+$n+Ke:R,{top:k,bottom:_,left:R,right:E}}function S(p,k){var _=Bs(p.nodes,function(M){return M.column}),E=n-t,R=r-e,z=E+k.right+k.left,I=R+k.top+k.bottom,N=E/z,U=R/I;return t=t*N+k.left,n=k.right==0?n:n*N,e=e*U+k.top,r=r*U,p.nodes.forEach(function(M){M.x0=t+M.column*((n-t-a)/_),M.x1=M.x0+a}),U}function w(p){var k,_,E;for(k=p.nodes,_=[],E=0;k.length;++E,k=_,_=[])k.forEach(function(R){R.depth=E,R.sourceLinks.forEach(function(z){_.indexOf(z.target)<0&&!z.circular&&_.push(z.target)})});for(k=p.nodes,_=[],E=0;k.length;++E,k=_,_=[])k.forEach(function(R){R.height=E,R.targetLinks.forEach(function(z){_.indexOf(z.source)<0&&!z.circular&&_.push(z.source)})});p.nodes.forEach(function(R){R.column=Math.floor(o.call(null,R,E))})}function y(p,k,_){var E=im().key(function(M){return M.column}).sortKeys(Os).entries(p.nodes).map(function(M){return M.values});I(_),U();for(var R=1,z=k;z>0;--z)N(R*=.99,_),U();function I(M){if(f){var Y=1/0;E.forEach(function(V){var et=r*f/(V.length+1);Y=et<Y?et:Y}),i=Y}var C=Ys(E,function(V){return(r-e-(V.length-1)*i)/Us(V,Gs)});C=C*bm,p.links.forEach(function(V){V.width=V.value*C});var F=x(p),H=S(p,F);C=C*H,p.links.forEach(function(V){V.width=V.value*C}),E.forEach(function(V){var et=V.length;V.forEach(function($,dt){$.depth==E.length-1&&et==1||$.depth==0&&et==1?($.y0=r/2-$.value*C,$.y1=$.y0+$.value*C):$.partOfCycle?pu($,M)==0?($.y0=r/2+dt,$.y1=$.y0+$.value*C):$.circularLinkType=="top"?($.y0=e+dt,$.y1=$.y0+$.value*C):($.y0=r-$.value*C-dt,$.y1=$.y0+$.value*C):F.top==0||F.bottom==0?($.y0=(r-e)/et*dt,$.y1=$.y0+$.value*C):($.y0=(r-e)/2-et/2+dt,$.y1=$.y0+$.value*C)})})}function N(M,Y){var C=E.length;E.forEach(function(F){var H=F.length,V=F[0].depth;F.forEach(function(et){var $;if((et.sourceLinks.length||et.targetLinks.length)&&!(et.partOfCycle&&pu(et,Y)>0))if(V==0&&H==1)$=et.y1-et.y0,et.y0=r/2-$/2,et.y1=r/2+$/2;else if(V==C-1&&H==1)$=et.y1-et.y0,et.y0=r/2-$/2,et.y1=r/2+$/2;else{var dt=0,wt=au(et.sourceLinks,ym),pt=au(et.targetLinks,gm);wt&&pt?dt=(wt+pt)/2:dt=wt||pt;var _t=(dt-Zs(et))*M;et.y0+=_t,et.y1+=_t}})})}function U(){E.forEach(function(M){var Y,C,F=e,H=M.length,V;for(M.sort(Ks),V=0;V<H;++V)Y=M[V],C=F-Y.y0,C>0&&(Y.y0+=C,Y.y1+=C),F=Y.y1+i;if(C=F-i-r,C>0)for(F=Y.y0-=C,Y.y1-=C,V=H-2;V>=0;--V)Y=M[V],C=Y.y1+i-F,C>0&&(Y.y0-=C,Y.y1-=C),F=Y.y0})}}function T(p){p.nodes.forEach(function(k){k.sourceLinks.sort(pm),k.targetLinks.sort(dm)}),p.nodes.forEach(function(k){var _=k.y0,E=_,R=k.y1,z=R;k.sourceLinks.forEach(function(I){I.circular?(I.y0=R-I.width/2,R=R-I.width):(I.y0=_+I.width/2,_+=I.width)}),k.targetLinks.forEach(function(I){I.circular?(I.y1=z-I.width/2,z=z-I.width):(I.y1=E+I.width/2,E+=I.width)})})}return v}function _m(t,e,n){var r=0;if(n===null){for(var a=[],i=0;i<t.links.length;i++){var s=t.links[i],o=s.source.index,l=s.target.index;a[o]||(a[o]=[]),a[l]||(a[l]=[]),a[o].indexOf(l)===-1&&a[o].push(l)}var c=fm(a);c.sort(function(g,v){return g.length-v.length});var u={};for(i=0;i<c.length;i++){var h=c[i],f=h.slice(-2);u[f[0]]||(u[f[0]]={}),u[f[0]][f[1]]=!0}t.links.forEach(function(g){var v=g.target.index,b=g.source.index;v===b||u[b]&&u[b][v]?(g.circular=!0,g.circularLinkID=r,r=r+1):g.circular=!1})}else t.links.forEach(function(g){g.source[n]<g.target[n]?g.circular=!1:(g.circular=!0,g.circularLinkID=r,r=r+1)})}function hu(t,e){var n=0,r=0;t.links.forEach(function(a){a.circular&&(a.source.circularLinkType||a.target.circularLinkType?a.circularLinkType=a.source.circularLinkType?a.source.circularLinkType:a.target.circularLinkType:a.circularLinkType=n<r?"top":"bottom",a.circularLinkType=="top"?n=n+1:r=r+1,t.nodes.forEach(function(i){(Re(i,e)==Re(a.source,e)||Re(i,e)==Re(a.target,e))&&(i.circularLinkType=a.circularLinkType)}))}),t.links.forEach(function(a){a.circular&&(a.source.circularLinkType==a.target.circularLinkType&&(a.circularLinkType=a.source.circularLinkType),sa(a,e)&&(a.circularLinkType=a.source.circularLinkType))})}function du(t){var e=Math.abs(t.y1-t.y0),n=Math.abs(t.target.x0-t.source.x1);return Math.atan(n/e)}function km(t,e){return t.source.column<e.target.column?!1:!(t.target.column>e.source.column)}function pu(t,e){var n=0;t.sourceLinks.forEach(function(a){n=a.circular&&!sa(a,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(a){r=a.circular&&!sa(a,e)?r+1:r}),n+r}function gu(t){var e=t.source.sourceLinks,n=0;e.forEach(function(i){n=i.circular?n+1:n});var r=t.target.targetLinks,a=0;return r.forEach(function(i){a=i.circular?a+1:a}),!(n>1||a>1)}function yu(t,e,n){return t.sort(Sm),t.forEach(function(r,a){var i=0;if(sa(r,n)&&gu(r))r.circularPathData.verticalBuffer=i+r.width/2;else{var s=0;for(s;s<a;s++)if(km(t[a],t[s])){var o=t[s].circularPathData.verticalBuffer+t[s].width/2+e;i=o>i?o:i}r.circularPathData.verticalBuffer=i+r.width/2}}),t}function xu(t,e,n,r){var a=5,i=Ys(t.links,function(l){return l.source.y0});t.links.forEach(function(l){l.circular&&(l.circularPathData={})});var s=t.links.filter(function(l){return l.circularLinkType=="top"});yu(s,e,r);var o=t.links.filter(function(l){return l.circularLinkType=="bottom"});yu(o,e,r),t.links.forEach(function(l){if(l.circular){if(l.circularPathData.arcRadius=l.width+Ke,l.circularPathData.leftNodeBuffer=a,l.circularPathData.rightNodeBuffer=a,l.circularPathData.sourceWidth=l.source.x1-l.source.x0,l.circularPathData.sourceX=l.source.x0+l.circularPathData.sourceWidth,l.circularPathData.targetX=l.target.x0,l.circularPathData.sourceY=l.y0,l.circularPathData.targetY=l.y1,sa(l,r)&&gu(l))l.circularPathData.leftSmallArcRadius=Ke+l.width/2,l.circularPathData.leftLargeArcRadius=Ke+l.width/2,l.circularPathData.rightSmallArcRadius=Ke+l.width/2,l.circularPathData.rightLargeArcRadius=Ke+l.width/2,l.circularLinkType=="bottom"?(l.circularPathData.verticalFullExtent=l.source.y1+$n+l.circularPathData.verticalBuffer,l.circularPathData.verticalLeftInnerExtent=l.circularPathData.verticalFullExtent-l.circularPathData.leftLargeArcRadius,l.circularPathData.verticalRightInnerExtent=l.circularPathData.verticalFullExtent-l.circularPathData.rightLargeArcRadius):(l.circularPathData.verticalFullExtent=l.source.y0-$n-l.circularPathData.verticalBuffer,l.circularPathData.verticalLeftInnerExtent=l.circularPathData.verticalFullExtent+l.circularPathData.leftLargeArcRadius,l.circularPathData.verticalRightInnerExtent=l.circularPathData.verticalFullExtent+l.circularPathData.rightLargeArcRadius);else{var c=l.source.column,u=l.circularLinkType,h=t.links.filter(function(v){return v.source.column==c&&v.circularLinkType==u});l.circularLinkType=="bottom"?h.sort(vu):h.sort(mu);var f=0;h.forEach(function(v,b){v.circularLinkID==l.circularLinkID&&(l.circularPathData.leftSmallArcRadius=Ke+l.width/2+f,l.circularPathData.leftLargeArcRadius=Ke+l.width/2+b*e+f),f=f+v.width}),c=l.target.column,h=t.links.filter(function(v){return v.target.column==c&&v.circularLinkType==u}),l.circularLinkType=="bottom"?h.sort(Nm):h.sort(Mm),f=0,h.forEach(function(v,b){v.circularLinkID==l.circularLinkID&&(l.circularPathData.rightSmallArcRadius=Ke+l.width/2+f,l.circularPathData.rightLargeArcRadius=Ke+l.width/2+b*e+f),f=f+v.width}),l.circularLinkType=="bottom"?(l.circularPathData.verticalFullExtent=Math.max(n,l.source.y1,l.target.y1)+$n+l.circularPathData.verticalBuffer,l.circularPathData.verticalLeftInnerExtent=l.circularPathData.verticalFullExtent-l.circularPathData.leftLargeArcRadius,l.circularPathData.verticalRightInnerExtent=l.circularPathData.verticalFullExtent-l.circularPathData.rightLargeArcRadius):(l.circularPathData.verticalFullExtent=i-$n-l.circularPathData.verticalBuffer,l.circularPathData.verticalLeftInnerExtent=l.circularPathData.verticalFullExtent+l.circularPathData.leftLargeArcRadius,l.circularPathData.verticalRightInnerExtent=l.circularPathData.verticalFullExtent+l.circularPathData.rightLargeArcRadius)}l.circularPathData.leftInnerExtent=l.circularPathData.sourceX+l.circularPathData.leftNodeBuffer,l.circularPathData.rightInnerExtent=l.circularPathData.targetX-l.circularPathData.rightNodeBuffer,l.circularPathData.leftFullExtent=l.circularPathData.sourceX+l.circularPathData.leftLargeArcRadius+l.circularPathData.leftNodeBuffer,l.circularPathData.rightFullExtent=l.circularPathData.targetX-l.circularPathData.rightLargeArcRadius-l.circularPathData.rightNodeBuffer}if(l.circular)l.path=Am(l);else{var g=eu().source(function(v){var b=v.source.x0+(v.source.x1-v.source.x0),d=v.y0;return[b,d]}).target(function(v){var b=v.target.x0,d=v.y1;return[b,d]});l.path=g(l)}})}function Am(t){var e="";return t.circularLinkType=="top"?e="M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.leftSmallArcRadius)+" L"+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" L"+t.circularPathData.rightFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.rightSmallArcRadius)+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:e="M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.leftSmallArcRadius)+" L"+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" L"+t.circularPathData.rightFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.rightSmallArcRadius)+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY,e}function Sm(t,e){return vi(t)==vi(e)?t.circularLinkType=="bottom"?vu(t,e):mu(t,e):vi(e)-vi(t)}function mu(t,e){return t.y0-e.y0}function vu(t,e){return e.y0-t.y0}function Mm(t,e){return t.y1-e.y1}function Nm(t,e){return e.y1-t.y1}function vi(t){return t.target.column-t.source.column}function bu(t){return t.target.x0-t.source.x1}function wu(t,e){var n=du(t),r=bu(e)/Math.tan(n),a=bi(t)=="up"?t.y1+r:t.y1-r;return a}function _u(t,e){var n=du(t),r=bu(e)/Math.tan(n),a=bi(t)=="up"?t.y1-r:t.y1+r;return a}function Tm(t,e,n,r){t.links.forEach(function(a){if(!a.circular&&a.target.column-a.source.column>1){var i=a.source.column+1,s=a.target.column-1,o=1,l=s-i+1;for(o=1;i<=s;i++,o++)t.nodes.forEach(function(c){if(c.column==i){var u=o/(l+1),h=Math.pow(1-u,3),f=3*u*Math.pow(1-u,2),g=3*Math.pow(u,2)*(1-u),v=Math.pow(u,3),b=h*a.y0+f*a.y0+g*a.y1+v*a.y1,d=b-a.width/2,x=b+a.width/2,S;d>c.y0&&d<c.y1?(S=c.y1-d+10,S=c.circularLinkType=="bottom"?S:-S,c=br(c,S,e,n),t.nodes.forEach(function(w){Re(w,r)==Re(c,r)||w.column!=c.column||Dm(c,w)&&br(w,S,e,n)})):x>c.y0&&x<c.y1?(S=x-c.y0+10,c=br(c,S,e,n),t.nodes.forEach(function(w){Re(w,r)==Re(c,r)||w.column!=c.column||w.y0<c.y1&&w.y1>c.y1&&br(w,S,e,n)})):d<c.y0&&x>c.y1&&(S=x-c.y0+10,c=br(c,S,e,n),t.nodes.forEach(function(w){Re(w,r)==Re(c,r)||w.column!=c.column||w.y0<c.y1&&w.y1>c.y1&&br(w,S,e,n)}))}})}})}function Dm(t,e){return t.y0>e.y0&&t.y0<e.y1||t.y1>e.y0&&t.y1<e.y1?!0:t.y0<e.y0&&t.y1>e.y1}function br(t,e,n,r){return t.y0+e>=n&&t.y1+e<=r&&(t.y0=t.y0+e,t.y1=t.y1+e,t.targetLinks.forEach(function(a){a.y1=a.y1+e}),t.sourceLinks.forEach(function(a){a.y0=a.y0+e})),t}function Js(t,e,n,r){t.nodes.forEach(function(a){r&&a.y+(a.y1-a.y0)>e&&(a.y=a.y-(a.y+(a.y1-a.y0)-e));var i=t.links.filter(function(l){return Re(l.source,n)==Re(a,n)}),s=i.length;s>1&&i.sort(function(l,c){if(!l.circular&&!c.circular){if(l.target.column==c.target.column)return l.y1-c.y1;if(ku(l,c)){if(l.target.column>c.target.column){var u=_u(c,l);return l.y1-u}if(c.target.column>l.target.column){var h=_u(l,c);return h-c.y1}}else return l.y1-c.y1}if(l.circular&&!c.circular)return l.circularLinkType=="top"?-1:1;if(c.circular&&!l.circular)return c.circularLinkType=="top"?1:-1;if(l.circular&&c.circular)return l.circularLinkType===c.circularLinkType&&l.circularLinkType=="top"?l.target.column===c.target.column?l.target.y1-c.target.y1:c.target.column-l.target.column:l.circularLinkType===c.circularLinkType&&l.circularLinkType=="bottom"?l.target.column===c.target.column?c.target.y1-l.target.y1:l.target.column-c.target.column:l.circularLinkType=="top"?-1:1});var o=a.y0;i.forEach(function(l){l.y0=o+l.width/2,o=o+l.width}),i.forEach(function(l,c){if(l.circularLinkType=="bottom"){var u=c+1,h=0;for(u;u<s;u++)h=h+i[u].width;l.y0=a.y1-h-l.width/2}})})}function Qs(t,e,n){t.nodes.forEach(function(r){var a=t.links.filter(function(o){return Re(o.target,n)==Re(r,n)}),i=a.length;i>1&&a.sort(function(o,l){if(!o.circular&&!l.circular){if(o.source.column==l.source.column)return o.y0-l.y0;if(ku(o,l)){if(l.source.column<o.source.column){var c=wu(l,o);return o.y0-c}if(o.source.column<l.source.column){var u=wu(o,l);return u-l.y0}}else return o.y0-l.y0}if(o.circular&&!l.circular)return o.circularLinkType=="top"?-1:1;if(l.circular&&!o.circular)return l.circularLinkType=="top"?1:-1;if(o.circular&&l.circular)return o.circularLinkType===l.circularLinkType&&o.circularLinkType=="top"?o.source.column===l.source.column?o.source.y1-l.source.y1:o.source.column-l.source.column:o.circularLinkType===l.circularLinkType&&o.circularLinkType=="bottom"?o.source.column===l.source.column?o.source.y1-l.source.y1:l.source.column-o.source.column:o.circularLinkType=="top"?-1:1});var s=r.y0;a.forEach(function(o){o.y1=s+o.width/2,s=s+o.width}),a.forEach(function(o,l){if(o.circularLinkType=="bottom"){var c=l+1,u=0;for(c;c<i;c++)u=u+a[c].width;o.y1=r.y1-u-o.width/2}})})}function ku(t,e){return bi(t)==bi(e)}function bi(t){return t.y0-t.y1>0?"up":"down"}function sa(t,e){return Re(t.source,e)==Re(t.target,e)}function $m(t,e,n){var r=t.nodes,a=t.links,i=!1,s=!1;if(a.forEach(function(f){f.circularLinkType=="top"?i=!0:f.circularLinkType=="bottom"&&(s=!0)}),i==!1||s==!1){var o=Ys(r,function(f){return f.y0}),l=Bs(r,function(f){return f.y1}),c=l-o,u=n-e,h=u/c;r.forEach(function(f){var g=(f.y1-f.y0)*h;f.y0=(f.y0-o)*h,f.y1=f.y0+g}),a.forEach(function(f){f.y0=(f.y0-o)*h,f.y1=(f.y1-o)*h,f.width=f.width*h})}}function Au(t){const e=new Map;for(const{source:s,target:o}of t)e.has(s)||e.set(s,[]),e.has(o)||e.set(o,[]),e.get(s).push(o);const n=new Set,r=new Set,a=[];function i(s){n.add(s),r.add(s),a.push(s);const o=e.get(s)||[];for(const l of o)if(n.has(l)){if(r.has(l))return a.push(l),!0}else if(i(l))return!0;return r.delete(s),a.pop(),!1}for(const s of e.keys())if(!n.has(s)&&i(s)){const o=a[a.length-1],l=a.indexOf(o);return{hasCircularConnection:!0,cyclePath:a.slice(l)}}return{hasCircularConnection:!1}}const Su={sankeyEnergyLink:"_sankeyEnergyLink_10fud_285",sankeyLabel:"_sankeyLabel_10fud_323"};function Cm({data:t,tooltipFormat:e}){const[n,r]=bt.useState(null),[a,i]=bt.useState(!1),[s,o]=bt.useState(!1),l=bt.useRef(!0),c=bt.useRef(!0),u=bt.useRef("data"),[h,f]=Ne(),{width:g,height:v}=f,b=rn(n?n.nodes.map(k=>k.name):[]);function d(k){const _=new Map,E=[],R=[],z=I=>(_.has(I)||(_.set(I,E.length),E.push({name:I})),_.get(I));for(const{source:I,target:N,value:U}of k)R.push({source:z(I),target:z(N),value:U});return{nodes:E,links:R}}bt.useEffect(()=>{r(k=>{const _=d(t),E=k===null?[]:k.nodes.map(z=>z.name),R=_.nodes.map(z=>z.name);return l.current=R.every(z=>!E.includes(z)),k!==null&&(c.current=!1),u.current="data",_}),s&&o(!1),a&&i(!1)},[t]),bt.useEffect(()=>{g!==0&&v!==0&&(u.current="dimension")},[g,v]);const x=Au(t),S=bt.useDeferredValue(t),w=bt.useRef(void 0);bt.useEffect(()=>{if(S!==t){const k=Au(S);w.current=k.hasCircularConnection}},[t,S]);const y=g<=768,T=1e3,p=Se(k=>{if(!n)return;const _=g,E=v;if(_===0||E===0)return;const R={top:30,right:20,bottom:20,left:20},z=E-(R.top+R.bottom),I=_-(R.left+R.right),N=z,U=I,M=n.links.map(L=>({...L})),Y=n.nodes.map(L=>({...L}));M.forEach(function(L){const Z=n.nodes[L.source].name,ft=n.nodes[L.target].name,st=Z+" → "+ft;L.sourceName=Z,L.targetName=ft,L.id=st});const C=k.select("svg");C.node();const F=C.select(".plot-area").attr("transform","translate("+R.left+","+R.top+")"),H=hi(k).style("opacity",0),V=L=>{const Z=L.targetLinks?.reduce((st,it)=>st+it.value,0)??0,ft=L.sourceLinks?.reduce((st,it)=>st+it.value,0)??0;return{enteringValue:Z,exitingValue:ft}},et=wm(),$=Vx().nodeAlign(Ox).nodeSort(s?(L,Z)=>{const{enteringValue:ft,exitingValue:st}=V(L),{enteringValue:it,exitingValue:A}=V(Z);return Math.max(ft,st)-Math.max(it,A)}:null).linkSort(a?(L,Z)=>L.value-Z.value:null),dt=x.hasCircularConnection||w.current?et:$;dt.nodeWidth(U<=540?8:U>540&&U<=768?12:15).nodePadding(U<=540?5:8).extent([[0,0],[U,N]]);const wt=dt({nodes:Y.map(L=>Object.assign({},L)),links:M.map(L=>Object.assign({},L))}),{nodes:pt,links:_t}=wt;F.selectAll("linearGradient").remove();const G=F.selectAll("linearGradient").data(_t).join("linearGradient").attr("id",(L,Z)=>Z.toString()).attr("gradientUnits","userSpaceOnUse").attr("x1",L=>L.source.x0).attr("x2",L=>L.target.x0);G.append("stop").attr("offset","0%").attr("stop-color",L=>{const Z=b.current.findIndex(ft=>ft===L.sourceName);return de(Z,!1)}),G.append("stop").attr("offset","100%").attr("stop-color",L=>{const Z=b.current.findIndex(ft=>ft===L.targetName);return de(Z,!1)});const ot=L=>{const Z=L.source,ft=L.target,st=Math.abs(ft.depth-Z.depth);return U*1.5*st},O=L=>ot(L)+" "+ot(L),Q=L=>x.hasCircularConnection||!l.current||u.current==="sort node"||u.current==="sort link"||u.current!=="data"&&!c.current?0:L.target.depth*T;F.selectAll(".link").data(_t,L=>L.id).join(L=>L.append("path").attr("class",`link ${Su.sankeyEnergyLink}`).attr("d",nu()).style("stroke",function(Z){return`url(#${G.filter(it=>it.sourceName===Z.sourceName&&it.targetName===Z.targetName).node()?.id})`}).attr("stroke-dasharray",O).attr("stroke-dashoffset",ot).attr("stroke-width",Z=>Math.max(1,Z.width)).transition().duration(T).delay(function(Z){return x.hasCircularConnection?0:l.current?Q(Z):T}).attr("stroke-dashoffset",0).on("end",function(){qt(this).attr("stroke-dasharray","none")}),L=>(L.attr("stroke-width",Z=>Math.max(1,Z.width||0)).transition().duration(T).delay(Q).attr("d",nu()).attr("stroke-dashoffset",0).on("end",function(){qt(this).attr("stroke-dasharray","none")}),L),L=>l.current?L.remove():L.transition().duration(T/4).style("opacity",0).remove()).on("pointerenter",(L,Z)=>{F.selectAll("path.link").filter(ft=>ft.id!==Z.id).style("stroke","#1f2937").style("stroke-opacity",.05),F.selectAll("text.label").filter(ft=>{const st=ft;return st.name!==Z.sourceName&&st.name!==Z.targetName}).style("opacity",0),H.style("opacity",1),H.select("p.title").text(Z.id+Pe(Z.value,e)),H.select("p.top-label").style("display","none"),H.select("p.bottom-label").style("display","none"),Dn(L,H)}).on("pointermove",(L,Z)=>{Dn(L,H)}).on("pointerleave",(L,Z)=>{H.style("opacity",0),F.selectAll("path.link").style("stroke",function(ft){const st=ft;return`url(#${G.filter(j=>j.sourceName===st.sourceName&&j.targetName===st.targetName).node()?.id})`}).style("stroke-opacity",.5).style("fill","none").attr("class",`link ${J.sankeyEnergyLink}`),F.selectAll("text.label").style("opacity",1)});const X=L=>x.hasCircularConnection||!l.current||L.depth===0||u.current==="sort node"||u.current==="sort link"||u.current!=="data"&&!c.current?0:L.depth*T+T/4,D=L=>{const{enteringValue:Z,exitingValue:ft}=V(L);return{nodeState:L.sourceLinks?.length===0&&L.targetLinks?.length===0?"stray node":L.sourceLinks?.length===0?"leaf node":L.targetLinks?.length===0?"source node":Z>ft?"surplus":Z<ft?"minus":"balanced",enteringValue:Z,exitingValue:ft}},tt=L=>{const{nodeState:Z,enteringValue:ft,exitingValue:st}=D(L);return{enteringValue:ft,exitingValue:st,nodeState:Z,stateColor:Z==="surplus"?"#4ade80":Z==="minus"?"#f87171":"#e7e7e7"}};F.selectAll("rect.node").data(pt,(L=>L.name)).join(L=>L.append("rect").attr("class",`node ${J.baseNode}`).attr("x",Z=>Z.x0).attr("y",Z=>Z.y0).attr("height",Z=>l.current?Math.abs(Z.y1-Z.y0):0).attr("width",Z=>l.current?0:Z.x1-Z.x0).attr("opacity",0).attr("stroke-width",2.5).transition().duration(T).delay(X).attr("fill",Z=>{const ft=b.current.findIndex(st=>st===Z.name);return de(ft,!1)}).attr("opacity",1).attr("width",function(Z){return Z.x1-Z.x0}),void 0,L=>l.current?L.remove():L.transition().duration(T/4).style("opacity",0).remove()).on("pointerenter",(L,Z)=>{F.selectAll("path.link").filter(W=>{const K=W;return!(K.sourceName===Z.name||K.targetName===Z.name)}).style("stroke","#1f2937").style("stroke-opacity",.05);const ft=Z.sourceLinks?.map(W=>W.targetName)??[],it=[...Z.targetLinks?.map(W=>W.sourceName)??[],...ft,Z.name];F.selectAll("text.label").filter(W=>!it.includes(W.name)).style("opacity",.0625);const{enteringValue:A,exitingValue:j,nodeState:nt,stateColor:Dt}=tt(Z);H.style("opacity",1),H.select("p.title").text(Z.name+" :"),H.select("p.top-label").style("display","block").text("in "+Pe(A,e)),H.select("p.bottom-label").style("display","block").text("out "+Pe(j,e)),H.select("p.small-text").style("display","block").text(`${nt}`).style("color",`${Dt}`),Dn(L,H)}).on("pointermove",(L,Z)=>{Dn(L,H)}).on("pointerleave",(L,Z)=>{H.style("opacity",0),H.select("p.small-text").style("display","none"),F.selectAll("path.link").style("stroke",function(A){const j=A;return`url(#${G.filter(W=>W.sourceName===j.sourceName&&W.targetName===j.targetName).node()?.id})`}).style("stroke-opacity",.5).style("fill","none").attr("class",`link ${J.sankeyEnergyLink}`);const ft=Z.sourceLinks?.map(A=>A.targetName)??[],it=[...Z.targetLinks?.map(A=>A.sourceName)??[],...ft,Z.name];F.selectAll("text.label").filter(A=>!it.includes(A.name)).style("opacity",1)}).transition().duration(T).delay(X).attr("stroke-width",y?2:2.5).style("stroke",function(L){const{stateColor:Z,nodeState:ft}=tt(L);return ft==="surplus"||ft==="minus"?Z:"#52525b"}).attr("opacity",1).attr("x",L=>L.x0).attr("y",L=>L.y0).attr("height",L=>Math.abs(L.y1-L.y0)).attr("width",L=>L.x1-L.x0).attr("fill",L=>{const Z=b.current.findIndex(ft=>ft===L.name);return de(Z,!1)}),F.selectAll("text.label").data(pt,L=>L.name).join(L=>L.append("text").attr("class",`label ${Su.sankeyLabel}`).attr("x",Z=>Z.x0<U/2?Z.x1+6:Z.x0-6).attr("y",Z=>(Z.y1+Z.y0)/2).attr("dy","0.35em").attr("text-anchor",Z=>Z.x0<U/2?"start":"end").style("font-size",U<648?"12px":"16px").style("font-weight",U<648?"normal":"bold").style("stroke-width",U<648?"0px":"0.25px").style("stroke","#eff1f4").text(Z=>Z.name).attr("opacity",0),void 0,L=>L.remove()).style("font-size",U<648?"12px":"16px").style("font-weight",U<648?"normal":"bold").style("stroke-width",U<648?"0px":"0.25px").transition().duration(T).delay(X).attr("x",L=>L.x0<U/2?L.x1+6:L.x0-6).attr("y",L=>(L.y1+L.y0)/2).attr("dy","0.35em").attr("text-anchor",L=>L.x0<U/2?"start":"end").attr("opacity",1)},[n,a,s,g,v,e]);return m.jsx("div",{ref:h,style:{width:g,height:v,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:p,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${g} ${v}`,children:m.jsx("g",{className:"plot-area"})}),m.jsxs("div",{style:{position:"absolute",right:"12px",top:"6px",display:x.hasCircularConnection?"none":"flex",alignItems:"center",pointerEvents:x.hasCircularConnection?"none":"auto"},children:[m.jsxs("label",{className:J["controls-label"],children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:a,onChange:k=>{const _=k.target.checked;_&&(u.current="sort link"),i(_)}}),"Sort link"]}),m.jsxs("label",{className:J["controls-label"],children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:s,onChange:k=>{const _=k.target.checked;_&&(u.current="sort node"),o(_)}}),"Sort node"]})]}),m.jsx(Qe,{pCount:4})]})})}function Lm(t,e){return e.value-t.value}function jm(t){return t.children}function Pm(t){return t.value}function Em(t,e){return t.value-e.value}function wr(t,e){if(!t)return;const n=[t],r=[];let a;for(;a=n.pop();){r.push(a);const i=a.children;if(i&&i.length)for(let s=0;s<i.length;s++)n.push(i[s])}for(;a=r.pop();)e(a)}const Rm=t=>{let e=0;for(let a=0;a<t.length;a++)e+=t[a].length;const n=new Array(e);let r=t.length;for(;--r>=0;){const a=t[r];let i=a.length;for(;--i>=0;)n[--e]=a[i]}return n};function zm(t){return Rm(t.map(e=>(e.children||[]).map(n=>({source:e,target:n}))))}function Im(t,e,n){return function(...r){const a=n.apply(e,r);return a===e?t:a}}function Fm(t,e,...n){for(let r=0;r<n.length;r++){const a=n[r];t[a]=Im(t,e,e[a])}return t}function Hm(t,e){return Fm(t,e,"sort","children","value"),t.nodes=t,t.links=zm,t}function Wm(){let t=Lm,e=jm,n=Pm;function r(a){const i=[a],s=[];let o;for(a.depth=0;o=i.pop();){s.push(o);const l=e.call(r,o,o.depth);if(l&&l.length){for(let c=l.length-1;c>=0;c--){const u=l[c];i.push(u),u.parent=o,u.depth=(o.depth||0)+1}n&&(o.value=0),o.children=l}else n&&(o.value=+n.call(r,o,o.depth||0)||0),delete o.children}return wr(a,l=>{t&&l.children&&l.children.sort(t),n&&l.parent&&(l.parent.value+=l.value)}),s}return r.sort=function(a){return arguments.length?(t=a,r):t},r.children=function(a){return arguments.length?(e=a,r):e},r.value=function(a){return arguments.length?(n=a,r):n},r}function Om(t){delete t._pack_next,delete t._pack_prev}function Bm(t){t._pack_next=t._pack_prev=t}function Mu(t,e,n){let r=t.r+n.r,a=e.x-t.x,i=e.y-t.y;if(r&&(a||i)){let s=e.r+n.r,o=a*a+i*i;s*=s,r*=r;const l=.5+(r-s)/(2*o),c=Math.sqrt(Math.max(0,2*s*(r+o)-(r-=o)*r-s*s))/(2*o);n.x=t.x+l*a+c*i,n.y=t.y+l*i-c*a}else n.x=t.x+r,n.y=t.y}function Nu(t,e,n,r){const a=t.children;if(t.x=e+r*t.x,t.y=n+r*t.y,t.r*=r,a)for(let i=0;i<a.length;i++)Nu(a[i],t.x,t.y,r)}function qs(t,e){const n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Tu(t,e){const n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return .999*a*a>n*n+r*r}function Du(t,e){t._pack_next=e,e._pack_prev=t}function $u(t){const e=t.children;if(e&&e.length){let n=1/0,r=-1/0,a=1/0,i=-1/0;const s=h=>{n=Math.min(h.x-h.r,n),r=Math.max(h.x+h.r,r),a=Math.min(h.y-h.r,a),i=Math.max(h.y+h.r,i)};e.forEach(Bm);let o=e[0];if(o.x=-o.r,o.y=0,s(o),e.length>1){let h=e[1];if(h.x=h.r,h.y=0,s(h),e.length>2){let f=e[2];Mu(o,h,f),s(f),qs(o,f),o._pack_prev=f,qs(f,h),h=o._pack_next;for(let g=3;g<e.length;g++){Mu(o,h,f=e[g]);let v=0,b=1,d=1;for(let x=h._pack_next;x!==h;x=x._pack_next,b++)if(Tu(x,f)){v=1;break}if(v===1)for(let x=o._pack_prev;x!==e[g-1]._pack_prev&&!Tu(x,f);x=x._pack_prev,d++);v?(d>b||b===d&&h.r<o.r?Du(o,h=h._pack_next):Du(o=o._pack_prev,h),g--):(qs(o,f),h=f,s(f))}}}const l=(n+r)/2,c=(a+i)/2;let u=0;for(let h=0;h<e.length;h++){const f=e[h];f.x-=l,f.y-=c,u=Math.max(u,f.r+Math.sqrt(f.x*f.x+f.y*f.y))}t.r=u,e.forEach(Om)}}function Cu(){let t,e=Wm().sort(Em),n=0,r=[1,1];function a(i,s){const o=e(i,s),l=o[0],c=r[0],u=r[1],h=t==null?Math.sqrt:typeof t=="function"?t:()=>t;if(l.x=l.y=0,wr(l,f=>{f.r=+h(f.value)}),wr(l,$u),n){const f=n*(t?1:Math.max(2*l.r/c,2*l.r/u))/2;wr(l,g=>{g.r+=f}),wr(l,$u),wr(l,g=>{g.r-=f})}return Nu(l,c/2,u/2,t?1:1/Math.max(2*l.r/c,2*l.r/u)),o}return a.size=function(i){return arguments.length?(r=i,a):r},a.radius=function(i){return arguments.length?(t=i==null||typeof i=="function"?i:+i,a):t},a.padding=function(i){return arguments.length?(n=+i,a):n},Hm(a,e)}const Kn={node:"_node_1x526_1","node--leaf":"_node--leaf_1x526_19",circle_pack_label:"_circle_pack_label_1x526_27","node--root":"_node--root_1x526_73"};function Ym(t){const e=new Map;for(const n of t)e.set(n.name,n);return e}function Lu(t,e){const n=e.get(t.data.name);if(n&&(t.sortedX=n.x,t.sortedY=n.y,t.sortedR=n.r),t.children)for(const r of t.children)Lu(r,e)}function Um({data:t,tooltipFormat:e,colorScheme:n="monochrome"}){const[r,a]=bt.useState(null),[i,s]=bt.useState(!1),o=bt.useRef(!0),[l,c]=Ne(),{width:u,height:h}=c;bt.useEffect(()=>{a(x=>(x!==null&&(o.current=!1),t))},[t]);const f=rn(t.children?.map(x=>x.name)),g=ll($c,12),v=bt.useRef(hr().domain(f.current).range(g)),b=1e3,d=Se(x=>{if(!r)return;const S=u,w=h,y=12,T=1.5;if(S===0||w===0)return;const p=25,k=w-p*2,_=S-p*2,E=k,R=_,z={name:"branches",children:r.children},I=Math.min(R,E),N=fr(we(z)).sum(function(A){return A.value}).sort(function(A,j){return A.value-j.value}),U=Jl().size([I-p,I-p]).padding(2),Y=Cu().padding(2).size([I-p,I-p]).value(function(A){return A.value}).nodes(we(z));let C=N,F=1,H=1;const V=U(N),et=V.descendants(),$=[V.x,V.y,V.r*2+p],dt=Ym(Y);Lu(et[0],dt);const wt=x.select("#tooltip").style("opacity",0),pt=x.select("svg"),_t=pt.node(),G=pt.select(".plot-area"),ot=ye().domain([-1,2]).range(["#34d399","#6b21a8"]).interpolate(jd),O=A=>{let j=A;for(;j.depth>1;)j=j.parent;const nt=j.data.name,Dt=v.current(nt),W=Ve(Dt);if(!W)return Dt;const K=A.depth,Ct=.5;return K===1?W.formatHex():W.darker(K*Ct).formatHex()},Q=A=>n==="monochrome"?A.children?ot(A.depth):"#f0fdfa":O(A);function X(A){const j=I/$[2];return(i?A.sortedR??0:A.r)*j}function D(A){const j=I/$[2];return((i?A.sortedX??0:A.x)-$[0])*j}function tt(A){const j=I/$[2];return((i?A.sortedY??0:A.y)-$[1])*j}const L=G.selectAll("circle").data(et,A=>A.data.name).join(A=>A.append("circle").attr("class",function(j){return j.parent?j.children?Kn.node:`${Kn.node} ${Kn["node--leaf"]}`:`${Kn.node} ${Kn["node--root"]}`}).style("fill",Q).style("cursor","pointer").transition().duration(b).attr("r",X).attr("cx",D).attr("cy",tt).style("stroke","#737373").style("stroke-width",T*H).style("fill",Q),A=>A.transition().duration(b).attr("cx",D).attr("cy",tt).attr("r",X).style("stroke",function(j){return"#737373"}).style("stroke-width",T*H).style("fill",Q),A=>A.transition().duration(b).style("opacity",0).remove()).on("mouseover",function(A,j){C.parent===j?ft.filter(function(W){return W.parent===C||this.style.display==="inline"}).style("font-size",y*H).style("fill-opacity",function(W){return W.parent===C?1:0}).style("display",function(W){return W.parent===C?"inline":"none"}):j===C?ft.filter(function(W){return W.parent===C||this.style.display==="inline"}).style("font-size",y*H).style("fill-opacity",function(W){return W.parent===C?1:0}).style("display",function(W){return W.parent===C?"inline":"none"}):(ft.filter(function(W){if(i){const K=j;return W.name!==K.name}return W.data.name!=j.data.name}).style("fill-opacity",0).style("display","none"),ft.filter(function(W){if(i){const K=j;return W.name!==K.name}return W.data.name===j.data.name}).style("fill-opacity",1).style("display","inline")),j!=N&&qt(this).style("stroke-width",T*H*2.5).style("stroke","#e4e4e7");const nt=j.data.name==="branches"?"Total":j.data.name;wt.select("p.name").text(nt);const Dt=j.value??0;wt.select("p.value").text(Pe(Dt,e).toLocaleString()),wt.transition().duration(250).style("opacity",1),le(wt,{e:A,svg:_t})}).on("mousemove",(A,j)=>{le(wt,{e:A,svg:_t})}).on("mouseout",function(A,j){ft.filter(function(nt){return nt.parent===C||this.style.display==="inline"}).style("fill-opacity",function(nt){return nt.parent===C?1:0}).style("display",function(nt){return nt.parent===C?"inline":"none"}),qt(this).style("stroke-width",T*H).style("stroke",function(nt){return"#737373"}),wt.transition().duration(250).style("opacity",0)}).on("click",function(A,j){if(j===N){it();return}C!=j?st(j):it(),L.style("stroke-width",T*H),A.stopPropagation()});function Z(A){const j=I/$[2],nt=i?A.sortedX??0:A.x,Dt=i?A.sortedY??0:A.y;return"translate("+(nt-$[0])*j+","+(Dt-$[1])*j+")"}const ft=G.selectAll("text").data(et,A=>A.data.name).join(A=>A.append("text").attr("class",Kn.circle_pack_label).text(j=>j.data.name).style("font-size",y).style("text-anchor","middle").style("fill-opacity",0).style("stroke-opacity",0).style("display","none").style("pointer-events","none").style("text-shadow","0 1px 0 lightblue, 1px 0 0 lightblue, -1px 0 0 lightblue, 0 -1px 0 lightblue").transition().duration(b).attr("transform",Z).style("fill-opacity",function(j){return j.parent===N?1:0}).style("display",function(j){return j.parent===N?"inline":"none"}),A=>A.attr("class",Kn.circle_pack_label).transition().duration(b).attr("transform",Z).style("fill-opacity",function(j){return j.parent===N?1:0}).style("display",function(j){return j.parent===N?"inline":"none"}),A=>A.transition().duration(b).style("opacity",0).remove());ft.raise();function st(A){C=A;const j=I/2-p,nt=S/2,Dt=w/2,W=I/$[2],K=A.r*W;H=K/j,F=j/K;const Rt=((i?A.sortedX??0:A.x)-$[0])*W,q=nt-Rt*F,ut=((i?A.sortedY??0:A.y)-$[0])*W,vt=Dt-ut*F;G.transition().duration(1e3).attr("transform","translate("+q+","+vt+")scale("+F+")"),ft.style("font-size",y*H+"px").filter(function(At){return At.parent===C||this.style.display==="inline"}).style("fill-opacity",function(At){return At.parent===C?1:0}).style("display",function(At){return At.parent===C?"inline":"none"})}function it(){G.transition().duration(b).attr("transform","translate("+S/2+", "+w/2+")scale(1)"),C=N,F=1,H=1,ft.style("font-size",y*H+"px").filter(function(A){return A.parent===C||this.style.display==="inline"}).style("fill-opacity",function(A){return A.parent===C?1:0}).style("display",function(A){return A.parent===C?"inline":"none"})}it()},[r,n,u,h,i]);return m.jsx("div",{ref:l,style:{width:u,height:h,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:d,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${u} ${h}`,children:m.jsx("g",{className:"plot-area"})}),m.jsxs("label",{className:J["controls-label"],style:{position:"absolute",right:"12px",top:"6px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:i,onChange:x=>s(x.target.checked)}),"Sort"]}),m.jsxs(Qe,{children:[m.jsx("p",{className:"name",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat"},children:"Tooltip"}),m.jsx("p",{className:"value",style:{fontWeight:"400px",margin:"3px",fontSize:"13px",color:"wheat",textAlign:"right"},children:"Tooltip"})]})]})})}const Vm=({size:t=24,color:e="#0099ff",...n})=>m.jsx("svg",{viewBox:"0 0 64 64",width:t,height:t,xmlns:"http://www.w3.org/2000/svg",...n,children:m.jsxs("g",{fill:e,children:[m.jsx("path",{d:`M62.242,47.758l0.014-0.014c-5.847-4.753-12.84-8.137-20.491-9.722C44.374,35.479,46,31.932,46,28\r
|
|
24
24
|
c1.657,0,3-1.343,3-3v-2c0-0.886-0.391-1.673-1-2.222V12c0-6.627-5.373-12-12-12h-8c-6.627,0-12,5.373-12,12v8.778\r
|
|
25
25
|
c-0.609,0.549-1,1.336-1,2.222v2c0,1.657,1.343,3,3,3c0,3.932,1.626,7.479,4.236,10.022c-7.652,1.586-14.646,4.969-20.492,9.722\r
|
|
26
26
|
l0.014,0.014C0.672,48.844,0,50.344,0,52v8c0,2.211,1.789,4,4,4h56c2.211,0,4-1.789,4-4v-8C64,50.344,63.328,48.844,62.242,47.758z\r
|
|
@@ -59,8 +59,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
59
59
|
c0.491-0.253,0.684-0.856,0.431-1.347\r
|
|
60
60
|
C39.594,20.969,38.653,20,37,20\r
|
|
61
61
|
c-1.691,0-2.618,0.983-2.9,1.564\r
|
|
62
|
-
C33.866,22.047,34.065,22.609,34.539,22.862z`})]})}),Be={male:"_male_1piqt_1",maleTotal:"_maleTotal_1piqt_1",totalMale:"_totalMale_1piqt_25",female:"_female_1piqt_53",femaleTotal:"_femaleTotal_1piqt_53",totalFemale:"_totalFemale_1piqt_77","value-axis":"_value-axis_1piqt_113",container:"_container_1piqt_133",inner:"_inner_1piqt_143"};function Km({data:t}){const[e,n]=Ne(),{width:r,height:a}=n,[i,s]=bt.useState(!1),[o,l]=bt.useState(!1),[c,u]=bt.useState(!1),[h,f]=He(),{width:g,height:v}=f,b=500;bt.useEffect(()=>{c&&s(!1),l(c)},[c]),bt.useEffect(()=>{u(!1),s(!1),l(!1)},[t]);const d=r>576,x=m.jsxs("div",{className:`${J[d?"controls-container":"controls-container-sm"]}`,children:[m.jsxs("label",{className:`${J["controls-label"]} ${c?J.disabled:""}`,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:`${J["controls-checkbox"]}`,checked:i,onChange:k=>s(k.target.checked),disabled:c}),"Sort"]}),m.jsxs("label",{className:`${J["controls-label"]} ${c?J.disabled:""}`,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:o,onChange:k=>l(k.target.checked),disabled:c}),"By Total"]}),m.jsxs("label",{className:J["controls-label"],style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:c,onChange:k=>u(k.target.checked)}),"By Percentage"]})]}),S=t.reduce((k,_)=>(_.male=+_.male,_.female=+_.female,_.Total=_.male+_.female,{totalPeople:k.totalPeople+_.male+_.female,totalMale:k.totalMale+_.male,totalFemale:k.totalFemale+_.female}),{totalPeople:0,totalMale:0,totalFemale:0}),{totalPeople:w,totalMale:y,totalFemale:T}=S,p=Se(k=>{if(r===0||a===0)return;const _={top:0,right:d?0:15,bottom:30,left:d?0:15},E=r-_.left-_.right,R=a-_.top-_.bottom;let z=Xe().range([R,0]),I=Xe().range([R,0]),N=ye().rangeRound([0,E/2]),U=ye().rangeRound([E/2,E]),M=he(N).ticks(d?8:4).tickSize(-R).tickFormat(pe(c?"~%":".2s")),Y=he(U).ticks(d?8:4).tickSize(-R).tickFormat(pe(".2s")),C=be(z),F=Ni(I);const H=k.select("svg");H.node();const V=H.select(".plot-area").attr("fill","steelblue").attr("transform","translate("+_.left+","+_.top+")"),et=k.select("div#tooltip").style("opacity",0);V.select("g.yMale.axis").node()===null&&V.append("g").attr("class",`yMale axis ${Be["value-axis"]}`).call(C).attr("pointer-events","none"),V.select("g.xMale.axis").node()===null&&V.append("g").attr("class",`xMale axis ${Be["value-axis"]}`).attr("transform","translate(0,"+R+")").call(M).attr("pointer-events","none").selectAll(".tick").filter(A=>A===0).select("line").remove(),V.select("g.yFemale.axis").node()===null&&V.append("g").attr("class",`yFemale axis ${Be["value-axis"]}`).attr("transform","translate("+E+",0)").call(F).attr("pointer-events","none"),V.select("g.xFemale.axis").node()===null&&V.append("g").attr("class",`xFemale axis ${Be["value-axis"]}`).attr("transform","translate(0,"+R+")").call(Y).attr("pointer-events","none").selectAll(".tick").filter(A=>A===0).select("line").remove();const $=we(t),dt=["male","female"],pt=na().keys(dt).order(ui).offset(ea)($),_t=!(c||o),G=Gt(pt[0],function(A){return A.data.Total})??0,ot=Gt(pt[0],function(A){return A.data.male})??0;Dr(pt[0],function(A){return A.data.male});const O=Gt(pt[1],function(A){return A.data.female})??0;Dr(pt[1],function(A){return A.data.female});const Q=_t?Math.max(ot,O):G,X=(A,j)=>{const nt=pt[0].sort(i?function(W,K){const Ct=o?K.data.Total??0:K.data.male,Rt=o?W.data.Total??0:W.data.male;return Ct-Rt}:function(W,K){return j.indexOf(W.data.ageRange+"")-j.indexOf(K.data.ageRange+"")}).map(function(W){return W.data.ageRange+""});z.domain(nt);const
|
|
63
|
-
of ${pe(",d")(j.data.Total)} people)`}return`${A} ${j.data.ageRange} y.o: ${pe(",d")(j.data[A])}`})}},[t,r,a,i,o,c]);return m.jsxs("div",{ref:e,style:{width:r,height:a,display:"flex",flexDirection:"column"},children:[x,m.jsx("div",{className:`${Be.container}`,children:m.jsxs("span",{ref:h,className:`${Be.inner}`,style:{transform:`translateX(${o||c?60:(r-g)/2}px)`},children:[m.jsxs("p",{style:{display:o||c?"none":"block"},children:[pe(",d")(y)," male"]}),m.jsx(Vm,{}),m.jsx(Xm,{}),m.jsx("p",{children:o||c?`${pe(",d")(w)} people`:`${pe(",d")(T)} female`})]})}),m.jsxs("div",{ref:p,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsxs("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${r} ${a}`,children:[m.jsx("rect",{width:r,height:a,className:"bgRect opacity-0",style:{fill:"white"}}),m.jsx("g",{className:"plot-area"})]}),m.jsx(Qe,{})]})]})}Jr("%A"),Jr("%w"),Jr("%B");const Gm=t=>{const e=oo(t,n=>Xr(n.date));return Array.from(e.values()).map(n=>{const r=n[0],a=n[n.length-1],i=Dr(n,s=>s.volume);return{date:r.date,endDate:a.date,open:r.open,close:a.close,adj_close:a.adj_close,volumeOpen:r.volume,volumeClose:a.volume,volume:Math.round(i/n.length),hi:Gt(n,s=>s.hi),low:oe(n,s=>s.low)}})},Zm=t=>{const e=oo(t,n=>qa(n.date));return Array.from(e.values()).map(n=>{const r=n[0],a=n[n.length-1],i=Dr(n,s=>s.volume);return{date:r.date,endDate:a.date,open:r.open,close:a.close,adj_close:a.adj_close,volumeOpen:r.volume,volumeClose:a.volume,volume:Math.round(i/n.length),hi:Gt(n,s=>s.hi),low:oe(n,s=>s.low)}})};function Jm({data:t,timeframe:e="daily",mode:n="linechart",tooltipFormat:r={prefix:"",suffix:""}}){const[a,i]=Ne(),{width:s,height:o}=i,l=750,c=[t,e,n,s,o,r],u=qr,h=Object.keys(t[0]).filter(d=>d!=="date"&&d!=="volume"&&d!=="adj_close"),f={top:0,right:30,bottom:20,left:60},g=s>576,v={bullish:"#047857",bearish:"#be123c"},b=Se(d=>{if(s===0||o===0)return;const x=40,S=x+f.bottom,w=s-f.left-f.right,y=o-f.top-f.bottom,T=y-2*S,p=d.select("svg");p.node();const k=p.select(".plot-area").attr("transform","translate("+f.left+","+f.top+")");p.selectAll("defs").remove(),p.append("defs").append("clipPath").attr("id","clip").append("rect").attr("width",w>0?w:0).attr("height",y>0?y:0);const _=p.select(".volume-area").attr("transform","translate("+f.left+","+(T+f.top+f.bottom)+")"),E=p.select(".brush-area").attr("transform","translate("+f.left+","+(T+f.top+f.bottom+S)+")"),R=W=>{const K=Ac("%Y-%m-%d")(W.date);return{date:new Date(K||new Date),open:+W.open,hi:+W.hi,low:+W.low,close:+W.close,adj_close:+W.adj_close,volume:+W.volume}},z=t.map(W=>R(W)),I=e==="weekly"?Gm(z):[],N=e==="monthly"?Zm(z):[],U=e==="daily"?z:e==="weekly"?I:e==="monthly"?N:[],M=h.map(function(W){return{name:W,values:z.map(function(K){return{date:K.date,value:+K[W]}})}}),Y=fa(z,function(W){return W.date}),C=ti().domain(Y).range([0,w]),F=g?an.axisText:an.rotatedAxisText;k.select(".x-axis").attr("transform","translate(0,"+T+")").call(he(C)).selectAll("text").attr("class",F);const H=Gt(M,function(W){return Gt(W.values,function(K){return K.value})})||0,V=oe(M,function(W){return oe(W.values,function(K){return K.value})})||0,et=ye().domain([V,H]).range([T,0]),$=be(et).tickSize(-w);k.select(".y-axis").call($),k.selectAll("path.chartline").remove();const dt=Bn().x(function(W){return C(W.date)}).y(function(W){return et(W.value)});n==="linechart"&&M.forEach((W,K)=>{k.insert("path","g.tooltip").attr("class","chartline").datum(W.values).attr("fill","none").attr("stroke",u[K]).attr("stroke-width",1).attr("d",dt).attr("clip-path","url(#clip)")}),k.selectAll("path.candle").remove();const wt=W=>W.open>=W.close?v.bullish:v.bearish;n==="candlestick"&&k.selectAll("path.candle").data(U).join(W=>W.insert("path","g.tooltip").attr("class","candle").attr("d",function(K){return $t(K,et)}).style("fill",wt).attr("clip-path","url(#clip)"),void 0,W=>W.remove()).on("pointerenter",function(W,K){const{date:Ct,open:Rt,hi:q,low:Tt,close:ut,volume:vt}=K,At=qt(this).node()?.getBBox().width??0;Q({date:Ct,open:Rt,hi:q,low:Tt,close:ut,volume:vt}),O({xPos:C(Ct)+At/2,low:Tt,volume:vt})}).on("pointerleave",X).attr("d",function(W){return $t(W,et)}).style("fill",wt);const pt=k.select("g.tooltip").style("pointer-events","none"),_t=_.select("g.tooltip").style("pointer-events","none");k.select("rect.overlay").attr("width",w>0?w:0).attr("height",T>0?T:0).style("fill","none").style("pointer-events",n==="linechart"?"all":"none").on("pointerenter pointermove",ot).on("pointerleave",X).on("touchstart",W=>W.preventDefault());function G(W){return W.toLocaleString("en",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function ot(W){if(n==="candlestick")return;const K=n==="linechart"?z:U,Ct=Nr(Xt=>Xt.date).center,Rt=Ct(K,C.invert(tr(W)[0])),{date:q,open:Tt,hi:ut,low:vt,close:At,volume:jt}=K[Rt];Q({date:q,open:Tt,hi:ut,low:vt,close:At,volume:jt}),O({xPos:C(q),low:vt,volume:jt})}const O=W=>{const{xPos:K,low:Ct,volume:Rt}=W;pt.style("display",null),pt.attr("transform",`translate(${K},${et(Ct)})`),_t.style("display",null),_t.attr("transform",`translate(${K},${tt(Rt)})`)},Q=W=>{const{prefix:K,suffix:Ct}=r,{date:Rt,open:q,hi:Tt,low:ut,close:vt,volume:At}=W,jt=pt.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),Xt=pt.selectAll("text").data([null]).join("text").call(Wt=>Wt.selectAll("tspan").data([G(Rt),`open: ${Pe(q,{prefix:K,suffix:Ct})}`,`hi: ${Pe(Tt,{prefix:K,suffix:Ct})}`,`low: ${Pe(ut,{prefix:K,suffix:Ct})}`,`close: ${Pe(vt,{prefix:K,suffix:Ct})}`]).join("tspan").attr("x",0).attr("y",(te,ie)=>`${ie*1.1}em`).attr("font-weight",(te,ie)=>ie?null:"bold").style("align","right").text(te=>te));D(Xt,jt);const ae=_t.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),Zt=_t.selectAll("text").data([null]).join("text").call(Wt=>Wt.selectAll("tspan").data(["Trading Volume",Pe(At)]).join("tspan").attr("x",0).attr("y",(te,ie)=>`${ie*1.1}em`).attr("font-weight",(te,ie)=>ie?null:"bold").text(te=>te));D(Zt,ae),E.transition().duration(l/4).style("opacity",0)};function X(W){pt.style("display","none"),_t.style("display","none"),E.transition().duration(l/4).style("opacity",1)}function D(W,K){const{x:Ct,y:Rt,width:q,height:Tt}=W.node().getBBox();W.attr("transform",`translate(${-q/2},${15-Rt})`),K.attr("d",`M${-q/2-10},5H-5l5,-5l5,5H${q/2+10}v${Tt+20}h-${q+20}z`)}const tt=ye().domain([0,Gt(t,function(W){return typeof W.volume=="string"?parseInt(W.volume):W.volume})]).range([x,0]),L=js().x(function(W){return C(new Date(W.date))}).y0(tt(0)).y1(function(W){return tt(typeof W.volume=="string"?parseInt(W.volume):W.volume)});_.selectAll("path.area").remove(),_.insert("path","g.tooltip").datum(z).attr("class","area").attr("d",L).style("fill","lightgray").style("stroke","none").attr("clip-path","url(#clip)"),_.select(".x-axis").attr("transform","translate(0,"+x+")").call(he(C)).selectAll("text").attr("class",F);const Z=ti().domain(Y).range([0,w]),ft=ye().domain([V,H]).range([x,0]),st=Bn().x(function(W){return Z(W.date)}).y(function(W){return ft(W.value)});E.selectAll("path.line").remove(),E.selectAll("g.brush").remove(),n==="linechart"&&M.forEach((W,K)=>{E.append("path").attr("class","line").datum(W.values).attr("fill","none").attr("stroke",u[K]).attr("stroke-width",1).attr("d",st).attr("clip-path","url(#clip)")}),E.selectAll("path.candle").remove(),n==="candlestick"&&E.selectAll("path.candle").data(U).join(W=>W.insert("path","g.tooltip").attr("class","candle").attr("d",function(K){return $t(K,ft)}).style("fill",wt).attr("clip-path","url(#clip)"),void 0,W=>W.remove()).attr("d",function(W){return $t(W,ft)}).style("fill",wt),E.select(".x-axis").attr("transform","translate(0,"+x+")").call(he(Z)).selectAll("text").attr("class",F);const it=Sl().extent([[0,0],[s,x]]).on("brush",A);E.append("g").attr("class","brush").call(it);function A(W){const K=W.selection;K?C.domain([Z.invert(K[0]),Z.invert(K[1])]):(!K||K===null)&&C.domain(Y),j()}p.on("dblclick",function(){C.domain(Y),E.select(".brush").call(it.move,null),j()});const j=()=>{k.select(".x-axis").call(he(C)).selectAll("text").attr("class",F),n==="candlestick"?k.selectAll("path.candle").attr("d",function(W){return $t(W,et)}):n==="linechart"&&k.selectAll("path.chartline").attr("d",dt),_.select(".x-axis").call(he(C)).selectAll("text").attr("class",F),_.selectAll("path.area").attr("d",L)};function nt(){const W=C(U[1].date)-C(U[0].date),K=(W-W*.2)/2;return{barWidth:W,shoulderWidth:K}}function $t(W,K){let Ct,Rt;W.open>=W.close?(Ct=W.open,Rt=W.close):(Ct=W.close,Rt=W.open);const{barWidth:q,shoulderWidth:Tt}=nt();K(Ct)-K(Rt);const ut=K(W.hi)-K(Ct),vt=K(W.low)-K(Rt);return"M "+C(W.date)+","+K(Ct)+" "+(C(W.date)+Tt)+","+K(Ct)+" "+(C(W.date)+Tt)+","+(K(Ct)+ut)+" "+(C(W.date)+Tt+q*.2)+","+(K(Ct)+ut)+" "+(C(W.date)+Tt+q*.2)+","+K(Ct)+" "+(C(W.date)+q)+","+K(Ct)+" "+(C(W.date)+q)+","+K(Rt)+" "+(C(W.date)+Tt+q*.2)+","+K(Rt)+" "+(C(W.date)+Tt+q*.2)+","+(K(Rt)+vt)+" "+(C(W.date)+Tt)+","+(K(Rt)+vt)+" "+(C(W.date)+Tt)+","+K(Rt)+" "+C(W.date)+","+K(Rt)+"z"}},[...c,r]);return m.jsx("div",{ref:a,style:{width:s,height:o,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:b,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{className:`${J[g?"controls-container":"controls-container-sm"]}`,style:{gap:2,height:24},children:[n==="linechart"&&h.map((d,x)=>m.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"start",alignItems:"center"},children:[m.jsx("div",{style:{width:16,height:2.5,borderRadius:1,backgroundColor:u[x]}}),m.jsx("p",{style:{padding:0,margin:0},children:d})]},d)),n==="candlestick"&&["bullish","bearish"].map(d=>m.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:v[d],borderRadius:2.5,padding:"2px 3px"},children:m.jsx("p",{style:{color:"white",margin:0,padding:0},children:d})},d))]}),m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${s} ${o}`,children:s>0&&m.jsxs(m.Fragment,{children:[m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`x-axis ${an["time-axis"]}`}),m.jsx("g",{className:`y-axis ${an["value-axis"]}`}),m.jsx("rect",{className:"overlay"}),m.jsx("g",{className:"tooltip"})]}),m.jsxs("g",{className:"volume-area",children:[m.jsx("g",{className:`x-axis ${an["time-axis"]}`}),m.jsx("g",{className:"tooltip"})]}),m.jsx("g",{className:"brush-area",children:m.jsx("g",{className:`x-axis ${an["time-axis"]}`})})]})})]})})}function Qm({data:t,tooltipFormat:e}){const[n,r]=Ne(),{width:a,height:i}=r,[s,o]=bt.useState(null),[l,c]=bt.useState(!1),u=Math.min(a,i),h=u/2,f=S=>{const w=fr(S).sum(T=>T.value).sort((T,p)=>p.value-T.value),y=jg().size([2*Math.PI,w.height+1])(w);return y.each(T=>T.current={x0:T.x0,x1:T.x1,y0:T.y0,y1:T.y1}),y};bt.useEffect(()=>{(()=>{const w=f(t);o(w)})()},[t]);const g=rn(t.children?.map(S=>S.name)),v=ll($c,10),b=bt.useRef(hr().domain(g.current).range(v)),d=750,x=Se(S=>{if(a===0||i===0)return;const w=S.select("#tooltip").style("opacity",0);function y(G,ot=0,O={oldData:new Map,oldTarget:new Map}){const Q=typeof G.x0=="number"&&typeof G.x1=="number"&&typeof G.y0=="number"&&typeof G.y1=="number";return O.oldData.set(`${ot}-${G.data.name}`,Q?{x0:G.x0,x1:G.x1,y0:G.y0,y1:G.y1}:null),O.oldTarget.set(`${ot}-${G.data.name}`,G.target?{x0:G.target.x0,x1:G.target.x1,y0:G.target.y0,y1:G.target.y1}:null),G.children&&G.children.forEach(X=>y(X,ot+1,O)),O}function T(G,ot,O=0){const Q=`${O}-${G.data.name}`;if(typeof G.x0=="number"&&typeof G.x1=="number"&&typeof G.y0=="number"&&typeof G.y1=="number"){const D={oldData:ot.oldData.get(Q)??null,oldTarget:ot.oldTarget.get(Q)??null};G.oldRect=D}return G.children&&G.children.forEach(D=>T(D,ot,O+1)),G}function p(G,ot){if(!ot)return T(G,{oldData:new Map,oldTarget:new Map});const O=y(ot);return T(G,O)}const k=f(we(t)),_=s===null||k.data.name===s.data.name,E=p(k,_?void 0:s||void 0),R=E.height+1,z=h/R;let I=E;const N=si().startAngle(G=>G.x0).endAngle(G=>G.x1).padAngle(G=>Math.min((G.x1-G.x0)/2,.005)).padRadius(h*1.5).innerRadius(G=>G.y0*z).outerRadius(G=>Math.max(G.y0*z,G.y1*z-1)),M=(Math.max(a,i)-u)/2,Y=a>i?`translate(${M}, 0)`:`translate(0, ${M})`,C=S.select("svg").attr("transform",Y).style("font","10px sans-serif"),F=C.node(),H=C.select(".plot-area").style("fill-opacity",.6),V=C.select(".label-group").attr("pointer-events","none").attr("text-anchor","middle").style("user-select","none"),et="0 1px 0 lightblue, 1px 0 0 lightblue, -1px 0 0 lightblue, 0 -1px 0 lightblue",$=G=>{let ot=G;for(;ot.depth>1;)ot=ot.parent;const O=ot.data.name,Q=b.current(O),X=Ve(Q);if(!X)return Q;const D=G.depth,tt=.5;return D===1?X.formatHex():X.darker(D*tt).formatHex()};H.selectAll("path.slice").data(E.descendants(),function(G){return G.data.name}).join(G=>{const ot=G.append("path").attr("class","slice").attr("fill",$).style("cursor",function(O){return O.children?"pointer":"default"});return ot.transition().duration(d).attrTween("d",function(O){const Q={x0:O.current.x0,x1:O.current.x0,y0:O.current.y0,y1:O.current.y1},X=Ae(Q,{x0:O.x0,x1:O.x1,y0:O.y0,y1:O.y1});return function(D){return O.current=X(D),N(O.current)}}),ot},G=>G.transition().duration(d).attrTween("d",function(ot){const O=Ae(ot.oldRect?ot.oldRect.oldTarget?ot.oldRect.oldTarget:ot.oldRect.oldData:ot.current,{x0:ot.x0,x1:ot.x1,y0:ot.y0,y1:ot.y1});return function(Q){return ot.current=O(Q),N(ot.current)}}).attr("fill",$),G=>G.transition().duration(d).style("opacity",0).remove()).on("pointerenter",function(G,ot){V.selectAll("text.suntext").filter(X=>X.data.name===ot.data.name).style("fill-opacity",1).style("text-shadow",et);const O=ot.data.name==="branches"?"Total":ot.data.name;w.select("p.name").text(O);const Q=ot.value??0;w.select("p.value").text(Pe(Q,e).toLocaleString()),w.transition().duration(250).style("opacity",1),le(w,{e:G,svg:F})}).on("pointermove",function(G,ot){le(w,{e:G,svg:F})}).on("pointerleave",function(G,ot){V.selectAll("text.suntext").filter(O=>O.data.name===ot.data.name).style("fill-opacity",O=>pt(O)?1:0).style("text-shadow",O=>pt(O)?et:"none"),w.transition().duration(250).style("opacity",0)}).on("click",function(G,ot){ot.children&&wt(G,ot)}),C.select("circle.reset").remove();const dt=C.selectAll("circle").data([E]).join("circle").attr("class","reset").attr("r",z).attr("fill","transparent").attr("pointer-events","all").on("click",(G,ot)=>wt(G,ot));V.selectAll("text.suntext").data(E.descendants(),function(G){return G.data.name}).join(G=>G.append("text").attr("class","suntext").attr("dy","0.35em").style("fill-opacity",0).style("text-shadow","none").text(ot=>ot.data.name).transition().duration(d).style("fill-opacity",ot=>pt(ot)?1:0).style("text-shadow",ot=>pt(ot)?et:"none").attr("transform",_t),void 0,G=>G.transition().duration(d).style("opacity",0).remove()).transition().duration(d).style("fill-opacity",G=>pt(G)?1:0).style("text-shadow",G=>pt(G)?et:"none").attr("transform",_t).attr("dy","0.35em");function wt(G,ot,O=!1){const Q=ot;I=Q,dt.style("cursor",I===E?"default":"pointer"),dt.datum(O?E:Q.parent||E),E.each(X=>X.target={x0:Math.max(0,Math.min(1,(X.x0-Q.x0)/(Q.x1-Q.x0)))*2*Math.PI,x1:Math.max(0,Math.min(1,(X.x1-Q.x0)/(Q.x1-Q.x0)))*2*Math.PI,y0:Math.max(0,X.y0-Q.depth),y1:Math.max(0,X.y1-Q.depth)}),H.selectAll("path.slice").transition().duration(d).tween("data",X=>{const D=Ae(X.current,X.target);return tt=>X.current=D(tt)}).attrTween("d",X=>()=>N(X.current)??""),V.selectAll("text.suntext").transition().duration(d).tween("data",X=>{const D=Ae(X.current,X.target);return tt=>X.current=D(tt)}).style("fill-opacity",X=>pt(X)?1:0).style("text-shadow",X=>pt(X)?et:"none").attrTween("transform",X=>()=>_t(X.current)),o(E)}function pt(G){const ot=G.target??G.current,{x0:O,x1:Q,y0:X,y1:D}=ot,tt=Q-O,Z=(X+D)/2*tt;return I!==E&&G.ancestors().includes(I)?!0:D<=R&&X>=0&&tt>.003&&Z>.25}function _t(G){if(G.y0===0)return"translate(0,0)";const ot=(G.x0+G.x1)/2*180/Math.PI,O=(G.y0+G.y1)/2*z;return`
|
|
62
|
+
C33.866,22.047,34.065,22.609,34.539,22.862z`})]})}),Be={male:"_male_1piqt_1",maleTotal:"_maleTotal_1piqt_1",totalMale:"_totalMale_1piqt_25",female:"_female_1piqt_53",femaleTotal:"_femaleTotal_1piqt_53",totalFemale:"_totalFemale_1piqt_77","value-axis":"_value-axis_1piqt_113",container:"_container_1piqt_133",inner:"_inner_1piqt_143"};function Km({data:t}){const[e,n]=Ne(),{width:r,height:a}=n,[i,s]=bt.useState(!1),[o,l]=bt.useState(!1),[c,u]=bt.useState(!1),[h,f]=He(),{width:g,height:v}=f,b=500;bt.useEffect(()=>{c&&s(!1),l(c)},[c]),bt.useEffect(()=>{u(!1),s(!1),l(!1)},[t]);const d=r>576,x=m.jsxs("div",{className:`${J[d?"controls-container":"controls-container-sm"]}`,children:[m.jsxs("label",{className:`${J["controls-label"]} ${c?J.disabled:""}`,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:`${J["controls-checkbox"]}`,checked:i,onChange:k=>s(k.target.checked),disabled:c}),"Sort"]}),m.jsxs("label",{className:`${J["controls-label"]} ${c?J.disabled:""}`,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:o,onChange:k=>l(k.target.checked),disabled:c}),"By Total"]}),m.jsxs("label",{className:J["controls-label"],style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:c,onChange:k=>u(k.target.checked)}),"By Percentage"]})]}),S=t.reduce((k,_)=>(_.male=+_.male,_.female=+_.female,_.Total=_.male+_.female,{totalPeople:k.totalPeople+_.male+_.female,totalMale:k.totalMale+_.male,totalFemale:k.totalFemale+_.female}),{totalPeople:0,totalMale:0,totalFemale:0}),{totalPeople:w,totalMale:y,totalFemale:T}=S,p=Se(k=>{if(r===0||a===0)return;const _={top:0,right:d?0:15,bottom:30,left:d?0:15},E=r-_.left-_.right,R=a-_.top-_.bottom;let z=Xe().range([R,0]),I=Xe().range([R,0]),N=ye().rangeRound([0,E/2]),U=ye().rangeRound([E/2,E]),M=he(N).ticks(d?8:4).tickSize(-R).tickFormat(pe(c?"~%":".2s")),Y=he(U).ticks(d?8:4).tickSize(-R).tickFormat(pe(".2s")),C=be(z),F=Ni(I);const H=k.select("svg");H.node();const V=H.select(".plot-area").attr("fill","steelblue").attr("transform","translate("+_.left+","+_.top+")"),et=k.select("div#tooltip").style("opacity",0);V.select("g.yMale.axis").node()===null&&V.append("g").attr("class",`yMale axis ${Be["value-axis"]}`).call(C).attr("pointer-events","none"),V.select("g.xMale.axis").node()===null&&V.append("g").attr("class",`xMale axis ${Be["value-axis"]}`).attr("transform","translate(0,"+R+")").call(M).attr("pointer-events","none").selectAll(".tick").filter(A=>A===0).select("line").remove(),V.select("g.yFemale.axis").node()===null&&V.append("g").attr("class",`yFemale axis ${Be["value-axis"]}`).attr("transform","translate("+E+",0)").call(F).attr("pointer-events","none"),V.select("g.xFemale.axis").node()===null&&V.append("g").attr("class",`xFemale axis ${Be["value-axis"]}`).attr("transform","translate(0,"+R+")").call(Y).attr("pointer-events","none").selectAll(".tick").filter(A=>A===0).select("line").remove();const $=we(t),dt=["male","female"],pt=na().keys(dt).order(ui).offset(ea)($),_t=!(c||o),G=Gt(pt[0],function(A){return A.data.Total})??0,ot=Gt(pt[0],function(A){return A.data.male})??0;Dr(pt[0],function(A){return A.data.male});const O=Gt(pt[1],function(A){return A.data.female})??0;Dr(pt[1],function(A){return A.data.female});const Q=_t?Math.max(ot,O):G,X=(A,j)=>{const nt=pt[0].sort(i?function(W,K){const Ct=o?K.data.Total??0:K.data.male,Rt=o?W.data.Total??0:W.data.male;return Ct-Rt}:function(W,K){return j.indexOf(W.data.ageRange+"")-j.indexOf(K.data.ageRange+"")}).map(function(W){return W.data.ageRange+""});z.domain(nt);const Dt=pt[0].sort(i?function(W,K){const Ct=o?K.data.Total??0:K.data.female,Rt=o?W.data.Total??0:W.data.female;return Ct-Rt}:function(W,K){return j.indexOf(W.data.ageRange+"")-j.indexOf(K.data.ageRange+"")}).map(function(W){return W.data.ageRange+""});I.domain(Dt),A.select(".yMale.axis").transition().duration(b).call(C),A.select(".yFemale.axis").transition().duration(b).attr("transform","translate("+E+", 0)").call(F).style("opacity",_t?1:0)},D=(A,j,nt,Dt,W,K)=>{const Ct=_t?[K,0]:[0,c?1:K],Rt=_t?E/2:E;j.domain([...Ct]).rangeRound([0,Rt]).nice(),A.select(".xMale.axis").transition().duration(b).attr("transform","translate(0,"+R+")").call(nt).selectAll("text").style("text-anchor",d?"center":"end").attr("dx",function(q){return d?0:-12.8}),Dt.domain([0,K]).nice(),A.select(".xFemale.axis").transition().duration(b).attr("transform",`translate(0,${R})`).call(W).style("opacity",_t?1:0).selectAll("text").style("text-anchor",d?"center":"end").attr("dx",function(q){return d?0:-12.8})};let tt=[];tt.length===0&&(tt=$.map(function(A){return A.ageRange})),X(V,tt),D(V,N,M,U,Y,Q);const L=o&&!c?Be.maleTotal:Be.male,Z=A=>{if(!o)return"none";const j=N(A[1])-N(A[0]),nt=isNaN(j)?0:j,Dt=z.bandwidth();return`${nt} ${Dt} ${nt+Dt}`};V.selectAll(".maleBars").data(pt[0],function(A){return A.data.ageRange}).join(A=>A.append("rect").attr("class","maleBars "+L).attr("fill","#0099ff").attr("width",0).attr("x",E/2).attr("y",function(j){return z(j.data.ageRange)??0}).attr("height",z.bandwidth()).attr("stroke-dasharray",Z).call(j=>j.transition().duration(b).attr("x",function(nt){return N(_t?nt[1]:0)}).attr("width",function(nt,Dt){if(!_t){const K=c?nt[0]/nt.data.Total:nt[0],Ct=c?nt[1]/nt.data.Total:nt[1],Rt=N(Ct)-N(K);return isNaN(Rt)?0:Rt}const W=N(nt[0])-N(nt[1]);return isNaN(W)?0:W})),void 0,A=>A.remove()).on("pointerenter",function(A,j){o&&!c&&V.selectAll(".femaleBars").filter(nt=>nt.data.ageRange===j.data.ageRange).attr("class","femaleBars "+Be.totalFemale),V.select("g.yMale.axis").selectAll("text").filter(function(nt){return j.data.ageRange===nt}).style("font-weight","bold"),A.stopPropagation(),it("male",j),Dn(j,et)}).on("pointermove",function(A){A.stopPropagation(),Dn(A,et)}).on("pointerleave",function(A,j){V.select("g.yMale.axis").selectAll("text").filter(function(nt){return j.data.ageRange===nt}).style("font-weight","normal"),o&&!c&&V.selectAll(".femaleBars").filter(nt=>nt.data.ageRange===j.data.ageRange).attr("class","femaleBars "+Be.femaleTotal),et.style("opacity",0)}).attr("class","maleBars "+L).transition().duration(b).attr("stroke-dasharray",Z).attr("y",function(A,j){return z(A.data.ageRange)??0}).attr("height",z.bandwidth()).attr("x",function(A,j){return N(_t?A[1]:0)}).attr("width",function(A,j){if(!_t){const Dt=c?A[0]/A.data.Total:A[0],W=c?A[1]/A.data.Total:A[1],K=N(W)-N(Dt);return isNaN(K)?0:K}const nt=N(A[0])-N(A[1]);return isNaN(nt)?0:nt});const ft=o&&!c?Be.femaleTotal:Be.female,st=A=>{if(!o)return"none";const j=N(A[1])-N(A[0]),nt=isNaN(j)?0:j,Dt=I.bandwidth();return`${nt+Dt+nt} ${Dt}`};V.selectAll(".femaleBars").data(pt[1],function(A){return A.data.ageRange}).join(A=>A.append("rect").attr("class","femaleBars "+ft).attr("stroke-dasharray",st).attr("fill","#ff6699").attr("width",0).attr("x",function(j,nt){if(!_t){const Dt=c?j[0]/j.data.Total:j[0];return N(Dt)}return E/2}).attr("y",function(j,nt){return(_t?I:z)(j.data.ageRange)??0}).attr("height",I.bandwidth()).call(j=>j.transition().duration(b).attr("width",function(nt,Dt){if(!_t){const K=c?nt[0]/nt.data.Total:nt[0],Ct=c?nt[1]/nt.data.Total:nt[1],Rt=N(Ct)-N(K);return isNaN(Rt)?0:Rt}const W=U(nt[1])-U(nt[0]);return isNaN(W)?0:W})),void 0,A=>A.remove()).on("pointerenter",function(A,j){A.stopPropagation(),V.select("g.yFemale.axis").selectAll("text").filter(function(nt){return j.data.ageRange===nt}).style("font-weight","bold"),o&&!c&&V.selectAll(".maleBars").filter(nt=>nt.data.ageRange===j.data.ageRange).attr("class","maleBars "+Be.totalMale),it("female",j),Dn(j,et)}).on("pointermove",function(A){A.stopPropagation(),Dn(A,et)}).on("pointerleave",function(A,j){V.select("g.yFemale.axis").selectAll("text").filter(function(nt){return j.data.ageRange===nt}).style("font-weight","normal"),o&&!c&&V.selectAll(".maleBars").filter(nt=>nt.data.ageRange===j.data.ageRange).attr("class","maleBars "+Be.maleTotal),et.style("opacity",0)}).attr("class","femaleBars "+ft).transition().duration(b).attr("stroke-dasharray",st).attr("y",function(A,j){return(_t?I:z)(A.data.ageRange)??0}).attr("height",I.bandwidth()).attr("x",function(A,j){if(!_t){const nt=c?A[0]/A.data.Total:A[0];return N(nt)}return E/2}).attr("width",function(A,j){if(!_t){const Dt=c?A[0]/A.data.Total:A[0],W=c?A[1]/A.data.Total:A[1],K=N(W)-N(Dt);return isNaN(K)?0:K}const nt=U(A[1])-U(A[0]);return isNaN(nt)?0:nt});function it(A,j){et.style("opacity",1),et.select("p").text(function(){if(o&&!c)return`${j.data.ageRange} y.o: ${pe(",d")(j.data.Total)} people`;if(c){const nt=j.data[A]/j.data.Total;return`${pe(".1%")(nt)} (${pe(",d")(j.data[A])}
|
|
63
|
+
of ${pe(",d")(j.data.Total)} people)`}return`${A} ${j.data.ageRange} y.o: ${pe(",d")(j.data[A])}`})}},[t,r,a,i,o,c]);return m.jsxs("div",{ref:e,style:{width:r,height:a,display:"flex",flexDirection:"column"},children:[x,m.jsx("div",{className:`${Be.container}`,children:m.jsxs("span",{ref:h,className:`${Be.inner}`,style:{transform:`translateX(${o||c?60:(r-g)/2}px)`},children:[m.jsxs("p",{style:{display:o||c?"none":"block"},children:[pe(",d")(y)," male"]}),m.jsx(Vm,{}),m.jsx(Xm,{}),m.jsx("p",{children:o||c?`${pe(",d")(w)} people`:`${pe(",d")(T)} female`})]})}),m.jsxs("div",{ref:p,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsxs("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${r} ${a}`,children:[m.jsx("rect",{width:r,height:a,className:"bgRect opacity-0",style:{fill:"white"}}),m.jsx("g",{className:"plot-area"})]}),m.jsx(Qe,{})]})]})}Jr("%A"),Jr("%w"),Jr("%B");const Gm=t=>{const e=oo(t,n=>Xr(n.date));return Array.from(e.values()).map(n=>{const r=n[0],a=n[n.length-1],i=Dr(n,s=>s.volume);return{date:r.date,endDate:a.date,open:r.open,close:a.close,adj_close:a.adj_close,volumeOpen:r.volume,volumeClose:a.volume,volume:Math.round(i/n.length),hi:Gt(n,s=>s.hi),low:oe(n,s=>s.low)}})},Zm=t=>{const e=oo(t,n=>qa(n.date));return Array.from(e.values()).map(n=>{const r=n[0],a=n[n.length-1],i=Dr(n,s=>s.volume);return{date:r.date,endDate:a.date,open:r.open,close:a.close,adj_close:a.adj_close,volumeOpen:r.volume,volumeClose:a.volume,volume:Math.round(i/n.length),hi:Gt(n,s=>s.hi),low:oe(n,s=>s.low)}})};function Jm({data:t,timeframe:e="daily",mode:n="linechart",tooltipFormat:r={prefix:"",suffix:""}}){const[a,i]=Ne(),{width:s,height:o}=i,l=750,c=[t,e,n,s,o,r],u=qr,h=Object.keys(t[0]).filter(d=>d!=="date"&&d!=="volume"&&d!=="adj_close"),f={top:0,right:30,bottom:20,left:60},g=s>576,v={bullish:"#047857",bearish:"#be123c"},b=Se(d=>{if(s===0||o===0)return;const x=40,S=x+f.bottom,w=s-f.left-f.right,y=o-f.top-f.bottom,T=y-2*S,p=d.select("svg");p.node();const k=p.select(".plot-area").attr("transform","translate("+f.left+","+f.top+")");p.selectAll("defs").remove(),p.append("defs").append("clipPath").attr("id","clip").append("rect").attr("width",w>0?w:0).attr("height",y>0?y:0);const _=p.select(".volume-area").attr("transform","translate("+f.left+","+(T+f.top+f.bottom)+")"),E=p.select(".brush-area").attr("transform","translate("+f.left+","+(T+f.top+f.bottom+S)+")"),R=W=>{const K=Ac("%Y-%m-%d")(W.date);return{date:new Date(K||new Date),open:+W.open,hi:+W.hi,low:+W.low,close:+W.close,adj_close:+W.adj_close,volume:+W.volume}},z=t.map(W=>R(W)),I=e==="weekly"?Gm(z):[],N=e==="monthly"?Zm(z):[],U=e==="daily"?z:e==="weekly"?I:e==="monthly"?N:[],M=h.map(function(W){return{name:W,values:z.map(function(K){return{date:K.date,value:+K[W]}})}}),Y=fa(z,function(W){return W.date}),C=ti().domain(Y).range([0,w]),F=g?an.axisText:an.rotatedAxisText;k.select(".x-axis").attr("transform","translate(0,"+T+")").call(he(C)).selectAll("text").attr("class",F);const H=Gt(M,function(W){return Gt(W.values,function(K){return K.value})})||0,V=oe(M,function(W){return oe(W.values,function(K){return K.value})})||0,et=ye().domain([V,H]).range([T,0]),$=be(et).tickSize(-w);k.select(".y-axis").call($),k.selectAll("path.chartline").remove();const dt=Bn().x(function(W){return C(W.date)}).y(function(W){return et(W.value)});n==="linechart"&&M.forEach((W,K)=>{k.insert("path","g.tooltip").attr("class","chartline").datum(W.values).attr("fill","none").attr("stroke",u[K]).attr("stroke-width",1).attr("d",dt).attr("clip-path","url(#clip)")}),k.selectAll("path.candle").remove();const wt=W=>W.open>=W.close?v.bullish:v.bearish;n==="candlestick"&&k.selectAll("path.candle").data(U).join(W=>W.insert("path","g.tooltip").attr("class","candle").attr("d",function(K){return Dt(K,et)}).style("fill",wt).attr("clip-path","url(#clip)"),void 0,W=>W.remove()).on("pointerenter",function(W,K){const{date:Ct,open:Rt,hi:q,low:Tt,close:ut,volume:vt}=K,At=qt(this).node()?.getBBox().width??0;Q({date:Ct,open:Rt,hi:q,low:Tt,close:ut,volume:vt}),O({xPos:C(Ct)+At/2,low:Tt,volume:vt})}).on("pointerleave",X).attr("d",function(W){return Dt(W,et)}).style("fill",wt);const pt=k.select("g.tooltip").style("pointer-events","none"),_t=_.select("g.tooltip").style("pointer-events","none");k.select("rect.overlay").attr("width",w>0?w:0).attr("height",T>0?T:0).style("fill","none").style("pointer-events",n==="linechart"?"all":"none").on("pointerenter pointermove",ot).on("pointerleave",X).on("touchstart",W=>W.preventDefault());function G(W){return W.toLocaleString("en",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function ot(W){if(n==="candlestick")return;const K=n==="linechart"?z:U,Ct=Nr(Xt=>Xt.date).center,Rt=Ct(K,C.invert(tr(W)[0])),{date:q,open:Tt,hi:ut,low:vt,close:At,volume:jt}=K[Rt];Q({date:q,open:Tt,hi:ut,low:vt,close:At,volume:jt}),O({xPos:C(q),low:vt,volume:jt})}const O=W=>{const{xPos:K,low:Ct,volume:Rt}=W;pt.style("display",null),pt.attr("transform",`translate(${K},${et(Ct)})`),_t.style("display",null),_t.attr("transform",`translate(${K},${tt(Rt)})`)},Q=W=>{const{prefix:K,suffix:Ct}=r,{date:Rt,open:q,hi:Tt,low:ut,close:vt,volume:At}=W,jt=pt.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),Xt=pt.selectAll("text").data([null]).join("text").call(Ht=>Ht.selectAll("tspan").data([G(Rt),`open: ${Pe(q,{prefix:K,suffix:Ct})}`,`hi: ${Pe(Tt,{prefix:K,suffix:Ct})}`,`low: ${Pe(ut,{prefix:K,suffix:Ct})}`,`close: ${Pe(vt,{prefix:K,suffix:Ct})}`]).join("tspan").attr("x",0).attr("y",(te,ie)=>`${ie*1.1}em`).attr("font-weight",(te,ie)=>ie?null:"bold").style("align","right").text(te=>te));D(Xt,jt);const ae=_t.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),Zt=_t.selectAll("text").data([null]).join("text").call(Ht=>Ht.selectAll("tspan").data(["Trading Volume",Pe(At)]).join("tspan").attr("x",0).attr("y",(te,ie)=>`${ie*1.1}em`).attr("font-weight",(te,ie)=>ie?null:"bold").text(te=>te));D(Zt,ae),E.transition().duration(l/4).style("opacity",0)};function X(W){pt.style("display","none"),_t.style("display","none"),E.transition().duration(l/4).style("opacity",1)}function D(W,K){const{x:Ct,y:Rt,width:q,height:Tt}=W.node().getBBox();W.attr("transform",`translate(${-q/2},${15-Rt})`),K.attr("d",`M${-q/2-10},5H-5l5,-5l5,5H${q/2+10}v${Tt+20}h-${q+20}z`)}const tt=ye().domain([0,Gt(t,function(W){return typeof W.volume=="string"?parseInt(W.volume):W.volume})]).range([x,0]),L=js().x(function(W){return C(new Date(W.date))}).y0(tt(0)).y1(function(W){return tt(typeof W.volume=="string"?parseInt(W.volume):W.volume)});_.selectAll("path.area").remove(),_.insert("path","g.tooltip").datum(z).attr("class","area").attr("d",L).style("fill","lightgray").style("stroke","none").attr("clip-path","url(#clip)"),_.select(".x-axis").attr("transform","translate(0,"+x+")").call(he(C)).selectAll("text").attr("class",F);const Z=ti().domain(Y).range([0,w]),ft=ye().domain([V,H]).range([x,0]),st=Bn().x(function(W){return Z(W.date)}).y(function(W){return ft(W.value)});E.selectAll("path.line").remove(),E.selectAll("g.brush").remove(),n==="linechart"&&M.forEach((W,K)=>{E.append("path").attr("class","line").datum(W.values).attr("fill","none").attr("stroke",u[K]).attr("stroke-width",1).attr("d",st).attr("clip-path","url(#clip)")}),E.selectAll("path.candle").remove(),n==="candlestick"&&E.selectAll("path.candle").data(U).join(W=>W.insert("path","g.tooltip").attr("class","candle").attr("d",function(K){return Dt(K,ft)}).style("fill",wt).attr("clip-path","url(#clip)"),void 0,W=>W.remove()).attr("d",function(W){return Dt(W,ft)}).style("fill",wt),E.select(".x-axis").attr("transform","translate(0,"+x+")").call(he(Z)).selectAll("text").attr("class",F);const it=Sl().extent([[0,0],[s,x]]).on("brush",A);E.append("g").attr("class","brush").call(it);function A(W){const K=W.selection;K?C.domain([Z.invert(K[0]),Z.invert(K[1])]):(!K||K===null)&&C.domain(Y),j()}p.on("dblclick",function(){C.domain(Y),E.select(".brush").call(it.move,null),j()});const j=()=>{k.select(".x-axis").call(he(C)).selectAll("text").attr("class",F),n==="candlestick"?k.selectAll("path.candle").attr("d",function(W){return Dt(W,et)}):n==="linechart"&&k.selectAll("path.chartline").attr("d",dt),_.select(".x-axis").call(he(C)).selectAll("text").attr("class",F),_.selectAll("path.area").attr("d",L)};function nt(){const W=C(U[1].date)-C(U[0].date),K=(W-W*.2)/2;return{barWidth:W,shoulderWidth:K}}function Dt(W,K){let Ct,Rt;W.open>=W.close?(Ct=W.open,Rt=W.close):(Ct=W.close,Rt=W.open);const{barWidth:q,shoulderWidth:Tt}=nt();K(Ct)-K(Rt);const ut=K(W.hi)-K(Ct),vt=K(W.low)-K(Rt);return"M "+C(W.date)+","+K(Ct)+" "+(C(W.date)+Tt)+","+K(Ct)+" "+(C(W.date)+Tt)+","+(K(Ct)+ut)+" "+(C(W.date)+Tt+q*.2)+","+(K(Ct)+ut)+" "+(C(W.date)+Tt+q*.2)+","+K(Ct)+" "+(C(W.date)+q)+","+K(Ct)+" "+(C(W.date)+q)+","+K(Rt)+" "+(C(W.date)+Tt+q*.2)+","+K(Rt)+" "+(C(W.date)+Tt+q*.2)+","+(K(Rt)+vt)+" "+(C(W.date)+Tt)+","+(K(Rt)+vt)+" "+(C(W.date)+Tt)+","+K(Rt)+" "+C(W.date)+","+K(Rt)+"z"}},[...c,r]);return m.jsx("div",{ref:a,style:{width:s,height:o,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:b,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{className:`${J[g?"controls-container":"controls-container-sm"]}`,style:{gap:2,height:24},children:[n==="linechart"&&h.map((d,x)=>m.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"start",alignItems:"center"},children:[m.jsx("div",{style:{width:16,height:2.5,borderRadius:1,backgroundColor:u[x]}}),m.jsx("p",{style:{padding:0,margin:0},children:d})]},d)),n==="candlestick"&&["bullish","bearish"].map(d=>m.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:v[d],borderRadius:2.5,padding:"2px 3px"},children:m.jsx("p",{style:{color:"white",margin:0,padding:0},children:d})},d))]}),m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${s} ${o}`,children:s>0&&m.jsxs(m.Fragment,{children:[m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`x-axis ${an["time-axis"]}`}),m.jsx("g",{className:`y-axis ${an["value-axis"]}`}),m.jsx("rect",{className:"overlay"}),m.jsx("g",{className:"tooltip"})]}),m.jsxs("g",{className:"volume-area",children:[m.jsx("g",{className:`x-axis ${an["time-axis"]}`}),m.jsx("g",{className:"tooltip"})]}),m.jsx("g",{className:"brush-area",children:m.jsx("g",{className:`x-axis ${an["time-axis"]}`})})]})})]})})}function Qm({data:t,tooltipFormat:e}){const[n,r]=Ne(),{width:a,height:i}=r,[s,o]=bt.useState(null),[l,c]=bt.useState(!1),u=Math.min(a,i),h=u/2,f=S=>{const w=fr(S).sum(T=>T.value).sort((T,p)=>p.value-T.value),y=jg().size([2*Math.PI,w.height+1])(w);return y.each(T=>T.current={x0:T.x0,x1:T.x1,y0:T.y0,y1:T.y1}),y};bt.useEffect(()=>{(()=>{const w=f(t);o(w)})()},[t]);const g=rn(t.children?.map(S=>S.name)),v=ll($c,10),b=bt.useRef(hr().domain(g.current).range(v)),d=750,x=Se(S=>{if(a===0||i===0)return;const w=S.select("#tooltip").style("opacity",0);function y(G,ot=0,O={oldData:new Map,oldTarget:new Map}){const Q=typeof G.x0=="number"&&typeof G.x1=="number"&&typeof G.y0=="number"&&typeof G.y1=="number";return O.oldData.set(`${ot}-${G.data.name}`,Q?{x0:G.x0,x1:G.x1,y0:G.y0,y1:G.y1}:null),O.oldTarget.set(`${ot}-${G.data.name}`,G.target?{x0:G.target.x0,x1:G.target.x1,y0:G.target.y0,y1:G.target.y1}:null),G.children&&G.children.forEach(X=>y(X,ot+1,O)),O}function T(G,ot,O=0){const Q=`${O}-${G.data.name}`;if(typeof G.x0=="number"&&typeof G.x1=="number"&&typeof G.y0=="number"&&typeof G.y1=="number"){const D={oldData:ot.oldData.get(Q)??null,oldTarget:ot.oldTarget.get(Q)??null};G.oldRect=D}return G.children&&G.children.forEach(D=>T(D,ot,O+1)),G}function p(G,ot){if(!ot)return T(G,{oldData:new Map,oldTarget:new Map});const O=y(ot);return T(G,O)}const k=f(we(t)),_=s===null||k.data.name===s.data.name,E=p(k,_?void 0:s||void 0),R=E.height+1,z=h/R;let I=E;const N=si().startAngle(G=>G.x0).endAngle(G=>G.x1).padAngle(G=>Math.min((G.x1-G.x0)/2,.005)).padRadius(h*1.5).innerRadius(G=>G.y0*z).outerRadius(G=>Math.max(G.y0*z,G.y1*z-1)),M=(Math.max(a,i)-u)/2,Y=a>i?`translate(${M}, 0)`:`translate(0, ${M})`,C=S.select("svg").attr("transform",Y).style("font","10px sans-serif"),F=C.node(),H=C.select(".plot-area").style("fill-opacity",.6),V=C.select(".label-group").attr("pointer-events","none").attr("text-anchor","middle").style("user-select","none"),et="0 1px 0 lightblue, 1px 0 0 lightblue, -1px 0 0 lightblue, 0 -1px 0 lightblue",$=G=>{let ot=G;for(;ot.depth>1;)ot=ot.parent;const O=ot.data.name,Q=b.current(O),X=Ve(Q);if(!X)return Q;const D=G.depth,tt=.5;return D===1?X.formatHex():X.darker(D*tt).formatHex()};H.selectAll("path.slice").data(E.descendants(),function(G){return G.data.name}).join(G=>{const ot=G.append("path").attr("class","slice").attr("fill",$).style("cursor",function(O){return O.children?"pointer":"default"});return ot.transition().duration(d).attrTween("d",function(O){const Q={x0:O.current.x0,x1:O.current.x0,y0:O.current.y0,y1:O.current.y1},X=Ae(Q,{x0:O.x0,x1:O.x1,y0:O.y0,y1:O.y1});return function(D){return O.current=X(D),N(O.current)}}),ot},G=>G.transition().duration(d).attrTween("d",function(ot){const O=Ae(ot.oldRect?ot.oldRect.oldTarget?ot.oldRect.oldTarget:ot.oldRect.oldData:ot.current,{x0:ot.x0,x1:ot.x1,y0:ot.y0,y1:ot.y1});return function(Q){return ot.current=O(Q),N(ot.current)}}).attr("fill",$),G=>G.transition().duration(d).style("opacity",0).remove()).on("pointerenter",function(G,ot){V.selectAll("text.suntext").filter(X=>X.data.name===ot.data.name).style("fill-opacity",1).style("text-shadow",et);const O=ot.data.name==="branches"?"Total":ot.data.name;w.select("p.name").text(O);const Q=ot.value??0;w.select("p.value").text(Pe(Q,e).toLocaleString()),w.transition().duration(250).style("opacity",1),le(w,{e:G,svg:F})}).on("pointermove",function(G,ot){le(w,{e:G,svg:F})}).on("pointerleave",function(G,ot){V.selectAll("text.suntext").filter(O=>O.data.name===ot.data.name).style("fill-opacity",O=>pt(O)?1:0).style("text-shadow",O=>pt(O)?et:"none"),w.transition().duration(250).style("opacity",0)}).on("click",function(G,ot){ot.children&&wt(G,ot)}),C.select("circle.reset").remove();const dt=C.selectAll("circle").data([E]).join("circle").attr("class","reset").attr("r",z).attr("fill","transparent").attr("pointer-events","all").on("click",(G,ot)=>wt(G,ot));V.selectAll("text.suntext").data(E.descendants(),function(G){return G.data.name}).join(G=>G.append("text").attr("class","suntext").attr("dy","0.35em").style("fill-opacity",0).style("text-shadow","none").text(ot=>ot.data.name).transition().duration(d).style("fill-opacity",ot=>pt(ot)?1:0).style("text-shadow",ot=>pt(ot)?et:"none").attr("transform",_t),void 0,G=>G.transition().duration(d).style("opacity",0).remove()).transition().duration(d).style("fill-opacity",G=>pt(G)?1:0).style("text-shadow",G=>pt(G)?et:"none").attr("transform",_t).attr("dy","0.35em");function wt(G,ot,O=!1){const Q=ot;I=Q,dt.style("cursor",I===E?"default":"pointer"),dt.datum(O?E:Q.parent||E),E.each(X=>X.target={x0:Math.max(0,Math.min(1,(X.x0-Q.x0)/(Q.x1-Q.x0)))*2*Math.PI,x1:Math.max(0,Math.min(1,(X.x1-Q.x0)/(Q.x1-Q.x0)))*2*Math.PI,y0:Math.max(0,X.y0-Q.depth),y1:Math.max(0,X.y1-Q.depth)}),H.selectAll("path.slice").transition().duration(d).tween("data",X=>{const D=Ae(X.current,X.target);return tt=>X.current=D(tt)}).attrTween("d",X=>()=>N(X.current)??""),V.selectAll("text.suntext").transition().duration(d).tween("data",X=>{const D=Ae(X.current,X.target);return tt=>X.current=D(tt)}).style("fill-opacity",X=>pt(X)?1:0).style("text-shadow",X=>pt(X)?et:"none").attrTween("transform",X=>()=>_t(X.current)),o(E)}function pt(G){const ot=G.target??G.current,{x0:O,x1:Q,y0:X,y1:D}=ot,tt=Q-O,Z=(X+D)/2*tt;return I!==E&&G.ancestors().includes(I)?!0:D<=R&&X>=0&&tt>.003&&Z>.25}function _t(G){if(G.y0===0)return"translate(0,0)";const ot=(G.x0+G.x1)/2*180/Math.PI,O=(G.y0+G.y1)/2*z;return`
|
|
64
64
|
rotate(${ot-90})
|
|
65
65
|
translate(${O},0)
|
|
66
66
|
rotate(${ot<180?0:180})
|
|
@@ -68,14 +68,14 @@ React keys must be passed directly to JSX without using spread:
|
|
|
68
68
|
${vt}
|
|
69
69
|
${d!=="waterfall"&&d===ut?At:""}
|
|
70
70
|
legend-item
|
|
71
|
-
`};F.selectAll(".legend-item").data(["inflows","outflows"],ut=>ut).join(ut=>{const vt=ut.append("div").attr("class",V).style("left",(At,jt)=>`${jt*H}px`).style("top","-53px").style("opacity",0);return vt.append("div").attr("class",J["legend-rect"]).style("background",At=>At==="inflows"?me.inflows:me.outflows),vt.append("span").attr("class",J["legend-label"]).style("color",At=>"#333").text(At=>At),vt.transition().duration(_).style("top","0px").style("opacity",1),vt},ut=>(ut.attr("class",V).transition().duration(_).style("top","0px").style("left",(vt,At)=>`${At*H}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",vt=>vt==="inflows"?me.inflows:me.outflows),ut.select(`.${J["legend-label"]}`).style("color",vt=>"#333").text(vt=>vt),ut),ut=>ut.transition().duration(_).style("opacity",0).style("top","53px").remove()).on("mouseover",function(ut,vt){d==="waterfall"&&p.current&&(Y.selectAll("rect.bar").filter(At=>vt==="inflows"?At.type==="total"||At.start>At.end:At.type==="total"||At.start<=At.end).style("opacity",.5),Y.selectAll(".label").filter(At=>vt==="inflows"?At.type==="total"||At.start>At.end:At.type==="total"||At.start<At.end).style("opacity",.25))}).on("mouseout",function(ut,vt){d==="waterfall"&&p.current&&(Y.selectAll(".bar").style("opacity",1),Y.selectAll(".label").style("opacity",Ct))}).on("click",function(ut,vt){x(d===vt?"waterfall":vt)});const et=hi(R).style("opacity",0),$=v-z.left-z.right,dt=b-z.top-z.bottom,wt=N.map((ut,vt)=>{const At=vt===N.length-1;return Math.min(ut.start,At?ut.value:ut.end)}),pt=N.map((ut,vt)=>{const At=vt===N.length-1;return Math.max(ut.start,At?ut.value:ut.end)}),_t=d==="waterfall"?Math.min(...wt):0,G=Math.max(...d==="waterfall"?pt:N.map(ut=>Math.abs(ut.value))),ot=ye().domain([_t,G]).rangeRound([dt,0]).nice(),O=be(ot).ticks(5,"s").tickSize(-$);Y.select(".y-axis").attr("transform","translate(0, 0)").transition().duration(_).call(O);const Q=N.map(ut=>ut.label),X=Xe().domain(Q).rangeRound([0,$]).paddingInner(k?.4:.25).paddingOuter(.1),D=he(X).tickValues(X.domain()).scale(X).tickSizeOuter(0),L=di(v,Q)?`${J.rotatedAxisText} ${xe["axis-label-sm"]}`:`${J.axisText} ${xe["axis-label"]}`;Y.select(".x-axis").transition().duration(_).call(D).attr("transform",`translate(0, ${dt})`).selectAll("text").attr("class",`${L}`),Y.select(".x-axis").selectAll("path").style("display","none"),Y.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",$).attr("y2",0).transition().duration(_).attr("transform",`translate(0, ${ot(0)||0})`);function Z(ut){return X(ut.label)??0}function ft(ut,vt){return d==="waterfall"?ut.type==="total"&&vt>0?ut.start<=ut.end?ot(ut.value):ot(0):ot(Math.max(ut.start,ut.end)):ot(Math.abs(ut.value))}function st(ut,vt){if(d==="waterfall"){const At=Math.abs(ot(ut.start)-ot(ut.end));if(ut.type==="total"&&vt>0)if(ut.start<=ut.end){const jt=ot(0)-ot(ut.value);return jt<0?At:jt}else return ot(0)-ot(-ut.value);return At}return ot(0)-ot(Math.abs(ut.value))}function it(ut){return ut.start<=ut.end?me.inflows:me.outflows}const A=300,j=Y.selectAll(".bar").data(N,ut=>ut.label).join(ut=>ut.append("rect").attr("class",`bar ${J.bar}`).attr("x",Z).attr("width",X.bandwidth()).attr("y",(vt,At)=>y.current==="data"?vt.type==="total"?ot(0):ot(vt.start):ot(0)).attr("height",0).attr("rx",5).attr("ry",5).style("fill",it).transition().duration(A).delay((vt,At)=>0).attr("y",ft).attr("height",st).on("end",function(vt,At){y.current==="data"&&d==="waterfall"?At===I.length-1&&(p.current=!0):p.current=!0}),ut=>(d==="waterfall"&&y.current==="data"?ut.transition().duration(_).style("fill",it).attr("x",Z).attr("width",X.bandwidth()).attr("y",vt=>vt.type==="total"?ot(0):ot(vt.start)).attr("height",0).attr("rx",5).attr("ry",5).transition().duration(_).attr("y",ft).attr("height",st).on("end",function(vt,At){y.current==="data"&&d==="waterfall"?At===I.length-1&&(p.current=!0):p.current=!0}):ut.transition().duration(_).style("fill",it).attr("x",Z).attr("width",X.bandwidth()).attr("y",ft).attr("height",st).on("end",function(vt,At){p.current=!0}),ut),ut=>ut.transition().duration(_).style("opacity",0).remove()),nt={formatType:a,prefix:n,suffix:r};j.on("pointerenter",function(ut,vt){et.select("p.label span.label span.chev").style("color",vt.value>=0?me.inflows:me.outflows).text(vt.value>0?"▲":vt.value<0?"▼":""),et.select("p.label span.label span.text").text(vt.label+" :"),et.select("p.label span.value").text(_e(vt.value,nt)),vt.type==="total"?(et.select("p.from").style("display","none"),et.select("p.to").style("display","none")):d==="waterfall"?(et.select("p.from").style("display","flex"),et.select("p.from span.label").text("from: "),et.select("p.from span.value").text(_e(vt.start,nt)),et.select("p.to").style("display","flex"),et.select("p.to span.label").text("to: "),et.select("p.to span.value").text(_e(vt.end,nt))):(et.select("p.from").style("display","none"),et.select("p.to").style("display","none")),et.style("opacity",1),le(et,{e:ut,svg:M})}).on("pointermove",function(ut,vt){le(et,{e:ut,svg:M})}).on("pointerleave",function(ut,vt){et.style("opacity",0)});const
|
|
71
|
+
`};F.selectAll(".legend-item").data(["inflows","outflows"],ut=>ut).join(ut=>{const vt=ut.append("div").attr("class",V).style("left",(At,jt)=>`${jt*H}px`).style("top","-53px").style("opacity",0);return vt.append("div").attr("class",J["legend-rect"]).style("background",At=>At==="inflows"?me.inflows:me.outflows),vt.append("span").attr("class",J["legend-label"]).style("color",At=>"#333").text(At=>At),vt.transition().duration(_).style("top","0px").style("opacity",1),vt},ut=>(ut.attr("class",V).transition().duration(_).style("top","0px").style("left",(vt,At)=>`${At*H}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",vt=>vt==="inflows"?me.inflows:me.outflows),ut.select(`.${J["legend-label"]}`).style("color",vt=>"#333").text(vt=>vt),ut),ut=>ut.transition().duration(_).style("opacity",0).style("top","53px").remove()).on("mouseover",function(ut,vt){d==="waterfall"&&p.current&&(Y.selectAll("rect.bar").filter(At=>vt==="inflows"?At.type==="total"||At.start>At.end:At.type==="total"||At.start<=At.end).style("opacity",.5),Y.selectAll(".label").filter(At=>vt==="inflows"?At.type==="total"||At.start>At.end:At.type==="total"||At.start<At.end).style("opacity",.25))}).on("mouseout",function(ut,vt){d==="waterfall"&&p.current&&(Y.selectAll(".bar").style("opacity",1),Y.selectAll(".label").style("opacity",Ct))}).on("click",function(ut,vt){x(d===vt?"waterfall":vt)});const et=hi(R).style("opacity",0),$=v-z.left-z.right,dt=b-z.top-z.bottom,wt=N.map((ut,vt)=>{const At=vt===N.length-1;return Math.min(ut.start,At?ut.value:ut.end)}),pt=N.map((ut,vt)=>{const At=vt===N.length-1;return Math.max(ut.start,At?ut.value:ut.end)}),_t=d==="waterfall"?Math.min(...wt):0,G=Math.max(...d==="waterfall"?pt:N.map(ut=>Math.abs(ut.value))),ot=ye().domain([_t,G]).rangeRound([dt,0]).nice(),O=be(ot).ticks(5,"s").tickSize(-$);Y.select(".y-axis").attr("transform","translate(0, 0)").transition().duration(_).call(O);const Q=N.map(ut=>ut.label),X=Xe().domain(Q).rangeRound([0,$]).paddingInner(k?.4:.25).paddingOuter(.1),D=he(X).tickValues(X.domain()).scale(X).tickSizeOuter(0),L=di(v,Q)?`${J.rotatedAxisText} ${xe["axis-label-sm"]}`:`${J.axisText} ${xe["axis-label"]}`;Y.select(".x-axis").transition().duration(_).call(D).attr("transform",`translate(0, ${dt})`).selectAll("text").attr("class",`${L}`),Y.select(".x-axis").selectAll("path").style("display","none"),Y.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",$).attr("y2",0).transition().duration(_).attr("transform",`translate(0, ${ot(0)||0})`);function Z(ut){return X(ut.label)??0}function ft(ut,vt){return d==="waterfall"?ut.type==="total"&&vt>0?ut.start<=ut.end?ot(ut.value):ot(0):ot(Math.max(ut.start,ut.end)):ot(Math.abs(ut.value))}function st(ut,vt){if(d==="waterfall"){const At=Math.abs(ot(ut.start)-ot(ut.end));if(ut.type==="total"&&vt>0)if(ut.start<=ut.end){const jt=ot(0)-ot(ut.value);return jt<0?At:jt}else return ot(0)-ot(-ut.value);return At}return ot(0)-ot(Math.abs(ut.value))}function it(ut){return ut.start<=ut.end?me.inflows:me.outflows}const A=300,j=Y.selectAll(".bar").data(N,ut=>ut.label).join(ut=>ut.append("rect").attr("class",`bar ${J.bar}`).attr("x",Z).attr("width",X.bandwidth()).attr("y",(vt,At)=>y.current==="data"?vt.type==="total"?ot(0):ot(vt.start):ot(0)).attr("height",0).attr("rx",5).attr("ry",5).style("fill",it).transition().duration(A).delay((vt,At)=>0).attr("y",ft).attr("height",st).on("end",function(vt,At){y.current==="data"&&d==="waterfall"?At===I.length-1&&(p.current=!0):p.current=!0}),ut=>(d==="waterfall"&&y.current==="data"?ut.transition().duration(_).style("fill",it).attr("x",Z).attr("width",X.bandwidth()).attr("y",vt=>vt.type==="total"?ot(0):ot(vt.start)).attr("height",0).attr("rx",5).attr("ry",5).transition().duration(_).attr("y",ft).attr("height",st).on("end",function(vt,At){y.current==="data"&&d==="waterfall"?At===I.length-1&&(p.current=!0):p.current=!0}):ut.transition().duration(_).style("fill",it).attr("x",Z).attr("width",X.bandwidth()).attr("y",ft).attr("height",st).on("end",function(vt,At){p.current=!0}),ut),ut=>ut.transition().duration(_).style("opacity",0).remove()),nt={formatType:a,prefix:n,suffix:r};j.on("pointerenter",function(ut,vt){et.select("p.label span.label span.chev").style("color",vt.value>=0?me.inflows:me.outflows).text(vt.value>0?"▲":vt.value<0?"▼":""),et.select("p.label span.label span.text").text(vt.label+" :"),et.select("p.label span.value").text(_e(vt.value,nt)),vt.type==="total"?(et.select("p.from").style("display","none"),et.select("p.to").style("display","none")):d==="waterfall"?(et.select("p.from").style("display","flex"),et.select("p.from span.label").text("from: "),et.select("p.from span.value").text(_e(vt.start,nt)),et.select("p.to").style("display","flex"),et.select("p.to span.label").text("to: "),et.select("p.to span.value").text(_e(vt.end,nt))):(et.select("p.from").style("display","none"),et.select("p.to").style("display","none")),et.style("opacity",1),le(et,{e:ut,svg:M})}).on("pointermove",function(ut,vt){le(et,{e:ut,svg:M})}).on("pointerleave",function(ut,vt){et.style("opacity",0)});const Dt=12;function W(ut,vt){const At=ft(ut,vt),jt=st(ut,vt);return At+jt/2+Dt/2}function K(ut,vt){const At=Z(ut),jt=X.bandwidth();return At+jt/2}function Ct(ut,vt){return st(ut,vt)<20?0:1}const Rt=Y.selectAll(".label").data(N,ut=>ut.label).join(ut=>ut.append("text").attr("class",`label ${xe.label}`).text(vt=>pe("~s")(d!=="waterfall"?Math.abs(vt.value):vt.value)).attr("text-anchor","middle").style("font-size",Dt).style("font-weight","bold").style("pointer-events","none").style("opacity",0).attr("x",K).attr("y",W).transition().duration(_).style("opacity",Ct).attr("x",K).attr("y",W),ut=>ut.attr("class",`label ${xe.label}`).text(vt=>pe("~s")(d!=="waterfall"?Math.abs(vt.value):vt.value)).attr("text-anchor","middle").style("font-size",Dt).style("font-weight","bold").transition().duration(_).style("opacity",Ct).attr("x",K).attr("y",W),ut=>ut.transition().duration(_).style("opacity",0).remove()),q=N.map((ut,vt)=>({label:ut.label,value:d!=="waterfall"?Math.abs(ut.value):vt!==N.length-1?ut.end:ut.value})),Tt=d==="waterfall"?"#2b2b22":me[d];aa(Y,{scale:X,offset:X.bandwidth()/2},ot,{data:q},v,e,{showLine:i,showDots:s,curve:o,dotFill:Tt}),Rt.raise()},[t,v,b,e,d,{showLine:i,showDots:s,curve:o},S,{prefix:n,suffix:r,formatType:a}]);return m.jsx("div",{ref:l,style:{width:u,height:h,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:E,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{className:`controls ${J[k?"controls-container":"controls-container-sm"]}`,children:[m.jsxs("label",{className:`
|
|
72
72
|
${J["controls-label"]}
|
|
73
73
|
${xe.sort}
|
|
74
74
|
${d!=="waterfall"?xe.visible:""}
|
|
75
75
|
`,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:S,onChange:R=>w(R.target.checked)}),"Sort"]}),m.jsx("div",{className:`legends-container ${J["legends-container"]}`})]}),m.jsxs("div",{ref:f,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${v} ${b}`,children:m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`${J["value-axis"]} y-axis`}),m.jsx("g",{className:`${xe["x-axis"]} x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})}),m.jsx(ju,{})]})]})})}function tv({data:t,tooltipFormat:{prefix:e="",suffix:n="",formatType:r="long"}={prefix:"",suffix:"",formatType:"long"},lineProps:{showLine:a=!1,showDots:i=!0,curve:s="linear"}={showLine:!1,showDots:!0,curve:"linear"}}){const[o,l]=Ne(),{width:c,height:u}=l,[h,f]=He(),{width:g,height:v}=f,[b,d]=bt.useState(-1),[x,S]=bt.useState(!1),w=bt.useRef("data"),y=bt.useRef(!0),T=bt.useRef(!0),[p,k]=bt.useState(""),_=bt.useRef(t);bt.useEffect(()=>{T.current?T.current=!1:w.current="mode"},[p]),bt.useEffect(()=>{_.current=t,d(-1),k(""),S(!1),w.current="dataS"},[t]);const E=_.current!==t?-1:b,R=g>576,z=750,I=Se(U=>{if(g===0||v===0)return;const M={top:40,right:50,bottom:50,left:50},Y=t.map(ct=>({label:ct.label,data:Pu(ct.data)})),C=Y.map(ct=>{const P=ct.data.find(ht=>ht.label==="Opening"),at=P||ct.data[0];return{label:ct.label,data:{...at,label:"Opening "}}}),F=p!=="inflows"&&p!=="outflows"?E===-1?C:[C[E]]:[];F.sort((ct,P)=>p==="open"&&x?P.data.value-ct.data.value:0);const H=Y.map(ct=>{const P=ct.data.find(ht=>ht.label==="Closing"),at=P||ct.data[ct.data.length-1];return{label:ct.label,data:{...at,label:"Closing"}}}),V=p!=="inflows"&&p!=="outflows"?E===-1?H:[H[E]]:[];V.sort((ct,P)=>p==="close"&&x?P.data.value-ct.data.value:0);const et=["open","close"],$=U.select("svg"),dt=$.node(),wt=$.select(".plot-area").attr("transform","translate("+M.left+","+M.top+")"),_t=U.select(".controls").select(".legends-container"),G=E===-1?["open","close"]:["open","inflows","outflows","close"],ot=60,O=function(ct){const P=J[R?"legend-container":"legend-container-sm"],at=J[R?"legend-container-active":"legend-container-active-sm"],ht=J[R?"legend-container-inactive":"legend-container-inactive-sm"];return`
|
|
76
76
|
${p!==""?p===ct?at:ht:P}
|
|
77
77
|
legend-item
|
|
78
|
-
`};_t.selectAll(".legend-item").data([...G],ct=>ct).join(ct=>{const P=ct.append("div").attr("class",O).style("left",(at,ht)=>`${ht*ot}px`).style("top","-53px").style("opacity",0);return P.append("div").attr("class",J["legend-rect"]).style("background",at=>me[at]),P.append("span").attr("class",J["legend-label"]).text(at=>at),P.transition().duration(z).style("top","0px").style("opacity",1),P},ct=>(ct.attr("class",O).transition().duration(z).style("top","0px").style("left",(P,at)=>`${at*ot}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",P=>me[P]),ct.select(`.${J["legend-label"]}`).text(P=>P),ct),ct=>ct.transition().duration(z).style("opacity",0).style("top","53px").remove().remove()).on("click",(ct,P)=>{(P==="open"||P==="close")&&d(-1);const at=p===P?"":P;at===""&&S(!1),k(at)});const X=g-M.left-M.right,D=v-M.top-M.bottom,tt=F.map(ct=>ct?.data.value),L=V.map(ct=>ct?.data.value),Z=[...tt,...L],ft=E===-1?null:Y[E],st=ft?ft.data:[],it=st.map((ct,P)=>{const at=P===st.length-1;return Math.min(ct.start,at?ct.value:ct.end)}),A=st.map((ct,P)=>{const at=P===st.length-1;return Math.max(ct.start,at?ct.value:ct.end)}),j=p==="inflows"||p==="outflows"?p:"waterfall",nt=st.filter(ct=>ct.type!=="total")
|
|
78
|
+
`};_t.selectAll(".legend-item").data([...G],ct=>ct).join(ct=>{const P=ct.append("div").attr("class",O).style("left",(at,ht)=>`${ht*ot}px`).style("top","-53px").style("opacity",0);return P.append("div").attr("class",J["legend-rect"]).style("background",at=>me[at]),P.append("span").attr("class",J["legend-label"]).text(at=>at),P.transition().duration(z).style("top","0px").style("opacity",1),P},ct=>(ct.attr("class",O).transition().duration(z).style("top","0px").style("left",(P,at)=>`${at*ot}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",P=>me[P]),ct.select(`.${J["legend-label"]}`).text(P=>P),ct),ct=>ct.transition().duration(z).style("opacity",0).style("top","53px").remove().remove()).on("click",(ct,P)=>{(P==="open"||P==="close")&&d(-1);const at=p===P?"":P;at===""&&S(!1),k(at)});const X=g-M.left-M.right,D=v-M.top-M.bottom,tt=F.map(ct=>ct?.data.value),L=V.map(ct=>ct?.data.value),Z=[...tt,...L],ft=E===-1?null:Y[E],st=ft?ft.data:[],it=st.map((ct,P)=>{const at=P===st.length-1;return Math.min(ct.start,at?ct.value:ct.end)}),A=st.map((ct,P)=>{const at=P===st.length-1;return Math.max(ct.start,at?ct.value:ct.end)}),j=p==="inflows"||p==="outflows"?p:"waterfall",nt=st.filter(ct=>ct.type!=="total"),Dt=j==="waterfall"?nt:nt.filter(ct=>j==="inflows"?ct.start<=ct.end:ct.start>ct.end).sort((ct,P)=>x?Math.abs(P.value)-Math.abs(ct.value):0),W=j==="waterfall"?Math.min(...it):0,K=Math.max(...j==="waterfall"?A:Dt.map(ct=>Math.abs(ct.value))),Ct=Math.min(0,oe(Z)??0),Rt=Math.max(0,Gt(Z)??0),q=ye().domain(E===-1?[Ct,Rt]:[W,K]).range([D,0]).nice(),Tt=be(q).ticks(5,"s").tickSize(-X);wt.select(".y-axis").attr("transform","translate(0, 0)").transition().duration(z).call(Tt);const ut=p==="open"&&x?F.map(ct=>ct.label):p==="close"&&x?V.map(ct=>ct.label):Y.map(ct=>ct.label),vt=j==="waterfall"?st.map(ct=>ct.label==="Opening"?"open":ct.label==="Closing"?"close":ct.label):Dt.map(ct=>ct.label),At=E===-1?ut:vt,jt=Xe().domain(At).rangeRound([0,X]).padding(.2),Xt=he(jt).tickValues(jt.domain()).scale(jt).tickSizeOuter(0),ae=Xe().domain(et).range([0,jt.bandwidth()]).padding(.05),te=`${di(g,At)?`${J.rotatedAxisText} ${xe["axis-label-sm"]}`:`${J.axisText} ${xe["axis-label"]}`} ${xe["clickable-label"]}`;wt.select(".x-axis").transition().duration(z).call(Xt).attr("transform",`translate(0, ${D})`).selectAll("text").attr("class",`${te}`),wt.select(".x-axis").selectAll("path").style("display","none"),wt.select(".x-axis").selectAll("text").on("click",function(ct,P){b===-1&&(d(ut.indexOf(P)),k(""),S(!1))}),wt.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",X).attr("y2",0).transition().duration(z).attr("transform",`translate(0, ${q(0)||0})`);const ie=12,rt=({labelData:ct,xPos:P,barWidth:at,yPos:ht,barHeight:Lt,labelFor:$t})=>{const zt=ct[0]&&"data"in ct[0]?"openClose":"waterfall";function Yt(Bt,Kt){return P(Bt,Kt)+at/2}function Ot(Bt,Kt){const Ge=ht(Bt,Kt),Ze=Lt(Bt,Kt);return Ge+Ze/2+ie/2}function Jt(Bt,Kt){return p==="open"&&$t==="close"||p==="close"&&$t==="open"?0:Lt(Bt,Kt)>=20&&at>=20?1:0}const ge=Bt=>{const Kt=zt==="openClose"?Bt.data.value:Bt.value;return pe("~s")(j!=="waterfall"?Math.abs(Kt):Kt)},Et=$t?`${$t}label`:"label";return wt.selectAll(`.${Et}`).data(ct,Bt=>Bt?.label+`${$t?"-"+$t:""}`).join(Bt=>Bt.append("text").attr("class",`${Et} ${xe.label}`).text(ge).attr("text-anchor","middle").style("font-size",ie).style("font-weight","bold").style("pointer-events","none").style("opacity",0).attr("x",Yt).attr("y",q(0)).transition().duration(z).style("opacity",Jt).attr("x",Yt).attr("y",Ot),Bt=>Bt.attr("class",`${Et} ${xe.label}`).text(ge).attr("text-anchor","middle").style("font-size",ie).style("font-weight","bold").transition().duration(z).style("opacity",Jt).attr("x",Yt).attr("y",Ot),Bt=>Bt.remove())},gt=(ct,P)=>E===-1?(jt(ct.label)??0)+(ae(P)??0):jt(P)??0,kt=E===-1&&p!=="open"&&p!=="close"?ae.bandwidth():jt.bandwidth(),Wt=(ct,P)=>gt(ct,"open"),xt=(ct,P)=>E===-1?ct.data.value>=0?q(ct.data.value):q(0):q(Math.max(ct.data.start,ct.data.end)),Nt=(ct,P)=>Math.abs(E===-1?q(ct.data.value)-q(0):q(ct.data.start)-q(ct.data.end)),B=wt.selectAll("rect.open").data(F,ct=>ct?.label||" - open").join(ct=>ct.append("rect").attr("class",`open ${J.bar}`).attr("fill",me.open).attr("y",q(0)??0).attr("height",0).attr("x",Wt).attr("width",kt),void 0,ct=>ct.remove());B.transition().duration(z).attr("x",Wt).attr("width",kt).attr("y",xt).attr("height",Nt).style("opacity",p!=="close"?1:0).style("pointer-events",p!=="close"?"auto":"none"),rt({labelData:F,xPos:Wt,barWidth:kt,yPos:xt,barHeight:Nt,labelFor:"open"});const mt=(ct,P)=>gt(ct,p==="close"?"open":"close"),Mt=(ct,P)=>E===-1?ct.data.value>=0?q(ct.data.value):q(0):ct.data.start<=ct.data.end?q(ct.data.value):q(0),Pt=(ct,P)=>{if(E===-1)return Math.abs(q(ct.data.value)-q(0));{const at=Math.abs(q(ct.data.start)-q(ct.data.end));if(ct.data.start<=ct.data.end){const ht=q(0)-q(ct.data.value);return ht<0?at:ht}else return q(0)-q(-ct.data.value)}},ee=wt.selectAll("rect.close").data(V,ct=>ct?.label||" - close").join(ct=>ct.append("rect").attr("class",`close ${J.bar}`).attr("fill",me.close).attr("y",q(0)).attr("height",0).attr("x",mt).attr("width",kt),void 0,ct=>ct.remove());ee.transition().duration(z).attr("x",mt).attr("width",kt).attr("y",Mt).attr("height",Pt).attr("fill","orange").style("opacity",p!=="open"?1:0).style("pointer-events",p!=="open"?"auto":"none"),rt({labelData:V,xPos:mt,barWidth:kt,yPos:Mt,barHeight:Pt,labelFor:"close"});function re(ct){return jt(ct.label)??0}function lt(ct,P){return j==="waterfall"?ct.type==="total"&&P>0?ct.start<=ct.end?q(ct.value):q(0):q(Math.max(ct.start,ct.end)):q(Math.abs(ct.value))}function yt(ct,P){if(j==="waterfall"){const at=Math.abs(q(ct.start)-q(ct.end));if(ct.type==="total"&&P>0)if(ct.start<=ct.end){const ht=q(0)-q(ct.value);return ht<0?at:ht}else return q(0)-q(-ct.value);return at}return q(0)-q(Math.abs(ct.value))}function St(ct){return ct.start<=ct.end?me.inflows:me.outflows}const Ft=wt.selectAll(".bar").data(Dt,ct=>ct.label).join(ct=>ct.append("rect").attr("class",`bar ${J.bar}`).attr("x",re).attr("width",jt.bandwidth()).attr("y",(P,at)=>w.current==="data"?P.type==="total"?q(0):q(P.start):q(0)).attr("height",0).attr("rx",5).attr("ry",5).style("fill",St).transition().duration(z).attr("y",lt).attr("height",yt).on("end",function(P,at){w.current==="data"&&j==="waterfall"?at===Y.length-1&&(y.current=!0):y.current=!0}),ct=>(ct.transition().duration(z).style("fill",St).attr("x",re).attr("width",jt.bandwidth()).attr("y",lt).attr("height",yt).attr("rx",5).attr("ry",5),ct),ct=>ct.transition().duration(z).style("opacity",0).remove());rt({labelData:Dt,xPos:re,barWidth:jt.bandwidth(),yPos:lt,barHeight:yt});const ue=(p===""||p==="open")&&E===-1?C.map(ct=>({label:ct.label,value:ct.data.value})):[];aa(wt,{scale:jt,offset:E===-1&&p===""?ae.bandwidth()/2:jt.bandwidth()/2},q,{data:ue,idExtension:"open"},g,"vertical",{showLine:a,showDots:i,curve:s,lineStroke:String(Ve(me.open)?.darker()),dotFill:me.open});const Ut=(p===""||p==="close")&&E===-1?H.map(ct=>({label:ct.label,value:ct.data.value})):[];aa(wt,{scale:jt,offset:E===-1&&p===""?jt.bandwidth()/2+ae.bandwidth()/2:jt.bandwidth()/2},q,{data:Ut,idExtension:"close"},g,"vertical",{showLine:a,showDots:i,curve:s,lineStroke:String(Ve(me.close)?.darker()),dotFill:me.close});const hn=(j==="waterfall"?st:Dt).map((ct,P)=>({label:ct.label==="Opening"?"open":ct.label==="Closing"?"close":ct.label,value:j!=="waterfall"?Math.abs(ct.value):P!==st.length-1?ct.end:ct.value})),to=j==="waterfall"?"#2b2b22":me[j];aa(wt,{scale:jt,offset:jt.bandwidth()/2},q,{data:hn,idExtension:"waterfall"},g,"vertical",{showLine:a,showDots:i,curve:s,dotFill:to});const se=hi(U).style("opacity",0),Cn={formatType:r,prefix:e,suffix:n},Gn=(ct,P)=>{se.select("p.label span.label span.chev").style("color",P>=0?me.inflows:me.outflows).text(P>0?"▲":P<0?"▼":""),se.select("p.label span.label span.text").text(ct),se.select("p.label span.value").text(_e(P,Cn))},wi=(ct,P)=>{const{value:at,label:ht}=P.data;Gn(P.label+" "+ht+" :",at),se.select("p.from").style("display","none"),se.select("p.to").style("display","none"),se.style("opacity",1)},oa=ct=>{le(se,{e:ct,svg:dt})},la=()=>{se.style("opacity",0)};B.on("pointerenter",wi).on("pointermove",oa).on("pointerleave",la),ee.on("pointerenter",wi).on("pointermove",oa).on("pointerleave",la),Ft.on("pointerenter",function(ct,P){const{label:at,value:ht}=P;Gn(at,ht),j==="waterfall"?(se.select("p.from").style("display","flex"),se.select("p.from span.label").text("from: "),se.select("p.from span.value").text(_e(P.start,Cn)),se.select("p.to").style("display","flex"),se.select("p.to span.label").text("to: "),se.select("p.to span.value").text(_e(P.end,Cn))):(se.select("p.from").style("display","none"),se.select("p.to").style("display","none")),se.style("opacity",1)}).on("pointermove",oa).on("pointerleave",la)},[E,t,g,v,p,x,{showLine:a,showDots:i,curve:s},{prefix:e,suffix:n,formatType:r}]),N=15;return m.jsx("div",{ref:o,style:{width:c,height:u,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:I,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{className:`controls ${J[R?"controls-container":"controls-container-sm"]}`,children:[m.jsxs("label",{className:`
|
|
79
79
|
${J["controls-label"]}
|
|
80
80
|
${xe.sort}
|
|
81
81
|
${p!==""?xe.visible:""}
|
|
@@ -101,17 +101,17 @@ React keys must be passed directly to JSX without using spread:
|
|
|
101
101
|
L 0 ${-N/2}
|
|
102
102
|
L ${N/2} ${N/2}
|
|
103
103
|
Z
|
|
104
|
-
`})}),m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`${J["value-axis"]} y-axis`}),m.jsx("g",{className:`${xe["x-axis"]} x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})]}),m.jsx(ju,{})]})]})})}function ev({data:t,title:e="",orientation:n="horizontal",tooltipFormat:{prefix:r="",suffix:a="",formatType:i="long"}={prefix:"",suffix:"",formatType:"long"}}){const[s,o]=Ne(),{width:l,height:c}=o,[u,h]=He(),{width:f,height:g}=h,v=l>576,b=750,d={startColor:"#22c55e",endColor:"#6366f1"},x=Se(S=>{if(f===0||g===0)return;const w={top:20,right:25,bottom:25,left:70},y=f-w.left-w.right,T=g-w.top-w.bottom,p=Object.keys(t[0]).filter(it=>it!=="label"),k=S.select("svg"),_=k.node(),E=k.select(".plot-area").attr("transform","translate("+w.left+","+w.top+")"),z=S.select(".controls").select(".legends-container"),I=v?80:50,N=function(it){return`${J[v?"legend-container":"legend-container-sm"]} legend-item`};z.selectAll(".legend-item").data([...p],it=>it).join(it=>{const A=it.append("div").attr("class",N).style("left",(j,nt)=>`${nt*I}px`).style("top","-53px").style("opacity",0);return A.append("div").attr("class",J["legend-rect"]).style("background",j=>p.indexOf(j)===0?d.startColor:d.endColor).style("border-radius","50%"),A.append("span").attr("class",J["legend-label"]).style("color",j=>"#333").text(j=>j),A.transition().duration(b).style("top","0px").style("opacity",1),A},it=>(it.attr("class",N).transition().duration(b).style("top","0px").style("left",(A,j)=>`${j*I}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",A=>p.indexOf(A)===0?d.startColor:d.endColor).style("border-radius","50%"),it.select(`.${J["legend-label"]}`).text(A=>A),it),it=>it.transition().duration(b).style("opacity",0).style("top","53px").remove());const U=S.select("div#tooltip").style("opacity",0),M=Xe().domain(t.map(it=>it.label)).rangeRound([0,n==="horizontal"?T:y]).paddingOuter(.1),Y=oe(t,it=>it[p[0]])??0,C=Gt(t,it=>it[p[0]])??0,F=oe(t,it=>it[p[1]])??0,H=Gt(t,it=>it[p[1]])??0,V=Math.min(Y,F),et=Math.max(C,H),$=ye().domain([V,et]).rangeRound(n==="horizontal"?[0,y]:[T,0]).nice(),dt=n==="horizontal"?be(M).tickSizeOuter(0):be($).scale($).ticks(10,"s").tickSize(-y),wt=n==="horizontal"?he($).scale($).ticks(10,"s").tickSize(-T):he(M).tickSizeOuter(0);E.select(".x-axis").transition().duration(b).call(wt).attr("transform",`translate(0, ${T})`),E.select(".y-axis").transition().duration(b).call(dt),E.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",n==="vertical"?y:0).attr("y2",n==="vertical"?0:T).transition().duration(b).attr("transform",n==="vertical"?`translate(0, ${$(0)||0})`:`translate(${$(0)||0}, 0)`);const _t=it=>$(it[p[0]]),G=it=>$(it[p[1]]),ot=it=>(M(it.label)??0)+M.bandwidth()/2,O=it=>n==="horizontal"?_t(it):ot(it),Q=it=>n==="horizontal"?ot(it):_t(it),X=it=>n==="horizontal"?G(it):ot(it),D=it=>n==="horizontal"?ot(it):G(it);E.selectAll("line.link").data(t,it=>it.label).join(it=>it.append("line").attr("class","link").attr("stroke","#9ca3af").attr("stroke-width",2.5).attr("x1",O).attr("y1",Q).attr("x2",O).attr("y2",Q).transition().duration(b).attr("x1",O).attr("y1",Q).attr("x2",X).attr("y2",D),it=>it.transition().duration(b).attr("x1",O).attr("y1",Q).attr("x2",X).attr("y2",D),it=>it.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ft).on("pointerleave",st);const tt=v?7:4;E.selectAll("circle.start").data(t,it=>it.label+"-start").join(it=>it.append("circle").attr("class","start").attr("fill",d.startColor).attr("cx",O).attr("cy",Q).transition().duration(b).attr("cx",O).attr("cy",Q).attr("r",tt),it=>it.transition().duration(b).attr("cx",O).attr("cy",Q).attr("r",tt),it=>it.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ft).on("pointerleave",st),E.selectAll("circle.end").data(t,it=>it.label+"-end").join(it=>it.append("circle").attr("class","end").attr("fill",d.endColor).attr("cx",O).attr("cy",Q).transition().duration(b).attr("cx",X).attr("cy",D).attr("r",tt),it=>it.transition().duration(b).attr("cx",X).attr("cy",D).attr("r",tt),it=>it.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ft).on("pointerleave",st);const L={prefix:r,suffix:a,formatType:i};function Z(it,A){const j=A[p[0]],nt=A[p[1]];U.style("opacity",1),U.select("p.label").text(A.label),U.select("p.change span.from span.value").text(_e(j,L)),U.select("p.change span.to span.value").text(_e(nt,L));const $t=nt-j;U.select("p.total span.label span.text").text(_e($t,L)),U.select("p.total span.label span.chev").style("color",$t>=0?"#22c55e":"#ef4444").text($t>0?"▲":$t<0?"▼":""),le(U,{e:it,svg:_,yScale:$})}function ft(it,A){le(U,{e:it,svg:_,yScale:$})}function st(it,A){U.style("opacity",0)}},[t,e,f,g,n,{prefix:r,suffix:a,formatType:i}]);return m.jsx("div",{ref:s,style:{width:l,height:c,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:x,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsxs("div",{className:`controls ${J[v?"controls-container":"controls-container-sm"]}`,children:[m.jsx("p",{className:"title",style:{whiteSpace:"nowrap",paddingBottom:22,color:"#333"},children:e}),m.jsx("div",{className:`legends-container ${J["legends-container"]}`})]}),m.jsxs("div",{ref:u,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${f} ${g}`,children:m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`${n==="vertical"?J["value-axis"]:""} y-axis`}),m.jsx("g",{className:`${n==="horizontal"?J["value-axis"]:""} x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})}),m.jsxs(Qe,{children:[m.jsx("p",{className:"label",style:{margin:"3px",marginBottom:0,fontSize:"11px",color:"wheat",textAlign:"center"}}),m.jsxs("p",{className:"title",style:{fontWeight:600,margin:"3px",marginBottom:0,fontSize:"12px",color:"wheat"},children:[e," ","change:"]}),m.jsxs("p",{className:"change",style:{fontWeight:700,margin:"3px",fontSize:"13px",color:"wheat",display:"flex",alignItems:"center",justifyContent:"center",gap:2.5},children:[m.jsxs("span",{className:"from",style:{display:"flex",alignItems:"center",gap:2},children:[m.jsx("span",{className:"marker",style:{width:10,height:10,borderRadius:5,backgroundColor:d.startColor}}),m.jsx("span",{className:"value"})]})," ","to"," ",m.jsxs("span",{className:"to",style:{display:"flex",alignItems:"center",gap:2},children:[m.jsx("span",{className:"value"}),m.jsx("span",{className:"marker",style:{width:10,height:10,borderRadius:5,backgroundColor:d.endColor}})]})]}),m.jsxs("p",{className:"total",style:{fontWeight:600,margin:"3px",fontSize:"12px",color:"wheat",display:"flex",alignItems:"center",justifyContent:"center",gap:2,textAlign:"center"},children:[m.jsx("span",{style:{flex:1,textAlign:"right"},children:"Total:"}),m.jsxs("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"},children:[m.jsx("span",{className:"text"}),m.jsx("span",{className:"chev"})]})]})]})]})]})})}function Eu(t){const e=Array.from(new Set(t.flatMap(r=>[r.source,r.target]))),n=new Map(t.map(r=>[`${r.source}|${r.target}`,r.value]));return e.map(r=>({name:r,values:e.map(a=>n.get(`${r}|${a}`)??0)}))}function nv({data:t,tooltipFormat:{prefix:e="",suffix:n="",formatType:r="long"}={prefix:"",suffix:"",formatType:"long"}}){const a=bt.useRef(null),i=bt.useDeferredValue(t),[s,o]=Ne(),{width:l,height:c}=o,u=l>576;bt.useEffect(()=>{t!==i&&(a.current=i)},[t,i]);function h(w,y){const T=(w.endAngle-w.startAngle)/w.value;return ga(0,w.value,y).map(p=>({value:p,angle:p*T+w.startAngle,dIndex:w.index}))}const g=("links"in t?"comprehensive":"basic")==="comprehensive"?t.links:t,v=Eu(g),b=v.map(w=>w.name),d=rn(b),x=750,S=Se(w=>{if(l===0||c===0)return;const y=w.select("svg"),T=y.node(),p=y.select(".plot-area").attr("transform","translate("+l/2+","+c/2+")"),k=hi(w).style("opacity",0);y.on("pointerenter pointerleave",function(){k.style("opacity",0)});const _=e0().padAngle(.05).sortSubgroups(ao),E=a.current??[],z=("links"in E?"comprehensive":"basic")==="comprehensive"?E.links:E,I=Eu(z),N=I.map(D=>D.name),U=I.map(D=>D.values),M=_(U),Y=v.map(D=>D.name),C=v.map(D=>D.values),F=_(C),H=a===null;N.every(D=>Y.includes(D));const et=Math.max(Math.min(l,c),1)*.4;p.selectAll("linearGradient").remove();function $(D,tt){return[Math.cos(D-Math.PI/2)*tt,Math.sin(D-Math.PI/2)*tt]}const dt=p.selectAll("linearGradient").data(F).join("linearGradient").attr("id",(D,tt)=>`chord-gradient-${tt}`).attr("gradientUnits","userSpaceOnUse").each(function(D){const tt=(D.source.startAngle+D.source.endAngle)/2,L=(D.target.startAngle+D.target.endAngle)/2,[Z,ft]=$(tt,et),[st,it]=$(L,et);qt(this).attr("x1",Z).attr("y1",ft).attr("x2",st).attr("y2",it)});dt.append("stop").attr("offset","0%").attr("stop-color",D=>{const tt=Y[D.source.index],L=d.current.findIndex(Z=>Z===tt);return de(L,!0)}),dt.append("stop").attr("offset","100%").attr("stop-color",D=>{const tt=Y[D.target.index],L=d.current.findIndex(Z=>Z===tt);return de(L,!0)});const wt=h0().radius(et-10),pt=p.selectAll("path.link").data(F).join(D=>{const tt=D.append("path").attr("class","link").style("fill",(L,Z)=>`url(#chord-gradient-${Z})`).style("fill-opacity",0).style("stroke","none");return tt.transition().duration(x).delay(H?x/2:x).style("fill-opacity",1).attr("d",wt),tt},D=>D.transition().duration(x).style("fill-opacity",1).attrTween("d",function(tt){const L=M.find(ft=>{const st=N[ft.source.index],it=N[ft.target.index],A=Y[tt.source.index],j=Y[tt.target.index];return st===A&&it===j}),Z=Ae(L,tt);return ft=>wt(Z(ft))}),D=>D.transition().duration(x).style("fill-opacity",0).remove()),_t=si().innerRadius(et>10?et-10:0).outerRadius(et),G=(D,tt)=>{const L=Ae(tt==="exit"?D.endAngle:D.startAngle,tt==="exit"?D.startAngle:D.endAngle);return function(Z){return D.endAngle=L(Z),_t(D)}},ot=p.selectAll("g.nodes").data(F.groups,D=>Y[D.index]).join(D=>D.append("g").attr("class","nodes"),D=>{const tt=D;return D.transition().duration(x),tt},D=>{const tt=D;return tt.selectAll("path").transition().duration(x).attrTween("d",function(L){return G(L,"exit")}).remove(),tt.transition().duration(x).style("opacity",0).remove(),tt});ot.selectAll("path").data(D=>[D]).join(D=>{const tt=D.append("path").style("fill",function(L,Z){const ft=Y[L.index],st=d.current.findIndex(it=>it===ft);return de(st,!0)}).style("stroke","#a89ea9");return tt.transition().duration(x).attr("d",_t).attrTween("d",function(L){if(!H)return G(L,"not exit");const Z=Ae(0,L.startAngle),ft=Ae(0,L.endAngle);return function(st){return L.startAngle=Z(st),L.endAngle=ft(st),_t(L)}}),tt},D=>{const tt=D;return tt.transition().duration(x).style("fill",function(L,Z){const ft=Y[L.index],st=d.current.findIndex(it=>it===ft);return de(st,!0)}).attrTween("d",function(L){const Z=Y[L.index],ft=M.groups.find(nt=>N[nt.index]===Z),st=ft&&ft.startAngle?ft.startAngle:0,it=Ae(st,L.startAngle),A=ft&&ft.endAngle?ft.endAngle:0,j=Ae(A,L.endAngle);return function(nt){return L.startAngle=it(nt),L.endAngle=j(nt),_t(L)}}),tt},D=>D.transition().duration(x).attrTween("d",function(tt){return G(tt,"exit")}).remove());const O=pa(0,Dr(C.flat()),100);ot.selectAll("g.group-tick").data(D=>h(D,O),D=>D.value).join(D=>{const tt=D.append("g").attr("class","group-tick").attr("transform",L=>`
|
|
104
|
+
`})}),m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`${J["value-axis"]} y-axis`}),m.jsx("g",{className:`${xe["x-axis"]} x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})]}),m.jsx(ju,{})]})]})})}function ev({data:t,title:e="",orientation:n="horizontal",tooltipFormat:{prefix:r="",suffix:a="",formatType:i="long"}={prefix:"",suffix:"",formatType:"long"}}){const[s,o]=Ne(),{width:l,height:c}=o,[u,h]=He(),{width:f,height:g}=h,v=l>576,b=750,d={startColor:"#22c55e",endColor:"#6366f1"},x=Se(S=>{if(f===0||g===0)return;const w={top:20,right:25,bottom:25,left:70},y=f-w.left-w.right,T=g-w.top-w.bottom,p=Object.keys(t[0]).filter(it=>it!=="label"),k=S.select("svg"),_=k.node(),E=k.select(".plot-area").attr("transform","translate("+w.left+","+w.top+")"),z=S.select(".controls").select(".legends-container"),I=v?80:50,N=function(it){return`${J[v?"legend-container":"legend-container-sm"]} legend-item`};z.selectAll(".legend-item").data([...p],it=>it).join(it=>{const A=it.append("div").attr("class",N).style("left",(j,nt)=>`${nt*I}px`).style("top","-53px").style("opacity",0);return A.append("div").attr("class",J["legend-rect"]).style("background",j=>p.indexOf(j)===0?d.startColor:d.endColor).style("border-radius","50%"),A.append("span").attr("class",J["legend-label"]).style("color",j=>"#333").text(j=>j),A.transition().duration(b).style("top","0px").style("opacity",1),A},it=>(it.attr("class",N).transition().duration(b).style("top","0px").style("left",(A,j)=>`${j*I}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",A=>p.indexOf(A)===0?d.startColor:d.endColor).style("border-radius","50%"),it.select(`.${J["legend-label"]}`).text(A=>A),it),it=>it.transition().duration(b).style("opacity",0).style("top","53px").remove());const U=S.select("div#tooltip").style("opacity",0),M=Xe().domain(t.map(it=>it.label)).rangeRound([0,n==="horizontal"?T:y]).paddingOuter(.1),Y=oe(t,it=>it[p[0]])??0,C=Gt(t,it=>it[p[0]])??0,F=oe(t,it=>it[p[1]])??0,H=Gt(t,it=>it[p[1]])??0,V=Math.min(Y,F),et=Math.max(C,H),$=ye().domain([V,et]).rangeRound(n==="horizontal"?[0,y]:[T,0]).nice(),dt=n==="horizontal"?be(M).tickSizeOuter(0):be($).scale($).ticks(10,"s").tickSize(-y),wt=n==="horizontal"?he($).scale($).ticks(10,"s").tickSize(-T):he(M).tickSizeOuter(0);E.select(".x-axis").transition().duration(b).call(wt).attr("transform",`translate(0, ${T})`),E.select(".y-axis").transition().duration(b).call(dt),E.select("line.zero-line").attr("x1",0).attr("y1",0).attr("x2",n==="vertical"?y:0).attr("y2",n==="vertical"?0:T).transition().duration(b).attr("transform",n==="vertical"?`translate(0, ${$(0)||0})`:`translate(${$(0)||0}, 0)`);const _t=it=>$(it[p[0]]),G=it=>$(it[p[1]]),ot=it=>(M(it.label)??0)+M.bandwidth()/2,O=it=>n==="horizontal"?_t(it):ot(it),Q=it=>n==="horizontal"?ot(it):_t(it),X=it=>n==="horizontal"?G(it):ot(it),D=it=>n==="horizontal"?ot(it):G(it);E.selectAll("line.link").data(t,it=>it.label).join(it=>it.append("line").attr("class","link").attr("stroke","#9ca3af").attr("stroke-width",2.5).attr("x1",O).attr("y1",Q).attr("x2",O).attr("y2",Q).transition().duration(b).attr("x1",O).attr("y1",Q).attr("x2",X).attr("y2",D),it=>it.transition().duration(b).attr("x1",O).attr("y1",Q).attr("x2",X).attr("y2",D),it=>it.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ft).on("pointerleave",st);const tt=v?7:4;E.selectAll("circle.start").data(t,it=>it.label+"-start").join(it=>it.append("circle").attr("class","start").attr("fill",d.startColor).attr("cx",O).attr("cy",Q).transition().duration(b).attr("cx",O).attr("cy",Q).attr("r",tt),it=>it.transition().duration(b).attr("cx",O).attr("cy",Q).attr("r",tt),it=>it.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ft).on("pointerleave",st),E.selectAll("circle.end").data(t,it=>it.label+"-end").join(it=>it.append("circle").attr("class","end").attr("fill",d.endColor).attr("cx",O).attr("cy",Q).transition().duration(b).attr("cx",X).attr("cy",D).attr("r",tt),it=>it.transition().duration(b).attr("cx",X).attr("cy",D).attr("r",tt),it=>it.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ft).on("pointerleave",st);const L={prefix:r,suffix:a,formatType:i};function Z(it,A){const j=A[p[0]],nt=A[p[1]];U.style("opacity",1),U.select("p.label").text(A.label),U.select("p.change span.from span.value").text(_e(j,L)),U.select("p.change span.to span.value").text(_e(nt,L));const Dt=nt-j;U.select("p.total span.label span.text").text(_e(Dt,L)),U.select("p.total span.label span.chev").style("color",Dt>=0?"#22c55e":"#ef4444").text(Dt>0?"▲":Dt<0?"▼":""),le(U,{e:it,svg:_,yScale:$})}function ft(it,A){le(U,{e:it,svg:_,yScale:$})}function st(it,A){U.style("opacity",0)}},[t,e,f,g,n,{prefix:r,suffix:a,formatType:i}]);return m.jsx("div",{ref:s,style:{width:l,height:c,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:x,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsxs("div",{className:`controls ${J[v?"controls-container":"controls-container-sm"]}`,children:[m.jsx("p",{className:"title",style:{whiteSpace:"nowrap",paddingBottom:22,color:"#333"},children:e}),m.jsx("div",{className:`legends-container ${J["legends-container"]}`})]}),m.jsxs("div",{ref:u,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`0 0 ${f} ${g}`,children:m.jsxs("g",{className:"plot-area",children:[m.jsx("g",{className:`${n==="vertical"?J["value-axis"]:""} y-axis`}),m.jsx("g",{className:`${n==="horizontal"?J["value-axis"]:""} x-axis`}),m.jsx("line",{className:"zero-line",stroke:"currentColor",strokeWidth:1})]})}),m.jsxs(Qe,{children:[m.jsx("p",{className:"label",style:{margin:"3px",marginBottom:0,fontSize:"11px",color:"wheat",textAlign:"center"}}),m.jsxs("p",{className:"title",style:{fontWeight:600,margin:"3px",marginBottom:0,fontSize:"12px",color:"wheat"},children:[e," ","change:"]}),m.jsxs("p",{className:"change",style:{fontWeight:700,margin:"3px",fontSize:"13px",color:"wheat",display:"flex",alignItems:"center",justifyContent:"center",gap:2.5},children:[m.jsxs("span",{className:"from",style:{display:"flex",alignItems:"center",gap:2},children:[m.jsx("span",{className:"marker",style:{width:10,height:10,borderRadius:5,backgroundColor:d.startColor}}),m.jsx("span",{className:"value"})]})," ","to"," ",m.jsxs("span",{className:"to",style:{display:"flex",alignItems:"center",gap:2},children:[m.jsx("span",{className:"value"}),m.jsx("span",{className:"marker",style:{width:10,height:10,borderRadius:5,backgroundColor:d.endColor}})]})]}),m.jsxs("p",{className:"total",style:{fontWeight:600,margin:"3px",fontSize:"12px",color:"wheat",display:"flex",alignItems:"center",justifyContent:"center",gap:2,textAlign:"center"},children:[m.jsx("span",{style:{flex:1,textAlign:"right"},children:"Total:"}),m.jsxs("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"},children:[m.jsx("span",{className:"text"}),m.jsx("span",{className:"chev"})]})]})]})]})]})})}function Eu(t){const e=Array.from(new Set(t.flatMap(r=>[r.source,r.target]))),n=new Map(t.map(r=>[`${r.source}|${r.target}`,r.value]));return e.map(r=>({name:r,values:e.map(a=>n.get(`${r}|${a}`)??0)}))}function nv({data:t,tooltipFormat:{prefix:e="",suffix:n="",formatType:r="long"}={prefix:"",suffix:"",formatType:"long"}}){const a=bt.useRef(null),i=bt.useDeferredValue(t),[s,o]=Ne(),{width:l,height:c}=o,u=l>576;bt.useEffect(()=>{t!==i&&(a.current=i)},[t,i]);function h(w,y){const T=(w.endAngle-w.startAngle)/w.value;return ga(0,w.value,y).map(p=>({value:p,angle:p*T+w.startAngle,dIndex:w.index}))}const g=("links"in t?"comprehensive":"basic")==="comprehensive"?t.links:t,v=Eu(g),b=v.map(w=>w.name),d=rn(b),x=750,S=Se(w=>{if(l===0||c===0)return;const y=w.select("svg"),T=y.node(),p=y.select(".plot-area").attr("transform","translate("+l/2+","+c/2+")"),k=hi(w).style("opacity",0);y.on("pointerenter pointerleave",function(){k.style("opacity",0)});const _=e0().padAngle(.05).sortSubgroups(ao),E=a.current??[],z=("links"in E?"comprehensive":"basic")==="comprehensive"?E.links:E,I=Eu(z),N=I.map(D=>D.name),U=I.map(D=>D.values),M=_(U),Y=v.map(D=>D.name),C=v.map(D=>D.values),F=_(C),H=a===null;N.every(D=>Y.includes(D));const et=Math.max(Math.min(l,c),1)*.4;p.selectAll("linearGradient").remove();function $(D,tt){return[Math.cos(D-Math.PI/2)*tt,Math.sin(D-Math.PI/2)*tt]}const dt=p.selectAll("linearGradient").data(F).join("linearGradient").attr("id",(D,tt)=>`chord-gradient-${tt}`).attr("gradientUnits","userSpaceOnUse").each(function(D){const tt=(D.source.startAngle+D.source.endAngle)/2,L=(D.target.startAngle+D.target.endAngle)/2,[Z,ft]=$(tt,et),[st,it]=$(L,et);qt(this).attr("x1",Z).attr("y1",ft).attr("x2",st).attr("y2",it)});dt.append("stop").attr("offset","0%").attr("stop-color",D=>{const tt=Y[D.source.index],L=d.current.findIndex(Z=>Z===tt);return de(L,!0)}),dt.append("stop").attr("offset","100%").attr("stop-color",D=>{const tt=Y[D.target.index],L=d.current.findIndex(Z=>Z===tt);return de(L,!0)});const wt=h0().radius(et-10),pt=p.selectAll("path.link").data(F).join(D=>{const tt=D.append("path").attr("class","link").style("fill",(L,Z)=>`url(#chord-gradient-${Z})`).style("fill-opacity",0).style("stroke","none");return tt.transition().duration(x).delay(H?x/2:x).style("fill-opacity",1).attr("d",wt),tt},D=>D.transition().duration(x).style("fill-opacity",1).attrTween("d",function(tt){const L=M.find(ft=>{const st=N[ft.source.index],it=N[ft.target.index],A=Y[tt.source.index],j=Y[tt.target.index];return st===A&&it===j}),Z=Ae(L,tt);return ft=>wt(Z(ft))}),D=>D.transition().duration(x).style("fill-opacity",0).remove()),_t=si().innerRadius(et>10?et-10:0).outerRadius(et),G=(D,tt)=>{const L=Ae(tt==="exit"?D.endAngle:D.startAngle,tt==="exit"?D.startAngle:D.endAngle);return function(Z){return D.endAngle=L(Z),_t(D)}},ot=p.selectAll("g.nodes").data(F.groups,D=>Y[D.index]).join(D=>D.append("g").attr("class","nodes"),D=>{const tt=D;return D.transition().duration(x),tt},D=>{const tt=D;return tt.selectAll("path").transition().duration(x).attrTween("d",function(L){return G(L,"exit")}).remove(),tt.transition().duration(x).style("opacity",0).remove(),tt});ot.selectAll("path").data(D=>[D]).join(D=>{const tt=D.append("path").style("fill",function(L,Z){const ft=Y[L.index],st=d.current.findIndex(it=>it===ft);return de(st,!0)}).style("stroke","#a89ea9");return tt.transition().duration(x).attr("d",_t).attrTween("d",function(L){if(!H)return G(L,"not exit");const Z=Ae(0,L.startAngle),ft=Ae(0,L.endAngle);return function(st){return L.startAngle=Z(st),L.endAngle=ft(st),_t(L)}}),tt},D=>{const tt=D;return tt.transition().duration(x).style("fill",function(L,Z){const ft=Y[L.index],st=d.current.findIndex(it=>it===ft);return de(st,!0)}).attrTween("d",function(L){const Z=Y[L.index],ft=M.groups.find(nt=>N[nt.index]===Z),st=ft&&ft.startAngle?ft.startAngle:0,it=Ae(st,L.startAngle),A=ft&&ft.endAngle?ft.endAngle:0,j=Ae(A,L.endAngle);return function(nt){return L.startAngle=it(nt),L.endAngle=j(nt),_t(L)}}),tt},D=>D.transition().duration(x).attrTween("d",function(tt){return G(tt,"exit")}).remove());const O=pa(0,Dr(C.flat()),100);ot.selectAll("g.group-tick").data(D=>h(D,O),D=>D.value).join(D=>{const tt=D.append("g").attr("class","group-tick").attr("transform",L=>`
|
|
105
105
|
rotate(${L.angle*180/Math.PI-90})
|
|
106
106
|
translate(${et},0)
|
|
107
107
|
`).style("opacity",0);return tt.append("line").style("stroke","#a8a29e").attr("x2",6),tt.append("text").attr("dy","0.35em").style("fill","#292524").style("font-size",u?"10px":"8px").attr("x",8).attr("transform",L=>L.angle>Math.PI?"rotate(180) translate(-16)":null).style("text-anchor",L=>L.angle>Math.PI?"end":"start"),tt.transition().duration(x).delay(x).style("opacity",1),tt},D=>D.transition().duration(x).attr("transform",tt=>`
|
|
108
108
|
rotate(${tt.angle*180/Math.PI-90})
|
|
109
109
|
translate(${et},0)
|
|
110
|
-
`).style("opacity",1),D=>D.transition().duration(x).style("opacity",0).remove()).select("text").filter(D=>D.value%(O*5)===0).text(D=>D.value>0?pe(".0s")(D.value):pe(".1~%")(D.value)).attr("x",8).attr("transform",D=>D.angle>Math.PI?"rotate(180) translate(-16)":null).style("text-anchor",D=>D.angle>Math.PI?"end":"start"),ot.select("text").attr("font-weight","bold").text(function(D){return this.getAttribute("text-anchor")==="end"?`↑ ${Y[D.index]}`:`${Y[D.index]} ↓`});const X=.3;ot.on("pointerenter",function(D,tt){D.stopPropagation(),ot.filter(K=>K.index!==tt.index).style("opacity",X),pt.filter(K=>K.source.index!==tt.index&&K.target.index!==tt.index).style("opacity",X);const L=pt.filter(K=>K.target.index===tt.index&&K.source.index!==tt.index),Z=pt.filter(K=>K.source.index===tt.index&&K.target.index!==tt.index),ft=pt.filter(K=>K.source.index===tt.index&&K.target.index===tt.index),st=L.data(),it=Z.data(),A=ft.data(),j=st.reduce((K,Ct)=>K+Ct.target.value,0),nt=it.reduce((K,Ct)=>K+Ct.source.value,0)
|
|
110
|
+
`).style("opacity",1),D=>D.transition().duration(x).style("opacity",0).remove()).select("text").filter(D=>D.value%(O*5)===0).text(D=>D.value>0?pe(".0s")(D.value):pe(".1~%")(D.value)).attr("x",8).attr("transform",D=>D.angle>Math.PI?"rotate(180) translate(-16)":null).style("text-anchor",D=>D.angle>Math.PI?"end":"start"),ot.select("text").attr("font-weight","bold").text(function(D){return this.getAttribute("text-anchor")==="end"?`↑ ${Y[D.index]}`:`${Y[D.index]} ↓`});const X=.3;ot.on("pointerenter",function(D,tt){D.stopPropagation(),ot.filter(K=>K.index!==tt.index).style("opacity",X),pt.filter(K=>K.source.index!==tt.index&&K.target.index!==tt.index).style("opacity",X);const L=pt.filter(K=>K.target.index===tt.index&&K.source.index!==tt.index),Z=pt.filter(K=>K.source.index===tt.index&&K.target.index!==tt.index),ft=pt.filter(K=>K.source.index===tt.index&&K.target.index===tt.index),st=L.data(),it=Z.data(),A=ft.data(),j=st.reduce((K,Ct)=>K+Ct.target.value,0),nt=it.reduce((K,Ct)=>K+Ct.source.value,0),Dt=A.reduce((K,Ct)=>K+Ct.source.value,0);k.style("opacity",1);const W=Y[tt.index];k.select("p.name").style("display","block").text(W),k.select("p.value1").style("display","flex"),k.select("p.value1 span.label").text("inflows: "),k.select("p.value1 span.value").text(`${e}${Yn(j)}${n}`),k.select("p.value2").style("display","flex"),k.select("p.value2 span.label").text("outflows: "),k.select("p.value2 span.value").text(`${e}${Yn(nt)}${n}`),k.select("p.selfValue").style("display","flex"),k.select("p.selfValue span.label").text("internal: "),k.select("p.selfValue span.value").text(`${e}${Yn(Dt)}${n}`),le(k,{e:D,svg:T})}).on("pointermove",(D,tt)=>{le(k,{e:D,svg:T})}).on("pointerleave",function(D,tt){ot.filter(L=>L.index!==tt.index).style("opacity",1),pt.style("opacity",1),k.style("opacity",0)}),pt.on("pointerenter",function(D,tt){D.stopPropagation(),ot.filter(A=>A.index!==tt.source.index&&A.index!==tt.target.index).style("opacity",X),pt.filter(A=>A.source.index!==tt.source.index||A.target.index!==tt.target.index).style("opacity",X),k.style("opacity",1);const L=Y[tt.source.index],Z=Y[tt.target.index],ft=`${e}${Yn(tt.source.value)}${n}`,st=`${e}${Yn(tt.target.value)}${n}`,it=`
|
|
111
111
|
${e}
|
|
112
112
|
${Yn(tt.source.value-tt.target.value)}
|
|
113
113
|
${n}
|
|
114
|
-
`;L===Z?(k.select("p.name").style("display","block").text(`${L} (internal): ${ft}`),k.select("p.value1").style("display","none"),k.select("p.value2").style("display","none"),k.select("p.selfValue").style("display","none")):(k.select("p.name").style("display","none"),k.select("p.value1").style("display","flex"),k.select("p.value1 span.label").text(`${L} → ${Z}:`),k.select("p.value1 span.value").text(`${ft}`),k.select("p.value2").style("display","flex"),k.select("p.value2 span.label").text(`${Z} → ${L}:`),k.select("p.value2 span.value").text(`${st}`),k.select("p.selfValue").style("display","flex"),k.select("p.selfValue span.label").text(`Total ${L} → ${Z}:`),k.select("p.selfValue span.value").text(`${it}`))}).on("pointermove",(D,tt)=>{le(k,{e:D,svg:T})}).on("pointerleave",function(D,tt){ot.filter(L=>L.index!==tt.source.index&&L.index!==tt.target.index).style("opacity",1),pt.filter(L=>L.source.index!==tt.source.index||L.target.index!==tt.target.index).style("opacity",1),k.style("opacity",0)})},[v,l,c,{prefix:e,suffix:n,formatType:r}]);return m.jsx("div",{ref:s,style:{width:l,height:c,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:S,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${l} ${c}`,children:m.jsx("g",{className:"plot-area"})}),m.jsxs(Qe,{children:[m.jsx("p",{className:"name",style:{fontWeight:700,margin:"3px",fontSize:"13px",color:"wheat",textAlign:"center"},children:"Tooltip"}),m.jsxs("p",{className:"value1",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat",display:"flex"},children:[m.jsx("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"}}),m.jsx("span",{className:"value",style:{flex:1,textAlign:"right",paddingLeft:4,fontWeight:600}})]}),m.jsxs("p",{className:"value2",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat",display:"flex"},children:[m.jsx("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"}}),m.jsx("span",{className:"value",style:{flex:1,textAlign:"right",paddingLeft:4,fontWeight:600}})]}),m.jsxs("p",{className:"selfValue",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat",display:"flex"},children:[m.jsx("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"}}),m.jsx("span",{className:"value",style:{flex:1,textAlign:"right",paddingLeft:4,fontWeight:600}})]})]})]})})}const _r="#2b2b22";function rv(t,e,n,r,a,i="vertical",s={showLine:!1,showDots:!0,curve:"linear",lineStroke:_r,dotFill:_r}){const{binRanges:o,binSorted:l,isSorted:c}=e,u=750,h=a>576,f=_=>{const E=_.x0,R=_.x1,z=R===E?E+1:R,I=o(z)-o(E)||0;return i==="vertical"?c?(l(_.x0+"-"+_.x1)||0)+l.bandwidth()/2:(o(_.x0)||0)+I/2:n(_.length)},g=_=>i==="vertical"?n(_.length):(c?l(_.x0+"-"+_.x1):o(_.x0)||0)||0,{showLine:v,showDots:b,curve:d,lineStroke:x,dotFill:S}=s,w=v&&b?r:[],y=h?3:2;t.selectAll(".dot").data(w,_=>_.x0+"-"+_.x1).join(_=>_.append("circle").attr("class","dot").attr("cx",f).attr("cy",g).attr("fill",S??_r).attr("r",0).style("pointer-events","none").transition().duration(u).attr("cx",f).attr("cy",g).attr("r",y),void 0,_=>_.transition().duration(u).style("opacity",0).remove()).transition().duration(u).attr("cx",f).attr("cy",g).attr("r",y).attr("fill",S??_r);const T=Bn().x(f).y(g);d==="linear"?T.curve(li):d==="basis"?T.curve(Rc):d==="cardinal"?T.curve(Ic):d==="catmullrom"?T.curve(Hc):d==="natural"&&T.curve(Bc);const p=v?[r]:[],k=t.selectAll("path.chartline").data(p).join(_=>_.append("path").attr("class","chartline").attr("fill","none").attr("stroke",x??_r).attr("stroke-width",2).style("stroke-opacity",.75).style("pointer-events","none"),void 0,_=>_.remove());k.transition().duration(u).attr("d",_=>T(_)).attr("stroke",x??_r),k.raise()}const ce={"histogram-legends-container":"_histogram-legends-container_whzpw_1","legends-layer1":"_legends-layer1_whzpw_21",base:"_base_whzpw_21",positive:"_positive_whzpw_31",negative:"_negative_whzpw_41","legends-layer2":"_legends-layer2_whzpw_51","legend-label":"_legend-label_whzpw_99",controls:"_controls_whzpw_151","controls-container":"_controls-container_whzpw_177","controls-container-sm":"_controls-container-sm_whzpw_187","controls-label":"_controls-label_whzpw_197","controls-checkbox":"_controls-checkbox_whzpw_241","table-container":"_table-container_whzpw_271","show-table":"_show-table_whzpw_289","slide-down":"_slide-down_whzpw_1","hide-table":"_hide-table_whzpw_299","slide-up":"_slide-up_whzpw_1","table-scroll-container":"_table-scroll-container_whzpw_355","responsive-table":"_responsive-table_whzpw_369","pagination-controls":"_pagination-controls_whzpw_419","pagination-btn":"_pagination-btn_whzpw_439","pagination-info":"_pagination-info_whzpw_499","pagination-page-number":"_pagination-page-number_whzpw_511"};function av({data:t,compareMode:e="default",binOption:n={mode:"algorithm",value:"Freedman-Diaconis",compareConsolidate:!1},sortOption:{sortable:r=!0,filterEmptyBin:a=!1}={sortable:!0,filterEmptyBin:!1},orientation:i="vertical",tooltipFormat:{prefix:s="",suffix:o="",formatType:l="long"}={prefix:"",suffix:"",formatType:"long"},lineProps:{showLine:c=!1,showDots:u=!0,curve:h="linear"}={showLine:!1,showDots:!0,curve:"linear"}}){const[f,g]=Ne(),{width:v,height:b}=g,[d,x]=He(),{height:S}=x,[w,y]=He(),{width:T,height:p}=y,[k,_]=bt.useState({valueKey:"",data:[]}),E=bt.useRef(Date.now()),[R,z]=bt.useState(!1),I=T>576;bt.useEffect(()=>{z(!1),_({valueKey:"",data:[]})},[t,e]),bt.useEffect(()=>{r||z(!1)},[r]);const N=t.valueKey!==void 0,U=750,M=Se(Y=>{if(T===0||p===0)return;const C={top:30,right:i==="vertical"?30:50,bottom:i==="vertical"?50:30,left:i==="vertical"?25:50},F=T-C.left-C.right,H=p-C.top-C.bottom,V=Y.select("svg"),et=V.node(),$=V.select(".plot-area").attr("transform","translate("+C.left+","+C.top+")"),dt=q=>{const Tt=q.data.filter(ut=>{const vt=ut[q.valueKey],At=typeof vt=="string"||typeof vt=="number"?String(vt):"";return!isNaN(parseFloat(At))});return{title:q.title,valueKey:q.valueKey,data:Tt}},wt=N?dt(t):t.data.reduce((q,Tt)=>{const ut=dt(Tt);return q.push(ut),q},[]),pt=N?wt:{title:t.title,data:wt},_t=N?pt.data.map(q=>parseFloat(String(q[t.valueKey]))):pt.data.reduce((q,Tt)=>{if(!Tt.valueKey)return q;const ut=Tt.valueKey,vt=Tt.data.map(At=>parseFloat(String(At[ut])));return q.push(...vt),q},[]),G=Math.min(..._t),ot=Math.max(..._t),O=ye().domain([G,ot]).range([0,F]),Q=q=>{if(!q||!q.data||q.data.length===0)return[];const Tt=q.data.map(rt=>parseFloat(String(rt[q.valueKey]))),ut=Math.min(...Tt),vt=Math.max(...Tt);ga(ut,vt,(vt-ut)/15);const{mode:jt,value:Xt,compareConsolidate:ae}=n,Zt=q.valueKey||"",
|
|
114
|
+
`;L===Z?(k.select("p.name").style("display","block").text(`${L} (internal): ${ft}`),k.select("p.value1").style("display","none"),k.select("p.value2").style("display","none"),k.select("p.selfValue").style("display","none")):(k.select("p.name").style("display","none"),k.select("p.value1").style("display","flex"),k.select("p.value1 span.label").text(`${L} → ${Z}:`),k.select("p.value1 span.value").text(`${ft}`),k.select("p.value2").style("display","flex"),k.select("p.value2 span.label").text(`${Z} → ${L}:`),k.select("p.value2 span.value").text(`${st}`),k.select("p.selfValue").style("display","flex"),k.select("p.selfValue span.label").text(`Total ${L} → ${Z}:`),k.select("p.selfValue span.value").text(`${it}`))}).on("pointermove",(D,tt)=>{le(k,{e:D,svg:T})}).on("pointerleave",function(D,tt){ot.filter(L=>L.index!==tt.source.index&&L.index!==tt.target.index).style("opacity",1),pt.filter(L=>L.source.index!==tt.source.index||L.target.index!==tt.target.index).style("opacity",1),k.style("opacity",0)})},[v,l,c,{prefix:e,suffix:n,formatType:r}]);return m.jsx("div",{ref:s,style:{width:l,height:c,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:S,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${l} ${c}`,children:m.jsx("g",{className:"plot-area"})}),m.jsxs(Qe,{children:[m.jsx("p",{className:"name",style:{fontWeight:700,margin:"3px",fontSize:"13px",color:"wheat",textAlign:"center"},children:"Tooltip"}),m.jsxs("p",{className:"value1",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat",display:"flex"},children:[m.jsx("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"}}),m.jsx("span",{className:"value",style:{flex:1,textAlign:"right",paddingLeft:4,fontWeight:600}})]}),m.jsxs("p",{className:"value2",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat",display:"flex"},children:[m.jsx("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"}}),m.jsx("span",{className:"value",style:{flex:1,textAlign:"right",paddingLeft:4,fontWeight:600}})]}),m.jsxs("p",{className:"selfValue",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat",display:"flex"},children:[m.jsx("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"}}),m.jsx("span",{className:"value",style:{flex:1,textAlign:"right",paddingLeft:4,fontWeight:600}})]})]})]})})}const _r="#2b2b22";function rv(t,e,n,r,a,i="vertical",s={showLine:!1,showDots:!0,curve:"linear",lineStroke:_r,dotFill:_r}){const{binRanges:o,binSorted:l,isSorted:c}=e,u=750,h=a>576,f=_=>{const E=_.x0,R=_.x1,z=R===E?E+1:R,I=o(z)-o(E)||0;return i==="vertical"?c?(l(_.x0+"-"+_.x1)||0)+l.bandwidth()/2:(o(_.x0)||0)+I/2:n(_.length)},g=_=>i==="vertical"?n(_.length):(c?l(_.x0+"-"+_.x1):o(_.x0)||0)||0,{showLine:v,showDots:b,curve:d,lineStroke:x,dotFill:S}=s,w=v&&b?r:[],y=h?3:2;t.selectAll(".dot").data(w,_=>_.x0+"-"+_.x1).join(_=>_.append("circle").attr("class","dot").attr("cx",f).attr("cy",g).attr("fill",S??_r).attr("r",0).style("pointer-events","none").transition().duration(u).attr("cx",f).attr("cy",g).attr("r",y),void 0,_=>_.transition().duration(u).style("opacity",0).remove()).transition().duration(u).attr("cx",f).attr("cy",g).attr("r",y).attr("fill",S??_r);const T=Bn().x(f).y(g);d==="linear"?T.curve(li):d==="basis"?T.curve(Rc):d==="cardinal"?T.curve(Ic):d==="catmullrom"?T.curve(Hc):d==="natural"&&T.curve(Bc);const p=v?[r]:[],k=t.selectAll("path.chartline").data(p).join(_=>_.append("path").attr("class","chartline").attr("fill","none").attr("stroke",x??_r).attr("stroke-width",2).style("stroke-opacity",.75).style("pointer-events","none"),void 0,_=>_.remove());k.transition().duration(u).attr("d",_=>T(_)).attr("stroke",x??_r),k.raise()}const ce={"histogram-legends-container":"_histogram-legends-container_whzpw_1","legends-layer1":"_legends-layer1_whzpw_21",base:"_base_whzpw_21",positive:"_positive_whzpw_31",negative:"_negative_whzpw_41","legends-layer2":"_legends-layer2_whzpw_51","legend-label":"_legend-label_whzpw_99",controls:"_controls_whzpw_151","controls-container":"_controls-container_whzpw_177","controls-container-sm":"_controls-container-sm_whzpw_187","controls-label":"_controls-label_whzpw_197","controls-checkbox":"_controls-checkbox_whzpw_241","table-container":"_table-container_whzpw_271","show-table":"_show-table_whzpw_289","slide-down":"_slide-down_whzpw_1","hide-table":"_hide-table_whzpw_299","slide-up":"_slide-up_whzpw_1","table-scroll-container":"_table-scroll-container_whzpw_355","responsive-table":"_responsive-table_whzpw_369","pagination-controls":"_pagination-controls_whzpw_419","pagination-btn":"_pagination-btn_whzpw_439","pagination-info":"_pagination-info_whzpw_499","pagination-page-number":"_pagination-page-number_whzpw_511"};function av({data:t,compareMode:e="default",binOption:n={mode:"algorithm",value:"Freedman-Diaconis",compareConsolidate:!1},sortOption:{sortable:r=!0,filterEmptyBin:a=!1}={sortable:!0,filterEmptyBin:!1},orientation:i="vertical",tooltipFormat:{prefix:s="",suffix:o="",formatType:l="long"}={prefix:"",suffix:"",formatType:"long"},lineProps:{showLine:c=!1,showDots:u=!0,curve:h="linear"}={showLine:!1,showDots:!0,curve:"linear"}}){const[f,g]=Ne(),{width:v,height:b}=g,[d,x]=He(),{height:S}=x,[w,y]=He(),{width:T,height:p}=y,[k,_]=bt.useState({valueKey:"",data:[]}),E=bt.useRef(Date.now()),[R,z]=bt.useState(!1),I=T>576;bt.useEffect(()=>{z(!1),_({valueKey:"",data:[]})},[t,e]),bt.useEffect(()=>{r||z(!1)},[r]);const N=t.valueKey!==void 0,U=750,M=Se(Y=>{if(T===0||p===0)return;const C={top:30,right:i==="vertical"?30:50,bottom:i==="vertical"?50:30,left:i==="vertical"?25:50},F=T-C.left-C.right,H=p-C.top-C.bottom,V=Y.select("svg"),et=V.node(),$=V.select(".plot-area").attr("transform","translate("+C.left+","+C.top+")"),dt=q=>{const Tt=q.data.filter(ut=>{const vt=ut[q.valueKey],At=typeof vt=="string"||typeof vt=="number"?String(vt):"";return!isNaN(parseFloat(At))});return{title:q.title,valueKey:q.valueKey,data:Tt}},wt=N?dt(t):t.data.reduce((q,Tt)=>{const ut=dt(Tt);return q.push(ut),q},[]),pt=N?wt:{title:t.title,data:wt},_t=N?pt.data.map(q=>parseFloat(String(q[t.valueKey]))):pt.data.reduce((q,Tt)=>{if(!Tt.valueKey)return q;const ut=Tt.valueKey,vt=Tt.data.map(At=>parseFloat(String(At[ut])));return q.push(...vt),q},[]),G=Math.min(..._t),ot=Math.max(..._t),O=ye().domain([G,ot]).range([0,F]),Q=q=>{if(!q||!q.data||q.data.length===0)return[];const Tt=q.data.map(rt=>parseFloat(String(rt[q.valueKey]))),ut=Math.min(...Tt),vt=Math.max(...Tt);ga(ut,vt,(vt-ut)/15);const{mode:jt,value:Xt,compareConsolidate:ae}=n,Zt=q.valueKey||"",Ht=rf().value(rt=>rt[Zt]).domain(ae?[G,ot]:[ut,vt]);function te(rt,gt,kt){if(kt<=0)throw new Error("interval must be greater than 0");let Wt=Math.floor(rt/kt)*kt,xt=Math.ceil(gt/kt)*kt;Wt>=rt&&(Wt-=kt),xt<=gt&&(xt+=kt);const Nt=[];for(let B=Wt;B<=xt;B+=kt)Nt.push(B);return Nt}if(jt==="arbitrary")Ht.thresholds(O.ticks(Xt));else if(jt==="fixed")Ht.thresholds(ga(ut,vt,(vt-ut)/Xt));else if(jt==="interval"){const rt=te(ut,vt,Xt);Ht.thresholds(rt)}else jt==="custom"?Ht.thresholds(Xt):jt==="algorithm"&&(Xt==="Freedman-Diaconis"?Ht.thresholds(af):Xt==="Scott"?Ht.thresholds(sf):Xt==="Sturges"&&Ht.thresholds(fo));return Ht(q.data)},X=N?[Q(pt),[]]:[Q(pt.data[0]),Q(pt.data[1])],D=X[0][0]?.x0<0||X[1][0]?.x0<0,tt=Array.isArray(wt)?[Object.assign(D?["positive","negative"]:["positive"],{title:wt[0].title}),Object.assign(D?["positive","negative"]:["positive"],{title:wt[1].title})]:D?[Object.assign(["positive","negative"],{title:wt.title})]:[],L=tt.map(q=>q.title),Z=I?80:60,ft=function(){return`${J[I?"legend-container":"legend-container-sm"]} legend-item`},st={base:"#7c3aed",layer1:{positive:"#2563eb",negative:"#f43f5e"},layer2:{positive:"#22c55e",negative:"#dc2626"}};Y.select(".controls").select(".legends-container").selectAll(".legend-item").data(tt,q=>q.title).join(q=>{const Tt=q.append("div").attr("class",ft).style("left",(At,jt)=>`${jt*Z}px`).style("top","-53px").style("opacity",0),ut=Tt.append("div").attr("class",function(At,jt){return`
|
|
115
115
|
legends-rect
|
|
116
116
|
${ce[jt===0?"legends-layer1":"legends-layer2"]}
|
|
117
117
|
${ce["histogram-legends-container"]}
|
|
@@ -121,27 +121,27 @@ React keys must be passed directly to JSX without using spread:
|
|
|
121
121
|
legends-rect
|
|
122
122
|
${ce[jt===0?"legends-layer1":"legends-layer2"]}
|
|
123
123
|
${ce["histogram-legends-container"]}
|
|
124
|
-
`}).style("width",`${Z}px`);const ut=Tt.selectAll(`div.${ce.negative}`).empty();return ut&&D&&Tt.append("div").attr("class",`${J["legend-rect"]} ${ce.negative}`).append("p").text("-"),!ut&&!D&&Tt.selectAll(`div.${ce.negative}`).remove(),N?Tt.selectAll(`div.${ce.positive}`).attr("class",`${J["legend-rect"]} ${ce.base}`):Tt.selectAll(`div.${ce.base}`).attr("class",`${J["legend-rect"]} ${ce.positive}`),Tt.selectAll("p").transition().duration(U).style("opacity",`${D?1:0}`),q.transition().duration(U).style("top","0px").style("left",(vt,At)=>`${At*Z}px`).style("opacity",1),q},q=>q.style("color",Ee).transition().duration(U).style("opacity",0).style("top","53px").remove());const j=Math.max(...X[0].map(q=>q?.length)),nt=Math.max(...X[1].map(q=>q?.length))
|
|
124
|
+
`}).style("width",`${Z}px`);const ut=Tt.selectAll(`div.${ce.negative}`).empty();return ut&&D&&Tt.append("div").attr("class",`${J["legend-rect"]} ${ce.negative}`).append("p").text("-"),!ut&&!D&&Tt.selectAll(`div.${ce.negative}`).remove(),N?Tt.selectAll(`div.${ce.positive}`).attr("class",`${J["legend-rect"]} ${ce.base}`):Tt.selectAll(`div.${ce.base}`).attr("class",`${J["legend-rect"]} ${ce.positive}`),Tt.selectAll("p").transition().duration(U).style("opacity",`${D?1:0}`),q.transition().duration(U).style("top","0px").style("left",(vt,At)=>`${At*Z}px`).style("opacity",1),q},q=>q.style("color",Ee).transition().duration(U).style("opacity",0).style("top","53px").remove());const j=Math.max(...X[0].map(q=>q?.length)),nt=Math.max(...X[1].map(q=>q?.length)),Dt=Math.max(j,nt),W=N?Q(pt).filter(q=>q.length>0).sort((q,Tt)=>Tt.length-q.length).map(q=>q.x0+"-"+q.x1):[],K=Y.select("#tooltip").style("opacity",0),Ct={prefix:s,suffix:o,formatType:l};function Rt(q,Tt){const ut=!N&&e==="compare",vt=N?t.valueKey??0:t.data[Tt-1].valueKey??0,At=Tt===1?$.select(".layer-1"):$.select(".layer-2");Tt===1?At.transition().duration(U).attr("transform",`translate(${i==="horizontal"&&ut?F/2:0}, 0)`):At.transition().duration(U).attr("transform",`translate(
|
|
125
125
|
0,
|
|
126
|
-
${i==="vertical"&&ut?H/2:0})`),R&&(a&&(q=q.filter(rt=>rt.length>0)),q.sort((rt,
|
|
126
|
+
${i==="vertical"&&ut?H/2:0})`),R&&(a&&(q=q.filter(rt=>rt.length>0)),q.sort((rt,gt)=>gt.length-rt.length));const jt=ye().domain([G,ot]).range(i==="vertical"?[0,F]:[0,H]),Xt=q.map(rt=>rt.x0+"-"+rt.x1),ae=Tt===2&&Xt.length===0?W:Xt,Zt=Xe().domain(ae).rangeRound(i==="vertical"?[0,F]:[0,H]),Ht=ye().domain([0,Dt]).nice();if(Tt===1){Ht.range(i==="vertical"?[ut?H/2:H,0]:[0,ut?F/2:F]).nice();const rt=i==="vertical"&&(!I||R)?N?J.rotatedAxisText:J.rotatedTopAxisText:J.axisText,gt=va(i==="vertical"?R?Zt:jt:Ht);i==="vertical"?gt.tickSizeOuter(0).ticks(10):gt.tickSizeOuter(0).ticks(5,"s").tickSize(-H),At.select(".x-axis").transition().duration(U).call(gt).attr("transform","translate(0, 0)").style("opacity",i==="horizontal"||!N&&R?1:0).selectAll("text").attr("class",rt);const kt=i==="vertical"?be(Ht):Ni(R?Zt:jt);i==="vertical"?kt.ticks(5,"s").tickSize(-F):kt.tickSizeOuter(0),At.select(".y-axis").transition().duration(U).attr("transform",`translate(
|
|
127
127
|
${i==="horizontal"&&ut?F/2:0},
|
|
128
128
|
0
|
|
129
|
-
)`).style("opacity",ut?1:0).call(kt)}else{
|
|
130
|
-
${_e(
|
|
129
|
+
)`).style("opacity",ut?1:0).call(kt)}else{Ht.range(i==="vertical"?ut?[0,H/2]:[H,0]:ut?[F/2,0]:[0,F]).nice();const rt=i==="vertical"&&(!I||R)?J.rotatedAxisText:J.axisText,gt=i==="vertical"?he(R?Zt:jt):va(Ht);i==="vertical"?gt.tickSizeOuter(0).ticks(10):gt.tickSizeOuter(0).ticks(5,"s").tickSize(H),At.select(".x-axis").attr("transform",`translate(0, ${i==="vertical"&&ut?H/2:H})`).transition().duration(U).call(gt).selectAll("text").attr("class",rt);const kt=be(i==="vertical"?Ht:R?Zt:jt);i==="vertical"?kt.ticks(5,"s").tickSize(-F):kt.tickSizeOuter(0),At.select(".y-axis").transition().duration(U).call(kt)}const te=rt=>(jt(rt.x0)||0)<jt(0)?Tt===1?st.layer1.negative:st.layer2.negative:N?st.base:Tt===1?st.layer1.positive:st.layer2.positive;At.selectAll("rect.bar").data(q,rt=>rt.x0+"-"+rt.x1).join(rt=>rt.append("rect").attr("class",`bar ${J.bar}`).attr("x",function(gt){return i==="vertical"?(R?Zt(gt.x0+"-"+gt.x1):jt(gt.x0)||0)||0:Ht(0)}).attr("width",function(gt){return i==="vertical"?R?Zt.bandwidth():jt(gt.x1)-jt(gt.x0)||0:0}).style("fill","#4ade80").style("stroke","#394447").attr("y",function(gt){return i==="vertical"?Ht(0):(R?Zt(gt.x0+"-"+gt.x1):jt(gt.x0)||0)||0}).attr("height",function(gt){return i==="vertical"?0:R?Zt.bandwidth():jt(gt.x1)-jt(gt.x0)||0}),void 0,rt=>rt.transition().duration(U).attr("y",Ht(0)).attr("height",0).style("fill","#a1a1aa").style("opacity",0).remove()).on("pointerenter",function(rt,gt){K.select("p.range span.badge").style("background",te(gt)),K.select("p.range span.label").text(`
|
|
130
|
+
${_e(gt.x0??0,Ct)}
|
|
131
131
|
<= ${vt} <
|
|
132
|
-
${_e(
|
|
133
|
-
`);const kt=
|
|
132
|
+
${_e(gt.x1??0,Ct)}
|
|
133
|
+
`);const kt=gt.length;K.select("p.amount").text(`
|
|
134
134
|
${kt}
|
|
135
135
|
member${kt>1?"s":""}
|
|
136
|
-
`),K.style("opacity",1),le(K,{e:rt,svg:et,yScale:
|
|
136
|
+
`),K.style("opacity",1),le(K,{e:rt,svg:et,yScale:Ht})}).on("pointermove",function(rt,gt){le(K,{e:rt,svg:et,yScale:Ht})}).on("pointerleave",function(rt,gt){K.style("opacity",0)}).on("dblclick",function(rt,gt){const kt=t,Wt=N?kt.valueKey??"":kt.data[Tt-1].valueKey??"";_({valueKey:Wt,data:gt})}).on("touchend",function(rt,gt){const kt=Date.now();if(kt-E.current<=300){const xt=t,Nt=N?xt.valueKey??"":xt.data[Tt-1].valueKey??"";_({valueKey:Nt,data:gt})}E.current=kt}).transition().duration(U).style("fill",te).attr("x",function(rt){return i==="vertical"?(R?Zt(rt.x0+"-"+rt.x1):jt(rt.x0)||0)||0:Ht(Tt===2&&ut?rt.length:0)}).attr("width",function(rt){if(i==="vertical"){if(R)return Zt.bandwidth();{const gt=rt.x0,kt=rt.x1,Wt=kt===gt?gt+1:kt;return jt(Wt)-jt(gt)||0}}else return Tt===2&&ut?F/2-Ht(rt.length):Ht(rt.length)}).attr("y",function(rt){return i==="vertical"?Tt===2&&e==="compare"?Ht(0):Ht(rt.length)||0:(R?Zt(rt.x0+"-"+rt.x1):jt(rt.x0)||0)||0}).attr("height",function(rt){if(i==="vertical")return Tt===2&&e==="compare"?Ht(rt.length):(ut?H/2:H)-Ht(rt.length)||0;if(R)return Zt.bandwidth();{const gt=rt.x0,kt=rt.x1,Wt=kt===gt?gt+1:kt;return jt(Wt)-jt(gt)||0}});const ie=Tt===1?N?"#394447":D?st.layer1.positive:st.base:st.layer2.positive;rv(At,{binRanges:jt,binSorted:Zt,isSorted:R},Ht,q,T,i,{showLine:c,showDots:u,lineStroke:String(Ve(ie)?.darker()),dotFill:ie})}Rt(X[0],1),Rt(X[1],2)},[t,e,n,a,T,p,R,i,{showLine:c,showDots:u,curve:h},{prefix:s,suffix:o,formatType:l}]);return m.jsx("div",{ref:f,style:{width:`${v}px`,height:`${b}px`,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:M,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsxs("div",{ref:d,className:`controls ${J[I?"controls-container":"controls-container-sm"]}`,children:[r&&m.jsxs("label",{className:J["controls-label"],style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:R,onChange:Y=>z(Y.target.checked)}),"Sort"]}),m.jsx("div",{className:`legends-container ${J["legends-container"]}`})]}),m.jsxs("div",{ref:w,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[m.jsx("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${T} ${p}`,children:m.jsxs("g",{className:"plot-area",children:[m.jsxs("g",{className:"layer-2",children:[m.jsx("g",{className:`${i==="vertical"?J["value-axis"]:""} y-axis`}),m.jsx("g",{className:`${i==="horizontal"?J["value-axis"]:""} x-axis`})]}),m.jsxs("g",{className:"layer-1",children:[m.jsx("g",{className:`${i==="vertical"?J["value-axis"]:""} y-axis`}),m.jsx("g",{className:`${i==="horizontal"?J["value-axis"]:""} x-axis`})]})]})}),m.jsxs(Qe,{children:[m.jsxs("p",{className:"range",style:{fontWeight:600,margin:"3px",marginBottom:0,fontSize:"14px",color:"wheat",display:"flex",alignItems:"center"},children:[m.jsx("span",{className:"badge",style:{width:8,height:8,borderRadius:2,border:"1px solid #a3a3a3"}}),m.jsx("span",{className:"label",style:{paddingLeft:4}})]}),m.jsx("p",{className:"amount",style:{fontWeight:700,margin:"3px",marginBottom:0,fontSize:"15px",color:"wheat",textAlign:"center"}}),m.jsx("p",{className:"detailTip",style:{fontWeight:600,margin:"3px",fontSize:"10px",color:"wheat",fontStyle:"italic",textAlign:"center"},children:"(dbl click bar for detail)"})]})]}),m.jsx(iv,{data:k,width:v,height:b,valueKey:t.valueKey??"",close:()=>{_({valueKey:"",data:[]})},tooltipFormat:{prefix:s,suffix:o,formatType:l}})]})})}const iv=({data:t,width:e,height:n,pageRows:r=10,tooltipFormat:a,close:i})=>{const[s,o]=bt.useState(1),l=t.data,c=Math.ceil(l.length/r);bt.useEffect(()=>{o(1)},[t]),bt.useEffect(()=>{l.length>0&&window.getSelection()?.removeAllRanges()},[l.length]);const u=l.length>0?Object.keys(l[0]):[],h=(s-1)*r,f=s*r-1,v=l.filter(b=>typeof b=="object").filter((b,d)=>d>=h&&d<=f);return m.jsxs("div",{className:`
|
|
137
137
|
${ce["table-container"]}
|
|
138
138
|
${l.length===0?ce["hide-table"]:ce["show-table"]}
|
|
139
139
|
`,style:{width:e,height:n},children:[m.jsxs("div",{style:{width:"100%",display:"flex",padding:5,justifyContent:"space-between"},children:[m.jsxs("div",{style:{display:"flex"},children:[m.jsxs("div",{className:ce["pagination-controls"],children:[m.jsx("button",{className:ce["pagination-btn"],title:"First Page",disabled:s===1,onClick:()=>{o(1)},children:"«"}),m.jsx("button",{className:ce["pagination-btn"],title:"Previous Page",disabled:s===1,onClick:()=>{o(s-1)},children:"‹"}),m.jsxs("span",{className:ce["pagination-info"],children:["Page",m.jsx("span",{className:ce["pagination-page-number"],children:s}),"of ",c]}),m.jsx("button",{className:ce["pagination-btn"],title:"Next Page",disabled:s===c,onClick:()=>{o(s+1)},children:"›"}),m.jsx("button",{className:ce["pagination-btn"],title:"Last Page",disabled:s===c,onClick:()=>{o(c)},children:"»"})]}),m.jsxs("p",{style:{fontWeight:600,textAlign:"left",paddingLeft:4},children:[_e(l.x0,a),` <= ${t.valueKey} < `,_e(l.x1,a)]})]}),m.jsx("button",{className:`${J.button}`,style:{marginRight:6},onClick:i,children:"Ok"})]}),m.jsx("div",{className:ce["table-scroll-container"],children:m.jsxs("table",{className:ce["responsive-table"],children:[m.jsx("thead",{children:m.jsx("tr",{children:u.map(b=>m.jsx("th",{children:b===t.valueKey?b.toUpperCase():b},b))})}),m.jsx("tbody",{children:v.map((b,d)=>m.jsx("tr",{children:u.map(x=>m.jsx("td",{children:x===t.valueKey?_e(b[x],a):String(b[x]??"")},x))},d))})]})})]})};function sv({data:t,noLabel:e,sourceNode:n="",targetNode:r="",hierarchyMode:a="default",color:{idx:i=0,type:s="fixed"}={idx:0,type:"fixed"},linkType:{curve:o="straight",directed:l=!1}={curve:"straight",directed:!1},tooltipFormat:{prefix:c="",suffix:u="",formatType:h="long"}={prefix:"",suffix:"",formatType:"long"}}){const[f,g]=Ne(),{width:v,height:b}=g,[d,x]=He(),{width:S,height:w}=x,[y,T]=bt.useState("");bt.useDeferredValue(y);const[p,k]=bt.useState(!1);bt.useEffect(()=>{k(!1)},[y]);const _=bt.useRef(!0),E=bt.useRef(!0),R=S>576,z=bt.useRef(null),I={idx:i,type:s},N={curve:o,directed:l},U=250,M="name"in t?"hierarchy":"links"in t?"network":"bubble",Y=!("name"in t)&&!("nodes"in t&&("links"in t||"valueProp"in t));bt.useEffect(()=>{_.current=!0,E.current=!0,setTimeout(()=>{E.current=!1},250),k(!1),T("")},[t]),bt.useEffect(()=>{_.current=!0},[a,S,w,e]),bt.useEffect(()=>{E.current||(_.current=!1)},[n,r,y,p]),bt.useEffect(()=>{T("")},[S,w]);const C=Se(F=>{if(S===0||w===0||Y)return;const H=Math.min(S,w)/2-30,V=F.select("svg"),et=V.selectAll("defs"),$=V.node(),dt=V.select(".plot-area"),pt=F.select(".controls").select(".legends-container"),_t=M==="bubble"?t.groupBy:"",G=_t!==""?[...new Set(t.nodes.map(P=>P[_t]))]:[],ot=60,O=function(P){const at=J[R?"legend-container":"legend-container-sm"],ht=J[R?"legend-container-active":"legend-container-active-sm"],Lt=J[R?"legend-container-inactive":"legend-container-inactive-sm"];return`
|
|
140
140
|
${y!==""?y===P?ht:Lt:at}
|
|
141
141
|
legend-item
|
|
142
|
-
`},Q=hr(qr);pt.selectAll(".legend-item").data([...G],P=>P).join(P=>{const at=P.append("div").attr("class",O).style("left",(ht,Lt)=>`${Lt*ot}px`).style("top","-53px").style("opacity",0);return at.append("div").attr("class",J["legend-rect"]).style("background",ht=>Q(ht)).style("border-radius","50%"),at.append("span").attr("class",J["legend-label"]).text(ht=>ht),at.transition().duration(U).style("top","0px").style("opacity",1),at},P=>(P.attr("class",O).transition().duration(U).style("top","0px").style("left",(at,ht)=>`${ht*ot}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",at=>Q(at)).style("border-radius","50%"),P.select(`.${J["legend-label"]}`).text(at=>at),P),P=>P.transition().duration(U).style("opacity",0).style("top","53px").remove().remove()).on("click",function(P,at){T(y!==at?at:"")});function D(P){function at(ht,Lt,Dt){Lt===0?ht.group=ht.name:(Lt===1&&(Dt=ht.name),ht.group=Dt),ht.children?.forEach(zt=>at(zt,Lt+1,Dt))}return at(P,0,P.name),P}const tt=we(t);(M==="network"||M==="hierarchy")&&D(tt);const L=F.select("#tooltip").style("opacity",0),Z=M==="bubble"?t.tooltipColumns??["label"].concat(Object.keys(t.nodes[0]).map(P=>P)):["name","value"],ft=L.selectAll("p.content").data(Z,P=>P).join("p").attr("class",P=>`content ${P}`).style("font-weight",300).style("margin",1).style("font-size",300).style("color","wheat"),st=M==="hierarchy"?fr(tt):tt;let it=[],A=[],j=[],nt=F0();function $t(P,at,ht){const Lt=t.valueProp,zt={label:"bubble nodes",children:P.map(Kt=>{const Ge=Kt[Lt];return{...Kt,value:Ge}})},Jt=Cu().padding(2).size([at,at]).value(function(Kt){return Kt.value}).nodes(zt)[0],ge=[Jt.x,Jt.y,Jt.r*2],Et=Jt.children,Qt=at/ge[2],Bt=Et.map(Kt=>{const Ge=Kt[_t],{x:Ze,y:We,r:ve,...dn}=Kt;return{sortedX:(Ze-ge[0])*Qt,sortedY:(We-ge[1])*Qt,r:ve*Qt,value:Ge,...dn}});return ht&&ht.nodes(Bt),Bt}const{curve:W,directed:K}=N;if(_.current)if(M==="hierarchy"){const at=()=>(st.sum(Dt=>Dt.value??1),Jl().size([S,w]).padding(1)(st));if(a!=="default"){if(A=a==="nodes only"?at().descendants():at().leaves(),A.forEach(ht=>{ht.x-=S/2,ht.y-=w/2}),a==="nodes only"){const ht=Gt(A,function(Dt){return Dt.value}),Lt=oc().exponent(.5).range([2,60]).domain([0,ht??0]);A.forEach(Dt=>{Dt.r=Lt(Dt.value)})}}else{at().descendants();const Lt=tc().size([2*Math.PI,H]).separation((Dt,zt)=>(Dt.parent==zt.parent?1:2)/Dt.depth)(st);Lt.each(Dt=>{Dt.baseX=Dt.x,Dt.baseY=Dt.y,Dt.finalX=Dt.y*Math.cos(Dt.x-Math.PI/2),Dt.finalY=Dt.y*Math.sin(Dt.x-Math.PI/2),delete Dt.x,delete Dt.y}),A=Lt.descendants(),it=Lt.links()}}else if(M==="network"){if(A=st.nodes,it=st.links,K){const at=[...new Set(it.map(ht=>ht.type))];j=at.some(ht=>ht===void 0)?["arrow"]:[...at]}}else{const P=st.nodes,at=Math.min(S,w);A=$t(P,at,nt)}const Ct=P=>a==="default"?P.depth===0?8:P.depth===1?5:3:P.r,Rt=4,q=.03;if(_.current){let P=function(ht,Lt,Dt=.2){let zt=[];function Yt(Ot){const Jt=Gu(zt,Et=>at(Et,Lt),ht),ge=Ot*Dt;for(const Et of zt){const Qt=ht(Et),{x:Bt,y:Kt}=Jt.get(Qt)??{x:0,y:0};Et.vx??=0,Et.vy??=0,Et.vx-=((Et.x??0)-Bt)*ge,Et.vy-=((Et.y??0)-Kt)*ge}}return Yt.initialize=Ot=>{zt=Ot},Yt},at=function(ht,Lt){let Dt=0,zt=0,Yt=0;for(const Ot of ht){const ge=Lt(Ot)**2;Dt+=(Ot.x??0)*ge,zt+=(Ot.y??0)*ge,Yt+=ge}return{x:Yt===0?0:Dt/Yt,y:Yt===0?0:zt/Yt}};if(nt.nodes(A),M==="hierarchy")if(a!=="default"){let ht=function(){let Yt,Ot;const Jt=()=>{const ge=Oa(Yt,Et=>Et.x,Et=>Et.y);for(const Et of Yt){const Qt=Et.r+Ot,Bt=Et.x-Qt,Kt=Et.y-Qt,Ge=Et.x+Qt,Ze=Et.y+Qt;ge.visit((We,ve,dn,_i,kr)=>{if(!We.length){for(let Ye=We;Ye;Ye=Ye.next)if(Ye.data!==Et){const Zn=Et.r+Ye.data.r+(Et.data.group===Ye.data.data.group?2:6);let Jn=Et.x-Ye.data.x,Ar=Et.y-Ye.data.y,pn=Math.hypot(Jn,Ar);pn<Zn&&(pn=(pn-Zn)/pn*.4,Et.x-=Jn*=pn,Et.y-=Ar*=pn,Ye.data.x+=Jn,Ye.data.y+=Ar)}}return ve>Ge||_i<Bt||dn>Ze||kr<Kt})}};return Jt.initialize=ge=>{Yt=ge,Ot=Gt(Yt,Et=>Et.r)+Math.max(2,6)},Jt};if(a==="nodes only"){let Lt=function(zt){return-Math.pow(zt.r,2)*Dt};const Dt=.03;nt.velocityDecay(.2).force("x",Nn().strength(.03).x(0)).force("y",Tn().strength(.03).y(0)).force("charge",Or().strength(zt=>Lt(zt))).alpha(1).alphaTarget(0)}else{const Lt=P(Dt=>Dt.data.group??"",Dt=>Dt.r,.2);nt.force("x",Nn(0).strength(.01)).force("y",Tn(0).strength(.01)).force("cluster",Lt).force("collide",ht()).alpha(1).alphaTarget(0)}}else nt.force("center",fs()).force("link",ds(it).id(ht=>ht.id).distance(50)).force("x",Nn(-S/2).x(ht=>ht.finalX??0).strength(1)).force("y",Tn(-w/2).y(ht=>ht.finalY??0).strength(1)).force("charge",Or().strength(-30)).force("collide",Wr().radius(Ct)).alpha(.15).alphaTarget(0);else if(M==="network")W==="straight"?nt.force("link",ds(it).id(ht=>ht.id)).force("charge",Or()).force("center",fs().x(0).y(0)).alpha(1).alphaTarget(0):W==="curved"&&nt.force("link",ds(it).id(ht=>ht.id)).force("charge",Or()).force("center",fs()).alpha(1).alphaTarget(0);else if(M==="bubble"){let ht=function(Dt){return-Math.pow(Dt.r??0,2)*q};nt.velocityDecay(.2).force("x",Nn().strength(q).x(0)).force("y",Tn().strength(q).y(0));const{clusterByGroup:Lt}=t;if(!Lt)nt.force("charge",Or().strength(ht));else{const Dt=P(zt=>String(zt[t.groupBy]),zt=>zt.r??0,.2);nt.force("cluster",Dt).force("collide",Wr().radius(zt=>zt.r??2).iterations(3))}}z.current=nt}else if(nt=z.current,A=nt?.nodes(),M!=="bubble"){if(it=nt.force("link")?.links(),K){const ht=[...new Set(it.map(Lt=>Lt.type))];j=ht.some(Lt=>Lt===void 0)?["arrow"]:[...ht]}}else{const P=S>w?"desktop":"mobile",at=P==="desktop"?{x:S/4,y:0}:{x:0,y:w/4},ht=P==="desktop"?{x:-S/4,y:0}:{x:0,y:-w/4};if(p){let Lt=function(zt){if(!zt.length)return 0;const Yt=zt.reduce((Et,Qt)=>Et+Math.PI*Qt*Qt,0),Ot=Math.PI/(3+2*Math.SQRT2),Jt=Math.sqrt(Yt/Ot),ge=2*Math.max(...zt);return Math.max(Jt,ge)},Dt=function(zt,Yt=0){if(!zt||zt.length===0)return 0;const Ot=[...zt].sort((Ze,We)=>We-Ze),Jt=Ot.reduce((Ze,We)=>Ze+Math.PI*Math.pow(We+Yt/2,2),0);let ge=Math.max(Ot[0]*2+Yt,Math.sqrt(Jt/.75)),Et=0,Qt=0,Bt=0,Kt=0;for(const Ze of Ot){const We=Ze*2+Yt;Et+We>ge&&Et>0&&(Qt+=Bt,Et=0,Bt=0),Et+=We,Bt=Math.max(Bt,We),Kt=Math.max(Kt,Et)}const Ge=Qt+Bt;return Math.ceil(Math.max(Kt,Ge))};if(y!==""){const zt=t.groupBy??"",Yt=A.filter(ve=>ve[zt]===y),Ot=Yt.map(ve=>ve.r),Jt=Lt(Ot)+20;Dt(Ot,1)+20;const ge=Yt.map(ve=>{const{value:dn,r:_i,x:kr,y:Ye,sortedX:Zn,sortedY:Jn,vx:Ar,vy:pn,...ca}=ve;return{...ca}}),Et=$t(ge,Jt),Qt=A.filter(ve=>ve[zt]!==y),Bt=Qt.map(ve=>ve.r),Kt=Lt(Bt)+30;Dt(Bt,1)+20;const Ge=Qt.map(ve=>{const{value:dn,r:_i,x:kr,y:Ye,sortedX:Zn,sortedY:Jn,vx:Ar,vy:pn,...ca}=ve;return{...ca}}),Ze=$t(Ge,Kt),We=ve=>{const dn=ve[zt]===y,kr=(dn?Et:Ze).find(ca=>ca.label===ve.label),Ye=kr?.sortedX??0,Zn=dn?at:ht,Jn=Ye+Zn.x,pn=(kr?.sortedY??0)+Zn.y;return{sortedX:Jn,sortedY:pn}};nt.force("x",Nn().x(ve=>We(ve).sortedX).strength(.95)).force("y",Tn().y(ve=>We(ve).sortedY).strength(.95))}else nt.force("x",Nn().strength(.5).x(zt=>zt.sortedX)).force("y",Tn().strength(.5).y(zt=>zt.sortedY));nt.force("collide",Wr().radius(zt=>p?zt.r/3:zt.r)).alpha(p?y!==""?.065:.075:.225).alphaTarget(0).restart()}else y===""?nt.force("x",Nn().strength(q).x(0)).force("y",Tn().strength(q).y(0)):nt.force("x",Nn().strength(q).x(Lt=>Lt[_t]===y?at.x:ht.x)).force("y",Tn().strength(q).y(Lt=>Lt[_t]===y?at.y:ht.y)),nt.alpha(.75).alphaTarget(0),setTimeout(()=>{nt.restart()},500)}const Tt=M==="bubble"||M==="hierarchy"&&a!=="default";function ut(P,at,ht){if(Tt)return"no link";const Lt=P.nodes.filter(Et=>M==="hierarchy"?Et.data.name===n:M==="network"?Et.id===n:void 0);if(!Lt||Lt.length===0)return"no source node";const Dt=P.nodes.filter(Et=>M==="hierarchy"?Et.data.name===r:M==="network"?Et.id===r:void 0);if(!Dt||Dt.length===0)return"no target node";const zt=new Map,Yt=new Map,Ot=new Set,Jt=new Map;for(const Et of P.nodes){const Qt=M==="hierarchy"?Et.data.name:Et.id;zt.set(Qt,1/0),Yt.set(Qt,null),Ot.add(Qt),Jt.set(Qt,[])}for(const Et of P.links){const Qt=M==="hierarchy"?Et.source.data.name:Et.source.id,Bt=M==="hierarchy"?Et.target.data.name:Et.target.id,Kt=M==="hierarchy"?1:Et.value??1;Jt.get(Qt)?.push({node:Bt,weight:Kt}),Jt.get(Bt)?.push({node:Qt,weight:Kt})}for(zt.set(at,0);Ot.size>0;){let Et=null,Qt=1/0;for(const Bt of Ot){const Kt=zt.get(Bt);Kt<Qt&&(Qt=Kt,Et=Bt)}if(Et===null||Et===ht)break;Ot.delete(Et);for(const Bt of Jt.get(Et)){if(!Ot.has(Bt.node))continue;const Kt=zt.get(Et)+Bt.weight;Kt<zt.get(Bt.node)&&(zt.set(Bt.node,Kt),Yt.set(Bt.node,Et))}}return{distances:zt,previous:Yt,path:ht!==void 0?(Et=>{const Qt=[];let Bt=Et;for(;Bt!==null;)Qt.unshift(Bt),Bt=Yt.get(Bt);return Qt})(ht):void 0}}const vt=ut({nodes:A,links:it},n,r),At=typeof vt=="string",jt=hr(j,qr),Xt="#999";et.selectAll("marker").data(j,P=>typeof P=="string"?P:"").join("marker").attr("id",P=>`arrow-${P}`).attr("viewBox","0 -5 10 10").attr("refX",15).attr("refY",-.5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto").append("path").attr("fill",P=>P==="arrow"?Xt:jt(P??"")).attr("d","M0,-5L10,0L0,5");const{distances:ae,previous:Zt,path:Wt}=vt,te=P=>{if(Array.isArray(Wt)){const at=M==="network"?P.source.id:P.source.data.name,ht=M==="network"?P.target.id:P.target.data.name;let Lt=!1;for(let Dt=0;Dt<Wt.length-1;Dt++){if(at===Wt[Dt]&&ht===Wt[Dt+1]){Lt=!0;break}if(ht===Wt[Dt]&&at===Wt[Dt+1]){Lt=!0;break}}return Lt}return!1},ie=.25,rt=P=>At||te(P)?1:ie,yt=P=>At||te(P)?"auto":"none",kt=P=>(At?K:K&&te(P))?P.type?`url(#arrow-${P.type})`:"url(#arrow-arrow)":"",Ft=dt.selectAll("path.link").data(it,function(P,at){if(M==="hierarchy"){const ht=P.source.data?.name,Lt=P.source.data?.name;return`${ht}-${Lt}`}else if(M==="network"){const ht=P.source.id,Lt=P.target.id;return`${ht}-${Lt}`}return at}).join(P=>P.append("path").attr("class","link").attr("fill","none").attr("stroke-width",1.5).attr("stroke",at=>at.type?Q(at.type):Xt).style("pointer-events",yt).attr("marker-end",kt).attr("stroke-opacity",rt),void 0,P=>P.remove()).attr("stroke",P=>P.type?Q(P.type):Xt).attr("marker-end",kt).attr("stroke-opacity",rt).style("pointer-events",yt);function gt(P){const at=Cn(P.source),ht=Gn(P.source),Lt=Cn(P.target),Dt=Gn(P.target);if(W==="straight")return`M${at},${ht} L${Lt},${Dt}`;const zt=Math.hypot(Lt-at,Dt-ht);return`
|
|
142
|
+
`},Q=hr(qr);pt.selectAll(".legend-item").data([...G],P=>P).join(P=>{const at=P.append("div").attr("class",O).style("left",(ht,Lt)=>`${Lt*ot}px`).style("top","-53px").style("opacity",0);return at.append("div").attr("class",J["legend-rect"]).style("background",ht=>Q(ht)).style("border-radius","50%"),at.append("span").attr("class",J["legend-label"]).text(ht=>ht),at.transition().duration(U).style("top","0px").style("opacity",1),at},P=>(P.attr("class",O).transition().duration(U).style("top","0px").style("left",(at,ht)=>`${ht*ot}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",at=>Q(at)).style("border-radius","50%"),P.select(`.${J["legend-label"]}`).text(at=>at),P),P=>P.transition().duration(U).style("opacity",0).style("top","53px").remove().remove()).on("click",function(P,at){T(y!==at?at:"")});function D(P){function at(ht,Lt,$t){Lt===0?ht.group=ht.name:(Lt===1&&($t=ht.name),ht.group=$t),ht.children?.forEach(zt=>at(zt,Lt+1,$t))}return at(P,0,P.name),P}const tt=we(t);(M==="network"||M==="hierarchy")&&D(tt);const L=F.select("#tooltip").style("opacity",0),Z=M==="bubble"?t.tooltipColumns??["label"].concat(Object.keys(t.nodes[0]).map(P=>P)):["name","value"],ft=L.selectAll("p.content").data(Z,P=>P).join("p").attr("class",P=>`content ${P}`).style("font-weight",300).style("margin",1).style("font-size",300).style("color","wheat"),st=M==="hierarchy"?fr(tt):tt;let it=[],A=[],j=[],nt=F0();function Dt(P,at,ht){const Lt=t.valueProp,zt={label:"bubble nodes",children:P.map(Kt=>{const Ge=Kt[Lt];return{...Kt,value:Ge}})},Jt=Cu().padding(2).size([at,at]).value(function(Kt){return Kt.value}).nodes(zt)[0],ge=[Jt.x,Jt.y,Jt.r*2],Et=Jt.children,Qt=at/ge[2],Bt=Et.map(Kt=>{const Ge=Kt[_t],{x:Ze,y:We,r:ve,...dn}=Kt;return{sortedX:(Ze-ge[0])*Qt,sortedY:(We-ge[1])*Qt,r:ve*Qt,value:Ge,...dn}});return ht&&ht.nodes(Bt),Bt}const{curve:W,directed:K}=N;if(_.current)if(M==="hierarchy"){const at=()=>(st.sum($t=>$t.value??1),Jl().size([S,w]).padding(1)(st));if(a!=="default"){if(A=a==="nodes only"?at().descendants():at().leaves(),A.forEach(ht=>{ht.x-=S/2,ht.y-=w/2}),a==="nodes only"){const ht=Gt(A,function($t){return $t.value}),Lt=oc().exponent(.5).range([2,60]).domain([0,ht??0]);A.forEach($t=>{$t.r=Lt($t.value)})}}else{at().descendants();const Lt=tc().size([2*Math.PI,H]).separation(($t,zt)=>($t.parent==zt.parent?1:2)/$t.depth)(st);Lt.each($t=>{$t.baseX=$t.x,$t.baseY=$t.y,$t.finalX=$t.y*Math.cos($t.x-Math.PI/2),$t.finalY=$t.y*Math.sin($t.x-Math.PI/2),delete $t.x,delete $t.y}),A=Lt.descendants(),it=Lt.links()}}else if(M==="network"){if(A=st.nodes,it=st.links,K){const at=[...new Set(it.map(ht=>ht.type))];j=at.some(ht=>ht===void 0)?["arrow"]:[...at]}}else{const P=st.nodes,at=Math.min(S,w);A=Dt(P,at,nt)}const Ct=P=>a==="default"?P.depth===0?8:P.depth===1?5:3:P.r,Rt=4,q=.03;if(_.current){let P=function(ht,Lt,$t=.2){let zt=[];function Yt(Ot){const Jt=Gu(zt,Et=>at(Et,Lt),ht),ge=Ot*$t;for(const Et of zt){const Qt=ht(Et),{x:Bt,y:Kt}=Jt.get(Qt)??{x:0,y:0};Et.vx??=0,Et.vy??=0,Et.vx-=((Et.x??0)-Bt)*ge,Et.vy-=((Et.y??0)-Kt)*ge}}return Yt.initialize=Ot=>{zt=Ot},Yt},at=function(ht,Lt){let $t=0,zt=0,Yt=0;for(const Ot of ht){const ge=Lt(Ot)**2;$t+=(Ot.x??0)*ge,zt+=(Ot.y??0)*ge,Yt+=ge}return{x:Yt===0?0:$t/Yt,y:Yt===0?0:zt/Yt}};if(nt.nodes(A),M==="hierarchy")if(a!=="default"){let ht=function(){let Yt,Ot;const Jt=()=>{const ge=Oa(Yt,Et=>Et.x,Et=>Et.y);for(const Et of Yt){const Qt=Et.r+Ot,Bt=Et.x-Qt,Kt=Et.y-Qt,Ge=Et.x+Qt,Ze=Et.y+Qt;ge.visit((We,ve,dn,_i,kr)=>{if(!We.length){for(let Ye=We;Ye;Ye=Ye.next)if(Ye.data!==Et){const Zn=Et.r+Ye.data.r+(Et.data.group===Ye.data.data.group?2:6);let Jn=Et.x-Ye.data.x,Ar=Et.y-Ye.data.y,pn=Math.hypot(Jn,Ar);pn<Zn&&(pn=(pn-Zn)/pn*.4,Et.x-=Jn*=pn,Et.y-=Ar*=pn,Ye.data.x+=Jn,Ye.data.y+=Ar)}}return ve>Ge||_i<Bt||dn>Ze||kr<Kt})}};return Jt.initialize=ge=>{Yt=ge,Ot=Gt(Yt,Et=>Et.r)+Math.max(2,6)},Jt};if(a==="nodes only"){let Lt=function(zt){return-Math.pow(zt.r,2)*$t};const $t=.03;nt.velocityDecay(.2).force("x",Nn().strength(.03).x(0)).force("y",Tn().strength(.03).y(0)).force("charge",Or().strength(zt=>Lt(zt))).alpha(1).alphaTarget(0)}else{const Lt=P($t=>$t.data.group??"",$t=>$t.r,.2);nt.force("x",Nn(0).strength(.01)).force("y",Tn(0).strength(.01)).force("cluster",Lt).force("collide",ht()).alpha(1).alphaTarget(0)}}else nt.force("center",fs()).force("link",ds(it).id(ht=>ht.id).distance(50)).force("x",Nn(-S/2).x(ht=>ht.finalX??0).strength(1)).force("y",Tn(-w/2).y(ht=>ht.finalY??0).strength(1)).force("charge",Or().strength(-30)).force("collide",Wr().radius(Ct)).alpha(.15).alphaTarget(0);else if(M==="network")W==="straight"?nt.force("link",ds(it).id(ht=>ht.id)).force("charge",Or()).force("center",fs().x(0).y(0)).alpha(1).alphaTarget(0):W==="curved"&&nt.force("link",ds(it).id(ht=>ht.id)).force("charge",Or()).force("center",fs()).alpha(1).alphaTarget(0);else if(M==="bubble"){let ht=function($t){return-Math.pow($t.r??0,2)*q};nt.velocityDecay(.2).force("x",Nn().strength(q).x(0)).force("y",Tn().strength(q).y(0));const{clusterByGroup:Lt}=t;if(!Lt)nt.force("charge",Or().strength(ht));else{const $t=P(zt=>String(zt[t.groupBy]),zt=>zt.r??0,.2);nt.force("cluster",$t).force("collide",Wr().radius(zt=>zt.r??2).iterations(3))}}z.current=nt}else if(nt=z.current,A=nt?.nodes(),M!=="bubble"){if(it=nt.force("link")?.links(),K){const ht=[...new Set(it.map(Lt=>Lt.type))];j=ht.some(Lt=>Lt===void 0)?["arrow"]:[...ht]}}else{const P=S>w?"desktop":"mobile",at=P==="desktop"?{x:S/4,y:0}:{x:0,y:w/4},ht=P==="desktop"?{x:-S/4,y:0}:{x:0,y:-w/4};if(p){let Lt=function(zt){if(!zt.length)return 0;const Yt=zt.reduce((Et,Qt)=>Et+Math.PI*Qt*Qt,0),Ot=Math.PI/(3+2*Math.SQRT2),Jt=Math.sqrt(Yt/Ot),ge=2*Math.max(...zt);return Math.max(Jt,ge)},$t=function(zt,Yt=0){if(!zt||zt.length===0)return 0;const Ot=[...zt].sort((Ze,We)=>We-Ze),Jt=Ot.reduce((Ze,We)=>Ze+Math.PI*Math.pow(We+Yt/2,2),0);let ge=Math.max(Ot[0]*2+Yt,Math.sqrt(Jt/.75)),Et=0,Qt=0,Bt=0,Kt=0;for(const Ze of Ot){const We=Ze*2+Yt;Et+We>ge&&Et>0&&(Qt+=Bt,Et=0,Bt=0),Et+=We,Bt=Math.max(Bt,We),Kt=Math.max(Kt,Et)}const Ge=Qt+Bt;return Math.ceil(Math.max(Kt,Ge))};if(y!==""){const zt=t.groupBy??"",Yt=A.filter(ve=>ve[zt]===y),Ot=Yt.map(ve=>ve.r),Jt=Lt(Ot)+20;$t(Ot,1)+20;const ge=Yt.map(ve=>{const{value:dn,r:_i,x:kr,y:Ye,sortedX:Zn,sortedY:Jn,vx:Ar,vy:pn,...ca}=ve;return{...ca}}),Et=Dt(ge,Jt),Qt=A.filter(ve=>ve[zt]!==y),Bt=Qt.map(ve=>ve.r),Kt=Lt(Bt)+30;$t(Bt,1)+20;const Ge=Qt.map(ve=>{const{value:dn,r:_i,x:kr,y:Ye,sortedX:Zn,sortedY:Jn,vx:Ar,vy:pn,...ca}=ve;return{...ca}}),Ze=Dt(Ge,Kt),We=ve=>{const dn=ve[zt]===y,kr=(dn?Et:Ze).find(ca=>ca.label===ve.label),Ye=kr?.sortedX??0,Zn=dn?at:ht,Jn=Ye+Zn.x,pn=(kr?.sortedY??0)+Zn.y;return{sortedX:Jn,sortedY:pn}};nt.force("x",Nn().x(ve=>We(ve).sortedX).strength(.95)).force("y",Tn().y(ve=>We(ve).sortedY).strength(.95))}else nt.force("x",Nn().strength(.5).x(zt=>zt.sortedX)).force("y",Tn().strength(.5).y(zt=>zt.sortedY));nt.force("collide",Wr().radius(zt=>p?zt.r/3:zt.r)).alpha(p?y!==""?.065:.075:.225).alphaTarget(0).restart()}else y===""?nt.force("x",Nn().strength(q).x(0)).force("y",Tn().strength(q).y(0)):nt.force("x",Nn().strength(q).x(Lt=>Lt[_t]===y?at.x:ht.x)).force("y",Tn().strength(q).y(Lt=>Lt[_t]===y?at.y:ht.y)),nt.alpha(.75).alphaTarget(0),setTimeout(()=>{nt.restart()},500)}const Tt=M==="bubble"||M==="hierarchy"&&a!=="default";function ut(P,at,ht){if(Tt)return"no link";const Lt=P.nodes.filter(Et=>M==="hierarchy"?Et.data.name===n:M==="network"?Et.id===n:void 0);if(!Lt||Lt.length===0)return"no source node";const $t=P.nodes.filter(Et=>M==="hierarchy"?Et.data.name===r:M==="network"?Et.id===r:void 0);if(!$t||$t.length===0)return"no target node";const zt=new Map,Yt=new Map,Ot=new Set,Jt=new Map;for(const Et of P.nodes){const Qt=M==="hierarchy"?Et.data.name:Et.id;zt.set(Qt,1/0),Yt.set(Qt,null),Ot.add(Qt),Jt.set(Qt,[])}for(const Et of P.links){const Qt=M==="hierarchy"?Et.source.data.name:Et.source.id,Bt=M==="hierarchy"?Et.target.data.name:Et.target.id,Kt=M==="hierarchy"?1:Et.value??1;Jt.get(Qt)?.push({node:Bt,weight:Kt}),Jt.get(Bt)?.push({node:Qt,weight:Kt})}for(zt.set(at,0);Ot.size>0;){let Et=null,Qt=1/0;for(const Bt of Ot){const Kt=zt.get(Bt);Kt<Qt&&(Qt=Kt,Et=Bt)}if(Et===null||Et===ht)break;Ot.delete(Et);for(const Bt of Jt.get(Et)){if(!Ot.has(Bt.node))continue;const Kt=zt.get(Et)+Bt.weight;Kt<zt.get(Bt.node)&&(zt.set(Bt.node,Kt),Yt.set(Bt.node,Et))}}return{distances:zt,previous:Yt,path:ht!==void 0?(Et=>{const Qt=[];let Bt=Et;for(;Bt!==null;)Qt.unshift(Bt),Bt=Yt.get(Bt);return Qt})(ht):void 0}}const vt=ut({nodes:A,links:it},n,r),At=typeof vt=="string",jt=hr(j,qr),Xt="#999";et.selectAll("marker").data(j,P=>typeof P=="string"?P:"").join("marker").attr("id",P=>`arrow-${P}`).attr("viewBox","0 -5 10 10").attr("refX",15).attr("refY",-.5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto").append("path").attr("fill",P=>P==="arrow"?Xt:jt(P??"")).attr("d","M0,-5L10,0L0,5");const{distances:ae,previous:Zt,path:Ht}=vt,te=P=>{if(Array.isArray(Ht)){const at=M==="network"?P.source.id:P.source.data.name,ht=M==="network"?P.target.id:P.target.data.name;let Lt=!1;for(let $t=0;$t<Ht.length-1;$t++){if(at===Ht[$t]&&ht===Ht[$t+1]){Lt=!0;break}if(ht===Ht[$t]&&at===Ht[$t+1]){Lt=!0;break}}return Lt}return!1},ie=.25,rt=P=>At||te(P)?1:ie,gt=P=>At||te(P)?"auto":"none",kt=P=>(At?K:K&&te(P))?P.type?`url(#arrow-${P.type})`:"url(#arrow-arrow)":"",Wt=dt.selectAll("path.link").data(it,function(P,at){if(M==="hierarchy"){const ht=P.source.data?.name,Lt=P.source.data?.name;return`${ht}-${Lt}`}else if(M==="network"){const ht=P.source.id,Lt=P.target.id;return`${ht}-${Lt}`}return at}).join(P=>P.append("path").attr("class","link").attr("fill","none").attr("stroke-width",1.5).attr("stroke",at=>at.type?Q(at.type):Xt).style("pointer-events",gt).attr("marker-end",kt).attr("stroke-opacity",rt),void 0,P=>P.remove()).attr("stroke",P=>P.type?Q(P.type):Xt).attr("marker-end",kt).attr("stroke-opacity",rt).style("pointer-events",gt);function xt(P){const at=Cn(P.source),ht=Gn(P.source),Lt=Cn(P.target),$t=Gn(P.target);if(W==="straight")return`M${at},${ht} L${Lt},${$t}`;const zt=Math.hypot(Lt-at,$t-ht);return`
|
|
143
143
|
M${at},${ht}
|
|
144
|
-
A${zt},${zt} 0 0,1 ${Lt},${
|
|
145
|
-
`}const
|
|
144
|
+
A${zt},${zt} 0 0,1 ${Lt},${$t}
|
|
145
|
+
`}const Nt=P=>{if(typeof vt=="string")return"no path to highlight";const{path:at}=vt;if(Array.isArray(at)){const ht=M==="network"?P.id:P.data.name,Lt=at.indexOf(ht);return Lt===0||Lt===at.length-1?"source or destination":Lt>-1?"path":"not path member"}return"not path member"},B=P=>M==="hierarchy"?Ct(P):M==="network"?P.radius??Rt:P.r>0?P.r:0;function mt(P,at){return M==="hierarchy"?P.data?.name??"":M==="network"?P.id:at}const Mt=P=>{if(M==="hierarchy"){const at=P;if(at.data.color)return at.data.color;const{group:ht}=at.data;return ht!==void 0?Q(String(ht))??"steelblue":"steelblue"}else if(M==="network"){const at=P.group;return at!==void 0?Q(String(at))??"steelblue":"steelblue"}else if(M==="bubble"){const at=P[_t];return Q(at)}return"steelblue"},Pt=P=>M==="hierarchy"?P.children?"none":"#fff":Sa(Mt(P)).darker().toString(),ee=.5,re=P=>{const at=Nt(P);return at==="no path to highlight"?1:at==="not path member"?ee:1},lt=P=>{const at=Nt(P);return at==="no path to highlight"?"auto":at==="not path member"?"none":"auto"},yt=dt.selectAll("circle.node").data(A,mt).join(P=>P.append("circle").attr("class","node").attr("stroke",at=>M==="hierarchy"?at.children?null:"#fff":"none").attr("r",B).attr("fill",Mt).style("opacity",re).style("pointer-events",lt),void 0,P=>P.remove()).attr("stroke",Pt).attr("r",B).attr("fill",Mt).style("opacity",re).style("pointer-events",lt);M==="hierarchy"&&a!=="default"&&yt.transition().delay((P,at)=>Math.random()*500).duration(750).attrTween("r",P=>{const at=Ae(0,P.r);return Lt=>`${at(Lt)}`});const St=6,Ft=12,ue=10,Ut="black";yt.on("pointerenter",function(P,at){if(qt(this).style("stroke",Ut),(M==="hierarchy"||M==="bubble")&&L.transition().duration(250).style("opacity",1),M==="network"&&At){const Lt=Wt.filter(Ot=>Ot.source.id===at.id).data().map(Ot=>Ot.target.id),zt=Wt.filter(Ot=>Ot.target.id===at.id).data().map(Ot=>Ot.source.id);Wt.filter(Ot=>Ot.source.id!==at.id&&Ot.target.id!==at.id).style("opacity",ie);const Yt=[...zt,...Lt];se.filter(Ot=>Ot.id!==at.id&&!Yt.includes(Ot.id)).style("opacity",0),yt.filter(Ot=>Ot.id!==at.id&&!Yt.includes(Ot.id)).style("opacity",ee),se.filter(Ot=>Ot.id===at.id).style("font-size",Ft),se.filter(Ot=>Yt.includes(Ot.id)).style("font-size",ue)}else if(M==="hierarchy"){const ht=ft.filter($t=>$t==="name").node();qt(ht).text(`${at.data.name}`);const Lt=ft.filter($t=>$t==="value").node();qt(Lt).text(`${Pe(at.value)}`)}else if(M==="bubble")for(const ht of Z){const Lt=ft.filter(Ot=>Ot===ht).node(),$t=at[ht],zt=typeof $t=="number"?$t.toLocaleString():$t,Yt=ht==="label"?zt.toUpperCase():`${ht}: ${zt}`;qt(Lt).text(`${Yt}`)}}).on("pointermove",function(P,at){le(L,{e:P,svg:$})}).on("pointerleave",function(P,at){const ht=Pt(at);qt(this).style("stroke",ht),L.transition().duration(250).style("opacity",0),M==="network"&&At&&(Wt.style("opacity",rt),yt.style("opacity",re),se.style("opacity",ke).style("font-size",hn))}),Wt.on("pointerenter",function(P,at){if(qt(this).style("stroke",at.type?Ve(Q(at.type))?.darker().toString()??Ut:Ut),M==="network"){L.transition().duration(250).style("opacity",1);const ht=at.source.id,Lt=at.target.id;At&&(se.filter(Jt=>Jt.id!==ht&&Jt.id!==Lt).style("opacity",0),se.filter(Jt=>Jt.id===ht||Jt.id===Lt).style("font-size",ue)),L.transition().duration(250).style("opacity",1);const $t=ft.filter(Jt=>Jt==="name").node();qt($t).text(`${ht} ⟶ ${Lt}`);const zt=ft.filter(Jt=>Jt==="value").node(),Yt=at.value,Ot=typeof Yt=="number"?Pe(Yt):"---";qt(zt).text(`${Ot}`),le(L,{e:P,svg:$})}}).on("pointermove",function(P,at){M==="network"&&le(L,{e:P,svg:$})}).on("pointerleave",function(P,at){qt(this).style("stroke",at.type?Q(at.type):Xt),M==="network"&&(L.transition().duration(250).style("opacity",0),At&&se.style("opacity",ke).style("font-size",hn))});const ke=P=>{const at=B(P);if(Tt)return at<15?0:1;const ht=Nt(P);return ht==="no path to highlight"||ht==="source or destination"||ht==="path"?1:.25},hn=P=>{const at=Nt(P);return at==="no path to highlight"?St:at==="source or destination"?Ft:at==="path"?ue:St},to=e?[]:A,se=dt.selectAll("text.label").data(to,mt).join(P=>P.append("text").attr("class","label").attr("stroke-linejoin","round").attr("stroke-width",3).attr("dy","0.31em").attr("paint-order","stroke").attr("stroke","white").attr("fill","currentColor").style("font-size",hn).style("pointer-events","none").text(at=>M==="hierarchy"?at.data.name:M==="network"?at.id:at.label).style("opacity",ke),void 0,P=>P.remove()).style("opacity",ke).style("font-size",hn).text(P=>M==="hierarchy"?P.data.name:M==="network"?P.id:P.label);M==="hierarchy"?se.attr("text-anchor",P=>P.baseX<Math.PI==!P.children?"start":"end"):(M==="network"||M==="bubble")&&se.attr("text-anchor","middle"),yt.raise(),se.raise(),nt.on("tick",()=>{Wt.attr("d",P=>xt(P)),yt.attr("cx",Cn).attr("cy",Gn),se.attr("transform",P=>{if(M!=="hierarchy"||a!=="default")return"";const at=P;if(at.depth===0)return"";const ht=P.x??0,Lt=P.y??0,$t=at.baseX??0;if(!Un(ht)||!Un(Lt)||!Un($t))return"";const zt=$t*180/Math.PI-90,Yt=$t>=Math.PI?180:0;return`rotate(${zt+Yt}, ${ht}, ${Lt})`}).attr("x",P=>{const at=M==="hierarchy"&&a==="default"?P.baseX<Math.PI==!P.children?6:-6:0,ht=Cn(P);return(Un(ht)?ht:0)+at}).attr("y",P=>{const at=Gn(P);return(Un(at)?at:0)+(M==="network"?Rt+4:0)})});const Cn=P=>{const at=Un(P.x)?P.x:0,ht=B(P),Lt=-S/2+ht,$t=S/2-ht;return Math.min(Math.max(at,Lt),$t)},Gn=P=>{const at=Un(P.y)?P.y:0,ht=B(P),Lt=-w/2+ht,$t=w/2-ht;return Math.min(Math.max(at,Lt),$t)},wi=nd().on("start",oa).on("drag",la).on("end",ct);yt.call(wi);function oa(P,at){P.active||(M==="bubble"&&p&&nt.force("collide",Wr().radius(ht=>ht.r)),nt.alphaTarget(.3).restart()),at.fx=at.x,at.fy=at.y}function la(P,at){at.fx=P.x,at.fy=P.y}function ct(P,at){P.active||(M==="bubble"&&nt.force("collide",Wr().radius(ht=>p?ht.r/3:ht.r)),nt.alphaTarget(0)),at.fx=null,at.fy=null}},[t,e,n,r,N,p,y,M,I,S,w,{prefix:c,suffix:u,formatType:h}]);return m.jsx("div",{ref:f,style:{width:v,height:b,display:"flex",flexDirection:"column",overflow:"hidden"},children:m.jsxs("div",{ref:C,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{className:`controls ${J[R?"controls-container":"controls-container-sm"]}`,style:{display:M==="bubble"?"flex":"none",zIndex:1},children:[m.jsxs("label",{className:`
|
|
146
146
|
${J["controls-label"]}
|
|
147
147
|
`,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:p,onChange:F=>{k(F.target.checked)}}),"Sort"]}),m.jsx("div",{className:`legends-container ${J["legends-container"]}`})]}),m.jsxs("div",{ref:d,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",overflow:"hidden",zIndex:2},children:[m.jsxs("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,viewBox:`${-S/2} ${-w/2} ${S} ${w}`,children:[m.jsx("defs",{}),m.jsx("g",{className:"plot-area"})]}),m.jsx(Qe,{})]})]})})}function ov({data:t,tooltipFormat:{prefix:e="",suffix:n="",formatType:r="long"}={prefix:"",suffix:"",formatType:"long"}}){const[a,i]=Ne(),{width:s,height:o}=i,l=Se(c=>{if(s===0||o===0)return;const u={top:0,left:0},h=Math.min(s,o)/2-30,f=c.select("svg");f.node();const g=f.select(".plot-area").attr("transform","translate("+u.left+","+u.top+")");c.select("#tooltip").style("opacity",0);const v=fr(t),d=tc().size([2*Math.PI,h]).separation((y,T)=>(y.parent==T.parent?1:2)/y.depth)(v),x=d.links(),S=d.descendants();g.selectAll("path.link").remove(),g.selectAll("circle.node").remove(),g.selectAll("text.label").remove();const w=Mx().angle(y=>y.x).radius(y=>y.y);g.selectAll("path.link").data(x).join("path").attr("class","link").attr("fill","none").attr("stroke","#555").attr("stroke-opacity",.4).attr("stroke-width",1.5).attr("d",w),g.selectAll("circle.node").data(S).join("circle").attr("class","node").attr("transform",y=>`rotate(${y.x*180/Math.PI-90}) translate(${y.y},0)`).attr("fill",y=>y.children?"#555":"#999").attr("r",2.5),g.selectAll("text.label").data(S).join("text").attr("class","label").attr("stroke-linejoin","round").attr("stroke-width",3).attr("transform",y=>`rotate(${y.x*180/Math.PI-90}) translate(${y.y},0) rotate(${y.x>=Math.PI?180:0})`).attr("dy","0.31em").attr("x",y=>y.x<Math.PI==!y.children?6:-6).attr("text-anchor",y=>y.x<Math.PI==!y.children?"start":"end").attr("paint-order","stroke").attr("stroke","white").attr("fill","currentColor").style("font-size",10).text(y=>y.data.name)},[t,s,o,{prefix:e,suffix:n,formatType:r}]);return m.jsx("div",{ref:a,style:{width:s,height:o,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:l,style:{width:s,height:o,position:"relative"},children:[m.jsx("svg",{width:s,height:o,viewBox:`${-s/2} ${-o/2} ${s} ${o}`,style:{border:"1px solid green"},children:m.jsx("g",{className:"plot-area"})}),m.jsx(Qe,{})]})})}fe.BarChart=jx,fe.ChordDiagram=nv,fe.CirclePacks=Um,fe.DeltaWaterfall=tv,fe.DumbbellChart=ev,fe.GroupedBarChart=zx,fe.Histogram=av,fe.LineChart=Px,fe.MorphStackedBarChart=Fx,fe.NetworkGraph=sv,fe.PercentageBarChart=Ix,fe.PieChart=Ex,fe.PopulationPyramid=Km,fe.Sankey=Cm,fe.StackedBarChart=Rx,fe.StockPriceChart=Jm,fe.Sunburst=Qm,fe.TreeDiagram=ov,fe.WaterfallChart=qm,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})}));
|