chartformers 1.0.55 → 1.0.57

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.
Files changed (42) hide show
  1. package/README.md +15 -5
  2. package/dist/chartformers.css +1 -1
  3. package/dist/chartformers.es.js +10457 -4624
  4. package/dist/chartformers.umd.js +107 -36
  5. package/dist/src/charts/{barchart.d.ts → barchart/index.d.ts} +4 -3
  6. package/dist/src/charts/chord/index.d.ts +10 -0
  7. package/dist/src/charts/chord/types.d.ts +21 -0
  8. package/dist/src/charts/chord/utils.d.ts +2 -0
  9. package/dist/src/charts/circle-packs/index.d.ts +4 -3
  10. package/dist/src/charts/dumbbell/index.d.ts +13 -0
  11. package/dist/src/charts/dumbbell/types.d.ts +7 -0
  12. package/dist/src/charts/histogram/index.d.ts +23 -0
  13. package/dist/src/charts/histogram/types.d.ts +8 -0
  14. package/dist/src/charts/histogram/utils.d.ts +14 -0
  15. package/dist/src/charts/linechart/index.d.ts +18 -0
  16. package/dist/src/charts/linechart/types.d.ts +1 -0
  17. package/dist/src/charts/network/index.d.ts +53 -0
  18. package/dist/src/charts/network/types.d.ts +30 -0
  19. package/dist/src/charts/{piechart.d.ts → piechart/index.d.ts} +1 -1
  20. package/dist/src/charts/{population-pyramid.d.ts → population-pyramid/index.d.ts} +1 -2
  21. package/dist/src/charts/population-pyramid/types.d.ts +6 -0
  22. package/dist/src/charts/{sankey.d.ts → sankey/index.d.ts} +2 -1
  23. package/dist/src/charts/sankey/types.d.ts +20 -0
  24. package/dist/src/charts/sankey/utils.d.ts +11 -0
  25. package/dist/src/charts/stacked-barchart-variants/grouped-barchart.d.ts +5 -1
  26. package/dist/src/charts/stacked-barchart-variants/morph-stacked-barchart.d.ts +9 -0
  27. package/dist/src/charts/stacked-barchart-variants/percentage-barchart.d.ts +1 -1
  28. package/dist/src/charts/stacked-barchart-variants/stacked-barchart.d.ts +1 -1
  29. package/dist/src/charts/stacked-barchart-variants/tooltip.d.ts +6 -0
  30. package/dist/src/charts/stacked-barchart-variants/types.d.ts +16 -0
  31. package/dist/src/charts/sunburst.d.ts +8 -0
  32. package/dist/src/charts/tree.d.ts +8 -0
  33. package/dist/src/charts/waterfall/deltaWaterfall.d.ts +10 -0
  34. package/dist/src/charts/waterfall/tooltip.d.ts +2 -0
  35. package/dist/src/charts/waterfall/types.d.ts +11 -0
  36. package/dist/src/charts/waterfall/utils.d.ts +14 -0
  37. package/dist/src/charts/waterfall/waterfall.d.ts +11 -0
  38. package/dist/src/components/tooltip.d.ts +3 -2
  39. package/dist/src/index.d.ts +10 -0
  40. package/dist/src/types.d.ts +18 -51
  41. package/dist/src/utils.d.ts +22 -6
  42. package/package.json +12 -10
@@ -1,39 +1,26 @@
1
- (function(jt,ut){typeof exports=="object"&&typeof module<"u"?ut(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],ut):(jt=typeof globalThis<"u"?globalThis:jt||self,ut(jt.chartformers={},jt.React,jt.ReactDOM))})(this,(function(jt,ut,kn){"use strict";var Sn={exports:{}},Je={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Ta;function Ko(){if(Ta)return Je;Ta=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,a,i){var o=null;if(i!==void 0&&(o=""+i),a.key!==void 0&&(o=""+a.key),"key"in a){i={};for(var s in a)s!=="key"&&(i[s]=a[s])}else i=a;return a=i.ref,{$$typeof:t,type:r,key:o,ref:a!==void 0?a:null,props:i}}return Je.Fragment=e,Je.jsx=n,Je.jsxs=n,Je}var Qe={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Na;function qo(){return Na||(Na=1,process.env.NODE_ENV!=="production"&&(function(){function t(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===A?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case b:return"Fragment";case L:return"Profiler";case v:return"StrictMode";case N:return"Suspense";case z:return"SuspenseList";case Z:return"Activity"}if(typeof g=="object")switch(typeof g.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case W:return"Portal";case M:return g.displayName||"Context";case x:return(g._context.displayName||"Context")+".Consumer";case j:var H=g.render;return g=g.displayName,g||(g=H.displayName||H.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case Y:return H=g.displayName||null,H!==null?H:t(g.type)||"Memo";case B:H=g._payload,g=g._init;try{return t(g(H))}catch{}}return null}function e(g){return""+g}function n(g){try{e(g);var H=!1}catch{H=!0}if(H){H=console;var K=H.error,J=typeof Symbol=="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return K.call(H,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",J),e(g)}}function r(g){if(g===b)return"<>";if(typeof g=="object"&&g!==null&&g.$$typeof===B)return"<...>";try{var H=t(g);return H?"<"+H+">":"<...>"}catch{return"<...>"}}function a(){var g=X.A;return g===null?null:g.getOwner()}function i(){return Error("react-stack-top-frame")}function o(g){if(S.call(g,"key")){var H=Object.getOwnPropertyDescriptor(g,"key").get;if(H&&H.isReactWarning)return!1}return g.key!==void 0}function s(g,H){function K(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",H))}K.isReactWarning=!0,Object.defineProperty(g,"key",{get:K,configurable:!0})}function c(){var g=t(this.type);return T[g]||(T[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function l(g,H,K,J,ct,it){var O=K.ref;return g={$$typeof:k,type:g,key:H,props:K,_owner:J},(O!==void 0?O:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:c}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ct}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:it}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function u(g,H,K,J,ct,it){var O=H.children;if(O!==void 0)if(J)if(P(O)){for(J=0;J<O.length;J++)f(O[J]);Object.freeze&&Object.freeze(O)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(O);if(S.call(H,"key")){O=t(g);var tt=Object.keys(H).filter(function(_){return _!=="key"});J=0<tt.length?"{key: someKey, "+tt.join(": ..., ")+": ...}":"{key: someKey}",E[O+J]||(tt=0<tt.length?"{"+tt.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(fe,bt){typeof exports=="object"&&typeof module<"u"?bt(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],bt):(fe=typeof globalThis<"u"?globalThis:fe||self,bt(fe.chartformers={},fe.React,fe.ReactDOM))})(this,(function(fe,bt,Ru){"use strict";function zu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ua={exports:{}},Sr={};var eo;function Iu(){if(eo)return Sr;eo=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,a,i){var s=null;if(i!==void 0&&(s=""+i),a.key!==void 0&&(s=""+a.key),"key"in a){i={};for(var o in a)o!=="key"&&(i[o]=a[o])}else i=a;return a=i.ref,{$$typeof:t,type:r,key:s,ref:a!==void 0?a:null,props:i}}return Sr.Fragment=e,Sr.jsx=n,Sr.jsxs=n,Sr}var Mr={};var no;function Fu(){return no||(no=1,process.env.NODE_ENV!=="production"&&(function(){function t($){if($==null)return null;if(typeof $=="function")return $.$$typeof===I?null:$.displayName||$.name||null;if(typeof $=="string")return $;switch($){case d:return"Fragment";case S:return"Profiler";case x:return"StrictMode";case p:return"Suspense";case k:return"SuspenseList";case R:return"Activity";case z:return"ViewTransition"}if(typeof $=="object")switch(typeof $.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),$.$$typeof){case b:return"Portal";case y:return $.displayName||"Context";case w:return($._context.displayName||"Context")+".Consumer";case T:var pt=$.render;return $=$.displayName,$||($=pt.displayName||pt.name||"",$=$!==""?"ForwardRef("+$+")":"ForwardRef"),$;case _:return pt=$.displayName||null,pt!==null?pt:t($.type)||"Memo";case E:pt=$._payload,$=$._init;try{return t($(pt))}catch{}}return null}function e($){return""+$}function n($){try{e($);var pt=!1}catch{pt=!0}if(pt){pt=console;var wt=pt.error,gt=typeof Symbol=="function"&&Symbol.toStringTag&&$[Symbol.toStringTag]||$.constructor.name||"Object";return wt.call(pt,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",gt),e($)}}function r($){if($===d)return"<>";if(typeof $=="object"&&$!==null&&$.$$typeof===E)return"<...>";try{var pt=t($);return pt?"<"+pt+">":"<...>"}catch{return"<...>"}}function a(){var $=N.A;return $===null?null:$.getOwner()}function i(){return Error("react-stack-top-frame")}function s($){if(U.call($,"key")){var pt=Object.getOwnPropertyDescriptor($,"key").get;if(pt&&pt.isReactWarning)return!1}return $.key!==void 0}function o($,pt){function wt(){C||(C=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",pt))}wt.isReactWarning=!0,Object.defineProperty($,"key",{get:wt,configurable:!0})}function l(){var $=t(this.type);return H[$]||(H[$]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),$=this.props.ref,$!==void 0?$:null}function c($,pt,wt,gt,_t,G){var st=wt.ref;return $={$$typeof:v,type:$,key:pt,props:wt,_owner:gt},(st!==void 0?st:null)!==null?Object.defineProperty($,"ref",{enumerable:!1,get:l}):Object.defineProperty($,"ref",{enumerable:!1,value:null}),$._store={},Object.defineProperty($._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty($,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty($,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:_t}),Object.defineProperty($,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.freeze&&(Object.freeze($.props),Object.freeze($)),$}function u($,pt,wt,gt,_t,G){var st=pt.children;if(st!==void 0)if(gt)if(M(st)){for(gt=0;gt<st.length;gt++)h(st[gt]);Object.freeze&&Object.freeze(st)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else h(st);if(U.call(pt,"key")){st=t($);var B=Object.keys(pt).filter(function(X){return X!=="key"});gt=0<B.length?"{key: someKey, "+B.join(": ..., ")+": ...}":"{key: someKey}",q[st+gt]||(B=0<B.length?"{"+B.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
2
  let props = %s;
19
3
  <%s {...props} />
20
4
  React keys must be passed directly to JSX without using spread:
21
5
  let props = %s;
22
- <%s key={someKey} {...props} />`,J,O,tt,O),E[O+J]=!0)}if(O=null,K!==void 0&&(n(K),O=""+K),o(H)&&(n(H.key),O=""+H.key),"key"in H){K={};for(var d in H)d!=="key"&&(K[d]=H[d])}else K=H;return O&&s(K,typeof g=="function"?g.displayName||g.name||"Unknown":g),l(g,O,K,a(),ct,it)}function f(g){h(g)?g._store&&(g._store.validated=1):typeof g=="object"&&g!==null&&g.$$typeof===B&&(g._payload.status==="fulfilled"?h(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function h(g){return typeof g=="object"&&g!==null&&g.$$typeof===k}var p=ut,k=Symbol.for("react.transitional.element"),W=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),M=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),A=Symbol.for("react.client.reference"),X=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,S=Object.prototype.hasOwnProperty,P=Array.isArray,y=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(g){return g()}};var D,T={},I=p.react_stack_bottom_frame.bind(p,i)(),m=y(r(i)),E={};Qe.Fragment=b,Qe.jsx=function(g,H,K){var J=1e4>X.recentlyCreatedOwnerStacks++;return u(g,H,K,!1,J?Error("react-stack-top-frame"):I,J?y(r(g)):m)},Qe.jsxs=function(g,H,K){var J=1e4>X.recentlyCreatedOwnerStacks++;return u(g,H,K,!0,J?Error("react-stack-top-frame"):I,J?y(r(g)):m)}})()),Qe}var Ca;function Go(){return Ca||(Ca=1,process.env.NODE_ENV==="production"?Sn.exports=Ko():Sn.exports=qo()),Sn.exports}var $=Go();function tn(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Zo(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Mn(t){let e,n,r;t.length!==2?(e=tn,n=(s,c)=>tn(t(s),c),r=(s,c)=>t(s)-c):(e=t===tn||t===Zo?t:Jo,n=t,r=t);function a(s,c,l=0,u=s.length){if(l<u){if(e(c,c)!==0)return u;do{const f=l+u>>>1;n(s[f],c)<0?l=f+1:u=f}while(l<u)}return l}function i(s,c,l=0,u=s.length){if(l<u){if(e(c,c)!==0)return u;do{const f=l+u>>>1;n(s[f],c)<=0?l=f+1:u=f}while(l<u)}return l}function o(s,c,l=0,u=s.length){const f=a(s,c,l,u-1);return f>l&&r(s[f-1],c)>-r(s[f],c)?f-1:f}return{left:a,center:o,right:i}}function Jo(){return 0}function Qo(t){return t===null?NaN:+t}const ts=Mn(tn).right;Mn(Qo).center;function es(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 vr extends Map{constructor(e,n=as){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($a(this,e))}has(e){return super.has($a(this,e))}set(e,n){return super.set(ns(this,e),n)}delete(e){return super.delete(rs(this,e))}}function $a({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function ns({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function rs({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function as(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Da(t){return t}function Ra(t,...e){return is(t,Da,Da,e)}function is(t,e,n,r){return(function a(i,o){if(o>=r.length)return n(i);const s=new vr,c=r[o++];let l=-1;for(const u of i){const f=c(u,++l,i),h=s.get(f);h?h.push(u):s.set(f,[u])}for(const[u,f]of s)s.set(u,a(f,o));return e(s)})(t,0)}const os=Math.sqrt(50),ss=Math.sqrt(10),ls=Math.sqrt(2);function An(t,e,n){const r=(e-t)/Math.max(0,n),a=Math.floor(Math.log10(r)),i=r/Math.pow(10,a),o=i>=os?10:i>=ss?5:i>=ls?2:1;let s,c,l;return a<0?(l=Math.pow(10,-a)/o,s=Math.round(t*l),c=Math.round(e*l),s/l<t&&++s,c/l>e&&--c,l=-l):(l=Math.pow(10,a)*o,s=Math.round(t/l),c=Math.round(e/l),s*l<t&&++s,c*l>e&&--c),c<s&&.5<=n&&n<2?An(t,e,n*2):[s,c,l]}function cs(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[a,i,o]=r?An(e,t,n):An(t,e,n);if(!(i>=a))return[];const s=i-a+1,c=new Array(s);if(r)if(o<0)for(let l=0;l<s;++l)c[l]=(i-l)/-o;else for(let l=0;l<s;++l)c[l]=(i-l)*o;else if(o<0)for(let l=0;l<s;++l)c[l]=(a+l)/-o;else for(let l=0;l<s;++l)c[l]=(a+l)*o;return c}function _r(t,e,n){return e=+e,t=+t,n=+n,An(t,e,n)[2]}function br(t,e,n){e=+e,t=+t,n=+n;const r=e<t,a=r?_r(e,t,n):_r(t,e,n);return(r?-1:1)*(a<0?1/-a:a)}function Dt(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 Tn(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 us(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 fs=hs(Math.random);function hs(t){return function(n,r=0,a=n.length){let i=a-(r=+r);for(;i;){const o=t()*i--|0,s=n[i+r];n[i+r]=n[o+r],n[o+r]=s}return n}}function Nn(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 ds(t){return t}var wr=1,Cn=2,kr=3,en=4,Ea=1e-6;function ps(t){return"translate("+t+",0)"}function gs(t){return"translate(0,"+t+")"}function ms(t){return e=>+t(e)}function ys(t,e){return e=Math.max(0,t.bandwidth()-e*2)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function xs(){return!this.__axis}function Sr(t,e){var n=[],r=null,a=null,i=6,o=6,s=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,l=t===wr||t===en?-1:1,u=t===en||t===Cn?"x":"y",f=t===wr||t===kr?ps:gs;function h(p){var k=r??(e.ticks?e.ticks.apply(e,n):e.domain()),W=a??(e.tickFormat?e.tickFormat.apply(e,n):ds),b=Math.max(i,0)+s,v=e.range(),L=+v[0]+c,x=+v[v.length-1]+c,M=(e.bandwidth?ys:ms)(e.copy(),c),j=p.selection?p.selection():p,N=j.selectAll(".domain").data([null]),z=j.selectAll(".tick").data(k,e).order(),Y=z.exit(),B=z.enter().append("g").attr("class","tick"),Z=z.select("line"),A=z.select("text");N=N.merge(N.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),z=z.merge(B),Z=Z.merge(B.append("line").attr("stroke","currentColor").attr(u+"2",l*i)),A=A.merge(B.append("text").attr("fill","currentColor").attr(u,l*b).attr("dy",t===wr?"0em":t===kr?"0.71em":"0.32em")),p!==j&&(N=N.transition(p),z=z.transition(p),Z=Z.transition(p),A=A.transition(p),Y=Y.transition(p).attr("opacity",Ea).attr("transform",function(X){return isFinite(X=M(X))?f(X+c):this.getAttribute("transform")}),B.attr("opacity",Ea).attr("transform",function(X){var S=this.parentNode.__axis;return f((S&&isFinite(S=S(X))?S:M(X))+c)})),Y.remove(),N.attr("d",t===en||t===Cn?o?"M"+l*o+","+L+"H"+c+"V"+x+"H"+l*o:"M"+c+","+L+"V"+x:o?"M"+L+","+l*o+"V"+c+"H"+x+"V"+l*o:"M"+L+","+c+"H"+x),z.attr("opacity",1).attr("transform",function(X){return f(M(X)+c)}),Z.attr(u+"2",l*i),A.attr(u,l*b).text(W),j.filter(xs).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===Cn?"start":t===en?"end":"middle"),j.each(function(){this.__axis=M})}return h.scale=function(p){return arguments.length?(e=p,h):e},h.ticks=function(){return n=Array.from(arguments),h},h.tickArguments=function(p){return arguments.length?(n=p==null?[]:Array.from(p),h):n.slice()},h.tickValues=function(p){return arguments.length?(r=p==null?null:Array.from(p),h):r&&r.slice()},h.tickFormat=function(p){return arguments.length?(a=p,h):a},h.tickSize=function(p){return arguments.length?(i=o=+p,h):i},h.tickSizeInner=function(p){return arguments.length?(i=+p,h):i},h.tickSizeOuter=function(p){return arguments.length?(o=+p,h):o},h.tickPadding=function(p){return arguments.length?(s=+p,h):s},h.offset=function(p){return arguments.length?(c=+p,h):c},h}function vs(t){return Sr(Cn,t)}function Ut(t){return Sr(kr,t)}function te(t){return Sr(en,t)}var _s={value:()=>{}};function Mr(){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 $n(n)}function $n(t){this._=t}function bs(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}})}$n.prototype=Mr.prototype={constructor:$n,on:function(t,e){var n=this._,r=bs(t+"",n),a,i=-1,o=r.length;if(arguments.length<2){for(;++i<o;)if((a=(t=r[i]).type)&&(a=ws(n[a],t.name)))return a;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(a=(t=r[i]).type)n[a]=La(n[a],t.name,e);else if(e==null)for(a in n)n[a]=La(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 $n(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 ws(t,e){for(var n=0,r=t.length,a;n<r;++n)if((a=t[n]).name===e)return a.value}function La(t,e,n){for(var r=0,a=t.length;r<a;++r)if(t[r].name===e){t[r]=_s,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Ar="http://www.w3.org/1999/xhtml";const ja={svg:"http://www.w3.org/2000/svg",xhtml:Ar,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Dn(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),ja.hasOwnProperty(e)?{space:ja[e],local:t}:t}function ks(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Ar&&e.documentElement.namespaceURI===Ar?e.createElement(t):e.createElementNS(n,t)}}function Ss(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Pa(t){var e=Dn(t);return(e.local?Ss:ks)(e)}function Ms(){}function Tr(t){return t==null?Ms:function(){return this.querySelector(t)}}function As(t){typeof t!="function"&&(t=Tr(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],o=i.length,s=r[a]=new Array(o),c,l,u=0;u<o;++u)(c=i[u])&&(l=t.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),s[u]=l);return new Xt(r,this._parents)}function Ts(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Ns(){return[]}function Ha(t){return t==null?Ns:function(){return this.querySelectorAll(t)}}function Cs(t){return function(){return Ts(t.apply(this,arguments))}}function $s(t){typeof t=="function"?t=Cs(t):t=Ha(t);for(var e=this._groups,n=e.length,r=[],a=[],i=0;i<n;++i)for(var o=e[i],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(t.call(c,c.__data__,l,o)),a.push(c));return new Xt(r,a)}function za(t){return function(){return this.matches(t)}}function Ia(t){return function(e){return e.matches(t)}}var Ds=Array.prototype.find;function Rs(t){return function(){return Ds.call(this.children,t)}}function Es(){return this.firstElementChild}function Ls(t){return this.select(t==null?Es:Rs(typeof t=="function"?t:Ia(t)))}var js=Array.prototype.filter;function Ps(){return Array.from(this.children)}function Hs(t){return function(){return js.call(this.children,t)}}function zs(t){return this.selectAll(t==null?Ps:Hs(typeof t=="function"?t:Ia(t)))}function Is(t){typeof t!="function"&&(t=za(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],o=i.length,s=r[a]=[],c,l=0;l<o;++l)(c=i[l])&&t.call(c,c.__data__,l,i)&&s.push(c);return new Xt(r,this._parents)}function Fa(t){return new Array(t.length)}function Fs(){return new Xt(this._enter||this._groups.map(Fa),this._parents)}function Rn(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Rn.prototype={constructor:Rn,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 Us(t){return function(){return t}}function Os(t,e,n,r,a,i){for(var o=0,s,c=e.length,l=i.length;o<l;++o)(s=e[o])?(s.__data__=i[o],r[o]=s):n[o]=new Rn(t,i[o]);for(;o<c;++o)(s=e[o])&&(a[o]=s)}function Ys(t,e,n,r,a,i,o){var s,c,l=new Map,u=e.length,f=i.length,h=new Array(u),p;for(s=0;s<u;++s)(c=e[s])&&(h[s]=p=o.call(c,c.__data__,s,e)+"",l.has(p)?a[s]=c:l.set(p,c));for(s=0;s<f;++s)p=o.call(t,i[s],s,i)+"",(c=l.get(p))?(r[s]=c,c.__data__=i[s],l.delete(p)):n[s]=new Rn(t,i[s]);for(s=0;s<u;++s)(c=e[s])&&l.get(h[s])===c&&(a[s]=c)}function Ws(t){return t.__data__}function Vs(t,e){if(!arguments.length)return Array.from(this,Ws);var n=e?Ys:Os,r=this._parents,a=this._groups;typeof t!="function"&&(t=Us(t));for(var i=a.length,o=new Array(i),s=new Array(i),c=new Array(i),l=0;l<i;++l){var u=r[l],f=a[l],h=f.length,p=Bs(t.call(u,u&&u.__data__,l,r)),k=p.length,W=s[l]=new Array(k),b=o[l]=new Array(k),v=c[l]=new Array(h);n(u,f,W,b,v,p,e);for(var L=0,x=0,M,j;L<k;++L)if(M=W[L]){for(L>=x&&(x=L+1);!(j=b[x])&&++x<k;);M._next=j||null}}return o=new Xt(o,r),o._enter=s,o._exit=c,o}function Bs(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Xs(){return new Xt(this._exit||this._groups.map(Fa),this._parents)}function Ks(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 qs(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,a=n.length,i=r.length,o=Math.min(a,i),s=new Array(a),c=0;c<o;++c)for(var l=n[c],u=r[c],f=l.length,h=s[c]=new Array(f),p,k=0;k<f;++k)(p=l[k]||u[k])&&(h[k]=p);for(;c<a;++c)s[c]=n[c];return new Xt(s,this._parents)}function Gs(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],a=r.length-1,i=r[a],o;--a>=0;)(o=r[a])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function Zs(t){t||(t=Js);function e(f,h){return f&&h?t(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,a=new Array(r),i=0;i<r;++i){for(var o=n[i],s=o.length,c=a[i]=new Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(e)}return new Xt(a,this._parents).order()}function Js(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Qs(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function tl(){return Array.from(this)}function el(){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 o=r[a];if(o)return o}return null}function nl(){let t=0;for(const e of this)++t;return t}function rl(){return!this.node()}function al(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var a=e[n],i=0,o=a.length,s;i<o;++i)(s=a[i])&&t.call(s,s.__data__,i,a);return this}function il(t){return function(){this.removeAttribute(t)}}function ol(t){return function(){this.removeAttributeNS(t.space,t.local)}}function sl(t,e){return function(){this.setAttribute(t,e)}}function ll(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function cl(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function ul(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 fl(t,e){var n=Dn(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?ol:il:typeof e=="function"?n.local?ul:cl:n.local?ll:sl)(n,e))}function Ua(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function hl(t){return function(){this.style.removeProperty(t)}}function dl(t,e,n){return function(){this.style.setProperty(t,e,n)}}function pl(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function gl(t,e,n){return arguments.length>1?this.each((e==null?hl:typeof e=="function"?pl:dl)(t,e,n??"")):Re(this.node(),t)}function Re(t,e){return t.style.getPropertyValue(e)||Ua(t).getComputedStyle(t,null).getPropertyValue(e)}function ml(t){return function(){delete this[t]}}function yl(t,e){return function(){this[t]=e}}function xl(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function vl(t,e){return arguments.length>1?this.each((e==null?ml:typeof e=="function"?xl:yl)(t,e)):this.node()[t]}function Oa(t){return t.trim().split(/^|\s+/)}function Nr(t){return t.classList||new Ya(t)}function Ya(t){this._node=t,this._names=Oa(t.getAttribute("class")||"")}Ya.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 Wa(t,e){for(var n=Nr(t),r=-1,a=e.length;++r<a;)n.add(e[r])}function Va(t,e){for(var n=Nr(t),r=-1,a=e.length;++r<a;)n.remove(e[r])}function _l(t){return function(){Wa(this,t)}}function bl(t){return function(){Va(this,t)}}function wl(t,e){return function(){(e.apply(this,arguments)?Wa:Va)(this,t)}}function kl(t,e){var n=Oa(t+"");if(arguments.length<2){for(var r=Nr(this.node()),a=-1,i=n.length;++a<i;)if(!r.contains(n[a]))return!1;return!0}return this.each((typeof e=="function"?wl:e?_l:bl)(n,e))}function Sl(){this.textContent=""}function Ml(t){return function(){this.textContent=t}}function Al(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Tl(t){return arguments.length?this.each(t==null?Sl:(typeof t=="function"?Al:Ml)(t)):this.node().textContent}function Nl(){this.innerHTML=""}function Cl(t){return function(){this.innerHTML=t}}function $l(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Dl(t){return arguments.length?this.each(t==null?Nl:(typeof t=="function"?$l:Cl)(t)):this.node().innerHTML}function Rl(){this.nextSibling&&this.parentNode.appendChild(this)}function El(){return this.each(Rl)}function Ll(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jl(){return this.each(Ll)}function Pl(t){var e=typeof t=="function"?t:Pa(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Hl(){return null}function zl(t,e){var n=typeof t=="function"?t:Pa(t),r=e==null?Hl:typeof e=="function"?e:Tr(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Il(){var t=this.parentNode;t&&t.removeChild(this)}function Fl(){return this.each(Il)}function Ul(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ol(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Yl(t){return this.select(t?Ol:Ul)}function Wl(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Vl(t){return function(e){t.call(this,e,this.__data__)}}function Bl(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 Xl(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 Kl(t,e,n){return function(){var r=this.__on,a,i=Vl(e);if(r){for(var o=0,s=r.length;o<s;++o)if((a=r[o]).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 ql(t,e,n){var r=Bl(t+""),a,i=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(a=0,u=s[c];a<i;++a)if((o=r[a]).type===u.type&&o.name===u.name)return u.value}return}for(s=e?Kl:Xl,a=0;a<i;++a)this.each(s(r[a],e,n));return this}function Ba(t,e,n){var r=Ua(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 Gl(t,e){return function(){return Ba(this,t,e)}}function Zl(t,e){return function(){return Ba(this,t,e.apply(this,arguments))}}function Jl(t,e){return this.each((typeof e=="function"?Zl:Gl)(t,e))}function*Ql(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],a=0,i=r.length,o;a<i;++a)(o=r[a])&&(yield o)}var Xa=[null];function Xt(t,e){this._groups=t,this._parents=e}function nn(){return new Xt([[document.documentElement]],Xa)}function tc(){return this}Xt.prototype=nn.prototype={constructor:Xt,select:As,selectAll:$s,selectChild:Ls,selectChildren:zs,filter:Is,data:Vs,enter:Fs,exit:Xs,join:Ks,merge:qs,selection:tc,order:Gs,sort:Zs,call:Qs,nodes:tl,node:el,size:nl,empty:rl,each:al,attr:fl,style:gl,property:vl,classed:kl,text:Tl,html:Dl,raise:El,lower:jl,append:Pl,insert:zl,remove:Fl,clone:Yl,datum:Wl,on:ql,dispatch:Jl,[Symbol.iterator]:Ql};function At(t){return typeof t=="string"?new Xt([[document.querySelector(t)]],[document.documentElement]):new Xt([[t]],Xa)}function ec(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Cr(t,e){if(t=ec(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 $r={capture:!0,passive:!1};function Dr(t){t.preventDefault(),t.stopImmediatePropagation()}function nc(t){var e=t.document.documentElement,n=At(t).on("dragstart.drag",Dr,$r);"onselectstart"in e?n.on("selectstart.drag",Dr,$r):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function rc(t,e){var n=t.document.documentElement,r=At(t).on("dragstart.drag",null);e&&(r.on("click.drag",Dr,$r),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function rn(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function En(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function be(){}var an=.7,Ln=1/an,Ee="\\s*([+-]?\\d+)\\s*",on="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ac=/^#([0-9a-f]{3,8})$/,ic=new RegExp(`^rgb\\(${Ee},${Ee},${Ee}\\)$`),oc=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),sc=new RegExp(`^rgba\\(${Ee},${Ee},${Ee},${on}\\)$`),lc=new RegExp(`^rgba\\(${ee},${ee},${ee},${on}\\)$`),cc=new RegExp(`^hsl\\(${on},${ee},${ee}\\)$`),uc=new RegExp(`^hsla\\(${on},${ee},${ee},${on}\\)$`),Ka={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};rn(be,we,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:qa,formatHex:qa,formatHex8:fc,formatHsl:hc,formatRgb:Ga,toString:Ga});function qa(){return this.rgb().formatHex()}function fc(){return this.rgb().formatHex8()}function hc(){return ni(this).formatHsl()}function Ga(){return this.rgb().formatRgb()}function we(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ac.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Za(e):n===3?new Pt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?jn(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?jn(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=ic.exec(t))?new Pt(e[1],e[2],e[3],1):(e=oc.exec(t))?new Pt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=sc.exec(t))?jn(e[1],e[2],e[3],e[4]):(e=lc.exec(t))?jn(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=cc.exec(t))?ei(e[1],e[2]/100,e[3]/100,1):(e=uc.exec(t))?ei(e[1],e[2]/100,e[3]/100,e[4]):Ka.hasOwnProperty(t)?Za(Ka[t]):t==="transparent"?new Pt(NaN,NaN,NaN,0):null}function Za(t){return new Pt(t>>16&255,t>>8&255,t&255,1)}function jn(t,e,n,r){return r<=0&&(t=e=n=NaN),new Pt(t,e,n,r)}function Ja(t){return t instanceof be||(t=we(t)),t?(t=t.rgb(),new Pt(t.r,t.g,t.b,t.opacity)):new Pt}function Rr(t,e,n,r){return arguments.length===1?Ja(t):new Pt(t,e,n,r??1)}function Pt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}rn(Pt,Rr,En(be,{brighter(t){return t=t==null?Ln:Math.pow(Ln,t),new Pt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?an:Math.pow(an,t),new Pt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Pt(ke(this.r),ke(this.g),ke(this.b),Pn(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:Qa,formatHex:Qa,formatHex8:dc,formatRgb:ti,toString:ti}));function Qa(){return`#${Se(this.r)}${Se(this.g)}${Se(this.b)}`}function dc(){return`#${Se(this.r)}${Se(this.g)}${Se(this.b)}${Se((isNaN(this.opacity)?1:this.opacity)*255)}`}function ti(){const t=Pn(this.opacity);return`${t===1?"rgb(":"rgba("}${ke(this.r)}, ${ke(this.g)}, ${ke(this.b)}${t===1?")":`, ${t})`}`}function Pn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ke(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Se(t){return t=ke(t),(t<16?"0":"")+t.toString(16)}function ei(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Jt(t,e,n,r)}function ni(t){if(t instanceof Jt)return new Jt(t.h,t.s,t.l,t.opacity);if(t instanceof be||(t=we(t)),!t)return new Jt;if(t instanceof Jt)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),o=NaN,s=i-a,c=(i+a)/2;return s?(e===i?o=(n-r)/s+(n<r)*6:n===i?o=(r-e)/s+2:o=(e-n)/s+4,s/=c<.5?i+a:2-i-a,o*=60):s=c>0&&c<1?0:o,new Jt(o,s,c,t.opacity)}function pc(t,e,n,r){return arguments.length===1?ni(t):new Jt(t,e,n,r??1)}function Jt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}rn(Jt,pc,En(be,{brighter(t){return t=t==null?Ln:Math.pow(Ln,t),new Jt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?an:Math.pow(an,t),new Jt(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 Pt(Er(t>=240?t-240:t+120,a,r),Er(t,a,r),Er(t<120?t+240:t-120,a,r),this.opacity)},clamp(){return new Jt(ri(this.h),Hn(this.s),Hn(this.l),Pn(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=Pn(this.opacity);return`${t===1?"hsl(":"hsla("}${ri(this.h)}, ${Hn(this.s)*100}%, ${Hn(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ri(t){return t=(t||0)%360,t<0?t+360:t}function Hn(t){return Math.max(0,Math.min(1,t||0))}function Er(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 gc=Math.PI/180,mc=180/Math.PI,zn=18,ai=.96422,ii=1,oi=.82521,si=4/29,Le=6/29,li=3*Le*Le,yc=Le*Le*Le;function ci(t){if(t instanceof ne)return new ne(t.l,t.a,t.b,t.opacity);if(t instanceof oe)return ui(t);t instanceof Pt||(t=Ja(t));var e=Hr(t.r),n=Hr(t.g),r=Hr(t.b),a=Lr((.2225045*e+.7168786*n+.0606169*r)/ii),i,o;return e===n&&n===r?i=o=a:(i=Lr((.4360747*e+.3850649*n+.1430804*r)/ai),o=Lr((.0139322*e+.0971045*n+.7141733*r)/oi)),new ne(116*a-16,500*(i-a),200*(a-o),t.opacity)}function xc(t,e,n,r){return arguments.length===1?ci(t):new ne(t,e,n,r??1)}function ne(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}rn(ne,xc,En(be,{brighter(t){return new ne(this.l+zn*(t??1),this.a,this.b,this.opacity)},darker(t){return new ne(this.l-zn*(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=ai*jr(e),t=ii*jr(t),n=oi*jr(n),new Pt(Pr(3.1338561*e-1.6168667*t-.4906146*n),Pr(-.9787684*e+1.9161415*t+.033454*n),Pr(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}}));function Lr(t){return t>yc?Math.pow(t,1/3):t/li+si}function jr(t){return t>Le?t*t*t:li*(t-si)}function Pr(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Hr(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function vc(t){if(t instanceof oe)return new oe(t.h,t.c,t.l,t.opacity);if(t instanceof ne||(t=ci(t)),t.a===0&&t.b===0)return new oe(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*mc;return new oe(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function zr(t,e,n,r){return arguments.length===1?vc(t):new oe(t,e,n,r??1)}function oe(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function ui(t){if(isNaN(t.h))return new ne(t.l,0,0,t.opacity);var e=t.h*gc;return new ne(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}rn(oe,zr,En(be,{brighter(t){return new oe(this.h,this.c,this.l+zn*(t??1),this.opacity)},darker(t){return new oe(this.h,this.c,this.l-zn*(t??1),this.opacity)},rgb(){return ui(this).rgb()}}));const In=t=>()=>t;function fi(t,e){return function(n){return t+n*e}}function _c(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 bc(t,e){var n=e-t;return n?fi(t,n>180||n<-180?n-360*Math.round(n/360):n):In(isNaN(t)?e:t)}function wc(t){return(t=+t)==1?sn:function(e,n){return n-e?_c(e,n,t):In(isNaN(e)?n:e)}}function sn(t,e){var n=e-t;return n?fi(t,n):In(isNaN(t)?e:t)}const Fn=(function t(e){var n=wc(e);function r(a,i){var o=n((a=Rr(a)).r,(i=Rr(i)).r),s=n(a.g,i.g),c=n(a.b,i.b),l=sn(a.opacity,i.opacity);return function(u){return a.r=o(u),a.g=s(u),a.b=c(u),a.opacity=l(u),a+""}}return r.gamma=t,r})(1);function kc(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 Sc(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Mc(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,a=new Array(r),i=new Array(n),o;for(o=0;o<r;++o)a[o]=se(t[o],e[o]);for(;o<n;++o)i[o]=e[o];return function(s){for(o=0;o<r;++o)i[o]=a[o](s);return i}}function Ac(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function qt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Tc(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]=se(t[a],e[a]):r[a]=e[a];return function(i){for(a in n)r[a]=n[a](i);return r}}var Ir=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fr=new RegExp(Ir.source,"g");function Nc(t){return function(){return t}}function Cc(t){return function(e){return t(e)+""}}function hi(t,e){var n=Ir.lastIndex=Fr.lastIndex=0,r,a,i,o=-1,s=[],c=[];for(t=t+"",e=e+"";(r=Ir.exec(t))&&(a=Fr.exec(e));)(i=a.index)>n&&(i=e.slice(n,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(a=a[0])?s[o]?s[o]+=a:s[++o]=a:(s[++o]=null,c.push({i:o,x:qt(r,a)})),n=Fr.lastIndex;return n<e.length&&(i=e.slice(n),s[o]?s[o]+=i:s[++o]=i),s.length<2?c[0]?Cc(c[0].x):Nc(e):(e=c.length,function(l){for(var u=0,f;u<e;++u)s[(f=c[u]).i]=f.x(l);return s.join("")})}function se(t,e){var n=typeof e,r;return e==null||n==="boolean"?In(e):(n==="number"?qt:n==="string"?(r=we(e))?(e=r,Fn):hi:e instanceof we?Fn:e instanceof Date?Ac:Sc(e)?kc:Array.isArray(e)?Mc:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Tc:qt)(t,e)}function $c(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var di=180/Math.PI,Ur={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function pi(t,e,n,r,a,i){var o,s,c;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(c=t*n+e*r)&&(n-=t*c,r-=e*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),t*r<e*n&&(t=-t,e=-e,c=-c,o=-o),{translateX:a,translateY:i,rotate:Math.atan2(e,t)*di,skewX:Math.atan(c)*di,scaleX:o,scaleY:s}}var Un;function Dc(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Ur:pi(e.a,e.b,e.c,e.d,e.e,e.f)}function Rc(t){return t==null||(Un||(Un=document.createElementNS("http://www.w3.org/2000/svg","g")),Un.setAttribute("transform",t),!(t=Un.transform.baseVal.consolidate()))?Ur:(t=t.matrix,pi(t.a,t.b,t.c,t.d,t.e,t.f))}function gi(t,e,n,r){function a(l){return l.length?l.pop()+" ":""}function i(l,u,f,h,p,k){if(l!==f||u!==h){var W=p.push("translate(",null,e,null,n);k.push({i:W-4,x:qt(l,f)},{i:W-2,x:qt(u,h)})}else(f||h)&&p.push("translate("+f+e+h+n)}function o(l,u,f,h){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),h.push({i:f.push(a(f)+"rotate(",null,r)-2,x:qt(l,u)})):u&&f.push(a(f)+"rotate("+u+r)}function s(l,u,f,h){l!==u?h.push({i:f.push(a(f)+"skewX(",null,r)-2,x:qt(l,u)}):u&&f.push(a(f)+"skewX("+u+r)}function c(l,u,f,h,p,k){if(l!==f||u!==h){var W=p.push(a(p)+"scale(",null,",",null,")");k.push({i:W-4,x:qt(l,f)},{i:W-2,x:qt(u,h)})}else(f!==1||h!==1)&&p.push(a(p)+"scale("+f+","+h+")")}return function(l,u){var f=[],h=[];return l=t(l),u=t(u),i(l.translateX,l.translateY,u.translateX,u.translateY,f,h),o(l.rotate,u.rotate,f,h),s(l.skewX,u.skewX,f,h),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,h),l=u=null,function(p){for(var k=-1,W=h.length,b;++k<W;)f[(b=h[k]).i]=b.x(p);return f.join("")}}}var Ec=gi(Dc,"px, ","px)","deg)"),Lc=gi(Rc,", ",")",")");function jc(t){return function(e,n){var r=t((e=zr(e)).h,(n=zr(n)).h),a=sn(e.c,n.c),i=sn(e.l,n.l),o=sn(e.opacity,n.opacity);return function(s){return e.h=r(s),e.c=a(s),e.l=i(s),e.opacity=o(s),e+""}}}const Pc=jc(bc);var je=0,ln=0,cn=0,mi=1e3,On,un,Yn=0,Me=0,Wn=0,fn=typeof performance=="object"&&performance.now?performance:Date,yi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Or(){return Me||(yi(Hc),Me=fn.now()+Wn)}function Hc(){Me=0}function Vn(){this._call=this._time=this._next=null}Vn.prototype=xi.prototype={constructor:Vn,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Or():+n)+(e==null?0:+e),!this._next&&un!==this&&(un?un._next=this:On=this,un=this),this._call=t,this._time=n,Yr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yr())}};function xi(t,e,n){var r=new Vn;return r.restart(t,e,n),r}function zc(){Or(),++je;for(var t=On,e;t;)(e=Me-t._time)>=0&&t._call.call(void 0,e),t=t._next;--je}function vi(){Me=(Yn=fn.now())+Wn,je=ln=0;try{zc()}finally{je=0,Fc(),Me=0}}function Ic(){var t=fn.now(),e=t-Yn;e>mi&&(Wn-=e,Yn=t)}function Fc(){for(var t,e=On,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:On=n);un=t,Yr(r)}function Yr(t){if(!je){ln&&(ln=clearTimeout(ln));var e=t-Me;e>24?(t<1/0&&(ln=setTimeout(vi,t-fn.now()-Wn)),cn&&(cn=clearInterval(cn))):(cn||(Yn=fn.now(),cn=setInterval(Ic,mi)),je=1,yi(vi))}}function _i(t,e,n){var r=new Vn;return e=e==null?0:+e,r.restart(a=>{r.stop(),t(a+e)},e,n),r}var Uc=Mr("start","end","cancel","interrupt"),Oc=[],bi=0,wi=1,Wr=2,Bn=3,ki=4,Vr=5,Xn=6;function Kn(t,e,n,r,a,i){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;Yc(t,n,{name:e,index:r,group:a,on:Uc,tween:Oc,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:bi})}function Br(t,e){var n=Qt(t,e);if(n.state>bi)throw new Error("too late; already scheduled");return n}function re(t,e){var n=Qt(t,e);if(n.state>Bn)throw new Error("too late; already running");return n}function Qt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Yc(t,e,n){var r=t.__transition,a;r[e]=n,n.timer=xi(i,0,n.time);function i(l){n.state=wi,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var u,f,h,p;if(n.state!==wi)return c();for(u in r)if(p=r[u],p.name===n.name){if(p.state===Bn)return _i(o);p.state===ki?(p.state=Xn,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete r[u]):+u<e&&(p.state=Xn,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete r[u])}if(_i(function(){n.state===Bn&&(n.state=ki,n.timer.restart(s,n.delay,n.time),s(l))}),n.state=Wr,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Wr){for(n.state=Bn,a=new Array(h=n.tween.length),u=0,f=-1;u<h;++u)(p=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(a[++f]=p);a.length=f+1}}function s(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Vr,1),f=-1,h=a.length;++f<h;)a[f].call(t,u);n.state===Vr&&(n.on.call("end",t,t.__data__,n.index,n.group),c())}function c(){n.state=Xn,n.timer.stop(),delete r[e];for(var l in r)return;delete t.__transition}}function Xr(t,e){var n=t.__transition,r,a,i=!0,o;if(n){e=e==null?null:e+"";for(o in n){if((r=n[o]).name!==e){i=!1;continue}a=r.state>Wr&&r.state<Vr,r.state=Xn,r.timer.stop(),r.on.call(a?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[o]}i&&delete t.__transition}}function Wc(t){return this.each(function(){Xr(this,t)})}function Vc(t,e){var n,r;return function(){var a=re(this,t),i=a.tween;if(i!==n){r=n=i;for(var o=0,s=r.length;o<s;++o)if(r[o].name===e){r=r.slice(),r.splice(o,1);break}}a.tween=r}}function Bc(t,e,n){var r,a;if(typeof n!="function")throw new Error;return function(){var i=re(this,t),o=i.tween;if(o!==r){a=(r=o).slice();for(var s={name:e,value:n},c=0,l=a.length;c<l;++c)if(a[c].name===e){a[c]=s;break}c===l&&a.push(s)}i.tween=a}}function Xc(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=Qt(this.node(),n).tween,a=0,i=r.length,o;a<i;++a)if((o=r[a]).name===t)return o.value;return null}return this.each((e==null?Vc:Bc)(n,t,e))}function Kr(t,e,n){var r=t._id;return t.each(function(){var a=re(this,r);(a.value||(a.value={}))[e]=n.apply(this,arguments)}),function(a){return Qt(a,r).value[e]}}function Si(t,e){var n;return(typeof e=="number"?qt:e instanceof we?Fn:(n=we(e))?(e=n,Fn):hi)(t,e)}function Kc(t){return function(){this.removeAttribute(t)}}function qc(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Gc(t,e,n){var r,a=n+"",i;return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function Zc(t,e,n){var r,a=n+"",i;return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function Jc(t,e,n){var r,a,i;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(t):(o=this.getAttribute(t),c=s+"",o===c?null:o===r&&c===a?i:(a=c,i=e(r=o,s)))}}function Qc(t,e,n){var r,a,i;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),c=s+"",o===c?null:o===r&&c===a?i:(a=c,i=e(r=o,s)))}}function tu(t,e){var n=Dn(t),r=n==="transform"?Lc:Si;return this.attrTween(t,typeof e=="function"?(n.local?Qc:Jc)(n,r,Kr(this,"attr."+t,e)):e==null?(n.local?qc:Kc)(n):(n.local?Zc:Gc)(n,r,e))}function eu(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function nu(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function ru(t,e){var n,r;function a(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&nu(t,i)),n}return a._value=e,a}function au(t,e){var n,r;function a(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&eu(t,i)),n}return a._value=e,a}function iu(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=Dn(t);return this.tween(n,(r.local?ru:au)(r,e))}function ou(t,e){return function(){Br(this,t).delay=+e.apply(this,arguments)}}function su(t,e){return e=+e,function(){Br(this,t).delay=e}}function lu(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?ou:su)(e,t)):Qt(this.node(),e).delay}function cu(t,e){return function(){re(this,t).duration=+e.apply(this,arguments)}}function uu(t,e){return e=+e,function(){re(this,t).duration=e}}function fu(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?cu:uu)(e,t)):Qt(this.node(),e).duration}function hu(t,e){if(typeof e!="function")throw new Error;return function(){re(this,t).ease=e}}function du(t){var e=this._id;return arguments.length?this.each(hu(e,t)):Qt(this.node(),e).ease}function pu(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;re(this,t).ease=n}}function gu(t){if(typeof t!="function")throw new Error;return this.each(pu(this._id,t))}function mu(t){typeof t!="function"&&(t=za(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a<n;++a)for(var i=e[a],o=i.length,s=r[a]=[],c,l=0;l<o;++l)(c=i[l])&&t.call(c,c.__data__,l,i)&&s.push(c);return new le(r,this._parents,this._name,this._id)}function yu(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),o=new Array(r),s=0;s<i;++s)for(var c=e[s],l=n[s],u=c.length,f=o[s]=new Array(u),h,p=0;p<u;++p)(h=c[p]||l[p])&&(f[p]=h);for(;s<r;++s)o[s]=e[s];return new le(o,this._parents,this._name,this._id)}function xu(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 vu(t,e,n){var r,a,i=xu(e)?Br:re;return function(){var o=i(this,t),s=o.on;s!==r&&(a=(r=s).copy()).on(e,n),o.on=a}}function _u(t,e){var n=this._id;return arguments.length<2?Qt(this.node(),n).on.on(t):this.each(vu(n,t,e))}function bu(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function wu(){return this.on("end.remove",bu(this._id))}function ku(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Tr(t));for(var r=this._groups,a=r.length,i=new Array(a),o=0;o<a;++o)for(var s=r[o],c=s.length,l=i[o]=new Array(c),u,f,h=0;h<c;++h)(u=s[h])&&(f=t.call(u,u.__data__,h,s))&&("__data__"in u&&(f.__data__=u.__data__),l[h]=f,Kn(l[h],e,n,h,l,Qt(u,n)));return new le(i,this._parents,e,n)}function Su(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Ha(t));for(var r=this._groups,a=r.length,i=[],o=[],s=0;s<a;++s)for(var c=r[s],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var h=t.call(u,u.__data__,f,c),p,k=Qt(u,n),W=0,b=h.length;W<b;++W)(p=h[W])&&Kn(p,e,n,W,h,k);i.push(h),o.push(u)}return new le(i,o,e,n)}var Mu=nn.prototype.constructor;function Au(){return new Mu(this._groups,this._parents)}function Tu(t,e){var n,r,a;return function(){var i=Re(this,t),o=(this.style.removeProperty(t),Re(this,t));return i===o?null:i===n&&o===r?a:a=e(n=i,r=o)}}function Mi(t){return function(){this.style.removeProperty(t)}}function Nu(t,e,n){var r,a=n+"",i;return function(){var o=Re(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}function Cu(t,e,n){var r,a,i;return function(){var o=Re(this,t),s=n(this),c=s+"";return s==null&&(c=s=(this.style.removeProperty(t),Re(this,t))),o===c?null:o===r&&c===a?i:(a=c,i=e(r=o,s))}}function $u(t,e){var n,r,a,i="style."+e,o="end."+i,s;return function(){var c=re(this,t),l=c.on,u=c.value[i]==null?s||(s=Mi(e)):void 0;(l!==n||a!==u)&&(r=(n=l).copy()).on(o,a=u),c.on=r}}function Du(t,e,n){var r=(t+="")=="transform"?Ec:Si;return e==null?this.styleTween(t,Tu(t,r)).on("end.style."+t,Mi(t)):typeof e=="function"?this.styleTween(t,Cu(t,r,Kr(this,"style."+t,e))).each($u(this._id,t)):this.styleTween(t,Nu(t,r,e),n).on("end.style."+t,null)}function Ru(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Eu(t,e,n){var r,a;function i(){var o=e.apply(this,arguments);return o!==a&&(r=(a=o)&&Ru(t,o,n)),r}return i._value=e,i}function Lu(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,Eu(t,e,n??""))}function ju(t){return function(){this.textContent=t}}function Pu(t){return function(){var e=t(this);this.textContent=e??""}}function Hu(t){return this.tween("text",typeof t=="function"?Pu(Kr(this,"text",t)):ju(t==null?"":t+""))}function zu(t){return function(e){this.textContent=t.call(this,e)}}function Iu(t){var e,n;function r(){var a=t.apply(this,arguments);return a!==n&&(e=(n=a)&&zu(a)),e}return r._value=t,r}function Fu(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,Iu(t))}function Uu(){for(var t=this._name,e=this._id,n=Ai(),r=this._groups,a=r.length,i=0;i<a;++i)for(var o=r[i],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=Qt(c,e);Kn(c,t,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new le(r,this._parents,t,n)}function Ou(){var t,e,n=this,r=n._id,a=n.size();return new Promise(function(i,o){var s={value:o},c={value:function(){--a===0&&i()}};n.each(function(){var l=re(this,r),u=l.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(s),e._.interrupt.push(s),e._.end.push(c)),l.on=e}),a===0&&i()})}var Yu=0;function le(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Ai(){return++Yu}var ce=nn.prototype;le.prototype={constructor:le,select:ku,selectAll:Su,selectChild:ce.selectChild,selectChildren:ce.selectChildren,filter:mu,merge:yu,selection:Au,transition:Uu,call:ce.call,nodes:ce.nodes,node:ce.node,size:ce.size,empty:ce.empty,each:ce.each,on:_u,attr:tu,attrTween:iu,style:Du,styleTween:Lu,text:Hu,textTween:Fu,remove:wu,tween:Xc,delay:lu,duration:fu,ease:du,easeVarying:gu,end:Ou,[Symbol.iterator]:ce[Symbol.iterator]};function Wu(t){return--t*t*t+1}function Vu(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Bu={time:null,delay:0,duration:250,ease:Vu};function Xu(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 Ku(t){var e,n;t instanceof le?(e=t._id,t=t._name):(e=Ai(),(n=Bu).time=Or(),t=t==null?null:t+"");for(var r=this._groups,a=r.length,i=0;i<a;++i)for(var o=r[i],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Kn(c,t,e,l,o,n||Xu(c,e));return new le(r,this._parents,t,e)}nn.prototype.interrupt=Wc,nn.prototype.transition=Ku;const qr=t=>()=>t;function qu(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 Gu(t){t.stopImmediatePropagation()}function Gr(t){t.preventDefault(),t.stopImmediatePropagation()}var Ti={name:"drag"},Zr={name:"space"},Pe={name:"handle"},He={name:"center"};const{abs:Ni,max:Ht,min:zt}=Math;function Ci(t){return[+t[0],+t[1]]}function $i(t){return[Ci(t[0]),Ci(t[1])]}var qn={name:"x",handles:["w","e"].map(Qr),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]]}},Jr={},ue={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"},Di={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},Ri={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},Zu={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},Ju={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function Qr(t){return{type:t}}function Qu(t){return!t.ctrlKey&&!t.button}function tf(){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 ef(){return navigator.maxTouchPoints||"ontouchstart"in this}function ta(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function nf(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}function rf(){return af(qn)}function af(t){var e=tf,n=Qu,r=ef,a=!0,i=Mr("start","brush","end"),o=6,s;function c(b){var v=b.property("__brush",W).selectAll(".overlay").data([Qr("overlay")]);v.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",ue.overlay).merge(v).each(function(){var x=ta(this).extent;At(this).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])}),b.selectAll(".selection").data([Qr("selection")]).enter().append("rect").attr("class","selection").attr("cursor",ue.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var L=b.selectAll(".handle").data(t.handles,function(x){return x.type});L.exit().remove(),L.enter().append("rect").attr("class",function(x){return"handle handle--"+x.type}).attr("cursor",function(x){return ue[x.type]}),b.each(l).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",h).filter(r).on("touchstart.brush",h).on("touchmove.brush",p).on("touchend.brush touchcancel.brush",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}c.move=function(b,v,L){b.tween?b.on("start.brush",function(x){u(this,arguments).beforestart().start(x)}).on("interrupt.brush end.brush",function(x){u(this,arguments).end(x)}).tween("brush",function(){var x=this,M=x.__brush,j=u(x,arguments),N=M.selection,z=t.input(typeof v=="function"?v.apply(this,arguments):v,M.extent),Y=se(N,z);function B(Z){M.selection=Z===1&&z===null?null:Y(Z),l.call(x),j.brush()}return N!==null&&z!==null?B:B(1)}):b.each(function(){var x=this,M=arguments,j=x.__brush,N=t.input(typeof v=="function"?v.apply(x,M):v,j.extent),z=u(x,M).beforestart();Xr(x),j.selection=N===null?null:N,l.call(x),z.start(L).brush(L).end(L)})},c.clear=function(b,v){c.move(b,null,v)};function l(){var b=At(this),v=ta(this).selection;v?(b.selectAll(".selection").style("display",null).attr("x",v[0][0]).attr("y",v[0][1]).attr("width",v[1][0]-v[0][0]).attr("height",v[1][1]-v[0][1]),b.selectAll(".handle").style("display",null).attr("x",function(L){return L.type[L.type.length-1]==="e"?v[1][0]-o/2:v[0][0]-o/2}).attr("y",function(L){return L.type[0]==="s"?v[1][1]-o/2:v[0][1]-o/2}).attr("width",function(L){return L.type==="n"||L.type==="s"?v[1][0]-v[0][0]+o:o}).attr("height",function(L){return L.type==="e"||L.type==="w"?v[1][1]-v[0][1]+o:o})):b.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(b,v,L){var x=b.__brush.emitter;return x&&(!L||!x.clean)?x:new f(b,v,L)}function f(b,v,L){this.that=b,this.args=v,this.state=b.__brush,this.active=0,this.clean=L}f.prototype={beforestart:function(){return++this.active===1&&(this.state.emitter=this,this.starting=!0),this},start:function(b,v){return this.starting?(this.starting=!1,this.emit("start",b,v)):this.emit("brush",b),this},brush:function(b,v){return this.emit("brush",b,v),this},end:function(b,v){return--this.active===0&&(delete this.state.emitter,this.emit("end",b,v)),this},emit:function(b,v,L){var x=At(this.that).datum();i.call(b,this.that,new qu(b,{sourceEvent:v,target:c,selection:t.output(this.state.selection),mode:L,dispatch:i}),x)}};function h(b){if(s&&!b.touches||!n.apply(this,arguments))return;var v=this,L=b.target.__data__.type,x=(a&&b.metaKey?L="overlay":L)==="selection"?Ti:a&&b.altKey?He:Pe,M=t===Jr?null:Zu[L],j=t===qn?null:Ju[L],N=ta(v),z=N.extent,Y=N.selection,B=z[0][0],Z,A,X=z[0][1],S,P,y=z[1][0],D,T,I=z[1][1],m,E,g=0,H=0,K,J=M&&j&&a&&b.shiftKey,ct,it,O=Array.from(b.touches||[b],et=>{const V=et.identifier;return et=Cr(et,v),et.point0=et.slice(),et.identifier=V,et});Xr(v);var tt=u(v,arguments,!0).beforestart();if(L==="overlay"){Y&&(K=!0);const et=[O[0],O[1]||O[0]];N.selection=Y=[[Z=t===Jr?B:zt(et[0][0],et[1][0]),S=t===qn?X:zt(et[0][1],et[1][1])],[D=t===Jr?y:Ht(et[0][0],et[1][0]),m=t===qn?I:Ht(et[0][1],et[1][1])]],O.length>1&&Q(b)}else Z=Y[0][0],S=Y[0][1],D=Y[1][0],m=Y[1][1];A=Z,P=S,T=D,E=m;var d=At(v).attr("pointer-events","none"),_=d.selectAll(".overlay").attr("cursor",ue[L]);if(b.touches)tt.moved=w,tt.ended=rt;else{var C=At(b.view).on("mousemove.brush",w,!0).on("mouseup.brush",rt,!0);a&&C.on("keydown.brush",ft,!0).on("keyup.brush",xt,!0),nc(b.view)}l.call(v),tt.start(b,x.name);function w(et){for(const V of et.changedTouches||[et])for(const at of O)at.identifier===V.identifier&&(at.cur=Cr(V,v));if(J&&!ct&&!it&&O.length===1){const V=O[0];Ni(V.cur[0]-V[0])>Ni(V.cur[1]-V[1])?it=!0:ct=!0}for(const V of O)V.cur&&(V[0]=V.cur[0],V[1]=V.cur[1]);K=!0,Gr(et),Q(et)}function Q(et){const V=O[0],at=V.point0;var R;switch(g=V[0]-at[0],H=V[1]-at[1],x){case Zr:case Ti:{M&&(g=Ht(B-Z,zt(y-D,g)),A=Z+g,T=D+g),j&&(H=Ht(X-S,zt(I-m,H)),P=S+H,E=m+H);break}case Pe:{O[1]?(M&&(A=Ht(B,zt(y,O[0][0])),T=Ht(B,zt(y,O[1][0])),M=1),j&&(P=Ht(X,zt(I,O[0][1])),E=Ht(X,zt(I,O[1][1])),j=1)):(M<0?(g=Ht(B-Z,zt(y-Z,g)),A=Z+g,T=D):M>0&&(g=Ht(B-D,zt(y-D,g)),A=Z,T=D+g),j<0?(H=Ht(X-S,zt(I-S,H)),P=S+H,E=m):j>0&&(H=Ht(X-m,zt(I-m,H)),P=S,E=m+H));break}case He:{M&&(A=Ht(B,zt(y,Z-g*M)),T=Ht(B,zt(y,D+g*M))),j&&(P=Ht(X,zt(I,S-H*j)),E=Ht(X,zt(I,m+H*j)));break}}T<A&&(M*=-1,R=Z,Z=D,D=R,R=A,A=T,T=R,L in Di&&_.attr("cursor",ue[L=Di[L]])),E<P&&(j*=-1,R=S,S=m,m=R,R=P,P=E,E=R,L in Ri&&_.attr("cursor",ue[L=Ri[L]])),N.selection&&(Y=N.selection),ct&&(A=Y[0][0],T=Y[1][0]),it&&(P=Y[0][1],E=Y[1][1]),(Y[0][0]!==A||Y[0][1]!==P||Y[1][0]!==T||Y[1][1]!==E)&&(N.selection=[[A,P],[T,E]],l.call(v),tt.brush(et,x.name))}function rt(et){if(Gu(et),et.touches){if(et.touches.length)return;s&&clearTimeout(s),s=setTimeout(function(){s=null},500)}else rc(et.view,K),C.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);d.attr("pointer-events","all"),_.attr("cursor",ue.overlay),N.selection&&(Y=N.selection),nf(Y)&&(N.selection=null,l.call(v)),tt.end(et,x.name)}function ft(et){switch(et.keyCode){case 16:{J=M&&j;break}case 18:{x===Pe&&(M&&(D=T-g*M,Z=A+g*M),j&&(m=E-H*j,S=P+H*j),x=He,Q(et));break}case 32:{(x===Pe||x===He)&&(M<0?D=T-g:M>0&&(Z=A-g),j<0?m=E-H:j>0&&(S=P-H),x=Zr,_.attr("cursor",ue.selection),Q(et));break}default:return}Gr(et)}function xt(et){switch(et.keyCode){case 16:{J&&(ct=it=J=!1,Q(et));break}case 18:{x===He&&(M<0?D=T:M>0&&(Z=A),j<0?m=E:j>0&&(S=P),x=Pe,Q(et));break}case 32:{x===Zr&&(et.altKey?(M&&(D=T-g*M,Z=A+g*M),j&&(m=E-H*j,S=P+H*j),x=He):(M<0?D=T:M>0&&(Z=A),j<0?m=E:j>0&&(S=P),x=Pe),_.attr("cursor",ue[L]),Q(et));break}default:return}Gr(et)}}function p(b){u(this,arguments).moved(b)}function k(b){u(this,arguments).ended(b)}function W(){var b=this.__brush||{selection:null};return b.extent=$i(e.apply(this,arguments)),b.dim=t,b}return c.extent=function(b){return arguments.length?(e=typeof b=="function"?b:qr($i(b)),c):e},c.filter=function(b){return arguments.length?(n=typeof b=="function"?b:qr(!!b),c):n},c.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:qr(!!b),c):r},c.handleSize=function(b){return arguments.length?(o=+b,c):o},c.keyModifiers=function(b){return arguments.length?(a=!!b,c):a},c.on=function(){var b=i.on.apply(i,arguments);return b===i?c:b},c}const ea=Math.PI,na=2*ea,Ae=1e-6,of=na-Ae;function Ei(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function sf(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Ei;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 lf=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?Ei:sf(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,o){this._append`C${+e},${+n},${+r},${+a},${this._x1=+i},${this._y1=+o}`}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 o=this._x1,s=this._y1,c=r-e,l=a-n,u=o-e,f=s-n,h=u*u+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(h>Ae)if(!(Math.abs(f*c-l*u)>Ae)||!i)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,k=a-s,W=c*c+l*l,b=p*p+k*k,v=Math.sqrt(W),L=Math.sqrt(h),x=i*Math.tan((ea-Math.acos((W+h-b)/(2*v*L)))/2),M=x/L,j=x/v;Math.abs(M-1)>Ae&&this._append`L${e+M*u},${n+M*f}`,this._append`A${i},${i},0,0,${+(f*p>u*k)},${this._x1=e+j*c},${this._y1=n+j*l}`}}arc(e,n,r,a,i,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let s=r*Math.cos(a),c=r*Math.sin(a),l=e+s,u=n+c,f=1^o,h=o?a-i:i-a;this._x1===null?this._append`M${l},${u}`:(Math.abs(this._x1-l)>Ae||Math.abs(this._y1-u)>Ae)&&this._append`L${l},${u}`,r&&(h<0&&(h=h%na+na),h>of?this._append`A${r},${r},0,1,${f},${e-s},${n-c}A${r},${r},0,1,${f},${this._x1=l},${this._y1=u}`:h>Ae&&this._append`A${r},${r},0,${+(h>=ea)},${f},${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 cf(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Gn(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function ze(t){return t=Gn(Math.abs(t)),t?t[1]:NaN}function uf(t,e){return function(n,r){for(var a=n.length,i=[],o=0,s=t[0],c=0;a>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),i.push(n.substring(a-=s,a+s)),!((c+=s+1)>r));)s=t[o=(o+1)%t.length];return i.reverse().join(e)}}function ff(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var hf=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Zn(t){if(!(e=hf.exec(t)))throw new Error("invalid format: "+t);var e;return new ra({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]})}Zn.prototype=ra.prototype;function ra(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+""}ra.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 df(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 Li;function pf(t,e){var n=Gn(t,e);if(!n)return t+"";var r=n[0],a=n[1],i=a-(Li=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,o=r.length;return i===o?r:i>o?r+new Array(i-o+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+Gn(t,Math.max(0,e+i-1))[0]}function ji(t,e){var n=Gn(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 Pi={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:cf,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)=>ji(t*100,e),r:ji,s:pf,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Hi(t){return t}var zi=Array.prototype.map,Ii=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function gf(t){var e=t.grouping===void 0||t.thousands===void 0?Hi:uf(zi.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?Hi:ff(zi.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",s=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function l(f){f=Zn(f);var h=f.fill,p=f.align,k=f.sign,W=f.symbol,b=f.zero,v=f.width,L=f.comma,x=f.precision,M=f.trim,j=f.type;j==="n"?(L=!0,j="g"):Pi[j]||(x===void 0&&(x=12),M=!0,j="g"),(b||h==="0"&&p==="=")&&(b=!0,h="0",p="=");var N=W==="$"?n:W==="#"&&/[boxX]/.test(j)?"0"+j.toLowerCase():"",z=W==="$"?r:/[%p]/.test(j)?o:"",Y=Pi[j],B=/[defgprs%]/.test(j);x=x===void 0?6:/[gprs]/.test(j)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x));function Z(A){var X=N,S=z,P,y,D;if(j==="c")S=Y(A)+S,A="";else{A=+A;var T=A<0||1/A<0;if(A=isNaN(A)?c:Y(Math.abs(A),x),M&&(A=df(A)),T&&+A==0&&k!=="+"&&(T=!1),X=(T?k==="("?k:s:k==="-"||k==="("?"":k)+X,S=(j==="s"?Ii[8+Li/3]:"")+S+(T&&k==="("?")":""),B){for(P=-1,y=A.length;++P<y;)if(D=A.charCodeAt(P),48>D||D>57){S=(D===46?a+A.slice(P+1):A.slice(P))+S,A=A.slice(0,P);break}}}L&&!b&&(A=e(A,1/0));var I=X.length+A.length+S.length,m=I<v?new Array(v-I+1).join(h):"";switch(L&&b&&(A=e(m+A,m.length?v-S.length:1/0),m=""),p){case"<":A=X+A+S+m;break;case"=":A=X+m+A+S;break;case"^":A=m.slice(0,I=m.length>>1)+X+A+S+m.slice(I);break;default:A=m+X+A+S;break}return i(A)}return Z.toString=function(){return f+""},Z}function u(f,h){var p=l((f=Zn(f),f.type="f",f)),k=Math.max(-8,Math.min(8,Math.floor(ze(h)/3)))*3,W=Math.pow(10,-k),b=Ii[8+k/3];return function(v){return p(W*v)+b}}return{format:l,formatPrefix:u}}var Jn,Rt,Fi;mf({thousands:",",grouping:[3],currency:["$",""]});function mf(t){return Jn=gf(t),Rt=Jn.format,Fi=Jn.formatPrefix,Jn}function yf(t){return Math.max(0,-ze(Math.abs(t)))}function xf(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ze(e)/3)))*3-ze(Math.abs(t)))}function vf(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,ze(e)-ze(t))+1}function _f(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 bf(){return this.eachAfter(_f)}function wf(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this}function kf(t,e){for(var n=this,r=[n],a,i,o=-1;n=r.pop();)if(t.call(e,n,++o,this),a=n.children)for(i=a.length-1;i>=0;--i)r.push(a[i]);return this}function Sf(t,e){for(var n=this,r=[n],a=[],i,o,s,c=-1;n=r.pop();)if(a.push(n),i=n.children)for(o=0,s=i.length;o<s;++o)r.push(i[o]);for(;n=a.pop();)t.call(e,n,++c,this);return this}function Mf(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r}function Af(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 Tf(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function Nf(t){for(var e=this,n=Cf(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 Cf(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 $f(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function Df(){return Array.from(this)}function Rf(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function Ef(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function*Lf(){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 aa(t,e){t instanceof Map?(t=[void 0,t],e===void 0&&(e=Hf)):e===void 0&&(e=Pf);for(var n=new Qn(t),r,a=[n],i,o,s,c;r=a.pop();)if((o=e(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)a.push(i=o[s]=new Qn(o[s])),i.parent=r,i.depth=r.depth+1;return n.eachBefore(If)}function jf(){return aa(this).eachBefore(zf)}function Pf(t){return t.children}function Hf(t){return Array.isArray(t)?t[1]:null}function zf(t){t.data.value!==void 0&&(t.value=t.data.value),t.data=t.data.data}function If(t){var e=0;do t.height=e;while((t=t.parent)&&t.height<++e)}function Qn(t){this.data=t,this.depth=this.height=0,this.parent=null}Qn.prototype=aa.prototype={constructor:Qn,count:bf,each:wf,eachAfter:Sf,eachBefore:kf,find:Mf,sum:Af,sort:Tf,path:Nf,ancestors:$f,descendants:Df,leaves:Rf,links:Ef,copy:jf,[Symbol.iterator]:Lf};function Ff(t){return t==null?null:Uf(t)}function Uf(t){if(typeof t!="function")throw new Error;return t}function Ui(){return 0}function Of(t){return function(){return t}}const Yf=1664525,Wf=1013904223,Oi=4294967296;function Vf(){let t=1;return()=>(t=(Yf*t+Wf)%Oi)/Oi}function Bf(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Xf(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 Kf(t,e){for(var n=0,r=(t=Xf(Array.from(t),e)).length,a=[],i,o;n<r;)i=t[n],o&&Yi(o,i)?++n:(o=Gf(a=qf(a,i)),n=0);return o}function qf(t,e){var n,r;if(ia(e,t))return[e];for(n=0;n<t.length;++n)if(tr(e,t[n])&&ia(hn(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(tr(hn(t[n],t[r]),e)&&tr(hn(t[n],e),t[r])&&tr(hn(t[r],e),t[n])&&ia(Wi(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function tr(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 Yi(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 ia(t,e){for(var n=0;n<e.length;++n)if(!Yi(t,e[n]))return!1;return!0}function Gf(t){switch(t.length){case 1:return Zf(t[0]);case 2:return hn(t[0],t[1]);case 3:return Wi(t[0],t[1],t[2])}}function Zf(t){return{x:t.x,y:t.y,r:t.r}}function hn(t,e){var n=t.x,r=t.y,a=t.r,i=e.x,o=e.y,s=e.r,c=i-n,l=o-r,u=s-a,f=Math.sqrt(c*c+l*l);return{x:(n+i+c/f*u)/2,y:(r+o+l/f*u)/2,r:(f+a+s)/2}}function Wi(t,e,n){var r=t.x,a=t.y,i=t.r,o=e.x,s=e.y,c=e.r,l=n.x,u=n.y,f=n.r,h=r-o,p=r-l,k=a-s,W=a-u,b=c-i,v=f-i,L=r*r+a*a-i*i,x=L-o*o-s*s+c*c,M=L-l*l-u*u+f*f,j=p*k-h*W,N=(k*M-W*x)/(j*2)-r,z=(W*b-k*v)/j,Y=(p*x-h*M)/(j*2)-a,B=(h*v-p*b)/j,Z=z*z+B*B-1,A=2*(i+N*z+Y*B),X=N*N+Y*Y-i*i,S=-(Math.abs(Z)>1e-6?(A+Math.sqrt(A*A-4*Z*X))/(2*Z):X/A);return{x:r+N+z*S,y:a+Y+B*S,r:S}}function Vi(t,e,n){var r=t.x-e.x,a,i,o=t.y-e.y,s,c,l=r*r+o*o;l?(i=e.r+n.r,i*=i,c=t.r+n.r,c*=c,i>c?(a=(l+c-i)/(2*l),s=Math.sqrt(Math.max(0,c/l-a*a)),n.x=t.x-a*r-s*o,n.y=t.y-a*o+s*r):(a=(l+i-c)/(2*l),s=Math.sqrt(Math.max(0,i/l-a*a)),n.x=e.x+a*r-s*o,n.y=e.y+a*o+s*r)):(n.x=e.x+n.r,n.y=e.y)}function Bi(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 Xi(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 er(t){this._=t,this.next=null,this.previous=null}function Jf(t,e){if(!(i=(t=Bf(t)).length))return 0;var n,r,a,i,o,s,c,l,u,f,h;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;Vi(r,n,a=t[2]),n=new er(n),r=new er(r),a=new er(a),n.next=a.previous=r,r.next=n.previous=a,a.next=r.previous=n;t:for(c=3;c<i;++c){Vi(n._,r._,a=t[c]),a=new er(a),l=r.next,u=n.previous,f=r._.r,h=n._.r;do if(f<=h){if(Bi(l._,a._)){r=l,n.next=r,r.previous=n,--c;continue t}f+=l._.r,l=l.next}else{if(Bi(u._,a._)){n=u,n.next=r,r.previous=n,--c;continue t}h+=u._.r,u=u.previous}while(l!==u.next);for(a.previous=n,a.next=r,n.next=r.previous=r=a,o=Xi(n);(a=a.next)!==r;)(s=Xi(a))<o&&(n=a,o=s);r=n.next}for(n=[r._],a=r;(a=a.next)!==r;)n.push(a._);for(a=Kf(n,e),c=0;c<i;++c)n=t[c],n.x-=a.x,n.y-=a.y;return a.r}function Qf(t){return Math.sqrt(t.value)}function th(){var t=null,e=1,n=1,r=Ui;function a(i){const o=Vf();return i.x=e/2,i.y=n/2,t?i.eachBefore(Ki(t)).eachAfter(oa(r,.5,o)).eachBefore(qi(1)):i.eachBefore(Ki(Qf)).eachAfter(oa(Ui,1,o)).eachAfter(oa(r,i.r/Math.min(e,n),o)).eachBefore(qi(Math.min(e,n)/(2*i.r))),i}return a.radius=function(i){return arguments.length?(t=Ff(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:Of(+i),a):r},a}function Ki(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function oa(t,e,n){return function(r){if(a=r.children){var a,i,o=a.length,s=t(r)*e||0,c;if(s)for(i=0;i<o;++i)a[i].r+=s;if(c=Jf(a,n),s)for(i=0;i<o;++i)a[i].r-=s;r.r=c+s}}}function qi(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 nr(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}const Gi=Symbol("implicit");function Zi(){var t=new vr,e=[],n=[],r=Gi;function a(i){let o=t.get(i);if(o===void 0){if(r!==Gi)return r;t.set(i,o=e.push(i)-1)}return n[o%n.length]}return a.domain=function(i){if(!arguments.length)return e.slice();e=[],t=new vr;for(const o of i)t.has(o)||t.set(o,e.push(o)-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 Zi(e,n).unknown(r)},nr.apply(a,arguments),a}function ye(){var t=Zi().unknown(void 0),e=t.domain,n=t.range,r=0,a=1,i,o,s=!1,c=0,l=0,u=.5;delete t.unknown;function f(){var h=e().length,p=a<r,k=p?a:r,W=p?r:a;i=(W-k)/Math.max(1,h-c+l*2),s&&(i=Math.floor(i)),k+=(W-k-i*(h-c))*u,o=i*(1-c),s&&(k=Math.round(k),o=Math.round(o));var b=us(h).map(function(v){return k+i*v});return n(p?b.reverse():b)}return t.domain=function(h){return arguments.length?(e(h),f()):e()},t.range=function(h){return arguments.length?([r,a]=h,r=+r,a=+a,f()):[r,a]},t.rangeRound=function(h){return[r,a]=h,r=+r,a=+a,s=!0,f()},t.bandwidth=function(){return o},t.step=function(){return i},t.round=function(h){return arguments.length?(s=!!h,f()):s},t.padding=function(h){return arguments.length?(c=Math.min(1,l=+h),f()):c},t.paddingInner=function(h){return arguments.length?(c=Math.min(1,h),f()):c},t.paddingOuter=function(h){return arguments.length?(l=+h,f()):l},t.align=function(h){return arguments.length?(u=Math.max(0,Math.min(1,h)),f()):u},t.copy=function(){return ye(e(),[r,a]).round(s).paddingInner(c).paddingOuter(l).align(u)},nr.apply(f(),arguments)}function eh(t){return function(){return t}}function nh(t){return+t}var Ji=[0,1];function Ie(t){return t}function sa(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:eh(isNaN(e)?NaN:.5)}function rh(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function ah(t,e,n){var r=t[0],a=t[1],i=e[0],o=e[1];return a<r?(r=sa(a,r),i=n(o,i)):(r=sa(r,a),i=n(i,o)),function(s){return i(r(s))}}function ih(t,e,n){var r=Math.min(t.length,e.length)-1,a=new Array(r),i=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)a[o]=sa(t[o],t[o+1]),i[o]=n(e[o],e[o+1]);return function(s){var c=ts(t,s,1,r)-1;return i[c](a[c](s))}}function Qi(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function oh(){var t=Ji,e=Ji,n=se,r,a,i,o=Ie,s,c,l;function u(){var h=Math.min(t.length,e.length);return o!==Ie&&(o=rh(t[0],t[h-1])),s=h>2?ih:ah,c=l=null,f}function f(h){return h==null||isNaN(h=+h)?i:(c||(c=s(t.map(r),e,n)))(r(o(h)))}return f.invert=function(h){return o(a((l||(l=s(e,t.map(r),qt)))(h)))},f.domain=function(h){return arguments.length?(t=Array.from(h,nh),u()):t.slice()},f.range=function(h){return arguments.length?(e=Array.from(h),u()):e.slice()},f.rangeRound=function(h){return e=Array.from(h),n=$c,u()},f.clamp=function(h){return arguments.length?(o=h?!0:Ie,u()):o!==Ie},f.interpolate=function(h){return arguments.length?(n=h,u()):n},f.unknown=function(h){return arguments.length?(i=h,f):i},function(h,p){return r=h,a=p,u()}}function to(){return oh()(Ie,Ie)}function sh(t,e,n,r){var a=br(t,e,n),i;switch(r=Zn(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(i=xf(a,o))&&(r.precision=i),Fi(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(i=vf(a,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=i-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(i=yf(a))&&(r.precision=i-(r.type==="%")*2);break}}return Rt(r)}function lh(t){var e=t.domain;return t.ticks=function(n){var r=e();return cs(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var a=e();return sh(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,o=r[a],s=r[i],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=a,a=i,i=l);u-- >0;){if(l=_r(o,s,n),l===c)return r[a]=o,r[i]=s,e(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return t},t}function Gt(){var t=to();return t.copy=function(){return Qi(t,Gt())},nr.apply(t,arguments),lh(t)}function ch(t,e){t=t.slice();var n=0,r=t.length-1,a=t[n],i=t[r],o;return i<a&&(o=n,n=r,r=o,o=a,a=i,i=o),t[n]=e.floor(a),t[r]=e.ceil(i),t}const la=new Date,ca=new Date;function Nt(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 o=a(i),s=a.ceil(i);return i-o<s-i?o:s},a.offset=(i,o)=>(e(i=new Date(+i),o==null?1:Math.floor(o)),i),a.range=(i,o,s)=>{const c=[];if(i=a.ceil(i),s=s==null?1:Math.floor(s),!(i<o)||!(s>0))return c;let l;do c.push(l=new Date(+i)),e(i,s),t(i);while(l<i&&i<o);return c},a.filter=i=>Nt(o=>{if(o>=o)for(;t(o),!i(o);)o.setTime(o-1)},(o,s)=>{if(o>=o)if(s<0)for(;++s<=0;)for(;e(o,-1),!i(o););else for(;--s>=0;)for(;e(o,1),!i(o););}),n&&(a.count=(i,o)=>(la.setTime(+i),ca.setTime(+o),t(la),t(ca),Math.floor(n(la,ca))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(r?o=>r(o)%i===0:o=>a.count(0,o)%i===0):a)),a}const rr=Nt(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);rr.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Nt(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):rr),rr.range;const fe=1e3,Zt=fe*60,he=Zt*60,de=he*24,ua=de*7,eo=de*30,fa=de*365,Fe=Nt(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*fe)},(t,e)=>(e-t)/fe,t=>t.getUTCSeconds());Fe.range;const ha=Nt(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*fe)},(t,e)=>{t.setTime(+t+e*Zt)},(t,e)=>(e-t)/Zt,t=>t.getMinutes());ha.range,Nt(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Zt)},(t,e)=>(e-t)/Zt,t=>t.getUTCMinutes()).range;const da=Nt(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*fe-t.getMinutes()*Zt)},(t,e)=>{t.setTime(+t+e*he)},(t,e)=>(e-t)/he,t=>t.getHours());da.range,Nt(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*he)},(t,e)=>(e-t)/he,t=>t.getUTCHours()).range;const dn=Nt(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Zt)/de,t=>t.getDate()-1);dn.range;const pa=Nt(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/de,t=>t.getUTCDate()-1);pa.range,Nt(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/de,t=>Math.floor(t/de)).range;function Te(t){return Nt(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())*Zt)/ua)}const pn=Te(0),ar=Te(1),uh=Te(2),fh=Te(3),Ue=Te(4),hh=Te(5),dh=Te(6);pn.range,ar.range,uh.range,fh.range,Ue.range,hh.range,dh.range;function Ne(t){return Nt(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)/ua)}const no=Ne(0),ir=Ne(1),ph=Ne(2),gh=Ne(3),Oe=Ne(4),mh=Ne(5),yh=Ne(6);no.range,ir.range,ph.range,gh.range,Oe.range,mh.range,yh.range;const or=Nt(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());or.range,Nt(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 pe=Nt(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());pe.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Nt(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)}),pe.range;const Ce=Nt(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());Ce.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Nt(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)}),Ce.range;function xh(t,e,n,r,a,i){const o=[[Fe,1,fe],[Fe,5,5*fe],[Fe,15,15*fe],[Fe,30,30*fe],[i,1,Zt],[i,5,5*Zt],[i,15,15*Zt],[i,30,30*Zt],[a,1,he],[a,3,3*he],[a,6,6*he],[a,12,12*he],[r,1,de],[r,2,2*de],[n,1,ua],[e,1,eo],[e,3,3*eo],[t,1,fa]];function s(l,u,f){const h=u<l;h&&([l,u]=[u,l]);const p=f&&typeof f.range=="function"?f:c(l,u,f),k=p?p.range(l,+u+1):[];return h?k.reverse():k}function c(l,u,f){const h=Math.abs(u-l)/f,p=Mn(([,,b])=>b).right(o,h);if(p===o.length)return t.every(br(l/fa,u/fa,f));if(p===0)return rr.every(Math.max(br(l,u,f),1));const[k,W]=o[h/o[p-1][2]<o[p][2]/h?p-1:p];return k.every(W)}return[s,c]}const[vh,_h]=xh(pe,or,pn,dn,da,ha);function ga(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 ma(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 gn(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function bh(t){var e=t.dateTime,n=t.date,r=t.time,a=t.periods,i=t.days,o=t.shortDays,s=t.months,c=t.shortMonths,l=mn(a),u=yn(a),f=mn(i),h=yn(i),p=mn(o),k=yn(o),W=mn(s),b=yn(s),v=mn(c),L=yn(c),x={a:T,A:I,b:m,B:E,c:null,d:lo,e:lo,f:Wh,g:td,G:nd,H:Uh,I:Oh,j:Yh,L:co,m:Vh,M:Bh,p:g,q:H,Q:mo,s:yo,S:Xh,u:Kh,U:qh,V:Gh,w:Zh,W:Jh,x:null,X:null,y:Qh,Y:ed,Z:rd,"%":go},M={a:K,A:J,b:ct,B:it,c:null,d:fo,e:fo,f:sd,g:yd,G:vd,H:ad,I:id,j:od,L:ho,m:ld,M:cd,p:O,q:tt,Q:mo,s:yo,S:ud,u:fd,U:hd,V:dd,w:pd,W:gd,x:null,X:null,y:md,Y:xd,Z:_d,"%":go},j={a:Z,A,b:X,B:S,c:P,d:oo,e:oo,f:Hh,g:io,G:ao,H:so,I:so,j:Eh,L:Ph,m:Rh,M:Lh,p:B,q:Dh,Q:Ih,s:Fh,S:jh,u:Ah,U:Th,V:Nh,w:Mh,W:Ch,x:y,X:D,y:io,Y:ao,Z:$h,"%":zh};x.x=N(n,x),x.X=N(r,x),x.c=N(e,x),M.x=N(n,M),M.X=N(r,M),M.c=N(e,M);function N(d,_){return function(C){var w=[],Q=-1,rt=0,ft=d.length,xt,et,V;for(C instanceof Date||(C=new Date(+C));++Q<ft;)d.charCodeAt(Q)===37&&(w.push(d.slice(rt,Q)),(et=ro[xt=d.charAt(++Q)])!=null?xt=d.charAt(++Q):et=xt==="e"?" ":"0",(V=_[xt])&&(xt=V(C,et)),w.push(xt),rt=Q+1);return w.push(d.slice(rt,Q)),w.join("")}}function z(d,_){return function(C){var w=gn(1900,void 0,1),Q=Y(w,d,C+="",0),rt,ft;if(Q!=C.length)return null;if("Q"in w)return new Date(w.Q);if("s"in w)return new Date(w.s*1e3+("L"in w?w.L:0));if(_&&!("Z"in w)&&(w.Z=0),"p"in w&&(w.H=w.H%12+w.p*12),w.m===void 0&&(w.m="q"in w?w.q:0),"V"in w){if(w.V<1||w.V>53)return null;"w"in w||(w.w=1),"Z"in w?(rt=ma(gn(w.y,0,1)),ft=rt.getUTCDay(),rt=ft>4||ft===0?ir.ceil(rt):ir(rt),rt=pa.offset(rt,(w.V-1)*7),w.y=rt.getUTCFullYear(),w.m=rt.getUTCMonth(),w.d=rt.getUTCDate()+(w.w+6)%7):(rt=ga(gn(w.y,0,1)),ft=rt.getDay(),rt=ft>4||ft===0?ar.ceil(rt):ar(rt),rt=dn.offset(rt,(w.V-1)*7),w.y=rt.getFullYear(),w.m=rt.getMonth(),w.d=rt.getDate()+(w.w+6)%7)}else("W"in w||"U"in w)&&("w"in w||(w.w="u"in w?w.u%7:"W"in w?1:0),ft="Z"in w?ma(gn(w.y,0,1)).getUTCDay():ga(gn(w.y,0,1)).getDay(),w.m=0,w.d="W"in w?(w.w+6)%7+w.W*7-(ft+5)%7:w.w+w.U*7-(ft+6)%7);return"Z"in w?(w.H+=w.Z/100|0,w.M+=w.Z%100,ma(w)):ga(w)}}function Y(d,_,C,w){for(var Q=0,rt=_.length,ft=C.length,xt,et;Q<rt;){if(w>=ft)return-1;if(xt=_.charCodeAt(Q++),xt===37){if(xt=_.charAt(Q++),et=j[xt in ro?_.charAt(Q++):xt],!et||(w=et(d,C,w))<0)return-1}else if(xt!=C.charCodeAt(w++))return-1}return w}function B(d,_,C){var w=l.exec(_.slice(C));return w?(d.p=u.get(w[0].toLowerCase()),C+w[0].length):-1}function Z(d,_,C){var w=p.exec(_.slice(C));return w?(d.w=k.get(w[0].toLowerCase()),C+w[0].length):-1}function A(d,_,C){var w=f.exec(_.slice(C));return w?(d.w=h.get(w[0].toLowerCase()),C+w[0].length):-1}function X(d,_,C){var w=v.exec(_.slice(C));return w?(d.m=L.get(w[0].toLowerCase()),C+w[0].length):-1}function S(d,_,C){var w=W.exec(_.slice(C));return w?(d.m=b.get(w[0].toLowerCase()),C+w[0].length):-1}function P(d,_,C){return Y(d,e,_,C)}function y(d,_,C){return Y(d,n,_,C)}function D(d,_,C){return Y(d,r,_,C)}function T(d){return o[d.getDay()]}function I(d){return i[d.getDay()]}function m(d){return c[d.getMonth()]}function E(d){return s[d.getMonth()]}function g(d){return a[+(d.getHours()>=12)]}function H(d){return 1+~~(d.getMonth()/3)}function K(d){return o[d.getUTCDay()]}function J(d){return i[d.getUTCDay()]}function ct(d){return c[d.getUTCMonth()]}function it(d){return s[d.getUTCMonth()]}function O(d){return a[+(d.getUTCHours()>=12)]}function tt(d){return 1+~~(d.getUTCMonth()/3)}return{format:function(d){var _=N(d+="",x);return _.toString=function(){return d},_},parse:function(d){var _=z(d+="",!1);return _.toString=function(){return d},_},utcFormat:function(d){var _=N(d+="",M);return _.toString=function(){return d},_},utcParse:function(d){var _=z(d+="",!0);return _.toString=function(){return d},_}}}var ro={"-":"",_:" ",0:"0"},$t=/^\s*\d+/,wh=/^%/,kh=/[\\^$*+?|[\]().{}]/g;function kt(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 Sh(t){return t.replace(kh,"\\$&")}function mn(t){return new RegExp("^(?:"+t.map(Sh).join("|")+")","i")}function yn(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Mh(t,e,n){var r=$t.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Ah(t,e,n){var r=$t.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Th(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Nh(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Ch(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function ao(t,e,n){var r=$t.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function io(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function $h(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 Dh(t,e,n){var r=$t.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Rh(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function oo(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Eh(t,e,n){var r=$t.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function so(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Lh(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function jh(t,e,n){var r=$t.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Ph(t,e,n){var r=$t.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Hh(t,e,n){var r=$t.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function zh(t,e,n){var r=wh.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Ih(t,e,n){var r=$t.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Fh(t,e,n){var r=$t.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function lo(t,e){return kt(t.getDate(),e,2)}function Uh(t,e){return kt(t.getHours(),e,2)}function Oh(t,e){return kt(t.getHours()%12||12,e,2)}function Yh(t,e){return kt(1+dn.count(pe(t),t),e,3)}function co(t,e){return kt(t.getMilliseconds(),e,3)}function Wh(t,e){return co(t,e)+"000"}function Vh(t,e){return kt(t.getMonth()+1,e,2)}function Bh(t,e){return kt(t.getMinutes(),e,2)}function Xh(t,e){return kt(t.getSeconds(),e,2)}function Kh(t){var e=t.getDay();return e===0?7:e}function qh(t,e){return kt(pn.count(pe(t)-1,t),e,2)}function uo(t){var e=t.getDay();return e>=4||e===0?Ue(t):Ue.ceil(t)}function Gh(t,e){return t=uo(t),kt(Ue.count(pe(t),t)+(pe(t).getDay()===4),e,2)}function Zh(t){return t.getDay()}function Jh(t,e){return kt(ar.count(pe(t)-1,t),e,2)}function Qh(t,e){return kt(t.getFullYear()%100,e,2)}function td(t,e){return t=uo(t),kt(t.getFullYear()%100,e,2)}function ed(t,e){return kt(t.getFullYear()%1e4,e,4)}function nd(t,e){var n=t.getDay();return t=n>=4||n===0?Ue(t):Ue.ceil(t),kt(t.getFullYear()%1e4,e,4)}function rd(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+kt(e/60|0,"0",2)+kt(e%60,"0",2)}function fo(t,e){return kt(t.getUTCDate(),e,2)}function ad(t,e){return kt(t.getUTCHours(),e,2)}function id(t,e){return kt(t.getUTCHours()%12||12,e,2)}function od(t,e){return kt(1+pa.count(Ce(t),t),e,3)}function ho(t,e){return kt(t.getUTCMilliseconds(),e,3)}function sd(t,e){return ho(t,e)+"000"}function ld(t,e){return kt(t.getUTCMonth()+1,e,2)}function cd(t,e){return kt(t.getUTCMinutes(),e,2)}function ud(t,e){return kt(t.getUTCSeconds(),e,2)}function fd(t){var e=t.getUTCDay();return e===0?7:e}function hd(t,e){return kt(no.count(Ce(t)-1,t),e,2)}function po(t){var e=t.getUTCDay();return e>=4||e===0?Oe(t):Oe.ceil(t)}function dd(t,e){return t=po(t),kt(Oe.count(Ce(t),t)+(Ce(t).getUTCDay()===4),e,2)}function pd(t){return t.getUTCDay()}function gd(t,e){return kt(ir.count(Ce(t)-1,t),e,2)}function md(t,e){return kt(t.getUTCFullYear()%100,e,2)}function yd(t,e){return t=po(t),kt(t.getUTCFullYear()%100,e,2)}function xd(t,e){return kt(t.getUTCFullYear()%1e4,e,4)}function vd(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Oe(t):Oe.ceil(t),kt(t.getUTCFullYear()%1e4,e,4)}function _d(){return"+0000"}function go(){return"%"}function mo(t){return+t}function yo(t){return Math.floor(+t/1e3)}var Ye,xn,xo;bd({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 bd(t){return Ye=bh(t),xn=Ye.format,xo=Ye.parse,Ye.utcFormat,Ye.utcParse,Ye}function wd(t){return new Date(t)}function kd(t){return t instanceof Date?+t:+new Date(+t)}function vo(t,e,n,r,a,i,o,s,c,l){var u=to(),f=u.invert,h=u.domain,p=l(".%L"),k=l(":%S"),W=l("%I:%M"),b=l("%I %p"),v=l("%a %d"),L=l("%b %d"),x=l("%B"),M=l("%Y");function j(N){return(c(N)<N?p:s(N)<N?k:o(N)<N?W:i(N)<N?b:r(N)<N?a(N)<N?v:L:n(N)<N?x:M)(N)}return u.invert=function(N){return new Date(f(N))},u.domain=function(N){return arguments.length?h(Array.from(N,kd)):h().map(wd)},u.ticks=function(N){var z=h();return t(z[0],z[z.length-1],N??10)},u.tickFormat=function(N,z){return z==null?j:l(z)},u.nice=function(N){var z=h();return(!N||typeof N.range!="function")&&(N=e(z[0],z[z.length-1],N??10)),N?h(ch(z,N)):u},u.copy=function(){return Qi(u,vo(t,e,n,r,a,i,o,s,c,l))},u}function _o(){return nr.apply(vo(vh,_h,pe,or,pn,dn,da,ha,Fe,xn).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function vn(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 ya=vn("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),bo=vn("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"),wo=vn("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"),ko=vn("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"),So=vn("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");function wt(t){return function(){return t}}const Mo=Math.abs,It=Math.atan2,$e=Math.cos,Sd=Math.max,xa=Math.min,ae=Math.sin,We=Math.sqrt,Wt=1e-12,_n=Math.PI,sr=_n/2,lr=2*_n;function Md(t){return t>1?0:t<-1?_n:Math.acos(t)}function Ao(t){return t>=1?sr:t<=-1?-sr:Math.asin(t)}function va(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 lf(e)}function Ad(t){return t.innerRadius}function Td(t){return t.outerRadius}function Nd(t){return t.startAngle}function Cd(t){return t.endAngle}function $d(t){return t&&t.padAngle}function Dd(t,e,n,r,a,i,o,s){var c=n-t,l=r-e,u=o-a,f=s-i,h=f*c-u*l;if(!(h*h<Wt))return h=(u*(e-i)-f*(t-a))/h,[t+h*c,e+h*l]}function cr(t,e,n,r,a,i,o){var s=t-n,c=e-r,l=(o?i:-i)/We(s*s+c*c),u=l*c,f=-l*s,h=t+u,p=e+f,k=n+u,W=r+f,b=(h+k)/2,v=(p+W)/2,L=k-h,x=W-p,M=L*L+x*x,j=a-i,N=h*W-k*p,z=(x<0?-1:1)*We(Sd(0,j*j*M-N*N)),Y=(N*x-L*z)/M,B=(-N*L-x*z)/M,Z=(N*x+L*z)/M,A=(-N*L+x*z)/M,X=Y-b,S=B-v,P=Z-b,y=A-v;return X*X+S*S>P*P+y*y&&(Y=Z,B=A),{cx:Y,cy:B,x01:-u,y01:-f,x11:Y*(a/j-1),y11:B*(a/j-1)}}function To(){var t=Ad,e=Td,n=wt(0),r=null,a=Nd,i=Cd,o=$d,s=null,c=va(l);function l(){var u,f,h=+t.apply(this,arguments),p=+e.apply(this,arguments),k=a.apply(this,arguments)-sr,W=i.apply(this,arguments)-sr,b=Mo(W-k),v=W>k;if(s||(s=u=c()),p<h&&(f=p,p=h,h=f),!(p>Wt))s.moveTo(0,0);else if(b>lr-Wt)s.moveTo(p*$e(k),p*ae(k)),s.arc(0,0,p,k,W,!v),h>Wt&&(s.moveTo(h*$e(W),h*ae(W)),s.arc(0,0,h,W,k,v));else{var L=k,x=W,M=k,j=W,N=b,z=b,Y=o.apply(this,arguments)/2,B=Y>Wt&&(r?+r.apply(this,arguments):We(h*h+p*p)),Z=xa(Mo(p-h)/2,+n.apply(this,arguments)),A=Z,X=Z,S,P;if(B>Wt){var y=Ao(B/h*ae(Y)),D=Ao(B/p*ae(Y));(N-=y*2)>Wt?(y*=v?1:-1,M+=y,j-=y):(N=0,M=j=(k+W)/2),(z-=D*2)>Wt?(D*=v?1:-1,L+=D,x-=D):(z=0,L=x=(k+W)/2)}var T=p*$e(L),I=p*ae(L),m=h*$e(j),E=h*ae(j);if(Z>Wt){var g=p*$e(x),H=p*ae(x),K=h*$e(M),J=h*ae(M),ct;if(b<_n)if(ct=Dd(T,I,K,J,g,H,m,E)){var it=T-ct[0],O=I-ct[1],tt=g-ct[0],d=H-ct[1],_=1/ae(Md((it*tt+O*d)/(We(it*it+O*O)*We(tt*tt+d*d)))/2),C=We(ct[0]*ct[0]+ct[1]*ct[1]);A=xa(Z,(h-C)/(_-1)),X=xa(Z,(p-C)/(_+1))}else A=X=0}z>Wt?X>Wt?(S=cr(K,J,T,I,p,X,v),P=cr(g,H,m,E,p,X,v),s.moveTo(S.cx+S.x01,S.cy+S.y01),X<Z?s.arc(S.cx,S.cy,X,It(S.y01,S.x01),It(P.y01,P.x01),!v):(s.arc(S.cx,S.cy,X,It(S.y01,S.x01),It(S.y11,S.x11),!v),s.arc(0,0,p,It(S.cy+S.y11,S.cx+S.x11),It(P.cy+P.y11,P.cx+P.x11),!v),s.arc(P.cx,P.cy,X,It(P.y11,P.x11),It(P.y01,P.x01),!v))):(s.moveTo(T,I),s.arc(0,0,p,L,x,!v)):s.moveTo(T,I),!(h>Wt)||!(N>Wt)?s.lineTo(m,E):A>Wt?(S=cr(m,E,g,H,h,-A,v),P=cr(T,I,K,J,h,-A,v),s.lineTo(S.cx+S.x01,S.cy+S.y01),A<Z?s.arc(S.cx,S.cy,A,It(S.y01,S.x01),It(P.y01,P.x01),!v):(s.arc(S.cx,S.cy,A,It(S.y01,S.x01),It(S.y11,S.x11),!v),s.arc(0,0,h,It(S.cy+S.y11,S.cx+S.x11),It(P.cy+P.y11,P.cx+P.x11),v),s.arc(P.cx,P.cy,A,It(P.y11,P.x11),It(P.y01,P.x01),!v))):s.arc(0,0,h,j,M,v)}if(s.closePath(),u)return s=null,u+""||null}return l.centroid=function(){var u=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,f=(+a.apply(this,arguments)+ +i.apply(this,arguments))/2-_n/2;return[$e(f)*u,ae(f)*u]},l.innerRadius=function(u){return arguments.length?(t=typeof u=="function"?u:wt(+u),l):t},l.outerRadius=function(u){return arguments.length?(e=typeof u=="function"?u:wt(+u),l):e},l.cornerRadius=function(u){return arguments.length?(n=typeof u=="function"?u:wt(+u),l):n},l.padRadius=function(u){return arguments.length?(r=u==null?null:typeof u=="function"?u:wt(+u),l):r},l.startAngle=function(u){return arguments.length?(a=typeof u=="function"?u:wt(+u),l):a},l.endAngle=function(u){return arguments.length?(i=typeof u=="function"?u:wt(+u),l):i},l.padAngle=function(u){return arguments.length?(o=typeof u=="function"?u:wt(+u),l):o},l.context=function(u){return arguments.length?(s=u??null,l):s},l}function ur(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function No(t){this._context=t}No.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 Co(t){return new No(t)}function $o(t){return t[0]}function Do(t){return t[1]}function _a(t,e){var n=wt(!0),r=null,a=Co,i=null,o=va(s);t=typeof t=="function"?t:t===void 0?$o:wt(t),e=typeof e=="function"?e:e===void 0?Do:wt(e);function s(c){var l,u=(c=ur(c)).length,f,h=!1,p;for(r==null&&(i=a(p=o())),l=0;l<=u;++l)!(l<u&&n(f=c[l],l,c))===h&&((h=!h)?i.lineStart():i.lineEnd()),h&&i.point(+t(f,l,c),+e(f,l,c));if(p)return i=null,p+""||null}return s.x=function(c){return arguments.length?(t=typeof c=="function"?c:wt(+c),s):t},s.y=function(c){return arguments.length?(e=typeof c=="function"?c:wt(+c),s):e},s.defined=function(c){return arguments.length?(n=typeof c=="function"?c:wt(!!c),s):n},s.curve=function(c){return arguments.length?(a=c,r!=null&&(i=a(r)),s):a},s.context=function(c){return arguments.length?(c==null?r=i=null:i=a(r=c),s):r},s}function Rd(t,e,n){var r=null,a=wt(!0),i=null,o=Co,s=null,c=va(l);t=typeof t=="function"?t:t===void 0?$o:wt(+t),e=typeof e=="function"?e:wt(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?Do:wt(+n);function l(f){var h,p,k,W=(f=ur(f)).length,b,v=!1,L,x=new Array(W),M=new Array(W);for(i==null&&(s=o(L=c())),h=0;h<=W;++h){if(!(h<W&&a(b=f[h],h,f))===v)if(v=!v)p=h,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),k=h-1;k>=p;--k)s.point(x[k],M[k]);s.lineEnd(),s.areaEnd()}v&&(x[h]=+t(b,h,f),M[h]=+e(b,h,f),s.point(r?+r(b,h,f):x[h],n?+n(b,h,f):M[h]))}if(L)return s=null,L+""||null}function u(){return _a().defined(a).curve(o).context(i)}return l.x=function(f){return arguments.length?(t=typeof f=="function"?f:wt(+f),r=null,l):t},l.x0=function(f){return arguments.length?(t=typeof f=="function"?f:wt(+f),l):t},l.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:wt(+f),l):r},l.y=function(f){return arguments.length?(e=typeof f=="function"?f:wt(+f),n=null,l):e},l.y0=function(f){return arguments.length?(e=typeof f=="function"?f:wt(+f),l):e},l.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:wt(+f),l):n},l.lineX0=l.lineY0=function(){return u().x(t).y(e)},l.lineY1=function(){return u().x(t).y(n)},l.lineX1=function(){return u().x(r).y(e)},l.defined=function(f){return arguments.length?(a=typeof f=="function"?f:wt(!!f),l):a},l.curve=function(f){return arguments.length?(o=f,i!=null&&(s=o(i)),l):o},l.context=function(f){return arguments.length?(f==null?i=s=null:s=o(i=f),l):i},l}function Ed(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function Ld(t){return t}function jd(){var t=Ld,e=Ed,n=null,r=wt(0),a=wt(lr),i=wt(0);function o(s){var c,l=(s=ur(s)).length,u,f,h=0,p=new Array(l),k=new Array(l),W=+r.apply(this,arguments),b=Math.min(lr,Math.max(-lr,a.apply(this,arguments)-W)),v,L=Math.min(Math.abs(b)/l,i.apply(this,arguments)),x=L*(b<0?-1:1),M;for(c=0;c<l;++c)(M=k[p[c]=c]=+t(s[c],c,s))>0&&(h+=M);for(e!=null?p.sort(function(j,N){return e(k[j],k[N])}):n!=null&&p.sort(function(j,N){return n(s[j],s[N])}),c=0,f=h?(b-l*x)/h:0;c<l;++c,W=v)u=p[c],M=k[u],v=W+(M>0?M*f:0)+x,k[u]={data:s[u],index:c,value:M,startAngle:W,endAngle:v,padAngle:L};return k}return o.value=function(s){return arguments.length?(t=typeof s=="function"?s:wt(+s),o):t},o.sortValues=function(s){return arguments.length?(e=s,n=null,o):e},o.sort=function(s){return arguments.length?(n=s,e=null,o):n},o.startAngle=function(s){return arguments.length?(r=typeof s=="function"?s:wt(+s),o):r},o.endAngle=function(s){return arguments.length?(a=typeof s=="function"?s:wt(+s),o):a},o.padAngle=function(s){return arguments.length?(i=typeof s=="function"?s:wt(+s),o):i},o}function fr(t,e){if((o=t.length)>1)for(var n=1,r,a,i=t[e[0]],o,s=i.length;n<o;++n)for(a=i,i=t[e[n]],r=0;r<s;++r)i[r][1]+=i[r][0]=isNaN(a[r][1])?a[r][0]:a[r][1]}function hr(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Pd(t,e){return t[e]}function Hd(t){const e=[];return e.key=t,e}function bn(){var t=wt([]),e=hr,n=fr,r=Pd;function a(i){var o=Array.from(t.apply(this,arguments),Hd),s,c=o.length,l=-1,u;for(const f of i)for(s=0,++l;s<c;++s)(o[s][l]=[0,+r(f,o[s].key,l,i)]).data=f;for(s=0,u=ur(e(o));s<c;++s)o[u[s]].index=s;return n(o,u),o}return a.keys=function(i){return arguments.length?(t=typeof i=="function"?i:wt(Array.from(i)),a):t},a.value=function(i){return arguments.length?(r=typeof i=="function"?i:wt(+i),a):r},a.order=function(i){return arguments.length?(e=i==null?hr:typeof i=="function"?i:wt(Array.from(i)),a):e},a.offset=function(i){return arguments.length?(n=i??fr,a):n},a}function zd(t,e){if((r=t.length)>0){for(var n,r,a=0,i=t[0].length,o;a<i;++a){for(o=n=0;n<r;++n)o+=t[n][a][1]||0;if(o)for(n=0;n<r;++n)t[n][a][1]/=o}fr(t,e)}}function wn(t,e,n){this.k=t,this.x=e,this.y=n}wn.prototype={constructor:wn,scale:function(t){return t===1?this:new wn(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new wn(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+")"}},wn.prototype;const Kt=(t,e)=>{const n=ut.useRef(null);return ut.useEffect(()=>{e!==void 0&&n.current&&t(At(n.current))},e===null?void 0:e),n};function ge(){const t=ut.useRef(null),[e,n]=ut.useState({width:0,height:0});return ut.useEffect(()=>{const r=t.current;if(!r||!r.parentElement)return;const a=r.parentElement,i=()=>{const s=a.getBoundingClientRect();n({width:s.width,height:s.height})};i();const o=new ResizeObserver(()=>i());return o.observe(a),()=>o.disconnect()},[]),[t,e]}function dr(){const[t,e]=ut.useState(null);return ut.useEffect(()=>{const n=typeof document<"u"?document.getElementById("UI-controls"):null;e(n)},[]),t}const Ot=t=>{try{return JSON.parse(JSON.stringify(t))}catch{return console.log("error when cloning object : "),Array.isArray(t)?[]:null}},Ve=["#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"];fs([...wo,...bo,...ko,...So,...ya]);const Ro=[...wo,...bo,...ko,...So,...ya],Ft=(t,e=!0)=>{const n=e?[...Ve,...Ro]:[...Ro,...Ve];return t<n.length?n[t]:n[t%n.length]},Be=t=>t<Ve.length?Ve[t]:Ve[t%Ve.length],Et=(t,{formatType:e="long",prefix:n="",suffix:r=""}={})=>n+Rt(e==="long"?",":"~s")(t)+r;function Id(t,e,n){const{top:r}=e.getBoundingClientRect(),a=t.clientY-r;return{pixelY:a,dataY:n.invert(a)}}const Vt={tooltip:"_tooltip_vth6t_3","tooltip--arrow-up":"_tooltip--arrow-up_vth6t_73","tooltip--arrow-down":"_tooltip--arrow-down_vth6t_101",title:"_title_vth6t_167","text-small":"_text-small_vth6t_199","right-label":"_right-label_vth6t_227"},Xe=({pCount:t})=>$.jsxs("div",{id:"tooltip",className:`${Vt.tooltip}`,style:{opacity:0},children:[!t&&$.jsx("p",{className:`top-label ${Vt["text-small"]}`}),t===2&&$.jsxs($.Fragment,{children:[$.jsx("p",{className:`top-label ${Vt["text-small"]}`}),$.jsx("p",{className:`bottom-label ${Vt["text-small"]}`})]}),$.jsxs($.Fragment,{children:[$.jsx("p",{className:`title ${Vt.title}`}),$.jsx("p",{className:`top-label ${Vt["right-label"]}`}),$.jsx("p",{className:`bottom-label ${Vt["right-label"]}`})]}),t===4&&$.jsx("p",{className:`small-text ${Vt["right-label"]} ${Vt["small-text"]}`})]}),Ke=(t,e="tooltip")=>t.select(`#${e}`).style("pointer-events","none").style("position","fixed").style("left","auto").style("top","auto").style("bottom","auto").style("right","auto").style("padding","8px 5px").style("max-width","200px").style("opacity",0);function pr(t,e){const{e:n,svg:r,yScale:a}=e,{pixelY:i}=Id(n,r,a),o=i<100?"bottom":"top",{offsetWidth:s,offsetHeight:c}=t.node()||{},l=typeof document<"u"?document.documentElement.clientWidth:0,u=n.x-s/2;let f=0;if(u<0)f=0;else if(u+s>l){const p=u+s-l;f=u-p}else f=u;const h=o==="top"?Vt["tooltip--arrow-down"]:Vt["tooltip--arrow-up"];t.attr("class",`${Vt.tooltip} ${h}`).style("left",f+"px").style("top",o==="top"?n.y-(c+20)+"px":n.y+30+"px")}function gr(t,e){const{offsetWidth:n,offsetHeight:r}=e.node()||{},a=document.documentElement.clientWidth,i=t.x-n/2;let o=0;if(i<0)o=0;else if(i+n>a){const s=i+n-a;o=i-s}else o=i;e.style("left",o+"px").attr("class",`${Vt.tooltip} ${Vt["tooltip--arrow-down"]}`).style("top",t.y-(r+10)+"px")}function Fd(t){t.style("opacity",0)}const me="#d1d5db",st={"controls-container":"_controls-container_6kkmf_1","controls-container-sm":"_controls-container-sm_6kkmf_1","fill-container":"_fill-container_6kkmf_39","controls-label":"_controls-label_6kkmf_55",disabled:"_disabled_6kkmf_99","controls-checkbox":"_controls-checkbox_6kkmf_109","chart-svg":"_chart-svg_6kkmf_139"},mr={rotatedAxisText:"_rotatedAxisText_1tba7_1",axisText:"_axisText_1tba7_11","value-axis":"_value-axis_1tba7_21"},qe=t=>{const e=ut.useRef([]);return ut.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 Ud({data:t,color:{idx:e=0,type:n="fixed"}={idx:0,type:"fixed"},orientation:r="vertical",tooltipFormat:{prefix:a="",suffix:i="",formatType:o="long"}={prefix:"",suffix:"",formatType:"long"}}){const[s,c]=ge(),{width:l,height:u}=c,[f,h]=ut.useState(!1),p=qe(t.map(M=>M.label)),k=dr(),W=l>576,b=$.jsx("div",{id:"controls",className:`${st[W?"controls-container":"controls-container-sm"]} ${k?st["fill-container"]:""}`,children:$.jsxs("label",{className:st["controls-label"],children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:f,onChange:M=>h(M.target.checked)}),"Sort"]})}),v={idx:e,type:n},L=750,x=Kt(M=>{if(l===0||u===0)return;const j={top:20,right:30,bottom:r==="vertical"?50:30,left:r==="vertical"?25:50},N=f?Ot(t).sort((m,E)=>E.value-m.value):Ot(t),z=M.select("svg"),Y=z.node(),B=z.select(".plot-area").attr("transform","translate("+j.left+","+j.top+")"),Z=Ke(M).style("opacity",0),A=W?mr.axisText:mr.rotatedAxisText,X=l-j.left-j.right,S=u-j.top-j.bottom,P=ye().domain(N.map(m=>m.label)).rangeRound(r==="vertical"?[0,X]:[S,0]).paddingInner(W?.4:.25).paddingOuter(.1),y=Gt().domain([0,Dt(N,m=>m.value)??0]).rangeRound(r==="vertical"?[S,0]:[0,X]),D=r==="vertical"?Ut(P).tickValues(P.domain()).scale(P).tickSizeOuter(0):Ut(y).ticks(5,"s").tickSizeOuter(0).tickSize(-S);B.select(".x-axis").attr("transform",`translate(0, ${S})`).transition().duration(L).call(D).selectAll("text").attr("class",A);const T=r==="vertical"?te(y).ticks(5,"s").tickSize(-X):te(P).tickSizeOuter(0);B.select(".y-axis").attr("transform","translate(0, 0)").transition().duration(L).call(T);const I=m=>{const{idx:E,type:g}=v,H=p.current.findIndex(K=>K===m.label);return Be(g==="fixed"?E:E+H)};B.selectAll(".bar").data(N,m=>m.label).join(m=>m.append("rect").attr("class","bar").attr("x",function(E){return r==="vertical"?P(E.label)??0:y(0)}).attr("width",function(E){return r==="vertical"?P.bandwidth():0}).attr("y",function(E){return r==="vertical"?y(0):P(E.label)??0}).attr("height",function(){return r==="vertical"?0:P.bandwidth()}).attr("fill",I).transition().duration(L).attr("y",function(E){return r==="vertical"?y(E.value):P(E.label)??0}).attr("width",function(E){return r==="vertical"?P.bandwidth():y(E.value)}).attr("height",function(E){return r==="vertical"?y(0)-y(E.value):P.bandwidth()}),void 0,m=>m.transition().duration(L).attr("fill",me).attr("height",0).attr("y",u).style("opacity",0).remove()).on("mouseover",(m,E)=>{B.selectAll("rect.bar").filter(g=>g.label===E.label).style("stroke","#71717a").style("stroke-width",1),Z.style("opacity",1).select("p").text(E.label+` :
23
- ${a}
24
- ${Rt(o==="long"?",":"~s")(E.value)}
25
- ${i}`),At(".x-axis").selectAll("text").filter(g=>g===E.label).style("font-weight","bold")}).on("mousemove",(m,E)=>{pr(Z,{e:m,svg:Y,yScale:y})}).on("mouseout",(m,E)=>{B.selectAll("rect.bar").filter(g=>g.label===E.label).style("stroke","none").style("stroke-width",0),Z.style("opacity",0),At(".x-axis").selectAll("text").filter(g=>g===E.label).style("font-weight","normal")}).transition().duration(L).attr("fill",I).attr("x",function(m){return r==="vertical"?P(m.label)??0:y(0)}).attr("width",function(m){return r==="vertical"?P.bandwidth():y(m.value)}).attr("y",function(m){return r==="vertical"?y(m.value):P(m.label)??0}).attr("height",function(m){return r==="vertical"?y(0)-y(m.value):P.bandwidth()})},[t,v,l,u,f,r,{prefix:a,suffix:i,formatType:o}]);return $.jsxs("div",{ref:s,style:{width:l,height:u,display:"flex",flexDirection:"column"},children:[k&&kn.createPortal(b,k),$.jsxs("div",{ref:x,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[$.jsx("svg",{className:`${st["chart-svg"]} ${st["fill-container"]}`,style:{},viewBox:`0 0 ${l} ${u}`,children:$.jsxs("g",{className:"plot-area",children:[$.jsx("g",{className:`${r==="vertical"?mr["value-axis"]:""} y-axis`}),$.jsx("g",{className:`${r==="horizontal"?mr["value-axis"]:""} x-axis`})]})}),!k&&$.jsxs("label",{className:st["controls-label"],style:{position:"absolute",right:"12px",top:"6px"},children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:f,onChange:M=>h(M.target.checked)}),"Sort"]}),$.jsx(Xe,{})]})]})}function xe(){const t=ut.useRef(null),[e,n]=ut.useState({width:0,height:0});return ut.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 ie={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 Od({data:t,innerRadius:e=0,sortWithLegends:n=!1,colorIdx:r=0}){const[a,i]=ge(),{width:o,height:s}=i,[c,l]=xe(),{width:u,height:f}=l,h=qe(t.map(z=>z.label)),[p,k]=ut.useState([]),[W,b]=ut.useState(!1),[v,L]=ut.useState(""),x=750,M=Kt(z=>{const B=(n&&W?Ot(t).sort((A,X)=>A.value-X.value):t).map(A=>A.label);z.selectAll(".legend-item").data([...B],A=>A).join(A=>{const X=A.append("div").attr("class",function(S){return`${ie[S===v?"legend-active":"legend"]} legend-item`}).style("left","-10px").style("top",function(S,P){return`${P*20+10}px`}).style("opacity",0);return X.append("div").attr("class",`rect ${ie["legend-rect"]}`).style("background-color",S=>Be(h.current.findIndex(P=>P===S)+r)),X.append("span").attr("class",ie["legend-label"]).style("color",S=>"#333").text(S=>S),X.transition().duration(x).style("left","6px").style("opacity",1),X},A=>(A.attr("class",X=>`
26
- ${ie[X===v?"legend-active":"legend"]} legend-item`).transition().duration(x).style("top",function(X,S){return`${S*20+10}px`}).style("left","6px").style("opacity",1).select("div.rect").attr("class",`rect ${ie["legend-rect"]}`).style("background-color",X=>Be(h.current.findIndex(S=>S===X)+r)),A.select("span").style("color",X=>"#333").text(X=>X),A),A=>A.transition().duration(x).style("opacity",0).style("left","30px").remove()).on("mouseover",(A,X)=>{L(X)}).on("mouseout",()=>{L("")})},[t,r,u,f,v,W,n]),j=Kt(z=>{if(u===0||f===0)return;const Y={x:u/2,y:f/2},B={top:10,right:20,bottom:10,left:20},Z=t,A=u-(B.left+B.right),X=f-(B.top+B.bottom),S=Math.min(A,X)/2,P=Z.reduce((C,w)=>C+w.value,0),y=z.select(".plot-area").attr("transform","translate("+Y.x+","+Y.y+")"),D=jd().value(function(C){return C.value}).sort(function(C,w){return W?tn(C.value,w.value):0}),T=Ot(Z),I=D(T),m=Ot(T);k(D(m));let E=m.length>T.length;const g=p.map(C=>C.data.label),H=I.map(C=>C.data.label);g.every(C=>E?!1:H.includes(C)?!0:(E=!0,!1));const K=p.length===0,ct=To().innerRadius(e*S).outerRadius(S-12),it=To().innerRadius(e*S).outerRadius(S),O=(C,w)=>{const Q=se(w==="exit"?C.endAngle:C.startAngle,w==="exit"?C.startAngle:C.endAngle),rt=C.data.label===v;return function(ft){return C.endAngle=Q(ft),rt?it(C)||"":ct(C)||""}};y.selectAll("path").data(I,function(C){return C.data.label}).join(C=>{const w=C.append("path").attr("class",ie.pieSlice).attr("fill",function(Q){const rt=h.current.findIndex(ft=>ft===Q.data.label)+r;return Be(rt)});return w.transition().duration(x).delay(K?0:x).attr("d",ct).attrTween("d",function(Q){if(!K)return O(Q,"not exit");const rt=se(0,Q.startAngle),ft=se(0,Q.endAngle),xt=Q.data.label===v;return function(et){return Q.startAngle=rt(et),Q.endAngle=ft(et),xt?it(Q):ct(Q)}}),w},C=>{const w=C;return C.transition().duration(x).attr("fill",function(Q,rt){const ft=h.current.findIndex(xt=>xt===Q.data.label)+r;return Be(ft)}).attrTween("d",function(Q){const rt=p.find(R=>R.data.label===Q.data.label),ft=rt&&rt.startAngle?rt.startAngle:0,xt=se(ft,Q.startAngle),et=rt&&rt.endAngle?rt.endAngle:0,V=se(et,Q.endAngle),at=Q.data.label===v;return function(R){return Q.startAngle=xt(R),Q.endAngle=V(R),at?it(Q)||"":ct(Q)||""}}),w},C=>C.attr("class",ie.pieSliceExit).transition().duration(x).attr("fill",me).attrTween("d",function(w){return O(w,"exit")}).remove()).on("mouseover",function(C,w){L(w.data.label)}).on("mouseout",()=>{L("")});const d=C=>Z.length===1?"translate(0, 0)":`translate(${ct.centroid(C)})`,_=C=>{const w=C.value/P;return Rt(".1%")(w)};y.selectAll("text").data(I,function(C){return C.data.label}).join(C=>{const w=C.append("text").text(_).attr("class",ie.pieLabelEnter);return w.merge(w).transition().duration(x).delay(x).attr("transform",d),w},C=>{const w=C.text(_);return C.merge(w).attr("class",ie.pieLabelUpdate).transition().duration(v!==""?250:x).style("opacity",function(Q){const rt=v===Q.data.label;return v===""||rt?1:0}).attr("transform",d),w},C=>C.transition().duration(x/2).attr("class",ie.pieLabelExit).remove())},[t,r,e,u,f,W,v]),N=o>s;return $.jsxs("div",{ref:a,style:{width:o,height:s,position:"relative",display:"flex",flexDirection:N?"row":"column",overflow:"hidden"},children:[$.jsx("div",{ref:c,style:{flex:1,position:"relative",display:"flex"},children:$.jsx("svg",{ref:j,className:`${st["chart-svg"]} ${st["fill-container"]}`,viewBox:`0 0 ${u} ${f}`,children:$.jsx("g",{className:"plot-area"})})}),$.jsx("div",{style:{width:N?o>480?"180px":"100px":"100%",height:N?"100%":s>400?"180px":"100px",flexShrink:0,overflowY:"auto",background:"rgba(255, 255, 255)",borderLeft:N?"1px solid #ddd":"none",borderTop:N?"none":"1px solid #ddd",padding:"0px"},children:$.jsx("div",{ref:M,className:"legends-content",style:{display:"flex",flexDirection:"column",gap:"6px",padding:"8px 8px 16px 8px",boxSizing:"border-box",position:"relative"}})}),$.jsxs("label",{className:st["controls-label"],style:{position:"absolute",left:"12px",top:"6px"},children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:W,onChange:z=>b(z.target.checked)}),"Sort"]})]})}const yt={"legends-container":"_legends-container_aemvq_1","legend-container":"_legend-container_aemvq_61","legend-container-active":"_legend-container-active_aemvq_61","legend-container-inactive":"_legend-container-inactive_aemvq_61","legend-container-sm":"_legend-container-sm_aemvq_63","legend-container-active-sm":"_legend-container-active-sm_aemvq_63","legend-container-inactive-sm":"_legend-container-inactive-sm_aemvq_63","legend-rect":"_legend-rect_aemvq_125","legend-label":"_legend-label_aemvq_159",rect:"_rect_aemvq_277",rectCard:"_rectCard_aemvq_277",rectLegendNotHovered:"_rectLegendNotHovered_aemvq_297",legend:"_legend_aemvq_1",rectHoveredLegend:"_rectHoveredLegend_aemvq_333",rectCardLegendHovered:"_rectCardLegendHovered_aemvq_343",rectLegendHovered:"_rectLegendHovered_aemvq_355",rotatedAxisText:"_rotatedAxisText_aemvq_377",axisText:"_axisText_aemvq_387",hoveredAxisText:"_hoveredAxisText_aemvq_397",yAxisLabel:"_yAxisLabel_aemvq_411","value-axis":"_value-axis_aemvq_421"};function Yd({data:t,focusOnPlot:e=!1,colorIdx:n=0,orientation:r="vertical",tooltipFormat:a}){const[i,o]=ge(),{width:s,height:c}=o,[l,u]=xe(),{height:f}=u,[h,p]=xe(),{width:k,height:W}=p,[b,v]=ut.useState(null),[L,x]=ut.useState(!1),[M,j]=ut.useState(["all"]),[N,z]=ut.useState(!1),[Y,B]=ut.useState(""),[Z,A]=ut.useState(!1),X=dr(),S=t;ut.useEffect(()=>{j(["all"]),x(!0)},[S]),ut.useEffect(()=>{j(["all"])},[e]);const P=750;ut.useEffect(()=>{let K;return L&&(K=setTimeout(()=>{x(!1)},P+500)),()=>{clearTimeout(K)}},[L]);const y=[k,W,M,n,e],D=Ot(S),T=D.length===0?[]:Object.keys(D[0]).filter(K=>K!=="label"&&K!=="total"),I=qe(T),m=k>576,E=Kt(K=>{if(L)return;const J=m?80:50,ct=function(O){const tt=yt[m?"legend-container":"legend-container-sm"],d=yt[m?"legend-container-active":"legend-container-active-sm"],_=yt[m?"legend-container-inactive":"legend-container-inactive-sm"];return`
27
- ${M.includes(O)?e?d:_:tt}
6
+ <%s key={someKey} {...props} />`,gt,st,B,st),q[st+gt]=!0)}if(st=null,wt!==void 0&&(n(wt),st=""+wt),s(pt)&&(n(pt.key),st=""+pt.key),"key"in pt){wt={};for(var Q in pt)Q!=="key"&&(wt[Q]=pt[Q])}else wt=pt;return st&&o(wt,typeof $=="function"?$.displayName||$.name||"Unknown":$),c($,st,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,H={},W=g.react_stack_bottom_frame.bind(g,i)(),V=Y(r(i)),q={};Mr.Fragment=d,Mr.jsx=function($,pt,wt){var gt=1e4>N.recentlyCreatedOwnerStacks++;if(gt){var _t=Error.stackTraceLimit;Error.stackTraceLimit=10;var G=Error("react-stack-top-frame");Error.stackTraceLimit=_t}else G=W;return u($,pt,wt,!1,G,gt?Y(r($)):V)},Mr.jsxs=function($,pt,wt){var gt=1e4>N.recentlyCreatedOwnerStacks++;if(gt){var _t=Error.stackTraceLimit;Error.stackTraceLimit=10;var G=Error("react-stack-top-frame");Error.stackTraceLimit=_t}else G=W;return u($,pt,wt,!0,G,gt?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 Zt(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 Zt(t);var r,a=(r-1)*e,i=Math.floor(a),s=Zt(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 Ve(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 Ve(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 Ve(r,this._parents)}function _o(t){return new Array(t.length)}function Ef(){return new Ve(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 Ve(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 Ve(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 Ve(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 Ve(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 Ve(t,e){this._groups=t,this._parents=e}function Lr(){return new Ve([[document.documentElement]],Do)}function Gh(){return this}Ve.prototype=Lr.prototype={constructor:Ve,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 te(t){return typeof t=="string"?new Ve([[document.querySelector(t)]],[document.documentElement]):new Ve([[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=te(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=te(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&&(te(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){te(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,H){var W=z,V;switch(Y){case"start":a[_]=M,V=s++;break;case"end":delete a[_],--s;case"drag":z=tr(H||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]-W[0],dy:z[1]-W[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,Xe,{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 Xe(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=Xe(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=Xe(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=Xe(e))?(e=r,Ca):nl:e instanceof Xe?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 Xe?Ca:(n=Xe(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;te(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=te(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=te(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,H=k[1][1],W,V,q=0,$=0,pt,wt=y&&T&&a&&d.shiftKey,gt,_t,G=Array.from(d.touches||[d],ot=>{const at=ot.identifier;return ot=tr(ot,x),ot.point0=ot.slice(),ot.identifier=at,ot});Ji(x);var st=u(x,arguments,!0).beforestart();if(S==="overlay"){_&&(pt=!0);const ot=[G[0],G[1]||G[0]];p.selection=_=[[R=t===ns?E:Ce(ot[0][0],ot[1][0]),N=t===Ha?I:Ce(ot[0][1],ot[1][1])],[Y=t===ns?M:$e(ot[0][0],ot[1][0]),W=t===Ha?H:$e(ot[0][1],ot[1][1])]],G.length>1&&tt(d)}else R=_[0][0],N=_[0][1],Y=_[1][0],W=_[1][1];z=R,U=N,C=Y,V=W;var B=te(x).attr("pointer-events","none"),Q=B.selectAll(".overlay").attr("cursor",vn[S]);if(d.touches)st.moved=D,st.ended=L;else{var X=te(d.view).on("mousemove.brush",D,!0).on("mouseup.brush",L,!0);a&&X.on("keydown.brush",Z,!0).on("keyup.brush",ht,!0),$o(d.view)}c.call(x),st.start(d,w.name);function D(ot){for(const at of ot.changedTouches||[ot])for(const A of G)A.identifier===at.identifier&&(A.cur=tr(at,x));if(wt&&!gt&&!_t&&G.length===1){const at=G[0];bl(at.cur[0]-at[0])>bl(at.cur[1]-at[1])?_t=!0:gt=!0}for(const at of G)at.cur&&(at[0]=at.cur[0],at[1]=at.cur[1]);pt=!0,ts(ot),tt(ot)}function tt(ot){const at=G[0],A=at.point0;var j;switch(q=at[0]-A[0],$=at[1]-A[1],w){case es:case vl:{y&&(q=$e(E-R,Ce(M-Y,q)),z=R+q,C=Y+q),T&&($=$e(I-N,Ce(H-W,$)),U=N+$,V=W+$);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(H,G[0][1])),V=$e(I,Ce(H,G[1][1])),T=1)):(y<0?(q=$e(E-R,Ce(M-R,q)),z=R+q,C=Y):y>0&&(q=$e(E-Y,Ce(M-Y,q)),z=R,C=Y+q),T<0?($=$e(I-N,Ce(H-N,$)),U=N+$,V=W):T>0&&($=$e(I-W,Ce(H-W,$)),U=N,V=W+$));break}case lr:{y&&(z=$e(E,Ce(M,R-q*y)),C=$e(E,Ce(M,Y+q*y))),T&&(U=$e(I,Ce(H,N-$*T)),V=$e(I,Ce(H,W+$*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=W,W=j,j=U,U=V,V=j,S in Al&&Q.attr("cursor",vn[S=Al[S]])),p.selection&&(_=p.selection),gt&&(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),st.brush(ot,w.name))}function L(ot){if(Vp(ot),ot.touches){if(ot.touches.length)return;o&&clearTimeout(o),o=setTimeout(function(){o=null},500)}else Co(ot.view,pt),X.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);B.attr("pointer-events","all"),Q.attr("cursor",vn.overlay),p.selection&&(_=p.selection),Qp(_)&&(p.selection=null,c.call(x)),st.end(ot,w.name)}function Z(ot){switch(ot.keyCode){case 16:{wt=y&&T;break}case 18:{w===or&&(y&&(Y=C-q*y,R=z+q*y),T&&(W=V-$*T,N=U+$*T),w=lr,tt(ot));break}case 32:{(w===or||w===lr)&&(y<0?Y=C-q:y>0&&(R=z-q),T<0?W=V-$:T>0&&(N=U-$),w=es,Q.attr("cursor",vn.selection),tt(ot));break}default:return}ts(ot)}function ht(ot){switch(ot.keyCode){case 16:{wt&&(gt=_t=wt=!1,tt(ot));break}case 18:{w===lr&&(y<0?Y=C:y>0&&(R=z),T<0?W=V:T>0&&(N=U),w=or,tt(ot));break}case 32:{w===es&&(ot.altKey?(y&&(Y=C-q*y,R=z+q*y),T&&(W=V-$*T,N=U+$*T),w=lr):(y<0?Y=C:y>0&&(R=z),T<0?W=V:T>0&&(N=U),w=or),Q.attr("cursor",vn[S]),tt(ot));break}default:return}ts(ot)}}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 H=I<0||1/I<0;if(I=isNaN(I)?l:E(Math.abs(I),y),T&&(I=Y0(I)),H&&+I==0&&b!=="+"&&(H=!1),N=(H?b==="("?b:o:b==="-"||b==="("?"":b)+N,U=(p==="s"&&!isNaN(I)&&Ua!==void 0?Ol[8+Ua/3]:"")+U+(H&&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 W=N.length+I.length+U.length,V=W<S?new Array(S-W+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,W=V.length>>1)+N+I+U+V.slice(W);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 Oe(){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 Oe(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:H,b:W,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:q,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:pt,A:wt,b:gt,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:st,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(B,Q){return function(X){var D=[],tt=-1,L=0,Z=B.length,ht,ot,at;for(X instanceof Date||(X=new Date(+X));++tt<Z;)B.charCodeAt(tt)===37&&(D.push(B.slice(L,tt)),(ot=uc[ht=B.charAt(++tt)])!=null?ht=B.charAt(++tt):ot=ht==="e"?" ":"0",(at=Q[ht])&&(ht=at(X,ot)),D.push(ht),L=tt+1);return D.push(B.slice(L,tt)),D.join("")}}function k(B,Q){return function(X){var D=Kr(1900,void 0,1),tt=_(D,B,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 _(B,Q,X,D){for(var tt=0,L=Q.length,Z=X.length,ht,ot;tt<L;){if(D>=Z)return-1;if(ht=Q.charCodeAt(tt++),ht===37){if(ht=Q.charAt(tt++),ot=T[ht in uc?Q.charAt(tt++):ht],!ot||(D=ot(B,X,D))<0)return-1}else if(ht!=X.charCodeAt(D++))return-1}return D}function E(B,Q,X){var D=c.exec(Q.slice(X));return D?(B.p=u.get(D[0].toLowerCase()),X+D[0].length):-1}function R(B,Q,X){var D=g.exec(Q.slice(X));return D?(B.w=v.get(D[0].toLowerCase()),X+D[0].length):-1}function z(B,Q,X){var D=h.exec(Q.slice(X));return D?(B.w=f.get(D[0].toLowerCase()),X+D[0].length):-1}function I(B,Q,X){var D=x.exec(Q.slice(X));return D?(B.m=S.get(D[0].toLowerCase()),X+D[0].length):-1}function N(B,Q,X){var D=b.exec(Q.slice(X));return D?(B.m=d.get(D[0].toLowerCase()),X+D[0].length):-1}function U(B,Q,X){return _(B,e,Q,X)}function M(B,Q,X){return _(B,n,Q,X)}function Y(B,Q,X){return _(B,r,Q,X)}function C(B){return s[B.getDay()]}function H(B){return i[B.getDay()]}function W(B){return l[B.getMonth()]}function V(B){return o[B.getMonth()]}function q(B){return a[+(B.getHours()>=12)]}function $(B){return 1+~~(B.getMonth()/3)}function pt(B){return s[B.getUTCDay()]}function wt(B){return i[B.getUTCDay()]}function gt(B){return l[B.getUTCMonth()]}function _t(B){return o[B.getUTCMonth()]}function G(B){return a[+(B.getUTCHours()>=12)]}function st(B){return 1+~~(B.getUTCMonth()/3)}return{format:function(B){var Q=p(B+="",w);return Q.toString=function(){return B},Q},parse:function(B){var Q=k(B+="",!1);return Q.toString=function(){return B},Q},utcFormat:function(B){var Q=p(B+="",y);return Q.toString=function(){return B},Q},utcParse:function(B){var Q=k(B+="",!0);return Q.toString=function(){return B},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),H=g*un(S),W=f*On(T),V=f*un(T);if(R>je){var q=g*On(w),$=g*un(w),pt=f*On(y),wt=f*un(y),gt;if(d<ta)if(gt=yx(C,H,pt,wt,q,$,W,V)){var _t=C-gt[0],G=H-gt[1],st=q-gt[0],B=$-gt[1],Q=1/un(ux((_t*st+G*B)/(xr(_t*_t+G*G)*xr(st*st+B*B)))/2),X=xr(gt[0]*gt[0]+gt[1]*gt[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(pt,wt,C,H,g,I,x),U=ii(q,$,W,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,H),o.arc(0,0,g,S,w,!x)):o.moveTo(C,H),!(f>je)||!(p>je)?o.lineTo(W,V):z>je?(N=ii(W,V,q,$,f,-z,x),U=ii(C,H,pt,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(te(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 Be={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:`${Be.tooltip}`,style:{opacity:0},children:[e,!t&&!e&&m.jsx("p",{className:`top-label ${Be["text-small"]}`}),t===2&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:`top-label ${Be["text-small"]}`}),m.jsx("p",{className:`bottom-label ${Be["text-small"]}`})]}),(t===3||t===4)&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:`title ${Be.title}`}),m.jsx("p",{className:`top-label ${Be["right-label"]}`}),m.jsx("p",{className:`bottom-label ${Be["right-label"]}`})]}),t===4&&m.jsx("p",{className:`small-text ${Be["right-label"]} ${Be["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"?Be["tooltip--arrow-down"]:Be["tooltip--arrow-up"];t.attr("class",`${Be.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",`${Be.tooltip} ${Be["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((B,Q)=>Q.value-B.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=Oe().domain(E.map(B=>String(B.label))).rangeRound(r==="vertical"?[0,M]:[Y,0]).paddingInner(S?.4:.25).paddingOuter(.1),H=oe(E,B=>B.value)??0,W=Math.min(0,H),V=Zt(E,B=>B.value)??0,q=Math.max(0,V),$=ye().domain([W,q]).rangeRound(r==="vertical"?[Y,0]:[0,M]).nice(),pt=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(pt).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 gt=B=>{const{idx:Q,type:X}=y,D=d.current.findIndex(tt=>tt===String(B.label));return vr(X==="fixed"?Q:Q+D)},_t=B=>r==="vertical"?B>=0?$(B):$(0):B>=0?$(0):$(B),G=B=>{const Q=Math.abs($(B)-$(0));return isNaN(Q)||Q<0?0:Q},st={prefix:a,suffix:i,formatType:s};I.selectAll(".bar").data(E,B=>String(B.label)).join(B=>B.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",gt).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,B=>B.transition().duration(T).attr("fill",Ee).attr("height",0).attr("y",g).style("opacity",0).remove()).on("pointerenter",(B,Q)=>{N.style("opacity",1),N.select("p.label span.chev").style("background",gt(Q)),N.select("p.label span.value").text(String(Q.label)+""),N.select("p.value").text(_e(Q.value,st)),le(N,{e:B,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",(B,Q)=>{le(N,{e:B,svg:z,yScale:$})}).on("pointerleave",(B,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",gt).attr("x",function(B){return r==="vertical"?C(String(B.label))??0:_t(B.value)}).attr("width",function(B){return r==="vertical"?C.bandwidth():G(B.value)}).attr("y",function(B){return r==="vertical"?_t(B.value):C(String(B.label))??0}).attr("height",function(B){return r==="vertical"?G(B.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=Zt(t,function(A){return Zt(A.datum,function(j){return U?new Date(j[n]):typeof j[n]=="number"?j[n]:Number(j[n])})}),C=[M,Y],H=U?ti().domain(C):ye().domain(C);H.range([0,T]);const W=di(T,U?[M,Y]:[]),V=U?v?an.axisText:an.rotatedAxisText:W,{prefix:q,suffix:$}=s;E.select(".x-axis").attr("transform","translate(0,"+k+")").transition().duration(h).call(he(H)).selectAll("text").attr("class",V);const pt=oe(t,A=>oe(A.datum,function(j){const nt=j[r];return typeof nt=="number"?nt:void 0}))??0,wt=Zt(t,A=>Zt(A.datum,function(j){const nt=j[r];return typeof nt=="number"?nt:void 0}))??0,gt=ye().domain([pt,wt]).rangeRound([k,0]).nice(),_t=be(gt).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=>H(U?new Date(A[n]):A[n])).y(A=>gt(Number(A[r]))),st=A=>{const j=d.current.findIndex(nt=>nt===t[A].title)+i;return de(j,!1,!0)},B=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=>H(U?new Date(A[n]):A[n])).y0(k).y1(A=>gt(Number(A[r])));e==="area"&&(t.map(j=>j.title).forEach((j,nt)=>{const Nt=Rs(j),O=z.append("linearGradient").attr("id",Nt).attr("x1","0%").attr("y1","0%").attr("x2","0%").attr("y2","100%"),K=de(nt,!1,!0);O.append("stop").attr("offset","0%").attr("stop-color",K).attr("stop-opacity",.7),O.append("stop").attr("offset","100%").attr("stop-color",K).attr("stop-opacity",0)}),B.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=te(this.parentNode).datum(),{title:Nt}=nt;return`url(#${Rs(Nt)})`}).attr("d",nt=>G(nt)).attr("clip-path","url(#clip)").style("pointer-events","none"),void 0,j=>j.remove()).attr("d",j=>Q(j))),B.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=te(this.parentNode).datum(),nt=d.current.findIndex(Nt=>Nt===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=B.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=te(this.parentNode).datum(),nt=d.current.findIndex(Nt=>Nt===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=te(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,H.invert(tr(A)[0])),Nt=t[0].datum[nt],O=oe(t,function(ut){return Number(ut.datum[nt][r])}),K=[];for(let ut=0;ut<t.length;ut++){const{title:vt}=t[ut],kt=t[ut].datum[nt],jt=String(kt[n]),Xt=Number(kt[r]);D.filter(function(){return te(this.parentNode).datum().title===vt}).attr("cx",H(U?new Date(kt[n]):kt[n])).attr("cy",gt(Xt)).style("opacity",1),K.push({title:vt,label:jt,value:Xt})}const $t=H(U?new Date(t[0].datum[nt][n]):t[0].datum[nt][n]);R.style("opacity",1).attr("x1",$t).attr("x2",$t),ht(K);const zt=5,et=H(U?new Date(Nt[n]):Nt[n]),Tt=gt(O??0)+X+zt;tt.transition().duration(100).style("display",null).attr("transform",`translate(${et},${Tt})`)}function Z(A){tt.transition().duration(250).style("display","none"),D.style("opacity",0),R.style("opacity",0),a&&at.transition().duration(h/4).style("opacity",1)}function ht(A){const j=tt.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),nt=A.reduce((O,K)=>{const $t=K.title,zt=K.label+": "+(q??"")+K.value+($??"");return O.push($t),O.push(zt),O},[]),Nt=tt.selectAll("text").data([null]).join("text").call(O=>O.selectAll("tspan").data(nt).join("tspan").attr("x",0).attr("y",(K,$t)=>`${$t*1.1}em`).style("align","right").text(K=>K));ot(Nt,j),a&&at.transition().duration(h/4).style("opacity",0)}function ot(A,j){const{x:nt,y:Nt,width:O,height:K}=A.node().getBBox();A.attr("transform",`translate(${-O/2},${15-Nt})`),j.attr("d",`M${-O/2-10},5H-5l5,-5l5,5H${O/2+10}v${K+20}h-${O+20}z`)}const at=_.select(".brush-area").attr("transform","translate("+g.left+","+(k+g.top+g.bottom)+")");if(at.selectAll("path.line").remove(),at.selectAll("path.area").remove(),at.selectAll("g.brush").remove(),a){let A=function($t){const zt=$t.selection;if(zt)H.domain([j.invert(zt[0]),j.invert(zt[1])]);else if(!zt||zt===null){const et=C;H.domain(et)}K()};const j=U?ti().domain(C):ye().domain(C);j.range([0,T]);const nt=ye().domain([pt,wt]).range([w,0]),Nt=Bn().x($t=>H(U?new Date($t[n]):$t[n])).y($t=>nt(Number($t[r])));for(let $t=0;$t<t.length;$t++){if(e==="area"){const zt=js().x(et=>H(U?new Date(et[n]):et[n])).y0(w).y1(et=>nt(Number(et[r])));at.append("path").datum(t[$t].datum).attr("class","area").attr("fill",function(){const et=t[$t].title;return`url(#${Rs(et)})`}).attr("stroke","none").attr("d",zt).attr("clip-path","url(#clip)")}at.append("path").datum(t[$t].datum).attr("class","line").attr("fill","none").attr("stroke",st($t)).attr("stroke-width",2).attr("d",Nt).attr("clip-path","url(#clip)")}at.select(".x-axis").attr("transform","translate(0,"+w+")").call(he(j)).selectAll("text").attr("class",V);const O=Sl().extent([[0,0],[c,w]]).on("brush",A);at.append("g").attr("class","brush").call(O),_.on("dblclick",function(){H.domain(C),at.select(".brush").call(O.move,null),K()});const K=()=>{E.select(".x-axis").call(he(H)).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),H=Y(C),W=we(C);v(Y(W));let V=W.length>C.length;const q=g.map(X=>X.data.label),$=H.map(X=>X.data.label);q.every(X=>V?!1:$.includes(X)?!0:(V=!0,!1));const pt=g.length===0,gt=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)||"":gt(X)||""}};M.selectAll("path").data(H,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(pt?0:w).attr("d",gt).attrTween("d",function(tt){if(!pt)return G(tt,"not exit");const L=Ae(0,tt.startAngle),Z=Ae(0,tt.endAngle),ht=tt.data.label===x;return function(ot){return tt.startAngle=L(ot),tt.endAngle=Z(ot),ht?_t(tt):gt(tt)}}),D},X=>{const D=X;return X.transition().duration(w).attr("fill",function(tt,L){const Z=f.current.findIndex(ht=>ht===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,ht=Ae(Z,tt.startAngle),ot=L&&L.endAngle?L.endAngle:0,at=Ae(ot,tt.endAngle),A=tt.data.label===x;return function(j){return tt.startAngle=ht(j),tt.endAngle=at(j),A?_t(tt)||"":gt(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 B=X=>R.length===1?"translate(0, 0)":`translate(${gt.centroid(X)})`,Q=X=>{const D=X.value/U;return pe(".1%")(D)};M.selectAll("text").data(H,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",B),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",B),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}})]})]}),Ft={"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),H=d>576,W=Se(V=>{if(d===0||x===0)return;const q={top:20,right:30,bottom:30,left:30},$=M.length===0?[]:Object.keys(M[0]).filter(F=>F!=="label"&&F!=="total"),pt=e?$:$.filter(F=>!p.includes(F));M.forEach((F,yt)=>{const At=pt.reduce((Pt,ee)=>{ee in F||(F[ee]=0);const re=F[ee],lt=typeof re=="number"?re:0,xt=Pt.total+lt,St=Pt.totalPos+(lt>=0?lt:0),Wt=Pt.totalMin+(lt<0?lt:0);return{total:xt,totalPos:St,totalMin:Wt}},{total:0,totalPos:0,totalMin:0});F.total=At.total,F.totalPos=At.totalPos,F.totalMin=At.totalMin});const wt=M,gt=R?we(wt).sort(function(F,yt){return e?p[0]==="all"?F.total-yt.total:Number(F[p[0]])-Number(yt[p[0]]):F.total-yt.total}):wt,_t=d-q.left-q.right,G=x-q.top-q.bottom,st=V.select("svg"),B=st.node(),Q=st.select(".plot-area").attr("transform","translate("+q.left+","+q.top+")"),D=V.select(".controls").select(".legends-container"),tt=H?80:50,L=function(F){const yt=Ft[H?"legend-container":"legend-container-sm"],At=Ft[H?"legend-container-active":"legend-container-active-sm"],Pt=Ft[H?"legend-container-inactive":"legend-container-inactive-sm"];return`
8
+ ${p.includes(F)?e?At:Pt:yt}
28
9
  legend-item
29
- `};K.selectAll(".legend-item").data([...T],O=>O).join(O=>{const tt=O.append("div").attr("class",ct).style("left",(d,_)=>`${_*J}px`).style("top","-53px").style("opacity",0);return tt.append("div").attr("class",yt["legend-rect"]).style("background",d=>{if(!e&&M.includes(d))return me;const _=I.current.findIndex(C=>C===d)+n;return Ft(_)}),tt.append("span").attr("class",yt["legend-label"]).style("color",d=>!e&&M.includes(d)?"#d1d5db":"#333").text(d=>d),tt.transition().duration(P).style("top","0px").style("opacity",1),tt},O=>(O.attr("class",ct).transition().duration(P).style("top","0px").style("left",(tt,d)=>`${d*J}px`).style("opacity",1).select(`.${yt["legend-rect"]}`).style("background",tt=>{if(!e&&M.includes(tt))return me;const d=I.current.findIndex(_=>_===tt)+n;return Ft(d)}),O.select(`.${yt["legend-label"]}`).style("color",tt=>!e&&M.includes(tt)?me:"#333").text(tt=>tt),O),O=>O.style("color",me).transition().duration(P).style("opacity",0).style("top","53px").remove()).on("mouseover",function(O,tt){L||B(tt)}).on("mouseout",function(O,tt){L||(B(""),N&&z(!1))}).on("click",(O,tt)=>{j(d=>{let _=[];return e?d[0]===tt?_=["all"]:_=[tt]:d.includes(tt)?_=d.filter(C=>C!==tt):_=[...d,tt],_}),z(!0)})},[...y,T,L]),g=$.jsxs("div",{ref:l,className:`${st[m?"controls-container":"controls-container-sm"]} ${X?st["fill-container"]:""}`,children:[$.jsxs("label",{className:st["controls-label"],style:{paddingRight:"12px"},children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:Z,onChange:K=>A(K.target.checked)}),"Sort"]}),$.jsx("div",{ref:E,id:"stacked-barchart-legends",className:`${yt["legends-container"]}`})]}),H=Kt(K=>{if(k===0||W===0||Y!==""&&L)return;const J={top:20,right:20,bottom:30,left:40},ct=e?T:T.filter(U=>!M.includes(U));D.forEach((U,ht)=>{const dt=ct.reduce((Lt,Yt)=>{Yt in U||(U[Yt]=0);const _e=U[Yt];return Lt+(typeof _e=="number"?_e:0)},0);U.total=dt});const it=D,O=Z?Ot(it).sort(function(U,ht){return e?M[0]==="all"?U.total-ht.total:Number(U[M[0]])-Number(ht[M[0]]):U.total-ht.total}):it,tt=k-J.left-J.right,d=W-J.top-J.bottom,_=K.select("svg"),C=_.node(),w=_.select(".plot-area").attr("transform","translate("+J.left+","+J.top+")"),Q=Ke(K).style("opacity",0);let rt=!1;b===null&&(rt=!0,v(Ot(D)));const ft=O.map(function(U){return U.label}),xt=ye().domain(ft).rangeRound(r==="vertical"?[0,tt]:[d,0]).paddingInner(m?.4:.25).paddingOuter(.2).align(.2),et=e?M[0]==="all"?Dt(D,U=>U.total):Dt(D,U=>U[M[0]]):Dt(D,U=>U.total),V=Gt().domain([0,et??0]).range(r==="vertical"?[d,0]:[0,tt]),at=!m&&r==="vertical"?yt.rotatedAxisText:yt.axisText,R=[],lt=r==="vertical"?Ut(xt).tickValues(xt.domain()).tickSizeOuter(0):Ut(V).ticks(4,"s").tickSizeOuter(0).tickSize(-d);w.select(".x-axis").attr("transform",`translate(0,${d})`).transition().duration(P).call(lt).selectAll("text").style("cursor","pointer").attr("dy",m?"1em":".20em").attr("dx",m?"0em":"-.8em").attr("class",at).selectAll(".tick").filter(U=>U===0).select("line").remove();const nt=r==="vertical"?te(V).ticks(4,"s").tickSize(-tt):te(xt).tickSizeOuter(0);w.select(".y-axis").attr("transform","translate(0,0)").transition().duration(rt?0:P).call(nt).selectAll(".tick").filter(U=>U===0).select("line").remove();const q=bn().keys(ct)(O).map(U=>{const ht=U.key,dt=U.map(Lt=>{const Yt=Lt.data.label;return{...Lt,key:`${ht} - ${Yt}`,barKey:ht}});return dt.key=ht,dt}),pt=w.selectAll(".serie").data(q,U=>U.key).join(U=>U.append("g").attr("class","serie").attr("fill",dt=>{const Lt=I.current.findIndex(_e=>_e===dt.key)+n;return Ft(Lt)}).style("opacity",dt=>{if(Y!=="")if(e){if(M[0]==="all")return dt.key===Y||N?1:.25}else return N?1:dt.key===Y?.25:1;return e?M[0]==="all"||dt.key===M[0]?1:0:1}).style("pointer-events",dt=>e?M[0]==="all"||dt.key===M[0]?"auto":"none":"auto"),U=>U.transition().duration(P).attr("fill",dt=>{const Lt=I.current.findIndex(_e=>_e===dt.key)+n;return Ft(Lt)}).style("opacity",dt=>{if(Y!=="")if(e){if(M[0]==="all")return dt.key===Y||N?1:.25}else return N?1:dt.key===Y?.25:1;return e?M[0]==="all"||dt.key===M[0]?1:0:1}).style("pointer-events",dt=>e?M[0]==="all"||dt.key===M[0]?"auto":"none":"auto"),U=>U.transition().duration(P).attr("fill",me).style("opacity",0).selectAll("rect").attr("y",d).attr("height",0).remove()),vt=U=>xt(U.data.label+"")??0,bt=xt.bandwidth(),St=U=>{const ht=r==="vertical"?d:tt;return rt?0:M[0]==="all"?V(r==="vertical"?U[1]:U[0]):e&&r!=="vertical"?V(0):ht-(V(U[0])-V(U[1]))},Tt=U=>{const ht=r==="vertical"?V(U[0])-V(U[1]):V(U[1])-V(U[0]);return isNaN(ht)||ht<0?0:ht},Mt=U=>r==="vertical"?vt(U):St(U),Ct=U=>r==="vertical"?bt:Tt(U),ot=U=>r==="vertical"?St(U):vt(U),gt=U=>r==="vertical"?Tt(U):bt,_t=U=>{if(U.barKey===Y)return"none";const ht=Ct(U),dt=gt(U);return ct.indexOf(U.barKey)===ct.length-1||U.barKey===M[0]?r==="vertical"?`${ht+dt} ${ht} ${dt}`:`${ht+dt+ht}`:r==="vertical"?`${dt} ${ht}`:`${ht} ${dt}`},G=U=>{const ht=Ct(U),dt=ct.indexOf(U.barKey)===ct.length-1||U.barKey===M[0];return r==="vertical"?dt?0:ht*-1:0},mt=U=>Y!==""&&Y===U.barKey&&e?`rect ${yt.rectLegendHovered}`:`rect ${yt.rect}`;pt.selectAll("rect").data(U=>U,U=>U.data.label).join(U=>U.append("rect").attr("class",`rect ${st.rect}`).attr("x",function(dt){return r==="vertical"?Mt(dt):V(0)}).attr("width",function(dt){return r==="vertical"?Ct(dt):0}).attr("y",dt=>{if(r==="vertical"){if(!R.includes(dt.data.label))return d;const Lt=M[0]==="all"?V(dt[1]):dt.key.startsWith(M[0])?d-(V(dt[0])-V(dt[1])):V(dt[1]),Yt=V(dt[0])-V(dt[1]),_e=isNaN(Yt)||Yt<0?0:Yt,D0=Lt+_e;return rt?d-(J.bottom+J.top):D0}else return ot(dt)}).attr("height",function(dt){return r==="vertical"?0:gt(dt)}).attr("stroke-dasharray",_t).attr("stroke-dashoffset",G).transition().duration(P).attr("x",Mt).attr("width",Ct).attr("height",gt).attr("y",ot),void 0,U=>U.transition().duration(P).attr("opacity",0).attr("y",d).attr("height",0).remove()).attr("class",mt).attr("stroke-dasharray",_t).attr("stroke-dashoffset",G).transition().duration(P).attr("x",Mt).attr("width",Ct).attr("height",gt).attr("y",ot).on("start",function(){}).on("end",function(){}),pt.selectAll("rect").on("mouseover",function(U,ht){At(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(Yt=>Yt===ht.data.label).attr("class",(r==="vertical"?at:"")+" "+yt.hoveredAxisText),Q.style("opacity",1).select("p.title").text(ht.data.label);const dt=ht.data[ht.barKey],{total:Lt}=ht.data;Q.select("p.top-label").text(ht.barKey+" : "+Et(dt,a)),Q.select("p.bottom-label").text(M[0]==="all"?`Total : ${Et(Lt,a)}`:"~")}).on("touch",function(U,ht){At(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(dt=>dt===ht.data.label)}).on("mousemove",(U,ht)=>{pr(Q,{e:U,svg:C,yScale:V})}).on("mouseout",function(U,ht){At(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(dt=>dt===ht.data.label).attr("class",r==="vertical"?at:""),Q.style("opacity",0)})},[...y,Z,D,T,Y,N,L,r,a]);return $.jsxs("div",{ref:i,style:{width:`${s}px`,height:`${c}px`,display:"flex",flexDirection:"column"},children:[X?kn.createPortal(g,X):g,$.jsx("div",{ref:h,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:$.jsxs("div",{ref:H,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[$.jsx("svg",{className:`${st["chart-svg"]} ${st["fill-container"]}`,viewBox:`0 0 ${k} ${W}`,children:k>0&&$.jsxs("g",{className:"plot-area",children:[$.jsx("g",{className:"plot-rects"}),$.jsx("g",{className:`${r==="vertical"?yt["value-axis"]:""} y-axis`}),$.jsx("g",{className:`${r==="horizontal"?yt["value-axis"]:""} x-axis`})]})}),$.jsx(Xe,{pCount:3})]})})]})}function Wd({data:t,colorIdx:e=0,orientation:n="vertical",tooltipFormat:r}){const[a,i]=ge(),{width:o,height:s}=i,[c,l]=xe(),{height:u}=l,[f,h]=xe(),{width:p,height:k}=h,[W,b]=ut.useState(null),[v,L]=ut.useState(!1),[x,M]=ut.useState("all"),[j,N]=ut.useState(!1),[z,Y]=ut.useState(""),[B,Z]=ut.useState(!1),A=dr(),X=t;ut.useEffect(()=>{M("all"),L(!0),Z(!1)},[X]);const S=750;ut.useEffect(()=>{let H;return v&&(H=setTimeout(()=>{L(!1)},S+500)),()=>{clearTimeout(H)}},[v]);const P=[p,k,x,e],y=Ot(X),D=y.length===0?[]:Object.keys(y[0]).filter(H=>H!=="label"&&H!=="total"),T=qe(D),I=p>576,m=Kt(H=>{if(v)return;const K=I?80:50,J=function(it){const O=yt[I?"legend-container":"legend-container-sm"],tt=yt[I?"legend-container-active":"legend-container-active-sm"],d=yt[I?"legend-container-inactive":"legend-container-inactive-sm"];return`
30
- ${x.includes(it)?x===it?tt:d:O}
10
+ `},Z=F=>{const yt=C.current.findIndex(Pt=>Pt===F)+n;return de(yt)};function ht(F){return Z(F.key)}D.selectAll(".legend-item").data([...$],F=>F).join(F=>{const yt=F.append("div").attr("class",L).style("left",(At,Pt)=>`${Pt*tt}px`).style("top","-53px").style("opacity",0);return yt.append("div").attr("class",Ft["legend-rect"]).style("background",At=>{if(!e&&p.includes(At))return Ee;const Pt=C.current.findIndex(ee=>ee===At)+n;return de(Pt)}),yt.append("span").attr("class",Ft["legend-label"]).style("color",At=>!e&&p.includes(At)?"#d1d5db":"#333").text(At=>At),yt.transition().duration(N).style("top","0px").style("opacity",1),yt},F=>(F.attr("class",L).transition().duration(N).style("top","0px").style("left",(yt,At)=>`${At*tt}px`).style("opacity",1).select(`.${Ft["legend-rect"]}`).style("background",yt=>{if(!e&&p.includes(yt))return Ee;const At=C.current.findIndex(Pt=>Pt===yt)+n;return de(At)}),F.select(`.${Ft["legend-label"]}`).style("color",yt=>!e&&p.includes(yt)?Ee:"#333").text(yt=>yt),F),F=>F.style("color",Ee).transition().duration(N).style("opacity",0).style("top","53px").remove()).on("pointerenter",function(F,yt){if(p[0]==="all"){const At=Q.selectAll(".serie");e?(At.attr("fill",ht).filter(Pt=>Pt.key!==yt).style("opacity",.25),At.selectAll("rect").filter(Pt=>Pt.barKey===yt).attr("stroke-dasharray","none")):At.attr("fill",ht).filter(Pt=>Pt.key===yt).style("opacity",.25)}}).on("pointerleave",function(F,yt){const At=Q.selectAll(".serie");p[0]==="all"&&At.attr("fill",ht).style("opacity",1),At.selectAll("rect").attr("stroke-dasharray",ft),_&&E(!1)}).on("click",(F,yt)=>{k(At=>{let Pt=[];return e?At[0]===yt?Pt=["all"]:Pt=[yt]:At.includes(yt)?Pt=At.filter(ee=>ee!==yt):Pt=[...At,yt],Pt}),E(!0)});const ot=V.select("div#tooltip").style("opacity",0);S===null&&w(we(M));const at=gt.map(function(F){return F.label}),A=Oe().domain(at).rangeRound(r==="vertical"?[0,_t]:[G,0]).paddingInner(H?.4:.25).paddingOuter(.2).align(.2),j=e?p[0]==="all"?Zt(M,F=>F.totalPos):Zt(M,F=>F[p[0]]):Zt(M,F=>F.totalPos),nt=Math.max(0,j??0),Nt=e?p[0]==="all"?oe(M,F=>F.totalMin):oe(M,F=>F[p[0]]):oe(M,F=>F.totalMin),O=Math.min(0,Nt??0),K=ye().domain([O,nt]).range(r==="vertical"?[G,0]:[0,_t]).nice(),$t=!H&&r==="vertical"?Ft.rotatedAxisText:Ft.axisText,zt=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(zt).selectAll("text").style("cursor","pointer").attr("dy",H?"1em":".20em").attr("dx",H?"0em":"-.8em").attr("class",$t).selectAll(".tick").filter(F=>F===0).select("line").remove(),Q.select(".x-axis").selectAll("path").style("display","none");const et=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(et).selectAll(".tick").filter(F=>F===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(pt).offset(Es)(we(gt)).map(F=>{const yt=F.key,At=F.map(Pt=>{const ee=Pt.data.label;return{...Pt,key:`${yt} - ${ee}`,barKey:yt}});return At.key=yt,At}),vt=Q.selectAll(".serie").data(ut,F=>F.key).join(F=>F.append("g").attr("class","serie").attr("fill",ht).style("opacity",At=>e?p[0]==="all"||At.key===p[0]?1:0:1).style("pointer-events",At=>e?p[0]==="all"||At.key===p[0]?"auto":"none":"auto"),F=>F.transition().duration(N).attr("fill",At=>{const Pt=C.current.findIndex(re=>re===At.key)+n;return de(Pt)}).style("opacity",At=>e?p[0]==="all"||At.key===p[0]?1:0:1).style("pointer-events",At=>e?p[0]==="all"||At.key===p[0]?"auto":"none":"auto"),F=>F.transition().duration(N).attr("fill",Ee).style("opacity",0).selectAll("rect").attr("y",G).attr("height",0).remove()),kt=F=>A(F.data.label+"")??0,jt=A.bandwidth(),Xt=e&&p[0]!=="all"||pt.length===1,ie=F=>{if(Xt){const yt=Number(F.data[F.barKey]);return r==="vertical"?yt>=0?K(yt):K(0):yt>=0?K(0):K(yt)}else{const yt=r==="vertical"?G:_t;return p[0]==="all"?K(r==="vertical"?F[1]:F[0]):e&&r!=="vertical"?K(0):yt-(K(F[0])-K(F[1]))}},Jt=F=>{if(Xt){const yt=Number(F.data[F.barKey]),At=Math.abs(K(yt)-K(0));return isNaN(At)||At<0?0:At}else{const yt=r==="vertical"?K(F[0])-K(F[1]):K(F[1])-K(F[0]);return isNaN(yt)||yt<0?0:yt}},Ht=F=>r==="vertical"?kt(F):ie(F),Gt=F=>r==="vertical"?jt:Jt(F),ae=F=>r==="vertical"?ie(F):kt(F),Ct=F=>r==="vertical"?Jt(F):jt,Rt=gt.map((F,yt)=>{const At=ut.map(re=>({key:re.key,start:re[yt][0],end:re[yt][1],value:F[re.key]})),Pt=At.filter(re=>re.value??!1).sort((re,lt)=>lt.end-re.end),ee=At.filter(re=>re.value??!1).sort((re,lt)=>re.start-lt.start);return{label:F.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}}),ft=(F,yt)=>{const At=Gt(F),Pt=Ct(F),ee=Rt.find(St=>St.label===F.data.label),re=F.data[F.barKey],lt=ee?.top===F.barKey&&Number(re)>=0,xt=ee?.bottom===F.barKey&&Number(re)<0;return lt?r==="vertical"?`${At+Pt} ${At} ${Pt}`:`${At+Pt+At}`:xt?r==="vertical"?`${Pt+At+Pt} ${At}`:`${At} ${Pt} ${At+Pt}`:r==="vertical"?`${Pt} ${At}`:`${At} ${Pt}`},Mt=F=>{const yt=Gt(F),At=Rt.find(lt=>lt.label===F.data.label),Pt=F.data[F.barKey],ee=At?.top===F.barKey&&Number(Pt)>=0;return At?.bottom===F.barKey&&Number(Pt)<0?r==="vertical"?yt*-1:0:r==="vertical"?ee?0:yt*-1:0},it=F=>`rect ${Ft.rect}`;vt.selectAll("rect").data(F=>F,F=>F.data.label).join(F=>{const yt=F.append("rect").attr("class",`rect ${J.rect}`).attr("x",function(At){return r==="vertical"?Ht(At):K(0)}).attr("width",function(At){return r==="vertical"?Gt(At):0}).attr("y",At=>r==="vertical"?K(0):ae(At)).attr("height",function(At){return r==="vertical"?0:Ct(At)}).attr("stroke-dasharray",ft).attr("stroke-dashoffset",Mt);return yt.transition().duration(N).attr("x",Ht).attr("width",Gt).attr("height",Ct).attr("y",ae),yt},void 0,F=>F.transition().duration(N).attr("opacity",0).attr("y",G).attr("height",0).remove()).attr("class",it).attr("stroke-dasharray",ft).attr("stroke-dashoffset",Mt).transition().duration(N).attr("x",Ht).attr("width",Gt).attr("height",Ct).attr("y",ae);const mt={prefix:a,suffix:i,formatType:s};vt.selectAll("rect").on("pointerenter",function(F,yt){Q.select(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(ee=>ee===yt.data.label).attr("class",(r==="vertical"?$t:"")+" "+Ft.hoveredAxisText),ot.style("opacity",1);const At=yt.data[yt.barKey],{total:Pt}=yt.data;ot.select("p.label").text(yt.data.label),ot.select("p.layer span.label span.chev").style("background",Z(yt.barKey)),ot.select("p.layer span.label span.label").text(yt.barKey),ot.select("p.layer span.value").text(_e(At,mt)),ot.select("p.total span.value").text(_e(Pt??0,mt)),le(ot,{e:F,svg:B,yScale:K})}).on("touch",function(F,yt){te(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(At=>At===yt.data.label)}).on("pointermove",(F,yt)=>{le(ot,{e:F,svg:B,yScale:K})}).on("pointerleave",function(F,yt){Q.select(r==="vertical"?".x-axis":".y-axis").selectAll("text").filter(At=>At===yt.data.label).attr("class",r==="vertical"?$t:""),ot.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:W,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("div",{ref:h,className:`controls ${J[H?"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 ${Ft["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"?Ft["value-axis"]:Ft["label-axis"]}
11
+ y-axis`}),m.jsx("g",{className:`${r==="horizontal"?Ft["value-axis"]:Ft["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 q;return y&&(q=setTimeout(()=>{T(!1)},N+500)),()=>{clearTimeout(q)}},[y]);const U=[d,x,p,e],M=we(I),Y=M.length===0?[]:Object.keys(M[0]).filter(q=>q!=="label"&&q!=="total"),C=rn(Y),H=d>576,W={prefix:a,suffix:i,formatType:s},V=Se(q=>{if(d===0||x===0)return;const $={top:20,right:30,bottom:30,left:30},pt=M.length===0?[]:Object.keys(M[0]).filter(it=>it!=="label"&&it!=="total"),wt=r?pt:pt.filter(it=>!p.includes(it));M.forEach(function(it){it.total=wt.reduce((mt,F)=>{F in it||(it[F]=0);const yt=it[F];return mt+(typeof yt=="number"?yt:Number(yt))},0)});const gt=M,_t=R&&(r&&p[0]!=="all"||!r&&wt.length===1)?we(gt).sort(function(it,mt){return r?p[0]==="all"?it.total-mt.total:Number(it[p[0]])-Number(mt[p[0]]):it.total-mt.total}):gt,G=d-$.left-$.right,st=x-$.top-$.bottom,B=q.select("svg"),Q=B.node(),X=B.select(".plot-area").attr("transform","translate("+$.left+","+$.top+")"),tt=q.select(".controls").select(".legends-container"),L=H?80:50,Z=function(it){const mt=Ft[H?"legend-container":"legend-container-sm"],F=Ft[H?"legend-container-active":"legend-container-active-sm"],yt=Ft[H?"legend-container-inactive":"legend-container-inactive-sm"];return`
13
+ ${p.includes(it)?r?F:yt:mt}
31
14
  legend-item
32
- `};H.selectAll(".legend-item").data([...D],it=>it).join(it=>{const O=it.append("div").attr("class",J).style("left",(tt,d)=>`${d*K}px`).style("top","-53px").style("opacity",0);return O.append("div").attr("class",yt["legend-rect"]).style("background",tt=>{const d=T.current.findIndex(_=>_===tt)+e;return Ft(d)}),O.append("span").attr("class",yt["legend-label"]).text(tt=>tt),O.transition().duration(S).style("top","0px").style("opacity",1),O},it=>(it.attr("class",J).transition().duration(S).style("top","0px").style("left",(O,tt)=>`${tt*K}px`).style("opacity",1).select(`.${yt["legend-rect"]}`).style("background",O=>{const tt=T.current.findIndex(d=>d===O)+e;return Ft(tt)}),it.select(`.${yt["legend-label"]}`).text(O=>O),it),it=>it.transition().duration(S).style("opacity",0).style("top","53px").remove().remove()).on("click",(it,O)=>{M(tt=>tt===O?(Z(!1),"all"):O)}).on("mouseover",(it,O)=>{Y(O)}).on("mouseout",(it,O)=>{Y("")})},[...P,D,v]),E=$.jsxs("div",{ref:c,className:`${st[I?"controls-container":"controls-container-sm"]} ${A?st["fill-container"]:""}`,children:[$.jsxs("label",{className:`${st["controls-label"]} ${x==="all"?st.disabled:""}`,style:{paddingRight:"12px"},children:[$.jsx("input",{type:"checkbox",className:`${st["controls-checkbox"]}`,checked:B,onChange:H=>Z(H.target.checked),disabled:x==="all"}),"Sort"]}),$.jsx("div",{ref:m,id:"stacked-barchart-legends",className:`${yt["legends-container"]}`})]}),g=Kt(H=>{if(p===0||k===0||z!==""&&v)return;const K={top:20,right:30,bottom:30,left:40};y.forEach(function(ot){ot.total=D.reduce((gt,_t)=>{_t in ot||(ot[_t]=0);const G=ot[_t];return gt+(typeof G=="number"?G:Number(G))},0)});const J=y,ct=B?Ot(J).sort(function(ot,gt){return Number(ot[x])-Number(gt[x])}):J,it=p-K.left-K.right,O=k-K.top-K.bottom,tt=H.select("svg"),d=tt.node(),_=tt.select(".plot-area").attr("transform","translate("+K.left+","+K.top+")"),C=Ke(H).style("opacity",0);W===null&&b(Ot(y));const w=x==="all",Q=!I&&n==="vertical"?yt.rotatedAxisText:yt.axisText,rt=ct.map(function(ot){return ot.label}),ft=ye().domain(rt).rangeRound(n==="vertical"?[0,it]:[O,0]).paddingInner(w?.15:I?.4:.25).paddingOuter(.2).align(.2),xt=x==="all"?Dt(y,ot=>Dt(Object.entries(ot).filter(([gt])=>gt!=="total"&&gt!=="label").map(([,gt])=>gt))):Dt(y,ot=>ot[x]),et=Gt().domain([0,xt??0]).range(n==="vertical"?[O,0]:[0,it]),V=n==="vertical"?Ut(ft).tickValues(ft.domain()).tickSizeOuter(0):Ut(et).ticks(4,"s").tickSizeOuter(0).tickSize(-O);_.select(".x-axis").attr("transform",`translate(0,${O})`).transition().duration(S).call(V).selectAll("text").style("cursor","pointer").attr("dy",I?"1em":".20em").attr("dx",I?"0em":"-.8em").attr("class",Q).selectAll(".tick").filter(ot=>ot===0).select("line").remove();const at=n==="vertical"?te(et).ticks(4,"s").tickSize(-it):te(ft).tickSizeOuter(0);_.select(".y-axis").attr("transform","translate(0,0)").transition().duration(S).call(at).selectAll(".tick").filter(ot=>ot===0).select("line").remove();const lt=bn().keys(D)(ct).map(ot=>{const gt=ot.key,_t=ot.map(G=>({...G,key:`${gt} - ${G.data.label}`,barKey:gt}));return _t.key=gt,_t}),nt=ot=>z!==""?`rect
33
- ${z===ot.barKey?yt.rectLegendHovered:yt.rectLegendNotHovered}`:`rect ${yt.rect}`;let F=_.selectAll(".serie").data(lt,function(ot){return ot.key}).join(ot=>ot.append("g").attr("class","serie").attr("fill",function(_t){const G=T.current.findIndex(mt=>mt===_t.key)+e;return Ft(G)}).style("opacity",_t=>x==="all"||_t.key===x?1:0).style("pointer-events",_t=>x==="all"||_t.key===x?"auto":"none"),ot=>ot.transition().duration(S).attr("fill",function(_t){const G=T.current.findIndex(mt=>mt===_t.key)+e;return Ft(G)}).style("opacity",_t=>x==="all"||_t.key===x?1:0).style("pointer-events",_t=>x==="all"||_t.key===x?"auto":"none"),ot=>ot.transition().duration(S).style("opacity",0).attr("fill","grey").selectAll("rect").attr("y",O).attr("height",0).remove());const q=ot=>{const gt=ft(ot.data.label+"")??0;if(x==="all"){const _t=D.indexOf(ot.barKey)||0;return gt+_t*(ft.bandwidth()/D.length)}return gt},pt=()=>x==="all"?ft.bandwidth()/D.length:ft.bandwidth(),vt=ot=>n==="vertical"?O-(et(ot[0])-et(ot[1])):et(0),bt=ot=>{const gt=n==="vertical"?et(ot[0])-et(ot[1]):et(ot[1])-et(ot[0]);return isNaN(gt)||gt<0?0:gt},St=ot=>n==="vertical"?q(ot):vt(ot),Tt=ot=>n==="vertical"?pt():bt(ot),Mt=ot=>n==="vertical"?vt(ot):q(ot),Ct=ot=>n==="vertical"?bt(ot):pt();F.selectAll("rect").data(ot=>ot,ot=>ot.data.label).join(ot=>{let gt;return gt=ot.append("rect").attr("class",nt).attr("x",function(_t){return n==="vertical"?St(_t):0}).attr("width",function(_t){return n==="vertical"?x==="all"?ft.bandwidth()/D.length:ft.bandwidth():0}).attr("y",function(_t){return n==="vertical"?O:Mt(_t)}).attr("height",function(_t){return n==="vertical"?0:x==="all"?ft.bandwidth()/D.length:ft.bandwidth()}).transition().duration(S).attr("x",St).attr("width",Tt).attr("height",Ct).attr("y",Mt),gt},void 0,ot=>ot.attr("fill",me).transition().duration(S).attr("opacity",0).attr("height",0).attr("y",O+K.bottom).remove()).attr("class",nt).transition().duration(S).attr("x",St).attr("width",Tt).attr("height",Ct).attr("y",Mt),F.selectAll("rect").on("mouseover",function(ot,gt){At(n==="vertical"?".x-axis":".y-axis").selectAll("text").filter(U=>U===gt.data.label).attr("class",(n==="vertical"?Q:"")+" "+yt.hoveredAxisText),C.style("opacity",1).select("p.title").text(gt.data.label);const _t=gt.data[gt.barKey],{total:G}=gt.data,mt=_t/G*100;Rt(".1f")(mt)+"",C.select("p.top-label").text(gt.barKey+" : "+Et(_t,r)),C.select("p.bottom-label").text(x==="all"?`Total : ${Et(G,r)}`:"~")}).on("touch",function(ot,gt){At(".x-axis").selectAll("text").filter(_t=>_t===gt.data.label).attr("class",Q)}).on("mousemove",(ot,gt)=>{pr(C,{e:ot,svg:d,yScale:et})}).on("mouseout",function(ot,gt){At(n==="vertical"?".x-axis":".y-axis").selectAll("text").filter(_t=>_t===gt.data.label).attr("class",n==="vertical"?Q:""),C.style("opacity",0)})},[...P,B,y,D,z,j,n,v,r]);return $.jsxs("div",{ref:a,style:{width:o,height:s,display:"flex",flexDirection:"column"},children:[A?kn.createPortal(E,A):E,$.jsx("div",{ref:f,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:$.jsxs("div",{ref:g,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[$.jsx("svg",{className:`${st["chart-svg"]} ${st["fill-container"]}`,viewBox:`0 0 ${p} ${k}`,children:p>0&&$.jsxs("g",{className:"plot-area",children:[$.jsx("g",{className:"plot-rects"}),$.jsx("g",{className:`${n==="vertical"?yt["value-axis"]:""} y-axis`}),$.jsx("g",{className:`${n==="horizontal"?yt["value-axis"]:""} x-axis`})]})}),$.jsx(Xe,{pCount:3})]})})]})}function Vd({data:t,colorIdx:e=0,orientation:n="vertical",tooltipFormat:r}){const[a,i]=ge(),{width:o,height:s}=i,[c,l]=xe(),{height:u}=l,[f,h]=xe(),{width:p,height:k}=h,[W,b]=ut.useState(""),[v,L]=ut.useState(!0),[x,M]=ut.useState(!1),[j,N]=ut.useState("all"),z=dr(),Y=t;ut.useEffect(()=>{N("all"),L(!0),M(!0)},[Y]);const B=750;ut.useEffect(()=>{let I;return x&&(I=setTimeout(()=>{M(!1)},B+500)),()=>{clearTimeout(I)}},[x]);const Z=[p,k,j,e],A=Ot(Y),X=A.length===0?[]:Object.keys(A[0]).filter(I=>I!=="label"&&I!=="total"),S=qe(X),P=p>576,y=Kt(I=>{if(x)return;const m=P?80:50,E=function(H){const K=yt[P?"legend-container":"legend-container-sm"],J=yt[P?"legend-container-active":"legend-container-active-sm"],ct=yt[P?"legend-container-inactive":"legend-container-inactive-sm"];return`
34
- ${j.includes(H)?j===H?J:ct:K}
15
+ `},ht=it=>{const mt=C.current.findIndex(yt=>yt===it)+e;return de(mt)};function ot(it){return ht(it.key)}tt.selectAll(".legend-item").data([...pt],it=>it).join(it=>{const mt=it.append("div").attr("class",Z).style("left",(F,yt)=>`${yt*L}px`).style("top","-53px").style("opacity",0);return mt.append("div").attr("class",Ft["legend-rect"]).style("background",F=>{if(!r&&p.includes(F))return Ee;const yt=C.current.findIndex(At=>At===F)+e;return de(yt)}),mt.append("span").attr("class",Ft["legend-label"]).text(F=>F),mt.transition().duration(N).style("top","0px").style("opacity",1),mt},it=>(it.attr("class",Z).transition().duration(N).style("top","0px").style("left",(mt,F)=>`${F*L}px`).style("opacity",1).select(`.${Ft["legend-rect"]}`).style("background",mt=>{if(!r&&p.includes(mt))return Ee;const F=C.current.findIndex(yt=>yt===mt)+e;return de(F)}),it.select(`.${Ft["legend-label"]}`).text(mt=>mt),it),it=>it.transition().duration(N).style("opacity",0).style("top","53px").remove().remove()).on("click",(it,mt)=>{k(F=>{let yt=[];return r?F[0]===mt?yt=["all"]:yt=[mt]:F.includes(mt)?yt=F.filter(At=>At!==mt):yt=[...F,mt],yt}),E(!0)}).on("pointerenter",(it,mt)=>{const F=X.selectAll(".serie");p[0]==="all"&&(r?F.attr("fill",ot).filter(yt=>yt.key!==mt).transition().duration(250).style("opacity",.25):F.attr("fill",ot).filter(yt=>yt.key===mt).transition().duration(250).style("opacity",.25))}).on("pointerleave",(it,mt)=>{X.selectAll(".serie"),p[0]==="all"&&X.selectAll(".serie").attr("fill",ot).transition().duration(250).style("opacity",1)});const A=q.select("div#tooltip").style("opacity",0);S===null&&w(we(M));const j=p[0]==="all",nt=_t.map(function(it){return it.label}),O=di(d,nt)&&n==="vertical"?Ft.rotatedAxisText:Ft.axisText,K=Oe().domain(nt).rangeRound(n==="vertical"?[0,G]:[st,0]).paddingInner(j?.15:H?.4:.25).paddingOuter(.2).align(.2),$t=p[0]==="all"?Zt(M,it=>Zt(Object.entries(it).filter(([mt])=>mt!=="total"&&mt!=="label").map(([,mt])=>mt))):Zt(M,it=>it[p[0]]),zt=p[0]==="all"?oe(M,it=>oe(Object.entries(it).filter(([mt])=>mt!=="total"&&mt!=="label").map(([,mt])=>mt))):oe(M,it=>it[p[0]]),et=Math.min(0,zt??0),Tt=ye().domain([et,$t??0]).range(n==="vertical"?[st,0]:[0,G]),ut=n==="vertical"?he(K).tickValues(K.domain()).tickSizeOuter(0).tickSize(0):he(Tt).ticks(4,"s").tickSizeOuter(0).tickSize(-st);X.select(".x-axis").attr("transform",`translate(0,${st})`).transition().duration(N).call(ut).selectAll("text").attr("dy",H?"1em":".20em").attr("dx",H?"0em":"-.8em").attr("class",O).selectAll(".tick").filter(it=>it===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(it=>it===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:st).attr("transform",n==="vertical"?`translate(0, ${Tt(0)||0})`:`translate(${Tt(0)||0}, 0)`);const jt=na().keys(wt).offset(Es)(_t).map(it=>{const mt=it.key,F=it.map(yt=>{const At=Object.keys(yt.data).filter(Pt=>Pt!=="label"&&Pt!=="total"&&(r?!0:!p.includes(Pt))).map(Pt=>({label:Pt,value:yt.data[Pt]})).sort((Pt,ee)=>Number(Pt.value)-Number(ee.value));return{...yt,key:`${mt} - ${yt.data.label}`,barKey:mt,data:{...yt.data,sortedLayers:At.map(Pt=>Pt.label)}}});return F.key=mt,F}),Xt=it=>`rect ${Ft.rect}`;let ie=X.selectAll(".serie").data(jt,function(it){return it.key}).join(it=>it.append("g").attr("class","serie").attr("fill",ot).style("opacity",F=>p[0]==="all"||F.key===p[0]?1:0).style("pointer-events",F=>p[0]==="all"||F.key===p[0]?"auto":"none"),it=>it.transition().duration(N).attr("fill",ot).style("opacity",F=>p[0]==="all"||F.key===p[0]?1:0).style("pointer-events",F=>p[0]==="all"||F.key===p[0]?"auto":"none"),it=>it.transition().duration(N).style("opacity",0).attr("fill","grey").selectAll("rect").attr("y",st).attr("height",0).remove());const Jt=it=>{const mt=K(it.data.label)??0;if(!r||r&&p[0]==="all"){const F=R?it.data.sortedLayers:wt,yt=Array.isArray(F)&&F.indexOf(it.barKey)||0;return mt+yt*(K.bandwidth()/wt.length)}return mt},Ht=()=>!r||r&&p[0]==="all"?K.bandwidth()/wt.length:K.bandwidth(),Gt=it=>{const mt=Number(it.data[it.barKey]);return n==="vertical"?mt>=0?Tt(mt):Tt(0):mt>=0?Tt(0):Tt(mt)},ae=it=>{const mt=Number(it.data[it.barKey]),F=Math.abs(Tt(mt)-Tt(0));return isNaN(F)||F<0?0:F},Ct=it=>n==="vertical"?Jt(it):Gt(it),Rt=it=>n==="vertical"?Ht():ae(it),ft=it=>n==="vertical"?Gt(it):Jt(it),Mt=it=>n==="vertical"?ae(it):Ht();ie.selectAll("rect").data(it=>it,it=>it.data.label).join(it=>{let mt;return mt=it.append("rect").attr("class",Xt).attr("x",function(F){return n==="vertical"?Ct(F):0}).attr("width",function(F){return n==="vertical"?p[0]==="all"?K.bandwidth()/wt.length:K.bandwidth():0}).attr("y",function(F){return n==="vertical"?st:ft(F)}).attr("height",function(F){return n==="vertical"?0:p[0]==="all"?K.bandwidth()/wt.length:K.bandwidth()}).transition().duration(N).style("opacity",1).attr("x",Ct).attr("width",Rt).attr("height",Mt).attr("y",ft),mt},void 0,it=>it.attr("fill",Ee).transition().duration(N).attr("opacity",0).attr("height",0).attr("y",st+$.bottom).remove()).attr("class",Xt).transition().duration(N).style("opacity",1).attr("x",Ct).attr("width",Rt).attr("height",Mt).attr("y",ft),ie.selectAll("rect").on("pointerenter",function(it,mt){R&&ie.selectAll("rect").filter(Pt=>Pt.barKey!==mt.barKey).style("opacity",.25),X.select(n==="vertical"?".x-axis":".y-axis").selectAll("text").filter(Pt=>Pt===mt.data.label).attr("class",(n==="vertical"?O:"")+" "+Ft.hoveredAxisText),A.style("opacity",1);const F=mt.data[mt.barKey],{total:yt}=mt.data,At=F/yt*100;pe(".1f")(At)+"",A.select("p.label").text(mt.data.label),A.select("p.layer span.label span.chev").style("background",ht(mt.barKey)),A.select("p.layer span.label span.label").text(mt.barKey),A.select("p.layer span.value").text(_e(F,W)),A.select("p.total span.value").text(_e(yt??0,W)),le(A,{e:it,svg:Q,yScale:Tt})}).on("touch",function(it,mt){te(".x-axis").selectAll("text").filter(F=>F===mt.data.label).attr("class",O)}).on("pointermove",(it,mt)=>{le(A,{e:it,svg:Q,yScale:Tt})}).on("pointerleave",function(it,mt){R&&ie.selectAll("rect").filter(F=>F.barKey!==mt.barKey).style("opacity",1),X.select(n==="vertical"?".x-axis":".y-axis").selectAll("text").filter(F=>F===mt.data.label).attr("class",n==="vertical"?O:""),A.style("opacity",0)})},[...U,R,M,_,n,y,W]);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[H?"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:q=>z(q.target.checked)}),"Sort"]}),m.jsx("div",{className:`legends-container ${Ft["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"?Ft["value-axis"]:Ft["label-axis"]} y-axis`}),m.jsx("g",{className:`${n==="horizontal"?Ft["value-axis"]:Ft["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},H=R.length===0?[]:Object.keys(R[0]).filter(ft=>ft!=="label"&&ft!=="total"),W=H.filter(ft=>!T.includes(ft));R.forEach(function(ft){ft.total=W.reduce((Mt,it)=>{it in ft||(ft[it]=0);const mt=ft[it];return Mt+(typeof mt=="number"?mt:Number(mt))},0)});const q=R.filter(ft=>ft?.total&&ft.total>0),$=b-C.left-C.right,pt=d-C.top-C.bottom,wt=Y.select("svg"),gt=wt.node(),_t=wt.select(".plot-area").attr("transform","translate("+C.left+","+C.top+")"),st=Y.select(".controls").select(".legends-container"),B=N?80:50,Q=ft=>{const Mt=I.current.findIndex(it=>it===ft)+e;return de(Mt)};function X(ft){return Q(ft.key)}const D=function(ft){const Mt=Ft[N?"legend-container":"legend-container-sm"],it=Ft[N?"legend-container-inactive":"legend-container-inactive-sm"];return`
16
+ ${T.includes(ft)?it:Mt}
35
17
  legend-item
36
- `};I.selectAll(".legend-item").data([...X],H=>H).join(H=>{const K=H.append("div").attr("class",E).style("left",(J,ct)=>`${ct*m}px`).style("top","-53px").style("opacity",0);return K.append("div").attr("class",yt["legend-rect"]).style("background",J=>{const ct=S.current.findIndex(it=>it===J)+e;return Ft(ct)}),K.append("span").attr("class",yt["legend-label"]).text(J=>J),K.transition().duration(B).style("top","0px").style("opacity",1),K},H=>(H.attr("class",E).transition().duration(B).style("top","0px").style("left",(K,J)=>`${J*m}px`).style("opacity",1).select(`.${yt["legend-rect"]}`).style("background",K=>{const J=S.current.findIndex(ct=>ct===K)+e;return Ft(J)}),H.select(`.${yt["legend-label"]}`).text(K=>K),H),H=>H.transition().duration(B).style("opacity",0).style("top","53px").remove().remove().remove()).on("mouseover",(H,K)=>{b(K)}).on("mouseout",function(H){b("")})},[...Z,X,x]),D=$.jsxs("div",{ref:c,className:`${st["controls-container"]} ${z?st["fill-container"]:""}`,children:[$.jsxs("label",{className:st["controls-label"],style:{paddingRight:"12px"},children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:v,onChange:I=>L(I.target.checked)}),"Percentage"]}),$.jsx("div",{ref:y,id:"stacked-barchart-legends",className:`${yt["legends-container"]}`})]}),T=Kt(I=>{if(p===0||k===0||W!==""&&x)return;const m={top:20,right:30,bottom:30,left:40};A.forEach(function(G){G.total=X.reduce((mt,U)=>{U in G||(G[U]=0);const ht=G[U];return mt+(typeof ht=="number"?ht:Number(ht))},0)});const g=A.filter(G=>G?.total&&G.total>0),H=p-m.left-m.right,K=k-m.top-m.bottom,J=I.select("svg"),ct=J.node(),it=J.select(".plot-area").attr("transform","translate("+m.left+","+m.top+")"),O=Ke(I).style("opacity",0),tt=!P&&n==="vertical"?yt.rotatedAxisText:yt.axisText,d=g.map(function(G){return G.label}),_=ye().domain(d).rangeRound(n==="vertical"?[0,H]:[K,0]).paddingInner(P?.4:.25).paddingOuter(.2).align(.2),C=Dt(A,G=>G.total),w=Gt().domain([0,v?1:C||0]).nice().range(n==="vertical"?[K,0]:[0,H]),Q=ye().rangeRound([0,H]).paddingInner(.1).align(.2),rt=g.map(function(G){return G.label});Q.domain(rt);const ft=[],xt=n==="vertical"?Ut(_).tickValues(_.domain()).tickSizeOuter(0):Ut(w).ticks(4,v?".0%":"s").tickSizeOuter(0).tickSize(-K);it.select(".x-axis").attr("transform",`translate(0,${K})`).transition().duration(B).call(xt).selectAll("text").style("cursor","pointer").attr("dy",P?"1em":".20em").attr("dx",P?"0em":"-.8em").attr("class",tt).selectAll(".tick").filter(G=>G===0).select("line").remove();const et=Dt(A,G=>G.total),V=Gt().domain([0,v?1:et||0]).nice().range([K,0]),at=n==="vertical"?te(w).ticks(4,v?".0%":"s").tickSize(-H):te(_).tickSizeOuter(0);it.select(".y-axis").attr("transform","translate(0,0)").transition().duration(B).call(at).selectAll(".tick").filter(G=>G===0).select("line").remove();const R=bn().order(hr).offset(zd),nt=(v?R.keys(X)(g):bn().keys(X)(g)).map(G=>{const mt=G.key,U=G.map(ht=>{const dt=ht.data.label;return{...ht,key:`${mt} - ${dt}`,barKey:mt}});return U.key=mt,U});let F=it.selectAll(".serie").data(nt,function(G){return G.key}).join(G=>G.append("g").attr("class","serie").attr("fill",function(U){const ht=S.current.findIndex(dt=>dt===U.key)+e;return Ft(ht)}).style("opacity",1).style("pointer-events","auto"),G=>G.transition().duration(B).attr("fill",function(U){const ht=S.current.findIndex(dt=>dt===U.key)+e;return Ft(ht)}).style("opacity",1).style("pointer-events","auto"),G=>G.transition().duration(B).style("opacity",0).attr("fill",me).selectAll("rect").attr("y",K).attr("height",0).remove());const q=G=>_(G.data.label+"")??0,pt=_.bandwidth(),vt=G=>w(n==="vertical"?G[1]:G[0]),bt=G=>{const mt=n==="vertical"?w(G[0])-w(G[1]):w(G[1])-w(G[0]);return isNaN(mt)||mt<0?0:mt},St=G=>n==="vertical"?q(G):vt(G),Tt=G=>n==="vertical"?pt:bt(G),Mt=G=>n==="vertical"?vt(G):q(G),Ct=G=>n==="vertical"?bt(G):pt;function ot(G){if(G.barKey===W)return"none";const mt=Tt(G),U=Ct(G);return X.indexOf(G.barKey)===X.length-1||G.barKey===j[0]?n==="vertical"?`${mt+U} ${mt} ${U}`:`${mt+U+mt}`:n==="vertical"?`${U} ${mt}`:`${mt} ${U}`}function gt(G){const mt=Tt(G),U=X.indexOf(G.barKey)===X.length-1;return n==="vertical"?U?0:mt*-1:0}const _t=G=>W!==""&&W===G.barKey?`rect ${yt.rectLegendHovered}`:`rect ${yt.rect}`;F.selectAll("rect").data(G=>G,G=>G.data.label).join(G=>{let mt;return mt=G.append("rect").attr("class",_t).attr("x",function(U){return n==="vertical"?Q(U.data.label+"")??0:w(0)}).attr("width",function(U){return n==="vertical"?_.bandwidth():0}).attr("y",function(U){if(n==="vertical"){if(!ft.includes(U.data.label+""))return K;const ht=w(U[1]),dt=w(U[0])-w(U[1]),Lt=isNaN(dt)||dt<0?0:dt;return ht+Lt}else return Mt(U)}).attr("height",function(U){return n==="vertical"?0:Ct(U)}).attr("stroke-dasharray",ot).attr("stroke-dashoffset",gt).transition().duration(B).attr("x",St).attr("width",Tt).attr("height",Ct).attr("y",Mt),mt},void 0,G=>G.transition().duration(B).attr("opacity",0).attr("height",0).attr("y",K).remove()).attr("class",_t).attr("stroke-dasharray",ot).attr("stroke-dashoffset",gt).transition().duration(B).attr("x",St).attr("width",Tt).attr("height",Ct).attr("y",Mt),F.selectAll("rect").on("mouseover",function(G,mt){At(".x-axis").selectAll("text").filter(Yt=>Yt===mt.data.name).attr("class",tt+" "+st.hoveredAxisText),O.style("opacity",1).select("p.title").text(mt.data.label);const U=mt.data[mt.barKey]||0,ht=mt.data.total||0,dt=U/ht*100,Lt=Rt(".1f")(dt)+"%";O.select("p.top-label").text(mt.barKey+" : "+(v?Lt:Et(U,r))),O.select("p.bottom-label").text(v?`(${Et(U,r)} of ${Et(ht,r)})`:`Total : ${Et(ht,r)}`)}).on("touch",function(G,mt){At(".x-axis").selectAll("text").filter(U=>U===mt.data.label).attr("class",tt)}).on("mousemove",(G,mt)=>{pr(O,{e:G,svg:ct,yScale:V})}).on("mouseout",function(G,mt){At(".x-axis").selectAll("text").filter(U=>U===mt.data.name).attr("class",tt),O.style("opacity",0)})},[...Z,A,X,v,W,n,x,r]);return $.jsxs("div",{ref:a,style:{width:o,height:s,display:"flex",flexDirection:"column"},children:[z?kn.createPortal(D,z):D,$.jsx("div",{ref:f,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:$.jsxs("div",{ref:T,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[$.jsx("svg",{className:`${st["chart-svg"]} ${st["fill-container"]}`,viewBox:`0 0 ${p} ${k}`,children:$.jsxs("g",{className:"plot-area",children:[$.jsx("g",{className:"plot-rects"}),$.jsx("g",{className:`${n==="vertical"?yt["value-axis"]:""} y-axis`}),$.jsx("g",{className:`${n==="horizontal"?yt["value-axis"]:""} x-axis`})]})}),$.jsx(Xe,{pCount:3})]})})]})}function Eo(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 Bd(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 ba(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 Xd(t,e){return t.sourceLinks.length?t.depth:e-1}function yr(t){return function(){return t}}function Lo(t,e){return xr(t.source,e.source)||t.index-e.index}function jo(t,e){return xr(t.target,e.target)||t.index-e.index}function xr(t,e){return t.y0-e.y0}function wa(t){return t.value}function Kd(t){return t.index}function qd(t){return t.nodes}function Gd(t){return t.links}function Po(t,e){const n=t.get(e);if(!n)throw new Error("missing: "+e);return n}function Ho({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 Zd(){let t=0,e=0,n=1,r=1,a=24,i=8,o,s=Kd,c=Xd,l,u,f=qd,h=Gd,p=6;function k(){const y={nodes:f.apply(null,arguments),links:h.apply(null,arguments)};return W(y),b(y),v(y),L(y),j(y),Ho(y),y}k.update=function(y){return Ho(y),y},k.nodeId=function(y){return arguments.length?(s=typeof y=="function"?y:yr(y),k):s},k.nodeAlign=function(y){return arguments.length?(c=typeof y=="function"?y:yr(y),k):c},k.nodeSort=function(y){return arguments.length?(l=y,k):l},k.nodeWidth=function(y){return arguments.length?(a=+y,k):a},k.nodePadding=function(y){return arguments.length?(i=o=+y,k):i},k.nodes=function(y){return arguments.length?(f=typeof y=="function"?y:yr(y),k):f},k.links=function(y){return arguments.length?(h=typeof y=="function"?y:yr(y),k):h},k.linkSort=function(y){return arguments.length?(u=y,k):u},k.size=function(y){return arguments.length?(t=e=0,n=+y[0],r=+y[1],k):[n-t,r-e]},k.extent=function(y){return arguments.length?(t=+y[0][0],n=+y[1][0],e=+y[0][1],r=+y[1][1],k):[[t,e],[n,r]]},k.iterations=function(y){return arguments.length?(p=+y,k):p};function W({nodes:y,links:D}){for(const[I,m]of y.entries())m.index=I,m.sourceLinks=[],m.targetLinks=[];const T=new Map(y.map((I,m)=>[s(I,m,y),I]));for(const[I,m]of D.entries()){m.index=I;let{source:E,target:g}=m;typeof E!="object"&&(E=m.source=Po(T,E)),typeof g!="object"&&(g=m.target=Po(T,g)),E.sourceLinks.push(m),g.targetLinks.push(m)}if(u!=null)for(const{sourceLinks:I,targetLinks:m}of y)I.sort(u),m.sort(u)}function b({nodes:y}){for(const D of y)D.value=D.fixedValue===void 0?Math.max(ba(D.sourceLinks,wa),ba(D.targetLinks,wa)):D.fixedValue}function v({nodes:y}){const D=y.length;let T=new Set(y),I=new Set,m=0;for(;T.size;){for(const E of T){E.depth=m;for(const{target:g}of E.sourceLinks)I.add(g)}if(++m>D)throw new Error("circular link");T=I,I=new Set}}function L({nodes:y}){const D=y.length;let T=new Set(y),I=new Set,m=0;for(;T.size;){for(const E of T){E.height=m;for(const{source:g}of E.targetLinks)I.add(g)}if(++m>D)throw new Error("circular link");T=I,I=new Set}}function x({nodes:y}){const D=Eo(y,m=>m.depth)+1,T=(n-t-a)/(D-1),I=new Array(D);for(const m of y){const E=Math.max(0,Math.min(D-1,Math.floor(c.call(null,m,D))));m.layer=E,m.x0=t+E*T,m.x1=m.x0+a,I[E]?I[E].push(m):I[E]=[m]}if(l)for(const m of I)m.sort(l);return I}function M(y){const D=Bd(y,T=>(r-e-(T.length-1)*o)/ba(T,wa));for(const T of y){let I=e;for(const m of T){m.y0=I,m.y1=I+m.value*D,I=m.y1+o;for(const E of m.sourceLinks)E.width=E.value*D}I=(r-I+o)/(T.length+1);for(let m=0;m<T.length;++m){const E=T[m];E.y0+=I*(m+1),E.y1+=I*(m+1)}X(T)}}function j(y){const D=x(y);o=Math.min(i,(r-e)/(Eo(D,T=>T.length)-1)),M(D);for(let T=0;T<p;++T){const I=Math.pow(.99,T),m=Math.max(1-I,(T+1)/p);z(D,I,m),N(D,I,m)}}function N(y,D,T){for(let I=1,m=y.length;I<m;++I){const E=y[I];for(const g of E){let H=0,K=0;for(const{source:ct,value:it}of g.targetLinks){let O=it*(g.layer-ct.layer);H+=S(ct,g)*O,K+=O}if(!(K>0))continue;let J=(H/K-g.y0)*D;g.y0+=J,g.y1+=J,A(g)}l===void 0&&E.sort(xr),Y(E,T)}}function z(y,D,T){for(let I=y.length,m=I-2;m>=0;--m){const E=y[m];for(const g of E){let H=0,K=0;for(const{target:ct,value:it}of g.sourceLinks){let O=it*(ct.layer-g.layer);H+=P(g,ct)*O,K+=O}if(!(K>0))continue;let J=(H/K-g.y0)*D;g.y0+=J,g.y1+=J,A(g)}l===void 0&&E.sort(xr),Y(E,T)}}function Y(y,D){const T=y.length>>1,I=y[T];Z(y,I.y0-o,T-1,D),B(y,I.y1+o,T+1,D),Z(y,r,y.length-1,D),B(y,e,0,D)}function B(y,D,T,I){for(;T<y.length;++T){const m=y[T],E=(D-m.y0)*I;E>1e-6&&(m.y0+=E,m.y1+=E),D=m.y1+o}}function Z(y,D,T,I){for(;T>=0;--T){const m=y[T],E=(m.y1-D)*I;E>1e-6&&(m.y0-=E,m.y1-=E),D=m.y0-o}}function A({sourceLinks:y,targetLinks:D}){if(u===void 0){for(const{source:{sourceLinks:T}}of D)T.sort(jo);for(const{target:{targetLinks:T}}of y)T.sort(Lo)}}function X(y){if(u===void 0)for(const{sourceLinks:D,targetLinks:T}of y)D.sort(jo),T.sort(Lo)}function S(y,D){let T=y.y0-(y.sourceLinks.length-1)*o/2;for(const{target:I,width:m}of y.sourceLinks){if(I===D)break;T+=m+o}for(const{source:I,width:m}of D.targetLinks){if(I===y)break;T-=m}return T}function P(y,D){let T=D.y0-(D.targetLinks.length-1)*o/2;for(const{source:I,width:m}of D.targetLinks){if(I===y)break;T+=m+o}for(const{target:I,width:m}of y.sourceLinks){if(I===D)break;T-=m}return T}return k}var ka=Math.PI,Sa=2*ka,De=1e-6,Jd=Sa-De;function Ma(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function zo(){return new Ma}Ma.prototype=zo.prototype={constructor:Ma,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,o=this._y1,s=n-t,c=r-e,l=i-t,u=o-e,f=l*l+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(f>De)if(!(Math.abs(u*s-c*l)>De)||!a)this._+="L"+(this._x1=t)+","+(this._y1=e);else{var h=n-i,p=r-o,k=s*s+c*c,W=h*h+p*p,b=Math.sqrt(k),v=Math.sqrt(f),L=a*Math.tan((ka-Math.acos((k+f-W)/(2*b*v)))/2),x=L/v,M=L/b;Math.abs(x-1)>De&&(this._+="L"+(t+x*l)+","+(e+x*u)),this._+="A"+a+","+a+",0,0,"+ +(u*h>l*p)+","+(this._x1=t+M*s)+","+(this._y1=e+M*c)}},arc:function(t,e,n,r,a,i){t=+t,e=+e,n=+n,i=!!i;var o=n*Math.cos(r),s=n*Math.sin(r),c=t+o,l=e+s,u=1^i,f=i?r-a:a-r;if(n<0)throw new Error("negative radius: "+n);this._x1===null?this._+="M"+c+","+l:(Math.abs(this._x1-c)>De||Math.abs(this._y1-l)>De)&&(this._+="L"+c+","+l),n&&(f<0&&(f=f%Sa+Sa),f>Jd?this._+="A"+n+","+n+",0,1,"+u+","+(t-o)+","+(e-s)+"A"+n+","+n+",0,1,"+u+","+(this._x1=c)+","+(this._y1=l):f>De&&(this._+="A"+n+","+n+",0,"+ +(f>=ka)+","+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 Io(t){return function(){return t}}function Qd(t){return t[0]}function t0(t){return t[1]}var e0=Array.prototype.slice;function n0(t){return t.source}function r0(t){return t.target}function a0(t){var e=n0,n=r0,r=Qd,a=t0,i=null;function o(){var s,c=e0.call(arguments),l=e.apply(this,c),u=n.apply(this,c);if(i||(i=s=zo()),t(i,+r.apply(this,(c[0]=l,c)),+a.apply(this,c),+r.apply(this,(c[0]=u,c)),+a.apply(this,c)),s)return i=null,s+""||null}return o.source=function(s){return arguments.length?(e=s,o):e},o.target=function(s){return arguments.length?(n=s,o):n},o.x=function(s){return arguments.length?(r=typeof s=="function"?s:Io(+s),o):r},o.y=function(s){return arguments.length?(a=typeof s=="function"?s:Io(+s),o):a},o.context=function(s){return arguments.length?(i=s??null,o):i},o}function i0(t,e,n,r,a){t.moveTo(e,n),t.bezierCurveTo(e=(e+r)/2,n,e,a,r,a)}function o0(){return a0(i0)}function s0(t){return[t.source.x1,t.y0]}function l0(t){return[t.target.x0,t.y1]}function Fo(){return o0().source(s0).target(l0)}const Uo={sankeyEnergyLink:"_sankeyEnergyLink_10fud_285",sankeyLabel:"_sankeyLabel_10fud_323"};function c0({data:t,tooltipFormat:e}){const[n,r]=ut.useState(null),[a,i]=ut.useState(!1),[o,s]=ut.useState(!1),c=ut.useRef(!0),l=ut.useRef(!0),u=ut.useRef("data"),[f,h]=ge(),{width:p,height:k}=h,W=qe(n?n.nodes.map(M=>M.name):[]);function b(M){const j=new Map,N=[],z=[],Y=B=>(j.has(B)||(j.set(B,N.length),N.push({name:B})),j.get(B));for(const{source:B,target:Z,value:A}of M)z.push({source:Y(B),target:Y(Z),value:A});return{nodes:N,links:z}}ut.useEffect(()=>{r(M=>{const j=b(t),N=M===null?[]:M.nodes.map(Y=>Y.name),z=j.nodes.map(Y=>Y.name);return c.current=z.every(Y=>!N.includes(Y)),M!==null&&(l.current=!1),u.current="data",j}),o&&s(!1),a&&i(!1)},[t]),ut.useEffect(()=>{p!==0&&k!==0&&(u.current="dimension")},[p,k]);const v=p<=768,L=1e3,x=Kt(M=>{if(!n)return;const j=p,N=k;if(j===0||N===0)return;const z={top:30,right:20,bottom:20,left:20},Y=N-(z.top+z.bottom),B=j-(z.left+z.right),Z=Y,A=B,X=n.links.map(d=>({...d})),S=n.nodes.map(d=>({...d}));X.forEach(function(d){const _=n.nodes[d.source].name,C=n.nodes[d.target].name,w=_+" → "+C;d.sourceName=_,d.targetName=C,d.id=w});const P=M.select("svg");P.node();const y=P.select(".plot-area").attr("transform","translate("+z.left+","+z.top+")"),D=Ke(M).style("opacity",0),T=d=>{const _=d.targetLinks?.reduce((w,Q)=>w+Q.value,0)??0,C=d.sourceLinks?.reduce((w,Q)=>w+Q.value,0)??0;return{enteringValue:_,exitingValue:C}},m=Zd().nodeSort(o?(d,_)=>{const{enteringValue:C,exitingValue:w}=T(d),{enteringValue:Q,exitingValue:rt}=T(_);return Math.max(C,w)-Math.max(Q,rt)}:null).linkSort(a?(d,_)=>d.value-_.value:null).nodeWidth(A<=540?8:A>540&&A<=768?12:15).nodePadding(A<=540?5:8).extent([[0,0],[A,Z]])({nodes:S.map(d=>Object.assign({},d)),links:X.map(d=>Object.assign({},d))}),{nodes:E,links:g}=m;y.selectAll("linearGradient").remove();const H=y.selectAll("linearGradient").data(g).join("linearGradient").attr("id",(d,_)=>_.toString()).attr("gradientUnits","userSpaceOnUse").attr("x1",d=>d.source.x0).attr("x2",d=>d.target.x0);H.append("stop").attr("offset","0%").attr("stop-color",d=>{const _=W.current.findIndex(C=>C===d.sourceName);return Ft(_,!1)}),H.append("stop").attr("offset","100%").attr("stop-color",d=>{const _=W.current.findIndex(C=>C===d.targetName);return Ft(_,!1)});const K=d=>{const _=d.source,C=d.target,w=Math.abs(C.depth-_.depth);return A*1.5*w},J=d=>K(d)+" "+K(d),ct=d=>!c.current||u.current==="sort node"||u.current==="sort link"||u.current!=="data"&&!l.current?0:d.target.depth*L;y.selectAll(".link").data(g,d=>d.id).join(d=>d.append("path").attr("class",`link ${Uo.sankeyEnergyLink}`).attr("d",Fo()).style("stroke",function(_){return`url(#${H.filter(Q=>Q.sourceName===_.sourceName&&Q.targetName===_.targetName).node()?.id})`}).attr("stroke-dasharray",J).attr("stroke-dashoffset",K).attr("stroke-width",_=>Math.max(1,_.width)).transition().duration(L).delay(function(_){return c.current?ct(_):L}).attr("stroke-dashoffset",0).on("end",function(){At(this).attr("stroke-dasharray","none")}),d=>(d.attr("stroke-width",_=>Math.max(1,_.width||0)).transition().duration(L).delay(ct).attr("d",Fo()).attr("stroke-dashoffset",0).on("end",function(){At(this).attr("stroke-dasharray","none")}),d),d=>c.current?d.remove():d.transition().duration(L/4).style("opacity",0).remove()).on("mouseover",(d,_)=>{y.selectAll("path.link").filter(C=>C.id!==_.id).style("stroke","#1f2937").style("stroke-opacity",.05),y.selectAll("text.label").filter(C=>{const w=C;return w.name!==_.sourceName&&w.name!==_.targetName}).style("opacity",0),D.style("opacity",1),D.select("p.title").text(_.id+Et(_.value,e)),D.select("p.top-label").style("display","none"),D.select("p.bottom-label").style("display","none")}).on("mousemove",(d,_)=>{gr(d,D)}).on("mouseout",(d,_)=>{D.style("opacity",0),y.selectAll("path.link").style("stroke",function(C){const w=C;return`url(#${H.filter(ft=>ft.sourceName===w.sourceName&&ft.targetName===w.targetName).node()?.id})`}).style("stroke-opacity",.5).style("fill","none").attr("class",`link ${st.sankeyEnergyLink}`),y.selectAll("text.label").style("opacity",1)});const it=d=>!c.current||d.depth===0||u.current==="sort node"||u.current==="sort link"||u.current!=="data"&&!l.current?0:d.depth*L+L/4,O=d=>{const{enteringValue:_,exitingValue:C}=T(d);return{nodeState:d.sourceLinks?.length===0&&d.targetLinks?.length===0?"stray node":d.sourceLinks?.length===0?"leaf node":d.targetLinks?.length===0?"source node":_>C?"surplus":_<C?"minus":"balanced",enteringValue:_,exitingValue:C}},tt=d=>{const{nodeState:_,enteringValue:C,exitingValue:w}=O(d);return{enteringValue:C,exitingValue:w,nodeState:_,stateColor:_==="surplus"?"#4ade80":_==="minus"?"#f87171":"#e7e7e7"}};y.selectAll("rect.node").data(E,(d=>d.name)).join(d=>d.append("rect").attr("class",`node ${st.baseNode}`).attr("x",_=>_.x0).attr("y",_=>_.y0).attr("height",_=>c.current?Math.abs(_.y1-_.y0):0).attr("width",_=>c.current?0:_.x1-_.x0).attr("opacity",0).attr("stroke-width",2.5).transition().duration(L).delay(it).attr("fill",_=>{const C=W.current.findIndex(w=>w===_.name);return Ft(C,!1)}).attr("opacity",1).attr("width",function(_){return _.x1-_.x0}),void 0,d=>c.current?d.remove():d.transition().duration(L/4).style("opacity",0).remove()).on("mouseover",(d,_)=>{y.selectAll("path.link").filter(V=>{const at=V;return!(at.sourceName===_.name||at.targetName===_.name)}).style("stroke","#1f2937").style("stroke-opacity",.05);const C=_.sourceLinks?.map(V=>V.targetName)??[],Q=[..._.targetLinks?.map(V=>V.sourceName)??[],...C,_.name];y.selectAll("text.label").filter(V=>!Q.includes(V.name)).style("opacity",.0625);const{enteringValue:rt,exitingValue:ft,nodeState:xt,stateColor:et}=tt(_);D.style("opacity",1),D.select("p.title").text(_.name+" :"),D.select("p.top-label").style("display","block").text("in "+Et(rt,e)),D.select("p.bottom-label").style("display","block").text("out "+Et(ft,e)),D.select("p.small-text").style("display","block").text(`${xt}`).style("color",`${et}`)}).on("mousemove",(d,_)=>{gr(d,D)}).on("mouseout",(d,_)=>{D.style("opacity",0),D.select("p.small-text").style("display","none"),y.selectAll("path.link").style("stroke",function(rt){const ft=rt;return`url(#${H.filter(V=>V.sourceName===ft.sourceName&&V.targetName===ft.targetName).node()?.id})`}).style("stroke-opacity",.5).style("fill","none").attr("class",`link ${st.sankeyEnergyLink}`);const C=_.sourceLinks?.map(rt=>rt.targetName)??[],Q=[..._.targetLinks?.map(rt=>rt.sourceName)??[],...C,_.name];y.selectAll("text.label").filter(rt=>!Q.includes(rt.name)).style("opacity",1)}).transition().duration(L).delay(it).attr("stroke-width",v?2:2.5).style("stroke",function(d){const{stateColor:_,nodeState:C}=tt(d);return C==="surplus"||C==="minus"?_:"#52525b"}).attr("opacity",1).attr("x",d=>d.x0).attr("y",d=>d.y0).attr("height",d=>Math.abs(d.y1-d.y0)).attr("width",d=>d.x1-d.x0).attr("fill",d=>{const _=W.current.findIndex(C=>C===d.name);return Ft(_,!1)}),y.selectAll("text.label").data(E,d=>d.name).join(d=>d.append("text").attr("class",`label ${Uo.sankeyLabel}`).attr("x",_=>_.x0<A/2?_.x1+6:_.x0-6).attr("y",_=>(_.y1+_.y0)/2).attr("dy","0.35em").attr("text-anchor",_=>_.x0<A/2?"start":"end").style("font-size",A<648?"12px":"16px").style("font-weight",A<648?"normal":"bold").style("stroke-width",A<648?"0px":"0.25px").style("stroke","#eff1f4").text(_=>_.name).attr("opacity",0),void 0,d=>d.remove()).style("font-size",A<648?"12px":"16px").style("font-weight",A<648?"normal":"bold").style("stroke-width",A<648?"0px":"0.25px").transition().duration(L).delay(it).attr("x",d=>d.x0<A/2?d.x1+6:d.x0-6).attr("y",d=>(d.y1+d.y0)/2).attr("dy","0.35em").attr("text-anchor",d=>d.x0<A/2?"start":"end").attr("opacity",1)},[n,a,o,p,k,e]);return $.jsx("div",{ref:f,style:{width:p,height:k,display:"flex",flexDirection:"column"},children:$.jsxs("div",{ref:x,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[$.jsx("svg",{className:`${st["chart-svg"]} ${st["fill-container"]}`,viewBox:`0 0 ${p} ${k}`,children:$.jsx("g",{className:"plot-area"})}),$.jsxs("div",{style:{position:"absolute",right:"12px",top:"6px",display:"flex",alignItems:"center"},children:[$.jsxs("label",{className:st["controls-label"],children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:a,onChange:M=>{const j=M.target.checked;j&&(u.current="sort link"),i(j)}}),"Sort link"]}),$.jsxs("label",{className:st["controls-label"],children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:o,onChange:M=>{const j=M.target.checked;j&&(u.current="sort node"),s(j)}}),"Sort node"]})]}),$.jsx(Xe,{pCount:4})]})})}function u0(t,e){return e.value-t.value}function f0(t){return t.children}function h0(t){return t.value}function d0(t,e){return t.value-e.value}function Ge(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 o=0;o<i.length;o++)n.push(i[o])}for(;a=r.pop();)e(a)}const p0=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 g0(t){return p0(t.map(e=>(e.children||[]).map(n=>({source:e,target:n}))))}function m0(t,e,n){return function(...r){const a=n.apply(e,r);return a===e?t:a}}function y0(t,e,...n){for(let r=0;r<n.length;r++){const a=n[r];t[a]=m0(t,e,e[a])}return t}function x0(t,e){return y0(t,e,"sort","children","value"),t.nodes=t,t.links=g0,t}function v0(){let t=u0,e=f0,n=h0;function r(a){const i=[a],o=[];let s;for(a.depth=0;s=i.pop();){o.push(s);const c=e.call(r,s,s.depth);if(c&&c.length){for(let l=c.length-1;l>=0;l--){const u=c[l];i.push(u),u.parent=s,u.depth=(s.depth||0)+1}n&&(s.value=0),s.children=c}else n&&(s.value=+n.call(r,s,s.depth||0)||0),delete s.children}return Ge(a,c=>{t&&c.children&&c.children.sort(t),n&&c.parent&&(c.parent.value+=c.value)}),o}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 _0(t){delete t._pack_next,delete t._pack_prev}function b0(t){t._pack_next=t._pack_prev=t}function Oo(t,e,n){let r=t.r+n.r,a=e.x-t.x,i=e.y-t.y;if(r&&(a||i)){let o=e.r+n.r,s=a*a+i*i;o*=o,r*=r;const c=.5+(r-o)/(2*s),l=Math.sqrt(Math.max(0,2*o*(r+s)-(r-=s)*r-o*o))/(2*s);n.x=t.x+c*a+l*i,n.y=t.y+c*i-l*a}else n.x=t.x+r,n.y=t.y}function Yo(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++)Yo(a[i],t.x,t.y,r)}function Aa(t,e){const n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Wo(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 Vo(t,e){t._pack_next=e,e._pack_prev=t}function Bo(t){const e=t.children;if(e&&e.length){let n=1/0,r=-1/0,a=1/0,i=-1/0;const o=f=>{n=Math.min(f.x-f.r,n),r=Math.max(f.x+f.r,r),a=Math.min(f.y-f.r,a),i=Math.max(f.y+f.r,i)};e.forEach(b0);let s=e[0];if(s.x=-s.r,s.y=0,o(s),e.length>1){let f=e[1];if(f.x=f.r,f.y=0,o(f),e.length>2){let h=e[2];Oo(s,f,h),o(h),Aa(s,h),s._pack_prev=h,Aa(h,f),f=s._pack_next;for(let p=3;p<e.length;p++){Oo(s,f,h=e[p]);let k=0,W=1,b=1;for(let v=f._pack_next;v!==f;v=v._pack_next,W++)if(Wo(v,h)){k=1;break}if(k===1)for(let v=s._pack_prev;v!==e[p-1]._pack_prev&&!Wo(v,h);v=v._pack_prev,b++);k?(b>W||W===b&&f.r<s.r?Vo(s,f=f._pack_next):Vo(s=s._pack_prev,f),p--):(Aa(s,h),f=h,o(h))}}}const c=(n+r)/2,l=(a+i)/2;let u=0;for(let f=0;f<e.length;f++){const h=e[f];h.x-=c,h.y-=l,u=Math.max(u,h.r+Math.sqrt(h.x*h.x+h.y*h.y))}t.r=u,e.forEach(_0)}}function w0(){let t,e=v0().sort(d0),n=0,r=[1,1];function a(i,o){const s=e(i,o),c=s[0],l=r[0],u=r[1],f=t==null?Math.sqrt:typeof t=="function"?t:()=>t;if(c.x=c.y=0,Ge(c,h=>{h.r=+f(h.value)}),Ge(c,Bo),n){const h=n*(t?1:Math.max(2*c.r/l,2*c.r/u))/2;Ge(c,p=>{p.r+=h}),Ge(c,Bo),Ge(c,p=>{p.r-=h})}return Yo(c,l/2,u/2,t?1:1/Math.max(2*c.r/l,2*c.r/u)),s}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},x0(a,e)}const ve={node:"_node_1x526_1","node--leaf":"_node--leaf_1x526_19",circle_pack_label:"_circle_pack_label_1x526_27","node--root":"_node--root_1x526_73",glass_card:"_glass_card_1x526_205"};function k0(t){const e=new Map;for(const n of t)e.set(n.name,n);return e}function Xo(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)Xo(r,e)}function S0({data:t,tooltipFormat:e}){const[n,r]=ut.useState(null),[a,i]=ut.useState(!1),[o,s]=ut.useState({name:"",value:0}),[c,l]=ut.useState({name:"",value:0}),u=ut.useRef(!0),[f,h]=ge(),{width:p,height:k}=h,W=ut.useRef(null),b=ut.useRef(null);ut.useEffect(()=>{if(!b.current||!W.current)return;const x=W.current;function M(N,z){const Y=Math.max(N.length,z.length);return function(B){let Z="";for(let A=0;A<Y;A++)Z+=B<.5?N[A]??"":z[A]??"";return Z}}At(x).transition().duration(250).tween("text",function(){const N=M(c.name,o.name);return function(z){x.textContent=N(z)}});const j=b.current;At(j).transition().duration(250).ease(Wu).tween("text",function(){const N=qt(c.value,o.value);return function(z){j.textContent=Et(Math.round(N(z)),e).toLocaleString()}})},[o,c]),ut.useEffect(()=>{r(x=>(x!==null&&(u.current=!1),t))},[t]);const v=1e3,L=Kt(x=>{if(!n)return;const M=p,j=k,N=12,z=1.5;if(M===0||j===0)return;const Y=25,B=j-Y*2,Z=M-Y*2,A=B,X=Z,S={name:"branches",children:n},P=Math.min(X,A),y=aa(Ot(S)).sum(function(V){return V.value}).sort(function(V,at){return V.value-at.value}),D=th().size([P-Y,P-Y]).padding(2),I=w0().padding(2).size([P-Y,P-Y]).value(function(V){return V.value}).nodes(Ot(S));let m=y,E=1,g=1;const H=D(y),K=H.descendants(),J=[H.x,H.y,H.r*2+Y],ct=k0(I);Xo(K[0],ct);const it=x.select("#tooltip").style("opacity",0),O=x.select("svg");O.node();const tt=O.select(".plot-area"),d=Gt().domain([-1,2]).range(["#34d399","#6b21a8"]).interpolate(Pc);function _(V){const at=P/J[2];return(a?V.sortedR??0:V.r)*at}function C(V){const at=P/J[2];return((a?V.sortedX??0:V.x)-J[0])*at}function w(V){const at=P/J[2];return((a?V.sortedY??0:V.y)-J[1])*at}const Q=tt.selectAll("circle").data(K,V=>V.data.name).join(V=>V.append("circle").attr("class",function(at){return at.parent?at.children?ve.node:`${ve.node} ${ve["node--leaf"]}`:`${ve.node} ${ve["node--root"]}`}).style("fill",function(at){return at.children?d(at.depth):"#f0fdfa"}).style("cursor","pointer").transition().duration(v).attr("r",_).attr("cx",C).attr("cy",w).style("stroke","#737373").style("stroke-width",z*g).style("fill",function(at){return at.children?d(at.depth):"#f0fdfa"}),V=>V.transition().duration(v).attr("cx",C).attr("cy",w).attr("r",_).style("stroke",function(at){return"#737373"}).style("stroke-width",z*g).style("fill",function(at){return at.children?d(at.depth):"#f0fdfa"}),V=>V.transition().duration(v).style("opacity",0).remove()).on("mouseover",function(V,at){m.parent===at?ft.filter(function(R){return R.parent===m||this.style.display==="inline"}).style("font-size",N*g).style("fill-opacity",function(R){return R.parent===m?1:0}).style("display",function(R){return R.parent===m?"inline":"none"}):at===m?ft.filter(function(R){return R.parent===m||this.style.display==="inline"}).style("font-size",N*g).style("fill-opacity",function(R){return R.parent===m?1:0}).style("display",function(R){return R.parent===m?"inline":"none"}):(ft.filter(function(R){if(a){const lt=at;return R.name!==lt.name}return R.data.name!=at.data.name}).style("fill-opacity",0).style("display","none"),ft.filter(function(R){if(a){const lt=at;return R.name!==lt.name}return R.data.name===at.data.name}).style("fill-opacity",1).style("display","inline")),At(this).style("stroke"),at!=y&&At(this).style("stroke-width",z*g*2.5).style("stroke","#e4e4e7"),it.transition().duration(250).style("opacity",1),s(R=>{l(R);const lt=at.data.name;return{name:lt==="branches"?"Total":lt,value:at.value?at.value:0}})}).on("mouseout",function(V,at){ft.filter(function(R){return R.parent===m||this.style.display==="inline"}).style("fill-opacity",function(R){return R.parent===m?1:0}).style("display",function(R){return R.parent===m?"inline":"none"}),At(this).style("stroke-width",z*g).style("stroke",function(R){return"#737373"}),it.transition().duration(250).style("opacity",0)}).on("click",function(V,at){if(at===y){et();return}m!=at?xt(at):et(),Q.style("stroke-width",z*g),V.stopPropagation()});function rt(V){const at=P/J[2],R=a?V.sortedX??0:V.x,lt=a?V.sortedY??0:V.y;return"translate("+(R-J[0])*at+","+(lt-J[1])*at+")"}const ft=tt.selectAll("text").data(K,V=>V.data.name).join(V=>V.append("text").attr("class",ve.circle_pack_label).text(at=>at.data.name).style("font-size",N).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(v).attr("transform",rt).style("fill-opacity",function(at){return at.parent===y?1:0}).style("display",function(at){return at.parent===y?"inline":"none"}),V=>V.attr("class",ve.circle_pack_label).transition().duration(v).attr("transform",rt).style("fill-opacity",function(at){return at.parent===y?1:0}).style("display",function(at){return at.parent===y?"inline":"none"}),V=>V.transition().duration(v).style("opacity",0).remove());ft.raise();function xt(V){m=V;const at=P/2-Y,R=M/2,lt=j/2,nt=P/J[2],F=V.r*nt;g=F/at,E=at/F;const pt=((a?V.sortedX??0:V.x)-J[0])*nt,vt=R-pt*E,St=((a?V.sortedY??0:V.y)-J[0])*nt,Tt=lt-St*E;tt.transition().duration(1e3).attr("transform","translate("+vt+","+Tt+")scale("+E+")"),ft.style("font-size",N*g+"px").filter(function(Mt){return Mt.parent===m||this.style.display==="inline"}).style("fill-opacity",function(Mt){return Mt.parent===m?1:0}).style("display",function(Mt){return Mt.parent===m?"inline":"none"})}function et(){tt.transition().duration(v).attr("transform","translate("+M/2+", "+j/2+")scale(1)"),m=y,E=1,g=1,ft.style("font-size",N*g+"px").filter(function(V){return V.parent===m||this.style.display==="inline"}).style("fill-opacity",function(V){return V.parent===m?1:0}).style("display",function(V){return V.parent===m?"inline":"none"})}et()},[n,p,k,a]);return $.jsx("div",{ref:f,style:{width:p,height:k,display:"flex",flexDirection:"column"},children:$.jsxs("div",{ref:L,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[$.jsx("svg",{className:`${st["chart-svg"]} ${st["fill-container"]}`,viewBox:`0 0 ${p} ${k}`,children:$.jsx("g",{className:"plot-area"})}),$.jsxs("div",{id:"tooltip",className:`${ve.glass_card}`,style:{position:"absolute",left:2,top:2,fontSize:12,fontWeight:600,display:"flex",alignItems:"center",gap:2},children:[$.jsx("p",{ref:W,id:"name",style:{padding:0,margin:0},children:"Test tooltip"}),$.jsx("p",{ref:b,id:"value",style:{padding:0,margin:0},children:"Test tooltip"})]}),$.jsxs("label",{className:st["controls-label"],style:{position:"absolute",right:"12px",top:"6px"},children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:a,onChange:x=>i(x.target.checked)}),"Sort"]})]})})}const M0=({size:t=24,color:e="#0099ff",...n})=>$.jsx("svg",{viewBox:"0 0 64 64",width:t,height:t,xmlns:"http://www.w3.org/2000/svg",...n,children:$.jsxs("g",{fill:e,children:[$.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
18
+ `};st.selectAll(".legend-item").data([...H],ft=>ft).join(ft=>{const Mt=ft.append("div").attr("class",D).style("left",(it,mt)=>`${mt*B}px`).style("top","-53px").style("opacity",0);return Mt.append("div").attr("class",Ft["legend-rect"]).style("background",it=>{if(T.includes(it))return Ee;const mt=I.current.findIndex(F=>F===it)+e;return de(mt)}),Mt.append("span").attr("class",Ft["legend-label"]).text(it=>it),Mt.transition().duration(_).style("top","0px").style("opacity",1),Mt},ft=>(ft.attr("class",D).transition().duration(_).style("top","0px").style("left",(Mt,it)=>`${it*B}px`).style("opacity",1).select(`.${Ft["legend-rect"]}`).style("background",Mt=>{if(T.includes(Mt))return Ee;const it=I.current.findIndex(mt=>mt===Mt)+e;return de(it)}),ft.select(`.${Ft["legend-label"]}`).text(Mt=>Mt),ft),ft=>ft.transition().duration(_).style("opacity",0).style("top","53px").remove().remove().remove()).on("pointerenter",(ft,Mt)=>{_t.selectAll(".serie").attr("fill",X).filter(it=>it.key===Mt).style("opacity",.25)}).on("pointerleave",function(ft,Mt){_t.selectAll(".serie").attr("fill",X).filter(it=>it.key===Mt).style("opacity",1)}).on("click",function(ft,Mt){p(it=>{let mt=[];return it.includes(Mt)?mt=it.filter(F=>F!==Mt):mt=[...it,Mt],mt})});const L=Y.select("div#tooltip").style("opacity",0),Z=!N&&n==="vertical"?Ft.rotatedAxisText:Ft.axisText,ht=q.map(function(ft){return ft.label}),ot=Oe().domain(ht).rangeRound(n==="vertical"?[0,$]:[pt,0]).paddingInner(N?.4:.25).paddingOuter(.2).align(.2),at=Zt(R,ft=>ft.total),A=ye().domain([0,x?1:at||0]).nice().range(n==="vertical"?[pt,0]:[0,$]),j=Oe().rangeRound([0,$]).paddingInner(.1).align(.2),nt=q.map(function(ft){return ft.label});j.domain(nt);const Nt=[],O=n==="vertical"?he(ot).tickValues(ot.domain()).tickSizeOuter(0):he(A).ticks(10,x?".0%":"s").tickSizeOuter(0).tickSize(-pt);_t.select(".x-axis").attr("transform",`translate(0,${pt})`).transition().duration(_).call(O).selectAll("text").style("cursor","pointer").attr("dy",N?"1em":".20em").attr("dx",N?"0em":"-.8em").attr("class",Z).selectAll(".tick").filter(ft=>ft===0).select("line").remove();const K=Zt(R,ft=>ft.total),$t=ye().domain([0,x?1:K||0]).nice().range([pt,0]),zt=n==="vertical"?be(A).ticks(10,x?".0%":"s").tickSize(-$):be(ot).tickSizeOuter(0);_t.select(".y-axis").attr("transform","translate(0,0)").transition().duration(_).call(zt).selectAll(".tick").filter(ft=>ft===0).select("line").remove();const Tt=na().keys(W).order(ui).offset(x?Yc:ea)(q).map(ft=>{const Mt=ft.key,it=ft.map(mt=>{const F=mt.data.label;return{...mt,key:`${Mt} - ${F}`,barKey:Mt}});return it.key=Mt,it});let ut=_t.selectAll(".serie").data(Tt,function(ft){return ft.key}).join(ft=>ft.append("g").attr("class","serie").attr("fill",X).style("opacity",1).style("pointer-events","auto"),ft=>ft.transition().duration(_).attr("fill",X).style("opacity",1).style("pointer-events","auto"),ft=>ft.transition().duration(_).style("opacity",0).attr("fill",Ee).selectAll("rect").attr("y",pt).attr("height",0).remove());const vt=ft=>ot(ft.data.label+"")??0,kt=ot.bandwidth(),jt=ft=>A(n==="vertical"?ft[1]:ft[0]),Xt=ft=>{const Mt=n==="vertical"?A(ft[0])-A(ft[1]):A(ft[1])-A(ft[0]);return isNaN(Mt)||Mt<0?0:Mt},ie=ft=>n==="vertical"?vt(ft):jt(ft),Jt=ft=>n==="vertical"?kt:Xt(ft),Ht=ft=>n==="vertical"?jt(ft):vt(ft),Gt=ft=>n==="vertical"?Xt(ft):kt;function ae(ft){const Mt=Jt(ft),it=Gt(ft);return W.indexOf(ft.barKey)===W.length-1||ft.barKey===T[0]?n==="vertical"?`${Mt+it} ${Mt} ${it}`:`${Mt+it+Mt}`:n==="vertical"?`${it} ${Mt}`:`${Mt} ${it}`}function Ct(ft){const Mt=Jt(ft),it=W.indexOf(ft.barKey)===W.length-1;return n==="vertical"?it?0:Mt*-1:0}const Rt=ft=>`rect ${Ft.rect}`;ut.selectAll("rect").data(ft=>ft,ft=>ft.data.label).join(ft=>{let Mt;return Mt=ft.append("rect").attr("class",Rt).attr("x",function(it){return n==="vertical"?j(it.data.label+"")??0:A(0)}).attr("width",function(it){return n==="vertical"?ot.bandwidth():0}).attr("y",function(it){if(n==="vertical"){if(!Nt.includes(it.data.label+""))return pt;const mt=A(it[1]),F=A(it[0])-A(it[1]),yt=isNaN(F)||F<0?0:F;return mt+yt}else return Ht(it)}).attr("height",function(it){return n==="vertical"?0:Gt(it)}).attr("stroke-dasharray",ae).attr("stroke-dashoffset",Ct).transition().duration(_).attr("x",ie).attr("width",Jt).attr("height",Gt).attr("y",Ht),Mt},void 0,ft=>ft.transition().duration(_).attr("opacity",0).attr("height",0).attr("y",pt).remove()).attr("class",Rt).attr("stroke-dasharray",ae).attr("stroke-dashoffset",Ct).transition().duration(_).attr("x",ie).attr("width",Jt).attr("height",Gt).attr("y",Ht),ut.selectAll("rect").on("pointerenter",function(ft,Mt){_t.select(".x-axis").selectAll("text").filter(At=>At===Mt.data.name).attr("class",Z+" "+J.hoveredAxisText),L.style("opacity",1);const it=Mt.data[Mt.barKey]||0,mt=Mt.data.total||0,F=it/mt*100,yt=pe(".1f")(F)+"%";L.select("p.label").text(Mt.data.label),L.select("p.layer span.label span.chev").style("background",Q(Mt.barKey)),L.select("p.layer span.label span.label").text(Mt.barKey),L.select("p.layer span.value").text(yt),L.select("p.total span.value").text(`(${Pe(it,U)} of ${Pe(mt,U)})`),le(L,{e:ft,svg:gt,yScale:$t})}).on("touch",function(ft,Mt){te(".x-axis").selectAll("text").filter(it=>it===Mt.data.label).attr("class",Z)}).on("pointermove",(ft,Mt)=>{le(L,{e:ft,svg:gt,yScale:$t})}).on("pointerleave",function(ft,Mt){_t.select(".x-axis").selectAll("text").filter(it=>it===Mt.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 ${Ft["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"?Ft["value-axis"]:""} y-axis`}),m.jsx("g",{className:`${n==="horizontal"?Ft["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(W=>W!=="label"&&W!=="total"),Y=rn(M),C=d>576,H=Se(W=>{if(d===0||x===0)return;const V={top:20,right:30,bottom:30,left:30},q=u.current,$=N.length===0?[]:Object.keys(N[0]).filter(lt=>lt!=="label"&&lt!=="total"),pt=a?$:$.filter(lt=>!y.includes(lt));N.forEach(function(lt){const xt=pt.reduce((St,Wt)=>{Wt in lt||(lt[Wt]=0);const ue=lt[Wt],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=xt.total,lt.totalPos=xt.totalPos,lt.totalMin=xt.totalMin});const wt=N,gt=_&&(n==="stacked"||n==="grouped"&&(a&&y[0]!=="all"||!a&&pt.length===1))?we(wt).sort(function(lt,xt){return a?y[0]==="all"?lt.total-xt.total:Number(lt[y[0]])-Number(xt[y[0]]):lt.total-xt.total}):wt,_t=d-V.left-V.right,G=x-V.top-V.bottom,st=W.select("svg"),B=st.node(),Q=st.select(".plot-area").attr("transform","translate("+V.left+","+V.top+")"),D=W.select(".controls").select(".legends-container"),tt=function(lt){const xt=Ft[C?"legend-container":"legend-container-sm"],St=Ft[C?"legend-container-active":"legend-container-active-sm"],Wt=Ft[C?"legend-container-inactive":"legend-container-inactive-sm"];return`
19
+ ${y.includes(lt)?a?St:Wt:xt}
20
+ legend-item
21
+ `},L=lt=>{const xt=Y.current.findIndex(Wt=>Wt===lt)+e;return de(xt)};function Z(lt){return L(lt.key)}const ht=C?80:50;D.selectAll(".legend-item").data([...$],lt=>lt).join(lt=>{const xt=lt.append("div").attr("class",tt).style("left",(St,Wt)=>`${Wt*ht}px`).style("top","-53px").style("opacity",0);return xt.append("div").attr("class",Ft["legend-rect"]).style("background",St=>{if(!a&&y.includes(St))return Ee;const Wt=Y.current.findIndex(ue=>ue===St)+e;return de(Wt)}),xt.append("span").attr("class",Ft["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*ht}px`).style("opacity",1).select(`.${Ft["legend-rect"]}`).style("background",xt=>{if(!a&&y.includes(xt))return Ee;const St=Y.current.findIndex(Wt=>Wt===xt)+e;return de(St)}),lt.select(`.${Ft["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(Wt=>Wt.key!==xt).transition().duration(250).style("opacity",.25),St.selectAll("rect").filter(Wt=>Wt.barKey===xt).attr("stroke-dasharray","none")):St.attr("fill",Z).filter(Wt=>Wt.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",yt)}).on("click",(lt,xt)=>{n==="percentage"&&a||(T(St=>{let Wt=[];return a?St[0]===xt?Wt=["all"]:Wt=[xt]:St.includes(xt)?Wt=St.filter(ue=>ue!==xt):Wt=[...St,xt],Wt}),k(!0))});const ot=gt.map(function(lt){return lt.label}),at=S?.map(lt=>lt.name)??[];let A=!1;S===null&&(A=!0,w(we(N)));const j=Oe().rangeRound(r==="vertical"?[0,_t]:[G,0]).domain(ot).paddingInner(n!=="grouped"||n==="grouped"&&(a&&y[0]!=="all"||!a&&pt.length===1)?C?.4:.25:.1).paddingOuter(.2).align(.2),nt=a&&y[0]!=="all"||pt.length===1,Nt=n==="stacked"||n==="percentage",O=n==="stacked"?a?y[0]==="all"?Zt(N,lt=>lt.totalPos):Zt(N,lt=>lt[y[0]]):Zt(N,lt=>lt.totalPos):n==="grouped"?y[0]==="all"?Zt(N,lt=>Zt(Object.entries(lt).filter(([xt])=>xt!=="total"&&xt!=="label"&&xt!=="totalPos"&&xt!=="totalMin").map(([,xt])=>xt))):Zt(N,lt=>lt[y[0]]):1,K=Math.max(0,O??0),$t=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,zt=Math.min(0,$t??0),et=ye().domain([zt,K]).range(r==="vertical"?[G,0]:[0,_t]).nice(),Tt=!C&&r==="vertical"?Ft.rotatedAxisText:Ft.axisText,ut=r==="vertical"?he(j).tickValues(j.domain()).tickSizeOuter(0):he(et).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(et).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, ${et(0)||0})`:`translate(${et(0)||0}, 0)`);const kt=W.select("div#tooltip").style("opacity",0),Xt=na().keys(pt).offset(n!=="percentage"?Es:Yc)(gt).map(lt=>{const xt=lt.key,St=lt.map(Wt=>{const ue=Object.keys(Wt.data).filter(Ut=>Ut!=="label"&&Ut!=="total"&&Ut!=="totalPos"&&Ut!=="totalMin"&&(a?!0:!y.includes(Ut))).map(Ut=>({label:Ut,value:Wt.data[Ut]})).sort((Ut,ke)=>Number(Ut.value)-Number(ke.value));return{...Wt,key:`${xt} - ${Wt.data.label}`,barKey:xt,data:{...Wt.data,sortedLayers:ue.map(Ut=>Ut.label)}}});return St.key=xt,St}),ie=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()),Jt=lt=>`rect ${Ft.rect}`,Ht=gt.map((lt,xt)=>{const St=Xt.map(Ut=>({key:Ut.key,start:Ut[xt][0],end:Ut[xt][1],value:lt[Ut.key]})),Wt=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:Wt.length>0?Wt[0]?.key:ue[ue.length-1]?.key,bottom:ue.length>0?ue[0]?.key:Wt[Wt.length-1]?.key}});function Gt(lt){const xt=j(lt.data.label)??0;if(n==="grouped"&&(!a||a&&y[0]==="all")){const Wt=(_?lt.data.sortedLayers:pt).indexOf(lt.barKey);return xt+Wt*(j.bandwidth()/pt.length)}return xt}function ae(lt){return n==="grouped"&&(!a||a&&y[0]==="all")?j.bandwidth()/pt.length:j.bandwidth()}function Ct(lt){if(Nt)if(nt){const xt=Number(lt.data[lt.barKey]);return r==="vertical"?xt>=0?et(xt):et(0):xt>=0?et(0):et(xt)}else{const xt=r==="vertical"?G:_t;return y[0]==="all"?et(r==="vertical"?lt[1]:lt[0]):a&&r!=="vertical"?et(0):xt-(et(lt[0])-et(lt[1]))}else{const xt=Number(lt.data[lt.barKey]);return r==="vertical"?xt>=0?et(xt):et(0):xt>=0?et(0):et(xt)}}function Rt(lt){if(Nt)if(nt){const xt=Number(lt.data[lt.barKey]),St=Math.abs(et(xt)-et(0));return isNaN(St)||St<0?0:St}else{const xt=r==="vertical"?et(lt[0])-et(lt[1]):et(lt[1])-et(lt[0]);return isNaN(xt)||xt<0?0:xt}else{const xt=Number(lt.data[lt.barKey]),St=Math.abs(et(xt)-et(0));return isNaN(St)||St<0?0:St}}const ft=q==="stacked"||q==="percentage",Mt=lt=>r==="vertical"?Gt(lt):Ct(lt),it=lt=>r==="vertical"?ae():Rt(lt),mt=lt=>r==="vertical"?Ct(lt):Gt(lt),F=lt=>r==="vertical"?Rt(lt):ae();function yt(lt){if(n==="grouped"||nt)return"none";const xt=it(lt),St=F(lt),Wt=Ht.find(hn=>hn.label===lt.data.label),ue=lt.data[lt.barKey],Ut=Wt?.top===lt.barKey&&Number(ue)>=0,ke=Wt?.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 At(lt){const xt=it(lt),St=Ht.find(ke=>ke.label===lt.data.label),Wt=lt.data[lt.barKey],ue=St?.top===lt.barKey&&Number(Wt)>=0;return St?.bottom===lt.barKey&&Number(Wt)<0?r==="vertical"?xt*-1:0:r==="vertical"?ue?0:xt*-1:0}ie.selectAll("rect").data(lt=>lt,lt=>lt.data.label).join(lt=>Nt&&ft||!Nt&&!ft?lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:at.includes(St.data.label)?Ct(St)+Rt(St):et(0)}).attr("width",r==="vertical"?j.bandwidth():0).attr("y",function(St){return r==="vertical"?at.includes(St.data.label)?Ct(St)+Rt(St):et(0):j(St.data.label)??0}).attr("height",r==="vertical"?0:j.bandwidth()).attr("stroke-dasharray",yt).attr("stroke-dashoffset",At).transition().duration(z).attr("x",Mt).attr("width",it).attr("height",F).attr("y",mt):ft&&!Nt?lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:et(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",yt).attr("stroke-dashoffset",At).transition().duration(z).attr("x",Mt).attr("width",it).attr("height",F).transition().duration(z).attr("y",mt):!ft&&Nt?lt.append("rect").attr("class",J.rect).attr("x",function(St){return r==="vertical"?j(St.data.label)??0:et(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",yt).attr("stroke-dashoffset",At).transition().duration(z).attr("y",mt).transition().duration(z).attr("x",Mt).attr("width",it).attr("height",F):lt,void 0,lt=>lt.attr("opacity",0).style("fill","grey").remove()).on("pointerenter",function(lt,xt){n==="grouped"&&_&&ie.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:"")+" "+Ft.hoveredAxisText),kt.style("opacity",1);const St=xt.data[xt.barKey],Wt=xt.data.total??0,ue=St/Wt*100,Ut=pe(".1f")(ue)+"%";kt.select("p.label").text(xt.data.label),kt.select("p.layer span.label span.chev").style("background",L(xt.barKey)),kt.select("p.layer span.label span.label").text(xt.barKey),kt.select("p.layer span.value").text(n==="percentage"?Ut:_e(St,U)),kt.select("p.total span.value").text(n==="percentage"?`(${Pe(St,U)} of ${Pe(Wt,U)})`:_e(Wt,U)),le(kt,{e:lt,svg:B,yScale:et})}).on("pointermove",(lt,xt)=>{le(kt,{e:lt,svg:B,yScale:et})}).on("pointerleave",function(lt,xt){n==="grouped"&&_&&ie.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:""),kt.style("opacity",0)});function Pt(){ie.selectAll("rect").attr("class",Jt).transition().duration(z).attr("stroke-dasharray",yt).attr("stroke-dashoffset",At).attr("x",Mt).attr("width",it).attr("height",F).attr("y",mt)}function ee(){ie.selectAll("rect").attr("class",Jt).transition().duration(z).attr("x",Mt).attr("width",it).transition().duration(z).attr("stroke-dasharray",yt).attr("stroke-dashoffset",At).attr("height",F).attr("y",mt)}function re(){ie.selectAll("rect").attr("class",Jt).transition().duration(z).attr("y",mt).attr("height",F).transition().duration(z).attr("stroke-dasharray",yt).attr("stroke-dashoffset",At).attr("x",Mt).attr("width",it)}n===q?Pt():Nt?ft?Pt():r==="vertical"?re():ee():ft?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:H,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:W=>E(W.target.checked),disabled:n==="percentage"}),"Sort"]}),m.jsx("div",{className:`legends-container ${Ft["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"?Ft["value-axis"]:Ft["label-axis"]}
22
+ y-axis`}),m.jsx("g",{className:`${r==="horizontal"?Ft["value-axis"]:Ft["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[H,W]of M.entries())W.index=H,W.sourceLinks=[],W.targetLinks=[];const C=new Map(M.map((H,W)=>[o(H,W,M),H]));for(const[H,W]of Y.entries()){W.index=H;let{source:V,target:q}=W;typeof V!="object"&&(V=W.source=Jc(C,V)),typeof q!="object"&&(q=W.target=Jc(C,q)),V.sourceLinks.push(W),q.targetLinks.push(W)}if(u!=null)for(const{sourceLinks:H,targetLinks:W}of M)H.sort(u),W.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),H=new Set,W=0;for(;C.size;){for(const V of C){V.depth=W;for(const{target:q}of V.sourceLinks)H.add(q)}if(++W>Y)throw new Error("circular link");C=H,H=new Set}}function S({nodes:M}){const Y=M.length;let C=new Set(M),H=new Set,W=0;for(;C.size;){for(const V of C){V.height=W;for(const{source:q}of V.targetLinks)H.add(q)}if(++W>Y)throw new Error("circular link");C=H,H=new Set}}function w({nodes:M}){const Y=Xc(M,W=>W.depth)+1,C=(n-t-a)/(Y-1),H=new Array(Y);for(const W of M){const V=Math.max(0,Math.min(Y-1,Math.floor(l.call(null,W,Y))));W.layer=V,W.x0=t+V*C,W.x1=W.x0+a,H[V]?H[V].push(W):H[V]=[W]}if(c)for(const W of H)W.sort(c);return H}function y(M){const Y=Kc(M,C=>(r-e-(C.length-1)*s)/zs(C,Is));for(const C of M){let H=e;for(const W of C){W.y0=H,W.y1=H+W.value*Y,H=W.y1+s;for(const V of W.sourceLinks)V.width=V.value*Y}H=(r-H+s)/(C.length+1);for(let W=0;W<C.length;++W){const V=C[W];V.y0+=H*(W+1),V.y1+=H*(W+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 H=Math.pow(.99,C),W=Math.max(1-H,(C+1)/g);k(Y,H,W),p(Y,H,W)}}function p(M,Y,C){for(let H=1,W=M.length;H<W;++H){const V=M[H];for(const q of V){let $=0,pt=0;for(const{source:gt,value:_t}of q.targetLinks){let G=_t*(q.layer-gt.layer);$+=N(gt,q)*G,pt+=G}if(!(pt>0))continue;let wt=($/pt-q.y0)*Y;q.y0+=wt,q.y1+=wt,z(q)}c===void 0&&V.sort(yi),_(V,C)}}function k(M,Y,C){for(let H=M.length,W=H-2;W>=0;--W){const V=M[W];for(const q of V){let $=0,pt=0;for(const{target:gt,value:_t}of q.sourceLinks){let G=_t*(gt.layer-q.layer);$+=U(q,gt)*G,pt+=G}if(!(pt>0))continue;let wt=($/pt-q.y0)*Y;q.y0+=wt,q.y1+=wt,z(q)}c===void 0&&V.sort(yi),_(V,C)}}function _(M,Y){const C=M.length>>1,H=M[C];R(M,H.y0-s,C-1,Y),E(M,H.y1+s,C+1,Y),R(M,r,M.length-1,Y),E(M,e,0,Y)}function E(M,Y,C,H){for(;C<M.length;++C){const W=M[C],V=(Y-W.y0)*H;V>1e-6&&(W.y0+=V,W.y1+=V),Y=W.y1+s}}function R(M,Y,C,H){for(;C>=0;--C){const W=M[C],V=(W.y1-Y)*H;V>1e-6&&(W.y0-=V,W.y1-=V),Y=W.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:H,width:W}of M.sourceLinks){if(H===Y)break;C+=W+s}for(const{source:H,width:W}of Y.targetLinks){if(H===M)break;C-=W}return C}function U(M,Y){let C=Y.y0-(Y.targetLinks.length-1)*s/2;for(const{source:H,width:W}of Y.targetLinks){if(H===M)break;C+=W+s}for(const{target:H,width:W}of M.sourceLinks){if(H===Y)break;C-=W}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 q=r*f/(V.length+1);Y=q<Y?q: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 H=x(p),W=S(p,H);C=C*W,p.links.forEach(function(V){V.width=V.value*C}),E.forEach(function(V){var q=V.length;V.forEach(function($,pt){$.depth==E.length-1&&q==1||$.depth==0&&q==1?($.y0=r/2-$.value*C,$.y1=$.y0+$.value*C):$.partOfCycle?pu($,M)==0?($.y0=r/2+pt,$.y1=$.y0+$.value*C):$.circularLinkType=="top"?($.y0=e+pt,$.y1=$.y0+$.value*C):($.y0=r-$.value*C-pt,$.y1=$.y0+$.value*C):H.top==0||H.bottom==0?($.y0=(r-e)/q*pt,$.y1=$.y0+$.value*C):($.y0=(r-e)/2-q/2+pt,$.y1=$.y0+$.value*C)})})}function N(M,Y){var C=E.length;E.forEach(function(H){var W=H.length,V=H[0].depth;H.forEach(function(q){var $;if((q.sourceLinks.length||q.targetLinks.length)&&!(q.partOfCycle&&pu(q,Y)>0))if(V==0&&W==1)$=q.y1-q.y0,q.y0=r/2-$/2,q.y1=r/2+$/2;else if(V==C-1&&W==1)$=q.y1-q.y0,q.y0=r/2-$/2,q.y1=r/2+$/2;else{var pt=0,wt=au(q.sourceLinks,ym),gt=au(q.targetLinks,gm);wt&&gt?pt=(wt+gt)/2:pt=wt||gt;var _t=(pt-Zs(q))*M;q.y0+=_t,q.y1+=_t}})})}function U(){E.forEach(function(M){var Y,C,H=e,W=M.length,V;for(M.sort(Ks),V=0;V<W;++V)Y=M[V],C=H-Y.y0,C>0&&(Y.y0+=C,Y.y1+=C),H=Y.y1+i;if(C=H-i-r,C>0)for(H=Y.y0-=C,Y.y1-=C,V=W-2;V>=0;--V)Y=M[V],C=Y.y1+i-H,C>0&&(Y.y0-=C,Y.y1-=C),H=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,ht=n.nodes[L.target].name,ot=Z+" → "+ht;L.sourceName=Z,L.targetName=ht,L.id=ot});const C=k.select("svg");C.node();const H=C.select(".plot-area").attr("transform","translate("+R.left+","+R.top+")"),W=hi(k).style("opacity",0),V=L=>{const Z=L.targetLinks?.reduce((ot,at)=>ot+at.value,0)??0,ht=L.sourceLinks?.reduce((ot,at)=>ot+at.value,0)??0;return{enteringValue:Z,exitingValue:ht}},q=wm(),$=Vx().nodeAlign(Ox).nodeSort(s?(L,Z)=>{const{enteringValue:ht,exitingValue:ot}=V(L),{enteringValue:at,exitingValue:A}=V(Z);return Math.max(ht,ot)-Math.max(at,A)}:null).linkSort(a?(L,Z)=>L.value-Z.value:null),pt=x.hasCircularConnection||w.current?q:$;pt.nodeWidth(U<=540?8:U>540&&U<=768?12:15).nodePadding(U<=540?5:8).extent([[0,0],[U,N]]);const wt=pt({nodes:Y.map(L=>Object.assign({},L)),links:M.map(L=>Object.assign({},L))}),{nodes:gt,links:_t}=wt;H.selectAll("linearGradient").remove();const G=H.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(ht=>ht===L.sourceName);return de(Z,!1)}),G.append("stop").attr("offset","100%").attr("stop-color",L=>{const Z=b.current.findIndex(ht=>ht===L.targetName);return de(Z,!1)});const st=L=>{const Z=L.source,ht=L.target,ot=Math.abs(ht.depth-Z.depth);return U*1.5*ot},B=L=>st(L)+" "+st(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;H.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(at=>at.sourceName===Z.sourceName&&at.targetName===Z.targetName).node()?.id})`}).attr("stroke-dasharray",B).attr("stroke-dashoffset",st).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(){te(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(){te(this).attr("stroke-dasharray","none")}),L),L=>l.current?L.remove():L.transition().duration(T/4).style("opacity",0).remove()).on("pointerenter",(L,Z)=>{H.selectAll("path.link").filter(ht=>ht.id!==Z.id).style("stroke","#1f2937").style("stroke-opacity",.05),H.selectAll("text.label").filter(ht=>{const ot=ht;return ot.name!==Z.sourceName&&ot.name!==Z.targetName}).style("opacity",0),W.style("opacity",1),W.select("p.title").text(Z.id+Pe(Z.value,e)),W.select("p.top-label").style("display","none"),W.select("p.bottom-label").style("display","none"),Dn(L,W)}).on("pointermove",(L,Z)=>{Dn(L,W)}).on("pointerleave",(L,Z)=>{W.style("opacity",0),H.selectAll("path.link").style("stroke",function(ht){const ot=ht;return`url(#${G.filter(j=>j.sourceName===ot.sourceName&&j.targetName===ot.targetName).node()?.id})`}).style("stroke-opacity",.5).style("fill","none").attr("class",`link ${J.sankeyEnergyLink}`),H.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:ht}=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>ht?"surplus":Z<ht?"minus":"balanced",enteringValue:Z,exitingValue:ht}},tt=L=>{const{nodeState:Z,enteringValue:ht,exitingValue:ot}=D(L);return{enteringValue:ht,exitingValue:ot,nodeState:Z,stateColor:Z==="surplus"?"#4ade80":Z==="minus"?"#f87171":"#e7e7e7"}};H.selectAll("rect.node").data(gt,(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 ht=b.current.findIndex(ot=>ot===Z.name);return de(ht,!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)=>{H.selectAll("path.link").filter(O=>{const K=O;return!(K.sourceName===Z.name||K.targetName===Z.name)}).style("stroke","#1f2937").style("stroke-opacity",.05);const ht=Z.sourceLinks?.map(O=>O.targetName)??[],at=[...Z.targetLinks?.map(O=>O.sourceName)??[],...ht,Z.name];H.selectAll("text.label").filter(O=>!at.includes(O.name)).style("opacity",.0625);const{enteringValue:A,exitingValue:j,nodeState:nt,stateColor:Nt}=tt(Z);W.style("opacity",1),W.select("p.title").text(Z.name+" :"),W.select("p.top-label").style("display","block").text("in "+Pe(A,e)),W.select("p.bottom-label").style("display","block").text("out "+Pe(j,e)),W.select("p.small-text").style("display","block").text(`${nt}`).style("color",`${Nt}`),Dn(L,W)}).on("pointermove",(L,Z)=>{Dn(L,W)}).on("pointerleave",(L,Z)=>{W.style("opacity",0),W.select("p.small-text").style("display","none"),H.selectAll("path.link").style("stroke",function(A){const j=A;return`url(#${G.filter(O=>O.sourceName===j.sourceName&&O.targetName===j.targetName).node()?.id})`}).style("stroke-opacity",.5).style("fill","none").attr("class",`link ${J.sankeyEnergyLink}`);const ht=Z.sourceLinks?.map(A=>A.targetName)??[],at=[...Z.targetLinks?.map(A=>A.sourceName)??[],...ht,Z.name];H.selectAll("text.label").filter(A=>!at.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:ht}=tt(L);return ht==="surplus"||ht==="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(ht=>ht===L.name);return de(Z,!1)}),H.selectAll("text.label").data(gt,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,H=1,W=1;const V=U(N),q=V.descendants(),$=[V.x,V.y,V.r*2+p],pt=Ym(Y);Lu(q[0],pt);const wt=x.select("#tooltip").style("opacity",0),gt=x.select("svg"),_t=gt.node(),G=gt.select(".plot-area"),st=ye().domain([-1,2]).range(["#34d399","#6b21a8"]).interpolate(jd),B=A=>{let j=A;for(;j.depth>1;)j=j.parent;const nt=j.data.name,Nt=v.current(nt),O=Xe(Nt);if(!O)return Nt;const K=A.depth,$t=.5;return K===1?O.formatHex():O.darker(K*$t).formatHex()},Q=A=>n==="monochrome"?A.children?st(A.depth):"#f0fdfa":B(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(q,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*W).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*W).style("fill",Q),A=>A.transition().duration(b).style("opacity",0).remove()).on("mouseover",function(A,j){C.parent===j?ht.filter(function(O){return O.parent===C||this.style.display==="inline"}).style("font-size",y*W).style("fill-opacity",function(O){return O.parent===C?1:0}).style("display",function(O){return O.parent===C?"inline":"none"}):j===C?ht.filter(function(O){return O.parent===C||this.style.display==="inline"}).style("font-size",y*W).style("fill-opacity",function(O){return O.parent===C?1:0}).style("display",function(O){return O.parent===C?"inline":"none"}):(ht.filter(function(O){if(i){const K=j;return O.name!==K.name}return O.data.name!=j.data.name}).style("fill-opacity",0).style("display","none"),ht.filter(function(O){if(i){const K=j;return O.name!==K.name}return O.data.name===j.data.name}).style("fill-opacity",1).style("display","inline")),j!=N&&te(this).style("stroke-width",T*W*2.5).style("stroke","#e4e4e7");const nt=j.data.name==="branches"?"Total":j.data.name;wt.select("p.name").text(nt);const Nt=j.value??0;wt.select("p.value").text(Pe(Nt,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){ht.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"}),te(this).style("stroke-width",T*W).style("stroke",function(nt){return"#737373"}),wt.transition().duration(250).style("opacity",0)}).on("click",function(A,j){if(j===N){at();return}C!=j?ot(j):at(),L.style("stroke-width",T*W),A.stopPropagation()});function Z(A){const j=I/$[2],nt=i?A.sortedX??0:A.x,Nt=i?A.sortedY??0:A.y;return"translate("+(nt-$[0])*j+","+(Nt-$[1])*j+")"}const ht=G.selectAll("text").data(q,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());ht.raise();function ot(A){C=A;const j=I/2-p,nt=S/2,Nt=w/2,O=I/$[2],K=A.r*O;W=K/j,H=j/K;const zt=((i?A.sortedX??0:A.x)-$[0])*O,et=nt-zt*H,ut=((i?A.sortedY??0:A.y)-$[0])*O,vt=Nt-ut*H;G.transition().duration(1e3).attr("transform","translate("+et+","+vt+")scale("+H+")"),ht.style("font-size",y*W+"px").filter(function(kt){return kt.parent===C||this.style.display==="inline"}).style("fill-opacity",function(kt){return kt.parent===C?1:0}).style("display",function(kt){return kt.parent===C?"inline":"none"})}function at(){G.transition().duration(b).attr("transform","translate("+S/2+", "+w/2+")scale(1)"),C=N,H=1,W=1,ht.style("font-size",y*W+"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"})}at()},[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
37
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
38
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
39
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
@@ -41,13 +28,13 @@ React keys must be passed directly to JSX without using spread:
41
28
  c2.088,0,3.926-1.068,5-2.687C30.074,13.932,31.912,15,34,15h6c2.209,0,4,1.791,4,4v1v1c0,0.553,0.447,1,1,1h1c0.553,0,1,0.447,1,1\r
42
29
  v2c0,0.553-0.447,1-1,1h-1c-0.553,0-1,0.447-1,1v1c0,6.627-5.373,12-12,12S20,34.627,20,28z\r
43
30
  M24.285,39.678C26.498,41.143,29.147,42,32,42s5.502-0.857,7.715-2.322c1.66,0.281,3.297,0.63,4.892,1.084\r
44
- C41.355,43.983,36.911,46,31.973,46c-4.932,0-9.371-2.011-12.621-5.226C20.96,40.315,22.61,39.961,24.285,39.678z`}),$.jsx("path",{d:`M24.537,21.862c0.475,0.255,1.073,0.068,1.345-0.396C25.91,21.419,26.18,21,26.998,21\r
31
+ C41.355,43.983,36.911,46,31.973,46c-4.932,0-9.371-2.011-12.621-5.226C20.96,40.315,22.61,39.961,24.285,39.678z`}),m.jsx("path",{d:`M24.537,21.862c0.475,0.255,1.073,0.068,1.345-0.396C25.91,21.419,26.18,21,26.998,21\r
45
32
  c0.808,0,1.096,0.436,1.111,0.458C28.287,21.803,28.637,22,28.999,22c0.154,0,0.311-0.035,0.457-0.111\r
46
33
  c0.491-0.253,0.684-0.856,0.431-1.347C29.592,19.969,28.651,19,26.998,19c-1.691,0-2.618,0.983-2.9,1.564\r
47
- C23.864,21.047,24.063,21.609,24.537,21.862z`}),$.jsx("path",{d:`M34.539,21.862c0.475,0.255,1.073,0.068,1.345-0.396C35.912,21.419,36.182,21,37,21\r
34
+ C23.864,21.047,24.063,21.609,24.537,21.862z`}),m.jsx("path",{d:`M34.539,21.862c0.475,0.255,1.073,0.068,1.345-0.396C35.912,21.419,36.182,21,37,21\r
48
35
  c0.808,0,1.096,0.436,1.111,0.458C38.289,21.803,38.639,22,39.001,22c0.154,0,0.311-0.035,0.457-0.111\r
49
36
  c0.491-0.253,0.684-0.856,0.431-1.347C39.594,19.969,38.653,19,37,19c-1.691,0-2.618,0.983-2.9,1.564\r
50
- C33.866,21.047,34.065,21.609,34.539,21.862z`})]})}),A0=({size:t=24,color:e="#ff6699",...n})=>$.jsx("svg",{viewBox:"0 0 64 64",width:t,height:t,xmlns:"http://www.w3.org/2000/svg",...n,children:$.jsxs("g",{fill:e,children:[$.jsx("path",{d:`M62.242,47.758l0.014-0.014c-3.239-2.634-6.865-4.874-10.839-6.644\r
37
+ C33.866,21.047,34.065,21.609,34.539,21.862z`})]})}),Xm=({size:t=24,color:e="#ff6699",...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-3.239-2.634-6.865-4.874-10.839-6.644\r
51
38
  C50.502,38.229,50,35.175,50,32V16c0-8.837-7.163-16-16-16h-4c-8.837,0-16,7.163-16,16v16\r
52
39
  c0,3.173-0.501,6.226-1.415,9.096c-3.979,1.745-7.526,3.953-10.841,6.648l0.014,0.014\r
53
40
  C0.672,48.844,0,50.344,0,52v8c0,2.211,1.789,4,4,4h56c2.211,0,4-1.789,4-4v-8\r
@@ -60,17 +47,101 @@ React keys must be passed directly to JSX without using spread:
60
47
  c-2.468,2.468-13.311,13.311-13.691,13.691\r
61
48
  c-0.43,0.43-0.748,0.447-1.183,0.013\r
62
49
  C31.03,54.616,20.18,43.766,17.711,41.297\r
63
- C20.277,40.457,22.934,39.817,25.677,39.439z`}),$.jsx("path",{d:`M25.882,22.467C25.91,22.419,26.18,22,26.998,22c0.808,0,1.096,0.436,1.111,0.458\r
50
+ C20.277,40.457,22.934,39.817,25.677,39.439z`}),m.jsx("path",{d:`M25.882,22.467C25.91,22.419,26.18,22,26.998,22c0.808,0,1.096,0.436,1.111,0.458\r
64
51
  C28.287,22.803,28.637,23,28.999,23c0.154,0,0.311-0.035,0.457-0.111\r
65
52
  c0.491-0.253,0.684-0.856,0.431-1.347\r
66
53
  C29.592,20.969,28.651,20,26.998,20\r
67
54
  c-1.691,0-2.618,0.983-2.9,1.564\r
68
55
  c-0.233,0.482-0.034,1.045,0.439,1.298\r
69
- C25.012,23.117,25.61,22.931,25.882,22.467z`}),$.jsx("path",{d:`M34.539,22.862c0.475,0.255,1.073,0.068,1.345-0.396\r
56
+ C25.012,23.117,25.61,22.931,25.882,22.467z`}),m.jsx("path",{d:`M34.539,22.862c0.475,0.255,1.073,0.068,1.345-0.396\r
70
57
  C35.912,22.419,36.182,22,37,22c0.808,0,1.096,0.436,1.111,0.458\r
71
58
  C38.289,22.803,38.639,23,39.001,23c0.154,0,0.311-0.035,0.457-0.111\r
72
59
  c0.491-0.253,0.684-0.856,0.431-1.347\r
73
60
  C39.594,20.969,38.653,20,37,20\r
74
61
  c-1.691,0-2.618,0.983-2.9,1.564\r
75
- C33.866,22.047,34.065,22.609,34.539,22.862z`})]})}),Bt={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 T0({data:t}){const[e,n]=ge(),{width:r,height:a}=n,[i,o]=ut.useState(!1),[s,c]=ut.useState(!1),[l,u]=ut.useState(!1),[f,h]=xe(),{width:p,height:k}=h,W=500;ut.useEffect(()=>{l&&o(!1),c(l)},[l]),ut.useEffect(()=>{u(!1),o(!1),c(!1)},[t]);const b=r>576,v=$.jsxs("div",{className:`${st[b?"controls-container":"controls-container-sm"]}`,children:[$.jsxs("label",{className:`${st["controls-label"]} ${l?st.disabled:""}`,style:{paddingRight:"12px"},children:[$.jsx("input",{type:"checkbox",className:`${st["controls-checkbox"]}`,checked:i,onChange:z=>o(z.target.checked),disabled:l}),"Sort"]}),$.jsxs("label",{className:`${st["controls-label"]} ${l?st.disabled:""}`,style:{paddingRight:"12px"},children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:s,onChange:z=>c(z.target.checked),disabled:l}),"By Total"]}),$.jsxs("label",{className:st["controls-label"],style:{paddingRight:"12px"},children:[$.jsx("input",{type:"checkbox",className:st["controls-checkbox"],checked:l,onChange:z=>u(z.target.checked)}),"By Percentage"]})]}),L=t.reduce((z,Y)=>(Y.male=+Y.male,Y.female=+Y.female,Y.Total=Y.male+Y.female,{totalPeople:z.totalPeople+Y.male+Y.female,totalMale:z.totalMale+Y.male,totalFemale:z.totalFemale+Y.female}),{totalPeople:0,totalMale:0,totalFemale:0}),{totalPeople:x,totalMale:M,totalFemale:j}=L,N=Kt(z=>{if(r===0||a===0)return;const Y={top:0,right:b?0:15,bottom:30,left:b?0:15},B=r-Y.left-Y.right,Z=a-Y.top-Y.bottom;let A=ye().range([Z,0]),X=ye().range([Z,0]),S=Gt().rangeRound([0,B/2]),P=Gt().rangeRound([B/2,B]),y=Ut(S).ticks(b?8:4).tickSize(-Z).tickFormat(Rt(l?"~%":".2s")),D=Ut(P).ticks(b?8:4).tickSize(-Z).tickFormat(Rt(".2s")),T=te(A),I=vs(X);const m=z.select("svg");m.node();const E=m.select(".plot-area").attr("fill","steelblue").attr("transform","translate("+Y.left+","+Y.top+")"),g=Ke(z);function H(){Fd(g)}E.on("mouseout",function(){H()}),m.select("rect.bgRect").on("mouseover",function(){H()}).on("mousemove",function(){H()}),E.select("g.yMale.axis").node()===null&&E.append("g").attr("class",`yMale axis ${Bt["value-axis"]}`).call(T).attr("pointer-events","none"),E.select("g.xMale.axis").node()===null&&E.append("g").attr("class",`xMale axis ${Bt["value-axis"]}`).attr("transform","translate(0,"+Z+")").call(y).attr("pointer-events","none").selectAll(".tick").filter(R=>R===0).select("line").remove(),E.select("g.yFemale.axis").node()===null&&E.append("g").attr("class",`yFemale axis ${Bt["value-axis"]}`).attr("transform","translate("+B+",0)").call(I).attr("pointer-events","none"),E.select("g.xFemale.axis").node()===null&&E.append("g").attr("class",`xFemale axis ${Bt["value-axis"]}`).attr("transform","translate(0,"+Z+")").call(D).attr("pointer-events","none").selectAll(".tick").filter(R=>R===0).select("line").remove();const K=Ot(t),J=["male","female"],it=bn().keys(J).order(hr).offset(fr)(K),O=!(l||s),tt=Dt(it[0],function(R){return R.data.Total})??0,d=Dt(it[0],function(R){return R.data.male})??0;Nn(it[0],function(R){return R.data.male});const _=Dt(it[1],function(R){return R.data.female})??0;Nn(it[1],function(R){return R.data.female});const C=O?Math.max(d,_):tt,w=(R,lt)=>{const nt=it[0].sort(i?function(q,pt){const vt=s?pt.data.Total??0:pt.data.male,bt=s?q.data.Total??0:q.data.male;return vt-bt}:function(q,pt){return lt.indexOf(q.data.ageRange+"")-lt.indexOf(pt.data.ageRange+"")}).map(function(q){return q.data.ageRange+""});A.domain(nt);const F=it[0].sort(i?function(q,pt){const vt=s?pt.data.Total??0:pt.data.female,bt=s?q.data.Total??0:q.data.female;return vt-bt}:function(q,pt){return lt.indexOf(q.data.ageRange+"")-lt.indexOf(pt.data.ageRange+"")}).map(function(q){return q.data.ageRange+""});X.domain(F),R.select(".yMale.axis").transition().duration(W).call(T),R.select(".yFemale.axis").transition().duration(W).attr("transform","translate("+B+", 0)").call(I).style("opacity",O?1:0)},Q=(R,lt,nt,F,q,pt)=>{const vt=O?[pt,0]:[0,l?1:pt],bt=O?B/2:B;lt.domain([...vt]).rangeRound([0,bt]).nice(),R.select(".xMale.axis").transition().duration(W).attr("transform","translate(0,"+Z+")").call(nt).selectAll("text").style("text-anchor",b?"center":"end").attr("dx",function(St){return b?0:"-.8em"}),F.domain([0,pt]).nice(),R.select(".xFemale.axis").transition().duration(W).attr("transform",`translate(0,${Z})`).call(q).style("opacity",O?1:0).selectAll("text").style("text-anchor",b?"center":"end").attr("dx",function(St){return b?0:"-.8em"})};let rt=[];rt.length===0&&(rt=K.map(function(R){return R.ageRange})),w(E,rt),Q(E,S,y,P,D,C);const ft=s&&!l?Bt.maleTotal:Bt.male,xt=R=>{if(!s)return"none";const lt=S(R[1])-S(R[0]),nt=isNaN(lt)?0:lt,F=A.bandwidth();return`${nt} ${F} ${nt+F}`};E.selectAll(".maleBars").data(it[0],function(R){return R.data.ageRange}).join(R=>R.append("rect").attr("class","maleBars "+ft).attr("fill","#0099ff").attr("width",0).attr("x",B/2).attr("y",function(lt){return A(lt.data.ageRange)??0}).attr("height",A.bandwidth()).attr("stroke-dasharray",xt).call(lt=>lt.transition().duration(W).attr("x",function(nt){return S(O?nt[1]:0)}).attr("width",function(nt,F){if(!O){const pt=l?nt[0]/nt.data.Total:nt[0],vt=l?nt[1]/nt.data.Total:nt[1],bt=S(vt)-S(pt);return isNaN(bt)?0:bt}const q=S(nt[0])-S(nt[1]);return isNaN(q)?0:q})),void 0,R=>R.remove()).on("mouseover",function(R,lt){s&&!l&&E.selectAll(".femaleBars").filter(nt=>nt.data.ageRange===lt.data.ageRange).attr("class","femaleBars "+Bt.totalFemale),E.select("g.yMale.axis").selectAll("text").filter(function(nt){return lt.data.ageRange===nt}).style("font-weight","bold"),at("male",lt)}).on("mousemove",function(R){gr(R,g)}).on("mouseout",function(R,lt){E.select("g.yMale.axis").selectAll("text").filter(function(nt){return lt.data.ageRange===nt}).style("font-weight","normal"),s&&!l&&E.selectAll(".femaleBars").filter(nt=>nt.data.ageRange===lt.data.ageRange).attr("class","femaleBars "+Bt.femaleTotal),H()}).attr("class","maleBars "+ft).transition().duration(W).attr("stroke-dasharray",xt).attr("y",function(R,lt){return A(R.data.ageRange)??0}).attr("height",A.bandwidth()).attr("x",function(R,lt){return S(O?R[1]:0)}).attr("width",function(R,lt){if(!O){const F=l?R[0]/R.data.Total:R[0],q=l?R[1]/R.data.Total:R[1],pt=S(q)-S(F);return isNaN(pt)?0:pt}const nt=S(R[0])-S(R[1]);return isNaN(nt)?0:nt});const et=s&&!l?Bt.femaleTotal:Bt.female,V=R=>{if(!s)return"none";const lt=S(R[1])-S(R[0]),nt=isNaN(lt)?0:lt,F=X.bandwidth();return`${nt+F+nt} ${F}`};E.selectAll(".femaleBars").data(it[1],function(R){return R.data.ageRange}).join(R=>R.append("rect").attr("class","femaleBars "+et).attr("stroke-dasharray",V).attr("fill","#ff6699").attr("width",0).attr("x",function(lt,nt){if(!O){const F=l?lt[0]/lt.data.Total:lt[0];return S(F)}return B/2}).attr("y",function(lt,nt){return(O?X:A)(lt.data.ageRange)??0}).attr("height",X.bandwidth()).call(lt=>lt.transition().duration(W).attr("width",function(nt,F){if(!O){const pt=l?nt[0]/nt.data.Total:nt[0],vt=l?nt[1]/nt.data.Total:nt[1],bt=S(vt)-S(pt);return isNaN(bt)?0:bt}const q=P(nt[1])-P(nt[0]);return isNaN(q)?0:q})),void 0,R=>R.remove()).on("mouseover",function(R,lt){E.select("g.yFemale.axis").selectAll("text").filter(function(nt){return lt.data.ageRange===nt}).style("font-weight","bold"),s&&!l&&E.selectAll(".maleBars").filter(nt=>nt.data.ageRange===lt.data.ageRange).attr("class","maleBars "+Bt.totalMale),at("female",lt)}).on("mousemove",function(R){gr(R,g)}).on("mouseout",function(R,lt){E.select("g.yFemale.axis").selectAll("text").filter(function(nt){return lt.data.ageRange===nt}).style("font-weight","normal"),s&&!l&&E.selectAll(".maleBars").filter(nt=>nt.data.ageRange===lt.data.ageRange).attr("class","maleBars "+Bt.maleTotal),H()}).attr("class","femaleBars "+et).transition().duration(W).attr("stroke-dasharray",V).attr("y",function(R,lt){return(O?X:A)(R.data.ageRange)??0}).attr("height",X.bandwidth()).attr("x",function(R,lt){if(!O){const nt=l?R[0]/R.data.Total:R[0];return S(nt)}return B/2}).attr("width",function(R,lt){if(!O){const F=l?R[0]/R.data.Total:R[0],q=l?R[1]/R.data.Total:R[1],pt=S(q)-S(F);return isNaN(pt)?0:pt}const nt=P(R[1])-P(R[0]);return isNaN(nt)?0:nt});function at(R,lt){g.style("opacity",1).select("p").text(function(){if(s&&!l)return`${lt.data.ageRange} y.o: ${Rt(",d")(lt.data.Total)} people`;if(l){const nt=lt.data[R]/lt.data.Total;return`${Rt(".1%")(nt)} (${Rt(",d")(lt.data[R])}
76
- of ${Rt(",d")(lt.data.Total)} people)`}return`${R} ${lt.data.ageRange} y.o: ${Rt(",d")(lt.data[R])}`})}},[t,r,a,i,s,l]);return $.jsxs("div",{ref:e,style:{width:r,height:a,display:"flex",flexDirection:"column"},children:[v,$.jsx("div",{className:`${Bt.container}`,children:$.jsxs("span",{ref:f,className:`${Bt.inner}`,style:{transform:`translateX(${s||l?60:(r-p)/2}px)`},children:[$.jsxs("p",{style:{display:s||l?"none":"block"},children:[Rt(",d")(M)," male"]}),$.jsx(M0,{}),$.jsx(A0,{}),$.jsx("p",{children:s||l?`${Rt(",d")(x)} people`:`${Rt(",d")(j)} female`})]})}),$.jsxs("div",{ref:N,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[$.jsxs("svg",{className:`${st["chart-svg"]} ${st["fill-container"]}`,style:{},viewBox:`0 0 ${r} ${a}`,children:[$.jsx("rect",{width:r,height:a,className:"bgRect opacity-0",style:{fill:"white"}}),$.jsx("g",{className:"plot-area"})]}),$.jsx(Xe,{})]})]})}const Ze={rotatedAxisText:"_rotatedAxisText_y6xfd_1",axisText:"_axisText_y6xfd_11","value-axis":"_value-axis_y6xfd_21","time-axis":"_time-axis_y6xfd_41"};xn("%A"),xn("%w"),xn("%B");const N0=t=>{const e=Ra(t,n=>pn(n.date));return Array.from(e.values()).map(n=>{const r=n[0],a=n[n.length-1],i=Nn(n,o=>o.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:Dt(n,o=>o.hi),low:Tn(n,o=>o.low)}})},C0=t=>{const e=Ra(t,n=>or(n.date));return Array.from(e.values()).map(n=>{const r=n[0],a=n[n.length-1],i=Nn(n,o=>o.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:Dt(n,o=>o.hi),low:Tn(n,o=>o.low)}})};function $0({data:t,timeframe:e="daily",mode:n="linechart",tooltipFormat:r={prefix:"",suffix:""}}){const[a,i]=ge(),{width:o,height:s}=i,c=750,l=[t,e,n,o,s,r],u=ya,f=Object.keys(t[0]).filter(b=>b!=="date"&&b!=="volume"&&b!=="adj_close"),h={top:0,right:30,bottom:20,left:60},p=o>576,k={bullish:"#047857",bearish:"#be123c"},W=Kt(b=>{if(o===0||s===0)return;const v=40,L=v+h.bottom,x=o-h.left-h.right,M=s-h.top-h.bottom,j=M-2*L,N=b.select("svg");N.node();const z=N.select(".plot-area").attr("transform","translate("+h.left+","+h.top+")");N.selectAll("defs").remove(),N.append("defs").append("clipPath").attr("id","clip").append("rect").attr("width",x).attr("height",M);const Y=N.select(".volume-area").attr("transform","translate("+h.left+","+(j+h.top+h.bottom)+")"),B=N.select(".brush-area").attr("transform","translate("+h.left+","+(j+h.top+h.bottom+L)+")"),Z=F=>{const q=xo("%Y-%m-%d")(F.date);return{date:new Date(q||new Date),open:+F.open,hi:+F.hi,low:+F.low,close:+F.close,adj_close:+F.adj_close,volume:+F.volume}},A=t.map(F=>Z(F)),X=e==="weekly"?N0(A):[],S=e==="monthly"?C0(A):[],P=e==="daily"?A:e==="weekly"?X:e==="monthly"?S:[],y=f.map(function(F){return{name:F,values:A.map(function(q){return{date:q.date,value:+q[F]}})}}),D=es(A,function(F){return F.date}),T=_o().domain(D).range([0,x]),I=p?Ze.axisText:Ze.rotatedAxisText;z.select(".x-axis").attr("transform","translate(0,"+j+")").call(Ut(T)).selectAll("text").attr("class",I);const m=Dt(y,function(F){return Dt(F.values,function(q){return q.value})})||0,E=Tn(y,function(F){return Tn(F.values,function(q){return q.value})})||0,g=Gt().domain([E,m]).range([j,0]),H=te(g).tickSize(-x);z.select(".y-axis").call(H),z.selectAll("path.chartline").remove();const K=_a().x(function(F){return T(F.date)}).y(function(F){return g(F.value)});n==="linechart"&&y.forEach((F,q)=>{z.insert("path","g.tooltip").attr("class","chartline").datum(F.values).attr("fill","none").attr("stroke",u[q]).attr("stroke-width",1).attr("d",K).attr("clip-path","url(#clip)")}),z.selectAll("path.candle").remove();const J=F=>F.open>=F.close?k.bullish:k.bearish;n==="candlestick"&&z.selectAll("path.candle").data(P).join(F=>F.insert("path","g.tooltip").attr("class","candle").attr("d",function(q){return nt(q,g)}).style("fill",J).attr("clip-path","url(#clip)"),void 0,F=>F.remove()).on("pointerenter",function(F,q){const{date:pt,open:vt,hi:bt,low:St,close:Tt,volume:Mt}=q,Ct=At(this).node()?.getBBox().width??0;_({date:pt,open:vt,hi:bt,low:St,close:Tt,volume:Mt}),d({xPos:T(pt)+Ct/2,low:St,volume:Mt})}).on("pointerout",C).attr("d",function(F){return nt(F,g)}).style("fill",J);const ct=z.select("g.tooltip").style("pointer-events","none"),it=Y.select("g.tooltip").style("pointer-events","none");z.select("rect.overlay").attr("width",x).attr("height",j).style("fill","none").style("pointer-events",n==="linechart"?"all":"none").on("pointerenter pointermove",tt).on("pointerleave",C).on("touchstart",F=>F.preventDefault());function O(F){return F.toLocaleString("en",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function tt(F){if(n==="candlestick")return;const q=n==="linechart"?A:P,pt=Mn(gt=>gt.date).center,vt=pt(q,T.invert(Cr(F)[0])),{date:bt,open:St,hi:Tt,low:Mt,close:Ct,volume:ot}=q[vt];_({date:bt,open:St,hi:Tt,low:Mt,close:Ct,volume:ot}),d({xPos:T(bt),low:Mt,volume:ot})}const d=F=>{const{xPos:q,low:pt,volume:vt}=F;ct.style("display",null),ct.attr("transform",`translate(${q},${g(pt)})`),it.style("display",null),it.attr("transform",`translate(${q},${Q(vt)})`)},_=F=>{const{prefix:q,suffix:pt}=r,{date:vt,open:bt,hi:St,low:Tt,close:Mt,volume:Ct}=F,ot=ct.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),gt=ct.selectAll("text").data([null]).join("text").call(mt=>mt.selectAll("tspan").data([O(vt),`open: ${Et(bt,{prefix:q,suffix:pt})}`,`hi: ${Et(St,{prefix:q,suffix:pt})}`,`low: ${Et(Tt,{prefix:q,suffix:pt})}`,`close: ${Et(Mt,{prefix:q,suffix:pt})}`]).join("tspan").attr("x",0).attr("y",(U,ht)=>`${ht*1.1}em`).attr("font-weight",(U,ht)=>ht?null:"bold").style("align","right").text(U=>U));w(gt,ot);const _t=it.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),G=it.selectAll("text").data([null]).join("text").call(mt=>mt.selectAll("tspan").data(["Trading Volume",Et(Ct)]).join("tspan").attr("x",0).attr("y",(U,ht)=>`${ht*1.1}em`).attr("font-weight",(U,ht)=>ht?null:"bold").text(U=>U));w(G,_t),B.transition().duration(c/4).style("opacity",0)};function C(F){ct.style("display","none"),it.style("display","none"),B.transition().duration(c/4).style("opacity",1)}function w(F,q){const{x:pt,y:vt,width:bt,height:St}=F.node().getBBox();F.attr("transform",`translate(${-bt/2},${15-vt})`),q.attr("d",`M${-bt/2-10},5H-5l5,-5l5,5H${bt/2+10}v${St+20}h-${bt+20}z`)}const Q=Gt().domain([0,Dt(t,function(F){return typeof F.volume=="string"?parseInt(F.volume):F.volume})]).range([v,0]),rt=Rd().x(function(F){return T(new Date(F.date))}).y0(Q(0)).y1(function(F){return Q(typeof F.volume=="string"?parseInt(F.volume):F.volume)});Y.selectAll("path.area").remove(),Y.insert("path","g.tooltip").datum(A).attr("class","area").attr("d",rt).style("fill","lightgray").style("stroke","none").attr("clip-path","url(#clip)"),Y.select(".x-axis").attr("transform","translate(0,"+v+")").call(Ut(T)).selectAll("text").attr("class",I);const ft=_o().domain(D).range([0,x]),xt=Gt().domain([E,m]).range([v,0]),et=_a().x(function(F){return ft(F.date)}).y(function(F){return xt(F.value)});B.selectAll("path.line").remove(),B.selectAll("g.brush").remove(),n==="linechart"&&y.forEach((F,q)=>{B.append("path").attr("class","line").datum(F.values).attr("fill","none").attr("stroke",u[q]).attr("stroke-width",1).attr("d",et).attr("clip-path","url(#clip)")}),B.selectAll("path.candle").remove(),n==="candlestick"&&B.selectAll("path.candle").data(P).join(F=>F.insert("path","g.tooltip").attr("class","candle").attr("d",function(q){return nt(q,xt)}).style("fill",J).attr("clip-path","url(#clip)"),void 0,F=>F.remove()).attr("d",function(F){return nt(F,xt)}).style("fill",J),B.select(".x-axis").attr("transform","translate(0,"+v+")").call(Ut(ft)).selectAll("text").attr("class",I);const V=rf().extent([[0,0],[o,v]]).on("brush",at);B.append("g").attr("class","brush").call(V);function at(F){const q=F.selection;q?T.domain([ft.invert(q[0]),ft.invert(q[1])]):(!q||q===null)&&T.domain(D),R()}N.on("dblclick",function(){T.domain(D),B.select(".brush").call(V.move,null),R()});const R=()=>{z.select(".x-axis").call(Ut(T)).selectAll("text").attr("class",I),n==="candlestick"?z.selectAll("path.candle").attr("d",function(F){return nt(F,g)}):n==="linechart"&&z.selectAll("path.chartline").attr("d",K),Y.select(".x-axis").call(Ut(T)).selectAll("text").attr("class",I),Y.selectAll("path.area").attr("d",rt)};function lt(){const F=T(P[1].date)-T(P[0].date),q=(F-F*.2)/2;return{barWidth:F,shoulderWidth:q}}function nt(F,q){let pt,vt;F.open>=F.close?(pt=F.open,vt=F.close):(pt=F.close,vt=F.open);const{barWidth:bt,shoulderWidth:St}=lt();q(pt)-q(vt);const Tt=q(F.hi)-q(pt),Mt=q(F.low)-q(vt);return"M "+T(F.date)+","+q(pt)+" "+(T(F.date)+St)+","+q(pt)+" "+(T(F.date)+St)+","+(q(pt)+Tt)+" "+(T(F.date)+St+bt*.2)+","+(q(pt)+Tt)+" "+(T(F.date)+St+bt*.2)+","+q(pt)+" "+(T(F.date)+bt)+","+q(pt)+" "+(T(F.date)+bt)+","+q(vt)+" "+(T(F.date)+St+bt*.2)+","+q(vt)+" "+(T(F.date)+St+bt*.2)+","+(q(vt)+Mt)+" "+(T(F.date)+St)+","+(q(vt)+Mt)+" "+(T(F.date)+St)+","+q(vt)+" "+T(F.date)+","+q(vt)+"z"}},[...l,r]);return $.jsx("div",{ref:a,style:{width:o,height:s,display:"flex",flexDirection:"column"},children:$.jsxs("div",{ref:W,className:`${st["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[$.jsxs("div",{className:`${st[p?"controls-container":"controls-container-sm"]}`,style:{gap:2,height:24},children:[n==="linechart"&&f.map((b,v)=>$.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"start",alignItems:"center"},children:[$.jsx("div",{style:{width:16,height:2.5,borderRadius:1,backgroundColor:u[v]}}),$.jsx("p",{style:{padding:0,margin:0},children:b})]},b)),n==="candlestick"&&["bullish","bearish"].map(b=>$.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:k[b],borderRadius:2.5,padding:"2px 3px"},children:$.jsx("p",{style:{color:"white",margin:0,padding:0},children:b})},b))]}),$.jsx("svg",{className:`${st["chart-svg"]} ${st["fill-container"]}`,viewBox:`0 0 ${o} ${s}`,children:o>0&&$.jsxs($.Fragment,{children:[$.jsxs("g",{className:"plot-area",children:[$.jsx("g",{className:`x-axis ${Ze["time-axis"]}`}),$.jsx("g",{className:`y-axis ${Ze["value-axis"]}`}),$.jsx("rect",{className:"overlay"}),$.jsx("g",{className:"tooltip"})]}),$.jsxs("g",{className:"volume-area",children:[$.jsx("g",{className:`x-axis ${Ze["time-axis"]}`}),$.jsx("g",{className:"tooltip"})]}),$.jsx("g",{className:"brush-area",children:$.jsx("g",{className:`x-axis ${Ze["time-axis"]}`})})]})})]})})}jt.BarChart=Ud,jt.CirclePacks=S0,jt.GroupedBarChart=Wd,jt.PercentageBarChart=Vd,jt.PieChart=Od,jt.PopulationPyramid=T0,jt.Sankey=c0,jt.StackedBarChart=Yd,jt.StockPriceChart=$0,Object.defineProperty(jt,Symbol.toStringTag,{value:"Module"})}));
62
+ C33.866,22.047,34.065,22.609,34.539,22.862z`})]})}),Ye={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=Oe().range([R,0]),I=Oe().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),H=Ni(I);const W=k.select("svg");W.node();const V=W.select(".plot-area").attr("fill","steelblue").attr("transform","translate("+_.left+","+_.top+")"),q=k.select("div#tooltip").style("opacity",0);V.select("g.yMale.axis").node()===null&&V.append("g").attr("class",`yMale axis ${Ye["value-axis"]}`).call(C).attr("pointer-events","none"),V.select("g.xMale.axis").node()===null&&V.append("g").attr("class",`xMale axis ${Ye["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 ${Ye["value-axis"]}`).attr("transform","translate("+E+",0)").call(H).attr("pointer-events","none"),V.select("g.xFemale.axis").node()===null&&V.append("g").attr("class",`xFemale axis ${Ye["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),pt=["male","female"],gt=na().keys(pt).order(ui).offset(ea)($),_t=!(c||o),G=Zt(gt[0],function(A){return A.data.Total})??0,st=Zt(gt[0],function(A){return A.data.male})??0;Dr(gt[0],function(A){return A.data.male});const B=Zt(gt[1],function(A){return A.data.female})??0;Dr(gt[1],function(A){return A.data.female});const Q=_t?Math.max(st,B):G,X=(A,j)=>{const nt=gt[0].sort(i?function(O,K){const $t=o?K.data.Total??0:K.data.male,zt=o?O.data.Total??0:O.data.male;return $t-zt}:function(O,K){return j.indexOf(O.data.ageRange+"")-j.indexOf(K.data.ageRange+"")}).map(function(O){return O.data.ageRange+""});z.domain(nt);const Nt=gt[0].sort(i?function(O,K){const $t=o?K.data.Total??0:K.data.female,zt=o?O.data.Total??0:O.data.female;return $t-zt}:function(O,K){return j.indexOf(O.data.ageRange+"")-j.indexOf(K.data.ageRange+"")}).map(function(O){return O.data.ageRange+""});I.domain(Nt),A.select(".yMale.axis").transition().duration(b).call(C),A.select(".yFemale.axis").transition().duration(b).attr("transform","translate("+E+", 0)").call(H).style("opacity",_t?1:0)},D=(A,j,nt,Nt,O,K)=>{const $t=_t?[K,0]:[0,c?1:K],zt=_t?E/2:E;j.domain([...$t]).rangeRound([0,zt]).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(et){return d?0:-12.8}),Nt.domain([0,K]).nice(),A.select(".xFemale.axis").transition().duration(b).attr("transform",`translate(0,${R})`).call(O).style("opacity",_t?1:0).selectAll("text").style("text-anchor",d?"center":"end").attr("dx",function(et){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?Ye.maleTotal:Ye.male,Z=A=>{if(!o)return"none";const j=N(A[1])-N(A[0]),nt=isNaN(j)?0:j,Nt=z.bandwidth();return`${nt} ${Nt} ${nt+Nt}`};V.selectAll(".maleBars").data(gt[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,Nt){if(!_t){const K=c?nt[0]/nt.data.Total:nt[0],$t=c?nt[1]/nt.data.Total:nt[1],zt=N($t)-N(K);return isNaN(zt)?0:zt}const O=N(nt[0])-N(nt[1]);return isNaN(O)?0:O})),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 "+Ye.totalFemale),V.select("g.yMale.axis").selectAll("text").filter(function(nt){return j.data.ageRange===nt}).style("font-weight","bold"),A.stopPropagation(),at("male",j),Dn(j,q)}).on("pointermove",function(A){A.stopPropagation(),Dn(A,q)}).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 "+Ye.femaleTotal),q.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 Nt=c?A[0]/A.data.Total:A[0],O=c?A[1]/A.data.Total:A[1],K=N(O)-N(Nt);return isNaN(K)?0:K}const nt=N(A[0])-N(A[1]);return isNaN(nt)?0:nt});const ht=o&&!c?Ye.femaleTotal:Ye.female,ot=A=>{if(!o)return"none";const j=N(A[1])-N(A[0]),nt=isNaN(j)?0:j,Nt=I.bandwidth();return`${nt+Nt+nt} ${Nt}`};V.selectAll(".femaleBars").data(gt[1],function(A){return A.data.ageRange}).join(A=>A.append("rect").attr("class","femaleBars "+ht).attr("stroke-dasharray",ot).attr("fill","#ff6699").attr("width",0).attr("x",function(j,nt){if(!_t){const Nt=c?j[0]/j.data.Total:j[0];return N(Nt)}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,Nt){if(!_t){const K=c?nt[0]/nt.data.Total:nt[0],$t=c?nt[1]/nt.data.Total:nt[1],zt=N($t)-N(K);return isNaN(zt)?0:zt}const O=U(nt[1])-U(nt[0]);return isNaN(O)?0:O})),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 "+Ye.totalMale),at("female",j),Dn(j,q)}).on("pointermove",function(A){A.stopPropagation(),Dn(A,q)}).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 "+Ye.maleTotal),q.style("opacity",0)}).attr("class","femaleBars "+ht).transition().duration(b).attr("stroke-dasharray",ot).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 Nt=c?A[0]/A.data.Total:A[0],O=c?A[1]/A.data.Total:A[1],K=N(O)-N(Nt);return isNaN(K)?0:K}const nt=U(A[1])-U(A[0]);return isNaN(nt)?0:nt});function at(A,j){q.style("opacity",1),q.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:`${Ye.container}`,children:m.jsxs("span",{ref:h,className:`${Ye.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:Zt(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:Zt(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=O=>{const K=Ac("%Y-%m-%d")(O.date);return{date:new Date(K||new Date),open:+O.open,hi:+O.hi,low:+O.low,close:+O.close,adj_close:+O.adj_close,volume:+O.volume}},z=t.map(O=>R(O)),I=e==="weekly"?Gm(z):[],N=e==="monthly"?Zm(z):[],U=e==="daily"?z:e==="weekly"?I:e==="monthly"?N:[],M=h.map(function(O){return{name:O,values:z.map(function(K){return{date:K.date,value:+K[O]}})}}),Y=fa(z,function(O){return O.date}),C=ti().domain(Y).range([0,w]),H=g?an.axisText:an.rotatedAxisText;k.select(".x-axis").attr("transform","translate(0,"+T+")").call(he(C)).selectAll("text").attr("class",H);const W=Zt(M,function(O){return Zt(O.values,function(K){return K.value})})||0,V=oe(M,function(O){return oe(O.values,function(K){return K.value})})||0,q=ye().domain([V,W]).range([T,0]),$=be(q).tickSize(-w);k.select(".y-axis").call($),k.selectAll("path.chartline").remove();const pt=Bn().x(function(O){return C(O.date)}).y(function(O){return q(O.value)});n==="linechart"&&M.forEach((O,K)=>{k.insert("path","g.tooltip").attr("class","chartline").datum(O.values).attr("fill","none").attr("stroke",u[K]).attr("stroke-width",1).attr("d",pt).attr("clip-path","url(#clip)")}),k.selectAll("path.candle").remove();const wt=O=>O.open>=O.close?v.bullish:v.bearish;n==="candlestick"&&k.selectAll("path.candle").data(U).join(O=>O.insert("path","g.tooltip").attr("class","candle").attr("d",function(K){return Nt(K,q)}).style("fill",wt).attr("clip-path","url(#clip)"),void 0,O=>O.remove()).on("pointerenter",function(O,K){const{date:$t,open:zt,hi:et,low:Tt,close:ut,volume:vt}=K,kt=te(this).node()?.getBBox().width??0;Q({date:$t,open:zt,hi:et,low:Tt,close:ut,volume:vt}),B({xPos:C($t)+kt/2,low:Tt,volume:vt})}).on("pointerleave",X).attr("d",function(O){return Nt(O,q)}).style("fill",wt);const gt=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",st).on("pointerleave",X).on("touchstart",O=>O.preventDefault());function G(O){return O.toLocaleString("en",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function st(O){if(n==="candlestick")return;const K=n==="linechart"?z:U,$t=Nr(Xt=>Xt.date).center,zt=$t(K,C.invert(tr(O)[0])),{date:et,open:Tt,hi:ut,low:vt,close:kt,volume:jt}=K[zt];Q({date:et,open:Tt,hi:ut,low:vt,close:kt,volume:jt}),B({xPos:C(et),low:vt,volume:jt})}const B=O=>{const{xPos:K,low:$t,volume:zt}=O;gt.style("display",null),gt.attr("transform",`translate(${K},${q($t)})`),_t.style("display",null),_t.attr("transform",`translate(${K},${tt(zt)})`)},Q=O=>{const{prefix:K,suffix:$t}=r,{date:zt,open:et,hi:Tt,low:ut,close:vt,volume:kt}=O,jt=gt.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),Xt=gt.selectAll("text").data([null]).join("text").call(Ht=>Ht.selectAll("tspan").data([G(zt),`open: ${Pe(et,{prefix:K,suffix:$t})}`,`hi: ${Pe(Tt,{prefix:K,suffix:$t})}`,`low: ${Pe(ut,{prefix:K,suffix:$t})}`,`close: ${Pe(vt,{prefix:K,suffix:$t})}`]).join("tspan").attr("x",0).attr("y",(Gt,ae)=>`${ae*1.1}em`).attr("font-weight",(Gt,ae)=>ae?null:"bold").style("align","right").text(Gt=>Gt));D(Xt,jt);const ie=_t.selectAll("path").data([null]).join("path").attr("fill","white").attr("stroke","black"),Jt=_t.selectAll("text").data([null]).join("text").call(Ht=>Ht.selectAll("tspan").data(["Trading Volume",Pe(kt)]).join("tspan").attr("x",0).attr("y",(Gt,ae)=>`${ae*1.1}em`).attr("font-weight",(Gt,ae)=>ae?null:"bold").text(Gt=>Gt));D(Jt,ie),E.transition().duration(l/4).style("opacity",0)};function X(O){gt.style("display","none"),_t.style("display","none"),E.transition().duration(l/4).style("opacity",1)}function D(O,K){const{x:$t,y:zt,width:et,height:Tt}=O.node().getBBox();O.attr("transform",`translate(${-et/2},${15-zt})`),K.attr("d",`M${-et/2-10},5H-5l5,-5l5,5H${et/2+10}v${Tt+20}h-${et+20}z`)}const tt=ye().domain([0,Zt(t,function(O){return typeof O.volume=="string"?parseInt(O.volume):O.volume})]).range([x,0]),L=js().x(function(O){return C(new Date(O.date))}).y0(tt(0)).y1(function(O){return tt(typeof O.volume=="string"?parseInt(O.volume):O.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",H);const Z=ti().domain(Y).range([0,w]),ht=ye().domain([V,W]).range([x,0]),ot=Bn().x(function(O){return Z(O.date)}).y(function(O){return ht(O.value)});E.selectAll("path.line").remove(),E.selectAll("g.brush").remove(),n==="linechart"&&M.forEach((O,K)=>{E.append("path").attr("class","line").datum(O.values).attr("fill","none").attr("stroke",u[K]).attr("stroke-width",1).attr("d",ot).attr("clip-path","url(#clip)")}),E.selectAll("path.candle").remove(),n==="candlestick"&&E.selectAll("path.candle").data(U).join(O=>O.insert("path","g.tooltip").attr("class","candle").attr("d",function(K){return Nt(K,ht)}).style("fill",wt).attr("clip-path","url(#clip)"),void 0,O=>O.remove()).attr("d",function(O){return Nt(O,ht)}).style("fill",wt),E.select(".x-axis").attr("transform","translate(0,"+x+")").call(he(Z)).selectAll("text").attr("class",H);const at=Sl().extent([[0,0],[s,x]]).on("brush",A);E.append("g").attr("class","brush").call(at);function A(O){const K=O.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(at.move,null),j()});const j=()=>{k.select(".x-axis").call(he(C)).selectAll("text").attr("class",H),n==="candlestick"?k.selectAll("path.candle").attr("d",function(O){return Nt(O,q)}):n==="linechart"&&k.selectAll("path.chartline").attr("d",pt),_.select(".x-axis").call(he(C)).selectAll("text").attr("class",H),_.selectAll("path.area").attr("d",L)};function nt(){const O=C(U[1].date)-C(U[0].date),K=(O-O*.2)/2;return{barWidth:O,shoulderWidth:K}}function Nt(O,K){let $t,zt;O.open>=O.close?($t=O.open,zt=O.close):($t=O.close,zt=O.open);const{barWidth:et,shoulderWidth:Tt}=nt();K($t)-K(zt);const ut=K(O.hi)-K($t),vt=K(O.low)-K(zt);return"M "+C(O.date)+","+K($t)+" "+(C(O.date)+Tt)+","+K($t)+" "+(C(O.date)+Tt)+","+(K($t)+ut)+" "+(C(O.date)+Tt+et*.2)+","+(K($t)+ut)+" "+(C(O.date)+Tt+et*.2)+","+K($t)+" "+(C(O.date)+et)+","+K($t)+" "+(C(O.date)+et)+","+K(zt)+" "+(C(O.date)+Tt+et*.2)+","+K(zt)+" "+(C(O.date)+Tt+et*.2)+","+(K(zt)+vt)+" "+(C(O.date)+Tt)+","+(K(zt)+vt)+" "+(C(O.date)+Tt)+","+K(zt)+" "+C(O.date)+","+K(zt)+"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,st=0,B={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 B.oldData.set(`${st}-${G.data.name}`,Q?{x0:G.x0,x1:G.x1,y0:G.y0,y1:G.y1}:null),B.oldTarget.set(`${st}-${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,st+1,B)),B}function T(G,st,B=0){const Q=`${B}-${G.data.name}`;if(typeof G.x0=="number"&&typeof G.x1=="number"&&typeof G.y0=="number"&&typeof G.y1=="number"){const D={oldData:st.oldData.get(Q)??null,oldTarget:st.oldTarget.get(Q)??null};G.oldRect=D}return G.children&&G.children.forEach(D=>T(D,st,B+1)),G}function p(G,st){if(!st)return T(G,{oldData:new Map,oldTarget:new Map});const B=y(st);return T(G,B)}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"),H=C.node(),W=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"),q="0 1px 0 lightblue, 1px 0 0 lightblue, -1px 0 0 lightblue, 0 -1px 0 lightblue",$=G=>{let st=G;for(;st.depth>1;)st=st.parent;const B=st.data.name,Q=b.current(B),X=Xe(Q);if(!X)return Q;const D=G.depth,tt=.5;return D===1?X.formatHex():X.darker(D*tt).formatHex()};W.selectAll("path.slice").data(E.descendants(),function(G){return G.data.name}).join(G=>{const st=G.append("path").attr("class","slice").attr("fill",$).style("cursor",function(B){return B.children?"pointer":"default"});return st.transition().duration(d).attrTween("d",function(B){const Q={x0:B.current.x0,x1:B.current.x0,y0:B.current.y0,y1:B.current.y1},X=Ae(Q,{x0:B.x0,x1:B.x1,y0:B.y0,y1:B.y1});return function(D){return B.current=X(D),N(B.current)}}),st},G=>G.transition().duration(d).attrTween("d",function(st){const B=Ae(st.oldRect?st.oldRect.oldTarget?st.oldRect.oldTarget:st.oldRect.oldData:st.current,{x0:st.x0,x1:st.x1,y0:st.y0,y1:st.y1});return function(Q){return st.current=B(Q),N(st.current)}}).attr("fill",$),G=>G.transition().duration(d).style("opacity",0).remove()).on("pointerenter",function(G,st){V.selectAll("text.suntext").filter(X=>X.data.name===st.data.name).style("fill-opacity",1).style("text-shadow",q);const B=st.data.name==="branches"?"Total":st.data.name;w.select("p.name").text(B);const Q=st.value??0;w.select("p.value").text(Pe(Q,e).toLocaleString()),w.transition().duration(250).style("opacity",1),le(w,{e:G,svg:H})}).on("pointermove",function(G,st){le(w,{e:G,svg:H})}).on("pointerleave",function(G,st){V.selectAll("text.suntext").filter(B=>B.data.name===st.data.name).style("fill-opacity",B=>gt(B)?1:0).style("text-shadow",B=>gt(B)?q:"none"),w.transition().duration(250).style("opacity",0)}).on("click",function(G,st){st.children&&wt(G,st)}),C.select("circle.reset").remove();const pt=C.selectAll("circle").data([E]).join("circle").attr("class","reset").attr("r",z).attr("fill","transparent").attr("pointer-events","all").on("click",(G,st)=>wt(G,st));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(st=>st.data.name).transition().duration(d).style("fill-opacity",st=>gt(st)?1:0).style("text-shadow",st=>gt(st)?q:"none").attr("transform",_t),void 0,G=>G.transition().duration(d).style("opacity",0).remove()).transition().duration(d).style("fill-opacity",G=>gt(G)?1:0).style("text-shadow",G=>gt(G)?q:"none").attr("transform",_t).attr("dy","0.35em");function wt(G,st,B=!1){const Q=st;I=Q,pt.style("cursor",I===E?"default":"pointer"),pt.datum(B?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)}),W.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=>gt(X)?1:0).style("text-shadow",X=>gt(X)?q:"none").attrTween("transform",X=>()=>_t(X.current)),o(E)}function gt(G){const st=G.target??G.current,{x0:B,x1:Q,y0:X,y1:D}=st,tt=Q-B,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 st=(G.x0+G.x1)/2*180/Math.PI,B=(G.y0+G.y1)/2*z;return`
64
+ rotate(${st-90})
65
+ translate(${B},0)
66
+ rotate(${st<180?0:180})
67
+ `}},[t,a,i,e,l]);return m.jsx("div",{ref:n,style:{width:a,height:i,display:"flex",flexDirection:"column"},children:m.jsxs("div",{ref:x,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column",position:"relative"},children:[u>0&&s!==null&&m.jsxs("svg",{width:u,height:u,style:{position:"absolute",left:0,top:0},viewBox:`${[-u/2,-u/2,u,u]}`,children:[m.jsx("g",{className:"plot-area"}),m.jsx("g",{className:"label-group"})]}),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 ju=()=>m.jsxs(Qe,{children:[m.jsxs("p",{className:"label",style:{fontWeight:700,margin:"3px",fontSize:"13px",color:"wheat",display:"flex"},children:[m.jsxs("span",{className:"label",style:{flex:1,textAlign:"left",whiteSpace:"nowrap"},children:[m.jsx("span",{className:"chev"}),m.jsx("span",{className:"text"})]}),m.jsx("span",{className:"value",style:{flex:1,textAlign:"right",paddingLeft:4,fontWeight:600}})]}),m.jsxs("p",{className:"from",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat",display:"flex",justifyContent:"flex-end"},children:[m.jsx("span",{className:"label",style:{width:"auto",textAlign:"right",whiteSpace:"nowrap"}}),m.jsx("span",{className:"value",style:{width:"auto",textAlign:"right",paddingLeft:4,fontWeight:600}})]}),m.jsxs("p",{className:"to",style:{fontWeight:"300px",margin:"3px",fontSize:"12px",color:"wheat",display:"flex",justifyContent:"flex-end"},children:[m.jsx("span",{className:"label",style:{width:"auto",textAlign:"right",whiteSpace:"nowrap"}}),m.jsx("span",{className:"value",style:{width:"auto",textAlign:"right",paddingLeft:4,fontWeight:600}})]})]}),me={inflows:"#22c55e",outflows:"#ef4444",open:"steelblue",close:"orange"},Pu=t=>{let e=0,n=0,r=n;return t.map((i,s)=>(e=r,n=e+i.value,r=n,{...i,start:e,end:n}))},xe={"x-axis":"_x-axis_1vpcq_1",label:"_label_1vpcq_9","axis-label":"_axis-label_1vpcq_9","axis-label-sm":"_axis-label-sm_1vpcq_9","clickable-label":"_clickable-label_1vpcq_43",sort:"_sort_1vpcq_59",visible:"_visible_1vpcq_69","chevron-initial":"_chevron-initial_1vpcq_77",chevron:"_chevron_1vpcq_77","chevron-inactive":"_chevron-inactive_1vpcq_127"};function qm({data:t,orientation:e="vertical",tooltipFormat:{prefix:n="",suffix:r="",formatType:a="long"}={prefix:"",suffix:"",formatType:"long"},lineProps:{showLine:i=!1,showDots:s=!0,curve:o="linear"}={showLine:!1,showDots:!0,curve:"linear"}}){const[l,c]=Ne(),{width:u,height:h}=c,[f,g]=He(),{width:v,height:b}=g,[d,x]=bt.useState("waterfall"),[S,w]=bt.useState(!1),y=bt.useRef("data"),T=bt.useRef(!0),p=bt.useRef(!0);bt.useEffect(()=>{d==="waterfall"&&w(!1),T.current?T.current=!1:y.current="mode",p.current=!1},[d]),bt.useEffect(()=>{x("waterfall"),y.current="data",p.current=!1},[t]);const k=v>576,_=750,E=Se(R=>{if(v===0||b===0)return;const z={top:20,right:25,bottom:50,left:25},I=Pu(t),N=d==="waterfall"?I:I.filter(ut=>ut.type==="variation"&&(d==="inflows"?ut.start<=ut.end:ut.start>ut.end)).sort((ut,vt)=>S?Math.abs(vt.value)-Math.abs(ut.value):0),U=R.select("svg"),M=U.node(),Y=U.select(".plot-area").attr("transform","translate("+z.left+","+z.top+")"),H=R.select(".controls").select(".legends-container"),W=k?80:50,V=function(ut){const vt=J[k?"legend-container":"legend-container-sm"],kt=J[k?"legend-container-active":"legend-container-active-sm"];return`
68
+ ${vt}
69
+ ${d!=="waterfall"&&d===ut?kt:""}
70
+ legend-item
71
+ `};H.selectAll(".legend-item").data(["inflows","outflows"],ut=>ut).join(ut=>{const vt=ut.append("div").attr("class",V).style("left",(kt,jt)=>`${jt*W}px`).style("top","-53px").style("opacity",0);return vt.append("div").attr("class",J["legend-rect"]).style("background",kt=>kt==="inflows"?me.inflows:me.outflows),vt.append("span").attr("class",J["legend-label"]).style("color",kt=>"#333").text(kt=>kt),vt.transition().duration(_).style("top","0px").style("opacity",1),vt},ut=>(ut.attr("class",V).transition().duration(_).style("top","0px").style("left",(vt,kt)=>`${kt*W}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(kt=>vt==="inflows"?kt.type==="total"||kt.start>kt.end:kt.type==="total"||kt.start<=kt.end).style("opacity",.5),Y.selectAll(".label").filter(kt=>vt==="inflows"?kt.type==="total"||kt.start>kt.end:kt.type==="total"||kt.start<kt.end).style("opacity",.25))}).on("mouseout",function(ut,vt){d==="waterfall"&&p.current&&(Y.selectAll(".bar").style("opacity",1),Y.selectAll(".label").style("opacity",$t))}).on("click",function(ut,vt){x(d===vt?"waterfall":vt)});const q=hi(R).style("opacity",0),$=v-z.left-z.right,pt=b-z.top-z.bottom,wt=N.map((ut,vt)=>{const kt=vt===N.length-1;return Math.min(ut.start,kt?ut.value:ut.end)}),gt=N.map((ut,vt)=>{const kt=vt===N.length-1;return Math.max(ut.start,kt?ut.value:ut.end)}),_t=d==="waterfall"?Math.min(...wt):0,G=Math.max(...d==="waterfall"?gt:N.map(ut=>Math.abs(ut.value))),st=ye().domain([_t,G]).rangeRound([pt,0]).nice(),B=be(st).ticks(5,"s").tickSize(-$);Y.select(".y-axis").attr("transform","translate(0, 0)").transition().duration(_).call(B);const Q=N.map(ut=>ut.label),X=Oe().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, ${pt})`).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, ${st(0)||0})`);function Z(ut){return X(ut.label)??0}function ht(ut,vt){return d==="waterfall"?ut.type==="total"&&vt>0?ut.start<=ut.end?st(ut.value):st(0):st(Math.max(ut.start,ut.end)):st(Math.abs(ut.value))}function ot(ut,vt){if(d==="waterfall"){const kt=Math.abs(st(ut.start)-st(ut.end));if(ut.type==="total"&&vt>0)if(ut.start<=ut.end){const jt=st(0)-st(ut.value);return jt<0?kt:jt}else return st(0)-st(-ut.value);return kt}return st(0)-st(Math.abs(ut.value))}function at(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,kt)=>y.current==="data"?vt.type==="total"?st(0):st(vt.start):st(0)).attr("height",0).attr("rx",5).attr("ry",5).style("fill",at).transition().duration(A).delay((vt,kt)=>0).attr("y",ht).attr("height",ot).on("end",function(vt,kt){y.current==="data"&&d==="waterfall"?kt===I.length-1&&(p.current=!0):p.current=!0}),ut=>(d==="waterfall"&&y.current==="data"?ut.transition().duration(_).style("fill",at).attr("x",Z).attr("width",X.bandwidth()).attr("y",vt=>vt.type==="total"?st(0):st(vt.start)).attr("height",0).attr("rx",5).attr("ry",5).transition().duration(_).attr("y",ht).attr("height",ot).on("end",function(vt,kt){y.current==="data"&&d==="waterfall"?kt===I.length-1&&(p.current=!0):p.current=!0}):ut.transition().duration(_).style("fill",at).attr("x",Z).attr("width",X.bandwidth()).attr("y",ht).attr("height",ot).on("end",function(vt,kt){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){q.select("p.label span.label span.chev").style("color",vt.value>=0?me.inflows:me.outflows).text(vt.value>0?"▲":vt.value<0?"▼":""),q.select("p.label span.label span.text").text(vt.label+" :"),q.select("p.label span.value").text(_e(vt.value,nt)),vt.type==="total"?(q.select("p.from").style("display","none"),q.select("p.to").style("display","none")):d==="waterfall"?(q.select("p.from").style("display","flex"),q.select("p.from span.label").text("from: "),q.select("p.from span.value").text(_e(vt.start,nt)),q.select("p.to").style("display","flex"),q.select("p.to span.label").text("to: "),q.select("p.to span.value").text(_e(vt.end,nt))):(q.select("p.from").style("display","none"),q.select("p.to").style("display","none")),q.style("opacity",1),le(q,{e:ut,svg:M})}).on("pointermove",function(ut,vt){le(q,{e:ut,svg:M})}).on("pointerleave",function(ut,vt){q.style("opacity",0)});const Nt=12;function O(ut,vt){const kt=ht(ut,vt),jt=ot(ut,vt);return kt+jt/2+Nt/2}function K(ut,vt){const kt=Z(ut),jt=X.bandwidth();return kt+jt/2}function $t(ut,vt){return ot(ut,vt)<20?0:1}const zt=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",Nt).style("font-weight","bold").style("pointer-events","none").style("opacity",0).attr("x",K).attr("y",O).transition().duration(_).style("opacity",$t).attr("x",K).attr("y",O),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",Nt).style("font-weight","bold").transition().duration(_).style("opacity",$t).attr("x",K).attr("y",O),ut=>ut.transition().duration(_).style("opacity",0).remove()),et=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},st,{data:et},v,e,{showLine:i,showDots:s,curve:o,dotFill:Tt}),zt.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
+ ${J["controls-label"]}
73
+ ${xe.sort}
74
+ ${d!=="waterfall"?xe.visible:""}
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(dt=>dt.label==="Opening"),rt=P||ct.data[0];return{label:ct.label,data:{...rt,label:"Opening "}}}),H=p!=="inflows"&&p!=="outflows"?E===-1?C:[C[E]]:[];H.sort((ct,P)=>p==="open"&&x?P.data.value-ct.data.value:0);const W=Y.map(ct=>{const P=ct.data.find(dt=>dt.label==="Closing"),rt=P||ct.data[ct.data.length-1];return{label:ct.label,data:{...rt,label:"Closing"}}}),V=p!=="inflows"&&p!=="outflows"?E===-1?W:[W[E]]:[];V.sort((ct,P)=>p==="close"&&x?P.data.value-ct.data.value:0);const q=["open","close"],$=U.select("svg"),pt=$.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"],st=60,B=function(ct){const P=J[R?"legend-container":"legend-container-sm"],rt=J[R?"legend-container-active":"legend-container-active-sm"],dt=J[R?"legend-container-inactive":"legend-container-inactive-sm"];return`
76
+ ${p!==""?p===ct?rt:dt:P}
77
+ legend-item
78
+ `};_t.selectAll(".legend-item").data([...G],ct=>ct).join(ct=>{const P=ct.append("div").attr("class",B).style("left",(rt,dt)=>`${dt*st}px`).style("top","-53px").style("opacity",0);return P.append("div").attr("class",J["legend-rect"]).style("background",rt=>me[rt]),P.append("span").attr("class",J["legend-label"]).text(rt=>rt),P.transition().duration(z).style("top","0px").style("opacity",1),P},ct=>(ct.attr("class",B).transition().duration(z).style("top","0px").style("left",(P,rt)=>`${rt*st}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 rt=p===P?"":P;rt===""&&S(!1),k(rt)});const X=g-M.left-M.right,D=v-M.top-M.bottom,tt=H.map(ct=>ct?.data.value),L=V.map(ct=>ct?.data.value),Z=[...tt,...L],ht=E===-1?null:Y[E],ot=ht?ht.data:[],at=ot.map((ct,P)=>{const rt=P===ot.length-1;return Math.min(ct.start,rt?ct.value:ct.end)}),A=ot.map((ct,P)=>{const rt=P===ot.length-1;return Math.max(ct.start,rt?ct.value:ct.end)}),j=p==="inflows"||p==="outflows"?p:"waterfall",nt=ot.filter(ct=>ct.type!=="total"),Nt=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),O=j==="waterfall"?Math.min(...at):0,K=Math.max(...j==="waterfall"?A:Nt.map(ct=>Math.abs(ct.value))),$t=Math.min(0,oe(Z)??0),zt=Math.max(0,Zt(Z)??0),et=ye().domain(E===-1?[$t,zt]:[O,K]).range([D,0]).nice(),Tt=be(et).ticks(5,"s").tickSize(-X);wt.select(".y-axis").attr("transform","translate(0, 0)").transition().duration(z).call(Tt);const ut=p==="open"&&x?H.map(ct=>ct.label):p==="close"&&x?V.map(ct=>ct.label):Y.map(ct=>ct.label),vt=j==="waterfall"?ot.map(ct=>ct.label==="Opening"?"open":ct.label==="Closing"?"close":ct.label):Nt.map(ct=>ct.label),kt=E===-1?ut:vt,jt=Oe().domain(kt).rangeRound([0,X]).padding(.2),Xt=he(jt).tickValues(jt.domain()).scale(jt).tickSizeOuter(0),ie=Oe().domain(q).range([0,jt.bandwidth()]).padding(.05),Gt=`${di(g,kt)?`${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",`${Gt}`),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, ${et(0)||0})`);const ae=12,Ct=({labelData:ct,xPos:P,barWidth:rt,yPos:dt,barHeight:Lt,labelFor:Dt})=>{const It=ct[0]&&"data"in ct[0]?"openClose":"waterfall";function Yt(Bt,Kt){return P(Bt,Kt)+rt/2}function Ot(Bt,Kt){const Ge=dt(Bt,Kt),Ze=Lt(Bt,Kt);return Ge+Ze/2+ae/2}function Qt(Bt,Kt){return p==="open"&&Dt==="close"||p==="close"&&Dt==="open"?0:Lt(Bt,Kt)>=20&&rt>=20?1:0}const ge=Bt=>{const Kt=It==="openClose"?Bt.data.value:Bt.value;return pe("~s")(j!=="waterfall"?Math.abs(Kt):Kt)},Et=Dt?`${Dt}label`:"label";return wt.selectAll(`.${Et}`).data(ct,Bt=>Bt?.label+`${Dt?"-"+Dt:""}`).join(Bt=>Bt.append("text").attr("class",`${Et} ${xe.label}`).text(ge).attr("text-anchor","middle").style("font-size",ae).style("font-weight","bold").style("pointer-events","none").style("opacity",0).attr("x",Yt).attr("y",et(0)).transition().duration(z).style("opacity",Qt).attr("x",Yt).attr("y",Ot),Bt=>Bt.attr("class",`${Et} ${xe.label}`).text(ge).attr("text-anchor","middle").style("font-size",ae).style("font-weight","bold").transition().duration(z).style("opacity",Qt).attr("x",Yt).attr("y",Ot),Bt=>Bt.remove())},Rt=(ct,P)=>E===-1?(jt(ct.label)??0)+(ie(P)??0):jt(P)??0,ft=E===-1&&p!=="open"&&p!=="close"?ie.bandwidth():jt.bandwidth(),Mt=(ct,P)=>Rt(ct,"open"),it=(ct,P)=>E===-1?ct.data.value>=0?et(ct.data.value):et(0):et(Math.max(ct.data.start,ct.data.end)),mt=(ct,P)=>Math.abs(E===-1?et(ct.data.value)-et(0):et(ct.data.start)-et(ct.data.end)),F=wt.selectAll("rect.open").data(H,ct=>ct?.label||" - open").join(ct=>ct.append("rect").attr("class",`open ${J.bar}`).attr("fill",me.open).attr("y",et(0)??0).attr("height",0).attr("x",Mt).attr("width",ft),void 0,ct=>ct.remove());F.transition().duration(z).attr("x",Mt).attr("width",ft).attr("y",it).attr("height",mt).style("opacity",p!=="close"?1:0).style("pointer-events",p!=="close"?"auto":"none"),Ct({labelData:H,xPos:Mt,barWidth:ft,yPos:it,barHeight:mt,labelFor:"open"});const yt=(ct,P)=>Rt(ct,p==="close"?"open":"close"),At=(ct,P)=>E===-1?ct.data.value>=0?et(ct.data.value):et(0):ct.data.start<=ct.data.end?et(ct.data.value):et(0),Pt=(ct,P)=>{if(E===-1)return Math.abs(et(ct.data.value)-et(0));{const rt=Math.abs(et(ct.data.start)-et(ct.data.end));if(ct.data.start<=ct.data.end){const dt=et(0)-et(ct.data.value);return dt<0?rt:dt}else return et(0)-et(-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",et(0)).attr("height",0).attr("x",yt).attr("width",ft),void 0,ct=>ct.remove());ee.transition().duration(z).attr("x",yt).attr("width",ft).attr("y",At).attr("height",Pt).attr("fill","orange").style("opacity",p!=="open"?1:0).style("pointer-events",p!=="open"?"auto":"none"),Ct({labelData:V,xPos:yt,barWidth:ft,yPos:At,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?et(ct.value):et(0):et(Math.max(ct.start,ct.end)):et(Math.abs(ct.value))}function xt(ct,P){if(j==="waterfall"){const rt=Math.abs(et(ct.start)-et(ct.end));if(ct.type==="total"&&P>0)if(ct.start<=ct.end){const dt=et(0)-et(ct.value);return dt<0?rt:dt}else return et(0)-et(-ct.value);return rt}return et(0)-et(Math.abs(ct.value))}function St(ct){return ct.start<=ct.end?me.inflows:me.outflows}const Wt=wt.selectAll(".bar").data(Nt,ct=>ct.label).join(ct=>ct.append("rect").attr("class",`bar ${J.bar}`).attr("x",re).attr("width",jt.bandwidth()).attr("y",(P,rt)=>w.current==="data"?P.type==="total"?et(0):et(P.start):et(0)).attr("height",0).attr("rx",5).attr("ry",5).style("fill",St).transition().duration(z).attr("y",lt).attr("height",xt).on("end",function(P,rt){w.current==="data"&&j==="waterfall"?rt===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",xt).attr("rx",5).attr("ry",5),ct),ct=>ct.transition().duration(z).style("opacity",0).remove());Ct({labelData:Nt,xPos:re,barWidth:jt.bandwidth(),yPos:lt,barHeight:xt});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===""?ie.bandwidth()/2:jt.bandwidth()/2},et,{data:ue,idExtension:"open"},g,"vertical",{showLine:a,showDots:i,curve:s,lineStroke:String(Xe(me.open)?.darker()),dotFill:me.open});const Ut=(p===""||p==="close")&&E===-1?W.map(ct=>({label:ct.label,value:ct.data.value})):[];aa(wt,{scale:jt,offset:E===-1&&p===""?jt.bandwidth()/2+ie.bandwidth()/2:jt.bandwidth()/2},et,{data:Ut,idExtension:"close"},g,"vertical",{showLine:a,showDots:i,curve:s,lineStroke:String(Xe(me.close)?.darker()),dotFill:me.close});const hn=(j==="waterfall"?ot:Nt).map((ct,P)=>({label:ct.label==="Opening"?"open":ct.label==="Closing"?"close":ct.label,value:j!=="waterfall"?Math.abs(ct.value):P!==ot.length-1?ct.end:ct.value})),to=j==="waterfall"?"#2b2b22":me[j];aa(wt,{scale:jt,offset:jt.bandwidth()/2},et,{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:rt,label:dt}=P.data;Gn(P.label+" "+dt+" :",rt),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:pt})},la=()=>{se.style("opacity",0)};F.on("pointerenter",wi).on("pointermove",oa).on("pointerleave",la),ee.on("pointerenter",wi).on("pointermove",oa).on("pointerleave",la),Wt.on("pointerenter",function(ct,P){const{label:rt,value:dt}=P;Gn(rt,dt),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
+ ${J["controls-label"]}
80
+ ${xe.sort}
81
+ ${p!==""?xe.visible:""}
82
+ `,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:x,onChange:U=>S(U.target.checked)}),"Sort"]}),m.jsx("div",{className:`legends-container ${J["legends-container"]}`})]}),m.jsxs("div",{ref:h,className:`${J["fill-container"]}`,style:{display:"flex",flexDirection:"column"},children:[m.jsxs("svg",{className:`${J["chart-svg"]} ${J["fill-container"]}`,style:{},viewBox:`0 0 ${g} ${v}`,children:[m.jsx("g",{transform:`translate(10, ${v/2})`,onClick:()=>{b>0&&d(b-1),k(""),S(!1)},className:"chevron chevron-left",children:m.jsx("path",{className:`
83
+ ${xe["chevron-initial"]}
84
+ ${b===0?xe["chevron-inactive"]:b>0?xe.chevron:""}`,d:`
85
+ M ${N/2} ${-N/2}
86
+ L ${-N/2} 0
87
+ L ${N/2} ${N/2}
88
+ Z
89
+ `})}),m.jsx("g",{transform:`translate(${g-10}, ${v/2})`,onClick:()=>{b<t.length-1&&d(b+1),k(""),S(!1)},className:"chevron chevron-right",children:m.jsx("path",{className:`
90
+ ${xe["chevron-initial"]}
91
+ ${b>-1?b<t.length-1?xe.chevron:xe["chevron-inactive"]:""}`,d:`
92
+ M ${-N/2} ${-N/2}
93
+ L ${N/2} 0
94
+ L ${-N/2} ${N/2}
95
+ Z
96
+ `})}),m.jsx("g",{transform:`translate(${g/2}, 10)`,onClick:()=>{d(-1),k(""),S(!1)},className:"chevron chevron-top",children:m.jsx("path",{className:`
97
+ ${xe["chevron-initial"]}
98
+ ${b>-1?xe.chevron:""}
99
+ `,d:`
100
+ M ${-N/2} ${N/2}
101
+ L 0 ${-N/2}
102
+ L ${N/2} ${N/2}
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(at=>at!=="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(at){return`${J[v?"legend-container":"legend-container-sm"]} legend-item`};z.selectAll(".legend-item").data([...p],at=>at).join(at=>{const A=at.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},at=>(at.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%"),at.select(`.${J["legend-label"]}`).text(A=>A),at),at=>at.transition().duration(b).style("opacity",0).style("top","53px").remove());const U=S.select("div#tooltip").style("opacity",0),M=Oe().domain(t.map(at=>at.label)).rangeRound([0,n==="horizontal"?T:y]).paddingOuter(.1),Y=oe(t,at=>at[p[0]])??0,C=Zt(t,at=>at[p[0]])??0,H=oe(t,at=>at[p[1]])??0,W=Zt(t,at=>at[p[1]])??0,V=Math.min(Y,H),q=Math.max(C,W),$=ye().domain([V,q]).rangeRound(n==="horizontal"?[0,y]:[T,0]).nice(),pt=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(pt),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=at=>$(at[p[0]]),G=at=>$(at[p[1]]),st=at=>(M(at.label)??0)+M.bandwidth()/2,B=at=>n==="horizontal"?_t(at):st(at),Q=at=>n==="horizontal"?st(at):_t(at),X=at=>n==="horizontal"?G(at):st(at),D=at=>n==="horizontal"?st(at):G(at);E.selectAll("line.link").data(t,at=>at.label).join(at=>at.append("line").attr("class","link").attr("stroke","#9ca3af").attr("stroke-width",2.5).attr("x1",B).attr("y1",Q).attr("x2",B).attr("y2",Q).transition().duration(b).attr("x1",B).attr("y1",Q).attr("x2",X).attr("y2",D),at=>at.transition().duration(b).attr("x1",B).attr("y1",Q).attr("x2",X).attr("y2",D),at=>at.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ht).on("pointerleave",ot);const tt=v?7:4;E.selectAll("circle.start").data(t,at=>at.label+"-start").join(at=>at.append("circle").attr("class","start").attr("fill",d.startColor).attr("cx",B).attr("cy",Q).transition().duration(b).attr("cx",B).attr("cy",Q).attr("r",tt),at=>at.transition().duration(b).attr("cx",B).attr("cy",Q).attr("r",tt),at=>at.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ht).on("pointerleave",ot),E.selectAll("circle.end").data(t,at=>at.label+"-end").join(at=>at.append("circle").attr("class","end").attr("fill",d.endColor).attr("cx",B).attr("cy",Q).transition().duration(b).attr("cx",X).attr("cy",D).attr("r",tt),at=>at.transition().duration(b).attr("cx",X).attr("cy",D).attr("r",tt),at=>at.transition().duration(b).style("opacity",0).remove()).on("pointerenter",Z).on("pointermove",ht).on("pointerleave",ot);const L={prefix:r,suffix:a,formatType:i};function Z(at,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 Nt=nt-j;U.select("p.total span.label span.text").text(_e(Nt,L)),U.select("p.total span.label span.chev").style("color",Nt>=0?"#22c55e":"#ef4444").text(Nt>0?"▲":Nt<0?"▼":""),le(U,{e:at,svg:_,yScale:$})}function ht(at,A){le(U,{e:at,svg:_,yScale:$})}function ot(at,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),H=_(C),W=a===null;N.every(D=>Y.includes(D));const q=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 pt=p.selectAll("linearGradient").data(H).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,ht]=$(tt,q),[ot,at]=$(L,q);te(this).attr("x1",Z).attr("y1",ht).attr("x2",ot).attr("y2",at)});pt.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)}),pt.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(q-10),gt=p.selectAll("path.link").data(H).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(W?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(ht=>{const ot=N[ht.source.index],at=N[ht.target.index],A=Y[tt.source.index],j=Y[tt.target.index];return ot===A&&at===j}),Z=Ae(L,tt);return ht=>wt(Z(ht))}),D=>D.transition().duration(x).style("fill-opacity",0).remove()),_t=si().innerRadius(q>10?q-10:0).outerRadius(q),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)}},st=p.selectAll("g.nodes").data(H.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});st.selectAll("path").data(D=>[D]).join(D=>{const tt=D.append("path").style("fill",function(L,Z){const ht=Y[L.index],ot=d.current.findIndex(at=>at===ht);return de(ot,!0)}).style("stroke","#a89ea9");return tt.transition().duration(x).attr("d",_t).attrTween("d",function(L){if(!W)return G(L,"not exit");const Z=Ae(0,L.startAngle),ht=Ae(0,L.endAngle);return function(ot){return L.startAngle=Z(ot),L.endAngle=ht(ot),_t(L)}}),tt},D=>{const tt=D;return tt.transition().duration(x).style("fill",function(L,Z){const ht=Y[L.index],ot=d.current.findIndex(at=>at===ht);return de(ot,!0)}).attrTween("d",function(L){const Z=Y[L.index],ht=M.groups.find(nt=>N[nt.index]===Z),ot=ht&&ht.startAngle?ht.startAngle:0,at=Ae(ot,L.startAngle),A=ht&&ht.endAngle?ht.endAngle:0,j=Ae(A,L.endAngle);return function(nt){return L.startAngle=at(nt),L.endAngle=j(nt),_t(L)}}),tt},D=>D.transition().duration(x).attrTween("d",function(tt){return G(tt,"exit")}).remove());const B=pa(0,Dr(C.flat()),100);st.selectAll("g.group-tick").data(D=>h(D,B),D=>D.value).join(D=>{const tt=D.append("g").attr("class","group-tick").attr("transform",L=>`
105
+ rotate(${L.angle*180/Math.PI-90})
106
+ translate(${q},0)
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
+ rotate(${tt.angle*180/Math.PI-90})
109
+ translate(${q},0)
110
+ `).style("opacity",1),D=>D.transition().duration(x).style("opacity",0).remove()).select("text").filter(D=>D.value%(B*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"),st.select("text").attr("font-weight","bold").text(function(D){return this.getAttribute("text-anchor")==="end"?`↑ ${Y[D.index]}`:`${Y[D.index]} ↓`});const X=.3;st.on("pointerenter",function(D,tt){D.stopPropagation(),st.filter(K=>K.index!==tt.index).style("opacity",X),gt.filter(K=>K.source.index!==tt.index&&K.target.index!==tt.index).style("opacity",X);const L=gt.filter(K=>K.target.index===tt.index&&K.source.index!==tt.index),Z=gt.filter(K=>K.source.index===tt.index&&K.target.index!==tt.index),ht=gt.filter(K=>K.source.index===tt.index&&K.target.index===tt.index),ot=L.data(),at=Z.data(),A=ht.data(),j=ot.reduce((K,$t)=>K+$t.target.value,0),nt=at.reduce((K,$t)=>K+$t.source.value,0),Nt=A.reduce((K,$t)=>K+$t.source.value,0);k.style("opacity",1);const O=Y[tt.index];k.select("p.name").style("display","block").text(O),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(Nt)}${n}`),le(k,{e:D,svg:T})}).on("pointermove",(D,tt)=>{le(k,{e:D,svg:T})}).on("pointerleave",function(D,tt){st.filter(L=>L.index!==tt.index).style("opacity",1),gt.style("opacity",1),k.style("opacity",0)}),gt.on("pointerenter",function(D,tt){D.stopPropagation(),st.filter(A=>A.index!==tt.source.index&&A.index!==tt.target.index).style("opacity",X),gt.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],ht=`${e}${Yn(tt.source.value)}${n}`,ot=`${e}${Yn(tt.target.value)}${n}`,at=`
111
+ ${e}
112
+ ${Yn(tt.source.value-tt.target.value)}
113
+ ${n}
114
+ `;L===Z?(k.select("p.name").style("display","block").text(`${L} (internal): ${ht}`),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(`${ht}`),k.select("p.value2").style("display","flex"),k.select("p.value2 span.label").text(`${Z} → ${L}:`),k.select("p.value2 span.value").text(`${ot}`),k.select("p.selfValue").style("display","flex"),k.select("p.selfValue span.label").text(`Total ${L} → ${Z}:`),k.select("p.selfValue span.value").text(`${at}`))}).on("pointermove",(D,tt)=>{le(k,{e:D,svg:T})}).on("pointerleave",function(D,tt){st.filter(L=>L.index!==tt.source.index&&L.index!==tt.target.index).style("opacity",1),gt.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},H=T-C.left-C.right,W=p-C.top-C.bottom,V=Y.select("svg"),q=V.node(),$=V.select(".plot-area").attr("transform","translate("+C.left+","+C.top+")"),pt=et=>{const Tt=et.data.filter(ut=>{const vt=ut[et.valueKey],kt=typeof vt=="string"||typeof vt=="number"?String(vt):"";return!isNaN(parseFloat(kt))});return{title:et.title,valueKey:et.valueKey,data:Tt}},wt=N?pt(t):t.data.reduce((et,Tt)=>{const ut=pt(Tt);return et.push(ut),et},[]),gt=N?wt:{title:t.title,data:wt},_t=N?gt.data.map(et=>parseFloat(String(et[t.valueKey]))):gt.data.reduce((et,Tt)=>{if(!Tt.valueKey)return et;const ut=Tt.valueKey,vt=Tt.data.map(kt=>parseFloat(String(kt[ut])));return et.push(...vt),et},[]),G=Math.min(..._t),st=Math.max(..._t),B=ye().domain([G,st]).range([0,H]),Q=et=>{if(!et||!et.data||et.data.length===0)return[];const Tt=et.data.map(Ct=>parseFloat(String(Ct[et.valueKey]))),ut=Math.min(...Tt),vt=Math.max(...Tt);ga(ut,vt,(vt-ut)/15);const{mode:jt,value:Xt,compareConsolidate:ie}=n,Jt=et.valueKey||"",Ht=rf().value(Ct=>Ct[Jt]).domain(ie?[G,st]:[ut,vt]);function Gt(Ct,Rt,ft){if(ft<=0)throw new Error("interval must be greater than 0");let Mt=Math.floor(Ct/ft)*ft,it=Math.ceil(Rt/ft)*ft;Mt>=Ct&&(Mt-=ft),it<=Rt&&(it+=ft);const mt=[];for(let F=Mt;F<=it;F+=ft)mt.push(F);return mt}if(jt==="arbitrary")Ht.thresholds(B.ticks(Xt));else if(jt==="fixed")Ht.thresholds(ga(ut,vt,(vt-ut)/Xt));else if(jt==="interval"){const Ct=Gt(ut,vt,Xt);Ht.thresholds(Ct)}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(et.data)},X=N?[Q(gt),[]]:[Q(gt.data[0]),Q(gt.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(et=>et.title),Z=I?80:60,ht=function(){return`${J[I?"legend-container":"legend-container-sm"]} legend-item`},ot={base:"#7c3aed",layer1:{positive:"#2563eb",negative:"#f43f5e"},layer2:{positive:"#22c55e",negative:"#dc2626"}};Y.select(".controls").select(".legends-container").selectAll(".legend-item").data(tt,et=>et.title).join(et=>{const Tt=et.append("div").attr("class",ht).style("left",(kt,jt)=>`${jt*Z}px`).style("top","-53px").style("opacity",0),ut=Tt.append("div").attr("class",function(kt,jt){return`
115
+ legends-rect
116
+ ${ce[jt===0?"legends-layer1":"legends-layer2"]}
117
+ ${ce["histogram-legends-container"]}
118
+ `}).style("width",`${Z}px`);return ut.append("div").attr("class",`${J["legend-rect"]}
119
+ ${N?ce.base:ce.positive}
120
+ `).append("p").text("+").style("opacity",`${D?1:0}`),D&&ut.append("div").attr("class",`${J["legend-rect"]} ${ce.negative}`).append("p").text("-"),Tt.append("p").text((kt,jt)=>L[jt]).attr("class",ce["legend-label"]),Tt.transition().duration(U).style("top","0px").style("opacity",1),Tt},et=>{et.attr("class",ht);const Tt=et.selectAll("div.legends-rect");Tt.attr("class",function(vt,kt){const jt=L.indexOf(vt.title);return`
121
+ legends-rect
122
+ ${ce[jt===0?"legends-layer1":"legends-layer2"]}
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}`),et.transition().duration(U).style("top","0px").style("left",(vt,kt)=>`${kt*Z}px`).style("opacity",1),et},et=>et.style("color",Ee).transition().duration(U).style("opacity",0).style("top","53px").remove());const j=Math.max(...X[0].map(et=>et?.length)),nt=Math.max(...X[1].map(et=>et?.length)),Nt=Math.max(j,nt),O=N?Q(gt).filter(et=>et.length>0).sort((et,Tt)=>Tt.length-et.length).map(et=>et.x0+"-"+et.x1):[],K=Y.select("#tooltip").style("opacity",0),$t={prefix:s,suffix:o,formatType:l};function zt(et,Tt){const ut=!N&&e==="compare",vt=N?t.valueKey??0:t.data[Tt-1].valueKey??0,kt=Tt===1?$.select(".layer-1"):$.select(".layer-2");Tt===1?kt.transition().duration(U).attr("transform",`translate(${i==="horizontal"&&ut?H/2:0}, 0)`):kt.transition().duration(U).attr("transform",`translate(
125
+ 0,
126
+ ${i==="vertical"&&ut?W/2:0})`),R&&(a&&(et=et.filter(Ct=>Ct.length>0)),et.sort((Ct,Rt)=>Rt.length-Ct.length));const jt=ye().domain([G,st]).range(i==="vertical"?[0,H]:[0,W]),Xt=et.map(Ct=>Ct.x0+"-"+Ct.x1),ie=Tt===2&&Xt.length===0?O:Xt,Jt=Oe().domain(ie).rangeRound(i==="vertical"?[0,H]:[0,W]),Ht=ye().domain([0,Nt]).nice();if(Tt===1){Ht.range(i==="vertical"?[ut?W/2:W,0]:[0,ut?H/2:H]).nice();const Ct=i==="vertical"&&(!I||R)?N?J.rotatedAxisText:J.rotatedTopAxisText:J.axisText,Rt=va(i==="vertical"?R?Jt:jt:Ht);i==="vertical"?Rt.tickSizeOuter(0).ticks(10):Rt.tickSizeOuter(0).ticks(5,"s").tickSize(-W),kt.select(".x-axis").transition().duration(U).call(Rt).attr("transform","translate(0, 0)").style("opacity",i==="horizontal"||!N&&R?1:0).selectAll("text").attr("class",Ct);const ft=i==="vertical"?be(Ht):Ni(R?Jt:jt);i==="vertical"?ft.ticks(5,"s").tickSize(-H):ft.tickSizeOuter(0),kt.select(".y-axis").transition().duration(U).attr("transform",`translate(
127
+ ${i==="horizontal"&&ut?H/2:0},
128
+ 0
129
+ )`).style("opacity",ut?1:0).call(ft)}else{Ht.range(i==="vertical"?ut?[0,W/2]:[W,0]:ut?[H/2,0]:[0,H]).nice();const Ct=i==="vertical"&&(!I||R)?J.rotatedAxisText:J.axisText,Rt=i==="vertical"?he(R?Jt:jt):va(Ht);i==="vertical"?Rt.tickSizeOuter(0).ticks(10):Rt.tickSizeOuter(0).ticks(5,"s").tickSize(W),kt.select(".x-axis").attr("transform",`translate(0, ${i==="vertical"&&ut?W/2:W})`).transition().duration(U).call(Rt).selectAll("text").attr("class",Ct);const ft=be(i==="vertical"?Ht:R?Jt:jt);i==="vertical"?ft.ticks(5,"s").tickSize(-H):ft.tickSizeOuter(0),kt.select(".y-axis").transition().duration(U).call(ft)}const Gt=Ct=>(jt(Ct.x0)||0)<jt(0)?Tt===1?ot.layer1.negative:ot.layer2.negative:N?ot.base:Tt===1?ot.layer1.positive:ot.layer2.positive;kt.selectAll("rect.bar").data(et,Ct=>Ct.x0+"-"+Ct.x1).join(Ct=>Ct.append("rect").attr("class",`bar ${J.bar}`).attr("x",function(Rt){return i==="vertical"?(R?Jt(Rt.x0+"-"+Rt.x1):jt(Rt.x0)||0)||0:Ht(0)}).attr("width",function(Rt){return i==="vertical"?R?Jt.bandwidth():jt(Rt.x1)-jt(Rt.x0)||0:0}).style("fill","#4ade80").style("stroke","#394447").attr("y",function(Rt){return i==="vertical"?Ht(0):(R?Jt(Rt.x0+"-"+Rt.x1):jt(Rt.x0)||0)||0}).attr("height",function(Rt){return i==="vertical"?0:R?Jt.bandwidth():jt(Rt.x1)-jt(Rt.x0)||0}),void 0,Ct=>Ct.transition().duration(U).attr("y",Ht(0)).attr("height",0).style("fill","#a1a1aa").style("opacity",0).remove()).on("pointerenter",function(Ct,Rt){K.select("p.range span.badge").style("background",Gt(Rt)),K.select("p.range span.label").text(`
130
+ ${_e(Rt.x0??0,$t)}
131
+ <= ${vt} <
132
+ ${_e(Rt.x1??0,$t)}
133
+ `);const ft=Rt.length;K.select("p.amount").text(`
134
+ ${ft}
135
+ member${ft>1?"s":""}
136
+ `),K.style("opacity",1),le(K,{e:Ct,svg:q,yScale:Ht})}).on("pointermove",function(Ct,Rt){le(K,{e:Ct,svg:q,yScale:Ht})}).on("pointerleave",function(Ct,Rt){K.style("opacity",0)}).on("dblclick",function(Ct,Rt){const ft=t,Mt=N?ft.valueKey??"":ft.data[Tt-1].valueKey??"";_({valueKey:Mt,data:Rt})}).on("touchend",function(Ct,Rt){const ft=Date.now();if(ft-E.current<=300){const it=t,mt=N?it.valueKey??"":it.data[Tt-1].valueKey??"";_({valueKey:mt,data:Rt})}E.current=ft}).transition().duration(U).style("fill",Gt).attr("x",function(Ct){return i==="vertical"?(R?Jt(Ct.x0+"-"+Ct.x1):jt(Ct.x0)||0)||0:Ht(Tt===2&&ut?Ct.length:0)}).attr("width",function(Ct){if(i==="vertical"){if(R)return Jt.bandwidth();{const Rt=Ct.x0,ft=Ct.x1,Mt=ft===Rt?Rt+1:ft;return jt(Mt)-jt(Rt)||0}}else return Tt===2&&ut?H/2-Ht(Ct.length):Ht(Ct.length)}).attr("y",function(Ct){return i==="vertical"?Tt===2&&e==="compare"?Ht(0):Ht(Ct.length)||0:(R?Jt(Ct.x0+"-"+Ct.x1):jt(Ct.x0)||0)||0}).attr("height",function(Ct){if(i==="vertical")return Tt===2&&e==="compare"?Ht(Ct.length):(ut?W/2:W)-Ht(Ct.length)||0;if(R)return Jt.bandwidth();{const Rt=Ct.x0,ft=Ct.x1,Mt=ft===Rt?Rt+1:ft;return jt(Mt)-jt(Rt)||0}});const ae=Tt===1?N?"#394447":D?ot.layer1.positive:ot.base:ot.layer2.positive;rv(kt,{binRanges:jt,binSorted:Jt,isSorted:R},Ht,et,T,i,{showLine:c,showDots:u,lineStroke:String(Xe(ae)?.darker()),dotFill:ae})}zt(X[0],1),zt(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
+ ${ce["table-container"]}
138
+ ${l.length===0?ce["hide-table"]:ce["show-table"]}
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(H=>{if(S===0||w===0||Y)return;const W=Math.min(S,w)/2-30,V=H.select("svg"),q=V.selectAll("defs"),$=V.node(),pt=V.select(".plot-area"),gt=H.select(".controls").select(".legends-container"),_t=M==="bubble"?t.groupBy:"",G=_t!==""?[...new Set(t.nodes.map(P=>P[_t]))]:[],st=60,B=function(P){const rt=J[R?"legend-container":"legend-container-sm"],dt=J[R?"legend-container-active":"legend-container-active-sm"],Lt=J[R?"legend-container-inactive":"legend-container-inactive-sm"];return`
140
+ ${y!==""?y===P?dt:Lt:rt}
141
+ legend-item
142
+ `},Q=hr(qr);gt.selectAll(".legend-item").data([...G],P=>P).join(P=>{const rt=P.append("div").attr("class",B).style("left",(dt,Lt)=>`${Lt*st}px`).style("top","-53px").style("opacity",0);return rt.append("div").attr("class",J["legend-rect"]).style("background",dt=>Q(dt)).style("border-radius","50%"),rt.append("span").attr("class",J["legend-label"]).text(dt=>dt),rt.transition().duration(U).style("top","0px").style("opacity",1),rt},P=>(P.attr("class",B).transition().duration(U).style("top","0px").style("left",(rt,dt)=>`${dt*st}px`).style("opacity",1).select(`.${J["legend-rect"]}`).style("background",rt=>Q(rt)).style("border-radius","50%"),P.select(`.${J["legend-label"]}`).text(rt=>rt),P),P=>P.transition().duration(U).style("opacity",0).style("top","53px").remove().remove()).on("click",function(P,rt){T(y!==rt?rt:"")});function D(P){function rt(dt,Lt,Dt){Lt===0?dt.group=dt.name:(Lt===1&&(Dt=dt.name),dt.group=Dt),dt.children?.forEach(It=>rt(It,Lt+1,Dt))}return rt(P,0,P.name),P}const tt=we(t);(M==="network"||M==="hierarchy")&&D(tt);const L=H.select("#tooltip").style("opacity",0),Z=M==="bubble"?t.tooltipColumns??["label"].concat(Object.keys(t.nodes[0]).map(P=>P)):["name","value"],ht=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"),ot=M==="hierarchy"?fr(tt):tt;let at=[],A=[],j=[],nt=F0();function Nt(P,rt,dt){const Lt=t.valueProp,It={label:"bubble nodes",children:P.map(Kt=>{const Ge=Kt[Lt];return{...Kt,value:Ge}})},Qt=Cu().padding(2).size([rt,rt]).value(function(Kt){return Kt.value}).nodes(It)[0],ge=[Qt.x,Qt.y,Qt.r*2],Et=Qt.children,qt=rt/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 dt&&dt.nodes(Bt),Bt}const{curve:O,directed:K}=N;if(_.current)if(M==="hierarchy"){const rt=()=>(ot.sum(Dt=>Dt.value??1),Jl().size([S,w]).padding(1)(ot));if(a!=="default"){if(A=a==="nodes only"?rt().descendants():rt().leaves(),A.forEach(dt=>{dt.x-=S/2,dt.y-=w/2}),a==="nodes only"){const dt=Zt(A,function(Dt){return Dt.value}),Lt=oc().exponent(.5).range([2,60]).domain([0,dt??0]);A.forEach(Dt=>{Dt.r=Lt(Dt.value)})}}else{rt().descendants();const Lt=tc().size([2*Math.PI,W]).separation((Dt,It)=>(Dt.parent==It.parent?1:2)/Dt.depth)(ot);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(),at=Lt.links()}}else if(M==="network"){if(A=ot.nodes,at=ot.links,K){const rt=[...new Set(at.map(dt=>dt.type))];j=rt.some(dt=>dt===void 0)?["arrow"]:[...rt]}}else{const P=ot.nodes,rt=Math.min(S,w);A=Nt(P,rt,nt)}const $t=P=>a==="default"?P.depth===0?8:P.depth===1?5:3:P.r,zt=4,et=.03;if(_.current){let P=function(dt,Lt,Dt=.2){let It=[];function Yt(Ot){const Qt=Gu(It,Et=>rt(Et,Lt),dt),ge=Ot*Dt;for(const Et of It){const qt=dt(Et),{x:Bt,y:Kt}=Qt.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=>{It=Ot},Yt},rt=function(dt,Lt){let Dt=0,It=0,Yt=0;for(const Ot of dt){const ge=Lt(Ot)**2;Dt+=(Ot.x??0)*ge,It+=(Ot.y??0)*ge,Yt+=ge}return{x:Yt===0?0:Dt/Yt,y:Yt===0?0:It/Yt}};if(nt.nodes(A),M==="hierarchy")if(a!=="default"){let dt=function(){let Yt,Ot;const Qt=()=>{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 Ue=We;Ue;Ue=Ue.next)if(Ue.data!==Et){const Zn=Et.r+Ue.data.r+(Et.data.group===Ue.data.data.group?2:6);let Jn=Et.x-Ue.data.x,Ar=Et.y-Ue.data.y,pn=Math.hypot(Jn,Ar);pn<Zn&&(pn=(pn-Zn)/pn*.4,Et.x-=Jn*=pn,Et.y-=Ar*=pn,Ue.data.x+=Jn,Ue.data.y+=Ar)}}return ve>Ge||_i<Bt||dn>Ze||kr<Kt})}};return Qt.initialize=ge=>{Yt=ge,Ot=Zt(Yt,Et=>Et.r)+Math.max(2,6)},Qt};if(a==="nodes only"){let Lt=function(It){return-Math.pow(It.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(It=>Lt(It))).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",dt()).alpha(1).alphaTarget(0)}}else nt.force("center",fs()).force("link",ds(at).id(dt=>dt.id).distance(50)).force("x",Nn(-S/2).x(dt=>dt.finalX??0).strength(1)).force("y",Tn(-w/2).y(dt=>dt.finalY??0).strength(1)).force("charge",Or().strength(-30)).force("collide",Wr().radius($t)).alpha(.15).alphaTarget(0);else if(M==="network")O==="straight"?nt.force("link",ds(at).id(dt=>dt.id)).force("charge",Or()).force("center",fs().x(0).y(0)).alpha(1).alphaTarget(0):O==="curved"&&nt.force("link",ds(at).id(dt=>dt.id)).force("charge",Or()).force("center",fs()).alpha(1).alphaTarget(0);else if(M==="bubble"){let dt=function(Dt){return-Math.pow(Dt.r??0,2)*et};nt.velocityDecay(.2).force("x",Nn().strength(et).x(0)).force("y",Tn().strength(et).y(0));const{clusterByGroup:Lt}=t;if(!Lt)nt.force("charge",Or().strength(dt));else{const Dt=P(It=>String(It[t.groupBy]),It=>It.r??0,.2);nt.force("cluster",Dt).force("collide",Wr().radius(It=>It.r??2).iterations(3))}}z.current=nt}else if(nt=z.current,A=nt?.nodes(),M!=="bubble"){if(at=nt.force("link")?.links(),K){const dt=[...new Set(at.map(Lt=>Lt.type))];j=dt.some(Lt=>Lt===void 0)?["arrow"]:[...dt]}}else{const P=S>w?"desktop":"mobile",rt=P==="desktop"?{x:S/4,y:0}:{x:0,y:w/4},dt=P==="desktop"?{x:-S/4,y:0}:{x:0,y:-w/4};if(p){let Lt=function(It){if(!It.length)return 0;const Yt=It.reduce((Et,qt)=>Et+Math.PI*qt*qt,0),Ot=Math.PI/(3+2*Math.SQRT2),Qt=Math.sqrt(Yt/Ot),ge=2*Math.max(...It);return Math.max(Qt,ge)},Dt=function(It,Yt=0){if(!It||It.length===0)return 0;const Ot=[...It].sort((Ze,We)=>We-Ze),Qt=Ot.reduce((Ze,We)=>Ze+Math.PI*Math.pow(We+Yt/2,2),0);let ge=Math.max(Ot[0]*2+Yt,Math.sqrt(Qt/.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 It=t.groupBy??"",Yt=A.filter(ve=>ve[It]===y),Ot=Yt.map(ve=>ve.r),Qt=Lt(Ot)+20;Dt(Ot,1)+20;const ge=Yt.map(ve=>{const{value:dn,r:_i,x:kr,y:Ue,sortedX:Zn,sortedY:Jn,vx:Ar,vy:pn,...ca}=ve;return{...ca}}),Et=Nt(ge,Qt),qt=A.filter(ve=>ve[It]!==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:Ue,sortedX:Zn,sortedY:Jn,vx:Ar,vy:pn,...ca}=ve;return{...ca}}),Ze=Nt(Ge,Kt),We=ve=>{const dn=ve[It]===y,kr=(dn?Et:Ze).find(ca=>ca.label===ve.label),Ue=kr?.sortedX??0,Zn=dn?rt:dt,Jn=Ue+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(It=>It.sortedX)).force("y",Tn().strength(.5).y(It=>It.sortedY));nt.force("collide",Wr().radius(It=>p?It.r/3:It.r)).alpha(p?y!==""?.065:.075:.225).alphaTarget(0).restart()}else y===""?nt.force("x",Nn().strength(et).x(0)).force("y",Tn().strength(et).y(0)):nt.force("x",Nn().strength(et).x(Lt=>Lt[_t]===y?rt.x:dt.x)).force("y",Tn().strength(et).y(Lt=>Lt[_t]===y?rt.y:dt.y)),nt.alpha(.75).alphaTarget(0),setTimeout(()=>{nt.restart()},500)}const Tt=M==="bubble"||M==="hierarchy"&&a!=="default";function ut(P,rt,dt){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 It=new Map,Yt=new Map,Ot=new Set,Qt=new Map;for(const Et of P.nodes){const qt=M==="hierarchy"?Et.data.name:Et.id;It.set(qt,1/0),Yt.set(qt,null),Ot.add(qt),Qt.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;Qt.get(qt)?.push({node:Bt,weight:Kt}),Qt.get(Bt)?.push({node:qt,weight:Kt})}for(It.set(rt,0);Ot.size>0;){let Et=null,qt=1/0;for(const Bt of Ot){const Kt=It.get(Bt);Kt<qt&&(qt=Kt,Et=Bt)}if(Et===null||Et===dt)break;Ot.delete(Et);for(const Bt of Qt.get(Et)){if(!Ot.has(Bt.node))continue;const Kt=It.get(Et)+Bt.weight;Kt<It.get(Bt.node)&&(It.set(Bt.node,Kt),Yt.set(Bt.node,Et))}}return{distances:It,previous:Yt,path:dt!==void 0?(Et=>{const qt=[];let Bt=Et;for(;Bt!==null;)qt.unshift(Bt),Bt=Yt.get(Bt);return qt})(dt):void 0}}const vt=ut({nodes:A,links:at},n,r),kt=typeof vt=="string",jt=hr(j,qr),Xt="#999";q.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:ie,previous:Jt,path:Ht}=vt,Gt=P=>{if(Array.isArray(Ht)){const rt=M==="network"?P.source.id:P.source.data.name,dt=M==="network"?P.target.id:P.target.data.name;let Lt=!1;for(let Dt=0;Dt<Ht.length-1;Dt++){if(rt===Ht[Dt]&&dt===Ht[Dt+1]){Lt=!0;break}if(dt===Ht[Dt]&&rt===Ht[Dt+1]){Lt=!0;break}}return Lt}return!1},ae=.25,Ct=P=>kt||Gt(P)?1:ae,Rt=P=>kt||Gt(P)?"auto":"none",ft=P=>(kt?K:K&&Gt(P))?P.type?`url(#arrow-${P.type})`:"url(#arrow-arrow)":"",Mt=pt.selectAll("path.link").data(at,function(P,rt){if(M==="hierarchy"){const dt=P.source.data?.name,Lt=P.source.data?.name;return`${dt}-${Lt}`}else if(M==="network"){const dt=P.source.id,Lt=P.target.id;return`${dt}-${Lt}`}return rt}).join(P=>P.append("path").attr("class","link").attr("fill","none").attr("stroke-width",1.5).attr("stroke",rt=>rt.type?Q(rt.type):Xt).style("pointer-events",Rt).attr("marker-end",ft).attr("stroke-opacity",Ct),void 0,P=>P.remove()).attr("stroke",P=>P.type?Q(P.type):Xt).attr("marker-end",ft).attr("stroke-opacity",Ct).style("pointer-events",Rt);function it(P){const rt=Cn(P.source),dt=Gn(P.source),Lt=Cn(P.target),Dt=Gn(P.target);if(O==="straight")return`M${rt},${dt} L${Lt},${Dt}`;const It=Math.hypot(Lt-rt,Dt-dt);return`
143
+ M${rt},${dt}
144
+ A${It},${It} 0 0,1 ${Lt},${Dt}
145
+ `}const mt=P=>{if(typeof vt=="string")return"no path to highlight";const{path:rt}=vt;if(Array.isArray(rt)){const dt=M==="network"?P.id:P.data.name,Lt=rt.indexOf(dt);return Lt===0||Lt===rt.length-1?"source or destination":Lt>-1?"path":"not path member"}return"not path member"},F=P=>M==="hierarchy"?$t(P):M==="network"?P.radius??zt:P.r>0?P.r:0;function yt(P,rt){return M==="hierarchy"?P.data?.name??"":M==="network"?P.id:rt}const At=P=>{if(M==="hierarchy"){const rt=P;if(rt.data.color)return rt.data.color;const{group:dt}=rt.data;return dt!==void 0?Q(String(dt))??"steelblue":"steelblue"}else if(M==="network"){const rt=P.group;return rt!==void 0?Q(String(rt))??"steelblue":"steelblue"}else if(M==="bubble"){const rt=P[_t];return Q(rt)}return"steelblue"},Pt=P=>M==="hierarchy"?P.children?"none":"#fff":Sa(At(P)).darker().toString(),ee=.5,re=P=>{const rt=mt(P);return rt==="no path to highlight"?1:rt==="not path member"?ee:1},lt=P=>{const rt=mt(P);return rt==="no path to highlight"?"auto":rt==="not path member"?"none":"auto"},xt=pt.selectAll("circle.node").data(A,yt).join(P=>P.append("circle").attr("class","node").attr("stroke",rt=>M==="hierarchy"?rt.children?null:"#fff":"none").attr("r",F).attr("fill",At).style("opacity",re).style("pointer-events",lt),void 0,P=>P.remove()).attr("stroke",Pt).attr("r",F).attr("fill",At).style("opacity",re).style("pointer-events",lt);M==="hierarchy"&&a!=="default"&&xt.transition().delay((P,rt)=>Math.random()*500).duration(750).attrTween("r",P=>{const rt=Ae(0,P.r);return Lt=>`${rt(Lt)}`});const St=6,Wt=12,ue=10,Ut="black";xt.on("pointerenter",function(P,rt){if(te(this).style("stroke",Ut),(M==="hierarchy"||M==="bubble")&&L.transition().duration(250).style("opacity",1),M==="network"&&kt){const Lt=Mt.filter(Ot=>Ot.source.id===rt.id).data().map(Ot=>Ot.target.id),It=Mt.filter(Ot=>Ot.target.id===rt.id).data().map(Ot=>Ot.source.id);Mt.filter(Ot=>Ot.source.id!==rt.id&&Ot.target.id!==rt.id).style("opacity",ae);const Yt=[...It,...Lt];se.filter(Ot=>Ot.id!==rt.id&&!Yt.includes(Ot.id)).style("opacity",0),xt.filter(Ot=>Ot.id!==rt.id&&!Yt.includes(Ot.id)).style("opacity",ee),se.filter(Ot=>Ot.id===rt.id).style("font-size",Wt),se.filter(Ot=>Yt.includes(Ot.id)).style("font-size",ue)}else if(M==="hierarchy"){const dt=ht.filter(Dt=>Dt==="name").node();te(dt).text(`${rt.data.name}`);const Lt=ht.filter(Dt=>Dt==="value").node();te(Lt).text(`${Pe(rt.value)}`)}else if(M==="bubble")for(const dt of Z){const Lt=ht.filter(Ot=>Ot===dt).node(),Dt=rt[dt],It=typeof Dt=="number"?Dt.toLocaleString():Dt,Yt=dt==="label"?It.toUpperCase():`${dt}: ${It}`;te(Lt).text(`${Yt}`)}}).on("pointermove",function(P,rt){le(L,{e:P,svg:$})}).on("pointerleave",function(P,rt){const dt=Pt(rt);te(this).style("stroke",dt),L.transition().duration(250).style("opacity",0),M==="network"&&kt&&(Mt.style("opacity",Ct),xt.style("opacity",re),se.style("opacity",ke).style("font-size",hn))}),Mt.on("pointerenter",function(P,rt){if(te(this).style("stroke",rt.type?Xe(Q(rt.type))?.darker().toString()??Ut:Ut),M==="network"){L.transition().duration(250).style("opacity",1);const dt=rt.source.id,Lt=rt.target.id;kt&&(se.filter(Qt=>Qt.id!==dt&&Qt.id!==Lt).style("opacity",0),se.filter(Qt=>Qt.id===dt||Qt.id===Lt).style("font-size",ue)),L.transition().duration(250).style("opacity",1);const Dt=ht.filter(Qt=>Qt==="name").node();te(Dt).text(`${dt} ⟶ ${Lt}`);const It=ht.filter(Qt=>Qt==="value").node(),Yt=rt.value,Ot=typeof Yt=="number"?Pe(Yt):"---";te(It).text(`${Ot}`),le(L,{e:P,svg:$})}}).on("pointermove",function(P,rt){M==="network"&&le(L,{e:P,svg:$})}).on("pointerleave",function(P,rt){te(this).style("stroke",rt.type?Q(rt.type):Xt),M==="network"&&(L.transition().duration(250).style("opacity",0),kt&&se.style("opacity",ke).style("font-size",hn))});const ke=P=>{const rt=F(P);if(Tt)return rt<15?0:1;const dt=mt(P);return dt==="no path to highlight"||dt==="source or destination"||dt==="path"?1:.25},hn=P=>{const rt=mt(P);return rt==="no path to highlight"?St:rt==="source or destination"?Wt:rt==="path"?ue:St},to=e?[]:A,se=pt.selectAll("text.label").data(to,yt).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(rt=>M==="hierarchy"?rt.data.name:M==="network"?rt.id:rt.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"),xt.raise(),se.raise(),nt.on("tick",()=>{Mt.attr("d",P=>it(P)),xt.attr("cx",Cn).attr("cy",Gn),se.attr("transform",P=>{if(M!=="hierarchy"||a!=="default")return"";const rt=P;if(rt.depth===0)return"";const dt=P.x??0,Lt=P.y??0,Dt=rt.baseX??0;if(!Un(dt)||!Un(Lt)||!Un(Dt))return"";const It=Dt*180/Math.PI-90,Yt=Dt>=Math.PI?180:0;return`rotate(${It+Yt}, ${dt}, ${Lt})`}).attr("x",P=>{const rt=M==="hierarchy"&&a==="default"?P.baseX<Math.PI==!P.children?6:-6:0,dt=Cn(P);return(Un(dt)?dt:0)+rt}).attr("y",P=>{const rt=Gn(P);return(Un(rt)?rt:0)+(M==="network"?zt+4:0)})});const Cn=P=>{const rt=Un(P.x)?P.x:0,dt=F(P),Lt=-S/2+dt,Dt=S/2-dt;return Math.min(Math.max(rt,Lt),Dt)},Gn=P=>{const rt=Un(P.y)?P.y:0,dt=F(P),Lt=-w/2+dt,Dt=w/2-dt;return Math.min(Math.max(rt,Lt),Dt)},wi=nd().on("start",oa).on("drag",la).on("end",ct);xt.call(wi);function oa(P,rt){P.active||(M==="bubble"&&p&&nt.force("collide",Wr().radius(dt=>dt.r)),nt.alphaTarget(.3).restart()),rt.fx=rt.x,rt.fy=rt.y}function la(P,rt){rt.fx=P.x,rt.fy=P.y}function ct(P,rt){P.active||(M==="bubble"&&nt.force("collide",Wr().radius(dt=>p?dt.r/3:dt.r)),nt.alphaTarget(0)),rt.fx=null,rt.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
+ ${J["controls-label"]}
147
+ `,style:{paddingRight:"12px"},children:[m.jsx("input",{type:"checkbox",className:J["controls-checkbox"],checked:p,onChange:H=>{k(H.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"})}));